ui: Added on-screen search feature (issue #79)
* Use menu action "Edit -> Find in View" or Ctrl + D * UI displayed as search bar at bottom of main window * Hide search bar with ECS or close button * Entering a query searches in name of graph nodes and code contents of code view * Use Enter to iterate through matches, well move match into view in graph and code view * Checkboxes allow for adding/removing results for certain views * Create Bookmark shortcut is now CTRL + S bug id = 79
This commit is contained in:
@@ -168,6 +168,80 @@ void QtGraphView::refreshView()
|
||||
getView()->refreshStyle();
|
||||
}
|
||||
|
||||
bool QtGraphView::isVisible() const
|
||||
{
|
||||
return QtViewWidgetWrapper::getWidgetOfView(this)->isVisible();
|
||||
}
|
||||
|
||||
void QtGraphView::findMatches(ScreenSearchSender* sender, const std::string& query)
|
||||
{
|
||||
m_onQtThread(
|
||||
[sender, query, this]()
|
||||
{
|
||||
m_matchedNodes.clear();
|
||||
|
||||
for (std::shared_ptr<QtGraphNode> node : m_oldNodes)
|
||||
{
|
||||
node->matchNameRecursive(query, &m_matchedNodes);
|
||||
}
|
||||
|
||||
sender->foundMatches(this, m_matchedNodes.size());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtGraphView::activateMatch(size_t matchIndex)
|
||||
{
|
||||
m_onQtThread(
|
||||
[matchIndex, this]()
|
||||
{
|
||||
if (matchIndex >= m_matchedNodes.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QtGraphNode* node = m_matchedNodes[matchIndex];
|
||||
|
||||
node->setActiveMatch(true);
|
||||
node->updateStyle();
|
||||
|
||||
centerNode(node);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtGraphView::deactivateMatch(size_t matchIndex)
|
||||
{
|
||||
m_onQtThread(
|
||||
[matchIndex, this]()
|
||||
{
|
||||
if (matchIndex >= m_matchedNodes.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QtGraphNode* node = m_matchedNodes[matchIndex];
|
||||
node->setActiveMatch(false);
|
||||
node->updateStyle();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtGraphView::clearMatches()
|
||||
{
|
||||
m_onQtThread(
|
||||
[this]()
|
||||
{
|
||||
for (QtGraphNode* node : m_matchedNodes)
|
||||
{
|
||||
node->removeNameMatch();
|
||||
}
|
||||
|
||||
m_matchedNodes.clear();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtGraphView::rebuildGraph(
|
||||
std::shared_ptr<Graph> graph,
|
||||
const std::vector<std::shared_ptr<DummyNode>>& nodes,
|
||||
@@ -599,6 +673,8 @@ void QtGraphView::doRebuildGraph(
|
||||
m_graph = graph;
|
||||
}
|
||||
|
||||
m_matchedNodes.clear();
|
||||
|
||||
QGraphicsView* view = getView();
|
||||
|
||||
|
||||
@@ -682,6 +758,8 @@ void QtGraphView::doClear()
|
||||
|
||||
m_graph.reset();
|
||||
m_oldGraph.reset();
|
||||
|
||||
m_matchedNodes.clear();
|
||||
}
|
||||
|
||||
void QtGraphView::doResize()
|
||||
|
||||
Reference in New Issue
Block a user