Sayonara Player
ItemView.h
1 /* View.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  * MyListView.h
24  *
25  * Created on: Jun 26, 2011
26  * Author: Michael Lugmair (Lucio Carreras)
27  */
28 
29 #ifndef ITEM_VIEW_H_
30 #define ITEM_VIEW_H_
31 
32 #include "Gui/Utils/Widgets/Dragable.h"
33 #include "Gui/Utils/SearchableWidget/SearchableView.h"
34 
35 #include "Gui/InfoDialog/InfoDialogContainer.h"
36 #include "Gui/Utils/ContextMenu/LibraryContextMenu.h"
37 
38 #include "Utils/SetFwd.h"
39 #include "Utils/Pimpl.h"
40 
41 class AbstractLibrary;
42 
43 namespace Library
44 {
45  class MergeData;
46  class ItemModel;
47 
54  class ItemView :
55  public SearchableTableView,
56  public InfoDialogContainer,
57  protected Gui::Dragable
58  {
59  Q_OBJECT
60  PIMPL(ItemView)
61 
62  signals:
63  void sigDeleteClicked();
64  void sigPlayClicked();
65  void sigPlayNextClicked();
66  void sigPlayNewTabClicked();
67  void sigAppendClicked();
68  void sigRefreshClicked();
69  void sigReloadClicked();
70  void sigImportFiles(const QStringList& files);
71  void sigSelectionChanged(const IndexSet& indexes);
72 
73  private:
74  ItemView(const ItemView& other)=delete;
75  ItemView& operator =(const ItemView& other)=delete;
76 
77  void showContextMenuActions(Library::ContextMenu::Entries entries);
78 
79  using SearchableTableView::setSearchableModel;
80 
81  public:
82  explicit ItemView(QWidget* parent=nullptr);
83  virtual ~ItemView() override;
84 
85  void setItemModel(ItemModel* model);
86 
87  void showClearButton(bool visible);
88  void useClearButton(bool yesno);
89 
90  void resizeRowsToContents();
91  void resizeRowsToContents(int first_row, int count);
92 
93  virtual Library::ContextMenu::Entries contextMenuEntries() const;
94 
96  QMimeData* dragableMimedata() const override;
97  QPixmap dragPixmap() const override;
98 
99  bool isValidDragPosition(const QPoint &p) const override;
100 
101  protected:
102  // Events implemented in LibraryViewEvents.cpp
103  virtual void mousePressEvent(QMouseEvent* event) override;
104  virtual void contextMenuEvent(QContextMenuEvent* event) override;
105 
106  virtual void dragEnterEvent(QDragEnterEvent* event) override;
107  virtual void dragMoveEvent(QDragMoveEvent* event) override;
108  virtual void dropEvent(QDropEvent* event) override;
109  virtual void changeEvent(QEvent* event) override;
110  virtual void resizeEvent(QResizeEvent* event) override;
111 
112  virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override;
113 
114  Library::ContextMenu* contextMenu() const;
115  virtual void initContextMenu();
116  virtual void initCustomContextMenu(Library::ContextMenu* menu);
117 
118  ItemModel* itemModel() const;
119  virtual AbstractLibrary* library() const;
120 
127  virtual bool isMergeable() const=0;
128 
129  MetaDataList infoDialogData() const override;
130 
131  virtual void selectedItemsChanged(const IndexSet& indexes);
132  virtual void importRequested(const QStringList& files);
133 
134  virtual void runMergeOperation(const Library::MergeData& md);
135 
136  int viewportHeight() const override;
137 
138 
139  protected slots:
140  virtual void showContextMenu(const QPoint&);
141  virtual void mergeActionTriggered();
142  virtual void playClicked();
143  virtual void playNewTabClicked();
144  virtual void playNextClicked();
145  virtual void deleteClicked();
146  virtual void appendClicked();
147  virtual void refreshClicked();
148  virtual void reloadClicked();
149  virtual void albumArtistsToggled();
150  virtual void filterExtensionsTriggered(const QString& extension, bool b);
151  virtual void fill();
152  };
153 }
154 
155 #endif /* ITEM_VIEW_H_ */
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:61
Context menu used for Library and playlist windows.
Definition: LibraryContextMenu.h:43
Changes all metadata containing one of the source ids and replaces it with the target id....
Definition: MergeData.h:38
QMimeData * dragableMimedata() const override
virtual bool isMergeable() const =0
indicates if multiple ids can be merged into one. For example if the same artist is written in three ...
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:84
Definition: AbstractLibrary.h:41
The MetaDataList class.
Definition: MetaDataList.h:35
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
The Dragable class.
Definition: Dragable.h:60
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:30
The main task of the ItemView is to display a context menu for various selections....
Definition: ItemView.h:54
The ItemModel is intended to abstract the various views. It supports searching, selections and a libr...
Definition: ItemModel.h:46
MetaDataList infoDialogData() const override
get the metadata that should be used for the info dialog So for lists, the selected tracks are used h...