mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
Merge bitcoin-core/gui#13: Hide peer detail view if multiple are selected
76277cc77d
qt: Hide peer detail view if multiple are selected (João Barbosa) Pull request description: Currently if multiple peers are selected the peer detail view shows the first new selected peer. With this PR the peer detail view is hidden when multiple peers are selected. It is also a slight refactor to simplify and remove duplicate code. ACKs for top commit: jonasschnelli: Tested ACK76277cc77d
. hebasto: ACK76277cc77d
, tested on Linux Mint 20 (Qt 5.12.8). Tree-SHA512: 16c9cfd6ccb7077a9f31917a6cb3532e32d17d21f735e43bf4720fb0c8bb1bd539d42569c105df4b551f5dccb4acaeedb6bb2362620a9cb9267a602d9d065b9f
This commit is contained in:
commit
094663842d
2 changed files with 16 additions and 29 deletions
|
@ -487,9 +487,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
|
||||||
m_node.rpcSetTimerInterfaceIfUnset(rpcTimerInterface);
|
m_node.rpcSetTimerInterfaceIfUnset(rpcTimerInterface);
|
||||||
|
|
||||||
setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS);
|
setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS);
|
||||||
|
updateDetailWidget();
|
||||||
ui->detailWidget->hide();
|
|
||||||
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
|
|
||||||
|
|
||||||
consoleFontSize = settings.value(fontSizeSettingsKey, QFont().pointSize()).toInt();
|
consoleFontSize = settings.value(fontSizeSettingsKey, QFont().pointSize()).toInt();
|
||||||
clear();
|
clear();
|
||||||
|
@ -620,7 +618,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
||||||
connect(disconnectAction, &QAction::triggered, this, &RPCConsole::disconnectSelectedNode);
|
connect(disconnectAction, &QAction::triggered, this, &RPCConsole::disconnectSelectedNode);
|
||||||
|
|
||||||
// peer table signal handling - update peer details when selecting new node
|
// peer table signal handling - update peer details when selecting new node
|
||||||
connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::peerSelected);
|
connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::updateDetailWidget);
|
||||||
// peer table signal handling - update peer details when new nodes are added to the model
|
// peer table signal handling - update peer details when new nodes are added to the model
|
||||||
connect(model->getPeerTableModel(), &PeerTableModel::layoutChanged, this, &RPCConsole::peerLayoutChanged);
|
connect(model->getPeerTableModel(), &PeerTableModel::layoutChanged, this, &RPCConsole::peerLayoutChanged);
|
||||||
// peer table signal handling - cache selected node ids
|
// peer table signal handling - cache selected node ids
|
||||||
|
@ -1015,18 +1013,6 @@ void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
|
||||||
ui->lblBytesOut->setText(GUIUtil::formatBytes(totalBytesOut));
|
ui->lblBytesOut->setText(GUIUtil::formatBytes(totalBytesOut));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
|
|
||||||
{
|
|
||||||
Q_UNUSED(deselected);
|
|
||||||
|
|
||||||
if (!clientModel || !clientModel->getPeerTableModel() || selected.indexes().isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row());
|
|
||||||
if (stats)
|
|
||||||
updateNodeDetail(stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RPCConsole::peerLayoutAboutToChange()
|
void RPCConsole::peerLayoutAboutToChange()
|
||||||
{
|
{
|
||||||
QModelIndexList selected = ui->peerWidget->selectionModel()->selectedIndexes();
|
QModelIndexList selected = ui->peerWidget->selectionModel()->selectedIndexes();
|
||||||
|
@ -1043,7 +1029,6 @@ void RPCConsole::peerLayoutChanged()
|
||||||
if (!clientModel || !clientModel->getPeerTableModel())
|
if (!clientModel || !clientModel->getPeerTableModel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const CNodeCombinedStats *stats = nullptr;
|
|
||||||
bool fUnselect = false;
|
bool fUnselect = false;
|
||||||
bool fReselect = false;
|
bool fReselect = false;
|
||||||
|
|
||||||
|
@ -1074,9 +1059,6 @@ void RPCConsole::peerLayoutChanged()
|
||||||
fUnselect = true;
|
fUnselect = true;
|
||||||
fReselect = true;
|
fReselect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get fresh stats on the detail node.
|
|
||||||
stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fUnselect && selectedRow >= 0) {
|
if (fUnselect && selectedRow >= 0) {
|
||||||
|
@ -1091,12 +1073,20 @@ void RPCConsole::peerLayoutChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stats)
|
updateDetailWidget();
|
||||||
updateNodeDetail(stats);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
|
void RPCConsole::updateDetailWidget()
|
||||||
{
|
{
|
||||||
|
QModelIndexList selected_rows;
|
||||||
|
auto selection_model = ui->peerWidget->selectionModel();
|
||||||
|
if (selection_model) selected_rows = selection_model->selectedRows();
|
||||||
|
if (!clientModel || !clientModel->getPeerTableModel() || selected_rows.size() != 1) {
|
||||||
|
ui->detailWidget->hide();
|
||||||
|
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected_rows.first().row());
|
||||||
// update the detail ui with latest node information
|
// update the detail ui with latest node information
|
||||||
QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
|
QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
|
||||||
peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid));
|
peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid));
|
||||||
|
@ -1254,8 +1244,7 @@ void RPCConsole::clearSelectedNode()
|
||||||
{
|
{
|
||||||
ui->peerWidget->selectionModel()->clearSelection();
|
ui->peerWidget->selectionModel()->clearSelection();
|
||||||
cachedNodeids.clear();
|
cachedNodeids.clear();
|
||||||
ui->detailWidget->hide();
|
updateDetailWidget();
|
||||||
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPCConsole::showOrHideBanTableIfRequired()
|
void RPCConsole::showOrHideBanTableIfRequired()
|
||||||
|
|
|
@ -95,6 +95,8 @@ private Q_SLOTS:
|
||||||
void showOrHideBanTableIfRequired();
|
void showOrHideBanTableIfRequired();
|
||||||
/** clear the selected node */
|
/** clear the selected node */
|
||||||
void clearSelectedNode();
|
void clearSelectedNode();
|
||||||
|
/** show detailed information on ui about selected node */
|
||||||
|
void updateDetailWidget();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void clear(bool clearHistory = true);
|
void clear(bool clearHistory = true);
|
||||||
|
@ -116,8 +118,6 @@ public Q_SLOTS:
|
||||||
void browseHistory(int offset);
|
void browseHistory(int offset);
|
||||||
/** Scroll console view to end */
|
/** Scroll console view to end */
|
||||||
void scrollToEnd();
|
void scrollToEnd();
|
||||||
/** Handle selection of peer in peers list */
|
|
||||||
void peerSelected(const QItemSelection &selected, const QItemSelection &deselected);
|
|
||||||
/** Handle selection caching before update */
|
/** Handle selection caching before update */
|
||||||
void peerLayoutAboutToChange();
|
void peerLayoutAboutToChange();
|
||||||
/** Handle updated peer information */
|
/** Handle updated peer information */
|
||||||
|
@ -138,8 +138,6 @@ Q_SIGNALS:
|
||||||
private:
|
private:
|
||||||
void startExecutor();
|
void startExecutor();
|
||||||
void setTrafficGraphRange(int mins);
|
void setTrafficGraphRange(int mins);
|
||||||
/** show detailed information on ui about selected node */
|
|
||||||
void updateNodeDetail(const CNodeCombinedStats *stats);
|
|
||||||
|
|
||||||
enum ColumnWidths
|
enum ColumnWidths
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue