feat(StatusQ): custom UndefinedFilter filter for filtering undefined role values

Generic filter for handling undefined values. This kind of filtering
cannot be done using ValueFilter. On the other hand using
FastExpressionFilter is much more costy in terms of performance
overhead.

Closes: #13638
This commit is contained in:
Michał Cieślak 2024-02-20 14:02:36 +01:00 committed by Michał
parent ac266bb997
commit 29c15a5bff
4 changed files with 32 additions and 1 deletions

View File

@ -111,6 +111,7 @@ add_library(StatusQ SHARED
include/StatusQ/stringutilsinternal.h
include/StatusQ/submodelproxymodel.h
include/StatusQ/sumaggregator.h
include/StatusQ/undefinedfilter.h
include/StatusQ/writableproxymodel.h
src/QClipboardProxy.cpp
src/aggregator.cpp
@ -132,6 +133,7 @@ add_library(StatusQ SHARED
src/stringutilsinternal.cpp
src/submodelproxymodel.cpp
src/sumaggregator.cpp
src/undefinedfilter.cpp
src/writableproxymodel.cpp
# wallet

View File

@ -0,0 +1,16 @@
#pragma once
#include <filters/rolefilter.h>
class UndefinedFilter : public qqsfpm::RoleFilter
{
Q_OBJECT
public:
using RoleFilter::RoleFilter;
protected:
bool filterRow(
const QModelIndex &sourceIndex,
const qqsfpm::QQmlSortFilterProxyModel& proxyModel) const override;
};

View File

@ -8,6 +8,7 @@
#include "StatusQ/fastexpressionfilter.h"
#include "StatusQ/fastexpressionrole.h"
#include "StatusQ/fastexpressionsorter.h"
#include "StatusQ/formatteddoubleproperty.h"
#include "StatusQ/leftjoinmodel.h"
#include "StatusQ/modelutilsinternal.h"
#include "StatusQ/movablemodel.h"
@ -19,8 +20,8 @@
#include "StatusQ/stringutilsinternal.h"
#include "StatusQ/submodelproxymodel.h"
#include "StatusQ/sumaggregator.h"
#include "StatusQ/undefinedfilter.h"
#include "StatusQ/writableproxymodel.h"
#include "StatusQ/formatteddoubleproperty.h"
#include "wallet/managetokenscontroller.h"
#include "wallet/managetokensmodel.h"
@ -48,6 +49,7 @@ public:
qmlRegisterType<FastExpressionFilter>("StatusQ", 0, 1, "FastExpressionFilter");
qmlRegisterType<FastExpressionRole>("StatusQ", 0, 1, "FastExpressionRole");
qmlRegisterType<FastExpressionSorter>("StatusQ", 0, 1, "FastExpressionSorter");
qmlRegisterType<UndefinedFilter>("StatusQ", 0, 1, "UndefinedFilter");
qmlRegisterType<LeftJoinModel>("StatusQ", 0, 1, "LeftJoinModel");
qmlRegisterType<SubmodelProxyModel>("StatusQ", 0, 1, "SubmodelProxyModel");

View File

@ -0,0 +1,11 @@
#include "StatusQ/undefinedfilter.h"
#include <qqmlsortfilterproxymodel.h>
using namespace qqsfpm;
bool UndefinedFilter::filterRow(const QModelIndex& sourceIndex,
const QQmlSortFilterProxyModel& proxyModel) const
{
return !sourceData(sourceIndex, proxyModel).isValid();
}