1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtOrganizer module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#ifndef QORGANIZERITEM_H
35#define QORGANIZERITEM_H
36
37#include <QtCore/qshareddata.h>
38#include <QtCore/qstringlist.h>
39#include <QtCore/qvariant.h>
40
41#include <QtOrganizer/qorganizercollectionid.h>
42#include <QtOrganizer/qorganizeritemid.h>
43#include <QtOrganizer/qorganizeritemdetail.h>
44#include <QtOrganizer/qorganizeritemtype.h>
45
46QT_BEGIN_NAMESPACE_ORGANIZER
47
48class QOrganizerItemData;
49class Q_ORGANIZER_EXPORT QOrganizerItem
50{
51public:
52 QOrganizerItem();
53 QOrganizerItem(const QOrganizerItem &other);
54 ~QOrganizerItem();
55
56 QOrganizerItem &operator=(const QOrganizerItem &other);
57
58 bool operator==(const QOrganizerItem &other) const;
59 bool operator!=(const QOrganizerItem &other) const {return !(other == *this);}
60
61 QOrganizerItemId id() const;
62 void setId(const QOrganizerItemId &id);
63
64 QOrganizerCollectionId collectionId() const;
65 void setCollectionId(const QOrganizerCollectionId &collectionId);
66
67 bool isEmpty() const;
68 void clearDetails();
69
70 QOrganizerItemDetail detail(QOrganizerItemDetail::DetailType detailType = QOrganizerItemDetail::TypeUndefined) const;
71 QList<QOrganizerItemDetail> details(QOrganizerItemDetail::DetailType detailType = QOrganizerItemDetail::TypeUndefined) const;
72
73 bool saveDetail(QOrganizerItemDetail *detail);
74 bool removeDetail(QOrganizerItemDetail *detail);
75
76 QOrganizerItemType::ItemType type() const;
77 void setType(QOrganizerItemType::ItemType type);
78
79 QString displayLabel() const;
80 void setDisplayLabel(const QString &label);
81
82 QString description() const;
83 void setDescription(const QString &description);
84
85 QStringList comments() const;
86 void clearComments();
87 void setComments(const QStringList &comments);
88 void addComment(const QString &comment);
89
90 QStringList tags() const;
91 void clearTags();
92 void addTag(const QString &tag);
93 void setTags(const QStringList &tags);
94
95 QString guid() const;
96 void setGuid(const QString &guid);
97
98 QVariant data(const QString &name) const;
99 void setData(const QString &name, const QVariant &data);
100
101protected:
102 explicit QOrganizerItem(QOrganizerItemType::ItemType type);
103 QOrganizerItem(const QOrganizerItem &other, QOrganizerItemType::ItemType expectedType);
104 QOrganizerItem &assign(const QOrganizerItem &other, QOrganizerItemType::ItemType expectedType);
105
106protected:
107 friend class QOrganizerItemData;
108 friend class QOrganizerManager;
109 friend class QOrganizerManagerData;
110 friend class QOrganizerManagerEngine;
111
112#ifndef QT_NO_DATASTREAM
113 Q_ORGANIZER_EXPORT friend QDataStream &operator<<(QDataStream &out, const QOrganizerItem &item);
114 Q_ORGANIZER_EXPORT friend QDataStream &operator>>(QDataStream &in, QOrganizerItem &item);
115#endif // QT_NO_DATASTREAM
116
117 QSharedDataPointer<QOrganizerItemData> d;
118};
119
120Q_ORGANIZER_EXPORT uint qHash(const QOrganizerItem &key);
121
122#ifndef QT_NO_DATASTREAM
123Q_ORGANIZER_EXPORT QDataStream &operator<<(QDataStream &out, const QOrganizerItem &item);
124Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerItem &item);
125#endif // QT_NO_DATASTREAM
126#ifndef QT_NO_DEBUG_STREAM
127Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerItem &item);
128#endif // QT_NO_DEBUG_STREAM
129
130#define Q_DECLARE_CUSTOM_ORGANIZER_ITEM(className, typeConstant) \
131 className() : QOrganizerItem(typeConstant) {} \
132 className(const QOrganizerItem &other) : QOrganizerItem(other, typeConstant) {} \
133 className& operator=(const QOrganizerItem &other) {assign(other, typeConstant); return *this;}
134
135QT_END_NAMESPACE_ORGANIZER
136
137QT_BEGIN_NAMESPACE
138Q_DECLARE_TYPEINFO(QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItem), Q_MOVABLE_TYPE);
139QT_END_NAMESPACE
140
141#endif // QORGANIZERITEM_H
142

source code of qtpim/src/organizer/qorganizeritem.h