Skip to content

Commit

Permalink
Fix compilation with qt < 5.2 (#1672)
Browse files Browse the repository at this point in the history
* Fix compilation with qt < 5.2

* remove code duplication
  • Loading branch information
UdjinM6 authored Oct 9, 2017
1 parent ece8849 commit 296cfd2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/qt/masternodelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
#include <QTimer>
#include <QMessageBox>

int GetOffsetFromUtc()
{
#if QT_VERSION < 0x050200
const QDateTime dateTime1 = QDateTime::currentDateTime();
const QDateTime dateTime2 = QDateTime(dateTime1.date(), dateTime1.time(), Qt::UTC);
return dateTime1.secsTo(dateTime2);
#else
return QDateTime::currentDateTime().offsetFromUtc();
#endif
}

MasternodeList::MasternodeList(const PlatformStyle *platformStyle, QWidget *parent) :
QWidget(parent),
ui(new Ui::MasternodeList),
Expand Down Expand Up @@ -193,7 +204,7 @@ void MasternodeList::updateMyMasternodeInfo(QString strAlias, QString strAddr, c
QTableWidgetItem *statusItem = new QTableWidgetItem(QString::fromStdString(fFound ? CMasternode::StateToString(infoMn.nActiveState) : "MISSING"));
QTableWidgetItem *activeSecondsItem = new QTableWidgetItem(QString::fromStdString(DurationToDHMS(fFound ? (infoMn.nTimeLastPing - infoMn.sigTime) : 0)));
QTableWidgetItem *lastSeenItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat("%Y-%m-%d %H:%M",
fFound ? infoMn.nTimeLastPing + QDateTime::currentDateTime().offsetFromUtc() : 0)));
fFound ? infoMn.nTimeLastPing + GetOffsetFromUtc() : 0)));
QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(fFound ? CBitcoinAddress(infoMn.pubKeyCollateralAddress.GetID()).ToString() : ""));

ui->tableWidgetMyMasternodes->setItem(nNewRow, 0, aliasItem);
Expand Down Expand Up @@ -263,6 +274,7 @@ void MasternodeList::updateNodeList()
ui->tableWidgetMasternodes->clearContents();
ui->tableWidgetMasternodes->setRowCount(0);
std::map<COutPoint, CMasternode> mapMasternodes = mnodeman.GetFullMasternodeMap();
int offsetFromUtc = GetOffsetFromUtc();

for(auto& mnpair : mapMasternodes)
{
Expand All @@ -273,7 +285,7 @@ void MasternodeList::updateNodeList()
QTableWidgetItem *protocolItem = new QTableWidgetItem(QString::number(mn.nProtocolVersion));
QTableWidgetItem *statusItem = new QTableWidgetItem(QString::fromStdString(mn.GetStatus()));
QTableWidgetItem *activeSecondsItem = new QTableWidgetItem(QString::fromStdString(DurationToDHMS(mn.lastPing.sigTime - mn.sigTime)));
QTableWidgetItem *lastSeenItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat("%Y-%m-%d %H:%M", mn.lastPing.sigTime + QDateTime::currentDateTime().offsetFromUtc())));
QTableWidgetItem *lastSeenItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat("%Y-%m-%d %H:%M", mn.lastPing.sigTime + offsetFromUtc)));
QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString()));

if (strCurrentFilter != "")
Expand Down

0 comments on commit 296cfd2

Please sign in to comment.