1 /* PlaylistView.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 22 /* 23 * PlaylistView.h 24 * 25 * Created on: Jun 27, 2011 26 * Author: Michael Lugmair (Lucio Carreras) 27 */ 28 29 #ifndef PLAYLISTVIEW_H_ 30 #define PLAYLISTVIEW_H_ 31 32 #include "Gui/Utils/SearchableWidget/SearchableView.h" 33 #include "Gui/Utils/Widgets/Dragable.h" 34 #include "Gui/Utils/Widgets/WidgetTemplate.h" 35 36 #include "Gui/InfoDialog/InfoDialogContainer.h" 37 38 #include "Utils/Playlist/PlaylistFwd.h" 39 #include "Utils/MetaData/MetaDataFwd.h" 40 #include "Utils/Pimpl.h" 41 42 class QPoint; 43 class DynamicPlaybackChecker; 44 class PlaylistCreator; 45 46 namespace Playlist 47 { 48 /** 49 * @brief The PlaylistView class 50 * @ingroup GuiPlaylists 51 */ 52 class View : 53 public SearchableTableView, 54 public InfoDialogContainer, 55 private Gui::Dragable 56 { 57 Q_OBJECT 58 PIMPL(View) 59 60 signals: 61 void sigDoubleClicked(int row); 62 void sigBookmarkPressed(int trackIdx, Seconds timestamp); 63 64 public: 65 View(PlaylistCreator* playlistCreator, PlaylistPtr playlist, DynamicPlaybackChecker* dynamicPlaybackChecker, QWidget* parent=nullptr); 66 ~View() override; 67 68 void deleteSelectedTracks(); 69 70 /** 71 * @brief called from GUI_Playlist when data has not been dropped 72 * directly into the view widget. Insert on first row then 73 * @param event 74 */ 75 void dropEventFromOutside(QDropEvent* event); 76 77 public slots: 78 void clear(); 79 void removeSelectedRows(); 80 void gotoRow(int row); 81 82 private slots: 83 void refresh(); 84 void asyncDropFinished(); 85 void ratingChanged(Rating rating); 86 void columnsChanged(); 87 void showRatingChanged(); 88 void findTrackTriggered(); 89 void bookmarkTriggered(Seconds timestamp); 90 void moveSelectedRowsUp(); 91 void moveSelectedRowsDown(); 92 void playSelectedTrack(); 93 void jumpToCurrentTrack(); 94 void playlistBusyChanged(bool isBusy); 95 void currentScannedFileChanged(const QString& currentFile); 96 void currentTrackChanged(int index); 97 98 private: 99 void initContextMenu(); 100 void initShortcuts(); 101 void handleDrop(QDropEvent* event); 102 103 protected: 104 MD::Interpretation metadataInterpretation() const override; 105 MetaDataList infoDialogData() const override; 106 QWidget* getParentWidget() override; 107 108 int mapModelIndexToIndex(const QModelIndex& idx) const override; 109 ModelIndexRange mapIndexToModelIndexes(int idx) const override; 110 111 void skinChanged() override; 112 113 /** 114 * @brief we start the drag action, all lines has to be cleared 115 * @param the event 116 */ 117 void dragLeaveEvent(QDragLeaveEvent* event) override; 118 void dragEnterEvent(QDragEnterEvent* event) override; 119 void dragMoveEvent(QDragMoveEvent* event) override; 120 void dropEvent(QDropEvent* event) override; 121 void mousePressEvent(QMouseEvent* event) override; 122 void mouseDoubleClickEvent(QMouseEvent* event) override; 123 void keyPressEvent(QKeyEvent* event) override; 124 bool viewportEvent(QEvent* event) override; 125 void contextMenuEvent(QContextMenuEvent* e) override; 126 }; 127 } 128 129 #endif /* PlaylistView_H_ */ 130