How to update the content of a tree view



Hello.

I'm familiar with GUI programming but is fairly new to GTK+ and GTKmm.
I'm going through the basics but is stuck on how to properly design my
application for use of tree views.

Let's say that I have an application that creates and runs a number of
"jobs". These jobs are displayed in a tree view where each job has a
job ID and a progress bar, where the progress bar shows how much of
the job that is done.

Creating this tree view and populating it with initial values was very
easy. You create the tree view, the associated model and creates rows
for the model by calling append() on the tree model.

However, every now and then the progress bars has to be updated and
this is where I don't follow. I don't get how I should do to properly
update the value of a specific row.

I have an object for each job, and that object knows how far the job
has completed. My first thought was to have the job object signal the
tree view that it has new data and have it reload the model. However,
that means that I have to iterate through the rows and try to find the
correct row to update.

Another idea was to take a pointer to the row and pass it to the job
object. So now the job object will be able to update the row directly.
While this seams to work it is a bit odd to pass view objects to model
objects. It also complicates it if I want to have the same jobs
displayed in different tree views.

What is the appropriate way to update a tree view after it has been created?

John


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