ui: Added option to show/hide referenced builtin types in graph, default is hide (issue #409)
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "data/graph/token_component/TokenComponentAccess.h"
|
||||
#include "data/graph/Graph.h"
|
||||
#include "data/parser/AccessKind.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
GraphController::GraphController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
@@ -40,7 +41,7 @@ void GraphController::handleMessage(MessageActivateAll* message)
|
||||
|
||||
if (message->filter)
|
||||
{
|
||||
createDummyGraphForTokenIdsAndSetActiveAndVisibility(
|
||||
createDummyGraphAndSetActiveAndVisibility(
|
||||
std::vector<Id>(), m_storageAccess->getGraphForFilter(message->filter));
|
||||
|
||||
addCharacterIndex();
|
||||
@@ -49,7 +50,7 @@ void GraphController::handleMessage(MessageActivateAll* message)
|
||||
}
|
||||
else
|
||||
{
|
||||
createDummyGraphForTokenIdsAndSetActiveAndVisibility(std::vector<Id>(), m_storageAccess->getGraphForAll());
|
||||
createDummyGraphAndSetActiveAndVisibility(std::vector<Id>(), m_storageAccess->getGraphForAll());
|
||||
|
||||
bundleNodesByType();
|
||||
|
||||
@@ -101,7 +102,7 @@ void GraphController::handleMessage(MessageActivateTokens* message)
|
||||
bool isNamespace = false;
|
||||
std::shared_ptr<Graph> graph = m_storageAccess->getGraphForActiveTokenIds(tokenIds, getExpandedNodeIds(), &isNamespace);
|
||||
|
||||
createDummyGraphForTokenIdsAndSetActiveAndVisibility(tokenIds, graph);
|
||||
createDummyGraphAndSetActiveAndVisibility(tokenIds, graph);
|
||||
|
||||
if (isNamespace)
|
||||
{
|
||||
@@ -157,7 +158,7 @@ void GraphController::handleMessage(MessageActivateTrail* message)
|
||||
std::shared_ptr<Graph> graph = m_storageAccess->getGraphForTrail(
|
||||
message->originId, message->targetId, message->trailType, message->depth);
|
||||
|
||||
createDummyGraphForTokenIds(m_activeNodeIds, graph);
|
||||
createDummyGraph(graph);
|
||||
m_graph->setTrailMode(message->horizontalLayout ? Graph::TRAIL_HORIZONTAL : Graph::TRAIL_VERTICAL);
|
||||
|
||||
setVisibility(setActive(m_activeNodeIds, true));
|
||||
@@ -356,7 +357,8 @@ void GraphController::handleMessage(MessageGraphNodeExpand* message)
|
||||
break;
|
||||
}
|
||||
|
||||
std::shared_ptr<Graph> aggregationGraph = m_storageAccess->getGraphForActiveTokenIds(aggregationIds, std::vector<Id>());
|
||||
std::shared_ptr<Graph> aggregationGraph =
|
||||
m_storageAccess->getGraphForActiveTokenIds(aggregationIds, std::vector<Id>());
|
||||
|
||||
aggregationGraph->forEachEdge(
|
||||
[this](Edge* e)
|
||||
@@ -439,7 +441,7 @@ void GraphController::clear()
|
||||
getView()->clear();
|
||||
}
|
||||
|
||||
void GraphController::createDummyGraphForTokenIds(const std::vector<Id>& tokenIds, const std::shared_ptr<Graph> graph)
|
||||
void GraphController::createDummyGraph(const std::shared_ptr<Graph> graph)
|
||||
{
|
||||
TRACE();
|
||||
|
||||
@@ -517,12 +519,12 @@ void GraphController::createDummyGraphForTokenIds(const std::vector<Id>& tokenId
|
||||
m_useBezierEdges = false;
|
||||
}
|
||||
|
||||
void GraphController::createDummyGraphForTokenIdsAndSetActiveAndVisibility(
|
||||
void GraphController::createDummyGraphAndSetActiveAndVisibility(
|
||||
const std::vector<Id>& tokenIds, const std::shared_ptr<Graph> graph
|
||||
){
|
||||
std::vector<Id> expandedNodeIds = getExpandedNodeIds();
|
||||
|
||||
createDummyGraphForTokenIds(tokenIds, graph);
|
||||
createDummyGraph(graph);
|
||||
|
||||
bool noActive = setActive(tokenIds, false);
|
||||
|
||||
@@ -530,6 +532,8 @@ void GraphController::createDummyGraphForTokenIdsAndSetActiveAndVisibility(
|
||||
setExpandedNodeIds(expandedNodeIds);
|
||||
|
||||
setVisibility(noActive);
|
||||
|
||||
hideBuiltinTypes();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<DummyNode>> GraphController::createDummyNodeTopDown(Node* node, Id ancestorId)
|
||||
@@ -782,6 +786,22 @@ void GraphController::setNodeVisibilityRecursiveTopDown(DummyNode* node, bool pa
|
||||
}
|
||||
}
|
||||
|
||||
void GraphController::hideBuiltinTypes()
|
||||
{
|
||||
if (ApplicationSettings::getInstance()->getShowBuiltinTypesInGraph() || m_activeNodeIds.size() != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<DummyNode>& node : m_dummyNodes)
|
||||
{
|
||||
if (node->isGraphNode() && !node->active && node->data->getType().isBuiltin())
|
||||
{
|
||||
node->visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphController::bundleNodes()
|
||||
{
|
||||
TRACE();
|
||||
@@ -1301,7 +1321,8 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
|
||||
|
||||
if (node->isGraphNode())
|
||||
{
|
||||
margins = GraphViewStyle::getMarginsForDataNode(node->data->getType().getNodeStyle(), node->data->getType().hasIcon(), node->childVisible);
|
||||
margins = GraphViewStyle::getMarginsForDataNode(
|
||||
node->data->getType().getNodeStyle(), node->data->getType().hasIcon(), node->childVisible);
|
||||
}
|
||||
else if (node->isAccessNode())
|
||||
{
|
||||
@@ -1315,7 +1336,8 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
|
||||
{
|
||||
if (node->bundledNodeType.getType() != NodeType::NODE_SYMBOL)
|
||||
{
|
||||
margins = GraphViewStyle::getMarginsForDataNode(node->bundledNodeType.getNodeStyle(), node->bundledNodeType.hasIcon(), false);
|
||||
margins = GraphViewStyle::getMarginsForDataNode(
|
||||
node->bundledNodeType.getNodeStyle(), node->bundledNodeType.hasIcon(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1822,7 +1844,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
}
|
||||
);
|
||||
|
||||
createDummyGraphForTokenIds(std::vector<Id>(), graph);
|
||||
createDummyGraph(graph);
|
||||
|
||||
for (size_t i = 0; i < 2; i++)
|
||||
{
|
||||
|
||||
@@ -72,8 +72,8 @@ private:
|
||||
|
||||
virtual void clear();
|
||||
|
||||
void createDummyGraphForTokenIds(const std::vector<Id>& tokenIds, const std::shared_ptr<Graph> graph);
|
||||
void createDummyGraphForTokenIdsAndSetActiveAndVisibility(
|
||||
void createDummyGraph(const std::shared_ptr<Graph> graph);
|
||||
void createDummyGraphAndSetActiveAndVisibility(
|
||||
const std::vector<Id>& tokenIds, const std::shared_ptr<Graph> graph);
|
||||
std::vector<std::shared_ptr<DummyNode>> createDummyNodeTopDown(Node* node, Id ancestorId);
|
||||
|
||||
@@ -88,6 +88,8 @@ private:
|
||||
bool setNodeVisibilityRecursiveBottomUp(DummyNode* node, bool noActive) const;
|
||||
void setNodeVisibilityRecursiveTopDown(DummyNode* node, bool parentExpanded) const;
|
||||
|
||||
void hideBuiltinTypes();
|
||||
|
||||
void bundleNodes();
|
||||
void bundleNodesAndEdgesMatching(
|
||||
std::function<bool(const DummyNode::BundleInfo&, const Node*)> matcher, size_t count, bool countConnectedNodes,
|
||||
|
||||
+30
-24
@@ -25,6 +25,12 @@ bool NodeType::isFile() const
|
||||
return ((m_type & mask) > 0);
|
||||
}
|
||||
|
||||
bool NodeType::isBuiltin() const
|
||||
{
|
||||
const NodeType::TypeMask mask = NodeType::NODE_BUILTIN_TYPE;
|
||||
return ((m_type & mask) > 0);
|
||||
}
|
||||
|
||||
bool NodeType::isUnknownSymbol() const
|
||||
{
|
||||
const NodeType::TypeMask mask =
|
||||
@@ -36,11 +42,11 @@ bool NodeType::isInheritable() const
|
||||
{
|
||||
// what about java enums?
|
||||
const NodeType::TypeMask mask =
|
||||
NodeType::NODE_SYMBOL |
|
||||
NodeType::NODE_BUILTIN_TYPE |
|
||||
NodeType::NODE_TYPE |
|
||||
NodeType::NODE_STRUCT |
|
||||
NodeType::NODE_CLASS |
|
||||
NodeType::NODE_SYMBOL |
|
||||
NodeType::NODE_BUILTIN_TYPE |
|
||||
NodeType::NODE_TYPE |
|
||||
NodeType::NODE_STRUCT |
|
||||
NodeType::NODE_CLASS |
|
||||
NodeType::NODE_INTERFACE;
|
||||
|
||||
return ((m_type & mask) > 0);
|
||||
@@ -73,12 +79,12 @@ bool NodeType::isVariable() const
|
||||
bool NodeType::isUsable() const
|
||||
{
|
||||
const NodeType::TypeMask mask =
|
||||
NodeType::NODE_SYMBOL |
|
||||
NodeType::NODE_BUILTIN_TYPE |
|
||||
NodeType::NODE_STRUCT |
|
||||
NodeType::NODE_CLASS |
|
||||
NodeType::NODE_ENUM |
|
||||
NodeType::NODE_UNION |
|
||||
NodeType::NODE_SYMBOL |
|
||||
NodeType::NODE_BUILTIN_TYPE |
|
||||
NodeType::NODE_STRUCT |
|
||||
NodeType::NODE_CLASS |
|
||||
NodeType::NODE_ENUM |
|
||||
NodeType::NODE_UNION |
|
||||
NodeType::NODE_INTERFACE |
|
||||
NodeType::NODE_TYPEDEF;
|
||||
return ((m_type & mask) > 0);
|
||||
@@ -87,13 +93,13 @@ bool NodeType::isUsable() const
|
||||
bool NodeType::isPotentialMember() const
|
||||
{
|
||||
const NodeType::TypeMask mask =
|
||||
NodeType::NODE_METHOD |
|
||||
NodeType::NODE_FIELD |
|
||||
NodeType::NODE_CLASS |
|
||||
NodeType::NODE_INTERFACE |
|
||||
NodeType::NODE_STRUCT |
|
||||
NodeType::NODE_UNION |
|
||||
NodeType::NODE_TYPEDEF |
|
||||
NodeType::NODE_METHOD |
|
||||
NodeType::NODE_FIELD |
|
||||
NodeType::NODE_CLASS |
|
||||
NodeType::NODE_INTERFACE |
|
||||
NodeType::NODE_STRUCT |
|
||||
NodeType::NODE_UNION |
|
||||
NodeType::NODE_TYPEDEF |
|
||||
NodeType::NODE_ENUM;
|
||||
|
||||
return ((m_type & mask) > 0);
|
||||
@@ -102,12 +108,12 @@ bool NodeType::isPotentialMember() const
|
||||
bool NodeType::isCollapsible() const
|
||||
{
|
||||
const NodeType::TypeMask mask =
|
||||
NodeType::NODE_SYMBOL |
|
||||
NodeType::NODE_TYPE |
|
||||
NodeType::NODE_BUILTIN_TYPE |
|
||||
NodeType::NODE_CLASS |
|
||||
NodeType::NODE_STRUCT |
|
||||
NodeType::NODE_ENUM |
|
||||
NodeType::NODE_SYMBOL |
|
||||
NodeType::NODE_TYPE |
|
||||
NodeType::NODE_BUILTIN_TYPE |
|
||||
NodeType::NODE_CLASS |
|
||||
NodeType::NODE_STRUCT |
|
||||
NodeType::NODE_ENUM |
|
||||
NodeType::NODE_UNION |
|
||||
NodeType::NODE_INTERFACE;
|
||||
return ((m_type & mask) > 0);
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
Type getType() const;
|
||||
|
||||
bool isFile() const;
|
||||
bool isBuiltin() const;
|
||||
bool isUnknownSymbol() const;
|
||||
bool isInheritable() const;
|
||||
bool isPackage() const;
|
||||
|
||||
@@ -96,7 +96,7 @@ void PersistentStorage::addFile(const StorageFile& data)
|
||||
{
|
||||
m_sqliteIndexStorage.addFile(data);
|
||||
}
|
||||
|
||||
|
||||
if (!storedFile.complete && data.complete)
|
||||
{
|
||||
m_sqliteIndexStorage.setFileComplete(data.complete, storedFile.id);
|
||||
|
||||
@@ -137,6 +137,16 @@ void ApplicationSettings::setUseAnimations(bool useAnimations)
|
||||
setValue<bool>("application/use_animations", useAnimations);
|
||||
}
|
||||
|
||||
bool ApplicationSettings::getShowBuiltinTypesInGraph() const
|
||||
{
|
||||
return getValue<bool>("application/builtin_types_in_graph", false);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setShowBuiltinTypesInGraph(bool showBuiltinTypes)
|
||||
{
|
||||
setValue<bool>("application/builtin_types_in_graph", showBuiltinTypes);
|
||||
}
|
||||
|
||||
FilePath ApplicationSettings::getColorSchemePath() const
|
||||
{
|
||||
FilePath defaultPath(ResourcePaths::getColorSchemesPath().concat(FilePath("bright.xml")));
|
||||
|
||||
@@ -50,6 +50,9 @@ public:
|
||||
bool getUseAnimations() const;
|
||||
void setUseAnimations(bool useAnimations);
|
||||
|
||||
bool getShowBuiltinTypesInGraph() const;
|
||||
void setShowBuiltinTypesInGraph(bool showBuiltinTypes);
|
||||
|
||||
int getWindowBaseWidth() const;
|
||||
int getWindowBaseHeight() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user