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 
30 namespace Library
31 {
32  class Info;
33 }
34 
35 namespace Directory
36 {
41  class Model :
42  public QSortFilterProxyModel
43  {
44  Q_OBJECT
45  PIMPL(Model)
46 
47  signals:
48  void sigBusy(bool b);
49 
50  public:
51  explicit Model(QObject* parent=nullptr);
52  ~Model() override;
53 
54  QModelIndex setDataSource(LibraryId libraryId);
55  QModelIndex setDataSource(const QString& path);
56  LibraryId libraryDataSource() const;
57 
58  QString filePath(const QModelIndex& index);
59  QModelIndex indexOfPath(const QString& path) const;
60 
61  void setFilter(const QString& filter);
62 
63  int columnCount(const QModelIndex& parent) const override;
64 
65  private slots:
66  void filterTimerTimeout();
67 
68  protected:
69  using QSortFilterProxyModel::setFilterRegExp;
70  using QSortFilterProxyModel::setFilterWildcard;
71  using QSortFilterProxyModel::setFilterFixedString;
72 
73  bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
74  };
75 }
76 
77 #endif // SEARCHABLEFileTreeView_H
Library
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31
Directory::Model
The SearchableFileTreeModel class.
Definition: DirectoryModel.h:43