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/Printable.h>
25 
26 #include <QPalette>
27 #include <QPrinter>
28 #include <QStringList>
29 #include <QThread>
30 #include <QWidget>
31 
32 QT_FORWARD_DECLARE_CLASS(QUndoStack)
33 
34 namespace quentier {
35 
36 QT_FORWARD_DECLARE_CLASS(Account)
37 QT_FORWARD_DECLARE_CLASS(LocalStorageManagerAsync)
38 QT_FORWARD_DECLARE_CLASS(NoteEditor)
39 QT_FORWARD_DECLARE_CLASS(SpellChecker)
40 
41 class QUENTIER_EXPORT INoteEditorBackend
42 {
43 public:
44  virtual ~INoteEditorBackend();
45 
46  virtual void initialize(
47  LocalStorageManagerAsync & localStorageManager,
48  SpellChecker & spellChecker, const Account & account,
49  QThread * pBackgroundJobsThread) = 0;
50 
51  virtual QObject * object() = 0; // provide QObject interface
52  virtual QWidget * widget() = 0; // provide QWidget interface
53 
54  virtual void setAccount(const Account & account) = 0;
55  virtual void setUndoStack(QUndoStack * pUndoStack) = 0;
56 
57  virtual void setInitialPageHtml(const QString & html) = 0;
58  virtual void setNoteNotFoundPageHtml(const QString & html) = 0;
59  virtual void setNoteDeletedPageHtml(const QString & html) = 0;
60  virtual void setNoteLoadingPageHtml(const QString & html) = 0;
61 
62  virtual bool isNoteLoaded() const = 0;
63  virtual qint64 idleTime() const = 0;
64 
65  virtual void convertToNote() = 0;
66  virtual void saveNoteToLocalStorage() = 0;
67  virtual void setNoteTitle(const QString & noteTitle) = 0;
68 
69  virtual void setTagIds(
70  const QStringList & tagLocalUids, const QStringList & tagGuids) = 0;
71 
72  virtual void undo() = 0;
73  virtual void redo() = 0;
74  virtual void cut() = 0;
75  virtual void copy() = 0;
76  virtual void paste() = 0;
77  virtual void pasteUnformatted() = 0;
78  virtual void selectAll() = 0;
79 
80  virtual void formatSelectionAsSourceCode() = 0;
81 
82  virtual void fontMenu() = 0;
83  virtual void textBold() = 0;
84  virtual void textItalic() = 0;
85  virtual void textUnderline() = 0;
86  virtual void textStrikethrough() = 0;
87  virtual void textHighlight() = 0;
88 
89  virtual void alignLeft() = 0;
90  virtual void alignCenter() = 0;
91  virtual void alignRight() = 0;
92  virtual void alignFull() = 0;
93 
94  virtual QString selectedText() const = 0;
95  virtual bool hasSelection() const = 0;
96 
97  virtual void findNext(const QString & text, const bool matchCase) const = 0;
98 
99  virtual void findPrevious(
100  const QString & text, const bool matchCase) const = 0;
101 
102  virtual void replace(
103  const QString & textToReplace, const QString & replacementText,
104  const bool matchCase) = 0;
105 
106  virtual void replaceAll(
107  const QString & textToReplace, const QString & replacementText,
108  const 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(const bool enabled) = 0;
117  virtual bool spellCheckEnabled() const = 0;
118 
119  virtual void setFont(const QFont & font) = 0;
120  virtual void setFontHeight(const int height) = 0;
121  virtual void setFontColor(const QColor & color) = 0;
122  virtual void setBackgroundColor(const QColor & color) = 0;
123 
124  virtual QPalette defaultPalette() const = 0;
125  virtual void setDefaultPalette(const QPalette & pal) = 0;
126 
127  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  const int rows, const int columns, const int widthInPixels) = 0;
145 
146  virtual void insertRelativeWidthTable(
147  const int rows, const int columns, const 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 = 0,
169  Counterclockwise
170  };
171 
172  friend QUENTIER_EXPORT QTextStream & operator<<(
173  QTextStream & strm, const Rotation rotation);
174 
175  friend QUENTIER_EXPORT QDebug & operator<<(
176  QDebug & dbg, const Rotation rotation);
177 
178  virtual void rotateImageAttachment(
179  const QByteArray & resourceHash, const Rotation rotationDirection) = 0;
180 
181  virtual void rotateImageAttachmentUnderCursor(
182  const Rotation rotationDirection) = 0;
183 
184  virtual void encryptSelectedText() = 0;
185 
186  virtual void decryptEncryptedTextUnderCursor() = 0;
187 
188  virtual void decryptEncryptedText(
189  QString encryptedText, QString cipher, QString keyLength, QString hint,
190  QString enCryptIndex) = 0;
191 
192  virtual void hideDecryptedTextUnderCursor() = 0;
193 
194  virtual void hideDecryptedText(
195  QString encryptedText, QString decryptedText, QString cipher,
196  QString keyLength, QString hint, QString enDecryptedIndex) = 0;
197 
198  virtual void editHyperlinkDialog() = 0;
199  virtual void copyHyperlink() = 0;
200  virtual void removeHyperlink() = 0;
201 
202  virtual void onNoteLoadCancelled() = 0;
203 
204  virtual bool print(QPrinter & printer, ErrorString & errorDescription) = 0;
205 
206  virtual bool exportToPdf(
207  const QString & absoluteFilePath, ErrorString & errorDescription) = 0;
208 
209  virtual bool exportToEnex(
210  const QStringList & tagNames, QString & enex,
211  ErrorString & errorDescription) = 0;
212 
213  virtual QString currentNoteLocalUid() const = 0;
214  virtual void setCurrentNoteLocalUid(const QString & noteLocalUid) = 0;
215 
216  virtual void clear() = 0;
217 
218  virtual bool isModified() const = 0;
219  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
229 
230 #endif // LIB_QUENTIER_NOTE_EDITOR_I_NOTE_EDITOR_BACKEND_H
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition: Account.h:39
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:44
Definition: INoteEditorBackend.h:42
Definition: LocalStorageManagerAsync.h:44
The NoteEditor class is a widget encapsulating all the functionality necessary for showing and editin...
Definition: NoteEditor.h:46
Definition: SpellChecker.h:36