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 QORGANIZERITEMDETAIL_H
35#define QORGANIZERITEMDETAIL_H
36
37#include <QtCore/qmap.h>
38#include <QtCore/qshareddata.h>
39#include <QtCore/qstringlist.h>
40#include <QtCore/qvariant.h>
41
42#include <QtOrganizer/qorganizerglobal.h>
43
44QT_BEGIN_NAMESPACE_ORGANIZER
45
46class QOrganizerItemDetailPrivate;
47class Q_ORGANIZER_EXPORT QOrganizerItemDetail
48{
49public:
50 enum DetailType {
51 TypeUndefined = 0,
52 TypeClassification = 100,
53 TypeComment = 200,
54 TypeDescription = 300,
55 TypeDisplayLabel = 400,
56 TypeItemType = 500,
57 TypeGuid = 600,
58 TypeLocation = 700,
59 TypeParent = 800,
60 TypePriority = 900,
61 TypeRecurrence = 1000,
62 TypeTag = 1100,
63 TypeTimestamp = 1200,
64 TypeVersion = 1300,
65 TypeReminder = 1400,
66 TypeAudibleReminder = 1500,
67 TypeEmailReminder = 1600,
68 TypeVisualReminder = 1700,
69 TypeExtendedDetail = 1800,
70 TypeEventAttendee = 1900,
71 TypeEventRsvp = 2000,
72 TypeEventTime = 2100,
73 TypeJournalTime = 2200,
74 TypeTodoProgress = 2300,
75 TypeTodoTime = 2400
76 };
77
78 QOrganizerItemDetail(DetailType detailType = TypeUndefined);
79 QOrganizerItemDetail(const QOrganizerItemDetail &other);
80 ~QOrganizerItemDetail();
81
82 QOrganizerItemDetail &operator=(const QOrganizerItemDetail &other);
83
84 bool operator==(const QOrganizerItemDetail &other) const;
85 bool operator!=(const QOrganizerItemDetail &other) const {return !(other == *this);}
86
87 DetailType type() const;
88 bool isEmpty() const;
89
90 int key() const;
91 void resetKey();
92
93 bool setValue(int field, const QVariant &value);
94 bool removeValue(int field);
95 bool hasValue(int field) const;
96
97 QMap<int, QVariant> values() const;
98 QVariant value(int field) const;
99 template <typename T> T value(int field) const
100 {
101 return value(field).value<T>();
102 }
103
104protected:
105 QOrganizerItemDetail(const QOrganizerItemDetail &other, DetailType expectedDetailType);
106 QOrganizerItemDetail &assign(const QOrganizerItemDetail &other, DetailType expectedDetailType);
107
108private:
109 friend Q_ORGANIZER_EXPORT uint qHash(const QOrganizerItemDetail &key);
110 friend class QOrganizerItem;
111 friend class QOrganizerItemDetailPrivate;
112
113#ifndef QT_NO_DATASTREAM
114 friend Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerItemDetail &detail);
115#endif // QT_NO_DATASTREAM
116
117 QSharedDataPointer<QOrganizerItemDetailPrivate> d;
118};
119
120Q_ORGANIZER_EXPORT uint qHash(const QOrganizerItemDetail &key);
121#ifndef QT_NO_DATASTREAM
122Q_ORGANIZER_EXPORT QDataStream &operator<<(QDataStream &out, const QOrganizerItemDetail &detail);
123Q_ORGANIZER_EXPORT QDataStream &operator>>(QDataStream &in, QOrganizerItemDetail &detail);
124#endif // QT_NO_DATASTREAM
125#ifndef QT_NO_DEBUG_STREAM
126Q_ORGANIZER_EXPORT QDebug operator<<(QDebug dbg, const QOrganizerItemDetail &detail);
127#endif // QT_NO_DEBUG_STREAM
128
129#define Q_DECLARE_CUSTOM_ORGANIZER_DETAIL(className, detailType) \
130 className() : QOrganizerItemDetail(detailType) {} \
131 className(const QOrganizerItemDetail &other) : QOrganizerItemDetail(other, detailType) {} \
132 className &operator=(const QOrganizerItemDetail &other) {assign(other, detailType); return *this;}
133
134QT_END_NAMESPACE_ORGANIZER
135
136QT_BEGIN_NAMESPACE
137Q_DECLARE_TYPEINFO(QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemDetail), Q_MOVABLE_TYPE);
138QT_END_NAMESPACE
139
140#endif // QORGANIZERITEMDETAIL_H
141

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