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:
@@ -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
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required (VERSION 3.9)
|
cmake_minimum_required (VERSION 3.22)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# gLabels Label Designer Project
|
# gLabels Label Designer Project
|
||||||
@@ -111,12 +111,7 @@ if (MINGW)
|
|||||||
set (CMAKE_PREFIX_PATH ${MINGW_BASE_DIR} )
|
set (CMAKE_PREFIX_PATH ${MINGW_BASE_DIR} )
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
find_package (Qt5Core 5.15 REQUIRED)
|
find_package (Qt6 6.2 REQUIRED COMPONENTS Core Gui Widgets PrintSupport Xml Svg LinguistTools Test)
|
||||||
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)
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
# Locate Qt directories
|
# Locate Qt directories
|
||||||
@@ -131,8 +126,6 @@ find_package (ZLIB 1.2 QUIET)
|
|||||||
find_package (GnuBarcode 0.98 QUIET)
|
find_package (GnuBarcode 0.98 QUIET)
|
||||||
find_package (LibQrencode 3.4 QUIET)
|
find_package (LibQrencode 3.4 QUIET)
|
||||||
find_package (LibZint 2.6 EXACT 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
|
# Uncomment to compile everything with aggressively pedantic options
|
||||||
# (not recommended -- only for testing -- also not portable)
|
# (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
|
# Uncomment to always compile with debug symbols
|
||||||
add_compile_options("-g")
|
add_compile_options("-g")
|
||||||
@@ -153,7 +146,7 @@ endif ()
|
|||||||
#=======================================
|
#=======================================
|
||||||
# Unit Testing
|
# Unit Testing
|
||||||
#=======================================
|
#=======================================
|
||||||
if (Qt5Test_FOUND)
|
if (Qt6Test_FOUND)
|
||||||
enable_testing ()
|
enable_testing ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
@@ -177,11 +170,13 @@ add_subdirectory (data)
|
|||||||
message (STATUS "")
|
message (STATUS "")
|
||||||
message (STATUS "Project name ............ " ${CMAKE_PROJECT_NAME})
|
message (STATUS "Project name ............ " ${CMAKE_PROJECT_NAME})
|
||||||
message (STATUS "Project version ......... " ${LONG_VERSION_STRING})
|
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 "Installation prefix ..... " ${CMAKE_INSTALL_PREFIX})
|
||||||
message (STATUS "Source code location .... " ${glabels_SOURCE_DIR})
|
message (STATUS "Source code location .... " ${glabels_SOURCE_DIR})
|
||||||
message (STATUS "CMake version ........... " ${CMAKE_VERSION})
|
message (STATUS "CMake version ........... " ${CMAKE_VERSION})
|
||||||
message (STATUS "C++ Compiler ............ " ${CMAKE_CXX_COMPILER_ID} " " ${CMAKE_CXX_COMPILER} " " ${CMAKE_CXX_COMPILER_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)
|
if (ZLIB_FOUND)
|
||||||
message (STATUS "zlib (optional).......... " ${ZLIB_VERSION_STRING})
|
message (STATUS "zlib (optional).......... " ${ZLIB_VERSION_STRING})
|
||||||
@@ -207,12 +202,6 @@ else (LIBZINT_FOUND)
|
|||||||
message (STATUS "libzint (optional)....... No.")
|
message (STATUS "libzint (optional)....... No.")
|
||||||
endif (LIBZINT_FOUND)
|
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)
|
if (MSVC)
|
||||||
message (STATUS "MSVC Qt location ........ " ${QT_BASE_DIR})
|
message (STATUS "MSVC Qt location ........ " ${QT_BASE_DIR})
|
||||||
endif (MSVC)
|
endif (MSVC)
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
[](https://travis-ci.org/j-evins/glabels-qt)
|
[](https://github.com/j-evins/glabels-qt/actions/workflows/build-tests.yml)
|
||||||
[](https://ci.appveyor.com/project/j-evins/glabels-qt)
|
|
||||||
|
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
@@ -89,3 +88,4 @@ restrictive licensing:
|
|||||||
label database. No copyright is claimed on the facts contained within
|
label database. No copyright is claimed on the facts contained within
|
||||||
the database and can be used for any purpose. The files themselves are
|
the database and can be used for any purpose. The files themselves are
|
||||||
licensed using the MIT/X license. See [templates/LICENSE](templates/LICENSE).
|
licensed using the MIT/X license. See [templates/LICENSE](templates/LICENSE).
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ set (barcode_qobject_headers
|
|||||||
Backends.h
|
Backends.h
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers})
|
qt6_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers})
|
||||||
|
|
||||||
#=====================================
|
#=====================================
|
||||||
# Target
|
# Target
|
||||||
@@ -60,7 +60,7 @@ target_include_directories (Barcode
|
|||||||
|
|
||||||
target_link_libraries (Barcode
|
target_link_libraries (Barcode
|
||||||
glbarcode
|
glbarcode
|
||||||
Qt5::Core
|
Qt6::Core
|
||||||
${OPTIONAL_GNUBARCODE}
|
${OPTIONAL_GNUBARCODE}
|
||||||
${OPTIONAL_ZINT}
|
${OPTIONAL_ZINT}
|
||||||
${OPTIONAL_QRENCODE}
|
${OPTIONAL_QRENCODE}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ set (merge_qobject_headers
|
|||||||
Merge.h
|
Merge.h
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
|
qt6_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
|
||||||
|
|
||||||
#=====================================
|
#=====================================
|
||||||
# Target
|
# Target
|
||||||
@@ -43,5 +43,5 @@ target_include_directories (Merge
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries (Merge
|
target_link_libraries (Merge
|
||||||
Qt5::Core
|
Qt6::Core
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ endif ()
|
|||||||
if (GNUBARCODE_INCLUDE_DIR AND EXISTS "${GNUBARCODE_INCLUDE_DIR}/barcode.h")
|
if (GNUBARCODE_INCLUDE_DIR AND EXISTS "${GNUBARCODE_INCLUDE_DIR}/barcode.h")
|
||||||
file (STRINGS "${GNUBARCODE_INCLUDE_DIR}/barcode.h" BARCODE_H REGEX "^#define BARCODE_VERSION *\"[^\"]*\"")
|
file (STRINGS "${GNUBARCODE_INCLUDE_DIR}/barcode.h" BARCODE_H REGEX "^#define BARCODE_VERSION *\"[^\"]*\"")
|
||||||
string (REGEX REPLACE "^.*VERSION *\"([^\"]*)\"" "\\1" GNUBARCODE_VERSION_STRING "${BARCODE_H}")
|
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()
|
endif()
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set GNUBARCODE_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set GNUBARCODE_FOUND to TRUE if
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ gLabels Linux Build Instructions
|
|||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- g++
|
- g++
|
||||||
- CMake 2.8.12+
|
- CMake 3.22+
|
||||||
- Qt5 5.15+ Development Packages ( Qt5Core, Qt5Widgets, Qt5PrintSupport, Qt5Xml, Qt5Svg )
|
- Qt6 6.2+ Development Packages ( Qt6Core, Qt6Widgets, Qt6PrintSupport, Qt6Xml, Qt6Svg, Qt6Test )
|
||||||
- zlib 1.2+ Development Package
|
- zlib 1.2+ Development Package
|
||||||
|
|
||||||
> Even if the above library packages are installed, their corresponding development packages
|
> Even if the above library packages are installed, their corresponding development packages
|
||||||
@@ -26,36 +26,32 @@ $ make
|
|||||||
$ sudo make install
|
$ sudo make install
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
## Example: Ubuntu 19.04
|
|
||||||
|
## Example: Ubuntu 24.04
|
||||||
|
|
||||||
### Installing Prerequisites
|
### Installing Prerequisites
|
||||||
```
|
```
|
||||||
sudo apt install cmake
|
$ sudo apt install cmake
|
||||||
sudo apt install qtbase5-dev libqt5svg5-dev qttools5-dev zlib1g-dev
|
$ sudo apt install qt6-base-dev qt6-svg-dev qt6-tools-dev zlib1g-dev
|
||||||
```
|
```
|
||||||
_QREncode (Optional)_
|
_QREncode (Optional)_
|
||||||
```
|
```
|
||||||
sudo apt install pkgconf libqrencode-dev
|
$ sudo apt install pkgconf libqrencode-dev
|
||||||
```
|
```
|
||||||
_Zint (Optional)_
|
_Zint (Optional)_
|
||||||
|
|
||||||
Install zint from source:
|
Install zint from source:
|
||||||
```
|
```
|
||||||
wget https://downloads.sourceforge.net/project/zint/zint/2.6.3/zint-2.6.3_final.tar.gz
|
$ 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
|
$ tar xzf zint-2.6.3_final.tar.gz
|
||||||
cd zint-2.6.3.src/
|
$ cd zint-2.6.3.src/
|
||||||
mkdir build && cd build && cmake .. && make
|
$ mkdir build && cd build && cmake .. && make
|
||||||
sudo make install
|
$ sudo make install
|
||||||
```
|
```
|
||||||
_GNU Barcode (Optional)_
|
_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
|
$ sudo apt install barcode
|
||||||
tar xzf barcode-0.98.tar.gz
|
|
||||||
cd barcode-0.98/
|
|
||||||
./configure && make
|
|
||||||
sudo make install
|
|
||||||
```
|
```
|
||||||
### Compile and Install gLabels
|
### Compile and Install gLabels
|
||||||
|
|
||||||
@@ -67,6 +63,8 @@ $ cmake ..
|
|||||||
$ make
|
$ make
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Example: Fedora 35
|
## Example: Fedora 35
|
||||||
|
|
||||||
### Installing Prerequisites
|
### 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
|
$ 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.
|
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.
|
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
|
If the Cmake pass or build has missing package errors or warnings, you can search for the needed
|
||||||
package with:
|
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
|
### Compile and Install gLabels into /usr/local
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ Visual Studio
|
|||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- Visual Studio (these instructions are for _Visual Studio 15 2017 Win64_)
|
- Visual Studio (these instructions are for _Visual Studio 15 2017 Win64_)
|
||||||
- CMake 3.2+
|
- CMake 3.22+
|
||||||
- Qt5 5.9+ for your version of Visual Studio
|
- Qt6 6.2+ for your version of Visual Studio
|
||||||
- NSIS 3.03+ (optional -- for creating an installer)
|
- 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:
|
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
|
- MSYS/MINGW, including the following packages
|
||||||
+ mingw32-gcc-g++
|
+ mingw32-gcc-g++
|
||||||
+ mingw32-libz
|
+ mingw32-libz
|
||||||
- CMake 3.2+
|
- CMake 3.22+
|
||||||
- Qt5 5.9+ for MINGW
|
- 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:
|
Make sure that Qt tools and CMake are in your executable search path. For example, add something like this to your .profile file:
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ int main( int argc, char **argv )
|
|||||||
// Setup translators
|
// Setup translators
|
||||||
//
|
//
|
||||||
QLocale locale = QLocale::system();
|
QLocale locale = QLocale::system();
|
||||||
QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
|
QString qtTranslationsDir = QLibraryInfo::path( QLibraryInfo::TranslationsPath );
|
||||||
QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
|
QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
|
||||||
|
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ set (glabels_resource_files
|
|||||||
images.qrc
|
images.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_cpp (glabels_moc_sources ${glabels_qobject_headers})
|
qt6_wrap_cpp (glabels_moc_sources ${glabels_qobject_headers})
|
||||||
qt5_wrap_ui (glabels_forms_headers ${glabels_forms})
|
qt6_wrap_ui (glabels_forms_headers ${glabels_forms})
|
||||||
qt5_add_resources (glabels_qrc_sources ${glabels_resource_files})
|
qt6_add_resources (glabels_qrc_sources ${glabels_resource_files})
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
# Windows resource file
|
# Windows resource file
|
||||||
@@ -137,7 +137,7 @@ target_include_directories (glabels-qt
|
|||||||
|
|
||||||
target_link_libraries (glabels-qt
|
target_link_libraries (glabels-qt
|
||||||
Model
|
Model
|
||||||
Qt5::Widgets
|
Qt6::Widgets
|
||||||
)
|
)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
@@ -173,7 +173,6 @@ if (WIN32)
|
|||||||
env PATH="${QT_BIN_DIR}" "${WINDEPLOYQT_EXECUTABLE}"
|
env PATH="${QT_BIN_DIR}" "${WINDEPLOYQT_EXECUTABLE}"
|
||||||
--verbose 0
|
--verbose 0
|
||||||
--no-compiler-runtime
|
--no-compiler-runtime
|
||||||
--no-angle
|
|
||||||
--no-opengl-sw
|
--no-opengl-sw
|
||||||
\"$<TARGET_FILE:glabels-qt>\"
|
\"$<TARGET_FILE:glabels-qt>\"
|
||||||
)
|
)
|
||||||
@@ -198,7 +197,6 @@ if (WIN32)
|
|||||||
--verbose 0
|
--verbose 0
|
||||||
--release
|
--release
|
||||||
--no-compiler-runtime
|
--no-compiler-runtime
|
||||||
--no-angle
|
|
||||||
--no-opengl-sw
|
--no-opengl-sw
|
||||||
\"$<TARGET_FILE:glabels-qt>\"
|
\"$<TARGET_FILE:glabels-qt>\"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Enter Event
|
/// Enter Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::enterEvent( QEvent* event )
|
void ColorPaletteItem::enterEvent( QEnterEvent* event )
|
||||||
{
|
{
|
||||||
mHover = true;
|
mHover = true;
|
||||||
update();
|
update();
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace glabels
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void paintEvent( QPaintEvent* event ) override;
|
void paintEvent( QPaintEvent* event ) override;
|
||||||
void enterEvent( QEvent* event ) override;
|
void enterEvent( QEnterEvent* event ) override;
|
||||||
void leaveEvent( QEvent* event ) override;
|
void leaveEvent( QEvent* event ) override;
|
||||||
void mousePressEvent( QMouseEvent* event ) override;
|
void mousePressEvent( QMouseEvent* event ) override;
|
||||||
|
|
||||||
|
|||||||
@@ -327,22 +327,22 @@ namespace glabels
|
|||||||
connect( fileSaveAsAction, SIGNAL(triggered()), this, SLOT(fileSaveAs()) );
|
connect( fileSaveAsAction, SIGNAL(triggered()), this, SLOT(fileSaveAs()) );
|
||||||
|
|
||||||
fileShowEditorPageAction = new QAction( tr("&Edit") , this );
|
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") );
|
fileShowEditorPageAction->setStatusTip( tr("Select project Edit mode") );
|
||||||
connect( fileShowEditorPageAction, SIGNAL(triggered()), this, SLOT(fileShowEditorPage()) );
|
connect( fileShowEditorPageAction, SIGNAL(triggered()), this, SLOT(fileShowEditorPage()) );
|
||||||
|
|
||||||
fileShowPropertiesPageAction = new QAction( tr("P&roperties") , this );
|
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") );
|
fileShowPropertiesPageAction->setStatusTip( tr("Select project Properties mode") );
|
||||||
connect( fileShowPropertiesPageAction, SIGNAL(triggered()), this, SLOT(fileShowPropertiesPage()) );
|
connect( fileShowPropertiesPageAction, SIGNAL(triggered()), this, SLOT(fileShowPropertiesPage()) );
|
||||||
|
|
||||||
fileShowMergePageAction = new QAction( tr("&Merge") , this );
|
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") );
|
fileShowMergePageAction->setStatusTip( tr("Select project Merge mode") );
|
||||||
connect( fileShowMergePageAction, SIGNAL(triggered()), this, SLOT(fileShowMergePage()) );
|
connect( fileShowMergePageAction, SIGNAL(triggered()), this, SLOT(fileShowMergePage()) );
|
||||||
|
|
||||||
fileShowVariablesPageAction = new QAction( tr("&Variables") , this );
|
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") );
|
fileShowVariablesPageAction->setStatusTip( tr("Select project Variables mode") );
|
||||||
connect( fileShowVariablesPageAction, SIGNAL(triggered()), this, SLOT(fileShowVariablesPage()) );
|
connect( fileShowVariablesPageAction, SIGNAL(triggered()), this, SLOT(fileShowVariablesPage()) );
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace glabels
|
|||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TemplateDesigner::TemplateDesigner( QWidget* parent )
|
TemplateDesigner::TemplateDesigner( QWidget* parent )
|
||||||
: mIsBasedOnCopy(false), QWizard(parent)
|
: QWizard(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle( tr("Product Template Designer") );
|
setWindowTitle( tr("Product Template Designer") );
|
||||||
setPixmap( QWizard::LogoPixmap, QPixmap( ":icons/apps/48x48/glabels.svg" ) );
|
setPixmap( QWizard::LogoPixmap, QPixmap( ":icons/apps/48x48/glabels.svg" ) );
|
||||||
@@ -1315,7 +1315,7 @@ namespace glabels
|
|||||||
x0Spin->setRange( x0Min, x0Max );
|
x0Spin->setRange( x0Min, x0Max );
|
||||||
y0Spin->setRange( y0Min, y0Max );
|
y0Spin->setRange( y0Min, y0Max );
|
||||||
dxSpin->setRange( dxMin, dxMax );
|
dxSpin->setRange( dxMin, dxMax );
|
||||||
dySpin->setRange( dyMin, dxMax );
|
dySpin->setRange( dyMin, dyMax );
|
||||||
|
|
||||||
static bool alreadyInitialized = false;
|
static bool alreadyInitialized = false;
|
||||||
if ( !td->isBasedOnCopy() && !alreadyInitialized )
|
if ( !td->isBasedOnCopy() && !alreadyInitialized )
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ int main( int argc, char **argv )
|
|||||||
// Setup translators
|
// Setup translators
|
||||||
//
|
//
|
||||||
QLocale locale = QLocale::system();
|
QLocale locale = QLocale::system();
|
||||||
QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
|
QString qtTranslationsDir = QLibraryInfo::path( QLibraryInfo::TranslationsPath );
|
||||||
QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
|
QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
|
||||||
|
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace glbarcode
|
|||||||
{
|
{
|
||||||
for (char c : rawData)
|
for (char c : rawData)
|
||||||
{
|
{
|
||||||
if ( (c < 0) || (c > 0x7F) )
|
if ( c < 0 )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,5 +42,5 @@ target_include_directories (glbarcode
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries (glbarcode
|
target_link_libraries (glbarcode
|
||||||
Qt5::Widgets
|
Qt6::Widgets
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-10
@@ -116,16 +116,7 @@ namespace glbarcode
|
|||||||
/**
|
/**
|
||||||
* Indirection "[]" operator
|
* Indirection "[]" operator
|
||||||
*/
|
*/
|
||||||
inline T* operator[]( int i )
|
inline T* operator[]( int i ) const
|
||||||
{
|
|
||||||
return (mData + (mNx * i));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indirection "[]" operator
|
|
||||||
*/
|
|
||||||
inline T const*const operator[]( int i ) const
|
|
||||||
{
|
{
|
||||||
return (mData + (mNx * i));
|
return (mData + (mNx * i));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ namespace glbarcode
|
|||||||
font.setPointSizeF( FONT_SCALE*size );
|
font.setPointSizeF( FONT_SCALE*size );
|
||||||
|
|
||||||
QFontMetricsF fm( font );
|
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();
|
double yCorner = y - fm.ascent();
|
||||||
|
|
||||||
QTextLayout layout( QString::fromStdString(text), font );
|
QTextLayout layout( QString::fromStdString(text), font );
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ set (Model_sources
|
|||||||
Outline.cpp
|
Outline.cpp
|
||||||
PageRenderer.cpp
|
PageRenderer.cpp
|
||||||
Paper.cpp
|
Paper.cpp
|
||||||
|
ParserState.cpp
|
||||||
Point.cpp
|
Point.cpp
|
||||||
RawText.cpp
|
RawText.cpp
|
||||||
Region.cpp
|
Region.cpp
|
||||||
@@ -85,7 +86,7 @@ set (Model_qobject_headers
|
|||||||
Variables.h
|
Variables.h
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_cpp (Model_moc_sources ${Model_qobject_headers})
|
qt6_wrap_cpp (Model_moc_sources ${Model_qobject_headers})
|
||||||
|
|
||||||
#=====================================
|
#=====================================
|
||||||
# Target
|
# Target
|
||||||
@@ -107,10 +108,10 @@ target_include_directories (Model
|
|||||||
target_link_libraries (Model
|
target_link_libraries (Model
|
||||||
Barcode
|
Barcode
|
||||||
Merge
|
Merge
|
||||||
Qt5::Core
|
Qt6::Core
|
||||||
Qt5::PrintSupport
|
Qt6::PrintSupport
|
||||||
Qt5::Xml
|
Qt6::Xml
|
||||||
Qt5::Svg
|
Qt6::Svg
|
||||||
${OPTIONAL_ZLIB}
|
${OPTIONAL_ZLIB}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -21,7 +21,8 @@
|
|||||||
#include "Distance.h"
|
#include "Distance.h"
|
||||||
|
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QtDebug>
|
#include <QDebug>
|
||||||
|
#include <QIODevice>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
|
|||||||
@@ -60,6 +60,15 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame::~Frame()
|
||||||
|
{
|
||||||
|
while ( !mMarkups.isEmpty() )
|
||||||
|
{
|
||||||
|
delete mMarkups.takeFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Frame::id() const
|
QString Frame::id() const
|
||||||
{
|
{
|
||||||
return mId;
|
return mId;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ namespace glabels
|
|||||||
Frame( const Frame& other );
|
Frame( const Frame& other );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~Frame();
|
||||||
virtual Frame* dup() const = 0;
|
virtual Frame* dup() const = 0;
|
||||||
|
|
||||||
QString id() const;
|
QString id() const;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ namespace glabels
|
|||||||
class Markup
|
class Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~Markup() = default;
|
||||||
|
|
||||||
virtual Markup* dup() const = 0;
|
virtual Markup* dup() const = 0;
|
||||||
|
|
||||||
virtual QPainterPath path( const Frame* frame ) const;
|
virtual QPainterPath path( const Frame* frame ) const;
|
||||||
|
|||||||
+6
-4
@@ -55,7 +55,6 @@ namespace glabels
|
|||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
///
|
///
|
||||||
Model::Model()
|
Model::Model()
|
||||||
: mUntitledInstance(0), mModified(true), mRotate(false)
|
|
||||||
{
|
{
|
||||||
mVariables = new Variables();
|
mVariables = new Variables();
|
||||||
mMerge = new merge::None();
|
mMerge = new merge::None();
|
||||||
@@ -65,7 +64,6 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
Model::Model( merge::Merge* merge, Variables* variables )
|
Model::Model( merge::Merge* merge, Variables* variables )
|
||||||
: mUntitledInstance(0), mModified(true), mRotate(false)
|
|
||||||
{
|
{
|
||||||
mVariables = variables; // Shared
|
mVariables = variables; // Shared
|
||||||
mMerge = merge; // Shared
|
mMerge = merge; // Shared
|
||||||
@@ -235,8 +233,10 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
Distance Model::w() const
|
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();
|
return mRotate ? frame->h() : frame->w();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -251,8 +251,10 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
Distance Model::h() const
|
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();
|
return mRotate ? frame->w() : frame->h();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+3
-3
@@ -233,11 +233,11 @@ namespace glabels
|
|||||||
// Private data
|
// Private data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
int mUntitledInstance;
|
int mUntitledInstance{0};
|
||||||
bool mModified;
|
bool mModified{true};
|
||||||
QString mFileName;
|
QString mFileName;
|
||||||
Template mTmplate;
|
Template mTmplate;
|
||||||
bool mRotate;
|
bool mRotate{false};
|
||||||
|
|
||||||
QList<ModelObject*> mObjectList;
|
QList<ModelObject*> mObjectList;
|
||||||
|
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
mImage = new QImage(value);
|
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 ) );
|
mFilenameNode = TextNode( false, QString("%image_%1%").arg( cs ) );
|
||||||
|
|
||||||
emit changed();
|
emit changed();
|
||||||
|
|||||||
@@ -47,9 +47,6 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
PageRenderer::PageRenderer( const Model* model )
|
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 )
|
if ( model )
|
||||||
{
|
{
|
||||||
|
|||||||
+19
-19
@@ -111,29 +111,29 @@ namespace glabels
|
|||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
const Model* mModel;
|
const Model* mModel{ nullptr };
|
||||||
const merge::Merge* mMerge;
|
const merge::Merge* mMerge{ nullptr };
|
||||||
Variables* mVariables;
|
Variables* mVariables{ nullptr };
|
||||||
|
|
||||||
int mNCopies;
|
int mNCopies{ 0 };
|
||||||
int mStartItem;
|
int mStartItem{ 0 };
|
||||||
int mLastItem;
|
int mLastItem{ 0 };
|
||||||
int mNGroups;
|
int mNGroups{ 0 };
|
||||||
int mNItemsPerGroup;
|
int mNItemsPerGroup{ 0 };
|
||||||
int mNPagesPerGroup;
|
int mNPagesPerGroup{ 0 };
|
||||||
int mIPage;
|
int mIPage{ 0 };
|
||||||
|
|
||||||
bool mIsMerge;
|
bool mIsMerge{ false };
|
||||||
|
|
||||||
int mNItems;
|
int mNItems{ 0 };
|
||||||
int mNPages;
|
int mNPages{ 0 };
|
||||||
int mNItemsPerPage;
|
int mNItemsPerPage{ 0 };
|
||||||
|
|
||||||
bool mIsCollated;
|
bool mIsCollated{ false };
|
||||||
bool mAreGroupsContiguous;
|
bool mAreGroupsContiguous{ false };
|
||||||
bool mPrintOutlines;
|
bool mPrintOutlines{ false };
|
||||||
bool mPrintCropMarks;
|
bool mPrintCropMarks{ false };
|
||||||
bool mPrintReverse;
|
bool mPrintReverse{ false };
|
||||||
|
|
||||||
QVector<Point> mOrigins;
|
QVector<Point> mOrigins;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
@@ -18,10 +18,14 @@
|
|||||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "RawText.h"
|
#include "RawText.h"
|
||||||
|
|
||||||
|
#include "ParserState.h"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
namespace model
|
namespace model
|
||||||
@@ -112,8 +116,8 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
Token token;
|
Token token;
|
||||||
|
|
||||||
QStringRef s = &mString;
|
ParserState s( mString );
|
||||||
while ( s.size() )
|
while ( s.charsLeft() )
|
||||||
{
|
{
|
||||||
SubstitutionField field;
|
SubstitutionField field;
|
||||||
if ( SubstitutionField::parse( s, field ) )
|
if ( SubstitutionField::parse( s, field ) )
|
||||||
@@ -134,7 +138,7 @@ namespace glabels
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
token.text += s[0];
|
token.text += s[0];
|
||||||
s = s.mid(1);
|
s.advanceChars(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
// Guess at a suitable default
|
// Guess at a suitable default
|
||||||
QString defaultFamily;
|
QString defaultFamily;
|
||||||
switch (QLocale::system().country())
|
switch (QLocale::system().territory())
|
||||||
{
|
{
|
||||||
case QLocale::UnitedStates:
|
case QLocale::UnitedStates:
|
||||||
case QLocale::Canada:
|
case QLocale::Canada:
|
||||||
|
|||||||
+42
-42
@@ -37,7 +37,7 @@ namespace glabels
|
|||||||
SubstitutionField::SubstitutionField( const QString& string )
|
SubstitutionField::SubstitutionField( const QString& string )
|
||||||
: mFormatType(0), mNewLine(false)
|
: mFormatType(0), mNewLine(false)
|
||||||
{
|
{
|
||||||
QStringRef s(&string);
|
ParserState s(string);
|
||||||
parse( s, *this );
|
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 ) )
|
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 ) )
|
if ( !parseModifier( sTmp, field ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sTmp.size() && sTmp[0] == '}' )
|
if ( sTmp.charsLeft() && sTmp[0] == '}' )
|
||||||
{
|
{
|
||||||
sTmp = sTmp.mid(1);
|
sTmp.advanceChars( 1 );
|
||||||
|
|
||||||
// Success. Update s.
|
// Success. Update s.
|
||||||
s = sTmp;
|
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;
|
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] );
|
field.mFieldName.append( s[0] );
|
||||||
s = s.mid(1);
|
s.advanceChars( 1 );
|
||||||
|
|
||||||
success = true;
|
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;
|
bool success = false;
|
||||||
|
|
||||||
if ( s.size() && s[0] == '%' )
|
if ( s.charsLeft() && s[0] == '%' )
|
||||||
{
|
{
|
||||||
s = s.mid(1);
|
s.advanceChars( 1 );
|
||||||
success = parseFormatModifier( s, field );
|
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 );
|
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 );
|
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();
|
field.mDefaultValue.clear();
|
||||||
|
|
||||||
while ( s.size() && !QString( ":}" ).contains( s[0] ) )
|
while ( s.charsLeft() && !QString( ":}" ).contains( s[0] ) )
|
||||||
{
|
{
|
||||||
if ( s[0] == '\\' )
|
if ( s[0] == '\\' )
|
||||||
{
|
{
|
||||||
s = s.mid(1); // Skip escape
|
s.advanceChars( 1 ); // Skip escape
|
||||||
if ( s.size() )
|
if ( s.charsLeft() )
|
||||||
{
|
{
|
||||||
field.mDefaultValue.append( s[0] );
|
field.mDefaultValue.append( s[0] );
|
||||||
s = s.mid(1);
|
s.advanceChars( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
field.mDefaultValue.append( s[0] );
|
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 = "%";
|
field.mFormat = "%";
|
||||||
|
|
||||||
parseFormatFlags( s, field );
|
parseFormatFlags( s, field );
|
||||||
parseFormatWidth( s, field );
|
parseFormatWidth( s, field );
|
||||||
|
|
||||||
if ( s.size() && s[0] == '.' )
|
if ( s.charsLeft() && s[0] == '.' )
|
||||||
{
|
{
|
||||||
field.mFormat += ".";
|
field.mFormat += ".";
|
||||||
s = s.mid(1);
|
s.advanceChars( 1 );
|
||||||
parseFormatPrecision( s, field );
|
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];
|
field.mFormat += s[0];
|
||||||
s = s.mid(1);
|
s.advanceChars( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SubstitutionField::parseFormatWidth( QStringRef& s, SubstitutionField& field )
|
bool SubstitutionField::parseFormatWidth( ParserState& s, SubstitutionField& field )
|
||||||
{
|
{
|
||||||
return parseNaturalInteger( s, field );
|
return parseNaturalInteger( s, field );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SubstitutionField::parseFormatPrecision( QStringRef& s, SubstitutionField& field )
|
bool SubstitutionField::parseFormatPrecision( ParserState& s, SubstitutionField& field )
|
||||||
{
|
{
|
||||||
return parseNaturalInteger( s, field );
|
return parseNaturalInteger( s, field );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SubstitutionField::parseFormatType( QStringRef& s, SubstitutionField& field )
|
bool SubstitutionField::parseFormatType( ParserState& s, SubstitutionField& field )
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
if ( s.size() && QString( "diufFeEgGxXos" ).contains( s[0] ) )
|
if ( s.charsLeft() && QString( "diufFeEgGxXos" ).contains( s[0] ) )
|
||||||
{
|
{
|
||||||
field.mFormatType = s[0];
|
field.mFormatType = s[0];
|
||||||
field.mFormat += s[0];
|
field.mFormat += s[0];
|
||||||
s = s.mid(1);
|
s.advanceChars( 1 );
|
||||||
success = true;
|
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;
|
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];
|
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];
|
field.mFormat += s[0];
|
||||||
s = s.mid(1);
|
s.advanceChars( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
success = true;
|
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;
|
field.mNewLine = true;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+13
-12
@@ -21,12 +21,13 @@
|
|||||||
#ifndef model_SubstitutionField_h
|
#ifndef model_SubstitutionField_h
|
||||||
#define model_SubstitutionField_h
|
#define model_SubstitutionField_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "ParserState.h"
|
||||||
#include "Variables.h"
|
#include "Variables.h"
|
||||||
|
|
||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringRef>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
@@ -48,19 +49,19 @@ namespace glabels
|
|||||||
QChar formatType() const;
|
QChar formatType() const;
|
||||||
bool newLine() const;
|
bool newLine() const;
|
||||||
|
|
||||||
static bool parse( QStringRef& s, SubstitutionField& field );
|
static bool parse( ParserState& s, SubstitutionField& field );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool parseFieldName( QStringRef& s, SubstitutionField& field );
|
static bool parseFieldName( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseModifier( QStringRef& s, SubstitutionField& field );
|
static bool parseModifier( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseDefaultValueModifier( QStringRef& s, SubstitutionField& field );
|
static bool parseDefaultValueModifier( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseFormatModifier( QStringRef& s, SubstitutionField& field );
|
static bool parseFormatModifier( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseFormatFlags( QStringRef& s, SubstitutionField& field );
|
static bool parseFormatFlags( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseFormatWidth( QStringRef& s, SubstitutionField& field );
|
static bool parseFormatWidth( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseFormatPrecision( QStringRef& s, SubstitutionField& field );
|
static bool parseFormatPrecision( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseFormatType( QStringRef& s, SubstitutionField& field );
|
static bool parseFormatType( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseNaturalInteger( QStringRef& s, SubstitutionField& field );
|
static bool parseNaturalInteger( ParserState& s, SubstitutionField& field );
|
||||||
static bool parseNewLineModifier( QStringRef& s, SubstitutionField& field );
|
static bool parseNewLineModifier( ParserState& s, SubstitutionField& field );
|
||||||
|
|
||||||
QString formatValue( const QString& value ) const;
|
QString formatValue( const QString& value ) const;
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -46,10 +46,7 @@ namespace glabels
|
|||||||
mPageWidth(pageWidth),
|
mPageWidth(pageWidth),
|
||||||
mPageHeight(pageHeight),
|
mPageHeight(pageHeight),
|
||||||
mRollWidth(rollWidth),
|
mRollWidth(rollWidth),
|
||||||
mIsUserDefined(isUserDefined),
|
mIsUserDefined(isUserDefined)
|
||||||
mIsSizeIso(false),
|
|
||||||
mIsSizeUs(false),
|
|
||||||
mName("")
|
|
||||||
{
|
{
|
||||||
mName.append( brand ).append( " " ).append( part );
|
mName.append( brand ).append( " " ).append( part );
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -112,11 +112,12 @@ namespace glabels
|
|||||||
Distance mPageWidth;
|
Distance mPageWidth;
|
||||||
Distance mPageHeight;
|
Distance mPageHeight;
|
||||||
Distance mRollWidth;
|
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 mEquivPart;
|
||||||
QString mName;
|
QString mName;
|
||||||
|
|||||||
+2
-1
@@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QtDebug>
|
#include <QDebug>
|
||||||
|
#include <QIODevice>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
|
|||||||
@@ -1,99 +1,99 @@
|
|||||||
if (Qt5Test_FOUND)
|
if (Qt6Test_FOUND)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test SubstitutionField class
|
# 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})
|
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)
|
add_test (NAME SubstitutionField COMMAND TestSubstitutionField)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test XmlUtil class
|
# 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})
|
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)
|
add_test (NAME XmlUtil COMMAND TestXmlUtil)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test XmlLabelCreator/Parser classes
|
# 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})
|
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)
|
add_test (NAME XmlLabel COMMAND TestXmlLabel)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test ColorNode class
|
# 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})
|
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)
|
add_test (NAME ColorNode COMMAND TestColorNode)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test FileUtil class
|
# 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})
|
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)
|
add_test (NAME FileUtil COMMAND TestFileUtil)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test Merge classes
|
# 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})
|
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)
|
add_test (NAME Merge COMMAND TestMerge)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test Model class
|
# 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})
|
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)
|
add_test (NAME Model COMMAND TestModel)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test ModelImageObject class
|
# 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})
|
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)
|
add_test (NAME ModelImageObject COMMAND TestModelImageObject)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test RawText class
|
# 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})
|
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)
|
add_test (NAME RawText COMMAND TestRawText)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test TextNode class
|
# 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})
|
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)
|
add_test (NAME TextNode COMMAND TestTextNode)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test Variable class
|
# 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})
|
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)
|
add_test (NAME Variable COMMAND TestVariable)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Test Variables class
|
# 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})
|
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)
|
add_test (NAME Variables COMMAND TestVariables)
|
||||||
|
|
||||||
endif (Qt5Test_FOUND)
|
endif (Qt6Test_FOUND)
|
||||||
|
|||||||
@@ -36,7 +36,8 @@
|
|||||||
#include "merge/TextCsv.h"
|
#include "merge/TextCsv.h"
|
||||||
#include "merge/TextCsvKeys.h"
|
#include "merge/TextCsvKeys.h"
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QDebug>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
|
||||||
QTEST_MAIN(TestModel)
|
QTEST_MAIN(TestModel)
|
||||||
@@ -59,7 +60,7 @@ void TestModel::model()
|
|||||||
model.clearModified();
|
model.clearModified();
|
||||||
QVERIFY( !model.isModified() );
|
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" );
|
model.setFileName( "dir/file1.ext" );
|
||||||
QCOMPARE( model.fileName(), QString( "dir/file1.ext" ) );
|
QCOMPARE( model.fileName(), QString( "dir/file1.ext" ) );
|
||||||
QCOMPARE( model.shortName(), QString( "file1" ) );
|
QCOMPARE( model.shortName(), QString( "file1" ) );
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void TestSubstitutionField::parseValid()
|
|||||||
// Valid substitution fields (concatenated in single input string)
|
// 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}";
|
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;
|
model::SubstitutionField f1;
|
||||||
QCOMPARE( model::SubstitutionField::parse( s, f1 ), true );
|
QCOMPARE( model::SubstitutionField::parse( s, f1 ), true );
|
||||||
@@ -87,49 +87,49 @@ void TestSubstitutionField::parseInvalid()
|
|||||||
// Ordinary text
|
// Ordinary text
|
||||||
//
|
//
|
||||||
QString input5 = "Abcdefg";
|
QString input5 = "Abcdefg";
|
||||||
QStringRef s5 = &input5;
|
model::ParserState s5( input5 );
|
||||||
model::SubstitutionField f5;
|
model::SubstitutionField f5;
|
||||||
QCOMPARE( model::SubstitutionField::parse( s5, f5 ), false );
|
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)
|
// Invalid substitution fields (which are treated as ordinary text)
|
||||||
//
|
//
|
||||||
QString input6 = "$abc";
|
QString input6 = "$abc";
|
||||||
QStringRef s6 = &input6;
|
model::ParserState s6( input6 );
|
||||||
model::SubstitutionField f6;
|
model::SubstitutionField f6;
|
||||||
QCOMPARE( model::SubstitutionField::parse( s6, f6 ), false );
|
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";
|
QString input7 = "${abc";
|
||||||
QStringRef s7 = &input7;
|
model::ParserState s7( input7 );
|
||||||
model::SubstitutionField f7;
|
model::SubstitutionField f7;
|
||||||
QCOMPARE( model::SubstitutionField::parse( s7, f7 ), false );
|
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:}";
|
QString input8 = "${abc:}";
|
||||||
QStringRef s8 = &input8;
|
model::ParserState s8( input8 );
|
||||||
model::SubstitutionField f8;
|
model::SubstitutionField f8;
|
||||||
QCOMPARE( model::SubstitutionField::parse( s8, f8 ), false );
|
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.
|
// Even though format is invalid, let it slide. Overall structure still good. Format will be ignored.
|
||||||
QString input9 = "${abc:%3.2}";
|
QString input9 = "${abc:%3.2}";
|
||||||
QStringRef s9 = &input9;
|
model::ParserState s9( input9 );
|
||||||
model::SubstitutionField f9;
|
model::SubstitutionField f9;
|
||||||
QCOMPARE( model::SubstitutionField::parse( s9, f9 ), true );
|
QCOMPARE( model::SubstitutionField::parse( s9, f9 ), true );
|
||||||
|
|
||||||
QString input10 = "${embedded\nnew-line}";
|
QString input10 = "${embedded\nnew-line}";
|
||||||
QStringRef s10 = &input10;
|
model::ParserState s10( input10 );
|
||||||
model::SubstitutionField f10;
|
model::SubstitutionField f10;
|
||||||
QCOMPARE( model::SubstitutionField::parse( s10, f10 ), false );
|
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}";
|
QString input11 = "${how-about-a\ttab}";
|
||||||
QStringRef s11 = &input11;
|
model::ParserState s11( input11 );
|
||||||
model::SubstitutionField f11;
|
model::SubstitutionField f11;
|
||||||
QCOMPARE( model::SubstitutionField::parse( s11, f11 ), false );
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ include (TRANSLATION_FILES.txt)
|
|||||||
#
|
#
|
||||||
# Update strings in C-locale translation files (lupdate+lrelease)
|
# 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}/glabels
|
||||||
${CMAKE_SOURCE_DIR}/model
|
${CMAKE_SOURCE_DIR}/model
|
||||||
${CMAKE_SOURCE_DIR}/backends
|
${CMAKE_SOURCE_DIR}/backends
|
||||||
glabels_C.ts
|
glabels_C.ts
|
||||||
OPTIONS -no-obsolete -locations none
|
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
|
${CMAKE_CURRENT_BINARY_DIR}/template-strings.h
|
||||||
templates_C.ts
|
templates_C.ts
|
||||||
OPTIONS -no-obsolete -locations none
|
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)
|
# 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}
|
${GLABELS_TS_FILES}
|
||||||
${TEMPLATES_TS_FILES}
|
${TEMPLATES_TS_FILES}
|
||||||
)
|
)
|
||||||
@@ -50,8 +50,8 @@ target_compile_features (Model
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries (XmlStrings
|
target_link_libraries (XmlStrings
|
||||||
Qt5::Core
|
Qt6::Core
|
||||||
Qt5::Xml
|
Qt6::Xml
|
||||||
)
|
)
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
|
|||||||
Reference in New Issue
Block a user