Jump to content

Marble/ModelView: Difference between revisions

From KDE Community Wiki
Tgridel (talk | contribs)
No edit summary
Ochurlaud (talk | contribs)
m 10 revisions imported
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== ModelView framework in Marble ==
= ModelView framework in Marble =


Marble uses Qt's Model/View framework as a way to signal updates in a model to interested parts. In that respect, a Model class can wrap any possible data.
Marble uses Qt's Model/View framework as a way to signal updates to a model to interested parts. In that respect, a Model class can wrap any possible data.


Here is the list of Model classes, and a description of how they are used.
The Model-View framework is designed to hide the details of the model content, and to present it in a standardised way to views. The advantage of this solution is that the View need not know much about the data it presents.


=== QAbstractItemModel ===
The multiple models and proxies in Marble each fit the purpose of feeding some GeoData classes to interested widgets. Those models are fed by the {{class|FileManager|kdeedu|4.x}}.
* {{class|GeoDataDebugModel|kdeedu|4.x}}
It represents the tree of {{class|GeoDataObject|kdeedu|4.x}} elements corresponding to a {{class|GeoDataDocument|kdeedu|4.x}}.


It is used by the {{class|DataViewPlugin|kdeedu|4.x}} debug plugin (and is broken atm).
Here is the list of Model and Proxy classes, and a description of how they are used.


* {{class|GpxFileModel|kdeedu|4.x}}
=== GeoDataTreeModel ===
It represents a list of gpx data files represented as {{class|GpxFile|kdeedu|4.x}}
The {{class|GeoDataTreeModel|kdeedu|4.x}} represents the list of all {{class|GeoDataDocument|kdeedu|4.x}} registered through the {{class|FileManager|kdeedu|4.x}}.


This was originally intended to but used as the model for the File List View ( which is accessible by running marble with --enableFileView ) but has since been replaced by the FileViewModel.
It has signals/slots to react to files being added or removed in the FileManager.


The model is used as a member in the GpsLayer to hold the list of gpx files as a collection class and is deprecated. This, along with the whole current GPX implementation, needs to be removed and updated to the current concepts in Marble. See [[Projects/Marble/GPXStatus|Gpx Status]]
It is used as the base model for GeoDataDocuments.


* {{class|MarbleGeometryModel|kdeedu|4.x}}
The {{class|GeometryLayer|kdeedu|4.x}} renders all {{class|GeoDataGeometry|kdeedu|4.x}} related placemarks.
It represents the {{class|GeoDataGeometry|kdeedu}} and the {{class|GeoDataFeature|kdeedu|4.x}} items of the last opened {{class|GeoDataDocument|kdeedu|4.x}}.


It is used by the {{class|GeoRenderPlugin|kdeedu|4.x}} to access the list of vector data and draw it.
=== FileViewModel ===
The {{class|FileViewModel|kdeedu|4.x}} represents the list of opened files. The {{class|FileManager|kdeedu|4.x}} appends the documents it opens.
It is used by the {{class|FileViewFloatItem|kdeedu|4.x}}.


=== QAbstractListModel ===
=== KDescendantsProxyModel ===
* {{class|FileViewModel|kdeedu|4.x}}
The {{class|KDescendantsProxyModel|kdeedu|4.x}} is used to flatten the tree of GeoData features. It represents the list of all Placemarks of all opened files.
It represents the list of opened files. The {{class|FileManager|kdeedu|4.x}} signals it about the documents it opens or closes.


It is used by the {{class|FileViewFloatItem|kdeedu|4.x}} and by a List widget in the {{class|MarbleControlBox|kdeedu|4.X}}.
The {{class|MarbleControlBox|kdeedu|4.X}} uses that proxy model to provide the list of placemarks to search for, and the {{class|PlacemarkLayout|kdeedu|4.x}} uses it also to determine layouting on the map.
 
* {{class|MarbleGeoDataModel|kdeedu|4.x}}
It represents a list of {{class|GeoDataDocuments|kdeedu|4.x}}. Only the {{class|PlacemarksPlugin|kdeedu|4.x}} uses it.
 
It is used by no other code.
 
* {{class|MarblePlacemarkModel|kdeedu|4.x}}
It represents a list of Placemarks.
 
The {{class|PlaceMarkManager|kdeedu|4.x}} appends all the placemarks contained in the {{class|GeoDataDocument|kdeedu|4.x}} it knows about in its instance.
 
The {{class|MarbleRunnerManager|kdeedu|4.x}} appends the list of placemarks that the Runners found in its instance.
 
It is used by the {{class|MarbleControlBox|kdeedu|4.X}} to provide a list of placemarks (either from the PlacemarkManager or from the MarbleRunnerManager).
 
It is also used by the {{class|PlacemarkLayout|kdeedu|4.x}} to determine layouting on the map.

Latest revision as of 08:05, 21 October 2016

ModelView framework in Marble

Marble uses Qt's Model/View framework as a way to signal updates to a model to interested parts. In that respect, a Model class can wrap any possible data.

The Model-View framework is designed to hide the details of the model content, and to present it in a standardised way to views. The advantage of this solution is that the View need not know much about the data it presents.

The multiple models and proxies in Marble each fit the purpose of feeding some GeoData classes to interested widgets. Those models are fed by the FileManager.

Here is the list of Model and Proxy classes, and a description of how they are used.

GeoDataTreeModel

The GeoDataTreeModel represents the list of all GeoDataDocument registered through the FileManager.

It has signals/slots to react to files being added or removed in the FileManager.

It is used as the base model for GeoDataDocuments.

The GeometryLayer renders all GeoDataGeometry related placemarks.

FileViewModel

The FileViewModel represents the list of opened files. The FileManager appends the documents it opens. It is used by the FileViewFloatItem.

KDescendantsProxyModel

The KDescendantsProxyModel is used to flatten the tree of GeoData features. It represents the list of all Placemarks of all opened files.

The MarbleControlBox uses that proxy model to provide the list of placemarks to search for, and the PlacemarkLayout uses it also to determine layouting on the map.