mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-04 18:17:27 -04:00
History: replace payment id search with global incremental search
This commit is contained in:
@@ -42,6 +42,20 @@ TransactionHistorySortFilterModel::TransactionHistorySortFilterModel(QObject *pa
|
||||
setDynamicSortFilter(true);
|
||||
}
|
||||
|
||||
QString TransactionHistorySortFilterModel::searchFilter() const
|
||||
{
|
||||
return m_searchString;
|
||||
}
|
||||
|
||||
void TransactionHistorySortFilterModel::setSearchFilter(const QString &arg)
|
||||
{
|
||||
if (searchFilter() != arg) {
|
||||
m_searchString = arg;
|
||||
emit searchFilterChanged();
|
||||
invalidateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
QString TransactionHistorySortFilterModel::paymentIdFilter() const
|
||||
{
|
||||
return m_filterValues.value(TransactionHistoryModel::TransactionPaymentIdRole).toString();
|
||||
@@ -200,7 +214,32 @@ bool TransactionHistorySortFilterModel::filterAcceptsRow(int source_row, const Q
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
if (!result || m_searchString.isEmpty())
|
||||
return result;
|
||||
|
||||
QVariant data = sourceModel()->data(index, TransactionHistoryModel::TransactionPaymentIdRole);
|
||||
if (data.toString().contains(m_searchString))
|
||||
return true;
|
||||
data = sourceModel()->data(index, TransactionHistoryModel::TransactionDisplayAmountRole);
|
||||
if (data.toString().contains(m_searchString))
|
||||
return true;
|
||||
data = sourceModel()->data(index, TransactionHistoryModel::TransactionBlockHeightRole);
|
||||
if (data.toString().contains(m_searchString))
|
||||
return true;
|
||||
data = sourceModel()->data(index, TransactionHistoryModel::TransactionFeeRole);
|
||||
if (data.toString().contains(m_searchString))
|
||||
return true;
|
||||
data = sourceModel()->data(index, TransactionHistoryModel::TransactionHashRole);
|
||||
if (data.toString().contains(m_searchString))
|
||||
return true;
|
||||
data = sourceModel()->data(index, TransactionHistoryModel::TransactionDateRole);
|
||||
if (data.toString().contains(m_searchString))
|
||||
return true;
|
||||
data = sourceModel()->data(index, TransactionHistoryModel::TransactionTimeRole);
|
||||
if (data.toString().contains(m_searchString))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TransactionHistorySortFilterModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
|
||||
@@ -14,6 +14,7 @@ class TransactionHistory;
|
||||
class TransactionHistorySortFilterModel: public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString searchFilter READ searchFilter WRITE setSearchFilter NOTIFY searchFilterChanged)
|
||||
Q_PROPERTY(QString paymentIdFilter READ paymentIdFilter WRITE setPaymentIdFilter NOTIFY paymentIdFilterChanged)
|
||||
Q_PROPERTY(QDate dateFromFilter READ dateFromFilter WRITE setDateFromFilter NOTIFY dateFromFilterChanged)
|
||||
Q_PROPERTY(QDate dateToFilter READ dateToFilter WRITE setDateToFilter NOTIFY dateToFilterChanged)
|
||||
@@ -25,6 +26,10 @@ class TransactionHistorySortFilterModel: public QSortFilterProxyModel
|
||||
|
||||
public:
|
||||
TransactionHistorySortFilterModel(QObject * parent = nullptr);
|
||||
//! filtering by string search
|
||||
QString searchFilter() const;
|
||||
void setSearchFilter(const QString &arg);
|
||||
|
||||
//! filtering by payment id
|
||||
QString paymentIdFilter() const;
|
||||
void setPaymentIdFilter(const QString &arg);
|
||||
@@ -53,6 +58,7 @@ public:
|
||||
TransactionHistory * transactionHistory() const;
|
||||
|
||||
signals:
|
||||
void searchFilterChanged();
|
||||
void paymentIdFilterChanged();
|
||||
void dateFromFilterChanged();
|
||||
void dateToFilterChanged();
|
||||
@@ -74,6 +80,7 @@ private:
|
||||
|
||||
private:
|
||||
QMap<int, QVariant> m_filterValues;
|
||||
QString m_searchString;
|
||||
};
|
||||
|
||||
#endif // TRANSACTIONHISTORYSORTFILTERMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user