diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-02-06 22:50:30 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-02-07 15:22:48 (GMT) |
commit | afcfa9dd33cfb5e36edf7d8148a7f8b24c976741 (patch) | |
tree | c16d40dbb089a9bcf70fafc2d50def34a9984e58 /Swift/QtUI/ContextMenus | |
parent | 90a511ed523cfaf500dd27316b12e128e0c70ce3 (diff) | |
download | swift-afcfa9dd33cfb5e36edf7d8148a7f8b24c976741.zip swift-afcfa9dd33cfb5e36edf7d8148a7f8b24c976741.tar.bz2 |
Reworking contact editing.
Collapsed rename, group edit, and remove into one dialog.
Moved contact editing logic to controllers.
Diffstat (limited to 'Swift/QtUI/ContextMenus')
-rw-r--r-- | Swift/QtUI/ContextMenus/QtContextMenu.cpp | 14 | ||||
-rw-r--r-- | Swift/QtUI/ContextMenus/QtContextMenu.h | 17 | ||||
-rw-r--r-- | Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp | 112 | ||||
-rw-r--r-- | Swift/QtUI/ContextMenus/QtRosterContextMenu.h | 34 |
4 files changed, 0 insertions, 177 deletions
diff --git a/Swift/QtUI/ContextMenus/QtContextMenu.cpp b/Swift/QtUI/ContextMenus/QtContextMenu.cpp deleted file mode 100644 index c74fb31..0000000 --- a/Swift/QtUI/ContextMenus/QtContextMenu.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include "ContextMenus/QtContextMenu.h" - -namespace Swift { - -QtContextMenu::~QtContextMenu() { -} - -} diff --git a/Swift/QtUI/ContextMenus/QtContextMenu.h b/Swift/QtUI/ContextMenus/QtContextMenu.h deleted file mode 100644 index 9e73ef9..0000000 --- a/Swift/QtUI/ContextMenus/QtContextMenu.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -namespace Swift { - class RosterItem; - class QtContextMenu { - public: - virtual ~QtContextMenu(); - - virtual void show(RosterItem* item) = 0; - }; -} diff --git a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp b/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp deleted file mode 100644 index 9bbbbca..0000000 --- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include "Swift/QtUI/ContextMenus/QtRosterContextMenu.h" - -#include <QInputDialog> -#include <QLineEdit> -#include <QMenu> -#include <QDebug> -#include <QDialog> -#include <QMessageBox> - -#include <boost/shared_ptr.hpp> - -#include "Swiften/Roster/ContactRosterItem.h" -#include "Swiften/Roster/GroupRosterItem.h" -#include "Swiften/Base/String.h" -#include "Swiften/Roster/Roster.h" -#include "Swift/Controllers/UIEvents/UIEvent.h" -#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h" -#include "Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h" -#include "Swift/QtUI/QtSwiftUtil.h" -#include "Swift/QtUI/QtSetGroupsDialog.h" - - -namespace Swift { - -QtRosterContextMenu::QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidget* treeWidget) : eventStream_(eventStream), treeWidget_(treeWidget), item_(NULL) { -} - -void QtRosterContextMenu::show(RosterItem* item) { - ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item); - item_ = item; - QMenu contextMenu; - if (contact) { - contextMenu.addAction("Rename", this, SLOT(handleRenameContact())); - contextMenu.addAction("Groups", this, SLOT(handleRegroupContact())); - contextMenu.addSeparator(); - contextMenu.addAction("Remove", this, SLOT(handleRemoveContact())); - } - GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item); - if (group) { - contextMenu.addAction("Rename", this, SLOT(handleRenameGroup())); - } - contextMenu.exec(QCursor::pos()); -} - -void QtRosterContextMenu::handleRegroupContact() { - QList<QString> allGroups; - foreach (RosterItem* item, treeWidget_->getRoster()->getRoot()->getChildren()) { - GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item); - if (group) { - allGroups.push_back(P2QSTRING(group->getDisplayName())); - } - } - ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item_); - assert(contact); - QtSetGroupsDialog groupDialog(contact, allGroups); - - if (groupDialog.exec() == QDialog::Accepted) { - eventStream_->send(groupDialog.getRegroupEvent()); - } -} - -void QtRosterContextMenu::handleRemoveContact() { - ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item_); - assert(contact); - QMessageBox msgBox; - msgBox.setWindowTitle("Confirm contact deletion"); - msgBox.setText("Are you sure you want to delete this contact?"); - msgBox.setInformativeText(QString("This will remove the contact '%1' from all groups they may be in.").arg(P2QSTRING(contact->getJID().toString()))); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) { - 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)))); - } -} - -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 deleted file mode 100644 index 0a88a8e..0000000 --- a/Swift/QtUI/ContextMenus/QtRosterContextMenu.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2010 Kevin Smith - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -#include <QObject> - -#include "Swift/QtUI/ContextMenus/QtContextMenu.h" -#include "Swift/QtUI/Roster/QtTreeWidget.h" -#include "Swift/Controllers/UIEvents/UIEventStream.h" - -namespace Swift { - class RosterItem; - class QtRosterContextMenu : public QObject, public QtContextMenu { - Q_OBJECT - public: - QtRosterContextMenu(UIEventStream* eventStream, QtTreeWidget* treeWidget); - void show(RosterItem* item); - - private slots: - void handleRemoveContact(); - void handleRenameContact(); - void handleRenameGroup(); - void handleRegroupContact(); - - private: - UIEventStream* eventStream_; - QtTreeWidget* treeWidget_; - RosterItem* item_; - }; -} |