diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-08-29 15:20:29 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-08-29 17:32:41 (GMT) |
commit | 46b13c4d25270c6933d20c6aa790619e30e4cfe8 (patch) | |
tree | 36fb78a6eb49180ddbffe2d50e5034f89474e72e /Swift/QtUI | |
parent | f2301a18167bc1221cc0b70b71692ce9d1021119 (diff) | |
download | swift-46b13c4d25270c6933d20c6aa790619e30e4cfe8.zip swift-46b13c4d25270c6933d20c6aa790619e30e4cfe8.tar.bz2 |
Added stanza acking support to client.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtXMLConsoleWidget.cpp | 21 | ||||
-rw-r--r-- | Swift/QtUI/QtXMLConsoleWidget.h | 3 |
2 files changed, 16 insertions, 8 deletions
diff --git a/Swift/QtUI/QtXMLConsoleWidget.cpp b/Swift/QtUI/QtXMLConsoleWidget.cpp index 00f9d3b..1e7eff3 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.cpp +++ b/Swift/QtUI/QtXMLConsoleWidget.cpp @@ -71,22 +71,29 @@ void QtXMLConsoleWidget::closeEvent(QCloseEvent* event) { } void QtXMLConsoleWidget::handleDataRead(const String& data) { - textEdit->setTextColor(QColor(33,98,33)); - appendTextIfEnabled(data); + appendTextIfEnabled(data, QColor(33,98,33)); } void QtXMLConsoleWidget::handleDataWritten(const String& data) { - textEdit->setTextColor(QColor(155,1,0)); - appendTextIfEnabled(data); + appendTextIfEnabled(data, QColor(155,1,0)); } -void QtXMLConsoleWidget::appendTextIfEnabled(const String& data) { +void QtXMLConsoleWidget::appendTextIfEnabled(const String& data, const QColor& color) { if (enabled->isChecked()) { QScrollBar* scrollBar = textEdit->verticalScrollBar(); bool scrollToBottom = (!scrollBar || scrollBar->value() == scrollBar->maximum()); - textEdit->append(P2QSTRING(data)); + + QTextCursor cursor(textEdit->document()); + cursor.beginEditBlock(); + cursor.movePosition(QTextCursor::End); + QTextCharFormat format; + format.setForeground(QBrush(color)); + cursor.mergeCharFormat(format); + cursor.insertText(P2QSTRING(data)); + cursor.endEditBlock(); + if (scrollToBottom) { - textEdit->ensureCursorVisible(); + scrollBar->setValue(scrollBar->maximum()); } } } diff --git a/Swift/QtUI/QtXMLConsoleWidget.h b/Swift/QtUI/QtXMLConsoleWidget.h index 28b15e8..1cfe54f 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.h +++ b/Swift/QtUI/QtXMLConsoleWidget.h @@ -11,6 +11,7 @@ class QTextEdit; class QCheckBox; +class QColor; namespace Swift { class QtXMLConsoleWidget : public QtTabbable, public XMLConsoleWidget { @@ -29,7 +30,7 @@ namespace Swift { virtual void closeEvent(QCloseEvent* event); virtual void showEvent(QShowEvent* event); - void appendTextIfEnabled(const String& data); + void appendTextIfEnabled(const String& data, const QColor& color); private: QTextEdit* textEdit; |