25 #ifndef KLFCONFIGBASE_H_ 26 #define KLFCONFIGBASE_H_ 42 virtual QVariant toVariant()
const = 0;
67 virtual void connectQObjectProperty(
const QString& configPropertyName,
QObject *
object,
69 virtual void disconnectQObjectProperty(
const QString& configPropertyName,
QObject *
object,
77 virtual void connectQObjectSlot(
const QString& configPropertyName,
QObject *
object,
79 virtual void disconnectQObjectSlot(
const QString& configPropertyName,
QObject *
object,
83 virtual void disconnectQObject(
QObject *
object);
103 void connectQObject(
const QString& configPropertyName,
QObject *
object,
105 void disconnectQObject(
const QString& configPropertyName,
QObject *
object,
120 KLFConfigProp() : config(NULL), val(T()), defval(T()), isdefaultvaluedefinite(false) { }
123 operator Type ()
const 138 return value() == compareValue;
142 return value() != compareValue;
152 Type oldvalue = value();
153 KLF_ASSERT_NOT_NULL(config,
"we ("<<pname<<
") have not been initialized!",
return false; ) ;
155 if (!config->okChangeProperty(
this, vc.convert(oldvalue), vc.convert(newvalue))) {
160 config->propertyChanged(
this, vc.convert(oldvalue), vc.convert(newvalue));
170 return isdefaultvaluedefinite;
174 KLF_ASSERT_NOT_NULL(config,
"we ("<<pname<<
") have not been initialized!",
return Type(); ) ;
175 config->propertyValueRequested(
this);
195 return v.
convert(defaultValue());
199 bool isDefaultValueDefinite =
true)
205 defval = defaultValue;
208 isdefaultvaluedefinite = isDefaultValueDefinite;
213 defval = defaultValue;
214 isdefaultvaluedefinite =
true;
221 config->connectQObjectProperty(pname,
object, propName) ;
227 config->disconnectQObjectProperty(pname,
object, propName) ;
234 config->connectQObjectSlot(pname,
object, slotName) ;
240 config->disconnectQObjectSlot(pname,
object, slotName) ;
253 bool isdefaultvaluedefinite;
256 #define KLFCONFIGPROP_INIT_CONFIG(configptr) KLFConfigBase *__klfconfigprop_configbase = (configptr) ; 257 #define KLFCONFIGPROP_INIT(var, defval) (var).initialize(__klfconfigprop_configbase, #var, (defval)) 258 #define KLFCONFIGPROP_INIT_DEFNOTDEF(var, defval) (var).initialize(__klfconfigprop_configbase, #var, (defval), false)
bool operator==(const Type &compareValue) const
virtual QVariant defaultValueVariant() const
QList< KLFConfigPropBase * > pProperties
bool operator!=(const Type &compareValue) const
Base declarations for klatexformula and some utilities.
void initialize(KLFConfigBase *confptr, const QString &propName, const Type &defaultValue, bool isDefaultValueDefinite=true)
bool setValue(const Type &newvalue)
bool operator==(const ObjConnection &b) const
const Type operator()() const
Type defaultValue() const
#define KLF_ASSERT_NOT_NULL(ptr, msg, failaction)
Asserting Non-NULL pointers (NON-FATAL)
void connectQObjectSlot(QObject *object, const QByteArray &slotName)
bool defaultValueDefinite() const
bool setValue(const QVariant &newvalue)
QHash< QString, QList< ObjConnection > > pObjConnections
void setDefaultValue(const Type &defaultValue)
void disconnectQObjectProperty(QObject *object, const QByteArray &propName)
void disconnectQObjectSlot(QObject *object, const QByteArray &slotName)
virtual bool setValue(const QVariant &newvalue)
static QVariant convert(const T &value)
virtual QVariant defaultValueVariant() const
void connectQObjectProperty(QObject *object, const QByteArray &propName)
void registerConfigProp(KLFConfigPropBase *p)
const Type & operator=(const Type &newvalue)
virtual QVariant toVariant() const
virtual QString propName() const