Page MenuHomePhabricator

Implement base class for DataStorageViewer
Closed, ResolvedPublic

Description

As a basis for T23296 we need to implement a base widget that can be used to implement different views on the data storage.
Such a base widget (DataStorageViewer) should have access to the data storage. It should be possible to filter the nodes in the data storage (using node predicates).

The idea is to allow developers to create their own concrete data storage view widget, without having to manage data storage node events or model selection events etc. The developer should only customize the view by providing a QtAbstractItemView and a QtAbstractItemModel.
The base class provides functions that are called on data storage node events and transforms model selection events into a list of currently selected data nodes.
The base class provides a signal / slot mechanism to send / receive selected data nodes to / from its local workbench view.

Revisions and Commits

Event Timeline

Regarding a different use of this class:
Currently we want to use this AbstractDataStorageViewer as a class, that takes a view and a model from the developer and connects the signals and slots in a way, that selections of the view are correctly set from outside or propagated outwards. Additionally the AbstractDataStorageViewer is used to connect the Node-events from the DataStorage to member functions.
However, these member functions do not provide any implementation as the developer of a concrete DataStorageViewer should be free to implement the desired behavior.

This leaves me thinking about the responsibility and use of this AbstractDataStorageViewer.
It could be split up into two classes, one that connects a given model with the events from the data storage (needed to update the model information when something in the data storage changed). The second class is a connector for the selections (send and receive). Both classes could be used in a way, that the view/model and the data storage / node predicate is given to the classes, but a custom data storage viewer only needs to know about these two classes.
There is no need for subclassing. A custom data storage viewer that subclasses the AbstractDataStorageViewer (as it is intended now) has to define the model/view to be used anyway (and thus customize the viewer) and then add the qt-view to its layout or the like.

kalali raised the priority of this task from Wishlist to Normal.Dec 21 2017, 1:21 PM

I changed the design:
We now provide a QmitkAbstractDataStorageModel that needs to be sub-classed for a custom model. The abstract model already connects the data storage node events (add, remove, change) with protected pure virtual functions.
These functions have to be overwritten in the derived model class to provide a custom behavior.
It furthermore accepts a node predicate to filter the nodes in the data storage.

This still fits the task's description. However, we do not provide a full widget anymore, but rather define the base model to be used for this scenario. The developer can still define it's view and customize the base model to his or her needs.

However, the handling of the model selections are moved to the QmitkModelViewSelectionConnector-class (see new modifications in T23752).

kalali added a revision: Restricted Differential Revision.Jan 12 2018, 6:24 PM