[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:01:21 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=d2969fa

The following commit has been merged in the master branch:
commit d2969fa850ec3caf273dd7569f7a004721c2c69b
Author: Florian Reinhard <florian.reinhard at googlemail.com>
Date:   Fri Jan 6 00:42:33 2012 +0100

    SimpleProfileSelectWidget: make sure the selected profile has the ConnectionManager installed.
    
    ProfileSelectWidget and SimpleProfileSelectWidget now share ProfileListModel which already did all sanity-checks on Profiles for ProfileSelectWidget.
    
    BUG: 290637
    REVIEW: 103592
    Reviewed-by: David Edmundson <kde at davidedmundson.co.uk>
---
 src/KCMTelepathyAccounts/CMakeLists.txt            |  1 +
 src/KCMTelepathyAccounts/profile-list-model.cpp    | 36 ++++++++++++++---
 src/KCMTelepathyAccounts/profile-list-model.h      | 12 +++---
 src/KCMTelepathyAccounts/profile-select-widget.cpp | 31 ++-------------
 src/KCMTelepathyAccounts/profile-select-widget.h   |  4 +-
 .../simple-profile-select-widget.cpp               | 46 +++-------------------
 .../simple-profile-select-widget.h                 |  4 +-
 src/add-account-assistant.cpp                      |  9 ++++-
 8 files changed, 59 insertions(+), 84 deletions(-)

diff --git a/src/KCMTelepathyAccounts/CMakeLists.txt b/src/KCMTelepathyAccounts/CMakeLists.txt
index d886b45..e19f3ac 100644
--- a/src/KCMTelepathyAccounts/CMakeLists.txt
+++ b/src/KCMTelepathyAccounts/CMakeLists.txt
@@ -34,6 +34,7 @@ set (libktpaccountskcminternal_HDRS
      account-edit-widget.h
      plugin-macros.h
      plugin-manager.h
+     profile-list-model.h
      profile-select-widget.h
      simple-profile-select-widget.h
      profile-item.h
diff --git a/src/KCMTelepathyAccounts/profile-list-model.cpp b/src/KCMTelepathyAccounts/profile-list-model.cpp
index 6c4b08a..458916e 100644
--- a/src/KCMTelepathyAccounts/profile-list-model.cpp
+++ b/src/KCMTelepathyAccounts/profile-list-model.cpp
@@ -23,21 +23,41 @@
 
 #include "profile-item.h"
 
+#include <TelepathyQt/Feature>
+#include <TelepathyQt/PendingReady>
 #include <TelepathyQt/ProfileManager>
 #include <TelepathyQt/PendingStringList>
 
+#include <KDebug>
 #include <KIcon>
 
 ProfileListModel::ProfileListModel(QObject *parent)
  : QAbstractListModel(parent)
 {
     m_profileItems.clear();
+    m_profileManager = Tp::ProfileManager::create(QDBusConnection::sessionBus());
+    // FIXME: Until all distros ship correct profile files, we should fake them
+    connect(m_profileManager->becomeReady(Tp::Features() << Tp::ProfileManager::FeatureFakeProfiles),
+            SIGNAL(finished(Tp::PendingOperation*)),
+            this,
+            SLOT(onProfileManagerReady(Tp::PendingOperation*)));
 }
 
 ProfileListModel::~ProfileListModel()
 {
 }
 
+void ProfileListModel::onProfileManagerReady(Tp::PendingOperation *op)
+{
+    // Check the pending operation completed successfully.
+    if (op->isError()) {
+        kDebug() << "becomeReady() failed:" << op->errorName() << op->errorMessage();
+        return;
+    }
+    Tp::PendingStringList* pendingNames = Tp::ConnectionManager::listNames();
+    connect(pendingNames, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onConnectionManagerNamesFetched(Tp::PendingOperation*)));
+}
+
 int ProfileListModel::rowCount(const QModelIndex &index) const
 {
     // If the index is the root item, then return the row count.
@@ -76,16 +96,20 @@ QVariant ProfileListModel::data(const QModelIndex &index, int role) const
     return data;
 }
 
-void ProfileListModel::setProfileManager(Tp::ProfileManagerPtr profileManager)
+ProfileItem *ProfileListModel::itemForIndex(const QModelIndex &index) const
 {
-    m_profileManager = profileManager;
-    Tp::PendingStringList* pendingNames = Tp::ConnectionManager::listNames();
-    connect(pendingNames, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onConnectionManagerNamesFetched(Tp::PendingOperation*)));
+    return m_profileItems.at(index.row());
 }
 
