[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:07:42 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=314cb8a
The following commit has been merged in the master branch:
commit 314cb8a84cfe069f181a772f626753c80c011c4c
Author: Leon Handreke <leonh at ndreke.de>
Date: Sun Oct 6 12:16:15 2013 +0000
Make favorite chat room names editable
REVIEW: 113111
BUG: 308210
FIXED-IN: 0.8.0
DIGEST: Add ability to edit the name of your favourite chat rooms for quick joining
---
KTp/Models/rooms-model.cpp | 38 ++++++++++++++++++++++++++++++++
KTp/Models/rooms-model.h | 4 ++++
KTp/Widgets/join-chat-room-dialog.cpp | 41 +++++++++++++++++++++++++++++++----
KTp/Widgets/join-chat-room-dialog.h | 4 +++-
KTp/Widgets/join-chat-room-dialog.ui | 10 +++++++++
5 files changed, 92 insertions(+), 5 deletions(-)
diff --git a/KTp/Models/rooms-model.cpp b/KTp/Models/rooms-model.cpp
index 4c3bb4f..d7047b3 100644
--- a/KTp/Models/rooms-model.cpp
+++ b/KTp/Models/rooms-model.cpp
@@ -196,6 +196,10 @@ QVariant KTp::FavoriteRoomsModel::data(const QModelIndex &index, int role) const
return room.value(QLatin1String("handle-name"));
case FavoriteRoomsModel::HandleNameRole:
return room.value(QLatin1String("handle-name"));
+ case FavoriteRoomsModel::NameRole:
+ return room.value(QLatin1String("name"));
+ case FavoriteRoomsModel::AccountRole:
+ return room.value(QLatin1String("account-identifier"));
case FavoriteRoomsModel::FavoriteRoomRole:
return QVariant::fromValue<QVariantMap>(room);
}
@@ -203,6 +207,40 @@ QVariant KTp::FavoriteRoomsModel::data(const QModelIndex &index, int role) const
return QVariant();
}
+bool KTp::FavoriteRoomsModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (!index.isValid() || index.row() >= m_favoriteRoomsList.size()) {
+ return false;
+ }
+
+ const int row = index.row();
+ QVariantMap &room = m_favoriteRoomsList[row];
+
+ if (role == Qt::EditRole) {
+ switch (index.column()) {
+ case NameColumn:
+ room.insert(QLatin1String("name"), value);
+ break;
+ case HandleNameColumn:
+ room.insert(QLatin1String("handle-name"), value);
+ break;
+ case AccountIdentifierColumn:
+ room.insert(QLatin1String("account-identifier"), value);
+ break;
+ default:
+ return false;
+ }
+ Q_EMIT dataChanged(index, index);
+ return true;
+ }
+ return false;
+}
+
+Qt::ItemFlags KTp::FavoriteRoomsModel::flags(const QModelIndex &index) const {
+ Q_UNUSED(index);
+ return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
void KTp::FavoriteRoomsModel::addRooms(const QList<QVariantMap> newRoomList)
{
if (newRoomList.size() > 0) {
diff --git a/KTp/Models/rooms-model.h b/KTp/Models/rooms-model.h
index 2630141..2ff1604 100644
--- a/KTp/Models/rooms-model.h
+++ b/KTp/Models/rooms-model.h
@@ -79,6 +79,8 @@ public:
enum Roles {
HandleNameRole = Qt::UserRole,
+ NameRole,
+ AccountRole,
FavoriteRoomRole
};
@@ -86,6 +88,8 @@ public:
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 bool setData(const QModelIndex &index, const QVariant &value, int role);
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
/**
* rief Add new rooms to the list.
diff --git a/KTp/Widgets/join-chat-room-dialog.cpp b/KTp/Widgets/join-chat-room-dialog.cpp
index 3f86005..1099b5e 100644
--- a/KTp/Widgets/join-chat-room-dialog.cpp
+++ b/KTp/Widgets/join-chat-room-dialog.cpp
@@ -76,6 +76,7 @@ KTp::JoinChatRoomDialog::JoinChatRoomDialog(Tp::AccountManagerPtr accountManager
//set icons
ui->addFavoritePushButton->setIcon(KIcon(QLatin1String("list-add")));
+ ui->editFavoritePushButton->setIcon(KIcon(QLatin1String("list-edit")));
ui->removeFavoritePushButton->setIcon(KIcon(QLatin1String("list-remove")));
ui->removeRecentPushButton->setIcon(KIcon(QLatin1String("list-remove")));
ui->clearRecentPushButton->setIcon(KIcon(QLatin1String("edit-clear-list")));
@@ -116,9 +117,13 @@ KTp::JoinChatRoomDialog::JoinChatRoomDialog(Tp::AccountManagerPtr accountManager
// connects
connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString)));
- connect(ui->listView, SIGNAL(clicked(QModelIndex)), this, SLOT(onFavoriteRoomClicked(QModelIndex)));
connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));
+ connect(ui->listView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
+ this, SLOT(onFavoriteRoomSelectionChanged(QModelIndex,QModelIndex)));
+ connect(m_favoritesModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+ this, SLOT(onFavoriteRoomDataChanged(QModelIndex,QModelIndex)));
connect(ui->addFavoritePushButton, SIGNAL(clicked(bool)), this, SLOT(addFavorite()));
+ connect(ui->editFavoritePushButton, SIGNAL(clicked(bool)), this, SLOT(editFavorite()));
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()));
@@ -230,6 +235,11 @@ void KTp::JoinChatRoomDialog::addFavorite()
}
}
+void KTp::JoinChatRoomDialog::editFavorite()
+{
+ ui->listView->edit(ui->listView->currentIndex());
+}
+
void KTp::JoinChatRoomDialog::removeFavorite()
{
QString favoriteHandle = ui->listView->currentIndex().data(FavoriteRoomsModel::HandleNameRole).toString();
@@ -249,6 +259,26 @@ void KTp::JoinChatRoomDialog::removeFavorite()
}
}
+void KTp::JoinChatRoomDialog::onFavoriteRoomDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+ // Because listView only allows editing of a single row, assume that topLeft points to the changed data.
+ Q_UNUSED(bottomRight);
+
+ const QString &favoriteHandle = topLeft.data(FavoriteRoomsModel::HandleNameRole).toString();
+ const QString &favoriteName = topLeft.data(FavoriteRoomsModel::NameRole).toString();
+ const QString &favoriteAccount = topLeft.data(FavoriteRoomsModel::AccountRole).toString();
+
+ const QString &key = favoriteHandle + favoriteAccount;
+
+ // Write the changed room to the config file
+ QVariantList favorite;
+ favorite.append(favoriteName);
+ favorite.append(favoriteHandle);
+ favorite.append(favoriteAccount);
+ m_favoriteRoomsGroup.writeEntry(key, favorite);
+ m_favoriteRoomsGroup.sync();
+}
+
void KTp::JoinChatRoomDialog::addRecentRoom()
{
Tp::AccountPtr account = ui->comboBox->currentAccount();
@@ -424,12 +454,15 @@ void KTp::JoinChatRoomDialog::onGotRooms(Tp::RoomInfoList roomInfoList)
m_model->addRooms(roomInfoList);
}
-void KTp::JoinChatRoomDialog::onFavoriteRoomClicked(const QModelIndex &index)
+void KTp::JoinChatRoomDialog::onFavoriteRoomSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
- if (index.isValid()) {
+ Q_UNUSED(previous);
+ if (current.isValid()) {
+ ui->editFavoritePushButton->setEnabled(true);
ui->removeFavoritePushButton->setEnabled(true);
- ui->lineEdit->setText(index.data(FavoriteRoomsModel::HandleNameRole).toString());
+ ui->lineEdit->setText(current.data(FavoriteRoomsModel::HandleNameRole).toString());
} else {
+ ui->editFavoritePushButton->setEnabled(false);
ui->removeFavoritePushButton->setEnabled(false);
}
}
diff --git a/KTp/Widgets/join-chat-room-dialog.h b/KTp/Widgets/join-chat-room-dialog.h
index c996e76..1b69f25 100644
--- a/KTp/Widgets/join-chat-room-dialog.h
+++ b/KTp/Widgets/join-chat-room-dialog.h
@@ -53,6 +53,7 @@ private Q_SLOTS:
void onTextChanged(QString newText);
void onAccountSelectionChanged(int newIndex);
void addFavorite();
+ void editFavorite();
void removeFavorite();
void addRecentRoom();
void removeRecentRoom();
@@ -64,7 +65,8 @@ private Q_SLOTS:
void onRoomListChannelClosed(Tp::PendingOperation *operation);
void onListing(bool isListing);
void onGotRooms(Tp::RoomInfoList roomInfoList);
- void onFavoriteRoomClicked(const QModelIndex &index);
+ void onFavoriteRoomSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous);
+ void onFavoriteRoomDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void onRecentRoomClicked();
void onRoomClicked(const QModelIndex &index);
void onAccountManagerReady(Tp::PendingOperation*);
diff --git a/KTp/Widgets/join-chat-room-dialog.ui b/KTp/Widgets/join-chat-room-dialog.ui
index 4bc1d3b..058362d 100644
--- a/KTp/Widgets/join-chat-room-dialog.ui
+++ b/KTp/Widgets/join-chat-room-dialog.ui
@@ -65,6 +65,16 @@
</widget>
</item>
<item>
+ <widget class="QPushButton" name="editFavoritePushButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Edit Room</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="removeFavoritePushButton">
<property name="enabled">
<bool>false</bool>
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list