summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-13 22:31:50 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-13 22:31:50 +0300
commit787f04649748e06eb89a189782cf4bed405036ca (patch)
tree7ed9544c0fa5fc177b597230431998719902b038
parent4321bd81a30e8aaa9dfd5d29fb3135708fa3d123 (diff)
column menu for #2881 (p.1)
-rw-r--r--plugins/QuickSearch/src/stdafx.h1
-rw-r--r--plugins/QuickSearch/src/window.cpp63
2 files changed, 63 insertions, 1 deletions
diff --git a/plugins/QuickSearch/src/stdafx.h b/plugins/QuickSearch/src/stdafx.h
index ae66116c0c..f2a830e9d7 100644
--- a/plugins/QuickSearch/src/stdafx.h
+++ b/plugins/QuickSearch/src/stdafx.h
@@ -389,6 +389,7 @@ public:
void ChangeCellValue(MCONTACT hContact, int col);
bool PrepareToFill();
+ void ToggleColumn(int col);
INT_PTR OnSysCommand(UINT, WPARAM, LPARAM);
INT_PTR OnMouseMove(UINT, WPARAM, LPARAM);
diff --git a/plugins/QuickSearch/src/window.cpp b/plugins/QuickSearch/src/window.cpp
index 63d4a652a8..5ee73703aa 100644
--- a/plugins/QuickSearch/src/window.cpp
+++ b/plugins/QuickSearch/src/window.cpp
@@ -111,7 +111,68 @@ INT_PTR QSMainDlg::NewEditProc(UINT msg, WPARAM wParam, LPARAM)
// list header window procedure
static void MakeColumnMenu()
-{}
+{
+ HMENU hMenu = CreatePopupMenu();
+
+ for (auto &it : g_plugin.m_columns) {
+ int flag = MF_STRING + (it->bEnabled) ? MF_CHECKED : MF_UNCHECKED;
+ AppendMenuW(hMenu, flag, 100 + g_plugin.m_columns.indexOf(&it), TranslateW(it->title));
+ }
+
+ POINT pt;
+ GetCursorPos(&pt);
+
+ int id = TrackPopupMenu(hMenu, TPM_RETURNCMD + TPM_NONOTIFY, pt.x, pt.y, 0, g_pDlg->GetHwnd(), 0);
+ if (id >= 100)
+ g_pDlg->ToggleColumn(id - 100);
+
+ DestroyMenu(hMenu);
+}
+
+void QSMainDlg::ToggleColumn(int col)
+{
+ auto &pCol = g_plugin.m_columns[col];
+
+ if (!pCol.bEnabled) { // show column
+ pCol.bEnabled = true;
+
+ if (!pCol.bInit) {
+ for (auto &it : m_rows)
+ it->pValues[col].LoadOneItem(it->hContact, pCol, this);
+ pCol.bInit = true;
+ }
+
+ // screen
+ int lvcol = ColumnToListView(col);
+ AddColumn(lvcol, &pCol);
+
+ int nCount = m_grid.GetItemCount();
+ for (int i = 0; i < nCount; i++) {
+ auto *pRow = GetRow(i);
+
+ LV_ITEMW li;
+ li.iItem = i;
+ li.iSubItem = lvcol;
+ li.mask = LVIF_TEXT;
+ li.pszText = pRow->pValues[col].text;
+ if ((pCol.isClient && (g_plugin.m_flags & QSO_CLIENTICONS) && li.pszText) || pCol.isGender || pCol.isXstatus)
+ li.mask |= LVIF_IMAGE;
+ m_grid.SetItem(&li);
+ }
+ }
+ else { // hide column
+ int cnt = 0;
+ for (auto &it : g_plugin.m_columns)
+ if (it->bEnabled)
+ cnt++;
+
+ // keep at least one visible column (1 + this)
+ if (cnt > 2) {
+ m_grid.DeleteColumn(col);
+ pCol.bEnabled = false;
+ }
+ }
+}
static LRESULT CALLBACK sttNewLVHProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{