Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit dataChanged signal to dynamically re-sort Peers table #375

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,7 @@ void PeerTableModel::refresh()
m_peers_data.swap(new_peers_data);
}

Q_EMIT changed();
const auto top_left = index(0, 0);
const auto bottom_right = index(rowCount() - 1, columnCount() - 1);
Q_EMIT dataChanged(top_left, bottom_right);
}
3 changes: 0 additions & 3 deletions src/qt/peertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ class PeerTableModel : public QAbstractTableModel
public Q_SLOTS:
void refresh();

Q_SIGNALS:
void changed();

private:
//! Internal peer data structure.
QList<CNodeCombinedStats> m_peers_data{};
Expand Down
3 changes: 2 additions & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#endif

#include <QAbstractButton>
#include <QAbstractItemModel>
#include <QDateTime>
#include <QFont>
#include <QKeyEvent>
Expand Down Expand Up @@ -684,7 +685,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_

// peer table signal handling - update peer details when selecting new node
connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::updateDetailWidget);
connect(model->getPeerTableModel(), &PeerTableModel::changed, this, &RPCConsole::updateDetailWidget);
connect(model->getPeerTableModel(), &QAbstractItemModel::dataChanged, [this] { updateDetailWidget(); });

// set up ban table
ui->banlistWidget->setModel(model->getBanTableModel());
Expand Down