mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
core: add macros to handle setter functions
Add macros to handle full function set functions in qPref Remark: the function name is fixed to be "set_<name>" where name is identical to the variable in struct preferences This is not our standard naming, but is consistent with struct preferences (that also use different name schemes). Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
7ee1aab728
commit
e3767fdc43
1 changed files with 51 additions and 1 deletions
|
@ -102,7 +102,6 @@ void qPref ## class::disk_ ## field(bool doSync) \
|
|||
LOADSYNC_TXT(name, field); \
|
||||
}
|
||||
|
||||
|
||||
//******* Macros to generate get function
|
||||
#define GET_PREFERENCE_BOOL(class, field) \
|
||||
bool qPref ## class::field () const \
|
||||
|
@ -133,4 +132,55 @@ const QString qPref ## class::field () const \
|
|||
{ \
|
||||
return prefs.field; \
|
||||
}
|
||||
|
||||
//******* Macros to generate set function
|
||||
#define SET_PREFERENCE_BOOL(class, field) \
|
||||
void qPref ## class::set_ ## field (bool value) \
|
||||
{ \
|
||||
if (value != prefs.field) { \
|
||||
prefs.field = value; \
|
||||
disk_ ## field(true); \
|
||||
emit field ## _changed(value); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_PREFERENCE_DOUBLE(class, field) \
|
||||
void qPref ## class::set_ ## field (double value) \
|
||||
{ \
|
||||
if (value != prefs.field) { \
|
||||
prefs.field = value; \
|
||||
disk_ ## field(true); \
|
||||
emit field ## _changed(value); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_PREFERENCE_ENUM(class, type, field) \
|
||||
void qPref ## class::set_ ## field (type value) \
|
||||
{ \
|
||||
if (value != prefs.field) { \
|
||||
prefs.field = value; \
|
||||
disk_ ## field(true); \
|
||||
emit field ## _changed(value); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_PREFERENCE_INT(class, field) \
|
||||
void qPref ## class::set_ ## field (int value) \
|
||||
{ \
|
||||
if (value != prefs.field) { \
|
||||
prefs.field = value; \
|
||||
disk_ ## field(true); \
|
||||
emit field ## _changed(value); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_PREFERENCE_TXT(class, field) \
|
||||
void qPref ## class::set_ ## field (const QString& value) \
|
||||
{ \
|
||||
if (value != prefs.field) { \
|
||||
COPY_TXT(field, value); \
|
||||
disk_ ## field(true); \
|
||||
emit field ## _changed(value); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue