libquentier  0.5.0
The library for rich desktop clients of Evernote service
INoteEditorBackend.h
1 /*
2  * Copyright 2016-2020 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 #ifndef LIB_QUENTIER_NOTE_EDITOR_I_NOTE_EDITOR_BACKEND_H
20 #define LIB_QUENTIER_NOTE_EDITOR_I_NOTE_EDITOR_BACKEND_H
21 
22 #include <quentier/types/Note.h>
23 #include <quentier/utility/Linkage.h>
24 #include <quentier/utility/Macros.h>
25 #include <quentier/utility/Printable.h>
26 
27 #include <QPalette>
28 #include <QPrinter>
29 #include <QStringList>
30 #include <QThread>
31 #include <QWidget>
32 
33 QT_FORWARD_DECLARE_CLASS(QUndoStack)
34 
35 namespace quentier {
36 
37 QT_FORWARD_DECLARE_CLASS(Account)
38 QT_FORWARD_DECLARE_CLASS(LocalStorageManagerAsync)
39 QT_FORWARD_DECLARE_CLASS(NoteEditor)
40 QT_FORWARD_DECLARE_CLASS(SpellChecker)
41 
42 class QUENTIER_EXPORT INoteEditorBackend
43 {
44 public:
45  virtual ~INoteEditorBackend();
46 
47  virtual void initialize(
48  LocalStorageManagerAsync & localStorageManager,
49  SpellChecker & spellChecker, const Account & account,
50  QThread * pBackgroundJobsThread) = 0;
51 
52  virtual QObject * object() = 0; // provide QObject interface
53  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  virtual bool isNoteLoaded() const = 0;
64  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,
72  const QStringList & tagGuids) = 0;
73 
74  virtual void undo() = 0;
75  virtual void redo() = 0;
76  virtual void cut() = 0;
77  virtual void copy() = 0;
78  virtual void paste() = 0;
79  virtual void pasteUnformatted() = 0;
80  virtual void selectAll() = 0;
81 
82  virtual void formatSelectionAsSourceCode() = 0;
83 
84  virtual void fontMenu() = 0;
85  virtual void textBold() = 0;
86  virtual void textItalic() = 0;
87  virtual void textUnderline() = 0;
88  virtual void textStrikethrough() = 0;
89  virtual void textHighlight() = 0;
90 
91  virtual void alignLeft() = 0;
92  virtual void alignCenter() = 0;
93  virtual void alignRight() = 0;
94  virtual void alignFull() = 0;
95 
96  virtual QString selectedText() const = 0;
97  virtual bool hasSelection() const = 0;
98 
99  virtual void findNext(const QString & text, const bool matchCase) const = 0;
100 
101  virtual void findPrevious(
102  const QString & text, const bool matchCase) const = 0;
103 
104  virtual void replace(
105  const QString & textToReplace, const QString & replacementText,
106  const bool matchCase) = 0;
107 
108  virtual void replaceAll(
109  const QString & textToReplace, const QString & replacementText,
110  const bool matchCase) = 0;
111 
112  virtual void insertToDoCheckbox() = 0;
113 
114  virtual void insertInAppNoteLink(
115  const QString & userId, const QString & shardId,
116  const QString & noteGuid, const QString & linkText) = 0;
117 
118  virtual void setSpellcheck(const bool enabled) = 0;
119  virtual bool spellCheckEnabled() const = 0;
120 
121  virtual void setFont(const QFont & font) = 0;
122  virtual void setFontHeight(const int height) = 0;
123  virtual void setFontColor(const QColor & color) = 0;
124  virtual void setBackgroundColor(const QColor & color) = 0;
125 
126  virtual QPalette defaultPalette() const = 0;
127  virtual void setDefaultPalette(const QPalette & pal) = 0;
128 
129  virtual const QFont * defaultFont() const = 0;
130  virtual void setDefaultFont(const QFont & font) = 0;
131 
132  virtual void insertHorizontalLine() = 0;
133 
134  virtual void increaseFontSize() = 0;
135  virtual void decreaseFontSize() = 0;
136 
137  virtual void increaseIndentation() = 0;
138  virtual void decreaseIndentation() = 0;
139 
140  virtual void insertBulletedList() = 0;
141  virtual void insertNumberedList() = 0;
142 
143  virtual void insertTableDialog() = 0;
144 
145  virtual void insertFixedWidthTable(
146  const int rows, const int columns, const int widthInPixels) = 0;
147 
148  virtual void insertRelativeWidthTable(
149  const int rows, const int columns, const double relativeWidth) = 0;
150 
151  virtual void insertTableRow() = 0;
152  virtual void insertTableColumn() = 0;
153  virtual void removeTableRow() = 0;
154  virtual void removeTableColumn() = 0;
155 
156  virtual void addAttachmentDialog() = 0;
157  virtual void saveAttachmentDialog(const QByteArray & resourceHash) = 0;
158  virtual void saveAttachmentUnderCursor() = 0;
159  virtual void openAttachment(const QByteArray & resourceHash) = 0;
160  virtual void openAttachmentUnderCursor() = 0;
161  virtual void copyAttachment(const QByteArray & resourceHash) = 0;
162  virtual void copyAttachmentUnderCursor() = 0;
163  virtual void removeAttachment(const QByteArray & resourceHash) = 0;
164  virtual void removeAttachmentUnderCursor() = 0;
165  virtual void renameAttachment(const QByteArray & resourceHash) = 0;
166  virtual void renameAttachmentUnderCursor() = 0;
167 
168  enum class Rotation
169  {
170  Clockwise = 0,
171  Counterclockwise
172  };
173 
174  friend QUENTIER_EXPORT QTextStream & operator<<(
175  QTextStream & strm, const Rotation rotation);
176 
177  friend QUENTIER_EXPORT QDebug & operator<<(
178  QDebug & dbg, const Rotation rotation);
179 
180  virtual void rotateImageAttachment(
181  const QByteArray & resourceHash,
182  const Rotation rotationDirection) = 0;
183 
184  virtual void rotateImageAttachmentUnderCursor(
185  const Rotation rotationDirection) = 0;
186 
187  virtual void encryptSelectedText() = 0;
188 
189  virtual void decryptEncryptedTextUnderCursor() = 0;
190 
191  virtual void decryptEncryptedText(
192  QString encryptedText, QString cipher, QString keyLength, QString hint,
193  QString enCryptIndex) = 0;
194 
195  virtual void hideDecryptedTextUnderCursor() = 0;
196 
197  virtual void hideDecryptedText(
198  QString encryptedText, QString decryptedText, QString cipher,
199  QString keyLength, QString hint, QString enDecryptedIndex) = 0;
200 
201  virtual void editHyperlinkDialog() = 0;
202  virtual void copyHyperlink() = 0;
203  virtual void removeHyperlink() = 0;
204 
205  virtual void onNoteLoadCancelled() = 0;
206 
207  virtual bool print(QPrinter & printer, ErrorString & errorDescription) = 0;
208 
209  virtual bool exportToPdf(
210  const QString & absoluteFilePath, ErrorString & errorDescription) = 0;
211 
212  virtual bool exportToEnex(
213  const QStringList & tagNames, QString & enex,
214  ErrorString & errorDescription) = 0;
215 
216  virtual QString currentNoteLocalUid() const = 0;
217  virtual void setCurrentNoteLocalUid(const QString & noteLocalUid) = 0;
218 
219  virtual void clear() = 0;
220 
221  virtual bool isModified() const = 0;
222  virtual bool isEditorPageModified() const = 0;
223 
224  virtual void setFocusToEditor() = 0;
225 
226 protected:
227  INoteEditorBackend(NoteEditor * parent);
228  NoteEditor * m_pNoteEditor;
229 };
230 
231 } // namespace quentier
232 
233 #endif // LIB_QUENTIER_NOTE_EDITOR_I_NOTE_EDITOR_BACKEND_H
Definition: INoteEditorBackend.h:42
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:43
Definition: LocalStorageManagerAsync.h:44
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition: Account.h:39
Definition: SpellChecker.h:36
The NoteEditor class is a widget encapsulating all the functionality necessary for showing and editin...
Definition: NoteEditor.h:46