summaryrefslogtreecommitdiff
path: root/plugins/QuickSearch
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2014-01-22 17:42:42 +0000
committerAlexey Kulakov <panda75@bk.ru>2014-01-22 17:42:42 +0000
commitd139e286676c7fa67ed208e69f2ee9dc22e2f614 (patch)
treeaa3d8ab63b2593573df9ff8077249c06eaf5e02c /plugins/QuickSearch
parentdde622d64e2c3ef843c70971b4f108189f19195f (diff)
QuickSearch: bug of column menu fixed
git-svn-id: http://svn.miranda-ng.org/main/trunk@7828 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/QuickSearch')
-rw-r--r--plugins/QuickSearch/sr_global.pas34
-rw-r--r--plugins/QuickSearch/sr_window.pas76
2 files changed, 52 insertions, 58 deletions
diff --git a/plugins/QuickSearch/sr_global.pas b/plugins/QuickSearch/sr_global.pas
index fe6a0864e2..050fa3a3ee 100644
--- a/plugins/QuickSearch/sr_global.pas
+++ b/plugins/QuickSearch/sr_global.pas
@@ -46,15 +46,15 @@ const //types
const
COL_ON = $0001; // Show column
- COL_INIT = $0002; // No need to update
COL_FILTER = $0004; // Filter column by pattern
// QS window runtime flags
+ COL_INIT = $0002; // No need to update
COL_XSTATUS = $0100;
COL_GENDER = $0200;
COL_CLIENT = $0400;
COL_GROUP = $0800;
COL_CNTNR = $1000;
- COL_REFRESH = $FF00; // mask
+ COL_REFRESH = $FF02; // mask
const
QSO_SORTBYSTATUS = $00000001; // Sort by status
@@ -84,13 +84,13 @@ type
pcolumnitem = ^tcolumnitem;
tcolumnitem = record
title :PWideChar;
- setting_type :dword; // QST_* constants
+ setting_type :word; // QST_* constants
flags :word; // COL_* constants
width :word;
case integer of
// db setting
0: (
- datatype:integer; // QSTS_* constants
+ datatype:word; // QSTS_* constants
module :pAnsiChar;
setting :pAnsiChar;
);
@@ -104,9 +104,9 @@ type
restype:dword;
);
// contact info
- 3: (cnftype:dword); // CNF_* constants
+ 3: (cnftype:word); // CNF_* constants
// other
- 4: (other:integer); // QSTO_* constants
+ 4: (other:word); // QSTO_* constants
end;
tcolumnarray = array of tcolumnitem;
@@ -641,15 +641,15 @@ begin
p:=StrEnd(IntToStr(pp,num));
with column do
begin
- StrCopy(p,so__setting_type); WriteWord(buf,setting_type);
StrCopy(p,so__title); WriteUnicode(buf,title);
- StrCopy(p,so__flags); WriteWord(buf,flags);
+ StrCopy(p,so__setting_type); WriteWord(buf,setting_type);
+ StrCopy(p,so__flags); WriteWord(buf,flags and not COL_REFRESH);
StrCopy(p,so__width); WriteWord(buf,width);
case setting_type of
QST_SETTING: begin
- StrCopy(p,so__datatype); WriteInt(buf,datatype);
- StrCopy(p,so__module ); WriteStr(buf,module);
- StrCopy(p,so__setting ); WriteStr(buf,setting);
+ StrCopy(p,so__datatype); WriteWord(buf,datatype);
+ StrCopy(p,so__module ); WriteStr (buf,module);
+ StrCopy(p,so__setting ); WriteStr (buf,setting);
end;
QST_SCRIPT: begin
@@ -680,7 +680,7 @@ begin
end;
QST_OTHER: begin
- StrCopy(p,so__other); WriteInt(buf,other);
+ StrCopy(p,so__other); WriteWord(buf,other);
end;
end;
end;
@@ -779,12 +779,12 @@ begin
StrCopy(p,so__setting_type); setting_type:=GetWord(buf,0);
StrCopy(p,so__title); title:=GetUnicode(buf);
StrCopy(p,so__width); width:=GetWord(buf,20);
- StrCopy(p,so__flags); flags:=GetWord(buf,COL_ON);
+ StrCopy(p,so__flags); flags:=GetWord(buf,COL_ON) and not COL_REFRESH;
case setting_type of
QST_SETTING: begin
- StrCopy(p,so__datatype); datatype:=GetInt(buf,0);
- StrCopy(p,so__module ); module :=GetStr(buf);
- StrCopy(p,so__setting ); setting :=GetStr(buf);
+ StrCopy(p,so__datatype); datatype:=GetWord(buf,0);
+ StrCopy(p,so__module ); module :=GetStr (buf);
+ StrCopy(p,so__setting ); setting :=GetStr (buf);
end;
QST_SCRIPT: begin
@@ -815,7 +815,7 @@ begin
end;
QST_OTHER: begin
- StrCopy(p,so__other); other:=GetInt(buf,0);
+ StrCopy(p,so__other); other:=GetWord(buf,0);
end;
end;
end;
diff --git a/plugins/QuickSearch/sr_window.pas b/plugins/QuickSearch/sr_window.pas
index 64aef6a95d..2c25cf9fd1 100644
--- a/plugins/QuickSearch/sr_window.pas
+++ b/plugins/QuickSearch/sr_window.pas
@@ -1010,11 +1010,30 @@ begin
end;
end;
+procedure addcolumn(num:integer;column:pcolumnitem);
+var
+ lvcol:LV_COLUMNW;
+ hdi:THDITEM;
+begin
+ zeromemory(@lvcol,sizeof(lvcol));
+ lvcol.mask :=LVCF_TEXT or LVCF_WIDTH;
+ lvcol.pszText :=TranslateW(column.title);
+ lvcol.cx :=column.width;
+ SendMessageW(grid,LVM_INSERTCOLUMNW,num,lparam(@lvcol));
+
+ // set checkbox in column header
+ hdi.mask:=HDI_FORMAT;
+ if (column.flags and COL_FILTER)<>0 then
+ hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX or HDF_CHECKED
+ else
+ hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX;
+ SendMessage(ListView_GetHeader(grid),HDM_SETITEM,num,tlparam(@hdi));
+end;
+
procedure MakeColumnMenu;
var
column:pcolumnitem;
menu:HMENU;
- lvcol:LV_COLUMNW;
pt:TPOINT;
flag,id,i,j:integer;
begin
@@ -1031,13 +1050,14 @@ begin
end;
GetCursorPos(pt);
id:=integer(TrackPopupMenu(menu,TPM_RETURNCMD+TPM_NONOTIFY,pt.x,pt.y,0,mainwnd,nil));
- if id>100 then
+ if id>=100 then
begin
dec(id,100);
column:=@qsopt.columns[id];
- column.flags:=column.flags xor COL_ON;
- if (column.flags and COL_ON)<>0 then
+ // show column
+ if (column.flags and COL_ON)=0 then
begin
+ column.flags:=column.flags or COL_ON;
// memory
if (column.flags and COL_INIT)=0 then
begin
@@ -1049,29 +1069,27 @@ begin
end;
// screen
i:=ColumnToListView(id);
- zeromemory(@lvcol,sizeof(lvcol));
- lvcol.mask :=LVCF_TEXT or LVCF_WIDTH;
- lvcol.pszText :=TranslateW(column.title);
- lvcol.cx :=column.width;
- //!!
- SendMessageW(grid,LVM_INSERTCOLUMNW,i,tlparam(@lvcol));
+ addcolumn(i,column);
// fill new column
FillLVColumn(id,i);
end
else
+ // hide column
begin
j:=0;
+
for i:=0 to qsopt.numcolumns-1 do
begin
if (qsopt.columns[i].flags and COL_ON)<>0 then
inc(j);
end;
- // keep at least one visible column
- if j>1 then
- SendMessage(grid,LVM_DELETECOLUMN,ColumnToListView(id),0)
- else
- column.flags:=column.flags or COL_ON;
+ // keep at least one visible column (1 + this)
+ if j>2 then
+ begin
+ SendMessage(grid,LVM_DELETECOLUMN,ColumnToListView(id),0);
+ column.flags:=column.flags and not COL_ON;
+ end;
end;
end;
DestroyMenu(menu);
@@ -1625,29 +1643,16 @@ begin
qsopt.columns[num].flags:=flags;
end;
end;
-{
-procedure addcolumn(handle:hwnd;num,width:integer;title:PWideChar);
-var
- lvcol:LV_COLUMNW;
-begin
- zeromemory(@lvcol,sizeof(lvcol));
- lvcol.mask :=LVCF_TEXT or LVCF_WIDTH;
- lvcol.pszText :=title;
- lvcol.cx :=width;
- SendMessageW(handle,LVM_INSERTCOLUMNW,num,lparam(@lvcol));
-end;
-}
+
// Set columns and clear listview
procedure PrepareTable(reset:boolean=false);
var
lvcol:LV_COLUMNW;
hdi:THDITEM;
- header:HWND;
i:integer;
old:integer;
begin
SendMessage(grid,LVM_DELETEALLITEMS,0,0);
- header:=ListView_GetHeader(grid);
zeromemory(@hdi,sizeof(hdi));
hdi.mask:=HDI_FORMAT;
@@ -1662,18 +1667,7 @@ begin
begin
if (flags and COL_ON)<>0 then
begin
- lvcol.pszText:=TranslateW(title);
- lvcol.cx :=width;
- SendMessageW(grid,LVM_INSERTCOLUMNW,tablecolumns,tlparam(@lvcol));
-// addcolumn(grid,tablecolumns,width,TranslateW(title));
-
- // set checkbox in column header
- if (flags and COL_FILTER)<>0 then
- hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX or HDF_CHECKED
- else
- hdi.fmt:=HDF_LEFT or HDF_STRING or HDF_CHECKBOX;
- SendMessage(header,HDM_SETITEM,tablecolumns,tlparam(@hdi));
-
+ addcolumn(tablecolumns,@qsopt.columns[i]);
inc(tablecolumns);
end;