diff options
-rw-r--r-- | pbap/pbap.cpp | 13 | ||||
-rw-r--r-- | pbap/pbap.h | 1 |
2 files changed, 14 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); } diff --git a/pbap/pbap.h b/pbap/pbap.h index 2a5fb61..4b1bd43 100644 --- a/pbap/pbap.h +++ b/pbap/pbap.h @@ -69,6 +69,7 @@ class Contact : public QObject explicit Contact(QString name, QList<QObject *>numbers); virtual ~Contact(); + bool operator<(Contact& c) {return ((this->m_name < c.m_name));}; QString name() {return m_name;}; QList<QObject *>numbers() {return m_numbers;}; |