ShellTreeView:

- respect the designtime settings of ObjectTypes.
- add DbgS() for TObjectTypes

git-svn-id: trunk@47690 -
This commit is contained in:
bart 2015-02-10 21:55:47 +00:00
parent fb19f71ae7
commit 9e7fa223d3

View File

@ -53,6 +53,7 @@ type
FRoot: string;
FShellListView: TCustomShellListView;
FFileSortType: TFileSortType;
FInitialRoot: String;
{ Setters and getters }
function GetPath: string;
procedure SetFileSortType(const AValue: TFileSortType);
@ -60,6 +61,7 @@ type
procedure SetRoot(const AValue: string);
procedure SetShellListView(const Value: TCustomShellListView);
protected
procedure Loaded; override;
{ Other methods specific to Lazarus }
function PopulateTreeNodeWithFiles(
ANode: TTreeNode; ANodePath: string): Boolean;
@ -294,6 +296,8 @@ const
SShellCtrlsInvalidPathRelative = 'Invalid relative pathname:'#13'"%s"'#13
+'in relation to rootpath:'#13'"%s"';
function DbgS(OT: TObjectTypes): String; overload;
procedure Register;
implementation
@ -302,6 +306,19 @@ implementation
uses Windows;
{$endif}
function DbgS(OT: TObjectTypes): String; overload;
begin
Result := '[';
if (otFolders in OT) then Result := Result + 'otFolders,';
if (otNonFolders in OT) then Result := Result + 'otNonFolders,';
if (otHidden in OT) then Result := Result + 'otHidden';
if Result[Length(Result)] = ',' then System.Delete(Result, Length(Result), 1);
Result := Result + ']';
end;
{
uses ShlObj;
@ -361,11 +378,25 @@ begin
Value.ShellTreeView := Self;
end;
procedure TCustomShellTreeView.Loaded;
begin
inherited Loaded;
if (FInitialRoot = '') then
PopulateWithBaseFiles()
else
SetRoot(FInitialRoot);
end;
procedure TCustomShellTreeView.SetRoot(const AValue: string);
var
RootNode: TTreeNode;
begin
if FRoot=AValue then exit;
if (csLoading in ComponentState) then
begin
FInitialRoot := AValue;
Exit;
end;
//Delphi raises an unspecified exception in this case, but don't crash the IDE at designtime
if not (csDesigning in ComponentState)
and (AValue <> '')
@ -442,14 +473,13 @@ end;
constructor TCustomShellTreeView.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FInitialRoot := '';
// Initial property values
ObjectTypes:= [otFolders];
// Populates the base dirs
PopulateWithBaseFiles();
// Populating the base dirs is done in Loaded
end;
destructor TCustomShellTreeView.Destroy;
@ -760,7 +790,8 @@ var
NewNode: TTreeNode;
begin
// avoids crashes in the IDE by not populating during design
if (csDesigning in ComponentState) then Exit;
// also do not populate before loading is done
if ([csDesigning, csLoading] * ComponentState <> []) then Exit;
// This allows showing "/" in Linux, but in Windows it makes no sense to show the base
if GetBasePath() <> '' then