data.h 755 Bytes
Newer Older
EXT Arnaud Clère's avatar
EXT Arnaud Clère committed
1
2
3
4
5
6
7
8
9
10
11
12
13
#pragma once

#include <QtCore/qmetaobject.h>

#include "QBind_impl.h"

class Phone {
    Q_GADGET
    Q_PROPERTY(Type    type   MEMBER _t)
    Q_PROPERTY(QString number MEMBER _n)
public:
    QBIND_GADGET_WITH_METAOBJECT(Phone) // making it (de)serializable and printable using reflection

14
    enum Type : quint8 { Unknown=0, Mobile, Home, Office };
EXT Arnaud Clère's avatar
EXT Arnaud Clère committed
15
16
17
    Q_ENUM(Type)

    Phone(Type t=Unknown, QString n=QString()) : _t(t), _n(n) {}
18
//private:
EXT Arnaud Clère's avatar
EXT Arnaud Clère committed
19
20
    Type _t; QString _n;
};
21
22
23
24
25
26
27
28
29
30
31

Q_DECLARE_METATYPE(Phone)

// For comparison purposes:

#include<QtCore/qdebug.h>
QDebug &operator<<(QDebug &out, const Phone &p);

#include<QtCore/qdatastream.h>
QDataStream &operator<<(QDataStream &out, const Phone &p);
QDataStream &operator>>(QDataStream &out,       Phone &p);