data.h 761 Bytes
Newer Older
EXT Arnaud Clère's avatar
EXT Arnaud Clère committed
1 2 3 4
#pragma once

#include <QtCore/qmetaobject.h>

EXT Arnaud Clère's avatar
EXT Arnaud Clère committed
5
#include "QValue.h"
EXT Arnaud Clère's avatar
EXT Arnaud Clère committed
6 7 8 9 10 11

class Phone {
    Q_GADGET
    Q_PROPERTY(Type    type   MEMBER _t)
    Q_PROPERTY(QString number MEMBER _n)
public:
12
    Q_DEFINE_ZAP_WITH_METAOBJECT(Phone) // making it (de)serializable and printable using reflection
EXT Arnaud Clère's avatar
EXT Arnaud Clère committed
13

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

19
//private:
EXT Arnaud Clère's avatar
EXT Arnaud Clère committed
20 21
    Type _t; QString _n;
};
22 23 24 25 26 27

Q_DECLARE_METATYPE(Phone)

// For comparison purposes:

#include<QtCore/qdebug.h>
28
QDebug      &operator<<(QDebug      &out, const Phone &p);
29 30 31
#include<QtCore/qdatastream.h>
QDataStream &operator<<(QDataStream &out, const Phone &p);
QDataStream &operator>>(QDataStream &out,       Phone &p);