mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-04-01 03:39:06 +00:00
History: replace payment id search with global incremental search
This commit is contained in:
parent
c83336cc47
commit
78da2b5b1b
3 changed files with 60 additions and 18 deletions
|
@ -170,34 +170,32 @@ Rectangle {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Filter by Payment ID input
|
// Filter by string
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: paymentIdLabel
|
id: searchLabel
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: filterHeaderText.bottom // addressLine.bottom
|
anchors.top: filterHeaderText.bottom // addressLine.bottom
|
||||||
anchors.leftMargin: 17
|
anchors.leftMargin: 17
|
||||||
anchors.topMargin: 17
|
anchors.topMargin: 17
|
||||||
text: qsTr("Payment ID <font size='2'>(Optional)</font>") + translationManager.emptyString
|
text: qsTr("Incremental search") + translationManager.emptyString
|
||||||
fontSize: 14
|
fontSize: 14
|
||||||
tipText: qsTr("<b>Payment ID</b><br/><br/>A unique user name used in<br/>the address book. It is not a<br/>transfer of information sent<br/>during thevtransfer")
|
tipText: qsTr("Search transfers for a given string") + translationManager.emptyString
|
||||||
+ translationManager.emptyString
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LineEdit {
|
LineEdit {
|
||||||
id: paymentIdLine
|
id: searchLine
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: paymentIdLabel.bottom // addressLabel.bottom
|
anchors.top: searchLabel.bottom // addressLabel.bottom
|
||||||
anchors.leftMargin: 17
|
anchors.leftMargin: 17
|
||||||
anchors.rightMargin: 17
|
anchors.rightMargin: 17
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString
|
placeholderText: qsTr("Type search string") + translationManager.emptyString
|
||||||
validator: RegExpValidator {
|
onTextChanged: {
|
||||||
regExp: /[0-9a-fA-F]+/
|
model.searchFilter = searchLine.text
|
||||||
|
selectedAmount.text = getSelectedAmount()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by description input (not implemented yet)
|
// Filter by description input (not implemented yet)
|
||||||
|
@ -205,7 +203,7 @@ Rectangle {
|
||||||
Label {
|
Label {
|
||||||
id: descriptionLabel
|
id: descriptionLabel
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: paymentIdLine.bottom
|
anchors.top: searchLine.bottom
|
||||||
anchors.leftMargin: 17
|
anchors.leftMargin: 17
|
||||||
anchors.topMargin: 17
|
anchors.topMargin: 17
|
||||||
text: qsTr("Description <font size='2'>(Local database)</font>") + translationManager.emptyString
|
text: qsTr("Description <font size='2'>(Local database)</font>") + translationManager.emptyString
|
||||||
|
@ -229,7 +227,7 @@ Rectangle {
|
||||||
Label {
|
Label {
|
||||||
id: dateFromText
|
id: dateFromText
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: paymentIdLine.bottom // descriptionLine.bottom
|
anchors.top: searchLine.bottom // descriptionLine.bottom
|
||||||
anchors.leftMargin: 17
|
anchors.leftMargin: 17
|
||||||
anchors.topMargin: 17
|
anchors.topMargin: 17
|
||||||
width: 156
|
width: 156
|
||||||
|
@ -255,7 +253,7 @@ Rectangle {
|
||||||
Label {
|
Label {
|
||||||
id: dateToText
|
id: dateToText
|
||||||
anchors.left: dateFromText.right
|
anchors.left: dateFromText.right
|
||||||
anchors.top: paymentIdLine.bottom //descriptionLine.bottom
|
anchors.top: searchLine.bottom //descriptionLine.bottom
|
||||||
anchors.leftMargin: 17
|
anchors.leftMargin: 17
|
||||||
anchors.topMargin: 17
|
anchors.topMargin: 17
|
||||||
text: qsTr("To")
|
text: qsTr("To")
|
||||||
|
@ -292,8 +290,6 @@ Rectangle {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// Apply filter here;
|
// Apply filter here;
|
||||||
|
|
||||||
model.paymentIdFilter = paymentIdLine.text
|
|
||||||
|
|
||||||
resetFilter(model)
|
resetFilter(model)
|
||||||
|
|
||||||
if (fromDatePicker.currentDate > toDatePicker.currentDate) {
|
if (fromDatePicker.currentDate > toDatePicker.currentDate) {
|
||||||
|
|
|
@ -42,6 +42,20 @@ TransactionHistorySortFilterModel::TransactionHistorySortFilterModel(QObject *pa
|
||||||
setDynamicSortFilter(true);
|
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
|
QString TransactionHistorySortFilterModel::paymentIdFilter() const
|
||||||
{
|
{
|
||||||
return m_filterValues.value(TransactionHistoryModel::TransactionPaymentIdRole).toString();
|
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
|
bool TransactionHistorySortFilterModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||||
|
|
|
@ -14,6 +14,7 @@ class TransactionHistory;
|
||||||
class TransactionHistorySortFilterModel: public QSortFilterProxyModel
|
class TransactionHistorySortFilterModel: public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString searchFilter READ searchFilter WRITE setSearchFilter NOTIFY searchFilterChanged)
|
||||||
Q_PROPERTY(QString paymentIdFilter READ paymentIdFilter WRITE setPaymentIdFilter NOTIFY paymentIdFilterChanged)
|
Q_PROPERTY(QString paymentIdFilter READ paymentIdFilter WRITE setPaymentIdFilter NOTIFY paymentIdFilterChanged)
|
||||||
Q_PROPERTY(QDate dateFromFilter READ dateFromFilter WRITE setDateFromFilter NOTIFY dateFromFilterChanged)
|
Q_PROPERTY(QDate dateFromFilter READ dateFromFilter WRITE setDateFromFilter NOTIFY dateFromFilterChanged)
|
||||||
Q_PROPERTY(QDate dateToFilter READ dateToFilter WRITE setDateToFilter NOTIFY dateToFilterChanged)
|
Q_PROPERTY(QDate dateToFilter READ dateToFilter WRITE setDateToFilter NOTIFY dateToFilterChanged)
|
||||||
|
@ -25,6 +26,10 @@ class TransactionHistorySortFilterModel: public QSortFilterProxyModel
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransactionHistorySortFilterModel(QObject * parent = nullptr);
|
TransactionHistorySortFilterModel(QObject * parent = nullptr);
|
||||||
|
//! filtering by string search
|
||||||
|
QString searchFilter() const;
|
||||||
|
void setSearchFilter(const QString &arg);
|
||||||
|
|
||||||
//! filtering by payment id
|
//! filtering by payment id
|
||||||
QString paymentIdFilter() const;
|
QString paymentIdFilter() const;
|
||||||
void setPaymentIdFilter(const QString &arg);
|
void setPaymentIdFilter(const QString &arg);
|
||||||
|
@ -53,6 +58,7 @@ public:
|
||||||
TransactionHistory * transactionHistory() const;
|
TransactionHistory * transactionHistory() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void searchFilterChanged();
|
||||||
void paymentIdFilterChanged();
|
void paymentIdFilterChanged();
|
||||||
void dateFromFilterChanged();
|
void dateFromFilterChanged();
|
||||||
void dateToFilterChanged();
|
void dateToFilterChanged();
|
||||||
|
@ -74,6 +80,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<int, QVariant> m_filterValues;
|
QMap<int, QVariant> m_filterValues;
|
||||||
|
QString m_searchString;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSACTIONHISTORYSORTFILTERMODEL_H
|
#endif // TRANSACTIONHISTORYSORTFILTERMODEL_H
|
||||||
|
|
Loading…
Reference in a new issue