summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-09 21:10:41 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-09 21:10:41 +0300
commit45e0d9b22b0592bf46e3aec2148770eba9882e46 (patch)
treeb56a8a01e540909439d93f25b7504b9ece7603b9 /src
parentdf6b0c988eb26339d4c7e4a1d0fe3b9717703c28 (diff)
more cleaning
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/clc.cpp16
-rw-r--r--src/mir_app/src/clistmod.cpp8
-rw-r--r--src/mir_app/src/extraicons.cpp8
-rw-r--r--src/mir_app/src/hotkey_opts.cpp49
-rw-r--r--src/mir_app/src/proto_order.cpp3
5 files changed, 44 insertions, 40 deletions
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp
index 382150ff65..a7c8b06698 100644
--- a/src/mir_app/src/clc.cpp
+++ b/src/mir_app/src/clc.cpp
@@ -384,18 +384,19 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam
DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING *)lParam;
if (dbcws->value.type == DBVT_ASCIIZ || dbcws->value.type == DBVT_UTF8) {
int groupId = atoi(dbcws->szSetting) + 1;
- int i, eq;
- //check name of group and ignore message if just being expanded/collapsed
+
+ // check name of group and ignore message if just being expanded/collapsed
if (Clist_FindItem(hwnd, dat, groupId | HCONTACT_ISGROUP, &contact, &group, nullptr)) {
CMStringW szFullName(contact->szText);
while (group->parent) {
ClcContact *cc = nullptr;
- for (i = 0; i < group->parent->cl.getCount(); i++) {
- cc = group->parent->cl[i];
- if (cc->group == group)
+ for (auto &it : group->parent->cl)
+ if (it->group == group) {
+ cc = it;
break;
- }
- if (i == group->parent->cl.getCount()) {
+ }
+
+ if (cc == nullptr) {
szFullName.Empty();
break;
}
@@ -403,6 +404,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam
group = group->parent;
}
+ int eq;
if (dbcws->value.type == DBVT_ASCIIZ)
eq = !mir_wstrcmp(szFullName, _A2T(dbcws->value.pszVal+1));
else
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp
index 8362bf71f9..87c616de47 100644
--- a/src/mir_app/src/clistmod.cpp
+++ b/src/mir_app/src/clistmod.cpp
@@ -52,7 +52,7 @@ struct ProtoIconIndex
int iIconBase;
};
-OBJLIST<ProtoIconIndex> protoIconIndex(5);
+OBJLIST<ProtoIconIndex> protoIconIndex(5, PtrKeySortT);
wchar_t* fnGetStatusModeDescription(int mode, int flags)
{
@@ -180,9 +180,9 @@ static void AddProtoIconIndex(PROTOACCOUNT *pa)
static void RemoveProtoIconIndex(PROTOACCOUNT *pa)
{
- for (int i = 0; i < protoIconIndex.getCount(); i++)
- if (mir_strcmp(protoIconIndex[i].szProto, pa->szModuleName) == 0) {
- protoIconIndex.remove(i);
+ for (auto &it : protoIconIndex)
+ if (mir_strcmp(it->szProto, pa->szModuleName) == 0) {
+ protoIconIndex.remove(it);
break;
}
}
diff --git a/src/mir_app/src/extraicons.cpp b/src/mir_app/src/extraicons.cpp
index 90cac83a2b..937b5e61a8 100644
--- a/src/mir_app/src/extraicons.cpp
+++ b/src/mir_app/src/extraicons.cpp
@@ -159,8 +159,8 @@ static void LoadGroups(LIST<ExtraIconGroup> &groups)
static ExtraIconGroup* IsInGroup(LIST<ExtraIconGroup> &groups, BaseExtraIcon *extra)
{
for (auto &group : groups)
- for (int j = 0; j < group->m_items.getCount(); j++)
- if (extra == group->m_items[j])
+ for (auto &it : group->m_items)
+ if (extra == it)
return group;
return nullptr;
@@ -179,8 +179,8 @@ void RebuildListsBasedOnGroups(LIST<ExtraIconGroup> &groups)
extraIconsBySlot.destroy();
for (auto &group : groups) {
- for (int j = 0; j < group->m_items.getCount(); j++)
- extraIconsByHandle.put(group->m_items[j]->getID() - 1, group);
+ for (auto &it : group->m_items)
+ extraIconsByHandle.put(it->getID()-1, group);
extraIconsBySlot.insert(group);
}
diff --git a/src/mir_app/src/hotkey_opts.cpp b/src/mir_app/src/hotkey_opts.cpp
index 1de4e22f38..e86751c501 100644
--- a/src/mir_app/src/hotkey_opts.cpp
+++ b/src/mir_app/src/hotkey_opts.cpp
@@ -381,39 +381,40 @@ static void sttOptionsSaveItem(THotkeyItem *item)
static void sttBuildHotkeyList(HWND hwndList)
{
- int i, nItems = 0;
ListView_DeleteAllItems(hwndList);
- for (i = 0; i < hotkeys.getCount(); i++) {
+ int nItems = 0;
+ THotkeyItem *prevItem = nullptr;
+ for (auto &item : hotkeys) {
LVITEM lvi = { 0 };
- THotkeyItem *item = hotkeys[i];
- if (item->OptDeleted)
- continue;
+ if (!item->OptDeleted) {
+ if (!prevItem || mir_wstrcmp(item->pwszSection, prevItem->pwszSection)) {
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.iItem = nItems++;
+ lvi.iSubItem = 0;
+ lvi.lParam = 0;
+ lvi.pszText = item->getSection();
+ ListView_InsertItem(hwndList, &lvi);
+ ListView_SetCheckState(hwndList, lvi.iItem, TRUE);
- if (!i || mir_wstrcmp(item->pwszSection, hotkeys[i - 1]->pwszSection)) {
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.iItem = nItems++;
- lvi.iSubItem = 0;
- lvi.lParam = 0;
- lvi.pszText = item->getSection();
- ListView_InsertItem(hwndList, &lvi);
- ListView_SetCheckState(hwndList, lvi.iItem, TRUE);
+ lvi.mask = LVIF_TEXT;
+ lvi.iSubItem = 1;
+ lvi.pszText = item->pwszSection;
+ ListView_SetItem(hwndList, &lvi);
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = 1;
- lvi.pszText = item->pwszSection;
- ListView_SetItem(hwndList, &lvi);
+ lvi.iSubItem = 0;
+ }
- lvi.iSubItem = 0;
+ lvi.mask = LVIF_PARAM | LVIF_INDENT;
+ lvi.iIndent = 1;
+ lvi.iItem = nItems++;
+ lvi.lParam = (LPARAM)item;
+ ListView_InsertItem(hwndList, &lvi);
+ sttOptionsSetupItem(hwndList, nItems - 1, item);
}
- lvi.mask = LVIF_PARAM | LVIF_INDENT;
- lvi.iIndent = 1;
- lvi.iItem = nItems++;
- lvi.lParam = (LPARAM)item;
- ListView_InsertItem(hwndList, &lvi);
- sttOptionsSetupItem(hwndList, nItems - 1, item);
+ prevItem = item;
}
ListView_SortItemsEx(hwndList, sttOptionsSortList, (LPARAM)hwndList);
diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp
index 7456218447..b35c115385 100644
--- a/src/mir_app/src/proto_order.cpp
+++ b/src/mir_app/src/proto_order.cpp
@@ -47,7 +47,8 @@ bool CheckProtocolOrder(void)
for (;;) {
// Find account with this id
for (i = 0; i < accounts.getCount(); i++)
- if (accounts[i]->iOrder == id) break;
+ if (accounts[i]->iOrder == id)
+ break;
// Account with id not found
if (i == accounts.getCount()) {