summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-07-24 13:26:05 (GMT)
committerCătălin Badea <catalin.badea392@gmail.com>2012-08-11 15:59:12 (GMT)
commit22d4e0bfe7d78beba9fb24ef71513702340993b5 (patch)
tree99d309d8d875a7af6348bcec734b85fc819ab104 /Swift
parent11343358c77553291adbbac69e3aa0439dec3769 (diff)
downloadswift-contrib-22d4e0bfe7d78beba9fb24ef71513702340993b5.zip
swift-contrib-22d4e0bfe7d78beba9fb24ef71513702340993b5.tar.bz2
Append messages to bottom.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/MessageSnippet.cpp2
-rw-r--r--Swift/QtUI/QtChatView.cpp2
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp18
-rw-r--r--Swift/QtUI/QtHistoryWindow.h4
4 files changed, 23 insertions, 3 deletions
diff --git a/Swift/QtUI/MessageSnippet.cpp b/Swift/QtUI/MessageSnippet.cpp
index 51c9c78..a10ee2c 100644
--- a/Swift/QtUI/MessageSnippet.cpp
+++ b/Swift/QtUI/MessageSnippet.cpp
@@ -37,7 +37,7 @@ MessageSnippet::MessageSnippet(const QString& message, const QString& sender, co
content_.replace("%time%", wrapResizable("<span class='swift_time'>" + timeToEscapedString(time) + "</span>"));
content_.replace("%userIconPath%", escape(iconURI));
content_ = "<div id='" + id + "'>" + content_ + "</div>";
- content_ = "<div class='date" + time.date().toString(Qt::ISODate) + "'>" + content_ + "</span>";
+ content_ = "<span class='date" + time.date().toString(Qt::ISODate) + "'>" + content_ + "</span>";
}
MessageSnippet::~MessageSnippet() {
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index b2a1754..0af1262 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -106,8 +106,10 @@ void QtChatView::addMessageTop(boost::shared_ptr<ChatSnippet> snippet) {
topMessageAdded_ = true;
QWebElement newElement = snippetToDOM(snippet);
+
firstElement_.prependOutside(newElement);
firstElement_ = newElement;
+
if (lastElement_.isNull()) {
lastElement_ = firstElement_;
}
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index b3603a8..0a7c5b5 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -27,7 +27,9 @@
namespace Swift {
-QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* eventStream) {
+QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* eventStream) :
+ previousTopMessageWasSelf_(false),
+ previousBottomMessageWasSelf_(false) {
ui_.setupUi(this);
theme_ = new QtChatTheme("");
@@ -112,10 +114,17 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string &
QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded();
if (addAtTheTop) {
+ // bool appendToPrevious = ((senderIsSelf && previousTopMessageWasSelf_) || (!senderIsSelf && !previousTopMessageWasSelf_&& previousTopSenderName_ == P2QSTRING(senderName)));
conversation_->addMessageTop(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, false, theme_, P2QSTRING(id))));
+
+ previousTopMessageWasSelf_ = senderIsSelf;
+ previousTopSenderName_ = P2QSTRING(senderName);
}
else {
- conversation_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, false, theme_, P2QSTRING(id))));
+ bool appendToPrevious = ((senderIsSelf && previousBottomMessageWasSelf_) || (!senderIsSelf && !previousBottomMessageWasSelf_&& previousBottomSenderName_ == P2QSTRING(senderName)));
+ conversation_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
+ previousBottomMessageWasSelf_ = senderIsSelf;
+ previousBottomSenderName_ = P2QSTRING(senderName);
}
// keep track of the days viewable in the chatView
@@ -129,6 +138,11 @@ void QtHistoryWindow::handleSomethingSelectedChanged(RosterItem* item) {
}
void QtHistoryWindow::resetConversationView() {
+ previousTopMessageWasSelf_ = false;
+ previousBottomMessageWasSelf_ = false;
+ previousTopSenderName_.clear();
+ previousBottomSenderName_.clear();
+
dates_.clear();
conversation_->resetView();
}
diff --git a/Swift/QtUI/QtHistoryWindow.h b/Swift/QtUI/QtHistoryWindow.h
index cdffe69..c813b82 100644
--- a/Swift/QtUI/QtHistoryWindow.h
+++ b/Swift/QtUI/QtHistoryWindow.h
@@ -54,5 +54,9 @@ namespace Swift {
QtTreeWidget* conversationRoster_;
std::set<QDate> dates_;
int idCounter_;
+ bool previousTopMessageWasSelf_;
+ QString previousTopSenderName_;
+ bool previousBottomMessageWasSelf_;
+ QString previousBottomSenderName_;
};
}