Commit e2dcdae8 authored by Alessandro Portale's avatar Alessandro Portale

ScxmlEditor: Inline the ErrorWidget ui creation

Change-Id: I39e1890673aa38ec1671d3cf57aad04a28e886a6
Reviewed-by: Alessandro Portale's avatarAlessandro Portale <alessandro.portale@qt.io>
parent a500af07
......@@ -637,8 +637,8 @@ void MainWidget::createUi()
m_stateProperties = new StateProperties;
m_structure = new Structure;
auto verticalSplitter = new Core::MiniSplitter(Qt::Vertical);
verticalSplitter->addWidget(m_stateProperties);
verticalSplitter->addWidget(m_structure);
verticalSplitter->addWidget(m_stateProperties);
m_horizontalSplitter = new Core::MiniSplitter(Qt::Horizontal);
m_horizontalSplitter->addWidget(m_shapesFrame);
......
......@@ -24,13 +24,18 @@
****************************************************************************/
#include "errorwidget.h"
#include "tableview.h"
#include "scxmleditorconstants.h"
#include <QLayout>
#include <QFile>
#include <QFileDialog>
#include <QHeaderView>
#include <QMessageBox>
#include <QSortFilterProxyModel>
#include <QTextStream>
#include <QToolBar>
#include <QToolButton>
#include <coreplugin/icore.h>
#include <utils/utilsicons.h>
......@@ -42,62 +47,55 @@ ErrorWidget::ErrorWidget(QWidget *parent)
, m_warningModel(new WarningModel(this))
, m_proxyModel(new QSortFilterProxyModel(this))
{
m_ui.setupUi(this);
m_ui.m_clean->setIcon(Utils::Icons::CLEAN.icon());
m_ui.m_exportWarnings->setIcon(Utils::Icons::SAVEFILE.icon());
m_ui.m_showErrors->setIcon(Utils::Icons::ERROR.icon());
m_ui.m_showWarnings->setIcon(Utils::Icons::WARNING.icon());
m_ui.m_showInfos->setIcon(Utils::Icons::INFO.icon());
createUi();
m_proxyModel->setFilterRole(WarningModel::FilterRole);
m_proxyModel->setSourceModel(m_warningModel);
m_proxyModel->setFilterFixedString(Constants::C_WARNINGMODEL_FILTER_ACTIVE);
m_ui.m_errorsTable->setModel(m_proxyModel);
m_ui.m_errorsTable->horizontalHeader()->setSectionsMovable(true);
m_errorsTable->setModel(m_proxyModel);
connect(m_ui.m_errorsTable, &TableView::entered, [this](const QModelIndex &ind) {
connect(m_errorsTable, &TableView::entered, [this](const QModelIndex &ind) {
if (ind.isValid())
emit warningEntered(m_warningModel->getWarning(m_proxyModel->mapToSource(ind)));
});
connect(m_ui.m_errorsTable, &TableView::pressed, [this](const QModelIndex &ind) {
connect(m_errorsTable, &TableView::pressed, [this](const QModelIndex &ind) {
if (ind.isValid())
emit warningSelected(m_warningModel->getWarning(m_proxyModel->mapToSource(ind)));
});
connect(m_ui.m_errorsTable, &TableView::doubleClicked, [this](const QModelIndex &ind) {
connect(m_errorsTable, &TableView::doubleClicked, [this](const QModelIndex &ind) {
if (ind.isValid())
emit warningDoubleClicked(m_warningModel->getWarning(m_proxyModel->mapToSource(ind)));
});
connect(m_ui.m_errorsTable, &TableView::mouseExited, this, [this](){
connect(m_errorsTable, &TableView::mouseExited, this, [this](){
emit mouseExited();
});
connect(m_ui.m_showErrors, &QToolButton::toggled, [this](bool show) {
connect(m_showErrors, &QToolButton::toggled, [this](bool show) {
m_warningModel->setShowWarnings(Warning::ErrorType, show);
});
connect(m_ui.m_showWarnings, &QToolButton::toggled, [this](bool show) {
connect(m_showWarnings, &QToolButton::toggled, [this](bool show) {
m_warningModel->setShowWarnings(Warning::WarningType, show);
});
connect(m_ui.m_showInfos, &QToolButton::toggled, [this](bool show) {
connect(m_showInfos, &QToolButton::toggled, [this](bool show) {
m_warningModel->setShowWarnings(Warning::InfoType, show);
});
connect(m_ui.m_clean, &QToolButton::clicked, m_warningModel, &WarningModel::clear);
connect(m_ui.m_exportWarnings, &QToolButton::clicked, this, &ErrorWidget::exportWarnings);
connect(m_clean, &QToolButton::clicked, m_warningModel, &WarningModel::clear);
connect(m_exportWarnings, &QToolButton::clicked, this, &ErrorWidget::exportWarnings);
connect(m_warningModel, &WarningModel::warningsChanged, this, &ErrorWidget::updateWarnings);
connect(m_warningModel, &WarningModel::countChanged, this, &ErrorWidget::warningCountChanged);
const QSettings *s = Core::ICore::settings();
m_ui.m_errorsTable->restoreGeometry(s->value(Constants::C_SETTINGS_ERRORPANE_GEOMETRY).toByteArray());
m_ui.m_showErrors->setChecked(s->value(Constants::C_SETTINGS_ERRORPANE_SHOWERRORS, true).toBool());
m_ui.m_showWarnings->setChecked(s->value(Constants::C_SETTINGS_ERRORPANE_SHOWWARNINGS, true).toBool());
m_ui.m_showInfos->setChecked(s->value(Constants::C_SETTINGS_ERRORPANE_SHOWINFOS, true).toBool());
m_errorsTable->restoreGeometry(s->value(Constants::C_SETTINGS_ERRORPANE_GEOMETRY).toByteArray());
m_showErrors->setChecked(s->value(Constants::C_SETTINGS_ERRORPANE_SHOWERRORS, true).toBool());
m_showWarnings->setChecked(s->value(Constants::C_SETTINGS_ERRORPANE_SHOWWARNINGS, true).toBool());
m_showInfos->setChecked(s->value(Constants::C_SETTINGS_ERRORPANE_SHOWINFOS, true).toBool());
updateWarnings();
}
......@@ -105,16 +103,58 @@ ErrorWidget::ErrorWidget(QWidget *parent)
ErrorWidget::~ErrorWidget()
{
QSettings *s = Core::ICore::settings();
s->setValue(Constants::C_SETTINGS_ERRORPANE_GEOMETRY, m_ui.m_errorsTable->saveGeometry());
s->setValue(Constants::C_SETTINGS_ERRORPANE_SHOWERRORS, m_ui.m_showErrors->isChecked());
s->setValue(Constants::C_SETTINGS_ERRORPANE_SHOWWARNINGS, m_ui.m_showWarnings->isChecked());
s->setValue(Constants::C_SETTINGS_ERRORPANE_SHOWINFOS, m_ui.m_showInfos->isChecked());
s->setValue(Constants::C_SETTINGS_ERRORPANE_GEOMETRY, m_errorsTable->saveGeometry());
s->setValue(Constants::C_SETTINGS_ERRORPANE_SHOWERRORS, m_showErrors->isChecked());
s->setValue(Constants::C_SETTINGS_ERRORPANE_SHOWWARNINGS, m_showWarnings->isChecked());
s->setValue(Constants::C_SETTINGS_ERRORPANE_SHOWINFOS, m_showInfos->isChecked());
}
void ErrorWidget::setPaneFocus()
{
}
void ErrorWidget::createUi()
{
m_clean = new QToolButton;
m_clean->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
m_exportWarnings = new QToolButton;
m_exportWarnings->setIcon(Utils::Icons::SAVEFILE_TOOLBAR.icon());
m_showErrors = new QToolButton;
m_showErrors->setIcon(Utils::Icons::ERROR_TOOLBAR.icon());
m_showErrors->setCheckable(true);
m_showWarnings = new QToolButton;
m_showWarnings->setIcon(Utils::Icons::WARNING_TOOLBAR.icon());
m_showWarnings->setCheckable(true);
m_showInfos = new QToolButton;
m_showInfos->setIcon(Utils::Icons::INFO_TOOLBAR.icon());
m_showInfos->setCheckable(true);
auto toolBar = new QToolBar;
toolBar->addWidget(m_clean);
toolBar->addWidget(m_exportWarnings);
toolBar->addWidget(m_showErrors);
toolBar->addWidget(m_showWarnings);
toolBar->addWidget(m_showInfos);
auto stretch = new QWidget;
stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
toolBar->addWidget(stretch);
m_errorsTable = new TableView;
m_errorsTable->horizontalHeader()->setSectionsMovable(true);
m_errorsTable->horizontalHeader()->setStretchLastSection(true);
m_errorsTable->setTextElideMode(Qt::ElideRight);
m_errorsTable->setSortingEnabled(true);
m_errorsTable->setAlternatingRowColors(true);
m_errorsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
m_errorsTable->setFrameShape(QFrame::NoFrame);
setLayout(new QVBoxLayout);
layout()->addWidget(toolBar);
layout()->addWidget(m_errorsTable);
layout()->setMargin(0);
layout()->setSpacing(0);
}
void ErrorWidget::updateWarnings()
{
int errorCount = m_warningModel->count(Warning::ErrorType);
......@@ -123,11 +163,11 @@ void ErrorWidget::updateWarnings()
m_title = tr("Errors(%1) / Warnings(%2) / Info(%3)").arg(errorCount).arg(warningCount).arg(infoCount);
if (errorCount > 0)
m_icon = m_ui.m_showInfos->icon();
m_icon = m_showInfos->icon();
else if (warningCount > 0)
m_icon = m_ui.m_showWarnings->icon();
m_icon = m_showWarnings->icon();
else if (infoCount > 0)
m_icon = m_ui.m_showErrors->icon();
m_icon = m_showErrors->icon();
else
m_icon = QIcon();
......@@ -179,13 +219,13 @@ void ErrorWidget::exportWarnings()
// Headerdata
QStringList values;
for (int c = 0; c < m_proxyModel->columnCount(); ++c)
values << modifyExportedValue(m_proxyModel->headerData(m_ui.m_errorsTable->horizontalHeader()->visualIndex(c), Qt::Horizontal, Qt::DisplayRole).toString());
values << modifyExportedValue(m_proxyModel->headerData(m_errorsTable->horizontalHeader()->visualIndex(c), Qt::Horizontal, Qt::DisplayRole).toString());
out << values.join(",") << "\n";
for (int r = 0; r < m_proxyModel->rowCount(); ++r) {
values.clear();
for (int c = 0; c < m_proxyModel->columnCount(); ++c)
values << modifyExportedValue(m_proxyModel->data(m_proxyModel->index(r, m_ui.m_errorsTable->horizontalHeader()->visualIndex(c)), Qt::DisplayRole).toString());
values << modifyExportedValue(m_proxyModel->data(m_proxyModel->index(r, m_errorsTable->horizontalHeader()->visualIndex(c)), Qt::DisplayRole).toString());
out << values.join(",") << "\n";
}
}
......@@ -26,15 +26,17 @@
#pragma once
#include "outputpane.h"
#include "ui_errorwidget.h"
#include "warningmodel.h"
QT_FORWARD_DECLARE_CLASS(QToolButton)
QT_FORWARD_DECLARE_CLASS(QSortFilterProxyModel)
namespace ScxmlEditor {
namespace OutputPane {
class TableView;
class ErrorWidget : public OutputPane
{
Q_OBJECT
......@@ -68,6 +70,7 @@ signals:
void warningDoubleClicked(Warning *w);
private:
void createUi();
void updateWarnings();
void exportWarnings();
void warningCountChanged(int c);
......@@ -77,7 +80,13 @@ private:
QString m_title;
WarningModel *m_warningModel;
QSortFilterProxyModel *m_proxyModel;
Ui::ErrorWidget m_ui;
TableView *m_errorsTable = nullptr;
QToolButton *m_clean = nullptr;
QToolButton *m_exportWarnings = nullptr;
QToolButton *m_showErrors = nullptr;
QToolButton *m_showWarnings = nullptr;
QToolButton *m_showInfos = nullptr;
};
} // namespace OutputPane
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScxmlEditor::OutputPane::ErrorWidget</class>
<widget class="QWidget" name="ScxmlEditor::OutputPane::ErrorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>857</width>
<height>326</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="m_subTitleFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="m_clean"/>
</item>
<item>
<widget class="QToolButton" name="m_exportWarnings"/>
</item>
<item>
<widget class="QToolButton" name="m_showErrors">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_showWarnings">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_showInfos">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>646</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="ScxmlEditor::OutputPane::TableView" name="m_errorsTable">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="textElideMode">
<enum>Qt::ElideRight</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ScxmlEditor::OutputPane::TableView</class>
<extends>QTableView</extends>
<header>tableview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -16,5 +16,4 @@ SOURCES += \
$$PWD/warning.cpp
FORMS += \
$$PWD/errorwidget.ui \
$$PWD/outputtabwidget.ui
......@@ -97,7 +97,6 @@ QtcPlugin {
"warning.cpp", "warning.h",
"warningmodel.cpp", "warningmodel.h",
"errorwidget.ui",
"outputtabwidget.ui",
]
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment