Skip to content

Commit

Permalink
Add aggregateCollectionId() to extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Bea Lam authored and Chris Adams committed Sep 16, 2020
1 parent 8645dc8 commit cc6f435
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
4 changes: 4 additions & 0 deletions src/extensions/qtcontacts-extensions.h
Expand Up @@ -34,6 +34,7 @@
#define QTCONTACTS_EXTENSIONS_H

#include <QContactDetail>
#include <QContactCollectionId>
#include <QContactId>
#include <QContactManager>

Expand Down Expand Up @@ -106,6 +107,9 @@ namespace QtContactsSqliteExtensions {

QTCONTACTS_USE_NAMESPACE

QContactCollectionId aggregateCollectionId(const QString &managerUri);
QContactCollectionId localCollectionId(const QString &managerUri);

QContactId apiContactId(quint32, const QString &managerUri);
quint32 internalContactId(const QContactId &);

Expand Down
10 changes: 10 additions & 0 deletions src/extensions/qtcontacts-extensions_impl.h
Expand Up @@ -178,6 +178,16 @@ QString normalize(const QString &input, int flags, int maxCharacters)

namespace QtContactsSqliteExtensions {

QContactCollectionId aggregateCollectionId(const QString &managerUri)
{
return QContactCollectionId(managerUri, QByteArrayLiteral("col-") + QByteArray::number(1));
}

QContactCollectionId localCollectionId(const QString &managerUri)
{
return QContactCollectionId(managerUri, QByteArrayLiteral("col-") + QByteArray::number(2));
}

QContactId apiContactId(quint32 iid, const QString &managerUri)
{
return QContactId(managerUri, QByteArrayLiteral("sql-") + QByteArray::number(iid));
Expand Down
21 changes: 11 additions & 10 deletions tests/auto/aggregation/tst_aggregation.cpp
Expand Up @@ -33,6 +33,7 @@
#define QT_STATICPLUGIN

#include "../../util.h"
#include "qtcontacts-extensions.h"

#include <QLocale>

Expand All @@ -59,16 +60,6 @@ QString detailProvenanceContact(const QContactDetail &detail)
return provenance.left(provenance.indexOf(QChar::fromLatin1(':')));
}

QByteArray aggregateAddressbookId()
{
return QByteArrayLiteral("col-") + QByteArray::number(1); // AggregateAddressbookCollectionId
}

QByteArray localAddressbookId()
{
return QByteArrayLiteral("col-") + QByteArray::number(2); // LocalAddressbookCollectionId
}

}

class tst_Aggregation : public QObject
Expand Down Expand Up @@ -152,6 +143,16 @@ private slots:
QSet<QContactId> m_chgAccumulatedIds;
QSet<QContactId> m_remAccumulatedIds;
QSet<QContactId> m_createdIds;

QByteArray aggregateAddressbookId()
{
return QtContactsSqliteExtensions::aggregateCollectionId(m_cm->managerUri()).localId();
}

QByteArray localAddressbookId()
{
return QtContactsSqliteExtensions::localCollectionId(m_cm->managerUri()).localId();
}
};

tst_Aggregation::tst_Aggregation()
Expand Down
25 changes: 11 additions & 14 deletions tests/auto/synctransactions/tst_synctransactions.cpp
Expand Up @@ -35,6 +35,7 @@

#include "../../util.h"
#include "testsyncadaptor.h"
#include "qtcontacts-extensions.h"

#include "qcontactcollectionchangesfetchrequest.h"
#include "qcontactcollectionchangesfetchrequest_impl.h"
Expand All @@ -45,20 +46,6 @@
#include "qcontactclearchangeflagsrequest.h"
#include "qcontactclearchangeflagsrequest_impl.h"

namespace {

QByteArray aggregateAddressbookId()
{
return QByteArrayLiteral("col-") + QByteArray::number(1); // AggregateAddressbookCollectionId
}

QByteArray localAddressbookId()
{
return QByteArrayLiteral("col-") + QByteArray::number(2); // LocalAddressbookCollectionId
}

}

class tst_synctransactions : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -96,6 +83,16 @@ private slots:
QContactManager *m_cm;
QSet<QContactCollectionId> m_createdColIds;
QSet<QContactId> m_createdIds;

QByteArray aggregateAddressbookId()
{
return QtContactsSqliteExtensions::aggregateCollectionId(m_cm->managerUri()).localId();
}

QByteArray localAddressbookId()
{
return QtContactsSqliteExtensions::localCollectionId(m_cm->managerUri()).localId();
}
};

tst_synctransactions::tst_synctransactions()
Expand Down

0 comments on commit cc6f435

Please sign in to comment.