mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 20:28:19 +02:00
IDE: creating component name from class name: check if removing leading T starts with a number
git-svn-id: trunk@32838 -
This commit is contained in:
parent
21f584b765
commit
ce6a9b8431
@ -5815,16 +5815,16 @@ begin
|
||||
DirTempl.AddChild(TDefineTemplate.Create('components path addition',
|
||||
Format(ctsAddsDirToSourcePath,['synedit']),
|
||||
SrcPathMacroName,
|
||||
d('../components/lazutils;'
|
||||
+'../components/codetools;'
|
||||
+'../lcl'
|
||||
d('../components/lazutils'
|
||||
+';../components/codetools'
|
||||
+';../lcl'
|
||||
+';../lcl/interfaces'
|
||||
+';../lcl/interfaces/'+WidgetType
|
||||
+'../ideintf;'
|
||||
+'../components/synedit;'
|
||||
+'../components/codetools;'
|
||||
+'../components/lazcontrols;'
|
||||
+'../components/custom;')
|
||||
+';../ideintf'
|
||||
+';../components/synedit'
|
||||
+';../components/codetools'
|
||||
+';../components/lazcontrols'
|
||||
+';../components/custom')
|
||||
+';'+SrcPath
|
||||
,da_Define));
|
||||
DirTempl.AddChild(TDefineTemplate.Create('main path addition',
|
||||
|
@ -44,7 +44,7 @@ uses
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, AvgLvlTree, TypInfo, LCLProc, LResources, Forms, Controls,
|
||||
LCLMemManager, LCLIntf, Dialogs,
|
||||
PropEditUtils, IDEProcs,
|
||||
PropEditUtils, PropEdits, IDEProcs,
|
||||
BasePkgManager;
|
||||
|
||||
type
|
||||
@ -785,8 +785,7 @@ begin
|
||||
ComponentPrefix:=ComponentClassName;
|
||||
if ComponentPrefix='' then
|
||||
ComponentPrefix:='Component';
|
||||
if ComponentPrefix[1] in ['t','T'] then
|
||||
ComponentPrefix:=copy(ComponentPrefix,2,length(ComponentPrefix));
|
||||
ComponentPrefix:=ClassNameToComponentName(ComponentPrefix);
|
||||
repeat
|
||||
ComponentName:=ComponentPrefix+IntToStr(a);
|
||||
ComponentClassName:='T'+ComponentName;
|
||||
@ -912,7 +911,7 @@ begin
|
||||
if FCurReadJITComponent.Name = '' then
|
||||
begin
|
||||
NewName := FCurReadJITComponent.ClassName;
|
||||
if NewName[1] in ['T', 't'] then
|
||||
if NewName[1]='T' then
|
||||
System.Delete(NewName, 1, 1);
|
||||
if FCurReadJITComponent is TControl then
|
||||
AControl:=TControl(FCurReadJITComponent)
|
||||
|
@ -2089,9 +2089,7 @@ begin
|
||||
i:=1;
|
||||
while true do begin
|
||||
j:=OwnerComponent.ComponentCount-1;
|
||||
Result:=AClassName;
|
||||
if (length(Result)>1) and (Result[1]='T') then
|
||||
Result:=RightStr(Result,length(Result)-1);
|
||||
Result:=ClassNameToComponentName(AClassName);
|
||||
if Result[length(Result)] in ['0'..'9'] then
|
||||
Result:=Result+'_';
|
||||
Result:=Result+IntToStr(i);
|
||||
|
@ -54,7 +54,7 @@ uses
|
||||
Laz_XMLCfg, CodeToolsConfig, ExprEval, FileProcs, DefineTemplates,
|
||||
CodeToolsCfgScript, CodeToolManager, CodeCache,
|
||||
// IDEIntf
|
||||
CompOptsIntf, ProjectIntf, MacroIntf, LazIDEIntf,
|
||||
PropEdits, CompOptsIntf, ProjectIntf, MacroIntf, LazIDEIntf,
|
||||
// IDE
|
||||
CompOptsModes, ProjectResources, LazConf, W32Manifest, ProjectIcon,
|
||||
LazarusIDEStrConsts, CompilerOptions,
|
||||
@ -3931,13 +3931,15 @@ function TProject.NewUniqueComponentName(const AComponentPrefix: string): string
|
||||
|
||||
function FormComponentExists(const AComponentName: string): boolean;
|
||||
var i: integer;
|
||||
ComponentClassName: string;
|
||||
begin
|
||||
Result:=true;
|
||||
if GetClass(AComponentName)<>nil then exit;
|
||||
ComponentClassName:=ClassNameToComponentName(AComponentName);
|
||||
for i:=0 to UnitCount-1 do begin
|
||||
if (Units[i].Component<>nil) then begin
|
||||
if CompareText(Units[i].Component.Name,AComponentName)=0 then exit;
|
||||
if CompareText(Units[i].Component.ClassName,'T'+AComponentName)=0
|
||||
if CompareText(Units[i].Component.ClassName,ComponentClassName)=0
|
||||
then exit;
|
||||
end else if (Units[i].ComponentName<>'')
|
||||
and ((Units[i].IsPartOfProject) or (Units[i].Loaded)) then begin
|
||||
|
@ -1527,6 +1527,7 @@ var
|
||||
function ClassTypeInfo(Value: TClass): PTypeInfo;
|
||||
function GetClassUnitName(Value: TClass): string;
|
||||
procedure CreateComponentEvent(AComponent: TComponent; const EventName: string);
|
||||
function ClassNameToComponentName(const AClassName: string): string;
|
||||
|
||||
procedure LazSetMethodProp(Instance : TObject;PropInfo : PPropInfo; Value : TMethod);
|
||||
procedure WritePublishedProperties(Instance: TPersistent);
|
||||
@ -3886,10 +3887,8 @@ begin
|
||||
if Root is TFrame then
|
||||
Result := 'Frame'
|
||||
else
|
||||
begin;
|
||||
Result := PropertyHook.GetRootClassName;
|
||||
if (Result <> '') and (Result[1] = 'T') then
|
||||
System.Delete(Result, 1, 1);
|
||||
begin
|
||||
Result := ClassNameToComponentName(PropertyHook.GetRootClassName);
|
||||
end;
|
||||
end else begin
|
||||
Result := PropertyHook.GetObjectName(GetComponent(0));
|
||||
@ -3937,9 +3936,7 @@ begin
|
||||
Result := 'Frame'
|
||||
else
|
||||
begin
|
||||
Result := RootClassName;
|
||||
if (Result <> '') and (Result[1] = 'T') then
|
||||
System.Delete(Result, 1, 1);
|
||||
Result := ClassNameToComponentName(RootClassName);
|
||||
end;
|
||||
end else begin
|
||||
Result := ComponentName;
|
||||
@ -6170,6 +6167,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function ClassNameToComponentName(const AClassName: string): string;
|
||||
begin
|
||||
Result:=AClassName;
|
||||
if (length(Result)>2) and (Result[1] in ['T','t'])
|
||||
and (not (Result[2] in ['0'..'9'])) then
|
||||
System.Delete(Result,1,1);
|
||||
end;
|
||||
|
||||
Function ClassTypeInfo(Value: TClass): PTypeInfo;
|
||||
begin
|
||||
Result := PTypeInfo(Value.ClassInfo);
|
||||
|
Loading…
Reference in New Issue
Block a user