This project implements a automate editor using Qt 4. One point of particular interest is the code for the graphical view of an automate.

Why, you may ask. That is because the view is a QGraphicsScene but this QGraphicsScene is implemented in a way that it can be used as a QAbstractItemView.

The Qt docs say:

QAbstractItemView class is the base class for every standard view that uses a QAbstractItemModel. QAbstractItemView is an abstract class and cannot itself be instantiated. It provides a standard interface for interoperating with models through the signals and slots mechanism, enabling subclasses to be kept up-to-date with changes to their models. This class provides standard support for keyboard and mouse navigation, viewport scrolling, item editing, and selections.

what is special about this?

the code uses a QGraphicsScene on top of an QAbstractItemModel (in form of a QAbstractItemView). objects which are in my case 'nodes' and 'connections' are represented by the model. however to draw a connection in the QGraphicsScene/QGraphicsView we have to maintain two objects (start and end) and the code mentioned above handles this transparently. it even delegates changes to node names through the model (best use of model/view/controller mvc).

The best idea is to visualize the class dependencies by a graph:

graphicssceneasabstractitemview.png http://lastlog.de/misc/graphicssceneasabstractitemview.odt

In this graph one can see several things:

  • my used class names and from where they inherit as 'graphicsView : AbstractView'
  • in which hierarchy level what 'primary' object type is used for representation of the structure (text in red)
  • the basic concept of how the classes are organized

In general:

  • the shortcuts are handled by the GraphicsScene class
  • the toolbar is handled by the GraphicsView class

Back when i created the classes i tried to give them a semantic name. The GraphicsView is on of two view classes in my project and one can use several views editing the same automate. For instance 1graphicsView and 2treeViews (of which are all inheriting AbstractView).

see: http://lastlog.de/misc/repository1/automate/doxygen/html/classgraphicsView.html

a screenshot

graphicsView18.jpg

This picture features the 'pelican' automate.

code

http://github.com/qknight/automate

doxygen documentation

there is no online doxygen documentation right now. clone the repository and run doxygen yourself. to give you a brief overview hat this all is about, you can read this (outdated build)

http://lastlog.de/misc/repository1/automate/doxygen/html/

Powered by MediaWiki