libquentier  0.8.0
The library for rich desktop clients of Evernote service
INoteEditorBackend.h
1 /*
2  * Copyright 2016-2025 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <quentier/enml/Fwd.h>
22 #include <quentier/local_storage/Fwd.h>
23 #include <quentier/utility/Linkage.h>
24 
25 #include <QPalette>
26 #include <QPrinter>
27 #include <QStringList>
28 #include <QThread>
29 #include <QWidget>
30 
31 class QTextStream;
32 class QUndoStack;
33 
34 namespace quentier {
35 
36 class Account;
37 class ErrorString;
38 class NoteEditor;
39 class SpellChecker;
40 
41 class QUENTIER_EXPORT INoteEditorBackend
42 {
43 public:
44  virtual ~INoteEditorBackend() noexcept;
45 
46  virtual void initialize(
47  local_storage::ILocalStoragePtr localStorage,
48  SpellChecker & spellChecker, const Account & account,
49  QThread * backgroundJobsThread,
50  enml::IDecryptedTextCachePtr decryptedTextCache) = 0;
51 
52  [[nodiscard]] virtual QObject * object() = 0; // provide QObject interface
53  [[nodiscard]] virtual QWidget * widget() = 0; // provide QWidget interface
54 
55  virtual void setAccount(const Account & account) = 0;
56  virtual void setUndoStack(QUndoStack * pUndoStack) = 0;
57 
58  virtual void setInitialPageHtml(const QString & html) = 0;
59  virtual void setNoteNotFoundPageHtml(const QString & html) = 0;
60  virtual void setNoteDeletedPageHtml(const QString & html) = 0;
61  virtual void setNoteLoadingPageHtml(const QString & html) = 0;
62 
63  [[nodiscard]] virtual bool isNoteLoaded() const = 0;
64  [[nodiscard]] virtual qint64 idleTime() const = 0;
65 
66  virtual void convertToNote() = 0;
67  virtual void saveNoteToLocalStorage() = 0;
68  virtual void setNoteTitle(const QString & noteTitle) = 0;
69 
70  virtual void setTagIds(
71  const QStringList & tagLocalUids, const QStringList & tagGuids) = 0;
72 
73  virtual void undo() = 0;
74  virtual void redo() = 0;
75  virtual void cut() = 0;
76  virtual void copy() = 0;
77  virtual void paste() = 0;
78  virtual void pasteUnformatted() = 0;
79  virtual void selectAll() = 0;
80 
81  virtual void formatSelectionAsSourceCode() = 0;
82 
83  virtual void fontMenu() = 0;
84  virtual void textBold() = 0;
85  virtual void textItalic() = 0;
86  virtual void textUnderline() = 0;
87  virtual void textStrikethrough() = 0;
88  virtual void textHighlight() = 0;
89 
90  virtual void alignLeft() = 0;
91  virtual void alignCenter() = 0;
92  virtual void alignRight() = 0;
93  virtual void alignFull() = 0;
94 
95  [[nodiscard]] virtual QString selectedText() const = 0;
96  [[nodiscard]] virtual bool hasSelection() const = 0;
97 
98  virtual void findNext(const QString & text, bool matchCase) const = 0;
99 
100  virtual void findPrevious(const QString & text, bool matchCase) const = 0;
101 
102  virtual void replace(
103  const QString & textToReplace, const QString & replacementText,
104  bool matchCase) = 0;
105 
106  virtual void replaceAll(
107  const QString & textToReplace, const QString & replacementText,
108  bool matchCase) = 0;
109 
110  virtual void insertToDoCheckbox() = 0;
111 
112  virtual void insertInAppNoteLink(
113  const QString & userId, const QString & shardId,
114  const QString & noteGuid, const QString & linkText) = 0;
115 
116  virtual void setSpellcheck(bool enabled) = 0;
117  [[nodiscard]] virtual bool spellCheckEnabled() const = 0;
118 
119  virtual void setFont(const QFont & font) = 0;
120  virtual void setFontHeight(int height) = 0;
121  virtual void setFontColor(const QColor & color) = 0;
122  virtual void setBackgroundColor(const QColor & color) = 0;
123 
124  [[nodiscard]] virtual QPalette defaultPalette() const = 0;
125  virtual void setDefaultPalette(const QPalette & pal) = 0;
126 
127  [[nodiscard]] virtual const QFont * defaultFont() const = 0;
128  virtual void setDefaultFont(const QFont & font) = 0;
129 
130  virtual void insertHorizontalLine() = 0;
131 
132  virtual void increaseFontSize() = 0;
133  virtual void decreaseFontSize() = 0;
134 
135  virtual void increaseIndentation() = 0;
136  virtual void decreaseIndentation() = 0;
137 
138  virtual void insertBulletedList() = 0;
139  virtual void insertNumberedList() = 0;
140 
141  virtual void insertTableDialog() = 0;
142 
143  virtual void insertFixedWidthTable(
144  int rows, int columns, int widthInPixels) = 0;
145 
146  virtual void insertRelativeWidthTable(
147  int rows, int columns, double relativeWidth) = 0;
148 
149  virtual void insertTableRow() = 0;
150  virtual void insertTableColumn() = 0;
151  virtual void removeTableRow() = 0;
152  virtual void removeTableColumn() = 0;
153 
154  virtual void addAttachmentDialog() = 0;
155  virtual void saveAttachmentDialog(const QByteArray & resourceHash) = 0;
156  virtual void saveAttachmentUnderCursor() = 0;
157  virtual void openAttachment(const QByteArray & resourceHash) = 0;
158  virtual void openAttachmentUnderCursor() = 0;
159  virtual void copyAttachment(const QByteArray & resourceHash) = 0;
160  virtual void copyAttachmentUnderCursor() = 0;
161  virtual void removeAttachment(const QByteArray & resourceHash) = 0;
162  virtual void removeAttachmentUnderCursor() = 0;
163  virtual void renameAttachment(const QByteArray & resourceHash) = 0;
164  virtual void renameAttachmentUnderCursor() = 0;
165 
166  enum class Rotation
167  {
168  Clockwise,
169  Counterclockwise
170  };
171 
172  friend QUENTIER_EXPORT QTextStream & operator<<(
173  QTextStream & strm, Rotation rotation);
174 
175  friend QUENTIER_EXPORT QDebug & operator<<(QDebug & dbg, Rotation rotation);
176 
177  virtual void rotateImageAttachment(
178  const QByteArray & resourceHash, Rotation rotationDirection) = 0;
179 
180  virtual void rotateImageAttachmentUnderCursor(
181  Rotation rotationDirection) = 0;
182 
183  virtual void encryptSelectedText() = 0;
184 
185  virtual void decryptEncryptedTextUnderCursor() = 0;
186 
187  virtual void decryptEncryptedText(
188  QString encryptedText, QString cipher, QString hint,
189  QString enCryptIndex) = 0;
190 
191  virtual void hideDecryptedTextUnderCursor() = 0;
192 
193  virtual void hideDecryptedText(
194  QString encryptedText, QString decryptedText, QString cipher,
195  QString hint, QString enDecryptedIndex) = 0;
196 
197  virtual void editHyperlinkDialog() = 0;
198  virtual void copyHyperlink() = 0;
199  virtual void removeHyperlink() = 0;
200 
201  virtual void onNoteLoadCancelled() = 0;
202 
203  [[nodiscard]] virtual bool print(
204  QPrinter & printer, ErrorString & errorDescription) = 0;
205 
206  [[nodiscard]] virtual bool exportToPdf(
207  const QString & absoluteFilePath, ErrorString & errorDescription) = 0;
208 
209  [[nodiscard]] virtual bool exportToEnex(
210  const QStringList & tagNames, QString & enex,
211  ErrorString & errorDescription) = 0;
212 
213  [[nodiscard]] virtual QString currentNoteLocalId() const = 0;
214  virtual void setCurrentNoteLocalId(const QString & noteLocalUid) = 0;
215 
216  virtual void clear() = 0;
217 
218  [[nodiscard]] virtual bool isModified() const = 0;
219  [[nodiscard]] virtual bool isEditorPageModified() const = 0;
220 
221  virtual void setFocusToEditor() = 0;
222 
223 protected:
224  INoteEditorBackend(NoteEditor * parent);
225  NoteEditor * m_pNoteEditor;
226 };
227 
228 } // namespace quentier
Definition: INoteEditorBackend.h:41
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:42
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition: Account.h:37
Definition: SpellChecker.h:35
The NoteEditor class is a widget encapsulating all the functionality necessary for showing and editin...
Definition: NoteEditor.h:46