[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:17 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=ba2e954
The following commit has been merged in the master branch:
commit ba2e9546b5ba0c9036386337ced260ae8d84adfc
Author: Othmane Moustaouda <othmane.moustaouda at gmail.com>
Date: Sat Sep 8 22:11:55 2012 +0100
Use join chat room dialog from common internals
REVIEW: 104533
---
CMakeLists.txt | 3 -
dialogs/join-chat-room-dialog.cpp | 472 --------------------------------------
dialogs/join-chat-room-dialog.h | 85 -------
dialogs/join-chat-room-dialog.ui | 244 --------------------
main-widget.cpp | 4 +-
rooms-model.cpp | 254 --------------------
rooms-model.h | 129 -----------
7 files changed, 2 insertions(+), 1189 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ffadc0b..7cb36cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,6 @@ include_directories (${KDE4_INCLUDES}
set (ktp_contactlist_SRCS
- rooms-model.cpp
contact-list-widget.cpp
context-menu.cpp
abstract-contact-delegate.cpp
@@ -40,7 +39,6 @@ set (ktp_contactlist_SRCS
main.cpp
main-widget.cpp
global-presence-chooser.cpp
- dialogs/join-chat-room-dialog.cpp
dialogs/remove-contact-dialog.cpp
dialogs/contact-info.cpp
dialogs/custom-presence-dialog.cpp
@@ -54,7 +52,6 @@ set (ktp_contactlist_SRCS
kde4_add_ui_files (ktp_contactlist_SRCS
main-widget.ui
- dialogs/join-chat-room-dialog.ui
dialogs/remove-contact-dialog.ui
dialogs/contact-info.ui
tooltips/contacttooltip.ui
diff --git a/dialogs/join-chat-room-dialog.cpp b/dialogs/join-chat-room-dialog.cpp
deleted file mode 100644
index d048798..0000000
--- a/dialogs/join-chat-room-dialog.cpp
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- * This file is part of telepathy-contactslist-prototype
- *
- * Copyright (C) 2011 Francesco Nwokeka <francesco.nwokeka at gmail.com>
- * Copyright (C) 2012 Dominik Cermak <d.cermak at arcor.de>
- *
- * 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 "join-chat-room-dialog.h"
-#include "ui_join-chat-room-dialog.h"
-
-#include <KTp/Models/accounts-model.h>
-
-#include <KConfig>
-#include <KInputDialog>
-#include <KMessageBox>
-#include <KNotification>
-#include <KPushButton>
-#include <KCompletionBox>
-
-#include <TelepathyQt/AccountManager>
-#include <TelepathyQt/ChannelTypeRoomListInterface>
-#include <TelepathyQt/PendingChannel>
-#include <TelepathyQt/PendingReady>
-#include <TelepathyQt/RoomListChannel>
-
-#include <QSortFilterProxyModel>
-
-#include <rooms-model.h>
-
-#include <KDebug>
-
-JoinChatRoomDialog::JoinChatRoomDialog(Tp::AccountManagerPtr accountManager, QWidget* parent)
- : KDialog(parent, Qt::Dialog)
- , ui(new Ui::JoinChatRoomDialog)
- , m_model(new RoomsModel(this))
- , m_favoritesModel(new FavoriteRoomsModel(this))
- , m_favoritesProxyModel(new QSortFilterProxyModel(this))
- , m_recentComp(new KCompletion)
-{
- QWidget *joinChatRoomDialog = new QWidget(this);
- m_accounts = accountManager->allAccounts();
- ui->setupUi(joinChatRoomDialog);
- setMainWidget(joinChatRoomDialog);
- setWindowIcon(KIcon("telepathy-kde"));
-
- // config
- KSharedConfigPtr commonConfig = KSharedConfig::openConfig("ktelepathyrc");
- m_favoriteRoomsGroup = commonConfig->group("FavoriteRooms");
-
- KSharedConfigPtr contactListConfig = KSharedConfig::openConfig("ktp-contactlistrc");
- m_recentRoomsGroup = contactListConfig->group("RecentChatRooms");
-
- Q_FOREACH (const QString &key, m_recentRoomsGroup.keyList()) {
- if (!m_recentRoomsGroup.readEntry(key, QStringList()).isEmpty()) {
- m_recentRooms.insert(key, m_recentRoomsGroup.readEntry(key, QStringList()));
- }
- }
-
- loadFavoriteRooms();
-
- // disable OK button on start
- button(Ok)->setEnabled(false);
-
- //set icons
- ui->addFavoritePushButton->setIcon(KIcon(QLatin1String("list-add")));
- ui->removeFavoritePushButton->setIcon(KIcon(QLatin1String("list-remove")));
- ui->removeRecentPushButton->setIcon(KIcon(QLatin1String("list-remove")));
- ui->clearRecentPushButton->setIcon(KIcon(QLatin1String("edit-clear-list")));
-
- // populate combobox with accounts that support chat rooms
- for (int i = 0; i < m_accounts.count(); ++i) {
- Tp::AccountPtr acc = m_accounts.at(i);
-
- if (acc->capabilities().textChatrooms() && acc->isOnline()) {
- // add unique data to identify the correct account later on
- ui->comboBox->addItem(KIcon(acc->iconName()), acc->displayName(), acc->uniqueIdentifier());
- }
- }
-
- // apply the filter after populating
- onAccountSelectionChanged(ui->comboBox->currentIndex());
-
- // favoritesTab
- m_favoritesProxyModel->setSourceModel(m_favoritesModel);
- m_favoritesProxyModel->setFilterKeyColumn(FavoriteRoomsModel::AccountIdentifierColumn);
- m_favoritesProxyModel->setDynamicSortFilter(true);
-
- ui->listView->setModel(m_favoritesProxyModel);
- ui->listView->setModelColumn(FavoriteRoomsModel::NameColumn);
-
- // recentTab
- m_recentComp->setCompletionMode(KGlobalSettings::CompletionPopup);
- m_recentComp->setIgnoreCase(true);
-
- ui->lineEdit->setCompletionObject(m_recentComp);
- ui->lineEdit->setAutoDeleteCompletionObject(true);
-
- // queryTab
- if (ui->comboBox->count() > 0) {
- ui->queryPushButton->setEnabled(true);
- }
-
- QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
- proxyModel->setSourceModel(m_model);
- proxyModel->setSortLocaleAware(true);
- proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
- proxyModel->setFilterKeyColumn(RoomsModel::NameColumn);
- proxyModel->setDynamicSortFilter(true);
-
- ui->treeView->setModel(proxyModel);
- ui->treeView->header()->setResizeMode(QHeaderView::ResizeToContents);
- ui->treeView->sortByColumn(RoomsModel::NameColumn, Qt::AscendingOrder);
-
- // connects
- connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString)));
- connect(ui->listView, SIGNAL(clicked(QModelIndex)), this, SLOT(onFavoriteRoomClicked(QModelIndex)));
- connect(ui->addFavoritePushButton, SIGNAL(clicked(bool)), this, SLOT(addFavorite()));
- connect(ui->removeFavoritePushButton, SIGNAL(clicked(bool)), this, SLOT(removeFavorite()));
- connect(ui->recentListWidget, SIGNAL(currentTextChanged(QString)), ui->lineEdit, SLOT(setText(QString)));
- connect(ui->recentListWidget, SIGNAL(currentTextChanged(QString)), this, SLOT(onRecentRoomClicked()));
- connect(ui->removeRecentPushButton, SIGNAL(clicked(bool)), this , SLOT(removeRecentRoom()));
- connect(ui->clearRecentPushButton, SIGNAL(clicked(bool)), this, SLOT(clearRecentRooms()));
- connect(ui->queryPushButton, SIGNAL(clicked(bool)), this, SLOT(getRoomList()));
- connect(ui->stopPushButton, SIGNAL(clicked(bool)), this, SLOT(stopListing()));
- connect(ui->treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(onRoomClicked(QModelIndex)));
- connect(ui->filterBar, SIGNAL(textChanged(QString)), proxyModel, SLOT(setFilterFixedString(QString)));
- connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onAccountSelectionChanged(int)));
- connect(button(Ok), SIGNAL(clicked(bool)), this, SLOT(addRecentRoom()));
-}
-
-JoinChatRoomDialog::~JoinChatRoomDialog()
-{
- delete ui;
-}
-
-Tp::AccountPtr JoinChatRoomDialog::selectedAccount() const
-{
- Tp::AccountPtr account;
- bool found = false;
-
- for (int i = 0; i < m_accounts.count() && !found; ++i) {
- if (m_accounts.at(i)->uniqueIdentifier() == ui->comboBox->itemData(ui->comboBox->currentIndex()).toString()) {
- account = m_accounts.at(i);
- found = true;
- }
- }
-
- // account should never be empty
- return account;
-}
-
-void JoinChatRoomDialog::onAccountSelectionChanged(int newIndex)
-{
- // Show only favorites associated with the selected account
- QString accountIdentifier = ui->comboBox->itemData(newIndex).toString();
- m_favoritesProxyModel->setFilterFixedString(accountIdentifier);
-
- // Provide only rooms recently used with the selected account for completion
- m_recentComp->clear();
-
- Q_FOREACH (const QString &room, m_recentRooms.value(accountIdentifier)) {
- m_recentComp->addItem(room);
- }
-
- // Show only rooms recently used with the selected account in the list
- ui->recentListWidget->clear();
- ui->recentListWidget->addItems(m_recentRooms.value(accountIdentifier));
-
- // Enable/disable the buttons as appropriate
- bool recentListNonEmpty = m_recentRooms.value(accountIdentifier).size() > 0;
-
- ui->clearRecentPushButton->setEnabled(recentListNonEmpty);
- ui->removeRecentPushButton->setEnabled(recentListNonEmpty);
-}
-
-void JoinChatRoomDialog::addFavorite()
-{
- bool ok = false;
- QString favoriteHandle = ui->lineEdit->text();
- QString favoriteAccount = ui->comboBox->itemData(ui->comboBox->currentIndex()).toString();
-
- if (m_favoritesModel->containsRoom(favoriteHandle, favoriteAccount)) {
- KMessageBox::sorry(this, i18n("This room is already in your favorites."));
- } else {
- QString favoriteName = KInputDialog::getText(i18n("Add room"), i18n("Name"), QString(), &ok);
-
- if (ok) {
- QString key = favoriteHandle + favoriteAccount;
-
- // Write it to the config file
- QVariantList favorite;
- favorite.append(favoriteName);
- favorite.append(favoriteHandle);
- favorite.append(favoriteAccount);
- m_favoriteRoomsGroup.writeEntry(key, favorite);
- m_favoriteRoomsGroup.sync();
-
- // Insert it into the model
- QVariantMap room;
- room.insert("name", favoriteName);
- room.insert("handle-name", favoriteHandle);
- room.insert("account-identifier", favoriteAccount);
- m_favoritesModel->addRoom(room);
- }
- }
-}
-
-void JoinChatRoomDialog::removeFavorite()
-{
- QString favoriteHandle = ui->listView->currentIndex().data(FavoriteRoomsModel::HandleNameRole).toString();
- QString favoriteAccount = ui->comboBox->itemData(ui->comboBox->currentIndex()).toString();
- QVariantMap room = ui->listView->currentIndex().data(FavoriteRoomsModel::FavoriteRoomRole).value<QVariantMap>();
-
- QString key = favoriteHandle + favoriteAccount;
-
- if(m_favoriteRoomsGroup.keyList().contains(key)) {
- m_favoriteRoomsGroup.deleteEntry(key);
- m_favoriteRoomsGroup.sync();
- m_favoritesModel->removeRoom(room);
-
- if (m_favoritesModel->countForAccount(favoriteAccount) == 0) {
- ui->removeFavoritePushButton->setEnabled(false);
- }
- }
-}
-
-void JoinChatRoomDialog::addRecentRoom()
-{
- QString accountIdentifier = ui->comboBox->itemData(ui->comboBox->currentIndex()).toString();
- QString handle = ui->lineEdit->text();
-
- if (!handle.isEmpty()) {
- if (m_recentRooms.contains(accountIdentifier)) {
- QStringList currentList = m_recentRooms.take(accountIdentifier);
-
- // If the handle is already in the list move it at the first position
- // because now it is the most recent
- if (currentList.contains(handle)) {
- currentList.move(currentList.indexOf(handle), 0);
- m_recentRooms.insert(accountIdentifier, currentList);
- // else just insert it at the first position and check for the size
- } else {
- currentList.insert(0, handle);
-
- if (currentList.size() > 8) {
- currentList.removeLast();
- }
-
- m_recentRooms.insert(accountIdentifier, currentList);
- }
- } else {
- m_recentRooms.insert(accountIdentifier, QStringList(handle));
- }
-
- // Write it to the config
- m_recentRoomsGroup.writeEntry(accountIdentifier, m_recentRooms.value(accountIdentifier));
- m_recentRoomsGroup.sync();
- }
-}
-
-void JoinChatRoomDialog::removeRecentRoom()
-{
- QString accountIdentifier = ui->comboBox->itemData(ui->comboBox->currentIndex()).toString();
- QString handle = ui->recentListWidget->currentItem()->text();
-
- // Remove the entry
- QStringList currentList = m_recentRooms.take(accountIdentifier);
- currentList.removeOne(handle);
- m_recentRooms.insert(accountIdentifier, currentList);
-
- // Update the completion and list
- onAccountSelectionChanged(ui->comboBox->currentIndex());
-
- // Write it to the config
- m_recentRoomsGroup.writeEntry(accountIdentifier, m_recentRooms.value(accountIdentifier));
- m_recentRoomsGroup.sync();
-
- // Disable the button
- ui->removeRecentPushButton->setEnabled(false);
-}
-
-void JoinChatRoomDialog::clearRecentRooms()
-{
- QString accountIdentifier = ui->comboBox->itemData(ui->comboBox->currentIndex()).toString();
-
- // Remove all entries for the current account
- m_recentRooms.remove(accountIdentifier);
-
- // Update the completion and list
- onAccountSelectionChanged(ui->comboBox->currentIndex());
-
- // Update the config
- m_recentRoomsGroup.deleteEntry(accountIdentifier);
- m_recentRoomsGroup.sync();
-}
-
-void JoinChatRoomDialog::getRoomList()
-{
- Tp::AccountPtr account = selectedAccount();
-
- // Clear the list from previous items
- m_model->clearRoomInfoList();
-
- // Build the channelrequest
- QVariantMap request;
- request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"),
- TP_QT_IFACE_CHANNEL_TYPE_ROOM_LIST);
- request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"),
- Tp::HandleTypeNone);
-
- // If the user provided a server use it, else use the standard server for the selected account
- if (!ui->serverLineEdit->text().isEmpty()) {
- request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".Type.RoomList.Server"),
- ui->serverLineEdit->text());
- }
-
- m_pendingRoomListChannel = account->createAndHandleChannel(request, QDateTime::currentDateTime());
- connect(m_pendingRoomListChannel, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(onRoomListChannelReadyForHandling(Tp::PendingOperation*)));
-
-}
-
-void JoinChatRoomDialog::stopListing()
-{
- m_iface->StopListing();
-}
-
-void JoinChatRoomDialog::onRoomListChannelReadyForHandling(Tp::PendingOperation *operation)
-{
- if (operation->isError()) {
- kDebug() << operation->errorName();
- kDebug() << operation->errorMessage();
- QString errorMsg(operation->errorName() + QLatin1String(": ") + operation->errorMessage());
- sendNotificationToUser(errorMsg);
- } else {
- m_roomListChannel = m_pendingRoomListChannel->channel();
-
- connect(m_roomListChannel->becomeReady(),
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onRoomListChannelReady(Tp::PendingOperation*)));
- }
-}
-
-void JoinChatRoomDialog::onRoomListChannelReady(Tp::PendingOperation *operation)
-{
- if (operation->isError()) {
- kDebug() << operation->errorName();
- kDebug() << operation->errorMessage();
- QString errorMsg(operation->errorName() + QLatin1String(": ") + operation->errorMessage());
- sendNotificationToUser(errorMsg);
- } else {
- m_iface = m_roomListChannel->interface<Tp::Client::ChannelTypeRoomListInterface>();
-
- m_iface->ListRooms();
-
- connect(m_iface, SIGNAL(ListingRooms(bool)), SLOT(onListing(bool)));
- connect(m_iface, SIGNAL(GotRooms(Tp::RoomInfoList)), SLOT(onGotRooms(Tp::RoomInfoList)));
- }
-}
-
-void JoinChatRoomDialog::onRoomListChannelClosed(Tp::PendingOperation *operation)
-{
- if (operation->isError()) {
- kDebug() << operation->errorName();
- kDebug() << operation->errorMessage();
- QString errorMsg(operation->errorName() + QLatin1String(": ") + operation->errorMessage());
- sendNotificationToUser(errorMsg);
- } else {
- ui->queryPushButton->setEnabled(true);
- ui->stopPushButton->setEnabled(false);
- }
-}
-
-void JoinChatRoomDialog::onListing(bool isListing)
-{
- if (isListing) {
- kDebug() << "listing";
- ui->queryPushButton->setEnabled(false);
- ui->stopPushButton->setEnabled(true);
- } else {
- kDebug() << "finished listing";
- Tp::PendingOperation *op = m_roomListChannel->requestClose();
- connect(op,
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onRoomListChannelClosed(Tp::PendingOperation*)));
- }
-}
-
-void JoinChatRoomDialog::onGotRooms(Tp::RoomInfoList roomInfoList)
-{
- m_model->addRooms(roomInfoList);
-}
-
-void JoinChatRoomDialog::onFavoriteRoomClicked(const QModelIndex &index)
-{
- if (index.isValid()) {
- ui->removeFavoritePushButton->setEnabled(true);
- ui->lineEdit->setText(index.data(FavoriteRoomsModel::HandleNameRole).toString());
- } else {
- ui->removeFavoritePushButton->setEnabled(false);
- }
-}
-
-void JoinChatRoomDialog::onRecentRoomClicked()
-{
- ui->removeRecentPushButton->setEnabled(true);
-}
-
-void JoinChatRoomDialog::onRoomClicked(const QModelIndex& index)
-{
- ui->lineEdit->setText(index.data(RoomsModel::HandleNameRole).toString());
-}
-
-QString JoinChatRoomDialog::selectedChatRoom() const
-{
- return ui->lineEdit->text();
-}
-
-void JoinChatRoomDialog::onTextChanged(QString newText)
-{
- if (newText.isEmpty()) {
- button(Ok)->setEnabled(false);
- ui->addFavoritePushButton->setEnabled(false);
- } else {
- button(Ok)->setEnabled(true);
- ui->addFavoritePushButton->setEnabled(true);
- }
-}
-
-void JoinChatRoomDialog::sendNotificationToUser(const QString& errorMsg)
-{
- //The pointer is automatically deleted when the event is closed
- KNotification *notification;
- notification = new KNotification(QLatin1String("telepathyError"), this);
-
- notification->setText(errorMsg);
- notification->sendEvent();
-}
-
-void JoinChatRoomDialog::loadFavoriteRooms()
-{
- QList<QVariantMap> roomList;
-
- Q_FOREACH(const QString &key, m_favoriteRoomsGroup.keyList()) {
- QVariantList favorite = m_favoriteRoomsGroup.readEntry(key, QVariantList());
- QString favoriteName = favorite.at(0).toString();
- QString favoriteHandle = favorite.at(1).toString();
- QString favoriteAccount = favorite.at(2).toString();
-
- QVariantMap room;
- room.insert("name", favoriteName);
- room.insert("handle-name", favoriteHandle);
- room.insert("account-identifier", favoriteAccount);
- roomList.append(room);
- }
-
- m_favoritesModel->addRooms(roomList);
-}
diff --git a/dialogs/join-chat-room-dialog.h b/dialogs/join-chat-room-dialog.h
deleted file mode 100644
index d306e92..0000000
--- a/dialogs/join-chat-room-dialog.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * This file is part of telepathy-contactslist-prototype
- *
- * Copyright (C) 2011 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 JOINCHATROOMDIALOG_H
-#define JOINCHATROOMDIALOG_H
-
-#include <KDialog>
-#include <TelepathyQt/AccountManager>
-
-namespace Ui {
- class JoinChatRoomDialog;
-}
-
-class RoomsModel;
-class FavoriteRoomsModel;
-class QSortFilterProxyModel;
-class KCompletion;
-
-class JoinChatRoomDialog : public KDialog
-{
- Q_OBJECT
-
-public:
- explicit JoinChatRoomDialog(Tp::AccountManagerPtr accountManager, QWidget *parent = 0);
- ~JoinChatRoomDialog();
-
- Tp::AccountPtr selectedAccount() const; /** returns selected account */
- QString selectedChatRoom() const; /** returns selected chat room */
-
-private slots:
- void onTextChanged(QString newText);
- void onAccountSelectionChanged(int newIndex);
- void addFavorite();
- void removeFavorite();
- void addRecentRoom();
- void removeRecentRoom();
- void clearRecentRooms();
- void getRoomList();
- void stopListing();
- void onRoomListChannelReadyForHandling(Tp::PendingOperation *operation);
- void onRoomListChannelReady(Tp::PendingOperation *operation);
- void onRoomListChannelClosed(Tp::PendingOperation *operation);
- void onListing(bool isListing);
- void onGotRooms(Tp::RoomInfoList roomInfoList);
- void onFavoriteRoomClicked(const QModelIndex &index);
- void onRecentRoomClicked();
- void onRoomClicked(const QModelIndex &index);
-
-private:
- void sendNotificationToUser(const QString& errorMsg);
- void loadFavoriteRooms();
-
- QList<Tp::AccountPtr> m_accounts;
- Ui::JoinChatRoomDialog *ui;
- Tp::PendingChannel *m_pendingRoomListChannel;
- Tp::ChannelPtr m_roomListChannel;
- Tp::Client::ChannelTypeRoomListInterface *m_iface;
- RoomsModel *m_model;
- FavoriteRoomsModel *m_favoritesModel;
- QSortFilterProxyModel *m_favoritesProxyModel;
- KConfigGroup m_favoriteRoomsGroup;
- KConfigGroup m_recentRoomsGroup;
- QHash <QString, QStringList> m_recentRooms;
- KCompletion *m_recentComp;
-};
-
-
-#endif // JOINCHATROOMDIALOG_H
diff --git a/dialogs/join-chat-room-dialog.ui b/dialogs/join-chat-room-dialog.ui
deleted file mode 100644
index 2d077c4..0000000
--- a/dialogs/join-chat-room-dialog.ui
+++ /dev/null
@@ -1,244 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>JoinChatRoomDialog</class>
- <widget class="QWidget" name="JoinChatRoomDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>525</width>
- <height>325</height>
- </rect>
- </property>
- <property name="minimumSize">
- <size>
- <width>525</width>
- <height>0</height>
- </size>
- </property>
- <property name="windowTitle">
- <string>Join Chatroom</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="KComboBox" name="comboBox"/>
- </item>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Enter chat room:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KLineEdit" name="lineEdit">
- <property name="showClearButton" stdset="0">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTabWidget" name="tabWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="favoritesTab">
- <attribute name="title">
- <string>Favorites</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QListView" name="listView"/>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <widget class="QPushButton" name="addFavoritePushButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Add Room</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="removeFavoritePushButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Remove Room</string>
- </property>
- </widget>
- </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>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="recentTab">
- <attribute name="title">
- <string>Recent</string>
- </attribute>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QListWidget" name="recentListWidget"/>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_5">
- <item>
- <widget class="QPushButton" name="removeRecentPushButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Remove</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="clearRecentPushButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Clear list</string>
- </property>
- </widget>
- </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>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="queryTab">
- <attribute name="title">
- <string>Query</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLabel" name="serverLabel">
- <property name="text">
- <string>Server to be queried:</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="KLineEdit" name="serverLineEdit">
- <property name="placeholderText">
- <string/>
- </property>
- <property name="clickMessage">
- <string>Leave blank for the selected account's default server</string>
- </property>
- <property name="showClearButton" stdset="0">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="queryPushButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Query</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="stopPushButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Stop</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QTreeView" name="treeView">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::ExtendedSelection</enum>
- </property>
- <property name="rootIsDecorated">
- <bool>false</bool>
- </property>
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- <property name="allColumnsShowFocus">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KLineEdit" name="filterBar">
- <property name="placeholderText">
- <string/>
- </property>
- <property name="clickMessage">
- <string>Search rooms</string>
- </property>
- <property name="showClearButton" stdset="0">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
diff --git a/main-widget.cpp b/main-widget.cpp
index 64d624d..ff0056a 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -40,6 +40,7 @@
#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>
#include <KDebug>
#include <KDialog>
@@ -57,7 +58,6 @@
#include "ui_main-widget.h"
#include "account-buttons-panel.h"
#include "contact-list-application.h"
-#include "dialogs/join-chat-room-dialog.h"
#include "tooltips/tooltipmanager.h"
#include "context-menu.h"
@@ -394,7 +394,7 @@ void MainWidget::onGenericOperationFinished(Tp::PendingOperation* operation)
void MainWidget::onJoinChatRoomRequested()
{
- QWeakPointer<JoinChatRoomDialog> dialog = new JoinChatRoomDialog(m_accountManager);
+ QWeakPointer<KTp::JoinChatRoomDialog> dialog = new KTp::JoinChatRoomDialog(m_accountManager);
if (dialog.data()->exec() == QDialog::Accepted) {
Tp::AccountPtr account = dialog.data()->selectedAccount();
diff --git a/rooms-model.cpp b/rooms-model.cpp
deleted file mode 100644
index 36b2700..0000000
--- a/rooms-model.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Rooms Model - A model of chatrooms.
- * Copyright (C) 2012 Dominik Cermak <d.cermak at arcor.de>
- *
- * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "rooms-model.h"
-#include <KIcon>
-#include <KLocale>
-
-// RoomsModel
-RoomsModel::RoomsModel(QObject *parent): QAbstractListModel(parent)
-{
-}
-
-int RoomsModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid()) {
- return 0;
- } else {
- return m_roomInfoList.size();
- }
-}
-
-int RoomsModel::columnCount(const QModelIndex &parent) const
-{
- if (parent.isValid()) {
- return 0;
- } else {
- return 4;
- }
-}
-
-QVariant RoomsModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid()) {
- return QVariant();
- }
-
- if (index.row() >= m_roomInfoList.count()) {
- return QVariant();
- }
-
- const int row = index.row();
- const Tp::RoomInfo &roomInfo = m_roomInfoList.at(row);
-
- // this is handled here because when putting it in the switch below
- // all columns get an empty space for the decoration
- if (index.column() == PasswordColumn) {
- switch (role) {
- case Qt::DecorationRole:
- if (roomInfo.info.value("password").toBool()) {
- return KIcon("object-locked");
- } else {
- return QVariant();
- }
- case Qt::ToolTipRole:
- if (roomInfo.info.value("password").toBool()) {
- return i18n("Password required");
- } else {
- return i18n("No password required");
- }
- }
- }
-
- switch(role) {
- case Qt::DisplayRole:
- switch (index.column()) {
- case PasswordColumn:
- return QVariant();
- case NameColumn:
- return roomInfo.info.value(QString("name"));
- case DescriptionColumn:
- return roomInfo.info.value(QString("description"));
- case MembersColumn:
- return roomInfo.info.value(QString("members"));
- }
- case Qt::ToolTipRole:
- switch (index.column()) {
- case MembersColumn:
- return i18n("Member count");
- }
- case RoomsModel::HandleNameRole:
- return roomInfo.info.value(QString("handle-name"));
- }
-
- return QVariant();
-}
-
-QVariant RoomsModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if (role != Qt::DisplayRole && role != Qt::DecorationRole) {
- return QVariant();
- }
-
- if (orientation == Qt::Horizontal) {
- switch (role) {
- case Qt::DisplayRole:
- switch (section) {
- case NameColumn:
- return i18nc("Chatrooms name", "Name");
- case DescriptionColumn:
- return i18nc("Chatrooms description", "Description");
- }
- case Qt::DecorationRole:
- switch (section) {
- case PasswordColumn:
- return KIcon("object-locked");
- case MembersColumn:
- return KIcon("meeting-participant");
- }
- }
- }
-
- return QVariant();
-}
-
-void RoomsModel::addRooms(const Tp::RoomInfoList newRoomList)
-{
- if (newRoomList.size() > 0) {
- beginInsertRows(QModelIndex(), m_roomInfoList.size(), m_roomInfoList.size() + newRoomList.size() - 1);
- m_roomInfoList.append(newRoomList);
- endInsertRows();
- }
-}
-
-void RoomsModel::clearRoomInfoList()
-{
- if (m_roomInfoList.size() > 0) {
- beginRemoveRows(QModelIndex(), 0, m_roomInfoList.size() - 1);
- m_roomInfoList.clear();
- endRemoveRows();
- }
-}
-
-// FavoriteRoomsModel
-FavoriteRoomsModel::FavoriteRoomsModel(QObject *parent): QAbstractListModel(parent)
-{
-}
-
-int FavoriteRoomsModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid()) {
- return 0;
- } else {
- return m_favoriteRoomsList.size();
- }
-}
-
-int FavoriteRoomsModel::columnCount(const QModelIndex &parent) const
-{
- if (parent.isValid()) {
- return 0;
- } else {
- return 3;
- }
-}
-
-QVariant FavoriteRoomsModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid()) {
- return QVariant();
- }
-
- if (index.row() >= m_favoriteRoomsList.size()) {
- return QVariant();
- }
-
- const int row = index.row();
- const QVariantMap &room = m_favoriteRoomsList.at(row);
-
- switch(role) {
- case Qt::DisplayRole:
- switch (index.column()) {
- case NameColumn:
- return room.value("name");
- case HandleNameColumn:
- return room.value("handle-name");
- case AccountIdentifierColumn:
- return room.value("account-identifier");
- }
- case Qt::ToolTipRole:
- return room.value("handle-name");
- case FavoriteRoomsModel::HandleNameRole:
- return room.value("handle-name");
- case FavoriteRoomsModel::FavoriteRoomRole:
- return QVariant::fromValue<QVariantMap>(room);
- }
-
- return QVariant();
-}
-
-void FavoriteRoomsModel::addRooms(const QList<QVariantMap> newRoomList)
-{
- if (newRoomList.size() > 0) {
- beginInsertRows(QModelIndex(), m_favoriteRoomsList.size(), m_favoriteRoomsList.size() + newRoomList.size() - 1);
- m_favoriteRoomsList.append(newRoomList);
- endInsertRows();
- }
-}
-
-void FavoriteRoomsModel::addRoom(const QVariantMap &room)
-{
- beginInsertRows(QModelIndex(), m_favoriteRoomsList.size(), m_favoriteRoomsList.size());
- m_favoriteRoomsList.append(room);
- endInsertRows();
-}
-
-void FavoriteRoomsModel::removeRoom(const QVariantMap &room)
-{
- int row = m_favoriteRoomsList.indexOf(room);
- beginRemoveRows(QModelIndex(), row, row);
- m_favoriteRoomsList.removeOne(room);
- endRemoveRows();
-}
-
-bool FavoriteRoomsModel::containsRoom(const QString &handle, const QString &account) const
-{
- bool contains = false;
-
- Q_FOREACH(const QVariantMap &room, m_favoriteRoomsList) {
- if ((room.value("handle-name") == handle) && (room.value("account-identifier") == account)) {
- contains = true;
- }
- }
-
- return contains;
-}
-
-int FavoriteRoomsModel::countForAccount(const QString &account) const
-{
- int count = 0;
-
- Q_FOREACH (const QVariantMap &room, m_favoriteRoomsList) {
- if (room.value("account-identifier") == account) {
- count++;
- }
- }
-
- return count;
-}
diff --git a/rooms-model.h b/rooms-model.h
deleted file mode 100644
index 8945472..0000000
--- a/rooms-model.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Rooms Model - A model of chatrooms.
- * Copyright (C) 2012 Dominik Cermak <d.cermak at arcor.de>
- *
- * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef ROOMSMODEL_H
-#define ROOMSMODEL_H
-
-#include <QtCore/QAbstractListModel>
-#include <TelepathyQt/Types>
-
-class RoomsModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- // TODO: find a suitable icon and add an invitation column
- enum Column {
- PasswordColumn=0,
- MembersColumn,
- NameColumn,
- DescriptionColumn
- };
-
- enum Roles {
- HandleNameRole = Qt::UserRole
- };
-
- explicit RoomsModel(QObject *parent = 0);
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
-
- /**
- * rief Add new rooms to the list.
- *
- * \param newRoomList The list with the new rooms to add.
- */
- void addRooms(const Tp::RoomInfoList newRoomList);
-
- /**
- * rief Clear the room list.
- */
- void clearRoomInfoList();
-
-private:
- Tp::RoomInfoList m_roomInfoList;
-};
-
-class FavoriteRoomsModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- enum Column {
- NameColumn = 0,
- HandleNameColumn,
- AccountIdentifierColumn
- };
-
- enum Roles {
- HandleNameRole = Qt::UserRole,
- FavoriteRoomRole
- };
-
- explicit FavoriteRoomsModel(QObject *parent = 0);
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-
- /**
- * rief Add new rooms to the list.
- *
- * \param newRoomList The list with the new rooms to add.
- */
- void addRooms(const QList<QVariantMap> newRoomList);
-
- /**
- * rief Add a new room to the list.
- *
- * \param room The room to add.
- */
- void addRoom(const QVariantMap &room);
-
- /**
- * rief Remove a room from the list.
- *
- * \param room The room to remove.
- */
- void removeRoom(const QVariantMap &room);
-
- /**
- * rief Checks if it contains a room (identified by his handle-name).
- *
- * \param handle The handle to look for.
- *
- *
eturn True if it contains the room else false.
- */
- bool containsRoom(const QString &handle, const QString &account) const;
-
- /**
- * rief Returns the count of rooms for the specified account.
- *
- * \param account The account to return the count for.
- *
- *
eturn The count of rooms.
- */
- int countForAccount(const QString &account) const;
-
-private:
- QList<QVariantMap> m_favoriteRoomsList;
-};
-
-#endif // ROOMSMODEL_H
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list