diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-09 20:03:46 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-09 20:03:46 +0000 |
commit | bcb27264ba737778e5d3edad36088bacf74f0236 (patch) | |
tree | fd1f57744dd380b7babe312a0ab5dc60b48854f2 /plugins/Clist_mw | |
parent | 940231dc5a484b03a278900e1880aa083472b601 (diff) |
- short function names allows to write database loops in one string;
- 'continue' operator can be used then;
- multiple bugs fixed in clists;
- code becomes much more compact;
git-svn-id: http://svn.miranda-ng.org/main/trunk@4403 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_mw')
-rw-r--r-- | plugins/Clist_mw/src/clcitems.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_mw/src/clistmod.cpp | 5 | ||||
-rw-r--r-- | plugins/Clist_mw/src/clistsettings.cpp | 5 | ||||
-rw-r--r-- | plugins/Clist_mw/src/contact.cpp | 4 |
4 files changed, 4 insertions, 16 deletions
diff --git a/plugins/Clist_mw/src/clcitems.cpp b/plugins/Clist_mw/src/clcitems.cpp index 245afe3048..af48a8fd0f 100644 --- a/plugins/Clist_mw/src/clcitems.cpp +++ b/plugins/Clist_mw/src/clcitems.cpp @@ -323,7 +323,6 @@ void RebuildEntireList(HWND hwnd,struct ClcData *dat) {
// char *szProto;
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
- HANDLE hContact;
struct ClcContact * cont;
ClcGroup *group;
//DBVARIANT dbv;
@@ -352,9 +351,7 @@ void RebuildEntireList(HWND hwnd,struct ClcData *dat) }
}
- hContact = db_find_first();
- while(hContact) {
-
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
ClcCacheEntry *cacheEntry;
cont = NULL;
cacheEntry = GetContactFullCacheEntry(hContact);
@@ -389,7 +386,6 @@ void RebuildEntireList(HWND hwnd,struct ClcData *dat) if (strcmp(cont->proto,"MetaContacts") == 0)
AddSubcontacts(cont);
}
- hContact = db_find_next(hContact);
}
if (style&CLS_HIDEEMPTYGROUPS) {
diff --git a/plugins/Clist_mw/src/clistmod.cpp b/plugins/Clist_mw/src/clistmod.cpp index 41a73e0041..b6879662c7 100644 --- a/plugins/Clist_mw/src/clistmod.cpp +++ b/plugins/Clist_mw/src/clistmod.cpp @@ -129,11 +129,8 @@ static int ContactListShutdownProc(WPARAM wParam,LPARAM lParam) int LoadContactListModule(void)
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
db_set_s(hContact, "CList", "StatusMsg", "");
- hContact = db_find_next(hContact);
- }
hCListImages = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0);
DefaultImageListColorDepth = db_get_dw(NULL,"CList","DefaultImageListColorDepth",ILC_COLOR32);
diff --git a/plugins/Clist_mw/src/clistsettings.cpp b/plugins/Clist_mw/src/clistsettings.cpp index 28b69254ca..1bd75f0956 100644 --- a/plugins/Clist_mw/src/clistsettings.cpp +++ b/plugins/Clist_mw/src/clistsettings.cpp @@ -46,16 +46,13 @@ void InitDisplayNameCache(SortedList *list) list->sortFunc = (FSortFunc)handleCompare;
list->increment = CallService(MS_DB_CONTACT_GETCOUNT,0,0)+1;
- hContact = db_find_first();
i = 0;
- while (hContact != 0)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
ClcCacheEntry *pdnce = (ClcCacheEntry *)mir_calloc(sizeof(ClcCacheEntry));
pdnce->hContact = hContact;
InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,0);
List_GetIndex(list,pdnce,&idx);
List_Insert(list,pdnce,idx);
- hContact = db_find_next(hContact);
i++;
} }
diff --git a/plugins/Clist_mw/src/contact.cpp b/plugins/Clist_mw/src/contact.cpp index bd2ad97052..589b11bbbc 100644 --- a/plugins/Clist_mw/src/contact.cpp +++ b/plugins/Clist_mw/src/contact.cpp @@ -82,9 +82,8 @@ void LoadContactTree(void) CallService(MS_CLUI_GROUPADDED, i, 0);
int hideOffline = db_get_b(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT);
- HANDLE hContact = db_find_first();
- while(hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
ClcCacheEntry *cacheEntry = GetContactFullCacheEntry(hContact);
if (cacheEntry == NULL) {
MessageBoxA(0,"Fail To Get CacheEntry for hContact","!!!!!",0);
@@ -93,7 +92,6 @@ void LoadContactTree(void) int status = cacheEntry->status;
if ((!hideOffline || status != ID_STATUS_OFFLINE) && !cacheEntry->bIsHidden)
ChangeContactIcon(hContact,ExtIconFromStatusMode(hContact,(char*)cacheEntry->szProto,status),1);
- hContact = db_find_next(hContact);
}
sortByStatus = db_get_b(NULL,"CList","SortByStatus",SETTING_SORTBYSTATUS_DEFAULT);
sortByProto = db_get_b(NULL,"CList","SortByProto",SETTING_SORTBYPROTO_DEFAULT);
|