2024-04-11 14:51:43 +08:00
|
|
|
#pragma once
|
2024-03-01 00:19:41 +08:00
|
|
|
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QtQml/qqml.h>
|
|
|
|
#include <QJSValue>
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
2024-04-11 14:51:43 +08:00
|
|
|
class FluTableSortProxyModel : public QSortFilterProxyModel {
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY_AUTO_P(QAbstractTableModel*, model)
|
2024-03-01 00:19:41 +08:00
|
|
|
QML_NAMED_ELEMENT(FluTableSortProxyModel)
|
|
|
|
public:
|
|
|
|
explicit FluTableSortProxyModel(QSortFilterProxyModel *parent = nullptr);
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-03-01 00:19:41 +08:00
|
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-03-01 00:19:41 +08:00
|
|
|
bool filterAcceptsColumn(int sourceColumn, const QModelIndex &sourceParent) const override;
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-03-01 00:19:41 +08:00
|
|
|
bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-04-11 19:18:37 +08:00
|
|
|
[[maybe_unused]] Q_INVOKABLE QVariant getRow(int rowIndex);
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-04-11 19:18:37 +08:00
|
|
|
[[maybe_unused]] Q_INVOKABLE void setRow(int rowIndex, const QVariant &val);
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-04-11 19:18:37 +08:00
|
|
|
[[maybe_unused]] Q_INVOKABLE void removeRow(int rowIndex, int rows);
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-04-11 19:18:37 +08:00
|
|
|
[[maybe_unused]] Q_INVOKABLE void setComparator(const QJSValue &comparator);
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-04-11 19:18:37 +08:00
|
|
|
[[maybe_unused]] Q_INVOKABLE void setFilter(const QJSValue &filter);
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-03-01 00:19:41 +08:00
|
|
|
private:
|
2024-03-01 23:24:03 +08:00
|
|
|
QJSValue _filter;
|
2024-03-01 00:19:41 +08:00
|
|
|
QJSValue _comparator;
|
2024-04-11 19:18:37 +08:00
|
|
|
};
|