Some style cleanup to libglabels.
This commit is contained in:
@@ -19,3 +19,16 @@
|
||||
*/
|
||||
|
||||
#include "Category.h"
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Category::Category( const QString &id, const QString &name )
|
||||
: mId(id), mName(name)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+11
-6
@@ -30,19 +30,24 @@ namespace libglabels
|
||||
|
||||
class Category
|
||||
{
|
||||
public:
|
||||
Category( const QString &id, const QString &name ) : mId(id), mName(name)
|
||||
{
|
||||
}
|
||||
|
||||
inline const QString &id() const { return mId; }
|
||||
inline const QString &name() const { return mName; }
|
||||
public:
|
||||
Category( const QString& id, const QString& name );
|
||||
|
||||
const QString& id() const;
|
||||
const QString& name() const;
|
||||
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
QString mName;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Category.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Category_h
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/* Category.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline const QString& Category::id() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
|
||||
inline const QString& Category::name() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,6 +67,19 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
void Db::init()
|
||||
{
|
||||
instance();
|
||||
}
|
||||
|
||||
|
||||
Db* Db::instance()
|
||||
{
|
||||
static Db* db = new Db();
|
||||
return db;
|
||||
}
|
||||
|
||||
|
||||
void Db::registerPaper( Paper *paper )
|
||||
{
|
||||
if ( !isPaperIdKnown( paper->id() ) )
|
||||
|
||||
+19
-13
@@ -44,22 +44,22 @@ namespace libglabels
|
||||
Db();
|
||||
|
||||
public:
|
||||
static void init() { instance(); }
|
||||
static Db *instance() { static Db *db = new Db(); return db; }
|
||||
static void init();
|
||||
static Db* instance();
|
||||
|
||||
|
||||
static const QList<Paper*> &papers() { return mPapers; }
|
||||
static const QStringList &paperIds() { return mPaperIds; }
|
||||
static const QStringList &paperNames() { return mPaperNames; }
|
||||
static const QList<Paper*>& papers();
|
||||
static const QStringList& paperIds();
|
||||
static const QStringList& paperNames();
|
||||
|
||||
static const QList<Category*> &categories() { return mCategories; }
|
||||
static const QStringList &categoryIds() { return mCategoryIds; }
|
||||
static const QStringList &categoryNames() { return mCategoryNames; }
|
||||
static const QList<Category*>& categories();
|
||||
static const QStringList& categoryIds();
|
||||
static const QStringList& categoryNames();
|
||||
|
||||
static const QList<Vendor*> &vendors() { return mVendors; }
|
||||
static const QStringList &vendorNames() { return mVendorNames; }
|
||||
static const QList<Vendor*>& vendors();
|
||||
static const QStringList& vendorNames();
|
||||
|
||||
static const QList<Template*> &templates() { return mTemplates; }
|
||||
static const QList<Template*>& templates();
|
||||
|
||||
|
||||
static void registerPaper( Paper *paper );
|
||||
@@ -84,13 +84,15 @@ namespace libglabels
|
||||
|
||||
static void registerTemplate( Template *tmplate );
|
||||
static const Template *lookupTemplateFromName( const QString &name );
|
||||
static const Template *lookupTemplateFromBrandPart( const QString &brand, const QString &part );
|
||||
static const Template *lookupTemplateFromBrandPart( const QString &brand,
|
||||
const QString &part );
|
||||
static bool isTemplateKnown( const QString &brand, const QString &part );
|
||||
static QStringList getNameListOfSimilarTemplates( const QString &name );
|
||||
|
||||
static void registerUserTemplate( Template *tmplate );
|
||||
static void deleteUserTemplateByName( const QString &name );
|
||||
static void deleteUserTemplateByBrandPart( const QString &brand, const QString &part );
|
||||
static void deleteUserTemplateByBrandPart( const QString &brand,
|
||||
const QString &part );
|
||||
|
||||
static void printKnownPapers();
|
||||
static void printKnownCategories();
|
||||
@@ -134,4 +136,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Db.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Db_h
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/* Db.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline const QList<Paper*>& Db::papers()
|
||||
{
|
||||
return mPapers;
|
||||
}
|
||||
|
||||
|
||||
inline const QStringList& Db::paperIds()
|
||||
{
|
||||
return mPaperIds;
|
||||
}
|
||||
|
||||
|
||||
inline const QStringList& Db::paperNames()
|
||||
{
|
||||
return mPaperNames;
|
||||
}
|
||||
|
||||
|
||||
inline const QList<Category*>& Db::categories()
|
||||
{
|
||||
return mCategories;
|
||||
}
|
||||
|
||||
|
||||
inline const QStringList& Db::categoryIds()
|
||||
{
|
||||
return mCategoryIds;
|
||||
}
|
||||
|
||||
|
||||
inline const QStringList& Db::categoryNames()
|
||||
{
|
||||
return mCategoryNames;
|
||||
}
|
||||
|
||||
|
||||
inline const QList<Vendor*>& Db::vendors()
|
||||
{
|
||||
return mVendors;
|
||||
}
|
||||
|
||||
|
||||
inline const QStringList& Db::vendorNames()
|
||||
{
|
||||
return mVendorNames;
|
||||
}
|
||||
|
||||
inline const QList<Template*>& Db::templates()
|
||||
{
|
||||
return mTemplates;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,13 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Frame::Frame( const Frame &other )
|
||||
Frame::Frame( const QString& id )
|
||||
: mId(id), mNLabels(0), mLayoutDescription("")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Frame::Frame( const Frame& other )
|
||||
{
|
||||
mId = other.mId;
|
||||
mNLabels = 0;
|
||||
|
||||
+18
-16
@@ -43,34 +43,32 @@ namespace libglabels
|
||||
Q_DECLARE_TR_FUNCTIONS(Frame)
|
||||
|
||||
protected:
|
||||
Frame( const QString &id = "0" ) : mId(id), mNLabels(0), mLayoutDescription("")
|
||||
{
|
||||
}
|
||||
|
||||
Frame( const Frame &other );
|
||||
Frame( const QString& id = "0" );
|
||||
Frame( const Frame& other );
|
||||
|
||||
public:
|
||||
virtual Frame *dup() const = 0;
|
||||
virtual Frame* dup() const = 0;
|
||||
|
||||
inline const QString &id() const { return mId; }
|
||||
inline int nLabels() const { return mNLabels; }
|
||||
inline const QString &layoutDescription() const { return mLayoutDescription; }
|
||||
inline const QList<Layout*> &layouts() const { return mLayouts; }
|
||||
inline const QList<Markup*> &markups() const { return mMarkups; }
|
||||
const QString& id() const;
|
||||
int nLabels() const;
|
||||
const QString& layoutDescription() const;
|
||||
const QList<Layout*>& layouts() const;
|
||||
const QList<Markup*>& markups() const;
|
||||
|
||||
QVector<Point> getOrigins() const;
|
||||
|
||||
void addLayout( Layout *layout );
|
||||
void addMarkup( Markup *markup );
|
||||
void addLayout( Layout* layout );
|
||||
void addMarkup( Markup* markup );
|
||||
|
||||
virtual double w() const = 0;
|
||||
virtual double h() const = 0;
|
||||
|
||||
virtual const QString sizeDescription( const Units *units ) const = 0;
|
||||
virtual bool isSimilarTo( Frame *other ) const = 0;
|
||||
virtual const QString sizeDescription( const Units* units ) const = 0;
|
||||
virtual bool isSimilarTo( Frame* other ) const = 0;
|
||||
|
||||
virtual const QPainterPath &path( bool isRotated = false ) const = 0;
|
||||
virtual QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const = 0;
|
||||
virtual QGraphicsItem* createMarginGraphicsItem( double size,
|
||||
const QPen& pen ) const = 0;
|
||||
|
||||
|
||||
private:
|
||||
@@ -84,4 +82,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Frame.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Frame_h
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/* Frame.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline const QString& Frame::id() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
|
||||
inline int Frame::nLabels() const
|
||||
{
|
||||
return mNLabels;
|
||||
}
|
||||
|
||||
|
||||
inline const QString& Frame::layoutDescription() const
|
||||
{
|
||||
return mLayoutDescription;
|
||||
}
|
||||
|
||||
|
||||
inline const QList<Layout*>& Frame::layouts() const
|
||||
{
|
||||
return mLayouts;
|
||||
}
|
||||
|
||||
|
||||
inline const QList<Markup*>& Frame::markups() const
|
||||
{
|
||||
return mMarkups;
|
||||
}
|
||||
|
||||
}
|
||||
+77
-45
@@ -29,6 +29,80 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
FrameCd::FrameCd( double r1, double r2, double w, double h, double waste, QString id )
|
||||
: mR1(r1), mR2(r2), mW(w), mH(h), mWaste(waste), Frame(id)
|
||||
{
|
||||
//
|
||||
// First, initialize the un-rotated path
|
||||
//
|
||||
{
|
||||
// Outer path (may be clipped in the case business card type CD)
|
||||
double theta1 = acos( w / (2*mR1) ) * 180/M_PI;
|
||||
double theta2 = asin( h / (2*mR1) ) * 180/M_PI;
|
||||
|
||||
mPath.arcMoveTo( 0, 0, 2*mR1, 2*mR1, theta1 );
|
||||
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, theta1, theta2-theta1 );
|
||||
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180-theta2, theta2-theta1 );
|
||||
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180+theta1, theta2-theta1 );
|
||||
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 360-theta2, theta2-theta1 );
|
||||
mPath.closeSubpath();
|
||||
|
||||
// Inner path (hole)
|
||||
mPath.addEllipse( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
|
||||
|
||||
// Translate to account for offset with clipped business card CDs
|
||||
mPath.translate( w/2 - mR1, h/2 - mR1 );
|
||||
}
|
||||
|
||||
//
|
||||
// Next, initialize the rotated path
|
||||
//
|
||||
{
|
||||
// Outer path (may be clipped in the case business card type CD)
|
||||
double theta1 = acos( h / (2*mR1) ) * 180/M_PI;
|
||||
double theta2 = asin( w / (2*mR1) ) * 180/M_PI;
|
||||
|
||||
mRotatedPath.arcMoveTo( 0, 0, 2*mR1, 2*mR1, theta1 );
|
||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, theta1, theta2-theta1 );
|
||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180-theta2, theta2-theta1 );
|
||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180+theta1, theta2-theta1 );
|
||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 360-theta2, theta2-theta1 );
|
||||
mRotatedPath.closeSubpath();
|
||||
|
||||
// Inner path (hole)
|
||||
mRotatedPath.addEllipse( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
|
||||
|
||||
// Translate to account for offset with clipped business card CDs
|
||||
mRotatedPath.translate( h/2 - mR1, w/2 - mR1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FrameCd::FrameCd( const FrameCd& other )
|
||||
: mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
||||
mPath(other.mPath), Frame(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Frame* FrameCd::dup() const
|
||||
{
|
||||
return new FrameCd( *this );
|
||||
}
|
||||
|
||||
|
||||
double FrameCd::w() const
|
||||
{
|
||||
return (mW == 0) ? 2*mR1 : mW;
|
||||
}
|
||||
|
||||
|
||||
double FrameCd::h() const
|
||||
{
|
||||
return (mH == 0) ? 2*mR1 : mH;
|
||||
}
|
||||
|
||||
|
||||
const QString FrameCd::sizeDescription( const Units *units ) const
|
||||
{
|
||||
if ( units->id() == "in" )
|
||||
@@ -66,53 +140,11 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
void FrameCd::initPath()
|
||||
const QPainterPath& FrameCd::path( bool isRotated ) const
|
||||
{
|
||||
//
|
||||
// First the un-rotated path
|
||||
//
|
||||
{
|
||||
// Outer path (may be clipped in the case business card type CD)
|
||||
double theta1 = acos( w() / (2*mR1) ) * 180/M_PI;
|
||||
double theta2 = asin( h() / (2*mR1) ) * 180/M_PI;
|
||||
|
||||
mPath.arcMoveTo( 0, 0, 2*mR1, 2*mR1, theta1 );
|
||||
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, theta1, theta2-theta1 );
|
||||
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180-theta2, theta2-theta1 );
|
||||
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180+theta1, theta2-theta1 );
|
||||
mPath.arcTo( 0, 0, 2*mR1, 2*mR1, 360-theta2, theta2-theta1 );
|
||||
mPath.closeSubpath();
|
||||
|
||||
// Inner path (hole)
|
||||
mPath.addEllipse( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
|
||||
|
||||
// Translate to account for offset with clipped business card CDs
|
||||
mPath.translate( w()/2 - mR1, h()/2 - mR1 );
|
||||
}
|
||||
|
||||
//
|
||||
// Next, the rotated path
|
||||
//
|
||||
{
|
||||
// Outer path (may be clipped in the case business card type CD)
|
||||
double theta1 = acos( h() / (2*mR1) ) * 180/M_PI;
|
||||
double theta2 = asin( w() / (2*mR1) ) * 180/M_PI;
|
||||
|
||||
mRotatedPath.arcMoveTo( 0, 0, 2*mR1, 2*mR1, theta1 );
|
||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, theta1, theta2-theta1 );
|
||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180-theta2, theta2-theta1 );
|
||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 180+theta1, theta2-theta1 );
|
||||
mRotatedPath.arcTo( 0, 0, 2*mR1, 2*mR1, 360-theta2, theta2-theta1 );
|
||||
mRotatedPath.closeSubpath();
|
||||
|
||||
// Inner path (hole)
|
||||
mRotatedPath.addEllipse( mR1-mR2, mR1-mR2, 2*mR2, 2*mR2 );
|
||||
|
||||
// Translate to account for offset with clipped business card CDs
|
||||
mRotatedPath.translate( h()/2 - mR1, w()/2 - mR1 );
|
||||
}
|
||||
return isRotated ? mRotatedPath : mPath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QGraphicsItem* FrameCd::createMarginGraphicsItem( double size, const QPen& pen ) const
|
||||
{
|
||||
|
||||
+13
-24
@@ -30,42 +30,27 @@ namespace libglabels
|
||||
class FrameCd : public Frame
|
||||
{
|
||||
public:
|
||||
FrameCd( double r1,
|
||||
double r2,
|
||||
double w,
|
||||
double h,
|
||||
double waste,
|
||||
QString id = "0" )
|
||||
: mR1(r1), mR2(r2), mW(w), mH(h), mWaste(waste), Frame(id)
|
||||
{
|
||||
initPath();
|
||||
}
|
||||
FrameCd( double r1, double r2, double w, double h, double waste, QString id = "0" );
|
||||
|
||||
FrameCd( const FrameCd &other )
|
||||
: mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
||||
mPath(other.mPath), Frame(other)
|
||||
{
|
||||
}
|
||||
FrameCd( const FrameCd &other );
|
||||
|
||||
Frame *dup() const { return new FrameCd( *this ); }
|
||||
Frame *dup() const;
|
||||
|
||||
inline double r1() const { return mR1; }
|
||||
inline double r2() const { return mR2; }
|
||||
inline double waste() const { return mWaste; }
|
||||
double r1() const;
|
||||
double r2() const;
|
||||
double waste() const;
|
||||
|
||||
double w() const { return (mW == 0) ? 2*mR1 : mW; }
|
||||
double h() const { return (mH == 0) ? 2*mR1 : mH; }
|
||||
double w() const;
|
||||
double h() const;
|
||||
|
||||
const QString sizeDescription( const Units *units ) const;
|
||||
bool isSimilarTo( Frame *other ) const;
|
||||
|
||||
const QPainterPath &path( bool isRotated ) const { return isRotated ? mRotatedPath : mPath; }
|
||||
const QPainterPath &path( bool isRotated ) const;
|
||||
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
||||
|
||||
|
||||
private:
|
||||
void initPath();
|
||||
|
||||
double mR1;
|
||||
double mR2;
|
||||
double mW;
|
||||
@@ -79,4 +64,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "FrameCd.inl"
|
||||
|
||||
|
||||
#endif // libglabels_FrameCd_h
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/* FrameCd.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline double FrameCd::r1() const
|
||||
{
|
||||
return mR1;
|
||||
}
|
||||
|
||||
|
||||
inline double FrameCd::r2() const
|
||||
{
|
||||
return mR2;
|
||||
}
|
||||
|
||||
|
||||
inline double FrameCd::waste() const
|
||||
{
|
||||
return mWaste;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,37 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
FrameEllipse::FrameEllipse( double w, double h, double waste, QString id )
|
||||
: mW(w), mH(h), mWaste(waste), Frame(id)
|
||||
{
|
||||
mPath.addEllipse( 0, 0, mW, mH );
|
||||
mRotatedPath.addEllipse( 0, 0, mH, mW );
|
||||
}
|
||||
|
||||
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
||||
: mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Frame* FrameEllipse::dup() const
|
||||
{
|
||||
return new FrameEllipse( *this );
|
||||
}
|
||||
|
||||
|
||||
double FrameEllipse::w() const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
|
||||
double FrameEllipse::h() const
|
||||
{
|
||||
return mH;
|
||||
}
|
||||
|
||||
|
||||
const QString FrameEllipse::sizeDescription( const Units *units ) const
|
||||
{
|
||||
if ( units->id() == "in" )
|
||||
@@ -51,9 +82,9 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
bool FrameEllipse::isSimilarTo( Frame *other ) const
|
||||
bool FrameEllipse::isSimilarTo( Frame* other ) const
|
||||
{
|
||||
if ( FrameEllipse *otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
||||
if ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
||||
{
|
||||
if ( (fabs( mW - otherEllipse->mW ) <= Constants::EPSILON) &&
|
||||
(fabs( mH - otherEllipse->mH ) <= Constants::EPSILON) )
|
||||
@@ -65,6 +96,12 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
const QPainterPath& FrameEllipse::path( bool isRotated ) const
|
||||
{
|
||||
return isRotated ? mRotatedPath : mPath;
|
||||
}
|
||||
|
||||
|
||||
QGraphicsItem* FrameEllipse::createMarginGraphicsItem( double size, const QPen& pen ) const
|
||||
{
|
||||
double w = mW - 2*size;
|
||||
|
||||
+14
-20
@@ -29,33 +29,23 @@ namespace libglabels
|
||||
|
||||
class FrameEllipse : public Frame
|
||||
{
|
||||
|
||||
public:
|
||||
FrameEllipse( double w,
|
||||
double h,
|
||||
double waste,
|
||||
QString id = "0" )
|
||||
: mW(w), mH(h), mWaste(waste), Frame(id)
|
||||
{
|
||||
mPath.addEllipse( 0, 0, mW, mH );
|
||||
mRotatedPath.addEllipse( 0, 0, mH, mW );
|
||||
}
|
||||
FrameEllipse( double w, double h, double waste, QString id = "0" );
|
||||
|
||||
FrameEllipse( const FrameEllipse &other )
|
||||
: mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
||||
{
|
||||
}
|
||||
FrameEllipse( const FrameEllipse& other );
|
||||
|
||||
Frame *dup() const { return new FrameEllipse( *this ); }
|
||||
Frame* dup() const;
|
||||
|
||||
inline double waste() const { return mWaste; }
|
||||
double waste() const;
|
||||
|
||||
double w() const { return mW; }
|
||||
double h() const { return mH; }
|
||||
double w() const;
|
||||
double h() const;
|
||||
|
||||
const QString sizeDescription( const Units *units ) const;
|
||||
bool isSimilarTo( Frame *other ) const;
|
||||
const QString sizeDescription( const Units* units ) const;
|
||||
bool isSimilarTo( Frame* other ) const;
|
||||
|
||||
const QPainterPath &path( bool isRotated ) const { return isRotated ? mRotatedPath : mPath; }
|
||||
const QPainterPath& path( bool isRotated ) const;
|
||||
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
||||
|
||||
|
||||
@@ -71,4 +61,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "FrameEllipse.inl"
|
||||
|
||||
|
||||
#endif // libglabels_FrameEllipse_h
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/* FrameEllipse.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline double FrameEllipse::waste() const
|
||||
{
|
||||
return mWaste;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,39 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
FrameRect::FrameRect( double w, double h, double r, double xWaste, double yWaste, QString id )
|
||||
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
||||
{
|
||||
mPath.addRoundedRect( 0, 0, mW, mH, mR, mR );
|
||||
mRotatedPath.addRoundedRect( 0, 0, mH, mW, mR, mR );
|
||||
}
|
||||
|
||||
|
||||
FrameRect::FrameRect( const FrameRect &other )
|
||||
: mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
|
||||
mYWaste(other.mYWaste), mPath(other.mPath), Frame(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Frame* FrameRect::dup() const
|
||||
{
|
||||
return new FrameRect( *this );
|
||||
}
|
||||
|
||||
|
||||
double FrameRect::w() const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
|
||||
double FrameRect::h() const
|
||||
{
|
||||
return mH;
|
||||
}
|
||||
|
||||
|
||||
const QString FrameRect::sizeDescription( const Units *units ) const
|
||||
{
|
||||
if ( units->id() == "in" )
|
||||
@@ -65,6 +98,12 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
const QPainterPath& FrameRect::path( bool isRotated ) const
|
||||
{
|
||||
return isRotated ? mRotatedPath : mPath;
|
||||
}
|
||||
|
||||
|
||||
QGraphicsItem* FrameRect::createMarginGraphicsItem( double size, const QPen& pen ) const
|
||||
{
|
||||
double w = mW - 2*size;
|
||||
@@ -80,5 +119,6 @@ namespace libglabels
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+14
-18
@@ -35,32 +35,24 @@ namespace libglabels
|
||||
double r,
|
||||
double xWaste,
|
||||
double yWaste,
|
||||
QString id = "0" )
|
||||
: mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste), Frame(id)
|
||||
{
|
||||
mPath.addRoundedRect( 0, 0, mW, mH, mR, mR );
|
||||
mRotatedPath.addRoundedRect( 0, 0, mH, mW, mR, mR );
|
||||
}
|
||||
QString id = "0" );
|
||||
|
||||
FrameRect( const FrameRect &other )
|
||||
: mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste), mYWaste(other.mYWaste),
|
||||
mPath(other.mPath), Frame(other)
|
||||
{
|
||||
}
|
||||
FrameRect( const FrameRect& other );
|
||||
|
||||
Frame *dup() const { return new FrameRect( *this ); }
|
||||
Frame* dup() const;
|
||||
|
||||
inline double r() const { return mR; }
|
||||
inline double xWaste() const { return mXWaste; }
|
||||
inline double yWaste() const { return mYWaste; }
|
||||
double r() const;
|
||||
double xWaste() const;
|
||||
double yWaste() const;
|
||||
|
||||
double w() const { return mW; }
|
||||
double h() const { return mH; }
|
||||
double w() const;
|
||||
double h() const;
|
||||
|
||||
const QString sizeDescription( const Units *units ) const;
|
||||
|
||||
bool isSimilarTo( Frame *other ) const;
|
||||
|
||||
const QPainterPath &path( bool isRotated ) const { return isRotated ? mRotatedPath : mPath; }
|
||||
const QPainterPath& path( bool isRotated ) const;
|
||||
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
||||
|
||||
|
||||
@@ -78,4 +70,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "FrameRect.inl"
|
||||
|
||||
|
||||
#endif // libglabels_FrameRect_h
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/* FrameRect.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline double FrameRect::r() const
|
||||
{
|
||||
return mR;
|
||||
}
|
||||
|
||||
|
||||
inline double FrameRect::xWaste() const
|
||||
{
|
||||
return mXWaste;
|
||||
}
|
||||
|
||||
|
||||
inline double FrameRect::yWaste() const
|
||||
{
|
||||
return mYWaste;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,37 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
FrameRound::FrameRound( double r, double waste, QString id )
|
||||
: mR(r), mWaste(waste), Frame(id)
|
||||
{
|
||||
mPath.addEllipse( 0, 0, 2*mR, 2*mR );
|
||||
}
|
||||
|
||||
|
||||
FrameRound::FrameRound( const FrameRound& other )
|
||||
: mR(other.mR), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Frame* FrameRound::dup() const
|
||||
{
|
||||
return new FrameRound( *this );
|
||||
}
|
||||
|
||||
|
||||
double FrameRound::w() const
|
||||
{
|
||||
return 2*mR;
|
||||
}
|
||||
|
||||
|
||||
double FrameRound::h() const
|
||||
{
|
||||
return 2*mR;
|
||||
}
|
||||
|
||||
|
||||
const QString FrameRound::sizeDescription( const Units *units ) const
|
||||
{
|
||||
if ( units->id() == "in" )
|
||||
@@ -63,6 +94,12 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
const QPainterPath& FrameRound::path( bool isRotated ) const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
|
||||
QGraphicsItem* FrameRound::createMarginGraphicsItem( double size, const QPen& pen ) const
|
||||
{
|
||||
double r = mR - size;
|
||||
|
||||
+13
-17
@@ -29,32 +29,24 @@ namespace libglabels
|
||||
|
||||
class FrameRound : public Frame
|
||||
{
|
||||
|
||||
public:
|
||||
FrameRound( double r,
|
||||
double waste,
|
||||
QString id = "0" )
|
||||
: mR(r), mWaste(waste), Frame(id)
|
||||
{
|
||||
mPath.addEllipse( 0, 0, 2*mR, 2*mR );
|
||||
}
|
||||
FrameRound( double r, double waste, QString id = "0" );
|
||||
|
||||
FrameRound( const FrameRound &other )
|
||||
: mR(other.mR), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
||||
{
|
||||
}
|
||||
FrameRound( const FrameRound &other );
|
||||
|
||||
Frame *dup() const { return new FrameRound( *this ); }
|
||||
Frame *dup() const;
|
||||
|
||||
inline double r() const { return mR; }
|
||||
inline double waste() const { return mWaste; }
|
||||
double r() const;
|
||||
double waste() const;
|
||||
|
||||
double w() const { return 2*mR; }
|
||||
double h() const { return 2*mR; }
|
||||
double w() const;
|
||||
double h() const;
|
||||
|
||||
const QString sizeDescription( const Units *units ) const;
|
||||
bool isSimilarTo( Frame *other ) const;
|
||||
|
||||
const QPainterPath &path( bool isRotated ) const { return mPath; }
|
||||
const QPainterPath &path( bool isRotated ) const;
|
||||
QGraphicsItem* createMarginGraphicsItem( double size, const QPen& pen ) const;
|
||||
|
||||
|
||||
@@ -68,4 +60,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "FrameRound.inl"
|
||||
|
||||
|
||||
#endif // libglabels_FrameRound_h
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* FrameRound.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline double FrameRound::r() const
|
||||
{
|
||||
return mR;
|
||||
}
|
||||
|
||||
|
||||
inline double FrameRound::waste() const
|
||||
{
|
||||
return mWaste;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,19 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Layout::Layout( int nx, int ny, double x0, double y0, double dx, double dy )
|
||||
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Layout::Layout( const Layout& other )
|
||||
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0),
|
||||
mDx(other.mDx), mDy(other.mDy)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool Layout::isSimilarTo( const Layout *other )
|
||||
{
|
||||
return ( (mNx == other->mNx) &&
|
||||
@@ -38,4 +51,11 @@ namespace libglabels
|
||||
(fabs(mDy - other->mDy) < Constants::EPSILON) );
|
||||
}
|
||||
|
||||
|
||||
Layout* Layout::dup() const
|
||||
{
|
||||
Layout *other = new Layout( *this );
|
||||
return other;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-19
@@ -27,33 +27,24 @@ namespace libglabels
|
||||
|
||||
class Layout
|
||||
{
|
||||
|
||||
public:
|
||||
Layout( int nx, int ny, double x0, double y0, double dx, double dy )
|
||||
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
||||
{
|
||||
}
|
||||
Layout( int nx, int ny, double x0, double y0, double dx, double dy );
|
||||
|
||||
Layout( const Layout &other )
|
||||
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0), mDx(other.mDx), mDy(other.mDy)
|
||||
{
|
||||
}
|
||||
Layout( const Layout &other );
|
||||
|
||||
inline int nx() const { return mNx; }
|
||||
inline int ny() const { return mNy; }
|
||||
int nx() const;
|
||||
int ny() const;
|
||||
|
||||
inline double x0() const { return mX0; }
|
||||
inline double y0() const { return mY0; }
|
||||
double x0() const;
|
||||
double y0() const;
|
||||
|
||||
inline double dx() const { return mDx; }
|
||||
inline double dy() const { return mDy; }
|
||||
double dx() const;
|
||||
double dy() const;
|
||||
|
||||
bool isSimilarTo( const Layout *other );
|
||||
|
||||
inline Layout *dup() const
|
||||
{
|
||||
Layout *other = new Layout( *this );
|
||||
return other;
|
||||
}
|
||||
Layout* dup() const;
|
||||
|
||||
|
||||
private:
|
||||
@@ -63,8 +54,13 @@ namespace libglabels
|
||||
double mY0;
|
||||
double mDx;
|
||||
double mDy;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Layout.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Layout_h
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* Layout.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline int Layout::nx() const
|
||||
{
|
||||
return mNx;
|
||||
}
|
||||
|
||||
|
||||
inline int Layout::ny() const
|
||||
{
|
||||
return mNy;
|
||||
}
|
||||
|
||||
|
||||
inline double Layout::x0() const
|
||||
{
|
||||
return mX0;
|
||||
}
|
||||
|
||||
|
||||
inline double Layout::y0() const
|
||||
{
|
||||
return mY0;
|
||||
}
|
||||
|
||||
|
||||
inline double Layout::dx() const
|
||||
{
|
||||
return mDx;
|
||||
}
|
||||
|
||||
|
||||
inline double Layout::dy() const
|
||||
{
|
||||
return mDy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,3 +20,111 @@
|
||||
|
||||
#include "Markup.h"
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
MarkupMargin::MarkupMargin( double size )
|
||||
: mSize(size)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Markup* MarkupMargin::dup() const
|
||||
{
|
||||
return new MarkupMargin( mSize );
|
||||
}
|
||||
|
||||
|
||||
QGraphicsItem* MarkupMargin::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
return frame->createMarginGraphicsItem( mSize, pen );
|
||||
}
|
||||
|
||||
|
||||
MarkupLine::MarkupLine( double x1, double y1, double x2, double y2 )
|
||||
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Markup* MarkupLine::dup() const
|
||||
{
|
||||
return new MarkupLine( mX1, mY1, mX2, mY2 );
|
||||
}
|
||||
|
||||
|
||||
QGraphicsItem* MarkupLine::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
QGraphicsLineItem* item = new QGraphicsLineItem( mX1, mY1, mX2, mY2 );
|
||||
item->setPen( pen );
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
MarkupRect::MarkupRect( double x1, double y1, double w, double h, double r )
|
||||
: mX1(x1), mY1(y1), mW(w), mH(h), mR(r)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Markup* MarkupRect::dup() const
|
||||
{
|
||||
return new MarkupRect( mX1, mY1, mW, mH, mR );
|
||||
}
|
||||
|
||||
|
||||
QGraphicsItem* MarkupRect::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addRoundedRect( mX1, mY1, mW, mH, mR, mR );
|
||||
|
||||
QGraphicsPathItem* item = new QGraphicsPathItem( path );
|
||||
item->setPen( pen );
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
MarkupEllipse::MarkupEllipse( double x1, double y1, double w, double h )
|
||||
: mX1(x1), mY1(y1), mW(w), mH(h)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Markup* MarkupEllipse::dup() const
|
||||
{
|
||||
return new MarkupEllipse( mX1, mY1, mW, mH );
|
||||
}
|
||||
|
||||
|
||||
QGraphicsItem* MarkupEllipse::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
QGraphicsEllipseItem* item = new QGraphicsEllipseItem( mX1, mY1, mW, mH );
|
||||
item->setPen( pen );
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
MarkupCircle::MarkupCircle( double x0, double y0, double r )
|
||||
: mX0(x0), mY0(y0), mR(r)
|
||||
{
|
||||
}
|
||||
|
||||
Markup* MarkupCircle::dup() const
|
||||
{
|
||||
return new MarkupCircle( mX0, mY0, mR );
|
||||
}
|
||||
|
||||
|
||||
QGraphicsItem* MarkupCircle::createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
QGraphicsEllipseItem* item = new QGraphicsEllipseItem( mX0-mR, mY0-mR, 2*mR, 2*mR );
|
||||
item->setPen( pen );
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+37
-76
@@ -33,7 +33,7 @@ namespace libglabels
|
||||
class Markup
|
||||
{
|
||||
public:
|
||||
virtual Markup *dup() const = 0;
|
||||
virtual Markup* dup() const = 0;
|
||||
virtual QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const = 0;
|
||||
};
|
||||
|
||||
@@ -41,18 +41,13 @@ namespace libglabels
|
||||
class MarkupMargin : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupMargin( double size ) : mSize(size)
|
||||
{
|
||||
}
|
||||
MarkupMargin( double size );
|
||||
|
||||
inline double size() const { return mSize; }
|
||||
double size() const;
|
||||
|
||||
Markup *dup() const { return new MarkupMargin( mSize ); }
|
||||
Markup* dup() const;
|
||||
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
return frame->createMarginGraphicsItem( mSize, pen );
|
||||
}
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||
|
||||
private:
|
||||
double mSize;
|
||||
@@ -62,24 +57,16 @@ namespace libglabels
|
||||
class MarkupLine : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupLine( double x1, double y1, double x2, double y2 ) : mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
||||
{
|
||||
}
|
||||
MarkupLine( double x1, double y1, double x2, double y2 );
|
||||
|
||||
inline double x1() const { return mX1; }
|
||||
inline double y1() const { return mY1; }
|
||||
inline double x2() const { return mX2; }
|
||||
inline double y2() const { return mY2; }
|
||||
double x1() const;
|
||||
double y1() const;
|
||||
double x2() const;
|
||||
double y2() const;
|
||||
|
||||
Markup *dup() const { return new MarkupLine( mX1, mY1, mX2, mY2 ); }
|
||||
Markup* dup() const;
|
||||
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
QGraphicsLineItem* item = new QGraphicsLineItem( mX1, mY1, mX2, mY2 );
|
||||
item->setPen( pen );
|
||||
|
||||
return item;
|
||||
}
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||
|
||||
private:
|
||||
double mX1;
|
||||
@@ -92,29 +79,17 @@ namespace libglabels
|
||||
class MarkupRect : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupRect( double x1, double y1, double w, double h, double r )
|
||||
: mX1(x1), mY1(y1), mW(w), mH(h), mR(r)
|
||||
{
|
||||
}
|
||||
MarkupRect( double x1, double y1, double w, double h, double r );
|
||||
|
||||
inline double x1() const { return mX1; }
|
||||
inline double y1() const { return mY1; }
|
||||
inline double w() const { return mW; }
|
||||
inline double h() const { return mH; }
|
||||
inline double r() const { return mR; }
|
||||
double x1() const;
|
||||
double y1() const;
|
||||
double w() const;
|
||||
double h() const;
|
||||
double r() const;
|
||||
|
||||
Markup *dup() const { return new MarkupRect( mX1, mY1, mW, mH, mR ); }
|
||||
Markup* dup() const;
|
||||
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addRoundedRect( mX1, mY1, mW, mH, mR, mR );
|
||||
|
||||
QGraphicsPathItem* item = new QGraphicsPathItem( path );
|
||||
item->setPen( pen );
|
||||
|
||||
return item;
|
||||
}
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||
|
||||
private:
|
||||
double mX1;
|
||||
@@ -128,25 +103,16 @@ namespace libglabels
|
||||
class MarkupEllipse : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupEllipse( double x1, double y1, double w, double h )
|
||||
: mX1(x1), mY1(y1), mW(w), mH(h)
|
||||
{
|
||||
}
|
||||
MarkupEllipse( double x1, double y1, double w, double h );
|
||||
|
||||
inline double x1() const { return mX1; }
|
||||
inline double y1() const { return mY1; }
|
||||
inline double w() const { return mW; }
|
||||
inline double h() const { return mH; }
|
||||
double x1() const;
|
||||
double y1() const;
|
||||
double w() const;
|
||||
double h() const;
|
||||
|
||||
Markup *dup() const { return new MarkupEllipse( mX1, mY1, mW, mH ); }
|
||||
Markup* dup() const;
|
||||
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
QGraphicsEllipseItem* item = new QGraphicsEllipseItem( mX1, mY1, mW, mH );
|
||||
item->setPen( pen );
|
||||
|
||||
return item;
|
||||
}
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||
|
||||
private:
|
||||
double mX1;
|
||||
@@ -159,24 +125,15 @@ namespace libglabels
|
||||
class MarkupCircle : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupCircle( double x0, double y0, double r )
|
||||
: mX0(x0), mY0(y0), mR(r)
|
||||
{
|
||||
}
|
||||
MarkupCircle( double x0, double y0, double r );
|
||||
|
||||
inline double x0() const { return mX0; }
|
||||
inline double y0() const { return mY0; }
|
||||
inline double r() const { return mR; }
|
||||
double x0() const;
|
||||
double y0() const;
|
||||
double r() const;
|
||||
|
||||
Markup *dup() const { return new MarkupCircle( mX0, mY0, mR ); }
|
||||
Markup* dup() const;
|
||||
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const
|
||||
{
|
||||
QGraphicsEllipseItem* item = new QGraphicsEllipseItem( mX0-mR, mY0-mR, 2*mR, 2*mR );
|
||||
item->setPen( pen );
|
||||
|
||||
return item;
|
||||
}
|
||||
QGraphicsItem* createGraphicsItem( const Frame* frame, const QPen& pen ) const;
|
||||
|
||||
private:
|
||||
double mX0;
|
||||
@@ -187,4 +144,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Markup.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Markup_h
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/* Markup.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline double MarkupMargin::size() const { return mSize; }
|
||||
|
||||
inline double MarkupLine::x1() const { return mX1; }
|
||||
inline double MarkupLine::y1() const { return mY1; }
|
||||
inline double MarkupLine::x2() const { return mX2; }
|
||||
inline double MarkupLine::y2() const { return mY2; }
|
||||
|
||||
inline double MarkupRect::x1() const { return mX1; }
|
||||
inline double MarkupRect::y1() const { return mY1; }
|
||||
inline double MarkupRect::w() const { return mW; }
|
||||
inline double MarkupRect::h() const { return mH; }
|
||||
inline double MarkupRect::r() const { return mR; }
|
||||
|
||||
inline double MarkupEllipse::x1() const { return mX1; }
|
||||
inline double MarkupEllipse::y1() const { return mY1; }
|
||||
inline double MarkupEllipse::w() const { return mW; }
|
||||
inline double MarkupEllipse::h() const { return mH; }
|
||||
|
||||
inline double MarkupCircle::x0() const { return mX0; }
|
||||
inline double MarkupCircle::y0() const { return mY0; }
|
||||
inline double MarkupCircle::r() const { return mR; }
|
||||
|
||||
}
|
||||
@@ -38,6 +38,18 @@ namespace
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
MiniPreviewPixmap::MiniPreviewPixmap()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MiniPreviewPixmap::MiniPreviewPixmap( const Template *tmplate, int width, int height )
|
||||
: QPixmap( width, height )
|
||||
{
|
||||
draw( tmplate, width, height );
|
||||
}
|
||||
|
||||
|
||||
void MiniPreviewPixmap::draw( const Template *tmplate, int width, int height )
|
||||
{
|
||||
fill( Qt::transparent );
|
||||
|
||||
@@ -34,22 +34,19 @@ namespace libglabels
|
||||
|
||||
class MiniPreviewPixmap : public QPixmap
|
||||
{
|
||||
|
||||
public:
|
||||
MiniPreviewPixmap()
|
||||
{
|
||||
}
|
||||
MiniPreviewPixmap();
|
||||
|
||||
MiniPreviewPixmap( const Template *tmplate, int width, int height )
|
||||
: QPixmap( width, height )
|
||||
{
|
||||
draw( tmplate, width, height );
|
||||
}
|
||||
MiniPreviewPixmap( const Template *tmplate, int width, int height );
|
||||
|
||||
|
||||
private:
|
||||
void draw( const Template *tmplate, int width, int height );
|
||||
void drawPaper( QPainter &painter, const Template *tmplate, double scale );
|
||||
void drawLabelOutlines( QPainter &painter, const Template *tmplate, double scale );
|
||||
void drawLabelOutline( QPainter &painter, const Frame *frame, double x0, double y0 );
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -19,3 +19,14 @@
|
||||
*/
|
||||
|
||||
#include "Paper.h"
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Paper::Paper( const QString& id, const QString& name, double width, double height, const QString& pwgSize )
|
||||
: mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-15
@@ -31,29 +31,22 @@ namespace libglabels
|
||||
class Paper
|
||||
{
|
||||
public:
|
||||
Paper( const QString &id,
|
||||
const QString &name,
|
||||
double width,
|
||||
double height,
|
||||
const QString &pwgSize ) : mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
||||
{
|
||||
}
|
||||
Paper( const QString& id, const QString& name, double width, double height, const QString& pwgSize );
|
||||
|
||||
inline const QString &id() const { return mId; }
|
||||
|
||||
inline const QString &name() const { return mName; }
|
||||
inline const QString& id() const;
|
||||
inline const QString& name() const;
|
||||
|
||||
/* Width (in points) */
|
||||
inline double width() const { return mWidth; }
|
||||
inline double width() const;
|
||||
|
||||
/* Height (in points) */
|
||||
inline double height() const { return mHeight; }
|
||||
inline double height() const;
|
||||
|
||||
/* PWG 5101.1-2002 size name */
|
||||
inline QString pwgSize() const { return mPwgSize; }
|
||||
inline QString pwgSize() const;
|
||||
|
||||
inline bool isSizeIso() const { return mPwgSize.startsWith( "iso_" ); }
|
||||
inline bool isSizeUs() const { return mPwgSize.startsWith( "na_" ); }
|
||||
inline bool isSizeIso() const;
|
||||
inline bool isSizeUs() const;
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
@@ -65,4 +58,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Paper.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Paper_h
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* Paper.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline const QString& Paper::id() const { return mId; }
|
||||
inline const QString& Paper::name() const { return mName; }
|
||||
|
||||
inline double Paper::width() const { return mWidth; }
|
||||
inline double Paper::height() const { return mHeight; }
|
||||
|
||||
inline QString Paper::pwgSize() const { return mPwgSize; }
|
||||
|
||||
inline bool Paper::isSizeIso() const { return mPwgSize.startsWith( "iso_" ); }
|
||||
inline bool Paper::isSizeUs() const { return mPwgSize.startsWith( "na_" ); }
|
||||
|
||||
}
|
||||
@@ -24,6 +24,16 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Point::Point() : mX(0), mY(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Point::Point( double x, double y ) : mX(x), mY(y)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool Point::operator<( const Point &other ) const
|
||||
{
|
||||
if ( mY < other.mY )
|
||||
|
||||
+9
-9
@@ -28,16 +28,12 @@ namespace libglabels
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
Point() : mX(0), mY(0)
|
||||
{
|
||||
}
|
||||
Point();
|
||||
|
||||
Point( double x, double y );
|
||||
|
||||
Point( double x, double y ) : mX(x), mY(y)
|
||||
{
|
||||
}
|
||||
|
||||
inline double x() const { return mX; }
|
||||
inline double y() const { return mY; }
|
||||
double x() const;
|
||||
double y() const;
|
||||
|
||||
bool operator<( const Point &other ) const;
|
||||
|
||||
@@ -49,4 +45,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Point.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Point_h
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Point.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline double Point::x() const { return mX; }
|
||||
inline double Point::y() const { return mY; }
|
||||
|
||||
}
|
||||
+28
-22
@@ -28,10 +28,10 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Template::Template( const QString &brand,
|
||||
const QString &part,
|
||||
const QString &description,
|
||||
const QString &paperId,
|
||||
Template::Template( const QString& brand,
|
||||
const QString& part,
|
||||
const QString& description,
|
||||
const QString& paperId,
|
||||
double pageWidth = 0,
|
||||
double pageHeight = 0 )
|
||||
: mBrand(brand),
|
||||
@@ -48,14 +48,14 @@ namespace libglabels
|
||||
|
||||
if ( Db::isPaperIdKnown( paperId ) )
|
||||
{
|
||||
const Paper *paper = Db::lookupPaperFromId( paperId );
|
||||
const Paper* paper = Db::lookupPaperFromId( paperId );
|
||||
mIsSizeIso = paper->isSizeIso();
|
||||
mIsSizeUs = paper->isSizeUs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Template::Template( const Template &other )
|
||||
Template::Template( const Template& other )
|
||||
{
|
||||
mBrand = other.mBrand;
|
||||
mPart = other.mPart;
|
||||
@@ -69,7 +69,7 @@ namespace libglabels
|
||||
mName = other.mName;
|
||||
mProductUrl = other.mProductUrl;
|
||||
|
||||
foreach ( Frame *frame, other.mFrames )
|
||||
foreach ( Frame* frame, other.mFrames )
|
||||
{
|
||||
addFrame( frame );
|
||||
}
|
||||
@@ -81,8 +81,14 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
Template* Template::dup() const
|
||||
{
|
||||
return new Template( *this );
|
||||
}
|
||||
|
||||
|
||||
// Generic full page template
|
||||
Template *Template::fullPage( const QString &paperId )
|
||||
Template* Template::fullPage( const QString& paperId )
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
@@ -90,14 +96,14 @@ namespace libglabels
|
||||
|
||||
|
||||
// From equivalent part number
|
||||
Template *Template::fromEquiv( const QString &brand,
|
||||
const QString &part,
|
||||
const QString &equivPart )
|
||||
Template* Template::fromEquiv( const QString& brand,
|
||||
const QString& part,
|
||||
const QString& equivPart )
|
||||
{
|
||||
const Template *other = Db::lookupTemplateFromBrandPart( brand, equivPart );
|
||||
const Template* other = Db::lookupTemplateFromBrandPart( brand, equivPart );
|
||||
if ( other != NULL )
|
||||
{
|
||||
Template *tmplate = other->dup();
|
||||
Template* tmplate = other->dup();
|
||||
|
||||
tmplate->mPart = part;
|
||||
tmplate->mEquivPart = equivPart;
|
||||
@@ -117,13 +123,13 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
void Template::addCategory( const QString &categoryId )
|
||||
void Template::addCategory( const QString& categoryId )
|
||||
{
|
||||
mCategoryIds << categoryId;
|
||||
}
|
||||
|
||||
|
||||
void Template::addFrame( Frame *frame )
|
||||
void Template::addFrame( Frame* frame )
|
||||
{
|
||||
mFrames << frame;
|
||||
}
|
||||
@@ -135,13 +141,13 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
bool Template::operator==( const Template &other ) const
|
||||
bool Template::operator==( const Template& other ) const
|
||||
{
|
||||
return (mBrand == other.mBrand) && (mPart == other.mPart);
|
||||
}
|
||||
|
||||
|
||||
bool Template::hasCategory( const QString &categoryId ) const
|
||||
bool Template::hasCategory( const QString& categoryId ) const
|
||||
{
|
||||
foreach ( QString testCategoryId, mCategoryIds )
|
||||
{
|
||||
@@ -155,7 +161,7 @@ namespace libglabels
|
||||
}
|
||||
|
||||
|
||||
bool Template::isSimilarTo( const Template *other ) const
|
||||
bool Template::isSimilarTo( const Template* other ) const
|
||||
{
|
||||
// Does page size match?
|
||||
if ( (mPaperId != other->mPaperId) ||
|
||||
@@ -166,18 +172,18 @@ namespace libglabels
|
||||
}
|
||||
|
||||
// Are frames similar
|
||||
Frame *frame1 = mFrames.first();
|
||||
Frame *frame2 = other->mFrames.first();
|
||||
Frame* frame1 = mFrames.first();
|
||||
Frame* frame2 = other->mFrames.first();
|
||||
if ( !frame1->isSimilarTo( frame2 ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Are they layed out similarly?
|
||||
foreach ( Layout *layout1, frame1->layouts() )
|
||||
foreach ( Layout* layout1, frame1->layouts() )
|
||||
{
|
||||
bool matchFound = false;
|
||||
foreach ( Layout *layout2, frame2->layouts() )
|
||||
foreach ( Layout* layout2, frame2->layouts() )
|
||||
{
|
||||
if ( layout1->isSimilarTo(layout2) )
|
||||
{
|
||||
|
||||
+35
-32
@@ -46,58 +46,57 @@ namespace libglabels
|
||||
|
||||
public:
|
||||
|
||||
Template( const QString &brand,
|
||||
const QString &part,
|
||||
const QString &description,
|
||||
const QString &paperId,
|
||||
Template( const QString& brand,
|
||||
const QString& part,
|
||||
const QString& description,
|
||||
const QString& paperId,
|
||||
double pageWidth,
|
||||
double pageHeight );
|
||||
|
||||
Template( const Template &other );
|
||||
|
||||
inline Template *dup() const { return new Template( *this ); }
|
||||
Template( const Template& other );
|
||||
|
||||
Template* dup() const;
|
||||
|
||||
// Generic full page template
|
||||
static Template *fullPage( const QString &paperId );
|
||||
static Template* fullPage( const QString& paperId );
|
||||
|
||||
// From equivalent part number
|
||||
static Template *fromEquiv( const QString &brand,
|
||||
const QString &part,
|
||||
const QString &equivPart );
|
||||
static Template* fromEquiv( const QString& brand,
|
||||
const QString& part,
|
||||
const QString& equivPart );
|
||||
|
||||
|
||||
inline const QString &brand() const { return mBrand; }
|
||||
inline const QString &part() const { return mPart; }
|
||||
inline const QString &description() const { return mDescription; }
|
||||
const QString& brand() const;
|
||||
const QString& part() const;
|
||||
const QString& description() const;
|
||||
|
||||
inline const QString &paperId() const { return mPaperId; }
|
||||
inline double pageWidth() const { return mPageWidth; }
|
||||
inline double pageHeight() const { return mPageHeight; }
|
||||
inline bool isSizeIso() const { return mIsSizeIso; }
|
||||
inline bool isSizeUs() const { return mIsSizeUs; }
|
||||
inline bool isSizeOther() const { return !mIsSizeIso && !mIsSizeUs; }
|
||||
const QString& paperId() const;
|
||||
double pageWidth() const;
|
||||
double pageHeight() const;
|
||||
bool isSizeIso() const;
|
||||
bool isSizeUs() const;
|
||||
bool isSizeOther() const;
|
||||
|
||||
inline const QString &equivPart() const { return mEquivPart; }
|
||||
inline void setEquivPart( const QString &value ) { mEquivPart = value; }
|
||||
const QString& equivPart() const;
|
||||
void setEquivPart( const QString& value );
|
||||
|
||||
inline const QString &productUrl() const { return mProductUrl; }
|
||||
inline void setProductUrl( const QString &value ) { mProductUrl = value; }
|
||||
const QString& productUrl() const;
|
||||
void setProductUrl( const QString& value );
|
||||
|
||||
inline const QString &name() const { return mName; }
|
||||
const QString& name() const;
|
||||
|
||||
void addCategory( const QString &categoryId );
|
||||
void addFrame( Frame *frame );
|
||||
void addCategory( const QString& categoryId );
|
||||
void addFrame( Frame* frame );
|
||||
|
||||
void initPreview();
|
||||
inline const MiniPreviewPixmap &preview() const { return mPreview; }
|
||||
const MiniPreviewPixmap& preview() const;
|
||||
|
||||
inline const QList<Frame*> &frames() const { return mFrames; }
|
||||
const QList<Frame*>& frames() const;
|
||||
|
||||
bool operator==( const Template &other ) const;
|
||||
bool operator==( const Template& other ) const;
|
||||
|
||||
bool hasCategory( const QString &categoryId ) const;
|
||||
bool isSimilarTo( const Template *other ) const;
|
||||
bool hasCategory( const QString& categoryId ) const;
|
||||
bool isSimilarTo( const Template* other ) const;
|
||||
|
||||
|
||||
private:
|
||||
@@ -124,4 +123,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Template.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Template_h
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/* Template.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline const QString& Template::brand() const { return mBrand; }
|
||||
inline const QString& Template::part() const { return mPart; }
|
||||
inline const QString& Template::description() const { return mDescription; }
|
||||
|
||||
inline const QString& Template::paperId() const { return mPaperId; }
|
||||
inline double Template::pageWidth() const { return mPageWidth; }
|
||||
inline double Template::pageHeight() const { return mPageHeight; }
|
||||
inline bool Template::isSizeIso() const { return mIsSizeIso; }
|
||||
inline bool Template::isSizeUs() const { return mIsSizeUs; }
|
||||
inline bool Template::isSizeOther() const { return !mIsSizeIso && !mIsSizeUs; }
|
||||
|
||||
inline const QString& Template::equivPart() const { return mEquivPart; }
|
||||
inline void Template::setEquivPart( const QString& value ) { mEquivPart = value; }
|
||||
|
||||
inline const QString& Template::productUrl() const { return mProductUrl; }
|
||||
inline void Template::setProductUrl( const QString& value ) { mProductUrl = value; }
|
||||
|
||||
inline const QString& Template::name() const { return mName; }
|
||||
|
||||
inline const MiniPreviewPixmap& Template::preview() const { return mPreview; }
|
||||
|
||||
inline const QList<Frame*>& Template::frames() const { return mFrames; }
|
||||
|
||||
}
|
||||
@@ -36,6 +36,13 @@ namespace
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Units::Units( const QString &id, const QString &name, double pointsPerUnit )
|
||||
: mId(id), mName(name), mPointsPerUnit(pointsPerUnit)
|
||||
{
|
||||
mUnitsPerPoint = 1.0 / mPointsPerUnit;
|
||||
}
|
||||
|
||||
|
||||
Units *Units::fromId( const QString &id )
|
||||
{
|
||||
if ( id == "pt" )
|
||||
|
||||
+9
-13
@@ -36,22 +36,14 @@ namespace libglabels
|
||||
|
||||
|
||||
private:
|
||||
Units( const QString &id, const QString &name, double pointsPerUnit )
|
||||
: mId(id), mName(name), mPointsPerUnit(pointsPerUnit)
|
||||
{
|
||||
mUnitsPerPoint = 1.0 / mPointsPerUnit;
|
||||
}
|
||||
|
||||
Units( const QString &id, const QString &name, double pointsPerUnit );
|
||||
|
||||
public:
|
||||
inline QString id() const { return mId; }
|
||||
|
||||
inline QString name() const { return mName; }
|
||||
|
||||
inline double pointsPerUnit() const { return mPointsPerUnit; }
|
||||
|
||||
inline double unitsPerPoint() const { return mUnitsPerPoint; }
|
||||
QString id() const;
|
||||
QString name() const;
|
||||
|
||||
double pointsPerUnit() const;
|
||||
double unitsPerPoint() const;
|
||||
|
||||
static Units *fromId( const QString &id );
|
||||
|
||||
@@ -78,4 +70,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Units.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Units_h
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/* Units.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline QString Units::id() const { return mId; }
|
||||
|
||||
inline QString Units::name() const { return mName; }
|
||||
|
||||
inline double Units::pointsPerUnit() const { return mPointsPerUnit; }
|
||||
|
||||
inline double Units::unitsPerPoint() const { return mUnitsPerPoint; }
|
||||
|
||||
}
|
||||
@@ -19,3 +19,13 @@
|
||||
*/
|
||||
|
||||
#include "Vendor.h"
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Vendor::Vendor( const QString &name, const QString &url ) : mName(name), mUrl(url)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-6
@@ -31,13 +31,10 @@ namespace libglabels
|
||||
class Vendor
|
||||
{
|
||||
public:
|
||||
Vendor( const QString &name, const QString &url ) : mName(name), mUrl(url)
|
||||
{
|
||||
}
|
||||
Vendor( const QString &name, const QString &url );
|
||||
|
||||
inline const QString &name() const { return mName; }
|
||||
|
||||
inline const QString &url() const { return mUrl; }
|
||||
const QString& name() const;
|
||||
const QString& url() const;
|
||||
|
||||
private:
|
||||
QString mName;
|
||||
@@ -46,4 +43,8 @@ namespace libglabels
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "Vendor.inl"
|
||||
|
||||
|
||||
#endif // libglabels_Vendor_h
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Vendor.inl
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
inline const QString& Vendor::name() const { return mName; }
|
||||
inline const QString& Vendor::url() const { return mUrl; }
|
||||
|
||||
}
|
||||
+27
-3
@@ -27,7 +27,31 @@
|
||||
namespace libglabels
|
||||
{
|
||||
|
||||
Units *XmlUtil::mDefaultUnits;
|
||||
Units* XmlUtil::mDefaultUnits;
|
||||
|
||||
|
||||
XmlUtil::XmlUtil()
|
||||
{
|
||||
mDefaultUnits = Units::point();
|
||||
}
|
||||
|
||||
|
||||
void XmlUtil::init()
|
||||
{
|
||||
static XmlUtil* xmlUtil = new XmlUtil();
|
||||
}
|
||||
|
||||
|
||||
const Units* XmlUtil::defaultUnits()
|
||||
{
|
||||
return mDefaultUnits;
|
||||
}
|
||||
|
||||
|
||||
void XmlUtil::setDefaultUnits( Units* defaultUnits )
|
||||
{
|
||||
mDefaultUnits = defaultUnits;
|
||||
}
|
||||
|
||||
|
||||
QString XmlUtil::getStringAttr( const QDomElement& node,
|
||||
@@ -186,9 +210,9 @@ namespace libglabels
|
||||
return default_value;
|
||||
}
|
||||
|
||||
Units *units = Units::fromId( unitsString );
|
||||
Units* units = Units::fromId( unitsString );
|
||||
|
||||
return value * units->pointsPerUnit();
|
||||
return value* units->pointsPerUnit();
|
||||
}
|
||||
|
||||
return default_value;
|
||||
|
||||
+6
-15
@@ -34,24 +34,15 @@ namespace libglabels
|
||||
class XmlUtil
|
||||
{
|
||||
private:
|
||||
XmlUtil()
|
||||
{
|
||||
mDefaultUnits = Units::point();
|
||||
}
|
||||
XmlUtil();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static void init()
|
||||
{
|
||||
static XmlUtil *xmlUtil = new XmlUtil();
|
||||
}
|
||||
static void init();
|
||||
|
||||
static const Units *defaultUnits() { return mDefaultUnits; }
|
||||
|
||||
static void setDefaultUnits( Units *defaultUnits )
|
||||
{
|
||||
mDefaultUnits = defaultUnits;
|
||||
}
|
||||
static const Units* defaultUnits();
|
||||
static void setDefaultUnits( Units* defaultUnits );
|
||||
|
||||
static QString getStringAttr( const QDomElement& node,
|
||||
const QString& name,
|
||||
@@ -106,7 +97,7 @@ namespace libglabels
|
||||
double value );
|
||||
|
||||
private:
|
||||
static Units *mDefaultUnits;
|
||||
static Units* mDefaultUnits;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user