diff --git a/kleiner-brauhelfer-core/proxymodelrohstoff.cpp b/kleiner-brauhelfer-core/proxymodelrohstoff.cpp index d5476e3..db5db0b 100644 --- a/kleiner-brauhelfer-core/proxymodelrohstoff.cpp +++ b/kleiner-brauhelfer-core/proxymodelrohstoff.cpp @@ -45,6 +45,7 @@ void ProxyModelRohstoff::setFilter(Filter value) if (mFilter != value) { mFilter = value; + emit filterChanged(mFilter); invalidateRowsFilter(); } } @@ -58,6 +59,12 @@ bool ProxyModelRohstoff::filterAcceptsRow(int source_row, const QModelIndex &sou if (index.isValid()) accept = sourceModel()->data(index).toDouble() > 0.0; } + if (accept && mFilter == Filter::NichtVorhanden) + { + QModelIndex index = sourceModel()->index(source_row, mAmountColumn, source_parent); + if (index.isValid()) + accept = sourceModel()->data(index).toDouble() <= 0.0; + } if (accept && mFilter == Filter::InGebrauch) { QModelIndex index = sourceModel()->index(source_row, mInUsedColumn, source_parent); diff --git a/kleiner-brauhelfer-core/proxymodelrohstoff.h b/kleiner-brauhelfer-core/proxymodelrohstoff.h index 5ba5e80..65345be 100644 --- a/kleiner-brauhelfer-core/proxymodelrohstoff.h +++ b/kleiner-brauhelfer-core/proxymodelrohstoff.h @@ -8,24 +8,28 @@ class LIB_EXPORT ProxyModelRohstoff : public ProxyModel { Q_OBJECT - #if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) - Q_PROPERTY(Filter filter READ filter WRITE setFilter NOTIFY layoutChanged) - #endif + Q_PROPERTY(Filter filter READ filter WRITE setFilter NOTIFY filterChanged) public: enum Filter { Alle, Vorhanden, - InGebrauch + InGebrauch, + NichtVorhanden }; Q_ENUM(Filter) public: ProxyModelRohstoff(QObject* parent = nullptr); Filter filter() const; + +public slots: void setFilter(Filter value); +signals: + void filterChanged(Filter value); + protected: bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const Q_DECL_OVERRIDE; diff --git a/kleiner-brauhelfer-core/proxymodelsud.h b/kleiner-brauhelfer-core/proxymodelsud.h index b5c368f..c6401c4 100644 --- a/kleiner-brauhelfer-core/proxymodelsud.h +++ b/kleiner-brauhelfer-core/proxymodelsud.h @@ -10,13 +10,11 @@ class LIB_EXPORT ProxyModelSud : public ProxyModel { Q_OBJECT - #if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) Q_PROPERTY(bool filterMerkliste READ filterMerkliste WRITE setFilterMerkliste NOTIFY layoutChanged) Q_PROPERTY(FilterStatus filterStatus READ filterStatus WRITE setFilterStatus NOTIFY layoutChanged) Q_PROPERTY(QDateTime minDate READ filterMinimumDate WRITE setFilterMinimumDate NOTIFY layoutChanged) Q_PROPERTY(QDateTime maxDate READ filterMaximumDate WRITE setFilterMaximumDate NOTIFY layoutChanged) Q_PROPERTY(QString filterText READ filterText WRITE setFilterText NOTIFY layoutChanged) - #endif public: enum FilterStatusPart