From 52f14f40f233146f76a3c1eb143deb12c6a5b2d6 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 4 Dec 2015 11:59:07 +0100 Subject: Provide a way to get to the ApplicationDomainType base class QVariant doesn't support polymorphism for non-QObject classes. --- common/clientapi.h | 3 ++- common/modelresult.cpp | 4 ++++ common/modelresult.h | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/clientapi.h b/common/clientapi.h index edf42e4..074aabc 100644 --- a/common/clientapi.h +++ b/common/clientapi.h @@ -45,7 +45,8 @@ public: enum Roles { DomainObjectRole = Qt::UserRole + 1, //Must be the same as in ModelResult - ChildrenFetchedRole + ChildrenFetchedRole, + DomainObjectBaseRole }; /** diff --git a/common/modelresult.cpp b/common/modelresult.cpp index c7fcd49..4fd8d97 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp @@ -71,6 +71,10 @@ QVariant ModelResult::data(const QModelIndex &index, int role) const Q_ASSERT(mEntities.contains(index.internalId())); return QVariant::fromValue(mEntities.value(index.internalId())); } + if (role == DomainObjectBaseRole) { + Q_ASSERT(mEntities.contains(index.internalId())); + return QVariant::fromValue(mEntities.value(index.internalId()). template staticCast()); + } if (role == ChildrenFetchedRole) { return childrenFetched(index); } diff --git a/common/modelresult.h b/common/modelresult.h index 700064b..298e157 100644 --- a/common/modelresult.h +++ b/common/modelresult.h @@ -34,7 +34,8 @@ class ModelResult : public QAbstractItemModel public: enum Roles { DomainObjectRole = Qt::UserRole + 1, - ChildrenFetchedRole + ChildrenFetchedRole, + DomainObjectBaseRole }; ModelResult(const Akonadi2::Query &query, const QList &propertyColumns); -- cgit v1.2.3