55 class QContactDetailPrivate; |
55 class QContactDetailPrivate; |
56 class Q_CONTACTS_EXPORT QContactDetail |
56 class Q_CONTACTS_EXPORT QContactDetail |
57 { |
57 { |
58 public: |
58 public: |
59 QContactDetail(); |
59 QContactDetail(); |
|
60 QContactDetail(const char* definitionName); // possibly internal |
60 QContactDetail(const QString& definitionName); |
61 QContactDetail(const QString& definitionName); |
61 virtual ~QContactDetail(); |
62 ~QContactDetail(); |
62 |
63 |
63 QContactDetail(const QContactDetail& other); |
64 QContactDetail(const QContactDetail& other); |
64 QContactDetail& operator=(const QContactDetail& other); |
65 QContactDetail& operator=(const QContactDetail& other); |
65 |
66 |
66 enum AccessConstraint { |
67 enum AccessConstraint { |
72 |
73 |
73 AccessConstraints accessConstraints() const; |
74 AccessConstraints accessConstraints() const; |
74 |
75 |
75 // Predefined attribute names and values |
76 // Predefined attribute names and values |
76 #ifdef Q_QDOC |
77 #ifdef Q_QDOC |
77 const char* FieldContext; |
78 static const QLatin1Constant FieldContext; |
78 const char* ContextHome; |
79 static const QLatin1Constant ContextHome; |
79 const char* ContextWork; |
80 static const QLatin1Constant ContextWork; |
80 const char* ContextOther; |
81 static const QLatin1Constant ContextOther; |
81 const char* FieldDetailUri; |
82 static const QLatin1Constant FieldDetailUri; |
82 const char* FieldLinkedDetailUris; |
83 static const QLatin1Constant FieldLinkedDetailUris; |
83 #else |
84 #else |
84 Q_DECLARE_LATIN1_LITERAL(FieldContext, "Context"); |
85 Q_DECLARE_LATIN1_CONSTANT(FieldContext, "Context"); |
85 Q_DECLARE_LATIN1_LITERAL(ContextHome, "Home"); |
86 Q_DECLARE_LATIN1_CONSTANT(ContextHome, "Home"); |
86 Q_DECLARE_LATIN1_LITERAL(ContextWork, "Work"); |
87 Q_DECLARE_LATIN1_CONSTANT(ContextWork, "Work"); |
87 Q_DECLARE_LATIN1_LITERAL(ContextOther, "Other"); |
88 Q_DECLARE_LATIN1_CONSTANT(ContextOther, "Other"); |
88 Q_DECLARE_LATIN1_LITERAL(FieldDetailUri, "DetailUri"); |
89 Q_DECLARE_LATIN1_CONSTANT(FieldDetailUri, "DetailUri"); |
89 Q_DECLARE_LATIN1_LITERAL(FieldLinkedDetailUris, "LinkedDetailUris"); |
90 Q_DECLARE_LATIN1_CONSTANT(FieldLinkedDetailUris, "LinkedDetailUris"); |
90 #endif |
91 #endif |
91 |
92 |
92 bool operator==(const QContactDetail& other) const; |
93 bool operator==(const QContactDetail& other) const; |
93 bool operator!=(const QContactDetail& other) const {return !(other == *this);} |
94 bool operator!=(const QContactDetail& other) const {return !(other == *this);} |
94 |
95 |
95 QString definitionName() const; |
96 QString definitionName() const; |
96 bool isEmpty() const; |
97 bool isEmpty() const; |
97 |
98 |
98 int key() const; |
99 int key() const; |
99 void resetKey(); |
100 void resetKey(); |
100 |
|
101 void setPreferredActions(const QList<QContactActionDescriptor>& preferredActions); |
|
102 QList<QContactActionDescriptor> preferredActions() const; |
|
103 |
101 |
104 QString value(const QString& key) const; |
102 QString value(const QString& key) const; |
105 bool setValue(const QString& key, const QVariant& value); |
103 bool setValue(const QString& key, const QVariant& value); |
106 bool removeValue(const QString& key); |
104 bool removeValue(const QString& key); |
107 bool hasValue(const QString& key) const; |
105 bool hasValue(const QString& key) const; |
111 template <typename T> T value(const QString& key) const |
109 template <typename T> T value(const QString& key) const |
112 { |
110 { |
113 return variantValue(key).value<T>(); |
111 return variantValue(key).value<T>(); |
114 } |
112 } |
115 |
113 |
116 |
114 /* These are probably internal */ |
|
115 QString value(const char* key) const; |
|
116 bool setValue(const char* key, const QVariant& value); |
|
117 bool removeValue(const char* key); |
|
118 bool hasValue(const char* key) const; |
|
119 QVariant variantValue(const char *key) const; |
|
120 template<typename T> T value(const char *key) const |
|
121 { |
|
122 return variantValue(key).value<T>(); |
|
123 } |
|
124 template<int N> QString value(const QLatin1Constant<N>& key) const |
|
125 { |
|
126 return value(key.latin1()); |
|
127 } |
|
128 template<int N> bool setValue(const QLatin1Constant<N>& key, const QVariant& value) |
|
129 { |
|
130 return setValue(key.latin1(), value); |
|
131 } |
|
132 template<int N> bool removeValue(const QLatin1Constant<N>& key) |
|
133 { |
|
134 return removeValue(key.latin1()); |
|
135 } |
|
136 template<int N> bool hasValue(const QLatin1Constant<N>& key) const |
|
137 { |
|
138 return hasValue(key.latin1()); |
|
139 } |
|
140 template<int N> QVariant variantValue(const QLatin1Constant<N>& key) const |
|
141 { |
|
142 return variantValue(key.latin1()); |
|
143 } |
|
144 template<typename T, int N> T value(const QLatin1Constant<N>& key) const |
|
145 { |
|
146 return value<T>(key.latin1()); |
|
147 } |
117 |
148 |
118 void setContexts(const QStringList& contexts) |
149 void setContexts(const QStringList& contexts) |
119 { |
150 { |
120 setValue(FieldContext, contexts); |
151 setValue(FieldContext, contexts); |
121 } |
152 } |
154 { |
185 { |
155 return value<QStringList>(FieldLinkedDetailUris); |
186 return value<QStringList>(FieldLinkedDetailUris); |
156 } |
187 } |
157 |
188 |
158 protected: |
189 protected: |
159 QContactDetail(const QContactDetail& other, const QString& expectedDefinitionId); |
190 QContactDetail(const QContactDetail &other, const QString& expectedDefinitionId); |
160 QContactDetail& assign(const QContactDetail& other, const QString& expectedDefinitionId); |
191 QContactDetail& assign(const QContactDetail &other, const QString& expectedDefinitionId); |
|
192 QContactDetail(const QContactDetail &other, const char* expectedDefinitionId); |
|
193 QContactDetail& assign(const QContactDetail &other, const char* expectedDefinitionId); |
161 |
194 |
162 private: |
195 private: |
163 friend class QContact; |
196 friend class QContact; |
164 friend class QContactDetailPrivate; |
197 friend class QContactDetailPrivate; |
165 QSharedDataPointer<QContactDetailPrivate> d; |
198 QSharedDataPointer<QContactDetailPrivate> d; |
166 }; |
199 }; |
167 |
200 |
|
201 Q_CONTACTS_EXPORT uint qHash(const QContactDetail& key); |
|
202 #ifndef QT_NO_DEBUG_STREAM |
|
203 Q_CONTACTS_EXPORT QDebug operator<<(QDebug dbg, const QContactDetail& detail); |
|
204 #endif |
|
205 |
168 Q_DECLARE_OPERATORS_FOR_FLAGS(QContactDetail::AccessConstraints); |
206 Q_DECLARE_OPERATORS_FOR_FLAGS(QContactDetail::AccessConstraints); |
169 |
207 |
170 #define Q_DECLARE_CUSTOM_CONTACT_DETAIL(className, definitionNameString) \ |
208 #define Q_DECLARE_CUSTOM_CONTACT_DETAIL(className, definitionNameString) \ |
171 className() : QContactDetail(DefinitionName) {} \ |
209 className() : QContactDetail(DefinitionName.latin1()) {} \ |
172 className(const QContactDetail& field) : QContactDetail(field, DefinitionName) {} \ |
210 className(const QContactDetail& field) : QContactDetail(field, DefinitionName.latin1()) {} \ |
173 className& operator=(const QContactDetail& other) {assign(other, DefinitionName); return *this;} \ |
211 className& operator=(const QContactDetail& other) {assign(other, DefinitionName.latin1()); return *this;} \ |
174 \ |
212 \ |
175 Q_DECLARE_LATIN1_LITERAL(DefinitionName, definitionNameString); |
213 Q_DECLARE_LATIN1_CONSTANT(DefinitionName, definitionNameString); |
176 |
214 |
177 #define Q_IMPLEMENT_CUSTOM_CONTACT_DETAIL(className, definitionNameString) \ |
215 #define Q_IMPLEMENT_CUSTOM_CONTACT_DETAIL(className, definitionNameString) \ |
178 Q_DEFINE_LATIN1_LITERAL(className::DefinitionName, definitionNameString) |
216 Q_DEFINE_LATIN1_CONSTANT(className::DefinitionName, definitionNameString) |
179 |
217 |
180 QTM_END_NAMESPACE |
218 QTM_END_NAMESPACE |
181 |
219 |
182 Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QContactDetail), Q_MOVABLE_TYPE); |
220 Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QContactDetail), Q_MOVABLE_TYPE); |
183 |
221 |