libquentier  0.4.0
The library for rich desktop clients of Evernote service
INoteEditorBackend.h
1 /*
2  * Copyright 2016 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/utility/Macros.h>
23 #include <quentier/utility/Linkage.h>
24 #include <quentier/utility/Printable.h>
25 #include <quentier/types/Note.h>
26 #include <quentier/types/Notebook.h>
27 #include <QWidget>
28 #include <QPrinter>
29 #include <QStringList>
30 
31 QT_FORWARD_DECLARE_CLASS(QUndoStack)
32 
33 namespace quentier {
34 
35 QT_FORWARD_DECLARE_CLASS(Account)
36 QT_FORWARD_DECLARE_CLASS(NoteEditor)
37 QT_FORWARD_DECLARE_CLASS(FileIOProcessorAsync)
38 QT_FORWARD_DECLARE_CLASS(SpellChecker)
39 
40 class QUENTIER_EXPORT INoteEditorBackend
41 {
42 public:
43  virtual ~INoteEditorBackend();
44 
45  virtual void initialize(FileIOProcessorAsync & fileIOProcessorAsync,
46  SpellChecker & spellChecker,
47  const Account & account) = 0;
48 
49  virtual QObject * object() = 0; // provide QObject interface
50  virtual QWidget * widget() = 0; // provide QWidget interface
51 
52  virtual void setAccount(const Account & account) = 0;
53  virtual void setUndoStack(QUndoStack * pUndoStack) = 0;
54 
55  virtual void setBlankPageHtml(const QString & html) = 0;
56 
57  virtual bool isNoteLoaded() const = 0;
58 
59  virtual void convertToNote() = 0;
60  virtual void undo() = 0;
61  virtual void redo() = 0;
62  virtual void cut() = 0;
63  virtual void copy() = 0;
64  virtual void paste() = 0;
65  virtual void pasteUnformatted() = 0;
66  virtual void selectAll() = 0;
67 
68  virtual void formatSelectionAsSourceCode() = 0;
69 
70  virtual void fontMenu() = 0;
71  virtual void textBold() = 0;
72  virtual void textItalic() = 0;
73  virtual void textUnderline() = 0;
74  virtual void textStrikethrough() = 0;
75  virtual void textHighlight() = 0;
76 
77  virtual void alignLeft() = 0;
78  virtual void alignCenter() = 0;
79  virtual void alignRight() = 0;
80  virtual void alignFull() = 0;
81 
82  virtual QString selectedText() const = 0;
83  virtual bool hasSelection() const = 0;
84 
85  virtual void findNext(const QString & text, const bool matchCase) const = 0;
86  virtual void findPrevious(const QString & text, const bool matchCase) const = 0;
87  virtual void replace(const QString & textToReplace, const QString & replacementText, const bool matchCase) = 0;
88  virtual void replaceAll(const QString & textToReplace, const QString & replacementText, const bool matchCase) = 0;
89 
90  virtual void insertToDoCheckbox() = 0;
91 
92  virtual void insertInAppNoteLink(const QString & userId, const QString & shardId,
93  const QString & noteGuid, const QString & linkText) = 0;
94 
95  virtual void setSpellcheck(const bool enabled) = 0;
96  virtual bool spellCheckEnabled() const = 0;
97 
98  virtual void setFont(const QFont & font) = 0;
99  virtual void setFontHeight(const int height) = 0;
100  virtual void setFontColor(const QColor & color) = 0;
101  virtual void setBackgroundColor(const QColor & color) = 0;
102 
103  virtual void insertHorizontalLine() = 0;
104 
105  virtual void increaseFontSize() = 0;
106  virtual void decreaseFontSize() = 0;
107 
108  virtual void increaseIndentation() = 0;
109  virtual void decreaseIndentation() = 0;
110 
111  virtual void insertBulletedList() = 0;
112  virtual void insertNumberedList() = 0;
113 
114  virtual void insertTableDialog() = 0;
115  virtual void insertFixedWidthTable(const int rows, const int columns, const int widthInPixels) = 0;
116  virtual void insertRelativeWidthTable(const int rows, const int columns, const double relativeWidth) = 0;
117  virtual void insertTableRow() = 0;
118  virtual void insertTableColumn() = 0;
119  virtual void removeTableRow() = 0;
120  virtual void removeTableColumn() = 0;
121 
122  virtual void addAttachmentDialog() = 0;
123  virtual void saveAttachmentDialog(const QByteArray & resourceHash) = 0;
124  virtual void saveAttachmentUnderCursor() = 0;
125  virtual void openAttachment(const QByteArray & resourceHash) = 0;
126  virtual void openAttachmentUnderCursor() = 0;
127  virtual void copyAttachment(const QByteArray & resourceHash) = 0;
128  virtual void copyAttachmentUnderCursor() = 0;
129  virtual void removeAttachment(const QByteArray & resourceHash) = 0;
130  virtual void removeAttachmentUnderCursor() = 0;
131  virtual void renameAttachment(const QByteArray & resourceHash) = 0;
132  virtual void renameAttachmentUnderCursor() = 0;
133 
134  struct Rotation
135  {
136  enum type
137  {
138  Clockwise = 0,
139  Counterclockwise
140  };
141 
142  friend QTextStream & operator<<(QTextStream & strm, const type & rotation);
143  };
144 
145  virtual void rotateImageAttachment(const QByteArray & resourceHash, const Rotation::type rotationDirection) = 0;
146  virtual void rotateImageAttachmentUnderCursor(const Rotation::type rotationDirection) = 0;
147 
148  virtual void encryptSelectedText() = 0;
149 
150  virtual void decryptEncryptedTextUnderCursor() = 0;
151  virtual void decryptEncryptedText(QString encryptedText, QString cipher, QString keyLength, QString hint, QString enCryptIndex) = 0;
152 
153  virtual void hideDecryptedTextUnderCursor() = 0;
154  virtual void hideDecryptedText(QString encryptedText, QString decryptedText, QString cipher, QString keyLength, QString hint, QString enDecryptedIndex) = 0;
155 
156  virtual void editHyperlinkDialog() = 0;
157  virtual void copyHyperlink() = 0;
158  virtual void removeHyperlink() = 0;
159 
160  virtual void onNoteLoadCancelled() = 0;
161 
162  virtual bool print(QPrinter & printer, ErrorString & errorDescription) = 0;
163  virtual bool exportToPdf(const QString & absoluteFilePath, ErrorString & errorDescription) = 0;
164  virtual bool exportToEnex(const QStringList & tagNames,
165  QString & enex, ErrorString & errorDescription) = 0;
166 
167  virtual void setNoteAndNotebook(const Note & note, const Notebook & notebook) = 0;
168 
169  virtual void clear() = 0;
170 
171  virtual bool isModified() const = 0;
172 
173  virtual void setFocusToEditor() = 0;
174 
175 protected:
176  INoteEditorBackend(NoteEditor * parent);
177  NoteEditor * m_pNoteEditor;
178 };
179 
180 } // namespace quentier
181 
182 #endif // LIB_QUENTIER_NOTE_EDITOR_I_NOTE_EDITOR_BACKEND_H
Definition: INoteEditorBackend.h:40
The FileIOProcessorAsync class is a wrapper under simple file IO operations, it is meant to be used f...
Definition: FileIOProcessorAsync.h:39
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:38
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition: Account.h:24
Definition: Notebook.h:38
Definition: SpellChecker.h:34
Definition: Note.h:38
The NoteEditor class is a widget encapsulating all the functionality necessary for showing and editin...
Definition: NoteEditor.h:43
Definition: INoteEditorBackend.h:134