Why when using Wt list models must you specify a column in the data
and index
methods?
The WAbstractListModel doc says, "An abstract list model specializes WAbstractItemModel for one-dimensional lists (i.e. a model with 1 column and no children)."
The WAbstractListModel::index
prototype is index (int row, int column, const WModelIndex &parent=WModelIndex())
. Wouldn't it make sense to also have index (int row, const WModelIndex &parent=WModelIndex())
?
The same situation is found in WStringListModel::data
, whose prototype is data (int row, int column, int role=DisplayRole, const WModelIndex &parent=WModelIndex())
? Wouldn't it make sense for WStringListModel (or any implementation of WAbstractListModel) to provide a method data (int row, int role=DisplayRole, const WModelIndex &parent=WModelIndex())
?
I realize that Wt is incomplete in many ways. Is the lack of a one-dimensional API for list models simply a result of that incompleteness? Or is there some conceptual reason to require specification of column numbers here?
WAbstractListModel doesn't add much (besides expressing intent).
The item models and views have been modelled after those in Qt, and are in most ways the same as those provided by Qt. See for example http://doc.qt.io/qt-5/qstringlistmodel.html
That Qt link shows that both of my suggestions are implemented there.
QAbstractListModel::index does not require you to specify a column:
QModelIndex QAbstractListModel::index(int row, int column = 0, const QModelIndex & parent = QModelIndex()) const
And, QStringListModel::data does not have a column parameter:
QVariant QStringListModel::data(const QModelIndex & index, int role) const
So, I'm chalking this up to "incompleteness."