summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2014-05-13 21:47:16 +0300
committerMatthew Vogt <matthew.vogt@qinetic.com.au>2014-08-01 02:59:05 +0200
commit39f686ed2492dd168eb551f96a22b08b2eedeb45 (patch)
treec8e97260485272a927348de2a20b39882a4a348f
parent3b77fe17a82590627d306d5e58ecd5d83fee7893 (diff)
Simplify contact and organizer ID representations
Simplify contact and organizer IDs to simply contain a manager URI that identifies the owner of the identified object, and an engine- specific string that identifies the object to that manager. Change-Id: Ic14c419df264e91c61e0f3d474d846289e1aaa82 Reviewed-by: Christopher Adams <chris.adams@jollamobile.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
-rw-r--r--src/contacts/contacts.pro6
-rw-r--r--src/contacts/qcontactengineid.cpp115
-rw-r--r--src/contacts/qcontactengineid.h75
-rw-r--r--src/contacts/qcontactid.cpp262
-rw-r--r--src/contacts/qcontactid.h42
-rw-r--r--src/contacts/qcontactmanager_p.cpp43
-rw-r--r--src/contacts/qcontactmanager_p.h7
-rw-r--r--src/contacts/qcontactmanagerengine.cpp46
-rw-r--r--src/contacts/qcontactmanagerengine.h14
-rw-r--r--src/contacts/qcontactmanagerenginefactory.cpp7
-rw-r--r--src/contacts/qcontactmanagerenginefactory.h5
-rw-r--r--src/organizer/doc/src/organizerengines.qdoc5
-rw-r--r--src/organizer/organizer.pro4
-rw-r--r--src/organizer/qorganizer.h2
-rw-r--r--src/organizer/qorganizercollectionengineid.cpp121
-rw-r--r--src/organizer/qorganizercollectionengineid.h80
-rw-r--r--src/organizer/qorganizercollectionid.cpp255
-rw-r--r--src/organizer/qorganizercollectionid.h50
-rw-r--r--src/organizer/qorganizeritemengineid.cpp115
-rw-r--r--src/organizer/qorganizeritemengineid.h75
-rw-r--r--src/organizer/qorganizeritemid.cpp254
-rw-r--r--src/organizer/qorganizeritemid.h49
-rw-r--r--src/organizer/qorganizermanager_p.cpp47
-rw-r--r--src/organizer/qorganizermanager_p.h10
-rw-r--r--src/organizer/qorganizermanagerengine.cpp73
-rw-r--r--src/organizer/qorganizermanagerengine.h13
-rw-r--r--src/organizer/qorganizermanagerenginefactory.cpp15
-rw-r--r--src/organizer/qorganizermanagerenginefactory.h4
-rw-r--r--src/plugins/contacts/memory/qcontactmemorybackend.cpp108
-rw-r--r--src/plugins/contacts/memory/qcontactmemorybackend_p.h33
-rw-r--r--src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp222
-rw-r--r--src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h76
-rw-r--r--src/plugins/organizer/skeleton/qorganizerskeleton.cpp391
-rw-r--r--src/plugins/organizer/skeleton/qorganizerskeleton_p.h60
-rw-r--r--tests/auto/contacts/qcontact/qcontact.pro1
-rw-r--r--tests/auto/contacts/qcontact/tst_qcontact.cpp47
-rw-r--r--tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin.cpp7
-rw-r--r--tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin_p.h1
-rw-r--r--tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp37
-rw-r--r--tests/auto/contacts/qcontactfilter/tst_qcontactfilter.cpp8
-rw-r--r--tests/auto/contacts/qcontactidmock.h110
-rw-r--r--tests/auto/contacts/qcontactmanager/qcontactmanager.pro1
-rw-r--r--tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp12
-rw-r--r--tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.cpp5
-rw-r--r--tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.h1
-rw-r--r--tests/auto/contacts/qcontactmanagerplugins/unittest/tst_qcontactmanagerplugins.cpp8
-rw-r--r--tests/auto/contacts/qcontactrelationship/qcontactrelationship.pro1
-rw-r--r--tests/auto/contacts/qcontactrelationship/tst_qcontactrelationship.cpp29
-rw-r--r--tests/auto/organizer/qorganizercollection/tst_qorganizercollection.cpp64
-rw-r--r--tests/auto/organizer/qorganizeritem/tst_qorganizeritem.cpp63
-rw-r--r--tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin.cpp14
-rw-r--r--tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h2
-rw-r--r--tests/auto/organizer/qorganizeritemfilter/tst_qorganizeritemfilter.cpp142
-rw-r--r--tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp87
54 files changed, 692 insertions, 2632 deletions
diff --git a/src/contacts/contacts.pro b/src/contacts/contacts.pro
index 008b04a74..d4100f8a4 100644
--- a/src/contacts/contacts.pro
+++ b/src/contacts/contacts.pro
@@ -30,8 +30,7 @@ PUBLIC_HEADERS += \
qcontactrelationship.h \
qcontactsortorder.h \
qcontactsglobal.h \
- qcontacts.h \
- qcontactengineid.h \
+ qcontacts.h
PRIVATE_HEADERS += \
qcontact_p.h \
@@ -67,8 +66,7 @@ SOURCES += \
qcontactmanagerenginefactory.cpp \
qcontactobserver.cpp \
qcontactrelationship.cpp \
- qcontactsortorder.cpp \
- qcontactengineid.cpp \
+ qcontactsortorder.cpp
!isEmpty(CONTACTS_DEFAULT_ENGINE): DEFINES += Q_CONTACTS_DEFAULT_ENGINE=$$CONTACTS_DEFAULT_ENGINE
diff --git a/src/contacts/qcontactengineid.cpp b/src/contacts/qcontactengineid.cpp
deleted file mode 100644
index f15976f32..000000000
--- a/src/contacts/qcontactengineid.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Pim module.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcontactengineid.h"
-
-QT_BEGIN_NAMESPACE_CONTACTS
-
-/*!
- \class QContactEngineId
- \relates QContactId
- \brief The QContactEngineId class uniquely identifies a contact within a
- particular engine plugin.
-
- \inmodule QtContacts
- \ingroup contacts-backends
-
- Clients of the Contacts API should never use this class.
- Every engine implementor must implement a class derived from
- QContactEngineId.
-
- This class is provided so that engine implementors can implement their own
- id class (which may contain arbitrary data, and which may implement the
- required functions in an arbitrary manner).
- */
-
-/*!
- \fn QContactEngineId::~QContactEngineId()
- Cleans up any memory in use by this engine contact id.
- */
-
-/*!
- \fn QContactEngineId::isEqualTo(const QContactEngineId* other) const
- Returns true if this id is equal to the \a other id; false otherwise.
- Note that when implementing this function, you do not have to check that the type is the same,
- since the function which calls this function (in QContactId) does that check for you.
- */
-
-/*!
- \fn QContactEngineId::isLessThan(const QContactEngineId* other) const
- Returns true if this id is less than the \a other id; false otherwise.
- Note that when implementing this function, you do not have to check that the type is the same,
- since the function which calls this function (in QContactId) does that check for you.
- */
-
-/*!
- \fn QContactEngineId::managerUri() const
- Returns the manager URI of the constructed manager which created
- the id. If the contact which the id identifies has not been deleted,
- the id should still be valid in the manager identified by the
- manager URI returned by this function.
- */
-
-/*!
- \fn QContactEngineId::toString() const
- Serializes the id to a string. It contains all of the information
- required to identify a particular contact in the manager which created
- the id, formatted according to the serialization format of the
- manager.
- */
-
-/*!
- \fn QContactEngineId::clone() const
- Returns a deep-copy clone of this id.
- The caller takes ownership of the returned engine contact id.
- */
-
-/*!
- \fn QContactEngineId::debugStreamOut(QDebug& dbg) const
- Streams this id out to the debug stream \a dbg.
- */
-
-/*!
- \fn QContactEngineId::hash() const
- Returns the hash value of this id.
- */
-
-QT_END_NAMESPACE_CONTACTS
diff --git a/src/contacts/qcontactengineid.h b/src/contacts/qcontactengineid.h
deleted file mode 100644
index 2113afe75..000000000
--- a/src/contacts/qcontactengineid.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtContacts module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCONTACTENGINEID_H
-#define QCONTACTENGINEID_H
-
-#include <QtCore/qshareddata.h>
-#include <QtCore/qstring.h>
-
-#include <QtContacts/qcontactabstractrequest.h>
-
-QT_BEGIN_NAMESPACE_CONTACTS
-
-class Q_CONTACTS_EXPORT QContactEngineId: public QSharedData
-{
-public:
- virtual ~QContactEngineId() {}
-
- virtual bool isEqualTo(const QContactEngineId *other) const = 0;
- virtual bool isLessThan(const QContactEngineId *other) const = 0;
-
- virtual QString managerUri() const = 0;
-
- virtual QContactEngineId* clone() const = 0;
-
- virtual QString toString() const = 0;
-
-#ifndef QT_NO_DEBUG_STREAM
- // NOTE: on platforms where Qt is built without debug streams enabled, vtable will differ!
- virtual QDebug& debugStreamOut(QDebug &dbg) const = 0;
-#endif
- virtual uint hash() const = 0;
-};
-
-QT_END_NAMESPACE_CONTACTS
-
-#endif // QCONTACTENGINEID_H
diff --git a/src/contacts/qcontactid.cpp b/src/contacts/qcontactid.cpp
index 31fae155c..37b03c2af 100644
--- a/src/contacts/qcontactid.cpp
+++ b/src/contacts/qcontactid.cpp
@@ -48,185 +48,109 @@
#include <QtCore/qdebug.h>
#endif
-#include "qcontactengineid.h"
#include "qcontactmanager_p.h"
-QT_BEGIN_NAMESPACE
-template<> QTCONTACTS_PREPEND_NAMESPACE(QContactEngineId) *QSharedDataPointer<QTCONTACTS_PREPEND_NAMESPACE(QContactEngineId)>::clone()
-{
- return d ? d->clone() : 0;
-}
-QT_END_NAMESPACE
-
QT_BEGIN_NAMESPACE_CONTACTS
/*!
- \class QContactId
+ \class QContactId
+ \brief The QContactId class provides information that uniquely identifies
+ a contact in a particular manager.
+ \inmodule QtContacts
+ \ingroup contacts-main
- \inmodule QtContacts
+ It consists of a manager URI which identifies the manager which contains the contact,
+ and the engine specific ID of the contact in that manager.
- \brief The QContactId class provides information that uniquely identifies
- a contact in a particular manager.
+ An invalid QContactId has an empty manager URI.
+*/
- It consists of a manager URI which identifies the manager which contains the contact,
+/*!
+ \fn QContactId::QContactId()
- A QContactId is "null" when it is default-constructed and therefore not associated with a contact in any manager.
+ Constructs a new, invalid contact ID.
*/
+// TODO: Document and remove internal once the correct signature has been determined
/*!
- * Constructs a new contact id. The contact is said to be "null",
- it has null engine id and isNull() for it returns true. This is the default constructor
+ \fn QContactId::QContactId(const QString &managerUri, const QString &localId)
+ \internal
- \sa isNull()
- */
-QContactId::QContactId()
- : d(0)
-{
-}
+ Constructs an ID from the supplied manager URI \a managerUri and the engine
+ specific \a localId string.
+*/
/*!
- * Cleans up the memory in use by the contact id
- */
-QContactId::~QContactId()
-{
-}
+ \fn bool QContactId::operator==(const QContactId &other) const
-/*! Constructs a new contact id as a copy of \a other */
-QContactId::QContactId(const QContactId &other)
- : d(other.d)
-{
-}
+ Returns true if this contact ID has the same manager URI and
+ engine specific ID as \a other. Returns true also, if both IDs are null.
+*/
/*!
- Constructs a manager-unique id which wraps the given engine-unique contact id
- \a engineId. This id takes ownership of the engine-unique contact id and
- will delete it when the id goes out of scope. Engine implementors must not
- delete the \a engineId or undefined behaviour will occur.
- The created contact id is not null, if the \a engineId is not null.
- */
-QContactId::QContactId(QContactEngineId *engineId)
- : d(engineId)
-{
-}
+ \fn bool QContactId::operator!=(const QContactId &other) const
-/*! Assigns the contact id to be equal to \a other
+ Returns true if either the manager URI or engine specific ID of this
+ contact ID is different to that of \a other.
*/
-QContactId& QContactId::operator=(const QContactId &other)
-{
- d = other.d;
- return *this;
-}
-/*! Returns true if the \a other contact id has the same manager URI
- and they have equal engine ids. Returns true also, if both are null contact ids.
-*/
-bool QContactId::operator==(const QContactId &other) const
-{
- // if both ids are null then they are equal.
- if (d == 0 && other.d == 0)
- return true;
+/*!
+ \fn bool operator<(const QContactId &id1, const QContactId &id2)
+ \relates QContactId
- if (d && other.d) {
- // ensure they're of the same type (and therefore comparable)
- if (d->managerUri() == other.d->managerUri())
- return d->isEqualTo(other.d);
- }
+ Returns true if the contact ID \a id1 will be considered less than
+ the contact ID \a id2 if the manager URI of ID \a id1 is alphabetically
+ less than the manager URI of the \a id2 ID. If both IDs have the same
+ manager URI, ID \a id1 will be considered less than the ID \a id2
+ if the the engine specific ID of \a id1 is less than the engine specific ID of \a id2.
- return false;
-}
+ The invalid, null contact ID consists of an empty manager URI and a null engine ID,
+ and hence will be less than any valid, non-null contact ID.
-/*! Returns true if either the manager URI or id of the contact id is different to that of \a other
+ This operator is provided primarily to allow use of a QContactId as a key in a QMap.
*/
-bool QContactId::operator!=(const QContactId &other) const
-{
- return !(*this == other);
-}
-
-/*! Returns true if this id is less than the \a other id.
- This id will be considered less than the \a other id if the
- manager URI of this id is alphabetically less than the manager
- URI of the \a other id. If both ids have the same manager URI,
- this id will be considered less than the \a other id if the
- engine id of this id is less than the engine id of the \a other id.
- The null contact id is less than any non-null id.
+/*!
+ \fn uint qHash(const QContactId &id)
+ \relates QContactId
- This operator is provided primarily to allow use of a QContactId
- as a key in a QMap.
- */
-bool QContactId::operator<(const QContactId &other) const
-{
+ Returns the hash value for \a id.
+*/
- // a null id is always less than a non-null id.
- if (d == 0 && other.d != 0)
- return true;
+/*!
+ \fn bool QContactId::isValid() const
- if (d && other.d) {
- // ensure they're of the same type (and therefore comparable)
- if (d->managerUri() == other.d->managerUri())
- return d->isLessThan(other.d);
+ Returns true if the manager URI part is not null; returns false otherwise.
- // not the same type? just compare the manager uri.
- return d->managerUri() < other.d->managerUri();
- }
+ Note that valid ID may be null at the same time, which means new contact.
- return false;
-}
+ \sa isNull()
+*/
/*!
- * Returns the hash value for \a key.
- */
-uint qHash(const QContactId &key)
-{
- if (key.d)
- return key.d->hash();
- return 0;
-}
+ \fn bool QContactId::isNull() const
+ Returns true if the engine specific ID part is a null (default constructed);
+ returns false otherwise.
-/*!
-Returns true if this is the null (default constructed) id which has a null engine id;
- */
-bool QContactId::isNull() const
-{
- return d == 0;
-}
+ \sa isValid()
+*/
/*!
- * Returns the URI of the manager which contains the contact identified by this id
- */
-QString QContactId::managerUri() const
-{
- return d ? d->managerUri() : QString();
-}
+ \fn QString QContactId::managerUri() const
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QContactId &id)
-{
- dbg.nospace() << "QContactId(";
- if (id.isNull())
- dbg.nospace() << "(null))";
- else
- id.d->debugStreamOut(dbg) << ")";
- return dbg.maybeSpace();
-}
-#endif
+ Returns the URI of the manager which contains the contact identified by this ID.
-#ifndef QT_NO_DATASTREAM
-QDataStream& operator<<(QDataStream &out, const QContactId &contactId)
-{
- out << (contactId.toString());
- return out;
-}
+ \sa localId()
+*/
-QDataStream& operator>>(QDataStream &in, QContactId &id)
-{
- QString idString;
- in >> idString;
- id = QContactId::fromString(idString);
- return in;
-}
-#endif
+/*!
+ \fn QString QContactId::localId() const
+
+ Returns the contact's engine specific ID part.
+
+ \sa managerUri()
+*/
/*!
Serializes the contact ID to a string. The format of the string will be:
@@ -236,35 +160,63 @@ QDataStream& operator>>(QDataStream &in, QContactId &id)
*/
QString QContactId::toString() const
{
- QString managerName;
- QMap<QString, QString> params;
- QString engineIdString;
-
- // rely on engine id to supply the full manager uri
- if (d && QContactManagerData::parseIdString(d->managerUri(), &managerName, &params))
- engineIdString = d->toString();
+ if (QContactManagerData::parseIdString(m_managerUri, 0, 0))
+ return QContactManagerData::buildIdString(m_managerUri, m_localId);
- return QContactManagerData::buildIdString(managerName, params, &engineIdString);
+ return QContactManagerData::buildIdString(QString(), QMap<QString, QString>(), QStringLiteral(""));
}
/*!
Deserializes the given \a idString. Returns a default-constructed (null)
- contact ID if the given \a idString is not a valid, serialized contact ID,
- or if the manager engine from which the ID came could not be found.
+ contact ID if the given \a idString is not a valid, serialized contact ID.
\sa toString()
*/
QContactId QContactId::fromString(const QString &idString)
{
- QString managerName;
- QMap<QString, QString> params;
+ QString managerUri;
QString engineIdString;
- if (!QContactManagerData::parseIdString(idString, &managerName, &params, &engineIdString))
- return QContactId(); // invalid idString given.
+ if (QContactManagerData::parseIdString(idString, 0, 0, &managerUri, &engineIdString))
+ return QContactId(managerUri, engineIdString);
+
+ return QContactId();
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+/*!
+ \relates QContactId
+ Outputs \a id to the debug stream \a dbg.
+*/
+QDebug operator<<(QDebug dbg, const QContactId &id)
+{
+ dbg.nospace() << "QContactId(" << id.toString() << ")";
+ return dbg.maybeSpace();
+}
+#endif // QT_NO_DEBUG_STREAM
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \relates QContactId
+ Streams \a id to the data stream \a out.
+*/
+QDataStream& operator<<(QDataStream &out, const QContactId &id)
+{
+ out << id.toString();
+ return out;
+}
- QContactEngineId* engineId = QContactManagerData::createEngineContactId(managerName, params, engineIdString);
- return QContactId(engineId);
+/*!
+ \relates QContactId
+ Streams \a id in from the data stream \a in.
+*/
+QDataStream& operator>>(QDataStream &in, QContactId &id)
+{
+ QString idString;
+ in >> idString;
+ id = QContactId::fromString(idString);
+ return in;
}
+#endif // QT_NO_DATASTREAM
QT_END_NAMESPACE_CONTACTS
diff --git a/src/contacts/qcontactid.h b/src/contacts/qcontactid.h
index 45db76e4a..0697008ac 100644
--- a/src/contacts/qcontactid.h
+++ b/src/contacts/qcontactid.h
@@ -42,7 +42,6 @@
#ifndef QCONTACTID_H
#define QCONTACTID_H
-#include <QtCore/qshareddata.h>
#include <QtCore/qvariant.h>
#include <QtContacts/qcontactsglobal.h>
@@ -51,38 +50,39 @@ QT_BEGIN_NAMESPACE_CONTACTS
class QContactManagerEngine;
-class QContactEngineId;
class Q_CONTACTS_EXPORT QContactId
{
public:
- QContactId();
- ~QContactId();
+ inline QContactId() {}
+ inline QContactId(const QString &managerUri, const QString &localId)
+ : m_managerUri(managerUri), m_localId(localId)
+ {}
+ // compiler-generated dtor and copy/move ctors/assignment operators are fine!
- QContactId(const QContactId &other);
- QContactId& operator=(const QContactId &other);
- explicit QContactId(QContactEngineId *engineId);
+ inline bool operator==(const QContactId &other) const
+ { return localId() == other.localId() && managerUri() == other.managerUri(); }
+ inline bool operator!=(const QContactId &other) const
+ { return localId() != other.localId() || managerUri() != other.managerUri(); }
- bool operator==(const QContactId &other) const;
- bool operator!=(const QContactId &other) const;
- bool operator<(const QContactId &other) const;
+ inline bool isValid() const { return !m_managerUri.isEmpty(); }
+ inline bool isNull() const { return m_localId.isEmpty(); }
+
+ inline QString managerUri() const { return m_managerUri; }
+ inline QString localId() const { return m_localId; }
- QString managerUri() const;
- bool isNull() const;
QString toString() const;
static QContactId fromString(const QString &idString);
private:
- QSharedDataPointer<QContactEngineId> d;
- friend class QContactManager;
- friend class QContactManagerEngine;
- Q_CONTACTS_EXPORT friend uint qHash(const QContactId &key);
-
-#ifndef QT_NO_DEBUG_STREAM
- Q_CONTACTS_EXPORT friend QDebug operator<<(QDebug dbg, const QContactId &id);
-#endif
+ QString m_managerUri;
+ QString m_localId;
};
-Q_CONTACTS_EXPORT uint qHash(const QContactId &key);
+inline bool operator<(const QContactId &id1, const QContactId &id2)
+{ return (id1.managerUri() != id2.managerUri()) ? id1.managerUri() < id2.managerUri() : id1.localId() < id2.localId(); }
+
+inline uint qHash(const QContactId &id)
+{ return qHash(id.localId()); }
#ifndef QT_NO_DEBUG_STREAM
Q_CONTACTS_EXPORT QDebug operator<<(QDebug dbg, const QContactId &id);
diff --git a/src/contacts/qcontactmanager_p.cpp b/src/contacts/qcontactmanager_p.cpp
index 132a934c4..9472c00e6 100644
--- a/src/contacts/qcontactmanager_p.cpp
+++ b/src/contacts/qcontactmanager_p.cpp
@@ -193,16 +193,6 @@ void QContactManagerData::createEngine(const QString &managerName, const QMap<QS
}
}
-
-/* Caller takes ownership of the id */
-QContactEngineId* QContactManagerData::createEngineContactId(const QString &managerName, const QMap<QString, QString>& parameters, const QString &engineIdString)
-{
- loadFactoriesMetadata();
- QContactManagerEngineFactory *engineFactory = m_engines.value(managerName);
- return engineFactory ? engineFactory->createContactEngineId(parameters, engineIdString) : NULL;
-}
-
-
void QContactManagerData::loadStaticFactories()
{
if (!m_discoveredStatic) {
@@ -385,10 +375,10 @@ static inline QString unescapeParam(const QString &param)
/*!
Parses the individual components of the given \a idString and fills the
- \a managerName, \a params and \a engineIdString.
+ \a managerName, \a params, \a managerUri and \a engineIdString.
Returns true if the parts could be parsed successfully, false otherwise.
*/
-bool QContactManagerData::parseIdString(const QString &idString, QString *managerName, QMap<QString, QString> *params, QString *engineIdString)
+bool QContactManagerData::parseIdString(const QString &idString, QString *managerName, QMap<QString, QString> *params, QString *managerUri, QString *engineIdString)
{
// Format: qtcontacts:<managerid>:<key>=<value>&<key>=<value>:<engineIdString>
// we assume that the prefix, managerid, params, and engineIdString cannot contain `:', `=', or `&'
@@ -399,7 +389,7 @@ bool QContactManagerData::parseIdString(const QString &idString, QString *manage
return false;
const QString prefix = colonSplit.at(0);
- const QString mgrName = colonSplit.at(1).trimmed();
+ const QString mgrName = colonSplit.at(1);
const QString paramString = colonSplit.value(2);
if (prefix != QStringLiteral("qtcontacts") || mgrName.isEmpty())
@@ -434,6 +424,9 @@ bool QContactManagerData::parseIdString(const QString &idString, QString *manage
if (managerName)
*managerName = unescapeParam(mgrName);
+ if (managerUri)
+ *managerUri = prefix + QLatin1Char(':') + mgrName + QLatin1Char(':') + paramString;
+
// and unescape the engine id string
if (engineIdString)
*engineIdString = unescapeParam(colonSplit.at(3));
@@ -442,12 +435,26 @@ bool QContactManagerData::parseIdString(const QString &idString, QString *manage
}
/*!
- Returns a ID string that describes a manager name and parameters with which to instantiate
+ Returns an ID string that describes a manager name and parameters with which to instantiate
+ a manager object, from the given \a managerUri.
+ If \a engineIdString is non-null, the generated ID string is suitable for
+ passing to QContactId::fromString().
+*/
+QString QContactManagerData::buildIdString(const QString &managerUri, const QString &engineIdString)
+{
+ if (!engineIdString.isNull())
+ return managerUri + QLatin1Char(':') + escapeParam(engineIdString);
+
+ return managerUri;
+}
+
+/*!
+ Returns an ID string that describes a manager name and parameters with which to instantiate
a manager object, from the given \a managerName and \a params.
- If \a engineIdString is not null, the generated ID string is suitable for
+ If \a engineIdString is non-null, the generated ID string is suitable for
passing to QContactId::fromString().
*/
-QString QContactManagerData::buildIdString(const QString &managerName, const QMap<QString, QString> &params, QString *engineIdString)
+QString QContactManagerData::buildIdString(const QString &managerName, const QMap<QString, QString> &params, const QString &engineIdString)
{
// Format: qtcontacts:<managerid>:<key>=<value>&<key>=<value>:<engineIdString>
// if the prefix, managerid, param keys, param values, or engineIdString contain `:', `=', or `&',
@@ -466,8 +473,8 @@ QString QContactManagerData::buildIdString(const QString &managerName, const QMa
}
idString = QStringLiteral("qtcontacts:") + escapeParam(managerName) + QLatin1Char(':') + idString;
- if (engineIdString)
- idString += QLatin1Char(':') + escapeParam(*engineIdString);
+ if (!engineIdString.isNull())
+ idString += QLatin1Char(':') + escapeParam(engineIdString);
return idString;
}
diff --git a/src/contacts/qcontactmanager_p.h b/src/contacts/qcontactmanager_p.h
index 60ebc53fc..91c8cfa25 100644
--- a/src/contacts/qcontactmanager_p.h
+++ b/src/contacts/qcontactmanager_p.h
@@ -85,13 +85,14 @@ public:
}
// helpers
- static bool parseIdString(const QString &idString, QString *managerName, QMap<QString, QString> *params, QString *engineIdString = 0);
- static QString buildIdString(const QString &managerName, const QMap<QString, QString> &params, QString *engineIdString = 0);
+ static bool parseIdString(const QString &idString, QString *managerName, QMap<QString, QString> *params, QString *managerUri = 0, QString *engineIdString = 0);
+
+ static QString buildIdString(const QString &managerUri, const QString &engineIdString = QString());
+ static QString buildIdString(const QString &managerName, const QMap<QString, QString> &params, const QString &engineIdString = QString());
void createEngine(const QString &managerName, const QMap<QString, QString> &parameters);
static QContactManagerData* get(const QContactManager *manager);
static QContactManagerEngine* engine(const QContactManager *manager);
- static QContactEngineId* createEngineContactId(const QString &managerName, const QMap<QString, QString> &parameters, const QString &engineIdString);
QContactManagerEngine* m_engine;
QContactManager::Error m_lastError;
diff --git a/src/contacts/qcontactmanagerengine.cpp b/src/contacts/qcontactmanagerengine.cpp
index 00a439cd9..574d36e8b 100644
--- a/src/contacts/qcontactmanagerengine.cpp
+++ b/src/contacts/qcontactmanagerengine.cpp
@@ -207,15 +207,41 @@ QMap<QString, QString> QContactManagerEngine::managerParameters() const
}
/*!
- Returns the unique URI of this manager, which is built from the manager name and the parameters
- used to construct it.
+ Returns the subset of the manager parameters that are relevant when interpreting
+ contact ID values. Since contact ID comparison involves equivalence of
+ managerUri values, parameters that do not differentiate contact IDs should not
+ be returned by this function.
+
+ For example, a manager engine may support 'user' and 'cachesize' parameters,
+ where the former distinguishes between separate user domains, and the latter
+ is for performance tuning. The 'user' parameter will be relevant to the interpretation
+ of contact IDs and thus should be returned by this function, whereas 'cachesize'
+ is not relevant and should be omitted.
+
+ \sa managerUri(), managerParamaters()
*/
-QString QContactManagerEngine::managerUri() const
+QMap<QString, QString> QContactManagerEngine::idInterpretationParameters() const
{
- return QContactManager::buildUri(managerName(), managerParameters());
+ return QMap<QString, QString>(); // default implementation returns no parameters.
}
/*!
+ \fn QString QContactManagerEngine::managerUri() const
+
+ Returns the unique URI of this manager, which is built from the manager name and the
+ ID interpretation parameters used to construct it.
+
+ \sa idInterpretationParameters()
+ */
+
+/*!
+ \fn QContactId QContactManagerEngine::contactId(const QString &localId) const
+
+ Returns the contact ID for this managerUri() and the given
+ engine specific ID part \a localId.
+*/
+
+/*!
Returns a list of contact ids that match the given \a filter, sorted according to the given list of \a sortOrders.
Depending on the backend, this filtering operation may involve retrieving all the contacts.
Any error which occurs will be saved in \a error.
@@ -1430,18 +1456,6 @@ void QContactManagerEngine::setContactRelationships(QContact* contact, const QLi
contact->d->m_relationshipsCache = relationships;
}
-
-/*!
- Returns the engine ID from the given \a contactId.
-
- The caller does not take ownership of the pointer, and should not delete returned id or undefined
- behavior may occur.
- */
-const QContactEngineId *QContactManagerEngine::engineId(const QContactId &contactId)
-{
- return contactId.d.data();
-}
-
/*!
Compares two contacts (\a a and \a b) using the given list of \a sortOrders. Returns a negative number if \a a should appear
before \a b according to the sort order, a positive number if \a a should appear after \a b according to the sort order,
diff --git a/src/contacts/qcontactmanagerengine.h b/src/contacts/qcontactmanagerengine.h
index fc267c812..c6bde2774 100644
--- a/src/contacts/qcontactmanagerengine.h
+++ b/src/contacts/qcontactmanagerengine.h
@@ -67,12 +67,16 @@ public:
QContactManagerEngine() {}
/* URI reporting */
- virtual QString managerName() const = 0; // e.g. "memory"
- virtual QMap<QString, QString> managerParameters() const; // e.g. "filename=private.db"
+ virtual QString managerName() const = 0; // e.g. "memory"
+ virtual QMap<QString, QString> managerParameters() const; // e.g. "filename=private.db,cachesize=1024"
+ virtual QMap<QString, QString> idInterpretationParameters() const; // e.g. "filename=private.db"
virtual int managerVersion() const = 0;
- /* Default and only implementation of this */
- QString managerUri() const;
+ inline QString managerUri() const
+ { return QContactManager::buildUri(managerName(), idInterpretationParameters()); }
+
+ inline QContactId contactId(const QString &localId) const
+ { return QContactId(managerUri(), localId); }
/* Filtering */
virtual QList<QContactId> contactIds(const QContactFilter &filter, const QList<QContactSortOrder> &sortOrders, QContactManager::Error *error) const;
@@ -141,7 +145,6 @@ public:
static void setContactRelationships(QContact *contact, const QList<QContactRelationship> &relationships);
/* Helper functions */
- static const QContactEngineId *engineId(const QContactId &contactId);
static int compareContact(const QContact &a, const QContact &b, const QList<QContactSortOrder> &sortOrders);
static void addSorted(QList<QContact>* sorted, const QContact &toAdd, const QList<QContactSortOrder> &sortOrders);
static int compareVariant(const QVariant &first, const QVariant &second, Qt::CaseSensitivity sensitivity);
@@ -150,7 +153,6 @@ public:
static QContactFilter canonicalizedFilter(const QContactFilter &filter);
-
private:
/* QContactChangeSet is a utility class used to emit the appropriate signals */
friend class QContactChangeSet;
diff --git a/src/contacts/qcontactmanagerenginefactory.cpp b/src/contacts/qcontactmanagerenginefactory.cpp
index c5ac6d951..9b2bc478c 100644
--- a/src/contacts/qcontactmanagerenginefactory.cpp
+++ b/src/contacts/qcontactmanagerenginefactory.cpp
@@ -93,13 +93,6 @@ QStringList QContactManagerEngineFactory::keys() const
*/
/*!
- \fn QContactManagerEngineFactory::createContactEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const
-
- This function should return an engine-specific Contact ID, according to the given \a parameters and
- the \a engineIdString.
- */
-
-/*!
\fn QContactManagerEngineFactory::managerName() const
This function should return a unique string that identifies
diff --git a/src/contacts/qcontactmanagerenginefactory.h b/src/contacts/qcontactmanagerenginefactory.h
index 7f185f565..930b115fb 100644
--- a/src/contacts/qcontactmanagerenginefactory.h
+++ b/src/contacts/qcontactmanagerenginefactory.h
@@ -48,15 +48,11 @@
#include <QtContacts/qcontactmanager.h>
QT_BEGIN_NAMESPACE_CONTACTS
-/* Backend plugin API interface, creates engines for us */
-class QContactEngineId;
-class QContactManagerEngine;
struct Q_CONTACTS_EXPORT QContactManagerEngineFactoryInterface : public QFactoryInterface
{
virtual QContactManagerEngine *engine(const QMap<QString, QString> &parameters, QContactManager::Error *error) = 0;
virtual QString managerName() const = 0;
- virtual QContactEngineId *createContactEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const = 0;
};
QT_END_NAMESPACE_CONTACTS
@@ -75,7 +71,6 @@ public:
virtual QList<int> supportedImplementationVersions() const;
virtual ~QContactManagerEngineFactory();
virtual QContactManagerEngine* engine(const QMap<QString, QString> &parameters, QContactManager::Error *error) = 0;
- virtual QContactEngineId* createContactEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const = 0;
virtual QString managerName() const = 0;
virtual QStringList keys() const;
};
diff --git a/src/organizer/doc/src/organizerengines.qdoc b/src/organizer/doc/src/organizerengines.qdoc
index 56499a745..bf95ca09e 100644
--- a/src/organizer/doc/src/organizerengines.qdoc
+++ b/src/organizer/doc/src/organizerengines.qdoc
@@ -69,11 +69,6 @@ have its own particular way of identifying items stored in it. The
Qt Organizer API allows engine implementers to define their own
id format.
-Engine implementers must implement their own id classes derived from
-\l QOrganizerItemEngineId and \l QOrganizerCollectionEngineId respectively.
-For an example of how to implement these classes, see the \e skeleton example
-plugin.
-
\section2 Which Functions Do I Need To Implement
Different engines provide different functionality and support different features. Depending on
diff --git a/src/organizer/organizer.pro b/src/organizer/organizer.pro
index b21c628a2..8038914fa 100644
--- a/src/organizer/organizer.pro
+++ b/src/organizer/organizer.pro
@@ -14,7 +14,6 @@ include(filters/filters.pri)
PUBLIC_HEADERS += \
qorganizercollection.h \
qorganizercollectionchangeset.h \
- qorganizercollectionengineid.h \
qorganizercollectionid.h \
qorganizerabstractrequest.h \
qorganizeritemchangeset.h \
@@ -23,7 +22,6 @@ PUBLIC_HEADERS += \
qorganizeritemfilter.h \
qorganizeritem.h \
qorganizeritemid.h \
- qorganizeritemengineid.h \
qorganizeritemobserver.h \
qorganizermanager.h \
qorganizermanagerengine.h \
@@ -49,7 +47,6 @@ PRIVATE_HEADERS += \
SOURCES += \
qorganizercollection.cpp \
qorganizercollectionchangeset.cpp \
- qorganizercollectionengineid.cpp \
qorganizercollectionid.cpp \
qorganizerabstractrequest.cpp \
qorganizeritemchangeset.cpp \
@@ -58,7 +55,6 @@ SOURCES += \
qorganizeritemfetchhint.cpp \
qorganizeritemfilter.cpp \
qorganizeritemid.cpp \
- qorganizeritemengineid.cpp \
qorganizeritemobserver.cpp \
qorganizermanager.cpp \
qorganizermanagerengine.cpp \
diff --git a/src/organizer/qorganizer.h b/src/organizer/qorganizer.h
index 4f54c1707..9e991d742 100644
--- a/src/organizer/qorganizer.h
+++ b/src/organizer/qorganizer.h
@@ -65,8 +65,6 @@
#include <QtOrganizer/qorganizercollectionchangeset.h> // engine-specific collection changeset
#include <QtOrganizer/qorganizeritemchangeset.h> // engine-specific item changeset
-#include <QtOrganizer/qorganizercollectionengineid.h> // engine-specific collection id
-#include <QtOrganizer/qorganizeritemengineid.h> // engine specific item id
#include <QtOrganizer/qorganizeritems.h> // item derived classes
#include <QtOrganizer/qorganizeritemdetails.h> // detail derived classes
diff --git a/src/organizer/qorganizercollectionengineid.cpp b/src/organizer/qorganizercollectionengineid.cpp
deleted file mode 100644
index eba7204b0..000000000
--- a/src/organizer/qorganizercollectionengineid.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtOrganizer module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qorganizercollectionengineid.h"
-
-QT_BEGIN_NAMESPACE_ORGANIZER
-
-/*!
- \class QOrganizerCollectionEngineId
- \brief The QOrganizerCollectionEngineId class uniquely identifies an item within a
- particular engine plugin.
- \inmodule QtOrganizer
- \ingroup organizer-backends
-
- Clients of the Organizer API should never use this class, while every engine implementor must
- implement a class derived from QOrganizerCollectionEngineId.
-
- This class is provided so that engine implementors can implement their own collection ID class
- (which may contain arbitrary data, and which may implement the required functions in an arbitrary
- manner).
- */
-
-/*!
- Cleans up any memory in use by this engine collection ID.
- */
-QOrganizerCollectionEngineId::~QOrganizerCollectionEngineId()
-{
-}
-
-/*!
- \fn QOrganizerCollectionEngineId::isEqualTo(const QOrganizerCollectionEngineId *other) const
-
- Returns true if this ID is equal to the \a other; false otherwise.
-
- Note that when implementing this function, you do not have to check that the type is the same,
- since the function which calls this function (in QOrganizerCollectionId) does that check for you.
- */
-
-/*!
- \fn QOrganizerCollectionEngineId::isLessThan(const QOrganizerCollectionEngineId *other) const
-
- Returns true if this id is less than the \a other; false otherwise.
-
- Note that when implementing this function, you do not have to check that the type is the same,
- since the function which calls this function (in QOrganizerCollectionId) does that check for you.
- */
-
-/*!
- \fn QOrganizerCollectionEngineId::managerUri() const
-
- Returns the manager URI of the constructed manager which created the ID. If the collection which
- the ID identifies has not been deleted, the ID should still be valid in the manager identified by
- the manager URI returned by this function.
- */
-
-/*!
- \fn QOrganizerCollectionEngineId::toString() const
-
- Serializes the id to a string. It contains all of the information required to identify a particular
- collection in the manager which created the ID, formatted according to the serialization format of
- the manager.
- */
-
-/*!
- \fn QOrganizerCollectionEngineId::clone() const
-
- Returns a deep-copy clone of this ID. The caller takes ownership of the returned engine collection
- ID.
- */
-
-/*!
- \fn QOrganizerCollectionEngineId::debugStreamOut(QDebug &dbg) const
-
- Streams this ID out to the debug stream \a dbg.
- */
-
-/*!
- \fn QOrganizerCollectionEngineId::hash() const
-
- Returns the hash value of this ID.
- */
-
-QT_END_NAMESPACE_ORGANIZER
diff --git a/src/organizer/qorganizercollectionengineid.h b/src/organizer/qorganizercollectionengineid.h
deleted file mode 100644
index bac1d2b1b..000000000
--- a/src/organizer/qorganizercollectionengineid.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtOrganizer module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QORGANIZERCOLLECTIONENGINEID_H
-#define QORGANIZERCOLLECTIONENGINEID_H
-
-#include <QtCore/qshareddata.h>
-#include <QtCore/qstring.h>
-
-#include <QtOrganizer/qorganizerglobal.h>
-
-QT_BEGIN_NAMESPACE_ORGANIZER
-
-class Q_ORGANIZER_EXPORT QOrganizerCollectionEngineId : public QSharedData
-{
-public:
- virtual ~QOrganizerCollectionEngineId();
-
- virtual bool isEqualTo(const QOrganizerCollectionEngineId *other) const = 0;
- virtual bool isLessThan(const QOrganizerCollectionEngineId *other) const = 0;
-
- virtual QString managerUri() const = 0;
-
- virtual QOrganizerCollectionEngineId *clone() const = 0;
-
- virtual QString toString() const = 0;
-
-#ifndef QT_NO_DEBUG_STREAM
- // NOTE: on platforms where Qt is built without debug streams enabled, vtable will differ!
- virtual QDebug &debugStreamOut(QDebug &dbg) const = 0;
-#endif // QT_NO_DEBUG_STREAM
-
- virtual uint hash() const = 0;
-};
-
-QT_END_NAMESPACE_ORGANIZER
-
-QT_BEGIN_NAMESPACE
-Q_DECLARE_TYPEINFO(QTORGANIZER_PREPEND_NAMESPACE(QOrganizerCollectionEngineId), Q_MOVABLE_TYPE);
-QT_END_NAMESPACE
-
-#endif // QORGANIZERCOLLECTIONENGINEID_H
diff --git a/src/organizer/qorganizercollectionid.cpp b/src/organizer/qorganizercollectionid.cpp
index 16edb0ea9..d9c799671 100644
--- a/src/organizer/qorganizercollectionid.cpp
+++ b/src/organizer/qorganizercollectionid.cpp
@@ -48,18 +48,8 @@
#include <QtCore/qdebug.h>
#endif
-#include "qorganizercollectionengineid.h"
#include "qorganizermanager_p.h"
-#if !defined(Q_CC_MWERKS)
-QT_BEGIN_NAMESPACE
-template<> QTORGANIZER_PREPEND_NAMESPACE(QOrganizerCollectionEngineId) *QSharedDataPointer<QTORGANIZER_PREPEND_NAMESPACE(QOrganizerCollectionEngineId)>::clone()
-{
- return d ? d->clone() : 0;
-}
-QT_END_NAMESPACE
-#endif // Q_CC_MWERKS
-
QT_BEGIN_NAMESPACE_ORGANIZER
/*!
@@ -69,136 +59,138 @@ QT_BEGIN_NAMESPACE_ORGANIZER
\inmodule QtOrganizer
\ingroup organizer-main
- It consists of a manager URI which identifies the manager which manages the collection, and the
- ID of the collection in that manager.
- */
+ It consists of a manager URI which identifies the manager which contains the collection,
+ and the engine specific ID of the collection in that manager.
-/*!
- Constructs a new, null collection ID.
- */
-QOrganizerCollectionId::QOrganizerCollectionId()
- : d(0)
-{
-}
+ An invalid QOrganizerCollectionId has an empty manager URI.
+*/
/*!
- Cleans up the memory in use by the collection ID.
- */
-QOrganizerCollectionId::~QOrganizerCollectionId()
-{
-}
+ \fn QOrganizerCollectionId::QOrganizerCollectionId()
+
+ Constructs a new, invalid collection ID.
+*/
+// TODO: Document and remove internal once the correct signature has been determined
/*!
- Constructs a manager-unique ID which wraps the given engine-unique \a engineId.
+ \fn QOrganizerCollectionId::QOrganizerCollectionId(const QString &managerUri, const QString &localId)
+ \internal
- This ID takes ownership of the \a engineId and will delete it when this ID is destructed. Engine
- implementors must not delete the \a engineId, otherwise undefined behaviour will occur.
- */
-QOrganizerCollectionId::QOrganizerCollectionId(QOrganizerCollectionEngineId *engineId)
- : d(engineId)
-{
-}
+ Constructs an ID from the supplied manager URI \a managerUri and the engine
+ specific \a localId string.
+*/
/*!
- Constructs a new collection ID as a copy of \a other.
- */
-QOrganizerCollectionId::QOrganizerCollectionId(const QOrganizerCollectionId &other)
- : d(other.d)
-{
-}
+ \fn bool QOrganizerCollectionId::operator==(const QOrganizerCollectionId &other) const
+
+ Returns true if this collection ID has the same manager URI and
+ engine specific ID as \a other. Returns true also, if both IDs are null.
+*/
/*!
- Assigns the collection ID to be equal to \a other.
- */
-QOrganizerCollectionId &QOrganizerCollectionId::operator=(const QOrganizerCollectionId &other)
-{
- d = other.d;
- return *this;
-}
+ \fn bool QOrganizerCollectionId::operator!=(const QOrganizerCollectionId &other) const
+
+ Returns true if either the manager URI or engine specific ID of this
+ collection ID is different to that of \a other.
+*/
/*!
- Returns true if it has the same manager URI and ID as \a other.
+ \fn bool operator<(const QOrganizerCollectionId &id1, const QOrganizerCollectionId &id2)
+ \relates QOrganizerCollectionId
+
+ Returns true if the collection ID \a id1 will be considered less than
+ the collection ID \a id2 if the manager URI of ID \a id1 is alphabetically
+ less than the manager URI of the \a id2 ID. If both IDs have the same
+ manager URI, ID \a id1 will be considered less than the ID \a id2
+ if the the engine specific ID of \a id1 is less than the engine specific ID of \a id2.
+
+ The invalid, null collection ID consists of an empty manager URI and a null engine ID,
+ and hence will be less than any valid, non-null collection ID.
+
+ This operator is provided primarily to allow use of a QOrganizerCollectionId as a key in a QMap.
*/
-bool QOrganizerCollectionId::operator==(const QOrganizerCollectionId &other) const
-{
- if (d == other.d)
- return true;
- if (d && other.d)
- return d->managerUri() == other.d->managerUri() && d->isEqualTo(other.d);
+/*!
+ \fn uint qHash(const QOrganizerCollectionId &id)
+ \relates QOrganizerCollectionId
- return false;
-}
+ Returns the hash value for \a id.
+*/
/*!
- Returns true if either the manager URI or ID of it is different to that of \a other.
- */
-bool QOrganizerCollectionId::operator!=(const QOrganizerCollectionId &other) const
-{
- return !(*this == other);
-}
+ \fn bool QOrganizerCollectionId::isValid() const
+
+ Returns true if the manager URI part is not null; returns false otherwise.
+
+ Note that valid ID may be null at the same time, which means new collection.
+
+ \sa isNull()
+*/
/*!
- Returns true if this ID is less than the \a other.
+ \fn bool QOrganizerCollectionId::isNull() const
- This ID will be considered less than the \a other if the manager URI of this ID is alphabetically
- less than the manager URI of the \a other. If both IDs have the same manager URI, this ID will
- be considered less than the \a other if the engine ID is less than the engine ID of the \a other.
+ Returns true if the engine specific ID part is a null (default constructed);
+ returns false otherwise.
- The invalid, empty ID consists of an empty manager URI and a null engine ID, and hence will be
- less than any non-invalid ID.
+ \sa isValid()
+*/
- This operator is provided primarily to allow use of a QOrganizerCollectionId as a key in a QMap.
- */
-bool QOrganizerCollectionId::operator<(const QOrganizerCollectionId &other) const
-{
- // a null id is always less than a non-null id.
- if (d == 0 && other.d != 0)
- return true;
+/*!
+ \fn QString QOrganizerCollectionId::managerUri() const
+
+ Returns the URI of the manager which contains the collection identified by this ID.
+
+ \sa localId()
+*/
- if (d && other.d) {
- // ensure they're of the same type (and therefore comparable)
- if (d->managerUri() == other.d->managerUri())
- return d->isLessThan(other.d);
+/*!
+ \fn QString QOrganizerCollectionId::localId() const
- // not the same type? just compare the manager uri.
- return d->managerUri() < other.d->managerUri();
- }
+ Returns the collection's engine specific ID part.
- return false;
-}
+ \sa managerUri()
+*/
/*!
- Returns true if the engine ID part of this ID is null (default constructed); otherwise, returns false.
- */
-bool QOrganizerCollectionId::isNull() const
+ Serializes the collection ID to a string. The format of the string will be:
+ "qtorganizer:managerName:constructionParams:engineLocalCollectionId".
+
+ \sa fromString()
+*/
+QString QOrganizerCollectionId::toString() const
{
- return (d == 0);
+ if (QOrganizerManagerData::parseIdString(m_managerUri, 0, 0))
+ return QOrganizerManagerData::buildIdString(m_managerUri, m_localId);
+
+ return QOrganizerManagerData::buildIdString(QString(), QMap<QString, QString>(), QStringLiteral(""));
}
/*!
- \relates QOrganizerCollectionId
- Returns the hash value for \a key.
- */
-uint qHash(const QOrganizerCollectionId &key)
+ Deserializes the given \a idString. Returns a default-constructed (null)
+ collection ID if the given \a idString is not a valid, serialized collection ID.
+
+ \sa toString()
+*/
+QOrganizerCollectionId QOrganizerCollectionId::fromString(const QString &idString)
{
- if (key.d)
- return key.d->hash();
- return 0;
+ QString managerUri;
+ QString engineIdString;
+
+ if (QOrganizerManagerData::parseIdString(idString, 0, 0, &managerUri, &engineIdString))
+ return QOrganizerCollectionId(managerUri, engineIdString);
+
+ return QOrganizerCollectionId();
}
#ifndef QT_NO_DEBUG_STREAM
/*!
\relates QOrganizerCollectionId
Outputs \a id to the debug stream \a dbg.
- */
+*/
QDebug operator<<(QDebug dbg, const QOrganizerCollectionId &id)
{
- dbg.nospace() << "QOrganizerCollectionId(";
- if (id.isNull())
- dbg.nospace() << "(null))";
- else
- id.d->debugStreamOut(dbg) << ")";
+ dbg.nospace() << "QOrganizerCollectionId(" << id.toString() << ")";
return dbg.maybeSpace();
}
#endif // QT_NO_DEBUG_STREAM
@@ -206,72 +198,25 @@ QDebug operator<<(QDebug dbg, const QOrganizerCollectionId &id)
#ifndef QT_NO_DATASTREAM
/*!
\relates QOrganizerCollectionId
- Streams \a collectionId to the data stream \a out.
- */
-QDataStream &operator<<(QDataStream &out, const QOrganizerCollectionId &collectionId)
+ Streams \a id to the data stream \a out.
+*/
+QDataStream &operator<<(QDataStream &out, const QOrganizerCollectionId &id)
{
- out << (collectionId.toString());
+ out << id.toString();
return out;
}
/*!
\relates QOrganizerCollectionId
- Streams \a collectionId in from the data stream \a in.
- */
-QDataStream &operator>>(QDataStream &in, QOrganizerCollectionId &collectionId)
+ Streams \a id in from the data stream \a in.
+*/
+QDataStream &operator>>(QDataStream &in, QOrganizerCollectionId &id)
{
QString idString;
in >> idString;
- collectionId = QOrganizerCollectionId::fromString(idString);
+ id = QOrganizerCollectionId::fromString(idString);
return in;
}
#endif // QT_NO_DATASTREAM
-/*!
- Returns the URI of the manager which contains the collection identified by this ID.
- */
-QString QOrganizerCollectionId::managerUri() const
-{
- return d ? d->managerUri() : QString::null;
-}
-
-/*!
- Serializes the collection ID to a string. The format of the string will be:
- "qtorganizer:managerName:constructionParams:engineLocalCollectionId".
-
- \sa fromString()
-*/
-QString QOrganizerCollectionId::toString() const
-{
- QString managerName;
- QMap<QString, QString> params;
- QString engineIdString;
-
- // rely on engine id to supply the full manager uri
- if (d && QOrganizerManagerData::parseIdString(d->managerUri(), &managerName, &params))
- engineIdString = d->toString();
-
- return QOrganizerManagerData::buildIdString(managerName, params, &engineIdString);
-}
-
-/*!
- Deserializes the given \a idString. Returns a default-constructed (null)
- collection ID if the given \a idString is not a valid, serialized collection ID,
- or if the manager engine from which the ID refers to could not be found.
-
- \sa toString()
-*/
-QOrganizerCollectionId QOrganizerCollectionId::fromString(const QString &idString)
-{
- QString managerName;
- QMap<QString, QString> params;
- QString engineIdString;
-
- if (!QOrganizerManagerData::parseIdString(idString, &managerName, &params, &engineIdString))
- return QOrganizerCollectionId(); // invalid idString given.
-
- QOrganizerCollectionEngineId *engineId = QOrganizerManagerData::createEngineCollectionId(managerName, params, engineIdString);
- return QOrganizerCollectionId(engineId);
-}
-
QT_END_NAMESPACE_ORGANIZER
diff --git a/src/organizer/qorganizercollectionid.h b/src/organizer/qorganizercollectionid.h
index e30b2823a..a47554c8f 100644
--- a/src/organizer/qorganizercollectionid.h
+++ b/src/organizer/qorganizercollectionid.h
@@ -42,7 +42,6 @@
#ifndef QORGANIZERCOLLECTIONID_H
#define QORGANIZERCOLLECTIONID_H
-#include <QtCore/qshareddata.h>
#include <QtCore/qvariant.h>
#include <QtOrganizer/qorganizerglobal.h>
@@ -51,49 +50,48 @@ QT_BEGIN_NAMESPACE_ORGANIZER
class QOrganizerManagerEngine;
-class QOrganizerCollectionEngineId;
class Q_ORGANIZER_EXPORT QOrganizerCollectionId
{
public:
- QOrganizerCollectionId();
- explicit QOrganizerCollectionId(QOrganizerCollectionEngineId *engineId);
- QOrganizerCollectionId(const QOrganizerCollectionId &other);
- ~QOrganizerCollectionId();
+ inline QOrganizerCollectionId() {}
+ inline QOrganizerCollectionId(const QString &managerUri, const QString &localId)
+ : m_managerUri(managerUri), m_localId(localId)
+ {}
+ // compiler-generated dtor and copy/move ctors/assignment operators are fine!
- QOrganizerCollectionId &operator=(const QOrganizerCollectionId &other);
+ inline bool operator==(const QOrganizerCollectionId &other) const
+ { return localId() == other.localId() && managerUri() == other.managerUri(); }
+ inline bool operator!=(const QOrganizerCollectionId &other) const
+ { return localId() != other.localId() || managerUri() != other.managerUri(); }
- bool operator==(const QOrganizerCollectionId &other) const;
- bool operator!=(const QOrganizerCollectionId &other) const;
- bool operator<(const QOrganizerCollectionId &other) const;
+ inline bool isValid() const { return !m_managerUri.isEmpty(); }
+ inline bool isNull() const { return m_localId.isEmpty(); }
- bool isNull() const;
-
- QString managerUri() const;
+ inline QString managerUri() const { return m_managerUri; }
+ inline QString localId() const { return m_localId; }
QString toString() const;
static QOrganizerCollectionId fromString(const QString &idString);
private:
- QSharedDataPointer<QOrganizerCollectionEngineId> d;
-
-#ifndef QT_NO_DEBUG_STREAM
- Q_ORGANIZER_EXPORT friend QDebug operator<<(QDebug dbg, const QOrganizerCollectionId &id);
-#endif // QT_NO_DEBUG_STREAM
-
- Q_ORGANIZER_EXPORT friend uint qHash(const QOrganizerCollectionId &key);
- friend class QOrganizerManagerEngine;
+ QString m_managerUri;
+ QString m_localId;
};
-Q_ORGANIZER_EXPORT uint qHash(const QOrganizerCollectionId &key);
+inline bool operator<(const QOrganizerCollectionId &id1, const QOrganizerCollectionId &id2)
+{ return (id1.managerUri() != id2.managerUri()) ? id1.managerUri() < id2.managerUri() : id1.localId() < id2.localId(); }
+
+inline uint qHash(const QOrganizerCollectionId &id)
+{ return qHash(id.localId()); }
#ifndef QT_NO_DATASTREAM
-Q_ORGANIZER_EXPORT QDataStream &operator<<(QDataStream &out, const QOrganizerCollectionId &collectionId);
-Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerCollectionId &collectionId);
-#endif // QT_NO_DATASTREAM
+Q_ORGANIZER_EXPORT QDataStream &operator<<(QDataStream &out, const QOrganizerCollectionId &id);
+Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerCollectionId &id);
+#endif
#ifndef QT_NO_DEBUG_STREAM
Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerCollectionId &id);
-#endif // QT_NO_DEBUG_STREAM
+#endif
QT_END_NAMESPACE_ORGANIZER
diff --git a/src/organizer/qorganizeritemengineid.cpp b/src/organizer/qorganizeritemengineid.cpp
deleted file mode 100644
index e175d8336..000000000
--- a/src/organizer/qorganizeritemengineid.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtOrganizer module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qorganizeritemengineid.h"
-
-QT_BEGIN_NAMESPACE_ORGANIZER
-
-/*!
- \class QOrganizerItemEngineId
- \relates QOrganizerItemId
- \brief The QOrganizerItemEngineId class uniquely identifies an item within a
- particular engine plugin.
-
- \inmodule QtOrganizer
- \ingroup organizer-backends
-
- Clients of the Organizer API should never use this class.
- Every engine implementor must implement a class derived from
- QOrganizerItemEngineId.
-
- This class is provided so that engine implementors can implement their own
- id class (which may contain arbitrary data, and which may implement the
- required functions in an arbitrary manner).
- */
-
-/*!
- \fn QOrganizerItemEngineId::~QOrganizerItemEngineId()
- Cleans up any memory in use by this engine item id.
- */
-
-/*!
- \fn QOrganizerItemEngineId::isEqualTo(const QOrganizerItemEngineId* other) const
- Returns true if this id is equal to the \a other id; false otherwise.
- Note that when implementing this function, you do not have to check that the type is the same,
- since the function which calls this function (in QOrganizerItemId) does that check for you.
- */
-
-/*!
- \fn QOrganizerItemEngineId::isLessThan(const QOrganizerItemEngineId* other) const
- Returns true if this id is less than the \a other id; false otherwise.
- Note that when implementing this function, you do not have to check that the type is the same,
- since the function which calls this function (in QOrganizerItemId) does that check for you.
- */
-
-/*!
- \fn QOrganizerItemEngineId::managerUri() const
- Returns the manager URI of the constructed manager which created
- the id. If the item which the id identifies has not been deleted,
- the id should still be valid in the manager identified by the
- manager URI returned by this function.
- */
-
-/*!
- \fn QOrganizerItemEngineId::toString() const
- Serializes the id to a string. It contains all of the information
- required to identify a particular item in the manager which created
- the id, formatted according to the serialization format of the
- manager.
- */
-
-/*!
- \fn QOrganizerItemEngineId::clone() const
- Returns a deep-copy clone of this id.
- The caller takes ownership of the returned engine item id.
- */
-
-/*!
- \fn QOrganizerItemEngineId::debugStreamOut(QDebug& dbg) const
- Streams this id out to the debug stream \a dbg.
- */
-
-/*!
- \fn QOrganizerItemEngineId::hash() const
- Returns the hash value of this id.
- */
-
-QT_END_NAMESPACE_ORGANIZER
diff --git a/src/organizer/qorganizeritemengineid.h b/src/organizer/qorganizeritemengineid.h
deleted file mode 100644
index 51b880887..000000000
--- a/src/organizer/qorganizeritemengineid.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtOrganizer module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QORGANIZERITEMENGINEID_H
-#define QORGANIZERITEMENGINEID_H
-
-#include <QtCore/qshareddata.h>
-#include <QtCore/qstring.h>
-
-#include <QtOrganizer/qorganizerglobal.h>
-
-QT_BEGIN_NAMESPACE_ORGANIZER
-
-class Q_ORGANIZER_EXPORT QOrganizerItemEngineId: public QSharedData
-{
-public:
- virtual ~QOrganizerItemEngineId() {}
-
- virtual bool isEqualTo(const QOrganizerItemEngineId *other) const = 0;
- virtual bool isLessThan(const QOrganizerItemEngineId *other) const = 0;
-
- virtual QString managerUri() const = 0;
-
- virtual QOrganizerItemEngineId *clone() const = 0;
-
- virtual QString toString() const = 0;
-
-#ifndef QT_NO_DEBUG_STREAM
- virtual QDebug &debugStreamOut(QDebug &dbg) const = 0;
-#endif
-
- virtual uint hash() const = 0;
-};
-
-QT_END_NAMESPACE_ORGANIZER
-
-#endif // QORGANIZERITEMENGINEID_H
diff --git a/src/organizer/qorganizeritemid.cpp b/src/organizer/qorganizeritemid.cpp
index f8df4d835..d2db0d4ee 100644
--- a/src/organizer/qorganizeritemid.cpp
+++ b/src/organizer/qorganizeritemid.cpp
@@ -48,18 +48,8 @@
#include <QtCore/qdebug.h>
#endif
-#include "qorganizeritemengineid.h"
#include "qorganizermanager_p.h"
-#if !defined(Q_CC_MWERKS)
-QT_BEGIN_NAMESPACE
-template<> QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemEngineId) *QSharedDataPointer<QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemEngineId)>::clone()
-{
- return d ? d->clone() : 0;
-}
-QT_END_NAMESPACE
-#endif
-
QT_BEGIN_NAMESPACE_ORGANIZER
/*!
@@ -72,169 +62,95 @@ QT_BEGIN_NAMESPACE_ORGANIZER
It consists of a manager URI which identifies the manager which contains the organizer item,
and the engine specific ID of the organizer item in that manager.
- A "null" QOrganizerItemId has an empty manager URI.
- */
+ An invalid QOrganizerItemId has an empty manager URI.
+*/
/*!
- Constructs a new organizer item ID.
- */
-QOrganizerItemId::QOrganizerItemId()
- : d(0)
-{
-}
+ \fn QOrganizerItemId::QOrganizerItemId()
-/*!
- Constructs a manager-unique ID which wraps the given engine-unique item ID \a engineItemId.
- This item ID takes ownership of the engine ID and will delete it when the item ID goes out
- of scope. Engine implementors must not delete the \a engineItemId or undefined behaviour
- will occur.
- */
-QOrganizerItemId::QOrganizerItemId(QOrganizerItemEngineId *engineItemId)
- : d(engineItemId)
-{
-}
+ Constructs a new, invalid organizer item ID.
+*/
+// TODO: Document and remove internal once the correct signature has been determined
/*!
- Cleans up the memory in use by the organizer item ID.
- */
-QOrganizerItemId::~QOrganizerItemId()
-{
-}
+ \fn QOrganizerItemId::QOrganizerItemId(const QString &managerUri, const QString &localId)
+ \internal
-/*!
- Constructs a new organizer item ID as a copy of \a other.
+ Constructs an ID from the supplied manager URI \a managerUri and the engine
+ specific \a localId string.
*/
-QOrganizerItemId::QOrganizerItemId(const QOrganizerItemId &other)
- : d(other.d)
-{
-}
/*!
- Assigns the organizer item ID to be equal to \a other.
+ \fn bool QOrganizerItemId::operator==(const QOrganizerItemId &other) const
+
+ Returns true if this organizer item ID has the same manager URI and
+ engine specific ID as \a other. Returns true also, if both IDs are null.
*/
-QOrganizerItemId &QOrganizerItemId::operator=(const QOrganizerItemId &other)
-{
- d = other.d;
- return *this;
-}
/*!
- Returns true if the organizer item ID has the same manager URI and ID as \a other.
+ \fn bool QOrganizerItemId::operator!=(const QOrganizerItemId &other) const
+
+ Returns true if either the manager URI or engine specific ID of this
+ organizer item ID is different to that of \a other.
*/
-bool QOrganizerItemId::operator==(const QOrganizerItemId &other) const
-{
- if (d == other.d)
- return true;
- if (d && other.d)
- return d->managerUri() == other.d->managerUri() && d->isEqualTo(other.d);
+/*!
+ \fn bool operator<(const QOrganizerItemId &id1, const QOrganizerItemId &id2)
+ \relates QOrganizerItemId
+
+ Returns true if the organizer item ID \a id1 will be considered less than
+ the organizer item ID \a id2 if the manager URI of ID \a id1 is alphabetically
+ less than the manager URI of the \a id2 ID. If both IDs have the same
+ manager URI, ID \a id1 will be considered less than the ID \a id2
+ if the the engine specific ID of \a id1 is less than the engine specific ID of \a id2.
- return false;
-}
+ The invalid, null organizer item ID consists of an empty manager URI and a null engine ID,
+ and hence will be less than any valid, non-null organizer item ID.
+
+ This operator is provided primarily to allow use of a QOrganizerItemId as a key in a QMap.
+*/
/*!
- Returns true if either the manager URI or ID is different to that of \a other.
+ \fn uint qHash(const QOrganizerItemId &id)
+ \relates QOrganizerItemId
+
+ Returns the hash value for \a id.
*/
-bool QOrganizerItemId::operator!=(const QOrganizerItemId &other) const
-{
- return !(*this == other);
-}
/*!
- Returns true if this ID is less than the \a other ID.
+ \fn bool QOrganizerItemId::isValid() const
- This ID will be considered less than the \a other iID if the manager URI of this ID is
- alphabetically less than the manager URI of the \a other ID. If both IDs have the same
- manager URI, this ID will be considered less than the \a other ID if the engine ID of
- this ID is less than the engine ID of the \a other ID.
+ Returns true if the manager URI part is not null; returns false otherwise.
- The invalid, empty ID consists of an empty manager URI and a null engine ID, and hence will
- be less than any non-invalid ID.
+ Note that valid ID may be null at the same time, which means new organizer item.
- This operator is provided primarily to allow use of a QOrganizerItemId as a key in a QMap.
- */
-bool QOrganizerItemId::operator<(const QOrganizerItemId &other) const
-{
- if (d == 0 && other.d != 0)
- return true;
+ \sa isNull()
+*/
- if (d && other.d) {
- if (d->managerUri() == other.d->managerUri())
- return d->isLessThan(other.d);
+/*!
+ \fn bool QOrganizerItemId::isNull() const
- return d->managerUri() < other.d->managerUri();
- }
+ Returns true if the engine specific ID part is a null (default constructed);
+ returns false otherwise.
- return false;
-}
+ \sa isValid()
+*/
/*!
- \relates QOrganizerItemId
- Returns the hash value for \a key.
- */
-Q_ORGANIZER_EXPORT uint qHash(const QOrganizerItemId &key)
-{
- if (key.d)
- return key.d->hash();
- return 0;
-}
+ \fn QString QOrganizerItemId::managerUri() const
-#ifndef QT_NO_DEBUG_STREAM
-/*!
- \relates QOrganizerItemId
- Outputs \a id to the debug stream \a dbg.
- */
-Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerItemId &id)
-{
- dbg.nospace() << "QOrganizerItemId(";
- if (id.isNull())
- dbg.nospace() << "(null))";
- else
- id.d->debugStreamOut(dbg) << ")";
- return dbg.maybeSpace();
-}
-#endif
+ Returns the URI of the manager which contains the organizer item identified by this ID.
-#ifndef QT_NO_DATASTREAM
-/*!
- \relates QOrganizerItemId
- Streams \a itemId to the data stream \a out.
- */
-Q_ORGANIZER_EXPORT QDataStream &operator<<(QDataStream &out, const QOrganizerItemId &itemId)
-{
- out << (itemId.toString());
- return out;
-}
+ \sa localId()
+*/
/*!
- \relates QOrganizerItemId
- Streams \a itemId in from the data stream \a in.
- */
-Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerItemId &itemId)
-{
- QString idString;
- in >> idString;
- itemId = QOrganizerItemId::fromString(idString);
- return in;
-}
-#endif
+ \fn QString QOrganizerItemId::localId() const
-/*!
- Returns true if the engine ID part is a null (default constructed) engine ID; otherwise,
- returns false.
- */
-bool QOrganizerItemId::isNull() const
-{
- return d == 0;
-}
+ Returns the organizer item's engine specific ID part.
-/*!
- Returns the URI of the manager which contains the organizer item identified by this ID.
- */
-QString QOrganizerItemId::managerUri() const
-{
- return d ? d->managerUri() : QString();
-}
+ \sa managerUri()
+*/
/*!
Serializes the organizer item ID to a string. The format of the string will be:
@@ -244,35 +160,63 @@ QString QOrganizerItemId::managerUri() const
*/
QString QOrganizerItemId::toString() const
{
- QString managerName;
- QMap<QString, QString> params;
- QString engineIdString;
+ if (QOrganizerManagerData::parseIdString(m_managerUri, 0, 0))
+ return QOrganizerManagerData::buildIdString(m_managerUri, m_localId);
- // rely on engine id to supply the full manager uri
- if (d && QOrganizerManagerData::parseIdString(d->managerUri(), &managerName, &params))
- engineIdString = d->toString();
-
- return QOrganizerManagerData::buildIdString(managerName, params, &engineIdString);
+ return QOrganizerManagerData::buildIdString(QString(), QMap<QString, QString>(), QStringLiteral(""));
}
/*!
Deserializes the given \a idString. Returns a default-constructed (null)
- organizer item ID if the given \a idString is not a valid, serialized organizer item ID,
- or if the manager engine from which the ID came could not be found.
+ organizer item ID if the given \a idString is not a valid, serialized organizer item ID.
\sa toString()
*/
QOrganizerItemId QOrganizerItemId::fromString(const QString &idString)
{
- QString managerName;
- QMap<QString, QString> params;
+ QString managerUri;
QString engineIdString;
- if (!QOrganizerManagerData::parseIdString(idString, &managerName, &params, &engineIdString))
- return QOrganizerItemId(); // invalid idString given.
+ if (QOrganizerManagerData::parseIdString(idString, 0, 0, &managerUri, &engineIdString))
+ return QOrganizerItemId(managerUri, engineIdString);
+
+ return QOrganizerItemId();
+}
- QOrganizerItemEngineId *engineId = QOrganizerManagerData::createEngineItemId(managerName, params, engineIdString);
- return QOrganizerItemId(engineId);
+#ifndef QT_NO_DEBUG_STREAM
+/*!
+ \relates QOrganizerItemId
+ Outputs \a id to the debug stream \a dbg.
+*/
+Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerItemId &id)
+{
+ dbg.nospace() << "QOrganizerItemId(" << id.toString() << ")";
+ return dbg.maybeSpace();
+}
+#endif // QT_NO_DEBUG_STREAM
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \relates QOrganizerItemId
+ Streams \a id to the data stream \a out.
+*/
+Q_ORGANIZER_EXPORT QDataStream &operator<<(QDataStream &out, const QOrganizerItemId &id)
+{
+ out << id.toString();
+ return out;
+}
+
+/*!
+ \relates QOrganizerItemId
+ Streams \a id in from the data stream \a in.
+*/
+Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerItemId &id)
+{
+ QString idString;
+ in >> idString;
+ id = QOrganizerItemId::fromString(idString);
+ return in;
}
+#endif // QT_NO_DATASTREAM
QT_END_NAMESPACE_ORGANIZER
diff --git a/src/organizer/qorganizeritemid.h b/src/organizer/qorganizeritemid.h
index cf419cb4b..36a594f61 100644
--- a/src/organizer/qorganizeritemid.h
+++ b/src/organizer/qorganizeritemid.h
@@ -42,7 +42,6 @@
#ifndef QORGANIZERITEMID_H
#define QORGANIZERITEMID_H
-#include <QtCore/qshareddata.h>
#include <QtCore/qvariant.h>
#include <QtOrganizer/qorganizerglobal.h>
@@ -51,47 +50,47 @@ QT_BEGIN_NAMESPACE_ORGANIZER
class QOrganizerManagerEngine;
-class QOrganizerItemEngineId;
class Q_ORGANIZER_EXPORT QOrganizerItemId
{
public:
- QOrganizerItemId();
- QOrganizerItemId(const QOrganizerItemId &other);
- explicit QOrganizerItemId(QOrganizerItemEngineId *engineId);
- ~QOrganizerItemId();
+ inline QOrganizerItemId() {}
+ inline QOrganizerItemId(const QString &managerUri, const QString &localId)
+ : m_managerUri(managerUri), m_localId(localId)
+ {}
+ // compiler-generated dtor and copy/move ctors/assignment operators are fine!
- QOrganizerItemId &operator=(const QOrganizerItemId &other);
+ inline bool operator==(const QOrganizerItemId &other) const
+ { return localId() == other.localId() && managerUri() == other.managerUri(); }
+ inline bool operator!=(const QOrganizerItemId &other) const
+ { return localId() != other.localId() || managerUri() != other.managerUri(); }
- bool operator==(const QOrganizerItemId &other) const;
- bool operator!=(const QOrganizerItemId &other) const;
- bool operator<(const QOrganizerItemId &other) const;
+ inline bool isValid() const { return !m_managerUri.isEmpty(); }
+ inline bool isNull() const { return m_localId.isEmpty(); }
- bool isNull() const;
-
- QString managerUri() const;
+ inline QString managerUri() const { return m_managerUri; }
+ inline QString localId() const { return m_localId; }
QString toString() const;
static QOrganizerItemId fromString(const QString &idString);
private:
- QSharedDataPointer<QOrganizerItemEngineId> d;
-
-#ifndef QT_NO_DEBUG_STREAM
- friend Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerItemId &itemId);
-#endif
- friend Q_ORGANIZER_EXPORT uint qHash(const QOrganizerItemId &key);
- friend class QOrganizerManagerEngine;
+ QString m_managerUri;
+ QString m_localId;
};
-Q_ORGANIZER_EXPORT uint qHash(const QOrganizerItemId &key);
+inline bool operator<(const QOrganizerItemId &id1, const QOrganizerItemId &id2)
+{ return (id1.managerUri() != id2.managerUri()) ? id1.managerUri() < id2.managerUri() : id1.localId() < id2.localId(); }
+
+inline uint qHash(const QOrganizerItemId &id)
+{ return qHash(id.localId()); }
#ifndef QT_NO_DATASTREAM
-Q_ORGANIZER_EXPORT QDataStream &operator<<(QDataStream &out, const QOrganizerItemId &itemId);
-Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerItemId &itemId);
+Q_ORGANIZER_EXPORT QDataStream &operator<<(QDataStream &out, const QOrganizerItemId &id);
+Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerItemId &id);
#endif
#ifndef QT_NO_DEBUG_STREAM
-Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerItemId &itemId);
+Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerItemId &id);
#endif
QT_END_NAMESPACE_ORGANIZER
@@ -100,6 +99,6 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemId), Q_MOVABLE_TYPE);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemId));
+Q_DECLARE_METATYPE(QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemId))
#endif // QORGANIZERITEMID_H
diff --git a/src/organizer/qorganizermanager_p.cpp b/src/organizer/qorganizermanager_p.cpp
index 3816f5bf5..8851d9a2f 100644
--- a/src/organizer/qorganizermanager_p.cpp
+++ b/src/organizer/qorganizermanager_p.cpp
@@ -195,22 +195,6 @@ void QOrganizerManagerData::loadFactories()
}
}
-QOrganizerItemEngineId *QOrganizerManagerData::createEngineItemId(const QString &managerName, const QMap<QString, QString> &parameters, const QString &engineIdString)
-{
- // caller takes ownership of the ID
- loadFactories();
- QOrganizerManagerEngineFactory *engineFactory = m_engines.value(managerName);
- return engineFactory ? engineFactory->createItemEngineId(parameters, engineIdString) : NULL;
-}
-
-QOrganizerCollectionEngineId *QOrganizerManagerData::createEngineCollectionId(const QString &managerName, const QMap<QString, QString> &parameters, const QString &engineIdString)
-{
- // caller takes ownership of the ID
- loadFactories();
- QOrganizerManagerEngineFactory *engineFactory = m_engines.value(managerName);
- return engineFactory ? engineFactory->createCollectionEngineId(parameters, engineIdString) : NULL;
-}
-
void QOrganizerManagerData::registerObserver(QOrganizerItemObserver *observer)
{
m_observerForItem.insert(observer->itemId(), observer);
@@ -290,10 +274,10 @@ static inline QString unescapeParam(const QString &param)
/*!
Parses the individual components of the given \a idString and fills the
- \a managerName, \a params and \a engineIdString.
+ \a managerName, \a params, \a managerUri and \a engineIdString.
Returns true if the parts could be parsed successfully, false otherwise.
*/
-bool QOrganizerManagerData::parseIdString(const QString &idString, QString *managerName, QMap<QString, QString> *params, QString *engineIdString)
+bool QOrganizerManagerData::parseIdString(const QString &idString, QString *managerName, QMap<QString, QString> *params, QString *managerUri, QString *engineIdString)
{
// Format: qtorganizer:<managerid>:<key>=<value>&<key>=<value>:<engineIdString>
// we assume that the prefix, managerid, params, and engineIdString cannot contain `:', `=', or `&'
@@ -304,7 +288,7 @@ bool QOrganizerManagerData::parseIdString(const QString &idString, QString *mana
return false;
const QString prefix = colonSplit.at(0);
- const QString mgrName = colonSplit.at(1).trimmed();
+ const QString mgrName = colonSplit.at(1);
const QString paramString = colonSplit.value(2);
if (prefix != QStringLiteral("qtorganizer") || mgrName.isEmpty())
@@ -339,6 +323,9 @@ bool QOrganizerManagerData::parseIdString(const QString &idString, QString *mana
if (managerName)
*managerName = unescapeParam(mgrName);
+ if (managerUri)
+ *managerUri = prefix + QLatin1Char(':') + mgrName + QLatin1Char(':') + paramString;
+
// and unescape the engine id string
if (engineIdString)
*engineIdString = unescapeParam(colonSplit.at(3));
@@ -347,12 +334,26 @@ bool QOrganizerManagerData::parseIdString(const QString &idString, QString *mana
}
/*!
+ Returns an ID string that describes a manager name and parameters with which to instantiate
+ a manager object, from the given \a managerUri.
+ If \a engineIdString is non-null, the generated ID string is suitable for
+ passing to QOrganizerCollectionId::fromString() or QOrganizerItemId::fromString().
+*/
+QString QOrganizerManagerData::buildIdString(const QString &managerUri, const QString &engineIdString)
+{
+ if (!engineIdString.isNull())
+ return managerUri + QLatin1Char(':') + escapeParam(engineIdString);
+
+ return managerUri;
+}
+
+/*!
Returns a ID string that describes a manager name and parameters with which to instantiate
a manager object, from the given \a managerName and \a params.
- If \a engineIdString is not null, the generated ID string is suitable for
+ If \a engineIdString is non-null, the generated ID string is suitable for
passing to QOrganizerCollectionId::fromString() or QOrganizerItemId::fromString().
*/
-QString QOrganizerManagerData::buildIdString(const QString &managerName, const QMap<QString, QString> &params, QString *engineIdString)
+QString QOrganizerManagerData::buildIdString(const QString &managerName, const QMap<QString, QString> &params, const QString &engineIdString)
{
// Format: qtorganizer:<managerid>:<key>=<value>&<key>=<value>:<engineIdString>
// if the prefix, managerid, param keys, param values, or engineIdString contain `:', `=', or `&',
@@ -371,8 +372,8 @@ QString QOrganizerManagerData::buildIdString(const QString &managerName, const Q
}
idString = QStringLiteral("qtorganizer:") + escapeParam(managerName) + QLatin1Char(':') + idString;
- if (engineIdString)
- idString += QLatin1Char(':') + escapeParam(*engineIdString);
+ if (!engineIdString.isNull())
+ idString += QLatin1Char(':') + escapeParam(engineIdString);
return idString;
}
diff --git a/src/organizer/qorganizermanager_p.h b/src/organizer/qorganizermanager_p.h
index 77c217476..80e1a098d 100644
--- a/src/organizer/qorganizermanager_p.h
+++ b/src/organizer/qorganizermanager_p.h
@@ -63,10 +63,8 @@
QT_BEGIN_NAMESPACE_ORGANIZER
-class QOrganizerCollectionEngineId;
class QOrganizerItemObserver;
class QOrganizerManagerEngineFactory;
-class QOrganizerItemEngineId;
class QOrganizerManagerData
{
@@ -82,14 +80,14 @@ public:
}
// helpers
- static bool parseIdString(const QString &idString, QString *managerName, QMap<QString, QString> *params, QString *engineIdString = 0);
- static QString buildIdString(const QString &managerName, const QMap<QString, QString> &params, QString *engineIdString = 0);
+ static bool parseIdString(const QString &idString, QString *managerName, QMap<QString, QString> *params, QString *managerUri = 0, QString *engineIdString = 0);
+
+ static QString buildIdString(const QString &managerUri, const QString &engineIdString = QString());
+ static QString buildIdString(const QString &managerName, const QMap<QString, QString> &params, const QString &engineIdString = QString());
void createEngine(const QString &managerName, const QMap<QString, QString> &parameters);
static QOrganizerManagerData *get(const QOrganizerManager *manager);
static QOrganizerManagerEngine *engine(const QOrganizerManager *manager);
- static QOrganizerItemEngineId *createEngineItemId(const QString &managerName, const QMap<QString, QString> &parameters, const QString &engineIdString);
- static QOrganizerCollectionEngineId *createEngineCollectionId(const QString &managerName, const QMap<QString, QString> &parameters, const QString &engineIdString);
QOrganizerManagerEngine *m_engine;
QOrganizerManager::Error m_lastError;
diff --git a/src/organizer/qorganizermanagerengine.cpp b/src/organizer/qorganizermanagerengine.cpp
index 92b44fe00..eb54532e3 100644
--- a/src/organizer/qorganizermanagerengine.cpp
+++ b/src/organizer/qorganizermanagerengine.cpp
@@ -202,10 +202,9 @@ QString QOrganizerManagerEngine::managerName() const
}
/*!
- This function should be reimplemented to return the parameters used in when constructing this
- backend. The default implementation returns an empty QMap.
-
- If certain paramters are invalid, or discarded by the backend, they should not be returned.
+ Returns the parameters with which this engine was constructed. Note that
+ the engine may have discarded unused or invalid parameters at the time of
+ construction, and these will not be returned.
*/
QMap<QString, QString> QOrganizerManagerEngine::managerParameters() const
{
@@ -213,15 +212,48 @@ QMap<QString, QString> QOrganizerManagerEngine::managerParameters() const
}
/*!
- Returns the unique URI of this manager, which is built from the manager name and the parameters
- used to construct it.
+ Returns the subset of the manager parameters that are relevant when interpreting
+ contact ID values. Since contact ID comparison involves equivalence of
+ managerUri values, parameters that do not differentiate contact IDs should not
+ be returned by this function.
+
+ For example, a manager engine may support 'user' and 'cachesize' parameters,
+ where the former distinguishes between separate user domains, and the latter
+ is for performance tuning. The 'user' parameter will be relevant to the interpretation
+ of contact IDs and thus should be returned by this function, whereas 'cachesize'
+ is not relevant and should be omitted.
+
+ \sa managerUri(), managerParamaters()
*/
-QString QOrganizerManagerEngine::managerUri() const
+QMap<QString, QString> QOrganizerManagerEngine::idInterpretationParameters() const
{
- return QOrganizerManager::buildUri(managerName(), managerParameters());
+ return QMap<QString, QString>(); // default implementation returns no parameters.
}
/*!
+ \fn QString QOrganizerManagerEngine::managerUri() const
+
+ Returns the unique URI of this manager, which is built from the manager name and the
+ ID interpretation parameters used to construct it.
+
+ \sa idInterpretationParameters()
+ */
+
+/*!
+ \fn QOrganizerItemId QOrganizerManagerEngine::itemId(const QString &localId) const
+
+ Returns the organizer item ID for this managerUri() and the given
+ engine specific ID part \a localId.
+*/
+
+/*!
+ \fn QOrganizerCollectionId QOrganizerManagerEngine::collectionId(const QString &localId) const
+
+ Returns the organizer collection ID for this managerUri() and the given
+ engine specific ID part \a localId.
+*/
+
+/*!
This function should be reimplemented to support synchronous calls to fetch occurrences of the
given parent item.
@@ -1658,31 +1690,6 @@ bool QOrganizerManagerEngine::itemHasReccurence(const QOrganizerItem& oi)
return false;
}
-
-
-
-/*!
- Returns the engine ID from the given item \a id.
-
- The caller does not take ownership of the pointer, and should not delete returned id or undefined
- behavior may occur.
- */
-const QOrganizerItemEngineId *QOrganizerManagerEngine::engineItemId(const QOrganizerItemId &id)
-{
- return id.d.data();
-}
-
-/*!
- Returns the engine ID from the given collection \a id.
-
- The caller does not take ownership of the pointer, and should not delete returned id or undefined
- behavior may occur.
- */
-const QOrganizerCollectionEngineId* QOrganizerManagerEngine::engineCollectionId(const QOrganizerCollectionId& id)
-{
- return id.d.data();
-}
-
/*!
This function is called when the given \a request has been destroyed by the client.
diff --git a/src/organizer/qorganizermanagerengine.h b/src/organizer/qorganizermanagerengine.h
index 43e52030c..6d4a82509 100644
--- a/src/organizer/qorganizermanagerengine.h
+++ b/src/organizer/qorganizermanagerengine.h
@@ -69,7 +69,15 @@ public:
virtual QString managerName() const;
virtual QMap<QString, QString> managerParameters() const;
- QString managerUri() const;
+ virtual QMap<QString, QString> idInterpretationParameters() const;
+
+ inline QString managerUri() const
+ { return QOrganizerManager::buildUri(managerName(), idInterpretationParameters()); }
+
+ inline QOrganizerItemId itemId(const QString &localId) const
+ { return QOrganizerItemId(managerUri(), localId); }
+ inline QOrganizerCollectionId collectionId(const QString &localId) const
+ { return QOrganizerCollectionId(managerUri(), localId); }
// items
virtual QList<QOrganizerItem> items(const QList<QOrganizerItemId> &itemIds, const QOrganizerItemFetchHint &fetchHint,
@@ -157,9 +165,6 @@ public:
virtual QList<QOrganizerItemType::ItemType> supportedItemTypes() const;
// helper
- static const QOrganizerItemEngineId *engineItemId(const QOrganizerItemId &itemId);
- static const QOrganizerCollectionEngineId *engineCollectionId(const QOrganizerCollectionId &collectionId);
-
static int addSorted(QList<QOrganizerItem> *sorted, const QOrganizerItem &toAdd, const QList<QOrganizerItemSortOrder> &sortOrders);
static bool addDefaultSorted(QMultiMap<QDateTime, QOrganizerItem> *defaultSorted, const QOrganizerItem &toAdd);
static int compareItem(const QOrganizerItem &a, const QOrganizerItem &b, const QList<QOrganizerItemSortOrder> &sortOrders);
diff --git a/src/organizer/qorganizermanagerenginefactory.cpp b/src/organizer/qorganizermanagerenginefactory.cpp
index 21d087c01..08b5b43b8 100644
--- a/src/organizer/qorganizermanagerenginefactory.cpp
+++ b/src/organizer/qorganizermanagerenginefactory.cpp
@@ -88,21 +88,6 @@ QOrganizerManagerEngineFactory::~QOrganizerManagerEngineFactory()
*/
/*!
- \fn QOrganizerManagerEngineFactory::createItemEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const
-
- This function should return an engine-specific item ID, according to the given \a parameters and
- the \a engineIdString.
- */
-
-/*!
- \fn QOrganizerManagerEngineFactory::createCollectionEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const
-
-
- This function should return an engine-specific collection ID, according to the given \a parameters
- and the \a engineIdString.
- */
-
-/*!
\internal
*/
QStringList QOrganizerManagerEngineFactory::keys() const
diff --git a/src/organizer/qorganizermanagerenginefactory.h b/src/organizer/qorganizermanagerenginefactory.h
index 6781c915d..5449c77fc 100644
--- a/src/organizer/qorganizermanagerenginefactory.h
+++ b/src/organizer/qorganizermanagerenginefactory.h
@@ -52,8 +52,6 @@ struct Q_ORGANIZER_EXPORT QOrganizerManagerEngineFactoryInterface : public QFact
{
virtual QOrganizerManagerEngine *engine(const QMap<QString, QString> &parameters, QOrganizerManager::Error *error) = 0;
virtual QString managerName() const = 0;
- virtual QOrganizerItemEngineId *createItemEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const = 0;
- virtual QOrganizerCollectionEngineId *createCollectionEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const = 0;
};
QT_END_NAMESPACE_ORGANIZER
@@ -72,8 +70,6 @@ public:
virtual ~QOrganizerManagerEngineFactory();
virtual QOrganizerManagerEngine *engine(const QMap<QString, QString> &parameters, QOrganizerManager::Error *error) = 0;
virtual QString managerName() const = 0;
- virtual QOrganizerItemEngineId *createItemEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const = 0;
- virtual QOrganizerCollectionEngineId *createCollectionEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const = 0;
QStringList keys() const;
};
diff --git a/src/plugins/contacts/memory/qcontactmemorybackend.cpp b/src/plugins/contacts/memory/qcontactmemorybackend.cpp
index fb29aac17..ed13f27cb 100644
--- a/src/plugins/contacts/memory/qcontactmemorybackend.cpp
+++ b/src/plugins/contacts/memory/qcontactmemorybackend.cpp
@@ -62,14 +62,6 @@ QContactManagerEngine* QContactMemoryEngineFactory::engine(const QMap<QString, Q
return ret;
}
-
-QContactEngineId* QContactMemoryEngineFactory::createContactEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const
-{
- Q_UNUSED(parameters);
- QContactMemoryEngineId *retn = new QContactMemoryEngineId(parameters, engineIdString);
- return retn;
-}
-
QString QContactMemoryEngineFactory::managerName() const
{
return QString::fromLatin1("memory");
@@ -168,6 +160,13 @@ QMap<QString, QString> QContactMemoryEngine::managerParameters() const
return params;
}
+/*! \reimp
+*/
+QMap<QString, QString> QContactMemoryEngine::idInterpretationParameters() const
+{
+ return managerParameters();
+}
+
/*! \reimp */
bool QContactMemoryEngine::setSelfContactId(const QContactId &contactId, QContactManager::Error *error)
{
@@ -909,111 +908,20 @@ bool QContactMemoryEngine::saveContact(QContact *theContact, QContactChangeSet &
theContact->saveDetail(&ts);
// update the contact item - set its ID
- quint32 nextContactId = d->m_nextContactId; // don't increment the persistent version until we're successful or we know it collides.
- nextContactId += 1; // but do increment the temporary version to check for collision
- QContactMemoryEngineId *newMemoryEngineId = new QContactMemoryEngineId;
- newMemoryEngineId->m_contactId = nextContactId;
- newMemoryEngineId->m_managerUri = d->m_managerUri;
- QContactId newContactId = QContactId(newMemoryEngineId);
+ QContactId newContactId = contactId(QString::number(d->m_nextContactId++));
theContact->setId(newContactId);
- // note: do NOT delete the QContactMemoryEngineId -- the QContactId ctor takes ownership of it.
-
-
// finally, add the contact to our internal lists and return
d->m_contacts.append(*theContact); // add contact to list
d->m_contactIds.append(theContact->id()); // track the contact id.
changeSet.insertAddedContact(theContact->id());
- // successful, now increment the persistent version of the next item id.
- d->m_nextContactId += 1;
}
*error = QContactManager::NoError; // successful.
return true;
}
-/*!
- \class QContactMemoryEngineId
- \brief The QContactMemoryEngineId class provides an id which uniquely identifies
- a QContact stored within a QContactMemoryEngine.
-
- \internal
- It may be used as a reference implementation, although since different platforms
- have different semantics for ids
- the precise implementation required may differ.
- */
-QContactMemoryEngineId::QContactMemoryEngineId()
- : QContactEngineId(), m_contactId(0)
-{
-}
-
-QContactMemoryEngineId::QContactMemoryEngineId(quint32 contactId, const QString &managerUri)
- : QContactEngineId(), m_contactId(contactId), m_managerUri(managerUri)
-{
-}
-
-QContactMemoryEngineId::~QContactMemoryEngineId()
-{
-}
-
-QContactMemoryEngineId::QContactMemoryEngineId(const QContactMemoryEngineId &other)
- : QContactEngineId(), m_contactId(other.m_contactId), m_managerUri(other.m_managerUri)
-{
-}
-
-QContactMemoryEngineId::QContactMemoryEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString)
- : QContactEngineId()
-{
- m_contactId = engineIdString.toInt();
- m_managerUri = QContactManager::buildUri("memory", parameters);
-}
-
-bool QContactMemoryEngineId::isEqualTo(const QContactEngineId *other) const
-{
- if (m_contactId != static_cast<const QContactMemoryEngineId*>(other)->m_contactId)
- return false;
- return true;
-}
-
-bool QContactMemoryEngineId::isLessThan(const QContactEngineId *other) const
-{
- const QContactMemoryEngineId *otherPtr = static_cast<const QContactMemoryEngineId*>(other);
- if (m_managerUri < otherPtr->m_managerUri)
- return true;
- if (m_contactId < otherPtr->m_contactId)
- return true;
- return false;
-}
-
-QString QContactMemoryEngineId::managerUri() const
-{
- return m_managerUri;
-}
-
-QString QContactMemoryEngineId::toString() const
-{
- return QString::number(m_contactId);
-}
-
-QContactEngineId* QContactMemoryEngineId::clone() const
-{
- return new QContactMemoryEngineId(m_contactId, m_managerUri);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug& QContactMemoryEngineId::debugStreamOut(QDebug &dbg) const
-{
- dbg.nospace() << "QContactMemoryEngineId(" << m_managerUri << "," << m_contactId << ")";
- return dbg.maybeSpace();
-}
-#endif
-
-uint QContactMemoryEngineId::hash() const
-{
- return m_contactId;
-}
-
#include "moc_qcontactmemorybackend_p.cpp"
QT_END_NAMESPACE_CONTACTS
diff --git a/src/plugins/contacts/memory/qcontactmemorybackend_p.h b/src/plugins/contacts/memory/qcontactmemorybackend_p.h
index e3a76c80c..7c44d7d3f 100644
--- a/src/plugins/contacts/memory/qcontactmemorybackend_p.h
+++ b/src/plugins/contacts/memory/qcontactmemorybackend_p.h
@@ -58,7 +58,6 @@
#include <QtContacts/qcontactmanager.h>
#include <QtContacts/qcontactmanagerengine.h>
#include <QtContacts/qcontactchangeset.h>
-#include <QtContacts/qcontactengineid.h>
#include <QtContacts/qcontactmanagerenginefactory.h>
QT_BEGIN_NAMESPACE_CONTACTS
@@ -72,7 +71,6 @@ class QContactMemoryEngineFactory : public QContactManagerEngineFactory
public:
QContactManagerEngine* engine(const QMap<QString, QString> &parameters, QContactManager::Error*);
QString managerName() const;
- QContactEngineId* createContactEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const;
};
class QContactMemoryEngineData : public QSharedData
@@ -126,35 +124,6 @@ public:
};
-class QContactMemoryEngineId : public QContactEngineId
-{
-public:
- QContactMemoryEngineId();
- ~QContactMemoryEngineId();
- QContactMemoryEngineId(quint32 contactId, const QString &managerUri);
- QContactMemoryEngineId(const QContactMemoryEngineId &other);
- QContactMemoryEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString);
-
- bool isEqualTo(const QContactEngineId *other) const;
- bool isLessThan(const QContactEngineId *other) const;
-
- QString managerUri() const;
-
- QContactEngineId* clone() const;
-
- QString toString() const;
-
-#ifndef QT_NO_DEBUG_STREAM
- QDebug& debugStreamOut(QDebug &dbg) const;
-#endif
- uint hash() const;
-
-private:
- quint32 m_contactId;
- QString m_managerUri;
- friend class QContactMemoryEngine;
-};
-
class QContactMemoryEngine : public QContactManagerEngine
{
Q_OBJECT
@@ -167,6 +136,8 @@ public:
/* URI reporting */
QString managerName() const;
QMap<QString, QString> managerParameters() const;
+ QMap<QString, QString> idInterpretationParameters() const;
+
/*! \reimp */
int managerVersion() const {return 1;}
diff --git a/src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp b/src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp
index f1d27e38f..622f46d2b 100644
--- a/src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp
+++ b/src/plugins/organizer/memory/qorganizeritemmemorybackend.cpp
@@ -63,20 +63,6 @@ QOrganizerManagerEngine* QOrganizerItemMemoryFactory::engine(const QMap<QString,
return ret;
}
-QOrganizerItemEngineId* QOrganizerItemMemoryFactory::createItemEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
-{
- Q_UNUSED(parameters);
- QOrganizerItemMemoryEngineId *retn = new QOrganizerItemMemoryEngineId(idString);
- return retn;
-}
-
-QOrganizerCollectionEngineId* QOrganizerItemMemoryFactory::createCollectionEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
-{
- Q_UNUSED(parameters);
- QOrganizerCollectionMemoryEngineId *retn = new QOrganizerCollectionMemoryEngineId(idString);
- return retn;
-}
-
QString QOrganizerItemMemoryFactory::managerName() const
{
return QString::fromLatin1("memory");
@@ -102,192 +88,6 @@ QString QOrganizerItemMemoryFactory::managerName() const
no longer requires this engine.
*/
-
-/*!
- \class QOrganizerItemMemoryEngineId
- \brief The QOrganizerItemMemoryEngineId class provides an id which uniquely identifies
- a QOrganizerItem stored within a collection stored within a a QOrganizerItemMemoryEngine.
-
- \internal
- It may be used as a reference implementation, although since different platforms
- have different semantics for ids (datastore-unique versus calendar-unique, etc),
- the precise implementation required may differ.
- */
-QOrganizerItemMemoryEngineId::QOrganizerItemMemoryEngineId()
- : QOrganizerItemEngineId(), m_collectionId(0), m_itemId(0)
-{
-}
-
-QOrganizerItemMemoryEngineId::QOrganizerItemMemoryEngineId(quint32 collectionId, quint32 itemId, const QString& managerUri)
- : QOrganizerItemEngineId(), m_collectionId(collectionId), m_itemId(itemId), m_managerUri(managerUri)
-{
-}
-
-QOrganizerItemMemoryEngineId::~QOrganizerItemMemoryEngineId()
-{
-}
-
-QOrganizerItemMemoryEngineId::QOrganizerItemMemoryEngineId(const QOrganizerItemMemoryEngineId& other)
- : QOrganizerItemEngineId(), m_collectionId(other.m_collectionId), m_itemId(other.m_itemId), m_managerUri(other.m_managerUri)
-{
-}
-
-QOrganizerItemMemoryEngineId::QOrganizerItemMemoryEngineId(const QString& idString)
- : QOrganizerItemEngineId()
-{
- int temp = 0;
- int colonIndex = idString.indexOf(QStringLiteral(":"), 0);
- m_collectionId = idString.mid(temp, colonIndex).toUInt();
- temp = colonIndex + 1;
- colonIndex = idString.indexOf(QStringLiteral(":"), temp);
- m_itemId = idString.mid(temp, (colonIndex-temp)).toUInt();
- temp = colonIndex + 1;
- m_managerUri = idString.mid(temp);
-}
-
-bool QOrganizerItemMemoryEngineId::isEqualTo(const QOrganizerItemEngineId* other) const
-{
- // note: we don't need to check the collectionId because itemIds in the memory
- // engine are unique regardless of which collection the item is in; also, we
- // don't need to check the managerUri, because this function is not called if
- // the managerUris don't match.
- if (m_itemId != static_cast<const QOrganizerItemMemoryEngineId*>(other)->m_itemId)
- return false;
- return true;
-}
-
-bool QOrganizerItemMemoryEngineId::isLessThan(const QOrganizerItemEngineId* other) const
-{
- // order by collection, then by item in collection.
- const QOrganizerItemMemoryEngineId* otherPtr = static_cast<const QOrganizerItemMemoryEngineId*>(other);
- if (m_managerUri < otherPtr->m_managerUri)
- return true;
- if (m_collectionId < otherPtr->m_collectionId)
- return true;
- if (m_collectionId == otherPtr->m_collectionId)
- return (m_itemId < otherPtr->m_itemId);
- return false;
-}
-
-QString QOrganizerItemMemoryEngineId::managerUri() const
-{
- return m_managerUri;
-}
-
-QString QOrganizerItemMemoryEngineId::toString() const
-{
- return (QString::number(m_collectionId) % QLatin1Char(':') % QString::number(m_itemId) % QLatin1Char(':') % m_managerUri);
-}
-
-QOrganizerItemEngineId* QOrganizerItemMemoryEngineId::clone() const
-{
- return new QOrganizerItemMemoryEngineId(m_collectionId, m_itemId, m_managerUri);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug& QOrganizerItemMemoryEngineId::debugStreamOut(QDebug& dbg) const
-{
- dbg.nospace() << "QOrganizerItemMemoryEngineId(" << m_collectionId << ", " << m_itemId << "," << m_managerUri << ")";
- return dbg.maybeSpace();
-}
-#endif
-
-uint QOrganizerItemMemoryEngineId::hash() const
-{
- // Note: doesn't need to be unique, since == ensures difference.
- // Hash function merely determines distribution in a hash table.
- // We certainly don't want to qHash(managerUri) since that's slow.
- // We don't need anything other than itemId in the memory engine,
- // since it's unique across collections.
- return m_itemId;
-}
-
-/*!
- \class QOrganizerCollectionMemoryEngineId
- \brief The QOrganizerCollectionMemoryEngineId class provides an id which uniquely identifies
- a QOrganizerCollection stored within a collection stored within a a QOrganizerCollectionMemoryEngine.
- \internal
-
- It may be used as a reference implementation, although since different platforms
- have different semantics for ids (datastore-unique versus calendar-unique, etc),
- the precise implementation required may differ.
- */
-QOrganizerCollectionMemoryEngineId::QOrganizerCollectionMemoryEngineId()
- : QOrganizerCollectionEngineId(), m_collectionId(0)
-{
-}
-
-QOrganizerCollectionMemoryEngineId::QOrganizerCollectionMemoryEngineId(quint32 collectionId, const QString& managerUri)
- : QOrganizerCollectionEngineId(), m_collectionId(collectionId), m_managerUri(managerUri)
-{
-}
-
-QOrganizerCollectionMemoryEngineId::QOrganizerCollectionMemoryEngineId(const QOrganizerCollectionMemoryEngineId& other)
- : QOrganizerCollectionEngineId(), m_collectionId(other.m_collectionId)
-{
-}
-
-QOrganizerCollectionMemoryEngineId::QOrganizerCollectionMemoryEngineId(const QString& idString)
- : QOrganizerCollectionEngineId()
-{
- int colonIndex = idString.indexOf(QStringLiteral(":"));
- m_collectionId = idString.mid(0, colonIndex).toUInt();
- m_managerUri = idString.mid(colonIndex+1);
-}
-
-QOrganizerCollectionMemoryEngineId::~QOrganizerCollectionMemoryEngineId()
-{
-}
-
-bool QOrganizerCollectionMemoryEngineId::isEqualTo(const QOrganizerCollectionEngineId* other) const
-{
- // note: we don't need to check the managerUri because this function is not called
- // if the managerUris are different.
- if (m_collectionId != static_cast<const QOrganizerCollectionMemoryEngineId*>(other)->m_collectionId)
- return false;
- return true;
-}
-
-bool QOrganizerCollectionMemoryEngineId::isLessThan(const QOrganizerCollectionEngineId* other) const
-{
- // order by collection, then by item in collection.
- const QOrganizerCollectionMemoryEngineId* otherPtr = static_cast<const QOrganizerCollectionMemoryEngineId*>(other);
- if (m_managerUri < otherPtr->m_managerUri)
- return true;
- if (m_collectionId < otherPtr->m_collectionId)
- return true;
- return false;
-}
-
-QString QOrganizerCollectionMemoryEngineId::managerUri() const
-{
- return m_managerUri;
-}
-
-QString QOrganizerCollectionMemoryEngineId::toString() const
-{
- return (QString::number(m_collectionId) % QLatin1Char(':') % m_managerUri);
-}
-
-QOrganizerCollectionEngineId* QOrganizerCollectionMemoryEngineId::clone() const
-{
- return new QOrganizerCollectionMemoryEngineId(m_collectionId, m_managerUri);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug& QOrganizerCollectionMemoryEngineId::debugStreamOut(QDebug& dbg) const
-{
- dbg.nospace() << "QOrganizerCollectionMemoryEngineId(" << m_collectionId << "," << m_managerUri << ")";
- return dbg.maybeSpace();
-}
-#endif
-
-uint QOrganizerCollectionMemoryEngineId::hash() const
-{
- return m_collectionId;
-}
-
-
typedef QHash<QString, QOrganizerItemMemoryEngineData *> EngineDatas;
Q_GLOBAL_STATIC(EngineDatas, theEngineDatas);
@@ -338,7 +138,7 @@ QOrganizerItemMemoryEngine::QOrganizerItemMemoryEngine(QOrganizerItemMemoryEngin
// the default collection always exists.
if (d->m_idToCollectionHash.isEmpty()) {
d->m_managerUri = managerUri();
- QOrganizerCollectionId defaultId = d->defaultCollectionId();
+ const QOrganizerCollectionId defaultId = defaultCollectionId();
QOrganizerCollection defaultCollection;
defaultCollection.setId(defaultId);
defaultCollection.setMetaData(QOrganizerCollection::KeyName, QString(QStringLiteral("Default Collection")));
@@ -376,6 +176,13 @@ QMap<QString, QString> QOrganizerItemMemoryEngine::managerParameters() const
return params;
}
+/*! \reimp
+*/
+QMap<QString, QString> QOrganizerItemMemoryEngine::idInterpretationParameters() const
+{
+ return managerParameters();
+}
+
QList<QOrganizerItem> QOrganizerItemMemoryEngine::items(const QList<QOrganizerItemId> &itemIds, const QOrganizerItemFetchHint &fetchHint,
QMap<int, QOrganizerManager::Error> *errorMap, QOrganizerManager::Error *error)
{
@@ -842,13 +649,10 @@ bool QOrganizerItemMemoryEngine::storeItem(QOrganizerItem* theOrganizerItem, QOr
// if target collection id is null, set to default id.
if (targetCollectionId.isNull())
- targetCollectionId = d->defaultCollectionId();
+ targetCollectionId = defaultCollectionId();
// update the organizer item - set its ID
- const QOrganizerCollectionMemoryEngineId *colEngineId = static_cast<const QOrganizerCollectionMemoryEngineId *>(QOrganizerManagerEngine::engineCollectionId(targetCollectionId));
- QOrganizerItemMemoryEngineId* newId = new QOrganizerItemMemoryEngineId(colEngineId->m_collectionId, d->m_nextOrganizerItemId++, d->m_managerUri);
- // note: do NOT delete the QOrganizerItemMemoryEngineId -- the QOrganizerItemId ctor takes ownership of it.
- theOrganizerItemId = QOrganizerItemId(newId);
+ theOrganizerItemId = this->itemId(QString::number(d->m_nextOrganizerItemId++));
theOrganizerItem->setId(theOrganizerItemId);
// finally, add the organizer item to our internal lists and return
theOrganizerItem->setCollectionId(targetCollectionId);
@@ -1244,7 +1048,7 @@ bool QOrganizerItemMemoryEngine::removeItems(const QList<QOrganizerItem> *items,
QOrganizerCollection QOrganizerItemMemoryEngine::defaultCollection(QOrganizerManager::Error* error)
{
- const QOrganizerCollectionId defaultCollectionId = d->defaultCollectionId();
+ const QOrganizerCollectionId defaultCollectionId = this->defaultCollectionId();
Q_ASSERT(d->m_idToCollectionHash.contains(defaultCollectionId));
*error = QOrganizerManager::NoError;
return d->m_idToCollectionHash.value(defaultCollectionId);
@@ -1291,7 +1095,7 @@ bool QOrganizerItemMemoryEngine::saveCollection(QOrganizerCollection* collection
}
// this is a new collection with a null id; create a new id, add it to our list.
- collectionId = QOrganizerCollectionId(new QOrganizerCollectionMemoryEngineId(d->m_nextOrganizerCollectionId++, d->m_managerUri));
+ collectionId = this->collectionId(QString::number(d->m_nextOrganizerCollectionId++));
collection->setId(collectionId);
cs.insertAddedCollection(collectionId);
}
@@ -1304,7 +1108,7 @@ bool QOrganizerItemMemoryEngine::saveCollection(QOrganizerCollection* collection
bool QOrganizerItemMemoryEngine::removeCollection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error)
{
- if (collectionId == d->defaultCollectionId()) {
+ if (collectionId == defaultCollectionId()) {
// attempting to remove the default collection. this is not allowed in the memory engine.
*error = QOrganizerManager::PermissionsError;
return false;
diff --git a/src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h b/src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h
index 3daa40bb5..12320348e 100644
--- a/src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h
+++ b/src/plugins/organizer/memory/qorganizeritemmemorybackend_p.h
@@ -53,8 +53,6 @@
// We mean it.
//
-#include <QtOrganizer/qorganizeritemengineid.h>
-#include <QtOrganizer/qorganizercollectionengineid.h>
#include <QtOrganizer/qorganizermanagerengine.h>
#include <QtOrganizer/qorganizermanagerenginefactory.h>
#include <QtOrganizer/qorganizercollectionchangeset.h>
@@ -70,73 +68,17 @@ class QOrganizerItemMemoryFactory : public QOrganizerManagerEngineFactory
public:
QOrganizerManagerEngine* engine(const QMap<QString, QString>& parameters, QOrganizerManager::Error*);
- QOrganizerItemEngineId* createItemEngineId(const QMap<QString, QString>& parameters, const QString& idString) const;
- QOrganizerCollectionEngineId* createCollectionEngineId(const QMap<QString, QString>& parameters, const QString& idString) const;
QString managerName() const;
};
-class QOrganizerItemMemoryEngineId : public QOrganizerItemEngineId
-{
-public:
- QOrganizerItemMemoryEngineId();
- QOrganizerItemMemoryEngineId(quint32 collectionId, quint32 itemId, const QString& managerUri);
- ~QOrganizerItemMemoryEngineId();
- QOrganizerItemMemoryEngineId(const QOrganizerItemMemoryEngineId& other);
- QOrganizerItemMemoryEngineId(const QString& idString);
-
- bool isEqualTo(const QOrganizerItemEngineId* other) const;
- bool isLessThan(const QOrganizerItemEngineId* other) const;
-
- QString managerUri() const;
- QOrganizerItemEngineId* clone() const;
-
- QString toString() const;
-
-#ifndef QT_NO_DEBUG_STREAM
- QDebug& debugStreamOut(QDebug& dbg) const;
-#endif
- uint hash() const;
-
-private:
- quint32 m_collectionId;
- quint32 m_itemId;
- QString m_managerUri;
- friend class QOrganizerItemMemoryEngine;
-};
-
-class QOrganizerCollectionMemoryEngineId : public QOrganizerCollectionEngineId
-{
-public:
- QOrganizerCollectionMemoryEngineId();
- QOrganizerCollectionMemoryEngineId(quint32 collectionId, const QString& managerUri);
- ~QOrganizerCollectionMemoryEngineId();
- QOrganizerCollectionMemoryEngineId(const QOrganizerCollectionMemoryEngineId& other);
- QOrganizerCollectionMemoryEngineId(const QString& idString);
-
- bool isEqualTo(const QOrganizerCollectionEngineId* other) const;
- bool isLessThan(const QOrganizerCollectionEngineId* other) const;
-
- QString managerUri() const;
- QOrganizerCollectionEngineId* clone() const;
-
- QString toString() const;
-
-#ifndef QT_NO_DEBUG_STREAM
- QDebug& debugStreamOut(QDebug& dbg) const;
-#endif
- uint hash() const;
-
-private:
- quint32 m_collectionId;
- QString m_managerUri;
- friend class QOrganizerItemMemoryEngine;
-};
class QOrganizerAbstractRequest;
class QOrganizerManagerEngine;
class QOrganizerItemMemoryEngineData : public QSharedData
{
public:
+ enum { DefaultCollectionLocalId = 1 }; // default collection has id of 1.
+
QOrganizerItemMemoryEngineData();
~QOrganizerItemMemoryEngineData()
{
@@ -144,18 +86,12 @@ public:
QString m_id; // the id parameter value
- inline QOrganizerCollectionId defaultCollectionId() const
- {
- enum { DefaultCollectionLocalId = 1 }; // default collection has id of 1.
- return QOrganizerCollectionId(new QOrganizerCollectionMemoryEngineId(DefaultCollectionLocalId, m_managerUri));
- }
-
QHash<QOrganizerItemId, QOrganizerItem> m_idToItemHash; // hash of id to the item identified by that id
QMultiHash<QOrganizerItemId, QOrganizerItemId> m_parentIdToChildIdHash; // hash of id to that item's children's ids
QHash<QOrganizerCollectionId, QOrganizerCollection> m_idToCollectionHash; // hash of id to the collection identified by that id
QMultiHash<QOrganizerCollectionId, QOrganizerItemId> m_itemsInCollectionsHash; // hash of collection ids to the ids of items the collection contains.
- quint32 m_nextOrganizerItemId; // the m_itemId portion of a QOrganizerItemMemoryEngineId.
- quint32 m_nextOrganizerCollectionId; // the m_collectionId portion of a QOrganizerCollectionMemoryEngineId.
+ quint32 m_nextOrganizerItemId; // the localId() portion of a QOrganizerItemId
+ quint32 m_nextOrganizerCollectionId; // the localId() portion of a QOrganizerCollectionId
QString m_managerUri; // for faster lookup.
void emitSharedSignals(QOrganizerCollectionChangeSet *cs)
@@ -184,6 +120,10 @@ public:
/* URI reporting */
QString managerName() const;
QMap<QString, QString> managerParameters() const;
+ QMap<QString, QString> idInterpretationParameters() const;
+
+ inline QOrganizerCollectionId defaultCollectionId() const
+ { return collectionId(QString::number(QOrganizerItemMemoryEngineData::DefaultCollectionLocalId)); }
// items
QList<QOrganizerItem> items(const QList<QOrganizerItemId> &itemIds, const QOrganizerItemFetchHint &fetchHint,
diff --git a/src/plugins/organizer/skeleton/qorganizerskeleton.cpp b/src/plugins/organizer/skeleton/qorganizerskeleton.cpp
index 16787c9a0..c194e7ab7 100644
--- a/src/plugins/organizer/skeleton/qorganizerskeleton.cpp
+++ b/src/plugins/organizer/skeleton/qorganizerskeleton.cpp
@@ -58,403 +58,12 @@ QOrganizerManagerEngine* QOrganizerItemSkeletonFactory::engine(const QMap<QStrin
return ret;
}
-QOrganizerItemEngineId* QOrganizerItemSkeletonFactory::createItemEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
-{
- /*
- TODO
-
- Instantiate your engine-specific item id in this function.
-
- If idString is not empty, then you should deserialize the idString
- (the opposite of your QOrganizerItemEngineId derived-class'
- toString() function), otherwise you should instantiate an empty
- engine-specific collection id.
-
- This function allows clients to deserialize serialized ids from
- your engine.
- */
- Q_UNUSED(parameters);
- QOrganizerItemSkeletonEngineId* retn = new QOrganizerItemSkeletonEngineId;
- if (!idString.isEmpty())
- retn->m_itemId = idString.toUInt();
- return retn;
-}
-
-QOrganizerCollectionEngineId* QOrganizerItemSkeletonFactory::createCollectionEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
-{
- /*
- TODO
-
- Instantiate your engine-specific collection id in this function.
-
- If idString is not empty, then you should deserialize the idString
- (the opposite of your QOrganizerCollectionEngineId derived-class'
- toString() function), otherwise you should instantiate an empty
- engine-specific collection id.
-
- This function allows clients to deserialize serialized ids from
- your engine.
- */
- Q_UNUSED(parameters);
- QOrganizerCollectionSkeletonEngineId* retn = new QOrganizerCollectionSkeletonEngineId;
- if (!idString.isEmpty())
- retn->m_collectionId = idString.toUInt();
- return retn;
-}
-
QString QOrganizerItemSkeletonFactory::managerName() const
{
/* TODO - put your engine name here */
return QStringLiteral("skeleton");
}
-QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId()
- : QOrganizerItemEngineId(), m_itemId(0)
-{
- /*
- TODO
-
- Initialize any data members of your engine-specific item id in the constructor.
-
- This default constructor should not be used when returning a null id,
- but is provided in order to allow use of the ids in a list, and as an
- enabler for the implementation of QOrganizerItemId.
-
- When returning a null id, the backend should simply return a default
- constructed QOrganizerItemId.
-
- In this example, we use just a single quint32 to identify the item,
- however your engine may require more information in order to uniquely
- identify an item within it (e.g., a collection identifier plus an item
- identifier, and perhaps a datastore identifier which identifies the
- datastore in which the collection can be found).
- */
-}
-
-QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId(quint32 itemId)
- : QOrganizerItemEngineId(), m_itemId(itemId)
-{
- /*
- TODO
-
- Whatever data members your particular class has, should be passed as arguments
- to a ctor of this type. This is the constructor which will be used by your
- engine code.
-
- In particular, you will most likely be returning to clients an id by calling:
- QOrganizerItemId id(new QOrganizerItemSkeletonEngineId(3));
- or something similar. Note that the QOrganizerItemId constructor which
- takes a QOrganizerItemEngineId pointer as a parameter takes ownership
- of that pointer (and so controls its lifetime).
- */
-}
-
-QOrganizerItemSkeletonEngineId::QOrganizerItemSkeletonEngineId(const QOrganizerItemSkeletonEngineId& other)
- : QOrganizerItemEngineId(), m_itemId(other.m_itemId)
-{
- /* TODO - implement a copy constructor for your engine-specific id class */
-}
-
-QOrganizerItemSkeletonEngineId::~QOrganizerItemSkeletonEngineId()
-{
- /* TODO - Clean up any memory in use by your engine-specific id. */
-}
-
-bool QOrganizerItemSkeletonEngineId::isEqualTo(const QOrganizerItemEngineId* other) const
-{
- /*
- TODO
-
- The isEqualTo(other) function is called by the QOrganizerItemId::operator==(other) function.
- You must implement this in terms of the data members which your class contains.
-
- An example implementation is provided below, for the case where only a single quint32
- is required to uniquely identify an item in a manager.
- */
-
- quint32 otherItemId = static_cast<const QOrganizerItemSkeletonEngineId*>(other)->m_itemId;
- if (m_itemId != otherItemId)
- return false;
- return true;
-}
-
-bool QOrganizerItemSkeletonEngineId::isLessThan(const QOrganizerItemEngineId* other) const
-{
- /*
- TODO
-
- The isLessThan(other) function is called by the QOrganizerItemId::operator<(other) function.
- You must implement this in terms of the data members which your class contains.
-
- An example implementation is provided below, for the case where only a single quint32
- is required to uniquely identify an item in a manager.
- */
-
- quint32 otherItemId = static_cast<const QOrganizerItemSkeletonEngineId*>(other)->m_itemId;
- return (m_itemId < otherItemId);
-}
-
-QString QOrganizerItemSkeletonEngineId::managerUri() const
-{
- // TODO: make this return the actual managerUri (including params) of the
- // engine it is associated with
- static const QString uri(QStringLiteral("qtorganizer:skeleton:"));
- return uri;
-}
-
-QOrganizerItemEngineId* QOrganizerItemSkeletonEngineId::clone() const
-{
- /*
- TODO
-
- When a QOrganizerItemId is copied or assigned, it performs a clone of
- the engine-specific id. This function is called in that case.
-
- Implement this function so that the data members of your engine-specific id
- are deep-copied.
-
- An example implementation for the case where an item can be uniquely identified
- with just a single quint32 is given below.
- */
-
- QOrganizerItemSkeletonEngineId *myClone = new QOrganizerItemSkeletonEngineId;
- myClone->m_itemId = m_itemId;
- return myClone;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug& QOrganizerItemSkeletonEngineId::debugStreamOut(QDebug& dbg) const
-{
- /*
- TODO
-
- In order to allow clients to debug applications, you must implement this
- function. We recommend streaming the name of your class followed by the
- values of the data members in your engine-specific id class in
- parentheses.
-
- An example implementation for the case where an item can be uniquely identified
- with just a single quint32 is given below.
-
- Note that you must include the #ifndef QT_NO_DEBUG_STREAM preprocessor
- directive block in order to ensure compilation in environments where that
- directive is defined.
- */
-
- dbg.nospace() << "QOrganizerItemSkeletonEngineId(" << m_itemId << ")";
- return dbg.maybeSpace();
-}
-#endif
-
-QString QOrganizerItemSkeletonEngineId::toString() const
-{
- /*
- TODO
-
- In order to allow clients to serialize QOrganizerItemId's, you must implement
- this function.
-
- An example implementation for the case where an item can be uniquely identified
- with just a single quint32 is given below.
- */
-
- return QString::number(m_itemId);
-}
-
-uint QOrganizerItemSkeletonEngineId::hash() const
-{
- /*
- TODO
-
- Provide a hash function for your engine-specific id.
- Note that the hash doesn't strictly need to be unique, since isEqualTo()
- ensures that individual id's in a single hash-bucket can be uniquely
- determined; however a better hash function will result in better performance
- because the ids will be distributed more randomly in a hash table.
-
- In the example implementation below, we could simply return the id, since the
- id is a quint32. In more complex id classes, however, you may need to
- qHash() individual data members and combine the results somehow.
- */
-
- return QT_PREPEND_NAMESPACE(qHash)(m_itemId);
-}
-
-
-QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId()
- : QOrganizerCollectionEngineId(), m_collectionId(0)
-{
- /*
- TODO
-
- Initialize any data members of your engine-specific collection id in the constructor.
-
- This default constructor should not be used when returning a null id,
- but is provided in order to allow use of the ids in a list, and as an
- enabler for the implementation of QOrganizerCollectionId.
-
- When returning a null id, the backend should simply return a default
- constructed QOrganizerCollectionId.
-
- In this example, we use just a single quint32 to identify the collection,
- however your engine may require more information in order to uniquely
- identify a collection within it (e.g., a collection identifier plus a datastore
- identifier which identifies the datastore in which the collection can be found).
- */
-}
-
-QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId(quint32 collectionId)
- : QOrganizerCollectionEngineId(), m_collectionId(collectionId)
-{
- /*
- TODO
-
- Whatever data members your particular class has, should be passed as arguments
- to a ctor of this type. This is the constructor which will be used by your
- engine code.
-
- In particular, you will most likely be returning to clients an id by calling:
- QOrganizerCollectionId id(new QOrganizerCollectionSkeletonEngineId(3));
- or something similar. Note that the QOrganizerCollectionId constructor which
- takes a QOrganizerCollectionEngineId pointer as a parameter takes ownership
- of that pointer (and so controls its lifetime).
- */
-}
-
-QOrganizerCollectionSkeletonEngineId::QOrganizerCollectionSkeletonEngineId(const QOrganizerCollectionSkeletonEngineId& other)
- : QOrganizerCollectionEngineId(), m_collectionId(other.m_collectionId)
-{
- /* TODO - implement a copy constructor for your engine-specific id class */
-}
-
-QOrganizerCollectionSkeletonEngineId::~QOrganizerCollectionSkeletonEngineId()
-{
- /* TODO - Clean up any memory in use by your engine-specific id. */
-}
-
-bool QOrganizerCollectionSkeletonEngineId::isEqualTo(const QOrganizerCollectionEngineId* other) const
-{
- /*
- TODO
-
- The isEqualTo(other) function is called by the QOrganizerCollectionId::operator==(other) function.
- You must implement this in terms of the data members which your class contains.
-
- An example implementation is provided below, for the case where only a single quint32
- is required to uniquely identify a collection in a manager.
- */
-
- quint32 otherCollectionId = static_cast<const QOrganizerCollectionSkeletonEngineId*>(other)->m_collectionId;
- if (m_collectionId != otherCollectionId)
- return false;
- return true;
-}
-
-bool QOrganizerCollectionSkeletonEngineId::isLessThan(const QOrganizerCollectionEngineId* other) const
-{
- /*
- TODO
-
- The isLessThan(other) function is called by the QOrganizerCollectionId::operator<(other) function.
- You must implement this in terms of the data members which your class contains.
-
- An example implementation is provided below, for the case where only a single quint32
- is required to uniquely identify a collection in a manager.
- */
-
- quint32 otherCollectionId = static_cast<const QOrganizerCollectionSkeletonEngineId*>(other)->m_collectionId;
- if (m_collectionId < otherCollectionId)
- return true;
- return false;
-}
-
-QString QOrganizerCollectionSkeletonEngineId::managerUri() const
-{
- // TODO: make this return the actual managerUri (including params) of the
- // engine it is associated with
- static const QString uri(QStringLiteral("qtorganizer:skeleton:"));
- return uri;
-}
-
-QOrganizerCollectionEngineId* QOrganizerCollectionSkeletonEngineId::clone() const
-{
- /*
- TODO
-
- When a QOrganizerCollectionId is copied or assigned, it performs a clone of
- the engine-specific id. This function is called in that case.
-
- Implement this function so that the data members of your engine-specific id
- are deep-copied.
-
- An example implementation for the case where a collection can be uniquely identified
- with just a single quint32 is given below.
- */
-
- QOrganizerCollectionSkeletonEngineId *myClone = new QOrganizerCollectionSkeletonEngineId;
- myClone->m_collectionId = m_collectionId;
- return myClone;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug& QOrganizerCollectionSkeletonEngineId::debugStreamOut(QDebug& dbg) const
-{
- /*
- TODO
-
- In order to allow clients to debug applications, you must implement this
- function. We recommend streaming the name of your class followed by the
- values of the data members in your engine-specific id class in
- parentheses.
-
- An example implementation for the case where a collection can be uniquely identified
- with just a single quint32 is given below.
-
- Note that you must include the #ifndef QT_NO_DEBUG_STREAM preprocessor
- directive block in order to ensure compilation in environments where that
- directive is defined.
- */
-
- dbg.nospace() << "QOrganizerCollectionSkeletonEngineId(" << m_collectionId << ")";
- return dbg.maybeSpace();
-}
-#endif
-
-QString QOrganizerCollectionSkeletonEngineId::toString() const
-{
- /*
- TODO
-
- In order to allow clients to serialize QOrganizerCollectionId's, you must implement
- this function.
-
- An example implementation for the case where a collection can be uniquely identified
- with just a single quint32 is given below.
- */
-
- return QString::number(m_collectionId);
-}
-
-uint QOrganizerCollectionSkeletonEngineId::hash() const
-{
- /*
- TODO
-
- Provide a hash function for your engine-specific id.
- Note that the hash doesn't strictly need to be unique, since isEqualTo()
- ensures that individual id's in a single hash-bucket can be uniquely
- determined; however a better hash function will result in better performance
- because the ids will be distributed more randomly in a hash table.
-
- In the example implementation below, we could simply return the id, since the
- id is a quint32. In more complex id classes, however, you may need to
- qHash() individual data members and combine the results somehow.
- */
-
- return QT_PREPEND_NAMESPACE(qHash)(m_collectionId);
-}
-
-
QOrganizerItemSkeletonEngine::~QOrganizerItemSkeletonEngine()
{
diff --git a/src/plugins/organizer/skeleton/qorganizerskeleton_p.h b/src/plugins/organizer/skeleton/qorganizerskeleton_p.h
index 58a264249..96eb6336e 100644
--- a/src/plugins/organizer/skeleton/qorganizerskeleton_p.h
+++ b/src/plugins/organizer/skeleton/qorganizerskeleton_p.h
@@ -68,8 +68,6 @@
#include <QtOrganizer/qorganizermanagerengine.h>
#include <QtOrganizer/qorganizermanagerenginefactory.h>
#include <QtOrganizer/qorganizerabstractrequest.h>
-#include <QtOrganizer/qorganizeritemengineid.h>
-#include <QtOrganizer/qorganizercollectionengineid.h>
QT_BEGIN_NAMESPACE_ORGANIZER
@@ -80,67 +78,9 @@ class QOrganizerItemSkeletonFactory : public QOrganizerManagerEngineFactory
public:
QOrganizerManagerEngine* engine(const QMap<QString, QString>& parameters, QOrganizerManager::Error*);
- QOrganizerItemEngineId* createItemEngineId(const QMap<QString, QString>& parameters, const QString& idString) const;
- QOrganizerCollectionEngineId* createCollectionEngineId(const QMap<QString, QString>& parameters, const QString& idString) const;
QString managerName() const;
};
-class QOrganizerCollectionSkeletonEngineId : public QOrganizerCollectionEngineId
-{
-public:
- QOrganizerCollectionSkeletonEngineId();
- QOrganizerCollectionSkeletonEngineId(quint32 collectionId);
- ~QOrganizerCollectionSkeletonEngineId();
- QOrganizerCollectionSkeletonEngineId(const QOrganizerCollectionSkeletonEngineId& other);
-
- bool isEqualTo(const QOrganizerCollectionEngineId* other) const;
- bool isLessThan(const QOrganizerCollectionEngineId* other) const;
-
- QString managerUri() const;
- QOrganizerCollectionEngineId* clone() const;
-
- QString toString() const;
-
-#ifndef QT_NO_DEBUG_STREAM
- QDebug& debugStreamOut(QDebug& dbg) const;
-#endif
- uint hash() const;
-
- // data members:
- // Your backend can use whatever it likes as an id internally.
- // In this example, we use just a single quint32, but you can
- // use any datatype you need to (filename string, etc).
- quint32 m_collectionId;
-};
-
-class QOrganizerItemSkeletonEngineId : public QOrganizerItemEngineId
-{
-public:
- QOrganizerItemSkeletonEngineId();
- QOrganizerItemSkeletonEngineId(quint32 itemId);
- ~QOrganizerItemSkeletonEngineId();
- QOrganizerItemSkeletonEngineId(const QOrganizerItemSkeletonEngineId& other);
-
- bool isEqualTo(const QOrganizerItemEngineId* other) const;
- bool isLessThan(const QOrganizerItemEngineId* other) const;
-
- QString managerUri() const;
- QOrganizerItemEngineId* clone() const;
-
- QString toString() const;
-
-#ifndef QT_NO_DEBUG_STREAM
- QDebug& debugStreamOut(QDebug& dbg) const;
-#endif
- uint hash() const;
-
- // data members:
- // Your backend can use whatever it likes as an id internally.
- // In this example, we use just a single quint32, but you can
- // use a pair of ints (one for collectionId, one for itemId)
- // or any other information (uuid string, etc).
- quint32 m_itemId;
-};
class QOrganizerItemSkeletonEngineData : public QSharedData
{
diff --git a/tests/auto/contacts/qcontact/qcontact.pro b/tests/auto/contacts/qcontact/qcontact.pro
index 7f562cb3f..2d2f85c93 100644
--- a/tests/auto/contacts/qcontact/qcontact.pro
+++ b/tests/auto/contacts/qcontact/qcontact.pro
@@ -3,6 +3,5 @@ include(../../auto.pri)
QT += contacts
SOURCES += tst_qcontact.cpp
-HEADERS += ../qcontactidmock.h
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/contacts/qcontact/tst_qcontact.cpp b/tests/auto/contacts/qcontact/tst_qcontact.cpp
index fd9bb2883..50c705015 100644
--- a/tests/auto/contacts/qcontact/tst_qcontact.cpp
+++ b/tests/auto/contacts/qcontact/tst_qcontact.cpp
@@ -42,12 +42,17 @@
#include <QtTest/QtTest>
#include <QtContacts/qcontacts.h>
#include <QSet>
-#include "../qcontactidmock.h"
//TESTED_COMPONENT=src/contacts
QTCONTACTS_USE_NAMESPACE
+static inline QContactId makeId(const QString &managerName, uint id)
+{
+ return QContactId(QStringLiteral("qtcontacts:basic%1:").arg(managerName), QString::number(id));
+}
+
+
class tst_QContact: public QObject
{
Q_OBJECT
@@ -536,28 +541,29 @@ void tst_QContact::emptiness()
void tst_QContact::idComparison()
{
- QContactId id1 = QContactIdMock::createId("a", 1);
- QContactId id2 = QContactIdMock::createId("a", 1);
+ QContactId id1(makeId("a", 1));
+ QContactId id2(makeId("a", 1));
QVERIFY(!(id1 < id2));
QVERIFY(!(id2 < id1));
QVERIFY(id1 == id2);
- QContactId id3 = QContactIdMock::createId("a", 2);
- QContactId id4 = QContactIdMock::createId("b", 1);
- QContactId id5 = QContactIdMock::createId(QString(), 2); // no Uri specified.
- QVERIFY(((id1 < id3) || (id3 < id1)) && (id1 != id3));
- QVERIFY(((id1 < id4) || (id4 < id1)) && (id1 != id4));
- QVERIFY(((id3 < id4) || (id4 < id3)) && (id3 != id4));
- QVERIFY(((id1 < id5) || (id5 < id1)) && (id1 != id5));
+ QContactId id3(makeId("a", 2));
+ QContactId id4(makeId("b", 1));
+ QContactId id5(makeId(QString(), 2)); // no Uri specified.
+ QVERIFY((((id1 < id3) && !(id3 < id1)) || ((id3 < id1) && !(id1 < id3))) && (id1 != id3));
+ QVERIFY((((id1 < id4) && !(id4 < id1)) || ((id4 < id1) && !(id1 < id4))) && (id1 != id4));
+ QVERIFY((((id3 < id4) && !(id4 < id3)) || ((id4 < id3) && !(id3 < id4))) && (id3 != id4));
+ QVERIFY((((id1 < id5) && !(id5 < id1)) || ((id5 < id1) && !(id1 < id5))) && (id3 != id4));
}
void tst_QContact::idHash()
{
- QContactId id1 = QContactIdMock::createId("a", 1);
- QContactId id2 = QContactIdMock::createId("a", 1);
- QContactId id3 = QContactIdMock::createId("b", 1);
- QContactId id4 = QContactIdMock::createId("a", 2);
+ QContactId id1(makeId("a", 1));
+ QContactId id2(makeId("a", 1));
+ QContactId id3(makeId("b", 1));
+ QContactId id4(makeId("a", 2));
// note that the hash function ignores the managerUri
QCOMPARE(qHash(id1), qHash(id2));
+ QCOMPARE(qHash(id1), qHash(id3));
QVERIFY(qHash(id1) != qHash(id4));
QSet<QContactId> set;
@@ -570,7 +576,7 @@ void tst_QContact::idHash()
void tst_QContact::hash()
{
- QContactId id = QContactIdMock::createId("a", 1);
+ QContactId id = makeId("a", 1);
QContact contact1;
contact1.setId(id);
QContactDetail detail1(QContactDetail::TypeExtendedDetail);
@@ -603,7 +609,7 @@ void tst_QContact::datastream()
QByteArray buffer;
QDataStream stream1(&buffer, QIODevice::WriteOnly);
QContact contactIn;
- QContactId id = QContactIdMock::createId("manager", 1234);
+ QContactId id = makeId("manager", 1234);
contactIn.setId(id);
QContactPhoneNumber phone;
phone.setNumber("5678");
@@ -612,11 +618,10 @@ void tst_QContact::datastream()
QVERIFY(buffer.size() > 0);
- /* TODO: fix me?
QDataStream stream2(buffer);
QContact contactOut;
stream2 >> contactOut;
- QCOMPARE(contactOut, contactIn);*/
+ QCOMPARE(contactOut, contactIn);
}
void tst_QContact::traits()
@@ -631,10 +636,10 @@ void tst_QContact::traits()
void tst_QContact::idTraits()
{
- QCOMPARE(sizeof(QContactId), sizeof(void *));
+ QCOMPARE(sizeof(QContactId), 2*sizeof(void *));
QVERIFY(QTypeInfo<QContactId>::isComplex);
QVERIFY(!QTypeInfo<QContactId>::isStatic);
- QVERIFY(!QTypeInfo<QContactId>::isLarge);
+ QVERIFY(QTypeInfo<QContactId>::isLarge);
QVERIFY(!QTypeInfo<QContactId>::isPointer);
QVERIFY(!QTypeInfo<QContactId>::isDummy);
}
@@ -667,7 +672,7 @@ void tst_QContact::equality()
void tst_QContact::inequality()
{
- QContactId id = QContactIdMock::createId("a", 123);
+ QContactId id = makeId("a", 123);
QContactName name;
name.setFirstName("John");
name.setLastName("Doe");
diff --git a/tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin.cpp b/tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin.cpp
index ef0e5fa5d..8382f1727 100644
--- a/tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin.cpp
+++ b/tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin.cpp
@@ -195,11 +195,4 @@ QContactManagerEngine* MaliciousEngineFactory::engine(const QMap<QString, QStrin
return new MaliciousAsyncManagerEngine();
}
-QContactEngineId* MaliciousEngineFactory::createContactEngineId(const QMap<QString, QString>& parameters, const QString& engineIdString) const
-{
- Q_UNUSED(parameters);
- Q_UNUSED(engineIdString);
- return 0;
-}
-
#include "maliciousplugin.moc"
diff --git a/tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin_p.h b/tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin_p.h
index f4617917f..63da9afb1 100644
--- a/tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin_p.h
+++ b/tests/auto/contacts/qcontactasync/maliciousplugin/maliciousplugin_p.h
@@ -178,7 +178,6 @@ class MaliciousEngineFactory : public QContactManagerEngineFactory
public:
QContactManagerEngine* engine(const QMap<QString, QString>& parameters, QContactManager::Error* error);
- QContactEngineId* createContactEngineId(const QMap<QString, QString>& parameters, const QString& engineIdString) const;
QString managerName() const;
private:
diff --git a/tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp b/tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp
index 51bcd6abc..bdd2f9a37 100644
--- a/tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp
+++ b/tests/auto/contacts/qcontactasync/unittest/tst_qcontactasync.cpp
@@ -44,28 +44,8 @@
#include <QCoreApplication>
#include <QScopedPointer>
-#include <QtContacts/QContact>
-#include <QtContacts/QContactAbstractRequest>
-#include <QtContacts/QContactTimestamp>
-#include <QtContacts/QContactFetchRequest>
-#include <QtContacts/QContactDetailFilter>
-#include <QtContacts/QContactUrl>
-#include <QtContacts/QContactPhoneNumber>
-#include <QtContacts/QContactFetchByIdRequest>
-#include <QtContacts/QContactIdFetchRequest>
-#include <QtContacts/QContactRemoveRequest>
-#include <QtContacts/QContactSaveRequest>
-#include <QtContacts/QContactEmailAddress>
-#include <QtContacts/QContactOnlineAccount>
-#include <QtContacts/QContactTag>
-#include <QtContacts/QContactOrganization>
-#include <QtContacts/QContactRelationshipFetchRequest>
-#include <QtContacts/QContactRelationshipRemoveRequest>
-#include <QtContacts/QContactRelationshipSaveRequest>
-#include <QtContacts/QContactName>
-#include <QtContacts/QContactIdFilter>
-
-#include "qcontactidmock.h"
+#include <QtContacts/qcontacts.h>
+
#include "qcontactmanagerdataholder.h" //QContactManagerDataHolder
QTCONTACTS_USE_NAMESPACE
@@ -184,6 +164,13 @@ private:
QList< QVariantList> savedArgs;
};
+
+static inline QContactId makeId(const QString &managerName, uint id)
+{
+ return QContactId(QStringLiteral("qtcontacts:basic%1:").arg(managerName), QString::number(id));
+}
+
+
class tst_QContactAsync : public QObject
{
Q_OBJECT
@@ -1240,7 +1227,7 @@ void tst_QContactAsync::contactRemoveErrorHandling() {
// Setup valid and invalid contact ids for remove request, start it and wait for finished.
QContactId emptyId;
- QContactId failingId = QContactIdMock::createId("Failing", 0);
+ QContactId failingId = makeId("Failing", 0);
QList<QContactId> toRemove;
toRemove << emptyId << cm.data()->contactIds();
toRemove.insert(3, emptyId);
@@ -1779,7 +1766,7 @@ void tst_QContactAsync::contactPartialSave()
QCOMPARE(contacts[4].details<QContactPhoneNumber>().count(), 1); // saved
// 6) Have a bad manager uri in the middle
- QContactId badId = QContactIdMock::createId("BadManager", 0);
+ QContactId badId = makeId("BadManager", 0);
contacts[3].setId(badId);
csr.setContacts(contacts);
QVERIFY(csr.start());
@@ -1790,7 +1777,7 @@ void tst_QContactAsync::contactPartialSave()
QCOMPARE(errorMap[3], QContactManager::DoesNotExistError);
// 7) Have a non existing contact in the middle
- badId = QContactIdMock::createId(cm->managerName(), 0);
+ badId = makeId(cm->managerName(), 0);
contacts[3].setId(badId);
csr.setContacts(contacts);
QVERIFY(csr.start());
diff --git a/tests/auto/contacts/qcontactfilter/tst_qcontactfilter.cpp b/tests/auto/contacts/qcontactfilter/tst_qcontactfilter.cpp
index 2eced47b9..14f04bedb 100644
--- a/tests/auto/contacts/qcontactfilter/tst_qcontactfilter.cpp
+++ b/tests/auto/contacts/qcontactfilter/tst_qcontactfilter.cpp
@@ -42,7 +42,6 @@
#include <QMetaType>
#include <QtContacts/qcontacts.h>
-#include "../qcontactidmock.h"
//TESTED_COMPONENT=src/contacts
@@ -51,6 +50,11 @@ QTCONTACTS_USE_NAMESPACE
Q_DECLARE_METATYPE(QContact)
Q_DECLARE_METATYPE(QContactFilter)
+static inline QContactId makeId(const QString &managerName, uint id)
+{
+ return QContactId(QStringLiteral("qtcontacts:basic%1:").arg(managerName), QString::number(id));
+}
+
class tst_QContactFilter : public QObject
{
Q_OBJECT
@@ -645,7 +649,7 @@ void tst_QContactFilter::relationshipFilter()
QVERIFY(crf.relatedContactId() == QContactId());
QContact newContact;
- newContact.setId(QContactIdMock::createId("test", 5));
+ newContact.setId(makeId("test", 5));
crf.setRelatedContactId(newContact.id());
QVERIFY(crf.relationshipType() == QString());
diff --git a/tests/auto/contacts/qcontactidmock.h b/tests/auto/contacts/qcontactidmock.h
deleted file mode 100644
index 7eafa08c1..000000000
--- a/tests/auto/contacts/qcontactidmock.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QCONTACTIDMOCK_H
-#define QCONTACTIDMOCK_H
-
-#include <QtContacts/qcontacts.h>
-#include <QtContacts/qcontactengineid.h>
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-QTCONTACTS_USE_NAMESPACE
-
-class QContactIdMock : public QContactEngineId
-{
-public:
- QContactIdMock(const QString& managerUri, uint id) : m_managerUri(managerUri), m_id(id) {}
-
- bool isEqualTo(const QContactEngineId* other) const {
- return m_id == static_cast<const QContactIdMock*>(other)->m_id;
- }
-
- bool isLessThan(const QContactEngineId* other) const {
- return m_id < static_cast<const QContactIdMock*>(other)->m_id;
- }
-
- QString localId() const {
- return QString::number(m_id);
- }
-
- QString managerUri() const {
- return "qtcontacts:" + m_managerUri;
- }
-
- QContactEngineId* clone() const {
- QContactIdMock* cloned = new QContactIdMock(m_managerUri, m_id);
- return cloned;
- }
-
- QDebug& debugStreamOut(QDebug& dbg) const {
- return dbg << m_managerUri << m_id;
- }
-
- QString toString() const {
- return m_managerUri + QString("::") + QString::number(m_id);
- }
-
- uint hash() const {
- return qHash(toString());
- }
-
- static QContactId createId(const QString& managerUri, uint id)
- {
- return QContactId(new QContactIdMock(managerUri, id));
- }
-
-private:
- QString m_managerUri;
- uint m_id;
-};
-
-#endif
diff --git a/tests/auto/contacts/qcontactmanager/qcontactmanager.pro b/tests/auto/contacts/qcontactmanager/qcontactmanager.pro
index 86fd33a7e..ca61169d8 100644
--- a/tests/auto/contacts/qcontactmanager/qcontactmanager.pro
+++ b/tests/auto/contacts/qcontactmanager/qcontactmanager.pro
@@ -4,7 +4,6 @@ QT += contacts versit contacts-private
SOURCES += tst_qcontactmanager.cpp
HEADERS += ../qcontactmanagerdataholder.h
-HEADERS += ../qcontactidmock.h
OTHER_FILES += lazy.json
diff --git a/tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp b/tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp
index f319772ec..43fa8eff1 100644
--- a/tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp
+++ b/tests/auto/contacts/qcontactmanager/tst_qcontactmanager.cpp
@@ -47,7 +47,6 @@
#include <QtContacts>
#include "qcontactmanagerdataholder.h"
-#include "qcontactidmock.h"
#if defined(USE_VERSIT_PLZ)
// This makes it easier to create specific QContacts
@@ -276,7 +275,6 @@ class LazyEngineFactory : public QContactManagerEngineFactory
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QContactManagerEngineFactoryInterface" FILE "lazy.json")
public:
QContactManagerEngine* engine(const QMap<QString, QString>& parameters, QContactManager::Error* error);
- QContactEngineId* createContactEngineId(const QMap<QString, QString>& parameters, const QString& idString) const;
QString managerName() const {return "testlazy";}
};
@@ -290,11 +288,9 @@ QContactManagerEngine* LazyEngineFactory::engine(const QMap<QString, QString>& p
return new QContactLazyEngine2();
}
-QContactEngineId* LazyEngineFactory::createContactEngineId(const QMap<QString, QString>& parameters, const QString& idString) const
+static inline QContactId makeId(const QString &managerName, uint id)
{
- Q_UNUSED(parameters)
- Q_UNUSED(idString)
- return new QContactIdMock("",1);
+ return QContactId(QStringLiteral("qtcontacts:basic%1:").arg(managerName), QString::number(id));
}
tst_QContactManager::tst_QContactManager()
@@ -2156,7 +2152,7 @@ void tst_QContactManager::actionPreferences()
void tst_QContactManager::changeSet()
{
- QContactId id = QContactIdMock::createId("a", 1);
+ QContactId id = makeId("a", 1);
QContactChangeSet changeSet;
QVERIFY(changeSet.addedContacts().isEmpty());
QVERIFY(changeSet.changedContacts().isEmpty());
@@ -2198,7 +2194,7 @@ void tst_QContactManager::changeSet()
QList<QContactId> l1, l2;
foreach (int n, QList<int>() << 1 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 4 << 5 << 10 << 9 << 8 << 8 << 8 << 7 << 7 << 6) {
- ((qrand() % 2) ? l1 : l2).append(QContactIdMock::createId("a", n));
+ ((qrand() % 2) ? l1 : l2).append(makeId("a", n));
}
changeSet.clearChangedContacts();
changeSet.insertChangedContacts(l1, QList<QContactDetail::DetailType>() << QContactName::Type << QContactBirthday::Type);
diff --git a/tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.cpp b/tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.cpp
index 236b72ced..0c45c6a86 100644
--- a/tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.cpp
+++ b/tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.cpp
@@ -215,9 +215,4 @@ QList<QVariant::Type> DummyEngine::supportedDataTypes() const
return st;
}
-QContactEngineId* DummyEngineFactory::createContactEngineId(const QMap<QString, QString>& parameters, const QString& engineIdString) const
-{
- return 0;
-}
-
#include "moc_dummyplugin.cpp"
diff --git a/tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.h b/tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.h
index 125e6930e..1b744a1e6 100644
--- a/tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.h
+++ b/tests/auto/contacts/qcontactmanagerplugins/dummyplugin/dummyplugin.h
@@ -179,7 +179,6 @@ class DummyEngineFactory : public QContactManagerEngineFactory
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QContactManagerEngineFactoryInterface" FILE "dummy.json")
public:
QContactManagerEngine* engine(const QMap<QString, QString>& parameters, QContactManager::Error* error);
- QContactEngineId* createContactEngineId(const QMap<QString, QString>& parameters, const QString& engineIdString) const;
QString managerName() const;
};
diff --git a/tests/auto/contacts/qcontactmanagerplugins/unittest/tst_qcontactmanagerplugins.cpp b/tests/auto/contacts/qcontactmanagerplugins/unittest/tst_qcontactmanagerplugins.cpp
index b4a9e4082..a4f9c8126 100644
--- a/tests/auto/contacts/qcontactmanagerplugins/unittest/tst_qcontactmanagerplugins.cpp
+++ b/tests/auto/contacts/qcontactmanagerplugins/unittest/tst_qcontactmanagerplugins.cpp
@@ -73,7 +73,6 @@ class DummyStaticEngineFactory : public QObject, public QContactManagerEngineFac
Q_INTERFACES(QtContacts::QContactManagerEngineFactory)
public:
QContactManagerEngine* engine(const QMap<QString, QString>& parameters, QContactManager::Error* error);
- QContactEngineId* createContactEngineId(const QMap<QString, QString>& parameters, const QString& engineIdString) const;
QString managerName() const {return "teststaticdummy";}
};
@@ -84,13 +83,6 @@ QContactManagerEngine* DummyStaticEngineFactory::engine(const QMap<QString, QStr
return 0; // always fail, haha
}
-QContactEngineId* DummyStaticEngineFactory::createContactEngineId(const QMap<QString, QString>& parameters, const QString& engineIdString) const
-{
- Q_UNUSED(parameters);
- Q_UNUSED(engineIdString);
- return 0;
-}
-
Q_EXPORT_PLUGIN2(contacts_teststaticdummy, DummyStaticEngineFactory)
Q_IMPORT_PLUGIN(contacts_teststaticdummy)
diff --git a/tests/auto/contacts/qcontactrelationship/qcontactrelationship.pro b/tests/auto/contacts/qcontactrelationship/qcontactrelationship.pro
index 64a057072..0c564f4d9 100644
--- a/tests/auto/contacts/qcontactrelationship/qcontactrelationship.pro
+++ b/tests/auto/contacts/qcontactrelationship/qcontactrelationship.pro
@@ -3,6 +3,5 @@ include(../../auto.pri)
QT += contacts
SOURCES += tst_qcontactrelationship.cpp
-HEADERS += ../qcontactidmock.h
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/contacts/qcontactrelationship/tst_qcontactrelationship.cpp b/tests/auto/contacts/qcontactrelationship/tst_qcontactrelationship.cpp
index 5f1c8375f..de59f88ff 100644
--- a/tests/auto/contacts/qcontactrelationship/tst_qcontactrelationship.cpp
+++ b/tests/auto/contacts/qcontactrelationship/tst_qcontactrelationship.cpp
@@ -44,10 +44,15 @@
#include <QtTest/QtTest>
#include <QtContacts/qcontacts.h>
-#include "../qcontactidmock.h"
QTCONTACTS_USE_NAMESPACE
+static inline QContactId makeId(const QString &managerName, uint id)
+{
+ return QContactId(QStringLiteral("qtcontacts:%1:").arg(managerName), QString::number(id));
+}
+
+
class tst_QContactRelationship: public QObject
{
Q_OBJECT
@@ -97,9 +102,9 @@ void tst_QContactRelationship::emptiness()
QContactRelationship r1, r2, r3;
QContact contact1, contact2, contact3;
- contact1.setId(QContactIdMock::createId("test", 1));
- contact2.setId(QContactIdMock::createId("test", 2));
- contact3.setId(QContactIdMock::createId("test", 3));
+ contact1.setId(makeId("test", 1));
+ contact2.setId(makeId("test", 2));
+ contact3.setId(makeId("test", 3));
QVERIFY(r1.first() == QContactId());
QVERIFY(r1.second() == QContactId());
@@ -134,10 +139,10 @@ void tst_QContactRelationship::hash()
{
QContactRelationship r1;
QContact contact1;
- contact1.setId(QContactIdMock::createId("a", 1));
+ contact1.setId(makeId("a", 1));
r1.setFirst(contact1.id());
QContact contact2;
- contact2.setId(QContactIdMock::createId("b", 2));
+ contact2.setId(makeId("b", 2));
r1.setSecond(contact2.id());
r1.setRelationshipType(QContactRelationship::HasMember());
@@ -149,7 +154,7 @@ void tst_QContactRelationship::hash()
QContactRelationship r3;
r3.setFirst(contact1.id());
QContact contact3;
- contact1.setId(QContactIdMock::createId("c", 3));
+ contact1.setId(makeId("c", 3));
r3.setSecond(contact3.id());
r3.setRelationshipType(QContactRelationship::HasMember());
@@ -160,20 +165,14 @@ void tst_QContactRelationship::hash()
void tst_QContactRelationship::datastream()
{
- QSKIP("Datastream is not currently supported when using the QContactIdMock class");
- //After QContactId introduction, the QCOMPARE at then end this case will fail, since
- //relationshipOut will contain contacts with "null" QContactIds, whereas
- //relationshipIn will contain contacts with QContactIds referring to
- //manager "a", which is an invalid one.
-
QByteArray buffer;
QDataStream stream1(&buffer, QIODevice::WriteOnly);
QContactRelationship relationshipIn;
QContact contact1;
- contact1.setId(QContactIdMock::createId("a", 1));
+ contact1.setId(makeId("a", 1));
relationshipIn.setFirst(contact1.id());
QContact contact2;
- contact2.setId(QContactIdMock::createId("a", 2));
+ contact2.setId(makeId("a", 2));
relationshipIn.setSecond(contact2.id());
relationshipIn.setRelationshipType(QContactRelationship::HasMember());
stream1 << relationshipIn;
diff --git a/tests/auto/organizer/qorganizercollection/tst_qorganizercollection.cpp b/tests/auto/organizer/qorganizercollection/tst_qorganizercollection.cpp
index cf8202c59..e779265dd 100644
--- a/tests/auto/organizer/qorganizercollection/tst_qorganizercollection.cpp
+++ b/tests/auto/organizer/qorganizercollection/tst_qorganizercollection.cpp
@@ -45,11 +45,17 @@
#include <QtOrganizer/qorganizer.h>
#include <QtOrganizer/qorganizeritemid.h>
-#include <QtOrganizer/qorganizercollectionengineid.h>
//TESTED_COMPONENT=src/organizer
QTORGANIZER_USE_NAMESPACE
+
+static inline QOrganizerCollectionId makeId(const QString &managerName, uint id)
+{
+ return QOrganizerCollectionId(QStringLiteral("qtorganizer:basic%1:").arg(managerName), QString::number(id));
+}
+
+
class tst_QOrganizerCollection: public QObject
{
Q_OBJECT
@@ -92,49 +98,6 @@ void tst_QOrganizerCollection::metaData()
QCOMPARE(c.metaData(QOrganizerCollection::KeyName).toString(), QString(QStringLiteral("test2")));
}
-class BasicCollectionLocalId : public QOrganizerCollectionEngineId
-{
-public:
- BasicCollectionLocalId(const QString& managerUri, uint id) : m_managerUri(managerUri), m_id(id) {}
- bool isEqualTo(const QOrganizerCollectionEngineId* other) const {
- if (m_managerUri == static_cast<const BasicCollectionLocalId*>(other)->m_managerUri)
- return m_id == static_cast<const BasicCollectionLocalId*>(other)->m_id;
- return false;
- }
- bool isLessThan(const QOrganizerCollectionEngineId* other) const {
- if (m_managerUri == static_cast<const BasicCollectionLocalId*>(other)->m_managerUri)
- return m_id < static_cast<const BasicCollectionLocalId*>(other)->m_id;
- return m_managerUri < static_cast<const BasicCollectionLocalId*>(other)->m_managerUri;
- }
- QString managerUri() const {
- static const QString uri(QStringLiteral("qtorganizer:basic:"));
- return uri;
- }
- QOrganizerCollectionEngineId* clone() const {
- BasicCollectionLocalId* cloned = new BasicCollectionLocalId(m_managerUri, m_id);
- return cloned;
- }
- QDebug& debugStreamOut(QDebug& dbg) const {
- return dbg << m_managerUri << m_id;
- }
- QString toString() const {
- return m_managerUri + QString("::") + QString::number(m_id);
- }
- uint hash() const {
- return m_id;
- }
-
-private:
- QString m_managerUri;
- uint m_id;
-};
-
-QOrganizerCollectionId makeId(const QString& managerUri, uint id)
-{
- return QOrganizerCollectionId(new BasicCollectionLocalId(managerUri, id));
-}
-
-
void tst_QOrganizerCollection::compare()
{
QOrganizerCollection c, c2;
@@ -177,10 +140,10 @@ void tst_QOrganizerCollection::idComparison()
QOrganizerCollectionId id3(makeId("a", 2));
QOrganizerCollectionId id4(makeId("b", 1));
QOrganizerCollectionId id5(makeId(QString(), 2)); // no Uri specified.
- QVERIFY(((id1 < id3) || (id3 < id1)) && (id1 != id3));
- QVERIFY(((id1 < id4) || (id4 < id1)) && (id1 != id4));
- QVERIFY(((id3 < id4) || (id4 < id3)) && (id3 != id4));
- QVERIFY(((id1 < id5) || (id5 < id1)) && (id1 != id5));
+ QVERIFY((((id1 < id3) && !(id3 < id1)) || ((id3 < id1) && !(id1 < id3))) && (id1 != id3));
+ QVERIFY((((id1 < id4) && !(id4 < id1)) || ((id4 < id1) && !(id1 < id4))) && (id1 != id4));
+ QVERIFY((((id3 < id4) && !(id4 < id3)) || ((id4 < id3) && !(id3 < id4))) && (id3 != id4));
+ QVERIFY((((id1 < id5) && !(id5 < id1)) || ((id5 < id1) && !(id1 < id5))) && (id3 != id4));
}
void tst_QOrganizerCollection::idHash()
@@ -191,6 +154,7 @@ void tst_QOrganizerCollection::idHash()
QOrganizerCollectionId id4(makeId("a", 2));
// note that the hash function ignores the managerUri
QCOMPARE(qHash(id1), qHash(id2));
+ QCOMPARE(qHash(id1), qHash(id3));
QVERIFY(qHash(id1) != qHash(id4));
QSet<QOrganizerCollectionId> set;
@@ -460,10 +424,10 @@ void tst_QOrganizerCollection::traits()
void tst_QOrganizerCollection::idTraits()
{
- QCOMPARE(sizeof(QOrganizerCollectionId), sizeof(void *));
+ QCOMPARE(sizeof(QOrganizerCollectionId), 2*sizeof(void *));
QVERIFY(QTypeInfo<QOrganizerCollectionId>::isComplex);
QVERIFY(!QTypeInfo<QOrganizerCollectionId>::isStatic);
- QVERIFY(!QTypeInfo<QOrganizerCollectionId>::isLarge);
+ QVERIFY(QTypeInfo<QOrganizerCollectionId>::isLarge);
QVERIFY(!QTypeInfo<QOrganizerCollectionId>::isPointer);
QVERIFY(!QTypeInfo<QOrganizerCollectionId>::isDummy);
}
diff --git a/tests/auto/organizer/qorganizeritem/tst_qorganizeritem.cpp b/tests/auto/organizer/qorganizeritem/tst_qorganizeritem.cpp
index 38b4a3144..e2c55d0d3 100644
--- a/tests/auto/organizer/qorganizeritem/tst_qorganizeritem.cpp
+++ b/tests/auto/organizer/qorganizeritem/tst_qorganizeritem.cpp
@@ -45,11 +45,17 @@
#include <QtOrganizer/qorganizer.h>
#include <QtOrganizer/qorganizeritemid.h>
-#include <QtOrganizer/qorganizeritemengineid.h>
//TESTED_COMPONENT=src/organizer
QTORGANIZER_USE_NAMESPACE
+
+static inline QOrganizerItemId makeId(const QString &managerName, uint id)
+{
+ return QOrganizerItemId(QStringLiteral("qtorganizer:basic%1:").arg(managerName), QString::number(id));
+}
+
+
class tst_QOrganizerItem: public QObject
{
Q_OBJECT
@@ -556,48 +562,6 @@ void tst_QOrganizerItem::emptiness()
QVERIFY(oi.isEmpty() == true); // type doesn't affect emptiness
}
-class BasicItemLocalId : public QOrganizerItemEngineId
-{
-public:
- BasicItemLocalId(const QString& managerUri, uint id) : m_managerUri(managerUri), m_id(id) {}
- bool isEqualTo(const QOrganizerItemEngineId* other) const {
- if (m_managerUri == static_cast<const BasicItemLocalId*>(other)->m_managerUri)
- return m_id == static_cast<const BasicItemLocalId*>(other)->m_id;
- return false;
- }
- bool isLessThan(const QOrganizerItemEngineId* other) const {
- if (m_managerUri == static_cast<const BasicItemLocalId*>(other)->m_managerUri)
- return m_id < static_cast<const BasicItemLocalId*>(other)->m_id;
- return m_managerUri < static_cast<const BasicItemLocalId*>(other)->m_managerUri;
- }
- QString managerUri() const {
- static const QString uri(QStringLiteral("qtorganizer:basic:"));
- return uri;
- }
- QOrganizerItemEngineId* clone() const {
- BasicItemLocalId* cloned = new BasicItemLocalId(m_managerUri, m_id);
- return cloned;
- }
- QDebug& debugStreamOut(QDebug& dbg) const {
- return dbg << m_managerUri << m_id;
- }
- QString toString() const {
- return m_managerUri + QString("::") + QString::number(m_id);
- }
- uint hash() const {
- return m_id;
- }
-
-private:
- QString m_managerUri;
- uint m_id;
-};
-
-QOrganizerItemId makeId(const QString& managerUri, uint id)
-{
- return QOrganizerItemId(new BasicItemLocalId(managerUri, id));
-}
-
void tst_QOrganizerItem::idComparison()
{
QOrganizerItemId id1(makeId("a", 1));
@@ -608,10 +572,10 @@ void tst_QOrganizerItem::idComparison()
QOrganizerItemId id3(makeId("a", 2));
QOrganizerItemId id4(makeId("b", 1));
QOrganizerItemId id5(makeId(QString(), 2)); // no Uri specified.
- QVERIFY(((id1 < id3) || (id3 < id1)) && (id1 != id3));
- QVERIFY(((id1 < id4) || (id4 < id1)) && (id1 != id4));
- QVERIFY(((id3 < id4) || (id4 < id3)) && (id3 != id4));
- QVERIFY(((id1 < id5) || (id5 < id1)) && (id1 != id5));
+ QVERIFY((((id1 < id3) && !(id3 < id1)) || ((id3 < id1) && !(id1 < id3))) && (id1 != id3));
+ QVERIFY((((id1 < id4) && !(id4 < id1)) || ((id4 < id1) && !(id1 < id4))) && (id1 != id4));
+ QVERIFY((((id3 < id4) && !(id4 < id3)) || ((id4 < id3) && !(id3 < id4))) && (id3 != id4));
+ QVERIFY((((id1 < id5) && !(id5 < id1)) || ((id5 < id1) && !(id1 < id5))) && (id3 != id4));
}
void tst_QOrganizerItem::idHash()
@@ -622,6 +586,7 @@ void tst_QOrganizerItem::idHash()
QOrganizerItemId id4(makeId("a", 2));
// note that the hash function ignores the managerUri
QCOMPARE(qHash(id1), qHash(id2));
+ QCOMPARE(qHash(id1), qHash(id3));
QVERIFY(qHash(id1) != qHash(id4));
QSet<QOrganizerItemId> set;
@@ -921,10 +886,10 @@ void tst_QOrganizerItem::traits()
void tst_QOrganizerItem::idTraits()
{
- QCOMPARE(sizeof(QOrganizerItemId), sizeof(void *));
+ QCOMPARE(sizeof(QOrganizerItemId), 2*sizeof(void *));
QVERIFY(QTypeInfo<QOrganizerItemId>::isComplex);
QVERIFY(!QTypeInfo<QOrganizerItemId>::isStatic);
- QVERIFY(!QTypeInfo<QOrganizerItemId>::isLarge);
+ QVERIFY(QTypeInfo<QOrganizerItemId>::isLarge);
QVERIFY(!QTypeInfo<QOrganizerItemId>::isPointer);
QVERIFY(!QTypeInfo<QOrganizerItemId>::isDummy);
}
diff --git a/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin.cpp b/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin.cpp
index 9ca9d31b4..9142a19cf 100644
--- a/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin.cpp
+++ b/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin.cpp
@@ -237,18 +237,4 @@ QOrganizerManagerEngine *MaliciousEngineFactory::engine(const QMap<QString, QStr
return new MaliciousAsyncManagerEngine();
}
-QOrganizerItemEngineId *MaliciousEngineFactory::createItemEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const
-{
- Q_UNUSED(parameters);
- Q_UNUSED(engineIdString);
- return 0;
-}
-
-QOrganizerCollectionEngineId *MaliciousEngineFactory::createCollectionEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const
-{
- Q_UNUSED(parameters);
- Q_UNUSED(engineIdString);
- return 0;
-}
-
#include "maliciousplugin.moc"
diff --git a/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h b/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h
index ee8612ae1..b547104db 100644
--- a/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h
+++ b/tests/auto/organizer/qorganizeritemasync/maliciousplugin/maliciousplugin_p.h
@@ -194,8 +194,6 @@ class MaliciousEngineFactory : public QOrganizerManagerEngineFactory
public:
QString managerName() const;
QOrganizerManagerEngine *engine(const QMap<QString, QString> &parameters, QOrganizerManager::Error *error);
- QOrganizerItemEngineId *createItemEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const;
- QOrganizerCollectionEngineId *createCollectionEngineId(const QMap<QString, QString> &parameters, const QString &engineIdString) const;
private:
MaliciousAsyncManagerEngine mame;
diff --git a/tests/auto/organizer/qorganizeritemfilter/tst_qorganizeritemfilter.cpp b/tests/auto/organizer/qorganizeritemfilter/tst_qorganizeritemfilter.cpp
index c48d47525..037e05c35 100644
--- a/tests/auto/organizer/qorganizeritemfilter/tst_qorganizeritemfilter.cpp
+++ b/tests/auto/organizer/qorganizeritemfilter/tst_qorganizeritemfilter.cpp
@@ -42,7 +42,6 @@
#include <QtCore/QMetaType>
#include <QtOrganizer/qorganizer.h>
-#include <QtOrganizer/qorganizeritemengineid.h>
//TESTED_COMPONENT=src/organizer
@@ -52,6 +51,17 @@ Q_DECLARE_METATYPE(QOrganizerItem)
Q_DECLARE_METATYPE(QOrganizerItemFilter)
Q_DECLARE_METATYPE(QOrganizerItemDetailFieldFilter)
+static inline QOrganizerItemId makeItemId(uint id)
+{
+ return QOrganizerItemId(QStringLiteral("qtorganizer:basic:"), QString::number(id));
+}
+
+static inline QOrganizerCollectionId makeCollectionId(uint id)
+{
+ return QOrganizerCollectionId(QStringLiteral("qtorganizer:basic:"), QString::number(id));
+}
+
+
class tst_QOrganizerItemFilter : public QObject
{
Q_OBJECT
@@ -86,80 +96,6 @@ private slots:
void testDebugStreamOut_data();
};
-class BasicItemLocalId : public QOrganizerItemEngineId
-{
-public:
- BasicItemLocalId(uint id) : m_id(id) {}
- bool isEqualTo(const QOrganizerItemEngineId* other) const {
- return m_id == static_cast<const BasicItemLocalId*>(other)->m_id;
- }
- bool isLessThan(const QOrganizerItemEngineId* other) const {
- return m_id < static_cast<const BasicItemLocalId*>(other)->m_id;
- }
- QOrganizerItemEngineId* clone() const {
- BasicItemLocalId* cloned = new BasicItemLocalId(m_id);
- return cloned;
- }
- QString managerUri() const {
- static const QString uri(QStringLiteral("qtorganizer:basicItem:"));
- return uri;
- }
- QDebug& debugStreamOut(QDebug& dbg) const {
- return dbg << m_id;
- }
- QString toString() const {
- return QString::number(m_id);
- }
- uint hash() const {
- return m_id;
- }
-
-private:
- uint m_id;
-};
-
-class BasicCollectionLocalId : public QOrganizerCollectionEngineId
-{
-public:
- BasicCollectionLocalId(uint id) : m_id(id) {}
- bool isEqualTo(const QOrganizerCollectionEngineId* other) const {
- return m_id == static_cast<const BasicCollectionLocalId*>(other)->m_id;
- }
- bool isLessThan(const QOrganizerCollectionEngineId* other) const {
- return m_id < static_cast<const BasicCollectionLocalId*>(other)->m_id;
- }
- QOrganizerCollectionEngineId* clone() const {
- BasicCollectionLocalId* cloned = new BasicCollectionLocalId(m_id);
- return cloned;
- }
- QString managerUri() const {
- static const QString uri(QStringLiteral("qtorganizer:basicCollection:"));
- return uri;
- }
- QDebug& debugStreamOut(QDebug& dbg) const {
- return dbg << m_id;
- }
- QString toString() const {
- return QString::number(m_id);
- }
- uint hash() const {
- return m_id;
- }
-
-private:
- uint m_id;
-};
-
-QOrganizerItemId makeId(uint id)
-{
- return QOrganizerItemId(new BasicItemLocalId(id));
-}
-
-QOrganizerCollectionId makeCId(uint id)
-{
- return QOrganizerCollectionId(new BasicCollectionLocalId(id));
-}
-
tst_QOrganizerItemFilter::tst_QOrganizerItemFilter()
{
}
@@ -751,7 +687,7 @@ void tst_QOrganizerItemFilter::idListFilter()
QVERIFY(idf.ids().count() == 0);
QList<QOrganizerItemId> ids;
- ids << makeId(5) << makeId(6) << makeId(17);
+ ids << makeItemId(5) << makeItemId(6) << makeItemId(17);
idf.setIds(ids);
QVERIFY(idf.ids() == ids);
@@ -759,7 +695,7 @@ void tst_QOrganizerItemFilter::idListFilter()
idf.setIds(QList<QOrganizerItemId>());
QVERIFY(idf.ids().count() == 0);
- QOrganizerItemId singleId = makeId(12);
+ QOrganizerItemId singleId = makeItemId(12);
idf.insert(singleId);
QVERIFY(idf.ids().contains(singleId));
idf.remove(singleId);
@@ -804,10 +740,10 @@ void tst_QOrganizerItemFilter::collectionFilter()
QVERIFY(icf.collectionIds().isEmpty());
- QOrganizerCollectionId id1 = makeCId(5);
- QOrganizerCollectionId id2 = makeCId(6);
- QOrganizerCollectionId id3 = makeCId(7);
- QOrganizerCollectionId id4 = makeCId(12);
+ QOrganizerCollectionId id1 = makeCollectionId(5);
+ QOrganizerCollectionId id2 = makeCollectionId(6);
+ QOrganizerCollectionId id3 = makeCollectionId(7);
+ QOrganizerCollectionId id4 = makeCollectionId(12);
QSet<QOrganizerCollectionId> ids;
ids << id1 << id2 << id3;
@@ -966,7 +902,7 @@ void tst_QOrganizerItemFilter::canonicalizedFilter_data()
{
QOrganizerItemIdFilter qclif;
- qclif.setIds(QList<QOrganizerItemId>() << makeId(1) << makeId(2));
+ qclif.setIds(QList<QOrganizerItemId>() << makeItemId(1) << makeItemId(2));
QTest::newRow("Normal local id filter")
<< static_cast<QOrganizerItemFilter>(qclif)
<< static_cast<QOrganizerItemFilter>(qclif);
@@ -1236,39 +1172,39 @@ void tst_QOrganizerItemFilter::testDebugStreamOut_data()
{
QOrganizerItemCollectionFilter filter;
- QOrganizerCollectionId id1 = makeCId(5);
- QOrganizerCollectionId id2 = makeCId(6);
- QOrganizerCollectionId id3 = makeCId(7);
- QOrganizerCollectionId id4 = makeCId(12);
+ QOrganizerCollectionId id1 = makeCollectionId(5);
+ QOrganizerCollectionId id2 = makeCollectionId(6);
+ QOrganizerCollectionId id3 = makeCollectionId(7);
+ QOrganizerCollectionId id4 = makeCollectionId(12);
QSet<QOrganizerCollectionId> ids;
ids << id1 << id2 << id3;
filter.setCollectionIds(ids);
// Testing method setCollectionIds
- QTest::newRow("collection") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(5), QOrganizerCollectionId(6), QOrganizerCollectionId(7))))";
+ QTest::newRow("collection") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(\"qtorganizer:basic::5\"), QOrganizerCollectionId(\"qtorganizer:basic::6\"), QOrganizerCollectionId(\"qtorganizer:basic::7\"))))";
filter.setCollectionId(id2);
// Testing method setCollectionId (and the related clearing of the collection)
- QTest::newRow("collection") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(6))))";
+ QTest::newRow("collection") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(\"qtorganizer:basic::6\"))))";
filter.setCollectionId(id4);
// Testing again method setCollectionId (and the related clearing of the collection)
- QTest::newRow("collection") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(12))))";
+ QTest::newRow("collection") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(\"qtorganizer:basic::12\"))))";
ids.clear();
ids << id4;
// Testing again method setCollectionIds
- QTest::newRow("collection") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(12))))";
+ QTest::newRow("collection") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(\"qtorganizer:basic::12\"))))";
QOrganizerItemCollectionFilter filter2;
filter2 = filter;
// Testing again method setCollectionIds on the copied filter
- QTest::newRow("collection") << (QOrganizerItemFilter)filter2 << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(12))))";
+ QTest::newRow("collection") << (QOrganizerItemFilter)filter2 << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(\"qtorganizer:basic::12\"))))";
QOrganizerItemFilter fil;
fil = filter;
// Testing that the assignment/conversion went fine
- QTest::newRow("collection") << (QOrganizerItemFilter)fil << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(12))))";
+ QTest::newRow("collection") << (QOrganizerItemFilter)fil << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(\"qtorganizer:basic::12\"))))";
QOrganizerItemCollectionFilter filter3(fil);
- QTest::newRow("collection") << (QOrganizerItemFilter)filter3 << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(12))))";
+ QTest::newRow("collection") << (QOrganizerItemFilter)filter3 << "QOrganizerItemFilter(QOrganizerItemCollectionFilter(collectionIds=(QOrganizerCollectionId(\"qtorganizer:basic::12\"))))";
}
{
@@ -1350,18 +1286,18 @@ void tst_QOrganizerItemFilter::testDebugStreamOut_data()
// Testing the method setIds
QList<QOrganizerItemId> ids;
- ids << makeId(5) << makeId(6) << makeId(17);
+ ids << makeItemId(5) << makeItemId(6) << makeItemId(17);
filter.setIds(ids);
- QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(5), QOrganizerItemId(6), QOrganizerItemId(17))))";
+ QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(\"qtorganizer:basic::5\"), QOrganizerItemId(\"qtorganizer:basic::6\"), QOrganizerItemId(\"qtorganizer:basic::17\"))))";
// Resetting the list of Ids
filter.setIds(QList<QOrganizerItemId>());
QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=()))";
// Testing the method insert
- QOrganizerItemId singleId = makeId(12);
+ QOrganizerItemId singleId = makeItemId(12);
filter.insert(singleId);
- QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(12))))";
+ QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(\"qtorganizer:basic::12\"))))";
// Testing the method remove
filter.remove(singleId);
@@ -1376,28 +1312,28 @@ void tst_QOrganizerItemFilter::testDebugStreamOut_data()
// Test op=
filter.setIds(ids);
QOrganizerItemFilter f = filter;
- QTest::newRow("Id") << (QOrganizerItemFilter)f << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(5), QOrganizerItemId(6), QOrganizerItemId(17))))";
+ QTest::newRow("Id") << (QOrganizerItemFilter)f << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(\"qtorganizer:basic::5\"), QOrganizerItemId(\"qtorganizer:basic::6\"), QOrganizerItemId(\"qtorganizer:basic::17\"))))";
QOrganizerItemIdFilter filter2 = f;
- QTest::newRow("Id") << (QOrganizerItemFilter)filter2 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(5), QOrganizerItemId(6), QOrganizerItemId(17))))";
+ QTest::newRow("Id") << (QOrganizerItemFilter)filter2 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(\"qtorganizer:basic::5\"), QOrganizerItemId(\"qtorganizer:basic::6\"), QOrganizerItemId(\"qtorganizer:basic::17\"))))";
filter2 = filter;
- QTest::newRow("Id") << (QOrganizerItemFilter)filter2 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(5), QOrganizerItemId(6), QOrganizerItemId(17))))";
+ QTest::newRow("Id") << (QOrganizerItemFilter)filter2 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(\"qtorganizer:basic::5\"), QOrganizerItemId(\"qtorganizer:basic::6\"), QOrganizerItemId(\"qtorganizer:basic::17\"))))";
// Self assignment should do nothing
filter2 = filter2;
- QTest::newRow("Id") << (QOrganizerItemFilter)filter2 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(5), QOrganizerItemId(6), QOrganizerItemId(17))))";
+ QTest::newRow("Id") << (QOrganizerItemFilter)filter2 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(\"qtorganizer:basic::5\"), QOrganizerItemId(\"qtorganizer:basic::6\"), QOrganizerItemId(\"qtorganizer:basic::17\"))))";
QOrganizerItemDetailFieldFilter dfil;
QOrganizerItemIdFilter filter3(dfil);
QTest::newRow("Id") << (QOrganizerItemFilter)filter3 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=()))";
QOrganizerItemIdFilter filter4(filter);
- QTest::newRow("Id") << (QOrganizerItemFilter)filter4 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(5), QOrganizerItemId(6), QOrganizerItemId(17))))";
+ QTest::newRow("Id") << (QOrganizerItemFilter)filter4 << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(\"qtorganizer:basic::5\"), QOrganizerItemId(\"qtorganizer:basic::6\"), QOrganizerItemId(\"qtorganizer:basic::17\"))))";
filter = dfil; // now assign.
QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=()))";
QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=()))";
filter = filter3;
filter.setIds(ids); // force a detach
- QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(5), QOrganizerItemId(6), QOrganizerItemId(17))))";
+ QTest::newRow("Id") << (QOrganizerItemFilter)filter << "QOrganizerItemFilter(QOrganizerItemIdFilter(ids=(QOrganizerItemId(\"qtorganizer:basic::5\"), QOrganizerItemId(\"qtorganizer:basic::6\"), QOrganizerItemId(\"qtorganizer:basic::17\"))))";
}
{
diff --git a/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp b/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
index 0721ffcfd..b74ac72fb 100644
--- a/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
+++ b/tests/auto/organizer/qorganizermanager/tst_qorganizermanager.cpp
@@ -51,8 +51,6 @@
#include <QtOrganizer/qorganizernote.h>
#include <QtOrganizer/qorganizerevent.h>
-#include <QtOrganizer/qorganizeritemengineid.h>
-
QTORGANIZER_USE_NAMESPACE
// to get QFETCH to work with the template expression...
@@ -70,6 +68,17 @@ Q_DECLARE_METATYPE(QOrganizerManager::Error)
Q_DECLARE_METATYPE(QList<QDate>)
Q_DECLARE_METATYPE(QList<QOrganizerItemDetail::DetailType>);
+static inline QOrganizerItemId makeItemId(uint id)
+{
+ return QOrganizerItemId(QStringLiteral("qtorganizer:basic:"), QString::number(id));
+}
+
+static inline QOrganizerCollectionId makeCollectionId(uint id)
+{
+ return QOrganizerCollectionId(QStringLiteral("qtorganizer:basic:"), QString::number(id));
+}
+
+
class tst_QOrganizerManager : public QObject
{
Q_OBJECT
@@ -202,80 +211,6 @@ private slots:
void testVersion();
};
-class BasicItemLocalId : public QOrganizerItemEngineId
-{
-public:
- BasicItemLocalId(uint id) : m_id(id) {}
- bool isEqualTo(const QOrganizerItemEngineId* other) const {
- return m_id == static_cast<const BasicItemLocalId*>(other)->m_id;
- }
- bool isLessThan(const QOrganizerItemEngineId* other) const {
- return m_id < static_cast<const BasicItemLocalId*>(other)->m_id;
- }
- QOrganizerItemEngineId* clone() const {
- BasicItemLocalId* cloned = new BasicItemLocalId(m_id);
- return cloned;
- }
- QString managerUri() const {
- static const QString uri(QStringLiteral("qtorganizer:basicItem:"));
- return uri;
- }
- QDebug& debugStreamOut(QDebug& dbg) const {
- return dbg << m_id;
- }
- QString toString() const {
- return QString::number(m_id);
- }
- uint hash() const {
- return m_id;
- }
-
-private:
- uint m_id;
-};
-
-class BasicCollectionLocalId : public QOrganizerCollectionEngineId
-{
-public:
- BasicCollectionLocalId(uint id) : m_id(id) {}
- bool isEqualTo(const QOrganizerCollectionEngineId* other) const {
- return m_id == static_cast<const BasicCollectionLocalId*>(other)->m_id;
- }
- bool isLessThan(const QOrganizerCollectionEngineId* other) const {
- return m_id < static_cast<const BasicCollectionLocalId*>(other)->m_id;
- }
- QOrganizerCollectionEngineId* clone() const {
- BasicCollectionLocalId* cloned = new BasicCollectionLocalId(m_id);
- return cloned;
- }
- QString managerUri() const {
- static const QString uri(QStringLiteral("qtorganizer:basicCollection:"));
- return uri;
- }
- QDebug& debugStreamOut(QDebug& dbg) const {
- return dbg << m_id;
- }
- QString toString() const {
- return QString::number(m_id);
- }
- uint hash() const {
- return m_id;
- }
-
-private:
- uint m_id;
-};
-
-QOrganizerItemId makeItemId(uint id)
-{
- return QOrganizerItemId(new BasicItemLocalId(id));
-}
-
-QOrganizerCollectionId makeCollectionId(uint id)
-{
- return QOrganizerCollectionId(new BasicCollectionLocalId(id));
-}
-
tst_QOrganizerManager::tst_QOrganizerManager()
{
}