diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-02-21 20:46:55 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-02-21 20:46:55 (GMT) |
commit | 811aa9951613990956ad9027f4b969c8886b1123 (patch) | |
tree | 0b2c5628cc64796a68f2e2008d81290a59fdd687 /Swift | |
parent | ba81a3d454db0abd0b8e00a34a9da3b720af454f (diff) | |
download | swift-811aa9951613990956ad9027f4b969c8886b1123.zip swift-811aa9951613990956ad9027f4b969c8886b1123.tar.bz2 |
Added "Remove" context menu.
Resolves: #768
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/QtContactEditWindow.cpp | 13 | ||||
-rw-r--r-- | Swift/QtUI/QtContactEditWindow.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 1 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidget.cpp | 8 |
4 files changed, 19 insertions, 5 deletions
diff --git a/Swift/QtUI/QtContactEditWindow.cpp b/Swift/QtUI/QtContactEditWindow.cpp index 543d39a..5affaef 100644 --- a/Swift/QtUI/QtContactEditWindow.cpp +++ b/Swift/QtUI/QtContactEditWindow.cpp @@ -72,16 +72,19 @@ void QtContactEditWindow::hide() { } void QtContactEditWindow::handleRemoveContact() { + if (confirmContactDeletion(jid_)) { + onRemoveContactRequest(); + } +} + +bool QtContactEditWindow::confirmContactDeletion(const JID& jid) { QMessageBox msgBox; msgBox.setWindowTitle(tr("Confirm contact deletion")); msgBox.setText(tr("Are you sure you want to delete this contact?")); - msgBox.setInformativeText(QString(tr("This will remove the contact '%1' from all groups they may be in.")).arg(P2QSTRING(jid_.toString()))); + msgBox.setInformativeText(QString(tr("This will remove the contact '%1' from all groups they may be in.")).arg(P2QSTRING(jid.toString()))); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) { - onRemoveContactRequest(); - } + return msgBox.exec() == QMessageBox::Yes; } void QtContactEditWindow::handleUpdateContact() { diff --git a/Swift/QtUI/QtContactEditWindow.h b/Swift/QtUI/QtContactEditWindow.h index 2d283de..b25e8b9 100644 --- a/Swift/QtUI/QtContactEditWindow.h +++ b/Swift/QtUI/QtContactEditWindow.h @@ -30,6 +30,8 @@ namespace Swift { void show(); void hide(); + static bool confirmContactDeletion(const JID& jid); + private slots: void handleRemoveContact(); void handleUpdateContact(); diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 55ceabc..99cbcf5 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -58,6 +58,7 @@ QtMainWindow::QtMainWindow(QtSettingsProvider* settings, UIEventStream* uiEventS contactTabLayout->setContentsMargins(0, 0, 0, 0); treeWidget_ = new QtTreeWidget(uiEventStream_); + treeWidget_->setEditable(true); contactTabLayout->addWidget(treeWidget_); tabs_->addTab(contactsTabWidget_, tr("&Contacts")); diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp index e88e1bb..a76dc70 100644 --- a/Swift/QtUI/Roster/QtTreeWidget.cpp +++ b/Swift/QtUI/Roster/QtTreeWidget.cpp @@ -17,8 +17,10 @@ #include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" #include "Swift/Controllers/UIEvents/RequestContactEditorUIEvent.h" +#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h" #include "Swift/Controllers/UIEvents/RenameGroupUIEvent.h" #include "QtSwiftUtil.h" +#include "QtContactEditWindow.h" namespace Swift { @@ -87,10 +89,16 @@ void QtTreeWidget::contextMenuEvent(QContextMenuEvent* event) { QMenu contextMenu; if (ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item)) { QAction* editContact = contextMenu.addAction(tr("Edit")); + QAction* removeContact = contextMenu.addAction(tr("Remove")); QAction* result = contextMenu.exec(event->globalPos()); if (result == editContact) { eventStream_->send(boost::make_shared<RequestContactEditorUIEvent>(contact->getJID())); } + else if (result == removeContact) { + if (QtContactEditWindow::confirmContactDeletion(contact->getJID())) { + eventStream_->send(boost::make_shared<RemoveRosterItemUIEvent>(contact->getJID())); + } + } } else if (GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item)) { QAction* renameGroup = contextMenu.addAction(tr("Rename")); |