1 /* $BEGIN_LICENSE 2 3 This file is part of Musique. 4 Copyright 2013, Flavio Tordini <flavio.tordini@gmail.com> 5 6 Musique 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 Musique 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 Musique. If not, see <http://www.gnu.org/licenses/>. 18 19 $END_LICENSE */ 20 21 #ifndef SEARCHMODEL_H 22 #define SEARCHMODEL_H 23 24 #include <QtWidgets> 25 26 class ArtistSqlModel; 27 class AlbumSqlModel; 28 class TrackSqlModel; 29 class FileSystemModel; 30 class FinderWidget; 31 class Item; 32 33 class SearchModel : public QAbstractListModel { 34 Q_OBJECT 35 36 public: 37 SearchModel(QObject *parent = nullptr); 38 void search(const QString &query); 39 40 public slots: refreshIndex(const QModelIndex & index)41 void refreshIndex(const QModelIndex &index) { emit dataChanged(index, index); } 42 43 protected: 44 int rowCount(const QModelIndex & /* parent */) const; 45 QVariant data(const QModelIndex &item, int role) const; 46 int columnCount(const QModelIndex &parent = QModelIndex()) const { return 1; } 47 48 private slots: 49 void itemActivated(const QModelIndex &index); 50 void itemPlayed(const QModelIndex &index); 51 52 private: 53 Item *itemAt(const QModelIndex &index) const; 54 55 ArtistSqlModel *artistListModel; 56 AlbumSqlModel *albumListModel; 57 TrackSqlModel *trackListModel; 58 FileSystemModel *fileSystemModel; 59 60 // drag and drop 61 Qt::ItemFlags flags(const QModelIndex &index) const; 62 QStringList mimeTypes() const; 63 Qt::DropActions supportedDropActions() const; 64 QMimeData *mimeData(const QModelIndexList &indexes) const; 65 66 FinderWidget *finder; 67 }; 68 69 #endif // SEARCHMODEL_H 70