diff --git a/.github/workflows/build-tests.yml b/.github/workflows/build-tests.yml new file mode 100644 index 0000000..e560705 --- /dev/null +++ b/.github/workflows/build-tests.yml @@ -0,0 +1,110 @@ +# This workflow performs test builds across a diversity of supported platforms +# +# - ubuntu-latest - gcc +# - ubuntu-latest - clang +# - ubuntu-24.04 - gcc (For backwards compatablity) +# - windows-latest - cl +# +# TODO: +# - macos +# - install optional dependencies for windows-latest test build + + +name: Multi-Platform Build Tests + +on: + push: + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + + matrix: + os: [ubuntu-latest, ubuntu-22.04, windows-latest] + build_type: [Release] + c_compiler: [gcc, clang, cl] + include: + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + - os: ubuntu-latest + c_compiler: clang + cpp_compiler: clang++ + - os: ubuntu-22.04 + c_compiler: gcc + cpp_compiler: g++ + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + exclude: + - os: ubuntu-latest + c_compiler: cl + - os: ubuntu-22.04 + c_compiler: clang + - os: ubuntu-22.04 + c_compiler: cl + - os: windows-latest + c_compiler: gcc + - os: windows-latest + c_compiler: clang + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # Checkout full-depth to facilitate auto versioning + fetch-depth: 0 + + - name: Install optional dependencies (Ubuntu) + shell: bash + if: startsWith( matrix.os, 'ubuntu-' ) + run: | + # install packages + sudo apt-get update + sudo apt-get -y install xvfb + sudo apt-get -y install pkgconf libqrencode-dev + sudo apt-get -y install barcode + # install zint-2.6.5 from source + # - 2.6.5 is last version that works with glabels-qt + # - currently must be done before qt installed, because of errors + # trying to build qzint + wget https://downloads.sourceforge.net/project/zint/zint/2.6.5/zint-2.6.5.tar.gz && tar xzf zint-2.6.5.tar.gz && ( cd zint-2.6.5 && mkdir build && cd build && cmake .. && make && sudo make install ) + + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + version: '6.2.*' + install-deps: 'true' + archives: 'qtbase qtsvg qttools icu' + + - name: Set reusable strings + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Configure CMake + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Test (Ubuntu) + if: startsWith( matrix.os, 'ubuntu-' ) + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: xvfb-run ctest --build-config ${{ matrix.build_type }} + + - name: Test (Windows) + if: startsWith( matrix.os, 'windows-' ) + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: ctest --build-config ${{ matrix.build_type }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 6486262..1711af8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.9) +cmake_minimum_required (VERSION 3.22) ############################################################################### # gLabels Label Designer Project @@ -111,12 +111,7 @@ if (MINGW) set (CMAKE_PREFIX_PATH ${MINGW_BASE_DIR} ) endif () -find_package (Qt5Core 5.15 REQUIRED) -find_package (Qt5Widgets 5.15 REQUIRED) -find_package (Qt5PrintSupport 5.15 REQUIRED) -find_package (Qt5Xml 5.15 REQUIRED) -find_package (Qt5Svg 5.15 REQUIRED) -find_package (Qt5LinguistTools) +find_package (Qt6 6.2 REQUIRED COMPONENTS Core Gui Widgets PrintSupport Xml Svg LinguistTools Test) if (WIN32) # Locate Qt directories @@ -131,8 +126,6 @@ find_package (ZLIB 1.2 QUIET) find_package (GnuBarcode 0.98 QUIET) find_package (LibQrencode 3.4 QUIET) find_package (LibZint 2.6 EXACT QUIET) -# Unit testing support -find_package (Qt5Test 5.6 QUIET) #======================================= @@ -143,7 +136,7 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") # Uncomment to compile everything with aggressively pedantic options # (not recommended -- only for testing -- also not portable) # - #add_compile_options("-Wall" "-Werror" "-Wpedantic") + #add_compile_options("-Wall" "-Wextra" "-Wpedantic" "-Wno-unused-parameter" "-Werror") # Uncomment to always compile with debug symbols add_compile_options("-g") @@ -153,7 +146,7 @@ endif () #======================================= # Unit Testing #======================================= -if (Qt5Test_FOUND) +if (Qt6Test_FOUND) enable_testing () endif () @@ -177,11 +170,13 @@ add_subdirectory (data) message (STATUS "") message (STATUS "Project name ............ " ${CMAKE_PROJECT_NAME}) message (STATUS "Project version ......... " ${LONG_VERSION_STRING}) +message (STATUS "Host system ............. " ${CMAKE_HOST_SYSTEM} " " ${CMAKE_HOST_SYSTEM_PROCESSOR}) +message (STATUS "Target system ........... " ${CMAKE_SYSTEM} " " ${CMAKE_SYSTEM_PROCESSOR}) message (STATUS "Installation prefix ..... " ${CMAKE_INSTALL_PREFIX}) message (STATUS "Source code location .... " ${glabels_SOURCE_DIR}) message (STATUS "CMake version ........... " ${CMAKE_VERSION}) message (STATUS "C++ Compiler ............ " ${CMAKE_CXX_COMPILER_ID} " " ${CMAKE_CXX_COMPILER} " " ${CMAKE_CXX_COMPILER_VERSION}) -message (STATUS "Qt version .............. " ${Qt5Core_VERSION}) +message (STATUS "Qt version .............. " ${Qt6Core_VERSION}) if (ZLIB_FOUND) message (STATUS "zlib (optional).......... " ${ZLIB_VERSION_STRING}) @@ -207,12 +202,6 @@ else (LIBZINT_FOUND) message (STATUS "libzint (optional)....... No.") endif (LIBZINT_FOUND) -if (Qt5Test_FOUND) - message (STATUS "QtTest (optional)........ " ${Qt5Test_VERSION}) -else (Qt5Test_FOUND) - message (STATUS "QtTest (optional)........ No.") -endif (Qt5Test_FOUND) - if (MSVC) message (STATUS "MSVC Qt location ........ " ${QT_BASE_DIR}) endif (MSVC) diff --git a/README.md b/README.md index 16eba36..3d879bd 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ ![Cover Image](docs/images/cover-image.png) -[![Travis Build Status](https://travis-ci.org/j-evins/glabels-qt.svg?branch=master)](https://travis-ci.org/j-evins/glabels-qt) -[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/j-evins/glabels-qt?branch=master&svg=true)](https://ci.appveyor.com/project/j-evins/glabels-qt) +[![Multi-Platform Build Tests](https://github.com/j-evins/glabels-qt/actions/workflows/build-tests.yml/badge.svg?branch=master&event=push)](https://github.com/j-evins/glabels-qt/actions/workflows/build-tests.yml) ******************************************************************************* @@ -89,3 +88,4 @@ restrictive licensing: label database. No copyright is claimed on the facts contained within the database and can be used for any purpose. The files themselves are licensed using the MIT/X license. See [templates/LICENSE](templates/LICENSE). + diff --git a/backends/barcode/CMakeLists.txt b/backends/barcode/CMakeLists.txt index a4b1e34..daa6f31 100644 --- a/backends/barcode/CMakeLists.txt +++ b/backends/barcode/CMakeLists.txt @@ -39,7 +39,7 @@ set (barcode_qobject_headers Backends.h ) -qt5_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers}) +qt6_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers}) #===================================== # Target @@ -60,7 +60,7 @@ target_include_directories (Barcode target_link_libraries (Barcode glbarcode - Qt5::Core + Qt6::Core ${OPTIONAL_GNUBARCODE} ${OPTIONAL_ZINT} ${OPTIONAL_QRENCODE} diff --git a/backends/merge/CMakeLists.txt b/backends/merge/CMakeLists.txt index bc8d413..b5e7818 100644 --- a/backends/merge/CMakeLists.txt +++ b/backends/merge/CMakeLists.txt @@ -23,7 +23,7 @@ set (merge_qobject_headers Merge.h ) -qt5_wrap_cpp (merge_moc_sources ${merge_qobject_headers}) +qt6_wrap_cpp (merge_moc_sources ${merge_qobject_headers}) #===================================== # Target @@ -43,5 +43,5 @@ target_include_directories (Merge ) target_link_libraries (Merge - Qt5::Core + Qt6::Core ) diff --git a/cmake/Modules/FindGnuBarcode.cmake b/cmake/Modules/FindGnuBarcode.cmake index 01ca230..5e56ff1 100644 --- a/cmake/Modules/FindGnuBarcode.cmake +++ b/cmake/Modules/FindGnuBarcode.cmake @@ -36,6 +36,9 @@ endif () if (GNUBARCODE_INCLUDE_DIR AND EXISTS "${GNUBARCODE_INCLUDE_DIR}/barcode.h") file (STRINGS "${GNUBARCODE_INCLUDE_DIR}/barcode.h" BARCODE_H REGEX "^#define BARCODE_VERSION *\"[^\"]*\"") string (REGEX REPLACE "^.*VERSION *\"([^\"]*)\"" "\\1" GNUBARCODE_VERSION_STRING "${BARCODE_H}") + if (NOT "${BARCODE_H}") + set(GNUBARCODE_VERSION_STRING "0.99") # ubuntu v0.99 may have barcode.h, but no version string + endif() endif() # handle the QUIETLY and REQUIRED arguments and set GNUBARCODE_FOUND to TRUE if diff --git a/docs/BUILD-INSTRUCTIONS-LINUX.md b/docs/BUILD-INSTRUCTIONS-LINUX.md index ee93da0..aa665a9 100644 --- a/docs/BUILD-INSTRUCTIONS-LINUX.md +++ b/docs/BUILD-INSTRUCTIONS-LINUX.md @@ -5,8 +5,8 @@ gLabels Linux Build Instructions ### Prerequisites - g++ -- CMake 2.8.12+ -- Qt5 5.15+ Development Packages ( Qt5Core, Qt5Widgets, Qt5PrintSupport, Qt5Xml, Qt5Svg ) +- CMake 3.22+ +- Qt6 6.2+ Development Packages ( Qt6Core, Qt6Widgets, Qt6PrintSupport, Qt6Xml, Qt6Svg, Qt6Test ) - zlib 1.2+ Development Package > Even if the above library packages are installed, their corresponding development packages @@ -26,36 +26,32 @@ $ make $ sudo make install -## Example: Ubuntu 19.04 + +## Example: Ubuntu 24.04 ### Installing Prerequisites ``` -sudo apt install cmake -sudo apt install qtbase5-dev libqt5svg5-dev qttools5-dev zlib1g-dev +$ sudo apt install cmake +$ sudo apt install qt6-base-dev qt6-svg-dev qt6-tools-dev zlib1g-dev ``` _QREncode (Optional)_ ``` -sudo apt install pkgconf libqrencode-dev +$ sudo apt install pkgconf libqrencode-dev ``` _Zint (Optional)_ Install zint from source: ``` -wget https://downloads.sourceforge.net/project/zint/zint/2.6.3/zint-2.6.3_final.tar.gz -tar xzf zint-2.6.3_final.tar.gz -cd zint-2.6.3.src/ -mkdir build && cd build && cmake .. && make -sudo make install +$ wget https://downloads.sourceforge.net/project/zint/zint/2.6.3/zint-2.6.3_final.tar.gz +$ tar xzf zint-2.6.3_final.tar.gz +$ cd zint-2.6.3.src/ +$ mkdir build && cd build && cmake .. && make +$ sudo make install ``` _GNU Barcode (Optional)_ -As of version 0.99, GNU Barcode no longer installs its library. So install 0.98 from source: ``` -wget https://ftp.gnu.org/gnu/barcode/barcode-0.98.tar.gz -tar xzf barcode-0.98.tar.gz -cd barcode-0.98/ -./configure && make -sudo make install +$ sudo apt install barcode ``` ### Compile and Install gLabels @@ -67,6 +63,8 @@ $ cmake .. $ make $ sudo make install ``` + + ## Example: Fedora 35 ### Installing Prerequisites @@ -76,12 +74,12 @@ We assume the build system already has things like cmake and the GNU C++ suite i $ sudo dnf install qt5-qtbase-devel qt5-qtsvg-devel qt5-linguist qt5-qttools ``` These installs will pull in additional packages to fill out their prerequisites. -Fedora has a different package naming scheme that Ubuntu. This is to distinguish the QT5 +Fedora has a different package naming scheme that Ubuntu. This is to distinguish the QT6 packages from the QT3 and QT4 packages that they still support for compatibility. If the Cmake pass or build has missing package errors or warnings, you can search for the needed package with: ``` -$ sudo dnf search qt5 |grep +$ sudo dnf search qt6 |grep ``` ### Compile and Install gLabels into /usr/local diff --git a/docs/BUILD-INSTRUCTIONS-WINDOWS.md b/docs/BUILD-INSTRUCTIONS-WINDOWS.md index 83f8921..c99613f 100644 --- a/docs/BUILD-INSTRUCTIONS-WINDOWS.md +++ b/docs/BUILD-INSTRUCTIONS-WINDOWS.md @@ -13,8 +13,8 @@ Visual Studio ### Prerequisites - Visual Studio (these instructions are for _Visual Studio 15 2017 Win64_) -- CMake 3.2+ -- Qt5 5.9+ for your version of Visual Studio +- CMake 3.22+ +- Qt6 6.2+ for your version of Visual Studio - NSIS 3.03+ (optional -- for creating an installer) Make sure that CMake and the Qt tools are in your executable search path. For example, you may need to add something like the following to your PATH environment variable: @@ -67,8 +67,8 @@ MSYS/MINGW - MSYS/MINGW, including the following packages + mingw32-gcc-g++ + mingw32-libz -- CMake 3.2+ -- Qt5 5.9+ for MINGW +- CMake 3.22+ +- Qt6 6.2+ for MINGW Make sure that Qt tools and CMake are in your executable search path. For example, add something like this to your .profile file: diff --git a/glabels-batch/main.cpp b/glabels-batch/main.cpp index 2fa99c4..cc0ccbd 100644 --- a/glabels-batch/main.cpp +++ b/glabels-batch/main.cpp @@ -69,7 +69,7 @@ int main( int argc, char **argv ) // Setup translators // QLocale locale = QLocale::system(); - QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath ); + QString qtTranslationsDir = QLibraryInfo::path( QLibraryInfo::TranslationsPath ); QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath(); QTranslator qtTranslator; diff --git a/glabels/CMakeLists.txt b/glabels/CMakeLists.txt index f8ba83f..eb5e9a7 100644 --- a/glabels/CMakeLists.txt +++ b/glabels/CMakeLists.txt @@ -107,9 +107,9 @@ set (glabels_resource_files images.qrc ) -qt5_wrap_cpp (glabels_moc_sources ${glabels_qobject_headers}) -qt5_wrap_ui (glabels_forms_headers ${glabels_forms}) -qt5_add_resources (glabels_qrc_sources ${glabels_resource_files}) +qt6_wrap_cpp (glabels_moc_sources ${glabels_qobject_headers}) +qt6_wrap_ui (glabels_forms_headers ${glabels_forms}) +qt6_add_resources (glabels_qrc_sources ${glabels_resource_files}) if (WIN32) # Windows resource file @@ -137,7 +137,7 @@ target_include_directories (glabels-qt target_link_libraries (glabels-qt Model - Qt5::Widgets + Qt6::Widgets ) #======================================= @@ -173,7 +173,6 @@ if (WIN32) env PATH="${QT_BIN_DIR}" "${WINDEPLOYQT_EXECUTABLE}" --verbose 0 --no-compiler-runtime - --no-angle --no-opengl-sw \"$\" ) @@ -198,7 +197,6 @@ if (WIN32) --verbose 0 --release --no-compiler-runtime - --no-angle --no-opengl-sw \"$\" ) diff --git a/glabels/ColorPaletteItem.cpp b/glabels/ColorPaletteItem.cpp index fa04223..7b4e4f8 100644 --- a/glabels/ColorPaletteItem.cpp +++ b/glabels/ColorPaletteItem.cpp @@ -120,7 +120,7 @@ namespace glabels /// /// Enter Event /// - void ColorPaletteItem::enterEvent( QEvent* event ) + void ColorPaletteItem::enterEvent( QEnterEvent* event ) { mHover = true; update(); diff --git a/glabels/ColorPaletteItem.h b/glabels/ColorPaletteItem.h index 2fb5bc8..931530a 100644 --- a/glabels/ColorPaletteItem.h +++ b/glabels/ColorPaletteItem.h @@ -67,7 +67,7 @@ namespace glabels ///////////////////////////////// protected: void paintEvent( QPaintEvent* event ) override; - void enterEvent( QEvent* event ) override; + void enterEvent( QEnterEvent* event ) override; void leaveEvent( QEvent* event ) override; void mousePressEvent( QMouseEvent* event ) override; diff --git a/glabels/MainWindow.cpp b/glabels/MainWindow.cpp index 2af0593..254ae27 100644 --- a/glabels/MainWindow.cpp +++ b/glabels/MainWindow.cpp @@ -327,22 +327,22 @@ namespace glabels connect( fileSaveAsAction, SIGNAL(triggered()), this, SLOT(fileSaveAs()) ); fileShowEditorPageAction = new QAction( tr("&Edit") , this ); - fileShowEditorPageAction->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_1 ) ); + fileShowEditorPageAction->setShortcut( QKeySequence( Qt::CTRL | Qt::Key_1 ) ); fileShowEditorPageAction->setStatusTip( tr("Select project Edit mode") ); connect( fileShowEditorPageAction, SIGNAL(triggered()), this, SLOT(fileShowEditorPage()) ); fileShowPropertiesPageAction = new QAction( tr("P&roperties") , this ); - fileShowPropertiesPageAction->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_2 ) ); + fileShowPropertiesPageAction->setShortcut( QKeySequence( Qt::CTRL | Qt::Key_2 ) ); fileShowPropertiesPageAction->setStatusTip( tr("Select project Properties mode") ); connect( fileShowPropertiesPageAction, SIGNAL(triggered()), this, SLOT(fileShowPropertiesPage()) ); fileShowMergePageAction = new QAction( tr("&Merge") , this ); - fileShowMergePageAction->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_3 ) ); + fileShowMergePageAction->setShortcut( QKeySequence( Qt::CTRL | Qt::Key_3 ) ); fileShowMergePageAction->setStatusTip( tr("Select project Merge mode") ); connect( fileShowMergePageAction, SIGNAL(triggered()), this, SLOT(fileShowMergePage()) ); fileShowVariablesPageAction = new QAction( tr("&Variables") , this ); - fileShowVariablesPageAction->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_4 ) ); + fileShowVariablesPageAction->setShortcut( QKeySequence( Qt::CTRL | Qt::Key_4 ) ); fileShowVariablesPageAction->setStatusTip( tr("Select project Variables mode") ); connect( fileShowVariablesPageAction, SIGNAL(triggered()), this, SLOT(fileShowVariablesPage()) ); diff --git a/glabels/TemplateDesigner.cpp b/glabels/TemplateDesigner.cpp index b12a949..ca0c0ab 100644 --- a/glabels/TemplateDesigner.cpp +++ b/glabels/TemplateDesigner.cpp @@ -110,7 +110,7 @@ namespace glabels /// Constructor /// TemplateDesigner::TemplateDesigner( QWidget* parent ) - : mIsBasedOnCopy(false), QWizard(parent) + : QWizard(parent) { setWindowTitle( tr("Product Template Designer") ); setPixmap( QWizard::LogoPixmap, QPixmap( ":icons/apps/48x48/glabels.svg" ) ); @@ -1315,7 +1315,7 @@ namespace glabels x0Spin->setRange( x0Min, x0Max ); y0Spin->setRange( y0Min, y0Max ); dxSpin->setRange( dxMin, dxMax ); - dySpin->setRange( dyMin, dxMax ); + dySpin->setRange( dyMin, dyMax ); static bool alreadyInitialized = false; if ( !td->isBasedOnCopy() && !alreadyInitialized ) diff --git a/glabels/main.cpp b/glabels/main.cpp index 4822f5c..a8d1786 100644 --- a/glabels/main.cpp +++ b/glabels/main.cpp @@ -51,7 +51,7 @@ int main( int argc, char **argv ) // Setup translators // QLocale locale = QLocale::system(); - QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath ); + QString qtTranslationsDir = QLibraryInfo::path( QLibraryInfo::TranslationsPath ); QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath(); QTranslator qtTranslator; diff --git a/glbarcode/BarcodeCode39Ext.cpp b/glbarcode/BarcodeCode39Ext.cpp index 7be79d0..7a0d5ee 100644 --- a/glbarcode/BarcodeCode39Ext.cpp +++ b/glbarcode/BarcodeCode39Ext.cpp @@ -80,7 +80,7 @@ namespace glbarcode { for (char c : rawData) { - if ( (c < 0) || (c > 0x7F) ) + if ( c < 0 ) { return false; } diff --git a/glbarcode/CMakeLists.txt b/glbarcode/CMakeLists.txt index ca561c1..69d2fab 100644 --- a/glbarcode/CMakeLists.txt +++ b/glbarcode/CMakeLists.txt @@ -42,5 +42,5 @@ target_include_directories (glbarcode ) target_link_libraries (glbarcode - Qt5::Widgets + Qt6::Widgets ) diff --git a/glbarcode/Matrix.h b/glbarcode/Matrix.h index cc09105..e0f14ac 100644 --- a/glbarcode/Matrix.h +++ b/glbarcode/Matrix.h @@ -116,16 +116,7 @@ namespace glbarcode /** * Indirection "[]" operator */ - inline T* operator[]( int i ) - { - return (mData + (mNx * i)); - } - - - /** - * Indirection "[]" operator - */ - inline T const*const operator[]( int i ) const + inline T* operator[]( int i ) const { return (mData + (mNx * i)); } diff --git a/glbarcode/QtRenderer.cpp b/glbarcode/QtRenderer.cpp index 62b540f..63e8c2f 100644 --- a/glbarcode/QtRenderer.cpp +++ b/glbarcode/QtRenderer.cpp @@ -134,7 +134,7 @@ namespace glbarcode font.setPointSizeF( FONT_SCALE*size ); QFontMetricsF fm( font ); - double xCorner = x - fm.width( QString::fromStdString(text) )/2.0; + double xCorner = x - fm.horizontalAdvance( QString::fromStdString(text) )/2.0; double yCorner = y - fm.ascent(); QTextLayout layout( QString::fromStdString(text), font ); diff --git a/model/CMakeLists.txt b/model/CMakeLists.txt index 1690772..fbc3be4 100644 --- a/model/CMakeLists.txt +++ b/model/CMakeLists.txt @@ -46,6 +46,7 @@ set (Model_sources Outline.cpp PageRenderer.cpp Paper.cpp + ParserState.cpp Point.cpp RawText.cpp Region.cpp @@ -85,7 +86,7 @@ set (Model_qobject_headers Variables.h ) -qt5_wrap_cpp (Model_moc_sources ${Model_qobject_headers}) +qt6_wrap_cpp (Model_moc_sources ${Model_qobject_headers}) #===================================== # Target @@ -107,10 +108,10 @@ target_include_directories (Model target_link_libraries (Model Barcode Merge - Qt5::Core - Qt5::PrintSupport - Qt5::Xml - Qt5::Svg + Qt6::Core + Qt6::PrintSupport + Qt6::Xml + Qt6::Svg ${OPTIONAL_ZLIB} ) diff --git a/model/Distance.cpp b/model/Distance.cpp index eca4410..b510f00 100644 --- a/model/Distance.cpp +++ b/model/Distance.cpp @@ -21,7 +21,8 @@ #include "Distance.h" #include -#include +#include +#include namespace glabels diff --git a/model/Frame.cpp b/model/Frame.cpp index 812f63d..36089f1 100644 --- a/model/Frame.cpp +++ b/model/Frame.cpp @@ -60,6 +60,15 @@ namespace glabels } + Frame::~Frame() + { + while ( !mMarkups.isEmpty() ) + { + delete mMarkups.takeFirst(); + } + } + + QString Frame::id() const { return mId; diff --git a/model/Frame.h b/model/Frame.h index 139cef6..b657a91 100644 --- a/model/Frame.h +++ b/model/Frame.h @@ -52,6 +52,7 @@ namespace glabels Frame( const Frame& other ); public: + virtual ~Frame(); virtual Frame* dup() const = 0; QString id() const; diff --git a/model/Markup.h b/model/Markup.h index ae4aaa7..87deb16 100644 --- a/model/Markup.h +++ b/model/Markup.h @@ -35,6 +35,8 @@ namespace glabels class Markup { public: + virtual ~Markup() = default; + virtual Markup* dup() const = 0; virtual QPainterPath path( const Frame* frame ) const; diff --git a/model/Model.cpp b/model/Model.cpp index 58f2790..71735d8 100644 --- a/model/Model.cpp +++ b/model/Model.cpp @@ -55,7 +55,6 @@ namespace glabels /// Default constructor. /// Model::Model() - : mUntitledInstance(0), mModified(true), mRotate(false) { mVariables = new Variables(); mMerge = new merge::None(); @@ -65,7 +64,6 @@ namespace glabels Model::Model( merge::Merge* merge, Variables* variables ) - : mUntitledInstance(0), mModified(true), mRotate(false) { mVariables = variables; // Shared mMerge = merge; // Shared @@ -235,8 +233,10 @@ namespace glabels /// Distance Model::w() const { - if ( auto* frame = mTmplate.frames().constFirst() ) + auto& frames = mTmplate.frames(); + if ( !frames.isEmpty() ) { + auto* frame = mTmplate.frames().constFirst(); return mRotate ? frame->h() : frame->w(); } else @@ -251,8 +251,10 @@ namespace glabels /// Distance Model::h() const { - if ( auto* frame = mTmplate.frames().constFirst() ) + auto& frames = mTmplate.frames(); + if ( !frames.isEmpty() ) { + auto* frame = mTmplate.frames().constFirst(); return mRotate ? frame->w() : frame->h(); } else diff --git a/model/Model.h b/model/Model.h index 5732c5b..996fc89 100644 --- a/model/Model.h +++ b/model/Model.h @@ -233,11 +233,11 @@ namespace glabels // Private data ///////////////////////////////// private: - int mUntitledInstance; - bool mModified; + int mUntitledInstance{0}; + bool mModified{true}; QString mFileName; Template mTmplate; - bool mRotate; + bool mRotate{false}; QList mObjectList; diff --git a/model/ModelImageObject.cpp b/model/ModelImageObject.cpp index 3236b89..bb4ce8a 100644 --- a/model/ModelImageObject.cpp +++ b/model/ModelImageObject.cpp @@ -316,7 +316,7 @@ namespace glabels } mImage = new QImage(value); - quint16 cs = qChecksum( (const char*)mImage->constBits(), mImage->sizeInBytes() ); + quint16 cs = qChecksum( QByteArray( (const char*)mImage->constBits(), mImage->sizeInBytes() ) ); mFilenameNode = TextNode( false, QString("%image_%1%").arg( cs ) ); emit changed(); diff --git a/model/PageRenderer.cpp b/model/PageRenderer.cpp index ecdbd2d..f1092aa 100644 --- a/model/PageRenderer.cpp +++ b/model/PageRenderer.cpp @@ -47,9 +47,6 @@ namespace glabels PageRenderer::PageRenderer( const Model* model ) - : mModel(nullptr), mMerge(nullptr), mVariables(nullptr), mNCopies(0), mStartItem(0), mLastItem(0), - mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false), - mIPage(0), mIsMerge(false), mNPages(0), mNItemsPerPage(0) { if ( model ) { diff --git a/model/PageRenderer.h b/model/PageRenderer.h index 73ecaca..eb30d9c 100644 --- a/model/PageRenderer.h +++ b/model/PageRenderer.h @@ -111,29 +111,29 @@ namespace glabels // Private Data ///////////////////////////////// private: - const Model* mModel; - const merge::Merge* mMerge; - Variables* mVariables; + const Model* mModel{ nullptr }; + const merge::Merge* mMerge{ nullptr }; + Variables* mVariables{ nullptr }; - int mNCopies; - int mStartItem; - int mLastItem; - int mNGroups; - int mNItemsPerGroup; - int mNPagesPerGroup; - int mIPage; + int mNCopies{ 0 }; + int mStartItem{ 0 }; + int mLastItem{ 0 }; + int mNGroups{ 0 }; + int mNItemsPerGroup{ 0 }; + int mNPagesPerGroup{ 0 }; + int mIPage{ 0 }; - bool mIsMerge; + bool mIsMerge{ false }; - int mNItems; - int mNPages; - int mNItemsPerPage; + int mNItems{ 0 }; + int mNPages{ 0 }; + int mNItemsPerPage{ 0 }; - bool mIsCollated; - bool mAreGroupsContiguous; - bool mPrintOutlines; - bool mPrintCropMarks; - bool mPrintReverse; + bool mIsCollated{ false }; + bool mAreGroupsContiguous{ false }; + bool mPrintOutlines{ false }; + bool mPrintCropMarks{ false }; + bool mPrintReverse{ false }; QVector mOrigins; }; diff --git a/model/ParserState.cpp b/model/ParserState.cpp new file mode 100644 index 0000000..34cd3b0 --- /dev/null +++ b/model/ParserState.cpp @@ -0,0 +1,87 @@ +/* ParserState.cpp + * + * Copyright (C) 2025 Jaye Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt 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. + * + * gLabels-qt 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + + +#include "ParserState.h" + +#include + + +namespace glabels +{ + namespace model + { + + ParserState::ParserState( const QString& string, + unsigned int pos ) + : mString(&string), + mPos( pos ) + { + } + + + QChar + ParserState::operator[]( unsigned int i ) const + { + auto ii = mPos + i; + if ( ii < mString->size() ) + { + return (*mString)[ii]; + } + else + { + return '\0'; + } + } + + + bool + ParserState::isNextSubString( const QString& s ) const + { + for ( unsigned int i = 0; i < s.size(); i++ ) + { + if ( operator[](i) != s[i] ) return false; + } + return true; + } + + + qsizetype + ParserState::pos() const + { + return mPos; + } + + + qsizetype + ParserState::charsLeft() const + { + return mString->size() - mPos; + } + + + void + ParserState::advanceChars( unsigned int i ) + { + mPos = std::min( mPos + i, mString->size() ); + } + + } +} diff --git a/model/ParserState.h b/model/ParserState.h new file mode 100644 index 0000000..da75ad0 --- /dev/null +++ b/model/ParserState.h @@ -0,0 +1,58 @@ +/* ParserState.h + * + * Copyright (C) 2025 Jaye Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt 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. + * + * gLabels-qt 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#ifndef model_ParserState_h +#define model_ParserState_h + + +#include + + +namespace glabels +{ + namespace model + { + + class ParserState + { + public: + ParserState() = default; + ParserState( const QString& string, + unsigned int pos = 0 ); + ~ParserState() = default; + + QChar operator[]( unsigned int i ) const; + bool isNextSubString( const QString& s ) const; + qsizetype pos() const; + qsizetype charsLeft() const; + + void advanceChars( unsigned int i ); + + + private: + const QString* mString; + qsizetype mPos{ 0 }; + }; + + } +} + + +#endif // model_ParserState_h diff --git a/model/RawText.cpp b/model/RawText.cpp index 2d69d4c..9cd9d5d 100644 --- a/model/RawText.cpp +++ b/model/RawText.cpp @@ -18,10 +18,14 @@ * along with gLabels-qt. If not, see . */ + #include "RawText.h" +#include "ParserState.h" + #include + namespace glabels { namespace model @@ -112,8 +116,8 @@ namespace glabels { Token token; - QStringRef s = &mString; - while ( s.size() ) + ParserState s( mString ); + while ( s.charsLeft() ) { SubstitutionField field; if ( SubstitutionField::parse( s, field ) ) @@ -134,7 +138,7 @@ namespace glabels else { token.text += s[0]; - s = s.mid(1); + s.advanceChars(1); } } diff --git a/model/Settings.cpp b/model/Settings.cpp index bdaba97..a90bce8 100644 --- a/model/Settings.cpp +++ b/model/Settings.cpp @@ -96,7 +96,7 @@ namespace glabels { // Guess at a suitable default QString defaultFamily; - switch (QLocale::system().country()) + switch (QLocale::system().territory()) { case QLocale::UnitedStates: case QLocale::Canada: diff --git a/model/SubstitutionField.cpp b/model/SubstitutionField.cpp index da4e0b8..206fb24 100644 --- a/model/SubstitutionField.cpp +++ b/model/SubstitutionField.cpp @@ -37,7 +37,7 @@ namespace glabels SubstitutionField::SubstitutionField( const QString& string ) : mFormatType(0), mNewLine(false) { - QStringRef s(&string); + ParserState s(string); parse( s, *this ); } @@ -107,28 +107,28 @@ namespace glabels } - bool SubstitutionField::parse( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parse( ParserState& s, SubstitutionField& field ) { - QStringRef sTmp = s; + ParserState sTmp = s; - if ( sTmp.startsWith( "${" ) ) + if ( sTmp.isNextSubString( "${" ) ) { - sTmp = sTmp.mid(2); + sTmp.advanceChars( 2 ); if ( parseFieldName( sTmp, field ) ) { - while ( sTmp.size() && sTmp[0] == ':' ) + while ( sTmp.charsLeft() && sTmp[0] == ':' ) { - sTmp = sTmp.mid(1); + sTmp.advanceChars( 1 ); if ( !parseModifier( sTmp, field ) ) { return false; } } - if ( sTmp.size() && sTmp[0] == '}' ) + if ( sTmp.charsLeft() && sTmp[0] == '}' ) { - sTmp = sTmp.mid(1); + sTmp.advanceChars( 1 ); // Success. Update s. s = sTmp; @@ -141,14 +141,14 @@ namespace glabels } - bool SubstitutionField::parseFieldName( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseFieldName( ParserState& s, SubstitutionField& field ) { bool success = false; - while ( s.size() && (s[0].isPrint() && s[0] != ':' && s[0] != '}') ) + while ( s.charsLeft() && (s[0].isPrint() && s[0] != ':' && s[0] != '}') ) { field.mFieldName.append( s[0] ); - s = s.mid(1); + s.advanceChars( 1 ); success = true; } @@ -157,23 +157,23 @@ namespace glabels } - bool SubstitutionField::parseModifier( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseModifier( ParserState& s, SubstitutionField& field ) { bool success = false; - if ( s.size() && s[0] == '%' ) + if ( s.charsLeft() && s[0] == '%' ) { - s = s.mid(1); + s.advanceChars( 1 ); success = parseFormatModifier( s, field ); } - else if ( s.size() && s[0] == '=' ) + else if ( s.charsLeft() && s[0] == '=' ) { - s = s.mid(1); + s.advanceChars( 1 ); success = parseDefaultValueModifier( s, field ); } - else if ( s.size() && s[0] == 'n' ) + else if ( s.charsLeft() && s[0] == 'n' ) { - s = s.mid(1); + s.advanceChars( 1 ); success = parseNewLineModifier( s, field ); } @@ -181,25 +181,25 @@ namespace glabels } - bool SubstitutionField::parseDefaultValueModifier( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseDefaultValueModifier( ParserState& s, SubstitutionField& field ) { field.mDefaultValue.clear(); - while ( s.size() && !QString( ":}" ).contains( s[0] ) ) + while ( s.charsLeft() && !QString( ":}" ).contains( s[0] ) ) { if ( s[0] == '\\' ) { - s = s.mid(1); // Skip escape - if ( s.size() ) + s.advanceChars( 1 ); // Skip escape + if ( s.charsLeft() ) { field.mDefaultValue.append( s[0] ); - s = s.mid(1); + s.advanceChars( 1 ); } } else { field.mDefaultValue.append( s[0] ); - s = s.mid(1); + s.advanceChars( 1 ); } } @@ -207,17 +207,17 @@ namespace glabels } - bool SubstitutionField::parseFormatModifier( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseFormatModifier( ParserState& s, SubstitutionField& field ) { field.mFormat = "%"; parseFormatFlags( s, field ); parseFormatWidth( s, field ); - if ( s.size() && s[0] == '.' ) + if ( s.charsLeft() && s[0] == '.' ) { field.mFormat += "."; - s = s.mid(1); + s.advanceChars( 1 ); parseFormatPrecision( s, field ); } @@ -227,39 +227,39 @@ namespace glabels } - bool SubstitutionField::parseFormatFlags( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseFormatFlags( ParserState& s, SubstitutionField& field ) { - while ( s.size() && QString( "-+ 0" ).contains( s[0] ) ) + while ( s.charsLeft() && QString( "-+ 0" ).contains( s[0] ) ) { field.mFormat += s[0]; - s = s.mid(1); + s.advanceChars( 1 ); } return true; } - bool SubstitutionField::parseFormatWidth( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseFormatWidth( ParserState& s, SubstitutionField& field ) { return parseNaturalInteger( s, field ); } - bool SubstitutionField::parseFormatPrecision( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseFormatPrecision( ParserState& s, SubstitutionField& field ) { return parseNaturalInteger( s, field ); } - bool SubstitutionField::parseFormatType( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseFormatType( ParserState& s, SubstitutionField& field ) { bool success = false; - if ( s.size() && QString( "diufFeEgGxXos" ).contains( s[0] ) ) + if ( s.charsLeft() && QString( "diufFeEgGxXos" ).contains( s[0] ) ) { field.mFormatType = s[0]; field.mFormat += s[0]; - s = s.mid(1); + s.advanceChars( 1 ); success = true; } @@ -267,19 +267,19 @@ namespace glabels } - bool SubstitutionField::parseNaturalInteger( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseNaturalInteger( ParserState& s, SubstitutionField& field ) { bool success = false; - if ( s.size() && s[0] >= '1' && s[0] <= '9' ) + if ( s.charsLeft() && s[0] >= '1' && s[0] <= '9' ) { field.mFormat += s[0]; - s = s.mid(1); + s.advanceChars( 1 ); - while ( s.size() && s[0].isDigit() ) + while ( s.charsLeft() && s[0].isDigit() ) { field.mFormat += s[0]; - s = s.mid(1); + s.advanceChars( 1 ); } success = true; @@ -289,7 +289,7 @@ namespace glabels } - bool SubstitutionField::parseNewLineModifier( QStringRef& s, SubstitutionField& field ) + bool SubstitutionField::parseNewLineModifier( ParserState& s, SubstitutionField& field ) { field.mNewLine = true; return true; diff --git a/model/SubstitutionField.h b/model/SubstitutionField.h index 8afb812..6ef3b8b 100644 --- a/model/SubstitutionField.h +++ b/model/SubstitutionField.h @@ -21,12 +21,13 @@ #ifndef model_SubstitutionField_h #define model_SubstitutionField_h + +#include "ParserState.h" #include "Variables.h" #include "merge/Record.h" #include -#include namespace glabels @@ -48,19 +49,19 @@ namespace glabels QChar formatType() const; bool newLine() const; - static bool parse( QStringRef& s, SubstitutionField& field ); + static bool parse( ParserState& s, SubstitutionField& field ); private: - static bool parseFieldName( QStringRef& s, SubstitutionField& field ); - static bool parseModifier( QStringRef& s, SubstitutionField& field ); - static bool parseDefaultValueModifier( QStringRef& s, SubstitutionField& field ); - static bool parseFormatModifier( QStringRef& s, SubstitutionField& field ); - static bool parseFormatFlags( QStringRef& s, SubstitutionField& field ); - static bool parseFormatWidth( QStringRef& s, SubstitutionField& field ); - static bool parseFormatPrecision( QStringRef& s, SubstitutionField& field ); - static bool parseFormatType( QStringRef& s, SubstitutionField& field ); - static bool parseNaturalInteger( QStringRef& s, SubstitutionField& field ); - static bool parseNewLineModifier( QStringRef& s, SubstitutionField& field ); + static bool parseFieldName( ParserState& s, SubstitutionField& field ); + static bool parseModifier( ParserState& s, SubstitutionField& field ); + static bool parseDefaultValueModifier( ParserState& s, SubstitutionField& field ); + static bool parseFormatModifier( ParserState& s, SubstitutionField& field ); + static bool parseFormatFlags( ParserState& s, SubstitutionField& field ); + static bool parseFormatWidth( ParserState& s, SubstitutionField& field ); + static bool parseFormatPrecision( ParserState& s, SubstitutionField& field ); + static bool parseFormatType( ParserState& s, SubstitutionField& field ); + static bool parseNaturalInteger( ParserState& s, SubstitutionField& field ); + static bool parseNewLineModifier( ParserState& s, SubstitutionField& field ); QString formatValue( const QString& value ) const; diff --git a/model/Template.cpp b/model/Template.cpp index 7a1d20f..d434d58 100644 --- a/model/Template.cpp +++ b/model/Template.cpp @@ -46,10 +46,7 @@ namespace glabels mPageWidth(pageWidth), mPageHeight(pageHeight), mRollWidth(rollWidth), - mIsUserDefined(isUserDefined), - mIsSizeIso(false), - mIsSizeUs(false), - mName("") + mIsUserDefined(isUserDefined) { mName.append( brand ).append( " " ).append( part ); diff --git a/model/Template.h b/model/Template.h index b60c42e..2f90509 100644 --- a/model/Template.h +++ b/model/Template.h @@ -112,11 +112,12 @@ namespace glabels Distance mPageWidth; Distance mPageHeight; Distance mRollWidth; - bool mIsSizeIso; - bool mIsSizeUs; - bool mIsRoll; - bool mIsUserDefined; + bool mIsSizeIso{ false }; + bool mIsSizeUs{ false }; + bool mIsRoll{ false }; + + bool mIsUserDefined{ false }; QString mEquivPart; QString mName; diff --git a/model/XmlUtil.cpp b/model/XmlUtil.cpp index b5ad925..082287a 100644 --- a/model/XmlUtil.cpp +++ b/model/XmlUtil.cpp @@ -22,7 +22,8 @@ #include #include -#include +#include +#include namespace glabels diff --git a/model/unit_tests/CMakeLists.txt b/model/unit_tests/CMakeLists.txt index 21fc314..5aca82b 100644 --- a/model/unit_tests/CMakeLists.txt +++ b/model/unit_tests/CMakeLists.txt @@ -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) diff --git a/model/unit_tests/TestModel.cpp b/model/unit_tests/TestModel.cpp index 741daf8..260648a 100644 --- a/model/unit_tests/TestModel.cpp +++ b/model/unit_tests/TestModel.cpp @@ -36,7 +36,8 @@ #include "merge/TextCsv.h" #include "merge/TextCsvKeys.h" -#include +#include +#include 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" ) ); diff --git a/model/unit_tests/TestSubstitutionField.cpp b/model/unit_tests/TestSubstitutionField.cpp index 0f00751..8d32bce 100644 --- a/model/unit_tests/TestSubstitutionField.cpp +++ b/model/unit_tests/TestSubstitutionField.cpp @@ -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 } diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt index dfc5ac6..448175b 100644 --- a/translations/CMakeLists.txt +++ b/translations/CMakeLists.txt @@ -9,14 +9,14 @@ include (TRANSLATION_FILES.txt) # # Update strings in C-locale translation files (lupdate+lrelease) # -qt5_create_translation (glabels_C_qm_file +qt6_create_translation (glabels_C_qm_file ${CMAKE_SOURCE_DIR}/glabels ${CMAKE_SOURCE_DIR}/model ${CMAKE_SOURCE_DIR}/backends glabels_C.ts OPTIONS -no-obsolete -locations none ) -qt5_create_translation (templates_C_qm_file +qt6_create_translation (templates_C_qm_file ${CMAKE_CURRENT_BINARY_DIR}/template-strings.h templates_C.ts OPTIONS -no-obsolete -locations none @@ -25,7 +25,7 @@ qt5_create_translation (templates_C_qm_file # # Generate QM files from all other language translation files (lrelease only) # -qt5_add_translation (language_qm_files +qt6_add_translation (language_qm_files ${GLABELS_TS_FILES} ${TEMPLATES_TS_FILES} ) @@ -50,8 +50,8 @@ target_compile_features (Model ) target_link_libraries (XmlStrings - Qt5::Core - Qt5::Xml + Qt6::Core + Qt6::Xml ) #=======================================