From 19a5e6f0b9c3232933132dbaa9420aecef497336 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 8 Jul 2014 12:29:46 +0000 Subject: fix for the recent items filtration git-svn-id: http://svn.miranda-ng.org/main/trunk@9731 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/FavContacts/src/favlist.h | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'plugins/FavContacts') diff --git a/plugins/FavContacts/src/favlist.h b/plugins/FavContacts/src/favlist.h index 4aeeed62e8..e3adeabec7 100644 --- a/plugins/FavContacts/src/favlist.h +++ b/plugins/FavContacts/src/favlist.h @@ -67,28 +67,36 @@ class TFavContacts : public LIST < TContactInfo > private: int nGroups; TCHAR *prevGroup; + MIDatabase *db; - void addContact(MIDatabase *db, MCONTACT hContact, bool bManual) + int addContact(MCONTACT hContact, bool bManual) { DBCachedContact *cc = db->m_cache->GetCachedContact(hContact); if (cc == NULL) - return; + return 0; if (db_mc_isEnabled()) { if (cc->IsSub()) // skip subcontacts if MC is enabled - return; + return 0; } else if (cc->IsMeta()) // skip metacontacts if MC is not enabled - return; + return 0; - TCHAR *group = addContact(hContact, bManual)->getGroup(); + TContactInfo *info = new TContactInfo(hContact, bManual); + insert(info); + TCHAR *group = info->getGroup(); if (prevGroup && lstrcmp(prevGroup, group)) ++nGroups; prevGroup = group; + return 1; } public: - TFavContacts() : LIST(5, TContactInfo::cmp) {} + TFavContacts() : LIST(5, TContactInfo::cmp) + { + db = GetCurrentDatabase(); + } + ~TFavContacts() { for (int i = 0; i < this->getCount(); ++i) @@ -97,23 +105,15 @@ public: __forceinline int groupCount() const { return nGroups; } - TContactInfo *addContact(MCONTACT hContact, bool bManual) - { - TContactInfo *info = new TContactInfo(hContact, bManual); - this->insert(info); - return info; - } - void build() { prevGroup = NULL; - MIDatabase *db = GetCurrentDatabase(); nGroups = 1; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) if (db_get_b(hContact, "FavContacts", "IsFavourite", 0)) - addContact(db, hContact, true); + addContact(hContact, true); int nRecent = 0; for (int i = 0; nRecent < g_Options.wMaxRecent; ++i) { @@ -121,10 +121,8 @@ public: if (!hContact) break; - if (!db_get_b(hContact, "FavContacts", "IsFavourite", 0)) { - addContact(db, hContact, false); - nRecent++; - } + if (!db_get_b(hContact, "FavContacts", "IsFavourite", 0)) + nRecent += addContact(hContact, false); } } }; -- cgit v1.2.3