Skip to content

Commit

Permalink
Remove Qt5 ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Oct 25, 2024
1 parent 4d10046 commit d2b0b35
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 158 deletions.
4 changes: 0 additions & 4 deletions ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,7 @@ QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, RiaDefines::Da
//--------------------------------------------------------------------------------------------------
QDateTime RiaQDateTimeTools::createDateTime( const QDate& date, Qt::TimeSpec timeSpec /*= Qt::LocalTime*/ )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
return date.startOfDay( timeSpec );
#else
return QDateTime( date, QTime( 0, 0 ), timeSpec );
#endif
}

//--------------------------------------------------------------------------------------------------
Expand Down
11 changes: 5 additions & 6 deletions ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,11 @@ void RiuQtChartsPlotWidget::setAutoTickIntervalCounts( RiuPlotAxis axis, int max
//--------------------------------------------------------------------------------------------------
double RiuQtChartsPlotWidget::majorTickInterval( RiuPlotAxis axis ) const
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
// QValueAxis::tickInterval was introduced in 5.12
QAbstractAxis* ax = plotAxis( axis );
QValueAxis* valueAxis = dynamic_cast<QValueAxis*>( ax );
if ( valueAxis ) return valueAxis->tickInterval();
#endif
if ( QValueAxis* valueAxis = dynamic_cast<QValueAxis*>( plotAxis( axis ) ) )
{
return valueAxis->tickInterval();
}

return 0.0;
}

