diff --git a/src/kjotsedit.h b/src/kjotsedit.h --- a/src/kjotsedit.h +++ b/src/kjotsedit.h @@ -54,7 +54,6 @@ void mousePopupMenuImplementation(const QPoint &pos); void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); void tryDisableEditing(); - void onBookshelfSelection(void); void onAutoBullet(void); void onLinkify(void); void addCheckmark(void); diff --git a/src/kjotsedit.cpp b/src/kjotsedit.cpp --- a/src/kjotsedit.cpp +++ b/src/kjotsedit.cpp @@ -155,51 +155,6 @@ setReadOnly(false); } -void KJotsEdit::onBookshelfSelection(void) -{ - // TODO: PORT. Review and remove. Possibly keep the bug workaround. -#if 0 - QList selection = bookshelf->selectedItems(); - int selectionSize = selection.size(); - - if (selectionSize != 1) { - disableEditing(); - } else { - KJotsPage *newPage = dynamic_cast(selection[0]); - if (!newPage) { - disableEditing(); - } else { - setEnabled(newPage->isEditable()); - setReadOnly(!newPage->isEditable()); - if (currentPage != newPage) { - if (currentPage) { - currentPage->setCursor(textCursor()); - } - currentPage = newPage; - - setDocument(currentPage->body()); - if (!currentPage->getCursor().isNull()) { - setTextCursor(currentPage->getCursor()); - } - - QStackedWidget *stack = static_cast(parent()); - stack->setCurrentWidget(this); - setFocus(); - - if (textCursor().atStart()) { - // Reflect formatting when switching pages and the first word is formatted - // Work-around for qrextedit bug. The format does not seem to exist - // before the first character. Submitted to qt-bugs, id 192886. - moveCursor(QTextCursor::Right); - moveCursor(QTextCursor::Left); - } - - } - } - } -#endif -} - void KJotsEdit::onAutoBullet(void) { KTextEdit::AutoFormatting currentFormatting = autoFormatting(); diff --git a/src/kjotswidget.cpp b/src/kjotswidget.cpp --- a/src/kjotswidget.cpp +++ b/src/kjotswidget.cpp @@ -969,6 +969,13 @@ QTextCursor textCursor = document->property("textCursor").value(); if (!textCursor.isNull()) { editor->setTextCursor(textCursor); + } else { + // This is a work-around for QTextEdit bug. If the first letter of the document is formatted, + // QTextCursor doesn't follow this format. One can either move the cursor 1 symbol to the right + // and then 1 symbol to the left as a workaround, or just explicitly move it to the start. + // Submitted to qt-bugs, id 192886. + // -- (don't know the fate of this bug, as for April 2020 it is unaccessible) + editor->moveCursor(QTextCursor::Start); } stackedWidget->setCurrentWidget(editor); editor->setFocus();