File: 0029-Add-label-group-field-to-display-label-detail.patch

package info (click to toggle)
qtpim-opensource-src 5.0~git20201102.f9a8f0fc%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 18,236 kB
  • sloc: cpp: 82,965; xml: 91; makefile: 81; javascript: 67
file content (161 lines) | stat: -rw-r--r-- 7,030 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
From 30c235b096c3eae390030372eccdb78105983c70 Mon Sep 17 00:00:00 2001
From: Chris Adams <chris.adams@jollamobile.com>
Date: Fri, 17 May 2019 15:44:58 +1000
Subject: [PATCH 28/32] Add label group field to display label detail

Modern UIs often display contacts in sections grouped by the first
letter of their first (or last, depending on platform and locale
preferences) name.

This commit adds a label group field to the display label detail
which allows a locale-specific label group to be stored for each
contact and exposed to clients.

Change-Id: I40f20fd7e8861e74618c5d0a76fc3c2b8119dfc0
Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
Signed-off-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
---
 src/contacts/details/qcontactdetails.cpp      | 41 ++++++++++++++++---
 src/contacts/details/qcontactdisplaylabel.h   |  6 ++-
 .../qcontactdetails/tst_qcontactdetails.cpp   |  5 +++
 3 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/src/contacts/details/qcontactdetails.cpp b/src/contacts/details/qcontactdetails.cpp
index d8f2ce16..a33dd46b 100644
--- a/src/contacts/details/qcontactdetails.cpp
+++ b/src/contacts/details/qcontactdetails.cpp
@@ -1242,8 +1242,9 @@ class QContactDisplayLabelPrivate : public QContactDetailBuiltinPrivate<QContact
 {
 public:
     QString m_label;
+    QString m_labelGroup;
 
-    enum { FieldCount = 1 };
+    enum { FieldCount = 2 };
 
     QContactDisplayLabelPrivate() : QContactDetailBuiltinPrivate<QContactDisplayLabelPrivate>(QContactDisplayLabel::Type) {}
 };
