ui: Show error in errors table when clicked in code view

bug id = 323
This commit is contained in:
Eberhard Graether
2017-01-27 14:04:55 +01:00
parent 7ee9624217
commit b659b2ac34
3 changed files with 31 additions and 8 deletions
@@ -33,10 +33,7 @@ void ErrorController::handleMessage(MessageShowErrors* message)
{ {
if (message->errorId) if (message->errorId)
{ {
if (message->isReplayed()) getView()->setErrorId(message->errorId);
{
getView()->setErrorId(message->errorId);
}
return; return;
} }
+29 -4
View File
@@ -17,6 +17,7 @@
#include "utility/messaging/type/MessageFocusIn.h" #include "utility/messaging/type/MessageFocusIn.h"
#include "utility/messaging/type/MessageFocusOut.h" #include "utility/messaging/type/MessageFocusOut.h"
#include "utility/messaging/type/MessageMoveIDECursor.h" #include "utility/messaging/type/MessageMoveIDECursor.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/utility.h" #include "utility/utility.h"
#include "data/location/TokenLocation.h" #include "data/location/TokenLocation.h"
@@ -500,8 +501,15 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
QTextCursor cursor = this->cursorForPosition(event->pos()); QTextCursor cursor = this->cursorForPosition(event->pos());
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(cursor.position()); std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(cursor.position());
activateTokenLocations(annotations); if (m_navigator->hasErrors())
activateLocalSymbols(annotations); {
activateErrors(annotations);
}
else
{
activateTokenLocations(annotations);
activateLocalSymbols(annotations);
}
} }
} }
} }
@@ -551,7 +559,7 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
setHoveredAnnotations(annotations); setHoveredAnnotations(annotations);
if (annotations.size() == 1) if (m_navigator->hasErrors() && annotations.size() == 1)
{ {
std::string errorMessage = m_navigator->getErrorMessageForId(annotations[0]->tokenId); std::string errorMessage = m_navigator->getErrorMessageForId(annotations[0]->tokenId);
QToolTip::showText(event->globalPos(), QString::fromStdString(errorMessage)); QToolTip::showText(event->globalPos(), QString::fromStdString(errorMessage));
@@ -702,12 +710,29 @@ void QtCodeArea::activateLocalSymbols(const std::vector<const Annotation*>& anno
} }
} }
if (!allActive || !localSymbolIds.size()) if (!allActive || localSymbolIds.size())
{ {
MessageActivateLocalSymbols(localSymbolIds).dispatch(); MessageActivateLocalSymbols(localSymbolIds).dispatch();
} }
} }
void QtCodeArea::activateErrors(const std::vector<const Annotation*>& annotations)
{
std::vector<Id> errorIds;
for (const Annotation* annotation : annotations)
{
if (annotation->locationType == LOCATION_ERROR && annotation->tokenId > 0)
{
errorIds.push_back(annotation->tokenId);
}
}
if (errorIds.size() == 1)
{
MessageShowErrors(errorIds[0]).dispatch();
}
}
void QtCodeArea::createAnnotations(std::shared_ptr<TokenLocationFile> locationFile) void QtCodeArea::createAnnotations(std::shared_ptr<TokenLocationFile> locationFile)
{ {
locationFile->forEachStartTokenLocation( locationFile->forEachStartTokenLocation(
+1
View File
@@ -145,6 +145,7 @@ private:
std::vector<const Annotation*> getInteractiveAnnotationsForPosition(int pos) const; std::vector<const Annotation*> getInteractiveAnnotationsForPosition(int pos) const;
void activateTokenLocations(const std::vector<const Annotation*>& annotations); void activateTokenLocations(const std::vector<const Annotation*>& annotations);
void activateLocalSymbols(const std::vector<const Annotation*>& annotations); void activateLocalSymbols(const std::vector<const Annotation*>& annotations);
void activateErrors(const std::vector<const Annotation*>& annotations);
void createAnnotations(std::shared_ptr<TokenLocationFile> locationFile); void createAnnotations(std::shared_ptr<TokenLocationFile> locationFile);
void annotateText(); void annotateText();