mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -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
|
QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
class QAction;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
class QDateTime;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QProgressBar;
|
class QProgressBar;
|
||||||
class QProgressDialog;
|
class QProgressDialog;
|
||||||
|
|
|
@ -920,4 +920,13 @@ void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action)
|
||||||
menu->popup(point, 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
|
} // namespace GUIUtil
|
||||||
|
|
|
@ -289,7 +289,7 @@ namespace GUIUtil
|
||||||
/**
|
/**
|
||||||
* Returns the distance in pixels appropriate for drawing a subsequent character after text.
|
* 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.
|
* In Qt 5.11 the QFontMetrics::horizontalAdvance() was introduced.
|
||||||
*/
|
*/
|
||||||
int TextWidth(const QFontMetrics& fm, const QString& text);
|
int TextWidth(const QFontMetrics& fm, const QString& text);
|
||||||
|
@ -303,6 +303,15 @@ namespace GUIUtil
|
||||||
* Call QMenu::popup() only on supported QT_QPA_PLATFORM.
|
* Call QMenu::popup() only on supported QT_QPA_PLATFORM.
|
||||||
*/
|
*/
|
||||||
void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action = nullptr);
|
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
|
} // namespace GUIUtil
|
||||||
|
|
||||||
#endif // BITCOIN_QT_GUIUTIL_H
|
#endif // BITCOIN_QT_GUIUTIL_H
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDateTime>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStatusTipEvent>
|
#include <QStatusTipEvent>
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace Ui {
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QDateTime;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QItemSelection;
|
class QItemSelection;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
|
@ -275,30 +275,30 @@ void TransactionView::chooseDate(int idx)
|
||||||
break;
|
break;
|
||||||
case Today:
|
case Today:
|
||||||
transactionProxyModel->setDateRange(
|
transactionProxyModel->setDateRange(
|
||||||
QDateTime(current),
|
GUIUtil::StartOfDay(current),
|
||||||
TransactionFilterProxy::MAX_DATE);
|
TransactionFilterProxy::MAX_DATE);
|
||||||
break;
|
break;
|
||||||
case ThisWeek: {
|
case ThisWeek: {
|
||||||
// Find last Monday
|
// Find last Monday
|
||||||
QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
|
QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
|
||||||
transactionProxyModel->setDateRange(
|
transactionProxyModel->setDateRange(
|
||||||
QDateTime(startOfWeek),
|
GUIUtil::StartOfDay(startOfWeek),
|
||||||
TransactionFilterProxy::MAX_DATE);
|
TransactionFilterProxy::MAX_DATE);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case ThisMonth:
|
case ThisMonth:
|
||||||
transactionProxyModel->setDateRange(
|
transactionProxyModel->setDateRange(
|
||||||
QDateTime(QDate(current.year(), current.month(), 1)),
|
GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1)),
|
||||||
TransactionFilterProxy::MAX_DATE);
|
TransactionFilterProxy::MAX_DATE);
|
||||||
break;
|
break;
|
||||||
case LastMonth:
|
case LastMonth:
|
||||||
transactionProxyModel->setDateRange(
|
transactionProxyModel->setDateRange(
|
||||||
QDateTime(QDate(current.year(), current.month(), 1).addMonths(-1)),
|
GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1).addMonths(-1)),
|
||||||
QDateTime(QDate(current.year(), current.month(), 1)));
|
GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1)));
|
||||||
break;
|
break;
|
||||||
case ThisYear:
|
case ThisYear:
|
||||||
transactionProxyModel->setDateRange(
|
transactionProxyModel->setDateRange(
|
||||||
QDateTime(QDate(current.year(), 1, 1)),
|
GUIUtil::StartOfDay(QDate(current.year(), 1, 1)),
|
||||||
TransactionFilterProxy::MAX_DATE);
|
TransactionFilterProxy::MAX_DATE);
|
||||||
break;
|
break;
|
||||||
case Range:
|
case Range:
|
||||||
|
@ -583,8 +583,8 @@ void TransactionView::dateRangeChanged()
|
||||||
if(!transactionProxyModel)
|
if(!transactionProxyModel)
|
||||||
return;
|
return;
|
||||||
transactionProxyModel->setDateRange(
|
transactionProxyModel->setDateRange(
|
||||||
QDateTime(dateFrom->date()),
|
GUIUtil::StartOfDay(dateFrom->date()),
|
||||||
QDateTime(dateTo->date()).addDays(1));
|
GUIUtil::StartOfDay(dateTo->date()).addDays(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionView::focusTransaction(const QModelIndex &idx)
|
void TransactionView::focusTransaction(const QModelIndex &idx)
|
||||||
|
|
Loading…
Add table
Reference in a new issue