mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Move function that doesn't add node when value is default to XmlConfig.
This commit is contained in:
parent
b210d7805a
commit
a32d3d70c4
4 changed files with 44 additions and 25 deletions
|
|
@ -206,12 +206,6 @@ type
|
|||
ToolItemExecute: TOnToolItemExecute;
|
||||
end;
|
||||
|
||||
procedure SaveIfNotEmpty(Config: TXmlConfig; Node: TXmlNode; Name, Value: String);
|
||||
begin
|
||||
if Value <> EmptyStr then
|
||||
Config.AddValue(Node, Name, Value);
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('KASComponents',[TKASToolBar]);
|
||||
|
|
|
|||
|
|
@ -169,12 +169,6 @@ implementation
|
|||
uses
|
||||
DCStrUtils;
|
||||
|
||||
procedure SaveIfNotEmpty(Config: TXmlConfig; Node: TXmlNode; Name, Value: String);
|
||||
begin
|
||||
if Value <> EmptyStr then
|
||||
Config.AddValue(Node, Name, Value);
|
||||
end;
|
||||
|
||||
{ TKASToolItem }
|
||||
|
||||
procedure TKASToolItem.Assign(OtherItem: TKASToolItem);
|
||||
|
|
@ -470,9 +464,9 @@ end;
|
|||
procedure TKASNormalItem.SaveContents(Config: TXmlConfig; Node: TXmlNode);
|
||||
begin
|
||||
Config.AddValue(Node, 'ID', ID);
|
||||
SaveIfNotEmpty(Config, Node, 'Text', Text);
|
||||
SaveIfNotEmpty(Config, Node, 'Icon', Icon);
|
||||
SaveIfNotEmpty(Config, Node, 'Hint', Hint);
|
||||
Config.AddValueDef(Node, 'Text', Text, '');
|
||||
Config.AddValueDef(Node, 'Icon', Icon, '');
|
||||
Config.AddValueDef(Node, 'Hint', Hint, '');
|
||||
end;
|
||||
|
||||
{ TKASToolBarItems }
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ type
|
|||
TXmlNode = TDOMNode;
|
||||
TXmlPath = DOMString;
|
||||
|
||||
{ TXmlConfig }
|
||||
|
||||
TXmlConfig = class
|
||||
private
|
||||
FFileName: UTF8String;
|
||||
|
|
@ -92,6 +94,11 @@ type
|
|||
procedure AddValue(const RootNode: TDOMNode; const ValueName: DOMString; const AValue: Integer);
|
||||
procedure AddValue(const RootNode: TDOMNode; const ValueName: DOMString; const AValue: Int64);
|
||||
procedure AddValue(const RootNode: TDOMNode; const ValueName: DOMString; const AValue: Double);
|
||||
procedure AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: String);
|
||||
procedure AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: Boolean);
|
||||
procedure AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: Integer);
|
||||
procedure AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: Int64);
|
||||
procedure AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: Double);
|
||||
|
||||
// SetValue functions can only set values for unique paths.
|
||||
procedure SetAttr(const RootNode: TDOMNode; const Path: DOMString; const AValue: UTF8String);
|
||||
|
|
@ -370,6 +377,36 @@ begin
|
|||
Node.TextContent := UTF8ToUTF16(AValue);
|
||||
end;
|
||||
|
||||
procedure TXmlConfig.AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: Boolean);
|
||||
begin
|
||||
if AValue <> DefaultValue then
|
||||
AddValue(RootNode, ValueName, AValue);
|
||||
end;
|
||||
|
||||
procedure TXmlConfig.AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: Double);
|
||||
begin
|
||||
if AValue <> DefaultValue then
|
||||
AddValue(RootNode, ValueName, AValue);
|
||||
end;
|
||||
|
||||
procedure TXmlConfig.AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: Int64);
|
||||
begin
|
||||
if AValue <> DefaultValue then
|
||||
AddValue(RootNode, ValueName, AValue);
|
||||
end;
|
||||
|
||||
procedure TXmlConfig.AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: Integer);
|
||||
begin
|
||||
if AValue <> DefaultValue then
|
||||
AddValue(RootNode, ValueName, AValue);
|
||||
end;
|
||||
|
||||
procedure TXmlConfig.AddValueDef(const RootNode: TDOMNode; const ValueName: DOMString; const AValue, DefaultValue: String);
|
||||
begin
|
||||
if AValue <> DefaultValue then
|
||||
AddValue(RootNode, ValueName, AValue);
|
||||
end;
|
||||
|
||||
procedure TXmlConfig.AddValue(const RootNode: TDOMNode; const ValueName: DOMString; const AValue: Boolean);
|
||||
begin
|
||||
AddValue(RootNode, ValueName, BoolStrings[AValue]);
|
||||
|
|
|
|||
|
|
@ -95,12 +95,6 @@ const
|
|||
ProgramItemConfigNode = 'Program';
|
||||
DriveItemConfigNode = 'Drive';
|
||||
|
||||
procedure SaveIfNotEmpty(Config: TXmlConfig; Node: TXmlNode; Name, Value: String);
|
||||
begin
|
||||
if Value <> EmptyStr then
|
||||
Config.AddValue(Node, Name, Value);
|
||||
end;
|
||||
|
||||
{ TKASDriveItem }
|
||||
|
||||
procedure TKASDriveItem.Assign(OtherItem: TKASToolItem);
|
||||
|
|
@ -174,7 +168,7 @@ begin
|
|||
inherited SaveContents(Config, Node);
|
||||
Config.AddValue(Node, 'Command', Command);
|
||||
for AParam in Params do
|
||||
SaveIfNotEmpty(Config, Node, 'Param', AParam);
|
||||
Config.AddValueDef(Node, 'Param', AParam, '');
|
||||
end;
|
||||
|
||||
{ TKASProgramItem }
|
||||
|
|
@ -223,9 +217,9 @@ end;
|
|||
procedure TKASProgramItem.SaveContents(Config: TXmlConfig; Node: TXmlNode);
|
||||
begin
|
||||
inherited SaveContents(Config, Node);
|
||||
SaveIfNotEmpty(Config, Node, 'Command', Command);
|
||||
SaveIfNotEmpty(Config, Node, 'Params', Params);
|
||||
SaveIfNotEmpty(Config, Node, 'StartPath', StartPath);
|
||||
Config.AddValueDef(Node, 'Command', Command, '');
|
||||
Config.AddValueDef(Node, 'Params', Params, '');
|
||||
Config.AddValueDef(Node, 'StartPath', StartPath, '');
|
||||
end;
|
||||
|
||||
{ TKASToolBarExtendedLoader }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue