diff options
author | George Hazan <george.hazan@gmail.com> | 2024-07-21 15:26:46 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-07-21 15:26:46 +0300 |
commit | 17b6a94812b2dbf4af29fb5d84064ceb1c7d393e (patch) | |
tree | 72e46849d5f6d3f19746df08329d5a19e88bb790 /plugins/QuickSearch | |
parent | 5ddeb2223413391589a77ef2620d561d21078cf4 (diff) |
fixes #4554 (QuickSearch: после скрытия и повторного показа столбца пропадает значок протокола)
Diffstat (limited to 'plugins/QuickSearch')
-rw-r--r-- | plugins/QuickSearch/src/stdafx.h | 3 | ||||
-rw-r--r-- | plugins/QuickSearch/src/utils.cpp | 38 | ||||
-rw-r--r-- | plugins/QuickSearch/src/window.cpp | 12 | ||||
-rw-r--r-- | plugins/QuickSearch/src/window_misc.cpp | 32 |
4 files changed, 50 insertions, 35 deletions
diff --git a/plugins/QuickSearch/src/stdafx.h b/plugins/QuickSearch/src/stdafx.h index 84ca0c16a7..11aed49bc5 100644 --- a/plugins/QuickSearch/src/stdafx.h +++ b/plugins/QuickSearch/src/stdafx.h @@ -87,6 +87,7 @@ struct ColumnItem : public MZeroedObject ColumnItem(const ColumnItem &src); ~ColumnItem(); + int HasImage(const wchar_t *pwsztext) const; void SetSpecialColumns(); wchar_t *title; @@ -102,13 +103,13 @@ struct ColumnItem : public MZeroedObject bool bFilter : 1; bool isXstatus : 1; bool isGender : 1; + bool isAccount : 1; bool isClient : 1; bool isGroup : 1; bool isContainer : 1; }; }; - union { // 0: db setting struct { diff --git a/plugins/QuickSearch/src/utils.cpp b/plugins/QuickSearch/src/utils.cpp index 96ed8c1f41..eb450e9db1 100644 --- a/plugins/QuickSearch/src/utils.cpp +++ b/plugins/QuickSearch/src/utils.cpp @@ -118,23 +118,36 @@ ColumnItem::~ColumnItem() }
}
+int ColumnItem::HasImage(const wchar_t *pwsztext) const
+{
+ if (isClient && (g_plugin.m_flags & QSO_CLIENTICONS) && pwsztext)
+ return LVIF_IMAGE;
+
+ if (isGender || isXstatus || isAccount)
+ return LVIF_IMAGE;
+
+ return 0;
+}
+
void ColumnItem::SetSpecialColumns()
{
- if (setting_type == QST_SETTING) {
- if (datatype == QSTS_STRING && !mir_strcmp(module, "CList") && !mir_strcmp(setting, "Group"))
- isGroup = true;
+ if (setting_type == QST_SETTING) {
+ if (datatype == QSTS_STRING && !mir_strcmp(module, "CList") && !mir_strcmp(setting, "Group"))
+ isGroup = true;
- else if (datatype == QSTS_STRING && !mir_strcmp(module, "Tab_SRMsg") && !mir_strcmp(setting, "containerW"))
- isContainer = true;
+ else if (datatype == QSTS_STRING && !mir_strcmp(module, "Tab_SRMsg") && !mir_strcmp(setting, "containerW"))
+ isContainer = true;
- else if (datatype == QSTS_BYTE && !mir_strcmpi(setting, "XStatusId"))
- isXstatus = true;
+ else if (datatype == QSTS_BYTE && !mir_strcmpi(setting, "XStatusId"))
+ isXstatus = true;
- else if (datatype == QSTS_STRING && !mir_strcmp(setting, "MirVer") && g_bFingerInstalled)
- isClient = true;
- }
- else if (setting_type == QST_CONTACTINFO && cnftype == CNF_GENDER)
- isGender = true;
+ else if (datatype == QSTS_STRING && !mir_strcmp(setting, "MirVer") && g_bFingerInstalled)
+ isClient = true;
+ }
+ else if (setting_type == QST_CONTACTINFO && cnftype == CNF_GENDER)
+ isGender = true;
+ else if (setting_type == QST_OTHER && cnftype == QSTO_ACCOUNT)
+ isAccount = true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -322,6 +335,7 @@ void CMPlugin::LoadColumn(int n, ColumnItem &col) if (!mir_strcmp(col.svc.service, "Proto/GetContactBaseAccount")) {
col.setting_type = QST_OTHER;
col.other = QSTO_ACCOUNT;
+ col.isAccount = true;
break;
}
diff --git a/plugins/QuickSearch/src/window.cpp b/plugins/QuickSearch/src/window.cpp index 8864f9e65b..a39f2761a6 100644 --- a/plugins/QuickSearch/src/window.cpp +++ b/plugins/QuickSearch/src/window.cpp @@ -128,18 +128,19 @@ void QSMainDlg::ToggleColumn(int col) // screen
int lvcol = ColumnToListView(col);
AddColumn(lvcol, &pCol);
+ pCol.SetSpecialColumns();
int nCount = m_grid.GetItemCount();
for (int i = 0; i < nCount; i++) {
auto *pRow = GetRow(i);
- LV_ITEMW li;
+ LV_ITEM 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;
+ li.mask = LVIF_TEXT + pCol.HasImage(li.pszText);
+ if (pCol.isAccount)
+ li.iImage = Clist_GetContactIcon(pRow->hContact);
m_grid.SetItem(&li);
}
}
@@ -753,6 +754,9 @@ void QSMainDlg::onCustomDraw_Grid(CCtrlListView::TEventInfo *ev) pRow->GetCellColor(lplvcd->nmcd.dwItemSpec, lplvcd->clrTextBk, lplvcd->clrText);
{
int sub = ListViewToColumn(lplvcd->iSubItem);
+ if (sub == -1)
+ break;
+
auto *pCol = &g_plugin.m_columns[sub];
if (pCol == nullptr)
break;
diff --git a/plugins/QuickSearch/src/window_misc.cpp b/plugins/QuickSearch/src/window_misc.cpp index bd377b09dd..c856533e51 100644 --- a/plugins/QuickSearch/src/window_misc.cpp +++ b/plugins/QuickSearch/src/window_misc.cpp @@ -95,27 +95,23 @@ void QSMainDlg::MakePattern(const wchar_t *pwszPattern) void QSMainDlg::AddColumn(int idx, ColumnItem *pCol)
{
- LV_COLUMN lvcol = {};
- lvcol.mask = LVCF_TEXT | LVCF_WIDTH;
- lvcol.pszText = TranslateW(pCol->title);
- lvcol.cx = pCol->width;
- m_grid.InsertColumn(idx, &lvcol);
+ LV_COLUMN lvc = {};
+ lvc.mask = LVCF_TEXT | LVCF_WIDTH;
+ lvc.pszText = TranslateW(pCol->title);
+ lvc.cx = pCol->width;
+ m_grid.InsertColumn(idx, &lvc);
HDITEM hdi;
hdi.mask = HDI_FORMAT;
- if (pCol->bFilter)
- hdi.fmt = HDF_LEFT | HDF_STRING | HDF_CHECKBOX | HDF_CHECKED;
- else
- hdi.fmt = HDF_LEFT | HDF_STRING | HDF_CHECKBOX;
+ hdi.fmt = HDF_LEFT | HDF_STRING | HDF_CHECKBOX | (pCol->bFilter ? HDF_CHECKED : 0);
SendMessage(m_grid.GetHeader(), HDM_SETITEM, idx, LPARAM(&hdi));
}
void QSMainDlg::AddContactToList(MCONTACT hContact, CRowItem *pRow)
{
- LV_ITEMW li = {};
- li.mask = LVIF_IMAGE | LVIF_PARAM;
+ LV_ITEM li = {};
+ li.mask = LVIF_PARAM;
li.iItem = 100000;
- li.iImage = Clist_GetContactIcon(hContact);
li.lParam = LPARAM(pRow);
li.iItem = m_grid.InsertItem(&li);
@@ -129,9 +125,9 @@ void QSMainDlg::AddContactToList(MCONTACT hContact, CRowItem *pRow) // Client icons preprocess
li.pszText = pRow->pValues[i].text;
- li.mask = LVIF_TEXT;
- if ((col.isClient && (g_plugin.m_flags & QSO_CLIENTICONS) && li.pszText != 0) || col.isXstatus || col.isGender)
- li.mask |= LVIF_IMAGE;
+ li.mask = LVIF_TEXT + col.HasImage(li.pszText);
+ if (col.isAccount)
+ li.iImage = Clist_GetContactIcon(hContact);
m_grid.SetItem(&li);
li.iSubItem++;
}
@@ -171,10 +167,10 @@ void QSMainDlg::ChangeStatusPicture(CRowItem *pRow, MCONTACT, LPARAM lParam) if (idx == -1)
return;
- LV_ITEMW li = {};
+ LV_ITEM li = {};
li.iItem = idx;
li.mask = LVIF_IMAGE;
- li.iImage = lParam; //CallService(MS_CLIST_GETCONTACTICON,hContact,0);
+ li.iImage = lParam;
m_grid.SetItem(&li);
}
@@ -432,7 +428,7 @@ void QSMainDlg::PrepareTable(bool bReset) }
if (bReset)
- for (int i = old + tableColumns - 1; i >= tableColumns; i--)
+ for (int i = old - 1; i >= tableColumns; i--)
m_grid.DeleteColumn(i);
}
|