Skip to content

Commit

Permalink
Qt5: fix deprecation warnings for Qt 5.15
Browse files Browse the repository at this point in the history
+ replace QDirModel with QFileSystemModel
+ QProcess::start(QString, OpenMode) is deprecated
+ QByteArray::append is deprecated
+ QPixmap* QLabel::pixmap() is deprecated
  • Loading branch information
wwmayer committed Oct 15, 2020
1 parent 3430add commit 9c72532
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/Gui/NetworkRetriever.cpp
Expand Up @@ -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();
Expand Down
6 changes: 2 additions & 4 deletions src/Gui/OnlineDocumentation.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 2 additions & 3 deletions src/Gui/ProjectView.cpp
Expand Up @@ -36,7 +36,7 @@
# include <QTimer>
#endif

#include <QDirModel>
#include <QFileSystemModel>
#include <Base/Console.h>
#include <App/Document.h>

Expand All @@ -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);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Gui/ProjectView.h
Expand Up @@ -31,7 +31,8 @@

#include <Gui/DockWindow.h>
#include <Gui/Selection.h>
class QDirModel;

class QFileSystemModel;

namespace Gui {

Expand All @@ -48,7 +49,7 @@ class ProjectWidget : public QTreeView
~ProjectWidget();

private:
QDirModel *fileModel;
QFileSystemModel *fileModel;

};

Expand Down
13 changes: 13 additions & 0 deletions src/Gui/QSint/actionpanel/actionbox.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/QSint/actionpanel/actionbox.h
Expand Up @@ -182,7 +182,7 @@ class QSINT_EXPORT ActionBox : public QFrame
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.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/QSint/actionpanel/taskgroup_p.cpp
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/QSint/actionpanel/taskheader_p.cpp
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/TaskElementColors.cpp
Expand Up @@ -263,7 +263,7 @@ class ElementColors::Private: public Gui::SelectionGate
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);
}
}
Expand Down

0 comments on commit 9c72532

Please sign in to comment.