diff options
Diffstat (limited to 'Swift/Controllers/Contact.cpp')
-rw-r--r-- | Swift/Controllers/Contact.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Swift/Controllers/Contact.cpp b/Swift/Controllers/Contact.cpp index 198443d..be2b83a 100644 --- a/Swift/Controllers/Contact.cpp +++ b/Swift/Controllers/Contact.cpp @@ -11,23 +11,31 @@ namespace Swift { Contact::Contact() { } Contact::Contact(const std::string& name, const JID& jid, StatusShow::Type statusType, const boost::filesystem::path& path) : name(name), jid(jid), statusType(statusType), avatarPath(path) { } bool Contact::lexicographicalSortPredicate(const Contact::ref& a, const Contact::ref& b) { - return a->jid < b->jid; + if (a->jid.isValid() && b->jid.isValid()) { + return a->jid < b->jid; + } else { + return a->name < b->name; + } } bool Contact::equalityPredicate(const Contact::ref& a, const Contact::ref& b) { - return a->jid == b->jid; + if (a->jid.isValid() && b->jid.isValid()) { + return a->jid == b->jid; + } else { + return a->name == b->name; + } } bool Contact::sortPredicate(const Contact::ref& a, const Contact::ref& b, const std::string& search) { /* perform case insensitive comparisons */ std::string aLower = a->name; boost::to_lower(aLower); std::string bLower = b->name; boost::to_lower(bLower); std::string searchLower = search; |