summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-09-24 16:58:30 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-09-24 16:58:30 (GMT)
commit245185ca3133fd496b90c5c9973713e8aa02f0ef (patch)
treed67354fa0f96f78bfcf6ec9969b436e9f29ee234 /Swift
parentecc4dc5633b6d3b46ff2ef24d7d976172b9c01ae (diff)
downloadswift-245185ca3133fd496b90c5c9973713e8aa02f0ef.zip
swift-245185ca3133fd496b90c5c9973713e8aa02f0ef.tar.bz2
Rename contacts in the QtUI.
Resolves: #575
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp18
-rw-r--r--Swift/QtUI/ContextMenus/QtRosterContextMenu.h3
2 files changed, 18 insertions, 3 deletions
diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp
index e6b5ae5..59c3b78 100644
--- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp
+++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp
@@ -6,6 +6,8 @@
#include "Swift/QtUI/ContextMenus/QtRosterContextMenu.h"
+#include <QInputDialog>
+#include <QLineEdit>
#include <QMenu>
#include <QDebug>
@@ -15,6 +17,7 @@
#include "Swiften/Base/String.h"
#include "Swift/Controllers/UIEvents/UIEvent.h"
#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h"
+#include "Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h"
#include "Swift/QtUI/QtSwiftUtil.h"
namespace Swift {
@@ -30,14 +33,25 @@ void QtRosterContextMenu::show(RosterItem* item) {
}
item_ = item;
QMenu* contextMenu = new QMenu();
- contextMenu->addAction("Remove", this, SLOT(handleRemove()));
+ contextMenu->addAction("Remove", this, SLOT(handleRemoveContact()));
+ contextMenu->addAction("Rename", this, SLOT(handleRenameContact()));
contextMenu->exec(QCursor::pos());
}
-void QtRosterContextMenu::handleRemove() {
+void QtRosterContextMenu::handleRemoveContact() {
ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item_);
assert(contact);
eventStream_->send(boost::shared_ptr<UIEvent>(new RemoveRosterItemUIEvent(contact->getJID())));
}
+void QtRosterContextMenu::handleRenameContact() {
+ ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item_);
+ assert(contact);
+ bool ok;
+ QString newName = QInputDialog::getText(NULL, "Rename contact", "New name for " + P2QSTRING(item_->getDisplayName()), QLineEdit::Normal, P2QSTRING(item_->getDisplayName()), &ok);
+ if (ok) {
+ eventStream_->send(boost::shared_ptr<UIEvent>(new RenameRosterItemUIEvent(contact->getJID(), Q2PSTRING(newName))));
+ }
+}
+
}
diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h
index 51556e4..44f3314 100644
--- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h
+++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h
@@ -20,7 +20,8 @@ namespace Swift {
void show(RosterItem* item);
private slots:
- void handleRemove();
+ void handleRemoveContact();
+ void handleRenameContact();
private:
RosterItem* item_;