logic: Refactored undo redo stack
* Store MessageActivateTokens instead of original view messages * Renamed FeatureController to ActivationController * Remove all non-activation messages from undo redo stack after reindexing project * Added MessageShowReference to undo redo stack * Added MessageScrollGraph for restoring graph view scroll position * Fixed MessageGraphNodeMove not saved for bundles * Refactored tokenIds and nodeNames in SearchMatch and MessageActivateTokens * Refactored SearchController * Fixed file expansion on undoing/redoing after switching code view mode * Fixed redundant graph animation due to present qualifier nodes * Fixed no restoring of graph node expansion when showing overview in between
This commit is contained in:
@@ -13,6 +13,8 @@ add_files(
|
||||
component/controller/helper/SnippetMerger.cpp
|
||||
component/controller/helper/SnippetMerger.h
|
||||
|
||||
component/controller/ActivationController.cpp
|
||||
component/controller/ActivationController.h
|
||||
component/controller/BookmarkController.cpp
|
||||
component/controller/BookmarkController.h
|
||||
component/controller/CodeController.cpp
|
||||
@@ -21,8 +23,6 @@ add_files(
|
||||
component/controller/Controller.h
|
||||
component/controller/ErrorController.cpp
|
||||
component/controller/ErrorController.h
|
||||
component/controller/FeatureController.cpp
|
||||
component/controller/FeatureController.h
|
||||
component/controller/GraphController.cpp
|
||||
component/controller/GraphController.h
|
||||
component/controller/IDECommunicationController.cpp
|
||||
@@ -104,7 +104,7 @@ add_files(
|
||||
data/bookmark/EdgeBookmark.h
|
||||
data/bookmark/NodeBookmark.cpp
|
||||
data/bookmark/NodeBookmark.h
|
||||
|
||||
|
||||
data/fulltextsearch/FullTextSearchIndex.cpp
|
||||
data/fulltextsearch/FullTextSearchIndex.h
|
||||
data/fulltextsearch/SuffixArray.cpp
|
||||
@@ -135,7 +135,7 @@ add_files(
|
||||
data/graph/Node.h
|
||||
data/graph/Token.cpp
|
||||
data/graph/Token.h
|
||||
|
||||
|
||||
data/indexer/Indexer.h
|
||||
data/indexer/IndexerBase.cpp
|
||||
data/indexer/IndexerBase.h
|
||||
@@ -271,7 +271,7 @@ add_files(
|
||||
utility/interprocess/SharedQueue.h
|
||||
utility/interprocess/SharedUUIDManager.cpp
|
||||
utility/interprocess/SharedUUIDManager.h
|
||||
|
||||
|
||||
utility/logging/ConsoleLogger.cpp
|
||||
utility/logging/ConsoleLogger.h
|
||||
utility/logging/FileLogger.cpp
|
||||
@@ -347,6 +347,7 @@ add_files(
|
||||
utility/messaging/type/MessageRefresh.h
|
||||
utility/messaging/type/MessageResetZoom.h
|
||||
utility/messaging/type/MessageScrollCode.h
|
||||
utility/messaging/type/MessageScrollGraph.h
|
||||
utility/messaging/type/MessageScrollToLine.h
|
||||
utility/messaging/type/MessageSearch.h
|
||||
utility/messaging/type/MessageSearchAutocomplete.h
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "component/ComponentFactory.h"
|
||||
|
||||
#include "component/Component.h"
|
||||
#include "component/controller/ActivationController.h"
|
||||
#include "component/controller/BookmarkController.h"
|
||||
#include "component/controller/CodeController.h"
|
||||
#include "component/controller/ErrorController.h"
|
||||
#include "component/controller/FeatureController.h"
|
||||
#include "component/controller/GraphController.h"
|
||||
#include "component/controller/LogController.h"
|
||||
#include "component/controller/RefreshController.h"
|
||||
@@ -50,6 +50,13 @@ StorageAccess* ComponentFactory::getStorageAccess() const
|
||||
return m_storageAccess;
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createActivationComponent()
|
||||
{
|
||||
std::shared_ptr<Controller> controller = std::make_shared<ActivationController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(nullptr, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createBookmarkComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<BookmarkView> view = m_viewFactory->createBookmarkView(viewLayout);
|
||||
@@ -84,13 +91,6 @@ std::shared_ptr<Component> ComponentFactory::createLogComponent(ViewLayout* view
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createFeatureComponent()
|
||||
{
|
||||
std::shared_ptr<Controller> controller = std::make_shared<FeatureController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(nullptr, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createGraphComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<View> view = m_viewFactory->createGraphView(viewLayout);
|
||||
|
||||
@@ -19,10 +19,10 @@ public:
|
||||
ViewFactory* getViewFactory() const;
|
||||
StorageAccess* getStorageAccess() const;
|
||||
|
||||
std::shared_ptr<Component> createActivationComponent();
|
||||
std::shared_ptr<Component> createBookmarkComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createCodeComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createErrorComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createFeatureComponent();
|
||||
std::shared_ptr<Component> createGraphComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createLogComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createRefreshComponent(ViewLayout* viewLayout);
|
||||
|
||||
@@ -54,8 +54,8 @@ void ComponentManager::setup(ViewLayout* viewLayout)
|
||||
std::shared_ptr<Component> statusBarComponent = m_componentFactory->createStatusBarComponent(viewLayout);
|
||||
m_components.push_back(statusBarComponent);
|
||||
|
||||
std::shared_ptr<Component> featureComponent = m_componentFactory->createFeatureComponent();
|
||||
m_components.push_back(featureComponent);
|
||||
std::shared_ptr<Component> activationComponent = m_componentFactory->createActivationComponent();
|
||||
m_components.push_back(activationComponent);
|
||||
|
||||
m_dialogView = m_componentFactory->getViewFactory()->createDialogView(viewLayout, m_componentFactory->getStorageAccess());
|
||||
|
||||
|
||||
+41
-75
@@ -1,4 +1,4 @@
|
||||
#include "component/controller/FeatureController.h"
|
||||
#include "component/controller/ActivationController.h"
|
||||
|
||||
#include "data/access/StorageAccess.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
@@ -13,58 +13,50 @@
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/messaging/type/MessageScrollToLine.h"
|
||||
|
||||
FeatureController::FeatureController(StorageAccess* storageAccess)
|
||||
ActivationController::ActivationController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
{
|
||||
}
|
||||
|
||||
FeatureController::~FeatureController()
|
||||
ActivationController::~ActivationController()
|
||||
{
|
||||
}
|
||||
|
||||
void FeatureController::clear()
|
||||
void ActivationController::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageActivateEdge* message)
|
||||
void ActivationController::handleMessage(MessageActivateEdge* message)
|
||||
{
|
||||
if (message->isAggregation())
|
||||
{
|
||||
// TODO: validate aggregationIds
|
||||
MessageActivateTokens m(message, message->aggregationIds);
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds = message->aggregationIds;
|
||||
m.setKeepContent(false);
|
||||
m.isAggregation = true;
|
||||
m.tokenNames.push_back(NameHierarchy(message->getFullName()));
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
else
|
||||
{
|
||||
Id edgeId = message->tokenId;
|
||||
|
||||
if (message->isReplayed())
|
||||
{
|
||||
edgeId = m_storageAccess->getIdForEdge(message->type, message->fromNameHierarchy, message->toNameHierarchy);
|
||||
}
|
||||
|
||||
std::vector<Id> ids;
|
||||
if (edgeId)
|
||||
{
|
||||
ids.push_back(edgeId);
|
||||
}
|
||||
|
||||
MessageActivateTokens m(message, ids);
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds.push_back(message->tokenId);
|
||||
m.isEdge = true;
|
||||
m.unknownNames = std::vector<std::string>(1, message->getFullName());
|
||||
m.tokenNames.push_back(NameHierarchy(message->getFullName()));
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageActivateFile* message)
|
||||
void ActivationController::handleMessage(MessageActivateFile* message)
|
||||
{
|
||||
Id fileId = m_storageAccess->getTokenIdForFileNode(message->filePath);
|
||||
|
||||
if (fileId)
|
||||
{
|
||||
MessageActivateTokens(message, std::vector<Id>(1, fileId)).dispatchImmediately();
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds.push_back(fileId);
|
||||
m.tokenNames.push_back(message->filePath.str());
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -74,8 +66,6 @@ void FeatureController::handleMessage(MessageActivateFile* message)
|
||||
true,
|
||||
true
|
||||
);
|
||||
msg.setIsReplayed(message->isReplayed());
|
||||
msg.setKeepContent(message->keepContent());
|
||||
msg.dispatchImmediately();
|
||||
}
|
||||
|
||||
@@ -85,35 +75,22 @@ void FeatureController::handleMessage(MessageActivateFile* message)
|
||||
}
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageActivateNodes* message)
|
||||
void ActivationController::handleMessage(MessageActivateNodes* message)
|
||||
{
|
||||
std::vector<Id> nodeIds;
|
||||
|
||||
MessageActivateTokens m(message);
|
||||
for (const MessageActivateNodes::ActiveNode& node : message->nodes)
|
||||
{
|
||||
if (node.nodeId)
|
||||
Id nodeId = node.nodeId ? node.nodeId : m_storageAccess->getIdForNodeWithNameHierarchy(node.nameHierarchy);
|
||||
if (nodeId > 0)
|
||||
{
|
||||
nodeIds.push_back(node.nodeId);
|
||||
m.tokenIds.push_back(nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Id nodeId = m_storageAccess->getIdForNodeWithNameHierarchy(node.nameHierarchy);
|
||||
if (nodeId > 0)
|
||||
{
|
||||
nodeIds.push_back(nodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessageActivateTokens m(message, nodeIds);
|
||||
for (const MessageActivateNodes::ActiveNode& node : message->nodes)
|
||||
{
|
||||
m.unknownNames.push_back(node.nameHierarchy.getQualifiedName());
|
||||
m.tokenNames.push_back(node.nameHierarchy);
|
||||
}
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageSearch* message)
|
||||
void ActivationController::handleMessage(MessageSearch* message)
|
||||
{
|
||||
const std::vector<SearchMatch>& matches = message->getMatches();
|
||||
|
||||
@@ -127,17 +104,13 @@ void FeatureController::handleMessage(MessageSearch* message)
|
||||
{
|
||||
case SearchMatch::COMMAND_ALL:
|
||||
{
|
||||
MessageActivateAll msg;
|
||||
msg.setIsReplayed(message->isReplayed());
|
||||
msg.dispatchImmediately();
|
||||
MessageActivateAll().dispatchImmediately();
|
||||
return;
|
||||
}
|
||||
|
||||
case SearchMatch::COMMAND_ERROR:
|
||||
{
|
||||
MessageShowErrors msg(m_storageAccess->getErrorCount());
|
||||
msg.setIsReplayed(true);
|
||||
msg.dispatch();
|
||||
MessageShowErrors(m_storageAccess->getErrorCount()).dispatch();
|
||||
MessageFlushUpdates().dispatch();
|
||||
return;
|
||||
}
|
||||
@@ -151,41 +124,34 @@ void FeatureController::handleMessage(MessageSearch* message)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Id> tokenIds = m_storageAccess->getTokenIdsForMatches(matches);
|
||||
|
||||
MessageActivateTokens m(message, tokenIds);
|
||||
for (const SearchMatch& match : matches)
|
||||
{
|
||||
m.unknownNames.push_back(match.name);
|
||||
}
|
||||
if (!message->isReplayed())
|
||||
{
|
||||
m.isFromSearch = true;
|
||||
}
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds = message->getTokenIdsOfMatches();
|
||||
m.searchMatches = matches;
|
||||
m.tokenNames = m_storageAccess->getNameHierarchiesForNodeIds(m.tokenIds);
|
||||
m.isFromSearch = true;
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageActivateTokenIds* message)
|
||||
void ActivationController::handleMessage(MessageActivateTokenIds* message)
|
||||
{
|
||||
MessageActivateTokens(message, message->tokenIds).dispatchImmediately();
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds = message->tokenIds;
|
||||
m.searchMatches = m_storageAccess->getSearchMatchesForTokenIds(message->tokenIds);
|
||||
m.tokenNames = m_storageAccess->getNameHierarchiesForNodeIds(m.tokenIds);
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageActivateTokenLocations* message)
|
||||
void ActivationController::handleMessage(MessageActivateTokenLocations* message)
|
||||
{
|
||||
std::vector<Id> nodeIds = m_storageAccess->getNodeIdsForLocationIds(message->locationIds);
|
||||
MessageActivateNodes m;
|
||||
for (Id nodeId : nodeIds)
|
||||
for (Id nodeId : m_storageAccess->getNodeIdsForLocationIds(message->locationIds))
|
||||
{
|
||||
m.addNode(
|
||||
nodeId,
|
||||
m_storageAccess->getNodeTypeForNodeWithId(nodeId),
|
||||
m_storageAccess->getNameHierarchyForNodeWithId(nodeId)
|
||||
);
|
||||
m.addNode(nodeId, m_storageAccess->getNameHierarchyForNodeWithId(nodeId));
|
||||
}
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageResetZoom* message)
|
||||
void ActivationController::handleMessage(MessageResetZoom* message)
|
||||
{
|
||||
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
|
||||
int fontSizeStd = settings->getFontSizeStd();
|
||||
@@ -201,7 +167,7 @@ void FeatureController::handleMessage(MessageResetZoom* message)
|
||||
MessageStatus("Zoom: 100%").dispatch();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageZoom* message)
|
||||
void ActivationController::handleMessage(MessageZoom* message)
|
||||
{
|
||||
bool zoomIn = message->zoomIn;
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
#ifndef FEATURE_CONTROLLER_H
|
||||
#define FEATURE_CONTROLLER_H
|
||||
#ifndef ACTIVATION_CONTROLLER_H
|
||||
#define ACTIVATION_CONTROLLER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
class StorageAccess;
|
||||
|
||||
class FeatureController
|
||||
class ActivationController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateEdge>
|
||||
, public MessageListener<MessageActivateFile>
|
||||
@@ -29,8 +29,8 @@ class FeatureController
|
||||
, public MessageListener<MessageZoom>
|
||||
{
|
||||
public:
|
||||
FeatureController(StorageAccess* storageAccess);
|
||||
~FeatureController();
|
||||
ActivationController(StorageAccess* storageAccess);
|
||||
~ActivationController();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
@@ -47,4 +47,4 @@ private:
|
||||
StorageAccess* m_storageAccess;
|
||||
};
|
||||
|
||||
#endif // FEATURE_CONTROLLER_H
|
||||
#endif // ACTIVATION_CONTROLLER_H
|
||||
@@ -47,7 +47,7 @@ std::vector<std::shared_ptr<Bookmark>> BookmarkController::getAllBookmarks() con
|
||||
LOG_INFO_STREAM(<< "Retrieving all bookmarks");
|
||||
|
||||
std::vector<std::shared_ptr<Bookmark>> bookmarks;
|
||||
|
||||
|
||||
std::vector<NodeBookmark> nodeBookmarks = m_storageAccess->getAllNodeBookmarks();
|
||||
|
||||
for (unsigned int i = 0; i < nodeBookmarks.size(); i++)
|
||||
@@ -91,7 +91,7 @@ std::vector<std::shared_ptr<Bookmark>> BookmarkController::getAllBookmarks() con
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return bookmarks;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ void BookmarkController::handleMessage(MessageActivateBookmark* message)
|
||||
for (unsigned int i = 0; i < baseBookmark.getTokenNames().size(); i++)
|
||||
{
|
||||
NameHierarchy nh = NameHierarchy::deserialize(baseBookmark.getTokenNames()[i]);
|
||||
activateNodes.addNode(nh);
|
||||
activateNodes.addNode(0, nh);
|
||||
}
|
||||
|
||||
activateNodes.dispatch();
|
||||
@@ -208,7 +208,7 @@ void BookmarkController::handleMessage(MessageActivateBookmark* message)
|
||||
for (unsigned int i = 0; i < bookmark->getTokenNames().size(); i++)
|
||||
{
|
||||
NameHierarchy nh = NameHierarchy::deserialize(bookmark->getTokenNames()[i]);
|
||||
activateNodes.addNode(nh);
|
||||
activateNodes.addNode(0, nh);
|
||||
}
|
||||
|
||||
activateNodes.dispatch();
|
||||
@@ -234,7 +234,7 @@ void BookmarkController::handleMessage(MessageActivateTokens* message)
|
||||
int typeId = edge.type;
|
||||
|
||||
tokenTypes.push_back(typeId);
|
||||
|
||||
|
||||
NameHierarchy sourceHierarchy = m_storageAccess->getNameHierarchyForNodeWithId(edge.sourceNodeId);
|
||||
NameHierarchy targetHierarchy = m_storageAccess->getNameHierarchyForNodeWithId(edge.targetNodeId);
|
||||
|
||||
@@ -527,7 +527,7 @@ std::vector<int> BookmarkController::getTokenTypes(const std::vector<Id>& ids) c
|
||||
int type = m_storageAccess->getNodeTypeForNodeWithId(ids[i]);
|
||||
types.push_back(type);
|
||||
}
|
||||
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,17 +105,18 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
|
||||
CodeView* view = getView();
|
||||
|
||||
if (!message->keepContent())
|
||||
{
|
||||
view->clearCodeSnippets();
|
||||
}
|
||||
|
||||
std::vector<Id> activeTokenIds = message->tokenIds;
|
||||
if (!activeTokenIds.size())
|
||||
{
|
||||
view->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!message->keepContent())
|
||||
{
|
||||
view->clearCodeSnippets();
|
||||
}
|
||||
|
||||
Id declarationId = 0; // 0 means that no token is found.
|
||||
if (!message->isAggregation)
|
||||
{
|
||||
@@ -139,17 +140,21 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
else
|
||||
{
|
||||
m_collection = m_storageAccess->getTokenLocationsForTokenIds(activeTokenIds);
|
||||
view->showCodeSnippets(getSnippetsForActiveTokenLocations(m_collection.get(), declarationId), activeTokenIds, true);
|
||||
m_scrollToDefinition = !message->isReplayed() || message->isLast();
|
||||
view->showCodeSnippets(
|
||||
getSnippetsForActiveTokenLocations(m_collection.get(), declarationId),
|
||||
activeTokenIds,
|
||||
!message->isReplayed() || message->isReplayCleared()
|
||||
);
|
||||
m_scrollToDefinition = !message->isReplayed() || message->isReplayCleared();
|
||||
|
||||
size_t fileCount = m_collection->getTokenLocationFileCount();
|
||||
size_t referenceCount = m_collection->getTokenLocationCount();
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
if (message->unknownNames.size())
|
||||
if (message->tokenNames.size())
|
||||
{
|
||||
ss << "Activate \"" << message->unknownNames[0] << "\": ";
|
||||
ss << "Activate \"" << message->tokenNames[0].getQualifiedName() << "\": ";
|
||||
}
|
||||
|
||||
ss << message->tokenIds.size() << ' ';
|
||||
@@ -179,15 +184,22 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
||||
}
|
||||
|
||||
CodeView* view = getView();
|
||||
bool inListMode = view->isInListMode();
|
||||
|
||||
switch (message->state)
|
||||
MessageChangeFileView::FileState state = message->state;
|
||||
if (state == MessageChangeFileView::FILE_DEFAULT_FOR_MODE)
|
||||
{
|
||||
state = inListMode ? MessageChangeFileView::FILE_SNIPPETS : MessageChangeFileView::FILE_MAXIMIZED;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case MessageChangeFileView::FILE_MINIMIZED:
|
||||
view->setFileState(message->filePath, CodeView::FILE_MINIMIZED);
|
||||
break;
|
||||
|
||||
case MessageChangeFileView::FILE_SNIPPETS:
|
||||
if (message->needsData)
|
||||
if (message->needsData && inListMode)
|
||||
{
|
||||
std::shared_ptr<TokenLocationFile> file = m_collection->getTokenLocationFileByPath(message->filePath);
|
||||
if (!file)
|
||||
@@ -250,6 +262,8 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
||||
|
||||
view->setFileState(message->filePath, CodeView::FILE_MAXIMIZED);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
showContents(message);
|
||||
|
||||
@@ -32,6 +32,8 @@ void GraphController::handleMessage(MessageActivateAll* message)
|
||||
m_activeNodeIds.clear();
|
||||
m_activeEdgeIds.clear();
|
||||
|
||||
m_dummyGraphNodes.clear();
|
||||
|
||||
createDummyGraphForTokenIdsAndSetActiveAndVisibility(std::vector<Id>(), m_storageAccess->getGraphForAll());
|
||||
|
||||
bundleNodesByType();
|
||||
@@ -104,6 +106,14 @@ void GraphController::handleMessage(MessageFlushUpdates* message)
|
||||
buildGraph(message, true, !message->keepContent());
|
||||
}
|
||||
|
||||
void GraphController::handleMessage(MessageScrollGraph* message)
|
||||
{
|
||||
if (message->isReplayed())
|
||||
{
|
||||
getView()->scrollToValues(message->xValue, message->yValue);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphController::handleMessage(MessageSearchFullText* message)
|
||||
{
|
||||
clear();
|
||||
@@ -247,7 +257,7 @@ void GraphController::handleMessage(MessageShowErrors* message)
|
||||
|
||||
void GraphController::handleMessage(MessageShowReference* message)
|
||||
{
|
||||
if (!message->tokenId)
|
||||
if (!message->tokenId || !message->animated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeExpand.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
#include "utility/messaging/type/MessageScrollGraph.h"
|
||||
#include "utility/messaging/type/MessageSearchFullText.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/messaging/type/MessageShowReference.h"
|
||||
@@ -40,6 +41,7 @@ class GraphController
|
||||
, public MessageListener<MessageGraphNodeBundleSplit>
|
||||
, public MessageListener<MessageGraphNodeExpand>
|
||||
, public MessageListener<MessageGraphNodeMove>
|
||||
, public MessageListener<MessageScrollGraph>
|
||||
, public MessageListener<MessageSearchFullText>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
, public MessageListener<MessageShowReference>
|
||||
@@ -57,6 +59,7 @@ private:
|
||||
virtual void handleMessage(MessageGraphNodeBundleSplit* message);
|
||||
virtual void handleMessage(MessageGraphNodeExpand* message);
|
||||
virtual void handleMessage(MessageGraphNodeMove* message);
|
||||
virtual void handleMessage(MessageScrollGraph* message);
|
||||
virtual void handleMessage(MessageSearchFullText* message);
|
||||
virtual void handleMessage(MessageShowErrors* message);
|
||||
virtual void handleMessage(MessageShowReference* message);
|
||||
|
||||
@@ -13,30 +13,42 @@ SearchController::~SearchController()
|
||||
{
|
||||
}
|
||||
|
||||
void SearchController::handleMessage(MessageActivateAll* message)
|
||||
{
|
||||
getView()->setMatches(std::vector<SearchMatch>(1, SearchMatch::createCommand(SearchMatch::COMMAND_ALL)));
|
||||
}
|
||||
|
||||
void SearchController::handleMessage(MessageActivateTokens* message)
|
||||
{
|
||||
if (!message->isFromSearch)
|
||||
if ((message->isFromSearch && !message->isReplayed()) || message->keepContent())
|
||||
{
|
||||
if (!message->keepContent() && message->tokenIds.size())
|
||||
return;
|
||||
}
|
||||
|
||||
if (message->searchMatches.size())
|
||||
{
|
||||
getView()->setMatches(message->searchMatches);
|
||||
}
|
||||
else if (message->tokenIds.size())
|
||||
{
|
||||
getView()->setMatches(m_storageAccess->getSearchMatchesForTokenIds(message->tokenIds));
|
||||
}
|
||||
else if (message->tokenNames.size())
|
||||
{
|
||||
std::vector<SearchMatch> matches;
|
||||
getView()->setMatches(matches);
|
||||
|
||||
for (const NameHierarchy& name : message->tokenNames)
|
||||
{
|
||||
getView()->setMatches(m_storageAccess->getSearchMatchesForTokenIds(message->tokenIds));
|
||||
matches.push_back(SearchMatch(name.getQualifiedName()));
|
||||
}
|
||||
else if ((message->isReplayed() || message->unknownNames.size()) && !message->tokenIds.size())
|
||||
|
||||
if (!matches.size())
|
||||
{
|
||||
std::vector<SearchMatch> matches;
|
||||
|
||||
for (const std::string& name : message->unknownNames)
|
||||
{
|
||||
matches.push_back(SearchMatch(name));
|
||||
}
|
||||
|
||||
if (!matches.size())
|
||||
{
|
||||
matches.push_back(SearchMatch("<invalid>"));
|
||||
}
|
||||
|
||||
getView()->setMatches(matches);
|
||||
matches.push_back(SearchMatch("<invalid>"));
|
||||
}
|
||||
|
||||
getView()->setMatches(matches);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,21 +64,6 @@ void SearchController::handleMessage(MessageFind* message)
|
||||
}
|
||||
}
|
||||
|
||||
void SearchController::handleMessage(MessageSearch* message)
|
||||
{
|
||||
const std::vector<SearchMatch>& matches = message->getMatches();
|
||||
|
||||
for (const SearchMatch& match : matches)
|
||||
{
|
||||
if (match.searchType == SearchMatch::SEARCH_COMMAND)
|
||||
{
|
||||
SearchMatch m = SearchMatch::createCommand(SearchMatch::getCommandType(match.getFullName()));
|
||||
getView()->setMatches(std::vector<SearchMatch>(1, m));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SearchController::handleMessage(MessageSearchAutocomplete* message)
|
||||
{
|
||||
TRACE("search autocomplete");
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateAll.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageFind.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageSearchAutocomplete.h"
|
||||
#include "utility/messaging/type/MessageSearchFullText.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
@@ -15,9 +15,9 @@ class SearchView;
|
||||
|
||||
class SearchController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateAll>
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageFind>
|
||||
, public MessageListener<MessageSearch>
|
||||
, public MessageListener<MessageSearchAutocomplete>
|
||||
, public MessageListener<MessageSearchFullText>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
@@ -27,9 +27,9 @@ public:
|
||||
~SearchController();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageActivateAll* message);
|
||||
virtual void handleMessage(MessageActivateTokens* message);
|
||||
virtual void handleMessage(MessageFind* message);
|
||||
virtual void handleMessage(MessageSearch* message);
|
||||
virtual void handleMessage(MessageSearchAutocomplete* message);
|
||||
virtual void handleMessage(MessageSearchFullText* message);
|
||||
virtual void handleMessage(MessageShowErrors* message);
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
#include "component/controller/UndoRedoController.h"
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageFlushUpdates.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include "component/view/UndoRedoView.h"
|
||||
#include "data/access/StorageAccess.h"
|
||||
|
||||
UndoRedoController::UndoRedoController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
{
|
||||
m_iterator = m_list.end();
|
||||
}
|
||||
@@ -38,30 +39,14 @@ UndoRedoController::Command::Command(std::shared_ptr<MessageBase> message, Order
|
||||
{
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageActivateEdge* message)
|
||||
void UndoRedoController::handleMessage(MessageActivateAll* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) &&
|
||||
static_cast<MessageActivateEdge*>(lastMessage())->getFullName() == message->getFullName())
|
||||
if (sameMessageTypeAsLast(message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(
|
||||
std::make_shared<MessageActivateEdge>(*message),
|
||||
(message->isAggregation() ? Command::ORDER_ACTIVATE : Command::ORDER_ADAPT)
|
||||
);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageActivateFile* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) &&
|
||||
static_cast<MessageActivateFile*>(lastMessage())->filePath == message->filePath)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(std::make_shared<MessageActivateFile>(*message), Command::ORDER_ACTIVATE);
|
||||
Command command(std::make_shared<MessageActivateAll>(*message), Command::ORDER_ACTIVATE);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
@@ -77,30 +62,18 @@ void UndoRedoController::handleMessage(MessageActivateLocalSymbols* message)
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageActivateNodes* message)
|
||||
void UndoRedoController::handleMessage(MessageActivateTokens* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) &&
|
||||
message->nodes.size() &&
|
||||
static_cast<MessageActivateNodes*>(lastMessage())->nodes.size() == message->nodes.size() &&
|
||||
static_cast<MessageActivateNodes*>(lastMessage())->nodes[0].nameHierarchy.getQualifiedNameWithSignature() ==
|
||||
message->nodes[0].nameHierarchy.getQualifiedNameWithSignature())
|
||||
static_cast<MessageActivateTokens*>(lastMessage())->tokenIds == message->tokenIds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(std::make_shared<MessageActivateNodes>(*message), Command::ORDER_ACTIVATE);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageActivateTokenIds* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) && message->tokenIds.size() &&
|
||||
static_cast<MessageActivateTokenIds*>(lastMessage())->tokenIds == message->tokenIds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(std::make_shared<MessageActivateTokenIds>(*message), Command::ORDER_ACTIVATE);
|
||||
Command command(
|
||||
std::make_shared<MessageActivateTokens>(*message),
|
||||
message->isEdge ? Command::ORDER_ADAPT : Command::ORDER_ACTIVATE
|
||||
);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
@@ -134,6 +107,33 @@ void UndoRedoController::handleMessage(MessageDeactivateEdge* message)
|
||||
m->setKeepContent(keepContent);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
std::list<Command> newList;
|
||||
|
||||
for (const Command& command : m_list)
|
||||
{
|
||||
if (command.order == Command::ORDER_ACTIVATE)
|
||||
{
|
||||
MessageActivateTokens* msg = dynamic_cast<MessageActivateTokens*>(command.message.get());
|
||||
if (msg)
|
||||
{
|
||||
if (msg->isAggregation)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
msg->isFromSearch = false;
|
||||
}
|
||||
|
||||
command.message->setIsReplayCleared(true);
|
||||
newList.insert(newList.end(), command);
|
||||
}
|
||||
}
|
||||
|
||||
m_list = newList;
|
||||
m_iterator = m_list.end();
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageGraphNodeBundleSplit* message)
|
||||
{
|
||||
Command command(std::make_shared<MessageGraphNodeBundleSplit>(*message), Command::ORDER_ADAPT);
|
||||
@@ -173,9 +173,7 @@ void UndoRedoController::handleMessage(MessageRedo* message)
|
||||
getView()->setRedoButtonEnabled(false);
|
||||
}
|
||||
|
||||
bool keepsContent = replayCommands(oldIterator);
|
||||
|
||||
MessageFlushUpdates(keepsContent).dispatch();
|
||||
replayCommands(oldIterator);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageRefresh* message)
|
||||
@@ -193,9 +191,7 @@ void UndoRedoController::handleMessage(MessageRefresh* message)
|
||||
}
|
||||
else
|
||||
{
|
||||
bool keepsContent = replayCommands();
|
||||
|
||||
MessageFlushUpdates(keepsContent).dispatch();
|
||||
replayCommands();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,15 +207,16 @@ void UndoRedoController::handleMessage(MessageScrollCode* message)
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageSearch* message)
|
||||
void UndoRedoController::handleMessage(MessageScrollGraph* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) &&
|
||||
static_cast<MessageSearch*>(lastMessage())->getMatchesAsString() == message->getMatchesAsString())
|
||||
if (sameMessageTypeAsLast(message))
|
||||
{
|
||||
static_cast<MessageScrollGraph*>(lastMessage())->xValue = message->xValue;
|
||||
static_cast<MessageScrollGraph*>(lastMessage())->yValue = message->yValue;
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(std::make_shared<MessageSearch>(*message), Command::ORDER_ACTIVATE);
|
||||
Command command(std::make_shared<MessageScrollGraph>(*message), Command::ORDER_VIEW, true);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
@@ -248,6 +245,18 @@ void UndoRedoController::handleMessage(MessageShowErrors* message)
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageShowReference* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) &&
|
||||
static_cast<MessageShowReference*>(lastMessage())->refIndex == message->refIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(std::make_shared<MessageShowReference>(*message), Command::ORDER_VIEW);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageShowScope* message)
|
||||
{
|
||||
Command command(std::make_shared<MessageShowScope>(*message), Command::ORDER_VIEW);
|
||||
@@ -290,12 +299,10 @@ void UndoRedoController::handleMessage(MessageUndo* message)
|
||||
|
||||
m_iterator = it;
|
||||
|
||||
bool keepsContent = replayCommands();
|
||||
|
||||
MessageFlushUpdates(keepsContent).dispatch();
|
||||
replayCommands();
|
||||
}
|
||||
|
||||
bool UndoRedoController::replayCommands()
|
||||
void UndoRedoController::replayCommands()
|
||||
{
|
||||
std::list<Command>::iterator startIterator = m_iterator;
|
||||
|
||||
@@ -305,25 +312,21 @@ bool UndoRedoController::replayCommands()
|
||||
}
|
||||
while (startIterator != m_list.begin() && startIterator->order != Command::ORDER_ACTIVATE);
|
||||
|
||||
return replayCommands(startIterator);
|
||||
replayCommands(startIterator);
|
||||
}
|
||||
|
||||
bool UndoRedoController::replayCommands(std::list<Command>::iterator it)
|
||||
void UndoRedoController::replayCommands(std::list<Command>::iterator it)
|
||||
{
|
||||
std::vector<std::list<Command>::iterator> viewCommands;
|
||||
bool keepsContent = true;
|
||||
|
||||
std::shared_ptr<MessageBase> m;
|
||||
while (it != m_iterator)
|
||||
{
|
||||
m = it->message;
|
||||
if (it->order != Command::ORDER_VIEW || it->replayLastOnly == false)
|
||||
{
|
||||
m->setIsReplayed(true);
|
||||
m->setIsLast(it == std::prev(m_iterator));
|
||||
m->dispatch();
|
||||
replayCommand(it);
|
||||
|
||||
if (!m->keepContent())
|
||||
if (!it->message->keepContent())
|
||||
{
|
||||
keepsContent = false;
|
||||
}
|
||||
@@ -356,14 +359,31 @@ bool UndoRedoController::replayCommands(std::list<Command>::iterator it)
|
||||
|
||||
for (size_t i = lastViewCommands.size(); i > 0; i--)
|
||||
{
|
||||
it = lastViewCommands[i - 1];
|
||||
m = it->message;
|
||||
m->setIsReplayed(true);
|
||||
m->setIsLast(it == std::prev(m_iterator));
|
||||
m->dispatch();
|
||||
replayCommand(lastViewCommands[i - 1]);
|
||||
}
|
||||
|
||||
return keepsContent;
|
||||
MessageFlushUpdates(keepsContent).dispatch();
|
||||
}
|
||||
|
||||
void UndoRedoController::replayCommand(std::list<Command>::iterator it)
|
||||
{
|
||||
std::shared_ptr<MessageBase> m = it->message;
|
||||
m->setIsReplayed(true);
|
||||
m->setIsLast(it == std::prev(m_iterator));
|
||||
|
||||
if (m->getType() == MessageActivateTokens::getStaticType())
|
||||
{
|
||||
MessageActivateTokens* msg = dynamic_cast<MessageActivateTokens*>(m.get());
|
||||
|
||||
if (!msg->isEdge && !msg->isAggregation)
|
||||
{
|
||||
msg->tokenIds = m_storageAccess->getNodeIdsForNameHierarchies(msg->tokenNames);
|
||||
msg->searchMatches.clear();
|
||||
}
|
||||
}
|
||||
|
||||
m->dispatch();
|
||||
m->setIsReplayCleared(false);
|
||||
}
|
||||
|
||||
void UndoRedoController::processCommand(Command command)
|
||||
@@ -425,7 +445,7 @@ bool UndoRedoController::sameMessageTypeAsLast(MessageBase* message) const
|
||||
return false;
|
||||
}
|
||||
|
||||
return std::prev(m_iterator)->message->getType() == message->getType();
|
||||
return lastMessage()->getType() == message->getType();
|
||||
}
|
||||
|
||||
MessageBase* UndoRedoController::lastMessage() const
|
||||
@@ -435,7 +455,7 @@ MessageBase* UndoRedoController::lastMessage() const
|
||||
|
||||
void UndoRedoController::dump() const
|
||||
{
|
||||
std::cout << "Undo Redo Stack:\n\n";
|
||||
std::cout << "\nUndo Redo Stack:\n----------\n";
|
||||
|
||||
std::list<Command>::const_iterator it = m_list.begin();
|
||||
while (it != m_list.end())
|
||||
@@ -450,7 +470,7 @@ void UndoRedoController::dump() const
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << it->message->getType() << " " << it->replayLastOnly;
|
||||
std::cout << it->message->getType();
|
||||
|
||||
if (it == m_iterator)
|
||||
{
|
||||
@@ -463,8 +483,7 @@ void UndoRedoController::dump() const
|
||||
|
||||
if (m_list.end() == m_iterator)
|
||||
{
|
||||
std::cout << " <-";
|
||||
std::cout << "<-" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "----------" << std::endl;
|
||||
}
|
||||
|
||||
@@ -5,22 +5,22 @@
|
||||
|
||||
#include "utility/messaging/MessageBase.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateEdge.h"
|
||||
#include "utility/messaging/type/MessageActivateFile.h"
|
||||
#include "utility/messaging/type/MessageActivateAll.h"
|
||||
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenIds.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageChangeFileView.h"
|
||||
#include "utility/messaging/type/MessageDeactivateEdge.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeExpand.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
#include "utility/messaging/type/MessageRedo.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageScrollCode.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageScrollGraph.h"
|
||||
#include "utility/messaging/type/MessageSearchFullText.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/messaging/type/MessageShowReference.h"
|
||||
#include "utility/messaging/type/MessageShowScope.h"
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
|
||||
@@ -31,22 +31,22 @@ class UndoRedoView;
|
||||
|
||||
class UndoRedoController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateEdge>
|
||||
, public MessageListener<MessageActivateFile>
|
||||
, public MessageListener<MessageActivateAll>
|
||||
, public MessageListener<MessageActivateLocalSymbols>
|
||||
, public MessageListener<MessageActivateNodes>
|
||||
, public MessageListener<MessageActivateTokenIds>
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageChangeFileView>
|
||||
, public MessageListener<MessageDeactivateEdge>
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
, public MessageListener<MessageGraphNodeBundleSplit>
|
||||
, public MessageListener<MessageGraphNodeExpand>
|
||||
, public MessageListener<MessageGraphNodeMove>
|
||||
, public MessageListener<MessageRedo>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageScrollCode>
|
||||
, public MessageListener<MessageSearch>
|
||||
, public MessageListener<MessageScrollGraph>
|
||||
, public MessageListener<MessageSearchFullText>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
, public MessageListener<MessageShowReference>
|
||||
, public MessageListener<MessageShowScope>
|
||||
, public MessageListener<MessageUndo>
|
||||
{
|
||||
@@ -75,27 +75,28 @@ private:
|
||||
bool replayLastOnly;
|
||||
};
|
||||
|
||||
virtual void handleMessage(MessageActivateEdge* message);
|
||||
virtual void handleMessage(MessageActivateFile* message);
|
||||
virtual void handleMessage(MessageActivateAll* message);
|
||||
virtual void handleMessage(MessageActivateLocalSymbols* message);
|
||||
virtual void handleMessage(MessageActivateNodes* message);
|
||||
virtual void handleMessage(MessageActivateTokenIds* message);
|
||||
virtual void handleMessage(MessageActivateTokens* message);
|
||||
virtual void handleMessage(MessageChangeFileView* message);
|
||||
virtual void handleMessage(MessageDeactivateEdge* message);
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
virtual void handleMessage(MessageGraphNodeBundleSplit* message);
|
||||
virtual void handleMessage(MessageGraphNodeExpand* message);
|
||||
virtual void handleMessage(MessageGraphNodeMove* message);
|
||||
virtual void handleMessage(MessageRedo* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
virtual void handleMessage(MessageScrollCode* message);
|
||||
virtual void handleMessage(MessageSearch* message);
|
||||
virtual void handleMessage(MessageScrollGraph* message);
|
||||
virtual void handleMessage(MessageSearchFullText* message);
|
||||
virtual void handleMessage(MessageShowErrors* message);
|
||||
virtual void handleMessage(MessageShowReference* message);
|
||||
virtual void handleMessage(MessageShowScope* message);
|
||||
virtual void handleMessage(MessageUndo* message);
|
||||
|
||||
bool replayCommands();
|
||||
bool replayCommands(std::list<Command>::iterator iterator);
|
||||
void replayCommands();
|
||||
void replayCommands(std::list<Command>::iterator it);
|
||||
void replayCommand(std::list<Command>::iterator it);
|
||||
|
||||
void processCommand(Command command);
|
||||
|
||||
@@ -104,6 +105,8 @@ private:
|
||||
|
||||
void dump() const;
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
|
||||
std::list<Command> m_list;
|
||||
std::list<Command>::iterator m_iterator;
|
||||
};
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
virtual void scrollToLine(const FilePath filePath, unsigned int line) = 0;
|
||||
virtual void scrollToDefinition(bool ignoreActiveReference) = 0;
|
||||
|
||||
virtual bool isInListMode() const = 0;
|
||||
|
||||
private:
|
||||
CodeController* getController();
|
||||
};
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
virtual void resizeView() = 0;
|
||||
|
||||
virtual Vec2i getViewSize() const = 0;
|
||||
|
||||
virtual void scrollToValues(int xValue, int yValue) = 0;
|
||||
};
|
||||
|
||||
#endif // GRAPH_VIEW_H
|
||||
|
||||
@@ -491,6 +491,30 @@ Node::NodeType PersistentStorage::getNodeTypeForNodeWithId(Id nodeId) const
|
||||
return Node::intToType(m_sqliteStorage.getFirstById<StorageNode>(nodeId).type);
|
||||
}
|
||||
|
||||
std::vector<NameHierarchy> PersistentStorage::getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const
|
||||
{
|
||||
std::vector<NameHierarchy> nameHierarchies;
|
||||
for (const StorageNode& storageNode : m_sqliteStorage.getAllByIds<StorageNode>(nodeIds))
|
||||
{
|
||||
nameHierarchies.push_back(NameHierarchy::deserialize(storageNode.serializedName));
|
||||
}
|
||||
return nameHierarchies;
|
||||
}
|
||||
|
||||
std::vector<Id> PersistentStorage::getNodeIdsForNameHierarchies(const std::vector<NameHierarchy> nameHierarchies) const
|
||||
{
|
||||
std::vector<Id> nodeIds;
|
||||
for (const NameHierarchy& name : nameHierarchies)
|
||||
{
|
||||
Id nodeId = getIdForNodeWithNameHierarchy(name);
|
||||
if (nodeId)
|
||||
{
|
||||
nodeIds.push_back(nodeId);
|
||||
}
|
||||
}
|
||||
return nodeIds;
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> PersistentStorage::getFullTextSearchLocations(
|
||||
const std::string& searchTerm, bool caseSensitive
|
||||
) const
|
||||
@@ -660,32 +684,31 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(const
|
||||
for (const SearchResult& result : results)
|
||||
{
|
||||
SearchMatch match;
|
||||
|
||||
const StorageNode* firstNode = nullptr;
|
||||
|
||||
for (const Id& elementId : result.elementIds)
|
||||
{
|
||||
if (elementId != 0)
|
||||
{
|
||||
const StorageNode& node = storageNodeMap[elementId];
|
||||
match.nameHierarchies.push_back(NameHierarchy::deserialize(node.serializedName));
|
||||
match.tokenIds.push_back(elementId);
|
||||
|
||||
if (!match.hasChildren)
|
||||
{
|
||||
match.hasChildren = m_hierarchyCache.nodeHasChildren(node.id);
|
||||
match.hasChildren = m_hierarchyCache.nodeHasChildren(elementId);
|
||||
}
|
||||
|
||||
if (!firstNode)
|
||||
{
|
||||
firstNode = &node;
|
||||
firstNode = &storageNodeMap[elementId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match.name = result.text;
|
||||
|
||||
match.text = result.text;
|
||||
|
||||
const size_t idx = m_hierarchyCache.getIndexOfLastVisibleParentNode(firstNode->id);
|
||||
const NameHierarchy& name = match.nameHierarchies[0];
|
||||
const NameHierarchy& name = NameHierarchy::deserialize(firstNode->serializedName);
|
||||
match.text = name.getRange(idx, name.size()).getQualifiedName();
|
||||
match.subtext = name.getRange(0, idx).getQualifiedName();
|
||||
|
||||
@@ -717,9 +740,8 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionFileMatches(const s
|
||||
{
|
||||
SearchMatch match;
|
||||
|
||||
match.nameHierarchies.push_back(NameHierarchy(result.text));
|
||||
|
||||
match.name = result.text;
|
||||
match.tokenIds = utility::toVector(result.elementIds);
|
||||
|
||||
FilePath path(match.name);
|
||||
match.text = path.fileName();
|
||||
@@ -770,31 +792,36 @@ std::vector<SearchMatch> PersistentStorage::getSearchMatchesForTokenIds(const st
|
||||
// In that case there should be only one search match.
|
||||
std::vector<SearchMatch> matches;
|
||||
|
||||
// fetch StorageNodes for node ids
|
||||
std::map<Id, StorageNode> storageNodeMap;
|
||||
for (StorageNode& node : m_sqliteStorage.getAllByIds<StorageNode>(elementIds))
|
||||
{
|
||||
storageNodeMap.emplace(node.id, node);
|
||||
}
|
||||
|
||||
for (Id elementId : elementIds)
|
||||
{
|
||||
SearchMatch match;
|
||||
|
||||
NameHierarchy nameHierarchy = NameHierarchy::deserialize(m_sqliteStorage.getFirstById<StorageNode>(elementId).serializedName);
|
||||
match.name = nameHierarchy.getQualifiedName();
|
||||
match.text = nameHierarchy.getRawName();
|
||||
match.nameHierarchies.push_back(nameHierarchy.getQualifiedName());
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
if (m_sqliteStorage.isFile(elementId))
|
||||
{
|
||||
match.text = FilePath(match.text).fileName();
|
||||
match.nodeType = Node::NODE_FILE;
|
||||
}
|
||||
else if (m_sqliteStorage.isNode(elementId))
|
||||
{
|
||||
StorageNode node = m_sqliteStorage.getFirstById<StorageNode>(elementId);
|
||||
match.nodeType = Node::intToType(node.type);
|
||||
}
|
||||
else
|
||||
if (storageNodeMap.find(elementId) == storageNodeMap.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
StorageNode node = storageNodeMap[elementId];
|
||||
|
||||
SearchMatch match;
|
||||
NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
match.name = nameHierarchy.getQualifiedName();
|
||||
match.text = nameHierarchy.getRawName();
|
||||
|
||||
match.tokenIds.push_back(elementId);
|
||||
match.nodeType = Node::intToType(node.type);
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
if (match.nodeType == Node::NODE_FILE)
|
||||
{
|
||||
match.text = FilePath(match.text).fileName();
|
||||
}
|
||||
|
||||
matches.push_back(match);
|
||||
}
|
||||
|
||||
@@ -1070,45 +1097,6 @@ bool PersistentStorage::checkNodeExistsByName(const std::string& serializedName)
|
||||
return m_sqliteStorage.checkNodeExistsByName(serializedName);
|
||||
}
|
||||
|
||||
std::vector<Id> PersistentStorage::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
|
||||
{
|
||||
FilePath rootPath = getDbFilePath().parentDirectory();
|
||||
std::set<Id> idSet;
|
||||
for (const SearchMatch& match : matches)
|
||||
{
|
||||
if (match.nodeType == Node::NODE_FILE)
|
||||
{
|
||||
FilePath path(match.subtext);
|
||||
if (!path.isAbsolute())
|
||||
{
|
||||
path = rootPath.concat(path).canonical();
|
||||
}
|
||||
|
||||
idSet.insert(m_sqliteStorage.getFileByPath(path.str()).id);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < match.nameHierarchies.size(); i++)
|
||||
{
|
||||
idSet.insert(
|
||||
m_sqliteStorage.getNodeBySerializedName(NameHierarchy::serialize(match.nameHierarchies[i])).id
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Id> ids;
|
||||
for (std::set<Id>::const_iterator it = idSet.begin(); it != idSet.end(); it++)
|
||||
{
|
||||
if (*it != 0)
|
||||
{
|
||||
ids.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
Id PersistentStorage::getTokenIdForFileNode(const FilePath& filePath) const
|
||||
{
|
||||
return m_sqliteStorage.getFileByPath(filePath.str()).id;
|
||||
|
||||
@@ -104,6 +104,9 @@ public:
|
||||
virtual NameHierarchy getNameHierarchyForNodeWithId(Id nodeId) const;
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id nodeId) const;
|
||||
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const;
|
||||
virtual std::vector<Id> getNodeIdsForNameHierarchies(const std::vector<NameHierarchy> nameHierarchies) const;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getFullTextSearchLocations(
|
||||
const std::string& searchTerm, bool caseSensitive) const;
|
||||
virtual std::vector<SearchMatch> getAutocompletionMatches(const std::string& query) const;
|
||||
@@ -123,7 +126,6 @@ public:
|
||||
virtual std::vector<Id> getLocalSymbolIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||
virtual bool checkNodeExistsByName(const std::string& serializedName) const;
|
||||
|
||||
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const;
|
||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getTokenLocationsForTokenIds(
|
||||
|
||||
@@ -44,6 +44,9 @@ public:
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const = 0;
|
||||
virtual bool checkNodeExistsByName(const std::string& serializedName) const = 0;
|
||||
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const = 0;
|
||||
virtual std::vector<Id> getNodeIdsForNameHierarchies(const std::vector<NameHierarchy> nameHierarchies) const = 0;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getFullTextSearchLocations(
|
||||
const std::string& searchTerm, bool caseSensitive) const = 0;
|
||||
virtual std::vector<SearchMatch> getAutocompletionMatches(const std::string& query) const = 0;
|
||||
@@ -57,7 +60,6 @@ public:
|
||||
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const = 0;
|
||||
virtual std::vector<Id> getLocalSymbolIdsForLocationIds(const std::vector<Id>& locationIds) const = 0;
|
||||
|
||||
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const = 0;
|
||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const = 0;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getTokenLocationsForTokenIds(
|
||||
|
||||
@@ -77,6 +77,16 @@ bool StorageAccessProxy::checkEdgeExists(Id edgeId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
NameHierarchy StorageAccessProxy::getNameHierarchyForNodeWithId(Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getNameHierarchyForNodeWithId(id);
|
||||
}
|
||||
|
||||
return NameHierarchy();
|
||||
}
|
||||
|
||||
Node::NodeType StorageAccessProxy::getNodeTypeForNodeWithId(Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
@@ -95,24 +105,22 @@ bool StorageAccessProxy::checkNodeExistsByName(const std::string& serializedName
|
||||
return false;
|
||||
}
|
||||
|
||||
NameHierarchy StorageAccessProxy::getNameHierarchyForNodeWithId(Id id) const
|
||||
std::vector<NameHierarchy> StorageAccessProxy::getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getNameHierarchyForNodeWithId(id);
|
||||
return m_subject->getNameHierarchiesForNodeIds(nodeIds);
|
||||
}
|
||||
|
||||
return NameHierarchy();
|
||||
return std::vector<NameHierarchy>();
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> StorageAccessProxy::getAutocompletionMatches(const std::string& query) const
|
||||
std::vector<Id> StorageAccessProxy::getNodeIdsForNameHierarchies(const std::vector<NameHierarchy> nameHierarchies) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getAutocompletionMatches(query);
|
||||
return m_subject->getNodeIdsForNameHierarchies(nameHierarchies);
|
||||
}
|
||||
|
||||
return std::vector<SearchMatch>();
|
||||
return std::vector<Id>();
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> StorageAccessProxy::getFullTextSearchLocations(
|
||||
@@ -126,6 +134,16 @@ std::shared_ptr<TokenLocationCollection> StorageAccessProxy::getFullTextSearchLo
|
||||
return std::make_shared<TokenLocationCollection>();
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> StorageAccessProxy::getAutocompletionMatches(const std::string& query) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getAutocompletionMatches(query);
|
||||
}
|
||||
|
||||
return std::vector<SearchMatch>();
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> StorageAccessProxy::getSearchMatchesForTokenIds(const std::vector<Id>& tokenIds) const
|
||||
{
|
||||
if (hasSubject())
|
||||
@@ -186,16 +204,6 @@ std::vector<Id> StorageAccessProxy::getLocalSymbolIdsForLocationIds(const std::v
|
||||
return std::vector<Id>();
|
||||
}
|
||||
|
||||
std::vector<Id> StorageAccessProxy::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getTokenIdsForMatches(matches);
|
||||
}
|
||||
|
||||
return std::vector<Id>();
|
||||
}
|
||||
|
||||
Id StorageAccessProxy::getTokenIdForFileNode(const FilePath& filePath) const
|
||||
{
|
||||
if (hasSubject())
|
||||
|
||||
@@ -29,6 +29,9 @@ public:
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const;
|
||||
virtual bool checkNodeExistsByName(const std::string& serializedName) const;
|
||||
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const;
|
||||
virtual std::vector<Id> getNodeIdsForNameHierarchies(const std::vector<NameHierarchy> nameHierarchies) const;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getFullTextSearchLocations(
|
||||
const std::string& searchTerm, bool caseSensitive) const;
|
||||
virtual std::vector<SearchMatch> getAutocompletionMatches(const std::string& query) const;
|
||||
@@ -42,7 +45,6 @@ public:
|
||||
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||
virtual std::vector<Id> getLocalSymbolIdsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||
|
||||
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const;
|
||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getTokenLocationsForTokenIds(
|
||||
|
||||
@@ -54,6 +54,7 @@ struct SearchMatch
|
||||
std::string getSearchTypeName() const;
|
||||
|
||||
std::string name;
|
||||
std::vector<Id> tokenIds;
|
||||
|
||||
std::string text;
|
||||
std::string subtext;
|
||||
@@ -66,8 +67,6 @@ struct SearchMatch
|
||||
|
||||
int score;
|
||||
|
||||
std::vector<NameHierarchy> nameHierarchies;
|
||||
|
||||
bool hasChildren;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class MessageBase
|
||||
public:
|
||||
MessageBase()
|
||||
: m_isReplayed(false)
|
||||
, m_isReplayCleared(false)
|
||||
, m_sendAsTask(true)
|
||||
, m_keepContent(false)
|
||||
, m_isLast(true)
|
||||
@@ -43,6 +44,16 @@ public:
|
||||
m_isReplayed = isReplayed;
|
||||
}
|
||||
|
||||
bool isReplayCleared() const
|
||||
{
|
||||
return m_isReplayCleared;
|
||||
}
|
||||
|
||||
void setIsReplayCleared(bool isReplayCleared)
|
||||
{
|
||||
m_isReplayCleared = isReplayCleared;
|
||||
}
|
||||
|
||||
bool isLast() const
|
||||
{
|
||||
return m_isLast;
|
||||
@@ -85,8 +96,11 @@ public:
|
||||
|
||||
private:
|
||||
bool m_isReplayed;
|
||||
bool m_isReplayCleared;
|
||||
|
||||
bool m_sendAsTask;
|
||||
bool m_keepContent;
|
||||
|
||||
bool m_isLast;
|
||||
bool m_isLogged;
|
||||
};
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
|
||||
class MessageActivateNodes
|
||||
: public Message<MessageActivateNodes>
|
||||
{
|
||||
@@ -13,7 +11,6 @@ public:
|
||||
struct ActiveNode
|
||||
{
|
||||
Id nodeId;
|
||||
Node::NodeType type;
|
||||
NameHierarchy nameHierarchy;
|
||||
};
|
||||
|
||||
@@ -21,21 +18,10 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void addNode(Id tokenId, Node::NodeType type, const NameHierarchy& nameHierarchy)
|
||||
void addNode(Id tokenId, const NameHierarchy& nameHierarchy)
|
||||
{
|
||||
ActiveNode node;
|
||||
node.nodeId = tokenId;
|
||||
node.type = type;
|
||||
node.nameHierarchy = nameHierarchy;
|
||||
|
||||
nodes.push_back(node);
|
||||
}
|
||||
|
||||
void addNode(const NameHierarchy& nameHierarchy)
|
||||
{
|
||||
ActiveNode node;
|
||||
node.nodeId = 0;
|
||||
node.type = Node::NODE_NON_INDEXED;
|
||||
node.nameHierarchy = nameHierarchy;
|
||||
|
||||
nodes.push_back(node);
|
||||
|
||||
@@ -4,19 +4,18 @@
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "data/search/SearchMatch.h"
|
||||
|
||||
class MessageActivateTokens
|
||||
: public Message<MessageActivateTokens>
|
||||
{
|
||||
public:
|
||||
MessageActivateTokens(const MessageBase* other, const std::vector<Id>& tokenIds)
|
||||
: tokenIds(tokenIds)
|
||||
, isEdge(false)
|
||||
MessageActivateTokens(const MessageBase* other)
|
||||
: isEdge(false)
|
||||
, isAggregation(false)
|
||||
, isFromSearch(false)
|
||||
{
|
||||
setIsReplayed(other->isReplayed());
|
||||
setKeepContent(other->keepContent());
|
||||
setIsLast(other->isLast());
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
@@ -32,13 +31,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<Id> tokenIds;
|
||||
std::vector<Id> tokenIds;
|
||||
std::vector<NameHierarchy> tokenNames;
|
||||
std::vector<SearchMatch> searchMatches;
|
||||
|
||||
bool isEdge;
|
||||
bool isAggregation;
|
||||
bool isFromSearch;
|
||||
|
||||
std::vector<std::string> unknownNames;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ACTIVATE_TOKENS_H
|
||||
|
||||
@@ -13,11 +13,12 @@ public:
|
||||
{
|
||||
FILE_MINIMIZED,
|
||||
FILE_SNIPPETS,
|
||||
FILE_MAXIMIZED
|
||||
FILE_MAXIMIZED,
|
||||
FILE_DEFAULT_FOR_MODE
|
||||
};
|
||||
|
||||
MessageChangeFileView(
|
||||
const FilePath filePath,
|
||||
const FilePath& filePath,
|
||||
FileState state,
|
||||
bool needsData,
|
||||
bool showErrors
|
||||
@@ -41,6 +42,7 @@ public:
|
||||
case FILE_MINIMIZED: os << "minimize"; break;
|
||||
case FILE_SNIPPETS: os << "snippets"; break;
|
||||
case FILE_MAXIMIZED: os << "maximize"; break;
|
||||
case FILE_DEFAULT_FOR_MODE: os << "default"; break;
|
||||
}
|
||||
|
||||
if (needsData)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef MESSAGE_SCROLL_GRAPH_H
|
||||
#define MESSAGE_SCROLL_GRAPH_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageScrollGraph
|
||||
: public Message<MessageScrollGraph>
|
||||
{
|
||||
public:
|
||||
MessageScrollGraph(int xValue, int yValue)
|
||||
: xValue(xValue)
|
||||
, yValue(yValue)
|
||||
{
|
||||
setIsLogged(false);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageScrollGraph";
|
||||
}
|
||||
|
||||
int xValue;
|
||||
int yValue;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SCROLL_GRAPH_H
|
||||
@@ -49,6 +49,22 @@ public:
|
||||
return m_matches;
|
||||
}
|
||||
|
||||
std::vector<Id> getTokenIdsOfMatches() const
|
||||
{
|
||||
std::vector<Id> tokenIds;
|
||||
for (const SearchMatch& match : m_matches)
|
||||
{
|
||||
for (const Id tokenId : match.tokenIds)
|
||||
{
|
||||
if (tokenId)
|
||||
{
|
||||
tokenIds.push_back(tokenId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tokenIds;
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << getMatchesAsString();
|
||||
|
||||
@@ -8,10 +8,11 @@ class MessageShowReference
|
||||
: public Message<MessageShowReference>
|
||||
{
|
||||
public:
|
||||
MessageShowReference(size_t refIndex, Id tokenId, Id locationId)
|
||||
MessageShowReference(size_t refIndex, Id tokenId, Id locationId, bool animated)
|
||||
: refIndex(refIndex)
|
||||
, tokenId(tokenId)
|
||||
, locationId(locationId)
|
||||
, animated(animated)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,6 +29,7 @@ public:
|
||||
const size_t refIndex;
|
||||
const Id tokenId;
|
||||
const Id locationId;
|
||||
const bool animated;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_REFERENCE_H
|
||||
|
||||
@@ -250,7 +250,7 @@ bool QtCodeFile::isCollapsed() const
|
||||
return m_isCollapsed;
|
||||
}
|
||||
|
||||
void QtCodeFile::requestContent()
|
||||
void QtCodeFile::requestContent(bool isFirstInList)
|
||||
{
|
||||
if (!isCollapsed() || m_contentRequested)
|
||||
{
|
||||
@@ -260,15 +260,15 @@ void QtCodeFile::requestContent()
|
||||
|
||||
m_contentRequested = true;
|
||||
|
||||
MessageChangeFileView msg(
|
||||
m_filePath,
|
||||
m_isWholeFile ? MessageChangeFileView::FILE_MAXIMIZED : MessageChangeFileView::FILE_SNIPPETS,
|
||||
isCollapsed(),
|
||||
m_navigator->hasErrors()
|
||||
);
|
||||
MessageChangeFileView::FileState state =
|
||||
isFirstInList ? MessageChangeFileView::FILE_DEFAULT_FOR_MODE : MessageChangeFileView::FILE_SNIPPETS;
|
||||
|
||||
msg.setIsReplayed(true);
|
||||
msg.dispatch();
|
||||
if (m_isWholeFile)
|
||||
{
|
||||
state = MessageChangeFileView::FILE_MAXIMIZED;
|
||||
}
|
||||
|
||||
MessageChangeFileView(m_filePath, state, isCollapsed(), m_navigator->hasErrors()).dispatch();
|
||||
}
|
||||
|
||||
void QtCodeFile::updateContent()
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
bool isCollapsed() const;
|
||||
|
||||
void requestContent();
|
||||
void requestContent(bool isFirstInList = false);
|
||||
void updateContent();
|
||||
|
||||
void setWholeFile(bool isWholeFile, int refCount);
|
||||
|
||||
@@ -101,9 +101,9 @@ void QtCodeFileList::addCodeSnippet(
|
||||
file->setModificationTime(params.modificationTime);
|
||||
}
|
||||
|
||||
void QtCodeFileList::requestFileContent(const FilePath& filePath)
|
||||
void QtCodeFileList::requestFileContent(const FilePath& filePath, bool isFirstInList)
|
||||
{
|
||||
getFile(filePath)->requestContent();
|
||||
getFile(filePath)->requestContent(isFirstInList);
|
||||
}
|
||||
|
||||
bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop)
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false);
|
||||
|
||||
virtual void requestFileContent(const FilePath& filePath);
|
||||
void requestFileContent(const FilePath& filePath, bool isFirstInList = false);
|
||||
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop);
|
||||
|
||||
virtual void updateFiles();
|
||||
|
||||
@@ -142,15 +142,12 @@ void QtCodeFileSingle::requestFileContent(const FilePath& filePath)
|
||||
|
||||
m_contentRequested = true;
|
||||
|
||||
MessageChangeFileView msg(
|
||||
MessageChangeFileView(
|
||||
filePath,
|
||||
MessageChangeFileView::FILE_MAXIMIZED,
|
||||
MessageChangeFileView::FILE_DEFAULT_FOR_MODE,
|
||||
true,
|
||||
m_navigator->hasErrors()
|
||||
);
|
||||
|
||||
msg.setIsReplayed(true);
|
||||
msg.dispatch();
|
||||
).dispatch();
|
||||
}
|
||||
|
||||
bool QtCodeFileSingle::requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop)
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false) override;
|
||||
|
||||
virtual void requestFileContent(const FilePath& filePath) override;
|
||||
void requestFileContent(const FilePath& filePath);
|
||||
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop) override;
|
||||
|
||||
virtual void updateFiles() override;
|
||||
|
||||
@@ -22,7 +22,6 @@ public:
|
||||
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false) = 0;
|
||||
|
||||
virtual void requestFileContent(const FilePath& filePath) = 0;
|
||||
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop) = 0;
|
||||
|
||||
virtual void updateFiles() = 0;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageCodeViewExpandedInitialFiles.h"
|
||||
#include "utility/messaging/type/MessageScrollCode.h"
|
||||
#include "utility/messaging/type/MessageShowReference.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "data/location/TokenLocation.h"
|
||||
@@ -321,6 +320,11 @@ size_t QtCodeNavigator::getFatalErrorCountForFile(const FilePath& filePath) cons
|
||||
return fatalErrorCount;
|
||||
}
|
||||
|
||||
bool QtCodeNavigator::isInListMode() const
|
||||
{
|
||||
return m_mode == MODE_LIST;
|
||||
}
|
||||
|
||||
void QtCodeNavigator::showActiveSnippet(
|
||||
const std::vector<Id>& activeTokenIds, std::shared_ptr<TokenLocationCollection> collection, bool scrollTo)
|
||||
{
|
||||
@@ -442,7 +446,7 @@ void QtCodeNavigator::setupFiles()
|
||||
{
|
||||
if (filePathsToExpand.find(ref.filePath) == filePathsToExpand.end())
|
||||
{
|
||||
m_list->requestFileContent(ref.filePath);
|
||||
m_list->requestFileContent(ref.filePath, filePathsToExpand.size() == 0);
|
||||
filePathsToExpand.insert(ref.filePath);
|
||||
|
||||
if (filePathsToExpand.size() >= 3)
|
||||
@@ -626,10 +630,7 @@ void QtCodeNavigator::requestScroll(const FilePath& filePath, uint lineNumber, I
|
||||
}
|
||||
}
|
||||
|
||||
if (m_scrollRequest.filePath.empty())
|
||||
{
|
||||
m_scrollRequest = req;
|
||||
}
|
||||
m_scrollRequest = req;
|
||||
|
||||
m_singleHasNewFile = false;
|
||||
}
|
||||
@@ -755,19 +756,7 @@ void QtCodeNavigator::setMode(Mode mode)
|
||||
void QtCodeNavigator::showCurrentReference(bool fromUI)
|
||||
{
|
||||
const Reference& ref = m_references[m_refIndex - 1];
|
||||
|
||||
setCurrentActiveLocationIds(std::vector<Id>(1, ref.locationId));
|
||||
updateFiles();
|
||||
|
||||
requestScroll(ref.filePath, 0, ref.locationId, fromUI, false);
|
||||
emit scrollRequest();
|
||||
|
||||
updateRefLabel();
|
||||
|
||||
if (fromUI)
|
||||
{
|
||||
MessageShowReference(m_refIndex - 1, ref.tokenId, ref.locationId).dispatch();
|
||||
}
|
||||
MessageShowReference(m_refIndex, ref.tokenId, ref.locationId, fromUI).dispatch();
|
||||
}
|
||||
|
||||
void QtCodeNavigator::updateRefLabel()
|
||||
@@ -817,6 +806,28 @@ void QtCodeNavigator::handleMessage(MessageFinishedParsing* message)
|
||||
);
|
||||
}
|
||||
|
||||
void QtCodeNavigator::handleMessage(MessageShowReference* message)
|
||||
{
|
||||
m_refIndex = message->refIndex;
|
||||
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
if (m_refIndex > 0)
|
||||
{
|
||||
const Reference& ref = m_references[m_refIndex - 1];
|
||||
setCurrentActiveLocationIds(std::vector<Id>(1, ref.locationId));
|
||||
updateFiles();
|
||||
|
||||
requestScroll(ref.filePath, 0, ref.locationId, message->animated, false);
|
||||
emit scrollRequest();
|
||||
}
|
||||
|
||||
updateRefLabel();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtCodeNavigator::handleMessage(MessageSwitchColorScheme* message)
|
||||
{
|
||||
m_onQtThread(
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageShowReference.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
|
||||
@@ -23,6 +24,7 @@ class QtCodeNavigator
|
||||
: public QWidget
|
||||
, public MessageListener<MessageCodeReference>
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
, public MessageListener<MessageShowReference>
|
||||
, public MessageListener<MessageSwitchColorScheme>
|
||||
, public MessageListener<MessageWindowFocus>
|
||||
{
|
||||
@@ -62,6 +64,8 @@ public:
|
||||
bool hasErrors() const;
|
||||
size_t getFatalErrorCountForFile(const FilePath& filePath) const;
|
||||
|
||||
bool isInListMode() const;
|
||||
|
||||
void showActiveSnippet(
|
||||
const std::vector<Id>& activeTokenIds, std::shared_ptr<TokenLocationCollection> collection, bool scrollTo);
|
||||
|
||||
@@ -147,6 +151,7 @@ private:
|
||||
|
||||
void handleMessage(MessageCodeReference* message);
|
||||
void handleMessage(MessageFinishedParsing* message);
|
||||
void handleMessage(MessageShowReference* message);
|
||||
void handleMessage(MessageSwitchColorScheme* message);
|
||||
void handleMessage(MessageWindowFocus* message);
|
||||
|
||||
|
||||
@@ -175,6 +175,11 @@ void QtCodeView::scrollToDefinition(bool ignoreActiveReference)
|
||||
);
|
||||
}
|
||||
|
||||
bool QtCodeView::isInListMode() const
|
||||
{
|
||||
return m_widget->isInListMode();
|
||||
}
|
||||
|
||||
void QtCodeView::doShowCodeSnippets(
|
||||
const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds, bool setupFiles)
|
||||
{
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
virtual void scrollToLine(const FilePath filePath, unsigned int line);
|
||||
virtual void scrollToDefinition(bool ignoreActiveReference);
|
||||
|
||||
virtual bool isInListMode() const;
|
||||
|
||||
private:
|
||||
void doShowCodeSnippets(
|
||||
const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds, bool setupFiles);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/messaging/type/MessageDeactivateEdge.h"
|
||||
#include "utility/messaging/type/MessageScrollGraph.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/graphics/QtGraphicsView.h"
|
||||
@@ -40,6 +41,7 @@ QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
||||
, m_focusInFunctor(std::bind(&QtGraphView::doFocusIn, this, std::placeholders::_1))
|
||||
, m_focusOutFunctor(std::bind(&QtGraphView::doFocusOut, this, std::placeholders::_1))
|
||||
, m_scrollToTop(false)
|
||||
, m_restoreScroll(false)
|
||||
, m_isIndexedList(false)
|
||||
{
|
||||
}
|
||||
@@ -77,6 +79,9 @@ void QtGraphView::initView()
|
||||
m_scrollSpeedChangeListenerHorizontal.setScrollBar(view->horizontalScrollBar());
|
||||
m_scrollSpeedChangeListenerVertical.setScrollBar(view->verticalScrollBar());
|
||||
|
||||
connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrolled(int)));
|
||||
connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrolled(int)));
|
||||
|
||||
doRefreshView();
|
||||
}
|
||||
|
||||
@@ -114,6 +119,12 @@ Vec2i QtGraphView::getViewSize() const
|
||||
return Vec2i(view->width() / zoomFactor - 60, view->height() / zoomFactor - 60);
|
||||
}
|
||||
|
||||
void QtGraphView::scrollToValues(int xValue, int yValue)
|
||||
{
|
||||
m_restoreScroll = true;
|
||||
m_scrollValues = Vec2i(xValue, yValue);
|
||||
}
|
||||
|
||||
void QtGraphView::updateScrollBars()
|
||||
{
|
||||
QGraphicsView* view = getView();
|
||||
@@ -121,7 +132,12 @@ void QtGraphView::updateScrollBars()
|
||||
QScrollBar* hb = view->horizontalScrollBar();
|
||||
QScrollBar* vb = view->verticalScrollBar();
|
||||
|
||||
if (m_scrollToTop)
|
||||
if (m_restoreScroll)
|
||||
{
|
||||
hb->setValue(m_scrollValues.x());
|
||||
vb->setValue(m_scrollValues.y());
|
||||
}
|
||||
else if (m_scrollToTop)
|
||||
{
|
||||
vb->setValue(vb->minimum());
|
||||
}
|
||||
@@ -201,6 +217,13 @@ void QtGraphView::pressedCharacterKey(QChar c)
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphView::scrolled(int)
|
||||
{
|
||||
QGraphicsView* view = getView();
|
||||
|
||||
MessageScrollGraph(view->horizontalScrollBar()->value(), view->verticalScrollBar()->value()).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphView::switchToNewGraphData()
|
||||
{
|
||||
m_oldGraph = m_graph;
|
||||
@@ -223,9 +246,12 @@ void QtGraphView::switchToNewGraphData()
|
||||
|
||||
doResize();
|
||||
|
||||
if (m_scrollToTop)
|
||||
if (m_scrollToTop || m_restoreScroll)
|
||||
{
|
||||
updateScrollBars();
|
||||
|
||||
m_scrollToTop = false;
|
||||
m_restoreScroll = false;
|
||||
}
|
||||
|
||||
// Manually hover the item below the mouse cursor.
|
||||
@@ -568,7 +594,8 @@ void QtGraphView::compareNodesRecursive(
|
||||
dynamic_cast<QtGraphNodeAccess*>((*it).get())->getAccessKind() ==
|
||||
dynamic_cast<QtGraphNodeAccess*>((*it2).get())->getAccessKind()) ||
|
||||
((*it)->isExpandToggleNode() && (*it2)->isExpandToggleNode()) ||
|
||||
((*it)->isBundleNode() && (*it2)->isBundleNode() && (*it)->getTokenId() == (*it2)->getTokenId()))
|
||||
((*it)->isBundleNode() && (*it2)->isBundleNode() && (*it)->getTokenId() == (*it2)->getTokenId()) ||
|
||||
((*it)->isQualifierNode() && (*it2)->isQualifierNode() && (*it)->getTokenId() == (*it2)->getTokenId()))
|
||||
{
|
||||
remainingNodes->push_back(std::pair<QtGraphNode*, QtGraphNode*>((*it).get(), (*it2).get()));
|
||||
compareNodesRecursive(
|
||||
|
||||
@@ -48,11 +48,14 @@ public:
|
||||
|
||||
virtual Vec2i getViewSize() const;
|
||||
|
||||
virtual void scrollToValues(int xValue, int yValue);
|
||||
|
||||
private slots:
|
||||
void updateScrollBars();
|
||||
void finishedTransition();
|
||||
void clickedInEmptySpace();
|
||||
void pressedCharacterKey(QChar c);
|
||||
void scrolled(int);
|
||||
|
||||
private:
|
||||
void switchToNewGraphData();
|
||||
@@ -114,6 +117,8 @@ private:
|
||||
|
||||
std::shared_ptr<QtGraphNode> m_activeNode;
|
||||
bool m_scrollToTop;
|
||||
bool m_restoreScroll;
|
||||
Vec2i m_scrollValues;
|
||||
bool m_isIndexedList;
|
||||
|
||||
std::shared_ptr<QSequentialAnimationGroup> m_transition;
|
||||
|
||||
@@ -85,8 +85,10 @@ void QtGraphNodeData::onClick()
|
||||
return;
|
||||
}
|
||||
|
||||
FilePath path = getFilePath();
|
||||
|
||||
MessageActivateNodes message;
|
||||
message.addNode(m_data->getId(), m_data->getType(), m_data->getNameHierarchy());
|
||||
message.addNode(m_data->getId(), path.empty() ? m_data->getNameHierarchy() : path.str());
|
||||
message.dispatch();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ bool QtGraphNodeQualifier::setPosition(const Vec2i& pos)
|
||||
void QtGraphNodeQualifier::onClick()
|
||||
{
|
||||
MessageActivateNodes msg;
|
||||
msg.addNode(m_qualifierName);
|
||||
msg.addNode(0, m_qualifierName);
|
||||
msg.dispatch();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user