digiKam
dateoption.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-08-08
7  * Description : an option to provide date information to the parser
8  *
9  * Copyright (C) 2009-2012 by Andi Clemens <andi dot clemens 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_DATE_OPTION_H
25 #define DIGIKAM_DATE_OPTION_H
26 
27 // Qt includes
28 
29 #include <QDialog>
30 #include <QObject>
31 #include <QString>
32 #include <QVariant>
33 
34 // Local includes
35 
36 #include "option.h"
37 #include "ruledialog.h"
38 
39 namespace Ui
40 {
41 class DateOptionDialogWidget;
42 }
43 
44 namespace Digikam
45 {
46 
48 {
49 public:
50 
51  enum Type
52  {
53  Standard = 0,
54  ISO,
57  Custom
58  };
59 
60 public:
61 
62  typedef QPair<QString, QVariant> DateFormatDescriptor;
64 
65 public:
66 
67  explicit DateFormat();
69 
70  Type type(const QString& identifier);
71 
72  QString identifier(Type type);
73 
74  QVariant format(Type type);
75  QVariant format(const QString& identifier);
76 
78  {
79  return m_map;
80  };
81 
82 private:
83 
84  DateFormat(const DateFormat&) = delete;
85  DateFormat& operator=(const DateFormat&) = delete;
86 
87 private:
88 
89  DateFormatMap m_map;
90 };
91 
92 // --------------------------------------------------------
93 
95 {
96  Q_OBJECT
97 
98 public:
99 
101  {
105  };
106 
107 public:
108 
109  explicit DateOptionDialog(Rule* parent);
110  ~DateOptionDialog() override;
111 
112  Ui::DateOptionDialogWidget* const ui;
113 
115 
116 private Q_SLOTS:
117 
118  void slotDateSourceChanged(int);
119  void slotDateFormatChanged(int);
120  void slotCustomFormatChanged(const QString&);
121 
122 private:
123 
124  // Disable
125  explicit DateOptionDialog(QWidget*) = delete;
127  DateOptionDialog& operator=(const DateOptionDialog&);
128 
129  QString formattedDateTime(const QDateTime& date);
130  void updateExampleLabel();
131 };
132 
133 // --------------------------------------------------------
134 
135 class DateOption : public Option
136 {
137  Q_OBJECT
138 
139 public:
140 
141  explicit DateOption();
142  ~DateOption() override = default;
143 
144 protected:
145 
146  QString parseOperation(ParseSettings& settings, const QRegularExpressionMatch &match) override;
147 
148 private Q_SLOTS:
149 
150  void slotTokenTriggered(const QString& token) override;
151 
152 private:
153 
154  // Disable
155  explicit DateOption(QObject*) = delete;
156  DateOption(const DateOption&) = delete;
157  DateOption& operator=(const DateOption&) = delete;
158 };
159 
160 } // namespace Digikam
161 
162 #endif // DIGIKAM_DATE_OPTION_H
Definition: dateoption.h:48
QString identifier(Type type)
Definition: dateoption.cpp:83
Type type(const QString &identifier)
Definition: dateoption.cpp:65
DateFormat()
Definition: dateoption.cpp:56
QList< DateFormatDescriptor > DateFormatMap
Definition: dateoption.h:63
Type
Definition: dateoption.h:52
@ Standard
Definition: dateoption.h:53
@ UnixTimeStamp
Definition: dateoption.h:56
@ ISO
Definition: dateoption.h:54
@ Custom
Definition: dateoption.h:57
@ FullText
Definition: dateoption.h:55
DateFormatMap & map()
Definition: dateoption.h:77
QVariant format(Type type)
Definition: dateoption.cpp:88
~DateFormat()
Definition: dateoption.h:68
QPair< QString, QVariant > DateFormatDescriptor
Definition: dateoption.h:62
Definition: dateoption.h:95
DateSource
Definition: dateoption.h:101
@ FromImage
Definition: dateoption.h:102
@ CurrentDateTime
Definition: dateoption.h:103
@ FixedDateTime
Definition: dateoption.h:104
Ui::DateOptionDialogWidget *const ui
Definition: dateoption.h:112
DateOptionDialog(Rule *parent)
Definition: dateoption.cpp:112
~DateOptionDialog() override
Definition: dateoption.cpp:177
DateSource dateSource()
Definition: dateoption.cpp:182
Definition: dateoption.h:136
DateOption()
Definition: dateoption.cpp:262
QString parseOperation(ParseSettings &settings, const QRegularExpressionMatch &match) override
Definition: dateoption.cpp:276
~DateOption() override=default
Definition: option.h:35
Definition: parsesettings.h:43
Definition: ruledialog.h:38
Definition: rule.h:42
Definition: datefolderview.cpp:43
Type
Definition: gpsitemcontainer.h:45