Hi,

On Tue, 2010-09-14 at 17:48 +0200, Stephen Kelly wrote:
> Cornelius Hald wrote:
> 
> > Hi,
> > 
> > I've now managed to use my own data model together with a customized
> > QSortFilterProxyModel to provide sorting and searching for my QML UI. I
> > still have two open questions, though.
> > 
> > 1) Is there a way to animate sorting? I have animations for inserting
> > and removing data and they are also used when filtering (very nice). But
> > I would also like to give the user some feedback about changed sorting
> > as well.
> 
> Not in the current design of the QML model handling stuff because 
> QPersistentModelIndexes are not used by QML.

that's a pity, but I think I can give some other visual indicator just
to give the user feedback. Currently it's sometimes difficult so see
that the sorting has changed because it just happens too fast.

> How do you do animate the items in and out? Undocumented internals or some 
> other way?

Sorry, but I'm not exactly sure what you are asking. Are you asking how
I animate the inserts and removes? If yes, I'm using the attached
signals onAdd() and onRemove() of the ListView element. In my delegate I
react on those signals and make the delegates shrink/grow and fade
out/in. 

> > 2) In my proxy class I have to call beginResetModel() and
> > endResetModel() around my sorting code. Otherwise the QML ListView does
> > not update itself. Is this really needed? I thought the
> > QSortFilterProxyModel class would take care about that itself. Making
> > the filter work doesn't need these calls.
> > 
> > My code looks like this:
> > 
> > SortedModel::SortedModel(QObject *parent) :
> >     QSortFilterProxyModel(parent)
> > {
> > }
> > 
> > void SortedModel::sortBy(QString roleName)
> > {
> >     beginResetModel(); // Do I really need that?
> >     if (roleName == "name") {
> >         setSortRole(MyModel::NameRole);
> >     } else if (roleName == "description") {
> >         setSortRole(MyModel::DescriptionRole);
> >     }
> >     endResetModel();
> > }
> > 
> > void SortedModel::search(QString search)
> > {
> >     setFilterCaseSensitivity(Qt::CaseInsensitive);
> >     setFilterRole(MyModel::NameRole);
> >     setFilterWildcard(search);
> > }
> 
> Fixed in Qt 4.7.1.
> 
> http://bugreports.qt.nokia.com/browse/QTBUG-13146

Ah yes. Looks exactly like my problem. Thanks for the link.

Cheers,
Conny


_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to