logic: scroll code when no symbol
Scrolling to line, when comming from plugin and the file is was modified. Since there we dont know from the position data if the symbol on position is the right one, we scroll to the line if modified.
This commit is contained in:
@@ -264,6 +264,11 @@ QtCodeSnippet* QtCodeFile::insertCodeSnippet(const CodeSnippetParams& params)
|
||||
return snippet.get();
|
||||
}
|
||||
|
||||
QtCodeSnippet* QtCodeFile::getFileSnippet() const
|
||||
{
|
||||
return m_fileSnippet.get();
|
||||
}
|
||||
|
||||
QtCodeSnippet* QtCodeFile::findFirstActiveSnippet() const
|
||||
{
|
||||
if (m_locationFile)
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
QtCodeSnippet* insertCodeSnippet(const CodeSnippetParams& params);
|
||||
|
||||
QtCodeSnippet* findFirstActiveSnippet() const;
|
||||
QtCodeSnippet* getFileSnippet() const;
|
||||
bool isCollapsedActiveFile() const;
|
||||
|
||||
void updateContent();
|
||||
|
||||
@@ -225,6 +225,19 @@ void QtCodeFileList::showContents()
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFileList::scrollToLine(std::string filename, unsigned int line)
|
||||
{
|
||||
for (std::shared_ptr<QtCodeFile> file: m_files)
|
||||
{
|
||||
if( filename == file->getFilePath().str() )
|
||||
{
|
||||
emit shouldScrollToSnippet(file->getFileSnippet(), line);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QtCodeFileList::scrollToValue(int value)
|
||||
{
|
||||
m_value = value;
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
void updateFiles();
|
||||
void showContents();
|
||||
void scrollToValue(int value);
|
||||
void scrollToLine(std::string, unsigned int line);
|
||||
void scrollToActiveFileIfRequested();
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -43,7 +43,7 @@ void QtTcpWrapper::sendMessage(const std::string& message) const
|
||||
data.append(message.c_str());
|
||||
|
||||
QTcpSocket socket;
|
||||
socket.connectToHost(QHostAddress::LocalHost, 6666);
|
||||
socket.connectToHost(QHostAddress::LocalHost, m_clientPort);
|
||||
|
||||
if (socket.waitForConnected())
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout)
|
||||
, m_defocusTokenIdsFunctor(std::bind(&QtCodeView::doDefocusTokenIds, this))
|
||||
, m_showContentsFunctor(std::bind(&QtCodeView::doShowContents, this))
|
||||
, m_scrollToValueFunctor(std::bind(&QtCodeView::doScrollToValue, this, std::placeholders::_1))
|
||||
, m_scrollToLineFunctor(std::bind(&QtCodeView::doScrollToLine, this, std::placeholders::_1, std::placeholders::_2))
|
||||
{
|
||||
m_widget = new QtCodeFileList();
|
||||
setStyleSheet();
|
||||
@@ -121,6 +122,11 @@ void QtCodeView::scrollToValue(int value)
|
||||
m_scrollToValueFunctor(value);
|
||||
}
|
||||
|
||||
void QtCodeView::scrollToLine(std::string filename, unsigned int line)
|
||||
{
|
||||
m_scrollToLineFunctor(filename, line);
|
||||
}
|
||||
|
||||
void QtCodeView::doRefreshView()
|
||||
{
|
||||
setStyleSheet();
|
||||
@@ -232,6 +238,11 @@ void QtCodeView::doScrollToValue(int value)
|
||||
m_widget->scrollToValue(value);
|
||||
}
|
||||
|
||||
void QtCodeView::doScrollToLine(std::string filename, unsigned int line)
|
||||
{
|
||||
m_widget->scrollToLine(filename, line);
|
||||
}
|
||||
|
||||
void QtCodeView::setStyleSheet() const
|
||||
{
|
||||
utility::setWidgetBackgroundColor(m_widget, ColorScheme::getInstance()->getColor("code/background"));
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
virtual void showContents();
|
||||
|
||||
virtual void scrollToValue(int value);
|
||||
virtual void scrollToLine(std::string filename, unsigned int line);
|
||||
|
||||
private:
|
||||
void doRefreshView();
|
||||
@@ -68,6 +69,7 @@ private:
|
||||
void doShowContents();
|
||||
|
||||
void doScrollToValue(int value);
|
||||
void doScrollToLine(std::string filename, unsigned int line);
|
||||
|
||||
void setStyleSheet() const;
|
||||
|
||||
@@ -84,6 +86,7 @@ private:
|
||||
QtThreadedFunctor<> m_defocusTokenIdsFunctor;
|
||||
QtThreadedFunctor<> m_showContentsFunctor;
|
||||
QtThreadedFunctor<int> m_scrollToValueFunctor;
|
||||
QtThreadedFunctor<std::string, unsigned int> m_scrollToLineFunctor;
|
||||
|
||||
QtCodeFileList* m_widget;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user