logic: Moved all error handling logic into ErrorController (issue #577)
* Handle all error related messages in ErrorController * Moved error filter state from Storage to ErrorController * Moved all error related messages to type/error subdirectory * Enable all errors shown by default * Always show unfiltered error count in status bar and overview * Fixed all errors shown again when changing error filter on errors for file
This commit is contained in:
@@ -17,11 +17,11 @@
|
||||
#include "qt/utility/QtContextMenu.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "utility/messaging/type/error/MessageShowError.h"
|
||||
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageMoveIDECursor.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/TextCodec.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityApp.h"
|
||||
@@ -715,7 +715,7 @@ void QtCodeArea::activateErrors(const std::vector<const Annotation*>& annotation
|
||||
|
||||
if (errorIds.size() == 1)
|
||||
{
|
||||
MessageShowErrors(errorIds[0]).dispatch();
|
||||
MessageShowError(errorIds[0]).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <QVariant>
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/messaging/type/MessageShowErrorsForFile.h"
|
||||
#include "utility/messaging/type/error/MessageErrorsForFile.h"
|
||||
|
||||
QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool isSingle)
|
||||
: QtHoverButton(parent)
|
||||
@@ -44,7 +44,7 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool is
|
||||
|
||||
m_showErrorsButton = new QPushButton("show errors");
|
||||
m_showErrorsButton->setObjectName("screen_button");
|
||||
m_showErrorsButton->setToolTip("Show all errors related to this file");
|
||||
m_showErrorsButton->setToolTip("Show all errors causing this file to be incomplete");
|
||||
m_showErrorsButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_showErrorsButton->hide();
|
||||
titleLayout->addWidget(m_showErrorsButton);
|
||||
@@ -52,7 +52,7 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool is
|
||||
connect(m_showErrorsButton, &QPushButton::clicked,
|
||||
[this]()
|
||||
{
|
||||
MessageShowErrorsForFile(m_titleButton->getFilePath()).dispatch();
|
||||
MessageErrorsForFile(m_titleButton->getFilePath()).dispatch();
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/error/MessageShowError.h"
|
||||
#include "utility/messaging/type/MessageScrollCode.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "data/location/SourceLocation.h"
|
||||
@@ -918,7 +918,7 @@ void QtCodeNavigator::handleMessage(MessageShowReference* message)
|
||||
|
||||
if (ref.locationType == LOCATION_ERROR)
|
||||
{
|
||||
MessageShowErrors(ref.tokenId).dispatch();
|
||||
MessageShowError(ref.tokenId).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -424,25 +424,8 @@ void QtDialogView::handleMessage(MessageInterruptTasks* message)
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::handleMessage(MessageNewErrors* message)
|
||||
void QtDialogView::handleMessage(MessageErrorCountUpdate* message)
|
||||
{
|
||||
ErrorCountInfo errorInfo = m_storageAccess->getErrorCount();
|
||||
|
||||
m_onQtThread3(
|
||||
[=]()
|
||||
{
|
||||
updateErrorCount(errorInfo.total, errorInfo.fatal);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (message->isReplayed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorCountInfo errorInfo = message->errorCount;
|
||||
|
||||
m_onQtThread3(
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
#include "qt/window/QtWindowStack.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/error/MessageErrorCountUpdate.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/messaging/type/MessageNewErrors.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/messaging/type/MessageWindowClosed.h"
|
||||
|
||||
class QtMainWindow;
|
||||
@@ -18,9 +17,8 @@ class QtWindow;
|
||||
class QtDialogView
|
||||
: public QObject
|
||||
, public DialogView
|
||||
, public MessageListener<MessageErrorCountUpdate>
|
||||
, public MessageListener<MessageInterruptTasks>
|
||||
, public MessageListener<MessageNewErrors>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
, public MessageListener<MessageWindowClosed>
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -57,9 +55,8 @@ private slots:
|
||||
void setUIBlocked(bool blocked);
|
||||
|
||||
private:
|
||||
void handleMessage(MessageErrorCountUpdate* message) override;
|
||||
void handleMessage(MessageInterruptTasks* message) override;
|
||||
void handleMessage(MessageNewErrors* message) override;
|
||||
void handleMessage(MessageShowErrors* message) override;
|
||||
void handleMessage(MessageWindowClosed* message) override;
|
||||
|
||||
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "utility/messaging/type/MessageErrorFilterChanged.h"
|
||||
#include "utility/messaging/type/MessageProjectEdit.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QIcon QtErrorView::s_errorIcon;
|
||||
@@ -56,6 +54,7 @@ QWidget* SelectableDelegate::createEditor(
|
||||
|
||||
QtErrorView::QtErrorView(ViewLayout* viewLayout)
|
||||
: ErrorView(viewLayout)
|
||||
, m_controllerProxy(this)
|
||||
, m_ignoreRowSelection(false)
|
||||
{
|
||||
s_errorIcon = QIcon(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/error.png").wstr()));
|
||||
@@ -107,7 +106,9 @@ void QtErrorView::initView()
|
||||
return;
|
||||
}
|
||||
|
||||
MessageShowErrors(m_model->item(index.row(), COLUMN::ID)->text().toUInt()).dispatch();
|
||||
Id errorId = m_model->item(index.row(), COLUMN::ID)->text().toUInt();
|
||||
|
||||
m_controllerProxy.executeAsTaskWithArgs(&ErrorController::showError, errorId);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -153,11 +154,9 @@ void QtErrorView::initView()
|
||||
m_allLabel = new QLabel("");
|
||||
checkboxes->addWidget(m_allLabel);
|
||||
m_allLabel->hide();
|
||||
}
|
||||
|
||||
checkboxes->addSpacing(5);
|
||||
checkboxes->addSpacing(5);
|
||||
|
||||
{
|
||||
m_allButton = new QPushButton("");
|
||||
m_allButton->setObjectName("screen_button");
|
||||
connect(m_allButton, &QPushButton::clicked,
|
||||
@@ -169,6 +168,9 @@ void QtErrorView::initView()
|
||||
);
|
||||
checkboxes->addWidget(m_allButton);
|
||||
m_allButton->hide();
|
||||
|
||||
m_errorLabel = new QLabel("");
|
||||
checkboxes->addWidget(m_errorLabel);
|
||||
}
|
||||
|
||||
checkboxes->addSpacing(10);
|
||||
@@ -215,10 +217,14 @@ void QtErrorView::clear()
|
||||
}
|
||||
|
||||
m_table->updateRows();
|
||||
|
||||
m_allLabel->setVisible(false);
|
||||
m_allButton->setVisible(false);
|
||||
m_errorLabel->setVisible(false);
|
||||
});
|
||||
}
|
||||
|
||||
void QtErrorView::addErrors(const std::vector<ErrorInfo>& errors, bool scrollTo)
|
||||
void QtErrorView::addErrors(const std::vector<ErrorInfo>& errors, const ErrorCountInfo& errorCount, bool scrollTo)
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
@@ -236,6 +242,20 @@ void QtErrorView::addErrors(const std::vector<ErrorInfo>& errors, bool scrollTo)
|
||||
{
|
||||
m_table->showFirstRow();
|
||||
}
|
||||
|
||||
bool limited = m_errorFilter.limit > 0 && errorCount.total > m_errorFilter.limit;
|
||||
|
||||
m_allLabel->setVisible(limited);
|
||||
m_allLabel->setText("<b>Only displaying first " + QString::number(m_errorFilter.limit) + " errors</b>");
|
||||
|
||||
m_allButton->setVisible(limited);
|
||||
m_allButton->setText("Show all " + QString::number(errorCount.total));
|
||||
|
||||
m_errorLabel->setVisible(!limited);
|
||||
m_errorLabel->setText("<b>displaying " +
|
||||
QString::number(errorCount.total) + " error" + (errorCount.total != 1 ? "s" : "") +
|
||||
(errorCount.fatal > 0 ? " (" + QString::number(errorCount.fatal) + " fatal)" : "") + "</b>"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -254,26 +274,6 @@ void QtErrorView::setErrorId(Id 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(0, false);
|
||||
}
|
||||
|
||||
void QtErrorView::showErrorHelpMessage()
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
@@ -282,12 +282,40 @@ void QtErrorView::showErrorHelpMessage()
|
||||
});
|
||||
}
|
||||
|
||||
void QtErrorView::errorFilterChanged(int i)
|
||||
ErrorFilter QtErrorView::getErrorFilter() const
|
||||
{
|
||||
errorFilterChanged(i, true);
|
||||
return m_errorFilter;
|
||||
}
|
||||
|
||||
void QtErrorView::errorFilterChanged(int i, bool showErrors)
|
||||
void QtErrorView::setErrorFilter(const ErrorFilter& filter)
|
||||
{
|
||||
if (m_errorFilter == filter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_errorFilter = filter;
|
||||
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_showErrors->blockSignals(true);
|
||||
m_showFatals->blockSignals(true);
|
||||
m_showNonIndexedErrors->blockSignals(true);
|
||||
m_showNonIndexedFatals->blockSignals(true);
|
||||
|
||||
m_showErrors->setChecked(m_errorFilter.error);
|
||||
m_showFatals->setChecked(m_errorFilter.fatal);
|
||||
m_showNonIndexedErrors->setChecked(m_errorFilter.unindexedError);
|
||||
m_showNonIndexedFatals->setChecked(m_errorFilter.unindexedFatal);
|
||||
|
||||
m_showErrors->blockSignals(false);
|
||||
m_showFatals->blockSignals(false);
|
||||
m_showNonIndexedErrors->blockSignals(false);
|
||||
m_showNonIndexedFatals->blockSignals(false);
|
||||
});
|
||||
}
|
||||
|
||||
void QtErrorView::errorFilterChanged(int i)
|
||||
{
|
||||
m_table->selectionModel()->clearSelection();
|
||||
|
||||
@@ -296,7 +324,7 @@ void QtErrorView::errorFilterChanged(int i, bool showErrors)
|
||||
m_errorFilter.unindexedError = m_showNonIndexedErrors->isChecked();
|
||||
m_errorFilter.unindexedFatal = m_showNonIndexedFatals->isChecked();
|
||||
|
||||
MessageErrorFilterChanged(m_errorFilter, showErrors).dispatch();
|
||||
m_controllerProxy.executeAsTaskWithArgs(&ErrorController::errorFilterChanged, m_errorFilter);
|
||||
}
|
||||
|
||||
void QtErrorView::setStyleSheet() const
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "component/controller/ErrorController.h"
|
||||
#include "component/controller/helper/ControllerProxy.h"
|
||||
#include "component/view/ErrorView.h"
|
||||
#include "data/ErrorFilter.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
@@ -33,17 +35,17 @@ public:
|
||||
|
||||
// ErrorView implementation
|
||||
virtual void clear();
|
||||
virtual void addErrors(const std::vector<ErrorInfo>& errors, bool scrollTo);
|
||||
virtual void setErrorId(Id errorId);
|
||||
|
||||
virtual void setErrorCount(ErrorCountInfo info);
|
||||
virtual void resetErrorLimit();
|
||||
virtual void addErrors(const std::vector<ErrorInfo>& errors, const ErrorCountInfo& errorCount, bool scrollTo);
|
||||
virtual void setErrorId(Id errorId);
|
||||
|
||||
virtual void showErrorHelpMessage();
|
||||
|
||||
virtual ErrorFilter getErrorFilter() const;
|
||||
virtual void setErrorFilter(const ErrorFilter& filter);
|
||||
|
||||
private slots:
|
||||
void errorFilterChanged(int i = 0);
|
||||
void errorFilterChanged(int i, bool showErrors);
|
||||
|
||||
private:
|
||||
enum COLUMN {
|
||||
@@ -65,10 +67,12 @@ private:
|
||||
|
||||
static QIcon s_errorIcon;
|
||||
|
||||
ControllerProxy<ErrorController> m_controllerProxy;
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
ErrorFilter m_errorFilter;
|
||||
|
||||
QLabel* m_errorLabel;
|
||||
QLabel* m_allLabel;
|
||||
QPushButton* m_allButton;
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/element/QtHelpButton.h"
|
||||
#include "qt/element/QtProgressBar.h"
|
||||
#include "utility/messaging/type/error/MessageErrorsHelpMessage.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/messaging/type/MessageShowErrorHelpMessage.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
@@ -359,7 +359,7 @@ void QtIndexingDialog::handleNext()
|
||||
|
||||
if (m_type == DIALOG_REPORT)
|
||||
{
|
||||
MessageShowErrorHelpMessage().dispatch();
|
||||
MessageErrorsHelpMessage().dispatch();
|
||||
}
|
||||
|
||||
QtWindow::handleNext();
|
||||
@@ -486,7 +486,7 @@ void QtIndexingDialog::addErrorWidget(QBoxLayout* layout)
|
||||
connect(helpButton, &QtHelpButton::clicked,
|
||||
[]()
|
||||
{
|
||||
MessageShowErrorHelpMessage(true).dispatch();
|
||||
MessageErrorsHelpMessage(true).dispatch();
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/error/MessageErrorsHelpMessage.h"
|
||||
#include "utility/messaging/type/MessageActivateBookmark.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarkCreator.h"
|
||||
@@ -40,7 +41,6 @@
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageResetZoom.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageShowErrorHelpMessage.h"
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
#include "utility/messaging/type/MessageWindowClosed.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
@@ -455,7 +455,7 @@ void QtMainWindow::showKeyboardShortcuts()
|
||||
|
||||
void QtMainWindow::showErrorHelpMessage()
|
||||
{
|
||||
MessageShowErrorHelpMessage(true).dispatch();
|
||||
MessageErrorsHelpMessage(true).dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::showBugtracker()
|
||||
|
||||
Reference in New Issue
Block a user