[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:07:04 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=7a92e14
The following commit has been merged in the master branch:
commit 7a92e14e1527d958b187dd7dd29e95222af603af
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Wed Aug 28 18:52:15 2013 +0100
Add namespace function isKPeopleEnabled
Add namespace function isKPeopleEnabled. This makes it easier for apps
to do runtime checking similar to that originally in the ContactsModel.
REVIEW: 112344
---
KTp/CMakeLists.txt | 2 ++
KTp/Models/contacts-model.cpp | 22 +++++++------------
tests/model-view.h => KTp/core.cpp | 44 ++++++++++++++++++++++----------------
tests/model-view.h => KTp/core.h | 30 +++++++-------------------
KTp/types.h | 2 ++
5 files changed, 46 insertions(+), 54 deletions(-)
diff --git a/KTp/CMakeLists.txt b/KTp/CMakeLists.txt
index 89b0721..ec1760d 100644
--- a/KTp/CMakeLists.txt
+++ b/KTp/CMakeLists.txt
@@ -10,6 +10,7 @@ set (ktp_common_internals_private_SRCS
circular-countdown.cpp
contact.cpp
contact-factory.cpp
+ core.cpp
debug.cpp
error-dictionary.cpp
global-contact-manager.cpp
@@ -40,6 +41,7 @@ set (ktp_common_internals_private_HDRS
contact.h
contact-info-dialog.h
contact-factory.h
+ core.h
debug.h
error-dictionary.h
global-contact-manager.h
diff --git a/KTp/Models/contacts-model.cpp b/KTp/Models/contacts-model.cpp
index b24e4ee..8a1b0d6 100644
--- a/KTp/Models/contacts-model.cpp
+++ b/KTp/Models/contacts-model.cpp
@@ -25,10 +25,11 @@
#include "groups-tree-proxy-model.h"
#include "text-channel-watcher-proxy-model.h"
+#include "core.h"
+
#include <TelepathyQt/ClientRegistrar>
#ifdef HAVE_KPEOPLE
-#include <Nepomuk2/ResourceManager>
#include <KPeople/PersonsModel>
#include <kpeople/personsmodelfeature.h>
#include "kpeopletranslationproxy.h"
@@ -44,7 +45,6 @@ class ContactsModel::Private
public:
GroupMode groupMode;
bool trackUnread;
- bool nepomukEnabled;
QWeakPointer<KTp::AbstractGroupingProxyModel> proxy;
QAbstractItemModel *source;
Tp::AccountManagerPtr accountManager;
@@ -60,11 +60,8 @@ KTp::ContactsModel::ContactsModel(QObject *parent)
{
d->groupMode = NoGrouping;
d->trackUnread = false;
- d->nepomukEnabled = false;
-#ifdef HAVE_KPEOPLE
- d->nepomukEnabled = Nepomuk2::ResourceManager::instance()->initialized();
-
- if (d->nepomukEnabled) {
+ if (KTp::kpeopleEnabled()) {
+ #ifdef HAVE_KPEOPLE
kDebug() << "Nepomuk is enabled, using kpeople model";
KPeople::PersonsModel *personsModel = new KPeople::PersonsModel(this);
@@ -83,8 +80,9 @@ KTp::ContactsModel::ContactsModel(QObject *parent)
<< KPeople::PersonsModelFeature::nicknameModelFeature());
d->source = new KPeopleTranslationProxy(this);
qobject_cast<KPeopleTranslationProxy*>(d->source)->setSourceModel(personsModel);
- } else
-#endif
+ #endif
+ }
+ else
{
kDebug() << "Nepomuk is disabled, using normal model";
d->source = new KTp::ContactsListModel(this);
@@ -104,13 +102,9 @@ void KTp::ContactsModel::setAccountManager(const Tp::AccountManagerPtr &accountM
updateGroupProxyModels();
//set the account manager after we've reloaded the groups so that we don't send a list to the view, only to replace it with a grouped tree
-#ifdef HAVE_KPEOPLE
- if (!d->nepomukEnabled) {
+ if (qobject_cast<ContactsListModel*>(d->source)) {
qobject_cast<ContactsListModel*>(d->source)->setAccountManager(accountManager);
}
-#else
- qobject_cast<ContactsListModel*>(d->source)->setAccountManager(accountManager);
-#endif
}
Tp::AccountManagerPtr KTp::ContactsModel::accountManager() const
diff --git a/tests/model-view.h b/KTp/core.cpp
similarity index 55%
copy from tests/model-view.h
copy to KTp/core.cpp
index f0ad9f7..42fbafd 100644
--- a/tests/model-view.h
+++ b/KTp/core.cpp
@@ -1,8 +1,7 @@
/*
- * This file is part of telepathy-kde-models-test-ui
+ * static methods on the KTp namespace
*
- * Copyright (C) 2011 Collabora Ltd. <info at collabora.co.uk>
- * Copyright (C) 2013 David Edmundson <davidedmundson at kde.org>
+ * Copyright (C) 2013 David Edmundson <kde at davidedmundson.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,24 +18,33 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef MAIN_WIDGET_H
-#define MAIN_WIDGET_H
+#include "core.h"
-#include "ui_model-view.h"
-
-#include <QWidget>
-#include <QAbstractItemModel>
-
-class ModelView : public QWidget, protected Ui::MainWidget {
+#ifdef HAVE_KPEOPLE
+#include <Nepomuk2/ResourceManager>
+#endif
- Q_OBJECT
+#include <KGlobal>
+class CorePrivate
+{
public:
- ModelView(QAbstractItemModel *model, QWidget *parent = 0);
- ~ModelView();
-
+ CorePrivate();
+ bool m_kPeopleEnabled;
};
-
-#endif
-
+CorePrivate::CorePrivate()
+ : m_kPeopleEnabled(false)
+{
+ //if built with kpeople support, enable kpeople if Nepomuk is running
+ #ifdef HAVE_KPEOPLE
+ m_kPeopleEnabled = Nepomuk2::ResourceManager::instance()->initialized();
+ #endif
+}
+
+K_GLOBAL_STATIC(CorePrivate, s_instance)
+
+bool KTp::kpeopleEnabled()
+{
+ return s_instance->m_kPeopleEnabled;
+}
diff --git a/tests/model-view.h b/KTp/core.h
similarity index 61%
copy from tests/model-view.h
copy to KTp/core.h
index f0ad9f7..3402fe7 100644
--- a/tests/model-view.h
+++ b/KTp/core.h
@@ -1,8 +1,7 @@
/*
- * This file is part of telepathy-kde-models-test-ui
+ * static methods on the KTp namespace
*
- * Copyright (C) 2011 Collabora Ltd. <info at collabora.co.uk>
- * Copyright (C) 2013 David Edmundson <davidedmundson at kde.org>
+ * Copyright (C) 2013 David Edmundson <kde at davidedmundson.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,24 +18,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef MAIN_WIDGET_H
-#define MAIN_WIDGET_H
+#include <TelepathyQt/Types>
-#include "ui_model-view.h"
-
-#include <QWidget>
-#include <QAbstractItemModel>
-
-class ModelView : public QWidget, protected Ui::MainWidget {
-
- Q_OBJECT
-
-public:
- ModelView(QAbstractItemModel *model, QWidget *parent = 0);
- ~ModelView();
-
-};
-
-
-#endif
+#include <KTp/ktp-export.h>
+namespace KTp
+{
+ KTP_EXPORT bool kpeopleEnabled();
+}
\ No newline at end of file
diff --git a/KTp/types.h b/KTp/types.h
index 7980c3c..e3b350c 100644
--- a/KTp/types.h
+++ b/KTp/types.h
@@ -23,6 +23,8 @@
#include "contact.h"
+#include "core.h"
+
#include <TelepathyQt/Account>
#include <TelepathyQt/AccountManager>
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list