From c8dae9eb85a4b12cd35dcd2a4a6adfe973a924fc Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 10 Jun 2020 23:02:47 +0200 Subject: [PATCH] Qt5: 'void QTime::start()' / 'int QTime::elapsed() const' / 'int QTime::restart()' are deprecated: Use QElapsedTimer instead [-Wdeprecated-declarations] --- src/Base/PreCompiled.h | 2 ++ src/Base/Tools.cpp | 7 ++----- src/Gui/DownloadItem.cpp | 7 +++++-- src/Gui/DownloadItem.h | 5 +++-- src/Gui/ProgressBar.cpp | 7 ++++--- src/Gui/ProgressDialog.cpp | 7 ++++--- src/Gui/SoFCColorBar.cpp | 5 ++++- src/Gui/SoFCColorBar.h | 4 ++-- src/Gui/Tree.h | 4 ++-- src/Gui/Widgets.cpp | 1 + src/Gui/Widgets.h | 4 ++-- src/Mod/Mesh/Gui/RemeshGmsh.cpp | 4 ++-- src/Mod/Part/Gui/TaskCheckGeometry.h | 4 ++-- 13 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/Base/PreCompiled.h b/src/Base/PreCompiled.h index 2503d7e86d..8de6fe3b9c 100644 --- a/src/Base/PreCompiled.h +++ b/src/Base/PreCompiled.h @@ -114,11 +114,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include diff --git a/src/Base/Tools.cpp b/src/Base/Tools.cpp index 167b9bed36..d5b32e03dd 100644 --- a/src/Base/Tools.cpp +++ b/src/Base/Tools.cpp @@ -26,9 +26,9 @@ # include # include # include +# include #endif -# include #include "PyExport.h" #include "Interpreter.h" #include "Tools.h" @@ -265,7 +265,7 @@ using namespace Base; struct StopWatch::Private { - QTime t; + QElapsedTimer t; }; StopWatch::StopWatch() : d(new Private) @@ -313,6 +313,3 @@ std::string StopWatch::toString(int ms) const str << msec << "ms"; return str.str(); } - - - diff --git a/src/Gui/DownloadItem.cpp b/src/Gui/DownloadItem.cpp index 04cbbaa350..00edad31d8 100644 --- a/src/Gui/DownloadItem.cpp +++ b/src/Gui/DownloadItem.cpp @@ -130,7 +130,9 @@ AutoSaver::~AutoSaver() void AutoSaver::changeOccurred() { - if (m_firstChange.isNull()) +if (!m_firstChange.isValid()) +printf("changeOccurred\n"); + if (!m_firstChange.isValid()) m_firstChange.start(); if (m_firstChange.elapsed() > MAXWAIT) { @@ -154,7 +156,8 @@ void AutoSaver::saveIfNecessary() if (!m_timer.isActive()) return; m_timer.stop(); - m_firstChange = QTime(); +printf("saveifnecessary\n"); + m_firstChange = QElapsedTimer(); if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) { qWarning() << "AutoSaver: error invoking slot save() on parent"; } diff --git a/src/Gui/DownloadItem.h b/src/Gui/DownloadItem.h index b032a832fb..51fc3f8882 100644 --- a/src/Gui/DownloadItem.h +++ b/src/Gui/DownloadItem.h @@ -25,6 +25,7 @@ #define GUI_DIALOG_DOWNLOADITEM_H #include +#include #include #include #include @@ -83,7 +84,7 @@ protected: private: QBasicTimer m_timer; - QTime m_firstChange; + QElapsedTimer m_firstChange; }; @@ -146,7 +147,7 @@ private: bool m_requestFileName; qint64 m_bytesReceived; - QTime m_downloadTime; + QElapsedTimer m_downloadTime; }; } // namespace Dialog diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index bf65b37e0b..47f22faf32 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ # include +# include # include # include # include @@ -51,9 +52,9 @@ struct SequencerBarPrivate { ProgressBar* bar; WaitCursor* waitCursor; - QTime measureTime; - QTime progressTime; - QTime checkAbortTime; + QElapsedTimer measureTime; + QElapsedTimer progressTime; + QElapsedTimer checkAbortTime; QString text; bool guiThread; }; diff --git a/src/Gui/ProgressDialog.cpp b/src/Gui/ProgressDialog.cpp index da83fd5044..cf803daf6b 100644 --- a/src/Gui/ProgressDialog.cpp +++ b/src/Gui/ProgressDialog.cpp @@ -26,8 +26,9 @@ # include # include # include -# include +# include # include +# include #endif #include "ProgressDialog.h" #include "MainWindow.h" @@ -40,8 +41,8 @@ namespace Gui { struct SequencerDialogPrivate { ProgressDialog* dlg; - QTime measureTime; - QTime progressTime; + QElapsedTimer measureTime; + QElapsedTimer progressTime; QString text; bool guiThread; bool canabort; diff --git a/src/Gui/SoFCColorBar.cpp b/src/Gui/SoFCColorBar.cpp index 7145d1d944..614841728d 100644 --- a/src/Gui/SoFCColorBar.cpp +++ b/src/Gui/SoFCColorBar.cpp @@ -254,7 +254,10 @@ void SoFCColorBar::handleEvent (SoHandleEventAction *action) if ((e->getButton() == SoMouseButtonEvent::BUTTON1)) { if (e->getState() == SoButtonEvent::DOWN) { // double click event - if (_timer.restart() < QApplication::doubleClickInterval()) { + if (!_timer.isValid()) { + _timer.start(); + } + else if (_timer.restart() < QApplication::doubleClickInterval()) { QApplication::postEvent( new SoFCColorBarProxyObject(this), new QEvent(QEvent::User)); diff --git a/src/Gui/SoFCColorBar.h b/src/Gui/SoFCColorBar.h index 389e16b4f2..c02e3cf891 100644 --- a/src/Gui/SoFCColorBar.h +++ b/src/Gui/SoFCColorBar.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -190,7 +190,7 @@ private: private: float _fMaxX, _fMinX, _fMaxY, _fMinY; - QTime _timer; + QElapsedTimer _timer; SoSwitch* pColorMode; std::vector _colorBars; diff --git a/src/Gui/Tree.h b/src/Gui/Tree.h index 4da8e8f62e..caed51169f 100644 --- a/src/Gui/Tree.h +++ b/src/Gui/Tree.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -228,7 +228,7 @@ private: QTimer* statusTimer; QTimer* selectTimer; QTimer* preselectTimer; - QTime preselectTime; + QElapsedTimer preselectTime; static std::unique_ptr documentPixmap; static std::unique_ptr documentPartialPixmap; std::unordered_map DocumentMap; diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 83a24b9875..6651742922 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -990,6 +990,7 @@ void ToolTip::showText(const QPoint & pos, const QString & text, QWidget * w) tip->w = w; // show text with a short delay tip->tooltipTimer.start(80, tip); + tip->displayTime.start(); } else { // do immediately diff --git a/src/Gui/Widgets.h b/src/Gui/Widgets.h index 0fd06bb59c..c2aed4189f 100644 --- a/src/Gui/Widgets.h +++ b/src/Gui/Widgets.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include "ExpressionBinding.h" @@ -351,7 +351,7 @@ private: QPoint pos; QPointer w; // need guard in case widget gets destroyed QBasicTimer tooltipTimer; - QTime displayTime; + QElapsedTimer displayTime; }; // ---------------------------------------------------------------------- diff --git a/src/Mod/Mesh/Gui/RemeshGmsh.cpp b/src/Mod/Mesh/Gui/RemeshGmsh.cpp index 9651aac101..dd5dc0a4dd 100644 --- a/src/Mod/Mesh/Gui/RemeshGmsh.cpp +++ b/src/Mod/Mesh/Gui/RemeshGmsh.cpp @@ -27,7 +27,7 @@ # include # include # include -# include +# include #endif #include "RemeshGmsh.h" @@ -69,7 +69,7 @@ public: QPointer label; QPointer syntax; QProcess gmsh; - QTime time; + QElapsedTimer time; }; GmshWidget::GmshWidget(QWidget* parent, Qt::WindowFlags fl) diff --git a/src/Mod/Part/Gui/TaskCheckGeometry.h b/src/Mod/Part/Gui/TaskCheckGeometry.h index 9c4349a179..b45e7b1005 100644 --- a/src/Mod/Part/Gui/TaskCheckGeometry.h +++ b/src/Mod/Part/Gui/TaskCheckGeometry.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include class SoSeparator; class SoSwitch; @@ -200,7 +200,7 @@ public: private: int steps; bool canceled; - QTime time; + QElapsedTimer time; QProgressDialog* myProgress; };