ui: Improved user experience of error display

* label errors as errors instead of references in file snippet headers
* show number of fatal errors in file snippet headers as well
* only show the first 10 error snippets open, remaining collapsed
* don't show status message after parsing in red on errors
* don't show stats of parsing when project was only loaded
This commit is contained in:
Eberhard Graether
2016-04-13 12:14:55 +02:00
parent 4eef42d15c
commit fcc39f4a77
21 changed files with 159 additions and 53 deletions
+2 -2
View File
@@ -423,7 +423,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
m_eventPosition = event->pos();
setIDECursorPosition();
}
else if (!m_fileWidget->getErrorMessages().size())
else if (!m_fileWidget->hasErrors())
{
QTextCursor cursor = this->cursorForPosition(event->pos());
std::vector<const Annotation*> annotations = getNonScopeAnnotationsForPosition(cursor.position());
@@ -471,7 +471,7 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
setHoveredAnnotations(annotations);
const std::vector<std::string>& errorMessages = m_fileWidget->getErrorMessages();
std::vector<std::string> errorMessages = m_fileWidget->getErrorMessages();
if (annotations.size() == 1 && errorMessages.size() > annotations[0]->tokenId)
{
QToolTip::showText(event->globalPos(), QString::fromStdString(errorMessages[annotations[0]->tokenId]));
+15 -3
View File
@@ -139,14 +139,14 @@ const std::vector<Id>& QtCodeFile::getFocusedTokenIds() const
return m_parent->getFocusedTokenIds();
}
const std::vector<std::string>& QtCodeFile::getErrorMessages() const
std::vector<std::string> QtCodeFile::getErrorMessages() const
{
return m_parent->getErrorMessages();
}
bool QtCodeFile::hasErrors() const
{
return getErrorMessages().size() > 0;
return m_parent->hasErrors();;
}
void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
@@ -472,7 +472,19 @@ void QtCodeFile::updateRefCount(int refCount)
{
if (refCount > 0)
{
m_referenceCount->setText(QString::fromStdString(std::to_string(refCount) + (refCount == 1 ? " reference" : " references")));
QString label = hasErrors() ? "error" : "reference";
if (refCount > 1)
{
label += "s";
}
size_t fatalErrorCount = m_parent->getFatalErrorCountForFile(m_filePath);
if (fatalErrorCount > 0)
{
label += " (" + QString::number(fatalErrorCount) + " fatal)";
}
m_referenceCount->setText(QString::number(refCount) + " " + label);
m_referenceCount->show();
}
else
+2 -1
View File
@@ -14,6 +14,7 @@
#include "utility/messaging/type/MessageWindowFocus.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "data/ErrorInfo.h"
#include "component/view/helper/CodeSnippetParams.h"
class QLabel;
@@ -42,7 +43,7 @@ public:
const std::vector<Id>& getActiveLocalSymbolIds() const;
const std::vector<Id>& getFocusedTokenIds() const;
const std::vector<std::string>& getErrorMessages() const;
std::vector<std::string> getErrorMessages() const;
bool hasErrors() const;
void addCodeSnippet(const CodeSnippetParams& params);
+27 -4
View File
@@ -108,14 +108,37 @@ void QtCodeFileList::setFocusedTokenIds(const std::vector<Id>& focusedTokenIds)
m_focusedTokenIds = focusedTokenIds;
}
const std::vector<std::string>& QtCodeFileList::getErrorMessages() const
std::vector<std::string> QtCodeFileList::getErrorMessages() const
{
return m_errorMessages;
std::vector<std::string> errorMessages;
for (const ErrorInfo& error : m_errorInfos)
{
errorMessages.push_back(error.message);
}
return errorMessages;
}
void QtCodeFileList::setErrorMessages(const std::vector<std::string>& errorMessages)
void QtCodeFileList::setErrorInfos(const std::vector<ErrorInfo>& errorInfos)
{
m_errorMessages = errorMessages;
m_errorInfos = errorInfos;
}
bool QtCodeFileList::hasErrors() const
{
return m_errorInfos.size() > 0;
}
size_t QtCodeFileList::getFatalErrorCountForFile(const FilePath& filePath) const
{
size_t fatalErrorCount = 0;
for (const ErrorInfo& error : m_errorInfos)
{
if (error.filePath == filePath && error.isFatal)
{
fatalErrorCount++;
}
}
return fatalErrorCount;
}
void QtCodeFileList::showActiveTokenIds()
+7 -3
View File
@@ -11,6 +11,7 @@
#include "utility/TimePoint.h"
#include "utility/types.h"
#include "data/ErrorInfo.h"
#include "component/view/helper/CodeSnippetParams.h"
class QtCodeFile;
@@ -45,8 +46,11 @@ public:
const std::vector<Id>& getFocusedTokenIds() const;
void setFocusedTokenIds(const std::vector<Id>& focusedTokenIds);
const std::vector<std::string>& getErrorMessages() const;
void setErrorMessages(const std::vector<std::string>& errorMessages);
std::vector<std::string> getErrorMessages() const;
void setErrorInfos(const std::vector<ErrorInfo>& errorInfos);
bool hasErrors() const;
size_t getFatalErrorCountForFile(const FilePath& filePath) const;
void showActiveTokenIds();
@@ -82,7 +86,7 @@ private:
std::vector<Id> m_activeTokenIds;
std::vector<Id> m_activeLocalSymbolIds;
std::vector<Id> m_focusedTokenIds;
std::vector<std::string> m_errorMessages;
std::vector<ErrorInfo> m_errorInfos;
QtCodeFile* m_scrollToFile;
int m_value;
+2 -2
View File
@@ -69,8 +69,8 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount)
if (errorCount.total > 0)
{
m_errorButton.setText(
QString::number(errorCount.total) + " error" + (errorCount.total > 1 ? "s" : "") +
(errorCount.fatal > 0 ? "(" + QString::number(errorCount.fatal) + " fatal)" : ""));
QString::number(errorCount.total) + " error" + (errorCount.total > 1 ? "s" : "") +
(errorCount.fatal > 0 ? " (" + QString::number(errorCount.fatal) + " fatal)" : ""));
m_errorButton.show();
}
else
+3 -3
View File
@@ -57,9 +57,9 @@ void QtCodeView::setActiveTokenIds(const std::vector<Id>& activeTokenIds)
m_activeTokenIds = activeTokenIds;
}
void QtCodeView::setErrorMessages(const std::vector<std::string>& errorMessages)
void QtCodeView::setErrorInfos(const std::vector<ErrorInfo>& errorInfos)
{
m_errorMessages = errorMessages;
m_errorInfos = errorInfos;
}
void QtCodeView::showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds)
@@ -134,7 +134,7 @@ void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippe
m_widget->clearCodeSnippets();
m_widget->setActiveTokenIds(activeTokenIds);
m_widget->setErrorMessages(m_errorMessages);
m_widget->setErrorInfos(m_errorInfos);
for (const CodeSnippetParams& params : snippets)
{
+2 -2
View File
@@ -29,7 +29,7 @@ public:
virtual void clear();
virtual void setActiveTokenIds(const std::vector<Id>& activeTokenIds);
virtual void setErrorMessages(const std::vector<std::string>& errorMessages);
virtual void setErrorInfos(const std::vector<ErrorInfo>& errorInfos);
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds);
virtual void addCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert);
@@ -88,7 +88,7 @@ private:
QtCodeFileList* m_widget;
std::vector<Id> m_activeTokenIds;
std::vector<std::string> m_errorMessages;
std::vector<ErrorInfo> m_errorInfos;
};
# endif // QT_CODE_VIEW_H