Correctly limit overview transaction list
The way that the main overview page limits the number of transactions displayed (currently 5) is not an appropriate use of Qt. If it's run with a DEBUG build of Qt, it'll result in a segfault in certain relatively common situations. Instead of artificially limiting the rowCount() in the subclassed proxy filter, we hide/unhide the rows in the displaying QListView upon any changes in the sorted proxy filter.
This commit is contained in:
1 parent
ab98673f05
commit
08209c039f
4 files changed
+15
-24
No files matched your search
+14
-1
@@ -262,7 +262,6 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||
// Set up transaction list
|
||||
filter.reset(new TransactionFilterProxy());
|
||||
filter->setSourceModel(model->getTransactionTableModel());
|
||||
filter->setLimit(NUM_ITEMS);
|
||||
filter->setDynamicSortFilter(true);
|
||||
filter->setSortRole(Qt::EditRole);
|
||||
filter->setShowInactive(false);
|
||||
@@ -271,6 +270,10 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||
ui->listTransactions->setModel(filter.get());
|
||||
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
|
||||
|
||||
connect(filter.get(), &TransactionFilterProxy::rowsInserted, this, &OverviewPage::LimitTransactionRows);
|
||||
connect(filter.get(), &TransactionFilterProxy::rowsRemoved, this, &OverviewPage::LimitTransactionRows);
|
||||
connect(filter.get(), &TransactionFilterProxy::rowsMoved, this, &OverviewPage::LimitTransactionRows);
|
||||
LimitTransactionRows();
|
||||
// Keep up to date with wallet
|
||||
setBalance(model->getCachedBalance());
|
||||
connect(model, &WalletModel::balanceChanged, this, &OverviewPage::setBalance);
|
||||
@@ -299,6 +302,16 @@ void OverviewPage::changeEvent(QEvent* e)
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
||||
// Only show most recent NUM_ITEMS rows
|
||||
void OverviewPage::LimitTransactionRows()
|
||||
{
|
||||
if (filter && ui->listTransactions && ui->listTransactions->model() && filter.get() == ui->listTransactions->model()) {
|
||||
for (int i = 0; i < filter->rowCount(); ++i) {
|
||||
ui->listTransactions->setRowHidden(i, i >= NUM_ITEMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OverviewPage::updateDisplayUnit()
|
||||
{
|
||||
if (walletModel && walletModel->getOptionsModel()) {
|
||||
|
||||
Reference in new issue
Block a user