src/config.h

Thu, 05 Dec 2013 13:51:52 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 05 Dec 2013 13:51:52 +0200
changeset 538
2f85d4d286e5
parent 497
c51941e590b6
child 539
72ad83a67165
permissions
-rw-r--r--

- ensured header files' guards start with LDFORGE_
- removed typedef "qchar" (use QChar instead), removed use of short, long and size_t (use int instead)
- use C++11-using syntax instead of typedefs in types.h

183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
4 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
9 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
14 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
19 #ifndef LDFORGE_CONFIG_H
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
20 #define LDFORGE_CONFIG_H
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "common.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include <QString>
467
59549731151a Added ListConfig type, using it in recent files now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 465
diff changeset
26 #include <QVariant>
298
f945fc8dae9e Nuked the now-empty string.cpp/.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
27 #include <QKeySequence>
436
4268a5507725 Converted configuration code to use QSettings.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
28 class QSettings;
298
f945fc8dae9e Nuked the now-empty string.cpp/.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
29
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 497
diff changeset
30 typedef QChar QChar;
298
f945fc8dae9e Nuked the now-empty string.cpp/.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
31 typedef QString str;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 #define MAX_INI_LINE 512
239
ea09eeba1c2b Use a C-array for config too for the same reasons as with actions
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
34 #define MAX_CONFIG 512
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
36 #define cfg(T, NAME, DEFAULT) T##Config NAME (DEFAULT, #NAME, #DEFAULT)
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
37 #define extern_cfg(T, NAME) extern T##Config NAME
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 // =========================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
40 class Config
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
41 { public:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
42 enum Type
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
43 { Int,
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
44 String,
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
45 Float,
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
46 Bool,
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
47 KeySequence,
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
48 List,
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
49 };
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
50
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
51 Config (const char* name, const char* defstring);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
52 const char* name;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
53
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
54 virtual Type getType() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
55 { return (Type) 0;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
56 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
57
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
58 virtual void resetValue() {}
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
59 virtual void loadFromVariant (const QVariant& val)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
60 { (void) val;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
61 }
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
62
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
63 virtual bool isDefault() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
64 { return false;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
65 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
66
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
67 virtual QVariant toVariant() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
68 { return QVariant();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
69 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
70
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
71 virtual QVariant defaultVariant() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
72 { return QVariant();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
73 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
74
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
75 // ------------------------------------------
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
76 static bool load();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
77 static bool save();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
78 static void reset();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
79 static str dirpath();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
80 static str filepath (str file);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
81
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
82 protected:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
83 static void addToArray (Config* ptr);
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
84
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
85 private:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
86 const char* m_defstring;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 // =============================================================================
462
55173a35eea5 bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
90 #define IMPLEMENT_CONFIG(NAME, T) \
55173a35eea5 bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
91 T value, defval; \
55173a35eea5 bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
92 NAME##Config (T defval, const char* name, const char* defstring) : \
55173a35eea5 bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
93 Config (name, defstring), value (defval), defval (defval) \
55173a35eea5 bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
94 { Config::addToArray (this); } \
55173a35eea5 bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
95 \
55173a35eea5 bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
96 operator const T&() const { return value; } \
55173a35eea5 bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 461
diff changeset
97 Config::Type getType() const override { return Config::NAME; } \
468
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
98 virtual void resetValue() override { value = defval; } \
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
99 virtual bool isDefault() const override { return value == defval; } \
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
100 virtual QVariant toVariant() const override { return QVariant::fromValue<T> (value); } \
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
101 virtual QVariant defaultVariant() const override { return QVariant::fromValue<T> (defval); } \
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
102 virtual void loadFromVariant (const QVariant& val) override { value = val.value<T>(); } \
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
103
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
104 #define DEFINE_UNARY_OPERATOR(T, OP) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
105 T operator OP() { \
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
106 return OP value; \
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
107 }
468
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
108
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
109 #define DEFINE_BINARY_OPERATOR(T, OP) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
110 T operator OP (const T other) { \
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
111 return value OP other; \
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
112 }
468
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
113
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
114 #define DEFINE_ASSIGN_OPERATOR(T, OP) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
115 T& operator OP (const T other) { \
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
116 return value OP other; \
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
117 }
468
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
118
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
119 #define DEFINE_COMPARE_OPERATOR(T, OP) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
120 bool operator OP (const T other) { \
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
121 return value OP other; \
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
122 }
468
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
123
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
124 #define DEFINE_CAST_OPERATOR(T) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
125 operator T() { \
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 return (T) value; \
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
127 }
468
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
128
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
129 #define DEFINE_ALL_COMPARE_OPERATORS(T) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
130 DEFINE_COMPARE_OPERATOR (T, ==) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
131 DEFINE_COMPARE_OPERATOR (T, !=) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
132 DEFINE_COMPARE_OPERATOR (T, >) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
133 DEFINE_COMPARE_OPERATOR (T, <) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
134 DEFINE_COMPARE_OPERATOR (T, >=) \
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
135 DEFINE_COMPARE_OPERATOR (T, <=) \
468
7b3159f1a9e2 woo smallification!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 467
diff changeset
136
421
7d26db0be944 style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 367
diff changeset
137 #define DEFINE_INCREMENT_OPERATORS(T) \
359
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
138 T operator++() { return ++value; } \
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
139 T operator++(int) { return value++; } \
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
140 T operator--() { return --value; } \
bcdfc801658b more restyle/refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 299
diff changeset
141 T operator--(int) { return value--; }
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 // =============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
144 class IntConfig : public Config
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
145 { public:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
146 IMPLEMENT_CONFIG (Int, int)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
147 DEFINE_ALL_COMPARE_OPERATORS (int)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
148 DEFINE_INCREMENT_OPERATORS (int)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
149 DEFINE_BINARY_OPERATOR (int, +)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
150 DEFINE_BINARY_OPERATOR (int, -)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
151 DEFINE_BINARY_OPERATOR (int, *)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
152 DEFINE_BINARY_OPERATOR (int, /)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
153 DEFINE_BINARY_OPERATOR (int, %)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
154 DEFINE_BINARY_OPERATOR (int, ^)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
155 DEFINE_BINARY_OPERATOR (int, |)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
156 DEFINE_BINARY_OPERATOR (int, &)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
157 DEFINE_BINARY_OPERATOR (int, >>)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
158 DEFINE_BINARY_OPERATOR (int, <<)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
159 DEFINE_UNARY_OPERATOR (int, !)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
160 DEFINE_UNARY_OPERATOR (int, ~)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
161 DEFINE_UNARY_OPERATOR (int, -)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
162 DEFINE_UNARY_OPERATOR (int, +)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
163 DEFINE_ASSIGN_OPERATOR (int, =)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
164 DEFINE_ASSIGN_OPERATOR (int, +=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
165 DEFINE_ASSIGN_OPERATOR (int, -=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
166 DEFINE_ASSIGN_OPERATOR (int, *=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
167 DEFINE_ASSIGN_OPERATOR (int, /=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
168 DEFINE_ASSIGN_OPERATOR (int, %=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
169 DEFINE_ASSIGN_OPERATOR (int, >>=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
170 DEFINE_ASSIGN_OPERATOR (int, <<=)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 // =============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
174 class StringConfig : public Config
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
175 { public:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
176 IMPLEMENT_CONFIG (String, str)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
177
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
178 DEFINE_COMPARE_OPERATOR (str, ==)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
179 DEFINE_COMPARE_OPERATOR (str, !=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
180 DEFINE_ASSIGN_OPERATOR (str, =)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
181 DEFINE_ASSIGN_OPERATOR (str, +=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
182
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
183 QChar operator[] (int n)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
184 { return value[n];
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
185 }
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 // =============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
189 class FloatConfig : public Config
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
190 { public:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
191 IMPLEMENT_CONFIG (Float, float)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
192 DEFINE_ALL_COMPARE_OPERATORS (float)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
193 DEFINE_INCREMENT_OPERATORS (float)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
194 DEFINE_BINARY_OPERATOR (float, +)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
195 DEFINE_BINARY_OPERATOR (float, -)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
196 DEFINE_BINARY_OPERATOR (float, *)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
197 DEFINE_UNARY_OPERATOR (float, !)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
198 DEFINE_ASSIGN_OPERATOR (float, =)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
199 DEFINE_ASSIGN_OPERATOR (float, +=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
200 DEFINE_ASSIGN_OPERATOR (float, -=)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
201 DEFINE_ASSIGN_OPERATOR (float, *=)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 // =============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
205 class BoolConfig : public Config
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
206 { public:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
207 IMPLEMENT_CONFIG (Bool, bool)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
208 DEFINE_ALL_COMPARE_OPERATORS (bool)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
209 DEFINE_ASSIGN_OPERATOR (bool, =)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 // =============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
213 class KeySequenceConfig : public Config
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
214 { public:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
215 IMPLEMENT_CONFIG (KeySequence, QKeySequence)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
216 DEFINE_ALL_COMPARE_OPERATORS (QKeySequence)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
217 DEFINE_ASSIGN_OPERATOR (QKeySequence, =)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219
467
59549731151a Added ListConfig type, using it in recent files now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 465
diff changeset
220 // =============================================================================
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
221 class ListConfig : public Config
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
222 { public:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
223 IMPLEMENT_CONFIG (List, QList<QVariant>)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
224 DEFINE_ASSIGN_OPERATOR (QList<QVariant>, =)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
225
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
226 typedef QList<QVariant>::iterator it;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
227 typedef QList<QVariant>::const_iterator c_it;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
228
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
229 it begin()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
230 { return value.begin();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
231 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
232
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
233 c_it begin() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
234 { return value.constBegin();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
235 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
236
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
237 it end()
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
238 { return value.end();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
239 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
240
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
241 c_it end() const
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
242 { return value.constEnd();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 471
diff changeset
243 }
467
59549731151a Added ListConfig type, using it in recent files now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 465
diff changeset
244 };
59549731151a Added ListConfig type, using it in recent files now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 465
diff changeset
245
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
246 #endif // LDFORGE_CONFIG_H

mercurial