| 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 |
* SPDX-FileCopyrightText: 2014-2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com> |
| 10 |
* SPDX-FileCopyrightText: 2014-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 11 |
* |
| 12 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 13 |
* |
| 14 |
* ============================================================ */ |
| 15 |
|
| 16 |
#pragma once |
| 17 |
|
| 18 |
// Qt includes |
| 19 |
|
| 20 |
#include <QTreeWidget> |
| 21 |
|
| 22 |
// Local includes |
| 23 |
|
| 24 |
#include "coredbconstants.h" |
| 25 |
#include "album.h" |
| 26 |
#include "statesavingobject.h" |
| 27 |
#include "itemlisterrecord.h" |
| 28 |
|
| 29 |
namespace Digikam |
| 30 |
{ |
| 31 |
|
| 32 |
class LabelsTreeView : public QTreeWidget, public StateSavingObject |
| 33 |
{ |
| 34 |
Q_OBJECT |
| 35 |
|
| 36 |
public: |
| 37 |
|
| 38 |
enum Labels |
| 39 |
{ |
| 40 |
Ratings = 0, |
| 41 |
Picks, |
| 42 |
Colors |
| 43 |
}; |
| 44 |
|
| 45 |
public: |
| 46 |
|
| 47 |
explicit LabelsTreeView(QWidget* const parent = nullptr, bool setCheckable = false); |
| 48 |
~LabelsTreeView() override; |
| 49 |
|
| 50 |
/** |
| 51 |
* @return true if the tree widget is checkable |
| 52 |
* and false if not |
| 53 |
*/ |
| 54 |
bool isCheckable() const; |
| 55 |
|
| 56 |
/** |
| 57 |
* @return true if Loading state function is running |
| 58 |
*/ |
| 59 |
bool isLoadingState() const; |
| 60 |
|
| 61 |
/** |
| 62 |
* @return a Pixmap of a 30*30 pixels golden star used |
| 63 |
* for rating and widget icon |
| 64 |
*/ |
| 65 |
QPixmap goldenStarPixmap(bool fillin=true) const; |
| 66 |
|
| 67 |
/** |
| 68 |
* @brief Creates a 30*30 rectangular pixmap with |
| 69 |
* specific color |
| 70 |
* |
| 71 |
* @param color wanted to be set |
| 72 |
* @return pixmap has a rectangle filled with the color |
| 73 |
*/ |
| 74 |
QPixmap colorRectPixmap(const QColor& color) const; |
| 75 |
|
| 76 |
/** |
| 77 |
* @brief Provide the current selection from the tree-view |
| 78 |
* hierarchy |
| 79 |
* |
| 80 |
* @return a QHash with three keys: "Ratings", "Picks", and |
| 81 |
* "Colors", every key dedicated to an int list which |
| 82 |
* holds the rows selected |
| 83 |
*/ |
| 84 |
QHash<Labels, QList<int> > selectedLabels(); |
| 85 |
|
| 86 |
/** |
| 87 |
* @brief Restores the selection state from the AlbumHistory |
| 88 |
* class |
| 89 |
* |
| 90 |
* @param neededLabels is a QHash to restore the selection |
| 91 |
* from it, the hash is formatted just like the hash |
| 92 |
* generated from @see selectedLabels() |
| 93 |
*/ |
| 94 |
void restoreSelectionFromHistory(QHash<Labels, QList<int> > neededLabels); |
| 95 |
|
| 96 |
/** |
| 97 |
* @brief Emits a signal to the search handler to set the Current |
| 98 |
* album from currently selected labels |
| 99 |
*/ |
| 100 |
void setCurrentAlbum(); |
| 101 |
|
| 102 |
protected: |
| 103 |
|
| 104 |
/** |
| 105 |
* @brief Loading and saving state function inherited from |
| 106 |
* StateSavingObject |
| 107 |
*/ |
| 108 |
void doLoadState() override; |
| 109 |
void doSaveState() override; |
| 110 |
|
| 111 |
private: |
| 112 |
|
| 113 |
/** |
| 114 |
* @brief Initializing the tree-view hierarchy |
| 115 |
*/ |
| 116 |
void initTreeView(); |
| 117 |
void initRatingsTree(); |
| 118 |
void initPicksTree(); |
| 119 |
void initColorsTree(); |
| 120 |
|
| 121 |
/** |
| 122 |
* @brief Index based access to the items |
| 123 |
*/ |
| 124 |
QTreeWidgetItem* getOrCreateItem(QTreeWidgetItem* const parent); |
| 125 |
|
| 126 |
private Q_SLOTS: |
| 127 |
|
| 128 |
void slotSettingsChanged(); |
| 129 |
|
| 130 |
Q_SIGNALS: |
| 131 |
|
| 132 |
void signalSetCurrentAlbum(); |
| 133 |
void signalColorNameChanged(int, const QString& name); |
| 134 |
|
| 135 |
private: |
| 136 |
|
| 137 |
class Private; |
| 138 |
Private* const d = nullptr; |
| 139 |
}; |
| 140 |
|
| 141 |
} // namespace Digikam |