mirror of https://gitlab.com/basile.b/dexed.git
fixes for the widgets that replace the "free project"
This commit is contained in:
parent
ed15c31b57
commit
9a1f542253
|
@ -133,6 +133,11 @@ type
|
|||
|
||||
(**
|
||||
* An implementer is informed about the current project(s).
|
||||
* Usually observer should keep track of two ICECOmmonProject:
|
||||
* - the free project: the project that's not in a group and that has to
|
||||
* be freed manualy in order to be replaced.
|
||||
* - the current project which can be either the free project or one of the
|
||||
* project in the group
|
||||
*)
|
||||
ICEProjectObserver = interface(ISubjectType)
|
||||
['ICEProjectObserver']
|
||||
|
|
|
@ -14,6 +14,7 @@ type
|
|||
TDDHandler = class(TObject, ICEProjectObserver)
|
||||
private
|
||||
fProj: ICECommonProject;
|
||||
fFreeProj: ICECommonProject;
|
||||
procedure projNew(aProject: ICECommonProject);
|
||||
procedure projChanged(aProject: ICECommonProject);
|
||||
procedure projClosing(aProject: ICECommonProject);
|
||||
|
@ -52,6 +53,8 @@ end;
|
|||
procedure TDDHandler.projNew(aProject: ICECommonProject);
|
||||
begin
|
||||
fProj := aProject;
|
||||
if not fProj.inGroup then
|
||||
fFreeProj := fProj;
|
||||
end;
|
||||
|
||||
procedure TDDHandler.projChanged(aProject: ICECommonProject);
|
||||
|
@ -60,13 +63,16 @@ end;
|
|||
|
||||
procedure TDDHandler.projClosing(aProject: ICECommonProject);
|
||||
begin
|
||||
if (fProj <> nil) and (fProj = aProject) then
|
||||
fProj := nil;
|
||||
if aProject = fFreeProj then
|
||||
fFreeProj := nil;
|
||||
end;
|
||||
|
||||
procedure TDDHandler.projFocused(aProject: ICECommonProject);
|
||||
begin
|
||||
fProj := aProject;
|
||||
if not fProj.inGroup then
|
||||
fFreeProj := fProj;
|
||||
end;
|
||||
|
||||
procedure TDDHandler.projCompiling(aProject: ICECommonProject);
|
||||
|
@ -128,24 +134,22 @@ begin
|
|||
|
||||
if isValidNativeProject(fname) then
|
||||
begin
|
||||
if assigned(fProj) then
|
||||
if assigned(fFreeProj) then
|
||||
begin
|
||||
if fProj.modified and not fProj.inGroup and
|
||||
(dlgFileChangeClose(fProj.filename) = mrCancel) then
|
||||
if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then
|
||||
exit;
|
||||
fProj.getProject.Free;
|
||||
fFreeProj.getProject.Free;
|
||||
end;
|
||||
TCENativeProject.create(nil);
|
||||
proj := true;
|
||||
end
|
||||
else if isValidDubProject(fname) then
|
||||
begin
|
||||
if assigned(fProj) then
|
||||
if assigned(fFreeProj) and not fFreeProj.inGroup then
|
||||
begin
|
||||
if fProj.modified and not fProj.inGroup and
|
||||
(dlgFileChangeClose(fProj.filename) = mrCancel) then
|
||||
if fProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then
|
||||
exit;
|
||||
fProj.getProject.Free;
|
||||
fFreeProj.getProject.Free;
|
||||
end;
|
||||
TCEDubProject.create(nil);
|
||||
proj := true;
|
||||
|
|
|
@ -59,6 +59,7 @@ type
|
|||
);
|
||||
private
|
||||
fProj: ICECommonProject;
|
||||
fFreeProj: ICECommonProject;
|
||||
procedure updateButtonsState;
|
||||
procedure projNew(aProject: ICECommonProject);
|
||||
procedure projChanged(aProject: ICECommonProject);
|
||||
|
@ -121,6 +122,8 @@ end;
|
|||
procedure TCELibManEditorWidget.projNew(aProject: ICECommonProject);
|
||||
begin
|
||||
fProj := aProject;
|
||||
if not aProject.inGroup then
|
||||
fFreeProj := aProject;
|
||||
end;
|
||||
|
||||
procedure TCELibManEditorWidget.projChanged(aProject: ICECommonProject);
|
||||
|
@ -134,15 +137,17 @@ end;
|
|||
|
||||
procedure TCELibManEditorWidget.projClosing(aProject: ICECommonProject);
|
||||
begin
|
||||
if fProj <> aProject then
|
||||
exit;
|
||||
fProj := nil;
|
||||
if aProject = fFreeProj then
|
||||
fFreeProj := nil;
|
||||
updateButtonsState;
|
||||
end;
|
||||
|
||||
procedure TCELibManEditorWidget.projFocused(aProject: ICECommonProject);
|
||||
begin
|
||||
fProj := aProject;
|
||||
if not aProject.inGroup then
|
||||
fFreeProj := aProject;
|
||||
updateButtonsState;
|
||||
end;
|
||||
|
||||
|
@ -511,24 +516,22 @@ begin
|
|||
//
|
||||
if isValidNativeProject(fname) then
|
||||
begin
|
||||
if assigned(fProj) then
|
||||
if assigned(fFreeProj) then
|
||||
begin
|
||||
if fProj.modified and not fProj.inGroup and
|
||||
(dlgFileChangeClose(fProj.filename) = mrCancel) then
|
||||
if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then
|
||||
exit;
|
||||
fProj.getProject.Free;
|
||||
fFreeProj.getProject.Free;
|
||||
end;
|
||||
TCENativeProject.create(nil);
|
||||
fProj.loadFromFile(fname);
|
||||
end
|
||||
else if isValidDubProject(fname) then
|
||||
begin
|
||||
if assigned(fProj) then
|
||||
if assigned(fFreeProj) then
|
||||
begin
|
||||
if fProj.modified and not fProj.inGroup and
|
||||
(dlgFileChangeClose(fProj.filename) = mrCancel) then
|
||||
if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then
|
||||
exit;
|
||||
fProj.getProject.Free;
|
||||
fFreeProj.getProject.Free;
|
||||
end;
|
||||
TCEDubProject.create(nil);
|
||||
fProj.loadFromFile(fname);
|
||||
|
|
|
@ -85,6 +85,7 @@ type
|
|||
procedure TreeEnter(Sender: TObject);
|
||||
private
|
||||
fProj: ICECommonProject;
|
||||
fFreeProj: ICECommonProject;
|
||||
fFavorites: TStringList;
|
||||
fLastFold: string;
|
||||
fLastListOrTree: TControl;
|
||||
|
@ -307,6 +308,8 @@ end;
|
|||
procedure TCEMiniExplorerWidget.projNew(aProject: ICECommonProject);
|
||||
begin
|
||||
fProj := aProject;
|
||||
if not aProject.inGroup then
|
||||
fFreeProj := aProject;
|
||||
end;
|
||||
|
||||
procedure TCEMiniExplorerWidget.projChanged(aProject: ICECommonProject);
|
||||
|
@ -315,13 +318,16 @@ end;
|
|||
|
||||
procedure TCEMiniExplorerWidget.projClosing(aProject: ICECommonProject);
|
||||
begin
|
||||
if fProj = aProject then
|
||||
fProj := nil;
|
||||
if aProject = fFreeProj then
|
||||
fFreeProj := nil;
|
||||
end;
|
||||
|
||||
procedure TCEMiniExplorerWidget.projFocused(aProject: ICECommonProject);
|
||||
begin
|
||||
fProj := aProject;
|
||||
if not aProject.inGroup then
|
||||
fFreeProj := aProject;
|
||||
if visible and aProject.fileName.fileExists and fContextExpand then
|
||||
expandPath(aProject.fileName.extractFilePath);
|
||||
end;
|
||||
|
@ -470,24 +476,22 @@ begin
|
|||
{$ENDIF}
|
||||
if isValidNativeProject(fname) then
|
||||
begin
|
||||
if assigned(fProj) then
|
||||
if assigned(fFreeProj) then
|
||||
begin
|
||||
if not fProj.inGroup and fProj.modified and
|
||||
(dlgFileChangeClose(fProj.filename) = mrCancel) then
|
||||
if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then
|
||||
exit;
|
||||
fProj.getProject.Free;
|
||||
fFreeProj.getProject.Free;
|
||||
end;
|
||||
TCENativeProject.create(nil);
|
||||
proj := true;
|
||||
end
|
||||
else if isValidDubProject(fname) then
|
||||
begin
|
||||
if assigned(fProj) then
|
||||
if assigned(fFreeProj) then
|
||||
begin
|
||||
if not fProj.inGroup and fProj.modified and
|
||||
(dlgFileChangeClose(fProj.filename) = mrCancel) then
|
||||
if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then
|
||||
exit;
|
||||
fProj.getProject.Free;
|
||||
fFreeProj.getProject.Free;
|
||||
end;
|
||||
TCEDubProject.create(nil);
|
||||
proj := true;
|
||||
|
|
Loading…
Reference in New Issue