logic: Refactored Code View to process all contents in one update
* Use unified showCodeSnippets method for setting file information on CodeView * Made async initial file and snippet expansion synced * Add ScrollParams API to CodeView * Regard scope size when scrolling to definition * Only use QtThreadedLambdaFunctor in QtCodeView now
This commit is contained in:
@@ -153,7 +153,6 @@ QtCodeArea::QtCodeArea(
|
||||
m_highlighter->highlightDocument();
|
||||
|
||||
createAnnotations(locationFile);
|
||||
annotateText();
|
||||
}
|
||||
|
||||
QtCodeArea::~QtCodeArea()
|
||||
@@ -294,39 +293,38 @@ uint QtCodeArea::getLineNumberForLocationId(Id locationId) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint QtCodeArea::getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const
|
||||
std::pair<uint, uint> QtCodeArea::getLineNumbersForLocationId(Id locationId) const
|
||||
{
|
||||
int firstActiveLine = 0;
|
||||
for (const Annotation& annotation : m_annotations)
|
||||
{
|
||||
if (annotation.locationType == LocationType::LOCATION_TOKEN && annotation.isActive)
|
||||
if (annotation.locationId == locationId)
|
||||
{
|
||||
if (annotation.tokenIds.find(tokenId) != annotation.tokenIds.end())
|
||||
{
|
||||
if (!firstActiveLine || firstActiveLine == annotation.startLine)
|
||||
{
|
||||
return getStartLineNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
return annotation.startLine;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
firstActiveLine = annotation.startLine;
|
||||
}
|
||||
return std::pair<uint, uint>(annotation.startLine, annotation.endLine);
|
||||
}
|
||||
}
|
||||
|
||||
return std::pair<uint, uint>(0, 0);
|
||||
}
|
||||
|
||||
Id QtCodeArea::getLocationIdOfFirstActiveLocation(Id tokenId) const
|
||||
{
|
||||
for (const Annotation& annotation : m_annotations)
|
||||
{
|
||||
if (annotation.locationType == LocationType::LOCATION_TOKEN && annotation.isActive &&
|
||||
annotation.tokenIds.find(tokenId) != annotation.tokenIds.end())
|
||||
{
|
||||
return annotation.locationId;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Id QtCodeArea::getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const
|
||||
Id QtCodeArea::getLocationIdOfFirstActiveScopeLocation(Id tokenId) const
|
||||
{
|
||||
for (const Annotation& annotation : m_annotations)
|
||||
{
|
||||
if (annotation.locationType == LocationType::LOCATION_TOKEN && annotation.isActive &&
|
||||
if (annotation.locationType == LocationType::LOCATION_SCOPE && annotation.isActive &&
|
||||
annotation.tokenIds.find(tokenId) != annotation.tokenIds.end())
|
||||
{
|
||||
return annotation.locationId;
|
||||
|
||||
@@ -85,8 +85,11 @@ public:
|
||||
void setIsActiveFile(bool isActiveFile);
|
||||
|
||||
uint getLineNumberForLocationId(Id locationId) const;
|
||||
uint getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const;
|
||||
Id getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const;
|
||||
std::pair<uint, uint> getLineNumbersForLocationId(Id locationId) const;
|
||||
|
||||
Id getLocationIdOfFirstActiveLocation(Id tokenId) const;
|
||||
Id getLocationIdOfFirstActiveScopeLocation(Id tokenId) const;
|
||||
|
||||
uint getActiveLocationCount() const;
|
||||
|
||||
QRectF getLineRectForLineNumber(uint lineNumber) const;
|
||||
|
||||
@@ -226,17 +226,17 @@ QtCodeSnippet* QtCodeFile::getFileSnippet() const
|
||||
return m_fileSnippet.get();
|
||||
}
|
||||
|
||||
std::pair<QtCodeSnippet*, uint> QtCodeFile::getFirstSnippetWithActiveLocation(Id tokenId) const
|
||||
std::pair<QtCodeSnippet*, Id> QtCodeFile::getFirstSnippetWithActiveLocationId(Id tokenId) const
|
||||
{
|
||||
std::pair<QtCodeSnippet*, uint> result(nullptr, 0);
|
||||
std::pair<QtCodeSnippet*, Id> result(nullptr, 0);
|
||||
|
||||
for (std::shared_ptr<QtCodeSnippet> snippet : m_snippets)
|
||||
{
|
||||
uint startLineNumber = snippet->getStartLineNumberOfFirstActiveLocationOfTokenId(tokenId);
|
||||
if (startLineNumber != 0)
|
||||
Id locationId = snippet->getFirstActiveLocationId(tokenId);
|
||||
if (locationId != 0)
|
||||
{
|
||||
result.first = snippet.get();
|
||||
result.second = startLineNumber;
|
||||
result.second = locationId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ bool QtCodeFile::isCollapsed() const
|
||||
return m_isCollapsed;
|
||||
}
|
||||
|
||||
void QtCodeFile::requestContent(bool isFirstInList)
|
||||
void QtCodeFile::requestContent()
|
||||
{
|
||||
if (!isCollapsed() || m_contentRequested)
|
||||
{
|
||||
@@ -260,12 +260,7 @@ void QtCodeFile::requestContent(bool isFirstInList)
|
||||
m_contentRequested = true;
|
||||
|
||||
MessageChangeFileView::FileState state =
|
||||
isFirstInList ? MessageChangeFileView::FILE_DEFAULT_FOR_MODE : MessageChangeFileView::FILE_SNIPPETS;
|
||||
|
||||
if (m_isWholeFile)
|
||||
{
|
||||
state = MessageChangeFileView::FILE_MAXIMIZED;
|
||||
}
|
||||
m_isWholeFile ? MessageChangeFileView::FILE_MAXIMIZED : MessageChangeFileView::FILE_SNIPPETS;
|
||||
|
||||
MessageChangeFileView(m_filePath, state, isCollapsed(), m_navigator->hasErrors()).dispatch();
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ public:
|
||||
QtCodeSnippet* getSnippetForLine(unsigned int line) const;
|
||||
QtCodeSnippet* getFileSnippet() const;
|
||||
|
||||
std::pair<QtCodeSnippet*, uint> getFirstSnippetWithActiveLocation(Id tokenId) const;
|
||||
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
|
||||
|
||||
bool isCollapsed() const;
|
||||
|
||||
void requestContent(bool isFirstInList = false);
|
||||
void requestContent();
|
||||
void updateContent();
|
||||
|
||||
void setWholeFile(bool isWholeFile, int refCount);
|
||||
|
||||
@@ -83,14 +83,12 @@ QScrollArea* QtCodeFileList::getScrollArea()
|
||||
return this;
|
||||
}
|
||||
|
||||
void QtCodeFileList::addCodeSnippet(
|
||||
const CodeSnippetParams& params,
|
||||
bool insert
|
||||
){
|
||||
void QtCodeFileList::addCodeSnippet(const CodeSnippetParams& params)
|
||||
{
|
||||
QtCodeFile* file = getFile(params.locationFile->getFilePath());
|
||||
QtCodeSnippet* snippet = nullptr;
|
||||
|
||||
if (insert)
|
||||
if (params.insertSnippet)
|
||||
{
|
||||
snippet = file->insertCodeSnippet(params);
|
||||
}
|
||||
@@ -103,9 +101,9 @@ void QtCodeFileList::addCodeSnippet(
|
||||
file->setIsComplete(params.locationFile->isComplete());
|
||||
}
|
||||
|
||||
void QtCodeFileList::requestFileContent(const FilePath& filePath, bool isFirstInList)
|
||||
void QtCodeFileList::requestFileContent(const FilePath& filePath)
|
||||
{
|
||||
getFile(filePath)->requestContent(isFirstInList);
|
||||
getFile(filePath)->requestContent();
|
||||
}
|
||||
|
||||
bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop)
|
||||
@@ -147,11 +145,19 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id
|
||||
file->setSnippets();
|
||||
}
|
||||
|
||||
uint endLineNumber = 0;
|
||||
if (!lineNumber)
|
||||
{
|
||||
if (locationId)
|
||||
{
|
||||
lineNumber = snippet->getLineNumberForLocationId(locationId);
|
||||
std::pair<uint, uint> lineNumbers = snippet->getLineNumbersForLocationId(locationId);
|
||||
|
||||
lineNumber = lineNumbers.first;
|
||||
|
||||
if (lineNumbers.first != lineNumbers.second)
|
||||
{
|
||||
endLineNumber = lineNumbers.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -159,7 +165,13 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id
|
||||
}
|
||||
}
|
||||
|
||||
ensureWidgetVisibleAnimated(m_filesArea, snippet, snippet->getLineRectForLineNumber(lineNumber), animated, onTop);
|
||||
QRectF lineRect = snippet->getLineRectForLineNumber(lineNumber);
|
||||
if (endLineNumber)
|
||||
{
|
||||
lineRect |= snippet->getLineRectForLineNumber(endLineNumber);
|
||||
}
|
||||
|
||||
ensureWidgetVisibleAnimated(m_filesArea, snippet, lineRect, animated, onTop);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -203,9 +215,9 @@ void QtCodeFileList::setFileMaximized(const FilePath path)
|
||||
getFile(path)->setMaximized();
|
||||
}
|
||||
|
||||
std::pair<QtCodeSnippet*, uint> QtCodeFileList::getFirstSnippetWithActiveLocation(Id tokenId) const
|
||||
std::pair<QtCodeSnippet*, Id> QtCodeFileList::getFirstSnippetWithActiveLocationId(Id tokenId) const
|
||||
{
|
||||
std::pair<QtCodeSnippet*, uint> result(nullptr, 0);
|
||||
std::pair<QtCodeSnippet*, Id> result(nullptr, 0);
|
||||
|
||||
for (std::shared_ptr<QtCodeFile> filePtr : m_files)
|
||||
{
|
||||
@@ -214,7 +226,7 @@ std::pair<QtCodeSnippet*, uint> QtCodeFileList::getFirstSnippetWithActiveLocatio
|
||||
continue;
|
||||
}
|
||||
|
||||
result = filePtr->getFirstSnippetWithActiveLocation(tokenId);
|
||||
result = filePtr->getFirstSnippetWithActiveLocationId(tokenId);
|
||||
if (result.first != nullptr)
|
||||
{
|
||||
break;
|
||||
|
||||
@@ -33,9 +33,9 @@ public:
|
||||
// QtCodeNaviatebale implementation
|
||||
virtual QScrollArea* getScrollArea();
|
||||
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false);
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params);
|
||||
|
||||
void requestFileContent(const FilePath& filePath, bool isFirstInList = false);
|
||||
virtual void requestFileContent(const FilePath& filePath);
|
||||
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop);
|
||||
|
||||
virtual void updateFiles();
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
void setFileSnippets(const FilePath path);
|
||||
void setFileMaximized(const FilePath path);
|
||||
|
||||
std::pair<QtCodeSnippet*, uint> getFirstSnippetWithActiveLocation(Id tokenId) const;
|
||||
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
|
||||
|
||||
private:
|
||||
QtCodeNavigator* m_navigator;
|
||||
|
||||
@@ -20,6 +20,7 @@ QtCodeFileSingle::QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent)
|
||||
: m_navigator(navigator)
|
||||
, m_area(nullptr)
|
||||
, m_contentRequested(false)
|
||||
, m_scrollRequested(false)
|
||||
{
|
||||
setObjectName("code_container");
|
||||
|
||||
@@ -83,7 +84,7 @@ void QtCodeFileSingle::clearCache()
|
||||
m_filePaths.clear();
|
||||
}
|
||||
|
||||
void QtCodeFileSingle::addCodeSnippet(const CodeSnippetParams& params, bool insert)
|
||||
void QtCodeFileSingle::addCodeSnippet(const CodeSnippetParams& params)
|
||||
{
|
||||
if (!params.locationFile->isWhole())
|
||||
{
|
||||
@@ -163,11 +164,24 @@ bool QtCodeFileSingle::requestScroll(const FilePath& filePath, uint lineNumber,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_scrollRequested)
|
||||
{
|
||||
animated = false;
|
||||
}
|
||||
|
||||
uint endLineNumber = 0;
|
||||
if (!lineNumber)
|
||||
{
|
||||
if (locationId)
|
||||
{
|
||||
lineNumber = m_area->getLineNumberForLocationId(locationId);
|
||||
std::pair<uint, uint> lineNumbers = m_area->getLineNumbersForLocationId(locationId);
|
||||
|
||||
lineNumber = lineNumbers.first;
|
||||
|
||||
if (lineNumbers.first != lineNumbers.second)
|
||||
{
|
||||
endLineNumber = lineNumbers.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,7 +189,12 @@ bool QtCodeFileSingle::requestScroll(const FilePath& filePath, uint lineNumber,
|
||||
}
|
||||
}
|
||||
|
||||
ensurePercentVisibleAnimated(double(lineNumber - 1) / m_area->getEndLineNumber(), animated, onTop);
|
||||
double percentA = double(lineNumber - 1) / m_area->getEndLineNumber();
|
||||
double percentB = endLineNumber ? double(endLineNumber - 1) / m_area->getEndLineNumber() : 0.0f;
|
||||
|
||||
ensurePercentVisibleAnimated(percentA, percentB, animated, onTop);
|
||||
|
||||
m_scrollRequested = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -206,6 +225,11 @@ const FilePath& QtCodeFileSingle::getCurrentFilePath() const
|
||||
return m_currentFilePath;
|
||||
}
|
||||
|
||||
bool QtCodeFileSingle::hasFileCached(const FilePath& filePath) const
|
||||
{
|
||||
return getFileData(filePath).area != nullptr;
|
||||
}
|
||||
|
||||
Id QtCodeFileSingle::getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const
|
||||
{
|
||||
if (!m_area)
|
||||
@@ -213,7 +237,13 @@ Id QtCodeFileSingle::getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) con
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_area->getLocationIdOfFirstActiveLocationOfTokenId(tokenId);
|
||||
Id scopeId = m_area->getLocationIdOfFirstActiveScopeLocation(tokenId);
|
||||
if (scopeId)
|
||||
{
|
||||
return scopeId;
|
||||
}
|
||||
|
||||
return m_area->getLocationIdOfFirstActiveLocation(tokenId);
|
||||
}
|
||||
|
||||
QtCodeFileSingle::FileData QtCodeFileSingle::getFileData(const FilePath& filePath) const
|
||||
@@ -273,6 +303,8 @@ void QtCodeFileSingle::setFileData(const FileData& file)
|
||||
|
||||
m_title->show();
|
||||
m_area->show();
|
||||
|
||||
m_scrollRequested = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -32,9 +32,9 @@ public:
|
||||
// QtCodeNaviatebale implementation
|
||||
virtual QAbstractScrollArea* getScrollArea() override;
|
||||
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false) override;
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params) override;
|
||||
|
||||
void requestFileContent(const FilePath& filePath);
|
||||
virtual void requestFileContent(const FilePath& filePath) override;
|
||||
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop) override;
|
||||
|
||||
virtual void updateFiles() override;
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
virtual void onWindowFocus() override;
|
||||
|
||||
const FilePath& getCurrentFilePath() const;
|
||||
bool hasFileCached(const FilePath& filePath) const;
|
||||
|
||||
Id getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const;
|
||||
|
||||
@@ -75,6 +76,7 @@ private:
|
||||
std::deque<FilePath> m_filePaths;
|
||||
|
||||
bool m_contentRequested;
|
||||
bool m_scrollRequested;
|
||||
};
|
||||
|
||||
#endif // QT_CODE_FILE_SINGLE_H
|
||||
|
||||
@@ -58,7 +58,7 @@ void QtCodeNavigateable::ensureWidgetVisibleAnimated(
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeNavigateable::ensurePercentVisibleAnimated(double percent, bool animated, bool onTop)
|
||||
void QtCodeNavigateable::ensurePercentVisibleAnimated(double percentA, double percentB, bool animated, bool onTop)
|
||||
{
|
||||
QAbstractScrollArea* area = getScrollArea();
|
||||
if (!area)
|
||||
@@ -74,10 +74,34 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(double percent, bool anima
|
||||
return;
|
||||
}
|
||||
|
||||
int scrollHeight = totalHeight * percent;
|
||||
int scrollHeight = totalHeight * percentA;
|
||||
if (!onTop)
|
||||
{
|
||||
scrollHeight -= visibleHeight / 3;
|
||||
if (percentB)
|
||||
{
|
||||
int scrollHeightB = totalHeight * percentB;
|
||||
int rectHeight = scrollHeightB - scrollHeight;
|
||||
|
||||
if (rectHeight < visibleHeight)
|
||||
{
|
||||
if (rectHeight < visibleHeight / 2)
|
||||
{
|
||||
scrollHeight -= visibleHeight / 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollHeight += rectHeight / 2 - visibleHeight / 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollHeight -= 20;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollHeight -= visibleHeight / 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -19,8 +19,9 @@ public:
|
||||
|
||||
virtual QAbstractScrollArea* getScrollArea() = 0;
|
||||
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false) = 0;
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params) = 0;
|
||||
|
||||
virtual void requestFileContent(const FilePath& filePath) = 0;
|
||||
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop) = 0;
|
||||
|
||||
virtual void updateFiles() = 0;
|
||||
@@ -30,7 +31,7 @@ public:
|
||||
|
||||
protected:
|
||||
void ensureWidgetVisibleAnimated(QWidget* parentWidget, QWidget *childWidget, QRectF rect, bool animated, bool onTop);
|
||||
void ensurePercentVisibleAnimated(double percent, bool animated, bool onTop);
|
||||
void ensurePercentVisibleAnimated(double percentA, double percentB, bool animated, bool onTop);
|
||||
};
|
||||
|
||||
#endif // QT_CODE_NAVIGATEABLE_H
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageCodeViewExpandedInitialFiles.h"
|
||||
#include "utility/messaging/type/MessageScrollCode.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
@@ -137,21 +136,30 @@ QtCodeNavigator::~QtCodeNavigator()
|
||||
{
|
||||
}
|
||||
|
||||
void QtCodeNavigator::addCodeSnippet(const CodeSnippetParams& params, bool insert)
|
||||
void QtCodeNavigator::addCodeSnippet(const CodeSnippetParams& params)
|
||||
{
|
||||
FilePath currentPath = m_single->getCurrentFilePath();
|
||||
|
||||
if (params.reduced)
|
||||
{
|
||||
m_list->addCodeSnippet(params, insert);
|
||||
m_single->addCodeSnippet(params, insert);
|
||||
m_list->addCodeSnippet(params);
|
||||
m_single->addCodeSnippet(params);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_current->addCodeSnippet(params, insert);
|
||||
m_current->addCodeSnippet(params);
|
||||
}
|
||||
|
||||
if (currentPath != m_single->getCurrentFilePath())
|
||||
{
|
||||
m_singleHasNewFile = true;
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimePoint modificationTime)
|
||||
{
|
||||
bool firstFile = m_references.size() == 0;
|
||||
|
||||
m_list->addFile(locationFile->getFilePath(), locationFile->isWhole(), refCount, modificationTime, locationFile->isComplete());
|
||||
|
||||
if (locationFile->isWhole())
|
||||
@@ -195,13 +203,26 @@ void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (firstFile && m_references.size() && m_references[0].locationType != LOCATION_TOKEN)
|
||||
{
|
||||
clearCaches();
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeNavigator::addedFiles()
|
||||
{
|
||||
if (m_references.size() && m_references[0].locationType != LOCATION_TOKEN)
|
||||
if (m_mode == MODE_SINGLE && m_references.size())
|
||||
{
|
||||
clearCaches();
|
||||
if (!m_refIndex || !m_activeReference.tokenId)
|
||||
{
|
||||
m_single->requestFileContent(m_references.front().filePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_refIndex == 0)
|
||||
{
|
||||
updateRefLabel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,6 +364,11 @@ bool QtCodeNavigator::isInListMode() const
|
||||
return m_mode == MODE_LIST;
|
||||
}
|
||||
|
||||
bool QtCodeNavigator::hasSingleFileCached(const FilePath& filePath) const
|
||||
{
|
||||
return m_single->hasFileCached(filePath);
|
||||
}
|
||||
|
||||
void QtCodeNavigator::showActiveSnippet(
|
||||
const std::vector<Id>& activeTokenIds, std::shared_ptr<SourceLocationCollection> collection, bool scrollTo)
|
||||
{
|
||||
@@ -425,8 +451,11 @@ void QtCodeNavigator::showActiveSnippet(
|
||||
|
||||
if (firstReference.tokenId)
|
||||
{
|
||||
requestScroll(firstReference.filePath, 0, firstReference.locationId, true, false);
|
||||
emit scrollRequest();
|
||||
if (scrollTo)
|
||||
{
|
||||
requestScroll(firstReference.filePath, 0, firstReference.locationId, true, false);
|
||||
emit scrollRequest();
|
||||
}
|
||||
|
||||
m_refIndex = refIndex;
|
||||
updateRefLabel();
|
||||
@@ -465,46 +494,6 @@ void QtCodeNavigator::setFileMaximized(const FilePath path)
|
||||
m_list->setFileMaximized(path);
|
||||
}
|
||||
|
||||
void QtCodeNavigator::setupFiles()
|
||||
{
|
||||
if (m_mode == MODE_LIST)
|
||||
{
|
||||
std::set<FilePath> filePathsToExpand;
|
||||
for (const Reference& ref : m_references)
|
||||
{
|
||||
if (filePathsToExpand.find(ref.filePath) == filePathsToExpand.end())
|
||||
{
|
||||
m_list->requestFileContent(ref.filePath, filePathsToExpand.size() == 0);
|
||||
filePathsToExpand.insert(ref.filePath);
|
||||
|
||||
if (filePathsToExpand.size() >= 3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filePathsToExpand.size())
|
||||
{
|
||||
MessageCodeViewExpandedInitialFiles(m_refIndex != 0 || m_activeReference.tokenId).dispatch();
|
||||
}
|
||||
}
|
||||
else if (m_references.size())
|
||||
{
|
||||
m_singleHasNewFile = (m_single->getCurrentFilePath() != m_references.front().filePath);
|
||||
if (!m_refIndex || !m_activeReference.tokenId)
|
||||
{
|
||||
m_single->requestFileContent(m_references.front().filePath);
|
||||
}
|
||||
MessageCodeViewExpandedInitialFiles(true).dispatch();
|
||||
}
|
||||
|
||||
if (m_refIndex == 0)
|
||||
{
|
||||
updateRefLabel();
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeNavigator::updateFiles()
|
||||
{
|
||||
m_current->updateFiles();
|
||||
@@ -555,7 +544,8 @@ void QtCodeNavigator::scrollToValue(int value, bool inListMode)
|
||||
if ((m_mode == MODE_LIST) == inListMode)
|
||||
{
|
||||
m_value = value;
|
||||
QTimer::singleShot(1000, this, SLOT(setValue()));
|
||||
QTimer::singleShot(100, this, SLOT(setValue()));
|
||||
m_scrollRequest = ScrollRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -565,7 +555,7 @@ void QtCodeNavigator::scrollToLine(const FilePath& filePath, unsigned int line)
|
||||
emit scrollRequest();
|
||||
}
|
||||
|
||||
void QtCodeNavigator::scrollToDefinition(bool ignoreActiveReference)
|
||||
void QtCodeNavigator::scrollToDefinition(bool animated, bool ignoreActiveReference)
|
||||
{
|
||||
if (ignoreActiveReference)
|
||||
{
|
||||
@@ -594,25 +584,25 @@ void QtCodeNavigator::scrollToDefinition(bool ignoreActiveReference)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_activeTokenId && m_mode == MODE_SINGLE && m_references.size() && m_references.front().locationType != LOCATION_TOKEN)
|
||||
{
|
||||
requestScroll(m_references.front().filePath, 0, m_references.front().locationId, false, true);
|
||||
emit scrollRequest();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_activeTokenId)
|
||||
{
|
||||
if (m_mode == MODE_SINGLE && m_references.size() && m_references.front().locationType != LOCATION_TOKEN)
|
||||
{
|
||||
requestScroll(m_references.front().filePath, 0, m_references.front().locationId, false, false);
|
||||
emit scrollRequest();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mode == MODE_LIST)
|
||||
{
|
||||
std::pair<QtCodeSnippet*, uint> result = m_list->getFirstSnippetWithActiveLocation(m_activeTokenId);
|
||||
std::cout << animated << std::endl;
|
||||
std::pair<QtCodeSnippet*, Id> result = m_list->getFirstSnippetWithActiveLocationId(m_activeTokenId);
|
||||
if (result.first != nullptr)
|
||||
{
|
||||
requestScroll(result.first->getFile()->getFilePath(), result.second, 0, false, true);
|
||||
requestScroll(result.first->getFile()->getFilePath(), 0, result.second, animated, false);
|
||||
emit scrollRequest();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -620,22 +610,18 @@ void QtCodeNavigator::scrollToDefinition(bool ignoreActiveReference)
|
||||
Id locationId = m_single->getLocationIdOfFirstActiveLocationOfTokenId(m_activeTokenId);
|
||||
if (locationId)
|
||||
{
|
||||
for (size_t i = 0; i < m_references.size(); i++)
|
||||
{
|
||||
if (m_references[i].locationId == locationId)
|
||||
{
|
||||
m_refIndex = i + 1;
|
||||
showCurrentReference(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_references.size())
|
||||
{
|
||||
nextReference(false);
|
||||
requestScroll(m_single->getCurrentFilePath(), 0, locationId, true, false);
|
||||
emit scrollRequest();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//m_singleHasNewFile = false;
|
||||
if (m_references.size())
|
||||
{
|
||||
m_current->requestFileContent(m_references.front().filePath);
|
||||
requestScroll(m_references.front().filePath, 0, m_references.front().locationId, false, false);
|
||||
emit scrollRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeNavigator::scrollToSnippetIfRequested()
|
||||
@@ -658,10 +644,6 @@ void QtCodeNavigator::requestScroll(const FilePath& filePath, uint lineNumber, I
|
||||
{
|
||||
req.animated = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
req.animated = (m_single->getCurrentFilePath() == filePath);
|
||||
}
|
||||
}
|
||||
|
||||
// std::cout << "scroll request: " << req.filePath.str() << " " << req.lineNumber << " " << req.locationId;
|
||||
@@ -688,6 +670,10 @@ void QtCodeNavigator::handleScrollRequest()
|
||||
{
|
||||
m_scrollRequest = ScrollRequest();
|
||||
}
|
||||
else if (m_mode == MODE_SINGLE)
|
||||
{
|
||||
m_scrollRequest.animated = false;
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeNavigator::scrolled(int value)
|
||||
@@ -789,7 +775,7 @@ void QtCodeNavigator::setMode(Mode mode)
|
||||
ApplicationSettings::getInstance()->setCodeViewModeSingle(m_mode == MODE_SINGLE);
|
||||
ApplicationSettings::getInstance()->save();
|
||||
|
||||
setupFiles();
|
||||
scrollToDefinition(false, false);
|
||||
showContents();
|
||||
}
|
||||
|
||||
@@ -859,7 +845,7 @@ void QtCodeNavigator::handleMessage(MessageShowReference* message)
|
||||
setCurrentActiveLocationIds(std::vector<Id>(1, ref.locationId));
|
||||
updateFiles();
|
||||
|
||||
requestScroll(ref.filePath, 0, ref.locationId, message->animated, false);
|
||||
requestScroll(ref.filePath, 0, ref.locationId, true, false);
|
||||
emit scrollRequest();
|
||||
|
||||
if (ref.locationType == LOCATION_ERROR)
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
QtCodeNavigator(QWidget* parent = nullptr);
|
||||
virtual ~QtCodeNavigator();
|
||||
|
||||
void addCodeSnippet(const CodeSnippetParams& params, bool insert = false);
|
||||
void addCodeSnippet(const CodeSnippetParams& params);
|
||||
void addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimePoint modificationTime);
|
||||
|
||||
void addedFiles();
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
size_t getFatalErrorCountForFile(const FilePath& filePath) const;
|
||||
|
||||
bool isInListMode() const;
|
||||
bool hasSingleFileCached(const FilePath& filePath) const;
|
||||
|
||||
void showActiveSnippet(
|
||||
const std::vector<Id>& activeTokenIds, std::shared_ptr<SourceLocationCollection> collection, bool scrollTo);
|
||||
@@ -76,7 +77,6 @@ public:
|
||||
void setFileSnippets(const FilePath path);
|
||||
void setFileMaximized(const FilePath path);
|
||||
|
||||
void setupFiles();
|
||||
void updateFiles();
|
||||
void showContents();
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
void scrollToValue(int value, bool inListMode);
|
||||
void scrollToLine(const FilePath& filePath, unsigned int line);
|
||||
void scrollToDefinition(bool ignoreActiveReference);
|
||||
void scrollToDefinition(bool animated, bool ignoreActiveReference);
|
||||
|
||||
void scrollToSnippetIfRequested();
|
||||
|
||||
|
||||
@@ -164,9 +164,20 @@ uint QtCodeSnippet::getLineNumberForLocationId(Id locationId) const
|
||||
return m_codeArea->getLineNumberForLocationId(locationId);
|
||||
}
|
||||
|
||||
uint QtCodeSnippet::getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const
|
||||
std::pair<uint, uint> QtCodeSnippet::getLineNumbersForLocationId(Id locationId) const
|
||||
{
|
||||
return m_codeArea->getStartLineNumberOfFirstActiveLocationOfTokenId(tokenId);
|
||||
return m_codeArea->getLineNumbersForLocationId(locationId);
|
||||
}
|
||||
|
||||
Id QtCodeSnippet::getFirstActiveLocationId(Id tokenId) const
|
||||
{
|
||||
Id scopeId = m_codeArea->getLocationIdOfFirstActiveScopeLocation(tokenId);
|
||||
if (scopeId)
|
||||
{
|
||||
return scopeId;
|
||||
}
|
||||
|
||||
return m_codeArea->getLocationIdOfFirstActiveLocation(tokenId);
|
||||
}
|
||||
|
||||
QRectF QtCodeSnippet::getLineRectForLineNumber(uint lineNumber) const
|
||||
|
||||
@@ -44,7 +44,9 @@ public:
|
||||
void setIsActiveFile(bool isActiveFile);
|
||||
|
||||
uint getLineNumberForLocationId(Id locationId) const;
|
||||
uint getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const;
|
||||
std::pair<uint, uint> getLineNumbersForLocationId(Id locationId) const;
|
||||
|
||||
Id getFirstActiveLocationId(Id tokenId) const;
|
||||
QRectF getLineRectForLineNumber(uint lineNumber) const;
|
||||
|
||||
std::string getCode() const;
|
||||
|
||||
+118
-165
@@ -1,25 +1,16 @@
|
||||
#include "qt/view/QtCodeView.h"
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
#include "qt/element/QtCodeArea.h"
|
||||
#include "qt/element/QtCodeNavigator.h"
|
||||
#include "qt/utility/QtHighlighter.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtCodeView::QtCodeView(ViewLayout* viewLayout)
|
||||
: CodeView(viewLayout)
|
||||
, m_showCodeSnippetsFunctor(
|
||||
std::bind(&QtCodeView::doShowCodeSnippets, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))
|
||||
, m_addCodeSnippetsFunctor(std::bind(&QtCodeView::doAddCodeSnippets, this, std::placeholders::_1, std::placeholders::_2))
|
||||
, m_setFileStateFunctor(std::bind(&QtCodeView::doSetFileState, 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))
|
||||
{
|
||||
m_widget = new QtCodeNavigator();
|
||||
setStyleSheet();
|
||||
@@ -40,138 +31,156 @@ void QtCodeView::initView()
|
||||
|
||||
void QtCodeView::refreshView()
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
setStyleSheet();
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
setStyleSheet();
|
||||
|
||||
m_widget->refreshStyle();
|
||||
m_widget->refreshStyle();
|
||||
|
||||
QtCodeArea::clearAnnotationColors();
|
||||
QtHighlighter::clearHighlightingRules();
|
||||
}
|
||||
);
|
||||
QtCodeArea::clearAnnotationColors();
|
||||
QtHighlighter::clearHighlightingRules();
|
||||
});
|
||||
}
|
||||
|
||||
void QtCodeView::clear()
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->clear();
|
||||
}
|
||||
);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->clear();
|
||||
});
|
||||
|
||||
m_errorInfos.clear();
|
||||
}
|
||||
|
||||
void QtCodeView::clearCodeSnippets()
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->clearCodeSnippets();
|
||||
}
|
||||
);
|
||||
|
||||
m_errorInfos.clear();
|
||||
}
|
||||
|
||||
void QtCodeView::setErrorInfos(const std::vector<ErrorInfo>& errorInfos)
|
||||
{
|
||||
m_errorInfos = errorInfos;
|
||||
m_scrollParams = ScrollParams();
|
||||
}
|
||||
|
||||
bool QtCodeView::showsErrors() const
|
||||
{
|
||||
return m_errorInfos.size() > 0;
|
||||
return m_widget->hasErrors();
|
||||
}
|
||||
|
||||
void QtCodeView::showCodeSnippets(
|
||||
const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds, bool setupFiles)
|
||||
void QtCodeView::showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const CodeParams params)
|
||||
{
|
||||
m_showCodeSnippetsFunctor(snippets, activeTokenIds, setupFiles);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
if (params.clearSnippets)
|
||||
{
|
||||
m_widget->clearCodeSnippets();
|
||||
|
||||
m_widget->setActiveTokenIds(params.activeTokenIds);
|
||||
m_widget->setErrorInfos(params.errorInfos);
|
||||
}
|
||||
|
||||
bool addedFiles = false;
|
||||
|
||||
for (const CodeSnippetParams& snippet : snippets)
|
||||
{
|
||||
if (snippet.isCollapsed)
|
||||
{
|
||||
m_widget->addFile(snippet.locationFile, snippet.refCount, snippet.modificationTime);
|
||||
|
||||
addedFiles = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_widget->addCodeSnippet(snippet);
|
||||
}
|
||||
}
|
||||
|
||||
if (addedFiles)
|
||||
{
|
||||
m_widget->addedFiles();
|
||||
}
|
||||
|
||||
m_widget->updateFiles();
|
||||
|
||||
if (m_widget->isInListMode())
|
||||
{
|
||||
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
|
||||
}
|
||||
|
||||
if (params.showContents)
|
||||
{
|
||||
m_widget->showContents();
|
||||
performScroll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void QtCodeView::addCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert)
|
||||
void QtCodeView::scrollTo(const ScrollParams params)
|
||||
{
|
||||
m_addCodeSnippetsFunctor(snippets, insert);
|
||||
m_scrollParams = params;
|
||||
}
|
||||
|
||||
void QtCodeView::setFileState(const FilePath filePath, FileState state)
|
||||
{
|
||||
m_setFileStateFunctor(filePath, state);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case FILE_MINIMIZED:
|
||||
m_widget->setFileMinimized(filePath);
|
||||
break;
|
||||
case FILE_SNIPPETS:
|
||||
m_widget->setFileSnippets(filePath);
|
||||
break;
|
||||
case FILE_MAXIMIZED:
|
||||
m_widget->setFileMaximized(filePath);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void QtCodeView::showActiveSnippet(
|
||||
const std::vector<Id>& activeTokenIds, std::shared_ptr<SourceLocationCollection> collection, bool scrollTo)
|
||||
{
|
||||
m_doShowActiveSnippetFunctor(activeTokenIds, collection, scrollTo);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->showActiveSnippet(activeTokenIds, collection, scrollTo);
|
||||
});
|
||||
}
|
||||
|
||||
void QtCodeView::showActiveTokenIds(const std::vector<Id>& activeTokenIds)
|
||||
{
|
||||
m_doShowActiveTokenIdsFunctor(activeTokenIds);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->setActiveTokenIds(activeTokenIds);
|
||||
m_widget->updateFiles();
|
||||
|
||||
performScroll();
|
||||
});
|
||||
}
|
||||
|
||||
void QtCodeView::showActiveLocalSymbolIds(const std::vector<Id>& activeLocalSymbolIds)
|
||||
{
|
||||
m_doShowActiveLocalSymbolIdsFunctor(activeLocalSymbolIds);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->setActiveLocalSymbolIds(activeLocalSymbolIds);
|
||||
m_widget->updateFiles();
|
||||
});
|
||||
}
|
||||
|
||||
void QtCodeView::focusTokenIds(const std::vector<Id>& focusedTokenIds)
|
||||
{
|
||||
m_focusTokenIdsFunctor(focusedTokenIds);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->focusTokenIds(focusedTokenIds);
|
||||
});
|
||||
}
|
||||
|
||||
void QtCodeView::defocusTokenIds()
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->defocusTokenIds();
|
||||
}
|
||||
);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->defocusTokenIds();
|
||||
});
|
||||
}
|
||||
|
||||
void QtCodeView::showContents()
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->showContents();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtCodeView::scrollToValue(int value, bool inListMode)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->scrollToValue(value, inListMode);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtCodeView::scrollToLine(const FilePath filePath, unsigned int line)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->scrollToLine(filePath, line);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtCodeView::scrollToDefinition(bool ignoreActiveReference)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->scrollToDefinition(ignoreActiveReference);
|
||||
}
|
||||
);
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
m_widget->showContents();
|
||||
performScroll();
|
||||
});
|
||||
}
|
||||
|
||||
bool QtCodeView::isInListMode() const
|
||||
@@ -179,87 +188,31 @@ bool QtCodeView::isInListMode() const
|
||||
return m_widget->isInListMode();
|
||||
}
|
||||
|
||||
void QtCodeView::doShowCodeSnippets(
|
||||
const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds, bool setupFiles)
|
||||
bool QtCodeView::hasSingleFileCached(const FilePath& filePath) const
|
||||
{
|
||||
m_widget->setActiveTokenIds(activeTokenIds);
|
||||
m_widget->setErrorInfos(m_errorInfos);
|
||||
|
||||
for (const CodeSnippetParams& params : snippets)
|
||||
{
|
||||
if (params.isCollapsed)
|
||||
{
|
||||
m_widget->addFile(params.locationFile, params.refCount, params.modificationTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_widget->addCodeSnippet(params);
|
||||
}
|
||||
}
|
||||
|
||||
m_widget->addedFiles();
|
||||
|
||||
if (setupFiles)
|
||||
{
|
||||
m_widget->setupFiles();
|
||||
}
|
||||
|
||||
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
|
||||
return m_widget->hasSingleFileCached(filePath);
|
||||
}
|
||||
|
||||
void QtCodeView::doAddCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert)
|
||||
void QtCodeView::performScroll()
|
||||
{
|
||||
for (const CodeSnippetParams& params : snippets)
|
||||
switch (m_scrollParams.type)
|
||||
{
|
||||
m_widget->addCodeSnippet(params, insert);
|
||||
}
|
||||
|
||||
m_widget->updateFiles();
|
||||
|
||||
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
|
||||
|
||||
m_widget->scrollToSnippetIfRequested();
|
||||
}
|
||||
|
||||
void QtCodeView::doSetFileState(const FilePath filePath, FileState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case FILE_MINIMIZED:
|
||||
m_widget->setFileMinimized(filePath);
|
||||
case ScrollParams::SCROLL_TO_DEFINITION:
|
||||
m_widget->scrollToDefinition(m_scrollParams.animated, m_scrollParams.ignoreActiveReference);
|
||||
break;
|
||||
case FILE_SNIPPETS:
|
||||
m_widget->setFileSnippets(filePath);
|
||||
case ScrollParams::SCROLL_TO_LINE:
|
||||
m_widget->scrollToLine(m_scrollParams.filePath, m_scrollParams.line);
|
||||
break;
|
||||
case FILE_MAXIMIZED:
|
||||
m_widget->setFileMaximized(filePath);
|
||||
case ScrollParams::SCROLL_TO_VALUE:
|
||||
m_widget->scrollToValue(m_scrollParams.value, m_scrollParams.inListMode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_widget->scrollToSnippetIfRequested();
|
||||
}
|
||||
|
||||
void QtCodeView::doShowActiveSnippet(
|
||||
const std::vector<Id>& activeTokenIds, std::shared_ptr<SourceLocationCollection> collection, bool scrollTo)
|
||||
{
|
||||
m_widget->showActiveSnippet(activeTokenIds, collection, scrollTo);
|
||||
}
|
||||
|
||||
void QtCodeView::doShowActiveTokenIds(const std::vector<Id>& activeTokenIds)
|
||||
{
|
||||
m_widget->setActiveTokenIds(activeTokenIds);
|
||||
m_widget->updateFiles();
|
||||
}
|
||||
|
||||
void QtCodeView::doShowActiveLocalSymbolIds(const std::vector<Id>& localSymbolIds)
|
||||
{
|
||||
m_widget->setActiveLocalSymbolIds(localSymbolIds);
|
||||
m_widget->updateFiles();
|
||||
}
|
||||
|
||||
void QtCodeView::doFocusTokenIds(const std::vector<Id>& focusedTokenIds)
|
||||
{
|
||||
m_widget->focusTokenIds(focusedTokenIds);
|
||||
m_scrollParams = ScrollParams();
|
||||
}
|
||||
|
||||
void QtCodeView::setStyleSheet() const
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
#ifndef QT_CODE_VIEW_H
|
||||
#define QT_CODE_VIEW_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "component/view/CodeView.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
class QFrame;
|
||||
class QtCodeNavigator;
|
||||
class QWidget;
|
||||
|
||||
class QtCodeView
|
||||
: public CodeView
|
||||
@@ -27,15 +20,12 @@ public:
|
||||
|
||||
// CodeView implementation
|
||||
virtual void clear();
|
||||
virtual void clearCodeSnippets();
|
||||
|
||||
virtual void setErrorInfos(const std::vector<ErrorInfo>& errorInfos);
|
||||
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const CodeParams params);
|
||||
virtual void scrollTo(const ScrollParams params);
|
||||
|
||||
virtual bool showsErrors() const;
|
||||
|
||||
virtual void showCodeSnippets(
|
||||
const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds, bool setupFiles);
|
||||
virtual void addCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert);
|
||||
|
||||
virtual void setFileState(const FilePath filePath, FileState state);
|
||||
|
||||
virtual void showActiveSnippet(
|
||||
@@ -48,41 +38,20 @@ public:
|
||||
|
||||
virtual void showContents();
|
||||
|
||||
virtual void scrollToValue(int value, bool inListMode);
|
||||
virtual void scrollToLine(const FilePath filePath, unsigned int line);
|
||||
virtual void scrollToDefinition(bool ignoreActiveReference);
|
||||
|
||||
virtual bool isInListMode() const;
|
||||
virtual bool hasSingleFileCached(const FilePath& filePath) const;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void doShowCodeSnippets(
|
||||
const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds, bool setupFiles);
|
||||
void doAddCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert);
|
||||
|
||||
void doSetFileState(const FilePath filePath, FileState state);
|
||||
|
||||
void doShowActiveSnippet(
|
||||
const std::vector<Id>& activeTokenIds, std::shared_ptr<SourceLocationCollection> collection, bool scrollTo);
|
||||
void doShowActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
||||
void doShowActiveLocalSymbolIds(const std::vector<Id>& localSymbolIds);
|
||||
|
||||
void doFocusTokenIds(const std::vector<Id>& focusedTokenIds);
|
||||
|
||||
void performScroll();
|
||||
void setStyleSheet() const;
|
||||
|
||||
QtThreadedFunctor<const std::vector<CodeSnippetParams>&, const std::vector<Id>&, bool> m_showCodeSnippetsFunctor;
|
||||
QtThreadedFunctor<const std::vector<CodeSnippetParams>&, bool> m_addCodeSnippetsFunctor;
|
||||
QtThreadedFunctor<const FilePath, FileState> m_setFileStateFunctor;
|
||||
QtThreadedFunctor<const std::vector<Id>&, std::shared_ptr<SourceLocationCollection>, bool> m_doShowActiveSnippetFunctor;
|
||||
QtThreadedFunctor<const std::vector<Id>&> m_doShowActiveTokenIdsFunctor;
|
||||
QtThreadedFunctor<const std::vector<Id>&> m_doShowActiveLocalSymbolIdsFunctor;
|
||||
QtThreadedFunctor<const std::vector<Id>&> m_focusTokenIdsFunctor;
|
||||
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
QtCodeNavigator* m_widget;
|
||||
|
||||
std::vector<ErrorInfo> m_errorInfos;
|
||||
ScrollParams m_scrollParams;
|
||||
};
|
||||
|
||||
# endif // QT_CODE_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user