mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 00:07:51 +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 {
|
||||
id: paymentIdLabel
|
||||
id: searchLabel
|
||||
anchors.left: parent.left
|
||||
anchors.top: filterHeaderText.bottom // addressLine.bottom
|
||||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 17
|
||||
text: qsTr("Payment ID <font size='2'>(Optional)</font>") + translationManager.emptyString
|
||||
text: qsTr("Incremental search") + translationManager.emptyString
|
||||
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")
|
||||
+ translationManager.emptyString
|
||||
tipText: qsTr("Search transfers for a given string") + translationManager.emptyString
|
||||
}
|
||||
|
||||
LineEdit {
|
||||
id: paymentIdLine
|
||||
id: searchLine
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: paymentIdLabel.bottom // addressLabel.bottom
|
||||
anchors.top: searchLabel.bottom // addressLabel.bottom
|
||||
anchors.leftMargin: 17
|
||||
anchors.rightMargin: 17
|
||||
anchors.topMargin: 5
|
||||
placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString
|
||||
validator: RegExpValidator {
|
||||
regExp: /[0-9a-fA-F]+/
|
||||
placeholderText: qsTr("Type search string") + translationManager.emptyString
|
||||
onTextChanged: {
|
||||
model.searchFilter = searchLine.text
|
||||
selectedAmount.text = getSelectedAmount()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Filter by description input (not implemented yet)
|
||||
|
@ -205,7 +203,7 @@ Rectangle {
|
|||
Label {
|
||||
id: descriptionLabel
|
||||
anchors.left: parent.left
|
||||
anchors.top: paymentIdLine.bottom
|
||||
anchors.top: searchLine.bottom
|
||||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 17
|
||||
text: qsTr("Description <font size='2'>(Local database)</font>") + translationManager.emptyString
|
||||
|
@ -229,7 +227,7 @@ Rectangle {
|
|||
Label {
|
||||
id: dateFromText
|
||||
anchors.left: parent.left
|
||||
anchors.top: paymentIdLine.bottom // descriptionLine.bottom
|
||||
anchors.top: searchLine.bottom // descriptionLine.bottom
|
||||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 17
|
||||
width: 156
|
||||
|
@ -255,7 +253,7 @@ Rectangle {
|
|||
Label {
|
||||
id: dateToText
|
||||
anchors.left: dateFromText.right
|
||||
anchors.top: paymentIdLine.bottom //descriptionLine.bottom
|
||||
anchors.top: searchLine.bottom //descriptionLine.bottom
|
||||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 17
|
||||
text: qsTr("To")
|
||||
|
@ -292,8 +290,6 @@ Rectangle {
|
|||
onClicked: {
|
||||
// Apply filter here;
|
||||
|
||||
model.paymentIdFilter = paymentIdLine.text
|
||||
|
||||
resetFilter(model)
|
||||
|
||||
if (fromDatePicker.currentDate > toDatePicker.currentDate) {
|
||||
|
|
|
@ -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
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue