ui: Refactored code component to handle all state changes in controller

This commit is contained in:
Eberhard Graether
2019-11-08 16:20:43 +01:00
parent 9d556599ab
commit 9281c237a7
32 changed files with 1542 additions and 1985 deletions
+32 -48
View File
@@ -388,19 +388,6 @@ Id QtCodeArea::getLocationIdOfFirstHighlightedLocation() const
return 0;
}
std::vector<Id> QtCodeArea::getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const
{
std::vector<Id> 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
{
size_t count = 0;
@@ -639,14 +626,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(event->pos());
if (annotations.size())
{
if (m_navigator->hasErrors())
{
activateErrors(annotations);
}
else
{
activateAnnotations(annotations);
}
activateAnnotationsOrErrors(annotations);
}
else if (m_navigator->getActiveLocalTokenIds().size())
{
@@ -700,15 +680,25 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
if (!same)
{
if (m_navigator->hasErrors())
{
for (const Annotation* annotation : annotations)
{
if (annotation->locationType == LOCATION_ERROR && annotation->tokenIds.size())
{
std::wstring errorMessage = m_navigator->getErrorMessageForId(*annotation->tokenIds.begin());
QToolTip::showText(event->globalPos(), QString::fromStdWString(errorMessage), this);
QtCodeField::focusTokenIds({ *annotation->tokenIds.begin() });
viewport()->setCursor(Qt::PointingHandCursor);
return;
}
}
}
QToolTip::hideText();
setHoveredAnnotations(annotations);
if (m_navigator->hasErrors() && annotations.size() == 1 && annotations[0]->tokenIds.size())
{
std::wstring errorMessage = m_navigator->getErrorMessageForId(*annotations[0]->tokenIds.begin());
QToolTip::showText(event->globalPos(), QString::fromStdWString(errorMessage), this);
}
}
}
@@ -748,23 +738,11 @@ void QtCodeArea::contextMenuEvent(QContextMenuEvent* event)
void QtCodeArea::focusTokenIds(const std::vector<Id>& tokenIds)
{
if (m_navigator->hasErrors() && tokenIds.size() == 1)
{
QtCodeField::focusTokenIds(tokenIds);
return;
}
MessageFocusIn(tokenIds, TOOLTIP_ORIGIN_CODE).dispatch();
}
void QtCodeArea::defocusTokenIds(const std::vector<Id>& tokenIds)
{
if (m_navigator->hasErrors() && tokenIds.size() == 1)
{
annotateText();
return;
}
MessageFocusOut(tokenIds).dispatch();
}
@@ -821,21 +799,27 @@ void QtCodeArea::setNewTextCursor(const QTextCursor& cursor)
verticalScrollBar()->setValue(verticalValue);
}
void QtCodeArea::activateErrors(const std::vector<const Annotation*>& annotations)
void QtCodeArea::activateAnnotationsOrErrors(const std::vector<const Annotation*>& annotations)
{
std::vector<Id> errorIds;
for (const Annotation* annotation : annotations)
if (m_navigator->hasErrors())
{
if (annotation->locationType == LOCATION_ERROR && annotation->tokenIds.size())
std::vector<Id> errorIds;
for (const Annotation* annotation : annotations)
{
errorIds.insert(errorIds.end(), annotation->tokenIds.begin(), annotation->tokenIds.end());
if (annotation->locationType == LOCATION_ERROR && annotation->tokenIds.size())
{
errorIds.insert(errorIds.end(), annotation->tokenIds.begin(), annotation->tokenIds.end());
}
}
if (errorIds.size() == 1)
{
MessageShowError(errorIds[0]).dispatch();
return;
}
}
if (errorIds.size() == 1)
{
MessageShowError(errorIds[0]).dispatch();
}
activateAnnotations(annotations);
}
void QtCodeArea::annotateText()
+1 -3
View File
@@ -81,8 +81,6 @@ public:
Id getLocationIdOfFirstActiveScopeLocation(Id tokenId) const;
Id getLocationIdOfFirstHighlightedLocation() const;
std::vector<Id> getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const;
size_t getActiveLocationCount() const;
QRectF getLineRectForLineNumber(size_t lineNumber) const;
@@ -114,7 +112,7 @@ private:
void clearSelection();
void setNewTextCursor(const QTextCursor& cursor);
void activateErrors(const std::vector<const Annotation*>& annotations);
void activateAnnotationsOrErrors(const std::vector<const Annotation*>& annotations);
void annotateText();
+37 -149
View File
@@ -15,7 +15,6 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator, boo
, m_navigator(navigator)
, m_filePath(filePath)
, m_isWholeFile(false)
, m_contentRequested(false)
{
setObjectName("code_file");
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
@@ -43,6 +42,7 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator, boo
m_snippetLayout->setSpacing(0);
layout->addLayout(m_snippetLayout);
setMinimized();
update();
}
@@ -67,118 +67,30 @@ const QtCodeFileTitleBar* QtCodeFile::getTitleBar() const
QtCodeSnippet* QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
{
if (m_isWholeFile && m_snippets.size() == 1)
{
return m_snippets[0];
}
for (QtCodeSnippet* snippet : m_snippets)
{
if (snippet->getStartLineNumber() == params.startLineNumber &&
snippet->getEndLineNumber() == params.endLineNumber)
{
return snippet;
}
}
QtCodeSnippet* snippet = new QtCodeSnippet(params, m_navigator, this);
if (params.reduced)
if (params.isOverview)
{
m_titleBar->getTitleButton()->setProject(params.title);
m_isWholeFile = true;
}
if (params.locationFile->isWhole() || m_isWholeFile)
{
m_isWholeFile = true;
snippet->setIsActiveFile(true);
if (params.refCount != -1)
{
updateRefCount(0);
}
for (QtCodeSnippet* oldSnippet : m_snippets)
{
oldSnippet->hide();
}
m_snippets.clear();
}
else
{
updateRefCount(params.refCount);
}
m_snippetLayout->addWidget(snippet);
m_snippets.push_back(snippet);
setSnippets();
return snippet;
}
QtCodeSnippet* QtCodeFile::insertCodeSnippet(const CodeSnippetParams& params)
{
QtCodeSnippet* newSnippet = new QtCodeSnippet(params, m_navigator, this);
size_t i = 0;
while (i < m_snippets.size())
{
size_t start = newSnippet->getStartLineNumber();
size_t end = newSnippet->getEndLineNumber();
QtCodeSnippet* oldSnippet = m_snippets[i];
if (oldSnippet->getEndLineNumber() + 1 < start) // before
{
i++;
continue;
}
else if (oldSnippet->getStartLineNumber() > end + 1) // after
{
break;
}
else if (oldSnippet->getStartLineNumber() <= start && oldSnippet->getEndLineNumber() >= end) // containing
{
newSnippet->deleteLater();
return oldSnippet;
}
else if (oldSnippet->getStartLineNumber() < start || oldSnippet->getEndLineNumber() > end) // overlaping
{
newSnippet = QtCodeSnippet::merged(newSnippet, oldSnippet, m_navigator, this);
}
else if (oldSnippet->getStartLineNumber() >= start && oldSnippet->getEndLineNumber() <= end) // enclosing
{
// copy all source locations from old to new snippet: fulltext locations got lost
oldSnippet->getArea()->getSourceLocationFile()->copySourceLocations(
newSnippet->getArea()->getSourceLocationFile());
newSnippet->getArea()->updateSourceLocations(oldSnippet->getArea()->getSourceLocationFile());
}
m_navigator->clearSnippetReferences();
oldSnippet->hide();
m_snippetLayout->removeWidget(oldSnippet);
oldSnippet->deleteLater();
m_snippets.erase(m_snippets.begin() + i);
}
m_snippetLayout->insertWidget(i, newSnippet);
m_snippets.insert(m_snippets.begin() + i, newSnippet);
setSnippets();
return newSnippet;
}
void QtCodeFile::updateCodeSnippet(const CodeSnippetParams& params)
void QtCodeFile::updateSourceLocations(const CodeSnippetParams& params)
{
if (m_isWholeFile && m_snippets.size() == 1)
{
m_snippets[0]->updateCodeSnippet(params);
m_snippets[0]->updateSourceLocations(params);
return;
}
@@ -187,11 +99,16 @@ void QtCodeFile::updateCodeSnippet(const CodeSnippetParams& params)
if (snippet->getStartLineNumber() == params.startLineNumber &&
snippet->getEndLineNumber() == params.endLineNumber)
{
snippet->updateCodeSnippet(params);
snippet->updateSourceLocations(params);
}
}
}
const std::vector<QtCodeSnippet*>& QtCodeFile::getSnippets() const
{
return m_snippets;
}
std::vector<QtCodeSnippet*> QtCodeFile::getVisibleSnippets() const
{
std::vector<QtCodeSnippet*> snippets;
@@ -251,32 +168,7 @@ std::pair<QtCodeSnippet*, Id> QtCodeFile::getFirstSnippetWithActiveLocationId(Id
return result;
}
bool QtCodeFile::isCollapsed() const
{
return !m_snippets.size();
}
void QtCodeFile::requestContent()
{
if (!isCollapsed() || m_contentRequested)
{
updateContent();
return;
}
m_contentRequested = true;
MessageChangeFileView::FileState state =
m_isWholeFile ? MessageChangeFileView::FILE_MAXIMIZED : MessageChangeFileView::FILE_SNIPPETS;
bool needsData = (m_snippets.size() == 0);
MessageChangeFileView msg(m_filePath, state, MessageChangeFileView::VIEW_LIST, needsData, m_navigator->hasErrors());
msg.setSchedulerId(m_navigator->getSchedulerId());
msg.dispatch();
}
void QtCodeFile::requestWholeFileContent()
void QtCodeFile::requestWholeFileContent(size_t targetLineNumber)
{
if (!m_isWholeFile)
{
@@ -284,8 +176,7 @@ void QtCodeFile::requestWholeFileContent()
m_filePath,
MessageChangeFileView::FILE_MAXIMIZED,
MessageChangeFileView::VIEW_LIST,
true,
m_navigator->hasErrors()
CodeScrollParams::toLine(m_filePath, targetLineNumber, CodeScrollParams::Target::VISIBLE)
);
msg.setSchedulerId(m_navigator->getSchedulerId());
msg.dispatch();
@@ -309,7 +200,6 @@ void QtCodeFile::updateContent()
void QtCodeFile::setWholeFile(bool isWholeFile, int refCount)
{
m_isWholeFile = isWholeFile;
setMinimized();
updateRefCount(isWholeFile ? 0 : refCount);
}
@@ -344,16 +234,28 @@ void QtCodeFile::setSnippets()
m_titleBar->setSnippets();
}
void QtCodeFile::setMaximized()
{
setSnippets();
}
bool QtCodeFile::hasSnippets() const
{
return m_snippets.size() > 0;
}
void QtCodeFile::clearSnippets()
{
for (QtCodeSnippet* snippet : m_snippets)
{
m_snippetLayout->removeWidget(snippet);
snippet->hide();
snippet->deleteLater();
}
if (m_snippets.size())
{
m_navigator->clearSnippetReferences();
}
m_snippets.clear();
}
void QtCodeFile::updateSnippets()
{
if (m_snippets.size() == 0)
@@ -391,27 +293,13 @@ void QtCodeFile::findScreenMatches(const std::wstring& query, std::vector<std::p
}
}
std::vector<std::pair<FilePath, Id>> QtCodeFile::getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const
{
std::vector<std::pair<FilePath, Id>> 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 msg(
m_filePath,
MessageChangeFileView::FILE_MINIMIZED,
MessageChangeFileView::VIEW_LIST,
false,
m_navigator->hasErrors()
CodeScrollParams::toFile(m_filePath, CodeScrollParams::Target::VISIBLE)
);
msg.setSchedulerId(m_navigator->getSchedulerId());
msg.dispatch();
@@ -419,14 +307,11 @@ void QtCodeFile::clickedMinimizeButton()
void QtCodeFile::clickedSnippetButton()
{
m_navigator->requestScroll(m_filePath, 0, 0, false, QtCodeNavigateable::SCROLL_VISIBLE);
MessageChangeFileView msg(
m_filePath,
MessageChangeFileView::FILE_SNIPPETS,
MessageChangeFileView::VIEW_LIST,
isCollapsed(),
m_navigator->hasErrors()
CodeScrollParams::toFile(m_filePath, CodeScrollParams::Target::VISIBLE)
);
msg.setSchedulerId(m_navigator->getSchedulerId());
msg.dispatch();
@@ -453,14 +338,17 @@ void QtCodeFile::clickedMaximizeButton()
}
}
m_navigator->requestScroll(m_filePath, lineNumber, locationId, false, QtCodeNavigateable::SCROLL_CENTER);
m_navigator->setMode(QtCodeNavigator::MODE_SINGLE);
CodeScrollParams scrollParams = locationId ?
CodeScrollParams::toReference(m_filePath, locationId, CodeScrollParams::Target::CENTER) :
CodeScrollParams::toLine(m_filePath, lineNumber, CodeScrollParams::Target::CENTER);
MessageChangeFileView msg(
m_filePath,
MessageChangeFileView::FILE_MAXIMIZED,
MessageChangeFileView::VIEW_SINGLE,
true, // TODO: check if data is really needed
m_navigator->hasErrors(),
scrollParams,
true
);
msg.setSchedulerId(m_navigator->getSchedulerId());
+4 -11
View File
@@ -35,19 +35,16 @@ public:
const QtCodeFileTitleBar* getTitleBar() const;
QtCodeSnippet* addCodeSnippet(const CodeSnippetParams& params);
QtCodeSnippet* insertCodeSnippet(const CodeSnippetParams& params);
void updateCodeSnippet(const CodeSnippetParams& params);
void updateSourceLocations(const CodeSnippetParams& params);
const std::vector<QtCodeSnippet*>& getSnippets() const;
std::vector<QtCodeSnippet*> getVisibleSnippets() const;
QtCodeSnippet* getSnippetForLocationId(Id locationId) const;
QtCodeSnippet* getSnippetForLine(unsigned int line) const;
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
bool isCollapsed() const;
void requestContent();
void requestWholeFileContent();
void requestWholeFileContent(size_t targetLineNumber);
void updateContent();
void setWholeFile(bool isWholeFile, int refCount);
@@ -56,16 +53,14 @@ public:
void setMinimized();
void setSnippets();
void setMaximized();
bool hasSnippets() const;
void clearSnippets();
void updateSnippets();
void updateTitleBar();
void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
std::vector<std::pair<FilePath, Id>> getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const;
public slots:
void clickedMinimizeButton();
void clickedSnippetButton();
@@ -83,8 +78,6 @@ private:
const FilePath m_filePath;
bool m_isWholeFile;
mutable bool m_contentRequested;
};
#endif // QT_CODE_FILE_H
+63 -136
View File
@@ -115,13 +115,51 @@ QtCodeFile* QtCodeFileList::getFile(const FilePath filePath)
return file;
}
void QtCodeFileList::addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimeStamp modificationTime)
void QtCodeFileList::addFile(const CodeFileParams& params)
{
QtCodeFile* file = getFile(locationFile->getFilePath());
file->setWholeFile(locationFile->isWhole(), refCount);
file->setModificationTime(modificationTime);
file->setIsComplete(locationFile->isComplete());
file->setIsIndexed(locationFile->isIndexed());
QtCodeFile* file = getFile(params.locationFile->getFilePath());
file->setWholeFile(params.locationFile->isWhole(), params.referenceCount);
file->setModificationTime(params.modificationTime);
file->setIsComplete(params.locationFile->isComplete());
file->setIsIndexed(params.locationFile->isIndexed());
if (params.isMinimized)
{
file->setMinimized();
}
else
{
bool same = true;
const std::vector<QtCodeSnippet*> snippets = file->getSnippets();
if (params.snippetParams.size() != snippets.size())
{
same = false;
}
else
{
for (size_t i = 0; i < snippets.size(); i++)
{
if (params.snippetParams[i].startLineNumber != snippets[i]->getStartLineNumber() ||
params.snippetParams[i].endLineNumber != snippets[i]->getEndLineNumber())
{
same = false;
break;
}
}
}
if (!same)
{
file->clearSnippets();
for (const CodeSnippetParams& snippetParams : params.snippetParams)
{
file->addCodeSnippet(snippetParams);
}
}
file->setSnippets();
}
}
QScrollArea* QtCodeFileList::getScrollArea()
@@ -129,47 +167,36 @@ QScrollArea* QtCodeFileList::getScrollArea()
return m_scrollArea;
}
void QtCodeFileList::addCodeSnippet(const CodeSnippetParams& params)
void QtCodeFileList::updateSourceLocations(const CodeSnippetParams& params)
{
QtCodeFile* file = getFile(params.locationFile->getFilePath());
if (params.insertSnippet)
if (file)
{
file->insertCodeSnippet(params);
file->updateSourceLocations(params);
}
else
}
void QtCodeFileList::updateFiles()
{
for (QtCodeFile* file : m_files)
{
file->addCodeSnippet(params);
file->setProperty("last", file == m_files.back());
file->updateContent();
file->updateTitleBar();
file->show();
}
file->setModificationTime(params.modificationTime);
file->setIsComplete(params.locationFile->isComplete());
file->setIsIndexed(params.locationFile->isIndexed());
// Perform delayed so all widgets are already visible
QTimer::singleShot(100, this, &QtCodeFileList::updateSnippetTitleAndScrollBarSlot);
}
void QtCodeFileList::updateCodeSnippet(const CodeSnippetParams& params)
{
QtCodeFile* file = getFile(params.locationFile->getFilePath());
file->updateCodeSnippet(params);
}
void QtCodeFileList::requestFileContent(const FilePath& filePath)
{
getFile(filePath)->requestContent();
}
bool QtCodeFileList::requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target)
void QtCodeFileList::scrollTo(
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, CodeScrollParams::Target target)
{
QtCodeFile* file = getFile(filePath);
if (!file)
{
return true;
}
if (file->isCollapsed())
{
file->requestContent();
return false;
return;
}
QtCodeSnippet* snippet = nullptr;
@@ -187,16 +214,10 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, size_t lineNumber,
snippet = file->getSnippetForLine(1);
}
if (!snippet)
if (!snippet || !snippet->isVisible())
{
ensureWidgetVisibleAnimated(m_filesArea, file->getTitleBar(), QRect(), animated, target);
return true;
}
if (!snippet->isVisible())
{
file->setSnippets();
return true;
return;
}
size_t endLineNumber = 0;
@@ -228,29 +249,6 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, size_t lineNumber,
ensureWidgetVisibleAnimated(m_filesArea, snippet, lineRect, animated, target);
snippet->ensureLocationIdVisible(locationId, animated);
return true;
}
void QtCodeFileList::updateFiles()
{
for (QtCodeFile* file : m_files)
{
file->setProperty("last", file == m_files.back());
file->updateContent();
}
// Perform delayed so all widgets are already visible
QTimer::singleShot(100, this, &QtCodeFileList::updateSnippetTitleAndScrollBarSlot);
}
void QtCodeFileList::showContents()
{
for (QtCodeFile* file : m_files)
{
file->updateTitleBar();
file->show();
}
}
void QtCodeFileList::onWindowFocus()
@@ -274,67 +272,6 @@ void QtCodeFileList::findScreenMatches(const std::wstring& query, std::vector<st
}
}
std::vector<std::pair<FilePath, Id>> QtCodeFileList::getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const
{
std::vector<std::pair<FilePath, Id>> locationIds;
for (QtCodeFile* file : m_files)
{
utility::append(locationIds, file->getLocationIdsForTokenIds(tokenIds));
}
return locationIds;
}
void QtCodeFileList::setFileMinimized(const FilePath path)
{
if (path.empty())
{
if (m_files.size())
{
m_files[0]->setMinimized();
}
}
else
{
QtCodeFile* file = getFile(path);
file->setMinimized();
if (m_firstSnippetTitleBar->isVisible())
{
ensureWidgetVisibleAnimated(m_filesArea, file->getTitleBar(), QRect(), false, SCROLL_TOP);
}
}
}
void QtCodeFileList::setFileSnippets(const FilePath path)
{
if (path.empty())
{
if (m_files.size())
{
m_files[0]->setSnippets();
}
}
else
{
getFile(path)->setSnippets();
}
}
void QtCodeFileList::setFileMaximized(const FilePath path)
{
if (path.empty())
{
if (m_files.size())
{
m_files[0]->setMaximized();
}
}
else
{
getFile(path)->setMaximized();
}
}
void QtCodeFileList::maximizeFirstFile()
{
if (m_files.size())
@@ -347,11 +284,6 @@ std::pair<QtCodeFile*, Id> QtCodeFileList::getFirstFileWithActiveLocationId() co
{
for (QtCodeFile* file : m_files)
{
if (file->isCollapsed())
{
continue;
}
std::pair<QtCodeSnippet*, Id> snippet = file->getFirstSnippetWithActiveLocationId(0);
if (snippet.first != nullptr)
{
@@ -368,11 +300,6 @@ std::pair<QtCodeSnippet*, Id> QtCodeFileList::getFirstSnippetWithActiveLocationI
for (QtCodeFile* file : m_files)
{
if (file->isCollapsed())
{
continue;
}
result = file->getFirstSnippetWithActiveLocationId(tokenId);
if (result.first != nullptr)
{
+6 -14
View File
@@ -29,30 +29,21 @@ public:
void clearSnippetTitleAndScrollBar();
QtCodeFile* getFile(const FilePath filePath);
void addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimeStamp modificationTime);
void addFile(const CodeFileParams& params);
// QtCodeNaviatebale implementation
QScrollArea* getScrollArea() override;
void addCodeSnippet(const CodeSnippetParams& params) override;
void updateCodeSnippet(const CodeSnippetParams& params) override;
void requestFileContent(const FilePath& filePath) override;
bool requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) override;
void updateSourceLocations(const CodeSnippetParams& params) override;
void updateFiles() override;
void showContents() override;
void scrollTo(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, CodeScrollParams::Target target) override;
void onWindowFocus() override;
void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches) override;
std::vector<std::pair<FilePath, Id>> getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const override;
void setFileMinimized(const FilePath path);
void setFileSnippets(const FilePath path);
void setFileMaximized(const FilePath path);
void maximizeFirstFile();
std::pair<QtCodeFile*, Id> getFirstFileWithActiveLocationId() const;
@@ -64,6 +55,7 @@ protected:
private slots:
void updateSnippetTitleAndScrollBarSlot();
void updateSnippetTitleAndScrollBar(int value = 0);
void scrollLastSnippet(int value);
void scrollLastSnippetScrollBar(int value);
+103 -148
View File
@@ -9,7 +9,6 @@
#include "FilePath.h"
#include "logging.h"
#include "MessageChangeFileView.h"
#include "SourceLocationFile.h"
#include "QtCodeArea.h"
#include "QtCodeFileTitleBar.h"
@@ -20,8 +19,6 @@
QtCodeFileSingle::QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent)
: m_navigator(navigator)
, m_area(nullptr)
, m_contentRequested(false)
, m_scrollRequested(false)
{
setObjectName("code_container");
@@ -44,11 +41,6 @@ QtCodeFileSingle::QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent)
layout()->addWidget(m_areaWrapper);
}
QAbstractScrollArea* QtCodeFileSingle::getScrollArea()
{
return m_area;
}
void QtCodeFileSingle::clearFile()
{
setFileData(FileData());
@@ -65,110 +57,115 @@ void QtCodeFileSingle::clearCache()
m_fileDatas.clear();
m_filePaths.clear();
m_lastLocationFile.reset();
}
void QtCodeFileSingle::addCodeSnippet(const CodeSnippetParams& params)
bool QtCodeFileSingle::addFile(const CodeFileParams& params, bool useSingleFileCache)
{
if (!params.locationFile->isWhole())
if (!params.fileParams)
{
LOG_ERROR("Snippet params passed are not for whole file.");
return;
}
FileData file = getFileData(params.locationFile->getFilePath());
if (file.area)
{
setFileData(file);
return;
}
file.filePath = params.locationFile->getFilePath();
file.modificationTime = params.modificationTime;
file.isComplete = params.locationFile->isComplete();
file.isIndexed = params.locationFile->isIndexed();
if (params.reduced)
{
file.title = params.title;
}
file.area = new QtCodeArea(1, params.code, params.locationFile, m_navigator, !params.reduced, this);
connect(file.area->verticalScrollBar(), &QScrollBar::valueChanged, m_navigator, &QtCodeNavigator::scrolled);
m_fileDatas.emplace(file.filePath, file);
m_filePaths.push_back(file.filePath);
setFileData(file);
m_contentRequested = false;
if (m_filePaths.size() > 100)
{
FilePath toDelete = m_filePaths.front();
m_filePaths.pop_front();
auto it = m_fileDatas.find(toDelete);
if (it != m_fileDatas.end())
{
it->second.area->deleteLater();
m_fileDatas.erase(it);
}
}
}
void QtCodeFileSingle::updateCodeSnippet(const CodeSnippetParams& params)
{
auto it = m_fileDatas.find(params.locationFile->getFilePath());
if (it != m_fileDatas.end())
{
it->second.area->updateSourceLocations(params.locationFile);
}
}
void QtCodeFileSingle::requestFileContent(const FilePath& filePath)
{
if (m_contentRequested)
{
return;
}
FileData file = getFileData(filePath);
if (file.area)
{
setFileData(file);
return;
}
m_contentRequested = true;
MessageChangeFileView msg(
filePath,
MessageChangeFileView::FILE_MAXIMIZED,
MessageChangeFileView::VIEW_SINGLE,
true,
m_navigator->hasErrors()
);
msg.setSchedulerId(m_navigator->getSchedulerId());
msg.dispatch();
}
bool QtCodeFileSingle::requestScroll(
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target)
{
FileData file = getFileData(filePath);
if (file.area)
{
setFileData(file);
}
else
{
requestFileContent(filePath);
LOG_ERROR("File params have missing information.");
return false;
}
if (!m_scrollRequested)
std::shared_ptr<SourceLocationFile> locationFile = params.fileParams->locationFile;
FileData file = useSingleFileCache ? getFileData(locationFile->getFilePath()) : FileData();
if (file.area)
{
animated = false;
if (file.area == m_area)
{
return false;
}
setFileData(file);
return true;
}
if (!locationFile->isWhole())
{
LOG_ERROR("Snippet params passed are not for whole file.");
return false;
}
// prevent non cached file from being created again when currently displayed
if (locationFile == m_lastLocationFile && locationFile->getFilePath() == m_currentFilePath)
{
return false;
}
m_lastLocationFile = locationFile;
file.filePath = locationFile->getFilePath();
file.isComplete = locationFile->isComplete();
file.isIndexed = locationFile->isIndexed();
file.modificationTime = params.modificationTime;
if (params.fileParams->isOverview)
{
file.title = params.fileParams->title;
}
file.area = new QtCodeArea(1, params.fileParams->code, locationFile, m_navigator, !params.fileParams->isOverview, this);
connect(file.area->verticalScrollBar(), &QScrollBar::valueChanged, m_navigator, &QtCodeNavigator::scrolled);
setFileData(file);
updateRefCount(params.referenceCount);
if (useSingleFileCache)
{
m_fileDatas.emplace(file.filePath, file);
m_filePaths.push_back(file.filePath);
if (m_filePaths.size() > 100)
{
// TODO: don't delete files that were added multiple times
FilePath toDelete = m_filePaths.front();
m_filePaths.pop_front();
auto it = m_fileDatas.find(toDelete);
if (it != m_fileDatas.end())
{
it->second.area->deleteLater();
m_fileDatas.erase(it);
}
}
}
return true;
}
QAbstractScrollArea* QtCodeFileSingle::getScrollArea()
{
return m_area;
}
void QtCodeFileSingle::updateSourceLocations(const CodeSnippetParams& params)
{
if (m_currentFilePath == params.locationFile->getFilePath())
{
m_area->updateSourceLocations(params.locationFile);
}
}
void QtCodeFileSingle::updateFiles()
{
if (m_area)
{
m_area->updateContent();
m_area->show();
// Resizes the area to fix a bug where the area could be scrolled below the last line.
m_area->updateGeometry();
}
}
void QtCodeFileSingle::scrollTo(
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, CodeScrollParams::Target target)
{
if (m_currentFilePath != filePath)
{
return;
}
size_t endLineNumber = 0;
@@ -196,30 +193,6 @@ bool QtCodeFileSingle::requestScroll(
ensurePercentVisibleAnimated(percentA, percentB, animated, target);
m_area->ensureLocationIdVisible(locationId, width(), animated);
m_scrollRequested = true;
return true;
}
void QtCodeFileSingle::updateFiles()
{
if (m_area)
{
m_area->updateContent();
}
}
void QtCodeFileSingle::showContents()
{
if (m_area)
{
m_area->show();
updateRefCount(m_area->getActiveLocationCount());
// Resizes the area to fix a bug where the area could be scrolled below the last line.
m_area->updateGeometry();
}
}
void QtCodeFileSingle::onWindowFocus()
@@ -235,21 +208,6 @@ void QtCodeFileSingle::findScreenMatches(const std::wstring& query, std::vector<
}
}
std::vector<std::pair<FilePath, Id>> QtCodeFileSingle::getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const
{
if (m_area)
{
std::vector<std::pair<FilePath, Id>> 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;
@@ -278,14 +236,13 @@ Id QtCodeFileSingle::getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) con
void QtCodeFileSingle::clickedSnippetButton()
{
m_navigator->requestScroll(m_currentFilePath, 0, 0, false, QtCodeNavigateable::SCROLL_TOP);
m_navigator->setMode(QtCodeNavigator::MODE_LIST);
MessageChangeFileView(
m_currentFilePath,
MessageChangeFileView::FILE_SNIPPETS,
MessageChangeFileView::VIEW_LIST,
true, // TODO: check if data is really needed
m_navigator->hasErrors(),
CodeScrollParams::toFile(m_currentFilePath, CodeScrollParams::Target::TOP),
true
).dispatch();
}
@@ -350,8 +307,6 @@ void QtCodeFileSingle::setFileData(const FileData& file)
// Resizes the area to fix a bug where the area could be scrolled below the last line.
m_area->updateGeometry();
m_scrollRequested = false;
}
else
{
+6 -12
View File
@@ -30,26 +30,21 @@ public:
void clearFile();
void clearCache();
bool addFile(const CodeFileParams& params, bool useSingleFileCache);
// QtCodeNavigateable implementation
QAbstractScrollArea* getScrollArea() override;
void addCodeSnippet(const CodeSnippetParams& params) override;
void updateCodeSnippet(const CodeSnippetParams& params) override;
void requestFileContent(const FilePath& filePath) override;
bool requestScroll(
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) override;
void updateSourceLocations(const CodeSnippetParams& params) override;
void updateFiles() override;
void showContents() override;
void scrollTo(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, CodeScrollParams::Target target) override;
void onWindowFocus() override;
void findScreenMatches(
const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches) override;
std::vector<std::pair<FilePath, Id>> getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const override;
const FilePath& getCurrentFilePath() const;
bool hasFileCached(const FilePath& filePath) const;
@@ -86,8 +81,7 @@ private:
std::map<FilePath, FileData> m_fileDatas;
std::deque<FilePath> m_filePaths;
bool m_contentRequested;
bool m_scrollRequested;
std::shared_ptr<SourceLocationFile> m_lastLocationFile;
};
#endif // QT_CODE_FILE_SINGLE_H
@@ -11,7 +11,7 @@ QtCodeNavigateable::~QtCodeNavigateable()
}
void QtCodeNavigateable::ensureWidgetVisibleAnimated(
const QWidget* parentWidget, const QWidget *childWidget, QRectF rect, bool animated, ScrollTarget target)
const QWidget* parentWidget, const QWidget *childWidget, QRectF rect, bool animated, CodeScrollParams::Target target)
{
QAbstractScrollArea* area = getScrollArea();
if (!area || !parentWidget->isAncestorOf(childWidget))
@@ -36,19 +36,28 @@ void QtCodeNavigateable::ensureWidgetVisibleAnimated(
// scroll to top if widget is bigger than view
if (focusRect.height() > visibleRect.height())
{
target = SCROLL_TOP;
target = CodeScrollParams::Target::TOP;
}
int value = 0;
switch (target)
{
case SCROLL_VISIBLE:
case CodeScrollParams::Target::VISIBLE:
if (focusRect.top() > visibleRect.top() && focusRect.bottom() < visibleRect.bottom())
{
return;
}
else if (focusRect.top() < visibleRect.top())
{
value = focusRect.top() - visibleRect.top() - 50;
}
else
{
value = focusRect.bottom() - visibleRect.bottom() + 50;
}
break;
case SCROLL_CENTER:
case CodeScrollParams::Target::CENTER:
value = focusRect.center().y() - visibleRect.center().y();
if (abs(value) < 50)
{
@@ -56,8 +65,12 @@ void QtCodeNavigateable::ensureWidgetVisibleAnimated(
}
break;
case SCROLL_TOP:
case CodeScrollParams::Target::TOP:
value = focusRect.top() - visibleRect.top() - 50;
if (value > 0 && value < 150)
{
value = 0;
}
break;
}
@@ -80,7 +93,8 @@ void QtCodeNavigateable::ensureWidgetVisibleAnimated(
}
}
void QtCodeNavigateable::ensurePercentVisibleAnimated(double percentA, double percentB, bool animated, ScrollTarget target)
void QtCodeNavigateable::ensurePercentVisibleAnimated(
double percentA, double percentB, bool animated, CodeScrollParams::Target target)
{
QAbstractScrollArea* area = getScrollArea();
if (!area)
@@ -105,18 +119,18 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(double percentA, double pe
if (rectHeight > visibleHeight)
{
target = SCROLL_TOP;
target = CodeScrollParams::Target::TOP;
}
switch (target)
{
case SCROLL_VISIBLE:
case CodeScrollParams::Target::VISIBLE:
if (scrollY > visibleY && scrollY + rectHeight < visibleY + scrollableHeight)
{
return;
}
case SCROLL_CENTER:
case CodeScrollParams::Target::CENTER:
if (rectHeight < visibleHeight / 2)
{
scrollY -= visibleHeight / 4;
@@ -127,8 +141,8 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(double percentA, double pe
}
break;
case SCROLL_TOP:
scrollY -= 20;
case CodeScrollParams::Target::TOP:
scrollY -= 100;
break;
}
@@ -3,9 +3,9 @@
#include <set>
#include "types.h"
#include "CodeScrollParams.h"
#include "CodeSnippetParams.h"
#include "types.h"
class FilePath;
class QRectF;
@@ -17,35 +17,24 @@ class QWidget;
class QtCodeNavigateable
{
public:
enum ScrollTarget
{
SCROLL_VISIBLE,
SCROLL_CENTER,
SCROLL_TOP
};
virtual ~QtCodeNavigateable();
virtual QAbstractScrollArea* getScrollArea() = 0;
virtual void addCodeSnippet(const CodeSnippetParams& params) = 0;
virtual void updateCodeSnippet(const CodeSnippetParams& params) = 0;
virtual void requestFileContent(const FilePath& filePath) = 0;
virtual bool requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) = 0;
virtual void updateSourceLocations(const CodeSnippetParams& params) = 0;
virtual void updateFiles() = 0;
virtual void showContents() = 0;
virtual void scrollTo(
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, CodeScrollParams::Target target) = 0;
virtual void onWindowFocus() = 0;
virtual void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches) = 0;
virtual std::vector<std::pair<FilePath, Id>> getLocationIdsForTokenIds(const std::set<Id>& 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);
void ensureWidgetVisibleAnimated(
const QWidget* parentWidget, const QWidget *childWidget, QRectF rect, bool animated, CodeScrollParams::Target target);
void ensurePercentVisibleAnimated(double percentA, double percentB, bool animated, CodeScrollParams::Target target);
QRect getFocusRectForWidget(const QWidget* childWidget, const QWidget* parentWidget) const;
};
File diff suppressed because it is too large Load Diff
+13 -95
View File
@@ -10,8 +10,6 @@
#include "QtThreadedFunctor.h"
#include "MessageListener.h"
#include "MessageIndexingFinished.h"
#include "MessageCodeReference.h"
#include "MessageShowReference.h"
#include "MessageSwitchColorScheme.h"
#include "MessageWindowFocus.h"
@@ -23,9 +21,7 @@ class SourceLocationFile;
class QtCodeNavigator
: public QWidget
, public MessageListener<MessageCodeReference>
, public MessageListener<MessageIndexingFinished>
, public MessageListener<MessageShowReference>
, public MessageListener<MessageSwitchColorScheme>
, public MessageListener<MessageWindowFocus>
{
@@ -42,16 +38,16 @@ public:
QtCodeNavigator(QWidget* parent = nullptr);
virtual ~QtCodeNavigator();
void addCodeSnippet(const CodeSnippetParams& params);
void updateCodeSnippet(const CodeSnippetParams& params);
void addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimeStamp modificationTime);
void addedFiles();
void addSnippetFile(const CodeFileParams& params);
bool addSingleFile(const CodeFileParams& params, bool useSingleFileCache);
void updateSourceLocations(const CodeSnippetParams& params);
void updateReferenceCount(
size_t referenceCount, size_t referenceIndex, size_t localReferenceCount, size_t localReferenceIndex);
void clear();
void clearCodeSnippets(bool useSingleFileCache);
void clearSnippets();
void clearFile();
void clearCaches();
void clearCache();
void clearSnippetReferences();
void setMode(Mode mode);
@@ -86,18 +82,10 @@ public:
bool isInListMode() const;
bool hasSingleFileCached(const FilePath& filePath) const;
void showActiveSnippet(
const std::vector<Id>& activeTokenIds, std::shared_ptr<SourceLocationCollection> collection, bool scrollTo);
void focusTokenIds(const std::vector<Id>& focusedTokenIds);
void defocusTokenIds();
void setFileMinimized(const FilePath path);
void setFileSnippets(const FilePath path);
void setFileMaximized(const FilePath path);
void updateFiles();
void showContents();
void refreshStyle();
@@ -107,17 +95,7 @@ public:
bool hasScreenMatches() const;
void clearScreenMatches();
void scrollToValue(int value, bool inListMode);
void scrollToLine(const FilePath& filePath, unsigned int line);
void scrollToDefinition(bool animated, bool ignoreActiveReference);
void scrollToSnippetIfRequested();
void requestScroll(
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target);
signals:
void scrollRequest();
void scrollTo(const CodeScrollParams& params, bool animated);
public slots:
void scrolled(int value);
@@ -126,62 +104,17 @@ protected:
void showEvent(QShowEvent* event) override;
private slots:
void handleScrollRequest();
void setValue();
void previousReference();
void nextReference();
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 previousLocalReference();
void nextLocalReference();
void setModeList();
void setModeSingle();
private:
struct Reference
{
Reference()
: tokenId(0)
, locationId(0)
, locationType(LOCATION_TOKEN)
{
}
FilePath filePath;
Id tokenId;
Id locationId;
LocationType locationType;
};
void showCurrentReference(bool fromUI);
void showCurrentLocalReference();
void updateRefLabels();
struct ScrollRequest
{
ScrollRequest()
: lineNumber(0)
, locationId(0)
, animated(false)
, target(QtCodeNavigateable::SCROLL_VISIBLE)
{
}
FilePath filePath;
size_t lineNumber;
Id locationId;
bool animated;
QtCodeNavigateable::ScrollTarget target;
};
void handleMessage(MessageCodeReference* message) override;
void handleMessage(MessageIndexingFinished* message) override;
void handleMessage(MessageShowReference* message) override;
void handleMessage(MessageSwitchColorScheme* message) override;
void handleMessage(MessageWindowFocus* message) override;
@@ -205,12 +138,6 @@ private:
std::set<Id> m_focusedTokenIds;
std::map<Id, ErrorInfo> m_errorInfos;
Id m_activeTokenId;
int m_value;
QtSearchBarButton* m_prevFileButton;
QtSearchBarButton* m_nextFileButton;
QtSearchBarButton* m_prevReferenceButton;
QtSearchBarButton* m_nextReferenceButton;
QLabel* m_refLabel;
@@ -224,16 +151,7 @@ private:
QFrame* m_separatorLine;
std::vector<Reference> m_references;
Reference m_activeReference;
size_t m_refIndex;
std::vector<Reference> m_localReferences;
size_t m_localRefIndex;
ScrollRequest m_scrollRequest;
bool m_singleHasNewFile;
bool m_useSingleFileCache;
CodeScrollParams m_scrollParams;
std::vector<std::pair<QtCodeArea*, Id>> m_screenMatches;
Id m_activeScreenMatchId = 0;
+5 -62
View File
@@ -10,54 +10,6 @@
#include "QtCodeNavigator.h"
#include "QtCodeFile.h"
QtCodeSnippet* QtCodeSnippet::merged(
const QtCodeSnippet* a, const QtCodeSnippet* b, QtCodeNavigator* navigator, QtCodeFile* file)
{
const QtCodeSnippet* first = a->getStartLineNumber() < b->getStartLineNumber() ? a : b;
const QtCodeSnippet* second = a->getStartLineNumber() > b->getStartLineNumber() ? a : b;
SourceLocationFile* aFile = a->m_codeArea->getSourceLocationFile().get();
SourceLocationFile* bFile = b->m_codeArea->getSourceLocationFile().get();
std::shared_ptr<SourceLocationFile> locationFile = std::make_shared<SourceLocationFile>(
aFile->getFilePath(), aFile->getLanguage(), aFile->isWhole(), aFile->isComplete(), aFile->isIndexed());
aFile->forEachSourceLocation(
[&locationFile](SourceLocation* loc)
{
locationFile->addSourceLocationCopy(loc);
}
);
bFile->forEachSourceLocation(
[&locationFile](SourceLocation* loc)
{
locationFile->addSourceLocationCopy(loc);
}
);
std::string code = first->getCode();
std::string secondCode = second->getCode();
int secondCodeStartIndex = 0;
for (size_t i = second->getStartLineNumber(); i <= first->getEndLineNumber(); i++)
{
secondCodeStartIndex = secondCode.find("\n", secondCodeStartIndex) + 1;
}
code += secondCode.substr(secondCodeStartIndex, secondCode.npos);
CodeSnippetParams params;
params.startLineNumber = first->getStartLineNumber();
params.title = first->m_titleString;
params.titleId = first->m_titleId;
params.footer = second->m_footerString;
params.footerId = second->m_footerId;
params.code = code;
params.locationFile = locationFile;
return new QtCodeSnippet(params, navigator, file);
}
QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* navigator, QtCodeFile* file)
: QFrame(file)
, m_navigator(navigator)
@@ -78,7 +30,7 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* n
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
if (!m_titleString.empty() && !params.reduced)
if (!m_titleString.empty() && !params.isOverview)
{
m_title = createScopeLine(layout);
if (m_titleId == 0) // title is a file path
@@ -92,7 +44,7 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* n
connect(m_title, &QPushButton::clicked, this, &QtCodeSnippet::clickedTitle);
}
m_codeArea = new QtCodeArea(params.startLineNumber, params.code, params.locationFile, navigator, !params.reduced, this);
m_codeArea = new QtCodeArea(params.startLineNumber, params.code, params.locationFile, navigator, !params.isOverview, this);
layout->addWidget(m_codeArea);
if (!m_footerString.empty())
@@ -139,7 +91,7 @@ int QtCodeSnippet::lineNumberDigits() const
return m_codeArea->lineNumberDigits();
}
void QtCodeSnippet::updateCodeSnippet(const CodeSnippetParams& params)
void QtCodeSnippet::updateSourceLocations(const CodeSnippetParams& params)
{
m_codeArea->updateSourceLocations(params.locationFile);
@@ -199,11 +151,6 @@ void QtCodeSnippet::findScreenMatches(const std::wstring& query, std::vector<std
m_codeArea->findScreenMatches(query, screenMatches);
}
std::vector<Id> QtCodeSnippet::getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const
{
return m_codeArea->getLocationIdsForTokenIds(tokenIds);
}
void QtCodeSnippet::ensureLocationIdVisible(Id locationId, bool animated)
{
m_codeArea->ensureLocationIdVisible(locationId, width(), animated);
@@ -217,10 +164,8 @@ void QtCodeSnippet::clickedTitle()
}
else
{
getFile()->requestWholeFileContent();
getFile()->requestWholeFileContent(getStartLineNumber());
}
m_navigator->requestScroll(getFile()->getFilePath(), getStartLineNumber(), 0, true, QtCodeNavigateable::SCROLL_VISIBLE);
}
void QtCodeSnippet::clickedFooter()
@@ -231,10 +176,8 @@ void QtCodeSnippet::clickedFooter()
}
else
{
getFile()->requestWholeFileContent();
getFile()->requestWholeFileContent(getEndLineNumber());
}
m_navigator->requestScroll(getFile()->getFilePath(), getEndLineNumber(), 0, true, QtCodeNavigateable::SCROLL_CENTER);
}
QPushButton* QtCodeSnippet::createScopeLine(QBoxLayout* layout)
+1 -6
View File
@@ -23,9 +23,6 @@ class QtCodeSnippet
Q_OBJECT
public:
static QtCodeSnippet* merged(
const QtCodeSnippet* a, const QtCodeSnippet* b, QtCodeNavigator* navigator, QtCodeFile* file);
QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* navigator, QtCodeFile* file);
virtual ~QtCodeSnippet();
@@ -37,7 +34,7 @@ public:
int lineNumberDigits() const;
void updateCodeSnippet(const CodeSnippetParams& params);
void updateSourceLocations(const CodeSnippetParams& params);
void updateLineNumberAreaWidthForDigits(int digits);
void updateContent();
@@ -54,8 +51,6 @@ public:
void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
std::vector<Id> getLocationIdsForTokenIds(const std::set<Id>& tokenIds) const;
void ensureLocationIdVisible(Id locationId, bool animated);
private slots: