From 4ef1fd90a178b8525644181615844f6a16e2afd2 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Fri, 17 Sep 2010 19:25:42 +0100 Subject: Scroll to bottom after amending messages as well. Resolves: #570 diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp index 696d16a..0f7e87b 100644 --- a/Swift/QtUI/QtChatView.cpp +++ b/Swift/QtUI/QtChatView.cpp @@ -87,19 +87,21 @@ void QtChatView::addToDOM(boost::shared_ptr snippet) { } lastElement_ = newElement; if (bottom) { - /* Warning: I'm not confident about this.*/ + /* Warning: I'm not confident about this, although it does work.*/ QTimer::singleShot(0, this, SLOT(scrollToBottom())); } } void QtChatView::replaceLastMessage(const QString& newMessage) { - /* FIXME: must be queued */ + /* FIXME: must be queued? */ + bool bottom = isScrolledToBottom(); QWebElement replace = lastElement_.findFirst("span.swift_message"); assert(!replace.isNull()); QString old = lastElement_.toOuterXml(); replace.setInnerXml(ChatSnippet::escape(newMessage)); - //qDebug() << "Replacing old: " << old; - //qDebug() << "With new: " << lastElement_.toOuterXml(); + if (bottom) { + QTimer::singleShot(0, this, SLOT(scrollToBottom())); + } } void QtChatView::replaceLastMessage(const QString& newMessage, const QString& note) { -- cgit v0.10.2-6-g49f6