logic: error limit and better user experience (issue #385)

* only show up to 1000 errors in table and code view
* click button in bottom right of error table to show all
* same error order in code and table
* highlight error line when switching reference in code view
* improved error view performance

bug id = 385
This commit is contained in:
Eberhard Graether
2017-05-30 23:11:20 +02:00
parent a34abe6b4b
commit 29cfbe0f66
20 changed files with 204 additions and 75 deletions
@@ -10,6 +10,7 @@
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageCodeViewExpandedInitialFiles.h"
#include "utility/messaging/type/MessageScrollCode.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/ResourcePaths.h"
#include "data/location/SourceLocation.h"
@@ -860,6 +861,11 @@ void QtCodeNavigator::handleMessage(MessageShowReference* message)
requestScroll(ref.filePath, 0, ref.locationId, message->animated, false);
emit scrollRequest();
if (ref.locationType == LOCATION_ERROR)
{
MessageShowErrors(ref.tokenId).dispatch();
}
}
updateRefLabel();
+11 -14
View File
@@ -80,31 +80,23 @@ void QtTable::updateRows()
verticalHeader()->setStyleSheet("::section { width: " + QString::number(width) + "px; }");
verticalHeader()->setDefaultSectionSize(ApplicationSettings::getInstance()->getFontSize() + 6);
if (this->selectionModel()->hasSelection())
if (this->selectionModel()->hasSelection() && selectionModel()->selection().indexes()[0].row() >= model()->rowCount() - 2)
{
if (selectionModel()->selection().indexes()[0].row() >= model()->rowCount() - 2)
{
clearSelection();
showLastRow();
}
}
else
{
showLastRow();
clearSelection();
}
}
int QtTable::getFilledRowCount()
{
for (int i = 0; i < model()->rowCount(); i++)
for (int i = model()->rowCount() - 1; i >= 0; i--)
{
if (model()->index(i, 0).data(Qt::DisplayRole).toString().isEmpty())
if (!model()->index(i, 0).data(Qt::DisplayRole).toString().isEmpty())
{
return i;
return i + 1;
}
}
return model()->rowCount();
return 0;
}
void QtTable::showFirstRow()
@@ -120,6 +112,11 @@ void QtTable::showLastRow()
}
}
bool QtTable::hasSelection() const
{
return this->selectionModel()->hasSelection();
}
void QtTable::resizeEvent(QResizeEvent* event)
{
QTableView::resizeEvent(event);
+2
View File
@@ -19,6 +19,8 @@ public:
void showFirstRow();
void showLastRow();
bool hasSelection() const;
protected:
virtual void resizeEvent(QResizeEvent* event);
+67 -29
View File
@@ -5,8 +5,10 @@
#include <QFrame>
#include <QHeaderView>
#include <QItemSelectionModel>
#include <QLabel>
#include <QLineEdit>
#include <QPalette>
#include <QPushButton>
#include <QStandardItemModel>
#include <QStandardItem>
#include <QStyledItemDelegate>
@@ -107,13 +109,38 @@ void QtErrorView::initView()
QBoxLayout* checkboxes = new QHBoxLayout();
checkboxes->addSpacing(15);
m_showFatals = createFilterCheckbox("fatals", true, checkboxes);
m_showErrors = createFilterCheckbox("errors", true, checkboxes);
m_showNonIndexedFatals = createFilterCheckbox("fatals in non-indexed files", true, checkboxes);
m_showNonIndexedErrors = createFilterCheckbox("errors in non-indexed files", false, checkboxes);
{
m_showFatals = createFilterCheckbox("fatals", m_errorFilter.fatal, checkboxes);
m_showErrors = createFilterCheckbox("errors", m_errorFilter.error, checkboxes);
m_showNonIndexedFatals = createFilterCheckbox("fatals in non-indexed files", m_errorFilter.unindexedFatal, checkboxes);
m_showNonIndexedErrors = createFilterCheckbox("errors in non-indexed files", m_errorFilter.unindexedError, checkboxes);
}
checkboxes->addStretch();
{
m_allLabel = new QLabel("");
checkboxes->addWidget(m_allLabel);
m_allLabel->hide();
}
checkboxes->addSpacing(5);
{
m_allButton = new QPushButton("");
connect(m_allButton, &QPushButton::clicked,
[=]()
{
m_errorFilter.limit = 0;
errorFilterChanged();
}
);
checkboxes->addWidget(m_allButton);
m_allButton->hide();
}
checkboxes->addSpacing(10);
layout->addLayout(checkboxes);
doRefreshView();
@@ -139,6 +166,39 @@ void QtErrorView::setErrorId(Id errorId)
m_setErrorIdFunctor(errorId);
}
void QtErrorView::setErrorCount(ErrorCountInfo info)
{
m_onQtThread(
[=]()
{
m_allLabel->setVisible(m_errorFilter.limit > 0 && info.total > m_errorFilter.limit);
m_allButton->setVisible(m_errorFilter.limit > 0 && info.total > m_errorFilter.limit);
m_allLabel->setText("<b>Only showing first " + QString::number(m_errorFilter.limit) + " errors</b>");
m_allButton->setText("show all " + QString::number(info.total));
}
);
}
void QtErrorView::resetErrorLimit()
{
ErrorFilter filter;
m_errorFilter.limit = filter.limit;
errorFilterChanged();
}
void QtErrorView::errorFilterChanged(int i)
{
m_table->selectionModel()->clearSelection();
m_errorFilter.error = m_showErrors->isChecked();
m_errorFilter.fatal = m_showFatals->isChecked();
m_errorFilter.unindexedError = m_showNonIndexedErrors->isChecked();
m_errorFilter.unindexedFatal = m_showNonIndexedFatals->isChecked();
MessageErrorFilterChanged(m_errorFilter).dispatch();
}
void QtErrorView::doRefreshView()
{
setStyleSheet();
@@ -151,16 +211,16 @@ void QtErrorView::doClear()
m_model->removeRows(0, m_model->rowCount());
}
m_errors.clear();
m_table->updateRows();
}
void QtErrorView::doAddErrors(const std::vector<ErrorInfo>& errors, bool scrollTo)
{
for (const ErrorInfo& error : errors)
{
m_errors.push_back(error);
addErrorToTable(error);
}
m_table->updateRows();
if (scrollTo)
{
@@ -191,19 +251,12 @@ void QtErrorView::setStyleSheet() const
QPalette palette(m_showErrors->palette());
palette.setColor(QPalette::WindowText, QColor(ColorScheme::getInstance()->getColor("table/text/normal").c_str()));
//palette.setColor(QPalette::Text, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//palette.setColor(QPalette::ButtonText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//m_showErrors->setAutoFillBackground(true);
m_showErrors->setPalette(palette);
m_showFatals->setPalette(palette);
m_showNonIndexedErrors->setPalette(palette);
m_showNonIndexedFatals->setPalette(palette);
//widget->setStyleSheet(
//utility::getStyleSheet(ResourcePaths::getGuiPath() + "error_view/error_view.css").c_str()
//);
m_table->updateRows();
}
@@ -235,8 +288,6 @@ void QtErrorView::addErrorToTable(const ErrorInfo& error)
m_model->setItem(rowNumber, COLUMN::INDEXED, new QStandardItem(error.indexed ? "yes" : "no"));
m_model->setItem(rowNumber, COLUMN::ID, new QStandardItem(QString::number(error.id)));
m_table->updateRows();
}
QCheckBox* QtErrorView::createFilterCheckbox(const QString& name, bool checked, QBoxLayout* layout)
@@ -244,20 +295,7 @@ QCheckBox* QtErrorView::createFilterCheckbox(const QString& name, bool checked,
QCheckBox* checkbox = new QCheckBox(name);
checkbox->setChecked(checked);
connect(checkbox, &QCheckBox::stateChanged,
[=](int)
{
m_table->selectionModel()->clearSelection();
ErrorFilter filter;
filter.error = m_showErrors->isChecked();
filter.fatal = m_showFatals->isChecked();
filter.unindexedError = m_showNonIndexedErrors->isChecked();
filter.unindexedFatal = m_showNonIndexedFatals->isChecked();
MessageErrorFilterChanged(filter).dispatch();
}
);
connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(errorFilterChanged(int)));
layout->addWidget(checkbox);
layout->addSpacing(25);
+16 -4
View File
@@ -4,11 +4,13 @@
#include <QWidget>
#include "component/view/ErrorView.h"
#include "data/ErrorFilter.h"
#include "qt/utility/QtThreadedFunctor.h"
class QBoxLayout;
class QCheckBox;
class QPalette;
class QLabel;
class QPushButton;
class QStandardItemModel;
class QtTable;
@@ -32,6 +34,12 @@ public:
virtual void addErrors(const std::vector<ErrorInfo>& errors, bool scrollTo);
virtual void setErrorId(Id errorId);
virtual void setErrorCount(ErrorCountInfo info);
virtual void resetErrorLimit();
private slots:
void errorFilterChanged(int i = 0);
private:
enum COLUMN {
TYPE = 0,
@@ -61,6 +69,13 @@ private:
QtThreadedFunctor<const std::vector<ErrorInfo>&, bool> m_addErrorsFunctor;
QtThreadedFunctor<Id> m_setErrorIdFunctor;
QtThreadedLambdaFunctor m_onQtThread;
ErrorFilter m_errorFilter;
QLabel* m_allLabel;
QPushButton* m_allButton;
QCheckBox* m_showErrors;
QCheckBox* m_showFatals;
QCheckBox* m_showNonIndexedErrors;
@@ -69,9 +84,6 @@ private:
QStandardItemModel* m_model;
QtTable* m_table;
std::vector<ErrorInfo> m_errors;
QPalette* m_palette;
bool m_ignoreRowSelection;
};
+6 -1
View File
@@ -74,7 +74,7 @@ void QtStatusView::initView()
);
filters->addWidget(clearButton);
filters->addSpacing(15);
filters->addSpacing(10);
layout->addLayout(filters);
@@ -153,6 +153,11 @@ void QtStatusView::doAddStatus(const std::vector<Status>& status)
}
m_table->updateRows();
if (!m_table->hasSelection())
{
m_table->showLastRow();
}
}
void QtStatusView::setStyleSheet() const