Go to the documentation of this file.
31 #include <QDataStream>
32 #include <QTextStream>
36 #include <QStringList>
71 virtual QString objectKind()
const = 0;
97 virtual bool setProperty(
const QString& pname,
const QVariant& value) = 0;
129 virtual bool hasFixedTypes()
const {
return false; }
183 if (val < 0 || val >= enumVals.
size()) {
184 klfWarning(
"Invalid value: "<<val<<
" for enum values "<<enumVals) ;
187 return enumVals[val];
323 virtual bool hasPropertyValue(
const QString& propName)
const;
331 virtual bool hasPropertyValue(
int propId)
const;
424 void setAllPropertiesFromByteArray(
const QByteArray& data);
458 ToStringUseHtml = 0x0001,
459 ToStringUseHtmlDiv = 0x0002,
460 ToStringQuoteValues = 0x0004,
461 ToStringAllProperties = 0x0008
467 virtual QString toString(uint toStringFlags = 0)
const;
472 int propertyMaxId()
const;
477 bool propertyIdRegistered(
int propId)
const;
482 bool propertyNameRegistered(
const QString& propertyName)
const;
487 int propertyIdForName(
const QString& propertyName)
const;
522 virtual void propertyValueChanged(
int propId,
const QVariant& oldValue,
530 virtual bool doSetProperty(
const QString& propname,
const QVariant& value);
543 virtual int doLoadProperty(
const QString& propname,
const QVariant& value);
548 void registerBuiltInProperty(
int propId,
const QString& propName)
const;
554 int registerProperty(
const QString& propertyName)
const;
605 static void registerBuiltInProperty(
const QString& propNameSpace,
int propId,
621 static int registerProperty(
const QString& propNameSpace,
const QString& propertyName);
630 static int propertyMaxId(
const QString& propNameSpace);
639 static bool propertyIdRegistered(
const QString& propNameSpace,
int propId);
648 static bool propertyNameRegistered(
const QString& propNameSpace,
const QString& propertyName);
662 static int propertyIdForName(
const QString& propNameSpace,
const QString& propertyName);
715 static int internalRegisterProperty(
const QString& propNameSpace,
const QString& name,
765 : pPObj(pobj), pPropId(
propId)
769 : pPObj(other.pPObj), pPropId(other.pPropId)
779 : pPObj(pobj), pPropId(builtInPropId)
790 : pPObj(pobj), pPropId(builtInPropId)
798 return variantValue();
804 const T operator ()()
const
810 pPObj->setProperty(pPropId, v);
815 pPObj->setProperty(pPropId, QVariant::fromValue<T>(value));
821 return this->operator=(value.
value());
826 return pPObj->property(pPropId);
834 template<
class VariantType>
837 QVariant v = pPObj->property(pPropId);
838 return T(v.
value<VariantType>());
841 template<
class VariantType>
844 pPObj->setProperty(pPropId, QVariant::fromValue<VariantType>(value));
851 template<
class VariantType>
854 return (value<VariantType>() == other.
value<VariantType>());
858 return equals<T>(other);
863 return (value() == val);
867 return (value() == other.
value());
871 void init(
const QString& pname)
873 if (!pPObj->propertyIdRegistered(pPropId)) {
880 <<
" does not have name "<<pname<<
" !",
902 doregister(Register, name);
907 return doregister(Query, name);
911 enum Action { Query, Register };
912 static int doregister(Action action,
const char * name)
924 fprintf(stderr,
"ERRORORROOERROR: %s: what is your action?? `%d' for name `%s'\n",
936 #define KLF_DECLARE_POBJ_TYPE(TYPE) \
937 static KLFPObjRegisteredType __klf_pobj_regtype_##TYPE = KLFPObjRegisteredType(#TYPE) ;
944 doregister(Register, name);
949 return doregister(Query, name);
953 enum Action { Query, Register };
954 static int doregister(Action action,
const char * name)
966 fprintf(stderr,
"ERRORORROORORR: %s: what is your action?? `%d' for name `%s'\n",
974 #define KLF_DECLARE_SPECIFYABLE_TYPE(TYPE) \
975 static KLFSpecifyableRegisteredType __klf_specifyable_regtype_##TYPE = KLFSpecifyableRegisteredType(#TYPE) ;
KLFPObjPropRef(KLFPropertizedObject *pobj, int builtInPropId, const QString &pname)
void append(const T &value)
bool setSpecification(const QByteArray &data)
KLFPObjPropRef(const KLFPObjPropRef &other)
QVariant variantValue() const
const KLFPObjPropRef & operator=(const QVariant &v)
QStringList enumValues() const
QString fromUtf8(const char *str, int size)
bool operator==(const KLFPObjPropRef &other) const
bool equals(const KLFPObjPropRef &other) const
QString propertyNameSpace() const
KLF_EXPORT QDataStream & operator>>(QDataStream &stream, KLFEnumType &e)
virtual bool setAllProperties(const QMap< QString, QVariant > &data)
Convenience function to load a set of property values.
KLF_EXPORT QDataStream & operator<<(QDataStream &stream, const KLFEnumType &e)
KLFEnumType(const KLFEnumType ©)
bool operator==(const T &val) const
const KLFPObjPropRef & operator=(const T &value)
bool contains(const T &value) const
static bool isRegistered(const char *name)
QString propertyNameSpace(KLFPropertizedObject *obj) const
virtual QStringList propertyNameList() const =0
Queries what property are (or can be) set.
bool equals(const KLFPObjPropRef &other) const
Q_DECLARE_METATYPE(KLFEnumType)
QByteArray toUtf8() const
KLFPObjRegisteredType(const char *name)
void registerBuiltInProperty(int propId, const QString &propName) const
bool operator==(const KLFEnumType &a, const KLFEnumType &b)
KLFPObjPropRef(KLFPropertizedObject *pobj, int builtInPropId, const QString &pname, const T &value)
QString join(const QString &separator) const
virtual QString objectKind() const
const KLFPObjPropRef & operator=(const KLFPObjPropRef &value)
#define klfWarning(streamableItems)
KLFPObjPropRef(KLFPropertizedObject *pobj, int propId)
#define KLF_ASSERT_CONDITION(expr, msg, failaction)
Asserting Conditions (NON-FATAL)
void setEnumValues(const QStringList &list)
virtual QMap< QString, QVariant > allProperties() const
Convenience function to retrieve all properties.
QVector< QVariant > propertyVector() const
An abstract object characterized by properties.
QByteArray specification() const
QString enumValue() const
virtual QVariant property(const QString &propName) const =0
get a property's value
A class that holds properties.
void registerbuiltinprop(KLFPropertizedObject *obj, int propid, const QString &pname)
static bool isRegistered(const char *name)
Base declarations for klatexformula and some utilities.
virtual bool setProperty(const QString &pname, const QVariant &value)=0
Assign a value to a property.
ToStringFlag
Flags for tuning the toString() method.
KLFSpecifyableRegisteredType(const char *name)
Generated by doxygen 1.8.17