digiKam
metadataselector.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 : 2009-07-16
7  * Description : metadata selector.
8  *
9  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_META_DATA_SELECTOR_H
25 #define DIGIKAM_META_DATA_SELECTOR_H
26 
27 // Qt includes
28 
29 #include <QTreeWidgetItem>
30 #include <QTreeWidget>
31 #include <QStringList>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 #include "searchtextbar.h"
37 #include "dmetadata.h"
38 
39 namespace Digikam
40 {
41 
42 class MdKeyListViewItem;
43 class MetadataSelectorView;
44 
45 class DIGIKAM_EXPORT MetadataSelectorItem : public QTreeWidgetItem
46 {
47 public:
48 
50  const QString& key,
51  const QString& title,
52  const QString& desc);
53  ~MetadataSelectorItem() override;
54 
55  QString key() const;
56  QString mdKeyTitle() const;
57 
58 private:
59 
60  QString m_key;
61  MdKeyListViewItem* m_parent;
62 
63 private:
64 
65  Q_DISABLE_COPY(MetadataSelectorItem)
66 };
67 
68 // ------------------------------------------------------------------------------------
69 
70 class DIGIKAM_EXPORT MetadataSelector : public QTreeWidget
71 {
72  Q_OBJECT
73 
74 public:
75 
76  explicit MetadataSelector(MetadataSelectorView* const parent);
77  ~MetadataSelector() override;
78 
79  void setTagsMap(const DMetadata::TagsMap& map);
80 
81  void setcheckedTagsList(const QStringList& list);
82  QStringList checkedTagsList();
83 
84  void clearSelection();
85  void selectAll() override;
86 
87 private:
88 
89  MetadataSelectorView* m_parent;
90 };
91 
92 // ------------------------------------------------------------------------------------
93 
94 class DIGIKAM_EXPORT MetadataSelectorView : public QWidget
95 {
96  Q_OBJECT
97 
98 public:
99 
101  {
102  SelectAllBtn = 0x01,
103  ClearBtn = 0x02,
104  DefaultBtn = 0x04,
105  SearchBar = 0x08
106  };
107  Q_DECLARE_FLAGS(ControlElements, ControlElement)
108 
109  enum Backend
110  {
111  Exiv2Backend = 0,
112  ExifToolBackend
113  };
114 
115 public:
116 
117  explicit MetadataSelectorView(QWidget* const parent, Backend be);
118  ~MetadataSelectorView() override;
119 
120  int itemsCount() const;
121 
122  void setTagsMap(const DMetadata::TagsMap& map);
123 
124  void setcheckedTagsList(const QStringList& list);
125 
126  void setDefaultFilter(const QStringList& list);
127  QStringList defaultFilter() const;
128 
129  QStringList checkedTagsList() const;
130 
131  Backend backend() const;
132 
133  void setControlElements(ControlElements controllerMask);
134 
135  void clearSelection();
136  void selectAll();
137  void selectDefault();
138 
139 private Q_SLOTS:
140 
141  void slotSearchTextChanged(const SearchTextSettings&);
142  void slotDeflautSelection();
143  void slotSelectAll();
144  void slotClearSelection();
145 
146 private:
147 
148  void cleanUpMdKeyItem();
149 
150 private:
151 
152  // Disable.
153  MetadataSelectorView() = delete;
154 
155 private:
156 
157  class Private;
158  Private* const d;
159 };
160 
161 } // namespace Digikam
162 
163 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::MetadataSelectorView::ControlElements)
164 
165 #endif // DIGIKAM_META_DATA_SELECTOR_H
Definition: mdkeylistviewitem.h:44
QMap< QString, QStringList > TagsMap
Definition: metaengine.h:151
Definition: metadataselector.h:46
Definition: metadataselector.h:95
ControlElement
Definition: metadataselector.h:101
Backend
Definition: metadataselector.h:110
Definition: metadataselector.h:71
Definition: searchtextbar.h:43
Definition: datefolderview.cpp:43