mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-08 21:18:15 +02:00
LCL, LazControls: Remove fFilter variable from FilterEdits. Instead use Text property always.
This commit is contained in:
parent
335531eabf
commit
4c822bb36e
@ -143,7 +143,7 @@ begin
|
||||
fFilteredListbox:=AValue;
|
||||
if Assigned(fFilteredListbox) then
|
||||
begin
|
||||
InternalSetFilter(Text);
|
||||
ActivateFilter;
|
||||
fOriginalData.Assign(fFilteredListbox.Items);
|
||||
if (fFilteredListbox is TCustomCheckListBox) and not Assigned(fCheckedItems) then
|
||||
fCheckedItems:=TStringMap.Create(False);
|
||||
|
@ -154,7 +154,7 @@ begin
|
||||
fFilteredListview:=AValue;
|
||||
if Assigned(fFilteredListview) then
|
||||
begin
|
||||
InternalSetFilter(Text);
|
||||
ActivateFilter;
|
||||
for i := 0 to fFilteredListview.Items.Count-1 do
|
||||
fOriginalData.Add(ListItem2Data(fFilteredListview.Items[i]));
|
||||
end;
|
||||
|
@ -450,7 +450,7 @@ begin
|
||||
fFilteredTreeview := AValue;
|
||||
if fFilteredTreeview <> nil then
|
||||
begin
|
||||
InternalSetFilter(Text);
|
||||
ActivateFilter;
|
||||
fFilteredTreeview.FreeNotification(Self);
|
||||
fFilteredTreeview.AddHandlerOnBeforeDestruction(@OnBeforeTreeDestroy);
|
||||
end;
|
||||
|
@ -224,7 +224,6 @@ type
|
||||
// visual controls like TListView and TTreeView.
|
||||
TCustomControlFilterEdit = class(TCustomEditButton)
|
||||
private
|
||||
fFilter: string;
|
||||
fFilterLowercase: string;
|
||||
fFilterOptions: TFilterStringOptions;
|
||||
fIdleConnected: Boolean;
|
||||
@ -232,6 +231,7 @@ type
|
||||
fIsFirstSetFormActivate: Boolean;
|
||||
fOnAfterFilter: TNotifyEvent;
|
||||
procedure ApplyFilter(Immediately: Boolean = False);
|
||||
function GetFilter: string;
|
||||
procedure SetFilter(const AValue: string);
|
||||
procedure SetFilterOptions(AValue: TFilterStringOptions);
|
||||
procedure SetSortData(AValue: Boolean);
|
||||
@ -246,7 +246,7 @@ type
|
||||
fOnFilterItemEx: TFilterItemExEvent;
|
||||
fOnCheckItem: TCheckItemEvent;
|
||||
procedure DestroyWnd; override;
|
||||
procedure InternalSetFilter(const AValue: string);
|
||||
procedure ActivateFilter;
|
||||
function DoDefaultFilterItem(const ACaption: string;
|
||||
const ItemData: Pointer): Boolean; virtual;
|
||||
function DoFilterItem(const ACaption: string;
|
||||
@ -274,8 +274,7 @@ type
|
||||
procedure StoreSelection; virtual; abstract;
|
||||
procedure RestoreSelection; virtual; abstract;
|
||||
public
|
||||
property Filter: string read fFilter write SetFilter;
|
||||
property FilterLowercase: string read fFilterLowercase;
|
||||
property Filter: string read GetFilter write SetFilter;
|
||||
property IdleConnected: Boolean read fIdleConnected write SetIdleConnected;
|
||||
property SortData: Boolean read fSortData write SetSortData;
|
||||
property SelectedPart: TObject read fSelectedPart write fSelectedPart;
|
||||
@ -1171,12 +1170,17 @@ begin
|
||||
inherited DestroyWnd;
|
||||
end;
|
||||
|
||||
procedure TCustomControlFilterEdit.InternalSetFilter(const AValue: string);
|
||||
function TCustomControlFilterEdit.GetFilter: string;
|
||||
begin
|
||||
if fFilter=AValue then Exit;
|
||||
Button.Enabled:=AValue<>'';
|
||||
fFilter:=AValue;
|
||||
fFilterLowercase:=UTF8LowerCase(fFilter);
|
||||
Result:=Text;
|
||||
end;
|
||||
|
||||
procedure TCustomControlFilterEdit.ActivateFilter;
|
||||
// Activate an existing filter text.
|
||||
// Used when user types text, and initially when a container control is assigned.
|
||||
begin
|
||||
Button.Enabled:=Text<>'';
|
||||
fFilterLowercase:=UTF8LowerCase(Text);
|
||||
InvalidateFilter;
|
||||
end;
|
||||
|
||||
@ -1184,7 +1188,9 @@ procedure TCustomControlFilterEdit.SetFilter(const AValue: string);
|
||||
begin
|
||||
if Text=AValue then Exit;
|
||||
Text:=AValue;
|
||||
InternalSetFilter(AValue);
|
||||
Button.Enabled:=AValue<>'';
|
||||
fFilterLowercase:=UTF8LowerCase(AValue);
|
||||
InvalidateFilter;
|
||||
end;
|
||||
|
||||
procedure TCustomControlFilterEdit.SetFilterOptions(AValue: TFilterStringOptions);
|
||||
@ -1206,11 +1212,11 @@ function TCustomControlFilterEdit.DoDefaultFilterItem(const ACaption: string;
|
||||
var
|
||||
NPos: integer;
|
||||
begin
|
||||
if fFilter='' then
|
||||
if Filter='' then
|
||||
exit(True);
|
||||
|
||||
if fsoCaseSensitive in fFilterOptions then
|
||||
NPos := Pos(fFilter, ACaption)
|
||||
NPos := Pos(Filter, ACaption)
|
||||
else
|
||||
NPos := Pos(fFilterLowercase, UTF8LowerCase(ACaption));
|
||||
|
||||
@ -1294,7 +1300,7 @@ end;
|
||||
|
||||
procedure TCustomControlFilterEdit.EditChange;
|
||||
begin
|
||||
InternalSetFilter(Text);
|
||||
ActivateFilter;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -1344,11 +1350,10 @@ end;
|
||||
function TCustomControlFilterEdit.ForceFilter(AFilter: String): String;
|
||||
// Apply a new filter immediately without waiting for idle. Returns the previous filter.
|
||||
begin
|
||||
Result := FFilter;
|
||||
if fFilter <> AFilter then begin
|
||||
FFilter := AFilter;
|
||||
ApplyFilter(True);
|
||||
end;
|
||||
Result := Filter;
|
||||
if Result = AFilter then Exit;
|
||||
Filter := AFilter;
|
||||
ApplyFilter(True);
|
||||
end;
|
||||
|
||||
function TCustomControlFilterEdit.GetDefaultGlyphName: string;
|
||||
|
Loading…
Reference in New Issue
Block a user