diff options
author | Catalin Badea <catalin.badea392@gmail.com> | 2012-07-01 20:13:27 (GMT) |
---|---|---|
committer | Catalin Badea <catalin.badea392@gmail.com> | 2012-07-01 20:13:27 (GMT) |
commit | 831075a8aeb15dc79c84d28d284b5cdbae2f60ea (patch) | |
tree | e51fa0ff00611e5ca4af7bca1fbfc38a75d640fd /Swift/QtUI | |
parent | 583809c9f96bbf35196c416a1b6e44539b5ceacc (diff) | |
download | swift-contrib-831075a8aeb15dc79c84d28d284b5cdbae2f60ea.zip swift-contrib-831075a8aeb15dc79c84d28d284b5cdbae2f60ea.tar.bz2 |
Dump message logs using new db structure. Avatars not working
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtHistoryWindow.cpp | 21 | ||||
-rw-r--r-- | Swift/QtUI/QtHistoryWindow.h | 2 |
2 files changed, 18 insertions, 5 deletions
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index 24085d9..122655a 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -13,6 +13,13 @@ #include <string> #include <boost/shared_ptr.hpp> + +#include <QTime> +#include <QUrl> +#include <QMenu> +#include <QTextDocument> +#include <Swift/QtUI/QtScaledAvatarCache.h> + #include <boost/smart_ptr/make_shared.hpp> namespace Swift { @@ -69,12 +76,18 @@ void QtHistoryWindow::setRosterModel(Roster* model) { conversationRoster_->setRosterModel(model); } -void QtHistoryWindow::addMessage(const HistoryMessage& message) { - // TODO - // boost::shared_ptr<MessageSnippet> snippet(new MessageSnippet(QString::fromStdString(message.getMessage()), QString::fromStdString(message.getDisplayNick()), QDateTime::currentDateTime(), "", false, false, theme_, "id")); - // conversation_->addMessage(snippet); +void QtHistoryWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const std::string& avatarPath, const boost::posix_time::ptime& time) { + QString scaledAvatarPath = QtScaledAvatarCache(32).getScaledAvatarPath(avatarPath.c_str()); + + QString messageHTML(P2QSTRING(message)); + messageHTML = Qt::escape(messageHTML); + + QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded(); + + conversation_->addMessage(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), B2QDATE(time), qAvatarPath, senderIsSelf, false, theme_, "id"))); } + void QtHistoryWindow::handleSomethingSelectedChanged(RosterItem* item) { conversation_->resetView(); onSelectedContactChanged(item); diff --git a/Swift/QtUI/QtHistoryWindow.h b/Swift/QtUI/QtHistoryWindow.h index 1ddaf61..965abf7 100644 --- a/Swift/QtUI/QtHistoryWindow.h +++ b/Swift/QtUI/QtHistoryWindow.h @@ -21,7 +21,7 @@ namespace Swift { ~QtHistoryWindow(); void activate(); void setRosterModel(Roster*); - void addMessage(const HistoryMessage& message); + void addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const std::string& avatarPath, const boost::posix_time::ptime& time); private: virtual void closeEvent(QCloseEvent* event); |