digiKam
advancedrenameinput.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-09-03
7  * Description : an input widget for the AdvancedRename utility
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_ADVANCED_RENAME_INPUT_H
25 #define DIGIKAM_ADVANCED_RENAME_INPUT_H
26 
27 // Qt includes
28 
29 #include <QPlainTextEdit>
30 #include <QWidget>
31 #include <QComboBox>
32 
33 // Local includes
34 
35 #include "comboboxutilities.h"
36 #include "parser.h"
37 
38 class QFocusEvent;
39 class QKeyEvent;
40 class QMouseEvent;
41 class QEvent;
42 
43 namespace Digikam
44 {
45 
46 class AdvancedRenameLineEdit : public QPlainTextEdit
47 {
48  Q_OBJECT
49 
50 public:
51 
52  explicit AdvancedRenameLineEdit(QWidget* const parent = nullptr);
53  ~AdvancedRenameLineEdit() override;
54 
55  void setParser(Parser* parser);
56  Parser* parser() const;
57 
58  void setParseTimerDuration(int milliseconds);
59 
60 public Q_SLOTS:
61 
62  void slotSetText(const QString&);
64 
65 Q_SIGNALS:
66 
67  void signalTextChanged(const QString&);
68  void signalTokenMarked(bool);
70 
71 protected:
72 
73  void keyPressEvent(QKeyEvent* e) override;
74  void wheelEvent(QWheelEvent* e) override;
75  void scrollContentsBy(int dx, int dy) override;
76 
77 private Q_SLOTS:
78 
79  void slotTextChanged();
80  void slotParseTimer();
81 
82 private:
83 
84  void setupWidgets();
85  void setupConnections();
86 
87 private:
88 
90  AdvancedRenameLineEdit& operator=(const AdvancedRenameLineEdit&) = delete;
91 
92 private:
93 
94  class Private;
95  Private* const d;
96 };
97 
98 // --------------------------------------------------------
99 
100 class AdvancedRenameInput : public QComboBox
101 {
102  Q_OBJECT
103 
104 public:
105 
106  explicit AdvancedRenameInput(QWidget* const parent = nullptr);
107  ~AdvancedRenameInput() override;
108 
109  void setParser(Parser* parser);
110  void setParseTimerDuration(int milliseconds);
111 
112  QString text() const;
113  void setText(const QString& text);
114 
115 Q_SIGNALS:
116 
117  void signalTextChanged(const QString&);
118  void signalTokenMarked(bool);
120 
121 public Q_SLOTS:
122 
123  void slotAddToken(const QString&);
124  void slotClearText();
126  void slotSetFocus();
127 
128  void slotHighlightLineEdit();
129  void slotHighlightLineEdit(const QString& word);
130 
131 protected:
132 
133  void changeEvent(QEvent* e) override;
134 
135 private Q_SLOTS:
136 
137  void slotClearButtonPressed();
138  void slotTextChanged(const QString& text);
139 
140 private:
141 
142  void readSettings();
143  void writeSettings();
144  void enableHighlighter(bool enable);
145 
146  void setupWidgets();
147  void setupConnections();
148 
149 private:
150 
151  // Disable
152  AdvancedRenameInput(const AdvancedRenameInput&) = delete;
153  AdvancedRenameInput& operator=(const AdvancedRenameInput&) = delete;
154 
155 private:
156 
157  class Private;
158  Private* const d;
159 };
160 
161 } // namespace Digikam
162 
163 #endif // DIGIKAM_ADVANCED_RENAME_INPUT_H
Definition: advancedrenameinput.h:101
void slotHighlightLineEdit()
Definition: advancedrenameinput.cpp:338
~AdvancedRenameInput() override
Definition: advancedrenameinput.cpp:299
void setParseTimerDuration(int milliseconds)
Definition: advancedrenameinput.cpp:311
AdvancedRenameInput(QWidget *const parent=nullptr)
Definition: advancedrenameinput.cpp:289
void setParser(Parser *parser)
Definition: advancedrenameinput.cpp:305
void signalTextChanged(const QString &)
void slotClearText()
Definition: advancedrenameinput.cpp:321
void slotAddToken(const QString &)
Definition: advancedrenameinput.cpp:420
QString text() const
Definition: advancedrenameinput.cpp:415
void slotSetFocus()
Definition: advancedrenameinput.cpp:332
void changeEvent(QEvent *e) override
Definition: advancedrenameinput.cpp:393
void slotClearTextAndHistory()
Definition: advancedrenameinput.cpp:326
void setText(const QString &text)
Definition: advancedrenameinput.cpp:316
Definition: advancedrenameinput.h:47
AdvancedRenameLineEdit(QWidget *const parent=nullptr)
Definition: advancedrenameinput.cpp:77
void slotSetText(const QString &)
Definition: advancedrenameinput.cpp:248
void keyPressEvent(QKeyEvent *e) override
Definition: advancedrenameinput.cpp:152
void slotCursorPositionChanged()
Definition: advancedrenameinput.cpp:230
void wheelEvent(QWheelEvent *e) override
Definition: advancedrenameinput.cpp:197
void setParser(Parser *parser)
Definition: advancedrenameinput.cpp:139
void scrollContentsBy(int dx, int dy) override
Definition: advancedrenameinput.cpp:217
void signalTextChanged(const QString &)
void setParseTimerDuration(int milliseconds)
Definition: advancedrenameinput.cpp:134
Parser * parser() const
Definition: advancedrenameinput.cpp:147
~AdvancedRenameLineEdit() override
Definition: advancedrenameinput.cpp:85
Definition: parser.h:45
Definition: datefolderview.cpp:43