model/view design question

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

model/view design question

John W. Eaton
Administrator
I noticed that in most cases where we are using model/view programming,
we store the model and view objects together in the same class.  For
example, our files_dock_widget class owns a QFileSystemModel object and
a QTreeView object.  But the the workspace_view class (also a dock
widget) only owns a QTableView object and the corresponding model
objects is owned by the main_window class.  Is there a reason for this
difference?

Given that there could be multiple view objects that use the same model,
maybe they should not be owned by the same parent object?  But if not,
then who should own the model data (or at least the model objects that
can access the data from the interpreter)?

Maybe these model classes should be stored in the gui application object
or the QObject adapter class that manages the Octave interpreter?  Then
any number of views could (in theory, anyway) be attached to them and
the would be independent of any one particular view.

OTOH, if we know that we will only ever have one view of these models,
then it might be simpler to package them together?

Either way, it seems like it would be good to fix things so that we are
doing things consistently for all these model/view classes.

Comments and suggestions welcome.

jwe