@@ -1251,6 +1252,7 @@ public:
 template<>
 const QContactDetailBuiltinPrivateBase::Member QContactDetailBuiltinPrivate<QContactDisplayLabelPrivate>::s_members[] = {
     { QContactDetailBuiltinPrivateBase::String, offsetof(QContactDisplayLabelPrivate, m_label) },
+    { QContactDetailBuiltinPrivateBase::String, offsetof(QContactDisplayLabelPrivate, m_labelGroup) },
 };
 
 /*!
@@ -1262,14 +1264,15 @@ const QContactDetail::DetailType QContactDisplayLabel::Type(QContactType::TypeDi
 /*!
    \enum QContactDisplayLabel::DisplayLabelField
    This enumeration defines the fields supported by QContactDisplayLabel.
-   \value FieldLabel The value stored in this field contains the displaylabel.
-   \sa label(), setLabel()
+   \value FieldLabel The value stored in this field contains the display label.
+   \value FieldLabelGroup The value stored in this field contains the label group (section character)
+   \sa label(), setLabel(), setLabelGroup(), labelGroup()
  */
 
 /*!
    \fn QContactDisplayLabel::setLabel(const QString& displayLabel)
-   Sets the displayLabel of the contact which is stored in this detail to \a displayLabel.
-   displayLabel can be for example the first name of a contact.
+   Sets the display label of the contact which is stored in this detail to \a displayLabel.
+   The display label may be equivalent to the formatted name of the contact.
  */
 void QContactDisplayLabel::setLabel(const QString& _value)
 {
@@ -1278,13 +1281,39 @@ void QContactDisplayLabel::setLabel(const QString& _value)
 
 /*!
    \fn QContactDisplayLabel::label() const
-   Returns the displayLabel of the contact which is stored in this detail.
+   Returns the display label of the contact which is stored in this detail.
  */
 QString QContactDisplayLabel::label() const
 {
     return reinterpret_cast<const QContactDisplayLabelPrivate*>(d.constData())->memberValue<QString>(QContactDisplayLabel::FieldLabel);
 }
 
+/*!
+   \fn QContactDisplayLabel::setLabelGroup(const QString& group)
+   Sets the display label group for the contact which is stored in this detail to \a group.
+
+   This is usually the first character of the display label, but may instead
+   be the first character of either the first name or last name of the contact,
+   depending on the platform settings.
+
+   The display label group specifies the group to which the contact belongs,
+   within sectionized views such as fast-scroll ribbons or other subdivided
+   contact list views.
+ */
+void QContactDisplayLabel::setLabelGroup(const QString& _value)
+{
+    reinterpret_cast<QContactDisplayLabelPrivate*>(d.data())->setMemberValue<QString>(QContactDisplayLabel::FieldLabelGroup, _value);
+}
+
+/*!
+   \fn QContactDisplayLabel::labelGroup() const
+   Returns the display label group of the contact which is stored in this detail.
+ */
+QString QContactDisplayLabel::labelGroup() const
+{
+    return reinterpret_cast<const QContactDisplayLabelPrivate*>(d.constData())->memberValue<QString>(QContactDisplayLabel::FieldLabelGroup);
+}
+
 
 /* ==================== QContactGender ======================= */
 
diff --git a/src/contacts/details/qcontactdisplaylabel.h b/src/contacts/details/qcontactdisplaylabel.h
index 152717df..6aba5fb9 100644
--- a/src/contacts/details/qcontactdisplaylabel.h
+++ b/src/contacts/details/qcontactdisplaylabel.h
@@ -57,12 +57,16 @@ public:
 #endif
 
     enum DisplayLabelField {
-        FieldLabel = 0
+        FieldLabel = 0,
+        FieldLabelGroup
     };
 
     void setLabel(const QString& displayLabel);
     QString label() const;
 
+    void setLabelGroup(const QString& displayLabelGroup);
+    QString labelGroup() const;
+
     static QContactFilter match(const QString& label);
 };
 
diff --git a/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp b/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp
index 65197506..ba251258 100644
--- a/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp
+++ b/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp
@@ -367,13 +367,17 @@ void tst_QContactDetails::displayLabel()
 
     // test property set
     d1.setLabel("1234");
+    d1.setLabelGroup("1");
     QCOMPARE(d1.label(), QString("1234"));
     QCOMPARE(d1.value(QContactDisplayLabel::FieldLabel).toString(), QString("1234"));
+    QCOMPARE(d1.labelGroup(), QString("1"));
+    QCOMPARE(d1.value(QContactDisplayLabel::FieldLabelGroup).toString(), QString("1"));
 
     // test property add
     QVERIFY(c.saveDetail(&d1));
     QCOMPARE(c.details(QContactDisplayLabel::Type).count(), 1);
     QCOMPARE(QContactDisplayLabel(c.details(QContactDisplayLabel::Type).value(0)).label(), d1.label());
+    QCOMPARE(QContactDisplayLabel(c.details(QContactDisplayLabel::Type).value(0)).labelGroup(), d1.labelGroup());
 
     // test property update
     d1.setValue(QContactDisplayLabel::FieldContext, QContactDetail::ContextWork);
@@ -381,6 +385,7 @@ void tst_QContactDetails::displayLabel()
     QVERIFY(c.saveDetail(&d1));
     QCOMPARE(c.details(QContactDisplayLabel::Type).value(0).value(QContactDisplayLabel::FieldContext).value<QList<int> >(), QList<int>() << QContactDetail::ContextWork);
     QCOMPARE(c.details(QContactDisplayLabel::Type).value(0).value(QContactDisplayLabel::FieldLabel).toString(), QString("12345"));
+    QCOMPARE(c.details(QContactDisplayLabel::Type).value(0).value(QContactDisplayLabel::FieldLabelGroup).toString(), QString("1"));
 
     // test property remove
     QVERIFY(c.removeDetail(&d1));
-- 
2.30.2