diff --git a/src/lib/component/controller/BookmarkController.cpp b/src/lib/component/controller/BookmarkController.cpp index 800f208d..92d89ddc 100644 --- a/src/lib/component/controller/BookmarkController.cpp +++ b/src/lib/component/controller/BookmarkController.cpp @@ -281,7 +281,11 @@ void BookmarkController::handleMessage(MessageCreateBookmark* message) m_bookmarkCache.clear(); - getView()->setCreateButtonState(BookmarkView::CreateButtonState::ALREADY_CREATED); + if (!message->nodeId || (m_activeNodeIds.size() == 1 && m_activeNodeIds[0] == message->nodeId)) + { + getView()->setCreateButtonState(BookmarkView::CreateButtonState::ALREADY_CREATED); + } + getView()->update(); } diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index 24c8ccae..7f37cc98 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -147,7 +147,7 @@ void CodeController::handleMessage(MessageActivateTokens* message) m_collection = m_storageAccess->getSourceLocationsForTokenIds(params.activeTokenIds); std::vector snippets = getSnippetsForActiveSourceLocations(m_collection.get(), declarationId); - expandVisibleSnippets(&snippets); + expandVisibleSnippets(&snippets, true); view->showCodeSnippets(snippets, params); @@ -314,7 +314,7 @@ void CodeController::handleMessage(MessageShowErrors* message) std::sort(snippets.begin(), snippets.end(), CodeSnippetParams::sortById); - expandVisibleSnippets(&snippets); + expandVisibleSnippets(&snippets, false); CodeView::CodeParams params; params.clearSnippets = true; @@ -340,7 +340,7 @@ void CodeController::handleMessage(MessageSearchFullText* message) getView()->scrollTo(scrollParams); std::vector snippets = getSnippetsForCollection(m_collection, true); - expandVisibleSnippets(&snippets); + expandVisibleSnippets(&snippets, true); CodeView::CodeParams params; params.clearSnippets = true; @@ -398,7 +398,7 @@ void CodeController::clear() m_collection.reset(); } -void CodeController::expandVisibleSnippets(std::vector* snippets) const +void CodeController::expandVisibleSnippets(std::vector* snippets, bool addSourceLocations) const { TRACE(); @@ -417,7 +417,7 @@ void CodeController::expandVisibleSnippets(std::vector* snipp } std::vector newSnippets = - getSnippetsForFileWithState(oldSnippet.locationFile->getFilePath(), state, true); + getSnippetsForFileWithState(oldSnippet.locationFile->getFilePath(), state, addSourceLocations); if (!newSnippets.size()) { continue; diff --git a/src/lib/component/controller/CodeController.h b/src/lib/component/controller/CodeController.h index b1475c36..798af059 100644 --- a/src/lib/component/controller/CodeController.h +++ b/src/lib/component/controller/CodeController.h @@ -77,7 +77,7 @@ private: virtual void clear(); - void expandVisibleSnippets(std::vector* snippets) const; + void expandVisibleSnippets(std::vector* snippets, bool addSourceLocations) const; std::vector getSnippetsForFileWithState( const FilePath& filePath, CodeView::FileState state, bool addSourceLocations) const; diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index 7bc3e15c..4a641c12 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -21,6 +21,7 @@ GraphController::GraphController(StorageAccess* storageAccess) : m_storageAccess(storageAccess) + , m_useBezierEdges(false) { } @@ -86,7 +87,7 @@ void GraphController::handleMessage(MessageActivateTokens* message) std::vector tokenIds = utility::concat(m_activeNodeIds, m_activeEdgeIds); bool isNamespace = false; - std::shared_ptr graph = m_storageAccess->getGraphForActiveTokenIds(tokenIds, &isNamespace); + std::shared_ptr graph = m_storageAccess->getGraphForActiveTokenIds(tokenIds, getExpandedNodeIds(), &isNamespace); createDummyGraphForTokenIdsAndSetActiveAndVisibility(tokenIds, graph); @@ -108,6 +109,11 @@ void GraphController::handleMessage(MessageActivateTokens* message) assignBundleIds(); } + if (message->isAggregation) + { + m_useBezierEdges = true; + } + buildGraph(message, !isNamespace, true, isNamespace); } @@ -318,7 +324,7 @@ void GraphController::handleMessage(MessageGraphNodeExpand* message) break; } - std::shared_ptr aggregationGraph = m_storageAccess->getGraphForActiveTokenIds(aggregationIds); + std::shared_ptr aggregationGraph = m_storageAccess->getGraphForActiveTokenIds(aggregationIds, std::vector()); aggregationGraph->forEachEdge( [this](Edge* e) @@ -396,6 +402,8 @@ void GraphController::clear() m_graph.reset(); + m_useBezierEdges = false; + getView()->clear(); } @@ -474,6 +482,7 @@ void GraphController::createDummyGraphForTokenIds(const std::vector& tokenId m_dummyNodes = dummyNodes; m_graph = graph; + m_useBezierEdges = false; } void GraphController::createDummyGraphForTokenIdsAndSetActiveAndVisibility( @@ -1555,13 +1564,7 @@ void GraphController::buildGraph( params.animatedTransition = animatedTransition; params.scrollToTop = scrollToTop; params.isIndexedList = scrollToTop; - params.bezierEdges = false; - - MessageActivateTokens* msg = dynamic_cast(message); - if (msg && msg->isAggregation) - { - params.bezierEdges = true; - } + params.bezierEdges = m_useBezierEdges; getView()->rebuildGraph(m_graph, m_dummyNodes, m_dummyEdges, params); } diff --git a/src/lib/component/controller/GraphController.h b/src/lib/component/controller/GraphController.h index b28d7097..58f4d5e5 100644 --- a/src/lib/component/controller/GraphController.h +++ b/src/lib/component/controller/GraphController.h @@ -131,6 +131,8 @@ private: std::shared_ptr m_graph; std::map m_topLevelAncestorIds; + + bool m_useBezierEdges; }; #endif // GRAPH_CONTROLLER_H diff --git a/src/lib/data/PersistentStorage.cpp b/src/lib/data/PersistentStorage.cpp index 028d930b..b417cf10 100644 --- a/src/lib/data/PersistentStorage.cpp +++ b/src/lib/data/PersistentStorage.cpp @@ -987,7 +987,7 @@ std::shared_ptr PersistentStorage::getGraphForAll() const } std::shared_ptr PersistentStorage::getGraphForActiveTokenIds( - const std::vector& tokenIds, bool* isActiveNamespace) const + const std::vector& tokenIds, const std::vector& expandedNodeIds, bool* isActiveNamespace) const { TRACE(); @@ -1103,6 +1103,26 @@ std::shared_ptr PersistentStorage::getGraphForActiveTokenIds( addAggregationEdgesToGraph(tokenIds[0], edgesToAggregate, graph); } + if (!isNamespace) + { + std::vector expandedChildIds; + std::vector expandedChildEdgeIds; + + for (Id nodeId : expandedNodeIds) + { + if (graph->getNodeById(nodeId)) + { + m_hierarchyCache.addFirstNonImplicitChildIdsForNodeId(nodeId, &expandedChildIds, &expandedChildEdgeIds); + } + } + + if (expandedChildIds.size()) + { + addNodesToGraph(expandedChildIds, graph); + addEdgesToGraph(expandedChildEdgeIds, graph); + } + } + addComponentAccessToGraph(graph); if (isActiveNamespace) @@ -1778,10 +1798,19 @@ std::vector PersistentStorage::getAllChildNodeIds(const Id nodeId) const return utility::toVector(childNodeIds); } -void PersistentStorage::addNodesToGraph(const std::vector& nodeIds, Graph* graph) const +void PersistentStorage::addNodesToGraph(const std::vector& newNodeIds, Graph* graph) const { TRACE(); + std::vector nodeIds; + for (Id id : newNodeIds) + { + if (!graph->getNodeById(id)) + { + nodeIds.push_back(id); + } + } + if (nodeIds.size() == 0) { return; @@ -1865,10 +1894,19 @@ void PersistentStorage::addNodesToGraph(const std::vector& nodeIds, Graph* g } } -void PersistentStorage::addEdgesToGraph(const std::vector& edgeIds, Graph* graph) const +void PersistentStorage::addEdgesToGraph(const std::vector& newEdgeIds, Graph* graph) const { TRACE(); + std::vector edgeIds; + for (Id id : newEdgeIds) + { + if (!graph->getEdgeById(id)) + { + edgeIds.push_back(id); + } + } + if (edgeIds.size() == 0) { return; diff --git a/src/lib/data/PersistentStorage.h b/src/lib/data/PersistentStorage.h index 0c6b6ec0..3eada4ff 100644 --- a/src/lib/data/PersistentStorage.h +++ b/src/lib/data/PersistentStorage.h @@ -107,7 +107,8 @@ public: virtual std::vector getSearchMatchesForTokenIds(const std::vector& elementIds) const; virtual std::shared_ptr getGraphForAll() const; - virtual std::shared_ptr getGraphForActiveTokenIds(const std::vector& tokenIds, bool* isActiveNamespace = nullptr) const; + virtual std::shared_ptr getGraphForActiveTokenIds( + const std::vector& tokenIds, const std::vector& expandedNodeIds, bool* isActiveNamespace = nullptr) const; virtual std::shared_ptr getGraphForChildrenOfNodeId(Id nodeId) const; virtual std::shared_ptr getGraphForTrail(Id originId, Id targetId, Edge::EdgeTypeMask trailType, size_t depth) const; diff --git a/src/lib/data/access/StorageAccess.h b/src/lib/data/access/StorageAccess.h index c9c6e2ed..bfbfb5a8 100644 --- a/src/lib/data/access/StorageAccess.h +++ b/src/lib/data/access/StorageAccess.h @@ -48,7 +48,8 @@ public: virtual std::vector getSearchMatchesForTokenIds(const std::vector& tokenIds) const = 0; virtual std::shared_ptr getGraphForAll() const = 0; - virtual std::shared_ptr getGraphForActiveTokenIds(const std::vector& tokenIds, bool* isActiveNamespace = nullptr) const = 0; + virtual std::shared_ptr getGraphForActiveTokenIds( + const std::vector& tokenIds, const std::vector& expandedNodeIds, bool* isActiveNamespace = nullptr) const = 0; virtual std::shared_ptr getGraphForChildrenOfNodeId(Id nodeId) const = 0; virtual std::shared_ptr getGraphForTrail(Id originId, Id targetId, Edge::EdgeTypeMask trailType, size_t depth) const = 0; diff --git a/src/lib/data/access/StorageAccessProxy.cpp b/src/lib/data/access/StorageAccessProxy.cpp index 2cd82f7f..04241127 100644 --- a/src/lib/data/access/StorageAccessProxy.cpp +++ b/src/lib/data/access/StorageAccessProxy.cpp @@ -155,11 +155,12 @@ std::shared_ptr StorageAccessProxy::getGraphForAll() const return std::make_shared(); } -std::shared_ptr StorageAccessProxy::getGraphForActiveTokenIds(const std::vector& tokenIds, bool* isActiveNamespace) const +std::shared_ptr StorageAccessProxy::getGraphForActiveTokenIds( + const std::vector& tokenIds, const std::vector& expandedNodeIds, bool* isActiveNamespace) const { if (hasSubject()) { - return m_subject->getGraphForActiveTokenIds(tokenIds, isActiveNamespace); + return m_subject->getGraphForActiveTokenIds(tokenIds, expandedNodeIds, isActiveNamespace); } return std::make_shared(); diff --git a/src/lib/data/access/StorageAccessProxy.h b/src/lib/data/access/StorageAccessProxy.h index 05dadb00..e3af44b2 100644 --- a/src/lib/data/access/StorageAccessProxy.h +++ b/src/lib/data/access/StorageAccessProxy.h @@ -37,7 +37,8 @@ public: virtual std::vector getSearchMatchesForTokenIds(const std::vector& tokenIds) const; virtual std::shared_ptr getGraphForAll() const; - virtual std::shared_ptr getGraphForActiveTokenIds(const std::vector& tokenIds, bool* isActiveNamespace = nullptr) const; + virtual std::shared_ptr getGraphForActiveTokenIds( + const std::vector& tokenIds, const std::vector& expandedNodeIds, bool* isActiveNamespace = nullptr) const; virtual std::shared_ptr getGraphForChildrenOfNodeId(Id nodeId) const; virtual std::shared_ptr getGraphForTrail(Id originId, Id targetId, Edge::EdgeTypeMask trailType, size_t depth) const; diff --git a/src/lib_gui/qt/element/QtCodeFile.cpp b/src/lib_gui/qt/element/QtCodeFile.cpp index 92b494b8..29e65fa8 100644 --- a/src/lib_gui/qt/element/QtCodeFile.cpp +++ b/src/lib_gui/qt/element/QtCodeFile.cpp @@ -473,24 +473,15 @@ void QtCodeFile::enteredTitleBar(QPushButton* button) { if (m_minimizeButton->isEnabled()) { - if (m_minimizeButton != button) - { - m_minimizeButton->hoverIn(); - } + m_minimizeButton->hoverIn(); } else if (m_snippetButton->isEnabled()) { - if (m_snippetButton != button) - { - m_snippetButton->hoverIn(); - } + m_snippetButton->hoverIn(); } else if (m_maximizeButton->isEnabled()) { - if (m_maximizeButton != button) - { - m_maximizeButton->hoverIn(); - } + m_maximizeButton->hoverIn(); } } diff --git a/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp b/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp index 88c04455..67317287 100644 --- a/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp +++ b/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp @@ -71,7 +71,7 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete) ); setStyleSheet(( - "background-image: url(" + hatchingFilePath.str() + ");" + "#title_label { background-image: url(" + hatchingFilePath.str() + "); }" ).c_str()); } else