Re: Has anyone been able to force TreeView expander with no children?



ke, 2009-10-14 kello 18:52 -0700, Daniel B. Thurman kirjoitti:
I have a FileViewer application that I am working on
and so far I have not been able to force expanders
on TreeView when there are only "top-level"
directories/files populated in the TreeStore.

As I understand it, the expander will only be shown for tree rows that
have children. You want to show them always, so that you don't have to
scan an entire directory tree to figure out which have children and
which don't.

Would one of the following approaches work for you?

a) Add dummy items to nodes. When a node is expanded, and it has a dummy
node, scan for subdirectories and replace the dummy node with real ones.
This means even nodes without subdirectories will have an expander,
which might be awkward for the user.

b) Initially, add top level items and their immediate subdirectories.
When a node is expanded the first time, scan its subdirectories'
subdirectories and add those. That was confusing, let me show an
example. Initially, have this (> means closed expander, v means open):

        > aaa
        > bbb
          ccc

Here, you've scanned aaa and bbb and ccc for subdirectories. You know
ccc doesn't have any, so it gets no children and no expander. aaa and
bbb have children, so they get them and expanders.

When aaa is expanded the first time, you scan aaa/* for subdirectories,
and add them to their parent nodes (i.e., to children of aaa), before
letting the aaa node be expanded on screen. In other words:

        v aaa
            aaa-1
          > aaa-2
            aaa-3
        > bbb
          ccc
        
Here, you scanned aaa-1, aaa-2, and aaa-3 for children, and found that
aaa-2 has them.

You can use a hidden column to keep track of which nodes have been
expanded (= scanned).

c) Do the scan in the background, modifying the tree when you find
things. You can either let the scan go through the entire filesystem
this way, or scan directories that are shown (a bit like in option b,
but scanning is done in the background, not just when the node is about
to be expanded).





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]