IDE: build modes: editing name

git-svn-id: trunk@23102 -
This commit is contained in:
mattias 2009-12-12 13:54:52 +00:00
parent 5d639e329d
commit 6deb52fdc0
2 changed files with 64 additions and 2 deletions

View File

@ -238,7 +238,9 @@ type
function FindVarWithIdentifier(Identifier: string; out BuildVars: TIDEBuildVariables;
out BuildVar: TIDEBuildVariable): boolean;
function GetUniqueVarName(CheckToo: TIDEBuildVariables): string;
function GetUniqueModeName(Ignore, CheckToo: TBuildMode): string;
function GetUniqueModeName(Ignore: TBuildMode = nil; CheckToo: TBuildMode = nil): string;
function FixModeName(const ModeName: string; Ignore: TBuildMode = nil;
CheckToo: TBuildMode = nil): string;
property Evaluator: TExpressionEvaluator read FEvaluator;
property SelectedMode: TBuildMode read FSelectedMode write SetSelectedMode;// saved to project session
function ModeCount: integer;
@ -3905,7 +3907,8 @@ begin
and ((CheckToo=nil) or (CheckToo.IndexOfIdentifier(Result)<0));
end;
function TBuildModeGraph.GetUniqueModeName(Ignore, CheckToo: TBuildMode): string;
function TBuildModeGraph.GetUniqueModeName(Ignore: TBuildMode;
CheckToo: TBuildMode): string;
var
i: Integer;
CurMode: TBuildMode;
@ -3923,6 +3926,42 @@ begin
end;
end;
function TBuildModeGraph.FixModeName(const ModeName: string;
Ignore: TBuildMode; CheckToo: TBuildMode): string;
function NameOk(s: string): boolean;
var
CurMode: TBuildMode;
begin
if (CheckToo<>nil) and (SysUtils.CompareText(CheckToo.Name,s)=0) then
exit(false);
CurMode:=FindModeWithName(s);
if (CurMode<>nil) and (CurMode<>Ignore) then
exit(false);
Result:=true;
end;
var
i: Integer;
Prefix: String;
begin
Result:=ModeName;
if Result<>'' then
Result:=copy(Result,1,strlen(PChar(Result)));
if Result<>'' then
UTF8FixBroken(PChar(Result));
for i:=length(Result) downto 1 do
if Result[i] in [#0..#31,#127] then
System.Delete(Result,i,1);
if NameOk(Result) then exit;
Prefix:=Result;
i:=0;
repeat
inc(i);
Result:=Prefix+IntToStr(i);
until NameOk(Result);
end;
function TBuildModeGraph.ModeCount: integer;
begin
Result:=FModes.Count;

View File

@ -56,6 +56,9 @@ type
function GetModeRows(Index: integer): TBuildModeGridRow;
procedure ClearModeRows;
procedure FillGridRow(i: integer);
protected
function ValidateEntry(const ACol,ARow:Integer; const OldValue:string;
var NewValue:string): boolean; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -161,6 +164,24 @@ begin
end;
end;
function TBuildModesGrid.ValidateEntry(const ACol, ARow: Integer;
const OldValue: string; var NewValue: string): boolean;
var
CurMode: TBuildModeGridRow;
begin
Result:=inherited ValidateEntry(aCol, aRow, OldValue, NewValue);
if not Result then exit;
if (aRow>=1) and (aRow<=ModeRowCount) then begin
CurMode:=ModeRows[aRow-1];
if aCol=0 then begin
NewValue:=Graph.FixModeName(NewValue,CurMode.Mode);
CurMode.Mode.Name:=NewValue;
end else begin
end;
end;
end;
function TBuildModesGrid.GetModeRowCount: integer;
begin
Result:=FModeRows.Count;
@ -171,6 +192,7 @@ begin
inherited Create(TheOwner);
fGraph:=TBuildModeGraph.Create;
FModeRows:=TFPList.Create;
Options:=Options+[goEditing];
end;
destructor TBuildModesGrid.Destroy;
@ -246,6 +268,7 @@ begin
RowCount:=FModeRows.Count+1;
FixedRows:=1;
ColCount:=GroupModeCount+3;
FixedCols:=0;
TypeCol:=GroupModeCount+1;
ValueCol:=TypeCol+1;
ColWidths[0]:=150;