From 4262e8021c8ffdc0401d9ebe09899f90c654aa18 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 30 Apr 2021 11:37:17 +0300 Subject: we use contact iterators when possible --- plugins/DbEditorPP/src/exportimport.cpp | 25 +++++++++---------------- plugins/DbEditorPP/src/main_window.cpp | 3 +-- 2 files changed, 10 insertions(+), 18 deletions(-) (limited to 'plugins/DbEditorPP') diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index a182418881..4ae33f26d1 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -161,17 +161,15 @@ void exportDB(MCONTACT hContact, const char *module) // exporting entire db if (hContact == INVALID_CONTACT_ID) { - hContact = NULL; - if (module == nullptr) { fprintf(file, "SETTINGS:\n"); mod = modlist.first; while (mod) { - if (IsModuleEmpty(hContact, mod->name)) { + if (IsModuleEmpty(NULL, mod->name)) { mod = (ModSetLinkLinkItem *)mod->next; continue; } - exportModule(hContact, mod->name, file); + exportModule(NULL, mod->name, file); mod = (ModSetLinkLinkItem *)mod->next; if (mod) fprintf(file, "\n"); @@ -182,27 +180,23 @@ void exportDB(MCONTACT hContact, const char *module) module = nullptr; // reset module for all contacts export } - hContact = db_find_first(); - if (hContact) - fprintf(file, "\n\n"); + fprintf(file, "\n\n"); - while (hContact) { - if (ApplyProtoFilter(hContact)) { - hContact = db_find_next(hContact); + for (auto &cc : Contacts()) { + if (ApplyProtoFilter(cc)) continue; - } - fprintf(file, "CONTACT: %s\n", NickFromHContact(hContact)); + fprintf(file, "CONTACT: %s\n", NickFromHContact(cc)); if (module == nullptr) // export all modules { mod = modlist.first; while (mod) { - if (IsModuleEmpty(hContact, mod->name)) { + if (IsModuleEmpty(cc, mod->name)) { mod = (ModSetLinkLinkItem *)mod->next; continue; } - exportModule(hContact, mod->name, file); + exportModule(cc, mod->name, file); mod = (ModSetLinkLinkItem *)mod->next; if (mod) fprintf(file, "\n"); @@ -210,9 +204,8 @@ void exportDB(MCONTACT hContact, const char *module) } else // export module { - exportModule(hContact, module, file); + exportModule(cc, module, file); } - hContact = db_find_next(hContact); } } // exporting a contact diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index a281640f1f..4eb8e0e128 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -555,8 +555,7 @@ void CMainDlg::onSelChanged_Modules(CCtrlTreeView::TEventInfo *ev) Select = 0; if (mtis->type == MODULE) { - _T2A module(text); - PopulateSettings(hContact, module); + PopulateSettings(hContact, _T2A(text)); } else if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) { int multi = 0; -- cgit v1.2.3