summaryrefslogtreecommitdiffstats
path: root/pbap/pbap.cpp
diff options
context:
space:
mode:
authorMatt Porter <mporter@konsulko.com>2018-06-26 11:51:51 -0400
committerMatt Porter <mporter@konsulko.com>2018-06-26 12:05:20 -0400
commitbc9d7b82208767b92cb975e4a2c3dc43983fb6f9 (patch)
treea5b3c39f1e0a8a9b633a339b1f5c67cc9fac464e /pbap/pbap.cpp
parent5506cf50dba098399bbacb73533603d186d8a91e (diff)
pbap: sort and trim contact list
Sort the contacts list alphabetically and trim out bogus entries. Bug-AGL: SPEC-1436 Change-Id: I71e4311bb7638750732ba27fbeaa76c063113c46 Signed-off-by: Matt Porter <mporter@konsulko.com>
Diffstat (limited to 'pbap/pbap.cpp')
-rw-r--r--pbap/pbap.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/pbap/pbap.cpp b/pbap/pbap.cpp
index ad3eec7..20024a7 100644
--- a/pbap/pbap.cpp
+++ b/pbap/pbap.cpp
@@ -137,6 +137,14 @@ void Pbap::search(QString number)
tmsg->deleteLater();
}
+bool compareContactPtr(QObject *a, QObject *b)
+{
+ Contact *contactA = qobject_cast<Contact *>(a);
+ Contact *contactB = qobject_cast<Contact *>(b);
+
+ return (*contactA < *contactB);
+}
+
void Pbap::updateContacts(QString vcards)
{
QString name, number, type;
@@ -147,6 +155,8 @@ void Pbap::updateContacts(QString vcards)
vCardProperty name_prop = vcard.property(VC_FORMATTED_NAME);
QStringList values = name_prop.values();
name = values.at(vCardProperty::DefaultValue);
+ if (name.isEmpty() || name.startsWith('#'))
+ continue;
/*
* libvcard has no member function to return a list of named
* properties, so we iterate over all properties and parse
@@ -166,6 +176,9 @@ void Pbap::updateContacts(QString vcards)
}
m_contacts.append(new Contact(name, numbers));
}
+
+ std::sort(m_contacts.begin(), m_contacts.end(), compareContactPtr);
+
refreshCalls(100);
}