[SCM] ktp-contact-applet packaging branch, master, updated. debian/15.12.1-1-966-gde83ac5

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:11:26 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=23ffd45

The following commit has been merged in the master branch:
commit 23ffd45b5d540e818fad00bbbae78f62e8e46be0
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date:   Fri Aug 19 12:43:06 2011 +0200

    Enabled setting of contact to keep trace of
    
    info still needs to be shown by QML
---
 src/config.cpp           | 29 ++++++++++++++++++++++-------
 src/config.h             |  6 ++++++
 src/telepathyContact.cpp | 13 +++++++++++++
 src/telepathyContact.h   |  9 +++++++++
 4 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/src/config.cpp b/src/config.cpp
index c68af9d..a8c0369 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "contactDelegate.h"
 #include "models/accounts-model.h"
+#include "models/contact-model-item.h"
 #include "models/groups-model.h"
 #include "models/accounts-filter-model.h"
 
@@ -42,8 +43,6 @@ Config::Config(QWidget* parent)
     setMainWidget(widget);
 
     Tp::registerTypes();
-//     Tp::enableDebug(KCmdLineArgs::parsedArgs()->isSet("debug"));
-//     Tp::enableWarnings(true);
 
     // setup the telepathy account manager from where I'll retrieve info on accounts and contacts
     Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
@@ -73,7 +72,8 @@ Config::Config(QWidget* parent)
                                                   channelFactory,
                                                   contactFactory);
 
-    connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onAccountManagerReady(Tp::PendingOperation*)));
+    connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(onAccountManagerReady(Tp::PendingOperation*)));
+    connect(this, SIGNAL(buttonClicked(KDialog::ButtonCode)), this, SLOT(slotButtonClicked(int)));
 }
 
 Config::~Config()
@@ -137,15 +137,30 @@ void Config::setupContactsList()
     // disable ok button until a list item is selected
     button(Ok)->setEnabled(false);
 
-    ui.contactsList->setItemDelegate(new ContactDelegate());
     ui.contactsList->header()->hide();
-    ui.contactsList->setExpandsOnDoubleClick(false);
+    ui.contactsList->setRootIsDecorated(false);
+    ui.contactsList->setItemDelegate(new ContactDelegate());
     ui.contactsList->setSortingEnabled(true);
     ui.contactsList->sortByColumn(0, Qt::AscendingOrder);
-//     ui.contactsList->setSelectionMode(QAbstractItemView::SingleSelection);
-//     ui.contactsList->setSelectionBehavior(QAbstractItemView::SelectRows);
+    ui.contactsList->setSelectionMode(QAbstractItemView::SingleSelection);
+    ui.contactsList->setSelectionBehavior(QAbstractItemView::SelectItems);
 
     connect(ui.contactsList, SIGNAL(clicked(QModelIndex)), this, SLOT(activateOkButton()));
     connect(ui.showOfflineContacts, SIGNAL(toggled(bool)), this, SLOT(enableOfflineContacts(bool)));
     connect(ui.showGroups, SIGNAL(toggled(bool)), this, SLOT(enableGroupsView(bool)));
 }
+
+void Config::slotButtonClicked(int button)
+{
+    QModelIndex selectedItem = ui.contactsList->currentIndex();
+
+    if (button == KDialog::Ok && selectedItem.isValid()) {
+        if (selectedItem.data(AccountsModel::ItemRole).userType() == qMetaTypeId<ContactModelItem*>()) {
+            ContactModelItem *item = selectedItem.data(AccountsModel::ItemRole).value<ContactModelItem*>();
+            setNewContact(item->contact());
+            accept();
+        }
+    }
+
+    KDialog::slotButtonClicked(button);
+}
diff --git a/src/config.h b/src/config.h
index f39e314..63357f0 100644
--- a/src/config.h
+++ b/src/config.h
@@ -41,6 +41,12 @@ public:
     Config(QWidget *parent = 0);
     ~Config();
 
+signals:
+    void setNewContact(const Tp::ContactPtr &newContact);
+
+protected slots:
+    void slotButtonClicked(int button);
+
 private slots:
     void activateOkButton();
     void enableGroupsView(bool enable);                     /** enable/disable groups view */
diff --git a/src/telepathyContact.cpp b/src/telepathyContact.cpp
index ec9d5ac..947e0b8 100644
--- a/src/telepathyContact.cpp
+++ b/src/telepathyContact.cpp
@@ -31,12 +31,15 @@ TelepathyContact::TelepathyContact(QObject* parent, const QVariantList& args)
     : Plasma::Applet(parent, args)
     , m_config(new Config())
     , m_declarative(new Plasma::DeclarativeWidget(this))
+    , m_contact(0)
 {
     setBackgroundHints(NoBackground);
     m_declarative->setGeometry(geometry());
 
     // user shouldn't be able to resize the plasmoid
     setAspectRatioMode(Plasma::FixedSize);
+
+    connect(m_config, SIGNAL(setNewContact(Tp::ContactPtr)), this, SLOT(setContact(Tp::ContactPtr)));
 }
 
 TelepathyContact::~TelepathyContact()
@@ -61,6 +64,16 @@ void TelepathyContact::paintInterface(QPainter* p, const QStyleOptionGraphicsIte
     Plasma::Applet::paintInterface(p, option, contentsRect);
 }
 
+void TelepathyContact::setContact(const Tp::ContactPtr& newContact)
+{
+    Q_ASSERT(newContact);
+
+    if (!m_contact || m_contact->id() != newContact->id()) {
+        m_contact = newContact;
+        /// TODO update contact info for QML to read from
+    }
+}
+
 void TelepathyContact::showConfigurationInterface()
 {
     m_config->show();
diff --git a/src/telepathyContact.h b/src/telepathyContact.h
index 1bcda12..5631d44 100644
--- a/src/telepathyContact.h
+++ b/src/telepathyContact.h
@@ -25,6 +25,8 @@
 #include <Plasma/Applet>
 #include <Plasma/DeclarativeWidget>
 
+#include <TelepathyQt4/Contact>
+
 class Config;
 
 class TelepathyContact: public Plasma::Applet
@@ -40,9 +42,16 @@ public:
     /** overide of config signal */
     void showConfigurationInterface();
 
+public slots:
+    /** called from config dialog to set new contact
+     * @param newContact Tp::ContactPtr to the new contact to use
+     */
+    void setContact(const Tp::ContactPtr &newContact);
+
 private:
     Config *m_config;
     Plasma::DeclarativeWidget *m_declarative;
+    Tp::ContactPtr m_contact;
 };
 
 #endif  // TELEPATHY_CONTACT_H
\ No newline at end of file

-- 
ktp-contact-applet packaging



More information about the pkg-kde-commits mailing list