libquentier  0.4.0
The library for rich desktop clients of Evernote service
NoteEditor.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_NOTE_EDITOR_H
20 #define LIB_QUENTIER_NOTE_EDITOR_NOTE_EDITOR_H
21 
22 #include <quentier/types/Note.h>
23 #include <quentier/utility/Macros.h>
24 #include <quentier/utility/Linkage.h>
25 #include <quentier/types/ErrorString.h>
26 #include <QWidget>
27 #include <QPrinter>
28 #include <QStringList>
29 
30 QT_FORWARD_DECLARE_CLASS(QUndoStack)
31 
32 namespace quentier {
33 
34 QT_FORWARD_DECLARE_CLASS(Account)
35 QT_FORWARD_DECLARE_CLASS(Notebook)
36 QT_FORWARD_DECLARE_CLASS(INoteEditorBackend)
37 QT_FORWARD_DECLARE_CLASS(FileIOProcessorAsync)
38 QT_FORWARD_DECLARE_CLASS(SpellChecker)
39 
40 
43 class QUENTIER_EXPORT NoteEditor: public QWidget
44 {
45  Q_OBJECT
46 public:
47  explicit NoteEditor(QWidget * parent = Q_NULLPTR, Qt::WindowFlags flags = 0);
48  virtual ~NoteEditor() Q_DECL_OVERRIDE;
49 
54  void initialize(FileIOProcessorAsync & fileIOProcessorAsync,
55  SpellChecker & spellChecker,
56  const Account & account);
57 
62  void setBackend(INoteEditorBackend * backend);
63 
67  void setAccount(const Account & account);
68 
72  const QUndoStack * undoStack() const;
73 
77  void setUndoStack(QUndoStack * pUndoStack);
78 
82  void setBlankPageHtml(const QString & html);
83 
87  QString currentNoteLocalUid() const;
88 
92  void setNoteAndNotebook(const Note & note, const Notebook & notebook);
93 
97  void clear();
98 
102  bool isModified() const;
103 
108  bool isNoteLoaded() const;
109 
113  void setFocus();
114 
115  QString selectedText() const;
116  bool hasSelection() const;
117 
118  bool spellCheckEnabled() const;
119 
120  bool print(QPrinter & printer, ErrorString & errorDescription);
121  bool exportToPdf(const QString & absoluteFilePath, ErrorString & errorDescription);
122  bool exportToEnex(const QStringList & tagNames,
123  QString & enex, ErrorString & errorDescription);
124 
132  QPalette defaultPalette() const;
133 
134 Q_SIGNALS:
139  void contentChanged();
140 
145  void noteModified();
146 
150  void notifyError(ErrorString error);
151 
155  void inAppNoteLinkClicked(QString userId, QString shardId, QString noteGuid);
156 
165  void inAppNoteLinkPasteRequested(QString url, QString userId, QString shardId, QString noteGuid);
166 
167  void convertedToNote(Note note);
168  void cantConvertToNote(ErrorString error);
169 
170  void noteEditorHtmlUpdated(QString html);
171 
172  void currentNoteChanged(Note note);
173 
174  void spellCheckerNotReady();
175  void spellCheckerReady();
176 
177  void noteLoaded();
178 
179  // Signals to notify anyone interested of the formatting at the current cursor position
180  void textBoldState(bool state);
181  void textItalicState(bool state);
182  void textUnderlineState(bool state);
183  void textStrikethroughState(bool state);
184  void textAlignLeftState(bool state);
185  void textAlignCenterState(bool state);
186  void textAlignRightState(bool state);
187  void textAlignFullState(bool state);
188  void textInsideOrderedListState(bool state);
189  void textInsideUnorderedListState(bool state);
190  void textInsideTableState(bool state);
191 
192  void textFontFamilyChanged(QString fontFamily);
193  void textFontSizeChanged(int fontSize);
194 
195  void insertTableDialogRequested();
196 
197 public Q_SLOTS:
202  void convertToNote();
203 
204  void undo();
205  void redo();
206  void cut();
207  void copy();
208  void paste();
209  void pasteUnformatted();
210  void selectAll();
211 
212  void formatSelectionAsSourceCode();
213 
214  void fontMenu();
215  void textBold();
216  void textItalic();
217  void textUnderline();
218  void textStrikethrough();
219  void textHighlight();
220 
221  void alignLeft();
222  void alignCenter();
223  void alignRight();
224  void alignFull();
225 
226  void findNext(const QString & text, const bool matchCase) const;
227  void findPrevious(const QString & text, const bool matchCase) const;
228  void replace(const QString & textToReplace, const QString & replacementText, const bool matchCase);
229  void replaceAll(const QString & textToReplace, const QString & replacementText, const bool matchCase);
230 
231  void insertToDoCheckbox();
232 
233  void insertInAppNoteLink(const QString & userId, const QString & shardId, const QString & noteGuid, const QString & linkText);
234 
235  void setSpellcheck(const bool enabled);
236 
237  void setFont(const QFont & font);
238  void setFontHeight(const int height);
239  void setFontColor(const QColor & color);
240  void setBackgroundColor(const QColor & color);
241 
257  void setDefaultPalette(const QPalette & pal);
258 
259  void insertHorizontalLine();
260 
261  void increaseFontSize();
262  void decreaseFontSize();
263 
264  void increaseIndentation();
265  void decreaseIndentation();
266 
267  void insertBulletedList();
268  void insertNumberedList();
269 
270  void insertTableDialog();
271  void insertFixedWidthTable(const int rows, const int columns, const int widthInPixels);
272  void insertRelativeWidthTable(const int rows, const int columns, const double relativeWidth);
273  void insertTableRow();
274  void insertTableColumn();
275  void removeTableRow();
276  void removeTableColumn();
277 
278  void addAttachmentDialog();
279  void saveAttachmentDialog(const QByteArray & resourceHash);
280  void saveAttachmentUnderCursor();
281  void openAttachment(const QByteArray & resourceHash);
282  void openAttachmentUnderCursor();
283  void copyAttachment(const QByteArray & resourceHash);
284  void copyAttachmentUnderCursor();
285 
286  void encryptSelectedText();
287  void decryptEncryptedTextUnderCursor();
288 
289  void editHyperlinkDialog();
290  void copyHyperlink();
291  void removeHyperlink();
292 
293  void onNoteLoadCancelled();
294 
295 protected:
296  virtual void dragMoveEvent(QDragMoveEvent * pEvent) Q_DECL_OVERRIDE;
297  virtual void dropEvent(QDropEvent * pEvent) Q_DECL_OVERRIDE;
298 
299 private:
300  INoteEditorBackend * m_backend;
301 };
302 
303 } // namespace quentier
304 
305 #endif // LIB_QUENTIER_NOTE_EDITOR_NOTE_EDITOR_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::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