summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-02-12 14:06:18 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-02-12 14:32:23 +0000
commit18e3d741c3526978cdacc88bc260d250918d2080 (patch)
tree751d4f540543795944bc984bf2d6004c7c17e7d6
parent86db658eace4dc84c1d3185c71f2282278b3a452 (diff)
Replace defaultCollection() with defaultCollectionId()
This assumes the id of a default collection is known at the engine initialization time, but makes it possible to defer fetching the default collection's content up until it is needed. This also greatly simplifies the initialization process for the async-only engines. Change-Id: I5116ffdd22d7fa6cc5f8a8eed7f94518e6db7089 Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
-rw-r--r--examples/organizer/calendardemo/src/calendardemo.cpp4
-rw-r--r--src/contacts/qcontactmanager.cpp9
-rw-r--r--src/contacts/qcontactmanager.h2
-rw-r--r--src/contacts/qcontactmanagerengine.cpp8
-rw-r--r--src/contacts/qcontactmanagerengine.h2
-rw-r--r--src/imports/organizer/qdeclarativeorganizermodel.cpp10
-rw-r--r--src/imports/organizer/qdeclarativeorganizermodel_p.h2
-rw-r--r--src/organizer/doc/src/organizerengines.qdoc3
-rw-r--r--src/organizer/doc/src/organizersync.qdoc3
-rw-r--r--src/organizer/qorganizermanager.cpp9
-rw-r--r--src/organizer/qorganizermanager.h2
-rw-r--r--src/organizer/qorganizermanagerengine.cpp8
-rw-r--r--src/organizer/qorganizermanagerengine.h2
-rw-r--r--src/plugins/contacts/memory/qcontactmemorybackend.cpp14
-rw-r--r--src/plugins/contacts/memory/qcontactmemorybackend_p.h4
-rw-r--r--src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp8
-rw-r--r--src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h5
-rw-r--r--src/plugins/organizer/skeleton/qorganizerskeleton.cpp4
-rw-r--r--src/plugins/organizer/skeleton/qorganizerskeleton_p.h2
-rw-r--r--tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp4
-rw-r--r--tests/auto/organizer/qmlorganizer/testcases/QOrganizerTestUtility.qml2
-rw-r--r--tests/auto/organizer/qmlorganizer/testcases/tst_collection.qml14
-rw-r--r--tests/auto/organizer/qmlorganizer/testcases/tst_organizercollectionfilter.qml10
-rw-r--r--tests/auto/organizer/qmlorganizer/testcases/tst_organizerintersectionfilter.qml4
-rw-r--r--tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml4
-rw-r--r--tests/auto/organizer/qmlorganizer/testcases/tst_organizerunionfilter.qml4
-rw-r--r--tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h4
-rw-r--r--tests/auto/organizer/qorganizeritemasync/unittest/tst_qorganizeritemasync.cpp2
-rw-r--r--tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp16
-rw-r--r--tests/system/qmlorganizer/contents/CollectionRoller.qml2
30 files changed, 74 insertions, 93 deletions
diff --git a/examples/organizer/calendardemo/src/calendardemo.cpp b/examples/organizer/calendardemo/src/calendardemo.cpp
index ca0f4b086..c32317a40 100644
--- a/examples/organizer/calendardemo/src/calendardemo.cpp
+++ b/examples/organizer/calendardemo/src/calendardemo.cpp
@@ -312,7 +312,7 @@ void CalendarDemo::addEvents()
QList<QOrganizerItem> items;
// Create a large number of events asynchronously
- QOrganizerCollectionId defaultCollectionId = m_manager->defaultCollection().id();
+ QOrganizerCollectionId defaultCollectionId = m_manager->defaultCollectionId();
for(int index=0 ; index < 100 ; index++) {
QOrganizerItem item;
item.setType(QOrganizerItemType::TypeEvent);
@@ -494,7 +494,7 @@ void CalendarDemo::deleteAllEntries()
void CalendarDemo::addCalendar()
{
// Get default collection
- QOrganizerCollection defaultCollection = m_manager->defaultCollection();
+ QOrganizerCollection defaultCollection = m_manager->collection(m_manager->defaultCollectionId());
QOrganizerCollection newCollection = defaultCollection;
newCollection.setId(QOrganizerCollectionId()); // reset collection id
diff --git a/src/contacts/qcontactmanager.cpp b/src/contacts/qcontactmanager.cpp
index 2730d29e3..5f314d764 100644
--- a/src/contacts/qcontactmanager.cpp
+++ b/src/contacts/qcontactmanager.cpp
@@ -812,13 +812,12 @@ QList<QContactDetail::DetailType> QContactManager::supportedContactDetailTypes()
}
/*!
- Returns the default collection managed by this manager. There is always only one default collection
- for each backend.
+ Returns the id of a default collection managed by this manager.
+ There is always only one default collection for each backend.
*/
-QContactCollection QContactManager::defaultCollection()
+QContactCollectionId QContactManager::defaultCollectionId() const
{
- QContactManagerSyncOpErrorHolder h(this);
- return d->m_engine->defaultCollection(&h.error);
+ return d->m_engine->defaultCollectionId();
}
/*!
diff --git a/src/contacts/qcontactmanager.h b/src/contacts/qcontactmanager.h
index c50288ed1..db6a84e1f 100644
--- a/src/contacts/qcontactmanager.h
+++ b/src/contacts/qcontactmanager.h
@@ -158,7 +158,7 @@ public:
QList<QContactDetail::DetailType> supportedContactDetailTypes() const;
// collections
- QContactCollection defaultCollection();
+ QContactCollectionId defaultCollectionId() const;
QContactCollection collection(const QContactCollectionId& collectionId);
QList<QContactCollection> collections();
bool saveCollection(QContactCollection* collection);
diff --git a/src/contacts/qcontactmanagerengine.cpp b/src/contacts/qcontactmanagerengine.cpp
index ba2919d5f..f6ba47dcf 100644
--- a/src/contacts/qcontactmanagerengine.cpp
+++ b/src/contacts/qcontactmanagerengine.cpp
@@ -452,13 +452,11 @@ bool QContactManagerEngine::removeRelationships(const QList<QContactRelationship
}
/*!
- This function should be reimplemented to support synchronous calls to fetch the default collection.
- Any errors encountered during this operation should be stored to \a error.
+ This function should be reimplemented to support synchronous calls to fetch the default collection id.
*/
-QContactCollection QContactManagerEngine::defaultCollection(QContactManager::Error* error)
+QContactCollectionId QContactManagerEngine::defaultCollectionId() const
{
- *error = QContactManager::NotSupportedError;
- return QContactCollection();
+ return QContactCollectionId();
}
/*!
diff --git a/src/contacts/qcontactmanagerengine.h b/src/contacts/qcontactmanagerengine.h
index 146b4a48d..db0e350b3 100644
--- a/src/contacts/qcontactmanagerengine.h
+++ b/src/contacts/qcontactmanagerengine.h
@@ -108,7 +108,7 @@ public:
virtual bool removeRelationships(const QList<QContactRelationship> &relationships, QMap<int, QContactManager::Error> *errorMap, QContactManager::Error *error);
// collections
- virtual QContactCollection defaultCollection(QContactManager::Error *error);
+ virtual QContactCollectionId defaultCollectionId() const;
virtual QContactCollection collection(const QContactCollectionId &collectionId, QContactManager::Error *error);
virtual QList<QContactCollection> collections(QContactManager::Error *error);
virtual bool saveCollection(QContactCollection *collection, QContactManager::Error *error);
diff --git a/src/imports/organizer/qdeclarativeorganizermodel.cpp b/src/imports/organizer/qdeclarativeorganizermodel.cpp
index fb0ef7081..8432ffa2a 100644
--- a/src/imports/organizer/qdeclarativeorganizermodel.cpp
+++ b/src/imports/organizer/qdeclarativeorganizermodel.cpp
@@ -1696,13 +1696,13 @@ void QDeclarativeOrganizerModel::removeCollection(const QString &collectionId)
}
/*!
- \qmlmethod Collection OrganizerModel::defaultCollection()
- Returns the default Collection object.
+ \qmlmethod string OrganizerModel::defaultCollectionId()
+ Returns the id of a default Collection object.
*/
-QDeclarativeOrganizerCollection* QDeclarativeOrganizerModel::defaultCollection()
+QString QDeclarativeOrganizerModel::defaultCollectionId() const
{
- Q_D(QDeclarativeOrganizerModel);
- return collection(d->m_manager->defaultCollection().id().toString());
+ Q_D(const QDeclarativeOrganizerModel);
+ return d->m_manager->defaultCollectionId().toString();
}
/*!
diff --git a/src/imports/organizer/qdeclarativeorganizermodel_p.h b/src/imports/organizer/qdeclarativeorganizermodel_p.h
index e240dd480..30b0ed626 100644
--- a/src/imports/organizer/qdeclarativeorganizermodel_p.h
+++ b/src/imports/organizer/qdeclarativeorganizermodel_p.h
@@ -160,7 +160,7 @@ public:
Q_INVOKABLE QVariantList itemsByTimePeriod(const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime());
Q_INVOKABLE QDeclarativeOrganizerItem* item(const QString& id);
Q_INVOKABLE QStringList itemIds(const QDateTime &start = QDateTime(), const QDateTime &end = QDateTime());
- Q_INVOKABLE QDeclarativeOrganizerCollection* defaultCollection();
+ Q_INVOKABLE QString defaultCollectionId() const;
Q_INVOKABLE QDeclarativeOrganizerCollection* collection(const QString& collectionId);
Q_INVOKABLE void importItems(const QUrl& url, const QStringList& profiles = QStringList());
diff --git a/src/organizer/doc/src/organizerengines.qdoc b/src/organizer/doc/src/organizerengines.qdoc
index bf95ca09e..ce322f7b9 100644
--- a/src/organizer/doc/src/organizerengines.qdoc
+++ b/src/organizer/doc/src/organizerengines.qdoc
@@ -90,7 +90,8 @@ All engines must implement the following functions:
\li QOrganizerManagerEngine::itemIds()
\li QOrganizerManagerEngine::items()
\li QOrganizerManagerEngine::itemsForExport()
- \li QOrganizerManagerEngine::defaultCollection()
+ \li QOrganizerManagerEngine::defaultCollectionId()
+ \li QOrganizerManagerEngine::collection()
\li QOrganizerManagerEngine::collections()
\endlist
diff --git a/src/organizer/doc/src/organizersync.qdoc b/src/organizer/doc/src/organizersync.qdoc
index 7ab30a07d..368348fc8 100644
--- a/src/organizer/doc/src/organizersync.qdoc
+++ b/src/organizer/doc/src/organizersync.qdoc
@@ -93,7 +93,8 @@ by clients. For in-depth information about collections, see
The synchronous API offers the following functions to manipulate collections:
\list
- \li QOrganizerManager::defaultCollection() returns the default collection of the manager
+ \li QOrganizerManager::defaultCollectionId() returns the id of a default collection of the manager
+ \li QOrganizerManager::collection() returns an existing collection by its id
\li QOrganizerManager::collections() returns all collections in the manager
\li QOrganizerManager::saveCollection() updates an existing collection or adds a new collection
\li QOrganizerManager::removeCollection() removes an existing collection (and deletes any items it contains)
diff --git a/src/organizer/qorganizermanager.cpp b/src/organizer/qorganizermanager.cpp
index 79752ed70..661575997 100644
--- a/src/organizer/qorganizermanager.cpp
+++ b/src/organizer/qorganizermanager.cpp
@@ -646,13 +646,12 @@ bool QOrganizerManager::removeItems(const QList<QOrganizerItem> *items)
}
/*!
- Returns the default collection managed by this manager. There is always only one default collection
- for each backend.
+ Returns the id of a default collection managed by this manager.
+ There is always only one default collection for each backend.
*/
-QOrganizerCollection QOrganizerManager::defaultCollection()
+QOrganizerCollectionId QOrganizerManager::defaultCollectionId() const
{
- QOrganizerManagerSyncOpErrorHolder h(this);
- return d->m_engine->defaultCollection(&h.error);
+ return d->m_engine->defaultCollectionId();
}
/*!
diff --git a/src/organizer/qorganizermanager.h b/src/organizer/qorganizermanager.h
index d82fbf8fe..409843020 100644
--- a/src/organizer/qorganizermanager.h
+++ b/src/organizer/qorganizermanager.h
@@ -150,7 +150,7 @@ public:
bool removeItems(const QList<QOrganizerItem> *items);
// collections
- QOrganizerCollection defaultCollection();
+ QOrganizerCollectionId defaultCollectionId() const;
QOrganizerCollection collection(const QOrganizerCollectionId& collectionId);
QList<QOrganizerCollection> collections();
bool saveCollection(QOrganizerCollection* collection);
diff --git a/src/organizer/qorganizermanagerengine.cpp b/src/organizer/qorganizermanagerengine.cpp
index 704835412..aebb5bf22 100644
--- a/src/organizer/qorganizermanagerengine.cpp
+++ b/src/organizer/qorganizermanagerengine.cpp
@@ -528,13 +528,11 @@ bool QOrganizerManagerEngine::removeItems(const QList<QOrganizerItem> *items, QM
/*!
- This function should be reimplemented to support synchronous calls to fetch the default collection.
- Any errors encountered during this operation should be stored to \a error.
+ This function should be reimplemented to support synchronous calls to fetch the default collection id.
*/
-QOrganizerCollection QOrganizerManagerEngine::defaultCollection(QOrganizerManager::Error* error)
+QOrganizerCollectionId QOrganizerManagerEngine::defaultCollectionId() const
{
- *error = QOrganizerManager::NotSupportedError;
- return QOrganizerCollection();
+ return QOrganizerCollectionId();
}
/*!
diff --git a/src/organizer/qorganizermanagerengine.h b/src/organizer/qorganizermanagerengine.h
index acffaa65b..b0edb3274 100644
--- a/src/organizer/qorganizermanagerengine.h
+++ b/src/organizer/qorganizermanagerengine.h
@@ -110,7 +110,7 @@ public:
virtual bool removeItems(const QList<QOrganizerItem> *items, QMap<int, QOrganizerManager::Error> *errorMap, QOrganizerManager::Error *error);
// collections
- virtual QOrganizerCollection defaultCollection(QOrganizerManager::Error *error);
+ virtual QOrganizerCollectionId defaultCollectionId() const;
virtual QOrganizerCollection collection(const QOrganizerCollectionId &collectionId, QOrganizerManager::Error *error);
virtual QList<QOrganizerCollection> collections(QOrganizerManager::Error *error);
virtual bool saveCollection(QOrganizerCollection *collection, QOrganizerManager::Error *error);
diff --git a/src/plugins/contacts/memory/qcontactmemorybackend.cpp b/src/plugins/contacts/memory/qcontactmemorybackend.cpp
index 6476ae485..0007096f8 100644
--- a/src/plugins/contacts/memory/qcontactmemorybackend.cpp
+++ b/src/plugins/contacts/memory/qcontactmemorybackend.cpp
@@ -521,12 +521,10 @@ bool QContactMemoryEngine::removeRelationships(const QList<QContactRelationship>
return (*error == QContactManager::NoError);
}
-QContactCollection QContactMemoryEngine::defaultCollection(QContactManager::Error *error)
+QContactCollectionId QContactMemoryEngine::defaultCollectionId() const
{
- const QContactCollectionId defaultCollectionId = this->defaultCollectionId();
- Q_ASSERT(d->m_idToCollectionHash.contains(defaultCollectionId));
- *error = QContactManager::NoError;
- return d->m_idToCollectionHash.value(defaultCollectionId);
+ static const QByteArray id("Personal");
+ return collectionId(id);
}
QContactCollection QContactMemoryEngine::collection(const QContactCollectionId &collectionId, QContactManager::Error *error)
@@ -901,12 +899,6 @@ void QContactMemoryEngine::performAsynchronousOperation(QContactAbstractRequest
d->emitSharedSignals(&changeSet);
}
-QContactCollectionId QContactMemoryEngine::defaultCollectionId() const
-{
- static const QByteArray id("Personal");
- return collectionId(id);
-}
-
void QContactMemoryEngine::partiallySyncDetails(QContact *to, const QContact &from, const QList<QContactDetail::DetailType> &mask)
{
// these details in old contact
diff --git a/src/plugins/contacts/memory/qcontactmemorybackend_p.h b/src/plugins/contacts/memory/qcontactmemorybackend_p.h
index adeff03a7..cf0c570ff 100644
--- a/src/plugins/contacts/memory/qcontactmemorybackend_p.h
+++ b/src/plugins/contacts/memory/qcontactmemorybackend_p.h
@@ -166,7 +166,7 @@ public:
virtual bool removeRelationships(const QList<QContactRelationship> &relationships, QMap<int, QContactManager::Error> *errorMap, QContactManager::Error *error);
// collections
- QContactCollection defaultCollection(QContactManager::Error* error);
+ QContactCollectionId defaultCollectionId() const;
QContactCollection collection(const QContactCollectionId &collectionId, QContactManager::Error *error);
QList<QContactCollection> collections(QContactManager::Error* error);
bool saveCollection(QContactCollection* collection, QContactManager::Error* error);
@@ -217,8 +217,6 @@ private:
void performAsynchronousOperation(QContactAbstractRequest *request);
- QContactCollectionId defaultCollectionId() const;
-
QContactMemoryEngineData *d;
static QMap<QString, QContactMemoryEngineData*> engineDatas;
diff --git a/src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp b/src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp
index 15f2c84a2..22652ee8c 100644
--- a/src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp
+++ b/src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp
@@ -1047,12 +1047,10 @@ bool QOrganizerItemMemoryEngine::removeItems(const QList<QOrganizerItem> *items,
return (*error == QOrganizerManager::NoError);
}
-QOrganizerCollection QOrganizerItemMemoryEngine::defaultCollection(QOrganizerManager::Error* error)
+QOrganizerCollectionId QOrganizerItemMemoryEngine::defaultCollectionId() const
{
- const QOrganizerCollectionId defaultCollectionId = this->defaultCollectionId();
- Q_ASSERT(d->m_idToCollectionHash.contains(defaultCollectionId));
- *error = QOrganizerManager::NoError;
- return d->m_idToCollectionHash.value(defaultCollectionId);
+ const uint id(QOrganizerItemMemoryEngineData::DefaultCollectionLocalId);
+ return collectionId(QByteArray(reinterpret_cast<const char *>(&id), sizeof(uint)));
}
QOrganizerCollection QOrganizerItemMemoryEngine::collection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error)
diff --git a/src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h b/src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h
index ad1c8ac42..db969655c 100644
--- a/src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h
+++ b/src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h
@@ -122,9 +122,6 @@ public:
QMap<QString, QString> managerParameters() const;
QMap<QString, QString> idInterpretationParameters() const;
- inline QOrganizerCollectionId defaultCollectionId() const
- { const uint id(QOrganizerItemMemoryEngineData::DefaultCollectionLocalId); return collectionId(QByteArray(reinterpret_cast<const char *>(&id), sizeof(uint))); }
-
// items
QList<QOrganizerItem> items(const QList<QOrganizerItemId> &itemIds, const QOrganizerItemFetchHint &fetchHint,
QMap<int, QOrganizerManager::Error> *errorMap, QOrganizerManager::Error *error);
@@ -157,7 +154,7 @@ public:
QOrganizerManager::Error* error);
// collections
- QOrganizerCollection defaultCollection(QOrganizerManager::Error* error);
+ QOrganizerCollectionId defaultCollectionId() const;
QOrganizerCollection collection(const QOrganizerCollectionId &collectionId, QOrganizerManager::Error *error);
QList<QOrganizerCollection> collections(QOrganizerManager::Error* error);
bool saveCollection(QOrganizerCollection* collection, QOrganizerManager::Error* error);
diff --git a/src/plugins/organizer/skeleton/qorganizerskeleton.cpp b/src/plugins/organizer/skeleton/qorganizerskeleton.cpp
index c194e7ab7..9ddcdb527 100644
--- a/src/plugins/organizer/skeleton/qorganizerskeleton.cpp
+++ b/src/plugins/organizer/skeleton/qorganizerskeleton.cpp
@@ -251,7 +251,7 @@ bool QOrganizerItemSkeletonEngine::removeItems(const QList<QOrganizerItemId> &it
return QOrganizerManagerEngine::removeItems(itemIds, errorMap, error);
}
-QOrganizerCollection QOrganizerItemSkeletonEngine::defaultCollection(QOrganizerManager::Error* error)
+QOrganizerCollectionId QOrganizerItemSkeletonEngine::defaultCollectionId() const
{
/*
TODO
@@ -263,7 +263,7 @@ QOrganizerCollection QOrganizerItemSkeletonEngine::defaultCollection(QOrganizerM
There is always at least one collection in a manager, and all items are
saved in exactly one collection.
*/
- return QOrganizerManagerEngine::defaultCollection(error);
+ return QOrganizerManagerEngine::defaultCollectionId();
}
QOrganizerCollection QOrganizerItemSkeletonEngine::collection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error)
diff --git a/src/plugins/organizer/skeleton/qorganizerskeleton_p.h b/src/plugins/organizer/skeleton/qorganizerskeleton_p.h
index 96eb6336e..bd12fd44f 100644
--- a/src/plugins/organizer/skeleton/qorganizerskeleton_p.h
+++ b/src/plugins/organizer/skeleton/qorganizerskeleton_p.h
@@ -142,7 +142,7 @@ public:
QOrganizerManager::Error *error);
// collections
- QOrganizerCollection defaultCollection(QOrganizerManager::Error* error);
+ QOrganizerCollectionId defaultCollectionId() const;
QOrganizerCollection collection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error);
QList<QOrganizerCollection> collections(QOrganizerManager::Error* error);
bool saveCollection(QOrganizerCollection* collection, QOrganizerManager::Error* error);
diff --git a/tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp b/tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp
index 885606b27..dde8c2067 100644
--- a/tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp
+++ b/tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp
@@ -1345,7 +1345,7 @@ void tst_QContactAsync::contactSave()
QVERIFY(result.first().detail<QContactName>() == nameDetail);
// check if the contact was saved on default collection
- QCOMPARE(result.first().collectionId().toString(), cm->defaultCollection().id().toString());
+ QCOMPARE(result.first().collectionId().toString(), cm->defaultCollectionId().toString());
QCOMPARE(cm->contactIds().size(), originalCount + 1);
// update a previously saved contact
@@ -2558,7 +2558,7 @@ void tst_QContactAsync::collectionRemove()
// specific collection set
QContactCollectionId removeId = cm->collections().last().id();
- if (cm->defaultCollection().id() == removeId)
+ if (cm->defaultCollectionId() == removeId)
removeId = cm->collections().first().id();
crr.setCollectionId(removeId);
QVERIFY(crr.collectionIds() == QList<QContactCollectionId>() << removeId);
diff --git a/tests/auto/organizer/qmlorganizer/testcases/QOrganizerTestUtility.qml b/tests/auto/organizer/qmlorganizer/testcases/QOrganizerTestUtility.qml
index 56e4f683d..ce87a6ef9 100644
--- a/tests/auto/organizer/qmlorganizer/testcases/QOrganizerTestUtility.qml
+++ b/tests/auto/organizer/qmlorganizer/testcases/QOrganizerTestUtility.qml
@@ -238,7 +238,7 @@ TestCase {
__model.autoUpdate = false;
for (var i = 0; i < __model.collections.length; ++i) {
var collId = __model.collections[i].collectionId;
- if (collId != __model.defaultCollection().collectionId) {
+ if (collId != __model.defaultCollectionId()) {
__model.removeCollection(collId);
}
}
diff --git a/tests/auto/organizer/qmlorganizer/testcases/tst_collection.qml b/tests/auto/organizer/qmlorganizer/testcases/tst_collection.qml
index a5f6da428..f9f7be53e 100644
--- a/tests/auto/organizer/qmlorganizer/testcases/tst_collection.qml
+++ b/tests/auto/organizer/qmlorganizer/testcases/tst_collection.qml
@@ -65,7 +65,7 @@ TestCase {
}
for (var i = 0; i < organizerModel.collections.length; ++i) {
var collId = organizerModel.collections[i].collectionId;
- if (collId != organizerModel.defaultCollection().collectionId) {
+ if (collId != organizerModel.defaultCollectionId()) {
organizerModel.removeCollection(collId);
}
}
@@ -303,11 +303,11 @@ TestCase {
organizerModel.saveItem(event);
modelChangedSpy.wait(spyWaitDelay);
var savedEvent = organizerModel.items[organizerModel.items.length - 1];
- compare(savedEvent.collectionId, organizerModel.defaultCollection().collectionId);//savedEvent sometimes undefined!?!?!?
+ compare(savedEvent.collectionId, organizerModel.defaultCollectionId());//savedEvent sometimes undefined!?!?!?
spySettingCollectionId.target = savedEvent;
// set different collection
- verify(savedCollection.collectionId != organizerModel.defaultCollection().collectionId)
+ verify(savedCollection.collectionId != organizerModel.defaultCollectionId())
savedEvent.collectionId = savedCollection.collectionId;
spySettingCollectionId.wait(spyWaitDelay);
compare(spySettingCollectionId.count, 1);
@@ -327,7 +327,7 @@ TestCase {
savedEvent = organizerModel.items[organizerModel.items.length - 1];
compare(organizerModel.error, "InvalidCollection");
expectFailContinue("memory backend", "Model is updated even in error case.")
- compare(savedEvent.collectionId, organizerModel.defaultCollection().collectionId);
+ compare(savedEvent.collectionId, organizerModel.defaultCollectionId());
}
// cleanup
@@ -368,7 +368,7 @@ TestCase {
var originalAmountOfCollections = organizerModel.collections.length;
// default collection exists always
- var defCollection = organizerModel.defaultCollection();
+ var defCollection = organizerModel.collection(organizerModel.defaultCollectionId());
verify(defCollection);
// add/save collection
@@ -479,13 +479,13 @@ TestCase {
compare(organizerModel.collections.length, amountBeforeDeletions - 2);
compare(collectionsChangedSpy.count, 7);
// - remove default collection
- organizerModel.removeCollection(organizerModel.defaultCollection.collectionId);
+ organizerModel.removeCollection(organizerModel.defaultCollectionId());
wait(noSpyWaitDelay);// how to utilise SignalSpy to check signal is _not_ emitted?
compare(organizerModel.collections.length, amountBeforeDeletions - 2);
compare(collectionsChangedSpy.count, 7);
// after all the modifications to collections, default should still be the same
- compare(defCollection.collectionId, organizerModel.defaultCollection().collectionId);
+ compare(defCollection.collectionId, organizerModel.defaultCollectionId());
empty_calendar(organizerModel);
}
diff --git a/tests/auto/organizer/qmlorganizer/testcases/tst_organizercollectionfilter.qml b/tests/auto/organizer/qmlorganizer/testcases/tst_organizercollectionfilter.qml
index 49945c90c..7ddb1da06 100644
--- a/tests/auto/organizer/qmlorganizer/testcases/tst_organizercollectionfilter.qml
+++ b/tests/auto/organizer/qmlorganizer/testcases/tst_organizercollectionfilter.qml
@@ -130,14 +130,14 @@ Rectangle {
compare(model.itemCount, 1)
//default collection
- utility.debug("default collection id :" + model.defaultCollection().collectionId, debugFlag);
+ utility.debug("default collection id :" + model.defaultCollectionId(), debugFlag);
var modelCollectionFilter = model.filter;
- modelCollectionFilter.ids = [model.defaultCollection().collectionId];
+ modelCollectionFilter.ids = [model.defaultCollectionId()];
utility.waitModelChange(0);
compare(model.itemCount, 0)
//save event to default collection
- event.collectionId = model.defaultCollection().collectionId;
+ event.collectionId = model.defaultCollectionId();
model.saveItem(event);
utility.waitModelChange(1);
@@ -160,12 +160,12 @@ Rectangle {
//set more collection ids
modelCollectionFilter = model.filter
- modelCollectionFilter.ids = [model.defaultCollection().collectionId, savedCollection.collectionId];
+ modelCollectionFilter.ids = [model.defaultCollectionId(), savedCollection.collectionId];
utility.waitModelChange(2);
compare(model.itemCount, 2);
//One invalid collection id
- modelCollectionFilter.ids = [model.defaultCollection().collectionId, "12345666666",savedCollection.collectionId];
+ modelCollectionFilter.ids = [model.defaultCollectionId(), "12345666666",savedCollection.collectionId];
utility.waitModelChange(2);
compare(model.itemCount, 2);
diff --git a/tests/auto/organizer/qmlorganizer/testcases/tst_organizerintersectionfilter.qml b/tests/auto/organizer/qmlorganizer/testcases/tst_organizerintersectionfilter.qml
index 441a723f3..246c6ed40 100644
--- a/tests/auto/organizer/qmlorganizer/testcases/tst_organizerintersectionfilter.qml
+++ b/tests/auto/organizer/qmlorganizer/testcases/tst_organizerintersectionfilter.qml
@@ -159,7 +159,7 @@ Rectangle {
//Double filter 2
//Change collection filter id
- collectionFilter.ids = [savedCollection.collectionId, model.defaultCollection().collectionId];
+ collectionFilter.ids = [savedCollection.collectionId, model.defaultCollectionId()];
model.filter.filters = [idFilter, collectionFilter]
utility.debug("Duoble filter 2", debugFlag);
utility.waitModelChange(1);
@@ -167,7 +167,7 @@ Rectangle {
//Double filter 3
//Change collection filter id
- collectionFilter.ids = [savedCollection.collectionId, model.defaultCollection().collectionId];
+ collectionFilter.ids = [savedCollection.collectionId, model.defaultCollectionId()];
idFilter.ids = [idEventId, collectionEventId];
utility.debug("Duoble filter ~3", debugFlag);
model.filter.filters = [idFilter, collectionFilter]
diff --git a/tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml b/tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml
index 009c04c98..7b4cabba2 100644
--- a/tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml
+++ b/tests/auto/organizer/qmlorganizer/testcases/tst_organizermodel.qml
@@ -380,7 +380,7 @@ TestCase {
organizerChangedSpy.target = organizerModel;
organizerChangedSpy.signalName = "modelChanged";
organizerChangedSpy.wait();
- organizerModel.removeCollection(organizerModel.defaultCollection().collectionId);
+ organizerModel.removeCollection(organizerModel.defaultCollectionId());
wait(signalWaitTime);// how to utilise SignalSpy to check signal is _not_ emitted?
compare(organizerModel.error, "PermissionsError");
}
@@ -1087,7 +1087,7 @@ TestCase {
+ "}\n", modelTests);
for (var i = 0; i < organizerModel.collections.length; ++i) {
var collId = organizerModel.collections[i].collectionId;
- if (collId != organizerModel.defaultCollection().collectionId) {
+ if (collId != organizerModel.defaultCollectionId()) {
event.collectionId = collId;
}
}
diff --git a/tests/auto/organizer/qmlorganizer/testcases/tst_organizerunionfilter.qml b/tests/auto/organizer/qmlorganizer/testcases/tst_organizerunionfilter.qml
index 10e4da44e..c3fe51d29 100644
--- a/tests/auto/organizer/qmlorganizer/testcases/tst_organizerunionfilter.qml
+++ b/tests/auto/organizer/qmlorganizer/testcases/tst_organizerunionfilter.qml
@@ -160,7 +160,7 @@ Rectangle {
//Double filter 2
//Change collection filter id
- collectionFilter.ids = [savedCollection.collectionId, model.defaultCollection().collectionId];
+ collectionFilter.ids = [savedCollection.collectionId, model.defaultCollectionId()];
model.filter.filters = [idFilter, collectionFilter]
utility.debug("Duoble filter 2", debugFlag);
utility.waitModelChange(2);
@@ -168,7 +168,7 @@ Rectangle {
//Double filter 3
//Change collection filter id
- collectionFilter.ids = [savedCollection.collectionId, model.defaultCollection().collectionId];
+ collectionFilter.ids = [savedCollection.collectionId, model.defaultCollectionId()];
idFilter.ids = [idEventId, collectionEventId];
utility.debug("Duoble filter ~3", debugFlag);
model.filter.filters = [idFilter, collectionFilter]
diff --git a/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h b/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h
index b547104db..ef4710a00 100644
--- a/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h
+++ b/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h
@@ -133,9 +133,9 @@ public:
}
// collections
- QOrganizerCollection defaultCollection(QOrganizerManager::Error *error)
+ QOrganizerCollectionId defaultCollectionId() const
{
- return QOrganizerManagerEngine::defaultCollection(error);
+ return QOrganizerManagerEngine::defaultCollectionId();
}
QOrganizerCollection collection(const QOrganizerCollectionId &collectionId, QOrganizerManager::Error *error)
diff --git a/tests/auto/organizer/qorganizeritemasync/unittest/tst_qorganizeritemasync.cpp b/tests/auto/organizer/qorganizeritemasync/unittest/tst_qorganizeritemasync.cpp
index c83387a52..98d065b59 100644
--- a/tests/auto/organizer/qorganizeritemasync/unittest/tst_qorganizeritemasync.cpp
+++ b/tests/auto/organizer/qorganizeritemasync/unittest/tst_qorganizeritemasync.cpp
@@ -2270,7 +2270,7 @@ void tst_QOrganizerItemAsync::collectionRemove()
// specific collection set
QOrganizerCollectionId removeId = oim->collections().last().id();
- if (oim->defaultCollection().id() == removeId)
+ if (oim->defaultCollectionId() == removeId)
removeId = oim->collections().first().id();
crr.setCollectionId(removeId);
QVERIFY(crr.collectionIds() == QList<QOrganizerCollectionId>() << removeId);
diff --git a/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp b/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
index e9a0c0635..a26aad15a 100644
--- a/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
+++ b/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
@@ -886,7 +886,7 @@ void tst_QOrganizerManager::persistence()
// Remove all non-default collections
QList<QOrganizerCollection> collections(cm->collections());
- QOrganizerCollectionId defaultCollectionId(cm->defaultCollection().id());
+ QOrganizerCollectionId defaultCollectionId(cm->defaultCollectionId());
foreach (const QOrganizerCollection &col, collections) {
QOrganizerCollectionId id(col.id());
if (id != defaultCollectionId)
@@ -1821,7 +1821,7 @@ void tst_QOrganizerManager::invalidManager()
QVERIFY(manager.error() == QOrganizerManager::NotSupportedError || manager.error() == QOrganizerManager::InvalidCollectionError);
QVERIFY(!manager.removeCollection(testCollection.id()));
QVERIFY(manager.error() == QOrganizerManager::NotSupportedError || manager.error() == QOrganizerManager::DoesNotExistError);
- QVERIFY(manager.defaultCollection() == QOrganizerCollection());
+ QVERIFY(manager.collection(manager.defaultCollectionId()) == QOrganizerCollection());
QVERIFY(manager.error() == QOrganizerManager::NotSupportedError);
QVERIFY(manager.collections().isEmpty());
QVERIFY(manager.error() == QOrganizerManager::NotSupportedError);
@@ -3816,7 +3816,7 @@ void tst_QOrganizerManager::idComparison()
QList<QOrganizerCollection> allCollections = cm->collections();
for (int i = 0; i < allCollections.size(); ++i) {
QOrganizerCollectionId currentId = allCollections.at(i).id();
- if (currentId != cm->defaultCollection().id()) {
+ if (currentId != cm->defaultCollectionId()) {
cm->removeCollection(currentId);
}
}
@@ -4247,7 +4247,7 @@ void tst_QOrganizerManager::collections()
QList<QOrganizerCollection> allCollections = oim->collections();
for (int i = 0; i < allCollections.size(); ++i) {
QOrganizerCollectionId currentId = allCollections.at(i).id();
- if (currentId != oim->defaultCollection().id()) {
+ if (currentId != oim->defaultCollectionId()) {
oim->removeCollection(currentId);
}
}
@@ -4274,14 +4274,14 @@ void tst_QOrganizerManager::collections()
if (oim->managerName() != "memory") // modifying default collection is not allowed in memory engine
{
int initialCollectionCount = oim->collections().size();
- QOrganizerCollection defaultCollection = oim->defaultCollection();
- QOrganizerCollectionId defaultCollectionId = oim->defaultCollection().id();
+ QOrganizerCollectionId defaultCollectionId = oim->defaultCollectionId();
+ QOrganizerCollection defaultCollection = oim->collection(defaultCollectionId);
defaultCollection.setMetaData(QOrganizerCollection::KeyName, "NewName");
QCOMPARE(defaultCollection.id(), defaultCollectionId);
QVERIFY(oim->saveCollection(&defaultCollection));
int finalCollectionCount = oim->collections().size();
QCOMPARE(finalCollectionCount, initialCollectionCount);
- QCOMPARE(oim->defaultCollection().metaData(QOrganizerCollection::KeyName).toString(), QString("NewName"));
+ QCOMPARE(oim->collection(defaultCollectionId).metaData(QOrganizerCollection::KeyName).toString(), QString("NewName"));
QCOMPARE(defaultCollection.id(), defaultCollectionId);
}
@@ -4315,7 +4315,7 @@ void tst_QOrganizerManager::collections()
QVERIFY(itemIndex >= 0);
QVERIFY(oim->items(QDateTime(), QDateTime(), fil).contains(i1) || isSuperset(c1Items.at(itemIndex), i1));
- fil.setCollectionId(oim->defaultCollection().id());
+ fil.setCollectionId(oim->defaultCollectionId());
QVERIFY(!oim->items(QDateTime(), QDateTime(), fil).contains(i1)); // it should not be in the default collection.
}
diff --git a/tests/system/qmlorganizer/contents/CollectionRoller.qml b/tests/system/qmlorganizer/contents/CollectionRoller.qml
index 3fd765266..44f235478 100644
--- a/tests/system/qmlorganizer/contents/CollectionRoller.qml
+++ b/tests/system/qmlorganizer/contents/CollectionRoller.qml
@@ -62,7 +62,7 @@ RollerRow {
}
// item's collection id not found, use default one
for (var i=0;i<organizer.collections.length;i++) {
- if (organizer.collections[i].collectionId == organizer.defaultCollection().collectionId) {
+ if (organizer.collections[i].collectionId == organizer.defaultCollectionId()) {
return i;
}
}