diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-08-31 19:10:57 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-09-03 10:02:35 (GMT) |
commit | eb50ea03ab7fc41610a8945002fe19dd30ffb5d7 (patch) | |
tree | d26d378e2996b163f13562488eb2bbc31d89db04 /Swift/QtUI | |
parent | 276d7f82ba42cdbc65ec5c9f35873a265a69bd73 (diff) | |
download | swift-eb50ea03ab7fc41610a8945002fe19dd30ffb5d7.zip swift-eb50ea03ab7fc41610a8945002fe19dd30ffb5d7.tar.bz2 |
Squash presence in chat and MUC windows.
Join/Parts will be shown in one block if they're uninterrupted, and only the last presence change in a row will be shown for chats.
Resolves: #230
Resolves: #430
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatView.cpp | 21 | ||||
-rw-r--r-- | Swift/QtUI/QtChatView.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 1 |
4 files changed, 19 insertions, 11 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp index ef558b7..d48365b 100644 --- a/Swift/QtUI/QtChatView.cpp +++ b/Swift/QtUI/QtChatView.cpp @@ -106,16 +106,21 @@ void QtChatView::addToDOM(boost::shared_ptr<ChatSnippet> snippet) { } } -void QtChatView::correctLastMessage(const QString& newMessage) { +void QtChatView::replaceLastMessage(const QString& newMessage) { /* FIXME: must be queued */ - lastElement_.findFirst("swift_message"); - lastElement_.setPlainText(ChatSnippet::escape(newMessage)); + 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(); } -void QtChatView::correctLastMessage(const QString& newMessage, const QString& note) { - correctLastMessage(newMessage); - lastElement_.findFirst("swift_time"); - lastElement_.setPlainText(ChatSnippet::escape(note)); +void QtChatView::replaceLastMessage(const QString& newMessage, const QString& note) { + replaceLastMessage(newMessage); + QWebElement replace = lastElement_.findFirst("span.swift_time"); + assert(!replace.isNull()); + replace.setInnerXml(ChatSnippet::escape(note)); } void QtChatView::copySelectionToClipboard() { @@ -147,8 +152,6 @@ void QtChatView::handleViewLoadFinished(bool ok) { Q_ASSERT(ok); viewReady_ = true; addQueuedSnippets(); -// webPage_->mainFrame()->evaluateJavaScript(queuedMessages_); -// queuedMessages_.clear(); } } diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h index 01c1ad7..ce1f8bc 100644 --- a/Swift/QtUI/QtChatView.h +++ b/Swift/QtUI/QtChatView.h @@ -28,8 +28,8 @@ namespace Swift { QtChatView(QtChatTheme* theme, QWidget* parent); void addMessage(boost::shared_ptr<ChatSnippet> snippet); - void correctLastMessage(const QString& newMessage); - void correctLastMessage(const QString& newMessage, const QString& note); + void replaceLastMessage(const QString& newMessage); + void replaceLastMessage(const QString& newMessage, const QString& note); bool isScrolledToBottom() const; signals: diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 53b0dde..70bde4b 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -370,4 +370,8 @@ void QtChatWindow::moveEvent(QMoveEvent*) { emit geometryChanged(); } +void QtChatWindow::replaceLastMessage(const String& message) { + messageLog_->replaceLastMessage(P2QSTRING(message)); +} + } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 2b006d9..a51b866 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -49,6 +49,7 @@ namespace Swift { void setRosterModel(Roster* roster); void setTabComplete(TabComplete* completer); int getCount(); + void replaceLastMessage(const String& message); signals: void geometryChanged(); |