Пример #1
0
void RPCConsole::peerLayoutChanged()
{
    if (!clientModel)
        return;

    const CNodeCombinedStats *stats = NULL;
    bool fUnselect = false;
    bool fReselect = false;

    if (cachedNodeid == -1) // no node selected yet
        return;

    // find the currently selected row
    int selectedRow;
    QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
    if (selectedModelIndex.isEmpty())
        selectedRow = -1;
    else
        selectedRow = selectedModelIndex.first().row();

    // check if our detail node has a row in the table (it may not necessarily
    // be at selectedRow since its position can change after a layout change)
    int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);

    if (detailNodeRow < 0)
    {
        // detail node dissapeared from table (node disconnected)
        fUnselect = true;
        cachedNodeid = -1;
        ui->detailWidget->hide();
        ui->peerHeading->setText(tr("Select a peer to view detailed information."));
    }
    else
    {
        if (detailNodeRow != selectedRow)
        {
            // detail node moved position
            fUnselect = true;
            fReselect = true;
        }

        // get fresh stats on the detail node.
        stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
    }

    if (fUnselect && selectedRow >= 0)
    {
        ui->peerWidget->selectionModel()->select(QItemSelection(selectedModelIndex.first(), selectedModelIndex.last()),
            QItemSelectionModel::Deselect);
    }

    if (fReselect)
    {
        ui->peerWidget->selectRow(detailNodeRow);
    }

    if (stats)
        updateNodeDetail(stats);
}
Пример #2
0
void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
{
    if (!clientModel || selected.indexes().isEmpty())
        return;

    const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row());

    if (stats)
        updateNodeDetail(stats);
}
Пример #3
0
void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
{
    Q_UNUSED(deselected);

    if (selected.indexes().isEmpty())
        return;

    // mark the cached banscore as unknown
    detailNodeStats.statestats.nMisbehavior = -1;

    const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row());

    if (stats)
    {
        detailNodeStats.nodestats.nodeid = stats->nodestats.nodeid;
        updateNodeDetail(stats);
        ui->detailWidget->show();
        ui->detailWidget->setDisabled(false);
    }
}
Пример #4
0
void RPCConsole::peerLayoutChanged()
{
    const CNodeCombinedStats *stats = NULL;
    bool fUnselect = false, fReselect = false, fDisconnected = false;

    if (detailNodeStats.nodestats.nodeid == -1)
        // no node selected yet
        return;

    // find the currently selected row
    int selectedRow;
    QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
    if (selectedModelIndex.isEmpty())
        selectedRow = -1;
    else
        selectedRow = selectedModelIndex.first().row();

    // check if our detail node has a row in the table (it may not necessarily
    // be at selectedRow since its position can change after a layout change)
    int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(detailNodeStats.nodestats.nodeid);

    if (detailNodeRow < 0)
    {
        // detail node dissapeared from table (node disconnected)
        fUnselect = true;
        fDisconnected = true;
        detailNodeStats.nodestats.nodeid = 0;
    }
    else
    {
        if (detailNodeRow != selectedRow)
        {
            // detail node moved position
            fUnselect = true;
            fReselect = true;
        }

        // get fresh stats on the detail node.
        stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
    }

    if (fUnselect && selectedRow >= 0)
    {
        ui->peerWidget->selectionModel()->select(QItemSelection(selectedModelIndex.first(), selectedModelIndex.last()),
            QItemSelectionModel::Deselect);
    }

    if (fReselect)
    {
        ui->peerWidget->selectRow(detailNodeRow);
    }

    if (stats)
        updateNodeDetail(stats);

    if (fDisconnected)
    {
        ui->peerHeading->setText(QString(tr("Peer Disconnected")));
        ui->detailWidget->setDisabled(true);
        QDateTime dt = QDateTime::fromTime_t(detailNodeStats.nodestats.nLastSend);
        if (detailNodeStats.nodestats.nLastSend)
            ui->peerLastSend->setText(dt.toString("yyyy-MM-dd hh:mm:ss"));
        dt.setTime_t(detailNodeStats.nodestats.nLastRecv);
        if (detailNodeStats.nodestats.nLastRecv)
            ui->peerLastRecv->setText(dt.toString("yyyy-MM-dd hh:mm:ss"));
        dt.setTime_t(detailNodeStats.nodestats.nTimeConnected);
        ui->peerConnTime->setText(dt.toString("yyyy-MM-dd hh:mm:ss"));
    }
}