Browse Source

Fixed displaying rows.

kevaview
Just Wonder 5 years ago
parent
commit
e044fdae22
  1. 4
      src/qt/kevadialog.cpp
  2. 11
      src/qt/kevatablemodel.cpp
  3. 2
      src/qt/kevatablemodel.h
  4. 3
      src/qt/walletmodel.cpp

4
src/qt/kevadialog.cpp

@ -70,7 +70,7 @@ void KevaDialog::setModel(WalletModel *_model)
if(_model && _model->getOptionsModel()) if(_model && _model->getOptionsModel())
{ {
_model->getKevaTableModel()->sort(KevaTableModel::Date, Qt::DescendingOrder); _model->getKevaTableModel()->sort(KevaTableModel::Block, Qt::DescendingOrder);
QTableView* tableView = ui->recentRequestsView; QTableView* tableView = ui->recentRequestsView;
tableView->verticalHeader()->hide(); tableView->verticalHeader()->hide();
@ -133,7 +133,7 @@ void KevaDialog::on_showContent_clicked()
std::vector<KevaEntry> vKevaEntries; std::vector<KevaEntry> vKevaEntries;
model->getKevaEntries(vKevaEntries, ValtypeToString(namespaceVal)); model->getKevaEntries(vKevaEntries, ValtypeToString(namespaceVal));
model->getKevaTableModel()->setKeva(vKevaEntries); model->getKevaTableModel()->setKeva(std::move(vKevaEntries));
} }
void KevaDialog::on_recentRequestsView_doubleClicked(const QModelIndex &index) void KevaDialog::on_recentRequestsView_doubleClicked(const QModelIndex &index)

11
src/qt/kevatablemodel.cpp

@ -123,14 +123,17 @@ Qt::ItemFlags KevaTableModel::flags(const QModelIndex &index) const
// actually add to table in GUI // actually add to table in GUI
void KevaTableModel::setKeva(std::vector<KevaEntry>& vKevaEntries) void KevaTableModel::setKeva(std::vector<KevaEntry> vKevaEntries)
{ {
// Remove the old ones.
removeRows(0, list.size());
list.clear(); list.clear();
beginInsertRows(QModelIndex(), 0, 0);
for (auto it = vKevaEntries.begin(); it != vKevaEntries.end(); it++) { for (auto it = vKevaEntries.begin(); it != vKevaEntries.end(); it++) {
beginInsertRows(QModelIndex(), 0, 0);
list.prepend(*it); list.prepend(*it);
endInsertRows();
} }
endInsertRows();
} }
void KevaTableModel::sort(int column, Qt::SortOrder order) void KevaTableModel::sort(int column, Qt::SortOrder order)
@ -161,6 +164,6 @@ bool KevaEntryLessThan::operator()(KevaEntry &left, KevaEntry &right) const
case KevaTableModel::Value: case KevaTableModel::Value:
return pLeft->value < pRight->value; return pLeft->value < pRight->value;
default: default:
return pLeft->date.toTime_t() < pRight->date.toTime_t(); return pLeft->block < pRight->block;
} }
} }

2
src/qt/kevatablemodel.h

@ -68,7 +68,7 @@ public:
/*@}*/ /*@}*/
const KevaEntry &entry(int row) const { return list[row]; } const KevaEntry &entry(int row) const { return list[row]; }
void setKeva(std::vector<KevaEntry>& vKevaEntries); void setKeva(std::vector<KevaEntry> vKevaEntries);
public Q_SLOTS: public Q_SLOTS:
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);

3
src/qt/walletmodel.cpp

@ -758,9 +758,10 @@ void WalletModel::getKevaEntries(std::vector<KevaEntry>& vKevaEntries, std::stri
{ {
LOCK(cs_main); LOCK(cs_main);
valtype nameSpaceVal = ValtypeFromString(nameSpace);
valtype key; valtype key;
CKevaData data; CKevaData data;
std::unique_ptr<CKevaIterator> iter(pcoinsTip->IterateKeys(ValtypeFromString(nameSpace))); std::unique_ptr<CKevaIterator> iter(pcoinsTip->IterateKeys(nameSpaceVal));
while (iter->next(key, data)) { while (iter->next(key, data)) {
KevaEntry entry; KevaEntry entry;
entry.key = ValtypeToString(key); entry.key = ValtypeToString(key);

Loading…
Cancel
Save