Skip to content

Commit

Permalink
Merge branch 'no-private' into 'master'
Browse files Browse the repository at this point in the history
Remove usage of QtContacts private headers

See merge request !7
  • Loading branch information
chriadam committed Nov 7, 2017
2 parents 6c56890 + ae77626 commit 83d0a7d
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 22 deletions.
4 changes: 3 additions & 1 deletion config.pri
@@ -1,2 +1,4 @@
CONFIG += link_pkgconfig
CONFIG += \
c++11 \
link_pkgconfig
PKGCONFIG += Qt5Contacts
1 change: 1 addition & 0 deletions src/engine/contactid.cpp
Expand Up @@ -33,6 +33,7 @@

#include <QContact>
#include <QContactManager>
#include <QDebug>

namespace {

Expand Down
2 changes: 2 additions & 0 deletions src/engine/contactreader.cpp
Expand Up @@ -43,6 +43,7 @@
#include <QContactAnniversary>
#include <QContactAvatar>
#include <QContactBirthday>
#include <QContactDisplayLabel>
#include <QContactEmailAddress>
#include <QContactFamily>
#include <QContactFavorite>
Expand Down Expand Up @@ -70,6 +71,7 @@
#include <QContactChangeLogFilter>
#include <QContactUnionFilter>
#include <QContactIntersectionFilter>
#include <QContactRelationshipFilter>

#include <QContactManagerEngine>

Expand Down
7 changes: 7 additions & 0 deletions src/engine/contactsengine.cpp
Expand Up @@ -49,6 +49,7 @@
#include <QDataStream>

// ---- for schema modification ------
#include <QtContacts/QContactDisplayLabel>
#include <QtContacts/QContactFamily>
#include <QtContacts/QContactGeoLocation>
#include <QtContacts/QContactFavorite>
Expand Down Expand Up @@ -854,10 +855,16 @@ ContactsEngine::ContactsEngine(const QString &name, const QMap<QString, QString>
autoTest.toInt() == 1) {
setAutoTest(true);
}

/* Store the engine into a property of QCoreApplication, so that it can be
* retrieved by the extension code */
QCoreApplication::instance()->setProperty(CONTACT_MANAGER_ENGINE_PROP,
QVariant::fromValue(this));
}

ContactsEngine::~ContactsEngine()
{
QCoreApplication::instance()->setProperty(CONTACT_MANAGER_ENGINE_PROP, 0);
}

QString ContactsEngine::databaseUuid()
Expand Down
1 change: 1 addition & 0 deletions src/engine/contactwriter.cpp
Expand Up @@ -39,6 +39,7 @@
#include "../extensions/qcontactincidental.h"
#include "../extensions/qcontactstatusflags.h"

#include <QContactDisplayLabel>
#include <QContactFavorite>
#include <QContactGender>
#include <QContactGlobalPresence>
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/qtcontacts-extensions.h
Expand Up @@ -108,4 +108,7 @@ ContactManagerEngine *contactManagerEngine(QContactManager &manager);

Q_DECLARE_OPERATORS_FOR_FLAGS(QtContactsSqliteExtensions::NormalizePhoneNumberFlags)

/* We define the name of the QCoreApplication property which holds our ContactsEngine */
#define CONTACT_MANAGER_ENGINE_PROP "qc_sqlite_extension_engine"

#endif
11 changes: 7 additions & 4 deletions src/extensions/qtcontacts-extensions_manager_impl.h
Expand Up @@ -35,15 +35,18 @@
#include <qtcontacts-extensions.h>
#include <contactmanagerengine.h>

// Needed for access to the QContactManager's internal engine
#include <private/qcontactmanager_p.h>
#include <QCoreApplication>
#include <QVariant>

