summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtContactEditWindow.cpp13
-rw-r--r--Swift/QtUI/QtContactEditWindow.h2
-rw-r--r--Swift/QtUI/QtMainWindow.cpp1
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp8
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"));