summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-15 21:16:37 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-15 21:19:29 (GMT)
commit1cf2023bc496a4abe5a98138401295b45a0b899a (patch)
tree8516e0132e9aaf197635ef9eb515b2e93256614c /Swift/QtUI
parentbd8af5feb9b61f42c15cab77b19a58dfd93afa06 (diff)
downloadswift-1cf2023bc496a4abe5a98138401295b45a0b899a.zip
swift-1cf2023bc496a4abe5a98138401295b45a0b899a.tar.bz2
Normalise muc joining, allow it from bookmark list.
Resolves: #320
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/ChatList/ChatListModel.cpp7
-rw-r--r--Swift/QtUI/ChatList/ChatListModel.h1
-rw-r--r--Swift/QtUI/ChatList/QtChatListWindow.cpp11
-rw-r--r--Swift/QtUI/QtLoginWindow.h2
-rw-r--r--Swift/QtUI/QtMainWindow.cpp7
-rw-r--r--Swift/QtUI/QtMainWindow.h2
-rw-r--r--Swift/QtUI/QtMainWindowFactory.h2
7 files changed, 25 insertions, 7 deletions
diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp
index 1b01c64..40ed1b7 100644
--- a/Swift/QtUI/ChatList/ChatListModel.cpp
+++ b/Swift/QtUI/ChatList/ChatListModel.cpp
@@ -41,8 +41,13 @@ int ChatListModel::columnCount(const QModelIndex& /*parent*/) const {
return 1;
}
+ChatListItem* ChatListModel::getItemForIndex(const QModelIndex& index) const {
+ return index.isValid() ? static_cast<ChatListItem*>(index.internalPointer()) : NULL;
+}
+
QVariant ChatListModel::data(const QModelIndex& index, int role) const {
- return index.isValid() ? static_cast<ChatListItem*>(index.internalPointer())->data(role) : QVariant();
+ ChatListItem* item = getItemForIndex(index);
+ return item ? item->data(role) : QVariant();
}
QModelIndex ChatListModel::index(int row, int column, const QModelIndex & parent) const {
diff --git a/Swift/QtUI/ChatList/ChatListModel.h b/Swift/QtUI/ChatList/ChatListModel.h
index f7cd137..71849cc 100644
--- a/Swift/QtUI/ChatList/ChatListModel.h
+++ b/Swift/QtUI/ChatList/ChatListModel.h
@@ -27,6 +27,7 @@ namespace Swift {
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& index) const;
int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ ChatListItem* getItemForIndex(const QModelIndex& index) const;
private:
ChatListGroupItem* mucBookmarks_;
ChatListGroupItem* root_;
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp
index c6c8e64..793d89a 100644
--- a/Swift/QtUI/ChatList/QtChatListWindow.cpp
+++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp
@@ -5,6 +5,8 @@
*/
#include "Swift/QtUI/ChatList/QtChatListWindow.h"
+#include "Swift/QtUI/ChatList/ChatListMUCItem.h"
+#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
namespace Swift {
@@ -29,8 +31,13 @@ QtChatListWindow::~QtChatListWindow() {
delete delegate_;
}
-void QtChatListWindow::handleItemActivated(const QModelIndex& item) {
-
+void QtChatListWindow::handleItemActivated(const QModelIndex& index) {
+ ChatListItem* item = model_->getItemForIndex(index);
+ ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(item);
+ if (mucItem) {
+ boost::shared_ptr<UIEvent> event(new JoinMUCUIEvent(mucItem->getBookmark()->getRoom(), mucItem->getBookmark()->getNick()));
+ eventStream_->send(event);
+ }
}
void QtChatListWindow::addMUCBookmark(boost::shared_ptr<MUCBookmark> bookmark) {
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index 654498d..c7b35c7 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -17,7 +17,7 @@
#include "Swift/Controllers/UIInterfaces/LoginWindow.h"
#include "Swift/Controllers/UIEvents/UIEventStream.h"
-#include "Swift/Controllers/MainWindow.h"
+#include "Swift/Controllers/UIInterfaces/MainWindow.h"
#include "QtAboutWidget.h"
class QLabel;
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index 116f52e..c947ae7 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -6,6 +6,8 @@
#include "QtMainWindow.h"
+#include <boost/optional.hpp>
+
#include <QBoxLayout>
#include <QComboBox>
#include <QLineEdit>
@@ -24,6 +26,7 @@
#include "Roster/QtTreeWidgetFactory.h"
#include "Roster/QtTreeWidget.h"
#include "Swift/Controllers/UIEvents/AddContactUIEvent.h"
+#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
namespace Swift {
@@ -137,7 +140,9 @@ void QtMainWindow::handleJoinMUCAction() {
}
void QtMainWindow::handleJoinMUCDialogComplete(const JID& muc, const QString& nick) {
- onJoinMUCRequest(muc, Q2PSTRING(nick));
+ boost::optional<String> maybeNick(Q2PSTRING(nick));
+ boost::shared_ptr<UIEvent> event(new JoinMUCUIEvent(muc, maybeNick));
+ uiEventStream_->send(event);
}
void QtMainWindow::handleStatusChanged(StatusShow::Type showType, const QString &statusMessage) {
diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h
index f846e27..45dbda6 100644
--- a/Swift/QtUI/QtMainWindow.h
+++ b/Swift/QtUI/QtMainWindow.h
@@ -9,7 +9,7 @@
#include <QWidget>
#include <QMenu>
-#include "Swift/Controllers/MainWindow.h"
+#include "Swift/Controllers/UIInterfaces/MainWindow.h"
#include "Swift/QtUI/QtRosterHeader.h"
#include "Swift/QtUI/EventViewer/QtEventWindow.h"
#include "Swift/QtUI/ChatList/QtChatListWindow.h"
diff --git a/Swift/QtUI/QtMainWindowFactory.h b/Swift/QtUI/QtMainWindowFactory.h
index 11414bb..c16d229 100644
--- a/Swift/QtUI/QtMainWindowFactory.h
+++ b/Swift/QtUI/QtMainWindowFactory.h
@@ -7,7 +7,7 @@
#ifndef SWIFT_QtMainWindowFactory_H
#define SWIFT_QtMainWindowFactory_H
-#include "Swift/Controllers/MainWindowFactory.h"
+#include "Swift/Controllers/UIInterfaces/MainWindowFactory.h"
namespace Swift {
class QtTreeWidgetFactory;