Sayonara Player
ItemView.h
1 /* View.h */
2 
3 /* Copyright (C) 2011-2019 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: 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 sig_all_selected();
64  void sig_delete_clicked();
65  void sig_play_clicked();
66  void sig_play_next_clicked();
67  void sig_play_new_tab_clicked();
68  void sig_append_clicked();
69  void sig_refresh_clicked();
70  void sig_reload_clicked();
71  void sig_import_files(const QStringList& files);
72  void sig_sel_changed(const IndexSet& indexes);
73  void sig_merge(const Util::Set<Id>& ids, int target_id);
74 
75  private:
76  ItemView(const ItemView& other)=delete;
77  ItemView& operator =(const ItemView& other)=delete;
78 
79  void show_context_menu_actions(Library::ContextMenu::Entries entries);
80 
81  using SearchableTableView::set_model;
82 
83  public:
84  explicit ItemView(QWidget* parent=nullptr);
85  virtual ~ItemView() override;
86 
87  void set_item_model(ItemModel* model);
88 
89  virtual Library::ContextMenu::Entries context_menu_entries() const;
90 
92  QMimeData* dragable_mimedata() const override;
93  QPixmap drag_pixmap() const override;
94 
95  void set_selection_type(SelectionViewInterface::SelectionType type) override;
96  bool is_valid_drag_position(const QPoint &p) const override;
97 
98  void show_clear_button(bool visible);
99  void use_clear_button(bool yesno);
100 
101  void resize_rows_to_contents();
102  void resize_rows_to_contents(int first_row, int count);
103 
104  protected:
105  // Events implemented in LibraryViewEvents.cpp
106  virtual void mousePressEvent(QMouseEvent* event) override;
107  virtual void mouseMoveEvent(QMouseEvent* event) override;
108  virtual void contextMenuEvent(QContextMenuEvent* event) override;
109 
110  virtual void dragEnterEvent(QDragEnterEvent *event) override;
111  virtual void dragMoveEvent(QDragMoveEvent *event) override;
112  virtual void dropEvent(QDropEvent* event) override;
113  virtual void changeEvent(QEvent* event) override;
114  virtual void keyPressEvent(QKeyEvent* event) override;
115  virtual void resizeEvent(QResizeEvent *event) override;
116 
117  virtual void selected_items_changed (const QItemSelection& selected, const QItemSelection& deselected );
118 
119  virtual void init_context_menu();
120  virtual void init_custom_context_menu(Library::ContextMenu* menu);
121 
122  Library::ContextMenu* context_menu() const;
123 
124  ItemModel* item_model() const;
125  virtual AbstractLibrary* library() const;
126 
133  virtual bool is_mergeable() const=0;
134 
135  MetaDataList info_dialog_data() const override;
136 
137  virtual void selection_changed(const IndexSet& indexes);
138  virtual void import_requested(const QStringList& files);
139 
140  virtual void run_merge_operation(const Library::MergeData& md);
141 
142  int viewport_height() const override;
143 
144 
145  protected slots:
146  virtual void show_context_menu(const QPoint&);
147  virtual void merge_action_triggered();
148  virtual void play_clicked();
149  virtual void play_new_tab_clicked();
150  virtual void play_next_clicked();
151  virtual void delete_clicked();
152  virtual void append_clicked();
153  virtual void refresh_clicked();
154  virtual void reload_clicked();
155  virtual void cover_view_toggled();
156  virtual void album_artists_toggled();
157  virtual void filter_extensions_triggered(const QString& extension, bool b);
158  virtual void fill();
159  };
160 }
161 
162 #endif /* ITEM_VIEW_H_ */
Library::ItemView
The main task of the ItemView is to display a context menu for various selections....
Definition: ItemView.h:54
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:35
Library::ItemView::dragable_mimedata
QMimeData * dragable_mimedata() const override
AbstractLibrary
Definition: AbstractLibrary.h:41
Gui::WidgetTemplate
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:84
Library::MergeData
Changes all metadata containing one of the source ids and replaces it with the target id....
Definition: MergeData.h:38
Library::ItemModel
The ItemModel is intended to abstract the various views. It supports searching, selections and a libr...
Definition: ItemModel.h:46
Library
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:32
Library::ItemView::info_dialog_data
MetaDataList info_dialog_data() const override
get the metadata that should be used for the info dialog So for lists, the selected tracks are used h...
InfoDialogContainer
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:61
Gui::Dragable
The Dragable class.
Definition: Dragable.h:38
Library::ContextMenu
Context menu used for Library and playlist windows.
Definition: LibraryContextMenu.h:43
Library::ItemView::is_mergeable
virtual bool is_mergeable() const =0
indicates if multiple ids can be merged into one. For example if the same artist is written in three ...