mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Saving opened tabs to XML.
This commit is contained in:
parent
db3fe6116a
commit
4b231dfd14
3 changed files with 349 additions and 103 deletions
219
src/fmain.pas
219
src/fmain.pas
|
|
@ -46,7 +46,7 @@ uses
|
|||
KASToolBar, KASBarMenu, KASBarFiles,
|
||||
uCmdBox, uFileSystemWatcher, uFilePanelSelect,
|
||||
uFileView, uColumnsFileView, uFileSource, uFileViewNotebook, uFile,
|
||||
uOperationsManager, uDrivesList, uTerminal
|
||||
uOperationsManager, uDrivesList, uTerminal, uClassesEx, uXmlConfig
|
||||
;
|
||||
|
||||
const
|
||||
|
|
@ -491,10 +491,14 @@ type
|
|||
procedure SetActiveFrame(panel: TFilePanelSelect);
|
||||
procedure UpdateDiskCount;
|
||||
procedure CreateDiskPanel(dskPanel : TKASToolBar);
|
||||
function CreateFileView(sType: String; FileSource: IFileSource; Path: String; Page: TFileViewPage): TFileView;
|
||||
function CreateFileView(sType: String; Page: TFileViewPage; AConfig: TIniFileEx; ASectionName: String; ATabIndex: Integer): TFileView;
|
||||
function CreateFileView(sType: String; Page: TFileViewPage; AConfig: TXmlConfig; ANode: TXmlNode): TFileView;
|
||||
procedure AssignEvents(AFileView: TFileView);
|
||||
function RemovePage(ANoteBook: TFileViewNotebook; iPageIndex:Integer): LongInt;
|
||||
procedure LoadTabs(ANoteBook: TFileViewNotebook);
|
||||
procedure SaveTabs(ANoteBook: TFileViewNotebook);
|
||||
procedure LoadTabsIni(ANoteBook: TFileViewNotebook);
|
||||
procedure LoadTabsXml(ANoteBook: TFileViewNotebook);
|
||||
procedure SaveTabsIni(ANoteBook: TFileViewNotebook);
|
||||
procedure SaveTabsXml(ANoteBook: TFileViewNotebook);
|
||||
function ExecCmd(Cmd:string; param:string='') : Boolean;
|
||||
function ExecCmdEx(Sender: TObject; NumberOfButton:Integer) : Boolean;
|
||||
procedure ToggleConsole;
|
||||
|
|
@ -544,7 +548,7 @@ implementation
|
|||
|
||||
uses
|
||||
LCLIntf, uGlobs, uLng, fConfigToolBar, Masks, fCopyMoveDlg, uQuickViewPanel,
|
||||
uShowMsg, uClassesEx, fHotDir, uDCUtils, uLog, uGlobsPaths, LCLProc, uOSUtils, uOSForms, uPixMapManager,
|
||||
uShowMsg, fHotDir, uDCUtils, uLog, uGlobsPaths, LCLProc, uOSUtils, uOSForms, uPixMapManager,
|
||||
uDragDropEx, StrUtils, uKeyboard, uFileSystemFileSource, fViewOperations,
|
||||
uFileSourceOperationTypes, uFileSourceCopyOperation, uFileSourceMoveOperation,
|
||||
fFileOpDlg, uFileSystemCopyOperation, uFileSystemMoveOperation, uFileSourceProperty,
|
||||
|
|
@ -576,6 +580,17 @@ var
|
|||
slCommandHistory: TStringListEx;
|
||||
I: Integer;
|
||||
begin
|
||||
Application.OnException := @AppException;
|
||||
|
||||
DrivesList := nil;
|
||||
LeftFrameWatcher:= nil;
|
||||
RightFrameWatcher:= nil;
|
||||
FDropParams := nil;
|
||||
|
||||
PanelSelected:=fpLeft;
|
||||
HiddenToTray := False;
|
||||
HidingTrayIcon := False;
|
||||
|
||||
nbLeft := CreateNotebook(pnlLeft, fpLeft);
|
||||
nbRight := CreateNotebook(pnlRight, fpRight);
|
||||
|
||||
|
|
@ -583,9 +598,6 @@ begin
|
|||
FDrivesListPopup.OnDriveSelected := @DriveListDriveSelected;
|
||||
FDrivesListPopup.OnClose := @DriveListClose;
|
||||
|
||||
HiddenToTray := False;
|
||||
HidingTrayIcon := False;
|
||||
|
||||
if gOnlyOnce and Assigned(UniqueInstance) then
|
||||
UniqueInstance.OnMessage:= @OnUniqueInstanceMessage;
|
||||
// frost_asm begin
|
||||
|
|
@ -593,8 +605,6 @@ begin
|
|||
// frost_asm end
|
||||
SetMyWndProc(Handle);
|
||||
|
||||
Application.OnException := @AppException;
|
||||
|
||||
if mbFileExists(gpIniDir+cHistoryFile) then
|
||||
begin
|
||||
slCommandHistory:= TStringListEx.Create;
|
||||
|
|
@ -620,14 +630,6 @@ begin
|
|||
actShowSysFiles.Checked:=uGlobs.gShowSystemFiles;
|
||||
|
||||
AllowDropFiles := not uDragDropEx.IsExternalDraggingSupported;
|
||||
FDropParams := nil;
|
||||
|
||||
PanelSelected:=fpLeft;
|
||||
|
||||
DrivesList := nil;
|
||||
|
||||
LeftFrameWatcher:= nil;
|
||||
RightFrameWatcher:= nil;
|
||||
|
||||
pmButtonMenu.BarFile.ChangePath := gpExePath;
|
||||
pmButtonMenu.BarFile.EnvVar := '%commander_path%';
|
||||
|
|
@ -1489,7 +1491,6 @@ var
|
|||
PopUpPoint: TPoint;
|
||||
NoteBook: TFileViewNotebook;
|
||||
TabNr: Integer;
|
||||
Index: Integer;
|
||||
begin
|
||||
NoteBook := Sender as TFileViewNotebook;
|
||||
|
||||
|
|
@ -2423,22 +2424,29 @@ begin
|
|||
AddSpecialButtons(dskPanel);
|
||||
end;
|
||||
|
||||
function TfrmMain.CreateFileView(sType: String; FileSource: IFileSource;
|
||||
Path: String; Page: TFileViewPage): TFileView;
|
||||
function TfrmMain.CreateFileView(sType: String; Page: TFileViewPage; AConfig: TIniFileEx; ASectionName: String; ATabIndex: Integer): TFileView;
|
||||
begin
|
||||
// This function should be changed to a separate TFileView factory.
|
||||
|
||||
if sType = 'columns' then
|
||||
begin
|
||||
Result := TColumnsFileView.Create(Page, FileSource, Path);
|
||||
end
|
||||
Result := TColumnsFileView.Create(Page, AConfig, ASectionName, ATabIndex)
|
||||
else
|
||||
begin
|
||||
Result := nil;
|
||||
Exit;
|
||||
end;
|
||||
raise Exception.Create('Invalid file view type');
|
||||
end;
|
||||
|
||||
with Result do
|
||||
function TfrmMain.CreateFileView(sType: String; Page: TFileViewPage; AConfig: TXmlConfig; ANode: TXmlNode): TFileView;
|
||||
begin
|
||||
// This function should be changed to a separate TFileView factory.
|
||||
|
||||
if sType = 'columns' then
|
||||
Result := TColumnsFileView.Create(Page, AConfig, ANode)
|
||||
else
|
||||
raise Exception.Create('Invalid file view type');
|
||||
end;
|
||||
|
||||
procedure TfrmMain.AssignEvents(AFileView: TFileView);
|
||||
begin
|
||||
with AFileView do
|
||||
begin
|
||||
OnBeforeChangeDirectory := @FileViewBeforeChangeDirectory;
|
||||
OnAfterChangeDirectory := @FileViewAfterChangeDirectory;
|
||||
|
|
@ -2478,7 +2486,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.LoadTabs(ANoteBook: TFileViewNotebook);
|
||||
procedure TfrmMain.LoadTabsIni(ANoteBook: TFileViewNotebook);
|
||||
var
|
||||
I: Integer;
|
||||
sIndex,
|
||||
|
|
@ -2487,6 +2495,7 @@ var
|
|||
sPath, sCaption: String;
|
||||
iActiveTab: Integer;
|
||||
Page: TFileViewPage;
|
||||
AFileView: TFileView;
|
||||
aFileSource: IFileSource;
|
||||
begin
|
||||
if ANoteBook = nbLeft then
|
||||
|
|
@ -2529,19 +2538,20 @@ begin
|
|||
|
||||
aFileSource := TFileSystemFileSource.GetFileSource;
|
||||
|
||||
if not Assigned(CreateFileView('columns', aFileSource, sPath, Page)) then
|
||||
AFileView := CreateFileView('columns', Page, gIni, TabsSection, StrToInt(sIndex));
|
||||
if not Assigned(AFileView) then
|
||||
begin
|
||||
ANoteBook.RemovePage(Page);
|
||||
continue;
|
||||
end;
|
||||
|
||||
Page.LockState := TTabLockState(gIni.ReadInteger(TabsSection, sIndex + '_options', 0));
|
||||
Page.LockState := TTabLockState(gIni.ReadInteger(TabsSection, sIndex + '_options', Integer(tlsNormal)));
|
||||
if Page.LockState = tlsPathResets then // if locked tab with directory change
|
||||
Page.LockPath := sPath;
|
||||
|
||||
Page.FileView.LoadConfiguration(TabsSection, StrToInt(sIndex));
|
||||
// Reload file list after loading configuration.
|
||||
Page.FileView.Reload;
|
||||
AFileView.AddFileSource(aFileSource, sPath);
|
||||
// Assign events after loading file source.
|
||||
AssignEvents(AFileView);
|
||||
|
||||
Inc(I);
|
||||
// get page index in string representation
|
||||
|
|
@ -2559,7 +2569,86 @@ begin
|
|||
ANoteBook.PageIndex := iActiveTab;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.SaveTabs(ANoteBook: TFileViewNotebook);
|
||||
procedure TfrmMain.LoadTabsXml(ANoteBook: TFileViewNotebook);
|
||||
var
|
||||
sCurrentDir,
|
||||
sPath, sCaption: String;
|
||||
iActiveTab: Integer;
|
||||
Page: TFileViewPage;
|
||||
AFileView: TFileView;
|
||||
aFileSource: IFileSource;
|
||||
RootNode, ANode: TXmlNode;
|
||||
begin
|
||||
if ANoteBook = nbLeft then
|
||||
RootNode := gConfig.FindNode(gConfig.RootNode, 'Tabs/OpenedTabs/Left')
|
||||
else
|
||||
RootNode := gConfig.FindNode(gConfig.RootNode, 'Tabs/OpenedTabs/Right');
|
||||
|
||||
if not Assigned(RootNode) then
|
||||
Exit;
|
||||
|
||||
if Assigned(RootNode) then
|
||||
begin
|
||||
sCurrentDir := mbGetCurrentDir; // default path
|
||||
ANode := RootNode.FirstChild;
|
||||
while Assigned(ANode) do
|
||||
begin
|
||||
if ANode.CompareName('Tab') = 0 then
|
||||
begin
|
||||
if gConfig.TryGetValue(ANode, 'Path', sPath) then
|
||||
begin
|
||||
if mbDirectoryExists(sPath) then
|
||||
begin
|
||||
if not gConfig.TryGetValue(ANode, 'Caption', sCaption) then
|
||||
sCaption := GetLastDir(sPath);
|
||||
end
|
||||
else
|
||||
begin // find exists directory
|
||||
repeat
|
||||
sPath:= GetParentDir(sPath);
|
||||
if sPath = EmptyStr then
|
||||
sPath:= sCurrentDir;
|
||||
until mbDirectoryExists(sPath);
|
||||
sCaption:= GetLastDir(sPath);
|
||||
end;
|
||||
|
||||
if sCaption <> '' then
|
||||
if (tb_text_length_limit in gDirTabOptions) and (Length(sCaption) > gDirTabLimit) then
|
||||
sCaption := Copy(sCaption, 1, gDirTabLimit) + '...';
|
||||
|
||||
Page := ANoteBook.AddPage(sCaption);
|
||||
|
||||
aFileSource := TFileSystemFileSource.GetFileSource;
|
||||
|
||||
AFileView := CreateFileView('columns', Page, gConfig, ANode);
|
||||
if not Assigned(AFileView) then
|
||||
begin
|
||||
ANoteBook.RemovePage(Page);
|
||||
continue;
|
||||
end;
|
||||
|
||||
Page.LockState := TTabLockState(gConfig.GetValue(ANode, 'Options', Integer(tlsNormal)));
|
||||
if Page.LockState = tlsPathResets then // if locked tab with directory change
|
||||
Page.LockPath := sPath;
|
||||
|
||||
AFileView.AddFileSource(aFileSource, sPath);
|
||||
// Assign events after loading file source.
|
||||
AssignEvents(AFileView);
|
||||
end
|
||||
else
|
||||
DebugLn('Invalid entry in configuration: ' + gConfig.GetPathFromNode(ANode) + '.');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// read active tab index
|
||||
iActiveTab := gConfig.GetValue(RootNode, 'ActiveTab', 0);
|
||||
// set active tab
|
||||
if (iActiveTab >= 0) and (iActiveTab < ANoteBook.PageCount) then
|
||||
ANoteBook.PageIndex := iActiveTab;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.SaveTabsIni(ANoteBook: TFileViewNotebook);
|
||||
var
|
||||
I, Count: Integer;
|
||||
sIndex,
|
||||
|
|
@ -2598,6 +2687,42 @@ begin
|
|||
gIni.WriteInteger(TabsSection, 'activetab', ANoteBook.PageIndex);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.SaveTabsXml(ANoteBook: TFileViewNotebook);
|
||||
var
|
||||
I: Integer;
|
||||
TabsSection: String;
|
||||
sPath : String;
|
||||
Page: TFileViewPage;
|
||||
ANode, SubNode: TXmlNode;
|
||||
begin
|
||||
ANode := gConfig.FindNode(gConfig.RootNode, 'Tabs/OpenedTabs', True);
|
||||
if ANoteBook = nbLeft then
|
||||
TabsSection := 'Left'
|
||||
else
|
||||
TabsSection := 'Right';
|
||||
ANode := gConfig.FindNode(ANode, TabsSection, True);
|
||||
|
||||
gConfig.ClearNode(ANode);
|
||||
gConfig.SetValue(ANode, 'ActiveTab', ANoteBook.PageIndex);
|
||||
|
||||
for I:= 0 to ANoteBook.PageCount - 1 do
|
||||
begin
|
||||
SubNode := gConfig.AddNode(ANode, 'Tab');
|
||||
Page := ANoteBook.Page[I];
|
||||
|
||||
if Page.LockState = tlsPathResets then // if locked tab with directory change
|
||||
sPath := Page.LockPath
|
||||
else
|
||||
sPath := Page.FileView.CurrentPath;
|
||||
|
||||
gConfig.AddValue(SubNode, 'Path', sPath);
|
||||
gConfig.AddValue(SubNode, 'Caption', Page.Caption);
|
||||
gConfig.AddValue(SubNode, 'Options', Integer(Page.LockState));
|
||||
|
||||
Page.FileView.SaveConfiguration(gConfig, SubNode);
|
||||
end;
|
||||
end;
|
||||
|
||||
(* Execute internal or external command *)
|
||||
|
||||
function TfrmMain.ExecCmd(Cmd: string; param:string=''): Boolean;
|
||||
|
|
@ -3059,8 +3184,16 @@ begin
|
|||
Self.WindowState := wsMaximized;
|
||||
|
||||
(* Load all tabs *)
|
||||
LoadTabs(nbLeft);
|
||||
LoadTabs(nbRight);
|
||||
if Assigned(gIni) then
|
||||
begin
|
||||
LoadTabsIni(nbLeft);
|
||||
LoadTabsIni(nbRight);
|
||||
end
|
||||
else
|
||||
begin
|
||||
LoadTabsXml(nbLeft);
|
||||
LoadTabsXml(nbRight);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.SaveWindowState;
|
||||
|
|
@ -3077,8 +3210,14 @@ begin
|
|||
}
|
||||
|
||||
(* Save all tabs *)
|
||||
SaveTabs(nbLeft);
|
||||
SaveTabs(nbRight);
|
||||
{$IFDEF DC_USE_XML_CONFIG}
|
||||
SaveTabsXml(nbLeft);
|
||||
SaveTabsXml(nbRight);
|
||||
{$ELSE}
|
||||
SaveTabsIni(nbLeft);
|
||||
SaveTabsIni(nbRight);
|
||||
{$ENDIF}
|
||||
|
||||
(* Save window bounds and state*)
|
||||
gIni.WriteInteger('Configuration', 'Main.Left', Left);
|
||||
gIni.WriteInteger('Configuration', 'Main.Top', Top);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ uses
|
|||
uColumnsFileViewFiles,
|
||||
uColumns,
|
||||
uFileSorting,
|
||||
uFunctionThread
|
||||
uFunctionThread,
|
||||
uXmlConfig,
|
||||
uClassesEx
|
||||
;
|
||||
|
||||
//{$DEFINE timeFileView}
|
||||
|
|
@ -204,13 +206,6 @@ type
|
|||
dgPanel: TDrawGridEx;
|
||||
tmContextMenu: TTimer;
|
||||
|
||||
{en
|
||||
Private constructor used to create an object intended to be a clone
|
||||
(with its properties copied from another object).
|
||||
}
|
||||
constructor Create(AOwner: TWinControl; AFileSource: IFileSource;
|
||||
APath: String; Cloning: Boolean = False); overload;
|
||||
|
||||
function GetGridHorzLine: Boolean;
|
||||
function GetGridVertLine: Boolean;
|
||||
procedure SetGridHorzLine(const AValue: Boolean);
|
||||
|
|
@ -366,6 +361,8 @@ type
|
|||
property FileFilter: String read FFileFilter write SetFileFilter;
|
||||
|
||||
protected
|
||||
procedure CreateDefault(AOwner: TWinControl); override;
|
||||
|
||||
procedure SetCurrentPath(NewPath: String); override;
|
||||
function GetActiveFile: TFile; override;
|
||||
function GetDisplayedFiles: TFiles; override;
|
||||
|
|
@ -380,6 +377,9 @@ type
|
|||
//---------------------
|
||||
|
||||
constructor Create(AOwner: TWinControl; AFileSource: IFileSource; APath: String); override;
|
||||
constructor Create(AOwner: TWinControl; AFileView: TFileView); override;
|
||||
constructor Create(AOwner: TWinControl; AConfig: TIniFileEx; ASectionName: String; ATabIndex: Integer); override;
|
||||
constructor Create(AOwner: TWinControl; AConfig: TXmlConfig; ANode: TXmlNode); override;
|
||||
|
||||
destructor Destroy; override;
|
||||
|
||||
|
|
@ -392,11 +392,13 @@ type
|
|||
procedure Reload(const PathsToReload: TPathsArray = nil); override;
|
||||
procedure StopBackgroundWork; override;
|
||||
|
||||
function Focused: Boolean; override;
|
||||
procedure SetFocus; override;
|
||||
|
||||
procedure LoadConfiguration(Section: String; TabIndex: Integer); override;
|
||||
procedure SaveConfiguration(Section: String; TabIndex: Integer); override;
|
||||
procedure LoadConfiguration(AConfig: TXmlConfig; ANode: TXmlNode); override;
|
||||
procedure SaveConfiguration(AConfig: TXmlConfig; ANode: TXmlNode); override;
|
||||
|
||||
function Focused: Boolean; override;
|
||||
procedure SetFocus; override;
|
||||
|
||||
{en
|
||||
Moves the selection focus to the file specified by FileName.
|
||||
|
|
@ -600,8 +602,6 @@ begin
|
|||
|
||||
ActiveColm := gIni.ReadString(Section, sIndex + '_columnsset', 'Default');
|
||||
|
||||
UpdateColumnsView;
|
||||
|
||||
// Load sorting options.
|
||||
FSorting.Clear;
|
||||
ColumnsClass := GetColumnsClass;
|
||||
|
|
@ -640,6 +640,58 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TColumnsFileView.LoadConfiguration(AConfig: TXmlConfig; ANode: TXmlNode);
|
||||
var
|
||||
ColumnsClass: TPanelColumnsClass;
|
||||
SortColumn: Integer;
|
||||
SortDirection: TSortDirection;
|
||||
begin
|
||||
ActiveColm := AConfig.GetValue(ANode, 'ColumnsSet', 'Default');
|
||||
|
||||
// Load sorting options.
|
||||
FSorting.Clear;
|
||||
ColumnsClass := GetColumnsClass;
|
||||
ANode := ANode.FindNode('Sorting');
|
||||
if Assigned(ANode) then
|
||||
begin
|
||||
ANode := ANode.FirstChild;
|
||||
while Assigned(ANode) do
|
||||
begin
|
||||
if ANode.CompareName('Sort') = 0 then
|
||||
begin
|
||||
if AConfig.TryGetValue(ANode, 'Column', SortColumn) and
|
||||
(SortColumn >= 0) and (SortColumn < ColumnsClass.ColumnsCount) then
|
||||
begin
|
||||
SortDirection := TSortDirection(AConfig.GetValue(ANode, 'Direction', Integer(sdNone)));
|
||||
FSorting.AddSorting(SortColumn, SortDirection);
|
||||
end
|
||||
else
|
||||
DebugLn('Invalid entry in configuration: ' + AConfig.GetPathFromNode(ANode) + '.');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColumnsFileView.SaveConfiguration(AConfig: TXmlConfig; ANode: TXmlNode);
|
||||
var
|
||||
SortingColumn: PFileListSortingColumn;
|
||||
i: Integer;
|
||||
SubNode: TXmlNode;
|
||||
begin
|
||||
AConfig.SetValue(ANode, 'ColumnsSet', ActiveColm);
|
||||
ANode := AConfig.FindNode(ANode, 'Sorting', True);
|
||||
AConfig.ClearNode(ANode);
|
||||
|
||||
// Save sorting options.
|
||||
for i := 0 to FSorting.Count - 1 do
|
||||
begin
|
||||
SortingColumn := PFileListSortingColumn(FSorting.Items[i]);
|
||||
SubNode := AConfig.AddNode(ANode, 'Sort');
|
||||
AConfig.AddValue(SubNode, 'Column', SortingColumn^.iField);
|
||||
AConfig.AddValue(SubNode, 'Direction', Integer(SortingColumn^.SortDirection));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColumnsFileView.SelectFile(AFile: TColumnsViewFile);
|
||||
begin
|
||||
InvertFileSelection(AFile);
|
||||
|
|
@ -2472,19 +2524,52 @@ end;
|
|||
|
||||
constructor TColumnsFileView.Create(AOwner: TWinControl; AFileSource: IFileSource; APath: String);
|
||||
begin
|
||||
Create(AOwner, AFileSource, APath, False);
|
||||
inherited Create(AOwner, AFileSource, APath);
|
||||
|
||||
FFiles := TColumnsViewFiles.Create;
|
||||
FSorting := TFileListSorting.Create;
|
||||
ActiveColm := 'Default';
|
||||
|
||||
// Update view before making file source file list,
|
||||
// so that file list isn't unnecessarily displayed twice.
|
||||
UpdateView;
|
||||
MakeFileSourceFileList;
|
||||
end;
|
||||
|
||||
constructor TColumnsFileView.Create(AOwner: TWinControl; AFileSource: IFileSource;
|
||||
APath: String; Cloning: Boolean = False);
|
||||
constructor TColumnsFileView.Create(AOwner: TWinControl; AFileView: TFileView);
|
||||
begin
|
||||
inherited Create(AOwner, AFileView);
|
||||
UpdateView;
|
||||
end;
|
||||
|
||||
constructor TColumnsFileView.Create(AOwner: TWinControl; AConfig: TIniFileEx; ASectionName: String; ATabIndex: Integer);
|
||||
begin
|
||||
inherited Create(AOwner, AConfig, ASectionName, ATabIndex);
|
||||
|
||||
FFiles := TColumnsViewFiles.Create;
|
||||
FSorting := TFileListSorting.Create;
|
||||
|
||||
LoadConfiguration(ASectionName, ATabIndex);
|
||||
end;
|
||||
|
||||
constructor TColumnsFileView.Create(AOwner: TWinControl; AConfig: TXmlConfig; ANode: TXmlNode);
|
||||
begin
|
||||
inherited Create(AOwner, AConfig, ANode);
|
||||
|
||||
FFiles := TColumnsViewFiles.Create;
|
||||
FSorting := TFileListSorting.Create;
|
||||
|
||||
LoadConfiguration(AConfig, ANode);
|
||||
end;
|
||||
|
||||
procedure TColumnsFileView.CreateDefault(AOwner: TWinControl);
|
||||
begin
|
||||
DebugLn('TColumnsFileView.Create components');
|
||||
|
||||
dgPanel := nil;
|
||||
|
||||
BorderStyle := bsNone; // Before Create or the window may be recreated
|
||||
inherited Create(AOwner, AFileSource, APath);
|
||||
Parent := AOwner;
|
||||
BorderStyle := bsNone; // Before Create or the window handle may be recreated
|
||||
inherited CreateDefault(AOwner);
|
||||
Align := alClient;
|
||||
|
||||
FFiles := nil;
|
||||
|
|
@ -2494,12 +2579,14 @@ begin
|
|||
FFileListBuilderLock := TCriticalSection.Create;
|
||||
FFileListBuilders := TFPList.Create;
|
||||
|
||||
ActiveColm := '';
|
||||
ActiveColmSlave := nil;
|
||||
isSlave := False;
|
||||
FLastSelectionStartRow := -1;
|
||||
FLastMark := '*';
|
||||
FLastActive := '';
|
||||
FActive := False;
|
||||
FFileFilter := '';
|
||||
|
||||
FSorting := nil;
|
||||
// default to sorting by 0-th column
|
||||
|
|
@ -2642,23 +2729,6 @@ begin
|
|||
|
||||
pmColumnsMenu := TPopupMenu.Create(Self);
|
||||
pmColumnsMenu.Parent := Self;
|
||||
|
||||
// Statements which should not be executed
|
||||
// when the object is created for cloning.
|
||||
if not Cloning then
|
||||
begin
|
||||
FFiles := TColumnsViewFiles.Create;
|
||||
FSorting := TFileListSorting.Create;
|
||||
|
||||
// Update view before making file source file list,
|
||||
// so that file list isn't unnecessarily displayed twice.
|
||||
UpdateView;
|
||||
|
||||
// Configuration should be read before loading file list.
|
||||
//MakeFileSourceFileList;
|
||||
end
|
||||
else
|
||||
UpdateView;
|
||||
end;
|
||||
|
||||
destructor TColumnsFileView.Destroy;
|
||||
|
|
@ -2703,8 +2773,7 @@ end;
|
|||
|
||||
function TColumnsFileView.Clone(NewParent: TWinControl): TColumnsFileView;
|
||||
begin
|
||||
Result := TColumnsFileView.Create(NewParent, FileSource, CurrentPath, True);
|
||||
CloneTo(Result);
|
||||
Result := TColumnsFileView.Create(NewParent, Self);
|
||||
end;
|
||||
|
||||
procedure TColumnsFileView.CloneTo(FileView: TFileView);
|
||||
|
|
@ -2743,11 +2812,7 @@ begin
|
|||
|
||||
ActiveColm := Self.ActiveColm;
|
||||
ActiveColmSlave := nil; // set to nil because only used in preview?
|
||||
isSlave := self.isSlave;
|
||||
|
||||
// All the visual controls don't need cloning.
|
||||
|
||||
UpdateView;
|
||||
isSlave := Self.isSlave;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ interface
|
|||
|
||||
uses
|
||||
Classes, SysUtils, Controls, ExtCtrls,
|
||||
uFile, uFileSource, uMethodsList, uDragDropEx;
|
||||
uFile, uFileSource, uMethodsList, uDragDropEx, uXmlConfig, uClassesEx;
|
||||
|
||||
type
|
||||
|
||||
|
|
@ -62,6 +62,11 @@ type
|
|||
procedure ReloadEvent(const aFileSource: IFileSource; const ReloadedPaths: TPathsArray);
|
||||
|
||||
protected
|
||||
{en
|
||||
Initializes parts of the view common to all creation methods.
|
||||
}
|
||||
procedure CreateDefault(AOwner: TWinControl); virtual;
|
||||
|
||||
function GetCurrentPath: String; virtual;
|
||||
procedure SetCurrentPath(NewPath: String); virtual;
|
||||
function GetActiveFile: TFile; virtual;
|
||||
|
|
@ -80,11 +85,20 @@ type
|
|||
constructor Create(AOwner: TWinControl;
|
||||
FileSource: IFileSource;
|
||||
Path: String); virtual reintroduce;
|
||||
constructor Create(AOwner: TWinControl;
|
||||
AFileView: TFileView); virtual reintroduce;
|
||||
constructor Create(AOwner: TWinControl;
|
||||
AConfig: TIniFileEx;
|
||||
ASectionName: String;
|
||||
ATabIndex: Integer); virtual reintroduce;
|
||||
constructor Create(AOwner: TWinControl;
|
||||
AConfig: TXmlConfig;
|
||||
ANode: TXmlNode); virtual reintroduce;
|
||||
|
||||
destructor Destroy; override;
|
||||
|
||||
function Clone(NewParent: TWinControl): TFileView; virtual;
|
||||
procedure CloneTo(FileView: TFileView); virtual;
|
||||
procedure CloneTo(AFileView: TFileView); virtual;
|
||||
|
||||
procedure AddFileSource(aFileSource: IFileSource; aPath: String); virtual;
|
||||
procedure RemoveLastFileSource; virtual;
|
||||
|
|
@ -103,6 +117,8 @@ type
|
|||
// Config should be independent of that in the future.
|
||||
procedure LoadConfiguration(Section: String; TabIndex: Integer); virtual abstract;
|
||||
procedure SaveConfiguration(Section: String; TabIndex: Integer); virtual abstract;
|
||||
procedure LoadConfiguration(AConfig: TXmlConfig; ANode: TXmlNode); virtual abstract;
|
||||
procedure SaveConfiguration(AConfig: TXmlConfig; ANode: TXmlNode); virtual abstract;
|
||||
|
||||
procedure UpdateView; virtual abstract;
|
||||
|
||||
|
|
@ -224,6 +240,31 @@ uses
|
|||
uActs, LCLProc;
|
||||
|
||||
constructor TFileView.Create(AOwner: TWinControl; FileSource: IFileSource; Path: String);
|
||||
begin
|
||||
CreateDefault(AOwner);
|
||||
|
||||
FFileSources.Add(FileSource);
|
||||
FCurrentPaths.Add(IncludeTrailingPathDelimiter(Path));
|
||||
FileSource.AddReloadEventListener(@ReloadEvent);
|
||||
end;
|
||||
|
||||
constructor TFileView.Create(AOwner: TWinControl; AFileView: TFileView);
|
||||
begin
|
||||
CreateDefault(AOwner);
|
||||
AFileView.CloneTo(Self);
|
||||
end;
|
||||
|
||||
constructor TFileView.Create(AOwner: TWinControl; AConfig: TIniFileEx; ASectionName: String; ATabIndex: Integer);
|
||||
begin
|
||||
CreateDefault(AOwner);
|
||||
end;
|
||||
|
||||
constructor TFileView.Create(AOwner: TWinControl; AConfig: TXmlConfig; ANode: TXmlNode);
|
||||
begin
|
||||
CreateDefault(AOwner);
|
||||
end;
|
||||
|
||||
procedure TFileView.CreateDefault(AOwner: TWinControl);
|
||||
begin
|
||||
FOnBeforeChangeDirectory := nil;
|
||||
FOnAfterChangeDirectory := nil;
|
||||
|
|
@ -231,17 +272,12 @@ begin
|
|||
FOnChangeFileSource := nil;
|
||||
FOnActivate := nil;
|
||||
FOnReload := nil;
|
||||
|
||||
FFileSources := TFileSources.Create;
|
||||
FFileSources.Add(FileSource);
|
||||
FCurrentPaths := TStringList.Create;
|
||||
FCurrentPaths.Add(IncludeTrailingPathDelimiter(Path));
|
||||
|
||||
FileSource.AddReloadEventListener(@ReloadEvent);
|
||||
|
||||
FMethods := TMethodsList.Create(Self);
|
||||
|
||||
inherited Create(AOwner);
|
||||
Parent := AOwner;
|
||||
end;
|
||||
|
||||
destructor TFileView.Destroy;
|
||||
|
|
@ -265,20 +301,20 @@ begin
|
|||
raise Exception.Create('Cannot create object of abstract class');
|
||||
end;
|
||||
|
||||
procedure TFileView.CloneTo(FileView: TFileView);
|
||||
procedure TFileView.CloneTo(AFileView: TFileView);
|
||||
begin
|
||||
if Assigned(FileView) then
|
||||
if Assigned(AFileView) then
|
||||
begin
|
||||
// FFileSource should have been passed to FileView constructor already.
|
||||
// FMethods are created in FileView constructor.
|
||||
FileView.OnBeforeChangeDirectory := Self.OnBeforeChangeDirectory;
|
||||
FileView.OnAfterChangeDirectory := Self.OnAfterChangeDirectory;
|
||||
FileView.OnChangeFileSource := Self.OnChangeFileSource;
|
||||
FileView.OnActivate := Self.OnActivate;
|
||||
FileView.OnReload := Self.OnReload;
|
||||
AFileView.OnBeforeChangeDirectory := Self.OnBeforeChangeDirectory;
|
||||
AFileView.OnAfterChangeDirectory := Self.OnAfterChangeDirectory;
|
||||
AFileView.OnChangeFileSource := Self.OnChangeFileSource;
|
||||
AFileView.OnActivate := Self.OnActivate;
|
||||
AFileView.OnReload := Self.OnReload;
|
||||
|
||||
FileView.FFileSources.Assign(Self.FFileSources);
|
||||
FileView.FCurrentPaths.Assign(Self.FCurrentPaths);
|
||||
AFileView.FFileSources.Assign(Self.FFileSources);
|
||||
AFileView.FCurrentPaths.Assign(Self.FCurrentPaths);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -292,12 +328,18 @@ end;
|
|||
|
||||
function TFileView.GetCurrentAddress: String;
|
||||
begin
|
||||
Result := FileSource.CurrentAddress;
|
||||
if FileSourcesCount > 0 then
|
||||
Result := FileSource.CurrentAddress
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function TFileView.GetCurrentPath: String;
|
||||
begin
|
||||
Result := FCurrentPaths.Strings[FCurrentPaths.Count - 1];
|
||||
if FCurrentPaths.Count > 0 then
|
||||
Result := FCurrentPaths.Strings[FCurrentPaths.Count - 1]
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
procedure TFileView.SetCurrentPath(NewPath: String);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue