UserVariables branch merge
This commit is contained in:
@@ -34,3 +34,6 @@ core
|
|||||||
*.sav*
|
*.sav*
|
||||||
.directory
|
.directory
|
||||||
TEST-DATA
|
TEST-DATA
|
||||||
|
SAV*
|
||||||
|
OLD*
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,28 @@ modifiers = modifier [ ":" modifiers ] ;
|
|||||||
modifier = format-modifier | default-value-modifier | new-line-modifier;
|
modifier = format-modifier | default-value-modifier | new-line-modifier;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Field Names
|
||||||
|
-----------
|
||||||
|
Field names can refer to either [Document Merge Fields](#document-merge-fields) or [User Variables](#user-variables). If a document merge field and a user variable share the same name, the document merge field takes precidence. Its syntax is simply:
|
||||||
|
|
||||||
|
```ebnf
|
||||||
|
field-name = merge-field-name | user-variable-name ;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Document Merge Fields
|
||||||
|
Document merge fields are the primary source of substitution fields. A document merge field represents a field from an external data source, such as a CSV file. The valid syntax for a document merge field name is determined by the merge source, with the following exception. Merge field names cannot contain either a colon (":") or closing curly bracket ("}").
|
||||||
|
|
||||||
|
### User Variables
|
||||||
|
Substitution fields can also refer to user variables. The syntax for valid user variable names is
|
||||||
|
|
||||||
|
```ebnf
|
||||||
|
letter = "a" | "b" | ... | "z" | "A" | ... | "Z";
|
||||||
|
digit = "0" | "1" | "2" | ... | "9";
|
||||||
|
user-variable-name = ( letter | "_" ) , { letter | digit | "_" } ;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Modifiers
|
Modifiers
|
||||||
---------
|
---------
|
||||||
### Format-Modifier (`%`)
|
### Format-Modifier (`%`)
|
||||||
@@ -89,20 +111,3 @@ ${CITY} ${STATE} ${ZIP}
|
|||||||
`${ADDR2}` would be printed on its own line, only if it is set and non-empty.
|
`${ADDR2}` would be printed on its own line, only if it is set and non-empty.
|
||||||
|
|
||||||
|
|
||||||
Document Merge Fields
|
|
||||||
---------------------
|
|
||||||
Document merge fields are the primary source of substitution fields. A document merge field represents a field from an external data source, such as a CSV file.
|
|
||||||
|
|
||||||
User Defined Variables
|
|
||||||
----------------------
|
|
||||||
Alternatively, merge fields can refer to user defined variables.
|
|
||||||
|
|
||||||
Built-In Variables
|
|
||||||
------------------
|
|
||||||
Potentially, merge fields may also refer to built-in variables. Candidates include:
|
|
||||||
- LABEL_NUMBER
|
|
||||||
- PAGE_NUMBER
|
|
||||||
- DATE
|
|
||||||
- TIME
|
|
||||||
- FILE_NAME
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,3 +29,15 @@ Add support for "Continuous Roll" labels
|
|||||||
|
|
||||||
Write help documentation
|
Write help documentation
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
||||||
|
To Do List for gLabels 4.1 -- 2019-03-17
|
||||||
|
========================================
|
||||||
|
|
||||||
|
Create a "built-in" merge source
|
||||||
|
--------------------------------
|
||||||
|
As an alternative to external merge sources, let the user edit the merge source
|
||||||
|
in situ. The user can add fields. The user can add records using those fields.
|
||||||
|
The user created database will become part of the glabels project file.
|
||||||
|
For simple databases, such as a small address list, this would be much easier
|
||||||
|
to deal with than creating it externally.
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ set (glabels_sources
|
|||||||
ColorHistory.cpp
|
ColorHistory.cpp
|
||||||
ColorPaletteDialog.cpp
|
ColorPaletteDialog.cpp
|
||||||
ColorPaletteItem.cpp
|
ColorPaletteItem.cpp
|
||||||
ColorPaletteButtonItem.cpp
|
|
||||||
ColorSwatch.cpp
|
ColorSwatch.cpp
|
||||||
Cursors.cpp
|
Cursors.cpp
|
||||||
|
EditVariableDialog.cpp
|
||||||
FieldButton.cpp
|
FieldButton.cpp
|
||||||
File.cpp
|
File.cpp
|
||||||
Help.cpp
|
Help.cpp
|
||||||
@@ -40,6 +40,7 @@ set (glabels_sources
|
|||||||
TemplatePicker.cpp
|
TemplatePicker.cpp
|
||||||
TemplatePickerItem.cpp
|
TemplatePickerItem.cpp
|
||||||
UndoRedoModel.cpp
|
UndoRedoModel.cpp
|
||||||
|
VariablesView.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set (glabels_qobject_headers
|
set (glabels_qobject_headers
|
||||||
@@ -51,7 +52,7 @@ set (glabels_qobject_headers
|
|||||||
ColorHistory.h
|
ColorHistory.h
|
||||||
ColorPaletteDialog.h
|
ColorPaletteDialog.h
|
||||||
ColorPaletteItem.h
|
ColorPaletteItem.h
|
||||||
ColorPaletteButtonItem.h
|
EditVariableDialog.h
|
||||||
FieldButton.h
|
FieldButton.h
|
||||||
File.h
|
File.h
|
||||||
LabelEditor.h
|
LabelEditor.h
|
||||||
@@ -69,10 +70,12 @@ set (glabels_qobject_headers
|
|||||||
TemplateDesigner.h
|
TemplateDesigner.h
|
||||||
TemplatePicker.h
|
TemplatePicker.h
|
||||||
UndoRedoModel.h
|
UndoRedoModel.h
|
||||||
|
VariablesView.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (glabels_forms
|
set (glabels_forms
|
||||||
ui/AboutDialog.ui
|
ui/AboutDialog.ui
|
||||||
|
ui/EditVariableDialog.ui
|
||||||
ui/MergeView.ui
|
ui/MergeView.ui
|
||||||
ui/ObjectEditor.ui
|
ui/ObjectEditor.ui
|
||||||
ui/PreferencesDialog.ui
|
ui/PreferencesDialog.ui
|
||||||
@@ -95,6 +98,7 @@ set (glabels_forms
|
|||||||
ui/TemplateDesignerOneLayoutPage.ui
|
ui/TemplateDesignerOneLayoutPage.ui
|
||||||
ui/TemplateDesignerTwoLayoutPage.ui
|
ui/TemplateDesignerTwoLayoutPage.ui
|
||||||
ui/TemplateDesignerApplyPage.ui
|
ui/TemplateDesignerApplyPage.ui
|
||||||
|
ui/VariablesView.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set (glabels_resource_files
|
set (glabels_resource_files
|
||||||
|
|||||||
+10
-11
@@ -48,8 +48,9 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
void ColorButton::init( const QString& defaultLabel,
|
void ColorButton::init( const QString& defaultLabel,
|
||||||
const QColor& defaultColor,
|
const QColor& defaultColor,
|
||||||
const QColor& color )
|
const QColor& color,
|
||||||
|
bool showUseFieldButton )
|
||||||
{
|
{
|
||||||
mDefaultColor = defaultColor;
|
mDefaultColor = defaultColor;
|
||||||
mColorNode = model::ColorNode( color );
|
mColorNode = model::ColorNode( color );
|
||||||
@@ -61,7 +62,10 @@ namespace glabels
|
|||||||
setText( "" );
|
setText( "" );
|
||||||
setCheckable( true );
|
setCheckable( true );
|
||||||
|
|
||||||
mDialog = new ColorPaletteDialog( defaultLabel, defaultColor, color );
|
mDialog = new ColorPaletteDialog( defaultLabel,
|
||||||
|
defaultColor,
|
||||||
|
color,
|
||||||
|
showUseFieldButton );
|
||||||
|
|
||||||
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
|
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
|
||||||
connect( mDialog, SIGNAL(colorChanged(model::ColorNode,bool)),
|
connect( mDialog, SIGNAL(colorChanged(model::ColorNode,bool)),
|
||||||
@@ -124,15 +128,10 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setKeys( const QList<QString> keyList )
|
void ColorButton::setKeys( const merge::Merge* merge,
|
||||||
|
const model::Variables* variables )
|
||||||
{
|
{
|
||||||
mDialog->setKeys( keyList );
|
mDialog->setKeys( merge, variables );
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::clearKeys()
|
|
||||||
{
|
|
||||||
mDialog->clearKeys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,13 +58,18 @@ namespace glabels
|
|||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color );
|
void init( const QString& defaultLabel,
|
||||||
|
const QColor& defaultColor,
|
||||||
|
const QColor& color,
|
||||||
|
bool showUseFieldButton = true );
|
||||||
|
|
||||||
void setColorNode( model::ColorNode colorNode );
|
void setColorNode( model::ColorNode colorNode );
|
||||||
void setColor( QColor color );
|
void setColor( QColor color );
|
||||||
void setToDefault();
|
void setToDefault();
|
||||||
model::ColorNode colorNode();
|
model::ColorNode colorNode();
|
||||||
void setKeys( const QList<QString> keyList );
|
|
||||||
void clearKeys();
|
void setKeys( const merge::Merge* merge,
|
||||||
|
const model::Variables* variables );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
+70
-40
@@ -46,23 +46,25 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorHistory::addColor( const QColor &color )
|
void ColorHistory::addColor( const QColor &color, const QString& name )
|
||||||
{
|
{
|
||||||
QList<QColor> colorList = readColorList();
|
QString nameColor = name + ":" + color.name();
|
||||||
|
|
||||||
|
QStringList nameColorList = readNameColorList();
|
||||||
|
|
||||||
// Remove any occurrences of this color already in list
|
// Remove any occurrences of this color already in list
|
||||||
colorList.removeAll( color );
|
nameColorList.removeAll( nameColor );
|
||||||
|
|
||||||
// Now add to list
|
// Now add to list
|
||||||
colorList.append( color );
|
nameColorList.append( nameColor );
|
||||||
|
|
||||||
// Remove oldest colors, if size exceeds current max
|
// Remove oldest colors, if size exceeds current max
|
||||||
while ( colorList.size() > MAX_COLORS )
|
while ( nameColorList.size() > MAX_COLORS )
|
||||||
{
|
{
|
||||||
colorList.removeFirst();
|
nameColorList.removeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
writeColorList( colorList );
|
writeNameColorList( nameColorList );
|
||||||
|
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
@@ -70,55 +72,83 @@ namespace glabels
|
|||||||
|
|
||||||
QList<QColor> ColorHistory::getColors()
|
QList<QColor> ColorHistory::getColors()
|
||||||
{
|
{
|
||||||
return readColorList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QColor ColorHistory::getColor( int id )
|
|
||||||
{
|
|
||||||
QList<QColor> colors = readColorList();
|
|
||||||
return colors[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<QColor> ColorHistory::readColorList()
|
|
||||||
{
|
|
||||||
QStringList defaultList;
|
|
||||||
QSettings settings;
|
|
||||||
|
|
||||||
settings.beginGroup( "ColorHistory" );
|
|
||||||
QStringList colorNameList = settings.value( "colors", defaultList ).toStringList();
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
QList<QColor> colorList;
|
QList<QColor> colorList;
|
||||||
foreach ( QString colorName, colorNameList )
|
|
||||||
{
|
|
||||||
colorList << QColor( colorName );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove oldest colors, if size exceeds current max
|
for ( QString& nameColor : readNameColorList() )
|
||||||
while ( colorList.size() > MAX_COLORS )
|
|
||||||
{
|
{
|
||||||
colorList.removeFirst();
|
QStringList v = nameColor.split( ':' );
|
||||||
|
if ( v.size() == 2 )
|
||||||
|
{
|
||||||
|
colorList << QColor( v[1] );
|
||||||
|
}
|
||||||
|
else if ( v.size() == 1 )
|
||||||
|
{
|
||||||
|
// Old-style, no name
|
||||||
|
colorList << QColor( v[0] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Should not happen
|
||||||
|
qWarning() << "Invalid color history.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return colorList;
|
return colorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
QStringList ColorHistory::getNames()
|
||||||
{
|
{
|
||||||
// Build name list
|
QStringList nameList;
|
||||||
QStringList colorNameList;
|
|
||||||
foreach ( QColor color, colorList )
|
for ( QString& nameColor : readNameColorList() )
|
||||||
{
|
{
|
||||||
colorNameList << color.name();
|
QStringList v = nameColor.split( ':' );
|
||||||
|
if ( v.size() == 2 )
|
||||||
|
{
|
||||||
|
nameList << v[0];
|
||||||
|
}
|
||||||
|
else if ( v.size() == 1 )
|
||||||
|
{
|
||||||
|
// Old-style, no name
|
||||||
|
nameList << QString(tr("color %1")).arg( v[0] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Should not happen
|
||||||
|
qWarning() << "Invalid color history.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nameList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList ColorHistory::readNameColorList()
|
||||||
|
{
|
||||||
|
QStringList defaultList;
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.beginGroup( "ColorHistory" );
|
||||||
|
QStringList nameColorList = settings.value( "colors", defaultList ).toStringList();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
// Remove oldest colors, if size exceeds current max
|
||||||
|
while ( nameColorList.size() > MAX_COLORS )
|
||||||
|
{
|
||||||
|
nameColorList.removeFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nameColorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorHistory::writeNameColorList( const QStringList& nameColorList )
|
||||||
|
{
|
||||||
// Save
|
// Save
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup( "ColorHistory" );
|
settings.beginGroup( "ColorHistory" );
|
||||||
settings.setValue( "colors", colorNameList );
|
settings.setValue( "colors", nameColorList );
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,17 +60,17 @@ namespace glabels
|
|||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void addColor( const QColor &color );
|
void addColor( const QColor& color, const QString& name );
|
||||||
QList<QColor> getColors();
|
QList<QColor> getColors();
|
||||||
QColor getColor( int id );
|
QStringList getNames();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Methods
|
// Private Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QList<QColor> readColorList();
|
QStringList readNameColorList();
|
||||||
void writeColorList( const QList<QColor>& colorList );
|
void writeNameColorList( const QStringList& nameColorList );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
/* ColorPaletteButtonItem.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Jim 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 "ColorPaletteButtonItem.h"
|
|
||||||
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QPainter>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
//
|
|
||||||
// Private
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
const int border = 4;
|
|
||||||
const int hBox = 25;
|
|
||||||
const int outlineWidthPixels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor From Data
|
|
||||||
///
|
|
||||||
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
|
|
||||||
: QWidget(parent), mText(text), mHover(false)
|
|
||||||
{
|
|
||||||
setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
|
|
||||||
setMinimumSize( hBox+2*border+1, hBox+2*border+1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Paint Event
|
|
||||||
///
|
|
||||||
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
|
||||||
{
|
|
||||||
QPainter painter(this);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw background
|
|
||||||
//
|
|
||||||
if ( isEnabled() && mHover )
|
|
||||||
{
|
|
||||||
QLinearGradient gradient( 0, 0, 0, height() );
|
|
||||||
gradient.setColorAt( 0, palette().color( QPalette::Highlight ).lighter() );
|
|
||||||
gradient.setColorAt( 1, palette().color( QPalette::Highlight ) );
|
|
||||||
painter.setBrush( QBrush( gradient ) );
|
|
||||||
|
|
||||||
QPen pen( palette().color( QPalette::Text ) );
|
|
||||||
pen.setWidth( outlineWidthPixels );
|
|
||||||
painter.setPen( pen );
|
|
||||||
|
|
||||||
painter.drawRect( 0, 0, width()-1, height()-1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw text
|
|
||||||
//
|
|
||||||
painter.setBrush( QBrush( Qt::NoBrush ) );
|
|
||||||
|
|
||||||
if ( isEnabled() && mHover )
|
|
||||||
{
|
|
||||||
painter.setPen( QPen( palette().color( QPalette::HighlightedText ) ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
painter.setPen( QPen( palette().color( QPalette::Text ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect textRect( border, border, width()-2*border, hBox );
|
|
||||||
|
|
||||||
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Enter Event
|
|
||||||
///
|
|
||||||
void ColorPaletteButtonItem::enterEvent( QEvent* event )
|
|
||||||
{
|
|
||||||
mHover = true;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Leave Event
|
|
||||||
///
|
|
||||||
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
|
|
||||||
{
|
|
||||||
mHover = false;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Mouse Press Event
|
|
||||||
///
|
|
||||||
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
|
|
||||||
{
|
|
||||||
emit activated();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels
|
|
||||||
+96
-106
@@ -18,14 +18,16 @@
|
|||||||
* 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 "ColorPaletteDialog.h"
|
#include "ColorPaletteDialog.h"
|
||||||
|
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QFrame>
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
@@ -83,6 +85,7 @@ namespace glabels
|
|||||||
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
||||||
const QColor& defaultColor,
|
const QColor& defaultColor,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
|
bool showUseFieldButton,
|
||||||
QWidget* parent )
|
QWidget* parent )
|
||||||
: QDialog( parent )
|
: QDialog( parent )
|
||||||
{
|
{
|
||||||
@@ -99,14 +102,12 @@ namespace glabels
|
|||||||
vLayout->setContentsMargins( 0, 0, 0, 0 );
|
vLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
vLayout->setSpacing( 0 );
|
vLayout->setSpacing( 0 );
|
||||||
|
|
||||||
auto* defaultButton = new ColorPaletteButtonItem( defaultLabel );
|
//
|
||||||
connect( defaultButton, SIGNAL(activated()), this, SLOT(onDefaultItemActivated()) );
|
// Construct Standard Colors Grid
|
||||||
vLayout->addWidget( defaultButton );
|
//
|
||||||
|
auto* standardColorsGroup = new QGroupBox( tr("Standard Colors") );
|
||||||
QFrame* hline1 = new QFrame;
|
standardColorsGroup->setAlignment( Qt::AlignHCenter );
|
||||||
hline1->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
vLayout->addWidget( standardColorsGroup );
|
||||||
hline1->setLineWidth( 1 );
|
|
||||||
vLayout->addWidget( hline1 );
|
|
||||||
|
|
||||||
auto* mainPaletteLayout = new QGridLayout();
|
auto* mainPaletteLayout = new QGridLayout();
|
||||||
mainPaletteLayout->setSpacing( 0 );
|
mainPaletteLayout->setSpacing( 0 );
|
||||||
@@ -119,17 +120,20 @@ namespace glabels
|
|||||||
ColorPaletteItem* item = new ColorPaletteItem( i,
|
ColorPaletteItem* item = new ColorPaletteItem( i,
|
||||||
QColor( mColorTable[i].colorSpec ),
|
QColor( mColorTable[i].colorSpec ),
|
||||||
tr(mColorTable[i].trname) );
|
tr(mColorTable[i].trname) );
|
||||||
connect( item, SIGNAL(activated(int)), this, SLOT(onPaletteItemActivated(int)) );
|
connect( item, SIGNAL(activated(int)),
|
||||||
|
this, SLOT(onPaletteItemActivated(int)) );
|
||||||
|
|
||||||
mainPaletteLayout->addWidget( item, iRow, iCol );
|
mainPaletteLayout->addWidget( item, iRow, iCol );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vLayout->addLayout( mainPaletteLayout );
|
standardColorsGroup->setLayout( mainPaletteLayout );
|
||||||
|
|
||||||
QFrame* hline2 = new QFrame;
|
//
|
||||||
hline2->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
// Construct Recent Colors Grid
|
||||||
hline2->setLineWidth( 1 );
|
//
|
||||||
vLayout->addWidget( hline2 );
|
auto* recentColorsGroup = new QGroupBox( tr("Recent Colors") );
|
||||||
|
recentColorsGroup->setAlignment( Qt::AlignHCenter );
|
||||||
|
vLayout->addWidget( recentColorsGroup );
|
||||||
|
|
||||||
auto* customPaletteLayout = new QHBoxLayout();
|
auto* customPaletteLayout = new QHBoxLayout();
|
||||||
customPaletteLayout->setSpacing( 0 );
|
customPaletteLayout->setSpacing( 0 );
|
||||||
@@ -137,39 +141,48 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
|
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
|
||||||
mHistoryItem[iCol]->setEnabled( false );
|
mHistoryItem[iCol]->setEnabled( false );
|
||||||
connect( mHistoryItem[iCol], SIGNAL(activated(int)), this, SLOT(onHistoryItemActivated(int)) );
|
connect( mHistoryItem[iCol], SIGNAL(activated(int)),
|
||||||
|
this, SLOT(onHistoryItemActivated(int)) );
|
||||||
|
|
||||||
customPaletteLayout->addWidget( mHistoryItem[iCol] );
|
customPaletteLayout->addWidget( mHistoryItem[iCol] );
|
||||||
}
|
}
|
||||||
vLayout->addLayout( customPaletteLayout );
|
recentColorsGroup->setLayout( customPaletteLayout );
|
||||||
|
|
||||||
|
|
||||||
QFrame* hline3 = new QFrame;
|
//
|
||||||
hline3->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
// Construct Default (e.g. "No Fill") Button
|
||||||
hline3->setLineWidth( 1 );
|
//
|
||||||
vLayout->addWidget( hline3 );
|
auto* defaultColorButton = new QPushButton( defaultLabel );
|
||||||
|
defaultColorButton->setAutoDefault( false );
|
||||||
|
defaultColorButton->setDefault( false );
|
||||||
|
connect( defaultColorButton, SIGNAL(clicked()), this, SLOT(onDefaultButtonClicked()) );
|
||||||
|
vLayout->addWidget( defaultColorButton );
|
||||||
|
|
||||||
ColorPaletteButtonItem* customColorButton = new ColorPaletteButtonItem( tr("Custom color...") );
|
//
|
||||||
connect( customColorButton, SIGNAL(activated()), this, SLOT(onCustomColorItemActivated()) );
|
// Construct Custom Color Button
|
||||||
|
//
|
||||||
|
auto* customColorButton = new QPushButton( tr("Custom color...") );
|
||||||
|
customColorButton->setAutoDefault( false );
|
||||||
|
customColorButton->setDefault( false );
|
||||||
|
connect( customColorButton, SIGNAL(clicked()), this, SLOT(onCustomColorButtonClicked()) );
|
||||||
vLayout->addWidget( customColorButton );
|
vLayout->addWidget( customColorButton );
|
||||||
|
|
||||||
QFrame* hline4 = new QFrame;
|
//
|
||||||
hline4->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
// Construct "Use field" Button
|
||||||
hline4->setLineWidth( 1 );
|
//
|
||||||
vLayout->addWidget( hline4 );
|
if ( showUseFieldButton )
|
||||||
|
{
|
||||||
mMergeFieldCombo = new QComboBox();
|
mFieldButton = new FieldButton();
|
||||||
mMergeFieldCombo->addItem( tr("Merge key...") );
|
mFieldButton->setText( tr("Use substitution field") );
|
||||||
mMergeFieldCombo->setMinimumSize( 34, 34 );
|
mFieldButton->setAutoDefault( false );
|
||||||
mMergeFieldCombo->setFrame( false );
|
mFieldButton->setDefault( false );
|
||||||
mMergeFieldCombo->setEnabled( false );
|
connect( mFieldButton, SIGNAL(keySelected(QString)), this, SLOT(onKeySelected(QString)) );
|
||||||
connect( mMergeFieldCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboIndexChanged(int)) );
|
vLayout->addWidget( mFieldButton );
|
||||||
vLayout->addWidget( mMergeFieldCombo );
|
}
|
||||||
|
else
|
||||||
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
{
|
||||||
const auto* model = qobject_cast<const QStandardItemModel*>(mMergeFieldCombo->model());
|
mFieldButton = nullptr;
|
||||||
QStandardItem* item = model->item(0);
|
}
|
||||||
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
|
||||||
|
|
||||||
setLayout( vLayout );
|
setLayout( vLayout );
|
||||||
|
|
||||||
@@ -183,41 +196,47 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
void ColorPaletteDialog::setKeys( const merge::Merge* merge,
|
||||||
|
const model::Variables* variables )
|
||||||
{
|
{
|
||||||
mKeys = keyList;
|
if (mFieldButton)
|
||||||
|
|
||||||
// Clear old keys, (all entries, except item 0)
|
|
||||||
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
|
||||||
{
|
{
|
||||||
mMergeFieldCombo->removeItem( index );
|
mFieldButton->setKeys( merge, variables );
|
||||||
}
|
|
||||||
|
|
||||||
// Add new keys
|
|
||||||
if ( keyList.size() > 0 )
|
|
||||||
{
|
|
||||||
mMergeFieldCombo->addItems( keyList );
|
|
||||||
mMergeFieldCombo->setEnabled( true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mMergeFieldCombo->setEnabled( false );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::clearKeys()
|
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
||||||
{
|
{
|
||||||
|
model::ColorNode newColorNode;
|
||||||
|
newColorNode.setField( false );
|
||||||
|
newColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
||||||
|
newColorNode.setKey( "" );
|
||||||
|
|
||||||
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
if ( newColorNode != mColorNode )
|
||||||
{
|
{
|
||||||
mMergeFieldCombo->removeItem( index );
|
mColorNode = newColorNode;
|
||||||
|
|
||||||
|
mColorHistory->addColor( mColorNode.color(), mColorTable[id].trname );
|
||||||
|
|
||||||
|
emit colorChanged( mColorNode, false );
|
||||||
|
accept();
|
||||||
}
|
}
|
||||||
mMergeFieldCombo->setEnabled( false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onDefaultItemActivated()
|
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
||||||
|
{
|
||||||
|
mColorNode.setField( false );
|
||||||
|
mColorNode.setColor( mColorHistory->getColors()[id] );
|
||||||
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
|
emit colorChanged( mColorNode, false );
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::onDefaultButtonClicked()
|
||||||
{
|
{
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
mColorNode.setColor( mDefaultColor );
|
mColorNode.setColor( mDefaultColor );
|
||||||
@@ -228,29 +247,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
void ColorPaletteDialog::onCustomColorButtonClicked()
|
||||||
{
|
|
||||||
mColorNode.setField( false );
|
|
||||||
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
|
||||||
mColorNode.setKey( "" );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
|
||||||
{
|
|
||||||
mColorNode.setField( false );
|
|
||||||
mColorNode.setColor( mColorHistory->getColor(id) );
|
|
||||||
mColorNode.setKey( "" );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onCustomColorItemActivated()
|
|
||||||
{
|
{
|
||||||
QColorDialog dlg( mColorNode.color(), this );
|
QColorDialog dlg( mColorNode.color(), this );
|
||||||
dlg.setWindowTitle( tr("Custom Color") );
|
dlg.setWindowTitle( tr("Custom Color") );
|
||||||
@@ -267,7 +264,10 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mColorNode = newColorNode;
|
mColorNode = newColorNode;
|
||||||
|
|
||||||
mColorHistory->addColor( mColorNode.color() );
|
// TRANSLATORS
|
||||||
|
//: %1 = color specification in hex. String must not contain a colon (:).
|
||||||
|
mColorHistory->addColor( mColorNode.color(),
|
||||||
|
QString(tr("Custom Color %1")).arg(mColorNode.color().name()) );
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
accept();
|
accept();
|
||||||
@@ -284,12 +284,13 @@ namespace glabels
|
|||||||
|
|
||||||
void ColorPaletteDialog::loadCustomColorHistory()
|
void ColorPaletteDialog::loadCustomColorHistory()
|
||||||
{
|
{
|
||||||
|
QStringList nameList = mColorHistory->getNames();
|
||||||
QList<QColor> colorList = mColorHistory->getColors();
|
QList<QColor> colorList = mColorHistory->getColors();
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
foreach ( QColor color, colorList )
|
foreach ( QColor color, colorList )
|
||||||
{
|
{
|
||||||
mHistoryItem[id]->setColor( id, color, QString(tr("Custom color #%1").arg(id+1) ) );
|
mHistoryItem[id]->setColor( id, color, nameList[id] );
|
||||||
mHistoryItem[id]->setEnabled( true );
|
mHistoryItem[id]->setEnabled( true );
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
@@ -302,25 +303,14 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onComboIndexChanged( int index )
|
void ColorPaletteDialog::onKeySelected( QString key )
|
||||||
{
|
{
|
||||||
if ( index != 0 )
|
mColorNode.setField( true );
|
||||||
{
|
mColorNode.setColor( QColor( 0xee, 0xee, 0xec ) );
|
||||||
mColorNode.setField( true );
|
mColorNode.setKey( key );
|
||||||
mColorNode.setColor( QColor( 0xee, 0xee, 0xec ) );
|
|
||||||
mColorNode.setKey( mKeys[index-1] );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
accept();
|
accept();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::showEvent( QShowEvent* event )
|
|
||||||
{
|
|
||||||
mMergeFieldCombo->setCurrentIndex( 0 );
|
|
||||||
|
|
||||||
QDialog::showEvent( event );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -24,11 +24,10 @@
|
|||||||
|
|
||||||
#include "ColorHistory.h"
|
#include "ColorHistory.h"
|
||||||
#include "ColorPaletteItem.h"
|
#include "ColorPaletteItem.h"
|
||||||
#include "ColorPaletteButtonItem.h"
|
#include "FieldButton.h"
|
||||||
|
|
||||||
#include "model/ColorNode.h"
|
#include "model/ColorNode.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
||||||
@@ -50,6 +49,7 @@ namespace glabels
|
|||||||
ColorPaletteDialog( const QString& defaultLabel,
|
ColorPaletteDialog( const QString& defaultLabel,
|
||||||
const QColor& defaultColor,
|
const QColor& defaultColor,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
|
bool showUseFieldButton = true,
|
||||||
QWidget* parent = nullptr );
|
QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
@@ -64,24 +64,22 @@ namespace glabels
|
|||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setColorNode( const model::ColorNode& colorNode );
|
void setColorNode( const model::ColorNode& colorNode );
|
||||||
void setKeys( const QStringList& keyList );
|
|
||||||
void clearKeys();
|
void setKeys( const merge::Merge* merge,
|
||||||
|
const model::Variables* variables );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onDefaultItemActivated();
|
|
||||||
void onPaletteItemActivated( int id );
|
void onPaletteItemActivated( int id );
|
||||||
void onHistoryItemActivated( int id );
|
void onHistoryItemActivated( int id );
|
||||||
void onCustomColorItemActivated();
|
void onDefaultButtonClicked();
|
||||||
|
void onCustomColorButtonClicked();
|
||||||
|
void onKeySelected( QString key );
|
||||||
void onColorHistoryChanged();
|
void onColorHistoryChanged();
|
||||||
void onComboIndexChanged( int index );
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void showEvent( QShowEvent* event ) override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -111,8 +109,7 @@ namespace glabels
|
|||||||
ColorHistory* mColorHistory;
|
ColorHistory* mColorHistory;
|
||||||
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
||||||
|
|
||||||
QComboBox* mMergeFieldCombo;
|
FieldButton* mFieldButton;
|
||||||
QStringList mKeys;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,220 @@
|
|||||||
|
/* EditVariableDialog.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 Jim 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 "EditVariableDialog.h"
|
||||||
|
|
||||||
|
#include "model/Settings.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
// All variable types. (must be in sorted order)
|
||||||
|
const QVector<glabels::model::Variable::Type> allTypes = {
|
||||||
|
glabels::model::Variable::Type::STRING,
|
||||||
|
glabels::model::Variable::Type::INTEGER,
|
||||||
|
glabels::model::Variable::Type::FLOATING_POINT,
|
||||||
|
glabels::model::Variable::Type::COLOR
|
||||||
|
};
|
||||||
|
|
||||||
|
// All variable increments. (must be in sorted order)
|
||||||
|
const QVector<glabels::model::Variable::Increment> allIncrements = {
|
||||||
|
glabels::model::Variable::Increment::NEVER,
|
||||||
|
glabels::model::Variable::Increment::PER_ITEM,
|
||||||
|
glabels::model::Variable::Increment::PER_COPY,
|
||||||
|
glabels::model::Variable::Increment::PER_PAGE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
EditVariableDialog::EditVariableDialog( QWidget *parent )
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
setupUi( this );
|
||||||
|
|
||||||
|
QRegularExpression reIdentifier( "[a-zA-Z_][a-zA-Z_0-9]*" );
|
||||||
|
nameEdit->setValidator( new QRegularExpressionValidator( reIdentifier ) );
|
||||||
|
|
||||||
|
colorValueButton->init( tr("Default"),
|
||||||
|
QColor(0,0,0,255),
|
||||||
|
QColor(0,0,0,255),
|
||||||
|
false );
|
||||||
|
|
||||||
|
for ( auto type : allTypes )
|
||||||
|
{
|
||||||
|
typeCombo->addItem( model::Variable::typeToI18nString( type ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( auto type : allIncrements )
|
||||||
|
{
|
||||||
|
incrementCombo->addItem( model::Variable::incrementToI18nString( type ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
stepSizeEdit->setText( "1" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set variable
|
||||||
|
///
|
||||||
|
void EditVariableDialog::setVariable( const model::Variable& variable )
|
||||||
|
{
|
||||||
|
typeCombo->setCurrentIndex( static_cast<int>(variable.type()) );
|
||||||
|
nameEdit->setText( variable.name() );
|
||||||
|
valueEdit->setText( variable.initialValue() );
|
||||||
|
colorValueButton->setColor( QColor( variable.initialValue() ) );
|
||||||
|
incrementCombo->setCurrentIndex( static_cast<int>(variable.increment()) );
|
||||||
|
stepSizeEdit->setText( variable.stepSize() );
|
||||||
|
|
||||||
|
updateControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get variable
|
||||||
|
///
|
||||||
|
model::Variable EditVariableDialog::variable() const
|
||||||
|
{
|
||||||
|
return model::Variable( static_cast<model::Variable::Type>(typeCombo->currentIndex()),
|
||||||
|
nameEdit->text(),
|
||||||
|
valueEdit->text(),
|
||||||
|
static_cast<model::Variable::Increment>(incrementCombo->currentIndex()),
|
||||||
|
stepSizeEdit->text() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// nameEdit Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onNameEditChanged()
|
||||||
|
{
|
||||||
|
validateCurrentInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// typeCombo Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onTypeComboChanged()
|
||||||
|
{
|
||||||
|
updateControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// valueEdit Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onValueEditChanged()
|
||||||
|
{
|
||||||
|
validateCurrentInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// colorValueButton Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onColorValueButtonChanged()
|
||||||
|
{
|
||||||
|
valueEdit->setText( colorValueButton->colorNode().color().name() );
|
||||||
|
validateCurrentInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// incrementCombo Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onIncrementComboChanged()
|
||||||
|
{
|
||||||
|
updateControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// stepSizeEdit Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onStepSizeEditChanged()
|
||||||
|
{
|
||||||
|
validateCurrentInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// update controls
|
||||||
|
///
|
||||||
|
void EditVariableDialog::updateControls()
|
||||||
|
{
|
||||||
|
auto type = static_cast<model::Variable::Type>(typeCombo->currentIndex());
|
||||||
|
auto increment = static_cast<model::Variable::Increment>(incrementCombo->currentIndex());
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
|
||||||
|
case model::Variable::Type::INTEGER:
|
||||||
|
valueEdit->setValidator( new QIntValidator() );
|
||||||
|
stepSizeEdit->setValidator( new QIntValidator() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case model::Variable::Type::FLOATING_POINT:
|
||||||
|
valueEdit->setValidator( new QDoubleValidator() );
|
||||||
|
stepSizeEdit->setValidator( new QDoubleValidator() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
valueEdit->setValidator( nullptr );
|
||||||
|
stepSizeEdit->setValidator( nullptr );
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
colorValueButton->setVisible( type == model::Variable::Type::COLOR );
|
||||||
|
|
||||||
|
bool isNumeric = ( type == model::Variable::Type::INTEGER ) ||
|
||||||
|
( type == model::Variable::Type::FLOATING_POINT );
|
||||||
|
|
||||||
|
incrementGroup->setVisible( isNumeric );
|
||||||
|
stepSizeLabel->setEnabled( isNumeric && (increment != model::Variable::Increment::NEVER) );
|
||||||
|
stepSizeEdit->setEnabled( isNumeric && (increment != model::Variable::Increment::NEVER) );
|
||||||
|
|
||||||
|
validateCurrentInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// validate current inputs
|
||||||
|
///
|
||||||
|
void EditVariableDialog::validateCurrentInputs()
|
||||||
|
{
|
||||||
|
bool hasValidIdentifier = nameEdit->hasAcceptableInput();
|
||||||
|
bool hasValidValue = valueEdit->hasAcceptableInput();
|
||||||
|
bool hasValidStepSize = stepSizeEdit->hasAcceptableInput();
|
||||||
|
|
||||||
|
bool isValid = hasValidIdentifier && hasValidValue && hasValidStepSize;
|
||||||
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled( isValid );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace glabels
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/* ColorPaletteButtonItem.h
|
/* EditVariableDialog.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2019 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -18,21 +18,21 @@
|
|||||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ColorPaletteButtonItem_h
|
#ifndef EditVariableDialog_h
|
||||||
#define ColorPaletteButtonItem_h
|
#define EditVariableDialog_h
|
||||||
|
|
||||||
|
|
||||||
#include <QColor>
|
#include "ui_EditVariableDialog.h"
|
||||||
#include <QWidget>
|
#include "model/Variable.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Color Palette Item
|
/// New Label Dialog Widget
|
||||||
///
|
///
|
||||||
class ColorPaletteButtonItem : public QWidget
|
class EditVariableDialog : public QDialog, public Ui_EditVariableDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -40,36 +40,37 @@ namespace glabels
|
|||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
ColorPaletteButtonItem( const QString& text, QWidget* parent = nullptr );
|
EditVariableDialog( QWidget *parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Public methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
void setVariable( const model::Variable& variable );
|
||||||
void activated();
|
model::Variable variable() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Event handlers
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
protected:
|
private slots:
|
||||||
void paintEvent( QPaintEvent* event ) override;
|
void onNameEditChanged();
|
||||||
void enterEvent( QEvent* event ) override;
|
void onTypeComboChanged();
|
||||||
void leaveEvent( QEvent* event ) override;
|
void onValueEditChanged();
|
||||||
void mousePressEvent( QMouseEvent* event ) override;
|
void onColorValueButtonChanged();
|
||||||
|
void onIncrementComboChanged();
|
||||||
|
void onStepSizeEditChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
void updateControls();
|
||||||
QString mText;
|
void validateCurrentInputs();
|
||||||
|
|
||||||
bool mHover;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorPaletteButtonItem_h
|
#endif // EditVariableDialog_h
|
||||||
+36
-54
@@ -1,6 +1,6 @@
|
|||||||
/* FieldButton.cpp
|
/* FieldButton.cpp
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2016 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2019 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -30,79 +30,61 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
FieldButton::FieldButton( QWidget* parent )
|
FieldButton::FieldButton( QWidget* parent ) : QPushButton(parent)
|
||||||
: QComboBox(parent)
|
|
||||||
{
|
{
|
||||||
setEnabled( false );
|
setEnabled( false );
|
||||||
|
setMenu( &mMenu );
|
||||||
|
|
||||||
connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)) );
|
connect( &mMenu, SIGNAL(triggered(QAction*)),
|
||||||
|
this, SLOT(onMenuActionTriggered(QAction*)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FieldButton::setName( const QString& name )
|
///
|
||||||
{
|
/// Set Keys
|
||||||
mName = name;
|
///
|
||||||
if ( count() == 0 )
|
void FieldButton::setKeys( const merge::Merge* merge,
|
||||||
{
|
const model::Variables* variables )
|
||||||
addItem( mName );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setItemText( 0, mName );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
|
||||||
const auto* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
|
||||||
QStandardItem* item = itemModel->item(0);
|
|
||||||
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FieldButton::setKeys( const QStringList& keyList )
|
|
||||||
{
|
{
|
||||||
// Clear old keys
|
// Clear old keys
|
||||||
clear();
|
mMenu.clear();
|
||||||
addItem( mName );
|
|
||||||
|
|
||||||
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
// Add merge keys, if any
|
||||||
const auto* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
mMenu.addSection( tr("Merge fields") );
|
||||||
QStandardItem* item = itemModel->item(0);
|
for ( auto& key : merge->keys() )
|
||||||
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
{
|
||||||
|
auto* action = mMenu.addAction( QString( "${%1}" ).arg( key ) );
|
||||||
|
action->setData( key );
|
||||||
|
}
|
||||||
|
if ( merge->keys().empty() )
|
||||||
|
{
|
||||||
|
auto* action = mMenu.addAction( "None" );
|
||||||
|
action->setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
// Add new keys
|
// Add variable keys, if any
|
||||||
if ( keyList.size() > 0 )
|
mMenu.addSection( tr("Variables") );
|
||||||
|
for ( auto& key : variables->keys() )
|
||||||
{
|
{
|
||||||
addItems( keyList );
|
auto* action = mMenu.addAction( QString( "${%1}" ).arg( key ) );
|
||||||
setEnabled( true );
|
action->setData( key );
|
||||||
}
|
}
|
||||||
else
|
if ( variables->keys().empty() )
|
||||||
{
|
{
|
||||||
setEnabled( false );
|
auto* action = mMenu.addAction( "None" );
|
||||||
|
action->setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setEnabled( !merge->keys().empty() || !variables->keys().empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FieldButton::clearKeys()
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
addItem( mName );
|
|
||||||
|
|
||||||
setEnabled( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onMenuKeySelected slot
|
/// onMenuActionTriggered slot
|
||||||
///
|
///
|
||||||
void FieldButton::onIndexChanged( int index )
|
void FieldButton::onMenuActionTriggered( QAction* action )
|
||||||
{
|
{
|
||||||
if ( index > 0 )
|
emit keySelected( action->data().toString() );
|
||||||
{
|
|
||||||
emit keySelected( itemText(index) );
|
|
||||||
|
|
||||||
setCurrentIndex( 0 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
+13
-9
@@ -1,6 +1,6 @@
|
|||||||
/* FieldButton.h
|
/* FieldButton.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2016 Jim Evins <evins@snaught.com>
|
* Copyright (C) 2019 Jim Evins <evins@snaught.com>
|
||||||
*
|
*
|
||||||
* This file is part of gLabels-qt.
|
* This file is part of gLabels-qt.
|
||||||
*
|
*
|
||||||
@@ -22,8 +22,13 @@
|
|||||||
#define FieldButton_h
|
#define FieldButton_h
|
||||||
|
|
||||||
|
|
||||||
#include <QComboBox>
|
#include "model/Variables.h"
|
||||||
#include <QString>
|
#include "merge/Merge.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
@@ -32,7 +37,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Field Button
|
/// Field Button
|
||||||
///
|
///
|
||||||
class FieldButton : public QComboBox
|
class FieldButton : public QPushButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -54,23 +59,22 @@ namespace glabels
|
|||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setName( const QString& name = "" );
|
void setKeys( const merge::Merge* merge,
|
||||||
void setKeys( const QStringList& keyList );
|
const model::Variables* variables );
|
||||||
void clearKeys();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onIndexChanged( int index );
|
void onMenuActionTriggered( QAction* action );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QString mName;
|
QMenu mMenu;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+2
-5
@@ -112,8 +112,6 @@ namespace glabels
|
|||||||
model::Model *model = model::XmlLabelParser::readFile( fileName );
|
model::Model *model = model::XmlLabelParser::readFile( fileName );
|
||||||
if ( model )
|
if ( model )
|
||||||
{
|
{
|
||||||
model->setFileName( fileName );
|
|
||||||
|
|
||||||
// Either apply to current window or open a new one
|
// Either apply to current window or open a new one
|
||||||
if ( window->isEmpty() )
|
if ( window->isEmpty() )
|
||||||
{
|
{
|
||||||
@@ -152,8 +150,6 @@ namespace glabels
|
|||||||
model::Model *model = model::XmlLabelParser::readFile( fileName );
|
model::Model *model = model::XmlLabelParser::readFile( fileName );
|
||||||
if ( model )
|
if ( model )
|
||||||
{
|
{
|
||||||
model->setFileName( fileName );
|
|
||||||
|
|
||||||
// Either apply to current window or open a new one
|
// Either apply to current window or open a new one
|
||||||
if ( window->isEmpty() )
|
if ( window->isEmpty() )
|
||||||
{
|
{
|
||||||
@@ -213,7 +209,8 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
bool File::saveAs( MainWindow *window )
|
bool File::saveAs( MainWindow *window )
|
||||||
{
|
{
|
||||||
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
// Either use the saved CWD from a previous open/save or grab it from the path
|
||||||
|
// of the current file.
|
||||||
QString cwd = mCwd;
|
QString cwd = mCwd;
|
||||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -473,6 +473,16 @@ namespace glabels
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Variables : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Variables()
|
||||||
|
{
|
||||||
|
addPixmap( QPixmap( ":icons/flat/48x48/glabels-variables.svg" ) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class ZoomBestFit : public QIcon
|
class ZoomBestFit : public QIcon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -1162,7 +1162,7 @@ namespace glabels
|
|||||||
void
|
void
|
||||||
LabelEditor::drawObjectsLayer( QPainter* painter )
|
LabelEditor::drawObjectsLayer( QPainter* painter )
|
||||||
{
|
{
|
||||||
mModel->draw( painter );
|
mModel->draw( painter, true, nullptr, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+53
-2
@@ -31,6 +31,7 @@
|
|||||||
#include "PropertiesView.h"
|
#include "PropertiesView.h"
|
||||||
#include "StartupView.h"
|
#include "StartupView.h"
|
||||||
#include "UndoRedoModel.h"
|
#include "UndoRedoModel.h"
|
||||||
|
#include "VariablesView.h"
|
||||||
|
|
||||||
#include "model/Db.h"
|
#include "model/Db.h"
|
||||||
#include "model/Model.h"
|
#include "model/Model.h"
|
||||||
@@ -51,7 +52,8 @@ namespace
|
|||||||
EDITOR_PAGE_INDEX = 1,
|
EDITOR_PAGE_INDEX = 1,
|
||||||
PROPERTIES_PAGE_INDEX = 2,
|
PROPERTIES_PAGE_INDEX = 2,
|
||||||
MERGE_PAGE_INDEX = 3,
|
MERGE_PAGE_INDEX = 3,
|
||||||
PRINT_PAGE_INDEX = 4,
|
VARIABLES_PAGE_INDEX = 4,
|
||||||
|
PRINT_PAGE_INDEX = 5,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +78,7 @@ namespace glabels
|
|||||||
QWidget* editorPage = createEditorPage();
|
QWidget* editorPage = createEditorPage();
|
||||||
QWidget* propertiesPage = createPropertiesPage();
|
QWidget* propertiesPage = createPropertiesPage();
|
||||||
QWidget* mergePage = createMergePage();
|
QWidget* mergePage = createMergePage();
|
||||||
|
QWidget* variablesPage = createVariablesPage();
|
||||||
QWidget* printPage = createPrintPage();
|
QWidget* printPage = createPrintPage();
|
||||||
|
|
||||||
// Table of contents widget
|
// Table of contents widget
|
||||||
@@ -141,6 +144,18 @@ namespace glabels
|
|||||||
mMergeAction = mContents->addWidget( mMergeButton );
|
mMergeAction = mContents->addWidget( mMergeButton );
|
||||||
group->addButton( mMergeButton );
|
group->addButton( mMergeButton );
|
||||||
|
|
||||||
|
// Add "Variables" page
|
||||||
|
mPages->addWidget( variablesPage );
|
||||||
|
mVariablesButton = new QToolButton( this );
|
||||||
|
mVariablesButton->setIcon( Icons::Variables() );
|
||||||
|
mVariablesButton->setText( tr("Variables") );
|
||||||
|
mVariablesButton->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||||
|
mVariablesButton->setCheckable( true );
|
||||||
|
mVariablesButton->setSizePolicy( QSizePolicy::MinimumExpanding,
|
||||||
|
QSizePolicy::Preferred );
|
||||||
|
mVariablesAction = mContents->addWidget( mVariablesButton );
|
||||||
|
group->addButton( mVariablesButton );
|
||||||
|
|
||||||
// Add "Print" page
|
// Add "Print" page
|
||||||
mPages->addWidget( printPage );
|
mPages->addWidget( printPage );
|
||||||
mPrintButton = new QToolButton( this );
|
mPrintButton = new QToolButton( this );
|
||||||
@@ -175,6 +190,7 @@ namespace glabels
|
|||||||
connect( mEditorButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
connect( mEditorButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
||||||
connect( mPropertiesButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
connect( mPropertiesButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
||||||
connect( mMergeButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
connect( mMergeButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
||||||
|
connect( mVariablesButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
||||||
connect( mPrintButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
connect( mPrintButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool)));
|
||||||
connect( mLabelEditor, SIGNAL(zoomChanged()), this, SLOT(onZoomChanged()) );
|
connect( mLabelEditor, SIGNAL(zoomChanged()), this, SLOT(onZoomChanged()) );
|
||||||
connect( model::Settings::instance(), SIGNAL(changed()), this, SLOT(onSettingsChanged()) );
|
connect( model::Settings::instance(), SIGNAL(changed()), this, SLOT(onSettingsChanged()) );
|
||||||
@@ -201,6 +217,7 @@ namespace glabels
|
|||||||
if ( mModel )
|
if ( mModel )
|
||||||
{
|
{
|
||||||
delete mModel->merge(); // Ownership of final Merge instance is ours
|
delete mModel->merge(); // Ownership of final Merge instance is ours
|
||||||
|
delete mModel->variables(); // Ownership of final Variables instance is ours
|
||||||
delete mModel;
|
delete mModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -226,7 +243,8 @@ namespace glabels
|
|||||||
mPropertiesView->setModel( mModel, mUndoRedoModel );
|
mPropertiesView->setModel( mModel, mUndoRedoModel );
|
||||||
mLabelEditor->setModel( mModel, mUndoRedoModel );
|
mLabelEditor->setModel( mModel, mUndoRedoModel );
|
||||||
mObjectEditor->setModel( mModel, mUndoRedoModel );
|
mObjectEditor->setModel( mModel, mUndoRedoModel );
|
||||||
mMergeView->setModel( mModel , mUndoRedoModel );
|
mMergeView->setModel( mModel, mUndoRedoModel );
|
||||||
|
mVariablesView->setModel( mModel, mUndoRedoModel );
|
||||||
mPrintView->setModel( mModel );
|
mPrintView->setModel( mModel );
|
||||||
|
|
||||||
mEditorButton->setChecked( true );
|
mEditorButton->setChecked( true );
|
||||||
@@ -323,6 +341,11 @@ namespace glabels
|
|||||||
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->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_4 ) );
|
||||||
|
fileShowVariablesPageAction->setStatusTip( tr("Select project Variables mode") );
|
||||||
|
connect( fileShowVariablesPageAction, SIGNAL(triggered()), this, SLOT(fileShowVariablesPage()) );
|
||||||
|
|
||||||
fileShowPrintPageAction = new QAction( tr("&Print") , this );
|
fileShowPrintPageAction = new QAction( tr("&Print") , this );
|
||||||
fileShowPrintPageAction->setShortcut( QKeySequence::Print );
|
fileShowPrintPageAction->setShortcut( QKeySequence::Print );
|
||||||
fileShowPrintPageAction->setStatusTip( tr("Select project Print mode") );
|
fileShowPrintPageAction->setStatusTip( tr("Select project Print mode") );
|
||||||
@@ -611,6 +634,7 @@ namespace glabels
|
|||||||
fileMenu->addAction( fileShowEditorPageAction );
|
fileMenu->addAction( fileShowEditorPageAction );
|
||||||
fileMenu->addAction( fileShowPropertiesPageAction );
|
fileMenu->addAction( fileShowPropertiesPageAction );
|
||||||
fileMenu->addAction( fileShowMergePageAction );
|
fileMenu->addAction( fileShowMergePageAction );
|
||||||
|
fileMenu->addAction( fileShowVariablesPageAction );
|
||||||
fileMenu->addAction( fileShowPrintPageAction );
|
fileMenu->addAction( fileShowPrintPageAction );
|
||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
fileMenu->addAction( fileTemplateDesignerAction );
|
fileMenu->addAction( fileTemplateDesignerAction );
|
||||||
@@ -823,6 +847,17 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create Variables Page
|
||||||
|
///
|
||||||
|
QWidget* MainWindow::createVariablesPage()
|
||||||
|
{
|
||||||
|
mVariablesView = new VariablesView();
|
||||||
|
|
||||||
|
return mVariablesView;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create Print Page
|
/// Create Print Page
|
||||||
///
|
///
|
||||||
@@ -847,6 +882,7 @@ namespace glabels
|
|||||||
bool isEditorPage = mEditorButton->isChecked();
|
bool isEditorPage = mEditorButton->isChecked();
|
||||||
bool isPropertiesPage = mPropertiesButton->isChecked();
|
bool isPropertiesPage = mPropertiesButton->isChecked();
|
||||||
bool isMergePage = mMergeButton->isChecked();
|
bool isMergePage = mMergeButton->isChecked();
|
||||||
|
bool isVariablesPage = mVariablesButton->isChecked();
|
||||||
bool isPrintPage = mPrintButton->isChecked();
|
bool isPrintPage = mPrintButton->isChecked();
|
||||||
|
|
||||||
// What is the current selection state?
|
// What is the current selection state?
|
||||||
@@ -859,6 +895,7 @@ namespace glabels
|
|||||||
mEditorAction->setVisible( !isWelcomePage );
|
mEditorAction->setVisible( !isWelcomePage );
|
||||||
mPropertiesAction->setVisible( !isWelcomePage );
|
mPropertiesAction->setVisible( !isWelcomePage );
|
||||||
mMergeAction->setVisible( !isWelcomePage );
|
mMergeAction->setVisible( !isWelcomePage );
|
||||||
|
mVariablesAction->setVisible( !isWelcomePage );
|
||||||
mPrintAction->setVisible( !isWelcomePage );
|
mPrintAction->setVisible( !isWelcomePage );
|
||||||
|
|
||||||
// Recent file actions
|
// Recent file actions
|
||||||
@@ -884,6 +921,7 @@ namespace glabels
|
|||||||
fileShowEditorPageAction->setEnabled( !isWelcomePage && !isEditorPage );
|
fileShowEditorPageAction->setEnabled( !isWelcomePage && !isEditorPage );
|
||||||
fileShowPropertiesPageAction->setEnabled( !isWelcomePage && !isPropertiesPage );
|
fileShowPropertiesPageAction->setEnabled( !isWelcomePage && !isPropertiesPage );
|
||||||
fileShowMergePageAction->setEnabled( !isWelcomePage && !isMergePage );
|
fileShowMergePageAction->setEnabled( !isWelcomePage && !isMergePage );
|
||||||
|
fileShowVariablesPageAction->setEnabled( !isWelcomePage && !isVariablesPage );
|
||||||
fileShowPrintPageAction->setEnabled( !isWelcomePage && !isPrintPage );
|
fileShowPrintPageAction->setEnabled( !isWelcomePage && !isPrintPage );
|
||||||
fileTemplateDesignerAction->setEnabled( true );
|
fileTemplateDesignerAction->setEnabled( true );
|
||||||
fileCloseAction->setEnabled( true );
|
fileCloseAction->setEnabled( true );
|
||||||
@@ -1110,6 +1148,10 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mPages->setCurrentIndex( MERGE_PAGE_INDEX );
|
mPages->setCurrentIndex( MERGE_PAGE_INDEX );
|
||||||
}
|
}
|
||||||
|
else if ( mVariablesButton->isChecked() )
|
||||||
|
{
|
||||||
|
mPages->setCurrentIndex( VARIABLES_PAGE_INDEX );
|
||||||
|
}
|
||||||
else if ( mPrintButton->isChecked() )
|
else if ( mPrintButton->isChecked() )
|
||||||
{
|
{
|
||||||
mPages->setCurrentIndex( PRINT_PAGE_INDEX );
|
mPages->setCurrentIndex( PRINT_PAGE_INDEX );
|
||||||
@@ -1206,6 +1248,15 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// File->Show Variables Page
|
||||||
|
///
|
||||||
|
void MainWindow::fileShowVariablesPage()
|
||||||
|
{
|
||||||
|
mVariablesButton->setChecked( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// File->Show Print Page
|
/// File->Show Print Page
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace glabels
|
|||||||
class PropertiesView;
|
class PropertiesView;
|
||||||
class StartupView;
|
class StartupView;
|
||||||
class UndoRedoModel;
|
class UndoRedoModel;
|
||||||
|
class VariablesView;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -97,6 +98,7 @@ namespace glabels
|
|||||||
void fileShowEditorPage();
|
void fileShowEditorPage();
|
||||||
void fileShowPropertiesPage();
|
void fileShowPropertiesPage();
|
||||||
void fileShowMergePage();
|
void fileShowMergePage();
|
||||||
|
void fileShowVariablesPage();
|
||||||
void fileShowPrintPage();
|
void fileShowPrintPage();
|
||||||
void fileTemplateDesigner();
|
void fileTemplateDesigner();
|
||||||
void fileClose();
|
void fileClose();
|
||||||
@@ -175,6 +177,7 @@ namespace glabels
|
|||||||
QWidget* createEditorPage();
|
QWidget* createEditorPage();
|
||||||
QWidget* createPropertiesPage();
|
QWidget* createPropertiesPage();
|
||||||
QWidget* createMergePage();
|
QWidget* createMergePage();
|
||||||
|
QWidget* createVariablesPage();
|
||||||
QWidget* createPrintPage();
|
QWidget* createPrintPage();
|
||||||
|
|
||||||
void manageActions();
|
void manageActions();
|
||||||
@@ -222,12 +225,14 @@ namespace glabels
|
|||||||
QToolButton* mEditorButton;
|
QToolButton* mEditorButton;
|
||||||
QToolButton* mPropertiesButton;
|
QToolButton* mPropertiesButton;
|
||||||
QToolButton* mMergeButton;
|
QToolButton* mMergeButton;
|
||||||
|
QToolButton* mVariablesButton;
|
||||||
QToolButton* mPrintButton;
|
QToolButton* mPrintButton;
|
||||||
|
|
||||||
QAction* mWelcomeAction;
|
QAction* mWelcomeAction;
|
||||||
QAction* mEditorAction;
|
QAction* mEditorAction;
|
||||||
QAction* mPropertiesAction;
|
QAction* mPropertiesAction;
|
||||||
QAction* mMergeAction;
|
QAction* mMergeAction;
|
||||||
|
QAction* mVariablesAction;
|
||||||
QAction* mPrintAction;
|
QAction* mPrintAction;
|
||||||
|
|
||||||
QStackedWidget* mPages;
|
QStackedWidget* mPages;
|
||||||
@@ -237,6 +242,7 @@ namespace glabels
|
|||||||
ObjectEditor* mObjectEditor;
|
ObjectEditor* mObjectEditor;
|
||||||
PropertiesView* mPropertiesView;
|
PropertiesView* mPropertiesView;
|
||||||
MergeView* mMergeView;
|
MergeView* mMergeView;
|
||||||
|
VariablesView* mVariablesView;
|
||||||
PrintView* mPrintView;
|
PrintView* mPrintView;
|
||||||
|
|
||||||
QLabel* zoomInfoLabel;
|
QLabel* zoomInfoLabel;
|
||||||
@@ -249,6 +255,7 @@ namespace glabels
|
|||||||
QAction* fileShowEditorPageAction;
|
QAction* fileShowEditorPageAction;
|
||||||
QAction* fileShowPropertiesPageAction;
|
QAction* fileShowPropertiesPageAction;
|
||||||
QAction* fileShowMergePageAction;
|
QAction* fileShowMergePageAction;
|
||||||
|
QAction* fileShowVariablesPageAction;
|
||||||
QAction* fileShowPrintPageAction;
|
QAction* fileShowPrintPageAction;
|
||||||
QAction* fileTemplateDesignerAction;
|
QAction* fileTemplateDesignerAction;
|
||||||
QAction* fileCloseAction;
|
QAction* fileCloseAction;
|
||||||
|
|||||||
+11
-21
@@ -63,14 +63,7 @@ namespace glabels
|
|||||||
mUndoRedoModel = undoRedoModel;
|
mUndoRedoModel = undoRedoModel;
|
||||||
|
|
||||||
// Initialize CWD
|
// Initialize CWD
|
||||||
if ( model->fileName().isEmpty() )
|
mCwd = mModel->dirPath();
|
||||||
{
|
|
||||||
mCwd = ".";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mCwd = QFileInfo( model->fileName() ).absolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
onMergeChanged();
|
onMergeChanged();
|
||||||
connect( mModel, SIGNAL(mergeChanged()), this, SLOT(onMergeChanged()) );
|
connect( mModel, SIGNAL(mergeChanged()), this, SLOT(onMergeChanged()) );
|
||||||
@@ -87,26 +80,22 @@ namespace glabels
|
|||||||
mOldFormatComboIndex = index;
|
mOldFormatComboIndex = index;
|
||||||
formatCombo->setCurrentIndex( index );
|
formatCombo->setCurrentIndex( index );
|
||||||
|
|
||||||
|
QString fn;
|
||||||
|
|
||||||
switch ( merge::Factory::idToType( mModel->merge()->id() ) )
|
switch ( merge::Factory::idToType( mModel->merge()->id() ) )
|
||||||
{
|
{
|
||||||
case merge::Factory::NONE:
|
case merge::Factory::NONE:
|
||||||
case merge::Factory::FIXED:
|
case merge::Factory::FIXED:
|
||||||
locationLabel->setEnabled( false );
|
locationLabel->setEnabled( false );
|
||||||
locationButton->setEnabled( false );
|
locationLineEdit->setText( "" );
|
||||||
locationButton->setText( "" );
|
locationBrowseButton->setVisible( false );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case merge::Factory::FILE:
|
case merge::Factory::FILE:
|
||||||
locationLabel->setEnabled( true );
|
locationLabel->setEnabled( true );
|
||||||
locationButton->setEnabled( true );
|
fn = mModel->dir().relativeFilePath( mModel->merge()->source() );
|
||||||
if ( mModel->merge()->source().isEmpty() )
|
locationLineEdit->setText( fn );
|
||||||
{
|
locationBrowseButton->setVisible( true );
|
||||||
locationButton->setText( "Select file..." );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
locationButton->setText( mModel->merge()->source() );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -135,7 +124,8 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void MergeView::onMergeSourceChanged()
|
void MergeView::onMergeSourceChanged()
|
||||||
{
|
{
|
||||||
locationButton->setText( mModel->merge()->source() );
|
QString fn = mModel->dir().relativeFilePath( mModel->merge()->source() );
|
||||||
|
locationLineEdit->setText( fn );
|
||||||
|
|
||||||
recordsTable->clear();
|
recordsTable->clear();
|
||||||
recordsTable->setColumnCount( 0 );
|
recordsTable->setColumnCount( 0 );
|
||||||
@@ -185,7 +175,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Location button clicked handler
|
/// Location button clicked handler
|
||||||
///
|
///
|
||||||
void MergeView::onLocationButtonClicked()
|
void MergeView::onLocationBrowseButtonClicked()
|
||||||
{
|
{
|
||||||
QString fileName =
|
QString fileName =
|
||||||
QFileDialog::getOpenFileName( this,
|
QFileDialog::getOpenFileName( this,
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ namespace glabels
|
|||||||
void onMergeSelectionChanged();
|
void onMergeSelectionChanged();
|
||||||
|
|
||||||
void onFormatComboActivated();
|
void onFormatComboActivated();
|
||||||
void onLocationButtonClicked();
|
void onLocationBrowseButtonClicked();
|
||||||
void onSelectAllButtonClicked();
|
void onSelectAllButtonClicked();
|
||||||
void onUnselectAllButtonClicked();
|
void onUnselectAllButtonClicked();
|
||||||
void onCellChanged( int iRow, int iCol );
|
void onCellChanged( int iRow, int iCol );
|
||||||
|
|||||||
+27
-18
@@ -36,6 +36,7 @@
|
|||||||
#include "merge/Merge.h"
|
#include "merge/Merge.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QDir>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
@@ -67,9 +68,9 @@ namespace glabels
|
|||||||
barcodeColorButton->init( tr("Default"), QColor(0,0,0,255), QColor(0,0,0,255) );
|
barcodeColorButton->init( tr("Default"), QColor(0,0,0,255), QColor(0,0,0,255) );
|
||||||
shadowColorButton->init( tr("Default"), QColor(0,0,0,255), QColor(0,0,0,255) );
|
shadowColorButton->init( tr("Default"), QColor(0,0,0,255), QColor(0,0,0,255) );
|
||||||
|
|
||||||
textInsertFieldCombo->setName( tr("Insert Field") );
|
textInsertFieldButton->setText( tr("Insert substitution field") );
|
||||||
barcodeInsertFieldCombo->setName( tr("Insert Field") );
|
barcodeInsertFieldButton->setText( tr("Insert substitution field") );
|
||||||
imageFieldCombo->setName( tr("Key") );
|
imageFieldButton->setText( tr("Use substitution field") );
|
||||||
|
|
||||||
setEnabled( false );
|
setEnabled( false );
|
||||||
hidePages();
|
hidePages();
|
||||||
@@ -93,11 +94,14 @@ namespace glabels
|
|||||||
this, SLOT(onSelectionChanged()) );
|
this, SLOT(onSelectionChanged()) );
|
||||||
|
|
||||||
connect( mModel, SIGNAL(mergeSourceChanged()),
|
connect( mModel, SIGNAL(mergeSourceChanged()),
|
||||||
this, SLOT(onMergeSourceChanged()) );
|
this, SLOT(onFieldsAvailableChanged()) );
|
||||||
|
|
||||||
|
connect( mModel, SIGNAL(variablesChanged()),
|
||||||
|
this, SLOT(onFieldsAvailableChanged()) );
|
||||||
|
|
||||||
onLabelSizeChanged();
|
onLabelSizeChanged();
|
||||||
onSelectionChanged();
|
onSelectionChanged();
|
||||||
onMergeSourceChanged();
|
onFieldsAvailableChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,12 +126,12 @@ namespace glabels
|
|||||||
|
|
||||||
if ( filenameNode.isField() )
|
if ( filenameNode.isField() )
|
||||||
{
|
{
|
||||||
QString field = QString("${%1}").arg( filenameNode.data() );
|
imageFilenameLineEdit->setText( QString("${%1}").arg(filenameNode.data()) );
|
||||||
imageFilenameLineEdit->setText( field );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
imageFilenameLineEdit->setText( filenameNode.data() );
|
QString fn = mModel->dir().relativeFilePath( filenameNode.data() );
|
||||||
|
imageFilenameLineEdit->setText( fn );
|
||||||
}
|
}
|
||||||
|
|
||||||
mBlocked = false;
|
mBlocked = false;
|
||||||
@@ -499,17 +503,19 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ObjectEditor::onMergeSourceChanged()
|
void ObjectEditor::onFieldsAvailableChanged()
|
||||||
{
|
{
|
||||||
if ( !mBlocked )
|
if ( !mBlocked )
|
||||||
{
|
{
|
||||||
QStringList keys = mModel->merge()->keys();
|
lineColorButton->setKeys( mModel->merge(), mModel->variables() );
|
||||||
lineColorButton->setKeys( keys );
|
fillColorButton->setKeys( mModel->merge(), mModel->variables() );
|
||||||
fillColorButton->setKeys( keys );
|
textColorButton->setKeys( mModel->merge(), mModel->variables() );
|
||||||
textInsertFieldCombo->setKeys( keys );
|
barcodeColorButton->setKeys( mModel->merge(), mModel->variables() );
|
||||||
barcodeInsertFieldCombo->setKeys( keys );
|
shadowColorButton->setKeys( mModel->merge(), mModel->variables() );
|
||||||
imageFieldCombo->setKeys( keys );
|
|
||||||
shadowColorButton->setKeys( keys );
|
textInsertFieldButton->setKeys( mModel->merge(), mModel->variables() );
|
||||||
|
barcodeInsertFieldButton->setKeys( mModel->merge(), mModel->variables() );
|
||||||
|
imageFieldButton->setKeys( mModel->merge(), mModel->variables() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,8 +626,11 @@ namespace glabels
|
|||||||
|
|
||||||
void ObjectEditor::onImageKeySelected( QString key )
|
void ObjectEditor::onImageKeySelected( QString key )
|
||||||
{
|
{
|
||||||
mUndoRedoModel->checkpoint( tr("Set image") );
|
if ( mObject )
|
||||||
mObject->setFilenameNode( model::TextNode( true, key ) );
|
{
|
||||||
|
mUndoRedoModel->checkpoint( tr("Set image") );
|
||||||
|
mObject->setFilenameNode( model::TextNode( true, key ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace glabels
|
|||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
void onLabelSizeChanged();
|
void onLabelSizeChanged();
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
void onMergeSourceChanged();
|
void onFieldsAvailableChanged();
|
||||||
void onObjectChanged();
|
void onObjectChanged();
|
||||||
void onObjectMoved();
|
void onObjectMoved();
|
||||||
void onObjectDestroyed();
|
void onObjectDestroyed();
|
||||||
|
|||||||
@@ -0,0 +1,254 @@
|
|||||||
|
/* VariablesView.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Jim 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 "VariablesView.h"
|
||||||
|
|
||||||
|
#include "EditVariableDialog.h"
|
||||||
|
|
||||||
|
#include <QTableWidgetItem>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
enum ICol {
|
||||||
|
I_COL_NAME,
|
||||||
|
I_COL_TYPE,
|
||||||
|
I_COL_VALUE,
|
||||||
|
I_COL_INCREMENT,
|
||||||
|
I_COL_STEP_SIZE,
|
||||||
|
I_COL_DUMMY,
|
||||||
|
N_COLS
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
VariablesView::VariablesView( QWidget *parent )
|
||||||
|
: QWidget(parent), mModel(nullptr), mUndoRedoModel(nullptr)
|
||||||
|
{
|
||||||
|
setupUi( this );
|
||||||
|
|
||||||
|
titleLabel->setText( QString( "<span style='font-size:18pt;'>%1</span>" ).arg( tr("Variables") ) );
|
||||||
|
|
||||||
|
table->setColumnCount( N_COLS );
|
||||||
|
|
||||||
|
auto* nameHeaderItem = new QTableWidgetItem( tr("Name") );
|
||||||
|
nameHeaderItem->setFlags( nameHeaderItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setHorizontalHeaderItem( I_COL_NAME, nameHeaderItem );
|
||||||
|
|
||||||
|
auto* typeHeaderItem = new QTableWidgetItem( tr("Type") );
|
||||||
|
typeHeaderItem->setFlags( typeHeaderItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setHorizontalHeaderItem( I_COL_TYPE, typeHeaderItem );
|
||||||
|
|
||||||
|
auto* valueHeaderItem = new QTableWidgetItem( tr("Value") );
|
||||||
|
valueHeaderItem->setFlags( valueHeaderItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setHorizontalHeaderItem( I_COL_VALUE, valueHeaderItem );
|
||||||
|
|
||||||
|
auto* incrementHeaderItem = new QTableWidgetItem( tr("Increment") );
|
||||||
|
incrementHeaderItem->setFlags( incrementHeaderItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setHorizontalHeaderItem( I_COL_INCREMENT, incrementHeaderItem );
|
||||||
|
|
||||||
|
auto* stepSizeHeaderItem = new QTableWidgetItem( tr("Step Size") );
|
||||||
|
stepSizeHeaderItem->setFlags( stepSizeHeaderItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setHorizontalHeaderItem( I_COL_STEP_SIZE, stepSizeHeaderItem );
|
||||||
|
|
||||||
|
auto* dummyHeaderItem = new QTableWidgetItem();
|
||||||
|
dummyHeaderItem->setFlags( Qt::NoItemFlags );
|
||||||
|
table->setHorizontalHeaderItem( I_COL_DUMMY, dummyHeaderItem );
|
||||||
|
table->horizontalHeader()->setStretchLastSection( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
VariablesView::~VariablesView()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set Model
|
||||||
|
///
|
||||||
|
void VariablesView::setModel( model::Model* model, UndoRedoModel* undoRedoModel )
|
||||||
|
{
|
||||||
|
mModel = model;
|
||||||
|
mUndoRedoModel = undoRedoModel;
|
||||||
|
|
||||||
|
updateControls();
|
||||||
|
loadTable();
|
||||||
|
|
||||||
|
connect( mModel, SIGNAL(variablesChanged()), this, SLOT(onVariablesChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// table Selection Changed
|
||||||
|
///
|
||||||
|
void VariablesView::onTableSelectionChanged()
|
||||||
|
{
|
||||||
|
updateControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// addButton Clicked
|
||||||
|
///
|
||||||
|
void VariablesView::onAddButtonClicked()
|
||||||
|
{
|
||||||
|
EditVariableDialog dialog( this );
|
||||||
|
|
||||||
|
model::Variable v( model::Variable::Type::INTEGER,
|
||||||
|
"x",
|
||||||
|
"0",
|
||||||
|
model::Variable::Increment::NEVER,
|
||||||
|
"1" );
|
||||||
|
dialog.setVariable( v );
|
||||||
|
dialog.setWindowTitle( tr("Add Variable") );
|
||||||
|
|
||||||
|
if ( dialog.exec() == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
mModel->variables()->addVariable( dialog.variable() );
|
||||||
|
selectVariable( dialog.variable().name() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// editButton Clicked
|
||||||
|
///
|
||||||
|
void VariablesView::onEditButtonClicked()
|
||||||
|
{
|
||||||
|
int iRow = table->selectedItems()[0]->row();
|
||||||
|
QString name = table->item( iRow, I_COL_NAME )->text();
|
||||||
|
|
||||||
|
if ( mModel->variables()->hasVariable( name ) )
|
||||||
|
{
|
||||||
|
model::Variable v = mModel->variables()->value( name );
|
||||||
|
|
||||||
|
EditVariableDialog dialog( this );
|
||||||
|
dialog.setVariable( v );
|
||||||
|
dialog.setWindowTitle( tr("Edit Variable") );
|
||||||
|
|
||||||
|
if ( dialog.exec() == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
mModel->variables()->replaceVariable( name, dialog.variable() );
|
||||||
|
selectVariable( dialog.variable().name() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// deleteButton Clicked
|
||||||
|
///
|
||||||
|
void VariablesView::onDeleteButtonClicked()
|
||||||
|
{
|
||||||
|
int iRow = table->selectedItems()[0]->row();
|
||||||
|
|
||||||
|
QString name = table->item( iRow, I_COL_NAME )->text();
|
||||||
|
mModel->variables()->deleteVariable( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Variables Changed
|
||||||
|
///
|
||||||
|
void VariablesView::onVariablesChanged()
|
||||||
|
{
|
||||||
|
// Reload table from variables
|
||||||
|
loadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// update controls
|
||||||
|
///
|
||||||
|
void VariablesView::updateControls()
|
||||||
|
{
|
||||||
|
bool hasSelection = !table->selectedItems().isEmpty();
|
||||||
|
|
||||||
|
editButton->setEnabled( hasSelection );
|
||||||
|
deleteButton->setEnabled( hasSelection );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// load table from variables
|
||||||
|
///
|
||||||
|
void VariablesView::loadTable()
|
||||||
|
{
|
||||||
|
table->clearContents();
|
||||||
|
table->setRowCount( mModel->variables()->size() );
|
||||||
|
|
||||||
|
int iRow = 0;
|
||||||
|
for( const auto& v : *mModel->variables() )
|
||||||
|
{
|
||||||
|
auto* typeItem = new QTableWidgetItem( model::Variable::typeToI18nString(v.type()) );
|
||||||
|
typeItem->setFlags( typeItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_TYPE, typeItem );
|
||||||
|
|
||||||
|
auto* nameItem = new QTableWidgetItem( v.name() );
|
||||||
|
nameItem->setFlags( nameItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_NAME, nameItem );
|
||||||
|
|
||||||
|
auto* valueItem = new QTableWidgetItem( v.initialValue() );
|
||||||
|
valueItem->setFlags( valueItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_VALUE, valueItem );
|
||||||
|
|
||||||
|
auto* incrementItem = new QTableWidgetItem( model::Variable::incrementToI18nString(v.increment()) );
|
||||||
|
incrementItem->setFlags( incrementItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_INCREMENT, incrementItem );
|
||||||
|
|
||||||
|
auto* stepSizeItem = new QTableWidgetItem( v.stepSize() );
|
||||||
|
stepSizeItem->setFlags( stepSizeItem->flags() ^ Qt::ItemIsEditable );
|
||||||
|
table->setItem( iRow, I_COL_STEP_SIZE, stepSizeItem );
|
||||||
|
|
||||||
|
table->showRow( iRow );
|
||||||
|
iRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void VariablesView::selectVariable( const QString& name )
|
||||||
|
{
|
||||||
|
int iRow = 0;
|
||||||
|
for( const auto& v : *mModel->variables() )
|
||||||
|
{
|
||||||
|
if ( v.name() == name )
|
||||||
|
{
|
||||||
|
table->setCurrentCell( iRow, 0,
|
||||||
|
(QItemSelectionModel::Select|QItemSelectionModel::Rows) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
iRow++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace glabels
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/* VariablesView.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Jim 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 VariablesView_h
|
||||||
|
#define VariablesView_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "ui_VariablesView.h"
|
||||||
|
|
||||||
|
#include "model/Model.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward references
|
||||||
|
class UndoRedoModel;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Variables Property Editor Widget
|
||||||
|
///
|
||||||
|
class VariablesView : public QWidget, public Ui_VariablesView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
VariablesView( QWidget *parent = nullptr );
|
||||||
|
~VariablesView() override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Public methods
|
||||||
|
/////////////////////////////////
|
||||||
|
void setModel( model::Model* model, UndoRedoModel* undoRedoModel );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onTableSelectionChanged();
|
||||||
|
void onAddButtonClicked();
|
||||||
|
void onEditButtonClicked();
|
||||||
|
void onDeleteButtonClicked();
|
||||||
|
void onVariablesChanged();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private methods
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
void updateControls();
|
||||||
|
void loadTable();
|
||||||
|
void selectVariable( const QString& name );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
model::Model* mModel;
|
||||||
|
UndoRedoModel* mUndoRedoModel;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // VariablesView_h
|
||||||
@@ -102,6 +102,7 @@
|
|||||||
<file>icons/flat/48x48/glabels-merge.svg</file>
|
<file>icons/flat/48x48/glabels-merge.svg</file>
|
||||||
<file>icons/flat/48x48/glabels-print.svg</file>
|
<file>icons/flat/48x48/glabels-print.svg</file>
|
||||||
<file>icons/flat/48x48/glabels-properties.svg</file>
|
<file>icons/flat/48x48/glabels-properties.svg</file>
|
||||||
|
<file>icons/flat/48x48/glabels-variables.svg</file>
|
||||||
<file>icons/apps/48x48/glabels.svg</file>
|
<file>icons/apps/48x48/glabels.svg</file>
|
||||||
|
|
||||||
<file>icons/apps/128x128/glabels.svg</file>
|
<file>icons/apps/128x128/glabels.svg</file>
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="48" height="48" >
|
||||||
|
|
||||||
|
<g transform="translate(0,-282.3)" >
|
||||||
|
<g style="fill:#333333;fill-opacity:1;stroke:none" transform="scale(0.87836138,1.1384836)" >
|
||||||
|
<path
|
||||||
|
d="M 7.9978635,276.23327 Q 6.4616456,276.08696 5.5106536,275.74558 4.584046,275.4042 4.1207422,275.13597 l 0.9266076,-2.38967 q 0.7803012,0.36576 1.8288308,0.68276 1.0485297,0.29261 2.2189814,0.29261 1.365527,0 1.901984,-0.34138 0.536457,-0.36576 0.536457,-1.12168 0,-0.43892 -0.21946,-0.75592 -0.195075,-0.31699 -0.60961,-0.56084 -0.39015,-0.26823 -0.9753763,-0.4633 -0.5852259,-0.21946 -1.3167582,-0.48769 -0.7071479,-0.24384 -1.3899114,-0.56084 -0.6827635,-0.317 -1.2192206,-0.75592 -0.536457,-0.4633 -0.8778387,-1.0973 -0.3169974,-0.65838 -0.3169974,-1.60937 0,-0.68276 0.1706909,-1.31676 0.1950753,-0.63399 0.5852259,-1.17045 0.4145349,-0.53646 1.072914,-0.92661 0.6583791,-0.41453 1.6093711,-0.63399 v -2.36529 h 2.7798227 v 2.24337 q 1.121683,0.0975 1.975137,0.34138 0.877839,0.24384 1.365527,0.43892 l -0.682763,2.51159 q -0.707148,-0.29261 -1.682524,-0.51207 -0.950992,-0.24384 -1.9751377,-0.24384 -1.1704517,0 -1.6337555,0.41453 -0.4389194,0.41454 -0.4389194,0.97538 0,0.39015 0.1463065,0.65838 0.1706909,0.24384 0.4876882,0.43892 0.3413818,0.19507 0.8046856,0.39015 0.4633038,0.17069 1.0972983,0.39015 0.950992,0.36576 1.755678,0.7803 0.804685,0.39015 1.389911,0.92661 0.585226,0.51207 0.902223,1.21922 0.341382,0.70714 0.341382,1.65814 0,0.65838 -0.195075,1.31675 -0.195075,0.634 -0.658379,1.19484 -0.43892,0.53646 -1.194836,0.95099 -0.731533,0.39015 -1.853216,0.56084 v 2.60914 H 7.9978635 Z" />
|
||||||
|
<path
|
||||||
|
d="m 20.043762,269.96647 q 1.316759,0.24385 1.8776,1.07292 0.585226,0.82907 0.585226,2.38967 v 2.75544 q 0,1.02415 0.292613,1.48745 0.292613,0.4633 1.072914,0.4633 h 2.26775 v 2.34091 h -2.535979 q -2.194597,0 -3.048051,-0.951 -0.82907,-0.95099 -0.82907,-2.75543 v -3.58451 q 0,-1.02415 -0.316997,-1.53622 -0.316998,-0.53646 -1.072914,-0.53646 h -1.316758 v -2.3409 h 1.316758 q 0.755916,0 1.072914,-0.51207 0.316997,-0.53646 0.316997,-1.53622 v -3.60889 q 0,-1.80445 0.82907,-2.75544 0.853454,-0.95099 3.048051,-0.95099 h 2.535979 v 2.3409 h -2.26775 q -0.780301,0 -1.072914,0.4633 -0.292613,0.43892 -0.292613,1.48745 v 2.75544 q 0,1.5606 -0.585226,2.38967 -0.560841,0.82907 -1.8776,1.12168 z" />
|
||||||
|
<path
|
||||||
|
d="m 33.869723,268.57656 2.340904,-3.5845 h 3.048051 l -3.70643,5.51087 q 0.585226,0.70715 1.146067,1.51184 0.560842,0.7803 1.072914,1.58498 0.512073,0.80469 0.926608,1.53622 0.414535,0.73153 0.707148,1.31676 H 36.28378 q -0.658379,-1.24361 -1.316758,-2.21898 -0.658379,-0.97538 -1.243605,-1.75568 -0.731532,0.97538 -1.316758,1.90198 -0.585226,0.92661 -1.194836,2.07268 h -3.048052 q 0.365766,-0.68277 0.82907,-1.4143 0.487688,-0.75591 0.999761,-1.51183 0.536457,-0.7803 1.097299,-1.53622 0.585225,-0.75592 1.121683,-1.43868 l -4.023428,-5.55964 h 3.145589 z" />
|
||||||
|
<path
|
||||||
|
d="m 47.500607,269.91771 q -1.316758,-0.24385 -1.901984,-1.07292 -0.585226,-0.82907 -0.585226,-2.38967 v -2.75544 q 0,-1.02414 -0.292613,-1.48745 -0.292613,-0.4633 -1.072914,-0.4633 h -2.243366 v -2.3409 h 2.511595 q 1.097298,0 1.828831,0.24384 0.755916,0.24384 1.194836,0.70715 0.463304,0.4633 0.658379,1.17045 0.195075,0.68276 0.195075,1.58499 v 3.5845 q 0,1.02415 0.316997,1.56061 0.316998,0.51207 1.072915,0.51207 h 1.341142 v 2.3409 h -1.341142 q -0.755917,0 -1.072915,0.53646 -0.316997,0.51207 -0.316997,1.51183 v 3.6089 q 0,0.90222 -0.195075,1.58498 -0.195075,0.70715 -0.658379,1.17045 -0.43892,0.46331 -1.194836,0.70715 -0.731533,0.24385 -1.828831,0.24385 h -2.511595 v -2.34091 h 2.243366 q 0.780301,0 1.072914,-0.4633 0.292613,-0.43892 0.292613,-1.48745 v -2.75544 q 0,-1.5606 0.585226,-2.38967 0.585226,-0.82907 1.901984,-1.12168 z" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,274 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>EditVariableDialog</class>
|
||||||
|
<widget class="QDialog" name="EditVariableDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>469</width>
|
||||||
|
<height>297</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QGroupBox" name="incrementGroup">
|
||||||
|
<property name="title">
|
||||||
|
<string>Increment</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="incrementCombo"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="stepSizeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Step size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="stepSizeEdit"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Variable</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="nameEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Value:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="typeCombo"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Type:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="valueEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="glabels::ColorButton" name="colorValueButton">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>glabels::ColorButton</class>
|
||||||
|
<extends>QPushButton</extends>
|
||||||
|
<header>ColorButton.h</header>
|
||||||
|
<slots>
|
||||||
|
<signal>colorChanged()</signal>
|
||||||
|
</slots>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>EditVariableDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>236</x>
|
||||||
|
<y>287</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>236</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>EditVariableDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>304</x>
|
||||||
|
<y>287</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>236</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>typeCombo</sender>
|
||||||
|
<signal>currentIndexChanged(int)</signal>
|
||||||
|
<receiver>EditVariableDialog</receiver>
|
||||||
|
<slot>onTypeComboChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>252</x>
|
||||||
|
<y>70</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>33</x>
|
||||||
|
<y>161</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>incrementCombo</sender>
|
||||||
|
<signal>currentIndexChanged(int)</signal>
|
||||||
|
<receiver>EditVariableDialog</receiver>
|
||||||
|
<slot>onIncrementComboChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>100</x>
|
||||||
|
<y>223</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>97</x>
|
||||||
|
<y>176</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>stepSizeEdit</sender>
|
||||||
|
<signal>textChanged(QString)</signal>
|
||||||
|
<receiver>EditVariableDialog</receiver>
|
||||||
|
<slot>onStepSizeEditChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>440</x>
|
||||||
|
<y>223</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>333</x>
|
||||||
|
<y>166</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>nameEdit</sender>
|
||||||
|
<signal>textChanged(QString)</signal>
|
||||||
|
<receiver>EditVariableDialog</receiver>
|
||||||
|
<slot>onNameEditChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>440</x>
|
||||||
|
<y>103</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>393</x>
|
||||||
|
<y>165</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>valueEdit</sender>
|
||||||
|
<signal>textChanged(QString)</signal>
|
||||||
|
<receiver>EditVariableDialog</receiver>
|
||||||
|
<slot>onValueEditChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>318</x>
|
||||||
|
<y>129</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>459</x>
|
||||||
|
<y>157</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>colorValueButton</sender>
|
||||||
|
<signal>colorChanged()</signal>
|
||||||
|
<receiver>EditVariableDialog</receiver>
|
||||||
|
<slot>onColorValueButtonChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>406</x>
|
||||||
|
<y>114</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>458</x>
|
||||||
|
<y>122</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<slots>
|
||||||
|
<slot>onTypeComboChanged()</slot>
|
||||||
|
<slot>onValueEditChanged()</slot>
|
||||||
|
<slot>onIncrementComboChanged()</slot>
|
||||||
|
<slot>onStepSizeEditChanged()</slot>
|
||||||
|
<slot>onNameEditChanged()</slot>
|
||||||
|
<slot>onColorValueButtonChanged()</slot>
|
||||||
|
</slots>
|
||||||
|
</ui>
|
||||||
+60
-49
@@ -11,12 +11,21 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>12</number>
|
<number>12</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@@ -37,16 +46,9 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Source</string>
|
<string>Source</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1">
|
||||||
<item row="0" column="0">
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QPushButton" name="locationButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Location</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -54,6 +56,27 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="formatCombo"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="locationLineEdit">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="locationBrowseButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="locationLabel">
|
<widget class="QLabel" name="locationLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -61,24 +84,8 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QComboBox" name="formatCombo"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>360</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -89,7 +96,11 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTableWidget" name="recordsTable"/>
|
<widget class="QTableWidget" name="recordsTable">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
@@ -138,8 +149,8 @@
|
|||||||
<slot>onSelectAllButtonClicked()</slot>
|
<slot>onSelectAllButtonClicked()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>63</x>
|
<x>97</x>
|
||||||
<y>571</y>
|
<y>570</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>69</x>
|
<x>69</x>
|
||||||
@@ -163,22 +174,6 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
|
||||||
<sender>locationButton</sender>
|
|
||||||
<signal>clicked()</signal>
|
|
||||||
<receiver>MergeView</receiver>
|
|
||||||
<slot>onLocationButtonClicked()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>174</x>
|
|
||||||
<y>93</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>570</x>
|
|
||||||
<y>75</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
<connection>
|
||||||
<sender>formatCombo</sender>
|
<sender>formatCombo</sender>
|
||||||
<signal>activated(int)</signal>
|
<signal>activated(int)</signal>
|
||||||
@@ -186,8 +181,8 @@
|
|||||||
<slot>onFormatComboActivated()</slot>
|
<slot>onFormatComboActivated()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>162</x>
|
<x>257</x>
|
||||||
<y>48</y>
|
<y>109</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>563</x>
|
<x>563</x>
|
||||||
@@ -195,11 +190,27 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>locationBrowseButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>MergeView</receiver>
|
||||||
|
<slot>onLocationBrowseButtonClicked()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>296</x>
|
||||||
|
<y>130</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>565</x>
|
||||||
|
<y>149</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>onSelectAllButtonClicked()</slot>
|
<slot>onSelectAllButtonClicked()</slot>
|
||||||
<slot>onUnselectAllButtonClicked()</slot>
|
<slot>onUnselectAllButtonClicked()</slot>
|
||||||
<slot>onLocationButtonClicked()</slot>
|
|
||||||
<slot>onFormatComboActivated()</slot>
|
<slot>onFormatComboActivated()</slot>
|
||||||
|
<slot>onLocationBrowseButtonClicked()</slot>
|
||||||
</slots>
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
+171
-170
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>640</height>
|
<height>648</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -29,9 +29,9 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
@@ -579,7 +579,11 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="glabels::FieldButton" name="textInsertFieldCombo"/>
|
<widget class="glabels::FieldButton" name="textInsertFieldButton">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Insert field</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
@@ -729,7 +733,11 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="glabels::FieldButton" name="barcodeInsertFieldCombo"/>
|
<widget class="glabels::FieldButton" name="barcodeInsertFieldButton">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Insert field</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_12">
|
<spacer name="horizontalSpacer_12">
|
||||||
@@ -758,14 +766,27 @@
|
|||||||
<string>Image</string>
|
<string>Image</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_13">
|
<layout class="QGridLayout" name="gridLayout_13">
|
||||||
<item row="0" column="0">
|
<item row="2" column="0">
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>646</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox_9">
|
<widget class="QGroupBox" name="groupBox_9">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_12">
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QHBoxLayout" name="horizontalLayout_17">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="imageFilenameLineEdit">
|
<widget class="QLineEdit" name="imageFilenameLineEdit">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -789,68 +810,47 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_17" stretch="1,0,1">
|
<widget class="QPushButton" name="imageBrowseButton">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QPushButton" name="imageFileButton">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<property name="sizePolicy">
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
<property name="text">
|
||||||
</property>
|
<string>Browse...</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Select File...</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<layout class="QHBoxLayout" name="horizontalLayout_27">
|
||||||
<property name="sizePolicy">
|
<item>
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<spacer name="horizontalSpacer_13">
|
||||||
<horstretch>0</horstretch>
|
<property name="orientation">
|
||||||
<verstretch>0</verstretch>
|
<enum>Qt::Horizontal</enum>
|
||||||
</sizepolicy>
|
</property>
|
||||||
</property>
|
<property name="sizeHint" stdset="0">
|
||||||
<property name="text">
|
<size>
|
||||||
<string>or</string>
|
<width>40</width>
|
||||||
</property>
|
<height>20</height>
|
||||||
</widget>
|
</size>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
</spacer>
|
||||||
<widget class="glabels::FieldButton" name="imageFieldCombo">
|
</item>
|
||||||
<property name="sizePolicy">
|
<item>
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<widget class="glabels::FieldButton" name="imageFieldButton">
|
||||||
<horstretch>0</horstretch>
|
<property name="text">
|
||||||
<verstretch>0</verstretch>
|
<string notr="true">Use field</string>
|
||||||
</sizepolicy>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Select Merge Field...</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
|
||||||
<spacer name="verticalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>646</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="lineFillPage">
|
<widget class="QWidget" name="lineFillPage">
|
||||||
@@ -1520,14 +1520,6 @@
|
|||||||
<signal>colorChanged()</signal>
|
<signal>colorChanged()</signal>
|
||||||
</slots>
|
</slots>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>glabels::FieldButton</class>
|
|
||||||
<extends>QComboBox</extends>
|
|
||||||
<header>FieldButton.h</header>
|
|
||||||
<slots>
|
|
||||||
<signal>keySelected(QString)</signal>
|
|
||||||
</slots>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>glabels::BarcodeMenuButton</class>
|
<class>glabels::BarcodeMenuButton</class>
|
||||||
<extends>QPushButton</extends>
|
<extends>QPushButton</extends>
|
||||||
@@ -1536,6 +1528,14 @@
|
|||||||
<signal>selectionChanged()</signal>
|
<signal>selectionChanged()</signal>
|
||||||
</slots>
|
</slots>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>glabels::FieldButton</class>
|
||||||
|
<extends>QPushButton</extends>
|
||||||
|
<header>FieldButton.h</header>
|
||||||
|
<slots>
|
||||||
|
<signal>keySelected(QString)</signal>
|
||||||
|
</slots>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
@@ -1644,8 +1644,8 @@
|
|||||||
<slot>onTextControlsChanged()</slot>
|
<slot>onTextControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>157</x>
|
<x>160</x>
|
||||||
<y>333</y>
|
<y>332</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>396</x>
|
<x>396</x>
|
||||||
@@ -1660,8 +1660,8 @@
|
|||||||
<slot>onTextControlsChanged()</slot>
|
<slot>onTextControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>198</x>
|
<x>200</x>
|
||||||
<y>333</y>
|
<y>332</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>398</x>
|
<x>398</x>
|
||||||
@@ -1676,8 +1676,8 @@
|
|||||||
<slot>onTextControlsChanged()</slot>
|
<slot>onTextControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>238</x>
|
<x>240</x>
|
||||||
<y>333</y>
|
<y>332</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>395</x>
|
<x>395</x>
|
||||||
@@ -1692,8 +1692,8 @@
|
|||||||
<slot>onTextControlsChanged()</slot>
|
<slot>onTextControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>284</x>
|
<x>286</x>
|
||||||
<y>333</y>
|
<y>332</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>393</x>
|
<x>393</x>
|
||||||
@@ -1708,8 +1708,8 @@
|
|||||||
<slot>onTextControlsChanged()</slot>
|
<slot>onTextControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>325</x>
|
<x>326</x>
|
||||||
<y>333</y>
|
<y>332</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>396</x>
|
<x>396</x>
|
||||||
@@ -1725,7 +1725,7 @@
|
|||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>365</x>
|
<x>365</x>
|
||||||
<y>333</y>
|
<y>332</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>397</x>
|
<x>397</x>
|
||||||
@@ -1740,8 +1740,8 @@
|
|||||||
<slot>onTextControlsChanged()</slot>
|
<slot>onTextControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>184</x>
|
<x>189</x>
|
||||||
<y>407</y>
|
<y>404</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>394</x>
|
<x>394</x>
|
||||||
@@ -1757,7 +1757,7 @@
|
|||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>178</x>
|
<x>178</x>
|
||||||
<y>143</y>
|
<y>139</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>392</x>
|
<x>392</x>
|
||||||
@@ -1772,8 +1772,8 @@
|
|||||||
<slot>onLineControlsChanged()</slot>
|
<slot>onLineControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>137</x>
|
<x>136</x>
|
||||||
<y>179</y>
|
<y>174</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>1</x>
|
<x>1</x>
|
||||||
@@ -1788,8 +1788,8 @@
|
|||||||
<slot>onFillControlsChanged()</slot>
|
<slot>onFillControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>136</x>
|
<x>135</x>
|
||||||
<y>263</y>
|
<y>256</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>6</x>
|
<x>6</x>
|
||||||
@@ -1804,8 +1804,8 @@
|
|||||||
<slot>onPositionControlsChanged()</slot>
|
<slot>onPositionControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>159</x>
|
<x>160</x>
|
||||||
<y>142</y>
|
<y>138</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>399</x>
|
<x>399</x>
|
||||||
@@ -1820,8 +1820,8 @@
|
|||||||
<slot>onPositionControlsChanged()</slot>
|
<slot>onPositionControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>159</x>
|
<x>160</x>
|
||||||
<y>179</y>
|
<y>174</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>325</x>
|
<x>325</x>
|
||||||
@@ -1836,8 +1836,8 @@
|
|||||||
<slot>onRectSizeControlsChanged()</slot>
|
<slot>onRectSizeControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>159</x>
|
<x>160</x>
|
||||||
<y>265</y>
|
<y>258</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>3</x>
|
<x>3</x>
|
||||||
@@ -1852,8 +1852,8 @@
|
|||||||
<slot>onRectSizeControlsChanged()</slot>
|
<slot>onRectSizeControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>159</x>
|
<x>160</x>
|
||||||
<y>302</y>
|
<y>294</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@@ -1868,8 +1868,8 @@
|
|||||||
<slot>onResetImageSize()</slot>
|
<slot>onResetImageSize()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>210</x>
|
<x>213</x>
|
||||||
<y>372</y>
|
<y>362</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>4</x>
|
<x>4</x>
|
||||||
@@ -1900,8 +1900,8 @@
|
|||||||
<slot>onShadowControlsChanged()</slot>
|
<slot>onShadowControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>165</x>
|
<x>166</x>
|
||||||
<y>142</y>
|
<y>138</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>398</x>
|
<x>398</x>
|
||||||
@@ -1916,8 +1916,8 @@
|
|||||||
<slot>onShadowControlsChanged()</slot>
|
<slot>onShadowControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>165</x>
|
<x>166</x>
|
||||||
<y>179</y>
|
<y>174</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>294</x>
|
<x>294</x>
|
||||||
@@ -1932,8 +1932,8 @@
|
|||||||
<slot>onShadowControlsChanged()</slot>
|
<slot>onShadowControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>142</x>
|
<x>141</x>
|
||||||
<y>215</y>
|
<y>209</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>399</x>
|
<x>399</x>
|
||||||
@@ -1948,8 +1948,8 @@
|
|||||||
<slot>onShadowControlsChanged()</slot>
|
<slot>onShadowControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>159</x>
|
<x>162</x>
|
||||||
<y>252</y>
|
<y>245</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>399</x>
|
<x>399</x>
|
||||||
@@ -1964,8 +1964,8 @@
|
|||||||
<slot>onLineSizeControlsChanged()</slot>
|
<slot>onLineSizeControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>174</x>
|
<x>177</x>
|
||||||
<y>456</y>
|
<y>444</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>5</x>
|
<x>5</x>
|
||||||
@@ -1980,8 +1980,8 @@
|
|||||||
<slot>onLineSizeControlsChanged()</slot>
|
<slot>onLineSizeControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>174</x>
|
<x>177</x>
|
||||||
<y>493</y>
|
<y>480</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>1</x>
|
<x>1</x>
|
||||||
@@ -1990,14 +1990,14 @@
|
|||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>imageFileButton</sender>
|
<sender>imageBrowseButton</sender>
|
||||||
<signal>clicked()</signal>
|
<signal>clicked()</signal>
|
||||||
<receiver>ObjectEditor</receiver>
|
<receiver>ObjectEditor</receiver>
|
||||||
<slot>onImageFileButtonClicked()</slot>
|
<slot>onImageFileButtonClicked()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>133</x>
|
<x>367</x>
|
||||||
<y>175</y>
|
<y>135</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>394</x>
|
<x>394</x>
|
||||||
@@ -2005,22 +2005,6 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
|
||||||
<sender>imageFieldCombo</sender>
|
|
||||||
<signal>keySelected(QString)</signal>
|
|
||||||
<receiver>ObjectEditor</receiver>
|
|
||||||
<slot>onImageKeySelected(QString)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>302</x>
|
|
||||||
<y>175</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>397</x>
|
|
||||||
<y>32</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
<connection>
|
||||||
<sender>textEdit</sender>
|
<sender>textEdit</sender>
|
||||||
<signal>textChanged()</signal>
|
<signal>textChanged()</signal>
|
||||||
@@ -2037,22 +2021,6 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
|
||||||
<sender>textInsertFieldCombo</sender>
|
|
||||||
<signal>keySelected(QString)</signal>
|
|
||||||
<receiver>ObjectEditor</receiver>
|
|
||||||
<slot>onTextInsertFieldKeySelected(QString)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>239</x>
|
|
||||||
<y>599</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>395</x>
|
|
||||||
<y>645</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
<connection>
|
||||||
<sender>barcodeShowTextCheck</sender>
|
<sender>barcodeShowTextCheck</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
@@ -2060,8 +2028,8 @@
|
|||||||
<slot>onBarcodeControlsChanged()</slot>
|
<slot>onBarcodeControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>178</x>
|
<x>195</x>
|
||||||
<y>172</y>
|
<y>167</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>4</x>
|
<x>4</x>
|
||||||
@@ -2076,8 +2044,8 @@
|
|||||||
<slot>onBarcodeControlsChanged()</slot>
|
<slot>onBarcodeControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>164</x>
|
<x>195</x>
|
||||||
<y>204</y>
|
<y>198</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>1</x>
|
<x>1</x>
|
||||||
@@ -2093,7 +2061,7 @@
|
|||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>126</x>
|
<x>126</x>
|
||||||
<y>239</y>
|
<y>232</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>1</x>
|
<x>1</x>
|
||||||
@@ -2117,22 +2085,6 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
|
||||||
<sender>barcodeInsertFieldCombo</sender>
|
|
||||||
<signal>keySelected(QString)</signal>
|
|
||||||
<receiver>ObjectEditor</receiver>
|
|
||||||
<slot>onBarcodeInsertFieldKeySelected(QString)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>239</x>
|
|
||||||
<y>400</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>403</x>
|
|
||||||
<y>625</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
<connection>
|
||||||
<sender>barcodeStyleButton</sender>
|
<sender>barcodeStyleButton</sender>
|
||||||
<signal>selectionChanged()</signal>
|
<signal>selectionChanged()</signal>
|
||||||
@@ -2140,8 +2092,8 @@
|
|||||||
<slot>onBarcodeControlsChanged()</slot>
|
<slot>onBarcodeControlsChanged()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>178</x>
|
<x>195</x>
|
||||||
<y>140</y>
|
<y>136</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>5</x>
|
<x>5</x>
|
||||||
@@ -2197,6 +2149,54 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>textInsertFieldButton</sender>
|
||||||
|
<signal>keySelected(QString)</signal>
|
||||||
|
<receiver>ObjectEditor</receiver>
|
||||||
|
<slot>onTextInsertFieldKeySelected(QString)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>191</x>
|
||||||
|
<y>589</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>227</x>
|
||||||
|
<y>642</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>barcodeInsertFieldButton</sender>
|
||||||
|
<signal>keySelected(QString)</signal>
|
||||||
|
<receiver>ObjectEditor</receiver>
|
||||||
|
<slot>onBarcodeInsertFieldKeySelected(QString)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>208</x>
|
||||||
|
<y>379</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>205</x>
|
||||||
|
<y>649</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>imageFieldButton</sender>
|
||||||
|
<signal>keySelected(QString)</signal>
|
||||||
|
<receiver>ObjectEditor</receiver>
|
||||||
|
<slot>onImageKeySelected(QString)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>317</x>
|
||||||
|
<y>160</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>331</x>
|
||||||
|
<y>-12</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>onChanged()</slot>
|
<slot>onChanged()</slot>
|
||||||
@@ -2213,5 +2213,6 @@
|
|||||||
<slot>onTextInsertFieldKeySelected(QString)</slot>
|
<slot>onTextInsertFieldKeySelected(QString)</slot>
|
||||||
<slot>onBarcodeControlsChanged()</slot>
|
<slot>onBarcodeControlsChanged()</slot>
|
||||||
<slot>onBarcodeInsertFieldKeySelected(QString)</slot>
|
<slot>onBarcodeInsertFieldKeySelected(QString)</slot>
|
||||||
|
<slot>onImageComboChanged()</slot>
|
||||||
</slots>
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,1">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,1">
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_5" columnstretch="0,0,0,0,1">
|
<layout class="QGridLayout" name="gridLayout_5" columnstretch="0,0,0,0,1">
|
||||||
<item row="0" column="4">
|
<item row="0" column="4">
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -0,0 +1,190 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>VariablesView</class>
|
||||||
|
<widget class="QWidget" name="VariablesView">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1105</width>
|
||||||
|
<height>605</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string notr="true">Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>21</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>21</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>21</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>21</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="titleLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"><html><head/><body><p><span style=" font-size:18pt;">Variables</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QTableWidget" name="table">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderHighlightSections">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Add variable</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Add</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="editButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Edit selected variable</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="deleteButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Delete selected variable</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Delete</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>addButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>VariablesView</receiver>
|
||||||
|
<slot>onAddButtonClicked()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>63</x>
|
||||||
|
<y>586</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>98</x>
|
||||||
|
<y>598</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>editButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>VariablesView</receiver>
|
||||||
|
<slot>onEditButtonClicked()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>167</x>
|
||||||
|
<y>576</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>317</x>
|
||||||
|
<y>608</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>deleteButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>VariablesView</receiver>
|
||||||
|
<slot>onDeleteButtonClicked()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>245</x>
|
||||||
|
<y>575</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>508</x>
|
||||||
|
<y>613</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>table</sender>
|
||||||
|
<signal>itemSelectionChanged()</signal>
|
||||||
|
<receiver>VariablesView</receiver>
|
||||||
|
<slot>onTableSelectionChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>380</x>
|
||||||
|
<y>258</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>787</x>
|
||||||
|
<y>610</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<slots>
|
||||||
|
<slot>onSelectAllButtonClicked()</slot>
|
||||||
|
<slot>onUnselectAllButtonClicked()</slot>
|
||||||
|
<slot>onLocationButtonClicked()</slot>
|
||||||
|
<slot>onFormatComboActivated()</slot>
|
||||||
|
<slot>onAddButtonClicked()</slot>
|
||||||
|
<slot>onEditButtonClicked()</slot>
|
||||||
|
<slot>onDeleteButtonClicked()</slot>
|
||||||
|
<slot>onTableSelectionChanged()</slot>
|
||||||
|
</slots>
|
||||||
|
</ui>
|
||||||
@@ -56,6 +56,8 @@ set (Model_sources
|
|||||||
Template.cpp
|
Template.cpp
|
||||||
TextNode.cpp
|
TextNode.cpp
|
||||||
Units.cpp
|
Units.cpp
|
||||||
|
Variable.cpp
|
||||||
|
Variables.cpp
|
||||||
Vendor.cpp
|
Vendor.cpp
|
||||||
XmlCategoryParser.cpp
|
XmlCategoryParser.cpp
|
||||||
XmlLabelCreator.cpp
|
XmlLabelCreator.cpp
|
||||||
@@ -80,6 +82,7 @@ set (Model_qobject_headers
|
|||||||
ModelTextObject.h
|
ModelTextObject.h
|
||||||
PageRenderer.h
|
PageRenderer.h
|
||||||
Settings.h
|
Settings.h
|
||||||
|
Variables.h
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_cpp (Model_moc_sources ${Model_qobject_headers})
|
qt5_wrap_cpp (Model_moc_sources ${Model_qobject_headers})
|
||||||
|
|||||||
+21
-19
@@ -175,30 +175,32 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Get color, expand if necessary
|
/// Get color, expand if necessary
|
||||||
///
|
///
|
||||||
QColor ColorNode::color( merge::Record* record ) const
|
QColor ColorNode::color( const merge::Record* record,
|
||||||
|
const Variables* variables ) const
|
||||||
{
|
{
|
||||||
if ( mIsField )
|
QColor value = QColor( 192, 192, 192, 128 );
|
||||||
|
|
||||||
|
bool haveRecordField = mIsField && record &&
|
||||||
|
record->contains(mKey) &&
|
||||||
|
!record->value(mKey).isEmpty();
|
||||||
|
bool haveVariable = mIsField && variables &&
|
||||||
|
variables->contains(mKey) &&
|
||||||
|
!(*variables)[mKey].value().isEmpty();
|
||||||
|
|
||||||
|
if ( haveRecordField )
|
||||||
{
|
{
|
||||||
if ( record == nullptr )
|
value = QColor( record->value(mKey) );
|
||||||
{
|
|
||||||
return mColor;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( record->contains( mKey ) )
|
|
||||||
{
|
|
||||||
return QColor( (*record)[ mKey ] );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return mColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if ( haveVariable )
|
||||||
{
|
{
|
||||||
return mColor;
|
value = QColor( (*variables)[mKey].value() );
|
||||||
}
|
}
|
||||||
|
else if ( !mIsField )
|
||||||
|
{
|
||||||
|
value = mColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -22,6 +22,7 @@
|
|||||||
#define model_ColorNode_h
|
#define model_ColorNode_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "Variables.h"
|
||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -95,7 +96,8 @@ namespace glabels
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
uint32_t rgba() const;
|
uint32_t rgba() const;
|
||||||
QColor color( merge::Record* record ) const;
|
QColor color( const merge::Record* record,
|
||||||
|
const Variables* variables ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
+64
-7
@@ -57,13 +57,17 @@ namespace glabels
|
|||||||
Model::Model()
|
Model::Model()
|
||||||
: mUntitledInstance(0), mModified(true), mRotate(false)
|
: mUntitledInstance(0), mModified(true), mRotate(false)
|
||||||
{
|
{
|
||||||
|
mVariables = new Variables();
|
||||||
mMerge = new merge::None();
|
mMerge = new merge::None();
|
||||||
|
|
||||||
|
connect( mVariables, SIGNAL(changed()), this, SLOT(onVariablesChanged()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Model::Model( merge::Merge* merge )
|
Model::Model( merge::Merge* merge, Variables* variables )
|
||||||
: mUntitledInstance(0), mModified(true), mRotate(false)
|
: mUntitledInstance(0), mModified(true), mRotate(false)
|
||||||
{
|
{
|
||||||
|
mVariables = variables; // Shared
|
||||||
mMerge = merge; // Shared
|
mMerge = merge; // Shared
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +77,8 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
Model::~Model()
|
Model::~Model()
|
||||||
{
|
{
|
||||||
// Final instance of mMerge to be deleted by Model owner
|
qDeleteAll( mObjectList );
|
||||||
|
// Final instance of mMerge and mVariables to be deleted by Model owner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,7 +87,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
Model* Model::save() const
|
Model* Model::save() const
|
||||||
{
|
{
|
||||||
auto* savedModel = new Model( mMerge ); // mMerge shared between models
|
auto* savedModel = new Model( mMerge, mVariables ); // mMerge and mVariables shared between models
|
||||||
|
|
||||||
if ( mFileName.isEmpty() && mUntitledInstance == 0 )
|
if ( mFileName.isEmpty() && mUntitledInstance == 0 )
|
||||||
{
|
{
|
||||||
@@ -283,6 +288,38 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get directory as a QDir.
|
||||||
|
///
|
||||||
|
QDir Model::dir() const
|
||||||
|
{
|
||||||
|
if ( mFileName.isEmpty() )
|
||||||
|
{
|
||||||
|
return QDir::current();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QFileInfo( mFileName ).absoluteDir();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get directory as a path.
|
||||||
|
///
|
||||||
|
QString Model::dirPath() const
|
||||||
|
{
|
||||||
|
if ( mFileName.isEmpty() )
|
||||||
|
{
|
||||||
|
return QDir::currentPath();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QFileInfo( mFileName ).absolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get short name.
|
/// Get short name.
|
||||||
///
|
///
|
||||||
@@ -309,6 +346,15 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get variables object
|
||||||
|
///
|
||||||
|
Variables* Model::variables() const
|
||||||
|
{
|
||||||
|
return mVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get merge object
|
/// Get merge object
|
||||||
///
|
///
|
||||||
@@ -458,6 +504,17 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Variables Changed Slot
|
||||||
|
///
|
||||||
|
void Model::onVariablesChanged()
|
||||||
|
{
|
||||||
|
setModified();
|
||||||
|
emit changed();
|
||||||
|
emit variablesChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Merge Source Changed Slot
|
/// Merge Source Changed Slot
|
||||||
///
|
///
|
||||||
@@ -1366,7 +1423,7 @@ namespace glabels
|
|||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
XmlLabelCreator::serializeObjects( getSelection(), buffer );
|
XmlLabelCreator::serializeObjects( getSelection(), this, buffer );
|
||||||
|
|
||||||
auto *mimeData = new QMimeData;
|
auto *mimeData = new QMimeData;
|
||||||
mimeData->setData( MIME_TYPE, buffer );
|
mimeData->setData( MIME_TYPE, buffer );
|
||||||
@@ -1422,7 +1479,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
// Native objects
|
// Native objects
|
||||||
QByteArray buffer = mimeData->data( MIME_TYPE );
|
QByteArray buffer = mimeData->data( MIME_TYPE );
|
||||||
QList <ModelObject*> objects = XmlLabelParser::deserializeObjects( buffer );
|
QList <ModelObject*> objects = XmlLabelParser::deserializeObjects( buffer, this );
|
||||||
|
|
||||||
unselectAll();
|
unselectAll();
|
||||||
foreach ( ModelObject* object, objects )
|
foreach ( ModelObject* object, objects )
|
||||||
@@ -1459,11 +1516,11 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw label objects
|
/// Draw label objects
|
||||||
///
|
///
|
||||||
void Model::draw( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void Model::draw( QPainter* painter, bool inEditor, merge::Record* record, Variables* variables ) const
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
foreach ( ModelObject* object, mObjectList )
|
||||||
{
|
{
|
||||||
object->draw( painter, inEditor, record );
|
object->draw( painter, inEditor, record, variables );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-2
@@ -24,10 +24,12 @@
|
|||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Template.h"
|
#include "Template.h"
|
||||||
|
#include "Variables.h"
|
||||||
|
|
||||||
#include "merge/Merge.h"
|
#include "merge/Merge.h"
|
||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@@ -57,7 +59,7 @@ namespace glabels
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
Model();
|
Model();
|
||||||
Model( merge::Merge* merge );
|
Model( merge::Merge* merge, Variables* variables );
|
||||||
~Model();
|
~Model();
|
||||||
|
|
||||||
|
|
||||||
@@ -77,6 +79,7 @@ namespace glabels
|
|||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
void modifiedChanged();
|
void modifiedChanged();
|
||||||
|
void variablesChanged();
|
||||||
void mergeChanged();
|
void mergeChanged();
|
||||||
void mergeSourceChanged();
|
void mergeSourceChanged();
|
||||||
void mergeSelectionChanged();
|
void mergeSelectionChanged();
|
||||||
@@ -90,6 +93,8 @@ namespace glabels
|
|||||||
void setModified();
|
void setModified();
|
||||||
void clearModified();
|
void clearModified();
|
||||||
|
|
||||||
|
QDir dir() const;
|
||||||
|
QString dirPath() const;
|
||||||
QString shortName();
|
QString shortName();
|
||||||
const QString& fileName() const;
|
const QString& fileName() const;
|
||||||
void setFileName( const QString &fileName );
|
void setFileName( const QString &fileName );
|
||||||
@@ -108,6 +113,8 @@ namespace glabels
|
|||||||
|
|
||||||
const QList<ModelObject*>& objectList() const;
|
const QList<ModelObject*>& objectList() const;
|
||||||
|
|
||||||
|
Variables* variables() const;
|
||||||
|
|
||||||
merge::Merge* merge() const;
|
merge::Merge* merge() const;
|
||||||
void setMerge( merge::Merge* merge );
|
void setMerge( merge::Merge* merge );
|
||||||
|
|
||||||
@@ -205,7 +212,10 @@ namespace glabels
|
|||||||
// Drawing operations
|
// Drawing operations
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, bool inEditor = true, merge::Record* record = nullptr ) const;
|
void draw( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -214,6 +224,7 @@ namespace glabels
|
|||||||
private slots:
|
private slots:
|
||||||
void onObjectChanged();
|
void onObjectChanged();
|
||||||
void onObjectMoved();
|
void onObjectMoved();
|
||||||
|
void onVariablesChanged();
|
||||||
void onMergeSourceChanged();
|
void onMergeSourceChanged();
|
||||||
void onMergeSelectionChanged();
|
void onMergeSelectionChanged();
|
||||||
|
|
||||||
@@ -230,6 +241,7 @@ namespace glabels
|
|||||||
|
|
||||||
QList<ModelObject*> mObjectList;
|
QList<ModelObject*> mObjectList;
|
||||||
|
|
||||||
|
Variables* mVariables;
|
||||||
merge::Merge* mMerge;
|
merge::Merge* mMerge;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -312,7 +312,8 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void ModelBarcodeObject::drawShadow( QPainter* painter,
|
void ModelBarcodeObject::drawShadow( QPainter* painter,
|
||||||
bool inEditor,
|
bool inEditor,
|
||||||
merge::Record* record ) const
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
// Barcodes don't support shadows.
|
// Barcodes don't support shadows.
|
||||||
}
|
}
|
||||||
@@ -323,9 +324,10 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void ModelBarcodeObject::drawObject( QPainter* painter,
|
void ModelBarcodeObject::drawObject( QPainter* painter,
|
||||||
bool inEditor,
|
bool inEditor,
|
||||||
merge::Record* record ) const
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor bcColor = mBcColorNode.color( record );
|
QColor bcColor = mBcColorNode.color( record, variables );
|
||||||
|
|
||||||
if ( inEditor )
|
if ( inEditor )
|
||||||
{
|
{
|
||||||
@@ -333,7 +335,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawBc( painter, bcColor, record );
|
drawBc( painter, bcColor, record, variables );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +453,8 @@ namespace glabels
|
|||||||
void
|
void
|
||||||
ModelBarcodeObject::drawBc( QPainter* painter,
|
ModelBarcodeObject::drawBc( QPainter* painter,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
merge::Record* record ) const
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
painter->setPen( QPen( color ) );
|
painter->setPen( QPen( color ) );
|
||||||
|
|
||||||
@@ -459,7 +462,7 @@ namespace glabels
|
|||||||
bc->setChecksum(mBcChecksumFlag);
|
bc->setChecksum(mBcChecksumFlag);
|
||||||
bc->setShowText(mBcTextFlag);
|
bc->setShowText(mBcTextFlag);
|
||||||
|
|
||||||
bc->build( mBcData.expand( record ).toStdString(), mW.pt(), mH.pt() );
|
bc->build( mBcData.expand( record, variables ).toStdString(), mW.pt(), mH.pt() );
|
||||||
|
|
||||||
glbarcode::QtRenderer renderer(painter);
|
glbarcode::QtRenderer renderer(painter);
|
||||||
bc->render( renderer );
|
bc->render( renderer );
|
||||||
|
|||||||
@@ -127,8 +127,16 @@ namespace glabels
|
|||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter,
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
|
void drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
|
|
||||||
@@ -140,7 +148,12 @@ namespace glabels
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
void drawBcInEditor( QPainter* painter, const QColor& color ) const;
|
void drawBcInEditor( QPainter* painter, const QColor& color ) const;
|
||||||
void drawBc( QPainter* painter, const QColor& color, merge::Record* record ) const;
|
|
||||||
|
void drawBc( QPainter* painter,
|
||||||
|
const QColor& color,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const;
|
||||||
|
|
||||||
void drawPlaceHolder( QPainter* painter, const QColor& color, const QString& text ) const;
|
void drawPlaceHolder( QPainter* painter, const QColor& color, const QString& text ) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -104,11 +104,14 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void ModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelBoxObject::drawShadow( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record, variables );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record, variables );
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
QColor shadowColor = mShadowColorNode.color( record, variables );
|
||||||
|
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
@@ -149,10 +152,13 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void ModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelBoxObject::drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record, variables );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record, variables );
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
painter->setBrush( fillColor );
|
painter->setBrush( fillColor );
|
||||||
|
|||||||
+10
-2
@@ -73,8 +73,16 @@ namespace glabels
|
|||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter,
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
|
void drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -104,11 +104,14 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void ModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelEllipseObject::drawShadow( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record, variables );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record, variables );
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
QColor shadowColor = mShadowColorNode.color( record, variables );
|
||||||
|
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
@@ -149,10 +152,13 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void ModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelEllipseObject::drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record, variables );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record, variables );
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
painter->setBrush( fillColor );
|
painter->setBrush( fillColor );
|
||||||
|
|||||||
@@ -73,8 +73,16 @@ namespace glabels
|
|||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter,
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
|
void drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+109
-8
@@ -20,9 +20,11 @@
|
|||||||
|
|
||||||
#include "ModelImageObject.h"
|
#include "ModelImageObject.h"
|
||||||
|
|
||||||
|
#include "Model.h"
|
||||||
#include "Size.h"
|
#include "Size.h"
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
@@ -40,6 +42,17 @@ namespace glabels
|
|||||||
QImage* ModelImageObject::smDefaultImage = nullptr;
|
QImage* ModelImageObject::smDefaultImage = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const QColor fillColor = QColor( 224, 224, 224, 255 );
|
||||||
|
const QColor labelColor = QColor( 102, 102, 102, 255 );
|
||||||
|
const Distance pad = Distance::pt(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
@@ -398,28 +411,51 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void ModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelImageObject::drawShadow( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
QColor shadowColor = mShadowColorNode.color( record, variables );
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
if ( mImage && mImage->hasAlphaChannel() && (mImage->depth() == 32) )
|
if ( mImage && mImage->hasAlphaChannel() && (mImage->depth() == 32) )
|
||||||
{
|
{
|
||||||
QImage* shadowImage = createShadowImage( shadowColor );
|
QImage* shadowImage = createShadowImage( *mImage, shadowColor );
|
||||||
painter->drawImage( destRect, *shadowImage );
|
painter->drawImage( destRect, *shadowImage );
|
||||||
delete shadowImage;
|
delete shadowImage;
|
||||||
}
|
}
|
||||||
|
else if ( mImage || inEditor )
|
||||||
|
{
|
||||||
|
painter->setBrush( shadowColor );
|
||||||
|
painter->setPen( QPen( Qt::NoPen ) );
|
||||||
|
|
||||||
|
painter->drawRect( destRect );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( mImage || inEditor )
|
// Look for image file relative to project file 1st then CWD 2nd
|
||||||
|
auto* model = dynamic_cast<Model*>( parent() );
|
||||||
|
QDir::setSearchPaths( "images", {model->dirPath(), QDir::currentPath()} );
|
||||||
|
QString filename = QString("images:") + mFilenameNode.text( record, variables );
|
||||||
|
|
||||||
|
auto* image = new QImage( filename );
|
||||||
|
if ( !image->isNull() && image->hasAlphaChannel() && (image->depth() == 32) )
|
||||||
|
{
|
||||||
|
QImage* shadowImage = createShadowImage( *image, shadowColor );
|
||||||
|
painter->drawImage( destRect, *shadowImage );
|
||||||
|
delete shadowImage;
|
||||||
|
}
|
||||||
|
else if ( !image->isNull() )
|
||||||
{
|
{
|
||||||
painter->setBrush( shadowColor );
|
painter->setBrush( shadowColor );
|
||||||
painter->setPen( QPen( Qt::NoPen ) );
|
painter->setPen( QPen( Qt::NoPen ) );
|
||||||
|
|
||||||
painter->drawRect( destRect );
|
painter->drawRect( destRect );
|
||||||
}
|
}
|
||||||
|
delete image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,16 +463,70 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void ModelImageObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelImageObject::drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|
||||||
if ( inEditor && (mFilenameNode.isField() || (!mImage && !mSvgRenderer) ) )
|
if ( inEditor && (mFilenameNode.isField() || (!mImage && !mSvgRenderer) ) )
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Render default place holder image
|
||||||
|
//
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setRenderHint( QPainter::SmoothPixmapTransform, false );
|
painter->setRenderHint( QPainter::SmoothPixmapTransform, false );
|
||||||
painter->drawImage( destRect, *smDefaultImage );
|
painter->drawImage( destRect, *smDefaultImage );
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Print label on top of place holder image, if we have room
|
||||||
|
//
|
||||||
|
if ( (mW > 6*pad) && (mH > 4*pad) )
|
||||||
|
{
|
||||||
|
QString labelText = tr("No image");
|
||||||
|
if ( mFilenameNode.isField() )
|
||||||
|
{
|
||||||
|
labelText = QString( "${%1}" ).arg( mFilenameNode.data() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine font size for labelText
|
||||||
|
QFont font( "Sans" );
|
||||||
|
font.setPointSizeF( 6 );
|
||||||
|
|
||||||
|
QFontMetricsF fm( font );
|
||||||
|
QRectF textRect = fm.boundingRect( labelText );
|
||||||
|
|
||||||
|
double wPts = (mW - 2*pad).pt();
|
||||||
|
double hPts = (mH - 2*pad).pt();
|
||||||
|
if ( (wPts < textRect.width()) || (hPts < textRect.height()) )
|
||||||
|
{
|
||||||
|
double scaleX = wPts / textRect.width();
|
||||||
|
double scaleY = hPts / textRect.height();
|
||||||
|
font.setPointSizeF( 6 * std::min( scaleX, scaleY ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render hole for text (font size may have changed above)
|
||||||
|
fm = QFontMetricsF( font );
|
||||||
|
textRect = fm.boundingRect( labelText );
|
||||||
|
|
||||||
|
QRectF holeRect( (mW.pt() - textRect.width())/2 - pad.pt(),
|
||||||
|
(mH.pt() - textRect.height())/2 - pad.pt(),
|
||||||
|
textRect.width() + 2*pad.pt(),
|
||||||
|
textRect.height() + 2*pad.pt() );
|
||||||
|
|
||||||
|
painter->setPen( Qt::NoPen );
|
||||||
|
painter->setBrush( QBrush( fillColor ) );
|
||||||
|
painter->drawRect( holeRect );
|
||||||
|
|
||||||
|
// Render text
|
||||||
|
painter->setFont( font );
|
||||||
|
painter->setPen( QPen( labelColor ) );
|
||||||
|
painter->drawText( QRectF( 0, 0, mW.pt(), mH.pt() ),
|
||||||
|
Qt::AlignCenter,
|
||||||
|
labelText );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( mImage )
|
else if ( mImage )
|
||||||
{
|
{
|
||||||
@@ -448,7 +538,17 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else if ( mFilenameNode.isField() )
|
else if ( mFilenameNode.isField() )
|
||||||
{
|
{
|
||||||
// TODO
|
// Look for image file relative to project file 1st then CWD 2nd
|
||||||
|
auto* model = dynamic_cast<Model*>( parent() );
|
||||||
|
QDir::setSearchPaths( "images", {model->dirPath(), QDir::currentPath()} );
|
||||||
|
QString filename = QString("images:") + mFilenameNode.text( record, variables );
|
||||||
|
|
||||||
|
auto* image = new QImage( filename );
|
||||||
|
if ( !image->isNull() )
|
||||||
|
{
|
||||||
|
painter->drawImage( destRect, *image );
|
||||||
|
}
|
||||||
|
delete image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,14 +647,15 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Create shadow image
|
/// Create shadow image
|
||||||
///
|
///
|
||||||
QImage* ModelImageObject::createShadowImage( const QColor& color ) const
|
QImage* ModelImageObject::createShadowImage( const QImage& image,
|
||||||
|
const QColor& color ) const
|
||||||
{
|
{
|
||||||
int r = color.red();
|
int r = color.red();
|
||||||
int g = color.green();
|
int g = color.green();
|
||||||
int b = color.blue();
|
int b = color.blue();
|
||||||
int a = color.alpha();
|
int a = color.alpha();
|
||||||
|
|
||||||
auto* shadow = new QImage( *mImage );
|
auto* shadow = new QImage( image );
|
||||||
for ( int iy = 0; iy < shadow->height(); iy++ )
|
for ( int iy = 0; iy < shadow->height(); iy++ )
|
||||||
{
|
{
|
||||||
auto* scanLine = (QRgb*)shadow->scanLine( iy );
|
auto* scanLine = (QRgb*)shadow->scanLine( iy );
|
||||||
|
|||||||
@@ -135,8 +135,16 @@ namespace glabels
|
|||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter,
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
|
void drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
|
|
||||||
@@ -144,7 +152,9 @@ namespace glabels
|
|||||||
// Private
|
// Private
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
void loadImage();
|
void loadImage();
|
||||||
QImage* createShadowImage( const QColor& color ) const;
|
|
||||||
|
QImage* createShadowImage( const QImage& image,
|
||||||
|
const QColor& color ) const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -186,10 +186,13 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void ModelLineObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelLineObject::drawShadow( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record, variables );
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
QColor shadowColor = mShadowColorNode.color( record, variables );
|
||||||
|
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
@@ -204,9 +207,12 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void ModelLineObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelLineObject::drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record, variables );
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|||||||
+10
-2
@@ -97,8 +97,16 @@ namespace glabels
|
|||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter,
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
|
void drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1226,7 +1226,10 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Draw object + shadow
|
/// Draw object + shadow
|
||||||
///
|
///
|
||||||
void ModelObject::draw( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelObject::draw( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate( mX0.pt(), mY0.pt() );
|
painter->translate( mX0.pt(), mY0.pt() );
|
||||||
@@ -1236,12 +1239,12 @@ namespace glabels
|
|||||||
painter->save();
|
painter->save();
|
||||||
painter->translate( mShadowX.pt(), mShadowY.pt() );
|
painter->translate( mShadowX.pt(), mShadowY.pt() );
|
||||||
painter->setMatrix( mMatrix, true );
|
painter->setMatrix( mMatrix, true );
|
||||||
drawShadow( painter, inEditor, record );
|
drawShadow( painter, inEditor, record, variables );
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setMatrix( mMatrix, true );
|
painter->setMatrix( mMatrix, true );
|
||||||
drawObject( painter, inEditor, record );
|
drawObject( painter, inEditor, record, variables );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-3
@@ -27,6 +27,7 @@
|
|||||||
#include "Handles.h"
|
#include "Handles.h"
|
||||||
#include "Outline.h"
|
#include "Outline.h"
|
||||||
#include "TextNode.h"
|
#include "TextNode.h"
|
||||||
|
#include "Variables.h"
|
||||||
|
|
||||||
#include "barcode/Style.h"
|
#include "barcode/Style.h"
|
||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
@@ -411,12 +412,24 @@ namespace glabels
|
|||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
void draw( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const;
|
||||||
|
|
||||||
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
virtual void drawShadow( QPainter* painter,
|
||||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const = 0;
|
||||||
|
|
||||||
|
virtual void drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const = 0;
|
||||||
|
|
||||||
virtual QPainterPath hoverPath( double scale ) const = 0;
|
virtual QPainterPath hoverPath( double scale ) const = 0;
|
||||||
|
|
||||||
virtual void sizeUpdated();
|
virtual void sizeUpdated();
|
||||||
|
|||||||
+15
-12
@@ -519,13 +519,14 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void ModelTextObject::drawShadow( QPainter* painter,
|
void ModelTextObject::drawShadow( QPainter* painter,
|
||||||
bool inEditor,
|
bool inEditor,
|
||||||
merge::Record* record ) const
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor textColor = mTextColorNode.color( record );
|
QColor textColor = mTextColorNode.color( record, variables );
|
||||||
|
|
||||||
if ( textColor.alpha() )
|
if ( textColor.alpha() )
|
||||||
{
|
{
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
QColor shadowColor = mShadowColorNode.color( record, variables );
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
if ( inEditor )
|
if ( inEditor )
|
||||||
@@ -534,7 +535,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawText( painter, shadowColor, record );
|
drawText( painter, shadowColor, record, variables );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -545,9 +546,10 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void ModelTextObject::drawObject( QPainter* painter,
|
void ModelTextObject::drawObject( QPainter* painter,
|
||||||
bool inEditor,
|
bool inEditor,
|
||||||
merge::Record* record ) const
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
QColor textColor = mTextColorNode.color( record );
|
QColor textColor = mTextColorNode.color( record, variables );
|
||||||
|
|
||||||
if ( inEditor )
|
if ( inEditor )
|
||||||
{
|
{
|
||||||
@@ -555,7 +557,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawText( painter, textColor, record );
|
drawText( painter, textColor, record, variables );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +699,8 @@ namespace glabels
|
|||||||
void
|
void
|
||||||
ModelTextObject::drawText( QPainter* painter,
|
ModelTextObject::drawText( QPainter* painter,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
merge::Record* record ) const
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
@@ -705,7 +708,7 @@ namespace glabels
|
|||||||
|
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setFamily( mFontFamily );
|
font.setFamily( mFontFamily );
|
||||||
font.setPointSizeF( mTextAutoShrink ? autoShrinkFontSize( record ) : mFontSize );
|
font.setPointSizeF( mTextAutoShrink ? autoShrinkFontSize( record, variables ) : mFontSize );
|
||||||
font.setWeight( mFontWeight );
|
font.setWeight( mFontWeight );
|
||||||
font.setItalic( mFontItalicFlag );
|
font.setItalic( mFontItalicFlag );
|
||||||
font.setUnderline( mFontUnderlineFlag );
|
font.setUnderline( mFontUnderlineFlag );
|
||||||
@@ -717,7 +720,7 @@ namespace glabels
|
|||||||
QFontMetricsF fontMetrics( font );
|
QFontMetricsF fontMetrics( font );
|
||||||
double dy = fontMetrics.lineSpacing() * mTextLineSpacing;
|
double dy = fontMetrics.lineSpacing() * mTextLineSpacing;
|
||||||
|
|
||||||
QTextDocument document( mText.expand( record ) );
|
QTextDocument document( mText.expand( record, variables ) );
|
||||||
|
|
||||||
QList<QTextLayout*> layouts;
|
QList<QTextLayout*> layouts;
|
||||||
|
|
||||||
@@ -791,7 +794,7 @@ namespace glabels
|
|||||||
/// Determine auto shrink font size
|
/// Determine auto shrink font size
|
||||||
///
|
///
|
||||||
double
|
double
|
||||||
ModelTextObject::autoShrinkFontSize( merge::Record* record ) const
|
ModelTextObject::autoShrinkFontSize( merge::Record* record, Variables* variables ) const
|
||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setFamily( mFontFamily );
|
font.setFamily( mFontFamily );
|
||||||
@@ -803,7 +806,7 @@ namespace glabels
|
|||||||
textOption.setAlignment( mTextHAlign );
|
textOption.setAlignment( mTextHAlign );
|
||||||
textOption.setWrapMode( mTextWrapMode );
|
textOption.setWrapMode( mTextWrapMode );
|
||||||
|
|
||||||
QTextDocument document( mText.expand( record ) );
|
QTextDocument document( mText.expand( record, variables ) );
|
||||||
|
|
||||||
double candidateSize = mFontSize;
|
double candidateSize = mFontSize;
|
||||||
while ( candidateSize > 1.0 )
|
while ( candidateSize > 1.0 )
|
||||||
|
|||||||
+21
-6
@@ -186,8 +186,16 @@ namespace glabels
|
|||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter,
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
|
void drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const override;
|
||||||
|
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
|
|
||||||
@@ -197,10 +205,17 @@ namespace glabels
|
|||||||
private:
|
private:
|
||||||
void sizeUpdated() override;
|
void sizeUpdated() override;
|
||||||
void update();
|
void update();
|
||||||
void drawTextInEditor( QPainter* painter, const QColor& color ) const;
|
|
||||||
void drawText( QPainter* painter, const QColor&color, merge::Record* record ) const;
|
void drawTextInEditor( QPainter* painter,
|
||||||
QString expandText( QString text, merge::Record* record ) const;
|
const QColor& color ) const;
|
||||||
double autoShrinkFontSize( merge::Record* record ) const;
|
|
||||||
|
void drawText( QPainter* painter,
|
||||||
|
const QColor& color,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const;
|
||||||
|
|
||||||
|
double autoShrinkFontSize( merge::Record* record,
|
||||||
|
Variables* variables ) const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
|||||||
+82
-55
@@ -47,7 +47,7 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
PageRenderer::PageRenderer( const Model* model )
|
PageRenderer::PageRenderer( const Model* model )
|
||||||
: mModel(nullptr), mMerge(nullptr), mNCopies(0), mStartLabel(0), mLastLabel(0),
|
: mModel(nullptr), mMerge(nullptr), mVariables(nullptr), mNCopies(0), mStartLabel(0), mLastLabel(0),
|
||||||
mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false),
|
mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false),
|
||||||
mIPage(0), mIsMerge(false), mNPages(0), mNLabelsPerPage(0)
|
mIPage(0), mIsMerge(false), mNPages(0), mNLabelsPerPage(0)
|
||||||
{
|
{
|
||||||
@@ -65,6 +65,7 @@ namespace glabels
|
|||||||
connect( mModel, SIGNAL(changed()), this, SLOT(onModelChanged()) );
|
connect( mModel, SIGNAL(changed()), this, SLOT(onModelChanged()) );
|
||||||
|
|
||||||
onModelChanged();
|
onModelChanged();
|
||||||
|
mVariables = mModel->variables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -246,83 +247,107 @@ namespace glabels
|
|||||||
|
|
||||||
void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
|
void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
|
||||||
{
|
{
|
||||||
int iStart = 0;
|
|
||||||
int iEnd = mNLabelsPerPage;
|
|
||||||
|
|
||||||
if ( iPage == 0 )
|
|
||||||
{
|
|
||||||
iStart = mStartLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (mLastLabel / mNLabelsPerPage) == iPage )
|
|
||||||
{
|
|
||||||
iEnd = mLastLabel % mNLabelsPerPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
printCropMarks( painter );
|
printCropMarks( painter );
|
||||||
|
|
||||||
for ( int i = iStart; i < iEnd; i++ )
|
int iCopy = 0;
|
||||||
|
int iLabel = mStartLabel;
|
||||||
|
int iCurrentPage = 0;
|
||||||
|
mVariables->resetVariables();
|
||||||
|
|
||||||
|
while ( (iCopy < mNCopies) && (iCurrentPage <= iPage) )
|
||||||
{
|
{
|
||||||
painter->save();
|
if ( iCurrentPage == iPage )
|
||||||
|
{
|
||||||
|
int i = iLabel % mNLabelsPerPage;
|
||||||
|
|
||||||
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
painter->save();
|
||||||
|
|
||||||
painter->save();
|
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||||
|
|
||||||
clipLabel( painter );
|
painter->save();
|
||||||
printLabel( painter, nullptr );
|
|
||||||
|
|
||||||
painter->restore(); // From before clip
|
clipLabel( painter );
|
||||||
|
printLabel( painter, nullptr, mVariables );
|
||||||
|
|
||||||
printOutline( painter );
|
painter->restore(); // From before clip
|
||||||
|
|
||||||
painter->restore(); // From before translation
|
printOutline( painter );
|
||||||
|
|
||||||
|
painter->restore(); // From before translation
|
||||||
|
}
|
||||||
|
|
||||||
|
iCopy++;
|
||||||
|
iLabel++;
|
||||||
|
iCurrentPage = iLabel / mNLabelsPerPage;
|
||||||
|
|
||||||
|
mVariables->incrementVariablesOnItem();
|
||||||
|
mVariables->incrementVariablesOnCopy();
|
||||||
|
if ( (iLabel % mNLabelsPerPage) == 0 /* starting a new page */ )
|
||||||
|
{
|
||||||
|
mVariables->incrementVariablesOnPage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::printMergePage( QPainter* painter, int iPage ) const
|
void PageRenderer::printMergePage( QPainter* painter, int iPage ) const
|
||||||
{
|
{
|
||||||
int iRecord = 0;
|
|
||||||
int iStart = 0;
|
|
||||||
int iEnd = mNLabelsPerPage;
|
|
||||||
|
|
||||||
if ( iPage == 0 )
|
|
||||||
{
|
|
||||||
iStart = mStartLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (mLastLabel / mNLabelsPerPage) == iPage )
|
|
||||||
{
|
|
||||||
iEnd = mLastLabel % mNLabelsPerPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<merge::Record*> records = mMerge->selectedRecords();
|
|
||||||
if ( records.size() )
|
|
||||||
{
|
|
||||||
iRecord = (iPage*mNLabelsPerPage + iStart - mStartLabel) % records.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
printCropMarks( painter );
|
printCropMarks( painter );
|
||||||
|
|
||||||
for ( int i = iStart; i < iEnd; i++ )
|
int iCopy = 0;
|
||||||
|
int iLabel = mStartLabel;
|
||||||
|
int iCurrentPage = 0;
|
||||||
|
|
||||||
|
const QList<merge::Record*> records = mMerge->selectedRecords();
|
||||||
|
int iRecord = 0;
|
||||||
|
int nRecords = records.size();
|
||||||
|
|
||||||
|
if ( nRecords == 0 )
|
||||||
{
|
{
|
||||||
painter->save();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
mVariables->resetVariables();
|
||||||
|
|
||||||
painter->save();
|
while ( (iCopy < mNCopies) && (iCurrentPage <= iPage) )
|
||||||
|
{
|
||||||
|
if ( iCurrentPage == iPage )
|
||||||
|
{
|
||||||
|
int i = iLabel % mNLabelsPerPage;
|
||||||
|
|
||||||
clipLabel( painter );
|
painter->save();
|
||||||
printLabel( painter, records[iRecord] );
|
|
||||||
|
|
||||||
painter->restore(); // From before clip
|
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||||
|
|
||||||
printOutline( painter );
|
painter->save();
|
||||||
|
|
||||||
painter->restore(); // From before translation
|
clipLabel( painter );
|
||||||
|
printLabel( painter, records[iRecord], mVariables );
|
||||||
|
|
||||||
iRecord = (iRecord + 1) % records.size();
|
painter->restore(); // From before clip
|
||||||
|
|
||||||
|
printOutline( painter );
|
||||||
|
|
||||||
|
painter->restore(); // From before translation
|
||||||
|
}
|
||||||
|
|
||||||
|
iRecord = (iRecord + 1) % nRecords;
|
||||||
|
if ( iRecord == 0 )
|
||||||
|
{
|
||||||
|
iCopy++;
|
||||||
|
}
|
||||||
|
iLabel++;
|
||||||
|
iCurrentPage = iLabel / mNLabelsPerPage;
|
||||||
|
|
||||||
|
mVariables->incrementVariablesOnItem();
|
||||||
|
if ( iRecord == 0 )
|
||||||
|
{
|
||||||
|
mVariables->incrementVariablesOnCopy();
|
||||||
|
}
|
||||||
|
if ( (iLabel % mNLabelsPerPage) == 0 /* starting a new page */ )
|
||||||
|
{
|
||||||
|
mVariables->incrementVariablesOnPage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +433,9 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::printLabel( QPainter* painter, merge::Record* record ) const
|
void PageRenderer::printLabel( QPainter* painter,
|
||||||
|
merge::Record* record,
|
||||||
|
Variables* variables ) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
@@ -424,7 +451,7 @@ namespace glabels
|
|||||||
painter->scale( -1, 1 );
|
painter->scale( -1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
mModel->draw( painter, false, record );
|
mModel->draw( painter, false, record, variables );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Point.h"
|
#include "Point.h"
|
||||||
|
#include "Variables.h"
|
||||||
|
|
||||||
#include "merge/Merge.h"
|
#include "merge/Merge.h"
|
||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
@@ -100,7 +101,7 @@ namespace glabels
|
|||||||
void printCropMarks( QPainter* painter ) const;
|
void printCropMarks( QPainter* painter ) const;
|
||||||
void printOutline( QPainter* painter ) const;
|
void printOutline( QPainter* painter ) const;
|
||||||
void clipLabel( QPainter* painter ) const;
|
void clipLabel( QPainter* painter ) const;
|
||||||
void printLabel( QPainter* painter, merge::Record* record ) const;
|
void printLabel( QPainter* painter, merge::Record* record, Variables* variables ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -109,6 +110,7 @@ namespace glabels
|
|||||||
private:
|
private:
|
||||||
const Model* mModel;
|
const Model* mModel;
|
||||||
const merge::Merge* mMerge;
|
const merge::Merge* mMerge;
|
||||||
|
Variables* mVariables;
|
||||||
|
|
||||||
int mNCopies;
|
int mNCopies;
|
||||||
int mStartLabel;
|
int mStartLabel;
|
||||||
|
|||||||
+2
-2
@@ -66,7 +66,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Expand all place holders
|
/// Expand all place holders
|
||||||
///
|
///
|
||||||
QString RawText::expand( merge::Record* record ) const
|
QString RawText::expand( merge::Record* record, Variables* variables ) const
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( token.isField )
|
if ( token.isField )
|
||||||
{
|
{
|
||||||
text += token.field.evaluate( record );
|
text += token.field.evaluate( record, variables );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ namespace glabels
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
std::string toStdString() const;
|
std::string toStdString() const;
|
||||||
QString expand( merge::Record* record ) const;
|
QString expand( merge::Record* record, Variables* variables ) const;
|
||||||
bool hasPlaceHolders() const;
|
bool hasPlaceHolders() const;
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
|||||||
@@ -42,21 +42,33 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString SubstitutionField::evaluate( const merge::Record* record ) const
|
QString SubstitutionField::evaluate( const merge::Record* record,
|
||||||
|
const Variables* variables ) const
|
||||||
{
|
{
|
||||||
QString value = mDefaultValue;
|
QString value = mDefaultValue;
|
||||||
|
|
||||||
if ( record && record->contains(mFieldName) && !record->value(mFieldName).isEmpty() )
|
bool haveRecordField = record &&
|
||||||
|
record->contains(mFieldName) &&
|
||||||
|
!record->value(mFieldName).isEmpty();
|
||||||
|
bool haveVariable = variables &&
|
||||||
|
variables->contains(mFieldName) &&
|
||||||
|
!(*variables)[mFieldName].value().isEmpty();
|
||||||
|
|
||||||
|
if ( haveRecordField )
|
||||||
{
|
{
|
||||||
value = record->value(mFieldName);
|
value = record->value(mFieldName);
|
||||||
}
|
}
|
||||||
|
else if ( haveVariable )
|
||||||
|
{
|
||||||
|
value = (*variables)[mFieldName].value();
|
||||||
|
}
|
||||||
|
|
||||||
if ( !mFormatType.isNull() )
|
if ( !mFormatType.isNull() )
|
||||||
{
|
{
|
||||||
value = formatValue( value );
|
value = formatValue( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( record && record->contains(mFieldName) && !record->value(mFieldName).isEmpty() && mNewLine )
|
if ( mNewLine && (haveRecordField || haveVariable) )
|
||||||
{
|
{
|
||||||
value = "\n" + value;
|
value = "\n" + value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#ifndef model_SubstitutionField_h
|
#ifndef model_SubstitutionField_h
|
||||||
#define model_SubstitutionField_h
|
#define model_SubstitutionField_h
|
||||||
|
|
||||||
|
#include "Variables.h"
|
||||||
|
|
||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ namespace glabels
|
|||||||
SubstitutionField();
|
SubstitutionField();
|
||||||
SubstitutionField( const QString& string );
|
SubstitutionField( const QString& string );
|
||||||
|
|
||||||
QString evaluate( const merge::Record* record ) const;
|
QString evaluate( const merge::Record* record, const Variables* variables ) const;
|
||||||
|
|
||||||
QString fieldName() const;
|
QString fieldName() const;
|
||||||
QString defaultValue() const;
|
QString defaultValue() const;
|
||||||
|
|||||||
+21
-35
@@ -105,48 +105,34 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Get text, expand if necessary
|
/// Get text, expand if necessary
|
||||||
///
|
///
|
||||||
QString TextNode::text( merge::Record* record ) const
|
QString TextNode::text( const merge::Record* record,
|
||||||
|
const Variables* variables ) const
|
||||||
{
|
{
|
||||||
if ( mIsField )
|
QString value("");
|
||||||
|
|
||||||
|
bool haveRecordField = mIsField && record &&
|
||||||
|
record->contains(mData) &&
|
||||||
|
!record->value(mData).isEmpty();
|
||||||
|
bool haveVariable = mIsField && variables &&
|
||||||
|
variables->contains(mData) &&
|
||||||
|
!(*variables)[mData].value().isEmpty();
|
||||||
|
|
||||||
|
if ( haveRecordField )
|
||||||
{
|
{
|
||||||
if ( !record )
|
value = record->value(mData);
|
||||||
{
|
|
||||||
return QString("${%1}").arg( mData );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( record->contains( mData ) )
|
|
||||||
{
|
|
||||||
return (*record)[ mData ];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if ( haveVariable )
|
||||||
{
|
{
|
||||||
return mData;
|
value = (*variables)[mData].value();
|
||||||
}
|
}
|
||||||
|
else if ( !mIsField )
|
||||||
|
{
|
||||||
|
value = mData;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Is it an empty field
|
|
||||||
///
|
|
||||||
bool TextNode::isEmptyField( merge::Record* record ) const
|
|
||||||
{
|
|
||||||
if ( record && mIsField )
|
|
||||||
{
|
|
||||||
if ( record->contains( mData ) )
|
|
||||||
{
|
|
||||||
return (*record)[mData].isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -22,6 +22,7 @@
|
|||||||
#define model_TextNode_h
|
#define model_TextNode_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "Variables.h"
|
||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -76,8 +77,8 @@ namespace glabels
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Misc. Methods
|
// Misc. Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
QString text( merge::Record* record ) const;
|
QString text( const merge::Record* record,
|
||||||
bool isEmptyField( merge::Record* record ) const;
|
const Variables* variables ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
@@ -0,0 +1,306 @@
|
|||||||
|
/* Variable.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2016 Jim 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 "Variable.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
|
||||||
|
Variable::Variable( Variable::Type type,
|
||||||
|
const QString& name,
|
||||||
|
const QString& initialValue,
|
||||||
|
Variable::Increment increment,
|
||||||
|
const QString& stepSize )
|
||||||
|
: mType(type),
|
||||||
|
mName(name),
|
||||||
|
mInitialValue(initialValue),
|
||||||
|
mIncrement(increment),
|
||||||
|
mStepSize(stepSize)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Variable::Type Variable::type() const
|
||||||
|
{
|
||||||
|
return mType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::name() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::initialValue() const
|
||||||
|
{
|
||||||
|
return mInitialValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Variable::Increment Variable::increment() const
|
||||||
|
{
|
||||||
|
return mIncrement;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::stepSize() const
|
||||||
|
{
|
||||||
|
return mStepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Variable::resetValue()
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case Type::STRING:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
case Type::INTEGER:
|
||||||
|
mIntegerValue = mInitialValue.toLongLong();
|
||||||
|
mIntegerStep = mStepSize.toLongLong();
|
||||||
|
break;
|
||||||
|
case Type::FLOATING_POINT:
|
||||||
|
mFloatingPointValue = mInitialValue.toDouble();
|
||||||
|
mFloatingPointStep = mStepSize.toDouble();
|
||||||
|
break;
|
||||||
|
case Type::COLOR:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Variable::incrementValueOnItem()
|
||||||
|
{
|
||||||
|
if ( mIncrement == Increment::PER_ITEM )
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case Type::STRING:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
case Type::INTEGER:
|
||||||
|
mIntegerValue += mIntegerStep;
|
||||||
|
break;
|
||||||
|
case Type::FLOATING_POINT:
|
||||||
|
mFloatingPointValue += mFloatingPointStep;
|
||||||
|
break;
|
||||||
|
case Type::COLOR:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Variable::incrementValueOnCopy()
|
||||||
|
{
|
||||||
|
if ( mIncrement == Increment::PER_COPY )
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case Type::STRING:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
case Type::INTEGER:
|
||||||
|
mIntegerValue += mIntegerStep;
|
||||||
|
break;
|
||||||
|
case Type::FLOATING_POINT:
|
||||||
|
mFloatingPointValue += mFloatingPointStep;
|
||||||
|
break;
|
||||||
|
case Type::COLOR:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Variable::incrementValueOnPage()
|
||||||
|
{
|
||||||
|
if ( mIncrement == Increment::PER_PAGE )
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case Type::STRING:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
case Type::INTEGER:
|
||||||
|
mIntegerValue += mIntegerStep;
|
||||||
|
break;
|
||||||
|
case Type::FLOATING_POINT:
|
||||||
|
mFloatingPointValue += mFloatingPointStep;
|
||||||
|
break;
|
||||||
|
case Type::COLOR:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::value() const
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case Type::STRING:
|
||||||
|
return mInitialValue;
|
||||||
|
case Type::INTEGER:
|
||||||
|
return QString::number( mIntegerValue );
|
||||||
|
case Type::FLOATING_POINT:
|
||||||
|
return QString::number( mFloatingPointValue, 'g', 15 );
|
||||||
|
case Type::COLOR:
|
||||||
|
return mInitialValue;
|
||||||
|
default:
|
||||||
|
return mInitialValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::typeToI18nString( Type type )
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Type::STRING:
|
||||||
|
return tr("String");
|
||||||
|
case Type::INTEGER:
|
||||||
|
return tr("Integer");
|
||||||
|
case Type::FLOATING_POINT:
|
||||||
|
return tr("Floating Point");
|
||||||
|
case Type::COLOR:
|
||||||
|
return tr("Color");
|
||||||
|
default:
|
||||||
|
return tr("String");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::typeToIdString( Type type )
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Type::STRING:
|
||||||
|
return "string";
|
||||||
|
case Type::INTEGER:
|
||||||
|
return "integer";
|
||||||
|
case Type::FLOATING_POINT:
|
||||||
|
return "float";
|
||||||
|
case Type::COLOR:
|
||||||
|
return "color";
|
||||||
|
default:
|
||||||
|
return "string";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Variable::Type Variable::idStringToType( const QString& id )
|
||||||
|
{
|
||||||
|
if ( id == "string" )
|
||||||
|
{
|
||||||
|
return Type::STRING;
|
||||||
|
}
|
||||||
|
else if ( id == "integer" )
|
||||||
|
{
|
||||||
|
return Type::INTEGER;
|
||||||
|
}
|
||||||
|
else if ( id == "float" )
|
||||||
|
{
|
||||||
|
return Type::FLOATING_POINT;
|
||||||
|
}
|
||||||
|
if ( id == "color" )
|
||||||
|
{
|
||||||
|
return Type::COLOR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Type::STRING; // Default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::incrementToI18nString( Increment increment )
|
||||||
|
{
|
||||||
|
switch (increment)
|
||||||
|
{
|
||||||
|
case Increment::NEVER:
|
||||||
|
return tr("Never");
|
||||||
|
case Increment::PER_ITEM:
|
||||||
|
return tr("Per item");
|
||||||
|
case Increment::PER_COPY:
|
||||||
|
return tr("Per copy");
|
||||||
|
case Increment::PER_PAGE:
|
||||||
|
return tr("Per page");
|
||||||
|
default:
|
||||||
|
return tr("Never");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Variable::incrementToIdString( Increment increment )
|
||||||
|
{
|
||||||
|
switch (increment)
|
||||||
|
{
|
||||||
|
case Increment::NEVER:
|
||||||
|
return "never";
|
||||||
|
case Increment::PER_ITEM:
|
||||||
|
return "per_item";
|
||||||
|
case Increment::PER_COPY:
|
||||||
|
return "per_copy";
|
||||||
|
case Increment::PER_PAGE:
|
||||||
|
return "per_page";
|
||||||
|
default:
|
||||||
|
return "never";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Variable::Increment Variable::idStringToIncrement( const QString& id )
|
||||||
|
{
|
||||||
|
if ( id == "never" )
|
||||||
|
{
|
||||||
|
return Increment::NEVER;
|
||||||
|
}
|
||||||
|
else if ( id == "per_item" )
|
||||||
|
{
|
||||||
|
return Increment::PER_ITEM;
|
||||||
|
}
|
||||||
|
else if ( id == "per_copy" )
|
||||||
|
{
|
||||||
|
return Increment::PER_COPY;
|
||||||
|
}
|
||||||
|
else if ( id == "per_page" )
|
||||||
|
{
|
||||||
|
return Increment::PER_PAGE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Increment::NEVER; // Default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/* Variable.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 Jim 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_Variable_h
|
||||||
|
#define model_Variable_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
|
||||||
|
class Variable
|
||||||
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(Variable)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum class Type
|
||||||
|
{
|
||||||
|
STRING,
|
||||||
|
INTEGER,
|
||||||
|
FLOATING_POINT,
|
||||||
|
COLOR
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Increment
|
||||||
|
{
|
||||||
|
NEVER,
|
||||||
|
PER_ITEM,
|
||||||
|
PER_COPY,
|
||||||
|
PER_PAGE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
Variable() = default;
|
||||||
|
|
||||||
|
Variable( Type type,
|
||||||
|
const QString& name,
|
||||||
|
const QString& initialValue,
|
||||||
|
Increment increment = Increment::NEVER,
|
||||||
|
const QString& stepSize = "0" );
|
||||||
|
|
||||||
|
virtual ~Variable() = default;
|
||||||
|
|
||||||
|
|
||||||
|
Type type() const;
|
||||||
|
QString name() const;
|
||||||
|
QString initialValue() const;
|
||||||
|
Increment increment() const;
|
||||||
|
QString stepSize() const;
|
||||||
|
|
||||||
|
void resetValue();
|
||||||
|
void incrementValueOnItem();
|
||||||
|
void incrementValueOnCopy();
|
||||||
|
void incrementValueOnPage();
|
||||||
|
QString value() const;
|
||||||
|
|
||||||
|
static QString typeToI18nString( Type type );
|
||||||
|
static QString typeToIdString( Type type );
|
||||||
|
static Type idStringToType( const QString& string );
|
||||||
|
|
||||||
|
static QString incrementToI18nString( Increment increment );
|
||||||
|
static QString incrementToIdString( Increment increment );
|
||||||
|
static Increment idStringToIncrement( const QString& string );
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type mType;
|
||||||
|
QString mName;
|
||||||
|
QString mInitialValue;
|
||||||
|
Increment mIncrement;
|
||||||
|
QString mStepSize;
|
||||||
|
|
||||||
|
long long mIntegerValue;
|
||||||
|
long long mIntegerStep;
|
||||||
|
double mFloatingPointValue;
|
||||||
|
double mFloatingPointStep;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // model_Variable_h
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
/* Variables.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2016 Jim 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 "Variables.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
///
|
||||||
|
/// Copy constructor
|
||||||
|
///
|
||||||
|
Variables::Variables( const Variables* variables )
|
||||||
|
: QMap<QString,Variable>(*variables)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clone
|
||||||
|
///
|
||||||
|
Variables* Variables::clone() const
|
||||||
|
{
|
||||||
|
return new Variables( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Do we have variable?
|
||||||
|
///
|
||||||
|
bool Variables::hasVariable( const QString& name ) const
|
||||||
|
{
|
||||||
|
return contains(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Add variable ( will replace if name is the same )
|
||||||
|
///
|
||||||
|
void Variables::addVariable( const Variable& variable )
|
||||||
|
{
|
||||||
|
insert( variable.name(), variable );
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Delete variable
|
||||||
|
///
|
||||||
|
void Variables::deleteVariable( const QString& name )
|
||||||
|
{
|
||||||
|
remove( name );
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Replace variable
|
||||||
|
///
|
||||||
|
void Variables::replaceVariable( const QString& origName, const Variable& variable )
|
||||||
|
{
|
||||||
|
remove( origName );
|
||||||
|
insert( variable.name(), variable );
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reset variables to their initial values
|
||||||
|
///
|
||||||
|
void Variables::resetVariables()
|
||||||
|
{
|
||||||
|
for ( auto& v : *this )
|
||||||
|
{
|
||||||
|
v.resetValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Increment variables on item
|
||||||
|
///
|
||||||
|
void Variables::incrementVariablesOnItem()
|
||||||
|
{
|
||||||
|
for ( auto& v : *this )
|
||||||
|
{
|
||||||
|
v.incrementValueOnItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Increment variables on copy
|
||||||
|
///
|
||||||
|
void Variables::incrementVariablesOnCopy()
|
||||||
|
{
|
||||||
|
for ( auto& v : *this )
|
||||||
|
{
|
||||||
|
v.incrementValueOnCopy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Increment variables on page
|
||||||
|
///
|
||||||
|
void Variables::incrementVariablesOnPage()
|
||||||
|
{
|
||||||
|
for ( auto& v : *this )
|
||||||
|
{
|
||||||
|
v.incrementValueOnPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace model
|
||||||
|
|
||||||
|
} // namespace glabels
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/* Variables.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2016 Jim 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_Variables_h
|
||||||
|
#define model_Variables_h
|
||||||
|
|
||||||
|
|
||||||
|
#include "Variable.h"
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Variables Collection
|
||||||
|
///
|
||||||
|
class Variables : public QObject, public QMap<QString,Variable>
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
Variables() = default;
|
||||||
|
Variables( const Variables* variables );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
Variables* clone() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
bool hasVariable( const QString& name ) const;
|
||||||
|
void addVariable( const Variable& variable );
|
||||||
|
void deleteVariable( const QString& name );
|
||||||
|
void replaceVariable( const QString& name, const Variable& variable );
|
||||||
|
|
||||||
|
void resetVariables();
|
||||||
|
void incrementVariablesOnItem();
|
||||||
|
void incrementVariablesOnCopy();
|
||||||
|
void incrementVariablesOnPage();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void changed();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // model_Variables_h
|
||||||
+107
-28
@@ -29,9 +29,11 @@
|
|||||||
#include "ModelImageObject.h"
|
#include "ModelImageObject.h"
|
||||||
#include "ModelTextObject.h"
|
#include "ModelTextObject.h"
|
||||||
#include "DataCache.h"
|
#include "DataCache.h"
|
||||||
|
#include "Variables.h"
|
||||||
#include "XmlTemplateCreator.h"
|
#include "XmlTemplateCreator.h"
|
||||||
#include "XmlUtil.h"
|
#include "XmlUtil.h"
|
||||||
|
|
||||||
|
#include "merge/Factory.h"
|
||||||
#include "merge/None.h"
|
#include "merge/None.h"
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
@@ -48,38 +50,41 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelCreator::writeFile( const Model* label, const QString& fileName )
|
XmlLabelCreator::writeFile( Model* model, const QString& fileName )
|
||||||
{
|
{
|
||||||
QDomDocument doc;
|
|
||||||
|
|
||||||
createDoc( doc, label );
|
|
||||||
QByteArray buffer = doc.toByteArray( 2 );
|
|
||||||
|
|
||||||
QFile file( fileName );
|
QFile file( fileName );
|
||||||
|
|
||||||
if ( !file.open( QFile::WriteOnly | QFile::Text) )
|
if ( !file.open( QFile::WriteOnly | QFile::Text) )
|
||||||
{
|
{
|
||||||
qWarning() << "Error: Cannot write file " << fileName
|
qWarning() << "Error: Cannot write file " << fileName
|
||||||
<< ": " << file.errorString();
|
<< ": " << file.errorString();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model->setFileName( fileName );
|
||||||
|
model->clearModified();
|
||||||
|
|
||||||
|
QDomDocument doc;
|
||||||
|
createDoc( doc, model );
|
||||||
|
|
||||||
|
QByteArray buffer = doc.toByteArray( 2 );
|
||||||
file.write( buffer.data(), buffer.size() );
|
file.write( buffer.data(), buffer.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelCreator::writeBuffer( const Model* label, QByteArray& buffer )
|
XmlLabelCreator::writeBuffer( const Model* model, QByteArray& buffer )
|
||||||
{
|
{
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
|
|
||||||
createDoc( doc, label );
|
createDoc( doc, model );
|
||||||
buffer = doc.toByteArray( 2 );
|
buffer = doc.toByteArray( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelCreator::serializeObjects( const QList<ModelObject*>& objects,
|
XmlLabelCreator::serializeObjects( const QList<ModelObject*>& objects,
|
||||||
QByteArray& buffer )
|
const Model* model,
|
||||||
|
QByteArray& buffer )
|
||||||
{
|
{
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
|
|
||||||
@@ -90,15 +95,15 @@ namespace glabels
|
|||||||
doc.appendChild( root );
|
doc.appendChild( root );
|
||||||
XmlUtil::setStringAttr( root, "version", "4.0" );
|
XmlUtil::setStringAttr( root, "version", "4.0" );
|
||||||
|
|
||||||
createDataNode( root, objects );
|
createDataNode( root, model, objects );
|
||||||
createObjectsNode( root, objects, false );
|
createObjectsNode( root, model, objects, false );
|
||||||
|
|
||||||
buffer = doc.toByteArray( 2 );
|
buffer = doc.toByteArray( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelCreator::createDoc( QDomDocument& doc, const Model* label )
|
XmlLabelCreator::createDoc( QDomDocument& doc, const Model* model )
|
||||||
{
|
{
|
||||||
QDomNode xmlNode( doc.createProcessingInstruction( "xml", "version=\"1.0\"" ) );
|
QDomNode xmlNode( doc.createProcessingInstruction( "xml", "version=\"1.0\"" ) );
|
||||||
doc.appendChild( xmlNode );
|
doc.appendChild( xmlNode );
|
||||||
@@ -107,21 +112,29 @@ namespace glabels
|
|||||||
doc.appendChild( root );
|
doc.appendChild( root );
|
||||||
XmlUtil::setStringAttr( root, "version", "4.0" );
|
XmlUtil::setStringAttr( root, "version", "4.0" );
|
||||||
|
|
||||||
XmlTemplateCreator().createTemplateNode( root, label->tmplate() );
|
XmlTemplateCreator().createTemplateNode( root, model->tmplate() );
|
||||||
|
|
||||||
createObjectsNode( root, label->objectList(), label->rotate() );
|
createObjectsNode( root, model, model->objectList(), model->rotate() );
|
||||||
|
|
||||||
if ( label->merge() && !dynamic_cast<merge::None*>(label->merge()) )
|
if ( model->merge() && !dynamic_cast<merge::None*>(model->merge()) )
|
||||||
{
|
{
|
||||||
createMergeNode( root, label );
|
createMergeNode( root, model );
|
||||||
}
|
}
|
||||||
|
|
||||||
createDataNode( root, label->objectList() );
|
if ( model->variables()->size() != 0 )
|
||||||
|
{
|
||||||
|
createVariablesNode( root, model );
|
||||||
|
}
|
||||||
|
|
||||||
|
createDataNode( root, model, model->objectList() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelCreator::createObjectsNode( QDomElement &parent, const QList<ModelObject*>& objects, bool rotate )
|
XmlLabelCreator::createObjectsNode( QDomElement& parent,
|
||||||
|
const Model* model,
|
||||||
|
const QList<ModelObject*>& objects,
|
||||||
|
bool rotate )
|
||||||
{
|
{
|
||||||
QDomDocument doc = parent.ownerDocument();
|
QDomDocument doc = parent.ownerDocument();
|
||||||
QDomElement node = doc.createElement( "Objects" );
|
QDomElement node = doc.createElement( "Objects" );
|
||||||
@@ -146,7 +159,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else if ( auto* imageObject = dynamic_cast<ModelImageObject*>(object) )
|
else if ( auto* imageObject = dynamic_cast<ModelImageObject*>(object) )
|
||||||
{
|
{
|
||||||
createObjectImageNode( node, imageObject );
|
createObjectImageNode( node, model, imageObject );
|
||||||
}
|
}
|
||||||
else if ( auto* barcodeObject = dynamic_cast<ModelBarcodeObject*>(object) )
|
else if ( auto* barcodeObject = dynamic_cast<ModelBarcodeObject*>(object) )
|
||||||
{
|
{
|
||||||
@@ -244,7 +257,9 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelCreator::createObjectImageNode( QDomElement &parent, const ModelImageObject* object )
|
XmlLabelCreator::createObjectImageNode( QDomElement& parent,
|
||||||
|
const Model* model,
|
||||||
|
const ModelImageObject* object )
|
||||||
{
|
{
|
||||||
QDomDocument doc = parent.ownerDocument();
|
QDomDocument doc = parent.ownerDocument();
|
||||||
QDomElement node = doc.createElement( "Object-image" );
|
QDomElement node = doc.createElement( "Object-image" );
|
||||||
@@ -263,7 +278,8 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
XmlUtil::setStringAttr( node, "src", object->filenameNode().data() );
|
QString fn = model->dir().relativeFilePath( object->filenameNode().data() );
|
||||||
|
XmlUtil::setStringAttr( node, "src", fn );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* affine attrs */
|
/* affine attrs */
|
||||||
@@ -453,19 +469,80 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelCreator::createMergeNode( QDomElement &parent, const Model* label )
|
XmlLabelCreator::createMergeNode( QDomElement &parent, const Model* model )
|
||||||
{
|
{
|
||||||
QDomDocument doc = parent.ownerDocument();
|
QDomDocument doc = parent.ownerDocument();
|
||||||
QDomElement node = doc.createElement( "Merge" );
|
QDomElement node = doc.createElement( "Merge" );
|
||||||
parent.appendChild( node );
|
parent.appendChild( node );
|
||||||
|
|
||||||
XmlUtil::setStringAttr( node, "type", label->merge()->id() );
|
QString id = model->merge()->id();
|
||||||
XmlUtil::setStringAttr( node, "src", label->merge()->source() );
|
QString src = model->merge()->source();
|
||||||
|
|
||||||
|
XmlUtil::setStringAttr( node, "type", id );
|
||||||
|
|
||||||
|
switch ( merge::Factory::idToType( id ) )
|
||||||
|
{
|
||||||
|
case merge::Factory::NONE:
|
||||||
|
case merge::Factory::FIXED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case merge::Factory::FILE:
|
||||||
|
{
|
||||||
|
QString fn = model->dir().relativeFilePath( src );
|
||||||
|
XmlUtil::setStringAttr( node, "src", fn );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
qWarning() << "XmlLabelCreator::createMergeNode(): Should not be reached!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelCreator::createDataNode( QDomElement &parent, const QList<ModelObject*>& objects )
|
XmlLabelCreator::createVariablesNode( QDomElement &parent, const Model* model )
|
||||||
|
{
|
||||||
|
QDomDocument doc = parent.ownerDocument();
|
||||||
|
QDomElement node = doc.createElement( "Variables" );
|
||||||
|
parent.appendChild( node );
|
||||||
|
|
||||||
|
for ( const auto& v : *model->variables() )
|
||||||
|
{
|
||||||
|
createVariableNode( node, v );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
XmlLabelCreator::createVariableNode( QDomElement &parent, const Variable& v )
|
||||||
|
{
|
||||||
|
QDomDocument doc = parent.ownerDocument();
|
||||||
|
QDomElement node = doc.createElement( "Variable" );
|
||||||
|
parent.appendChild( node );
|
||||||
|
|
||||||
|
XmlUtil::setStringAttr( node, "type", Variable::typeToIdString( v.type() ) );
|
||||||
|
XmlUtil::setStringAttr( node, "name", v.name() );
|
||||||
|
XmlUtil::setStringAttr( node, "initialValue", v.initialValue() );
|
||||||
|
|
||||||
|
if ( (v.type() == Variable::Type::INTEGER) ||
|
||||||
|
(v.type() == Variable::Type::FLOATING_POINT) )
|
||||||
|
{
|
||||||
|
XmlUtil::setStringAttr( node, "increment",
|
||||||
|
Variable::incrementToIdString( v.increment() ) );
|
||||||
|
|
||||||
|
if ( v.increment() != Variable::Increment::NEVER )
|
||||||
|
{
|
||||||
|
XmlUtil::setStringAttr( node, "stepSize", v.stepSize() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
XmlLabelCreator::createDataNode( QDomElement& parent,
|
||||||
|
const Model* model,
|
||||||
|
const QList<ModelObject*>& objects )
|
||||||
{
|
{
|
||||||
QDomDocument doc = parent.ownerDocument();
|
QDomDocument doc = parent.ownerDocument();
|
||||||
QDomElement node = doc.createElement( "Data" );
|
QDomElement node = doc.createElement( "Data" );
|
||||||
@@ -475,12 +552,14 @@ namespace glabels
|
|||||||
|
|
||||||
foreach ( QString name, data.imageNames() )
|
foreach ( QString name, data.imageNames() )
|
||||||
{
|
{
|
||||||
createPngFileNode( node, name, data.getImage( name ) );
|
QString fn = model->dir().relativeFilePath( name );
|
||||||
|
createPngFileNode( node, fn, data.getImage( name ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( QString name, data.svgNames() )
|
foreach ( QString name, data.svgNames() )
|
||||||
{
|
{
|
||||||
createSvgFileNode( node, name, data.getSvg( name ) );
|
QString fn = model->dir().relativeFilePath( name );
|
||||||
|
createSvgFileNode( node, fn, data.getSvg( name ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+80
-23
@@ -40,6 +40,7 @@ namespace glabels
|
|||||||
class ModelImageObject;
|
class ModelImageObject;
|
||||||
class ModelBarcodeObject;
|
class ModelBarcodeObject;
|
||||||
class ModelTextObject;
|
class ModelTextObject;
|
||||||
|
class Variable;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -50,31 +51,87 @@ namespace glabels
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void writeFile( const Model* label, const QString& fileName );
|
static void writeFile( Model* model,
|
||||||
static void writeBuffer( const Model* label, QByteArray& buffer );
|
const QString& fileName );
|
||||||
static void serializeObjects( const QList<ModelObject*>& objects, QByteArray& buffer );
|
|
||||||
|
static void writeBuffer( const Model* model,
|
||||||
|
QByteArray& buffer );
|
||||||
|
|
||||||
|
static void serializeObjects( const QList<ModelObject*>& objects,
|
||||||
|
const Model* model,
|
||||||
|
QByteArray& buffer );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void createDoc( QDomDocument& doc, const Model* label );
|
static void createDoc( QDomDocument& doc,
|
||||||
static void createRootNode( const Model* label );
|
const Model* model );
|
||||||
static void createObjectsNode( QDomElement &parent, const QList<ModelObject*>& objects, bool rotate );
|
|
||||||
static void createObjectBoxNode( QDomElement &parent, const ModelBoxObject* object );
|
static void createRootNode( const Model* model );
|
||||||
static void createObjectEllipseNode( QDomElement &parent, const ModelEllipseObject* object );
|
|
||||||
static void createObjectLineNode( QDomElement &parent, const ModelLineObject* object );
|
static void createObjectsNode( QDomElement& parent,
|
||||||
static void createObjectImageNode( QDomElement &parent, const ModelImageObject* object );
|
const Model* model,
|
||||||
static void createObjectBarcodeNode( QDomElement &parent, const ModelBarcodeObject* object );
|
const QList<ModelObject*>& objects,
|
||||||
static void createObjectTextNode( QDomElement &parent, const ModelTextObject* object );
|
bool rotate );
|
||||||
static void createPNode( QDomElement &parent, const QString& blockText );
|
|
||||||
static void createPositionAttrs( QDomElement &node, const ModelObject* object );
|
static void createObjectBoxNode( QDomElement& parent,
|
||||||
static void createSizeAttrs( QDomElement &node, const ModelObject* object );
|
const ModelBoxObject* object );
|
||||||
static void createLineAttrs( QDomElement &node, const ModelObject* object );
|
|
||||||
static void createFillAttrs( QDomElement &node, const ModelObject* object );
|
static void createObjectEllipseNode( QDomElement& parent,
|
||||||
static void createAffineAttrs( QDomElement &node, const ModelObject* object );
|
const ModelEllipseObject* object );
|
||||||
static void createShadowAttrs( QDomElement &node, const ModelObject* object );
|
|
||||||
static void createMergeNode( QDomElement &parent, const Model* label );
|
static void createObjectLineNode( QDomElement& parent,
|
||||||
static void createDataNode( QDomElement &parent, const QList<ModelObject*>& objects );
|
const ModelLineObject* object );
|
||||||
static void createPngFileNode( QDomElement &parent, const QString& name, const QImage& image );
|
|
||||||
static void createSvgFileNode( QDomElement &parent, const QString& name, const QByteArray& svg );
|
static void createObjectImageNode( QDomElement& parent,
|
||||||
|
const Model* model,
|
||||||
|
const ModelImageObject* object );
|
||||||
|
|
||||||
|
static void createObjectBarcodeNode( QDomElement& parent,
|
||||||
|
const ModelBarcodeObject* object );
|
||||||
|
|
||||||
|
static void createObjectTextNode( QDomElement& parent,
|
||||||
|
const ModelTextObject* object );
|
||||||
|
|
||||||
|
static void createPNode( QDomElement& parent,
|
||||||
|
const QString& blockText );
|
||||||
|
|
||||||
|
static void createPositionAttrs( QDomElement& node,
|
||||||
|
const ModelObject* object );
|
||||||
|
|
||||||
|
static void createSizeAttrs( QDomElement& node,
|
||||||
|
const ModelObject* object );
|
||||||
|
|
||||||
|
static void createLineAttrs( QDomElement& node,
|
||||||
|
const ModelObject* object );
|
||||||
|
|
||||||
|
static void createFillAttrs( QDomElement& node,
|
||||||
|
const ModelObject* object );
|
||||||
|
|
||||||
|
static void createAffineAttrs( QDomElement& node,
|
||||||
|
const ModelObject* object );
|
||||||
|
|
||||||
|
static void createShadowAttrs( QDomElement& node,
|
||||||
|
const ModelObject* object );
|
||||||
|
|
||||||
|
static void createMergeNode( QDomElement& parent,
|
||||||
|
const Model* model );
|
||||||
|
|
||||||
|
static void createVariablesNode( QDomElement& parent,
|
||||||
|
const Model* model );
|
||||||
|
|
||||||
|
static void createVariableNode( QDomElement& parent,
|
||||||
|
const Variable& v );
|
||||||
|
|
||||||
|
static void createDataNode( QDomElement& parent,
|
||||||
|
const Model* model,
|
||||||
|
const QList<ModelObject*>& objects );
|
||||||
|
|
||||||
|
static void createPngFileNode( QDomElement& parent,
|
||||||
|
const QString& name,
|
||||||
|
const QImage& image );
|
||||||
|
|
||||||
|
static void createSvgFileNode( QDomElement& parent,
|
||||||
|
const QString& name,
|
||||||
|
const QByteArray& svg );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+115
-50
@@ -105,7 +105,7 @@ namespace glabels
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseRootNode( root );
|
return parseRootNode( root, fileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -132,12 +132,12 @@ namespace glabels
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseRootNode( root );
|
return parseRootNode( root, QString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<ModelObject*>
|
QList<ModelObject*>
|
||||||
XmlLabelParser::deserializeObjects( const QByteArray& buffer )
|
XmlLabelParser::deserializeObjects( const QByteArray& buffer, const Model* model )
|
||||||
{
|
{
|
||||||
QList<ModelObject*> list;
|
QList<ModelObject*> list;
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( child.toElement().tagName() == "Data" )
|
if ( child.toElement().tagName() == "Data" )
|
||||||
{
|
{
|
||||||
parseDataNode( child.toElement(), data );
|
parseDataNode( child.toElement(), model, data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +176,10 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( child.toElement().tagName() == "Objects" )
|
if ( child.toElement().tagName() == "Objects" )
|
||||||
{
|
{
|
||||||
list = parseObjectsNode( child.toElement(), data );
|
list = parseObjectsNode( child.toElement(), model, data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +237,7 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
Model*
|
Model*
|
||||||
XmlLabelParser::parseRootNode( const QDomElement &node )
|
XmlLabelParser::parseRootNode( const QDomElement &node, const QString& fileName )
|
||||||
{
|
{
|
||||||
QString version = XmlUtil::getStringAttr( node, "version", "" );
|
QString version = XmlUtil::getStringAttr( node, "version", "" );
|
||||||
if ( version != "4.0" )
|
if ( version != "4.0" )
|
||||||
@@ -245,7 +246,8 @@ namespace glabels
|
|||||||
return XmlLabelParser_3::parseRootNode(node);
|
return XmlLabelParser_3::parseRootNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* label = new Model();
|
auto* model = new Model();
|
||||||
|
model->setFileName( fileName );
|
||||||
|
|
||||||
/* Pass 1, extract data nodes to pre-load cache. */
|
/* Pass 1, extract data nodes to pre-load cache. */
|
||||||
DataCache data;
|
DataCache data;
|
||||||
@@ -253,7 +255,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( child.toElement().tagName() == "Data" )
|
if ( child.toElement().tagName() == "Data" )
|
||||||
{
|
{
|
||||||
parseDataNode( child.toElement(), data );
|
parseDataNode( child.toElement(), model, data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,23 +270,27 @@ namespace glabels
|
|||||||
if ( tmplate == nullptr )
|
if ( tmplate == nullptr )
|
||||||
{
|
{
|
||||||
qWarning() << "Unable to parse template";
|
qWarning() << "Unable to parse template";
|
||||||
delete label;
|
delete model;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
label->setTmplate( tmplate );
|
model->setTmplate( tmplate );
|
||||||
}
|
}
|
||||||
else if ( tagName == "Objects" )
|
else if ( tagName == "Objects" )
|
||||||
{
|
{
|
||||||
label->setRotate( parseRotateAttr( child.toElement() ) );
|
model->setRotate( parseRotateAttr( child.toElement() ) );
|
||||||
QList<ModelObject*> list = parseObjectsNode( child.toElement(), data );
|
auto list = parseObjectsNode( child.toElement(), model, data );
|
||||||
foreach ( ModelObject* object, list )
|
foreach ( ModelObject* object, list )
|
||||||
{
|
{
|
||||||
label->addObject( object );
|
model->addObject( object );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( tagName == "Merge" )
|
else if ( tagName == "Merge" )
|
||||||
{
|
{
|
||||||
parseMergeNode( child.toElement(), label );
|
parseMergeNode( child.toElement(), model );
|
||||||
|
}
|
||||||
|
else if ( tagName == "Variables" )
|
||||||
|
{
|
||||||
|
parseVariablesNode( child.toElement(), model );
|
||||||
}
|
}
|
||||||
else if ( tagName == "Data" )
|
else if ( tagName == "Data" )
|
||||||
{
|
{
|
||||||
@@ -296,13 +302,15 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
label->clearModified();
|
model->clearModified();
|
||||||
return label;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<ModelObject*>
|
QList<ModelObject*>
|
||||||
XmlLabelParser::parseObjectsNode( const QDomElement &node, const DataCache& data )
|
XmlLabelParser::parseObjectsNode( const QDomElement& node,
|
||||||
|
const Model* model,
|
||||||
|
const DataCache& data )
|
||||||
{
|
{
|
||||||
QList<ModelObject*> list;
|
QList<ModelObject*> list;
|
||||||
|
|
||||||
@@ -328,7 +336,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else if ( tagName == "Object-image" )
|
else if ( tagName == "Object-image" )
|
||||||
{
|
{
|
||||||
list.append( parseObjectImageNode( child.toElement(), data ) );
|
list.append( parseObjectImageNode( child.toElement(), model, data ) );
|
||||||
}
|
}
|
||||||
else if ( tagName == "Object-barcode" )
|
else if ( tagName == "Object-barcode" )
|
||||||
{
|
{
|
||||||
@@ -361,13 +369,13 @@ namespace glabels
|
|||||||
|
|
||||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||||
bool field_flag = !key.isEmpty();
|
bool field_flag = !key.isEmpty();
|
||||||
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0 );
|
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0xFF );
|
||||||
ColorNode lineColorNode( field_flag, color, key );
|
ColorNode lineColorNode( field_flag, color, key );
|
||||||
|
|
||||||
/* fill attrs */
|
/* fill attrs */
|
||||||
key = XmlUtil::getStringAttr( node, "fill_color_field", "" );
|
key = XmlUtil::getStringAttr( node, "fill_color_field", "" );
|
||||||
field_flag = !key.isEmpty();
|
field_flag = !key.isEmpty();
|
||||||
color = XmlUtil::getUIntAttr( node, "fill_color", 0 );
|
color = XmlUtil::getUIntAttr( node, "fill_color", 0xFF );
|
||||||
ColorNode fillColorNode( field_flag, color, key );
|
ColorNode fillColorNode( field_flag, color, key );
|
||||||
|
|
||||||
/* affine attrs */
|
/* affine attrs */
|
||||||
@@ -387,7 +395,7 @@ namespace glabels
|
|||||||
|
|
||||||
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
||||||
field_flag = !key.isEmpty();
|
field_flag = !key.isEmpty();
|
||||||
color = XmlUtil::getUIntAttr( node, "shadow_color", 0 );
|
color = XmlUtil::getUIntAttr( node, "shadow_color", 0xFF );
|
||||||
ColorNode shadowColorNode( field_flag, color, key );
|
ColorNode shadowColorNode( field_flag, color, key );
|
||||||
|
|
||||||
return new ModelBoxObject( x0, y0, w, h, lockAspectRatio,
|
return new ModelBoxObject( x0, y0, w, h, lockAspectRatio,
|
||||||
@@ -415,13 +423,13 @@ namespace glabels
|
|||||||
|
|
||||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||||
bool field_flag = !key.isEmpty();
|
bool field_flag = !key.isEmpty();
|
||||||
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0 );
|
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0xFF );
|
||||||
ColorNode lineColorNode( field_flag, color, key );
|
ColorNode lineColorNode( field_flag, color, key );
|
||||||
|
|
||||||
/* fill attrs */
|
/* fill attrs */
|
||||||
key = XmlUtil::getStringAttr( node, "fill_color_field", "" );
|
key = XmlUtil::getStringAttr( node, "fill_color_field", "" );
|
||||||
field_flag = !key.isEmpty();
|
field_flag = !key.isEmpty();
|
||||||
color = XmlUtil::getUIntAttr( node, "fill_color", 0 );
|
color = XmlUtil::getUIntAttr( node, "fill_color", 0xFF );
|
||||||
ColorNode fillColorNode( field_flag, color, key );
|
ColorNode fillColorNode( field_flag, color, key );
|
||||||
|
|
||||||
/* affine attrs */
|
/* affine attrs */
|
||||||
@@ -441,7 +449,7 @@ namespace glabels
|
|||||||
|
|
||||||
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
||||||
field_flag = !key.isEmpty();
|
field_flag = !key.isEmpty();
|
||||||
color = XmlUtil::getUIntAttr( node, "shadow_color", 0 );
|
color = XmlUtil::getUIntAttr( node, "shadow_color", 0xFF );
|
||||||
ColorNode shadowColorNode( field_flag, color, key );
|
ColorNode shadowColorNode( field_flag, color, key );
|
||||||
|
|
||||||
return new ModelEllipseObject( x0, y0, w, h, lockAspectRatio,
|
return new ModelEllipseObject( x0, y0, w, h, lockAspectRatio,
|
||||||
@@ -468,7 +476,7 @@ namespace glabels
|
|||||||
|
|
||||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||||
bool field_flag = !key.isEmpty();
|
bool field_flag = !key.isEmpty();
|
||||||
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0 );
|
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0xFF );
|
||||||
ColorNode lineColorNode( field_flag, color, key );
|
ColorNode lineColorNode( field_flag, color, key );
|
||||||
|
|
||||||
/* affine attrs */
|
/* affine attrs */
|
||||||
@@ -488,7 +496,7 @@ namespace glabels
|
|||||||
|
|
||||||
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
||||||
field_flag = !key.isEmpty();
|
field_flag = !key.isEmpty();
|
||||||
color = XmlUtil::getUIntAttr( node, "shadow_color", 0 );
|
color = XmlUtil::getUIntAttr( node, "shadow_color", 0xFF );
|
||||||
ColorNode shadowColorNode( field_flag, color, key );
|
ColorNode shadowColorNode( field_flag, color, key );
|
||||||
|
|
||||||
return new ModelLineObject( x0, y0, dx, dy,
|
return new ModelLineObject( x0, y0, dx, dy,
|
||||||
@@ -499,7 +507,9 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
ModelImageObject*
|
ModelImageObject*
|
||||||
XmlLabelParser::parseObjectImageNode( const QDomElement &node, const DataCache& data )
|
XmlLabelParser::parseObjectImageNode( const QDomElement& node,
|
||||||
|
const Model* model,
|
||||||
|
const DataCache& data )
|
||||||
{
|
{
|
||||||
/* position attrs */
|
/* position attrs */
|
||||||
Distance x0 = XmlUtil::getLengthAttr( node, "x", 0.0 );
|
Distance x0 = XmlUtil::getLengthAttr( node, "x", 0.0 );
|
||||||
@@ -533,7 +543,7 @@ namespace glabels
|
|||||||
|
|
||||||
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
||||||
field_flag = !key.isEmpty();
|
field_flag = !key.isEmpty();
|
||||||
uint32_t color = XmlUtil::getUIntAttr( node, "shadow_color", 0 );
|
uint32_t color = XmlUtil::getUIntAttr( node, "shadow_color", 0xFF );
|
||||||
ColorNode shadowColorNode( field_flag, color, key );
|
ColorNode shadowColorNode( field_flag, color, key );
|
||||||
|
|
||||||
if ( filenameNode.isField() )
|
if ( filenameNode.isField() )
|
||||||
@@ -545,17 +555,19 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( data.hasImage( filename ) )
|
QString fn = QDir::cleanPath( model->dir().absoluteFilePath( filename ) );
|
||||||
|
|
||||||
|
if ( data.hasImage( fn ) )
|
||||||
{
|
{
|
||||||
return new ModelImageObject( x0, y0, w, h, lockAspectRatio,
|
return new ModelImageObject( x0, y0, w, h, lockAspectRatio,
|
||||||
filename, data.getImage( filename ),
|
fn, data.getImage( fn ),
|
||||||
QMatrix( a[0], a[1], a[2], a[3], a[4], a[5] ),
|
QMatrix( a[0], a[1], a[2], a[3], a[4], a[5] ),
|
||||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode );
|
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode );
|
||||||
}
|
}
|
||||||
else if ( data.hasSvg( filename ) )
|
else if ( data.hasSvg( fn ) )
|
||||||
{
|
{
|
||||||
return new ModelImageObject( x0, y0, w, h, lockAspectRatio,
|
return new ModelImageObject( x0, y0, w, h, lockAspectRatio,
|
||||||
filename, data.getSvg( filename ),
|
fn, data.getSvg( fn ),
|
||||||
QMatrix( a[0], a[1], a[2], a[3], a[4], a[5] ),
|
QMatrix( a[0], a[1], a[2], a[3], a[4], a[5] ),
|
||||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode );
|
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode );
|
||||||
}
|
}
|
||||||
@@ -563,7 +575,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( !filename.isEmpty() )
|
if ( !filename.isEmpty() )
|
||||||
{
|
{
|
||||||
qWarning() << "Embedded file" << filename << "missing. Trying actual file.";
|
qWarning() << "Embedded file" << fn << "missing. Trying actual file.";
|
||||||
}
|
}
|
||||||
return new ModelImageObject( x0, y0, w, h, lockAspectRatio,
|
return new ModelImageObject( x0, y0, w, h, lockAspectRatio,
|
||||||
filenameNode,
|
filenameNode,
|
||||||
@@ -594,7 +606,7 @@ namespace glabels
|
|||||||
|
|
||||||
QString key = XmlUtil::getStringAttr( node, "color_field", "" );
|
QString key = XmlUtil::getStringAttr( node, "color_field", "" );
|
||||||
bool field_flag = !key.isEmpty();
|
bool field_flag = !key.isEmpty();
|
||||||
uint32_t color = XmlUtil::getUIntAttr( node, "color", 0 );
|
uint32_t color = XmlUtil::getUIntAttr( node, "color", 0xFF );
|
||||||
ColorNode bcColorNode( field_flag, color, key );
|
ColorNode bcColorNode( field_flag, color, key );
|
||||||
|
|
||||||
QString bcData = XmlUtil::getStringAttr( node, "data", "" );
|
QString bcData = XmlUtil::getStringAttr( node, "data", "" );
|
||||||
@@ -629,7 +641,7 @@ namespace glabels
|
|||||||
/* color attr */
|
/* color attr */
|
||||||
QString key = XmlUtil::getStringAttr( node, "color_field", "" );
|
QString key = XmlUtil::getStringAttr( node, "color_field", "" );
|
||||||
bool field_flag = !key.isEmpty();
|
bool field_flag = !key.isEmpty();
|
||||||
uint32_t color = XmlUtil::getUIntAttr( node, "color", 0 );
|
uint32_t color = XmlUtil::getUIntAttr( node, "color", 0xFF );
|
||||||
ColorNode textColorNode( field_flag, color, key );
|
ColorNode textColorNode( field_flag, color, key );
|
||||||
|
|
||||||
/* font attrs */
|
/* font attrs */
|
||||||
@@ -663,7 +675,7 @@ namespace glabels
|
|||||||
|
|
||||||
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
key = XmlUtil::getStringAttr( node, "shadow_color_field", "" );
|
||||||
field_flag = !key.isEmpty();
|
field_flag = !key.isEmpty();
|
||||||
color = XmlUtil::getUIntAttr( node, "shadow_color", 0 );
|
color = XmlUtil::getUIntAttr( node, "shadow_color", 0xFF );
|
||||||
ColorNode shadowColorNode( field_flag, color, key );
|
ColorNode shadowColorNode( field_flag, color, key );
|
||||||
|
|
||||||
/* deserialize contents. */
|
/* deserialize contents. */
|
||||||
@@ -715,28 +727,45 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelParser::parseMergeNode( const QDomElement &node, Model* label )
|
XmlLabelParser::parseMergeNode( const QDomElement &node, Model* model )
|
||||||
{
|
{
|
||||||
QString type = XmlUtil::getStringAttr( node, "type", "None" );
|
QString id = XmlUtil::getStringAttr( node, "type", "None" );
|
||||||
QString src = XmlUtil::getStringAttr( node, "src", "" );
|
QString src = XmlUtil::getStringAttr( node, "src", "" );
|
||||||
|
|
||||||
merge::Merge* merge = merge::Factory::createMerge( type );
|
merge::Merge* merge = merge::Factory::createMerge( id );
|
||||||
merge->setSource( src );
|
|
||||||
|
|
||||||
label->setMerge( merge );
|
switch ( merge::Factory::idToType( id ) )
|
||||||
|
{
|
||||||
|
case merge::Factory::NONE:
|
||||||
|
case merge::Factory::FIXED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case merge::Factory::FILE:
|
||||||
|
{
|
||||||
|
QString fn = QDir::cleanPath( model->dir().absoluteFilePath( src ) );
|
||||||
|
merge->setSource( fn );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
qWarning() << "XmlLabelCreator::createMergeNode(): Should not be reached!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
model->setMerge( merge );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelParser::parseDataNode( const QDomElement &node, DataCache& data )
|
XmlLabelParser::parseVariablesNode( const QDomElement &node, Model* model )
|
||||||
{
|
{
|
||||||
for ( QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling() )
|
for ( QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling() )
|
||||||
{
|
{
|
||||||
QString tagName = child.toElement().tagName();
|
QString tagName = child.toElement().tagName();
|
||||||
|
|
||||||
if ( tagName == "File" )
|
if ( tagName == "Variable" )
|
||||||
{
|
{
|
||||||
parseFileNode( child.toElement(), data );
|
parseVariableNode( child.toElement(), model );
|
||||||
}
|
}
|
||||||
else if ( !child.isComment() )
|
else if ( !child.isComment() )
|
||||||
{
|
{
|
||||||
@@ -747,19 +776,55 @@ namespace glabels
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelParser::parsePixdataNode( const QDomElement& node, DataCache& data )
|
XmlLabelParser::parseVariableNode( const QDomElement &node, Model* model )
|
||||||
{
|
{
|
||||||
// TODO, compatibility with glabels-3
|
QString typeString = XmlUtil::getStringAttr( node, "type", "string" );
|
||||||
|
QString name = XmlUtil::getStringAttr( node, "name", "unknown" );
|
||||||
|
QString initialValue = XmlUtil::getStringAttr( node, "initialValue", "0" );
|
||||||
|
QString incrementString = XmlUtil::getStringAttr( node, "increment", "never" );
|
||||||
|
QString stepSize = XmlUtil::getStringAttr( node, "stepSize", "0" );
|
||||||
|
|
||||||
|
auto type = Variable::idStringToType( typeString );
|
||||||
|
auto increment = Variable::idStringToIncrement( incrementString );
|
||||||
|
|
||||||
|
Variable v( type, name, initialValue, increment, stepSize );
|
||||||
|
model->variables()->addVariable( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlLabelParser::parseFileNode( const QDomElement& node, DataCache& data )
|
XmlLabelParser::parseDataNode( const QDomElement &node,
|
||||||
|
const Model* model,
|
||||||
|
DataCache& data )
|
||||||
|
{
|
||||||
|
for ( QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling() )
|
||||||
|
{
|
||||||
|
QString tagName = child.toElement().tagName();
|
||||||
|
|
||||||
|
if ( tagName == "File" )
|
||||||
|
{
|
||||||
|
parseFileNode( child.toElement(), model, data );
|
||||||
|
}
|
||||||
|
else if ( !child.isComment() )
|
||||||
|
{
|
||||||
|
qWarning() << "Unexpected" << node.tagName() << "child:" << tagName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
XmlLabelParser::parseFileNode( const QDomElement& node,
|
||||||
|
const Model* model,
|
||||||
|
DataCache& data )
|
||||||
{
|
{
|
||||||
QString name = XmlUtil::getStringAttr( node, "name", "" );
|
QString name = XmlUtil::getStringAttr( node, "name", "" );
|
||||||
QString mimetype = XmlUtil::getStringAttr( node, "mimetype", "image/png" );
|
QString mimetype = XmlUtil::getStringAttr( node, "mimetype", "image/png" );
|
||||||
QString encoding = XmlUtil::getStringAttr( node, "encoding", "base64" );
|
QString encoding = XmlUtil::getStringAttr( node, "encoding", "base64" );
|
||||||
|
|
||||||
|
// Rewrite name as absolute file path
|
||||||
|
QString fn = QDir::cleanPath( model->dir().absoluteFilePath( name ) );
|
||||||
|
|
||||||
if ( mimetype == "image/png" )
|
if ( mimetype == "image/png" )
|
||||||
{
|
{
|
||||||
if ( encoding == "base64" )
|
if ( encoding == "base64" )
|
||||||
@@ -769,7 +834,7 @@ namespace glabels
|
|||||||
QImage image;
|
QImage image;
|
||||||
image.loadFromData( ba, "PNG" );
|
image.loadFromData( ba, "PNG" );
|
||||||
|
|
||||||
data.addImage( name, image );
|
data.addImage( fn, image );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -778,7 +843,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
else if ( mimetype == "image/svg+xml" )
|
else if ( mimetype == "image/svg+xml" )
|
||||||
{
|
{
|
||||||
data.addSvg( name, node.text().toUtf8() );
|
data.addSvg( fn, node.text().toUtf8() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+48
-16
@@ -52,25 +52,57 @@ namespace glabels
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static Model* readFile( const QString& fileName );
|
static Model* readFile( const QString& fileName );
|
||||||
|
|
||||||
static Model* readBuffer( const QByteArray& buffer );
|
static Model* readBuffer( const QByteArray& buffer );
|
||||||
static QList<ModelObject*> deserializeObjects( const QByteArray& buffer );
|
|
||||||
|
static QList<ModelObject*> deserializeObjects( const QByteArray& buffer,
|
||||||
|
const Model* model );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void gunzip( const QByteArray& gzippedData, QByteArray& data );
|
static void gunzip( const QByteArray& gzippedData,
|
||||||
static Model* parseRootNode( const QDomElement &node );
|
QByteArray& data );
|
||||||
static QList<ModelObject*> parseObjectsNode( const QDomElement &node, const DataCache& data );
|
|
||||||
static ModelBoxObject* parseObjectBoxNode( const QDomElement &node );
|
static Model* parseRootNode( const QDomElement& node,
|
||||||
static ModelEllipseObject* parseObjectEllipseNode( const QDomElement &node );
|
const QString& fileName );
|
||||||
static ModelLineObject* parseObjectLineNode( const QDomElement &node );
|
|
||||||
static ModelImageObject* parseObjectImageNode( const QDomElement &node, const DataCache& data );
|
static QList<ModelObject*> parseObjectsNode( const QDomElement& node,
|
||||||
static ModelBarcodeObject* parseObjectBarcodeNode( const QDomElement &node );
|
const Model* model,
|
||||||
static ModelTextObject* parseObjectTextNode( const QDomElement &node );
|
const DataCache& data );
|
||||||
static QString parsePNode( const QDomElement &node );
|
|
||||||
static bool parseRotateAttr( const QDomElement &node );
|
static ModelBoxObject* parseObjectBoxNode( const QDomElement& node );
|
||||||
static void parseMergeNode( const QDomElement &node, Model* label );
|
|
||||||
static void parseDataNode( const QDomElement &node, DataCache& data );
|
static ModelEllipseObject* parseObjectEllipseNode( const QDomElement& node );
|
||||||
static void parsePixdataNode( const QDomElement &node, DataCache& data );
|
|
||||||
static void parseFileNode( const QDomElement &node, DataCache& data );
|
static ModelLineObject* parseObjectLineNode( const QDomElement& node );
|
||||||
|
|
||||||
|
static ModelImageObject* parseObjectImageNode( const QDomElement& node,
|
||||||
|
const Model* model,
|
||||||
|
const DataCache& data );
|
||||||
|
|
||||||
|
static ModelBarcodeObject* parseObjectBarcodeNode( const QDomElement& node );
|
||||||
|
|
||||||
|
static ModelTextObject* parseObjectTextNode( const QDomElement& node );
|
||||||
|
|
||||||
|
static QString parsePNode( const QDomElement& node );
|
||||||
|
|
||||||
|
static bool parseRotateAttr( const QDomElement& node );
|
||||||
|
|
||||||
|
static void parseMergeNode( const QDomElement& node,
|
||||||
|
Model* model );
|
||||||
|
|
||||||
|
static void parseVariablesNode( const QDomElement& node,
|
||||||
|
Model* model );
|
||||||
|
|
||||||
|
static void parseVariableNode( const QDomElement& node,
|
||||||
|
Model* model );
|
||||||
|
|
||||||
|
static void parseDataNode( const QDomElement& node,
|
||||||
|
const Model* model,
|
||||||
|
DataCache& data );
|
||||||
|
|
||||||
|
static void parseFileNode( const QDomElement& node,
|
||||||
|
const Model* model,
|
||||||
|
DataCache& data );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ void TestColorNode::colorNode()
|
|||||||
QColor white = QColor::fromRgba( rgbaWhite );
|
QColor white = QColor::fromRgba( rgbaWhite );
|
||||||
QColor red = QColor::fromRgba( qRgbaRed );
|
QColor red = QColor::fromRgba( qRgbaRed );
|
||||||
QColor green80 = QColor::fromRgba( qRgbaGreen80 );
|
QColor green80 = QColor::fromRgba( qRgbaGreen80 );
|
||||||
|
QColor silver80 = QColor( 192, 192, 192, 128 );
|
||||||
|
|
||||||
Record record;
|
Record record;
|
||||||
|
|
||||||
@@ -53,8 +54,8 @@ void TestColorNode::colorNode()
|
|||||||
QCOMPARE( colorNode.color(), blackTransparent );
|
QCOMPARE( colorNode.color(), blackTransparent );
|
||||||
QCOMPARE( colorNode.key(), QString( "" ) );
|
QCOMPARE( colorNode.key(), QString( "" ) );
|
||||||
QCOMPARE( colorNode.rgba(), rgbaBlackTransparent );
|
QCOMPARE( colorNode.rgba(), rgbaBlackTransparent );
|
||||||
QCOMPARE( colorNode.color( nullptr ), blackTransparent );
|
QCOMPARE( colorNode.color( nullptr, nullptr ), blackTransparent );
|
||||||
QCOMPARE( colorNode.color( &record ), blackTransparent );
|
QCOMPARE( colorNode.color( &record, nullptr ), blackTransparent );
|
||||||
|
|
||||||
colorNode.setField( true );
|
colorNode.setField( true );
|
||||||
QVERIFY( colorNode.isField() );
|
QVERIFY( colorNode.isField() );
|
||||||
@@ -64,8 +65,8 @@ void TestColorNode::colorNode()
|
|||||||
colorNode.setColor( white );
|
colorNode.setColor( white );
|
||||||
QCOMPARE( colorNode.color(), white );
|
QCOMPARE( colorNode.color(), white );
|
||||||
QCOMPARE( colorNode.rgba(), rgbaWhite );
|
QCOMPARE( colorNode.rgba(), rgbaWhite );
|
||||||
QCOMPARE( colorNode.color( nullptr ), white );
|
QCOMPARE( colorNode.color( nullptr, nullptr ), white );
|
||||||
QCOMPARE( colorNode.color( &record ), white );
|
QCOMPARE( colorNode.color( &record, nullptr ), white );
|
||||||
|
|
||||||
colorNode.setKey( "key1" );
|
colorNode.setKey( "key1" );
|
||||||
QCOMPARE( colorNode.key(), QString( "key1" ) );
|
QCOMPARE( colorNode.key(), QString( "key1" ) );
|
||||||
@@ -102,28 +103,28 @@ void TestColorNode::colorNode()
|
|||||||
QVERIFY( colorNode.isField() ); // Defaults to true if given key only
|
QVERIFY( colorNode.isField() ); // Defaults to true if given key only
|
||||||
QCOMPARE( colorNode.key(), QString( "key1" ) );
|
QCOMPARE( colorNode.key(), QString( "key1" ) );
|
||||||
QCOMPARE( colorNode.color(), blackTransparent );
|
QCOMPARE( colorNode.color(), blackTransparent );
|
||||||
QCOMPARE( colorNode.color( &record ), blackTransparent );
|
QCOMPARE( colorNode.color( &record, nullptr ), silver80 ); // Defaults to silver if given non-matching record/variables
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Record
|
/// Record
|
||||||
///
|
///
|
||||||
record["key1"] = "white";
|
record["key1"] = "white";
|
||||||
QCOMPARE( colorNode.color( &record ), white );
|
QCOMPARE( colorNode.color( &record, nullptr ), white );
|
||||||
|
|
||||||
record["key1"] = "red";
|
record["key1"] = "red";
|
||||||
QCOMPARE( colorNode.color( &record ), red );
|
QCOMPARE( colorNode.color( &record, nullptr ), red );
|
||||||
|
|
||||||
record["key1"] = "#FF0000";
|
record["key1"] = "#FF0000";
|
||||||
QCOMPARE( colorNode.color( &record ), red );
|
QCOMPARE( colorNode.color( &record, nullptr ), red );
|
||||||
|
|
||||||
record["key1"] = "#FFFF0000"; // ARGB
|
record["key1"] = "#FFFF0000"; // ARGB
|
||||||
QCOMPARE( colorNode.color( &record ), red );
|
QCOMPARE( colorNode.color( &record, nullptr ), red );
|
||||||
|
|
||||||
record["key1"] = "#8000FF00";
|
record["key1"] = "#8000FF00";
|
||||||
QCOMPARE( colorNode.color( &record ), green80 );
|
QCOMPARE( colorNode.color( &record, nullptr ), green80 );
|
||||||
|
|
||||||
colorNode.setKey( "key2" );
|
colorNode.setKey( "key2" );
|
||||||
QCOMPARE( colorNode.color( &record ), blackTransparent );
|
QCOMPARE( colorNode.color( &record, nullptr ), silver80 );
|
||||||
record["key2"] = "#8000FF00";
|
record["key2"] = "#8000FF00";
|
||||||
QCOMPARE( colorNode.color( &record ), green80 );
|
QCOMPARE( colorNode.color( &record, nullptr ), green80 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ void TestRawText::rawText()
|
|||||||
QVERIFY( !rawText.hasPlaceHolders() );
|
QVERIFY( !rawText.hasPlaceHolders() );
|
||||||
QCOMPARE( rawText.toString(), QString( "" ) );
|
QCOMPARE( rawText.toString(), QString( "" ) );
|
||||||
QCOMPARE( rawText.toStdString(), std::string( "" ) );
|
QCOMPARE( rawText.toStdString(), std::string( "" ) );
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "" ) );
|
||||||
|
|
||||||
rawText = "text";
|
rawText = "text";
|
||||||
QVERIFY( !rawText.isEmpty() );
|
QVERIFY( !rawText.isEmpty() );
|
||||||
QVERIFY( !rawText.hasPlaceHolders() );
|
QVERIFY( !rawText.hasPlaceHolders() );
|
||||||
QCOMPARE( rawText.toString(), QString( "text" ) );
|
QCOMPARE( rawText.toString(), QString( "text" ) );
|
||||||
QCOMPARE( rawText.toStdString(), std::string( "text" ) );
|
QCOMPARE( rawText.toStdString(), std::string( "text" ) );
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "text" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "text" ) );
|
||||||
|
|
||||||
RawText rawText2( "text" );
|
RawText rawText2( "text" );
|
||||||
QVERIFY( !rawText2.isEmpty() );
|
QVERIFY( !rawText2.isEmpty() );
|
||||||
@@ -61,34 +61,34 @@ void TestRawText::rawText()
|
|||||||
QVERIFY( rawText.hasPlaceHolders() );
|
QVERIFY( rawText.hasPlaceHolders() );
|
||||||
QCOMPARE( rawText.toString(), QString( "${key1}" ) );
|
QCOMPARE( rawText.toString(), QString( "${key1}" ) );
|
||||||
QCOMPARE( rawText.toStdString(), std::string( "${key1}" ) );
|
QCOMPARE( rawText.toStdString(), std::string( "${key1}" ) );
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "" ) );
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Record
|
/// Record
|
||||||
///
|
///
|
||||||
record["key1"] = "val1";
|
record["key1"] = "val1";
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "val1" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1" ) );
|
||||||
|
|
||||||
rawText = "${key1}${key2}";
|
rawText = "${key1}${key2}";
|
||||||
QVERIFY( rawText.hasPlaceHolders() );
|
QVERIFY( rawText.hasPlaceHolders() );
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "val1" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1" ) );
|
||||||
|
|
||||||
record["key2"] = "val2";
|
record["key2"] = "val2";
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "val1val2" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1val2" ) );
|
||||||
|
|
||||||
rawText = "${key1}text${key2}";
|
rawText = "${key1}text${key2}";
|
||||||
QVERIFY( rawText.hasPlaceHolders() );
|
QVERIFY( rawText.hasPlaceHolders() );
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "val1textval2" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1textval2" ) );
|
||||||
|
|
||||||
rawText = "text1${key1}text2${key2}text3";
|
rawText = "text1${key1}text2${key2}text3";
|
||||||
QVERIFY( rawText.hasPlaceHolders() );
|
QVERIFY( rawText.hasPlaceHolders() );
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "text1val1text2val2text3" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "text1val1text2val2text3" ) );
|
||||||
|
|
||||||
rawText = "${key1}text${key2}${key3}";
|
rawText = "${key1}text${key2}${key3}";
|
||||||
QVERIFY( rawText.hasPlaceHolders() );
|
QVERIFY( rawText.hasPlaceHolders() );
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "val1textval2" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val1textval2" ) );
|
||||||
|
|
||||||
rawText = "${key2}${key3}${key1}";
|
rawText = "${key2}${key3}${key1}";
|
||||||
QVERIFY( rawText.hasPlaceHolders() );
|
QVERIFY( rawText.hasPlaceHolders() );
|
||||||
QCOMPARE( rawText.expand( &record ), QString( "val2val1" ) );
|
QCOMPARE( rawText.expand( &record, nullptr ), QString( "val2val1" ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ void TestSubstitutionField::simpleEvaluation()
|
|||||||
{
|
{
|
||||||
using namespace glabels;
|
using namespace glabels;
|
||||||
|
|
||||||
|
model::Variables variables;
|
||||||
|
|
||||||
model::SubstitutionField f1( "${1}" );
|
model::SubstitutionField f1( "${1}" );
|
||||||
model::SubstitutionField f2( "${2}" );
|
model::SubstitutionField f2( "${2}" );
|
||||||
model::SubstitutionField f3( "${3}" );
|
model::SubstitutionField f3( "${3}" );
|
||||||
@@ -150,10 +152,10 @@ void TestSubstitutionField::simpleEvaluation()
|
|||||||
record1[ "3" ] = "Opqrstu";
|
record1[ "3" ] = "Opqrstu";
|
||||||
record1[ "4" ] = "Vwxyz!@";
|
record1[ "4" ] = "Vwxyz!@";
|
||||||
|
|
||||||
QCOMPARE( f1.evaluate( &record1 ), QString( "Abcdefg" ) );
|
QCOMPARE( f1.evaluate( &record1, &variables ), QString( "Abcdefg" ) );
|
||||||
QCOMPARE( f2.evaluate( &record1 ), QString( "Hijklmn" ) );
|
QCOMPARE( f2.evaluate( &record1, &variables ), QString( "Hijklmn" ) );
|
||||||
QCOMPARE( f3.evaluate( &record1 ), QString( "Opqrstu" ) );
|
QCOMPARE( f3.evaluate( &record1, &variables ), QString( "Opqrstu" ) );
|
||||||
QCOMPARE( f4.evaluate( &record1 ), QString( "Vwxyz!@" ) );
|
QCOMPARE( f4.evaluate( &record1, &variables ), QString( "Vwxyz!@" ) );
|
||||||
|
|
||||||
merge::Record record2;
|
merge::Record record2;
|
||||||
record2[ "1" ] = "1234567";
|
record2[ "1" ] = "1234567";
|
||||||
@@ -161,10 +163,10 @@ void TestSubstitutionField::simpleEvaluation()
|
|||||||
record2[ "3" ] = "8901234";
|
record2[ "3" ] = "8901234";
|
||||||
record2[ "4" ] = "#$%^&*";
|
record2[ "4" ] = "#$%^&*";
|
||||||
|
|
||||||
QCOMPARE( f1.evaluate( &record2 ), QString( "1234567" ) );
|
QCOMPARE( f1.evaluate( &record2, &variables ), QString( "1234567" ) );
|
||||||
QCOMPARE( f2.evaluate( &record2 ), QString( "FooBar" ) );
|
QCOMPARE( f2.evaluate( &record2, &variables ), QString( "FooBar" ) );
|
||||||
QCOMPARE( f3.evaluate( &record2 ), QString( "8901234" ) );
|
QCOMPARE( f3.evaluate( &record2, &variables ), QString( "8901234" ) );
|
||||||
QCOMPARE( f4.evaluate( &record2 ), QString( "#$%^&*" ) );
|
QCOMPARE( f4.evaluate( &record2, &variables ), QString( "#$%^&*" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -172,6 +174,8 @@ void TestSubstitutionField::defaultValueEvaluation()
|
|||||||
{
|
{
|
||||||
using namespace glabels;
|
using namespace glabels;
|
||||||
|
|
||||||
|
model::Variables variables;
|
||||||
|
|
||||||
model::SubstitutionField f1( "${1:=foo1}" );
|
model::SubstitutionField f1( "${1:=foo1}" );
|
||||||
model::SubstitutionField f2( "${2:=foo2}" );
|
model::SubstitutionField f2( "${2:=foo2}" );
|
||||||
model::SubstitutionField f3( "${3:=foo3}" );
|
model::SubstitutionField f3( "${3:=foo3}" );
|
||||||
@@ -183,17 +187,17 @@ void TestSubstitutionField::defaultValueEvaluation()
|
|||||||
record1[ "3" ] = "Opqrstu";
|
record1[ "3" ] = "Opqrstu";
|
||||||
record1[ "4" ] = "Vwxyz!@";
|
record1[ "4" ] = "Vwxyz!@";
|
||||||
|
|
||||||
QCOMPARE( f1.evaluate( &record1 ), QString( "Abcdefg" ) );
|
QCOMPARE( f1.evaluate( &record1, &variables ), QString( "Abcdefg" ) );
|
||||||
QCOMPARE( f2.evaluate( &record1 ), QString( "Hijklmn" ) );
|
QCOMPARE( f2.evaluate( &record1, &variables ), QString( "Hijklmn" ) );
|
||||||
QCOMPARE( f3.evaluate( &record1 ), QString( "Opqrstu" ) );
|
QCOMPARE( f3.evaluate( &record1, &variables ), QString( "Opqrstu" ) );
|
||||||
QCOMPARE( f4.evaluate( &record1 ), QString( "Vwxyz!@" ) );
|
QCOMPARE( f4.evaluate( &record1, &variables ), QString( "Vwxyz!@" ) );
|
||||||
|
|
||||||
merge::Record record2; // All fields empty
|
merge::Record record2; // All fields empty
|
||||||
|
|
||||||
QCOMPARE( f1.evaluate( &record2 ), QString( "foo1" ) );
|
QCOMPARE( f1.evaluate( &record2, &variables ), QString( "foo1" ) );
|
||||||
QCOMPARE( f2.evaluate( &record2 ), QString( "foo2" ) );
|
QCOMPARE( f2.evaluate( &record2, &variables ), QString( "foo2" ) );
|
||||||
QCOMPARE( f3.evaluate( &record2 ), QString( "foo3" ) );
|
QCOMPARE( f3.evaluate( &record2, &variables ), QString( "foo3" ) );
|
||||||
QCOMPARE( f4.evaluate( &record2 ), QString( "foo4" ) );
|
QCOMPARE( f4.evaluate( &record2, &variables ), QString( "foo4" ) );
|
||||||
|
|
||||||
merge::Record record3;
|
merge::Record record3;
|
||||||
record3[ "1" ] = "xyzzy";
|
record3[ "1" ] = "xyzzy";
|
||||||
@@ -201,10 +205,10 @@ void TestSubstitutionField::defaultValueEvaluation()
|
|||||||
// Field "3" empty
|
// Field "3" empty
|
||||||
record3[ "4" ] = "plugh";
|
record3[ "4" ] = "plugh";
|
||||||
|
|
||||||
QCOMPARE( f1.evaluate( &record3 ), QString( "xyzzy" ) );
|
QCOMPARE( f1.evaluate( &record3, &variables ), QString( "xyzzy" ) );
|
||||||
QCOMPARE( f2.evaluate( &record3 ), QString( "foo2" ) );
|
QCOMPARE( f2.evaluate( &record3, &variables ), QString( "foo2" ) );
|
||||||
QCOMPARE( f3.evaluate( &record3 ), QString( "foo3" ) );
|
QCOMPARE( f3.evaluate( &record3, &variables ), QString( "foo3" ) );
|
||||||
QCOMPARE( f4.evaluate( &record3 ), QString( "plugh" ) );
|
QCOMPARE( f4.evaluate( &record3, &variables ), QString( "plugh" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -212,6 +216,8 @@ void TestSubstitutionField::formattedStringEvaluation()
|
|||||||
{
|
{
|
||||||
using namespace glabels;
|
using namespace glabels;
|
||||||
|
|
||||||
|
model::Variables variables;
|
||||||
|
|
||||||
model::SubstitutionField f1( "${1:%10s}" );
|
model::SubstitutionField f1( "${1:%10s}" );
|
||||||
model::SubstitutionField f2( "${2:%10s}" );
|
model::SubstitutionField f2( "${2:%10s}" );
|
||||||
model::SubstitutionField f3( "${3:%10s}" );
|
model::SubstitutionField f3( "${3:%10s}" );
|
||||||
@@ -233,15 +239,15 @@ void TestSubstitutionField::formattedStringEvaluation()
|
|||||||
record1[ "7" ] = "-100";
|
record1[ "7" ] = "-100";
|
||||||
record1[ "8" ] = "3.14";
|
record1[ "8" ] = "3.14";
|
||||||
|
|
||||||
QCOMPARE( f1.evaluate( &record1 ), QString( " 0" ) );
|
QCOMPARE( f1.evaluate( &record1, &variables ), QString( " 0" ) );
|
||||||
QCOMPARE( f2.evaluate( &record1 ), QString( " 1" ) );
|
QCOMPARE( f2.evaluate( &record1, &variables ), QString( " 1" ) );
|
||||||
QCOMPARE( f3.evaluate( &record1 ), QString( " -1" ) );
|
QCOMPARE( f3.evaluate( &record1, &variables ), QString( " -1" ) );
|
||||||
QCOMPARE( f4.evaluate( &record1 ), QString( " 3.14" ) );
|
QCOMPARE( f4.evaluate( &record1, &variables ), QString( " 3.14" ) );
|
||||||
|
|
||||||
QCOMPARE( f5.evaluate( &record1 ), QString( "0 " ) );
|
QCOMPARE( f5.evaluate( &record1, &variables ), QString( "0 " ) );
|
||||||
QCOMPARE( f6.evaluate( &record1 ), QString( "100 " ) );
|
QCOMPARE( f6.evaluate( &record1, &variables ), QString( "100 " ) );
|
||||||
QCOMPARE( f7.evaluate( &record1 ), QString( "-100 " ) );
|
QCOMPARE( f7.evaluate( &record1, &variables ), QString( "-100 " ) );
|
||||||
QCOMPARE( f8.evaluate( &record1 ), QString( "3.14 " ) );
|
QCOMPARE( f8.evaluate( &record1, &variables ), QString( "3.14 " ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -249,6 +255,8 @@ void TestSubstitutionField::formattedFloatEvaluation()
|
|||||||
{
|
{
|
||||||
using namespace glabels;
|
using namespace glabels;
|
||||||
|
|
||||||
|
model::Variables variables;
|
||||||
|
|
||||||
model::SubstitutionField f1( "${1:%+5.2f}" );
|
model::SubstitutionField f1( "${1:%+5.2f}" );
|
||||||
model::SubstitutionField f2( "${2:%+5.2f}" );
|
model::SubstitutionField f2( "${2:%+5.2f}" );
|
||||||
model::SubstitutionField f3( "${3:%+5.2f}" );
|
model::SubstitutionField f3( "${3:%+5.2f}" );
|
||||||
@@ -270,15 +278,15 @@ void TestSubstitutionField::formattedFloatEvaluation()
|
|||||||
record1[ "7" ] = "-100";
|
record1[ "7" ] = "-100";
|
||||||
record1[ "8" ] = "3.14";
|
record1[ "8" ] = "3.14";
|
||||||
|
|
||||||
QCOMPARE( f1.evaluate( &record1 ), QString( "+0.00" ) );
|
QCOMPARE( f1.evaluate( &record1, &variables ), QString( "+0.00" ) );
|
||||||
QCOMPARE( f2.evaluate( &record1 ), QString( "+1.00" ) );
|
QCOMPARE( f2.evaluate( &record1, &variables ), QString( "+1.00" ) );
|
||||||
QCOMPARE( f3.evaluate( &record1 ), QString( "-1.00" ) );
|
QCOMPARE( f3.evaluate( &record1, &variables ), QString( "-1.00" ) );
|
||||||
QCOMPARE( f4.evaluate( &record1 ), QString( "+3.14" ) );
|
QCOMPARE( f4.evaluate( &record1, &variables ), QString( "+3.14" ) );
|
||||||
|
|
||||||
QCOMPARE( f5.evaluate( &record1 ), QString( "+0.00e+00" ) );
|
QCOMPARE( f5.evaluate( &record1, &variables ), QString( "+0.00e+00" ) );
|
||||||
QCOMPARE( f6.evaluate( &record1 ), QString( "+1.00e+02" ) );
|
QCOMPARE( f6.evaluate( &record1, &variables ), QString( "+1.00e+02" ) );
|
||||||
QCOMPARE( f7.evaluate( &record1 ), QString( "-1.00e+02" ) );
|
QCOMPARE( f7.evaluate( &record1, &variables ), QString( "-1.00e+02" ) );
|
||||||
QCOMPARE( f8.evaluate( &record1 ), QString( "+3.14e+00" ) );
|
QCOMPARE( f8.evaluate( &record1, &variables ), QString( "+3.14e+00" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -286,6 +294,8 @@ void TestSubstitutionField::formattedIntEvaluation()
|
|||||||
{
|
{
|
||||||
using namespace glabels;
|
using namespace glabels;
|
||||||
|
|
||||||
|
model::Variables variables;
|
||||||
|
|
||||||
model::SubstitutionField f1( "${1:%08d}" );
|
model::SubstitutionField f1( "${1:%08d}" );
|
||||||
model::SubstitutionField f2( "${2:%08d}" );
|
model::SubstitutionField f2( "${2:%08d}" );
|
||||||
model::SubstitutionField f3( "${3:%08d}" );
|
model::SubstitutionField f3( "${3:%08d}" );
|
||||||
@@ -307,15 +317,15 @@ void TestSubstitutionField::formattedIntEvaluation()
|
|||||||
record1[ "7" ] = "-1";
|
record1[ "7" ] = "-1";
|
||||||
record1[ "8" ] = "314";
|
record1[ "8" ] = "314";
|
||||||
|
|
||||||
QCOMPARE( f1.evaluate( &record1 ), QString( "00000000" ) );
|
QCOMPARE( f1.evaluate( &record1, &variables ), QString( "00000000" ) );
|
||||||
QCOMPARE( f2.evaluate( &record1 ), QString( "00000001" ) );
|
QCOMPARE( f2.evaluate( &record1, &variables ), QString( "00000001" ) );
|
||||||
QCOMPARE( f3.evaluate( &record1 ), QString( "-0000001" ) );
|
QCOMPARE( f3.evaluate( &record1, &variables ), QString( "-0000001" ) );
|
||||||
QCOMPARE( f4.evaluate( &record1 ), QString( "00000000" ) ); // Invalid integer value
|
QCOMPARE( f4.evaluate( &record1, &variables ), QString( "00000000" ) ); // Invalid integer value
|
||||||
|
|
||||||
QCOMPARE( f5.evaluate( &record1 ), QString( "00000064" ) ); // 100(decimal) == 64(hex)
|
QCOMPARE( f5.evaluate( &record1, &variables ), QString( "00000064" ) ); // 100(decimal) == 64(hex)
|
||||||
QCOMPARE( f6.evaluate( &record1 ), QString( "00000100" ) );
|
QCOMPARE( f6.evaluate( &record1, &variables ), QString( "00000100" ) );
|
||||||
QCOMPARE( f7.evaluate( &record1 ), QString( "00000000" ) ); // Invalid unsigned integer
|
QCOMPARE( f7.evaluate( &record1, &variables ), QString( "00000000" ) ); // Invalid unsigned integer
|
||||||
QCOMPARE( f8.evaluate( &record1 ), QString( "0000013a" ) ); // 314(decimal) == 13a(hex)
|
QCOMPARE( f8.evaluate( &record1, &variables ), QString( "0000013a" ) ); // 314(decimal) == 13a(hex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -323,6 +333,8 @@ void TestSubstitutionField::newLineEvaluation()
|
|||||||
{
|
{
|
||||||
using namespace glabels;
|
using namespace glabels;
|
||||||
|
|
||||||
|
model::Variables variables;
|
||||||
|
|
||||||
model::SubstitutionField addr2( "${ADDR2:n}" );
|
model::SubstitutionField addr2( "${ADDR2:n}" );
|
||||||
QCOMPARE( addr2.fieldName(), QString( "ADDR2" ) );
|
QCOMPARE( addr2.fieldName(), QString( "ADDR2" ) );
|
||||||
QCOMPARE( addr2.newLine(), true );
|
QCOMPARE( addr2.newLine(), true );
|
||||||
@@ -336,7 +348,7 @@ void TestSubstitutionField::newLineEvaluation()
|
|||||||
merge::Record record3;
|
merge::Record record3;
|
||||||
// ADDR2 not defined
|
// ADDR2 not defined
|
||||||
|
|
||||||
QCOMPARE( addr2.evaluate( &record1 ), QString( "\nApt. 5B" ) ); // Prepends a newline
|
QCOMPARE( addr2.evaluate( &record1, &variables ), QString( "\nApt. 5B" ) ); // Prepends a newline
|
||||||
QCOMPARE( addr2.evaluate( &record2 ), QString( "" ) ); // Evaluates empty
|
QCOMPARE( addr2.evaluate( &record2, &variables ), QString( "" ) ); // Evaluates empty
|
||||||
QCOMPARE( addr2.evaluate( &record3 ), QString( "" ) ); // Evaluates empty
|
QCOMPARE( addr2.evaluate( &record3, &variables ), QString( "" ) ); // Evaluates empty
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,32 +42,24 @@ void TestTextNode::textNode()
|
|||||||
QCOMPARE( textNode.data(), QString( "" ) );
|
QCOMPARE( textNode.data(), QString( "" ) );
|
||||||
QVERIFY( textNode == TextNode() );
|
QVERIFY( textNode == TextNode() );
|
||||||
QVERIFY( !(textNode != TextNode()) );
|
QVERIFY( !(textNode != TextNode()) );
|
||||||
QCOMPARE( textNode.text( nullptr ), QString( "" ) );
|
QCOMPARE( textNode.text( nullptr, nullptr ), QString( "" ) );
|
||||||
QCOMPARE( textNode.text( &record ), QString( "" ) );
|
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||||
QVERIFY( !textNode.isEmptyField( nullptr ) );
|
|
||||||
QVERIFY( !textNode.isEmptyField( &record ) );
|
|
||||||
|
|
||||||
textNode.setField( true );
|
textNode.setField( true );
|
||||||
QVERIFY( textNode.isField() );
|
QVERIFY( textNode.isField() );
|
||||||
QCOMPARE( textNode.text( &record ), QString( "" ) );
|
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||||
QVERIFY( !textNode.isEmptyField( nullptr ) );
|
|
||||||
QVERIFY( !textNode.isEmptyField( &record ) );
|
|
||||||
|
|
||||||
textNode.setField( false );
|
textNode.setField( false );
|
||||||
QVERIFY( !textNode.isField() );
|
QVERIFY( !textNode.isField() );
|
||||||
|
|
||||||
textNode.setData( QString( "data1" ) );
|
textNode.setData( QString( "data1" ) );
|
||||||
QCOMPARE( textNode.data(), QString( "data1" ) );
|
QCOMPARE( textNode.data(), QString( "data1" ) );
|
||||||
QCOMPARE( textNode.text( nullptr ), QString( "data1" ) );
|
QCOMPARE( textNode.text( nullptr, nullptr ), QString( "data1" ) );
|
||||||
QCOMPARE( textNode.text( &record ), QString( "data1" ) );
|
QCOMPARE( textNode.text( &record, nullptr ), QString( "data1" ) );
|
||||||
QVERIFY( !textNode.isEmptyField( nullptr ) );
|
|
||||||
QVERIFY( !textNode.isEmptyField( &record ) );
|
|
||||||
|
|
||||||
textNode.setField( true );
|
textNode.setField( true );
|
||||||
QCOMPARE( textNode.text( nullptr ), QString( "${data1}" ) );
|
QCOMPARE( textNode.text( nullptr, nullptr ), QString( "" ) );
|
||||||
QCOMPARE( textNode.text( &record ), QString( "" ) );
|
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||||
QVERIFY( !textNode.isEmptyField( nullptr ) );
|
|
||||||
QVERIFY( !textNode.isEmptyField( &record ) );
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructors
|
/// Constructors
|
||||||
@@ -89,17 +81,11 @@ void TestTextNode::textNode()
|
|||||||
/// Record
|
/// Record
|
||||||
///
|
///
|
||||||
record["key1"] = "";
|
record["key1"] = "";
|
||||||
QCOMPARE( textNode.text( &record ), QString( "" ) );
|
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||||
QVERIFY( !textNode.isEmptyField( nullptr ) );
|
|
||||||
QVERIFY( !textNode.isEmptyField( &record ) );
|
|
||||||
|
|
||||||
textNode.setData( QString( "key1" ) );
|
textNode.setData( QString( "key1" ) );
|
||||||
QCOMPARE( textNode.text( &record ), QString( "" ) );
|
QCOMPARE( textNode.text( &record, nullptr ), QString( "" ) );
|
||||||
QVERIFY( !textNode.isEmptyField( nullptr ) );
|
|
||||||
QVERIFY( textNode.isEmptyField( &record ) );
|
|
||||||
|
|
||||||
record["key1"] = "val1";
|
record["key1"] = "val1";
|
||||||
QCOMPARE( textNode.text( &record ), QString( "val1" ) );
|
QCOMPARE( textNode.text( &record, nullptr ), QString( "val1" ) );
|
||||||
QVERIFY( !textNode.isEmptyField( nullptr ) );
|
|
||||||
QVERIFY( !textNode.isEmptyField( &record ) );
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "barcode/Backends.h"
|
#include "barcode/Backends.h"
|
||||||
#include "model/ColorNode.h"
|
#include "model/ColorNode.h"
|
||||||
|
#include "model/Model.h"
|
||||||
#include "model/Size.h"
|
#include "model/Size.h"
|
||||||
|
|
||||||
#include "model/ModelBarcodeObject.h"
|
#include "model/ModelBarcodeObject.h"
|
||||||
@@ -55,15 +56,16 @@ void TestXmlLabel::serializeDeserialize()
|
|||||||
//
|
//
|
||||||
// Empty object list
|
// Empty object list
|
||||||
//
|
//
|
||||||
|
Model* model = new Model();
|
||||||
QList<ModelObject*> objects, outObjects;
|
QList<ModelObject*> objects, outObjects;
|
||||||
QByteArray buffer, outBuffer;
|
QByteArray buffer, outBuffer;
|
||||||
|
|
||||||
QCOMPARE( objects.count(), 0 );
|
QCOMPARE( objects.count(), 0 );
|
||||||
XmlLabelCreator::serializeObjects( objects, buffer );
|
XmlLabelCreator::serializeObjects( objects, model, buffer );
|
||||||
outObjects = XmlLabelParser::deserializeObjects( buffer );
|
outObjects = XmlLabelParser::deserializeObjects( buffer, model );
|
||||||
QCOMPARE( objects.count(), outObjects.count() );
|
QCOMPARE( objects.count(), outObjects.count() );
|
||||||
QCOMPARE( objects, outObjects );
|
QCOMPARE( objects, outObjects );
|
||||||
XmlLabelCreator::serializeObjects( outObjects, outBuffer );
|
XmlLabelCreator::serializeObjects( outObjects, model, outBuffer );
|
||||||
QCOMPARE( buffer, outBuffer );
|
QCOMPARE( buffer, outBuffer );
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -90,10 +92,13 @@ void TestXmlLabel::serializeDeserialize()
|
|||||||
QCOMPARE( objects.count(), 10 );
|
QCOMPARE( objects.count(), 10 );
|
||||||
|
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
XmlLabelCreator::serializeObjects( objects, buffer );
|
XmlLabelCreator::serializeObjects( objects, model, buffer );
|
||||||
outObjects = XmlLabelParser::deserializeObjects( buffer );
|
outObjects = XmlLabelParser::deserializeObjects( buffer, model );
|
||||||
QCOMPARE( objects.count(), outObjects.count() );
|
QCOMPARE( objects.count(), outObjects.count() );
|
||||||
|
|
||||||
|
QString currentPath = QDir::currentPath();
|
||||||
|
currentPath.append( QDir::separator() );
|
||||||
|
|
||||||
for ( int i = 0; i < objects.count(); i++ )
|
for ( int i = 0; i < objects.count(); i++ )
|
||||||
{
|
{
|
||||||
qDebug() << "object" << i;
|
qDebug() << "object" << i;
|
||||||
@@ -128,7 +133,18 @@ void TestXmlLabel::serializeDeserialize()
|
|||||||
QCOMPARE( objects.at(i)->textLineSpacing(), outObjects.at(i)->textLineSpacing() );
|
QCOMPARE( objects.at(i)->textLineSpacing(), outObjects.at(i)->textLineSpacing() );
|
||||||
QCOMPARE( objects.at(i)->textAutoShrink(), outObjects.at(i)->textAutoShrink() );
|
QCOMPARE( objects.at(i)->textAutoShrink(), outObjects.at(i)->textAutoShrink() );
|
||||||
|
|
||||||
QVERIFY( objects.at(i)->filenameNode() == outObjects.at(i)->filenameNode() );
|
QCOMPARE( objects.at(i)->filenameNode().isField(), outObjects.at(i)->filenameNode().isField() );
|
||||||
|
QCOMPARE( objects.at(i)->filenameNode().data().isEmpty(), outObjects.at(i)->filenameNode().data().isEmpty() );
|
||||||
|
if ( objects.at(i)->filenameNode().data().isEmpty() || objects.at(i)->filenameNode().isField() || (!objects.at(i)->image() && objects.at(i)->svg().isEmpty()) )
|
||||||
|
{
|
||||||
|
QVERIFY( objects.at(i)->filenameNode() == outObjects.at(i)->filenameNode() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QVERIFY( objects.at(i)->filenameNode() != outObjects.at(i)->filenameNode() );
|
||||||
|
QCOMPARE( currentPath + objects.at(i)->filenameNode().data(), outObjects.at(i)->filenameNode().data() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( objects.at(i)->image() )
|
if ( objects.at(i)->image() )
|
||||||
{
|
{
|
||||||
QCOMPARE( *(objects.at(i)->image()), *(outObjects.at(i)->image()) );
|
QCOMPARE( *(objects.at(i)->image()), *(outObjects.at(i)->image()) );
|
||||||
@@ -157,6 +173,6 @@ void TestXmlLabel::serializeDeserialize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
outBuffer.clear();
|
outBuffer.clear();
|
||||||
XmlLabelCreator::serializeObjects( outObjects, outBuffer );
|
XmlLabelCreator::serializeObjects( outObjects, model, outBuffer );
|
||||||
QCOMPARE( buffer, outBuffer );
|
QCOMPARE( buffer, outBuffer );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,10 @@
|
|||||||
iec16022)"
|
iec16022)"
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!-- Variable related enumerations/types -->
|
||||||
|
<!ENTITY % VARIABLE_TYPE_TYPE "(numeric | string)">
|
||||||
|
<!ENTITY % VARIABLE_INC_TYPE "(never | per_copy | per_merge_record | per_page )">
|
||||||
|
|
||||||
<!-- Data encoding method -->
|
<!-- Data encoding method -->
|
||||||
<!ENTITY % DATA_ENCODING_TYPE "(cdata | base64)">
|
<!ENTITY % DATA_ENCODING_TYPE "(cdata | base64)">
|
||||||
|
|
||||||
@@ -139,7 +143,7 @@
|
|||||||
<!-- Top-level glabels document -->
|
<!-- Top-level glabels document -->
|
||||||
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
||||||
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
||||||
<!ELEMENT Glabels-document (Template, Objects+, Merge?, Data*)>
|
<!ELEMENT Glabels-document (Template, Objects+, Merge?, Variables?, Data*)>
|
||||||
<!ATTLIST Glabels-document
|
<!ATTLIST Glabels-document
|
||||||
xmlns %STRING_TYPE; #IMPLIED
|
xmlns %STRING_TYPE; #IMPLIED
|
||||||
version %STRING_TYPE; #IMPLIED
|
version %STRING_TYPE; #IMPLIED
|
||||||
@@ -441,6 +445,20 @@
|
|||||||
src %STRING_TYPE; #IMPLIED
|
src %STRING_TYPE; #IMPLIED
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
||||||
|
<!-- Variables Section -->
|
||||||
|
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
||||||
|
<!ELEMENT Variables (Variable*)>
|
||||||
|
|
||||||
|
<!ELEMENT Variable EMPTY>
|
||||||
|
<!ATTLIST Variable
|
||||||
|
type %VARIABLE_TYPE_TYPE; #REQUIRED
|
||||||
|
name %STRING_TYPE; #REQUIRED
|
||||||
|
value %STRING_TYPE; #REQUIRED
|
||||||
|
increment %VARIABLE_INC_TYPE; #REQUIRED
|
||||||
|
stepSize %STRING_TYPE; #REQUIRED
|
||||||
|
>
|
||||||
|
|
||||||
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
||||||
<!-- Data Section -->
|
<!-- Data Section -->
|
||||||
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
||||||
|
|||||||
+264
-167
@@ -178,6 +178,37 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>EditVariableDialog</name>
|
||||||
|
<message>
|
||||||
|
<source>Dialog</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Name:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Step size:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Increment</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Variable</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Type:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Value:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>Factory</name>
|
<name>Factory</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -251,18 +282,10 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MergeView</name>
|
<name>MergeView</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Source</source>
|
<source>Source</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Location</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Format:</source>
|
<source>Format:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -283,11 +306,15 @@
|
|||||||
<source>Unselect all</source>
|
<source>Unselect all</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Browse...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>ObjectEditor</name>
|
<name>ObjectEditor</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Form</source>
|
<source>Object properties</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
@@ -314,6 +341,14 @@
|
|||||||
<source>Word</source>
|
<source>Word</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Anywhere</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>None</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Allow printing to shrink text to fit object</source>
|
<source>Allow printing to shrink text to fit object</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -375,23 +410,7 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>None</source>
|
<source>Browse...</source>
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Anywhere</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Select File...</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>or</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Select Merge Field...</source>
|
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
@@ -470,10 +489,6 @@
|
|||||||
<source>Opacity:</source>
|
<source>Opacity:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Object properties</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PreferencesDialog</name>
|
<name>PreferencesDialog</name>
|
||||||
@@ -516,22 +531,6 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PrintView</name>
|
<name>PrintView</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Page</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>of</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>nn</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Copies</source>
|
<source>Copies</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -568,13 +567,21 @@
|
|||||||
<source>Print</source>
|
<source>Print</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Page</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>of</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>nn</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PropertiesView</name>
|
<name>PropertiesView</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Product</source>
|
<source>Product</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -615,6 +622,14 @@
|
|||||||
<source>Change product</source>
|
<source>Change product</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Adjustable Parameters</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Label length:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Orientation</source>
|
<source>Orientation</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -635,14 +650,6 @@
|
|||||||
<source>Similar Products</source>
|
<source>Similar Products</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Adjustable Parameters</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Label length:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>ReportBugDialog</name>
|
<name>ReportBugDialog</name>
|
||||||
@@ -724,10 +731,6 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>StartupView</name>
|
<name>StartupView</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Welcome to gLabels. Let's get started:</source>
|
<source>Welcome to gLabels. Let's get started:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -751,10 +754,6 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerApplyPage</name>
|
<name>TemplateDesignerApplyPage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>You have completed the gLabels Product Template Designer. If you wish to accept and save your product template, click "Save."</source>
|
<source>You have completed the gLabels Product Template Designer. If you wish to accept and save your product template, click "Save."</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -767,7 +766,11 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerCdPage</name>
|
<name>TemplateDesignerCdPage</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Form</source>
|
<source>6. Margin:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>1. Outer radius:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
@@ -779,28 +782,16 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>1. Outer radius:</source>
|
<source>3. Clipping width:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>5. Waste:</source>
|
<source>5. Waste:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>3. Clipping width:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>6. Margin:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerContinuousPage</name>
|
<name>TemplateDesignerContinuousPage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source><html><head/><body><p>Click &quot;Cancel&quot; to quit, or click &quot;Back&quot; to begin with a different product.</p></body></html></source>
|
<source><html><head/><body><p>Click &quot;Cancel&quot; to quit, or click &quot;Back&quot; to begin with a different product.</p></body></html></source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -808,14 +799,6 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerEllipsePage</name>
|
<name>TemplateDesignerEllipsePage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>3. Waste:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>2. Height:</source>
|
<source>2. Height:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -824,6 +807,10 @@
|
|||||||
<source>1. Width:</source>
|
<source>1. Width:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>3. Waste:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>4. Margin:</source>
|
<source>4. Margin:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -831,10 +818,6 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerIntroPage</name>
|
<name>TemplateDesignerIntroPage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source><html><head/><body><p>This dialog will help you create a custom product template. Let's get started:</p></body></html></source>
|
<source><html><head/><body><p>This dialog will help you create a custom product template. Let's get started:</p></body></html></source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -858,10 +841,6 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerNLayoutsPage</name>
|
<name>TemplateDesignerNLayoutsPage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>A layout is a set of labels or cards that can be arranged in a simple grid. Most products only need one layout, as in the first example below. The second example illustrates when two layouts are needed.</source>
|
<source>A layout is a set of labels or cards that can be arranged in a simple grid. Most products only need one layout, as in the first example below. The second example illustrates when two layouts are needed.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -890,40 +869,32 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerNamePage</name>
|
<name>TemplateDesignerNamePage</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Form</source>
|
<source>(e.g. "Mailing Labels," "Business Cards," ...)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Brand:</source>
|
<source>Brand:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>(e.g. Avery, Acme, ...)</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Part #:</source>
|
<source>Part #:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>(e.g. 8163A)</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Description:</source>
|
<source>Description:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>(e.g. "Mailing Labels," "Business Cards," ...)</source>
|
<source>(e.g. 8163A)</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>(e.g. Avery, Acme, ...)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerOneLayoutPage</name>
|
<name>TemplateDesignerOneLayoutPage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Number across (nx):</source>
|
<source>Number across (nx):</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -956,15 +927,7 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerPageSizePage</name>
|
<name>TemplateDesignerPageSizePage</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Form</source>
|
<source>Roll width:</source>
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Page size:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Width:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
@@ -972,16 +935,16 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Roll width:</source>
|
<source>Width:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Page size:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerPathPage</name>
|
<name>TemplateDesignerPathPage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source><html><head/><body><p>Click &quot;Cancel&quot; to quit, or click &quot;Back&quot; to begin with a different product.</p></body></html></source>
|
<source><html><head/><body><p>Click &quot;Cancel&quot; to quit, or click &quot;Back&quot; to begin with a different product.</p></body></html></source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -990,15 +953,7 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerRectPage</name>
|
<name>TemplateDesignerRectPage</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Form</source>
|
<source>4. Horizontal waste:</source>
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>1. Width:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>2. Height:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
@@ -1006,13 +961,17 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>4. Horizontal waste:</source>
|
<source>1. Width:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>5. Vertical waste:</source>
|
<source>5. Vertical waste:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>2. Height:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>6. Margin (X):</source>
|
<source>6. Margin (X):</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -1029,11 +988,7 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerRoundPage</name>
|
<name>TemplateDesignerRoundPage</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Form</source>
|
<source>3. Margin</source>
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>2. Waste:</source>
|
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
@@ -1041,16 +996,12 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>3. Margin</source>
|
<source>2. Waste:</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerShapePage</name>
|
<name>TemplateDesignerShapePage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Rectangular or square (can have rounded corners)</source>
|
<source>Rectangular or square (can have rounded corners)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -1070,10 +1021,6 @@
|
|||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>TemplateDesignerTwoLayoutPage</name>
|
<name>TemplateDesignerTwoLayoutPage</name>
|
||||||
<message>
|
|
||||||
<source>Form</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Distance from left edge (x0):</source>
|
<source>Distance from left edge (x0):</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -1126,6 +1073,68 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>Variable</name>
|
||||||
|
<message>
|
||||||
|
<source>String</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Integer</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Floating Point</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Never</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Per item</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Per copy</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Per page</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Color</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>VariablesView</name>
|
||||||
|
<message>
|
||||||
|
<source><html><head/><body><p>Add variable</p></body></html></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Add</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><html><head/><body><p>Edit selected variable</p></body></html></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Edit</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><html><head/><body><p>Delete selected variable</p></body></html></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Delete</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>glabels::AboutDialog</name>
|
<name>glabels::AboutDialog</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -1145,14 +1154,25 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>glabels::ColorHistory</name>
|
||||||
|
<message>
|
||||||
|
<source>color %1</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>glabels::ColorPaletteDialog</name>
|
<name>glabels::ColorPaletteDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Custom color...</source>
|
<source>Standard Colors</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Merge key...</source>
|
<source>Recent Colors</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Custom color...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
@@ -1160,7 +1180,30 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Custom color #%1</source>
|
<source>Custom Color %1</source>
|
||||||
|
<extracomment>%1 = color specification in hex. String must not contain a colon (:).</extracomment>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Use substitution field</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>glabels::EditVariableDialog</name>
|
||||||
|
<message>
|
||||||
|
<source>Default</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>glabels::FieldButton</name>
|
||||||
|
<message>
|
||||||
|
<source>Merge fields</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Variables</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
@@ -1220,6 +1263,10 @@
|
|||||||
<source>Welcome</source>
|
<source>Welcome</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Edit</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Properties</source>
|
<source>Properties</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -1229,11 +1276,11 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Print</source>
|
<source>Variables</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Edit</source>
|
<source>Print</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
@@ -1292,6 +1339,14 @@
|
|||||||
<source>Select project Merge mode</source>
|
<source>Select project Merge mode</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>&Variables</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Select project Variables mode</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>&Print</source>
|
<source>&Print</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -1782,14 +1837,6 @@
|
|||||||
<source>Default</source>
|
<source>Default</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Insert Field</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Key</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Original size</source>
|
<source>Original size</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -1934,6 +1981,14 @@
|
|||||||
<source>Reset</source>
|
<source>Reset</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Insert substitution field</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Use substitution field</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>glabels::PrintView</name>
|
<name>glabels::PrintView</name>
|
||||||
@@ -2002,11 +2057,11 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Copy</source>
|
<source>Roll</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Roll</source>
|
<source>Copy</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
@@ -2184,6 +2239,41 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>glabels::VariablesView</name>
|
||||||
|
<message>
|
||||||
|
<source>Variables</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Name</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Type</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Increment</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Step Size</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Add Variable</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Edit Variable</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Value</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>glabels::barcode::Backends</name>
|
<name>glabels::barcode::Backends</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -2322,6 +2412,10 @@
|
|||||||
<source>IEC18004 (QRCode)</source>
|
<source>IEC18004 (QRCode)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Australia Post Standard</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Australia Post Reply Paid</source>
|
<source>Australia Post Reply Paid</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -2374,10 +2468,6 @@
|
|||||||
<source>Code 49</source>
|
<source>Code 49</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Australia Post Standard</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Code 128 (Mode C suppression)</source>
|
<source>Code 128 (Mode C suppression)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
@@ -2565,6 +2655,13 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>glabels::model::ModelImageObject</name>
|
||||||
|
<message>
|
||||||
|
<source>No image</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>glabels::model::ModelTextObject</name>
|
<name>glabels::model::ModelTextObject</name>
|
||||||
<message>
|
<message>
|
||||||
|
|||||||
Reference in New Issue
Block a user