diff options
author | George Hazan <ghazan@miranda.im> | 2018-02-21 18:29:19 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-02-21 18:40:13 +0300 |
commit | 877a1c362c0b106b251cf353f77397d1b5b08b42 (patch) | |
tree | 0291da0a01fbc8428fb1e544567a398d1e33add7 /plugins | |
parent | fb9f17d1290be657ea8cc85dd02c8419cad1d9c4 (diff) |
Clist_Modern: C++'11 iterators
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Clist_modern/src/cluiframes.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_aniavatars.cpp | 43 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_cachefuncs.cpp | 16 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clistevents.cpp | 9 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clui.cpp | 9 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_skinengine.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_statusbar.cpp | 24 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_xptheme.cpp | 4 |
8 files changed, 52 insertions, 61 deletions
diff --git a/plugins/Clist_modern/src/cluiframes.cpp b/plugins/Clist_modern/src/cluiframes.cpp index 298c582c05..0a9826c5d9 100644 --- a/plugins/Clist_modern/src/cluiframes.cpp +++ b/plugins/Clist_modern/src/cluiframes.cpp @@ -1480,8 +1480,8 @@ static int CLUIFramesLoadMainMenu() if (_fCluiFramesModuleNotStarted)
return -1;
- for (int i = 0; i < g_frameMenus.getCount(); i++)
- Menu_RemoveItem(g_frameMenus[i]);
+ for (auto &it : g_frameMenus)
+ Menu_RemoveItem(it);
g_frameMenus.destroy();
// create frames menu
diff --git a/plugins/Clist_modern/src/modern_aniavatars.cpp b/plugins/Clist_modern/src/modern_aniavatars.cpp index fd8a616358..2e3686782f 100644 --- a/plugins/Clist_modern/src/modern_aniavatars.cpp +++ b/plugins/Clist_modern/src/modern_aniavatars.cpp @@ -253,14 +253,14 @@ static HWND _AniAva_CreateAvatarWindowSync(wchar_t *szFileName) static void _AniAva_PausePainting()
{
- for (int i = 0; i < s_Objects.getCount(); i++)
- SendMessage(s_Objects[i].hWindow, AAM_PAUSE, 0, 0);
+ for (auto &it : s_Objects)
+ SendMessage(it->hWindow, AAM_PAUSE, 0, 0);
}
static void _AniAva_ResumePainting()
{
- for (int i = 0; i < s_Objects.getCount(); i++)
- SendNotifyMessage(s_Objects[i].hWindow, AAM_RESUME, 0, 0);
+ for (auto &it : s_Objects)
+ SendNotifyMessage(it->hWindow, AAM_RESUME, 0, 0);
}
static void _AniAva_ReduceAvatarImages(int startY, int dY, BOOL bDestroyWindow)
@@ -414,8 +414,7 @@ static int _AniAva_LoadAvatarFromImage(wchar_t * szFileName, int width, int heig static BOOL _AniAva_GetAvatarImageInfo(DWORD dwAvatarUniqId, ANIAVATARIMAGEINFO * avii)
{
BOOL res = FALSE;
- for (int j = 0; j < s_AniAvatarList.getCount(); j++) {
- ANIAVA_INFO * aai = (ANIAVA_INFO *)s_AniAvatarList[j];
+ for (auto &aai : s_AniAvatarList) {
if (aai->dwAvatarUniqId == dwAvatarUniqId) {
avii->nFramesCount = aai->nFrameCount;
avii->pFrameDelays = aai->pFrameDelays;
@@ -829,8 +828,8 @@ int AniAva_InvalidateAvatarPositions(MCONTACT hContact) pai->bInvalidPos++;
}
else
- for (int i = 0; i < s_Objects.getCount(); i++)
- s_Objects[i].bInvalidPos++;
+ for (auto &it : s_Objects)
+ it->bInvalidPos++;
return 1;
}
@@ -843,12 +842,11 @@ int AniAva_RedrawAllAvatars(BOOL updateZOrder) aacheck 0;
mir_cslock lck(s_CS);
updateZOrder = 1;
- for (int i = 0; i < s_Objects.getCount(); i++) {
- ANIAVA_OBJECT &pai = s_Objects[i];
+ for (auto &it : s_Objects) {
if (updateZOrder)
- SendMessage(pai.hWindow, AAM_REDRAW, (WPARAM)updateZOrder, 0);
+ SendMessage(it->hWindow, AAM_REDRAW, (WPARAM)updateZOrder, 0);
else
- SendNotifyMessage(pai.hWindow, AAM_REDRAW, (WPARAM)updateZOrder, 0);
+ SendNotifyMessage(it->hWindow, AAM_REDRAW, (WPARAM)updateZOrder, 0);
}
return 1;
}
@@ -876,15 +874,13 @@ int AniAva_RemoveInvalidatedAvatars() aacheck 0;
mir_cslock lck(s_CS);
- for (int i = 0; i < s_Objects.getCount(); i++) {
- ANIAVA_OBJECT &pai = s_Objects[i];
- if (pai.hWindow && pai.bInvalidPos) {
- SendMessage(pai.hWindow, AAM_STOP, 0, 0);
- pai.bInvalidPos = 0;
- DestroyWindow(pai.hWindow);
- pai.hWindow = nullptr;
+ for (auto &it : s_Objects)
+ if (it->hWindow && it->bInvalidPos) {
+ SendMessage(it->hWindow, AAM_STOP, 0, 0);
+ it->bInvalidPos = 0;
+ DestroyWindow(it->hWindow);
+ it->hWindow = nullptr;
}
- }
return 1;
}
@@ -975,8 +971,8 @@ void AniAva_UpdateParent() aacheck;
mir_cslock lck(s_CS);
HWND parent = GetAncestor(pcli->hwndContactList, GA_PARENT);
- for (int i = 0; i < s_Objects.getCount(); i++)
- SendMessage(s_Objects[i].hWindow, AAM_SETPARENT, (WPARAM)parent, 0);
+ for (auto &it : s_Objects)
+ SendMessage(it->hWindow, AAM_SETPARENT, (WPARAM)parent, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1021,8 +1017,7 @@ int AniAva_UnloadModule() s_bModuleStarted = FALSE;
s_Objects.destroy();
- for (int i = 0; i < s_AniAvatarList.getCount(); i++) {
- ANIAVA_INFO *aai = s_AniAvatarList[i];
+ for (auto &aai : s_AniAvatarList) {
mir_free(aai->tcsFilename);
free(aai->pFrameDelays);
mir_free(aai);
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index db9283cec6..50056ee3df 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -602,19 +602,19 @@ static BOOL ExecuteOnAllContactsOfGroup(ClcGroup *group, ExecuteOnAllContactsFun if (!group) return TRUE; - for (int scanIndex = 0; scanIndex < group->cl.getCount(); scanIndex++) { - if (group->cl[scanIndex]->type == CLCIT_CONTACT) { - if (!func(group->cl[scanIndex], FALSE, param)) + for (auto &it : group->cl) { + if (it->type == CLCIT_CONTACT) { + if (!func(it, FALSE, param)) return FALSE; - if (group->cl[scanIndex]->iSubAllocated > 0) { - for (int i = 0; i < group->cl[scanIndex]->iSubAllocated; i++) - if (!func(&group->cl[scanIndex]->subcontacts[i], TRUE, param)) + if (it->iSubAllocated > 0) { + for (int i = 0; i < it->iSubAllocated; i++) + if (!func(&it->subcontacts[i], TRUE, param)) return FALSE; } } - else if (group->cl[scanIndex]->type == CLCIT_GROUP) - if (!ExecuteOnAllContactsOfGroup(group->cl[scanIndex]->group, func, param)) + else if (it->type == CLCIT_GROUP) + if (!ExecuteOnAllContactsOfGroup(it->group, func, param)) return FALSE; } diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index b2c5d33666..77032c27c5 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -56,11 +56,10 @@ struct NotifyMenuItemExData static CLISTEVENT* MyGetEvent(int iSelection)
{
- for (int i = 0; i < pcli->events->getCount(); i++) {
- CListEvent &p = (*pcli->events)[i];
- if (p.menuId == iSelection)
- return &p;
- }
+ for (auto &it : *pcli->events)
+ if (it->menuId == iSelection)
+ return it;
+
return nullptr;
}
diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 6f0eb8630a..1ebb35d4e7 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -946,9 +946,9 @@ static HICON CLUI_GetConnectingIconForProto(char *szAccoName, int idx) static PROTOTICKS* CLUI_GetProtoTicksByProto(char *szProto)
{
- for (int i = 0; i < arTicks.getCount(); i++)
- if (!mir_strcmp(arTicks[i].szProto, szProto))
- return &arTicks[i];
+ for (auto &it : arTicks)
+ if (!mir_strcmp(it->szProto, szProto))
+ return it;
PROTOTICKS *pt = new PROTOTICKS();
pt->szProto = mir_strdup(szProto);
@@ -1941,8 +1941,7 @@ LRESULT CLUI::OnSetFocus(UINT, WPARAM, LPARAM) LRESULT CLUI::OnStatusBarUpdateTimer(UINT msg, WPARAM wParam, LPARAM lParam)
{
- for (int i = 0; i < arTicks.getCount(); i++) {
- PROTOTICKS *pt = &arTicks[i];
+ for (auto &pt : arTicks) {
if (!pt->bTimerCreated)
continue;
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index 74145c1734..9ac08875bd 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -415,8 +415,8 @@ int SkinEngineUnloadModule() mir_free_and_nil(g_SkinObjectList.pMaskList); mir_free_and_nil(MainModernMaskList); - for (int i = 0; i < arEffectStack.getCount(); i++) - mir_free(arEffectStack[i]); + for (auto &it : arEffectStack) + mir_free(it); arEffectStack.destroy(); if (g_pCachedWindow) { diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index 8308345840..678faaa1cd 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -683,12 +683,11 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa KillTimer(hwnd, TM_STATUSBAR);
GetCursorPos(&pt);
if (pt.x == lastpnt.x && pt.y == lastpnt.y) {
- RECT rc;
ScreenToClient(hwnd, &pt);
- for (int i = 0; i < ProtosData.getCount(); i++) {
- rc = ProtosData[i].protoRect;
+ for (auto &it : ProtosData) {
+ RECT rc = it->protoRect;
if (PtInRect(&rc, pt)) {
- NotifyEventHooks(g_CluiData.hEventStatusBarShowToolTip, (WPARAM)ProtosData[i].szAccountName, 0);
+ NotifyEventHooks(g_CluiData.hEventStatusBarShowToolTip, (WPARAM)it->szAccountName, 0);
CLUI_SafeSetTimer(hwnd, TM_STATUSBARHIDE, db_get_w(0, "CLUIFrames", "HideToolTipTime", SETTING_HIDETOOLTIPTIME_DEFAULT), nullptr);
tooltipshoing = TRUE;
ClientToScreen(hwnd, &pt);
@@ -749,15 +748,14 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa NotifyEventHooks(g_CluiData.hEventStatusBarHideToolTip, 0, 0);
tooltipshoing = FALSE;
- for (int i = 0; i < ProtosData.getCount(); i++) {
- ProtoItemData &p = ProtosData[i];
+ for (auto &p : ProtosData) {
bool isOnExtra = false;
- rc = p.protoRect;
+ rc = p->protoRect;
RECT rc1 = rc;
rc1.left = rc.left + 16;
rc1.right = rc1.left + 16;
- if (PtInRect(&rc, pt) && PtInRect(&rc1, pt) && p.bDoubleIcons)
+ if (PtInRect(&rc, pt) && PtInRect(&rc1, pt) && p->bDoubleIcons)
isOnExtra = true;
if (PtInRect(&rc, pt)) {
@@ -767,13 +765,13 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa if (msg == WM_LBUTTONDOWN && bCtrl) {
if (g_CluiData.bFilterEffective != CLVM_FILTER_PROTOS || !bShift) {
ApplyViewMode("");
- mir_snprintf(g_CluiData.protoFilter, "%s|", p.szAccountName);
+ mir_snprintf(g_CluiData.protoFilter, "%s|", p->szAccountName);
g_CluiData.bFilterEffective = CLVM_FILTER_PROTOS;
}
else {
char protoF[sizeof(g_CluiData.protoFilter)];
- mir_snprintf(protoF, "%s|", p.szAccountName);
- char *pos = strstri(g_CluiData.protoFilter, p.szAccountName);
+ mir_snprintf(protoF, "%s|", p->szAccountName);
+ char *pos = strstri(g_CluiData.protoFilter, p->szAccountName);
if (pos) {
// remove filter
size_t len = mir_strlen(protoF);
@@ -827,7 +825,7 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa HMENU hMenu = nullptr;
if (msg == WM_RBUTTONDOWN) {
- BOOL a = ((g_StatusBarData.perProtoConfig && p.SBarRightClk) || g_StatusBarData.SBarRightClk);
+ BOOL a = ((g_StatusBarData.perProtoConfig && p->SBarRightClk) || g_StatusBarData.SBarRightClk);
if (a ^ bShift)
hMenu = Menu_GetMainMenu();
else
@@ -835,7 +833,7 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa }
else {
hMenu = Menu_GetStatusMenu();
- HMENU hSubMenu = GetSubMenu(hMenu, p.iProtoPos);
+ HMENU hSubMenu = GetSubMenu(hMenu, p->iProtoPos);
if (hSubMenu)
hMenu = hSubMenu;
}
diff --git a/plugins/Clist_modern/src/modern_xptheme.cpp b/plugins/Clist_modern/src/modern_xptheme.cpp index 56fb39f0cf..6122fa21f6 100644 --- a/plugins/Clist_modern/src/modern_xptheme.cpp +++ b/plugins/Clist_modern/src/modern_xptheme.cpp @@ -86,8 +86,8 @@ void xpt_OnWM_THEMECHANGED() {
mir_cslock lck(xptCS);
- for (int i = 0; i < xptObjectList.getCount(); i++)
- _sttXptReloadThemeData(&xptObjectList[i]);
+ for (auto &it : xptObjectList)
+ _sttXptReloadThemeData(it);
}
HRESULT xpt_DrawThemeBackground(XPTHANDLE xptHandle, HDC hdc, int type, int state, const RECT *sizeRect, const RECT *clipRect)
|