[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:10:21 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=2984af0
The following commit has been merged in the master branch:
commit 2984af041b56accb484dba0bc89f741473c315aa
Author: Dominik Cermak <d.cermak at arcor.de>
Date: Thu Mar 22 14:04:51 2012 +0100
Maintain a list of recently used rooms in JoinChatroomDialog
Upon joining a room (more exact upon clicking "Ok") the room is saved in
the recently used list for this account.
ATM it remembers up to 8 rooms and single rooms can be removed as well
as the whole list can be cleared.
The complete list is shown in a new tab and the rooms are used for
completion in the lineEdit.
CCBUG: 291711
REVIEW: 104269
---
dialogs/join-chat-room-dialog.cpp | 134 +++++++++++++++++++++++++++++++++++---
dialogs/join-chat-room-dialog.h | 8 +++
dialogs/join-chat-room-dialog.ui | 47 +++++++++++++
3 files changed, 180 insertions(+), 9 deletions(-)
diff --git a/dialogs/join-chat-room-dialog.cpp b/dialogs/join-chat-room-dialog.cpp
index 9dfe2e7..d048798 100644
--- a/dialogs/join-chat-room-dialog.cpp
+++ b/dialogs/join-chat-room-dialog.cpp
@@ -29,6 +29,7 @@
#include <KMessageBox>
#include <KNotification>
#include <KPushButton>
+#include <KCompletionBox>
#include <TelepathyQt/AccountManager>
#include <TelepathyQt/ChannelTypeRoomListInterface>
@@ -47,8 +48,8 @@ JoinChatRoomDialog::JoinChatRoomDialog(Tp::AccountManagerPtr accountManager, QWi
, ui(new Ui::JoinChatRoomDialog)
, m_model(new RoomsModel(this))
, m_favoritesModel(new FavoriteRoomsModel(this))
- , m_favoritesProxyModel(new QSortFilterProxyModel(this)
- )
+ , m_favoritesProxyModel(new QSortFilterProxyModel(this))
+ , m_recentComp(new KCompletion)
{
QWidget *joinChatRoomDialog = new QWidget(this);
m_accounts = accountManager->allAccounts();
@@ -57,18 +58,28 @@ JoinChatRoomDialog::JoinChatRoomDialog(Tp::AccountManagerPtr accountManager, QWi
setWindowIcon(KIcon("telepathy-kde"));
// config
- KSharedConfigPtr config = KSharedConfig::openConfig("ktelepathyrc");
- m_favoriteRoomsGroup = config->group("FavoriteRooms");
+ 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) {
@@ -80,10 +91,10 @@ JoinChatRoomDialog::JoinChatRoomDialog(Tp::AccountManagerPtr accountManager, QWi
}
}
- // Apply the filter after populating
+ // apply the filter after populating
onAccountSelectionChanged(ui->comboBox->currentIndex());
- // FavoritesTab
+ // favoritesTab
m_favoritesProxyModel->setSourceModel(m_favoritesModel);
m_favoritesProxyModel->setFilterKeyColumn(FavoriteRoomsModel::AccountIdentifierColumn);
m_favoritesProxyModel->setDynamicSortFilter(true);
@@ -91,7 +102,14 @@ JoinChatRoomDialog::JoinChatRoomDialog(Tp::AccountManagerPtr accountManager, QWi
ui->listView->setModel(m_favoritesProxyModel);
ui->listView->setModelColumn(FavoriteRoomsModel::NameColumn);
- // QueryTab
+ // 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);
}
@@ -112,11 +130,16 @@ JoinChatRoomDialog::JoinChatRoomDialog(Tp::AccountManagerPtr accountManager, QWi
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()
@@ -142,8 +165,26 @@ Tp::AccountPtr JoinChatRoomDialog::selectedAccount() const
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()
@@ -197,6 +238,76 @@ void JoinChatRoomDialog::removeFavorite()
}
}
+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();
@@ -304,6 +415,11 @@ void JoinChatRoomDialog::onFavoriteRoomClicked(const QModelIndex &index)
}
}
+void JoinChatRoomDialog::onRecentRoomClicked()
+{
+ ui->removeRecentPushButton->setEnabled(true);
+}
+
void JoinChatRoomDialog::onRoomClicked(const QModelIndex& index)
{
ui->lineEdit->setText(index.data(RoomsModel::HandleNameRole).toString());
diff --git a/dialogs/join-chat-room-dialog.h b/dialogs/join-chat-room-dialog.h
index 686fe31..d306e92 100644
--- a/dialogs/join-chat-room-dialog.h
+++ b/dialogs/join-chat-room-dialog.h
@@ -31,6 +31,7 @@ namespace Ui {
class RoomsModel;
class FavoriteRoomsModel;
class QSortFilterProxyModel;
+class KCompletion;
class JoinChatRoomDialog : public KDialog
{
@@ -48,6 +49,9 @@ private slots:
void onAccountSelectionChanged(int newIndex);
void addFavorite();
void removeFavorite();
+ void addRecentRoom();
+ void removeRecentRoom();
+ void clearRecentRooms();
void getRoomList();
void stopListing();
void onRoomListChannelReadyForHandling(Tp::PendingOperation *operation);
@@ -56,6 +60,7 @@ private slots:
void onListing(bool isListing);
void onGotRooms(Tp::RoomInfoList roomInfoList);
void onFavoriteRoomClicked(const QModelIndex &index);
+ void onRecentRoomClicked();
void onRoomClicked(const QModelIndex &index);
private:
@@ -71,6 +76,9 @@ private:
FavoriteRoomsModel *m_favoritesModel;
QSortFilterProxyModel *m_favoritesProxyModel;
KConfigGroup m_favoriteRoomsGroup;
+ KConfigGroup m_recentRoomsGroup;
+ QHash <QString, QStringList> m_recentRooms;
+ KCompletion *m_recentComp;
};
diff --git a/dialogs/join-chat-room-dialog.ui b/dialogs/join-chat-room-dialog.ui
index 3e8418b..2d077c4 100644
--- a/dialogs/join-chat-room-dialog.ui
+++ b/dialogs/join-chat-room-dialog.ui
@@ -93,6 +93,53 @@
</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>
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list