1 /* This file is part of Clementine. 2 Copyright 2010, David Sansome <me@davidsansome.com> 3 4 Clementine is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 Clementine is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with Clementine. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef PLAYLISTLISTCONTAINER_H 19 #define PLAYLISTLISTCONTAINER_H 20 21 #include "playlistbackend.h" 22 23 #include <QWidget> 24 25 class QMenu; 26 class QSortFilterProxyModel; 27 class QStandardItemModel; 28 29 class Application; 30 class Playlist; 31 class PlaylistListModel; 32 class Ui_PlaylistListContainer; 33 34 class PlaylistListFilterProxyModel; 35 36 class PlaylistListContainer : public QWidget { 37 Q_OBJECT 38 39 public: 40 PlaylistListContainer(QWidget* parent = nullptr); 41 ~PlaylistListContainer(); 42 43 void SetApplication(Application* app); 44 45 protected: 46 void showEvent(QShowEvent* e); 47 void contextMenuEvent(QContextMenuEvent* e); 48 49 private slots: 50 // From the UI 51 void NewFolderClicked(); 52 void DeleteClicked(); 53 void ItemDoubleClicked(const QModelIndex& index); 54 void SearchTextEdited(const QString& text); 55 56 // From the model 57 void PlaylistPathChanged(int id, const QString& new_path); 58 59 // From the PlaylistManager 60 void PlaylistRenamed(int id, const QString& new_name); 61 // Add playlist if favorite == true 62 void AddPlaylist(int id, const QString& name, bool favorite, const QString *ui_path = nullptr); 63 void RemovePlaylist(int id); 64 void SavePlaylist(); 65 void PlaylistFavoriteStateChanged(int id, bool favorite); 66 void CurrentChanged(Playlist* new_playlist); 67 void ActiveChanged(Playlist* new_playlist); 68 69 // From the Player 70 void ActivePlaying(); 71 void ActivePaused(); 72 void ActiveStopped(); 73 74 private: 75 QStandardItem* ItemForPlaylist(const QString& name, int id); 76 QStandardItem* ItemForFolder(const QString& name) const; 77 void RecursivelySetIcons(QStandardItem* parent) const; 78 79 void RecursivelyFindPlaylists(const QModelIndex& parent, 80 QSet<int>* ids) const; 81 82 void UpdateActiveIcon(int id, const QIcon& icon); 83 84 Application* app_; 85 Ui_PlaylistListContainer* ui_; 86 QMenu* menu_; 87 88 QAction* action_new_folder_; 89 QAction* action_remove_; 90 QAction* action_save_playlist_; 91 92 PlaylistListModel* model_; 93 PlaylistListFilterProxyModel* proxy_; 94 95 bool loaded_icons_; 96 QIcon padded_play_icon_; 97 98 int active_playlist_id_; 99 }; 100 101 #endif // PLAYLISTLISTCONTAINER_H 102