summaryrefslogtreecommitdiff
path: root/plugins/BasicHistory/src/Options.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-09 20:03:46 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-09 20:03:46 +0000
commitbcb27264ba737778e5d3edad36088bacf74f0236 (patch)
treefd1f57744dd380b7babe312a0ab5dc60b48854f2 /plugins/BasicHistory/src/Options.cpp
parent940231dc5a484b03a278900e1880aa083472b601 (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/BasicHistory/src/Options.cpp')
-rw-r--r--plugins/BasicHistory/src/Options.cpp41
1 files changed, 10 insertions, 31 deletions
diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp
index 3e9283df10..8e3d159289 100644
--- a/plugins/BasicHistory/src/Options.cpp
+++ b/plugins/BasicHistory/src/Options.cpp
@@ -598,18 +598,12 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks)
sprintf_s(buf, "Task_zipPassword_%d", i);
db_set_s(0, MODULE, buf, it->zipPassword.c_str());
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- db_unset(_hContact, MODULE, buf);
- _hContact = db_find_next(_hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ db_unset(hContact, MODULE, buf);
for(size_t j = 0; j < it->contacts.size(); ++j)
- {
db_set_b(it->contacts[j], MODULE, buf, 1);
- }
it->orderNr = i++;
taskOptions.push_back(*it);
@@ -660,13 +654,9 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks)
sprintf_s(buf, "Task_taskName_%d", i);
db_unset(NULL, MODULE, buf);
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- db_unset(_hContact, MODULE, buf);
- _hContact = db_find_next(_hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ db_unset(hContact, MODULE, buf);
}
LeaveCriticalSection(&criticalSection);
@@ -758,17 +748,10 @@ void Options::LoadTasks()
db_free(&var);
}
- HANDLE _hContact = db_find_first();
sprintf_s(buf, "IsInTask_%d", i);
- while(_hContact)
- {
- if(db_get_b(_hContact, MODULE, buf, 0) == 1)
- {
- to.contacts.push_back(_hContact);
- }
-
- _hContact = db_find_next(_hContact);
- }
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ if(db_get_b(hContact, MODULE, buf, 0) == 1)
+ to.contacts.push_back(hContact);
to.orderNr = i;
taskOptions.push_back(to);
@@ -1765,19 +1748,15 @@ void RebuildList(HWND hwnd, HANDLE hSystem, TaskOptions* to)
void SaveList(HWND hwnd, HANDLE hSystem, TaskOptions* to)
{
- HANDLE hContact, hItem;
-
to->contacts.clear();
if (hSystem)
to->isSystem = SendMessage(hwnd, CLM_GETCHECKMARK, (WPARAM) hSystem, 0) != 0;
- hContact = db_find_first();
- do
- {
- hItem = (HANDLE) SendMessage(hwnd, CLM_FINDCONTACT, (WPARAM) hContact, 0);
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE) SendMessage(hwnd, CLM_FINDCONTACT, (WPARAM) hContact, 0);
if (hItem && SendMessage(hwnd, CLM_GETCHECKMARK, (WPARAM) hItem, 0))
to->contacts.push_back(hContact);
}
- while (hContact = db_find_next(hContact));
}
bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top = NULL, std::wstring* err = NULL, std::wstring* errDescr = NULL);