logic: Made history menu use on Messages instead of SearchMatch
* Common base class MessageActivateBase for activation messages with getter for SearchMatches * Removed duplicate logic for creating SearchMatches from Messages * Fixed can't reactivate fulltext search from history menu * Renamed history message and moved to sub directory * Fixed activating node type filters didn't clear code view
This commit is contained in:
@@ -1,23 +1,34 @@
|
||||
#ifndef MESSAGE_ACTIVATE_ALL_H
|
||||
#define MESSAGE_ACTIVATE_ALL_H
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/NodeTypeSet.h"
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/messaging/type/MessageActivateBase.h"
|
||||
|
||||
#include "data/NodeTypeSet.h"
|
||||
|
||||
class MessageActivateAll
|
||||
: public Message<MessageActivateAll>
|
||||
, public MessageActivateBase
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageActivateAll";
|
||||
}
|
||||
|
||||
MessageActivateAll(NodeTypeSet acceptedNodeTypes = NodeTypeSet::all())
|
||||
: acceptedNodeTypes(acceptedNodeTypes)
|
||||
{
|
||||
setIsParallel(true);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
std::vector<SearchMatch> getSearchMatches() const override
|
||||
{
|
||||
return "MessageActivateAll";
|
||||
if (acceptedNodeTypes != NodeTypeSet::all())
|
||||
{
|
||||
return SearchMatch::createCommandsForNodeTypes(acceptedNodeTypes);
|
||||
}
|
||||
return { SearchMatch::createCommand(SearchMatch::COMMAND_ALL) };
|
||||
}
|
||||
|
||||
NodeTypeSet acceptedNodeTypes;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef MESSAGE_ACTIVATE_BASE_H
|
||||
#define MESSAGE_ACTIVATE_BASE_H
|
||||
|
||||
#include "data/search/SearchMatch.h"
|
||||
|
||||
class MessageActivateBase
|
||||
{
|
||||
public:
|
||||
virtual ~MessageActivateBase() = default;
|
||||
|
||||
virtual std::vector<SearchMatch> getSearchMatches() const = 0;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ACTIVATE_BASE_H
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef MESSAGE_ACTIVATE_FULLTEXT_SEARCH_H
|
||||
#define MESSAGE_ACTIVATE_FULLTEXT_SEARCH_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/messaging/type/MessageActivateBase.h"
|
||||
|
||||
class MessageActivateFullTextSearch
|
||||
: public Message<MessageActivateFullTextSearch>
|
||||
, public MessageActivateBase
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageActivateFullTextSearch";
|
||||
}
|
||||
|
||||
MessageActivateFullTextSearch(const std::wstring& searchTerm, bool caseSensitive = false)
|
||||
: searchTerm(searchTerm)
|
||||
, caseSensitive(caseSensitive)
|
||||
{
|
||||
}
|
||||
|
||||
void print(std::wostream& os) const override
|
||||
{
|
||||
os << searchTerm;
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> getSearchMatches() const override
|
||||
{
|
||||
std::wstring prefix(caseSensitive ? 2 : 1, SearchMatch::FULLTEXT_SEARCH_CHARACTER);
|
||||
SearchMatch match(prefix + searchTerm);
|
||||
match.searchType = SearchMatch::SEARCH_FULLTEXT;
|
||||
return { match };
|
||||
}
|
||||
|
||||
const std::wstring searchTerm;
|
||||
bool caseSensitive;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ACTIVATE_FULLTEXT_SEARCH_H
|
||||
@@ -2,12 +2,14 @@
|
||||
#define MESSAGE_ACTIVATE_TOKENS_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/messaging/type/MessageActivateBase.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "data/search/SearchMatch.h"
|
||||
|
||||
class MessageActivateTokens
|
||||
: public Message<MessageActivateTokens>
|
||||
, public MessageActivateBase
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
@@ -24,12 +26,31 @@ public:
|
||||
setKeepContent(other->keepContent());
|
||||
}
|
||||
|
||||
virtual void print(std::wostream& os) const
|
||||
void print(std::wostream& os) const override
|
||||
{
|
||||
for (const Id& id : tokenIds)
|
||||
{
|
||||
os << id << L" ";
|
||||
}
|
||||
|
||||
for (const SearchMatch& match : searchMatches)
|
||||
{
|
||||
os << match.tokenName.getQualifiedName() << L" ";
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> getSearchMatches() const override
|
||||
{
|
||||
if (isAggregation)
|
||||
{
|
||||
SearchMatch match;
|
||||
match.name = match.text = L"aggregation"; // TODO: show aggregation source and target
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
match.nodeType = NodeType::NODE_TYPE;
|
||||
return { match };
|
||||
}
|
||||
|
||||
return searchMatches;
|
||||
}
|
||||
|
||||
std::vector<NameHierarchy> getTokenNamesOfMatches() const
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef MESSAGE_NEW_ERRORS_H
|
||||
#define MESSAGE_NEW_ERRORS_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "data/ErrorInfo.h"
|
||||
|
||||
class MessageNewErrors
|
||||
: public Message<MessageNewErrors>
|
||||
{
|
||||
public:
|
||||
MessageNewErrors(const std::vector<ErrorInfo>& errors, ErrorCountInfo errorCount)
|
||||
: errors(errors)
|
||||
, errorCount(errorCount)
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageNewErrors";
|
||||
}
|
||||
|
||||
virtual void print(std::wostream& os) const
|
||||
{
|
||||
os << errors.size() << L" errors";
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> errors;
|
||||
const ErrorCountInfo errorCount;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_NEW_ERRORS_H
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef MESSAGE_REDO_H
|
||||
#define MESSAGE_REDO_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageRedo
|
||||
: public Message<MessageRedo>
|
||||
{
|
||||
public:
|
||||
MessageRedo()
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageRedo";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_REDO_H
|
||||
@@ -15,9 +15,8 @@ public:
|
||||
return "MessageSearch";
|
||||
}
|
||||
|
||||
MessageSearch(const std::vector<SearchMatch>& matches, NodeTypeSet acceptedNodeTypes = NodeTypeSet::all())
|
||||
: isFromSearch(true)
|
||||
, acceptedNodeTypes(acceptedNodeTypes)
|
||||
MessageSearch(const std::vector<SearchMatch>& matches, NodeTypeSet acceptedNodeTypes)
|
||||
: acceptedNodeTypes(acceptedNodeTypes)
|
||||
, m_matches(matches)
|
||||
{
|
||||
}
|
||||
@@ -27,41 +26,14 @@ 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;
|
||||
}
|
||||
|
||||
std::vector<NameHierarchy> getTokenNamesOfMatches() const
|
||||
{
|
||||
std::vector<NameHierarchy> tokenNames;
|
||||
for (const SearchMatch& match : m_matches)
|
||||
{
|
||||
tokenNames.push_back(match.tokenName);
|
||||
}
|
||||
return tokenNames;
|
||||
}
|
||||
|
||||
virtual void print(std::wostream& os) const
|
||||
{
|
||||
for (const SearchMatch& match : m_matches)
|
||||
{
|
||||
os << " @" << match.name << "-" << match.tokenName.getQualifiedName();
|
||||
os << " @" << match.name;
|
||||
}
|
||||
}
|
||||
|
||||
bool isFromSearch;
|
||||
NodeTypeSet acceptedNodeTypes;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef MESSAGE_SEARCH_FULLTEXT_H
|
||||
#define MESSAGE_SEARCH_FULLTEXT_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageSearchFullText: public Message<MessageSearchFullText>
|
||||
{
|
||||
public:
|
||||
MessageSearchFullText(const std::wstring& searchTerm, bool caseSensitive = false)
|
||||
: searchTerm(searchTerm)
|
||||
, caseSensitive(caseSensitive)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageSearchFullText";
|
||||
}
|
||||
|
||||
virtual void print(std::wostream& os) const
|
||||
{
|
||||
os << searchTerm;
|
||||
}
|
||||
|
||||
const std::wstring searchTerm;
|
||||
bool caseSensitive;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SEARCH_FULLTEXT_H
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef MESSAGE_TO_UNDO_REDO_POSITION_H
|
||||
#define MESSAGE_TO_UNDO_REDO_POSITION_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageToUndoRedoPosition
|
||||
: public Message<MessageToUndoRedoPosition>
|
||||
{
|
||||
public:
|
||||
MessageToUndoRedoPosition(size_t index)
|
||||
: index(index)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageToUndoRedoPosition";
|
||||
}
|
||||
|
||||
size_t index;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_TO_UNDO_REDO_POSITION_H
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef MESSAGE_UNDO_H
|
||||
#define MESSAGE_UNDO_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageUndo
|
||||
: public Message<MessageUndo>
|
||||
{
|
||||
public:
|
||||
MessageUndo()
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageUndo";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_UNDO_H
|
||||
@@ -1,11 +1,14 @@
|
||||
#ifndef MESSAGE_ACTIVATE_ERRORS_H
|
||||
#define MESSAGE_ACTIVATE_ERRORS_H
|
||||
|
||||
#include "data/ErrorFilter.h"
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/messaging/type/MessageActivateBase.h"
|
||||
|
||||
#include "data/ErrorFilter.h"
|
||||
|
||||
class MessageActivateErrors
|
||||
: public Message<MessageActivateErrors>
|
||||
, public MessageActivateBase
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
@@ -19,6 +22,20 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> getSearchMatches() const override
|
||||
{
|
||||
std::vector<SearchMatch> matches = { SearchMatch::createCommand(SearchMatch::COMMAND_ERROR) };
|
||||
if (!file.empty())
|
||||
{
|
||||
SearchMatch match;
|
||||
match.name = match.text = file.fileName();
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
match.nodeType = NodeType::NODE_FILE;
|
||||
matches.push_back(match);
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
const ErrorFilter filter;
|
||||
const FilePath file;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef MESSAGE_HISTORY_REDO_H
|
||||
#define MESSAGE_HISTORY_REDO_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageHistoryRedo
|
||||
: public Message<MessageHistoryRedo>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageHistoryRedo";
|
||||
}
|
||||
|
||||
MessageHistoryRedo()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_HISTORY_REDO_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_HISTORY_TO_POSITION_H
|
||||
#define MESSAGE_HISTORY_TO_POSITION_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageHistoryToPosition
|
||||
: public Message<MessageHistoryToPosition>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageHistoryToPosition";
|
||||
}
|
||||
|
||||
MessageHistoryToPosition(size_t index)
|
||||
: index(index)
|
||||
{
|
||||
}
|
||||
|
||||
const size_t index;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_HISTORY_TO_POSITION_H
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef MESSAGE_HISTORY_UNDO_H
|
||||
#define MESSAGE_HISTORY_UNDO_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageHistoryUndo
|
||||
: public Message<MessageHistoryUndo>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageHistoryUndo";
|
||||
}
|
||||
|
||||
MessageHistoryUndo()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_HISTORY_UNDO_H
|
||||
Reference in New Issue
Block a user