KTextEditor

variableitem.h
1/*
2 SPDX-FileCopyrightText: 2011-2018 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef VARIABLE_ITEM_H
8#define VARIABLE_ITEM_H
9
10#include <QColor>
11#include <QFont>
12#include <QString>
13#include <QStringList>
14
15class VariableEditor;
16
17// BEGIN class VariableItem
18class VariableItem
19{
20public:
21 explicit VariableItem(const QString &variable);
22 virtual ~VariableItem() = default;
23
24 QString variable() const;
25 QString helpText() const;
26 void setHelpText(const QString &text);
27
28 bool isActive() const;
29 void setActive(bool active);
30
31 virtual void setValueByString(const QString &value) = 0;
32 virtual QString valueAsString() const = 0;
33
34 virtual VariableEditor *createEditor(QWidget *parent) = 0;
35
36private:
37 // not implemented: copy constructor and operator=
38 VariableItem(const VariableItem &copy);
39 VariableItem &operator=(const VariableItem &other);
40
41 QString m_variable;
42 QString m_helpText;
43 bool m_active;
44};
45// END class VariableItem
46
47//
48// DERIVE A CLASS FOR EACH TYPE
49//
50
51// BEGIN class VariableIntItem
52class VariableIntItem : public VariableItem
53{
54public:
55 explicit VariableIntItem(const QString &variable, int value);
56
57 int value() const;
58 void setValue(int newValue);
59 void setRange(int minValue, int maxValue);
60 int minValue() const;
61 int maxValue() const;
62
63public:
64 void setValueByString(const QString &value) override;
65 QString valueAsString() const override;
66 VariableEditor *createEditor(QWidget *parent) override;
67
68private:
69 int m_value;
70 int m_minValue;
71 int m_maxValue;
72};
73// END class VariableIntItem
74
75// BEGIN class VariableStringListItem
76class VariableStringListItem : public VariableItem
77{
78public:
79 explicit VariableStringListItem(const QString &variable, const QStringList &slist, const QString &value);
80
81 QStringList stringList() const;
82
83 QString value() const;
84 void setValue(const QString &newValue);
85
86public:
87 void setValueByString(const QString &value) override;
88 QString valueAsString() const override;
89 VariableEditor *createEditor(QWidget *parent) override;
90
91private:
92 QStringList m_list;
93 QString m_value;
94};
95// END class VariableStringListItem
96
97// BEGIN class VariableBoolItem
98class VariableBoolItem : public VariableItem
99{
100public:
101 explicit VariableBoolItem(const QString &variable, bool value);
102
103 bool value() const;
104 void setValue(bool enabled);
105
106public:
107 void setValueByString(const QString &value) override;
108 QString valueAsString() const override;
109 VariableEditor *createEditor(QWidget *parent) override;
110
111private:
112 bool m_value;
113};
114// END class VariableBoolItem
115
116// BEGIN class VariableColorItem
117class VariableColorItem : public VariableItem
118{
119public:
120 explicit VariableColorItem(const QString &variable, const QColor &value);
121
122 QColor value() const;
123 void setValue(const QColor &color);
124
125public:
126 void setValueByString(const QString &value) override;
127 QString valueAsString() const override;
128 VariableEditor *createEditor(QWidget *parent) override;
129
130private:
131 QColor m_value;
132};
133// END class VariableColorItem
134
135// BEGIN class VariableFontItem
136class VariableFontItem : public VariableItem
137{
138public:
139 explicit VariableFontItem(const QString &variable, const QFont &value);
140
141 QFont value() const;
142 void setValue(const QFont &value);
143
144public:
145 void setValueByString(const QString &value) override;
146 QString valueAsString() const override;
147 VariableEditor *createEditor(QWidget *parent) override;
148
149private:
150 QFont m_value;
151};
152// END class VariableFontItem
153
154// BEGIN class VariableStringItem
155class VariableStringItem : public VariableItem
156{
157public:
158 explicit VariableStringItem(const QString &variable, const QString &value);
159
160 QString value() const;
161 void setValue(const QString &value);
162
163public:
164 void setValueByString(const QString &value) override; // Same as setValue() in this case, implemented for uniformity
165 QString valueAsString() const override; // Same as value() in this case, implemented for uniformity
166 VariableEditor *createEditor(QWidget *parent) override;
167
168private:
169 QString m_value;
170};
171
172// END class VariableStringItem
173
174// BEGIN class VariableSpellCheckItem
175class VariableSpellCheckItem : public VariableItem
176{
177public:
178 explicit VariableSpellCheckItem(const QString &variable, const QString &value);
179
180 QString value() const;
181 void setValue(const QString &value);
182
183public:
184 void setValueByString(const QString &value) override; // Same as setValue() in this case, implemented for uniformity
185 QString valueAsString() const override; // Same as value() in this case, implemented for uniformity
186 VariableEditor *createEditor(QWidget *parent) override;
187
188private:
189 QString m_value;
190};
191// END class VariableSpellCheckItem
192
193// BEGIN class VariableRemoveSpacesItem
194class VariableRemoveSpacesItem : public VariableItem
195{
196public:
197 explicit VariableRemoveSpacesItem(const QString &variable, int value);
198
199 int value() const;
200 void setValue(int value);
201
202public:
203 void setValueByString(const QString &value) override; // Same as setValue() in this case, implemented for uniformity
204 QString valueAsString() const override; // Same as value() in this case, implemented for uniformity
205 VariableEditor *createEditor(QWidget *parent) override;
206
207private:
208 int m_value;
209};
210// END class VariableRemoveSpacesItem
211
212#endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.