ui: Stay at original line when expanding scope in the code view
bug id = 82
This commit is contained in:
@@ -25,6 +25,7 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent)
|
||||
, m_parent(parent)
|
||||
, m_filePath(filePath)
|
||||
, m_snippetsRequested(false)
|
||||
, m_scrollToLine(0)
|
||||
{
|
||||
setObjectName("code_file");
|
||||
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
@@ -153,7 +154,7 @@ bool QtCodeFile::hasErrors() const
|
||||
return m_parent->hasErrors();;
|
||||
}
|
||||
|
||||
void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
|
||||
QtCodeSnippet* QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
|
||||
{
|
||||
m_locationFile.reset();
|
||||
|
||||
@@ -208,13 +209,16 @@ void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
|
||||
{
|
||||
updateRefCount(0);
|
||||
}
|
||||
return;
|
||||
|
||||
return m_fileSnippet.get();
|
||||
}
|
||||
|
||||
m_snippets.push_back(snippet);
|
||||
|
||||
setSnippets();
|
||||
updateRefCount(params.refCount);
|
||||
|
||||
return snippet.get();
|
||||
}
|
||||
|
||||
QtCodeSnippet* QtCodeFile::insertCodeSnippet(const CodeSnippetParams& params)
|
||||
@@ -495,6 +499,16 @@ void QtCodeFile::updateSnippets()
|
||||
m_snippets.back()->setProperty("isLast", true);
|
||||
}
|
||||
|
||||
uint QtCodeFile::getScrollToLine() const
|
||||
{
|
||||
return m_scrollToLine;
|
||||
}
|
||||
|
||||
void QtCodeFile::setScrollToLine(uint line)
|
||||
{
|
||||
m_scrollToLine = line;
|
||||
}
|
||||
|
||||
void QtCodeFile::handleMessage(MessageWindowFocus* message)
|
||||
{
|
||||
updateTitleBar();
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
std::vector<std::string> getErrorMessages() const;
|
||||
bool hasErrors() const;
|
||||
|
||||
void addCodeSnippet(const CodeSnippetParams& params);
|
||||
QtCodeSnippet* addCodeSnippet(const CodeSnippetParams& params);
|
||||
QtCodeSnippet* insertCodeSnippet(const CodeSnippetParams& params);
|
||||
|
||||
QtCodeSnippet* findFirstActiveSnippet() const;
|
||||
@@ -65,6 +65,9 @@ public:
|
||||
|
||||
void updateSnippets();
|
||||
|
||||
uint getScrollToLine() const;
|
||||
void setScrollToLine(uint line);
|
||||
|
||||
public slots:
|
||||
void clickedMinimizeButton() const;
|
||||
void clickedSnippetButton() const;
|
||||
@@ -103,6 +106,8 @@ private:
|
||||
|
||||
std::shared_ptr<TokenLocationFile> m_locationFile;
|
||||
mutable bool m_snippetsRequested;
|
||||
|
||||
uint m_scrollToLine;
|
||||
};
|
||||
|
||||
#endif // QT_CODE_FILE_H
|
||||
|
||||
@@ -45,15 +45,21 @@ void QtCodeFileList::addCodeSnippet(
|
||||
bool insert
|
||||
){
|
||||
QtCodeFile* file = getFile(params.locationFile->getFilePath());
|
||||
QtCodeSnippet* snippet = nullptr;
|
||||
|
||||
if (insert)
|
||||
{
|
||||
QtCodeSnippet* snippet = file->insertCodeSnippet(params);
|
||||
emit shouldScrollToSnippet(snippet, params.startLineNumber);
|
||||
snippet = file->insertCodeSnippet(params);
|
||||
}
|
||||
else
|
||||
{
|
||||
file->addCodeSnippet(params);
|
||||
snippet = file->addCodeSnippet(params);
|
||||
}
|
||||
|
||||
if (snippet && file->getScrollToLine())
|
||||
{
|
||||
emit shouldScrollToSnippet(snippet, file->getScrollToLine());
|
||||
file->setScrollToLine(0);
|
||||
}
|
||||
|
||||
file->setModificationTime(params.modificationTime);
|
||||
|
||||
@@ -173,13 +173,15 @@ std::string QtCodeSnippet::getCode() const
|
||||
|
||||
void QtCodeSnippet::clickedTitle()
|
||||
{
|
||||
getFile()->setScrollToLine(getStartLineNumber());
|
||||
|
||||
if (m_titleId > 0)
|
||||
{
|
||||
MessageShowScope(m_titleId, dynamic_cast<QtCodeFile*>(parent())->hasErrors()).dispatch();
|
||||
MessageShowScope(m_titleId, getFile()->hasErrors()).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamic_cast<QtCodeFile*>(parent())->clickedMaximizeButton();
|
||||
getFile()->clickedMaximizeButton();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +189,8 @@ void QtCodeSnippet::clickedFooter()
|
||||
{
|
||||
if (m_footerId > 0)
|
||||
{
|
||||
MessageShowScope(m_footerId, dynamic_cast<QtCodeFile*>(parent())->hasErrors()).dispatch();
|
||||
getFile()->setScrollToLine(getEndLineNumber());
|
||||
MessageShowScope(m_footerId, getFile()->hasErrors()).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user