Sayonara Player
DirectoryModel.h
1
2/* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
3 *
4 * This file is part of sayonara player
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef SEARCHABLEFILETREEMODEL_H
21#define SEARCHABLEFILETREEMODEL_H
22
23#include "Gui/Utils/SearchableWidget/SearchableModel.h"
24#include "Utils/Pimpl.h"
25
26#include <QTreeView>
27#include <QFileSystemModel>
28#include <QSortFilterProxyModel>
29
30namespace Library
31{
32 class Info;
33}
34
36
37namespace Directory
38{
43 class Model :
44 public QSortFilterProxyModel
45 {
46 Q_OBJECT
47 PIMPL(Model)
48
49 signals:
50 void sigBusy(bool b);
51
52 public:
53 explicit Model(LibraryInfoAccessor* libraryInfoAccessor, QObject* parent=nullptr);
54 ~Model() override;
55
56 QModelIndex setDataSource(LibraryId libraryId);
57 QModelIndex setDataSource(const QString& path);
58 LibraryId libraryDataSource() const;
59
60 QString filePath(const QModelIndex& index) const;
61 QModelIndex indexOfPath(const QString& path) const;
62
63 void setFilter(const QString& filter);
64
65 int columnCount(const QModelIndex& parent) const override;
66 QMimeData* mimeData(const QModelIndexList& indexes) const override;
67
68 private slots:
69 void filterTimerTimeout();
70
71 protected:
72 using QSortFilterProxyModel::setFilterRegExp;
73 using QSortFilterProxyModel::setFilterWildcard;
74 using QSortFilterProxyModel::setFilterFixedString;
75
76 bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
77 };
78}
79
80#endif // SEARCHABLEFileTreeView_H
The SearchableFileTreeModel class.
Definition: DirectoryModel.h:45
Definition: LibraryInfoAccessor.h:36
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31