LazControls: an option in ListViewFilterEdit to filter by all fields or just by caption.

git-svn-id: trunk@47186 -
This commit is contained in:
juha 2014-12-12 23:08:43 +00:00
parent 9c2b7067ce
commit 82b190d7a9

View File

@ -30,9 +30,13 @@ type
TListViewFilterEdit = class(TCustomControlFilterEdit) TListViewFilterEdit = class(TCustomControlFilterEdit)
private private
fFilteredListview: TCustomListView; // A control showing the (filtered) data. // A control showing the (filtered) data.
fSelectionList: TStringList; // Store/restore the old selections here. fFilteredListview: TCustomListView;
// Data supplied by caller through Data property. // All fields / Just the first field, caption.
fByAllFields: Boolean;
// Store/restore the old selections here.
fSelectionList: TStringList;
// Data supplied by caller through Items property.
fOriginalData: TListViewDataList; fOriginalData: TListViewDataList;
// Data sorted for viewing. // Data sorted for viewing.
fFilteredData: TListViewDataList; fFilteredData: TListViewDataList;
@ -55,6 +59,7 @@ type
property Items: TListViewDataList read fOriginalData; property Items: TListViewDataList read fOriginalData;
published published
property FilteredListview: TCustomListView read fFilteredListview write SetFilteredListview; property FilteredListview: TCustomListView read fFilteredListview write SetFilteredListview;
property ByAllFields: Boolean read fByAllFields write fByAllFields;
end; end;
var var
@ -124,11 +129,15 @@ end;
function TListViewFilterEdit.MatchesFilter(aData: TStringArray): Boolean; function TListViewFilterEdit.MatchesFilter(aData: TStringArray): Boolean;
var var
i: Integer; i, EndInd: Integer;
begin begin
if Filter='' then if Filter='' then
Exit(True); Exit(True);
for i := 0 to Pred(Length(aData)) do begin if fByAllFields then
EndInd := Pred(Length(aData))
else
EndInd := 0;
for i := 0 to EndInd do begin
Result := Pos(Filter,UTF8LowerCase(aData[i]))>0; Result := Pos(Filter,UTF8LowerCase(aData[i]))>0;
if Result then if Result then
Exit; Exit;