summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-10-08 11:07:28 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-10-08 11:07:28 (GMT)
commitd7fb4678b37a80f615755609648aad8dcef6ac00 (patch)
tree18be76ead67c3856a69e9041d4072fb8d1215dea /Swift
parent874ed4f42dd29fc2b8e7b905072e6a1b9a26582c (diff)
downloadswift-contrib-d7fb4678b37a80f615755609648aad8dcef6ac00.zip
swift-contrib-d7fb4678b37a80f615755609648aad8dcef6ac00.tar.bz2
Rename groups.
Resolves: #577 Release-Notes: Roster groups can now be renamed.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp40
-rw-r--r--Swift/QtUI/ContextMenus/QtRosterContextMenu.h1
2 files changed, 28 insertions, 13 deletions
diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp
index 1641266..d4473d8 100644
--- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp
+++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp
@@ -34,22 +34,17 @@ QtRosterContextMenu::QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidge
void QtRosterContextMenu::show(RosterItem* item) {
ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
- if (!contact) {
- return;
- }
item_ = item;
QMenu contextMenu;
- contextMenu.addAction("Remove", this, SLOT(handleRemoveContact()));
- contextMenu.addAction("Rename", this, SLOT(handleRenameContact()));
- contextMenu.addAction("Groups", this, SLOT(handleRegroupContact()));
- /*QMenu* groupsMenu = contextMenu.addMenu("Groups");
- std::map<QAction, String> groupActions;
- for (int i = 0; i < 0; i++) {
- String groupName;
- groupActions[groupsMenu->addAction(P2QSTRING(groupName))] = groupName;
+ if (contact) {
+ contextMenu.addAction("Remove", this, SLOT(handleRemoveContact()));
+ contextMenu.addAction("Rename", this, SLOT(handleRenameContact()));
+ contextMenu.addAction("Groups", this, SLOT(handleRegroupContact()));
+ }
+ GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item);
+ if (group) {
+ contextMenu.addAction("Rename", this, SLOT(handleRenameGroup()));
}
- groupsMenu->addSeparator();
- groupsMenu->addAction("New Group", this SLOT(handleNewGroup()));*/
contextMenu.exec(QCursor::pos());
}
@@ -86,4 +81,23 @@ void QtRosterContextMenu::handleRenameContact() {
}
}
+void QtRosterContextMenu::handleRenameGroup() {
+ GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item_);
+ assert(group);
+ bool ok;
+ QString newName = QInputDialog::getText(NULL, "Rename group", "New name for " + P2QSTRING(item_->getDisplayName()), QLineEdit::Normal, P2QSTRING(item_->getDisplayName()), &ok);
+ if (ok) {
+ std::vector<String> addedGroups;
+ std::vector<String> removedGroups;
+ addedGroups.push_back(Q2PSTRING(newName));
+ removedGroups.push_back(group->getDisplayName());
+ foreach (RosterItem* child, group->getChildren()) {
+ ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(child);
+ assert(contact);
+ boost::shared_ptr<RegroupRosterItemUIEvent> regroupItem(new RegroupRosterItemUIEvent(contact->getJID(), addedGroups, removedGroups));
+ eventStream_->send(regroupItem);
+ }
+ }
+}
+
}
diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h
index f2c7e1f..53f4bdd 100644
--- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h
+++ b/Swift/QtUI/ContextMenus/QtRosterContextMenu.h
@@ -23,6 +23,7 @@ namespace Swift {
private slots:
void handleRemoveContact();
void handleRenameContact();
+ void handleRenameGroup();
void handleRegroupContact();
private: