diff --git a/src/qt/kevadialog.cpp b/src/qt/kevadialog.cpp index dc37ce629..664ee2138 100644 --- a/src/qt/kevadialog.cpp +++ b/src/qt/kevadialog.cpp @@ -70,7 +70,7 @@ void KevaDialog::setModel(WalletModel *_model) if(_model && _model->getOptionsModel()) { - _model->getKevaTableModel()->sort(KevaTableModel::Date, Qt::DescendingOrder); + _model->getKevaTableModel()->sort(KevaTableModel::Block, Qt::DescendingOrder); QTableView* tableView = ui->recentRequestsView; tableView->verticalHeader()->hide(); @@ -133,7 +133,7 @@ void KevaDialog::on_showContent_clicked() std::vector vKevaEntries; model->getKevaEntries(vKevaEntries, ValtypeToString(namespaceVal)); - model->getKevaTableModel()->setKeva(vKevaEntries); + model->getKevaTableModel()->setKeva(std::move(vKevaEntries)); } void KevaDialog::on_recentRequestsView_doubleClicked(const QModelIndex &index) diff --git a/src/qt/kevatablemodel.cpp b/src/qt/kevatablemodel.cpp index 17ab5eb52..50abb1e09 100644 --- a/src/qt/kevatablemodel.cpp +++ b/src/qt/kevatablemodel.cpp @@ -123,14 +123,17 @@ Qt::ItemFlags KevaTableModel::flags(const QModelIndex &index) const // actually add to table in GUI -void KevaTableModel::setKeva(std::vector& vKevaEntries) +void KevaTableModel::setKeva(std::vector vKevaEntries) { + // Remove the old ones. + removeRows(0, list.size()); list.clear(); - beginInsertRows(QModelIndex(), 0, 0); + for (auto it = vKevaEntries.begin(); it != vKevaEntries.end(); it++) { + beginInsertRows(QModelIndex(), 0, 0); list.prepend(*it); + endInsertRows(); } - endInsertRows(); } void KevaTableModel::sort(int column, Qt::SortOrder order) @@ -161,6 +164,6 @@ bool KevaEntryLessThan::operator()(KevaEntry &left, KevaEntry &right) const case KevaTableModel::Value: return pLeft->value < pRight->value; default: - return pLeft->date.toTime_t() < pRight->date.toTime_t(); + return pLeft->block < pRight->block; } } diff --git a/src/qt/kevatablemodel.h b/src/qt/kevatablemodel.h index 0afe80790..83600bc0b 100644 --- a/src/qt/kevatablemodel.h +++ b/src/qt/kevatablemodel.h @@ -68,7 +68,7 @@ public: /*@}*/ const KevaEntry &entry(int row) const { return list[row]; } - void setKeva(std::vector& vKevaEntries); + void setKeva(std::vector vKevaEntries); public Q_SLOTS: void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index f1a1d9d21..be4bfa83d 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -758,9 +758,10 @@ void WalletModel::getKevaEntries(std::vector& vKevaEntries, std::stri { LOCK(cs_main); + valtype nameSpaceVal = ValtypeFromString(nameSpace); valtype key; CKevaData data; - std::unique_ptr iter(pcoinsTip->IterateKeys(ValtypeFromString(nameSpace))); + std::unique_ptr iter(pcoinsTip->IterateKeys(nameSpaceVal)); while (iter->next(key, data)) { KevaEntry entry; entry.key = ValtypeToString(key);