Changeset View
Changeset View
Standalone View
Standalone View
applets/notes/plugin/documenthandler.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | * at which point we should delete this | 44 | * at which point we should delete this | ||
45 | */ | 45 | */ | ||
46 | 46 | | |||
47 | #include "documenthandler.h" | 47 | #include "documenthandler.h" | ||
48 | 48 | | |||
49 | #include <QTextDocument> | 49 | #include <QTextDocument> | ||
50 | #include <QTextCursor> | 50 | #include <QTextCursor> | ||
51 | #include <QFontDatabase> | 51 | #include <QFontDatabase> | ||
52 | #include <QGuiApplication> | ||||
53 | #include <QMimeData> | ||||
54 | #include <QClipboard> | ||||
52 | 55 | | |||
53 | DocumentHandler::DocumentHandler() | 56 | DocumentHandler::DocumentHandler() | ||
54 | : m_target(nullptr) | 57 | : m_target(nullptr) | ||
55 | , m_doc(nullptr) | 58 | , m_doc(nullptr) | ||
56 | , m_cursorPosition(-1) | 59 | , m_cursorPosition(-1) | ||
57 | , m_selectionStart(0) | 60 | , m_selectionStart(0) | ||
58 | , m_selectionEnd(0) | 61 | , m_selectionEnd(0) | ||
59 | { | 62 | { | ||
Show All 23 Lines | |||||
83 | void DocumentHandler::setDocumentTitle(QString arg) | 86 | void DocumentHandler::setDocumentTitle(QString arg) | ||
84 | { | 87 | { | ||
85 | if (m_documentTitle != arg) { | 88 | if (m_documentTitle != arg) { | ||
86 | m_documentTitle = arg; | 89 | m_documentTitle = arg; | ||
87 | emit documentTitleChanged(); | 90 | emit documentTitleChanged(); | ||
88 | } | 91 | } | ||
89 | } | 92 | } | ||
90 | 93 | | |||
94 | void DocumentHandler::pasteWithoutFormatting() | ||||
davidedmundson: This could benefit from a name to explain the difference from the regular text edit paste. | |||||
95 | { | ||||
96 | QTextCursor cursor = textCursor(); | ||||
97 | if (cursor.isNull()) | ||||
98 | return; | ||||
99 | | ||||
100 | QClipboard *clipboard = QGuiApplication::clipboard(); | ||||
101 | if (!clipboard) | ||||
102 | return; | ||||
103 | | ||||
104 | const QMimeData *mimeData = clipboard->mimeData(); | ||||
105 | if (!mimeData) | ||||
106 | return; | ||||
107 | | ||||
108 | QString content = mimeData->text(); | ||||
109 | cursor.insertText(content, QTextCharFormat()); | ||||
110 | } | ||||
111 | | ||||
91 | void DocumentHandler::setText(const QString &arg) | 112 | void DocumentHandler::setText(const QString &arg) | ||
92 | { | 113 | { | ||
93 | if (m_text != arg) { | 114 | if (m_text != arg) { | ||
94 | m_text = arg; | 115 | m_text = arg; | ||
95 | emit textChanged(); | 116 | emit textChanged(); | ||
96 | } | 117 | } | ||
97 | } | 118 | } | ||
98 | 119 | | |||
▲ Show 20 Lines • Show All 213 Lines • Show Last 20 Lines |
This could benefit from a name to explain the difference from the regular text edit paste.