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 FINDERWIDGET_H 22 #define FINDERWIDGET_H 23 24 #include <QtWidgets> 25 26 class Breadcrumb; 27 class PlaylistModel; 28 class PlaylistView; 29 class SegmentedControl; 30 class ArtistListView; 31 class ArtistSqlModel; 32 class AlbumListView; 33 class AlbumSqlModel; 34 class TrackSqlModel; 35 class FileSystemModel; 36 class FilteringFileSystemModel; 37 class FileSystemFinderView; 38 class Track; 39 class SearchModel; 40 class SearchView; 41 class Artist; 42 class Album; 43 class FinderListView; 44 class GenresModel; 45 46 namespace Finder { 47 48 enum FinderDataRoles { 49 ItemTypeRole = Qt::UserRole, 50 DataObjectRole, 51 ItemObjectRole, 52 ActiveItemRole 53 }; 54 55 enum FinderItemTypes { 56 ItemTypeArtist = 1, 57 ItemTypeAlbum, 58 ItemTypeTrack, 59 ItemTypeFolder, 60 ItemTypeGenre, 61 ItemTypeDecade 62 }; 63 64 } // namespace Finder 65 66 class FinderWidget : public QWidget { 67 Q_OBJECT 68 69 public: 70 FinderWidget(QWidget *parent); setPlaylistModel(PlaylistModel * playlistModel)71 void setPlaylistModel(PlaylistModel *playlistModel) { this->playlistModel = playlistModel; } setPlaylistView(PlaylistView * playlistView)72 void setPlaylistView(PlaylistView *playlistView) { this->playlistView = playlistView; } 73 void appear(); 74 void disappear(); 75 void showSearch(const QString &query); 76 void addTracksAndPlay(const QVector<Track *> &tracks); 77 void artistActivated(Artist *artist); 78 void albumActivated(Album *album); 79 void trackActivated(Track *track); 80 81 private slots: 82 void goBack(); 83 void folderGoBack(); 84 void showArtists(); 85 void showAlbums(); 86 void showGenres(); 87 void showFolders(); 88 89 void artistActivated(const QModelIndex &index); 90 void artistPlayed(const QModelIndex &index); 91 92 void albumActivated(const QModelIndex &index); 93 void albumPlayed(const QModelIndex &index); 94 95 void trackActivated(const QModelIndex &index); 96 97 void folderActivated(const QModelIndex &index); 98 void folderPlayed(const QModelIndex &index); 99 100 void genreActivated(const QModelIndex &index); 101 void genrePlayed(const QModelIndex &index); 102 103 private: 104 void restoreSavedView(); 105 void setupBar(); 106 void setupArtists(); 107 void setupAlbums(); 108 void setupGenres(); 109 void setupFolders(); 110 void setupTracks(); 111 void setupSearch(); 112 void showWidget(QWidget *widget, bool isRoot); 113 114 SegmentedControl *finderBar; 115 QAction *artistsAction; 116 QAction *albumsAction; 117 QAction *genresAction; 118 QAction *foldersAction; 119 120 QStack<QWidget *> history; 121 QStackedWidget *stackedWidget; 122 Breadcrumb *breadcrumb; 123 Breadcrumb *folderBreadcrumb; 124 125 PlaylistModel *playlistModel; 126 PlaylistView *playlistView; 127 128 FileSystemFinderView *fileSystemView; 129 FileSystemModel *fileSystemModel; 130 FilteringFileSystemModel *filteringFileSystemModel; 131 132 ArtistListView *artistListView; 133 ArtistSqlModel *artistListModel; 134 135 AlbumListView *albumListView; 136 AlbumSqlModel *albumListModel; 137 138 FinderListView *genresListView; 139 GenresModel *genresModel; 140 141 QListView *trackListView; 142 TrackSqlModel *trackListModel; 143 144 SearchModel *searchModel; 145 SearchView *searchView; 146 }; 147 148 #endif // FINDERWIDGET_H 149