Update to Qt6

- New baseline minimum platform is Ubuntu 22.04
    - Qt6 requires at least 6.2
        - some deprecations may be flagged on later versions (e.g. 6.8)
    - CMake requires at least 3.22
- Include build-tests.yml github action to validate builds on mulitple platforms
- QtTest is no longer optional since it easily comes along for the ride with Qt
- Replaced QStringRef in model::SubstitutionField with simple ParserState class
- Removed deprecations up to Qt 6.2
This commit is contained in:
Jaye Evins
2025-05-06 18:26:53 -04:00
parent f683896706
commit f15c21a01d
42 changed files with 478 additions and 226 deletions
+26 -26
View File
@@ -1,99 +1,99 @@
if (Qt5Test_FOUND)
if (Qt6Test_FOUND)
#=======================================
# Test SubstitutionField class
#=======================================
qt5_wrap_cpp (TestSubstitutionField_moc_sources TestSubstitutionField.h)
qt6_wrap_cpp (TestSubstitutionField_moc_sources TestSubstitutionField.h)
add_executable (TestSubstitutionField TestSubstitutionField.cpp ${TestSubstitutionField_moc_sources})
target_link_libraries (TestSubstitutionField Model Qt5::Test)
target_link_libraries (TestSubstitutionField Model Qt6::Test)
add_test (NAME SubstitutionField COMMAND TestSubstitutionField)
#=======================================
# Test XmlUtil class
#=======================================
qt5_wrap_cpp (TestXmlUtil_moc_sources TestXmlUtil.h)
qt6_wrap_cpp (TestXmlUtil_moc_sources TestXmlUtil.h)
add_executable (TestXmlUtil TestXmlUtil.cpp ${TestXmlUtil_moc_sources})
target_link_libraries (TestXmlUtil Model Qt5::Test)
target_link_libraries (TestXmlUtil Model Qt6::Test)
add_test (NAME XmlUtil COMMAND TestXmlUtil)
#=======================================
# Test XmlLabelCreator/Parser classes
#=======================================
qt5_wrap_cpp (TestXmlLabel_moc_sources TestXmlLabel.h)
qt6_wrap_cpp (TestXmlLabel_moc_sources TestXmlLabel.h)
add_executable (TestXmlLabel TestXmlLabel.cpp ${TestXmlLabel_moc_sources})
target_link_libraries (TestXmlLabel Model Qt5::Test)
target_link_libraries (TestXmlLabel Model Qt6::Test)
add_test (NAME XmlLabel COMMAND TestXmlLabel)
#=======================================
# Test ColorNode class
#=======================================
qt5_wrap_cpp (TestColorNode_moc_sources TestColorNode.h)
qt6_wrap_cpp (TestColorNode_moc_sources TestColorNode.h)
add_executable (TestColorNode TestColorNode.cpp ${TestColorNode_moc_sources})
target_link_libraries (TestColorNode Model Qt5::Test)
target_link_libraries (TestColorNode Model Qt6::Test)
add_test (NAME ColorNode COMMAND TestColorNode)
#=======================================
# Test FileUtil class
#=======================================
qt5_wrap_cpp (TestFileUtil_moc_sources TestFileUtil.h)
qt6_wrap_cpp (TestFileUtil_moc_sources TestFileUtil.h)
add_executable (TestFileUtil TestFileUtil.cpp ${TestFileUtil_moc_sources})
target_link_libraries (TestFileUtil Model Qt5::Test)
target_link_libraries (TestFileUtil Model Qt6::Test)
add_test (NAME FileUtil COMMAND TestFileUtil)
#=======================================
# Test Merge classes
#=======================================
qt5_wrap_cpp (TestMerge_moc_sources TestMerge.h)
qt6_wrap_cpp (TestMerge_moc_sources TestMerge.h)
add_executable (TestMerge TestMerge.cpp ${TestMerge_moc_sources})
target_link_libraries (TestMerge Model Qt5::Test)
target_link_libraries (TestMerge Model Qt6::Test)
add_test (NAME Merge COMMAND TestMerge)
#=======================================
# Test Model class
#=======================================
qt5_wrap_cpp (TestModel_moc_sources TestModel.h)
qt6_wrap_cpp (TestModel_moc_sources TestModel.h)
add_executable (TestModel TestModel.cpp ${TestModel_moc_sources})
target_link_libraries (TestModel Model Qt5::Test)
target_link_libraries (TestModel Model Qt6::Test)
add_test (NAME Model COMMAND TestModel)
#=======================================
# Test ModelImageObject class
#=======================================
qt5_wrap_cpp (TestModelImageObject_moc_sources TestModelImageObject.h)
qt6_wrap_cpp (TestModelImageObject_moc_sources TestModelImageObject.h)
add_executable (TestModelImageObject TestModelImageObject.cpp ${TestModelImageObject_moc_sources})
target_link_libraries (TestModelImageObject Model Qt5::Test)
target_link_libraries (TestModelImageObject Model Qt6::Test)
add_test (NAME ModelImageObject COMMAND TestModelImageObject)
#=======================================
# Test RawText class
#=======================================
qt5_wrap_cpp (TestRawText_moc_sources TestRawText.h)
qt6_wrap_cpp (TestRawText_moc_sources TestRawText.h)
add_executable (TestRawText TestRawText.cpp ${TestRawText_moc_sources})
target_link_libraries (TestRawText Model Qt5::Test)
target_link_libraries (TestRawText Model Qt6::Test)
add_test (NAME RawText COMMAND TestRawText)
#=======================================
# Test TextNode class
#=======================================
qt5_wrap_cpp (TestTextNode_moc_sources TestTextNode.h)
qt6_wrap_cpp (TestTextNode_moc_sources TestTextNode.h)
add_executable (TestTextNode TestTextNode.cpp ${TestTextNode_moc_sources})
target_link_libraries (TestTextNode Model Qt5::Test)
target_link_libraries (TestTextNode Model Qt6::Test)
add_test (NAME TextNode COMMAND TestTextNode)
#=======================================
# Test Variable class
#=======================================
qt5_wrap_cpp (TestVariable_moc_sources TestVariable.h)
qt6_wrap_cpp (TestVariable_moc_sources TestVariable.h)
add_executable (TestVariable TestVariable.cpp ${TestVariable_moc_sources})
target_link_libraries (TestVariable Model Qt5::Test)
target_link_libraries (TestVariable Model Qt6::Test)
add_test (NAME Variable COMMAND TestVariable)
#=======================================
# Test Variables class
#=======================================
qt5_wrap_cpp (TestVariables_moc_sources TestVariables.h)
qt6_wrap_cpp (TestVariables_moc_sources TestVariables.h)
add_executable (TestVariables TestVariables.cpp ${TestVariables_moc_sources})
target_link_libraries (TestVariables Model Qt5::Test)
target_link_libraries (TestVariables Model Qt6::Test)
add_test (NAME Variables COMMAND TestVariables)
endif (Qt5Test_FOUND)
endif (Qt6Test_FOUND)
+3 -2
View File
@@ -36,7 +36,8 @@
#include "merge/TextCsv.h"
#include "merge/TextCsvKeys.h"
#include <QtDebug>
#include <QDebug>
#include <QRegularExpression>
QTEST_MAIN(TestModel)
@@ -59,7 +60,7 @@ void TestModel::model()
model.clearModified();
QVERIFY( !model.isModified() );
QVERIFY( model.shortName().contains( QRegExp( "^Untitled[1-9][0-9]*$" ) ) );
QVERIFY( model.shortName().contains( QRegularExpression( "^Untitled[1-9][0-9]*$" ) ) );
model.setFileName( "dir/file1.ext" );
QCOMPARE( model.fileName(), QString( "dir/file1.ext" ) );
QCOMPARE( model.shortName(), QString( "file1" ) );
+14 -14
View File
@@ -34,7 +34,7 @@ void TestSubstitutionField::parseValid()
// Valid substitution fields (concatenated in single input string)
//
QString input = "${1234}${abc:=ABC}${x:%08.2f}${y:%08.2f:=12.34}${ADDR2:n}${FüññýßútLæg@lѪmê}${Also_a legal-name}";
QStringRef s = &input;
model::ParserState s( input );
model::SubstitutionField f1;
QCOMPARE( model::SubstitutionField::parse( s, f1 ), true );
@@ -87,49 +87,49 @@ void TestSubstitutionField::parseInvalid()
// Ordinary text
//
QString input5 = "Abcdefg";
QStringRef s5 = &input5;
model::ParserState s5( input5 );
model::SubstitutionField f5;
QCOMPARE( model::SubstitutionField::parse( s5, f5 ), false );
QCOMPARE( s5, QStringRef( &input5 ) ); // Should not advance string reference
QCOMPARE( s5.pos(), model::ParserState( input5 ).pos() ); // Should not advance string reference
//
// Invalid substitution fields (which are treated as ordinary text)
//
QString input6 = "$abc";
QStringRef s6 = &input6;
model::ParserState s6( input6 );
model::SubstitutionField f6;
QCOMPARE( model::SubstitutionField::parse( s6, f6 ), false );
QCOMPARE( s6, QStringRef( &input6 ) ); // Should not advance string reference
QCOMPARE( s6.pos(), model::ParserState( input6 ).pos() ); // Should not advance string reference
QString input7 = "${abc";
QStringRef s7 = &input7;
model::ParserState s7( input7 );
model::SubstitutionField f7;
QCOMPARE( model::SubstitutionField::parse( s7, f7 ), false );
QCOMPARE( s7, QStringRef( &input7 ) ); // Should not advance string reference
QCOMPARE( s7.pos(), model::ParserState( input7 ).pos() ); // Should not advance string reference
QString input8 = "${abc:}";
QStringRef s8 = &input8;
model::ParserState s8( input8 );
model::SubstitutionField f8;
QCOMPARE( model::SubstitutionField::parse( s8, f8 ), false );
QCOMPARE( s8, QStringRef( &input8 ) ); // Should not advance string reference
QCOMPARE( s8.pos(), model::ParserState( input8 ).pos() ); // Should not advance string reference
// Even though format is invalid, let it slide. Overall structure still good. Format will be ignored.
QString input9 = "${abc:%3.2}";
QStringRef s9 = &input9;
model::ParserState s9( input9 );
model::SubstitutionField f9;
QCOMPARE( model::SubstitutionField::parse( s9, f9 ), true );
QString input10 = "${embedded\nnew-line}";
QStringRef s10 = &input10;
model::ParserState s10( input10 );
model::SubstitutionField f10;
QCOMPARE( model::SubstitutionField::parse( s10, f10 ), false );
QCOMPARE( s10, QStringRef( &input10 ) ); // Should not advance string reference
QCOMPARE( s10.pos(), model::ParserState( input10 ).pos() ); // Should not advance string reference
QString input11 = "${how-about-a\ttab}";
QStringRef s11 = &input11;
model::ParserState s11( input11 );
model::SubstitutionField f11;
QCOMPARE( model::SubstitutionField::parse( s11, f11 ), false );
QCOMPARE( s11, QStringRef( &input11 ) ); // Should not advance string reference
QCOMPARE( s11.pos(), model::ParserState( input11 ).pos() ); // Should not advance string reference
}