Commit 00788ab9 authored by Martin Schreiber's avatar Martin Schreiber

+ locatestringoptionty lso_noexact, lso_filterisuppercase.

* Fixed reducing filter size in dropdown dlo_livefilter mode.
parent d3350230
......@@ -337,6 +337,7 @@ type
procedure dodeactivate; override;
procedure docellevent(var info: celleventinfoty); override;
function getkeystring(const aindex: integer): msestring;
function getkeystringnohidden(const aindex: integer): msestring;
function locate(const filter: msestring): boolean; virtual;
function updatevisiblerows(): integer; virtual;
//returns first visible row
......@@ -2785,6 +2786,13 @@ begin
end;
end;
function tdropdownlist.getkeystringnohidden(const aindex: integer): msestring;
begin
with tstringcol(fdatacols[0]) do begin
result:= items[aindex];
end;
end;
function tdropdownlist.locate(const filter: msestring): boolean;
var
int1: integer;
......@@ -2821,6 +2829,7 @@ var
int1,int2,int3,count1: integer;
opt1: locatestringoptionsty;
bo1: boolean;
s1: msestring;
begin
result:= invalidaxis;
if (rowcount > 0) and (fdatacols.count > 0) then begin
......@@ -2831,9 +2840,14 @@ begin
folded:= true;
beginupdate;
int1:= 0;
opt1:= [lso_nodown];
opt1:= [lso_nodown,lso_noexact];
if dlo_casesensitive in foptions1 then begin
include(opt1,lso_casesensitive);
s1:= ffiltertext;
end
else begin
include(opt1,lso_filterisuppercase);
s1:= mseuppercase(ffiltertext);
end;
if dlo_posinsensitive in foptions1 then begin
include(opt1,lso_posinsensitive);
......@@ -2841,8 +2855,8 @@ begin
count1:= fdatacols[0].datalist.count;
repeat
int2:= int1;
bo1:= locatestring(ffiltertext,{$ifdef FPC}@{$endif}getkeystring,opt1,
count1,int1);
bo1:= locatestring(s1,{$ifdef FPC}@{$endif}getkeystringnohidden,
opt1,count1,int1);
if not bo1 then begin
int1:= fdatacols[0].datalist.count;
end;
......
......@@ -622,7 +622,8 @@ type
getkeystringfuncty = function (const index: integer): msestring of object;
locatestringoptionty = (lso_casesensitive,lso_posinsensitive,lso_exact,
lso_nodown,lso_noup);
lso_nodown,lso_noup,lso_noexact,
lso_filterisuppercase);
locatestringoptionsty = set of locatestringoptionty;
function locatestring(const afilter: msestring;
......@@ -792,11 +793,9 @@ begin
with locateinfo do begin
posinsensitive:= lso_posinsensitive in options;
casesensitive:= lso_casesensitive in options;
if casesensitive then begin
filter:= afilter;
end
else begin
filter:= mseuppercase(afilter);
filter:= afilter;
if not casesensitive and not (lso_filterisuppercase in options) then begin
filter:= mseuppercase(filter);
end;
result:= false;
int1:= aindex;
......@@ -811,32 +810,17 @@ begin
end;
end;
if int1 >= 0 then begin
exact:= true;
for int2:= int1 to count - 1 do begin
check(int2);
if result or (lso_noup in options) then begin
break;
end;
end;
if not result then begin
if not (lso_nodown in options) then begin
for int2:= int1-1 downto 0 do begin
check(int2);
if result then begin
break;
end;
if not (lso_noexact in options) then begin //search whole filtertext
exact:= true;
for int2:= int1 to count - 1 do begin
check(int2);
if result or (lso_noup in options) then begin
break;
end;
end;
if not result and not (lso_exact in options) then begin
exact:= false;
for int2:= int1 to count - 1 do begin
check(int2);
if result or (lso_noup in options) then begin
break;
end;
end;
if not result and not (lso_nodown in options) then begin
for int2:= int1 - 1 downto 0 do begin
if not result then begin
if not (lso_nodown in options) then begin
for int2:= int1-1 downto 0 do begin
check(int2);
if result then begin
break;
......@@ -845,6 +829,24 @@ begin
end;
end;
end;
if not result and not (lso_exact in options) then begin
//search partial filter text
exact:= false;
for int2:= int1 to count - 1 do begin
check(int2);
if result or (lso_noup in options) then begin
break;
end;
end;
if not result and not (lso_nodown in options) then begin
for int2:= int1 - 1 downto 0 do begin
check(int2);
if result then begin
break;
end;
end;
end;
end;
end;
end;
result:= locateinfo.result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment