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