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/BasicHistory/src | |
parent | 5046973a41e412afd06d6a78a3b9bce226e3cf50 (diff) |
always hated these long expressions: contact_iter makes them much shorter
Diffstat (limited to 'plugins/BasicHistory/src')
-rw-r--r-- | plugins/BasicHistory/src/HistoryWindow.cpp | 22 | ||||
-rw-r--r-- | plugins/BasicHistory/src/Options.cpp | 8 |
2 files changed, 19 insertions, 11 deletions
diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index 4f035f5255..88f20deb9f 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -1496,7 +1496,7 @@ void HistoryWindow::ReloadContacts() }
}
- for (MCONTACT _hContact = db_find_first(); _hContact; _hContact = db_find_next(_hContact)) {
+ for (auto &_hContact : contact_iter()) {
if (HistoryEventList::GetContactMessageNumber(_hContact) && (metaContactProto == nullptr || !db_mc_isSub(_hContact))) {
HANDLE hItem = (HANDLE)SendMessage(contactList, CLM_FINDCONTACT, (WPARAM)_hContact, 0);
if (hItem == nullptr)
@@ -1627,7 +1627,7 @@ void HistoryWindow::SavePos(bool all) {
MCONTACT contactToSave = m_hContact;
if (all) {
- for (MCONTACT _hContact = db_find_first(); _hContact; _hContact = db_find_next(_hContact)) {
+ for (auto &_hContact : contact_iter()) {
db_unset(_hContact, MODULE, "history_x");
db_unset(_hContact, MODULE, "history_y");
db_unset(_hContact, MODULE, "history_width");
@@ -1825,7 +1825,7 @@ void HistoryWindow::DoImport(IImport::ImportType type) std::wstring err;
std::vector<MCONTACT> contacts;
- for (MCONTACT _hContact = db_find_first(); _hContact != NULL; _hContact = db_find_next(_hContact))
+ for (auto &_hContact : contact_iter())
contacts.push_back(_hContact);
bool changeContact = false;
@@ -2049,7 +2049,7 @@ MCONTACT HistoryWindow::GetNextContact(MCONTACT hContact, int adder) HWND contactList = GetDlgItem(m_hWnd, IDC_LIST_CONTACTS);
if (adder > 0) {
if (hContact != NULL) {
- for (MCONTACT cc = db_find_next(hContact); cc; cc = db_find_next(cc))
+ for (auto &cc : contact_iter())
if (SendMessage(contactList, CLM_FINDCONTACT, cc, 0) != NULL)
return cc;
@@ -2057,19 +2057,27 @@ MCONTACT HistoryWindow::GetNextContact(MCONTACT hContact, int adder) return NULL;
}
- for (MCONTACT cc = db_find_first(); cc && cc != hContact; cc = db_find_next(cc))
+ for (auto &cc : contact_iter()) {
+ if (cc == hContact)
+ break;
+
if (SendMessage(contactList, CLM_FINDCONTACT, cc, 0) != NULL)
return cc;
+ }
}
else {
MCONTACT lastContact = NULL;
- for (MCONTACT cc = db_find_first(); cc && cc != hContact; cc = db_find_next(cc))
+ for (auto &cc : contact_iter()) {
+ if (cc == hContact)
+ break;
+
if (SendMessage(contactList, CLM_FINDCONTACT, cc, 0) != NULL)
lastContact = cc;
+ }
if (hContact != NULL) {
if (lastContact == NULL && !HistoryEventList::GetContactMessageNumber(NULL)) {
- for (MCONTACT cc = db_find_next(hContact); cc; cc = db_find_next(cc))
+ for (auto &cc : contact_iter())
if (SendMessage(contactList, CLM_FINDCONTACT, cc, 0) != NULL)
lastContact = cc;
}
diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp index 6df06b59b0..b86a6cc91f 100644 --- a/plugins/BasicHistory/src/Options.cpp +++ b/plugins/BasicHistory/src/Options.cpp @@ -550,7 +550,7 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) db_set_s(0, MODULE, buf, it->zipPassword.c_str());
mir_snprintf(buf, "IsInTask_%d", i);
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
db_unset(hContact, MODULE, buf);
for (size_t j = 0; j < it->contacts.size(); ++j)
@@ -605,7 +605,7 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks) db_unset(NULL, MODULE, buf);
mir_snprintf(buf, "IsInTask_%d", i);
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
db_unset(hContact, MODULE, buf);
}
}
@@ -691,7 +691,7 @@ void Options::LoadTasks() }
mir_snprintf(buf, "IsInTask_%d", i);
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (auto &hContact : contact_iter())
if (db_get_b(hContact, MODULE, buf, 0) == 1)
to.contacts.push_back(hContact);
@@ -1562,7 +1562,7 @@ void SaveList(HWND hwnd, MCONTACT hSystem, TaskOptions* to) if (hSystem)
to->isSystem = SendMessage(hwnd, CLM_GETCHECKMARK, (WPARAM)hSystem, 0) != 0;
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (auto &hContact : contact_iter()) {
HANDLE hItem = (HANDLE)SendMessage(hwnd, CLM_FINDCONTACT, hContact, 0);
if (hItem && SendMessage(hwnd, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
to->contacts.push_back(hContact);
|