mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Saving columns settings to XML.
This commit is contained in:
parent
d5fa1e3821
commit
d752252727
4 changed files with 88 additions and 52 deletions
|
|
@ -191,7 +191,8 @@ type
|
|||
|
||||
public
|
||||
{ public declarations }
|
||||
ColumnClass:TPanelColumnsClass;
|
||||
procedure SetColumnsClass(AColumnsClass: TPanelColumnsClass);
|
||||
|
||||
private
|
||||
{ Editing controls. }
|
||||
updWidth: TSpinEdit;
|
||||
|
|
@ -204,6 +205,7 @@ type
|
|||
|
||||
// Make a custom TColumnsFileViewPreview = class(TColumnsFileView).
|
||||
PreviewPan: TColumnsFileView;
|
||||
ColumnClass:TPanelColumnsClass;
|
||||
|
||||
IndexRaw: Integer;
|
||||
Showed: boolean;
|
||||
|
|
@ -742,12 +744,6 @@ begin
|
|||
|
||||
// Release ownership of ColumnClass (ColSet is now responsible for it).
|
||||
ColumnClassOwnership := False;
|
||||
|
||||
{$IFDEF DC_USE_XML_CONFIG}
|
||||
ColSet.Save(gConfig, gConfig.RootNode);
|
||||
{$ELSE}
|
||||
ColSet.Save(gIni);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TfColumnsSetConf.btnPrevClick(Sender: TObject);
|
||||
|
|
@ -1172,6 +1168,10 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TfColumnsSetConf.SetColumnsClass(AColumnsClass: TPanelColumnsClass);
|
||||
begin
|
||||
ColumnClass.Assign(AColumnsClass);
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I fcolumnssetconf.lrs}
|
||||
|
|
|
|||
|
|
@ -1951,8 +1951,7 @@ begin
|
|||
frmColumnsSetConf.edtNameofColumnsSet.Text:=lstColumnsSets.Items[lstColumnsSets.ItemIndex];
|
||||
frmColumnsSetConf.lbNrOfColumnsSet.Caption:=IntToStr(lstColumnsSets.ItemIndex+1);
|
||||
frmColumnsSetConf.Tag:=lstColumnsSets.ItemIndex;
|
||||
frmColumnsSetConf.ColumnClass.Clear;
|
||||
frmColumnsSetConf.ColumnClass.Load(gIni,lstColumnsSets.Items[lstColumnsSets.ItemIndex]);
|
||||
frmColumnsSetConf.SetColumnsClass(ColSet.GetColumnSet(lstColumnsSets.Items[lstColumnsSets.ItemIndex]));
|
||||
{EDIT Set}
|
||||
frmColumnsSetConf.ShowModal;
|
||||
FreeAndNil(frmColumnsSetConf);
|
||||
|
|
@ -2025,13 +2024,15 @@ begin
|
|||
end;
|
||||
|
||||
procedure TfrmOptions.btnCopyColumnsSetClick(Sender: TObject);
|
||||
var s:string;
|
||||
var
|
||||
s: string;
|
||||
begin
|
||||
if lstColumnsSets.ItemIndex=-1 then exit;
|
||||
s:=lstColumnsSets.Items[lstColumnsSets.ItemIndex];
|
||||
ColSet.CopyColumnSet(gIni,s,s+'_Copy');
|
||||
FillColumnsList;
|
||||
|
||||
if lstColumnsSets.ItemIndex <> -1 then
|
||||
begin
|
||||
s := lstColumnsSets.Items[lstColumnsSets.ItemIndex];
|
||||
ColSet.CopyColumnSet(s, s + '_Copy');
|
||||
FillColumnsList;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.btnCursorColorClick(Sender: TObject);
|
||||
|
|
@ -2070,7 +2071,7 @@ begin
|
|||
frmColumnsSetConf.edtNameofColumnsSet.Text:='New Columns'+inttostr(ColSet.count);
|
||||
frmColumnsSetConf.lbNrOfColumnsSet.Caption:=IntToStr(lstColumnsSets.Count+1);
|
||||
frmColumnsSetConf.Tag:=-1;
|
||||
frmColumnsSetConf.ColumnClass.Clear;
|
||||
frmColumnsSetConf.SetColumnsClass(nil);
|
||||
frmColumnsSetConf.ShowModal;
|
||||
FreeAndNil(frmColumnsSetConf);
|
||||
FillColumnsList;
|
||||
|
|
@ -2515,9 +2516,6 @@ begin
|
|||
frmMain.Repaint; // for panels repaint
|
||||
frmMain.SaveShortCuts;
|
||||
|
||||
{Columns Set}
|
||||
ColSet.Save(gIni);
|
||||
|
||||
{ Set plugins lists }
|
||||
gDSXPlugins.Assign(tmpDSXPlugins);
|
||||
gWCXPlugins.Assign(tmpWCXPlugins);
|
||||
|
|
|
|||
|
|
@ -2160,19 +2160,14 @@ var
|
|||
begin
|
||||
if ActiveColm <> '' then
|
||||
begin
|
||||
// If the columns set doesn't exist load the first one or the default one.
|
||||
if ColSet.Items.IndexOf(ActiveColm) = -1 then
|
||||
if ColSet.Items.Count > 0 then
|
||||
ActiveColm := ColSet.Items[0]
|
||||
else
|
||||
ActiveColm := 'Default';
|
||||
|
||||
Colset.GetColumnSet(ActiveColm).Load(gIni, ActiveColm);
|
||||
// If the ActiveColm set doesn't exist this will retrieve either
|
||||
// the first set or the default set.
|
||||
ColumnsClass := GetColumnsClass;
|
||||
// Set name in case a different set was loaded.
|
||||
ActiveColm := ColumnsClass.Name;
|
||||
|
||||
SetColumnsWidths;
|
||||
|
||||
ColumnsClass := GetColumnsClass;
|
||||
|
||||
dgPanel.FocusRectVisible := ColumnsClass.GetCursorBorder;
|
||||
dgPanel.FocusColor := ColumnsClass.GetCursorBorderColor;
|
||||
end;
|
||||
|
|
@ -2504,10 +2499,13 @@ begin
|
|||
Index:=ColSet.Items.IndexOf(ActiveColm);
|
||||
frmColumnsSetConf.lbNrOfColumnsSet.Caption:=IntToStr(1 + Index);
|
||||
frmColumnsSetConf.Tag:=Index;
|
||||
frmColumnsSetConf.ColumnClass.Clear;
|
||||
frmColumnsSetConf.ColumnClass.Load(gIni,ActiveColm);
|
||||
frmColumnsSetConf.SetColumnsClass(GetColumnsClass);
|
||||
{EDIT Set}
|
||||
frmColumnsSetConf.ShowModal;
|
||||
if frmColumnsSetConf.ShowModal = mrOK then
|
||||
begin
|
||||
// Force saving changes to config file.
|
||||
SaveGlobs;
|
||||
end;
|
||||
|
||||
FreeAndNil(frmColumnsSetConf);
|
||||
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ type
|
|||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure Assign(const OtherColumnsClass: TPanelColumnsClass);
|
||||
//---------------------
|
||||
function GetColumnTitle(const Index:Integer):string;
|
||||
function GetColumnFuncString(const Index:Integer):string;
|
||||
|
|
@ -240,7 +241,7 @@ type
|
|||
procedure Insert(AIndex: integer; AName: string; Item: TPanelColumnsClass);
|
||||
procedure DeleteColumnSet(SetName:string);
|
||||
procedure DeleteColumnSet(SetIndex:Integer); overload;
|
||||
procedure CopyColumnSet(ini:TIniFileEx; SetName,NewSetName:string);
|
||||
procedure CopyColumnSet(SetName, NewSetName: String);
|
||||
function GetColumnSet(const Index:Integer):TPanelColumnsClass;
|
||||
function GetColumnSet(Setname:string):TPanelColumnsClass;
|
||||
|
||||
|
|
@ -450,6 +451,44 @@ begin
|
|||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TPanelColumnsClass.Assign(const OtherColumnsClass: TPanelColumnsClass);
|
||||
var
|
||||
OldColumn, NewColumn: TPanelColumn;
|
||||
i: Integer;
|
||||
begin
|
||||
Clear;
|
||||
|
||||
if not Assigned(OtherColumnsClass) then
|
||||
Exit;
|
||||
|
||||
Name := OtherColumnsClass.Name;
|
||||
FCustomView := OtherColumnsClass.FCustomView;
|
||||
FCursorBorder := OtherColumnsClass.FCursorBorder;
|
||||
FCursorBorderColor := OtherColumnsClass.FCursorBorderColor;
|
||||
|
||||
for i := 0 to OtherColumnsClass.ColumnsCount - 1 do
|
||||
begin
|
||||
OldColumn := OtherColumnsClass.GetColumnItem(i);
|
||||
NewColumn := TPanelColumn.Create;
|
||||
Add(NewColumn);
|
||||
|
||||
NewColumn.Title := OldColumn.Title;
|
||||
NewColumn.FuncString := OldColumn.FuncString;
|
||||
FillListFromString(NewColumn.FuncList, NewColumn.FuncString);
|
||||
NewColumn.Width := OldColumn.Width;
|
||||
NewColumn.Align := OldColumn.Align;
|
||||
NewColumn.FontName := OldColumn.FontName;
|
||||
NewColumn.FontSize := OldColumn.FontSize;
|
||||
NewColumn.FontStyle := OldColumn.FontStyle;
|
||||
NewColumn.Overcolor := OldColumn.Overcolor;
|
||||
NewColumn.TextColor := OldColumn.TextColor;
|
||||
NewColumn.Background := OldColumn.Background;
|
||||
NewColumn.Background2 := OldColumn.Background2;
|
||||
NewColumn.MarkColor := OldColumn.MarkColor;
|
||||
NewColumn.CursorColor := OldColumn.CursorColor;
|
||||
NewColumn.CursorText := OldColumn.CursorText;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPanelColumnsClass.GetCount: Integer;
|
||||
begin
|
||||
|
|
@ -473,6 +512,7 @@ begin
|
|||
TPanelColumn(Flist[Result]).FontName:=gFontName;
|
||||
TPanelColumn(Flist[Result]).FontSize:=gFontSize;
|
||||
TPanelColumn(Flist[Result]).FontStyle:=gFontStyle;
|
||||
TPanelColumn(Flist[Result]).Overcolor:=True;
|
||||
TPanelColumn(Flist[Result]).TextColor:=gForeColor;
|
||||
TPanelColumn(Flist[Result]).Background:=gBackColor;
|
||||
TPanelColumn(Flist[Result]).Background2:=gBackColor2;
|
||||
|
|
@ -1174,28 +1214,28 @@ begin
|
|||
fSet.Delete(SetIndex);
|
||||
end;
|
||||
|
||||
procedure TPanelColumnsList.CopyColumnSet(ini: TIniFileEx; SetName,
|
||||
NewSetName: string);
|
||||
var x,i:integer; st:TStringList;
|
||||
procedure TPanelColumnsList.CopyColumnSet(SetName, NewSetName: String);
|
||||
var
|
||||
OldSetIndex, NewSetIndex: Integer;
|
||||
OldSet, NewSet: TPanelColumnsClass;
|
||||
begin
|
||||
x:=fSet.IndexOf(SetName);
|
||||
if x<>-1 then
|
||||
OldSetIndex := fSet.IndexOf(SetName);
|
||||
if OldSetIndex <> -1 then
|
||||
begin
|
||||
try
|
||||
st:=TStringList.Create;
|
||||
ini.ReadSectionValues(SetName,st);
|
||||
for i:=0 to st.Count-1 do
|
||||
begin
|
||||
ini.WriteString(NewSetName,st.Names[i],st.Values[st.Names[i]]);
|
||||
end;
|
||||
finally
|
||||
st.Free;
|
||||
end;
|
||||
fSet.AddObject(NewSetName,TPanelColumnsClass.Create);
|
||||
TPanelColumnsClass(fset.Objects[fset.Count-1]).Name:=NewSetName;
|
||||
TPanelColumnsClass(fset.Objects[fset.Count-1]).Load(ini,NewSetName);
|
||||
end;
|
||||
OldSet := TPanelColumnsClass(fSet.Objects[OldSetIndex]);
|
||||
NewSetIndex := fSet.IndexOf(NewSetName);
|
||||
if NewSetIndex <> -1 then
|
||||
NewSet := TPanelColumnsClass(fSet.Objects[NewSetIndex])
|
||||
else
|
||||
begin
|
||||
NewSet := TPanelColumnsClass.Create;
|
||||
fSet.AddObject(NewSetName, NewSet);
|
||||
end;
|
||||
|
||||
NewSet.Assign(OldSet);
|
||||
// Set new name.
|
||||
NewSet.Name := NewSetName;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPanelColumnsList.GetColumnSet(const Index: Integer): TPanelColumnsClass;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue