1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWIDGETITEMDATA_P_H
5#define QWIDGETITEMDATA_P_H
6
7#include <QtWidgets/private/qtwidgetsglobal_p.h>
8#include <QtCore/qdatastream.h>
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21QT_BEGIN_NAMESPACE
22
23class QWidgetItemData
24{
25public:
26 inline QWidgetItemData() : role(-1) {}
27 inline QWidgetItemData(int r, const QVariant &v) : role(r), value(v) {}
28 int role;
29 QVariant value;
30 inline bool operator==(const QWidgetItemData &other) const { return role == other.role && value == other.value; }
31};
32Q_DECLARE_TYPEINFO(QWidgetItemData, Q_RELOCATABLE_TYPE);
33
34#ifndef QT_NO_DATASTREAM
35
36inline QDataStream &operator>>(QDataStream &in, QWidgetItemData &data)
37{
38 in >> data.role;
39 in >> data.value;
40 return in;
41}
42
43inline QDataStream &operator<<(QDataStream &out, const QWidgetItemData &data)
44{
45 out << data.role;
46 out << data.value;
47 return out;
48}
49
50#endif // QT_NO_DATASTREAM
51
52QT_END_NAMESPACE
53
54#endif // QWIDGETITEMDATA_P_H
55

source code of qtbase/src/widgets/itemviews/qwidgetitemdata_p.h