namespace QtContactsSqliteExtensions {

ContactManagerEngine *contactManagerEngine(QContactManager &manager)
{
if (QContactManagerData *data = QContactManagerData::managerData(&manager)) {
return static_cast<QtContactsSqliteExtensions::ContactManagerEngine *>(data->m_engine);
QCoreApplication *app = QCoreApplication::instance();
QVariant v = app->property(CONTACT_MANAGER_ENGINE_PROP);
QContactManagerEngine *engine = static_cast<QContactManagerEngine*>(v.value<QObject*>());
if (engine && engine->managerName() == manager.managerName()) {
return static_cast<QtContactsSqliteExtensions::ContactManagerEngine *>(engine);
}

return 0;
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/twowaycontactsyncadapter.h
Expand Up @@ -35,9 +35,11 @@

#include <QDateTime>
#include <QString>
#include <QHash>
#include <QList>
#include <QPair>
#include <QMap>
#include <QSet>

#include <QContactDetail>
#include <QContact>
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/twowaycontactsyncadapter_impl.h
Expand Up @@ -37,14 +37,14 @@
#include <contactmanagerengine.h>
#include <twowaycontactsyncadapter.h>
#include <qcontactoriginmetadata.h>
#include <private/qcontactmanager_p.h>

#include <QContactManager>
#include <QContactGuid>
#include <QContactSyncTarget>
#include <QContactTimestamp>
#include <QContactUrl>

#include <QDebug>
#include <QLocale>
#include <QDataStream>

Expand Down
2 changes: 0 additions & 2 deletions tests/auto/aggregation/aggregation.pro
@@ -1,8 +1,6 @@
TARGET = tst_aggregation
include(../../common.pri)

QT += contacts-private

INCLUDEPATH += \
../../../src/engine/

Expand Down
2 changes: 1 addition & 1 deletion tests/auto/database/database.pro
Expand Up @@ -2,7 +2,7 @@ include(../../common.pri)

TARGET = tst_database

QT += sql contacts-private
QT += sql

# copied from src/engine/engine.pro, modified for test db
DEFINES += 'QTCONTACTS_SQLITE_PRIVILEGED_DIR=\'\"privileged\"\''
Expand Down
2 changes: 0 additions & 2 deletions tests/auto/memorytable/memorytable.pro
Expand Up @@ -2,8 +2,6 @@ include(../../common.pri)

TARGET = tst_memorytable

QT += contacts-private

HEADERS += \
../../util.h
SOURCES += \
Expand Down
2 changes: 0 additions & 2 deletions tests/auto/phonenumber/phonenumber.pro
Expand Up @@ -2,8 +2,6 @@ include(../../common.pri)

TARGET = tst_phonenumber

QT += contacts-private

HEADERS += \
../../util.h
SOURCES += \
Expand Down
2 changes: 0 additions & 2 deletions tests/auto/qcontactmanager/qcontactmanager.pro
Expand Up @@ -2,8 +2,6 @@ include(../../common.pri)

TARGET = tst_qcontactmanager

QT += contacts-private

INCLUDEPATH += \
../../../src/engine/

Expand Down
3 changes: 0 additions & 3 deletions tests/auto/qcontactmanager/tst_qcontactmanager.cpp
Expand Up @@ -48,9 +48,6 @@
#include "qversitreader.h"
#endif

// Needed for access to the QContactManager's internal engine
#include "private/qcontactmanager_p.h"

#include "../../util.h"
#include "../../qcontactmanagerdataholder.h"

Expand Down
Expand Up @@ -2,8 +2,6 @@ include(../../common.pri)

TARGET = tst_qcontactmanagerfiltering

QT += contacts-private

INCLUDEPATH += \
../../../src/engine/

Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/deltadetection/deltadetection.pro
Expand Up @@ -3,12 +3,12 @@ include(../../../config.pri)
TEMPLATE = app
TARGET = deltadetection

QT += testlib

SOURCES = main.cpp deltasyncadapter.cpp
HEADERS = deltasyncadapter.h ../../../src/extensions/contactmanagerengine.h

INCLUDEPATH += ../../../src/extensions ../../../src/engine/

QT += contacts-private

target.path = /opt/tests/qtcontacts-sqlite-qt5
INSTALLS += target

0 comments on commit 83d0a7d

Please sign in to comment.