Fix several deprecation warnings (#8657)

* Use constructor instead of nullptr for WindowFlags
* Use constructor instead of nullptr for Alignment
* Disable deprecation warning for QProcess
* Add string split method to RaTextStringTools
* Add caf.cpp used to manage Qt function deprecations
* Use position()
This commit is contained in:
Magne Sjaastad
2022-03-11 13:24:01 +01:00
committed by GitHub
parent 72fc47e003
commit 806a149809
75 changed files with 472 additions and 206 deletions

View File

@@ -16,6 +16,8 @@ find_package(
set(QT_LIBRARIES Qt5::Core)
set(PROJECT_FILES
caf.h
caf.cpp
cafAssert.h
cafAppEnum.h
cafClassTypeName.h

View File

@@ -0,0 +1,81 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2020- Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "caf.h"
#include "QtGui/qevent.h"
#include <QLocale>
#include <QTextStream>
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QLocale norwegianLocale()
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 )
return QLocale::NorwegianBokmal;
#else
return QLocale::Norwegian;
#endif
} // namespace caf::norwegianLocale()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QTextStream& endl( QTextStream& s )
{
// https: // github.com/qt/qtbase/blob/dev/src/corelib/serialization/qtextstream.cpp#L2845
#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 )
return s << QLatin1Char( '\n' ) << Qt::flush;
#else
return s << QLatin1Char( '\n' ) << flush;
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QPointF position( QWheelEvent* wheelEvent )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 )
return wheelEvent->position();
#else
return wheelEvent->pos();
#endif
}
} // namespace caf

View File

@@ -0,0 +1,48 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2020- Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
class QLocale;
class QTextStream;
class QPointF;
class QWheelEvent;
namespace caf
{
QLocale norwegianLocale();
QTextStream& endl( QTextStream& s );
QPointF position( QWheelEvent* wheelEvent );
}; // namespace caf

View File

@@ -69,7 +69,7 @@ public:
void defineGridLayout(int rowCount, int columnCount);
// See QGridLayout::addWidget
void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = nullptr);
void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = Qt::Alignment());
void removeWidget(QWidget* widget);
void addBlankCell(int row, int column);

View File

@@ -10,7 +10,7 @@ class WidgetLayoutTest : public QWidget
Q_OBJECT
public:
WidgetLayoutTest(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr);
WidgetLayoutTest(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~WidgetLayoutTest() override;
private:

View File

@@ -52,7 +52,7 @@ class PdmUiListView : public QWidget
{
Q_OBJECT
public:
PdmUiListView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
PdmUiListView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
~PdmUiListView() override;
void setPdmObject( caf::PdmObjectCollection* object );

View File

@@ -59,7 +59,7 @@ class PdmUiTableView : public QWidget
{
Q_OBJECT
public:
PdmUiTableView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
PdmUiTableView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
~PdmUiTableView() override;
void setChildArrayField( PdmChildArrayFieldHandle* childArrayField );

View File

@@ -64,7 +64,7 @@ class PdmUiTreeView : public QWidget
{
Q_OBJECT
public:
PdmUiTreeView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
PdmUiTreeView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
~PdmUiTreeView() override;
void enableDefaultContextMenu( bool enable );

View File

@@ -59,7 +59,7 @@ public:
QWidget* parent,
OpenGLWidget* shareWidget = nullptr,
Qt::WindowFlags f = nullptr );
OpenGLWidget( OpenGLWidget* shareWidget, QWidget* parent, Qt::WindowFlags f = nullptr );
OpenGLWidget( OpenGLWidget* shareWidget, QWidget* parent, Qt::WindowFlags f = Qt::WindowFlags() );
cvf::OpenGLContext* cvfOpenGLContext() const;
void cvfShutdownOpenGLContext();