Sayonara Player
FileListModel.h
1 /* FileListModel.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef FILE_LIST_MODEL_H
22 #define FILE_LIST_MODEL_H
23 
24 #include "Gui/Utils/SearchableWidget/SearchableModel.h"
25 #include "Utils/Pimpl.h"
26 
27 #include <QModelIndex>
28 
29 class QPixmap;
30 class QVariant;
31 
32 class LocalLibrary;
33 
34 namespace Directory
35 {
36  class IconWorkerThread : public QObject
37  {
38  Q_OBJECT
39  PIMPL(IconWorkerThread)
40 
41  signals:
42  void sigFinished(const QString& path);
43 
44  public:
45  IconWorkerThread(const QSize& targetSize, const QString& filename);
47 
48  QPixmap pixmap() const;
49 
50  public slots:
51  void start();
52  };
53 
58  class FileListModel :
60  {
61  Q_OBJECT
62  PIMPL(FileListModel)
63 
64  public:
65  explicit FileListModel(LocalLibrary* localLibrary, QObject* parent=nullptr);
66  ~FileListModel() override;
67 
68  QString parentDirectory() const;
69  void setParentDirectory(const QString& dir);
70 
71  LibraryId libraryId() const;
72  QStringList files() const;
73 
74  QModelIndexList searchResults(const QString& substr) override;
75 
76  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const override;
77  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
78 
79  int rowCount(const QModelIndex& parent=QModelIndex()) const override;
80  int columnCount(const QModelIndex& parent=QModelIndex()) const override;
81 
82  QMimeData* mimeData(const QModelIndexList &indexes) const override;
83  Qt::ItemFlags flags(const QModelIndex& index) const override;
84 
85  private:
86  bool checkRowForSearchstring(int row, const QString& substr) const;
87 
88  private slots:
89  void pixmapFetched(const QString& path);
90  };
91 }
92 
93 #endif
The FileListModel class.
Definition: FileListModel.h:60
Definition: FileListModel.h:37
Definition: LocalLibrary.h:38
Definition: SearchableModel.h:58