-ProfileItem *ProfileListModel::itemForIndex(const QModelIndex &index) const
+ProfileItem *ProfileListModel::itemForService(const QString &serviceName) const
 {
-    return m_profileItems.at(index.row());
+    Q_FOREACH (ProfileItem *profileItem, m_profileItems) {
+        if (profileItem->serviceName() == serviceName) {
+            return profileItem;
+        }
+    }
+
+    return 0;
 }
 
 bool ProfileListModel::hasNonFakeProfile(const Tp::ProfilePtr& profile, const QList<Tp::ProfilePtr> &profiles) const
diff --git a/src/KCMTelepathyAccounts/profile-list-model.h b/src/KCMTelepathyAccounts/profile-list-model.h
index e3c7cdd..d133ffc 100644
--- a/src/KCMTelepathyAccounts/profile-list-model.h
+++ b/src/KCMTelepathyAccounts/profile-list-model.h
@@ -19,8 +19,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_ACCOUNTS_KCM_PROFILE_LIST_MODEL_H
-#define TELEPATHY_ACCOUNTS_KCM_PROFILE_LIST_MODEL_H
+#ifndef LIB_KCM_TELEPATHY_ACCOUNTS_PROFILE_LIST_MODEL_H
+#define LIB_KCM_TELEPATHY_ACCOUNTS_PROFILE_LIST_MODEL_H
+
+#include "kcm_telepathy_accounts_export.h"
 
 #include <QtCore/QAbstractListModel>
 
