Open heltonbiker opened 8 years ago
The PyQt4.QtCore.QXmlStreamReader
class seems very promising to parse KML, specially after I discovered that libkml
uses ExPat, which is also a "handler-oriented" parser, and Marble uses exactely QXmlStreamReader to parse stuff, including KML.
The example here is killer, since it does exactely the desired mapping between xml and treeview, and back.
After a lot of reading, the two main sources of confusion are:
But most importantly, instead of adopting a big design up front, I think a better approach would be to use Incremental Development based on Acceptance Testing (ATDD). That would involve the following cycle:
That would probably require that the higher-level elements (Document, Folder) be implemented prior to the lower level, typically more deeply nested ones (Features, Geometries, etc.)
This is very interesting reading about the "conceptual gap" between QAbstractItemModel and QGraphicsScene:
https://invalidmagic.wordpress.com/2009/12/10/qgraphicsscene-used-as-a-qabstractitemmodel/
As I see it, a viable alternative would be to have one, yet-to-be-defined "MapModel", which in turn would contain one property of type QAbstractItemModel, and another of QGraphicsScene. Both would be bound to an underlying authoritative data-model, and manipulations would be somehow synchronized between both model structures - one for the TreeWidget, other for the GraphicsView.
Some information to possibly do that is available here:
http://doc.qt.io/qt-4.8/qt-itemviews-simpledommodel-example.html