digiKam
filteraction.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 : 2010-06-02
7  * Description : class that holds list of applied filters to image
8  *
9  * Copyright (C) 2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2010 by Martin Klapetek <martin dot klapetek 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_FILTER_ACTION_H
26 #define DIGIKAM_FILTER_ACTION_H
27 
28 // Qt includes
29 
30 #include <QFlags>
31 #include <QHash>
32 #include <QString>
33 #include <QVariant>
34 
35 // Local includes
36 
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_EXPORT FilterAction
43 {
44 public:
45 
46  enum Category
47  {
56  ReproducibleFilter = 0,
57 
63  ComplexFilter = 1,
64 
69  DocumentedHistory = 2,
70 
71  CategoryFirst = ReproducibleFilter,
72  CategoryLast = DocumentedHistory
73  };
74 
75  enum Flag
76  {
81  ExplicitBranch = 1 << 0
82  };
83  Q_DECLARE_FLAGS(Flags, Flag)
84 
85 public:
86 
87  FilterAction();
88  FilterAction(const QString& identifier, int version, Category category = ReproducibleFilter);
89 
90  bool isNull() const;
91 
92  bool operator==(const FilterAction& other) const;
93 
94  Category category() const;
95 
100  QString identifier() const;
101 
107  int version() const;
108 
113  QString description() const;
114  void setDescription(const QString& description);
115 
116  QString displayableName() const;
117  void setDisplayableName(const QString& displayableName);
118 
119  Flags flags() const;
120  void setFlags(Flags flags);
121  void addFlag(Flags flags);
122  void removeFlag(Flags flags);
123 
129  bool hasParameters() const;
130  const QHash<QString,QVariant>& parameters() const;
131  QHash<QString, QVariant>& parameters();
132 
133  bool hasParameter(const QString& key) const;
134  const QVariant parameter(const QString& key) const;
135  QVariant& parameter(const QString& key);
136 
140  template <typename T>
141  T parameter(const QString& key) const
142  {
143  return parameter(key).value<T>();
144  }
145 
152  template <typename T>
153  T parameter(const QString& key, const T& defaultValue) const
154  {
155  QVariant var = parameter(key);
156  return (
157  (var.isValid()) ? var.value<T>()
158  : defaultValue
159  );
160  }
161 
163  void addParameter(const QString& key, const QVariant& value);
164 
166  void removeParameters(const QString& key);
167 
169  void clearParameters();
170 
172  void setParameters(const QHash<QString, QVariant>& params);
173 
174 protected:
175 
178  Flags m_flags;
179  QString m_identifier;
181  QString m_description;
183  QHash<QString, QVariant> m_params;
184 };
185 
186 } // namespace Digikam
187 
188 Q_DECLARE_METATYPE(Digikam::FilterAction)
189 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::FilterAction::Flags)
190 
191 #endif // DIGIKAM_FILTER_ACTION_H
Definition: filteraction.h:43
T parameter(const QString &key) const
Definition: filteraction.h:141
Flag
Definition: filteraction.h:76
T parameter(const QString &key, const T &defaultValue) const
Definition: filteraction.h:153
Flags m_flags
Definition: filteraction.h:178
QString m_description
Definition: filteraction.h:181
QString m_identifier
Definition: filteraction.h:179
QString m_displayableName
Definition: filteraction.h:182
int m_version
Definition: filteraction.h:180
Category m_category
NOTE: Value class, do not create a d-pointer.
Definition: filteraction.h:177
QHash< QString, QVariant > m_params
Definition: filteraction.h:183
Category
Definition: filteraction.h:47
qulonglong value
Definition: itemviewutilities.cpp:592
#define T
Category
Definition: coredbconstants.h:95
Definition: datefolderview.cpp:43
bool operator==(const SearchTextSettings &a, const SearchTextSettings &b)
Definition: searchtextbar.cpp:49