File: 1006_add-gsettings-for-qtcontacts-sqlite.patch

package info (click to toggle)
qtcontacts-sqlite 0.3.20-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,952 kB
  • sloc: cpp: 32,880; ansic: 1,269; xml: 62; makefile: 32; sh: 18
file content (141 lines) | stat: -rw-r--r-- 5,135 bytes parent folder | download
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
Author: Lionel Duboeuf <lduboeuf@ouvaton.org>
Description: add gsettings for qtcontacts-sqlite

--- qtcontacts-sqlite.orig/config.pri
+++ qtcontacts-sqlite/config.pri
@@ -11,4 +11,9 @@ packagesExist(mlite5) {
     PKGCONFIG += mlite5
 }
 
+packagesExist(gsettings-qt) {
+    PKGCONFIG += gsettings-qt
+    DEFINES += HAS_GSETTINGS
+} 
+
 DEFINES += CONTACTS_DATABASE_PATH=\"\\\"$$[QT_INSTALL_LIBS]/qtcontacts-sqlite-qt5/\\\"\"
--- qtcontacts-sqlite.orig/qtcontacts-sqlite.pro
+++ qtcontacts-sqlite/qtcontacts-sqlite.pro
@@ -4,4 +4,11 @@ SUBDIRS = \
         tests
 OTHER_FILES += rpm/qtcontacts-sqlite-qt5.spec
 
+packagesExist(gsettings-qt) {
+    schemas.path = $${PREFIX}/share/glib-2.0/schemas
+    schemas.files = schemas/org.nemomobile.contacts.gschema.xml
+    
+    INSTALLS += schemas
+}
+
 tests.depends = src
--- /dev/null
+++ qtcontacts-sqlite/schemas/org.nemomobile.contacts.gschema.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+  <schema id="org.nemomobile.contacts" path="/org/nemomobile/contacts/">
+    <key name="group-property" type="s">
+      <summary>Contact group property</summary>
+      <description>Allow to group contact by property.</description>
+      <default>"firstName"</default>
+    </key>
+    <key name="display-label-order" type="i">
+      <summary>Contact displayLabel policy</summary>
+      <description>Allow to change display label structure, 0=FirstName First, 1=LastName First.</description>
+      <default>0</default>
+    </key>
+    <key name="sort-property" type="s">
+      <summary>Contact property sort</summary>
+      <description>Allow sorting contact by a property.</description>
+      <default>"firstName"</default>
+    </key>
+  </schema>
+</schemalist>
--- qtcontacts-sqlite.orig/src/engine/contactsdatabase.cpp
+++ qtcontacts-sqlite/src/engine/contactsdatabase.cpp
@@ -2311,7 +2311,7 @@ static bool executeDisplayLabelGroupLoca
         }
     }
 
-#ifndef HAS_MLITE
+#if !defined(HAS_MLITE) && !defined(HAS_GSETTINGS)
     bool sameGroupProperty = true;
 #else
     // also determine if the current system setting for deriving the group from the first vs last
@@ -3268,6 +3268,9 @@ ContactsDatabase::ContactsDatabase(Conta
 #ifdef HAS_MLITE
     , m_groupPropertyConf(QStringLiteral("/org/nemomobile/contacts/group_property"))
 #endif // HAS_MLITE
+#ifdef HAS_GSETTINGS
+    , m_groupPropertyConf(new QGSettings("org.nemomobile.contacts", "/org/nemomobile/contacts/"))
+#endif // HAS_GSETTINGS
 {
 #ifdef HAS_MLITE
     QObject::connect(&m_groupPropertyConf, &MGConfItem::valueChanged, [this, engine] {
@@ -3279,6 +3282,19 @@ ContactsDatabase::ContactsDatabase(Conta
         QMetaObject::invokeMethod(engine, "dataChanged", Qt::QueuedConnection);
     });
 #endif // HAS_MLITE
+#ifdef HAS_GSETTINGS
+    QObject::connect(m_groupPropertyConf, &QGSettings::changed, [this, engine](const QString &key) {
+        if (key == QLatin1String("group-property")) {
+            qDebug() << "group-property changed, regenerate display Label group";
+            this->regenerateDisplayLabelGroups();
+            // expensive, but if we don't do it, in multi-process case some clients may not get updated...
+            // if contacts backend were daemonised, this problem would go away...
+            // Emit some engine signals asynchronously.
+            QMetaObject::invokeMethod(engine, "_q_displayLabelGroupsChanged", Qt::QueuedConnection);
+            QMetaObject::invokeMethod(engine, "dataChanged", Qt::QueuedConnection);
+        }
+    });
+#endif
 }
 
 ContactsDatabase::~ContactsDatabase()
@@ -3480,6 +3496,8 @@ bool ContactsDatabase::open(const QStrin
         }
     }
 
+
+
     // Attach to the transient store - any process can create it, but only the primary connection of each
     if (!m_transientStore.open(nonprivileged, !secondaryConnection, !databasePreexisting)) {
         QTCONTACTS_SQLITE_WARNING(QString::fromLatin1("Failed to open contacts transient store"));
@@ -3894,8 +3912,16 @@ void ContactsDatabase::regenerateDisplay
 QString ContactsDatabase::displayLabelGroupPreferredProperty() const
 {
     QString retn(QStringLiteral("QContactName::FieldFirstName"));
+
+
 #ifdef HAS_MLITE
     const QVariant groupPropertyConf = m_groupPropertyConf.value();
+#endif
+#ifdef HAS_GSETTINGS
+    const QVariant groupPropertyConf = m_groupPropertyConf->get(QStringLiteral("group-property"));
+#endif
+
+#if defined(HAS_MLITE) || defined(HAS_GSETTINGS)
     if (groupPropertyConf.isValid()) {
         const QString gpcString = groupPropertyConf.toString();
         if (gpcString.compare(QStringLiteral("FirstName"), Qt::CaseInsensitive) == 0) {
--- qtcontacts-sqlite.orig/src/engine/contactsdatabase.h
+++ qtcontacts-sqlite/src/engine/contactsdatabase.h
@@ -40,6 +40,9 @@
 #ifdef HAS_MLITE
 #include <mgconfitem.h>
 #endif
+#ifdef HAS_GSETTINGS
+#include <QGSettings>
+#endif
 
 #include <QHash>
 #include <QMutex>
@@ -208,6 +211,9 @@ private:
 #ifdef HAS_MLITE
     MGConfItem m_groupPropertyConf;
 #endif // HAS_MLITE
+#ifdef HAS_GSETTINGS
+    QGSettings *m_groupPropertyConf;
+#endif // HAS_GSETTINGS
 };
 
 #endif