From c2052abf43d5ac3518ca873065ee546d8441d316 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 3 May 2017 22:20:09 -0400 Subject: [PATCH] Hooked up barcode data controls in object editor. --- glabels/LabelModelBarcodeObject.cpp | 29 ++- glabels/LabelModelBarcodeObject.h | 8 +- glabels/LabelModelObject.cpp | 8 +- glabels/LabelModelObject.h | 6 +- glabels/ObjectEditor.cpp | 10 ++ glabels/ObjectEditor.h | 1 + glabels/ui/ObjectEditor.ui | 269 ++++++---------------------- translations/glabels_C.ts | 149 +++++++-------- 8 files changed, 153 insertions(+), 327 deletions(-) diff --git a/glabels/LabelModelBarcodeObject.cpp b/glabels/LabelModelBarcodeObject.cpp index 44e8e3a..3648715 100644 --- a/glabels/LabelModelBarcodeObject.cpp +++ b/glabels/LabelModelBarcodeObject.cpp @@ -65,7 +65,7 @@ namespace glabels mBcTextFlag = mBcStyle.canText(); mBcChecksumFlag = mBcStyle.canChecksum(); mBcFormatDigits = mBcStyle.preferedN(); - mBcDataNode = TextNode( false, mBcStyle.defaultDigits() ); + mBcData = mBcStyle.defaultDigits(); mBcColorNode = ColorNode( Qt::black ); update(); // Initialize cached editor layouts @@ -82,7 +82,7 @@ namespace glabels mBcTextFlag = object->mBcTextFlag; mBcChecksumFlag = object->mBcChecksumFlag; mBcFormatDigits = object->mBcFormatDigits; - mBcDataNode = object->mBcDataNode; + mBcData = object->mBcData; mBcColorNode = object->mBcColorNode; mEditorBarcode = nullptr; @@ -117,22 +117,22 @@ namespace glabels /// - /// bcDataNode Property Getter + /// bcData Property Getter /// - TextNode LabelModelBarcodeObject::bcDataNode() const + QString LabelModelBarcodeObject::bcData() const { - return mBcDataNode; + return mBcData; } /// - /// bcDataNode Property Setter + /// bcData Property Setter /// - void LabelModelBarcodeObject::setBcDataNode( const TextNode& value ) + void LabelModelBarcodeObject::setBcData( const QString& value ) { - if ( mBcDataNode != value ) + if ( mBcData != value ) { - mBcDataNode = value; + mBcData = value; update(); emit changed(); } @@ -331,14 +331,7 @@ namespace glabels mEditorBarcode->setChecksum(mBcChecksumFlag); mEditorBarcode->setShowText(mBcTextFlag); - if ( mBcDataNode.isField() ) - { - mEditorBarcode->build( mBcStyle.defaultDigits().toStdString(), mW.pt(), mH.pt() ); - } - else - { - mEditorBarcode->build( mBcDataNode.data().toStdString(), mW.pt(), mH.pt() ); - } + mEditorBarcode->build( mBcData.toStdString(), mW.pt(), mH.pt() ); mW = Distance::pt( mEditorBarcode->width() ); mH = Distance::pt( mEditorBarcode->height() ); @@ -386,7 +379,7 @@ namespace glabels bc->setChecksum(mBcChecksumFlag); bc->setShowText(mBcTextFlag); - bc->build( mBcDataNode.text(record).toStdString(), mW.pt(), mH.pt() ); + bc->build( mBcData.toStdString(), mW.pt(), mH.pt() ); glbarcode::QtRenderer renderer(painter); bc->render( renderer ); diff --git a/glabels/LabelModelBarcodeObject.h b/glabels/LabelModelBarcodeObject.h index 05359d1..c073a7e 100644 --- a/glabels/LabelModelBarcodeObject.h +++ b/glabels/LabelModelBarcodeObject.h @@ -57,10 +57,10 @@ namespace glabels /////////////////////////////////////////////////////////////// public: // - // Barcode Property: bcDataNode + // Barcode Property: bcData // - TextNode bcDataNode() const override; - void setBcDataNode( const TextNode &value ) override; + QString bcData() const override; + void setBcData( const QString &value ) override; // @@ -134,7 +134,7 @@ namespace glabels bool mBcTextFlag; bool mBcChecksumFlag; int mBcFormatDigits; - TextNode mBcDataNode; + QString mBcData; ColorNode mBcColorNode; glbarcode::Barcode* mEditorBarcode; diff --git a/glabels/LabelModelObject.cpp b/glabels/LabelModelObject.cpp index c7e06c6..b862e1c 100644 --- a/glabels/LabelModelObject.cpp +++ b/glabels/LabelModelObject.cpp @@ -710,12 +710,12 @@ namespace glabels /// - /// Virtual Barcode Data Node Property Default Getter + /// Virtual Barcode Data Property Default Getter /// (Overridden by concrete class) /// - TextNode LabelModelObject::bcDataNode() const + QString LabelModelObject::bcData() const { - return TextNode(); + return QString(); } @@ -723,7 +723,7 @@ namespace glabels /// Virtual Barcode Data Node Property Default Setter /// (Overridden by concrete class) /// - void LabelModelObject::setBcDataNode( const TextNode &value ) + void LabelModelObject::setBcData( const QString& value ) { // empty } diff --git a/glabels/LabelModelObject.h b/glabels/LabelModelObject.h index c08328a..00a2480 100644 --- a/glabels/LabelModelObject.h +++ b/glabels/LabelModelObject.h @@ -299,10 +299,10 @@ namespace glabels /////////////////////////////////////////////////////////////// public: // - // Virtual Barcode Property: bcDataNode + // Virtual Barcode Property: bcData // - virtual TextNode bcDataNode() const; - virtual void setBcDataNode( const TextNode &value ); + virtual QString bcData() const; + virtual void setBcData( const QString& value ); // diff --git a/glabels/ObjectEditor.cpp b/glabels/ObjectEditor.cpp index 09c14a3..ebcce19 100644 --- a/glabels/ObjectEditor.cpp +++ b/glabels/ObjectEditor.cpp @@ -67,6 +67,7 @@ namespace glabels shadowColorButton->init( "Default", QColor(0,0,0,255), QColor(0,0,0,255) ); textInsertFieldCombo->setName( "Insert Field" ); + barcodeInsertFieldCombo->setName( "Insert Field" ); imageFieldCombo->setName( "Key" ); setEnabled( false ); @@ -251,6 +252,7 @@ namespace glabels barcodeShowTextCheck->setChecked( mObject->bcTextFlag() ); barcodeChecksumCheck->setChecked( mObject->bcChecksumFlag() ); barcodeColorButton->setColorNode( mObject->bcColorNode() ); + barcodeDataEdit->setText( mObject->bcData() ); mBlocked = false; } @@ -475,6 +477,7 @@ namespace glabels lineColorButton->setKeys( keys ); fillColorButton->setKeys( keys ); textInsertFieldCombo->setKeys( keys ); + barcodeInsertFieldCombo->setKeys( keys ); imageFieldCombo->setKeys( keys ); shadowColorButton->setKeys( keys ); } @@ -702,12 +705,19 @@ namespace glabels mObject->setBcTextFlag( barcodeShowTextCheck->isChecked() ); mObject->setBcChecksumFlag( barcodeChecksumCheck->isChecked() ); mObject->setBcColorNode( barcodeColorButton->colorNode() ); + mObject->setBcData( barcodeDataEdit->toPlainText() ); mBlocked = false; } } + void ObjectEditor::onBarcodeInsertFieldKeySelected( QString key ) + { + barcodeDataEdit->insertPlainText( "${" + key + "}" ); + } + + void ObjectEditor::onResetImageSize() { mObject->setSize( mObject->naturalSize() ); diff --git a/glabels/ObjectEditor.h b/glabels/ObjectEditor.h index 6a8f8a2..8298176 100644 --- a/glabels/ObjectEditor.h +++ b/glabels/ObjectEditor.h @@ -95,6 +95,7 @@ namespace glabels void onTextControlsChanged(); void onTextInsertFieldKeySelected( QString key ); void onBarcodeControlsChanged(); + void onBarcodeInsertFieldKeySelected( QString key ); void onResetImageSize(); void onShadowControlsChanged(); void onChanged(); diff --git a/glabels/ui/ObjectEditor.ui b/glabels/ui/ObjectEditor.ui index 1897a96..4592bc7 100644 --- a/glabels/ui/ObjectEditor.ui +++ b/glabels/ui/ObjectEditor.ui @@ -35,7 +35,7 @@ - 0 + 1 @@ -631,169 +631,44 @@ - Data + Barcode data - + - + - - - - - - 0 - 0 - - - - - 80 - 0 - - - - Literal: - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - 0 - 0 - - - - - 240 - 100 - - - + - + - - - - 0 - 0 - - - - - 80 - 0 - - - - Key: - - - - - + - Qt::Vertical + Qt::Horizontal - 20 - 40 + 40 + 20 - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + - - - - - format: - - - - - - - 0000000000 - - - - - - - digits: - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - + + + Qt::Horizontal + + + + 40 + 20 + + + @@ -1610,6 +1485,9 @@ glabels::FieldButton QComboBox
FieldButton.h
+ + keySelected(QString) + @@ -2176,70 +2054,6 @@ - - barcodeLiteralRadio - toggled(bool) - ObjectEditor - onBarcodeControlsChanged() - - - 68 - 302 - - - 5 - 331 - - - - - barcodeKeyRadio - toggled(bool) - ObjectEditor - onBarcodeControlsChanged() - - - 39 - 401 - - - 2 - 377 - - - - - barcodeDigitsSpin - valueChanged(int) - ObjectEditor - onBarcodeControlsChanged() - - - 216 - 485 - - - 397 - 532 - - - - - barcodeTextEdit - textChanged() - ObjectEditor - onBarcodeControlsChanged() - - - 242 - 333 - - - 4 - 369 - - - barcodeColorButton colorChanged() @@ -2256,6 +2070,38 @@ + + barcodeDataEdit + textChanged() + ObjectEditor + onBarcodeControlsChanged() + + + 255 + 405 + + + 398 + 534 + + + + + barcodeInsertFieldCombo + keySelected(QString) + ObjectEditor + onBarcodeInsertFieldKeySelected(QString) + + + 203 + 486 + + + 403 + 625 + + + onChanged() @@ -2271,5 +2117,6 @@ onTextControlsChanged() onTextInsertFieldKeySelected(QString) onBarcodeControlsChanged() + onBarcodeInsertFieldKeySelected(QString) diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index d20828f..a8815a7 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -205,9 +205,9 @@ - - - + + + Color: @@ -243,164 +243,139 @@ - Data + Barcode data - - Literal: - - - - - Key: - - - - - format: - - - - - 0000000000 - - - - - digits: - - - - + Image - + File - + None - + Select File... - + or - + Select Merge Field... - + Line/Fill - + Line - - + + Width: - + Fill - + Position/Size - + Position - + X: - + Y: - - + + Size - + Length: - + Angle: - + Original size: - + Reset - + Lock aspect ratio - + Height: - - + + Shadow - + X offset: - + Y offset: - + Opacity: - + Object properties @@ -1807,139 +1782,139 @@ glabels::ObjectEditor - + Original size - + Box object properties - + Ellipse object properties - + Image object properties - + Line object properties - + Text object properties - + Barcode object properties - + Line - + Fill - + Image files (*.png *.jpg *.jpeg *.gif *.bmp *.pbm *.pgm *.ppm *.xbm *.xpm *.svg) - + All files (*) - + PNG - Portable Network Graphics (*.png) - + BMP - Windows Bitmap (*.bmp) - + GIF - Graphics Interchange Format (*.gif) - + JPEG - Joint Photographic Experts Group (*.jpg *.jpeg) - + PBM - Portable Bitmap (*.pbm) - + PGM - Portable Graymap (*.pgm) - + PPM - Portable Pixmap (*.ppm) - + SVG - Scalable Vector Graphics (*.svg) - + XBM - X11 Bitmap (*.xbm) - + XPM - X11 Pixmap (*.xpm) - + gLabels - Select image file - - + + Set image - + Move - - + + Size - + Text - + Shadow