Hi yall,
so I'm trying to do a mulltiple-field sort (i.e. first by surname then by name) and I've chosen to subclass the QSortFilterProxyModel.
I've subclassed it and reimplemented functions
Code:
    virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
    virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
Then my model is derived from a QAbstractListModel (I want to just keep the reference to a list being kept elsewhere)
so I reimplemented functions
Code:
    //basic function for a read-only model
    int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
    QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const ;
Then all this content is controlled in a custom list (the purpose is to add i.e. the kinetic scrolling with Flickable)
Code:
    class MyList : public QListView
and displayed in a custom delegate
Code:
    class MyDelegate : public QItemDelegate
In the constructor of the widget that holds that list (it's a central Widget) I do:
Code:
    m_listview = new MyList(this);
    m_listview->setStyle(new QWindowsStyle);
    m_listview->setAutoFillBackground(true);

    MyModel *model = new MyModel (dataArray, this);

    MySortProxyModel *proxy = new MySortProxyModel(this);
    proxy->setDynamicSortFilter(true);
    proxy->setSourceModel(model);
    m_listview->setModel(proxy);

    MyDelegate *delegate = new MyDelegate(this);
    m_listview->setItemDelegate(delegate);
Now the problem is that the list is not sorted, and I've debugged it to see that the function filterAcceptsRow is called but lessThan NOT!
I've tried to read the Qt source, but not much luck there as I get lost when some signal is fired.
Please help, I wonder where I missed some decoration to make it work properly...