[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:11:36 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=064e9a3
The following commit has been merged in the master branch:
commit 064e9a3412ab9f34953ed58ca49fe1426fb1d7d2
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sat Nov 17 11:04:04 2012 +0900
Deprecate ContactModelItem and start to use KTp::Actions
Remove many usages of ContactModelItem/GroupsModelItem which are being phased out.
Replace calls to starting channels with calling KTp::Actions
REVIEW: 107354
---
contact-list-widget.cpp | 169 +++++-------------------------------------------
contact-list-widget.h | 11 ----
context-menu.cpp | 87 +++++++++++++++----------
main-widget.cpp | 9 +--
4 files changed, 73 insertions(+), 203 deletions(-)
diff --git a/contact-list-widget.cpp b/contact-list-widget.cpp
index a75558a..06323ba 100644
--- a/contact-list-widget.cpp
+++ b/contact-list-widget.cpp
@@ -31,6 +31,7 @@
#include <KTp/Models/contact-model-item.h>
#include <KTp/Models/accounts-model-item.h>
#include <KTp/Models/groups-model-item.h>
+#include <KTp/actions.h>
#include <KGlobal>
#include <KSharedConfig>
@@ -56,11 +57,6 @@
#include "contact-delegate-compact.h"
#include "contact-overlays.h"
-#define PREFERRED_TEXTCHAT_HANDLER "org.freedesktop.Telepathy.Client.KTp.TextUi"
-#define PREFERRED_FILETRANSFER_HANDLER "org.freedesktop.Telepathy.Client.KTp.FileTransfer"
-#define PREFERRED_AUDIO_VIDEO_HANDLER "org.freedesktop.Telepathy.Client.KTp.CallUi"
-#define PREFERRED_RFB_HANDLER "org.freedesktop.Telepathy.Client.krfb_rfb_handler"
-
ContactListWidget::ContactListWidget(QWidget *parent)
: QTreeView(parent),
d_ptr(new ContactListWidgetPrivate)
@@ -205,9 +201,15 @@ void ContactListWidget::onContactListDoubleClicked(const QModelIndex& index)
return;
}
- if (index.data(ContactsModel::ItemRole).userType() == qMetaTypeId<ContactModelItem*>()) {
+ if (index.data(ContactsModel::TypeRole).toInt() == ContactsModel::ContactRowType) {
kDebug() << "Text chat requested for index" << index;
- startTextChannel(index.data(ContactsModel::ItemRole).value<ContactModelItem*>());
+ Tp::ContactPtr contact = index.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ Tp::AccountPtr account = index.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();
+
+ if (contact && account) {
+ Tp::PendingOperation *op = KTp::Actions::startChat(account, contact, true);
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)), SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
+ }
}
}
@@ -300,133 +302,6 @@ void ContactListWidget::toggleSortByPresence(bool sort)
d->modelFilter->setSortMode(sort ? AccountsFilterModel::SortByPresence : AccountsFilterModel::DoNotSort);
}
-void ContactListWidget::startTextChannel(ContactModelItem *contactItem)
-{
- Q_D(ContactListWidget);
-
- Q_ASSERT(contactItem);
- Tp::ContactPtr contact = contactItem->contact();
-
- kDebug() << "Requesting chat for contact" << contact->alias();
-
- Tp::AccountPtr account = d->model->accountForContactItem(contactItem);
-
- Tp::ChannelRequestHints hints;
- hints.setHint("org.freedesktop.Telepathy.ChannelRequest","DelegateToPreferredHandler", QVariant(true));
-
- Tp::PendingChannelRequest *channelRequest = account->ensureTextChat(contact,
- QDateTime::currentDateTime(),
- PREFERRED_TEXTCHAT_HANDLER,
- hints);
- connect(channelRequest, SIGNAL(finished(Tp::PendingOperation*)),
- SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
-}
-
-void ContactListWidget::startAudioChannel(ContactModelItem *contactItem)
-{
- Q_D(ContactListWidget);
-
- Q_ASSERT(contactItem);
- Tp::ContactPtr contact = contactItem->contact();
-
- kDebug() << "Requesting audio for contact" << contact->alias();
-
- Tp::AccountPtr account = d->model->accountForContactItem(contactItem);
-
- Tp::PendingChannelRequest *channelRequest = account->ensureAudioCall(contact,
- QLatin1String("audio"), QDateTime::currentDateTime(), PREFERRED_AUDIO_VIDEO_HANDLER);
-
- connect(channelRequest, SIGNAL(finished(Tp::PendingOperation*)),
- SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
-}
-
-void ContactListWidget::startVideoChannel(ContactModelItem *contactItem)
-{
- Q_D(ContactListWidget);
-
- Q_ASSERT(contactItem);
- Tp::ContactPtr contact = contactItem->contact();
-
- kDebug() << "Requesting video for contact" << contact->alias();
-
- Tp::AccountPtr account = d->model->accountForContactItem(contactItem);
-
- Tp::PendingChannelRequest* channelRequest = account->ensureAudioVideoCall(contact,
- QLatin1String("audio"), QLatin1String("video"),
- QDateTime::currentDateTime(), PREFERRED_AUDIO_VIDEO_HANDLER);
-
- connect(channelRequest, SIGNAL(finished(Tp::PendingOperation*)),
- SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
-}
-
-void ContactListWidget::startDesktopSharing(ContactModelItem* contactItem)
-{
- Q_D(ContactListWidget);
-
- Q_ASSERT(contactItem);
- Tp::ContactPtr contact = contactItem->contact();
-
- kDebug() << "Requesting desktop sharing for contact" << contact->alias();
-
- Tp::AccountPtr account = d->model->accountForContactItem(contactItem);
-
- Tp::PendingChannelRequest* channelRequest = account->createStreamTube(contact,
- QLatin1String("rfb"),
- QDateTime::currentDateTime(),
- PREFERRED_RFB_HANDLER);
-
- connect(channelRequest, SIGNAL(finished(Tp::PendingOperation*)),
- SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
-}
-
-void ContactListWidget::startFileTransferChannel(ContactModelItem *contactItem)
-{
- Q_D(ContactListWidget);
-
- Q_ASSERT(contactItem);
- Tp::ContactPtr contact = contactItem->contact();
-
- kDebug() << "Requesting file transfer for contact" << contact->alias();
-
- Tp::AccountPtr account = d->model->accountForContactItem(contactItem);
-
- QStringList filenames = KFileDialog::getOpenFileNames(KUrl("kfiledialog:///FileTransferLastDirectory"),
- QString(),
- this,
- i18n("Choose files to send to %1", contact->alias()));
-
- if (filenames.isEmpty()) { // User hit cancel button
- return;
- }
-
- QDateTime now = QDateTime::currentDateTime();
-
- requestFileTransferChannels(account, contact, filenames, now);
-}
-
-void ContactListWidget::requestFileTransferChannels(const Tp::AccountPtr& account,
- const Tp::ContactPtr& contact,
- const QStringList& filenames,
- const QDateTime& userActionTime)
-{
- Q_FOREACH (const QString &filename, filenames) {
- kDebug() << "Filename:" << filename;
- kDebug() << "Content type:" << KMimeType::findByFileContent(filename)->name();
-
- Tp::FileTransferChannelCreationProperties fileTransferProperties(filename,
- KMimeType::findByFileContent(filename)->name());
-
- Tp::PendingChannelRequest* channelRequest = account->createFileTransfer(contact,
- fileTransferProperties,
- userActionTime,
- PREFERRED_FILETRANSFER_HANDLER);
-
- connect(channelRequest, SIGNAL(finished(Tp::PendingOperation*)),
- SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
- }
-
-}
-
void ContactListWidget::onNewGroupModelItemsInserted(const QModelIndex& index, int start, int end)
{
Q_UNUSED(start);
@@ -632,27 +507,15 @@ void ContactListWidget::dropEvent(QDropEvent *event)
if (event->mimeData()->hasUrls()) {
kDebug() << "It's a file!";
- ContactModelItem* contactItem = index.data(ContactsModel::ItemRole).value<ContactModelItem*>();
- Q_ASSERT(contactItem);
+ Tp::ContactPtr contact = index.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ Tp::AccountPtr account = index.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();
- Tp::ContactPtr contact = contactItem->contact();
-
- kDebug() << "Requesting file transfer for contact" << contact->alias();
-
- Tp::AccountPtr account = d->model->accountForContactItem(contactItem);
-
- QStringList filenames;
- Q_FOREACH (const QUrl &url, event->mimeData()->urls()) {
- filenames << url.toLocalFile();
- }
-
- if (filenames.isEmpty()) {
- return;
+ if (contact && account) {
+ Q_FOREACH (const QUrl &url, event->mimeData()->urls()) {
+ Tp::PendingOperation *op = KTp::Actions::startFileTransfer(account, contact, url.toLocalFile());
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)), SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
+ }
}
-
- QDateTime now = QDateTime::currentDateTime();
- requestFileTransferChannels(account, contact, filenames, now);
-
event->acceptProposedAction();
} else if (event->mimeData()->hasFormat("application/vnd.telepathy.contact")) {
kDebug() << "It's a contact!";
diff --git a/contact-list-widget.h b/contact-list-widget.h
index 5305e0d..557f48f 100644
--- a/contact-list-widget.h
+++ b/contact-list-widget.h
@@ -67,12 +67,6 @@ private Q_SLOTS:
void onNewGroupModelItemsInserted(const QModelIndex &index, int start, int end);
void addOverlayButtons();
- void startTextChannel(ContactModelItem *contactItem);
- void startFileTransferChannel(ContactModelItem *contactItem);
- void startAudioChannel(ContactModelItem *contactItem);
- void startVideoChannel(ContactModelItem *contactItem);
- void startDesktopSharing(ContactModelItem *contactItem);
-
Q_SIGNALS:
void enableOverlays(bool);
void accountManagerReady(Tp::PendingOperation* op);
@@ -91,11 +85,6 @@ protected:
virtual void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const;
private:
- void requestFileTransferChannels(const Tp::AccountPtr& account,
- const Tp::ContactPtr& contact,
- const QStringList& filenames,
- const QDateTime& userActionTime);
-
void loadGroupStatesFromConfig();
friend class ContextMenu;
diff --git a/context-menu.cpp b/context-menu.cpp
index 85968ce..ff735a5 100644
--- a/context-menu.cpp
+++ b/context-menu.cpp
@@ -27,6 +27,7 @@
#include <KToolInvocation>
#include <KInputDialog>
#include <KMessageBox>
+#include <KFileDialog>
#include <KTp/Models/contacts-model.h>
#include <KTp/Models/contact-model-item.h>
@@ -35,8 +36,11 @@
#include <KTp/Models/groups-model.h>
#include <KTp/text-parser.h>
#include <KTp/Widgets/notificationconfigdialog.h>
+#include <KTp/Models/accounts-filter-model.h>
+#include <KTp/actions.h>
#include <TelepathyQt/ContactManager>
+#include <TelepathyQt/PendingChannelRequest>
#include <TelepathyLoggerQt4/Entity>
#include <TelepathyLoggerQt4/LogManager>
@@ -46,7 +50,6 @@
#include "dialogs/contact-info.h"
#include "contact-list-widget_p.h"
-#include <KTp/Models/accounts-filter-model.h>
ContextMenu::ContextMenu(ContactListWidget *mainWidget)
: QObject(mainWidget)
@@ -81,14 +84,14 @@ KMenu* ContextMenu::contactContextMenu(const QModelIndex &index)
m_currentIndex = index;
- Tp::ContactPtr contact = index.data(ContactsModel::ItemRole).value<ContactModelItem*>()->contact();
+ Tp::ContactPtr contact = index.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
if (contact.isNull()) {
kDebug() << "Contact is nulled";
return 0;
}
- Tp::AccountPtr account = m_mainWidget->d_ptr->model->accountForContactItem(index.data(ContactsModel::ItemRole).value<ContactModelItem*>());
+ Tp::AccountPtr account = index.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();;
if (account.isNull()) {
kDebug() << "Account is nulled";
@@ -312,10 +315,7 @@ KMenu* ContextMenu::groupContextMenu(const QModelIndex &index)
void ContextMenu::onRemoveContactFromGroupTriggered()
{
QString groupName = m_currentIndex.parent().data(GroupsModel::GroupNameRole).toString();
- ContactModelItem *contactItem = m_currentIndex.data(ContactsModel::ItemRole).value<ContactModelItem*>();
-
- Q_ASSERT(contactItem);
- Tp::ContactPtr contact = contactItem->contact();
+ Tp::ContactPtr contact = m_currentIndex.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
Tp::PendingOperation* operation = contact->removeFromGroup(groupName);
@@ -337,9 +337,9 @@ void ContextMenu::onShowInfoTriggered()
return;
}
- ContactModelItem *item = m_currentIndex.data(ContactsModel::ItemRole).value<ContactModelItem*>();
- if (item) {
- QWeakPointer<ContactInfo> contactInfoDialog = new ContactInfo(item->contact(), m_mainWidget);
+ Tp::ContactPtr contact = m_currentIndex.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ if (contact) {
+ QWeakPointer<ContactInfo> contactInfoDialog = new ContactInfo(contact, m_mainWidget);
contactInfoDialog.data()->setAttribute(Qt::WA_DeleteOnClose);
contactInfoDialog.data()->show();
}
@@ -352,9 +352,12 @@ void ContextMenu::onStartTextChatTriggered()
return;
}
- ContactModelItem *item = m_currentIndex.data(ContactsModel::ItemRole).value<ContactModelItem*>();
- if (item) {
- m_mainWidget->startTextChannel(item);
+ Tp::ContactPtr contact = m_currentIndex.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ Tp::AccountPtr account = m_currentIndex.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();
+
+ if (contact && account) {
+ Tp::PendingOperation *op = KTp::Actions::startChat(account, contact, true);
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)), m_mainWidget, SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
}
}
@@ -365,9 +368,12 @@ void ContextMenu::onStartAudioChatTriggered()
return;
}
- ContactModelItem *item = m_currentIndex.data(ContactsModel::ItemRole).value<ContactModelItem*>();
- if (item) {
- m_mainWidget->startAudioChannel(item);
+ Tp::ContactPtr contact = m_currentIndex.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ Tp::AccountPtr account = m_currentIndex.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();
+
+ if (contact && account) {
+ Tp::PendingOperation *op = KTp::Actions::startAudioCall(account, contact);
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)), m_mainWidget, SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
}
}
@@ -378,9 +384,12 @@ void ContextMenu::onStartVideoChatTriggered()
return;
}
- ContactModelItem *item = m_currentIndex.data(ContactsModel::ItemRole).value<ContactModelItem*>();
- if (item) {
- m_mainWidget->startVideoChannel(item);
+ Tp::ContactPtr contact = m_currentIndex.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ Tp::AccountPtr account = m_currentIndex.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();
+
+ if (contact && account) {
+ Tp::PendingOperation *op = KTp::Actions::startAudioVideoCall(account, contact);
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)), m_mainWidget, SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
}
}
@@ -391,9 +400,21 @@ void ContextMenu::onStartFileTransferTriggered()
return;
}
- ContactModelItem *item = m_currentIndex.data(ContactsModel::ItemRole).value<ContactModelItem*>();
- if (item) {
- m_mainWidget->startFileTransferChannel(item);
+ Tp::ContactPtr contact = m_currentIndex.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ Tp::AccountPtr account = m_currentIndex.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();
+
+ if (contact && account) {
+ QStringList fileNames = KFileDialog::getOpenFileNames(KUrl("kfiledialog:///FileTransferLastDirectory"),
+ QString(),
+ m_mainWidget,
+ i18n("Choose files to send to %1", contact->alias()));
+
+ //if user hit cancel fileNames is empty
+
+ Q_FOREACH (const QString &fileName, fileNames) {
+ Tp::PendingOperation *op = KTp::Actions::startFileTransfer(account, contact, fileName);
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)), m_mainWidget, SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
+ }
}
}
@@ -404,9 +425,12 @@ void ContextMenu::onStartDesktopSharingTriggered()
return;
}
- ContactModelItem *item = m_currentIndex.data(ContactsModel::ItemRole).value<ContactModelItem*>();
- if (item) {
- m_mainWidget->startDesktopSharing(item);
+ Tp::ContactPtr contact = m_currentIndex.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ Tp::AccountPtr account = m_currentIndex.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();
+
+ if (contact && account) {
+ Tp::PendingOperation *op = KTp::Actions::startDesktopSharing(account, contact);
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)), m_mainWidget, SIGNAL(genericOperationFinished(Tp::PendingOperation*)));
}
}
@@ -417,15 +441,12 @@ void ContextMenu::onOpenLogViewerTriggered()
return;
}
- ContactModelItem *item = m_currentIndex.data(ContactsModel::ItemRole).value<ContactModelItem*>();
- Q_ASSERT(item);
-
- Tp::ContactPtr contact = item->contact();
- Tp::AccountPtr account = m_mainWidget->d_ptr->model->accountForContactItem(item);
+ Tp::ContactPtr contact = m_currentIndex.data(ContactsModel::ContactRole).value<Tp::ContactPtr>();
+ Tp::AccountPtr account = m_currentIndex.data(ContactsModel::AccountRole).value<Tp::AccountPtr>();
- /* Use "--" so that KCmdLineArgs does not parse UIDs starting with "-" as arguments */
- KToolInvocation::kdeinitExec(QLatin1String("ktp-log-viewer"),
- QStringList() << QLatin1String("--") << account->uniqueIdentifier() << contact->id());
+ if (contact && account) {
+ KTp::Actions::openLogViewer(account, contact);
+ }
}
void ContextMenu::onUnblockContactTriggered()
diff --git a/main-widget.cpp b/main-widget.cpp
index 549553a..112f8f0 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -37,8 +37,6 @@
#include <TelepathyQt/PendingReady>
#include <KTp/Models/contacts-model.h>
-#include <KTp/Models/contact-model-item.h>
-#include <KTp/Models/groups-model-item.h>
#include <KTp/Widgets/add-contact-dialog.h>
#include <KTp/Widgets/join-chat-room-dialog.h>
@@ -367,14 +365,13 @@ void MainWidget::onCustomContextMenuRequested(const QPoint &pos)
return;
}
- Tp::ContactPtr contact;
- QVariant item = index.data(ContactsModel::ItemRole);
+ ContactsModel::RowType type = (ContactsModel::RowType)index.data(ContactsModel::TypeRole).toInt();
KMenu *menu = 0;
- if (item.userType() == qMetaTypeId<ContactModelItem*>()) {
+ if (type == ContactsModel::ContactRowType) {
menu = m_contextMenu->contactContextMenu(index);
- } else if (item.userType() == qMetaTypeId<GroupsModelItem*>()) {
+ } else if (type == ContactsModel::GroupRowType) {
menu = m_contextMenu->groupContextMenu(index);
}
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list