If you could change the Drag'n'Drop API in QAbstractItemModel, what would you do?
-
Hi all,
I'm looking into implementing drag'n'drop defaults and customization points in
QRangeModel. In the spirit ofQRangeModel, the logic to "do stuff with data" should be close to the data type, rather than land in a subclass ofQRangeModel.Drag'n'drop in QAIM manifests itself in 4 virtual functions:
QStringList mimeTypes()returns a list of mime types that the model can "work with" in both directionsQMimeDate *mimeData(const QModelIndexList &indexes) constencodes the data atindexesinto one, some, or all of themimeTypes- that's up to the modelbool canDropMimeData(data, action, row, column, parent)anddropMimeData(..)then handle the drop into a specific location, the interpretation of which is documented convention rather than an enforced rule
In addition there are relevant flags in
Qt::ItemFlags, and then of course the interaction with the views, which is not relevant for this work (or at least out of scope for now).If you have overridden those APIs for your own models, what did you find difficult, what did you find most limiting, and what stood out as straight forward and easy to do?
Customization of
QRangeModelis done by specialising theQRangeModel::RowOptionsand/orQRangeModel::ItemAccesstemplates for your own row- and item- types. So we have some flexibility to come up with a better set of APIs, as long as we can map the 4 virtual functions to whatever we end up with.Drop a comment here or at https://qt-project.atlassian.net/browse/QTBUG-145800
Cheers,
Volker