Skip to content

Commit

Permalink
Update ProxyModelRohstoff
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgeoisLab committed Apr 12, 2024
1 parent 0f9ddeb commit 9466ca5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 7 additions & 0 deletions kleiner-brauhelfer-core/proxymodelrohstoff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void ProxyModelRohstoff::setFilter(Filter value)
if (mFilter != value)
{
mFilter = value;
emit filterChanged(mFilter);
invalidateRowsFilter();
}
}
Expand All @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions kleiner-brauhelfer-core/proxymodelrohstoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions kleiner-brauhelfer-core/proxymodelsud.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9466ca5

Please sign in to comment.