diff options
-rw-r--r-- | examples/widgets/cloudaddressbook/addressbookmodel.h | 2 | ||||
-rw-r--r-- | examples/widgets/todos-cpp/todosmodel.h | 2 | ||||
-rw-r--r-- | src/enginio_client/enginio.h | 2 | ||||
-rw-r--r-- | src/enginio_client/enginiomodel.cpp | 12 | ||||
-rw-r--r-- | tests/auto/enginiomodel/tst_enginiomodel.cpp | 10 |
5 files changed, 14 insertions, 14 deletions
diff --git a/examples/widgets/cloudaddressbook/addressbookmodel.h b/examples/widgets/cloudaddressbook/addressbookmodel.h index 362a931..fc5580c 100644 --- a/examples/widgets/cloudaddressbook/addressbookmodel.h +++ b/examples/widgets/cloudaddressbook/addressbookmodel.h @@ -54,7 +54,7 @@ class AddressBookModel : public EnginioModel public: //![Roles] enum Roles { - FirstNameRole = Enginio::LastRole, + FirstNameRole = Enginio::CustomPropertyRole, LastNameRole, EmailRole, PhoneRole, diff --git a/examples/widgets/todos-cpp/todosmodel.h b/examples/widgets/todos-cpp/todosmodel.h index c839753..76e2f19 100644 --- a/examples/widgets/todos-cpp/todosmodel.h +++ b/examples/widgets/todos-cpp/todosmodel.h @@ -51,7 +51,7 @@ class TodosModel : public EnginioModel public: enum Role { - TitleRole = Enginio::LastRole, + TitleRole = Enginio::CustomPropertyRole, CompletedRole }; //![definition] diff --git a/src/enginio_client/enginio.h b/src/enginio_client/enginio.h index 64471e3..fb3088b 100644 --- a/src/enginio_client/enginio.h +++ b/src/enginio_client/enginio.h @@ -91,7 +91,7 @@ public: UpdatedAtRole, IdRole, ObjectTypeRole, - LastRole = Qt::UserRole + 10 // the first fully dynamic role + CustomPropertyRole = Qt::UserRole + 10 // the first fully dynamic role }; enum ErrorType { diff --git a/src/enginio_client/enginiomodel.cpp b/src/enginio_client/enginiomodel.cpp index eb3facb..7f8c496 100644 --- a/src/enginio_client/enginiomodel.cpp +++ b/src/enginio_client/enginiomodel.cpp @@ -284,14 +284,14 @@ void EnginioBaseModelPrivate::syncRoles() _roles[Enginio::UpdatedAtRole] = EnginioString::updatedAt; _roles[Enginio::IdRole] = EnginioString::id; _roles[Enginio::ObjectTypeRole] = EnginioString::objectType; - _rolesCounter = Enginio::LastRole; + _rolesCounter = Enginio::CustomPropertyRole; } // check if someone does not use custom roles QHash<int, QByteArray> predefinedRoles = q->roleNames(); foreach (int i, predefinedRoles.keys()) { - if (i < Enginio::LastRole && i >= Enginio::SyncedRole && predefinedRoles[i] != _roles[i].toUtf8()) { - qWarning("Can not use custom role index lower then Enginio::LastRole, but '%i' was used for '%s'", i, predefinedRoles[i].constData()); + if (i < Enginio::CustomPropertyRole && i >= Enginio::SyncedRole && predefinedRoles[i] != _roles[i].toUtf8()) { + qWarning("Can not use custom role index lower then Enginio::CustomPropertyRole, but '%i' was used for '%s'", i, predefinedRoles[i].constData()); continue; } _roles[i] = QString::fromUtf8(predefinedRoles[i].constData()); @@ -392,11 +392,11 @@ EnginioBaseModel::~EnginioBaseModel() \value IdRole \c What is the id of an item \value ObjectTypeRole \c What is item type \value SyncedRole \c Mark if an item is in sync with the backend + \value CustomPropertyRole \c The first role id that may be used for dynamically created roles. \omitvalue InvalidRole - \omitvalue LastRole Additionally EnginioModel supports dynamic roles which are mapped - directly from recieved data. EnginioModel is mapping first item properties + directly from received data. EnginioModel is mapping an item's properties to role names. \note Some objects may not contain value for a static role, it may happen @@ -599,7 +599,7 @@ bool EnginioBaseModel::setData(const QModelIndex &index, const QVariant &value, \note when reimplementating this function, you need to call the base class implementation first and take the result into account as shown in the {todos-cpp}{Todos Example} - \note custom role indexes have to be greater then or equal to \l Enginio::LastRole + \note custom role indexes have to not overlap with \l Enginio::Role */ QHash<int, QByteArray> EnginioBaseModel::roleNames() const { diff --git a/tests/auto/enginiomodel/tst_enginiomodel.cpp b/tests/auto/enginiomodel/tst_enginiomodel.cpp index 9d1ed35..113aa9c 100644 --- a/tests/auto/enginiomodel/tst_enginiomodel.cpp +++ b/tests/auto/enginiomodel/tst_enginiomodel.cpp @@ -1364,13 +1364,13 @@ void tst_EnginioModel::updatingRoles() QJsonObject query; query.insert("objectType", objectType); - QTest::ignoreMessage(QtWarningMsg, "Can not use custom role index lower then Enginio::LastRole, but '261' was used for 'invalid'"); + QTest::ignoreMessage(QtWarningMsg, "Can not use custom role index lower then Enginio::CustomPropertyRole, but '261' was used for 'invalid'"); struct CustomModel: public EnginioModel { enum { - BarRole = Enginio::LastRole, - FooRole = Enginio::LastRole + 1, - TitleRole = Enginio::LastRole + 20, // existing custom role + BarRole = Enginio::CustomPropertyRole, + FooRole = Enginio::CustomPropertyRole + 1, + TitleRole = Enginio::CustomPropertyRole + 20, // existing custom role InvalidRole = Enginio::ObjectTypeRole, // custom and with wrong index IdRole = Enginio::IdRole // duplicate of existing role }; @@ -1441,7 +1441,7 @@ void tst_EnginioModel::setData() struct Model: public EnginioModel { enum Roles { - TitleRole = Enginio::LastRole + TitleRole = Enginio::CustomPropertyRole }; virtual QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE |