summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-04 14:13:48 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-07 09:44:06 -0700
commit29719846871a1ed54495b5b08b48ef6b1cd342da (patch)
tree8bda6c673d674e873d9dc24426d7f14c325067c7
parente3767fdc43ca0008bcc5265ba18d067ff06685ec (diff)
downloadsubsurface-29719846871a1ed54495b5b08b48ef6b1cd342da.tar.gz
core: add macros to handle get/set/loadsync functions
Add macros to handle get/set/loadsync function set functions in qPref These macros are only convinience functions to write less for all those variables who are traited standardized. Signed-off-by: Jan Iversen <jani@apache.org>
-rw-r--r--core/settings/qPref_private.h91
1 files changed, 59 insertions, 32 deletions
diff --git a/core/settings/qPref_private.h b/core/settings/qPref_private.h
index 67ed08a43..d5d64b58b 100644
--- a/core/settings/qPref_private.h
+++ b/core/settings/qPref_private.h
@@ -66,76 +66,76 @@
}
//******* Macros to generate disk function
-#define DISK_LOADSYNC_BOOL(class, name, field) \
-void qPref ## class::disk_ ## field(bool doSync) \
+#define DISK_LOADSYNC_BOOL(usegroup, name, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
LOADSYNC_BOOL(name, field); \
}
-#define DISK_LOADSYNC_DOUBLE(class, name, field) \
-void qPref ## class::disk_ ## field(bool doSync) \
+#define DISK_LOADSYNC_DOUBLE(usegroup, name, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
LOADSYNC_DOUBLE(name, field); \
}
-#define DISK_LOADSYNC_ENUM(class, name, type, field) \
-void qPref ## class::disk_ ## field(bool doSync) \
+#define DISK_LOADSYNC_ENUM(usegroup, name, type, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
LOADSYNC_ENUM(name, type, field); \
}
-#define DISK_LOADSYNC_INT(class, name, field) \
-void qPref ## class::disk_ ## field(bool doSync) \
+#define DISK_LOADSYNC_INT(usegroup, name, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
LOADSYNC_DOUBLE(name, field); \
}
-#define DISK_LOADSYNC_INT_DEF(class, name, field, defval) \
-void qPref ## class::disk_ ## field(bool doSync) \
+#define DISK_LOADSYNC_INT_DEF(usegroup, name, field, defval) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
LOADSYNC_INT_DEF(name, field, defval); \
}
-#define DISK_LOADSYNC_TXT(class, name, field) \
-void qPref ## class::disk_ ## field(bool doSync) \
+#define DISK_LOADSYNC_TXT(usegroup, name, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
LOADSYNC_TXT(name, field); \
}
//******* Macros to generate get function
-#define GET_PREFERENCE_BOOL(class, field) \
-bool qPref ## class::field () const \
+#define GET_PREFERENCE_BOOL(usegroup, field) \
+bool qPref ## usegroup::field () const \
{ \
return prefs.field; \
}
-#define GET_PREFERENCE_DOUBLE(class, field) \
-double qPref ## class::field () const \
+#define GET_PREFERENCE_DOUBLE(usegroup, field) \
+double qPref ## usegroup::field () const \
{ \
return prefs.field; \
}
-#define GET_PREFERENCE_ENUM(class, type, field) \
-struct type qPref ## class:: ## field () const \
+#define GET_PREFERENCE_ENUM(usegroup, type, field) \
+struct type qPref ## usegroup:: ## field () const \
{ \
return prefs.field; \
}
-#define GET_PREFERENCE_INT(class, field) \
-int qPref ## class::field () const \
+#define GET_PREFERENCE_INT(usegroup, field) \
+int qPref ## usegroup::field () const \
{ \
return prefs.field; \
}
-#define GET_PREFERENCE_TXT(class, field) \
-const QString qPref ## class::field () const \
+#define GET_PREFERENCE_TXT(usegroup, field) \
+const QString qPref ## usegroup::field () const \
{ \
return prefs.field; \
}
//******* Macros to generate set function
-#define SET_PREFERENCE_BOOL(class, field) \
-void qPref ## class::set_ ## field (bool value) \
+#define SET_PREFERENCE_BOOL(usegroup, field) \
+void qPref ## usegroup::set_ ## field (bool value) \
{ \
if (value != prefs.field) { \
prefs.field = value; \
@@ -144,8 +144,8 @@ void qPref ## class::set_ ## field (bool value) \
} \
}
-#define SET_PREFERENCE_DOUBLE(class, field) \
-void qPref ## class::set_ ## field (double value) \
+#define SET_PREFERENCE_DOUBLE(usegroup, field) \
+void qPref ## usegroup::set_ ## field (double value) \
{ \
if (value != prefs.field) { \
prefs.field = value; \
@@ -154,8 +154,8 @@ void qPref ## class::set_ ## field (double value) \
} \
}
-#define SET_PREFERENCE_ENUM(class, type, field) \
-void qPref ## class::set_ ## field (type value) \
+#define SET_PREFERENCE_ENUM(usegroup, type, field) \
+void qPref ## usegroup::set_ ## field (type value) \
{ \
if (value != prefs.field) { \
prefs.field = value; \
@@ -164,8 +164,8 @@ void qPref ## class::set_ ## field (type value) \
} \
}
-#define SET_PREFERENCE_INT(class, field) \
-void qPref ## class::set_ ## field (int value) \
+#define SET_PREFERENCE_INT(usegroup, field) \
+void qPref ## usegroup::set_ ## field (int value) \
{ \
if (value != prefs.field) { \
prefs.field = value; \
@@ -174,8 +174,8 @@ void qPref ## class::set_ ## field (int value) \
} \
}
-#define SET_PREFERENCE_TXT(class, field) \
-void qPref ## class::set_ ## field (const QString& value) \
+#define SET_PREFERENCE_TXT(usegroup, field) \
+void qPref ## usegroup::set_ ## field (const QString& value) \
{ \
if (value != prefs.field) { \
COPY_TXT(field, value); \
@@ -183,4 +183,31 @@ void qPref ## class::set_ ## field (const QString& value) \
emit field ## _changed(value); \
} \
}
+
+//******* Macros to generate set/set/loadsync combined
+#define HANDLE_PREFERENCE_BOOL(usegroup, name, field) \
+GET_PREFERENCE_BOOL(usegroup, field); \
+SET_PREFERENCE_BOOL(usegroup, field); \
+DISK_LOADSYNC_BOOL(usegroup, name, field);
+
+#define HANDLE_PREFERENCE_DOUBLE(usegroup, name, field) \
+GET_PREFERENCE_DOUBLE(usegroup, field); \
+SET_PREFERENCE_DOUBLE(usegroup, field); \
+DISK_LOADSYNC_DOUBLE(usegroup, name, field);
+
+#define HANDLE_PREFERENCE_ENUM(usegroup, type, name, field) \
+GET_PREFERENCE_ENUM(usegroup, type, field); \
+SET_PREFERENCE_ENUM(usegroup, type, field); \
+DISK_LOADSYNC_ENUM(usegroup, name, type, field);
+
+#define HANDLE_PREFERENCE_INT(usegroup, name, field) \
+GET_PREFERENCE_INT(usegroup, field); \
+SET_PREFERENCE_INT(usegroup, field); \
+DISK_LOADSYNC_INT(usegroup, name, field);
+
+#define HANDLE_PREFERENCE_TXT(usegroup, name, field) \
+GET_PREFERENCE_TXT(usegroup, field); \
+SET_PREFERENCE_TXT(usegroup, field); \
+DISK_LOADSYNC_TXT(usegroup, name, field);
+
#endif