ui: Added option to show/hide referenced builtin types in graph, default is hide (issue #409)
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
<font_size_std><!-- INTEGER: standard font size in pt --></font_size_std>
|
||||
|
||||
<use_animations><!-- BOOL: define if animations are used --></use_animations>
|
||||
<builtin_types_in_graph><!-- BOOL: if the graph shows built-in types when referenced --></builtin_types_in_graph>
|
||||
|
||||
<window_base_width><!-- INTEGER: initial width of an overlay window --></window_base_width>
|
||||
<window_base_height><!-- INTEGER: initial height of an overlay window --></window_base_height>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -70,6 +70,10 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
||||
m_useAnimations = addCheckBox("Animations", "Enable animations",
|
||||
"<p>Enable animations throughout the user interface.</p>", layout, row);
|
||||
|
||||
// built-in types
|
||||
m_showBuiltinTypes = addCheckBox("Built-in Types", "Show built-in types in graph when referenced",
|
||||
"<p>Enable display of referenced built-in types in the graph view.</p>", layout, row);
|
||||
|
||||
// logging
|
||||
m_loggingEnabled = addCheckBox("Logging", "Enable console and file logging",
|
||||
"<p>Show logs in the console and save this information in files.</p>", layout, row);
|
||||
@@ -155,7 +159,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
||||
|
||||
addLabelAndWidget("Indexer Threads", threadsWidget, layout, row, Qt::AlignLeft);
|
||||
addHelpButton(
|
||||
"Indexer Threads",
|
||||
"Indexer Threads",
|
||||
"<p>Set the number of threads used to work on indexing your project in parallel.</p>"
|
||||
"<p>When setting this value to 0 Sourcetrail tries to use the ideal thread count for your computer.</p>",
|
||||
layout, row
|
||||
@@ -246,7 +250,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
||||
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
|
||||
|
||||
addHelpButton(
|
||||
"JRE System Library",
|
||||
"JRE System Library",
|
||||
"<p>Only required for indexing Java projects.</p>"
|
||||
"<p>Add the jar files of your JRE System Library. These jars can be found inside your JRE install directory.</p>", layout, row);
|
||||
|
||||
@@ -276,7 +280,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
||||
addLabelAndWidget("Maven Path", m_mavenPath, layout, row);
|
||||
|
||||
addHelpButton(
|
||||
"Maven Path",
|
||||
"Maven Path",
|
||||
"<p>Only required for indexing projects using Maven.</p>"
|
||||
"<p>Provide the location of your installed Maven executable. You can also use the auto detection below.</p>"
|
||||
, layout, row
|
||||
@@ -317,6 +321,7 @@ void QtProjectWizzardContentPreferences::load()
|
||||
}
|
||||
|
||||
m_useAnimations->setChecked(appSettings->getUseAnimations());
|
||||
m_showBuiltinTypes->setChecked(appSettings->getShowBuiltinTypesInGraph());
|
||||
|
||||
m_loggingEnabled->setChecked(appSettings->getLoggingEnabled());
|
||||
m_verboseIndexerLoggingEnabled->setChecked(appSettings->getVerboseIndexerLoggingEnabled());
|
||||
@@ -364,6 +369,7 @@ void QtProjectWizzardContentPreferences::save()
|
||||
m_oldColorSchemeIndex = -1;
|
||||
|
||||
appSettings->setUseAnimations(m_useAnimations->isChecked());
|
||||
appSettings->setShowBuiltinTypesInGraph(m_showBuiltinTypes->isChecked());
|
||||
|
||||
appSettings->setLoggingEnabled(m_loggingEnabled->isChecked());
|
||||
appSettings->setVerboseIndexerLoggingEnabled(m_verboseIndexerLoggingEnabled->isChecked());
|
||||
|
||||
@@ -64,6 +64,8 @@ private:
|
||||
int m_newColorSchemeIndex;
|
||||
|
||||
QCheckBox* m_useAnimations;
|
||||
QCheckBox* m_showBuiltinTypes;
|
||||
|
||||
QCheckBox* m_loggingEnabled;
|
||||
QCheckBox* m_verboseIndexerLoggingEnabled;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user