[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:05:06 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=bb9712f
The following commit has been merged in the master branch:
commit bb9712f2b63889387a2e32f8d3ded4342d2f4228
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Wed Mar 28 22:13:13 2012 +0100
Move AddContactDialog to common internals
---
KTp/Widgets/CMakeLists.txt | 6 ++
KTp/Widgets/add-contact-dialog.cpp | 113 +++++++++++++++++++++++++++++++++++++
KTp/Widgets/add-contact-dialog.h | 53 +++++++++++++++++
KTp/Widgets/add-contact-dialog.ui | 45 +++++++++++++++
4 files changed, 217 insertions(+)
diff --git a/KTp/Widgets/CMakeLists.txt b/KTp/Widgets/CMakeLists.txt
index 810af29..3486552 100644
--- a/KTp/Widgets/CMakeLists.txt
+++ b/KTp/Widgets/CMakeLists.txt
@@ -4,10 +4,16 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}
set (ktp_widgets_private_SRCS
contact-grid-widget.cpp
+ add-contact-dialog.cpp
)
set (ktp_widgets_private_HDRS
contact-grid-widget.h
+ add-contact-dialog.h
+)
+
+kde4_add_ui_files (ktp_widgets_private_SRCS
+ add-contact-dialog.ui
)
kde4_add_library (ktpwidgetsprivate SHARED
diff --git a/KTp/Widgets/add-contact-dialog.cpp b/KTp/Widgets/add-contact-dialog.cpp
new file mode 100644
index 0000000..dfbd9aa
--- /dev/null
+++ b/KTp/Widgets/add-contact-dialog.cpp
@@ -0,0 +1,113 @@
+/*
+ * Add contact dialog
+ *
+ * Copyright (C) 2011 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
+ * 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 "add-contact-dialog.h"
+#include "ui_add-contact-dialog.h"
+
+#include <KTp/Models/accounts-model.h>
+#include <KTp/Models/accounts-model-item.h>
+
+#include <QObject>
+#include <QSortFilterProxyModel>
+#include <QDebug>
+
+
+#include <TelepathyQt/Account>
+#include <TelepathyQt/Connection>
+#include <TelepathyQt/ContactManager>
+
+namespace KTp {
+
+/** A filter which only lists connections which accept adding contacts*/
+class SubscribableAccountsModel : public QSortFilterProxyModel
+{
+public:
+ SubscribableAccountsModel(QObject *parent);
+ virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
+};
+
+SubscribableAccountsModel::SubscribableAccountsModel(QObject *parent)
+ : QSortFilterProxyModel(parent)
+{
+}
+
+bool KTp::SubscribableAccountsModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
+{
+ AccountsModelItem* item = sourceModel()->index(source_row, 0, source_parent).data(AccountsModel::ItemRole).value<AccountsModelItem*>();
+
+ if (item) {
+ Tp::AccountPtr account = item->account();
+
+ //if there's no connection we can't add contacts as we have no contactmanager
+ if (! account->connection()) {
+ return false;
+ }
+
+ //only show items which can add a contact (i.e hide accounts like IRC which are online but there's no point listing)
+ if (! account->connection()->contactManager()->canRequestPresenceSubscription()){
+ return false;
+ }
+ }
+ return true;
+}
+
+} //namespace
+
+KTp::AddContactDialog::AddContactDialog(AccountsModel *accountModel, QWidget *parent) :
+ KDialog(parent),
+ ui(new Ui::AddContactDialog)
+{
+ QWidget *widget = new QWidget(this);
+ ui->setupUi(widget);
+ setMainWidget(widget);
+
+ SubscribableAccountsModel *filteredModel = new SubscribableAccountsModel(this);
+ filteredModel->setSourceModel(accountModel);
+ for (int i = 0; i < filteredModel->rowCount(); ++i) {
+ ui->accountCombo->addItem(KIcon(filteredModel->data(filteredModel->index(i, 0), AccountsModel::IconRole).toString()),
+ filteredModel->data(filteredModel->index(i, 0)).toString(),
+ filteredModel->data(filteredModel->index(i, 0), AccountsModel::ItemRole));
+ }
+
+ ui->screenNameLineEdit->setFocus();
+}
+
+KTp::AddContactDialog::~AddContactDialog()
+{
+ delete ui;
+}
+
+Tp::AccountPtr KTp::AddContactDialog::account() const
+{
+ QVariant itemData = ui->accountCombo->itemData(ui->accountCombo->currentIndex(),AccountsModel::ItemRole);
+ AccountsModelItem* item = itemData.value<AccountsModelItem*>();
+ if (item) {
+ return item->account();
+ } else {
+ return Tp::AccountPtr();
+ }
+}
+
+const QString KTp::AddContactDialog::screenName() const
+{
+ return ui->screenNameLineEdit->text();
+}
+
+#include "add-contact-dialog.moc"
diff --git a/KTp/Widgets/add-contact-dialog.h b/KTp/Widgets/add-contact-dialog.h
new file mode 100644
index 0000000..cc65aa3
--- /dev/null
+++ b/KTp/Widgets/add-contact-dialog.h
@@ -0,0 +1,53 @@
+/*
+ * Add contact dialog
+ *
+ * Copyright (C) 2011 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
+ * 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 ADDCONTACTDIALOG_H
+#define ADDCONTACTDIALOG_H
+
+#include <KDialog>
+
+#include <TelepathyQt/Types>
+
+#include <KTp/ktp-export.h>
+
+namespace Ui {
+ class AddContactDialog;
+}
+
+class AccountsModel;
+
+namespace KTp
+{
+class KTP_EXPORT AddContactDialog : public KDialog
+{
+ Q_OBJECT
+
+public:
+ explicit AddContactDialog(AccountsModel* accountModel, QWidget *parent = 0);
+ virtual ~AddContactDialog();
+ Tp::AccountPtr account() const;
+ const QString screenName() const;
+
+private:
+ Ui::AddContactDialog *ui;
+};
+}
+
+#endif // ADDCONTACTDIALOG_H
diff --git a/KTp/Widgets/add-contact-dialog.ui b/KTp/Widgets/add-contact-dialog.ui
new file mode 100644
index 0000000..616fc71
--- /dev/null
+++ b/KTp/Widgets/add-contact-dialog.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AddContactDialog</class>
+ <widget class="QWidget" name="AddContactDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Account:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KComboBox" name="accountCombo"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Screen Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="KLineEdit" name="screenNameLineEdit"/>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>klineedit.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list