mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 19:39:17 +02:00
improved laz_xmlcfg.TXmlConfig to delete unused parent nodes
git-svn-id: trunk@9633 -
This commit is contained in:
parent
cfd72aa2fb
commit
1af44f9fb0
@ -425,6 +425,8 @@ type
|
|||||||
// Element
|
// Element
|
||||||
// -------------------------------------------------------
|
// -------------------------------------------------------
|
||||||
|
|
||||||
|
{ TDOMElement }
|
||||||
|
|
||||||
TDOMElement = class(TDOMNode_WithChildren)
|
TDOMElement = class(TDOMNode_WithChildren)
|
||||||
private
|
private
|
||||||
FAttributes: TDOMNamedNodeMap;
|
FAttributes: TDOMNamedNodeMap;
|
||||||
@ -443,6 +445,7 @@ type
|
|||||||
function RemoveAttributeNode(OldAttr: TDOMAttr): TDOMAttr;
|
function RemoveAttributeNode(OldAttr: TDOMAttr): TDOMAttr;
|
||||||
// Free NodeList with TDOMNodeList.Release!
|
// Free NodeList with TDOMNodeList.Release!
|
||||||
function GetElementsByTagName(const name: DOMString): TDOMNodeList;
|
function GetElementsByTagName(const name: DOMString): TDOMNodeList;
|
||||||
|
function IsEmpty: Boolean;
|
||||||
procedure Normalize;
|
procedure Normalize;
|
||||||
|
|
||||||
property AttribStrings[const Name: DOMString]: DOMString
|
property AttribStrings[const Name: DOMString]: DOMString
|
||||||
@ -1521,6 +1524,11 @@ begin
|
|||||||
Result := TDOMNodeList.Create(Self, name);
|
Result := TDOMNodeList.Create(Self, name);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDOMElement.IsEmpty: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=(FAttributes=nil) or (FAttributes.Count=0)
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDOMElement.Normalize;
|
procedure TDOMElement.Normalize;
|
||||||
begin
|
begin
|
||||||
// !!!: Not implemented
|
// !!!: Not implemented
|
||||||
|
@ -323,15 +323,26 @@ var
|
|||||||
Node: TDomNode;
|
Node: TDomNode;
|
||||||
StartPos: integer;
|
StartPos: integer;
|
||||||
NodeName: string;
|
NodeName: string;
|
||||||
|
ParentNode: TDOMNode;
|
||||||
begin
|
begin
|
||||||
Node:=FindNode(APath,true);
|
Node:=FindNode(APath,true);
|
||||||
if (Node=nil) then exit;
|
if (Node=nil) then exit;
|
||||||
StartPos:=length(APath);
|
StartPos:=length(APath);
|
||||||
while (StartPos>0) and (APath[StartPos]<>'/') do dec(StartPos);
|
while (StartPos>0) and (APath[StartPos]<>'/') do dec(StartPos);
|
||||||
NodeName:=copy(APath,StartPos+1,length(APath)-StartPos);
|
NodeName:=copy(APath,StartPos+1,length(APath)-StartPos);
|
||||||
if (not Assigned(TDOMElement(Node).GetAttributeNode(NodeName))) then exit;
|
if Assigned(TDOMElement(Node).GetAttributeNode(NodeName)) then begin
|
||||||
TDOMElement(Node).RemoveAttribute(NodeName);
|
TDOMElement(Node).RemoveAttribute(NodeName);
|
||||||
FModified := True;
|
FModified := True;
|
||||||
|
end;
|
||||||
|
while (Node.ChildNodes.Count=0) and (Node.ParentNode<>nil)
|
||||||
|
and (Node.ParentNode.ParentNode<>nil) do begin
|
||||||
|
if (Node is TDOMElement) and (not TDOMElement(Node).IsEmpty) then break;
|
||||||
|
ParentNode:=Node.ParentNode;
|
||||||
|
//writeln('TXMLConfig.DeleteValue APath="',APath,'" NodeName=',Node.NodeName,' ',Node.ClassName);
|
||||||
|
ParentNode.RemoveChild(Node);
|
||||||
|
Node:=ParentNode;
|
||||||
|
FModified := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TXMLConfig.Loaded;
|
procedure TXMLConfig.Loaded;
|
||||||
|
@ -197,7 +197,7 @@ type
|
|||||||
|
|
||||||
{ TEditorOptions }
|
{ TEditorOptions }
|
||||||
|
|
||||||
TEditorOptions = class(TPersistent)
|
TEditorOptions = class(TPersistent)
|
||||||
private
|
private
|
||||||
xmlconfig: TXMLConfig;
|
xmlconfig: TXMLConfig;
|
||||||
|
|
||||||
@ -1498,7 +1498,7 @@ begin
|
|||||||
// Key Mappings options
|
// Key Mappings options
|
||||||
XMLConfig.SetValue('EditorOptions/KeyMapping/Scheme', fKeyMappingScheme);
|
XMLConfig.SetValue('EditorOptions/KeyMapping/Scheme', fKeyMappingScheme);
|
||||||
fKeyMap.SaveToXMLConfig(
|
fKeyMap.SaveToXMLConfig(
|
||||||
XMLConfig, 'EditorOptions/KeyMapping/' + fKeyMappingScheme + '/');
|
XMLConfig, 'EditorOptions/KeyMapping/' + fKeyMappingScheme + '/');
|
||||||
|
|
||||||
// Color options
|
// Color options
|
||||||
for i := 0 to fHighlighterList.Count - 1 do
|
for i := 0 to fHighlighterList.Count - 1 do
|
||||||
|
@ -36,7 +36,7 @@ object ContextHelpEditorDlg: TContextHelpEditorDlg
|
|||||||
end
|
end
|
||||||
object CreateHelpNodeForControlButton: TButton
|
object CreateHelpNodeForControlButton: TButton
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
|
BorderSpacing.InnerBorder = 4
|
||||||
Caption = 'CreateHelpNodeForControlButton'
|
Caption = 'CreateHelpNodeForControlButton'
|
||||||
OnClick = CreateHelpNodeForControlButtonClick
|
OnClick = CreateHelpNodeForControlButtonClick
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
@ -46,7 +46,7 @@ object ContextHelpEditorDlg: TContextHelpEditorDlg
|
|||||||
end
|
end
|
||||||
object TestButton: TButton
|
object TestButton: TButton
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
|
BorderSpacing.InnerBorder = 4
|
||||||
Caption = 'TestButton'
|
Caption = 'TestButton'
|
||||||
OnClick = TestButtonClick
|
OnClick = TestButtonClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
@ -152,7 +152,6 @@ object ContextHelpEditorDlg: TContextHelpEditorDlg
|
|||||||
Align = alRight
|
Align = alRight
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
|
|
||||||
Caption = 'CancelBitBtn'
|
Caption = 'CancelBitBtn'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
NumGlyphs = 0
|
NumGlyphs = 0
|
||||||
@ -167,7 +166,6 @@ object ContextHelpEditorDlg: TContextHelpEditorDlg
|
|||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
BorderSpacing.Right = 15
|
BorderSpacing.Right = 15
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
|
|
||||||
Caption = 'OkBitBtn'
|
Caption = 'OkBitBtn'
|
||||||
Default = True
|
Default = True
|
||||||
ModalResult = 1
|
ModalResult = 1
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
{ This is an automatically generated lazarus resource file }
|
||||||
|
|
||||||
LazarusResources.Add('TContextHelpEditorDlg','FORMDATA',[
|
LazarusResources.Add('TContextHelpEditorDlg','FORMDATA',[
|
||||||
'TPF0'#21'TContextHelpEditorDlg'#20'ContextHelpEditorDlg'#7'Caption'#6#20'Con'
|
'TPF0'#21'TContextHelpEditorDlg'#20'ContextHelpEditorDlg'#7'Caption'#6#20'Con'
|
||||||
+'textHelpEditorDlg'#28'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopB'
|
+'textHelpEditorDlg'#28'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopB'
|
||||||
@ -12,41 +14,42 @@ LazarusResources.Add('TContextHelpEditorDlg','FORMDATA',[
|
|||||||
+#2#6#6'Height'#3#189#1#3'Top'#2#6#5'Width'#3'1'#1#0#9'TTreeView'#16'Controls'
|
+#2#6#6'Height'#3#189#1#3'Top'#2#6#5'Width'#3'1'#1#0#9'TTreeView'#16'Controls'
|
||||||
+'TreeView'#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#14#8'TabOrder'#2#0
|
+'TreeView'#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#14#8'TabOrder'#2#0
|
||||||
+#6'Height'#3'f'#1#5'Width'#3'-'#1#0#0#7'TButton'#30'CreateHelpNodeForControl'
|
+#6'Height'#3'f'#1#5'Width'#3'-'#1#0#0#7'TButton'#30'CreateHelpNodeForControl'
|
||||||
+'Button'#5'Align'#7#8'alBottom'#7'Caption'#6#30'CreateHelpNodeForControlButt'
|
+'Button'#5'Align'#7#8'alBottom'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'
|
||||||
+'on'#7'OnClick'#7'#CreateHelpNodeForControlButtonClick'#8'TabOrder'#2#1#6'He'
|
+#6#30'CreateHelpNodeForControlButton'#7'OnClick'#7'#CreateHelpNodeForControl'
|
||||||
+'ight'#2'#'#3'Top'#3'f'#1#5'Width'#3'-'#1#0#0#7'TButton'#10'TestButton'#5'Al'
|
+'ButtonClick'#8'TabOrder'#2#1#6'Height'#2'#'#3'Top'#3'f'#1#5'Width'#3'-'#1#0
|
||||||
+'ign'#7#8'alBottom'#7'Caption'#6#10'TestButton'#7'OnClick'#7#15'TestButtonCl'
|
+#0#7'TButton'#10'TestButton'#5'Align'#7#8'alBottom'#25'BorderSpacing.InnerBo'
|
||||||
+'ick'#8'TabOrder'#2#2#6'Height'#2'#'#3'Top'#3#137#1#5'Width'#3'-'#1#0#0#0#9
|
+'rder'#2#4#7'Caption'#6#10'TestButton'#7'OnClick'#7#15'TestButtonClick'#8'Ta'
|
||||||
+'TGroupBox'#13'NodesGroupBox'#5'Align'#7#8'alClient'#7'Caption'#6#13'NodesGr'
|
+'bOrder'#2#2#6'Height'#2'#'#3'Top'#3#137#1#5'Width'#3'-'#1#0#0#0#9'TGroupBox'
|
||||||
+'oupBox'#12'ClientHeight'#3#172#1#11'ClientWidth'#3#25#1#8'TabOrder'#2#1#4'L'
|
+#13'NodesGroupBox'#5'Align'#7#8'alClient'#7'Caption'#6#13'NodesGroupBox'#12
|
||||||
+'eft'#3'H'#1#6'Height'#3#189#1#3'Top'#2#6#5'Width'#3#29#1#0#9'TTreeView'#17
|
+'ClientHeight'#3#172#1#11'ClientWidth'#3#25#1#8'TabOrder'#2#1#4'Left'#3'H'#1
|
||||||
+'HelpNodesTreeView'#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#14#8'TabO'
|
+#6'Height'#3#189#1#3'Top'#2#6#5'Width'#3#29#1#0#9'TTreeView'#17'HelpNodesTre'
|
||||||
+'rder'#2#0#18'OnSelectionChanged'#7'!HelpNodesTreeViewSelectionChanged'#6'He'
|
+'eView'#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#14#8'TabOrder'#2#0#18
|
||||||
+'ight'#3';'#1#5'Width'#3#25#1#0#0#9'TGroupBox'#26'HelpNodePropertiesGroupBox'
|
+'OnSelectionChanged'#7'!HelpNodesTreeViewSelectionChanged'#6'Height'#3';'#1#5
|
||||||
+#5'Align'#7#8'alBottom'#7'Caption'#6#26'HelpNodePropertiesGroupBox'#12'Clien'
|
+'Width'#3#25#1#0#0#9'TGroupBox'#26'HelpNodePropertiesGroupBox'#5'Align'#7#8
|
||||||
+'tHeight'#2'`'#11'ClientWidth'#3#21#1#8'TabOrder'#2#1#6'Height'#2'q'#3'Top'#3
|
+'alBottom'#7'Caption'#6#26'HelpNodePropertiesGroupBox'#12'ClientHeight'#2'`'
|
||||||
+';'#1#5'Width'#3#25#1#0#6'TLabel'#13'NodeNameLabel'#7'Caption'#6#5'Name:'#5
|
+#11'ClientWidth'#3#21#1#8'TabOrder'#2#1#6'Height'#2'q'#3'Top'#3';'#1#5'Width'
|
||||||
+'Color'#7#6'clNone'#11'ParentColor'#8#4'Left'#2#10#6'Height'#2#13#3'Top'#2#10
|
+#3#25#1#0#6'TLabel'#13'NodeNameLabel'#7'Caption'#6#5'Name:'#5'Color'#7#6'clN'
|
||||||
+#5'Width'#2'$'#0#0#6'TLabel'#13'NodePathLabel'#7'Caption'#6#5'Path:'#5'Color'
|
+'one'#11'ParentColor'#8#4'Left'#2#10#6'Height'#2#13#3'Top'#2#10#5'Width'#2'$'
|
||||||
+#7#6'clNone'#11'ParentColor'#8#4'Left'#2#10#6'Height'#2#13#3'Top'#2'('#5'Wid'
|
+#0#0#6'TLabel'#13'NodePathLabel'#7'Caption'#6#5'Path:'#5'Color'#7#6'clNone'
|
||||||
+'th'#2#29#0#0#9'TCheckBox'#19'NodeHasHelpCheckBox'#7'Caption'#6#19'NodeHasHe'
|
+#11'ParentColor'#8#4'Left'#2#10#6'Height'#2#13#3'Top'#2'('#5'Width'#2#29#0#0
|
||||||
+'lpCheckBox'#13'OnEditingDone'#7#30'NodeHasHelpCheckBoxEditingDone'#8'TabOrd'
|
+#9'TCheckBox'#19'NodeHasHelpCheckBox'#7'Caption'#6#19'NodeHasHelpCheckBox'#13
|
||||||
+'er'#2#0#4'Left'#2#6#6'Height'#2#24#3'Top'#2'A'#5'Width'#3#162#0#0#0#5'TEdit'
|
+'OnEditingDone'#7#30'NodeHasHelpCheckBoxEditingDone'#8'TabOrder'#2#0#4'Left'
|
||||||
+#12'NodeNameEdit'#13'OnEditingDone'#7#23'NodeNameEditEditingDone'#8'TabOrder'
|
+#2#6#6'Height'#2#24#3'Top'#2'A'#5'Width'#3#162#0#0#0#5'TEdit'#12'NodeNameEdi'
|
||||||
+#2#1#4'Text'#6#12'NodeNameEdit'#4'Left'#2'F'#6'Height'#2#23#3'Top'#2#5#5'Wid'
|
+'t'#13'OnEditingDone'#7#23'NodeNameEditEditingDone'#8'TabOrder'#2#1#4'Text'#6
|
||||||
+'th'#3#204#0#0#0#5'TEdit'#12'NodePathEdit'#13'OnEditingDone'#7#23'NodePathEd'
|
+#12'NodeNameEdit'#4'Left'#2'F'#6'Height'#2#23#3'Top'#2#5#5'Width'#3#204#0#0#0
|
||||||
+'itEditingDone'#8'TabOrder'#2#2#4'Text'#6#12'NodePathEdit'#4'Left'#2'F'#6'He'
|
+#5'TEdit'#12'NodePathEdit'#13'OnEditingDone'#7#23'NodePathEditEditingDone'#8
|
||||||
+'ight'#2#23#3'Top'#2'#'#5'Width'#3#204#0#0#0#0#0#9'TSplitter'#9'Splitter1'#6
|
+'TabOrder'#2#2#4'Text'#6#12'NodePathEdit'#4'Left'#2'F'#6'Height'#2#23#3'Top'
|
||||||
+'Height'#3#189#1#5'Width'#2#5#6'Cursor'#7#8'crHSplit'#4'Left'#3'='#1#6'Heigh'
|
+#2'#'#5'Width'#3#204#0#0#0#0#0#9'TSplitter'#9'Splitter1'#6'Height'#3#189#1#5
|
||||||
+'t'#3#189#1#3'Top'#2#6#5'Width'#2#5#0#0#6'TPanel'#6'Panel1'#5'Align'#7#8'alB'
|
+'Width'#2#5#6'Cursor'#7#8'crHSplit'#4'Left'#3'='#1#6'Height'#3#189#1#3'Top'#2
|
||||||
+'ottom'#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2'('#11'ClientWidth'#3'_'
|
+#6#5'Width'#2#5#0#0#6'TPanel'#6'Panel1'#5'Align'#7#8'alBottom'#10'BevelOuter'
|
||||||
+#2#8'TabOrder'#2#2#4'Left'#2#6#6'Height'#2'('#3'Top'#3#201#1#5'Width'#3'_'#2
|
+#7#6'bvNone'#12'ClientHeight'#2'('#11'ClientWidth'#3'_'#2#8'TabOrder'#2#2#4
|
||||||
+#0#7'TBitBtn'#12'CancelBitBtn'#5'Align'#7#7'alRight'#7'Anchors'#11#5'akTop'#7
|
+'Left'#2#6#6'Height'#2'('#3'Top'#3#201#1#5'Width'#3'_'#2#0#7'TBitBtn'#12'Can'
|
||||||
+'akRight'#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#12'CancelBitBtn'#11'Mo'
|
+'celBitBtn'#5'Align'#7#7'alRight'#7'Anchors'#11#5'akTop'#7'akRight'#0#20'Bor'
|
||||||
+'dalResult'#2#2#9'NumGlyphs'#2#0#8'TabOrder'#2#0#4'Left'#3#240#1#6'Height'#2
|
+'derSpacing.Around'#2#6#7'Caption'#6#12'CancelBitBtn'#11'ModalResult'#2#2#9
|
||||||
+#28#3'Top'#2#6#5'Width'#2'i'#0#0#7'TBitBtn'#8'OkBitBtn'#5'Align'#7#7'alRight'
|
+'NumGlyphs'#2#0#8'TabOrder'#2#0#4'Left'#3#240#1#6'Height'#2#28#3'Top'#2#6#5
|
||||||
+#7'Anchors'#11#5'akTop'#7'akRight'#0#19'BorderSpacing.Right'#2#15#20'BorderS'
|
+'Width'#2'i'#0#0#7'TBitBtn'#8'OkBitBtn'#5'Align'#7#7'alRight'#7'Anchors'#11#5
|
||||||
+'pacing.Around'#2#6#7'Caption'#6#8'OkBitBtn'#7'Default'#9#11'ModalResult'#2#1
|
+'akTop'#7'akRight'#0#19'BorderSpacing.Right'#2#15#20'BorderSpacing.Around'#2
|
||||||
+#9'NumGlyphs'#2#0#7'OnClick'#7#13'OkBitBtnClick'#8'TabOrder'#2#1#4'Left'#3'r'
|
+#6#7'Caption'#6#8'OkBitBtn'#7'Default'#9#11'ModalResult'#2#1#9'NumGlyphs'#2#0
|
||||||
+#1#6'Height'#2#28#3'Top'#2#6#5'Width'#2'i'#0#0#0#0
|
+#7'OnClick'#7#13'OkBitBtnClick'#8'TabOrder'#2#1#4'Left'#3'r'#1#6'Height'#2#28
|
||||||
|
+#3'Top'#2#6#5'Width'#2'i'#0#0#0#0
|
||||||
]);
|
]);
|
||||||
|
@ -2545,7 +2545,7 @@ begin
|
|||||||
GetDefaultKeyForCommand(Command,TheKeyA,TheKeyB);
|
GetDefaultKeyForCommand(Command,TheKeyA,TheKeyB);
|
||||||
DefaultKeyStr:=KeyValuesToStr(TheKeyA, TheKeyB);
|
DefaultKeyStr:=KeyValuesToStr(TheKeyA, TheKeyB);
|
||||||
end;
|
end;
|
||||||
//writeln('TKeyCommandRelationList.SaveToXMLConfig A ',Prefix+Name,' ',CurKeyStr=DefaultKeyStr);
|
//debugln(['TKeyCommandRelationList.SaveToXMLConfig A ',Prefix+Name,' ',CurKeyStr=DefaultKeyStr]);
|
||||||
XMLConfig.SetDeleteValue(Prefix+Name+'/Value',CurKeyStr,DefaultKeyStr);
|
XMLConfig.SetDeleteValue(Prefix+Name+'/Value',CurKeyStr,DefaultKeyStr);
|
||||||
end;
|
end;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
|
@ -615,7 +615,7 @@ begin
|
|||||||
raise Exception.Create('item does not belong to this listview');
|
raise Exception.Create('item does not belong to this listview');
|
||||||
if FSelected = AValue then Exit;
|
if FSelected = AValue then Exit;
|
||||||
FSelected := AValue;
|
FSelected := AValue;
|
||||||
DebugLn('TCustomListView.SetSelection FSelected=',dbgs(FSelected));
|
//DebugLn('TCustomListView.SetSelection FSelected=',dbgs(FSelected));
|
||||||
if not HandleAllocated then Exit;
|
if not HandleAllocated then Exit;
|
||||||
TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self, FSelected.Index,
|
TWSCustomListViewClass(WidgetSetClass).ItemSetState(Self, FSelected.Index,
|
||||||
FSelected, lisSelected, True);
|
FSelected, lisSelected, True);
|
||||||
|
Loading…
Reference in New Issue
Block a user