/src/_ref15/kernel/qmetaobject.cpp
C++ | 1871 lines | 1130 code | 136 blank | 605 comment | 343 complexity | 96e00cb3908d48bfd2baab99e3d9602a MD5 | raw file
Possible License(s): MIT, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- /****************************************************************************
- **
- ** Copyright (C) 1992-2004 Trolltech AS. All rights reserved.
- **
- ** This file is part of the core module of the Qt Toolkit.
- **
- ** Licensees holding valid Qt Preview licenses may use this file in
- ** accordance with the Qt Preview License Agreement provided with the
- ** Software.
- **
- ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
- ** information about Qt Commercial License Agreements.
- **
- ** Contact info@trolltech.com if any conditions of this licensing are
- ** not clear to you.
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
- #include "qmetaobject.h"
- #include "qobject.h"
- #include <qcoreapplication.h>
- #include <qdatastream.h>
- #include <qstringlist.h>
- #include <qcorevariant.h>
- #include <qhash.h>
- #include <ctype.h>
- /*!
- \class QMetaObject qmetaobject.h
- \brief The QMetaObject class contains meta information about Qt
- objects.
- \ingroup objectmodel
- The Qt Meta Object System in Qt is responsible for the signals and
- slots inter-object communication mechanism, runtime type
- information, and the Qt property system. A single QMetaObject
- instance is created for each QObject subclass that is used in an
- application, and this instance stores all the meta information for
- the QObject subclass.
- This class is not normally required for application programming,
- but it is useful if you write meta applications, such as scripting
- engines or GUI builders.
- The functions you are most likely to find useful are these:
- \list
- \i className() returns the name of a class.
- \i superClass() returns the super-class's meta object.
- \i slotCount(), slot(), signalCount(), and signal() provide information
- about a class's signals and slots.
- \i enumeratorCount() and enumerator() provide information about
- a class's enumerators.
- \i propertyCount() and property() provide information about a
- class's properties.
- \endlist
- The index functions indexOfSlot(), indexOfSignal(),
- indexOfEnumerator(), and indexOfProperty() map names of member
- functions, enumerators, or properties to indices in the meta
- object. For example, Qt uses indexOfSignal() and indexOfSlot()
- internally when you connect a signal to a slot.
- Classes can also have a list of name--value pairs of additional
- \link QMetaClassInfo class information\endlink. The number of
- pairs is returned by classInfoCount(), single pairs are returned
- by classInfo(), and you can search for pairs with
- indexOfClassInfo().
- \sa \link moc.html moc (Meta QObject Compiler)\endlink
- */
- /*!
- \enum QMetaObject::Call
- \internal
- \value InvokeSlot
- \value EmitSignal
- \value ReadProperty
- \value WriteProperty
- \value ResetProperty
- \value QueryPropertyDesignable
- \value QueryPropertyScriptable
- \value QueryPropertyStored
- \value QueryPropertyEditable
- */
- /*!
- \fn void QMetaObject::activate(QObject *obj, int signal_index, void **argv)
- \internal
- */
- /*!
- \enum QMetaMember::Access
- \internal
- */
- // do not touch without touching the moc as well
- enum ProperyFlags {
- Invalid = 0x00000000,
- Readable = 0x00000001,
- Writable = 0x00000002,
- Resetable = 0x00000004,
- EnumOrFlag = 0x00000008,
- StdCppSet = 0x00000100,
- Override = 0x00000200,
- Designable = 0x00001000,
- ResolveDesignable = 0x00002000,
- Scriptable = 0x00004000,
- ResolveScriptable = 0x00008000,
- Stored = 0x00010000,
- ResolveStored = 0x00020000,
- Editable = 0x00040000,
- ResolveEditable = 0x00080000
- };
- enum FunctionFlags {
- AccessPrivate = 0x01,
- AccessPublic = 0x02,
- AccessProtected = 0x04,
- AccessMask = 0x07, //mask
- Compatability = QMetaMember::Compatability,
- Cloned = QMetaMember::Cloned
- };
- struct QMetaObjectPrivate
- {
- int revision;
- int className;
- int classInfoCount, classInfoData;
- int signalCount, signalData;
- int slotCount, slotData;
- int propertyCount, propertyData;
- int enumeratorCount, enumeratorData;
- };
- static inline const QMetaObjectPrivate *priv(const uint* data)
- { return reinterpret_cast<const QMetaObjectPrivate*>(data); }
- /*!
- \fn const char *QMetaObject::className() const
- Returns the class name.
- \sa superClass()
- */
- /*!
- \fn QMetaObject *QMetaObject::superClass() const
- Returns the meta object of the super-class, or 0 if there is no
- such object.
- */
- /*!
- \internal
- Returns \a obj if object \a obj inherits from this meta
- object; otherwise returns 0.
- */
- QObject *QMetaObject::cast(const QObject *obj) const
- {
- if (obj) {
- const QMetaObject *m = obj->metaObject();
- do {
- if (m == this)
- return const_cast<QObject*>(obj);
- } while ((m = m->d.superdata));
- }
- return 0;
- }
- #ifndef QT_NO_TRANSLATION
- /*!
- \internal
- Forwards a tr() call from the \c Q_OBJECT macro to the QApplication.
- */
- QString QMetaObject::tr(const char *s, const char *c) const
- {
- if (QCoreApplication::instance())
- return QCoreApplication::instance()->translate(d.stringdata, s, c, QCoreApplication::DefaultCodec);
- else
- return QString::fromLatin1(s);
- }
- /*!
- \internal
- Forwards a trUtf8() call from the \c Q_OBJECT macro to the
- QApplication.
- */
- QString QMetaObject::trUtf8(const char *s, const char *c) const
- {
- if (QCoreApplication::instance())
- return QCoreApplication::instance()->translate(d.stringdata, s, c, QCoreApplication::UnicodeUTF8);
- else
- return QString::fromUtf8(s);
- }
- #endif // QT_NO_TRANSLATION
- /*!
- Returns the slot offset for this class; i.e. the index position of
- this class's first slot. The offset is the sum of all the slots in
- the class's super-classes (which is always positive since QObject
- has the deleteLater() slot).
- */
- int QMetaObject::slotOffset() const
- {
- int offset = 0;
- const QMetaObject *m = d.superdata;
- while (m) {
- offset += priv(m->d.data)->slotCount;
- m = m->d.superdata;
- }
- return offset;
- }
- /*!
- Returns the signal offset for this class; i.e. the index position
- of this class's first signal. The offset is the sum of all the
- signals in the class's super-classes (which is always positive
- since QObject has the slots destroyed() and destroyed(QObject*)).
- */
- int QMetaObject::signalOffset() const
- {
- int offset = 0;
- const QMetaObject *m = d.superdata;
- while (m) {
- offset += priv(m->d.data)->signalCount;
- m = m->d.superdata;
- }
- return offset;
- }
- /*!
- Returns the enumerator offset for this class; i.e. the index
- position of this class's first enumerator. If the class has no
- super-classes with enumerators, the offset is 0; otherwise the
- offset is the sum of all the enumerators in the class's
- super-classes.
- */
- int QMetaObject::enumeratorOffset() const
- {
- int offset = 0;
- const QMetaObject *m = d.superdata;
- while (m) {
- offset += priv(m->d.data)->enumeratorCount;
- m = m->d.superdata;
- }
- return offset;
- }
- /*!
- Returns the property offset for this class; i.e. the index
- position of this class's first property. The offset is the sum of
- all the properties in the class's super-classes (which is always
- positive since QObject has the name() property).
- */
- int QMetaObject::propertyOffset() const
- {
- int offset = 0;
- const QMetaObject *m = d.superdata;
- while (m) {
- offset += priv(m->d.data)->propertyCount;
- m = m->d.superdata;
- }
- return offset;
- }
- /*!
- Returns the class information offset for this class; i.e. the
- index position of this class's first class information item. If
- the class has no super-classes with class information, the offset
- is 0; otherwise the offset is the sum of all the class information
- items in the class's super-classes.
- */
- int QMetaObject::classInfoOffset() const
- {
- int offset = 0;
- const QMetaObject *m = d.superdata;
- while (m) {
- offset += priv(m->d.data)->classInfoCount;
- m = m->d.superdata;
- }
- return offset;
- }
- /*!
- Returns the number of slots in this class.
- \sa slot()
- */
- int QMetaObject::slotCount() const
- {
- int n = priv(d.data)->slotCount;
- const QMetaObject *m = d.superdata;
- while (m) {
- n += priv(m->d.data)->slotCount;
- m = m->d.superdata;
- }
- return n;
- }
- /*!
- Returns the number of signals in this class.
- \sa signal()
- */
- int QMetaObject::signalCount() const
- {
- int n = priv(d.data)->signalCount;
- const QMetaObject *m = d.superdata;
- while (m) {
- n += priv(m->d.data)->signalCount;
- m = m->d.superdata;
- }
- return n;
- }
- /*!
- Returns the number of enumerators in this class.
- \sa enumerator()
- */
- int QMetaObject::enumeratorCount() const
- {
- int n = priv(d.data)->enumeratorCount;
- const QMetaObject *m = d.superdata;
- while (m) {
- n += priv(m->d.data)->enumeratorCount;
- m = m->d.superdata;
- }
- return n;
- }
- /*!
- Returns the number of properties in this class.
- \sa property()
- */
- int QMetaObject::propertyCount() const
- {
- int n = priv(d.data)->propertyCount;
- const QMetaObject *m = d.superdata;
- while (m) {
- n += priv(m->d.data)->propertyCount;
- m = m->d.superdata;
- }
- return n;
- }
- /*!
- Returns the number of items of class information in this class.
- */
- int QMetaObject::classInfoCount() const
- {
- int n = priv(d.data)->classInfoCount;
- const QMetaObject *m = d.superdata;
- while (m) {
- n += priv(m->d.data)->classInfoCount;
- m = m->d.superdata;
- }
- return n;
- }
- /*!
- Finds \a slot and returns its index; otherwise returns -1.
- \sa slot(), slotCount()
- */
- int QMetaObject::indexOfSlot(const char *slot) const
- {
- int i = -1;
- const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->slotCount-1; i >= 0; --i)
- if (strcmp(slot, m->d.stringdata
- + m->d.data[priv(m->d.data)->slotData + 5*i]) == 0) {
- i += m->slotOffset();
- break;
- }
- m = m->d.superdata;
- }
- return i;
- }
- /*!
- Finds \a signal and returns its index; otherwise returns -1.
- \sa signal(), signalCount()
- */
- int QMetaObject::indexOfSignal(const char *signal) const
- {
- int i = -1;
- const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->signalCount-1; i >= 0; --i)
- if (strcmp(signal, m->d.stringdata
- + m->d.data[priv(m->d.data)->signalData + 5*i]) == 0) {
- i += m->signalOffset();
- break;
- }
- m = m->d.superdata;
- }
- #ifndef QT_NO_DEBUG
- if (i >= 0 && m->d.superdata) {
- int conflict = m->d.superdata->indexOfSignal(signal);
- if (conflict >= 0)
- qWarning("QMetaObject::indexOfSignal:%s: Conflict with %s::%s",
- m->d.stringdata, m->d.superdata->d.stringdata, signal);
- }
- #endif
- return i;
- }
- /*!
- Finds enumerator \a name and returns its index; otherwise returns
- -1.
- \sa enumerator(), enumeratorCount()
- */
- int QMetaObject::indexOfEnumerator(const char *name) const
- {
- int i = -1;
- const QMetaObject *m = this;
- int scope = 0;
- const char *qualified_name = name;
- const char *s = name;
- while (*s && *s != ':')
- ++s;
- if (*s && *(s+1)==':') {
- scope = s - name;
- name += scope + 2;
- }
- while (m && i < 0) {
- for (i = priv(m->d.data)->enumeratorCount-1; i >= 0; --i) {
- if ((!scope || strncmp(qualified_name, m->d.stringdata, scope) == 0)
- && strcmp(name, m->d.stringdata
- + m->d.data[priv(m->d.data)->enumeratorData + 4*i]) == 0) {
- i += m->enumeratorOffset();
- break;
- }
- }
- m = m->d.superdata;
- }
- return i;
- }
- /*!
- Finds property \a name and returns its index; otherwise returns
- -1.
- \sa property(), propertyCount()
- */
- int QMetaObject::indexOfProperty(const char *name) const
- {
- int i = -1;
- const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->propertyCount-1; i >= 0; --i)
- if (strcmp(name, m->d.stringdata
- + m->d.data[priv(m->d.data)->propertyData + 3*i]) == 0) {
- i += m->propertyOffset();
- break;
- }
- m = m->d.superdata;
- }
- return i;
- }
- /*!
- Finds class information item \a name and returns its index;
- otherwise returns -1.
- \sa classInfo(), classInfoCount()
- */
- int QMetaObject::indexOfClassInfo(const char *name) const
- {
- int i = -1;
- const QMetaObject *m = this;
- while (m && i < 0) {
- for (i = priv(m->d.data)->classInfoCount-1; i >= 0; --i)
- if (strcmp(name, m->d.stringdata
- + m->d.data[priv(d.data)->classInfoData + 2*i]) == 0) {
- i += m->classInfoOffset();
- break;
- }
- m = m->d.superdata;
- }
- return i;
- }
- /*!
- Returns the meta data for the slot with the given \a index.
- \sa indexOfSlot()
- */
- QMetaMember QMetaObject::slot(int index) const
- {
- int i = index;
- i -= slotOffset();
- if (i < 0 && d.superdata)
- return d.superdata->slot(index);
- QMetaMember result;
- if (i >= 0 && i <= priv(d.data)->slotCount) {
- result.mobj = this;
- result.handle = priv(d.data)->slotData + 5*i;
- }
- return result;
- }
- /*!
- Returns the meta data for the signal with the given \a index.
- \sa indexOfSignal()
- */
- QMetaMember QMetaObject::signal(int index) const
- {
- int i = index;
- i -= signalOffset();
- if (i < 0 && d.superdata)
- return d.superdata->signal(index);
- QMetaMember result;
- if (i >= 0 && i <= priv(d.data)->signalCount) {
- result.mobj = this;
- result.handle = priv(d.data)->signalData + 5*i;
- }
- return result;
- }
- /*!
- Returns the meta data for the enumerator with the given \a index.
- \sa indexOfEnumerator()
- */
- QMetaEnum QMetaObject::enumerator(int index) const
- {
- int i = index;
- i -= enumeratorOffset();
- if (i < 0 && d.superdata)
- return d.superdata->enumerator(index);
- QMetaEnum result;
- if (i >= 0 && i <= priv(d.data)->enumeratorCount) {
- result.mobj = this;
- result.handle = priv(d.data)->enumeratorData + 4*i;
- }
- return result;
- }
- /*!
- Returns the meta data for the property with the given \a index.
- \sa indexOfProperty()
- */
- QMetaProperty QMetaObject::property(int index) const
- {
- int i = index;
- i -= propertyOffset();
- if (i < 0 && d.superdata)
- return d.superdata->property(index);
- QMetaProperty result;
- if (i >= 0 && i <= priv(d.data)->propertyCount) {
- int handle = priv(d.data)->propertyData + 3*i;
- int flags = d.data[handle + 2];
- const char *name = d.stringdata + d.data[handle];
- const char *type = d.stringdata + d.data[handle + 1];
- if ((flags & Override) && d.superdata){
- result = property(d.superdata->indexOfProperty(name));
- if (qstrcmp(result.typeName(), type)) // type missmatch, no override
- ::memset(&result, 0, sizeof(QMetaProperty));
- }
- if (flags & EnumOrFlag) {
- result.menum = enumerator(indexOfEnumerator(type));
- }
- if (flags & Readable) {
- result.mobj[ReadProperty] = this;
- result.idx[ReadProperty] = i;
- }
- if (flags & Writable) {
- result.mobj[WriteProperty] = this;
- result.idx[WriteProperty] = i;
- }
- if (flags & Resetable) {
- result.mobj[ResetProperty] = this;
- result.idx[ResetProperty] = i;
- }
- if ((flags & ResolveDesignable) == 0) {
- result.mobj[QueryPropertyDesignable] = this;
- result.idx[QueryPropertyDesignable] = i;
- }
- if ((flags & ResolveScriptable) == 0) {
- result.mobj[QueryPropertyScriptable] = this;
- result.idx[QueryPropertyScriptable] = i;
- }
- if ((flags & ResolveStored) == 0) {
- result.mobj[QueryPropertyStored] = this;
- result.idx[QueryPropertyStored] = i;
- }
- if ((flags & ResolveEditable) == 0) {
- result.mobj[QueryPropertyEditable] = this;
- result.idx[QueryPropertyEditable] = i;
- }
- }
- return result;
- }
- /*!
- Returns the meta data for the item of class information with the
- given \a index.
- \sa indexOfClassInfo()
- */
- QMetaClassInfo QMetaObject::classInfo(int index) const
- {
- int i = index;
- i -= classInfoOffset();
- if (i < 0 && d.superdata)
- return d.superdata->classInfo(index);
- QMetaClassInfo result;
- if (i >= 0 && i <= priv(d.data)->classInfoCount) {
- result.mobj = this;
- result.handle = priv(d.data)->classInfoData + 2*i;
- }
- return result;
- }
- /*!
- Returns true if the \a signal and \a member arguments are
- compatible; otherwise returns false.
- Both \a signal and \a member are expected to be normalized.
- \sa normalizedSignature()
- */
- bool QMetaObject::checkConnectArgs(const char *signal, const char *member)
- {
- const char *s1 = signal;
- const char *s2 = member;
- while (*s1++ != '(') { } // scan to first '('
- while (*s2++ != '(') { }
- if (*s2 == ')' || qstrcmp(s1,s2) == 0) // member has no args or
- return true; // exact match
- int s1len = strlen(s1);
- int s2len = strlen(s2);
- if (s2len < s1len && strncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==',')
- return true; // member has less args
- return false;
- }
- static inline bool is_ident_char(char s)
- {
- return ((s >= 'a' && s <= 'z')
- || (s >= 'A' && s <= 'Z')
- || (s >= '0' && s <= '9')
- || s == '_'
- );
- }
- static inline bool is_space(char s)
- {
- return (s == ' ' || s == '\t');
- }
- // WARNING: a copy of this function is in moc.cpp
- static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixScope = true, bool adjustConst = true)
- {
- int len = e - t;
- if (strncmp("void", t, len) == 0)
- return QByteArray();
- /*
- Convert 'char const *' into 'const char *'. Start at index 1,
- not 0, because 'const char *' is already OK.
- */
- QByteArray constbuf;
- for (int i = 1; i < len; i++) {
- if (t[i] == 'c' &&
- strncmp(t + i + 1, "onst", 4) == 0) {
- constbuf = QByteArray(t, len);
- if (is_space(t[i-1]))
- constbuf.remove(i-1, 6);
- else
- constbuf.remove(i, 5);
- constbuf.prepend("const ");
- t = constbuf.data();
- e = constbuf.data() + constbuf.length();
- break;
- }
- /*
- We musn't convert 'char * const *' into 'const char **'
- and we must beware of 'Bar<const Bla>'.
- */
- if (t[i] == '&' || t[i] == '*' ||t[i] == '<')
- break;
- }
- if (adjustConst && e > t + 6 && strncmp("const ", t, 6) == 0) {
- if (*(e-1) == '&') { // treat const reference as value
- t += 6;
- --e;
- } else if (is_ident_char(*(e-1))) { // treat const value as value
- t += 6;
- }
- }
- QByteArray result;
- result.reserve(len);
- // some type substitutions for 'unsigned x'
- if (strncmp("unsigned ", t, 9) == 0) {
- if (strncmp("int", t+9, 3) == 0) {
- t += 9+3;
- result += "uint";
- } else if (strncmp("long", t+9, 4) == 0) {
- t += 9+4;
- result += "ulong";
- }
- }
- while (t != e) {
- char c = *t++;
- if (fixScope && c == ':' && *t == ':' ) {
- ++t;
- c = *t++;
- int i = result.size() - 1;
- while (i >= 0 && is_ident_char(result.at(i)))
- --i;
- result.resize(i + 1);
- }
- result += c;
- if (c == '<') {
- //template recursion
- const char* tt = t;
- int templdepth = 1;
- while (t != e) {
- c = *t++;
- if (c == '<')
- ++templdepth;
- if (c == '>')
- --templdepth;
- if (templdepth == 0) {
- result += normalizeTypeInternal(tt, t-1, fixScope, false);
- result += c;
- if (*t == '>')
- result += ' '; // avoid >>
- break;
- }
- }
- }
- }
- return result;
- }
- /*!
- Normalizes the signature of the given \a member.
- Qt uses normalized signatures to decide whether two given signals
- and slots are compatible. Normalization reduces whitespace to a
- minimum, moves 'const' to the front where appropriate, removes
- 'const' from value types and replaces const references with
- values.
- \sa checkConnectArgs()
- */
- QByteArray QMetaObject::normalizedSignature(const char *member)
- {
- const char *s = member;
- if (!s || !*s)
- return "";
- int len = strlen(s);
- char stackbuf[64];
- char *buf = (len >= 64 ? new char[len+1] : stackbuf);
- char *d = buf;
- char last = 0;
- while(*s && is_space(*s))
- s++;
- while (*s) {
- while (*s && !is_space(*s))
- last = *d++ = *s++;
- while (*s && is_space(*s))
- s++;
- if (*s && is_ident_char(*s) && is_ident_char(last))
- last = *d++ = ' ';
- }
- *d = '\0';
- d = buf;
- QByteArray result;
- result.reserve(len);
- int argdepth = 0;
- int templdepth = 0;
- while (*d) {
- if (argdepth == 1) {
- const char *t = d;
- while (*d&& (templdepth
- || (*d != ',' && *d != ')'))) {
- if (*d == '<')
- ++templdepth;
- if (*d == '>')
- --templdepth;
- d++;
- }
- result += normalizeTypeInternal(t, d);
- }
- if (*d == '(')
- ++argdepth;
- if (*d == ')')
- --argdepth;
- result += *d++;
- }
- if (buf != stackbuf)
- delete [] buf;
- return result;
- }
- /*!
- \class QMetaMember qmetaobject.h
- \brief The QMetaMember class provides meta data about a signal or
- slot member function.
- \ingroup objectmodel
- A QMetaMember has a signature(), a list of parameters(), a
- return typeName(), a tag(), and an access() specifier.
- */
- /*!
- \enum QMetaMember::Attributes
- \value Compatability
- \value Cloned
- */
- /*!
- \fn QMetaMember::QMetaMember()
- \internal
- */
- /*!
- Returns the signature of this member.
- */
- const char *QMetaMember::signature() const
- {
- if (!mobj)
- return 0;
- return mobj->d.stringdata + mobj->d.data[handle];
- }
- /*!
- Returns a comma-separated list of parameter names.
- */
- const char *QMetaMember::parameters() const
- {
- if (!mobj)
- return 0;
- return mobj->d.stringdata + mobj->d.data[handle + 1];
- }
- /*!
- Returns the return type of this member, or an empty string if the
- return type is \e void.
- */
- const char *QMetaMember::typeName() const
- {
- if (!mobj)
- return 0;
- return mobj->d.stringdata + mobj->d.data[handle + 2];
- }
- /*!
- Returns the tag associated with this member.
- */
- const char *QMetaMember::tag() const
- {
- if (!mobj)
- return 0;
- return mobj->d.stringdata + mobj->d.data[handle + 3];
- }
- /*! \internal */
- int QMetaMember::attributes() const
- {
- if (!mobj)
- return false;
- return mobj->d.data[handle + 4] & ~AccessMask;
- }
- /*!
- Returns the access specification of this member: private,
- protected, or public. Signals are always protected.
- */
- QMetaMember::Access QMetaMember::access() const
- {
- if (!mobj)
- return Private;
- switch(mobj->d.data[handle + 4] & AccessMask) {
- case AccessPublic:
- return Public;
- case AccessPrivate:
- return Private;
- case AccessProtected:
- return Protected;
- default:
- break;
- }
- return Private;
- }
- /*!
- \class QMetaEnum qmetaobject.h
- \brief The QMetaEnum class provides meta data about an enumerator.
- \ingroup objectmodel
- Use name() for the enumerator's name. The enumerator's keys (names
- of each enumerated item) are returned by key(); use keyCount() to find
- the number of keys. isFlag() returns whether the enumerator is
- meant to be used as a flag, meaning that its values can be combined
- using the OR operator.
- The conversion functions keyToValue(), valueToKey(), keysToValue(),
- and valueToKeys() allow conversion between the integer
- representation of an enumeration or set value and its literal
- representation. The scope() function returns the class scope this
- enumerator was declared in.
- */
- /*!
- \fn bool QMetaEnum::isValid() const
- Returns true if this enum is valid (has a name); otherwise returns
- false.
- */
- /*!
- \fn QMetaEnum::QMetaEnum()
- \internal
- */
- /*!
- Returns the name of the enumerator.
- \sa isValid()
- */
- const char* QMetaEnum::name() const
- {
- if (!mobj)
- return 0;
- return mobj->d.stringdata + mobj->d.data[handle];
- }
- /*!
- Returns the number of keys.
- \sa key()
- */
- int QMetaEnum::keyCount() const
- {
- if (!mobj)
- return 0;
- return mobj->d.data[handle + 2];
- }
- /*!
- Returns the key with the given \a index, or 0 if no such key exists.
- \sa keyCount() value()
- */
- const char *QMetaEnum::key(int index) const
- {
- if (!mobj)
- return 0;
- int count = mobj->d.data[handle + 2];
- int data = mobj->d.data[handle + 3];
- if (index >= 0 && index < count)
- return mobj->d.stringdata + mobj->d.data[data + 2*index];
- return 0;
- }
- /*!
- Returns the value with the given \a index; or returns -1 if there
- is no such value.
- \sa keyCount() key()
- */
- int QMetaEnum::value(int index) const
- {
- if (!mobj)
- return 0;
- int count = mobj->d.data[handle + 2];
- int data = mobj->d.data[handle + 3];
- if (index >= 0 && index < count)
- return mobj->d.data[data + 2*index + 1];
- return -1;
- }
- /*!
- Returns true if this enumerator is used as a flag; otherwise returns
- false.
- When used as flags, enumerators can be combined using the OR
- operator.
- \sa keysToValue(), valueToKeys()
- */
- bool QMetaEnum::isFlag() const
- {
- return mobj && mobj->d.data[handle + 1];
- }
- /*!
- Returns the scope this enumerator was declared in.
- */
- const char *QMetaEnum::scope() const
- {
- return mobj?mobj->d.stringdata : 0;
- }
- /*!
- Returns the integer value of the given enumeration \a key, or -1
- if \a key is not defined.
- For set types, use keysToValue().
- \sa valueToKey(), isFlag(), keysToValue()
- */
- int QMetaEnum::keyToValue(const char *key) const
- {
- if (!mobj || !key)
- return -1;
- int scope = 0;
- const char *qualified_key = key;
- const char *s = key;
- while (*s && *s != ':')
- ++s;
- if (*s && *(s+1)==':') {
- scope = s - key;
- key += scope + 2;
- }
- int count = mobj->d.data[handle + 2];
- int data = mobj->d.data[handle + 3];
- for (int i = 0; i < count; ++i)
- if ((!scope || strncmp(qualified_key, mobj->d.stringdata, scope) == 0)
- && strcmp(key, mobj->d.stringdata + mobj->d.data[data + 2*i]) == 0)
- return mobj->d.data[data + 2*i + 1];
- return -1;
- }
- /*!
- Returns the string that is used as the name of the given
- enumeration \a value, or 0 if \a value is not defined.
- For set types, use valueToKeys().
- \sa valueToKey() isFlag() valueToKeys()
- */
- const char* QMetaEnum::valueToKey(int value) const
- {
- if (!mobj)
- return 0;
- int count = mobj->d.data[handle + 2];
- int data = mobj->d.data[handle + 3];
- for (int i = 0; i < count; ++i)
- if (value == (int)mobj->d.data[data + 2*i + 1])
- return mobj->d.stringdata + mobj->d.data[data + 2*i];
- return 0;
- }
- /*!
- Returns the value derived from combining together the values of the
- \a keys using the OR operator. Note that the strings in \a keys
- must be '|'-separated.
- \sa isFlag(), valueToKey(), keysToValue()
- */
- int QMetaEnum::keysToValue(const char *keys) const
- {
- if (!mobj)
- return -1;
- QStringList l = QString::fromLatin1(keys).split(QLatin1Char('|'));
- //#### TODO write proper code, do not use QStringList
- int value = 0;
- int count = mobj->d.data[handle + 2];
- int data = mobj->d.data[handle + 3];
- for (int li = 0; li < l.size(); ++li) {
- QString trimmed = l.at(li).trimmed();
- const char *key = trimmed.latin1();
- int scope = 0;
- const char *qualified_key = key;
- const char *s = key;
- while (*s && *s != ':')
- ++s;
- if (*s && *(s+1)==':') {
- scope = s - key;
- key += scope + 2;
- }
- int i;
- for (i = count-1; i >= 0; --i)
- if ((!scope || strncmp(qualified_key, mobj->d.stringdata, scope) == 0)
- && strcmp(key, mobj->d.stringdata + mobj->d.data[data + 2*i]) == 0) {
- value |= mobj->d.data[data + 2*i + 1];
- break;
- }
- if (i < 0)
- value |= -1;
- }
- return value;
- }
- /*!
- Returns a byte array of '|'-separated keys that represents the
- given \a value.
- \sa isFlag(), valueToKey(), valueToKeys()
- */
- QByteArray QMetaEnum::valueToKeys(int value) const
- {
- QByteArray keys;
- if (!mobj)
- return keys;
- int count = mobj->d.data[handle + 2];
- int data = mobj->d.data[handle + 3];
- int v = value;
- for(int i = count - 1; i >= 0; --i) {
- int k = mobj->d.data[data + 2*i + 1];
- if ((k != 0 && (v & k) == k ) || (k == value)) {
- v = v & ~k;
- if (!keys.isEmpty())
- keys += '|';
- keys += mobj->d.stringdata + mobj->d.data[data + 2*i];
- }
- }
- return keys;
- }
- /*!
- \class QMetaProperty qmetaobject.h
- \brief The QMetaProperty class provides meta data about a property.
- \ingroup objectmodel
- A property has a name() and a type(), as well as various
- attributes that specify its behavior: isReadable(), isWritable(),
- isDesignable(), isScriptable(), isStored(), and isEditable().
- If the property is an enumeration, isEnumType() returns true; if the
- property is an enumeration that is also a flag (i.e. its values
- can be combined using the OR operator), isEnumType() and
- isFlagType() both return true. The enumerator for these types is
- available from enumerator().
- The property's values are set and retrieved with read(), write(),
- and reset(); they can also be changed through QObject's set and get
- functions. See QObject::setProperty() and QObject::property() for
- details.
- You get meta property data through an object's meta object. See
- QMetaObject::property() and QMetaObject::propertyCount() for
- details.
- */
- /*!
- \fn bool QMetaProperty::isValid() const
- Returns true if this property is valid (readable); otherwise
- returns false.
- */
- /*!
- Constructs an invalid property
- \internal
- */
- QMetaProperty::QMetaProperty()
- {
- ::memset(this, 0, sizeof(QMetaProperty));
- }
- /*!
- Returns this property's name.
- */
- const char *QMetaProperty::name() const
- {
- if (!mobj[QMetaObject::ReadProperty])
- return 0;
- int handle = priv(mobj[QMetaObject::ReadProperty]->d.data)->propertyData + 3*idx[QMetaObject::ReadProperty];
- return mobj[QMetaObject::ReadProperty]->d.stringdata + mobj[QMetaObject::ReadProperty]->d.data[handle];
- }
- /*!
- Returns the name of this property's type.
- */
- const char *QMetaProperty::typeName() const
- {
- if (!mobj[QMetaObject::ReadProperty])
- return 0;
- int handle = priv(mobj[QMetaObject::ReadProperty]->d.data)->propertyData + 3*idx[QMetaObject::ReadProperty];
- return mobj[QMetaObject::ReadProperty]->d.stringdata + mobj[QMetaObject::ReadProperty]->d.data[handle + 1];
- }
- /*!
- Returns this property's type. The return value is one
- of the values of the QCoreVariant::Type enumeration, or
- -1 for properties of type QVariant.
- */
- uint QMetaProperty::type() const
- {
- if (!mobj[QMetaObject::ReadProperty])
- return 0;
- int handle = priv(mobj[QMetaObject::ReadProperty]->d.data)->propertyData + 3*idx[QMetaObject::ReadProperty];
- int flags = mobj[QMetaObject::ReadProperty]->d.data[handle + 2];
- return (QCoreVariant::Type)flags >> 24;
- }
- /*!
- Returns true if the property's type is an enumeration value that
- is used as a flag; otherwise returns false.
- Flags can be combined using the OR operator. A set type is
- implicitly also an enum type.
- \sa isEnumType(), enumerator()
- */
- bool QMetaProperty::isFlagType() const
- {
- return isEnumType() && menum.isFlag();
- }
- /*!
- Returns true if the property's type is an enumeration value;
- otherwise returns false.
- \sa enumerator(), isFlagType()
- */
- bool QMetaProperty::isEnumType() const
- {
- if (!mobj[QMetaObject::ReadProperty])
- return 0;
- int handle = priv(mobj[QMetaObject::ReadProperty]->d.data)->propertyData + 3*idx[QMetaObject::ReadProperty];
- int flags = mobj[QMetaObject::ReadProperty]->d.data[handle + 2];
- return (flags & EnumOrFlag) && menum.name();
- }
- /*!
- \internal
- Returns true if the property has a C++ setter function that
- follows Qt's standard "name" / "setName" pattern. Designer and uic
- query hasStdCppSet() in order to avoid expensive
- QObject::setProperty() calls. All properties in Qt [should] follow
- this pattern.
- */
- bool QMetaProperty::hasStdCppSet() const
- {
- if (!mobj[QMetaObject::ReadProperty])
- return 0;
- int handle = priv(mobj[QMetaObject::ReadProperty]->d.data)->propertyData + 3*idx[QMetaObject::ReadProperty];
- int flags = mobj[QMetaObject::ReadProperty]->d.data[handle + 2];
- return (flags & StdCppSet);
- }
- /*!
- Returns the enumerator if this property's type is an enumerator
- type; otherwise the returned value is undefined.
- \sa isEnumType()
- */
- QMetaEnum QMetaProperty::enumerator() const
- {
- return menum;
- }
- /*!
- \fn QCoreVariant QMetaProperty::read(const QObject *object) const
- Reads the property's value from the given \a object. Returns the value
- if it was able to read it; otherwise returns an invalid variant.
- \sa write() isReadable()
- */
- QCoreVariant QMetaProperty::read(const QObject *obj) const
- {
- if (!obj || !mobj[QMetaObject::ReadProperty])
- return QCoreVariant();
- QCoreVariant::Type t = QCoreVariant::Int;
- if (!isEnumType()) {
- int handle = priv(mobj[QMetaObject::ReadProperty]->d.data)->propertyData + 3*idx[QMetaObject::ReadProperty];
- int flags = mobj[QMetaObject::ReadProperty]->d.data[handle + 2];
- t = (QCoreVariant::Type)(flags >> 24);
- if (t == QCoreVariant::Invalid)
- t = QCoreVariant::nameToType(mobj[QMetaObject::ReadProperty]->d.stringdata
- + mobj[QMetaObject::ReadProperty]->d.data[handle + 1]);
- if (t == QCoreVariant::Invalid)
- return QCoreVariant();
- }
- QCoreVariant value;
- void *argv[1];
- void *user = 0;
- if ((uint)t == 0xffffffff) {
- argv[0] = &value;
- } else if (t == QCoreVariant::UserType) {
- qVariantSet(value, user, typeName());
- argv[0] = &user;
- } else {
- value = QCoreVariant(t, (void*)0);
- argv[0] = value.data();
- }
- const_cast<QObject*>(obj)->qt_metacall(QMetaObject::ReadProperty,
- idx[QMetaObject::ReadProperty] + mobj[QMetaObject::ReadProperty]->propertyOffset(),
- argv);
- if (t == QCoreVariant::UserType)
- qVariantSet(value, user, typeName());
- else if ((uint)t != 0xffffffff && argv[0] != value.data())
- return QCoreVariant(t, argv[0]);
- return value;
- }
- /*!
- \fn bool QMetaProperty::write(QObject *object, const QCoreVariant &value) const
- Writes \a value as the property's value to the given \a object. Returns
- true if the write succeeded; otherwise returns false.
- \sa read() isWritable()
- */
- bool QMetaProperty::write(QObject *obj, const QCoreVariant &value) const
- {
- if (!obj || !isWritable())
- return false;
- QCoreVariant v = value;
- QCoreVariant::Type t = QCoreVariant::Invalid;
- if (isEnumType()) {
- if (v.type() == QCoreVariant::String || v.type() == QCoreVariant::CString) {
- if (isFlagType())
- v = QCoreVariant(menum.keysToValue(value.toByteArray()));
- else
- v = QCoreVariant(menum.keyToValue(value.toByteArray()));
- } else if (v.type() != QCoreVariant::Int && v.type() != QCoreVariant::UInt) {
- return false;
- }
- v.cast(QCoreVariant::Int);
- } else {
- int handle = priv(mobj[QMetaObject::WriteProperty]->d.data)->propertyData + 3*idx[QMetaObject::WriteProperty];
- int flags = mobj[QMetaObject::WriteProperty]->d.data[handle + 2];
- t = (QCoreVariant::Type)(flags >> 24);
- if (t == QCoreVariant::Invalid)
- t = QCoreVariant::nameToType(mobj[QMetaObject::WriteProperty]->d.stringdata
- + mobj[QMetaObject::WriteProperty]->d.data[handle + 1]);
- if (t != QCoreVariant::Invalid && (uint)t != 0xffffffff && t != QCoreVariant::UserType && !v.cast(t))
- return false;
- }
- void *argv[1];
- if ((uint)t == 0xffffffff)
- argv[0] = &v;
- else
- argv[0] = v.data();
- obj->qt_metacall(QMetaObject::WriteProperty,
- idx[QMetaObject::WriteProperty] + mobj[QMetaObject::WriteProperty]->propertyOffset(),
- argv);
- return true;
- }
- /*!
- \fn bool QMetaProperty::reset(QObject *object) const
- Resets the property for the given \a object with a reset method.
- Returns true if the reset worked; otherwise returns false.
- Reset methods are optional; only a few properties support them.
- */
- bool QMetaProperty::reset(QObject *obj) const
- {
- if (!obj || !mobj[QMetaObject::ResetProperty])
- return false;
- void *argv[] = { 0 };
- obj->qt_metacall(QMetaObject::ResetProperty,
- idx[QMetaObject::ResetProperty] + mobj[QMetaObject::ResetProperty]->propertyOffset(),
- argv);
- return true;
- }
- /*!
- Returns true if this property is readable; otherwise returns false.
- \sa read() isWritable()
- */
- bool QMetaProperty::isReadable() const
- {
- return mobj[QMetaObject::ReadProperty] != 0;
- }
- /*!
- Returns true if this property is writable; otherwise returns
- false.
- \sa write() isReadable()
- */
- bool QMetaProperty::isWritable() const
- {
- if (!mobj[QMetaObject::WriteProperty])
- return false;
- int handle = priv(mobj[QMetaObject::ReadProperty]->d.data)->propertyData + 3*idx[QMetaObject::ReadProperty];
- int flags = mobj[QMetaObject::ReadProperty]->d.data[handle + 2];
- return !(flags & EnumOrFlag) || menum.name();
- }
- static bool qt_query_property(const QMetaObject*const*mobj,const int *idx, uint flag,
- QMetaObject::Call call, const QObject* obj)
- {
- if (!mobj[call])
- return false;
- int handle = priv(mobj[call]->d.data)->propertyData + 3*idx[call];
- int flags = mobj[call]->d.data[handle + 2];
- bool b = (flags & flag);
- if (obj) {
- void *argv[] = { &b };
- const_cast<QObject*>(obj)->qt_metacall(call,
- idx[call]
- + mobj[call]->propertyOffset(),
- argv);
- }
- return b;
- }
- /*!
- \fn bool QMetaProperty::isDesignable(const QObject *object) const
- Returns true if this property is designable for the given \a object;
- otherwise returns false.
- If no \a object is given, the function returns false if the
- \c{Q_PROPERTY}'s \c DESIGNABLE attribute is false; otherwise
- returns true (if the attribute is true or is a function or expression).
- */
- bool QMetaProperty::isDesignable(const QObject *obj) const
- {
- if (!mobj[QMetaObject::WriteProperty])
- return false;
- return qt_query_property(mobj, idx, Designable,
- QMetaObject::QueryPropertyDesignable,
- obj);
- }
- /*!
- \fn bool QMetaProperty::isScriptable(const QObject *object) const
- Returns true if the property is scriptable for the given \a object;
- otherwise returns false.
- If no \a object is given, the function returns false if the
- \c{Q_PROPERTY}'s \c DESIGNABLE attribute is false; otherwise returns
- true (if the attribute is true or is a function or expression).
- */
- bool QMetaProperty::isScriptable(const QObject *obj) const
- {
- return qt_query_property(mobj, idx, Scriptable,
- QMetaObject::QueryPropertyScriptable,
- obj);
- }
- /*!
- \fn bool QMetaProperty::isStored(const QObject *object) const
- Returns true if the property is stored for \a object; otherwise returns
- false.
- If no \a object is given, the function returns false if the
- \c{Q_PROPERTY}'s \c DESIGNABLE attribute is false; otherwise returns
- true (if the attribute is true or is a function or expression).
- */
- bool QMetaProperty::isStored(const QObject *obj) const
- {
- return qt_query_property(mobj, idx, Stored,
- QMetaObject::QueryPropertyStored,
- obj);
- }
- /*!
- \fn bool QMetaProperty::isEditable(const QObject *object) const
- Returns true if the property is editable for the given \a object;
- otherwise returns false.
- If no \a object is given, the function returns false if the
- \c{Q_PROPERTY}'s \c DESIGNABLE attribute is false; otherwise returns
- true (if the attribute is true or is a function or expression).
- */
- bool QMetaProperty::isEditable(const QObject *obj) const
- {
- return qt_query_property(mobj, idx, Editable,
- QMetaObject::QueryPropertyEditable,
- obj);
- }
- /*!
- \class QMetaClassInfo qmetaobject.h
- \brief The QMetaClassInfo class provides additional information
- about a class.
- \ingroup objectmodel
- Class information items are simple \e{name}--\e{value} pairs that
- are specified using \c Q_CLASSINFO in the source code. The
- information can be retrieved using name() and value().
- */
- /*!
- \fn QMetaClassInfo::QMetaClassInfo()
- \internal
- */
- /*!
- Returns the name of this item.
- \sa value()
- */
- const char* QMetaClassInfo::name() const
- {
- if (!mobj)
- return 0;
- return mobj->d.stringdata + mobj->d.data[handle];
- }
- /*!
- Returns the value of this item.
- \sa name()
- */
- const char* QMetaClassInfo::value() const
- {
- if (!mobj)
- return 0;
- return mobj->d.stringdata + mobj->d.data[handle + 1];
- }
- /*!
- \class QMetaType qmetaobject.h
- \brief The QMetaType class manages named types in the meta object system.
- \internal
- \ingroup objectmodel
- The class is used to queue signals and slots connections.
- */
- static const struct { const char * typeName; int type; } types[] = {
- {"void*", QMetaType::VoidStar},
- {"long", QMetaType::Long},
- {"int", QMetaType::Int},
- {"short", QMetaType::Short},
- {"char", QMetaType::Char},
- {"ulong", QMetaType::ULong},
- {"unsigned long", QMetaType::ULong},
- {"uint", QMetaType::UInt},
- {"unsigned int", QMetaType::UInt},
- {"ushort", QMetaType::UShort},
- {"unsigned short", QMetaType::UShort},
- {"uchar", QMetaType::UChar},
- {"unsigned char", QMetaType::UChar},
- {"bool", QMetaType::Bool},
- {"float", QMetaType::Float},
- {"double", QMetaType::Double},
- {"QChar", QMetaType::QChar},
- {"QByteArray", QMetaType::QByteArray},
- {"QString", QMetaType::QString},
- {"void", QMetaType::Void},
- {"", QMetaType::Void},
- {0, QMetaType::Void}
- };
- class QCustomTypeInfo
- {
- public:
- QCustomTypeInfo() : typeName(0, '\0'), copy(0), destr(0), saveOp(0), loadOp(0) {}
- inline void setData(const char *tname, QMetaType::CopyConstructor cp, QMetaType::Destructor de)
- { typeName = tname; copy = cp; destr = de; }
- inline void setData(QMetaType::CopyConstructor cp, QMetaType::Destructor de)
- { copy = cp; destr = de; }
- inline void setOperators(QMetaType::SaveOperator sOp, QMetaType::LoadOperator lOp)
- { saveOp = sOp; loadOp = lOp; }
- QByteArray typeName;
- QMetaType::CopyConstructor copy;
- QMetaType::Destructor destr;
- QMetaType::SaveOperator saveOp;
- QMetaType::LoadOperator loadOp;
- };
- Q_GLOBAL_STATIC(QVector<QCustomTypeInfo>, customTypes)
- void QMetaType::registerStreamOperators(const char *typeName, SaveOperator saveOp,
- LoadOperator loadOp)
- {
- int idx = type(typeName);
- if (!idx)
- return;
- QVector<QCustomTypeInfo> *ct = customTypes();
- if (!ct)
- return;
- (*ct)[idx - User].setOperators(saveOp, loadOp);
- }
- /*!
- Returns the type name associated with the given \a type, or 0 if no
- matching type was found. The returned pointer must not be deleted.
- */
- const char *QMetaType::typeName(int type)
- {
- if (type >= User) {
- if (!isRegistered(type))
- return 0;
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- if (!ct)
- return 0;
- return ct->at(type - User).typeName.constData();
- }
- int i = 0;
- while (types[i].typeName) {
- if (types[i].type == type)
- return types[i].typeName;
- ++i;
- }
- return 0;
- }
- /*!
- Registers a user type for marshalling, with \a typeName, a \a
- destructor, and a \a copyConstructor. Returns the type's handle,
- or -1 if the type could not be registered.
- */
- int QMetaType::registerType(const char *typeName, Destructor destructor,
- CopyConstructor copyConstructor)
- {
- QVector<QCustomTypeInfo> *ct = customTypes();
- static int currentIdx = User;
- if (!ct || !typeName || !destructor || !copyConstructor)
- return -1;
- int idx = type(typeName);
- if (idx) {
- if (idx < User) {
- qWarning("cannot re-register basic type '%s'", typeName);
- return -1;
- }
- (*ct)[idx - User].setData(copyConstructor, destructor);
- } else {
- idx = currentIdx++;
- ct->resize(ct->count() + 1);
- (*ct)[idx - User].setData(typeName, copyConstructor, destructor);
- }
- return idx;
- }
- /*!
- Returns true if the custom datatype with ID \a type is registered;
- otherwise returns false.
- */
- bool QMetaType::isRegistered(int type)
- {
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- return (type >= User) && (ct && ct->count() > type - User);
- }
- /*!
- Returns a handle to the type called \a typeName, or 0 if there is
- no such type.
- */
- int QMetaType::type(const char *typeName)
- {
- if (!typeName)
- return 0;
- int i = 0;
- while (types[i].typeName && strcmp(typeName, types[i].typeName))
- ++i;
- if (!types[i].type) {
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- for (int v = 0; ct && v < ct->count(); ++v) {
- if (strcmp(ct->at(v).typeName, typeName) == 0)
- return v + User;
- }
- }
- return types[i].type;
- }
- bool QMetaType::save(QDataStream &stream, int type, const void *data)
- {
- // FIXME - also stream simple types?
- if (!data || !isRegistered(type))
- return false;
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- if (!ct)
- return false;
- QMetaType::SaveOperator saveOp = ct->at(type - User).saveOp;
- if (!saveOp)
- return false;
- saveOp(stream, data);
- return true;
- }
- bool QMetaType::load(QDataStream &stream, int type, void *data)
- {
- // FIXME - also stream simple types?
- if (!data || !isRegistered(type))
- return false;
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- if (!ct)
- return false;
- QMetaType::LoadOperator loadOp = ct->at(type - User).loadOp;
- if (!loadOp)
- return false;
- loadOp(stream, data);
- return true;
- }
- /*
- Returns a copy of data, assuming it is of type \a type.
- */
- void *QMetaType::copy(int type, const void *data)
- {
- if (!data)
- return 0;
- switch(type) {
- case QMetaType::VoidStar:
- return new void *(*static_cast<void* const *>(data));
- case QMetaType::Long:
- return new long(*static_cast<const long*>(data));
- case QMetaType::Int:
- return new int(*static_cast<const int*>(data));
- case QMetaType::Short:
- return new short(*static_cast<const short*>(data));
- case QMetaType::Char:
- return new char(*static_cast<const char*>(data));
- case QMetaType::ULong:
- return new ulong(*static_cast<const ulong*>(data));
- case QMetaType::UInt:
- return new uint(*static_cast<const uint*>(data));
- case QMetaType::UShort:
- return new ushort(*static_cast<const ushort*>(data));
- case QMetaType::UChar:
- return new uchar(*static_cast<const uchar*>(data));
- case QMetaType::Bool:
- return new bool(*static_cast<const bool*>(data));
- case QMetaType::Float:
- return new float(*static_cast<const float*>(data));
- case QMetaType::Double:
- return new double(*static_cast<const double*>(data));
- case QMetaType::QChar:
- return new ::QChar(*static_…
Large files files are truncated, but you can click here to view the full file