libquentier 0.8.0
The library for rich desktop clients of Evernote service
Loading...
Searching...
No Matches
NoteEditor.h
1/*
2 * Copyright 2016-2024 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#pragma once
20
21#include <quentier/local_storage/Fwd.h>
22#include <quentier/types/ErrorString.h>
23#include <quentier/utility/Linkage.h>
24
25#include <qevercloud/types/Note.h>
26#include <qevercloud/types/Notebook.h>
27
28#include <QPrinter>
29#include <QStringList>
30#include <QThread>
31#include <QWidget>
32
33class QUndoStack;
34
35namespace quentier {
36
37class Account;
38class INoteEditorBackend;
39class SpellChecker;
40
45class QUENTIER_EXPORT NoteEditor : public QWidget
46{
48public:
49 explicit NoteEditor(
50 QWidget * parent = nullptr,
51#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
52 Qt::WindowFlags flags = {});
53#else
54 Qt::WindowFlags flags = 0); // NOLINT
55#endif
56
57 ~NoteEditor() noexcept override;
58
76 local_storage::ILocalStoragePtr localStorage,
78 QThread * pBackgroundJobsThread = nullptr);
79
84
90 void setBackend(INoteEditorBackend * backend);
91
95 void setAccount(const Account & account);
96
101
105 void setUndoStack(QUndoStack * pUndoStack);
106
110 void setInitialPageHtml(const QString & html);
111
116 void setNoteNotFoundPageHtml(const QString & html);
117
123 void setNoteDeletedPageHtml(const QString & html);
124
129 void setNoteLoadingPageHtml(const QString & html);
130
134 [[nodiscard]] QString currentNoteLocalId() const;
135
143 void setCurrentNoteLocalId(const QString & noteLocalId);
144
148 void clear();
149
154 [[nodiscard]] bool isModified() const noexcept;
155
160 [[nodiscard]] bool isEditorPageModified() const noexcept;
161
166 [[nodiscard]] bool isNoteLoaded() const noexcept;
167
174
178 void setFocus();
179
180 [[nodiscard]] QString selectedText() const noexcept;
181 [[nodiscard]] bool hasSelection() const noexcept;
182
183 [[nodiscard]] bool spellCheckEnabled() const noexcept;
184
185 [[nodiscard]] bool print(
186 QPrinter & printer, ErrorString & errorDescription);
187
188 [[nodiscard]] bool exportToPdf(
189 const QString & absoluteFilePath, ErrorString & errorDescription);
190
191 [[nodiscard]] bool exportToEnex(
192 const QStringList & tagNames, QString & enex,
193 ErrorString & errorDescription);
194
202 [[nodiscard]] QPalette defaultPalette() const;
203
208 [[nodiscard]] const QFont * defaultFont() const;
209
215 void contentChanged();
216
222 void noteAndNotebookFoundInLocalStorage(
223 qevercloud::Note note, qevercloud::Notebook notebook);
224
229 void noteNotFound(QString noteLocalId);
230
236 void noteDeleted(QString noteLocalId);
237
243 void noteModified();
244
249 void notifyError(ErrorString error);
250
255 void inAppNoteLinkClicked(
256 QString userId, QString shardId, QString noteGuid);
257
269 void inAppNoteLinkPasteRequested(
270 QString url, QString userId, QString shardId, QString noteGuid);
271
272 void convertedToNote(qevercloud::Note note);
273 void cantConvertToNote(ErrorString error);
274
275 void noteEditorHtmlUpdated(QString html);
276
277 void currentNoteChanged(qevercloud::Note note);
278
279 void spellCheckerNotReady();
280 void spellCheckerReady();
281
282 void noteLoaded();
283
290 void noteSavedToLocalStorage(QString noteLocalId);
291
296 void failedToSaveNoteToLocalStorage(
297 ErrorString errorDescription, QString noteLocalId);
298
299 // Signals to notify anyone interested of the formatting at the current
300 // cursor position
301 void textBoldState(bool state);
302 void textItalicState(bool state);
303 void textUnderlineState(bool state);
304 void textStrikethroughState(bool state);
305 void textAlignLeftState(bool state);
306 void textAlignCenterState(bool state);
307 void textAlignRightState(bool state);
308 void textAlignFullState(bool state);
309 void textInsideOrderedListState(bool state);
310 void textInsideUnorderedListState(bool state);
311 void textInsideTableState(bool state);
312
313 void textFontFamilyChanged(QString fontFamily);
314 void textFontSizeChanged(int fontSize);
315
316 void insertTableDialogRequested();
317
324 void convertToNote();
325
334 void saveNoteToLocalStorage();
335
345 void setNoteTitle(const QString & noteTitle);
346
358 void setTagIds(
360
361 void undo();
362 void redo();
363 void cut();
364 void copy();
365 void paste();
366 void pasteUnformatted();
367 void selectAll();
368
369 void formatSelectionAsSourceCode();
370
371 void fontMenu();
372 void textBold();
373 void textItalic();
374 void textUnderline();
375 void textStrikethrough();
376 void textHighlight();
377
378 void alignLeft();
379 void alignCenter();
380 void alignRight();
381 void alignFull();
382
383 void findNext(const QString & text, bool matchCase) const;
384 void findPrevious(const QString & text, bool matchCase) const;
385
386 void replace(
388 bool matchCase);
389
390 void replaceAll(
392 bool matchCase);
393
394 void insertToDoCheckbox();
395
396 void insertInAppNoteLink(
397 const QString & userId, const QString & shardId,
399
400 void setSpellcheck(bool enabled);
401
402 void setFont(const QFont & font);
403 void setFontHeight(int height);
404 void setFontColor(const QColor & color);
405 void setBackgroundColor(const QColor & color);
406
422 void setDefaultPalette(const QPalette & pal);
423
429 void setDefaultFont(const QFont & font);
430
431 void insertHorizontalLine();
432
433 void increaseFontSize();
434 void decreaseFontSize();
435
436 void increaseIndentation();
437 void decreaseIndentation();
438
439 void insertBulletedList();
440 void insertNumberedList();
441
442 void insertTableDialog();
443
444 void insertFixedWidthTable(int rows, int columns, int widthInPixels);
445
446 void insertRelativeWidthTable(int rows, int columns, double relativeWidth);
447
448 void insertTableRow();
449 void insertTableColumn();
450 void removeTableRow();
451 void removeTableColumn();
452
453 void addAttachmentDialog();
454 void saveAttachmentDialog(const QByteArray & resourceHash);
455 void saveAttachmentUnderCursor();
456 void openAttachment(const QByteArray & resourceHash);
457 void openAttachmentUnderCursor();
458 void copyAttachment(const QByteArray & resourceHash);
459 void copyAttachmentUnderCursor();
460
461 void encryptSelectedText();
462 void decryptEncryptedTextUnderCursor();
463
464 void editHyperlinkDialog();
465 void copyHyperlink();
466 void removeHyperlink();
467
468 void onNoteLoadCancelled();
469
471 void dragMoveEvent(QDragMoveEvent * pEvent) override;
472 void dropEvent(QDropEvent * pEvent) override;
473
474private:
475 INoteEditorBackend * m_backend;
476};
477
478} // namespace quentier
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition Account.h:38
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition ErrorString.h:43
Definition INoteEditorBackend.h:41
The NoteEditor class is a widget encapsulating all the functionality necessary for showing and editin...
Definition NoteEditor.h:46
void initialize(local_storage::ILocalStoragePtr localStorage, SpellChecker &spellChecker, const Account &account, QThread *pBackgroundJobsThread=nullptr)
INoteEditorBackend * backend() noexcept
The Result template class represents the bare bones result monad implementation which either contains...
Definition Result.h:38
Definition SpellChecker.h:35