TxPoolViewer: fix sort

This commit is contained in:
tobtoht 2024-05-03 11:34:46 +02:00
parent 9483325a68
commit 8b0013496c
No known key found for this signature in database
GPG key ID: E45B10DD027D2472

View file

@ -37,11 +37,7 @@ public:
bool operator<(const QTreeWidgetItem &other) const override { bool operator<(const QTreeWidgetItem &other) const override {
int column = treeWidget()->sortColumn(); int column = treeWidget()->sortColumn();
if (column == 2) { return this->data(column, Qt::UserRole).toUInt() < other.data(column, Qt::UserRole).toUInt();
return this->text(column).toInt() < other.text(column).toInt();
}
return this->text(column) < other.text(column);
} }
}; };
@ -70,13 +66,16 @@ void TxPoolViewerDialog::onTxPoolBacklog(const QVector<TxBacklogEntry> &txPool,
auto* item = new TxPoolSortItem(); auto* item = new TxPoolSortItem();
item->setText(0, QString("%1 B").arg(QString::number(entry.weight))); item->setText(0, QString("%1 B").arg(QString::number(entry.weight)));
item->setData(0, Qt::UserRole, entry.weight);
item->setTextAlignment(0, Qt::AlignRight); item->setTextAlignment(0, Qt::AlignRight);
item->setText(1, QString("%1 XMR").arg(WalletManager::displayAmount(entry.fee))); item->setText(1, QString("%1 XMR").arg(WalletManager::displayAmount(entry.fee)));
item->setData(1, Qt::UserRole, entry.fee);
item->setTextAlignment(1, Qt::AlignRight); item->setTextAlignment(1, Qt::AlignRight);
quint64 fee_per_byte = entry.fee / entry.weight; quint64 fee_per_byte = entry.fee / entry.weight;
item->setText(2, QString::number(entry.fee / entry.weight)); item->setText(2, QString::number(entry.fee / entry.weight));
item->setData(2, Qt::UserRole, entry.fee / entry.weight);
item->setTextAlignment(2, Qt::AlignRight); item->setTextAlignment(2, Qt::AlignRight);
if (fee_per_byte == baseFees[0]) { if (fee_per_byte == baseFees[0]) {