KDialog + KPage* d-ptr cleanup and fixes

Matthias Kretz kretz at kde.org
Sat Jun 23 09:36:23 BST 2007


On Saturday 23 June 2007, Tobias Koenig wrote:
> > - KPageView::setModel()/::model() use a QAbstractItemModel* instead of
> > KPageModel* now since otherwise you cannot use any of the Qt interview
> > convenience classes with KPageView. KPageModel only adds two enum values
> > to QAbstractItemModel.
>
> It adds two new ModelRoles which are required by KPageView to work
> correctly. If you pass a normal QAbstractItemModel based model (e.g.
> QStringListModel), KPageView wouldn't work at all, maybe even crash.
> So passing a QAbstractItemModel here is against the design of the
> KPageView, please don't commit this part of your change!

1. Taking KPageModel as base class to implement your model makes 0 difference 
compared to using QAbstractItemModel as inheriting KPageModel does not force 
you to return something valid for the two new roles in data(), flags() and so 
on.

2. If you implement a custom model (not using KPageWidgetModel) then it is 
often helpful to use a specialized model class from Qt and go from there: 
less work, less errors. By restricting the API to KPageModel* you disallow 
that (yes I know it's still possible to reinterpret_cast<KPageModel 
*>(static_cast<QAbstractItemModel *>(myModel)), but we really don't want to 
make developers write such code).
A valid use case would be to e.g. use KPageWidgetModel but pass 
QSortFilterProxyModel to KPageView.

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070623/eb238376/attachment.sig>


More information about the kde-core-devel mailing list