From a46bc43a4d6581601a8321027b586d8bd8063b52 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 28 Dec 2013 11:32:28 -0500 Subject: [PATCH] Style reconciliation. --- app/BarcodeStyle.cpp | 37 ++++- app/BarcodeStyle.h | 18 ++- app/CMakeLists.txt | 4 +- app/ColorNode.cpp | 63 +++++--- app/ColorNode.h | 56 +++++-- app/File.cpp | 3 + app/File.h | 3 + app/Help.cpp | 6 + app/Help.h | 3 + app/Icons.h | 50 +++++- app/LabelModel.cpp | 200 +++++++++++++++++++----- app/LabelModelBoxObject.cpp | 41 ++++- app/LabelModelBoxObject.h | 31 ++-- app/LabelModelObject.cpp | 303 ++++++++++++++++++++++++++++++++++-- app/LabelModelObject.h | 191 ++++++++++++----------- app/LabelRegion.h | 99 ++++++++++-- app/MainWindow.cpp | 221 ++++++++++++++++++++++++-- app/MainWindow.h | 8 +- app/MergeField.h | 59 ++++++- app/MergeRecord.cpp | 14 ++ app/MergeRecord.h | 59 +++++-- app/NewLabelDialog.cpp | 18 +++ app/NewLabelDialog.h | 11 ++ app/SimplePreview.cpp | 30 ++++ app/SimplePreview.h | 26 +++- app/TemplatePicker.cpp | 12 ++ app/TemplatePicker.h | 16 ++ app/TemplatePickerItem.cpp | 14 +- app/TemplatePickerItem.h | 19 ++- app/TextNode.cpp | 63 +++++++- app/TextNode.h | 65 ++++---- app/View.cpp | 63 ++++++++ app/View.h | 8 +- 33 files changed, 1525 insertions(+), 289 deletions(-) diff --git a/app/BarcodeStyle.cpp b/app/BarcodeStyle.cpp index f316a3b..2de085a 100644 --- a/app/BarcodeStyle.cpp +++ b/app/BarcodeStyle.cpp @@ -24,7 +24,9 @@ namespace glabels { - + /// + /// Default Constructor + /// BarcodeStyle::BarcodeStyle () : mId( "" ), mName( "" ), @@ -39,6 +41,9 @@ namespace glabels } + /// + /// Constructor From Data + /// BarcodeStyle::BarcodeStyle ( const QString& id, const QString& name, bool canText, @@ -61,60 +66,90 @@ namespace glabels } + /// + /// ID Property Getter + /// const QString& BarcodeStyle::id() const { return mId; } + /// + /// Name Property Getter + /// const QString& BarcodeStyle::name() const { return mName; } + /// + /// Can Text Property Getter + /// bool BarcodeStyle::canText() const { return mCanText; } + /// + /// Text Optional Property Getter + /// bool BarcodeStyle::textOptional() const { return mTextOptional; } + /// + /// Can Checksum Property Getter + /// bool BarcodeStyle::canChecksum() const { return mCanChecksum; } + /// + /// Checksum Optional Property Getter + /// bool BarcodeStyle::checksumOptional() const { return mChecksumOptional; } + /// + /// Default Digits Property Getter + /// const QString& BarcodeStyle::defaultDigits() const { return mDefaultDigits; } + /// + /// Can Freeform Property Getter + /// bool BarcodeStyle::canFreeform() const { return mCanFreeform; } + /// + /// Prefered N Property Getter + /// int BarcodeStyle::preferedN() const { return mPreferedN; } + /// + /// Generate Example Digits + /// QString BarcodeStyle::exampleDigits( int n ) const { if ( mCanFreeform ) diff --git a/app/BarcodeStyle.h b/app/BarcodeStyle.h index 2649c42..941e057 100644 --- a/app/BarcodeStyle.h +++ b/app/BarcodeStyle.h @@ -27,9 +27,15 @@ namespace glabels { - class BarcodeStyle + /// + /// Barcode Style Type + /// + struct BarcodeStyle { + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// public: BarcodeStyle (); @@ -44,6 +50,9 @@ namespace glabels int preferedN ); + ///////////////////////////////// + // Properties + ///////////////////////////////// const QString& id() const; const QString& name() const; @@ -63,9 +72,16 @@ namespace glabels int preferedN() const; + ///////////////////////////////// + // Methods + ///////////////////////////////// + public: QString exampleDigits( int n ) const; + ///////////////////////////////// + // Private Data + ///////////////////////////////// private: QString mId; QString mName; diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 4df608e..37698e4 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -27,10 +27,10 @@ set (glabels_qobject_headers LabelModel.h LabelModelObject.h LabelModelBoxObject.h - MainWindow.h - TemplatePicker.h NewLabelDialog.h + MainWindow.h SimplePreview.h + TemplatePicker.h View.h ) diff --git a/app/ColorNode.cpp b/app/ColorNode.cpp index 2c0546b..0829e88 100644 --- a/app/ColorNode.cpp +++ b/app/ColorNode.cpp @@ -24,30 +24,45 @@ namespace glabels { + /// + /// Default Constructor + /// ColorNode::ColorNode() : mFieldFlag(false), mColor(QColor::fromRgba(0x00000000)), mKey("") { } + /// + /// Constructor From Data + /// ColorNode::ColorNode( bool fieldFlag, const QColor& color, const QString& key ) : mFieldFlag(fieldFlag), mColor(color), mKey(key) { } + /// + /// Constructor From Color + /// ColorNode::ColorNode( const QColor& color ) : mFieldFlag(false), mColor(color), mKey("") { } + /// + /// Constructor From Key + /// ColorNode::ColorNode( const QString& key ) : mFieldFlag(true), mColor(QColor::fromRgba(0x00000000)), mKey(key) { } + /// + /// == Operator + /// bool ColorNode::operator==( const ColorNode& cn ) { return ( (mFieldFlag == cn.mFieldFlag) && @@ -56,6 +71,9 @@ namespace glabels } + /// + /// != Operator + /// bool ColorNode::operator!=( const ColorNode& cn ) { return ( (mFieldFlag != cn.mFieldFlag) || @@ -64,6 +82,33 @@ namespace glabels } + /// + /// Field Flag Property Getter + /// + bool ColorNode::fieldFlag( void ) const + { + return mFieldFlag; + } + + + /// + /// Color Property Getter + /// + const QColor& ColorNode::color( void ) const + { + return mColor; + } + + + /// + /// Key Property + /// + const QString& ColorNode::key( void ) const + { + return mKey; + } + + #if TODO QColor ColorNode::expand( MergeRecord? record ) { @@ -102,23 +147,5 @@ namespace glabels } #endif - - bool ColorNode::fieldFlag( void ) const - { - return mFieldFlag; - } - - - const QColor& ColorNode::color( void ) const - { - return mColor; - } - - - const QString& ColorNode::key( void ) const - { - return mKey; - } - } diff --git a/app/ColorNode.h b/app/ColorNode.h index 4b0a7c9..9013207 100644 --- a/app/ColorNode.h +++ b/app/ColorNode.h @@ -28,9 +28,15 @@ namespace glabels { - class ColorNode + /// + /// Color Node Type + /// + struct ColorNode { + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// public: ColorNode(); @@ -40,27 +46,51 @@ namespace glabels ColorNode( const QString& key ); + + ///////////////////////////////// + // Operators + ///////////////////////////////// + public: bool operator==( const ColorNode& cn ); bool operator!=( const ColorNode& cn ); + + ///////////////////////////////// + // Properties + ///////////////////////////////// + public: + // + // Field Flag Property + // + bool fieldFlag( void ) const; + + + // + // Color Property + // + const QColor& color( void ) const; + + + // + // Key Property + // + const QString& key( void ) const; + + + + ///////////////////////////////// + // Methods + ///////////////////////////////// + public: #if TODO QColor expand( MergeRecord? record ); #endif - // field flag property - bool fieldFlag( void ) const; - - - // color property - const QColor& color( void ) const; - - - // key property - const QString& key( void ) const; - - + ///////////////////////////////// + // Private Data + ///////////////////////////////// private: bool mFieldFlag; QColor mColor; diff --git a/app/File.cpp b/app/File.cpp index efdc06b..a5b96eb 100644 --- a/app/File.cpp +++ b/app/File.cpp @@ -26,6 +26,9 @@ namespace glabels { + /// + /// Open a New Label Dialog + /// void File::newLabel( QWidget *parent ) { NewLabelDialog newDialog( parent ); diff --git a/app/File.h b/app/File.h index 96a14a1..fe4e86b 100644 --- a/app/File.h +++ b/app/File.h @@ -28,6 +28,9 @@ namespace glabels { + /// + /// File Actions + /// namespace File { void newLabel( QWidget *parent ); diff --git a/app/Help.cpp b/app/Help.cpp index 370ea83..98ae170 100644 --- a/app/Help.cpp +++ b/app/Help.cpp @@ -28,12 +28,18 @@ namespace glabels { + /// + /// Display Help Contents + /// void Help::displayContents( QWidget *parent ) { std::cout << "TODO: Help::displayContents" << std::endl; } + /// + /// Display Help->About Dialog + /// void Help::displayAbout( QWidget *parent ) { QMessageBox aboutBox( QMessageBox::NoIcon, diff --git a/app/Help.h b/app/Help.h index 08d0a8f..82439ac 100644 --- a/app/Help.h +++ b/app/Help.h @@ -28,6 +28,9 @@ namespace glabels { + /// + /// Help Actions + /// namespace Help { void displayContents( QWidget *parent ); diff --git a/app/Icons.h b/app/Icons.h index 7ad2332..4bf69fa 100644 --- a/app/Icons.h +++ b/app/Icons.h @@ -27,6 +27,9 @@ namespace glabels { + /// + /// Glabels Icons + /// namespace Icons { @@ -40,6 +43,7 @@ namespace glabels } }; + class Barcode : public QIcon { public: @@ -50,6 +54,7 @@ namespace glabels } }; + class Box : public QIcon { public: @@ -60,6 +65,7 @@ namespace glabels } }; + class Ellipse : public QIcon { public: @@ -70,6 +76,7 @@ namespace glabels } }; + class Image : public QIcon { public: @@ -80,6 +87,7 @@ namespace glabels } }; + class Line : public QIcon { public: @@ -90,6 +98,7 @@ namespace glabels } }; + class Text : public QIcon { public: @@ -100,6 +109,7 @@ namespace glabels } }; + class Merge : public QIcon { public: @@ -110,6 +120,7 @@ namespace glabels } }; + class ObjectProperties : public QIcon { public: @@ -120,6 +131,7 @@ namespace glabels } }; + class AlignLeft : public QIcon { public: @@ -129,6 +141,7 @@ namespace glabels } }; + class AlignHCenter : public QIcon { public: @@ -138,6 +151,7 @@ namespace glabels } }; + class AlignRight : public QIcon { public: @@ -147,6 +161,7 @@ namespace glabels } }; + class AlignBottom : public QIcon { public: @@ -156,6 +171,7 @@ namespace glabels } }; + class AlignVCenter : public QIcon { public: @@ -165,6 +181,7 @@ namespace glabels } }; + class AlignTop : public QIcon { public: @@ -174,6 +191,7 @@ namespace glabels } }; + class CenterHoriz : public QIcon { public: @@ -183,6 +201,7 @@ namespace glabels } }; + class CenterVert : public QIcon { public: @@ -192,6 +211,7 @@ namespace glabels } }; + class FlipHoriz : public QIcon { public: @@ -201,6 +221,7 @@ namespace glabels } }; + class FlipVert : public QIcon { public: @@ -210,6 +231,7 @@ namespace glabels } }; + class RotateLeft : public QIcon { public: @@ -219,6 +241,7 @@ namespace glabels } }; + class RotateRight : public QIcon { public: @@ -228,6 +251,7 @@ namespace glabels } }; + class OrderBottom : public QIcon { public: @@ -237,6 +261,7 @@ namespace glabels } }; + class OrderTop : public QIcon { public: @@ -246,6 +271,7 @@ namespace glabels } }; + class AlignTextBottom : public QIcon { public: @@ -255,6 +281,7 @@ namespace glabels } }; + class AlignTextMiddle : public QIcon { public: @@ -264,6 +291,7 @@ namespace glabels } }; + class AlignTextTop : public QIcon { public: @@ -273,6 +301,7 @@ namespace glabels } }; + class BucketFill : public QIcon { public: @@ -283,6 +312,7 @@ namespace glabels } }; + class Pencil : public QIcon { public: @@ -293,6 +323,7 @@ namespace glabels } }; + class Glabels : public QIcon { public: @@ -307,10 +338,10 @@ namespace glabels }; - /* - * Fallback Icons. These are fallbacks for icons that would normally come from the current theme, - * if supported. These icons are copied from the mate-icon-theme (GPL-v3 or CC-BY-SA-v3). - */ + /// + /// Fallback Icons. These are fallbacks for icons that would normally come from the current theme, + /// if supported. These icons are copied from the mate-icon-theme (GPL-v3 or CC-BY-SA-v3). + /// namespace Fallback { @@ -323,6 +354,7 @@ namespace glabels } }; + class EditCut : public QIcon { public: @@ -332,6 +364,7 @@ namespace glabels } }; + class EditPaste : public QIcon { public: @@ -341,6 +374,7 @@ namespace glabels } }; + class FileNew : public QIcon { public: @@ -350,6 +384,7 @@ namespace glabels } }; + class FileOpen : public QIcon { public: @@ -359,6 +394,7 @@ namespace glabels } }; + class FilePrint : public QIcon { public: @@ -368,6 +404,7 @@ namespace glabels } }; + class FileSave : public QIcon { public: @@ -377,6 +414,7 @@ namespace glabels } }; + class FileSaveAs : public QIcon { public: @@ -386,6 +424,7 @@ namespace glabels } }; + class ZoomBestFit : public QIcon { public: @@ -395,6 +434,7 @@ namespace glabels } }; + class ZoomIn : public QIcon { public: @@ -404,6 +444,7 @@ namespace glabels } }; + class ZoomOriginal : public QIcon { public: @@ -413,6 +454,7 @@ namespace glabels } }; + class ZoomOut : public QIcon { public: diff --git a/app/LabelModel.cpp b/app/LabelModel.cpp index ce576a5..cb3e708 100644 --- a/app/LabelModel.cpp +++ b/app/LabelModel.cpp @@ -29,17 +29,17 @@ namespace glabels { - /** - * Default constructor. - */ + /// + /// Default constructor. + /// LabelModel::LabelModel() : mModified(true), mTmplate(0), mRotate(false) { } - /** - * Add object. - */ + /// + /// Add object. + /// void LabelModel::addObject( LabelModelObject* object ) { object->setParent( this ); @@ -55,6 +55,9 @@ namespace glabels } + /// + /// Object Changed Slot + /// void LabelModel::onObjectChanged() { mModified = true; @@ -64,6 +67,9 @@ namespace glabels } + /// + /// Object Moved Slot + /// void LabelModel::onObjectMoved() { mModified = true; @@ -73,6 +79,9 @@ namespace glabels } + /// + /// Delete Object + /// void LabelModel::deleteObject( LabelModelObject* object ) { object->unselect(); @@ -87,9 +96,9 @@ namespace glabels } - /** - * Select object. - */ + /// + /// Select Object + /// void LabelModel::selectObject( LabelModelObject* object ) { object->select(); @@ -98,9 +107,9 @@ namespace glabels } - /** - * Unselect object. - */ + /// + /// Unselect Object + /// void LabelModel::unselectObject( LabelModelObject* object ) { object->unselect(); @@ -109,9 +118,9 @@ namespace glabels } - /** - * Select all objects. - */ + /// + /// Select All Objects + /// void LabelModel::selectAll() { foreach ( LabelModelObject* object, mObjectList ) @@ -123,9 +132,9 @@ namespace glabels } - /** - * Unselect object all objects. - */ + /// + /// Unselect All Objects + /// void LabelModel::unselectAll() { foreach ( LabelModelObject* object, mObjectList ) @@ -137,6 +146,9 @@ namespace glabels } + /// + /// Select Region + /// void LabelModel::selectRegion( const LabelRegion ®ion ) { double rX1 = std::min( region.x1(), region.x2() ); @@ -161,6 +173,9 @@ namespace glabels } + /// + /// Is Selection Empty? + /// bool LabelModel::isSelectionEmpty() { foreach ( LabelModelObject* object, mObjectList ) @@ -175,6 +190,9 @@ namespace glabels } + /// + /// Is Selection Atomic? + /// bool LabelModel::isSelectionAtomic() { int nSelected = 0; @@ -195,6 +213,9 @@ namespace glabels } + /// + /// Get List of Selected Objects + /// QList LabelModel::getSelection() { QList selectedList; @@ -210,6 +231,9 @@ namespace glabels } + /// + /// Get First Object in Selection List + /// LabelModelObject* LabelModel::getFirstSelectedObject() { foreach ( LabelModelObject* object, mObjectList ) @@ -222,6 +246,9 @@ namespace glabels } + /// + /// Can Any Objects in Selection Accept Text Properties? + /// bool LabelModel::canSelectionText() { foreach ( LabelModelObject* object, mObjectList ) @@ -236,6 +263,9 @@ namespace glabels } + /// + /// Can Any Objects in Selection Accept Fill Property? + /// bool LabelModel::canSelectionFill() { foreach ( LabelModelObject* object, mObjectList ) @@ -250,6 +280,9 @@ namespace glabels } + /// + /// Can Any Objects in Selection Accept Line Color Property? + /// bool LabelModel::canSelectionLineColor() { foreach ( LabelModelObject* object, mObjectList ) @@ -264,6 +297,9 @@ namespace glabels } + /// + /// Can Any Objects in Selection Accept Line Width Property? + /// bool LabelModel::canSelectionLineWidth() { foreach ( LabelModelObject* object, mObjectList ) @@ -278,6 +314,9 @@ namespace glabels } + /// + /// Delete Selected Objects + /// void LabelModel::deleteSelection() { QList selectedList = getSelection(); @@ -294,6 +333,9 @@ namespace glabels } + /// + /// Raise Selected Objects To Top + /// void LabelModel::raiseSelectionToTop() { QList selectedList = getSelection(); @@ -303,7 +345,7 @@ namespace glabels mObjectList.removeOne( object ); } - /* Move to end of list, representing top most object. */ + /// Move to end of list, representing top most object. foreach ( LabelModelObject* object, selectedList ) { mObjectList.push_back( object ); @@ -316,6 +358,9 @@ namespace glabels } + /// + /// Lower Selected Objects To Bottom + /// void LabelModel::lowerSelectionToBottom() { QList selectedList = getSelection(); @@ -325,7 +370,7 @@ namespace glabels mObjectList.removeOne( object ); } - /* Move to front of list, representing bottom most object. */ + /// Move to front of list, representing bottom most object. foreach ( LabelModelObject* object, selectedList ) { mObjectList.push_front( object ); @@ -338,6 +383,9 @@ namespace glabels } + /// + /// Rotate Selected Objects + /// void LabelModel::rotateSelection( double thetaDegs ) { foreach ( LabelModelObject* object, mObjectList ) @@ -354,18 +402,27 @@ namespace glabels } + /// + /// Rotate Selected Objects Left 90 degrees + /// void LabelModel::rotateSelectionLeft() { rotateSelection( -90.0 ); } + /// + /// Rotate Selected Objects Right 90 degrees + /// void LabelModel::rotateSelectionRight() { rotateSelection( 90.0 ); } + /// + /// Flip Selected Objects Horizontally + /// void LabelModel::flipSelectionHoriz() { foreach ( LabelModelObject* object, mObjectList ) @@ -382,6 +439,9 @@ namespace glabels } + /// + /// Flip Selected Objects Vertically + /// void LabelModel::flipSelectionVert() { foreach ( LabelModelObject* object, mObjectList ) @@ -398,6 +458,9 @@ namespace glabels } + /// + /// Align Selected Objects To Their Left Edges + /// void LabelModel::alignSelectionLeft() { if ( isSelectionEmpty() || isSelectionAtomic() ) @@ -407,15 +470,15 @@ namespace glabels QList selectedList = getSelection(); - /* Find left-most edge. */ - double x1_min = 7200; /* Start with a very large value: 7200pts = 100in */ + /// Find left-most edge. + double x1_min = 7200; /// Start with a very large value: 7200pts = 100in foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); if ( r.x1() < x1_min ) x1_min = r.x1(); } - /* Now adjust the object positions to line up the left edges at left-most edge. */ + /// Now adjust the object positions to line up the left edges at left-most edge. foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); @@ -429,6 +492,9 @@ namespace glabels } + /// + /// Align Selected Objects To Their Right Edges + /// void LabelModel::alignSelectionRight() { if ( isSelectionEmpty() || isSelectionAtomic() ) @@ -438,15 +504,15 @@ namespace glabels QList selectedList = getSelection(); - /* Find right-most edge. */ - double x1_max = -7200; /* Start with a very large negative value: 7200pts = 100in */ + /// Find right-most edge. + double x1_max = -7200; /// Start with a very large negative value: 7200pts = 100in foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); if ( r.x1() > x1_max ) x1_max = r.x1(); } - /* Now adjust the object positions to line up the right edges at right-most edge. */ + /// Now adjust the object positions to line up the right edges at right-most edge. foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); @@ -460,6 +526,9 @@ namespace glabels } + /// + /// Align Selected Objects To Their Horizontal Centers + /// void LabelModel::alignSelectionHCenter() { if ( isSelectionEmpty() || isSelectionAtomic() ) @@ -469,7 +538,7 @@ namespace glabels QList selectedList = getSelection(); - /* Find average center of objects. */ + /// Find average center of objects. double xsum = 0; int n = 0; foreach ( LabelModelObject* object, selectedList ) @@ -480,8 +549,8 @@ namespace glabels } double xavg = xsum / n; - /* Find object closest to average center of objects. */ - double xcenter = 7200; /* Start with very large value. */ + /// Find object closest to average center of objects. + double xcenter = 7200; /// Start with very large value. double dxmin = fabs( xavg - xcenter ); foreach ( LabelModelObject* object, selectedList ) { @@ -494,7 +563,7 @@ namespace glabels } } - /* Now adjust the object positions to line up with the center of this object. */ + /// Now adjust the object positions to line up with the center of this object. foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); @@ -508,6 +577,9 @@ namespace glabels } + /// + /// Align Selected Objects To Their Top Edges + /// void LabelModel::alignSelectionTop() { if ( isSelectionEmpty() || isSelectionAtomic() ) @@ -517,15 +589,15 @@ namespace glabels QList selectedList = getSelection(); - /* Find top-most edge. */ - double y1_min = 7200; /* Start with a very large value: 7200pts = 100in */ + /// Find top-most edge. + double y1_min = 7200; /// Start with a very large value: 7200pts = 100in foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); if ( r.y1() < y1_min ) y1_min = r.y1(); } - /* Now adjust the object positions to line up the top edges at top-most edge. */ + /// Now adjust the object positions to line up the top edges at top-most edge. foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); @@ -539,6 +611,9 @@ namespace glabels } + /// + /// Align Selected Objects To Their Bottom Edges + /// void LabelModel::alignSelectionBottom() { if ( isSelectionEmpty() || isSelectionAtomic() ) @@ -548,15 +623,15 @@ namespace glabels QList selectedList = getSelection(); - /* Find bottom-most edge. */ - double y1_max = -7200; /* Start with a very large negative value: 7200pts = 100in */ + /// Find bottom-most edge. + double y1_max = -7200; /// Start with a very large negative value: 7200pts = 100in foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); if ( r.y1() > y1_max ) y1_max = r.y1(); } - /* Now adjust the object positions to line up the bottom edges at bottom-most edge. */ + /// Now adjust the object positions to line up the bottom edges at bottom-most edge. foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); @@ -570,6 +645,9 @@ namespace glabels } + /// + /// Align Selected Objects To Their Vertical Centers Edges + /// void LabelModel::alignSelectionVCenter() { if ( isSelectionEmpty() || isSelectionAtomic() ) @@ -579,7 +657,7 @@ namespace glabels QList selectedList = getSelection(); - /* Find average center of objects. */ + /// Find average center of objects. double ysum = 0; int n = 0; foreach ( LabelModelObject* object, selectedList ) @@ -590,8 +668,8 @@ namespace glabels } double yavg = ysum / n; - /* Find object closest to average center of objects. */ - double ycenter = 7200; /* Start with very large value. */ + /// Find object closest to average center of objects. + double ycenter = 7200; /// Start with very large value. double dymin = fabs( yavg - ycenter ); foreach ( LabelModelObject* object, selectedList ) { @@ -604,7 +682,7 @@ namespace glabels } } - /* Now adjust the object positions to line up with the center of this object. */ + /// Now adjust the object positions to line up with the center of this object. foreach ( LabelModelObject* object, selectedList ) { LabelRegion r = object->getExtent(); @@ -618,6 +696,9 @@ namespace glabels } + /// + /// Align Selected Objects To Center Of Label Horizontally + /// void LabelModel::centerSelectionHoriz() { double xLabelCenter = w() / 2.0; @@ -639,6 +720,9 @@ namespace glabels } + /// + /// Align Selected Objects To Center Of Label Vertically + /// void LabelModel::centerSelectionVert() { double yLabelCenter = h() / 2.0; @@ -660,6 +744,9 @@ namespace glabels } + /// + /// Move Selected Objects By dx,dy + /// void LabelModel::moveSelection( double dx, double dy ) { foreach ( LabelModelObject* object, mObjectList ) @@ -676,6 +763,9 @@ namespace glabels } + /// + /// Set Font Family Of Selected Objects + /// void LabelModel::setSelectionFontFamily( const QString &fontFamily ) { foreach ( LabelModelObject* object, mObjectList ) @@ -692,6 +782,9 @@ namespace glabels } + /// + /// Set Font Size Of Selected Objects + /// void LabelModel::setSelectionFontSize( double fontSize ) { foreach ( LabelModelObject* object, mObjectList ) @@ -708,6 +801,9 @@ namespace glabels } + /// + /// Set Font Weight Of Selected Objects + /// void LabelModel::setSelectionFontWeight( QFont::Weight fontWeight ) { foreach ( LabelModelObject* object, mObjectList ) @@ -724,6 +820,9 @@ namespace glabels } + /// + /// Set Font Italic Flag Of Selected Objects + /// void LabelModel::setSelectionFontItalicFlag( bool fontItalicFlag ) { foreach ( LabelModelObject* object, mObjectList ) @@ -740,6 +839,9 @@ namespace glabels } + /// + /// Set Text Horizontal Alignment Of Selected Objects + /// void LabelModel::setSelectionTextHAlign( Qt::Alignment textHAlign ) { foreach ( LabelModelObject* object, mObjectList ) @@ -756,6 +858,9 @@ namespace glabels } + /// + /// Set Text Vertical Alignment Of Selected Objects + /// void LabelModel::setSelectionTextVAlign( Qt::Alignment textVAlign ) { foreach ( LabelModelObject* object, mObjectList ) @@ -772,6 +877,9 @@ namespace glabels } + /// + /// Set Text Line Spacing Of Selected Objects + /// void LabelModel::setSelectionTextLineSpacing( double textLineSpacing ) { foreach ( LabelModelObject* object, mObjectList ) @@ -788,6 +896,9 @@ namespace glabels } + /// + /// Set Text Color Node Of Selected Objects + /// void LabelModel::setSelectionTextColorNode( ColorNode textColorNode ) { foreach ( LabelModelObject* object, mObjectList ) @@ -804,6 +915,9 @@ namespace glabels } + /// + /// Set Line Width Of Selected Objects + /// void LabelModel::setSelectionLineWidth( double lineWidth ) { foreach ( LabelModelObject* object, mObjectList ) @@ -820,6 +934,9 @@ namespace glabels } + /// + /// Set Line Color Node Of Selected Objects + /// void LabelModel::setSelectionLineColorNode( ColorNode lineColorNode ) { foreach ( LabelModelObject* object, mObjectList ) @@ -836,6 +953,9 @@ namespace glabels } + /// + /// Set Fill Color Node Of Selected Objects + /// void LabelModel::setSelectionFillColorNode( ColorNode fillColorNode ) { foreach ( LabelModelObject* object, mObjectList ) diff --git a/app/LabelModelBoxObject.cpp b/app/LabelModelBoxObject.cpp index c9ffb02..f9d3541 100644 --- a/app/LabelModelBoxObject.cpp +++ b/app/LabelModelBoxObject.cpp @@ -28,23 +28,35 @@ namespace glabels { + /// + /// Constructor + /// LabelModelBoxObject::LabelModelBoxObject( QObject* parent ) : LabelModelObject(parent) { /* TODO: initialize default line and fill poperties. */ } + /// + /// Destructor + /// LabelModelBoxObject::~LabelModelBoxObject() { } + /// + /// Line Width Property Getter + /// double LabelModelBoxObject::lineWidth( void ) const { return mLineWidth; } + /// + /// Line Width Property Setter + /// void LabelModelBoxObject::setLineWidth( double value ) { if ( mLineWidth != value ) @@ -55,12 +67,18 @@ namespace glabels } + /// + /// Line Color Node Property Getter + /// ColorNode LabelModelBoxObject::lineColorNode( void ) const { return mLineColorNode; } + /// + /// Line Color Node Property Setter + /// void LabelModelBoxObject::setLineColorNode( const ColorNode& value ) { if ( mLineColorNode != value ) @@ -71,12 +89,18 @@ namespace glabels } + /// + /// Fill Color Node Property Getter + /// ColorNode LabelModelBoxObject::fillColorNode( void ) const { return mFillColorNode; } + /// + /// Fill Color Node Property Setter + /// void LabelModelBoxObject::setFillColorNode( const ColorNode& value ) { if ( mFillColorNode != value ) @@ -87,25 +111,36 @@ namespace glabels } + /// + /// Can Fill Capability Implementation + /// bool LabelModelBoxObject::canFill() { return true; } + /// + /// Can Line Color Capability Implementation + /// bool LabelModelBoxObject::canLineColor() { return true; } + /// + /// Can Line Width Capability Implementation + /// bool LabelModelBoxObject::canLineWidth() { return true; } - // Create QGraphicsItem suitable for representing this object + /// + /// Create QGraphicsItem suitable for representing this object + /// QGraphicsItem* LabelModelBoxObject::createGraphicsItem() { QGraphicsRectItem *rectItem = new QGraphicsRectItem( x0(), y0(), w(), h() ); @@ -125,7 +160,9 @@ namespace glabels } - // Update a QGraphicsItem to keep it in sync with this object + /// + /// Update a QGraphicsItem to keep it in sync with this object + /// void LabelModelBoxObject::updateGraphicsItem( QGraphicsItem* graphicsItem ) { QGraphicsRectItem *rectItem = dynamic_cast(graphicsItem); diff --git a/app/LabelModelBoxObject.h b/app/LabelModelBoxObject.h index d5661e2..e17b4fb 100644 --- a/app/LabelModelBoxObject.h +++ b/app/LabelModelBoxObject.h @@ -27,6 +27,9 @@ namespace glabels { + /// + /// Label Model Box Object + /// class LabelModelBoxObject : public LabelModelObject { Q_OBJECT @@ -40,32 +43,32 @@ namespace glabels /////////////////////////////////////////////////////////////// - // Properties + // Property Implementations /////////////////////////////////////////////////////////////// public: - /* - * Virtual Shape Property: lineWidth - */ + // + // Shape Property: lineWidth + // virtual double lineWidth( void ) const; virtual void setLineWidth( double value ); - /* - * Virtual Shape Property: lineColorNode - */ + // + // Shape Property: lineColorNode + // virtual ColorNode lineColorNode( void ) const; virtual void setLineColorNode( const ColorNode& value ); - /* - * Virtual Shape Property: fillColorNode - */ + // + // Shape Property: fillColorNode + // virtual ColorNode fillColorNode( void ) const; virtual void setFillColorNode( const ColorNode& value ); /////////////////////////////////////////////////////////////// - // Capabilities + // Capability Implementations /////////////////////////////////////////////////////////////// public: virtual bool canFill(); @@ -74,11 +77,11 @@ namespace glabels /////////////////////////////////////////////////////////////// - // QGraphicsItem methods + // QGraphicsItem Method Implementations /////////////////////////////////////////////////////////////// public: - QGraphicsItem* createGraphicsItem(); - void updateGraphicsItem( QGraphicsItem* graphicsItem ); + virtual QGraphicsItem* createGraphicsItem(); + virtual void updateGraphicsItem( QGraphicsItem* graphicsItem ); /////////////////////////////////////////////////////////////// diff --git a/app/LabelModelObject.cpp b/app/LabelModelObject.cpp index f9dbf78..085857a 100644 --- a/app/LabelModelObject.cpp +++ b/app/LabelModelObject.cpp @@ -35,14 +35,18 @@ namespace glabels { - int LabelModelObject::lastId = 0; + /// + /// Next Object ID + /// + int LabelModelObject::msNextId = 0; - /* - * Default constructor. - */ + + /// + /// Constructor + /// LabelModelObject::LabelModelObject( QObject *parent = 0 ) : QObject(parent) { - mId = lastId++; + mId = msNextId++; mX0 = 0; mY0 = 0; @@ -60,41 +64,62 @@ namespace glabels } + /// + /// Destructor + /// LabelModelObject::~LabelModelObject() { } + /// + /// ID Property Getter + /// int LabelModelObject::id() const { return mId; } + /// + /// Selected Property Getter + /// bool LabelModelObject::isSelected() const { return mSelectedFlag; } + /// + /// Selected Property Setter + /// void LabelModelObject::select( bool value ) { mSelectedFlag = value; } + /// + /// Clear Selected Property Setter + /// void LabelModelObject::unselect() { mSelectedFlag = false; } + /// + /// X0 Property Getter + /// double LabelModelObject::x0() const { return mX0; } + /// + /// X0 Property Setter + /// void LabelModelObject::setX0( double value ) { if ( mX0 != value ) @@ -105,12 +130,18 @@ namespace glabels } + /// + /// Y0 Property Getter + /// double LabelModelObject::y0() const { return mY0; } + /// + /// Y0 Property Setter + /// void LabelModelObject::setY0( double value ) { if ( mY0 != value ) @@ -121,12 +152,18 @@ namespace glabels } + /// + /// W (Width) Property Getter + /// double LabelModelObject::w() const { return mW; } + /// + /// W (Width) Property Setter + /// void LabelModelObject::setW( double value ) { if ( mW != value ) @@ -137,12 +174,18 @@ namespace glabels } + /// + /// H (Height) Property Getter + /// double LabelModelObject::h() const { return mH; } + /// + /// H (Height) Property Setter + /// void LabelModelObject::setH( double value ) { if ( mH != value ) @@ -153,12 +196,18 @@ namespace glabels } + /// + /// Matrix Property Getter + /// QTransform LabelModelObject::matrix() const { return mMatrix; } + /// + /// Matrix Property Setter + /// void LabelModelObject::setMatrix( const QTransform& value ) { if ( mMatrix != value ) @@ -169,12 +218,18 @@ namespace glabels } + /// + /// Shadow State Property Getter + /// bool LabelModelObject::shadow() const { return mShadowState; } + /// + /// Shadow State Property Setter + /// void LabelModelObject::setShadow( bool value ) { if ( mShadowState != value ) @@ -185,12 +240,18 @@ namespace glabels } + /// + /// Shadow X Property Getter + /// double LabelModelObject::shadowX() const { return mShadowX; } + /// + /// Shadow X Property Setter + /// void LabelModelObject::setShadowX( double value ) { if ( mShadowX != value ) @@ -201,12 +262,18 @@ namespace glabels } + /// + /// Shadow Y Property Getter + /// double LabelModelObject::shadowY() const { return mShadowY; } + /// + /// Shadow Y Property Setter + /// void LabelModelObject::setShadowY( double value ) { if ( mShadowY != value ) @@ -217,12 +284,18 @@ namespace glabels } + /// + /// Shadow Opacity Property Getter + /// double LabelModelObject::shadowOpacity() const { return mShadowOpacity; } + /// + /// Shadow Opacity Property Setter + /// void LabelModelObject::setShadowOpacity( double value ) { if ( mShadowOpacity != value ) @@ -233,12 +306,18 @@ namespace glabels } + /// + /// Shadow Color Node Property Getter + /// ColorNode LabelModelObject::shadowColorNode() const { return mShadowColorNode; } + /// + /// Shadow Color Node Property Setter + /// void LabelModelObject::setShadowColorNode( const ColorNode& value ) { if ( mShadowColorNode != value ) @@ -249,239 +328,410 @@ namespace glabels } + /// + /// Virtual Font Family Property Default Getter + /// (Overridden by concrete class) + /// QString LabelModelObject::fontFamily() const { return ""; } + /// + /// Virtual Font Family Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setFontFamily( const QString& value ) { } + /// + /// Virtual Font Size Property Default Getter + /// (Overridden by concrete class) + /// double LabelModelObject::fontSize() const { return 0; } + /// + /// Virtual Font Size Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setFontSize( double value ) { } + /// + /// Virtual Font Weight Property Default Getter + /// (Overridden by concrete class) + /// QFont::Weight LabelModelObject::fontWeight() const { return QFont::Normal; } + /// + /// Virtual Font Weight Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setFontWeight( QFont::Weight value ) { } + /// + /// Virtual Font Italic Flag Property Default Getter + /// (Overridden by concrete class) + /// bool LabelModelObject::fontItalicFlag() const { return false; } + /// + /// Virtual Font Italic Flag Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setFontItalicFlag( bool value ) { } + /// + /// Virtual Font Underline Flag Property Default Getter + /// (Overridden by concrete class) + /// bool LabelModelObject::fontUnderlineFlag() const { return false; } + /// + /// Virtual Font Underline Flag Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setFontUnderlineFlag( bool value ) { } + /// + /// Virtual Text Color Node Property Default Getter + /// (Overridden by concrete class) + /// ColorNode LabelModelObject::textColorNode() const { return ColorNode( QColor::fromRgba(0x00000000) ); } + /// + /// Virtual Text Color Node Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setTextColorNode( const ColorNode &value ) { } + /// + /// Virtual Text Horizontal Alignment Property Default Getter + /// (Overridden by concrete class) + /// Qt::Alignment LabelModelObject::textHAlign() const { return Qt::AlignLeft; } + /// + /// Virtual Text Horizontal Alignment Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setTextHAlign( Qt::Alignment value ) { } + /// + /// Virtual Text Vertical Alignment Property Default Getter + /// (Overridden by concrete class) + /// Qt::Alignment LabelModelObject::textVAlign() const { return Qt::AlignTop; } + /// + /// Virtual Text Vertical Alignment Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setTextVAlign( Qt::Alignment value ) { } + /// + /// Virtual Text Line Spacing Property Default Getter + /// (Overridden by concrete class) + /// double LabelModelObject::textLineSpacing() const { return 0; } + /// + /// Virtual Text Line Spacing Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setTextLineSpacing( double value ) { } + /// + /// Virtual Filename Node Property Default Getter + /// (Overridden by concrete class) + /// TextNode LabelModelObject::filenameNode() const { return TextNode(); } + /// + /// Virtual Filename Node Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setFilenameNode( const TextNode& value ) { } + /// + /// Virtual Line Width Property Default Getter + /// (Overridden by concrete class) + /// double LabelModelObject::lineWidth() const { return 0; } + /// + /// Virtual Line Width Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setLineWidth( double value ) { } + /// + /// Virtual Line Color Node Property Default Getter + /// (Overridden by concrete class) + /// ColorNode LabelModelObject::lineColorNode() const { return ColorNode( QColor::fromRgba(0x00000000) ); } + /// + /// Virtual Line Color Node Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setLineColorNode( const ColorNode &value ) { } + /// + /// Virtual Fill Color Node Property Default Getter + /// (Overridden by concrete class) + /// ColorNode LabelModelObject::fillColorNode() const { return ColorNode( QColor::fromRgba(0x00000000) ); } + /// + /// Virtual Fill Color Node Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setFillColorNode( const ColorNode &value ) { } + /// + /// Virtual Barcode Data Node Property Default Getter + /// (Overridden by concrete class) + /// TextNode LabelModelObject::bcDataNode() const { return TextNode(); } + /// + /// Virtual Barcode Data Node Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setBcDataNode( const TextNode &value ) { } + /// + /// Virtual Barcode Text Flag Property Default Getter + /// (Overridden by concrete class) + /// bool LabelModelObject::bcTextFlag() const { return false; } + /// + /// Virtual Barcode Text Flag Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setBcTextFlag( bool value ) { } + /// + /// Virtual Barcode Checksum Flag Property Default Getter + /// (Overridden by concrete class) + /// bool LabelModelObject::bcChecksumFlag() const { return false; } + /// + /// Virtual Barcode Checksum Flag Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setBcChecksumFlag( bool value ) { } + /// + /// Virtual Barcode Color Node Property Default Getter + /// (Overridden by concrete class) + /// ColorNode LabelModelObject::bcColorNode() const { return ColorNode( QColor::fromRgba(0x00000000) ); } + /// + /// Virtual Barcode Color Node Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setBcColorNode( const ColorNode &value ) { } + /// + /// Virtual Barcode Style Property Default Getter + /// (Overridden by concrete class) + /// BarcodeStyle LabelModelObject::bcStyle() const { return BarcodeStyle(); } + /// + /// Virtual Barcode Style Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setBcStyle( const BarcodeStyle &value ) { } + /// + /// Virtual Barcode Format Digits Property Default Getter + /// (Overridden by concrete class) + /// int LabelModelObject::bcFormatDigits() const { - return false; + return 0; } + /// + /// Virtual Barcode Format Digits Property Default Setter + /// (Overridden by concrete class) + /// void LabelModelObject::setBcFormatDigits( int value ) { } + /// + /// Virtual Can Text Capability Read-Only Property Default Getter + /// (Overridden by concrete class) + /// bool LabelModelObject::canText() const { return false; } + /// + /// Virtual Can Fill Capability Read-Only Property Default Getter + /// (Overridden by concrete class) + /// bool LabelModelObject::canFill() const { return false; } + /// + /// Virtual Can Line Color Capability Read-Only Property Default Getter + /// (Overridden by concrete class) + /// bool LabelModelObject::canLineColor() const { return false; } + /// + /// Virtual Can Line Width Capability Read-Only Property Default Getter + /// (Overridden by concrete class) + /// bool LabelModelObject::canLineWidth() const { return false; } + /// + /// Set Absolute Position + /// void LabelModelObject::setPosition( double x0, double y0 ) { if ( ( mX0 != x0 ) || ( mY0 != y0 ) ) @@ -494,6 +744,9 @@ namespace glabels } + /// + /// Set Relative Position + /// void LabelModelObject::setPositionRelative( double dx, double dy ) { if ( ( dx != 0 ) || ( dy != 0 ) ) @@ -506,6 +759,9 @@ namespace glabels } + /// + /// Set Size + /// void LabelModelObject::setSize( double w, double h ) { mW = w; @@ -513,6 +769,9 @@ namespace glabels } + /// + /// Set Size (But Maintain Current Aspect Ratio) + /// void LabelModelObject::setSizeHonorAspect( double w, double h ) { double aspectRatio = mH / mW; @@ -536,6 +795,9 @@ namespace glabels } + /// + /// Set Width (But Maintain Current Aspect Ratio) + /// void LabelModelObject::setWHonorAspect( double w ) { double aspectRatio = mH / mW; @@ -551,6 +813,9 @@ namespace glabels } + /// + /// Set Height (But Maintain Current Aspect Ratio) + /// void LabelModelObject::setHHonorAspect( double h ) { double aspectRatio = mH / mW; @@ -566,6 +831,9 @@ namespace glabels } + /// + /// Get Extent of Bounding Box + /// LabelRegion LabelModelObject::getExtent() { QPointF a1( - lineWidth()/2, - lineWidth()/2 ); @@ -579,15 +847,18 @@ namespace glabels a4 = mMatrix.map( a4 ); LabelRegion region; - region.x1( std::min( a1.x(), std::min( a2.x(), std::min( a3.x(), a4.x() ) ) ) + mX0 ); - region.y1( std::min( a1.y(), std::min( a2.y(), std::min( a3.y(), a4.y() ) ) ) + mY0 ); - region.x2( std::max( a1.x(), std::max( a2.x(), std::max( a3.x(), a4.x() ) ) ) + mX0 ); - region.y2( std::max( a1.y(), std::max( a2.y(), std::max( a3.y(), a4.y() ) ) ) + mY0 ); + region.setX1( std::min( a1.x(), std::min( a2.x(), std::min( a3.x(), a4.x() ) ) ) + mX0 ); + region.setY1( std::min( a1.y(), std::min( a2.y(), std::min( a3.y(), a4.y() ) ) ) + mY0 ); + region.setX2( std::max( a1.x(), std::max( a2.x(), std::max( a3.x(), a4.x() ) ) ) + mX0 ); + region.setY2( std::max( a1.y(), std::max( a2.y(), std::max( a3.y(), a4.y() ) ) ) + mY0 ); return region; } + /// + /// Rotate Object + /// void LabelModelObject::rotate( double thetaDegs ) { if ( thetaDegs != 0 ) @@ -598,6 +869,9 @@ namespace glabels } + /// + /// Flip Object Horizontally + /// void LabelModelObject::flipHoriz() { mMatrix = mMatrix.scale( -1, 1 ); @@ -605,6 +879,9 @@ namespace glabels } + /// + /// Flip Object Vertically + /// void LabelModelObject::flipVert() { mMatrix = mMatrix.scale( 1, -1 ); @@ -612,12 +889,18 @@ namespace glabels } + /// + /// Update Representative Graphics Item with Object's Transformation Matrix + /// void LabelModelObject::updateGraphicsItemMatrix( QGraphicsItem* graphicsItem ) { graphicsItem->setTransform( mMatrix ); } + /// + /// Update Representative Graphics Item with Object's Shadow Properties + /// void LabelModelObject::updateGraphicsItemShadow( QGraphicsItem* graphicsItem ) { QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(); diff --git a/app/LabelModelObject.h b/app/LabelModelObject.h index 0706efb..77148a5 100644 --- a/app/LabelModelObject.h +++ b/app/LabelModelObject.h @@ -39,6 +39,9 @@ namespace glabels class MergeRecord; + /// + /// Label Model Object Base Class + /// class LabelModelObject : public QObject { Q_OBJECT @@ -63,16 +66,16 @@ namespace glabels // Common Properties /////////////////////////////////////////////////////////////// public: - /* - * ID Property. - */ + // + // ID Property. + // Q_PROPERTY( int id READ id ) int id() const; - /* - * Selected Property. - */ + // + // Selected Property. + // Q_PROPERTY( bool selected READ isSelected WRITE select RESET unselect ) bool isSelected() const; @@ -80,90 +83,90 @@ namespace glabels void unselect(); - /* - * x0 Property ( x coordinate of origin ) - */ + // + // x0 Property ( x coordinate of origin ) + // Q_PROPERTY( double x0 READ x0 WRITE setX0 ); double x0() const; void setX0( double value ); - /* - * y0 Property ( y coordinate of origin ) - */ + // + // y0 Property ( y coordinate of origin ) + // Q_PROPERTY( double y0 READ y0 WRITE setY0 ); double y0() const; void setY0( double value ); - /* - * w Property ( width of bounding box ) - */ + // + // w Property ( width of bounding box ) + // Q_PROPERTY( double w READ w WRITE setW ); double w() const; void setW( double value ); - /* - * h Property ( height of bounding box ) - */ + // + // h Property ( height of bounding box ) + // Q_PROPERTY( double h READ h WRITE setH ); double h() const; void setH( double value ); - /* - * Transformation Matrix Property - */ + // + // Transformation Matrix Property + // Q_PROPERTY( QTransform matrix READ matrix WRITE setMatrix ); QTransform matrix() const; void setMatrix( const QTransform& value ); - /* - * Shadow State Property - */ + // + // Shadow State Property + // Q_PROPERTY( bool shadow READ shadow WRITE setShadow ); bool shadow() const; void setShadow( bool value ); - /* - * Shadow x Offset Property - */ + // + // Shadow x Offset Property + // Q_PROPERTY( double shadowX READ shadowX WRITE setShadowX ); double shadowX() const; void setShadowX( double value ); - /* - * Shadow y Offset Property - */ + // + // Shadow y Offset Property + // Q_PROPERTY( double shadowY READ shadowY WRITE setShadowY ); double shadowY() const; void setShadowY( double value ); - /* - * Shadow opacity Property - */ + // + // Shadow opacity Property + // Q_PROPERTY( double shadowOpacity READ shadowOpacity WRITE setShadowOpacity ); double shadowOpacity() const; void setShadowOpacity( double value ); - /* - * Shadow Color Property - */ + // + // Shadow Color Property + // Q_PROPERTY( ColorNode shadowColorNode READ shadowColorNode WRITE setShadowColorNode ); ColorNode shadowColorNode() const; @@ -174,81 +177,81 @@ namespace glabels // Text Properties Virtual Interface /////////////////////////////////////////////////////////////// public: - /* - * Virtual Text Property: fontFamily - */ + // + // Virtual Text Property: fontFamily + // Q_PROPERTY( QString fontFamily READ fontFamily WRITE setFontFamily ); virtual QString fontFamily() const; virtual void setFontFamily( const QString &value ); - /* - * Virtual Text Property: fontSize - */ + // + // Virtual Text Property: fontSize + // Q_PROPERTY( double fontSize READ fontSize WRITE setFontSize ); virtual double fontSize() const; virtual void setFontSize( double value ); - /* - * Virtual Text Property: fontWeight - */ + // + // Virtual Text Property: fontWeight + // Q_PROPERTY( QFont::Weight fontWeight READ fontWeight WRITE setFontWeight ); virtual QFont::Weight fontWeight() const; virtual void setFontWeight( QFont::Weight value ); - /* - * Virtual Text Property: fontItalicFlag - */ + // + // Virtual Text Property: fontItalicFlag + // Q_PROPERTY( bool fontItalicFlag READ fontItalicFlag WRITE setFontItalicFlag ); virtual bool fontItalicFlag() const; virtual void setFontItalicFlag( bool value ); - /* - * Virtual Text Property: fontUnderlineFlag - */ + // + // Virtual Text Property: fontUnderlineFlag + // Q_PROPERTY( bool fontUnderlineFlag READ fontUnderlineFlag WRITE setFontUnderlineFlag ); virtual bool fontUnderlineFlag() const; virtual void setFontUnderlineFlag( bool value ); - /* - * Virtual Text Property: textColorNode - */ + // + // Virtual Text Property: textColorNode + // Q_PROPERTY( ColorNode textColorNode READ textColorNode WRITE setTextColorNode ); virtual ColorNode textColorNode() const; virtual void setTextColorNode( const ColorNode &value ); - /* - * Virtual Text Property: textHAlign - */ + // + // Virtual Text Property: textHAlign + // Q_PROPERTY( Qt::Alignment textHAlign READ textHAlign WRITE setTextHAlign ); virtual Qt::Alignment textHAlign() const; virtual void setTextHAlign( Qt::Alignment value ); - /* - * Virtual Text Property: textVAlign - */ + // + // Virtual Text Property: textVAlign + // Q_PROPERTY( Qt::Alignment textVAlign READ textVAlign WRITE setTextVAlign ); virtual Qt::Alignment textVAlign() const; virtual void setTextVAlign( Qt::Alignment value ); - /* - * Virtual Text Property: textLineSpacing - */ + // + // Virtual Text Property: textLineSpacing + // Q_PROPERTY( double textLineSpacing READ textLineSpacing WRITE setTextLineSpacing ); virtual double textLineSpacing() const; @@ -259,9 +262,9 @@ namespace glabels // Image Properties Virtual Interface /////////////////////////////////////////////////////////////// public: - /* - * Virtual Image Property: filenameNode - */ + // + // Virtual Image Property: filenameNode + // Q_PROPERTY( TextNode filenameNode READ filenameNode WRITE setFilenameNode ); virtual TextNode filenameNode() const; @@ -272,27 +275,27 @@ namespace glabels // Shape Properties Virtual Interface /////////////////////////////////////////////////////////////// public: - /* - * Virtual Shape Property: lineWidth - */ + // + // Virtual Shape Property: lineWidth + // Q_PROPERTY( double lineWidth READ lineWidth WRITE setLineWidth ); virtual double lineWidth() const; virtual void setLineWidth( double value ); - /* - * Virtual Shape Property: lineColorNode - */ + // + // Virtual Shape Property: lineColorNode + // Q_PROPERTY( ColorNode lineColorNode READ lineColorNode WRITE setLineColorNode ); virtual ColorNode lineColorNode() const; virtual void setLineColorNode( const ColorNode &value ); - /* - * Virtual Shape Property: fillColorNode - */ + // + // Virtual Shape Property: fillColorNode + // Q_PROPERTY( ColorNode fillColorNode READ fillColorNode WRITE setFillColorNode ); virtual ColorNode fillColorNode() const; @@ -303,54 +306,54 @@ namespace glabels // Barcode Properties Virtual Interface /////////////////////////////////////////////////////////////// public: - /* - * Virtual Barcode Property: bcDataNode - */ + // + // Virtual Barcode Property: bcDataNode + // Q_PROPERTY( TextNode bcDataNode READ bcDataNode WRITE setBcDataNode ); virtual TextNode bcDataNode() const; virtual void setBcDataNode( const TextNode &value ); - /* - * Virtual Barcode Property: bcTextFlag - */ + // + // Virtual Barcode Property: bcTextFlag + // Q_PROPERTY( bool bcTextFlag READ bcTextFlag WRITE setBcTextFlag ); virtual bool bcTextFlag() const; virtual void setBcTextFlag( bool value ); - /* - * Virtual Barcode Property: bcChecksumFlag - */ + // + // Virtual Barcode Property: bcChecksumFlag + // Q_PROPERTY( bool bcChecksumFlag READ bcChecksumFlag WRITE setBcChecksumFlag ); virtual bool bcChecksumFlag() const; virtual void setBcChecksumFlag( bool value ); - /* - * Virtual Barcode Property: bcColorNode - */ + // + // Virtual Barcode Property: bcColorNode + // Q_PROPERTY( ColorNode bcColorNode READ bcColorNode WRITE setBcColorNode ); virtual ColorNode bcColorNode() const; virtual void setBcColorNode( const ColorNode &value ); - /* - * Virtual Barcode Property: bcStyle - */ + // + // Virtual Barcode Property: bcStyle + // Q_PROPERTY( BarcodeStyle bcStyle READ bcStyle WRITE setBcStyle ); virtual BarcodeStyle bcStyle() const; virtual void setBcStyle( const BarcodeStyle &value ); - /* - * Virtual Barcode Property: bcFormatDigits - */ + // + // Virtual Barcode Property: bcFormatDigits + // Q_PROPERTY( int bcFormatDigits READ bcFormatDigits WRITE setBcFormatDigits ); virtual int bcFormatDigits() const; @@ -399,7 +402,7 @@ namespace glabels // Private Members /////////////////////////////////////////////////////////////// private: - static int lastId; + static int msNextId; int mId; bool mSelectedFlag; diff --git a/app/LabelRegion.h b/app/LabelRegion.h index 62675e1..b10fbfc 100644 --- a/app/LabelRegion.h +++ b/app/LabelRegion.h @@ -25,22 +25,48 @@ namespace glabels { + /// + /// Label Region Type + /// struct LabelRegion { + + ///////////////////////////////// + // Properties + ///////////////////////////////// public: - inline double x1( void ) const { return mX1; } - inline void x1( double value ) { mX1 = value; } - - inline double y1( void ) const { return mY1; } - inline void y1( double value ) { mY1 = value; } - - inline double x2( void ) const { return mX2; } - inline void x2( double value ) { mX2 = value; } - - inline double y2( void ) const { return mY2; } - inline void y2( double value ) { mY2 = value; } + // + // X1 Property + // + inline double x1( void ) const; + inline void setX1( double value ); + // + // Y1 Property + // + inline double y1( void ) const; + inline void setY1( double value ); + + + // + // X2 Property + // + inline double x2( void ) const; + inline void setX2( double value ); + + + + // + // Y2 Property + // + inline double y2( void ) const; + inline void setY2( double value ); + + + ///////////////////////////////// + // Private Data + ///////////////////////////////// private: double mX1; double mY1; @@ -48,6 +74,57 @@ namespace glabels double mY2; }; + + ///////////////////////////////// + // INLINE METHODS + ///////////////////////////////// + double LabelRegion::x1( void ) const + { + return mX1; + } + + + void LabelRegion::setX1( double value ) + { + mX1 = value; + } + + + double LabelRegion::y1( void ) const + { + return mY1; + } + + + void LabelRegion::setY1( double value ) + { + mY1 = value; + } + + + double LabelRegion::x2( void ) const + { + return mX2; + } + + + void LabelRegion::setX2( double value ) + { + mX2 = value; + } + + + double LabelRegion::y2( void ) const + { + return mY2; + } + + + void LabelRegion::setY2( double value ) + { + mY2 = value; + } + } #endif // glabels_LabelRegion_h diff --git a/app/MainWindow.cpp b/app/MainWindow.cpp index fe26ff8..097e488 100644 --- a/app/MainWindow.cpp +++ b/app/MainWindow.cpp @@ -43,6 +43,9 @@ namespace glabels { + /// + /// Constructor + /// MainWindow::MainWindow() { /////////////// TEMPORARY TESTING /////////////// @@ -87,6 +90,9 @@ namespace glabels } + /// + /// Close Event Handler + /// void MainWindow::closeEvent( QCloseEvent *event ) { std::cout << "CLOSE EVENT" << std::endl; @@ -95,6 +101,9 @@ namespace glabels } + /// + /// Create Actions + /// void MainWindow::createActions() { /* File actions */ @@ -385,6 +394,9 @@ namespace glabels } + /// + /// Create Menus + /// void MainWindow::createMenus() { fileMenu = menuBar()->addMenu( tr("&File") ); @@ -468,6 +480,9 @@ namespace glabels } + /// + /// Create Tool Bars + /// void MainWindow::createToolBars() { fileToolBar = addToolBar( tr("&File") ); @@ -502,6 +517,9 @@ namespace glabels } + /// + /// Create Status Bar + /// void MainWindow::createStatusBar() { zoomInfoLabel = new QLabel( " 999% " ); @@ -525,9 +543,9 @@ namespace glabels } - /* - * Set enabled state of actions associated with a document. - */ + /// + /// Set enabled state of actions associated with a document. + /// void MainWindow::setDocVerbsEnabled( bool enabled ) { filePropertiesAction->setEnabled( enabled ); @@ -579,27 +597,27 @@ namespace glabels } - /* - * Set enabled state of actions associated with a document being modified since last save. - */ + /// + /// Set enabled state of actions associated with a document being modified since last save. + /// void MainWindow::setDocModifiedVerbsEnabled( bool enabled ) { fileSaveAction->setEnabled( enabled ); } - /* - * Set enabled state of actions associated with data being available on clipboard. - */ + /// + /// Set enabled state of actions associated with data being available on clipboard. + /// void MainWindow::setPasteVerbsEnabled( bool enabled ) { editPasteAction->setEnabled( enabled ); } - /* - * Set enabled state of actions associated with a non-empty selection. - */ + /// + /// Set enabled state of actions associated with a non-empty selection. + /// void MainWindow::setSelectionVerbsEnabled( bool enabled ) { editCutAction->setEnabled( enabled ); @@ -620,9 +638,9 @@ namespace glabels } - /* - * Set enabled state of actions associated with a non-atomic selection. - */ + /// + /// Set enabled state of actions associated with a non-atomic selection. + /// void MainWindow::setMultiSelectionVerbsEnabled( bool enabled ) { objectsAlignMenu->setEnabled( enabled ); @@ -635,6 +653,9 @@ namespace glabels } + /// + /// Read MainWindow Settings + /// void MainWindow::readSettings() { QSettings settings; @@ -664,6 +685,9 @@ namespace glabels } + /// + /// Write MainWindow Settings + /// void MainWindow::writeSettings() { QSettings settings; @@ -679,318 +703,477 @@ namespace glabels } + /// + /// File->New Action + /// void MainWindow::fileNew() { File::newLabel( this ); } + /// + /// File->Open Action + /// void MainWindow::fileOpen() { std::cout << "ACTION: file->Open" << std::endl; } + /// + /// File->Save Action + /// void MainWindow::fileSave() { std::cout << "ACTION: file->Save" << std::endl; } + /// + /// File->Save As Action + /// void MainWindow::fileSaveAs() { std::cout << "ACTION: file->Save As" << std::endl; } + /// + /// File->Print Action + /// void MainWindow::filePrint() { std::cout << "ACTION: file->Print" << std::endl; } + /// + /// File->Properties Action + /// void MainWindow::fileProperties() { std::cout << "ACTION: file->Properties" << std::endl; } + /// + /// File->Template Designer Action + /// void MainWindow::fileTemplateDesigner() { std::cout << "ACTION: file->Template Designer" << std::endl; } + /// + /// File->Close Action + /// void MainWindow::fileClose() { std::cout << "ACTION: file->Close" << std::endl; } + /// + /// File->Exit Action + /// void MainWindow::fileExit() { std::cout << "ACTION: file->Exit" << std::endl; } + /// + /// Edit->Undo Action + /// void MainWindow::editUndo() { std::cout << "ACTION: edit->Undo" << std::endl; } + /// + /// Edit->Redo Action + /// void MainWindow::editRedo() { std::cout << "ACTION: edit->Redo" << std::endl; } + /// + /// Edit->Cut Action + /// void MainWindow::editCut() { std::cout << "ACTION: edit->Cut" << std::endl; } + /// + /// Edit->Copy Action + /// void MainWindow::editCopy() { std::cout << "ACTION: edit->Copy" << std::endl; } + /// + /// Edit->Paste Action + /// void MainWindow::editPaste() { std::cout << "ACTION: edit->Paste" << std::endl; } + /// + /// Edit->Delete Action + /// void MainWindow::editDelete() { std::cout << "ACTION: edit->Delete" << std::endl; } + /// + /// Edit->Select All Action + /// void MainWindow::editSelectAll() { std::cout << "ACTION: edit->Select All" << std::endl; } + /// + /// Edit->Unselect All Action + /// void MainWindow::editUnSelectAll() { std::cout << "ACTION: edit->Un-select All" << std::endl; } + /// + /// Edit->Preferences Action + /// void MainWindow::editPreferences() { std::cout << "ACTION: edit->Preferences" << std::endl; } + /// + /// View->File Tool Bar Toggle Action + /// void MainWindow::viewFileToolBar( bool state ) { fileToolBar->setVisible( state ); } + /// + /// View->Objects Tool Bar Toggle Action + /// void MainWindow::viewObjectsToolBar( bool state ) { objectsToolBar->setVisible( state ); } + /// + /// View->Edit Tool Bar Toggle Action + /// void MainWindow::viewEditToolBar( bool state ) { editToolBar->setVisible( state ); } + /// + /// View->View Tool Bar Toggle Action + /// void MainWindow::viewViewToolBar( bool state ) { viewToolBar->setVisible( state ); } + /// + /// View->Grid Toggle Action + /// void MainWindow::viewGrid( bool state ) { view->setGridVisible( state ); } + /// + /// View->Markup Toggle Action + /// void MainWindow::viewMarkup( bool state ) { view->setMarkupVisible( state ); } + /// + /// View->Zoom In Action + /// void MainWindow::viewZoomIn() { view->zoomIn(); } + /// + /// View->Zoom Out Action + /// void MainWindow::viewZoomOut() { view->zoomOut(); } + /// + /// View->Zoom 1:1 Action + /// void MainWindow::viewZoom1To1() { view->zoom1To1(); } + /// + /// View->Zoom To Fit Action + /// void MainWindow::viewZoomToFit() { view->zoomToFit(); } + /// + /// Objects->Arrow Mode Action + /// void MainWindow::objectsArrowMode() { std::cout << "ACTION: objects->Select Mode" << std::endl; } + /// + /// Objects->Create Text Mode Action + /// void MainWindow::objectsCreateText() { std::cout << "ACTION: objects->Create->Text" << std::endl; } + /// + /// Objects->Create Box Mode Action + /// void MainWindow::objectsCreateBox() { std::cout << "ACTION: objects->Create->Box" << std::endl; } + /// + /// Objects->Create Line Mode Action + /// void MainWindow::objectsCreateLine() { std::cout << "ACTION: objects->Create->Line" << std::endl; } + /// + /// Objects->Create Ellipse Mode Action + /// void MainWindow::objectsCreateEllipse() { std::cout << "ACTION: objects->Create->Ellipse" << std::endl; } + /// + /// Objects->Create Image Mode Action + /// void MainWindow::objectsCreateImage() { std::cout << "ACTION: objects->Create->Image" << std::endl; } + /// + /// Objects->Create Barcode Mode Action + /// void MainWindow::objectsCreateBarcode() { std::cout << "ACTION: objects->Create->Barcode" << std::endl; } + /// + /// Objects->Order->Bring To Front Action + /// void MainWindow::objectsOrderRaise() { std::cout << "ACTION: objects->Order->Bring to front" << std::endl; } + /// + /// Objects->Order->Send To Back Action + /// void MainWindow::objectsOrderLower() { std::cout << "ACTION: objects->Order->Send to back" << std::endl; } + /// + /// Objects->Rotate/Flip->Rotate Left Action + /// void MainWindow::objectsXformRotateLeft() { std::cout << "ACTION: objects->Rotate/Flip->Rotate Left" << std::endl; } + /// + /// Objects->Rotate/Flip->Rotate Right Action + /// void MainWindow::objectsXformRotateRight() { std::cout << "ACTION: objects->Rotate/Flip->Rotate Right" << std::endl; } + /// + /// Objects->Rotate/Flip->Flip Horizontally Action + /// void MainWindow::objectsXformFlipHoriz() { std::cout << "ACTION: objects->Rotate/Flip->Flip Horizontally" << std::endl; } + /// + /// Objects->Rotate/Flip->Flip Vertically Action + /// void MainWindow::objectsXformFlipVert() { std::cout << "ACTION: objects->Rotate/Flip->Flip Vertically" << std::endl; } + /// + /// Objects->Align->Left Action + /// void MainWindow::objectsAlignLeft() { std::cout << "ACTION: objects->Align->Left" << std::endl; } + /// + /// Objects->Align->Center Horizontally Action + /// void MainWindow::objectsAlignHCenter() { std::cout << "ACTION: objects->Align->Center Horizontally" << std::endl; } + /// + /// Objects->Align->Right Action + /// void MainWindow::objectsAlignRight() { std::cout << "ACTION: objects->Align->Right" << std::endl; } + /// + /// Objects->Align->Top Action + /// void MainWindow::objectsAlignTop() { std::cout << "ACTION: objects->Align->Top" << std::endl; } + /// + /// Objects->Align->Center Vertically Action + /// void MainWindow::objectsAlignVCenter() { std::cout << "ACTION: objects->Align->Center Vertically" << std::endl; } + /// + /// Objects->Align->Bottom Action + /// void MainWindow::objectsAlignBottom() { std::cout << "ACTION: objects->Align->Bottom" << std::endl; } + /// + /// Objects->Center->Horizontally Action + /// void MainWindow::objectsCenterHoriz() { std::cout << "ACTION: objects->Center->Horizontally" << std::endl; } + /// + /// Objects->Center->Vertically Action + /// void MainWindow::objectsCenterVert() { std::cout << "ACTION: objects->Center->Vertically" << std::endl; } + /// + /// Objects->Merge Properties Action + /// void MainWindow::objectsMergeProperties() { std::cout << "ACTION: objects->Merge Properties..." << std::endl; } + /// + /// Help->Contents Action + /// void MainWindow::helpContents() { Help::displayContents( this ); } + /// + /// Help->About Action + /// void MainWindow::helpAbout() { Help::displayAbout( this ); } + /// + /// Update Zoom Information in Status Bar + /// void MainWindow::updateZoomInfo() { zoomInfoLabel->setText( QString( " %1% " ).arg(100*view->zoom(), 0, 'f', 0) ); @@ -1000,6 +1183,9 @@ namespace glabels } + /// + /// Update Cursor Information in Status Bar + /// void MainWindow::updateCursorInfo( double x, double y ) { /* TODO: convert x,y to locale units and set precision accordingly. */ @@ -1007,7 +1193,10 @@ namespace glabels } - /* Clears cursor info. E.g. when pointer exits view. */ + /// + /// Update Zoom Information in Status Bar (Clears information) + /// E.g. when pointer exits view. + /// void MainWindow::updateCursorInfo() { cursorInfoLabel->setText( "" ); diff --git a/app/MainWindow.h b/app/MainWindow.h index 9198981..36b77a7 100644 --- a/app/MainWindow.h +++ b/app/MainWindow.h @@ -37,11 +37,9 @@ namespace glabels class View; - ////////////////////////////////////////////// - ////////////////////////////////////////////// - // MainWindow - ////////////////////////////////////////////// - ////////////////////////////////////////////// + /// + /// MainWindow Widget + /// class MainWindow : public QMainWindow { Q_OBJECT diff --git a/app/MergeField.h b/app/MergeField.h index 2123df4..659ec84 100644 --- a/app/MergeField.h +++ b/app/MergeField.h @@ -27,21 +27,66 @@ namespace glabels { + /// + /// Merge Field Structure + /// struct MergeField { + + ///////////////////////////////// + // Properties + ///////////////////////////////// public: - inline QString key( void ) { return m_key; } - inline void key( const QString &value ) { m_key = value; } - - inline QString value( void ) { return m_value; } - inline void value( const QString &value ) { m_value = value; } + // + // Key Property + // + inline const QString key( void ) const; + inline void setKey( const QString &value ); + // + // Value Property + // + inline const QString value( void ) const; + inline void setValue( const QString &value ); + + + ///////////////////////////////// + // Private data + ///////////////////////////////// private: - QString m_key; - QString m_value; + QString mKey; + QString mValue; + }; + + ///////////////////////////////// + // INLINE METHODS + ///////////////////////////////// + const QString MergeField::key( void ) const + { + return mKey; + } + + + void MergeField::setKey( const QString &value ) + { + mKey = value; + } + + + const QString MergeField::value( void ) const + { + return mValue; + } + + + void MergeField::setValue( const QString &value ) + { + mValue = value; + } + } #endif // glabels_MergeField_h diff --git a/app/MergeRecord.cpp b/app/MergeRecord.cpp index 4461213..5800a21 100644 --- a/app/MergeRecord.cpp +++ b/app/MergeRecord.cpp @@ -20,3 +20,17 @@ #include "MergeRecord.h" + +namespace glabels +{ + + /// + /// Constructor + /// + MergeRecord::MergeRecord() : mSelected( false ) + { + } + +} + + diff --git a/app/MergeRecord.h b/app/MergeRecord.h index 04850d1..e135f93 100644 --- a/app/MergeRecord.h +++ b/app/MergeRecord.h @@ -22,37 +22,72 @@ #define glabels_MergeRecord_h #include -#include +#include #include "MergeField.h" -using namespace std; - namespace glabels { + /// + /// Merge Record Structure + /// struct MergeRecord { + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// public: - MergeRecord() : m_selected( false ) - { - } + MergeRecord(); + ///////////////////////////////// + // Properties + ///////////////////////////////// public: - inline bool selected( void ) { return m_selected; } - inline void selected( bool value ) { m_selected = value; } + inline bool selected( void ) const; + inline void setSelected( bool value ); - inline list field_list( void ) { return m_field_list; } - inline void field_list( list &value ) { m_field_list = value; } + inline const QList& fieldList( void ) const; + inline void setFieldList( QList& value ); + ///////////////////////////////// + // Private data + ///////////////////////////////// private: - bool m_selected; - list m_field_list; + bool mSelected; + QList mFieldList; }; + + ///////////////////////////////// + // INLINE METHODS + ///////////////////////////////// + bool MergeRecord::selected( void ) const + { + return mSelected; + } + + + void MergeRecord::setSelected( bool value ) + { + mSelected = value; + } + + + const QList& MergeRecord::fieldList( void ) const + { + return mFieldList; + } + + + void MergeRecord::setFieldList( QList& value ) + { + mFieldList = value; + } + } #endif // glabels_MergeRecord_h diff --git a/app/NewLabelDialog.cpp b/app/NewLabelDialog.cpp index 1b7d38b..23c38b0 100644 --- a/app/NewLabelDialog.cpp +++ b/app/NewLabelDialog.cpp @@ -29,6 +29,9 @@ namespace glabels { + /// + /// Constructor + /// NewLabelDialog::NewLabelDialog( QWidget *parent = 0 ) { setupUi( this ); @@ -66,6 +69,9 @@ namespace glabels } + /// + /// Search Entry Text Changed Slot + /// void NewLabelDialog::searchEntryTextChanged( const QString &text ) { templatePicker->applyFilter( text, @@ -75,6 +81,9 @@ namespace glabels } + /// + /// Page Size Radio Toggled Slot + /// void NewLabelDialog::pageSizeRadioToggled( bool checked ) { if ( checked ) @@ -87,6 +96,9 @@ namespace glabels } + /// + /// Template Picker Selection Changed Slot + /// void NewLabelDialog::templatePickerSelectionChanged() { orientationNormalRadio->setChecked( true ); @@ -164,6 +176,9 @@ namespace glabels } + /// + /// Orientation Radio Button Toggled Slot + /// void NewLabelDialog::orientationRadioToggled( bool checked ) { if ( checked ) @@ -173,6 +188,9 @@ namespace glabels } + /// + /// Create Button Clicked Slot + /// void NewLabelDialog::createButtonClicked() { const libglabels::Template *tmplate = templatePicker->selectedTemplate(); diff --git a/app/NewLabelDialog.h b/app/NewLabelDialog.h index dd4b254..69eee0c 100644 --- a/app/NewLabelDialog.h +++ b/app/NewLabelDialog.h @@ -27,13 +27,24 @@ namespace glabels { + /// + /// New Label Dialog Widget + /// class NewLabelDialog : public QDialog, public Ui_NewLabelDialog { Q_OBJECT + + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// public: NewLabelDialog( QWidget *parent ); + + ///////////////////////////////// + // Slots + ///////////////////////////////// private slots: void searchEntryTextChanged( const QString &text ); void pageSizeRadioToggled( bool checked ); diff --git a/app/SimplePreview.cpp b/app/SimplePreview.cpp index c1c94d7..447667a 100644 --- a/app/SimplePreview.cpp +++ b/app/SimplePreview.cpp @@ -25,6 +25,9 @@ #include +// +// Private Configuration Data +// namespace { const QColor paperColor( 255, 255, 255 ); @@ -51,6 +54,9 @@ namespace namespace glabels { + /// + /// Constructor + /// SimplePreview::SimplePreview( QWidget *parent = 0 ) : mScale(1), mTmplate(NULL), mRotateFlag(false), QGraphicsView(parent) { @@ -65,6 +71,9 @@ namespace glabels } + /// + /// Template Property Setter + /// void SimplePreview::setTemplate( const libglabels::Template *tmplate ) { mTmplate = tmplate; @@ -72,6 +81,9 @@ namespace glabels } + /// + /// Rotate Property Setter + /// void SimplePreview::setRotate( bool rotateFlag ) { mRotateFlag = rotateFlag; @@ -79,6 +91,9 @@ namespace glabels } + /// + /// Update View + /// void SimplePreview::update() { clearScene(); @@ -103,6 +118,9 @@ namespace glabels } + /// + /// Clear View + /// void SimplePreview::clearScene() { foreach ( QGraphicsItem *item, mScene->items() ) @@ -113,6 +131,9 @@ namespace glabels } + /// + /// Draw Paper + /// void SimplePreview::drawPaper( double pw, double ph ) { QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(); @@ -133,6 +154,9 @@ namespace glabels } + /// + /// Draw Labels on Paper + /// void SimplePreview::drawLabels() { libglabels::Frame *frame = mTmplate->frames().first(); @@ -144,6 +168,9 @@ namespace glabels } + /// + /// Draw a Single Label at x,y + /// void SimplePreview::drawLabel( double x, double y, const QPainterPath &path ) { QBrush brush( labelColor ); @@ -159,6 +186,9 @@ namespace glabels } + /// + /// Draw Arrow Indicating Top of First Label + /// void SimplePreview::drawArrow() { libglabels::Frame *frame = mTmplate->frames().first(); diff --git a/app/SimplePreview.h b/app/SimplePreview.h index 6b13b71..c23b026 100644 --- a/app/SimplePreview.h +++ b/app/SimplePreview.h @@ -32,16 +32,32 @@ namespace glabels { + /// + /// Simple Preview Widget + /// class SimplePreview : public QGraphicsView { Q_OBJECT + + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// public: SimplePreview( QWidget *parent ); + + ///////////////////////////////// + // Properties + ///////////////////////////////// + public: void setTemplate( const libglabels::Template *tmplate ); void setRotate( bool rotateFlag ); + + ///////////////////////////////// + // Internal Methods + ///////////////////////////////// private: void update(); void clearScene(); @@ -50,11 +66,17 @@ namespace glabels void drawLabel( double x, double y, const QPainterPath &path ); void drawArrow(); - QGraphicsScene *mScene; - double mScale; + + ///////////////////////////////// + // Private Data + ///////////////////////////////// + private: const libglabels::Template *mTmplate; bool mRotateFlag; + QGraphicsScene *mScene; + double mScale; + }; } diff --git a/app/TemplatePicker.cpp b/app/TemplatePicker.cpp index 4f345e2..1734e7d 100644 --- a/app/TemplatePicker.cpp +++ b/app/TemplatePicker.cpp @@ -28,6 +28,9 @@ namespace glabels { + /// + /// Constructor + /// TemplatePicker::TemplatePicker( QWidget *parent ) : QListWidget(parent) { setViewMode( QListView::IconMode ); @@ -39,6 +42,9 @@ namespace glabels } + /// + /// Set List of Templates to Pick From + /// void TemplatePicker::setTemplates( const QList &tmplates ) { foreach (libglabels::Template *tmplate, tmplates) @@ -48,6 +54,9 @@ namespace glabels } + /// + /// Apply Filter to Narrow Template Choices + /// void TemplatePicker::applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask ) { @@ -72,6 +81,9 @@ namespace glabels } + /// + /// Get Currently Selected Template + /// const libglabels::Template *TemplatePicker::selectedTemplate() { QList items = selectedItems(); diff --git a/app/TemplatePicker.h b/app/TemplatePicker.h index b6344f0..bbd96f0 100644 --- a/app/TemplatePicker.h +++ b/app/TemplatePicker.h @@ -31,15 +31,31 @@ namespace glabels { + /// + /// Template Picker Widget + /// class TemplatePicker : public QListWidget { Q_OBJECT + + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// public: TemplatePicker( QWidget *parent = 0 ); + + ///////////////////////////////// + // Properties + ///////////////////////////////// + public: void setTemplates( const QList &tmplates ); + + ///////////////////////////////// + // Methods + ///////////////////////////////// void applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask ); const libglabels::Template *selectedTemplate(); diff --git a/app/TemplatePickerItem.cpp b/app/TemplatePickerItem.cpp index 078ae73..1097330 100644 --- a/app/TemplatePickerItem.cpp +++ b/app/TemplatePickerItem.cpp @@ -28,8 +28,11 @@ namespace glabels { + /// + /// Constructor + /// TemplatePickerItem::TemplatePickerItem( libglabels::Template *tmplate, - QListWidget *parent = 0 ) + QListWidget *parent ) : QListWidgetItem(parent) { mTmplate = tmplate; @@ -40,5 +43,14 @@ namespace glabels setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); } + + /// + /// Template Property Getter + /// + const libglabels::Template *TemplatePickerItem::tmplate() const + { + return mTmplate; + } + } diff --git a/app/TemplatePickerItem.h b/app/TemplatePickerItem.h index 73df4c4..4153876 100644 --- a/app/TemplatePickerItem.h +++ b/app/TemplatePickerItem.h @@ -31,14 +31,29 @@ namespace glabels { + /// + /// Template Picker Item Widget + /// class TemplatePickerItem : public QListWidgetItem { + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// public: - TemplatePickerItem( libglabels::Template *tmplate, QListWidget *parent ); + TemplatePickerItem( libglabels::Template *tmplate, QListWidget *parent = 0 ); - inline const libglabels::Template *tmplate() const { return mTmplate; } + ///////////////////////////////// + // Properties + ///////////////////////////////// + public: + const libglabels::Template *tmplate() const; + + + ///////////////////////////////// + // Private Data + ///////////////////////////////// private: libglabels::Template *mTmplate; diff --git a/app/TextNode.cpp b/app/TextNode.cpp index f2f6748..d1476cd 100644 --- a/app/TextNode.cpp +++ b/app/TextNode.cpp @@ -36,6 +36,27 @@ namespace { namespace glabels { + /// + /// Default Constructor + /// + TextNode::TextNode() + : mFieldFlag(false), mData("") + { + } + + + /// + /// Constructor from Data + /// + TextNode::TextNode( bool field_flag, const QString &data ) + : mFieldFlag(field_flag), mData(data) + { + } + + + /// + /// Constructor from Parsing Next Token in Text + /// TextNode::TextNode( const QString &text, int i_start, int &i_next ) { State state = START; @@ -175,13 +196,51 @@ namespace glabels } - m_field_flag = field_flag; - m_data = field_flag ? field_name : literal_text; + mFieldFlag = field_flag; + mData = field_flag ? field_name : literal_text; i_next = i; } + /// + /// == Operator + /// + bool TextNode::operator==( const TextNode& other ) + { + return ( (mFieldFlag == other.mFieldFlag) && + (mData == other.mData) ); + } + + + /// + /// != Operator + /// + bool TextNode::operator!=( const TextNode& other ) + { + return ( (mFieldFlag != other.mFieldFlag) || + (mData != other.mData) ); + } + + + /// + /// Field Flag Property Getter + /// + bool TextNode::fieldFlag( void ) const + { + return mFieldFlag; + } + + + /// + /// Data Property Getter + /// + const QString& TextNode::data( void ) const + { + return mData; + } + + #if TODO public string expand( MergeRecord? record ) { diff --git a/app/TextNode.h b/app/TextNode.h index c9d1267..497da4d 100644 --- a/app/TextNode.h +++ b/app/TextNode.h @@ -27,53 +27,64 @@ namespace glabels { - class TextNode + /// + /// Text Node Type + /// + struct TextNode { + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// public: - TextNode() - : m_field_flag(false), m_data("") - { - } - - - TextNode( bool field_flag, const QString &data ) - : m_field_flag(field_flag), m_data(data) - { - } - - virtual ~TextNode() {} + TextNode(); + TextNode( bool field_flag, const QString &data ); TextNode( const QString &text, int i_start, int &i_next ); - bool operator==( const TextNode &tn ) - { - return ( (m_field_flag == tn.m_field_flag) && - (m_data == tn.m_data) ); - } + ///////////////////////////////// + // Operators + ///////////////////////////////// + public: + bool operator==( const TextNode& other ); + + bool operator!=( const TextNode& other ); - bool operator!=( const TextNode &tn ) - { - return ( (m_field_flag != tn.m_field_flag) || - (m_data != tn.m_data) ); - } + ///////////////////////////////// + // Properties + ///////////////////////////////// + public: + // + // Field Flag Property + // + bool fieldFlag( void ) const; + + // + // Data Property + // + const QString& data( void ) const; + + ///////////////////////////////// + // Methods + ///////////////////////////////// #if TODO string expand( MergeRecord? record ); bool is_empty_field( MergeRecord? record ); #endif - bool field_flag( void ) { return m_field_flag; } - QString data( void ) { return m_data; } + ///////////////////////////////// + // Private Data + ///////////////////////////////// private: - bool m_field_flag; - QString m_data; + bool mFieldFlag; + QString mData; }; diff --git a/app/View.cpp b/app/View.cpp index e8d66e9..62d7a87 100644 --- a/app/View.cpp +++ b/app/View.cpp @@ -38,6 +38,9 @@ #include "libglabels/FrameCd.h" +// +// Private Configuration Data +// namespace { const int nZoomLevels = 14; @@ -65,6 +68,9 @@ namespace namespace glabels { + /// + /// Constructor + /// View::View( QWidget *parent ) : QGraphicsView(parent) { setZoomReal( 1, false ); @@ -86,6 +92,9 @@ namespace glabels } + /// + /// Model Parameter Setter + /// void View::setModel( LabelModel* model ) { mModel = model; @@ -103,18 +112,27 @@ namespace glabels } + /// + /// Grid Visibility Parameter Setter + /// void View::setGridVisible( bool visibleFlag ) { mGridLayer->setVisible( visibleFlag ); } + /// + /// Markup Visibility Parameter Setter + /// void View::setMarkupVisible( bool visibleFlag ) { mMarkupLayer->setVisible( visibleFlag ); } + /// + /// Zoom In "One Notch" + /// void View::zoomIn() { // Find closest standard zoom level to our current zoom @@ -137,6 +155,9 @@ namespace glabels } + /// + /// Zoom Out "One Notch" + /// void View::zoomOut() { // Find closest standard zoom level to our current zoom @@ -159,12 +180,18 @@ namespace glabels } + /// + /// Zoom To 1:1 Scale + /// void View::zoom1To1() { setZoomReal( 1.0, false ); } + /// + /// Zoom To Fit + /// void View::zoomToFit() { double x_scale = (72.0/physicalDpiX()) * ( width() - ZOOM_TO_FIT_PAD ) / mModel->w(); @@ -179,18 +206,27 @@ namespace glabels } + /// + /// Is Zoom at Maximum? + /// bool View::isZoomMax() const { return ( mZoom >= zoomLevels[0] ); } + /// + /// Is Zoom at Minimum? + /// bool View::isZoomMin() const { return ( mZoom <= zoomLevels[nZoomLevels-1] ); } + /// + /// Set Zoom to Value + /// void View::setZoomReal( double zoom, bool zoomToFitFlag ) { mZoom = zoom; @@ -203,6 +239,9 @@ namespace glabels } + /// + /// Resize Event Handler + /// void View::resizeEvent( QResizeEvent *event ) { if ( mZoomToFitFlag ) @@ -218,6 +257,9 @@ namespace glabels } + /// + /// Mouse Movement Event Handler + /// void View::mouseMoveEvent( QMouseEvent* event ) { QPointF pointer = mapToScene( event->x(), event->y() ); @@ -225,12 +267,18 @@ namespace glabels } + /// + /// Leave Event Handler + /// void View::leaveEvent( QEvent* event ) { emit pointerExited(); } + /// + /// Clear Layer (Item Group) of All Child Items + /// void View::clearLayer( QGraphicsItemGroup* layer ) { foreach( QGraphicsItem* item, layer->childItems() ) @@ -240,6 +288,9 @@ namespace glabels } + /// + /// Create Label Layer + /// void View::createLabelLayer() { clearLayer( mLabelLayer ); @@ -259,6 +310,9 @@ namespace glabels } + /// + /// Create Grid Layer + /// void View::createGridLayer() { clearLayer( mGridLayer ); @@ -302,6 +356,9 @@ namespace glabels } + /// + /// Create Markup Layer + /// void View::createMarkupLayer() { clearLayer( mMarkupLayer ); @@ -321,6 +378,9 @@ namespace glabels } + /// + /// Add Object to Object Layer + /// void View::addObjectToObjectLayer( LabelModelObject* object ) { QGraphicsItem* item = object->createGraphicsItem(); @@ -328,6 +388,9 @@ namespace glabels } + /// + /// Create Foreground Layer + /// void View::createForegroundLayer() { clearLayer( mForegroundLayer ); diff --git a/app/View.h b/app/View.h index 91f5a31..368bc86 100644 --- a/app/View.h +++ b/app/View.h @@ -34,11 +34,9 @@ namespace glabels class LabelModelObject; - ////////////////////////////////////////////// - ////////////////////////////////////////////// - // View - ////////////////////////////////////////////// - ////////////////////////////////////////////// + /// + /// View Widget + /// class View : public QGraphicsView { Q_OBJECT