Sayonara Player
LibraryGenreView.h
1 /* LibraryGenreView.h */
2 
3 /* Copyright (C) 2011-2016 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 #ifndef LIBRARYGENREVIEW_H
24 #define LIBRARYGENREVIEW_H
25 
26 
27 #include <QMap>
28 #include <QTreeWidget>
29 #include <QThread>
30 
31 #include <QItemSelectionModel>
32 
33 #include <QDragEnterEvent>
34 #include <QDragMoveEvent>
35 #include <QDropEvent>
36 #include <QDragLeaveEvent>
37 #include <QShowEvent>
38 
39 class CustomMimeData;
40 class MetaDataList;
42 class TagEdit;
43 
44 template<typename T>
45 class Tree;
46 class TreeDelegate;
47 
48 typedef Tree<QString> GenreNode;
49 
50 
51 
52 class LibraryGenreView : public QTreeWidget
53 {
54  Q_OBJECT
55 
56 signals:
57  void sig_progress(const QString& message, int progress);
58 
59 public:
60  LibraryGenreView(QWidget* parent=nullptr);
62 
63  QSize sizeHint() const override;
64  void reload_genres();
65  int get_row_count() const;
66 
67 private:
68 
69  GenreNode* _genres=nullptr;
70  TreeDelegate* _delegate=nullptr;
71  TagEdit* _tag_edit=nullptr;
72  QStringList _expanded_items;
73  bool _filled;
74 
75 private:
76  void fill_list(const QStringList& genres);
77  void init_data(const QStringList& genres);
78  void insert_genres(QTreeWidgetItem* parent_item, GenreNode* node);
79 
80 private slots:
81  void update_genre_tags_finished();
82  void item_expanded(QTreeWidgetItem* item);
83  void item_collapsed(QTreeWidgetItem* item);
84 
85  void progress_changed(int progress);
86 
87  void metadata_changed(const MetaDataList& v_md_old, const MetaDataList& v_md_new);
88 
89 
90 protected:
91  void keyPressEvent(QKeyEvent* e) override;
92  void dragEnterEvent(QDragEnterEvent* e) override;
93  void dragMoveEvent(QDragMoveEvent* e) override;
94  void dragLeaveEvent(QDragLeaveEvent* e) override;
95  void dropEvent(QDropEvent* e) override;
96 };
97 
98 #endif // LIBRARYGENREVIEW_H
The TagEdit class.
Definition: TagEdit.h:38
Definition: LibraryGenreView.h:52
Definition: MetaDataList.h:46
The MetaDataChangeNotifier class (Singleton)
Definition: MetaDataChangeNotifier.h:33
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:34
The TreeDelegate class.
Definition: TreeDelegate.h:32
The Tree class.
Definition: LibraryGenreView.h:45