diff options
| author | Catalin Badea <catalin.badea392@gmail.com> | 2012-07-24 13:26:05 (GMT) | 
|---|---|---|
| committer | Cătălin Badea <catalin.badea392@gmail.com> | 2012-08-11 15:59:12 (GMT) | 
| commit | 22d4e0bfe7d78beba9fb24ef71513702340993b5 (patch) | |
| tree | 99d309d8d875a7af6348bcec734b85fc819ab104 /Swift/QtUI/QtHistoryWindow.cpp | |
| parent | 11343358c77553291adbbac69e3aa0439dec3769 (diff) | |
| download | swift-contrib-22d4e0bfe7d78beba9fb24ef71513702340993b5.zip swift-contrib-22d4e0bfe7d78beba9fb24ef71513702340993b5.tar.bz2  | |
Append messages to bottom.
Diffstat (limited to 'Swift/QtUI/QtHistoryWindow.cpp')
| -rw-r--r-- | Swift/QtUI/QtHistoryWindow.cpp | 18 | 
1 files changed, 16 insertions, 2 deletions
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();  }  | 
 Swift