Sayonara Player
ItemView.h
1 /* View.h */
2 
3 /* Copyright (C) 2011-2017 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 #include "GUI/Utils/Shortcuts/ShortcutWidget.h"
38 
39 #include "Utils/Library/Sortorder.h"
40 #include "Utils/Set.h"
41 #include "Utils/Pimpl.h"
42 
43 class AbstractLibrary;
44 
45 namespace Library
46 {
47  class ColumnHeaderList;
48 
49  class ItemModel;
50 
51  class ItemView :
52  public SearchableTableView,
53  public InfoDialogContainer,
54  protected Dragable,
55  protected ShortcutWidget
56  {
57  Q_OBJECT
58  PIMPL(ItemView)
59 
60  protected:
61  class MergeData
62  {
63  PIMPL(MergeData)
64 
65  public:
66  MergeData(const Util::Set<Id>& source_ids, Id target_id, LibraryId library_id);
67  MergeData(const MergeData& other);
68  ~MergeData();
69 
70  MergeData& operator=(const MergeData& other);
71  bool is_valid() const;
72  Util::Set<Id> source_ids() const;
73  Id target_id() const;
74  LibraryId library_id() const;
75  };
76 
77  signals:
78  void sig_all_selected();
79  void sig_delete_clicked();
80  void sig_play_clicked();
81  void sig_play_next_clicked();
82  void sig_play_new_tab_clicked();
83  void sig_append_clicked();
84  void sig_refresh_clicked();
85  void sig_reload_clicked();
86  void sig_import_files(const QStringList& files);
87  void sig_sel_changed(const IndexSet& indexes);
88  void sig_merge(const Util::Set<Id>& ids, int target_id);
89 
90  private:
91  ItemView(const ItemView& other)=delete;
92  ItemView& operator =(const ItemView& other)=delete;
93 
94  void show_context_menu_actions(LibraryContextMenu::Entries entries);
95 
96  using SearchableTableView::set_model;
97 
98  public:
99  explicit ItemView(QWidget* parent=nullptr);
100  virtual ~ItemView();
101 
102  void set_item_model(ItemModel* model);
103 
104  virtual LibraryContextMenu::Entries context_menu_entries() const;
105 
106 
108  QMimeData* dragable_mimedata() const override;
109  QPixmap drag_pixmap() const override;
110 
111  void set_metadata_interpretation(MD::Interpretation type);
112  void set_selection_type(SelectionViewInterface::SelectionType type) override;
113 
114  void show_clear_button(bool visible);
115  void use_clear_button(bool yesno);
116 
117  bool is_valid_drag_position(const QPoint &p) const override;
118 
119  protected:
120  // Events implemented in LibraryViewEvents.cpp
121  virtual void mousePressEvent(QMouseEvent* event) override;
122  virtual void mouseMoveEvent(QMouseEvent* event) override;
123  virtual void contextMenuEvent(QContextMenuEvent* event) override;
124 
125  virtual void dragEnterEvent(QDragEnterEvent *event) override;
126  virtual void dragMoveEvent(QDragMoveEvent *event) override;
127  virtual void dropEvent(QDropEvent* event) override;
128  virtual void changeEvent(QEvent* event) override;
129  virtual void keyPressEvent(QKeyEvent* event) override;
130  virtual void resizeEvent(QResizeEvent *event) override;
131 
132  virtual void selected_items_changed (const QItemSelection& selected, const QItemSelection& deselected );
133 
134  virtual void init_context_menu();
135  virtual void init_context_menu_custom_type(LibraryContextMenu* menu);
136 
137  LibraryContextMenu* context_menu() const;
138 
139  ItemModel* item_model() const;
140  virtual AbstractLibrary* library() const;
141 
142  // InfoDialogContainer
143  virtual MD::Interpretation metadata_interpretation() const override final;
144  MetaDataList info_dialog_data() const override;
145 
146  virtual void selection_changed(const IndexSet& indexes);
147  virtual void import_requested(const QStringList& files);
148 
149  MergeData calc_mergedata() const;
150  virtual void run_merge_operation(const MergeData& md);
151 
152  int viewport_height() const override;
153 
154 
155  protected slots:
156  virtual void show_context_menu(const QPoint&);
157  virtual void merge_action_triggered();
158  virtual void play_clicked();
159  virtual void play_new_tab_clicked();
160  virtual void play_next_clicked();
161  virtual void delete_clicked();
162  virtual void append_clicked();
163  virtual void refresh_clicked();
164  virtual void reload_clicked();
165  virtual void cover_view_toggled();
166  virtual void album_artists_toggled();
167  virtual void filter_extensions_triggered(const QString& extension, bool b);
168  virtual void fill();
169 
170  public:
171  void resize_rows_to_contents();
172  void resize_rows_to_contents(int first_row, int count);
173  };
174 }
175 
176 #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:35
virtual MD::Interpretation metadata_interpretation() const override final
get the interpretation for the metadata. Maybe a list of metadata should be intrepeted as albums whil...
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:78
Definition: AbstractLibrary.h:39
The MetaDataList class.
Definition: MetaDataList.h:37
The Dragable class.
Definition: Dragable.h:37
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
QMimeData * dragable_mimedata() const override
Definition: ItemView.h:61
An interface class needed when implementing a library plugin.
Definition: CachingThread.h:29
Definition: ItemView.h:51
Definition: ItemModel.h:37
Context menu used for Library and playlist windows.
Definition: LibraryContextMenu.h:36
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:32
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...