Changeset 419 for ConfirmationDialog


Ignore:
Timestamp:
Sep 12, 2012, 7:50:33 AM (12 years ago)
Author:
chronos
Message:
  • Modified: ConfirmationForm package now use text identificator instead of numeric index.
Location:
ConfirmationDialog
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ConfirmationDialog/UConfirmationForm.lfm

    r403 r419  
    1010  OnDestroy = FormDestroy
    1111  Position = poMainFormCenter
    12   LCLVersion = '0.9.30'
     12  LCLVersion = '1.1'
    1313  object LabelDescription: TLabel
    1414    Left = 56
     
    2525    Height = 17
    2626    Top = 88
    27     Width = 141
     27    Width = 139
    2828    Anchors = [akLeft, akBottom]
    2929    Caption = 'Do same action next time'
  • ConfirmationDialog/UConfirmationForm.pas

    r403 r419  
    1313
    1414  TConfirmMessage = class
    15     Index: Integer;
     15    SysName: string;
    1616    Enabled: Boolean;
    1717    Title: string;
     
    2727  public
    2828    constructor Create; override;
    29     function AddItem(Index: Integer; Title, Text: string; Buttons: TMsgDlgButtons;
     29    function AddItem(SysName: string; Title, Text: string; Buttons: TMsgDlgButtons;
    3030      DefaultAction: TModalResult = mrNone): TConfirmMessage;
    3131    procedure Register(Message: TConfirmMessage);
     
    3333    procedure LoadFromRegistry(Context: TRegistryContext);
    3434    procedure SaveToRegistry(Context: TRegistryContext);
    35     function SearchByIndex(Index: Integer): TConfirmMessage;
     35    function SearchByName(Name: string): TConfirmMessage;
    3636  end;
    3737
     
    6868  SCancel = 'Cancel';
    6969  SOk = 'Ok';
     70  SAbort = 'Abort';
     71  SRetry = 'Retry';
     72  SIgnore = 'Ignore';
     73  SClose = 'Close';
    7074  SConfirmMessageNotFound = 'Confirm message id %s not found';
    7175
     
    8589var
    8690  RightPos: Integer;
    87   I: Integer;
    8891const
    8992  Space = 10;
     
    135138end;
    136139
    137 function TConfirmMessageList.AddItem(Index: Integer; Title, Text: string;
     140function TConfirmMessageList.AddItem(SysName: string; Title, Text: string;
    138141  Buttons: TMsgDlgButtons; DefaultAction: TModalResult = mrNone): TConfirmMessage;
    139142var
     
    141144begin
    142145  NewMessage := TConfirmMessage.Create;
    143   NewMessage.Index := Index;
     146  NewMessage.SysName := SysName;
    144147  NewMessage.Title := Title;
    145148  NewMessage.Text := Text;
     
    171174      with TConfirmMessage(Items[I]) do
    172175      begin
    173         OpenKey(Context.Key + '\' + IntToStr(Index), True);
     176        OpenKey(Context.Key + '\' + SysName, True);
    174177        Enabled := ReadBoolWithDefault('Enabled', Enabled);
    175178        DefaultAction := ReadIntegerWithDefault('DefaultAction', DefaultAction);
     
    190193      with TConfirmMessage(Items[I]) do
    191194      begin
    192         OpenKey(Context.Key + '\' + IntToStr(Index), True);
     195        OpenKey(Context.Key + '\' + SysName, True);
    193196        WriteBool('Enabled', Enabled);
    194197        WriteInteger('DefaultAction', DefaultAction);
     
    199202end;
    200203
    201 function TConfirmMessageList.SearchByIndex(Index: Integer): TConfirmMessage;
     204function TConfirmMessageList.SearchByName(Name: string): TConfirmMessage;
    202205var
    203206  I: Integer;
    204207begin
    205208  I := 0;
    206   while (I < Count) and (TConfirmMessage(Items[I]).Index <> Index) do Inc(I);
     209  while (I < Count) and (TConfirmMessage(Items[I]).SysName <> Name) do Inc(I);
    207210  if I < Count then Result := TConfirmMessage(Items[I])
    208211    else Result := nil;
     
    217220  else if DefaultAction = mrNo then Result := SNo
    218221  else if DefaultAction = mrCancel then Result := SCancel
    219   else if DefaultAction = mrOK then Result := SOk;
     222  else if DefaultAction = mrOK then Result := SOk
     223  else if DefaultAction = mrAbort then Result := SAbort
     224  else if DefaultAction = mrRetry then Result := SRetry
     225  else if DefaultAction = mrIgnore then Result := SIgnore
     226  else if DefaultAction = mrClose then Result := SClose;
    220227end;
    221228
Note: See TracChangeset for help on using the changeset viewer.