diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-09-21 12:25:27 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-09-23 16:47:57 (GMT) |
commit | f9c432ca127d6e7d87b49d2fbf6aace34bea0e06 (patch) | |
tree | d7f069d3c48cc3d768e770df614fe87ade6f3902 /Swift/QtUI/Roster/QtOccupantListWidget.cpp | |
parent | 20d3385909a2f9d886e7e0781357b23474e9f8dc (diff) | |
download | swift-contrib-f9c432ca127d6e7d87b49d2fbf6aace34bea0e06.zip swift-contrib-f9c432ca127d6e7d87b49d2fbf6aace34bea0e06.tar.bz2 |
Add support for kicking people from MUCs.
This also introduces a new DOM-like parser structure, used for the
MUC parsers.
Partially
Resolves: #689
Diffstat (limited to 'Swift/QtUI/Roster/QtOccupantListWidget.cpp')
-rw-r--r-- | Swift/QtUI/Roster/QtOccupantListWidget.cpp | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/Swift/QtUI/Roster/QtOccupantListWidget.cpp b/Swift/QtUI/Roster/QtOccupantListWidget.cpp index 2f992bf..cbda0f1 100644 --- a/Swift/QtUI/Roster/QtOccupantListWidget.cpp +++ b/Swift/QtUI/Roster/QtOccupantListWidget.cpp @@ -9,6 +9,7 @@ #include <QContextMenuEvent> #include <QMenu> +#include <QAction> #include <QInputDialog> #include "Swift/Controllers/Roster/ContactRosterItem.h" @@ -26,33 +27,33 @@ QtOccupantListWidget::~QtOccupantListWidget() { } +void QtOccupantListWidget::setAvailableOccupantActions(const std::vector<ChatWindow::OccupantAction>& actions) { + availableOccupantActions_ = actions; +} + void QtOccupantListWidget::contextMenuEvent(QContextMenuEvent* event) { -// QModelIndex index = indexAt(event->pos()); -// if (!index.isValid()) { -// return; -// } -// RosterItem* item = static_cast<RosterItem*>(index.internalPointer()); -// 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* renameGroupAction = contextMenu.addAction(tr("Rename")); -// QAction* result = contextMenu.exec(event->globalPos()); -// if (result == renameGroupAction) { -// renameGroup(group); -// } -// } + QModelIndex index = indexAt(event->pos()); + if (!index.isValid()) { + return; + } + RosterItem* item = static_cast<RosterItem*>(index.internalPointer()); + ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item); + if (contact) { + QMenu contextMenu; + std::map<QAction*, ChatWindow::OccupantAction> actions; + foreach (ChatWindow::OccupantAction availableAction, availableOccupantActions_) { + QString text = "Error: missing string"; + switch (availableAction) { + case ChatWindow::Kick: text = tr("Kick user"); break; + } + QAction* action = contextMenu.addAction(text); + actions[action] = availableAction; + } + QAction* result = contextMenu.exec(event->globalPos()); + if (result) { + onOccupantActionSelected(actions[result], contact); + } + } } } |