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