summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-04-28 12:28:02 (GMT)
committerTobias Markmann <tm@ayena.de>2015-04-28 19:26:00 (GMT)
commit68263f7cb360ae52915017df202775665c4eeeb6 (patch)
tree59dd2f8cece17d46e585fb00111fbc026fc1e9ce /Swift/QtUI/ChatList/QtChatListWindow.cpp
parent4ac05ebaf6c913b4bfcc7c4e7abeb6ace9efe5c8 (diff)
downloadswift-68263f7cb360ae52915017df202775665c4eeeb6.zip
swift-68263f7cb360ae52915017df202775665c4eeeb6.tar.bz2
Allow editing bookmarks of MUC chats in the "Recent Chats"
Test-Information: Tested with online and offline account. Tested with not bookmarked and already bookmarked chats. Works as expected. Change-Id: Ib8851a70a7a82a198ee5b7a207816f03ad9df61e
Diffstat (limited to 'Swift/QtUI/ChatList/QtChatListWindow.cpp')
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp
index 71d4f1b..7b40f9c 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.cpp
+++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright (c) 2010-2014 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
-#include "Swift/QtUI/ChatList/QtChatListWindow.h"
+#include <Swift/QtUI/ChatList/QtChatListWindow.h>
#include <boost/bind.hpp>
@@ -20,6 +20,7 @@
#include <Swift/Controllers/UIEvents/RemoveMUCBookmarkUIEvent.h>
#include <Swift/Controllers/UIEvents/RequestChatUIEvent.h>
#include <Swift/Controllers/UIEvents/ShowWhiteboardUIEvent.h>
+
#include <Swift/QtUI/ChatList/ChatListMUCItem.h>
#include <Swift/QtUI/ChatList/ChatListRecentItem.h>
#include <Swift/QtUI/ChatList/ChatListWhiteboardItem.h>
@@ -58,7 +59,6 @@ QtChatListWindow::~QtChatListWindow() {
delete model_;
delete delegate_;
delete mucMenu_;
- delete mucRecentsMenu_;
delete emptyMenu_;
}
@@ -89,9 +89,6 @@ void QtChatListWindow::setupContextMenus() {
onlineOnlyActions_ << mucMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark()));
onlineOnlyActions_ << mucMenu_->addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark()));
onlineOnlyActions_ << mucMenu_->addAction(tr("Remove Bookmark"), this, SLOT(handleRemoveBookmark()));
- mucRecentsMenu_ = new QMenu();
- onlineOnlyActions_ << mucRecentsMenu_->addAction(tr("Add to Bookmarks"), this, SLOT(handleAddBookmarkFromRecents()));
- mucRecentsMenu_->addAction(tr("Clear recents"), this, SLOT(handleClearRecentsRequested()));
emptyMenu_ = new QMenu();
onlineOnlyActions_ << emptyMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark()));
}
@@ -148,13 +145,13 @@ void QtChatListWindow::setOnline(bool isOnline) {
}
void QtChatListWindow::handleRemoveBookmark() {
- ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(contextMenuItem_);
+ const ChatListMUCItem* mucItem = dynamic_cast<const ChatListMUCItem*>(contextMenuItem_);
if (!mucItem) return;
eventStream_->send(boost::shared_ptr<UIEvent>(new RemoveMUCBookmarkUIEvent(mucItem->getBookmark())));
}
void QtChatListWindow::handleAddBookmarkFromRecents() {
- ChatListRecentItem* item = dynamic_cast<ChatListRecentItem*>(contextMenuItem_);
+ const ChatListRecentItem* item = dynamic_cast<const ChatListRecentItem*>(contextMenuItem_);
if (item) {
const ChatListWindow::Chat& chat = item->getChat();
MUCBookmark bookmark(chat.jid, chat.jid.toBare().toString());
@@ -170,7 +167,7 @@ void QtChatListWindow::handleAddBookmark() {
void QtChatListWindow::handleEditBookmark() {
- ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(contextMenuItem_);
+ const ChatListMUCItem* mucItem = dynamic_cast<const ChatListMUCItem*>(contextMenuItem_);
if (!mucItem) return;
QtEditBookmarkWindow* window = new QtEditBookmarkWindow(eventStream_, mucItem->getBookmark());
window->show();
@@ -209,7 +206,19 @@ void QtChatListWindow::contextMenuEvent(QContextMenuEvent* event) {
if (recentItem) {
const ChatListWindow::Chat& chat = recentItem->getChat();
if (chat.isMUC) {
- mucRecentsMenu_->exec(QCursor::pos());
+ QMenu mucRecentsMenu;
+ QAction* bookmarkAction = NULL;
+ const ChatListMUCItem* mucItem = model_->getChatListMUCItem(chat.jid);
+ if (mucItem) {
+ contextMenuItem_ = mucItem;
+ bookmarkAction = mucRecentsMenu.addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark()));
+ }
+ else {
+ bookmarkAction = mucRecentsMenu.addAction(tr("Add to Bookmarks"), this, SLOT(handleAddBookmarkFromRecents()));
+ }
+ bookmarkAction->setEnabled(isOnline_);
+ mucRecentsMenu.addAction(tr("Clear recents"), this, SLOT(handleClearRecentsRequested()));
+ mucRecentsMenu.exec(QCursor::pos());
return;
}
}