Changeset 48 for trunk/IDE/UProject.pas


Ignore:
Timestamp:
Mar 4, 2012, 4:28:12 PM (13 years ago)
Author:
chronos
Message:
  • Added: New project and files templates.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/IDE/UProject.pas

    r47 r48  
    6565    procedure LoadFromXMLNode(Node: TDOMNode);
    6666    function SearchFile(FileName: string): TProjectFile;
    67     procedure AddFile(FileName: string);
     67    function AddFile(FileName: string): TProjectFile;
    6868  end;
    6969
     
    9191  end;
    9292
     93  { TProjectTemplate }
     94
     95  TProjectTemplate = class
     96    Name: string;
     97    Description: TStringList;
     98    procedure InitProject(Project: TProject); virtual;
     99    constructor Create; virtual;
     100    destructor Destroy; override;
     101  end;
     102
     103  { TProjectTemplateList }
     104
     105  TProjectTemplateList = class(TListObject)
     106    procedure AddTemplate(Template: TProjectTemplate);
     107  end;
     108
     109
    93110implementation
    94111
     112resourcestring
     113  SNewProject = 'New project';
     114
     115{ TProjectTemplateList }
     116
     117procedure TProjectTemplateList.AddTemplate(Template: TProjectTemplate);
     118begin
     119  Add(Template);
     120end;
     121
     122{ TProjectTemplate }
     123
     124procedure TProjectTemplate.InitProject(Project: TProject);
     125begin
     126  Project.Active := False;
     127  Project.Active := True;
     128  Project.FileName := SNewProject;
     129end;
     130
     131constructor TProjectTemplate.Create;
     132begin
     133  Description := TStringList.Create;
     134end;
     135
     136destructor TProjectTemplate.Destroy;
     137begin
     138  Description.Free;
     139  inherited Destroy;
     140end;
     141
    95142{ TProjectPackageList }
    96143
     
    114161
    115162end;
    116 
    117 
    118163
    119164{ TProjectGroup }
     
    184229end;
    185230
    186 procedure TProjectFileList.AddFile(FileName: string);
    187 var
    188   NewFile: TProjectFile;
    189 begin
    190   NewFile := TProjectFile(AddNew(TProjectFile.Create));
    191   NewFile.Parent := Parent;
    192   NewFile.FileName := FileName;
     231function TProjectFileList.AddFile(FileName: string): TProjectFile;
     232begin
     233  Result := TProjectFile(AddNew(TProjectFile.Create));
     234  Result.Parent := Parent;
     235  Result.FileName := FileName;
    193236end;
    194237
     
    234277      FileName := UTF8Encode(NewNode.TextContent);
    235278  end;
    236   if FileExistsUTF8(FileName) then Load;
     279  if FileExistsUTF8(ExtractFileDir(Parent.FileName) + DirectorySeparator + FileName) then Load;
    237280end;
    238281
Note: See TracChangeset for help on using the changeset viewer.