[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:05:48 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=0d29d3e

The following commit has been merged in the master branch:
commit 0d29d3e7c02c148181e0a64f8c62556e044a91ea
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date:   Wed Apr 6 12:36:04 2011 +0200

    Remove contacts patch
    
    Added a class for the removal of a contact from the contactlist.
    
    REVIEW: David Edmundson
---
 CMakeLists.txt            |   4 +-
 main-widget.cpp           |  46 +++++++++
 main-widget.h             |   3 +
 remove-contact-dialog.cpp |  56 ++++++++++
 remove-contact-dialog.h   |  55 ++++++++++
 remove-contact-dialog.ui  | 255 ++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 418 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d737cf..548e8c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,13 +33,15 @@ set (contactlist_SRCS
      filter-bar.cpp
      main.cpp
      main-widget.cpp
-    add-contact-dialog.cpp
+     add-contact-dialog.cpp
+     remove-contact-dialog.cpp
 )
 
 
 kde4_add_ui_files (contactlist_SRCS
                    main-widget.ui
                    add-contact-dialog.ui
+                   remove-contact-dialog.ui
 )
 
 kde4_add_executable (telepathy-kde-contactlist
diff --git a/main-widget.cpp b/main-widget.cpp
index 99c6761..2e049a1 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -42,6 +42,7 @@
 #include <KDebug>
 #include <KUser>
 #include <KMenu>
+#include <KMessageBox>
 #include <KSettings/Dialog>
 
 #include "main-widget.h"
@@ -53,6 +54,7 @@
 #include "contact-delegate.h"
 #include "contact-model-item.h"
 #include "add-contact-dialog.h"
+#include "remove-contact-dialog.h"
 
 #define PREFERRED_TEXTCHAT_HANDLER "org.freedesktop.Telepathy.Client.KDE.TextUi"
 
@@ -524,6 +526,10 @@ void MainWidget::onCustomContextMenuRequested(const QPoint &)
     }
     menu->addSeparator();
 
+    // remove contact action
+    QAction *removeAction = menu->addAction(KIcon("list-remove-user"), i18n("Remove Contact"));
+    connect(removeAction, SIGNAL(triggered(bool)), this, SLOT(slotDeleteContact()));
+
     if (accountConnection->actualFeatures().contains(Tp::Connection::FeatureRosterGroups)) {
         QMenu* groupAddMenu = menu->addMenu(i18n("Move to Group"));
 
@@ -610,6 +616,7 @@ void MainWidget::slotBlockContactTriggered()
 {
     QModelIndex index = m_contactsListView->currentIndex();
     Tp::ContactPtr contact = m_model->contactForIndex(m_modelFilter->mapToSource(index));
+
     if (contact.isNull()) {
         kDebug() << "Contact is nulled";
         return;
@@ -620,6 +627,45 @@ void MainWidget::slotBlockContactTriggered()
             SLOT(slotBlockContactFinished(Tp::PendingOperation*)));
 }
 
+void MainWidget::slotDeleteContact()
+{
+    QModelIndex index = m_contactsListView->currentIndex();
+    Tp::ContactPtr contact = m_model->contactForIndex(m_modelFilter->mapToSource(index));
+
+    if (contact.isNull()) {
+        kDebug() << "Contact is null";
+        return;
+    }
+
+    QList<Tp::ContactPtr>contactList;
+    contactList.append(contact);
+
+    // ask for confirmation
+    QWeakPointer<RemoveContactDialog> removeDialog = new RemoveContactDialog(contact, this);
+
+    if (removeDialog.data()->exec() == QDialog::Accepted) {
+        // remove from contact list
+        Tp::PendingOperation *deleteOp = contact->manager()->removeContacts(contactList);
+        connect(deleteOp, SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(slotGenericOperationFinished(Tp::PendingOperation*)));
+
+        if (removeDialog.data()->blockContact()) {
+            // block contact
+            Tp::PendingOperation *blockOp = contact->manager()->blockContacts(contactList);
+            connect(blockOp, SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(slotGenericOperationFinished(Tp::PendingOperation*)));
+        }
+    }
+
+    delete removeDialog.data();
+}
+
+void MainWidget::slotGenericOperationFinished(Tp::PendingOperation* operation)
+{
+    if (operation->isError()) {
+        kDebug() << operation->errorName();
+        kDebug() << operation->errorMessage();
+    }
+}
+
 void MainWidget::slotRemoveContactFromGroupFinished(Tp::PendingOperation *operation)
 {
     if (operation->isError()) {
diff --git a/main-widget.h b/main-widget.h
index 6c45763..e310b35 100644
--- a/main-widget.h
+++ b/main-widget.h
@@ -91,6 +91,9 @@ private Q_SLOTS:
     void slotAddContactToGroupTriggered();
     void slotBlockContactFinished(Tp::PendingOperation *operation);
     void slotBlockContactTriggered();
+    void slotDeleteContact();   /** deletes contact from user's contactlist */
+    /** called when a Tp::PendingOperation finishes. Used to check for errors */
+    void slotGenericOperationFinished(Tp::PendingOperation *operation);
     void slotRemoveContactFromGroupFinished(Tp::PendingOperation *operation);
     void slotStartTextChat();
     void slotUnblockContactFinished(Tp::PendingOperation *operation);
diff --git a/remove-contact-dialog.cpp b/remove-contact-dialog.cpp
new file mode 100644
index 0000000..e6c6a86
--- /dev/null
+++ b/remove-contact-dialog.cpp
@@ -0,0 +1,56 @@
+/*
+ * This file is part of telepathy-contactslist
+ *
+ * Copyright (C) 2011 by Francesco Nwokeka <francesco.nwokeka at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "remove-contact-dialog.h"
+#include "ui_remove-contact-dialog.h"
+
+#include <KIcon>
+#include <KLocalizedString>
+
+#include <QtGui/QCheckBox>
+#include <QtGui/QLabel>
+
+#include <TelepathyQt4/AvatarData>
+
+RemoveContactDialog::RemoveContactDialog(Tp::ContactPtr contact, QWidget* parent)
+    : KDialog(parent, Qt::Dialog)
+    , ui(new Ui::RemoveContactDialog)
+{
+    QWidget *removeDialog = new QWidget(this);
+
+    ui->setupUi(removeDialog);
+    setMainWidget(removeDialog);
+
+    ui->textLabel->setText(i18n("Remove the selected contact?"));
+    ui->contactAliasLabel->setText(contact->alias());
+
+    // load contact avatar
+    if (contact->avatarData().fileName.isEmpty()) {
+        KIcon defaultIcon("im-user");       // load KIcon with the desired pixmap
+        ui->contactAvatarLabel->setPixmap(defaultIcon.pixmap(QSize(90, 90)));
+    } else {
+        ui->contactAvatarLabel->setPixmap(contact->avatarData().fileName);
+    }
+}
+
+bool RemoveContactDialog::blockContact() const
+{
+    return ui->blockCheckbox->isChecked();
+}
diff --git a/remove-contact-dialog.h b/remove-contact-dialog.h
new file mode 100644
index 0000000..2af624a
--- /dev/null
+++ b/remove-contact-dialog.h
@@ -0,0 +1,55 @@
+/*
+ * This file is part of telepathy-contactslist
+ *
+ * Copyright (C) 2011 by Francesco Nwokeka <francesco.nwokeka at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef REMOVECONTACTDIALOG_H
+#define REMOVECONTACTDIALOG_H
+
+#include <KDialog>
+
+#include <TelepathyQt4/Contact>
+
+namespace Ui {
+    class RemoveContactDialog;
+}
+
+class AccountsModel;
+
+class RemoveContactDialog : public KDialog
+{
+    Q_OBJECT
+
+public:
+    /**
+     * constructor
+     * @param contact Tp::ContactPtr of the contact to remove
+     * @param parent parent widget
+     */
+    RemoveContactDialog(Tp::ContactPtr contact, QWidget *parent = 0);
+
+    /** returns value of "block contact" checkbox */
+    bool blockContact() const;
+
+
+private:
+    Ui::RemoveContactDialog *ui;
+};
+
+
+#endif  // REMOVECONTACTDIALOG_H
diff --git a/remove-contact-dialog.ui b/remove-contact-dialog.ui
new file mode 100644
index 0000000..f76363b
--- /dev/null
+++ b/remove-contact-dialog.ui
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RemoveContactDialog</class>
+ <widget class="QWidget" name="RemoveContactDialog">
+  <property name="windowModality">
+   <enum>Qt::WindowModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>250</width>
+    <height>250</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle">
+   <string>Remove contact</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="sizeConstraint">
+    <enum>QLayout::SetDefaultConstraint</enum>
+   </property>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_8">
+     <item>
+      <spacer name="horizontalSpacer_10">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QLabel" name="textLabel">
+       <property name="text">
+        <string>Message</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_9">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_5">
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QFrame" name="frame">
+       <property name="frameShape">
+        <enum>QFrame::StyledPanel</enum>
+       </property>
+       <property name="frameShadow">
+        <enum>QFrame::Raised</enum>
+       </property>
+       <property name="midLineWidth">
+        <number>0</number>
+       </property>
+       <layout class="QVBoxLayout" name="verticalLayout_5">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_6">
+          <item>
+           <spacer name="horizontalSpacer_5">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>40</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QLabel" name="contactAvatarLabel">
+            <property name="text">
+             <string>Avatar</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_6">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>40</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_7">
+          <item>
+           <spacer name="horizontalSpacer_7">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>40</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QLabel" name="contactAliasLabel">
+            <property name="text">
+             <string>Alias</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_8">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>40</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+         </layout>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_4">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_9">
+     <item>
+      <spacer name="horizontalSpacer_11">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="blockCheckbox">
+       <property name="text">
+        <string>Block contact</string>
+       </property>
+       <property name="tristate">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_12">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list