mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-23 07:06:12 +02:00
Merge branch 'Cody/Dictionary/Refac' into 'main'
Cody/Dictionary: Refactoring See merge request freepascal.org/lazarus/lazarus!497
This commit is contained in:
commit
f99b581e24
@ -796,8 +796,8 @@ end;
|
||||
constructor TCodyUnitDictionary.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
FSaveIntervalInS:=60*3; // every 3 minutes
|
||||
FLoadAfterStartInS:=3;
|
||||
FSaveIntervalInS:=cDefSaveIntervalInS;
|
||||
FLoadAfterStartInS:=cDefLoadDelayInS;
|
||||
InitCriticalSection(fCritSec);
|
||||
fQueuedTools:=TAVLTree.Create;
|
||||
CodeToolBoss.AddHandlerToolTreeChanging(@ToolTreeChanged);
|
||||
@ -879,49 +879,49 @@ end;
|
||||
|
||||
procedure TCodyIdentifiersDlg.DeletePackageClick(Sender: TObject);
|
||||
var
|
||||
Identifier: string;
|
||||
UnitFilename: string;
|
||||
GroupName: string;
|
||||
GroupFilename: string;
|
||||
Group: TUDUnitGroup;
|
||||
s: String;
|
||||
lId: TCodyIdentifier;
|
||||
lMsg: string;
|
||||
lGroup: TUDUnitGroup;
|
||||
begin
|
||||
if not FindSelectedItem(Identifier, UnitFilename, GroupName, GroupFilename)
|
||||
then exit;
|
||||
if GroupFilename='' then exit;
|
||||
s:=Format(crsReallyDeleteThePackageFromTheDatabaseNoteThisDoe, [#13, #13,
|
||||
#13, GroupFilename]);
|
||||
if IDEMessageDialog(crsDeletePackage, s, mtConfirmation, [mbYes, mbNo], '')<>
|
||||
mrYes
|
||||
then exit;
|
||||
Group:=CodyUnitDictionary.FindGroupWithFilename(GroupFilename);
|
||||
if Group=nil then exit;
|
||||
CodyUnitDictionary.DeleteGroup(Group,true);
|
||||
lId := FindSelectedIdentifier;
|
||||
if lId = nil then exit;
|
||||
if lId.GroupFile = '' then exit;
|
||||
|
||||
// confirm
|
||||
lMsg := Format(crsReallyDeleteThePackageFromTheDatabaseNoteThisDoe,
|
||||
[LineEnding, LineEnding, LineEnding, lId.GroupFile]);
|
||||
if IDEMessageDialog(crsDeletePackage, lMsg, mtConfirmation, mbYesNo) <> mrYes then exit;
|
||||
|
||||
// delete
|
||||
lGroup := CodyUnitDictionary.FindGroupWithFilename(lId.GroupFile);
|
||||
if lGroup = nil then exit;
|
||||
CodyUnitDictionary.DeleteGroup(lGroup, true);
|
||||
|
||||
UpdateGeneralInfo;
|
||||
UpdateItemsList;
|
||||
end;
|
||||
|
||||
procedure TCodyIdentifiersDlg.DeleteUnitClick(Sender: TObject);
|
||||
var
|
||||
Identifier: string;
|
||||
UnitFilename: string;
|
||||
GroupName: string;
|
||||
GroupFilename: string;
|
||||
CurUnit: TUDUnit;
|
||||
s: String;
|
||||
lId: TCodyIdentifier;
|
||||
lMsg: string;
|
||||
lUnit: TUDUnit;
|
||||
begin
|
||||
if not FindSelectedItem(Identifier, UnitFilename, GroupName, GroupFilename)
|
||||
then exit;
|
||||
s:=Format(crsReallyDeleteTheUnitFromTheDatabaseNoteThisDoesNo, [#13, #13,
|
||||
#13, UnitFilename]);
|
||||
if GroupFilename<>'' then
|
||||
s+=#13+Format(crsIn, [GroupFilename]);
|
||||
if IDEMessageDialog(crsDeleteUnit, s, mtConfirmation, [mbYes, mbNo], '')<>
|
||||
mrYes
|
||||
then exit;
|
||||
CurUnit:=CodyUnitDictionary.FindUnitWithFilename(UnitFilename);
|
||||
if CurUnit=nil then exit;
|
||||
CodyUnitDictionary.DeleteUnit(CurUnit,true);
|
||||
lId := FindSelectedIdentifier;
|
||||
if lId = nil then exit;
|
||||
|
||||
// confirm
|
||||
lMsg := Format(crsReallyDeleteTheUnitFromTheDatabaseNoteThisDoesNo,
|
||||
[LineEnding, LineEnding, LineEnding, lId.UnitFile]);
|
||||
if lId.GroupFile <> '' then
|
||||
lMsg := lMsg + LineEnding + Format(crsIn, [lId.GroupFile]);
|
||||
if IDEMessageDialog(crsDeleteUnit, lMsg, mtConfirmation, mbYesNo) <> mrYes then exit;
|
||||
|
||||
// delete
|
||||
lUnit := CodyUnitDictionary.FindUnitWithFilename(lId.UnitFile);
|
||||
if lUnit = nil then exit;
|
||||
CodyUnitDictionary.DeleteUnit(lUnit, true);
|
||||
|
||||
UpdateGeneralInfo;
|
||||
UpdateItemsList;
|
||||
end;
|
||||
@ -983,7 +983,7 @@ begin
|
||||
ButtonPanel1.HelpButton.OnClick:=@ButtonPanel1HelpButtonClick;
|
||||
ButtonPanel1.OKButton.Caption:=crsUseIdentifier;
|
||||
ButtonPanel1.OKButton.OnClick:=@UseIdentifierClick;
|
||||
FMaxItems:=40;
|
||||
FMaxItems:=cDefMaxListItems;
|
||||
FilterEdit.TextHint:=crsFilter;
|
||||
FItems:=TObjectList.Create;
|
||||
HideOtherProjectsCheckBox.Checked:=true;
|
||||
@ -1352,14 +1352,11 @@ begin
|
||||
end;
|
||||
|
||||
function TCodyIdentifiersDlg.FindSelectedIdentifier: TCodyIdentifier;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=nil;
|
||||
if FItems=nil then exit;
|
||||
i:=ItemsListBox.ItemIndex;
|
||||
if (i<0) or (i>=FItems.Count) then exit;
|
||||
Result:=TCodyIdentifier(FItems[i]);
|
||||
if assigned(FItems) and InRange(ItemsListBox.ItemIndex, 0, FItems.Count - 1) then
|
||||
result := TCodyIdentifier(FItems[ItemsListBox.ItemIndex])
|
||||
else
|
||||
result := nil;
|
||||
end;
|
||||
|
||||
function TCodyIdentifiersDlg.FindSelectedItem(out Identifier, UnitFilename,
|
||||
@ -1367,19 +1364,21 @@ function TCodyIdentifiersDlg.FindSelectedItem(out Identifier, UnitFilename,
|
||||
var
|
||||
Item: TCodyIdentifier;
|
||||
begin
|
||||
Result:=false;
|
||||
Identifier:='';
|
||||
UnitFilename:='';
|
||||
GroupName:='';
|
||||
GroupFilename:='';
|
||||
Item:=FindSelectedIdentifier;
|
||||
if Item=nil then exit;
|
||||
Identifier:=Item.Identifier;
|
||||
UnitFilename:=Item.UnitFile;
|
||||
GroupName:=Item.GroupName;
|
||||
GroupFilename:=Item.GroupFile;
|
||||
Item := FindSelectedIdentifier;
|
||||
result := assigned(Item);
|
||||
if result then
|
||||
begin
|
||||
Identifier := Item.Identifier;
|
||||
UnitFilename := Item.UnitFile;
|
||||
GroupName := Item.GroupName;
|
||||
GroupFilename := Item.GroupFile;
|
||||
end else begin
|
||||
Identifier := '';
|
||||
UnitFilename := '';
|
||||
GroupName := '';
|
||||
GroupFilename := '';
|
||||
end;
|
||||
//debugln(['TCodyIdentifiersDlg.FindSelectedItem ',Identifier,' Unit=',UnitFilename,' Pkg=',GroupFilename]);
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TCodyIdentifiersDlg.Init: boolean;
|
||||
|
@ -15,12 +15,16 @@ uses
|
||||
|
||||
const
|
||||
CodyConfigVersion = 1;
|
||||
|
||||
const
|
||||
cDefLoadDelayInS = 10;
|
||||
cDefSaveIntervalInS = 600;
|
||||
cDefMaxListItems = 50;
|
||||
|
||||
var
|
||||
CodyMiscOptionID: integer = 1000;
|
||||
|
||||
type
|
||||
|
||||
{ TCodyMiscOptions }
|
||||
|
||||
TCodyMiscOptions = class(TPersistent)
|
||||
private
|
||||
FChangeStep: integer;
|
||||
@ -61,8 +65,6 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
{ TCodyMiscOptions }
|
||||
|
||||
procedure TCodyMiscOptions.SetModified(AValue: boolean);
|
||||
begin
|
||||
if AValue then
|
||||
@ -104,29 +106,21 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCodyMiscOptions.Assign(Source: TPersistent);
|
||||
var
|
||||
aSource: TCodyMiscOptions;
|
||||
begin
|
||||
if Source is TCodyMiscOptions then
|
||||
begin
|
||||
aSource:=TCodyMiscOptions(Source);
|
||||
UDSaveIntervalInS:=aSource.UDSaveIntervalInS;
|
||||
UDLoadDelayInS:=aSource.UDLoadDelayInS;
|
||||
UDSaveIntervalInS := TCodyMiscOptions(Source).UDSaveIntervalInS;
|
||||
UDLoadDelayInS := TCodyMiscOptions(Source).UDLoadDelayInS;
|
||||
end else
|
||||
inherited Assign(Source);
|
||||
end;
|
||||
|
||||
function TCodyMiscOptions.Equals(Obj: TObject): boolean;
|
||||
var
|
||||
Src: TCodyMiscOptions;
|
||||
begin
|
||||
Result:=false;
|
||||
if not (Obj is TCodyMiscOptions) then exit;
|
||||
Src:=TCodyMiscOptions(Obj);
|
||||
if (UDLoadDelayInS<>Src.UDLoadDelayInS)
|
||||
or (UDSaveIntervalInS<>Src.UDSaveIntervalInS)
|
||||
then exit;
|
||||
Result:=true;
|
||||
Result :=
|
||||
(Obj is TCodyMiscOptions) and // "is" also checks for nil
|
||||
(UDLoadDelayInS = TCodyMiscOptions(Obj).UDLoadDelayInS ) and
|
||||
(UDSaveIntervalInS = TCodyMiscOptions(Obj).UDSaveIntervalInS);
|
||||
end;
|
||||
|
||||
procedure TCodyMiscOptions.SaveSafe;
|
||||
@ -157,8 +151,8 @@ var
|
||||
begin
|
||||
Cfg:=GetIDEConfigStorage(Filename,false);
|
||||
try
|
||||
Cfg.SetDeleteValue('UnitDictionary/LoadDelay',UDLoadDelayInS,10);
|
||||
Cfg.SetDeleteValue('UnitDictionary/SaveInterval',UDSaveIntervalInS,600);
|
||||
Cfg.SetDeleteValue('UnitDictionary/LoadDelay', UDLoadDelayInS, cDefLoadDelayInS);
|
||||
Cfg.SetDeleteValue('UnitDictionary/SaveInterval',UDSaveIntervalInS,cDefSaveIntervalInS);
|
||||
Cfg.SetDeleteValue('Uses/PreferImplementationSection',PreferImplementationUsesSection,false);
|
||||
finally
|
||||
Cfg.Free;
|
||||
@ -172,8 +166,8 @@ begin
|
||||
Clear;
|
||||
Cfg:=GetIDEConfigStorage(Filename,true);
|
||||
try
|
||||
UDLoadDelayInS:=Cfg.GetValue('UnitDictionary/LoadDelay',10);
|
||||
UDSaveIntervalInS:=Cfg.GetValue('UnitDictionary/SaveInterval',600);
|
||||
UDLoadDelayInS :=Cfg.GetValue('UnitDictionary/LoadDelay', cDefLoadDelayInS);
|
||||
UDSaveIntervalInS:=Cfg.GetValue('UnitDictionary/SaveInterval',cDefSaveIntervalInS);
|
||||
PreferImplementationUsesSection:=Cfg.GetValue('Uses/PreferImplementationSection',false);
|
||||
//debugln(['TCodyMiscOptions.LoadFromFile UDSaveIntervalInS=',UDSaveIntervalInS,' LoadDelay=',UDLoadDelayInS]);
|
||||
finally
|
||||
@ -183,8 +177,8 @@ end;
|
||||
|
||||
procedure TCodyMiscOptions.Clear;
|
||||
begin
|
||||
UDLoadDelayInS:=10;
|
||||
UDSaveIntervalInS:=600;
|
||||
UDLoadDelayInS := cDefLoadDelayInS;
|
||||
UDSaveIntervalInS := cDefSaveIntervalInS;
|
||||
end;
|
||||
|
||||
procedure TCodyMiscOptions.Apply;
|
||||
|
Loading…
Reference in New Issue
Block a user