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:
@@ -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
@@ -21,7 +21,8 @@
|
||||
#include "Distance.h"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QtDebug>
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
|
||||
|
||||
namespace glabels
|
||||
|
||||
@@ -60,6 +60,15 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
Frame::~Frame()
|
||||
{
|
||||
while ( !mMarkups.isEmpty() )
|
||||
{
|
||||
delete mMarkups.takeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString Frame::id() const
|
||||
{
|
||||
return mId;
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace glabels
|
||||
Frame( const Frame& other );
|
||||
|
||||
public:
|
||||
virtual ~Frame();
|
||||
virtual Frame* dup() const = 0;
|
||||
|
||||
QString id() const;
|
||||
|
||||
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
|
||||
#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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -22,7 +22,8 @@
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QCoreApplication>
|
||||
#include <QtDebug>
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
|
||||
|
||||
namespace glabels
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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" ) );
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user