[fpc-pascal] Directory Tree

Jean SUZINEAU jean.suzineau at wanadoo.fr
Thu Apr 15 02:11:46 CEST 2021


Le 14/04/2021 à 13:06, James Richters via fpc-pascal a écrit :
> 	I still can’t get off the Master branch on my windows machine. I deleted everything, re-forked it, re-cloned it,
I finally found on my linux machine a 'test_gICAPI\jsLignes.Exclus.txt' 
file right in tools directory, and removed it. It has been generated by 
a delphi program (with \ hardcoded for file path separator) that I 
quickly recompile with lazarus under linux. The  \ is an escape sequence 
in linux file names.
It seems it isn't a problem for TortoiseGit  on my Windows machine, he 
just ignores it.
It should work for you now. I've tested several time checking out the 
whole repository and switching to the TjsDataContexe branch
> I added a Load Time edit box,  Total Run time, and total including loading needed in the report… Yay I managed to do something on my own!
> I also cleared the old tree when a new file was loaded.. so I managed to do two things 😊
> I wanted my run time to be just minutes and seconds, so I made your procedure that fixes the time format into a function and used that for my edit box as well.
> Since I still can't change branches on your repository, I updated mine
> https://github.com/Zaaphod/FileTree
>
> But now I have more questions…. while I can understand the pascal code… I find that I am still a bit lost on how things work, so I really appreciate the help.
>
> I would like the initial display of the tree to be expanded one level.. so just like I hit the + in front of M: so I thought, how hard could that be? ...
I have added a procedure vst_expand_first_level; for this .
> I also thought I would display the output in another tree in the right side of the split.. maybe a TTreeView Tree since it won't need checkboxes, and it could be just displayed already expanded all the way out.
> o I thought I would start by making   function TfFileVirtualTree.Get_Checked add the nodes to TTreeView so I tried to put
>             tv_addnode_from_key_value( td.Key, td.Value);
>        right before
>             Formate_Liste( Result, #13#10, td.Key+' '+td.Value);
>
> Well it couldn't find tv_addnode_from_key_value() because it's in ufFileTree.Pas  but I don't understand why it can't find it, because ufFileTRee is in the uses section of ufFileVirtualTree.
> I did move     procedure tv_addnode_from_key_value( _Key, _Value: String);  from private to public..  but it still can't find it.  I'm not really sure how to get data from one of the .PAS files into the other.

Even in public, you would have needed to call it as 
fFileTree.tv_addnode_from_key_value , but it will have worked on the 
TreeView  from fFileTree, which is not what you want. You can consider a 
bit  a class as a record. If tv_addnode_from_key_value is defined in a 
class TfFileTree, you can only call it on an instance of TfFileTree, in 
this case fFileTree, the same way you would access to something defined 
in a record.

Well, this lead me to a big refactoring. I move most of the code from 
ufFileTree to  uFileTree.

I didn't put it in the interface of the unit, but you could now 
eventually use procedure TreeView_addnode_from_key_value from uFileTree 
for this.

I did the same for ufFileVirtualTree, creating a unit uFileVirtualTree 
with a class ThVirtualStringTree dedicated to the handling of a 
TVirtualStringTree.

This way I could add another VirtualTreeView with no checkboxs to 
display the results. I think it's easier to use a VirtualTreeView to 
manage your time sums.
The ThVirtualStringTree class allows to reuse the exact same code for 
the result tree with time sums, and it allows reduce the complexity and 
the amount of code in ufFileVirtualTree.




More information about the fpc-pascal mailing list