diff options
Diffstat (limited to 'Swift/QtUI/ChatList')
-rw-r--r-- | Swift/QtUI/ChatList/ChatListModel.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/ChatListModel.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/QtChatListWindow.cpp | 11 |
3 files changed, 16 insertions, 3 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) { |