diff options
author | Catalin Badea <catalin.badea392@gmail.com> | 2012-06-27 12:02:47 (GMT) |
---|---|---|
committer | Catalin Badea <catalin.badea392@gmail.com> | 2012-06-27 12:02:47 (GMT) |
commit | 0998d6a8f138e0fd00245fc3c1efc8878fa7b888 (patch) | |
tree | d728ad825753ec227ee190a2953db4315cf85d88 /Swift/QtUI | |
parent | ad7d00c25b74d212457fa599861c5583e79e7c13 (diff) | |
download | swift-contrib-0998d6a8f138e0fd00245fc3c1efc8878fa7b888.zip swift-contrib-0998d6a8f138e0fd00245fc3c1efc8878fa7b888.tar.bz2 |
Log messages to the sqlite db and dump all messages in the history viewer
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtHistoryWindow.cpp | 19 | ||||
-rw-r--r-- | Swift/QtUI/QtHistoryWindow.h | 2 |
2 files changed, 11 insertions, 10 deletions
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index 4b459de..d067190 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -9,6 +9,7 @@ #include <QtSwiftUtil.h> #include <MessageSnippet.h> +#include <Swiften/History/HistoryMessage.h> #include <string> #include <boost/shared_ptr.hpp> @@ -19,10 +20,10 @@ namespace Swift { QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* eventStream) { ui_.setupUi(this); - QtChatTheme* theme = new QtChatTheme(""); // FIXME: leak + theme_ = new QtChatTheme(""); delete ui_.conversation_; - conversation_ = new QtChatView(theme, this); + conversation_ = new QtChatView(theme_, this); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(80); sizePolicy.setVerticalStretch(0); @@ -40,18 +41,11 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even ui_.bottomLeftLayout_->setDirection(QBoxLayout::BottomToTop); ui_.bottomLeftLayout_->addWidget(conversationRoster_); - conversation_->addMessage(boost::make_shared<MessageSnippet>("Hi", "Me", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/iron-man.png", false, false, theme, "id")); - conversation_->addMessage(boost::make_shared<MessageSnippet>("Hi", "You", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/putin.png", true, false, theme, "id2")); - conversation_->addMessage(boost::make_shared<MessageSnippet>("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<MessageSnippet>("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<MessageSnippet>("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<MessageSnippet>("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<MessageSnippet>("See you there.", "Me", QDateTime::currentDateTime(), "http://swarm.cs.pub.ro/~cbadea/swift/iron-man.png", false, false, theme, "id")); - setWindowTitle(tr("History")); } QtHistoryWindow::~QtHistoryWindow() { + delete theme_; } void QtHistoryWindow::activate() { @@ -73,4 +67,9 @@ void QtHistoryWindow::setRosterModel(Roster* model) { conversationRoster_->setRosterModel(model); } +void QtHistoryWindow::addMessage(const HistoryMessage& message) { + boost::shared_ptr<MessageSnippet> snippet(new MessageSnippet(QString::fromStdString(message.getMessage()), QString::fromStdString(message.getDisplayNick()), QDateTime::currentDateTime(), "", false, false, theme_, "id")); + conversation_->addMessage(snippet); +} + } diff --git a/Swift/QtUI/QtHistoryWindow.h b/Swift/QtUI/QtHistoryWindow.h index d61fb49..d522f53 100644 --- a/Swift/QtUI/QtHistoryWindow.h +++ b/Swift/QtUI/QtHistoryWindow.h @@ -25,12 +25,14 @@ namespace Swift { ~QtHistoryWindow(); void activate(); void setRosterModel(Roster*); + void addMessage(const HistoryMessage& message); private: virtual void closeEvent(QCloseEvent* event); virtual void showEvent(QShowEvent* event); Ui::QtHistoryWindow ui_; + QtChatTheme* theme_; QtChatView* conversation_; QtRosterWidget* conversationRoster_; }; |