Several adjustments related to Qt6

* Avoid ambiguous definition during unity build on Windows
* Add missing include
* Add Qt6 to expressionparser
* Add Qt6 to nightcharts
* Replace forward define of QStringList with include <QStringList>
* Use toMSecsSinceEpoch
* Use setContentsMargins
This commit is contained in:
Magne Sjaastad
2024-04-16 14:22:15 +02:00
committed by GitHub
parent 39b9a25faa
commit 030688cff6
30 changed files with 81 additions and 49 deletions
@@ -72,7 +72,7 @@ auto RiaRftPltCurveDefinition::operator<=>( const RiaRftPltCurveDefinition& othe
{ {
if ( m_wellName == other.m_wellName ) if ( m_wellName == other.m_wellName )
{ {
return m_timeStep.toTime_t() <=> other.m_timeStep.toTime_t(); return m_timeStep.toMSecsSinceEpoch() <=> other.m_timeStep.toMSecsSinceEpoch();
} }
return m_wellName.toStdString() <=> other.m_wellName.toStdString(); return m_wellName.toStdString() <=> other.m_wellName.toStdString();
} }
@@ -19,8 +19,7 @@
#pragma once #pragma once
#include <QString> #include <QString>
#include <QStringList>
class QStringList;
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@@ -18,13 +18,14 @@
#pragma once #pragma once
#include <QStringList>
#include <map> #include <map>
#include <memory> #include <memory>
#include <utility> #include <utility>
#include <vector> #include <vector>
class QString; class QString;
class QStringList;
class RimIdenticalGridCaseGroup; class RimIdenticalGridCaseGroup;
class RimRoffCase; class RimRoffCase;
@@ -18,6 +18,8 @@
#pragma once #pragma once
#include <QStringList>
#include <set> #include <set>
#include <vector> #include <vector>
@@ -26,7 +28,6 @@ class RifEclipseSummaryAddress;
class RimSummaryCaseCollection; class RimSummaryCaseCollection;
class QString; class QString;
class QStringList;
//================================================================================================== //==================================================================================================
// //
@@ -22,6 +22,7 @@
#include "RimObservedDataCollection.h" #include "RimObservedDataCollection.h"
#include <QString> #include <QString>
#include <QStringList>
#include <vector> #include <vector>
@@ -38,8 +39,6 @@ class RimObservedDataCollection;
class RimSummaryCurve; class RimSummaryCurve;
class RimUserDefinedCalculation; class RimUserDefinedCalculation;
class QStringList;
namespace caf namespace caf
{ {
class PdmObject; class PdmObject;
@@ -19,9 +19,9 @@
#pragma once #pragma once
#include <QString> #include <QString>
#include <map> #include <QStringList>
class QStringList; #include <map>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@@ -19,12 +19,13 @@
#pragma once #pragma once
#include <QString> #include <QString>
#include <QStringList>
#include <vector> #include <vector>
class RimEclipseCase; class RimEclipseCase;
class RimEclipseView; class RimEclipseView;
class RimWellPath; class RimWellPath;
class QStringList;
//================================================================================================== //==================================================================================================
// //
@@ -79,7 +79,7 @@ RicGridStatisticsDialog::RicGridStatisticsDialog( QWidget* parent )
dialogLayout->addWidget( m_mainViewWidget ); dialogLayout->addWidget( m_mainViewWidget );
QVBoxLayout* mainViewLayout = new QVBoxLayout(); QVBoxLayout* mainViewLayout = new QVBoxLayout();
mainViewLayout->setMargin( 0 ); mainViewLayout->setContentsMargins( 0, 0, 0, 0 );
m_mainViewWidget->setLayout( mainViewLayout ); m_mainViewWidget->setLayout( mainViewLayout );
mainViewLayout->addWidget( m_label ); mainViewLayout->addWidget( m_label );
mainViewLayout->addWidget( m_textEdit ); mainViewLayout->addWidget( m_textEdit );
@@ -18,6 +18,7 @@
#pragma once #pragma once
#include <QString> #include <QString>
#include <QStringList>
#include <set> #include <set>
#include <vector> #include <vector>
@@ -35,8 +36,6 @@ class RimSummaryCase;
class RimSummaryCaseCollection; class RimSummaryCaseCollection;
class RimEnsembleCurveSet; class RimEnsembleCurveSet;
class QStringList;
class RicSummaryPlotFeatureImpl class RicSummaryPlotFeatureImpl
{ {
public: public:
@@ -23,6 +23,7 @@
#include "RigCaseRealizationParameters.h" #include "RigCaseRealizationParameters.h"
#include <QString> #include <QString>
#include <QStringList>
#include <QTextStream> #include <QTextStream>
#include <map> #include <map>
@@ -30,7 +31,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
class QStringList;
class QTextStream; class QTextStream;
class QXmlStreamReader; class QXmlStreamReader;
class QFile; class QFile;
@@ -23,12 +23,12 @@
#include "ert/ecl/ecl_sum.hpp" #include "ert/ecl/ecl_sum.hpp"
#include <QString> #include <QString>
#include <QStringList>
#include <string> #include <string>
#include <vector> #include <vector>
class RifSummaryReaderInterface; class RifSummaryReaderInterface;
class QStringList;
//================================================================================================== //==================================================================================================
// //
@@ -18,13 +18,14 @@
#pragma once #pragma once
class QString; #include <QStringList>
class QDateTime;
class QStringList;
#include <cstddef> #include <cstddef>
#include <vector> #include <vector>
class QString;
class QDateTime;
//================================================================================================== //==================================================================================================
// //
// //
@@ -20,6 +20,8 @@
#pragma once #pragma once
#include <QIcon> #include <QIcon>
#include <QStringList>
#include <vector> #include <vector>
namespace caf namespace caf
@@ -28,7 +30,6 @@ class CmdFeatureMenuBuilder;
} }
class QString; class QString;
class QStringList;
class QMenu; class QMenu;
class RimWellPath; class RimWellPath;
class RimScriptCollection; class RimScriptCollection;
@@ -22,6 +22,7 @@
#include "cvfVector3.h" #include "cvfVector3.h"
#include <array> #include <array>
#include <list>
//================================================================================================== //==================================================================================================
/// Internal class for intersection point info /// Internal class for intersection point info
@@ -27,6 +27,8 @@
#include "cvfStructGrid.h" #include "cvfStructGrid.h"
#include "cvfVector3.h" #include "cvfVector3.h"
#include <QStringList>
#include <cmath> // Needed for HUGE_VAL on Linux #include <cmath> // Needed for HUGE_VAL on Linux
#include <deque> #include <deque>
#include <map> #include <map>
@@ -36,7 +38,6 @@ class RigActiveCellInfo;
class RigMainGrid; class RigMainGrid;
class RigCell; class RigCell;
class RigEclipseResultAddress; class RigEclipseResultAddress;
class QStringList;
class RigNNCData : public cvf::Object class RigNNCData : public cvf::Object
{ {
@@ -138,13 +138,13 @@ public:
{ {
int lineCount = 1 + posTickTypeText.second.label.count( "\n" ); int lineCount = 1 + posTickTypeText.second.label.count( "\n" );
mediumTextLineCount = std::max( mediumTextLineCount, lineCount ); mediumTextLineCount = std::max( mediumTextLineCount, lineCount );
medTickMaxTextSize = std::max( posTickTypeText.second.label.size(), medTickMaxTextSize ); medTickMaxTextSize = std::max( (int)posTickTypeText.second.label.size(), medTickMaxTextSize );
} }
else if ( posTickTypeText.second.tickType == QwtScaleDiv::MinorTick ) else if ( posTickTypeText.second.tickType == QwtScaleDiv::MinorTick )
{ {
int lineCount = 1 + posTickTypeText.second.label.count( "\n" ); int lineCount = 1 + posTickTypeText.second.label.count( "\n" );
minorTextLineCount = std::max( minorTextLineCount, lineCount ); minorTextLineCount = std::max( minorTextLineCount, lineCount );
minTickMaxTextSize = std::max( posTickTypeText.second.label.size(), minTickMaxTextSize ); minTickMaxTextSize = std::max( (int)posTickTypeText.second.label.size(), minTickMaxTextSize );
} }
} }
@@ -63,7 +63,7 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl
QGridLayout* mainLayout = new QGridLayout(); QGridLayout* mainLayout = new QGridLayout();
setLayout( mainLayout ); setLayout( mainLayout );
layout()->setMargin( 3 ); layout()->setContentsMargins( 3, 3, 3, 3 );
layout()->setSpacing( 3 ); layout()->setSpacing( 3 );
// White background // White background
@@ -20,11 +20,11 @@
#pragma once #pragma once
#include <QStringList>
#include <QWidget> #include <QWidget>
class QPaintEvent; class QPaintEvent;
class QString; class QString;
class QStringList;
class RiuGridStatisticsHistogramWidget : public QWidget class RiuGridStatisticsHistogramWidget : public QWidget
{ {
@@ -44,7 +44,10 @@ RiuMessagePanel::RiuMessagePanel( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
{ {
QVBoxLayout* layout = new QVBoxLayout( this ); QVBoxLayout* layout = new QVBoxLayout( this );
layout->setMargin( caf::StyleSheetTools::smallContentMargin() ); layout->setContentsMargins( caf::StyleSheetTools::smallContentMargin(),
caf::StyleSheetTools::smallContentMargin(),
caf::StyleSheetTools::smallContentMargin(),
caf::StyleSheetTools::smallContentMargin() );
m_textEdit = new QPlainTextEdit; m_textEdit = new QPlainTextEdit;
m_textEdit->setReadOnly( true ); m_textEdit->setReadOnly( true );
@@ -91,7 +91,7 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare
CAF_ASSERT( m_plotDefinition ); CAF_ASSERT( m_plotDefinition );
m_layout = new QVBoxLayout( this ); m_layout = new QVBoxLayout( this );
m_layout->setMargin( 0 ); m_layout->setContentsMargins( 0, 0, 0, 0 );
m_layout->setSpacing( 4 ); m_layout->setSpacing( 4 );
m_plotTitle = createTitleLabel(); m_plotTitle = createTitleLabel();
@@ -74,7 +74,7 @@ RiuProjectAndPropertyView::RiuProjectAndPropertyView( QWidget* parent, Qt::Windo
propertyHeader->setFixedHeight( 20 ); propertyHeader->setFixedHeight( 20 );
QVBoxLayout* layout = new QVBoxLayout; QVBoxLayout* layout = new QVBoxLayout;
layout->setMargin( 0 ); layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( propertyHeader ); layout->addWidget( propertyHeader );
layout->addWidget( m_propertyView ); layout->addWidget( m_propertyView );
@@ -87,7 +87,7 @@ RiuProjectAndPropertyView::RiuProjectAndPropertyView( QWidget* parent, Qt::Windo
splitter->addWidget( propertyEditorWithHeader ); splitter->addWidget( propertyEditorWithHeader );
QVBoxLayout* layout = new QVBoxLayout; QVBoxLayout* layout = new QVBoxLayout;
layout->setMargin( 0 ); layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( splitter ); layout->addWidget( splitter );
setLayout( layout ); setLayout( layout );
@@ -19,6 +19,7 @@
#pragma once #pragma once
#include <QDialog> #include <QDialog>
#include <QStringList>
namespace caf namespace caf
{ {
@@ -29,7 +30,6 @@ class PdmUiPropertyView;
class QDialogButtonBox; class QDialogButtonBox;
class QWidget; class QWidget;
class QString; class QString;
class QStringList;
class RiuPropertyViewTabWidget : public QDialog class RiuPropertyViewTabWidget : public QDialog
{ {
@@ -999,7 +999,7 @@ QString RiuResultTextBuilder::cellResultText( const std::vector<RimEclipseResult
auto resultTextAndValues = cellResultTextAndValueText( resDef ); auto resultTextAndValues = cellResultTextAndValueText( resDef );
for ( const auto& [key, value] : resultTextAndValues ) for ( const auto& [key, value] : resultTextAndValues )
{ {
maxKeyLength = std::max( maxKeyLength, key.length() ); maxKeyLength = std::max( maxKeyLength, (int)key.length() );
keyValues[key] = value; keyValues[key] = value;
} }
} }
@@ -20,11 +20,10 @@
#pragma once #pragma once
#include <QStringList>
#include <QWidget> #include <QWidget>
class QPaintEvent; class QPaintEvent;
class QString;
class QStringList;
class RiuSimpleHistogramWidget : public QWidget class RiuSimpleHistogramWidget : public QWidget
{ {
@@ -46,7 +46,7 @@ RiuWellAllocationPlot::RiuWellAllocationPlot( RimWellAllocationPlot* plotDefinit
QVBoxLayout* mainLayout = new QVBoxLayout(); QVBoxLayout* mainLayout = new QVBoxLayout();
setLayout( mainLayout ); setLayout( mainLayout );
layout()->setMargin( 0 ); layout()->setContentsMargins( 0, 0, 0, 0 );
layout()->setSpacing( 2 ); layout()->setSpacing( 2 );
m_titleLabel = new QLabel( this ); m_titleLabel = new QLabel( this );
+17 -7
View File
@@ -11,13 +11,23 @@ set(MOC_HEADER_FILES cafFrameAnimationControl.h cafAnimationToolBar.h
cafPopupMenuButton.h cafPopupMenuButton.h
) )
find_package( if(CEE_USE_QT6)
Qt5 find_package(
COMPONENTS Qt6
REQUIRED Core Gui Widgets COMPONENTS
) REQUIRED Core Gui Widgets
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets) )
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets)
qt_standard_project_setup()
else()
find_package(
Qt5
COMPONENTS
REQUIRED Core Gui Widgets
)
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets)
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
endif()
# NOTE! Resources in this subfolder appends to the variable QRC_FILES in parent # NOTE! Resources in this subfolder appends to the variable QRC_FILES in parent
# scope CMakeList.txt in the application folder (parent scope) must use the # scope CMakeList.txt in the application folder (parent scope) must use the
@@ -34,7 +34,13 @@
// //
//################################################################################################## //##################################################################################################
// This include is required to avoid ambiguous definition during unity build
#ifdef WIN32
#include <windows.h>
#endif // WIN32
#include "cafProgressInfo.h" #include "cafProgressInfo.h"
#include "cafAssert.h" #include "cafAssert.h"
#include "cafMemoryInspector.h" #include "cafMemoryInspector.h"
#include "cafProgressState.h" #include "cafProgressState.h"
+8 -3
View File
@@ -7,9 +7,14 @@ if(MSVC)
message(STATUS "MSVC: Enabled increased number of sections in object files") message(STATUS "MSVC: Enabled increased number of sections in object files")
endif() endif()
if (CEE_USE_QT6)
find_package(Qt5 COMPONENTS REQUIRED Core) find_package(Qt6 COMPONENTS REQUIRED Core)
set(QT_LIBRARIES Qt5::Core) set(QT_LIBRARIES Qt6::Core)
qt_standard_project_setup()
else()
find_package(Qt5 COMPONENTS REQUIRED Core)
set(QT_LIBRARIES Qt5::Core)
endif()
list (APPEND MAIN_SOURCE_FILES list (APPEND MAIN_SOURCE_FILES
ExpressionParser.h ExpressionParser.h
+8 -3
View File
@@ -2,9 +2,14 @@ cmake_minimum_required (VERSION 2.8.12)
project (nightcharts) project (nightcharts)
find_package(Qt5 COMPONENTS REQUIRED Core Widgets) if (CEE_USE_QT6)
set(QT_LIBRARIES Qt5::Core Qt5::Widgets) find_package(Qt6 COMPONENTS REQUIRED Core Gui Widgets)
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES}) set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets)
qt_standard_project_setup()
else()
find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets)
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets)
endif()
list (APPEND MAIN_SOURCE_FILES list (APPEND MAIN_SOURCE_FILES
nightcharts.h nightcharts.h
+3 -3
View File
@@ -330,7 +330,7 @@ int Nightcharts::draw(QPainter *painter)
painter->drawRect(cX+pDist+i*(pW + pDist),cY+cH,pW,-cH/100*pieces[i].pPerc-5); painter->drawRect(cX+pDist+i*(pW + pDist),cY+cH,pW,-cH/100*pieces[i].pPerc-5);
QString label = QString::number(pieces[i].pPerc)+"%"; QString label = QString::number(pieces[i].pPerc)+"%";
painter->setPen(Qt::SolidLine); painter->setPen(Qt::SolidLine);
painter->drawText(cX+pDist+i*(pW + pDist)+pW/2-painter->fontMetrics().width(label)/2,cY+cH-cH/100*pieces[i].pPerc-painter->fontMetrics().height()/2,label); painter->drawText(cX+pDist+i*(pW + pDist)+pW/2-painter->fontMetrics().horizontalAdvance(label)/2,cY+cH-cH/100*pieces[i].pPerc-painter->fontMetrics().height()/2,label);
} }
painter->setPen(Qt::SolidLine); painter->setPen(Qt::SolidLine);
for (int i=1;i<10;i++) for (int i=1;i<10;i++)
@@ -386,12 +386,12 @@ void Nightcharts::drawLegend(QPainter *painter)
} }
painter->drawLine(p.x(),p.y(),p_.x(),p_.y()); painter->drawLine(p.x(),p.y(),p_.x(),p_.y());
QString label = pieces[i].pname + " - " + QString::number(pieces[i].pPerc)+"%"; QString label = pieces[i].pname + " - " + QString::number(pieces[i].pPerc)+"%";
float recW = painter->fontMetrics().width(label)+10; float recW = painter->fontMetrics().horizontalAdvance(label)+10;
float recH = painter->fontMetrics().height()+10; float recH = painter->fontMetrics().height()+10;
p_.setX(p_.x()-recW/2 + recW/2*cos(angle*M_PI/180)); p_.setX(p_.x()-recW/2 + recW/2*cos(angle*M_PI/180));
p_.setY(p_.y()+recH/2 + recH/2*sin(angle*M_PI/180)); p_.setY(p_.y()+recH/2 + recH/2*sin(angle*M_PI/180));
painter->setBrush(textColor); painter->setBrush(textColor);
painter->drawRoundRect(p_.x() ,p_.y(), recW, -recH); painter->drawRect(p_.x() ,p_.y(), recW, -recH);
painter->drawText(p_.x()+5, p_.y()-recH/2+5, label); painter->drawText(p_.x()+5, p_.y()-recH/2+5, label);
angle -= pdegree/2; angle -= pdegree/2;
} }