IDE: removed buildmodegroups

git-svn-id: trunk@25564 -
This commit is contained in:
mattias 2010-05-21 12:55:06 +00:00
parent f3e19f4829
commit 8471e299e4
2 changed files with 19 additions and 271 deletions

View File

@ -149,28 +149,16 @@ type
FActive: boolean;
FFlags: TFPList; // lost TBuildModeFlag
FGraph: TBuildModeGraph;
FIncludes: TFPList;// list of TBuildMode
FIncludedBy: TFPList;// list of TBuildMode
FName: string;
FShowIncludes: boolean;
FStoredInSession: boolean;
function GetFlagCount: integer;
function GetFlags(Index: integer): TBuildModeFlag;
function GetIncludeCount: integer;
function GetIncludedBy(Index: integer): TBuildMode;
function GetIncludedByCount: integer;
function GetIncludes(Index: integer): TBuildMode;
procedure SetName(const AValue: string);
procedure SetStoredInSession(const AValue: boolean);
public
constructor Create(aGraph: TBuildModeGraph; const aName: string);
destructor Destroy; override;
procedure ClearFlags;
procedure ClearIncludes;
procedure ClearIncludedBys;
procedure Include(aMode: TBuildMode);
procedure Exclude(aMode: TBuildMode);
function IsIncludedBy(aMode: TBuildMode): boolean;
function AddFlag(Value: string; Variable: string = ''): TBuildModeFlag;
function InsertFlag(InsertPos: integer;
Value: string; Variable: string = ''): TBuildModeFlag;
@ -185,12 +173,7 @@ type
property Name: string read FName write SetName;
property Graph: TBuildModeGraph read FGraph;
property StoredInSession: boolean read FStoredInSession write SetStoredInSession;
property IncludeCount: integer read GetIncludeCount;
property Includes[Index: integer]: TBuildMode read GetIncludes;
property IncludedByCount: integer read GetIncludedByCount;
property IncludedBy[Index: integer]: TBuildMode read GetIncludedBy;
property Active: boolean read FActive;
property ShowIncludes: boolean read FShowIncludes write FShowIncludes;
property FlagCount: integer read GetFlagCount;
property Flags[Index: integer]: TBuildModeFlag read GetFlags;
end;
@ -3688,14 +3671,10 @@ end;
procedure TBuildModeGraph.UpdateActiveModes;
procedure Add(aMode: TBuildMode);
var
i: Integer;
begin
if (aMode=nil) or (FActiveModes.IndexOf(aMode)>=0) then exit;
FActiveModes.Add(aMode);
aMode.FActive:=true;
for i:=0 to aMode.IncludeCount-1 do
Add(aMode.Includes[i]);
end;
var
@ -4924,16 +4903,6 @@ end;
{ TBuildMode }
function TBuildMode.GetIncludedBy(Index: integer): TBuildMode;
begin
Result:=TBuildMode(FIncludedBy[Index]);
end;
function TBuildMode.GetIncludeCount: integer;
begin
Result:=FIncludes.Count;
end;
function TBuildMode.GetFlagCount: integer;
begin
Result:=FFlags.Count;
@ -4944,16 +4913,6 @@ begin
Result:=TBuildModeFlag(FFlags[Index]);
end;
function TBuildMode.GetIncludedByCount: integer;
begin
Result:=FIncludedBy.Count;
end;
function TBuildMode.GetIncludes(Index: integer): TBuildMode;
begin
Result:=TBuildMode(FIncludes[Index]);
end;
procedure TBuildMode.SetName(const AValue: string);
begin
if FName=AValue then exit;
@ -4970,19 +4929,13 @@ constructor TBuildMode.Create(aGraph: TBuildModeGraph; const aName: string);
begin
FGraph:=aGraph;
FName:=aName;
FIncludes:=TFPList.Create;
FIncludedBy:=TFPList.Create;
FFlags:=TFPList.Create;
end;
destructor TBuildMode.Destroy;
begin
ClearFlags;
ClearIncludes;
ClearIncludedBys;
FreeAndNil(FFlags);
FreeAndNil(FIncludes);
FreeAndNil(FIncludedBy);
inherited Destroy;
end;
@ -4995,54 +4948,6 @@ begin
FFlags.Clear;
end;
procedure TBuildMode.ClearIncludes;
var
i: Integer;
begin
for i:=0 to FIncludes.Count-1 do
Includes[i].FIncludedBy.Remove(Self);
FIncludes.Clear;
end;
procedure TBuildMode.ClearIncludedBys;
var
i: Integer;
begin
for i:=0 to FIncludedBy.Count-1 do
IncludedBy[i].FIncludes.Remove(Self);
FIncludedBy.Clear;
end;
procedure TBuildMode.Include(aMode: TBuildMode);
begin
if aMode=nil then exit;
if FIncludes.IndexOf(aMode)>=0 then exit;
if aMode.FIncludedBy.IndexOf(Self)>=0 then
RaiseException('');
FIncludes.Add(aMode);
aMode.FIncludedBy.Add(Self);
if Active or aMode.Active then
Graph.UpdateActiveModes;
end;
procedure TBuildMode.Exclude(aMode: TBuildMode);
begin
if FIncludes.IndexOf(aMode)<0 then exit;
FIncludes.Remove(aMode);
aMode.FIncludedBy.Remove(Self);
if Active or aMode.Active then
Graph.UpdateActiveModes;
end;
function TBuildMode.IsIncludedBy(aMode: TBuildMode): boolean;
var
i: Integer;
begin
for i:=0 to IncludedByCount-1 do
if IncludedBy[i]=aMode then exit(true);
Result:=false;
end;
function TBuildMode.AddFlag(Value: string; Variable: string): TBuildModeFlag;
begin
Result:=InsertFlag(FlagCount,Value,Variable);
@ -5074,10 +4979,6 @@ begin
Src:=TBuildMode(Source);
// name is not copied
FStoredInSession:=Src.FStoredInSession;
// copy includes
FIncludes.Clear;
for i:=0 to Src.IncludeCount-1 do
Include(Graph.FindModeWithName(Src.Includes[i].Name));
// copy flags
ClearFlags;
for i:=0 to Src.FlagCount-1 do begin
@ -5096,11 +4997,6 @@ begin
Result:=false;
if StoredInSession<>aMode.StoredInSession then exit;
if Name<>aMode.Name then exit;
if IncludeCount<>aMode.IncludeCount then exit;
for i:=0 to IncludeCount-1 do
if SysUtils.CompareText(Includes[i].Name,aMode.Includes[i].Name)<>0 then
exit;
// Note: do not compare includedby
if FlagCount<>aMode.FlagCount then exit;
for i:=0 to FlagCount-1 do
if not Flags[i].IsEqual(aMode.Flags[i]) then
@ -5115,9 +5011,7 @@ var
NewCnt: LongInt;
i: Integer;
Flag: TBuildModeFlag;
ModeName: String;
begin
ClearIncludes;
ClearFlags;
FName:=XMLConfig.GetValue(Path+'Name/Value','');
@ -5128,14 +5022,6 @@ begin
Flag.LoadFromXMLConfig(XMLConfig,Path+'Flags/Item'+IntToStr(i)+'/',
DoSwitchPathDelims);
end;
FShowIncludes:=XMLConfig.GetValue(Path+'Includes/Show',false);
NewCnt:=XMLConfig.GetValue(Path+'Includes/Count',0);
for i:=0 to NewCnt-1 do begin
ModeName:=XMLConfig.GetValue(Path+'Includes/Mode'+IntToStr(i)+'/Name','');
if ModeName='' then continue;
Include(Graph.FindModeWithName(ModeName));
end;
end;
procedure TBuildMode.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
@ -5148,11 +5034,6 @@ begin
for i:=0 to FlagCount-1 do
Flags[i].SaveToXMLConfig(XMLConfig,Path+'Flags/Item'+IntToStr(i)+'/',
UsePathDelim);
XMLConfig.SetDeleteValue(Path+'Includes/Show',ShowIncludes,false);
XMLConfig.SetDeleteValue(Path+'Includes/Count',IncludeCount,0);
for i:=0 to IncludeCount-1 do
XMLConfig.SetDeleteValue(Path+'Includes/Mode'+IntToStr(i)+'/Name',
Includes[i].Name,'');
end;
{ TBuildModeFlag }

