Warning, file /office/marknote/src/texteditor.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // SPDX-FileCopyrightText: 2023 Mathis BrĂ¼chert <mbb@kaidan.im>
0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003 
0004 #include "texteditor.h"
0005 
0006 #include <QQuickTextDocument>
0007 
0008 TextEditor::TextEditor(QObject *parent)
0009     : QObject(parent)
0010 {
0011 }
0012 
0013 QQuickTextDocument *TextEditor::document() const
0014 {
0015     return m_document;
0016 }
0017 
0018 void TextEditor::setDocument(QQuickTextDocument *document)
0019 {
0020     m_document = document;
0021 
0022     m_cursor = QTextCursor(document->textDocument());
0023 
0024     Q_EMIT documentChanged();
0025 }
0026 
0027 void TextEditor::makeSelectionItalic()
0028 {
0029 }
0030 
0031 void TextEditor::onCursorPositionChanged(int position)
0032 {
0033     m_cursor.setPosition(position);
0034 
0035     auto format = QTextBlockFormat();
0036     format.setHeadingLevel(1);
0037 
0038     auto charFormat = QTextCharFormat();
0039     charFormat.setFontWeight(30);
0040 
0041     // m_cursor.insertBlock(format);
0042     m_cursor.insertText("moin");
0043 }