File indexing completed on 2025-03-09 03:57:06

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-05-22
0007  * Description : database key selector.
0008  *
0009  * SPDX-FileCopyrightText: 2010-2012 by Andi Clemens <andi dot clemens at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_DB_KEY_SELECTOR_H
0016 #define DIGIKAM_DB_KEY_SELECTOR_H
0017 
0018 // Qt includes
0019 
0020 #include <QTreeWidgetItem>
0021 #include <QTreeWidget>
0022 #include <QStringList>
0023 
0024 // Local includes
0025 
0026 #include "searchtextbar.h"
0027 #include "databaseoption.h"
0028 
0029 namespace Digikam
0030 {
0031 class DbHeaderListItem;
0032 
0033 class DbKeySelectorItem : public QTreeWidgetItem
0034 {
0035 
0036 public:
0037 
0038     explicit DbKeySelectorItem(DbHeaderListItem* const parent, const QString& title, const QString& desc);
0039     ~DbKeySelectorItem() override;
0040 
0041     QString key()         const;
0042     QString description() const;
0043 
0044 private:
0045 
0046     QString m_key;
0047     QString m_description;
0048 
0049 private:
0050 
0051     // Disable
0052     DbKeySelectorItem(const DbKeySelectorItem&)            = delete;
0053     DbKeySelectorItem& operator=(const DbKeySelectorItem&) = delete;
0054 };
0055 
0056 // ------------------------------------------------------------------------------------
0057 
0058 class DbKeySelector : public QTreeWidget
0059 {
0060     Q_OBJECT
0061 
0062 public:
0063 
0064     explicit DbKeySelector(QWidget* const parent);
0065     ~DbKeySelector() override;
0066 
0067     void setKeysMap(const DbOptionKeysMap& map);
0068     QStringList checkedKeysList();
0069 
0070 private:
0071 
0072     // Disable
0073     DbKeySelector(const DbKeySelector&)            = delete;
0074     DbKeySelector& operator=(const DbKeySelector&) = delete;
0075 };
0076 
0077 // ------------------------------------------------------------------------------------
0078 
0079 class DbKeySelectorView : public QWidget
0080 {
0081     Q_OBJECT
0082 
0083 public:
0084 
0085     explicit DbKeySelectorView(QWidget* const parent);
0086     ~DbKeySelectorView() override;
0087 
0088     void setKeysMap(const DbOptionKeysMap& map);
0089     QStringList checkedKeysList() const;
0090 
0091 private Q_SLOTS:
0092 
0093     void slotSearchTextChanged(const SearchTextSettings&);
0094 
0095 private:
0096 
0097     void removeChildlessHeaders();
0098 
0099 private:
0100 
0101     // Disable
0102     DbKeySelectorView(const DbKeySelectorView&)            = delete;
0103     DbKeySelectorView& operator=(const DbKeySelectorView&) = delete;
0104 
0105 private:
0106 
0107     class Private;
0108     Private* const d;
0109 };
0110 
0111 } // namespace Digikam
0112 
0113 #endif // DIGIKAM_DB_KEY_SELECTOR_H