From 386ee5dd838eb988a48109e5de2a0d11e74531b7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 20 Jun 2012 19:57:53 +0000 Subject: fix for list sorting in the hot keys' editor git-svn-id: http://svn.miranda-ng.org/main/trunk@502 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/skin/hotkeys.cpp | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'src/modules') diff --git a/src/modules/skin/hotkeys.cpp b/src/modules/skin/hotkeys.cpp index 6408bcda7d..2d2fd77be0 100644 --- a/src/modules/skin/hotkeys.cpp +++ b/src/modules/skin/hotkeys.cpp @@ -568,20 +568,6 @@ static void sttOptionsDeleteHotkey(HWND hwndList, int idx, THotkeyItem *item) item->rootHotkey->OptChanged = TRUE; } -static int sttAlphaSort(const THotkeyItem *p1, const THotkeyItem *p2) -{ - int res; - if (res = lstrcmp(p1->getSection(), p2->getSection())) - return res; - if (res = lstrcmp(p1->getDescr(), p2->getDescr())) - return res; - if (!p1->rootHotkey && p2->rootHotkey) - return -1; - if (p1->rootHotkey && !p2->rootHotkey) - return 1; - return 0; -} - static int CALLBACK sttOptionsSortList(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { TCHAR title1[256] = {0}, title2[256] = {0}; @@ -617,7 +603,12 @@ static int CALLBACK sttOptionsSortList(LPARAM lParam1, LPARAM lParam2, LPARAM lP return res; return 1; } - return sttAlphaSort(item1, item2); + + if (res = lstrcmp(item1->getSection(), item2->getSection())) return res; + if (res = lstrcmp(item1->getDescr(), item2->getDescr())) return res; + if (!item1->rootHotkey && item2->rootHotkey) return -1; + if (item1->rootHotkey && !item2->rootHotkey) return 1; + return 0; } static void sttOptionsAddHotkey(HWND hwndList, THotkeyItem *item) @@ -703,19 +694,14 @@ static void sttBuildHotkeyList(HWND hwndList) int i, nItems=0; ListView_DeleteAllItems(hwndList); - // create the temporary list with language-dependent sort order - LIST tmpList(hotkeys.getCount(), sttAlphaSort); - for (i = 0; i < hotkeys.getCount(); i++) - tmpList.insert( hotkeys[i] ); - - for (i = 0; i < tmpList.getCount(); i++) { + for (i = 0; i < hotkeys.getCount(); i++) { LVITEM lvi = {0}; - THotkeyItem *item = tmpList[i]; + THotkeyItem *item = hotkeys[i]; if (item->OptDeleted) continue; - if ( !i || lstrcmp(item->ptszSection, tmpList[i-1]->ptszSection)) { + if ( !i || lstrcmp(item->ptszSection, hotkeys[i-1]->ptszSection)) { lvi.mask = LVIF_TEXT|LVIF_PARAM; lvi.iItem = nItems++; lvi.iSubItem = 0; @@ -739,6 +725,8 @@ static void sttBuildHotkeyList(HWND hwndList) ListView_InsertItem(hwndList, &lvi); sttOptionsSetupItem(hwndList, nItems-1, item); } + + ListView_SortItemsEx(hwndList, sttOptionsSortList, (LPARAM)hwndList); } static void sttOptionsStartEdit(HWND hwndDlg, HWND hwndHotkey) -- cgit v1.2.3