summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-10 16:49:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-10 16:49:49 (GMT)
commit7214d768dca85a6d43892169d5008898249dce73 (patch)
tree0f8b2820c9cb58f058263c78306987d934fec526 /UI/Qt/QtChatView.cpp
parentfd89da91d12b270d56f60544cad6f1ddc809af28 (diff)
downloadswift-7214d768dca85a6d43892169d5008898249dce73.zip
swift-7214d768dca85a6d43892169d5008898249dce73.tar.bz2
Moved UI/Qt -> Swift/QtUI.
Diffstat (limited to 'UI/Qt/QtChatView.cpp')
-rw-r--r--UI/Qt/QtChatView.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/UI/Qt/QtChatView.cpp b/UI/Qt/QtChatView.cpp
deleted file mode 100644
index ab093db..0000000
--- a/UI/Qt/QtChatView.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "QtChatView.h"
-
-#include <QtDebug>
-#include <QFile>
-#include <QVBoxLayout>
-#include <QWebView>
-#include <QWebFrame>
-#include <QKeyEvent>
-
-namespace Swift {
-
-QtChatView::QtChatView(QWidget* parent) : QWidget(parent) {
- setFocusPolicy(Qt::NoFocus);
-
- QVBoxLayout* mainLayout = new QVBoxLayout(this);
- mainLayout->setSpacing(0);
- mainLayout->setContentsMargins(0,0,0,0);
-
- webView_ = new QWebView(this);
- webView_->setFocusPolicy(Qt::NoFocus);
- mainLayout->addWidget(webView_);
-
- webPage_ = new QWebPage(this);
- webPage_->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
- webView_->setPage(webPage_);
- connect(webPage_, SIGNAL(selectionChanged()), SLOT(copySelectionToClipboard()));
-
- QFile file(":/themes/Default/Template.html");
- bool result = file.open(QIODevice::ReadOnly);
- Q_ASSERT(result);
- Q_UNUSED(result);
- QString pageHTML = file.readAll();
- pageHTML.replace("==bodyBackground==", "background-color:#e3e3e3");
- pageHTML.replace(pageHTML.indexOf("%@"), 2, "qrc:/themes/Default/");
- pageHTML.replace(pageHTML.indexOf("%@"), 2, "Variants/Blue on Green.css");
- pageHTML.replace(pageHTML.indexOf("%@"), 2, "");
- pageHTML.replace(pageHTML.indexOf("%@"), 2, "");
- file.close();
- webPage_->mainFrame()->setHtml(pageHTML);
-}
-
-void QtChatView::addMessage(const ChatSnippet& snippet) {
- //bool wasScrolledToBottom = isScrolledToBottom();
-
- QString content = snippet.getContent();
- content.replace("\\", "\\\\");
- content.replace("\"", "\\\"");
- content.replace("\n", "\\n");
- content.replace("\r", "");
- if (previousContinuationElementID_.isEmpty() || !snippet.getAppendToPrevious()) {
- webPage_->mainFrame()->evaluateJavaScript("appendMessage(\"" + content + "\");");
- }
- else {
- webPage_->mainFrame()->evaluateJavaScript("appendNextMessage(\"" + content + "\");");
- }
-
- //qDebug() << webPage_->mainFrame()->toHtml();
- previousContinuationElementID_ = snippet.getContinuationElementID();
-
- /*if (wasScrolledToBottom) {
- scrollToBottom();
- }*/
-}
-
-void QtChatView::copySelectionToClipboard() {
- if (!webPage_->selectedText().isEmpty()) {
- webPage_->triggerAction(QWebPage::Copy);
- }
-}
-
-bool QtChatView::isScrolledToBottom() const {
- return webPage_->mainFrame()->scrollBarValue(Qt::Vertical) == webPage_->mainFrame()->scrollBarMaximum(Qt::Vertical);
-}
-
-void QtChatView::scrollToBottom() {
- webPage_->mainFrame()->setScrollBarValue(Qt::Vertical, webPage_->mainFrame()->scrollBarMaximum(Qt::Vertical));
-}
-
-}