| 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 QtQml 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 QDECLARATIVECONTACTRELATIONSHIPMODEL_P_H |
| 35 | #define QDECLARATIVECONTACTRELATIONSHIPMODEL_P_H |
| 36 | |
| 37 | #include <QtCore/qabstractitemmodel.h> |
| 38 | |
| 39 | #include <QtQml/qqml.h> |
| 40 | |
| 41 | #include "qdeclarativecontactrelationship_p.h" |
| 42 | |
| 43 | QTCONTACTS_USE_NAMESPACE |
| 44 | |
| 45 | QT_BEGIN_NAMESPACE |
| 46 | |
| 47 | class QDeclarativeContactRelationshipModelPrivate; |
| 48 | class QDeclarativeContactRelationshipModel : public QAbstractListModel |
| 49 | { |
| 50 | Q_OBJECT |
| 51 | Q_PROPERTY(QString manager READ manager WRITE setManager NOTIFY managerChanged) |
| 52 | Q_PROPERTY(bool autoUpdate READ autoUpdate WRITE setAutoUpdate NOTIFY autoUpdateChanged) |
| 53 | Q_PROPERTY(QDeclarativeContact* participant READ participant WRITE setParticipant NOTIFY participantChanged) |
| 54 | Q_PROPERTY(QVariant relationshipType READ relationshipType WRITE setRelationshipType NOTIFY relationshipTypeChanged) |
| 55 | Q_PROPERTY(QDeclarativeContactRelationship::RelationshipRole role READ role WRITE setRole NOTIFY roleChanged) |
| 56 | Q_PROPERTY(QQmlListProperty<QDeclarativeContactRelationship> relationships READ relationships NOTIFY relationshipsChanged) |
| 57 | Q_PROPERTY(QString error READ error) |
| 58 | |
| 59 | public: |
| 60 | QDeclarativeContactRelationshipModel(QObject *parent = Q_NULLPTR); |
| 61 | ~QDeclarativeContactRelationshipModel(); |
| 62 | enum { |
| 63 | RelationshipRole = Qt::UserRole + 500 |
| 64 | |
| 65 | }; |
| 66 | |
| 67 | QString manager() const; |
| 68 | void setManager(const QString& manager); |
| 69 | bool autoUpdate() const; |
| 70 | void setAutoUpdate(bool autoUpdate); |
| 71 | QString error() const; |
| 72 | QDeclarativeContact* participant() const; |
| 73 | void setParticipant(QDeclarativeContact* participant); |
| 74 | |
| 75 | QVariant relationshipType() const; |
| 76 | void setRelationshipType(const QVariant& type); |
| 77 | |
| 78 | QDeclarativeContactRelationship::RelationshipRole role() const; |
| 79 | void setRole(QDeclarativeContactRelationship::RelationshipRole role); |
| 80 | |
| 81 | QQmlListProperty<QDeclarativeContactRelationship> relationships(); |
| 82 | int rowCount(const QModelIndex &parent) const; |
| 83 | QVariant data(const QModelIndex &index, int role) const; |
| 84 | |
| 85 | Q_INVOKABLE void removeRelationship(QDeclarativeContactRelationship* dcr); |
| 86 | Q_INVOKABLE void addRelationship(QDeclarativeContactRelationship* dcr); |
| 87 | signals: |
| 88 | void managerChanged(); |
| 89 | void participantChanged(); |
| 90 | void relationshipTypeChanged(); |
| 91 | void roleChanged(); |
| 92 | void relationshipsChanged(); |
| 93 | void autoUpdateChanged(); |
| 94 | private slots: |
| 95 | void fetchAgain(); |
| 96 | void requestUpdated(); |
| 97 | |
| 98 | void relationshipsSaved(); |
| 99 | |
| 100 | void relationshipsRemoved(); |
| 101 | |
| 102 | private: |
| 103 | QDeclarativeContactRelationshipModelPrivate* d; |
| 104 | }; |
| 105 | |
| 106 | QT_END_NAMESPACE |
| 107 | |
| 108 | QML_DECLARE_TYPE(QDeclarativeContactRelationshipModel) |
| 109 | |
| 110 | #endif // QDECLARATIVECONTACTRELATIONSHIPMODEL_P_H |
| 111 |
