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 
125 Q_SIGNALS:
130  void contentChanged();
131 
136  void noteModified();
137 
141  void notifyError(ErrorString error);
142 
146  void inAppNoteLinkClicked(QString userId, QString shardId, QString noteGuid);
147 
156  void inAppNoteLinkPasteRequested(QString url, QString userId, QString shardId, QString noteGuid);
157 
158  void convertedToNote(Note note);
159  void cantConvertToNote(ErrorString error);
160 
161  void noteEditorHtmlUpdated(QString html);
162 
163  void currentNoteChanged(Note note);
164 
165  void spellCheckerNotReady();
166  void spellCheckerReady();
167 
168  void noteLoaded();
169 
170  // Signals to notify anyone interested of the formatting at the current cursor position
171  void textBoldState(bool state);
172  void textItalicState(bool state);
173  void textUnderlineState(bool state);
174  void textStrikethroughState(bool state);
175  void textAlignLeftState(bool state);
176  void textAlignCenterState(bool state);
177  void textAlignRightState(bool state);
178  void textAlignFullState(bool state);
179  void textInsideOrderedListState(bool state);
180  void textInsideUnorderedListState(bool state);
181  void textInsideTableState(bool state);
182 
183  void textFontFamilyChanged(QString fontFamily);
184  void textFontSizeChanged(int fontSize);
185 
186  void insertTableDialogRequested();
187 
188 public Q_SLOTS:
193  void convertToNote();
194 
195  void undo();
196  void redo();
197  void cut();
198  void copy();
199  void paste();
200  void pasteUnformatted();
201  void selectAll();
202 
203  void formatSelectionAsSourceCode();
204 
205  void fontMenu();
206  void textBold();
207  void textItalic();
208  void textUnderline();
209  void textStrikethrough();
210  void textHighlight();
211 
212  void alignLeft();
213  void alignCenter();
214  void alignRight();
215  void alignFull();
216 
217  void findNext(const QString & text, const bool matchCase) const;
218  void findPrevious(const QString & text, const bool matchCase) const;
219  void replace(const QString & textToReplace, const QString & replacementText, const bool matchCase);
220  void replaceAll(const QString & textToReplace, const QString & replacementText, const bool matchCase);
221 
222  void insertToDoCheckbox();
223 
224  void insertInAppNoteLink(const QString & userId, const QString & shardId, const QString & noteGuid, const QString & linkText);
225 
226  void setSpellcheck(const bool enabled);
227 
228  void setFont(const QFont & font);
229  void setFontHeight(const int height);
230  void setFontColor(const QColor & color);
231  void setBackgroundColor(const QColor & color);
232 
233  void insertHorizontalLine();
234 
235  void increaseFontSize();
236  void decreaseFontSize();
237 
238  void increaseIndentation();
239  void decreaseIndentation();
240 
241  void insertBulletedList();
242  void insertNumberedList();
243 
244  void insertTableDialog();
245  void insertFixedWidthTable(const int rows, const int columns, const int widthInPixels);
246  void insertRelativeWidthTable(const int rows, const int columns, const double relativeWidth);
247  void insertTableRow();
248  void insertTableColumn();
249  void removeTableRow();
250  void removeTableColumn();
251 
252  void addAttachmentDialog();
253  void saveAttachmentDialog(const QByteArray & resourceHash);
254  void saveAttachmentUnderCursor();
255  void openAttachment(const QByteArray & resourceHash);
256  void openAttachmentUnderCursor();
257  void copyAttachment(const QByteArray & resourceHash);
258  void copyAttachmentUnderCursor();
259 
260  void encryptSelectedText();
261  void decryptEncryptedTextUnderCursor();
262 
263  void editHyperlinkDialog();
264  void copyHyperlink();
265  void removeHyperlink();
266 
267  void onNoteLoadCancelled();
268 
269 protected:
270  virtual void dragMoveEvent(QDragMoveEvent * pEvent) Q_DECL_OVERRIDE;
271  virtual void dropEvent(QDropEvent * pEvent) Q_DECL_OVERRIDE;
272 
273 private:
274  INoteEditorBackend * m_backend;
275 };
276 
277 } // namespace quentier
278 
279 #endif // LIB_QUENTIER_NOTE_EDITOR_NOTE_EDITOR_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