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
+110
View File
@@ -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 }}
+7 -18
View File
@@ -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)
+2 -2
View File
@@ -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).
+2 -2
View File
@@ -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}
+2 -2
View File
@@ -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
)
+3
View File
@@ -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
+17 -19
View File
@@ -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
</pre>
## 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 <package name substring>
$ sudo dnf search qt6 |grep <package name substring>
```
### Compile and Install gLabels into /usr/local
+4 -4
View File
@@ -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:
+1 -1
View File
@@ -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;
+4 -6
View File
@@ -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
\"$<TARGET_FILE:glabels-qt>\"
)
@@ -198,7 +197,6 @@ if (WIN32)
--verbose 0
--release
--no-compiler-runtime
--no-angle
--no-opengl-sw
\"$<TARGET_FILE:glabels-qt>\"
)
+1 -1
View File
@@ -120,7 +120,7 @@ namespace glabels
///
/// Enter Event
///
void ColorPaletteItem::enterEvent( QEvent* event )
void ColorPaletteItem::enterEvent( QEnterEvent* event )
{
mHover = true;
update();
+1 -1
View File
@@ -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;
+4 -4
View File
@@ -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()) );
+2 -2
View File
@@ -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 )
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -80,7 +80,7 @@ namespace glbarcode
{
for (char c : rawData)
{
if ( (c < 0) || (c > 0x7F) )
if ( c < 0 )
{
return false;
}
+1 -1
View File
@@ -42,5 +42,5 @@ target_include_directories (glbarcode
)
target_link_libraries (glbarcode
Qt5::Widgets
Qt6::Widgets
)
+1 -10
View File
@@ -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));
}
+1 -1
View File
@@ -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 );
+6 -5
View File
@@ -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}
)
+2 -1
View File
@@ -21,7 +21,8 @@
#include "Distance.h"
#include <QTextStream>
#include <QtDebug>
#include <QDebug>
#include <QIODevice>
namespace glabels
+9
View File
@@ -60,6 +60,15 @@ namespace glabels
}
Frame::~Frame()
{
while ( !mMarkups.isEmpty() )
{
delete mMarkups.takeFirst();
}
}
QString Frame::id() const
{
return mId;
+1
View File
@@ -52,6 +52,7 @@ namespace glabels
Frame( const Frame& other );
public:
virtual ~Frame();
virtual Frame* dup() const = 0;
QString id() const;
+2
View File
@@ -35,6 +35,8 @@ namespace glabels
class Markup
{
public:
virtual ~Markup() = default;
virtual Markup* dup() const = 0;
virtual QPainterPath path( const Frame* frame ) const;
+6 -4
View File
@@ -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
+3 -3
View File
@@ -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<ModelObject*> mObjectList;
+1 -1
View File
@@ -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();
-3
View File
@@ -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 )
{
+19 -19
View File
@@ -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<Point> mOrigins;
};
+87
View File
@@ -0,0 +1,87 @@
/* ParserState.cpp
*
* Copyright (C) 2025 Jaye Evins <evins@snaught.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "ParserState.h"
#include <algorithm>
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() );
}
}
}
+58
View File
@@ -0,0 +1,58 @@
/* ParserState.h
*
* Copyright (C) 2025 Jaye Evins <evins@snaught.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef model_ParserState_h
#define model_ParserState_h
#include <QString>
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
+7 -3
View File
@@ -18,10 +18,14 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "RawText.h"
#include "ParserState.h"
#include <QRegularExpression>
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);
}
}
+1 -1
View File
@@ -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:
+42 -42
View File
@@ -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;
+13 -12
View File
@@ -21,12 +21,13 @@
#ifndef model_SubstitutionField_h
#define model_SubstitutionField_h
#include "ParserState.h"
#include "Variables.h"
#include "merge/Record.h"
#include <QString>
#include <QStringRef>
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;
+1 -4
View File
@@ -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 );
+5 -4
View File
@@ -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;
+2 -1
View File
@@ -22,7 +22,8 @@
#include <QTextStream>
#include <QCoreApplication>
#include <QtDebug>
#include <QDebug>
#include <QIODevice>
namespace glabels
+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
}
+5 -5
View File
@@ -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
)
#=======================================