From f7875e91b6e507b5f57688776e16dbf9edcc7ad2 Mon Sep 17 00:00:00 2001 From: barton26 Date: Fri, 13 Aug 2021 15:43:39 -0400 Subject: [PATCH 1/3] Replace deprecated Qt::SystemLocale{Short,Long}Date --- src/qt/bantablemodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/bantablemodel.cpp b/src/qt/bantablemodel.cpp index 3948c17fd2..02180ca450 100644 --- a/src/qt/bantablemodel.cpp +++ b/src/qt/bantablemodel.cpp @@ -15,6 +15,7 @@ #include #include #include +#include bool BannedNodeLessThan::operator()(const CCombinedBan& left, const CCombinedBan& right) const { @@ -125,7 +126,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); } } From 6b069968c99a7f8e9f39b6ef6eb443866b4247fe Mon Sep 17 00:00:00 2001 From: barton26 Date: Fri, 13 Aug 2021 15:54:40 -0400 Subject: [PATCH 2/3] Fix 'QDateTime is deprecated' warnings --- src/qt/bitcoingui.h | 1 + src/qt/guiutil.cpp | 9 +++++++++ src/qt/guiutil.h | 8 ++++++++ src/qt/overviewpage.cpp | 1 + src/qt/rpcconsole.cpp | 1 + src/qt/rpcconsole.h | 1 + src/qt/transactionview.cpp | 16 ++++++++-------- 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index b348084a8c..4b176c3d1c 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -37,6 +37,7 @@ class QModelIndex; class QStackedWidget; class QUrl; class QMessageBox; +class QDateTime; QT_END_NAMESPACE /** diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 14766c2193..27e8a1db40 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -719,4 +719,13 @@ void HelpMessageBox::showOrPrint() #endif } +QDateTime StartOfDay(const QDate& date) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + return date.startOfDay(); +#else + return QDateTime(date); +#endif +} + } // namespace GUIUtil diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 38c7546042..4296974baf 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -155,6 +155,14 @@ namespace GUIUtil QString options; }; + /** + * 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); + } // namespace GUIUtil #endif // GUIUTIL_H diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index fa7dfc8a89..6290bb5c22 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -19,6 +19,7 @@ #include "gridcoin/voting/fwd.h" #include +#include #include #define DECORATION_SIZE 40 diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 5885d3d4cb..1cecc98f44 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -12,6 +12,7 @@ #include "main.h" #endif +#include #include #include #include diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 0f96e97c64..816ecefbfc 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -17,6 +17,7 @@ namespace Ui { class ClientModel; QT_BEGIN_NAMESPACE +class QDateTime; class QMenu; class QItemSelection; QT_END_NAMESPACE diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index c44570c19b..1b4aa1b057 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -215,30 +215,30 @@ void TransactionView::chooseDate(int idx) break; case Today: transactionProxyModel->setDateRange( - QDateTime(current), + GUIUtil::StartOfDay(current), TransactionFilterProxy::MAX_DATE); break; case ThisWeek: { // Find last Monday QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1)); transactionProxyModel->setDateRange( - QDateTime(startOfWeek), + GUIUtil::StartOfDay(startOfWeek), TransactionFilterProxy::MAX_DATE); } break; case ThisMonth: transactionProxyModel->setDateRange( - QDateTime(QDate(current.year(), current.month(), 1)), + GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1)), TransactionFilterProxy::MAX_DATE); break; case LastMonth: transactionProxyModel->setDateRange( - QDateTime(QDate(current.year(), current.month()-1, 1)), - QDateTime(QDate(current.year(), current.month(), 1))); + GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1).addMonths(-1)), + GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1))); break; case ThisYear: transactionProxyModel->setDateRange( - QDateTime(QDate(current.year(), 1, 1)), + GUIUtil::StartOfDay(QDate(current.year(), 1, 1)), TransactionFilterProxy::MAX_DATE); break; case Range: @@ -435,8 +435,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::focusTransaction(const QModelIndex &idx) From 355e393fc11b899b3a4ec340aebaf74a2e7b5ae9 Mon Sep 17 00:00:00 2001 From: barton26 Date: Sun, 15 Aug 2021 01:35:55 -0400 Subject: [PATCH 3/3] Suggestions --- src/qt/bitcoingui.h | 1 - src/qt/overviewpage.cpp | 1 - src/qt/rpcconsole.cpp | 1 - src/qt/rpcconsole.h | 1 - 4 files changed, 4 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 4b176c3d1c..b348084a8c 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -37,7 +37,6 @@ class QModelIndex; class QStackedWidget; class QUrl; class QMessageBox; -class QDateTime; QT_END_NAMESPACE /** diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 6290bb5c22..fa7dfc8a89 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -19,7 +19,6 @@ #include "gridcoin/voting/fwd.h" #include -#include #include #define DECORATION_SIZE 40 diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 1cecc98f44..5885d3d4cb 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -12,7 +12,6 @@ #include "main.h" #endif -#include #include #include #include diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 816ecefbfc..0f96e97c64 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -17,7 +17,6 @@ namespace Ui { class ClientModel; QT_BEGIN_NAMESPACE -class QDateTime; class QMenu; class QItemSelection; QT_END_NAMESPACE