From 9c72532f5de6ac4e63dfb13463c5b64d284d18da Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 15 Oct 2020 16:50:11 +0200 Subject: [PATCH] Qt5: fix deprecation warnings for Qt 5.15 + replace QDirModel with QFileSystemModel + QProcess::start(QString, OpenMode) is deprecated + QByteArray::append is deprecated + QPixmap* QLabel::pixmap() is deprecated --- src/Gui/NetworkRetriever.cpp | 3 ++- src/Gui/OnlineDocumentation.cpp | 6 ++---- src/Gui/ProjectView.cpp | 5 ++--- src/Gui/ProjectView.h | 5 +++-- src/Gui/QSint/actionpanel/actionbox.cpp | 13 +++++++++++++ src/Gui/QSint/actionpanel/actionbox.h | 2 +- src/Gui/QSint/actionpanel/taskgroup_p.cpp | 4 ++-- src/Gui/QSint/actionpanel/taskheader_p.cpp | 4 ++-- src/Gui/TaskElementColors.cpp | 2 +- 9 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/Gui/NetworkRetriever.cpp b/src/Gui/NetworkRetriever.cpp index 646a8baf7d..0019036e57 100644 --- a/src/Gui/NetworkRetriever.cpp +++ b/src/Gui/NetworkRetriever.cpp @@ -374,7 +374,8 @@ void NetworkRetriever::wgetFinished(int exitCode, QProcess::ExitStatus status) bool NetworkRetriever::testWget() { QProcess proc; - proc.start(QString::fromLatin1("wget")); + proc.setProgram(QString::fromLatin1("wget")); + proc.start(); bool ok = proc.state() == QProcess::Running; proc.kill(); proc.waitForFinished(); diff --git a/src/Gui/OnlineDocumentation.cpp b/src/Gui/OnlineDocumentation.cpp index 5504607948..4c1921c3ee 100644 --- a/src/Gui/OnlineDocumentation.cpp +++ b/src/Gui/OnlineDocumentation.cpp @@ -255,8 +255,7 @@ QByteArray PythonOnlineHelp::fileNotFound() const QString http(QLatin1String("HTTP/1.1 %1 %2\r\n%3\r\n")); QString httpResponseHeader = http.arg(404).arg(QLatin1String("File not found")).arg(header); - QByteArray res; - res.append(httpResponseHeader); + QByteArray res = httpResponseHeader.toLatin1(); return res; } @@ -285,8 +284,7 @@ QByteArray PythonOnlineHelp::loadFailed(const QString& error) const QString http(QLatin1String("HTTP/1.1 %1 %2\r\n%3\r\n")); QString httpResponseHeader = http.arg(404).arg(QLatin1String("File not found")).arg(header); - QByteArray res; - res.append(httpResponseHeader); + QByteArray res = httpResponseHeader.toLatin1(); return res; } diff --git a/src/Gui/ProjectView.cpp b/src/Gui/ProjectView.cpp index 857cf24f59..64e10e2b50 100644 --- a/src/Gui/ProjectView.cpp +++ b/src/Gui/ProjectView.cpp @@ -36,7 +36,7 @@ # include #endif -#include +#include #include #include @@ -56,8 +56,7 @@ using namespace Gui; ProjectWidget::ProjectWidget(QWidget* parent) : QTreeView(parent) { - fileModel = new QDirModel(this); - fileModel->setSorting(QDir::DirsFirst | QDir::Type); + fileModel = new QFileSystemModel(this); setModel(fileModel); } diff --git a/src/Gui/ProjectView.h b/src/Gui/ProjectView.h index 7b45386184..3e361cb4e7 100644 --- a/src/Gui/ProjectView.h +++ b/src/Gui/ProjectView.h @@ -31,7 +31,8 @@ #include #include -class QDirModel; + +class QFileSystemModel; namespace Gui { @@ -48,7 +49,7 @@ public: ~ProjectWidget(); private: - QDirModel *fileModel; + QFileSystemModel *fileModel; }; diff --git a/src/Gui/QSint/actionpanel/actionbox.cpp b/src/Gui/QSint/actionpanel/actionbox.cpp index 2ed673b4d5..8bd92e7bb5 100644 --- a/src/Gui/QSint/actionpanel/actionbox.cpp +++ b/src/Gui/QSint/actionpanel/actionbox.cpp @@ -116,6 +116,19 @@ void ActionBox::setIcon(const QPixmap & icon) iconLabel->setFixedSize(icon.size()); } +QPixmap ActionBox::icon() const +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + return iconLabel->pixmap(Qt::ReturnByValue); +#else + QPixmap p; + const QPixmap* ptr = iconLabel->pixmap(); + if (ptr) + p = *ptr; + return p; +#endif +} + ActionLabel* ActionBox::createItem(QAction * action, QLayout * l) { if (!action) diff --git a/src/Gui/QSint/actionpanel/actionbox.h b/src/Gui/QSint/actionpanel/actionbox.h index 0b599349dc..645d56175c 100644 --- a/src/Gui/QSint/actionpanel/actionbox.h +++ b/src/Gui/QSint/actionpanel/actionbox.h @@ -182,7 +182,7 @@ public: void setIcon(const QPixmap & icon); /** Returns icon of the ActionBox. */ - inline const QPixmap* icon() const { return iconLabel->pixmap(); } + QPixmap icon() const;// { return iconLabel->pixmap(); } /** Returns header item of the ActionBox. */ diff --git a/src/Gui/QSint/actionpanel/taskgroup_p.cpp b/src/Gui/QSint/actionpanel/taskgroup_p.cpp index 10a1a5a530..6133ab2e20 100644 --- a/src/Gui/QSint/actionpanel/taskgroup_p.cpp +++ b/src/Gui/QSint/actionpanel/taskgroup_p.cpp @@ -106,7 +106,7 @@ void TaskGroup::keyPressEvent ( QKeyEvent * event ) { case Qt::Key_Down: { - QKeyEvent ke(QEvent::KeyPress, Qt::Key_Tab, 0); + QKeyEvent ke(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier); QApplication::sendEvent(this, &ke); return; } @@ -131,7 +131,7 @@ void TaskGroup::keyReleaseEvent ( QKeyEvent * event ) { case Qt::Key_Down: { - QKeyEvent ke(QEvent::KeyRelease, Qt::Key_Tab, 0); + QKeyEvent ke(QEvent::KeyRelease, Qt::Key_Tab, Qt::NoModifier); QApplication::sendEvent(this, &ke); return; } diff --git a/src/Gui/QSint/actionpanel/taskheader_p.cpp b/src/Gui/QSint/actionpanel/taskheader_p.cpp index 63c9e0d19c..38c4ab4e1e 100644 --- a/src/Gui/QSint/actionpanel/taskheader_p.cpp +++ b/src/Gui/QSint/actionpanel/taskheader_p.cpp @@ -264,7 +264,7 @@ void TaskHeader::keyPressEvent ( QKeyEvent * event ) { case Qt::Key_Down: { - QKeyEvent ke(QEvent::KeyPress, Qt::Key_Tab,0 ); + QKeyEvent ke(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier); QApplication::sendEvent(this, &ke); return; } @@ -288,7 +288,7 @@ void TaskHeader::keyReleaseEvent ( QKeyEvent * event ) { case Qt::Key_Down: { - QKeyEvent ke(QEvent::KeyRelease, Qt::Key_Tab, 0); + QKeyEvent ke(QEvent::KeyRelease, Qt::Key_Tab, Qt::NoModifier); QApplication::sendEvent(this, &ke); return; } diff --git a/src/Gui/TaskElementColors.cpp b/src/Gui/TaskElementColors.cpp index c9d3dd30b6..39b70b2bf4 100644 --- a/src/Gui/TaskElementColors.cpp +++ b/src/Gui/TaskElementColors.cpp @@ -263,7 +263,7 @@ public: boost::starts_with(msg.pSubName,editSub)) { for(auto item : ui->elementList->findItems( - QString::fromLatin1(msg.pSubName-editSub.size()),0)) + QString::fromLatin1(msg.pSubName-editSub.size()), Qt::MatchExactly)) item->setSelected(msg.Type==SelectionChanges::AddSelection); } }