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 QtContacts 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 QDECLARATIVECONTACTORGANIZATION_H
35#define QDECLARATIVECONTACTORGANIZATION_H
36
37#include <QtContacts/qcontactorganization.h>
38
39#include "qdeclarativecontactdetail_p.h"
40
41QTCONTACTS_USE_NAMESPACE
42
43QT_BEGIN_NAMESPACE
44
45class QDeclarativeContactOrganization : public QDeclarativeContactDetail
46{
47 Q_OBJECT
48
49 Q_PROPERTY(QString name READ name WRITE setName NOTIFY valueChanged)
50 Q_PROPERTY(QUrl logoUrl READ logoUrl WRITE setLogoUrl NOTIFY valueChanged)
51 Q_PROPERTY(QStringList department READ department WRITE setDepartment NOTIFY valueChanged)
52 Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY valueChanged)
53 Q_PROPERTY(QString role READ role WRITE setRole NOTIFY valueChanged)
54 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY valueChanged)
55 Q_PROPERTY(QString assistantName READ assistantName WRITE setAssistantName NOTIFY valueChanged)
56 Q_CLASSINFO("DefaultProperty", "name")
57 Q_ENUMS(FieldType)
58public:
59 enum FieldType {
60 Name = QContactOrganization::FieldName,
61 LogoUrl = QContactOrganization::FieldLogoUrl,
62 Department = QContactOrganization::FieldDepartment,
63 Location = QContactOrganization::FieldLocation,
64 Role = QContactOrganization::FieldRole,
65 Title = QContactOrganization::FieldTitle,
66 AssistantName = QContactOrganization::FieldAssistantName
67 };
68
69 QDeclarativeContactOrganization(QObject* parent = Q_NULLPTR)
70 :QDeclarativeContactDetail(parent)
71 {
72 setDetail(QContactOrganization());
73 connect(asender: this, SIGNAL(valueChanged()), SIGNAL(detailChanged()));
74 }
75 DetailType detailType() const
76 {
77 return QDeclarativeContactDetail::Organization;
78 }
79
80 void setName(const QString& v)
81 {
82 if (!readOnly() && v != name()) {
83 detail().setValue(field: QContactOrganization::FieldName, value: v);
84 emit valueChanged();
85 }
86 }
87 QString name() const {return detail().value(field: QContactOrganization::FieldName).toString();}
88 void setLogoUrl(const QUrl& v)
89 {
90 if (!readOnly() && v != logoUrl()) {
91 detail().setValue(field: QContactOrganization::FieldLogoUrl, value: v);
92 emit valueChanged();
93 }
94 }
95 QUrl logoUrl() const {return detail().value(field: QContactOrganization::FieldLogoUrl).toString();}
96 void setDepartment(const QStringList& v)
97 {
98 if (!readOnly() && v.toSet() != department().toSet()) {
99 detail().setValue(field: QContactOrganization::FieldDepartment, value: v);
100 emit valueChanged();
101 }
102 }
103 QStringList department() const {return detail().value<QStringList>(field: QContactOrganization::FieldDepartment);}
104 void setLocation(const QString& v)
105 {
106 if (!readOnly() && v != location()) {
107 detail().setValue(field: QContactOrganization::FieldLocation, value: v);
108 emit valueChanged();
109 }
110 }
111 QString location() const {return detail().value(field: QContactOrganization::FieldLocation).toString();}
112 void setRole(const QString& v)
113 {
114 if (!readOnly() && v != role()) {
115 detail().setValue(field: QContactOrganization::FieldRole, value: v);
116 emit valueChanged();
117 }
118 }
119 QString role() const {return detail().value(field: QContactOrganization::FieldRole).toString();}
120 void setTitle(const QString& v)
121 {
122 if (!readOnly() && v != title()) {
123 detail().setValue(field: QContactOrganization::FieldTitle, value: v);
124 emit valueChanged();
125 }
126 }
127 QString title() const {return detail().value(field: QContactOrganization::FieldTitle).toString();}
128 void setAssistantName(const QString& v)
129 {
130 if (!readOnly() && v != assistantName()) {
131 detail().setValue(field: QContactOrganization::FieldAssistantName, value: v);
132 emit valueChanged();
133 }
134 }
135 QString assistantName() const {return detail().value(field: QContactOrganization::FieldAssistantName).toString();}
136
137signals:
138 void valueChanged();
139
140};
141
142QT_END_NAMESPACE
143
144QML_DECLARE_TYPE(QDeclarativeContactOrganization)
145
146#endif // QDECLARATIVECONTACTORGANIZATION_H
147

source code of qtpim/src/imports/contacts/details/qdeclarativecontactorganization_p.h