mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
qt, refactor: Fix 'QDateTime is deprecated' warnings
This commit is contained in:
parent
93ab136a33
commit
b02264cb5d
8 changed files with 31 additions and 10 deletions
|
@ -49,6 +49,7 @@ struct BlockAndHeaderTipInfo;
|
|||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QComboBox;
|
||||
class QDateTime;
|
||||
class QMenu;
|
||||
class QProgressBar;
|
||||
class QProgressDialog;
|
||||
|
|
|
@ -920,4 +920,13 @@ void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action)
|
|||
menu->popup(point, at_action);
|
||||
}
|
||||
|
||||
QDateTime StartOfDay(const QDate& date)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
return date.startOfDay();
|
||||
#else
|
||||
return QDateTime(date);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace GUIUtil
|
||||
|
|
|
@ -289,7 +289,7 @@ namespace GUIUtil
|
|||
/**
|
||||
* 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 13.0.
|
||||
* 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);
|
||||
|
@ -303,6 +303,15 @@ namespace GUIUtil
|
|||
* Call QMenu::popup() only on supported QT_QPA_PLATFORM.
|
||||
*/
|
||||
void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action = nullptr);
|
||||
|
||||
/**
|
||||
* 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 // BITCOIN_QT_GUIUTIL_H
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QApplication>
|
||||
#include <QDateTime>
|
||||
#include <QPainter>
|
||||
#include <QStatusTipEvent>
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <QApplication>
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileOpenEvent>
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <wallet/wallet.h>
|
||||
#endif
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QFont>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace Ui {
|
|||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDateTime;
|
||||
class QMenu;
|
||||
class QItemSelection;
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -275,30 +275,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).addMonths(-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:
|
||||
|
@ -583,8 +583,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)
|
||||
|
|
Loading…
Add table
Reference in a new issue