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:
Eberhard Graether
2017-03-16 23:24:33 +01:00
parent aa49fffca6
commit 630009a2ba
44 changed files with 516 additions and 400 deletions
+14
View File
@@ -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