From b9b792272c4c12aa6709401b92e5127ee1ed4bd8 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 8 Dec 2018 12:53:04 -0500 Subject: [PATCH 01/55] Created placeholder for Variables page in UI. --- glabels/CMakeLists.txt | 3 + glabels/Icons.h | 10 + glabels/MainWindow.cpp | 54 ++++- glabels/MainWindow.h | 7 + glabels/VariablesView.cpp | 62 +++++ glabels/VariablesView.h | 83 +++++++ glabels/icons.qrc | 1 + .../icons/flat/48x48/glabels-variables.svg | 15 ++ glabels/ui/MergeView.ui | 13 +- glabels/ui/ObjectEditor.ui | 4 +- glabels/ui/PrintView.ui | 2 +- glabels/ui/PropertiesView.ui | 2 +- glabels/ui/StartupView.ui | 2 +- glabels/ui/TemplateDesignerApplyPage.ui | 2 +- glabels/ui/TemplateDesignerCdPage.ui | 2 +- glabels/ui/TemplateDesignerContinuousPage.ui | 2 +- glabels/ui/TemplateDesignerEllipsePage.ui | 2 +- glabels/ui/TemplateDesignerIntroPage.ui | 2 +- glabels/ui/TemplateDesignerNLayoutsPage.ui | 2 +- glabels/ui/TemplateDesignerNamePage.ui | 2 +- glabels/ui/TemplateDesignerOneLayoutPage.ui | 2 +- glabels/ui/TemplateDesignerPageSizePage.ui | 2 +- glabels/ui/TemplateDesignerPathPage.ui | 2 +- glabels/ui/TemplateDesignerRectPage.ui | 2 +- glabels/ui/TemplateDesignerRoundPage.ui | 2 +- glabels/ui/TemplateDesignerShapePage.ui | 2 +- glabels/ui/TemplateDesignerTwoLayoutPage.ui | 2 +- glabels/ui/VariablesView.ui | 69 ++++++ translations/glabels_C.ts | 229 +++++++----------- 29 files changed, 418 insertions(+), 166 deletions(-) create mode 100644 glabels/VariablesView.cpp create mode 100644 glabels/VariablesView.h create mode 100644 glabels/icons/flat/48x48/glabels-variables.svg create mode 100644 glabels/ui/VariablesView.ui diff --git a/glabels/CMakeLists.txt b/glabels/CMakeLists.txt index 41305c0..715d63d 100644 --- a/glabels/CMakeLists.txt +++ b/glabels/CMakeLists.txt @@ -39,6 +39,7 @@ set (glabels_sources TemplatePicker.cpp TemplatePickerItem.cpp UndoRedoModel.cpp + VariablesView.cpp ) set (glabels_qobject_headers @@ -67,6 +68,7 @@ set (glabels_qobject_headers TemplateDesigner.h TemplatePicker.h UndoRedoModel.h + VariablesView.h ) set (glabels_forms @@ -92,6 +94,7 @@ set (glabels_forms ui/TemplateDesignerOneLayoutPage.ui ui/TemplateDesignerTwoLayoutPage.ui ui/TemplateDesignerApplyPage.ui + ui/VariablesView.ui ) set (glabels_resource_files diff --git a/glabels/Icons.h b/glabels/Icons.h index 5f02ed2..37dd081 100644 --- a/glabels/Icons.h +++ b/glabels/Icons.h @@ -473,6 +473,16 @@ namespace glabels }; + class Variables : public QIcon + { + public: + Variables() + { + addPixmap( QPixmap( ":icons/flat/48x48/glabels-variables.svg" ) ); + } + }; + + class ZoomBestFit : public QIcon { public: diff --git a/glabels/MainWindow.cpp b/glabels/MainWindow.cpp index 2dcbdaf..4d39842 100644 --- a/glabels/MainWindow.cpp +++ b/glabels/MainWindow.cpp @@ -31,6 +31,7 @@ #include "PropertiesView.h" #include "StartupView.h" #include "UndoRedoModel.h" +#include "VariablesView.h" #include "model/Db.h" #include "model/Model.h" @@ -51,7 +52,8 @@ namespace EDITOR_PAGE_INDEX = 1, PROPERTIES_PAGE_INDEX = 2, 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* propertiesPage = createPropertiesPage(); QWidget* mergePage = createMergePage(); + QWidget* variablesPage = createVariablesPage(); QWidget* printPage = createPrintPage(); // Table of contents widget @@ -141,6 +144,18 @@ namespace glabels mMergeAction = mContents->addWidget( 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 mPages->addWidget( printPage ); mPrintButton = new QToolButton( this ); @@ -175,6 +190,7 @@ namespace glabels connect( mEditorButton, 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( mVariablesButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool))); connect( mPrintButton, SIGNAL(toggled(bool)), this, SLOT(changePage(bool))); connect( mLabelEditor, SIGNAL(zoomChanged()), this, SLOT(onZoomChanged()) ); connect( QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardChanged()) ); @@ -217,7 +233,8 @@ namespace glabels mPropertiesView->setModel( mModel, mUndoRedoModel ); mLabelEditor->setModel( mModel, mUndoRedoModel ); mObjectEditor->setModel( mModel, mUndoRedoModel ); - mMergeView->setModel( mModel , mUndoRedoModel ); + mMergeView->setModel( mModel, mUndoRedoModel ); + mVariablesView->setModel( mModel, mUndoRedoModel ); mPrintView->setModel( mModel ); mEditorButton->setChecked( true ); @@ -306,6 +323,11 @@ namespace glabels fileShowMergePageAction->setStatusTip( tr("Select project Merge mode") ); connect( fileShowMergePageAction, SIGNAL(triggered()), this, SLOT(fileShowMergePage()) ); + fileShowVariablesPageAction = new QAction( tr("&Variables") , this ); + fileShowVariablesPageAction->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_4 ) ); + fileShowVariablesPageAction->setStatusTip( tr("Select project Variables mode") ); + connect( fileShowVariablesPageAction, SIGNAL(triggered()), this, SLOT(fileShowVariablesPage()) ); + fileShowPrintPageAction = new QAction( tr("&Print") , this ); fileShowPrintPageAction->setShortcut( QKeySequence::Print ); fileShowPrintPageAction->setStatusTip( tr("Select project Print mode") ); @@ -585,6 +607,7 @@ namespace glabels fileMenu->addAction( fileShowEditorPageAction ); fileMenu->addAction( fileShowPropertiesPageAction ); fileMenu->addAction( fileShowMergePageAction ); + fileMenu->addAction( fileShowVariablesPageAction ); fileMenu->addAction( fileShowPrintPageAction ); fileMenu->addSeparator(); fileMenu->addAction( fileTemplateDesignerAction ); @@ -795,6 +818,17 @@ namespace glabels } + /// + /// Create Variables Page + /// + QWidget* MainWindow::createVariablesPage() + { + mVariablesView = new VariablesView(); + + return mVariablesView; + } + + /// /// Create Print Page /// @@ -819,6 +853,7 @@ namespace glabels bool isEditorPage = mEditorButton->isChecked(); bool isPropertiesPage = mPropertiesButton->isChecked(); bool isMergePage = mMergeButton->isChecked(); + bool isVariablesPage = mVariablesButton->isChecked(); bool isPrintPage = mPrintButton->isChecked(); // What is the current selection state? @@ -831,6 +866,7 @@ namespace glabels mEditorAction->setVisible( !isWelcomePage ); mPropertiesAction->setVisible( !isWelcomePage ); mMergeAction->setVisible( !isWelcomePage ); + mVariablesAction->setVisible( !isWelcomePage ); mPrintAction->setVisible( !isWelcomePage ); // File actions @@ -841,6 +877,7 @@ namespace glabels fileShowEditorPageAction->setEnabled( !isWelcomePage && !isEditorPage ); fileShowPropertiesPageAction->setEnabled( !isWelcomePage && !isPropertiesPage ); fileShowMergePageAction->setEnabled( !isWelcomePage && !isMergePage ); + fileShowVariablesPageAction->setEnabled( !isWelcomePage && !isVariablesPage ); fileShowPrintPageAction->setEnabled( !isWelcomePage && !isPrintPage ); fileTemplateDesignerAction->setEnabled( true ); fileCloseAction->setEnabled( true ); @@ -1036,6 +1073,10 @@ namespace glabels { mPages->setCurrentIndex( MERGE_PAGE_INDEX ); } + else if ( mVariablesButton->isChecked() ) + { + mPages->setCurrentIndex( VARIABLES_PAGE_INDEX ); + } else if ( mPrintButton->isChecked() ) { mPages->setCurrentIndex( PRINT_PAGE_INDEX ); @@ -1118,6 +1159,15 @@ namespace glabels } + /// + /// File->Show Variables Page + /// + void MainWindow::fileShowVariablesPage() + { + mVariablesButton->setChecked( true ); + } + + /// /// File->Show Print Page /// diff --git a/glabels/MainWindow.h b/glabels/MainWindow.h index 6166173..268a161 100644 --- a/glabels/MainWindow.h +++ b/glabels/MainWindow.h @@ -47,6 +47,7 @@ namespace glabels class PropertiesView; class StartupView; class UndoRedoModel; + class VariablesView; /// @@ -96,6 +97,7 @@ namespace glabels void fileShowEditorPage(); void fileShowPropertiesPage(); void fileShowMergePage(); + void fileShowVariablesPage(); void fileShowPrintPage(); void fileTemplateDesigner(); void fileClose(); @@ -171,6 +173,7 @@ namespace glabels QWidget* createEditorPage(); QWidget* createPropertiesPage(); QWidget* createMergePage(); + QWidget* createVariablesPage(); QWidget* createPrintPage(); void manageActions(); @@ -217,12 +220,14 @@ namespace glabels QToolButton* mEditorButton; QToolButton* mPropertiesButton; QToolButton* mMergeButton; + QToolButton* mVariablesButton; QToolButton* mPrintButton; QAction* mWelcomeAction; QAction* mEditorAction; QAction* mPropertiesAction; QAction* mMergeAction; + QAction* mVariablesAction; QAction* mPrintAction; QStackedWidget* mPages; @@ -232,6 +237,7 @@ namespace glabels ObjectEditor* mObjectEditor; PropertiesView* mPropertiesView; MergeView* mMergeView; + VariablesView* mVariablesView; PrintView* mPrintView; QLabel* zoomInfoLabel; @@ -244,6 +250,7 @@ namespace glabels QAction* fileShowEditorPageAction; QAction* fileShowPropertiesPageAction; QAction* fileShowMergePageAction; + QAction* fileShowVariablesPageAction; QAction* fileShowPrintPageAction; QAction* fileTemplateDesignerAction; QAction* fileCloseAction; diff --git a/glabels/VariablesView.cpp b/glabels/VariablesView.cpp new file mode 100644 index 0000000..7505d12 --- /dev/null +++ b/glabels/VariablesView.cpp @@ -0,0 +1,62 @@ +/* VariablesView.cpp + * + * Copyright (C) 2016 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#include "VariablesView.h" + +#include + + +namespace glabels +{ + + /// + /// Constructor + /// + VariablesView::VariablesView( QWidget *parent ) + : QWidget(parent), mModel(nullptr), mUndoRedoModel(nullptr) + { + setupUi( this ); + + titleLabel->setText( QString( "%1" ).arg( tr("Variables") ) ); + } + + + /// + /// Destructor + /// + VariablesView::~VariablesView() + { + // empty + } + + + /// + /// Set Model + /// + void VariablesView::setModel( model::Model* model, UndoRedoModel* undoRedoModel ) + { + mModel = model; + mUndoRedoModel = undoRedoModel; + + //connect( mModel, SIGNAL(variablesChanged()), this, SLOT(onVariablesChanged()) ); + } + + +} // namespace glabels diff --git a/glabels/VariablesView.h b/glabels/VariablesView.h new file mode 100644 index 0000000..e045dd4 --- /dev/null +++ b/glabels/VariablesView.h @@ -0,0 +1,83 @@ +/* VariablesView.h + * + * Copyright (C) 2016 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#ifndef 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: + + + ///////////////////////////////// + // Private methods + ///////////////////////////////// + private: + + + ///////////////////////////////// + // Private Data + ///////////////////////////////// + private: + model::Model* mModel; + UndoRedoModel* mUndoRedoModel; + + }; + +} + + +#endif // VariablesView_h diff --git a/glabels/icons.qrc b/glabels/icons.qrc index 8d4f777..faa0f30 100644 --- a/glabels/icons.qrc +++ b/glabels/icons.qrc @@ -102,6 +102,7 @@ icons/flat/48x48/glabels-merge.svg icons/flat/48x48/glabels-print.svg icons/flat/48x48/glabels-properties.svg + icons/flat/48x48/glabels-variables.svg icons/apps/48x48/glabels.svg icons/apps/128x128/glabels.svg diff --git a/glabels/icons/flat/48x48/glabels-variables.svg b/glabels/icons/flat/48x48/glabels-variables.svg new file mode 100644 index 0000000..9b47813 --- /dev/null +++ b/glabels/icons/flat/48x48/glabels-variables.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/glabels/ui/MergeView.ui b/glabels/ui/MergeView.ui index e73b77a..e29278c 100644 --- a/glabels/ui/MergeView.ui +++ b/glabels/ui/MergeView.ui @@ -11,12 +11,21 @@ - Form + Form - + + 12 + + + 12 + + + 12 + + 12 diff --git a/glabels/ui/ObjectEditor.ui b/glabels/ui/ObjectEditor.ui index 3e0589e..0493a38 100644 --- a/glabels/ui/ObjectEditor.ui +++ b/glabels/ui/ObjectEditor.ui @@ -7,7 +7,7 @@ 0 0 400 - 640 + 648 @@ -29,7 +29,7 @@ - Form + Form diff --git a/glabels/ui/PrintView.ui b/glabels/ui/PrintView.ui index d4ea498..ac76237 100644 --- a/glabels/ui/PrintView.ui +++ b/glabels/ui/PrintView.ui @@ -17,7 +17,7 @@ - Form + Form diff --git a/glabels/ui/PropertiesView.ui b/glabels/ui/PropertiesView.ui index 60c0632..0f27550 100644 --- a/glabels/ui/PropertiesView.ui +++ b/glabels/ui/PropertiesView.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/StartupView.ui b/glabels/ui/StartupView.ui index 246e5c0..0aca3cb 100644 --- a/glabels/ui/StartupView.ui +++ b/glabels/ui/StartupView.ui @@ -11,7 +11,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerApplyPage.ui b/glabels/ui/TemplateDesignerApplyPage.ui index d0ed63b..3b1b913 100644 --- a/glabels/ui/TemplateDesignerApplyPage.ui +++ b/glabels/ui/TemplateDesignerApplyPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerCdPage.ui b/glabels/ui/TemplateDesignerCdPage.ui index f61fa31..a9add20 100644 --- a/glabels/ui/TemplateDesignerCdPage.ui +++ b/glabels/ui/TemplateDesignerCdPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerContinuousPage.ui b/glabels/ui/TemplateDesignerContinuousPage.ui index 8960aa6..d3cc112 100644 --- a/glabels/ui/TemplateDesignerContinuousPage.ui +++ b/glabels/ui/TemplateDesignerContinuousPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerEllipsePage.ui b/glabels/ui/TemplateDesignerEllipsePage.ui index 53dec92..0ea9ee5 100644 --- a/glabels/ui/TemplateDesignerEllipsePage.ui +++ b/glabels/ui/TemplateDesignerEllipsePage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerIntroPage.ui b/glabels/ui/TemplateDesignerIntroPage.ui index 90665ff..9b397cb 100644 --- a/glabels/ui/TemplateDesignerIntroPage.ui +++ b/glabels/ui/TemplateDesignerIntroPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerNLayoutsPage.ui b/glabels/ui/TemplateDesignerNLayoutsPage.ui index df42ffd..e88dd2f 100644 --- a/glabels/ui/TemplateDesignerNLayoutsPage.ui +++ b/glabels/ui/TemplateDesignerNLayoutsPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerNamePage.ui b/glabels/ui/TemplateDesignerNamePage.ui index 9bf0d13..a9ed4d7 100644 --- a/glabels/ui/TemplateDesignerNamePage.ui +++ b/glabels/ui/TemplateDesignerNamePage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerOneLayoutPage.ui b/glabels/ui/TemplateDesignerOneLayoutPage.ui index 508cfd4..315266d 100644 --- a/glabels/ui/TemplateDesignerOneLayoutPage.ui +++ b/glabels/ui/TemplateDesignerOneLayoutPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerPageSizePage.ui b/glabels/ui/TemplateDesignerPageSizePage.ui index 38c631f..41686e7 100644 --- a/glabels/ui/TemplateDesignerPageSizePage.ui +++ b/glabels/ui/TemplateDesignerPageSizePage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerPathPage.ui b/glabels/ui/TemplateDesignerPathPage.ui index 2f78452..3b59a4c 100644 --- a/glabels/ui/TemplateDesignerPathPage.ui +++ b/glabels/ui/TemplateDesignerPathPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerRectPage.ui b/glabels/ui/TemplateDesignerRectPage.ui index 7265e8f..a4a4758 100644 --- a/glabels/ui/TemplateDesignerRectPage.ui +++ b/glabels/ui/TemplateDesignerRectPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerRoundPage.ui b/glabels/ui/TemplateDesignerRoundPage.ui index c51aa03..2a6651d 100644 --- a/glabels/ui/TemplateDesignerRoundPage.ui +++ b/glabels/ui/TemplateDesignerRoundPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerShapePage.ui b/glabels/ui/TemplateDesignerShapePage.ui index 0466fbb..a471d6c 100644 --- a/glabels/ui/TemplateDesignerShapePage.ui +++ b/glabels/ui/TemplateDesignerShapePage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/TemplateDesignerTwoLayoutPage.ui b/glabels/ui/TemplateDesignerTwoLayoutPage.ui index d7cc9dc..e3cc62a 100644 --- a/glabels/ui/TemplateDesignerTwoLayoutPage.ui +++ b/glabels/ui/TemplateDesignerTwoLayoutPage.ui @@ -23,7 +23,7 @@ - Form + Form diff --git a/glabels/ui/VariablesView.ui b/glabels/ui/VariablesView.ui new file mode 100644 index 0000000..df37af4 --- /dev/null +++ b/glabels/ui/VariablesView.ui @@ -0,0 +1,69 @@ + + + VariablesView + + + + 0 + 0 + 570 + 605 + + + + Form + + + + + + 12 + + + 12 + + + 12 + + + 12 + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-size:18pt;">Variables</span></p></body></html> + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + onSelectAllButtonClicked() + onUnselectAllButtonClicked() + onLocationButtonClicked() + onFormatComboActivated() + + diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index c3f29d2..fc1cd75 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -251,10 +251,6 @@ MergeView - - Form - - Source @@ -287,7 +283,7 @@ ObjectEditor - Form + Object properties @@ -314,6 +310,14 @@ Word + + Anywhere + + + + None + + Allow printing to shrink text to fit object @@ -374,14 +378,6 @@ File - - None - - - - Anywhere - - Select File... @@ -470,10 +466,6 @@ Opacity: - - Object properties - - PreferencesDialog @@ -516,22 +508,6 @@ PrintView - - Form - - - - Page - - - - of - - - - nn - - Copies @@ -568,13 +544,21 @@ Print + + Page + + + + of + + + + nn + + PropertiesView - - Form - - Product @@ -615,6 +599,14 @@ Change product + + Adjustable Parameters + + + + Label length: + + Orientation @@ -635,14 +627,6 @@ Similar Products - - Adjustable Parameters - - - - Label length: - - SelectProductDialog @@ -705,10 +689,6 @@ StartupView - - Form - - Welcome to gLabels. Let's get started: @@ -732,10 +712,6 @@ TemplateDesignerApplyPage - - Form - - You have completed the gLabels Product Template Designer. If you wish to accept and save your product template, click "Save." @@ -748,7 +724,11 @@ TemplateDesignerCdPage - Form + 6. Margin: + + + + 1. Outer radius: @@ -760,28 +740,16 @@ - 1. Outer radius: + 3. Clipping width: 5. Waste: - - 3. Clipping width: - - - - 6. Margin: - - TemplateDesignerContinuousPage - - Form - - <html><head/><body><p>Click &quot;Cancel&quot; to quit, or click &quot;Back&quot; to begin with a different product.</p></body></html> @@ -789,14 +757,6 @@ TemplateDesignerEllipsePage - - Form - - - - 3. Waste: - - 2. Height: @@ -805,6 +765,10 @@ 1. Width: + + 3. Waste: + + 4. Margin: @@ -812,10 +776,6 @@ TemplateDesignerIntroPage - - Form - - <html><head/><body><p>This dialog will help you create a custom product template. Let's get started:</p></body></html> @@ -839,10 +799,6 @@ TemplateDesignerNLayoutsPage - - Form - - 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. @@ -871,40 +827,32 @@ TemplateDesignerNamePage - Form + (e.g. "Mailing Labels," "Business Cards," ...) Brand: - - (e.g. Avery, Acme, ...) - - Part #: - - (e.g. 8163A) - - Description: - (e.g. "Mailing Labels," "Business Cards," ...) + (e.g. 8163A) + + + + (e.g. Avery, Acme, ...) TemplateDesignerOneLayoutPage - - Form - - Number across (nx): @@ -937,15 +885,7 @@ TemplateDesignerPageSizePage - Form - - - - Page size: - - - - Width: + Roll width: @@ -953,16 +893,16 @@ - Roll width: + Width: + + + + Page size: TemplateDesignerPathPage - - Form - - <html><head/><body><p>Click &quot;Cancel&quot; to quit, or click &quot;Back&quot; to begin with a different product.</p></body></html> @@ -971,15 +911,7 @@ TemplateDesignerRectPage - Form - - - - 1. Width: - - - - 2. Height: + 4. Horizontal waste: @@ -987,13 +919,17 @@ - 4. Horizontal waste: + 1. Width: 5. Vertical waste: + + 2. Height: + + 6. Margin (X): @@ -1010,11 +946,7 @@ TemplateDesignerRoundPage - Form - - - - 2. Waste: + 3. Margin @@ -1022,16 +954,12 @@ - 3. Margin + 2. Waste: TemplateDesignerShapePage - - Form - - Rectangular or square (can have rounded corners) @@ -1051,10 +979,6 @@ TemplateDesignerTwoLayoutPage - - Form - - Distance from left edge (x0): @@ -1197,6 +1121,10 @@ Welcome + + Edit + + Properties @@ -1206,11 +1134,11 @@ - Print + Variables - Edit + Print @@ -1269,6 +1197,14 @@ Select project Merge mode + + &Variables + + + + Select project Variables mode + + &Print @@ -1920,11 +1856,11 @@ - Copy + Roll - Roll + Copy @@ -2102,6 +2038,13 @@ + + glabels::VariablesView + + Variables + + + glabels::barcode::Backends @@ -2240,6 +2183,10 @@ IEC18004 (QRCode) + + Australia Post Standard + + Australia Post Reply Paid @@ -2292,10 +2239,6 @@ Code 49 - - Australia Post Standard - - Code 128 (Mode C suppression) From c9e26c45fb4f0af02e92747cca1e6400bb434c76 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Tue, 5 Mar 2019 21:35:11 -0500 Subject: [PATCH 02/55] Prototype of VariableView and EditVariableDialog user interface. --- glabels/CMakeLists.txt | 3 + glabels/EditVariableDialog.cpp | 128 +++++++++++++++++ glabels/EditVariableDialog.h | 73 ++++++++++ glabels/VariablesView.cpp | 62 ++++++++ glabels/VariablesView.h | 5 + glabels/ui/EditVariableDialog.ui | 237 +++++++++++++++++++++++++++++++ glabels/ui/VariablesView.ui | 171 +++++++++++++++++++--- model/CMakeLists.txt | 1 + model/Variable.cpp | 74 ++++++++++ model/Variable.h | 84 +++++++++++ translations/glabels_C.ts | 98 +++++++++++++ 11 files changed, 913 insertions(+), 23 deletions(-) create mode 100644 glabels/EditVariableDialog.cpp create mode 100644 glabels/EditVariableDialog.h create mode 100644 glabels/ui/EditVariableDialog.ui create mode 100644 model/Variable.cpp create mode 100644 model/Variable.h diff --git a/glabels/CMakeLists.txt b/glabels/CMakeLists.txt index 715d63d..df14917 100644 --- a/glabels/CMakeLists.txt +++ b/glabels/CMakeLists.txt @@ -16,6 +16,7 @@ set (glabels_sources ColorPaletteButtonItem.cpp ColorSwatch.cpp Cursors.cpp + EditVariableDialog.cpp FieldButton.cpp File.cpp Help.cpp @@ -52,6 +53,7 @@ set (glabels_qobject_headers ColorPaletteDialog.h ColorPaletteItem.h ColorPaletteButtonItem.h + EditVariableDialog.h FieldButton.h File.h LabelEditor.h @@ -73,6 +75,7 @@ set (glabels_qobject_headers set (glabels_forms ui/AboutDialog.ui + ui/EditVariableDialog.ui ui/MergeView.ui ui/ObjectEditor.ui ui/PreferencesDialog.ui diff --git a/glabels/EditVariableDialog.cpp b/glabels/EditVariableDialog.cpp new file mode 100644 index 0000000..ea7d0f3 --- /dev/null +++ b/glabels/EditVariableDialog.cpp @@ -0,0 +1,128 @@ +/* EditVariableDialog.cpp + * + * Copyright (C) 2019 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#include "EditVariableDialog.h" + +#include "model/Settings.h" + + +namespace glabels +{ + + /// + /// Constructor + /// + EditVariableDialog::EditVariableDialog( QWidget *parent ) + : QDialog(parent) + { + setupUi( this ); + } + + + /// + /// Set variable + /// + void EditVariableDialog::setVariable( const model::Variable& variable ) + { + typeCombo->setCurrentIndex( variable.type() ); + nameEdit->setText( variable.name() ); + valueEdit->setText( variable.value() ); + incrementCombo->setCurrentIndex( variable.incrementPolicy() ); + stepSizeEdit->setText( variable.stepSize() ); + + updateControls(); + } + + + /// + /// Get variable + /// + model::Variable EditVariableDialog::variable() const + { + return model::Variable( static_cast(typeCombo->currentIndex()), + nameEdit->text(), + valueEdit->text(), + static_cast(incrementCombo->currentIndex()), + stepSizeEdit->text() ); + } + + + /// + /// typeCombo Changed + /// + void EditVariableDialog::onTypeComboChanged() + { + updateControls(); + } + + + /// + /// valueEdit Changed + /// + void EditVariableDialog::onValueEditChanged() + { + } + + + /// + /// incrementCombo Changed + /// + void EditVariableDialog::onIncrementComboChanged() + { + updateControls(); + } + + + /// + /// stepSizeEdit Changed + /// + void EditVariableDialog::onStepSizeEditChanged() + { + } + + + /// + /// update controls + /// + void EditVariableDialog::updateControls() + { + model::Variable::Type type = static_cast(typeCombo->currentIndex()); + model::Variable::IncrementPolicy incrementPolicy = static_cast(incrementCombo->currentIndex()); + + if ( type != model::Variable::TYPE_NUMERIC ) + { + incrementCombo->setCurrentIndex( model::Variable::INCREMENT_NEVER ); + } + + if ( incrementPolicy == model::Variable::INCREMENT_NEVER ) + { + stepSizeEdit->setText( "0" ); + } + + incrementLabel->setEnabled( type == model::Variable::TYPE_NUMERIC ); + incrementCombo->setEnabled( type == model::Variable::TYPE_NUMERIC ); + stepSizeLabel->setEnabled( (type == model::Variable::TYPE_NUMERIC) && + (incrementPolicy != model::Variable::INCREMENT_NEVER) ); + stepSizeEdit->setEnabled( (type == model::Variable::TYPE_NUMERIC) && + (incrementPolicy != model::Variable::INCREMENT_NEVER) ); + } + + +} // namespace glabels diff --git a/glabels/EditVariableDialog.h b/glabels/EditVariableDialog.h new file mode 100644 index 0000000..1419f2c --- /dev/null +++ b/glabels/EditVariableDialog.h @@ -0,0 +1,73 @@ +/* EditVariableDialog.h + * + * Copyright (C) 2019 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#ifndef EditVariableDialog_h +#define EditVariableDialog_h + + +#include "ui_EditVariableDialog.h" +#include "model/Variable.h" + + +namespace glabels +{ + + /// + /// New Label Dialog Widget + /// + class EditVariableDialog : public QDialog, public Ui_EditVariableDialog + { + Q_OBJECT + + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// + public: + EditVariableDialog( QWidget *parent = nullptr ); + + + ///////////////////////////////// + // Public methods + ///////////////////////////////// + void setVariable( const model::Variable& variable ); + model::Variable variable() const; + + + ///////////////////////////////// + // Slots + ///////////////////////////////// + private slots: + void onTypeComboChanged(); + void onValueEditChanged(); + void onIncrementComboChanged(); + void onStepSizeEditChanged(); + + + ///////////////////////////////// + // Private methods + ///////////////////////////////// + void updateControls(); + + }; + +} + + +#endif // EditVariableDialog_h diff --git a/glabels/VariablesView.cpp b/glabels/VariablesView.cpp index 7505d12..ffe64b8 100644 --- a/glabels/VariablesView.cpp +++ b/glabels/VariablesView.cpp @@ -20,6 +20,8 @@ #include "VariablesView.h" +#include "EditVariableDialog.h" + #include @@ -55,8 +57,68 @@ namespace glabels mModel = model; mUndoRedoModel = undoRedoModel; + updateControls(); + //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_NUMERIC, + "x", + "0", + model::Variable::INCREMENT_NEVER, + "0" ); + dialog.setVariable( v ); + + if ( dialog.exec() == QDialog::Accepted ) + { + qDebug() << "Add OK."; + } + } + + + /// + /// editButton Clicked + /// + void VariablesView::onEditButtonClicked() + { + } + + + /// + /// deleteButton Clicked + /// + void VariablesView::onDeleteButtonClicked() + { + } + + + /// + /// update controls + /// + void VariablesView::updateControls() + { + bool hasSelection = !table->selectedItems().isEmpty(); + + editButton->setEnabled( hasSelection ); + deleteButton->setEnabled( hasSelection ); + } + + } // namespace glabels diff --git a/glabels/VariablesView.h b/glabels/VariablesView.h index e045dd4..f648cd5 100644 --- a/glabels/VariablesView.h +++ b/glabels/VariablesView.h @@ -60,12 +60,17 @@ namespace glabels // Slots ///////////////////////////////// private slots: + void onTableSelectionChanged(); + void onAddButtonClicked(); + void onEditButtonClicked(); + void onDeleteButtonClicked(); ///////////////////////////////// // Private methods ///////////////////////////////// private: + void updateControls(); ///////////////////////////////// diff --git a/glabels/ui/EditVariableDialog.ui b/glabels/ui/EditVariableDialog.ui new file mode 100644 index 0000000..8cd925e --- /dev/null +++ b/glabels/ui/EditVariableDialog.ui @@ -0,0 +1,237 @@ + + + EditVariableDialog + + + + 0 + 0 + 471 + 237 + + + + Dialog + + + + + + + + Variable Type: + + + + + + + + Numeric + + + + + String + + + + + + + + Name: + + + + + + + + + + Value: + + + + + + + + + + Increment: + + + + + + + + + + Never + + + + + Per Copy + + + + + Per Merge Record + + + + + Per Page + + + + + + + + Step Size: + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + EditVariableDialog + accept() + + + 227 + 214 + + + 157 + 236 + + + + + buttonBox + rejected() + EditVariableDialog + reject() + + + 295 + 220 + + + 286 + 236 + + + + + typeCombo + currentIndexChanged(int) + EditVariableDialog + onTypeComboChanged() + + + 179 + 30 + + + 33 + 161 + + + + + valueEdit + textChanged(QString) + EditVariableDialog + onValueEditChanged() + + + 212 + 86 + + + 63 + 166 + + + + + incrementCombo + currentIndexChanged(int) + EditVariableDialog + onIncrementComboChanged() + + + 170 + 123 + + + 97 + 176 + + + + + stepSizeEdit + textChanged(QString) + EditVariableDialog + onStepSizeEditChanged() + + + 344 + 125 + + + 333 + 166 + + + + + + onTypeComboChanged() + onValueEditChanged() + onIncrementComboChanged() + onStepSizeEditChanged() + + diff --git a/glabels/ui/VariablesView.ui b/glabels/ui/VariablesView.ui index df37af4..04ec15b 100644 --- a/glabels/ui/VariablesView.ui +++ b/glabels/ui/VariablesView.ui @@ -6,50 +6,106 @@ 0 0 - 570 + 1105 605 Form - + - - - 12 + + + + 0 + 0 + - - 12 + + <html><head/><body><p><span style=" font-size:18pt;">Variables</span></p></body></html> - - 12 + + + + + + QAbstractItemView::SingleSelection - - 12 + + QAbstractItemView::SelectRows + + 5 + + + + Name + + + + + Type + + + + + Value + + + + + Increment + + + + + Step Size + + + + + + - - - - 0 - 0 - + + + <html><head/><body><p>Add variable</p></body></html> - <html><head/><body><p><span style=" font-size:18pt;">Variables</span></p></body></html> + Add - + + + <html><head/><body><p>Edit selected variable</p></body></html> + + + Edit + + + + + + + <html><head/><body><p>Delete selected variable</p></body></html> + + + Delete + + + + + - Qt::Vertical + Qt::Horizontal - 20 - 40 + 40 + 20 @@ -59,11 +115,80 @@ - + + + addButton + clicked() + VariablesView + onAddButtonClicked() + + + 63 + 586 + + + 98 + 598 + + + + + editButton + clicked() + VariablesView + onEditButtonClicked() + + + 167 + 576 + + + 317 + 608 + + + + + deleteButton + clicked() + VariablesView + onDeleteButtonClicked() + + + 245 + 575 + + + 508 + 613 + + + + + table + itemSelectionChanged() + VariablesView + onTableSelectionChanged() + + + 380 + 258 + + + 787 + 610 + + + + onSelectAllButtonClicked() onUnselectAllButtonClicked() onLocationButtonClicked() onFormatComboActivated() + onAddButtonClicked() + onEditButtonClicked() + onDeleteButtonClicked() + onTableSelectionChanged() diff --git a/model/CMakeLists.txt b/model/CMakeLists.txt index ee1af03..100d5bf 100644 --- a/model/CMakeLists.txt +++ b/model/CMakeLists.txt @@ -56,6 +56,7 @@ set (Model_sources Template.cpp TextNode.cpp Units.cpp + Variable.cpp Vendor.cpp XmlCategoryParser.cpp XmlLabelCreator.cpp diff --git a/model/Variable.cpp b/model/Variable.cpp new file mode 100644 index 0000000..3eb309d --- /dev/null +++ b/model/Variable.cpp @@ -0,0 +1,74 @@ +/* Variable.cpp + * + * Copyright (C) 2013-2016 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#include "Variable.h" + + +namespace glabels +{ + namespace model + { + + Variable::Variable( Variable::Type type, + const QString& name, + const QString& value, + Variable::IncrementPolicy incrementPolicy, + const QString& stepSize ) + : mType(type), + mName(name), + mValue(value), + mIncrementPolicy(incrementPolicy), + mStepSize(stepSize) + { + // empty + } + + + Variable::Type Variable::type() const + { + return mType; + } + + + QString Variable::name() const + { + return mName; + } + + + QString Variable::value() const + { + return mValue; + } + + + Variable::IncrementPolicy Variable::incrementPolicy() const + { + return mIncrementPolicy; + } + + + QString Variable::stepSize() const + { + return mStepSize; + } + + } +} diff --git a/model/Variable.h b/model/Variable.h new file mode 100644 index 0000000..333857f --- /dev/null +++ b/model/Variable.h @@ -0,0 +1,84 @@ +/* Variable.h + * + * Copyright (C) 2019 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#ifndef model_Variable_h +#define model_Variable_h + + +#include + + +namespace glabels +{ + namespace model + { + + class Variable + { + public: + enum Type + { + TYPE_NUMERIC, + TYPE_STRING + }; + + enum IncrementPolicy + { + INCREMENT_NEVER, + INCREMENT_PER_COPY, + INCREMENT_PER_MERGE_RECORD, + INCREMENT_PER_PAGE + }; + + + public: + Variable() = default; + + Variable( Type type, + const QString& name, + const QString& value, + IncrementPolicy incrementPolicy = INCREMENT_NEVER, + const QString& stepSize = "0" ); + + virtual ~Variable() = default; + + + Type type() const; + QString name() const; + QString value() const; + IncrementPolicy incrementPolicy() const; + QString stepSize() const; + + + + private: + Type mType; + QString mName; + QString mValue; + IncrementPolicy mIncrementPolicy; + QString mStepSize; + + }; + + } +} + + +#endif // model_Variable_h diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index fc1cd75..844a98f 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -178,6 +178,57 @@ + + EditVariableDialog + + Dialog + + + + Variable Type: + + + + Numeric + + + + String + + + + Name: + + + + Value: + + + + Increment: + + + + Never + + + + Per Copy + + + + Per Merge Record + + + + Per Page + + + + Step Size: + + + Factory @@ -1031,6 +1082,53 @@ + + VariablesView + + Name + + + + Type + + + + Value + + + + Increment + + + + Step Size + + + + <html><head/><body><p>Add variable</p></body></html> + + + + Add + + + + <html><head/><body><p>Edit selected variable</p></body></html> + + + + Edit + + + + <html><head/><body><p>Delete selected variable</p></body></html> + + + + Delete + + + glabels::AboutDialog From 6255939f39c309f35feafac9285e0bafc453952b Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 16 Mar 2019 18:12:17 -0400 Subject: [PATCH 03/55] Closed MVC loop for VariablesView. --- glabels/EditVariableDialog.cpp | 26 ++++---- glabels/VariablesView.cpp | 108 +++++++++++++++++++++++++++++++-- glabels/VariablesView.h | 3 + model/CMakeLists.txt | 2 + model/Model.cpp | 24 ++++++++ model/Model.h | 6 ++ model/Variable.cpp | 73 +++++++++++++++++++--- model/Variable.h | 49 +++++++++------ model/Variables.cpp | 90 +++++++++++++++++++++++++++ model/Variables.h | 85 ++++++++++++++++++++++++++ translations/glabels_C.ts | 27 +++++++++ 11 files changed, 448 insertions(+), 45 deletions(-) create mode 100644 model/Variables.cpp create mode 100644 model/Variables.h diff --git a/glabels/EditVariableDialog.cpp b/glabels/EditVariableDialog.cpp index ea7d0f3..62de4db 100644 --- a/glabels/EditVariableDialog.cpp +++ b/glabels/EditVariableDialog.cpp @@ -41,10 +41,10 @@ namespace glabels /// void EditVariableDialog::setVariable( const model::Variable& variable ) { - typeCombo->setCurrentIndex( variable.type() ); + typeCombo->setCurrentIndex( static_cast(variable.type()) ); nameEdit->setText( variable.name() ); valueEdit->setText( variable.value() ); - incrementCombo->setCurrentIndex( variable.incrementPolicy() ); + incrementCombo->setCurrentIndex( static_cast(variable.increment()) ); stepSizeEdit->setText( variable.stepSize() ); updateControls(); @@ -59,7 +59,7 @@ namespace glabels return model::Variable( static_cast(typeCombo->currentIndex()), nameEdit->text(), valueEdit->text(), - static_cast(incrementCombo->currentIndex()), + static_cast(incrementCombo->currentIndex()), stepSizeEdit->text() ); } @@ -104,24 +104,24 @@ namespace glabels void EditVariableDialog::updateControls() { model::Variable::Type type = static_cast(typeCombo->currentIndex()); - model::Variable::IncrementPolicy incrementPolicy = static_cast(incrementCombo->currentIndex()); + model::Variable::Increment increment = static_cast(incrementCombo->currentIndex()); - if ( type != model::Variable::TYPE_NUMERIC ) + if ( type != model::Variable::Type::NUMERIC ) { - incrementCombo->setCurrentIndex( model::Variable::INCREMENT_NEVER ); + incrementCombo->setCurrentIndex( static_cast(model::Variable::Increment::NEVER) ); } - if ( incrementPolicy == model::Variable::INCREMENT_NEVER ) + if ( increment == model::Variable::Increment::NEVER ) { stepSizeEdit->setText( "0" ); } - incrementLabel->setEnabled( type == model::Variable::TYPE_NUMERIC ); - incrementCombo->setEnabled( type == model::Variable::TYPE_NUMERIC ); - stepSizeLabel->setEnabled( (type == model::Variable::TYPE_NUMERIC) && - (incrementPolicy != model::Variable::INCREMENT_NEVER) ); - stepSizeEdit->setEnabled( (type == model::Variable::TYPE_NUMERIC) && - (incrementPolicy != model::Variable::INCREMENT_NEVER) ); + incrementLabel->setEnabled( type == model::Variable::Type::NUMERIC ); + incrementCombo->setEnabled( type == model::Variable::Type::NUMERIC ); + stepSizeLabel->setEnabled( (type == model::Variable::Type::NUMERIC) && + (increment != model::Variable::Increment::NEVER) ); + stepSizeEdit->setEnabled( (type == model::Variable::Type::NUMERIC) && + (increment != model::Variable::Increment::NEVER) ); } diff --git a/glabels/VariablesView.cpp b/glabels/VariablesView.cpp index ffe64b8..c737b71 100644 --- a/glabels/VariablesView.cpp +++ b/glabels/VariablesView.cpp @@ -22,9 +22,22 @@ #include "EditVariableDialog.h" +#include #include +namespace +{ + enum ICol { + I_COL_NAME = 0, + I_COL_TYPE = 1, + I_COL_VALUE = 2, + I_COL_INCREMENT = 3, + I_COL_STEP_SIZE = 4 + }; +} + + namespace glabels { @@ -58,8 +71,9 @@ namespace glabels mUndoRedoModel = undoRedoModel; updateControls(); + loadTable(); - //connect( mModel, SIGNAL(variablesChanged()), this, SLOT(onVariablesChanged()) ); + connect( mModel, SIGNAL(variablesChanged()), this, SLOT(onVariablesChanged()) ); } @@ -79,16 +93,17 @@ namespace glabels { EditVariableDialog dialog( this ); - model::Variable v( model::Variable::TYPE_NUMERIC, + model::Variable v( model::Variable::Type::NUMERIC, "x", "0", - model::Variable::INCREMENT_NEVER, + model::Variable::Increment::NEVER, "0" ); dialog.setVariable( v ); if ( dialog.exec() == QDialog::Accepted ) { - qDebug() << "Add OK."; + mModel->variables()->addVariable( dialog.variable() ); + selectVariable( dialog.variable().name() ); } } @@ -98,6 +113,22 @@ namespace glabels /// 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 ); + + if ( dialog.exec() == QDialog::Accepted ) + { + mModel->variables()->replaceVariable( name, dialog.variable() ); + selectVariable( dialog.variable().name() ); + } + } } @@ -106,6 +137,20 @@ namespace glabels /// 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(); } @@ -121,4 +166,59 @@ namespace glabels } + /// + /// 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.value() ); + 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 ) + { + qDebug() << "Selecting row " << iRow; + table->setCurrentCell( iRow, 0, + (QItemSelectionModel::Select|QItemSelectionModel::Rows) ); + break; + } + + iRow++; + } + } + + } // namespace glabels diff --git a/glabels/VariablesView.h b/glabels/VariablesView.h index f648cd5..93dca3d 100644 --- a/glabels/VariablesView.h +++ b/glabels/VariablesView.h @@ -64,6 +64,7 @@ namespace glabels void onAddButtonClicked(); void onEditButtonClicked(); void onDeleteButtonClicked(); + void onVariablesChanged(); ///////////////////////////////// @@ -71,6 +72,8 @@ namespace glabels ///////////////////////////////// private: void updateControls(); + void loadTable(); + void selectVariable( const QString& name ); ///////////////////////////////// diff --git a/model/CMakeLists.txt b/model/CMakeLists.txt index 100d5bf..fc7db0c 100644 --- a/model/CMakeLists.txt +++ b/model/CMakeLists.txt @@ -57,6 +57,7 @@ set (Model_sources TextNode.cpp Units.cpp Variable.cpp + Variables.cpp Vendor.cpp XmlCategoryParser.cpp XmlLabelCreator.cpp @@ -81,6 +82,7 @@ set (Model_qobject_headers ModelTextObject.h PageRenderer.h Settings.h + Variables.h ) qt5_wrap_cpp (Model_moc_sources ${Model_qobject_headers}) diff --git a/model/Model.cpp b/model/Model.cpp index b0eb83d..896970d 100644 --- a/model/Model.cpp +++ b/model/Model.cpp @@ -57,7 +57,10 @@ namespace glabels Model::Model() : mUntitledInstance(0), mModified(true), mRotate(false) { + mVariables = new Variables(); mMerge = new merge::None(); + + connect( mVariables, SIGNAL(changed()), this, SLOT(onVariablesChanged()) ); } @@ -66,6 +69,7 @@ namespace glabels /// Model::~Model() { + delete mVariables; delete mMerge; } @@ -302,6 +306,15 @@ namespace glabels } + /// + /// Get variables object + /// + Variables* Model::variables() const + { + return mVariables; + } + + /// /// Get merge object /// @@ -451,6 +464,17 @@ namespace glabels } + /// + /// Variables Changed Slot + /// + void Model::onVariablesChanged() + { + setModified(); + emit changed(); + emit variablesChanged(); + } + + /// /// Merge Source Changed Slot /// diff --git a/model/Model.h b/model/Model.h index 992606e..13b9f4c 100644 --- a/model/Model.h +++ b/model/Model.h @@ -24,6 +24,7 @@ #include "Settings.h" #include "Template.h" +#include "Variables.h" #include "merge/Merge.h" #include "merge/Record.h" @@ -76,6 +77,7 @@ namespace glabels void sizeChanged(); void selectionChanged(); void modifiedChanged(); + void variablesChanged(); void mergeChanged(); void mergeSourceChanged(); void mergeSelectionChanged(); @@ -107,6 +109,8 @@ namespace glabels const QList& objectList() const; + Variables* variables() const; + merge::Merge* merge() const; void setMerge( merge::Merge* merge ); @@ -213,6 +217,7 @@ namespace glabels private slots: void onObjectChanged(); void onObjectMoved(); + void onVariablesChanged(); void onMergeSourceChanged(); void onMergeSelectionChanged(); @@ -229,6 +234,7 @@ namespace glabels QList mObjectList; + Variables* mVariables; merge::Merge* mMerge; }; diff --git a/model/Variable.cpp b/model/Variable.cpp index 3eb309d..e4a3432 100644 --- a/model/Variable.cpp +++ b/model/Variable.cpp @@ -26,15 +26,15 @@ namespace glabels namespace model { - Variable::Variable( Variable::Type type, - const QString& name, - const QString& value, - Variable::IncrementPolicy incrementPolicy, - const QString& stepSize ) + Variable::Variable( Variable::Type type, + const QString& name, + const QString& value, + Variable::Increment increment, + const QString& stepSize ) : mType(type), mName(name), mValue(value), - mIncrementPolicy(incrementPolicy), + mIncrement(increment), mStepSize(stepSize) { // empty @@ -59,9 +59,9 @@ namespace glabels } - Variable::IncrementPolicy Variable::incrementPolicy() const + Variable::Increment Variable::increment() const { - return mIncrementPolicy; + return mIncrement; } @@ -70,5 +70,62 @@ namespace glabels return mStepSize; } + + QString Variable::typeToI18nString( Type type ) + { + switch (type) + { + case Type::NUMERIC: + return tr("Numeric"); + case Type::STRING: + return tr("String"); + } + } + + + QString Variable::typeToIdString( Type type ) + { + switch (type) + { + case Type::NUMERIC: + return "numeric"; + case Type::STRING: + return "string"; + } + } + + + QString Variable::incrementToI18nString( Increment increment ) + { + switch (increment) + { + case Increment::NEVER: + return tr("Never"); + case Increment::PER_COPY: + return tr("Per copy"); + case Increment::PER_MERGE_RECORD: + return tr("Per merge record"); + case Increment::PER_PAGE: + return tr("Per page"); + } + } + + + QString Variable::incrementToIdString( Increment increment ) + { + switch (increment) + { + case Increment::NEVER: + return "never"; + case Increment::PER_COPY: + return "per_copy"; + case Increment::PER_MERGE_RECORD: + return "per_merge_record"; + case Increment::PER_PAGE: + return "per_page"; + } + } + + } } diff --git a/model/Variable.h b/model/Variable.h index 333857f..d314642 100644 --- a/model/Variable.h +++ b/model/Variable.h @@ -22,6 +22,7 @@ #define model_Variable_h +#include #include @@ -32,19 +33,21 @@ namespace glabels class Variable { + Q_DECLARE_TR_FUNCTIONS(Variable) + public: - enum Type + enum class Type { - TYPE_NUMERIC, - TYPE_STRING + NUMERIC, + STRING }; - enum IncrementPolicy + enum class Increment { - INCREMENT_NEVER, - INCREMENT_PER_COPY, - INCREMENT_PER_MERGE_RECORD, - INCREMENT_PER_PAGE + NEVER, + PER_COPY, + PER_MERGE_RECORD, + PER_PAGE }; @@ -54,26 +57,32 @@ namespace glabels Variable( Type type, const QString& name, const QString& value, - IncrementPolicy incrementPolicy = INCREMENT_NEVER, + Increment increment = Increment::NEVER, const QString& stepSize = "0" ); virtual ~Variable() = default; - Type type() const; - QString name() const; - QString value() const; - IncrementPolicy incrementPolicy() const; - QString stepSize() const; - + Type type() const; + QString name() const; + QString value() const; + Increment increment() const; + QString stepSize() const; + + + static QString typeToI18nString( Type type ); + static QString typeToIdString( Type type ); + + static QString incrementToI18nString( Increment increment ); + static QString incrementToIdString( Increment increment ); private: - Type mType; - QString mName; - QString mValue; - IncrementPolicy mIncrementPolicy; - QString mStepSize; + Type mType; + QString mName; + QString mValue; + Increment mIncrement; + QString mStepSize; }; diff --git a/model/Variables.cpp b/model/Variables.cpp new file mode 100644 index 0000000..24d414f --- /dev/null +++ b/model/Variables.cpp @@ -0,0 +1,90 @@ +/* Variables.cpp + * + * Copyright (C) 2013-2016 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#include "Variables.h" + +#include + + +namespace glabels +{ + namespace model + { + /// + /// Copy constructor + /// + Variables::Variables( const Variables* variables ) + : QMap(*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(); + } + + + } // namespace model + +} // namespace glabels diff --git a/model/Variables.h b/model/Variables.h new file mode 100644 index 0000000..0c1a020 --- /dev/null +++ b/model/Variables.h @@ -0,0 +1,85 @@ +/* Variables.h + * + * Copyright (C) 2013-2016 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#ifndef model_Variables_h +#define model_Variables_h + + +#include "Variable.h" + +#include +#include +#include + + +namespace glabels +{ + namespace model + { + + /// + /// Variables Collection + /// + class Variables : public QObject, public QMap + { + 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 ); + + + ///////////////////////////////// + // Signals + ///////////////////////////////// + signals: + void changed(); + + + ///////////////////////////////// + // Private data + ///////////////////////////////// + private: + + }; + + } +} + + +#endif // model_Variables_h diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 844a98f..59305a8 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -1082,6 +1082,33 @@ + + Variable + + Numeric + + + + String + + + + Never + + + + Per copy + + + + Per merge record + + + + Per page + + + VariablesView From d05c6fbfd2bc045eeb98029d9cc26a19584d0282 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 17 Mar 2019 14:24:55 -0400 Subject: [PATCH 04/55] Fleshed out input validation for EditVariableDialog. --- glabels/EditVariableDialog.cpp | 84 +++++++++++++++++++++++++++++--- glabels/EditVariableDialog.h | 2 + glabels/VariablesView.cpp | 1 - glabels/ui/EditVariableDialog.ui | 53 ++++++++------------ translations/glabels_C.ts | 24 --------- 5 files changed, 97 insertions(+), 67 deletions(-) diff --git a/glabels/EditVariableDialog.cpp b/glabels/EditVariableDialog.cpp index 62de4db..2abcb12 100644 --- a/glabels/EditVariableDialog.cpp +++ b/glabels/EditVariableDialog.cpp @@ -22,6 +22,26 @@ #include "model/Settings.h" +#include + + +namespace +{ + // All variable types. (must be in sorted order) + const QVector allTypes = { + glabels::model::Variable::Type::NUMERIC, + glabels::model::Variable::Type::STRING + }; + + // All variable increments. (must be in sorted order) + const QVector allIncrements = { + glabels::model::Variable::Increment::NEVER, + glabels::model::Variable::Increment::PER_COPY, + glabels::model::Variable::Increment::PER_MERGE_RECORD, + glabels::model::Variable::Increment::PER_PAGE + }; +} + namespace glabels { @@ -33,6 +53,19 @@ namespace glabels : QDialog(parent) { setupUi( this ); + + QRegularExpression reIdentifier( "[a-zA-Z_][a-zA-Z_0-9]*" ); + nameEdit->setValidator( new QRegularExpressionValidator( reIdentifier ) ); + + for ( auto type : allTypes ) + { + typeCombo->addItem( model::Variable::typeToI18nString( type ) ); + } + + for ( auto type : allIncrements ) + { + incrementCombo->addItem( model::Variable::incrementToI18nString( type ) ); + } } @@ -64,6 +97,15 @@ namespace glabels } + /// + /// nameEdit Changed + /// + void EditVariableDialog::onNameEditChanged() + { + validateCurrentInputs(); + } + + /// /// typeCombo Changed /// @@ -78,6 +120,7 @@ namespace glabels /// void EditVariableDialog::onValueEditChanged() { + validateCurrentInputs(); } @@ -95,6 +138,7 @@ namespace glabels /// void EditVariableDialog::onStepSizeEditChanged() { + validateCurrentInputs(); } @@ -103,25 +147,49 @@ namespace glabels /// void EditVariableDialog::updateControls() { - model::Variable::Type type = static_cast(typeCombo->currentIndex()); - model::Variable::Increment increment = static_cast(incrementCombo->currentIndex()); + auto type = static_cast(typeCombo->currentIndex()); + auto increment = static_cast(incrementCombo->currentIndex()); - if ( type != model::Variable::Type::NUMERIC ) + if ( type == model::Variable::Type::NUMERIC ) { + valueEdit->setValidator( new QDoubleValidator() ); + stepSizeEdit->setValidator( new QDoubleValidator() ); + + if ( increment == model::Variable::Increment::NEVER ) + { + stepSizeEdit->setText( "0" ); + } + } + else + { + valueEdit->setValidator( nullptr ); + stepSizeEdit->setValidator( nullptr ); incrementCombo->setCurrentIndex( static_cast(model::Variable::Increment::NEVER) ); + stepSizeEdit->setText( "" ); } - if ( increment == model::Variable::Increment::NEVER ) - { - stepSizeEdit->setText( "0" ); - } - incrementLabel->setEnabled( type == model::Variable::Type::NUMERIC ); incrementCombo->setEnabled( type == model::Variable::Type::NUMERIC ); stepSizeLabel->setEnabled( (type == model::Variable::Type::NUMERIC) && (increment != model::Variable::Increment::NEVER) ); stepSizeEdit->setEnabled( (type == model::Variable::Type::NUMERIC) && (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 ); } diff --git a/glabels/EditVariableDialog.h b/glabels/EditVariableDialog.h index 1419f2c..8c57a20 100644 --- a/glabels/EditVariableDialog.h +++ b/glabels/EditVariableDialog.h @@ -54,6 +54,7 @@ namespace glabels // Slots ///////////////////////////////// private slots: + void onNameEditChanged(); void onTypeComboChanged(); void onValueEditChanged(); void onIncrementComboChanged(); @@ -64,6 +65,7 @@ namespace glabels // Private methods ///////////////////////////////// void updateControls(); + void validateCurrentInputs(); }; diff --git a/glabels/VariablesView.cpp b/glabels/VariablesView.cpp index c737b71..088fe70 100644 --- a/glabels/VariablesView.cpp +++ b/glabels/VariablesView.cpp @@ -210,7 +210,6 @@ namespace glabels { if ( v.name() == name ) { - qDebug() << "Selecting row " << iRow; table->setCurrentCell( iRow, 0, (QItemSelectionModel::Select|QItemSelectionModel::Rows) ); break; diff --git a/glabels/ui/EditVariableDialog.ui b/glabels/ui/EditVariableDialog.ui index 8cd925e..11399a7 100644 --- a/glabels/ui/EditVariableDialog.ui +++ b/glabels/ui/EditVariableDialog.ui @@ -24,18 +24,7 @@ - - - - Numeric - - - - - String - - - + @@ -67,28 +56,7 @@ - - - - Never - - - - - Per Copy - - - - - Per Merge Record - - - - - Per Page - - - + @@ -227,11 +195,28 @@ + + nameEdit + textChanged(QString) + EditVariableDialog + onNameEditChanged() + + + 371 + 62 + + + 393 + 165 + + + onTypeComboChanged() onValueEditChanged() onIncrementComboChanged() onStepSizeEditChanged() + onNameEditChanged() diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 59305a8..29dc951 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -188,14 +188,6 @@ Variable Type: - - Numeric - - - - String - - Name: @@ -208,22 +200,6 @@ Increment: - - Never - - - - Per Copy - - - - Per Merge Record - - - - Per Page - - Step Size: From dab2c1986217c88ceee0e604062c1d6b1cc00946 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 17 Mar 2019 14:35:29 -0400 Subject: [PATCH 05/55] Add window titles to "Add Variable" and "Edit Variable" dialogs. --- glabels/VariablesView.cpp | 2 ++ translations/glabels_C.ts | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/glabels/VariablesView.cpp b/glabels/VariablesView.cpp index 088fe70..0546566 100644 --- a/glabels/VariablesView.cpp +++ b/glabels/VariablesView.cpp @@ -99,6 +99,7 @@ namespace glabels model::Variable::Increment::NEVER, "0" ); dialog.setVariable( v ); + dialog.setWindowTitle( tr("Add Variable") ); if ( dialog.exec() == QDialog::Accepted ) { @@ -122,6 +123,7 @@ namespace glabels EditVariableDialog dialog( this ); dialog.setVariable( v ); + dialog.setWindowTitle( tr("Edit Variable") ); if ( dialog.exec() == QDialog::Accepted ) { diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 29dc951..5708957 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -2145,6 +2145,14 @@ Variables + + Add Variable + + + + Edit Variable + + glabels::barcode::Backends From 879092deaa387bcff849f231c66694b391c3b2a2 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 17 Mar 2019 19:55:05 -0400 Subject: [PATCH 06/55] Updated substitution field spec and TODO document. --- docs/SUBSTITUTION-FIELD-SPEC.md | 39 +++++++++++++++++++-------------- docs/TODO.md | 12 ++++++++++ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/docs/SUBSTITUTION-FIELD-SPEC.md b/docs/SUBSTITUTION-FIELD-SPEC.md index b69ff38..ddfc2ef 100644 --- a/docs/SUBSTITUTION-FIELD-SPEC.md +++ b/docs/SUBSTITUTION-FIELD-SPEC.md @@ -17,6 +17,28 @@ modifiers = modifier [ ":" modifiers ] ; 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 --------- ### 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. -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 - diff --git a/docs/TODO.md b/docs/TODO.md index 6eb3cb8..039f682 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -29,3 +29,15 @@ Add support for "Continuous Roll" labels 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. From 3a425f932a1fee57f46c3e25d8a6105d141a286f Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 17 Mar 2019 22:38:45 -0400 Subject: [PATCH 07/55] Include variables in glabels project file. --- glabels/ui/VariablesView.ui | 3 +++ model/Variable.cpp | 42 +++++++++++++++++++++++++++++++++ model/Variable.h | 10 ++++---- model/XmlLabelCreator.cpp | 35 +++++++++++++++++++++++++++ model/XmlLabelCreator.h | 3 +++ model/XmlLabelParser.cpp | 47 +++++++++++++++++++++++++++++++------ model/XmlLabelParser.h | 3 ++- templates/glabels-4.0.dtd | 20 +++++++++++++++- 8 files changed, 150 insertions(+), 13 deletions(-) diff --git a/glabels/ui/VariablesView.ui b/glabels/ui/VariablesView.ui index 04ec15b..801bb2c 100644 --- a/glabels/ui/VariablesView.ui +++ b/glabels/ui/VariablesView.ui @@ -38,6 +38,9 @@ 5 + + false + Name diff --git a/model/Variable.cpp b/model/Variable.cpp index e4a3432..b424a6b 100644 --- a/model/Variable.cpp +++ b/model/Variable.cpp @@ -95,6 +95,23 @@ namespace glabels } + Variable::Type Variable::idStringToType( const QString& string ) + { + if ( string == "numeric" ) + { + return Type::NUMERIC; + } + else if ( string == "string" ) + { + return Type::STRING; + } + else + { + return Type::STRING; // Default + } + } + + QString Variable::incrementToI18nString( Increment increment ) { switch (increment) @@ -127,5 +144,30 @@ namespace glabels } + Variable::Increment Variable::idStringToIncrement( const QString& string ) + { + if ( string == "never" ) + { + return Increment::NEVER; + } + else if ( string == "per_copy" ) + { + return Increment::PER_COPY; + } + else if ( string == "per_merge_record" ) + { + return Increment::PER_MERGE_RECORD; + } + else if ( string == "per_page" ) + { + return Increment::PER_PAGE; + } + else + { + return Increment::NEVER; // Default + } + } + + } } diff --git a/model/Variable.h b/model/Variable.h index d314642..0a90733 100644 --- a/model/Variable.h +++ b/model/Variable.h @@ -70,11 +70,13 @@ namespace glabels QString stepSize() const; - static QString typeToI18nString( Type type ); - static QString typeToIdString( Type type ); + 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 QString incrementToI18nString( Increment increment ); + static QString incrementToIdString( Increment increment ); + static Increment idStringToIncrement( const QString& string ); private: diff --git a/model/XmlLabelCreator.cpp b/model/XmlLabelCreator.cpp index 87b3114..2a31cf0 100644 --- a/model/XmlLabelCreator.cpp +++ b/model/XmlLabelCreator.cpp @@ -29,6 +29,7 @@ #include "ModelImageObject.h" #include "ModelTextObject.h" #include "DataCache.h" +#include "Variables.h" #include "XmlTemplateCreator.h" #include "XmlUtil.h" @@ -116,6 +117,11 @@ namespace glabels createMergeNode( root, label ); } + if ( label->variables()->size() != 0 ) + { + createVariablesNode( root, label ); + } + createDataNode( root, label->objectList() ); } @@ -466,6 +472,35 @@ namespace glabels } + void + XmlLabelCreator::createVariablesNode( QDomElement &parent, const Model* label ) + { + QDomDocument doc = parent.ownerDocument(); + QDomElement node = doc.createElement( "Variables" ); + parent.appendChild( node ); + + for ( const auto& v : *label->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, "value", v.value() ); + XmlUtil::setStringAttr( node, "increment", Variable::incrementToIdString( v.increment() ) ); + XmlUtil::setStringAttr( node, "stepSize", v.stepSize() ); + } + + void XmlLabelCreator::createDataNode( QDomElement &parent, const QList& objects ) { diff --git a/model/XmlLabelCreator.h b/model/XmlLabelCreator.h index 93c235e..2e3d87a 100644 --- a/model/XmlLabelCreator.h +++ b/model/XmlLabelCreator.h @@ -40,6 +40,7 @@ namespace glabels class ModelImageObject; class ModelBarcodeObject; class ModelTextObject; + class Variable; /// @@ -72,6 +73,8 @@ namespace glabels static void createAffineAttrs( QDomElement &node, const ModelObject* object ); static void createShadowAttrs( QDomElement &node, const ModelObject* object ); static void createMergeNode( QDomElement &parent, const Model* label ); + static void createVariablesNode( QDomElement &parent, const Model* label ); + static void createVariableNode( QDomElement &parent, const Variable& v ); static void createDataNode( QDomElement &parent, const QList& objects ); static void createPngFileNode( QDomElement &parent, const QString& name, const QImage& image ); static void createSvgFileNode( QDomElement &parent, const QString& name, const QByteArray& svg ); diff --git a/model/XmlLabelParser.cpp b/model/XmlLabelParser.cpp index 779149c..9412dd7 100644 --- a/model/XmlLabelParser.cpp +++ b/model/XmlLabelParser.cpp @@ -286,6 +286,10 @@ namespace glabels { parseMergeNode( child.toElement(), label ); } + else if ( tagName == "Variables" ) + { + parseVariablesNode( child.toElement(), label ); + } else if ( tagName == "Data" ) { /* Handled in pass 1. */ @@ -719,6 +723,42 @@ namespace glabels } + void + XmlLabelParser::parseVariablesNode( const QDomElement &node, Model* label ) + { + for ( QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling() ) + { + QString tagName = child.toElement().tagName(); + + if ( tagName == "Variable" ) + { + parseVariableNode( child.toElement(), label ); + } + else if ( !child.isComment() ) + { + qWarning() << "Unexpected" << node.tagName() << "child:" << tagName; + } + } + } + + + void + XmlLabelParser::parseVariableNode( const QDomElement &node, Model* label ) + { + QString typeString = XmlUtil::getStringAttr( node, "type", "string" ); + QString name = XmlUtil::getStringAttr( node, "name", "unknown" ); + QString value = XmlUtil::getStringAttr( node, "value", "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, value, increment, stepSize ); + label->variables()->addVariable( v ); + } + + void XmlLabelParser::parseDataNode( const QDomElement &node, DataCache& data ) { @@ -738,13 +778,6 @@ namespace glabels } - void - XmlLabelParser::parsePixdataNode( const QDomElement& node, DataCache& data ) - { - // TODO, compatibility with glabels-3 - } - - void XmlLabelParser::parseFileNode( const QDomElement& node, DataCache& data ) { diff --git a/model/XmlLabelParser.h b/model/XmlLabelParser.h index f135860..c13edf4 100644 --- a/model/XmlLabelParser.h +++ b/model/XmlLabelParser.h @@ -68,8 +68,9 @@ namespace glabels static QString parsePNode( const QDomElement &node ); static bool parseRotateAttr( const QDomElement &node ); static void parseMergeNode( const QDomElement &node, Model* label ); + static void parseVariablesNode( const QDomElement &node, Model* label ); + static void parseVariableNode( const QDomElement &node, Model* label ); static void parseDataNode( const QDomElement &node, DataCache& data ); - static void parsePixdataNode( const QDomElement &node, DataCache& data ); static void parseFileNode( const QDomElement &node, DataCache& data ); }; diff --git a/templates/glabels-4.0.dtd b/templates/glabels-4.0.dtd index 5834460..a883c94 100644 --- a/templates/glabels-4.0.dtd +++ b/templates/glabels-4.0.dtd @@ -87,6 +87,10 @@ iec16022)" --> + + + + @@ -139,7 +143,7 @@ - + + + + + + + + + From ff15eb1d7e023a9a52e57d2881ec194f8dd86252 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Fri, 22 Mar 2019 20:06:57 -0400 Subject: [PATCH 08/55] Disable focus on QTableWidgets. No more annoying highlighted cell. --- glabels/ui/MergeView.ui | 6 +++++- glabels/ui/VariablesView.ui | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/glabels/ui/MergeView.ui b/glabels/ui/MergeView.ui index e29278c..89517fd 100644 --- a/glabels/ui/MergeView.ui +++ b/glabels/ui/MergeView.ui @@ -98,7 +98,11 @@ - + + + Qt::NoFocus + + diff --git a/glabels/ui/VariablesView.ui b/glabels/ui/VariablesView.ui index 801bb2c..5758b63 100644 --- a/glabels/ui/VariablesView.ui +++ b/glabels/ui/VariablesView.ui @@ -29,6 +29,9 @@ + + Qt::NoFocus + QAbstractItemView::SingleSelection @@ -41,6 +44,9 @@ false + + true + Name From dedbe073128f3d0807110448492c10ea2178d570 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Fri, 22 Mar 2019 23:23:50 -0400 Subject: [PATCH 09/55] Populate VariablesView headers in class rather than ui/. --- glabels/VariablesView.cpp | 39 +++++++++++++++++++++++++++++++----- glabels/ui/VariablesView.ui | 27 +------------------------ translations/glabels_C.ts | 40 ++++++++++++++++++------------------- 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/glabels/VariablesView.cpp b/glabels/VariablesView.cpp index 0546566..a54a43f 100644 --- a/glabels/VariablesView.cpp +++ b/glabels/VariablesView.cpp @@ -29,11 +29,13 @@ namespace { enum ICol { - I_COL_NAME = 0, - I_COL_TYPE = 1, - I_COL_VALUE = 2, - I_COL_INCREMENT = 3, - I_COL_STEP_SIZE = 4 + I_COL_NAME, + I_COL_TYPE, + I_COL_VALUE, + I_COL_INCREMENT, + I_COL_STEP_SIZE, + I_COL_DUMMY, + N_COLS }; } @@ -50,6 +52,33 @@ namespace glabels setupUi( this ); titleLabel->setText( QString( "%1" ).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 ); } diff --git a/glabels/ui/VariablesView.ui b/glabels/ui/VariablesView.ui index 5758b63..a801498 100644 --- a/glabels/ui/VariablesView.ui +++ b/glabels/ui/VariablesView.ui @@ -39,7 +39,7 @@ QAbstractItemView::SelectRows - 5 + 0 false @@ -47,31 +47,6 @@ true - - - Name - - - - - Type - - - - - Value - - - - - Increment - - - - - Step Size - - diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 5708957..fb84528 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -1087,26 +1087,6 @@ VariablesView - - Name - - - - Type - - - - Value - - - - Increment - - - - Step Size - - <html><head/><body><p>Add variable</p></body></html> @@ -2153,6 +2133,26 @@ Edit Variable + + Name + + + + Type + + + + Value + + + + Increment + + + + Step Size + + glabels::barcode::Backends From 37f0a8890d195084d02800357072896f69ee77d4 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 24 Mar 2019 17:49:41 -0400 Subject: [PATCH 10/55] Implemented variable substitution in simple print jobs. --- glabels/EditVariableDialog.cpp | 42 +++++-- glabels/LabelEditor.cpp | 2 +- glabels/VariablesView.cpp | 6 +- glabels/ui/EditVariableDialog.ui | 6 +- model/Model.cpp | 4 +- model/Model.h | 5 +- model/ModelBarcodeObject.cpp | 13 +- model/ModelBarcodeObject.h | 19 ++- model/ModelBoxObject.cpp | 10 +- model/ModelBoxObject.h | 12 +- model/ModelEllipseObject.cpp | 10 +- model/ModelEllipseObject.h | 12 +- model/ModelImageObject.cpp | 10 +- model/ModelImageObject.h | 12 +- model/ModelLineObject.cpp | 10 +- model/ModelLineObject.h | 12 +- model/ModelObject.cpp | 9 +- model/ModelObject.h | 19 ++- model/ModelTextObject.cpp | 21 ++-- model/ModelTextObject.h | 27 +++- model/PageRenderer.cpp | 62 +++++---- model/PageRenderer.h | 4 +- model/RawText.cpp | 4 +- model/RawText.h | 2 +- model/SubstitutionField.cpp | 18 ++- model/SubstitutionField.h | 3 +- model/Variable.cpp | 139 ++++++++++++++++++--- model/Variable.h | 21 +++- model/Variables.cpp | 48 +++++++ model/Variables.h | 5 + model/XmlLabelCreator.cpp | 2 +- model/XmlLabelParser.cpp | 4 +- model/unit_tests/TestSubstitutionField.cpp | 106 +++++++++------- translations/glabels_C.ts | 38 +++--- 34 files changed, 524 insertions(+), 193 deletions(-) diff --git a/glabels/EditVariableDialog.cpp b/glabels/EditVariableDialog.cpp index 2abcb12..4d3b84d 100644 --- a/glabels/EditVariableDialog.cpp +++ b/glabels/EditVariableDialog.cpp @@ -29,8 +29,9 @@ namespace { // All variable types. (must be in sorted order) const QVector allTypes = { - glabels::model::Variable::Type::NUMERIC, - glabels::model::Variable::Type::STRING + glabels::model::Variable::Type::STRING, + glabels::model::Variable::Type::INTEGER, + glabels::model::Variable::Type::FLOATING_POINT }; // All variable increments. (must be in sorted order) @@ -76,7 +77,7 @@ namespace glabels { typeCombo->setCurrentIndex( static_cast(variable.type()) ); nameEdit->setText( variable.name() ); - valueEdit->setText( variable.value() ); + valueEdit->setText( variable.initialValue() ); incrementCombo->setCurrentIndex( static_cast(variable.increment()) ); stepSizeEdit->setText( variable.stepSize() ); @@ -150,8 +151,20 @@ namespace glabels auto type = static_cast(typeCombo->currentIndex()); auto increment = static_cast(incrementCombo->currentIndex()); - if ( type == model::Variable::Type::NUMERIC ) + switch (type) { + + case model::Variable::Type::INTEGER: + valueEdit->setValidator( new QIntValidator() ); + stepSizeEdit->setValidator( new QIntValidator() ); + + if ( increment == model::Variable::Increment::NEVER ) + { + stepSizeEdit->setText( "0" ); + } + break; + + case model::Variable::Type::FLOATING_POINT: valueEdit->setValidator( new QDoubleValidator() ); stepSizeEdit->setValidator( new QDoubleValidator() ); @@ -159,21 +172,24 @@ namespace glabels { stepSizeEdit->setText( "0" ); } - } - else - { + break; + + default: valueEdit->setValidator( nullptr ); stepSizeEdit->setValidator( nullptr ); incrementCombo->setCurrentIndex( static_cast(model::Variable::Increment::NEVER) ); stepSizeEdit->setText( "" ); + break; + } - incrementLabel->setEnabled( type == model::Variable::Type::NUMERIC ); - incrementCombo->setEnabled( type == model::Variable::Type::NUMERIC ); - stepSizeLabel->setEnabled( (type == model::Variable::Type::NUMERIC) && - (increment != model::Variable::Increment::NEVER) ); - stepSizeEdit->setEnabled( (type == model::Variable::Type::NUMERIC) && - (increment != model::Variable::Increment::NEVER) ); + bool isNumeric = ( type == model::Variable::Type::INTEGER ) || + ( type == model::Variable::Type::FLOATING_POINT ); + + incrementLabel->setEnabled( isNumeric ); + incrementCombo->setEnabled( isNumeric ); + stepSizeLabel->setEnabled( isNumeric && (increment != model::Variable::Increment::NEVER) ); + stepSizeEdit->setEnabled( isNumeric && (increment != model::Variable::Increment::NEVER) ); validateCurrentInputs(); } diff --git a/glabels/LabelEditor.cpp b/glabels/LabelEditor.cpp index ef7fe05..82c272a 100644 --- a/glabels/LabelEditor.cpp +++ b/glabels/LabelEditor.cpp @@ -1157,7 +1157,7 @@ namespace glabels void LabelEditor::drawObjectsLayer( QPainter* painter ) { - mModel->draw( painter ); + mModel->draw( painter, true, nullptr, nullptr ); } diff --git a/glabels/VariablesView.cpp b/glabels/VariablesView.cpp index a54a43f..9487085 100644 --- a/glabels/VariablesView.cpp +++ b/glabels/VariablesView.cpp @@ -63,7 +63,7 @@ namespace glabels typeHeaderItem->setFlags( typeHeaderItem->flags() ^ Qt::ItemIsEditable ); table->setHorizontalHeaderItem( I_COL_TYPE, typeHeaderItem ); - auto* valueHeaderItem = new QTableWidgetItem( tr("Value") ); + auto* valueHeaderItem = new QTableWidgetItem( tr("Initial Value") ); valueHeaderItem->setFlags( valueHeaderItem->flags() ^ Qt::ItemIsEditable ); table->setHorizontalHeaderItem( I_COL_VALUE, valueHeaderItem ); @@ -122,7 +122,7 @@ namespace glabels { EditVariableDialog dialog( this ); - model::Variable v( model::Variable::Type::NUMERIC, + model::Variable v( model::Variable::Type::INTEGER, "x", "0", model::Variable::Increment::NEVER, @@ -216,7 +216,7 @@ namespace glabels nameItem->setFlags( nameItem->flags() ^ Qt::ItemIsEditable ); table->setItem( iRow, I_COL_NAME, nameItem ); - auto* valueItem = new QTableWidgetItem( v.value() ); + auto* valueItem = new QTableWidgetItem( v.initialValue() ); valueItem->setFlags( valueItem->flags() ^ Qt::ItemIsEditable ); table->setItem( iRow, I_COL_VALUE, valueItem ); diff --git a/glabels/ui/EditVariableDialog.ui b/glabels/ui/EditVariableDialog.ui index 11399a7..af81a20 100644 --- a/glabels/ui/EditVariableDialog.ui +++ b/glabels/ui/EditVariableDialog.ui @@ -19,7 +19,7 @@ - Variable Type: + Variable type: @@ -39,7 +39,7 @@ - Value: + Initial value: @@ -61,7 +61,7 @@ - Step Size: + Step size: diff --git a/model/Model.cpp b/model/Model.cpp index 896970d..4fe8b34 100644 --- a/model/Model.cpp +++ b/model/Model.cpp @@ -1476,11 +1476,11 @@ namespace glabels /// /// 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 ) { - object->draw( painter, inEditor, record ); + object->draw( painter, inEditor, record, variables ); } } diff --git a/model/Model.h b/model/Model.h index 13b9f4c..cfd74c8 100644 --- a/model/Model.h +++ b/model/Model.h @@ -208,7 +208,10 @@ namespace glabels // Drawing operations ///////////////////////////////// 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; ///////////////////////////////// diff --git a/model/ModelBarcodeObject.cpp b/model/ModelBarcodeObject.cpp index 315632e..3b65e10 100644 --- a/model/ModelBarcodeObject.cpp +++ b/model/ModelBarcodeObject.cpp @@ -311,7 +311,8 @@ namespace glabels /// void ModelBarcodeObject::drawShadow( QPainter* painter, bool inEditor, - merge::Record* record ) const + merge::Record* record, + Variables* variables ) const { // Barcodes don't support shadows. } @@ -322,7 +323,8 @@ namespace glabels /// void ModelBarcodeObject::drawObject( QPainter* painter, bool inEditor, - merge::Record* record ) const + merge::Record* record, + Variables* variables ) const { QColor bcColor = mBcColorNode.color( record ); @@ -332,7 +334,7 @@ namespace glabels } else { - drawBc( painter, bcColor, record ); + drawBc( painter, bcColor, record, variables ); } } @@ -450,7 +452,8 @@ namespace glabels void ModelBarcodeObject::drawBc( QPainter* painter, const QColor& color, - merge::Record* record ) const + merge::Record* record, + Variables* variables ) const { painter->setPen( QPen( color ) ); @@ -458,7 +461,7 @@ namespace glabels bc->setChecksum(mBcChecksumFlag); 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); bc->render( renderer ); diff --git a/model/ModelBarcodeObject.h b/model/ModelBarcodeObject.h index 4931ddf..bd32091 100644 --- a/model/ModelBarcodeObject.h +++ b/model/ModelBarcodeObject.h @@ -126,8 +126,16 @@ namespace glabels // Drawing operations /////////////////////////////////////////////////////////////// protected: - void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override; - void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override; + void drawShadow( QPainter* painter, + 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; @@ -139,7 +147,12 @@ namespace glabels void update(); 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; diff --git a/model/ModelBoxObject.cpp b/model/ModelBoxObject.cpp index 94e81d5..24a61c6 100644 --- a/model/ModelBoxObject.cpp +++ b/model/ModelBoxObject.cpp @@ -103,7 +103,10 @@ namespace glabels /// /// 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 fillColor = mFillColorNode.color( record ); @@ -148,7 +151,10 @@ namespace glabels /// /// 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 fillColor = mFillColorNode.color( record ); diff --git a/model/ModelBoxObject.h b/model/ModelBoxObject.h index 8705c99..3c784c6 100644 --- a/model/ModelBoxObject.h +++ b/model/ModelBoxObject.h @@ -72,8 +72,16 @@ namespace glabels // Drawing operations /////////////////////////////////////////////////////////////// protected: - void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override; - void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override; + void drawShadow( QPainter* painter, + 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; }; diff --git a/model/ModelEllipseObject.cpp b/model/ModelEllipseObject.cpp index c3ca82e..e9e58fd 100644 --- a/model/ModelEllipseObject.cpp +++ b/model/ModelEllipseObject.cpp @@ -103,7 +103,10 @@ namespace glabels /// /// 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 fillColor = mFillColorNode.color( record ); @@ -148,7 +151,10 @@ namespace glabels /// /// 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 fillColor = mFillColorNode.color( record ); diff --git a/model/ModelEllipseObject.h b/model/ModelEllipseObject.h index e26e9ba..cd22cc9 100644 --- a/model/ModelEllipseObject.h +++ b/model/ModelEllipseObject.h @@ -72,8 +72,16 @@ namespace glabels // Drawing operations /////////////////////////////////////////////////////////////// protected: - void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override; - void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override; + void drawShadow( QPainter* painter, + 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; }; diff --git a/model/ModelImageObject.cpp b/model/ModelImageObject.cpp index 5848625..bc9eb18 100644 --- a/model/ModelImageObject.cpp +++ b/model/ModelImageObject.cpp @@ -395,7 +395,10 @@ namespace glabels /// /// 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() ); @@ -424,7 +427,10 @@ namespace glabels /// /// 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() ); diff --git a/model/ModelImageObject.h b/model/ModelImageObject.h index ba87078..d1c62a0 100644 --- a/model/ModelImageObject.h +++ b/model/ModelImageObject.h @@ -132,8 +132,16 @@ namespace glabels // Drawing operations /////////////////////////////////////////////////////////////// protected: - void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override; - void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override; + void drawShadow( QPainter* painter, + 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; diff --git a/model/ModelLineObject.cpp b/model/ModelLineObject.cpp index 5d7b5e1..9223f91 100644 --- a/model/ModelLineObject.cpp +++ b/model/ModelLineObject.cpp @@ -186,7 +186,10 @@ namespace glabels /// /// 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 shadowColor = mShadowColorNode.color( record ); @@ -204,7 +207,10 @@ namespace glabels /// /// 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 ); diff --git a/model/ModelLineObject.h b/model/ModelLineObject.h index 16cfdb6..a09670e 100644 --- a/model/ModelLineObject.h +++ b/model/ModelLineObject.h @@ -97,8 +97,16 @@ namespace glabels // Drawing operations /////////////////////////////////////////////////////////////// protected: - void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override; - void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override; + void drawShadow( QPainter* painter, + 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; diff --git a/model/ModelObject.cpp b/model/ModelObject.cpp index 637352c..c79c9f2 100644 --- a/model/ModelObject.cpp +++ b/model/ModelObject.cpp @@ -1200,7 +1200,10 @@ namespace glabels /// /// 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->translate( mX0.pt(), mY0.pt() ); @@ -1210,12 +1213,12 @@ namespace glabels painter->save(); painter->translate( mShadowX.pt(), mShadowY.pt() ); painter->setMatrix( mMatrix, true ); - drawShadow( painter, inEditor, record ); + drawShadow( painter, inEditor, record, variables ); painter->restore(); } painter->setMatrix( mMatrix, true ); - drawObject( painter, inEditor, record ); + drawObject( painter, inEditor, record, variables ); painter->restore(); } diff --git a/model/ModelObject.h b/model/ModelObject.h index 6af51e8..e7a6c2f 100644 --- a/model/ModelObject.h +++ b/model/ModelObject.h @@ -27,6 +27,7 @@ #include "Handles.h" #include "Outline.h" #include "TextNode.h" +#include "Variables.h" #include "barcode/Style.h" #include "merge/Record.h" @@ -403,12 +404,24 @@ namespace glabels // Drawing operations /////////////////////////////////////////////////////////////// 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; protected: - virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0; - virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0; + virtual void drawShadow( QPainter* painter, + 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 void sizeUpdated(); diff --git a/model/ModelTextObject.cpp b/model/ModelTextObject.cpp index 434d48b..45c259e 100644 --- a/model/ModelTextObject.cpp +++ b/model/ModelTextObject.cpp @@ -518,7 +518,8 @@ namespace glabels /// void ModelTextObject::drawShadow( QPainter* painter, bool inEditor, - merge::Record* record ) const + merge::Record* record, + Variables* variables ) const { QColor textColor = mTextColorNode.color( record ); @@ -533,7 +534,7 @@ namespace glabels } else { - drawText( painter, shadowColor, record ); + drawText( painter, shadowColor, record, variables ); } } } @@ -544,7 +545,8 @@ namespace glabels /// void ModelTextObject::drawObject( QPainter* painter, bool inEditor, - merge::Record* record ) const + merge::Record* record, + Variables* variables ) const { QColor textColor = mTextColorNode.color( record ); @@ -554,7 +556,7 @@ namespace glabels } else { - drawText( painter, textColor, record ); + drawText( painter, textColor, record, variables ); } } @@ -696,7 +698,8 @@ namespace glabels void ModelTextObject::drawText( QPainter* painter, const QColor& color, - merge::Record* record ) const + merge::Record* record, + Variables* variables ) const { painter->save(); @@ -704,7 +707,7 @@ namespace glabels QFont font; font.setFamily( mFontFamily ); - font.setPointSizeF( mTextAutoShrink ? autoShrinkFontSize( record ) : mFontSize ); + font.setPointSizeF( mTextAutoShrink ? autoShrinkFontSize( record, variables ) : mFontSize ); font.setWeight( mFontWeight ); font.setItalic( mFontItalicFlag ); font.setUnderline( mFontUnderlineFlag ); @@ -716,7 +719,7 @@ namespace glabels QFontMetricsF fontMetrics( font ); double dy = fontMetrics.lineSpacing() * mTextLineSpacing; - QTextDocument document( mText.expand( record ) ); + QTextDocument document( mText.expand( record, variables ) ); QList layouts; @@ -790,7 +793,7 @@ namespace glabels /// Determine auto shrink font size /// double - ModelTextObject::autoShrinkFontSize( merge::Record* record ) const + ModelTextObject::autoShrinkFontSize( merge::Record* record, Variables* variables ) const { QFont font; font.setFamily( mFontFamily ); @@ -802,7 +805,7 @@ namespace glabels textOption.setAlignment( mTextHAlign ); textOption.setWrapMode( mTextWrapMode ); - QTextDocument document( mText.expand( record ) ); + QTextDocument document( mText.expand( record, variables ) ); double candidateSize = mFontSize; while ( candidateSize > 1.0 ) diff --git a/model/ModelTextObject.h b/model/ModelTextObject.h index 1ab62c6..d15a624 100644 --- a/model/ModelTextObject.h +++ b/model/ModelTextObject.h @@ -185,8 +185,16 @@ namespace glabels // Drawing operations /////////////////////////////////////////////////////////////// protected: - void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override; - void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override; + void drawShadow( QPainter* painter, + 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; @@ -196,10 +204,17 @@ namespace glabels private: void sizeUpdated() override; void update(); - void drawTextInEditor( QPainter* painter, const QColor& color ) const; - void drawText( QPainter* painter, const QColor&color, merge::Record* record ) const; - QString expandText( QString text, merge::Record* record ) const; - double autoShrinkFontSize( merge::Record* record ) const; + + void drawTextInEditor( QPainter* painter, + const QColor& color ) const; + + void drawText( QPainter* painter, + const QColor& color, + merge::Record* record, + Variables* variables ) const; + + double autoShrinkFontSize( merge::Record* record, + Variables* variables ) const; /////////////////////////////////////////////////////////////// diff --git a/model/PageRenderer.cpp b/model/PageRenderer.cpp index 9c2b702..f1ada0f 100644 --- a/model/PageRenderer.cpp +++ b/model/PageRenderer.cpp @@ -47,7 +47,7 @@ namespace glabels 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), mIPage(0), mIsMerge(false), mNPages(0), mNLabelsPerPage(0) { @@ -65,6 +65,7 @@ namespace glabels connect( mModel, SIGNAL(changed()), this, SLOT(onModelChanged()) ); onModelChanged(); + mVariables = mModel->variables(); } @@ -249,37 +250,44 @@ namespace glabels 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 ); - 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->save(); - painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() ); + painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() ); - painter->save(); + painter->save(); - clipLabel( painter ); - printLabel( painter, nullptr ); + clipLabel( painter ); + printLabel( painter, nullptr, mVariables ); - painter->restore(); // From before clip + painter->restore(); // From before clip - printOutline( painter ); + printOutline( painter ); - painter->restore(); // From before translation + painter->restore(); // From before translation + } + + iCopy++; + iLabel++; + iCurrentPage = iLabel / mNLabelsPerPage; + + mVariables->incrementVariablesOnCopy(); + if ( (iLabel % mNLabelsPerPage) == 0 /* starting a new page */ ) + { + mVariables->incrementVariablesOnPage(); + } } } @@ -317,7 +325,7 @@ namespace glabels painter->save(); clipLabel( painter ); - printLabel( painter, records[iRecord] ); + printLabel( painter, records[iRecord], mVariables ); painter->restore(); // From before clip @@ -411,7 +419,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(); @@ -427,7 +437,7 @@ namespace glabels painter->scale( -1, 1 ); } - mModel->draw( painter, false, record ); + mModel->draw( painter, false, record, variables ); painter->restore(); } diff --git a/model/PageRenderer.h b/model/PageRenderer.h index 2db3ae4..08c93a9 100644 --- a/model/PageRenderer.h +++ b/model/PageRenderer.h @@ -23,6 +23,7 @@ #include "Point.h" +#include "Variables.h" #include "merge/Merge.h" #include "merge/Record.h" @@ -100,7 +101,7 @@ namespace glabels void printCropMarks( QPainter* painter ) const; void printOutline( 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: const Model* mModel; const merge::Merge* mMerge; + Variables* mVariables; int mNCopies; int mStartLabel; diff --git a/model/RawText.cpp b/model/RawText.cpp index 08ee6bf..ed4cd29 100644 --- a/model/RawText.cpp +++ b/model/RawText.cpp @@ -66,7 +66,7 @@ namespace glabels /// /// Expand all place holders /// - QString RawText::expand( merge::Record* record ) const + QString RawText::expand( merge::Record* record, Variables* variables ) const { QString text; @@ -74,7 +74,7 @@ namespace glabels { if ( token.isField ) { - text += token.field.evaluate( record ); + text += token.field.evaluate( record, variables ); } else { diff --git a/model/RawText.h b/model/RawText.h index 9b19084..2e8ab44 100644 --- a/model/RawText.h +++ b/model/RawText.h @@ -52,7 +52,7 @@ namespace glabels ///////////////////////////////// QString toString() const; std::string toStdString() const; - QString expand( merge::Record* record ) const; + QString expand( merge::Record* record, Variables* variables ) const; bool hasPlaceHolders() const; bool isEmpty() const; diff --git a/model/SubstitutionField.cpp b/model/SubstitutionField.cpp index 178b73e..76c4047 100644 --- a/model/SubstitutionField.cpp +++ b/model/SubstitutionField.cpp @@ -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; - 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); } + else if ( haveVariable ) + { + value = (*variables)[mFieldName].value(); + } if ( !mFormatType.isNull() ) { value = formatValue( value ); } - if ( record && record->contains(mFieldName) && !record->value(mFieldName).isEmpty() && mNewLine ) + if ( mNewLine && (haveRecordField || haveVariable) ) { value = "\n" + value; } diff --git a/model/SubstitutionField.h b/model/SubstitutionField.h index ec08a00..baaa255 100644 --- a/model/SubstitutionField.h +++ b/model/SubstitutionField.h @@ -21,6 +21,7 @@ #ifndef model_SubstitutionField_h #define model_SubstitutionField_h +#include "Variables.h" #include "merge/Record.h" @@ -39,7 +40,7 @@ namespace glabels SubstitutionField(); 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 defaultValue() const; diff --git a/model/Variable.cpp b/model/Variable.cpp index b424a6b..8b81a86 100644 --- a/model/Variable.cpp +++ b/model/Variable.cpp @@ -28,12 +28,12 @@ namespace glabels Variable::Variable( Variable::Type type, const QString& name, - const QString& value, + const QString& initialValue, Variable::Increment increment, const QString& stepSize ) : mType(type), mName(name), - mValue(value), + mInitialValue(initialValue), mIncrement(increment), mStepSize(stepSize) { @@ -53,9 +53,9 @@ namespace glabels } - QString Variable::value() const + QString Variable::initialValue() const { - return mValue; + return mInitialValue; } @@ -70,15 +70,110 @@ namespace glabels 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; + } + } + + 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; + } + } + } + + + void Variable::incrementValueOnMerge() + { + if ( mIncrement == Increment::PER_MERGE_RECORD ) + { + switch (mType) + { + case Type::STRING: + // do nothing + break; + case Type::INTEGER: + mIntegerValue += mIntegerStep; + break; + case Type::FLOATING_POINT: + mFloatingPointValue += mFloatingPointStep; + 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; + } + } + } + + + 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 ); + } + } + + QString Variable::typeToI18nString( Type type ) { switch (type) { - case Type::NUMERIC: - return tr("Numeric"); case Type::STRING: return tr("String"); + case Type::INTEGER: + return tr("Integer"); + case Type::FLOATING_POINT: + return tr("Floating Point"); } } @@ -87,24 +182,30 @@ namespace glabels { switch (type) { - case Type::NUMERIC: - return "numeric"; case Type::STRING: return "string"; + case Type::INTEGER: + return "integer"; + case Type::FLOATING_POINT: + return "float"; } } - Variable::Type Variable::idStringToType( const QString& string ) + Variable::Type Variable::idStringToType( const QString& id ) { - if ( string == "numeric" ) - { - return Type::NUMERIC; - } - else if ( string == "string" ) + if ( id == "string" ) { return Type::STRING; } + else if ( id == "integer" ) + { + return Type::INTEGER; + } + else if ( id == "float" ) + { + return Type::FLOATING_POINT; + } else { return Type::STRING; // Default @@ -144,21 +245,21 @@ namespace glabels } - Variable::Increment Variable::idStringToIncrement( const QString& string ) + Variable::Increment Variable::idStringToIncrement( const QString& id ) { - if ( string == "never" ) + if ( id == "never" ) { return Increment::NEVER; } - else if ( string == "per_copy" ) + else if ( id == "per_copy" ) { return Increment::PER_COPY; } - else if ( string == "per_merge_record" ) + else if ( id == "per_merge_record" ) { return Increment::PER_MERGE_RECORD; } - else if ( string == "per_page" ) + else if ( id == "per_page" ) { return Increment::PER_PAGE; } diff --git a/model/Variable.h b/model/Variable.h index 0a90733..3feb694 100644 --- a/model/Variable.h +++ b/model/Variable.h @@ -38,8 +38,9 @@ namespace glabels public: enum class Type { - NUMERIC, - STRING + STRING, + INTEGER, + FLOATING_POINT }; enum class Increment @@ -56,7 +57,7 @@ namespace glabels Variable( Type type, const QString& name, - const QString& value, + const QString& initialValue, Increment increment = Increment::NEVER, const QString& stepSize = "0" ); @@ -65,10 +66,15 @@ namespace glabels Type type() const; QString name() const; - QString value() const; + QString initialValue() const; Increment increment() const; QString stepSize() const; + void resetValue(); + void incrementValueOnCopy(); + void incrementValueOnMerge(); + void incrementValueOnPage(); + QString value() const; static QString typeToI18nString( Type type ); static QString typeToIdString( Type type ); @@ -82,10 +88,15 @@ namespace glabels private: Type mType; QString mName; - QString mValue; + QString mInitialValue; Increment mIncrement; QString mStepSize; + long long mIntegerValue; + long long mIntegerStep; + double mFloatingPointValue; + double mFloatingPointStep; + }; } diff --git a/model/Variables.cpp b/model/Variables.cpp index 24d414f..9bf149f 100644 --- a/model/Variables.cpp +++ b/model/Variables.cpp @@ -85,6 +85,54 @@ namespace glabels } + /// + /// Reset variables to their initial values + /// + void Variables::resetVariables() + { + for ( auto& v : *this ) + { + v.resetValue(); + } + } + + + /// + /// Increment variables on copy + /// + void Variables::incrementVariablesOnCopy() + { + for ( auto& v : *this ) + { + v.incrementValueOnCopy(); + } + } + + + /// + /// Increment variables on merge record + /// + void Variables::incrementVariablesOnMerge() + { + for ( auto& v : *this ) + { + v.incrementValueOnMerge(); + } + } + + + /// + /// Increment variables on page + /// + void Variables::incrementVariablesOnPage() + { + for ( auto& v : *this ) + { + v.incrementValueOnPage(); + } + } + + } // namespace model } // namespace glabels diff --git a/model/Variables.h b/model/Variables.h index 0c1a020..ec7b578 100644 --- a/model/Variables.h +++ b/model/Variables.h @@ -63,6 +63,11 @@ namespace glabels void deleteVariable( const QString& name ); void replaceVariable( const QString& name, const Variable& variable ); + void resetVariables(); + void incrementVariablesOnCopy(); + void incrementVariablesOnMerge(); + void incrementVariablesOnPage(); + ///////////////////////////////// // Signals diff --git a/model/XmlLabelCreator.cpp b/model/XmlLabelCreator.cpp index 2a31cf0..a546d14 100644 --- a/model/XmlLabelCreator.cpp +++ b/model/XmlLabelCreator.cpp @@ -495,7 +495,7 @@ namespace glabels XmlUtil::setStringAttr( node, "type", Variable::typeToIdString( v.type() ) ); XmlUtil::setStringAttr( node, "name", v.name() ); - XmlUtil::setStringAttr( node, "value", v.value() ); + XmlUtil::setStringAttr( node, "initialValue", v.initialValue() ); XmlUtil::setStringAttr( node, "increment", Variable::incrementToIdString( v.increment() ) ); XmlUtil::setStringAttr( node, "stepSize", v.stepSize() ); } diff --git a/model/XmlLabelParser.cpp b/model/XmlLabelParser.cpp index 9412dd7..07fd543 100644 --- a/model/XmlLabelParser.cpp +++ b/model/XmlLabelParser.cpp @@ -747,14 +747,14 @@ namespace glabels { QString typeString = XmlUtil::getStringAttr( node, "type", "string" ); QString name = XmlUtil::getStringAttr( node, "name", "unknown" ); - QString value = XmlUtil::getStringAttr( node, "value", "0" ); + 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, value, increment, stepSize ); + Variable v( type, name, initialValue, increment, stepSize ); label->variables()->addVariable( v ); } diff --git a/model/unit_tests/TestSubstitutionField.cpp b/model/unit_tests/TestSubstitutionField.cpp index fa9135a..04476b6 100644 --- a/model/unit_tests/TestSubstitutionField.cpp +++ b/model/unit_tests/TestSubstitutionField.cpp @@ -139,6 +139,8 @@ void TestSubstitutionField::simpleEvaluation() { using namespace glabels; + model::Variables variables; + model::SubstitutionField f1( "${1}" ); model::SubstitutionField f2( "${2}" ); model::SubstitutionField f3( "${3}" ); @@ -150,10 +152,10 @@ void TestSubstitutionField::simpleEvaluation() record1[ "3" ] = "Opqrstu"; record1[ "4" ] = "Vwxyz!@"; - QCOMPARE( f1.evaluate( &record1 ), QString( "Abcdefg" ) ); - QCOMPARE( f2.evaluate( &record1 ), QString( "Hijklmn" ) ); - QCOMPARE( f3.evaluate( &record1 ), QString( "Opqrstu" ) ); - QCOMPARE( f4.evaluate( &record1 ), QString( "Vwxyz!@" ) ); + QCOMPARE( f1.evaluate( &record1, &variables ), QString( "Abcdefg" ) ); + QCOMPARE( f2.evaluate( &record1, &variables ), QString( "Hijklmn" ) ); + QCOMPARE( f3.evaluate( &record1, &variables ), QString( "Opqrstu" ) ); + QCOMPARE( f4.evaluate( &record1, &variables ), QString( "Vwxyz!@" ) ); merge::Record record2; record2[ "1" ] = "1234567"; @@ -161,10 +163,10 @@ void TestSubstitutionField::simpleEvaluation() record2[ "3" ] = "8901234"; record2[ "4" ] = "#$%^&*"; - QCOMPARE( f1.evaluate( &record2 ), QString( "1234567" ) ); - QCOMPARE( f2.evaluate( &record2 ), QString( "FooBar" ) ); - QCOMPARE( f3.evaluate( &record2 ), QString( "8901234" ) ); - QCOMPARE( f4.evaluate( &record2 ), QString( "#$%^&*" ) ); + QCOMPARE( f1.evaluate( &record2, &variables ), QString( "1234567" ) ); + QCOMPARE( f2.evaluate( &record2, &variables ), QString( "FooBar" ) ); + QCOMPARE( f3.evaluate( &record2, &variables ), QString( "8901234" ) ); + QCOMPARE( f4.evaluate( &record2, &variables ), QString( "#$%^&*" ) ); } @@ -172,6 +174,8 @@ void TestSubstitutionField::defaultValueEvaluation() { using namespace glabels; + model::Variables variables; + model::SubstitutionField f1( "${1:=foo1}" ); model::SubstitutionField f2( "${2:=foo2}" ); model::SubstitutionField f3( "${3:=foo3}" ); @@ -183,17 +187,17 @@ void TestSubstitutionField::defaultValueEvaluation() record1[ "3" ] = "Opqrstu"; record1[ "4" ] = "Vwxyz!@"; - QCOMPARE( f1.evaluate( &record1 ), QString( "Abcdefg" ) ); - QCOMPARE( f2.evaluate( &record1 ), QString( "Hijklmn" ) ); - QCOMPARE( f3.evaluate( &record1 ), QString( "Opqrstu" ) ); - QCOMPARE( f4.evaluate( &record1 ), QString( "Vwxyz!@" ) ); + QCOMPARE( f1.evaluate( &record1, &variables ), QString( "Abcdefg" ) ); + QCOMPARE( f2.evaluate( &record1, &variables ), QString( "Hijklmn" ) ); + QCOMPARE( f3.evaluate( &record1, &variables ), QString( "Opqrstu" ) ); + QCOMPARE( f4.evaluate( &record1, &variables ), QString( "Vwxyz!@" ) ); merge::Record record2; // All fields empty - QCOMPARE( f1.evaluate( &record2 ), QString( "foo1" ) ); - QCOMPARE( f2.evaluate( &record2 ), QString( "foo2" ) ); - QCOMPARE( f3.evaluate( &record2 ), QString( "foo3" ) ); - QCOMPARE( f4.evaluate( &record2 ), QString( "foo4" ) ); + QCOMPARE( f1.evaluate( &record2, &variables ), QString( "foo1" ) ); + QCOMPARE( f2.evaluate( &record2, &variables ), QString( "foo2" ) ); + QCOMPARE( f3.evaluate( &record2, &variables ), QString( "foo3" ) ); + QCOMPARE( f4.evaluate( &record2, &variables ), QString( "foo4" ) ); merge::Record record3; record3[ "1" ] = "xyzzy"; @@ -201,10 +205,10 @@ void TestSubstitutionField::defaultValueEvaluation() // Field "3" empty record3[ "4" ] = "plugh"; - QCOMPARE( f1.evaluate( &record3 ), QString( "xyzzy" ) ); - QCOMPARE( f2.evaluate( &record3 ), QString( "foo2" ) ); - QCOMPARE( f3.evaluate( &record3 ), QString( "foo3" ) ); - QCOMPARE( f4.evaluate( &record3 ), QString( "plugh" ) ); + QCOMPARE( f1.evaluate( &record3, &variables ), QString( "xyzzy" ) ); + QCOMPARE( f2.evaluate( &record3, &variables ), QString( "foo2" ) ); + QCOMPARE( f3.evaluate( &record3, &variables ), QString( "foo3" ) ); + QCOMPARE( f4.evaluate( &record3, &variables ), QString( "plugh" ) ); } @@ -212,6 +216,8 @@ void TestSubstitutionField::formattedStringEvaluation() { using namespace glabels; + model::Variables variables; + model::SubstitutionField f1( "${1:%10s}" ); model::SubstitutionField f2( "${2:%10s}" ); model::SubstitutionField f3( "${3:%10s}" ); @@ -233,15 +239,15 @@ void TestSubstitutionField::formattedStringEvaluation() record1[ "7" ] = "-100"; record1[ "8" ] = "3.14"; - QCOMPARE( f1.evaluate( &record1 ), QString( " 0" ) ); - QCOMPARE( f2.evaluate( &record1 ), QString( " 1" ) ); - QCOMPARE( f3.evaluate( &record1 ), QString( " -1" ) ); - QCOMPARE( f4.evaluate( &record1 ), QString( " 3.14" ) ); + QCOMPARE( f1.evaluate( &record1, &variables ), QString( " 0" ) ); + QCOMPARE( f2.evaluate( &record1, &variables ), QString( " 1" ) ); + QCOMPARE( f3.evaluate( &record1, &variables ), QString( " -1" ) ); + QCOMPARE( f4.evaluate( &record1, &variables ), QString( " 3.14" ) ); - QCOMPARE( f5.evaluate( &record1 ), QString( "0 " ) ); - QCOMPARE( f6.evaluate( &record1 ), QString( "100 " ) ); - QCOMPARE( f7.evaluate( &record1 ), QString( "-100 " ) ); - QCOMPARE( f8.evaluate( &record1 ), QString( "3.14 " ) ); + QCOMPARE( f5.evaluate( &record1, &variables ), QString( "0 " ) ); + QCOMPARE( f6.evaluate( &record1, &variables ), QString( "100 " ) ); + QCOMPARE( f7.evaluate( &record1, &variables ), QString( "-100 " ) ); + QCOMPARE( f8.evaluate( &record1, &variables ), QString( "3.14 " ) ); } @@ -249,6 +255,8 @@ void TestSubstitutionField::formattedFloatEvaluation() { using namespace glabels; + model::Variables variables; + model::SubstitutionField f1( "${1:%+5.2f}" ); model::SubstitutionField f2( "${2:%+5.2f}" ); model::SubstitutionField f3( "${3:%+5.2f}" ); @@ -270,15 +278,15 @@ void TestSubstitutionField::formattedFloatEvaluation() record1[ "7" ] = "-100"; record1[ "8" ] = "3.14"; - QCOMPARE( f1.evaluate( &record1 ), QString( "+0.00" ) ); - QCOMPARE( f2.evaluate( &record1 ), QString( "+1.00" ) ); - QCOMPARE( f3.evaluate( &record1 ), QString( "-1.00" ) ); - QCOMPARE( f4.evaluate( &record1 ), QString( "+3.14" ) ); + QCOMPARE( f1.evaluate( &record1, &variables ), QString( "+0.00" ) ); + QCOMPARE( f2.evaluate( &record1, &variables ), QString( "+1.00" ) ); + QCOMPARE( f3.evaluate( &record1, &variables ), QString( "-1.00" ) ); + QCOMPARE( f4.evaluate( &record1, &variables ), QString( "+3.14" ) ); - QCOMPARE( f5.evaluate( &record1 ), QString( "+0.00e+00" ) ); - QCOMPARE( f6.evaluate( &record1 ), QString( "+1.00e+02" ) ); - QCOMPARE( f7.evaluate( &record1 ), QString( "-1.00e+02" ) ); - QCOMPARE( f8.evaluate( &record1 ), QString( "+3.14e+00" ) ); + QCOMPARE( f5.evaluate( &record1, &variables ), QString( "+0.00e+00" ) ); + QCOMPARE( f6.evaluate( &record1, &variables ), QString( "+1.00e+02" ) ); + QCOMPARE( f7.evaluate( &record1, &variables ), QString( "-1.00e+02" ) ); + QCOMPARE( f8.evaluate( &record1, &variables ), QString( "+3.14e+00" ) ); } @@ -286,6 +294,8 @@ void TestSubstitutionField::formattedIntEvaluation() { using namespace glabels; + model::Variables variables; + model::SubstitutionField f1( "${1:%08d}" ); model::SubstitutionField f2( "${2:%08d}" ); model::SubstitutionField f3( "${3:%08d}" ); @@ -307,15 +317,15 @@ void TestSubstitutionField::formattedIntEvaluation() record1[ "7" ] = "-1"; record1[ "8" ] = "314"; - QCOMPARE( f1.evaluate( &record1 ), QString( "00000000" ) ); - QCOMPARE( f2.evaluate( &record1 ), QString( "00000001" ) ); - QCOMPARE( f3.evaluate( &record1 ), QString( "-0000001" ) ); - QCOMPARE( f4.evaluate( &record1 ), QString( "00000000" ) ); // Invalid integer value + QCOMPARE( f1.evaluate( &record1, &variables ), QString( "00000000" ) ); + QCOMPARE( f2.evaluate( &record1, &variables ), QString( "00000001" ) ); + QCOMPARE( f3.evaluate( &record1, &variables ), QString( "-0000001" ) ); + QCOMPARE( f4.evaluate( &record1, &variables ), QString( "00000000" ) ); // Invalid integer value - QCOMPARE( f5.evaluate( &record1 ), QString( "00000064" ) ); // 100(decimal) == 64(hex) - QCOMPARE( f6.evaluate( &record1 ), QString( "00000100" ) ); - QCOMPARE( f7.evaluate( &record1 ), QString( "00000000" ) ); // Invalid unsigned integer - QCOMPARE( f8.evaluate( &record1 ), QString( "0000013a" ) ); // 314(decimal) == 13a(hex) + QCOMPARE( f5.evaluate( &record1, &variables ), QString( "00000064" ) ); // 100(decimal) == 64(hex) + QCOMPARE( f6.evaluate( &record1, &variables ), QString( "00000100" ) ); + QCOMPARE( f7.evaluate( &record1, &variables ), QString( "00000000" ) ); // Invalid unsigned integer + QCOMPARE( f8.evaluate( &record1, &variables ), QString( "0000013a" ) ); // 314(decimal) == 13a(hex) } @@ -323,6 +333,8 @@ void TestSubstitutionField::newLineEvaluation() { using namespace glabels; + model::Variables variables; + model::SubstitutionField addr2( "${ADDR2:n}" ); QCOMPARE( addr2.fieldName(), QString( "ADDR2" ) ); QCOMPARE( addr2.newLine(), true ); @@ -336,7 +348,7 @@ void TestSubstitutionField::newLineEvaluation() merge::Record record3; // ADDR2 not defined - QCOMPARE( addr2.evaluate( &record1 ), QString( "\nApt. 5B" ) ); // Prepends a newline - QCOMPARE( addr2.evaluate( &record2 ), QString( "" ) ); // Evaluates empty - QCOMPARE( addr2.evaluate( &record3 ), QString( "" ) ); // Evaluates empty + QCOMPARE( addr2.evaluate( &record1, &variables ), QString( "\nApt. 5B" ) ); // Prepends a newline + QCOMPARE( addr2.evaluate( &record2, &variables ), QString( "" ) ); // Evaluates empty + QCOMPARE( addr2.evaluate( &record3, &variables ), QString( "" ) ); // Evaluates empty } diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index fb84528..f7cdb4e 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -184,24 +184,24 @@ Dialog - - Variable Type: - - Name: - - Value: - - Increment: - Step Size: + Variable type: + + + + Initial value: + + + + Step size: @@ -1060,10 +1060,6 @@ Variable - - Numeric - - String @@ -1084,6 +1080,14 @@ Per page + + Integer + + + + Floating Point + + VariablesView @@ -2141,10 +2145,6 @@ Type - - Value - - Increment @@ -2153,6 +2153,10 @@ Step Size + + Initial Value + + glabels::barcode::Backends From efbb052856a6c46345194895c5ef2ed6331efeec Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 24 Mar 2019 20:22:12 -0400 Subject: [PATCH 11/55] Implemented variables in merge print jobs. --- model/PageRenderer.cpp | 80 +++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/model/PageRenderer.cpp b/model/PageRenderer.cpp index f1ada0f..fc27d2c 100644 --- a/model/PageRenderer.cpp +++ b/model/PageRenderer.cpp @@ -294,46 +294,62 @@ namespace glabels 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 records = mMerge->selectedRecords(); - if ( records.size() ) - { - iRecord = (iPage*mNLabelsPerPage + iStart - mStartLabel) % records.size(); - } - printCropMarks( painter ); - for ( int i = iStart; i < iEnd; i++ ) + int iCopy = 0; + int iLabel = mStartLabel; + int iCurrentPage = 0; + + const QList records = mMerge->selectedRecords(); + int iRecord = 0; + int nRecords = records.size(); + + if ( nRecords == 0 ) { - painter->save(); - - painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() ); + return; + } - painter->save(); + mVariables->resetVariables(); - clipLabel( painter ); - printLabel( painter, records[iRecord], mVariables ); + while ( (iCopy < mNCopies) && (iCurrentPage <= iPage) ) + { + if ( iCurrentPage == iPage ) + { + int i = iLabel % mNLabelsPerPage; + + painter->save(); - painter->restore(); // From before clip - - printOutline( painter ); + painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() ); - painter->restore(); // From before translation + painter->save(); - iRecord = (iRecord + 1) % records.size(); + clipLabel( painter ); + printLabel( painter, records[iRecord], mVariables ); + + 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->incrementVariablesOnMerge(); + if ( iRecord == 0 ) + { + mVariables->incrementVariablesOnCopy(); + } + if ( (iLabel % mNLabelsPerPage) == 0 /* starting a new page */ ) + { + mVariables->incrementVariablesOnPage(); + } } } From 54a66dfd8f8d5bf588b4860da2dfadb0287f8e23 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 24 Mar 2019 22:33:40 -0400 Subject: [PATCH 12/55] Increment per item, not per merge record. --- glabels/EditVariableDialog.cpp | 2 +- model/PageRenderer.cpp | 3 ++- model/Variable.cpp | 24 ++++++++++++------------ model/Variable.h | 4 ++-- model/Variables.cpp | 24 ++++++++++++------------ model/Variables.h | 2 +- translations/glabels_C.ts | 8 ++++---- 7 files changed, 34 insertions(+), 33 deletions(-) diff --git a/glabels/EditVariableDialog.cpp b/glabels/EditVariableDialog.cpp index 4d3b84d..4a1135e 100644 --- a/glabels/EditVariableDialog.cpp +++ b/glabels/EditVariableDialog.cpp @@ -37,8 +37,8 @@ namespace // All variable increments. (must be in sorted order) const QVector allIncrements = { glabels::model::Variable::Increment::NEVER, + glabels::model::Variable::Increment::PER_ITEM, glabels::model::Variable::Increment::PER_COPY, - glabels::model::Variable::Increment::PER_MERGE_RECORD, glabels::model::Variable::Increment::PER_PAGE }; } diff --git a/model/PageRenderer.cpp b/model/PageRenderer.cpp index fc27d2c..8af7d17 100644 --- a/model/PageRenderer.cpp +++ b/model/PageRenderer.cpp @@ -283,6 +283,7 @@ namespace glabels iLabel++; iCurrentPage = iLabel / mNLabelsPerPage; + mVariables->incrementVariablesOnItem(); mVariables->incrementVariablesOnCopy(); if ( (iLabel % mNLabelsPerPage) == 0 /* starting a new page */ ) { @@ -341,7 +342,7 @@ namespace glabels iLabel++; iCurrentPage = iLabel / mNLabelsPerPage; - mVariables->incrementVariablesOnMerge(); + mVariables->incrementVariablesOnItem(); if ( iRecord == 0 ) { mVariables->incrementVariablesOnCopy(); diff --git a/model/Variable.cpp b/model/Variable.cpp index 8b81a86..1cdca5d 100644 --- a/model/Variable.cpp +++ b/model/Variable.cpp @@ -90,9 +90,9 @@ namespace glabels } - void Variable::incrementValueOnCopy() + void Variable::incrementValueOnItem() { - if ( mIncrement == Increment::PER_COPY ) + if ( mIncrement == Increment::PER_ITEM ) { switch (mType) { @@ -110,9 +110,9 @@ namespace glabels } - void Variable::incrementValueOnMerge() + void Variable::incrementValueOnCopy() { - if ( mIncrement == Increment::PER_MERGE_RECORD ) + if ( mIncrement == Increment::PER_COPY ) { switch (mType) { @@ -219,10 +219,10 @@ namespace glabels { 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_MERGE_RECORD: - return tr("Per merge record"); case Increment::PER_PAGE: return tr("Per page"); } @@ -235,10 +235,10 @@ namespace glabels { case Increment::NEVER: return "never"; + case Increment::PER_ITEM: + return "per_item"; case Increment::PER_COPY: return "per_copy"; - case Increment::PER_MERGE_RECORD: - return "per_merge_record"; case Increment::PER_PAGE: return "per_page"; } @@ -251,14 +251,14 @@ namespace glabels { 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_merge_record" ) - { - return Increment::PER_MERGE_RECORD; - } else if ( id == "per_page" ) { return Increment::PER_PAGE; diff --git a/model/Variable.h b/model/Variable.h index 3feb694..95f3dec 100644 --- a/model/Variable.h +++ b/model/Variable.h @@ -46,8 +46,8 @@ namespace glabels enum class Increment { NEVER, + PER_ITEM, PER_COPY, - PER_MERGE_RECORD, PER_PAGE }; @@ -71,8 +71,8 @@ namespace glabels QString stepSize() const; void resetValue(); + void incrementValueOnItem(); void incrementValueOnCopy(); - void incrementValueOnMerge(); void incrementValueOnPage(); QString value() const; diff --git a/model/Variables.cpp b/model/Variables.cpp index 9bf149f..03fa927 100644 --- a/model/Variables.cpp +++ b/model/Variables.cpp @@ -97,6 +97,18 @@ namespace glabels } + /// + /// Increment variables on item + /// + void Variables::incrementVariablesOnItem() + { + for ( auto& v : *this ) + { + v.incrementValueOnItem(); + } + } + + /// /// Increment variables on copy /// @@ -109,18 +121,6 @@ namespace glabels } - /// - /// Increment variables on merge record - /// - void Variables::incrementVariablesOnMerge() - { - for ( auto& v : *this ) - { - v.incrementValueOnMerge(); - } - } - - /// /// Increment variables on page /// diff --git a/model/Variables.h b/model/Variables.h index ec7b578..379d56f 100644 --- a/model/Variables.h +++ b/model/Variables.h @@ -64,8 +64,8 @@ namespace glabels void replaceVariable( const QString& name, const Variable& variable ); void resetVariables(); + void incrementVariablesOnItem(); void incrementVariablesOnCopy(); - void incrementVariablesOnMerge(); void incrementVariablesOnPage(); diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index f7cdb4e..75a8f11 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -1072,10 +1072,6 @@ Per copy - - Per merge record - - Per page @@ -1088,6 +1084,10 @@ Floating Point + + Per item + + VariablesView From 87cc5d7e2203748e49a025d60888ae11ed2cf987 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 30 Mar 2019 12:50:30 -0400 Subject: [PATCH 13/55] Redesigned image selection in ObjectEditor to use new FieldCombo widget. --- glabels/CMakeLists.txt | 2 + glabels/FieldCombo.cpp | 146 +++++++++++++++++++++++++++++ glabels/FieldCombo.h | 94 +++++++++++++++++++ glabels/ObjectEditor.cpp | 27 ++++-- glabels/ObjectEditor.h | 2 +- glabels/ui/ObjectEditor.ui | 182 +++++++++++++++++++------------------ translations/glabels_C.ts | 24 ++--- 7 files changed, 365 insertions(+), 112 deletions(-) create mode 100644 glabels/FieldCombo.cpp create mode 100644 glabels/FieldCombo.h diff --git a/glabels/CMakeLists.txt b/glabels/CMakeLists.txt index df14917..d03daa7 100644 --- a/glabels/CMakeLists.txt +++ b/glabels/CMakeLists.txt @@ -18,6 +18,7 @@ set (glabels_sources Cursors.cpp EditVariableDialog.cpp FieldButton.cpp + FieldCombo.cpp File.cpp Help.cpp Icons.cpp @@ -55,6 +56,7 @@ set (glabels_qobject_headers ColorPaletteButtonItem.h EditVariableDialog.h FieldButton.h + FieldCombo.h File.h LabelEditor.h MainWindow.h diff --git a/glabels/FieldCombo.cpp b/glabels/FieldCombo.cpp new file mode 100644 index 0000000..0a41107 --- /dev/null +++ b/glabels/FieldCombo.cpp @@ -0,0 +1,146 @@ +/* FieldCombo.cpp + * + * Copyright (C) 2014-2019 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#include "FieldCombo.h" + +#include +#include + + +namespace glabels +{ + + /// + /// Constructor + /// + FieldCombo::FieldCombo( QWidget* parent ) + : QComboBox(parent) + { + connect( this, SIGNAL(currentIndexChanged(int)), + this, SLOT(onIndexChanged(int)) ); + } + + + /// + /// Is current selection the alternative default selection? + /// + bool FieldCombo::isCurrentSelectionSpecial() const + { + return currentIndex() == 0; + } + + + /// + /// Return current selection + /// + QString FieldCombo::currentSelection() const + { + return mFieldNames[ currentIndex() ]; + } + + + /// + /// Set current selection to special + /// + void FieldCombo::setCurrentSelectionToSpecial() + { + setCurrentIndex( 0 ); + } + + + /// + /// Set current selection + /// + void FieldCombo::setCurrentSelection( const QString& key ) + { + setCurrentText( QString( "${%1}" ).arg( key ) ); + } + + + /// + /// Set alternative default selection + /// + void FieldCombo::setSpecialSelectionText( const QString& name ) + { + mName = name; + if ( count() == 0 ) + { + addItem( mName ); + } + else + { + setItemText( 0, mName ); + } + } + + + /// + /// Set field selections + /// + void FieldCombo::setFieldSelections( const merge::Merge* merge, + const model::Variables* variables ) + { + // Clear old keys + clear(); + mFieldNames.clear(); + + // Add default alt selection + addItem( mName ); + mFieldNames.append( mName ); + + // Add merge fields, if any + for ( auto& key : merge->keys() ) + { + addItem( QString( "${%1}" ).arg( key ) ); + mFieldNames.append( key ); + } + + // Add variables, if any + for ( auto& key : variables->keys() ) + { + addItem( QString( "${%1}" ).arg( key ) ); + mFieldNames.append( key ); + } + } + + + /// + /// Clear field selections + /// + void FieldCombo::clearFieldSelections() + { + clear(); + mFieldNames.clear(); + + addItem( mName ); + mFieldNames.append( mName ); + } + + + /// + /// onMenuKeySelected slot + /// + void FieldCombo::onIndexChanged( int index ) + { + emit selectionChanged(); + } + + +} // namespace glabels diff --git a/glabels/FieldCombo.h b/glabels/FieldCombo.h new file mode 100644 index 0000000..a748628 --- /dev/null +++ b/glabels/FieldCombo.h @@ -0,0 +1,94 @@ +/* FieldCombo.h + * + * Copyright (C) 2014-2019 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#ifndef FieldCombo_h +#define FieldCombo_h + + +#include "model/Variables.h" +#include "merge/Merge.h" + +#include +#include +#include + + +namespace glabels +{ + + /// + /// Field Combo + /// + class FieldCombo : public QComboBox + { + Q_OBJECT + + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// + public: + FieldCombo( QWidget* parent = nullptr ); + + + ///////////////////////////////// + // Signals + ///////////////////////////////// + signals: + void selectionChanged(); + + + ///////////////////////////////// + // Public Methods + ///////////////////////////////// + public: + bool isCurrentSelectionSpecial() const; + QString currentSelection() const; + + void setCurrentSelectionToSpecial(); + void setCurrentSelection( const QString& key ); + + void setSpecialSelectionText( const QString& name = "" ); + + void setFieldSelections( const merge::Merge* merge, + const model::Variables* variables ); + + void clearFieldSelections(); + + + ///////////////////////////////// + // Slots + ///////////////////////////////// + private slots: + void onIndexChanged( int index ); + + + ///////////////////////////////// + // Private Data + ///////////////////////////////// + private: + QString mName; + QVector mFieldNames; + + }; + +} + + +#endif // FieldCombo_h diff --git a/glabels/ObjectEditor.cpp b/glabels/ObjectEditor.cpp index f61e9fe..ee2ba24 100644 --- a/glabels/ObjectEditor.cpp +++ b/glabels/ObjectEditor.cpp @@ -69,7 +69,7 @@ namespace glabels textInsertFieldCombo->setName( tr("Insert Field") ); barcodeInsertFieldCombo->setName( tr("Insert Field") ); - imageFieldCombo->setName( tr("Key") ); + imageFieldCombo->setSpecialSelectionText( tr("Selected File...") ); setEnabled( false ); hidePages(); @@ -120,13 +120,14 @@ namespace glabels model::TextNode filenameNode = mObject->filenameNode(); + imageFileSelectionBox->setVisible( !filenameNode.isField() ); if ( filenameNode.isField() ) { - QString field = QString("${%1}").arg( filenameNode.data() ); - imageFilenameLineEdit->setText( field ); + imageFieldCombo->setCurrentSelection( filenameNode.data() ); } else { + imageFieldCombo->setCurrentSelectionToSpecial(); imageFilenameLineEdit->setText( filenameNode.data() ); } @@ -506,7 +507,7 @@ namespace glabels fillColorButton->setKeys( keys ); textInsertFieldCombo->setKeys( keys ); barcodeInsertFieldCombo->setKeys( keys ); - imageFieldCombo->setKeys( keys ); + imageFieldCombo->setFieldSelections( mModel->merge(), mModel->variables() ); shadowColorButton->setKeys( keys ); } } @@ -616,10 +617,22 @@ namespace glabels } - void ObjectEditor::onImageKeySelected( QString key ) + void ObjectEditor::onImageComboChanged() { - mUndoRedoModel->checkpoint( tr("Set image") ); - mObject->setFilenameNode( model::TextNode( true, key ) ); + imageFileSelectionBox->setVisible( imageFieldCombo->isCurrentSelectionSpecial() ); + + if ( mObject ) + { + mUndoRedoModel->checkpoint( tr("Set image") ); + if ( imageFieldCombo->isCurrentSelectionSpecial() ) + { + mObject->setFilenameNode( model::TextNode( false, imageFilenameLineEdit->text() ) ); + } + else + { + mObject->setFilenameNode( model::TextNode( true, imageFieldCombo->currentSelection() ) ); + } + } } diff --git a/glabels/ObjectEditor.h b/glabels/ObjectEditor.h index 6e84687..311f691 100644 --- a/glabels/ObjectEditor.h +++ b/glabels/ObjectEditor.h @@ -87,7 +87,7 @@ namespace glabels void onLineControlsChanged(); void onFillControlsChanged(); void onImageFileButtonClicked(); - void onImageKeySelected( QString key ); + void onImageComboChanged(); void onPositionControlsChanged(); void onRectSizeControlsChanged(); void onLineSizeControlsChanged(); diff --git a/glabels/ui/ObjectEditor.ui b/glabels/ui/ObjectEditor.ui index 0493a38..d213373 100644 --- a/glabels/ui/ObjectEditor.ui +++ b/glabels/ui/ObjectEditor.ui @@ -31,7 +31,7 @@ Form - + @@ -763,77 +763,74 @@ File - - - + + + + + + 0 + 0 + + - - - - 0 - 0 - - - - - 231 - 0 - - - - true - - - None - - + + Selected File... + - - - - - - - 0 - 0 - - - - Select File... - - - - - - - - 0 - 0 - - - - or - - - - - - - - 0 - 0 - - - - - Select Merge Field... - - - - - - - + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 231 + 0 + + + + true + + + None + + + + + + + + 0 + 0 + + + + Browse... + + + + + @@ -1545,6 +1542,14 @@ selectionChanged() + + glabels::FieldCombo + QComboBox +
FieldCombo.h
+ + selectionChanged() + +
@@ -1999,13 +2004,13 @@ - imageFileButton + imageBrowseButton clicked() ObjectEditor onImageFileButtonClicked() - 133 + 365 175 @@ -2014,22 +2019,6 @@ - - imageFieldCombo - keySelected(QString) - ObjectEditor - onImageKeySelected(QString) - - - 302 - 175 - - - 397 - 32 - - - textEdit textChanged() @@ -2190,6 +2179,22 @@ + + imageFieldCombo + selectionChanged() + ObjectEditor + onImageComboChanged() + + + 283 + 118 + + + 398 + 18 + + + onChanged() @@ -2206,5 +2211,6 @@ onTextInsertFieldKeySelected(QString) onBarcodeControlsChanged() onBarcodeInsertFieldKeySelected(QString) + onImageComboChanged() diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 75a8f11..f131f4f 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -405,18 +405,6 @@ File - - Select File... - - - - or - - - - Select Merge Field... - - Line/Fill @@ -493,6 +481,10 @@ Opacity: + + Browse... + + PreferencesDialog @@ -1760,10 +1752,6 @@ Insert Field - - Key - - Original size @@ -1900,6 +1888,10 @@ Shadow + + Selected File... + + glabels::PrintView From d9a41c66f08dfec65a36628d9324b3fc2ab45524 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 30 Mar 2019 18:59:15 -0400 Subject: [PATCH 14/55] Don't emit selectionChanged if index is invalid. --- glabels/FieldCombo.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glabels/FieldCombo.cpp b/glabels/FieldCombo.cpp index 0a41107..c2da4a7 100644 --- a/glabels/FieldCombo.cpp +++ b/glabels/FieldCombo.cpp @@ -139,7 +139,10 @@ namespace glabels /// void FieldCombo::onIndexChanged( int index ) { - emit selectionChanged(); + if ( index >= 0 ) + { + emit selectionChanged(); + } } From 1313c2fc197d393527ead74fec9b79bca99a8dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Bl=C3=A4ttermann?= Date: Sun, 5 May 2019 19:38:54 +0200 Subject: [PATCH 15/55] Fix typo (#52) --- user-docs/man/glabels-batch-qt.rst | 2 +- user-docs/man/glabels-qt.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/user-docs/man/glabels-batch-qt.rst b/user-docs/man/glabels-batch-qt.rst index 35dcbce..5d1baaf 100644 --- a/user-docs/man/glabels-batch-qt.rst +++ b/user-docs/man/glabels-batch-qt.rst @@ -82,7 +82,7 @@ FILES BUGS ---- -Bugs and featue requests can be reported via the gLabels issue tracking system at GitHub (). You will need a GitHub account to submit new issues or to comment on existing issues. +Bugs and feature requests can be reported via the gLabels issue tracking system at GitHub (). You will need a GitHub account to submit new issues or to comment on existing issues. SEE ALSO -------- diff --git a/user-docs/man/glabels-qt.rst b/user-docs/man/glabels-qt.rst index 33e18d4..709d807 100644 --- a/user-docs/man/glabels-qt.rst +++ b/user-docs/man/glabels-qt.rst @@ -46,7 +46,7 @@ FILES BUGS ---- -Bugs and featue requests can be reported via the gLabels issue tracking system at GitHub (). You will need a GitHub account to submit new issues or to comment on existing issues. +Bugs and feature requests can be reported via the gLabels issue tracking system at GitHub (). You will need a GitHub account to submit new issues or to comment on existing issues. SEE ALSO From 3256c407fb608aabe1bb9c30b36fa2d33a4aa279 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 5 May 2019 14:45:44 -0400 Subject: [PATCH 16/55] Make version numbers of snapshots more meaningful. --- .version.in | 1 + CMakeLists.txt | 29 +++++++++++++++++++++++-- glabels-batch/main.cpp | 2 +- glabels/AboutDialog.cpp | 2 +- glabels/main.cpp | 2 +- model/Version.h.in | 1 + user-docs/_build/man/glabels-batch-qt.1 | 4 ++-- user-docs/_build/man/glabels-qt.1 | 4 ++-- 8 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 .version.in diff --git a/.version.in b/.version.in new file mode 100644 index 0000000..f3e763d --- /dev/null +++ b/.version.in @@ -0,0 +1 @@ +@VERSION_STRING@ diff --git a/CMakeLists.txt b/CMakeLists.txt index 885788f..f58d062 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,26 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/" set (WEBSITE "glabels.org") set (BUG_WEBSITE "https://github.com/jimevins/glabels-qt/issues") +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + RESULT_VARIABLE BRANCH_VALID + OUTPUT_VARIABLE BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if (NOT ${BRANCH_VALID} STREQUAL "0") + set (BRANCH "Unkonwn") +endif () + +execute_process( + COMMAND git rev-list --count ${BRANCH} + RESULT_VARIABLE COMMIT_COUNT_VALID + OUTPUT_VARIABLE COMMIT_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if (NOT ${COMMIT_COUNT_VALID} STREQUAL "0") + set (COMMIT_COUNT "?") +endif () + execute_process( COMMAND git log -1 --format=%h RESULT_VARIABLE COMMIT_HASH_VALID @@ -38,11 +58,16 @@ if (NOT ${COMMIT_DATE_VALID} STREQUAL "0") endif () # Uncomment for snapshots, comment for releases -set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}-snapshot (${COMMIT_HASH} ${COMMIT_DATE})") +set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}-${BRANCH}${COMMIT_COUNT}") # Uncomment for releases, comment for snapshots #set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") +set(LONG_VERSION_STRING "${VERSION_STRING} (${COMMIT_HASH} ${COMMIT_DATE})") + +# Auto-generate version file +configure_file (.version.in VERSION @ONLY) + #======================================= # Packaging Information @@ -147,7 +172,7 @@ add_subdirectory (data) #======================================= message (STATUS "") message (STATUS "Project name ............ " ${CMAKE_PROJECT_NAME}) -message (STATUS "Project version ......... " ${VERSION_STRING}) +message (STATUS "Project version ......... " ${LONG_VERSION_STRING}) message (STATUS "Installation prefix ..... " ${CMAKE_INSTALL_PREFIX}) message (STATUS "Source code location .... " ${glabels_SOURCE_DIR}) message (STATUS "CMake version ........... " ${CMAKE_VERSION}) diff --git a/glabels-batch/main.cpp b/glabels-batch/main.cpp index e857f44..a89d045 100644 --- a/glabels-batch/main.cpp +++ b/glabels-batch/main.cpp @@ -60,7 +60,7 @@ int main( int argc, char **argv ) QCoreApplication::setOrganizationName( "glabels.org" ); QCoreApplication::setOrganizationDomain( "glabels.org" ); QCoreApplication::setApplicationName( "glabels-batch-qt" ); - QCoreApplication::setApplicationVersion( glabels::model::Version::STRING ); + QCoreApplication::setApplicationVersion( glabels::model::Version::LONG_STRING ); // // Setup translators diff --git a/glabels/AboutDialog.cpp b/glabels/AboutDialog.cpp index ef9ff99..acfb423 100644 --- a/glabels/AboutDialog.cpp +++ b/glabels/AboutDialog.cpp @@ -38,7 +38,7 @@ namespace glabels { setupUi( this ); - QString version = tr("Version") + " " + model::Version::STRING; + QString version = tr("Version") + " " + model::Version::LONG_STRING; QString description = tr("A program to create labels and business cards."); diff --git a/glabels/main.cpp b/glabels/main.cpp index 1acdf1c..67b9c7c 100644 --- a/glabels/main.cpp +++ b/glabels/main.cpp @@ -45,7 +45,7 @@ int main( int argc, char **argv ) QCoreApplication::setOrganizationName( "glabels.org" ); QCoreApplication::setOrganizationDomain( "glabels.org" ); QCoreApplication::setApplicationName( "glabels-qt" ); - QCoreApplication::setApplicationVersion( glabels::model::Version::STRING ); + QCoreApplication::setApplicationVersion( glabels::model::Version::LONG_STRING ); // // Setup translators diff --git a/model/Version.h.in b/model/Version.h.in index b9cf033..0444361 100644 --- a/model/Version.h.in +++ b/model/Version.h.in @@ -37,6 +37,7 @@ namespace glabels const int MICRO = @glabels-qt_VERSION_PATCH@; const QString STRING = "@VERSION_STRING@"; + const QString LONG_STRING = "@LONG_VERSION_STRING@"; } } diff --git a/user-docs/_build/man/glabels-batch-qt.1 b/user-docs/_build/man/glabels-batch-qt.1 index 069178f..ce4b77f 100644 --- a/user-docs/_build/man/glabels-batch-qt.1 +++ b/user-docs/_build/man/glabels-batch-qt.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLABELS-BATCH-QT" "1" "Apr 29, 2019" "" "gLabels" +.TH "GLABELS-BATCH-QT" "1" "May 05, 2019" "" "gLabels" .SH NAME glabels-batch-qt \- batch creation of labels and business cards . @@ -110,7 +110,7 @@ Directory for manually created product templates. .UNINDENT .SH BUGS .sp -Bugs and featue requests can be reported via the gLabels issue tracking system at GitHub (<\fI\%https://github.com/jimevins/glabels\-qt/issues\fP>). You will need a GitHub account to submit new issues or to comment on existing issues. +Bugs and feature requests can be reported via the gLabels issue tracking system at GitHub (<\fI\%https://github.com/jimevins/glabels\-qt/issues\fP>). You will need a GitHub account to submit new issues or to comment on existing issues. .SH SEE ALSO .sp \fBglabels\-qt(1)\fP diff --git a/user-docs/_build/man/glabels-qt.1 b/user-docs/_build/man/glabels-qt.1 index d90c351..f68653b 100644 --- a/user-docs/_build/man/glabels-qt.1 +++ b/user-docs/_build/man/glabels-qt.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLABELS-QT" "1" "Apr 29, 2019" "" "gLabels" +.TH "GLABELS-QT" "1" "May 05, 2019" "" "gLabels" .SH NAME glabels-qt \- create labels and business cards . @@ -69,7 +69,7 @@ Directory for manually created product templates. .UNINDENT .SH BUGS .sp -Bugs and featue requests can be reported via the gLabels issue tracking system at GitHub (<\fI\%https://github.com/jimevins/glabels\-qt/issues\fP>). You will need a GitHub account to submit new issues or to comment on existing issues. +Bugs and feature requests can be reported via the gLabels issue tracking system at GitHub (<\fI\%https://github.com/jimevins/glabels\-qt/issues\fP>). You will need a GitHub account to submit new issues or to comment on existing issues. .SH SEE ALSO .sp \fBglabels\-batch\-qt(1)\fP From b77d57ad08a66636a9fdf23d18576327ebd18724 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 5 May 2019 16:04:40 -0400 Subject: [PATCH 17/55] Another method of determining branch. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f58d062..e03fcb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set (WEBSITE "glabels.org") set (BUG_WEBSITE "https://github.com/jimevins/glabels-qt/issues") execute_process( - COMMAND git rev-parse --abbrev-ref HEAD + COMMAND git symbolic-ref --short HEAD RESULT_VARIABLE BRANCH_VALID OUTPUT_VARIABLE BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE From 5108650ee27bb17127b84300ff35a13a713b34bc Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 5 May 2019 21:36:16 -0400 Subject: [PATCH 18/55] Re-attach to master in CI scripts to satisfy auto version tooling. --- .appveyor.yml | 1 + .travis.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index 66a4c85..40d0245 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -27,6 +27,7 @@ install: - set PATH=%PATH%;%QTDIR%/bin build_script: + - git checkout master # re-attach to master to satisfy auto version tooling - mkdir build - cd build - cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH=%QTDIR% .. diff --git a/.travis.yml b/.travis.yml index 45fec74..2f012d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ install: - source /opt/qt5*/bin/qt5*-env.sh script: + - git checkout master # re-attach to master to satisfy auto version tooling - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=/usr From 5109da9c6a229f172f5f52830fd146c94fc71303 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 5 May 2019 22:23:05 -0400 Subject: [PATCH 19/55] Restore repository depth in Travis CI script to properly count commits in auto versioning. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2f012d7..e97f3a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,8 @@ install: - source /opt/qt5*/bin/qt5*-env.sh script: - - git checkout master # re-attach to master to satisfy auto version tooling + - git fetch --unshallow # restore repository depth to properly count commits in auto versioning + - git checkout master # re-attach to master to satisfy auto versioning - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=/usr From 33e2d3dee383bf8aa67c843466471feda37429b8 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 12 May 2019 17:30:42 -0400 Subject: [PATCH 20/55] Tweaks to PrintView. - Increased range of copies spinbox to 100x the number of iterms per page (#51) - Fixed issue that blocked user from holding down on spinbox controls - Minor layout tweaks --- glabels/PrintView.cpp | 8 ++++-- glabels/ui/PrintView.ui | 55 ++++++++++++++++++++++++------------ glabels/ui/PropertiesView.ui | 6 ++++ 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/glabels/PrintView.cpp b/glabels/PrintView.cpp index a900af3..a6f3f7d 100644 --- a/glabels/PrintView.cpp +++ b/glabels/PrintView.cpp @@ -70,6 +70,9 @@ namespace glabels connect( mModel, SIGNAL(changed()), this, SLOT(onModelChanged()) ); + copiesSpin->setRange( 1, 100*mModel->frame()->nLabels() ); + copiesStartSpin->setRange( 1, mModel->frame()->nLabels() ); + onFormChanged(); } @@ -79,6 +82,9 @@ namespace glabels /// void PrintView::onModelChanged() { + copiesSpin->setRange( 1, 100*mModel->frame()->nLabels() ); + copiesStartSpin->setRange( 1, mModel->frame()->nLabels() ); + updateView(); } @@ -88,8 +94,6 @@ namespace glabels /// void PrintView::updateView() { - copiesStartSpin->setRange( 1, mModel->frame()->nLabels() ); - if ( mRenderer.nPages() == 1 ) { if ( mRenderer.nItems() == 1 ) diff --git a/glabels/ui/PrintView.ui b/glabels/ui/PrintView.ui index d4ea498..b7303ae 100644 --- a/glabels/ui/PrintView.ui +++ b/glabels/ui/PrintView.ui @@ -6,7 +6,7 @@ 0 0 - 759 + 852 792 @@ -73,21 +73,8 @@ Copies - - - - - - 0 - 0 - - - - (Will print a total of xx items on nn pages.) - - - - + + @@ -104,11 +91,20 @@ + + QAbstractSpinBox::UpDownArrows + + + true + 1 - 96 + 9999 + + + QAbstractSpinBox::DefaultStepType @@ -127,7 +123,7 @@ - + @@ -183,6 +179,29 @@ + + + + + + + 0 + 0 + + + + + 330 + 0 + + + + (Will print a total of xxxx items on nnn pages.) + + + + +
diff --git a/glabels/ui/PropertiesView.ui b/glabels/ui/PropertiesView.ui index 60c0632..6b8f115 100644 --- a/glabels/ui/PropertiesView.ui +++ b/glabels/ui/PropertiesView.ui @@ -241,6 +241,12 @@
+ + + 330 + 0 + + <html><head/><body><p>Select another product for this gLabels project.</p></body></html> From 25756753ac753c7624c7979cae1ecf1da76f0a30 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 12 May 2019 18:42:45 -0400 Subject: [PATCH 21/55] Removed new to qt 5.12 feature accidentally introduced by qt designer. --- glabels/ui/PrintView.ui | 3 --- 1 file changed, 3 deletions(-) diff --git a/glabels/ui/PrintView.ui b/glabels/ui/PrintView.ui index b7303ae..0301ee0 100644 --- a/glabels/ui/PrintView.ui +++ b/glabels/ui/PrintView.ui @@ -103,9 +103,6 @@ 9999 - - QAbstractSpinBox::DefaultStepType - From f030954663965fc915f89fc744a063de0d487530 Mon Sep 17 00:00:00 2001 From: "Brian K. White" Date: Sat, 18 May 2019 13:51:56 -0400 Subject: [PATCH 22/55] Add OL1649 (#55) --- templates/online-templates.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/templates/online-templates.xml b/templates/online-templates.xml index 0b296ac..ca81061 100644 --- a/templates/online-templates.xml +++ b/templates/online-templates.xml @@ -332,6 +332,16 @@ + +