summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtHistoryWindow.cpp')
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp21
1 files changed, 17 insertions, 4 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);