Ignore:
Timestamp:
Sep 9, 2022, 8:20:25 PM (22 months ago)
Author:
chronos
Message:
  • Modified: Removed TemplateGenerics package. Generics usage replaced by standard Generics.Collections.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UWebObjects.pas

    r137 r138  
    44
    55uses
    6   Classes, SysUtils, UHtmlClasses, UXmlClasses, SpecializedDictionary,
    7   Generics.Collections;
     6  Classes, SysUtils, UHtmlClasses, UXmlClasses, Generics.Collections;
    87
    98type
     
    4241    Title: string;
    4342    Rows: TQueryFormItemList;
    44     procedure Load(Items: TDictionaryStringString);
     43    procedure Load(Items: TDictionary<string, string>);
    4544    function AddNewItem: TQueryFormItem;
    4645    constructor Create;
     
    6968    function AddNewGroup: TQueryFormGroup;
    7069    function AddNewAction(Caption, Action: string): TQueryAction;
    71     procedure Load(Items: TDictionaryStringString);
     70    procedure Load(Items: TDictionary<string, string>);
    7271    constructor Create;
    7372    destructor Destroy; override;
     
    8483begin
    8584  I := 0;
    86   while (I < Count) and (TQueryFormItem(Items[I]).Value.ItemName <> AValue) do Inc(I);
    87   if I < Count then Result := TQueryFormItem(Items[I])
     85  while (I < Count) and (Items[I].Value.ItemName <> AValue) do Inc(I);
     86  if I < Count then Result := Items[I]
    8887    else Result := nil;
    8988end;
     
    141140    Table := THtmlTable.Create;
    142141    Table.ClassId := ClassId;
    143     Row := THtmlRow(Table.Rows.AddNew(THtmlRow.Create));
    144     with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     142    Row := Table.Rows.AddRow;
     143    with Row.Cells.AddCell do begin
    145144      ColSpan := 2;
    146145      Value := THtmlString.Create;
     
    149148    with Table do
    150149    for G := 0 to Groups.Count - 1 do
    151     with TQueryFormGroup(Groups[G]) do begin
     150    with Groups[G] do begin
    152151      if Title <> '' then begin
    153         Row := THtmlRow(Table.Rows.AddNew(THtmlRow.Create));
    154         with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     152        Row := Table.Rows.AddRow;
     153        with Row.Cells.AddCell do begin
    155154          ColSpan := 2;
    156155          Value := THtmlString.Create;
     
    159158      end;
    160159      for I := 0 to Rows.Count - 1 do
    161       with TQueryFormItem(Rows[I]) do begin
    162         Row := THtmlRow(Table.Rows.AddNew(THtmlRow.Create));
    163         with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     160      with Rows[I] do begin
     161        Row := Table.Rows.AddRow;
     162        with Row.Cells.AddCell do begin
    164163          Value := THtmlString.Create;
    165164          THtmlString(Value).Text := Caption;
     
    167166          THtmlString(Value).Text := THtmlString(Value).Text + ': ';
    168167        end;
    169         with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     168        with Row.Cells.AddCell do begin
    170169          Value := THtmlInput.Create;
    171           THtmlInput(Value).Assign(TQueryFormItem(Rows[I]).Value);
     170          THtmlInput(Value).Assign(Rows[I].Value);
    172171        end;
    173172      end;
    174173    end;
    175     Row := THtmlRow(Table.Rows.AddNew(THtmlRow.Create));
    176     with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     174    Row := Table.Rows.AddRow;
     175    with Row.Cells.AddCell do begin
    177176      ColSpan := 2;
    178177      Value := THtmlBlock.Create;
    179178      for I := 0 to Actions.Count - 1 do
    180       with THtmlInput(THtmlBlock(Value).SubItems.AddNew(THtmlInput.Create)) do begin
    181         Value := TQueryAction(Actions[I]).Caption;
     179      with THtmlBlock(Value).SubItems.AddInput do begin
     180        Value := Actions[I].Caption;
    182181        InputType := itSubmit;
    183         ItemName := TQueryAction(Actions[I]).Action;
     182        ItemName := Actions[I].Action;
    184183      end;
    185184    end;
     
    203202end;
    204203
    205 procedure TQueryForm.Load(Items: TDictionaryStringString);
     204procedure TQueryForm.Load(Items: TDictionary<string, string>);
    206205var
    207206  I: Integer;
    208207begin
    209208  for I := 0 to Groups.Count - 1 do
    210     TQueryFormGroup(Groups[I]).Load(Items);
     209    Groups[I].Load(Items);
    211210end;
    212211
     
    229228{ TQueryFormGroup }
    230229
    231 procedure TQueryFormGroup.Load(Items: TDictionaryStringString);
    232 var
    233   I: Integer;
     230procedure TQueryFormGroup.Load(Items: TDictionary<string, string>);
     231var
     232  I: Integer;
     233  Item: string;
    234234begin
    235235  for I := 0 to Rows.Count - 1 do
    236   with TQueryFormItem(Rows[I]) do begin
    237     if Items.SearchKey(Value.ItemName) <> -1 then
    238       Value.Value := Items.Values[Value.ItemName];
     236  with Rows[I] do begin
     237    if Items.TryGetValue(Value.ItemName, Item) then
     238      Value.Value := Item;
    239239  end;
    240240end;
Note: See TracChangeset for help on using the changeset viewer.