summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/ContextMenus')
-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: