ivoflipse / Pawlabeling

Tool for processing and analyzing pressure measurements
Other
18 stars 1 forks source link

Use QModels for bookkeeping #56

Closed ivoflipse closed 10 years ago

ivoflipse commented 10 years ago

At the moment I basically manage all the trees manually, but Qt offers the ability to create a Model, which stores whatever you want to view, the View is then the tree that displays the contents of the Model.

Then if I update the Model, the View should get changed accordingly. I've refrained from using it so far, because in the end you still have to write the code that does whatever you want either way. But it seems that in some cases it might make things a bit easier, especially when things happen asynchronously.

ivoflipse commented 10 years ago

This example worked to show the measurements, but I wanted to use the contents of the tree to pick the measurements to load. Off course I could make the user select the 'session' folder instead and load all the contents, one advantage of this version is that it shows multiple folders, so it makes browsing easier.

    self.files_tree = QtGui.QTreeView()
    self.files_model = QtGui.QFileSystemModel()
    self.files_model.setRootPath(configuration.measurement_folder)
    self.files_tree.setModel(self.files_model)
    self.files_tree.setRootIndex(self.files_model.index(configuration.measurement_folder))

image

I'm not yet sure what I prefer, so I'll wait for others to comment on it.

ivoflipse commented 10 years ago

I think for now I'm going to opt out of using QModels, they don't really save me that much work and most trees already work pretty much the way I want.