void MasternodeManager::updateNodeList() { TRY_LOCK(cs_masternodes, lockMasternodes); if(!lockMasternodes) return; ui->countLabel->setText("Updating..."); ui->tableWidget->clearContents(); ui->tableWidget->setRowCount(0); BOOST_FOREACH(CMasterNode mn, vecMasternodes) { int mnRow = 0; ui->tableWidget->insertRow(0); // populate list // Address, Rank, Active, Active Seconds, Last Seen, Pub Key QTableWidgetItem *activeItem = new QTableWidgetItem(QString::number(mn.IsEnabled())); QTableWidgetItem *addressItem = new QTableWidgetItem(QString::fromStdString(mn.addr.ToString())); QTableWidgetItem *rankItem = new QTableWidgetItem(QString::number(GetMasternodeRank(mn.vin, pindexBest->nHeight))); QTableWidgetItem *activeSecondsItem = new QTableWidgetItem(seconds_to_DHMS((qint64)(mn.lastTimeSeen - mn.now))); QTableWidgetItem *lastSeenItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat(mn.lastTimeSeen))); CScript pubkey; pubkey =GetScriptForDestination(mn.pubkey.GetID()); CTxDestination address1; ExtractDestination(pubkey, address1); CBitcoinAddress address2(address1); QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(address2.ToString())); ui->tableWidget->setItem(mnRow, 0, addressItem); ui->tableWidget->setItem(mnRow, 1, rankItem); ui->tableWidget->setItem(mnRow, 2, activeItem); ui->tableWidget->setItem(mnRow, 3, activeSecondsItem); ui->tableWidget->setItem(mnRow, 4, lastSeenItem); ui->tableWidget->setItem(mnRow, 5, pubkeyItem); }
void smart_plot::mousePress(QMouseEvent *event) { static double prevKey, prevValue; if(event->button() == Qt::MiddleButton) { QCPAbstractPlottable *plottable = activePlot()->plottableAt(event->localPos()); if(plottable) { QCPGraph *graph = qobject_cast<QCPGraph*>(plottable); plot_analytics analytics; plotStats stats; if(graph) { //Do diff by % range vs double mouseKey = graph->keyAxis()->pixelToCoord(event->localPos().x()); double mouseValue = graph->valueAxis()->pixelToCoord(event->localPos().y()); double keyRange = graph->keyAxis()->range().size(); double keyDistance_no_abs = 0; double value = 0; double key = 0; bool ok = false; double m = std::numeric_limits<double>::max(); //QCPGraphDataContainer analytics.plotAnalyze( graph, &stats, graph->keyAxis()->range()); //Iterate through on screen data and see which point is closest QCPGraphDataContainer::const_iterator QCPGraphDataBegin = graph->data().data()->findBegin(graph->keyAxis()->range().lower,true); QCPGraphDataContainer::const_iterator QCPGraphDataEnd = graph->data().data()->findEnd(graph->keyAxis()->range().upper,true); for (QCPGraphDataContainer::const_iterator QCPGraphDataIt=QCPGraphDataBegin; QCPGraphDataIt!=QCPGraphDataEnd; ++QCPGraphDataIt) { double valueRange = graph->valueAxis()->range().size(); double keyDistance = qAbs(mouseKey - QCPGraphDataIt->key)/keyRange; double valueDistance = qAbs(mouseValue - QCPGraphDataIt->value)/valueRange; if( (valueDistance + keyDistance) < m ) { value = QCPGraphDataIt->value; key = QCPGraphDataIt->key; keyDistance_no_abs = mouseKey - QCPGraphDataIt->key; ok = true; m = (valueDistance + keyDistance); } } // qDebug () << QDateTime::fromTime_t((int)mouseKey) << value; if(ok) { QToolTip::hideText(); if(!qSharedPointerDynamicCast<QCPAxisTickerDateTime>(graph->keyAxis()->ticker()).isNull()) { if(QApplication::keyboardModifiers().testFlag(Qt::ControlModifier)) { quint32 timeDelta = qAbs(mouseKey-prevKey); // add the bracket at the top: QCPItemBracket *bracket = new QCPItemBracket(activePlot()); bracket->left->setAxes(graph->keyAxis(), graph->valueAxis()); bracket->left->setCoords(prevKey, value); bracket->right->setAxes(graph->keyAxis(), graph->valueAxis()); bracket->right->setCoords(mouseKey, value); // add the text label at the top: QCPItemText *wavePacketText = new QCPItemText(activePlot()); wavePacketText->position->setParentAnchor(bracket->center); wavePacketText->position->setCoords(0, -10); // move 10 pixels to the top from bracket center anchor wavePacketText->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter); wavePacketText->setText( QString("%L1: ΔX->%L2 ΔY->%L3"). arg(graph->name().isEmpty() ? "..." : graph->name()). arg(seconds_to_DHMS(timeDelta)). arg(value-prevValue)); wavePacketText->setFont(QFont(font().family(), 12)); activePlot()->replot(); } else if(QApplication::keyboardModifiers().testFlag(Qt::AltModifier)) { if(QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) graph->addData(graph->keyAxis()->pixelToCoord(event->localPos().x()), graph->valueAxis()->pixelToCoord(event->localPos().y())); else if(keyDistance_no_abs < 0) graph->addData(key - 1, std::numeric_limits<double>::quiet_NaN()); else graph->addData(key + 1, std::numeric_limits<double>::quiet_NaN()); activePlot()->replot(); } else if(QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)) { //Delete point graph->data().data()->remove(key); activePlot()->replot(); } //Hold Alt to insert NAN(Break link?) else { QDateTime dateTime; dateTime.setTime_t(mouseKey); //activePlot()->xAxis->tick QToolTip::showText(event->globalPos(), QString("<table>" "<tr>" "<th colspan=\"2\">%L1</th>" "</tr>" "<tr>" "<td>X:</td>" "<td>%L2</td>" "</tr>" "<tr>" "<td>Y:</td>" "<td>%L3</td>" "</tr>" "<tr>" "<td>Min:</td>" "<td>%L4</td>" "</tr>" "<tr>" "<td>Avg:</td>" "<td>%L5</td>" "</tr>" "<tr>" "<td>Max:</td>" "<td>%L6</td>" "</tr>" "</table>"). arg(graph->name().isEmpty() ? "..." : graph->name()). arg(dateTime.toString(qSharedPointerDynamicCast<QCPAxisTickerDateTime>(graph->keyAxis()->ticker())->dateTimeFormat())). arg(value). arg(stats.minValue). arg(stats.avgValue). arg(stats.maxValue), activePlot(), activePlot()->rect()); } } else { QToolTip::showText(event->globalPos(), QString("<table>" "<tr>" "<th colspan=\"2\">%L1</th>" "</tr>" "<tr>" "<td>X:</td>" "<td>%L2</td>" "</tr>" "<tr>" "<td>Y:</td>" "<td>%L3</td>" "</tr>" "<tr>" "<td>Min:</td>" "<td>%L4</td>" "</tr>" "<tr>" "<td>Avg:</td>" "<td>%L5</td>" "</tr>" "<tr>" "<td>Max:</td>" "<td>%L6</td>" "</tr>" "</table>"). arg(graph->name().isEmpty() ? "..." : graph->name()). arg(mouseKey). arg(value). arg(stats.minValue). arg(stats.avgValue). arg(stats.maxValue), activePlot(), activePlot()->rect()); } } prevKey = mouseKey; prevValue = value; } } } }