diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index 20ada589..0c8538f1 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -3,7 +3,6 @@ #include #include "utility/messaging/type/MessageStatus.h" -#include "utility/messaging/type/MessageScrollToLine.h" #include "utility/text/TextAccess.h" #include "utility/tracing.h" #include "utility/utility.h" @@ -213,7 +212,7 @@ void CodeController::handleMessage(MessageChangeFileView* message) params.locationFile = file; } - getView()->showCodeFile(params); + getView()->addCodeSnippets(std::vector(1, params), false); } view->setFileState(message->filePath, CodeView::FILE_MAXIMIZED); break; @@ -239,20 +238,20 @@ void CodeController::handleMessage(MessageFocusOut* message) void CodeController::handleMessage(MessageScrollToLine* message) { - getView()->scrollToLine(message->filename, message->line); + getView()->scrollToLine(message->filePath, message->line); - if ( message->isModified ) + if (message->isModified) { MessageStatus( - "File was modified. Showing the File: " + message->filename - + " at line " + std::to_string(message->line) + " now. Please refresh." + "The file was modified, please refresh. Showing source location: " + message->filePath.str() + + " : " + std::to_string(message->line), + true ).dispatch(); } else { MessageStatus( - "Showing the File: " + message->filename - + " at line " + std::to_string(message->line) + "." + "Showing source location: " + message->filePath.str() + " : " + std::to_string(message->line) ).dispatch(); } } diff --git a/src/lib/component/controller/FeatureController.cpp b/src/lib/component/controller/FeatureController.cpp index e49459c8..d8c006ff 100644 --- a/src/lib/component/controller/FeatureController.cpp +++ b/src/lib/component/controller/FeatureController.cpp @@ -77,9 +77,10 @@ void FeatureController::handleMessage(MessageActivateFile* message) msg.setKeepContent(message->keepContent()); msg.dispatchImmediately(); } - if( message->line > 0 ) + + if (message->line > 0) { - MessageScrollToLine(message->filePath.str(), message->line, true).dispatch(); + MessageScrollToLine(message->filePath, message->line, true).dispatch(); } } diff --git a/src/lib/component/controller/IDECommunicationController.cpp b/src/lib/component/controller/IDECommunicationController.cpp index de0e3aa1..d7f9b61f 100644 --- a/src/lib/component/controller/IDECommunicationController.cpp +++ b/src/lib/component/controller/IDECommunicationController.cpp @@ -12,8 +12,6 @@ #include "utility/messaging/type/MessageProjectNew.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/messaging/type/MessageActivateFile.h" -#include "utility/messaging/type/MessageScrollCode.h" -#include "utility/messaging/type/MessageScrollToLine.h" IDECommunicationController::IDECommunicationController(StorageAccess* storageAccess) : m_storageAccess(storageAccess) @@ -70,32 +68,32 @@ void IDECommunicationController::handleSetActiveTokenMessage( { const unsigned int cursorColumn = message.column; - if(FileSystem::getFileInfoForPath(message.fileLocation).lastWriteTime - == m_storageAccess->getFileInfoForFilePath(message.fileLocation).lastWriteTime) + if (FileSystem::getFileInfoForPath(message.fileLocation).lastWriteTime + == m_storageAccess->getFileInfoForFilePath(message.fileLocation).lastWriteTime) { // file was not modified std::shared_ptr tokenLocationFile = m_storageAccess->getTokenLocationsForLinesInFile( - message.fileLocation, message.row, message.row + message.fileLocation, message.row, message.row ); std::vector selectedLocationIds; tokenLocationFile->forEachStartTokenLocation( - [&](TokenLocation* startLocation) - { - TokenLocation* endLocation = startLocation->getEndTokenLocation(); + [&](TokenLocation* startLocation) + { + TokenLocation* endLocation = startLocation->getEndTokenLocation(); - if (!startLocation->isScopeTokenLocation() - && startLocation->getColumnNumber() <= cursorColumn - && endLocation->getColumnNumber() + 1 >= cursorColumn) - { - selectedLocationIds.push_back(startLocation->getId()); - } + if (!startLocation->isScopeTokenLocation() + && startLocation->getColumnNumber() <= cursorColumn + && endLocation->getColumnNumber() + 1 >= cursorColumn) + { + selectedLocationIds.push_back(startLocation->getId()); } + } ); if (selectedLocationIds.size() > 0) { - MessageStatus("Activating a source location from external succeeded.").dispatch(); + MessageStatus("Activating a source location from plug-in succeeded.").dispatch(); MessageDispatchWhenLicenseValid( std::make_shared(selectedLocationIds) ).dispatch(); @@ -105,7 +103,7 @@ void IDECommunicationController::handleSetActiveTokenMessage( } Id fileId = m_storageAccess->getTokenIdForFileNode(message.fileLocation); - if( fileId > 0) + if (fileId > 0) { MessageDispatchWhenLicenseValid( std::make_shared(message.fileLocation, message.row) @@ -115,8 +113,9 @@ void IDECommunicationController::handleSetActiveTokenMessage( else { MessageStatus( - "Activating a source location from external failed. No file " + message.fileLocation - + " have been found at in indexed source." + "Activating source location from plug-in failed. File " + message.fileLocation + + " was not found in the project.", + true ).dispatch(); } } diff --git a/src/lib/component/view/CodeView.h b/src/lib/component/view/CodeView.h index fa59ffe8..5873d7ca 100644 --- a/src/lib/component/view/CodeView.h +++ b/src/lib/component/view/CodeView.h @@ -34,7 +34,6 @@ public: virtual void showCodeSnippets(const std::vector& snippets, const std::vector& activeTokenIds) = 0; virtual void addCodeSnippets(const std::vector& snippets, bool insert) = 0; - virtual void showCodeFile(const CodeSnippetParams& params) = 0; virtual void setFileState(const FilePath filePath, FileState state) = 0; @@ -49,7 +48,7 @@ public: virtual void showContents() = 0; virtual void scrollToValue(int value) = 0; - virtual void scrollToLine(std::string filename, unsigned int line) = 0; + virtual void scrollToLine(const FilePath filePath, unsigned int line) = 0; private: CodeController* getController(); diff --git a/src/lib/utility/messaging/type/MessageScrollToLine.h b/src/lib/utility/messaging/type/MessageScrollToLine.h index 73559f73..b2e0f8d8 100644 --- a/src/lib/utility/messaging/type/MessageScrollToLine.h +++ b/src/lib/utility/messaging/type/MessageScrollToLine.h @@ -2,17 +2,17 @@ #define MESSAGE_SCROLL_TO_LINE_h #include "utility/messaging/Message.h" +#include "utility/file/FilePath.h" class MessageScrollToLine : public Message { public: - MessageScrollToLine(std::string filename, unsigned int line, bool isModified = false) - : filename(filename) + MessageScrollToLine(const FilePath& filePath, unsigned int line, bool isModified = false) + : filePath(filePath) , line(line) , isModified(isModified) { - setIsLogged(false); } static const std::string getStaticType() @@ -20,7 +20,7 @@ public: return "MessageScrollToLine"; } - std::string filename; + const FilePath filePath; unsigned int line; bool isModified; }; diff --git a/src/lib_gui/qt/element/QtCodeArea.cpp b/src/lib_gui/qt/element/QtCodeArea.cpp index ced20938..1ce301dc 100644 --- a/src/lib_gui/qt/element/QtCodeArea.cpp +++ b/src/lib_gui/qt/element/QtCodeArea.cpp @@ -264,6 +264,15 @@ uint QtCodeArea::getLineNumberForLocationId(Id locationId) const QRectF QtCodeArea::getLineRectForLineNumber(uint lineNumber) const { + if (lineNumber < getStartLineNumber()) + { + lineNumber = getStartLineNumber(); + } + else if (lineNumber > getEndLineNumber()) + { + lineNumber = getEndLineNumber(); + } + QTextBlock block = document()->findBlockByLineNumber(lineNumber - m_startLineNumber); return blockBoundingGeometry(block); } diff --git a/src/lib_gui/qt/element/QtCodeFile.cpp b/src/lib_gui/qt/element/QtCodeFile.cpp index af1cc04d..9b0f10d8 100644 --- a/src/lib_gui/qt/element/QtCodeFile.cpp +++ b/src/lib_gui/qt/element/QtCodeFile.cpp @@ -25,7 +25,6 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator) , m_navigator(navigator) , m_filePath(filePath) , m_contentRequested(false) - , m_scrollToLine(0) { setObjectName("code_file"); setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); @@ -252,6 +251,24 @@ QtCodeSnippet* QtCodeFile::getSnippetForLocationId(Id locationId) const return nullptr; } +QtCodeSnippet* QtCodeFile::getSnippetForLine(unsigned int line) const +{ + if (m_fileSnippet && m_fileSnippet->isVisible()) + { + return m_fileSnippet.get(); + } + + for (std::shared_ptr snippet : m_snippets) + { + if (snippet->getStartLineNumber() <= line && line <= snippet->getEndLineNumber()) + { + return snippet.get(); + } + } + + return nullptr; +} + QtCodeSnippet* QtCodeFile::getFileSnippet() const { return m_fileSnippet.get(); @@ -386,16 +403,6 @@ 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::clickedMinimizeButton() const { MessageChangeFileView( @@ -421,7 +428,7 @@ void QtCodeFile::clickedMaximizeButton() const MessageChangeFileView( m_filePath, MessageChangeFileView::FILE_MAXIMIZED, - !isCollapsed(), + !getFileSnippet(), m_navigator->hasErrors() ).dispatch(); } diff --git a/src/lib_gui/qt/element/QtCodeFile.h b/src/lib_gui/qt/element/QtCodeFile.h index 85bbd6b3..37975257 100644 --- a/src/lib_gui/qt/element/QtCodeFile.h +++ b/src/lib_gui/qt/element/QtCodeFile.h @@ -43,6 +43,7 @@ public: QtCodeSnippet* insertCodeSnippet(const CodeSnippetParams& params); QtCodeSnippet* getSnippetForLocationId(Id locationId) const; + QtCodeSnippet* getSnippetForLine(unsigned int line) const; QtCodeSnippet* getFileSnippet() const; bool isCollapsed() const; @@ -59,9 +60,6 @@ public: bool hasSnippets() const; void updateSnippets(); - uint getScrollToLine() const; - void setScrollToLine(uint line); - public slots: void clickedMinimizeButton() const; void clickedSnippetButton() const; @@ -100,8 +98,6 @@ private: std::shared_ptr m_locationFile; mutable bool m_contentRequested; - - uint m_scrollToLine; }; #endif // QT_CODE_FILE_H diff --git a/src/lib_gui/qt/element/QtCodeFileList.cpp b/src/lib_gui/qt/element/QtCodeFileList.cpp index 85a33896..90358172 100644 --- a/src/lib_gui/qt/element/QtCodeFileList.cpp +++ b/src/lib_gui/qt/element/QtCodeFileList.cpp @@ -12,8 +12,6 @@ QtCodeFileList::QtCodeFileList(QtCodeNavigator* navigator) : QFrame() , m_navigator(navigator) - , m_scrollToFile(nullptr) - , m_scrollToLocationId(0) { setObjectName("code_file_list"); @@ -44,12 +42,6 @@ void QtCodeFileList::addCodeSnippet( snippet = file->addCodeSnippet(params); } - if (snippet && file->getScrollToLine()) - { - emit shouldScrollToSnippet(snippet, file->getScrollToLine()); - file->setScrollToLine(0); - } - file->setModificationTime(params.modificationTime); } @@ -65,28 +57,6 @@ void QtCodeFileList::clearCodeSnippets() m_files.clear(); } -void QtCodeFileList::showLocation(const FilePath& filePath, Id locationId, bool scrollTo) -{ - updateFiles(); - - QtCodeFile* file = getFile(filePath); - - if (file->isCollapsed()) - { - file->requestContent(); - - if (scrollTo) - { - m_scrollToFile = file; - m_scrollToLocationId = locationId; - } - } - else - { - scrollToLocation(file, locationId, scrollTo); - } -} - void QtCodeFileList::requestFileContent(const FilePath& filePath) { getFile(filePath)->requestContent(); @@ -123,65 +93,6 @@ void QtCodeFileList::showContents() } } -void QtCodeFileList::scrollToLocation(QtCodeFile* file, Id locationId, bool scrollTo) -{ - QtCodeSnippet* snippet = nullptr; - - if (locationId) - { - snippet = file->getSnippetForLocationId(locationId); - } - else - { - snippet = file->getFileSnippet(); - } - - if (!snippet) - { - return; - } - - if (!snippet->isVisible()) - { - file->setSnippets(); - } - - if (scrollTo) - { - if (locationId) - { - emit shouldScrollToSnippet(snippet, snippet->getLineNumberForLocationId(locationId)); - } - else - { - emit shouldScrollToSnippet(snippet, 1); - } - } -} - -void QtCodeFileList::scrollToLine(std::string filename, unsigned int line) -{ - for (std::shared_ptr file: m_files) - { - if (filename == file->getFilePath().str()) - { - emit shouldScrollToSnippet(file->getFileSnippet(), line); - return; - } - } -} - -void QtCodeFileList::scrollToSnippetIfRequested() -{ - if (m_scrollToFile && m_scrollToFile->hasSnippets()) - { - scrollToLocation(m_scrollToFile, m_scrollToLocationId, true); - - m_scrollToFile = nullptr; - m_scrollToLocationId = 0; - } -} - QtCodeFile* QtCodeFileList::getFile(const FilePath filePath) { QtCodeFile* file = nullptr; diff --git a/src/lib_gui/qt/element/QtCodeFileList.h b/src/lib_gui/qt/element/QtCodeFileList.h index e385cdc3..9ddeeab1 100644 --- a/src/lib_gui/qt/element/QtCodeFileList.h +++ b/src/lib_gui/qt/element/QtCodeFileList.h @@ -23,9 +23,6 @@ class QtCodeFileList { Q_OBJECT -signals: - void shouldScrollToSnippet(QtCodeSnippet* widget, uint lineNumber); - public: QtCodeFileList(QtCodeNavigator* navigator); virtual ~QtCodeFileList(); @@ -35,8 +32,6 @@ public: void clearCodeSnippets(); - void showLocation(const FilePath& filePath, Id locationId, bool scrollTo); - void requestFileContent(const FilePath& filePath); void setFileMinimized(const FilePath path); @@ -46,12 +41,9 @@ public: void updateFiles(); void showContents(); - void scrollToLocation(QtCodeFile* file, Id locationId, bool scrollTo); - void scrollToLine(std::string filename, unsigned int line); - void scrollToSnippetIfRequested(); + QtCodeFile* getFile(const FilePath filePath); private: - QtCodeFile* getFile(const FilePath filePath); QtCodeSnippet* getFirstActiveSnippet() const; void expandActiveSnippetFile(bool scrollTo); @@ -59,9 +51,6 @@ private: QtCodeNavigator* m_navigator; std::vector> m_files; - - QtCodeFile* m_scrollToFile; - Id m_scrollToLocationId; }; #endif // QT_CODE_FILE_LIST diff --git a/src/lib_gui/qt/element/QtCodeNavigator.cpp b/src/lib_gui/qt/element/QtCodeNavigator.cpp index 364ff05b..43cd035a 100644 --- a/src/lib_gui/qt/element/QtCodeNavigator.cpp +++ b/src/lib_gui/qt/element/QtCodeNavigator.cpp @@ -15,6 +15,7 @@ #include "utility/messaging/type/MessageScrollCode.h" #include "utility/messaging/type/MessageShowReference.h" +#include "qt/element/QtCodeFile.h" #include "qt/element/QtCodeSnippet.h" QtCodeNavigator::QtCodeNavigator(QWidget* parent) @@ -22,6 +23,9 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent) , m_switchReferenceFunctor(std::bind(&QtCodeNavigator::doSwitchReference, this, std::placeholders::_1)) , m_value(0) , m_refIndex(0) + , m_scrollToFile(nullptr) + , m_scrollToLine(0) + , m_scrollToLocationId(0) { QVBoxLayout* layout = new QVBoxLayout(); layout->setSpacing(0); @@ -77,7 +81,7 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent) m_scrollArea->setWidget(m_list); connect(m_scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrolled(int))); - connect(m_list, SIGNAL(shouldScrollToSnippet(QtCodeSnippet*, uint)), + connect(this, SIGNAL(shouldScrollToSnippet(QtCodeSnippet*, uint)), this, SLOT(scrollToSnippet(QtCodeSnippet*, uint)), Qt::QueuedConnection); } @@ -293,7 +297,7 @@ void QtCodeNavigator::showActiveSnippet( if (firstLocationId) { - m_list->showLocation(firstFilePath, firstLocationId, scrollTo); + showLocation(firstFilePath, firstLocationId, scrollTo); m_refIndex = 0; updateRefLabel(); @@ -358,20 +362,112 @@ void QtCodeNavigator::showContents() m_list->showContents(); } +void QtCodeNavigator::showLocation(const FilePath& filePath, Id locationId, bool scrollTo) +{ + updateFiles(); + + QtCodeFile* file = m_list->getFile(filePath); + + if (file->isCollapsed()) + { + file->requestContent(); + + if (scrollTo) + { + m_scrollToFile = file; + m_scrollToLocationId = locationId; + } + } + else + { + scrollToLocation(file, locationId, scrollTo); + } +} + void QtCodeNavigator::scrollToValue(int value) { m_value = value; QTimer::singleShot(100, this, SLOT(setValue())); } -void QtCodeNavigator::scrollToLine(std::string filename, unsigned int line) +void QtCodeNavigator::scrollToLine(const FilePath& filePath, unsigned int line) { - m_list->scrollToLine(filename, line); + QtCodeFile* file = m_list->getFile(filePath); + + if (!file) + { + return; + } + + if (file->isCollapsed()) + { + file->requestContent(); + + m_scrollToFile = file; + m_scrollToLine = line; + } + else if (file->getFileSnippet()) + { + emit shouldScrollToSnippet(file->getFileSnippet(), line); + } +} + +void QtCodeNavigator::scrollToLocation(QtCodeFile* file, Id locationId, bool scrollTo) +{ + QtCodeSnippet* snippet = nullptr; + + if (locationId) + { + snippet = file->getSnippetForLocationId(locationId); + } + else + { + snippet = file->getFileSnippet(); + } + + if (!snippet) + { + return; + } + + if (!snippet->isVisible()) + { + file->setSnippets(); + } + + if (scrollTo) + { + if (locationId) + { + emit shouldScrollToSnippet(snippet, snippet->getLineNumberForLocationId(locationId)); + } + else + { + emit shouldScrollToSnippet(snippet, 1); + } + } } void QtCodeNavigator::scrollToSnippetIfRequested() { - m_list->scrollToSnippetIfRequested(); + if (m_scrollToFile && m_scrollToLine) + { + emit shouldScrollToSnippet(m_scrollToFile->getSnippetForLine(m_scrollToLine), m_scrollToLine); + } + else if (m_scrollToFile && m_scrollToFile->hasSnippets()) + { + scrollToLocation(m_scrollToFile, m_scrollToLocationId, true); + } + + m_scrollToFile = nullptr; + m_scrollToLocationId = 0; + m_scrollToLine = 0; +} + +void QtCodeNavigator::requestScrollToLine(QtCodeFile* file, unsigned int line) +{ + m_scrollToFile = file; + m_scrollToLine = line; } void QtCodeNavigator::scrolled(int value) @@ -433,7 +529,7 @@ void QtCodeNavigator::showCurrentReference() const Reference& ref = m_references[m_refIndex - 1]; setCurrentActiveLocationIds(std::vector(1, ref.locationId)); - m_list->showLocation(ref.filePath, ref.locationId, true); + showLocation(ref.filePath, ref.locationId, true); updateRefLabel(); diff --git a/src/lib_gui/qt/element/QtCodeNavigator.h b/src/lib_gui/qt/element/QtCodeNavigator.h index 08ad2829..36c74a1f 100644 --- a/src/lib_gui/qt/element/QtCodeNavigator.h +++ b/src/lib_gui/qt/element/QtCodeNavigator.h @@ -64,9 +64,17 @@ public: void updateFiles(); void showContents(); + void showLocation(const FilePath& filePath, Id locationId, bool scrollTo); + void scrollToValue(int value); - void scrollToLine(std::string filename, unsigned int line); + void scrollToLine(const FilePath& filePath, unsigned int line); + void scrollToLocation(QtCodeFile* file, Id locationId, bool scrollTo); + void scrollToSnippetIfRequested(); + void requestScrollToLine(QtCodeFile* file, unsigned int line); + +signals: + void shouldScrollToSnippet(QtCodeSnippet* widget, uint lineNumber); private slots: void scrolled(int value); @@ -113,6 +121,10 @@ private: std::vector m_references; size_t m_refIndex; + + QtCodeFile* m_scrollToFile; + uint m_scrollToLine; + Id m_scrollToLocationId; }; #endif // QT_CODE_NAVIGATOR_H diff --git a/src/lib_gui/qt/element/QtCodeSnippet.cpp b/src/lib_gui/qt/element/QtCodeSnippet.cpp index b77e4c0c..b95d7fc6 100644 --- a/src/lib_gui/qt/element/QtCodeSnippet.cpp +++ b/src/lib_gui/qt/element/QtCodeSnippet.cpp @@ -172,8 +172,6 @@ std::string QtCodeSnippet::getCode() const void QtCodeSnippet::clickedTitle() { - getFile()->setScrollToLine(getStartLineNumber()); - if (m_titleId > 0) { MessageShowScope(m_titleId, m_navigator->hasErrors()).dispatch(); @@ -182,14 +180,17 @@ void QtCodeSnippet::clickedTitle() { getFile()->clickedMaximizeButton(); } + + m_navigator->requestScrollToLine(getFile(), getStartLineNumber()); } void QtCodeSnippet::clickedFooter() { if (m_footerId > 0) { - getFile()->setScrollToLine(getEndLineNumber()); MessageShowScope(m_footerId, m_navigator->hasErrors()).dispatch(); + + m_navigator->requestScrollToLine(getFile(), getEndLineNumber()); } } diff --git a/src/lib_gui/qt/view/QtCodeView.cpp b/src/lib_gui/qt/view/QtCodeView.cpp index 79c15d3b..82939aff 100644 --- a/src/lib_gui/qt/view/QtCodeView.cpp +++ b/src/lib_gui/qt/view/QtCodeView.cpp @@ -16,7 +16,6 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout) , m_clearFunctor(std::bind(&QtCodeView::doClear, this)) , m_showCodeSnippetsFunctor(std::bind(&QtCodeView::doShowCodeSnippets, this, std::placeholders::_1, std::placeholders::_2)) , m_addCodeSnippetsFunctor(std::bind(&QtCodeView::doAddCodeSnippets, this, std::placeholders::_1, std::placeholders::_2)) - , m_showCodeFileFunctor(std::bind(&QtCodeView::doShowCodeFile, this, std::placeholders::_1)) , 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)) @@ -72,11 +71,6 @@ void QtCodeView::addCodeSnippets(const std::vector& snippets, m_addCodeSnippetsFunctor(snippets, insert); } -void QtCodeView::showCodeFile(const CodeSnippetParams& params) -{ - m_showCodeFileFunctor(params); -} - void QtCodeView::setFileState(const FilePath filePath, FileState state) { m_setFileStateFunctor(filePath, state); @@ -118,9 +112,9 @@ void QtCodeView::scrollToValue(int value) m_scrollToValueFunctor(value); } -void QtCodeView::scrollToLine(std::string filename, unsigned int line) +void QtCodeView::scrollToLine(const FilePath filePath, unsigned int line) { - m_scrollToLineFunctor(filename, line); + m_scrollToLineFunctor(filePath, line); } void QtCodeView::doRefreshView() @@ -173,11 +167,6 @@ void QtCodeView::doAddCodeSnippets(const std::vector& snippet m_widget->scrollToSnippetIfRequested(); } -void QtCodeView::doShowCodeFile(const CodeSnippetParams& params) -{ - m_widget->addCodeSnippet(params); -} - void QtCodeView::doSetFileState(const FilePath filePath, FileState state) { switch (state) @@ -192,6 +181,8 @@ void QtCodeView::doSetFileState(const FilePath filePath, FileState state) m_widget->setFileMaximized(filePath); break; } + + m_widget->scrollToSnippetIfRequested(); } void QtCodeView::doShowActiveSnippet( @@ -232,9 +223,9 @@ void QtCodeView::doScrollToValue(int value) m_widget->scrollToValue(value); } -void QtCodeView::doScrollToLine(std::string filename, unsigned int line) +void QtCodeView::doScrollToLine(const FilePath filePath, unsigned int line) { - m_widget->scrollToLine(filename, line); + m_widget->scrollToLine(filePath, line); } void QtCodeView::setStyleSheet() const diff --git a/src/lib_gui/qt/view/QtCodeView.h b/src/lib_gui/qt/view/QtCodeView.h index 198ff595..381f1955 100644 --- a/src/lib_gui/qt/view/QtCodeView.h +++ b/src/lib_gui/qt/view/QtCodeView.h @@ -32,7 +32,6 @@ public: virtual void showCodeSnippets(const std::vector& snippets, const std::vector& activeTokenIds); virtual void addCodeSnippets(const std::vector& snippets, bool insert); - virtual void showCodeFile(const CodeSnippetParams& params); virtual void setFileState(const FilePath filePath, FileState state); @@ -47,7 +46,7 @@ public: virtual void showContents(); virtual void scrollToValue(int value); - virtual void scrollToLine(std::string filename, unsigned int line); + virtual void scrollToLine(const FilePath filePath, unsigned int line); private: void doRefreshView(); @@ -55,7 +54,6 @@ private: void doShowCodeSnippets(const std::vector& snippets, const std::vector& activeTokenIds); void doAddCodeSnippets(const std::vector& snippets, bool insert); - void doShowCodeFile(const CodeSnippetParams& params); void doSetFileState(const FilePath filePath, FileState state); @@ -70,7 +68,7 @@ private: void doShowContents(); void doScrollToValue(int value); - void doScrollToLine(std::string filename, unsigned int line); + void doScrollToLine(const FilePath filePath, unsigned int line); void setStyleSheet() const; @@ -78,7 +76,6 @@ private: QtThreadedFunctor<> m_clearFunctor; QtThreadedFunctor&, const std::vector&> m_showCodeSnippetsFunctor; QtThreadedFunctor&, bool> m_addCodeSnippetsFunctor; - QtThreadedFunctor m_showCodeFileFunctor; QtThreadedFunctor m_setFileStateFunctor; QtThreadedFunctor&, std::shared_ptr, bool> m_doShowActiveSnippetFunctor; QtThreadedFunctor&> m_doShowActiveTokenIdsFunctor; @@ -87,7 +84,7 @@ private: QtThreadedFunctor<> m_defocusTokenIdsFunctor; QtThreadedFunctor<> m_showContentsFunctor; QtThreadedFunctor m_scrollToValueFunctor; - QtThreadedFunctor m_scrollToLineFunctor; + QtThreadedFunctor m_scrollToLineFunctor; QtCodeNavigator* m_widget;