I have made the following changes intended for : CE:MW:Shared / nemo-qml-plugins
Please review and accept or decline. BOSS has already run some checks on this request. See the "Messages from BOSS" section below. https://build.pub.meego.com//request/show/7483 Thank You, Islam Amer [This message was auto-generated] --- Request # 7483: Messages from BOSS: State: review at 2012-12-01T21:34:45 by bossbot Reviews: accepted by bossbot : Prechecks succeeded. new for CE-maintainers : Please replace this text with a review and approve/reject the review (not the SR). BOSS will take care of the rest Changes: submit: Project:MTF:MW / nemo-qml-plugins -> CE:MW:Shared / nemo-qml-plugins changes files: -------------- --- nemo-qml-plugins.changes +++ nemo-qml-plugins.changes @@ -0,0 +1,4 @@ +* Sat Dec 1 2012 Johan Paul <[email protected]> - 0.1.7 +- Add a filter property to SeasideProxyModel (by Chris Adams) +- Improve property-based filtering support in SeasideProxyModel (by Chris Adams) + old: ---- nemo-qml-plugins-0.1.6.tar.bz2 new: ---- nemo-qml-plugins-0.1.7.tar.bz2 spec files: ----------- --- nemo-qml-plugins.spec +++ nemo-qml-plugins.spec @@ -9,7 +9,7 @@ # << macros Summary: Nemo QML plugins source package. -Version: 0.1.6 +Version: 0.1.7 Release: 1 Group: System/Libraries License: BSD other changes: -------------- ++++++ nemo-qml-plugins-0.1.6.tar.bz2 -> nemo-qml-plugins-0.1.7.tar.bz2 --- contacts/src/seasidepeoplemodel.cpp +++ contacts/src/seasidepeoplemodel.cpp @@ -273,6 +273,11 @@ return vcard.fileName(); } +bool SeasidePeopleModel::populated() const +{ + return priv->memoryCachePopulated; +} + QContactManager *SeasidePeopleModel::manager() const { return priv->manager; --- contacts/src/seasidepeoplemodel.h +++ contacts/src/seasidepeoplemodel.h @@ -47,6 +47,7 @@ Q_OBJECT Q_ENUMS(PeopleRoles) Q_ENUMS(FilterRoles) + Q_PROPERTY(bool populated READ populated NOTIFY populatedChanged) public: SeasidePeopleModel(QObject *parent = 0); @@ -74,8 +75,13 @@ Q_INVOKABLE int importContacts(const QString &path); Q_INVOKABLE QString exportContacts() const; + bool populated() const; + QContactManager *manager() const; +Q_SIGNALS: + void populatedChanged(); + private: SeasidePeopleModelPriv *priv; friend class SeasidePeopleModelPriv; --- contacts/src/seasidepeoplemodel_p.cpp +++ contacts/src/seasidepeoplemodel_p.cpp @@ -45,6 +45,7 @@ SeasidePeopleModelPriv::SeasidePeopleModelPriv(SeasidePeopleModel *parent) : QObject(parent) , q(parent) + , memoryCachePopulated(false) { QContactSortOrder sort; sort.setDetailDefinitionName(QContactName::DefinitionName, QContactName::FieldFirstName); @@ -432,9 +433,11 @@ addContacts(contactsList, size); + memoryCachePopulated = true; q->endResetModel(); MODEL_DEBUG() << Q_FUNC_INFO << "Done with model reset"; fetchRequest->deleteLater(); + q->populatedChanged(); } --- contacts/src/seasidepeoplemodel_p.h +++ contacts/src/seasidepeoplemodel_p.h @@ -30,6 +30,7 @@ } SeasidePeopleModel *q; + bool memoryCachePopulated; QContactManager *manager; QContactFetchHint currentFetchHint; QList<QContactSortOrder> sortOrder; --- contacts/src/seasideproxymodel.cpp +++ contacts/src/seasideproxymodel.cpp @@ -18,9 +18,15 @@ class SeasideProxyModelPriv { public: + SeasideProxyModelPriv() + : componentComplete(false) + { + } + SeasideProxyModel::FilterType filterType; LocaleUtils *localeHelper; QString searchPattern; + bool componentComplete; }; SeasideProxyModel::SeasideProxyModel(QObject *parent) @@ -32,7 +38,6 @@ setDynamicSortFilter(true); setFilterKeyColumn(-1); - connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(countChanged())); @@ -41,9 +46,6 @@ connect(this, SIGNAL(layoutChanged()), SIGNAL(countChanged())); - - setSourceModel(SeasidePeopleModel::instance()); - sort(0, Qt::AscendingOrder); } SeasideProxyModel::~SeasideProxyModel() @@ -51,16 +53,63 @@ delete priv; } +void SeasideProxyModel::classBegin() +{ + priv->componentComplete = false; +} + +void SeasideProxyModel::componentComplete() +{ + priv->componentComplete = true; + + SeasidePeopleModel *sourceModel = SeasidePeopleModel::instance(); + setSourceModel(sourceModel); + sort(0, Qt::AscendingOrder); + + connect(sourceModel, SIGNAL(populatedChanged()), + this, SIGNAL(populatedChanged())); +} + +bool SeasideProxyModel::populated() const +{ + SeasidePeopleModel *model = static_cast<SeasidePeopleModel *>(sourceModel()); + if (model) + return model->populated(); + return false; +} + +SeasideProxyModel::FilterType SeasideProxyModel::filterType() const +{ + return priv->filterType; +} + void SeasideProxyModel::setFilter(FilterType filter) { - priv->filterType = filter; - invalidateFilter(); + if (filter != priv->filterType) { + priv->filterType = filter; + if (filter == FilterNone) + priv->searchPattern = QString(); + if (priv->componentComplete) + invalidateFilter(); + emit filterTypeChanged(); + if (filter == FilterNone) + emit filterPatternChanged(); + } +} + +QString SeasideProxyModel::filterPattern() const +{ + return priv->searchPattern; } -void SeasideProxyModel::search(const QString &pattern) +void SeasideProxyModel::setFilterPattern(const QString &pattern) { - priv->searchPattern = pattern; - invalidateFilter(); + if (pattern != priv->searchPattern) { + priv->searchPattern = pattern; + if (priv->componentComplete) + invalidateFilter(); + emit filterPatternChanged(); + } } bool SeasideProxyModel::personMatchesFilter(SeasidePerson *person, const QString &filter) @@ -122,6 +171,8 @@ } switch (priv->filterType) { + case FilterNone: + return false; case FilterAll: return true; case FilterFavorites: --- contacts/src/seasideproxymodel.h +++ contacts/src/seasideproxymodel.h @@ -12,11 +12,16 @@ #include <QSortFilterProxyModel> #include "seasidepeoplemodel.h" +#include <QDeclarativeParserStatus> + class SeasideProxyModelPriv; -class SeasideProxyModel : public QSortFilterProxyModel +class SeasideProxyModel : public QSortFilterProxyModel, public QDeclarativeParserStatus { Q_OBJECT + Q_PROPERTY(bool populated READ populated NOTIFY populatedChanged) + Q_PROPERTY(FilterType filterType READ filterType WRITE setFilter NOTIFY filterTypeChanged) + Q_PROPERTY(QString filterPattern READ filterPattern WRITE setFilterPattern NOTIFY filterPatternChanged) Q_ENUMS(FilterType) public: @@ -24,6 +29,7 @@ virtual ~SeasideProxyModel(); enum FilterType { + FilterNone, FilterAll, FilterFavorites, }; @@ -33,8 +39,16 @@ Secondary, }; + void classBegin(); + void componentComplete(); + + bool populated() const; + + FilterType filterType() const; Q_INVOKABLE virtual void setFilter(FilterType filter); - Q_INVOKABLE virtual void search(const QString &pattern); + QString filterPattern() const; + Q_INVOKABLE void setFilterPattern(const QString &pattern); + Q_INVOKABLE void search(const QString &pattern) { setFilterPattern(pattern); } // for SectionScroller support Q_INVOKABLE QVariantMap get(int row) const; @@ -81,7 +95,10 @@ int count() const; signals: + void populatedChanged(); void countChanged(); + void filterTypeChanged(); + void filterPatternChanged(); protected: virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; ++++++ nemo-qml-plugins.yaml --- nemo-qml-plugins.yaml +++ nemo-qml-plugins.yaml @@ -2,7 +2,7 @@ Summary: Nemo QML plugins source package. Group: System/Libraries Description: Do not install this, install the subpackaged plugins. -Version: 0.1.6 +Version: 0.1.7 Release: 1 Sources: - "%{name}-%{version}.tar.bz2"
