From 743388feda5091bd6e54d88f66d2866a59205f35 Mon Sep 17 00:00:00 2001 From: Catalin Badea Date: Tue, 19 Jun 2012 23:16:09 +0300 Subject: Added contact roster diff --git a/Swift/Controllers/HistoryController.cpp b/Swift/Controllers/HistoryController.cpp index 4f97006..6d8e68e 100644 --- a/Swift/Controllers/HistoryController.cpp +++ b/Swift/Controllers/HistoryController.cpp @@ -18,13 +18,24 @@ HistoryController::HistoryController(UIEventStream* uiEventStream, HistoryWindow HistoryController::~HistoryController() { uiEventStream_->onUIEvent.disconnect(boost::bind(&HistoryController::handleUIEvent, this, _1)); delete historyWindow_; + delete roster_; } void HistoryController::handleUIEvent(boost::shared_ptr rawEvent) { boost::shared_ptr event = boost::dynamic_pointer_cast(rawEvent); if (event != NULL) { if (historyWindow_ == NULL) { - historyWindow_ = historyWindowFactory_->createHistoryWindow(); + historyWindow_ = historyWindowFactory_->createHistoryWindow(uiEventStream_); + roster_ = new Roster(false, true); + historyWindow_->setRosterModel(roster_); + + JID putin("vputin@karla.com"); + JID medvedev("dmedvedev@karla.com"); + JID kev("kevin@doomsong.co.uk"); + const std::set none; + roster_->addContact(putin, putin, "Vladimir Putin", "Recent", ""); + roster_->addContact(medvedev, medvedev, "Dmitri Medvedev", "Recent", ""); + roster_->addContact(kev, kev, "Kev", "Recent", ""); } historyWindow_->activate(); } diff --git a/Swift/Controllers/HistoryController.h b/Swift/Controllers/HistoryController.h index 47ae361..320b26e 100644 --- a/Swift/Controllers/HistoryController.h +++ b/Swift/Controllers/HistoryController.h @@ -15,6 +15,7 @@ namespace Swift { class HistoryWindowFactory; class HistoryWindow; + class Roster; class HistoryController { public: @@ -28,5 +29,6 @@ namespace Swift { UIEventStream* uiEventStream_; HistoryWindowFactory* historyWindowFactory_; HistoryWindow* historyWindow_; + Roster* roster_; }; } diff --git a/Swift/Controllers/UIInterfaces/HistoryWindow.h b/Swift/Controllers/UIInterfaces/HistoryWindow.h index cb29120..713f986 100644 --- a/Swift/Controllers/UIInterfaces/HistoryWindow.h +++ b/Swift/Controllers/UIInterfaces/HistoryWindow.h @@ -6,11 +6,14 @@ #pragma once +#include + namespace Swift { class HistoryWindow { public: virtual ~HistoryWindow() {}; virtual void activate() = 0; + virtual void setRosterModel(Roster*) = 0; }; } diff --git a/Swift/Controllers/UIInterfaces/HistoryWindowFactory.h b/Swift/Controllers/UIInterfaces/HistoryWindowFactory.h index 135438b..e91bc37 100644 --- a/Swift/Controllers/UIInterfaces/HistoryWindowFactory.h +++ b/Swift/Controllers/UIInterfaces/HistoryWindowFactory.h @@ -13,6 +13,6 @@ namespace Swift { class HistoryWindowFactory { public: virtual ~HistoryWindowFactory() {}; - virtual HistoryWindow* createHistoryWindow() = 0; + virtual HistoryWindow* createHistoryWindow(UIEventStream* eventStream) = 0; }; } diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index 192406e..4b459de 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -16,25 +16,37 @@ namespace Swift { -QtHistoryWindow::QtHistoryWindow() { +QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* eventStream) { ui_.setupUi(this); QtChatTheme* theme = new QtChatTheme(""); // FIXME: leak - delete ui_.conversation; + delete ui_.conversation_; conversation_ = new QtChatView(theme, this); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(80); sizePolicy.setVerticalStretch(0); conversation_->setSizePolicy(sizePolicy); - ui_.conversation = conversation_; - ui_.bottomLayout->addWidget(conversation_); + ui_.conversation_ = conversation_; + ui_.bottomLayout_->addWidget(conversation_); - conversation_->addMessage(boost::make_shared("hey", "Me", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/storage/iron_man.png", false, false, theme, "id")); - conversation_->addMessage(boost::make_shared("hey", "You", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/storage/war_machine.png", true, false, theme, "id2")); - conversation_->addMessage(boost::make_shared("knock knock", "Me", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/storage/iron_man.png", false, false, theme, "id")); - conversation_->addMessage(boost::make_shared("who's there?", "You", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/storage/war_machine.png", true, false, theme, "id2")); + delete ui_.conversationRoster_; + conversationRoster_ = new QtRosterWidget(eventStream, settings, this); + QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Expanding); + sizePolicy2.setVerticalStretch(80); + conversationRoster_->setSizePolicy(sizePolicy2); + ui_.conversationRoster_ = conversationRoster_; + ui_.bottomLeftLayout_->setDirection(QBoxLayout::BottomToTop); + ui_.bottomLeftLayout_->addWidget(conversationRoster_); + + conversation_->addMessage(boost::make_shared("Hi", "Me", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/iron-man.png", false, false, theme, "id")); + conversation_->addMessage(boost::make_shared("Hi", "You", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/putin.png", true, false, theme, "id2")); + conversation_->addMessage(boost::make_shared("How is it going?", "Me", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/iron-man.png", false, false, theme, "id")); + conversation_->addMessage(boost::make_shared("Fine, just going through some documents.", "You", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/putin.png", true, false, theme, "id2")); + conversation_->addMessage(boost::make_shared("Cool. Hey, do you want to go for a beer?", "Me", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/iron-man.png", false, false, theme, "id")); + conversation_->addMessage(boost::make_shared("Sure. Meet me at the pub around 10?", "You", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/putin.png", true, false, theme, "id2")); + conversation_->addMessage(boost::make_shared("See you there.", "Me", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/iron-man.png", false, false, theme, "id")); setWindowTitle(tr("History")); } @@ -57,4 +69,8 @@ void QtHistoryWindow::closeEvent(QCloseEvent* event) { event->accept(); } +void QtHistoryWindow::setRosterModel(Roster* model) { + conversationRoster_->setRosterModel(model); +} + } diff --git a/Swift/QtUI/QtHistoryWindow.h b/Swift/QtUI/QtHistoryWindow.h index 08db473..d61fb49 100644 --- a/Swift/QtUI/QtHistoryWindow.h +++ b/Swift/QtUI/QtHistoryWindow.h @@ -10,6 +10,7 @@ #include #include #include +#include class QTextEdit; class QCheckBox; @@ -20,9 +21,10 @@ namespace Swift { Q_OBJECT public: - QtHistoryWindow(); + QtHistoryWindow(SettingsProvider*, UIEventStream*); ~QtHistoryWindow(); void activate(); + void setRosterModel(Roster*); private: virtual void closeEvent(QCloseEvent* event); @@ -30,5 +32,6 @@ namespace Swift { Ui::QtHistoryWindow ui_; QtChatView* conversation_; + QtRosterWidget* conversationRoster_; }; } diff --git a/Swift/QtUI/QtHistoryWindow.ui b/Swift/QtUI/QtHistoryWindow.ui index 83168ab..77d592f 100644 --- a/Swift/QtUI/QtHistoryWindow.ui +++ b/Swift/QtUI/QtHistoryWindow.ui @@ -13,18 +13,18 @@ Form - - - + + + - + Search: - + 0 @@ -36,43 +36,55 @@ - - - - - - Qt::Horizontal - - - - - 5 - 0 - - - - - 180 - 0 - - - + + - War Machine + Next - - - - Nick Fury + + false - - + + + + - Hawkeye + Previous - + + + + + + + + Qt::Horizontal + + + + + + + + 5 + 0 + + + + + + + + + 0 + 0 + + + + + - + 85 diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index 03a2929..7963205 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -45,8 +45,8 @@ XMLConsoleWidget* QtUIFactory::createXMLConsoleWidget() { return widget; } -HistoryWindow* QtUIFactory::createHistoryWindow() { - QtHistoryWindow* window = new QtHistoryWindow(); +HistoryWindow* QtUIFactory::createHistoryWindow(UIEventStream* uiEventStream) { + QtHistoryWindow* window = new QtHistoryWindow(settings, uiEventStream); tabs->addTab(window); if (!tabs->isVisible()) { tabs->show(); diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h index 0fa95b8..b30eecb 100644 --- a/Swift/QtUI/QtUIFactory.h +++ b/Swift/QtUI/QtUIFactory.h @@ -31,7 +31,7 @@ namespace Swift { QtUIFactory(SettingsProviderHierachy* settings, QtSettingsProvider* qtOnlySettings, QtChatTabs* tabs, QSplitter* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory, TimerFactory* timerFactory, bool startMinimized, bool emoticonsExist); virtual XMLConsoleWidget* createXMLConsoleWidget(); - virtual HistoryWindow* createHistoryWindow(); + virtual HistoryWindow* createHistoryWindow(UIEventStream*); virtual MainWindow* createMainWindow(UIEventStream* eventStream); virtual LoginWindow* createLoginWindow(UIEventStream* eventStream); virtual EventWindow* createEventWindow(); -- cgit v0.10.2-6-g49f6