diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/ChatListGroupItem.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/ChatListMUCItem.h | 6 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/ChatListModel.cpp | 16 | ||||
-rw-r--r-- | Swift/QtUI/SConscript | 1 |
6 files changed, 24 insertions, 10 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index d83c42e..8311726 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -50,7 +50,7 @@ ChatsManager::~ChatsManager() { void ChatsManager::handleMUCBookmarkAdded(boost::shared_ptr<MUCBookmark> bookmark) { std::map<JID, MUCController*>::iterator it = mucControllers_.find(bookmark->getRoom()); - if (it == mucControllers_.end()) { + if (it == mucControllers_.end() && bookmark->getAutojoin()) { //FIXME: need vcard stuff here to get a nick String nick = bookmark->getNick() ? bookmark->getNick().get() : "Swift user"; handleJoinMUCRequest(bookmark->getRoom(), nick); diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index 2bab1df..acc96db 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -6,6 +6,7 @@ #include "Swift/Controllers/UIInterfaces/ChatWindow.h" #include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h" +#include "Swift/Controllers/UIInterfaces/ChatListWindowFactory.h" #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swiften/Client/Client.h" #include "Swift/Controllers/Chat/ChatController.h" @@ -54,15 +55,16 @@ public: serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(new DiscoInfo()); presenceSender_ = NULL; uiEventStream_ = new UIEventStream(); - manager_ = new ChatsManager(jid_, stanzaChannel_, iqRouter_, eventController_, chatWindowFactory_, treeWidgetFactory_, nickResolver_, presenceOracle_, serverDiscoInfo_, presenceSender_, uiEventStream_); + chatListWindowFactory_ = mocks_->InterfaceMock<ChatListWindowFactory>(); + manager_ = new ChatsManager(jid_, stanzaChannel_, iqRouter_, eventController_, chatWindowFactory_, treeWidgetFactory_, nickResolver_, presenceOracle_, serverDiscoInfo_, presenceSender_, uiEventStream_, chatListWindowFactory_); avatarManager_ = new MockAvatarManager(); manager_->setAvatarManager(avatarManager_); }; void tearDown() { + delete avatarManager_; delete manager_; delete presenceSender_; - delete avatarManager_; delete presenceOracle_; delete nickResolver_; delete treeWidgetFactory_; @@ -267,6 +269,7 @@ private: PresenceSender* presenceSender_; MockRepository* mocks_; UIEventStream* uiEventStream_; + ChatListWindowFactory* chatListWindowFactory_; }; CPPUNIT_TEST_SUITE_REGISTRATION(ChatsManagerTest); diff --git a/Swift/QtUI/ChatList/ChatListGroupItem.h b/Swift/QtUI/ChatList/ChatListGroupItem.h index 82c9616..eb9729b 100644 --- a/Swift/QtUI/ChatList/ChatListGroupItem.h +++ b/Swift/QtUI/ChatList/ChatListGroupItem.h @@ -13,7 +13,7 @@ namespace Swift { int rowCount() {return items_.size();}; ChatListItem* item(int i) {return items_[i];}; int row(ChatListItem* item) {return items_.indexOf(item);}; - QVariant data(int role) {return "Bob";}; + QVariant data(int role) {return (role == Qt::DisplayRole) ? name_ : QVariant();}; private: QString name_; QList<ChatListItem*> items_; diff --git a/Swift/QtUI/ChatList/ChatListMUCItem.h b/Swift/QtUI/ChatList/ChatListMUCItem.h index dd3f185..b973ac2 100644 --- a/Swift/QtUI/ChatList/ChatListMUCItem.h +++ b/Swift/QtUI/ChatList/ChatListMUCItem.h @@ -11,9 +11,9 @@ namespace Swift { class ChatListMUCItem : public ChatListItem { public: - ChatListMUCItem(boost::shared_ptr<MUCBookmark> bookmark, ChatListGroupItem* parent) : ChatListItem(parent), bookmark_(bookmark) {}; - boost::shared_ptr<MUCBookmark> getBookmark() {return bookmark_;}; - QVariant data(int role) { return QVariant(); }; + ChatListMUCItem(boost::shared_ptr<MUCBookmark> bookmark, ChatListGroupItem* parent); + boost::shared_ptr<MUCBookmark> getBookmark(); + QVariant data(int role); private: boost::shared_ptr<MUCBookmark> bookmark_; QList<ChatListItem*> items_; diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp index 246d45d..1a1bb80 100644 --- a/Swift/QtUI/ChatList/ChatListModel.cpp +++ b/Swift/QtUI/ChatList/ChatListModel.cpp @@ -7,12 +7,16 @@ namespace Swift { ChatListModel::ChatListModel() { root_ = new ChatListGroupItem("", NULL); mucBookmarks_ = new ChatListGroupItem("MUC Bookmarks", root_); + root_->addItem(mucBookmarks_); } void ChatListModel::addMUCBookmark(boost::shared_ptr<Swift::MUCBookmark> bookmark) { emit layoutAboutToBeChanged(); mucBookmarks_->addItem(new ChatListMUCItem(bookmark, mucBookmarks_)); emit layoutChanged(); + //QModelIndex index = createIndex(mucBookmarks_->rowCount() - 1, 0, mucBookmarks_); + //emit dataChanged(index, index); + //emit dataChanged(parent(index), parent(index)); } void ChatListModel::removeMUCBookmark(boost::shared_ptr<Swift::MUCBookmark> bookmark) { @@ -54,11 +58,17 @@ QModelIndex ChatListModel::parent(const QModelIndex& index) const { } int ChatListModel::rowCount(const QModelIndex& parentIndex) const { - ChatListGroupItem* parent = root_; + ChatListGroupItem* parent = NULL; + printf("Counting\n"); if (parentIndex.isValid()) { - parent = static_cast<ChatListGroupItem*>(parentIndex.internalPointer()); + printf("Valid index\n"); + parent = dynamic_cast<ChatListGroupItem*>(static_cast<ChatListItem*>(parentIndex.internalPointer())); + } else { + parent = root_; } - return parent ? parent->rowCount() : 0; + int count = (parent ? parent->rowCount() : 0); + printf("Count returned as %d, muc count is %d\n", count, mucBookmarks_->rowCount()); + return count; } } diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index d2e6c37..e0e41bc 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -88,6 +88,7 @@ sources = [ "ChatList/QtChatListWindowFactory.cpp", "ChatList/ChatListModel.cpp", "ChatList/ChatListDelegate.cpp", + "ChatList/ChatListMUCItem.cpp", "QtSubscriptionRequestWindow.cpp", "QtRosterHeader.cpp", "qrc_DefaultTheme.cc", |