src: various fixes

* fixed crash when hovering GraphNode while expanding/collapsing it
* fixed clang warnings
* fixed GraphNodeExpandToggle to show empty circle
* fixed Searchbar showing empty block when nothing was parsed
* made template related edges in GraphView red
This commit is contained in:
Eberhard Graether
2015-05-05 23:12:25 +02:00
parent 0763dc9cdf
commit 7dcf8b0bdb
9 changed files with 65 additions and 77 deletions
+10
View File
@@ -100,6 +100,16 @@ void QtGraphView::switchToNewGraphData()
{ {
m_oldGraph = m_graph; m_oldGraph = m_graph;
for (const std::shared_ptr<QtGraphNode>& node : m_oldNodes)
{
node->hide();
}
for (const std::shared_ptr<QtGraphEdge>& edge : m_oldEdges)
{
edge->hide();
}
m_oldNodes = m_nodes; m_oldNodes = m_nodes;
m_oldEdges = m_edges; m_oldEdges = m_edges;
@@ -1,5 +1,6 @@
#include "qt/view/graphElements/QtGraphNodeExpandToggle.h" #include "qt/view/graphElements/QtGraphNodeExpandToggle.h"
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageGraphNodeExpand.h" #include "utility/messaging/type/MessageGraphNodeExpand.h"
#include "qt/graphics/QtRoundedRectItem.h" #include "qt/graphics/QtRoundedRectItem.h"
@@ -8,31 +9,29 @@
QtGraphNodeExpandToggle::QtGraphNodeExpandToggle(bool expanded, int invisibleSubNodeCount) QtGraphNodeExpandToggle::QtGraphNodeExpandToggle(bool expanded, int invisibleSubNodeCount)
: m_allVisible(invisibleSubNodeCount == 0) : m_allVisible(invisibleSubNodeCount == 0)
{ {
if (!expanded && !invisibleSubNodeCount)
{
LOG_ERROR("ExpandToggle shouldn't be visible");
return;
}
const int iconHeight = 4; const int iconHeight = 4;
m_icon = new QGraphicsPixmapItem(this); m_icon = new QGraphicsPixmapItem(this);
if (!expanded && !invisibleSubNodeCount) QtDeviceScaledPixmap pixmap("data/gui/graph_view/images/arrow.png");
pixmap.scaleToHeight(iconHeight);
if (invisibleSubNodeCount)
{ {
this->hide(); QString numberStr = QString::number(invisibleSubNodeCount);
return; m_text->setText(numberStr);
} }
else else
{ {
QtDeviceScaledPixmap pixmap("data/gui/graph_view/images/arrow.png"); pixmap.mirror();
pixmap.scaleToHeight(iconHeight);
if (invisibleSubNodeCount)
{
QString numberStr = QString::number(invisibleSubNodeCount);
m_text->setText(numberStr);
}
else
{
pixmap.mirror();
}
m_icon->setPixmap(pixmap.pixmap());
} }
m_icon->setPixmap(pixmap.pixmap());
} }
QtGraphNodeExpandToggle::~QtGraphNodeExpandToggle() QtGraphNodeExpandToggle::~QtGraphNodeExpandToggle()
+5 -2
View File
@@ -99,12 +99,15 @@ void Application::handleMessage(MessageFinishedParsing* message)
Id mainId = m_storageAccessProxy->getIdForNodeWithName("main"); Id mainId = m_storageAccessProxy->getIdForNodeWithName("main");
if (!mainId) if (!mainId && m_storageAccessProxy->getNameForNodeWithId(1).size() > 0)
{ {
mainId = 1; mainId = 1;
} }
MessageActivateTokens(mainId).dispatch(); if (mainId)
{
MessageActivateTokens(mainId).dispatch();
}
} }
void Application::handleMessage(MessageLoadProject* message) void Application::handleMessage(MessageLoadProject* message)
@@ -523,7 +523,10 @@ void GraphController::addExpandToggleNode(DummyNode& node) const
} }
} }
node.subNodes.push_back(expandNode); if (expandNode.isExpanded() || expandNode.invisibleSubNodeCount)
{
node.subNodes.push_back(expandNode);
}
} }
void GraphController::layoutToGrid(DummyNode& node) const void GraphController::layoutToGrid(DummyNode& node) const
@@ -13,7 +13,6 @@ SearchController::~SearchController()
{ {
} }
#include <iostream>
void SearchController::handleMessage(MessageActivateTokens* message) void SearchController::handleMessage(MessageActivateTokens* message)
{ {
if (!m_ignoreNextMessageActivateTokens && message->tokenIds.size()) if (!m_ignoreNextMessageActivateTokens && message->tokenIds.size())
+6 -1
View File
@@ -407,7 +407,12 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(Edge::EdgeType typ
case Edge::EDGE_INCLUDE: case Edge::EDGE_INCLUDE:
style.color = "#87BA50"; style.color = "#87BA50";
break; break;
case Edge::EDGE_TEMPLATE_PARAMETER_OF:
case Edge::EDGE_TEMPLATE_ARGUMENT_OF:
case Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT_OF:
case Edge::EDGE_TEMPLATE_SPECIALIZATION_OF:
style.color = "#DD0000";
break;
default: default:
style.color = "#878787"; style.color = "#878787";
break; break;
+8 -17
View File
@@ -547,12 +547,10 @@ Id Storage::onTemplateArgumentTypeParsed(
Node* argumentNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, argumentNameHierarchy); Node* argumentNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, argumentNameHierarchy);
Node* templateNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, templateNameHierarchy); Node* templateNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, templateNameHierarchy);
m_graph.createEdge(Edge::EDGE_TEMPLATE_ARGUMENT_OF, argumentNode, templateNode); Edge* argumentOfEdge = m_graph.createEdge(Edge::EDGE_TEMPLATE_ARGUMENT_OF, argumentNode, templateNode);
if (location.isValid()) addTokenLocation(argumentNode, location);
{ addTokenLocation(argumentOfEdge, location);
addTokenLocation(argumentNode, location);
}
return argumentNode->getId(); return argumentNode->getId();
} }
@@ -1060,14 +1058,9 @@ std::shared_ptr<TokenLocationFile> Storage::getTokenLocationOfParentScope(const
const TokenLocation* parent = child; const TokenLocation* parent = child;
const FilePath filePath = child->getFilePath(); const FilePath filePath = child->getFilePath();
const TokenLocationFile* locationFile = m_locationCollection.findTokenLocationFileByPath(child->getFilePath()); const TokenLocationFile* locationFile = m_locationCollection.findTokenLocationFileByPath(child->getFilePath());
locationFile->forEachTokenLocation( locationFile->forEachStartTokenLocation(
[&](TokenLocation* tokenLocation) -> void [&](TokenLocation* tokenLocation) -> void
{ {
if (tokenLocation->isStartTokenLocation())
{
TokenLocation::LocationType lt = tokenLocation->getType();
int sln = tokenLocation->getLineNumber();
int eln = tokenLocation->getEndTokenLocation()->getLineNumber();
if (tokenLocation->getType() == TokenLocation::LOCATION_SCOPE && if (tokenLocation->getType() == TokenLocation::LOCATION_SCOPE &&
tokenLocation->isStartTokenLocation() && tokenLocation->isStartTokenLocation() &&
(*tokenLocation) < *(child->getStartTokenLocation()) && (*tokenLocation) < *(child->getStartTokenLocation()) &&
@@ -1077,17 +1070,15 @@ std::shared_ptr<TokenLocationFile> Storage::getTokenLocationOfParentScope(const
{ {
parent = tokenLocation; parent = tokenLocation;
} }
else // since tokenLocation is a start location the > location indicates the scope that is closer to the child.
else if ((*tokenLocation) > *parent)
{ {
if ((*tokenLocation) > *parent) // since tokenLocation is a start location the > location indiceates the scope that is closer to the child. parent = tokenLocation;
{
parent = tokenLocation;
}
} }
} }
}
} }
); );
std::shared_ptr<TokenLocationFile> file = std::make_shared<TokenLocationFile>(filePath); std::shared_ptr<TokenLocationFile> file = std::make_shared<TokenLocationFile>(filePath);
if (parent != child) if (parent != child)
{ {
+1 -22
View File
@@ -918,26 +918,5 @@ ParseFunction ASTVisitor::getParseFunction(const clang::FunctionDecl* declaratio
ParseFunction ASTVisitor::getParseFunction(const clang::FunctionTemplateDecl* declaration) const ParseFunction ASTVisitor::getParseFunction(const clang::FunctionTemplateDecl* declaration) const
{ {
bool isStatic = false; return getParseFunction(declaration->getTemplatedDecl());
bool isConst = false;
const clang::FunctionDecl* templatedDecl = declaration->getTemplatedDecl();
if (clang::isa<clang::CXXMethodDecl>(templatedDecl))
{
const clang::CXXMethodDecl* methodDecl = clang::dyn_cast<const clang::CXXMethodDecl>(templatedDecl);
isStatic = methodDecl->isStatic();
isConst = methodDecl->isConst();
}
else
{
isStatic = templatedDecl->getStorageClass() == clang::SC_Static;
}
return ParseFunction(
getParseTypeUsageOfReturnType(templatedDecl),
utility::getDeclNameHierarchy(declaration),
getParameters(templatedDecl),
isStatic,
isConst
);
} }
+15 -16
View File
@@ -2437,22 +2437,21 @@ public:
TS_ASSERT_EQUALS(client->errors[0], "use of undeclared identifier \'b\' <1:9 1:9>"); TS_ASSERT_EQUALS(client->errors[0], "use of undeclared identifier \'b\' <1:9 1:9>");
} }
// void ___test_TEST()
void ___test_TEST() // {
{ // std::shared_ptr<TestParserClient> client = parseCode(
std::shared_ptr<TestParserClient> client = parseCode( // "template <template<template<typename> class> class T>\n"
"template <template<template<typename> class> class T>\n" // "class A {\n"
"class A {\n" // "T<>\n"
"T<>\n" // "};\n"
"};\n" // "template <template<typename> class T>\n"
"template <template<typename> class T>\n" // "class B {};\n"
"class B {};\n" // "template <typename T>\n"
"template <typename T>\n" // "class C {};\n"
"class C {};\n" // "A<B> a;\n"
"A<B> a;\n" // );
); // int ofo = 0;
int ofo = 0; // }
}
private: private:
class TestParserClient: public ParserClient class TestParserClient: public ParserClient