summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-11-21 19:43:42 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-11-21 19:51:36 (GMT)
commit90c44a10fec26d2a0935b2d62e82b6a5be028373 (patch)
tree43fec4088f5fe3a10320dc125206a3d48402b346 /Swift/QtUI/QtChatView.cpp
parent4bda0cd18e86f037c3f494f1ea7ba5efedaf5042 (diff)
downloadswift-90c44a10fec26d2a0935b2d62e82b6a5be028373.zip
swift-90c44a10fec26d2a0935b2d62e82b6a5be028373.tar.bz2
Clearing the chat window won't break continuation elements.
Resolves: #642 Resolves: #643 Release-Notes: Clearing the chat windows should now work correctly.
Diffstat (limited to 'Swift/QtUI/QtChatView.cpp')
-rw-r--r--Swift/QtUI/QtChatView.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 2a66fc0..4738da3 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -75,9 +75,12 @@ QWebElement QtChatView::snippetToDOM(boost::shared_ptr<ChatSnippet> snippet) {
void QtChatView::addToDOM(boost::shared_ptr<ChatSnippet> snippet) {
rememberScrolledToBottom();
- QWebElement newElement = snippetToDOM(snippet);
+ bool insert = snippet->getAppendToPrevious();
QWebElement continuationElement = lastElement_.findFirst("#insert");
- if (snippet->getAppendToPrevious()) {
+ bool fallback = insert && continuationElement.isNull();
+ boost::shared_ptr<ChatSnippet> newSnippet = (insert && fallback) ? snippet->getContinuationFallbackSnippet() : snippet;
+ QWebElement newElement = snippetToDOM(newSnippet);
+ if (insert && !fallback) {
Q_ASSERT(!continuationElement.isNull());
continuationElement.replace(newElement);
} else {
@@ -155,6 +158,7 @@ void QtChatView::handleViewLoadFinished(bool ok) {
}
void QtChatView::resetView() {
+ lastElement_ = QWebElement();
QString pageHTML = theme_->getTemplate();
pageHTML.replace("==bodyBackground==", "background-color:#e3e3e3");
pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getBase());