Ignore:
Timestamp:
Apr 10, 2022, 1:54:34 PM (3 years ago)
Author:
chronos
Message:
  • Modified: UDataFile unit moved into Common package and TDataFile class made TComponent descendant.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UDataFile.pas

    r133 r134  
    99  { TDataFile }
    1010
    11   TDataFile = class
     11  TDataFile = class(TComponent)
    1212  private
    1313    FFileName: string;
     
    2121    function GetFileName: string; virtual;
    2222    function GetFileFilter: string; virtual;
    23     procedure Assign(Source: TDataFile);
     23    procedure Assign(Source: TPersistent); override;
    2424    procedure LoadFromFile(FileName: string); virtual;
    2525    procedure SaveToFile(FileName: string); virtual;
    26     constructor Create; virtual;
     26    constructor Create(AOwner: TComponent); override;
    2727    property FileName: string read FFileName write SetFileName;
    2828    property Modified: Boolean read FModified write SetModified;
     29  published
    2930    property OnModify: TNotifyEvent read FOnModify write FOnModify;
    3031  end;
     
    3839  SDataFileName = 'Data file';
    3940  SAllFiles = 'All files';
     41
     42const
     43  AnyFileExt = '.*';
    4044
    4145
     
    6872function TDataFile.GetFileFilter: string;
    6973begin
    70   Result := SAllFiles + '|*.*';
     74  Result := SAllFiles + '|*' + AnyFileExt;
    7175end;
    7276
    73 procedure TDataFile.Assign(Source: TDataFile);
     77procedure TDataFile.Assign(Source: TPersistent);
    7478begin
    75   FFileName := Source.FFileName;
    76   FModified := Source.FModified;
     79  inherited;
     80  if Source is TDataFile then begin
     81    FFileName := TDataFile(Source).FFileName;
     82    FModified := TDataFile(Source).FModified;
     83  end;
    7784end;
    7885
     
    8592procedure TDataFile.SaveToFile(FileName: string);
    8693begin
     94  FModified := False;
    8795  Self.FileName := FileName;
    88   FModified := False;
    8996end;
    9097
    91 constructor TDataFile.Create;
     98constructor TDataFile.Create(AOwner: TComponent);
    9299begin
     100  inherited;
    93101  FileName := GetFileName + GetFileExt;
    94102end;
     
    100108end;
    101109
    102 
    103110end.
    104111
Note: See TracChangeset for help on using the changeset viewer.