mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 21:39:21 +02:00
qt intf: combobox from Luis
git-svn-id: trunk@10004 -
This commit is contained in:
parent
4f6130917f
commit
ab3ba51719
@ -141,7 +141,7 @@ type
|
|||||||
ParentClass: TClass): integer;
|
ParentClass: TClass): integer;
|
||||||
function AddJITComponentFromStream(BinStream: TStream; ParentClass: TClass;
|
function AddJITComponentFromStream(BinStream: TStream; ParentClass: TClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive: Boolean):integer;
|
Interactive, Visible: Boolean):integer;
|
||||||
procedure DestroyJITComponent(JITComponent: TComponent);
|
procedure DestroyJITComponent(JITComponent: TComponent);
|
||||||
procedure DestroyJITComponent(Index: integer);
|
procedure DestroyJITComponent(Index: integer);
|
||||||
function IndexOf(JITComponent: TComponent): integer;
|
function IndexOf(JITComponent: TComponent): integer;
|
||||||
@ -650,8 +650,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TJITComponentList.AddJITComponentFromStream(BinStream: TStream;
|
function TJITComponentList.AddJITComponentFromStream(BinStream: TStream;
|
||||||
ParentClass: TClass; const NewUnitName: ShortString; Interactive: Boolean
|
ParentClass: TClass; const NewUnitName: ShortString;
|
||||||
):integer;
|
Interactive, Visible: Boolean):integer;
|
||||||
// returns new index
|
// returns new index
|
||||||
// -1 = invalid stream
|
// -1 = invalid stream
|
||||||
var
|
var
|
||||||
@ -663,7 +663,6 @@ begin
|
|||||||
Result:=-1;
|
Result:=-1;
|
||||||
NewClassName:=GetClassNameFromLRSStream(BinStream, IsInherited);
|
NewClassName:=GetClassNameFromLRSStream(BinStream, IsInherited);
|
||||||
if IsInherited then ;
|
if IsInherited then ;
|
||||||
{ TODO: If IsInherited, read ancestor form stream }
|
|
||||||
if NewClassName='' then begin
|
if NewClassName='' then begin
|
||||||
MessageDlg('No classname in stream found.',mtError,[mbOK],0);
|
MessageDlg('No classname in stream found.',mtError,[mbOK],0);
|
||||||
exit;
|
exit;
|
||||||
|
@ -193,25 +193,26 @@ each control that's dropped onto the form
|
|||||||
function CreateUniqueComponentName(AComponent: TComponent): string;
|
function CreateUniqueComponentName(AComponent: TComponent): string;
|
||||||
function CreateUniqueComponentName(const AClassName: string;
|
function CreateUniqueComponentName(const AClassName: string;
|
||||||
OwnerComponent: TComponent): string;
|
OwnerComponent: TComponent): string;
|
||||||
Function CreateComponentInterface(AComponent: TComponent): TIComponentInterface;
|
function CreateComponentInterface(AComponent: TComponent): TIComponentInterface;
|
||||||
procedure CreateChildComponentInterfaces(AComponent: TComponent);
|
procedure CreateChildComponentInterfaces(AComponent: TComponent);
|
||||||
Function GetDefaultComponentParent(TypeClass: TComponentClass
|
function GetDefaultComponentParent(TypeClass: TComponentClass
|
||||||
): TIComponentInterface; override;
|
): TIComponentInterface; override;
|
||||||
Function GetDefaultComponentPosition(TypeClass: TComponentClass;
|
function GetDefaultComponentPosition(TypeClass: TComponentClass;
|
||||||
ParentCI: TIComponentInterface;
|
ParentCI: TIComponentInterface;
|
||||||
var X,Y: integer): boolean; override;
|
var X,Y: integer): boolean; override;
|
||||||
function CreateComponent(ParentCI: TIComponentInterface;
|
function CreateComponent(ParentCI: TIComponentInterface;
|
||||||
TypeClass: TComponentClass;
|
TypeClass: TComponentClass;
|
||||||
const AUnitName: shortstring;
|
const AUnitName: shortstring;
|
||||||
X,Y,W,H: Integer): TIComponentInterface; override;
|
X,Y,W,H: Integer): TIComponentInterface; override;
|
||||||
Function CreateComponentFromStream(BinStream: TStream;
|
function CreateComponentFromStream(BinStream: TStream;
|
||||||
AncestorType: TComponentClass;
|
AncestorType: TComponentClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive: boolean): TIComponentInterface; override;
|
Interactive: boolean;
|
||||||
Function CreateChildComponentFromStream(BinStream: TStream;
|
Visible: boolean = true): TIComponentInterface; override;
|
||||||
|
function CreateChildComponentFromStream(BinStream: TStream;
|
||||||
ComponentClass: TComponentClass; Root: TComponent;
|
ComponentClass: TComponentClass; Root: TComponent;
|
||||||
ParentControl: TWinControl): TIComponentInterface; override;
|
ParentControl: TWinControl): TIComponentInterface; override;
|
||||||
Procedure SetComponentNameAndClass(CI: TIComponentInterface;
|
procedure SetComponentNameAndClass(CI: TIComponentInterface;
|
||||||
const NewName, NewClassName: shortstring);
|
const NewName, NewClassName: shortstring);
|
||||||
|
|
||||||
// define properties
|
// define properties
|
||||||
@ -1427,7 +1428,8 @@ end;
|
|||||||
|
|
||||||
Function TCustomFormEditor.CreateComponentFromStream(
|
Function TCustomFormEditor.CreateComponentFromStream(
|
||||||
BinStream: TStream; AncestorType: TComponentClass;
|
BinStream: TStream; AncestorType: TComponentClass;
|
||||||
const NewUnitName: ShortString; Interactive: boolean): TIComponentInterface;
|
const NewUnitName: ShortString; Interactive: boolean;
|
||||||
|
Visible: boolean): TIComponentInterface;
|
||||||
var
|
var
|
||||||
NewJITIndex: integer;
|
NewJITIndex: integer;
|
||||||
NewComponent: TComponent;
|
NewComponent: TComponent;
|
||||||
@ -1439,14 +1441,14 @@ begin
|
|||||||
RaiseException('TCustomFormEditor.CreateComponentFromStream ClassName='+
|
RaiseException('TCustomFormEditor.CreateComponentFromStream ClassName='+
|
||||||
AncestorType.ClassName);
|
AncestorType.ClassName);
|
||||||
NewJITIndex := JITList.AddJITComponentFromStream(BinStream,AncestorType,
|
NewJITIndex := JITList.AddJITComponentFromStream(BinStream,AncestorType,
|
||||||
NewUnitName,Interactive);
|
NewUnitName,Interactive,Visible);
|
||||||
if NewJITIndex < 0 then begin
|
if NewJITIndex < 0 then begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
NewComponent:=JITList[NewJITIndex];
|
NewComponent:=JITList[NewJITIndex];
|
||||||
|
|
||||||
// create a component interface for the form
|
// create a component interface
|
||||||
Result:=CreateComponentInterface(NewComponent);
|
Result:=CreateComponentInterface(NewComponent);
|
||||||
|
|
||||||
CreateChildComponentInterfaces(NewComponent);
|
CreateChildComponentInterfaces(NewComponent);
|
||||||
|
237
ide/main.pp
237
ide/main.pp
@ -576,10 +576,10 @@ type
|
|||||||
function DoLoadLFM(AnUnitInfo: TUnitInfo; Flags: TOpenFlags): TModalResult;
|
function DoLoadLFM(AnUnitInfo: TUnitInfo; Flags: TOpenFlags): TModalResult;
|
||||||
function DoLoadLFM(AnUnitInfo: TUnitInfo; LFMBuf: TCodeBuffer;
|
function DoLoadLFM(AnUnitInfo: TUnitInfo; LFMBuf: TCodeBuffer;
|
||||||
Flags: TOpenFlags; CloseDsgnForm: boolean): TModalResult;
|
Flags: TOpenFlags; CloseDsgnForm: boolean): TModalResult;
|
||||||
function DoLoadAncestorComponent(AnUnitInfo: TUnitInfo;
|
function DoLoadHiddenResourceComponent(AnUnitInfo: TUnitInfo;
|
||||||
const AncestorName: string;
|
const AComponentClassName: string; Flags: TOpenFlags;
|
||||||
var AncestorClass: TComponentClass;
|
var AComponentClass: TComponentClass;
|
||||||
Flags: TOpenFlags): TModalResult;
|
var ComponentUnitInfo: TUnitInfo): TModalResult;
|
||||||
|
|
||||||
// methods for 'close unit'
|
// methods for 'close unit'
|
||||||
function CloseDesignerForm(AnUnitInfo: TUnitInfo): TModalResult;
|
function CloseDesignerForm(AnUnitInfo: TUnitInfo): TModalResult;
|
||||||
@ -4736,6 +4736,7 @@ var
|
|||||||
APersistentClass: TPersistentClass;
|
APersistentClass: TPersistentClass;
|
||||||
ACaption, AText: String;
|
ACaption, AText: String;
|
||||||
NewUnitName: String;
|
NewUnitName: String;
|
||||||
|
AncestorUnitInfo: TUnitInfo;
|
||||||
begin
|
begin
|
||||||
debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
|
debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
|
||||||
|
|
||||||
@ -4748,7 +4749,11 @@ begin
|
|||||||
|
|
||||||
// close old designer form
|
// close old designer form
|
||||||
if CloseDsgnForm then
|
if CloseDsgnForm then
|
||||||
CloseDesignerForm(AnUnitInfo);
|
CloseDesignerForm(AnUnitInfo)
|
||||||
|
else if AnUnitInfo.Component<>nil then begin
|
||||||
|
DebugLn(['TMainIDE.DoLoadLFM INCONSISTENCY CloseDsgnForm=',CloseDsgnForm,' Filename=',AnUnitInfo.Filename,' Component=',dbgsName(AnUnitInfo.Component)]);
|
||||||
|
exit(mrAbort);
|
||||||
|
end;
|
||||||
|
|
||||||
//debugln('TMainIDE.DoLoadLFM LFM file loaded, parsing "',LFMBuf.Filename,'" ...');
|
//debugln('TMainIDE.DoLoadLFM LFM file loaded, parsing "',LFMBuf.Filename,'" ...');
|
||||||
|
|
||||||
@ -4763,7 +4768,7 @@ begin
|
|||||||
|
|
||||||
// find the classname of the LFM, and check for inherited form
|
// find the classname of the LFM, and check for inherited form
|
||||||
ReadLFMHeader(LFMBuf.Source,NewClassName,LFMType);
|
ReadLFMHeader(LFMBuf.Source,NewClassName,LFMType);
|
||||||
if NewClassName='' then begin
|
if (NewClassName='') or (LFMType='') then begin
|
||||||
Result:=MessageDlg(lisLFMFileCorrupt,
|
Result:=MessageDlg(lisLFMFileCorrupt,
|
||||||
Format(lisUnableToFindAValidClassnameIn, ['"', LFMBuf.Filename, '"']),
|
Format(lisUnableToFindAValidClassnameIn, ['"', LFMBuf.Filename, '"']),
|
||||||
mtError,[mbIgnore,mbCancel,mbAbort],0);
|
mtError,[mbIgnore,mbCancel,mbAbort],0);
|
||||||
@ -4797,12 +4802,13 @@ begin
|
|||||||
|
|
||||||
if (AncestorType=nil) then begin
|
if (AncestorType=nil) then begin
|
||||||
// try loading the ancestor first
|
// try loading the ancestor first
|
||||||
if DoLoadAncestorComponent(AnUnitInfo,NewAncestorName,AncestorType,Flags)
|
AncestorUnitInfo:=nil;
|
||||||
=mrAbort
|
Result:=DoLoadHiddenResourceComponent(AnUnitInfo,NewAncestorName,Flags,
|
||||||
then
|
AncestorType,AncestorUnitInfo);
|
||||||
exit(mrAbort);
|
if Result<>mrOk then exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// use TForm as default ancestor
|
||||||
if AncestorType=nil then
|
if AncestorType=nil then
|
||||||
AncestorType:=TForm;
|
AncestorType:=TForm;
|
||||||
//DebugLn('TMainIDE.DoLoadLFM Filename="',AnUnitInfo.Filename,'" AncestorClassName=',NewAncestorName,' AncestorType=',AncestorType.ClassName);
|
//DebugLn('TMainIDE.DoLoadLFM Filename="',AnUnitInfo.Filename,'" AncestorClassName=',NewAncestorName,' AncestorType=',AncestorType.ClassName);
|
||||||
@ -4839,7 +4845,8 @@ begin
|
|||||||
TxtLFMStream.Free;
|
TxtLFMStream.Free;
|
||||||
end;
|
end;
|
||||||
if ComponentLoadingOk then begin
|
if ComponentLoadingOk then begin
|
||||||
if not (ofProjectLoading in Flags) then FormEditor1.ClearSelection;
|
if ([ofProjectLoading,ofLoadHiddenResource]*Flags=[]) then
|
||||||
|
FormEditor1.ClearSelection;
|
||||||
|
|
||||||
// create JIT component
|
// create JIT component
|
||||||
NewUnitName:=AnUnitInfo.UnitName;
|
NewUnitName:=AnUnitInfo.UnitName;
|
||||||
@ -4864,24 +4871,27 @@ begin
|
|||||||
NewComponent:=CInterface.Component;
|
NewComponent:=CInterface.Component;
|
||||||
DebugLn('SUCCESS: streaming lfm="',LFMBuf.Filename,'"');
|
DebugLn('SUCCESS: streaming lfm="',LFMBuf.Filename,'"');
|
||||||
AnUnitInfo.Component:=NewComponent;
|
AnUnitInfo.Component:=NewComponent;
|
||||||
CreateDesignerForComponent(NewComponent);
|
|
||||||
AnUnitInfo.ComponentName:=NewComponent.Name;
|
AnUnitInfo.ComponentName:=NewComponent.Name;
|
||||||
AnUnitInfo.ComponentResourceName:=AnUnitInfo.ComponentName;
|
AnUnitInfo.ComponentResourceName:=AnUnitInfo.ComponentName;
|
||||||
DesignerForm:=FormEditor1.GetDesignerForm(AnUnitInfo.Component);
|
if not (ofLoadHiddenResource in Flags) then begin
|
||||||
|
CreateDesignerForComponent(NewComponent);
|
||||||
if not (ofProjectLoading in Flags) then begin
|
DesignerForm:=FormEditor1.GetDesignerForm(AnUnitInfo.Component);
|
||||||
FDisplayState:= dsForm;
|
end else begin
|
||||||
|
DesignerForm:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// select the new form (object inspector, formeditor, control selection)
|
// select the new form (object inspector, formeditor, control selection)
|
||||||
if not (ofProjectLoading in Flags) then begin
|
if ([ofProjectLoading,ofLoadHiddenResource]*Flags=[]) then begin
|
||||||
|
FDisplayState:= dsForm;
|
||||||
GlobalDesignHook.LookupRoot := NewComponent;
|
GlobalDesignHook.LookupRoot := NewComponent;
|
||||||
TheControlSelection.AssignPersistent(NewComponent);
|
TheControlSelection.AssignPersistent(NewComponent);
|
||||||
end;
|
end;
|
||||||
//DesignerForm.HandleNeeded;
|
|
||||||
LCLIntf.ShowWindow(DesignerForm.Handle,SW_SHOWNORMAL);
|
|
||||||
|
|
||||||
FLastFormActivated:=DesignerForm;
|
// show new form
|
||||||
|
if DesignerForm<>nil then begin
|
||||||
|
LCLIntf.ShowWindow(DesignerForm.Handle,SW_SHOWNORMAL);
|
||||||
|
FLastFormActivated:=DesignerForm;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
@ -4893,79 +4903,136 @@ begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoLoadAncestorComponent(AnUnitInfo: TUnitInfo;
|
function TMainIDE.DoLoadHiddenResourceComponent(AnUnitInfo: TUnitInfo;
|
||||||
const AncestorName: string; var AncestorClass: TComponentClass;
|
const AComponentClassName: string; Flags: TOpenFlags;
|
||||||
Flags: TOpenFlags): TModalResult;
|
var AComponentClass: TComponentClass; var ComponentUnitInfo: TUnitInfo
|
||||||
|
): TModalResult;
|
||||||
|
|
||||||
|
function TryUnit(const UnitFilename: string; out TheModalResult: TModalResult
|
||||||
|
): boolean;
|
||||||
|
// returns true if the unit contains the component class and sets
|
||||||
|
// TheModalResult to the result of the loading
|
||||||
|
var
|
||||||
|
LFMFilename: String;
|
||||||
|
LFMCode: TCodeBuffer;
|
||||||
|
LFMClassName: string;
|
||||||
|
LFMType: string;
|
||||||
|
CurUnitInfo: TUnitInfo;
|
||||||
|
UnitCode: TCodeBuffer;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
TheModalResult:=mrCancel;
|
||||||
|
|
||||||
|
CurUnitInfo:=Project1.UnitInfoWithFilename(UnitFilename);
|
||||||
|
if (CurUnitInfo<>nil) and (CurUnitInfo.Component<>nil) then
|
||||||
|
begin
|
||||||
|
if CompareText(CurUnitInfo.Component.ClassName,AComponentClassName)=0
|
||||||
|
then begin
|
||||||
|
// component found
|
||||||
|
ComponentUnitInfo:=CurUnitInfo;
|
||||||
|
AComponentClass:=TComponentClass(ComponentUnitInfo.Component.ClassType);
|
||||||
|
Result:=true;
|
||||||
|
end else begin
|
||||||
|
// this unit does not have this component
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||||
|
if not FileExists(LFMFilename) then exit;
|
||||||
|
|
||||||
|
// load the lfm file
|
||||||
|
TheModalResult:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText]);
|
||||||
|
if TheModalResult<>mrOk then begin
|
||||||
|
debugln('TMainIDE.DoLoadHiddenResourceComponent Failed loading ',LFMFilename);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
// read the LFM classname
|
||||||
|
ReadLFMHeader(LFMCode.Source,LFMClassName,LFMType);
|
||||||
|
if LFMType='' then ;
|
||||||
|
if CompareText(LFMClassName,AComponentClassName)<>0 then exit;
|
||||||
|
|
||||||
|
// component LFM found
|
||||||
|
Result:=true;
|
||||||
|
|
||||||
|
debugln('TMainIDE.DoLoadHiddenResourceComponent ',AnUnitInfo.Filename,' Loading ancestor unit ',UnitFilename);
|
||||||
|
// load unit source
|
||||||
|
TheModalResult:=LoadCodeBuffer(UnitCode,UnitFilename,[lbfCheckIfText]);
|
||||||
|
if TheModalResult<>mrOk then begin
|
||||||
|
debugln('TMainIDE.DoLoadHiddenResourceComponent Failed loading ',UnitFilename);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// create unit info
|
||||||
|
if CurUnitInfo=nil then begin
|
||||||
|
CurUnitInfo:=TUnitInfo.Create(UnitCode);
|
||||||
|
CurUnitInfo.ReadUnitNameFromSource(true);
|
||||||
|
Project1.AddFile(CurUnitInfo,false);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// load resource hidden
|
||||||
|
TheModalResult:=DoLoadLFM(CurUnitInfo,LFMCode,
|
||||||
|
Flags+[ofLoadHiddenResource],false);
|
||||||
|
if (TheModalResult=mrOk) then begin
|
||||||
|
ComponentUnitInfo:=CurUnitInfo;
|
||||||
|
AComponentClass:=TComponentClass(ComponentUnitInfo.Component.ClassType);
|
||||||
|
debugln('TMainIDE.DoLoadHiddenResourceComponent Wanted=',AComponentClassName,' Class=',AComponentClass.ClassName);
|
||||||
|
TheModalResult:=mrOk;
|
||||||
|
end else begin
|
||||||
|
debugln('TMainIDE.DoLoadHiddenResourceComponent Failed to load component ',AComponentClassName);
|
||||||
|
TheModalResult:=mrCancel;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
UsedUnitFilenames: TStrings;
|
UsedUnitFilenames: TStrings;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
LFMFilename: String;
|
|
||||||
LFMCode: TCodeBuffer;
|
|
||||||
LFMClassName: string;
|
|
||||||
LFMType: string;
|
|
||||||
UnitFilename: string;
|
|
||||||
AncestorUnitInfo: TUnitInfo;
|
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
|
|
||||||
// search ancestor lfm
|
// check for circles
|
||||||
debugln('TMainIDE.DoLoadAncestorComponent ',AnUnitInfo.Filename,' AncestorName=',AncestorName);
|
if AnUnitInfo.LoadingComponent then begin
|
||||||
|
Result:=QuestionDlg('Error','Unable to load the component class '
|
||||||
// search used units filenames
|
+'"'+AComponentClassName+'", because it depends on itself.',
|
||||||
UsedUnitFilenames:=nil;
|
mtError,[mrCancel,'Cancel loading this component',
|
||||||
try
|
mrAbort,'Abort whole loading'],0);
|
||||||
if not CodeToolBoss.FindUsedUnitFiles(AnUnitInfo.Source,UsedUnitFilenames)
|
exit;
|
||||||
then begin
|
|
||||||
DoJumpToCodeToolBossError;
|
|
||||||
Result:=mrCancel;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// search for every used unit the .lfm file
|
|
||||||
if (UsedUnitFilenames<>nil) then begin
|
|
||||||
for i:=UsedUnitFilenames.Count-1 downto 0 do begin
|
|
||||||
UnitFilename:=UsedUnitFilenames[i];
|
|
||||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
|
||||||
if FileExists(LFMFilename) then begin
|
|
||||||
// load the lfm file
|
|
||||||
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText]);
|
|
||||||
if Result<>mrOk then begin
|
|
||||||
debugln('TMainIDE.DoLoadAncestorComponent Failed loading ',LFMFilename);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
// read the LFM classname
|
|
||||||
ReadLFMHeader(LFMCode.Source,LFMClassName,LFMType);
|
|
||||||
if LFMType='' then ;
|
|
||||||
if CompareText(LFMClassName,AncestorName)=0 then begin
|
|
||||||
// ancestor LFM found
|
|
||||||
|
|
||||||
debugln('TMainIDE.DoLoadAncestorComponent ',AnUnitInfo.Filename,' Loading ancestor unit ',UnitFilename);
|
|
||||||
// TODO: open ancestor hidden
|
|
||||||
// WORKAROUND: just open it
|
|
||||||
// beware: don't close it or you will get strange errors
|
|
||||||
Result:=DoOpenEditorFile(UnitFilename,AnUnitInfo.EditorIndex+1,
|
|
||||||
Flags+[ofDoLoadResource,ofRegularFile]);
|
|
||||||
if (Result=mrOk) then begin
|
|
||||||
AncestorUnitInfo:=Project1.UnitInfoWithFilename(UnitFilename);
|
|
||||||
if (AncestorUnitInfo.Component<>nil) then begin
|
|
||||||
AncestorClass:=
|
|
||||||
TComponentClass(AncestorUnitInfo.Component.ClassType);
|
|
||||||
debugln('TMainIDE.DoLoadAncestorComponent AncestorClass=',AncestorClass.ClassName);
|
|
||||||
Result:=mrOk;
|
|
||||||
end else
|
|
||||||
debugln('TMainIDE.DoLoadAncestorComponent Failed to load ancestor component');
|
|
||||||
end;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
finally
|
|
||||||
UsedUnitFilenames.Free;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=mrCancel;
|
AnUnitInfo.LoadingComponent:=true;
|
||||||
|
try
|
||||||
|
// search component lfm
|
||||||
|
debugln('TMainIDE.DoLoadHiddenResourceComponent ',AnUnitInfo.Filename,' AComponentName=',AComponentClassName,' AComponentClass=',dbgsName(AComponentClass));
|
||||||
|
|
||||||
|
// first search the resource of ComponentUnitInfo
|
||||||
|
if ComponentUnitInfo<>nil then begin
|
||||||
|
if TryUnit(ComponentUnitInfo.Filename,Result) then exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// then search in used units
|
||||||
|
UsedUnitFilenames:=nil;
|
||||||
|
try
|
||||||
|
if not CodeToolBoss.FindUsedUnitFiles(AnUnitInfo.Source,UsedUnitFilenames)
|
||||||
|
then begin
|
||||||
|
DoJumpToCodeToolBossError;
|
||||||
|
Result:=mrCancel;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// search for every used unit the .lfm file
|
||||||
|
if (UsedUnitFilenames<>nil) then begin
|
||||||
|
for i:=UsedUnitFilenames.Count-1 downto 0 do begin
|
||||||
|
if TryUnit(UsedUnitFilenames[i],Result) then exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
UsedUnitFilenames.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result:=mrCancel;
|
||||||
|
finally
|
||||||
|
AnUnitInfo.LoadingComponent:=false;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
|
@ -202,6 +202,7 @@ const
|
|||||||
'ofMultiOpen',
|
'ofMultiOpen',
|
||||||
'ofDoNotLoadResource',
|
'ofDoNotLoadResource',
|
||||||
'ofDoLoadResource',
|
'ofDoLoadResource',
|
||||||
|
'ofLoadHiddenResource',
|
||||||
'ofAddToProject'
|
'ofAddToProject'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ type
|
|||||||
FIgnoreFileDateOnDiskValid: boolean;
|
FIgnoreFileDateOnDiskValid: boolean;
|
||||||
FIgnoreFileDateOnDisk: longint;
|
FIgnoreFileDateOnDisk: longint;
|
||||||
fLoaded: Boolean; // loaded in the source editor
|
fLoaded: Boolean; // loaded in the source editor
|
||||||
|
FLoadingComponent: boolean;
|
||||||
fModified: boolean;
|
fModified: boolean;
|
||||||
fNext, fPrev: array[TUnitInfoList] of TUnitInfo;
|
fNext, fPrev: array[TUnitInfoList] of TUnitInfo;
|
||||||
fOnFileBackup: TOnFileBackup;
|
fOnFileBackup: TOnFileBackup;
|
||||||
@ -226,6 +227,7 @@ type
|
|||||||
property FileReadOnly: Boolean read fFileReadOnly write SetFileReadOnly;
|
property FileReadOnly: Boolean read fFileReadOnly write SetFileReadOnly;
|
||||||
property HasResources: boolean read GetHasResources write fHasResources;
|
property HasResources: boolean read GetHasResources write fHasResources;
|
||||||
property Loaded: Boolean read fLoaded write SetLoaded;
|
property Loaded: Boolean read fLoaded write SetLoaded;
|
||||||
|
property LoadingComponent: boolean read FLoadingComponent write FLoadingComponent;
|
||||||
property Modified: boolean read fModified write fModified;// not Session data
|
property Modified: boolean read fModified write fModified;// not Session data
|
||||||
property SessionModified: boolean read FSessionModified write SetSessionModified;
|
property SessionModified: boolean read FSessionModified write SetSessionModified;
|
||||||
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
|
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
// Created by Svn2RevisionInc
|
// Created by Svn2RevisionInc
|
||||||
const RevisionStr = '9891';
|
const RevisionStr = '10002M';
|
||||||
|
@ -107,7 +107,8 @@ type
|
|||||||
function CreateComponentFromStream(BinStream: TStream;
|
function CreateComponentFromStream(BinStream: TStream;
|
||||||
AncestorType: TComponentClass;
|
AncestorType: TComponentClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive: boolean): TIComponentInterface; virtual; abstract;
|
Interactive: boolean;
|
||||||
|
Visible: boolean = true): TIComponentInterface; virtual; abstract;
|
||||||
function CreateChildComponentFromStream(BinStream: TStream;
|
function CreateChildComponentFromStream(BinStream: TStream;
|
||||||
ComponentClass: TComponentClass;
|
ComponentClass: TComponentClass;
|
||||||
Root: TComponent;
|
Root: TComponent;
|
||||||
|
@ -40,6 +40,7 @@ type
|
|||||||
ofMultiOpen, // set during loading multiple files
|
ofMultiOpen, // set during loading multiple files
|
||||||
ofDoNotLoadResource,// do not open form, datamodule, ... (overriding default)
|
ofDoNotLoadResource,// do not open form, datamodule, ... (overriding default)
|
||||||
ofDoLoadResource,// do open form, datamodule, ... (overriding default)
|
ofDoLoadResource,// do open form, datamodule, ... (overriding default)
|
||||||
|
ofLoadHiddenResource,// load component hidden
|
||||||
ofAddToProject // add file to project (if exists)
|
ofAddToProject // add file to project (if exists)
|
||||||
);
|
);
|
||||||
TOpenFlags = set of TOpenFlag;
|
TOpenFlags = set of TOpenFlag;
|
||||||
|
@ -8,6 +8,38 @@ uses Classes, StdCtrls, Controls, Graphics, SysUtils, qt4;
|
|||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
{ TQtComboStrings }
|
||||||
|
|
||||||
|
TQtComboStrings = class(TStrings)
|
||||||
|
private
|
||||||
|
FComboChanged: Boolean; // StringList and QtComboBox out of sync
|
||||||
|
FStringList: TStringList; // Holds the items to show
|
||||||
|
FQtComboBox: QComboBoxH; // Qt Widget
|
||||||
|
FOwner: TWinControl; // Lazarus Control Owning ListStrings
|
||||||
|
FUpdating: Boolean; // We're changing Qt Widget
|
||||||
|
procedure InternalUpdate;
|
||||||
|
procedure ExternalUpdate(var Astr: TStringList; Clear: Boolean = True);
|
||||||
|
procedure IsChanged; // OnChange triggered by program action
|
||||||
|
protected
|
||||||
|
function GetTextStr: string; override;
|
||||||
|
function GetCount: integer; override;
|
||||||
|
function Get(Index : Integer) : string; override;
|
||||||
|
//procedure SetSorted(Val : boolean); virtual;
|
||||||
|
public
|
||||||
|
constructor Create(ComboBoxH : QComboBoxH; TheOwner: TWinControl);
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure Assign(Source : TPersistent); override;
|
||||||
|
procedure Clear; override;
|
||||||
|
procedure Delete(Index : integer); override;
|
||||||
|
procedure Insert(Index : integer; const S: string); override;
|
||||||
|
procedure SetText(TheText: PChar); override;
|
||||||
|
//procedure Sort; virtual;
|
||||||
|
public
|
||||||
|
//property Sorted: boolean read FSorted write SetSorted;
|
||||||
|
property Owner: TWinControl read FOwner;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TQtListStrings }
|
{ TQtListStrings }
|
||||||
|
|
||||||
TQtListStrings = class(TStrings)
|
TQtListStrings = class(TStrings)
|
||||||
@ -567,5 +599,129 @@ begin
|
|||||||
Result := QImage_numBytes(Handle);
|
Result := QImage_numBytes(Handle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TQtComboStrings }
|
||||||
|
|
||||||
|
procedure TQtComboStrings.InternalUpdate;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtComboStrings.ExternalUpdate(var Astr: TStringList; Clear: Boolean
|
||||||
|
);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
data: QVariantH;
|
||||||
|
begin
|
||||||
|
|
||||||
|
data := QVariant_create(10); //Creates dummy data
|
||||||
|
|
||||||
|
FUpdating := True;
|
||||||
|
if Clear then
|
||||||
|
QComboBox_clear(FQtComboBox);
|
||||||
|
for i := 0 to AStr.Count -1 do
|
||||||
|
QComboBox_additem(FQtComboBox, @WideString(Astr[i]), data);
|
||||||
|
FUpdating := False;
|
||||||
|
IsChanged;
|
||||||
|
FUpdating := False;
|
||||||
|
|
||||||
|
QVariant_destroy(data); // Clean up
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtComboStrings.IsChanged;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtComboStrings.GetTextStr: string;
|
||||||
|
begin
|
||||||
|
Result:=inherited GetTextStr;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtComboStrings.GetCount: integer;
|
||||||
|
begin
|
||||||
|
if FComboChanged then InternalUpdate;
|
||||||
|
Result := FStringList.Count;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtComboStrings.Get(Index: Integer): string;
|
||||||
|
begin
|
||||||
|
if FComboChanged then InternalUpdate;
|
||||||
|
if Index < FStringList.Count then
|
||||||
|
Result := FStringList.Strings[Index]
|
||||||
|
else Result := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TQtComboStrings.Create(ComboBoxH: QComboBoxH; TheOwner: TWinControl
|
||||||
|
);
|
||||||
|
var
|
||||||
|
Method: TMethod;
|
||||||
|
Hook : QComboBox_hookH;
|
||||||
|
// Astr: WideString;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
|
||||||
|
{$ifdef VerboseQt}
|
||||||
|
if (ComboBoxH = nil) then WriteLn('TQtComboStrings.Create Unspecified ComboBoxH widget');
|
||||||
|
if (TheOwner = nil) then WriteLn('TQtComboStrings.Create Unspecified owner');
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
FStringList := TStringList.Create;
|
||||||
|
FQtComboBox := ComboBoxH;
|
||||||
|
FStringList.Text := TCustomComboBox(TheOwner).Items.Text;
|
||||||
|
FOwner:=TheOwner;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TQtComboStrings.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtComboStrings.Assign(Source: TPersistent);
|
||||||
|
begin
|
||||||
|
inherited Assign(Source);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtComboStrings.Clear;
|
||||||
|
begin
|
||||||
|
FUpdating := True;
|
||||||
|
FStringList.Clear;
|
||||||
|
QComboBox_clear(FQtComboBox);
|
||||||
|
FComboChanged := False;
|
||||||
|
FUpdating := False;
|
||||||
|
IsChanged;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtComboStrings.Delete(Index: integer);
|
||||||
|
begin
|
||||||
|
if FComboChanged then InternalUpdate;
|
||||||
|
|
||||||
|
if Index < FStringList.Count then
|
||||||
|
begin
|
||||||
|
FStringList.Delete(Index);
|
||||||
|
ExternalUpdate(FStringList,True);
|
||||||
|
FComboChanged := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtComboStrings.Insert(Index: integer; const S: string);
|
||||||
|
begin
|
||||||
|
if FComboChanged then InternalUpdate;
|
||||||
|
|
||||||
|
if Index < 0 then Index := 0;
|
||||||
|
|
||||||
|
if Index <= FStringList.Count then
|
||||||
|
begin
|
||||||
|
FStringList.Insert(Index,S);
|
||||||
|
ExternalUpdate(FStringList,True);
|
||||||
|
FComboChanged := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtComboStrings.SetText(TheText: PChar);
|
||||||
|
begin
|
||||||
|
inherited SetText(TheText);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -1071,10 +1071,11 @@ end;
|
|||||||
Returns: The state of the control
|
Returns: The state of the control
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
class function TQtWSCustomComboBox.GetItems(const ACustomComboBox: TCustomComboBox): TStrings;
|
class function TQtWSCustomComboBox.GetItems(const ACustomComboBox: TCustomComboBox): TStrings;
|
||||||
|
var
|
||||||
|
ComboBoxH: QComboBoxH;
|
||||||
begin
|
begin
|
||||||
Result := TStringList.Create;
|
ComboBoxH := QComboBoxH((TQtWidget(ACustomComboBox.Handle).Widget));
|
||||||
|
Result := TQtComboStrings.Create(ComboBoxH, ACustomComboBox);
|
||||||
Result.Text := ACustomComboBox.Items.Text;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
Loading…
Reference in New Issue
Block a user