ui: Added shortcuts for navigating to next and previous reference in code view

* Added new class QtCodeNavigator between QtCodeView and QtCodeFileList that handles active ids and navigation
* Pass all files as initially collapsed to code view and decide in QtCodeNavigator which ones show content
* Rewrote requesting of active snippet display to top down approach
* Display other locations focused when active location changes
* Show corresponding edges when navigating references
This commit is contained in:
Eberhard Graether
2016-08-09 13:29:14 +02:00
parent 210c5b1245
commit d0a063a3b6
32 changed files with 1037 additions and 599 deletions
+15 -21
View File
@@ -5,7 +5,7 @@
#include "qt/utility/utilityQt.h"
#include "qt/element/QtCodeArea.h"
#include "qt/element/QtCodeFileList.h"
#include "qt/element/QtCodeNavigator.h"
#include "qt/utility/QtHighlighter.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "settings/ColorScheme.h"
@@ -18,7 +18,8 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout)
, m_addCodeSnippetsFunctor(std::bind(&QtCodeView::doAddCodeSnippets, this, std::placeholders::_1, std::placeholders::_2))
, m_showCodeFileFunctor(std::bind(&QtCodeView::doShowCodeFile, this, std::placeholders::_1))
, m_setFileStateFunctor(std::bind(&QtCodeView::doSetFileState, this, std::placeholders::_1, std::placeholders::_2))
, m_doShowFirstActiveSnippetFunctor(std::bind(&QtCodeView::doShowFirstActiveSnippet, this, std::placeholders::_1, std::placeholders::_2))
, m_doShowActiveSnippetFunctor(
std::bind(&QtCodeView::doShowActiveSnippet, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))
, m_doShowActiveTokenIdsFunctor(std::bind(&QtCodeView::doShowActiveTokenIds, this, std::placeholders::_1))
, m_doShowActiveLocalSymbolIdsFunctor(std::bind(&QtCodeView::doShowActiveLocalSymbolIds, this, std::placeholders::_1))
, m_focusTokenIdsFunctor(std::bind(&QtCodeView::doFocusTokenIds, this, std::placeholders::_1))
@@ -27,7 +28,7 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout)
, m_scrollToValueFunctor(std::bind(&QtCodeView::doScrollToValue, this, std::placeholders::_1))
, m_scrollToLineFunctor(std::bind(&QtCodeView::doScrollToLine, this, std::placeholders::_1, std::placeholders::_2))
{
m_widget = new QtCodeFileList();
m_widget = new QtCodeNavigator();
setStyleSheet();
}
@@ -54,12 +55,6 @@ void QtCodeView::clear()
m_clearFunctor();
m_errorInfos.clear();
m_activeTokenIds.clear();
}
void QtCodeView::setActiveTokenIds(const std::vector<Id>& activeTokenIds)
{
m_activeTokenIds = activeTokenIds;
}
void QtCodeView::setErrorInfos(const std::vector<ErrorInfo>& errorInfos)
@@ -87,9 +82,10 @@ void QtCodeView::setFileState(const FilePath filePath, FileState state)
m_setFileStateFunctor(filePath, state);
}
void QtCodeView::showFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo)
void QtCodeView::showActiveSnippet(
const std::vector<Id>& activeTokenIds, std::shared_ptr<TokenLocationCollection> collection, bool scrollTo)
{
m_doShowFirstActiveSnippetFunctor(activeTokenIds, scrollTo);
m_doShowActiveSnippetFunctor(activeTokenIds, collection, scrollTo);
}
void QtCodeView::showActiveTokenIds(const std::vector<Id>& activeTokenIds)
@@ -143,9 +139,7 @@ void QtCodeView::doClear()
void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds)
{
setActiveTokenIds(activeTokenIds);
m_widget->setActiveTokenIds(m_activeTokenIds);
m_widget->setActiveTokenIds(activeTokenIds);
m_widget->setErrorInfos(m_errorInfos);
for (const CodeSnippetParams& params : snippets)
@@ -160,7 +154,7 @@ void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippe
}
}
m_widget->updateFiles();
m_widget->setupFiles();
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
}
@@ -176,7 +170,7 @@ void QtCodeView::doAddCodeSnippets(const std::vector<CodeSnippetParams>& snippet
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
m_widget->scrollToActiveFileIfRequested();
m_widget->scrollToSnippetIfRequested();
}
void QtCodeView::doShowCodeFile(const CodeSnippetParams& params)
@@ -200,22 +194,22 @@ void QtCodeView::doSetFileState(const FilePath filePath, FileState state)
}
}
void QtCodeView::doShowFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo)
void QtCodeView::doShowActiveSnippet(
const std::vector<Id>& activeTokenIds, std::shared_ptr<TokenLocationCollection> collection, bool scrollTo)
{
m_widget->setActiveTokenIds(activeTokenIds);
m_widget->showFirstActiveSnippet(scrollTo);
m_widget->showActiveSnippet(activeTokenIds, collection, scrollTo);
}
void QtCodeView::doShowActiveTokenIds(const std::vector<Id>& activeTokenIds)
{
m_widget->setActiveTokenIds(activeTokenIds);
m_widget->showActiveTokenIds();
m_widget->updateFiles();
}
void QtCodeView::doShowActiveLocalSymbolIds(const std::vector<Id>& localSymbolIds)
{
m_widget->setActiveLocalSymbolIds(localSymbolIds);
m_widget->showActiveTokenIds();
m_widget->updateFiles();
}
void QtCodeView::doFocusTokenIds(const std::vector<Id>& focusedTokenIds)
+7 -7
View File
@@ -10,7 +10,7 @@
#include "qt/utility/QtThreadedFunctor.h"
class QFrame;
class QtCodeFileList;
class QtCodeNavigator;
class QWidget;
class QtCodeView
@@ -28,7 +28,6 @@ public:
// CodeView implementation
virtual void clear();
virtual void setActiveTokenIds(const std::vector<Id>& activeTokenIds);
virtual void setErrorInfos(const std::vector<ErrorInfo>& errorInfos);
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds);
@@ -37,7 +36,8 @@ public:
virtual void setFileState(const FilePath filePath, FileState state);
virtual void showFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo);
virtual void showActiveSnippet(
const std::vector<Id>& activeTokenIds, std::shared_ptr<TokenLocationCollection> collection, bool scrollTo);
virtual void showActiveTokenIds(const std::vector<Id>& activeTokenIds);
virtual void showActiveLocalSymbolIds(const std::vector<Id>& activeLocalSymbolIds);
@@ -59,7 +59,8 @@ private:
void doSetFileState(const FilePath filePath, FileState state);
void doShowFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo);
void doShowActiveSnippet(
const std::vector<Id>& activeTokenIds, std::shared_ptr<TokenLocationCollection> collection, bool scrollTo);
void doShowActiveTokenIds(const std::vector<Id>& activeTokenIds);
void doShowActiveLocalSymbolIds(const std::vector<Id>& localSymbolIds);
@@ -79,7 +80,7 @@ private:
QtThreadedFunctor<const std::vector<CodeSnippetParams>&, bool> m_addCodeSnippetsFunctor;
QtThreadedFunctor<const CodeSnippetParams&> m_showCodeFileFunctor;
QtThreadedFunctor<const FilePath, FileState> m_setFileStateFunctor;
QtThreadedFunctor<const std::vector<Id>&, bool> m_doShowFirstActiveSnippetFunctor;
QtThreadedFunctor<const std::vector<Id>&, std::shared_ptr<TokenLocationCollection>, bool> m_doShowActiveSnippetFunctor;
QtThreadedFunctor<const std::vector<Id>&> m_doShowActiveTokenIdsFunctor;
QtThreadedFunctor<const std::vector<Id>&> m_doShowActiveLocalSymbolIdsFunctor;
QtThreadedFunctor<const std::vector<Id>&> m_focusTokenIdsFunctor;
@@ -88,9 +89,8 @@ private:
QtThreadedFunctor<int> m_scrollToValueFunctor;
QtThreadedFunctor<std::string, unsigned int> m_scrollToLineFunctor;
QtCodeFileList* m_widget;
QtCodeNavigator* m_widget;
std::vector<Id> m_activeTokenIds;
std::vector<ErrorInfo> m_errorInfos;
};