libquentier 0.5.0
The library for rich desktop clients of Evernote service
Loading...
Searching...
No Matches
Note.h
1/*
2 * Copyright 2016-2020 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_TYPES_NOTE_H
20#define LIB_QUENTIER_TYPES_NOTE_H
21
22#include "IFavoritableDataElement.h"
23#include "SharedNote.h"
24
25#include <qt5qevercloud/QEverCloud.h>
26
27#include <QSharedDataPointer>
28
29namespace quentier {
30
31QT_FORWARD_DECLARE_CLASS(Resource)
32QT_FORWARD_DECLARE_CLASS(NoteData)
33
34class QUENTIER_EXPORT Note : public IFavoritableDataElement
35{
36public:
37 QN_DECLARE_LOCAL_UID
38 QN_DECLARE_DIRTY
39 QN_DECLARE_FAVORITED
40 QN_DECLARE_LOCAL
41
42public:
43 explicit Note();
44 Note(const Note & other);
45 Note(Note && other);
46 Note & operator=(const Note & other);
47 Note & operator=(Note && other);
48
49 explicit Note(const qevercloud::Note & other);
50 Note & operator=(const qevercloud::Note & other);
51
52 virtual ~Note() override;
53
54 bool operator==(const Note & other) const;
55 bool operator!=(const Note & other) const;
56
57 const qevercloud::Note & qevercloudNote() const;
58 qevercloud::Note & qevercloudNote();
59
60 virtual bool hasGuid() const override;
61 virtual const QString & guid() const override;
62 virtual void setGuid(const QString & guid) override;
63
64 virtual bool hasUpdateSequenceNumber() const override;
65 virtual qint32 updateSequenceNumber() const override;
66 virtual void setUpdateSequenceNumber(const qint32 usn) override;
67
68 virtual void clear() override;
69
70 static bool validateTitle(
71 const QString & title, ErrorString * pErrorDescription = nullptr);
72
73 virtual bool checkParameters(ErrorString & errorDescription) const override;
74
75 bool hasTitle() const;
76 const QString & title() const;
77 void setTitle(const QString & title);
78
79 bool hasContent() const;
80 const QString & content() const;
81 void setContent(const QString & content);
82
83 bool hasContentHash() const;
84 const QByteArray & contentHash() const;
85 void setContentHash(const QByteArray & contentHash);
86
87 bool hasContentLength() const;
88 qint32 contentLength() const;
89 void setContentLength(const qint32 length);
90
91 bool hasCreationTimestamp() const;
92 qint64 creationTimestamp() const;
93 void setCreationTimestamp(const qint64 timestamp);
94
95 bool hasModificationTimestamp() const;
96 qint64 modificationTimestamp() const;
97 void setModificationTimestamp(const qint64 timestamp);
98
99 bool hasDeletionTimestamp() const;
100 qint64 deletionTimestamp() const;
101 void setDeletionTimestamp(const qint64 timestamp);
102
103 bool hasActive() const;
104 bool active() const;
105 void setActive(const bool active);
106
107 bool hasNotebookGuid() const;
108 const QString & notebookGuid() const;
109 void setNotebookGuid(const QString & guid);
110
111 bool hasNotebookLocalUid() const;
112 const QString & notebookLocalUid() const;
113 void setNotebookLocalUid(const QString & notebookLocalUid);
114
115 bool hasTagGuids() const;
116 const QStringList tagGuids() const;
117 void setTagGuids(const QStringList & guids);
118 void addTagGuid(const QString & guid);
119 void removeTagGuid(const QString & guid);
120
121 bool hasTagLocalUids() const;
122 const QStringList & tagLocalUids() const;
123 void setTagLocalUids(const QStringList & localUids);
124 void addTagLocalUid(const QString & localUid);
125 void removeTagLocalUid(const QString & localUid);
126
127 bool hasResources() const;
128 int numResources() const;
129 QList<Resource> resources() const;
130 void setResources(const QList<Resource> & resources);
131 void addResource(const Resource & resource);
132 bool updateResource(const Resource & resource);
133 bool removeResource(const Resource & resource);
134
135 bool hasNoteAttributes() const;
136 const qevercloud::NoteAttributes & noteAttributes() const;
137 qevercloud::NoteAttributes & noteAttributes();
138 void clearNoteAttributes();
139
140 bool hasSharedNotes() const;
141 QList<SharedNote> sharedNotes() const;
142 void setSharedNotes(const QList<SharedNote> & sharedNotes);
143 void addSharedNote(const SharedNote & sharedNote);
144
145 // NOTE: the shared note is recognized by its index in note
146 // in the following two methods
147 bool updateSharedNote(const SharedNote & sharedNote);
148 bool removeSharedNote(const SharedNote & sharedNote);
149
150 bool hasNoteRestrictions() const;
151 const qevercloud::NoteRestrictions & noteRestrictions() const;
152 qevercloud::NoteRestrictions & noteRestrictions();
153 void setNoteRestrictions(qevercloud::NoteRestrictions && restrictions);
154
155 bool hasNoteLimits() const;
156 const qevercloud::NoteLimits & noteLimits() const;
157 qevercloud::NoteLimits & noteLimits();
158 void setNoteLimits(qevercloud::NoteLimits && limits);
159
160 QByteArray thumbnailData() const;
161 void setThumbnailData(const QByteArray & thumbnailData);
162
163 bool isInkNote() const;
164
165 QString plainText(ErrorString * pErrorMessage = nullptr) const;
166 QStringList listOfWords(ErrorString * pErrorMessage = nullptr) const;
167
168 std::pair<QString, QStringList> plainTextAndListOfWords(
169 ErrorString * pErrorMessage = nullptr) const;
170
171 bool containsCheckedTodo() const;
172 bool containsUncheckedTodo() const;
173 bool containsTodo() const;
174 bool containsEncryption() const;
175
176 virtual QTextStream & print(QTextStream & strm) const override;
177
178private:
179 QSharedDataPointer<NoteData> d;
180};
181
182} // namespace quentier
183
184Q_DECLARE_METATYPE(quentier::Note)
185
186#endif // LIB_QUENTIER_TYPES_NOTE_H
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition ErrorString.h:44
Definition IFavoritableDataElement.h:33
Definition Note.h:35
Definition Resource.h:30
Definition SharedNote.h:34