From 88b0aff385e353c16bae6f55dc0f8238231c1e27 Mon Sep 17 00:00:00 2001 From: Peter Shugalev Date: Tue, 16 Jul 2024 16:03:45 +0200 Subject: [PATCH] Fixed Qt compilation warnings --- src/qt/addresstablemodel.cpp | 14 ++++----- src/qt/bantablemodel.cpp | 6 ++-- src/qt/bitcoin.cpp | 2 +- src/qt/bitcoinamountfield.cpp | 5 ++-- src/qt/bitcoingui.cpp | 2 +- src/qt/guiutil.cpp | 38 ++++++++++++++++++++++++- src/qt/guiutil.h | 44 +++++++++++++++++++++++++++++ src/qt/lelantusdialog.cpp | 12 ++++---- src/qt/notifymnemonic.cpp | 2 +- src/qt/optionsmodel.cpp | 16 +++++------ src/qt/overviewpage.cpp | 2 +- src/qt/pcodemodel.cpp | 4 +-- src/qt/peertablemodel.cpp | 4 +-- src/qt/receivecoinsdialog.cpp | 2 +- src/qt/receiverequestdialog.cpp | 12 ++++---- src/qt/recentrequeststablemodel.cpp | 2 +- src/qt/recentrequeststablemodel.h | 2 +- src/qt/sendcoinsdialog.cpp | 12 ++++---- src/qt/splashscreen.h | 2 +- src/qt/transactiontablemodel.cpp | 4 +-- src/qt/transactionview.cpp | 19 +++++++------ src/qt/utilitydialog.h | 2 +- 22 files changed, 144 insertions(+), 64 deletions(-) diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 16359b21a4..e373aac4b2 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -145,15 +145,15 @@ class AddressTablePriv // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order // Even though the map is already sorted this re-sorting step is needed because the originating map // is sorted by binary address, not by base58() address. - qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan()); + std::sort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan()); } void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status) { // Find address / label in model - QList::iterator lower = qLowerBound( + QList::iterator lower = std::lower_bound( cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan()); - QList::iterator upper = qUpperBound( + QList::iterator upper = std::upper_bound( cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan()); int lowerIndex = (lower - cachedAddressTable.begin()); int upperIndex = (upper - cachedAddressTable.begin()); @@ -205,9 +205,9 @@ class AddressTablePriv void updateEntry(const QString &pubCoin, const QString &isUsed, int status) { // Find address / label in model - QList::iterator lower = qLowerBound( + QList::iterator lower = std::lower_bound( cachedAddressTable.begin(), cachedAddressTable.end(), pubCoin, AddressTableEntryLessThan()); - QList::iterator upper = qUpperBound( + QList::iterator upper = std::upper_bound( cachedAddressTable.begin(), cachedAddressTable.end(), pubCoin, AddressTableEntryLessThan()); int lowerIndex = (lower - cachedAddressTable.begin()); bool inModel = (lower != upper); @@ -463,7 +463,7 @@ QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation, Qt::ItemFlags AddressTableModel::flags(const QModelIndex &index) const { if(!index.isValid()) - return 0; + return Qt::ItemFlags(); AddressTableEntry *rec = static_cast(index.internalPointer()); Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; @@ -822,7 +822,7 @@ bool PcodeAddressTableModel::removeRows(int row, int count, const QModelIndex &) Qt::ItemFlags PcodeAddressTableModel::flags(const QModelIndex &index) const { if(!index.isValid()) - return 0; + return Qt::ItemFlags(); Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; if(index.column() == int(ColumnIndex::Label)) { diff --git a/src/qt/bantablemodel.cpp b/src/qt/bantablemodel.cpp index 4b34e73eb7..a7bebaead7 100644 --- a/src/qt/bantablemodel.cpp +++ b/src/qt/bantablemodel.cpp @@ -65,7 +65,7 @@ class BanTablePriv if (sortColumn >= 0) // sort cachedBanlist (use stable sort to prevent rows jumping around unnecessarily) - qStableSort(cachedBanlist.begin(), cachedBanlist.end(), BannedNodeLessThan(sortColumn, sortOrder)); + std::stable_sort(cachedBanlist.begin(), cachedBanlist.end(), BannedNodeLessThan(sortColumn, sortOrder)); } int size() const @@ -127,7 +127,7 @@ QVariant BanTableModel::data(const QModelIndex &index, int role) const case Bantime: QDateTime date = QDateTime::fromMSecsSinceEpoch(0); date = date.addSecs(rec->banEntry.nBanUntil); - return date.toString(Qt::SystemLocaleLongDate); + return QLocale::system().toString(date, QLocale::LongFormat); } } @@ -149,7 +149,7 @@ QVariant BanTableModel::headerData(int section, Qt::Orientation orientation, int Qt::ItemFlags BanTableModel::flags(const QModelIndex &index) const { if(!index.isValid()) - return 0; + return Qt::ItemFlags(); Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; return retval; diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 65f7ffd8e9..7d387893e4 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -429,7 +429,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle) void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle) { - SplashScreen *splash = new SplashScreen(QPixmap(), 0); + SplashScreen *splash = new SplashScreen(QPixmap(), Qt::WindowFlags()); // We don't hold a direct pointer to the splash screen after creation, but the splash // screen will take care of deleting itself when slotFinish happens. splash->show(); diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index bacbc5063f..0af10e7fd6 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -7,6 +7,7 @@ #include "bitcoinunits.h" #include "guiconstants.h" #include "qvaluecombobox.h" +#include "guiutil.h" #include #include @@ -102,7 +103,7 @@ class AmountSpinBox: public QAbstractSpinBox const QFontMetrics fm(fontMetrics()); int h = lineEdit()->minimumSizeHint().height(); - int w = fm.width(BitcoinUnits::format(BitcoinUnits::BTC, BitcoinUnits::maxMoney(), false, BitcoinUnits::separatorAlways)); + int w = GUIUtil::TextWidth(fm, BitcoinUnits::format(BitcoinUnits::BTC, BitcoinUnits::maxMoney(), false, BitcoinUnits::separatorAlways)); w += 2; // cursor blinking space QStyleOptionSpinBox opt; @@ -174,7 +175,7 @@ class AmountSpinBox: public QAbstractSpinBox if (text().isEmpty()) // Allow step-up with empty field return StepUpEnabled; - StepEnabled rv = 0; + StepEnabled rv = StepEnabled(); bool valid = false; CAmount val = value(&valid); if(valid) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index b07dbbfe66..6e14a99593 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1413,7 +1413,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *pl const QFontMetrics fm(font()); for (const BitcoinUnits::Unit unit : units) { - max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit))); + max_width = qMax(max_width, GUIUtil::TextWidth(fm, BitcoinUnits::name(unit))); } setMinimumSize(max_width, 0); setAlignment(Qt::AlignRight | Qt::AlignVCenter); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 0985cbfc75..f11b9a432b 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -90,7 +90,7 @@ static CCriticalSection cs_css; QString dateTimeStr(const QDateTime &date) { - return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm"); + return QLocale::system().toString(date.date(), QLocale::ShortFormat) + QString(" ") + date.toString("hh:mm"); } QString dateTimeStr(qint64 nTime) @@ -894,4 +894,40 @@ void loadTheme() qApp->setStyleSheet(*stylesheet); } +int TextWidth(const QFontMetrics& fm, const QString& text) +{ + return fm.horizontalAdvance(text); +} + +QDateTime StartOfDay(const QDate& date) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + return date.startOfDay(); +#else + return QDateTime(date); +#endif +} + +bool HasPixmap(const QLabel* label) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + return !label->pixmap(Qt::ReturnByValue).isNull(); +#else + return label->pixmap() != nullptr; +#endif +} + +QImage GetImage(const QLabel* label) +{ + if (!HasPixmap(label)) { + return QImage(); + } + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + return label->pixmap(Qt::ReturnByValue).toImage(); +#else + return label->pixmap()->toImage(); +#endif +} + } // namespace GUIUtil diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 34ee530a4b..88a783e4e8 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -217,6 +217,50 @@ namespace GUIUtil void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override; }; + /** + * Returns the distance in pixels appropriate for drawing a subsequent character after text. + * + * In Qt 5.12 and before the QFontMetrics::width() is used and it is deprecated since Qt 5.13. + * In Qt 5.11 the QFontMetrics::horizontalAdvance() was introduced. + */ + int TextWidth(const QFontMetrics& fm, const QString& text); + + /** + * Returns the start-moment of the day in local time. + * + * QDateTime::QDateTime(const QDate& date) is deprecated since Qt 5.15. + * QDate::startOfDay() was introduced in Qt 5.14. + */ + QDateTime StartOfDay(const QDate& date); + + /** + * Returns true if pixmap has been set. + * + * QPixmap* QLabel::pixmap() is deprecated since Qt 5.15. + */ + bool HasPixmap(const QLabel* label); + QImage GetImage(const QLabel* label); + + /** + * Splits the string into substrings wherever separator occurs, and returns + * the list of those strings. Empty strings do not appear in the result. + * + * QString::split() signature differs in different Qt versions: + * - QString::SplitBehavior is deprecated since Qt 5.15 + * - Qt::SplitBehavior was introduced in Qt 5.14 + * If {QString|Qt}::SkipEmptyParts behavior is required, use this + * function instead of QString::split(). + */ + template + QStringList SplitSkipEmptyParts(const QString& string, const SeparatorType& separator) + { + #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + return string.split(separator, Qt::SkipEmptyParts); + #else + return string.split(separator, QString::SkipEmptyParts); + #endif + } + } // namespace GUIUtil #endif // BITCOIN_QT_GUIUTIL_H diff --git a/src/qt/lelantusdialog.cpp b/src/qt/lelantusdialog.cpp index be6e2ef2b2..0abc49ccd5 100644 --- a/src/qt/lelantusdialog.cpp +++ b/src/qt/lelantusdialog.cpp @@ -145,11 +145,11 @@ void LelantusDialog::setWalletModel(WalletModel *_walletModel) connect(ui->sliderSmartFee, &QSlider::valueChanged, this, &LelantusDialog::updateSmartFeeLabel); connect(ui->sliderSmartFee, &QSlider::valueChanged, this, &LelantusDialog::updateGlobalFeeVariables); connect(ui->sliderSmartFee, &QSlider::valueChanged, this, &LelantusDialog::coinControlUpdateLabels); - connect(ui->groupFee, qOverload(&QButtonGroup::buttonClicked), this, &LelantusDialog::updateFeeSectionControls); - connect(ui->groupFee, qOverload(&QButtonGroup::buttonClicked), this, &LelantusDialog::updateGlobalFeeVariables); - connect(ui->groupFee, qOverload(&QButtonGroup::buttonClicked), this, &LelantusDialog::coinControlUpdateLabels); - connect(ui->groupCustomFee, qOverload(&QButtonGroup::buttonClicked), this, &LelantusDialog::updateGlobalFeeVariables); - connect(ui->groupCustomFee, qOverload(&QButtonGroup::buttonClicked), this, &LelantusDialog::coinControlUpdateLabels); + connect(ui->groupFee, qOverload(&QButtonGroup::idClicked), this, &LelantusDialog::updateFeeSectionControls); + connect(ui->groupFee, qOverload(&QButtonGroup::idClicked), this, &LelantusDialog::updateGlobalFeeVariables); + connect(ui->groupFee, qOverload(&QButtonGroup::idClicked), this, &LelantusDialog::coinControlUpdateLabels); + connect(ui->groupCustomFee, qOverload(&QButtonGroup::idClicked), this, &LelantusDialog::updateGlobalFeeVariables); + connect(ui->groupCustomFee, qOverload(&QButtonGroup::idClicked), this, &LelantusDialog::coinControlUpdateLabels); connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &LelantusDialog::updateGlobalFeeVariables); connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &LelantusDialog::coinControlUpdateLabels); connect(ui->checkBoxMinimumFee, &QCheckBox::stateChanged, this, &LelantusDialog::setMinimumFee); @@ -563,7 +563,7 @@ void LelantusDialog::updateSmartFeeLabel() int lightness = ui->fallbackFeeWarningLabel->palette().color(QPalette::WindowText).lightness(); QColor warning_colour(255 - (lightness / 5), 176 - (lightness / 3), 48 - (lightness / 14)); ui->fallbackFeeWarningLabel->setStyleSheet("QLabel { color: " + warning_colour.name() + "; }"); - ui->fallbackFeeWarningLabel->setIndent(QFontMetrics(ui->fallbackFeeWarningLabel->font()).width("x")); + ui->fallbackFeeWarningLabel->setIndent(GUIUtil::TextWidth(QFontMetrics(ui->fallbackFeeWarningLabel->font()), "x")); } else { diff --git a/src/qt/notifymnemonic.cpp b/src/qt/notifymnemonic.cpp index 92ee78f37f..4b722f68fd 100644 --- a/src/qt/notifymnemonic.cpp +++ b/src/qt/notifymnemonic.cpp @@ -30,7 +30,7 @@ NotifyMnemonic::~NotifyMnemonic() void NotifyMnemonic::cancelEvent() { - if( QMessageBox::question( this, trUtf8( "Warning" ), trUtf8( "Are you sure you wish to proceed without confirming whether you have written down your seed words correctly?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { + if( QMessageBox::question( this, tr( "Warning" ), tr( "Are you sure you wish to proceed without confirming whether you have written down your seed words correctly?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { // allow cancel reject(); } diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 7489e60471..74d4ea6f03 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -236,12 +236,12 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return settings.value("fUseProxy", false); case ProxyIP: { // contains IP at index 0 and port at index 1 - QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); + QStringList strlIpPort = settings.value("addrProxy").toString().split(":", Qt::SkipEmptyParts); return strlIpPort.at(0); } case ProxyPort: { // contains IP at index 0 and port at index 1 - QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); + QStringList strlIpPort = settings.value("addrProxy").toString().split(":", Qt::SkipEmptyParts); return strlIpPort.at(1); } @@ -253,12 +253,12 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return settings.value("fUseSeparateProxyTor", false); case ProxyIPTor: { // contains IP at index 0 and port at index 1 - QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); + QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", Qt::SkipEmptyParts); return strlIpPort.at(0); } case ProxyPortTor: { // contains IP at index 0 and port at index 1 - QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); + QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", Qt::SkipEmptyParts); return strlIpPort.at(1); } @@ -333,7 +333,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in break; case ProxyIP: { // contains current IP at index 0 and current port at index 1 - QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); + QStringList strlIpPort = settings.value("addrProxy").toString().split(":", Qt::SkipEmptyParts); // if that key doesn't exist or has a changed IP if (!settings.contains("addrProxy") || strlIpPort.at(0) != value.toString()) { // construct new value from new IP and current port @@ -345,7 +345,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in break; case ProxyPort: { // contains current IP at index 0 and current port at index 1 - QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); + QStringList strlIpPort = settings.value("addrProxy").toString().split(":", Qt::SkipEmptyParts); // if that key doesn't exist or has a changed port if (!settings.contains("addrProxy") || strlIpPort.at(1) != value.toString()) { // construct new value from current IP and new port @@ -365,7 +365,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in break; case ProxyIPTor: { // contains current IP at index 0 and current port at index 1 - QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); + QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", Qt::SkipEmptyParts); // if that key doesn't exist or has a changed IP if (!settings.contains("addrSeparateProxyTor") || strlIpPort.at(0) != value.toString()) { // construct new value from new IP and current port @@ -377,7 +377,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in break; case ProxyPortTor: { // contains current IP at index 0 and current port at index 1 - QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); + QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", Qt::SkipEmptyParts); // if that key doesn't exist or has a changed port if (!settings.contains("addrSeparateProxyTor") || strlIpPort.at(1) != value.toString()) { // construct new value from current IP and new port diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 507f7f604d..2d0c753f06 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -474,7 +474,7 @@ MigrateLelantusToSparkDialog::MigrateLelantusToSparkDialog(WalletModel *_model): layout()->addWidget(wbody); setContentsMargins(0, 0, 0, 0); setStyleSheet("margin-right:-30px;"); - setStandardButtons(0); + setStandardButtons(StandardButtons()); connect(ignore, &QPushButton::clicked, this, &MigrateLelantusToSparkDialog::onIgnoreClicked); connect(migrate, &QPushButton::clicked, this, &MigrateLelantusToSparkDialog::onMigrateClicked); diff --git a/src/qt/pcodemodel.cpp b/src/qt/pcodemodel.cpp index a7a369cc8d..148948cf08 100644 --- a/src/qt/pcodemodel.cpp +++ b/src/qt/pcodemodel.cpp @@ -129,7 +129,7 @@ QModelIndex PcodeModel::index(int row, int column, const QModelIndex &parent) co Qt::ItemFlags PcodeModel::flags(const QModelIndex & index) const { if(!index.isValid()) - return 0; + return Qt::ItemFlags(); Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; if(index.column() == int(ColumnIndex::Label)) { @@ -245,7 +245,7 @@ void PcodeModel::sort(int column, Qt::SortOrder order) return std::get<2>(cmp1) < std::get<2>(cmp2); } }; - qSort(items.begin(), items.end(), sortPred); + std::sort(items.begin(), items.end(), sortPred); Q_EMIT dataChanged(index(0, 0, QModelIndex()), index(items.size() - 1, int(ColumnIndex::NumberOfColumns) - 1, QModelIndex())); } diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 35fe0bc16a..0d7d49e4ce 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -86,7 +86,7 @@ class PeerTablePriv if (sortColumn >= 0) // sort cacheNodeStats (use stable sort to prevent rows jumping around unnecessarily) - qStableSort(cachedNodeStats.begin(), cachedNodeStats.end(), NodeLessThan(sortColumn, sortOrder)); + std::stable_sort(cachedNodeStats.begin(), cachedNodeStats.end(), NodeLessThan(sortColumn, sortOrder)); // build index map mapNodeRows.clear(); @@ -197,7 +197,7 @@ QVariant PeerTableModel::headerData(int section, Qt::Orientation orientation, in Qt::ItemFlags PeerTableModel::flags(const QModelIndex &index) const { if(!index.isValid()) - return 0; + return Qt::ItemFlags(); Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; return retval; diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index 21b9352591..0aeeb9b301 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -276,7 +276,7 @@ void ReceiveCoinsDialog::copyColumnToClipboard(int column) if (!firstIndex.isValid()) { return; } - GUIUtil::setClipboard(model->getRecentRequestsTableModel()->data(firstIndex.child(firstIndex.row(), column), Qt::EditRole).toString()); + GUIUtil::setClipboard(model->getRecentRequestsTableModel()->index(firstIndex.row(), column).data(Qt::EditRole).toString()); } // context menu diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp index 559e4a18ac..0c19c5d9c1 100644 --- a/src/qt/receiverequestdialog.cpp +++ b/src/qt/receiverequestdialog.cpp @@ -43,14 +43,12 @@ QRImageWidget::QRImageWidget(QWidget *parent): QImage QRImageWidget::exportImage() { - if(!pixmap()) - return QImage(); - return pixmap()->toImage(); + return GUIUtil::GetImage(this); } void QRImageWidget::mousePressEvent(QMouseEvent *event) { - if(event->button() == Qt::LeftButton && pixmap()) + if(event->button() == Qt::LeftButton && GUIUtil::HasPixmap(this)) { event->accept(); QMimeData *mimeData = new QMimeData; @@ -66,7 +64,7 @@ void QRImageWidget::mousePressEvent(QMouseEvent *event) void QRImageWidget::saveImage() { - if(!pixmap()) + if(!GUIUtil::HasPixmap(this)) return; QString fn = GUIUtil::getSaveFileName(this, tr("Save QR Code"), QString(), tr("PNG Image (*.png)"), NULL); if (!fn.isEmpty()) @@ -77,14 +75,14 @@ void QRImageWidget::saveImage() void QRImageWidget::copyImage() { - if(!pixmap()) + if(!GUIUtil::HasPixmap(this)) return; QApplication::clipboard()->setImage(exportImage()); } void QRImageWidget::contextMenuEvent(QContextMenuEvent *event) { - if(!pixmap()) + if(!GUIUtil::HasPixmap(this)) return; contextMenu->exec(event->globalPos()); } diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp index b883922be8..0a4308f4e3 100644 --- a/src/qt/recentrequeststablemodel.cpp +++ b/src/qt/recentrequeststablemodel.cpp @@ -220,7 +220,7 @@ void RecentRequestsTableModel::addNewRequest(RecentRequestEntry &recipient) void RecentRequestsTableModel::sort(int column, Qt::SortOrder order) { - qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order)); + std::sort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order)); Q_EMIT dataChanged(index(0, 0, QModelIndex()), index(list.size() - 1, NUMBER_OF_COLUMNS - 1, QModelIndex())); } diff --git a/src/qt/recentrequeststablemodel.h b/src/qt/recentrequeststablemodel.h index 9168e4273e..26e4df5743 100644 --- a/src/qt/recentrequeststablemodel.h +++ b/src/qt/recentrequeststablemodel.h @@ -82,7 +82,7 @@ class RecentRequestsTableModel: public QAbstractTableModel QVariant data(const QModelIndex &index, int role) const; bool setData(const QModelIndex &index, const QVariant &value, int role); QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QModelIndex index(int row, int column, const QModelIndex &parent) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); Qt::ItemFlags flags(const QModelIndex &index) const; /*@}*/ diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 63e4862569..f644471d30 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -190,11 +190,11 @@ void SendCoinsDialog::setModel(WalletModel *_model) connect(ui->sliderSmartFee, &QSlider::valueChanged, this, &SendCoinsDialog::updateSmartFeeLabel); connect(ui->sliderSmartFee, &QSlider::valueChanged, this, &SendCoinsDialog::updateGlobalFeeVariables); connect(ui->sliderSmartFee, &QSlider::valueChanged, this, &SendCoinsDialog::coinControlUpdateLabels); - connect(ui->groupFee, qOverload(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::updateFeeSectionControls); - connect(ui->groupFee, qOverload(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::updateGlobalFeeVariables); - connect(ui->groupFee, qOverload(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::coinControlUpdateLabels); - connect(ui->groupCustomFee, qOverload(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::updateGlobalFeeVariables); - connect(ui->groupCustomFee, qOverload(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::coinControlUpdateLabels); + connect(ui->groupFee, qOverload(&QButtonGroup::idClicked), this, &SendCoinsDialog::updateFeeSectionControls); + connect(ui->groupFee, qOverload(&QButtonGroup::idClicked), this, &SendCoinsDialog::updateGlobalFeeVariables); + connect(ui->groupFee, qOverload(&QButtonGroup::idClicked), this, &SendCoinsDialog::coinControlUpdateLabels); + connect(ui->groupCustomFee, qOverload(&QButtonGroup::idClicked), this, &SendCoinsDialog::updateGlobalFeeVariables); + connect(ui->groupCustomFee, qOverload(&QButtonGroup::idClicked), this, &SendCoinsDialog::coinControlUpdateLabels); connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &SendCoinsDialog::updateGlobalFeeVariables); connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &SendCoinsDialog::coinControlUpdateLabels); connect(ui->checkBoxMinimumFee, &QCheckBox::stateChanged, this, &SendCoinsDialog::setMinimumFee); @@ -1093,7 +1093,7 @@ void SendCoinsDialog::updateSmartFeeLabel() int lightness = ui->fallbackFeeWarningLabel->palette().color(QPalette::WindowText).lightness(); QColor warning_colour(255 - (lightness / 5), 176 - (lightness / 3), 48 - (lightness / 14)); ui->fallbackFeeWarningLabel->setStyleSheet("QLabel { color: " + warning_colour.name() + "; }"); - ui->fallbackFeeWarningLabel->setIndent(QFontMetrics(ui->fallbackFeeWarningLabel->font()).width("x")); + ui->fallbackFeeWarningLabel->setIndent(GUIUtil::TextWidth(QFontMetrics(ui->fallbackFeeWarningLabel->font()), "x")); } else { diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h index 383ca77c50..a11ff2ada7 100644 --- a/src/qt/splashscreen.h +++ b/src/qt/splashscreen.h @@ -21,7 +21,7 @@ class SplashScreen : public QSplashScreen Q_OBJECT public: - explicit SplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0); + explicit SplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags()); // explicit SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle); // ~SplashScreen(); diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index d65f7577f7..aa2f661e91 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -101,9 +101,9 @@ class TransactionTablePriv qDebug() << "TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.ToString()) + " " + QString::number(status); // Find bounds of this transaction in model - QList::iterator lower = qLowerBound( + QList::iterator lower = std::lower_bound( cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); - QList::iterator upper = qUpperBound( + QList::iterator upper = std::upper_bound( cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); int lowerIndex = (lower - cachedWallet.begin()); int upperIndex = (upper - cachedWallet.begin()); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 7ad14a9ac5..b45675cd35 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -17,6 +17,7 @@ #include "transactiontablemodel.h" #include "walletmodel.h" #include "pcodemodel.h" +#include "guiutil.h" #include "ui_interface.h" @@ -250,7 +251,7 @@ void TransactionView::setModel(WalletModel *_model) if (_model->getOptionsModel()) { // Add third party transaction URLs to context menu - QStringList listUrls = _model->getOptionsModel()->getThirdPartyTxUrls().split("|", QString::SkipEmptyParts); + QStringList listUrls = _model->getOptionsModel()->getThirdPartyTxUrls().split("|", Qt::SkipEmptyParts); for (int i = 0; i < listUrls.size(); ++i) { QString url = listUrls[i].trimmed(); @@ -289,30 +290,30 @@ void TransactionView::chooseDate(int idx) break; case Today: transactionProxyModel->setDateRange( - QDateTime(current), + QDateTime(GUIUtil::StartOfDay(current)), TransactionFilterProxy::MAX_DATE); break; case ThisWeek: { // Find last Monday QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1)); transactionProxyModel->setDateRange( - QDateTime(startOfWeek), + QDateTime(GUIUtil::StartOfDay(startOfWeek)), TransactionFilterProxy::MAX_DATE); } break; case ThisMonth: transactionProxyModel->setDateRange( - QDateTime(QDate(current.year(), current.month(), 1)), + QDateTime(GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1))), TransactionFilterProxy::MAX_DATE); break; case LastMonth: transactionProxyModel->setDateRange( - QDateTime(QDate(current.year(), current.month(), 1).addMonths(-1)), - QDateTime(QDate(current.year(), current.month(), 1))); + QDateTime(GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1).addMonths(-1))), + QDateTime(GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1)))); break; case ThisYear: transactionProxyModel->setDateRange( - QDateTime(QDate(current.year(), 1, 1)), + QDateTime(GUIUtil::StartOfDay(QDate(current.year(), 1, 1))), TransactionFilterProxy::MAX_DATE); break; case Range: @@ -661,8 +662,8 @@ void TransactionView::dateRangeChanged() if(!transactionProxyModel) return; transactionProxyModel->setDateRange( - QDateTime(dateFrom->date()), - QDateTime(dateTo->date()).addDays(1)); + GUIUtil::StartOfDay(dateFrom->date()), + GUIUtil::StartOfDay(dateTo->date()).addDays(1)); } void TransactionView::updateCalendarWidgets() diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h index 1b6781c5fc..086f707a44 100644 --- a/src/qt/utilitydialog.h +++ b/src/qt/utilitydialog.h @@ -42,7 +42,7 @@ class ShutdownWindow : public QWidget Q_OBJECT public: - ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0); + ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags()); static QWidget *showShutdownWindow(BitcoinGUI *window); protected: