LMMS
Loading...
Searching...
No Matches
FileSearchJob.h
Go to the documentation of this file.
1/*
2 * FileSearchJob.h
3 *
4 * Copyright (c) 2025 saker <sakertooth@gmail.com>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_GUI_FILE_SEARCH_JOB_H
26#define LMMS_GUI_FILE_SEARCH_JOB_H
27
28#include <QDir>
29#include <QObject>
30#include <QString>
31#include <future>
32
33namespace lmms::gui {
36class FileSearchJob : public QObject
37{
38 Q_OBJECT
39public:
41 struct Task
42 {
43 QString filter;
44 QStringList paths;
45 QStringList extensions;
46 QFlags<QDir::Filter> dirFilters;
47 };
48
50 FileSearchJob(QObject* parent = nullptr);
51
54
55 FileSearchJob(const FileSearchJob&) = delete;
59
63 void search(Task task);
64
65signals:
67 void foundMatch(const QString& path);
68
70 void started();
71
73 void finished();
74
75private:
76 void runSearch(Task task);
77 std::future<void> m_task;
78 std::atomic_flag m_stop = ATOMIC_FLAG_INIT;
79};
80} // namespace lmms::gui
81
82#endif // LMMS_GUI_FILE_SEARCH_JOB_H
void foundMatch(const QString &path)
Emitted when the search job has found a matching path.
FileSearchJob(QObject *parent=nullptr)
Create a search job with the given parent (if any).
Definition FileSearchJob.cpp:33
void search(Task task)
Definition FileSearchJob.cpp:47
FileSearchJob & operator=(FileSearchJob &&)=delete
FileSearchJob(const FileSearchJob &)=delete
void runSearch(Task task)
Definition FileSearchJob.cpp:60
FileSearchJob(FileSearchJob &&)=delete
FileSearchJob & operator=(const FileSearchJob &)=delete
std::atomic_flag m_stop
Definition FileSearchJob.h:78
void started()
Emitted when the search job has started searching.
void finished()
Emitted when the search job has finished searching.
std::future< void > m_task
Definition FileSearchJob.h:77
~FileSearchJob()
Stop processing and destroys the object.
Definition FileSearchJob.cpp:38
static uintptr_t parent
Definition pugl.h:1644
Definition AudioPortAudio.cpp:223
Represents a search task to be carried out by the search job.
Definition FileSearchJob.h:42
QStringList paths
The filter to be tokenized.
Definition FileSearchJob.h:44
QFlags< QDir::Filter > dirFilters
The list of allowed extensions.
Definition FileSearchJob.h:46
QString filter
Definition FileSearchJob.h:43
QStringList extensions
The list of paths to search recursively through.
Definition FileSearchJob.h:45