diff options
Diffstat (limited to 'src/qdataroles_p.h')
-rw-r--r-- | src/qdataroles_p.h | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/qdataroles_p.h b/src/qdataroles_p.h index e71c650..6eb8f5a 100644 --- a/src/qdataroles_p.h +++ b/src/qdataroles_p.h @@ -36,16 +36,52 @@ // #include <qmetaobject.h> +#include <qdebug.h> QT_BEGIN_NAMESPACE -struct QtDataRoles : private QObject +class QtDataRoles : private QObject { - static QHash<int, QString> roles() { - QHash<int,QString> roles; - const QMetaObject &staticMetaObject = static_cast<QtDataRoles*>(0)->staticQtMetaObject; - const int index = staticMetaObject.indexOfEnumerator("DataRoles"); - const QMetaEnum metaEnum = staticMetaObject.enumerator(index); + Q_OBJECT + Q_ENUMS(ItemDataRole) +public: + enum ItemDataRole { + DisplayRole = 0, + DecorationRole = 1, + EditRole = 2, + ToolTipRole = 3, + StatusTipRole = 4, + WhatsThisRole = 5, + // Metadata + FontRole = 6, + TextAlignmentRole = 7, + BackgroundColorRole = 8, + BackgroundRole = 8, + TextColorRole = 9, + ForegroundRole = 9, + CheckStateRole = 10, + // Accessibility + AccessibleTextRole = 11, + AccessibleDescriptionRole = 12, + // More general purpose + SizeHintRole = 13, + // Internal UiLib roles. Start worrying when public roles go that high. + DisplayPropertyRole = 27, + DecorationPropertyRole = 28, + ToolTipPropertyRole = 29, + StatusTipPropertyRole = 30, + WhatsThisPropertyRole = 31, + // Reserved + UserRole = 32 + }; + + static QHash<int, QByteArray> roles() { + QHash<int,QByteArray> roles; + const QMetaObject &metaObject = QtDataRoles().staticMetaObject;//static_cast<QtDataRoles*>(0)->staticQtMetaObject; + const int index = metaObject.indexOfEnumerator("ItemDataRole"); + if (index == -1) + qWarning() << "QtDataRoles: could not find ItemDataRoles enumerator"; + const QMetaEnum metaEnum = metaObject.enumerator(index); for (int i = 0; i < metaEnum.keyCount(); ++i) roles.insert(metaEnum.value(i), metaEnum.key(i)); return roles; |