digiKam
labelstreeview.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2014-05-17
7  * Description : Album Labels Tree View.
8  *
9  * Copyright (C) 2014-2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
10  * Copyright (C) 2014-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_ALBUM_LABELS_TREEVIEW_H
26 #define DIGIKAM_ALBUM_LABELS_TREEVIEW_H
27 
28 // Qt includes
29 
30 #include <QTreeWidget>
31 
32 // Local includes
33 
34 #include "coredbconstants.h"
35 #include "album.h"
36 #include "statesavingobject.h"
37 #include "itemlisterrecord.h"
38 
39 namespace Digikam
40 {
41 
42 class LabelsTreeView : public QTreeWidget, public StateSavingObject
43 {
44  Q_OBJECT
45 
46 public:
47 
48  enum Labels
49  {
50  Ratings = 0,
52  Colors
53  };
54 
55 public:
56 
57  explicit LabelsTreeView(QWidget* const parent = nullptr, bool setCheckable = false);
58  ~LabelsTreeView() override;
59 
64  bool isCheckable() const;
65 
69  bool isLoadingState() const;
70 
75  QPixmap goldenStarPixmap(bool fillin=true) const;
76 
84  QPixmap colorRectPixmap(const QColor& color) const;
85 
94  QHash<Labels, QList<int> > selectedLabels();
95 
100  void doLoadState() override;
101  void doSaveState() override;
102 
111  void restoreSelectionFromHistory(QHash<Labels, QList<int> > neededLabels);
112 
117  void setCurrentAlbum();
118 
119 private:
120 
124  void initTreeView();
125  void initRatingsTree();
126  void initPicksTree();
127  void initColorsTree();
128 
129 private Q_SLOTS:
130 
131  void slotSettingsChanged();
132 
133 Q_SIGNALS:
134 
136 
137 private:
138 
139  class Private;
140  Private* const d;
141 };
142 
143 } // namespace Digikam
144 
145 #endif // DIGIKAM_ALBUM_LABELS_TREEVIEW_H
Definition: labelstreeview.h:43
void doLoadState() override
Loading and saving state function inherited from StateSavingObject.
Definition: labelstreeview.cpp:254
QHash< Labels, QList< int > > selectedLabels()
Provide the current selection from the tree-view hierarchy.
Definition: labelstreeview.cpp:197
QPixmap colorRectPixmap(const QColor &color) const
Creates a 30*30 rectangular pixmap with specific color.
Definition: labelstreeview.cpp:181
Labels
Definition: labelstreeview.h:49
@ Ratings
Definition: labelstreeview.h:50
@ Colors
Definition: labelstreeview.h:52
@ Picks
Definition: labelstreeview.h:51
void setCurrentAlbum()
Emits a signal to the search handler to set the Current album from currently selected labels.
Definition: labelstreeview.cpp:354
void doSaveState() override
Definition: labelstreeview.cpp:326
void restoreSelectionFromHistory(QHash< Labels, QList< int > > neededLabels)
Restores the selection state from the AlbumHistory class.
Definition: labelstreeview.cpp:504
QPixmap goldenStarPixmap(bool fillin=true) const
Definition: labelstreeview.cpp:155
LabelsTreeView(QWidget *const parent=nullptr, bool setCheckable=false)
Definition: labelstreeview.cpp:102
~LabelsTreeView() override
Definition: labelstreeview.cpp:140
bool isCheckable() const
Definition: labelstreeview.cpp:145
bool isLoadingState() const
Definition: labelstreeview.cpp:150
Definition: statesavingobject.h:76
Definition: datefolderview.cpp:43