logic: rewrote messages handling token activation for correct restoring on undo
* saving search query to undo stack with MessageSearch * saving node and edge with name to undo stack with MessageActivateNode and MessageActivateEdge * added FeatureController that handels distribution of MessageActivateTokens * clearing views when refreshing or changing project * clearing undo stack when changing project * added StorageCache derived from StorageAccessProxy
This commit is contained in:
@@ -60,14 +60,9 @@ QSize QtSearchBar::sizeHint() const
|
||||
return QSize(400, 100);
|
||||
}
|
||||
|
||||
void QtSearchBar::setText(const std::string& text)
|
||||
void QtSearchBar::setMatches(const std::deque<SearchMatch>& matches)
|
||||
{
|
||||
m_searchBox->setQuery(text);
|
||||
}
|
||||
|
||||
void QtSearchBar::setMatch(const SearchMatch& match)
|
||||
{
|
||||
m_searchBox->setQuery(match);
|
||||
m_searchBox->setMatches(matches);
|
||||
}
|
||||
|
||||
void QtSearchBar::setFocus()
|
||||
|
||||
@@ -22,8 +22,7 @@ public:
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
void setText(const std::string& text);
|
||||
void setMatch(const SearchMatch& match);
|
||||
void setMatches(const std::deque<SearchMatch>& matches);
|
||||
void setFocus();
|
||||
void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||
|
||||
|
||||
@@ -33,8 +33,10 @@ void QtQueryElement::onChecked(bool)
|
||||
void QtSmartSearchBox::search()
|
||||
{
|
||||
editTextToElement();
|
||||
LOG_INFO(utility::join(SearchMatch::searchMatchDequeToStringDeque(m_tokens), "")+ text().toStdString());
|
||||
MessageSearch(utility::join(SearchMatch::searchMatchDequeToStringDeque(m_tokens), "") + text().toStdString()).dispatch();
|
||||
|
||||
LOG_INFO_STREAM(<< "Search query: " << SearchMatch::searchMatchDequeToString(m_tokens) << text().toStdString());
|
||||
|
||||
MessageSearch(m_tokens).dispatch();
|
||||
}
|
||||
|
||||
QtSmartSearchBox::QtSmartSearchBox(QWidget* parent)
|
||||
@@ -80,21 +82,16 @@ void QtSmartSearchBox::setAutocompletionList(const std::vector<SearchMatch>& aut
|
||||
}
|
||||
}
|
||||
|
||||
void QtSmartSearchBox::setQuery(const SearchMatch& match)
|
||||
void QtSmartSearchBox::setMatches(const std::deque<SearchMatch>& matches)
|
||||
{
|
||||
clearLineEdit();
|
||||
m_tokens.clear();
|
||||
m_tokens.push_back(match);
|
||||
m_cursorIndex = m_tokens.size();
|
||||
updateElements();
|
||||
}
|
||||
if (SearchMatch::searchMatchDequeToString(matches) == SearchMatch::searchMatchDequeToString(m_tokens))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void QtSmartSearchBox::setQuery(const std::string& text)
|
||||
{
|
||||
clearLineEdit();
|
||||
m_tokens = SearchMatch::stringDequeToSearchMatchDeque(QueryTree::tokenizeQuery(text));
|
||||
m_tokens = matches;
|
||||
m_cursorIndex = m_tokens.size();
|
||||
|
||||
updateElements();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ public:
|
||||
virtual ~QtSmartSearchBox();
|
||||
|
||||
void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||
void setQuery(const SearchMatch& match);
|
||||
void setQuery(const std::string& text);
|
||||
void setMatches(const std::deque<SearchMatch>& matches);
|
||||
void setFocus();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -75,6 +75,7 @@ void QtCodeView::defocusToken()
|
||||
void QtCodeView::doRefreshView()
|
||||
{
|
||||
setStyleSheet(m_widget);
|
||||
m_widget->clearCodeSnippets();
|
||||
}
|
||||
|
||||
void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippets)
|
||||
|
||||
@@ -65,6 +65,7 @@ void QtGraphView::initView()
|
||||
|
||||
void QtGraphView::refreshView()
|
||||
{
|
||||
clear();
|
||||
resizeView();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
QtSearchView::QtSearchView(ViewLayout* viewLayout)
|
||||
: SearchView(viewLayout)
|
||||
, m_refreshViewFunctor(std::bind(&QtSearchView::doRefreshView, this))
|
||||
, m_setTextFunctor(std::bind(&QtSearchView::doSetText, this, std::placeholders::_1))
|
||||
, m_setMatchFunctor(std::bind(&QtSearchView::doSetMatch, this, std::placeholders::_1))
|
||||
, m_setMatchesFunctor(std::bind(&QtSearchView::doSetMatches, this, std::placeholders::_1))
|
||||
, m_setFocusFunctor(std::bind(&QtSearchView::doSetFocus, this))
|
||||
, m_setAutocompletionListFunctor(std::bind(&QtSearchView::doSetAutocompletionList, this, std::placeholders::_1))
|
||||
{
|
||||
@@ -34,14 +33,9 @@ void QtSearchView::refreshView()
|
||||
m_refreshViewFunctor();
|
||||
}
|
||||
|
||||
void QtSearchView::setText(const std::string& text)
|
||||
void QtSearchView::setMatches(const std::deque<SearchMatch>& matches)
|
||||
{
|
||||
m_setTextFunctor(text);
|
||||
}
|
||||
|
||||
void QtSearchView::setMatch(const SearchMatch& match)
|
||||
{
|
||||
m_setMatchFunctor(match);
|
||||
m_setMatchesFunctor(matches);
|
||||
}
|
||||
|
||||
void QtSearchView::setFocus()
|
||||
@@ -57,16 +51,12 @@ void QtSearchView::setAutocompletionList(const std::vector<SearchMatch>& autocom
|
||||
void QtSearchView::doRefreshView()
|
||||
{
|
||||
setStyleSheet();
|
||||
m_widget->setMatches(std::deque<SearchMatch>());
|
||||
}
|
||||
|
||||
void QtSearchView::doSetMatch(const SearchMatch& match)
|
||||
void QtSearchView::doSetMatches(const std::deque<SearchMatch>& matches)
|
||||
{
|
||||
m_widget->setMatch(match);
|
||||
}
|
||||
|
||||
void QtSearchView::doSetText(const std::string& text)
|
||||
{
|
||||
m_widget->setText(text);
|
||||
m_widget->setMatches(matches);
|
||||
}
|
||||
|
||||
void QtSearchView::doSetFocus()
|
||||
|
||||
@@ -19,23 +19,20 @@ public:
|
||||
virtual void refreshView();
|
||||
|
||||
// SearchView implementation
|
||||
virtual void setText(const std::string& text);
|
||||
virtual void setMatch(const SearchMatch& match);
|
||||
virtual void setMatches(const std::deque<SearchMatch>& matches);
|
||||
virtual void setFocus();
|
||||
virtual void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||
|
||||
private:
|
||||
void doRefreshView();
|
||||
void doSetMatch(const SearchMatch& match);
|
||||
void doSetText(const std::string& text);
|
||||
void doSetMatches(const std::deque<SearchMatch>& matches);
|
||||
void doSetFocus();
|
||||
void doSetAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||
|
||||
void setStyleSheet();
|
||||
|
||||
QtThreadedFunctor<> m_refreshViewFunctor;
|
||||
QtThreadedFunctor<const std::string&> m_setTextFunctor;
|
||||
QtThreadedFunctor<const SearchMatch&> m_setMatchFunctor;
|
||||
QtThreadedFunctor<const std::deque<SearchMatch>&> m_setMatchesFunctor;
|
||||
QtThreadedFunctor<> m_setFocusFunctor;
|
||||
QtThreadedFunctor<const std::vector<SearchMatch>&> m_setAutocompletionListFunctor;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <QGraphicsSceneEvent>
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageActivateEdge.h"
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
|
||||
@@ -123,16 +123,9 @@ void QtGraphEdge::onClick()
|
||||
{
|
||||
MessageGraphNodeBundleSplit(m_target.lock()->getTokenId()).dispatch();
|
||||
}
|
||||
else if (getData()->isType(Edge::EDGE_AGGREGATION))
|
||||
{
|
||||
const std::set<Id>& ids = getData()->getComponent<TokenComponentAggregation>()->getAggregationIds();
|
||||
MessageActivateTokens(std::vector<Id>(ids.begin(), ids.end())).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageActivateTokens message(getData()->getId());
|
||||
message.isEdge = true;
|
||||
message.dispatch();
|
||||
MessageActivateEdge(getData()->getId(), getData()->getType(), getData()->getName()).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "qt/view/graphElements/QtGraphNodeData.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageActivateNode.h"
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
@@ -37,7 +37,7 @@ void QtGraphNodeData::onClick()
|
||||
{
|
||||
if (!m_data->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE))
|
||||
{
|
||||
MessageActivateTokens(m_data->getId()).dispatch();
|
||||
MessageActivateNode(m_data->getId(), m_data->getType(), m_data->getFullName()).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user