Some namespace cleanup.

This commit is contained in:
Jim Evins
2016-03-27 00:14:38 -04:00
parent 5b7e031c52
commit 7559544b06
156 changed files with 9732 additions and 10126 deletions
+154 -161
View File
@@ -21,166 +21,159 @@
#include "BarcodeBackends.h"
namespace glabels
namespace
{
namespace
{
const std::string default_id = "code39";
}
BarcodeBackends::BackendMap BarcodeBackends::mBackendIdMap;
BarcodeBackends::BackendMap BarcodeBackends::mBackendNameMap;
BarcodeBackends::StyleMap BarcodeBackends::mStyleIdMap;
BarcodeBackends::StyleMap BarcodeBackends::mStyleNameMap;
QList<QString> BarcodeBackends::mBackendNameList;
QList<QString> BarcodeBackends::mNameList;
BarcodeBackends::BarcodeBackends()
{
registerStyle( "postnet", "", tr("POSTNET (any)"),
false, false, true, false, "12345-6789-12", false, 11 );
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
false, false, true, false, "12345", false, 5 );
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
false, false, true, false, "12345-6789", false, 9 );
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
false, false, true, false, "12345-6789-12", false, 11 );
registerStyle( "cepnet", "", tr("CEPNET"),
false, false, true, false, "12345-678", false, 8 );
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
false, false, true, false, "12345678901234567890", false, 20 );
registerStyle( "code39", "", tr("Code 39"),
true, true, true, true, "1234567890", true, 10 );
registerStyle( "code39ext", "", tr("Code 39 Extended"),
true, true, true, true, "1234567890", true, 10 );
registerStyle( "upc-A", "", tr("UPC-A"),
true, false, true, false, "12345678901", false, 11 );
registerStyle( "ean-13", "", tr("EAN-13"),
true, false, true, false, "123456789012", false, 12 );
registerStyle( "datamatrix", "", tr("DataMatrix"),
false, false, true, false, "1234567890AB", false, 12 );
registerStyle( "qrcode", "", tr("QRCode"),
false, false, true, false, "1234567890AB", false, 12 );
}
void BarcodeBackends::init( void )
{
static BarcodeBackends* singletonInstance = NULL;
if ( singletonInstance == NULL )
{
singletonInstance = new BarcodeBackends();
}
}
QString BarcodeBackends::BackendIdToName( const QString& backendId )
{
BackendMap::iterator i = mBackendIdMap.find( backendId );
if ( i != mBackendIdMap.end() )
{
return i.value();
}
return "";
}
QString BarcodeBackends::BackendNameToId( const QString& backendName )
{
BackendMap::iterator i = mBackendNameMap.find( backendName );
if ( i != mBackendNameMap.end() )
{
return i.value();
}
return "";
}
const QList<QString>& BarcodeBackends::getBackendNameList()
{
return mBackendNameList;
}
const QList<QString>& BarcodeBackends::getNameList()
{
return mNameList;
}
const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
{
StyleMap::iterator i = mStyleIdMap.find( id );
if ( i != mStyleIdMap.end() )
{
return i.value();
}
return 0;
}
const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
{
StyleMap::iterator i = mStyleNameMap.find( name );
if ( i != mStyleNameMap.end() )
{
return i.value();
}
return 0;
}
void BarcodeBackends::registerBackend( QString& id, QString& name)
{
mBackendNameList.append( name );
mBackendIdMap.insert( id, name );
mBackendNameMap.insert( name, id );
}
void BarcodeBackends::registerStyle( const char* id,
const char* backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const char* defaultDigits,
bool canFreeForm,
int preferedN )
{
BarcodeStyle* style = new BarcodeStyle( QString(id), QString(backendId), name,
canText, textOptional,
canChecksum, checksumOptional,
QString(defaultDigits), canFreeForm, preferedN );
QString fqName = QString(backendId) + QString(".") + name; // Name may not be unique
mNameList.append( name );
mStyleIdMap.insert( id, style );
mStyleNameMap.insert( fqName, style );
}
const std::string default_id = "code39";
}
BarcodeBackends::BackendMap BarcodeBackends::mBackendIdMap;
BarcodeBackends::BackendMap BarcodeBackends::mBackendNameMap;
BarcodeBackends::StyleMap BarcodeBackends::mStyleIdMap;
BarcodeBackends::StyleMap BarcodeBackends::mStyleNameMap;
QList<QString> BarcodeBackends::mBackendNameList;
QList<QString> BarcodeBackends::mNameList;
BarcodeBackends::BarcodeBackends()
{
registerStyle( "postnet", "", tr("POSTNET (any)"),
false, false, true, false, "12345-6789-12", false, 11 );
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
false, false, true, false, "12345", false, 5 );
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
false, false, true, false, "12345-6789", false, 9 );
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
false, false, true, false, "12345-6789-12", false, 11 );
registerStyle( "cepnet", "", tr("CEPNET"),
false, false, true, false, "12345-678", false, 8 );
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
false, false, true, false, "12345678901234567890", false, 20 );
registerStyle( "code39", "", tr("Code 39"),
true, true, true, true, "1234567890", true, 10 );
registerStyle( "code39ext", "", tr("Code 39 Extended"),
true, true, true, true, "1234567890", true, 10 );
registerStyle( "upc-A", "", tr("UPC-A"),
true, false, true, false, "12345678901", false, 11 );
registerStyle( "ean-13", "", tr("EAN-13"),
true, false, true, false, "123456789012", false, 12 );
registerStyle( "datamatrix", "", tr("DataMatrix"),
false, false, true, false, "1234567890AB", false, 12 );
registerStyle( "qrcode", "", tr("QRCode"),
false, false, true, false, "1234567890AB", false, 12 );
}
void BarcodeBackends::init( void )
{
static BarcodeBackends* singletonInstance = NULL;
if ( singletonInstance == NULL )
{
singletonInstance = new BarcodeBackends();
}
}
QString BarcodeBackends::BackendIdToName( const QString& backendId )
{
BackendMap::iterator i = mBackendIdMap.find( backendId );
if ( i != mBackendIdMap.end() )
{
return i.value();
}
return "";
}
QString BarcodeBackends::BackendNameToId( const QString& backendName )
{
BackendMap::iterator i = mBackendNameMap.find( backendName );
if ( i != mBackendNameMap.end() )
{
return i.value();
}
return "";
}
const QList<QString>& BarcodeBackends::getBackendNameList()
{
return mBackendNameList;
}
const QList<QString>& BarcodeBackends::getNameList()
{
return mNameList;
}
const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
{
StyleMap::iterator i = mStyleIdMap.find( id );
if ( i != mStyleIdMap.end() )
{
return i.value();
}
return 0;
}
const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
{
StyleMap::iterator i = mStyleNameMap.find( name );
if ( i != mStyleNameMap.end() )
{
return i.value();
}
return 0;
}
void BarcodeBackends::registerBackend( QString& id, QString& name)
{
mBackendNameList.append( name );
mBackendIdMap.insert( id, name );
mBackendNameMap.insert( name, id );
}
void BarcodeBackends::registerStyle( const char* id,
const char* backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const char* defaultDigits,
bool canFreeForm,
int preferedN )
{
BarcodeStyle* style = new BarcodeStyle( QString(id), QString(backendId), name,
canText, textOptional,
canChecksum, checksumOptional,
QString(defaultDigits), canFreeForm, preferedN );
QString fqName = QString(backendId) + QString(".") + name; // Name may not be unique
mNameList.append( name );
mStyleIdMap.insert( id, style );
mStyleNameMap.insert( fqName, style );
}
+51 -56
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_BarcodeBackends_h
#define glabels_BarcodeBackends_h
#ifndef BarcodeBackends_h
#define BarcodeBackends_h
#include "BarcodeStyle.h"
@@ -29,73 +29,68 @@
#include <QList>
namespace glabels
///
/// Barcode Backends Database
///
class BarcodeBackends : public QObject
{
///
/// Barcode Backends Database
///
class BarcodeBackends : public QObject
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
BarcodeBackends();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
BarcodeBackends();
public:
static void init( void );
public:
static void init( void );
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
static QString BackendIdToName( const QString& backendId );
static QString BackendNameToId( const QString& backendName );
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
static QString BackendIdToName( const QString& backendId );
static QString BackendNameToId( const QString& backendName );
static const QList<QString>& getBackendNameList();
static const QList<QString>& getNameList();
static const QList<QString>& getBackendNameList();
static const QList<QString>& getNameList();
static const BarcodeStyle* lookupStyleFromId( const QString& id );
static const BarcodeStyle* lookupStyleFromName( const QString& name );
static const BarcodeStyle* lookupStyleFromId( const QString& id );
static const BarcodeStyle* lookupStyleFromName( const QString& name );
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
static void registerBackend( QString &id, QString &name);
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
static void registerBackend( QString &id, QString &name);
static void registerStyle( const char* id,
const char* backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const char* defaultDigits,
bool canFreeForm,
int preferedN );
static void registerStyle( const char* id,
const char* backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const char* defaultDigits,
bool canFreeForm,
int preferedN );
/////////////////////////////////
// Private Members
/////////////////////////////////
typedef QMap<QString,QString> BackendMap;
static BackendMap mBackendIdMap;
static BackendMap mBackendNameMap;
/////////////////////////////////
// Private Members
/////////////////////////////////
typedef QMap<QString,QString> BackendMap;
static BackendMap mBackendIdMap;
static BackendMap mBackendNameMap;
typedef QMap<QString,BarcodeStyle*> StyleMap;
static StyleMap mStyleIdMap;
static StyleMap mStyleNameMap;
typedef QMap<QString,BarcodeStyle*> StyleMap;
static StyleMap mStyleIdMap;
static StyleMap mStyleNameMap;
static QList<QString> mBackendNameList;
static QList<QString> mNameList;
static QList<QString> mBackendNameList;
static QList<QString> mNameList;
};
}
};
#endif // glabels_BarcodeBackends_h
#endif // BarcodeBackends_h
+28 -35
View File
@@ -24,45 +24,38 @@
#include "BarcodeMenuItem.h"
namespace glabels
///
/// Constructor
///
BarcodeMenu::BarcodeMenu()
{
///
/// Constructor
///
BarcodeMenu::BarcodeMenu()
foreach ( QString name, BarcodeBackends::getNameList() )
{
foreach ( QString name, BarcodeBackends::getNameList() )
{
const BarcodeStyle* bcStyle = BarcodeBackends::lookupStyleFromName( name );
const BarcodeStyle* bcStyle = BarcodeBackends::lookupStyleFromName( name );
BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle );
connect( bcMenuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle );
connect( bcMenuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
addAction( bcMenuItem );
}
addAction( bcMenuItem );
}
///
/// bcStyle getter
///
const BarcodeStyle* BarcodeMenu::bcStyle() const
{
return mBcStyle;
}
///
/// onMenuItemActivated slot
///
void BarcodeMenu::onMenuItemActivated( BarcodeStyle *bcStyle )
{
mBcStyle = bcStyle;
emit styleChanged();
}
}
///
/// bcStyle getter
///
const BarcodeStyle* BarcodeMenu::bcStyle() const
{
return mBcStyle;
}
///
/// onMenuItemActivated slot
///
void BarcodeMenu::onMenuItemActivated( BarcodeStyle *bcStyle )
{
mBcStyle = bcStyle;
emit styleChanged();
}
+34 -39
View File
@@ -18,60 +18,55 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_BarcodeMenu_h
#define glabels_BarcodeMenu_h
#ifndef BarcodeMenu_h
#define BarcodeMenu_h
#include <QMenu>
#include "BarcodeStyle.h"
namespace glabels
///
/// Barcode Menu
///
class BarcodeMenu : public QMenu
{
Q_OBJECT
///
/// Barcode Menu
///
class BarcodeMenu : public QMenu
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeMenu();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeMenu();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void styleChanged();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void styleChanged();
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const BarcodeStyle* bcStyle() const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const BarcodeStyle* bcStyle() const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuItemActivated( BarcodeStyle *bcStyle );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuItemActivated( BarcodeStyle *bcStyle );
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
BarcodeStyle* mBcStyle;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
BarcodeStyle* mBcStyle;
};
};
}
#endif // glabels_BarcodeMenu_h
#endif // BarcodeMenu_h
+30 -37
View File
@@ -24,45 +24,38 @@
#include "BarcodeMenuItem.h"
namespace glabels
///
/// Constructor
///
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
: QPushButton(parent)
{
mMenu = new BarcodeMenu();
setMenu( mMenu );
///
/// Constructor
///
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
: QPushButton(parent)
{
mMenu = new BarcodeMenu();
setMenu( mMenu );
mBcStyle = BarcodeBackends::lookupStyleFromId( "" ); // Default style
setText( mBcStyle->name() );
connect( mMenu, SIGNAL(styleChanged()), this, SLOT(onMenuStyleChanged()) );
}
///
/// bcStyle getter
///
const BarcodeStyle* BarcodeMenuButton::bcStyle() const
{
return mBcStyle;
}
///
/// onMenuStyleChanged slot
///
void BarcodeMenuButton::onMenuStyleChanged()
{
mBcStyle = mMenu->bcStyle();
setText( mBcStyle->name() );
emit styleChanged();
}
mBcStyle = BarcodeBackends::lookupStyleFromId( "" ); // Default style
setText( mBcStyle->name() );
connect( mMenu, SIGNAL(styleChanged()), this, SLOT(onMenuStyleChanged()) );
}
///
/// bcStyle getter
///
const BarcodeStyle* BarcodeMenuButton::bcStyle() const
{
return mBcStyle;
}
///
/// onMenuStyleChanged slot
///
void BarcodeMenuButton::onMenuStyleChanged()
{
mBcStyle = mMenu->bcStyle();
setText( mBcStyle->name() );
emit styleChanged();
}
+35 -40
View File
@@ -18,62 +18,57 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_BarcodeMenuButton_h
#define glabels_BarcodeMenuButton_h
#ifndef BarcodeMenuButton_h
#define BarcodeMenuButton_h
#include <QPushButton>
#include "BarcodeMenu.h"
#include "BarcodeStyle.h"
namespace glabels
///
/// Barcode Menu Button
///
class BarcodeMenuButton : public QPushButton
{
Q_OBJECT
///
/// Barcode Menu Button
///
class BarcodeMenuButton : public QPushButton
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeMenuButton( QWidget* parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeMenuButton( QWidget* parent = 0 );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void styleChanged();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void styleChanged();
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const BarcodeStyle* bcStyle() const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const BarcodeStyle* bcStyle() const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuStyleChanged();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuStyleChanged();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
BarcodeMenu* mMenu;
const BarcodeStyle* mBcStyle;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
BarcodeMenu* mMenu;
const BarcodeStyle* mBcStyle;
};
};
}
#endif // glabels_BarcodeMenuButton_h
#endif // BarcodeMenuButton_h
+24 -30
View File
@@ -21,37 +21,31 @@
#include "BarcodeMenuItem.h"
namespace glabels
///
/// Constructor From Data
///
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent )
: QAction(parent), mBcStyle(bcStyle)
{
setText( bcStyle->name() );
///
/// Constructor From Data
///
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent )
: QAction(parent), mBcStyle(bcStyle)
{
setText( bcStyle->name() );
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
}
///
/// bcStyle Property Getter
///
const BarcodeStyle* BarcodeMenuItem::bcStyle() const
{
return mBcStyle;
}
///
/// onTriggered slot
///
void BarcodeMenuItem::onTriggered()
{
emit activated( mBcStyle );
}
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
}
///
/// bcStyle Property Getter
///
const BarcodeStyle* BarcodeMenuItem::bcStyle() const
{
return mBcStyle;
}
///
/// onTriggered slot
///
void BarcodeMenuItem::onTriggered()
{
emit activated( mBcStyle );
}
+34 -39
View File
@@ -18,60 +18,55 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_BarcodeMenuItem_h
#define glabels_BarcodeMenuItem_h
#ifndef BarcodeMenuItem_h
#define BarcodeMenuItem_h
#include <QAction>
#include "BarcodeStyle.h"
namespace glabels
///
/// Barcode Menu Item
///
class BarcodeMenuItem : public QAction
{
Q_OBJECT
///
/// Barcode Menu Item
///
class BarcodeMenuItem : public QAction
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent = 0 );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated( const BarcodeStyle* bcStyle );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated( const BarcodeStyle* bcStyle );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const BarcodeStyle* bcStyle() const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const BarcodeStyle* bcStyle() const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onTriggered();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onTriggered();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const BarcodeStyle* mBcStyle;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const BarcodeStyle* mBcStyle;
};
};
}
#endif // glabels_BarcodeMenuItem_h
#endif // BarcodeMenuItem_h
+143 -149
View File
@@ -23,160 +23,154 @@
#include <algorithm>
namespace glabels
///
/// Default Constructor
///
BarcodeStyle::BarcodeStyle ()
: mId( "" ),
mBackendId( "" ),
mName( "" ),
mCanText( false ),
mTextOptional( false ),
mCanChecksum( false ),
mChecksumOptional( false ),
mDefaultDigits( "" ),
mCanFreeform( false ),
mPreferedN( 0 )
{
}
///
/// Default Constructor
///
BarcodeStyle::BarcodeStyle ()
: mId( "" ),
mBackendId( "" ),
mName( "" ),
mCanText( false ),
mTextOptional( false ),
mCanChecksum( false ),
mChecksumOptional( false ),
mDefaultDigits( "" ),
mCanFreeform( false ),
mPreferedN( 0 )
///
/// Constructor From Data
///
BarcodeStyle::BarcodeStyle ( const QString& id,
const QString& backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const QString& defaultDigits,
bool canFreeform,
int preferedN )
: mId( id ),
mBackendId( backendId ),
mName( name ),
mCanText( canText ),
mTextOptional( textOptional ),
mCanChecksum( canChecksum ),
mChecksumOptional( checksumOptional ),
mDefaultDigits( defaultDigits ),
mCanFreeform( canFreeform ),
mPreferedN( preferedN )
{
}
///
/// ID Property Getter
///
const QString& BarcodeStyle::id() const
{
return mId;
}
///
/// Backend ID Property Getter
///
const QString& BarcodeStyle::backendId() const
{
return mBackendId;
}
///
/// Name Property Getter
///
const QString& BarcodeStyle::name() const
{
return mName;
}
///
/// Can Text Property Getter
///
bool BarcodeStyle::canText() const
{
return mCanText;
}
///
/// Text Optional Property Getter
///
bool BarcodeStyle::textOptional() const
{
return mTextOptional;
}
///
/// Can Checksum Property Getter
///
bool BarcodeStyle::canChecksum() const
{
return mCanChecksum;
}
///
/// Checksum Optional Property Getter
///
bool BarcodeStyle::checksumOptional() const
{
return mChecksumOptional;
}
///
/// Default Digits Property Getter
///
const QString& BarcodeStyle::defaultDigits() const
{
return mDefaultDigits;
}
///
/// Can Freeform Property Getter
///
bool BarcodeStyle::canFreeform() const
{
return mCanFreeform;
}
///
/// Prefered N Property Getter
///
int BarcodeStyle::preferedN() const
{
return mPreferedN;
}
///
/// Generate Example Digits
///
QString BarcodeStyle::exampleDigits( int n ) const
{
using std::max;
if ( mCanFreeform )
{
return QString( max( n, 1 ), QChar('0') );
}
///
/// Constructor From Data
///
BarcodeStyle::BarcodeStyle ( const QString& id,
const QString& backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const QString& defaultDigits,
bool canFreeform,
int preferedN )
: mId( id ),
mBackendId( backendId ),
mName( name ),
mCanText( canText ),
mTextOptional( textOptional ),
mCanChecksum( canChecksum ),
mChecksumOptional( checksumOptional ),
mDefaultDigits( defaultDigits ),
mCanFreeform( canFreeform ),
mPreferedN( preferedN )
{
}
///
/// ID Property Getter
///
const QString& BarcodeStyle::id() const
{
return mId;
}
///
/// Backend ID Property Getter
///
const QString& BarcodeStyle::backendId() const
{
return mBackendId;
}
///
/// Name Property Getter
///
const QString& BarcodeStyle::name() const
{
return mName;
}
///
/// Can Text Property Getter
///
bool BarcodeStyle::canText() const
{
return mCanText;
}
///
/// Text Optional Property Getter
///
bool BarcodeStyle::textOptional() const
{
return mTextOptional;
}
///
/// Can Checksum Property Getter
///
bool BarcodeStyle::canChecksum() const
{
return mCanChecksum;
}
///
/// Checksum Optional Property Getter
///
bool BarcodeStyle::checksumOptional() const
{
return mChecksumOptional;
}
///
/// Default Digits Property Getter
///
const QString& BarcodeStyle::defaultDigits() const
else
{
return mDefaultDigits;
}
///
/// Can Freeform Property Getter
///
bool BarcodeStyle::canFreeform() const
{
return mCanFreeform;
}
///
/// Prefered N Property Getter
///
int BarcodeStyle::preferedN() const
{
return mPreferedN;
}
///
/// Generate Example Digits
///
QString BarcodeStyle::exampleDigits( int n ) const
{
using std::max;
if ( mCanFreeform )
{
return QString( max( n, 1 ), QChar('0') );
}
else
{
return mDefaultDigits;
}
}
}
+55 -60
View File
@@ -18,88 +18,83 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_BarcodeStyle_h
#define glabels_BarcodeStyle_h
#ifndef BarcodeStyle_h
#define BarcodeStyle_h
#include <QString>
namespace glabels
///
/// Barcode Style Type
///
struct BarcodeStyle
{
///
/// Barcode Style Type
///
struct BarcodeStyle
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeStyle ();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeStyle ();
BarcodeStyle ( const QString& id,
const QString& backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const QString& defaultDigits,
bool canFreeform,
int preferedN );
BarcodeStyle ( const QString& id,
const QString& backendId,
const QString& name,
bool canText,
bool textOptional,
bool canChecksum,
bool checksumOptional,
const QString& defaultDigits,
bool canFreeform,
int preferedN );
/////////////////////////////////
// Properties
/////////////////////////////////
const QString& id() const;
/////////////////////////////////
// Properties
/////////////////////////////////
const QString& id() const;
const QString& backendId() const;
const QString& backendId() const;
const QString& name() const;
const QString& name() const;
bool canText() const;
bool canText() const;
bool textOptional() const;
bool textOptional() const;
bool canChecksum() const;
bool canChecksum() const;
bool checksumOptional() const;
bool checksumOptional() const;
const QString& defaultDigits() const;
const QString& defaultDigits() const;
bool canFreeform() const;
bool canFreeform() const;
int preferedN() const;
int preferedN() const;
/////////////////////////////////
// Methods
/////////////////////////////////
public:
QString exampleDigits( int n ) const;
/////////////////////////////////
// Methods
/////////////////////////////////
public:
QString exampleDigits( int n ) const;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
QString mId;
QString mBackendId;
QString mName;
bool mCanText;
bool mTextOptional;
bool mCanChecksum;
bool mChecksumOptional;
QString mDefaultDigits;
bool mCanFreeform;
int mPreferedN;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
QString mId;
QString mBackendId;
QString mName;
bool mCanText;
bool mTextOptional;
bool mCanChecksum;
bool mChecksumOptional;
QString mDefaultDigits;
bool mCanFreeform;
int mPreferedN;
};
};
}
#endif // glabels_BarcodeStyle_h
#endif // BarcodeStyle_h
+116 -122
View File
@@ -33,134 +33,128 @@ namespace
}
namespace glabels
ColorButton::ColorButton( QWidget* parent )
: QPushButton( parent )
{
}
ColorButton::ColorButton( QWidget* parent )
: QPushButton( parent )
void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color )
{
mDefaultColor = defaultColor;
mColorNode = ColorNode( color );
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
setText( "" );
setCheckable( true );
mDialog = new ColorPaletteDialog( defaultLabel, defaultColor, color );
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
connect( mDialog, SIGNAL(colorChanged(ColorNode,bool)),
this, SLOT(onPaletteDialogChanged(ColorNode,bool)) );
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
}
void ColorButton::setColorNode( ColorNode colorNode )
{
mIsDefault = false;
mColorNode = colorNode;
if ( colorNode.fieldFlag() )
{
setIcon( QIcon() );
setText( colorNode.key() );
}
void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color )
else
{
mDefaultColor = defaultColor;
mColorNode = ColorNode( color );
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
setText( "" );
setCheckable( true );
mDialog = new ColorPaletteDialog( defaultLabel, defaultColor, color );
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
connect( mDialog, SIGNAL(colorChanged(ColorNode,bool)),
this, SLOT(onPaletteDialogChanged(ColorNode,bool)) );
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
}
void ColorButton::setColorNode( ColorNode colorNode )
{
mIsDefault = false;
mColorNode = colorNode;
if ( colorNode.fieldFlag() )
{
setIcon( QIcon() );
setText( colorNode.key() );
}
else
{
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
setText( "" );
}
}
void ColorButton::setColor( QColor color )
{
mIsDefault = false;
mColorNode.setFieldFlag( false );
mColorNode.setColor( color );
mColorNode.setKey( "" );
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
setText( "" );
}
void ColorButton::setToDefault()
{
mIsDefault = true;
mColorNode.setFieldFlag( false );
mColorNode.setColor( mDefaultColor );
mColorNode.setKey( "" );
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
setText( "" );
}
ColorNode ColorButton::colorNode()
{
return mColorNode;
}
void ColorButton::setKeys( const QList<QString> keyList )
{
mDialog->setKeys( keyList );
}
void ColorButton::clearKeys()
{
mDialog->clearKeys();
}
void ColorButton::onButtonToggled( bool checked )
{
if ( checked )
{
///
/// @TODO: improve positioning of dialog -- near edges of screen.
///
QPoint dialogPos( 0, height() );
mDialog->move( mapToGlobal(dialogPos) );
mDialog->show();
}
}
void ColorButton::onPaletteDialogAccepted()
{
setChecked( false );
}
void ColorButton::onPaletteDialogRejected()
{
setChecked( false );
}
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
{
mColorNode = colorNode;
mIsDefault = isDefault;
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
setText( "" );
emit colorChanged();
}
}
void ColorButton::setColor( QColor color )
{
mIsDefault = false;
mColorNode.setFieldFlag( false );
mColorNode.setColor( color );
mColorNode.setKey( "" );
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
setText( "" );
}
void ColorButton::setToDefault()
{
mIsDefault = true;
mColorNode.setFieldFlag( false );
mColorNode.setColor( mDefaultColor );
mColorNode.setKey( "" );
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
setText( "" );
}
ColorNode ColorButton::colorNode()
{
return mColorNode;
}
void ColorButton::setKeys( const QList<QString> keyList )
{
mDialog->setKeys( keyList );
}
void ColorButton::clearKeys()
{
mDialog->clearKeys();
}
void ColorButton::onButtonToggled( bool checked )
{
if ( checked )
{
///
/// @TODO: improve positioning of dialog -- near edges of screen.
///
QPoint dialogPos( 0, height() );
mDialog->move( mapToGlobal(dialogPos) );
mDialog->show();
}
}
void ColorButton::onPaletteDialogAccepted()
{
setChecked( false );
}
void ColorButton::onPaletteDialogRejected()
{
setChecked( false );
}
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
{
mColorNode = colorNode;
mIsDefault = isDefault;
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
setText( "" );
emit colorChanged();
}
+50 -55
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_ColorButton_h
#define glabels_ColorButton_h
#ifndef ColorButton_h
#define ColorButton_h
#include <QPushButton>
@@ -27,72 +27,67 @@
#include "ColorPaletteDialog.h"
namespace glabels
///
/// Color Button
///
class ColorButton : public QPushButton
{
///
/// Color Button
///
class ColorButton : public QPushButton
{
Q_OBJECT
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorButton( QWidget* parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorButton( QWidget* parent = 0 );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void colorChanged();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void colorChanged();
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color );
void setColorNode( ColorNode colorNode );
void setColor( QColor color );
void setToDefault();
ColorNode colorNode();
void setKeys( const QList<QString> keyList );
void clearKeys();
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color );
void setColorNode( ColorNode colorNode );
void setColor( QColor color );
void setToDefault();
ColorNode colorNode();
void setKeys( const QList<QString> keyList );
void clearKeys();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onButtonToggled( bool checked );
void onPaletteDialogAccepted();
void onPaletteDialogRejected();
void onPaletteDialogChanged( ColorNode colorNode, bool isDefault );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onButtonToggled( bool checked );
void onPaletteDialogAccepted();
void onPaletteDialogRejected();
void onPaletteDialogChanged( ColorNode colorNode, bool isDefault );
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
/////////////////////////////////
// Private Members
/////////////////////////////////
private:
QColor mDefaultColor;
bool mIsDefault;
ColorNode mColorNode;
/////////////////////////////////
// Private Members
/////////////////////////////////
private:
QColor mDefaultColor;
bool mIsDefault;
ColorNode mColorNode;
ColorPaletteDialog* mDialog;
};
}
ColorPaletteDialog* mDialog;
};
#endif // glabels_ColorButton_h
#endif // ColorButton_h
+89 -94
View File
@@ -23,99 +23,94 @@
#include <QSettings>
namespace glabels
ColorHistory::ColorHistory()
{
ColorHistory::ColorHistory()
{
}
ColorHistory* ColorHistory::instance()
{
static ColorHistory* singletonInstance = 0;
if ( singletonInstance == 0 )
{
singletonInstance = new ColorHistory();
}
return singletonInstance;
}
void ColorHistory::addColor( const QColor &color )
{
QColor oldColors[MAX_COLORS];
QColor newColors[MAX_COLORS];
int n;
readColorArray( oldColors, &n );
int i;
newColors[0] = color;
for ( i = 0; ( i < (MAX_COLORS-1) ) && (i < n); i++ )
{
newColors[i+1] = oldColors[i];
}
writeColorArray( newColors, i+1 );
emit changed();
}
QColor ColorHistory::getColor( int i )
{
QColor colors[MAX_COLORS];
int n;
readColorArray( colors, &n );
if ( (n > 0) && (i < n) )
{
return colors[i];
}
else
{
return QColor( 0, 0, 0, 0 );
}
}
void ColorHistory::readColorArray( QColor array[MAX_COLORS], int* n )
{
QSettings settings;
settings.beginGroup( "ColorHistory" );
settings.beginReadArray( "history" );
*n = settings.value( "history/size", 0 ).toInt();
for ( int i = 0; i < *n; i++ )
{
settings.setArrayIndex(i);
array[i] = settings.value( "color" ).value<QColor>();
}
settings.endArray();
settings.endGroup();
}
void ColorHistory::writeColorArray( const QColor array[MAX_COLORS], int n )
{
QSettings settings;
settings.beginGroup( "ColorHistory" );
settings.beginWriteArray( "history" );
for ( int i = 0; (i < n) && (i < MAX_COLORS); i++ )
{
settings.setArrayIndex(i);
settings.setValue( "color", array[i] );
}
settings.endArray();
settings.endGroup();
}
}
ColorHistory* ColorHistory::instance()
{
static ColorHistory* singletonInstance = 0;
if ( singletonInstance == 0 )
{
singletonInstance = new ColorHistory();
}
return singletonInstance;
}
void ColorHistory::addColor( const QColor &color )
{
QColor oldColors[MAX_COLORS];
QColor newColors[MAX_COLORS];
int n;
readColorArray( oldColors, &n );
int i;
newColors[0] = color;
for ( i = 0; ( i < (MAX_COLORS-1) ) && (i < n); i++ )
{
newColors[i+1] = oldColors[i];
}
writeColorArray( newColors, i+1 );
emit changed();
}
QColor ColorHistory::getColor( int i )
{
QColor colors[MAX_COLORS];
int n;
readColorArray( colors, &n );
if ( (n > 0) && (i < n) )
{
return colors[i];
}
else
{
return QColor( 0, 0, 0, 0 );
}
}
void ColorHistory::readColorArray( QColor array[MAX_COLORS], int* n )
{
QSettings settings;
settings.beginGroup( "ColorHistory" );
settings.beginReadArray( "history" );
*n = settings.value( "history/size", 0 ).toInt();
for ( int i = 0; i < *n; i++ )
{
settings.setArrayIndex(i);
array[i] = settings.value( "color" ).value<QColor>();
}
settings.endArray();
settings.endGroup();
}
void ColorHistory::writeColorArray( const QColor array[MAX_COLORS], int n )
{
QSettings settings;
settings.beginGroup( "ColorHistory" );
settings.beginWriteArray( "history" );
for ( int i = 0; (i < n) && (i < MAX_COLORS); i++ )
{
settings.setArrayIndex(i);
settings.setValue( "color", array[i] );
}
settings.endArray();
settings.endGroup();
}
+39 -44
View File
@@ -18,67 +18,62 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_ColorHistory_h
#define glabels_ColorHistory_h
#ifndef ColorHistory_h
#define ColorHistory_h
#include <QObject>
#include <QColor>
namespace glabels
///
/// Barcode Backends Database
///
class ColorHistory : public QObject
{
Q_OBJECT
///
/// Barcode Backends Database
///
class ColorHistory : public QObject
{
Q_OBJECT
public:
static const int MAX_COLORS = 10;
public:
static const int MAX_COLORS = 10;
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
ColorHistory();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
private:
ColorHistory();
public:
static ColorHistory* instance();
public:
static ColorHistory* instance();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void changed();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void changed();
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void addColor( const QColor &color );
QColor getColor( int i );
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void addColor( const QColor &color );
QColor getColor( int i );
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
void readColorArray( QColor array[MAX_COLORS], int* n );
void writeColorArray( const QColor array[MAX_COLORS], int n );
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
void readColorArray( QColor array[MAX_COLORS], int* n );
void writeColorArray( const QColor array[MAX_COLORS], int n );
/////////////////////////////////
// Private Members
/////////////////////////////////
private:
/////////////////////////////////
// Private Members
/////////////////////////////////
private:
};
}
};
#endif // glabels_ColorHistory_h
#endif // ColorHistory_h
+130 -136
View File
@@ -21,183 +21,177 @@
#include "ColorNode.h"
namespace glabels
///
/// Default Constructor
///
ColorNode::ColorNode()
: mFieldFlag(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
{
///
/// Default Constructor
///
ColorNode::ColorNode()
: mFieldFlag(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
{
}
}
///
/// Constructor From Data
///
ColorNode::ColorNode( bool fieldFlag, const QColor& color, const QString& key )
: mFieldFlag(fieldFlag), mColor(color), mKey(key)
{
}
///
/// Constructor From Data
///
ColorNode::ColorNode( bool fieldFlag, const QColor& color, const QString& key )
: mFieldFlag(fieldFlag), mColor(color), mKey(key)
{
}
///
/// Constructor From Data
///
ColorNode::ColorNode( bool fieldFlag, uint32_t rgba, const QString& key )
: mFieldFlag(fieldFlag), mKey(key)
{
mColor = QColor( (rgba >> 24) & 0xFF,
(rgba >> 16) & 0xFF,
(rgba >> 8) & 0xFF,
(rgba ) & 0xFF );
}
///
/// Constructor From Data
///
ColorNode::ColorNode( bool fieldFlag, uint32_t rgba, const QString& key )
: mFieldFlag(fieldFlag), mKey(key)
{
mColor = QColor( (rgba >> 24) & 0xFF,
(rgba >> 16) & 0xFF,
(rgba >> 8) & 0xFF,
(rgba ) & 0xFF );
}
///
/// Constructor From Color
///
ColorNode::ColorNode( const QColor& color )
: mFieldFlag(false), mColor(color), mKey("")
{
}
///
/// Constructor From Color
///
ColorNode::ColorNode( const QColor& color )
: mFieldFlag(false), mColor(color), mKey("")
{
}
///
/// Constructor From Key
///
ColorNode::ColorNode( const QString& key )
: mFieldFlag(true), mColor(QColor::fromRgba(0x00000000)), mKey(key)
{
}
///
/// Constructor From Key
///
ColorNode::ColorNode( const QString& key )
: mFieldFlag(true), mColor(QColor::fromRgba(0x00000000)), mKey(key)
{
}
///
/// == Operator
///
bool ColorNode::operator==( const ColorNode& cn )
{
return ( (mFieldFlag == cn.mFieldFlag) &&
(mColor == cn.mColor) &&
(mKey == cn.mKey) );
}
///
/// == Operator
///
bool ColorNode::operator==( const ColorNode& cn )
{
return ( (mFieldFlag == cn.mFieldFlag) &&
(mColor == cn.mColor) &&
(mKey == cn.mKey) );
}
///
/// != Operator
///
bool ColorNode::operator!=( const ColorNode& cn )
{
return ( (mFieldFlag != cn.mFieldFlag) ||
(mColor != cn.mColor) ||
(mKey != cn.mKey) );
}
///
/// != Operator
///
bool ColorNode::operator!=( const ColorNode& cn )
{
return ( (mFieldFlag != cn.mFieldFlag) ||
(mColor != cn.mColor) ||
(mKey != cn.mKey) );
}
///
/// Field Flag Property Getter
///
bool ColorNode::fieldFlag( void ) const
{
return mFieldFlag;
}
///
/// Field Flag Property Getter
///
bool ColorNode::fieldFlag( void ) const
{
return mFieldFlag;
}
///
/// Field Flag Property Setter
///
void ColorNode::setFieldFlag( bool fieldFlag )
{
mFieldFlag = fieldFlag;
}
///
/// Field Flag Property Setter
///
void ColorNode::setFieldFlag( bool fieldFlag )
{
mFieldFlag = fieldFlag;
}
///
/// Color Property Getter
///
const QColor& ColorNode::color( void ) const
{
return mColor;
}
///
/// Color Property Getter
///
const QColor& ColorNode::color( void ) const
{
return mColor;
}
///
/// Color Property Setter
///
void ColorNode::setColor( const QColor& color )
{
mColor = color;
}
///
/// Color Property Setter
///
void ColorNode::setColor( const QColor& color )
{
mColor = color;
}
///
/// Key Property Getter
///
const QString& ColorNode::key( void ) const
{
return mKey;
}
///
/// Key Property Getter
///
const QString& ColorNode::key( void ) const
{
return mKey;
}
///
/// Key Property Setter
///
void ColorNode::setKey( const QString& key )
{
mKey = key;
}
///
/// Key Property Setter
///
void ColorNode::setKey( const QString& key )
{
mKey = key;
}
uint32_t ColorNode::rgba( void ) const
{
uint32_t c =
mColor.red() << 24 |
mColor.green() << 16 |
mColor.blue() << 8 |
mColor.alpha();
uint32_t ColorNode::rgba( void ) const
{
uint32_t c =
mColor.red() << 24 |
mColor.green() << 16 |
mColor.blue() << 8 |
mColor.alpha();
return c;
}
return c;
}
#if TODO
QColor ColorNode::expand( MergeRecord? record )
QColor ColorNode::expand( MergeRecord? record )
{
if ( fieldFlag )
{
if ( fieldFlag )
if ( record == null )
{
if ( record == null )
return QColor.fromRgba(0x00000000);
}
else
{
string? text = record.evalKey( key );
if ( text != null )
{
return QColor.fromRgba(0x00000000);
}
else
{
string? text = record.evalKey( key );
if ( text != null )
Gdk.Color gdkColor = Gdk.Color();
if ( Gdk.Color.parse( text, out gdkColor ) )
{
Gdk.Color gdkColor = Gdk.Color();
if ( Gdk.Color.parse( text, out gdkColor ) )
{
Color color = Color.from_gdkColor( gdkColor );
return color;
}
else
{
return Color.fromRgba(0x00000000);
}
Color color = Color.from_gdkColor( gdkColor );
return color;
}
else
{
return Color.fromRgba(0x00000000);
}
}
}
else
{
return color;
else
{
return Color.fromRgba(0x00000000);
}
}
}
#endif
else
{
return color;
}
}
#endif
+55 -59
View File
@@ -18,94 +18,90 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_ColorNode_h
#define glabels_ColorNode_h
#ifndef ColorNode_h
#define ColorNode_h
#include <QString>
#include <QColor>
#include <stdint.h>
namespace glabels
///
/// Color Node Type
///
struct ColorNode
{
///
/// Color Node Type
///
struct ColorNode
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorNode();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorNode();
ColorNode( bool fieldFlag, const QColor& color, const QString& key );
ColorNode( bool fieldFlag, const QColor& color, const QString& key );
ColorNode( bool fieldFlag, uint32_t rgba, const QString& key );
ColorNode( bool fieldFlag, uint32_t rgba, const QString& key );
ColorNode( const QColor& color );
ColorNode( const QColor& color );
ColorNode( const QString& key );
ColorNode( const QString& key );
/////////////////////////////////
// Operators
/////////////////////////////////
public:
bool operator==( const ColorNode& cn );
/////////////////////////////////
// Operators
/////////////////////////////////
public:
bool operator==( const ColorNode& cn );
bool operator!=( const ColorNode& cn );
bool operator!=( const ColorNode& cn );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
//
// Field Flag Property
//
bool fieldFlag( void ) const;
void setFieldFlag( bool fieldFlag );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
//
// Field Flag Property
//
bool fieldFlag( void ) const;
void setFieldFlag( bool fieldFlag );
//
// Color Property
//
const QColor& color( void ) const;
void setColor( const QColor& color );
//
// Color Property
//
const QColor& color( void ) const;
void setColor( const QColor& color );
//
// Key Property
//
const QString& key( void ) const;
void setKey( const QString& key );
//
// Key Property
//
const QString& key( void ) const;
void setKey( const QString& key );
/////////////////////////////////
// Methods
/////////////////////////////////
public:
uint32_t rgba( void ) const;
/////////////////////////////////
// Methods
/////////////////////////////////
public:
uint32_t rgba( void ) const;
#if TODO
QColor expand( MergeRecord? record );
QColor expand( MergeRecord? record );
#endif
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
bool mFieldFlag;
QColor mColor;
QString mKey;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
bool mFieldFlag;
QColor mColor;
QString mKey;
};
};
}
#endif // glabels_ColorNode_h
#endif // ColorNode_h
+79 -85
View File
@@ -36,91 +36,85 @@ namespace
}
namespace glabels
///
/// Constructor From Data
///
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
: QWidget(parent), mText(text), mHover(false)
{
///
/// Constructor From Data
///
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
: QWidget(parent), mText(text), mHover(false)
{
setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
setMinimumSize( hBox+2*border+1, hBox+2*border+1 );
}
///
/// Paint Event
///
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
{
QPainter painter(this);
//
// Draw background
//
if ( mHover )
{
QLinearGradient gradient( 0, 0, 0, height() );
gradient.setColorAt( 0, palette().color( QPalette::Highlight ).lighter() );
gradient.setColorAt( 1, palette().color( QPalette::Highlight ) );
painter.setBrush( QBrush( gradient ) );
QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( outlineWidthPixels );
painter.setPen( pen );
painter.drawRect( 0, 0, width()-1, height()-1 );
}
//
// Draw text
//
painter.setBrush( QBrush( Qt::NoBrush ) );
if ( mHover )
{
painter.setPen( QPen( palette().color( QPalette::HighlightedText ) ) );
}
else
{
painter.setPen( QPen( palette().color( QPalette::Text ) ) );
}
QRect textRect( border, border, width()-2*border, hBox );
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
}
///
/// Enter Event
///
void ColorPaletteButtonItem::enterEvent( QEvent* event )
{
mHover = true;
update();
}
///
/// Leave Event
///
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
{
mHover = false;
update();
}
///
/// Mouse Press Event
///
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
{
emit activated();
}
setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
setMinimumSize( hBox+2*border+1, hBox+2*border+1 );
}
///
/// Paint Event
///
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
{
QPainter painter(this);
//
// Draw background
//
if ( mHover )
{
QLinearGradient gradient( 0, 0, 0, height() );
gradient.setColorAt( 0, palette().color( QPalette::Highlight ).lighter() );
gradient.setColorAt( 1, palette().color( QPalette::Highlight ) );
painter.setBrush( QBrush( gradient ) );
QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( outlineWidthPixels );
painter.setPen( pen );
painter.drawRect( 0, 0, width()-1, height()-1 );
}
//
// Draw text
//
painter.setBrush( QBrush( Qt::NoBrush ) );
if ( mHover )
{
painter.setPen( QPen( palette().color( QPalette::HighlightedText ) ) );
}
else
{
painter.setPen( QPen( palette().color( QPalette::Text ) ) );
}
QRect textRect( border, border, width()-2*border, hBox );
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
}
///
/// Enter Event
///
void ColorPaletteButtonItem::enterEvent( QEvent* event )
{
mHover = true;
update();
}
///
/// Leave Event
///
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
{
mHover = false;
update();
}
///
/// Mouse Press Event
///
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
{
emit activated();
}
+33 -38
View File
@@ -18,57 +18,52 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_ColorPaletteButtonItem_h
#define glabels_ColorPaletteButtonItem_h
#ifndef ColorPaletteButtonItem_h
#define ColorPaletteButtonItem_h
#include <QWidget>
#include <QColor>
namespace glabels
///
/// Color Palette Item
///
class ColorPaletteButtonItem : public QWidget
{
Q_OBJECT
///
/// Color Palette Item
///
class ColorPaletteButtonItem : public QWidget
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorPaletteButtonItem( const QString& text, QWidget* parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorPaletteButtonItem( const QString& text, QWidget* parent = 0 );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated();
/////////////////////////////////
// Event handlers
/////////////////////////////////
protected:
void paintEvent( QPaintEvent* event );
void enterEvent( QEvent* event );
void leaveEvent( QEvent* event );
void mousePressEvent( QMouseEvent* event );
/////////////////////////////////
// Event handlers
/////////////////////////////////
protected:
void paintEvent( QPaintEvent* event );
void enterEvent( QEvent* event );
void leaveEvent( QEvent* event );
void mousePressEvent( QMouseEvent* event );
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
QString mText;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
QString mText;
bool mHover;
};
bool mHover;
};
}
#endif // glabels_ColorPaletteButtonItem_h
#endif // ColorPaletteButtonItem_h
+187 -192
View File
@@ -29,210 +29,205 @@
#include <QFrame>
namespace glabels
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
{ "#ef2929", tr("Light Scarlet Red", "Color name") },
{ "#fcaf3e", tr("Light Orange", "Color name") },
{ "#fce94f", tr("Light Butter", "Color name") },
{ "#8ae234", tr("Light Chameleon", "Color name") },
{ "#729fcf", tr("Light Sky Blue", "Color name") },
{ "#ad7fa8", tr("Light Plum", "Color name") },
{ "#e9b96e", tr("Light Chocolate", "Color name") },
{ "#888a85", tr("Light Aluminum 1", "Color name") },
{ "#eeeeec", tr("Light Aluminum 2", "Color name") },
{ "#cc0000", tr("Scarlet Red", "Color name") },
{ "#f57900", tr("Orange", "Color name") },
{ "#edd400", tr("Butter", "Color name") },
{ "#73d216", tr("Chameleon", "Color name") },
{ "#3465a4", tr("Sky Blue", "Color name") },
{ "#75507b", tr("Plum", "Color name") },
{ "#c17d11", tr("Chocolate", "Color name") },
{ "#555753", tr("Aluminum 1", "Color name") },
{ "#d3d7cf", tr("Aluminum 2", "Color name") },
{ "#a40000", tr("Dark Scarlet Red", "Color name") },
{ "#ce5c00", tr("Dark Orange", "Color name") },
{ "#c4a000", tr("Dark Butter", "Color name") },
{ "#4e9a06", tr("Dark Chameleon", "Color name") },
{ "#204a87", tr("Dark Sky Blue", "Color name") },
{ "#5c3566", tr("Dark Plum", "Color name") },
{ "#8f5902", tr("Dark Chocolate", "Color name") },
{ "#2e3436", tr("Dark Aluminum 1", "Color name") },
{ "#babdb6", tr("Dark Aluminum 2", "Color name") },
{ "#000000", tr("Black", "Color name") },
{ "#2e3436", tr("Very Dark Gray", "Color name") },
{ "#555753", tr("Darker Gray", "Color name") },
{ "#888a85", tr("Dark Gray", "Color name") },
{ "#babdb6", tr("Medium Gray", "Color name") },
{ "#d3d7cf", tr("Light Gray", "Color name") },
{ "#eeeeec", tr("Lighter Gray", "Color name") },
{ "#f3f3f3", tr("Very Light Gray", "Color name") },
{ "#ffffff", tr("White", "Color name") }
};
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color,
QWidget* parent )
: QDialog( parent )
{
mColorHistory = ColorHistory::instance();
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
mDefaultColor = defaultColor;
mColorNode = ColorNode( color );
{ "#ef2929", tr("Light Scarlet Red", "Color name") },
{ "#fcaf3e", tr("Light Orange", "Color name") },
{ "#fce94f", tr("Light Butter", "Color name") },
{ "#8ae234", tr("Light Chameleon", "Color name") },
{ "#729fcf", tr("Light Sky Blue", "Color name") },
{ "#ad7fa8", tr("Light Plum", "Color name") },
{ "#e9b96e", tr("Light Chocolate", "Color name") },
{ "#888a85", tr("Light Aluminum 1", "Color name") },
{ "#eeeeec", tr("Light Aluminum 2", "Color name") },
setStyleSheet( ".glabels--ColorPaletteDialog {background: white; border: 1px solid black}" );
setWindowFlags( Qt::Popup | Qt::FramelessWindowHint );
{ "#cc0000", tr("Scarlet Red", "Color name") },
{ "#f57900", tr("Orange", "Color name") },
{ "#edd400", tr("Butter", "Color name") },
{ "#73d216", tr("Chameleon", "Color name") },
{ "#3465a4", tr("Sky Blue", "Color name") },
{ "#75507b", tr("Plum", "Color name") },
{ "#c17d11", tr("Chocolate", "Color name") },
{ "#555753", tr("Aluminum 1", "Color name") },
{ "#d3d7cf", tr("Aluminum 2", "Color name") },
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->setContentsMargins( 0, 0, 0, 0 );
vLayout->setSpacing( 0 );
{ "#a40000", tr("Dark Scarlet Red", "Color name") },
{ "#ce5c00", tr("Dark Orange", "Color name") },
{ "#c4a000", tr("Dark Butter", "Color name") },
{ "#4e9a06", tr("Dark Chameleon", "Color name") },
{ "#204a87", tr("Dark Sky Blue", "Color name") },
{ "#5c3566", tr("Dark Plum", "Color name") },
{ "#8f5902", tr("Dark Chocolate", "Color name") },
{ "#2e3436", tr("Dark Aluminum 1", "Color name") },
{ "#babdb6", tr("Dark Aluminum 2", "Color name") },
{ "#000000", tr("Black", "Color name") },
{ "#2e3436", tr("Very Dark Gray", "Color name") },
{ "#555753", tr("Darker Gray", "Color name") },
{ "#888a85", tr("Dark Gray", "Color name") },
{ "#babdb6", tr("Medium Gray", "Color name") },
{ "#d3d7cf", tr("Light Gray", "Color name") },
{ "#eeeeec", tr("Lighter Gray", "Color name") },
{ "#f3f3f3", tr("Very Light Gray", "Color name") },
{ "#ffffff", tr("White", "Color name") }
};
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color,
QWidget* parent )
: QDialog( parent )
{
mColorHistory = ColorHistory::instance();
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
mDefaultColor = defaultColor;
mColorNode = ColorNode( color );
setStyleSheet( ".glabels--ColorPaletteDialog {background: white; border: 1px solid black}" );
setWindowFlags( Qt::Popup | Qt::FramelessWindowHint );
QVBoxLayout* vLayout = new QVBoxLayout();
vLayout->setContentsMargins( 0, 0, 0, 0 );
vLayout->setSpacing( 0 );
ColorPaletteButtonItem* defaultButton = new ColorPaletteButtonItem( defaultLabel );
connect( defaultButton, SIGNAL(activated()), this, SLOT(onDefaultItemActivated()) );
vLayout->addWidget( defaultButton );
ColorPaletteButtonItem* defaultButton = new ColorPaletteButtonItem( defaultLabel );
connect( defaultButton, SIGNAL(activated()), this, SLOT(onDefaultItemActivated()) );
vLayout->addWidget( defaultButton );
QFrame* hline1 = new QFrame;
hline1->setFrameStyle( QFrame::HLine | QFrame::Plain );
hline1->setLineWidth( 1 );
vLayout->addWidget( hline1 );
QFrame* hline1 = new QFrame;
hline1->setFrameStyle( QFrame::HLine | QFrame::Plain );
hline1->setLineWidth( 1 );
vLayout->addWidget( hline1 );
QGridLayout* mainPaletteLayout = new QGridLayout();
mainPaletteLayout->setSpacing( 0 );
for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ )
{
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
{
int i = iRow*PALETTE_COLS + iCol;
ColorPaletteItem* item = new ColorPaletteItem( i,
QColor( mColorTable[i].colorSpec ),
mColorTable[i].name );
connect( item, SIGNAL(activated(int)), this, SLOT(onPaletteItemActivated(int)) );
mainPaletteLayout->addWidget( item, iRow, iCol );
}
}
vLayout->addLayout( mainPaletteLayout );
QFrame* hline2 = new QFrame;
hline2->setFrameStyle( QFrame::HLine | QFrame::Plain );
hline2->setLineWidth( 1 );
vLayout->addWidget( hline2 );
QHBoxLayout* customPaletteLayout = new QHBoxLayout();
customPaletteLayout->setSpacing( 0 );
QGridLayout* mainPaletteLayout = new QGridLayout();
mainPaletteLayout->setSpacing( 0 );
for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ )
{
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
{
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
mHistoryItem[iCol]->setEnabled( false );
connect( mHistoryItem[iCol], SIGNAL(activated(int)), this, SLOT(onHistoryItemActivated(int)) );
int i = iRow*PALETTE_COLS + iCol;
customPaletteLayout->addWidget( mHistoryItem[iCol] );
}
vLayout->addLayout( customPaletteLayout );
ColorPaletteItem* item = new ColorPaletteItem( i,
QColor( mColorTable[i].colorSpec ),
mColorTable[i].name );
connect( item, SIGNAL(activated(int)), this, SLOT(onPaletteItemActivated(int)) );
QFrame* hline3 = new QFrame;
hline3->setFrameStyle( QFrame::HLine | QFrame::Plain );
hline3->setLineWidth( 1 );
vLayout->addWidget( hline3 );
ColorPaletteButtonItem* customColorButton = new ColorPaletteButtonItem( tr("Custom color") );
connect( customColorButton, SIGNAL(activated()), this, SLOT(onCustomColorItemActivated()) );
vLayout->addWidget( customColorButton );
QFrame* hline4 = new QFrame;
hline4->setFrameStyle( QFrame::HLine | QFrame::Plain );
hline4->setLineWidth( 1 );
vLayout->addWidget( hline4 );
ColorPaletteButtonItem* mergeFieldButton = new ColorPaletteButtonItem( "TODO: Field Button" );
vLayout->addWidget( mergeFieldButton );
setLayout( vLayout );
loadCustomColorHistory();
}
void ColorPaletteDialog::setKeys( const QList<QString> keyList )
{
// TODO
}
void ColorPaletteDialog::clearKeys()
{
// TODO
}
void ColorPaletteDialog::onDefaultItemActivated()
{
mColorNode.setFieldFlag( false );
mColorNode.setColor( mDefaultColor );
mColorNode.setKey( "" );
emit colorChanged( mColorNode, true );
accept();
}
void ColorPaletteDialog::onPaletteItemActivated( int id )
{
mColorNode.setFieldFlag( false );
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
mColorNode.setKey( "" );
emit colorChanged( mColorNode, false );
accept();
}
void ColorPaletteDialog::onHistoryItemActivated( int id )
{
mColorNode.setFieldFlag( false );
mColorNode.setColor( mColorHistory->getColor( id ) );
mColorNode.setKey( "" );
emit colorChanged( mColorNode, false );
accept();
}
void ColorPaletteDialog::onCustomColorItemActivated()
{
// TODO
accept();
}
void ColorPaletteDialog::onColorHistoryChanged()
{
loadCustomColorHistory();
}
void ColorPaletteDialog::loadCustomColorHistory()
{
for ( int i = 0; i < PALETTE_COLS; i++ )
{
QColor color = mColorHistory->getColor( i );
if ( color.alpha() != 0 )
{
mHistoryItem[i]->setColor( i, color, QString(tr("Custom color #%d").arg(i) ) );
mHistoryItem[i]->setEnabled( true );
}
mainPaletteLayout->addWidget( item, iRow, iCol );
}
}
vLayout->addLayout( mainPaletteLayout );
QFrame* hline2 = new QFrame;
hline2->setFrameStyle( QFrame::HLine | QFrame::Plain );
hline2->setLineWidth( 1 );
vLayout->addWidget( hline2 );
QHBoxLayout* customPaletteLayout = new QHBoxLayout();
customPaletteLayout->setSpacing( 0 );
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
{
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
mHistoryItem[iCol]->setEnabled( false );
connect( mHistoryItem[iCol], SIGNAL(activated(int)), this, SLOT(onHistoryItemActivated(int)) );
customPaletteLayout->addWidget( mHistoryItem[iCol] );
}
vLayout->addLayout( customPaletteLayout );
QFrame* hline3 = new QFrame;
hline3->setFrameStyle( QFrame::HLine | QFrame::Plain );
hline3->setLineWidth( 1 );
vLayout->addWidget( hline3 );
ColorPaletteButtonItem* customColorButton = new ColorPaletteButtonItem( tr("Custom color") );
connect( customColorButton, SIGNAL(activated()), this, SLOT(onCustomColorItemActivated()) );
vLayout->addWidget( customColorButton );
QFrame* hline4 = new QFrame;
hline4->setFrameStyle( QFrame::HLine | QFrame::Plain );
hline4->setLineWidth( 1 );
vLayout->addWidget( hline4 );
ColorPaletteButtonItem* mergeFieldButton = new ColorPaletteButtonItem( "TODO: Field Button" );
vLayout->addWidget( mergeFieldButton );
setLayout( vLayout );
loadCustomColorHistory();
}
void ColorPaletteDialog::setKeys( const QList<QString> keyList )
{
// TODO
}
void ColorPaletteDialog::clearKeys()
{
// TODO
}
void ColorPaletteDialog::onDefaultItemActivated()
{
mColorNode.setFieldFlag( false );
mColorNode.setColor( mDefaultColor );
mColorNode.setKey( "" );
emit colorChanged( mColorNode, true );
accept();
}
void ColorPaletteDialog::onPaletteItemActivated( int id )
{
mColorNode.setFieldFlag( false );
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
mColorNode.setKey( "" );
emit colorChanged( mColorNode, false );
accept();
}
void ColorPaletteDialog::onHistoryItemActivated( int id )
{
mColorNode.setFieldFlag( false );
mColorNode.setColor( mColorHistory->getColor( id ) );
mColorNode.setKey( "" );
emit colorChanged( mColorNode, false );
accept();
}
void ColorPaletteDialog::onCustomColorItemActivated()
{
// TODO
accept();
}
void ColorPaletteDialog::onColorHistoryChanged()
{
loadCustomColorHistory();
}
void ColorPaletteDialog::loadCustomColorHistory()
{
for ( int i = 0; i < PALETTE_COLS; i++ )
{
QColor color = mColorHistory->getColor( i );
if ( color.alpha() != 0 )
{
mHistoryItem[i]->setColor( i, color, QString(tr("Custom color #%d").arg(i) ) );
mHistoryItem[i]->setEnabled( true );
}
}
}
+57 -62
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_ColorPaletteDialog_h
#define glabels_ColorPaletteDialog_h
#ifndef ColorPaletteDialog_h
#define ColorPaletteDialog_h
#include <QObject>
#include <QDialog>
@@ -29,83 +29,78 @@
#include "ColorPaletteItem.h"
namespace glabels
///
/// Color Palette Dialog
///
class ColorPaletteDialog : public QDialog
{
///
/// Color Palette Dialog
///
class ColorPaletteDialog : public QDialog
{
Q_OBJECT
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorPaletteDialog( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color,
QWidget* parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorPaletteDialog( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color,
QWidget* parent = 0 );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void colorChanged( ColorNode colorNode, bool isDefault );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void colorChanged( ColorNode colorNode, bool isDefault );
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setKeys( const QList<QString> keyList );
void clearKeys();
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setKeys( const QList<QString> keyList );
void clearKeys();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onDefaultItemActivated();
void onPaletteItemActivated( int id );
void onHistoryItemActivated( int id );
void onCustomColorItemActivated();
void onColorHistoryChanged();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onDefaultItemActivated();
void onPaletteItemActivated( int id );
void onHistoryItemActivated( int id );
void onCustomColorItemActivated();
void onColorHistoryChanged();
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
void loadCustomColorHistory();
/////////////////////////////////
// Private Methods
/////////////////////////////////
private:
void loadCustomColorHistory();
/////////////////////////////////
// Private Members
/////////////////////////////////
private:
QColor mDefaultColor;
ColorNode mColorNode;
/////////////////////////////////
// Private Members
/////////////////////////////////
private:
QColor mDefaultColor;
ColorNode mColorNode;
static const int PALETTE_COLS = 9;
static const int PALETTE_ROWS = 4;
static const int PALETTE_COLS = 9;
static const int PALETTE_ROWS = 4;
typedef struct {
QString colorSpec;
QString name;
} ColorTableEntry;
typedef struct {
QString colorSpec;
QString name;
} ColorTableEntry;
static ColorTableEntry mColorTable[];
static ColorTableEntry mColorTable[];
ColorHistory* mColorHistory;
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
ColorHistory* mColorHistory;
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
};
}
};
#endif // glabels_ColorPaletteDialog_h
#endif // ColorPaletteDialog_h
+83 -89
View File
@@ -40,111 +40,105 @@ namespace
}
namespace glabels
///
/// Constructor From Data
///
ColorPaletteItem::ColorPaletteItem( int id,
const QColor& color,
const QString& tip,
QWidget* parent )
: QWidget(parent), mId(id), mColor(color), mTip(tip), mHover(false)
{
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
setMinimumSize( wSwatch+2*border+1, hSwatch+2*border+1 );
setToolTip( tip );
}
///
/// Constructor From Data
///
ColorPaletteItem::ColorPaletteItem( int id,
const QColor& color,
const QString& tip,
QWidget* parent )
: QWidget(parent), mId(id), mColor(color), mTip(tip), mHover(false)
///
/// Color Property Setter
///
void ColorPaletteItem::setColor( int id,
const QColor& color,
const QString& tip )
{
mId = id;
mColor = color;
mTip = tip;
setToolTip( tip );
update();
}
///
/// Paint Event
///
void ColorPaletteItem::paintEvent( QPaintEvent* event )
{
QPainter painter(this);
//
// Draw swatch
//
if ( isEnabled() )
{
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
setMinimumSize( wSwatch+2*border+1, hSwatch+2*border+1 );
setToolTip( tip );
}
///
/// Color Property Setter
///
void ColorPaletteItem::setColor( int id,
const QColor& color,
const QString& tip )
{
mId = id;
mColor = color;
mTip = tip;
setToolTip( tip );
update();
}
///
/// Paint Event
///
void ColorPaletteItem::paintEvent( QPaintEvent* event )
{
QPainter painter(this);
//
// Draw swatch
//
if ( isEnabled() )
if ( mHover )
{
if ( mHover )
{
QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( 2*outlineWidthPixels );
pen.setJoinStyle( Qt::MiterJoin );
painter.setPen( pen );
painter.setBrush( QBrush( mColor ) );
painter.drawRect( 1, 1, width()-2, height()-2 );
}
else
{
QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( outlineWidthPixels );
painter.setPen( pen );
painter.setBrush( QBrush( mColor ) );
painter.drawRect( border, border, wSwatch, hSwatch );
}
QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( 2*outlineWidthPixels );
pen.setJoinStyle( Qt::MiterJoin );
painter.setPen( pen );
painter.setBrush( QBrush( mColor ) );
painter.drawRect( 1, 1, width()-2, height()-2 );
}
else
{
QPen pen( palette().color( QPalette::Disabled, QPalette::Text ) );
QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( outlineWidthPixels );
painter.setPen( pen );
painter.setBrush( QBrush( mColor ) );
painter.drawRect( border, border, wSwatch, hSwatch );
}
}
///
/// Enter Event
///
void ColorPaletteItem::enterEvent( QEvent* event )
else
{
mHover = true;
update();
}
///
/// Leave Event
///
void ColorPaletteItem::leaveEvent( QEvent* event )
{
mHover = false;
update();
}
///
/// Mouse Press Event
///
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
{
emit activated( mId );
QPen pen( palette().color( QPalette::Disabled, QPalette::Text ) );
pen.setWidth( outlineWidthPixels );
painter.setPen( pen );
painter.setBrush( QBrush( mColor ) );
painter.drawRect( border, border, wSwatch, hSwatch );
}
}
///
/// Enter Event
///
void ColorPaletteItem::enterEvent( QEvent* event )
{
mHover = true;
update();
}
///
/// Leave Event
///
void ColorPaletteItem::leaveEvent( QEvent* event )
{
mHover = false;
update();
}
///
/// Mouse Press Event
///
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
{
emit activated( mId );
}
+45 -50
View File
@@ -18,71 +18,66 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_ColorPaletteItem_h
#define glabels_ColorPaletteItem_h
#ifndef ColorPaletteItem_h
#define ColorPaletteItem_h
#include <QWidget>
#include <QColor>
namespace glabels
///
/// Color Palette Item
///
class ColorPaletteItem : public QWidget
{
Q_OBJECT
///
/// Color Palette Item
///
class ColorPaletteItem : public QWidget
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorPaletteItem( int id,
const QColor& color,
const QString& tip,
QWidget* parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorPaletteItem( int id,
const QColor& color,
const QString& tip,
QWidget* parent = 0 );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated( int id );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated( int id );
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setColor( int id,
const QColor& color,
const QString& tip );
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setColor( int id,
const QColor& color,
const QString& tip );
/////////////////////////////////
// Event handlers
/////////////////////////////////
protected:
void paintEvent( QPaintEvent* event );
void enterEvent( QEvent* event );
void leaveEvent( QEvent* event );
void mousePressEvent( QMouseEvent* event );
/////////////////////////////////
// Event handlers
/////////////////////////////////
protected:
void paintEvent( QPaintEvent* event );
void enterEvent( QEvent* event );
void leaveEvent( QEvent* event );
void mousePressEvent( QMouseEvent* event );
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
int mId;
QColor mColor;
QString mTip;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
int mId;
QColor mColor;
QString mTip;
bool mHover;
};
bool mHover;
};
}
#endif // glabels_ColorPaletteItem_h
#endif // ColorPaletteItem_h
+14 -19
View File
@@ -33,28 +33,23 @@ namespace
}
namespace glabels
///
/// Constructor
///
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
: QPixmap( w, h )
{
fill( Qt::transparent );
///
/// Constructor
///
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
: QPixmap( w, h )
{
fill( Qt::transparent );
QPainter painter(this );
QPainter painter(this );
painter.setBackgroundMode( Qt::TransparentMode );
painter.setBackgroundMode( Qt::TransparentMode );
QBrush brush( color );
QPen pen( outlineColor );
pen.setWidth( outlineWidthPixels );
painter.setBrush( brush );
painter.setPen( pen );
painter.drawRect( 1, 1, w-2, h-2 );
}
QBrush brush( color );
QPen pen( outlineColor );
pen.setWidth( outlineWidthPixels );
painter.setBrush( brush );
painter.setPen( pen );
painter.drawRect( 1, 1, w-2, h-2 );
}
+13 -17
View File
@@ -18,29 +18,25 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_ColorSwatch_h
#define glabels_ColorSwatch_h
#ifndef ColorSwatch_h
#define ColorSwatch_h
#include <QPixmap>
namespace glabels
///
/// Simple Preview Widget
///
class ColorSwatch : public QPixmap
{
///
/// Simple Preview Widget
///
class ColorSwatch : public QPixmap
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorSwatch( int w, int h, const QColor& color );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ColorSwatch( int w, int h, const QColor& color );
};
};
}
#endif // glabels_ColorSwatch_h
#endif // ColorSwatch_h
+6 -6
View File
@@ -24,37 +24,37 @@
#include <QPixmap>
glabels::Cursors::Barcode::Barcode()
Cursors::Barcode::Barcode()
: QCursor( QPixmap(":cursors/32x32/cursor_barcode.png"), 7, 7 )
{
}
glabels::Cursors::Box::Box()
Cursors::Box::Box()
: QCursor( QPixmap(":cursors/32x32/cursor_box.png"), 7, 7 )
{
}
glabels::Cursors::Ellipse::Ellipse()
Cursors::Ellipse::Ellipse()
: QCursor( QPixmap(":cursors/32x32/cursor_ellipse.png"), 7, 7 )
{
}
glabels::Cursors::Image::Image()
Cursors::Image::Image()
: QCursor( QPixmap(":cursors/32x32/cursor_image.png"), 7, 7 )
{
}
glabels::Cursors::Line::Line()
Cursors::Line::Line()
: QCursor( QPixmap(":cursors/32x32/cursor_line.png"), 7, 7 )
{
}
glabels::Cursors::Text::Text()
Cursors::Text::Text()
: QCursor( QPixmap(":cursors/32x32/cursor_text.png"), 7, 7 )
{
}
+38 -42
View File
@@ -18,66 +18,62 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_Cursors_h
#define glabels_Cursors_h
#ifndef Cursors_h
#define Cursors_h
#include <QCursor>
namespace glabels
///
/// Glabels Cursors
///
namespace Cursors
{
///
/// Glabels Cursors
///
namespace Cursors
{
class Barcode : public QCursor
{
public:
Barcode();
};
class Barcode : public QCursor
{
public:
Barcode();
};
class Box : public QCursor
{
public:
Box();
};
class Box : public QCursor
{
public:
Box();
};
class Ellipse : public QCursor
{
public:
Ellipse();
};
class Ellipse : public QCursor
{
public:
Ellipse();
};
class Image : public QCursor
{
public:
Image();
};
class Image : public QCursor
{
public:
Image();
};
class Line : public QCursor
{
public:
Line();
};
class Line : public QCursor
{
public:
Line();
};
class Text : public QCursor
{
public:
Text();
};
class Text : public QCursor
{
public:
Text();
};
}
}
#endif // glabels_Cursors_h
#endif // Cursors_h
+74 -81
View File
@@ -21,101 +21,94 @@
#include "FieldButton.h"
namespace glabels
///
/// Constructor
///
FieldButton::FieldButton( QWidget* parent )
: QPushButton(parent)
{
setEnabled( false );
///
/// Constructor
///
FieldButton::FieldButton( QWidget* parent )
: QPushButton(parent)
mMenu = new FieldMenu();
setMenu( mMenu );
connect( mMenu, SIGNAL(keySelected(const QString&)), this, SLOT(onMenuKeySelected(const QString&)) );
}
void FieldButton::setName( const QString& name )
{
if ( name.isNull() || name.isEmpty() )
{
setEnabled( false );
mMenu = new FieldMenu();
setMenu( mMenu );
connect( mMenu, SIGNAL(keySelected(const QString&)), this, SLOT(onMenuKeySelected(const QString&)) );
setText( tr("(None)") );
mLabelIsKey = false;
}
void FieldButton::setName( const QString& name )
else
{
if ( name.isNull() || name.isEmpty() )
{
setText( tr("(None)") );
mLabelIsKey = false;
}
else
{
setText( name );
mLabelIsKey = true;
}
setText( name );
mLabelIsKey = true;
}
}
void FieldButton::setKeys( const QList<QString>& keyList )
void FieldButton::setKeys( const QList<QString>& keyList )
{
mMenu->setKeys( keyList );
if ( keyList.length() > 0 )
{
mMenu->setKeys( keyList );
if ( keyList.length() > 0 )
{
mKey = keyList.first();
if ( mLabelIsKey )
{
setText( mKey );
}
else
{
setText( tr("(None)") );
}
setEnabled( true );
}
else
{
setEnabled( false );
}
}
void FieldButton::clearKeys()
{
if ( !mLabelIsKey )
{
setText( tr("(None)") );
}
setEnabled( false );
}
///
/// key getter
///
QString FieldButton::key() const
{
return mKey;
}
///
/// onMenuKeySelected slot
///
void FieldButton::onMenuKeySelected( const QString& key )
{
mKey = key;
mKey = keyList.first();
if ( mLabelIsKey )
{
setText( key );
setText( mKey );
}
else
{
setText( tr("(None)") );
}
emit keySelected( key );
setEnabled( true );
}
else
{
setEnabled( false );
}
}
void FieldButton::clearKeys()
{
if ( !mLabelIsKey )
{
setText( tr("(None)") );
}
setEnabled( false );
}
///
/// key getter
///
QString FieldButton::key() const
{
return mKey;
}
///
/// onMenuKeySelected slot
///
void FieldButton::onMenuKeySelected( const QString& key )
{
mKey = key;
if ( mLabelIsKey )
{
setText( key );
}
emit keySelected( key );
}
+43 -48
View File
@@ -18,72 +18,67 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_FieldButton_h
#define glabels_FieldButton_h
#ifndef FieldButton_h
#define FieldButton_h
#include <QPushButton>
#include <QString>
#include "FieldMenu.h"
namespace glabels
///
/// Field Button
///
class FieldButton : public QPushButton
{
Q_OBJECT
///
/// Field Button
///
class FieldButton : public QPushButton
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
FieldButton( QWidget* parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
FieldButton( QWidget* parent = 0 );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void keySelected( const QString& key );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void keySelected( const QString& key );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
QString key() const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
QString key() const;
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setName( const QString& name = "" );
void setKeys( const QList<QString>& keyList );
void clearKeys();
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setName( const QString& name = "" );
void setKeys( const QList<QString>& keyList );
void clearKeys();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuKeySelected( const QString& key );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuKeySelected( const QString& key );
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
FieldMenu* mMenu;
QString mKey;
bool mLabelIsKey;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
FieldMenu* mMenu;
QString mKey;
bool mLabelIsKey;
};
};
}
#endif // glabels_FieldButton_h
#endif // FieldButton_h
+29 -36
View File
@@ -23,42 +23,35 @@
#include "FieldMenuItem.h"
namespace glabels
///
/// Constructor
///
FieldMenu::FieldMenu()
{
///
/// Constructor
///
FieldMenu::FieldMenu()
{
}
///
/// set keys
///
void FieldMenu::setKeys( const QList<QString>& keyList )
{
clear();
foreach ( QString key, keyList )
{
FieldMenuItem* menuItem = new FieldMenuItem( key );
connect( menuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
addAction( menuItem );
}
}
///
/// onMenuItemActivated slot
///
void FieldMenu::onMenuItemActivated( const QString& key )
{
emit keySelected( key );
}
}
///
/// set keys
///
void FieldMenu::setKeys( const QList<QString>& keyList )
{
clear();
foreach ( QString key, keyList )
{
FieldMenuItem* menuItem = new FieldMenuItem( key );
connect( menuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
addAction( menuItem );
}
}
///
/// onMenuItemActivated slot
///
void FieldMenu::onMenuItemActivated( const QString& key )
{
emit keySelected( key );
}
+33 -38
View File
@@ -18,59 +18,54 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_FieldMenu_h
#define glabels_FieldMenu_h
#ifndef FieldMenu_h
#define FieldMenu_h
#include <QMenu>
#include <QString>
namespace glabels
///
/// Field Menu
///
class FieldMenu : public QMenu
{
Q_OBJECT
///
/// Field Menu
///
class FieldMenu : public QMenu
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
FieldMenu();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
FieldMenu();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void keySelected( const QString& key );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void keySelected( const QString& key );
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setKeys( const QList<QString>& keyList );
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setKeys( const QList<QString>& keyList );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuItemActivated( const QString& key );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuItemActivated( const QString& key );
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
};
};
}
#endif // glabels_FieldMenu_h
#endif // FieldMenu_h
+24 -30
View File
@@ -21,37 +21,31 @@
#include "FieldMenuItem.h"
namespace glabels
///
/// Constructor From Data
///
FieldMenuItem::FieldMenuItem( const QString& key, QObject* parent )
: QAction(parent), mKey(key)
{
setText( key );
///
/// Constructor From Data
///
FieldMenuItem::FieldMenuItem( const QString& key, QObject* parent )
: QAction(parent), mKey(key)
{
setText( key );
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
}
///
/// key Property Getter
///
QString FieldMenuItem::key() const
{
return mKey;
}
///
/// onTriggered slot
///
void FieldMenuItem::onTriggered()
{
emit activated( mKey );
}
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
}
///
/// key Property Getter
///
QString FieldMenuItem::key() const
{
return mKey;
}
///
/// onTriggered slot
///
void FieldMenuItem::onTriggered()
{
emit activated( mKey );
}
+34 -39
View File
@@ -18,60 +18,55 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_FieldMenuItem_h
#define glabels_FieldMenuItem_h
#ifndef FieldMenuItem_h
#define FieldMenuItem_h
#include <QAction>
#include <QString>
namespace glabels
///
/// Field Menu Item
///
class FieldMenuItem : public QAction
{
Q_OBJECT
///
/// Field Menu Item
///
class FieldMenuItem : public QAction
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
FieldMenuItem( const QString& key, QObject* parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
FieldMenuItem( const QString& key, QObject* parent = 0 );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated( const QString& key );
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated( const QString& key );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
QString key() const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
QString key() const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onTriggered();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onTriggered();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const QString mKey;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const QString mKey;
};
};
}
#endif // glabels_FieldMenuItem_h
#endif // FieldMenuItem_h
+168 -174
View File
@@ -31,195 +31,189 @@
#include <QDebug>
namespace glabels
/// @TODO keep track of cwd between open/save dialogs
///
/// New Label Dialog
///
void File::newLabel( MainWindow *window )
{
/// @TODO keep track of cwd between open/save dialogs
// @TODO lookup latest template, if none default based on locale
const glabels::Template* tmplate = glabels::Db::lookupTemplateFromBrandPart( "Avery", "5159" );
LabelModel* label = new LabelModel();
label->setTmplate( tmplate );
label->setRotate( false );
///
/// New Label Dialog
///
void File::newLabel( MainWindow *window )
MainWindow *newWindow = new MainWindow();
newWindow->setModel( label );
newWindow->show();
}
///
/// Open File Dialog
///
void File::open( MainWindow *window )
{
QString fileName =
QFileDialog::getOpenFileName( window,
tr("Open label"),
".",
tr("glabels files (*.glabels);;All files (*)")
);
if ( !fileName.isEmpty() )
{
// @TODO lookup latest template, if none default based on locale
const libglabels::Template* tmplate = libglabels::Db::lookupTemplateFromBrandPart( "Avery", "5159" );
LabelModel* label = new LabelModel();
label->setTmplate( tmplate );
label->setRotate( false );
MainWindow *newWindow = new MainWindow();
newWindow->setModel( label );
newWindow->show();
}
///
/// Open File Dialog
///
void File::open( MainWindow *window )
{
QString fileName =
QFileDialog::getOpenFileName( window,
tr("Open label"),
".",
tr("glabels files (*.glabels);;All files (*)")
);
if ( !fileName.isEmpty() )
LabelModel *label = XmlLabelParser::readFile( fileName );
if ( label )
{
LabelModel *label = XmlLabelParser::readFile( fileName );
if ( label )
{
label->setFileName( fileName );
label->setFileName( fileName );
if ( window->isEmpty() )
{
window->setModel( label );
}
else
{
MainWindow *newWindow = new MainWindow();
newWindow->setModel( label );
newWindow->show();
}
if ( window->isEmpty() )
{
window->setModel( label );
}
else
{
QMessageBox msgBox;
msgBox.setText( tr("Unable to open \"") + fileName + tr("\".") );
msgBox.setStandardButtons( QMessageBox::Ok );
msgBox.setDefaultButton( QMessageBox::Ok );
msgBox.exec();
MainWindow *newWindow = new MainWindow();
newWindow->setModel( label );
newWindow->show();
}
}
else
{
QMessageBox msgBox;
msgBox.setText( tr("Unable to open \"") + fileName + tr("\".") );
msgBox.setStandardButtons( QMessageBox::Ok );
msgBox.setDefaultButton( QMessageBox::Ok );
msgBox.exec();
}
}
}
///
/// Save file
///
bool File::save( MainWindow *window )
{
if ( window->model()->fileName().isEmpty() )
{
return saveAs( window );
}
///
/// Save file
///
bool File::save( MainWindow *window )
if ( !window->model()->isModified() )
{
if ( window->model()->fileName().isEmpty() )
{
return saveAs( window );
}
if ( !window->model()->isModified() )
{
return true;
}
XmlLabelCreator::writeFile( window->model(), window->model()->fileName() );
return true;
}
///
/// Save file as
///
bool File::saveAs( MainWindow *window )
{
QString rawFileName =
QFileDialog::getSaveFileName( window,
tr("Save Label As"),
".",
tr("glabels files (*.glabels);;All files (*)"),
0,
QFileDialog::DontConfirmOverwrite
);
if ( !rawFileName.isEmpty() )
{
QString fileName = FileUtil::addExtension( rawFileName, ".glabels" );
if ( QFileInfo(fileName).exists() )
{
QMessageBox msgBox( window );
msgBox.setWindowTitle( tr("Save Label As") );
msgBox.setIcon( QMessageBox::Warning );
msgBox.setText( tr("%1 already exists.").arg(fileName) );
msgBox.setInformativeText( tr("Do you want to replace it?") );
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton( QMessageBox::No );
if ( msgBox.exec() == QMessageBox::No )
{
return saveAs( window );
}
}
XmlLabelCreator::writeFile( window->model(), fileName );
window->model()->setFileName( fileName );
return true;
}
return false;
}
///
/// Print file
///
void File::print( MainWindow *window )
{
qDebug() << "ACTION: file->print";
}
///
/// Close file
///
void File::close( MainWindow *window )
{
bool closeFlag = true;
if ( !window->isEmpty() )
{
QMessageBox msgBox;
msgBox.setText( tr("The document ") + window->model()->shortName() + tr(" has been modified.") );
msgBox.setInformativeText( tr("Do you want to save your changes?") );
msgBox.setStandardButtons( QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel );
msgBox.setDefaultButton( QMessageBox::Save );
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Save:
// Save was clicked
closeFlag = save( window );
break;
case QMessageBox::Discard:
// Don't Save was clicked
closeFlag = true;
break;
case QMessageBox::Cancel:
// Cancel was clicked
closeFlag = false;
break;
default:
// should never be reached
closeFlag = false;
break;
}
}
if ( closeFlag )
{
window->close();
}
}
///
/// Exit, closing all windows
///
void File::exit()
{
foreach ( MainWindow* window, MainWindow::windowList() )
{
close( window );
}
}
XmlLabelCreator::writeFile( window->model(), window->model()->fileName() );
return true;
}
///
/// Save file as
///
bool File::saveAs( MainWindow *window )
{
QString rawFileName =
QFileDialog::getSaveFileName( window,
tr("Save Label As"),
".",
tr("glabels files (*.glabels);;All files (*)"),
0,
QFileDialog::DontConfirmOverwrite
);
if ( !rawFileName.isEmpty() )
{
QString fileName = FileUtil::addExtension( rawFileName, ".glabels" );
if ( QFileInfo(fileName).exists() )
{
QMessageBox msgBox( window );
msgBox.setWindowTitle( tr("Save Label As") );
msgBox.setIcon( QMessageBox::Warning );
msgBox.setText( tr("%1 already exists.").arg(fileName) );
msgBox.setInformativeText( tr("Do you want to replace it?") );
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
msgBox.setDefaultButton( QMessageBox::No );
if ( msgBox.exec() == QMessageBox::No )
{
return saveAs( window );
}
}
XmlLabelCreator::writeFile( window->model(), fileName );
window->model()->setFileName( fileName );
return true;
}
return false;
}
///
/// Print file
///
void File::print( MainWindow *window )
{
qDebug() << "ACTION: file->print";
}
///
/// Close file
///
void File::close( MainWindow *window )
{
bool closeFlag = true;
if ( !window->isEmpty() )
{
QMessageBox msgBox;
msgBox.setText( tr("The document ") + window->model()->shortName() + tr(" has been modified.") );
msgBox.setInformativeText( tr("Do you want to save your changes?") );
msgBox.setStandardButtons( QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel );
msgBox.setDefaultButton( QMessageBox::Save );
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Save:
// Save was clicked
closeFlag = save( window );
break;
case QMessageBox::Discard:
// Don't Save was clicked
closeFlag = true;
break;
case QMessageBox::Cancel:
// Cancel was clicked
closeFlag = false;
break;
default:
// should never be reached
closeFlag = false;
break;
}
}
if ( closeFlag )
{
window->close();
}
}
///
/// Exit, closing all windows
///
void File::exit()
{
foreach ( MainWindow* window, MainWindow::windowList() )
{
close( window );
}
}
+20 -22
View File
@@ -18,34 +18,32 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_File_h
#define glabels_File_h
#ifndef File_h
#define File_h
#include <QObject>
namespace glabels
class MainWindow;
///
/// File Actions
///
class File : public QObject
{
class MainWindow;
Q_OBJECT
///
/// File Actions
///
class File : public QObject
{
Q_OBJECT
public:
static void newLabel( MainWindow *window = 0 );
static void open( MainWindow *window );
static bool save( MainWindow *window );
static bool saveAs( MainWindow *window );
static void print( MainWindow *window );
static void close( MainWindow *window );
static void exit();
};
public:
static void newLabel( MainWindow *window = 0 );
static void open( MainWindow *window );
static bool save( MainWindow *window );
static bool saveAs( MainWindow *window );
static void print( MainWindow *window );
static void close( MainWindow *window );
static void exit();
};
}
#endif // glabels_File_h
#endif // File_h
+5 -12
View File
@@ -21,24 +21,17 @@
#include "FileUtil.h"
namespace glabels
namespace FileUtil
{
namespace FileUtil
QString addExtension( const QString& rawFilename, const QString& extension )
{
QString addExtension( const QString& rawFilename, const QString& extension )
if ( rawFilename.endsWith( extension ) )
{
if ( rawFilename.endsWith( extension ) )
{
return rawFilename;
}
return rawFilename + extension;
return rawFilename;
}
return rawFilename + extension;
}
}
+6 -9
View File
@@ -18,21 +18,18 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_FileUtil_h
#define glabels_FileUtil_h
#ifndef FileUtil_h
#define FileUtil_h
#include <QString>
namespace glabels
namespace FileUtil
{
namespace FileUtil
{
QString addExtension( const QString& rawFilename, const QString& extension );
}
QString addExtension( const QString& rawFilename, const QString& extension );
}
#endif // glabels_FileUtil_h
#endif // FileUtil_h
+52 -52
View File
@@ -41,7 +41,7 @@ namespace
///
/// Handle Constructor
///
glabels::Handle::Handle( LabelModelObject* owner, Location location )
Handle::Handle( LabelModelObject* owner, Location location )
: mOwner(owner), mLocation(location)
{
}
@@ -50,7 +50,7 @@ glabels::Handle::Handle( LabelModelObject* owner, Location location )
///
/// Handle Destructor
///
glabels::Handle::~Handle()
Handle::~Handle()
{
}
@@ -58,7 +58,7 @@ glabels::Handle::~Handle()
///
/// Handle owner
///
glabels::LabelModelObject* glabels::Handle::owner() const
LabelModelObject* Handle::owner() const
{
return mOwner;
}
@@ -67,7 +67,7 @@ glabels::LabelModelObject* glabels::Handle::owner() const
///
/// Handle location
///
glabels::Handle::Location glabels::Handle::location() const
Handle::Location Handle::location() const
{
return mLocation;
}
@@ -76,11 +76,11 @@ glabels::Handle::Location glabels::Handle::location() const
///
/// Draw Handle at x,y
///
void glabels::Handle::drawAt( QPainter* painter,
double scale,
const libglabels::Distance& x,
const libglabels::Distance& y,
QColor color ) const
void Handle::drawAt( QPainter* painter,
double scale,
const glabels::Distance& x,
const glabels::Distance& y,
QColor color ) const
{
painter->save();
@@ -104,9 +104,9 @@ void glabels::Handle::drawAt( QPainter* painter,
///
/// Create Handle path at x,y
///
QPainterPath glabels::Handle::pathAt( double scale,
const libglabels::Distance& x,
const libglabels::Distance& y ) const
QPainterPath Handle::pathAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const
{
QPainterPath path;
@@ -122,7 +122,7 @@ QPainterPath glabels::Handle::pathAt( double scale,
///
/// HandleNorthWest Constructor
///
glabels::HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
: Handle( owner, NW )
{
}
@@ -131,7 +131,7 @@ glabels::HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
///
/// HandleNorthWest Destructor
///
glabels::HandleNorthWest::~HandleNorthWest()
HandleNorthWest::~HandleNorthWest()
{
}
@@ -139,7 +139,7 @@ glabels::HandleNorthWest::~HandleNorthWest()
///
/// Draw HandleNorthWest
///
void glabels::HandleNorthWest::draw( QPainter* painter, double scale ) const
void HandleNorthWest::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, 0, 0, originHandleFillColor );
}
@@ -148,7 +148,7 @@ void glabels::HandleNorthWest::draw( QPainter* painter, double scale ) const
///
/// HandleNorthWest Path
///
QPainterPath glabels::HandleNorthWest::path( double scale ) const
QPainterPath HandleNorthWest::path( double scale ) const
{
return pathAt( scale, 0, 0 );
}
@@ -157,7 +157,7 @@ QPainterPath glabels::HandleNorthWest::path( double scale ) const
///
/// HandleNorth Constructor
///
glabels::HandleNorth::HandleNorth( LabelModelObject* owner )
HandleNorth::HandleNorth( LabelModelObject* owner )
: Handle( owner, N )
{
}
@@ -166,7 +166,7 @@ glabels::HandleNorth::HandleNorth( LabelModelObject* owner )
///
/// HandleNorth Destructor
///
glabels::HandleNorth::~HandleNorth()
HandleNorth::~HandleNorth()
{
}
@@ -174,7 +174,7 @@ glabels::HandleNorth::~HandleNorth()
///
/// Draw HandleNorth
///
void glabels::HandleNorth::draw( QPainter* painter, double scale ) const
void HandleNorth::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, mOwner->w()/2, 0, handleFillColor );
}
@@ -183,7 +183,7 @@ void glabels::HandleNorth::draw( QPainter* painter, double scale ) const
///
/// HandleNorth Path
///
QPainterPath glabels::HandleNorth::path( double scale ) const
QPainterPath HandleNorth::path( double scale ) const
{
return pathAt( scale, mOwner->w()/2, 0 );
}
@@ -192,7 +192,7 @@ QPainterPath glabels::HandleNorth::path( double scale ) const
///
/// HandleNorthEast Constructor
///
glabels::HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
: Handle( owner, NE )
{
}
@@ -201,7 +201,7 @@ glabels::HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
///
/// HandleNorthEast Destructor
///
glabels::HandleNorthEast::~HandleNorthEast()
HandleNorthEast::~HandleNorthEast()
{
}
@@ -209,7 +209,7 @@ glabels::HandleNorthEast::~HandleNorthEast()
///
/// Draw HandleNorthEast
///
void glabels::HandleNorthEast::draw( QPainter* painter, double scale ) const
void HandleNorthEast::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, mOwner->w(), 0, handleFillColor );
}
@@ -218,7 +218,7 @@ void glabels::HandleNorthEast::draw( QPainter* painter, double scale ) const
///
/// HandleNorthEast Path
///
QPainterPath glabels::HandleNorthEast::path( double scale ) const
QPainterPath HandleNorthEast::path( double scale ) const
{
return pathAt( scale, mOwner->w(), 0 );
}
@@ -227,7 +227,7 @@ QPainterPath glabels::HandleNorthEast::path( double scale ) const
///
/// HandleEast Constructor
///
glabels::HandleEast::HandleEast( LabelModelObject* owner )
HandleEast::HandleEast( LabelModelObject* owner )
: Handle( owner, E )
{
}
@@ -236,7 +236,7 @@ glabels::HandleEast::HandleEast( LabelModelObject* owner )
///
/// HandleEast Destructor
///
glabels::HandleEast::~HandleEast()
HandleEast::~HandleEast()
{
}
@@ -244,7 +244,7 @@ glabels::HandleEast::~HandleEast()
///
/// Draw HandleEast
///
void glabels::HandleEast::draw( QPainter* painter, double scale ) const
void HandleEast::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, mOwner->w(), mOwner->h()/2, handleFillColor );
}
@@ -253,7 +253,7 @@ void glabels::HandleEast::draw( QPainter* painter, double scale ) const
///
/// HandleEast Path
///
QPainterPath glabels::HandleEast::path( double scale ) const
QPainterPath HandleEast::path( double scale ) const
{
return pathAt( scale, mOwner->w(), mOwner->h()/2 );
}
@@ -262,7 +262,7 @@ QPainterPath glabels::HandleEast::path( double scale ) const
///
/// HandleSouthEast Constructor
///
glabels::HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
: Handle( owner, SE )
{
}
@@ -271,7 +271,7 @@ glabels::HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
///
/// HandleSouthEast Destructor
///
glabels::HandleSouthEast::~HandleSouthEast()
HandleSouthEast::~HandleSouthEast()
{
}
@@ -279,7 +279,7 @@ glabels::HandleSouthEast::~HandleSouthEast()
///
/// Draw HandleSouthEast
///
void glabels::HandleSouthEast::draw( QPainter* painter, double scale ) const
void HandleSouthEast::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, mOwner->w(), mOwner->h(), handleFillColor );
}
@@ -288,7 +288,7 @@ void glabels::HandleSouthEast::draw( QPainter* painter, double scale ) const
///
/// HandleSouthEast Path
///
QPainterPath glabels::HandleSouthEast::path( double scale ) const
QPainterPath HandleSouthEast::path( double scale ) const
{
return pathAt( scale, mOwner->w(), mOwner->h() );
}
@@ -297,7 +297,7 @@ QPainterPath glabels::HandleSouthEast::path( double scale ) const
///
/// HandleSouth Constructor
///
glabels::HandleSouth::HandleSouth( LabelModelObject* owner )
HandleSouth::HandleSouth( LabelModelObject* owner )
: Handle( owner, S )
{
}
@@ -306,7 +306,7 @@ glabels::HandleSouth::HandleSouth( LabelModelObject* owner )
///
/// HandleSouth Destructor
///
glabels::HandleSouth::~HandleSouth()
HandleSouth::~HandleSouth()
{
}
@@ -314,7 +314,7 @@ glabels::HandleSouth::~HandleSouth()
///
/// Draw HandleSouth
///
void glabels::HandleSouth::draw( QPainter* painter, double scale ) const
void HandleSouth::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, mOwner->w()/2, mOwner->h(), handleFillColor );
}
@@ -323,7 +323,7 @@ void glabels::HandleSouth::draw( QPainter* painter, double scale ) const
///
/// HandleSouth Path
///
QPainterPath glabels::HandleSouth::path( double scale ) const
QPainterPath HandleSouth::path( double scale ) const
{
return pathAt( scale, mOwner->w()/2, mOwner->h() );
}
@@ -332,7 +332,7 @@ QPainterPath glabels::HandleSouth::path( double scale ) const
///
/// HandleSouthWest Constructor
///
glabels::HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
: Handle( owner, SW )
{
}
@@ -341,7 +341,7 @@ glabels::HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
///
/// HandleSouthWest Destructor
///
glabels::HandleSouthWest::~HandleSouthWest()
HandleSouthWest::~HandleSouthWest()
{
}
@@ -349,7 +349,7 @@ glabels::HandleSouthWest::~HandleSouthWest()
///
/// Draw HandleSouthWest
///
void glabels::HandleSouthWest::draw( QPainter* painter, double scale ) const
void HandleSouthWest::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, 0, mOwner->h(), handleFillColor );
}
@@ -358,7 +358,7 @@ void glabels::HandleSouthWest::draw( QPainter* painter, double scale ) const
///
/// HandleSouthWest Path
///
QPainterPath glabels::HandleSouthWest::path( double scale ) const
QPainterPath HandleSouthWest::path( double scale ) const
{
return pathAt( scale, 0, mOwner->h() );
}
@@ -367,7 +367,7 @@ QPainterPath glabels::HandleSouthWest::path( double scale ) const
///
/// HandleWest Constructor
///
glabels::HandleWest::HandleWest( LabelModelObject* owner )
HandleWest::HandleWest( LabelModelObject* owner )
: Handle( owner, W )
{
}
@@ -376,7 +376,7 @@ glabels::HandleWest::HandleWest( LabelModelObject* owner )
///
/// HandleWest Destructor
///
glabels::HandleWest::~HandleWest()
HandleWest::~HandleWest()
{
}
@@ -384,7 +384,7 @@ glabels::HandleWest::~HandleWest()
///
/// Draw HandleWest
///
void glabels::HandleWest::draw( QPainter* painter, double scale ) const
void HandleWest::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, 0, mOwner->h()/2, handleFillColor );
}
@@ -393,7 +393,7 @@ void glabels::HandleWest::draw( QPainter* painter, double scale ) const
///
/// HandleWest Path
///
QPainterPath glabels::HandleWest::path( double scale ) const
QPainterPath HandleWest::path( double scale ) const
{
return pathAt( scale, 0, mOwner->h()/2 );
}
@@ -402,7 +402,7 @@ QPainterPath glabels::HandleWest::path( double scale ) const
///
/// HandleP1 Constructor
///
glabels::HandleP1::HandleP1( LabelModelObject* owner )
HandleP1::HandleP1( LabelModelObject* owner )
: Handle( owner, P1 )
{
}
@@ -411,7 +411,7 @@ glabels::HandleP1::HandleP1( LabelModelObject* owner )
///
/// HandleP1 Destructor
///
glabels::HandleP1::~HandleP1()
HandleP1::~HandleP1()
{
}
@@ -419,7 +419,7 @@ glabels::HandleP1::~HandleP1()
///
/// Draw HandleP1
///
void glabels::HandleP1::draw( QPainter* painter, double scale ) const
void HandleP1::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, 0, 0, originHandleFillColor );
}
@@ -428,7 +428,7 @@ void glabels::HandleP1::draw( QPainter* painter, double scale ) const
///
/// HandleP1 Path
///
QPainterPath glabels::HandleP1::path( double scale ) const
QPainterPath HandleP1::path( double scale ) const
{
return pathAt( scale, 0, 0 );
}
@@ -437,7 +437,7 @@ QPainterPath glabels::HandleP1::path( double scale ) const
///
/// HandleP2 Constructor
///
glabels::HandleP2::HandleP2( LabelModelObject* owner )
HandleP2::HandleP2( LabelModelObject* owner )
: Handle( owner, P2 )
{
}
@@ -446,7 +446,7 @@ glabels::HandleP2::HandleP2( LabelModelObject* owner )
///
/// HandleP2 Destructor
///
glabels::HandleP2::~HandleP2()
HandleP2::~HandleP2()
{
}
@@ -454,7 +454,7 @@ glabels::HandleP2::~HandleP2()
///
/// Draw HandleP2
///
void glabels::HandleP2::draw( QPainter* painter, double scale ) const
void HandleP2::draw( QPainter* painter, double scale ) const
{
drawAt( painter, scale, mOwner->w(), mOwner->h(), handleFillColor );
}
@@ -463,7 +463,7 @@ void glabels::HandleP2::draw( QPainter* painter, double scale ) const
///
/// HandleP2 Path
///
QPainterPath glabels::HandleP2::path( double scale ) const
QPainterPath HandleP2::path( double scale ) const
{
return pathAt( scale, mOwner->w(), mOwner->h() );
}
+229 -234
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_Handles_h
#define glabels_Handles_h
#ifndef Handles_h
#define Handles_h
#include <QPainter>
@@ -27,288 +27,283 @@
#include "libglabels/Distance.h"
namespace glabels
class LabelModelObject;
///
/// Handle Base Class
///
class Handle
{
class LabelModelObject;
///
/// Handle Base Class
///
class Handle
{
////////////////////////////
// Location enumeration
////////////////////////////
public:
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
////////////////////////////
// Location enumeration
////////////////////////////
public:
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
////////////////////////////
// Lifecycle Methods
////////////////////////////
protected:
Handle( LabelModelObject* owner, Location location );
public:
virtual ~Handle();
////////////////////////////
// Lifecycle Methods
////////////////////////////
protected:
Handle( LabelModelObject* owner, Location location );
public:
virtual ~Handle();
////////////////////////////
// Attribue Methods
////////////////////////////
LabelModelObject* owner() const;
Location location() const;
////////////////////////////
// Attribue Methods
////////////////////////////
LabelModelObject* owner() const;
Location location() const;
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const = 0;
virtual QPainterPath path( double scale ) const = 0;
protected:
void drawAt( QPainter* painter,
double scale,
const libglabels::Distance& x,
const libglabels::Distance& y,
QColor color ) const;
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const = 0;
virtual QPainterPath path( double scale ) const = 0;
protected:
void drawAt( QPainter* painter,
double scale,
const glabels::Distance& x,
const glabels::Distance& y,
QColor color ) const;
QPainterPath pathAt( double scale,
const libglabels::Distance& x,
const libglabels::Distance& y ) const;
QPainterPath pathAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const;
////////////////////////////
// Protected Data
////////////////////////////
protected:
LabelModelObject* mOwner;
Location mLocation;
////////////////////////////
// Protected Data
////////////////////////////
protected:
LabelModelObject* mOwner;
Location mLocation;
};
};
///
/// HandleNorth Class
///
class HandleNorth : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleNorth( LabelModelObject* owner );
virtual ~HandleNorth();
///
/// HandleNorth Class
///
class HandleNorth : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleNorth( LabelModelObject* owner );
virtual ~HandleNorth();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleNorthEast Class
///
class HandleNorthEast : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleNorthEast( LabelModelObject* owner );
virtual ~HandleNorthEast();
///
/// HandleNorthEast Class
///
class HandleNorthEast : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleNorthEast( LabelModelObject* owner );
virtual ~HandleNorthEast();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleEast Class
///
class HandleEast : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleEast( LabelModelObject* owner );
virtual ~HandleEast();
///
/// HandleEast Class
///
class HandleEast : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleEast( LabelModelObject* owner );
virtual ~HandleEast();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleSouthEast Class
///
class HandleSouthEast : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleSouthEast( LabelModelObject* owner );
virtual ~HandleSouthEast();
///
/// HandleSouthEast Class
///
class HandleSouthEast : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleSouthEast( LabelModelObject* owner );
virtual ~HandleSouthEast();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleSouth Class
///
class HandleSouth : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleSouth( LabelModelObject* owner );
virtual ~HandleSouth();
///
/// HandleSouth Class
///
class HandleSouth : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleSouth( LabelModelObject* owner );
virtual ~HandleSouth();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleSouthWest Class
///
class HandleSouthWest : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleSouthWest( LabelModelObject* owner );
virtual ~HandleSouthWest();
///
/// HandleSouthWest Class
///
class HandleSouthWest : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleSouthWest( LabelModelObject* owner );
virtual ~HandleSouthWest();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleWest Class
///
class HandleWest : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleWest( LabelModelObject* owner );
virtual ~HandleWest();
///
/// HandleWest Class
///
class HandleWest : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleWest( LabelModelObject* owner );
virtual ~HandleWest();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleNorthWest Class
///
class HandleNorthWest : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleNorthWest( LabelModelObject* owner );
virtual ~HandleNorthWest();
///
/// HandleNorthWest Class
///
class HandleNorthWest : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleNorthWest( LabelModelObject* owner );
virtual ~HandleNorthWest();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleP1 Class
///
class HandleP1 : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleP1( LabelModelObject* owner );
virtual ~HandleP1();
///
/// HandleP1 Class
///
class HandleP1 : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleP1( LabelModelObject* owner );
virtual ~HandleP1();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
///
/// HandleP2 Class
///
class HandleP2 : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleP2( LabelModelObject* owner );
virtual ~HandleP2();
///
/// HandleP2 Class
///
class HandleP2 : public Handle
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
HandleP2( LabelModelObject* owner );
virtual ~HandleP2();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
////////////////////////////
// Drawing Methods
////////////////////////////
public:
virtual void draw( QPainter* painter, double scale ) const;
virtual QPainterPath path( double scale ) const;
};
}
#endif // glabels_Handles_h
#endif // Handles_h
+26 -32
View File
@@ -25,38 +25,32 @@
#include <iostream>
namespace glabels
///
/// Display Help Contents
///
void Help::displayContents( QWidget *parent )
{
///
/// Display Help Contents
///
void Help::displayContents( QWidget *parent )
{
std::cout << "TODO: Help::displayContents" << std::endl;
}
///
/// Display Help->About Dialog
///
void Help::displayAbout( QWidget *parent )
{
QMessageBox aboutBox( QMessageBox::NoIcon,
QMessageBox::tr("About gLabels"),
QMessageBox::tr("<h2>gLabels-qt</h2>"
"<p>x.x.x</p>"
"<p>A label and business card creation program.</p>"
"<font size=\"smaller\">"
"<p><a href=\"http://glabels.org\">Homepage</a></p>"
"<p>Copyright &copy; 2013 Jim Evins <evins@snaught.com></p>"
"</font>"),
QMessageBox::Ok,
parent );
aboutBox.setIconPixmap( QPixmap( ":/images/glabels-logo.png" ) );
aboutBox.exec();
}
std::cout << "TODO: Help::displayContents" << std::endl;
}
///
/// Display Help->About Dialog
///
void Help::displayAbout( QWidget *parent )
{
QMessageBox aboutBox( QMessageBox::NoIcon,
QMessageBox::tr("About gLabels"),
QMessageBox::tr("<h2>gLabels-qt</h2>"
"<p>x.x.x</p>"
"<p>A label and business card creation program.</p>"
"<font size=\"smaller\">"
"<p><a href=\"http://glabels.org\">Homepage</a></p>"
"<p>Copyright &copy; 2013 Jim Evins <evins@snaught.com></p>"
"</font>"),
QMessageBox::Ok,
parent );
aboutBox.setIconPixmap( QPixmap( ":/images/glabels-logo.png" ) );
aboutBox.exec();
}
+10 -12
View File
@@ -18,25 +18,23 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_Help_h
#define glabels_Help_h
#ifndef Help_h
#define Help_h
#include <QWidget>
namespace glabels
///
/// Help Actions
///
namespace Help
{
///
/// Help Actions
///
namespace Help
{
void displayContents( QWidget *parent );
void displayAbout( QWidget *parent );
}
void displayContents( QWidget *parent );
void displayAbout( QWidget *parent );
}
#endif // glabels_Help_h
#endif // Help_h
+354 -357
View File
@@ -18,456 +18,453 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_Icons_h
#define glabels_Icons_h
#ifndef Icons_h
#define Icons_h
#include <QIcon>
namespace glabels
///
/// Glabels Icons
///
namespace Icons
{
class Arrow : public QIcon
{
public:
Arrow()
{
addFile( ":icons/16x16/actions/glabels-arrow.png" );
addFile( ":icons/24x24/actions/glabels-arrow.png" );
}
};
class Barcode : public QIcon
{
public:
Barcode()
{
addFile( ":icons/16x16/actions/glabels-barcode.png" );
addFile( ":icons/24x24/actions/glabels-barcode.png" );
}
};
class Box : public QIcon
{
public:
Box()
{
addFile( ":icons/16x16/actions/glabels-box.png" );
addFile( ":icons/24x24/actions/glabels-box.png" );
}
};
class Ellipse : public QIcon
{
public:
Ellipse()
{
addFile( ":icons/16x16/actions/glabels-ellipse.png" );
addFile( ":icons/24x24/actions/glabels-ellipse.png" );
}
};
class Image : public QIcon
{
public:
Image()
{
addFile( ":icons/16x16/actions/glabels-image.png" );
addFile( ":icons/24x24/actions/glabels-image.png" );
}
};
class Line : public QIcon
{
public:
Line()
{
addFile( ":icons/16x16/actions/glabels-line.png" );
addFile( ":icons/24x24/actions/glabels-line.png" );
}
};
class Text : public QIcon
{
public:
Text()
{
addFile( ":icons/16x16/actions/glabels-text.png" );
addFile( ":icons/24x24/actions/glabels-text.png" );
}
};
class Merge : public QIcon
{
public:
Merge()
{
addFile( ":icons/16x16/actions/glabels-merge.png" );
addFile( ":icons/24x24/actions/glabels-merge.png" );
}
};
class ObjectProperties : public QIcon
{
public:
ObjectProperties()
{
addFile( ":icons/16x16/actions/glabels-object-properties.png" );
addFile( ":icons/24x24/actions/glabels-object-properties.png" );
}
};
class AlignLeft : public QIcon
{
public:
AlignLeft()
{
addFile( ":icons/16x16/actions/glabels-align-left.png" );
}
};
class AlignHCenter : public QIcon
{
public:
AlignHCenter()
{
addFile( ":icons/16x16/actions/glabels-align-hcenter.png" );
}
};
class AlignRight : public QIcon
{
public:
AlignRight()
{
addFile( ":icons/16x16/actions/glabels-align-right.png" );
}
};
class AlignBottom : public QIcon
{
public:
AlignBottom()
{
addFile( ":icons/16x16/actions/glabels-align-bottom.png" );
}
};
class AlignVCenter : public QIcon
{
public:
AlignVCenter()
{
addFile( ":icons/16x16/actions/glabels-align-vcenter.png" );
}
};
class AlignTop : public QIcon
{
public:
AlignTop()
{
addFile( ":icons/16x16/actions/glabels-align-top.png" );
}
};
class CenterHoriz : public QIcon
{
public:
CenterHoriz()
{
addFile( ":icons/16x16/actions/glabels-center-horiz.png" );
}
};
class CenterVert : public QIcon
{
public:
CenterVert()
{
addFile( ":icons/16x16/actions/glabels-center-vert.png" );
}
};
class FlipHoriz : public QIcon
{
public:
FlipHoriz()
{
addFile( ":icons/16x16/actions/glabels-flip-horiz.png" );
}
};
class FlipVert : public QIcon
{
public:
FlipVert()
{
addFile( ":icons/16x16/actions/glabels-flip-vert.png" );
}
};
class RotateLeft : public QIcon
{
public:
RotateLeft()
{
addFile( ":icons/16x16/actions/glabels-rotate-left.png" );
}
};
class RotateRight : public QIcon
{
public:
RotateRight()
{
addFile( ":icons/16x16/actions/glabels-rotate-right.png" );
}
};
class OrderBottom : public QIcon
{
public:
OrderBottom()
{
addFile( ":icons/16x16/actions/glabels-order-bottom.png" );
}
};
class OrderTop : public QIcon
{
public:
OrderTop()
{
addFile( ":icons/16x16/actions/glabels-order-top.png" );
}
};
class AlignTextBottom : public QIcon
{
public:
AlignTextBottom()
{
addFile( ":icons/24x24/actions/glabels-align-text-bottom.png" );
}
};
class AlignTextMiddle : public QIcon
{
public:
AlignTextMiddle()
{
addFile( ":icons/24x24/actions/glabels-align-text-middle.png" );
}
};
class AlignTextTop : public QIcon
{
public:
AlignTextTop()
{
addFile( ":icons/24x24/actions/glabels-align-text-top.png" );
}
};
class BucketFill : public QIcon
{
public:
BucketFill()
{
addFile( ":icons/16x16/actions/glabels-bucket-fill.png" );
addFile( ":icons/24x24/actions/glabels-bucket-fill.png" );
}
};
class Pencil : public QIcon
{
public:
Pencil()
{
addFile( ":icons/16x16/actions/glabels-pencil.png" );
addFile( ":icons/24x24/actions/glabels-pencil.png" );
}
};
class Glabels : public QIcon
{
public:
Glabels()
{
addFile( ":icons/16x16/apps/glabels.png" );
addFile( ":icons/24x24/apps/glabels.png" );
addFile( ":icons/32x32/apps/glabels.png" );
addFile( ":icons/48x48/apps/glabels.png" );
addFile( ":icons/scalable/apps/glabels.svg" );
}
};
///
/// Glabels 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 Icons
namespace Fallback
{
class Arrow : public QIcon
class EditCopy : public QIcon
{
public:
Arrow()
EditCopy()
{
addFile( ":icons/16x16/actions/glabels-arrow.png" );
addFile( ":icons/24x24/actions/glabels-arrow.png" );
addFile( ":icons/24x24/actions/edit-copy.png" );
}
};
class Barcode : public QIcon
class EditCut : public QIcon
{
public:
Barcode()
EditCut()
{
addFile( ":icons/16x16/actions/glabels-barcode.png" );
addFile( ":icons/24x24/actions/glabels-barcode.png" );
addFile( ":icons/24x24/actions/edit-cut.png" );
}
};
class Box : public QIcon
class EditPaste : public QIcon
{
public:
Box()
EditPaste()
{
addFile( ":icons/16x16/actions/glabels-box.png" );
addFile( ":icons/24x24/actions/glabels-box.png" );
addFile( ":icons/24x24/actions/edit-paste.png" );
}
};
class Ellipse : public QIcon
class FileNew : public QIcon
{
public:
Ellipse()
FileNew()
{
addFile( ":icons/16x16/actions/glabels-ellipse.png" );
addFile( ":icons/24x24/actions/glabels-ellipse.png" );
addFile( ":icons/24x24/actions/file-new.png" );
}
};
class Image : public QIcon
class FileOpen : public QIcon
{
public:
Image()
FileOpen()
{
addFile( ":icons/16x16/actions/glabels-image.png" );
addFile( ":icons/24x24/actions/glabels-image.png" );
addFile( ":icons/24x24/actions/file-open.png" );
}
};
class Line : public QIcon
class FilePrint : public QIcon
{
public:
Line()
FilePrint()
{
addFile( ":icons/16x16/actions/glabels-line.png" );
addFile( ":icons/24x24/actions/glabels-line.png" );
addFile( ":icons/24x24/actions/file-print.png" );
addFile( ":icons/32x32/actions/file-print.png" );
}
};
class Text : public QIcon
class FileSave : public QIcon
{
public:
Text()
FileSave()
{
addFile( ":icons/16x16/actions/glabels-text.png" );
addFile( ":icons/24x24/actions/glabels-text.png" );
addFile( ":icons/24x24/actions/file-save.png" );
}
};
class Merge : public QIcon
class FileSaveAs : public QIcon
{
public:
Merge()
FileSaveAs()
{
addFile( ":icons/16x16/actions/glabels-merge.png" );
addFile( ":icons/24x24/actions/glabels-merge.png" );
addFile( ":icons/24x24/actions/file-save-as.png" );
}
};
class ObjectProperties : public QIcon
class ZoomBestFit : public QIcon
{
public:
ObjectProperties()
ZoomBestFit()
{
addFile( ":icons/16x16/actions/glabels-object-properties.png" );
addFile( ":icons/24x24/actions/glabels-object-properties.png" );
addFile( ":icons/24x24/actions/zoom-best-fit.png" );
}
};
class AlignLeft : public QIcon
class ZoomIn : public QIcon
{
public:
AlignLeft()
ZoomIn()
{
addFile( ":icons/16x16/actions/glabels-align-left.png" );
addFile( ":icons/24x24/actions/zoom-in.png" );
}
};
class AlignHCenter : public QIcon
class ZoomOriginal : public QIcon
{
public:
AlignHCenter()
ZoomOriginal()
{
addFile( ":icons/16x16/actions/glabels-align-hcenter.png" );
addFile( ":icons/24x24/actions/zoom-original.png" );
}
};
class AlignRight : public QIcon
class ZoomOut : public QIcon
{
public:
AlignRight()
ZoomOut()
{
addFile( ":icons/16x16/actions/glabels-align-right.png" );
addFile( ":icons/24x24/actions/zoom-out.png" );
}
};
class AlignBottom : public QIcon
{
public:
AlignBottom()
{
addFile( ":icons/16x16/actions/glabels-align-bottom.png" );
}
};
class AlignVCenter : public QIcon
{
public:
AlignVCenter()
{
addFile( ":icons/16x16/actions/glabels-align-vcenter.png" );
}
};
class AlignTop : public QIcon
{
public:
AlignTop()
{
addFile( ":icons/16x16/actions/glabels-align-top.png" );
}
};
class CenterHoriz : public QIcon
{
public:
CenterHoriz()
{
addFile( ":icons/16x16/actions/glabels-center-horiz.png" );
}
};
class CenterVert : public QIcon
{
public:
CenterVert()
{
addFile( ":icons/16x16/actions/glabels-center-vert.png" );
}
};
class FlipHoriz : public QIcon
{
public:
FlipHoriz()
{
addFile( ":icons/16x16/actions/glabels-flip-horiz.png" );
}
};
class FlipVert : public QIcon
{
public:
FlipVert()
{
addFile( ":icons/16x16/actions/glabels-flip-vert.png" );
}
};
class RotateLeft : public QIcon
{
public:
RotateLeft()
{
addFile( ":icons/16x16/actions/glabels-rotate-left.png" );
}
};
class RotateRight : public QIcon
{
public:
RotateRight()
{
addFile( ":icons/16x16/actions/glabels-rotate-right.png" );
}
};
class OrderBottom : public QIcon
{
public:
OrderBottom()
{
addFile( ":icons/16x16/actions/glabels-order-bottom.png" );
}
};
class OrderTop : public QIcon
{
public:
OrderTop()
{
addFile( ":icons/16x16/actions/glabels-order-top.png" );
}
};
class AlignTextBottom : public QIcon
{
public:
AlignTextBottom()
{
addFile( ":icons/24x24/actions/glabels-align-text-bottom.png" );
}
};
class AlignTextMiddle : public QIcon
{
public:
AlignTextMiddle()
{
addFile( ":icons/24x24/actions/glabels-align-text-middle.png" );
}
};
class AlignTextTop : public QIcon
{
public:
AlignTextTop()
{
addFile( ":icons/24x24/actions/glabels-align-text-top.png" );
}
};
class BucketFill : public QIcon
{
public:
BucketFill()
{
addFile( ":icons/16x16/actions/glabels-bucket-fill.png" );
addFile( ":icons/24x24/actions/glabels-bucket-fill.png" );
}
};
class Pencil : public QIcon
{
public:
Pencil()
{
addFile( ":icons/16x16/actions/glabels-pencil.png" );
addFile( ":icons/24x24/actions/glabels-pencil.png" );
}
};
class Glabels : public QIcon
{
public:
Glabels()
{
addFile( ":icons/16x16/apps/glabels.png" );
addFile( ":icons/24x24/apps/glabels.png" );
addFile( ":icons/32x32/apps/glabels.png" );
addFile( ":icons/48x48/apps/glabels.png" );
addFile( ":icons/scalable/apps/glabels.svg" );
}
};
///
/// 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:
EditCopy()
{
addFile( ":icons/24x24/actions/edit-copy.png" );
}
};
class EditCut : public QIcon
{
public:
EditCut()
{
addFile( ":icons/24x24/actions/edit-cut.png" );
}
};
class EditPaste : public QIcon
{
public:
EditPaste()
{
addFile( ":icons/24x24/actions/edit-paste.png" );
}
};
class FileNew : public QIcon
{
public:
FileNew()
{
addFile( ":icons/24x24/actions/file-new.png" );
}
};
class FileOpen : public QIcon
{
public:
FileOpen()
{
addFile( ":icons/24x24/actions/file-open.png" );
}
};
class FilePrint : public QIcon
{
public:
FilePrint()
{
addFile( ":icons/24x24/actions/file-print.png" );
addFile( ":icons/32x32/actions/file-print.png" );
}
};
class FileSave : public QIcon
{
public:
FileSave()
{
addFile( ":icons/24x24/actions/file-save.png" );
}
};
class FileSaveAs : public QIcon
{
public:
FileSaveAs()
{
addFile( ":icons/24x24/actions/file-save-as.png" );
}
};
class ZoomBestFit : public QIcon
{
public:
ZoomBestFit()
{
addFile( ":icons/24x24/actions/zoom-best-fit.png" );
}
};
class ZoomIn : public QIcon
{
public:
ZoomIn()
{
addFile( ":icons/24x24/actions/zoom-in.png" );
}
};
class ZoomOriginal : public QIcon
{
public:
ZoomOriginal()
{
addFile( ":icons/24x24/actions/zoom-original.png" );
}
};
class ZoomOut : public QIcon
{
public:
ZoomOut()
{
addFile( ":icons/24x24/actions/zoom-out.png" );
}
};
}
}
}
#endif // glabels_Icons_h
#endif // Icons_h
+1005 -1011
View File
File diff suppressed because it is too large Load Diff
+252 -256
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_LabelModel_h
#define glabels_LabelModel_h
#ifndef LabelModel_h
#define LabelModel_h
#include <QObject>
#include <QList>
@@ -29,284 +29,280 @@
#include "libglabels/Template.h"
namespace glabels
// Forward References
class LabelModelObject;
class Handle;
class LabelRegion;
class ColorNode;
//////////////////////////////////////////////
//////////////////////////////////////////////
// LabelModel
//////////////////////////////////////////////
//////////////////////////////////////////////
class LabelModel : public QObject
{
// Forward References
class LabelModelObject;
class Handle;
class LabelRegion;
class ColorNode;
//////////////////////////////////////////////
//////////////////////////////////////////////
// LabelModel
//////////////////////////////////////////////
//////////////////////////////////////////////
class LabelModel : public QObject
{
Q_OBJECT
/////////////////////////////////
// Lifecycle
/////////////////////////////////
public:
LabelModel();
virtual ~LabelModel() {}
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void changed();
void nameChanged();
void sizeChanged();
void selectionChanged();
void modifiedChanged();
/////////////////////////////////
// Properties
/////////////////////////////////
public:
inline bool isModified() const;
void clearModified();
QString shortName();
inline const QString& fileName() const;
inline void setFileName( const QString &fileName );
inline int compressionLevel() const;
inline void setCompressionLevel( int compressionLevel );
inline const libglabels::Template* tmplate() const;
inline const libglabels::Frame* frame() const;
inline void setTmplate( const libglabels::Template* tmplate );
inline bool rotate() const;
inline void setRotate( bool rotate );
inline libglabels::Distance w() const;
inline libglabels::Distance h() const;
inline const QList<LabelModelObject*>& objectList() const;
/////////////////////////////////
// Manage objects
/////////////////////////////////
public:
void addObject( LabelModelObject* object );
void deleteObject( LabelModelObject* object );
LabelModelObject* objectAt( double scale,
const libglabels::Distance& x,
const libglabels::Distance& y ) const;
Handle* handleAt( double scale,
const libglabels::Distance& x,
const libglabels::Distance& y ) const;
/////////////////////////////////
// Manipulate selection
/////////////////////////////////
public:
void selectObject( LabelModelObject* object );
void unselectObject( LabelModelObject* object );
void selectAll();
void unselectAll();
void selectRegion( const LabelRegion& region );
bool isSelectionEmpty();
bool isSelectionAtomic();
/////////////////////////////////
// Get selected objects
/////////////////////////////////
public:
QList<LabelModelObject*> getSelection();
LabelModelObject* getFirstSelectedObject();
/////////////////////////////////
// Query selection capabilities
/////////////////////////////////
public:
bool canSelectionText();
bool canSelectionFill();
bool canSelectionLineColor();
bool canSelectionLineWidth();
/////////////////////////////////
// Operations on selections
/////////////////////////////////
public:
void deleteSelection();
void raiseSelectionToTop();
void lowerSelectionToBottom();
void rotateSelection( double thetaDegs );
void rotateSelectionLeft();
void rotateSelectionRight();
void flipSelectionHoriz();
void flipSelectionVert();
void alignSelectionLeft();
void alignSelectionRight();
void alignSelectionHCenter();
void alignSelectionTop();
void alignSelectionBottom();
void alignSelectionVCenter();
void centerSelectionHoriz();
void centerSelectionVert();
void moveSelection( const libglabels::Distance& dx, const libglabels::Distance& dy );
void setSelectionFontFamily( const QString& fontFamily );
void setSelectionFontSize( double fontSize );
void setSelectionFontWeight( QFont::Weight fontWeight );
void setSelectionFontItalicFlag( bool fontItalicFlag );
void setSelectionTextHAlign( Qt::Alignment textHAlign );
void setSelectionTextVAlign( Qt::Alignment textVAlign );
void setSelectionTextLineSpacing( double textLineSpacing );
void setSelectionTextColorNode( ColorNode textColorNode );
void setSelectionLineWidth( const libglabels::Distance& lineWidth );
void setSelectionLineColorNode( ColorNode lineColorNode );
void setSelectionFillColorNode( ColorNode fillColorNode );
/////////////////////////////////
// Drawing operations
/////////////////////////////////
public:
void draw( QPainter* painter, bool inEditor = true, MergeRecord* record = 0 ) const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onObjectChanged();
void onObjectMoved();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
int mUntitledInstance;
bool mModified;
QString mFileName;
int mCompressionLevel;
const libglabels::Template* mTmplate;
const libglabels::Frame* mFrame;
bool mRotate;
QList<LabelModelObject*> mObjectList;
};
Q_OBJECT
/////////////////////////////////
// INLINE METHODS
// Lifecycle
/////////////////////////////////
inline bool LabelModel::isModified() const
{
return mModified;
}
public:
LabelModel();
virtual ~LabelModel() {}
inline const QString& LabelModel::fileName() const
{
return mFileName;
}
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void changed();
void nameChanged();
void sizeChanged();
void selectionChanged();
void modifiedChanged();
inline void LabelModel::setFileName( const QString &fileName )
{
if ( mFileName != fileName )
{
mFileName = fileName;
emit nameChanged();
}
}
/////////////////////////////////
// Properties
/////////////////////////////////
public:
inline bool isModified() const;
void clearModified();
QString shortName();
inline const QString& fileName() const;
inline void setFileName( const QString &fileName );
inline int compressionLevel() const;
inline void setCompressionLevel( int compressionLevel );
inline const glabels::Template* tmplate() const;
inline const glabels::Frame* frame() const;
inline void setTmplate( const glabels::Template* tmplate );
inline bool rotate() const;
inline void setRotate( bool rotate );
inline glabels::Distance w() const;
inline glabels::Distance h() const;
inline const QList<LabelModelObject*>& objectList() const;
/////////////////////////////////
// Manage objects
/////////////////////////////////
public:
void addObject( LabelModelObject* object );
void deleteObject( LabelModelObject* object );
LabelModelObject* objectAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const;
Handle* handleAt( double scale,
const glabels::Distance& x,
const glabels::Distance& y ) const;
inline int LabelModel::compressionLevel() const
{
return mCompressionLevel;
}
/////////////////////////////////
// Manipulate selection
/////////////////////////////////
public:
void selectObject( LabelModelObject* object );
void unselectObject( LabelModelObject* object );
void selectAll();
void unselectAll();
void selectRegion( const LabelRegion& region );
bool isSelectionEmpty();
bool isSelectionAtomic();
inline void LabelModel::setCompressionLevel( int compressionLevel )
{
mCompressionLevel = compressionLevel;
}
/////////////////////////////////
// Get selected objects
/////////////////////////////////
public:
QList<LabelModelObject*> getSelection();
LabelModelObject* getFirstSelectedObject();
inline const libglabels::Template* LabelModel::tmplate() const
{
return mTmplate;
}
/////////////////////////////////
// Query selection capabilities
/////////////////////////////////
public:
bool canSelectionText();
bool canSelectionFill();
bool canSelectionLineColor();
bool canSelectionLineWidth();
inline const libglabels::Frame* LabelModel::frame() const
{
return mFrame;
}
/////////////////////////////////
// Operations on selections
/////////////////////////////////
public:
void deleteSelection();
void raiseSelectionToTop();
void lowerSelectionToBottom();
void rotateSelection( double thetaDegs );
void rotateSelectionLeft();
void rotateSelectionRight();
void flipSelectionHoriz();
void flipSelectionVert();
void alignSelectionLeft();
void alignSelectionRight();
void alignSelectionHCenter();
void alignSelectionTop();
void alignSelectionBottom();
void alignSelectionVCenter();
void centerSelectionHoriz();
void centerSelectionVert();
void moveSelection( const glabels::Distance& dx, const glabels::Distance& dy );
void setSelectionFontFamily( const QString& fontFamily );
void setSelectionFontSize( double fontSize );
void setSelectionFontWeight( QFont::Weight fontWeight );
void setSelectionFontItalicFlag( bool fontItalicFlag );
void setSelectionTextHAlign( Qt::Alignment textHAlign );
void setSelectionTextVAlign( Qt::Alignment textVAlign );
void setSelectionTextLineSpacing( double textLineSpacing );
void setSelectionTextColorNode( ColorNode textColorNode );
void setSelectionLineWidth( const glabels::Distance& lineWidth );
void setSelectionLineColorNode( ColorNode lineColorNode );
void setSelectionFillColorNode( ColorNode fillColorNode );
inline void LabelModel::setTmplate( const libglabels::Template* tmplate )
{
if (mTmplate != tmplate)
{
mTmplate = tmplate;
mFrame = tmplate->frames().first();
mModified = true;
emit changed();
emit sizeChanged();
}
}
/////////////////////////////////
// Drawing operations
/////////////////////////////////
public:
void draw( QPainter* painter, bool inEditor = true, MergeRecord* record = 0 ) const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onObjectChanged();
void onObjectMoved();
inline bool LabelModel::rotate() const
{
return mRotate;
}
/////////////////////////////////
// Private data
/////////////////////////////////
private:
int mUntitledInstance;
bool mModified;
QString mFileName;
int mCompressionLevel;
const glabels::Template* mTmplate;
const glabels::Frame* mFrame;
bool mRotate;
QList<LabelModelObject*> mObjectList;
};
inline void LabelModel::setRotate( bool rotate )
{
if (mRotate != rotate)
{
mRotate = rotate;
mModified = true;
emit changed();
emit sizeChanged();
}
}
inline libglabels::Distance LabelModel::w() const
{
return mRotate ? mFrame->h() : mFrame->w();
}
inline libglabels::Distance LabelModel::h() const
{
return mRotate ? mFrame->w() : mFrame->h();
}
inline const QList<LabelModelObject*>& LabelModel::objectList() const
{
return mObjectList;
}
/////////////////////////////////
// INLINE METHODS
/////////////////////////////////
inline bool LabelModel::isModified() const
{
return mModified;
}
#endif // glabels_LabelModel_h
inline const QString& LabelModel::fileName() const
{
return mFileName;
}
inline void LabelModel::setFileName( const QString &fileName )
{
if ( mFileName != fileName )
{
mFileName = fileName;
emit nameChanged();
}
}
inline int LabelModel::compressionLevel() const
{
return mCompressionLevel;
}
inline void LabelModel::setCompressionLevel( int compressionLevel )
{
mCompressionLevel = compressionLevel;
}
inline const glabels::Template* LabelModel::tmplate() const
{
return mTmplate;
}
inline const glabels::Frame* LabelModel::frame() const
{
return mFrame;
}
inline void LabelModel::setTmplate( const glabels::Template* tmplate )
{
if (mTmplate != tmplate)
{
mTmplate = tmplate;
mFrame = tmplate->frames().first();
mModified = true;
emit changed();
emit sizeChanged();
}
}
inline bool LabelModel::rotate() const
{
return mRotate;
}
inline void LabelModel::setRotate( bool rotate )
{
if (mRotate != rotate)
{
mRotate = rotate;
mModified = true;
emit changed();
emit sizeChanged();
}
}
inline glabels::Distance LabelModel::w() const
{
return mRotate ? mFrame->h() : mFrame->w();
}
inline glabels::Distance LabelModel::h() const
{
return mRotate ? mFrame->w() : mFrame->h();
}
inline const QList<LabelModelObject*>& LabelModel::objectList() const
{
return mObjectList;
}
#endif // LabelModel_h
+95 -100
View File
@@ -30,120 +30,115 @@ namespace
}
namespace glabels
///
/// Constructor
///
LabelModelBoxObject::LabelModelBoxObject( QObject* parent ) : LabelModelShapeObject(parent)
{
///
/// Constructor
///
LabelModelBoxObject::LabelModelBoxObject( QObject* parent ) : LabelModelShapeObject(parent)
{
}
}
///
/// Destructor
///
LabelModelBoxObject::~LabelModelBoxObject()
{
}
///
/// Destructor
///
LabelModelBoxObject::~LabelModelBoxObject()
{
}
///
/// Draw shadow of object
///
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const
{
/// TODO expand colors based on record
///
/// Draw shadow of object
///
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const
{
/// TODO expand colors based on record
QColor lineColor = mLineColorNode.color();
QColor fillColor = mFillColorNode.color();
QColor shadowColor = mShadowColorNode.color();
QColor lineColor = mLineColorNode.color();
QColor fillColor = mFillColorNode.color();
QColor shadowColor = mShadowColorNode.color();
shadowColor.setAlphaF( mShadowOpacity );
shadowColor.setAlphaF( mShadowOpacity );
if ( fillColor.alpha() )
if ( fillColor.alpha() )
{
painter->setPen( Qt::NoPen );
painter->setBrush( shadowColor );
if ( lineColor.alpha() )
{
painter->setPen( Qt::NoPen );
painter->setBrush( shadowColor );
if ( lineColor.alpha() )
{
/* Has FILL and OUTLINE: adjust size to account for line width. */
painter->drawRect( QRectF( -mLineWidth.pt()/2,
-mLineWidth.pt()/2,
(mW + mLineWidth).pt(),
(mH + mLineWidth).pt() ) );
}
else
{
/* Has FILL, but no OUTLINE. */
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
}
/* Has FILL and OUTLINE: adjust size to account for line width. */
painter->drawRect( QRectF( -mLineWidth.pt()/2,
-mLineWidth.pt()/2,
(mW + mLineWidth).pt(),
(mH + mLineWidth).pt() ) );
}
else
{
if ( lineColor.alpha() )
{
/* Has only OUTLINE. */
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
painter->setBrush( Qt::NoBrush );
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
}
/* Has FILL, but no OUTLINE. */
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
}
}
///
/// Draw object itself
///
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, MergeRecord* record ) const
else
{
/// TODO expand colors based on record
if ( lineColor.alpha() )
{
/* Has only OUTLINE. */
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
painter->setBrush( Qt::NoBrush );
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
}
}
QColor lineColor = mLineColorNode.color();
QColor fillColor = mFillColorNode.color();
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
painter->setBrush( fillColor );
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
}
///
/// Path to test for hover condition
///
QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
{
double s = 1 / scale;
QPainterPath path;
if ( mFillColorNode.color().alpha() && mLineColorNode.color().alpha() )
{
path.addRect( -mLineWidth.pt()/2, -mLineWidth.pt()/2, (mW+mLineWidth).pt(), (mH+mLineWidth).pt() );
}
else if ( mFillColorNode.color().alpha() && !(mLineColorNode.color().alpha()) )
{
path.addRect( 0, 0, mW.pt(), mH.pt() );
}
else if ( mLineColorNode.color().alpha() )
{
path.addRect( (-mLineWidth.pt()/2) - s*slopPixels,
(-mLineWidth.pt()/2) - s*slopPixels,
(mW + mLineWidth).pt() + s*2*slopPixels,
(mH + mLineWidth).pt() + s*2*slopPixels );
path.closeSubpath();
path.addRect( mLineWidth.pt()/2 + s*slopPixels,
mLineWidth.pt()/2 + s*slopPixels,
(mW - mLineWidth).pt() - s*2*slopPixels,
(mH - mLineWidth).pt() - s*2*slopPixels );
}
return path;
}
}
///
/// Draw object itself
///
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, MergeRecord* record ) const
{
/// TODO expand colors based on record
QColor lineColor = mLineColorNode.color();
QColor fillColor = mFillColorNode.color();
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
painter->setBrush( fillColor );
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
}
///
/// Path to test for hover condition
///
QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
{
double s = 1 / scale;
QPainterPath path;
if ( mFillColorNode.color().alpha() && mLineColorNode.color().alpha() )
{
path.addRect( -mLineWidth.pt()/2, -mLineWidth.pt()/2, (mW+mLineWidth).pt(), (mH+mLineWidth).pt() );
}
else if ( mFillColorNode.color().alpha() && !(mLineColorNode.color().alpha()) )
{
path.addRect( 0, 0, mW.pt(), mH.pt() );
}
else if ( mLineColorNode.color().alpha() )
{
path.addRect( (-mLineWidth.pt()/2) - s*slopPixels,
(-mLineWidth.pt()/2) - s*slopPixels,
(mW + mLineWidth).pt() + s*2*slopPixels,
(mH + mLineWidth).pt() + s*2*slopPixels );
path.closeSubpath();
path.addRect( mLineWidth.pt()/2 + s*slopPixels,
mLineWidth.pt()/2 + s*slopPixels,
(mW - mLineWidth).pt() - s*2*slopPixels,
(mH - mLineWidth).pt() - s*2*slopPixels );
}
return path;
}
+22 -26
View File
@@ -18,41 +18,37 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_LabelModelBoxObject_h
#define glabels_LabelModelBoxObject_h
#ifndef LabelModelBoxObject_h
#define LabelModelBoxObject_h
#include "LabelModelShapeObject.h"
namespace glabels
///
/// Label Model Box Object
///
class LabelModelBoxObject : public LabelModelShapeObject
{
Q_OBJECT
///
/// Label Model Box Object
///
class LabelModelBoxObject : public LabelModelShapeObject
{
Q_OBJECT
///////////////////////////////////////////////////////////////
// Lifecycle Methods
///////////////////////////////////////////////////////////////
public:
LabelModelBoxObject( QObject* parent = 0 );
virtual ~LabelModelBoxObject();
///////////////////////////////////////////////////////////////
// Lifecycle Methods
///////////////////////////////////////////////////////////////
public:
LabelModelBoxObject( QObject* parent = 0 );
virtual ~LabelModelBoxObject();
///////////////////////////////////////////////////////////////
// Drawing operations
///////////////////////////////////////////////////////////////
protected:
virtual void drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const;
virtual void drawObject( QPainter* painter, bool inEditor, MergeRecord* record ) const;
virtual QPainterPath hoverPath( double scale ) const;
///////////////////////////////////////////////////////////////
// Drawing operations
///////////////////////////////////////////////////////////////
protected:
virtual void drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const;
virtual void drawObject( QPainter* painter, bool inEditor, MergeRecord* record ) const;
virtual QPainterPath hoverPath( double scale ) const;
};
};
}
#endif // glabels_LabelModelBoxObject_h
#endif // LabelModelBoxObject_h
File diff suppressed because it is too large Load Diff
+260 -263
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_LabelModelObject_h
#define glabels_LabelModelObject_h
#ifndef LabelModelObject_h
#define LabelModelObject_h
#include <QObject>
#include <QFont>
@@ -34,345 +34,342 @@
#include "Outline.h"
namespace glabels
// Forward References
class LabelRegion;
class MergeRecord;
///
/// Label Model Object Base Class
///
class LabelModelObject : public QObject
{
// Forward References
class LabelRegion;
class MergeRecord;
Q_OBJECT
///////////////////////////////////////////////////////////////
// Lifecycle Methods
///////////////////////////////////////////////////////////////
public:
LabelModelObject( QObject *parent );
virtual ~LabelModelObject();
///
/// Label Model Object Base Class
///
class LabelModelObject : public QObject
{
Q_OBJECT
///////////////////////////////////////////////////////////////
// Lifecycle Methods
///////////////////////////////////////////////////////////////
public:
LabelModelObject( QObject *parent );
virtual ~LabelModelObject();
///////////////////////////////////////////////////////////////
// Signals
///////////////////////////////////////////////////////////////
signals:
void moved();
void changed();
///////////////////////////////////////////////////////////////
// Signals
///////////////////////////////////////////////////////////////
signals:
void moved();
void changed();
///////////////////////////////////////////////////////////////
// Common Properties
///////////////////////////////////////////////////////////////
public:
//
// ID Property.
//
int id() const;
//
// Selected Property.
//
bool isSelected() const;
void select( bool value = true );
void unselect();
///////////////////////////////////////////////////////////////
// Common Properties
///////////////////////////////////////////////////////////////
public:
//
// ID Property.
//
int id() const;
//
// Selected Property.
//
bool isSelected() const;
void select( bool value = true );
void unselect();
//
// x0 Property ( x coordinate of origin )
//
libglabels::Distance x0() const;
void setX0( const libglabels::Distance& value );
//
// x0 Property ( x coordinate of origin )
//
glabels::Distance x0() const;
void setX0( const glabels::Distance& value );
//
// y0 Property ( y coordinate of origin )
//
libglabels::Distance y0() const;
void setY0( const libglabels::Distance& value );
//
// y0 Property ( y coordinate of origin )
//
glabels::Distance y0() const;
void setY0( const glabels::Distance& value );
//
// w Property ( width of bounding box )
//
libglabels::Distance w() const;
void setW( const libglabels::Distance& value );
//
// w Property ( width of bounding box )
//
glabels::Distance w() const;
void setW( const glabels::Distance& value );
//
// h Property ( height of bounding box )
//
libglabels::Distance h() const;
void setH( const libglabels::Distance& value );
//
// h Property ( height of bounding box )
//
glabels::Distance h() const;
void setH( const glabels::Distance& value );
//
// Transformation Matrix Property
//
QMatrix matrix() const;
void setMatrix( const QMatrix& value );
//
// Transformation Matrix Property
//
QMatrix matrix() const;
void setMatrix( const QMatrix& value );
//
// Shadow State Property
//
bool shadow() const;
void setShadow( bool value );
//
// Shadow State Property
//
bool shadow() const;
void setShadow( bool value );
//
// Shadow x Offset Property
//
libglabels::Distance shadowX() const;
void setShadowX( const libglabels::Distance& value );
//
// Shadow x Offset Property
//
glabels::Distance shadowX() const;
void setShadowX( const glabels::Distance& value );
//
// Shadow y Offset Property
//
libglabels::Distance shadowY() const;
void setShadowY( const libglabels::Distance& value );
//
// Shadow y Offset Property
//
glabels::Distance shadowY() const;
void setShadowY( const glabels::Distance& value );
//
// Shadow opacity Property
//
double shadowOpacity() const;
void setShadowOpacity( double value );
//
// Shadow opacity Property
//
double shadowOpacity() const;
void setShadowOpacity( double value );
//
// Shadow Color Property
//
ColorNode shadowColorNode() const;
void setShadowColorNode( const ColorNode& value );
//
// Shadow Color Property
//
ColorNode shadowColorNode() const;
void setShadowColorNode( const ColorNode& value );
///////////////////////////////////////////////////////////////
// Text Properties Virtual Interface
///////////////////////////////////////////////////////////////
public:
//
// Virtual Text Property: fontFamily
//
virtual QString fontFamily() const;
virtual void setFontFamily( const QString &value );
///////////////////////////////////////////////////////////////
// Text Properties Virtual Interface
///////////////////////////////////////////////////////////////
public:
//
// Virtual Text Property: fontFamily
//
virtual QString fontFamily() const;
virtual void setFontFamily( const QString &value );
//
// Virtual Text Property: fontSize
//
virtual double fontSize() const;
virtual void setFontSize( double value );
//
// Virtual Text Property: fontSize
//
virtual double fontSize() const;
virtual void setFontSize( double value );
//
// Virtual Text Property: fontWeight
//
virtual QFont::Weight fontWeight() const;
virtual void setFontWeight( QFont::Weight value );
//
// Virtual Text Property: fontWeight
//
virtual QFont::Weight fontWeight() const;
virtual void setFontWeight( QFont::Weight value );
//
// Virtual Text Property: fontItalicFlag
//
virtual bool fontItalicFlag() const;
virtual void setFontItalicFlag( bool value );
//
// Virtual Text Property: fontItalicFlag
//
virtual bool fontItalicFlag() const;
virtual void setFontItalicFlag( bool value );
//
// Virtual Text Property: fontUnderlineFlag
//
virtual bool fontUnderlineFlag() const;
virtual void setFontUnderlineFlag( bool value );
//
// Virtual Text Property: fontUnderlineFlag
//
virtual bool fontUnderlineFlag() const;
virtual void setFontUnderlineFlag( bool value );
//
// Virtual Text Property: textColorNode
//
virtual ColorNode textColorNode() const;
virtual void setTextColorNode( const ColorNode &value );
//
// Virtual Text Property: textColorNode
//
virtual ColorNode textColorNode() const;
virtual void setTextColorNode( const ColorNode &value );
//
// Virtual Text Property: textHAlign
//
virtual Qt::Alignment textHAlign() const;
virtual void setTextHAlign( Qt::Alignment value );
//
// Virtual Text Property: textHAlign
//
virtual Qt::Alignment textHAlign() const;
virtual void setTextHAlign( Qt::Alignment value );
//
// Virtual Text Property: textVAlign
//
virtual Qt::Alignment textVAlign() const;
virtual void setTextVAlign( Qt::Alignment value );
//
// Virtual Text Property: textVAlign
//
virtual Qt::Alignment textVAlign() const;
virtual void setTextVAlign( Qt::Alignment value );
//
// Virtual Text Property: textLineSpacing
//
virtual double textLineSpacing() const;
virtual void setTextLineSpacing( double value );
//
// Virtual Text Property: textLineSpacing
//
virtual double textLineSpacing() const;
virtual void setTextLineSpacing( double value );
///////////////////////////////////////////////////////////////
// Image Properties Virtual Interface
///////////////////////////////////////////////////////////////
public:
//
// Virtual Image Property: filenameNode
//
virtual TextNode filenameNode() const;
virtual void setFilenameNode( const TextNode &value );
///////////////////////////////////////////////////////////////
// Image Properties Virtual Interface
///////////////////////////////////////////////////////////////
public:
//
// Virtual Image Property: filenameNode
//
virtual TextNode filenameNode() const;
virtual void setFilenameNode( const TextNode &value );
///////////////////////////////////////////////////////////////
// Shape Properties Virtual Interface
///////////////////////////////////////////////////////////////
public:
//
// Virtual Shape Property: lineWidth
//
virtual libglabels::Distance lineWidth() const;
virtual void setLineWidth( const libglabels::Distance& value );
///////////////////////////////////////////////////////////////
// Shape Properties Virtual Interface
///////////////////////////////////////////////////////////////
public:
//
// Virtual Shape Property: lineWidth
//
virtual glabels::Distance lineWidth() const;
virtual void setLineWidth( const glabels::Distance& value );
//
// Virtual Shape Property: lineColorNode
//
virtual ColorNode lineColorNode() const;
virtual void setLineColorNode( const ColorNode &value );
//
// Virtual Shape Property: lineColorNode
//
virtual ColorNode lineColorNode() const;
virtual void setLineColorNode( const ColorNode &value );
//
// Virtual Shape Property: fillColorNode
//
virtual ColorNode fillColorNode() const;
virtual void setFillColorNode( const ColorNode &value );
//
// Virtual Shape Property: fillColorNode
//
virtual ColorNode fillColorNode() const;
virtual void setFillColorNode( const ColorNode &value );
///////////////////////////////////////////////////////////////
// Barcode Properties Virtual Interface
///////////////////////////////////////////////////////////////
public:
//
// Virtual Barcode Property: bcDataNode
//
virtual TextNode bcDataNode() const;
virtual void setBcDataNode( const TextNode &value );
///////////////////////////////////////////////////////////////
// Barcode Properties Virtual Interface
///////////////////////////////////////////////////////////////
public:
//
// Virtual Barcode Property: bcDataNode
//
virtual TextNode bcDataNode() const;
virtual void setBcDataNode( const TextNode &value );
//
// Virtual Barcode Property: bcTextFlag
//
virtual bool bcTextFlag() const;
virtual void setBcTextFlag( bool value );
//
// Virtual Barcode Property: bcTextFlag
//
virtual bool bcTextFlag() const;
virtual void setBcTextFlag( bool value );
//
// Virtual Barcode Property: bcChecksumFlag
//
virtual bool bcChecksumFlag() const;
virtual void setBcChecksumFlag( bool value );
//
// Virtual Barcode Property: bcChecksumFlag
//
virtual bool bcChecksumFlag() const;
virtual void setBcChecksumFlag( bool value );
//
// Virtual Barcode Property: bcColorNode
//
virtual ColorNode bcColorNode() const;
virtual void setBcColorNode( const ColorNode &value );
//
// Virtual Barcode Property: bcColorNode
//
virtual ColorNode bcColorNode() const;
virtual void setBcColorNode( const ColorNode &value );
//
// Virtual Barcode Property: bcStyle
//
virtual BarcodeStyle bcStyle() const;
virtual void setBcStyle( const BarcodeStyle &value );
//
// Virtual Barcode Property: bcStyle
//
virtual BarcodeStyle bcStyle() const;
virtual void setBcStyle( const BarcodeStyle &value );
//
// Virtual Barcode Property: bcFormatDigits
//
virtual int bcFormatDigits() const;
virtual void setBcFormatDigits( int value );
//
// Virtual Barcode Property: bcFormatDigits
//
virtual int bcFormatDigits() const;
virtual void setBcFormatDigits( int value );
///////////////////////////////////////////////////////////////
// Capabilities (Overridden by concrete classes.)
///////////////////////////////////////////////////////////////
public:
virtual bool canText() const;
virtual bool canFill() const;
virtual bool canLineColor() const;
virtual bool canLineWidth() const;
///////////////////////////////////////////////////////////////
// Capabilities (Overridden by concrete classes.)
///////////////////////////////////////////////////////////////
public:
virtual bool canText() const;
virtual bool canFill() const;
virtual bool canLineColor() const;
virtual bool canLineWidth() const;
///////////////////////////////////////////////////////////////
// Position and Size methods
///////////////////////////////////////////////////////////////
public:
void setPosition( const libglabels::Distance& x0, const libglabels::Distance& y0 );
void setPositionRelative( const libglabels::Distance& dx, const libglabels::Distance& dy );
void setSize( const libglabels::Distance& w, const libglabels::Distance& h );
void setSizeHonorAspect( const libglabels::Distance& w, const libglabels::Distance& h );
void setWHonorAspect( const libglabels::Distance& w );
void setHHonorAspect( const libglabels::Distance& h );
LabelRegion getExtent();
void rotate( double thetaDegs );
void flipHoriz();
void flipVert();
bool isLocatedAt( double scale, const libglabels::Distance& x, const libglabels::Distance& y ) const;
Handle* handleAt( double scale, const libglabels::Distance& x, const libglabels::Distance& y ) const;
///////////////////////////////////////////////////////////////
// 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 setSize( const glabels::Distance& w, const glabels::Distance& h );
void setSizeHonorAspect( const glabels::Distance& w, const glabels::Distance& h );
void setWHonorAspect( const glabels::Distance& w );
void setHHonorAspect( const glabels::Distance& h );
LabelRegion 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;
///////////////////////////////////////////////////////////////
// Drawing operations
///////////////////////////////////////////////////////////////
public:
void draw( QPainter* painter, bool inEditor, MergeRecord* record ) const;
void drawSelectionHighlight( QPainter* painter, double scale ) const;
///////////////////////////////////////////////////////////////
// Drawing operations
///////////////////////////////////////////////////////////////
public:
void draw( QPainter* painter, bool inEditor, MergeRecord* record ) const;
void drawSelectionHighlight( QPainter* painter, double scale ) const;
protected:
virtual void drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const = 0;
virtual void drawObject( QPainter* painter, bool inEditor, MergeRecord* record ) const = 0;
virtual QPainterPath hoverPath( double scale ) const = 0;
protected:
virtual void drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const = 0;
virtual void drawObject( QPainter* painter, bool inEditor, MergeRecord* record ) const = 0;
virtual QPainterPath hoverPath( double scale ) const = 0;
///////////////////////////////////////////////////////////////
// Protected Members
///////////////////////////////////////////////////////////////
protected:
bool mSelectedFlag;
///////////////////////////////////////////////////////////////
// Protected Members
///////////////////////////////////////////////////////////////
protected:
bool mSelectedFlag;
libglabels::Distance mX0;
libglabels::Distance mY0;
libglabels::Distance mW;
libglabels::Distance mH;
glabels::Distance mX0;
glabels::Distance mY0;
glabels::Distance mW;
glabels::Distance mH;
bool mShadowState;
libglabels::Distance mShadowX;
libglabels::Distance mShadowY;
double mShadowOpacity;
ColorNode mShadowColorNode;
bool mShadowState;
glabels::Distance mShadowX;
glabels::Distance mShadowY;
double mShadowOpacity;
ColorNode mShadowColorNode;
QList<Handle*> mHandles;
Outline* mOutline;
QList<Handle*> mHandles;
Outline* mOutline;
///////////////////////////////////////////////////////////////
// Private Members
///////////////////////////////////////////////////////////////
private:
static int msNextId;
int mId;
///////////////////////////////////////////////////////////////
// Private Members
///////////////////////////////////////////////////////////////
private:
static int msNextId;
int mId;
QMatrix mMatrix;
QMatrix mMatrix;
};
};
}
#endif // glabels_LabelModelObject_h
#endif // LabelModelObject_h
+124 -130
View File
@@ -24,137 +24,131 @@
#include <QPen>
namespace glabels
///
/// Constructor
///
LabelModelShapeObject::LabelModelShapeObject( QObject* parent ) : LabelModelObject(parent)
{
mOutline = new Outline( this );
///
/// Constructor
///
LabelModelShapeObject::LabelModelShapeObject( QObject* parent ) : LabelModelObject(parent)
{
mOutline = new Outline( this );
mHandles << new HandleNorthWest( this );
mHandles << new HandleNorth( this );
mHandles << new HandleNorthEast( this );
mHandles << new HandleEast( this );
mHandles << new HandleSouthEast( this );
mHandles << new HandleSouth( this );
mHandles << new HandleSouthWest( this );
mHandles << new HandleWest( this );
mLineWidth = 1.0;
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
}
///
/// Destructor
///
LabelModelShapeObject::~LabelModelShapeObject()
{
delete mOutline;
foreach( Handle* handle, mHandles )
{
delete handle;
}
mHandles.clear();
}
///
/// Line Width Property Getter
///
libglabels::Distance LabelModelShapeObject::lineWidth( void ) const
{
return mLineWidth;
}
///
/// Line Width Property Setter
///
void LabelModelShapeObject::setLineWidth( const libglabels::Distance& value )
{
if ( mLineWidth != value )
{
mLineWidth = value;
emit changed();
}
}
///
/// Line Color Node Property Getter
///
ColorNode LabelModelShapeObject::lineColorNode( void ) const
{
return mLineColorNode;
}
///
/// Line Color Node Property Setter
///
void LabelModelShapeObject::setLineColorNode( const ColorNode& value )
{
if ( mLineColorNode != value )
{
mLineColorNode = value;
emit changed();
}
}
///
/// Fill Color Node Property Getter
///
ColorNode LabelModelShapeObject::fillColorNode( void ) const
{
return mFillColorNode;
}
///
/// Fill Color Node Property Setter
///
void LabelModelShapeObject::setFillColorNode( const ColorNode& value )
{
if ( mFillColorNode != value )
{
mFillColorNode = value;
emit changed();
}
}
///
/// Can Fill Capability Implementation
///
bool LabelModelShapeObject::canFill()
{
return true;
}
///
/// Can Line Color Capability Implementation
///
bool LabelModelShapeObject::canLineColor()
{
return true;
}
///
/// Can Line Width Capability Implementation
///
bool LabelModelShapeObject::canLineWidth()
{
return true;
}
mHandles << new HandleNorthWest( this );
mHandles << new HandleNorth( this );
mHandles << new HandleNorthEast( this );
mHandles << new HandleEast( this );
mHandles << new HandleSouthEast( this );
mHandles << new HandleSouth( this );
mHandles << new HandleSouthWest( this );
mHandles << new HandleWest( this );
mLineWidth = 1.0;
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
}
///
/// Destructor
///
LabelModelShapeObject::~LabelModelShapeObject()
{
delete mOutline;
foreach( Handle* handle, mHandles )
{
delete handle;
}
mHandles.clear();
}
///
/// Line Width Property Getter
///
glabels::Distance LabelModelShapeObject::lineWidth( void ) const
{
return mLineWidth;
}
///
/// Line Width Property Setter
///
void LabelModelShapeObject::setLineWidth( const glabels::Distance& value )
{
if ( mLineWidth != value )
{
mLineWidth = value;
emit changed();
}
}
///
/// Line Color Node Property Getter
///
ColorNode LabelModelShapeObject::lineColorNode( void ) const
{
return mLineColorNode;
}
///
/// Line Color Node Property Setter
///
void LabelModelShapeObject::setLineColorNode( const ColorNode& value )
{
if ( mLineColorNode != value )
{
mLineColorNode = value;
emit changed();
}
}
///
/// Fill Color Node Property Getter
///
ColorNode LabelModelShapeObject::fillColorNode( void ) const
{
return mFillColorNode;
}
///
/// Fill Color Node Property Setter
///
void LabelModelShapeObject::setFillColorNode( const ColorNode& value )
{
if ( mFillColorNode != value )
{
mFillColorNode = value;
emit changed();
}
}
///
/// Can Fill Capability Implementation
///
bool LabelModelShapeObject::canFill()
{
return true;
}
///
/// Can Line Color Capability Implementation
///
bool LabelModelShapeObject::canLineColor()
{
return true;
}
///
/// Can Line Width Capability Implementation
///
bool LabelModelShapeObject::canLineWidth()
{
return true;
}
+49 -53
View File
@@ -18,75 +18,71 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_LabelModelShapeObject_h
#define glabels_LabelModelShapeObject_h
#ifndef LabelModelShapeObject_h
#define LabelModelShapeObject_h
#include "LabelModelObject.h"
namespace glabels
///
/// Label Model Shape Object (Box or Ellipse)
///
class LabelModelShapeObject : public LabelModelObject
{
Q_OBJECT
///
/// Label Model Shape Object (Box or Ellipse)
///
class LabelModelShapeObject : public LabelModelObject
{
Q_OBJECT
///////////////////////////////////////////////////////////////
// Lifecycle Methods
///////////////////////////////////////////////////////////////
protected:
LabelModelShapeObject( QObject* parent = 0 );
public:
virtual ~LabelModelShapeObject();
///////////////////////////////////////////////////////////////
// Lifecycle Methods
///////////////////////////////////////////////////////////////
protected:
LabelModelShapeObject( QObject* parent = 0 );
public:
virtual ~LabelModelShapeObject();
///////////////////////////////////////////////////////////////
// Property Implementations
///////////////////////////////////////////////////////////////
public:
//
// Shape Property: lineWidth
//
virtual libglabels::Distance lineWidth( void ) const;
virtual void setLineWidth( const libglabels::Distance& value );
///////////////////////////////////////////////////////////////
// Property Implementations
///////////////////////////////////////////////////////////////
public:
//
// Shape Property: lineWidth
//
virtual glabels::Distance lineWidth( void ) const;
virtual void setLineWidth( const glabels::Distance& value );
//
// Shape Property: lineColorNode
//
virtual ColorNode lineColorNode( void ) const;
virtual void setLineColorNode( const ColorNode& value );
//
// Shape Property: lineColorNode
//
virtual ColorNode lineColorNode( void ) const;
virtual void setLineColorNode( const ColorNode& value );
//
// Shape Property: fillColorNode
//
virtual ColorNode fillColorNode( void ) const;
virtual void setFillColorNode( const ColorNode& value );
//
// Shape Property: fillColorNode
//
virtual ColorNode fillColorNode( void ) const;
virtual void setFillColorNode( const ColorNode& value );
///////////////////////////////////////////////////////////////
// Capability Implementations
///////////////////////////////////////////////////////////////
public:
virtual bool canFill();
virtual bool canLineColor();
virtual bool canLineWidth();
///////////////////////////////////////////////////////////////
// Capability Implementations
///////////////////////////////////////////////////////////////
public:
virtual bool canFill();
virtual bool canLineColor();
virtual bool canLineWidth();
///////////////////////////////////////////////////////////////
// Private Members
///////////////////////////////////////////////////////////////
protected:
libglabels::Distance mLineWidth;
ColorNode mLineColorNode;
ColorNode mFillColorNode;
///////////////////////////////////////////////////////////////
// Private Members
///////////////////////////////////////////////////////////////
protected:
glabels::Distance mLineWidth;
ColorNode mLineColorNode;
ColorNode mFillColorNode;
};
};
}
#endif // glabels_LabelModelShapeObject_h
#endif // LabelModelShapeObject_h
+9 -14
View File
@@ -24,22 +24,17 @@
#include <cmath>
namespace glabels
QRectF LabelRegion::rect() const
{
using std::min;
using std::fabs;
QRectF LabelRegion::rect() const
{
using std::min;
using std::fabs;
QRectF r;
QRectF r;
r.setX( min( mX1, mX2 ).pt() );
r.setY( min( mY1, mY2 ).pt() );
r.setWidth( fabs( mX2 - mX1 ).pt() );
r.setHeight( fabs( mY2 - mY1 ).pt() );
return r;
}
r.setX( min( mX1, mX2 ).pt() );
r.setY( min( mY1, mY2 ).pt() );
r.setWidth( fabs( mX2 - mX1 ).pt() );
r.setHeight( fabs( mY2 - mY1 ).pt() );
return r;
}
+92 -96
View File
@@ -18,123 +18,119 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_LabelRegion_h
#define glabels_LabelRegion_h
#ifndef LabelRegion_h
#define LabelRegion_h
#include <QRectF>
#include "libglabels/Distance.h"
namespace glabels
///
/// Label Region Type
///
struct LabelRegion
{
///
/// Label Region Type
///
struct LabelRegion
{
/////////////////////////////////
// Properties
/////////////////////////////////
public:
//
// X1 Property
//
libglabels::Distance x1( void ) const;
void setX1( const libglabels::Distance& value );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
//
// X1 Property
//
glabels::Distance x1( void ) const;
void setX1( const glabels::Distance& value );
//
// Y1 Property
//
libglabels::Distance y1( void ) const;
void setY1( const libglabels::Distance& value );
//
// Y1 Property
//
glabels::Distance y1( void ) const;
void setY1( const glabels::Distance& value );
//
// X2 Property
//
libglabels::Distance x2( void ) const;
void setX2( const libglabels::Distance& value );
//
// X2 Property
//
glabels::Distance x2( void ) const;
void setX2( const glabels::Distance& value );
//
// Y2 Property
//
libglabels::Distance y2( void ) const;
void setY2( const libglabels::Distance& value );
/////////////////////////////////
// Methods
/////////////////////////////////
public:
QRectF rect() const;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
libglabels::Distance mX1;
libglabels::Distance mY1;
libglabels::Distance mX2;
libglabels::Distance mY2;
};
//
// Y2 Property
//
glabels::Distance y2( void ) const;
void setY2( const glabels::Distance& value );
/////////////////////////////////
// INLINE METHODS
// Methods
/////////////////////////////////
inline libglabels::Distance LabelRegion::x1( void ) const
{
return mX1;
}
public:
QRectF rect() const;
inline void LabelRegion::setX1( const libglabels::Distance& value )
{
mX1 = value;
}
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
glabels::Distance mX1;
glabels::Distance mY1;
glabels::Distance mX2;
glabels::Distance mY2;
};
inline libglabels::Distance LabelRegion::y1( void ) const
{
return mY1;
}
inline void LabelRegion::setY1( const libglabels::Distance& value )
{
mY1 = value;
}
inline libglabels::Distance LabelRegion::x2( void ) const
{
return mX2;
}
inline void LabelRegion::setX2( const libglabels::Distance& value )
{
mX2 = value;
}
inline libglabels::Distance LabelRegion::y2( void ) const
{
return mY2;
}
inline void LabelRegion::setY2( const libglabels::Distance& value )
{
mY2 = value;
}
/////////////////////////////////
// INLINE METHODS
/////////////////////////////////
inline glabels::Distance LabelRegion::x1( void ) const
{
return mX1;
}
#endif // glabels_LabelRegion_h
inline void LabelRegion::setX1( const glabels::Distance& value )
{
mX1 = value;
}
inline glabels::Distance LabelRegion::y1( void ) const
{
return mY1;
}
inline void LabelRegion::setY1( const glabels::Distance& value )
{
mY1 = value;
}
inline glabels::Distance LabelRegion::x2( void ) const
{
return mX2;
}
inline void LabelRegion::setX2( const glabels::Distance& value )
{
mX2 = value;
}
inline glabels::Distance LabelRegion::y2( void ) const
{
return mY2;
}
inline void LabelRegion::setY2( const glabels::Distance& value )
{
mY2 = value;
}
#endif // LabelRegion_h
+1315 -1322
View File
File diff suppressed because it is too large Load Diff
+211 -214
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_MainWindow_h
#define glabels_MainWindow_h
#ifndef MainWindow_h
#define MainWindow_h
#include <QMainWindow>
@@ -32,245 +32,242 @@ class QLabel;
class QScrollArea;
namespace glabels
// Forward References
class LabelModel;
class PropertiesView;
class View;
class ObjectEditor;
class MergePropertyEditor;
class PrintView;
///
/// MainWindow Widget
///
class MainWindow : public QMainWindow
{
// Forward References
class LabelModel;
class PropertiesView;
class View;
class ObjectEditor;
class MergePropertyEditor;
class PrintView;
Q_OBJECT
///
/// MainWindow Widget
///
class MainWindow : public QMainWindow
{
Q_OBJECT
/////////////////////////////////////
// Lifecycle
/////////////////////////////////////
public:
MainWindow();
virtual ~MainWindow();
/////////////////////////////////////
// Lifecycle
/////////////////////////////////////
public:
MainWindow();
virtual ~MainWindow();
/////////////////////////////////////
// Public Methods
/////////////////////////////////////
public:
LabelModel* model() const;
void setModel( LabelModel* label );
bool isEmpty() const;
static QList<MainWindow *> windowList();
/////////////////////////////////////
// Public Methods
/////////////////////////////////////
public:
LabelModel* model() const;
void setModel( LabelModel* label );
bool isEmpty() const;
static QList<MainWindow *> windowList();
/////////////////////////////////////
// Events
/////////////////////////////////////
protected:
void closeEvent( QCloseEvent *event );
/////////////////////////////////////
// Events
/////////////////////////////////////
protected:
void closeEvent( QCloseEvent *event );
/////////////////////////////////////
// Slots
/////////////////////////////////////
private slots:
void fileNew();
void fileOpen();
void fileSave();
void fileSaveAs();
void fileProperties();
void fileTemplateDesigner();
void fileClose();
void fileExit();
void editUndo();
void editRedo();
void editCut();
void editCopy();
void editPaste();
void editDelete();
void editSelectAll();
void editUnSelectAll();
void editPreferences();
void viewFileToolBar( bool );
void viewEditorToolBar( bool );
void viewGrid( bool );
void viewMarkup( bool );
void viewZoomIn();
void viewZoomOut();
void viewZoom1To1();
void viewZoomToFit();
void objectsArrowMode();
void objectsCreateText();
void objectsCreateBox();
void objectsCreateLine();
void objectsCreateEllipse();
void objectsCreateImage();
void objectsCreateBarcode();
void objectsOrderRaise();
void objectsOrderLower();
void objectsXformRotateLeft();
void objectsXformRotateRight();
void objectsXformFlipHoriz();
void objectsXformFlipVert();
void objectsAlignLeft();
void objectsAlignHCenter();
void objectsAlignRight();
void objectsAlignTop();
void objectsAlignVCenter();
void objectsAlignBottom();
void objectsCenterHoriz();
void objectsCenterVert();
void helpContents();
void helpAbout();
void onContextMenuActivate();
void onZoomChanged();
void onPointerMoved( double, double );
void onPointerExit();
void onNameChanged();
void onModifiedChanged();
void onSelectionChanged();
void onLabelChanged();
/////////////////////////////////////
// Slots
/////////////////////////////////////
private slots:
void fileNew();
void fileOpen();
void fileSave();
void fileSaveAs();
void fileProperties();
void fileTemplateDesigner();
void fileClose();
void fileExit();
/////////////////////////////////////
// Internal Private Methods
/////////////////////////////////////
private:
void createActions();
void createMenus();
void createToolBars();
void createStatusBar();
void editUndo();
void editRedo();
void editCut();
void editCopy();
void editPaste();
void editDelete();
void editSelectAll();
void editUnSelectAll();
void editPreferences();
QWidget* createPropertiesPage();
QWidget* createEditorPage();
QWidget* createMergePage();
QWidget* createPrintPage();
void viewFileToolBar( bool );
void viewEditorToolBar( bool );
void viewGrid( bool );
void viewMarkup( bool );
void viewZoomIn();
void viewZoomOut();
void viewZoom1To1();
void viewZoomToFit();
void setDocVerbsEnabled( bool );
void setDocModifiedVerbsEnabled( bool );
void setPasteVerbsEnabled( bool );
void setSelectionVerbsEnabled( bool );
void setMultiSelectionVerbsEnabled( bool );
void objectsArrowMode();
void objectsCreateText();
void objectsCreateBox();
void objectsCreateLine();
void objectsCreateEllipse();
void objectsCreateImage();
void objectsCreateBarcode();
void objectsOrderRaise();
void objectsOrderLower();
void objectsXformRotateLeft();
void objectsXformRotateRight();
void objectsXformFlipHoriz();
void objectsXformFlipVert();
void objectsAlignLeft();
void objectsAlignHCenter();
void objectsAlignRight();
void objectsAlignTop();
void objectsAlignVCenter();
void objectsAlignBottom();
void objectsCenterHoriz();
void objectsCenterVert();
void setTitle();
void helpContents();
void helpAbout();
void onContextMenuActivate();
void onZoomChanged();
void onPointerMoved( double, double );
void onPointerExit();
void onNameChanged();
void onModifiedChanged();
void onSelectionChanged();
void onLabelChanged();
void readSettings();
void writeSettings();
/////////////////////////////////////
// Internal Private Methods
/////////////////////////////////////
private:
void createActions();
void createMenus();
void createToolBars();
void createStatusBar();
/////////////////////////////////////
// Private Data
/////////////////////////////////////
private:
static QList<MainWindow*> smWindowList;
QWidget* createPropertiesPage();
QWidget* createEditorPage();
QWidget* createMergePage();
QWidget* createPrintPage();
QMenu* fileMenu;
QMenu* editMenu;
QMenu* viewMenu;
QMenu* viewToolBarsMenu;
QMenu* objectsMenu;
QMenu* objectsCreateMenu;
QMenu* objectsOrderMenu;
QMenu* objectsXformMenu;
QMenu* objectsAlignMenu;
QMenu* objectsCenterMenu;
QMenu* helpMenu;
void setDocVerbsEnabled( bool );
void setDocModifiedVerbsEnabled( bool );
void setPasteVerbsEnabled( bool );
void setSelectionVerbsEnabled( bool );
void setMultiSelectionVerbsEnabled( bool );
void setTitle();
void readSettings();
void writeSettings();
/////////////////////////////////////
// Private Data
/////////////////////////////////////
private:
static QList<MainWindow*> smWindowList;
QMenu* fileMenu;
QMenu* editMenu;
QMenu* viewMenu;
QMenu* viewToolBarsMenu;
QMenu* objectsMenu;
QMenu* objectsCreateMenu;
QMenu* objectsOrderMenu;
QMenu* objectsXformMenu;
QMenu* objectsAlignMenu;
QMenu* objectsCenterMenu;
QMenu* helpMenu;
QMenu* contextMenu;
QMenu* contextOrderMenu;
QMenu* contextXformMenu;
QMenu* contextAlignMenu;
QMenu* contextCenterMenu;
QMenu* noSelectionContextMenu;
QMenu* contextMenu;
QMenu* contextOrderMenu;
QMenu* contextXformMenu;
QMenu* contextAlignMenu;
QMenu* contextCenterMenu;
QMenu* noSelectionContextMenu;
QToolBar* fileToolBar;
QToolBar* editorToolBar;
QToolBar* fileToolBar;
QToolBar* editorToolBar;
QTabWidget* mNotebook;
LabelModel* mModel;
PropertiesView* mPropertiesView;
QScrollArea* mViewScrollArea;
View* mView;
ObjectEditor* mObjectEditor;
MergePropertyEditor* mMergePropertyEditor;
PrintView* mPrintView;
QTabWidget* mNotebook;
LabelModel* mModel;
PropertiesView* mPropertiesView;
QScrollArea* mViewScrollArea;
View* mView;
ObjectEditor* mObjectEditor;
MergePropertyEditor* mMergePropertyEditor;
PrintView* mPrintView;
QLabel* zoomInfoLabel;
QLabel* cursorInfoLabel;
QLabel* zoomInfoLabel;
QLabel* cursorInfoLabel;
QAction* fileNewAction;
QAction* fileOpenAction;
QAction* fileSaveAction;
QAction* fileSaveAsAction;
QAction* filePropertiesAction;
QAction* fileTemplateDesignerAction;
QAction* fileCloseAction;
QAction* fileExitAction;
QAction* fileNewAction;
QAction* fileOpenAction;
QAction* fileSaveAction;
QAction* fileSaveAsAction;
QAction* filePropertiesAction;
QAction* fileTemplateDesignerAction;
QAction* fileCloseAction;
QAction* fileExitAction;
QAction* editUndoAction;
QAction* editRedoAction;
QAction* editCutAction;
QAction* editCopyAction;
QAction* editPasteAction;
QAction* editDeleteAction;
QAction* editSelectAllAction;
QAction* editUnSelectAllAction;
QAction* editPreferencesAction;
QAction* editUndoAction;
QAction* editRedoAction;
QAction* editCutAction;
QAction* editCopyAction;
QAction* editPasteAction;
QAction* editDeleteAction;
QAction* editSelectAllAction;
QAction* editUnSelectAllAction;
QAction* editPreferencesAction;
QAction* viewFileToolBarAction;
QAction* viewEditorToolBarAction;
QAction* viewGridAction;
QAction* viewMarkupAction;
QAction* viewZoomInAction;
QAction* viewZoomOutAction;
QAction* viewZoom1To1Action;
QAction* viewZoomToFitAction;
QAction* viewFileToolBarAction;
QAction* viewEditorToolBarAction;
QAction* viewGridAction;
QAction* viewMarkupAction;
QAction* viewZoomInAction;
QAction* viewZoomOutAction;
QAction* viewZoom1To1Action;
QAction* viewZoomToFitAction;
QAction* objectsArrowModeAction;
QAction* objectsCreateTextAction;
QAction* objectsCreateBoxAction;
QAction* objectsCreateLineAction;
QAction* objectsCreateEllipseAction;
QAction* objectsCreateImageAction;
QAction* objectsCreateBarcodeAction;
QAction* objectsOrderRaiseAction;
QAction* objectsOrderLowerAction;
QAction* objectsXformRotateLeftAction;
QAction* objectsXformRotateRightAction;
QAction* objectsXformFlipHorizAction;
QAction* objectsXformFlipVertAction;
QAction* objectsAlignLeftAction;
QAction* objectsAlignHCenterAction;
QAction* objectsAlignRightAction;
QAction* objectsAlignTopAction;
QAction* objectsAlignVCenterAction;
QAction* objectsAlignBottomAction;
QAction* objectsCenterHorizAction;
QAction* objectsCenterVertAction;
QAction* objectsArrowModeAction;
QAction* objectsCreateTextAction;
QAction* objectsCreateBoxAction;
QAction* objectsCreateLineAction;
QAction* objectsCreateEllipseAction;
QAction* objectsCreateImageAction;
QAction* objectsCreateBarcodeAction;
QAction* objectsOrderRaiseAction;
QAction* objectsOrderLowerAction;
QAction* objectsXformRotateLeftAction;
QAction* objectsXformRotateRightAction;
QAction* objectsXformFlipHorizAction;
QAction* objectsXformFlipVertAction;
QAction* objectsAlignLeftAction;
QAction* objectsAlignHCenterAction;
QAction* objectsAlignRightAction;
QAction* objectsAlignTopAction;
QAction* objectsAlignVCenterAction;
QAction* objectsAlignBottomAction;
QAction* objectsCenterHorizAction;
QAction* objectsCenterVertAction;
QAction* helpContentsAction;
QAction* helpAboutAction;
QAction* helpContentsAction;
QAction* helpAboutAction;
QAction* contextCutAction;
QAction* contextCopyAction;
QAction* contextPasteAction;
QAction* contextDeleteAction;
};
QAction* contextCutAction;
QAction* contextCopyAction;
QAction* contextPasteAction;
QAction* contextDeleteAction;
};
}
#endif // glabels_MainWindow_h
#endif // MainWindow_h
+101 -108
View File
@@ -21,115 +21,108 @@
#include "Merge.h"
namespace glabels
///
/// Constructor
///
Merge::Merge( QString id, QString name, SourceType type )
: mId(id), mName(name), mType(type)
{
///
/// Constructor
///
Merge::Merge( QString id, QString name, SourceType type )
: mId(id), mName(name), mType(type)
{
}
///
/// Destructor
///
Merge::~Merge()
{
}
///
/// Set source
///
void Merge::setSource( const QString& source )
{
mSource = source;
// Clear out any old records
foreach ( MergeRecord* record, mRecordList )
{
delete record;
}
mRecordList.clear();
open();
for ( MergeRecord* record = readNextRecord(); record != 0; record = readNextRecord() )
{
mRecordList.append( record );
}
close();
emit sourceChanged();
}
///
/// Select matching record
///
void Merge::select( MergeRecord* record )
{
record->setSelected( true );
emit selectionChanged();
}
///
/// Unselect matching record
///
void Merge::unselect( MergeRecord* record )
{
record->setSelected( false );
emit selectionChanged();
}
///
/// Select all records
///
void Merge::selectAll()
{
foreach ( MergeRecord* record, mRecordList )
{
record->setSelected( true );
}
emit selectionChanged();
}
///
/// Unselect all records
///
void Merge::unselectAll()
{
foreach ( MergeRecord* record, mRecordList )
{
record->setSelected( false );
}
emit selectionChanged();
}
///
/// Return list of selected records
///
const QList<MergeRecord*> Merge::selectedRecords() const
{
QList<MergeRecord*> list;
foreach ( MergeRecord* record, mRecordList )
{
if ( record->isSelected() )
{
list.append( record );
}
}
return list;
}
}
///
/// Destructor
///
Merge::~Merge()
{
}
///
/// Set source
///
void Merge::setSource( const QString& source )
{
mSource = source;
// Clear out any old records
foreach ( MergeRecord* record, mRecordList )
{
delete record;
}
mRecordList.clear();
open();
for ( MergeRecord* record = readNextRecord(); record != 0; record = readNextRecord() )
{
mRecordList.append( record );
}
close();
emit sourceChanged();
}
///
/// Select matching record
///
void Merge::select( MergeRecord* record )
{
record->setSelected( true );
emit selectionChanged();
}
///
/// Unselect matching record
///
void Merge::unselect( MergeRecord* record )
{
record->setSelected( false );
emit selectionChanged();
}
///
/// Select all records
///
void Merge::selectAll()
{
foreach ( MergeRecord* record, mRecordList )
{
record->setSelected( true );
}
emit selectionChanged();
}
///
/// Unselect all records
///
void Merge::unselectAll()
{
foreach ( MergeRecord* record, mRecordList )
{
record->setSelected( false );
}
emit selectionChanged();
}
///
/// Return list of selected records
///
const QList<MergeRecord*> Merge::selectedRecords() const
{
QList<MergeRecord*> list;
foreach ( MergeRecord* record, mRecordList )
{
if ( record->isSelected() )
{
list.append( record );
}
}
return list;
}
+101 -105
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_Merge_h
#define glabels_Merge_h
#ifndef Merge_h
#define Merge_h
#include <QObject>
#include <QString>
@@ -28,121 +28,117 @@
#include "MergeRecord.h"
namespace glabels
///
/// Merge Record Structure
///
struct Merge : QObject
{
///
/// Merge Record Structure
///
struct Merge : QObject
{
Q_OBJECT
/////////////////////////////////
// Source Type
/////////////////////////////////
enum SourceType { NONE, FIXED, FILE };
/////////////////////////////////
// Life Cycle
/////////////////////////////////
protected:
Merge( QString id, QString name, SourceType type );
virtual ~Merge();
/////////////////////////////////
// Properties
/////////////////////////////////
public:
inline QString id() const;
inline QString name() const;
inline SourceType type() const;
inline QString source() const;
void setSource( const QString& source );
inline const QList<MergeRecord*>& recordList( void ) const;
/////////////////////////////////
// Selection methods
/////////////////////////////////
public:
void select( MergeRecord* record );
void unselect( MergeRecord* record );
void selectAll();
void unselectAll();
const QList<MergeRecord*> selectedRecords() const;
/////////////////////////////////
// Virtual methods
/////////////////////////////////
public:
virtual QList<QString> keyList() const = 0;
virtual QString primaryKey() const = 0;
protected:
virtual void open() = 0;
virtual void close() = 0;
virtual MergeRecord* readNextRecord() = 0;
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void sourceChanged();
void selectionChanged();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
QString mId;
QString mName;
SourceType mType;
QString mSource;
bool mSelected;
QList<MergeRecord*> mRecordList;
};
Q_OBJECT
/////////////////////////////////
// INLINE METHODS
// Source Type
/////////////////////////////////
QString Merge::id() const
{
return mId;
}
enum SourceType { NONE, FIXED, FILE };
/////////////////////////////////
// Life Cycle
/////////////////////////////////
protected:
Merge( QString id, QString name, SourceType type );
virtual ~Merge();
QString Merge::name() const
{
return mId;
}
/////////////////////////////////
// Properties
/////////////////////////////////
public:
inline QString id() const;
inline QString name() const;
inline SourceType type() const;
inline QString source() const;
void setSource( const QString& source );
inline const QList<MergeRecord*>& recordList( void ) const;
Merge::SourceType Merge::type() const
{
return mType;
}
/////////////////////////////////
// Selection methods
/////////////////////////////////
public:
void select( MergeRecord* record );
void unselect( MergeRecord* record );
void selectAll();
void unselectAll();
const QList<MergeRecord*> selectedRecords() const;
QString Merge::source() const
{
return mSource;
}
/////////////////////////////////
// Virtual methods
/////////////////////////////////
public:
virtual QList<QString> keyList() const = 0;
virtual QString primaryKey() const = 0;
protected:
virtual void open() = 0;
virtual void close() = 0;
virtual MergeRecord* readNextRecord() = 0;
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void sourceChanged();
void selectionChanged();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
QString mId;
QString mName;
SourceType mType;
QString mSource;
bool mSelected;
QList<MergeRecord*> mRecordList;
};
const QList<MergeRecord*>& Merge::recordList( void ) const
{
return mRecordList;
}
/////////////////////////////////
// INLINE METHODS
/////////////////////////////////
QString Merge::id() const
{
return mId;
}
#endif // glabels_Merge_h
QString Merge::name() const
{
return mId;
}
Merge::SourceType Merge::type() const
{
return mType;
}
QString Merge::source() const
{
return mSource;
}
const QList<MergeRecord*>& Merge::recordList( void ) const
{
return mRecordList;
}
#endif // Merge_h
+52 -56
View File
@@ -18,75 +18,71 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_MergeField_h
#define glabels_MergeField_h
#ifndef MergeField_h
#define MergeField_h
#include <QString>
namespace glabels
///
/// Merge Field Structure
///
struct MergeField
{
///
/// Merge Field Structure
///
struct MergeField
{
/////////////////////////////////
// Properties
/////////////////////////////////
public:
//
// Key Property
//
inline const QString key( void ) const;
inline void setKey( const QString &value );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
//
// Key Property
//
inline const QString key( void ) const;
inline void setKey( const QString &value );
//
// Value Property
//
inline const QString value( void ) const;
inline void setValue( const QString &value );
/////////////////////////////////
// Private data
/////////////////////////////////
private:
QString mKey;
QString mValue;
};
//
// Value Property
//
inline const QString value( void ) const;
inline void setValue( const QString &value );
/////////////////////////////////
// INLINE METHODS
// Private data
/////////////////////////////////
const QString MergeField::key( void ) const
{
return mKey;
}
private:
QString mKey;
QString mValue;
};
void MergeField::setKey( const QString &value )
{
mKey = value;
}
const QString MergeField::value( void ) const
{
return mValue;
}
void MergeField::setValue( const QString &value )
{
mValue = value;
}
/////////////////////////////////
// INLINE METHODS
/////////////////////////////////
const QString MergeField::key( void ) const
{
return mKey;
}
#endif // glabels_MergeField_h
void MergeField::setKey( const QString &value )
{
mKey = value;
}
const QString MergeField::value( void ) const
{
return mValue;
}
void MergeField::setValue( const QString &value )
{
mValue = value;
}
#endif // MergeField_h
+33 -38
View File
@@ -24,43 +24,38 @@
#include <QtDebug>
namespace glabels
///
/// Constructor
///
MergePropertyEditor::MergePropertyEditor( QWidget *parent )
: QWidget(parent), mModel(0)
{
setupUi( this );
}
///
/// Destructor
///
MergePropertyEditor::~MergePropertyEditor()
{
}
///
/// Set Model
///
void MergePropertyEditor::setModel( LabelModel* model )
{
mModel = model;
connect( mModel, SIGNAL(changed()), this, SLOT(onLabelChanged()) );
}
///
/// Label changed handler
///
void MergePropertyEditor::onLabelChanged()
{
///
/// Constructor
///
MergePropertyEditor::MergePropertyEditor( QWidget *parent )
: QWidget(parent), mModel(0)
{
setupUi( this );
}
///
/// Destructor
///
MergePropertyEditor::~MergePropertyEditor()
{
}
///
/// Set Model
///
void MergePropertyEditor::setModel( LabelModel* model )
{
mModel = model;
connect( mModel, SIGNAL(changed()), this, SLOT(onLabelChanged()) );
}
///
/// Label changed handler
///
void MergePropertyEditor::onLabelChanged()
{
}
}
+31 -34
View File
@@ -18,54 +18,51 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_MergePropertyEditor_h
#define glabels_MergePropertyEditor_h
#ifndef MergePropertyEditor_h
#define MergePropertyEditor_h
#include "ui_MergePropertyEditor.h"
namespace glabels
{
class LabelModel; // Forward reference
class LabelModel; // Forward reference
///
/// Merge Property Editor Widget
///
class MergePropertyEditor : public QWidget, public Ui_MergePropertyEditor
{
Q_OBJECT
///
/// Merge Property Editor Widget
///
class MergePropertyEditor : public QWidget, public Ui_MergePropertyEditor
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
MergePropertyEditor( QWidget *parent = 0 );
~MergePropertyEditor();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
MergePropertyEditor( QWidget *parent = 0 );
~MergePropertyEditor();
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelChanged();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelChanged();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
LabelModel* mModel;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
LabelModel* mModel;
};
};
}
#endif // glabels_MergePropertyEditor_h
#endif // MergePropertyEditor_h
+4 -11
View File
@@ -21,16 +21,9 @@
#include "MergeRecord.h"
namespace glabels
///
/// Constructor
///
MergeRecord::MergeRecord() : mSelected( false )
{
///
/// Constructor
///
MergeRecord::MergeRecord() : mSelected( false )
{
}
}
+58 -62
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_MergeRecord_h
#define glabels_MergeRecord_h
#ifndef MergeRecord_h
#define MergeRecord_h
#include <QString>
#include <QList>
@@ -27,74 +27,70 @@
#include "MergeField.h"
namespace glabels
///
/// Merge Record Structure
///
struct MergeRecord
{
///
/// Merge Record Structure
///
struct MergeRecord
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
MergeRecord();
/////////////////////////////////
// Properties
/////////////////////////////////
public:
inline bool isSelected() const;
inline void setSelected( bool value );
inline bool empty() const;
inline const QList<MergeField>& fieldList() const;
inline void setFieldList( QList<MergeField>& value );
/////////////////////////////////
// Private data
/////////////////////////////////
private:
bool mSelected;
QList<MergeField> mFieldList;
};
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
MergeRecord();
/////////////////////////////////
// INLINE METHODS
// Properties
/////////////////////////////////
bool MergeRecord::isSelected() const
{
return mSelected;
}
public:
inline bool isSelected() const;
inline void setSelected( bool value );
inline bool empty() const;
inline const QList<MergeField>& fieldList() const;
inline void setFieldList( QList<MergeField>& value );
void MergeRecord::setSelected( bool value )
{
mSelected = value;
}
/////////////////////////////////
// Private data
/////////////////////////////////
private:
bool mSelected;
QList<MergeField> mFieldList;
};
bool MergeRecord::empty() const
{
return mFieldList.size() == 0;
}
const QList<MergeField>& MergeRecord::fieldList() const
{
return mFieldList;
}
void MergeRecord::setFieldList( QList<MergeField>& value )
{
mFieldList = value;
}
/////////////////////////////////
// INLINE METHODS
/////////////////////////////////
bool MergeRecord::isSelected() const
{
return mSelected;
}
#endif // glabels_MergeRecord_h
void MergeRecord::setSelected( bool value )
{
mSelected = value;
}
bool MergeRecord::empty() const
{
return mFieldList.size() == 0;
}
const QList<MergeField>& MergeRecord::fieldList() const
{
return mFieldList;
}
void MergeRecord::setFieldList( QList<MergeField>& value )
{
mFieldList = value;
}
#endif // MergeRecord_h
+227 -232
View File
@@ -29,306 +29,301 @@
#include <QtDebug>
namespace glabels
///
/// Constructor
///
ObjectEditor::ObjectEditor( QWidget *parent )
: mModel(0), mObject(0), mBlocked(false)
{
setupUi( this );
///
/// Constructor
///
ObjectEditor::ObjectEditor( QWidget *parent )
: mModel(0), mObject(0), mBlocked(false)
{
setupUi( this );
lineColorButton->init( "No line", QColor(0,0,0,0), QColor(0,0,0,255) );
fillColorButton->init( "No fill", QColor(0,0,0,0), QColor(0,0,0,255) );
shadowColorButton->init( "Default", QColor(0,0,0,255), QColor(0,0,0,255) );
lineColorButton->init( "No line", QColor(0,0,0,0), QColor(0,0,0,255) );
fillColorButton->init( "No fill", QColor(0,0,0,0), QColor(0,0,0,255) );
shadowColorButton->init( "Default", QColor(0,0,0,255), QColor(0,0,0,255) );
setEnabled( false );
hidePages();
}
setEnabled( false );
hidePages();
}
void ObjectEditor::setModel( LabelModel* model )
{
mModel = model;
void ObjectEditor::setModel( LabelModel* model )
{
mModel = model;
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
connect( mModel, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()) );
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
connect( mModel, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()) );
onLabelSizeChanged();
onSelectionChanged();
}
onLabelSizeChanged();
onSelectionChanged();
}
void ObjectEditor::hidePages()
void ObjectEditor::hidePages()
{
notebook->removeTab( notebook->indexOf(textPage) );
notebook->removeTab( notebook->indexOf(barcodePage) );
notebook->removeTab( notebook->indexOf(imagePage) );
notebook->removeTab( notebook->indexOf(lineFillPage) );
notebook->removeTab( notebook->indexOf(posSizePage) );
notebook->removeTab( notebook->indexOf(shadowPage) );
}
void ObjectEditor::loadLineFillPage()
{
if ( mObject )
{
notebook->removeTab( notebook->indexOf(textPage) );
notebook->removeTab( notebook->indexOf(barcodePage) );
notebook->removeTab( notebook->indexOf(imagePage) );
notebook->removeTab( notebook->indexOf(lineFillPage) );
notebook->removeTab( notebook->indexOf(posSizePage) );
notebook->removeTab( notebook->indexOf(shadowPage) );
mBlocked = true;
lineWidthSpin->setValue( mObject->lineWidth().pt() );
lineColorButton->setColorNode( mObject->lineColorNode() );
fillColorButton->setColorNode( mObject->fillColorNode() );
mBlocked = false;
}
}
void ObjectEditor::loadLineFillPage()
void ObjectEditor::loadPositionPage()
{
if ( mObject )
{
if ( mObject )
{
mBlocked = true;
mBlocked = true;
lineWidthSpin->setValue( mObject->lineWidth().pt() );
lineColorButton->setColorNode( mObject->lineColorNode() );
fillColorButton->setColorNode( mObject->fillColorNode() );
posXSpin->setValue( mObject->x0().in() );
posYSpin->setValue( mObject->y0().in() );
mBlocked = false;
}
mBlocked = false;
}
}
void ObjectEditor::loadPositionPage()
void ObjectEditor::loadRectSizePage()
{
if ( mObject )
{
if ( mObject )
{
mBlocked = true;
mBlocked = true;
posXSpin->setValue( mObject->x0().in() );
posYSpin->setValue( mObject->y0().in() );
sizeWSpin->setValue( mObject->w().in() );
sizeHSpin->setValue( mObject->h().in() );
mBlocked = false;
}
mBlocked = false;
}
}
void ObjectEditor::loadRectSizePage()
void ObjectEditor::loadShadowPage()
{
if ( mObject )
{
if ( mObject )
{
mBlocked = true;
mBlocked = true;
sizeWSpin->setValue( mObject->w().in() );
sizeHSpin->setValue( mObject->h().in() );
shadowEnableCheck->setChecked( mObject->shadow() );
shadowXSpin->setValue( mObject->shadowX().in() );
shadowYSpin->setValue( mObject->shadowY().in() );
shadowColorButton->setColorNode( mObject->shadowColorNode() );
shadowOpacitySpin->setValue( 100*mObject->shadowOpacity() );
mBlocked = false;
}
mBlocked = false;
}
}
void ObjectEditor::loadShadowPage()
void ObjectEditor::onLabelSizeChanged()
{
if ( mModel )
{
if ( mObject )
{
mBlocked = true;
shadowEnableCheck->setChecked( mObject->shadow() );
shadowXSpin->setValue( mObject->shadowX().in() );
shadowYSpin->setValue( mObject->shadowY().in() );
shadowColorButton->setColorNode( mObject->shadowColorNode() );
shadowOpacitySpin->setValue( 100*mObject->shadowOpacity() );
mBlocked = true;
mBlocked = false;
}
}
void ObjectEditor::onLabelSizeChanged()
{
if ( mModel )
{
mBlocked = true;
libglabels::Distance whMax = std::max( mModel->w(), mModel->h() );
posXSpin->setRange( -whMax.in(), 2*whMax.in() );
posYSpin->setRange( -whMax.in(), 2*whMax.in() );
sizeWSpin->setRange( 0, 2*whMax.in() );
sizeHSpin->setRange( 0, 2*whMax.in() );
mBlocked = false;
}
glabels::Distance whMax = std::max( mModel->w(), mModel->h() );
posXSpin->setRange( -whMax.in(), 2*whMax.in() );
posYSpin->setRange( -whMax.in(), 2*whMax.in() );
sizeWSpin->setRange( 0, 2*whMax.in() );
sizeHSpin->setRange( 0, 2*whMax.in() );
mBlocked = false;
}
}
void ObjectEditor::onSelectionChanged()
void ObjectEditor::onSelectionChanged()
{
if ( mObject )
{
if ( mObject )
disconnect( mObject, 0, this, 0 );
}
hidePages();
if ( mModel->isSelectionAtomic() )
{
mObject = mModel->getFirstSelectedObject();
if ( dynamic_cast<LabelModelBoxObject*>(mObject) )
{
disconnect( mObject, 0, this, 0 );
}
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-box.png") );
titleLabel->setText( "Box object properties" );
hidePages();
notebook->addTab( lineFillPage, "line/fill" );
notebook->addTab( posSizePage, "position/size" );
notebook->addTab( shadowPage, "shadow" );
if ( mModel->isSelectionAtomic() )
{
mObject = mModel->getFirstSelectedObject();
sizeRectFrame->setVisible( true );
sizeResetImageButton->setVisible( false );
sizeLineFrame->setVisible( false );
if ( dynamic_cast<LabelModelBoxObject*>(mObject) )
{
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-box.png") );
titleLabel->setText( "Box object properties" );
notebook->addTab( lineFillPage, "line/fill" );
notebook->addTab( posSizePage, "position/size" );
notebook->addTab( shadowPage, "shadow" );
sizeRectFrame->setVisible( true );
sizeResetImageButton->setVisible( false );
sizeLineFrame->setVisible( false );
loadLineFillPage();
loadPositionPage();
loadRectSizePage();
loadShadowPage();
loadLineFillPage();
loadPositionPage();
loadRectSizePage();
loadShadowPage();
setEnabled( true );
}
else
{
Q_ASSERT_X( false, "ObjectEditor::onSelectionChanged", "Invalid object" );
}
connect( mObject, SIGNAL(changed()), this, SLOT(onObjectChanged()) );
connect( mObject, SIGNAL(moved()), this, SLOT(onObjectMoved()) );
connect( mObject, SIGNAL(destroyed(QObject*)), this, SLOT(onObjectDestroyed()) );
setEnabled( true );
}
else
{
mObject = 0;
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-object-properties.png") );
titleLabel->setText( "Object properties" );
setEnabled( false );
Q_ASSERT_X( false, "ObjectEditor::onSelectionChanged", "Invalid object" );
}
connect( mObject, SIGNAL(changed()), this, SLOT(onObjectChanged()) );
connect( mObject, SIGNAL(moved()), this, SLOT(onObjectMoved()) );
connect( mObject, SIGNAL(destroyed(QObject*)), this, SLOT(onObjectDestroyed()) );
}
void ObjectEditor::onObjectChanged()
else
{
if ( !mBlocked )
{
loadLineFillPage();
loadRectSizePage();
loadShadowPage();
}
}
void ObjectEditor::onObjectMoved()
{
if ( !mBlocked )
{
loadPositionPage();
}
}
void ObjectEditor::onObjectDestroyed()
{
disconnect( mObject, 0, this, 0 );
mObject = 0;
}
void ObjectEditor::onLineControlsChanged()
{
if ( !mBlocked )
{
mBlocked = true;
mObject->setLineWidth( libglabels::Distance::pt(lineWidthSpin->value()) );
mObject->setLineColorNode( lineColorButton->colorNode() );
mBlocked = false;
}
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-object-properties.png") );
titleLabel->setText( "Object properties" );
setEnabled( false );
}
}
void ObjectEditor::onFillControlsChanged()
void ObjectEditor::onObjectChanged()
{
if ( !mBlocked )
{
if ( !mBlocked )
{
mBlocked = true;
mObject->setFillColorNode( fillColorButton->colorNode() );
mBlocked = false;
}
loadLineFillPage();
loadRectSizePage();
loadShadowPage();
}
}
void ObjectEditor::onPositionControlsChanged()
void ObjectEditor::onObjectMoved()
{
if ( !mBlocked )
{
if ( !mBlocked )
{
mBlocked = true;
mObject->setPosition( posXSpin->value(), posYSpin->value() );
mBlocked = false;
}
loadPositionPage();
}
}
void ObjectEditor::onRectSizeControlsChanged()
void ObjectEditor::onObjectDestroyed()
{
disconnect( mObject, 0, this, 0 );
mObject = 0;
}
void ObjectEditor::onLineControlsChanged()
{
if ( !mBlocked )
{
if ( !mBlocked )
{
mBlocked = true;
mBlocked = true;
mObject->setLineWidth( glabels::Distance::pt(lineWidthSpin->value()) );
mObject->setLineColorNode( lineColorButton->colorNode() );
mBlocked = false;
}
}
void ObjectEditor::onFillControlsChanged()
{
if ( !mBlocked )
{
mBlocked = true;
mObject->setFillColorNode( fillColorButton->colorNode() );
mBlocked = false;
}
}
void ObjectEditor::onPositionControlsChanged()
{
if ( !mBlocked )
{
mBlocked = true;
mObject->setPosition( posXSpin->value(), posYSpin->value() );
mBlocked = false;
}
}
void ObjectEditor::onRectSizeControlsChanged()
{
if ( !mBlocked )
{
mBlocked = true;
libglabels::Distance spinW = libglabels::Distance::in(sizeWSpin->value());
libglabels::Distance spinH = libglabels::Distance::in(sizeHSpin->value());
glabels::Distance spinW = glabels::Distance::in(sizeWSpin->value());
glabels::Distance spinH = glabels::Distance::in(sizeHSpin->value());
if ( sizeAspectCheck->isChecked() )
if ( sizeAspectCheck->isChecked() )
{
if ( fabs(spinW - mObject->w()) > fabs(spinH - mObject->h()) )
{
if ( fabs(spinW - mObject->w()) > fabs(spinH - mObject->h()) )
{
mObject->setWHonorAspect( spinW );
sizeHSpin->setValue( mObject->h().in() );
}
else
{
mObject->setHHonorAspect( spinH );
sizeWSpin->setValue( mObject->w().in() );
}
mObject->setWHonorAspect( spinW );
sizeHSpin->setValue( mObject->h().in() );
}
else
{
mObject->setSize( spinW, spinH );
mObject->setHHonorAspect( spinH );
sizeWSpin->setValue( mObject->w().in() );
}
}
else
{
mObject->setSize( spinW, spinH );
}
mBlocked = false;
}
mBlocked = false;
}
}
void ObjectEditor::onShadowControlsChanged()
{
if ( !mBlocked )
{
mBlocked = true;
mObject->setShadow( shadowEnableCheck->isChecked() );
mObject->setShadowX( glabels::Distance::in(shadowXSpin->value()) );
mObject->setShadowY( glabels::Distance::in(shadowYSpin->value()) );
mObject->setShadowColorNode( shadowColorButton->colorNode() );
mObject->setShadowOpacity( shadowOpacitySpin->value()/100.0 );
mBlocked = false;
}
}
void ObjectEditor::onChanged()
{
if ( !mBlocked )
{
mBlocked = true;
qDebug() << "Form changed.";
mBlocked = false;
}
void ObjectEditor::onShadowControlsChanged()
{
if ( !mBlocked )
{
mBlocked = true;
mObject->setShadow( shadowEnableCheck->isChecked() );
mObject->setShadowX( libglabels::Distance::in(shadowXSpin->value()) );
mObject->setShadowY( libglabels::Distance::in(shadowYSpin->value()) );
mObject->setShadowColorNode( shadowColorButton->colorNode() );
mObject->setShadowOpacity( shadowOpacitySpin->value()/100.0 );
mBlocked = false;
}
}
void ObjectEditor::onChanged()
{
if ( !mBlocked )
{
mBlocked = true;
qDebug() << "Form changed.";
mBlocked = false;
}
}
}
+52 -55
View File
@@ -18,77 +18,74 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_ObjectEditor_h
#define glabels_ObjectEditor_h
#ifndef ObjectEditor_h
#define ObjectEditor_h
#include "ui_ObjectEditor.h"
namespace glabels
{
class LabelModel; // Forward reference
class LabelModelObject; // Forward reference
class LabelModel; // Forward reference
class LabelModelObject; // Forward reference
///
/// Object Editor Widget
///
class ObjectEditor : public QWidget, public Ui_ObjectEditor
{
Q_OBJECT
///
/// Object Editor Widget
///
class ObjectEditor : public QWidget, public Ui_ObjectEditor
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ObjectEditor( QWidget *parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
ObjectEditor( QWidget *parent = 0 );
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Private methods
/////////////////////////////////
private:
void hidePages();
void loadLineFillPage();
void loadPositionPage();
void loadRectSizePage();
void loadShadowPage();
/////////////////////////////////
// Private methods
/////////////////////////////////
private:
void hidePages();
void loadLineFillPage();
void loadPositionPage();
void loadRectSizePage();
void loadShadowPage();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelSizeChanged();
void onSelectionChanged();
void onObjectChanged();
void onObjectMoved();
void onObjectDestroyed();
void onLineControlsChanged();
void onFillControlsChanged();
void onPositionControlsChanged();
void onRectSizeControlsChanged();
void onShadowControlsChanged();
void onChanged();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelSizeChanged();
void onSelectionChanged();
void onObjectChanged();
void onObjectMoved();
void onObjectDestroyed();
void onLineControlsChanged();
void onFillControlsChanged();
void onPositionControlsChanged();
void onRectSizeControlsChanged();
void onShadowControlsChanged();
void onChanged();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
LabelModel* mModel;
LabelModelObject* mObject;
bool mBlocked;
/////////////////////////////////
// Private data
/////////////////////////////////
private:
LabelModel* mModel;
LabelModelObject* mObject;
bool mBlocked;
};
};
}
#endif // glabels_ObjectEditor_h
#endif // ObjectEditor_h
+4 -4
View File
@@ -40,7 +40,7 @@ namespace
///
/// Outline Constructor
///
glabels::Outline::Outline( LabelModelObject* owner )
Outline::Outline( LabelModelObject* owner )
: mOwner(owner)
{
mDashes << dashSize << dashSize;
@@ -63,7 +63,7 @@ glabels::Outline::Outline( LabelModelObject* owner )
///
/// Outline Destructor
///
glabels::Outline::~Outline()
Outline::~Outline()
{
}
@@ -71,7 +71,7 @@ glabels::Outline::~Outline()
///
/// Draw Outline
///
void glabels::Outline::draw( QPainter* painter ) const
void Outline::draw( QPainter* painter ) const
{
painter->save();
@@ -90,7 +90,7 @@ void glabels::Outline::draw( QPainter* painter ) const
///
/// Create path for testing for hover condition
///
QPainterPath glabels::Outline::hoverPath( double scale ) const
QPainterPath Outline::hoverPath( double scale ) const
{
double s = 1 / scale;
+31 -35
View File
@@ -18,53 +18,49 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_Outline_h
#define glabels_Outline_h
#ifndef Outline_h
#define Outline_h
#include <QPainter>
#include <QPainterPath>
namespace glabels
class LabelModelObject;
///
/// Outline Base Class
///
class Outline
{
class LabelModelObject;
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
Outline( LabelModelObject* owner );
virtual ~Outline();
///
/// Outline Base Class
///
class Outline
{
////////////////////////////
// Lifecycle Methods
////////////////////////////
public:
Outline( LabelModelObject* owner );
virtual ~Outline();
////////////////////////////
// Drawing Methods
////////////////////////////
public:
void draw( QPainter* painter ) const;
QPainterPath hoverPath( double scale ) const;
////////////////////////////
// Drawing Methods
////////////////////////////
public:
void draw( QPainter* painter ) const;
QPainterPath hoverPath( double scale ) const;
////////////////////////////
// Private Data
////////////////////////////
private:
LabelModelObject* mOwner;
////////////////////////////
// Private Data
////////////////////////////
private:
LabelModelObject* mOwner;
QVector<qreal> mDashes;
QPen mPen1;
QPen mPen2;
QVector<qreal> mDashes;
QPen mPen1;
QPen mPen2;
};
};
}
#endif // glabels_Outline_h
#endif // Outline_h
+171 -176
View File
@@ -36,220 +36,215 @@ namespace
}
namespace glabels
PageRenderer::PageRenderer()
: mModel(0), mNLabels(0), mStartLabel(0),
mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false),
mIPage(0), mNPages(0)
{
PageRenderer::PageRenderer()
: mModel(0), mNLabels(0), mStartLabel(0),
mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false),
mIPage(0), mNPages(0)
{
}
}
void PageRenderer::setModel( const LabelModel* model )
{
mModel = model;
mOrigins = mModel->frame()->getOrigins();
mNLabelsPerPage = mModel->frame()->nLabels();
updateNPages();
}
void PageRenderer::setModel( const LabelModel* model )
{
mModel = model;
mOrigins = mModel->frame()->getOrigins();
mNLabelsPerPage = mModel->frame()->nLabels();
updateNPages();
}
void PageRenderer::setNLabels( int nLabels )
{
mNLabels = nLabels;
updateNPages();
}
void PageRenderer::setNLabels( int nLabels )
{
mNLabels = nLabels;
updateNPages();
}
void PageRenderer::setStartLabel( int startLabel )
{
mStartLabel = startLabel;
updateNPages();
}
void PageRenderer::setStartLabel( int startLabel )
{
mStartLabel = startLabel;
updateNPages();
}
void PageRenderer::setPrintOutlines( bool printOutlinesFlag )
{
mPrintOutlines = printOutlinesFlag;
}
void PageRenderer::setPrintOutlines( bool printOutlinesFlag )
{
mPrintOutlines = printOutlinesFlag;
}
void PageRenderer::setPrintCropMarks( bool printCropMarksFlag )
{
mPrintCropMarks = printCropMarksFlag;
}
void PageRenderer::setPrintCropMarks( bool printCropMarksFlag )
{
mPrintCropMarks = printCropMarksFlag;
}
void PageRenderer::setPrintReverse( bool printReverseFlag )
{
mPrintReverse = printReverseFlag;
}
void PageRenderer::setPrintReverse( bool printReverseFlag )
{
mPrintReverse = printReverseFlag;
}
void PageRenderer::setIPage( int iPage )
{
mIPage = iPage;
}
void PageRenderer::setIPage( int iPage )
{
mIPage = iPage;
}
int PageRenderer::nPages() const
{
return mNPages;
}
int PageRenderer::nPages() const
{
return mNPages;
}
QRectF PageRenderer::pageRect() const
QRectF PageRenderer::pageRect() const
{
if ( mModel )
{
if ( mModel )
{
return QRectF( 0, 0, mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
}
else
{
return QRectF( 0, 0, 0, 0 );
}
return QRectF( 0, 0, mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
}
else
{
return QRectF( 0, 0, 0, 0 );
}
}
void PageRenderer::updateNPages()
{
if ( mModel )
{
/// @TODO merge case
int lastLabel = mStartLabel + mNLabels;
mNPages = lastLabel / mNLabelsPerPage;
if ( lastLabel % mNLabelsPerPage )
{
mNPages++;
}
}
else
{
mNPages = 0;
}
}
///
/// Print page using persistent page number
///
void PageRenderer::printPage( QPainter* painter ) const
{
printPage( painter, mIPage );
}
///
/// Print page
///
void PageRenderer::printPage( QPainter* painter, int iPage ) const
{
if ( mModel )
{
/// @TODO merge case
printSimplePage( painter, iPage );
}
}
void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
{
int iStart = 0;
int iEnd = mNLabelsPerPage;
if ( iPage == 0 )
{
iStart = mStartLabel;
}
int lastLabel = mStartLabel + mNLabels;
if ( (lastLabel / mNLabelsPerPage) == iPage )
{
iEnd = lastLabel % mNLabelsPerPage;
}
printCropMarks( painter );
for ( int i = iStart; i < iEnd; i++ )
{
painter->save();
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
painter->save();
clipLabel( painter );
printLabel( painter, 0 );
painter->restore(); // From before clip
printOutline( painter );
painter->restore(); // From before translation
}
}
void PageRenderer::printMergePage( QPainter* painter, int iPage ) const
void PageRenderer::updateNPages()
{
if ( mModel )
{
/// @TODO merge case
}
void PageRenderer::printCropMarks( QPainter* painter ) const
{
if ( mPrintCropMarks )
{
// TODO
}
}
void PageRenderer::printOutline( QPainter* painter ) const
{
if ( mPrintOutlines )
{
painter->save();
painter->setBrush( QBrush( Qt::NoBrush ) );
painter->setPen( QPen( labelOutlineColor, labelOutlineWidth ) );
painter->drawPath( mModel->frame()->path() );
painter->restore();
int lastLabel = mStartLabel + mNLabels;
mNPages = lastLabel / mNLabelsPerPage;
if ( lastLabel % mNLabelsPerPage )
{
mNPages++;
}
}
else
{
mNPages = 0;
}
}
void PageRenderer::clipLabel( QPainter* painter ) const
///
/// Print page using persistent page number
///
void PageRenderer::printPage( QPainter* painter ) const
{
printPage( painter, mIPage );
}
///
/// Print page
///
void PageRenderer::printPage( QPainter* painter, int iPage ) const
{
if ( mModel )
{
// TODO: add clipPath() method to frame
/// @TODO merge case
printSimplePage( painter, iPage );
}
}
void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
{
int iStart = 0;
int iEnd = mNLabelsPerPage;
if ( iPage == 0 )
{
iStart = mStartLabel;
}
int lastLabel = mStartLabel + mNLabels;
if ( (lastLabel / mNLabelsPerPage) == iPage )
{
iEnd = lastLabel % mNLabelsPerPage;
}
printCropMarks( painter );
for ( int i = iStart; i < iEnd; i++ )
{
painter->save();
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
painter->save();
clipLabel( painter );
printLabel( painter, 0 );
painter->restore(); // From before clip
printOutline( painter );
painter->restore(); // From before translation
}
}
void PageRenderer::printLabel( QPainter* painter, MergeRecord* record ) const
void PageRenderer::printMergePage( QPainter* painter, int iPage ) const
{
/// @TODO merge case
}
void PageRenderer::printCropMarks( QPainter* painter ) const
{
if ( mPrintCropMarks )
{
// TODO
}
}
void PageRenderer::printOutline( QPainter* painter ) const
{
if ( mPrintOutlines )
{
painter->save();
if ( mModel->rotate() )
{
painter->rotate( 90.0 );
painter->translate( 0, mModel->h().pt() );
}
if ( mPrintReverse )
{
painter->translate( mModel->w().pt(), 0 );
painter->scale( -1, 1 );
}
mModel->draw( painter, false, record );
painter->setBrush( QBrush( Qt::NoBrush ) );
painter->setPen( QPen( labelOutlineColor, labelOutlineWidth ) );
painter->drawPath( mModel->frame()->path() );
painter->restore();
}
}
void PageRenderer::clipLabel( QPainter* painter ) const
{
// TODO: add clipPath() method to frame
}
void PageRenderer::printLabel( QPainter* painter, MergeRecord* record ) const
{
painter->save();
if ( mModel->rotate() )
{
painter->rotate( 90.0 );
painter->translate( 0, mModel->h().pt() );
}
if ( mPrintReverse )
{
painter->translate( mModel->w().pt(), 0 );
painter->scale( -1, 1 );
}
mModel->draw( painter, false, record );
painter->restore();
}
+59 -62
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_PageRenderer_h
#define glabels_PageRenderer_h
#ifndef PageRenderer_h
#define PageRenderer_h
#include "libglabels/Point.h"
@@ -31,72 +31,69 @@
class QPainter; // Forward reference
namespace glabels
class LabelModel; // Forward reference
class MergeRecord; // Forward reference
///
/// PageRenderer Widget
///
class PageRenderer
{
class LabelModel; // Forward reference
class MergeRecord; // Forward reference
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PageRenderer();
///
/// PageRenderer Widget
///
class PageRenderer
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PageRenderer();
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setModel( const LabelModel* model );
void setNLabels( int nLabels );
void setStartLabel( int startLabel );
void setPrintOutlines( bool printOutlinesFlag );
void setPrintCropMarks( bool printCropMarksFlag );
void setPrintReverse( bool printReverseFlag );
void setIPage( int iPage );
int nPages() const;
QRectF pageRect() const;
void printPage( QPainter* painter ) const;
void printPage( QPainter* painter, int iPage ) const;
/////////////////////////////////
// Public Methods
/////////////////////////////////
public:
void setModel( const LabelModel* model );
void setNLabels( int nLabels );
void setStartLabel( int startLabel );
void setPrintOutlines( bool printOutlinesFlag );
void setPrintCropMarks( bool printCropMarksFlag );
void setPrintReverse( bool printReverseFlag );
void setIPage( int iPage );
int nPages() const;
QRectF pageRect() const;
void printPage( QPainter* painter ) const;
void printPage( QPainter* painter, int iPage ) const;
/////////////////////////////////
// Internal Methods
/////////////////////////////////
private:
void updateNPages();
void printSimplePage( QPainter* painter, int iPage ) const;
void printMergePage( QPainter* painter, int iPage ) const;
void printCropMarks( QPainter* painter ) const;
void printOutline( QPainter* painter ) const;
void clipLabel( QPainter* painter ) const;
void printLabel( QPainter* painter, MergeRecord* record ) const;
/////////////////////////////////
// Internal Methods
/////////////////////////////////
private:
void updateNPages();
void printSimplePage( QPainter* painter, int iPage ) const;
void printMergePage( QPainter* painter, int iPage ) const;
void printCropMarks( QPainter* painter ) const;
void printOutline( QPainter* painter ) const;
void clipLabel( QPainter* painter ) const;
void printLabel( QPainter* painter, MergeRecord* record ) const;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const LabelModel* mModel;
int mNLabels;
int mStartLabel;
bool mPrintOutlines;
bool mPrintCropMarks;
bool mPrintReverse;
int mIPage;
int mNPages;
int mNLabelsPerPage;
QVector<glabels::Point> mOrigins;
};
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const LabelModel* mModel;
int mNLabels;
int mStartLabel;
bool mPrintOutlines;
bool mPrintCropMarks;
bool mPrintReverse;
int mIPage;
int mNPages;
int mNLabelsPerPage;
QVector<libglabels::Point> mOrigins;
};
}
#endif // glabels_PageRenderer_h
#endif // PageRenderer_h
+142 -148
View File
@@ -47,155 +47,149 @@ namespace
}
namespace glabels
///
/// Constructor
///
Preview::Preview( QWidget *parent )
: mModel(0), mRenderer(0), QGraphicsView(parent)
{
mScene = new QGraphicsScene();
setScene( mScene );
///
/// Constructor
///
Preview::Preview( QWidget *parent )
: mModel(0), mRenderer(0), QGraphicsView(parent)
{
mScene = new QGraphicsScene();
setScene( mScene );
setAttribute(Qt::WA_TranslucentBackground);
viewport()->setAutoFillBackground(false);
setFrameStyle( QFrame::NoFrame );
setRenderHints( QPainter::Antialiasing );
}
///
/// Set model
///
void Preview::setModel( const LabelModel* model )
{
mModel = model;
clearScene();
if ( mModel != NULL )
{
// Set scene up with a 5% margin around paper
libglabels::Distance x = -0.05 * mModel->tmplate()->pageWidth();
libglabels::Distance y = -0.05 * mModel->tmplate()->pageHeight();
libglabels::Distance w = 1.10 * mModel->tmplate()->pageWidth();
libglabels::Distance h = 1.10 * mModel->tmplate()->pageHeight();
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
drawPaper( mModel->tmplate()->pageWidth(), mModel->tmplate()->pageHeight() );
drawLabels();
drawPreviewOverlay();
}
}
///
/// Set renderer
///
void Preview::setRenderer( const PageRenderer* renderer )
{
mRenderer = renderer;
}
///
/// Resize Event Handler
///
void Preview::resizeEvent( QResizeEvent* event )
{
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
}
///
/// Clear View
///
void Preview::clearScene()
{
foreach ( QGraphicsItem *item, mScene->items() )
{
mScene->removeItem( item );
delete item;
}
}
///
/// Draw Paper
///
void Preview::drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph )
{
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
shadowEffect->setColor( shadowColor );
shadowEffect->setOffset( shadowOffsetPixels );
shadowEffect->setBlurRadius( shadowRadiusPixels );
QBrush brush( paperColor );
QPen pen( paperOutlineColor );
pen.setCosmetic( true );
pen.setWidthF( paperOutlineWidthPixels );
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() );
pageItem->setBrush( brush );
pageItem->setPen( pen );
pageItem->setGraphicsEffect( shadowEffect );
mScene->addItem( pageItem );
}
///
/// Draw Labels on Paper
///
void Preview::drawLabels()
{
libglabels::Frame *frame = mModel->tmplate()->frames().first();
foreach (libglabels::Point origin, frame->getOrigins() )
{
drawLabel( origin.x(), origin.y(), frame->path() );
}
}
///
/// Draw a Single Label at x,y
///
void Preview::drawLabel( const libglabels::Distance& x,
const libglabels::Distance& y,
const QPainterPath& path )
{
QBrush brush( Qt::NoBrush );
QPen pen( labelOutlineColor );
pen.setStyle( Qt::DotLine );
pen.setCosmetic( true );
pen.setWidthF( labelOutlineWidthPixels );
QGraphicsPathItem *labelOutlineItem = new QGraphicsPathItem( path );
labelOutlineItem->setBrush( brush );
labelOutlineItem->setPen( pen );
labelOutlineItem->setPos( x.pt(), y.pt() );
mScene->addItem( labelOutlineItem );
}
///
/// Draw Preview Overlay
///
void Preview::drawPreviewOverlay()
{
if ( mRenderer )
{
PreviewOverlayItem* overlayItem = new PreviewOverlayItem( mRenderer );
mScene->addItem( overlayItem );
}
}
setAttribute(Qt::WA_TranslucentBackground);
viewport()->setAutoFillBackground(false);
setFrameStyle( QFrame::NoFrame );
setRenderHints( QPainter::Antialiasing );
}
///
/// Set model
///
void Preview::setModel( const LabelModel* model )
{
mModel = model;
clearScene();
if ( mModel != NULL )
{
// Set scene up with a 5% margin around paper
glabels::Distance x = -0.05 * mModel->tmplate()->pageWidth();
glabels::Distance y = -0.05 * mModel->tmplate()->pageHeight();
glabels::Distance w = 1.10 * mModel->tmplate()->pageWidth();
glabels::Distance h = 1.10 * mModel->tmplate()->pageHeight();
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
drawPaper( mModel->tmplate()->pageWidth(), mModel->tmplate()->pageHeight() );
drawLabels();
drawPreviewOverlay();
}
}
///
/// Set renderer
///
void Preview::setRenderer( const PageRenderer* renderer )
{
mRenderer = renderer;
}
///
/// Resize Event Handler
///
void Preview::resizeEvent( QResizeEvent* event )
{
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
}
///
/// Clear View
///
void Preview::clearScene()
{
foreach ( QGraphicsItem *item, mScene->items() )
{
mScene->removeItem( item );
delete item;
}
}
///
/// Draw Paper
///
void Preview::drawPaper( const glabels::Distance& pw, const glabels::Distance& ph )
{
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
shadowEffect->setColor( shadowColor );
shadowEffect->setOffset( shadowOffsetPixels );
shadowEffect->setBlurRadius( shadowRadiusPixels );
QBrush brush( paperColor );
QPen pen( paperOutlineColor );
pen.setCosmetic( true );
pen.setWidthF( paperOutlineWidthPixels );
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() );
pageItem->setBrush( brush );
pageItem->setPen( pen );
pageItem->setGraphicsEffect( shadowEffect );
mScene->addItem( pageItem );
}
///
/// Draw Labels on Paper
///
void Preview::drawLabels()
{
glabels::Frame *frame = mModel->tmplate()->frames().first();
foreach (glabels::Point origin, frame->getOrigins() )
{
drawLabel( origin.x(), origin.y(), frame->path() );
}
}
///
/// Draw a Single Label at x,y
///
void Preview::drawLabel( const glabels::Distance& x,
const glabels::Distance& y,
const QPainterPath& path )
{
QBrush brush( Qt::NoBrush );
QPen pen( labelOutlineColor );
pen.setStyle( Qt::DotLine );
pen.setCosmetic( true );
pen.setWidthF( labelOutlineWidthPixels );
QGraphicsPathItem *labelOutlineItem = new QGraphicsPathItem( path );
labelOutlineItem->setBrush( brush );
labelOutlineItem->setPen( pen );
labelOutlineItem->setPos( x.pt(), y.pt() );
mScene->addItem( labelOutlineItem );
}
///
/// Draw Preview Overlay
///
void Preview::drawPreviewOverlay()
{
if ( mRenderer )
{
PreviewOverlayItem* overlayItem = new PreviewOverlayItem( mRenderer );
mScene->addItem( overlayItem );
}
}
+46 -49
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_Preview_h
#define glabels_Preview_h
#ifndef Preview_h
#define Preview_h
#include <QGraphicsView>
#include <QGraphicsScene>
@@ -27,65 +27,62 @@
#include "PageRenderer.h"
namespace glabels
class LabelModel; // Forward reference
///
/// Preview Widget
///
class Preview : public QGraphicsView
{
class LabelModel; // Forward reference
Q_OBJECT
///
/// Preview Widget
///
class Preview : public QGraphicsView
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
Preview( QWidget *parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
Preview( QWidget *parent = 0 );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
void setModel( const LabelModel* model );
void setRenderer( const PageRenderer* renderer );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
void setModel( const LabelModel* model );
void setRenderer( const PageRenderer* renderer );
/////////////////////////////////////
// Event handlers
/////////////////////////////////////
protected:
void resizeEvent( QResizeEvent* event );
/////////////////////////////////////
// Event handlers
/////////////////////////////////////
protected:
void resizeEvent( QResizeEvent* event );
/////////////////////////////////
// Internal Methods
/////////////////////////////////
private:
void clearScene();
void drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph );
void drawLabels();
void drawLabel( const libglabels::Distance& x,
const libglabels::Distance& y,
const QPainterPath& path );
/////////////////////////////////
// Internal Methods
/////////////////////////////////
private:
void clearScene();
void drawPaper( const glabels::Distance& pw, const glabels::Distance& ph );
void drawLabels();
void drawLabel( const glabels::Distance& x,
const glabels::Distance& y,
const QPainterPath& path );
void drawPreviewOverlay();
void drawPreviewOverlay();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const LabelModel* mModel;
const PageRenderer* mRenderer;
QGraphicsScene* mScene;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const LabelModel* mModel;
const PageRenderer* mRenderer;
QGraphicsScene* mScene;
};
};
}
#endif // glabels_Preview_h
#endif // Preview_h
+14 -19
View File
@@ -23,24 +23,19 @@
#include "PageRenderer.h"
namespace glabels
PreviewOverlayItem::PreviewOverlayItem( const PageRenderer* renderer, QGraphicsItem* parent )
: QGraphicsItem(parent), mRenderer(renderer)
{
PreviewOverlayItem::PreviewOverlayItem( const PageRenderer* renderer, QGraphicsItem* parent )
: QGraphicsItem(parent), mRenderer(renderer)
{
}
QRectF PreviewOverlayItem::boundingRect() const
{
return mRenderer->pageRect();
}
void PreviewOverlayItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
mRenderer->printPage( painter );
}
}
QRectF PreviewOverlayItem::boundingRect() const
{
return mRenderer->pageRect();
}
void PreviewOverlayItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
mRenderer->printPage( painter );
}
+28 -31
View File
@@ -18,46 +18,43 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_PreviewOverlayItem_h
#define glabels_PreviewOverlayItem_h
#ifndef PreviewOverlayItem_h
#define PreviewOverlayItem_h
#include <QGraphicsItem>
namespace glabels
class PageRenderer; // Forward reference
///
/// PreviewOverlayItem Widget
///
class PreviewOverlayItem : public QGraphicsItem
{
class PageRenderer; // Forward reference
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PreviewOverlayItem( const PageRenderer* renderer, QGraphicsItem* parent = 0 );
///
/// PreviewOverlayItem Widget
///
class PreviewOverlayItem : public QGraphicsItem
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PreviewOverlayItem( const PageRenderer* renderer, QGraphicsItem* parent = 0 );
/////////////////////////////////////
// Virtual method implementations
/////////////////////////////////////
public:
QRectF boundingRect() const;
void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget );
/////////////////////////////////////
// Virtual method implementations
/////////////////////////////////////
public:
QRectF boundingRect() const;
void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget );
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const PageRenderer* mRenderer;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const PageRenderer* mRenderer;
};
};
}
#endif // glabels_PreviewOverlayItem_h
#endif // PreviewOverlayItem_h
+139 -144
View File
@@ -26,150 +26,145 @@
#include <QtDebug>
namespace glabels
///
/// Constructor
///
PrintView::PrintView( QWidget *parent )
: QWidget(parent), mModel(0), mBlocked(false)
{
setupUi( this );
preview->setRenderer( &mRenderer );
///
/// Constructor
///
PrintView::PrintView( QWidget *parent )
: QWidget(parent), mModel(0), mBlocked(false)
{
setupUi( this );
preview->setRenderer( &mRenderer );
mPrinter = new QPrinter( QPrinter::HighResolution );
}
///
/// Destructor
///
PrintView::~PrintView()
{
delete mPrinter;
}
///
/// Set Model
///
void PrintView::setModel( LabelModel* model )
{
mModel = model;
// TODO set visibility based on merge selection
copiesBox->setVisible( true );
mergeBox->setVisible( false );
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
connect( mModel, SIGNAL(changed()), this, SLOT(onLabelChanged()) );
onLabelSizeChanged();
onFormChanged();
}
///
/// Label size changed handler
///
void PrintView::onLabelSizeChanged()
{
preview->setModel( mModel );
mRenderer.setModel( mModel );
}
///
/// Label changed handler
///
void PrintView::onLabelChanged()
{
preview->update();
}
///
/// Form changed handler
///
void PrintView::onFormChanged()
{
if ( !mBlocked )
{
mBlocked = true;
int nLabelsPerPage = mModel->frame()->nLabels();
copiesFromSpin->setRange( 1, nLabelsPerPage );
copiesToSpin->setRange( copiesFromSpin->value(), nLabelsPerPage );
// TODO select between simple and merge
if ( copiesSheetsRadio->isChecked() )
{
mRenderer.setNLabels( copiesSheetsSpin->value()*nLabelsPerPage );
mRenderer.setStartLabel( 0 );
copiesFromSpin->setValue( 1 );
copiesToSpin->setValue( nLabelsPerPage );
}
else
{
mRenderer.setNLabels( copiesToSpin->value() - copiesFromSpin->value() + 1 );
mRenderer.setStartLabel( copiesFromSpin->value() - 1 );
copiesSheetsSpin->setValue( 1 );
}
mRenderer.setPrintOutlines( printOutlinesCheck->isChecked() );
mRenderer.setPrintCropMarks( printCropMarksCheck->isChecked() );
mRenderer.setPrintReverse( printReverseCheck->isChecked() );
pageSpin->setRange( 1, mRenderer.nPages() );
nPagesLabel->setText( QString::number( mRenderer.nPages() ) );
mRenderer.setIPage( pageSpin->value() - 1 );
preview->update();
mBlocked = false;
}
}
///
/// Print Button Clicked handler
///
void PrintView::onPrintButtonClicked()
{
QSizeF pageSize( mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
mPrinter->setPaperSize( pageSize, QPrinter::Point );
mPrinter->setFullPage( true );
mPrinter->setPageMargins( 0, 0, 0, 0, QPrinter::Point );
QPrintDialog printDialog( mPrinter, this );
printDialog.setOption( QAbstractPrintDialog::PrintToFile, true );
printDialog.setOption( QAbstractPrintDialog::PrintSelection, false );
printDialog.setOption( QAbstractPrintDialog::PrintPageRange, false );
printDialog.setOption( QAbstractPrintDialog::PrintShowPageSize, true );
printDialog.setOption( QAbstractPrintDialog::PrintCollateCopies, false );
printDialog.setOption( QAbstractPrintDialog::PrintCurrentPage, false );
if ( printDialog.exec() == QDialog::Accepted )
{
QPainter painter( mPrinter );
QSizeF sizePx = mPrinter->paperSize( QPrinter::DevicePixel );
QSizeF sizePts = mPrinter->paperSize( QPrinter::Point );
painter.scale( sizePx.width()/sizePts.width(), sizePx.height()/sizePts.height() );
for ( int iPage = 0; iPage < mRenderer.nPages(); iPage++ )
{
if ( iPage )
{
mPrinter->newPage();
}
mRenderer.printPage( &painter, iPage );
}
}
}
mPrinter = new QPrinter( QPrinter::HighResolution );
}
///
/// Destructor
///
PrintView::~PrintView()
{
delete mPrinter;
}
///
/// Set Model
///
void PrintView::setModel( LabelModel* model )
{
mModel = model;
// TODO set visibility based on merge selection
copiesBox->setVisible( true );
mergeBox->setVisible( false );
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
connect( mModel, SIGNAL(changed()), this, SLOT(onLabelChanged()) );
onLabelSizeChanged();
onFormChanged();
}
///
/// Label size changed handler
///
void PrintView::onLabelSizeChanged()
{
preview->setModel( mModel );
mRenderer.setModel( mModel );
}
///
/// Label changed handler
///
void PrintView::onLabelChanged()
{
preview->update();
}
///
/// Form changed handler
///
void PrintView::onFormChanged()
{
if ( !mBlocked )
{
mBlocked = true;
int nLabelsPerPage = mModel->frame()->nLabels();
copiesFromSpin->setRange( 1, nLabelsPerPage );
copiesToSpin->setRange( copiesFromSpin->value(), nLabelsPerPage );
// TODO select between simple and merge
if ( copiesSheetsRadio->isChecked() )
{
mRenderer.setNLabels( copiesSheetsSpin->value()*nLabelsPerPage );
mRenderer.setStartLabel( 0 );
copiesFromSpin->setValue( 1 );
copiesToSpin->setValue( nLabelsPerPage );
}
else
{
mRenderer.setNLabels( copiesToSpin->value() - copiesFromSpin->value() + 1 );
mRenderer.setStartLabel( copiesFromSpin->value() - 1 );
copiesSheetsSpin->setValue( 1 );
}
mRenderer.setPrintOutlines( printOutlinesCheck->isChecked() );
mRenderer.setPrintCropMarks( printCropMarksCheck->isChecked() );
mRenderer.setPrintReverse( printReverseCheck->isChecked() );
pageSpin->setRange( 1, mRenderer.nPages() );
nPagesLabel->setText( QString::number( mRenderer.nPages() ) );
mRenderer.setIPage( pageSpin->value() - 1 );
preview->update();
mBlocked = false;
}
}
///
/// Print Button Clicked handler
///
void PrintView::onPrintButtonClicked()
{
QSizeF pageSize( mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
mPrinter->setPaperSize( pageSize, QPrinter::Point );
mPrinter->setFullPage( true );
mPrinter->setPageMargins( 0, 0, 0, 0, QPrinter::Point );
QPrintDialog printDialog( mPrinter, this );
printDialog.setOption( QAbstractPrintDialog::PrintToFile, true );
printDialog.setOption( QAbstractPrintDialog::PrintSelection, false );
printDialog.setOption( QAbstractPrintDialog::PrintPageRange, false );
printDialog.setOption( QAbstractPrintDialog::PrintShowPageSize, true );
printDialog.setOption( QAbstractPrintDialog::PrintCollateCopies, false );
printDialog.setOption( QAbstractPrintDialog::PrintCurrentPage, false );
if ( printDialog.exec() == QDialog::Accepted )
{
QPainter painter( mPrinter );
QSizeF sizePx = mPrinter->paperSize( QPrinter::DevicePixel );
QSizeF sizePts = mPrinter->paperSize( QPrinter::Point );
painter.scale( sizePx.width()/sizePts.width(), sizePx.height()/sizePts.height() );
for ( int iPage = 0; iPage < mRenderer.nPages(); iPage++ )
{
if ( iPage )
{
mPrinter->newPage();
}
mRenderer.printPage( &painter, iPage );
}
}
}
+37 -40
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_PrintView_h
#define glabels_PrintView_h
#ifndef PrintView_h
#define PrintView_h
#include "ui_PrintView.h"
#include "PageRenderer.h"
@@ -27,55 +27,52 @@
#include <QPrinter>
namespace glabels
{
class LabelModel; // Forward reference
class LabelModel; // Forward reference
///
/// Print View Widget
///
class PrintView : public QWidget, public Ui_PrintView
{
Q_OBJECT
///
/// Print View Widget
///
class PrintView : public QWidget, public Ui_PrintView
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PrintView( QWidget *parent = 0 );
~PrintView();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PrintView( QWidget *parent = 0 );
~PrintView();
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelChanged();
void onLabelSizeChanged();
void onFormChanged();
void onPrintButtonClicked();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelChanged();
void onLabelSizeChanged();
void onFormChanged();
void onPrintButtonClicked();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
LabelModel* mModel;
QPrinter* mPrinter;
PageRenderer mRenderer;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
LabelModel* mModel;
QPrinter* mPrinter;
PageRenderer mRenderer;
bool mBlocked;
bool mBlocked;
};
};
}
#endif // glabels_PrintView_h
#endif // PrintView_h
+136 -141
View File
@@ -27,167 +27,162 @@
#include <QtDebug>
namespace glabels
///
/// Constructor
///
PropertiesView::PropertiesView( QWidget *parent )
: QWidget(parent), mModel(0)
{
setupUi( this );
///
/// Constructor
///
PropertiesView::PropertiesView( QWidget *parent )
: QWidget(parent), mModel(0)
similarBrowser->setAttribute(Qt::WA_TranslucentBackground);
similarBrowser->viewport()->setAutoFillBackground(false);
}
///
/// Destructor
///
PropertiesView::~PropertiesView()
{
}
///
/// Set Model
///
void PropertiesView::setModel( LabelModel* model )
{
mModel = model;
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
onLabelSizeChanged();
}
///
/// Label size changed handler
///
void PropertiesView::onLabelSizeChanged()
{
const glabels::Template *tmplate = mModel->tmplate();
const glabels::Frame *frame = tmplate->frames().first();
bool isRotated = mModel->rotate();
preview->setTemplate( tmplate );
preview->setRotate( isRotated );
const glabels::Vendor *vendor = glabels::Db::lookupVendorFromName( tmplate->brand() );
if ( (vendor != NULL) && (vendor->url() != NULL) )
{
setupUi( this );
similarBrowser->setAttribute(Qt::WA_TranslucentBackground);
similarBrowser->viewport()->setAutoFillBackground(false);
QString markup = "<a href='" + vendor->url() + "'>" + vendor->name() + "</a>";
vendorLabel->setText( markup );
}
else
{
vendorLabel->setText( tmplate->brand() );
}
///
/// Destructor
///
PropertiesView::~PropertiesView()
if ( tmplate->productUrl() != NULL )
{
QString markup = "<a href='" + tmplate->productUrl() + "'>" + tmplate->part() + "</a>";
partLabel->setText( markup );
}
else
{
partLabel->setText( tmplate->part() );
}
descriptionLabel->setText( tmplate->description() );
///
/// Set Model
///
void PropertiesView::setModel( LabelModel* model )
QString pgSizeString = glabels::Db::lookupPaperNameFromId( tmplate->paperId() );
pageSizeLabel->setText( pgSizeString );
QString labelSizeString = frame->sizeDescription( glabels::Distance::Units::IN );
labelSizeLabel->setText( labelSizeString );
QString layoutString = frame->layoutDescription();
layoutLabel->setText( layoutString );
QStringList list = glabels::Db::getNameListOfSimilarTemplates( tmplate->name() );
if ( list.isEmpty() )
{
mModel = model;
similarProductsGroupBox->hide();
similarProductsNullBox->show();
}
else
{
similarProductsGroupBox->show();
similarProductsNullBox->hide();
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
onLabelSizeChanged();
QString similarListString;
foreach ( QString name, list )
{
similarListString += name + "\n";
}
similarBrowser->setText( similarListString );
}
///
/// Label size changed handler
///
void PropertiesView::onLabelSizeChanged()
orientationCombo->setEnabled( frame->w() != frame->h() );
if ( frame->w() == frame->h() )
{
const libglabels::Template *tmplate = mModel->tmplate();
const libglabels::Frame *frame = tmplate->frames().first();
bool isRotated = mModel->rotate();
preview->setTemplate( tmplate );
preview->setRotate( isRotated );
const libglabels::Vendor *vendor = libglabels::Db::lookupVendorFromName( tmplate->brand() );
if ( (vendor != NULL) && (vendor->url() != NULL) )
{
QString markup = "<a href='" + vendor->url() + "'>" + vendor->name() + "</a>";
vendorLabel->setText( markup );
}
else
{
vendorLabel->setText( tmplate->brand() );
}
if ( tmplate->productUrl() != NULL )
{
QString markup = "<a href='" + tmplate->productUrl() + "'>" + tmplate->part() + "</a>";
partLabel->setText( markup );
}
else
{
partLabel->setText( tmplate->part() );
}
descriptionLabel->setText( tmplate->description() );
QString pgSizeString = libglabels::Db::lookupPaperNameFromId( tmplate->paperId() );
pageSizeLabel->setText( pgSizeString );
QString labelSizeString = frame->sizeDescription( libglabels::Distance::Units::IN );
labelSizeLabel->setText( labelSizeString );
QString layoutString = frame->layoutDescription();
layoutLabel->setText( layoutString );
QStringList list = libglabels::Db::getNameListOfSimilarTemplates( tmplate->name() );
if ( list.isEmpty() )
{
similarProductsGroupBox->hide();
similarProductsNullBox->show();
}
else
{
similarProductsGroupBox->show();
similarProductsNullBox->hide();
QString similarListString;
foreach ( QString name, list )
{
similarListString += name + "\n";
}
similarBrowser->setText( similarListString );
}
orientationCombo->setEnabled( frame->w() != frame->h() );
if ( frame->w() == frame->h() )
{
orientationCombo->setCurrentIndex(0);
}
else if ( frame->w() > frame->h() )
{
orientationCombo->setCurrentIndex( isRotated ? 1 : 0 );
}
else
{
orientationCombo->setCurrentIndex( isRotated ? 0 : 1 );
}
orientationCombo->setCurrentIndex(0);
}
///
/// Form changed handler
///
void PropertiesView::onFormChanged()
else if ( frame->w() > frame->h() )
{
const libglabels::Template *tmplate = mModel->tmplate();
const libglabels::Frame *frame = tmplate->frames().first();
orientationCombo->setCurrentIndex( isRotated ? 1 : 0 );
}
else
{
orientationCombo->setCurrentIndex( isRotated ? 0 : 1 );
}
}
///
/// Form changed handler
///
void PropertiesView::onFormChanged()
{
const glabels::Template *tmplate = mModel->tmplate();
const glabels::Frame *frame = tmplate->frames().first();
if ( frame->w() == frame->h() )
{
mModel->setRotate( false );
}
else if ( frame->w() > frame->h() )
{
int index = orientationCombo->currentIndex();
mModel->setRotate( index == 1 );
}
else
{
int index = orientationCombo->currentIndex();
mModel->setRotate( index == 0 );
}
}
///
/// Change Product Button Clicked handler
///
void PropertiesView::onChangeProductButtonClicked()
{
SelectProductDialog selectProductDialog( this );
selectProductDialog.exec();
const glabels::Template* tmplate = selectProductDialog.tmplate();
if ( tmplate )
{
mModel->setTmplate( tmplate );
// Don't rotate circular or round labels
const glabels::Frame *frame = tmplate->frames().first();
if ( frame->w() == frame->h() )
{
mModel->setRotate( false );
}
else if ( frame->w() > frame->h() )
{
int index = orientationCombo->currentIndex();
mModel->setRotate( index == 1 );
}
else
{
int index = orientationCombo->currentIndex();
mModel->setRotate( index == 0 );
}
}
///
/// Change Product Button Clicked handler
///
void PropertiesView::onChangeProductButtonClicked()
{
SelectProductDialog selectProductDialog( this );
selectProductDialog.exec();
const libglabels::Template* tmplate = selectProductDialog.tmplate();
if ( tmplate )
{
mModel->setTmplate( tmplate );
// Don't rotate circular or round labels
const libglabels::Frame *frame = tmplate->frames().first();
if ( frame->w() == frame->h() )
{
mModel->setRotate( false );
}
}
}
}
+33 -36
View File
@@ -18,56 +18,53 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_PropertiesView_h
#define glabels_PropertiesView_h
#ifndef PropertiesView_h
#define PropertiesView_h
#include "ui_PropertiesView.h"
namespace glabels
{
class LabelModel; // Forward reference
class LabelModel; // Forward reference
///
/// Properties View Widget
///
class PropertiesView : public QWidget, public Ui_PropertiesView
{
Q_OBJECT
///
/// Properties View Widget
///
class PropertiesView : public QWidget, public Ui_PropertiesView
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PropertiesView( QWidget *parent = 0 );
~PropertiesView();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PropertiesView( QWidget *parent = 0 );
~PropertiesView();
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelSizeChanged();
void onFormChanged();
void onChangeProductButtonClicked();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelSizeChanged();
void onFormChanged();
void onChangeProductButtonClicked();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
LabelModel* mModel;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
LabelModel* mModel;
};
};
}
#endif // glabels_PropertiesView_h
#endif // PropertiesView_h
+95 -100
View File
@@ -26,108 +26,103 @@
#include "TemplatePickerItem.h"
namespace glabels
///
/// Constructor
///
SelectProductDialog::SelectProductDialog( QWidget *parent )
: QDialog(parent), mCanceled(false)
{
setupUi( this );
///
/// Constructor
///
SelectProductDialog::SelectProductDialog( QWidget *parent )
: QDialog(parent), mCanceled(false)
{
setupUi( this );
// TODO: Set default based on locale and/or saved preferences
// Perhaps move to checkboxes
pageSizeIsoCheck->setChecked( false );
pageSizeUsCheck->setChecked( true );
pageSizeOtherCheck->setChecked( true );
// TODO: Set default based on locale and/or saved preferences
// Perhaps move to checkboxes
pageSizeIsoCheck->setChecked( false );
pageSizeUsCheck->setChecked( true );
pageSizeOtherCheck->setChecked( true );
QList<libglabels::Template*> tmplates = libglabels::Db::templates();
templatePicker->setTemplates( tmplates );
templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked() );
}
///
/// Get selected template
///
const libglabels::Template* SelectProductDialog::tmplate() const
{
if ( !mCanceled )
{
return templatePicker->selectedTemplate();
}
else
{
return 0;
}
}
///
/// Search Entry Text Changed Slot
///
void SelectProductDialog::onSearchEntryTextChanged()
{
templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked() );
}
///
/// Search Entry Text Changed Slot
///
void SelectProductDialog::onSearchClearButtonClicked()
{
searchEntry->setText( "" );
}
///
/// Page Size Check Toggled Slot
///
void SelectProductDialog::onPageSizeCheckToggled()
{
templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked() );
}
///
/// Template Picker Selection Changed Slot
///
void SelectProductDialog::onTemplatePickerSelectionChanged()
{
const libglabels::Template *tmplate = templatePicker->selectedTemplate();
selectButton->setEnabled( tmplate != NULL );
}
///
/// Select Button Clicked Slot
///
void SelectProductDialog::onSelectButtonClicked()
{
close();
}
///
/// Cancel Button Clicked Slot
///
void SelectProductDialog::onCancelButtonClicked()
{
mCanceled = true;
close();
}
QList<glabels::Template*> tmplates = glabels::Db::templates();
templatePicker->setTemplates( tmplates );
templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked() );
}
///
/// Get selected template
///
const glabels::Template* SelectProductDialog::tmplate() const
{
if ( !mCanceled )
{
return templatePicker->selectedTemplate();
}
else
{
return 0;
}
}
///
/// Search Entry Text Changed Slot
///
void SelectProductDialog::onSearchEntryTextChanged()
{
templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked() );
}
///
/// Search Entry Text Changed Slot
///
void SelectProductDialog::onSearchClearButtonClicked()
{
searchEntry->setText( "" );
}
///
/// Page Size Check Toggled Slot
///
void SelectProductDialog::onPageSizeCheckToggled()
{
templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(),
pageSizeUsCheck->isChecked(),
pageSizeOtherCheck->isChecked() );
}
///
/// Template Picker Selection Changed Slot
///
void SelectProductDialog::onTemplatePickerSelectionChanged()
{
const glabels::Template *tmplate = templatePicker->selectedTemplate();
selectButton->setEnabled( tmplate != NULL );
}
///
/// Select Button Clicked Slot
///
void SelectProductDialog::onSelectButtonClicked()
{
close();
}
///
/// Cancel Button Clicked Slot
///
void SelectProductDialog::onCancelButtonClicked()
{
mCanceled = true;
close();
}
+33 -37
View File
@@ -18,56 +18,52 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_SelectProductDialog_h
#define glabels_SelectProductDialog_h
#ifndef SelectProductDialog_h
#define SelectProductDialog_h
#include "ui_SelectProductDialog.h"
namespace glabels
///
/// New Label Dialog Widget
///
class SelectProductDialog : public QDialog, public Ui_SelectProductDialog
{
///
/// New Label Dialog Widget
///
class SelectProductDialog : public QDialog, public Ui_SelectProductDialog
{
Q_OBJECT
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
SelectProductDialog( QWidget *parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
SelectProductDialog( QWidget *parent = 0 );
/////////////////////////////////
// Accessors
/////////////////////////////////
const libglabels::Template* tmplate() const;
/////////////////////////////////
// Accessors
/////////////////////////////////
const glabels::Template* tmplate() const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onSearchEntryTextChanged();
void onSearchClearButtonClicked();
void onPageSizeCheckToggled();
void onTemplatePickerSelectionChanged();
void onSelectButtonClicked();
void onCancelButtonClicked();
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onSearchEntryTextChanged();
void onSearchClearButtonClicked();
void onPageSizeCheckToggled();
void onTemplatePickerSelectionChanged();
void onSelectButtonClicked();
void onCancelButtonClicked();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
bool mCanceled;
/////////////////////////////////
// Private data
/////////////////////////////////
private:
bool mCanceled;
};
};
}
#endif // glabels_SelectProductDialog_h
#endif // SelectProductDialog_h
+195 -200
View File
@@ -51,207 +51,202 @@ namespace
}
namespace glabels
///
/// Constructor
///
SimplePreview::SimplePreview( QWidget *parent )
: mTmplate(NULL), mRotateFlag(false), QGraphicsView(parent)
{
mScene = new QGraphicsScene();
setScene( mScene );
///
/// Constructor
///
SimplePreview::SimplePreview( QWidget *parent )
: mTmplate(NULL), mRotateFlag(false), QGraphicsView(parent)
{
mScene = new QGraphicsScene();
setScene( mScene );
setAttribute(Qt::WA_TranslucentBackground);
viewport()->setAutoFillBackground(false);
setFrameStyle( QFrame::NoFrame );
setRenderHints( QPainter::Antialiasing );
}
///
/// Template Property Setter
///
void SimplePreview::setTemplate( const libglabels::Template *tmplate )
{
mTmplate = tmplate;
update();
}
///
/// Rotate Property Setter
///
void SimplePreview::setRotate( bool rotateFlag )
{
mRotateFlag = rotateFlag;
update();
}
///
/// Resize Event Handler
///
void SimplePreview::resizeEvent( QResizeEvent* event )
{
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
}
///
/// Update View
///
void SimplePreview::update()
{
clearScene();
if ( mTmplate != NULL )
{
// Set scene up with a 5% margin around paper
libglabels::Distance x = -0.05 * mTmplate->pageWidth();
libglabels::Distance y = -0.05 * mTmplate->pageHeight();
libglabels::Distance w = 1.10 * mTmplate->pageWidth();
libglabels::Distance h = 1.10 * mTmplate->pageHeight();
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
drawPaper( mTmplate->pageWidth(), mTmplate->pageHeight() );
drawLabels();
drawArrow();
}
}
///
/// Clear View
///
void SimplePreview::clearScene()
{
foreach ( QGraphicsItem *item, mScene->items() )
{
mScene->removeItem( item );
delete item;
}
}
///
/// Draw Paper
///
void SimplePreview::drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph )
{
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
shadowEffect->setColor( shadowColor );
shadowEffect->setOffset( shadowOffsetPixels );
shadowEffect->setBlurRadius( shadowRadiusPixels );
QBrush brush( paperColor );
QPen pen( paperOutlineColor );
pen.setCosmetic( true );
pen.setWidthF( paperOutlineWidthPixels );
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() );
pageItem->setBrush( brush );
pageItem->setPen( pen );
pageItem->setGraphicsEffect( shadowEffect );
mScene->addItem( pageItem );
}
///
/// Draw Labels on Paper
///
void SimplePreview::drawLabels()
{
libglabels::Frame *frame = mTmplate->frames().first();
foreach (libglabels::Point origin, frame->getOrigins() )
{
drawLabel( origin.x(), origin.y(), frame->path() );
}
}
///
/// Draw a Single Label at x,y
///
void SimplePreview::drawLabel( const libglabels::Distance& x,
const libglabels::Distance& y,
const QPainterPath& path )
{
QBrush brush( labelColor );
QPen pen( labelOutlineColor );
pen.setCosmetic( true );
pen.setWidthF( labelOutlineWidthPixels );
QGraphicsPathItem *labelItem = new QGraphicsPathItem( path );
labelItem->setBrush( brush );
labelItem->setPen( pen );
labelItem->setPos( x.pt(), y.pt() );
mScene->addItem( labelItem );
}
///
/// Draw Arrow Indicating Top of First Label
///
void SimplePreview::drawArrow()
{
libglabels::Frame *frame = mTmplate->frames().first();
libglabels::Distance w = frame->w();
libglabels::Distance h = frame->h();
libglabels::Distance min = libglabels::min( w, h );
QPen pen( arrowColor );
pen.setWidthF( 0.25*min.pt()*arrowScale );
pen.setCapStyle( Qt::FlatCap );
pen.setJoinStyle( Qt::MiterJoin );
QBrush brush( upColor );
libglabels::Point origin = frame->getOrigins().first();
libglabels::Distance x0 = origin.x();
libglabels::Distance y0 = origin.y();
QPainterPath path;
path.moveTo( 0, min.pt()*arrowScale/3 );
path.lineTo( 0, -min.pt()*arrowScale );
path.moveTo( -min.pt()*arrowScale/2, -min.pt()*arrowScale/2 );
path.lineTo( 0, -min.pt()*arrowScale );
path.lineTo( min.pt()*arrowScale/2, -min.pt()*arrowScale/2 );
QGraphicsPathItem *arrowItem = new QGraphicsPathItem( path );
arrowItem->setPen( pen );
arrowItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() );
if ( mRotateFlag )
{
arrowItem->setRotation( 90 );
}
QGraphicsSimpleTextItem *upItem = new QGraphicsSimpleTextItem( tr("Up") );
upItem->setBrush( brush );
upItem->setFont( QFont( upFontFamily, min.pt()*upScale, QFont::Bold ) );
upItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() );
QRectF rect = upItem->boundingRect();
if ( mRotateFlag )
{
upItem->setPos( upItem->x()-min.pt()/8, upItem->y()-rect.width()/2 );
upItem->setRotation( 90 );
}
else
{
upItem->setPos( upItem->x()-rect.width()/2, upItem->y()+min.pt()/8 );
}
mScene->addItem( arrowItem );
mScene->addItem( upItem );
}
setAttribute(Qt::WA_TranslucentBackground);
viewport()->setAutoFillBackground(false);
setFrameStyle( QFrame::NoFrame );
setRenderHints( QPainter::Antialiasing );
}
///
/// Template Property Setter
///
void SimplePreview::setTemplate( const glabels::Template *tmplate )
{
mTmplate = tmplate;
update();
}
///
/// Rotate Property Setter
///
void SimplePreview::setRotate( bool rotateFlag )
{
mRotateFlag = rotateFlag;
update();
}
///
/// Resize Event Handler
///
void SimplePreview::resizeEvent( QResizeEvent* event )
{
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
}
///
/// Update View
///
void SimplePreview::update()
{
clearScene();
if ( mTmplate != NULL )
{
// Set scene up with a 5% margin around paper
glabels::Distance x = -0.05 * mTmplate->pageWidth();
glabels::Distance y = -0.05 * mTmplate->pageHeight();
glabels::Distance w = 1.10 * mTmplate->pageWidth();
glabels::Distance h = 1.10 * mTmplate->pageHeight();
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
drawPaper( mTmplate->pageWidth(), mTmplate->pageHeight() );
drawLabels();
drawArrow();
}
}
///
/// Clear View
///
void SimplePreview::clearScene()
{
foreach ( QGraphicsItem *item, mScene->items() )
{
mScene->removeItem( item );
delete item;
}
}
///
/// Draw Paper
///
void SimplePreview::drawPaper( const glabels::Distance& pw, const glabels::Distance& ph )
{
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
shadowEffect->setColor( shadowColor );
shadowEffect->setOffset( shadowOffsetPixels );
shadowEffect->setBlurRadius( shadowRadiusPixels );
QBrush brush( paperColor );
QPen pen( paperOutlineColor );
pen.setCosmetic( true );
pen.setWidthF( paperOutlineWidthPixels );
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() );
pageItem->setBrush( brush );
pageItem->setPen( pen );
pageItem->setGraphicsEffect( shadowEffect );
mScene->addItem( pageItem );
}
///
/// Draw Labels on Paper
///
void SimplePreview::drawLabels()
{
glabels::Frame *frame = mTmplate->frames().first();
foreach (glabels::Point origin, frame->getOrigins() )
{
drawLabel( origin.x(), origin.y(), frame->path() );
}
}
///
/// Draw a Single Label at x,y
///
void SimplePreview::drawLabel( const glabels::Distance& x,
const glabels::Distance& y,
const QPainterPath& path )
{
QBrush brush( labelColor );
QPen pen( labelOutlineColor );
pen.setCosmetic( true );
pen.setWidthF( labelOutlineWidthPixels );
QGraphicsPathItem *labelItem = new QGraphicsPathItem( path );
labelItem->setBrush( brush );
labelItem->setPen( pen );
labelItem->setPos( x.pt(), y.pt() );
mScene->addItem( labelItem );
}
///
/// Draw Arrow Indicating Top of First Label
///
void SimplePreview::drawArrow()
{
glabels::Frame *frame = mTmplate->frames().first();
glabels::Distance w = frame->w();
glabels::Distance h = frame->h();
glabels::Distance min = glabels::min( w, h );
QPen pen( arrowColor );
pen.setWidthF( 0.25*min.pt()*arrowScale );
pen.setCapStyle( Qt::FlatCap );
pen.setJoinStyle( Qt::MiterJoin );
QBrush brush( upColor );
glabels::Point origin = frame->getOrigins().first();
glabels::Distance x0 = origin.x();
glabels::Distance y0 = origin.y();
QPainterPath path;
path.moveTo( 0, min.pt()*arrowScale/3 );
path.lineTo( 0, -min.pt()*arrowScale );
path.moveTo( -min.pt()*arrowScale/2, -min.pt()*arrowScale/2 );
path.lineTo( 0, -min.pt()*arrowScale );
path.lineTo( min.pt()*arrowScale/2, -min.pt()*arrowScale/2 );
QGraphicsPathItem *arrowItem = new QGraphicsPathItem( path );
arrowItem->setPen( pen );
arrowItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() );
if ( mRotateFlag )
{
arrowItem->setRotation( 90 );
}
QGraphicsSimpleTextItem *upItem = new QGraphicsSimpleTextItem( tr("Up") );
upItem->setBrush( brush );
upItem->setFont( QFont( upFontFamily, min.pt()*upScale, QFont::Bold ) );
upItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() );
QRectF rect = upItem->boundingRect();
if ( mRotateFlag )
{
upItem->setPos( upItem->x()-min.pt()/8, upItem->y()-rect.width()/2 );
upItem->setRotation( 90 );
}
else
{
upItem->setPos( upItem->x()-rect.width()/2, upItem->y()+min.pt()/8 );
}
mScene->addItem( arrowItem );
mScene->addItem( upItem );
}
+44 -48
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_SimplePreview_h
#define glabels_SimplePreview_h
#ifndef SimplePreview_h
#define SimplePreview_h
#include <QGraphicsView>
#include <QGraphicsScene>
@@ -29,64 +29,60 @@
#include "libglabels/Template.h"
namespace glabels
///
/// Simple Preview Widget
///
class SimplePreview : public QGraphicsView
{
///
/// Simple Preview Widget
///
class SimplePreview : public QGraphicsView
{
Q_OBJECT
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
SimplePreview( QWidget *parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
SimplePreview( QWidget *parent = 0 );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
void setTemplate( const libglabels::Template *tmplate );
void setRotate( bool rotateFlag );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
void setTemplate( const glabels::Template *tmplate );
void setRotate( bool rotateFlag );
/////////////////////////////////////
// Event handlers
/////////////////////////////////////
protected:
void resizeEvent( QResizeEvent* event );
/////////////////////////////////////
// Event handlers
/////////////////////////////////////
protected:
void resizeEvent( QResizeEvent* event );
/////////////////////////////////
// Internal Methods
/////////////////////////////////
private:
void update();
void clearScene();
void drawPaper( const libglabels::Distance& pw, const libglabels::Distance& ph );
void drawLabels();
void drawLabel( const libglabels::Distance& x,
const libglabels::Distance& y,
const QPainterPath& path );
void drawArrow();
/////////////////////////////////
// Internal Methods
/////////////////////////////////
private:
void update();
void clearScene();
void drawPaper( const glabels::Distance& pw, const glabels::Distance& ph );
void drawLabels();
void drawLabel( const glabels::Distance& x,
const glabels::Distance& y,
const QPainterPath& path );
void drawArrow();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const libglabels::Template *mTmplate;
bool mRotateFlag;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
const glabels::Template *mTmplate;
bool mRotateFlag;
QGraphicsScene *mScene;
QGraphicsScene *mScene;
};
};
}
#endif // glabels_SimplePreview_h
#endif // SimplePreview_h
+55 -61
View File
@@ -25,79 +25,73 @@
#include "TemplatePickerItem.h"
namespace glabels
///
/// Constructor
///
TemplatePicker::TemplatePicker( QWidget *parent ) : QListWidget(parent)
{
setViewMode( QListView::IconMode );
setResizeMode( QListView::Adjust );
setSpacing( 24 );
setWordWrap( true );
setUniformItemSizes( true );
setIconSize( QSize(glabels::TEMPLATE_PREVIEW_SIZE, glabels::TEMPLATE_PREVIEW_SIZE) );
}
///
/// Constructor
///
TemplatePicker::TemplatePicker( QWidget *parent ) : QListWidget(parent)
///
/// Set List of Templates to Pick From
///
void TemplatePicker::setTemplates( const QList <glabels::Template*> &tmplates )
{
foreach (glabels::Template *tmplate, tmplates)
{
setViewMode( QListView::IconMode );
setResizeMode( QListView::Adjust );
setSpacing( 24 );
setWordWrap( true );
setUniformItemSizes( true );
setIconSize( QSize(libglabels::TEMPLATE_PREVIEW_SIZE, libglabels::TEMPLATE_PREVIEW_SIZE) );
TemplatePickerItem *item = new TemplatePickerItem( tmplate, this );
}
}
///
/// Set List of Templates to Pick From
///
void TemplatePicker::setTemplates( const QList <libglabels::Template*> &tmplates )
///
/// Apply Filter to Narrow Template Choices
///
void TemplatePicker::applyFilter( const QString &searchString,
bool isoMask, bool usMask, bool otherMask )
{
foreach ( QListWidgetItem *item, findItems( "*", Qt::MatchWildcard ) )
{
foreach (libglabels::Template *tmplate, tmplates)
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem *>(item);
bool sizeMask =
(isoMask && tItem->tmplate()->isSizeIso()) ||
(usMask && tItem->tmplate()->isSizeUs()) ||
(otherMask && tItem->tmplate()->isSizeOther());
if ( tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) && sizeMask )
{
TemplatePickerItem *item = new TemplatePickerItem( tmplate, this );
}
}
///
/// Apply Filter to Narrow Template Choices
///
void TemplatePicker::applyFilter( const QString &searchString,
bool isoMask, bool usMask, bool otherMask )
{
foreach ( QListWidgetItem *item, findItems( "*", Qt::MatchWildcard ) )
{
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem *>(item);
bool sizeMask =
(isoMask && tItem->tmplate()->isSizeIso()) ||
(usMask && tItem->tmplate()->isSizeUs()) ||
(otherMask && tItem->tmplate()->isSizeOther());
if ( tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ) && sizeMask )
{
item->setHidden( false );
}
else
{
item->setHidden( true );
item->setSelected( false );
}
}
}
///
/// Get Currently Selected Template
///
const libglabels::Template *TemplatePicker::selectedTemplate()
{
QList<QListWidgetItem *> items = selectedItems();
if ( items.isEmpty() )
{
return NULL;
item->setHidden( false );
}
else
{
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem*>(items.first());
return tItem->tmplate();
item->setHidden( true );
item->setSelected( false );
}
}
}
///
/// Get Currently Selected Template
///
const glabels::Template *TemplatePicker::selectedTemplate()
{
QList<QListWidgetItem *> items = selectedItems();
if ( items.isEmpty() )
{
return NULL;
}
else
{
TemplatePickerItem *tItem = dynamic_cast<TemplatePickerItem*>(items.first());
return tItem->tmplate();
}
}
+24 -28
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_TemplatePicker_h
#define glabels_TemplatePicker_h
#ifndef TemplatePicker_h
#define TemplatePicker_h
#include <QListWidget>
@@ -28,40 +28,36 @@
#include "libglabels/Template.h"
namespace glabels
///
/// Template Picker Widget
///
class TemplatePicker : public QListWidget
{
///
/// Template Picker Widget
///
class TemplatePicker : public QListWidget
{
Q_OBJECT
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
TemplatePicker( QWidget *parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
TemplatePicker( QWidget *parent = 0 );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
void setTemplates( const QList <libglabels::Template*> &tmplates );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
void setTemplates( const QList <glabels::Template*> &tmplates );
/////////////////////////////////
// Methods
/////////////////////////////////
void applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask );
/////////////////////////////////
// Methods
/////////////////////////////////
void applyFilter( const QString &searchString, bool isoMask, bool usMask, bool otherMask );
const libglabels::Template *selectedTemplate();
const glabels::Template *selectedTemplate();
};
};
}
#endif // glabels_TemplatePicker_h
#endif // TemplatePicker_h
+19 -24
View File
@@ -25,32 +25,27 @@
#include <QHBoxLayout>
namespace glabels
///
/// Constructor
///
TemplatePickerItem::TemplatePickerItem( glabels::Template *tmplate,
QListWidget *parent )
: QListWidgetItem(parent)
{
mTmplate = tmplate;
///
/// Constructor
///
TemplatePickerItem::TemplatePickerItem( libglabels::Template *tmplate,
QListWidget *parent )
: QListWidgetItem(parent)
{
mTmplate = tmplate;
setIcon( QIcon(tmplate->preview()) );
setText( tmplate->name() );
setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
}
///
/// Template Property Getter
///
const libglabels::Template *TemplatePickerItem::tmplate() const
{
return mTmplate;
}
setIcon( QIcon(tmplate->preview()) );
setText( tmplate->name() );
setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
}
///
/// Template Property Getter
///
const glabels::Template *TemplatePickerItem::tmplate() const
{
return mTmplate;
}
+23 -27
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_TemplatePickerItem_h
#define glabels_TemplatePickerItem_h
#ifndef TemplatePickerItem_h
#define TemplatePickerItem_h
#include <QListWidget>
@@ -28,37 +28,33 @@
#include "libglabels/Template.h"
namespace glabels
///
/// Template Picker Item Widget
///
class TemplatePickerItem : public QListWidgetItem
{
///
/// Template Picker Item Widget
///
class TemplatePickerItem : public QListWidgetItem
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
TemplatePickerItem( libglabels::Template *tmplate, QListWidget *parent = 0 );
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
TemplatePickerItem( glabels::Template *tmplate, QListWidget *parent = 0 );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const libglabels::Template *tmplate() const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const glabels::Template *tmplate() const;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
libglabels::Template *mTmplate;
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
glabels::Template *mTmplate;
};
};
}
#endif // glabels_TemplatePickerItem_h
#endif // TemplatePickerItem_h
+181 -187
View File
@@ -33,212 +33,209 @@ namespace {
}
namespace glabels
///
/// Default Constructor
///
TextNode::TextNode()
: mFieldFlag(false), mData("")
{
}
///
/// Default Constructor
///
TextNode::TextNode()
: mFieldFlag(false), mData("")
///
/// Constructor from Data
///
TextNode::TextNode( bool field_flag, const QString &data )
: mFieldFlag(field_flag), mData(data)
{
}
///
/// Constructor from Parsing Next Token in Text
///
TextNode::TextNode( const QString &text, int i_start, int &i_next )
{
State state = START;
QString literal_text;
QString field_name;
bool field_flag = false;
int i = i_start;
while ( state != DONE )
{
}
QChar c = text[i];
switch (state) {
///
/// Constructor from Data
///
TextNode::TextNode( bool field_flag, const QString &data )
: mFieldFlag(field_flag), mData(data)
{
}
///
/// Constructor from Parsing Next Token in Text
///
TextNode::TextNode( const QString &text, int i_start, int &i_next )
{
State state = START;
QString literal_text;
QString field_name;
bool field_flag = false;
int i = i_start;
while ( state != DONE )
{
QChar c = text[i];
switch (state) {
case START:
switch (c.unicode()) {
case '$':
/* May be start of a field node. */
i++;
state = START_DOLLAR;
break;
case '\n':
state = DONE;
break;
case 0:
state = DONE;
break;
default:
/* Start a literal text node. */
literal_text.append( c );
i++;
state = LITERAL;
break;
}
case START:
switch (c.unicode()) {
case '$':
/* May be start of a field node. */
i++;
state = START_DOLLAR;
break;
case LITERAL:
switch (c.unicode()) {
case '$':
/* May be the beginning of a field node. */
i++;
state = LITERAL_DOLLAR;
break;
case '\n':
state = DONE;
break;
case 0:
state = DONE;
break;
default:
literal_text.append( c );
i++;
state = LITERAL;
break;
}
case '\n':
state = DONE;
break;
case LITERAL_DOLLAR:
switch (c.unicode()) {
case '{':
/* "${" indicates the start of a new field node, gather for literal too. */
literal_text.append( '$' );
i++;
state = DONE;
break;
case '\n':
/* Append "$" to literal text, don't gather newline. */
literal_text.append( '$' );
i++;
state = DONE;
break;
case 0:
/* Append "$" to literal text, don't gather null. */
literal_text.append( '$' );
i++;
state = DONE;
break;
default:
/* Append "$" to literal text, gather this character too. */
literal_text.append( '$' );
literal_text.append( c );
i+=2;
state = LITERAL;
break;
}
case 0:
state = DONE;
break;
case START_DOLLAR:
switch (c.unicode()) {
case '{':
/* This is probably the begining of a field node, gather for literal too. */
literal_text.append( c );
i++;
state = FIELD;
break;
case '\n':
state = DONE;
break;
case 0:
state = DONE;
break;
default:
/* The "$" was literal. */
literal_text.append( c );
i++;
state = LITERAL;
break;
}
default:
/* Start a literal text node. */
literal_text.append( c );
i++;
state = LITERAL;
break;
case FIELD:
switch (c.unicode()) {
case '}':
/* We now finally know that this node is really field node. */
field_flag = true;
i++;
state = DONE;
break;
case '\n':
state = DONE;
break;
case 0:
state = DONE;
break;
default:
/* Gather for field name and literal, just in case. */
field_name.append( c );
literal_text.append( c );
i++;
state = FIELD;
break;
}
break;
}
break;
case LITERAL:
switch (c.unicode()) {
case '$':
/* May be the beginning of a field node. */
i++;
state = LITERAL_DOLLAR;
break;
case '\n':
state = DONE;
break;
case 0:
state = DONE;
break;
default:
literal_text.append( c );
i++;
state = LITERAL;
break;
}
break;
case LITERAL_DOLLAR:
switch (c.unicode()) {
case '{':
/* "${" indicates the start of a new field node, gather for literal too. */
literal_text.append( '$' );
i++;
state = DONE;
break;
case '\n':
/* Append "$" to literal text, don't gather newline. */
literal_text.append( '$' );
i++;
state = DONE;
break;
case 0:
/* Append "$" to literal text, don't gather null. */
literal_text.append( '$' );
i++;
state = DONE;
break;
default:
/* Append "$" to literal text, gather this character too. */
literal_text.append( '$' );
literal_text.append( c );
i+=2;
state = LITERAL;
break;
}
break;
case START_DOLLAR:
switch (c.unicode()) {
case '{':
/* This is probably the begining of a field node, gather for literal too. */
literal_text.append( c );
i++;
state = FIELD;
break;
case '\n':
state = DONE;
break;
case 0:
state = DONE;
break;
default:
/* The "$" was literal. */
literal_text.append( c );
i++;
state = LITERAL;
break;
}
break;
case FIELD:
switch (c.unicode()) {
case '}':
/* We now finally know that this node is really field node. */
field_flag = true;
i++;
state = DONE;
break;
case '\n':
state = DONE;
break;
case 0:
state = DONE;
break;
default:
/* Gather for field name and literal, just in case. */
field_name.append( c );
literal_text.append( c );
i++;
state = FIELD;
break;
}
break;
}
mFieldFlag = field_flag;
mData = field_flag ? field_name : literal_text;
i_next = i;
}
mFieldFlag = field_flag;
mData = field_flag ? field_name : literal_text;
///
/// == Operator
///
bool TextNode::operator==( const TextNode& other )
{
return ( (mFieldFlag == other.mFieldFlag) &&
(mData == other.mData) );
}
i_next = i;
}
///
/// != Operator
///
bool TextNode::operator!=( const TextNode& other )
{
return ( (mFieldFlag != other.mFieldFlag) ||
(mData != other.mData) );
}
///
/// == Operator
///
bool TextNode::operator==( const TextNode& other )
{
return ( (mFieldFlag == other.mFieldFlag) &&
(mData == other.mData) );
}
///
/// Field Flag Property Getter
///
bool TextNode::fieldFlag( void ) const
{
return mFieldFlag;
}
///
/// != Operator
///
bool TextNode::operator!=( const TextNode& other )
{
return ( (mFieldFlag != other.mFieldFlag) ||
(mData != other.mData) );
}
///
/// Data Property Getter
///
const QString& TextNode::data( void ) const
{
return mData;
}
///
/// Field Flag Property Getter
///
bool TextNode::fieldFlag( void ) const
{
return mFieldFlag;
}
///
/// Data Property Getter
///
const QString& TextNode::data( void ) const
{
return mData;
}
#if TODO
@@ -285,6 +282,3 @@ namespace glabels
}
}
#endif
}
+44 -48
View File
@@ -18,76 +18,72 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_TextNode_h
#define glabels_TextNode_h
#ifndef TextNode_h
#define TextNode_h
#include <QString>
namespace glabels
///
/// Text Node Type
///
struct TextNode
{
///
/// Text Node Type
///
struct TextNode
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
TextNode();
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
TextNode();
TextNode( bool field_flag, const QString &data );
TextNode( bool field_flag, const QString &data );
TextNode( const QString &text, int i_start, int &i_next );
TextNode( const QString &text, int i_start, int &i_next );
/////////////////////////////////
// Operators
/////////////////////////////////
public:
bool operator==( const TextNode& other );
/////////////////////////////////
// Operators
/////////////////////////////////
public:
bool operator==( const TextNode& other );
bool operator!=( const TextNode& other );
bool operator!=( const TextNode& other );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
//
// Field Flag Property
//
bool fieldFlag( void ) const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
//
// Field Flag Property
//
bool fieldFlag( void ) const;
//
// Data Property
//
const QString& data( void ) const;
//
// Data Property
//
const QString& data( void ) const;
/////////////////////////////////
// Methods
/////////////////////////////////
/////////////////////////////////
// Methods
/////////////////////////////////
#if TODO
string expand( MergeRecord? record );
bool is_empty_field( MergeRecord? record );
string expand( MergeRecord? record );
bool is_empty_field( MergeRecord? record );
#endif
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
bool mFieldFlag;
QString mData;
bool mFieldFlag;
QString mData;
};
};
}
#endif // glabels_TextNode_h
#endif // TextNode_h
+71 -55
View File
@@ -59,7 +59,7 @@ namespace
const QColor gridLineColor( 192, 192, 192 );
const double gridLineWidthPixels = 1;
const libglabels::Distance gridSpacing = libglabels::Distance::pt(9); // TODO: determine from locale.
const glabels::Distance gridSpacing = glabels::Distance::pt(9); // TODO: determine from locale.
const QColor markupLineColor( 240, 99, 99 );
const double markupLineWidthPixels = 1;
@@ -74,7 +74,7 @@ namespace
///
/// Constructor
///
glabels::View::View( QScrollArea* scrollArea, QWidget* parent )
View::View( QScrollArea* scrollArea, QWidget* parent )
: QWidget(parent), mScrollArea(scrollArea)
{
mState = IdleState;
@@ -92,7 +92,7 @@ glabels::View::View( QScrollArea* scrollArea, QWidget* parent )
/// Zoom property
///
double
glabels::View::zoom() const
View::zoom() const
{
return mZoom;
}
@@ -102,7 +102,7 @@ glabels::View::zoom() const
/// Markup visible? property
///
bool
glabels::View::markupVisible() const
View::markupVisible() const
{
return mMarkupVisible;
}
@@ -112,7 +112,7 @@ glabels::View::markupVisible() const
/// Grid visible? property
///
bool
glabels::View::qridVisible() const
View::qridVisible() const
{
return mGridVisible;
}
@@ -122,7 +122,7 @@ glabels::View::qridVisible() const
/// Model Parameter Setter
///
void
glabels::View::setModel( LabelModel* model )
View::setModel( LabelModel* model )
{
mModel = model;
@@ -143,7 +143,7 @@ glabels::View::setModel( LabelModel* model )
/// Grid Visibility Parameter Setter
///
void
glabels::View::setGridVisible( bool visibleFlag )
View::setGridVisible( bool visibleFlag )
{
mGridVisible = visibleFlag;
update();
@@ -154,7 +154,7 @@ glabels::View::setGridVisible( bool visibleFlag )
/// Markup Visibility Parameter Setter
///
void
glabels::View::setMarkupVisible( bool visibleFlag )
View::setMarkupVisible( bool visibleFlag )
{
mMarkupVisible = visibleFlag;
update();
@@ -165,7 +165,7 @@ glabels::View::setMarkupVisible( bool visibleFlag )
/// Zoom In "One Notch"
///
void
glabels::View::zoomIn()
View::zoomIn()
{
// Find closest standard zoom level to our current zoom
// Start with 2nd largest scale
@@ -191,7 +191,7 @@ glabels::View::zoomIn()
/// Zoom Out "One Notch"
///
void
glabels::View::zoomOut()
View::zoomOut()
{
// Find closest standard zoom level to our current zoom
// Start with largest scale, end on 2nd smallest
@@ -217,7 +217,7 @@ glabels::View::zoomOut()
/// Zoom To 1:1 Scale
///
void
glabels::View::zoom1To1()
View::zoom1To1()
{
setZoomReal( 1.0, false );
}
@@ -227,7 +227,7 @@ glabels::View::zoom1To1()
/// Zoom To Fit
///
void
glabels::View::zoomToFit()
View::zoomToFit()
{
using std::min;
using std::max;
@@ -251,7 +251,7 @@ glabels::View::zoomToFit()
/// Is Zoom at Maximum?
///
bool
glabels::View::isZoomMax() const
View::isZoomMax() const
{
return ( mZoom >= zoomLevels[0] );
}
@@ -261,7 +261,7 @@ glabels::View::isZoomMax() const
/// Is Zoom at Minimum?
///
bool
glabels::View::isZoomMin() const
View::isZoomMin() const
{
return ( mZoom <= zoomLevels[nZoomLevels-1] );
}
@@ -271,7 +271,7 @@ glabels::View::isZoomMin() const
/// Set Zoom to Value
///
void
glabels::View::setZoomReal( double zoom, bool zoomToFitFlag )
View::setZoomReal( double zoom, bool zoomToFitFlag )
{
mZoom = zoom;
mZoomToFitFlag = zoomToFitFlag;
@@ -296,7 +296,7 @@ glabels::View::setZoomReal( double zoom, bool zoomToFitFlag )
/// Arrow mode (normal mode)
///
void
glabels::View::arrowMode()
View::arrowMode()
{
setCursor( Qt::ArrowCursor );
@@ -308,7 +308,7 @@ glabels::View::arrowMode()
/// Create box mode
///
void
glabels::View::createBoxMode()
View::createBoxMode()
{
setCursor( Cursors::Box() );
@@ -321,7 +321,7 @@ glabels::View::createBoxMode()
/// Resize Event Handler
///
void
glabels::View::resizeEvent( QResizeEvent *event )
View::resizeEvent( QResizeEvent *event )
{
if ( mModel )
{
@@ -345,7 +345,7 @@ glabels::View::resizeEvent( QResizeEvent *event )
/// Mouse Button Press Event Handler
///
void
glabels::View::mousePressEvent( QMouseEvent* event )
View::mousePressEvent( QMouseEvent* event )
{
if ( mModel )
{
@@ -358,8 +358,8 @@ glabels::View::mousePressEvent( QMouseEvent* event )
transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->posF() );
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
if ( event->button() & Qt::LeftButton )
@@ -511,7 +511,7 @@ glabels::View::mousePressEvent( QMouseEvent* event )
/// Mouse Movement Event Handler
///
void
glabels::View::mouseMoveEvent( QMouseEvent* event )
View::mouseMoveEvent( QMouseEvent* event )
{
using std::min;
using std::max;
@@ -527,8 +527,8 @@ glabels::View::mouseMoveEvent( QMouseEvent* event )
transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->posF() );
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
/*
@@ -615,7 +615,7 @@ glabels::View::mouseMoveEvent( QMouseEvent* event )
/// Mouse Button Release Event Handler
///
void
glabels::View::mouseReleaseEvent( QMouseEvent* event )
View::mouseReleaseEvent( QMouseEvent* event )
{
if ( mModel )
{
@@ -628,8 +628,8 @@ glabels::View::mouseReleaseEvent( QMouseEvent* event )
transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->posF() );
libglabels::Distance xWorld = libglabels::Distance::pt( pWorld.x() );
libglabels::Distance yWorld = libglabels::Distance::pt( pWorld.y() );
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
if ( event->button() & Qt::LeftButton )
@@ -691,7 +691,7 @@ glabels::View::mouseReleaseEvent( QMouseEvent* event )
/// Leave Event Handler
///
void
glabels::View::leaveEvent( QEvent* event )
View::leaveEvent( QEvent* event )
{
if ( mModel )
{
@@ -704,8 +704,8 @@ glabels::View::leaveEvent( QEvent* event )
/// Handle resize motion
///
void
glabels::View::handleResizeMotion( const libglabels::Distance& xWorld,
const libglabels::Distance& yWorld )
View::handleResizeMotion( const glabels::Distance& xWorld,
const glabels::Distance& yWorld )
{
QPointF p( xWorld.pt(), yWorld.pt() );
Handle::Location location = mResizeHandle->location();
@@ -795,22 +795,22 @@ glabels::View::handleResizeMotion( const libglabels::Distance& xWorld,
{
case Handle::E:
case Handle::W:
mResizeObject->setWHonorAspect( libglabels::Distance::pt(w) );
mResizeObject->setWHonorAspect( glabels::Distance::pt(w) );
break;
case Handle::N:
case Handle::S:
mResizeObject->setHHonorAspect( libglabels::Distance::pt(h) );
mResizeObject->setHHonorAspect( glabels::Distance::pt(h) );
break;
default:
mResizeObject->setSizeHonorAspect( libglabels::Distance::pt(w),
libglabels::Distance::pt(h) );
mResizeObject->setSizeHonorAspect( glabels::Distance::pt(w),
glabels::Distance::pt(h) );
break;
}
}
else
{
mResizeObject->setSize( libglabels::Distance::pt(w),
libglabels::Distance::pt(h) );
mResizeObject->setSize( glabels::Distance::pt(w),
glabels::Distance::pt(h) );
}
/*
@@ -836,8 +836,8 @@ glabels::View::handleResizeMotion( const libglabels::Distance& xWorld,
}
else
{
mResizeObject->setSize( libglabels::Distance::pt(w),
libglabels::Distance::pt(h) );
mResizeObject->setSize( glabels::Distance::pt(w),
glabels::Distance::pt(h) );
}
/*
@@ -846,8 +846,8 @@ glabels::View::handleResizeMotion( const libglabels::Distance& xWorld,
QPointF p0( x0, y0 );
p0 = mResizeObject->matrix().map( p0 );
p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
mResizeObject->setPosition( libglabels::Distance::pt(p0.x()),
libglabels::Distance::pt(p0.y()) );
mResizeObject->setPosition( glabels::Distance::pt(p0.x()),
glabels::Distance::pt(p0.y()) );
}
@@ -855,7 +855,7 @@ glabels::View::handleResizeMotion( const libglabels::Distance& xWorld,
/// Paint Event Handler
///
void
glabels::View::paintEvent( QPaintEvent* event )
View::paintEvent( QPaintEvent* event )
{
if ( mModel )
{
@@ -890,7 +890,7 @@ glabels::View::paintEvent( QPaintEvent* event )
/// Draw Background Layer
///
void
glabels::View::drawBgLayer( QPainter* painter )
View::drawBgLayer( QPainter* painter )
{
/*
* Draw shadow
@@ -935,15 +935,15 @@ glabels::View::drawBgLayer( QPainter* painter )
/// Draw Grid Layer
///
void
glabels::View::drawGridLayer( QPainter* painter )
View::drawGridLayer( QPainter* painter )
{
if ( mGridVisible )
{
libglabels::Distance w = mModel->frame()->w();
libglabels::Distance h = mModel->frame()->h();
glabels::Distance w = mModel->frame()->w();
glabels::Distance h = mModel->frame()->h();
libglabels::Distance x0, y0;
if ( dynamic_cast<const libglabels::FrameRect*>( mModel->frame() ) )
glabels::Distance x0, y0;
if ( dynamic_cast<const glabels::FrameRect*>( mModel->frame() ) )
{
x0 = gridSpacing;
y0 = gridSpacing;
@@ -968,12 +968,12 @@ glabels::View::drawGridLayer( QPainter* painter )
pen.setCosmetic( true );
painter->setPen( pen );
for ( libglabels::Distance x = x0; x < w; x += gridSpacing )
for ( glabels::Distance x = x0; x < w; x += gridSpacing )
{
painter->drawLine( x.pt(), 0, x.pt(), h.pt() );
}
for ( libglabels::Distance y = y0; y < h; y += gridSpacing )
for ( glabels::Distance y = y0; y < h; y += gridSpacing )
{
painter->drawLine( 0, y.pt(), w.pt(), y.pt() );
}
@@ -987,7 +987,7 @@ glabels::View::drawGridLayer( QPainter* painter )
/// Draw Markup Layer
///
void
glabels::View::drawMarkupLayer( QPainter* painter )
View::drawMarkupLayer( QPainter* painter )
{
if ( mMarkupVisible )
{
@@ -1002,7 +1002,7 @@ glabels::View::drawMarkupLayer( QPainter* painter )
painter->translate( -mModel->frame()->w().pt(), 0 );
}
foreach( libglabels::Markup* markup, mModel->frame()->markups() )
foreach( glabels::Markup* markup, mModel->frame()->markups() )
{
painter->drawPath( markup->path() );
}
@@ -1016,7 +1016,7 @@ glabels::View::drawMarkupLayer( QPainter* painter )
/// Draw Objects Layer
///
void
glabels::View::drawObjectsLayer( QPainter* painter )
View::drawObjectsLayer( QPainter* painter )
{
mModel->draw( painter );
}
@@ -1026,7 +1026,7 @@ glabels::View::drawObjectsLayer( QPainter* painter )
/// Draw Foreground Layer
///
void
glabels::View::drawFgLayer( QPainter* painter )
View::drawFgLayer( QPainter* painter )
{
/*
* Draw label outline
@@ -1053,7 +1053,7 @@ glabels::View::drawFgLayer( QPainter* painter )
/// Draw Highlight Layer
///
void
glabels::View::drawHighlightLayer( QPainter* painter )
View::drawHighlightLayer( QPainter* painter )
{
painter->save();
@@ -1073,7 +1073,7 @@ glabels::View::drawHighlightLayer( QPainter* painter )
/// Draw Select Region Layer
///
void
glabels::View::drawSelectRegionLayer( QPainter* painter )
View::drawSelectRegionLayer( QPainter* painter )
{
if ( mSelectRegionVisible )
{
@@ -1090,3 +1090,19 @@ glabels::View::drawSelectRegionLayer( QPainter* painter )
}
}
///
/// Model changed handler
///
void View::onModelChanged()
{
}
///
/// Model size changed handler
///
void View::onModelSizeChanged()
{
}
+156 -162
View File
@@ -18,8 +18,8 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_View_h
#define glabels_View_h
#ifndef View_h
#define View_h
#include <QWidget>
#include <QScrollArea>
@@ -28,190 +28,184 @@
#include "LabelRegion.h"
namespace glabels
// Forward References
class LabelModel;
class LabelModelObject;
class Handle;
///
/// View Widget
///
class View : public QWidget
{
// Forward References
class LabelModel;
class LabelModelObject;
class Handle;
Q_OBJECT
/////////////////////////////////////
// Lifecycle
/////////////////////////////////////
public:
View( QScrollArea* scrollArea, QWidget* parent = 0 );
///
/// View Widget
///
class View : public QWidget
{
Q_OBJECT
/////////////////////////////////////
// Lifecycle
/////////////////////////////////////
public:
View( QScrollArea* scrollArea, QWidget* parent = 0 );
/////////////////////////////////////
// Signals
/////////////////////////////////////
signals:
void contextMenuActivate();
void zoomChanged();
void pointerMoved( const glabels::Distance& x, const glabels::Distance& y );
void pointerExited();
void modeChanged();
/////////////////////////////////////
// Signals
/////////////////////////////////////
signals:
void contextMenuActivate();
void zoomChanged();
void pointerMoved( const libglabels::Distance& x, const libglabels::Distance& y );
void pointerExited();
void modeChanged();
/////////////////////////////////////
// Parameters
/////////////////////////////////////
public:
double zoom() const;
bool markupVisible() const;
bool qridVisible() const;
/////////////////////////////////////
// Parameters
/////////////////////////////////////
public:
double zoom() const;
bool markupVisible() const;
bool qridVisible() const;
/////////////////////////////////////
// Model
/////////////////////////////////////
public:
void setModel( LabelModel* model );
/////////////////////////////////////
// Model
/////////////////////////////////////
public:
void setModel( LabelModel* model );
/////////////////////////////////////
// Visibility operations
/////////////////////////////////////
public:
void setGridVisible( bool visibleFlag );
void setMarkupVisible( bool visibleFlag );
/////////////////////////////////////
// Visibility operations
/////////////////////////////////////
public:
void setGridVisible( bool visibleFlag );
void setMarkupVisible( bool visibleFlag );
/////////////////////////////////////
// Zoom operations
/////////////////////////////////////
public:
void zoomIn();
void zoomOut();
void zoom1To1();
void zoomToFit();
bool isZoomMax() const;
bool isZoomMin() const;
private:
void setZoomReal( double zoom, bool zoomToFitFlag );
/////////////////////////////////////
// Zoom operations
/////////////////////////////////////
public:
void zoomIn();
void zoomOut();
void zoom1To1();
void zoomToFit();
bool isZoomMax() const;
bool isZoomMin() const;
private:
void setZoomReal( double zoom, bool zoomToFitFlag );
/////////////////////////////////////
// Mode operations
/////////////////////////////////////
public:
void arrowMode();
void createBoxMode();
void createEllipseMode();
void createLineMode();
void createImageMode();
void createTextMode();
void createBarcodeMode();
/////////////////////////////////////
// Mode operations
/////////////////////////////////////
public:
void arrowMode();
void createBoxMode();
void createEllipseMode();
void createLineMode();
void createImageMode();
void createTextMode();
void createBarcodeMode();
/////////////////////////////////////
// Event handlers
/////////////////////////////////////
protected:
void resizeEvent( QResizeEvent* event );
void mousePressEvent( QMouseEvent* event );
void mouseMoveEvent( QMouseEvent* event );
void mouseReleaseEvent( QMouseEvent* event );
void leaveEvent( QEvent* event );
void paintEvent( QPaintEvent* event );
/////////////////////////////////////
// Event handlers
/////////////////////////////////////
protected:
void resizeEvent( QResizeEvent* event );
void mousePressEvent( QMouseEvent* event );
void mouseMoveEvent( QMouseEvent* event );
void mouseReleaseEvent( QMouseEvent* event );
void leaveEvent( QEvent* event );
void paintEvent( QPaintEvent* event );
/////////////////////////////////////
// Private methods
/////////////////////////////////////
private:
void handleResizeMotion( const glabels::Distance& xWorld,
const glabels::Distance& yWorld );
void drawBgLayer( QPainter* painter );
void drawGridLayer( QPainter* painter );
void drawMarkupLayer( QPainter* painter );
void drawObjectsLayer( QPainter* painter );
void drawFgLayer( QPainter* painter );
void drawHighlightLayer( QPainter* painter );
void drawSelectRegionLayer( QPainter* painter );
/////////////////////////////////////
// Private methods
/////////////////////////////////////
private:
void handleResizeMotion( const libglabels::Distance& xWorld,
const libglabels::Distance& yWorld );
void drawBgLayer( QPainter* painter );
void drawGridLayer( QPainter* painter );
void drawMarkupLayer( QPainter* painter );
void drawObjectsLayer( QPainter* painter );
void drawFgLayer( QPainter* painter );
void drawHighlightLayer( QPainter* painter );
void drawSelectRegionLayer( QPainter* painter );
/////////////////////////////////////
// Private slots
/////////////////////////////////////
private:
void onModelChanged();
void onModelSizeChanged();
/////////////////////////////////////
// Private data
/////////////////////////////////////
private:
enum State {
IdleState,
ArrowSelectRegion,
ArrowMove,
ArrowResize,
CreateIdle,
CreateDrag
};
enum CreateType {
Box,
Ellipse,
Line,
Image,
Text,
Barcode
};
QScrollArea* mScrollArea;
double mZoom;
bool mZoomToFitFlag;
double mScale;
libglabels::Distance mX0;
libglabels::Distance mY0;
bool mMarkupVisible;
bool mGridVisible;
double mGridSpacing;
LabelModel* mModel;
State mState;
/* ArrowSelectRegion state */
bool mSelectRegionVisible;
LabelRegion mSelectRegion;
/* ArrowMove state */
libglabels::Distance mMoveLastX;
libglabels::Distance mMoveLastY;
/* ArrowResize state */
LabelModelObject* mResizeObject;
Handle* mResizeHandle;
bool mResizeHonorAspect;
/* CreateDrag state */
CreateType mCreateObjectType;
LabelModelObject* mCreateObject;
libglabels::Distance mCreateX0;
libglabels::Distance mCreateY0;
/////////////////////////////////////
// Private slots
/////////////////////////////////////
private slots:
void onModelChanged();
void onModelSizeChanged();
/////////////////////////////////////
// Private data
/////////////////////////////////////
private:
enum State {
IdleState,
ArrowSelectRegion,
ArrowMove,
ArrowResize,
CreateIdle,
CreateDrag
};
enum CreateType {
Box,
Ellipse,
Line,
Image,
Text,
Barcode
};
}
QScrollArea* mScrollArea;
double mZoom;
bool mZoomToFitFlag;
double mScale;
glabels::Distance mX0;
glabels::Distance mY0;
bool mMarkupVisible;
bool mGridVisible;
double mGridSpacing;
LabelModel* mModel;
State mState;
/* ArrowSelectRegion state */
bool mSelectRegionVisible;
LabelRegion mSelectRegion;
/* ArrowMove state */
glabels::Distance mMoveLastX;
glabels::Distance mMoveLastY;
/* ArrowResize state */
LabelModelObject* mResizeObject;
Handle* mResizeHandle;
bool mResizeHonorAspect;
/* CreateDrag state */
CreateType mCreateObjectType;
LabelModelObject* mCreateObject;
glabels::Distance mCreateX0;
glabels::Distance mCreateY0;
};
#endif // glabels_View_h
#endif // View_h
+41 -41
View File
@@ -36,7 +36,7 @@
void
glabels::XmlLabelCreator::writeFile( const LabelModel* label, const QString& fileName )
XmlLabelCreator::writeFile( const LabelModel* label, const QString& fileName )
{
QDomDocument doc;
@@ -56,7 +56,7 @@ glabels::XmlLabelCreator::writeFile( const LabelModel* label, const QString& fil
void
glabels::XmlLabelCreator::writeBuffer( const LabelModel* label, QString& buffer )
XmlLabelCreator::writeBuffer( const LabelModel* label, QString& buffer )
{
QDomDocument doc;
@@ -66,7 +66,7 @@ glabels::XmlLabelCreator::writeBuffer( const LabelModel* label, QString& buffer
void
glabels::XmlLabelCreator::createDoc( QDomDocument& doc, const LabelModel* label )
XmlLabelCreator::createDoc( QDomDocument& doc, const LabelModel* label )
{
QDomNode xmlNode( doc.createProcessingInstruction( "xml", "version=\"1.0\"" ) );
doc.appendChild( xmlNode );
@@ -74,7 +74,7 @@ glabels::XmlLabelCreator::createDoc( QDomDocument& doc, const LabelModel* label
QDomElement root = doc.createElement( "Glabels-document" );
doc.appendChild( root );
libglabels::XmlTemplateCreator().createTemplateNode( root, label->tmplate() );
glabels::XmlTemplateCreator().createTemplateNode( root, label->tmplate() );
createObjectsNode( root, label );
@@ -85,14 +85,14 @@ glabels::XmlLabelCreator::createDoc( QDomDocument& doc, const LabelModel* label
void
glabels::XmlLabelCreator::createObjectsNode( QDomElement &parent, const LabelModel* label )
XmlLabelCreator::createObjectsNode( QDomElement &parent, const LabelModel* label )
{
QDomDocument doc = parent.ownerDocument();
QDomElement node = doc.createElement( "Objects" );
parent.appendChild( node );
libglabels::XmlUtil::setStringAttr( node, "id", "0" );
libglabels::XmlUtil::setBoolAttr( node, "rotate", label->rotate() );
glabels::XmlUtil::setStringAttr( node, "id", "0" );
glabels::XmlUtil::setBoolAttr( node, "rotate", label->rotate() );
foreach ( LabelModelObject* object, label->objectList() )
{
@@ -110,39 +110,39 @@ glabels::XmlLabelCreator::createObjectsNode( QDomElement &parent, const LabelMod
void
glabels::XmlLabelCreator::createObjectBoxNode( QDomElement &parent, const LabelModelBoxObject* object )
XmlLabelCreator::createObjectBoxNode( QDomElement &parent, const LabelModelBoxObject* object )
{
QDomDocument doc = parent.ownerDocument();
QDomElement node = doc.createElement( "Object-box" );
parent.appendChild( node );
/* position attrs */
libglabels::XmlUtil::setLengthAttr( node, "x", object->x0() );
libglabels::XmlUtil::setLengthAttr( node, "y", object->y0() );
glabels::XmlUtil::setLengthAttr( node, "x", object->x0() );
glabels::XmlUtil::setLengthAttr( node, "y", object->y0() );
/* size attrs */
libglabels::XmlUtil::setLengthAttr( node, "w", object->w() );
libglabels::XmlUtil::setLengthAttr( node, "h", object->h() );
glabels::XmlUtil::setLengthAttr( node, "w", object->w() );
glabels::XmlUtil::setLengthAttr( node, "h", object->h() );
/* line attrs */
libglabels::XmlUtil::setLengthAttr( node, "line_width", object->lineWidth() );
glabels::XmlUtil::setLengthAttr( node, "line_width", object->lineWidth() );
if ( object->lineColorNode().fieldFlag() )
{
libglabels::XmlUtil::setStringAttr( node, "line_color_field", object->lineColorNode().key() );
glabels::XmlUtil::setStringAttr( node, "line_color_field", object->lineColorNode().key() );
}
else
{
libglabels::XmlUtil::setUIntAttr( node, "line_color", object->lineColorNode().rgba() );
glabels::XmlUtil::setUIntAttr( node, "line_color", object->lineColorNode().rgba() );
}
/* fill attrs */
if ( object->fillColorNode().fieldFlag() )
{
libglabels::XmlUtil::setStringAttr( node, "fill_color_field", object->fillColorNode().key() );
glabels::XmlUtil::setStringAttr( node, "fill_color_field", object->fillColorNode().key() );
}
else
{
libglabels::XmlUtil::setUIntAttr( node, "fill_color", object->fillColorNode().rgba() );
glabels::XmlUtil::setUIntAttr( node, "fill_color", object->fillColorNode().rgba() );
}
/* affine attrs */
@@ -154,108 +154,108 @@ glabels::XmlLabelCreator::createObjectBoxNode( QDomElement &parent, const LabelM
void
glabels::XmlLabelCreator::createObjectEllipseNode( QDomElement &parent, const LabelModelEllipseObject* object )
XmlLabelCreator::createObjectEllipseNode( QDomElement &parent, const LabelModelEllipseObject* object )
{
// TODO
}
void
glabels::XmlLabelCreator::createObjectLineNode( QDomElement &parent, const LabelModelLineObject* object )
XmlLabelCreator::createObjectLineNode( QDomElement &parent, const LabelModelLineObject* object )
{
// TODO
}
void
glabels::XmlLabelCreator::createObjectImageNode( QDomElement &parent, const LabelModelImageObject* object )
XmlLabelCreator::createObjectImageNode( QDomElement &parent, const LabelModelImageObject* object )
{
// TODO
}
void
glabels::XmlLabelCreator::createObjectBarcodeNode( QDomElement &parent, const LabelModelBarcodeObject* object )
XmlLabelCreator::createObjectBarcodeNode( QDomElement &parent, const LabelModelBarcodeObject* object )
{
// TODO
}
void
glabels::XmlLabelCreator::createObjectTextNode( QDomElement &parent, const LabelModelTextObject* object )
XmlLabelCreator::createObjectTextNode( QDomElement &parent, const LabelModelTextObject* object )
{
// TODO
}
void
glabels::XmlLabelCreator::createObjectTopLevelSpanNode( QDomElement &parent, const LabelModelTextObject* object )
XmlLabelCreator::createObjectTopLevelSpanNode( QDomElement &parent, const LabelModelTextObject* object )
{
// TODO
}
void
glabels::XmlLabelCreator::createAffineAttrs( QDomElement &node, const LabelModelObject* object )
XmlLabelCreator::createAffineAttrs( QDomElement &node, const LabelModelObject* object )
{
QMatrix a = object->matrix();
libglabels::XmlUtil::setDoubleAttr( node, "a0", a.m11() );
libglabels::XmlUtil::setDoubleAttr( node, "a1", a.m12() );
libglabels::XmlUtil::setDoubleAttr( node, "a2", a.m21() );
libglabels::XmlUtil::setDoubleAttr( node, "a3", a.m22() );
libglabels::XmlUtil::setDoubleAttr( node, "a4", a.dx() );
libglabels::XmlUtil::setDoubleAttr( node, "a5", a.dy() );
glabels::XmlUtil::setDoubleAttr( node, "a0", a.m11() );
glabels::XmlUtil::setDoubleAttr( node, "a1", a.m12() );
glabels::XmlUtil::setDoubleAttr( node, "a2", a.m21() );
glabels::XmlUtil::setDoubleAttr( node, "a3", a.m22() );
glabels::XmlUtil::setDoubleAttr( node, "a4", a.dx() );
glabels::XmlUtil::setDoubleAttr( node, "a5", a.dy() );
}
void
glabels::XmlLabelCreator::createShadowAttrs( QDomElement &node, const LabelModelObject* object )
XmlLabelCreator::createShadowAttrs( QDomElement &node, const LabelModelObject* object )
{
if ( object->shadow() )
{
libglabels::XmlUtil::setBoolAttr( node, "shadow", object->shadow() );
glabels::XmlUtil::setBoolAttr( node, "shadow", object->shadow() );
libglabels::XmlUtil::setLengthAttr( node, "shadow_x", object->shadowX() );
libglabels::XmlUtil::setLengthAttr( node, "shadow_y", object->shadowY() );
glabels::XmlUtil::setLengthAttr( node, "shadow_x", object->shadowX() );
glabels::XmlUtil::setLengthAttr( node, "shadow_y", object->shadowY() );
if ( object->fillColorNode().fieldFlag() )
{
libglabels::XmlUtil::setStringAttr( node, "shadow_color_field", object->shadowColorNode().key() );
glabels::XmlUtil::setStringAttr( node, "shadow_color_field", object->shadowColorNode().key() );
}
else
{
libglabels::XmlUtil::setUIntAttr( node, "shadow_color", object->shadowColorNode().rgba() );
glabels::XmlUtil::setUIntAttr( node, "shadow_color", object->shadowColorNode().rgba() );
}
libglabels::XmlUtil::setDoubleAttr( node, "shadow_opacity", object->shadowOpacity() );
glabels::XmlUtil::setDoubleAttr( node, "shadow_opacity", object->shadowOpacity() );
}
}
void
glabels::XmlLabelCreator::createMergeNode( QDomElement &parent, const LabelModel* label )
XmlLabelCreator::createMergeNode( QDomElement &parent, const LabelModel* label )
{
// TODO
}
void
glabels::XmlLabelCreator::createDataNode( QDomElement &parent, const LabelModel* label )
XmlLabelCreator::createDataNode( QDomElement &parent, const LabelModel* label )
{
// TODO
}
void
glabels::XmlLabelCreator::createPixdataNode( QDomElement &parent, const LabelModel* label, const QString& name )
XmlLabelCreator::createPixdataNode( QDomElement &parent, const LabelModel* label, const QString& name )
{
// TODO
}
void
glabels::XmlLabelCreator::createSvgFileNode( QDomElement &parent, const LabelModel* label, const QString& name )
XmlLabelCreator::createSvgFileNode( QDomElement &parent, const LabelModel* label, const QString& name )
{
// TODO
}
+42 -45
View File
@@ -18,57 +18,54 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_XmlLabelCreator_h
#define glabels_XmlLabelCreator_h
#ifndef XmlLabelCreator_h
#define XmlLabelCreator_h
#include <QObject>
#include <QDomElement>
namespace glabels
class LabelModel;
class LabelModelObject;
class LabelModelBoxObject;
class LabelModelEllipseObject;
class LabelModelLineObject;
class LabelModelImageObject;
class LabelModelBarcodeObject;
class LabelModelTextObject;
///
/// XmlLabelCreator
///
class XmlLabelCreator : public QObject
{
class LabelModel;
class LabelModelObject;
class LabelModelBoxObject;
class LabelModelEllipseObject;
class LabelModelLineObject;
class LabelModelImageObject;
class LabelModelBarcodeObject;
class LabelModelTextObject;
Q_OBJECT
public:
static void writeFile( const LabelModel* label, const QString& fileName );
static void writeBuffer( const LabelModel* label, QString& buffer );
private:
static void createDoc( QDomDocument& doc, const LabelModel* label );
static void createRootNode( const LabelModel* label );
static void createObjectsNode( QDomElement &parent, const LabelModel* label );
static void createObjectBoxNode( QDomElement &parent, const LabelModelBoxObject* object );
static void createObjectEllipseNode( QDomElement &parent, const LabelModelEllipseObject* object );
static void createObjectLineNode( QDomElement &parent, const LabelModelLineObject* object );
static void createObjectImageNode( QDomElement &parent, const LabelModelImageObject* object );
static void createObjectBarcodeNode( QDomElement &parent, const LabelModelBarcodeObject* object );
static void createObjectTextNode( QDomElement &parent, const LabelModelTextObject* object );
static void createObjectTopLevelSpanNode( QDomElement &parent, const LabelModelTextObject* object );
static void createAffineAttrs( QDomElement &node, const LabelModelObject* object );
static void createShadowAttrs( QDomElement &node, const LabelModelObject* object );
static void createMergeNode( QDomElement &parent, const LabelModel* label );
static void createDataNode( QDomElement &parent, const LabelModel* label );
static void createPixdataNode( QDomElement &parent, const LabelModel* label, const QString& name );
static void createSvgFileNode( QDomElement &parent, const LabelModel* label, const QString& name );
};
///
/// XmlLabelCreator
///
class XmlLabelCreator : public QObject
{
Q_OBJECT
public:
static void writeFile( const LabelModel* label, const QString& fileName );
static void writeBuffer( const LabelModel* label, QString& buffer );
private:
static void createDoc( QDomDocument& doc, const LabelModel* label );
static void createRootNode( const LabelModel* label );
static void createObjectsNode( QDomElement &parent, const LabelModel* label );
static void createObjectBoxNode( QDomElement &parent, const LabelModelBoxObject* object );
static void createObjectEllipseNode( QDomElement &parent, const LabelModelEllipseObject* object );
static void createObjectLineNode( QDomElement &parent, const LabelModelLineObject* object );
static void createObjectImageNode( QDomElement &parent, const LabelModelImageObject* object );
static void createObjectBarcodeNode( QDomElement &parent, const LabelModelBarcodeObject* object );
static void createObjectTextNode( QDomElement &parent, const LabelModelTextObject* object );
static void createObjectTopLevelSpanNode( QDomElement &parent, const LabelModelTextObject* object );
static void createAffineAttrs( QDomElement &node, const LabelModelObject* object );
static void createShadowAttrs( QDomElement &node, const LabelModelObject* object );
static void createMergeNode( QDomElement &parent, const LabelModel* label );
static void createDataNode( QDomElement &parent, const LabelModel* label );
static void createPixdataNode( QDomElement &parent, const LabelModel* label, const QString& name );
static void createSvgFileNode( QDomElement &parent, const LabelModel* label, const QString& name );
};
}
#endif // glabels_XmlLabelCreator_h
#endif // XmlLabelCreator_h
+25 -25
View File
@@ -36,8 +36,8 @@
#include <QtDebug>
glabels::LabelModel*
glabels::XmlLabelParser::readFile( const QString& fileName )
LabelModel*
XmlLabelParser::readFile( const QString& fileName )
{
QFile file( fileName );
@@ -88,8 +88,8 @@ glabels::XmlLabelParser::readFile( const QString& fileName )
}
glabels::LabelModel*
glabels::XmlLabelParser::readBuffer( const QString& buffer )
LabelModel*
XmlLabelParser::readBuffer( const QString& buffer )
{
QDomDocument doc;
QString errorString;
@@ -116,7 +116,7 @@ glabels::XmlLabelParser::readBuffer( const QString& buffer )
void
glabels::XmlLabelParser::gunzip( const QByteArray& data, QByteArray& result )
XmlLabelParser::gunzip( const QByteArray& data, QByteArray& result )
{
result.clear();
@@ -165,10 +165,10 @@ glabels::XmlLabelParser::gunzip( const QByteArray& data, QByteArray& result )
}
glabels::LabelModel*
glabels::XmlLabelParser::parseRootNode( const QDomElement &node )
LabelModel*
XmlLabelParser::parseRootNode( const QDomElement &node )
{
using namespace libglabels;
using namespace glabels;
LabelModel* label = new LabelModel();
@@ -220,7 +220,7 @@ glabels::XmlLabelParser::parseRootNode( const QDomElement &node )
void
glabels::XmlLabelParser::parseObjectsNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseObjectsNode( const QDomElement &node, LabelModel* label )
{
for ( QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling() )
{
@@ -259,9 +259,9 @@ glabels::XmlLabelParser::parseObjectsNode( const QDomElement &node, LabelModel*
void
glabels::XmlLabelParser::parseObjectBoxNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseObjectBoxNode( const QDomElement &node, LabelModel* label )
{
using namespace libglabels;
using namespace glabels;
LabelModelBoxObject* object = new LabelModelBoxObject();
label->addObject( object );
@@ -303,45 +303,45 @@ glabels::XmlLabelParser::parseObjectBoxNode( const QDomElement &node, LabelModel
void
glabels::XmlLabelParser::parseObjectEllipseNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseObjectEllipseNode( const QDomElement &node, LabelModel* label )
{
}
void
glabels::XmlLabelParser::parseObjectLineNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseObjectLineNode( const QDomElement &node, LabelModel* label )
{
}
void
glabels::XmlLabelParser::parseObjectImageNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseObjectImageNode( const QDomElement &node, LabelModel* label )
{
}
void
glabels::XmlLabelParser::parseObjectBarcodeNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseObjectBarcodeNode( const QDomElement &node, LabelModel* label )
{
}
void
glabels::XmlLabelParser::parseObjectTextNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseObjectTextNode( const QDomElement &node, LabelModel* label )
{
}
void
glabels::XmlLabelParser::parseTopLevelSpanNode( const QDomElement &node, LabelModelTextObject* object )
XmlLabelParser::parseTopLevelSpanNode( const QDomElement &node, LabelModelTextObject* object )
{
}
void
glabels::XmlLabelParser::parseAffineAttrs( const QDomElement &node, LabelModelObject* object )
XmlLabelParser::parseAffineAttrs( const QDomElement &node, LabelModelObject* object )
{
using namespace libglabels;
using namespace glabels;
double a[6];
@@ -357,9 +357,9 @@ glabels::XmlLabelParser::parseAffineAttrs( const QDomElement &node, LabelModelOb
void
glabels::XmlLabelParser::parseShadowAttrs( const QDomElement &node, LabelModelObject* object )
XmlLabelParser::parseShadowAttrs( const QDomElement &node, LabelModelObject* object )
{
using namespace libglabels;
using namespace glabels;
object->setShadow( XmlUtil::getBoolAttr( node, "shadow", false ) );
@@ -380,25 +380,25 @@ glabels::XmlLabelParser::parseShadowAttrs( const QDomElement &node, LabelModelOb
void
glabels::XmlLabelParser::parseMergeNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseMergeNode( const QDomElement &node, LabelModel* label )
{
}
void
glabels::XmlLabelParser::parseDataNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseDataNode( const QDomElement &node, LabelModel* label )
{
}
void
glabels::XmlLabelParser::parsePixdataNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parsePixdataNode( const QDomElement &node, LabelModel* label )
{
}
void
glabels::XmlLabelParser::parseFileNode( const QDomElement &node, LabelModel* label )
XmlLabelParser::parseFileNode( const QDomElement &node, LabelModel* label )
{
}
+42 -45
View File
@@ -18,57 +18,54 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_XmlLabelParser_h
#define glabels_XmlLabelParser_h
#ifndef XmlLabelParser_h
#define XmlLabelParser_h
#include <QObject>
#include <QDomElement>
namespace glabels
class LabelModel;
class LabelModelObject;
class LabelModelBoxObject;
class LabelModelEllipseObject;
class LabelModelLineObject;
class LabelModelImageObject;
class LabelModelBarcodeObject;
class LabelModelTextObject;
///
/// XmlLabelParser
///
class XmlLabelParser : public QObject
{
class LabelModel;
class LabelModelObject;
class LabelModelBoxObject;
class LabelModelEllipseObject;
class LabelModelLineObject;
class LabelModelImageObject;
class LabelModelBarcodeObject;
class LabelModelTextObject;
Q_OBJECT
public:
static LabelModel* readFile( const QString& fileName );
static LabelModel* readBuffer( const QString& buffer );
private:
static void gunzip( const QByteArray& gzippedData, QByteArray& data );
static LabelModel* parseRootNode( const QDomElement &node );
static void parseObjectsNode( const QDomElement &node, LabelModel* label );
static void parseObjectBoxNode( const QDomElement &node, LabelModel* label );
static void parseObjectEllipseNode( const QDomElement &node, LabelModel* label );
static void parseObjectLineNode( const QDomElement &node, LabelModel* label );
static void parseObjectImageNode( const QDomElement &node, LabelModel* label );
static void parseObjectBarcodeNode( const QDomElement &node, LabelModel* label );
static void parseObjectTextNode( const QDomElement &node, LabelModel* label );
static void parseTopLevelSpanNode( const QDomElement &node, LabelModelTextObject* object );
static void parseAffineAttrs( const QDomElement &node, LabelModelObject* object );
static void parseShadowAttrs( const QDomElement &node, LabelModelObject* object );
static void parseMergeNode( const QDomElement &node, LabelModel* label );
static void parseDataNode( const QDomElement &node, LabelModel* label );
static void parsePixdataNode( const QDomElement &node, LabelModel* label );
static void parseFileNode( const QDomElement &node, LabelModel* label );
};
///
/// XmlLabelParser
///
class XmlLabelParser : public QObject
{
Q_OBJECT
public:
static LabelModel* readFile( const QString& fileName );
static LabelModel* readBuffer( const QString& buffer );
private:
static void gunzip( const QByteArray& gzippedData, QByteArray& data );
static LabelModel* parseRootNode( const QDomElement &node );
static void parseObjectsNode( const QDomElement &node, LabelModel* label );
static void parseObjectBoxNode( const QDomElement &node, LabelModel* label );
static void parseObjectEllipseNode( const QDomElement &node, LabelModel* label );
static void parseObjectLineNode( const QDomElement &node, LabelModel* label );
static void parseObjectImageNode( const QDomElement &node, LabelModel* label );
static void parseObjectBarcodeNode( const QDomElement &node, LabelModel* label );
static void parseObjectTextNode( const QDomElement &node, LabelModel* label );
static void parseTopLevelSpanNode( const QDomElement &node, LabelModelTextObject* object );
static void parseAffineAttrs( const QDomElement &node, LabelModelObject* object );
static void parseShadowAttrs( const QDomElement &node, LabelModelObject* object );
static void parseMergeNode( const QDomElement &node, LabelModel* label );
static void parseDataNode( const QDomElement &node, LabelModel* label );
static void parsePixdataNode( const QDomElement &node, LabelModel* label );
static void parseFileNode( const QDomElement &node, LabelModel* label );
};
}
#endif // glabels_XmlLabelParser_h
#endif // XmlLabelParser_h
+5 -8
View File
@@ -24,9 +24,6 @@
#include "File.h"
#include "libglabels/Db.h"
using namespace glabels;
using namespace libglabels;
int main( int argc, char **argv )
{
@@ -36,13 +33,13 @@ int main( int argc, char **argv )
QCoreApplication::setOrganizationDomain( "glabels.org" );
QCoreApplication::setApplicationName( "glabels-qt" );
Db::init();
glabels::Db::init();
////// TEMPORARY TESTING ////////
#if 0
Db::printKnownPapers();
Db::printKnownCategories();
Db::printKnownVendors();
Db::printKnownTemplates();
glabels::Db::printKnownPapers();
glabels::Db::printKnownCategories();
glabels::Db::printKnownVendors();
glabels::Db::printKnownTemplates();
#endif
/////////////////////////////////
+10 -10
View File
@@ -372,7 +372,7 @@
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<widget class="glabels::ColorButton" name="textColorButton">
<widget class="ColorButton" name="textColorButton">
<property name="text">
<string/>
</property>
@@ -451,7 +451,7 @@
</spacer>
</item>
<item>
<widget class="glabels::FieldButton" name="textInsertFieldButton">
<widget class="FieldButton" name="textInsertFieldButton">
<property name="text">
<string/>
</property>
@@ -539,7 +539,7 @@
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_22">
<item>
<widget class="glabels::ColorButton" name="barcodeColorButton">
<widget class="ColorButton" name="barcodeColorButton">
<property name="text">
<string/>
</property>
@@ -679,7 +679,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="glabels::FieldButton" name="barcodeFieldButton">
<widget class="FieldButton" name="barcodeFieldButton">
<property name="text">
<string/>
</property>
@@ -802,7 +802,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="glabels::FieldButton" name="imageFieldButton">
<widget class="FieldButton" name="imageFieldButton">
<property name="text">
<string/>
</property>
@@ -889,7 +889,7 @@
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="glabels::ColorButton" name="lineColorButton">
<widget class="ColorButton" name="lineColorButton">
<property name="text">
<string/>
</property>
@@ -950,7 +950,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="glabels::ColorButton" name="fillColorButton">
<widget class="ColorButton" name="fillColorButton">
<property name="text">
<string/>
</property>
@@ -1373,7 +1373,7 @@
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_24">
<item>
<widget class="glabels::ColorButton" name="shadowColorButton">
<widget class="ColorButton" name="shadowColorButton">
<property name="text">
<string/>
</property>
@@ -1433,7 +1433,7 @@
</widget>
<customwidgets>
<customwidget>
<class>glabels::ColorButton</class>
<class>ColorButton</class>
<extends>QPushButton</extends>
<header>ColorButton.h</header>
<slots>
@@ -1441,7 +1441,7 @@
</slots>
</customwidget>
<customwidget>
<class>glabels::FieldButton</class>
<class>FieldButton</class>
<extends>QPushButton</extends>
<header>FieldButton.h</header>
<slots>
+2 -2
View File
@@ -26,7 +26,7 @@
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="glabels::Preview" name="preview" native="true">
<widget class="Preview" name="preview" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@@ -453,7 +453,7 @@
</widget>
<customwidgets>
<customwidget>
<class>glabels::Preview</class>
<class>Preview</class>
<extends>QWidget</extends>
<header>Preview.h</header>
<container>1</container>
+2 -2
View File
@@ -29,7 +29,7 @@
<item row="0" column="4">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="glabels::SimplePreview" name="preview">
<widget class="SimplePreview" name="preview">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -356,7 +356,7 @@
</widget>
<customwidgets>
<customwidget>
<class>glabels::SimplePreview</class>
<class>SimplePreview</class>
<extends>QGraphicsView</extends>
<header>SimplePreview.h</header>
<container>1</container>
+2 -2
View File
@@ -134,7 +134,7 @@
</layout>
</item>
<item>
<widget class="glabels::TemplatePicker" name="templatePicker">
<widget class="TemplatePicker" name="templatePicker">
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
@@ -182,7 +182,7 @@
</widget>
<customwidgets>
<customwidget>
<class>glabels::TemplatePicker</class>
<class>TemplatePicker</class>
<extends>QListWidget</extends>
<header>TemplatePicker.h</header>
</customwidget>
+2 -2
View File
@@ -1,6 +1,6 @@
/* Category.cpp
*
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
@@ -21,7 +21,7 @@
#include "Category.h"
namespace libglabels
namespace glabels
{
Category::Category( const QString &id, const QString &name )
+5 -5
View File
@@ -1,6 +1,6 @@
/* Category.h
*
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
@@ -18,14 +18,14 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef libglabels_Category_h
#define libglabels_Category_h
#ifndef glabels_Category_h
#define glabels_Category_h
#include <QString>
namespace libglabels
namespace glabels
{
class Category
@@ -50,4 +50,4 @@ namespace libglabels
#include "Category.inl"
#endif // libglabels_Category_h
#endif // glabels_Category_h
+2 -2
View File
@@ -1,6 +1,6 @@
/* Category.inl
*
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
@@ -19,7 +19,7 @@
*/
namespace libglabels
namespace glabels
{
inline const QString& Category::id() const
+5 -5
View File
@@ -1,6 +1,6 @@
/* Config.h
*
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
@@ -18,11 +18,11 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef libglabels_Config_h
#define libglabels_Config_h
#ifndef glabels_Config_h
#define glabels_Config_h
namespace libglabels
namespace glabels
{
namespace Config
@@ -33,4 +33,4 @@ namespace libglabels
}
#endif // libglabels_Config_h
#endif // glabels_Config_h
+4 -4
View File
@@ -18,11 +18,11 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef libglabels_Constants_h
#define libglabels_Constants_h
#ifndef glabels_Constants_h
#define glabels_Constants_h
namespace libglabels
namespace glabels
{
const double PTS_PER_PT = 1.0;
@@ -33,4 +33,4 @@ namespace libglabels
}
#endif // libglabels_Constants_h
#endif // glabels_Constants_h

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