Commit 2ab90078 authored by Kai Koehne's avatar Kai Koehne
Browse files

Center cursor when going from Design mode to text mode

Just use high level TextEditor::gotoLine instead of directly manipulating
the QTextCursor.

Task-number: BAUHAUS-326
parent d5284232
......@@ -311,14 +311,15 @@ void DocumentWidget::setAutoSynchronization(bool sync)
selectedNode = rewriter->selectedModelNodes().first();
if (selectedNode.isValid()) {
int nodeOffset = rewriter->nodeOffset(selectedNode);
QTextCursor editTextCursor = m_textBuffer->textCursor();
if (nodeOffset > 0
&& nodeForPosition(editTextCursor.position()) != selectedNode) {
if (debug)
qDebug() << "Moving text cursor to " << nodeOffset;
editTextCursor.setPosition(nodeOffset);
m_textBuffer->setTextCursor(editTextCursor);
const int nodeOffset = rewriter->nodeOffset(selectedNode);
if (nodeOffset > 0) {
const ModelNode currentSelectedNode
= nodeForPosition(m_textBuffer->textCursor().position());
if (currentSelectedNode != selectedNode) {
int line, column;
textEditor()->convertPosition(nodeOffset, &line, &column);
textEditor()->gotoLine(line, column);
}
}
}
}
......
Supports Markdown
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