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/BasicHistory/src/HistoryWindow.cpp | |
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/BasicHistory/src/HistoryWindow.cpp')
-rw-r--r-- | plugins/BasicHistory/src/HistoryWindow.cpp | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index e5cd9c7384..5902dc3de8 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -1773,27 +1773,19 @@ void HistoryWindow::ReloadContacts() }
}
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- if(EventList::GetContactMessageNumber(_hContact) && (metaContactProto == NULL || db_get_b(_hContact, metaContactProto, "IsSubcontact", 0) == 0))
+ HANDLE hContact;
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if(EventList::GetContactMessageNumber(hContact) && (metaContactProto == NULL || db_get_b(hContact, metaContactProto, "IsSubcontact", 0) == 0))
{
- HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
+ HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if(hItem == NULL)
- {
- SendMessage(contactList, CLM_ADDCONTACT, (WPARAM)_hContact, 0);
- }
+ SendMessage(contactList, CLM_ADDCONTACT, (WPARAM)hContact, 0);
}
- else
- {
- HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
+ else {
+ HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if(hItem != NULL)
- {
- SendMessage(contactList, CLM_DELETEITEM, (WPARAM)_hContact, 0);
- }
+ SendMessage(contactList, CLM_DELETEITEM, (WPARAM)hContact, 0);
}
-
- _hContact = db_find_next(_hContact);
}
if(hContact != NULL)
@@ -1944,17 +1936,14 @@ void HistoryWindow::SavePos(bool all) HANDLE contactToSave = hContact;
if(all)
{
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- db_unset(_hContact, MODULE, "history_x");
- db_unset(_hContact, MODULE, "history_y");
- db_unset(_hContact, MODULE, "history_width");
- db_unset(_hContact, MODULE, "history_height");
- db_unset(_hContact, MODULE, "history_ismax");
- db_unset(_hContact, MODULE, "history_splitterv");
- db_unset(_hContact, MODULE, "history_splitter");
- _hContact = db_find_next(_hContact);
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ db_unset(hContact, MODULE, "history_x");
+ db_unset(hContact, MODULE, "history_y");
+ db_unset(hContact, MODULE, "history_width");
+ db_unset(hContact, MODULE, "history_height");
+ db_unset(hContact, MODULE, "history_ismax");
+ db_unset(hContact, MODULE, "history_splitterv");
+ db_unset(hContact, MODULE, "history_splitter");
}
contactToSave = NULL;
@@ -2170,12 +2159,9 @@ void HistoryWindow::DoImport(IImport::ImportType type) std::vector<IImport::ExternalMessage> messages;
std::wstring err;
std::vector<HANDLE> contacts;
- HANDLE _hContact = db_find_first();
- while(_hContact)
- {
- contacts.push_back(_hContact);
- _hContact = db_find_next(_hContact);
- }
+
+ for(hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ contacts.push_back(hContact);
bool changeContact = false;
HANDLE lastContact = hContact;
|