Commit cc7cf429 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Project: Use signal to save jumps in location history


Signed-off-by: Waqar Ahmed's avatarWaqar Ahmed <waqar.17a@gmail.com>
parent b79f2048
......@@ -124,6 +124,15 @@ void KateProjectInfoViewIndex::slotClicked(const QModelIndex &index)
return;
}
/** Save current position before jumping **/
auto currentView = m_pluginView->mainWindow()->activeView();
QUrl url;
KTextEditor::Cursor pos;
if (currentView) {
url = currentView->document()->url();
pos = currentView->cursorPosition();
}
/**
* create view
*/
......@@ -132,12 +141,18 @@ void KateProjectInfoViewIndex::slotClicked(const QModelIndex &index)
return;
}
/** save current position in location history */
Q_EMIT m_pluginView->posChanged(url, pos);
/**
* set cursor, if possible
*/
int line = m_model->item(index.row(), 3)->text().toInt();
if (line >= 1) {
view->setCursorPosition(KTextEditor::Cursor(line - 1, 0));
/** save the jump position in location history */
Q_EMIT m_pluginView->posChanged(view->document()->url(), {line - 1, 0});
}
}
......
......@@ -222,6 +222,14 @@ Q_SIGNALS:
*/
void message(const QVariantMap &message);
/**
* Signal for location changed. Location gets saved in history
* of the current KateViewSpace
* @param document url
* @param c pos in document
*/
void posChanged(const QUrl &url, KTextEditor::Cursor c);
private Q_SLOTS:
/**
* This slot is called whenever the active view changes in our main window.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment