*view & *doc relationship

Hauke Hildebrandt Hauke.Hildebrandt at iup.uni-heidelberg.de
Thu Apr 6 08:12:28 UTC 2000


Tim Rohrer wrote:
> 
> I'm fairly new to C++ and I've been working my way through the
> different tutorials with kdevelop (v1.1). The part I'm still confused on is
> the relationship between documents and views. I start a project with
> kde2 normal and I can modify the view class to be html (what I'm
> trying to test with) but I don't know what to do with the
> documentation. For the first experiment, I'm trying to create a
> simple browser. I've got it so I can get the html doc to show up in a
> window but not the main view.
> 
> I'm looking forward to help and anyone willing to work with me to get
> me up to speed. I am trying to develop printing abilities for labels,
> forms, addressbooks, etc. for kab2, etc.
> 
> Tks.
>   -tgr
> --
> Tim Rohrer
> tgrohrer at metbymail.com
> http://www.metbymail.com/~rohrer

Hi, Tim!

I have started working with C++ and kdevelop and - rest assured - the
document/view model was and still is confusing to me as well. The basic
idea
certainly is to separate the actual content of the document - text or
gif-files in your case - from their representation on the screen. So
your document class may contain a member variable of type QString
containing text or a list of pointers to gifs as well as methods for
saving and restoring this structure. The View class provides different
methods to show these contents on the screen - let' say a
"drawTextInCircularShape(const char* text)" function. You can open
different views of the same data with the document structure untouched -
e.g. a bar chart and a pie chart in the case of numerical data.

The point where I need help (and which could do with some examples in
the documentation) is: Let's say the App class has a menu entry to
change some data which opens a dialog. Who changes the document's data?
Do I hand over a pointer or reference of the doc's data to the dialog
which changes it? Does the dialog create some data and call a
"doc->changeData(float xyz)"? Who looks after the update of the view
after the data has been changed?

The doc-view model certainly has its merits, but it definitely
complicates matters, so please help us novices!

Thanks, Hauke
-- 
Hauke Hildebrandt
Institut für Umweltphysik
Universität Heidelberg
INF 229
69120 Heidelberg

Tel.: 06221/546318
Fax: 06221/546405

email: hauke.hildebrandt at iup.uni-heidelberg.de




More information about the KDevelop mailing list