ui: Fixed switching code view mode shows active reference
This commit is contained in:
@@ -350,7 +350,7 @@ Id QtCodeArea::getLocationIdOfFirstActiveLocation(Id tokenId) const
|
|||||||
for (const Annotation& annotation : m_annotations)
|
for (const Annotation& annotation : m_annotations)
|
||||||
{
|
{
|
||||||
if (annotation.locationType == LocationType::LOCATION_TOKEN && annotation.isActive &&
|
if (annotation.locationType == LocationType::LOCATION_TOKEN && annotation.isActive &&
|
||||||
annotation.tokenIds.find(tokenId) != annotation.tokenIds.end())
|
(!tokenId || annotation.tokenIds.find(tokenId) != annotation.tokenIds.end()))
|
||||||
{
|
{
|
||||||
return annotation.locationId;
|
return annotation.locationId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,13 +408,26 @@ void QtCodeFile::clickedSnippetButton()
|
|||||||
|
|
||||||
void QtCodeFile::clickedMaximizeButton()
|
void QtCodeFile::clickedMaximizeButton()
|
||||||
{
|
{
|
||||||
uint firstLineNumber = 1;
|
uint lineNumber = 0;
|
||||||
std::vector<QtCodeSnippet*> snippets = getVisibleSnippets();
|
Id locationId = 0;
|
||||||
if (snippets.size())
|
|
||||||
|
std::pair<QtCodeSnippet*, Id> snippet = getFirstSnippetWithActiveLocationId(0);
|
||||||
|
if (snippet.first)
|
||||||
{
|
{
|
||||||
firstLineNumber = snippets[0]->getStartLineNumber();
|
locationId = snippet.second;
|
||||||
}
|
}
|
||||||
m_navigator->requestScroll(m_filePath, firstLineNumber, 0, false, QtCodeNavigateable::SCROLL_CENTER);
|
else
|
||||||
|
{
|
||||||
|
lineNumber = 1;
|
||||||
|
|
||||||
|
std::vector<QtCodeSnippet*> snippets = getVisibleSnippets();
|
||||||
|
if (snippets.size())
|
||||||
|
{
|
||||||
|
lineNumber = snippets[0]->getStartLineNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_navigator->requestScroll(m_filePath, lineNumber, locationId, false, QtCodeNavigateable::SCROLL_CENTER);
|
||||||
|
|
||||||
MessageChangeFileView(
|
MessageChangeFileView(
|
||||||
m_filePath,
|
m_filePath,
|
||||||
|
|||||||
@@ -323,6 +323,25 @@ void QtCodeFileList::maximizeFirstFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<QtCodeFile*, Id> QtCodeFileList::getFirstFileWithActiveLocationId() const
|
||||||
|
{
|
||||||
|
for (QtCodeFile* file : m_files)
|
||||||
|
{
|
||||||
|
if (file->isCollapsed())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<QtCodeSnippet*, Id> snippet = file->getFirstSnippetWithActiveLocationId(0);
|
||||||
|
if (snippet.first != nullptr)
|
||||||
|
{
|
||||||
|
return std::make_pair(file, snippet.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_pair(nullptr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<QtCodeSnippet*, Id> QtCodeFileList::getFirstSnippetWithActiveLocationId(Id tokenId) const
|
std::pair<QtCodeSnippet*, Id> QtCodeFileList::getFirstSnippetWithActiveLocationId(Id tokenId) const
|
||||||
{
|
{
|
||||||
std::pair<QtCodeSnippet*, Id> result(nullptr, 0);
|
std::pair<QtCodeSnippet*, Id> result(nullptr, 0);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
|
|
||||||
void maximizeFirstFile();
|
void maximizeFirstFile();
|
||||||
|
|
||||||
|
std::pair<QtCodeFile*, Id> getFirstFileWithActiveLocationId() const;
|
||||||
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
|
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -821,12 +821,30 @@ void QtCodeNavigator::nextReference(bool fromUI)
|
|||||||
|
|
||||||
void QtCodeNavigator::setModeList()
|
void QtCodeNavigator::setModeList()
|
||||||
{
|
{
|
||||||
|
if (m_mode == MODE_LIST)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_single->clickedSnippetButton();
|
m_single->clickedSnippetButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeNavigator::setModeSingle()
|
void QtCodeNavigator::setModeSingle()
|
||||||
{
|
{
|
||||||
m_list->maximizeFirstFile();
|
if (m_mode == MODE_SINGLE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QtCodeFile* file = m_list->getFirstFileWithActiveLocationId().first;
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
file->clickedMaximizeButton();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_list->maximizeFirstFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeNavigator::showCurrentReference(bool fromUI)
|
void QtCodeNavigator::showCurrentReference(bool fromUI)
|
||||||
|
|||||||
Reference in New Issue
Block a user