@@ -32,7 +34,7 @@ namespace TelepathyQt {
 
 class ProfileItem;
 
-class ProfileListModel : public QAbstractListModel
+class KCM_TELEPATHY_ACCOUNTS_EXPORT ProfileListModel : public QAbstractListModel
 {
     Q_OBJECT
     Q_DISABLE_COPY(ProfileListModel);
@@ -50,11 +52,11 @@ public:
     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
     ProfileItem *itemForIndex(const QModelIndex &index) const;
-
-    void setProfileManager(Tp::ProfileManagerPtr profileManager);
+    ProfileItem *itemForService(const QString &serviceName) const;
 
 private Q_SLOTS:
     void onConnectionManagerNamesFetched(Tp::PendingOperation*);
+    void onProfileManagerReady(Tp::PendingOperation *op);
 
 private:
     bool hasNonFakeProfile(const Tp::ProfilePtr &profile, const QList<Tp::ProfilePtr> &profiles) const;
diff --git a/src/KCMTelepathyAccounts/profile-select-widget.cpp b/src/KCMTelepathyAccounts/profile-select-widget.cpp
index be0d41f..df5f6ee 100644
--- a/src/KCMTelepathyAccounts/profile-select-widget.cpp
+++ b/src/KCMTelepathyAccounts/profile-select-widget.cpp
@@ -28,10 +28,6 @@
 
 #include <KDebug>
 
-#include <TelepathyQt/PendingReady>
-#include <TelepathyQt/ProfileManager>
-#include <TelepathyQt/Feature>
-
 #include <QtGui/QSortFilterProxyModel>
 #include <QtGui/QItemSelectionModel>
 
@@ -39,25 +35,24 @@ class ProfileSelectWidget::Private
 {
 public:
     Private()
-     : profileManager(0),
-       ui(0),
+     : ui(0),
        sortModel(0),
        sourceModel(0)
     {
     }
 
-    Tp::ProfileManagerPtr profileManager;
     Ui::ProfileSelectWidget *ui;
     QSortFilterProxyModel *sortModel;
     ProfileListModel *sourceModel;
 };
 
-ProfileSelectWidget::ProfileSelectWidget(QWidget *parent, bool enableSalut)
+ProfileSelectWidget::ProfileSelectWidget(ProfileListModel *profileListModel, QWidget *parent, bool enableSalut)
  : QWidget(parent),
    d(new Private)
 {
+    (void)profileListModel;
     // Set up the models
-    d->sourceModel = new ProfileListModel(this);
+    d->sourceModel = profileListModel;
     d->sortModel = new QSortFilterProxyModel(this);
     d->sortModel->setSourceModel(d->sourceModel);
     d->sortModel->sort(0, Qt::AscendingOrder);
@@ -83,13 +78,6 @@ ProfileSelectWidget::ProfileSelectWidget(QWidget *parent, bool enableSalut)
     connect(d->ui->profileListView,
             SIGNAL(doubleClicked(QModelIndex)),
             SIGNAL(profileChosen()));
-
-    d->profileManager = Tp::ProfileManager::create(QDBusConnection::sessionBus());
-
-    // FIXME: Until all distros ship correct profile files, we should fake them
-    connect(d->profileManager->becomeReady(Tp::Features() << Tp::ProfileManager::FeatureFakeProfiles),
-            SIGNAL(finished(Tp::PendingOperation*)),
-            SLOT(onProfileManagerReady(Tp::PendingOperation*)));
 }
 
 ProfileSelectWidget::~ProfileSelectWidget()
@@ -98,17 +86,6 @@ ProfileSelectWidget::~ProfileSelectWidget()
     delete d;
 }
 
-void ProfileSelectWidget::onProfileManagerReady(Tp::PendingOperation *op)
-{
-    // Check the pending operation completed successfully.
-    if (op->isError()) {
-        kDebug() << "becomeReady() failed:" << op->errorName() << op->errorMessage();
-        return;
-    }
-
-    d->sourceModel->setProfileManager(d->profileManager);
-}
-
 // Return the selected ProfileItem or 0 if nothing is selected.
 ProfileItem *ProfileSelectWidget::selectedProfile()
 {
diff --git a/src/KCMTelepathyAccounts/profile-select-widget.h b/src/KCMTelepathyAccounts/profile-select-widget.h
index 8f3ad2a..39036c1 100644
--- a/src/KCMTelepathyAccounts/profile-select-widget.h
+++ b/src/KCMTelepathyAccounts/profile-select-widget.h
@@ -23,6 +23,7 @@
 #define TELEPATHY_ACCOUNTS_KCM_PROFILE_SELECT_WIDGET_H
 
 #include "kcm_telepathy_accounts_export.h"
+#include "profile-list-model.h"
 
 #include <QtGui/QWidget>
 
@@ -40,13 +41,12 @@ class KCM_TELEPATHY_ACCOUNTS_EXPORT ProfileSelectWidget : public QWidget
     Q_OBJECT
 
 public:
-    explicit ProfileSelectWidget(QWidget *parent = 0, bool enableSalut = false);
+    explicit ProfileSelectWidget(ProfileListModel *sprofileListModel, QWidget *parent = 0, bool enableSalut = false);
     ~ProfileSelectWidget();
 
     ProfileItem *selectedProfile();
 
 private Q_SLOTS:
-    void onProfileManagerReady(Tp::PendingOperation *op);
     void onSelectionChanged(const QItemSelection &selected);
 
 Q_SIGNALS:
diff --git a/src/KCMTelepathyAccounts/simple-profile-select-widget.cpp b/src/KCMTelepathyAccounts/simple-profile-select-widget.cpp
index 5bb708d..8f3ec90 100644
--- a/src/KCMTelepathyAccounts/simple-profile-select-widget.cpp
+++ b/src/KCMTelepathyAccounts/simple-profile-select-widget.cpp
@@ -41,25 +41,24 @@ class SimpleProfileSelectWidget::Private
 {
 public:
     Private()
-     : profileManager(0),
+     : profileListModel(0),
        ui(0),
-       signalMapper(0),
-       profileItem(0)
+       signalMapper(0)
     {
     }
 
-    Tp::ProfileManagerPtr profileManager;
+    ProfileListModel *profileListModel;
     Ui::SimpleProfileSelectWidget *ui;
     QSignalMapper *signalMapper;
-    ProfileItem *profileItem;
     QString profileName;
 };
 
-SimpleProfileSelectWidget::SimpleProfileSelectWidget(QWidget *parent)
+SimpleProfileSelectWidget::SimpleProfileSelectWidget(ProfileListModel *profileListModel, QWidget *parent)
  : QWidget(parent),
    d(new Private)
 {
     // Set up the models
+    d->profileListModel = profileListModel;
     d->signalMapper = new QSignalMapper(this);
 
     // Set up the widget
@@ -120,13 +119,6 @@ SimpleProfileSelectWidget::SimpleProfileSelectWidget(QWidget *parent)
 
     // Disable everything until Tp::ProfileManager is ready
     d->ui->verticalLayout->setEnabled(false);
-
-    d->profileManager = Tp::ProfileManager::create(QDBusConnection::sessionBus());
-
-    // FIXME: Until all distros ship correct profile files, we should fake them
-    connect(d->profileManager->becomeReady(Tp::Features() << Tp::ProfileManager::FeatureFakeProfiles),
-            SIGNAL(finished(Tp::PendingOperation*)),
-            SLOT(onProfileManagerReady(Tp::PendingOperation*)));
 }
 
 SimpleProfileSelectWidget::~SimpleProfileSelectWidget()
@@ -135,36 +127,10 @@ SimpleProfileSelectWidget::~SimpleProfileSelectWidget()
     delete d;
 }
 
-void SimpleProfileSelectWidget::onProfileManagerReady(Tp::PendingOperation *op)
-{
-    // Check the pending operation completed successfully.
-    if (op->isError()) {
-        kDebug() << "becomeReady() failed:" << op->errorName() << op->errorMessage();
-        return;
-    }
-    else {
-        // Enable the buttons
-        d->ui->verticalLayout->setEnabled(true);
-    }
-}
-
 // Return the selected ProfileItem or 0 if nothing is selected.
 ProfileItem *SimpleProfileSelectWidget::selectedProfile()
 {
-    delete d->profileItem;
-    d->profileItem = NULL;
-
-    Tp::ProfilePtr profilePtr = d->profileManager->profileForService(d->profileName);
-
-    if (profilePtr.isNull()) {
-        kDebug() << "Profile is missing, we need to install some packages here.";
-        return 0;
-    }
-    else {
-        d->profileItem = new ProfileItem(profilePtr, this);
-        return d->profileItem;
-    }
-
+   return d->profileListModel->itemForService(d->profileName);
 }
 
 // FIXME: before we proceed here, we should check if there's everything installed we need.
diff --git a/src/KCMTelepathyAccounts/simple-profile-select-widget.h b/src/KCMTelepathyAccounts/simple-profile-select-widget.h
index 88caa0a..52eede1 100644
--- a/src/KCMTelepathyAccounts/simple-profile-select-widget.h
+++ b/src/KCMTelepathyAccounts/simple-profile-select-widget.h
@@ -22,6 +22,7 @@
 #define TELEPATHY_ACCOUNTS_KCM_SIMPLE_PROFILE_SELECT_WIDGET_H
 
 #include "kcm_telepathy_accounts_export.h"
+#include "profile-list-model.h"
 
 #include <QtGui/QWidget>
 
@@ -39,13 +40,12 @@ class KCM_TELEPATHY_ACCOUNTS_EXPORT SimpleProfileSelectWidget : public QWidget
     Q_OBJECT
 
 public:
-    explicit SimpleProfileSelectWidget(QWidget *parent = 0);
+    explicit SimpleProfileSelectWidget(ProfileListModel *profileListModel, QWidget *parent = 0);
     ~SimpleProfileSelectWidget();
 
     ProfileItem *selectedProfile();
 
 private Q_SLOTS:
-    void onProfileManagerReady(Tp::PendingOperation *op);
     void onProfileClicked(QString profileName);
 
 Q_SIGNALS:
diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index 3f189b4..3023cf9 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -29,6 +29,7 @@
 #include "KCMTelepathyAccounts/account-edit-widget.h"
 #include "KCMTelepathyAccounts/plugin-manager.h"
 #include "KCMTelepathyAccounts/profile-item.h"
+#include "KCMTelepathyAccounts/profile-list-model.h"
 #include "KCMTelepathyAccounts/profile-select-widget.h"
 #include "KCMTelepathyAccounts/simple-profile-select-widget.h"
 
@@ -50,7 +51,9 @@ class AddAccountAssistant::Private
 public:
     Private()
      : currentProfileItem(0),
+       profileListModel(0),
        profileSelectWidget(0),
+       simpleProfileSelectWidget(0),
        accountEditWidget(0),
        pageOne(0),
        pageTwo(0),
@@ -61,6 +64,7 @@ public:
     Tp::AccountManagerPtr accountManager;
     Tp::ConnectionManagerPtr connectionManager;
     ProfileItem *currentProfileItem;
+    ProfileListModel *profileListModel;
     ProfileSelectWidget *profileSelectWidget;
     SimpleProfileSelectWidget *simpleProfileSelectWidget;
     AccountEditWidget *accountEditWidget;
@@ -77,8 +81,9 @@ AddAccountAssistant::AddAccountAssistant(Tp::AccountManagerPtr accountManager, Q
     d->accountManager = accountManager;
 
     // Set up the pages of the Assistant.
-    d->profileSelectWidget       = new ProfileSelectWidget(this);
-    d->simpleProfileSelectWidget = new SimpleProfileSelectWidget(this);
+    d->profileListModel          = new ProfileListModel(this);
+    d->profileSelectWidget       = new ProfileSelectWidget(d->profileListModel, this, true);
+    d->simpleProfileSelectWidget = new SimpleProfileSelectWidget(d->profileListModel, this);
     d->pageOne = new KPageWidgetItem(d->simpleProfileSelectWidget);
     d->pageTwo = new KPageWidgetItem(d->profileSelectWidget);
 

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list