Source

Target

Commits (4)
Showing with 1683 additions and 4 deletions
......@@ -312,7 +312,7 @@ void CalendarDemo::addEvents()
QList<QOrganizerItem> items;
// Create a large number of events asynchronously
QOrganizerCollectionId defaultCollectionId = m_manager->defaultCollection().id();
QOrganizerCollectionId defaultCollectionId = m_manager->defaultCollectionId();
for(int index=0 ; index < 100 ; index++) {
QOrganizerItem item;
item.setType(QOrganizerItemType::TypeEvent);
......@@ -494,7 +494,7 @@ void CalendarDemo::deleteAllEntries()
void CalendarDemo::addCalendar()
{
// Get default collection
QOrganizerCollection defaultCollection = m_manager->defaultCollection();
QOrganizerCollection defaultCollection = m_manager->collection(m_manager->defaultCollectionId());
QOrganizerCollection newCollection = defaultCollection;
newCollection.setId(QOrganizerCollectionId()); // reset collection id
......
......@@ -19,6 +19,9 @@ PUBLIC_HEADERS += \
qcontactactionfactory.h \
qcontactactiontarget.h \
qcontactchangeset.h \
qcontactcollection.h \
qcontactcollectionchangeset.h \
qcontactcollectionid.h \
qcontactdetail.h \
qcontactfetchhint.h \
qcontactfilter.h \
......@@ -39,6 +42,8 @@ PRIVATE_HEADERS += \
qcontactactionmanager_p.h \
qcontactactiontarget_p.h \
qcontactchangeset_p.h \
qcontactcollection_p.h \
qcontactcollectionchangeset_p.h \
qcontactdetail_p.h \
qcontactfetchhint_p.h \
qcontactfilter_p.h \
......@@ -56,6 +61,9 @@ SOURCES += \
qcontactactionmanager_p.cpp \
qcontactactiontarget.cpp \
qcontactchangeset.cpp \
qcontactcollection.cpp \
qcontactcollectionchangeset.cpp \
qcontactcollectionid.cpp \
qcontactdetail.cpp \
qcontactfetchhint.cpp \
qcontactfilter.cpp \
......
......@@ -3,6 +3,7 @@ INCLUDEPATH += filters
PUBLIC_HEADERS += \
filters/qcontactactionfilter.h \
filters/qcontactchangelogfilter.h \
filters/qcontactcollectionfilter.h \
filters/qcontactdetailfilter.h \
filters/qcontactdetailrangefilter.h \
filters/qcontactfilters.h \
......@@ -15,6 +16,7 @@ PUBLIC_HEADERS += \
PRIVATE_HEADERS += \
filters/qcontactactionfilter_p.h \
filters/qcontactchangelogfilter_p.h \
filters/qcontactcollectionfilter_p.h \
filters/qcontactdetailfilter_p.h \
filters/qcontactdetailrangefilter_p.h \
filters/qcontactidfilter_p.h \
......@@ -25,6 +27,7 @@ PRIVATE_HEADERS += \
SOURCES += \
filters/qcontactactionfilter.cpp \
filters/qcontactchangelogfilter.cpp \
filters/qcontactcollectionfilter.cpp \
filters/qcontactdetailfilter.cpp \
filters/qcontactdetailrangefilter.cpp \
filters/qcontactidfilter.cpp \
......
/****************************************************************************
**
** Copyright (C) 2015 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$
**
****************************************************************************/
#include "qcontactcollectionfilter.h"
#include "qcontactcollectionfilter_p.h"
QT_BEGIN_NAMESPACE_CONTACTS
/*!
\class QContactCollectionFilter
\brief The QContactCollectionFilter class provides a filter based around the collection one
contact belongs to.
\inmodule QtContacts
\ingroup contacts-filters
It may be used to select contacts belonging to certain collections.
*/
Q_IMPLEMENT_CONTACTFILTER_PRIVATE(QContactCollectionFilter)
/*!
\fn QContactCollectionFilter::QContactCollectionFilter(const QContactCollectionFilter &other)
Constructs a copy of \a other if possible, otherwise constructs a new contact collection filter.
*/
/*!
Constructs a new contact collection filter.
*/
QContactCollectionFilter::QContactCollectionFilter()
: QContactFilter(new QContactCollectionFilterPrivate)
{
}
/*!
Sets the \a id of the collection, which the contacts should belong to.
*/
void QContactCollectionFilter::setCollectionId(const QContactCollectionId &id)
{
Q_D(QContactCollectionFilter);
d->m_ids.clear();
d->m_ids.insert(id);
}
/*!
Sets the list of collection \a ids, which the contacts should belong to.
*/
void QContactCollectionFilter::setCollectionIds(const QSet<QContactCollectionId> &ids)
{
Q_D(QContactCollectionFilter);
d->m_ids = ids;
}
/*!
Returns the list of collection IDs of contacts should belong to.
*/
QSet<QContactCollectionId> QContactCollectionFilter::collectionIds() const
{
Q_D(const QContactCollectionFilter);
return d->m_ids;
}
QT_END_NAMESPACE_CONTACTS
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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 QCONTACTCOLLECTIONFILTER_H
#define QCONTACTCOLLECTIONFILTER_H
#include <QtCore/qset.h>
#include <QtContacts/qcontactcollectionid.h>
#include <QtContacts/qcontactfilter.h>
QT_BEGIN_NAMESPACE_CONTACTS
class QContactCollectionFilterPrivate;
/* Leaf class */
class Q_CONTACTS_EXPORT QContactCollectionFilter : public QContactFilter
{
public:
QContactCollectionFilter();
QContactCollectionFilter(const QContactFilter &other);
void setCollectionId(const QContactCollectionId &id);
void setCollectionIds(const QSet<QContactCollectionId> &ids);
QSet<QContactCollectionId> collectionIds() const;
private:
Q_DECLARE_CONTACTFILTER_PRIVATE(QContactCollectionFilter)
};
QT_END_NAMESPACE_CONTACTS
#endif // QCONTACTCOLLECTIONFILTER_H
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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 QCONTACTCOLLECTIONFILTER_P_H
#define QCONTACTCOLLECTIONFILTER_P_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.
//
#include <QtContacts/qcontactcollectionfilter.h>
#include <QtContacts/private/qcontactfilter_p.h>
#include <algorithm>
QT_BEGIN_NAMESPACE_CONTACTS
class QContactCollectionFilterPrivate : public QContactFilterPrivate
{
public:
QContactCollectionFilterPrivate()
: QContactFilterPrivate()
{
}
QContactCollectionFilterPrivate(const QContactCollectionFilterPrivate &other)
: QContactFilterPrivate(other), m_ids(other.m_ids)
{
}
virtual bool compare(const QContactFilterPrivate *other) const
{
const QContactCollectionFilterPrivate *od = static_cast<const QContactCollectionFilterPrivate *>(other);
if (od)
return m_ids == od->m_ids;
return false;
}
#ifndef QT_NO_DATASTREAM
QDataStream &outputToStream(QDataStream &stream, quint8 formatVersion) const
{
if (formatVersion == 1)
stream << m_ids;
return stream;
}
QDataStream &inputFromStream(QDataStream &stream, quint8 formatVersion)
{
if (formatVersion == 1)
stream >> m_ids;
return stream;
}
#endif // QT_NO_DATASTREAM
#ifndef QT_NO_DEBUG_STREAM
QDebug &debugStreamOut(QDebug &dbg) const
{
dbg.nospace() << "QContactCollectionFilter(collectionIds=";
QList<QContactCollectionId> ids(m_ids.toList());
std::sort(ids.begin(), ids.end());
dbg.nospace() << ids;
dbg.nospace() << ")";
return dbg.maybeSpace();
}
#endif // QT_NO_DEBUG_STREAM
Q_IMPLEMENT_CONTACTFILTER_VIRTUALCTORS(QContactCollectionFilter, QContactFilter::CollectionFilter)
QSet<QContactCollectionId> m_ids;
};
QT_END_NAMESPACE_CONTACTS
#endif // QCONTACTCOLLECTIONFILTER_P_H
......@@ -47,6 +47,7 @@
#include <QtContacts/qcontactactionfilter.h>
#include <QtContacts/qcontactchangelogfilter.h>
#include <QtContacts/qcontactcollectionfilter.h>
#include <QtContacts/qcontactdetailfilter.h>
#include <QtContacts/qcontactdetailrangefilter.h>
#include <QtContacts/qcontactidfilter.h>
......
......@@ -670,6 +670,16 @@ QList<QContactId> QContact::relatedContacts(const QString& relationshipType, QCo
return retn;
}
QContactCollectionId QContact::collectionId() const
{
return d->m_collectionId;
}
void QContact::setCollectionId(const QContactCollectionId &collectionId)
{
d->m_collectionId = collectionId;
}
/*!
* Return a list of descriptors for the actions available to be performed on this contact.
*
......
......@@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE_CONTACTS
class QContactActionDescriptor;
class QContactId;
class QContactManager;
class QContactCollectionId;
class QContactData;
class Q_CONTACTS_EXPORT QContact
......@@ -115,6 +116,9 @@ public:
QList<QContactRelationship> relationships(const QString& relationshipType = QString()) const;
QList<QContactId> relatedContacts(const QString& relationshipType = QString(), QContactRelationship::Role role = QContactRelationship::Either) const;
QContactCollectionId collectionId() const;
void setCollectionId(const QContactCollectionId &collectionId);
/* Actions available to be performed on this contact */
QList<QContactActionDescriptor> availableActions(const QString& serviceName = QString()) const;
......
......@@ -61,6 +61,7 @@
#include <QtContacts/qcontactdetail.h>
#include <QtContacts/qcontactid.h>
#include <QtContacts/qcontactrelationship.h>
#include <QtContacts/qcontactcollectionid.h>
QT_BEGIN_NAMESPACE_CONTACTS
......@@ -75,6 +76,7 @@ public:
QContactData(const QContactData& other)
: QSharedData(other),
m_id(other.m_id),
m_collectionId(other.m_collectionId),
m_details(other.m_details),
m_relationshipsCache(other.m_relationshipsCache),
m_preferences(other.m_preferences)
......@@ -84,6 +86,7 @@ public:
~QContactData() {}
QContactId m_id;
QContactCollectionId m_collectionId;
QList<QContactDetail> m_details;
QList<QContactRelationship> m_relationshipsCache;
QMap<QString, int> m_preferences;
......
......@@ -84,7 +84,10 @@ public:
RelationshipFetchRequest,
RelationshipRemoveRequest,
RelationshipSaveRequest,
ContactFetchByIdRequest
ContactFetchByIdRequest,
CollectionFetchRequest,
CollectionRemoveRequest,
CollectionSaveRequest,
};
RequestType type() const;
......
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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$
**
****************************************************************************/
#include "qcontactcollection.h"
#include "qcontactcollection_p.h"
#ifndef QT_NO_DATASTREAM
#include <QtCore/qdatastream.h>
#endif
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
#endif
QT_BEGIN_NAMESPACE_CONTACTS
/*!
\class QContactCollection
\brief The QContactCollection class represents a collection of contacts in a manager.
\inmodule QtContacts
\ingroup contacts-main
A collection has an ID and optionally some metadata, and contains zero or more contacts.
Each different manager will have different requirements before a collection may be saved
in it. Some managers do not allow collections to be saved at all, while others may require
a collection to have some minimal amount of metadata defined in it prior to save.
For example, most managers require a valid value for the QContactCollection::KeyName
meta data key to be set prior to save.
Every QContact is contained within a collection when stored in a manager.
To save an contact in a collection, the client should call QContact::setCollectionId()
on the contact, passing in the ID of the destination collection as the argument, and then
save the contact in the manager. To move an contact from one collection to another, the client
must fetch the contact from the manager, set the collection ID in the contact to the ID of the
collection to which the client wishes the contact to be moved, and then resave the contact in the
manager. That is, the collection which a contact is part of is treated as a property of the
contact.
*/
/*!
\enum QContactCollection::MetaDataKey
This enumeration describes the key of the contact collection metadata.
\value KeyName This metadata describes the name of the collection.
\value KeyDescription This metadata gives a description of the collection.
\value KeyColor This metadata describes the color of the collection.
\value KeySecondaryColor This metadata describes the secondary color of the collection.
\value KeyImage This metadata describes the image of the collection.
\value KeyExtended This is an extened metadata, which is stored as a QVariantMap.
*/
/*!
Constructs a new collection.
*/
QContactCollection::QContactCollection()
: d(new QContactCollectionData)
{
}
/*!
Cleans up any memory in use by the collection.
*/
QContactCollection::~QContactCollection()
{
}
/*!
Constructs a new copy of the \a other collection.
*/
QContactCollection::QContactCollection(const QContactCollection &other)
: d(other.d)
{
}
/*!
Assigns this collection to be equal to the \a other collection.
*/
QContactCollection &QContactCollection::operator=(const QContactCollection &other)
{
d = other.d;
return *this;
}
/*!
Returns true if the collection is the same as that of the \a other collection, false if either
the ID or any of the stored metadata are not the same.
*/
bool QContactCollection::operator==(const QContactCollection &other) const
{
if (d == other.d)
return true;
if (d->m_id != other.d->m_id
|| d->m_metaData.size() != other.d->m_metaData.size()) {
return false;
}
QMap<QContactCollection::MetaDataKey, QVariant>::const_iterator i = d->m_metaData.constBegin();
while (i != d->m_metaData.constEnd()) {
if (i.value() != other.d->m_metaData.value(i.key()))
return false;
++i;
}
return true;
}
/*!
\fn QContactCollection::operator!=(const QContactCollection &other) const
Returns true if the collection is not the same as the \a other collection.
*/
/*!
Returns the ID of the collection.
*/
QContactCollectionId QContactCollection::id() const
{
return d->m_id;
}
/*!
Sets the ID of the collection to \a id.
If the ID is set to a null (default-constructed) ID, saving the collection will cause the manager
to save the collection as a new collection.
*/
void QContactCollection::setId(const QContactCollectionId &id)
{
d->m_id = id;
}
/*!
Sets the metadata of the collection to be \a metaData.
*/
void QContactCollection::setMetaData(const QMap<QContactCollection::MetaDataKey, QVariant> &metaData)
{
d->m_metaData = metaData;
}
/*!
Returns the meta data of the collection.
*/
QMap<QContactCollection::MetaDataKey, QVariant> QContactCollection::metaData() const
{
return d->m_metaData;
}
/*!
Sets the meta data of the collection for the given \a key to the given \a value.
*/
void QContactCollection::setMetaData(MetaDataKey key, const QVariant &value)
{
d->m_metaData.insert(key, value);
}
/*!
Sets the value of the extended metadata with the given \a key to \a value.
*/
void QContactCollection::setExtendedMetaData(const QString &key, const QVariant &value)
{
QVariantMap variantMap = d->m_metaData.value(QContactCollection::KeyExtended).toMap();
variantMap.insert(key, value);
d->m_metaData.insert(QContactCollection::KeyExtended, variantMap);
}
/*!
Returns the value of extended metadata with the given \a key.
*/
QVariant QContactCollection::extendedMetaData(const QString &key) const
{
return d->m_metaData.value(QContactCollection::KeyExtended).toMap().value(key);
}
/*!
Returns the meta data of the collection for the given \a key.
*/
QVariant QContactCollection::metaData(MetaDataKey key) const
{
return d->m_metaData.value(key);
}
/*!
\relates QContactCollection
Returns the hash value for \a key.
*/
Q_CONTACTS_EXPORT uint qHash(const QContactCollection &key)
{
uint hash = qHash(key.id());
QMap<QContactCollection::MetaDataKey, QVariant>::const_iterator i = key.d->m_metaData.constBegin();
while (i != key.d->m_metaData.constEnd()) {
if (i.key() == QContactCollection::KeyExtended) {
QVariantMap variantMap = i.value().toMap();
QVariantMap::const_iterator j = variantMap.constBegin();
while (j != variantMap.constEnd()) {
hash += QT_PREPEND_NAMESPACE(qHash)(j.key()) + QT_PREPEND_NAMESPACE(qHash)(j.value().toString());
++j;
}
} else {
hash += QT_PREPEND_NAMESPACE(qHash)(i.key()) + QT_PREPEND_NAMESPACE(qHash)(i.value().toString());
}
++i;
}
return hash;
}
#ifndef QT_NO_DEBUG_STREAM
/*!
\relates QContactCollection
Streams the \a collection to the given debug stream \a dbg, and returns the stream.
*/
QDebug operator<<(QDebug dbg, const QContactCollection& collection)
{
dbg.nospace() << "QContactCollection(id=" << collection.id();
QMap<QContactCollection::MetaDataKey, QVariant> metaData = collection.metaData();
QMap<QContactCollection::MetaDataKey, QVariant>::const_iterator i = metaData.constBegin();
while (i != metaData.constEnd()) {
dbg.nospace() << ", " << i.key() << '=' << i.value();
++i;
}
dbg.nospace() << ')';
return dbg.maybeSpace();
}
#endif // QT_NO_DEBUG_STREAM
#ifndef QT_NO_DATASTREAM
/*!
\relates QContactCollection
Writes \a collection to the stream \a out.
*/
QDataStream &operator<<(QDataStream &out, const QContactCollection &collection)
{
quint8 formatVersion = 1;
return out << formatVersion
<< collection.id().toString()
<< collection.metaData();
}
/*!
\relates QContactCollection
Reads a contact collection from stream \a in into \a collection.
*/
QDataStream &operator>>(QDataStream &in, QContactCollection &collection)
{
quint8 formatVersion;
in >> formatVersion;
if (formatVersion == 1) {
QString idString;
QMap<int, QVariant> values;
in >> idString >> values;
collection = QContactCollection();
collection.setId(QContactCollectionId::fromString(idString));
QMap<int, QVariant>::const_iterator i = values.constBegin();
while (i != values.constEnd()) {
collection.setMetaData(static_cast<QContactCollection::MetaDataKey>(i.key()), i.value());
++i;
}
} else {
in.setStatus(QDataStream::ReadCorruptData);
}
return in;
}
#endif // QT_NO_DATASTREAM
QT_END_NAMESPACE_CONTACTS
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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 QCONTACTCOLLECTION_H
#define QCONTACTCOLLECTION_H
#include <QtCore/qmap.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qvariant.h>
#include <QtContacts/qcontactcollectionid.h>
#include <QtContacts/qcontactid.h>
#include <QtContacts/qcontactdetail.h>
#include <QtContacts/qcontacttype.h>
QT_BEGIN_NAMESPACE_CONTACTS
class QContactManagerEngine;
class QContactCollectionData;
class Q_CONTACTS_EXPORT QContactCollection
{
public:
enum MetaDataKey {
KeyName = 0,
KeyDescription,
KeyColor,
KeySecondaryColor,
KeyImage,
KeyExtended
};
QContactCollection();
~QContactCollection();
QContactCollection(const QContactCollection &other);
QContactCollection &operator=(const QContactCollection &other);
bool operator==(const QContactCollection &other) const;
bool operator!=(const QContactCollection &other) const {return !(other == *this);}
QContactCollectionId id() const;
void setId(const QContactCollectionId &id);
void setMetaData(MetaDataKey key, const QVariant &value);
QVariant metaData(MetaDataKey key) const;
void setMetaData(const QMap<QContactCollection::MetaDataKey, QVariant> &metaData);
QMap<QContactCollection::MetaDataKey, QVariant> metaData() const;
void setExtendedMetaData(const QString &key, const QVariant &value);
QVariant extendedMetaData(const QString &key) const;
private:
friend Q_CONTACTS_EXPORT uint qHash(const QContactCollection &key);
friend class QContactManagerEngine;
QSharedDataPointer<QContactCollectionData> d;
};
Q_CONTACTS_EXPORT uint qHash(const QContactCollection &key);
#ifndef QT_NO_DEBUG_STREAM
Q_CONTACTS_EXPORT QDebug operator<<(QDebug dbg, const QContactCollection &collection);
#endif // QT_NO_DEBUG_STREAM
#ifndef QT_NO_DATASTREAM
Q_CONTACTS_EXPORT QDataStream &operator<<(QDataStream &out, const QContactCollection &collection);
Q_CONTACTS_EXPORT QDataStream &operator>>(QDataStream &in, QContactCollection &collection);
#endif // QT_NO_DATASTREAM
QT_END_NAMESPACE_CONTACTS
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(QTCONTACTS_PREPEND_NAMESPACE(QContactCollection), Q_MOVABLE_TYPE);
QT_END_NAMESPACE
#endif // QCONTACTCOLLECTION_H
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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 QCONTACTCOLLECTION_P_H
#define QCONTACTCOLLECTION_P_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.
//
#include <QtCore/qmap.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qvariant.h>
#include <QtContacts/qcontactcollection.h>
#include <QtContacts/qcontactcollectionid.h>
QT_BEGIN_NAMESPACE_CONTACTS
class QContactCollectionData : public QSharedData
{
public:
QContactCollectionData()
: QSharedData()
{
}
QContactCollectionData(const QContactCollectionData &other)
: QSharedData(other), m_metaData(other.m_metaData), m_id(other.m_id)
{
}
~QContactCollectionData()
{
}
QMap<QContactCollection::MetaDataKey, QVariant> m_metaData;
QContactCollectionId m_id;
};
QT_END_NAMESPACE_CONTACTS
#endif // QCONTACTCOLLECTION_P_H
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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$
**
****************************************************************************/
#include "qcontactcollectionchangeset.h"
#include "qcontactcollectionchangeset_p.h"
#include "qcontactmanagerengine.h"
QT_BEGIN_NAMESPACE_CONTACTS
/*!
\class QContactCollectionChangeSet
\brief The QContactCollectionChangeSet class provides a simple API to simplify the emission
of state-change signals for collections from QContactManagerEngine implementations.
\inmodule QtContacts
\ingroup contacts-main
This class should only be used by backend developers.
*/
/*!
Constructs a new change set.
*/
QContactCollectionChangeSet::QContactCollectionChangeSet()
: d(new QContactCollectionChangeSetData)
{
}
/*!
Constructs a copy of the \a other change set.
*/
QContactCollectionChangeSet::QContactCollectionChangeSet(const QContactCollectionChangeSet &other)
: d(other.d)
{
}
/*!
Frees the memory used by this change set.
*/
QContactCollectionChangeSet::~QContactCollectionChangeSet()
{
}
/*!
Assigns this change set to be equal to \a other.
*/
QContactCollectionChangeSet &QContactCollectionChangeSet::operator=(const QContactCollectionChangeSet &other)
{
d = other.d;
return *this;
}
/*!
Sets the data changed flag to \a dataChanged.
If this is set to true prior to calling emitSignals(), only the QContactManagerEngine::dataChanged()
signal will be emitted; otherwise, the appropriate finer-grained signals will be emitted.
*/
void QContactCollectionChangeSet::setDataChanged(bool dataChanged)
{
d->m_dataChanged = dataChanged;
}
/*!
Returns the value of the data changed flag.
*/
bool QContactCollectionChangeSet::dataChanged() const
{
return d->m_dataChanged;
}
/*!
Returns the set of IDs of collections which have been added to the database.
*/
QSet<QContactCollectionId> QContactCollectionChangeSet::addedCollections() const
{
return d->m_addedCollections;
}
/*!
Inserts the given \a collectionId into the set of IDs of collections which have been added to
the database.
*/
void QContactCollectionChangeSet::insertAddedCollection(const QContactCollectionId &collectionId)
{
d->m_addedCollections.insert(collectionId);
d->m_modifiedCollections.append(QPair<QContactCollectionId, QContactManager::Operation>(collectionId, QContactManager::Add));
}
/*!
Inserts each of the given \a collectionIds into the set of IDs of collections which have been
added to the database.
*/
void QContactCollectionChangeSet::insertAddedCollections(const QList<QContactCollectionId> &collectionIds)
{
foreach (const QContactCollectionId &id, collectionIds) {
d->m_addedCollections.insert(id);
d->m_modifiedCollections.append(QPair<QContactCollectionId, QContactManager::Operation>(id, QContactManager::Add));
}
}
/*!
Clears the set of IDs of collections which have been added to the database.
*/
void QContactCollectionChangeSet::clearAddedCollections()
{
d->m_addedCollections.clear();
}
/*!
Returns the set of IDs of collections which have been changed in the database.
*/
QSet<QContactCollectionId> QContactCollectionChangeSet::changedCollections() const
{
return d->m_changedCollections;
}
/*!
Inserts the given \a collectionId into the set of IDs of collections which have been changed in
the database.
*/
void QContactCollectionChangeSet::insertChangedCollection(const QContactCollectionId &collectionId)
{
d->m_changedCollections.insert(collectionId);
d->m_modifiedCollections.append(QPair<QContactCollectionId, QContactManager::Operation>(collectionId, QContactManager::Change));
}
/*!
Inserts each of the given \a collectionIds into the set of IDs of collections which have been
changed in the database.
*/
void QContactCollectionChangeSet::insertChangedCollections(const QList<QContactCollectionId> &collectionIds)
{
foreach (const QContactCollectionId &id, collectionIds) {
d->m_changedCollections.insert(id);
d->m_modifiedCollections.append(QPair<QContactCollectionId, QContactManager::Operation>(id, QContactManager::Change));
}
}
/*!
Clears the set of IDs of collections which have been changed in the database.
*/
void QContactCollectionChangeSet::clearChangedCollections()
{
d->m_changedCollections.clear();
}
/*!
Returns the set of IDs of collections which have been removed from the database.
*/
QSet<QContactCollectionId> QContactCollectionChangeSet::removedCollections() const
{
return d->m_removedCollections;
}
/*!
Inserts the given \a collectionId into the set of IDs of collections which have been removed from
the database.
*/
void QContactCollectionChangeSet::insertRemovedCollection(const QContactCollectionId &collectionId)
{
d->m_removedCollections.insert(collectionId);
d->m_modifiedCollections.append(QPair<QContactCollectionId, QContactManager::Operation>(collectionId, QContactManager::Remove));
}
/*!
Inserts each of the given \a collectionIds into the set of IDs of collections which have been
removed from the database.
*/
void QContactCollectionChangeSet::insertRemovedCollections(const QList<QContactCollectionId> &collectionIds)
{
foreach (const QContactCollectionId &id, collectionIds) {
d->m_removedCollections.insert(id);
d->m_modifiedCollections.append(QPair<QContactCollectionId, QContactManager::Operation>(id, QContactManager::Remove));
}
}
/*!
Clears the set of ids of collections which have been removed from the database.
*/
void QContactCollectionChangeSet::clearRemovedCollections()
{
d->m_removedCollections.clear();
}
/*!
Returns the list of ids of contact collections which have been added, changed or removed from
the database. The list includes information about which database operation was done. The ids and
operations are ordered so that the first operation is first in the list.
*/
QList<QPair<QContactCollectionId, QContactManager::Operation> > QContactCollectionChangeSet::modifiedCollections() const
{
return d->m_modifiedCollections;
}
/*!
Clears the list of ids of contact collections which have been added, changed or removed from the database
*/
void QContactCollectionChangeSet::clearModifiedCollections()
{
d->m_modifiedCollections.clear();
}
/*!
Clears all flags and sets of IDs in this change set.
*/
void QContactCollectionChangeSet::clearAll()
{
d->m_dataChanged = false;
d->m_addedCollections.clear();
d->m_changedCollections.clear();
d->m_removedCollections.clear();
d->m_modifiedCollections.clear();
}
/*!
Emits the appropriate signals from the given \a engine given the state of the change set. Note
that the flags and sets of IDs are not cleared after signals are emitted.
*/
void QContactCollectionChangeSet::emitSignals(QContactManagerEngine *engine) const
{
if (!engine)
return;
if (d->m_dataChanged) {
emit engine->dataChanged();
} else {
if (!d->m_addedCollections.isEmpty())
emit engine->collectionsAdded(d->m_addedCollections.toList());
if (!d->m_changedCollections.isEmpty())
emit engine->collectionsChanged(d->m_changedCollections.toList());
if (!d->m_removedCollections.isEmpty())
emit engine->collectionsRemoved(d->m_removedCollections.toList());
if (!d->m_modifiedCollections.isEmpty())
emit engine->collectionsModified(d->m_modifiedCollections);
}
}
QT_END_NAMESPACE_CONTACTS
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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 QCONTACTCOLLECTIONCHANGESET_H
#define QCONTACTCOLLECTIONCHANGESET_H
#include <QtCore/qlist.h>
#include <QtCore/qset.h>
#include <QtCore/qshareddata.h>
#include <QtContacts/qcontactcollectionid.h>
#include <QtContacts/qcontactmanager.h>
QT_BEGIN_NAMESPACE_CONTACTS
class QContactManagerEngine;
class QContactCollectionChangeSetData;
class Q_CONTACTS_EXPORT QContactCollectionChangeSet
{
public:
QContactCollectionChangeSet();
QContactCollectionChangeSet(const QContactCollectionChangeSet &other);
~QContactCollectionChangeSet();
QContactCollectionChangeSet &operator=(const QContactCollectionChangeSet &other);
void setDataChanged(bool dataChanged);
bool dataChanged() const;
QSet<QContactCollectionId> addedCollections() const;
void insertAddedCollection(const QContactCollectionId &collectionId);
void insertAddedCollections(const QList<QContactCollectionId> &collectionIds);
void clearAddedCollections();
QSet<QContactCollectionId> changedCollections() const;
void insertChangedCollection(const QContactCollectionId &collectionId);
void insertChangedCollections(const QList<QContactCollectionId> &collectionIds);
void clearChangedCollections();
QSet<QContactCollectionId> removedCollections() const;
void insertRemovedCollection(const QContactCollectionId &collectionId);
void insertRemovedCollections(const QList<QContactCollectionId> &collectionIds);
void clearRemovedCollections();
QList<QPair<QContactCollectionId, QContactManager::Operation> > modifiedCollections() const;
void clearModifiedCollections();
void clearAll();
void emitSignals(QContactManagerEngine *engine) const;
private:
QSharedDataPointer<QContactCollectionChangeSetData> d;
};
QT_END_NAMESPACE_CONTACTS
#endif // QCONTACTCOLLECTIONCHANGESET_H
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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 QCONTACTCOLLECTIONCHANGESET_P_H
#define QCONTACTCOLLECTIONCHANGESET_P_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.
//
#include <QtCore/qlist.h>
#include <QtCore/qset.h>
#include <QtCore/qshareddata.h>
#include <QtContacts/qcontactcollectionid.h>
QT_BEGIN_NAMESPACE_CONTACTS
class QContactCollectionChangeSetData : public QSharedData
{
public:
QContactCollectionChangeSetData()
: QSharedData(), m_dataChanged(false)
{
}
QContactCollectionChangeSetData(const QContactCollectionChangeSetData& other)
: QSharedData(other),
m_dataChanged(other.m_dataChanged),
m_addedCollections(other.m_addedCollections),
m_changedCollections(other.m_changedCollections),
m_removedCollections(other.m_removedCollections),
m_modifiedCollections(other.m_modifiedCollections)
{
}
~QContactCollectionChangeSetData()
{
}
bool m_dataChanged;
QSet<QContactCollectionId> m_addedCollections;
QSet<QContactCollectionId> m_changedCollections;
QSet<QContactCollectionId> m_removedCollections;
QList<QPair<QContactCollectionId, QContactManager::Operation> > m_modifiedCollections;
};
QT_END_NAMESPACE_CONTACTS
#endif // QCONTACTCOLLECTIONCHANGESET_P_H
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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$
**
****************************************************************************/
#include "qcontactcollectionid.h"
#ifndef QT_NO_DATASTREAM
#include <QtCore/qdatastream.h>
#endif
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
#endif
#include "qcontactmanager_p.h"
QT_BEGIN_NAMESPACE_CONTACTS
/*!
\class QContactCollectionId
\brief The QContactCollectionId class provides information that uniquely identifies a collection
in a particular manager.
\inmodule QtContact
\ingroup contact-main
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.
An invalid QContactCollectionId has an empty manager URI.
*/
/*!
\fn QContactCollectionId::QContactCollectionId()
Constructs a new, invalid collection ID.
*/
// TODO: Document and remove internal once the correct signature has been determined
/*!
\fn QContactCollectionId::QContactCollectionId(const QString &managerUri, const QByteArray &localId)
\internal
Constructs an ID from the supplied manager URI \a managerUri and the engine
specific \a localId string.
*/
/*!
\fn bool QContactCollectionId::operator==(const QContactCollectionId &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.
*/
/*!
\fn bool QContactCollectionId::operator!=(const QContactCollectionId &other) const
Returns true if either the manager URI or engine specific ID of this
collection ID is different to that of \a other.
*/
/*!
\fn bool operator<(const QContactCollectionId &id1, const QContactCollectionId &id2)
\relates QContactCollectionId
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 QContactCollectionId as a key in a QMap.
*/
/*!
\fn uint qHash(const QContactCollectionId &id)
\relates QContactCollectionId
Returns the hash value for \a id.
*/
/*!
\fn bool QContactCollectionId::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()
*/
/*!
\fn bool QContactCollectionId::isNull() const
Returns true if the engine specific ID part is a null (default constructed);
returns false otherwise.
\sa isValid()
*/
/*!
\fn QString QContactCollectionId::managerUri() const
Returns the URI of the manager which contains the collection identified by this ID.
\sa localId()
*/
/*!
\fn QByteArray QContactCollectionId::localId() const
Returns the collection's engine specific ID part.
\sa managerUri()
*/
/*!
Serializes the collection ID to a string. The format of the string will be:
"qtcontacts:managerName:params:localId", where localId is encoded binary data
formatted as hexadecimal to ensure it is in a printable form.
\sa fromString(), toByteArray()
*/
QString QContactCollectionId::toString() const
{
if (!isNull()) {
// Ensure the localId component has a valid string representation by hex encoding
const QByteArray encodedLocalId(m_localId.toHex());
return QString::fromUtf8(QContactManagerData::buildIdData(m_managerUri, encodedLocalId));
}
return QString();
}
/*!
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(), fromByteArray()
*/
QContactCollectionId QContactCollectionId::fromString(const QString &idString)
{
QString managerUri;
QByteArray localId;
if (QContactManagerData::parseIdData(idString.toUtf8(), 0, 0, &managerUri, &localId)) {
// The localId component must be decoded from hex
return QContactCollectionId(managerUri, QByteArray::fromHex(localId));
}
return QContactCollectionId();
}
/*!
Serializes the collection ID to a byte array.
\sa fromByteArray(), toString()
*/
QByteArray QContactCollectionId::toByteArray() const
{
if (!isNull())
return QContactManagerData::buildIdData(m_managerUri, m_localId);
return QByteArray();
}
/*!
Deserializes the given \a idData. Returns a default-constructed (null)
collection ID if the given \a idData does not contain a valid, serialized collection ID.
\sa toByteArray(), fromString()
*/
QContactCollectionId QContactCollectionId::fromByteArray(const QByteArray &idData)
{
QString managerUri;
QByteArray localId;
if (QContactManagerData::parseIdData(idData, 0, 0, &managerUri, &localId))
return QContactCollectionId(managerUri, localId);
return QContactCollectionId();
}
#ifndef QT_NO_DEBUG_STREAM
/*!
\relates QContactCollectionId
Outputs \a id to the debug stream \a dbg.
*/
QDebug operator<<(QDebug dbg, const QContactCollectionId &id)
{
dbg.nospace() << "QContactCollectionId(" << id.toString().toUtf8().constData() << ")";
return dbg.maybeSpace();
}
#endif // QT_NO_DEBUG_STREAM
#ifndef QT_NO_DATASTREAM
/*!
\relates QContactCollectionId
Streams \a id to the data stream \a out.
*/
QDataStream &operator<<(QDataStream &out, const QContactCollectionId &id)
{
out << id.toByteArray();
return out;
}
/*!
\relates QContactCollectionId
Streams \a id in from the data stream \a in.
*/
QDataStream &operator>>(QDataStream &in, QContactCollectionId &id)
{
QByteArray idData;
in >> idData;
id = QContactCollectionId::fromByteArray(idData);
return in;
}
#endif // QT_NO_DATASTREAM
QT_END_NAMESPACE_CONTACTS
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2015 Canonical Ltd
** 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 QCONTACTCOLLECTIONID_H
#define QCONTACTCOLLECTIONID_H
#include <QtCore/qvariant.h>
#include <QtContacts/qcontactsglobal.h>
QT_BEGIN_NAMESPACE_CONTACTS
class QContactManagerEngine;
class Q_CONTACTS_EXPORT QContactCollectionId
{
public:
inline QContactCollectionId() {}
inline QContactCollectionId(const QString &managerUri, const QByteArray &localId)
: m_managerUri(localId.isEmpty() ? QString() : managerUri),
m_localId(m_managerUri.isEmpty() ? QByteArray() : localId)
{}
// compiler-generated dtor and copy/move ctors/assignment operators are fine!
inline bool operator==(const QContactCollectionId &other) const
{ return localId() == other.localId() && managerUri() == other.managerUri(); }
inline bool operator!=(const QContactCollectionId &other) const
{ return !operator==(other); }
inline bool isNull() const { return m_localId.isEmpty(); }
inline QString managerUri() const { return m_managerUri; }
inline QByteArray localId() const { return m_localId; }
QString toString() const;
static QContactCollectionId fromString(const QString &idString);
QByteArray toByteArray() const;
static QContactCollectionId fromByteArray(const QByteArray &idData);
private:
QString m_managerUri;
QByteArray m_localId;
};
inline bool operator<(const QContactCollectionId &id1, const QContactCollectionId &id2)
{ return id1.managerUri() != id2.managerUri() ? id1.managerUri() < id2.managerUri() : id1.localId() < id2.localId(); }
inline uint qHash(const QContactCollectionId &id)
{ return qHash(id.localId()); }
#ifndef QT_NO_DATASTREAM
Q_CONTACTS_EXPORT QDataStream &operator<<(QDataStream &out, const QContactCollectionId &id);
Q_CONTACTS_EXPORT QDataStream &operator>>(QDataStream &in, QContactCollectionId &id);
#endif
#ifndef QT_NO_DEBUG_STREAM
Q_CONTACTS_EXPORT QDebug operator<<(QDebug dbg, const QContactCollectionId &id);
#endif
QT_END_NAMESPACE_CONTACTS
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(QTCONTACTS_PREPEND_NAMESPACE(QContactCollectionId), Q_MOVABLE_TYPE);
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QTCONTACTS_PREPEND_NAMESPACE(QContactCollectionId))
#endif // QCONTACTCOLLECTIONID_H
......@@ -74,7 +74,8 @@ public:
IntersectionFilter,
UnionFilter,
IdFilter,
DefaultFilter
DefaultFilter,
CollectionFilter
};
FilterType type() const;
......