diff --git a/bin/app/data/color_schemes/bad_rainbow.xml b/bin/app/data/color_schemes/bad_rainbow.xml
index 31f8d967..e04f7287 100644
--- a/bin/app/data/color_schemes/bad_rainbow.xml
+++ b/bin/app/data/color_schemes/bad_rainbow.xml
@@ -184,7 +184,7 @@
#262626
- transparent
+ white
#A5DEFF
#262626
diff --git a/bin/app/data/color_schemes/bright.xml b/bin/app/data/color_schemes/bright.xml
index c5c7dd9a..3f29a099 100644
--- a/bin/app/data/color_schemes/bright.xml
+++ b/bin/app/data/color_schemes/bright.xml
@@ -183,7 +183,7 @@
#C6EAFF
- transparent
+ #136391
#C6EAFF
diff --git a/bin/app/data/color_schemes/dark.xml b/bin/app/data/color_schemes/dark.xml
index bf862534..ca731620 100644
--- a/bin/app/data/color_schemes/dark.xml
+++ b/bin/app/data/color_schemes/dark.xml
@@ -184,7 +184,7 @@
#191919
- transparent
+ white
#969696
#272728
diff --git a/bin/app/data/gui/code_view/code_view.css b/bin/app/data/gui/code_view/code_view.css
index 0a0f890d..9400e2a2 100644
--- a/bin/app/data/gui/code_view/code_view.css
+++ b/bin/app/data/gui/code_view/code_view.css
@@ -24,7 +24,7 @@
border: none;
}
-#code_navigation * {
+#code_navigation QLabel {
color: ;
font-size: px;
}
@@ -50,11 +50,39 @@
}
#code_navigation #reference_button_previous {
+ /*width: 20px;*/
+ padding-bottom: 2px;
+
border-bottom-left-radius: 11px;
border-top-left-radius: 11px;
}
#code_navigation #reference_button_next {
+ /*width: 20px;*/
+ padding-top: 3px;
+
+ border-bottom-right-radius: 11px;
+ border-top-right-radius: 11px;
+}
+
+#code_navigation #file_button_previous, #code_navigation #file_button_next {
+ width: 22px;
+}
+
+#code_navigation #file_button_previous, #code_navigation #local_reference_button_previous {
+ border-bottom-left-radius: 11px;
+ border-top-left-radius: 11px;
+}
+
+#code_navigation #local_reference_button_previous {
+ padding-bottom: 2px;
+}
+
+#code_navigation #local_reference_button_next {
+ padding-top: 3px;
+}
+
+#code_navigation #file_button_next, #code_navigation #local_reference_button_next {
border-bottom-right-radius: 11px;
border-top-right-radius: 11px;
}
diff --git a/bin/app/data/gui/code_view/images/arrow_down.png b/bin/app/data/gui/code_view/images/arrow_down.png
new file mode 100644
index 00000000..c5d095a1
Binary files /dev/null and b/bin/app/data/gui/code_view/images/arrow_down.png differ
diff --git a/bin/app/data/gui/code_view/images/arrow_up.png b/bin/app/data/gui/code_view/images/arrow_up.png
new file mode 100644
index 00000000..2d98a165
Binary files /dev/null and b/bin/app/data/gui/code_view/images/arrow_up.png differ
diff --git a/src/lib/utility/messaging/type/MessageCodeReference.h b/src/lib/utility/messaging/type/MessageCodeReference.h
index 50cb798a..32eaa0e6 100644
--- a/src/lib/utility/messaging/type/MessageCodeReference.h
+++ b/src/lib/utility/messaging/type/MessageCodeReference.h
@@ -13,8 +13,9 @@ public:
REFERENCE_NEXT
};
- MessageCodeReference(ReferenceType type)
+ MessageCodeReference(ReferenceType type, bool localReference)
: type(type)
+ , localReference(localReference)
{
}
@@ -33,9 +34,15 @@ public:
{
os << L"next";
}
+
+ if (localReference)
+ {
+ os << L" local";
+ }
}
const ReferenceType type;
+ bool localReference;
};
#endif // MESSAGE_CODE_REFERENCE_H
diff --git a/src/lib_gui/qt/element/QtCodeArea.cpp b/src/lib_gui/qt/element/QtCodeArea.cpp
index 839ecf4c..a818d4f7 100644
--- a/src/lib_gui/qt/element/QtCodeArea.cpp
+++ b/src/lib_gui/qt/element/QtCodeArea.cpp
@@ -151,8 +151,8 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent *event)
std::set activeLineNumbers;
std::set focusedLineNumbers;
- std::set activeSymbolIds = m_navigator->getActiveTokenIds();
- std::set activeLocationIds = m_navigator->getCurrentActiveLocationIds();
+ const std::set& activeSymbolIds = m_navigator->getActiveTokenIds();
+ const std::set& activeLocalTokenIds = m_navigator->getActiveLocalTokenIds();
for (const Annotation& annotation : m_annotations)
{
@@ -183,7 +183,7 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent *event)
case LOCATION_TOKEN:
case LOCATION_SCOPE:
- if (annotation.isActive && activeLocationIds.size())
+ if (annotation.isActive && activeLocalTokenIds.size())
{
focus = true;
break;
@@ -388,6 +388,19 @@ Id QtCodeArea::getLocationIdOfFirstHighlightedLocation() const
return 0;
}
+std::vector QtCodeArea::getLocationIdsForTokenIds(const std::set& tokenIds) const
+{
+ std::vector locationIds;
+ for (const Annotation& annotation : m_annotations)
+ {
+ if (utility::shareElement(annotation.tokenIds, tokenIds))
+ {
+ locationIds.push_back(annotation.locationId);
+ }
+ }
+ return locationIds;
+}
+
size_t QtCodeArea::getActiveLocationCount() const
{
uint count = 0;
@@ -636,7 +649,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
activateAnnotations(annotations);
}
}
- else if (m_navigator->getActiveLocalSymbolIds().size())
+ else if (m_navigator->getActiveLocalTokenIds().size())
{
MessageActivateLocalSymbols(std::vector()).dispatch();
}
@@ -816,12 +829,13 @@ void QtCodeArea::activateErrors(const std::vector& annotation
void QtCodeArea::annotateText()
{
- std::set activeSymbolIds = m_navigator->getCurrentActiveTokenIds();
- utility::append(activeSymbolIds, m_navigator->getActiveLocalSymbolIds());
-
- const std::set& activeLocationIds = m_navigator->getCurrentActiveLocationIds();
+ const std::set& activeSymbolIds = m_navigator->getCurrentActiveTokenIds();
+ const std::set& activeLocationIds =
+ utility::concat(m_navigator->getCurrentActiveLocationIds(), m_navigator->getCurrentActiveLocalLocationIds());
std::set focusedSymbolIds = m_navigator->getActiveTokenIds();
+ utility::append(focusedSymbolIds, m_navigator->getActiveLocalTokenIds());
+
for (Id currentActiveId : activeSymbolIds)
{
focusedSymbolIds.erase(currentActiveId);
diff --git a/src/lib_gui/qt/element/QtCodeArea.h b/src/lib_gui/qt/element/QtCodeArea.h
index f2601f6e..bdab092e 100644
--- a/src/lib_gui/qt/element/QtCodeArea.h
+++ b/src/lib_gui/qt/element/QtCodeArea.h
@@ -81,6 +81,8 @@ public:
Id getLocationIdOfFirstActiveScopeLocation(Id tokenId) const;
Id getLocationIdOfFirstHighlightedLocation() const;
+ std::vector getLocationIdsForTokenIds(const std::set& tokenIds) const;
+
size_t getActiveLocationCount() const;
QRectF getLineRectForLineNumber(uint lineNumber) const;
diff --git a/src/lib_gui/qt/element/QtCodeFile.cpp b/src/lib_gui/qt/element/QtCodeFile.cpp
index 2d7febc9..8149b3bf 100644
--- a/src/lib_gui/qt/element/QtCodeFile.cpp
+++ b/src/lib_gui/qt/element/QtCodeFile.cpp
@@ -390,6 +390,19 @@ void QtCodeFile::findScreenMatches(const std::wstring& query, std::vector> QtCodeFile::getLocationIdsForTokenIds(const std::set& tokenIds) const
+{
+ std::vector> locationIds;
+ for (QtCodeSnippet* snippet : m_snippets)
+ {
+ for (Id locationId : snippet->getLocationIdsForTokenIds(tokenIds))
+ {
+ locationIds.push_back(std::make_pair(m_filePath, locationId));
+ }
+ }
+ return locationIds;
+}
+
void QtCodeFile::clickedMinimizeButton()
{
MessageChangeFileView(
diff --git a/src/lib_gui/qt/element/QtCodeFile.h b/src/lib_gui/qt/element/QtCodeFile.h
index 68c0c4e8..7bff554d 100644
--- a/src/lib_gui/qt/element/QtCodeFile.h
+++ b/src/lib_gui/qt/element/QtCodeFile.h
@@ -2,6 +2,7 @@
#define QT_CODE_FILE_H
#include
+#include
#include
#include
@@ -63,6 +64,8 @@ public:
void findScreenMatches(const std::wstring& query, std::vector>* screenMatches);
+ std::vector> getLocationIdsForTokenIds(const std::set& tokenIds) const;
+
public slots:
void clickedMinimizeButton();
void clickedSnippetButton();
diff --git a/src/lib_gui/qt/element/QtCodeFileList.cpp b/src/lib_gui/qt/element/QtCodeFileList.cpp
index ffc6fff8..fab3191f 100644
--- a/src/lib_gui/qt/element/QtCodeFileList.cpp
+++ b/src/lib_gui/qt/element/QtCodeFileList.cpp
@@ -7,6 +7,7 @@
#include "utility/file/FilePath.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityApp.h"
+#include "utility/utility.h"
#include "data/location/SourceLocationFile.h"
#include "qt/element/QtCodeFile.h"
@@ -69,10 +70,6 @@ QtCodeFileList::QtCodeFileList(QtCodeNavigator* navigator)
connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, m_navigator, &QtCodeNavigator::scrolled);
}
-QtCodeFileList::~QtCodeFileList()
-{
-}
-
void QtCodeFileList::clear()
{
for (QtCodeFile* file : m_files)
@@ -275,6 +272,16 @@ void QtCodeFileList::findScreenMatches(const std::wstring& query, std::vector> QtCodeFileList::getLocationIdsForTokenIds(const std::set& tokenIds) const
+{
+ std::vector> locationIds;
+ for (QtCodeFile* file : m_files)
+ {
+ utility::append(locationIds, file->getLocationIdsForTokenIds(tokenIds));
+ }
+ return locationIds;
+}
+
void QtCodeFileList::setFileMinimized(const FilePath path)
{
if (path.empty())
diff --git a/src/lib_gui/qt/element/QtCodeFileList.h b/src/lib_gui/qt/element/QtCodeFileList.h
index 849c5d9a..432d8b92 100644
--- a/src/lib_gui/qt/element/QtCodeFileList.h
+++ b/src/lib_gui/qt/element/QtCodeFileList.h
@@ -23,7 +23,7 @@ class QtCodeFileList
public:
QtCodeFileList(QtCodeNavigator* navigator);
- virtual ~QtCodeFileList();
+ virtual ~QtCodeFileList() = default;
void clear();
void clearSnippetTitleAndScrollBar();
@@ -32,20 +32,22 @@ public:
void addFile(std::shared_ptr locationFile, int refCount, TimeStamp modificationTime);
// QtCodeNaviatebale implementation
- virtual QScrollArea* getScrollArea();
+ QScrollArea* getScrollArea() override;
- virtual void addCodeSnippet(const CodeSnippetParams& params);
- virtual void updateCodeSnippet(const CodeSnippetParams& params);
+ void addCodeSnippet(const CodeSnippetParams& params) override;
+ void updateCodeSnippet(const CodeSnippetParams& params) override;
- virtual void requestFileContent(const FilePath& filePath);
- virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target);
+ void requestFileContent(const FilePath& filePath) override;
+ bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target) override;
- virtual void updateFiles();
- virtual void showContents();
+ void updateFiles() override;
+ void showContents() override;
- virtual void onWindowFocus();
+ void onWindowFocus() override;
- virtual void findScreenMatches(const std::wstring& query, std::vector>* screenMatches);
+ void findScreenMatches(const std::wstring& query, std::vector>* screenMatches) override;
+
+ std::vector> getLocationIdsForTokenIds(const std::set& tokenIds) const override;
void setFileMinimized(const FilePath path);
void setFileSnippets(const FilePath path);
@@ -57,7 +59,7 @@ public:
std::pair getFirstSnippetWithActiveLocationId(Id tokenId) const;
protected:
- virtual void resizeEvent(QResizeEvent* event);
+ void resizeEvent(QResizeEvent* event) override;
private slots:
void updateSnippetTitleAndScrollBarSlot();
diff --git a/src/lib_gui/qt/element/QtCodeFileSingle.cpp b/src/lib_gui/qt/element/QtCodeFileSingle.cpp
index 9cbd24ef..1ecd17fd 100644
--- a/src/lib_gui/qt/element/QtCodeFileSingle.cpp
+++ b/src/lib_gui/qt/element/QtCodeFileSingle.cpp
@@ -44,10 +44,6 @@ QtCodeFileSingle::QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent)
layout()->addWidget(m_areaWrapper);
}
-QtCodeFileSingle::~QtCodeFileSingle()
-{
-}
-
QAbstractScrollArea* QtCodeFileSingle::getScrollArea()
{
return m_area;
@@ -234,6 +230,21 @@ void QtCodeFileSingle::findScreenMatches(const std::wstring& query, std::vector<
}
}
+std::vector> QtCodeFileSingle::getLocationIdsForTokenIds(const std::set& tokenIds) const
+{
+ if (m_area)
+ {
+ std::vector> locationIds;
+ for (Id locationId : m_area->getLocationIdsForTokenIds(tokenIds))
+ {
+ locationIds.push_back(std::make_pair(getCurrentFilePath(), locationId));
+ }
+ return locationIds;
+ }
+
+ return { };
+}
+
const FilePath& QtCodeFileSingle::getCurrentFilePath() const
{
return m_currentFilePath;
diff --git a/src/lib_gui/qt/element/QtCodeFileSingle.h b/src/lib_gui/qt/element/QtCodeFileSingle.h
index 5a1ae93a..80986ee4 100644
--- a/src/lib_gui/qt/element/QtCodeFileSingle.h
+++ b/src/lib_gui/qt/element/QtCodeFileSingle.h
@@ -25,29 +25,31 @@ class QtCodeFileSingle
public:
QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent = nullptr);
- virtual ~QtCodeFileSingle();
+ virtual ~QtCodeFileSingle() = default;
void clearFile();
void clearCache();
// QtCodeNavigateable implementation
- virtual QAbstractScrollArea* getScrollArea() override;
+ QAbstractScrollArea* getScrollArea() override;
- virtual void addCodeSnippet(const CodeSnippetParams& params) override;
- virtual void updateCodeSnippet(const CodeSnippetParams& params) override;
+ void addCodeSnippet(const CodeSnippetParams& params) override;
+ void updateCodeSnippet(const CodeSnippetParams& params) override;
- virtual void requestFileContent(const FilePath& filePath) override;
- virtual bool requestScroll(
+ void requestFileContent(const FilePath& filePath) override;
+ bool requestScroll(
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target) override;
- virtual void updateFiles() override;
- virtual void showContents() override;
+ void updateFiles() override;
+ void showContents() override;
- virtual void onWindowFocus() override;
+ void onWindowFocus() override;
- virtual void findScreenMatches(
+ void findScreenMatches(
const std::wstring& query, std::vector>* screenMatches) override;
+ std::vector> getLocationIdsForTokenIds(const std::set& tokenIds) const override;
+
const FilePath& getCurrentFilePath() const;
bool hasFileCached(const FilePath& filePath) const;
diff --git a/src/lib_gui/qt/element/QtCodeNavigateable.h b/src/lib_gui/qt/element/QtCodeNavigateable.h
index 9a55d1c1..229d367c 100644
--- a/src/lib_gui/qt/element/QtCodeNavigateable.h
+++ b/src/lib_gui/qt/element/QtCodeNavigateable.h
@@ -41,6 +41,8 @@ public:
virtual void findScreenMatches(const std::wstring& query, std::vector>* screenMatches) = 0;
+ virtual std::vector> getLocationIdsForTokenIds(const std::set& tokenIds) const = 0;
+
protected:
void ensureWidgetVisibleAnimated(const QWidget* parentWidget, const QWidget *childWidget, QRectF rect, bool animated, ScrollTarget target);
void ensurePercentVisibleAnimated(double percentA, double percentB, bool animated, ScrollTarget target);
diff --git a/src/lib_gui/qt/element/QtCodeNavigator.cpp b/src/lib_gui/qt/element/QtCodeNavigator.cpp
index ec7eb420..92b9af97 100644
--- a/src/lib_gui/qt/element/QtCodeNavigator.cpp
+++ b/src/lib_gui/qt/element/QtCodeNavigator.cpp
@@ -10,6 +10,7 @@
#include "utility/messaging/type/error/MessageShowError.h"
#include "utility/messaging/type/MessageScrollCode.h"
#include "utility/ResourcePaths.h"
+#include "utility/utility.h"
#include "data/location/SourceLocation.h"
#include "data/location/SourceLocationCollection.h"
@@ -18,6 +19,7 @@
#include "qt/element/QtCodeFile.h"
#include "qt/element/QtCodeSnippet.h"
#include "qt/element/QtSearchBarButton.h"
+#include "qt/utility/utilityQt.h"
#include "settings/ApplicationSettings.h"
QtCodeNavigator::QtCodeNavigator(QWidget* parent)
@@ -44,32 +46,87 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
navLayout->setSpacing(2);
navLayout->setContentsMargins(7, 7, 7, 6);
+ {
+ m_prevFileButton =
+ new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_left.png"), true);
+ m_nextFileButton =
+ new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_right.png"), true);
+ m_prevReferenceButton =
+ new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_up.png"), true);
+ m_nextReferenceButton =
+ new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_down.png"), true);
- m_prevButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_left.png"), true);
- m_nextButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_right.png"), true);
+ m_prevFileButton->setObjectName("file_button_previous");
+ m_nextFileButton->setObjectName("file_button_next");
+ m_prevReferenceButton->setObjectName("reference_button_previous");
+ m_nextReferenceButton->setObjectName("reference_button_next");
- m_prevButton->setObjectName("reference_button_previous");
- m_nextButton->setObjectName("reference_button_next");
+ m_prevFileButton->setToolTip("previous file");
+ m_nextFileButton->setToolTip("next file");
+ m_prevReferenceButton->setToolTip("previous reference");
+ m_nextReferenceButton->setToolTip("next reference");
- m_prevButton->setToolTip("previous reference");
- m_nextButton->setToolTip("next reference");
+ m_prevFileButton->setIconSize(QSize(12, 12));
+ m_nextFileButton->setIconSize(QSize(12, 12));
+ m_prevReferenceButton->setIconSize(QSize(12, 12));
+ m_nextReferenceButton->setIconSize(QSize(12, 12));
- m_prevButton->setIconSize(QSize(12, 12));
- m_nextButton->setIconSize(QSize(12, 12));
+ m_prevFileButton->hide();
+ m_nextFileButton->hide();
- navLayout->addWidget(m_prevButton);
- navLayout->addWidget(m_nextButton);
+ navLayout->addWidget(m_prevFileButton);
+ navLayout->addWidget(m_prevReferenceButton);
+ navLayout->addWidget(m_nextReferenceButton);
+ navLayout->addWidget(m_nextFileButton);
- connect(m_prevButton, &QPushButton::clicked, this, &QtCodeNavigator::previousReference);
- connect(m_nextButton, &QPushButton::clicked, this, &QtCodeNavigator::nextReference);
+ connect(m_prevFileButton, &QPushButton::clicked, this, &QtCodeNavigator::previousFile);
+ connect(m_nextFileButton, &QPushButton::clicked, this, &QtCodeNavigator::nextFile);
+ connect(m_prevReferenceButton, &QPushButton::clicked, this, &QtCodeNavigator::previousReference);
+ connect(m_nextReferenceButton, &QPushButton::clicked, this, &QtCodeNavigator::nextReference);
+ // m_refLabel = new QLabel("0 files | 0 references");
+ m_refLabel = new QLabel("0 references");
+ m_refLabel->setObjectName("references_label");
+ navLayout->addWidget(m_refLabel);
- m_refLabel = new QLabel("0/0 references");
- m_refLabel->setObjectName("references_label");
- navLayout->addWidget(m_refLabel);
+ navLayout->addStretch();
+ }
- navLayout->addStretch();
+ {
+ m_prevLocalReferenceButton =
+ new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_up.png"), true);
+ m_nextLocalReferenceButton =
+ new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_down.png"), true);
+ m_prevLocalReferenceButton->setObjectName("local_reference_button_previous");
+ m_nextLocalReferenceButton->setObjectName("local_reference_button_next");
+
+ m_prevLocalReferenceButton->setToolTip("previous local reference");
+ m_nextLocalReferenceButton->setToolTip("next local reference");
+
+ m_prevLocalReferenceButton->setIconSize(QSize(12, 12));
+ m_nextLocalReferenceButton->setIconSize(QSize(12, 12));
+
+ navLayout->addWidget(m_prevLocalReferenceButton);
+ navLayout->addWidget(m_nextLocalReferenceButton);
+
+ connect(m_prevLocalReferenceButton, &QPushButton::clicked, this, &QtCodeNavigator::previousLocalReference);
+ connect(m_nextLocalReferenceButton, &QPushButton::clicked, this, &QtCodeNavigator::nextLocalReference);
+
+ m_localRefLabel = new QLabel("0/0 local references");
+ m_localRefLabel->setObjectName("references_label");
+ navLayout->addWidget(m_localRefLabel);
+
+ navLayout->addStretch();
+
+ utility::setWidgetRetainsSpaceWhenHidden(m_prevLocalReferenceButton);
+ utility::setWidgetRetainsSpaceWhenHidden(m_nextLocalReferenceButton);
+ utility::setWidgetRetainsSpaceWhenHidden(m_localRefLabel);
+
+ m_prevLocalReferenceButton->hide();
+ m_nextLocalReferenceButton->hide();
+ m_localRefLabel->hide();
+ }
m_listButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/list.png"), true);
m_fileButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/file.png"), true);
@@ -139,6 +196,12 @@ void QtCodeNavigator::addCodeSnippet(const CodeSnippetParams& params)
{
m_singleHasNewFile = true;
}
+
+ // refresh local reference count when visible code changes
+ if (m_localReferences.size() && m_localReferences[0].locationType == LOCATION_LOCAL_SYMBOL)
+ {
+ setActiveLocalTokenIds(utility::toVector(m_activeLocalTokenIds), LOCATION_LOCAL_SYMBOL);
+ }
}
void QtCodeNavigator::updateCodeSnippet(const CodeSnippetParams& params)
@@ -205,14 +268,16 @@ void QtCodeNavigator::addedFiles()
if (m_refIndex == 0)
{
- updateRefLabel();
+ updateRefLabels();
}
}
void QtCodeNavigator::clear()
{
clearCodeSnippets(false);
- updateRefLabel();
+ clearCaches();
+
+ updateRefLabels();
}
void QtCodeNavigator::clearCodeSnippets(bool useSingleFileCache)
@@ -221,7 +286,7 @@ void QtCodeNavigator::clearCodeSnippets(bool useSingleFileCache)
m_currentActiveTokenIds.clear();
m_activeTokenIds.clear();
- m_activeLocalSymbolIds.clear();
+ m_activeLocalTokenIds.clear();
m_focusedTokenIds.clear();
m_errorInfos.clear();
@@ -246,7 +311,7 @@ void QtCodeNavigator::clearFile()
{
m_single->clearFile();
- updateRefLabel();
+ updateRefLabels();
}
void QtCodeNavigator::clearCaches()
@@ -291,10 +356,22 @@ const std::set& QtCodeNavigator::getCurrentActiveLocationIds() const
void QtCodeNavigator::setCurrentActiveLocationIds(const std::vector& currentActiveLocationIds)
{
+ setActiveLocalTokenIds({ }, LOCATION_TOKEN);
+
m_currentActiveLocationIds = std::set(currentActiveLocationIds.begin(), currentActiveLocationIds.end());
m_currentActiveTokenIds.clear();
}
+const std::set& QtCodeNavigator::getCurrentActiveLocalLocationIds() const
+{
+ return m_currentActiveLocalLocationIds;
+}
+
+void QtCodeNavigator::setCurrentActiveLocalLocationIds(const std::vector& currentActiveLocalLocationIds)
+{
+ m_currentActiveLocalLocationIds = std::set(currentActiveLocalLocationIds.begin(), currentActiveLocalLocationIds.end());
+}
+
const std::set& QtCodeNavigator::getActiveTokenIds() const
{
return m_activeTokenIds;
@@ -302,22 +379,40 @@ const std::set& QtCodeNavigator::getActiveTokenIds() const
void QtCodeNavigator::setActiveTokenIds(const std::vector& activeTokenIds)
{
+ setActiveLocalTokenIds({ }, LOCATION_TOKEN);
setCurrentActiveTokenIds(activeTokenIds);
m_activeTokenIds = std::set(activeTokenIds.begin(), activeTokenIds.end());
m_activeTokenId = activeTokenIds.size() ? activeTokenIds[0] : 0;
-
- m_activeLocalSymbolIds.clear();
}
-const std::set& QtCodeNavigator::getActiveLocalSymbolIds() const
+const std::set& QtCodeNavigator::getActiveLocalTokenIds() const
{
- return m_activeLocalSymbolIds;
+ return m_activeLocalTokenIds;
}
-void QtCodeNavigator::setActiveLocalSymbolIds(const std::vector& activeLocalSymbolIds)
+void QtCodeNavigator::setActiveLocalTokenIds(const std::vector& activeLocalTokenIds, LocationType locationType)
{
- m_activeLocalSymbolIds = std::set(activeLocalSymbolIds.begin(), activeLocalSymbolIds.end());
+ setCurrentActiveTokenIds(locationType == LOCATION_TOKEN ? activeLocalTokenIds : std::vector());
+ setCurrentActiveLocalLocationIds({ });
+
+ m_activeLocalTokenIds.clear();
+ m_activeLocalTokenIds.insert(activeLocalTokenIds.begin(), activeLocalTokenIds.end());
+
+ m_localReferences.clear();
+ m_localRefIndex = 0;
+
+ if (m_activeLocalTokenIds.size())
+ {
+ for (std::pair p : m_current->getLocationIdsForTokenIds(m_activeLocalTokenIds))
+ {
+ Reference ref;
+ ref.filePath = p.first;
+ ref.locationId = p.second;
+ ref.locationType = locationType;
+ m_localReferences.push_back(ref);
+ }
+ }
}
const std::set& QtCodeNavigator::getFocusedTokenIds() const
@@ -393,6 +488,13 @@ void QtCodeNavigator::showActiveSnippet(
m_activeReference = Reference();
Id tokenId = activeTokenIds[0];
+ // iterate local references when same tokenId get reactivated (consecutive edge clicks)
+ if (m_activeLocalTokenIds.size() == 1 && *m_activeLocalTokenIds.begin() == tokenId && m_localReferences.size())
+ {
+ nextLocalReference();
+ return;
+ }
+
std::vector locationIds;
size_t refIndex = 0;
Reference firstReference;
@@ -450,7 +552,7 @@ void QtCodeNavigator::showActiveSnippet(
);
}
- setCurrentActiveLocationIds(locationIds);
+ setActiveLocalTokenIds({ tokenId }, LOCATION_TOKEN);
updateFiles();
if (m_mode == MODE_LIST)
@@ -474,7 +576,7 @@ void QtCodeNavigator::showActiveSnippet(
}
m_refIndex = refIndex;
- updateRefLabel();
+ updateRefLabels();
if (!refIndex)
{
@@ -522,7 +624,7 @@ void QtCodeNavigator::setFileMaximized(const FilePath path)
void QtCodeNavigator::updateFiles()
{
m_current->updateFiles();
- updateRefLabel();
+ updateRefLabels();
}
void QtCodeNavigator::showContents()
@@ -637,7 +739,7 @@ void QtCodeNavigator::scrollToDefinition(bool animated, bool ignoreActiveReferen
{
m_activeReference = Reference();
m_refIndex = 0;
- updateRefLabel();
+ updateRefLabels();
}
if (m_activeReference.tokenId)
@@ -650,7 +752,7 @@ void QtCodeNavigator::scrollToDefinition(bool animated, bool ignoreActiveReferen
requestScroll(m_activeReference.filePath, 0, m_activeReference.locationId, true, QtCodeNavigateable::SCROLL_CENTER);
emit scrollRequest();
- updateRefLabel();
+ updateRefLabels();
return;
}
@@ -772,6 +874,66 @@ void QtCodeNavigator::setValue()
}
}
+void QtCodeNavigator::previousFile(bool fromUI)
+{
+ if (!m_references.size())
+ {
+ return;
+ }
+
+ if (m_refIndex == 0)
+ {
+ m_refIndex = m_references.size();
+ }
+ else
+ {
+ const Reference& ref = m_references[m_refIndex - 1];
+ do
+ {
+ m_refIndex--;
+ if (m_refIndex == 0)
+ {
+ m_refIndex = m_references.size();
+ }
+ }
+ while (&ref != &m_references[m_refIndex - 1] && ref.filePath == m_references[m_refIndex - 1].filePath);
+ }
+
+ m_activeReference = Reference();
+
+ showCurrentReference(fromUI);
+}
+
+void QtCodeNavigator::nextFile(bool fromUI)
+{
+ if (!m_references.size())
+ {
+ return;
+ }
+
+ if (m_refIndex == 0)
+ {
+ m_refIndex++;
+ }
+ else
+ {
+ const Reference& ref = m_references[m_refIndex - 1];
+ do
+ {
+ if (m_refIndex == m_references.size())
+ {
+ m_refIndex = 0;
+ }
+ m_refIndex++;
+ }
+ while (&ref != &m_references[m_refIndex - 1] && ref.filePath == m_references[m_refIndex - 1].filePath);
+ }
+
+ m_activeReference = Reference();
+
+ showCurrentReference(fromUI);
+}
+
void QtCodeNavigator::previousReference(bool fromUI)
{
if (!m_references.size())
@@ -812,6 +974,42 @@ void QtCodeNavigator::nextReference(bool fromUI)
showCurrentReference(fromUI);
}
+void QtCodeNavigator::previousLocalReference(bool fromUI)
+{
+ if (!m_localReferences.size())
+ {
+ return;
+ }
+
+ if (m_localRefIndex < 2)
+ {
+ m_localRefIndex = m_localReferences.size();
+ }
+ else
+ {
+ m_localRefIndex--;
+ }
+
+ showCurrentLocalReference();
+}
+
+void QtCodeNavigator::nextLocalReference(bool fromUI)
+{
+ if (!m_localReferences.size())
+ {
+ return;
+ }
+
+ m_localRefIndex++;
+
+ if (m_localRefIndex == m_localReferences.size() + 1)
+ {
+ m_localRefIndex = 1;
+ }
+
+ showCurrentLocalReference();
+}
+
void QtCodeNavigator::setModeList()
{
if (m_mode == MODE_LIST)
@@ -846,39 +1044,116 @@ void QtCodeNavigator::showCurrentReference(bool fromUI)
MessageShowReference(m_refIndex, ref.tokenId, ref.locationId, fromUI).dispatch();
}
-void QtCodeNavigator::updateRefLabel()
-{
- size_t n = m_references.size();
- size_t t = m_refIndex;
- if (t)
+void QtCodeNavigator::showCurrentLocalReference()
+{
+ if (m_localRefIndex > 0)
{
- m_refLabel->setText(QString::number(t) + "/" + QString::number(n) + " references");
+ const Reference& ref = m_localReferences[m_localRefIndex - 1];
+ setCurrentActiveLocalLocationIds({ ref.locationId });
+
+ if (ref.locationType == LOCATION_TOKEN)
+ {
+ setCurrentActiveTokenIds({ });
+
+ // synchronise reference navigation with local reference navigation
+ for (size_t i = 0; i < m_references.size(); i++)
+ {
+ if (m_references[i].locationId == ref.locationId)
+ {
+ m_refIndex = i + 1;
+ }
+ }
+ }
+
+ updateFiles();
+
+ requestScroll(ref.filePath, 0, ref.locationId, true, QtCodeNavigateable::SCROLL_CENTER);
+ emit scrollRequest();
+ }
+}
+
+void QtCodeNavigator::updateRefLabels()
+{
+ size_t refCount = m_references.size();
+
+ // std::set files;
+ // size_t fileIndex = 0;
+ // for (size_t i = 0; i < m_references.size(); i++)
+ // {
+ // const Reference& ref = m_references[i];
+ // files.insert(ref.filePath);
+ // if (i == m_refIndex - 1)
+ // {
+ // fileIndex = files.size();
+ // }
+ // }
+
+ if (m_refIndex)
+ {
+ m_refLabel->setText(QString::number(m_refIndex) + "/" + QString::number(refCount) + " references");
+ // m_refLabel->setText(
+ // QString::number(fileIndex) + "/" + QString::number(files.size()) + " files | " +
+ // QString::number(m_refIndex) + "/" + QString::number(refCount) + " references"
+ // );
}
else
{
- m_refLabel->setText(QString::number(n) + " references");
+ m_refLabel->setText(QString::number(refCount) + " references");
+ // m_refLabel->setText(QString::number(files.size()) + " files | " + QString::number(refCount) + " references");
}
- m_prevButton->setEnabled(n > 1);
- m_nextButton->setEnabled(n > 1);
+ m_refLabel->setMinimumWidth(
+ m_refLabel->fontMetrics().width(QString(QString::number(refCount).size() * 2, 'a') + "/ references") + 30);
+
+ m_prevFileButton->setEnabled(refCount > 1);
+ m_nextFileButton->setEnabled(refCount > 1);
+ m_prevReferenceButton->setEnabled(refCount > 1);
+ m_nextReferenceButton->setEnabled(refCount > 1);
+
+
+ size_t localRefCount = m_localReferences.size();
+ if (m_localRefIndex)
+ {
+ m_localRefLabel->setText(QString::number(m_localRefIndex) + "/" + QString::number(localRefCount) + " local references");
+ }
+ else
+ {
+ m_localRefLabel->setText(QString::number(localRefCount) + " local references");
+ }
+
+ m_localRefLabel->setMinimumWidth(
+ m_localRefLabel->fontMetrics().width(QString(QString::number(localRefCount).size() * 2, 'a') + "/ local references") + 30);
+
+ m_nextLocalReferenceButton->setVisible(localRefCount > 1);
+ m_prevLocalReferenceButton->setVisible(localRefCount > 1);
+ m_localRefLabel->setVisible(localRefCount > 1);
}
void QtCodeNavigator::handleMessage(MessageCodeReference* message)
{
- MessageCodeReference::ReferenceType type = message->type;
+ bool next = (message->type == MessageCodeReference::REFERENCE_NEXT);
+ bool local = message->localReference;
m_onQtThread(
[=]()
{
- if (type == MessageCodeReference::REFERENCE_PREVIOUS)
+ if (next && local)
{
- previousReference();
+ nextLocalReference();
}
- else if (type == MessageCodeReference::REFERENCE_NEXT)
+ else if (next)
{
nextReference();
}
+ else if (local)
+ {
+ previousLocalReference();
+ }
+ else
+ {
+ previousReference();
+ }
}
);
}
@@ -906,7 +1181,7 @@ void QtCodeNavigator::handleMessage(MessageShowReference* message)
if (m_refIndex > 0)
{
const Reference& ref = m_references[m_refIndex - 1];
- setCurrentActiveLocationIds(std::vector(1, ref.locationId));
+ setCurrentActiveLocationIds({ ref.locationId });
if (!replayed)
{
@@ -924,7 +1199,7 @@ void QtCodeNavigator::handleMessage(MessageShowReference* message)
if (!replayed)
{
- updateRefLabel();
+ updateRefLabels();
}
}
);
diff --git a/src/lib_gui/qt/element/QtCodeNavigator.h b/src/lib_gui/qt/element/QtCodeNavigator.h
index 0839d48d..e6686e9e 100644
--- a/src/lib_gui/qt/element/QtCodeNavigator.h
+++ b/src/lib_gui/qt/element/QtCodeNavigator.h
@@ -62,11 +62,14 @@ public:
const std::set& getCurrentActiveLocationIds() const;
void setCurrentActiveLocationIds(const std::vector& currentActiveLocationIds);
+ const std::set& getCurrentActiveLocalLocationIds() const;
+ void setCurrentActiveLocalLocationIds(const std::vector& currentActiveLocalLocationIds);
+
const std::set& getActiveTokenIds() const;
void setActiveTokenIds(const std::vector& activeTokenIds);
- const std::set& getActiveLocalSymbolIds() const;
- void setActiveLocalSymbolIds(const std::vector& activeLocalSymbolIds);
+ const std::set& getActiveLocalTokenIds() const;
+ void setActiveLocalTokenIds(const std::vector& activeLocalTokenIds, LocationType locationType);
const std::set& getFocusedTokenIds() const;
void setFocusedTokenIds(const std::vector& focusedTokenIds);
@@ -119,9 +122,15 @@ private slots:
void handleScrollRequest();
void setValue();
+ void previousFile(bool fromUI = true);
+ void nextFile(bool fromUI = true);
+
void previousReference(bool fromUI = true);
void nextReference(bool fromUI = true);
+ void previousLocalReference(bool fromUI = true);
+ void nextLocalReference(bool fromUI = true);
+
void setModeList();
void setModeSingle();
@@ -142,7 +151,8 @@ private:
};
void showCurrentReference(bool fromUI);
- void updateRefLabel();
+ void showCurrentLocalReference();
+ void updateRefLabels();
struct ScrollRequest
{
@@ -179,9 +189,10 @@ private:
std::set m_currentActiveTokenIds;
std::set m_currentActiveLocationIds;
+ std::set m_currentActiveLocalLocationIds;
std::set m_activeTokenIds;
- std::set m_activeLocalSymbolIds;
+ std::set m_activeLocalTokenIds;
std::set m_focusedTokenIds;
std::map m_errorInfos;
@@ -189,18 +200,28 @@ private:
int m_value;
- QtSearchBarButton* m_listButton;
- QtSearchBarButton* m_fileButton;
+ QtSearchBarButton* m_prevFileButton;
+ QtSearchBarButton* m_nextFileButton;
+ QtSearchBarButton* m_prevReferenceButton;
+ QtSearchBarButton* m_nextReferenceButton;
QLabel* m_refLabel;
- QtSearchBarButton* m_prevButton;
- QtSearchBarButton* m_nextButton;
+ QtSearchBarButton* m_prevLocalReferenceButton;
+ QtSearchBarButton* m_nextLocalReferenceButton;
+ QLabel* m_localRefLabel;
+
+ QtSearchBarButton* m_listButton;
+ QtSearchBarButton* m_fileButton;
+
QFrame* m_separatorLine;
std::vector m_references;
Reference m_activeReference;
size_t m_refIndex;
+ std::vector m_localReferences;
+ size_t m_localRefIndex;
+
ScrollRequest m_scrollRequest;
bool m_singleHasNewFile;
bool m_useSingleFileCache;
diff --git a/src/lib_gui/qt/element/QtCodeSnippet.cpp b/src/lib_gui/qt/element/QtCodeSnippet.cpp
index bdc2613c..5c9cd2b4 100644
--- a/src/lib_gui/qt/element/QtCodeSnippet.cpp
+++ b/src/lib_gui/qt/element/QtCodeSnippet.cpp
@@ -199,6 +199,11 @@ void QtCodeSnippet::findScreenMatches(const std::wstring& query, std::vectorfindScreenMatches(query, screenMatches);
}
+std::vector QtCodeSnippet::getLocationIdsForTokenIds(const std::set& tokenIds) const
+{
+ return m_codeArea->getLocationIdsForTokenIds(tokenIds);
+}
+
void QtCodeSnippet::ensureLocationIdVisible(Id locationId, bool animated)
{
m_codeArea->ensureLocationIdVisible(locationId, width(), animated);
diff --git a/src/lib_gui/qt/element/QtCodeSnippet.h b/src/lib_gui/qt/element/QtCodeSnippet.h
index cd66f7b0..d16c5e6f 100644
--- a/src/lib_gui/qt/element/QtCodeSnippet.h
+++ b/src/lib_gui/qt/element/QtCodeSnippet.h
@@ -54,6 +54,8 @@ public:
void findScreenMatches(const std::wstring& query, std::vector>* screenMatches);
+ std::vector getLocationIdsForTokenIds(const std::set& tokenIds) const;
+
void ensureLocationIdVisible(Id locationId, bool animated);
private slots:
diff --git a/src/lib_gui/qt/element/QtSearchBarButton.cpp b/src/lib_gui/qt/element/QtSearchBarButton.cpp
index 252580ae..2c9324a9 100644
--- a/src/lib_gui/qt/element/QtSearchBarButton.cpp
+++ b/src/lib_gui/qt/element/QtSearchBarButton.cpp
@@ -6,6 +6,7 @@ QtSearchBarButton::QtSearchBarButton(const FilePath& iconPath, bool small, QWidg
: QtSelfRefreshIconButton("", iconPath, "search/button", parent)
, m_small(small)
{
+ refresh();
}
void QtSearchBarButton::refresh()
diff --git a/src/lib_gui/qt/view/QtCodeView.cpp b/src/lib_gui/qt/view/QtCodeView.cpp
index 4fabbc17..840a03b9 100644
--- a/src/lib_gui/qt/view/QtCodeView.cpp
+++ b/src/lib_gui/qt/view/QtCodeView.cpp
@@ -216,7 +216,7 @@ void QtCodeView::showActiveLocalSymbolIds(const std::vector& activeLocalSymb
{
m_onQtThread([=]()
{
- m_widget->setActiveLocalSymbolIds(activeLocalSymbolIds);
+ m_widget->setActiveLocalTokenIds(activeLocalSymbolIds, LOCATION_LOCAL_SYMBOL);
m_widget->updateFiles();
});
}
diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp
index 4263e10f..b0b48ada 100644
--- a/src/lib_gui/qt/window/QtMainWindow.cpp
+++ b/src/lib_gui/qt/window/QtMainWindow.cpp
@@ -617,12 +617,22 @@ void QtMainWindow::findOnScreen()
void QtMainWindow::codeReferencePrevious()
{
- MessageCodeReference(MessageCodeReference::REFERENCE_PREVIOUS).dispatch();
+ MessageCodeReference(MessageCodeReference::REFERENCE_PREVIOUS, false).dispatch();
}
void QtMainWindow::codeReferenceNext()
{
- MessageCodeReference(MessageCodeReference::REFERENCE_NEXT).dispatch();
+ MessageCodeReference(MessageCodeReference::REFERENCE_NEXT, false).dispatch();
+}
+
+void QtMainWindow::codeLocalReferencePrevious()
+{
+ MessageCodeReference(MessageCodeReference::REFERENCE_PREVIOUS, true).dispatch();
+}
+
+void QtMainWindow::codeLocalReferenceNext()
+{
+ MessageCodeReference(MessageCodeReference::REFERENCE_NEXT, true).dispatch();
}
void QtMainWindow::overview()
@@ -828,6 +838,11 @@ void QtMainWindow::setupEditMenu()
menu->addAction(tr("Code Reference Previous"), this,
&QtMainWindow::codeReferencePrevious, QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_G));
+ menu->addAction(tr("Code Local Reference Next"), this,
+ &QtMainWindow::codeLocalReferenceNext, QKeySequence(Qt::CTRL + Qt::Key_T));
+ menu->addAction(tr("Code Local Reference Previous"), this,
+ &QtMainWindow::codeLocalReferencePrevious, QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_T));
+
menu->addSeparator();
menu->addAction(tr("&To overview"), this, &QtMainWindow::overview, QKeySequence::MoveToStartOfDocument);
diff --git a/src/lib_gui/qt/window/QtMainWindow.h b/src/lib_gui/qt/window/QtMainWindow.h
index e8960798..99acf29b 100644
--- a/src/lib_gui/qt/window/QtMainWindow.h
+++ b/src/lib_gui/qt/window/QtMainWindow.h
@@ -124,6 +124,8 @@ public slots:
void findOnScreen();
void codeReferencePrevious();
void codeReferenceNext();
+ void codeLocalReferencePrevious();
+ void codeLocalReferenceNext();
void overview();
void closeWindow();