Sayonara Player
GenreView.h
1 /* GenreView.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 #ifndef LIBRARYGENREVIEW_H
22 #define LIBRARYGENREVIEW_H
23 
24 #include <QTreeWidget>
25 
26 #include "GUI/Utils/Widgets/WidgetTemplate.h"
27 #include "GUI/Utils/SearchableWidget/SearchableView.h"
28 #include "Utils/Pimpl.h"
29 #include "Utils/SetFwd.h"
30 
31 class MetaDataList;
32 class Genre;
33 class TreeDelegate;
34 class QStringList;
35 class LocalLibrary;
36 
37 namespace SP
38 {
39  template<typename T>
40  class Tree;
41 }
42 
44 
45 namespace Library
46 {
47  class GenreView :
48  public Gui::WidgetTemplate<QTreeWidget>
49  {
50  Q_OBJECT
51  PIMPL(GenreView)
52 
53  signals:
54  void sig_progress(const QString& message, int progress);
55  void sig_genres_reloaded();
56 
57  public:
58  explicit GenreView(QWidget* parent=nullptr);
59  ~GenreView();
60 
61  void init(LocalLibrary* library);
62  void reload_genres();
63  bool has_items() const;
64 
65  private:
66  void set_genres(const SP::Set<Genre>& genres);
67  void build_genre_data_tree(const SP::Set<Genre>& genres);
68  void populate_widget(QTreeWidgetItem* parent_item, GenreNode* node);
69 
70  QTreeWidgetItem* find_genre(const QString& genre);
71 
72  void init_context_menu();
73 
74  private slots:
75  void item_expanded(QTreeWidgetItem* item);
76  void item_collapsed(QTreeWidgetItem* item);
77  void expand_current_item();
78 
79  void progress_changed(int progress);
80  void update_finished();
81 
82  void new_pressed();
83  void rename_pressed();
84  void delete_pressed();
85 
86  void tree_action_changed();
87  void tree_action_toggled(bool b);
88 
89 
90  protected:
91  void language_changed() override;
92 
93  void dragEnterEvent(QDragEnterEvent* e) override;
94  void dragMoveEvent(QDragMoveEvent* e) override;
95  void dragLeaveEvent(QDragLeaveEvent* e) override;
96  void dropEvent(QDropEvent* e) override;
97  void contextMenuEvent(QContextMenuEvent* e) override;
98  };
99 }
100 
101 #endif // LIBRARYGENREVIEW_H
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:47
Definition: LocalLibrary.h:35
The MetaDataList class.
Definition: MetaDataList.h:38
Definition: GenreView.h:47
The Tree class.
Definition: GenreView.h:40
Definition: Genre.h:29
An interface class needed when implementing a library plugin.
Definition: CachingThread.h:31
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:38