Reconcile style accross all source files.

- All glabels code is in "glabels" top-level namespace.
- Other assorted cleanup.
This commit is contained in:
Jim Evins
2017-01-15 22:58:53 -05:00
parent 44aa31d074
commit b797d13e40
153 changed files with 17673 additions and 16841 deletions
+38 -1
View File
@@ -57,7 +57,38 @@ information.
- Never use parens in return statements when not necessary.
File Organization
Naming
------
### Type Names
- Start with a capital letter.
- Each new word is capitalized.
- No underscores.
### Variable Names
- Start each variable name with a lowercase letter.
- Each subsequent word is capitalized.
- No underscores.
- Data members start with a lowercase "m" with the 2nd letter capitalized.
- Use "i" prefix for indexes and "n" prefix for total number of indexes.
### Function names
- Start each function name with a lowercase letter.
- Each subsequent word is capitalized.
- No underscores.
### Constant Names
- TBD (currently not uniform)
Code Organization
-----------------
Generally code is organized into modules. Usually a module defines a single
@@ -87,6 +118,7 @@ All header files should have an ifndef guard to prevent multiple inclusion.
#endif // ns_Module_h
```
### Include Directives
Header files should be included in the following order.
@@ -111,3 +143,8 @@ glabels header files.
Do not use forward declarations to any external entities. Use the appropriate
include directives instead.
### Namespaces
- Private definitions are placed in unnamed namespaces to limit scope to the current translation unit.
- All other glabels code is placed in the top-level "glabels" namespace.
+5
View File
@@ -28,6 +28,9 @@
#include "Version.h"
namespace glabels
{
///
/// Constructor
///
@@ -81,3 +84,5 @@ void AboutDialog::onWebsiteButtonClicked()
{
QDesktopServices::openUrl( QUrl(Version::WEBSITE) );
}
}
+5
View File
@@ -25,6 +25,9 @@
#include "ui_AboutDialog.h"
namespace glabels
{
///
/// About Dialog Widget
///
@@ -49,5 +52,7 @@ private slots:
};
}
#endif // AboutDialog_h
+8 -4
View File
@@ -21,11 +21,12 @@
#include "BarcodeBackends.h"
namespace
namespace glabels
{
const std::string default_id = "code39";
}
//
// Static data
//
BarcodeBackends::BackendMap BarcodeBackends::mBackendIdMap;
BarcodeBackends::BackendMap BarcodeBackends::mBackendNameMap;
@@ -169,7 +170,8 @@ void BarcodeBackends::registerStyle( const char* id,
BarcodeStyle* style = new BarcodeStyle( QString(id), QString(backendId), name,
canText, textOptional,
canChecksum, checksumOptional,
QString(defaultDigits), canFreeForm, preferedN );
QString(defaultDigits),
canFreeForm, preferedN );
QString fqName = QString(backendId) + QString(".") + name; // Name may not be unique
@@ -177,3 +179,5 @@ void BarcodeBackends::registerStyle( const char* id,
mStyleIdMap.insert( id, style );
mStyleNameMap.insert( fqName, style );
}
}
+5
View File
@@ -30,6 +30,9 @@
#include "BarcodeStyle.h"
namespace glabels
{
///
/// Barcode Backends Database
///
@@ -93,5 +96,7 @@ private:
};
}
#endif // BarcodeBackends_h
+5
View File
@@ -25,6 +25,9 @@
#include "BarcodeMenuItem.h"
namespace glabels
{
///
/// Constructor
///
@@ -60,3 +63,5 @@ void BarcodeMenu::onMenuItemActivated( BarcodeStyle *bcStyle )
emit styleChanged();
}
}
+5
View File
@@ -27,6 +27,9 @@
#include "BarcodeStyle.h"
namespace glabels
{
///
/// Barcode Menu
///
@@ -70,5 +73,7 @@ private:
};
}
#endif // BarcodeMenu_h
+5
View File
@@ -25,6 +25,9 @@
#include "BarcodeMenuItem.h"
namespace glabels
{
///
/// Constructor
///
@@ -60,3 +63,5 @@ void BarcodeMenuButton::onMenuStyleChanged()
emit styleChanged();
}
}
+5
View File
@@ -28,6 +28,9 @@
#include "BarcodeStyle.h"
namespace glabels
{
///
/// Barcode Menu Button
///
@@ -72,5 +75,7 @@ private:
};
}
#endif // BarcodeMenuButton_h
+5
View File
@@ -21,6 +21,9 @@
#include "BarcodeMenuItem.h"
namespace glabels
{
///
/// Constructor From Data
///
@@ -49,3 +52,5 @@ void BarcodeMenuItem::onTriggered()
{
emit activated( mBcStyle );
}
}
+5
View File
@@ -27,6 +27,9 @@
#include "BarcodeStyle.h"
namespace glabels
{
///
/// Barcode Menu Item
///
@@ -70,5 +73,7 @@ private:
};
}
#endif // BarcodeMenuItem_h
+7
View File
@@ -21,6 +21,9 @@
#include "BarcodeStyle.h"
namespace glabels
{
///
/// Default Constructor
///
@@ -36,6 +39,7 @@ BarcodeStyle::BarcodeStyle ()
mCanFreeform( false ),
mPreferedN( 0 )
{
// empty
}
@@ -63,6 +67,7 @@ BarcodeStyle::BarcodeStyle ( const QString& id,
mCanFreeform( canFreeform ),
mPreferedN( preferedN )
{
// empty
}
@@ -170,3 +175,5 @@ QString BarcodeStyle::exampleDigits( int n ) const
return mDefaultDigits;
}
}
}
+5
View File
@@ -24,6 +24,9 @@
#include <QString>
namespace glabels
{
///
/// Barcode Style Type
///
@@ -96,5 +99,7 @@ private:
};
}
#endif // BarcodeStyle_h
+1
View File
@@ -27,6 +27,7 @@ namespace glabels
Category::Category( const QString &id, const QString &name )
: mId(id), mName(name)
{
// empty
}
+12 -1
View File
@@ -28,6 +28,12 @@
#include "ColorSwatch.h"
namespace glabels
{
//
// Private
//
namespace
{
const int SWATCH_W = 64;
@@ -38,10 +44,13 @@ namespace
ColorButton::ColorButton( QWidget* parent )
: QPushButton( parent )
{
// empty
}
void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color )
void ColorButton::init( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color )
{
mDefaultColor = defaultColor;
mColorNode = ColorNode( color );
@@ -173,3 +182,5 @@ void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
emit colorChanged();
}
}
+5
View File
@@ -28,6 +28,9 @@
#include "ColorPaletteDialog.h"
namespace glabels
{
///
/// Color Button
///
@@ -90,5 +93,7 @@ private:
ColorPaletteDialog* mDialog;
};
}
#endif // ColorButton_h
+6
View File
@@ -25,8 +25,12 @@
#include <QtDebug>
namespace glabels
{
ColorHistory::ColorHistory()
{
// empty
}
@@ -111,3 +115,5 @@ void ColorHistory::writeColorList( const QList<QColor>& colorList )
settings.setValue( "colors", colorNameList );
settings.endGroup();
}
}
+5
View File
@@ -26,6 +26,9 @@
#include <QObject>
namespace glabels
{
///
/// Color History
///
@@ -76,5 +79,7 @@ private:
};
}
#endif // ColorHistory_h
+9
View File
@@ -24,12 +24,16 @@
#include "Merge/Record.h"
namespace glabels
{
///
/// Default Constructor
///
ColorNode::ColorNode()
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
{
// empty
}
@@ -39,6 +43,7 @@ ColorNode::ColorNode()
ColorNode::ColorNode( bool isField, const QColor& color, const QString& key )
: mIsField(isField), mColor(color), mKey(key)
{
// empty
}
@@ -61,6 +66,7 @@ ColorNode::ColorNode( bool isField, uint32_t rgba, const QString& key )
ColorNode::ColorNode( const QColor& color )
: mIsField(false), mColor(color), mKey("")
{
// empty
}
@@ -70,6 +76,7 @@ ColorNode::ColorNode( const QColor& color )
ColorNode::ColorNode( const QString& key )
: mIsField(true), mColor(QColor::fromRgba(0x00000000)), mKey(key)
{
// empty
}
@@ -192,3 +199,5 @@ QColor ColorNode::color( merge::Record* record ) const
return mColor;
}
}
}
+5
View File
@@ -30,6 +30,9 @@
#include "Merge/Record.h"
namespace glabels
{
///
/// Color Node Type
///
@@ -103,5 +106,7 @@ private:
};
}
#endif // ColorNode_h
+6 -1
View File
@@ -25,8 +25,11 @@
#include <QPainter>
namespace glabels
{
//
// Private Configuration Data
// Private
//
namespace
{
@@ -118,3 +121,5 @@ void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
{
emit activated();
}
}
+5
View File
@@ -26,6 +26,9 @@
#include <QWidget>
namespace glabels
{
///
/// Color Palette Item
///
@@ -66,5 +69,7 @@ private:
bool mHover;
};
}
#endif // ColorPaletteButtonItem_h
+9
View File
@@ -30,6 +30,12 @@
#include <QtDebug>
namespace glabels
{
//
// Static data
//
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
{ "#ef2929", tr("Light Scarlet Red", "Color name") },
@@ -71,6 +77,7 @@ ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
{ "#eeeeec", tr("Lighter Gray", "Color name") },
{ "#f3f3f3", tr("Very Light Gray", "Color name") },
{ "#ffffff", tr("White", "Color name") }
};
@@ -316,3 +323,5 @@ void ColorPaletteDialog::showEvent( QShowEvent* event )
QDialog::showEvent( event );
}
}
+5
View File
@@ -31,6 +31,9 @@
#include "ColorPaletteButtonItem.h"
namespace glabels
{
///
/// Color Palette Dialog
///
@@ -112,5 +115,7 @@ private:
};
}
#endif // ColorPaletteDialog_h
+6 -1
View File
@@ -25,8 +25,11 @@
#include <QPainter>
namespace glabels
{
//
// Private Configuration Data
// Private
//
namespace
{
@@ -142,3 +145,5 @@ void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
{
emit activated( mId );
}
}
+5
View File
@@ -26,6 +26,9 @@
#include <QWidget>
namespace glabels
{
///
/// Color Palette Item
///
@@ -80,5 +83,7 @@ private:
bool mHover;
};
}
#endif // ColorPaletteItem_h
+6 -1
View File
@@ -24,8 +24,11 @@
#include <QPainter>
namespace glabels
{
//
// Private Configuration Data
// Private
//
namespace
{
@@ -54,3 +57,5 @@ ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
painter.setPen( pen );
painter.drawRect( 1, 1, w-2, h-2 );
}
}
+5
View File
@@ -25,6 +25,9 @@
#include <QPixmap>
namespace glabels
{
///
/// Simple Preview Widget
///
@@ -39,5 +42,7 @@ public:
};
}
#endif // ColorSwatch_h
+1
View File
@@ -31,6 +31,7 @@ namespace glabels
const double PTS_PER_CM = (10.0*PTS_PER_MM);
const double PTS_PER_PICA = 12.0;
const Distance EPSILON( 0.5, Units::PT );
}
#endif // glabels_Constants_h
+11
View File
@@ -23,37 +23,48 @@
#include <QPixmap>
namespace glabels
{
Cursors::Barcode::Barcode()
: QCursor( QPixmap(":cursors/32x32/cursor_barcode.png"), 7, 7 )
{
// empty
}
Cursors::Box::Box()
: QCursor( QPixmap(":cursors/32x32/cursor_box.png"), 7, 7 )
{
// empty
}
Cursors::Ellipse::Ellipse()
: QCursor( QPixmap(":cursors/32x32/cursor_ellipse.png"), 7, 7 )
{
// empty
}
Cursors::Image::Image()
: QCursor( QPixmap(":cursors/32x32/cursor_image.png"), 7, 7 )
{
// empty
}
Cursors::Line::Line()
: QCursor( QPixmap(":cursors/32x32/cursor_line.png"), 7, 7 )
{
// empty
}
Cursors::Text::Text()
: QCursor( QPixmap(":cursors/32x32/cursor_text.png"), 7, 7 )
{
// empty
}
}
+5
View File
@@ -25,6 +25,9 @@
#include <QCursor>
namespace glabels
{
///
/// Glabels Cursors
///
@@ -75,5 +78,7 @@ namespace Cursors
}
}
#endif // Cursors_h
+23 -16
View File
@@ -32,18 +32,26 @@
#include "XmlVendorParser.h"
namespace
{
bool partNameLessThan( const glabels::Template *a, const glabels::Template *b )
{
return glabels::StrUtil::comparePartNames( a->name(), b->name() ) < 0;
}
}
namespace glabels
{
//
// Private
//
namespace
{
const QString empty = "";
bool partNameLessThan( const Template *a, const Template *b )
{
return StrUtil::comparePartNames( a->name(), b->name() ) < 0;
}
}
//
// Static data
//
QList<Paper*> Db::mPapers;
QStringList Db::mPaperIds;
QStringList Db::mPaperNames;
@@ -53,9 +61,8 @@ namespace glabels
QList<Vendor*> Db::mVendors;
QStringList Db::mVendorNames;
QList<Template*> Db::mTemplates;
QString Db::mPaperNameOther;
QString Db::mEmpty = "";
Db::Db()
{
@@ -204,7 +211,7 @@ namespace glabels
}
qWarning() << "Unknown paper name: " << name;
return mEmpty;
return empty;
}
@@ -225,7 +232,7 @@ namespace glabels
}
qWarning() << "Unknown paper id: " << id;
return mEmpty;
return empty;
}
@@ -318,7 +325,7 @@ namespace glabels
}
qWarning() << "Unknown category name: " << name;
return mEmpty;
return empty;
}
@@ -334,7 +341,7 @@ namespace glabels
}
qWarning() << "Unknown category id: " << id;
return mEmpty;
return empty;
}
@@ -399,7 +406,7 @@ namespace glabels
}
qWarning() << "Unknown vendor name: " << name;
return mEmpty;
return empty;
}
+1 -1
View File
@@ -132,7 +132,7 @@ namespace glabels
static QList<Template*> mTemplates;
static QString mPaperNameOther;
static QString mEmpty;
};
}
+5
View File
@@ -21,6 +21,9 @@
#include "EnumUtil.h"
namespace glabels
{
namespace EnumUtil
{
@@ -119,3 +122,5 @@ namespace EnumUtil
}
}
}
+5
View File
@@ -27,6 +27,9 @@
#include <Qt>
namespace glabels
{
namespace EnumUtil
{
@@ -41,5 +44,7 @@ namespace EnumUtil
}
}
#endif // EnumUtil_h
+5
View File
@@ -25,6 +25,9 @@
#include <QStandardItemModel>
namespace glabels
{
///
/// Constructor
///
@@ -102,3 +105,5 @@ void FieldButton::onIndexChanged( int index )
setCurrentIndex( 0 );
}
}
}
+5
View File
@@ -26,6 +26,9 @@
#include <QString>
namespace glabels
{
///
/// Field Button
///
@@ -71,5 +74,7 @@ private:
};
}
#endif // FieldButton_h
+10 -5
View File
@@ -33,9 +33,12 @@
#include "XmlLabelCreator.h"
///
/// Static data
///
namespace glabels
{
//
// Static data
//
QString File::mCwd = ".";
@@ -47,7 +50,7 @@ bool File::newLabel( MainWindow *window )
SelectProductDialog dialog( window );
dialog.exec();
const glabels::Template* tmplate = dialog.tmplate();
const Template* tmplate = dialog.tmplate();
if ( tmplate )
{
LabelModel* label = new LabelModel();
@@ -55,7 +58,7 @@ bool File::newLabel( MainWindow *window )
label->clearModified();
// Intelligently decide to rotate label by default
const glabels::Frame* frame = tmplate->frames().first();
const Frame* frame = tmplate->frames().first();
label->setRotate( frame->h() > frame->w() );
// Either apply to current window or open a new one
@@ -240,3 +243,5 @@ void File::exit()
}
}
}
}
+6
View File
@@ -24,6 +24,10 @@
#include <QObject>
namespace glabels
{
// Forward References
class MainWindow;
@@ -50,5 +54,7 @@ private:
};
}
#endif // File_h
+5
View File
@@ -21,6 +21,9 @@
#include "FileUtil.h"
namespace glabels
{
namespace FileUtil
{
@@ -35,3 +38,5 @@ namespace FileUtil
}
}
}
+5
View File
@@ -25,6 +25,9 @@
#include <QString>
namespace glabels
{
namespace FileUtil
{
@@ -32,5 +35,7 @@ namespace FileUtil
}
}
#endif // FileUtil_h
+1
View File
@@ -30,6 +30,7 @@ namespace glabels
Frame::Frame( const QString& id )
: mId(id), mNLabels(0), mLayoutDescription("")
{
// empty
}
+6 -5
View File
@@ -23,7 +23,7 @@
#include <QtDebug>
#include "privateConstants.h"
#include "Constants.h"
#include "StrUtil.h"
@@ -96,6 +96,7 @@ namespace glabels
: mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
mPath(other.mPath), Frame(other)
{
// empty
}
@@ -160,10 +161,10 @@ namespace glabels
{
if ( FrameCd *otherCd = dynamic_cast<FrameCd*>(other) )
{
if ( (fabs( mW - otherCd->mW ) <= Constants::EPSILON) &&
(fabs( mH - otherCd->mH ) <= Constants::EPSILON) &&
(fabs( mR1 - otherCd->mR1 ) <= Constants::EPSILON) &&
(fabs( mR2 - otherCd->mR2 ) <= Constants::EPSILON) )
if ( (fabs( mW - otherCd->mW ) <= EPSILON) &&
(fabs( mH - otherCd->mH ) <= EPSILON) &&
(fabs( mR1 - otherCd->mR1 ) <= EPSILON) &&
(fabs( mR2 - otherCd->mR2 ) <= EPSILON) )
{
return true;
}
+4 -3
View File
@@ -21,7 +21,7 @@
#include "FrameEllipse.h"
#include "privateConstants.h"
#include "Constants.h"
#include "StrUtil.h"
@@ -41,6 +41,7 @@ namespace glabels
FrameEllipse::FrameEllipse( const FrameEllipse& other )
: mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
{
// empty
}
@@ -94,8 +95,8 @@ namespace glabels
{
if ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
{
if ( (fabs( mW - otherEllipse->mW ) <= Constants::EPSILON) &&
(fabs( mH - otherEllipse->mH ) <= Constants::EPSILON) )
if ( (fabs( mW - otherEllipse->mW ) <= EPSILON) &&
(fabs( mH - otherEllipse->mH ) <= EPSILON) )
{
return true;
}
+4 -3
View File
@@ -21,7 +21,7 @@
#include "FrameRect.h"
#include "privateConstants.h"
#include "Constants.h"
#include "StrUtil.h"
@@ -48,6 +48,7 @@ namespace glabels
: mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
mYWaste(other.mYWaste), mPath(other.mPath), Frame(other)
{
// empty
}
@@ -113,8 +114,8 @@ namespace glabels
{
if ( FrameRect *otherRect = dynamic_cast<FrameRect*>(other) )
{
if ( (fabs( mW - otherRect->mW ) <= Constants::EPSILON) &&
(fabs( mH - otherRect->mH ) <= Constants::EPSILON) )
if ( (fabs( mW - otherRect->mW ) <= EPSILON) &&
(fabs( mH - otherRect->mH ) <= EPSILON) )
{
return true;
}
+5 -3
View File
@@ -21,7 +21,7 @@
#include "FrameRound.h"
#include "privateConstants.h"
#include "Constants.h"
#include "StrUtil.h"
@@ -34,13 +34,15 @@ namespace glabels
: mR(r), mWaste(waste), Frame(id)
{
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(), 2*(mR+mWaste).pt(), 2*(mR+mWaste).pt() );
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(),
2*(mR+mWaste).pt(), 2*(mR+mWaste).pt() );
}
FrameRound::FrameRound( const FrameRound& other )
: mR(other.mR), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
{
// empty
}
@@ -99,7 +101,7 @@ namespace glabels
{
if ( FrameRound *otherRound = dynamic_cast<FrameRound*>(other) )
{
if ( fabs( mR - otherRound->mR ) <= Constants::EPSILON )
if ( fabs( mR - otherRound->mR ) <= EPSILON )
{
return true;
}
+36 -5
View File
@@ -27,6 +27,12 @@
#include "LabelModelObject.h"
namespace glabels
{
//
// Private
//
namespace
{
const double handlePixels = 7;
@@ -44,6 +50,7 @@ namespace
Handle::Handle( LabelModelObject* owner, Location location )
: mOwner(owner), mLocation(location)
{
// empty
}
@@ -52,6 +59,7 @@ Handle::Handle( LabelModelObject* owner, Location location )
///
Handle::~Handle()
{
// empty
}
@@ -78,8 +86,8 @@ Handle::Location Handle::location() const
///
void Handle::drawAt( QPainter* painter,
double scale,
const glabels::Distance& x,
const glabels::Distance& y,
const Distance& x,
const Distance& y,
QColor color ) const
{
painter->save();
@@ -95,7 +103,8 @@ void Handle::drawAt( QPainter* painter,
painter->setPen( pen );
painter->setBrush( color );
painter->drawRect( QRectF( -s*handlePixels/2.0, -s*handlePixels/2.0, s*handlePixels, s*handlePixels ) );
painter->drawRect( QRectF( -s*handlePixels/2.0, -s*handlePixels/2.0,
s*handlePixels, s*handlePixels ) );
painter->restore();
}
@@ -105,8 +114,8 @@ void Handle::drawAt( QPainter* painter,
/// Create Handle path at x,y
///
QPainterPath Handle::pathAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const
const Distance& x,
const Distance& y ) const
{
QPainterPath path;
@@ -125,6 +134,7 @@ QPainterPath Handle::pathAt( double scale,
HandleNorth::HandleNorth( LabelModelObject* owner )
: Handle( owner, N )
{
// empty
}
@@ -133,6 +143,7 @@ HandleNorth::HandleNorth( LabelModelObject* owner )
///
HandleNorth::~HandleNorth()
{
// empty
}
@@ -169,6 +180,7 @@ QPainterPath HandleNorth::path( double scale ) const
HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
: Handle( owner, NE )
{
// empty
}
@@ -177,6 +189,7 @@ HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
///
HandleNorthEast::~HandleNorthEast()
{
// empty
}
@@ -213,6 +226,7 @@ QPainterPath HandleNorthEast::path( double scale ) const
HandleEast::HandleEast( LabelModelObject* owner )
: Handle( owner, E )
{
// empty
}
@@ -221,6 +235,7 @@ HandleEast::HandleEast( LabelModelObject* owner )
///
HandleEast::~HandleEast()
{
// empty
}
@@ -257,6 +272,7 @@ QPainterPath HandleEast::path( double scale ) const
HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
: Handle( owner, SE )
{
// empty
}
@@ -265,6 +281,7 @@ HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
///
HandleSouthEast::~HandleSouthEast()
{
// empty
}
@@ -301,6 +318,7 @@ QPainterPath HandleSouthEast::path( double scale ) const
HandleSouth::HandleSouth( LabelModelObject* owner )
: Handle( owner, S )
{
// empty
}
@@ -309,6 +327,7 @@ HandleSouth::HandleSouth( LabelModelObject* owner )
///
HandleSouth::~HandleSouth()
{
// empty
}
@@ -345,6 +364,7 @@ QPainterPath HandleSouth::path( double scale ) const
HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
: Handle( owner, SW )
{
// empty
}
@@ -353,6 +373,7 @@ HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
///
HandleSouthWest::~HandleSouthWest()
{
// empty
}
@@ -389,6 +410,7 @@ QPainterPath HandleSouthWest::path( double scale ) const
HandleWest::HandleWest( LabelModelObject* owner )
: Handle( owner, W )
{
// empty
}
@@ -397,6 +419,7 @@ HandleWest::HandleWest( LabelModelObject* owner )
///
HandleWest::~HandleWest()
{
// empty
}
@@ -433,6 +456,7 @@ QPainterPath HandleWest::path( double scale ) const
HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
: Handle( owner, NW )
{
// empty
}
@@ -441,6 +465,7 @@ HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
///
HandleNorthWest::~HandleNorthWest()
{
// empty
}
///
@@ -476,6 +501,7 @@ QPainterPath HandleNorthWest::path( double scale ) const
HandleP1::HandleP1( LabelModelObject* owner )
: Handle( owner, P1 )
{
// empty
}
@@ -484,6 +510,7 @@ HandleP1::HandleP1( LabelModelObject* owner )
///
HandleP1::~HandleP1()
{
// empty
}
@@ -520,6 +547,7 @@ QPainterPath HandleP1::path( double scale ) const
HandleP2::HandleP2( LabelModelObject* owner )
: Handle( owner, P2 )
{
// empty
}
@@ -528,6 +556,7 @@ HandleP2::HandleP2( LabelModelObject* owner )
///
HandleP2::~HandleP2()
{
// empty
}
@@ -556,3 +585,5 @@ QPainterPath HandleP2::path( double scale ) const
{
return pathAt( scale, mOwner->w(), mOwner->h() );
}
}
+10 -4
View File
@@ -27,6 +27,10 @@
#include "Distance.h"
namespace glabels
{
// Forward References
class LabelModelObject;
@@ -74,13 +78,13 @@ public:
protected:
void drawAt( QPainter* painter,
double scale,
const glabels::Distance& x,
const glabels::Distance& y,
const Distance& x,
const Distance& y,
QColor color ) const;
QPainterPath pathAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const;
const Distance& x,
const Distance& y ) const;
////////////////////////////
@@ -326,5 +330,7 @@ public:
virtual QPainterPath path( double scale ) const;
};
}
#endif // Handles_h
+5
View File
@@ -26,6 +26,9 @@
#include "AboutDialog.h"
namespace glabels
{
///
/// Display Help Contents
///
@@ -43,3 +46,5 @@ void Help::displayAbout( QWidget *parent )
AboutDialog dialog( parent );
dialog.exec();
}
}
+4
View File
@@ -25,6 +25,9 @@
#include <QWidget>
namespace glabels
{
///
/// Help Actions
///
@@ -36,5 +39,6 @@ namespace Help
}
}
#endif // Help_h
+3 -7
View File
@@ -25,6 +25,9 @@
#include <QIcon>
namespace glabels
{
///
/// Glabels Icons
///
@@ -336,13 +339,6 @@ namespace Icons
};
///
/// 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
{
class EditCopy : public QIcon
{
public:
+38 -35
View File
@@ -42,15 +42,17 @@
#include "UndoRedoModel.h"
namespace glabels
{
//
// Private Configuration Data
// Private
//
namespace
{
const int nZoomLevels = 11;
const double zoomLevels[nZoomLevels] = { 8, 6, 4, 3, 2, 1.5, 1, 0.75, 0.67, 0.50, 0.33 };
const double PTS_PER_INCH = 72.0;
const double ZOOM_TO_FIT_PAD = 16.0;
const QColor backgroundColor( 192, 192, 192 );
@@ -64,7 +66,7 @@ namespace
const QColor gridLineColor( 192, 192, 192 );
const double gridLineWidthPixels = 1;
const glabels::Distance gridSpacing = glabels::Distance::pt(9); // TODO: determine from locale.
const Distance gridSpacing = Distance::pt(9); // TODO: determine from locale.
const QColor markupLineColor( 240, 99, 99 );
const double markupLineWidthPixels = 1;
@@ -75,7 +77,6 @@ namespace
}
///
/// Constructor
///
@@ -418,8 +419,8 @@ LabelEditor::mousePressEvent( QMouseEvent* event )
transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->pos() );
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
Distance xWorld = Distance::pt( pWorld.x() );
Distance yWorld = Distance::pt( pWorld.y() );
if ( event->button() & Qt::LeftButton )
@@ -584,8 +585,8 @@ LabelEditor::mouseMoveEvent( QMouseEvent* event )
transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->pos() );
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
Distance xWorld = Distance::pt( pWorld.x() );
Distance yWorld = Distance::pt( pWorld.y() );
/*
@@ -686,8 +687,8 @@ LabelEditor::mouseReleaseEvent( QMouseEvent* event )
transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->pos() );
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
Distance xWorld = Distance::pt( pWorld.x() );
Distance yWorld = Distance::pt( pWorld.y() );
if ( event->button() & Qt::LeftButton )
@@ -762,8 +763,8 @@ LabelEditor::leaveEvent( QEvent* event )
/// Handle resize motion
///
void
LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
const glabels::Distance& yWorld )
LabelEditor::handleResizeMotion( const Distance& xWorld,
const Distance& yWorld )
{
QPointF p( xWorld.pt(), yWorld.pt() );
Handle::Location location = mResizeHandle->location();
@@ -853,22 +854,22 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
{
case Handle::E:
case Handle::W:
mResizeObject->setWHonorAspect( glabels::Distance::pt(w) );
mResizeObject->setWHonorAspect( Distance::pt(w) );
break;
case Handle::N:
case Handle::S:
mResizeObject->setHHonorAspect( glabels::Distance::pt(h) );
mResizeObject->setHHonorAspect( Distance::pt(h) );
break;
default:
mResizeObject->setSizeHonorAspect( glabels::Distance::pt(w),
glabels::Distance::pt(h) );
mResizeObject->setSizeHonorAspect( Distance::pt(w),
Distance::pt(h) );
break;
}
}
else
{
mResizeObject->setSize( glabels::Distance::pt(w),
glabels::Distance::pt(h) );
mResizeObject->setSize( Distance::pt(w),
Distance::pt(h) );
}
/*
@@ -894,8 +895,8 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
}
else
{
mResizeObject->setSize( glabels::Distance::pt(w),
glabels::Distance::pt(h) );
mResizeObject->setSize( Distance::pt(w),
Distance::pt(h) );
}
/*
@@ -904,8 +905,8 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
QPointF p0( x0, y0 );
p0 = mResizeObject->matrix().map( p0 );
p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
mResizeObject->setPosition( glabels::Distance::pt(p0.x()),
glabels::Distance::pt(p0.y()) );
mResizeObject->setPosition( Distance::pt(p0.x()),
Distance::pt(p0.y()) );
}
@@ -921,22 +922,22 @@ LabelEditor::keyPressEvent( QKeyEvent* event )
case Qt::Key_Left:
mUndoRedoModel->checkpoint( tr("Move") );
mModel->moveSelection( -mStepSize, glabels::Distance(0) );
mModel->moveSelection( -mStepSize, Distance(0) );
break;
case Qt::Key_Up:
mUndoRedoModel->checkpoint( tr("Move") );
mModel->moveSelection( glabels::Distance(0), -mStepSize );
mModel->moveSelection( Distance(0), -mStepSize );
break;
case Qt::Key_Right:
mUndoRedoModel->checkpoint( tr("Move") );
mModel->moveSelection( mStepSize, glabels::Distance(0) );
mModel->moveSelection( mStepSize, Distance(0) );
break;
case Qt::Key_Down:
mUndoRedoModel->checkpoint( tr("Move") );
mModel->moveSelection( glabels::Distance(0), mStepSize );
mModel->moveSelection( Distance(0), mStepSize );
break;
case Qt::Key_Delete:
@@ -1046,11 +1047,11 @@ LabelEditor::drawGridLayer( QPainter* painter )
{
if ( mGridVisible )
{
glabels::Distance w = mModel->frame()->w();
glabels::Distance h = mModel->frame()->h();
Distance w = mModel->frame()->w();
Distance h = mModel->frame()->h();
glabels::Distance x0, y0;
if ( dynamic_cast<const glabels::FrameRect*>( mModel->frame() ) )
Distance x0, y0;
if ( dynamic_cast<const FrameRect*>( mModel->frame() ) )
{
x0 = gridSpacing;
y0 = gridSpacing;
@@ -1075,12 +1076,12 @@ LabelEditor::drawGridLayer( QPainter* painter )
pen.setCosmetic( true );
painter->setPen( pen );
for ( glabels::Distance x = x0; x < w; x += gridSpacing )
for ( Distance x = x0; x < w; x += gridSpacing )
{
painter->drawLine( x.pt(), 0, x.pt(), h.pt() );
}
for ( glabels::Distance y = y0; y < h; y += gridSpacing )
for ( Distance y = y0; y < h; y += gridSpacing )
{
painter->drawLine( 0, y.pt(), w.pt(), y.pt() );
}
@@ -1112,7 +1113,7 @@ LabelEditor::drawMarkupLayer( QPainter* painter )
painter->translate( -mModel->frame()->w().pt(), 0 );
}
foreach( glabels::Markup* markup, mModel->frame()->markups() )
foreach( Markup* markup, mModel->frame()->markups() )
{
painter->drawPath( markup->path() );
}
@@ -1207,9 +1208,9 @@ LabelEditor::drawSelectRegionLayer( QPainter* painter )
///
void LabelEditor::onSettingsChanged()
{
glabels::Units units = Settings::units();
Units units = Settings::units();
mStepSize = glabels::Distance( units.resolution(), units );
mStepSize = Distance( units.resolution(), units );
}
@@ -1248,3 +1249,5 @@ void LabelEditor::onModelSizeChanged()
emit zoomChanged();
}
}
+16 -10
View File
@@ -28,6 +28,10 @@
#include "Region.h"
namespace glabels
{
// Forward References
class LabelModel;
class LabelModelObject;
@@ -55,7 +59,7 @@ public:
signals:
void contextMenuActivate();
void zoomChanged();
void pointerMoved( const glabels::Distance& x, const glabels::Distance& y );
void pointerMoved( const Distance& x, const Distance& y );
void pointerExited();
void modeChanged();
@@ -128,8 +132,8 @@ protected:
// Private methods
/////////////////////////////////////
private:
void handleResizeMotion( const glabels::Distance& xWorld,
const glabels::Distance& yWorld );
void handleResizeMotion( const Distance& xWorld,
const Distance& yWorld );
void drawBgLayer( QPainter* painter );
void drawGridLayer( QPainter* painter );
@@ -175,14 +179,14 @@ private:
double mZoom;
bool mZoomToFitFlag;
double mScale;
glabels::Distance mX0;
glabels::Distance mY0;
Distance mX0;
Distance mY0;
bool mMarkupVisible;
bool mGridVisible;
double mGridSpacing;
glabels::Distance mStepSize;
Distance mStepSize;
LabelModel* mModel;
UndoRedoModel* mUndoRedoModel;
@@ -194,8 +198,8 @@ private:
Region mSelectRegion;
/* ArrowMove state */
glabels::Distance mMoveLastX;
glabels::Distance mMoveLastY;
Distance mMoveLastX;
Distance mMoveLastY;
/* ArrowResize state */
LabelModelObject* mResizeObject;
@@ -205,11 +209,13 @@ private:
/* CreateDrag state */
CreateType mCreateObjectType;
LabelModelObject* mCreateObject;
glabels::Distance mCreateX0;
glabels::Distance mCreateY0;
Distance mCreateX0;
Distance mCreateY0;
};
}
#endif // LabelEditor_h
+65 -57
View File
@@ -35,6 +35,12 @@
#include "Merge/None.h"
namespace glabels
{
//
// Private
//
namespace
{
const QString MIME_TYPE = "application/x-glabels-objects";
@@ -161,7 +167,7 @@ void LabelModel::setCompressionLevel( int compressionLevel )
///
/// Get template
///
const glabels::Template* LabelModel::tmplate() const
const Template* LabelModel::tmplate() const
{
return mTmplate;
}
@@ -170,7 +176,7 @@ const glabels::Template* LabelModel::tmplate() const
///
/// Get frame
///
const glabels::Frame* LabelModel::frame() const
const Frame* LabelModel::frame() const
{
return mFrame;
}
@@ -179,7 +185,7 @@ const glabels::Frame* LabelModel::frame() const
///
/// Set template
///
void LabelModel::setTmplate( const glabels::Template* tmplate )
void LabelModel::setTmplate( const Template* tmplate )
{
if (mTmplate != tmplate)
{
@@ -225,7 +231,7 @@ void LabelModel::setRotate( bool rotate )
///
/// Get width
///
glabels::Distance LabelModel::w() const
Distance LabelModel::w() const
{
return mRotate ? mFrame->h() : mFrame->w();
}
@@ -234,7 +240,7 @@ glabels::Distance LabelModel::w() const
///
/// Get height
///
glabels::Distance LabelModel::h() const
Distance LabelModel::h() const
{
return mRotate ? mFrame->w() : mFrame->h();
}
@@ -365,8 +371,8 @@ void LabelModel::deleteObject( LabelModelObject* object )
/// Object at x,y
///
LabelModelObject* LabelModel::objectAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const
const Distance& x,
const Distance& y ) const
{
/* Search object list in reverse order. I.e. from top to bottom. */
QList<LabelModelObject*>::const_iterator it = mObjectList.end();
@@ -388,8 +394,8 @@ LabelModelObject* LabelModel::objectAt( double scale,
/// Handle at x,y
///
Handle* LabelModel::handleAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const
const Distance& x,
const Distance& y ) const
{
foreach( LabelModelObject* object, mObjectList )
{
@@ -500,10 +506,10 @@ void LabelModel::unselectAll()
///
void LabelModel::selectRegion( const Region &region )
{
glabels::Distance rX1 = min( region.x1(), region.x2() );
glabels::Distance rY1 = min( region.y1(), region.y2() );
glabels::Distance rX2 = max( region.x1(), region.x2() );
glabels::Distance rY2 = max( region.y1(), region.y2() );
Distance rX1 = min( region.x1(), region.x2() );
Distance rY1 = min( region.y1(), region.y2() );
Distance rX2 = max( region.x1(), region.x2() );
Distance rY2 = max( region.y1(), region.y2() );
foreach ( LabelModelObject* object, mObjectList )
{
@@ -695,7 +701,7 @@ void LabelModel::raiseSelectionToTop()
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 );
@@ -719,7 +725,7 @@ void LabelModel::lowerSelectionToBottom()
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 );
@@ -818,19 +824,19 @@ void LabelModel::alignSelectionLeft()
QList<LabelModelObject*> selectedList = getSelection();
/// Find left-most edge.
glabels::Distance x1_min = 7200; /// Start with a very large value: 7200pts = 100in
// Find left-most edge.
Distance x1_min = 7200; // Start with a very large value: 7200pts = 100in
foreach ( LabelModelObject* object, selectedList )
{
Region 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 )
{
Region r = object->getExtent();
glabels::Distance dx = x1_min - r.x1();
Distance dx = x1_min - r.x1();
object->setPositionRelative( dx, 0 );
}
@@ -852,19 +858,19 @@ void LabelModel::alignSelectionRight()
QList<LabelModelObject*> selectedList = getSelection();
/// Find right-most edge.
glabels::Distance x1_max = -7200; /// Start with a very large negative value: 7200pts = 100in
// Find right-most edge.
Distance x1_max = -7200; // Start with a very large negative value: 7200pts = 100in
foreach ( LabelModelObject* object, selectedList )
{
Region 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 )
{
Region r = object->getExtent();
glabels::Distance dx = x1_max - r.x1();
Distance dx = x1_max - r.x1();
object->setPositionRelative( dx, 0 );
}
@@ -886,8 +892,8 @@ void LabelModel::alignSelectionHCenter()
QList<LabelModelObject*> selectedList = getSelection();
/// Find average center of objects.
glabels::Distance xsum = 0;
// Find average center of objects.
Distance xsum = 0;
int n = 0;
foreach ( LabelModelObject* object, selectedList )
{
@@ -895,15 +901,15 @@ void LabelModel::alignSelectionHCenter()
xsum += (r.x1() + r.x2()) / 2.0;
n++;
}
glabels::Distance xavg = xsum / n;
Distance xavg = xsum / n;
/// Find object closest to average center of objects.
glabels::Distance xcenter = 7200; /// Start with very large value.
glabels::Distance dxmin = fabs( xavg - xcenter );
// Find object closest to average center of objects.
Distance xcenter = 7200; // Start with very large value.
Distance dxmin = fabs( xavg - xcenter );
foreach ( LabelModelObject* object, selectedList )
{
Region r = object->getExtent();
glabels::Distance dx = fabs( xavg - (r.x1() + r.x2())/2.0 );
Distance dx = fabs( xavg - (r.x1() + r.x2())/2.0 );
if ( dx < dxmin )
{
dxmin = dx;
@@ -911,11 +917,11 @@ void LabelModel::alignSelectionHCenter()
}
}
/// 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 )
{
Region r = object->getExtent();
glabels::Distance dx = xcenter - (r.x1() + r.x2())/2.0;
Distance dx = xcenter - (r.x1() + r.x2())/2.0;
object->setPositionRelative( dx, 0 );
}
@@ -937,19 +943,19 @@ void LabelModel::alignSelectionTop()
QList<LabelModelObject*> selectedList = getSelection();
/// Find top-most edge.
glabels::Distance y1_min = 7200; /// Start with a very large value: 7200pts = 100in
// Find top-most edge.
Distance y1_min = 7200; // Start with a very large value: 7200pts = 100in
foreach ( LabelModelObject* object, selectedList )
{
Region 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 )
{
Region r = object->getExtent();
glabels::Distance dy = y1_min - r.y1();
Distance dy = y1_min - r.y1();
object->setPositionRelative( 0, dy );
}
@@ -971,19 +977,19 @@ void LabelModel::alignSelectionBottom()
QList<LabelModelObject*> selectedList = getSelection();
/// Find bottom-most edge.
glabels::Distance y1_max = -7200; /// Start with a very large negative value: 7200pts = 100in
// Find bottom-most edge.
Distance y1_max = -7200; // Start with a very large negative value: 7200pts = 100in
foreach ( LabelModelObject* object, selectedList )
{
Region 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 )
{
Region r = object->getExtent();
glabels::Distance dy = y1_max - r.y1();
Distance dy = y1_max - r.y1();
object->setPositionRelative( 0, dy );
}
@@ -1005,8 +1011,8 @@ void LabelModel::alignSelectionVCenter()
QList<LabelModelObject*> selectedList = getSelection();
/// Find average center of objects.
glabels::Distance ysum = 0;
// Find average center of objects.
Distance ysum = 0;
int n = 0;
foreach ( LabelModelObject* object, selectedList )
{
@@ -1014,15 +1020,15 @@ void LabelModel::alignSelectionVCenter()
ysum += (r.y1() + r.y2()) / 2.0;
n++;
}
glabels::Distance yavg = ysum / n;
Distance yavg = ysum / n;
/// Find object closest to average center of objects.
glabels::Distance ycenter = 7200; /// Start with very large value.
glabels::Distance dymin = fabs( yavg - ycenter );
// Find object closest to average center of objects.
Distance ycenter = 7200; // Start with very large value.
Distance dymin = fabs( yavg - ycenter );
foreach ( LabelModelObject* object, selectedList )
{
Region r = object->getExtent();
glabels::Distance dy = fabs( yavg - (r.y1() + r.y2())/2.0 );
Distance dy = fabs( yavg - (r.y1() + r.y2())/2.0 );
if ( dy < dymin )
{
dymin = dy;
@@ -1030,11 +1036,11 @@ void LabelModel::alignSelectionVCenter()
}
}
/// 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 )
{
Region r = object->getExtent();
glabels::Distance dy = ycenter - (r.y1() + r.y2())/2.0;
Distance dy = ycenter - (r.y1() + r.y2())/2.0;
object->setPositionRelative( 0, dy );
}
@@ -1049,15 +1055,15 @@ void LabelModel::alignSelectionVCenter()
///
void LabelModel::centerSelectionHoriz()
{
glabels::Distance xLabelCenter = w() / 2.0;
Distance xLabelCenter = w() / 2.0;
foreach ( LabelModelObject* object, mObjectList )
{
if ( object->isSelected() )
{
Region r = object->getExtent();
glabels::Distance xObjectCenter = (r.x1() + r.x2()) / 2.0;
glabels::Distance dx = xLabelCenter - xObjectCenter;
Distance xObjectCenter = (r.x1() + r.x2()) / 2.0;
Distance dx = xLabelCenter - xObjectCenter;
object->setPositionRelative( dx, 0 );
}
}
@@ -1073,15 +1079,15 @@ void LabelModel::centerSelectionHoriz()
///
void LabelModel::centerSelectionVert()
{
glabels::Distance yLabelCenter = h() / 2.0;
Distance yLabelCenter = h() / 2.0;
foreach ( LabelModelObject* object, mObjectList )
{
if ( object->isSelected() )
{
Region r = object->getExtent();
glabels::Distance yObjectCenter = (r.y1() + r.y2()) / 2.0;
glabels::Distance dy = yLabelCenter - yObjectCenter;
Distance yObjectCenter = (r.y1() + r.y2()) / 2.0;
Distance dy = yLabelCenter - yObjectCenter;
object->setPositionRelative( 0, dy );
}
}
@@ -1095,7 +1101,7 @@ void LabelModel::centerSelectionVert()
///
/// Move Selected Objects By dx,dy
///
void LabelModel::moveSelection( const glabels::Distance& dx, const glabels::Distance& dy )
void LabelModel::moveSelection( const Distance& dx, const Distance& dy )
{
foreach ( LabelModelObject* object, mObjectList )
{
@@ -1266,7 +1272,7 @@ void LabelModel::setSelectionTextColorNode( ColorNode textColorNode )
///
/// Set Line Width Of Selected Objects
///
void LabelModel::setSelectionLineWidth( const glabels::Distance& lineWidth )
void LabelModel::setSelectionLineWidth( const Distance& lineWidth )
{
foreach ( LabelModelObject* object, mObjectList )
{
@@ -1415,3 +1421,5 @@ void LabelModel::draw( QPainter* painter, bool inEditor, merge::Record* record )
object->draw( painter, inEditor, record );
}
}
}
+22 -19
View File
@@ -32,18 +32,19 @@
#include "Merge/Merge.h"
#include "Merge/Record.h"
namespace glabels
{
// Forward References
class ColorNode;
class Handle;
class LabelModelObject;
class Region;
//////////////////////////////////////////////
//////////////////////////////////////////////
// LabelModel
//////////////////////////////////////////////
//////////////////////////////////////////////
///
/// LabelModel
///
class LabelModel : public QObject
{
Q_OBJECT
@@ -93,15 +94,15 @@ public:
int compressionLevel() const;
void setCompressionLevel( int compressionLevel );
const glabels::Template* tmplate() const;
const glabels::Frame* frame() const;
void setTmplate( const glabels::Template* tmplate );
const Template* tmplate() const;
const Frame* frame() const;
void setTmplate( const Template* tmplate );
bool rotate() const;
void setRotate( bool rotate );
glabels::Distance w() const;
glabels::Distance h() const;
Distance w() const;
Distance h() const;
const QList<LabelModelObject*>& objectList() const;
@@ -117,12 +118,12 @@ public:
void deleteObject( LabelModelObject* object );
LabelModelObject* objectAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const;
const Distance& x,
const Distance& y ) const;
Handle* handleAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const;
const Distance& x,
const Distance& y ) const;
/////////////////////////////////
@@ -176,7 +177,7 @@ public:
void alignSelectionVCenter();
void centerSelectionHoriz();
void centerSelectionVert();
void moveSelection( const glabels::Distance& dx, const glabels::Distance& dy );
void moveSelection( const Distance& dx, const Distance& dy );
void setSelectionFontFamily( const QString& fontFamily );
void setSelectionFontSize( double fontSize );
void setSelectionFontWeight( QFont::Weight fontWeight );
@@ -185,7 +186,7 @@ public:
void setSelectionTextVAlign( Qt::Alignment textVAlign );
void setSelectionTextLineSpacing( double textLineSpacing );
void setSelectionTextColorNode( ColorNode textColorNode );
void setSelectionLineWidth( const glabels::Distance& lineWidth );
void setSelectionLineWidth( const Distance& lineWidth );
void setSelectionLineColorNode( ColorNode lineColorNode );
void setSelectionFillColorNode( ColorNode fillColorNode );
@@ -223,8 +224,8 @@ private:
bool mModified;
QString mFileName;
int mCompressionLevel;
const glabels::Template* mTmplate;
const glabels::Frame* mFrame;
const Template* mTmplate;
const Frame* mFrame;
bool mRotate;
QList<LabelModelObject*> mObjectList;
@@ -232,5 +233,7 @@ private:
merge::Merge* mMerge;
};
}
#endif // LabelModel_h
+13 -1
View File
@@ -25,6 +25,12 @@
#include <QPen>
namespace glabels
{
//
// Private
//
namespace
{
const double slopPixels = 2;
@@ -36,14 +42,17 @@ namespace
///
LabelModelBoxObject::LabelModelBoxObject()
{
// empty
}
///
/// Copy constructor
///
LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object ) : LabelModelShapeObject( object )
LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object )
: LabelModelShapeObject( object )
{
// empty
}
@@ -52,6 +61,7 @@ LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object ) :
///
LabelModelBoxObject::~LabelModelBoxObject()
{
// empty
}
@@ -156,3 +166,5 @@ QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
return path;
}
}
+5
View File
@@ -25,6 +25,9 @@
#include "LabelModelShapeObject.h"
namespace glabels
{
///
/// Label Model Box Object
///
@@ -57,5 +60,7 @@ protected:
};
}
#endif // LabelModelBoxObject_h
+13 -1
View File
@@ -25,6 +25,12 @@
#include <QPen>
namespace glabels
{
//
// Private
//
namespace
{
const double slopPixels = 2;
@@ -36,14 +42,17 @@ namespace
///
LabelModelEllipseObject::LabelModelEllipseObject()
{
// empty
}
///
/// Copy constructor
///
LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject* object ) : LabelModelShapeObject( object )
LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject* object )
: LabelModelShapeObject( object )
{
// empty
}
@@ -52,6 +61,7 @@ LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject*
///
LabelModelEllipseObject::~LabelModelEllipseObject()
{
// empty
}
@@ -156,3 +166,5 @@ QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
return path;
}
}
+5
View File
@@ -25,6 +25,9 @@
#include "LabelModelShapeObject.h"
namespace glabels
{
///
/// Label Model Ellipse Object
///
@@ -57,5 +60,7 @@ protected:
};
}
#endif // LabelModelEllipseObject_h
+8 -8
View File
@@ -30,10 +30,8 @@
#include "Size.h"
namespace
namespace glabels
{
}
///
/// Static data
@@ -126,19 +124,19 @@ void LabelModelImageObject::setFilenameNode( const TextNode& value )
///
Size LabelModelImageObject::originalSize() const
{
Size size( glabels::Distance::pt(72), glabels::Distance::pt(72) );
Size size( Distance::pt(72), Distance::pt(72) );
if ( mImage )
{
QSize qsize = mImage->size();
size.setW( glabels::Distance::pt( qsize.width() ) );
size.setH( glabels::Distance::pt( qsize.height() ) );
size.setW( Distance::pt( qsize.width() ) );
size.setH( Distance::pt( qsize.height() ) );
}
else if ( mSvg )
{
QSize qsize = mSvg->defaultSize();
size.setW( glabels::Distance::pt( qsize.width() ) );
size.setH( glabels::Distance::pt( qsize.height() ) );
size.setW( Distance::pt( qsize.width() ) );
size.setH( Distance::pt( qsize.height() ) );
}
return size;
@@ -314,3 +312,5 @@ QImage* LabelModelImageObject::createShadowImage( const QColor& color ) const
return shadow;
}
}
+5
View File
@@ -27,6 +27,9 @@
#include "LabelModelObject.h"
namespace glabels
{
///
/// Label Model Image Object
///
@@ -98,5 +101,7 @@ protected:
};
}
#endif // LabelModelImageObject_h
+12 -3
View File
@@ -25,6 +25,12 @@
#include <QPen>
namespace glabels
{
//
// Private
//
namespace
{
const double slopPixels = 2;
@@ -49,7 +55,8 @@ LabelModelLineObject::LabelModelLineObject()
///
/// Copy constructor
///
LabelModelLineObject::LabelModelLineObject( const LabelModelLineObject* object ) : LabelModelObject(object)
LabelModelLineObject::LabelModelLineObject( const LabelModelLineObject* object )
: LabelModelObject(object)
{
mLineWidth = object->mLineWidth;
mLineColorNode = object->mLineColorNode;
@@ -81,7 +88,7 @@ LabelModelLineObject* LabelModelLineObject::clone() const
///
/// Line Width Property Getter
///
glabels::Distance LabelModelLineObject::lineWidth( void ) const
Distance LabelModelLineObject::lineWidth( void ) const
{
return mLineWidth;
}
@@ -90,7 +97,7 @@ glabels::Distance LabelModelLineObject::lineWidth( void ) const
///
/// Line Width Property Setter
///
void LabelModelLineObject::setLineWidth( const glabels::Distance& value )
void LabelModelLineObject::setLineWidth( const Distance& value )
{
if ( mLineWidth != value )
{
@@ -198,3 +205,5 @@ QPainterPath LabelModelLineObject::hoverPath( double scale ) const
return path;
}
}
+8 -3
View File
@@ -25,6 +25,9 @@
#include "LabelModelObject.h"
namespace glabels
{
///
/// Label Model Line Object
///
@@ -54,8 +57,8 @@ public:
//
// Line Property: lineWidth
//
virtual glabels::Distance lineWidth( void ) const;
virtual void setLineWidth( const glabels::Distance& value );
virtual Distance lineWidth( void ) const;
virtual void setLineWidth( const Distance& value );
//
@@ -86,10 +89,12 @@ protected:
// Private Members
///////////////////////////////////////////////////////////////
protected:
glabels::Distance mLineWidth;
Distance mLineWidth;
ColorNode mLineColorNode;
};
}
#endif // LabelModelLineObject_h
+60 -35
View File
@@ -31,6 +31,9 @@
#include "TextNode.h"
namespace glabels
{
///
/// Next Object ID
///
@@ -105,6 +108,7 @@ LabelModelObject::LabelModelObject( const LabelModelObject* object )
///
LabelModelObject::~LabelModelObject()
{
// empty
}
@@ -147,7 +151,7 @@ void LabelModelObject::unselect()
///
/// X0 Property Getter
///
glabels::Distance LabelModelObject::x0() const
Distance LabelModelObject::x0() const
{
return mX0;
}
@@ -156,7 +160,7 @@ glabels::Distance LabelModelObject::x0() const
///
/// X0 Property Setter
///
void LabelModelObject::setX0( const glabels::Distance& value )
void LabelModelObject::setX0( const Distance& value )
{
if ( mX0 != value )
{
@@ -169,7 +173,7 @@ void LabelModelObject::setX0( const glabels::Distance& value )
///
/// Y0 Property Getter
///
glabels::Distance LabelModelObject::y0() const
Distance LabelModelObject::y0() const
{
return mY0;
}
@@ -178,7 +182,7 @@ glabels::Distance LabelModelObject::y0() const
///
/// Y0 Property Setter
///
void LabelModelObject::setY0( const glabels::Distance& value )
void LabelModelObject::setY0( const Distance& value )
{
if ( mY0 != value )
{
@@ -191,7 +195,7 @@ void LabelModelObject::setY0( const glabels::Distance& value )
///
/// W (Width) Property Getter
///
glabels::Distance LabelModelObject::w() const
Distance LabelModelObject::w() const
{
return mW;
}
@@ -200,7 +204,7 @@ glabels::Distance LabelModelObject::w() const
///
/// W (Width) Property Setter
///
void LabelModelObject::setW( const glabels::Distance& value )
void LabelModelObject::setW( const Distance& value )
{
if ( mW != value )
{
@@ -214,7 +218,7 @@ void LabelModelObject::setW( const glabels::Distance& value )
///
/// H (Height) Property Getter
///
glabels::Distance LabelModelObject::h() const
Distance LabelModelObject::h() const
{
return mH;
}
@@ -223,7 +227,7 @@ glabels::Distance LabelModelObject::h() const
///
/// H (Height) Property Setter
///
void LabelModelObject::setH( const glabels::Distance& value )
void LabelModelObject::setH( const Distance& value )
{
if ( mH != value )
{
@@ -281,7 +285,7 @@ void LabelModelObject::setShadow( bool value )
///
/// Shadow X Property Getter
///
glabels::Distance LabelModelObject::shadowX() const
Distance LabelModelObject::shadowX() const
{
return mShadowX;
}
@@ -290,7 +294,7 @@ glabels::Distance LabelModelObject::shadowX() const
///
/// Shadow X Property Setter
///
void LabelModelObject::setShadowX( const glabels::Distance& value )
void LabelModelObject::setShadowX( const Distance& value )
{
if ( mShadowX != value )
{
@@ -303,7 +307,7 @@ void LabelModelObject::setShadowX( const glabels::Distance& value )
///
/// Shadow Y Property Getter
///
glabels::Distance LabelModelObject::shadowY() const
Distance LabelModelObject::shadowY() const
{
return mShadowY;
}
@@ -312,7 +316,7 @@ glabels::Distance LabelModelObject::shadowY() const
///
/// Shadow Y Property Setter
///
void LabelModelObject::setShadowY( const glabels::Distance& value )
void LabelModelObject::setShadowY( const Distance& value )
{
if ( mShadowY != value )
{
@@ -382,6 +386,7 @@ QString LabelModelObject::text() const
///
void LabelModelObject::setText( const QString& value )
{
// empty
}
@@ -401,6 +406,7 @@ QString LabelModelObject::fontFamily() const
///
void LabelModelObject::setFontFamily( const QString& value )
{
// empty
}
@@ -420,6 +426,7 @@ double LabelModelObject::fontSize() const
///
void LabelModelObject::setFontSize( double value )
{
// empty
}
@@ -439,6 +446,7 @@ QFont::Weight LabelModelObject::fontWeight() const
///
void LabelModelObject::setFontWeight( QFont::Weight value )
{
// empty
}
@@ -458,6 +466,7 @@ bool LabelModelObject::fontItalicFlag() const
///
void LabelModelObject::setFontItalicFlag( bool value )
{
// empty
}
@@ -477,6 +486,7 @@ bool LabelModelObject::fontUnderlineFlag() const
///
void LabelModelObject::setFontUnderlineFlag( bool value )
{
// empty
}
@@ -496,6 +506,7 @@ ColorNode LabelModelObject::textColorNode() const
///
void LabelModelObject::setTextColorNode( const ColorNode &value )
{
// empty
}
@@ -515,6 +526,7 @@ Qt::Alignment LabelModelObject::textHAlign() const
///
void LabelModelObject::setTextHAlign( Qt::Alignment value )
{
// empty
}
@@ -534,6 +546,7 @@ Qt::Alignment LabelModelObject::textVAlign() const
///
void LabelModelObject::setTextVAlign( Qt::Alignment value )
{
// empty
}
@@ -553,6 +566,7 @@ double LabelModelObject::textLineSpacing() const
///
void LabelModelObject::setTextLineSpacing( double value )
{
// empty
}
@@ -572,6 +586,7 @@ TextNode LabelModelObject::filenameNode() const
///
void LabelModelObject::setFilenameNode( const TextNode& value )
{
// empty
}
@@ -581,7 +596,7 @@ void LabelModelObject::setFilenameNode( const TextNode& value )
///
Size LabelModelObject::originalSize() const
{
return Size( glabels::Distance::pt(0), glabels::Distance::pt(0) );
return Size( Distance::pt(0), Distance::pt(0) );
}
@@ -589,7 +604,7 @@ Size LabelModelObject::originalSize() const
/// Virtual Line Width Property Default Getter
/// (Overridden by concrete class)
///
glabels::Distance LabelModelObject::lineWidth() const
Distance LabelModelObject::lineWidth() const
{
return 0;
}
@@ -599,8 +614,9 @@ glabels::Distance LabelModelObject::lineWidth() const
/// Virtual Line Width Property Default Setter
/// (Overridden by concrete class)
///
void LabelModelObject::setLineWidth( const glabels::Distance& value )
void LabelModelObject::setLineWidth( const Distance& value )
{
// empty
}
@@ -620,6 +636,7 @@ ColorNode LabelModelObject::lineColorNode() const
///
void LabelModelObject::setLineColorNode( const ColorNode &value )
{
// empty
}
@@ -639,6 +656,7 @@ ColorNode LabelModelObject::fillColorNode() const
///
void LabelModelObject::setFillColorNode( const ColorNode &value )
{
// empty
}
@@ -658,6 +676,7 @@ TextNode LabelModelObject::bcDataNode() const
///
void LabelModelObject::setBcDataNode( const TextNode &value )
{
// empty
}
@@ -677,6 +696,7 @@ bool LabelModelObject::bcTextFlag() const
///
void LabelModelObject::setBcTextFlag( bool value )
{
// empty
}
@@ -696,6 +716,7 @@ bool LabelModelObject::bcChecksumFlag() const
///
void LabelModelObject::setBcChecksumFlag( bool value )
{
// empty
}
@@ -715,6 +736,7 @@ ColorNode LabelModelObject::bcColorNode() const
///
void LabelModelObject::setBcColorNode( const ColorNode &value )
{
// empty
}
@@ -734,6 +756,7 @@ BarcodeStyle LabelModelObject::bcStyle() const
///
void LabelModelObject::setBcStyle( const BarcodeStyle &value )
{
// empty
}
@@ -753,6 +776,7 @@ int LabelModelObject::bcFormatDigits() const
///
void LabelModelObject::setBcFormatDigits( int value )
{
// empty
}
@@ -799,8 +823,8 @@ bool LabelModelObject::canLineWidth() const
///
/// Set Absolute Position
///
void LabelModelObject::setPosition( const glabels::Distance& x0,
const glabels::Distance& y0 )
void LabelModelObject::setPosition( const Distance& x0,
const Distance& y0 )
{
if ( ( mX0 != x0 ) || ( mY0 != y0 ) )
{
@@ -815,8 +839,8 @@ void LabelModelObject::setPosition( const glabels::Distance& x0,
///
/// Set Relative Position
///
void LabelModelObject::setPositionRelative( const glabels::Distance& dx,
const glabels::Distance& dy )
void LabelModelObject::setPositionRelative( const Distance& dx,
const Distance& dy )
{
if ( ( dx != 0 ) || ( dy != 0 ) )
{
@@ -840,8 +864,8 @@ Size LabelModelObject::size() const
///
/// Set Size
///
void LabelModelObject::setSize( const glabels::Distance& w,
const glabels::Distance& h )
void LabelModelObject::setSize( const Distance& w,
const Distance& h )
{
mW = w;
mH = h;
@@ -867,12 +891,12 @@ void LabelModelObject::setSize( const Size& size )
///
/// Set Size (But Maintain Current Aspect Ratio)
///
void LabelModelObject::setSizeHonorAspect( const glabels::Distance& w,
const glabels::Distance& h )
void LabelModelObject::setSizeHonorAspect( const Distance& w,
const Distance& h )
{
double aspectRatio = mH / mW;
glabels::Distance wNew = w;
glabels::Distance hNew = h;
Distance wNew = w;
Distance hNew = h;
if ( h > (w*aspectRatio) )
{
@@ -890,10 +914,10 @@ void LabelModelObject::setSizeHonorAspect( const glabels::Distance& w,
///
/// Set Width (But Maintain Current Aspect Ratio)
///
void LabelModelObject::setWHonorAspect( const glabels::Distance& w )
void LabelModelObject::setWHonorAspect( const Distance& w )
{
double aspectRatio = mH / mW;
glabels::Distance h = w * aspectRatio;
Distance h = w * aspectRatio;
if ( ( mW != w ) || ( mH != h ) )
{
@@ -909,10 +933,10 @@ void LabelModelObject::setWHonorAspect( const glabels::Distance& w )
///
/// Set Height (But Maintain Current Aspect Ratio)
///
void LabelModelObject::setHHonorAspect( const glabels::Distance& h )
void LabelModelObject::setHHonorAspect( const Distance& h )
{
double aspectRatio = mH / mW;
glabels::Distance w = h / aspectRatio;
Distance w = h / aspectRatio;
if ( ( mW != w ) || ( mH != h ) )
{
@@ -930,8 +954,6 @@ void LabelModelObject::setHHonorAspect( const glabels::Distance& h )
///
Region LabelModelObject::getExtent()
{
using namespace glabels;
QPointF a1( ( - lineWidth()/2).pt(), ( - lineWidth()/2).pt() );
QPointF a2( (mW + lineWidth()/2).pt(), ( - lineWidth()/2).pt() );
QPointF a3( (mW + lineWidth()/2).pt(), (mH + lineWidth()/2).pt() );
@@ -998,8 +1020,8 @@ void LabelModelObject::flipVert()
/// Is this object located at x,y?
///
bool LabelModelObject::isLocatedAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const
const Distance& x,
const Distance& y ) const
{
QPointF p( x.pt(), y.pt() );
@@ -1029,8 +1051,8 @@ bool LabelModelObject::isLocatedAt( double scale,
/// Is one of this object's handles locate at x,y? If so, return it.
///
Handle* LabelModelObject::handleAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const
const Distance& x,
const Distance& y ) const
{
if ( mSelectedFlag )
{
@@ -1104,4 +1126,7 @@ void LabelModelObject::drawSelectionHighlight( QPainter* painter, double scale )
///
void LabelModelObject::sizeUpdated()
{
// empty
}
}
+33 -28
View File
@@ -37,6 +37,9 @@
#include "Merge/Record.h"
namespace glabels
{
// Forward References
class Region;
class Size;
@@ -93,29 +96,29 @@ public:
//
// x0 Property ( x coordinate of origin )
//
glabels::Distance x0() const;
void setX0( const glabels::Distance& value );
Distance x0() const;
void setX0( const Distance& value );
//
// y0 Property ( y coordinate of origin )
//
glabels::Distance y0() const;
void setY0( const glabels::Distance& value );
Distance y0() const;
void setY0( const Distance& value );
//
// w Property ( width of bounding box )
//
glabels::Distance w() const;
void setW( const glabels::Distance& value );
Distance w() const;
void setW( const Distance& value );
//
// h Property ( height of bounding box )
//
glabels::Distance h() const;
void setH( const glabels::Distance& value );
Distance h() const;
void setH( const Distance& value );
//
@@ -135,15 +138,15 @@ public:
//
// Shadow x Offset Property
//
glabels::Distance shadowX() const;
void setShadowX( const glabels::Distance& value );
Distance shadowX() const;
void setShadowX( const Distance& value );
//
// Shadow y Offset Property
//
glabels::Distance shadowY() const;
void setShadowY( const glabels::Distance& value );
Distance shadowY() const;
void setShadowY( const Distance& value );
//
@@ -257,8 +260,8 @@ public:
//
// Virtual Shape Property: lineWidth
//
virtual glabels::Distance lineWidth() const;
virtual void setLineWidth( const glabels::Distance& value );
virtual Distance lineWidth() const;
virtual void setLineWidth( const Distance& value );
//
@@ -335,20 +338,20 @@ public:
// Position and Size methods
///////////////////////////////////////////////////////////////
public:
void setPosition( const glabels::Distance& x0, const glabels::Distance& y0 );
void setPositionRelative( const glabels::Distance& dx, const glabels::Distance& dy );
void setPosition( const Distance& x0, const Distance& y0 );
void setPositionRelative( const Distance& dx, const Distance& dy );
Size size() const;
void setSize( const glabels::Distance& w, const glabels::Distance& h );
void setSize( const Distance& w, const Distance& h );
void setSize( const Size& size );
void setSizeHonorAspect( const glabels::Distance& w, const glabels::Distance& h );
void setWHonorAspect( const glabels::Distance& w );
void setHHonorAspect( const glabels::Distance& h );
void setSizeHonorAspect( const Distance& w, const Distance& h );
void setWHonorAspect( const Distance& w );
void setHHonorAspect( const Distance& h );
Region getExtent();
void rotate( double thetaDegs );
void flipHoriz();
void flipVert();
bool isLocatedAt( double scale, const glabels::Distance& x, const glabels::Distance& y ) const;
Handle* handleAt( double scale, const glabels::Distance& x, const glabels::Distance& y ) const;
bool isLocatedAt( double scale, const Distance& x, const Distance& y ) const;
Handle* handleAt( double scale, const Distance& x, const Distance& y ) const;
///////////////////////////////////////////////////////////////
@@ -372,14 +375,14 @@ protected:
protected:
bool mSelectedFlag;
glabels::Distance mX0;
glabels::Distance mY0;
glabels::Distance mW;
glabels::Distance mH;
Distance mX0;
Distance mY0;
Distance mW;
Distance mH;
bool mShadowState;
glabels::Distance mShadowX;
glabels::Distance mShadowY;
Distance mShadowX;
Distance mShadowY;
double mShadowOpacity;
ColorNode mShadowColorNode;
@@ -398,5 +401,7 @@ private:
};
}
#endif // LabelModelObject_h
+7 -2
View File
@@ -25,6 +25,9 @@
#include <QPen>
namespace glabels
{
///
/// Constructor
///
@@ -76,7 +79,7 @@ LabelModelShapeObject::~LabelModelShapeObject()
///
/// Line Width Property Getter
///
glabels::Distance LabelModelShapeObject::lineWidth( void ) const
Distance LabelModelShapeObject::lineWidth( void ) const
{
return mLineWidth;
}
@@ -85,7 +88,7 @@ glabels::Distance LabelModelShapeObject::lineWidth( void ) const
///
/// Line Width Property Setter
///
void LabelModelShapeObject::setLineWidth( const glabels::Distance& value )
void LabelModelShapeObject::setLineWidth( const Distance& value )
{
if ( mLineWidth != value )
{
@@ -164,3 +167,5 @@ bool LabelModelShapeObject::canLineWidth()
{
return true;
}
}
+8 -3
View File
@@ -25,6 +25,9 @@
#include "LabelModelObject.h"
namespace glabels
{
///
/// Label Model Shape Object (Box or Ellipse)
///
@@ -49,8 +52,8 @@ public:
//
// Shape Property: lineWidth
//
virtual glabels::Distance lineWidth( void ) const;
virtual void setLineWidth( const glabels::Distance& value );
virtual Distance lineWidth( void ) const;
virtual void setLineWidth( const Distance& value );
//
@@ -80,11 +83,13 @@ public:
// Private Members
///////////////////////////////////////////////////////////////
protected:
glabels::Distance mLineWidth;
Distance mLineWidth;
ColorNode mLineColorNode;
ColorNode mFillColorNode;
};
}
#endif // LabelModelShapeObject_h
+20 -5
View File
@@ -29,6 +29,12 @@
#include <QtDebug>
namespace glabels
{
//
// Private
//
namespace
{
const double marginPts = 3;
@@ -67,7 +73,8 @@ LabelModelTextObject::LabelModelTextObject()
///
/// Copy constructor
///
LabelModelTextObject::LabelModelTextObject( const LabelModelTextObject* object ) : LabelModelObject(object)
LabelModelTextObject::LabelModelTextObject( const LabelModelTextObject* object )
: LabelModelObject(object)
{
mText = object->mText;
mFontFamily = object->mFontFamily;
@@ -337,7 +344,7 @@ void LabelModelTextObject::setTextLineSpacing( double value )
///
// Can Text Capability Implementation
/// Can Text Capability Implementation
///
bool LabelModelTextObject::canText()
{
@@ -348,7 +355,9 @@ bool LabelModelTextObject::canText()
///
/// Draw shadow of object
///
void LabelModelTextObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
void LabelModelTextObject::drawShadow( QPainter* painter,
bool inEditor,
merge::Record* record ) const
{
QColor textColor = mTextColorNode.color( record );
@@ -372,7 +381,9 @@ void LabelModelTextObject::drawShadow( QPainter* painter, bool inEditor, merge::
///
/// Draw object itself
///
void LabelModelTextObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
void LabelModelTextObject::drawObject( QPainter* painter,
bool inEditor,
merge::Record* record ) const
{
QColor textColor = mTextColorNode.color( record );
@@ -516,7 +527,9 @@ void LabelModelTextObject::drawTextInEditor( QPainter* painter, const QColor& co
/// Draw text in final printout or preview
///
void
LabelModelTextObject::drawText( QPainter* painter, const QColor&color, merge::Record* record ) const
LabelModelTextObject::drawText( QPainter* painter,
const QColor& color,
merge::Record* record ) const
{
QFont font;
font.setFamily( mFontFamily );
@@ -626,3 +639,5 @@ QString LabelModelTextObject::expandText( QString text, merge::Record* record )
return text;
}
}
+5
View File
@@ -27,6 +27,9 @@
#include "LabelModelObject.h"
namespace glabels
{
///
/// Label Model Line Object
///
@@ -170,5 +173,7 @@ private:
};
}
#endif // LabelModelTextObject_h
+7 -5
View File
@@ -23,7 +23,7 @@
#include <cmath>
#include "privateConstants.h"
#include "Constants.h"
namespace glabels
@@ -37,6 +37,7 @@ namespace glabels
const Distance& dy )
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
{
// empty
}
@@ -44,6 +45,7 @@ namespace glabels
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0),
mDx(other.mDx), mDy(other.mDy)
{
// empty
}
@@ -87,10 +89,10 @@ namespace glabels
{
return ( (mNx == other->mNx) &&
(mNy == other->mNy) &&
(fabs(mX0 - other->mX0) < Constants::EPSILON) &&
(fabs(mY0 - other->mY0) < Constants::EPSILON) &&
(fabs(mDx - other->mDx) < Constants::EPSILON) &&
(fabs(mDy - other->mDy) < Constants::EPSILON) );
(fabs(mX0 - other->mX0) < EPSILON) &&
(fabs(mY0 - other->mY0) < EPSILON) &&
(fabs(mDx - other->mDx) < EPSILON) &&
(fabs(mDy - other->mDy) < EPSILON) );
}
+21 -14
View File
@@ -52,6 +52,9 @@
#include "UndoRedoModel.h"
namespace glabels
{
///
/// Constructor
///
@@ -149,6 +152,7 @@ MainWindow::MainWindow()
///
MainWindow::~MainWindow()
{
// empty
}
@@ -226,25 +230,25 @@ void MainWindow::createActions()
{
/* File actions */
fileNewAction = new QAction( tr("&New..."), this );
fileNewAction->setIcon( QIcon::fromTheme( "document-new", Icons::Fallback::FileNew() ) );
fileNewAction->setIcon( QIcon::fromTheme( "document-new", Icons::FileNew() ) );
fileNewAction->setShortcut( QKeySequence::New );
fileNewAction->setStatusTip( tr("Create a new gLabels project") );
connect( fileNewAction, SIGNAL(triggered()), this, SLOT(fileNew()) );
fileOpenAction = new QAction( tr("&Open..."), this );
fileOpenAction->setIcon( QIcon::fromTheme( "document-open", Icons::Fallback::FileOpen() ) );
fileOpenAction->setIcon( QIcon::fromTheme( "document-open", Icons::FileOpen() ) );
fileOpenAction->setShortcut( QKeySequence::Open );
fileOpenAction->setStatusTip( tr("Open an existing gLabels project") );
connect( fileOpenAction, SIGNAL(triggered()), this, SLOT(fileOpen()) );
fileSaveAction = new QAction( tr("&Save"), this );
fileSaveAction->setIcon( QIcon::fromTheme( "document-save", Icons::Fallback::FileSave() ) );
fileSaveAction->setIcon( QIcon::fromTheme( "document-save", Icons::FileSave() ) );
fileSaveAction->setShortcut( QKeySequence::Save );
fileSaveAction->setStatusTip( tr("Save current gLabels project") );
connect( fileSaveAction, SIGNAL(triggered()), this, SLOT(fileSave()) );
fileSaveAsAction = new QAction( tr("Save &As..."), this );
fileSaveAsAction->setIcon( QIcon::fromTheme( "document-save-as", Icons::Fallback::FileSaveAs() ) );
fileSaveAsAction->setIcon( QIcon::fromTheme( "document-save-as", Icons::FileSaveAs() ) );
fileSaveAsAction->setShortcut( QKeySequence::SaveAs );
fileSaveAsAction->setStatusTip( tr("Save current gLabels project to a different name") );
connect( fileSaveAsAction, SIGNAL(triggered()), this, SLOT(fileSaveAs()) );
@@ -280,19 +284,19 @@ void MainWindow::createActions()
connect( editRedoAction, SIGNAL(triggered()), this, SLOT(editRedo()) );
editCutAction = new QAction( tr("Cut"), this );
editCutAction->setIcon( QIcon::fromTheme( "edit-cut", Icons::Fallback::EditCut() ) );
editCutAction->setIcon( QIcon::fromTheme( "edit-cut", Icons::EditCut() ) );
editCutAction->setShortcut( QKeySequence::Cut );
editCutAction->setStatusTip( tr("Cut the selection") );
connect( editCutAction, SIGNAL(triggered()), this, SLOT(editCut()) );
editCopyAction = new QAction( tr("&Copy"), this );
editCopyAction->setIcon( QIcon::fromTheme( "edit-copy", Icons::Fallback::EditCopy() ) );
editCopyAction->setIcon( QIcon::fromTheme( "edit-copy", Icons::EditCopy() ) );
editCopyAction->setShortcut( QKeySequence::Copy );
editCopyAction->setStatusTip( tr("Copy the selection") );
connect( editCopyAction, SIGNAL(triggered()), this, SLOT(editCopy()) );
editPasteAction = new QAction( tr("&Paste"), this );
editPasteAction->setIcon( QIcon::fromTheme( "edit-paste", Icons::Fallback::EditPaste() ) );
editPasteAction->setIcon( QIcon::fromTheme( "edit-paste", Icons::EditPaste() ) );
editPasteAction->setShortcut( QKeySequence::Paste );
editPasteAction->setStatusTip( tr("Paste the clipboard") );
connect( editPasteAction, SIGNAL(triggered()), this, SLOT(editPaste()) );
@@ -344,24 +348,24 @@ void MainWindow::createActions()
connect( viewMarkupAction, SIGNAL(toggled(bool)), this, SLOT(viewMarkup(bool)) );
viewZoomInAction = new QAction( tr("Zoom &In"), this );
viewZoomInAction->setIcon( QIcon::fromTheme( "zoom-in", Icons::Fallback::ZoomIn() ) );
viewZoomInAction->setIcon( QIcon::fromTheme( "zoom-in", Icons::ZoomIn() ) );
viewZoomInAction->setShortcut( QKeySequence::ZoomIn );
viewZoomInAction->setStatusTip( tr("Increase magnification") );
connect( viewZoomInAction, SIGNAL(triggered()), this, SLOT(viewZoomIn()) );
viewZoomOutAction = new QAction( tr("Zoom &Out"), this );
viewZoomOutAction->setIcon( QIcon::fromTheme( "zoom-out", Icons::Fallback::ZoomOut() ) );
viewZoomOutAction->setIcon( QIcon::fromTheme( "zoom-out", Icons::ZoomOut() ) );
viewZoomOutAction->setShortcut( QKeySequence::ZoomOut );
viewZoomOutAction->setStatusTip( tr("Decrease magnification") );
connect( viewZoomOutAction, SIGNAL(triggered()), this, SLOT(viewZoomOut()) );
viewZoom1To1Action = new QAction( tr("Zoom &1 to 1"), this );
viewZoom1To1Action->setIcon( QIcon::fromTheme( "zoom-original", Icons::Fallback::ZoomOriginal() ) );
viewZoom1To1Action->setIcon( QIcon::fromTheme( "zoom-original", Icons::ZoomOriginal() ) );
viewZoom1To1Action->setStatusTip( tr("Restore scale to 100%") );
connect( viewZoom1To1Action, SIGNAL(triggered()), this, SLOT(viewZoom1To1()) );
viewZoomToFitAction = new QAction( tr("Zoom to &Fit"), this );
viewZoomToFitAction->setIcon( QIcon::fromTheme( "zoom-fit-best", Icons::Fallback::ZoomBestFit() ) );
viewZoomToFitAction->setIcon( QIcon::fromTheme( "zoom-fit-best", Icons::ZoomBestFit() ) );
viewZoomToFitAction->setStatusTip( tr("Set scale to fit window") );
connect( viewZoomToFitAction, SIGNAL(triggered()), this, SLOT(viewZoomToFit()) );
@@ -488,17 +492,17 @@ void MainWindow::createActions()
/* Context menu version of edit actions */
contextCutAction = new QAction( tr("Cut"), this );
contextCutAction->setIcon( QIcon::fromTheme( "edit-cut", Icons::Fallback::EditCut() ) );
contextCutAction->setIcon( QIcon::fromTheme( "edit-cut", Icons::EditCut() ) );
contextCutAction->setStatusTip( tr("Cut the selection") );
connect( contextCutAction, SIGNAL(triggered()), this, SLOT(editCut()) );
contextCopyAction = new QAction( tr("&Copy"), this );
contextCopyAction->setIcon( QIcon::fromTheme( "edit-copy", Icons::Fallback::EditCopy() ) );
contextCopyAction->setIcon( QIcon::fromTheme( "edit-copy", Icons::EditCopy() ) );
contextCopyAction->setStatusTip( tr("Copy the selection") );
connect( contextCopyAction, SIGNAL(triggered()), this, SLOT(editCopy()) );
contextPasteAction = new QAction( tr("&Paste"), this );
contextPasteAction->setIcon( QIcon::fromTheme( "edit-paste", Icons::Fallback::EditPaste() ) );
contextPasteAction->setIcon( QIcon::fromTheme( "edit-paste", Icons::EditPaste() ) );
contextPasteAction->setStatusTip( tr("Paste the clipboard") );
connect( contextPasteAction, SIGNAL(triggered()), this, SLOT(editPaste()) );
@@ -1525,6 +1529,7 @@ void MainWindow::onSelectionChanged()
///
void MainWindow::onLabelChanged()
{
// TODO
}
@@ -1536,3 +1541,5 @@ void MainWindow::onUndoRedoChanged()
editUndoAction->setEnabled( mUndoRedoModel->canUndo() );
editRedoAction->setEnabled( mUndoRedoModel->canRedo() );
}
}
+7
View File
@@ -33,6 +33,10 @@
#include <QStackedWidget>
#include <QToolBar>
namespace glabels
{
// Forward References
class LabelEditor;
class LabelModel;
@@ -286,4 +290,7 @@ private:
};
}
#endif // MainWindow_h
+7 -4
View File
@@ -31,15 +31,17 @@
#include "TextSemicolonKeys.h"
namespace glabels
{
namespace merge
{
///
/// Static data
///
//
// Static data
//
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
QStringList Factory::mNameList;
@@ -219,3 +221,4 @@ namespace merge
}
}
+9 -1
View File
@@ -26,9 +26,14 @@
#include <QMap>
namespace glabels
{
namespace merge
{
class Merge; // Forward reference
// Forward references
class Merge;
///
@@ -100,4 +105,7 @@ namespace merge
}
}
#endif // merge_Factory_h
+5
View File
@@ -23,6 +23,9 @@
#include "Record.h"
namespace glabels
{
namespace merge
{
@@ -208,3 +211,5 @@ namespace merge
}
}
}
+9 -1
View File
@@ -27,9 +27,14 @@
#include <QList>
namespace glabels
{
namespace merge
{
class Record; // Forward reference
// Forward references
class Record;
///
@@ -113,4 +118,7 @@ namespace merge
}
}
#endif // merge_Merge_h
+5
View File
@@ -21,6 +21,9 @@
#include "None.h"
namespace glabels
{
namespace merge
{
@@ -120,3 +123,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Merge.h"
namespace glabels
{
namespace merge
{
@@ -71,4 +74,7 @@ namespace merge
}
}
#endif // merge_None_h
+5
View File
@@ -21,6 +21,9 @@
#include "Record.h"
namespace glabels
{
namespace merge
{
@@ -68,3 +71,5 @@ namespace merge
}
}
}
+6
View File
@@ -25,6 +25,9 @@
#include <QMap>
namespace glabels
{
namespace merge
{
@@ -66,4 +69,7 @@ namespace merge
}
}
#endif // merge_Record_h
+5
View File
@@ -24,6 +24,9 @@
#include <QtDebug>
namespace glabels
{
namespace merge
{
@@ -413,3 +416,5 @@ namespace merge
}
}
}
+6
View File
@@ -26,6 +26,9 @@
#include <QFile>
namespace glabels
{
namespace merge
{
@@ -77,4 +80,7 @@ namespace merge
}
}
#endif // merge_Text_h
+5
View File
@@ -21,6 +21,9 @@
#include "TextColon.h"
namespace glabels
{
namespace merge
{
static const QString ID = "Text/Colon";
@@ -78,3 +81,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Text.h"
namespace glabels
{
namespace merge
{
@@ -60,4 +63,7 @@ namespace merge
}
}
#endif // merge_TextColon_h
+5
View File
@@ -21,6 +21,9 @@
#include "TextColonKeys.h"
namespace glabels
{
namespace merge
{
static const QString ID = "Text/Colon/Line1Keys";
@@ -78,3 +81,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Text.h"
namespace glabels
{
namespace merge
{
@@ -60,4 +63,7 @@ namespace merge
}
}
#endif // merge_TextColonKeys_h
+5
View File
@@ -21,6 +21,9 @@
#include "TextCsv.h"
namespace glabels
{
namespace merge
{
static const QString ID = "Text/Comma";
@@ -78,3 +81,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Text.h"
namespace glabels
{
namespace merge
{
@@ -60,4 +63,7 @@ namespace merge
}
}
#endif // merge_TextCsv_h
+5
View File
@@ -21,6 +21,9 @@
#include "TextCsvKeys.h"
namespace glabels
{
namespace merge
{
static const QString ID = "Text/Comma/Line1Keys";
@@ -78,3 +81,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Text.h"
namespace glabels
{
namespace merge
{
@@ -60,4 +63,7 @@ namespace merge
}
}
#endif // merge_TextCsvKeys_h
+5
View File
@@ -21,6 +21,9 @@
#include "TextSemicolon.h"
namespace glabels
{
namespace merge
{
static const QString ID = "Text/Semicolon";
@@ -78,3 +81,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Text.h"
namespace glabels
{
namespace merge
{
@@ -60,4 +63,7 @@ namespace merge
}
}
#endif // merge_TextSemicolon_h
+5
View File
@@ -21,6 +21,9 @@
#include "TextSemicolonKeys.h"
namespace glabels
{
namespace merge
{
static const QString ID = "Text/Semicolon/Keys";
@@ -78,3 +81,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Text.h"
namespace glabels
{
namespace merge
{
@@ -60,4 +63,7 @@ namespace merge
}
}
#endif // merge_TextSemicolonKeys_h
+5
View File
@@ -21,6 +21,9 @@
#include "TextTsv.h"
namespace glabels
{
namespace merge
{
static const QString ID = "Text/Tab";
@@ -78,3 +81,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Text.h"
namespace glabels
{
namespace merge
{
@@ -60,4 +63,7 @@ namespace merge
}
}
#endif // merge_TextTsv_h
+5
View File
@@ -21,6 +21,9 @@
#include "TextTsvKeys.h"
namespace glabels
{
namespace merge
{
static const QString ID = "Text/Tab/Line1Keys";
@@ -78,3 +81,5 @@ namespace merge
}
}
}
+6
View File
@@ -24,6 +24,9 @@
#include "Text.h"
namespace glabels
{
namespace merge
{
@@ -60,4 +63,7 @@ namespace merge
}
}
#endif // merge_TextTsvKeys_h
+19 -6
View File
@@ -30,6 +30,9 @@
#include "Merge/Factory.h"
namespace glabels
{
///
/// Constructor
///
@@ -48,6 +51,7 @@ MergeView::MergeView( QWidget *parent )
///
MergeView::~MergeView()
{
// empty
}
@@ -79,7 +83,8 @@ void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
///
void MergeView::onMergeChanged()
{
int index = mMergeFormatNames.indexOf( merge::Factory::idToName( mModel->merge()->id() ) );
QString name = merge::Factory::idToName( mModel->merge()->id() );
int index = mMergeFormatNames.indexOf( name );
mOldFormatComboIndex = index;
formatCombo->setCurrentIndex( index );
@@ -115,10 +120,14 @@ void MergeView::onMergeChanged()
loadHeaders( mModel->merge() );
loadTable( mModel->merge() );
connect( mModel->merge(), SIGNAL(sourceChanged()), this, SLOT(onMergeSourceChanged()) );
connect( mModel->merge(), SIGNAL(selectionChanged()), this, SLOT(onMergeSelectionChanged()) );
connect( mModel->merge(), SIGNAL(sourceChanged()),
this, SLOT(onMergeSourceChanged()) );
connect( recordsTable, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)) );
connect( mModel->merge(), SIGNAL(selectionChanged()),
this, SLOT(onMergeSelectionChanged()) );
connect( recordsTable, SIGNAL(cellChanged(int,int)),
this, SLOT(onCellChanged(int,int)) );
}
@@ -160,6 +169,7 @@ void MergeView::onMergeSelectionChanged()
///
/// Format combo changed handler
///
void MergeView::onFormatComboActivated()
{
int index = formatCombo->currentIndex();
@@ -167,7 +177,8 @@ void MergeView::onFormatComboActivated()
{
mOldFormatComboIndex = index;
mModel->setMerge( merge::Factory::createMerge( merge::Factory::indexToId(index) ) );
QString id = merge::Factory::indexToId(index);
mModel->setMerge( merge::Factory::createMerge( id ) );
}
}
@@ -288,7 +299,7 @@ void MergeView::loadTable( merge::Merge* merge )
recordsTable->setItem( iRow, 0, item );
recordsTable->resizeColumnToContents( 0 );
// Starting on second column, one column per field (even if empty), skip primary field
// Starting on 2nd column, 1 column per field, skip primary field
int iCol = 1;
foreach ( QString key, mKeys )
{
@@ -316,3 +327,5 @@ void MergeView::loadTable( merge::Merge* merge )
mBlock = false;
}
}
+6
View File
@@ -26,6 +26,10 @@
#include "Merge/Merge.h"
namespace glabels
{
// Forward references
class LabelModel;
class UndoRedoModel;
@@ -95,5 +99,7 @@ private:
};
}
#endif // MergeView_h

Some files were not shown because too many files have changed in this diff Show More