From 1092518fe7543cd9fcf57bc4d7806acd6fa673b2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 6 Mar 2015 11:45:57 +0100 Subject: [PATCH 01/13] - logs pane below the status pane - retrieve javascript message --- mix/AppContext.cpp | 4 + mix/CodeEditorExtensionManager.cpp | 6 +- mix/qml/LogsPane.qml | 143 ++++++++++++++++++++++++ mix/qml/MainContent.qml | 14 +-- mix/qml/StatusPane.qml | 93 +++++++++++++--- mix/qml/WebPreview.qml | 11 +- mix/qml/img/broom.png | Bin 0 -> 501 bytes mix/qml/img/copy.png | Bin 0 -> 342 bytes mix/res.qrc | 4 + mix/sortfilterproxymodel.cpp | 170 +++++++++++++++++++++++++++++ mix/sortfilterproxymodel.h | 107 ++++++++++++++++++ 11 files changed, 522 insertions(+), 30 deletions(-) create mode 100644 mix/qml/LogsPane.qml create mode 100644 mix/qml/img/broom.png create mode 100644 mix/qml/img/copy.png create mode 100644 mix/sortfilterproxymodel.cpp create mode 100644 mix/sortfilterproxymodel.h diff --git a/mix/AppContext.cpp b/mix/AppContext.cpp index 29124a39a..46bb0f98d 100644 --- a/mix/AppContext.cpp +++ b/mix/AppContext.cpp @@ -22,6 +22,7 @@ * - KeyEventManager */ +#include #include #include #include @@ -37,6 +38,7 @@ #include "QVariableDefinition.h" #include "HttpServer.h" #include "AppContext.h" +#include "sortfilterproxymodel.h" using namespace dev; using namespace dev::eth; @@ -74,6 +76,7 @@ void AppContext::load() qmlRegisterType("org.ethereum.qml.QBoolType", 1, 0, "QBoolType"); qmlRegisterType("org.ethereum.qml.QVariableDeclaration", 1, 0, "QVariableDeclaration"); qmlRegisterType("org.ethereum.qml.RecordLogEntry", 1, 0, "RecordLogEntry"); + qmlRegisterType("org.ethereum.qml.SortFilterProxyModel", 1, 0, "SortFilterProxyModel"); QQmlComponent projectModelComponent(m_applicationEngine, QUrl("qrc:/qml/ProjectModel.qml")); QObject* projectModel = projectModelComponent.create(); if (projectModelComponent.isError()) @@ -86,6 +89,7 @@ void AppContext::load() m_applicationEngine->rootContext()->setContextProperty("projectModel", projectModel); qmlRegisterType("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); qmlRegisterType("HttpServer", 1, 0, "HttpServer"); + m_applicationEngine->load(QUrl("qrc:/qml/main.qml")); QWindow *window = qobject_cast(m_applicationEngine->rootObjects().at(0)); window->setIcon(QIcon(":/res/mix_256x256x32.png")); diff --git a/mix/CodeEditorExtensionManager.cpp b/mix/CodeEditorExtensionManager.cpp index 97b808eb2..516184cff 100644 --- a/mix/CodeEditorExtensionManager.cpp +++ b/mix/CodeEditorExtensionManager.cpp @@ -53,10 +53,10 @@ void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) void CodeEditorExtensionManager::initExtensions() { - std::shared_ptr output = std::make_shared(m_appContext); - QObject::connect(m_appContext->codeModel(), &CodeModel::compilationComplete, this, &CodeEditorExtensionManager::applyCodeHighlight); + //std::shared_ptr output = std::make_shared(m_appContext); + //QObject::connect(m_appContext->codeModel(), &CodeModel::compilationComplete, this, &CodeEditorExtensionManager::applyCodeHighlight); - initExtension(output); + //initExtension(output); } void CodeEditorExtensionManager::initExtension(std::shared_ptr _ext) diff --git a/mix/qml/LogsPane.qml b/mix/qml/LogsPane.qml new file mode 100644 index 000000000..63d940eb6 --- /dev/null +++ b/mix/qml/LogsPane.qml @@ -0,0 +1,143 @@ +import QtQuick 2.0 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 1.1 +import org.ethereum.qml.SortFilterProxyModel 1.0 +import "." + +Rectangle +{ + function push(_level, _type, _content) + { + _content = _content.replace(/\n/g, " ") + logsModel.insert(0, { "type": _type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss dd.MM.yyyy"), "content": _content, "level": _level }); + } + anchors.fill: parent + radius: 5 + color: "#f7f7f7" + border.color: "#808080" + border.width: 2 + ColumnLayout { + height: parent.height - 4 + width: parent.width - 2 + spacing: 0 + Row + { + id: rowAction + Layout.preferredHeight: 35 + height: 35 + anchors.leftMargin: 10 + anchors.left: parent.left + spacing: 5 + Button + { + height: 30 + anchors.verticalCenter: parent.verticalCenter + action: clearAction + iconSource: "qrc:/qml/img/broom.png" + } + + Action { + id: clearAction + enabled: logsModel.count > 0 + tooltip: qsTr("Clear") + onTriggered: { + logsModel.clear() + } + } + + Button + { + height: 30 + anchors.verticalCenter: parent.verticalCenter + action: copytoClipBoardAction + iconSource: "qrc:/qml/img/copy.png" + } + + Action { + id: copytoClipBoardAction + enabled: logsModel.count > 0 + tooltip: qsTr("Copy to Clipboard") + onTriggered: { + var content = ""; + for (var k = 0; k < logsModel.count; k++) + { + var log = logsModel.get(k); + content += log.type + "\t" + log.level + "\t" + log.date + "\t" + log.content; + } + appContext.toClipboard(content); + } + } + } + + ListModel { + id: logsModel + } + + TableView { + id: logsTable + clip: true + Layout.fillWidth: true + Layout.preferredHeight: parent.height - rowAction.height + headerVisible : false + onDoubleClicked: + { + var log = logsModel.get((logsTable.currentRow)); + appContext.toClipboard(log.type + " " + log.level + " " + log.date + " " + log.content); + } + + model: SortFilterProxyModel { + id: proxyModel + source: logsModel + + filterRole: "" + filterString: "" + filterSyntax: SortFilterProxyModel.Wildcard + filterCaseSensitivity: Qt.CaseInsensitive + } + TableViewColumn + { + role: "date" + title: qsTr("date") + width: 150 + delegate: itemDelegate + } + TableViewColumn + { + role: "type" + title: qsTr("type") + width: 100 + delegate: itemDelegate + } + TableViewColumn + { + role: "content" + title: qsTr("content") + width: 700 + delegate: itemDelegate + } + } + + Component { + id: itemDelegate + DefaultLabel { + text: styleData.value; + font.family: "sans serif" + font.pointSize: Style.absoluteSize(-1) + color: { + if (styleData.row > -1) + { + var l = logsModel.get(styleData.row).level + if (l === "error") + return "red" + else if (l === "warning") + return "orange" + else if (l === "info") + return "#808080" + } + else + return "#808080" + } + } + } + } +} diff --git a/mix/qml/MainContent.qml b/mix/qml/MainContent.qml index 081e0cd95..d295e9da0 100644 --- a/mix/qml/MainContent.qml +++ b/mix/qml/MainContent.qml @@ -102,7 +102,7 @@ Rectangle { } CodeEditorExtensionManager { - headerView: headerPaneTabs; + //headerView: headerPaneTabs; } Settings { @@ -133,16 +133,10 @@ Rectangle { } id: headerPaneContainer anchors.fill: parent - TabView { - id: headerPaneTabs - tabsVisible: false - antialiasing: true + StatusPane + { anchors.fill: parent - style: TabViewStyle { - frameOverlap: 1 - tab: Rectangle {} - frame: Rectangle { color: "transparent" } - } + webPreview: webPreview } } } diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index e526d65bd..87bfb39d5 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -8,6 +8,7 @@ import "." Rectangle { id: statusHeader objectName: "statusPane" + property variant webPreview function updateStatus(message) { @@ -15,7 +16,6 @@ Rectangle { { status.state = ""; status.text = qsTr("Compile successfully."); - logslink.visible = false; debugImg.state = "active"; } else @@ -23,39 +23,52 @@ Rectangle { status.state = "error"; var errorInfo = ErrorLocationFormater.extractErrorInfo(message, true); status.text = errorInfo.errorLocation + " " + errorInfo.errorDetail; - logslink.visible = true; debugImg.state = ""; } debugRunActionIcon.enabled = codeModel.hasContract; } - function infoMessage(text) + function infoMessage(text, type) { status.state = ""; status.text = text - logslink.visible = false; + logPane.push("info",type, text); } - function errorMessage(text) + function warningMessage(text, type) + { + status.state = ""; + status.text = text + logPane.push("warning", type, text); + } + + function errorMessage(text, type) { status.state = "error"; status.text = text - logslink.visible = false; + logPane.push("error", type, text); + } + + Connections { + target: webPreview + onJavaScriptErrorMessage: errorMessage(_content, "javascript") + onJavaScriptWarningMessage: warningMessage(_content, "javascript") + onJavaScriptInfoMessage: infoMessage(_content, "javascript") } Connections { target:clientModel - onRunStarted: infoMessage(qsTr("Running transactions...")); - onRunFailed: errorMessage(qsTr("Error running transactions: " + _message)); - onRunComplete: infoMessage(qsTr("Run complete")); - onNewBlock: infoMessage(qsTr("New block created")); + onRunStarted: infoMessage(qsTr("Running transactions..."), "run"); + onRunFailed: errorMessage(qsTr("Error running transactions: " + _message), "run"); + onRunComplete: infoMessage(qsTr("Run complete"), "run"); + onNewBlock: infoMessage(qsTr("New block created"), "state"); } Connections { target:projectModel - onDeploymentStarted: infoMessage(qsTr("Running deployment...")); - onDeploymentError: errorMessage(error); - onDeploymentComplete: infoMessage(qsTr("Deployment complete")); - onDeploymentStepChanged: infoMessage(message); + onDeploymentStarted: infoMessage(qsTr("Running deployment..."), "deployment"); + onDeploymentError: errorMessage(error, "deployment"); + onDeploymentComplete: infoMessage(qsTr("Deployment complete"), "deployment"); + onDeploymentStepChanged: infoMessage(message, "deployment"); } Connections { target: codeModel @@ -133,6 +146,53 @@ Rectangle { id: toolTipInfo tooltip: "" } + + Rectangle + { + function toggle() + { + if (logsContainer.state === "opened") + logsContainer.state = "closed" + else + logsContainer.state = "opened"; + } + + id: logsContainer + width: 1000 + height: 0 + anchors.topMargin: 2 + anchors.top: statusContainer.bottom + anchors.horizontalCenter: parent.horizontalCenter + visible: false + Component.onCompleted: + { + var top = logsContainer; + while (top.parent) + top = top.parent + var coordinates = logsContainer.mapToItem(top, 0, 0) + logsContainer.parent = top; + logsContainer.x = coordinates.x + logsContainer.y = coordinates.y + } + LogsPane + { + id: logPane + } + states: [ + State { + name: "opened"; + PropertyChanges { target: logsContainer; height: 500; visible: true } + }, + State { + name: "closed"; + PropertyChanges { target: logsContainer; height: 0; visible: false } + } + ] + transitions: Transition { + NumberAnimation { properties: "height"; easing.type: Easing.InOutQuad; duration: 200 } + NumberAnimation { properties: "visible"; easing.type: Easing.InOutQuad; duration: 200 } + } + } } Button @@ -140,7 +200,6 @@ Rectangle { id: logslink anchors.left: statusContainer.right anchors.leftMargin: 9 - visible: false anchors.verticalCenter: parent.verticalCenter action: displayLogAction iconSource: "qrc:/qml/img/search_filled.png" @@ -150,7 +209,9 @@ Rectangle { id: displayLogAction tooltip: qsTr("Display Log") onTriggered: { - mainContent.displayCompilationErrorIfAny(); + logsContainer.toggle(); + //if (status.state === "error" && logPane.front().type === "run") + // mainContent.displayCompilationErrorIfAny(); } } diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index 6f03088a4..5a9673a2c 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -12,6 +12,9 @@ Item { id: webPreview property string pendingPageUrl: "" property bool initialized: false + signal javaScriptErrorMessage(string _content) + signal javaScriptWarningMessage(string _content) + signal javaScriptInfoMessage(string _content) function setPreviewUrl(url) { if (!initialized) @@ -240,7 +243,13 @@ Item { id: webView experimental.settings.localContentCanAccessRemoteUrls: true onJavaScriptConsoleMessage: { - console.log(sourceID + ":" + lineNumber + ":" + message); + var info = sourceID + ":" + lineNumber + ":" + message; + if (level === 0) + webPreview.javaScriptInfoMessage(info); + else if (level === 1) + webPreview.javaScriptErrorMessage(info); + else if (level === 2) + webPreview.javaScriptErrorMessage(info); } onLoadingChanged: { if (!loading) { diff --git a/mix/qml/img/broom.png b/mix/qml/img/broom.png new file mode 100644 index 0000000000000000000000000000000000000000..76a9a0e0c90f9e671c3bbe3708f610c4a67f6383 GIT binary patch literal 501 zcmVl0knEFf(l4s2f?(imaF8NZjcWVO_}LI%a>%36+i~6T z^SQ6|3LtJhk^&Jz2utc^beF3b$swE(%#*EL^P}y!?)c0Gl3UrZ22;|P1>z-6qMhu) zSc&&J#k}OZ**r#`z41$?i>u|{BT{dCD|@ZL88aFoS+UGi|GK$H7_unV$Vw4NT7uEW zm-O+BfvnnV%>p9leRp*vN5T*w=e|-;#;Y22rS3<>&kwgnT?axGT}>SG8^x1s zXTOhJzePzd)sOKKbFkQxtFOOsE(7vswE3NB+UWECyT$!^v$yiJJ8C4)yjTAu`iq|U znj1Gy^<=#NA2xGJ-09bUCmJd(slT_!U2=U>^tx#e4LTY`t)UgF>el6QYc#rKzSe0f2{dxJC@=|jIIuvN`^^-?W_(@hk>V0_bL9qml/img/exit.png qml/img/run.png qml/img/note.png + qml/LogsPane.qml + qml/LogsWindow.qml + qml/img/copy.png + qml/img/broom.png diff --git a/mix/sortfilterproxymodel.cpp b/mix/sortfilterproxymodel.cpp new file mode 100644 index 000000000..75a50ea59 --- /dev/null +++ b/mix/sortfilterproxymodel.cpp @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "sortfilterproxymodel.h" +#include +#include + +using namespace dev::mix; + +SortFilterProxyModel::SortFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) +{ + connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged())); + connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged())); +} + +int SortFilterProxyModel::count() const +{ + return rowCount(); +} + +QObject *SortFilterProxyModel::source() const +{ + return sourceModel(); +} + +void SortFilterProxyModel::setSource(QObject *source) +{ + setSourceModel(qobject_cast(source)); +} + +QByteArray SortFilterProxyModel::sortRole() const +{ + return roleNames().value(QSortFilterProxyModel::sortRole()); +} + +void SortFilterProxyModel::setSortRole(const QByteArray &role) +{ + QSortFilterProxyModel::setSortRole(roleKey(role)); +} + +void SortFilterProxyModel::setSortOrder(Qt::SortOrder order) +{ + QSortFilterProxyModel::sort(0, order); +} + +QByteArray SortFilterProxyModel::filterRole() const +{ + return roleNames().value(QSortFilterProxyModel::filterRole()); +} + +void SortFilterProxyModel::setFilterRole(const QByteArray &role) +{ + QSortFilterProxyModel::setFilterRole(roleKey(role)); +} + +QString SortFilterProxyModel::filterString() const +{ + return filterRegExp().pattern(); +} + +void SortFilterProxyModel::setFilterString(const QString &filter) +{ + setFilterRegExp(QRegExp(filter, filterCaseSensitivity(), static_cast(filterSyntax()))); +} + +SortFilterProxyModel::FilterSyntax SortFilterProxyModel::filterSyntax() const +{ + return static_cast(filterRegExp().patternSyntax()); +} + +void SortFilterProxyModel::setFilterSyntax(SortFilterProxyModel::FilterSyntax syntax) +{ + setFilterRegExp(QRegExp(filterString(), filterCaseSensitivity(), static_cast(syntax))); +} + +QJSValue SortFilterProxyModel::get(int idx) const +{ + QJSEngine *engine = qmlEngine(this); + QJSValue value = engine->newObject(); + if (idx >= 0 && idx < count()) { + QHash roles = roleNames(); + QHashIterator it(roles); + while (it.hasNext()) { + it.next(); + value.setProperty(QString::fromUtf8(it.value()), data(index(idx, 0), it.key()).toString()); + } + } + return value; +} + +int SortFilterProxyModel::roleKey(const QByteArray &role) const +{ + QHash roles = roleNames(); + QHashIterator it(roles); + while (it.hasNext()) { + it.next(); + if (it.value() == role) + return it.key(); + } + return -1; +} + +QHash SortFilterProxyModel::roleNames() const +{ + if (QAbstractItemModel *source = sourceModel()) + return source->roleNames(); + return QHash(); +} + +bool SortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +{ + QRegExp rx = filterRegExp(); + if (rx.isEmpty()) + return true; + QAbstractItemModel *model = sourceModel(); + if (filterRole().isEmpty()) { + QHash roles = roleNames(); + QHashIterator it(roles); + while (it.hasNext()) { + it.next(); + QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); + QString key = model->data(sourceIndex, it.key()).toString(); + if (key.contains(rx)) + return true; + } + return false; + } + QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); + if (!sourceIndex.isValid()) + return true; + QString key = model->data(sourceIndex, roleKey(filterRole())).toString(); + return key.contains(rx); +} diff --git a/mix/sortfilterproxymodel.h b/mix/sortfilterproxymodel.h new file mode 100644 index 000000000..2ff479413 --- /dev/null +++ b/mix/sortfilterproxymodel.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SORTFILTERPROXYMODEL_H +#define SORTFILTERPROXYMODEL_H + +#include +#include + +namespace dev +{ +namespace mix +{ + +class SortFilterProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QObject *source READ source WRITE setSource) + + Q_PROPERTY(QByteArray sortRole READ sortRole WRITE setSortRole) + Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder) + + Q_PROPERTY(QByteArray filterRole READ filterRole WRITE setFilterRole) + Q_PROPERTY(QString filterString READ filterString WRITE setFilterString) + Q_PROPERTY(FilterSyntax filterSyntax READ filterSyntax WRITE setFilterSyntax) + + Q_ENUMS(FilterSyntax) + +public: + explicit SortFilterProxyModel(QObject *parent = 0); + + QObject *source() const; + void setSource(QObject *source); + + QByteArray sortRole() const; + void setSortRole(const QByteArray &role); + + void setSortOrder(Qt::SortOrder order); + + QByteArray filterRole() const; + void setFilterRole(const QByteArray &role); + + QString filterString() const; + void setFilterString(const QString &filter); + + enum FilterSyntax { + RegExp, + Wildcard, + FixedString + }; + + FilterSyntax filterSyntax() const; + void setFilterSyntax(FilterSyntax syntax); + + int count() const; + Q_INVOKABLE QJSValue get(int index) const; + +signals: + void countChanged(); + +protected: + int roleKey(const QByteArray &role) const; + QHash roleNames() const; + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; +}; + +} +} +#endif // SORTFILTERPROXYMODEL_H From b0203717433580c88384fb9d748ca0af66dc3834 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 6 Mar 2015 14:46:29 +0100 Subject: [PATCH 02/13] - UI changes - Filter by message type --- mix/qml/LogsPane.qml | 213 +++++++++++++++++++++++++++++------------ mix/qml/StatusPane.qml | 27 +++++- mix/res.qrc | 1 - 3 files changed, 178 insertions(+), 63 deletions(-) diff --git a/mix/qml/LogsPane.qml b/mix/qml/LogsPane.qml index 63d940eb6..9fa15f250 100644 --- a/mix/qml/LogsPane.qml +++ b/mix/qml/LogsPane.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.3 import org.ethereum.qml.SortFilterProxyModel 1.0 import "." @@ -15,10 +16,10 @@ Rectangle radius: 5 color: "#f7f7f7" border.color: "#808080" - border.width: 2 + border.width: 1 ColumnLayout { - height: parent.height - 4 - width: parent.width - 2 + height: parent.height + width: parent.width spacing: 0 Row { @@ -62,82 +63,172 @@ Rectangle for (var k = 0; k < logsModel.count; k++) { var log = logsModel.get(k); - content += log.type + "\t" + log.level + "\t" + log.date + "\t" + log.content; + content += log.type + "\t" + log.level + "\t" + log.date + "\t" + log.content + "\n"; } appContext.toClipboard(content); } } - } - - ListModel { - id: logsModel - } - TableView { - id: logsTable - clip: true - Layout.fillWidth: true - Layout.preferredHeight: parent.height - rowAction.height - headerVisible : false - onDoubleClicked: - { - var log = logsModel.get((logsTable.currentRow)); - appContext.toClipboard(log.type + " " + log.level + " " + log.date + " " + log.content); + Rectangle { + anchors.verticalCenter: parent.verticalCenter + width: 1; + height: parent.height - 10 + color : "#808080" } - model: SortFilterProxyModel { - id: proxyModel - source: logsModel + ToolButton { + id: javascriptButton + checkable: true + height: 30 + anchors.verticalCenter: parent.verticalCenter + checked: true + onCheckedChanged: { + proxyModel.toogleFilter("javascript") + } + tooltip: qsTr("JavaScript") + style: + ButtonStyle { + label: + Item { + DefaultLabel { + font.family: "sans serif" + font.pointSize: Style.absoluteSize(-3) + color: "#5391d8" + anchors.centerIn: parent + text: qsTr("JavaScript") + } + } + } + } - filterRole: "" - filterString: "" - filterSyntax: SortFilterProxyModel.Wildcard - filterCaseSensitivity: Qt.CaseInsensitive + ToolButton { + id: runButton + checkable: true + height: 30 + anchors.verticalCenter: parent.verticalCenter + checked: true + onCheckedChanged: { + proxyModel.toogleFilter("run") } - TableViewColumn - { - role: "date" - title: qsTr("date") - width: 150 - delegate: itemDelegate + tooltip: qsTr("Run") + style: + ButtonStyle { + label: + Item { + DefaultLabel { + font.family: "sans serif" + font.pointSize: Style.absoluteSize(-3) + color: "#5391d8" + anchors.centerIn: parent + text: qsTr("Run") + } + } } - TableViewColumn - { - role: "type" - title: qsTr("type") - width: 100 - delegate: itemDelegate + } + + ToolButton { + id: stateButton + checkable: true + height: 30 + anchors.verticalCenter: parent.verticalCenter + checked: true + onCheckedChanged: { + proxyModel.toogleFilter("state") + } + tooltip: qsTr("State") + style: + ButtonStyle { + label: + Item { + DefaultLabel { + font.family: "sans serif" + font.pointSize: Style.absoluteSize(-3) + color: "#5391d8" + anchors.centerIn: parent + text: qsTr("State") + } + } } - TableViewColumn + } + } + + ListModel { + id: logsModel + } + + TableView { + id: logsTable + clip: true + Layout.fillWidth: true + Layout.preferredHeight: parent.height - rowAction.height + headerVisible : false + onDoubleClicked: + { + var log = logsModel.get((logsTable.currentRow)); + appContext.toClipboard(log.type + " " + log.level + " " + log.date + " " + log.content); + } + + model: SortFilterProxyModel { + id: proxyModel + source: logsModel + + function toogleFilter(_value) { - role: "content" - title: qsTr("content") - width: 700 - delegate: itemDelegate + if (filterString.indexOf('_' + _value) !== -1) + filterString = filterString.replace('_' + _value, _value); + else + filterString = filterString.replace(_value, '_' + _value); } + + filterRole: "type" + filterString: "(?:javascript|run|state)" + filterSyntax: SortFilterProxyModel.RegExp + filterCaseSensitivity: Qt.CaseInsensitive } + TableViewColumn + { + role: "date" + title: qsTr("date") + width: 150 + delegate: itemDelegate + } + TableViewColumn + { + role: "type" + title: qsTr("type") + width: 100 + delegate: itemDelegate + } + TableViewColumn + { + role: "content" + title: qsTr("content") + width: 700 + delegate: itemDelegate + } + } - Component { - id: itemDelegate - DefaultLabel { - text: styleData.value; - font.family: "sans serif" - font.pointSize: Style.absoluteSize(-1) - color: { - if (styleData.row > -1) - { - var l = logsModel.get(styleData.row).level - if (l === "error") - return "red" - else if (l === "warning") - return "orange" - else if (l === "info") - return "#808080" - } - else + Component { + id: itemDelegate + DefaultLabel { + text: styleData.value; + font.family: "sans serif" + font.pointSize: Style.absoluteSize(-1) + color: { + if (styleData.row > -1) + { + var l = logsModel.get(styleData.row).level + if (l === "error") + return "red" + else if (l === "warning") + return "orange" + else if (l === "info") return "#808080" } + else + return "#808080" } } } } +} diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index 87bfb39d5..141d45a48 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -87,6 +87,24 @@ Rectangle { width: 500 height: 30 color: "#fcfbfc" + states: [ + State { + name: "logsOpened" + PropertyChanges { + target: statusContainer + border.color: "#808080" + border.width: 1 + } + }, + State { + name: "logsClosed" + PropertyChanges { + target: statusContainer + border.color: "#808080" + border.width: 0 + } + } + ] Text { anchors.verticalCenter: parent.verticalCenter @@ -152,18 +170,25 @@ Rectangle { function toggle() { if (logsContainer.state === "opened") + { + statusContainer.state = "logsClosed"; logsContainer.state = "closed" + } else + { + statusContainer.state = "logsOpened"; logsContainer.state = "opened"; + } } id: logsContainer width: 1000 height: 0 - anchors.topMargin: 2 + //anchors.topMargin: anchors.top: statusContainer.bottom anchors.horizontalCenter: parent.horizontalCenter visible: false + radius: 5 Component.onCompleted: { var top = logsContainer; diff --git a/mix/res.qrc b/mix/res.qrc index 4e5719a18..5c706fb9c 100644 --- a/mix/res.qrc +++ b/mix/res.qrc @@ -110,7 +110,6 @@ qml/img/run.png qml/img/note.png qml/LogsPane.qml - qml/LogsWindow.qml qml/img/copy.png qml/img/broom.png From c22df42b0b44830011bce256faf62eb824c5d63d Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 9 Mar 2015 13:11:02 +0100 Subject: [PATCH 03/13] - use input to filter logs by any str. - format exceptions coming from Executive.cpp --- mix/qml/LogsPane.qml | 66 +++++++++++++++++++++++++----------- mix/qml/StatusPane.qml | 23 +++++++++++-- mix/sortfilterproxymodel.cpp | 64 +++++++++++++++++++++++++++++----- mix/sortfilterproxymodel.h | 18 ++++++++-- 4 files changed, 138 insertions(+), 33 deletions(-) diff --git a/mix/qml/LogsPane.qml b/mix/qml/LogsPane.qml index 9fa15f250..ca78b3854 100644 --- a/mix/qml/LogsPane.qml +++ b/mix/qml/LogsPane.qml @@ -12,6 +12,7 @@ Rectangle _content = _content.replace(/\n/g, " ") logsModel.insert(0, { "type": _type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss dd.MM.yyyy"), "content": _content, "level": _level }); } + anchors.fill: parent radius: 5 color: "#f7f7f7" @@ -150,10 +151,24 @@ Rectangle } } } + + DefaultTextField + { + id: searchBox + height: 30 + anchors.verticalCenter: parent.verticalCenter + width: 200 + font.family: "sans serif" + font.pointSize: Style.absoluteSize(-3) + onTextChanged: { + proxyModel.search(text); + } + } } ListModel { id: logsModel + } TableView { @@ -171,17 +186,41 @@ Rectangle model: SortFilterProxyModel { id: proxyModel source: logsModel + property var roles: ["-", "javascript", "run", "state"] + + Component.onCompleted: { + filterType = regEx(proxyModel.roles); + } + + function search(_value) + { + filterContent = _value; + } function toogleFilter(_value) { - if (filterString.indexOf('_' + _value) !== -1) - filterString = filterString.replace('_' + _value, _value); - else - filterString = filterString.replace(_value, '_' + _value); + var count = roles.length; + for (var i in roles) + { + if (roles[i] === _value) + { + roles.splice(i, 1); + break; + } + } + if (count === roles.length) + roles.push(_value); + + filterType = regEx(proxyModel.roles); } - filterRole: "type" - filterString: "(?:javascript|run|state)" + function regEx(_value) + { + console.log("(?:" + roles.join('|') + ")"); + return "(?:" + roles.join('|') + ")"; + } + filterType: "(?:javascript|run|state)" + filterContent: "" filterSyntax: SortFilterProxyModel.RegExp filterCaseSensitivity: Qt.CaseInsensitive } @@ -214,20 +253,7 @@ Rectangle text: styleData.value; font.family: "sans serif" font.pointSize: Style.absoluteSize(-1) - color: { - if (styleData.row > -1) - { - var l = logsModel.get(styleData.row).level - if (l === "error") - return "red" - else if (l === "warning") - return "orange" - else if (l === "info") - return "#808080" - } - else - return "#808080" - } + color: "#808080" } } } diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index 141d45a48..2a2eeb910 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -59,9 +59,28 @@ Rectangle { Connections { target:clientModel onRunStarted: infoMessage(qsTr("Running transactions..."), "run"); - onRunFailed: errorMessage(qsTr("Error running transactions: " + _message), "run"); + onRunFailed: errorMessage(format(_message), "run"); onRunComplete: infoMessage(qsTr("Run complete"), "run"); onNewBlock: infoMessage(qsTr("New block created"), "state"); + + function format(_message) + { + var formatted = _message.match(/(?:)/); + if (formatted.length > 1) + formatted = formatted[1] + ": "; + var exceptionInfos = _message.match(/(tag_)(.+)/g); + console.log("hh " + exceptionInfos.length); + for (var k in exceptionInfos) + { + formatted += " " + exceptionInfos[k].replace("*]", "").replace("tag_", ""); + console.log(k); + if (k === exceptionInfos.length - 1) + formatted += "." + else + formatted += "," + } + return formatted; + } } Connections { target:projectModel @@ -82,7 +101,7 @@ Rectangle { Rectangle { id: statusContainer anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenter: parent.verticalCenterw radius: 3 width: 500 height: 30 diff --git a/mix/sortfilterproxymodel.cpp b/mix/sortfilterproxymodel.cpp index 75a50ea59..04e403738 100644 --- a/mix/sortfilterproxymodel.cpp +++ b/mix/sortfilterproxymodel.cpp @@ -80,15 +80,15 @@ void SortFilterProxyModel::setSortOrder(Qt::SortOrder order) QSortFilterProxyModel::sort(0, order); } -QByteArray SortFilterProxyModel::filterRole() const +/*QByteArray SortFilterProxyModel::filterRole() const { return roleNames().value(QSortFilterProxyModel::filterRole()); -} +}*/ -void SortFilterProxyModel::setFilterRole(const QByteArray &role) +/*void SortFilterProxyModel::setFilterRole(const QByteArray &role) { QSortFilterProxyModel::setFilterRole(roleKey(role)); -} +}*/ QString SortFilterProxyModel::filterString() const { @@ -146,10 +146,11 @@ QHash SortFilterProxyModel::roleNames() const bool SortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { - QRegExp rx = filterRegExp(); + /*QRegExp rx = filterRegExp(); if (rx.isEmpty()) return true; QAbstractItemModel *model = sourceModel(); + if (filterRole().isEmpty()) { QHash roles = roleNames(); QHashIterator it(roles); @@ -157,14 +158,61 @@ bool SortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &so it.next(); QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); QString key = model->data(sourceIndex, it.key()).toString(); - if (key.contains(rx)) + if (key.contains(rx))data return true; } return false; + }*/ + + QRegExp rx = filterRegExp(); + QAbstractItemModel *model = sourceModel(); + QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); + if (!sourceIndex.isValid()) + return true; + + QString keyType = model->data(sourceIndex, roleKey(type.toUtf8())).toString(); + QString keyContent = model->data(sourceIndex, roleKey(content.toUtf8())).toString(); + + return keyType.contains(m_filterType) && keyContent.contains(m_filterContent); +/* + for (auto filter: filterRoles()) + { + QString key = model->data(sourceIndex, roleKey(filter.toUtf8())).toString(); + if (!key.contains(rx)) + return false; } + return true; QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); if (!sourceIndex.isValid()) return true; - QString key = model->data(sourceIndex, roleKey(filterRole())).toString(); - return key.contains(rx); + for (auto role: filterR) + { + QString key = model->data(sourceIndex, roleKey(role)).toString(); + if (key.contains(rx)) + return true; + } + return false;*/ +} + +void SortFilterProxyModel::setFilterType(const QString &_type) +{ + m_filterType = QRegExp(_type, filterCaseSensitivity(), static_cast(filterSyntax())); + setFilterRegExp(_type); +} + +QString SortFilterProxyModel::filterType() const +{ + return m_filterType.pattern(); } + +void SortFilterProxyModel::setFilterContent(const QString &_content) +{ + m_filterContent = QRegExp(_content, filterCaseSensitivity(), static_cast(filterSyntax())); + setFilterRegExp(_content); +} + +QString SortFilterProxyModel::filterContent() const +{ + return m_filterContent.pattern(); +} + diff --git a/mix/sortfilterproxymodel.h b/mix/sortfilterproxymodel.h index 2ff479413..8eae97a68 100644 --- a/mix/sortfilterproxymodel.h +++ b/mix/sortfilterproxymodel.h @@ -58,7 +58,8 @@ class SortFilterProxyModel : public QSortFilterProxyModel Q_PROPERTY(QByteArray sortRole READ sortRole WRITE setSortRole) Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder) - Q_PROPERTY(QByteArray filterRole READ filterRole WRITE setFilterRole) + Q_PROPERTY(QString filterContent READ filterContent WRITE setFilterContent) + Q_PROPERTY(QString filterType READ filterType WRITE setFilterType) Q_PROPERTY(QString filterString READ filterString WRITE setFilterString) Q_PROPERTY(FilterSyntax filterSyntax READ filterSyntax WRITE setFilterSyntax) @@ -75,9 +76,14 @@ public: void setSortOrder(Qt::SortOrder order); - QByteArray filterRole() const; - void setFilterRole(const QByteArray &role); + QString filterContent() const; + void setFilterContent(const QString &_content); + QString filterType() const; + void setFilterType(const QString &_type); + /*QStringList filterRoles() const; + void setFilterRoles(const QStringList &roles); +*/ QString filterString() const; void setFilterString(const QString &filter); @@ -100,6 +106,12 @@ protected: int roleKey(const QByteArray &role) const; QHash roleNames() const; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + +private: + QRegExp m_filterType; + QRegExp m_filterContent; + const QString type = "type"; + const QString content = "content"; }; } From 16812749e5fd580bec1cac3ef5597fd13acfccdb Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 9 Mar 2015 13:40:23 +0100 Subject: [PATCH 04/13] format executive.cpp exception --- mix/qml/StatusPane.qml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index 2a2eeb910..c17e17f89 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -68,17 +68,11 @@ Rectangle { var formatted = _message.match(/(?:)/); if (formatted.length > 1) formatted = formatted[1] + ": "; - var exceptionInfos = _message.match(/(tag_)(.+)/g); - console.log("hh " + exceptionInfos.length); + else + return _message; + var exceptionInfos = _message.match(/(?:tag_)(.+)/g); for (var k in exceptionInfos) - { - formatted += " " + exceptionInfos[k].replace("*]", "").replace("tag_", ""); - console.log(k); - if (k === exceptionInfos.length - 1) - formatted += "." - else - formatted += "," - } + formatted += " " + exceptionInfos[k].replace("*]", "").replace("tag_", "") + " - "; return formatted; } } From e0fa87db76277189ecc341f2564b7775946fb6d0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 11:37:29 +0100 Subject: [PATCH 05/13] small changes --- mix/qml/LogsPane.qml | 50 ++++++++++++++++++++++++++--- mix/qml/MainContent.qml | 20 ++++++------ mix/qml/StatusPane.qml | 70 ++++++++++++++++++++--------------------- mix/qml/WebPreview.qml | 16 +++------- 4 files changed, 95 insertions(+), 61 deletions(-) diff --git a/mix/qml/LogsPane.qml b/mix/qml/LogsPane.qml index ca78b3854..67bdd44c1 100644 --- a/mix/qml/LogsPane.qml +++ b/mix/qml/LogsPane.qml @@ -19,6 +19,7 @@ Rectangle border.color: "#808080" border.width: 1 ColumnLayout { + z: 2 height: parent.height width: parent.width spacing: 0 @@ -152,6 +153,31 @@ Rectangle } } + ToolButton { + id: compilationButton + checkable: true + height: 30 + anchors.verticalCenter: parent.verticalCenter + checked: false + onCheckedChanged: { + proxyModel.toogleFilter("compilation") + } + tooltip: qsTr("Compilation") + style: + ButtonStyle { + label: + Item { + DefaultLabel { + font.family: "sans serif" + font.pointSize: Style.absoluteSize(-3) + color: "#5391d8" + anchors.centerIn: parent + text: qsTr("Compilation") + } + } + } + } + DefaultTextField { id: searchBox @@ -160,6 +186,7 @@ Rectangle width: 200 font.family: "sans serif" font.pointSize: Style.absoluteSize(-3) + font.italic: true onTextChanged: { proxyModel.search(text); } @@ -168,7 +195,6 @@ Rectangle ListModel { id: logsModel - } TableView { @@ -180,7 +206,8 @@ Rectangle onDoubleClicked: { var log = logsModel.get((logsTable.currentRow)); - appContext.toClipboard(log.type + " " + log.level + " " + log.date + " " + log.content); + if (log) + appContext.toClipboard(log.type + "\t" + log.level + "\t" + log.date + "\t" + log.content); } model: SortFilterProxyModel { @@ -216,9 +243,9 @@ Rectangle function regEx(_value) { - console.log("(?:" + roles.join('|') + ")"); return "(?:" + roles.join('|') + ")"; } + filterType: "(?:javascript|run|state)" filterContent: "" filterSyntax: SortFilterProxyModel.RegExp @@ -235,7 +262,7 @@ Rectangle { role: "type" title: qsTr("type") - width: 100 + width: 80 delegate: itemDelegate } TableViewColumn @@ -245,6 +272,14 @@ Rectangle width: 700 delegate: itemDelegate } + + rowDelegate: Item { + Rectangle { + width: logsTable.width - 4 + height: 17 + color: styleData.alternate ? "transparent" : "#f0f0f0" + } + } } Component { @@ -253,7 +288,12 @@ Rectangle text: styleData.value; font.family: "sans serif" font.pointSize: Style.absoluteSize(-1) - color: "#808080" + color: { + if (proxyModel.get(styleData.row).level === "error") + return "red" + else + return "#808080" + } } } } diff --git a/mix/qml/MainContent.qml b/mix/qml/MainContent.qml index d295e9da0..7ac751a79 100644 --- a/mix/qml/MainContent.qml +++ b/mix/qml/MainContent.qml @@ -35,8 +35,8 @@ Rectangle { onCompilationComplete: { if (firstCompile) { firstCompile = false; - if (runOnProjectLoad) - startQuickDebugging(); + if (runOnProjectLoad) + startQuickDebugging(); } } } @@ -102,7 +102,6 @@ Rectangle { } CodeEditorExtensionManager { - //headerView: headerPaneTabs; } Settings { @@ -116,6 +115,7 @@ Rectangle { ColumnLayout { + id: mainColumn anchors.fill: parent spacing: 0 Rectangle { @@ -141,7 +141,7 @@ Rectangle { } } - Rectangle{ + Rectangle { Layout.fillWidth: true height: 1 color: "#8c8c8c" @@ -162,9 +162,9 @@ Rectangle { { anchors.fill: parent handleDelegate: Rectangle { - width: 1 - height: 1 - color: "#8c8c8c" + width: 1 + height: 1 + color: "#8c8c8c" } orientation: Qt.Horizontal @@ -174,16 +174,18 @@ Rectangle { Layout.minimumWidth: 250 Layout.fillHeight: true } + Rectangle { id: contentView Layout.fillHeight: true Layout.fillWidth: true + SplitView { - handleDelegate: Rectangle { + handleDelegate: Rectangle { width: 1 height: 1 color: "#8c8c8c" - } + } id: codeWebSplitter anchors.fill: parent orientation: Qt.Vertical diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index 99ab39b6c..1ce7917a9 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -24,6 +24,7 @@ Rectangle { var errorInfo = ErrorLocationFormater.extractErrorInfo(message, true); status.text = errorInfo.errorLocation + " " + errorInfo.errorDetail; debugImg.state = ""; + errorMessage(status.text, "Compilation"); } debugRunActionIcon.enabled = codeModel.hasContract; } @@ -51,17 +52,27 @@ Rectangle { Connections { target: webPreview - onJavaScriptErrorMessage: errorMessage(_content, "javascript") - onJavaScriptWarningMessage: warningMessage(_content, "javascript") - onJavaScriptInfoMessage: infoMessage(_content, "javascript") + onJavaScriptMessage: + { + if (_level === 0) + infoMessage(_content, "JavaScript") + else + { + var message = _sourceId.substring(_sourceId.lastIndexOf("/") + 1) + " - " + qsTr("line") + " " + _lineNb + " - " + _content; + if (_level === 1) + warningMessage(message, "JavaScript") + else if (_level === 2) + errorMessage(message, "JavaScript") + } + } } Connections { target:clientModel - onRunStarted: infoMessage(qsTr("Running transactions..."), "run"); - onRunFailed: errorMessage(format(_message), "run"); - onRunComplete: infoMessage(qsTr("Run complete"), "run"); - onNewBlock: infoMessage(qsTr("New block created"), "state"); + onRunStarted: infoMessage(qsTr("Running transactions..."), "Run"); + onRunFailed: errorMessage(format(_message), "Run"); + onRunComplete: infoMessage(qsTr("Run complete"), "Run"); + onNewBlock: infoMessage(qsTr("New block created"), "State"); function format(_message) { @@ -72,16 +83,16 @@ Rectangle { return _message; var exceptionInfos = _message.match(/(?:tag_)(.+)/g); for (var k in exceptionInfos) - formatted += " " + exceptionInfos[k].replace("*]", "").replace("tag_", "") + " - "; + formatted += " " + exceptionInfos[k].replace("*]", "").replace("tag_", "").replace("=", ""); return formatted; } } Connections { target:projectModel - onDeploymentStarted: infoMessage(qsTr("Running deployment..."), "deployment"); - onDeploymentError: errorMessage(error, "deployment"); - onDeploymentComplete: infoMessage(qsTr("Deployment complete"), "deployment"); - onDeploymentStepChanged: infoMessage(message, "deployment"); + onDeploymentStarted: infoMessage(qsTr("Running deployment..."), "Deployment"); + onDeploymentError: errorMessage(error, "Deployment"); + onDeploymentComplete: infoMessage(qsTr("Deployment complete"), "Deployment"); + onDeploymentStepChanged: infoMessage(message, "Deployment"); } Connections { target: codeModel @@ -95,7 +106,7 @@ Rectangle { Rectangle { id: statusContainer anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenterw + anchors.verticalCenter: parent.verticalCenter radius: 3 width: 500 height: 30 @@ -171,6 +182,12 @@ Rectangle { color: "transparent" } } + MouseArea { + anchors.fill: parent + onClicked: { + logsContainer.toggle(); + } + } } Action { @@ -189,15 +206,17 @@ Rectangle { } else { - statusContainer.state = "logsOpened"; + statusContainer.state = "'logsOpened"; logsContainer.state = "opened"; + logsContainer.focus = true; + forceActiveFocus(); } } id: logsContainer width: 1000 height: 0 - //anchors.topMargin: + anchors.topMargin: 10 anchors.top: statusContainer.bottom anchors.horizontalCenter: parent.horizontalCenter visible: false @@ -233,26 +252,6 @@ Rectangle { } } - Button - { - id: logslink - anchors.left: statusContainer.right - anchors.leftMargin: 9 - anchors.verticalCenter: parent.verticalCenter - action: displayLogAction - iconSource: "qrc:/qml/img/search_filled.png" - } - - Action { - id: displayLogAction - tooltip: qsTr("Display Log") - onTriggered: { - logsContainer.toggle(); - //if (status.state === "error" && logPane.front().type === "run") - // mainContent.displayCompilationErrorIfAny(); - } - } - Rectangle { color: "transparent" @@ -267,7 +266,6 @@ Rectangle { { color: "transparent" anchors.fill: parent - Button { anchors.right: parent.right diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index 5a9673a2c..ba2975453 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -12,9 +12,7 @@ Item { id: webPreview property string pendingPageUrl: "" property bool initialized: false - signal javaScriptErrorMessage(string _content) - signal javaScriptWarningMessage(string _content) - signal javaScriptInfoMessage(string _content) + signal javaScriptMessage(var _level, string _sourceId, var _lineNb, string _content) function setPreviewUrl(url) { if (!initialized) @@ -201,7 +199,6 @@ Item { { setPreviewUrl(text); } - focus: true } @@ -219,7 +216,9 @@ Item { anchors.verticalCenter: parent.verticalCenter width: 21 height: 21 + focus: true } + CheckBox { id: autoReloadOnSave checked: true @@ -230,6 +229,7 @@ Item { text: qsTr("Auto reload on save") } } + focus: true } } } @@ -243,13 +243,7 @@ Item { id: webView experimental.settings.localContentCanAccessRemoteUrls: true onJavaScriptConsoleMessage: { - var info = sourceID + ":" + lineNumber + ":" + message; - if (level === 0) - webPreview.javaScriptInfoMessage(info); - else if (level === 1) - webPreview.javaScriptErrorMessage(info); - else if (level === 2) - webPreview.javaScriptErrorMessage(info); + webPreview.javaScriptMessage(level, sourceID, lineNumber, message); } onLoadingChanged: { if (!loading) { From 21cef78720c97244ef5ebfb1e7d44b96d3370426 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 11:52:45 +0100 Subject: [PATCH 06/13] Modify SortFilterProxyModel to be compliant with Coding Standards --- mix/sortfilterproxymodel.cpp | 90 +++++++++--------------------------- mix/sortfilterproxymodel.h | 35 ++++++-------- 2 files changed, 37 insertions(+), 88 deletions(-) diff --git a/mix/sortfilterproxymodel.cpp b/mix/sortfilterproxymodel.cpp index 04e403738..62d85cfa3 100644 --- a/mix/sortfilterproxymodel.cpp +++ b/mix/sortfilterproxymodel.cpp @@ -44,7 +44,7 @@ using namespace dev::mix; -SortFilterProxyModel::SortFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) +SortFilterProxyModel::SortFilterProxyModel(QObject* _parent) : QSortFilterProxyModel(_parent) { connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged())); connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged())); @@ -55,14 +55,14 @@ int SortFilterProxyModel::count() const return rowCount(); } -QObject *SortFilterProxyModel::source() const +QObject* SortFilterProxyModel::source() const { return sourceModel(); } -void SortFilterProxyModel::setSource(QObject *source) +void SortFilterProxyModel::setSource(QObject* _source) { - setSourceModel(qobject_cast(source)); + setSourceModel(qobject_cast(_source)); } QByteArray SortFilterProxyModel::sortRole() const @@ -70,34 +70,24 @@ QByteArray SortFilterProxyModel::sortRole() const return roleNames().value(QSortFilterProxyModel::sortRole()); } -void SortFilterProxyModel::setSortRole(const QByteArray &role) +void SortFilterProxyModel::setSortRole(QByteArray const& _role) { - QSortFilterProxyModel::setSortRole(roleKey(role)); + QSortFilterProxyModel::setSortRole(roleKey(_role)); } -void SortFilterProxyModel::setSortOrder(Qt::SortOrder order) +void SortFilterProxyModel::setSortOrder(Qt::SortOrder _order) { - QSortFilterProxyModel::sort(0, order); + QSortFilterProxyModel::sort(0, _order); } -/*QByteArray SortFilterProxyModel::filterRole() const -{ - return roleNames().value(QSortFilterProxyModel::filterRole()); -}*/ - -/*void SortFilterProxyModel::setFilterRole(const QByteArray &role) -{ - QSortFilterProxyModel::setFilterRole(roleKey(role)); -}*/ - QString SortFilterProxyModel::filterString() const { return filterRegExp().pattern(); } -void SortFilterProxyModel::setFilterString(const QString &filter) +void SortFilterProxyModel::setFilterString(QString const& _filter) { - setFilterRegExp(QRegExp(filter, filterCaseSensitivity(), static_cast(filterSyntax()))); + setFilterRegExp(QRegExp(_filter, filterCaseSensitivity(), static_cast(filterSyntax()))); } SortFilterProxyModel::FilterSyntax SortFilterProxyModel::filterSyntax() const @@ -105,33 +95,33 @@ SortFilterProxyModel::FilterSyntax SortFilterProxyModel::filterSyntax() const return static_cast(filterRegExp().patternSyntax()); } -void SortFilterProxyModel::setFilterSyntax(SortFilterProxyModel::FilterSyntax syntax) +void SortFilterProxyModel::setFilterSyntax(SortFilterProxyModel::FilterSyntax _syntax) { - setFilterRegExp(QRegExp(filterString(), filterCaseSensitivity(), static_cast(syntax))); + setFilterRegExp(QRegExp(filterString(), filterCaseSensitivity(), static_cast(_syntax))); } -QJSValue SortFilterProxyModel::get(int idx) const +QJSValue SortFilterProxyModel::get(int _idx) const { QJSEngine *engine = qmlEngine(this); QJSValue value = engine->newObject(); - if (idx >= 0 && idx < count()) { + if (_idx >= 0 && _idx < count()) { QHash roles = roleNames(); QHashIterator it(roles); while (it.hasNext()) { it.next(); - value.setProperty(QString::fromUtf8(it.value()), data(index(idx, 0), it.key()).toString()); + value.setProperty(QString::fromUtf8(it.value()), data(index(_idx, 0), it.key()).toString()); } } return value; } -int SortFilterProxyModel::roleKey(const QByteArray &role) const +int SortFilterProxyModel::roleKey(QByteArray const& _role) const { QHash roles = roleNames(); QHashIterator it(roles); while (it.hasNext()) { it.next(); - if (it.value() == role) + if (it.value() == _role) return it.key(); } return -1; @@ -139,62 +129,26 @@ int SortFilterProxyModel::roleKey(const QByteArray &role) const QHash SortFilterProxyModel::roleNames() const { - if (QAbstractItemModel *source = sourceModel()) + if (QAbstractItemModel* source = sourceModel()) return source->roleNames(); return QHash(); } -bool SortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +bool SortFilterProxyModel::filterAcceptsRow(int _sourceRow, QModelIndex const& _sourceParent) const { - /*QRegExp rx = filterRegExp(); - if (rx.isEmpty()) - return true; - QAbstractItemModel *model = sourceModel(); - - if (filterRole().isEmpty()) { - QHash roles = roleNames(); - QHashIterator it(roles); - while (it.hasNext()) { - it.next(); - QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); - QString key = model->data(sourceIndex, it.key()).toString(); - if (key.contains(rx))data - return true; - } - return false; - }*/ QRegExp rx = filterRegExp(); QAbstractItemModel *model = sourceModel(); - QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); + QModelIndex sourceIndex = model->index(_sourceRow, 0, _sourceParent); if (!sourceIndex.isValid()) return true; QString keyType = model->data(sourceIndex, roleKey(type.toUtf8())).toString(); QString keyContent = model->data(sourceIndex, roleKey(content.toUtf8())).toString(); - return keyType.contains(m_filterType) && keyContent.contains(m_filterContent); -/* - for (auto filter: filterRoles()) - { - QString key = model->data(sourceIndex, roleKey(filter.toUtf8())).toString(); - if (!key.contains(rx)) - return false; - } - return true; - QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); - if (!sourceIndex.isValid()) - return true; - for (auto role: filterR) - { - QString key = model->data(sourceIndex, roleKey(role)).toString(); - if (key.contains(rx)) - return true; - } - return false;*/ } -void SortFilterProxyModel::setFilterType(const QString &_type) +void SortFilterProxyModel::setFilterType(QString const& _type) { m_filterType = QRegExp(_type, filterCaseSensitivity(), static_cast(filterSyntax())); setFilterRegExp(_type); @@ -205,7 +159,7 @@ QString SortFilterProxyModel::filterType() const return m_filterType.pattern(); } -void SortFilterProxyModel::setFilterContent(const QString &_content) +void SortFilterProxyModel::setFilterContent(QString const& _content) { m_filterContent = QRegExp(_content, filterCaseSensitivity(), static_cast(filterSyntax())); setFilterRegExp(_content); diff --git a/mix/sortfilterproxymodel.h b/mix/sortfilterproxymodel.h index 8eae97a68..bc220a911 100644 --- a/mix/sortfilterproxymodel.h +++ b/mix/sortfilterproxymodel.h @@ -38,8 +38,7 @@ ** ****************************************************************************/ -#ifndef SORTFILTERPROXYMODEL_H -#define SORTFILTERPROXYMODEL_H +#pragma once #include #include @@ -49,11 +48,11 @@ namespace dev namespace mix { -class SortFilterProxyModel : public QSortFilterProxyModel +class SortFilterProxyModel: public QSortFilterProxyModel { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_PROPERTY(QObject *source READ source WRITE setSource) + Q_PROPERTY(QObject* source READ source WRITE setSource) Q_PROPERTY(QByteArray sortRole READ sortRole WRITE setSortRole) Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder) @@ -66,26 +65,23 @@ class SortFilterProxyModel : public QSortFilterProxyModel Q_ENUMS(FilterSyntax) public: - explicit SortFilterProxyModel(QObject *parent = 0); + explicit SortFilterProxyModel(QObject* _parent = 0); - QObject *source() const; - void setSource(QObject *source); + QObject* source() const; + void setSource(QObject* _source); QByteArray sortRole() const; - void setSortRole(const QByteArray &role); + void setSortRole(QByteArray const& _role); - void setSortOrder(Qt::SortOrder order); + void setSortOrder(Qt::SortOrder _order); QString filterContent() const; - void setFilterContent(const QString &_content); + void setFilterContent(QString const& _content); QString filterType() const; - void setFilterType(const QString &_type); + void setFilterType(QString const& _type); - /*QStringList filterRoles() const; - void setFilterRoles(const QStringList &roles); -*/ QString filterString() const; - void setFilterString(const QString &filter); + void setFilterString(QString const& _filter); enum FilterSyntax { RegExp, @@ -94,18 +90,18 @@ public: }; FilterSyntax filterSyntax() const; - void setFilterSyntax(FilterSyntax syntax); + void setFilterSyntax(FilterSyntax _syntax); int count() const; - Q_INVOKABLE QJSValue get(int index) const; + Q_INVOKABLE QJSValue get(int _index) const; signals: void countChanged(); protected: - int roleKey(const QByteArray &role) const; + int roleKey(QByteArray const& _role) const; QHash roleNames() const; - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + bool filterAcceptsRow(int _sourceRow, QModelIndex const& _sourceParent) const; private: QRegExp m_filterType; @@ -116,4 +112,3 @@ private: } } -#endif // SORTFILTERPROXYMODEL_H From c7f703cc71e618e11f0c166c8e7cad0105d8351a Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 11:58:33 +0100 Subject: [PATCH 07/13] small changes --- mix/CodeEditorExtensionManager.cpp | 9 --------- mix/CodeEditorExtensionManager.h | 2 -- 2 files changed, 11 deletions(-) diff --git a/mix/CodeEditorExtensionManager.cpp b/mix/CodeEditorExtensionManager.cpp index 516184cff..7f1f5d216 100644 --- a/mix/CodeEditorExtensionManager.cpp +++ b/mix/CodeEditorExtensionManager.cpp @@ -51,14 +51,6 @@ void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) return; } -void CodeEditorExtensionManager::initExtensions() -{ - //std::shared_ptr output = std::make_shared(m_appContext); - //QObject::connect(m_appContext->codeModel(), &CodeModel::compilationComplete, this, &CodeEditorExtensionManager::applyCodeHighlight); - - //initExtension(output); -} - void CodeEditorExtensionManager::initExtension(std::shared_ptr _ext) { if (!_ext->contentUrl().isEmpty()) @@ -93,5 +85,4 @@ void CodeEditorExtensionManager::setRightView(QQuickItem* _rightView) void CodeEditorExtensionManager::setHeaderView(QQuickItem* _headerView) { m_headerView = _headerView; - initExtensions(); //TODO: move this to a proper place } diff --git a/mix/CodeEditorExtensionManager.h b/mix/CodeEditorExtensionManager.h index fe6fbb33a..ebfe2d8a3 100644 --- a/mix/CodeEditorExtensionManager.h +++ b/mix/CodeEditorExtensionManager.h @@ -49,8 +49,6 @@ class CodeEditorExtensionManager: public QObject public: CodeEditorExtensionManager(); ~CodeEditorExtensionManager(); - /// Initialize all extensions. - void initExtensions(); /// Initialize extension. void initExtension(std::shared_ptr); /// Set current tab view From 68cd82a561cff29d5f58b773df955e75fc7de891 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 12:24:40 +0100 Subject: [PATCH 08/13] QML Styling --- mix/qml/LogsPane.qml | 346 +++++++++++++++++++------------------- mix/qml/LogsPaneStyle.qml | 28 +++ mix/qml/StatusPane.qml | 6 +- mix/qml/qmldir | 1 + mix/res.qrc | 1 + 5 files changed, 206 insertions(+), 176 deletions(-) create mode 100644 mix/qml/LogsPaneStyle.qml diff --git a/mix/qml/LogsPane.qml b/mix/qml/LogsPane.qml index 67bdd44c1..bc192f1a7 100644 --- a/mix/qml/LogsPane.qml +++ b/mix/qml/LogsPane.qml @@ -15,9 +15,9 @@ Rectangle anchors.fill: parent radius: 5 - color: "#f7f7f7" - border.color: "#808080" - border.width: 1 + color: LogsPaneStyle.generic.layout.backgroundColor + border.color: LogsPaneStyle.generic.layout.borderColor + border.width: LogsPaneStyle.generic.layout.borderWidth ColumnLayout { z: 2 height: parent.height @@ -26,14 +26,14 @@ Rectangle Row { id: rowAction - Layout.preferredHeight: 35 - height: 35 - anchors.leftMargin: 10 + Layout.preferredHeight: LogsPaneStyle.generic.layout.headerHeight + height: LogsPaneStyle.generic.layout.headerHeight + anchors.leftMargin: LogsPaneStyle.generic.layout.leftMargin anchors.left: parent.left - spacing: 5 + spacing: LogsPaneStyle.generic.layout.headerButtonSpacing Button { - height: 30 + height: LogsPaneStyle.generic.layout.headerButtonHeight anchors.verticalCenter: parent.verticalCenter action: clearAction iconSource: "qrc:/qml/img/broom.png" @@ -50,7 +50,7 @@ Rectangle Button { - height: 30 + height: LogsPaneStyle.generic.layout.headerButtonHeight anchors.verticalCenter: parent.verticalCenter action: copytoClipBoardAction iconSource: "qrc:/qml/img/copy.png" @@ -81,7 +81,7 @@ Rectangle ToolButton { id: javascriptButton checkable: true - height: 30 + height: LogsPaneStyle.generic.layout.headerButtonHeight anchors.verticalCenter: parent.verticalCenter checked: true onCheckedChanged: { @@ -89,212 +89,212 @@ Rectangle } tooltip: qsTr("JavaScript") style: - ButtonStyle { + ButtonStyle { label: Item { DefaultLabel { - font.family: "sans serif" + font.family: LogsPaneStyle.generic.layout.logLabelFont font.pointSize: Style.absoluteSize(-3) - color: "#5391d8" + color: LogsPaneStyle.generic.layout.logLabelColor anchors.centerIn: parent text: qsTr("JavaScript") } } + } } - } - ToolButton { - id: runButton - checkable: true - height: 30 - anchors.verticalCenter: parent.verticalCenter - checked: true - onCheckedChanged: { - proxyModel.toogleFilter("run") - } - tooltip: qsTr("Run") - style: - ButtonStyle { - label: - Item { - DefaultLabel { - font.family: "sans serif" - font.pointSize: Style.absoluteSize(-3) - color: "#5391d8" - anchors.centerIn: parent - text: qsTr("Run") + ToolButton { + id: runButton + checkable: true + height: LogsPaneStyle.generic.layout.headerButtonHeight + anchors.verticalCenter: parent.verticalCenter + checked: true + onCheckedChanged: { + proxyModel.toogleFilter("run") + } + tooltip: qsTr("Run") + style: + ButtonStyle { + label: + Item { + DefaultLabel { + font.family: LogsPaneStyle.generic.layout.logLabelFont + font.pointSize: Style.absoluteSize(-3) + color: LogsPaneStyle.generic.layout.logLabelColor + anchors.centerIn: parent + text: qsTr("Run") + } } } } - } - ToolButton { - id: stateButton - checkable: true - height: 30 - anchors.verticalCenter: parent.verticalCenter - checked: true - onCheckedChanged: { - proxyModel.toogleFilter("state") - } - tooltip: qsTr("State") - style: - ButtonStyle { - label: - Item { - DefaultLabel { - font.family: "sans serif" - font.pointSize: Style.absoluteSize(-3) - color: "#5391d8" - anchors.centerIn: parent - text: qsTr("State") + ToolButton { + id: stateButton + checkable: true + height: LogsPaneStyle.generic.layout.headerButtonHeight + anchors.verticalCenter: parent.verticalCenter + checked: true + onCheckedChanged: { + proxyModel.toogleFilter("state") + } + tooltip: qsTr("State") + style: + ButtonStyle { + label: + Item { + DefaultLabel { + font.family: LogsPaneStyle.generic.layout.logLabelFont + font.pointSize: Style.absoluteSize(-3) + color: "#5391d8" + anchors.centerIn: parent + text: qsTr("State") + } } } } - } - ToolButton { - id: compilationButton - checkable: true - height: 30 - anchors.verticalCenter: parent.verticalCenter - checked: false - onCheckedChanged: { - proxyModel.toogleFilter("compilation") - } - tooltip: qsTr("Compilation") - style: - ButtonStyle { - label: - Item { - DefaultLabel { - font.family: "sans serif" - font.pointSize: Style.absoluteSize(-3) - color: "#5391d8" - anchors.centerIn: parent - text: qsTr("Compilation") + ToolButton { + id: compilationButton + checkable: true + height: LogsPaneStyle.generic.layout.headerButtonHeight + anchors.verticalCenter: parent.verticalCenter + checked: false + onCheckedChanged: { + proxyModel.toogleFilter("compilation") + } + tooltip: qsTr("Compilation") + style: + ButtonStyle { + label: + Item { + DefaultLabel { + font.family: LogsPaneStyle.generic.layout.logLabelFont + font.pointSize: Style.absoluteSize(-3) + color: "#5391d8" + anchors.centerIn: parent + text: qsTr("Compilation") + } } } } - } - DefaultTextField - { - id: searchBox - height: 30 - anchors.verticalCenter: parent.verticalCenter - width: 200 - font.family: "sans serif" - font.pointSize: Style.absoluteSize(-3) - font.italic: true - onTextChanged: { - proxyModel.search(text); + DefaultTextField + { + id: searchBox + height: LogsPaneStyle.generic.layout.headerButtonHeight + anchors.verticalCenter: parent.verticalCenter + width: LogsPaneStyle.generic.layout.headerInputWidth + font.family: LogsPaneStyle.generic.layout.logLabelFont + font.pointSize: Style.absoluteSize(-3) + font.italic: true + onTextChanged: { + proxyModel.search(text); + } } } - } - ListModel { - id: logsModel - } - - TableView { - id: logsTable - clip: true - Layout.fillWidth: true - Layout.preferredHeight: parent.height - rowAction.height - headerVisible : false - onDoubleClicked: - { - var log = logsModel.get((logsTable.currentRow)); - if (log) - appContext.toClipboard(log.type + "\t" + log.level + "\t" + log.date + "\t" + log.content); + ListModel { + id: logsModel } - model: SortFilterProxyModel { - id: proxyModel - source: logsModel - property var roles: ["-", "javascript", "run", "state"] - - Component.onCompleted: { - filterType = regEx(proxyModel.roles); - } - - function search(_value) + TableView { + id: logsTable + clip: true + Layout.fillWidth: true + Layout.preferredHeight: parent.height - rowAction.height + headerVisible : false + onDoubleClicked: { - filterContent = _value; + var log = logsModel.get((logsTable.currentRow)); + if (log) + appContext.toClipboard(log.type + "\t" + log.level + "\t" + log.date + "\t" + log.content); } - function toogleFilter(_value) - { - var count = roles.length; - for (var i in roles) + model: SortFilterProxyModel { + id: proxyModel + source: logsModel + property var roles: ["-", "javascript", "run", "state"] + + Component.onCompleted: { + filterType = regEx(proxyModel.roles); + } + + function search(_value) { - if (roles[i] === _value) + filterContent = _value; + } + + function toogleFilter(_value) + { + var count = roles.length; + for (var i in roles) { - roles.splice(i, 1); - break; + if (roles[i] === _value) + { + roles.splice(i, 1); + break; + } } + if (count === roles.length) + roles.push(_value); + + filterType = regEx(proxyModel.roles); } - if (count === roles.length) - roles.push(_value); - filterType = regEx(proxyModel.roles); - } + function regEx(_value) + { + return "(?:" + roles.join('|') + ")"; + } - function regEx(_value) + filterType: "(?:javascript|run|state)" + filterContent: "" + filterSyntax: SortFilterProxyModel.RegExp + filterCaseSensitivity: Qt.CaseInsensitive + } + TableViewColumn { - return "(?:" + roles.join('|') + ")"; + role: "date" + title: qsTr("date") + width: LogsPaneStyle.generic.layout.dateWidth + delegate: itemDelegate + } + TableViewColumn + { + role: "type" + title: qsTr("type") + width: LogsPaneStyle.generic.layout.typeWidth + delegate: itemDelegate + } + TableViewColumn + { + role: "content" + title: qsTr("content") + width: LogsPaneStyle.generic.layout.contentWidth + delegate: itemDelegate } - filterType: "(?:javascript|run|state)" - filterContent: "" - filterSyntax: SortFilterProxyModel.RegExp - filterCaseSensitivity: Qt.CaseInsensitive - } - TableViewColumn - { - role: "date" - title: qsTr("date") - width: 150 - delegate: itemDelegate - } - TableViewColumn - { - role: "type" - title: qsTr("type") - width: 80 - delegate: itemDelegate - } - TableViewColumn - { - role: "content" - title: qsTr("content") - width: 700 - delegate: itemDelegate - } - - rowDelegate: Item { - Rectangle { - width: logsTable.width - 4 - height: 17 - color: styleData.alternate ? "transparent" : "#f0f0f0" + rowDelegate: Item { + Rectangle { + width: logsTable.width - 4 + height: 17 + color: styleData.alternate ? "transparent" : "#f0f0f0" + } } } - } - Component { - id: itemDelegate - DefaultLabel { - text: styleData.value; - font.family: "sans serif" - font.pointSize: Style.absoluteSize(-1) - color: { - if (proxyModel.get(styleData.row).level === "error") - return "red" - else - return "#808080" + Component { + id: itemDelegate + DefaultLabel { + text: styleData.value; + font.family: LogsPaneStyle.generic.layout.logLabelFont + font.pointSize: Style.absoluteSize(-1) + color: { + if (proxyModel.get(styleData.row).level === "error") + return "red" + else + return "#808080" + } } } } } -} diff --git a/mix/qml/LogsPaneStyle.qml b/mix/qml/LogsPaneStyle.qml new file mode 100644 index 000000000..c47ee6338 --- /dev/null +++ b/mix/qml/LogsPaneStyle.qml @@ -0,0 +1,28 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + + function absoluteSize(rel) + { + return systemPointSize + rel; + } + + property QtObject generic: QtObject { + property QtObject layout: QtObject { + property string backgroundColor: "#f7f7f7" + property string borderColor: "#5391d8" + property int borderWidth: 1 + property int headerHeight: 35 + property int headerButtonSpacing: 5 + property int leftMargin: 10 + property int headerButtonHeight: 30 + property string logLabelColor: "#5391d8" + property string logLabelFont: "sans serif" + property int headerInputWidth: 200 + property int dateWidth: 150 + property int typeWidth: 80 + property int contentWidth: 700 + } + } +} diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index 1ce7917a9..e9ff312a9 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -116,7 +116,7 @@ Rectangle { name: "logsOpened" PropertyChanges { target: statusContainer - border.color: "#808080" + border.color: "#5391d8" border.width: 1 } }, @@ -124,7 +124,7 @@ Rectangle { name: "logsClosed" PropertyChanges { target: statusContainer - border.color: "#808080" + border.color: "#5391d8" border.width: 0 } } @@ -206,7 +206,7 @@ Rectangle { } else { - statusContainer.state = "'logsOpened"; + statusContainer.state = "logsOpened"; logsContainer.state = "opened"; logsContainer.focus = true; forceActiveFocus(); diff --git a/mix/qml/qmldir b/mix/qml/qmldir index 0f3fcd88c..73c117941 100644 --- a/mix/qml/qmldir +++ b/mix/qml/qmldir @@ -5,3 +5,4 @@ singleton DebuggerPaneStyle 1.0 DebuggerPaneStyle.qml singleton StateStyle 1.0 StateStyle.qml singleton StatusPaneStyle 1.0 StatusPaneStyle.qml singleton WebPreviewStyle 1.0 WebPreviewStyle.qml +singleton LogsPaneStyle 1.0 LogsPaneStyle.qml diff --git a/mix/res.qrc b/mix/res.qrc index 8bda8124c..e953b3e35 100644 --- a/mix/res.qrc +++ b/mix/res.qrc @@ -114,5 +114,6 @@ qml/LogsPane.qml qml/img/copy.png qml/img/broom.png + qml/LogsPaneStyle.qml From 47d7f571c3dc8342e044a876d577e3702a8ff06a Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 12:34:29 +0100 Subject: [PATCH 09/13] add warning level --- mix/qml/LogsPane.qml | 6 ++++-- mix/qml/StatusPane.qml | 13 ++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mix/qml/LogsPane.qml b/mix/qml/LogsPane.qml index bc192f1a7..8956abdf2 100644 --- a/mix/qml/LogsPane.qml +++ b/mix/qml/LogsPane.qml @@ -290,9 +290,11 @@ Rectangle font.pointSize: Style.absoluteSize(-1) color: { if (proxyModel.get(styleData.row).level === "error") - return "red" + return "red"; + else if (proxyModel.get(styleData.row).level === "warning") + return "orange"; else - return "#808080" + return "#808080"; } } } diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index e9ff312a9..71f622865 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -38,7 +38,7 @@ Rectangle { function warningMessage(text, type) { - status.state = ""; + status.state = "warning"; status.text = text logPane.push("warning", type, text); } @@ -153,6 +153,17 @@ Rectangle { target: statusContainer color: "#fffcd5" } + }, + State { + name: "warning" + PropertyChanges { + target: status + color: "orange" + } + PropertyChanges { + target: statusContainer + color: "#fffcd5" + } } ] onTextChanged: From 0d444716b012a541caf9c7f13076b0894b8cb2ee Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 12:38:55 +0100 Subject: [PATCH 10/13] small changes --- mix/qml/LogsPane.qml | 2 +- mix/qml/LogsPaneStyle.qml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mix/qml/LogsPane.qml b/mix/qml/LogsPane.qml index 8956abdf2..9d03b2af2 100644 --- a/mix/qml/LogsPane.qml +++ b/mix/qml/LogsPane.qml @@ -277,7 +277,7 @@ Rectangle Rectangle { width: logsTable.width - 4 height: 17 - color: styleData.alternate ? "transparent" : "#f0f0f0" + color: styleData.alternate ? "transparent" : LogsPaneStyle.generic.layout.logAlternateColor } } } diff --git a/mix/qml/LogsPaneStyle.qml b/mix/qml/LogsPaneStyle.qml index c47ee6338..59b80653a 100644 --- a/mix/qml/LogsPaneStyle.qml +++ b/mix/qml/LogsPaneStyle.qml @@ -23,6 +23,7 @@ QtObject { property int dateWidth: 150 property int typeWidth: 80 property int contentWidth: 700 + property string logAlternateColor: "#f0f0f0" } } } From b0b1c5bca8592147099a458c0c56e92eefb89457 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 12:41:31 +0100 Subject: [PATCH 11/13] small changes --- mix/qml/StatusPane.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index 71f622865..20b30ce3b 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -33,7 +33,7 @@ Rectangle { { status.state = ""; status.text = text - logPane.push("info",type, text); + logPane.push("info", type, text); } function warningMessage(text, type) @@ -61,7 +61,7 @@ Rectangle { var message = _sourceId.substring(_sourceId.lastIndexOf("/") + 1) + " - " + qsTr("line") + " " + _lineNb + " - " + _content; if (_level === 1) warningMessage(message, "JavaScript") - else if (_level === 2) + else errorMessage(message, "JavaScript") } } From 071f81652b5204bccc6fd3dd775689fa6ddb38ca Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 14:28:27 +0100 Subject: [PATCH 12/13] Replace Qt header by Ethereum header. --- mix/AppContext.cpp | 2 +- ...roxymodel.cpp => Sortfilterproxymodel.cpp} | 65 ++++------ mix/Sortfilterproxymodel.h | 97 +++++++++++++++ mix/sortfilterproxymodel.h | 114 ------------------ 4 files changed, 122 insertions(+), 156 deletions(-) rename mix/{sortfilterproxymodel.cpp => Sortfilterproxymodel.cpp} (63%) create mode 100644 mix/Sortfilterproxymodel.h delete mode 100644 mix/sortfilterproxymodel.h diff --git a/mix/AppContext.cpp b/mix/AppContext.cpp index 46bb0f98d..b649ee4c2 100644 --- a/mix/AppContext.cpp +++ b/mix/AppContext.cpp @@ -38,7 +38,7 @@ #include "QVariableDefinition.h" #include "HttpServer.h" #include "AppContext.h" -#include "sortfilterproxymodel.h" +#include "Sortfilterproxymodel.h" using namespace dev; using namespace dev::eth; diff --git a/mix/sortfilterproxymodel.cpp b/mix/Sortfilterproxymodel.cpp similarity index 63% rename from mix/sortfilterproxymodel.cpp rename to mix/Sortfilterproxymodel.cpp index 62d85cfa3..64689842b 100644 --- a/mix/sortfilterproxymodel.cpp +++ b/mix/Sortfilterproxymodel.cpp @@ -1,44 +1,27 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sortfilterproxymodel.h" +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** + * @author Yann + * @date 2015 + * Proxy used to filter a QML TableView. + */ + + +#include "Sortfilterproxymodel.h" #include #include diff --git a/mix/Sortfilterproxymodel.h b/mix/Sortfilterproxymodel.h new file mode 100644 index 000000000..de9a2005f --- /dev/null +++ b/mix/Sortfilterproxymodel.h @@ -0,0 +1,97 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** + * @author Yann + * @date 2015 + * Proxy used to filter a QML TableView. + */ + + +#pragma once + +#include +#include + +namespace dev +{ +namespace mix +{ + +class SortFilterProxyModel: public QSortFilterProxyModel +{ + Q_OBJECT + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QObject* source READ source WRITE setSource) + + Q_PROPERTY(QByteArray sortRole READ sortRole WRITE setSortRole) + Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder) + + Q_PROPERTY(QString filterContent READ filterContent WRITE setFilterContent) + Q_PROPERTY(QString filterType READ filterType WRITE setFilterType) + Q_PROPERTY(QString filterString READ filterString WRITE setFilterString) + Q_PROPERTY(FilterSyntax filterSyntax READ filterSyntax WRITE setFilterSyntax) + + Q_ENUMS(FilterSyntax) + +public: + explicit SortFilterProxyModel(QObject* _parent = 0); + + QObject* source() const; + void setSource(QObject* _source); + + QByteArray sortRole() const; + void setSortRole(QByteArray const& _role); + + void setSortOrder(Qt::SortOrder _order); + + QString filterContent() const; + void setFilterContent(QString const& _content); + QString filterType() const; + void setFilterType(QString const& _type); + + QString filterString() const; + void setFilterString(QString const& _filter); + + enum FilterSyntax { + RegExp, + Wildcard, + FixedString + }; + + FilterSyntax filterSyntax() const; + void setFilterSyntax(FilterSyntax _syntax); + + int count() const; + Q_INVOKABLE QJSValue get(int _index) const; + +signals: + void countChanged(); + +protected: + int roleKey(QByteArray const& _role) const; + QHash roleNames() const; + bool filterAcceptsRow(int _sourceRow, QModelIndex const& _sourceParent) const; + +private: + QRegExp m_filterType; + QRegExp m_filterContent; + const QString type = "type"; + const QString content = "content"; +}; + +} +} diff --git a/mix/sortfilterproxymodel.h b/mix/sortfilterproxymodel.h deleted file mode 100644 index bc220a911..000000000 --- a/mix/sortfilterproxymodel.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#pragma once - -#include -#include - -namespace dev -{ -namespace mix -{ - -class SortFilterProxyModel: public QSortFilterProxyModel -{ - Q_OBJECT - Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_PROPERTY(QObject* source READ source WRITE setSource) - - Q_PROPERTY(QByteArray sortRole READ sortRole WRITE setSortRole) - Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder) - - Q_PROPERTY(QString filterContent READ filterContent WRITE setFilterContent) - Q_PROPERTY(QString filterType READ filterType WRITE setFilterType) - Q_PROPERTY(QString filterString READ filterString WRITE setFilterString) - Q_PROPERTY(FilterSyntax filterSyntax READ filterSyntax WRITE setFilterSyntax) - - Q_ENUMS(FilterSyntax) - -public: - explicit SortFilterProxyModel(QObject* _parent = 0); - - QObject* source() const; - void setSource(QObject* _source); - - QByteArray sortRole() const; - void setSortRole(QByteArray const& _role); - - void setSortOrder(Qt::SortOrder _order); - - QString filterContent() const; - void setFilterContent(QString const& _content); - QString filterType() const; - void setFilterType(QString const& _type); - - QString filterString() const; - void setFilterString(QString const& _filter); - - enum FilterSyntax { - RegExp, - Wildcard, - FixedString - }; - - FilterSyntax filterSyntax() const; - void setFilterSyntax(FilterSyntax _syntax); - - int count() const; - Q_INVOKABLE QJSValue get(int _index) const; - -signals: - void countChanged(); - -protected: - int roleKey(QByteArray const& _role) const; - QHash roleNames() const; - bool filterAcceptsRow(int _sourceRow, QModelIndex const& _sourceParent) const; - -private: - QRegExp m_filterType; - QRegExp m_filterContent; - const QString type = "type"; - const QString content = "content"; -}; - -} -} From d9be32d6311635462dc799047537d7dc4885ae82 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Mar 2015 17:36:14 +0100 Subject: [PATCH 13/13] small changes --- mix/AppContext.cpp | 3 +-- ...roxymodel.cpp => SortFilterProxyModel.cpp} | 25 ++++++++++--------- ...terproxymodel.h => SortFilterProxyModel.h} | 0 3 files changed, 14 insertions(+), 14 deletions(-) rename mix/{Sortfilterproxymodel.cpp => SortFilterProxyModel.cpp} (89%) rename mix/{Sortfilterproxymodel.h => SortFilterProxyModel.h} (100%) diff --git a/mix/AppContext.cpp b/mix/AppContext.cpp index b649ee4c2..991fd334a 100644 --- a/mix/AppContext.cpp +++ b/mix/AppContext.cpp @@ -22,7 +22,6 @@ * - KeyEventManager */ -#include #include #include #include @@ -38,7 +37,7 @@ #include "QVariableDefinition.h" #include "HttpServer.h" #include "AppContext.h" -#include "Sortfilterproxymodel.h" +#include "SortFilterProxyModel.h" using namespace dev; using namespace dev::eth; diff --git a/mix/Sortfilterproxymodel.cpp b/mix/SortFilterProxyModel.cpp similarity index 89% rename from mix/Sortfilterproxymodel.cpp rename to mix/SortFilterProxyModel.cpp index 64689842b..6fb2cca0c 100644 --- a/mix/Sortfilterproxymodel.cpp +++ b/mix/SortFilterProxyModel.cpp @@ -21,7 +21,7 @@ */ -#include "Sortfilterproxymodel.h" +#include "SortFilterProxyModel.h" #include #include @@ -29,8 +29,8 @@ using namespace dev::mix; SortFilterProxyModel::SortFilterProxyModel(QObject* _parent) : QSortFilterProxyModel(_parent) { - connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged())); - connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged())); + connect(this, &SortFilterProxyModel::rowsInserted, this, &SortFilterProxyModel::countChanged); + connect(this, &SortFilterProxyModel::rowsRemoved, this, &SortFilterProxyModel::countChanged); } int SortFilterProxyModel::count() const @@ -45,7 +45,7 @@ QObject* SortFilterProxyModel::source() const void SortFilterProxyModel::setSource(QObject* _source) { - setSourceModel(qobject_cast(_source)); + setSourceModel(qobject_cast(_source)); } QByteArray SortFilterProxyModel::sortRole() const @@ -87,10 +87,12 @@ QJSValue SortFilterProxyModel::get(int _idx) const { QJSEngine *engine = qmlEngine(this); QJSValue value = engine->newObject(); - if (_idx >= 0 && _idx < count()) { + if (_idx >= 0 && _idx < count()) + { QHash roles = roleNames(); QHashIterator it(roles); - while (it.hasNext()) { + while (it.hasNext()) + { it.next(); value.setProperty(QString::fromUtf8(it.value()), data(index(_idx, 0), it.key()).toString()); } @@ -102,7 +104,8 @@ int SortFilterProxyModel::roleKey(QByteArray const& _role) const { QHash roles = roleNames(); QHashIterator it(roles); - while (it.hasNext()) { + while (it.hasNext()) + { it.next(); if (it.value() == _role) return it.key(); @@ -119,12 +122,10 @@ QHash SortFilterProxyModel::roleNames() const bool SortFilterProxyModel::filterAcceptsRow(int _sourceRow, QModelIndex const& _sourceParent) const { - - QRegExp rx = filterRegExp(); - QAbstractItemModel *model = sourceModel(); + QAbstractItemModel* model = sourceModel(); QModelIndex sourceIndex = model->index(_sourceRow, 0, _sourceParent); - if (!sourceIndex.isValid()) - return true; + if (!sourceIndex.isValid()) + return true; QString keyType = model->data(sourceIndex, roleKey(type.toUtf8())).toString(); QString keyContent = model->data(sourceIndex, roleKey(content.toUtf8())).toString(); diff --git a/mix/Sortfilterproxymodel.h b/mix/SortFilterProxyModel.h similarity index 100% rename from mix/Sortfilterproxymodel.h rename to mix/SortFilterProxyModel.h