diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-16 20:01:14 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-16 20:01:14 +0300 |
commit | 39390b02dbd5aa7eb21a83773fa561b39f8828bc (patch) | |
tree | 7982eda1257f7466b5663c2865fdb7804c397257 /plugins/DbEditorPP/src | |
parent | 5046973a41e412afd06d6a78a3b9bce226e3cf50 (diff) |
always hated these long expressions: contact_iter makes them much shorter
Diffstat (limited to 'plugins/DbEditorPP/src')
-rw-r--r-- | plugins/DbEditorPP/src/copymodule.cpp | 4 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/deletemodule.cpp | 5 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/exportimport.cpp | 3 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/findwindow.cpp | 3 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/modsettingenum.cpp | 2 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/moduletree.cpp | 6 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/renamemodule.cpp | 2 |
7 files changed, 12 insertions, 13 deletions
diff --git a/plugins/DbEditorPP/src/copymodule.cpp b/plugins/DbEditorPP/src/copymodule.cpp index 419efd7ff7..61962fa89c 100644 --- a/plugins/DbEditorPP/src/copymodule.cpp +++ b/plugins/DbEditorPP/src/copymodule.cpp @@ -31,7 +31,7 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar mir_snwprintf(msg, TranslateT("Copy module \"%s\""), _A2T(mac->module));
SetWindowText(hwnd, msg);
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
if (ApplyProtoFilter(hContact))
continue;
@@ -61,7 +61,7 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar }
else {
SetCursor(LoadCursor(nullptr, IDC_WAIT));
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
copyModule(mac->module, mac->hContact, hContact);
SetCursor(LoadCursor(nullptr, IDC_ARROW));
diff --git a/plugins/DbEditorPP/src/deletemodule.cpp b/plugins/DbEditorPP/src/deletemodule.cpp index 41b3a123ed..5d3104d233 100644 --- a/plugins/DbEditorPP/src/deletemodule.cpp +++ b/plugins/DbEditorPP/src/deletemodule.cpp @@ -46,7 +46,8 @@ void __cdecl PopulateModuleDropListThreadFunc(void *param) module = module->next;
continue;
}
- for (MCONTACT hContact = db_find_first(); moduleEmpty && hContact; hContact = db_find_next(hContact)) {
+
+ for (auto &hContact : contact_iter()) {
if (!IsModuleEmpty(hContact, module->name)) {
SendDlgItemMessageA(hwnd, IDC_CONTACTS, CB_ADDSTRING, 0, (LPARAM)module->name);
moduleEmpty = 0;
@@ -93,7 +94,7 @@ INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) char module[FLD_SIZE];
GetDlgItemTextA(hwnd, IDC_CONTACTS, module, _countof(module));
SetCursor(LoadCursor(nullptr, IDC_WAIT));
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
deleteModule(hContact, module, 0);
// do the null
diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index e9c6efe468..82fc93f5eb 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -187,7 +187,6 @@ void exportDB(MCONTACT hContact, const char *module) fprintf(file, "\n\n");
while (hContact) {
-
if (ApplyProtoFilter(hContact)) {
hContact = db_find_next(hContact);
continue;
@@ -257,7 +256,7 @@ MCONTACT CheckNewContact(const char *myProto, const char *uid, const char *myNam {
char szProto[FLD_SIZE], szName[NAME_SIZE];
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
if (!db_get_static(hContact, "Protocol", "p", szProto, _countof(szProto)))
if (!mir_strcmp(szProto, myProto))
if (GetValueA(hContact, szProto, uid, szName, _countof(szName)) && !mir_strcmp(szName, myName))
diff --git a/plugins/DbEditorPP/src/findwindow.cpp b/plugins/DbEditorPP/src/findwindow.cpp index ccfc80060a..ca09d1750c 100644 --- a/plugins/DbEditorPP/src/findwindow.cpp +++ b/plugins/DbEditorPP/src/findwindow.cpp @@ -404,8 +404,7 @@ void __cdecl FindSettings(LPVOID param) hContact = db_find_first();
}
}
- else
- hContact = db_find_next(hContact);
+ else hContact = db_find_next(hContact);
for (module = ModuleList.first; module; module = module->next) {
diff --git a/plugins/DbEditorPP/src/modsettingenum.cpp b/plugins/DbEditorPP/src/modsettingenum.cpp index 79e734baf3..eef1292d39 100644 --- a/plugins/DbEditorPP/src/modsettingenum.cpp +++ b/plugins/DbEditorPP/src/modsettingenum.cpp @@ -160,7 +160,7 @@ int fixResidentSettings() fixing = 1;
int cnt = 0;
- for (MCONTACT hContact = db_find_first(); hContact != 0; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
for (ModSetLinkLinkItem *module = ModuleList.first; module; module = module->next) {
if (IsModuleEmpty(hContact, module->name))
continue;
diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index e23dfe866a..662c66ea85 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -46,9 +46,9 @@ int doContacts(HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelec char szProto[FLD_SIZE];
wchar_t name[NAME_SIZE];
- for (MCONTACT hContact = db_find_first(); hContact && hwnd2mainWindow; hContact = db_find_next(hContact)) {
-
- if (ApplyProtoFilter(hContact)) continue;
+ for (auto &hContact : contact_iter()) {
+ if (ApplyProtoFilter(hContact))
+ continue;
// add the contact
lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
diff --git a/plugins/DbEditorPP/src/renamemodule.cpp b/plugins/DbEditorPP/src/renamemodule.cpp index 74e9e00a4a..c4b12f9b88 100644 --- a/plugins/DbEditorPP/src/renamemodule.cpp +++ b/plugins/DbEditorPP/src/renamemodule.cpp @@ -44,7 +44,7 @@ static INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA if (IsDlgButtonChecked(hwnd, CHK_ADD2ALL)) {
// null contact
db_set_b(NULL, modulename, "(Default)", 0);
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
db_set_b(hContact, modulename, "(Default)", 0);
}
else db_set_b((MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA), modulename, "(Default)", 0);
|