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/MetaData/MetaDataFwd.h"
41 #include "Utils/typedefs.h"
42 #include "Utils/Set.h"
43 #include "Utils/Pimpl.h"
44 
45 class AbstractLibrary;
46 class LibraryContextMenu;
47 class QStringList;
48 class QMenu;
49 
50 namespace Library
51 {
52  class ColumnHeaderList;
53 
54  class ItemModel;
55 
56  class ItemView :
57  public SearchableTableView,
58  public InfoDialogContainer,
59  protected Dragable,
60  protected ShortcutWidget
61  {
62  Q_OBJECT
63  PIMPL(ItemView)
64 
65  protected:
66  struct MergeData
67  {
68  SP::Set<Id> source_ids;
69  Id target_id;
70 
71  bool is_valid() const;
72  };
73 
74  signals:
75  void sig_all_selected();
76  void sig_delete_clicked();
77  void sig_play_clicked();
78  void sig_play_next_clicked();
79  void sig_play_new_tab_clicked();
80  void sig_append_clicked();
81  void sig_refresh_clicked();
82  void sig_import_files(const QStringList& files);
83  void sig_sel_changed(const IndexSet& indexes);
84  void sig_merge(const SP::Set<Id>& ids, int target_id);
85 
86  private:
87  ItemView(const ItemView& other)=delete;
88  ItemView& operator =(const ItemView& other)=delete;
89 
90  void show_context_menu_actions(LibraryContextMenu::Entries entries);
91 
92  using SearchableTableView::set_model;
93 
94  public:
95  explicit ItemView(QWidget* parent=nullptr);
96  virtual ~ItemView();
97 
98  void set_item_model(ItemModel* model);
99 
100  virtual LibraryContextMenu::Entries context_menu_entries() const;
101 
102 
104  QMimeData* dragable_mimedata() const override;
105  QPixmap drag_pixmap() const override;
106 
107  void set_metadata_interpretation(MD::Interpretation type);
108  void set_selection_type(SelectionViewInterface::SelectionType type) override;
109 
110  void show_clear_button(bool visible);
111  void use_clear_button(bool yesno);
112 
113  bool is_valid_drag_position(const QPoint &p) const override;
114 
115 
116  protected:
117  // Events implemented in LibraryViewEvents.cpp
118  virtual void mousePressEvent(QMouseEvent* event) override;
119  virtual void mouseMoveEvent(QMouseEvent* event) override;
120  virtual void contextMenuEvent(QContextMenuEvent* event) override;
121 
122  virtual void dragEnterEvent(QDragEnterEvent *event) override;
123  virtual void dragMoveEvent(QDragMoveEvent *event) override;
124  virtual void dropEvent(QDropEvent* event) override;
125  virtual void changeEvent(QEvent* event) override;
126  virtual void keyPressEvent(QKeyEvent* event) override;
127  virtual void resizeEvent(QResizeEvent *event) override;
128 
129  virtual void selected_items_changed (const QItemSelection& selected, const QItemSelection& deselected );
130 
131  virtual void init_context_menu();
132  virtual void init_context_menu_custom_type(LibraryContextMenu* menu);
133 
134  LibraryContextMenu* context_menu() const;
135 
136  ItemModel* item_model() const;
137  virtual AbstractLibrary* library() const;
138 
139  // InfoDialogContainer
140  virtual MD::Interpretation metadata_interpretation() const override final;
141  MetaDataList info_dialog_data() const override;
142 
143  virtual void selection_changed(const IndexSet& indexes);
144  virtual void import_requested(const QStringList& files);
145 
146  MergeData calc_mergedata() const;
147  virtual void run_merge_operation(const MergeData& md);
148 
149 
150  protected slots:
151  virtual void show_context_menu(const QPoint&);
152  virtual void merge_action_triggered();
153  virtual void play_clicked();
154  virtual void play_new_tab_clicked();
155  virtual void play_next_clicked();
156  virtual void delete_clicked();
157  virtual void append_clicked();
158  virtual void refresh_clicked();
159  virtual void cover_view_toggled();
160  virtual void album_artists_toggled();
161  virtual void fill();
162 
163  public:
164  void resize_rows_to_contents();
165  void resize_rows_to_contents(int first_row, int count);
166  };
167 }
168 
169 #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:36
Definition: ItemView.h:66
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:47
Definition: AbstractLibrary.h:47
The MetaDataList class.
Definition: MetaDataList.h:38
The Dragable class.
Definition: Dragable.h:37
QMimeData * dragable_mimedata() const override
An interface class needed when implementing a library plugin.
Definition: CachingThread.h:31
Definition: ItemView.h:56
Definition: ItemModel.h:39
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...