Expand Down
4 changes: 0 additions & 4 deletions ApplicationLibCode/UserInterface/RiuTextDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,7 @@ RiuTabbedTextDialog::RiuTabbedTextDialog( RiuTabbedTextProvider* textProvider, Q
textEdit->setContextMenuPolicy( Qt::NoContextMenu );

auto fontWidth = QFontMetrics( font ).boundingRect( "m" ).width();
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
textEdit->setTabStopDistance( fontWidth * 4 );
#else
textEdit->setTabStopWidth( fontWidth * 4 );
#endif

m_tabWidget->addTab( textEdit, tabTitle );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromFieldReference( PdmFieldHandle* f
if ( reference.isEmpty() ) return nullptr;
if ( reference.trimmed().isEmpty() ) return nullptr;

#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) )
auto SkipEmptyParts = QString::SkipEmptyParts;
#else
auto SkipEmptyParts = Qt::SkipEmptyParts;
#endif

QStringList decodedReference = reference.split( QRegularExpression( "\\s+" ), SkipEmptyParts );
QStringList decodedReference = reference.split( QRegularExpression( "\\s+" ), Qt::SkipEmptyParts );
PdmObjectHandle* lastCommonAnchestor = fromField->ownerObject();
CAF_ASSERT( lastCommonAnchestor );

Expand Down
14 changes: 1 addition & 13 deletions Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/caf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,24 @@ 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
22 changes: 0 additions & 22 deletions Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafFontTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@

#include <QApplication>

#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
#include <QDesktopWidget>
#endif

#include <cmath>

namespace caf
Expand Down Expand Up @@ -95,15 +91,6 @@ int FontTools::absolutePointSize( FontSize normalPointSize, RelativeSize relativ
//--------------------------------------------------------------------------------------------------
int FontTools::pointSizeToPixelSize( int pointSize )
{
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
auto app = dynamic_cast<const QApplication*>( QCoreApplication::instance() );
if ( app )
{
int dpi = app->desktop()->logicalDpiX();
double inches = pointSize / 72.0;
return static_cast<int>( std::ceil( inches * dpi ) );
}
#endif
return pointSize;
}

Expand All @@ -120,15 +107,6 @@ int FontTools::pointSizeToPixelSize( FontSize pointSize )
//--------------------------------------------------------------------------------------------------
int FontTools::pixelSizeToPointSize( int pixelSize )
{
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
auto app = dynamic_cast<const QApplication*>( QCoreApplication::instance() );
if ( app )
{
int dpi = app->desktop()->logicalDpiX();
double inches = pixelSize / dpi;
return static_cast<int>( std::ceil( inches * 72.0 ) );
}
#endif
return pixelSize;
}

Expand Down
46 changes: 0 additions & 46 deletions Fwk/AppFwk/cafUserInterface/cafAboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
#include <QVBoxLayout>
#include <QVariant>

#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
#include <QtOpenGL/QGLFormat>
#endif

namespace caf
{
//==================================================================================================
Expand Down Expand Up @@ -302,48 +298,6 @@ QString AboutDialog::versionStringForcurrentOpenGLContext()
{
QString versionString( "OpenGL " );

#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();

if ( flags & QGLFormat::OpenGL_Version_4_0 )
versionString += "4.0";
else if ( flags & QGLFormat::OpenGL_Version_3_3 )
versionString += "3.3";
else if ( flags & QGLFormat::OpenGL_Version_3_2 )
versionString += "3.2";
else if ( flags & QGLFormat::OpenGL_Version_3_1 )
versionString += "3.1";
else if ( flags & QGLFormat::OpenGL_Version_3_0 )
versionString += "3.0";
else if ( flags & QGLFormat::OpenGL_ES_Version_2_0 )
versionString += "ES_Version 2.0";
else if ( flags & QGLFormat::OpenGL_ES_CommonLite_Version_1_1 )
versionString += "ES_CommonLite_Version 1.1";
else if ( flags & QGLFormat::OpenGL_ES_Common_Version_1_1 )
versionString += "ES_Common_Version 1.1";
else if ( flags & QGLFormat::OpenGL_ES_CommonLite_Version_1_0 )
versionString += "ES_CommonLite_Version 1.0";
else if ( flags & QGLFormat::OpenGL_ES_Common_Version_1_0 )
versionString += "ES_Common_Version 1.0";
else if ( flags & QGLFormat::OpenGL_Version_2_1 )
versionString += "2.1";
else if ( flags & QGLFormat::OpenGL_Version_2_0 )
versionString += "2.0";
else if ( flags & QGLFormat::OpenGL_Version_1_5 )
versionString += "1.5";
else if ( flags & QGLFormat::OpenGL_Version_1_4 )
versionString += "1.4";
else if ( flags & QGLFormat::OpenGL_Version_1_3 )
versionString += "1.3";
else if ( flags & QGLFormat::OpenGL_Version_1_2 )
versionString += "1.2";
else if ( flags & QGLFormat::OpenGL_Version_1_1 )
versionString += "1.1";
else if ( flags & QGLFormat::OpenGL_Version_None )
versionString += "None";
else
versionString += "Unknown";
#endif
return versionString;
}

Expand Down
9 changes: 2 additions & 7 deletions Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@

#ifdef __linux__

#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) )
auto SkipEmptyParts = QString::SkipEmptyParts;
#else
auto SkipEmptyParts = Qt::SkipEmptyParts;
#endif

//--------------------------------------------------------------------------------------------------
/// Read bytes of memory of different types for current process from /proc/self/statm
Expand All @@ -47,7 +42,7 @@ std::map<QString, uint64_t> readProcessBytesLinux()
if (procSelfStatus.open(QIODevice::ReadOnly | QIODevice::Text))
{
QString line(procSelfStatus.readLine(256));
QStringList lineWords = line.split(QRegularExpression("\\s+"), SkipEmptyParts);
QStringList lineWords = line.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
quantities["VmSize"] = static_cast<uint64_t>(lineWords[0].toLongLong() * pageSize);
quantities["RSS"] = static_cast<uint64_t>(lineWords[1].toLongLong() * pageSize);
quantities["Shared"] = static_cast<uint64_t>(lineWords[2].toLongLong() * pageSize);
Expand Down Expand Up @@ -75,7 +70,7 @@ std::map<QString, uint64_t> readMemInfoLinuxMiB()
if (lineLength > 0)
{
QString line = QString::fromLatin1(buf, lineLength);
QStringList words = line.split(QRegularExpression(":*\\s+"), SkipEmptyParts);
QStringList words = line.split(QRegularExpression(":*\\s+"), Qt::SkipEmptyParts);
if (words.size() > 1)
{
bool ok = true;
Expand Down
4 changes: 0 additions & 4 deletions Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,7 @@ void PdmUiTreeSelectionEditor::slotInvertCheckedStateOfAll()
//--------------------------------------------------------------------------------------------------
void PdmUiTreeSelectionEditor::setCheckedStateForIntegerItemsMatchingFilter()
{
#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) )
auto SkipEmptyParts = QString::SkipEmptyParts;
#else
auto SkipEmptyParts = Qt::SkipEmptyParts;
#endif

std::set<int> filterValues;

Expand Down
5 changes: 0 additions & 5 deletions Fwk/AppFwk/cafViewer/cafCadNavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent )
{
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );

#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
QPoint cursorPosition = we->pos();
#else
QPoint cursorPosition = we->position().toPoint();
#endif

updatePointOfInterestDuringZoomIfNecessary( cursorPosition.x(), cursorPosition.y() );

if ( m_isRotCenterInitialized )
Expand Down
6 changes: 1 addition & 5 deletions Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,8 @@ void caf::CeetronNavigation::wheelEvent( QWheelEvent* event )
int navDelta = vpHeight / 5;
if ( event->angleDelta().y() < 0 ) navDelta *= -1;

#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
QPoint cursorPosition = event->pos();
#else
QPoint cursorPosition = event->position().toPoint();
#endif
int posY = m_viewer->height() - cursorPosition.y();
int posY = m_viewer->height() - cursorPosition.y();

m_trackball->startNavigation( ManipulatorTrackball::WALK, cursorPosition.x(), posY );

Expand Down
5 changes: 0 additions & 5 deletions Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent )
{
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );

#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
QPoint cursorPosition = we->pos();
#else
QPoint cursorPosition = we->position().toPoint();
#endif

updatePointOfInterestDuringZoomIfNecessary( cursorPosition.x(), cursorPosition.y() );

if ( m_isRotCenterInitialized )
Expand Down
10 changes: 0 additions & 10 deletions Fwk/VizFwk/TestApps/Qt/QtMinimal/QMWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,8 @@ void QMWidget::mouseMoveEvent(QMouseEvent* event)
if (m_renderSequence.isNull()) return;

Qt::MouseButtons mouseBn = event->buttons();
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
const int posX = event->position().toPoint().x();
const int posY = height() - event->position().toPoint().y();
#else
const int posX = event->x();
const int posY = height() - event->y();
#endif

cvf::ManipulatorTrackball::NavigationType navType = cvf::ManipulatorTrackball::NONE;
if (mouseBn == Qt::LeftButton)
Expand Down Expand Up @@ -186,13 +181,8 @@ void QMWidget::mousePressEvent(QMouseEvent* event)
{
if (m_renderSequence.isNull()) return;

#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
const int posX = event->position().toPoint().x();
const int posY = height() - event->position().toPoint().y();
#else
const int posX = event->x();
const int posY = height() - event->y();
#endif

if (event->buttons() == Qt::LeftButton &&
event->modifiers() == Qt::ControlModifier)
Expand Down
10 changes: 0 additions & 10 deletions Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,8 @@ void QMVWidget::mouseMoveEvent(QMouseEvent* event)
if (m_renderSequence.isNull()) return;

Qt::MouseButtons mouseBn = event->buttons();
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
const int posX = event->position().toPoint().x();
const int posY = height() - event->position().toPoint().y();
#else
const int posX = event->x();
const int posY = height() - event->y();
#endif

cvf::ManipulatorTrackball::NavigationType navType = cvf::ManipulatorTrackball::NONE;
if (mouseBn == Qt::LeftButton)
Expand Down Expand Up @@ -214,13 +209,8 @@ void QMVWidget::mousePressEvent(QMouseEvent* event)
{
if (m_renderSequence.isNull()) return;

#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
const int posX = event->position().toPoint().x();
const int posY = height() - event->position().toPoint().y();
#else
const int posX = event->x();
const int posY = height() - event->y();
#endif

if (event->buttons() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier)
{
Expand Down
10 changes: 0 additions & 10 deletions Fwk/VizFwk/TestApps/Qt/QtTestBenchOpenGLWidget/QTBVizWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,8 @@ void QTBVizWidget::mouseMoveEvent(QMouseEvent* event)
if (m_renderSequence.isNull()) return;

Qt::MouseButtons mouseBn = event->buttons();
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
const int posX = event->position().toPoint().x();
const int posY = height() - event->position().toPoint().y();
#else
const int posX = event->x();
const int posY = height() - event->y();
#endif

cvf::ManipulatorTrackball::NavigationType navType = cvf::ManipulatorTrackball::NONE;
if (mouseBn == Qt::LeftButton)
Expand Down Expand Up @@ -286,13 +281,8 @@ void QTBVizWidget::mousePressEvent(QMouseEvent* event)
{
if (m_renderSequence.isNull()) return;

#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
const int posX = event->position().toPoint().x();
const int posY = height() - event->position().toPoint().y();
#else
const int posX = event->x();
const int posY = height() - event->y();
#endif

if (event->buttons() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier)
{
Expand Down

0 comments on commit d2b0b35

Please sign in to comment.