Add notify signals for SortFilterModel.sourceModel and filterRegExp

This commit is contained in:
Aurélien Gâteau 2012-08-28 11:42:56 +02:00
parent 115aab2242
commit 91313b5eb5
2 changed files with 8 additions and 2 deletions

View File

@ -75,6 +75,7 @@ void SortFilterModel::setModel(QObject *source)
connect(model, SIGNAL(modelReset()), this, SLOT(syncRoleNames())); connect(model, SIGNAL(modelReset()), this, SLOT(syncRoleNames()));
QSortFilterProxyModel::setSourceModel(model); QSortFilterProxyModel::setSourceModel(model);
sourceModelChanged(model);
} }
@ -83,6 +84,7 @@ void SortFilterModel::setModel(QObject *source)
void SortFilterModel::setFilterRegExp(const QString &exp) void SortFilterModel::setFilterRegExp(const QString &exp)
{ {
QSortFilterProxyModel::setFilterRegExp(QRegExp(exp, Qt::CaseInsensitive)); QSortFilterProxyModel::setFilterRegExp(QRegExp(exp, Qt::CaseInsensitive));
filterRegExpChanged(exp);
} }
QString SortFilterModel::filterRegExp() const QString SortFilterModel::filterRegExp() const

View File

@ -41,12 +41,12 @@ class SortFilterModel : public QSortFilterProxyModel
/** /**
* The source model of this sorting proxy model. It has to inherit QAbstractItemModel (ListModel is not supported) * The source model of this sorting proxy model. It has to inherit QAbstractItemModel (ListModel is not supported)
*/ */
Q_PROPERTY(QObject *sourceModel READ sourceModel WRITE setModel) Q_PROPERTY(QObject *sourceModel READ sourceModel WRITE setModel NOTIFY sourceModelChanged)
/** /**
* The regular expression for the filter, only items with their filterRole matching filterRegExp will be displayed * The regular expression for the filter, only items with their filterRole matching filterRegExp will be displayed
*/ */
Q_PROPERTY(QString filterRegExp READ filterRegExp WRITE setFilterRegExp) Q_PROPERTY(QString filterRegExp READ filterRegExp WRITE setFilterRegExp NOTIFY filterRegExpChanged)
/** /**
* The role of the sourceModel on which filterRegExp must be applied. * The role of the sourceModel on which filterRegExp must be applied.
@ -105,6 +105,8 @@ public:
Q_SIGNALS: Q_SIGNALS:
void countChanged(); void countChanged();
void sourceModelChanged(QObject *);
void filterRegExpChanged(const QString &);
protected: protected:
int roleNameToId(const QString &name); int roleNameToId(const QString &name);
@ -191,6 +193,8 @@ protected:
Q_SIGNALS: Q_SIGNALS:
void countChanged(); void countChanged();
void sourceModelChanged(QObject *);
void filterRegExpChanged(const QString &);
private Q_SLOTS: private Q_SLOTS:
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);