TileList Filtering improvement

I've added OnTileFilterSubject event to TileList. 
TTMSFMXTileFilterSubjectEvent = procedure(ATile: TTMSFMXTile; var Subject: string) of object; 

It allows user to implement custom filtering, instead of sticking to Tile Caption string, as shown in the code snipped below.
In addition, UnicodeString (System) Pos function is used instead of Ansi... ones, to implement Unicode-aware filtering. It's case sensitive, though.

function TTMSFMXTile.AllowDisplay: Boolean;
var
  str: String;
  strPos: Integer;
  
begin
  Result := True;
  if (FOwner.FFilter <> '') then
  begin
    str := GetStrippedCaption;

    if Assigned(FOwner.OnTileFilterSubject) then
      FOwner.OnTileFilterSubject(Self, str);    
    
    strPos := System.Pos(FOwner.FFilter, str);
  
    Result := 0 < strPos;
    if FOwner.Filtering = lfStart then
      Result := Result and (1 = strPos);
  end;
end;

Hi, 


This is a good suggestion, we have created the following implementation:

function TTMSFMXTile.AllowDisplay: Boolean;
var
  str: String;
begin
  Result := True;
  if (FOwner.FFilter <> '') then
  begin
    str := GetStrippedCaption;
    Result := AnsiContainsText(str, FOwner.FFilter);
    if FOwner.Filtering = lfStart then
      Result := Result and AnsiStartsText(FOwner.FFilter, str);

    if Assigned(FOwner.OnTileFilter) then
      FOwner.OnTileFilter(Self, Self, str, FOwner.FFilter, Result);
  end;
end;

This allows for any filtering operating to occur based on the tile and the filter that is applied. If the event isn't used, the default operating occurs. The next version will have this included.

Kind Regards, 
Pieter

Pieter Scheldeman2015-06-02 18:00:34