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