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:
Eberhard Graether
2017-09-19 14:00:40 +02:00
parent 4731f379f4
commit 95ef8c3eec
64 changed files with 1642 additions and 174 deletions
@@ -15,6 +15,7 @@
#include "data/location/SourceLocation.h"
#include "data/location/SourceLocationCollection.h"
#include "data/location/SourceLocationFile.h"
#include "qt/element/QtCodeArea.h"
#include "qt/element/QtCodeFile.h"
#include "qt/element/QtCodeSnippet.h"
#include "qt/utility/utilityQt.h"
@@ -255,6 +256,9 @@ void QtCodeNavigator::clearCodeSnippets()
m_refIndex = 0;
m_singleHasNewFile = false;
m_screenMatches.clear();
m_activeScreenMatchId = 0;
}
void QtCodeNavigator::clearFile()
@@ -549,6 +553,60 @@ void QtCodeNavigator::refreshStyle()
clearCaches();
}
size_t QtCodeNavigator::findScreenMatches(const std::string& query)
{
clearScreenMatches();
m_current->findScreenMatches(query, &m_screenMatches);
return m_screenMatches.size();
}
void QtCodeNavigator::activateScreenMatch(size_t matchIndex)
{
if (matchIndex >= m_screenMatches.size())
{
return;
}
std::pair<QtCodeArea*, Id> p = m_screenMatches[matchIndex];
m_activeScreenMatchId = p.second;
m_currentActiveLocationIds.insert(m_activeScreenMatchId);
p.first->updateContent();
requestScroll(p.first->getSourceLocationFile()->getFilePath(), 0, m_activeScreenMatchId, true, false);
emit scrollRequest();
}
void QtCodeNavigator::deactivateScreenMatch(size_t matchIndex)
{
if (matchIndex >= m_screenMatches.size())
{
return;
}
m_currentActiveLocationIds.erase(m_screenMatches[matchIndex].second);
m_screenMatches[matchIndex].first->updateContent();
m_activeScreenMatchId = 0;
}
void QtCodeNavigator::clearScreenMatches()
{
if (m_activeScreenMatchId)
{
m_currentActiveLocationIds.erase(m_activeScreenMatchId);
m_activeScreenMatchId = 0;
}
for (auto p : m_screenMatches)
{
p.first->clearScreenMatches();
}
m_screenMatches.clear();
}
void QtCodeNavigator::scrollToValue(int value, bool inListMode)
{
if ((m_mode == MODE_LIST) == inListMode)