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