Sayonara Player
Loading...
Searching...
No Matches
GenreView.h
1/* GenreView.h */
2
3/* Copyright (C) 2011-2024 Michael Lugmair (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
30class Genre;
31class TreeDelegate;
32class LocalLibrary;
33class QItemSelection;
34
35namespace Util
36{
37 template<typename T>
38 class Tree;
39}
40
41namespace Library
42{
47 class GenreView :
48 public Gui::WidgetTemplate<QTreeWidget>
49 {
51
52 Q_OBJECT
53 PIMPL(GenreView)
54
55 signals:
56 void sigProgress(const QString& name, int progress);
57 void sigSelectedChanged(const QStringList& genres);
58 void sigInvalidGenreSelected();
59
60 private:
61 using Parent::activated;
62 using Parent::clicked;
63 using Parent::pressed;
64
65 public:
66 explicit GenreView(QWidget* parent = nullptr);
67 ~GenreView() override;
68
69 void init(LocalLibrary* library);
70 void reloadGenres();
71
72 static QString invalidGenreName();
73
74 private:
75 void initContextMenu();
76
77 void setGenres(const Util::Set<Genre>& genres);
78
79 [[maybe_unused]] QTreeWidgetItem* findGenre(const QString& genre);
80
81 private slots: // NOLINT(*-redundant-access-specifiers)
82 void expandCurrentItem();
83
84 void progressChanged(int progress);
85 void updateFinished();
86
87 void newPressed();
88 void renamePressed();
89 void deletePressed();
90
91 void switchTreeList();
92
93 void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override;
94
95 protected:
96 void languageChanged() override;
97 void dragEnterEvent(QDragEnterEvent* e) override;
98 void dragMoveEvent(QDragMoveEvent* e) override;
99 void dragLeaveEvent(QDragLeaveEvent* e) override;
100 void dropEvent(QDropEvent* e) override;
101 void contextMenuEvent(QContextMenuEvent* e) override;
102 };
103
105 public QTreeWidgetItem
106 {
107 public:
108 GenreTreeItem(QTreeWidgetItem* parent, const QStringList& text);
109 GenreTreeItem(QTreeWidget* parent, const QStringList& text, bool isInvalidGenre);
110
111 void setInvalidGenre(bool b);
112 };
113}
114
115#endif // LIBRARYGENREVIEW_H
Definition: Genre.h:31
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:86
Definition: GenreView.h:106
The GenreView class.
Definition: GenreView.h:49
Definition: LocalLibrary.h:38
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37
Helper functions.
Definition: MetaTypeRegistry.h:25