View File

@ -101,7 +101,6 @@ type
property ModeRows[Index: integer]: TBuildModeGridRow read GetModeRows;
property GroupModeCount: integer read FGroupModeCount; // number of modes that are group of modes
property SelectedModeRow: TBuildModeGridRow read GetSelectedModeRow;
property ShowGroupGrid: boolean read FShowGroupGrid write SetShowGroupGrid;
end;
{ TBuildModesEditorFrame }
@ -239,41 +238,27 @@ begin
// set new mode name
NewValue:=Graph.FixModeName(NewValue,CurModeRow.Mode);
CurModeRow.Mode.Name:=NewValue;
if CurModeRow.Mode.ShowIncludes then begin
// this is a group mode => update column caption
Columns[ColToBuildGroup(aCol)].Title.Caption:=CurModeRow.Mode.Name;
end;
end else begin
// this is a sub flag => should be empty
NewValue:='';
end;
end else if ACol=TypeCol then begin
if CurModeRow.Mode.ShowIncludes then begin
// this is a group mode => no flags allowed
NewValue:='';
end else begin
NewValue:=SpecialCharsToSpaces(NewValue,true);
if (CurModeRow.Flag=nil) then begin
// create flag
CurModeRow.FFlag:=CurModeRow.Mode.AddFlag('','');
end;
// set variable name
CurModeRow.Flag.Variable:=NewValue;
UpdateValuePickList;
NewValue:=SpecialCharsToSpaces(NewValue,true);
if (CurModeRow.Flag=nil) then begin
// create flag
CurModeRow.FFlag:=CurModeRow.Mode.AddFlag('','');
end;
// set variable name
CurModeRow.Flag.Variable:=NewValue;
UpdateValuePickList;
end else if ACol=ValueCol then begin
if CurModeRow.Mode.ShowIncludes then begin
// this is a group mode => no flags allowed
NewValue:='';
end else begin
NewValue:=SpecialCharsToSpaces(NewValue,true);
if (CurModeRow.Flag=nil) then
// no flag => no value
NewValue:=''
else
// set new value
CurModeRow.Flag.Value:=NewValue;
end;
NewValue:=SpecialCharsToSpaces(NewValue,true);
if (CurModeRow.Flag=nil) then
// no flag => no value
NewValue:=''
else
// set new value
CurModeRow.Flag.Value:=NewValue;
end;
end;
end;
@ -486,9 +471,7 @@ procedure TBuildModesGrid.SetCheckboxState(const aCol, aRow: Integer;
var
CurModeRow: TBuildModeGridRow;
GrpID: LongInt;
GrpMode: TBuildMode;
NewState: TCheckBoxState;
dummystate: TCheckboxState;
begin
//DebugLn(['TBuildModesGrid.SetCheckboxState Col=',acol,' Row=',arow,' State=',ord(aState)]);
NewState:=cbUnchecked;
@ -497,33 +480,7 @@ begin
CurModeRow:=ModeRows[aRow-1];
GrpID:=ColToBuildGroup(aCol);
if (GrpID>=0) and (GrpID<GroupModeCount) then begin
if ShowGroupGrid or (not CurModeRow.Mode.ShowIncludes) then begin
GrpMode:=ModeRows[GrpID].Mode;
if CurModeRow.Mode=GrpMode then begin
// invalid circle
DebugLn(['TBuildModesGrid.SetCheckboxState invalid circle']);
end else if CurModeRow.Mode.IsIncludedBy(GrpMode)<>(aState=cbChecked) then
begin
// state changed
//DebugLn(['TBuildModesGrid.SetCheckboxState INCLUDE CHANGE check=',aState=cbChecked,' GrpMode=',GrpMode.Name,' ClickedMode=',CurModeRow.Mode.Name]);
if aState=cbChecked then begin
GrpMode.Include(CurModeRow.Mode);
NewState:=cbChecked;
end else begin
GrpMode.Exclude(CurModeRow.Mode);
end;
InvalidateCol(1); // update selected
GetCheckBoxState(aCol,aRow,dummystate);
end else begin
// state kept
//DebugLn(['TBuildModesGrid.SetCheckboxState STATE KEPT']);
if CurModeRow.Mode.IsIncludedBy(GrpMode) then
NewState:=cbChecked;
end;
end else begin
// group grid is hidden => keep state
DebugLn(['TBuildModesGrid.SetCheckboxState group grid is hidden']);
end;
end else if (aCol=1) and (CurModeRow.IndexInGroup=0) then begin
if Graph.SelectedMode=CurModeRow.Mode then
Graph.SelectedMode:=nil
@ -586,12 +543,6 @@ const
var
CurModeRow: TBuildModeGridRow;
TypeCol: Integer;
GrpID: LongInt;
x: Integer;
y: Integer;
RowGrpID: Integer;
BezierPoints: PPoint;
r: Integer;
begin
if (aRow>=1) and (aRow<=ModeRowCount) then begin
TypeCol:=GetTypeCol;
@ -605,54 +556,6 @@ begin
DrawGrid(aCol=TypeCol-1,
CurModeRow.IndexInGroup=CurModeRow.Mode.FlagCount-1);
exit;
end else if CurModeRow.Mode.ShowIncludes then begin
GrpID:=ColToBuildGroup(aCol);
if aCol>=TypeCol then begin
// groups have no type/value
PrepareCanvas(aCol, aRow, aState);
Canvas.FillRect(aRect);
if aRow=GroupModeCount then
DrawGrid(false,true);
exit;
end else if (GrpID>=0) and (GrpID<GroupModeCount) then begin
// draw paths from mode row to mode column
PrepareCanvas(aCol, aRow, aState);
Canvas.FillRect(aRect);
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clBtnFace;
Canvas.Pen.Style := psClear;
x:=(aRect.Left+aRect.Right) div 2;
y:=(aRect.Top+aRect.Bottom) div 2;
r:=Min(aRect.Right-aRect.Left,aRect.Bottom-aRect.Top) div 2;
RowGrpID:=aRow-1;
if GrpID=RowGrpID then begin
// draw curve left to bottom
GetMem(BezierPoints,SizeOf(TPoint)*10);
BezierPoints[0]:=Point(x-r,y-w); // middle,left
BezierPoints[1]:=Point(x-r+10,y-w); // to the right
BezierPoints[2]:=Point(x+w,y+r-10); // downwards
BezierPoints[3]:=Point(x+w,y+r); // bottom, middle
BezierPoints[4]:=Point(x+w-10,y+r); // to the left
BezierPoints[5]:=Point(x-w-10,y+r); // to the left
BezierPoints[6]:=Point(x-w,y+r); // bottom, middle
BezierPoints[7]:=Point(x-w,y+r-10); // upwards
BezierPoints[8]:=Point(x-r-10,y+w); // to the left
BezierPoints[9]:=Point(x-r,y+w); // middle,left
Canvas.PolyBezier(BezierPoints,10,true,true);
Freemem(BezierPoints);
Canvas.FillRect(aRect.Left,y-w,x-r,y+w+1);
Canvas.FillRect(x-w,y+r,x+w+1,aRect.Bottom);
end else if GrpID>RowGrpID then begin
// draw left to right
Canvas.FillRect(aRect.Left,y-w,aRect.Right,y+w+1);
end else begin
// draw top to bottom
Canvas.FillRect(x-w,aRect.Top,x+w+1,aRect.Bottom);
end;
if aRow=GroupModeCount then
DrawGrid(false,true);
exit;
end;
end;
end;
//DebugLn(['TBuildModesGrid.DrawCell draw default ',aCol,' ',aRow]);
@ -697,7 +600,6 @@ begin
Result:=Graph.AddMode(Graph.GetUniqueModeName(nil,nil));
if Group then
begin
Result.ShowIncludes:=true;
CurFlag:=nil;
InsertPos:=GroupModeCount;
InsertCol:=BuildGroupToCol(GroupModeCount-1);
@ -733,14 +635,6 @@ begin
end;
//DebugLn(['TBuildModesGrid.InsertNewBuildFlagBehind ',Row]);
CurModeRow:=ModeRows[Row-1];
if CurModeRow.Mode.ShowIncludes then
begin
MessageDlg(lisUnableToAddSetting,
Format(lisIsAGroupASettingCanOnlyBeAddedToNormalBuildModes, [
CurModeRow.Mode.Name]),
mtError, [mbCancel], 0);
exit;
end;
Result:=CurModeRow.Mode.InsertFlag(CurModeRow.IndexInGroup+1,'','');
InsertPos:=Row+1;
GridRow:=TBuildModeGridRow.Create(CurModeRow.Mode,Result);
@ -754,7 +648,6 @@ end;
procedure TBuildModesGrid.DeleteSelectedModeRow;
var
CurModeRow: TBuildModeGridRow;
GroupCol: LongInt;
begin
if (Row<1) or (Row>ModeRowCount) then
begin
@ -763,7 +656,7 @@ begin
exit;
end;
CurModeRow:=ModeRows[Row-1];
if (not CurModeRow.Mode.ShowIncludes) and (CurModeRow.Mode.FlagCount>1) then
if (CurModeRow.Mode.FlagCount>1) then
begin
// delete flag
if (CurModeRow.Flag.Value<>'') or (CurModeRow.Flag.Variable<>'') then
@ -783,12 +676,6 @@ begin
mtConfirmation,[mbYes,mbNo],0)<>mrYes
then
exit;
if CurModeRow.Mode.ShowIncludes then begin
// delete a group build mode
GroupCol:=Row;
DeleteColRow(true,GroupCol);
dec(FGroupModeCount);
end;
// delete a normal build mode
FModeRows.Remove(CurModeRow);
DeleteColRow(false,Row);
@ -808,19 +695,8 @@ begin
end;
function TBuildModesGrid.CellToInclude(aCol, aRow: integer): boolean;
var
GrpID: LongInt;
CurMode: TBuildModeGridRow;
begin
//DebugLn(['TBuildModesGrid.CellToInclude Col=',aCol,' aRow=',aRow,' GroupModeCount=',GroupModeCount]);
if (aRow>=1) and (ARow<=ModeRowCount) then begin
CurMode:=ModeRows[aRow-1];
GrpID:=ColToBuildGroup(aCol);
if (GrpID>=0) and (GrpID<GroupModeCount) then begin
if CurMode.Mode.IsIncludedBy(ModeRows[GrpID].Mode) then
exit(true);
end;
end;
Result:=false;
end;
@ -835,19 +711,12 @@ begin
end;
procedure TBuildModesGrid.RebuildGrid;
var
GroupInsertPos: Integer;
procedure AddRow(CurMode: TBuildMode; NewRow: TBuildModeGridRow);
var
InsertPos: LongInt;
begin
if CurMode.ShowIncludes then begin
InsertPos:=GroupInsertPos;
inc(GroupInsertPos);
end else begin
InsertPos:=FModeRows.Count;
end;
InsertPos:=FModeRows.Count;
if (InsertPos=0) or (ModeRows[InsertPos-1].Mode<>CurMode) then
NewRow.IndexInGroup:=0
else
@ -868,11 +737,9 @@ begin
FRebuilding:=true;
try
ClearModeRows;
GroupInsertPos:=0;
// create rows
for i:=0 to Graph.ModeCount-1 do begin
CurMode:=Graph.Modes[i];
if CurMode.ShowIncludes then inc(FGroupModeCount);
if (CurMode.FlagCount=0) then begin
// no flags => create an empty one
NewRow:=TBuildModeGridRow.Create(CurMode,nil);
@ -944,9 +811,9 @@ var
Mode: TBuildModeGridRow;
begin
Mode:=Grid.SelectedModeRow;
NewBuildFlagSpeedButton.Enabled:=(Mode<>nil) and (not Mode.Mode.ShowIncludes);
NewBuildFlagSpeedButton.Enabled:=(Mode<>nil);
DeleteBMRowSpeedButton.Enabled:=(Mode<>nil);
if (Mode<>nil) and (not Mode.Mode.ShowIncludes) and (Mode.Mode.FlagCount>1)
if (Mode<>nil) and (Mode.Mode.FlagCount>1)
then
DeleteBMRowSpeedButton.Hint:=lisDeleteSetting
else