Reconcile style accross all source files.
- All glabels code is in "glabels" top-level namespace. - Other assorted cleanup.
This commit is contained in:
+38
-1
@@ -57,7 +57,38 @@ information.
|
||||
- Never use parens in return statements when not necessary.
|
||||
|
||||
|
||||
File Organization
|
||||
Naming
|
||||
------
|
||||
|
||||
### Type Names
|
||||
|
||||
- Start with a capital letter.
|
||||
- Each new word is capitalized.
|
||||
- No underscores.
|
||||
|
||||
|
||||
### Variable Names
|
||||
|
||||
- Start each variable name with a lowercase letter.
|
||||
- Each subsequent word is capitalized.
|
||||
- No underscores.
|
||||
- Data members start with a lowercase "m" with the 2nd letter capitalized.
|
||||
- Use "i" prefix for indexes and "n" prefix for total number of indexes.
|
||||
|
||||
|
||||
### Function names
|
||||
|
||||
- Start each function name with a lowercase letter.
|
||||
- Each subsequent word is capitalized.
|
||||
- No underscores.
|
||||
|
||||
|
||||
### Constant Names
|
||||
|
||||
- TBD (currently not uniform)
|
||||
|
||||
|
||||
Code Organization
|
||||
-----------------
|
||||
|
||||
Generally code is organized into modules. Usually a module defines a single
|
||||
@@ -87,6 +118,7 @@ All header files should have an ifndef guard to prevent multiple inclusion.
|
||||
#endif // ns_Module_h
|
||||
```
|
||||
|
||||
|
||||
### Include Directives
|
||||
|
||||
Header files should be included in the following order.
|
||||
@@ -111,3 +143,8 @@ glabels header files.
|
||||
Do not use forward declarations to any external entities. Use the appropriate
|
||||
include directives instead.
|
||||
|
||||
|
||||
### Namespaces
|
||||
|
||||
- Private definitions are placed in unnamed namespaces to limit scope to the current translation unit.
|
||||
- All other glabels code is placed in the top-level "glabels" namespace.
|
||||
|
||||
+22
-17
@@ -28,12 +28,15 @@
|
||||
#include "Version.h"
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
AboutDialog::AboutDialog( QWidget *parent )
|
||||
: QDialog(parent)
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
AboutDialog::AboutDialog( QWidget *parent )
|
||||
: QDialog(parent)
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
QString version = tr("Version") + " " + Version::STRING;
|
||||
@@ -62,22 +65,24 @@ AboutDialog::AboutDialog( QWidget *parent )
|
||||
"<p align='left'>" + licenseParagraph2 + "</p>";
|
||||
|
||||
aboutLabel->setText( markup );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// "License" Button Clicked Slot
|
||||
///
|
||||
void AboutDialog::onLicenseButtonClicked()
|
||||
{
|
||||
///
|
||||
/// "License" Button Clicked Slot
|
||||
///
|
||||
void AboutDialog::onLicenseButtonClicked()
|
||||
{
|
||||
QDesktopServices::openUrl( QUrl("http://www.gnu.org/licenses/gpl-3.0.txt") );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// "Website" Button Clicked Slot
|
||||
///
|
||||
void AboutDialog::onWebsiteButtonClicked()
|
||||
{
|
||||
///
|
||||
/// "Website" Button Clicked Slot
|
||||
///
|
||||
void AboutDialog::onWebsiteButtonClicked()
|
||||
{
|
||||
QDesktopServices::openUrl( QUrl(Version::WEBSITE) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-7
@@ -25,29 +25,34 @@
|
||||
#include "ui_AboutDialog.h"
|
||||
|
||||
|
||||
///
|
||||
/// About Dialog Widget
|
||||
///
|
||||
class AboutDialog : public QDialog, public Ui_AboutDialog
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// About Dialog Widget
|
||||
///
|
||||
class AboutDialog : public QDialog, public Ui_AboutDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
AboutDialog( QWidget *parent = 0 );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onLicenseButtonClicked();
|
||||
void onWebsiteButtonClicked();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // AboutDialog_h
|
||||
|
||||
+43
-39
@@ -21,23 +21,24 @@
|
||||
#include "BarcodeBackends.h"
|
||||
|
||||
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
const std::string default_id = "code39";
|
||||
}
|
||||
|
||||
BarcodeBackends::BackendMap BarcodeBackends::mBackendIdMap;
|
||||
BarcodeBackends::BackendMap BarcodeBackends::mBackendNameMap;
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
BarcodeBackends::BackendMap BarcodeBackends::mBackendIdMap;
|
||||
BarcodeBackends::BackendMap BarcodeBackends::mBackendNameMap;
|
||||
|
||||
BarcodeBackends::StyleMap BarcodeBackends::mStyleIdMap;
|
||||
BarcodeBackends::StyleMap BarcodeBackends::mStyleNameMap;
|
||||
BarcodeBackends::StyleMap BarcodeBackends::mStyleIdMap;
|
||||
BarcodeBackends::StyleMap BarcodeBackends::mStyleNameMap;
|
||||
|
||||
QList<QString> BarcodeBackends::mBackendNameList;
|
||||
QList<QString> BarcodeBackends::mNameList;
|
||||
QList<QString> BarcodeBackends::mBackendNameList;
|
||||
QList<QString> BarcodeBackends::mNameList;
|
||||
|
||||
|
||||
BarcodeBackends::BarcodeBackends()
|
||||
{
|
||||
BarcodeBackends::BarcodeBackends()
|
||||
{
|
||||
registerStyle( "postnet", "", tr("POSTNET (any)"),
|
||||
false, false, true, false, "12345-6789-12", false, 11 );
|
||||
|
||||
@@ -73,22 +74,22 @@ BarcodeBackends::BarcodeBackends()
|
||||
|
||||
registerStyle( "qrcode", "", tr("QRCode"),
|
||||
false, false, true, false, "1234567890AB", false, 12 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BarcodeBackends::init( void )
|
||||
{
|
||||
void BarcodeBackends::init( void )
|
||||
{
|
||||
static BarcodeBackends* singletonInstance = NULL;
|
||||
|
||||
if ( singletonInstance == NULL )
|
||||
{
|
||||
singletonInstance = new BarcodeBackends();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString BarcodeBackends::BackendIdToName( const QString& backendId )
|
||||
{
|
||||
QString BarcodeBackends::BackendIdToName( const QString& backendId )
|
||||
{
|
||||
BackendMap::iterator i = mBackendIdMap.find( backendId );
|
||||
if ( i != mBackendIdMap.end() )
|
||||
{
|
||||
@@ -96,11 +97,11 @@ QString BarcodeBackends::BackendIdToName( const QString& backendId )
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString BarcodeBackends::BackendNameToId( const QString& backendName )
|
||||
{
|
||||
QString BarcodeBackends::BackendNameToId( const QString& backendName )
|
||||
{
|
||||
BackendMap::iterator i = mBackendNameMap.find( backendName );
|
||||
if ( i != mBackendNameMap.end() )
|
||||
{
|
||||
@@ -108,23 +109,23 @@ QString BarcodeBackends::BackendNameToId( const QString& backendName )
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const QList<QString>& BarcodeBackends::getBackendNameList()
|
||||
{
|
||||
const QList<QString>& BarcodeBackends::getBackendNameList()
|
||||
{
|
||||
return mBackendNameList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const QList<QString>& BarcodeBackends::getNameList()
|
||||
{
|
||||
const QList<QString>& BarcodeBackends::getNameList()
|
||||
{
|
||||
return mNameList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
|
||||
{
|
||||
const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
|
||||
{
|
||||
StyleMap::iterator i = mStyleIdMap.find( id );
|
||||
if ( i != mStyleIdMap.end() )
|
||||
{
|
||||
@@ -132,11 +133,11 @@ const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
|
||||
{
|
||||
const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
|
||||
{
|
||||
StyleMap::iterator i = mStyleNameMap.find( name );
|
||||
if ( i != mStyleNameMap.end() )
|
||||
{
|
||||
@@ -144,18 +145,18 @@ const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BarcodeBackends::registerBackend( QString& id, QString& name)
|
||||
{
|
||||
void BarcodeBackends::registerBackend( QString& id, QString& name)
|
||||
{
|
||||
mBackendNameList.append( name );
|
||||
mBackendIdMap.insert( id, name );
|
||||
mBackendNameMap.insert( name, id );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BarcodeBackends::registerStyle( const char* id,
|
||||
void BarcodeBackends::registerStyle( const char* id,
|
||||
const char* backendId,
|
||||
const QString& name,
|
||||
bool canText,
|
||||
@@ -165,15 +166,18 @@ void BarcodeBackends::registerStyle( const char* id,
|
||||
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(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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,25 +30,28 @@
|
||||
#include "BarcodeStyle.h"
|
||||
|
||||
|
||||
///
|
||||
/// Barcode Backends Database
|
||||
///
|
||||
class BarcodeBackends : public QObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Barcode Backends Database
|
||||
///
|
||||
class BarcodeBackends : public QObject
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
BarcodeBackends();
|
||||
|
||||
public:
|
||||
public:
|
||||
static void init( void );
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
static QString BackendIdToName( const QString& backendId );
|
||||
static QString BackendNameToId( const QString& backendName );
|
||||
|
||||
@@ -62,7 +65,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Private Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
static void registerBackend( QString &id, QString &name);
|
||||
|
||||
static void registerStyle( const char* id,
|
||||
@@ -91,7 +94,9 @@ private:
|
||||
static QList<QString> mBackendNameList;
|
||||
static QList<QString> mNameList;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // BarcodeBackends_h
|
||||
|
||||
+21
-16
@@ -25,11 +25,14 @@
|
||||
#include "BarcodeMenuItem.h"
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
BarcodeMenu::BarcodeMenu()
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
BarcodeMenu::BarcodeMenu()
|
||||
{
|
||||
foreach ( QString name, BarcodeBackends::getNameList() )
|
||||
{
|
||||
const BarcodeStyle* bcStyle = BarcodeBackends::lookupStyleFromName( name );
|
||||
@@ -39,24 +42,26 @@ BarcodeMenu::BarcodeMenu()
|
||||
|
||||
addAction( bcMenuItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// bcStyle getter
|
||||
///
|
||||
const BarcodeStyle* BarcodeMenu::bcStyle() const
|
||||
{
|
||||
///
|
||||
/// bcStyle getter
|
||||
///
|
||||
const BarcodeStyle* BarcodeMenu::bcStyle() const
|
||||
{
|
||||
return mBcStyle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// onMenuItemActivated slot
|
||||
///
|
||||
void BarcodeMenu::onMenuItemActivated( BarcodeStyle *bcStyle )
|
||||
{
|
||||
///
|
||||
/// onMenuItemActivated slot
|
||||
///
|
||||
void BarcodeMenu::onMenuItemActivated( BarcodeStyle *bcStyle )
|
||||
{
|
||||
mBcStyle = bcStyle;
|
||||
|
||||
emit styleChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-10
@@ -27,48 +27,53 @@
|
||||
#include "BarcodeStyle.h"
|
||||
|
||||
|
||||
///
|
||||
/// Barcode Menu
|
||||
///
|
||||
class BarcodeMenu : public QMenu
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Barcode Menu
|
||||
///
|
||||
class BarcodeMenu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
BarcodeMenu();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void styleChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
const BarcodeStyle* bcStyle() const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onMenuItemActivated( BarcodeStyle *bcStyle );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
BarcodeStyle* mBcStyle;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // BarcodeMenu_h
|
||||
|
||||
@@ -25,12 +25,15 @@
|
||||
#include "BarcodeMenuItem.h"
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
||||
: QPushButton(parent)
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
||||
: QPushButton(parent)
|
||||
{
|
||||
mMenu = new BarcodeMenu();
|
||||
setMenu( mMenu );
|
||||
|
||||
@@ -38,25 +41,27 @@ BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
||||
setText( mBcStyle->name() );
|
||||
|
||||
connect( mMenu, SIGNAL(styleChanged()), this, SLOT(onMenuStyleChanged()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// bcStyle getter
|
||||
///
|
||||
const BarcodeStyle* BarcodeMenuButton::bcStyle() const
|
||||
{
|
||||
///
|
||||
/// bcStyle getter
|
||||
///
|
||||
const BarcodeStyle* BarcodeMenuButton::bcStyle() const
|
||||
{
|
||||
return mBcStyle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// onMenuStyleChanged slot
|
||||
///
|
||||
void BarcodeMenuButton::onMenuStyleChanged()
|
||||
{
|
||||
///
|
||||
/// onMenuStyleChanged slot
|
||||
///
|
||||
void BarcodeMenuButton::onMenuStyleChanged()
|
||||
{
|
||||
mBcStyle = mMenu->bcStyle();
|
||||
setText( mBcStyle->name() );
|
||||
|
||||
emit styleChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-10
@@ -28,49 +28,54 @@
|
||||
#include "BarcodeStyle.h"
|
||||
|
||||
|
||||
///
|
||||
/// Barcode Menu Button
|
||||
///
|
||||
class BarcodeMenuButton : public QPushButton
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Barcode Menu Button
|
||||
///
|
||||
class BarcodeMenuButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
BarcodeMenuButton( QWidget* parent = 0 );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void styleChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
const BarcodeStyle* bcStyle() const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onMenuStyleChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
BarcodeMenu* mMenu;
|
||||
const BarcodeStyle* mBcStyle;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // BarcodeMenuButton_h
|
||||
|
||||
+22
-17
@@ -21,31 +21,36 @@
|
||||
#include "BarcodeMenuItem.h"
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent )
|
||||
: QAction(parent), mBcStyle(bcStyle)
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// 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
|
||||
{
|
||||
///
|
||||
/// bcStyle Property Getter
|
||||
///
|
||||
const BarcodeStyle* BarcodeMenuItem::bcStyle() const
|
||||
{
|
||||
return mBcStyle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// onTriggered slot
|
||||
///
|
||||
void BarcodeMenuItem::onTriggered()
|
||||
{
|
||||
///
|
||||
/// onTriggered slot
|
||||
///
|
||||
void BarcodeMenuItem::onTriggered()
|
||||
{
|
||||
emit activated( mBcStyle );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-10
@@ -27,48 +27,53 @@
|
||||
#include "BarcodeStyle.h"
|
||||
|
||||
|
||||
///
|
||||
/// Barcode Menu Item
|
||||
///
|
||||
class BarcodeMenuItem : public QAction
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Barcode Menu Item
|
||||
///
|
||||
class BarcodeMenuItem : public QAction
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent = 0 );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void activated( const BarcodeStyle* bcStyle );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
const BarcodeStyle* bcStyle() const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onTriggered();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
const BarcodeStyle* mBcStyle;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // BarcodeMenuItem_h
|
||||
|
||||
+84
-77
@@ -21,10 +21,13 @@
|
||||
#include "BarcodeStyle.h"
|
||||
|
||||
|
||||
///
|
||||
/// Default Constructor
|
||||
///
|
||||
BarcodeStyle::BarcodeStyle ()
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Default Constructor
|
||||
///
|
||||
BarcodeStyle::BarcodeStyle ()
|
||||
: mId( "" ),
|
||||
mBackendId( "" ),
|
||||
mName( "" ),
|
||||
@@ -35,14 +38,15 @@ BarcodeStyle::BarcodeStyle ()
|
||||
mDefaultDigits( "" ),
|
||||
mCanFreeform( false ),
|
||||
mPreferedN( 0 )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
BarcodeStyle::BarcodeStyle ( const QString& id,
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
BarcodeStyle::BarcodeStyle ( const QString& id,
|
||||
const QString& backendId,
|
||||
const QString& name,
|
||||
bool canText,
|
||||
@@ -62,105 +66,106 @@ BarcodeStyle::BarcodeStyle ( const QString& id,
|
||||
mDefaultDigits( defaultDigits ),
|
||||
mCanFreeform( canFreeform ),
|
||||
mPreferedN( preferedN )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// ID Property Getter
|
||||
///
|
||||
const QString& BarcodeStyle::id() const
|
||||
{
|
||||
///
|
||||
/// ID Property Getter
|
||||
///
|
||||
const QString& BarcodeStyle::id() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Backend ID Property Getter
|
||||
///
|
||||
const QString& BarcodeStyle::backendId() const
|
||||
{
|
||||
///
|
||||
/// Backend ID Property Getter
|
||||
///
|
||||
const QString& BarcodeStyle::backendId() const
|
||||
{
|
||||
return mBackendId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Name Property Getter
|
||||
///
|
||||
const QString& BarcodeStyle::name() const
|
||||
{
|
||||
///
|
||||
/// Name Property Getter
|
||||
///
|
||||
const QString& BarcodeStyle::name() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Can Text Property Getter
|
||||
///
|
||||
bool BarcodeStyle::canText() const
|
||||
{
|
||||
///
|
||||
/// Can Text Property Getter
|
||||
///
|
||||
bool BarcodeStyle::canText() const
|
||||
{
|
||||
return mCanText;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Text Optional Property Getter
|
||||
///
|
||||
bool BarcodeStyle::textOptional() const
|
||||
{
|
||||
///
|
||||
/// Text Optional Property Getter
|
||||
///
|
||||
bool BarcodeStyle::textOptional() const
|
||||
{
|
||||
return mTextOptional;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Can Checksum Property Getter
|
||||
///
|
||||
bool BarcodeStyle::canChecksum() const
|
||||
{
|
||||
///
|
||||
/// Can Checksum Property Getter
|
||||
///
|
||||
bool BarcodeStyle::canChecksum() const
|
||||
{
|
||||
return mCanChecksum;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Checksum Optional Property Getter
|
||||
///
|
||||
bool BarcodeStyle::checksumOptional() const
|
||||
{
|
||||
///
|
||||
/// Checksum Optional Property Getter
|
||||
///
|
||||
bool BarcodeStyle::checksumOptional() const
|
||||
{
|
||||
return mChecksumOptional;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Default Digits Property Getter
|
||||
///
|
||||
const QString& BarcodeStyle::defaultDigits() const
|
||||
{
|
||||
///
|
||||
/// Default Digits Property Getter
|
||||
///
|
||||
const QString& BarcodeStyle::defaultDigits() const
|
||||
{
|
||||
return mDefaultDigits;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Can Freeform Property Getter
|
||||
///
|
||||
bool BarcodeStyle::canFreeform() const
|
||||
{
|
||||
///
|
||||
/// Can Freeform Property Getter
|
||||
///
|
||||
bool BarcodeStyle::canFreeform() const
|
||||
{
|
||||
return mCanFreeform;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Prefered N Property Getter
|
||||
///
|
||||
int BarcodeStyle::preferedN() const
|
||||
{
|
||||
///
|
||||
/// Prefered N Property Getter
|
||||
///
|
||||
int BarcodeStyle::preferedN() const
|
||||
{
|
||||
return mPreferedN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Generate Example Digits
|
||||
///
|
||||
QString BarcodeStyle::exampleDigits( int n ) const
|
||||
{
|
||||
///
|
||||
/// Generate Example Digits
|
||||
///
|
||||
QString BarcodeStyle::exampleDigits( int n ) const
|
||||
{
|
||||
if ( mCanFreeform )
|
||||
{
|
||||
return QString( qMax( n, 1 ), QChar('0') );
|
||||
@@ -169,4 +174,6 @@ QString BarcodeStyle::exampleDigits( int n ) const
|
||||
{
|
||||
return mDefaultDigits;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-8
@@ -24,16 +24,19 @@
|
||||
#include <QString>
|
||||
|
||||
|
||||
///
|
||||
/// Barcode Style Type
|
||||
///
|
||||
struct BarcodeStyle
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Barcode Style Type
|
||||
///
|
||||
struct BarcodeStyle
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
BarcodeStyle ();
|
||||
|
||||
BarcodeStyle ( const QString& id,
|
||||
@@ -75,14 +78,14 @@ public:
|
||||
/////////////////////////////////
|
||||
// Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
QString exampleDigits( int n ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QString mId;
|
||||
QString mBackendId;
|
||||
QString mName;
|
||||
@@ -94,7 +97,9 @@ private:
|
||||
bool mCanFreeform;
|
||||
int mPreferedN;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // BarcodeStyle_h
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace glabels
|
||||
Category::Category( const QString &id, const QString &name )
|
||||
: mId(id), mName(name)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
|
||||
+48
-37
@@ -28,21 +28,30 @@
|
||||
#include "ColorSwatch.h"
|
||||
|
||||
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const int SWATCH_W = 64;
|
||||
const int SWATCH_H = 24;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ColorButton::ColorButton( QWidget* parent )
|
||||
ColorButton::ColorButton( QWidget* parent )
|
||||
: QPushButton( parent )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color )
|
||||
{
|
||||
void ColorButton::init( const QString& defaultLabel,
|
||||
const QColor& defaultColor,
|
||||
const QColor& color )
|
||||
{
|
||||
mDefaultColor = defaultColor;
|
||||
mColorNode = ColorNode( color );
|
||||
|
||||
@@ -60,11 +69,11 @@ void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor,
|
||||
this, SLOT(onPaletteDialogChanged(ColorNode,bool)) );
|
||||
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
|
||||
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::setColorNode( ColorNode colorNode )
|
||||
{
|
||||
void ColorButton::setColorNode( ColorNode colorNode )
|
||||
{
|
||||
mIsDefault = false;
|
||||
|
||||
mColorNode = colorNode;
|
||||
@@ -81,11 +90,11 @@ void ColorButton::setColorNode( ColorNode colorNode )
|
||||
}
|
||||
|
||||
mDialog->setColorNode( colorNode );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::setColor( QColor color )
|
||||
{
|
||||
void ColorButton::setColor( QColor color )
|
||||
{
|
||||
mIsDefault = false;
|
||||
|
||||
mColorNode.setField( false );
|
||||
@@ -94,11 +103,11 @@ void ColorButton::setColor( QColor color )
|
||||
|
||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
||||
setText( "" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::setToDefault()
|
||||
{
|
||||
void ColorButton::setToDefault()
|
||||
{
|
||||
mIsDefault = true;
|
||||
|
||||
mColorNode.setField( false );
|
||||
@@ -107,29 +116,29 @@ void ColorButton::setToDefault()
|
||||
|
||||
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
|
||||
setText( "" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ColorNode ColorButton::colorNode()
|
||||
{
|
||||
ColorNode ColorButton::colorNode()
|
||||
{
|
||||
return mColorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::setKeys( const QList<QString> keyList )
|
||||
{
|
||||
void ColorButton::setKeys( const QList<QString> keyList )
|
||||
{
|
||||
mDialog->setKeys( keyList );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::clearKeys()
|
||||
{
|
||||
void ColorButton::clearKeys()
|
||||
{
|
||||
mDialog->clearKeys();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::onButtonToggled( bool checked )
|
||||
{
|
||||
void ColorButton::onButtonToggled( bool checked )
|
||||
{
|
||||
if ( checked )
|
||||
{
|
||||
///
|
||||
@@ -140,23 +149,23 @@ void ColorButton::onButtonToggled( bool checked )
|
||||
|
||||
mDialog->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::onPaletteDialogAccepted()
|
||||
{
|
||||
void ColorButton::onPaletteDialogAccepted()
|
||||
{
|
||||
setChecked( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::onPaletteDialogRejected()
|
||||
{
|
||||
void ColorButton::onPaletteDialogRejected()
|
||||
{
|
||||
setChecked( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
||||
{
|
||||
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
||||
{
|
||||
mColorNode = colorNode;
|
||||
mIsDefault = isDefault;
|
||||
|
||||
@@ -172,4 +181,6 @@ void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
||||
}
|
||||
|
||||
emit colorChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-11
@@ -28,32 +28,35 @@
|
||||
#include "ColorPaletteDialog.h"
|
||||
|
||||
|
||||
///
|
||||
/// Color Button
|
||||
///
|
||||
class ColorButton : public QPushButton
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Color Button
|
||||
///
|
||||
class ColorButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
ColorButton( QWidget* parent = 0 );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void colorChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color );
|
||||
void setColorNode( ColorNode colorNode );
|
||||
void setColor( QColor color );
|
||||
@@ -66,7 +69,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onButtonToggled( bool checked );
|
||||
void onPaletteDialogAccepted();
|
||||
void onPaletteDialogRejected();
|
||||
@@ -76,19 +79,21 @@ private slots:
|
||||
/////////////////////////////////
|
||||
// Private Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Members
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QColor mDefaultColor;
|
||||
bool mIsDefault;
|
||||
ColorNode mColorNode;
|
||||
|
||||
ColorPaletteDialog* mDialog;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // ColorButton_h
|
||||
|
||||
+22
-16
@@ -25,13 +25,17 @@
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
ColorHistory::ColorHistory()
|
||||
namespace glabels
|
||||
{
|
||||
}
|
||||
|
||||
ColorHistory::ColorHistory()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
ColorHistory* ColorHistory::instance()
|
||||
{
|
||||
ColorHistory* ColorHistory::instance()
|
||||
{
|
||||
static ColorHistory* singletonInstance = 0;
|
||||
|
||||
if ( singletonInstance == 0 )
|
||||
@@ -40,11 +44,11 @@ ColorHistory* ColorHistory::instance()
|
||||
}
|
||||
|
||||
return singletonInstance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorHistory::addColor( const QColor &color )
|
||||
{
|
||||
void ColorHistory::addColor( const QColor &color )
|
||||
{
|
||||
QList<QColor> colorList = readColorList();
|
||||
|
||||
// Remove any occurances of this color already in list
|
||||
@@ -62,17 +66,17 @@ void ColorHistory::addColor( const QColor &color )
|
||||
writeColorList( colorList );
|
||||
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QList<QColor> ColorHistory::getColors()
|
||||
{
|
||||
QList<QColor> ColorHistory::getColors()
|
||||
{
|
||||
return readColorList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QList<QColor> ColorHistory::readColorList()
|
||||
{
|
||||
QList<QColor> ColorHistory::readColorList()
|
||||
{
|
||||
QStringList defaultList;
|
||||
QSettings settings;
|
||||
|
||||
@@ -93,11 +97,11 @@ QList<QColor> ColorHistory::readColorList()
|
||||
}
|
||||
|
||||
return colorList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
||||
{
|
||||
void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
||||
{
|
||||
// Build name list
|
||||
QStringList colorNameList;
|
||||
foreach ( QColor color, colorList )
|
||||
@@ -110,4 +114,6 @@ void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
||||
settings.beginGroup( "ColorHistory" );
|
||||
settings.setValue( "colors", colorNameList );
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
-12
@@ -26,37 +26,40 @@
|
||||
#include <QObject>
|
||||
|
||||
|
||||
///
|
||||
/// Color History
|
||||
///
|
||||
class ColorHistory : public QObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Color History
|
||||
///
|
||||
class ColorHistory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int MAX_COLORS = 9;
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
ColorHistory();
|
||||
|
||||
public:
|
||||
public:
|
||||
static ColorHistory* instance();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void addColor( const QColor &color );
|
||||
QList<QColor> getColors();
|
||||
|
||||
@@ -64,7 +67,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Private Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QList<QColor> readColorList();
|
||||
void writeColorList( const QList<QColor>& colorList );
|
||||
|
||||
@@ -72,9 +75,11 @@ private:
|
||||
/////////////////////////////////
|
||||
// Private Members
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // ColorHistory_h
|
||||
|
||||
+98
-89
@@ -24,136 +24,143 @@
|
||||
#include "Merge/Record.h"
|
||||
|
||||
|
||||
///
|
||||
/// Default Constructor
|
||||
///
|
||||
ColorNode::ColorNode()
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Default Constructor
|
||||
///
|
||||
ColorNode::ColorNode()
|
||||
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
ColorNode::ColorNode( bool isField, const QColor& color, const QString& key )
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
ColorNode::ColorNode( bool isField, const QColor& color, const QString& key )
|
||||
: mIsField(isField), mColor(color), mKey(key)
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
ColorNode::ColorNode( bool isField, uint32_t rgba, const QString& key )
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
ColorNode::ColorNode( bool isField, uint32_t rgba, const QString& key )
|
||||
: mIsField(isField), mKey(key)
|
||||
{
|
||||
{
|
||||
mColor = QColor( (rgba >> 24) & 0xFF,
|
||||
(rgba >> 16) & 0xFF,
|
||||
(rgba >> 8) & 0xFF,
|
||||
(rgba ) & 0xFF );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Color
|
||||
///
|
||||
ColorNode::ColorNode( const QColor& color )
|
||||
///
|
||||
/// Constructor From Color
|
||||
///
|
||||
ColorNode::ColorNode( const QColor& color )
|
||||
: mIsField(false), mColor(color), mKey("")
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Key
|
||||
///
|
||||
ColorNode::ColorNode( const QString& key )
|
||||
///
|
||||
/// Constructor From Key
|
||||
///
|
||||
ColorNode::ColorNode( const QString& key )
|
||||
: mIsField(true), mColor(QColor::fromRgba(0x00000000)), mKey(key)
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// == Operator
|
||||
///
|
||||
bool ColorNode::operator==( const ColorNode& cn )
|
||||
{
|
||||
///
|
||||
/// == Operator
|
||||
///
|
||||
bool ColorNode::operator==( const ColorNode& cn )
|
||||
{
|
||||
return (mIsField == cn.mIsField) &&
|
||||
(mColor == cn.mColor) &&
|
||||
(mKey == cn.mKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// != Operator
|
||||
///
|
||||
bool ColorNode::operator!=( const ColorNode& cn )
|
||||
{
|
||||
///
|
||||
/// != Operator
|
||||
///
|
||||
bool ColorNode::operator!=( const ColorNode& cn )
|
||||
{
|
||||
return (mIsField != cn.mIsField) ||
|
||||
(mColor != cn.mColor) ||
|
||||
(mKey != cn.mKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Field Flag Property Getter
|
||||
///
|
||||
bool ColorNode::isField() const
|
||||
{
|
||||
///
|
||||
/// Field Flag Property Getter
|
||||
///
|
||||
bool ColorNode::isField() const
|
||||
{
|
||||
return mIsField;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Field Flag Property Setter
|
||||
///
|
||||
void ColorNode::setField( bool isField )
|
||||
{
|
||||
///
|
||||
/// Field Flag Property Setter
|
||||
///
|
||||
void ColorNode::setField( bool isField )
|
||||
{
|
||||
mIsField = isField;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Color Property Getter
|
||||
///
|
||||
const QColor& ColorNode::color() const
|
||||
{
|
||||
///
|
||||
/// Color Property Getter
|
||||
///
|
||||
const QColor& ColorNode::color() const
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Color Property Setter
|
||||
///
|
||||
void ColorNode::setColor( const QColor& color )
|
||||
{
|
||||
///
|
||||
/// Color Property Setter
|
||||
///
|
||||
void ColorNode::setColor( const QColor& color )
|
||||
{
|
||||
mColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Key Property Getter
|
||||
///
|
||||
const QString& ColorNode::key() const
|
||||
{
|
||||
///
|
||||
/// Key Property Getter
|
||||
///
|
||||
const QString& ColorNode::key() const
|
||||
{
|
||||
return mKey;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Key Property Setter
|
||||
///
|
||||
void ColorNode::setKey( const QString& key )
|
||||
{
|
||||
///
|
||||
/// Key Property Setter
|
||||
///
|
||||
void ColorNode::setKey( const QString& key )
|
||||
{
|
||||
mKey = key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get color encoded as an RGBA 32-bit number
|
||||
///
|
||||
uint32_t ColorNode::rgba() const
|
||||
{
|
||||
///
|
||||
/// Get color encoded as an RGBA 32-bit number
|
||||
///
|
||||
uint32_t ColorNode::rgba() const
|
||||
{
|
||||
uint32_t c =
|
||||
mColor.red() << 24 |
|
||||
mColor.green() << 16 |
|
||||
@@ -161,14 +168,14 @@ uint32_t ColorNode::rgba() const
|
||||
mColor.alpha();
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get color, expand if necessary
|
||||
///
|
||||
QColor ColorNode::color( merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Get color, expand if necessary
|
||||
///
|
||||
QColor ColorNode::color( merge::Record* record ) const
|
||||
{
|
||||
if ( mIsField )
|
||||
{
|
||||
if ( record == 0 )
|
||||
@@ -191,4 +198,6 @@ QColor ColorNode::color( merge::Record* record ) const
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-10
@@ -30,16 +30,19 @@
|
||||
#include "Merge/Record.h"
|
||||
|
||||
|
||||
///
|
||||
/// Color Node Type
|
||||
///
|
||||
struct ColorNode
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Color Node Type
|
||||
///
|
||||
struct ColorNode
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
ColorNode();
|
||||
|
||||
ColorNode( bool isField, const QColor& color, const QString& key );
|
||||
@@ -54,7 +57,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Operators
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
bool operator==( const ColorNode& cn );
|
||||
|
||||
bool operator!=( const ColorNode& cn );
|
||||
@@ -63,7 +66,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Field Flag Property
|
||||
//
|
||||
@@ -88,7 +91,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Misc. Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
uint32_t rgba() const;
|
||||
QColor color( merge::Record* record ) const;
|
||||
|
||||
@@ -96,12 +99,14 @@ public:
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
bool mIsField;
|
||||
QColor mColor;
|
||||
QString mKey;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // ColorNode_h
|
||||
|
||||
@@ -25,33 +25,36 @@
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
//
|
||||
// Private Configuration Data
|
||||
//
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const int border = 4;
|
||||
const int hBox = 25;
|
||||
const int outlineWidthPixels = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
|
||||
///
|
||||
/// 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 )
|
||||
{
|
||||
///
|
||||
/// Paint Event
|
||||
///
|
||||
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
//
|
||||
@@ -88,33 +91,35 @@ void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
||||
QRect textRect( border, border, width()-2*border, hBox );
|
||||
|
||||
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Enter Event
|
||||
///
|
||||
void ColorPaletteButtonItem::enterEvent( QEvent* event )
|
||||
{
|
||||
///
|
||||
/// Enter Event
|
||||
///
|
||||
void ColorPaletteButtonItem::enterEvent( QEvent* event )
|
||||
{
|
||||
mHover = true;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Leave Event
|
||||
///
|
||||
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
|
||||
{
|
||||
///
|
||||
/// Leave Event
|
||||
///
|
||||
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
|
||||
{
|
||||
mHover = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Mouse Press Event
|
||||
///
|
||||
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
///
|
||||
/// Mouse Press Event
|
||||
///
|
||||
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
emit activated();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,31 +26,34 @@
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
///
|
||||
/// Color Palette Item
|
||||
///
|
||||
class ColorPaletteButtonItem : public QWidget
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Color Palette Item
|
||||
///
|
||||
class ColorPaletteButtonItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
ColorPaletteButtonItem( const QString& text, QWidget* parent = 0 );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void activated();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Event handlers
|
||||
/////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
void paintEvent( QPaintEvent* event );
|
||||
void enterEvent( QEvent* event );
|
||||
void leaveEvent( QEvent* event );
|
||||
@@ -60,11 +63,13 @@ protected:
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QString mText;
|
||||
|
||||
bool mHover;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // ColorPaletteButtonItem_h
|
||||
|
||||
@@ -30,7 +30,13 @@
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
||||
|
||||
{ "#ef2929", tr("Light Scarlet Red", "Color name") },
|
||||
{ "#fcaf3e", tr("Light Orange", "Color name") },
|
||||
@@ -71,15 +77,16 @@ ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
||||
{ "#eeeeec", tr("Lighter Gray", "Color name") },
|
||||
{ "#f3f3f3", tr("Very Light Gray", "Color name") },
|
||||
{ "#ffffff", tr("White", "Color name") }
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
||||
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()) );
|
||||
|
||||
@@ -168,17 +175,17 @@ ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
||||
setLayout( vLayout );
|
||||
|
||||
loadCustomColorHistory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::setColorNode( const ColorNode& colorNode )
|
||||
{
|
||||
void ColorPaletteDialog::setColorNode( const ColorNode& colorNode )
|
||||
{
|
||||
mColorNode = colorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
||||
{
|
||||
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
||||
{
|
||||
mKeys = keyList;
|
||||
|
||||
// Clear old keys, (all entries, except item 0)
|
||||
@@ -197,55 +204,55 @@ void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
||||
{
|
||||
mMergeFieldCombo->setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::clearKeys()
|
||||
{
|
||||
void ColorPaletteDialog::clearKeys()
|
||||
{
|
||||
|
||||
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
||||
{
|
||||
mMergeFieldCombo->removeItem( index );
|
||||
}
|
||||
mMergeFieldCombo->setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::onDefaultItemActivated()
|
||||
{
|
||||
void ColorPaletteDialog::onDefaultItemActivated()
|
||||
{
|
||||
mColorNode.setField( false );
|
||||
mColorNode.setColor( mDefaultColor );
|
||||
mColorNode.setKey( "" );
|
||||
|
||||
emit colorChanged( mColorNode, true );
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
||||
{
|
||||
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
||||
{
|
||||
mColorNode.setField( false );
|
||||
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
||||
mColorNode.setKey( "" );
|
||||
|
||||
emit colorChanged( mColorNode, false );
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
||||
{
|
||||
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
||||
{
|
||||
mColorNode.setField( false );
|
||||
mColorNode.setColor( mColorHistory->getColors()[id] );
|
||||
mColorNode.setKey( "" );
|
||||
|
||||
emit colorChanged( mColorNode, false );
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::onCustomColorItemActivated()
|
||||
{
|
||||
void ColorPaletteDialog::onCustomColorItemActivated()
|
||||
{
|
||||
QColorDialog dlg( mColorNode.color(), this );
|
||||
dlg.setWindowTitle( tr("Custom Color") );
|
||||
|
||||
@@ -267,17 +274,17 @@ void ColorPaletteDialog::onCustomColorItemActivated()
|
||||
accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::onColorHistoryChanged()
|
||||
{
|
||||
void ColorPaletteDialog::onColorHistoryChanged()
|
||||
{
|
||||
loadCustomColorHistory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::loadCustomColorHistory()
|
||||
{
|
||||
void ColorPaletteDialog::loadCustomColorHistory()
|
||||
{
|
||||
QList<QColor> colorList = mColorHistory->getColors();
|
||||
|
||||
int id = 0;
|
||||
@@ -293,11 +300,11 @@ void ColorPaletteDialog::loadCustomColorHistory()
|
||||
mHistoryItem[id]->setEnabled( false );
|
||||
id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::onComboIndexChanged( int index )
|
||||
{
|
||||
void ColorPaletteDialog::onComboIndexChanged( int index )
|
||||
{
|
||||
if ( index != 0 )
|
||||
{
|
||||
mColorNode.setField( true );
|
||||
@@ -307,12 +314,14 @@ void ColorPaletteDialog::onComboIndexChanged( int index )
|
||||
emit colorChanged( mColorNode, false );
|
||||
accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::showEvent( QShowEvent* event )
|
||||
{
|
||||
void ColorPaletteDialog::showEvent( QShowEvent* event )
|
||||
{
|
||||
mMergeFieldCombo->setCurrentIndex( 0 );
|
||||
|
||||
QDialog::showEvent( event );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,18 +31,21 @@
|
||||
#include "ColorPaletteButtonItem.h"
|
||||
|
||||
|
||||
///
|
||||
/// Color Palette Dialog
|
||||
///
|
||||
class ColorPaletteDialog : public QDialog
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Color Palette Dialog
|
||||
///
|
||||
class ColorPaletteDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
ColorPaletteDialog( const QString& defaultLabel,
|
||||
const QColor& defaultColor,
|
||||
const QColor& color,
|
||||
@@ -52,14 +55,14 @@ public:
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void colorChanged( ColorNode colorNode, bool isDefault );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void setColorNode( const ColorNode& colorNode );
|
||||
void setKeys( const QStringList& keyList );
|
||||
void clearKeys();
|
||||
@@ -68,7 +71,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onDefaultItemActivated();
|
||||
void onPaletteItemActivated( int id );
|
||||
void onHistoryItemActivated( int id );
|
||||
@@ -76,21 +79,21 @@ private slots:
|
||||
void onColorHistoryChanged();
|
||||
void onComboIndexChanged( int index );
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void showEvent( QShowEvent* event );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
void loadCustomColorHistory();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Members
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QColor mDefaultColor;
|
||||
ColorNode mColorNode;
|
||||
|
||||
@@ -110,7 +113,9 @@ private:
|
||||
QComboBox* mMergeFieldCombo;
|
||||
QStringList mKeys;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // ColorPaletteDialog_h
|
||||
|
||||
@@ -25,11 +25,14 @@
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
//
|
||||
// Private Configuration Data
|
||||
//
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const int border = 4;
|
||||
const int wSwatch = 25;
|
||||
const int hSwatch = 25;
|
||||
@@ -37,45 +40,45 @@ namespace
|
||||
const int hoverBgOutlineWidthPixels = 1;
|
||||
|
||||
const int outlineWidthPixels = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
ColorPaletteItem::ColorPaletteItem( int id,
|
||||
///
|
||||
/// 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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Color Property Setter
|
||||
///
|
||||
void ColorPaletteItem::setColor( int id,
|
||||
///
|
||||
/// 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 )
|
||||
{
|
||||
///
|
||||
/// Paint Event
|
||||
///
|
||||
void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
//
|
||||
@@ -112,33 +115,35 @@ void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
||||
painter.drawRect( border, border, wSwatch, hSwatch );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Enter Event
|
||||
///
|
||||
void ColorPaletteItem::enterEvent( QEvent* event )
|
||||
{
|
||||
///
|
||||
/// Enter Event
|
||||
///
|
||||
void ColorPaletteItem::enterEvent( QEvent* event )
|
||||
{
|
||||
mHover = true;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Leave Event
|
||||
///
|
||||
void ColorPaletteItem::leaveEvent( QEvent* event )
|
||||
{
|
||||
///
|
||||
/// Leave Event
|
||||
///
|
||||
void ColorPaletteItem::leaveEvent( QEvent* event )
|
||||
{
|
||||
mHover = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Mouse Press Event
|
||||
///
|
||||
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
///
|
||||
/// Mouse Press Event
|
||||
///
|
||||
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
emit activated( mId );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-10
@@ -26,17 +26,20 @@
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
///
|
||||
/// Color Palette Item
|
||||
///
|
||||
class ColorPaletteItem : public QWidget
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Color Palette Item
|
||||
///
|
||||
class ColorPaletteItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
ColorPaletteItem( int id,
|
||||
const QColor& color,
|
||||
const QString& tip,
|
||||
@@ -46,14 +49,14 @@ public:
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void activated( int id );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void setColor( int id,
|
||||
const QColor& color,
|
||||
const QString& tip );
|
||||
@@ -62,7 +65,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Event handlers
|
||||
/////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
void paintEvent( QPaintEvent* event );
|
||||
void enterEvent( QEvent* event );
|
||||
void leaveEvent( QEvent* event );
|
||||
@@ -72,13 +75,15 @@ protected:
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
int mId;
|
||||
QColor mColor;
|
||||
QString mTip;
|
||||
|
||||
bool mHover;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // ColorPaletteItem_h
|
||||
|
||||
+15
-10
@@ -24,22 +24,25 @@
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
//
|
||||
// Private Configuration Data
|
||||
//
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const QColor outlineColor( 0, 0, 0 );
|
||||
const double outlineWidthPixels = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
||||
: QPixmap( w, h )
|
||||
{
|
||||
{
|
||||
fill( Qt::transparent );
|
||||
|
||||
QPainter painter(this );
|
||||
@@ -53,4 +56,6 @@ ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
||||
painter.setBrush( brush );
|
||||
painter.setPen( pen );
|
||||
painter.drawRect( 1, 1, w-2, h-2 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-6
@@ -25,19 +25,24 @@
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
///
|
||||
/// Simple Preview Widget
|
||||
///
|
||||
class ColorSwatch : public QPixmap
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Simple Preview Widget
|
||||
///
|
||||
class ColorSwatch : public QPixmap
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
ColorSwatch( int w, int h, const QColor& color );
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // ColorSwatch_h
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace glabels
|
||||
const double PTS_PER_CM = (10.0*PTS_PER_MM);
|
||||
const double PTS_PER_PICA = 12.0;
|
||||
|
||||
const Distance EPSILON( 0.5, Units::PT );
|
||||
}
|
||||
|
||||
#endif // glabels_Constants_h
|
||||
|
||||
+28
-17
@@ -23,37 +23,48 @@
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
Cursors::Barcode::Barcode()
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
Cursors::Barcode::Barcode()
|
||||
: QCursor( QPixmap(":cursors/32x32/cursor_barcode.png"), 7, 7 )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Cursors::Box::Box()
|
||||
Cursors::Box::Box()
|
||||
: QCursor( QPixmap(":cursors/32x32/cursor_box.png"), 7, 7 )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Cursors::Ellipse::Ellipse()
|
||||
Cursors::Ellipse::Ellipse()
|
||||
: QCursor( QPixmap(":cursors/32x32/cursor_ellipse.png"), 7, 7 )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Cursors::Image::Image()
|
||||
Cursors::Image::Image()
|
||||
: QCursor( QPixmap(":cursors/32x32/cursor_image.png"), 7, 7 )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Cursors::Line::Line()
|
||||
Cursors::Line::Line()
|
||||
: QCursor( QPixmap(":cursors/32x32/cursor_line.png"), 7, 7 )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Cursors::Text::Text()
|
||||
Cursors::Text::Text()
|
||||
: QCursor( QPixmap(":cursors/32x32/cursor_text.png"), 7, 7 )
|
||||
{
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-4
@@ -25,12 +25,15 @@
|
||||
#include <QCursor>
|
||||
|
||||
|
||||
///
|
||||
/// Glabels Cursors
|
||||
///
|
||||
namespace Cursors
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Glabels Cursors
|
||||
///
|
||||
namespace Cursors
|
||||
{
|
||||
|
||||
|
||||
class Barcode : public QCursor
|
||||
{
|
||||
@@ -73,6 +76,8 @@ namespace Cursors
|
||||
Text();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+23
-16
@@ -32,18 +32,26 @@
|
||||
#include "XmlVendorParser.h"
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
bool partNameLessThan( const glabels::Template *a, const glabels::Template *b )
|
||||
{
|
||||
return glabels::StrUtil::comparePartNames( a->name(), b->name() ) < 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const QString empty = "";
|
||||
|
||||
bool partNameLessThan( const Template *a, const Template *b )
|
||||
{
|
||||
return StrUtil::comparePartNames( a->name(), b->name() ) < 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
QList<Paper*> Db::mPapers;
|
||||
QStringList Db::mPaperIds;
|
||||
QStringList Db::mPaperNames;
|
||||
@@ -53,9 +61,8 @@ namespace glabels
|
||||
QList<Vendor*> Db::mVendors;
|
||||
QStringList Db::mVendorNames;
|
||||
QList<Template*> Db::mTemplates;
|
||||
|
||||
QString Db::mPaperNameOther;
|
||||
QString Db::mEmpty = "";
|
||||
|
||||
|
||||
Db::Db()
|
||||
{
|
||||
@@ -204,7 +211,7 @@ namespace glabels
|
||||
}
|
||||
|
||||
qWarning() << "Unknown paper name: " << name;
|
||||
return mEmpty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +232,7 @@ namespace glabels
|
||||
}
|
||||
|
||||
qWarning() << "Unknown paper id: " << id;
|
||||
return mEmpty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -318,7 +325,7 @@ namespace glabels
|
||||
}
|
||||
|
||||
qWarning() << "Unknown category name: " << name;
|
||||
return mEmpty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +341,7 @@ namespace glabels
|
||||
}
|
||||
|
||||
qWarning() << "Unknown category id: " << id;
|
||||
return mEmpty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -399,7 +406,7 @@ namespace glabels
|
||||
}
|
||||
|
||||
qWarning() << "Unknown vendor name: " << name;
|
||||
return mEmpty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ namespace glabels
|
||||
static QList<Template*> mTemplates;
|
||||
|
||||
static QString mPaperNameOther;
|
||||
static QString mEmpty;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -21,9 +21,12 @@
|
||||
#include "EnumUtil.h"
|
||||
|
||||
|
||||
namespace EnumUtil
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace EnumUtil
|
||||
{
|
||||
|
||||
QString weightToString( QFont::Weight weight )
|
||||
{
|
||||
switch (weight)
|
||||
@@ -118,4 +121,6 @@ namespace EnumUtil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-1
@@ -27,9 +27,12 @@
|
||||
#include <Qt>
|
||||
|
||||
|
||||
namespace EnumUtil
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace EnumUtil
|
||||
{
|
||||
|
||||
QString weightToString( QFont::Weight weight );
|
||||
QFont::Weight stringToWeight( const QString& string );
|
||||
|
||||
@@ -39,6 +42,8 @@ namespace EnumUtil
|
||||
QString vAlignToString( Qt::Alignment align );
|
||||
Qt::Alignment stringToVAlign( const QString& string );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+25
-20
@@ -25,20 +25,23 @@
|
||||
#include <QStandardItemModel>
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
FieldButton::FieldButton( QWidget* parent )
|
||||
: QComboBox(parent)
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
FieldButton::FieldButton( QWidget* parent )
|
||||
: QComboBox(parent)
|
||||
{
|
||||
setEnabled( false );
|
||||
|
||||
connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FieldButton::setName( const QString& name )
|
||||
{
|
||||
void FieldButton::setName( const QString& name )
|
||||
{
|
||||
mName = name;
|
||||
if ( count() == 0 )
|
||||
{
|
||||
@@ -53,11 +56,11 @@ void FieldButton::setName( const QString& name )
|
||||
const QStandardItemModel* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
||||
QStandardItem* item = itemModel->item(0);
|
||||
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FieldButton::setKeys( const QStringList& keyList )
|
||||
{
|
||||
void FieldButton::setKeys( const QStringList& keyList )
|
||||
{
|
||||
// Clear old keys
|
||||
clear();
|
||||
addItem( mName );
|
||||
@@ -77,28 +80,30 @@ void FieldButton::setKeys( const QStringList& keyList )
|
||||
{
|
||||
setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FieldButton::clearKeys()
|
||||
{
|
||||
void FieldButton::clearKeys()
|
||||
{
|
||||
clear();
|
||||
addItem( mName );
|
||||
|
||||
setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// onMenuKeySelected slot
|
||||
///
|
||||
void FieldButton::onIndexChanged( int index )
|
||||
{
|
||||
///
|
||||
/// onMenuKeySelected slot
|
||||
///
|
||||
void FieldButton::onIndexChanged( int index )
|
||||
{
|
||||
if ( index > 0 )
|
||||
{
|
||||
emit keySelected( itemText(index) );
|
||||
|
||||
setCurrentIndex( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-10
@@ -26,31 +26,34 @@
|
||||
#include <QString>
|
||||
|
||||
|
||||
///
|
||||
/// Field Button
|
||||
///
|
||||
class FieldButton : public QComboBox
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Field Button
|
||||
///
|
||||
class FieldButton : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
FieldButton( QWidget* parent = 0 );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void keySelected( QString key );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void setName( const QString& name = "" );
|
||||
void setKeys( const QStringList& keyList );
|
||||
void clearKeys();
|
||||
@@ -59,17 +62,19 @@ public:
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onIndexChanged( int index );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QString mName;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // FieldButton_h
|
||||
|
||||
+47
-42
@@ -33,21 +33,24 @@
|
||||
#include "XmlLabelCreator.h"
|
||||
|
||||
|
||||
///
|
||||
/// Static data
|
||||
///
|
||||
QString File::mCwd = ".";
|
||||
|
||||
|
||||
///
|
||||
/// New Label Dialog
|
||||
///
|
||||
bool File::newLabel( MainWindow *window )
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
QString File::mCwd = ".";
|
||||
|
||||
|
||||
///
|
||||
/// New Label Dialog
|
||||
///
|
||||
bool File::newLabel( MainWindow *window )
|
||||
{
|
||||
SelectProductDialog dialog( window );
|
||||
dialog.exec();
|
||||
|
||||
const glabels::Template* tmplate = dialog.tmplate();
|
||||
const Template* tmplate = dialog.tmplate();
|
||||
if ( tmplate )
|
||||
{
|
||||
LabelModel* label = new LabelModel();
|
||||
@@ -55,7 +58,7 @@ bool File::newLabel( MainWindow *window )
|
||||
label->clearModified();
|
||||
|
||||
// Intelligently decide to rotate label by default
|
||||
const glabels::Frame* frame = tmplate->frames().first();
|
||||
const Frame* frame = tmplate->frames().first();
|
||||
label->setRotate( frame->h() > frame->w() );
|
||||
|
||||
// Either apply to current window or open a new one
|
||||
@@ -76,14 +79,14 @@ bool File::newLabel( MainWindow *window )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Open File Dialog
|
||||
///
|
||||
void File::open( MainWindow *window )
|
||||
{
|
||||
///
|
||||
/// Open File Dialog
|
||||
///
|
||||
void File::open( MainWindow *window )
|
||||
{
|
||||
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
||||
QString cwd = mCwd;
|
||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||
@@ -132,14 +135,14 @@ void File::open( MainWindow *window )
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Save file
|
||||
///
|
||||
bool File::save( MainWindow *window )
|
||||
{
|
||||
///
|
||||
/// Save file
|
||||
///
|
||||
bool File::save( MainWindow *window )
|
||||
{
|
||||
if ( window->model()->fileName().isEmpty() )
|
||||
{
|
||||
return saveAs( window );
|
||||
@@ -157,14 +160,14 @@ bool File::save( MainWindow *window )
|
||||
mCwd = QFileInfo( window->model()->fileName() ).absolutePath();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Save file as
|
||||
///
|
||||
bool File::saveAs( MainWindow *window )
|
||||
{
|
||||
///
|
||||
/// Save file as
|
||||
///
|
||||
bool File::saveAs( MainWindow *window )
|
||||
{
|
||||
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
||||
QString cwd = mCwd;
|
||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||
@@ -215,23 +218,23 @@ bool File::saveAs( MainWindow *window )
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Close file
|
||||
///
|
||||
void File::close( MainWindow *window )
|
||||
{
|
||||
///
|
||||
/// Close file
|
||||
///
|
||||
void File::close( MainWindow *window )
|
||||
{
|
||||
window->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Exit, closing all windows
|
||||
///
|
||||
void File::exit()
|
||||
{
|
||||
///
|
||||
/// Exit, closing all windows
|
||||
///
|
||||
void File::exit()
|
||||
{
|
||||
foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
|
||||
{
|
||||
if ( MainWindow* window = qobject_cast<MainWindow*>(qwidget) )
|
||||
@@ -239,4 +242,6 @@ void File::exit()
|
||||
window->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+18
-12
@@ -24,20 +24,24 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
// Forward References
|
||||
class MainWindow;
|
||||
|
||||
|
||||
///
|
||||
/// File Actions
|
||||
///
|
||||
/// Note: class provides a translation context for these static functions.
|
||||
///
|
||||
class File : public QObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class MainWindow;
|
||||
|
||||
|
||||
///
|
||||
/// File Actions
|
||||
///
|
||||
/// Note: class provides a translation context for these static functions.
|
||||
///
|
||||
class File : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
static bool newLabel( MainWindow *window = 0 );
|
||||
static void open( MainWindow *window );
|
||||
static bool save( MainWindow *window );
|
||||
@@ -45,10 +49,12 @@ public:
|
||||
static void close( MainWindow *window );
|
||||
static void exit();
|
||||
|
||||
private:
|
||||
private:
|
||||
static QString mCwd;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // File_h
|
||||
|
||||
@@ -21,9 +21,12 @@
|
||||
#include "FileUtil.h"
|
||||
|
||||
|
||||
namespace FileUtil
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace FileUtil
|
||||
{
|
||||
|
||||
QString addExtension( const QString& rawFilename, const QString& extension )
|
||||
{
|
||||
if ( rawFilename.endsWith( extension ) )
|
||||
@@ -34,4 +37,6 @@ namespace FileUtil
|
||||
return rawFilename + extension;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-1
@@ -25,11 +25,16 @@
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace FileUtil
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace FileUtil
|
||||
{
|
||||
|
||||
QString addExtension( const QString& rawFilename, const QString& extension );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace glabels
|
||||
Frame::Frame( const QString& id )
|
||||
: mId(id), mNLabels(0), mLayoutDescription("")
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-5
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#include "privateConstants.h"
|
||||
#include "Constants.h"
|
||||
#include "StrUtil.h"
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace glabels
|
||||
: mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
||||
mPath(other.mPath), Frame(other)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -160,10 +161,10 @@ namespace glabels
|
||||
{
|
||||
if ( FrameCd *otherCd = dynamic_cast<FrameCd*>(other) )
|
||||
{
|
||||
if ( (fabs( mW - otherCd->mW ) <= Constants::EPSILON) &&
|
||||
(fabs( mH - otherCd->mH ) <= Constants::EPSILON) &&
|
||||
(fabs( mR1 - otherCd->mR1 ) <= Constants::EPSILON) &&
|
||||
(fabs( mR2 - otherCd->mR2 ) <= Constants::EPSILON) )
|
||||
if ( (fabs( mW - otherCd->mW ) <= EPSILON) &&
|
||||
(fabs( mH - otherCd->mH ) <= EPSILON) &&
|
||||
(fabs( mR1 - otherCd->mR1 ) <= EPSILON) &&
|
||||
(fabs( mR2 - otherCd->mR2 ) <= EPSILON) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "FrameEllipse.h"
|
||||
|
||||
|
||||
#include "privateConstants.h"
|
||||
#include "Constants.h"
|
||||
#include "StrUtil.h"
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace glabels
|
||||
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
||||
: mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -94,8 +95,8 @@ namespace glabels
|
||||
{
|
||||
if ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
||||
{
|
||||
if ( (fabs( mW - otherEllipse->mW ) <= Constants::EPSILON) &&
|
||||
(fabs( mH - otherEllipse->mH ) <= Constants::EPSILON) )
|
||||
if ( (fabs( mW - otherEllipse->mW ) <= EPSILON) &&
|
||||
(fabs( mH - otherEllipse->mH ) <= EPSILON) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "FrameRect.h"
|
||||
|
||||
|
||||
#include "privateConstants.h"
|
||||
#include "Constants.h"
|
||||
#include "StrUtil.h"
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace glabels
|
||||
: mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
|
||||
mYWaste(other.mYWaste), mPath(other.mPath), Frame(other)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -113,8 +114,8 @@ namespace glabels
|
||||
{
|
||||
if ( FrameRect *otherRect = dynamic_cast<FrameRect*>(other) )
|
||||
{
|
||||
if ( (fabs( mW - otherRect->mW ) <= Constants::EPSILON) &&
|
||||
(fabs( mH - otherRect->mH ) <= Constants::EPSILON) )
|
||||
if ( (fabs( mW - otherRect->mW ) <= EPSILON) &&
|
||||
(fabs( mH - otherRect->mH ) <= EPSILON) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "FrameRound.h"
|
||||
|
||||
|
||||
#include "privateConstants.h"
|
||||
#include "Constants.h"
|
||||
#include "StrUtil.h"
|
||||
|
||||
|
||||
@@ -34,13 +34,15 @@ namespace glabels
|
||||
: mR(r), mWaste(waste), Frame(id)
|
||||
{
|
||||
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
|
||||
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(), 2*(mR+mWaste).pt(), 2*(mR+mWaste).pt() );
|
||||
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(),
|
||||
2*(mR+mWaste).pt(), 2*(mR+mWaste).pt() );
|
||||
}
|
||||
|
||||
|
||||
FrameRound::FrameRound( const FrameRound& other )
|
||||
: mR(other.mR), mWaste(other.mWaste), mPath(other.mPath), Frame(other)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +101,7 @@ namespace glabels
|
||||
{
|
||||
if ( FrameRound *otherRound = dynamic_cast<FrameRound*>(other) )
|
||||
{
|
||||
if ( fabs( mR - otherRound->mR ) <= Constants::EPSILON )
|
||||
if ( fabs( mR - otherRound->mR ) <= EPSILON )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
+373
-342
@@ -27,61 +27,69 @@
|
||||
#include "LabelModelObject.h"
|
||||
|
||||
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const double handlePixels = 7;
|
||||
const double handleOutlineWidthPixels = 1;
|
||||
|
||||
const QColor handleFillColor( 0, 192, 0, 96 );
|
||||
const QColor originHandleFillColor( 192, 0, 0, 96 );
|
||||
const QColor handleOutlineColor( 0, 0, 0, 192 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Handle Constructor
|
||||
///
|
||||
Handle::Handle( LabelModelObject* owner, Location location )
|
||||
///
|
||||
/// Handle Constructor
|
||||
///
|
||||
Handle::Handle( LabelModelObject* owner, Location location )
|
||||
: mOwner(owner), mLocation(location)
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Handle Destructor
|
||||
///
|
||||
Handle::~Handle()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Handle Destructor
|
||||
///
|
||||
Handle::~Handle()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Handle owner
|
||||
///
|
||||
LabelModelObject* Handle::owner() const
|
||||
{
|
||||
///
|
||||
/// Handle owner
|
||||
///
|
||||
LabelModelObject* Handle::owner() const
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Handle location
|
||||
///
|
||||
Handle::Location Handle::location() const
|
||||
{
|
||||
///
|
||||
/// Handle location
|
||||
///
|
||||
Handle::Location Handle::location() const
|
||||
{
|
||||
return mLocation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Handle at x,y
|
||||
///
|
||||
void Handle::drawAt( QPainter* painter,
|
||||
///
|
||||
/// Draw Handle at x,y
|
||||
///
|
||||
void Handle::drawAt( QPainter* painter,
|
||||
double scale,
|
||||
const glabels::Distance& x,
|
||||
const glabels::Distance& y,
|
||||
const Distance& x,
|
||||
const Distance& y,
|
||||
QColor color ) const
|
||||
{
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->translate( x.pt(), y.pt() );
|
||||
@@ -95,19 +103,20 @@ void Handle::drawAt( QPainter* painter,
|
||||
painter->setPen( pen );
|
||||
painter->setBrush( color );
|
||||
|
||||
painter->drawRect( QRectF( -s*handlePixels/2.0, -s*handlePixels/2.0, s*handlePixels, s*handlePixels ) );
|
||||
painter->drawRect( QRectF( -s*handlePixels/2.0, -s*handlePixels/2.0,
|
||||
s*handlePixels, s*handlePixels ) );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create Handle path at x,y
|
||||
///
|
||||
QPainterPath Handle::pathAt( double scale,
|
||||
const glabels::Distance& x,
|
||||
const glabels::Distance& y ) const
|
||||
{
|
||||
///
|
||||
/// Create Handle path at x,y
|
||||
///
|
||||
QPainterPath Handle::pathAt( double scale,
|
||||
const Distance& x,
|
||||
const Distance& y ) const
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
double s = 1/scale;
|
||||
@@ -116,443 +125,465 @@ QPainterPath Handle::pathAt( double scale,
|
||||
path.translate( x.pt(), y.pt() );
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Constructor
|
||||
///
|
||||
HandleNorth::HandleNorth( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleNorth Constructor
|
||||
///
|
||||
HandleNorth::HandleNorth( LabelModelObject* owner )
|
||||
: Handle( owner, N )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Destructor
|
||||
///
|
||||
HandleNorth::~HandleNorth()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleNorth Destructor
|
||||
///
|
||||
HandleNorth::~HandleNorth()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Clone
|
||||
///
|
||||
HandleNorth* HandleNorth::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleNorth Clone
|
||||
///
|
||||
HandleNorth* HandleNorth::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleNorth( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleNorth
|
||||
///
|
||||
void HandleNorth::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleNorth
|
||||
///
|
||||
void HandleNorth::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, mOwner->w()/2, 0, handleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Path
|
||||
///
|
||||
QPainterPath HandleNorth::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleNorth Path
|
||||
///
|
||||
QPainterPath HandleNorth::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, mOwner->w()/2, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Constructor
|
||||
///
|
||||
HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleNorthEast Constructor
|
||||
///
|
||||
HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
|
||||
: Handle( owner, NE )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Destructor
|
||||
///
|
||||
HandleNorthEast::~HandleNorthEast()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleNorthEast Destructor
|
||||
///
|
||||
HandleNorthEast::~HandleNorthEast()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Clone
|
||||
///
|
||||
HandleNorthEast* HandleNorthEast::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleNorthEast Clone
|
||||
///
|
||||
HandleNorthEast* HandleNorthEast::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleNorthEast( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleNorthEast
|
||||
///
|
||||
void HandleNorthEast::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleNorthEast
|
||||
///
|
||||
void HandleNorthEast::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, mOwner->w(), 0, handleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Path
|
||||
///
|
||||
QPainterPath HandleNorthEast::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleNorthEast Path
|
||||
///
|
||||
QPainterPath HandleNorthEast::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, mOwner->w(), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Constructor
|
||||
///
|
||||
HandleEast::HandleEast( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleEast Constructor
|
||||
///
|
||||
HandleEast::HandleEast( LabelModelObject* owner )
|
||||
: Handle( owner, E )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Destructor
|
||||
///
|
||||
HandleEast::~HandleEast()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleEast Destructor
|
||||
///
|
||||
HandleEast::~HandleEast()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Clone
|
||||
///
|
||||
HandleEast* HandleEast::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleEast Clone
|
||||
///
|
||||
HandleEast* HandleEast::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleEast( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleEast
|
||||
///
|
||||
void HandleEast::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleEast
|
||||
///
|
||||
void HandleEast::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, mOwner->w(), mOwner->h()/2, handleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Path
|
||||
///
|
||||
QPainterPath HandleEast::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleEast Path
|
||||
///
|
||||
QPainterPath HandleEast::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, mOwner->w(), mOwner->h()/2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Constructor
|
||||
///
|
||||
HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleSouthEast Constructor
|
||||
///
|
||||
HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
|
||||
: Handle( owner, SE )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Destructor
|
||||
///
|
||||
HandleSouthEast::~HandleSouthEast()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleSouthEast Destructor
|
||||
///
|
||||
HandleSouthEast::~HandleSouthEast()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Clone
|
||||
///
|
||||
HandleSouthEast* HandleSouthEast::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleSouthEast Clone
|
||||
///
|
||||
HandleSouthEast* HandleSouthEast::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleSouthEast( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleSouthEast
|
||||
///
|
||||
void HandleSouthEast::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleSouthEast
|
||||
///
|
||||
void HandleSouthEast::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, mOwner->w(), mOwner->h(), handleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Path
|
||||
///
|
||||
QPainterPath HandleSouthEast::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleSouthEast Path
|
||||
///
|
||||
QPainterPath HandleSouthEast::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, mOwner->w(), mOwner->h() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Constructor
|
||||
///
|
||||
HandleSouth::HandleSouth( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleSouth Constructor
|
||||
///
|
||||
HandleSouth::HandleSouth( LabelModelObject* owner )
|
||||
: Handle( owner, S )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Destructor
|
||||
///
|
||||
HandleSouth::~HandleSouth()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleSouth Destructor
|
||||
///
|
||||
HandleSouth::~HandleSouth()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Clone
|
||||
///
|
||||
HandleSouth* HandleSouth::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleSouth Clone
|
||||
///
|
||||
HandleSouth* HandleSouth::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleSouth( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleSouth
|
||||
///
|
||||
void HandleSouth::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleSouth
|
||||
///
|
||||
void HandleSouth::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, mOwner->w()/2, mOwner->h(), handleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Path
|
||||
///
|
||||
QPainterPath HandleSouth::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleSouth Path
|
||||
///
|
||||
QPainterPath HandleSouth::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, mOwner->w()/2, mOwner->h() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Constructor
|
||||
///
|
||||
HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleSouthWest Constructor
|
||||
///
|
||||
HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
|
||||
: Handle( owner, SW )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Destructor
|
||||
///
|
||||
HandleSouthWest::~HandleSouthWest()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleSouthWest Destructor
|
||||
///
|
||||
HandleSouthWest::~HandleSouthWest()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Clone
|
||||
///
|
||||
HandleSouthWest* HandleSouthWest::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleSouthWest Clone
|
||||
///
|
||||
HandleSouthWest* HandleSouthWest::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleSouthWest( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleSouthWest
|
||||
///
|
||||
void HandleSouthWest::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleSouthWest
|
||||
///
|
||||
void HandleSouthWest::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, 0, mOwner->h(), handleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Path
|
||||
///
|
||||
QPainterPath HandleSouthWest::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleSouthWest Path
|
||||
///
|
||||
QPainterPath HandleSouthWest::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, 0, mOwner->h() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Constructor
|
||||
///
|
||||
HandleWest::HandleWest( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleWest Constructor
|
||||
///
|
||||
HandleWest::HandleWest( LabelModelObject* owner )
|
||||
: Handle( owner, W )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Destructor
|
||||
///
|
||||
HandleWest::~HandleWest()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleWest Destructor
|
||||
///
|
||||
HandleWest::~HandleWest()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Clone
|
||||
///
|
||||
HandleWest* HandleWest::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleWest Clone
|
||||
///
|
||||
HandleWest* HandleWest::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleWest( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleWest
|
||||
///
|
||||
void HandleWest::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleWest
|
||||
///
|
||||
void HandleWest::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, 0, mOwner->h()/2, handleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Path
|
||||
///
|
||||
QPainterPath HandleWest::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleWest Path
|
||||
///
|
||||
QPainterPath HandleWest::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, 0, mOwner->h()/2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Constructor
|
||||
///
|
||||
HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleNorthWest Constructor
|
||||
///
|
||||
HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
|
||||
: Handle( owner, NW )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Destructor
|
||||
///
|
||||
HandleNorthWest::~HandleNorthWest()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleNorthWest Destructor
|
||||
///
|
||||
HandleNorthWest::~HandleNorthWest()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
///
|
||||
/// HandleNorthWest Clone
|
||||
///
|
||||
HandleNorthWest* HandleNorthWest::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleNorthWest Clone
|
||||
///
|
||||
HandleNorthWest* HandleNorthWest::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleNorthWest( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleNorthWest
|
||||
///
|
||||
void HandleNorthWest::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleNorthWest
|
||||
///
|
||||
void HandleNorthWest::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, 0, 0, originHandleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Path
|
||||
///
|
||||
QPainterPath HandleNorthWest::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleNorthWest Path
|
||||
///
|
||||
QPainterPath HandleNorthWest::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Constructor
|
||||
///
|
||||
HandleP1::HandleP1( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleP1 Constructor
|
||||
///
|
||||
HandleP1::HandleP1( LabelModelObject* owner )
|
||||
: Handle( owner, P1 )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Destructor
|
||||
///
|
||||
HandleP1::~HandleP1()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleP1 Destructor
|
||||
///
|
||||
HandleP1::~HandleP1()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Clone
|
||||
///
|
||||
HandleP1* HandleP1::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleP1 Clone
|
||||
///
|
||||
HandleP1* HandleP1::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleP1( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleP1
|
||||
///
|
||||
void HandleP1::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleP1
|
||||
///
|
||||
void HandleP1::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, 0, 0, originHandleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Path
|
||||
///
|
||||
QPainterPath HandleP1::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleP1 Path
|
||||
///
|
||||
QPainterPath HandleP1::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Constructor
|
||||
///
|
||||
HandleP2::HandleP2( LabelModelObject* owner )
|
||||
///
|
||||
/// HandleP2 Constructor
|
||||
///
|
||||
HandleP2::HandleP2( LabelModelObject* owner )
|
||||
: Handle( owner, P2 )
|
||||
{
|
||||
}
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Destructor
|
||||
///
|
||||
HandleP2::~HandleP2()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// HandleP2 Destructor
|
||||
///
|
||||
HandleP2::~HandleP2()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Clone
|
||||
///
|
||||
HandleP2* HandleP2::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
///
|
||||
/// HandleP2 Clone
|
||||
///
|
||||
HandleP2* HandleP2::clone( LabelModelObject* newOwner ) const
|
||||
{
|
||||
return new HandleP2( newOwner );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleP2
|
||||
///
|
||||
void HandleP2::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
///
|
||||
/// Draw HandleP2
|
||||
///
|
||||
void HandleP2::draw( QPainter* painter, double scale ) const
|
||||
{
|
||||
drawAt( painter, scale, mOwner->w(), mOwner->h(), handleFillColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Path
|
||||
///
|
||||
QPainterPath HandleP2::path( double scale ) const
|
||||
{
|
||||
///
|
||||
/// HandleP2 Path
|
||||
///
|
||||
QPainterPath HandleP2::path( double scale ) const
|
||||
{
|
||||
return pathAt( scale, mOwner->w(), mOwner->h() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+104
-98
@@ -27,28 +27,32 @@
|
||||
|
||||
#include "Distance.h"
|
||||
|
||||
// Forward References
|
||||
class LabelModelObject;
|
||||
|
||||
|
||||
///
|
||||
/// Handle Base Class
|
||||
///
|
||||
class Handle
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class LabelModelObject;
|
||||
|
||||
|
||||
///
|
||||
/// Handle Base Class
|
||||
///
|
||||
class Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Location enumeration
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
Handle( LabelModelObject* owner, Location location );
|
||||
public:
|
||||
public:
|
||||
virtual ~Handle();
|
||||
|
||||
|
||||
@@ -68,40 +72,40 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const = 0;
|
||||
virtual QPainterPath path( double scale ) const = 0;
|
||||
protected:
|
||||
protected:
|
||||
void drawAt( QPainter* painter,
|
||||
double scale,
|
||||
const glabels::Distance& x,
|
||||
const glabels::Distance& y,
|
||||
const Distance& x,
|
||||
const Distance& y,
|
||||
QColor color ) const;
|
||||
|
||||
QPainterPath pathAt( double scale,
|
||||
const glabels::Distance& x,
|
||||
const glabels::Distance& y ) const;
|
||||
const Distance& x,
|
||||
const Distance& y ) const;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Protected Data
|
||||
////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
LabelModelObject* mOwner;
|
||||
Location mLocation;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Class
|
||||
///
|
||||
class HandleNorth : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleNorth Class
|
||||
///
|
||||
class HandleNorth : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleNorth( LabelModelObject* owner );
|
||||
virtual ~HandleNorth();
|
||||
virtual HandleNorth* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -110,21 +114,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Class
|
||||
///
|
||||
class HandleNorthEast : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleNorthEast Class
|
||||
///
|
||||
class HandleNorthEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleNorthEast( LabelModelObject* owner );
|
||||
virtual ~HandleNorthEast();
|
||||
virtual HandleNorthEast* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -133,21 +137,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Class
|
||||
///
|
||||
class HandleEast : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleEast Class
|
||||
///
|
||||
class HandleEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleEast( LabelModelObject* owner );
|
||||
virtual ~HandleEast();
|
||||
virtual HandleEast* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -156,21 +160,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Class
|
||||
///
|
||||
class HandleSouthEast : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleSouthEast Class
|
||||
///
|
||||
class HandleSouthEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleSouthEast( LabelModelObject* owner );
|
||||
virtual ~HandleSouthEast();
|
||||
virtual HandleSouthEast* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -179,21 +183,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Class
|
||||
///
|
||||
class HandleSouth : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleSouth Class
|
||||
///
|
||||
class HandleSouth : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleSouth( LabelModelObject* owner );
|
||||
virtual ~HandleSouth();
|
||||
virtual HandleSouth* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -202,21 +206,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Class
|
||||
///
|
||||
class HandleSouthWest : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleSouthWest Class
|
||||
///
|
||||
class HandleSouthWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleSouthWest( LabelModelObject* owner );
|
||||
virtual ~HandleSouthWest();
|
||||
virtual HandleSouthWest* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -225,21 +229,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Class
|
||||
///
|
||||
class HandleWest : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleWest Class
|
||||
///
|
||||
class HandleWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleWest( LabelModelObject* owner );
|
||||
virtual ~HandleWest();
|
||||
virtual HandleWest* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -248,21 +252,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Class
|
||||
///
|
||||
class HandleNorthWest : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleNorthWest Class
|
||||
///
|
||||
class HandleNorthWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleNorthWest( LabelModelObject* owner );
|
||||
virtual ~HandleNorthWest();
|
||||
virtual HandleNorthWest* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -271,21 +275,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Class
|
||||
///
|
||||
class HandleP1 : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleP1 Class
|
||||
///
|
||||
class HandleP1 : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleP1( LabelModelObject* owner );
|
||||
virtual ~HandleP1();
|
||||
virtual HandleP1* clone( LabelModelObject* newOwner ) const;
|
||||
@@ -294,21 +298,21 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Class
|
||||
///
|
||||
class HandleP2 : public Handle
|
||||
{
|
||||
///
|
||||
/// HandleP2 Class
|
||||
///
|
||||
class HandleP2 : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
HandleP2( LabelModelObject* owner );
|
||||
virtual ~HandleP2();
|
||||
|
||||
@@ -321,10 +325,12 @@ public:
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const;
|
||||
virtual QPainterPath path( double scale ) const;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // Handles_h
|
||||
|
||||
+15
-10
@@ -26,20 +26,25 @@
|
||||
#include "AboutDialog.h"
|
||||
|
||||
|
||||
///
|
||||
/// Display Help Contents
|
||||
///
|
||||
void Help::displayContents( QWidget *parent )
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Display Help Contents
|
||||
///
|
||||
void Help::displayContents( QWidget *parent )
|
||||
{
|
||||
qDebug() << "TODO: Help::displayContents";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Display Help->About Dialog
|
||||
///
|
||||
void Help::displayAbout( QWidget *parent )
|
||||
{
|
||||
///
|
||||
/// Display Help->About Dialog
|
||||
///
|
||||
void Help::displayAbout( QWidget *parent )
|
||||
{
|
||||
AboutDialog dialog( parent );
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-5
@@ -25,16 +25,20 @@
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
///
|
||||
/// Help Actions
|
||||
///
|
||||
namespace Help
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Help Actions
|
||||
///
|
||||
namespace Help
|
||||
{
|
||||
|
||||
void displayContents( QWidget *parent );
|
||||
void displayAbout( QWidget *parent );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // Help_h
|
||||
|
||||
+7
-11
@@ -25,12 +25,15 @@
|
||||
#include <QIcon>
|
||||
|
||||
|
||||
///
|
||||
/// Glabels Icons
|
||||
///
|
||||
namespace Icons
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Glabels Icons
|
||||
///
|
||||
namespace Icons
|
||||
{
|
||||
|
||||
class Arrow : public QIcon
|
||||
{
|
||||
public:
|
||||
@@ -336,13 +339,6 @@ namespace Icons
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Fallback Icons. These are fallbacks for icons that would normally come from the current theme,
|
||||
/// if supported. These icons are copied from the mate-icon-theme (GPL-v3 or CC-BY-SA-v3).
|
||||
///
|
||||
namespace Fallback
|
||||
{
|
||||
|
||||
class EditCopy : public QIcon
|
||||
{
|
||||
public:
|
||||
|
||||
+295
-292
@@ -42,15 +42,17 @@
|
||||
#include "UndoRedoModel.h"
|
||||
|
||||
|
||||
//
|
||||
// Private Configuration Data
|
||||
//
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const int nZoomLevels = 11;
|
||||
const double zoomLevels[nZoomLevels] = { 8, 6, 4, 3, 2, 1.5, 1, 0.75, 0.67, 0.50, 0.33 };
|
||||
|
||||
const double PTS_PER_INCH = 72.0;
|
||||
const double ZOOM_TO_FIT_PAD = 16.0;
|
||||
|
||||
const QColor backgroundColor( 192, 192, 192 );
|
||||
@@ -64,7 +66,7 @@ namespace
|
||||
|
||||
const QColor gridLineColor( 192, 192, 192 );
|
||||
const double gridLineWidthPixels = 1;
|
||||
const glabels::Distance gridSpacing = glabels::Distance::pt(9); // TODO: determine from locale.
|
||||
const Distance gridSpacing = Distance::pt(9); // TODO: determine from locale.
|
||||
|
||||
const QColor markupLineColor( 240, 99, 99 );
|
||||
const double markupLineWidthPixels = 1;
|
||||
@@ -72,16 +74,15 @@ namespace
|
||||
const QColor selectRegionFillColor( 192, 192, 255, 128 );
|
||||
const QColor selectRegionOutlineColor( 0, 0, 255, 128 );
|
||||
const double selectRegionOutlineWidthPixels = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelEditor::LabelEditor( QScrollArea* scrollArea, QWidget* parent )
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelEditor::LabelEditor( QScrollArea* scrollArea, QWidget* parent )
|
||||
: QWidget(parent), mScrollArea(scrollArea)
|
||||
{
|
||||
{
|
||||
mState = IdleState;
|
||||
|
||||
mModel = 0;
|
||||
@@ -95,45 +96,45 @@ LabelEditor::LabelEditor( QScrollArea* scrollArea, QWidget* parent )
|
||||
|
||||
connect( Settings::instance(), SIGNAL(changed()), this, SLOT(onSettingsChanged()) );
|
||||
onSettingsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Zoom property
|
||||
///
|
||||
double
|
||||
LabelEditor::zoom() const
|
||||
{
|
||||
///
|
||||
/// Zoom property
|
||||
///
|
||||
double
|
||||
LabelEditor::zoom() const
|
||||
{
|
||||
return mZoom;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Markup visible? property
|
||||
///
|
||||
bool
|
||||
LabelEditor::markupVisible() const
|
||||
{
|
||||
///
|
||||
/// Markup visible? property
|
||||
///
|
||||
bool
|
||||
LabelEditor::markupVisible() const
|
||||
{
|
||||
return mMarkupVisible;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Grid visible? property
|
||||
///
|
||||
bool
|
||||
LabelEditor::qridVisible() const
|
||||
{
|
||||
///
|
||||
/// Grid visible? property
|
||||
///
|
||||
bool
|
||||
LabelEditor::qridVisible() const
|
||||
{
|
||||
return mGridVisible;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Model Parameter Setter
|
||||
///
|
||||
void
|
||||
LabelEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||
{
|
||||
///
|
||||
/// Model Parameter Setter
|
||||
///
|
||||
void
|
||||
LabelEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||
{
|
||||
mModel = model;
|
||||
mUndoRedoModel = undoRedoModel;
|
||||
|
||||
@@ -147,37 +148,37 @@ LabelEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Grid Visibility Parameter Setter
|
||||
///
|
||||
void
|
||||
LabelEditor::setGridVisible( bool visibleFlag )
|
||||
{
|
||||
///
|
||||
/// Grid Visibility Parameter Setter
|
||||
///
|
||||
void
|
||||
LabelEditor::setGridVisible( bool visibleFlag )
|
||||
{
|
||||
mGridVisible = visibleFlag;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Markup Visibility Parameter Setter
|
||||
///
|
||||
void
|
||||
LabelEditor::setMarkupVisible( bool visibleFlag )
|
||||
{
|
||||
///
|
||||
/// Markup Visibility Parameter Setter
|
||||
///
|
||||
void
|
||||
LabelEditor::setMarkupVisible( bool visibleFlag )
|
||||
{
|
||||
mMarkupVisible = visibleFlag;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Zoom In "One Notch"
|
||||
///
|
||||
void
|
||||
LabelEditor::zoomIn()
|
||||
{
|
||||
///
|
||||
/// Zoom In "One Notch"
|
||||
///
|
||||
void
|
||||
LabelEditor::zoomIn()
|
||||
{
|
||||
// Find closest standard zoom level to our current zoom
|
||||
// Start with 2nd largest scale
|
||||
int i_min = 1;
|
||||
@@ -195,15 +196,15 @@ LabelEditor::zoomIn()
|
||||
|
||||
// Zoom in one notch
|
||||
setZoomReal( zoomLevels[i_min-1], false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Zoom Out "One Notch"
|
||||
///
|
||||
void
|
||||
LabelEditor::zoomOut()
|
||||
{
|
||||
///
|
||||
/// Zoom Out "One Notch"
|
||||
///
|
||||
void
|
||||
LabelEditor::zoomOut()
|
||||
{
|
||||
// Find closest standard zoom level to our current zoom
|
||||
// Start with largest scale, end on 2nd smallest
|
||||
int i_min = 0;
|
||||
@@ -221,25 +222,25 @@ LabelEditor::zoomOut()
|
||||
|
||||
// Zoom out one notch
|
||||
setZoomReal( zoomLevels[i_min+1], false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Zoom To 1:1 Scale
|
||||
///
|
||||
void
|
||||
LabelEditor::zoom1To1()
|
||||
{
|
||||
///
|
||||
/// Zoom To 1:1 Scale
|
||||
///
|
||||
void
|
||||
LabelEditor::zoom1To1()
|
||||
{
|
||||
setZoomReal( 1.0, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Zoom To Fit
|
||||
///
|
||||
void
|
||||
LabelEditor::zoomToFit()
|
||||
{
|
||||
///
|
||||
/// Zoom To Fit
|
||||
///
|
||||
void
|
||||
LabelEditor::zoomToFit()
|
||||
{
|
||||
double wPixels = mScrollArea->maximumViewportSize().width();
|
||||
double hPixels = mScrollArea->maximumViewportSize().height();
|
||||
|
||||
@@ -252,35 +253,35 @@ LabelEditor::zoomToFit()
|
||||
newZoom = qMax( newZoom, zoomLevels[nZoomLevels-1] );
|
||||
|
||||
setZoomReal( newZoom, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Is Zoom at Maximum?
|
||||
///
|
||||
bool
|
||||
LabelEditor::isZoomMax() const
|
||||
{
|
||||
///
|
||||
/// Is Zoom at Maximum?
|
||||
///
|
||||
bool
|
||||
LabelEditor::isZoomMax() const
|
||||
{
|
||||
return mZoom >= zoomLevels[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Is Zoom at Minimum?
|
||||
///
|
||||
bool
|
||||
LabelEditor::isZoomMin() const
|
||||
{
|
||||
///
|
||||
/// Is Zoom at Minimum?
|
||||
///
|
||||
bool
|
||||
LabelEditor::isZoomMin() const
|
||||
{
|
||||
return mZoom <= zoomLevels[nZoomLevels-1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Set Zoom to Value
|
||||
///
|
||||
void
|
||||
LabelEditor::setZoomReal( double zoom, bool zoomToFitFlag )
|
||||
{
|
||||
///
|
||||
/// Set Zoom to Value
|
||||
///
|
||||
void
|
||||
LabelEditor::setZoomReal( double zoom, bool zoomToFitFlag )
|
||||
{
|
||||
mZoom = zoom;
|
||||
mZoomToFitFlag = zoomToFitFlag;
|
||||
|
||||
@@ -297,92 +298,92 @@ LabelEditor::setZoomReal( double zoom, bool zoomToFitFlag )
|
||||
update();
|
||||
|
||||
emit zoomChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Arrow mode (normal mode)
|
||||
///
|
||||
void
|
||||
LabelEditor::arrowMode()
|
||||
{
|
||||
///
|
||||
/// Arrow mode (normal mode)
|
||||
///
|
||||
void
|
||||
LabelEditor::arrowMode()
|
||||
{
|
||||
setCursor( Qt::ArrowCursor );
|
||||
|
||||
mState = IdleState;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create box mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createBoxMode()
|
||||
{
|
||||
///
|
||||
/// Create box mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createBoxMode()
|
||||
{
|
||||
setCursor( Cursors::Box() );
|
||||
|
||||
mCreateObjectType = Box;
|
||||
mState = CreateIdle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create ellipse mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createEllipseMode()
|
||||
{
|
||||
///
|
||||
/// Create ellipse mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createEllipseMode()
|
||||
{
|
||||
setCursor( Cursors::Ellipse() );
|
||||
|
||||
mCreateObjectType = Ellipse;
|
||||
mState = CreateIdle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create image mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createImageMode()
|
||||
{
|
||||
///
|
||||
/// Create image mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createImageMode()
|
||||
{
|
||||
setCursor( Cursors::Image() );
|
||||
|
||||
mCreateObjectType = Image;
|
||||
mState = CreateIdle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create line mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createLineMode()
|
||||
{
|
||||
///
|
||||
/// Create line mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createLineMode()
|
||||
{
|
||||
setCursor( Cursors::Line() );
|
||||
|
||||
mCreateObjectType = Line;
|
||||
mState = CreateIdle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create text mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createTextMode()
|
||||
{
|
||||
///
|
||||
/// Create text mode
|
||||
///
|
||||
void
|
||||
LabelEditor::createTextMode()
|
||||
{
|
||||
setCursor( Cursors::Text() );
|
||||
|
||||
mCreateObjectType = Text;
|
||||
mState = CreateIdle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Resize Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::resizeEvent( QResizeEvent *event )
|
||||
{
|
||||
///
|
||||
/// Resize Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::resizeEvent( QResizeEvent *event )
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
if ( mZoomToFitFlag )
|
||||
@@ -398,15 +399,15 @@ LabelEditor::resizeEvent( QResizeEvent *event )
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Mouse Button Press Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
///
|
||||
/// Mouse Button Press Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
/*
|
||||
@@ -418,8 +419,8 @@ LabelEditor::mousePressEvent( QMouseEvent* event )
|
||||
transform.translate( mX0.pt(), mY0.pt() );
|
||||
|
||||
QPointF pWorld = transform.inverted().map( event->pos() );
|
||||
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
|
||||
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
|
||||
Distance xWorld = Distance::pt( pWorld.x() );
|
||||
Distance yWorld = Distance::pt( pWorld.y() );
|
||||
|
||||
|
||||
if ( event->button() & Qt::LeftButton )
|
||||
@@ -564,15 +565,15 @@ LabelEditor::mousePressEvent( QMouseEvent* event )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Mouse Movement Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::mouseMoveEvent( QMouseEvent* event )
|
||||
{
|
||||
///
|
||||
/// Mouse Movement Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::mouseMoveEvent( QMouseEvent* event )
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
/*
|
||||
@@ -584,8 +585,8 @@ LabelEditor::mouseMoveEvent( QMouseEvent* event )
|
||||
transform.translate( mX0.pt(), mY0.pt() );
|
||||
|
||||
QPointF pWorld = transform.inverted().map( event->pos() );
|
||||
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
|
||||
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
|
||||
Distance xWorld = Distance::pt( pWorld.x() );
|
||||
Distance yWorld = Distance::pt( pWorld.y() );
|
||||
|
||||
|
||||
/*
|
||||
@@ -666,15 +667,15 @@ LabelEditor::mouseMoveEvent( QMouseEvent* event )
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Mouse Button Release Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::mouseReleaseEvent( QMouseEvent* event )
|
||||
{
|
||||
///
|
||||
/// Mouse Button Release Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::mouseReleaseEvent( QMouseEvent* event )
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
/*
|
||||
@@ -686,8 +687,8 @@ LabelEditor::mouseReleaseEvent( QMouseEvent* event )
|
||||
transform.translate( mX0.pt(), mY0.pt() );
|
||||
|
||||
QPointF pWorld = transform.inverted().map( event->pos() );
|
||||
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
|
||||
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
|
||||
Distance xWorld = Distance::pt( pWorld.x() );
|
||||
Distance yWorld = Distance::pt( pWorld.y() );
|
||||
|
||||
|
||||
if ( event->button() & Qt::LeftButton )
|
||||
@@ -742,29 +743,29 @@ LabelEditor::mouseReleaseEvent( QMouseEvent* event )
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Leave Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::leaveEvent( QEvent* event )
|
||||
{
|
||||
///
|
||||
/// Leave Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::leaveEvent( QEvent* event )
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
emit pointerExited();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Handle resize motion
|
||||
///
|
||||
void
|
||||
LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
|
||||
const glabels::Distance& yWorld )
|
||||
{
|
||||
///
|
||||
/// Handle resize motion
|
||||
///
|
||||
void
|
||||
LabelEditor::handleResizeMotion( const Distance& xWorld,
|
||||
const Distance& yWorld )
|
||||
{
|
||||
QPointF p( xWorld.pt(), yWorld.pt() );
|
||||
Handle::Location location = mResizeHandle->location();
|
||||
|
||||
@@ -853,22 +854,22 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
|
||||
{
|
||||
case Handle::E:
|
||||
case Handle::W:
|
||||
mResizeObject->setWHonorAspect( glabels::Distance::pt(w) );
|
||||
mResizeObject->setWHonorAspect( Distance::pt(w) );
|
||||
break;
|
||||
case Handle::N:
|
||||
case Handle::S:
|
||||
mResizeObject->setHHonorAspect( glabels::Distance::pt(h) );
|
||||
mResizeObject->setHHonorAspect( Distance::pt(h) );
|
||||
break;
|
||||
default:
|
||||
mResizeObject->setSizeHonorAspect( glabels::Distance::pt(w),
|
||||
glabels::Distance::pt(h) );
|
||||
mResizeObject->setSizeHonorAspect( Distance::pt(w),
|
||||
Distance::pt(h) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mResizeObject->setSize( glabels::Distance::pt(w),
|
||||
glabels::Distance::pt(h) );
|
||||
mResizeObject->setSize( Distance::pt(w),
|
||||
Distance::pt(h) );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -894,8 +895,8 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
|
||||
}
|
||||
else
|
||||
{
|
||||
mResizeObject->setSize( glabels::Distance::pt(w),
|
||||
glabels::Distance::pt(h) );
|
||||
mResizeObject->setSize( Distance::pt(w),
|
||||
Distance::pt(h) );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -904,16 +905,16 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
|
||||
QPointF p0( x0, y0 );
|
||||
p0 = mResizeObject->matrix().map( p0 );
|
||||
p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
|
||||
mResizeObject->setPosition( glabels::Distance::pt(p0.x()),
|
||||
glabels::Distance::pt(p0.y()) );
|
||||
}
|
||||
mResizeObject->setPosition( Distance::pt(p0.x()),
|
||||
Distance::pt(p0.y()) );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Key Press Event Handler
|
||||
void
|
||||
LabelEditor::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
///
|
||||
/// Key Press Event Handler
|
||||
void
|
||||
LabelEditor::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
if ( mState == IdleState )
|
||||
{
|
||||
switch (event->key())
|
||||
@@ -921,22 +922,22 @@ LabelEditor::keyPressEvent( QKeyEvent* event )
|
||||
|
||||
case Qt::Key_Left:
|
||||
mUndoRedoModel->checkpoint( tr("Move") );
|
||||
mModel->moveSelection( -mStepSize, glabels::Distance(0) );
|
||||
mModel->moveSelection( -mStepSize, Distance(0) );
|
||||
break;
|
||||
|
||||
case Qt::Key_Up:
|
||||
mUndoRedoModel->checkpoint( tr("Move") );
|
||||
mModel->moveSelection( glabels::Distance(0), -mStepSize );
|
||||
mModel->moveSelection( Distance(0), -mStepSize );
|
||||
break;
|
||||
|
||||
case Qt::Key_Right:
|
||||
mUndoRedoModel->checkpoint( tr("Move") );
|
||||
mModel->moveSelection( mStepSize, glabels::Distance(0) );
|
||||
mModel->moveSelection( mStepSize, Distance(0) );
|
||||
break;
|
||||
|
||||
case Qt::Key_Down:
|
||||
mUndoRedoModel->checkpoint( tr("Move") );
|
||||
mModel->moveSelection( glabels::Distance(0), mStepSize );
|
||||
mModel->moveSelection( Distance(0), mStepSize );
|
||||
break;
|
||||
|
||||
case Qt::Key_Delete:
|
||||
@@ -955,15 +956,15 @@ LabelEditor::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
QWidget::keyPressEvent( event );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Paint Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
///
|
||||
/// Paint Event Handler
|
||||
///
|
||||
void
|
||||
LabelEditor::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
QPainter painter( this );
|
||||
@@ -990,15 +991,15 @@ LabelEditor::paintEvent( QPaintEvent* event )
|
||||
drawHighlightLayer( &painter );
|
||||
drawSelectRegionLayer( &painter );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Background Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawBgLayer( QPainter* painter )
|
||||
{
|
||||
///
|
||||
/// Draw Background Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawBgLayer( QPainter* painter )
|
||||
{
|
||||
/*
|
||||
* Draw shadow
|
||||
*/
|
||||
@@ -1035,22 +1036,22 @@ LabelEditor::drawBgLayer( QPainter* painter )
|
||||
painter->drawPath( mModel->frame()->path() );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Grid Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawGridLayer( QPainter* painter )
|
||||
{
|
||||
///
|
||||
/// Draw Grid Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawGridLayer( QPainter* painter )
|
||||
{
|
||||
if ( mGridVisible )
|
||||
{
|
||||
glabels::Distance w = mModel->frame()->w();
|
||||
glabels::Distance h = mModel->frame()->h();
|
||||
Distance w = mModel->frame()->w();
|
||||
Distance h = mModel->frame()->h();
|
||||
|
||||
glabels::Distance x0, y0;
|
||||
if ( dynamic_cast<const glabels::FrameRect*>( mModel->frame() ) )
|
||||
Distance x0, y0;
|
||||
if ( dynamic_cast<const FrameRect*>( mModel->frame() ) )
|
||||
{
|
||||
x0 = gridSpacing;
|
||||
y0 = gridSpacing;
|
||||
@@ -1075,27 +1076,27 @@ LabelEditor::drawGridLayer( QPainter* painter )
|
||||
pen.setCosmetic( true );
|
||||
painter->setPen( pen );
|
||||
|
||||
for ( glabels::Distance x = x0; x < w; x += gridSpacing )
|
||||
for ( Distance x = x0; x < w; x += gridSpacing )
|
||||
{
|
||||
painter->drawLine( x.pt(), 0, x.pt(), h.pt() );
|
||||
}
|
||||
|
||||
for ( glabels::Distance y = y0; y < h; y += gridSpacing )
|
||||
for ( Distance y = y0; y < h; y += gridSpacing )
|
||||
{
|
||||
painter->drawLine( 0, y.pt(), w.pt(), y.pt() );
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Markup Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawMarkupLayer( QPainter* painter )
|
||||
{
|
||||
///
|
||||
/// Draw Markup Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawMarkupLayer( QPainter* painter )
|
||||
{
|
||||
if ( mMarkupVisible )
|
||||
{
|
||||
painter->save();
|
||||
@@ -1112,32 +1113,32 @@ LabelEditor::drawMarkupLayer( QPainter* painter )
|
||||
painter->translate( -mModel->frame()->w().pt(), 0 );
|
||||
}
|
||||
|
||||
foreach( glabels::Markup* markup, mModel->frame()->markups() )
|
||||
foreach( Markup* markup, mModel->frame()->markups() )
|
||||
{
|
||||
painter->drawPath( markup->path() );
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Objects Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawObjectsLayer( QPainter* painter )
|
||||
{
|
||||
///
|
||||
/// Draw Objects Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawObjectsLayer( QPainter* painter )
|
||||
{
|
||||
mModel->draw( painter );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Foreground Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawFgLayer( QPainter* painter )
|
||||
{
|
||||
///
|
||||
/// Draw Foreground Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawFgLayer( QPainter* painter )
|
||||
{
|
||||
/*
|
||||
* Draw label outline
|
||||
*/
|
||||
@@ -1156,15 +1157,15 @@ LabelEditor::drawFgLayer( QPainter* painter )
|
||||
painter->drawPath( mModel->frame()->path() );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Highlight Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawHighlightLayer( QPainter* painter )
|
||||
{
|
||||
///
|
||||
/// Draw Highlight Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawHighlightLayer( QPainter* painter )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
foreach ( LabelModelObject* object, mModel->objectList() )
|
||||
@@ -1176,15 +1177,15 @@ LabelEditor::drawHighlightLayer( QPainter* painter )
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Select Region Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawSelectRegionLayer( QPainter* painter )
|
||||
{
|
||||
///
|
||||
/// Draw Select Region Layer
|
||||
///
|
||||
void
|
||||
LabelEditor::drawSelectRegionLayer( QPainter* painter )
|
||||
{
|
||||
if ( mSelectRegionVisible )
|
||||
{
|
||||
painter->save();
|
||||
@@ -1199,25 +1200,25 @@ LabelEditor::drawSelectRegionLayer( QPainter* painter )
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Settings changed handler
|
||||
///
|
||||
void LabelEditor::onSettingsChanged()
|
||||
{
|
||||
glabels::Units units = Settings::units();
|
||||
///
|
||||
/// Settings changed handler
|
||||
///
|
||||
void LabelEditor::onSettingsChanged()
|
||||
{
|
||||
Units units = Settings::units();
|
||||
|
||||
mStepSize = glabels::Distance( units.resolution(), units );
|
||||
}
|
||||
mStepSize = Distance( units.resolution(), units );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Model size changed handler
|
||||
///
|
||||
void LabelEditor::onModelSizeChanged()
|
||||
{
|
||||
///
|
||||
/// Model size changed handler
|
||||
///
|
||||
void LabelEditor::onModelSizeChanged()
|
||||
{
|
||||
if (mZoomToFitFlag)
|
||||
{
|
||||
double wPixels = mScrollArea->maximumViewportSize().width();
|
||||
@@ -1247,4 +1248,6 @@ void LabelEditor::onModelSizeChanged()
|
||||
update();
|
||||
|
||||
emit zoomChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+39
-33
@@ -28,34 +28,38 @@
|
||||
|
||||
#include "Region.h"
|
||||
|
||||
// Forward References
|
||||
class LabelModel;
|
||||
class LabelModelObject;
|
||||
class UndoRedoModel;
|
||||
class Handle;
|
||||
|
||||
|
||||
///
|
||||
/// LabelEditor Widget
|
||||
///
|
||||
class LabelEditor : public QWidget
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class LabelModel;
|
||||
class LabelModelObject;
|
||||
class UndoRedoModel;
|
||||
class Handle;
|
||||
|
||||
|
||||
///
|
||||
/// LabelEditor Widget
|
||||
///
|
||||
class LabelEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////////
|
||||
// Lifecycle
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
LabelEditor( QScrollArea* scrollArea, QWidget* parent = 0 );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void contextMenuActivate();
|
||||
void zoomChanged();
|
||||
void pointerMoved( const glabels::Distance& x, const glabels::Distance& y );
|
||||
void pointerMoved( const Distance& x, const Distance& y );
|
||||
void pointerExited();
|
||||
void modeChanged();
|
||||
|
||||
@@ -63,7 +67,7 @@ signals:
|
||||
/////////////////////////////////////
|
||||
// Parameters
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
double zoom() const;
|
||||
bool markupVisible() const;
|
||||
bool qridVisible() const;
|
||||
@@ -72,14 +76,14 @@ public:
|
||||
/////////////////////////////////////
|
||||
// Model
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Visibility operations
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void setGridVisible( bool visibleFlag );
|
||||
void setMarkupVisible( bool visibleFlag );
|
||||
|
||||
@@ -87,21 +91,21 @@ public:
|
||||
/////////////////////////////////////
|
||||
// Zoom operations
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void zoom1To1();
|
||||
void zoomToFit();
|
||||
bool isZoomMax() const;
|
||||
bool isZoomMin() const;
|
||||
private:
|
||||
private:
|
||||
void setZoomReal( double zoom, bool zoomToFitFlag );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Mode operations
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void arrowMode();
|
||||
void createBoxMode();
|
||||
void createEllipseMode();
|
||||
@@ -114,7 +118,7 @@ public:
|
||||
/////////////////////////////////////
|
||||
// Event handlers
|
||||
/////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
void resizeEvent( QResizeEvent* event );
|
||||
void mousePressEvent( QMouseEvent* event );
|
||||
void mouseMoveEvent( QMouseEvent* event );
|
||||
@@ -127,9 +131,9 @@ protected:
|
||||
/////////////////////////////////////
|
||||
// Private methods
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
void handleResizeMotion( const glabels::Distance& xWorld,
|
||||
const glabels::Distance& yWorld );
|
||||
private:
|
||||
void handleResizeMotion( const Distance& xWorld,
|
||||
const Distance& yWorld );
|
||||
|
||||
void drawBgLayer( QPainter* painter );
|
||||
void drawGridLayer( QPainter* painter );
|
||||
@@ -143,7 +147,7 @@ private:
|
||||
/////////////////////////////////////
|
||||
// Private slots
|
||||
/////////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onSettingsChanged();
|
||||
void onModelSizeChanged();
|
||||
|
||||
@@ -151,7 +155,7 @@ private slots:
|
||||
/////////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
enum State {
|
||||
IdleState,
|
||||
ArrowSelectRegion,
|
||||
@@ -175,14 +179,14 @@ private:
|
||||
double mZoom;
|
||||
bool mZoomToFitFlag;
|
||||
double mScale;
|
||||
glabels::Distance mX0;
|
||||
glabels::Distance mY0;
|
||||
Distance mX0;
|
||||
Distance mY0;
|
||||
|
||||
bool mMarkupVisible;
|
||||
bool mGridVisible;
|
||||
|
||||
double mGridSpacing;
|
||||
glabels::Distance mStepSize;
|
||||
Distance mStepSize;
|
||||
|
||||
LabelModel* mModel;
|
||||
UndoRedoModel* mUndoRedoModel;
|
||||
@@ -194,8 +198,8 @@ private:
|
||||
Region mSelectRegion;
|
||||
|
||||
/* ArrowMove state */
|
||||
glabels::Distance mMoveLastX;
|
||||
glabels::Distance mMoveLastY;
|
||||
Distance mMoveLastX;
|
||||
Distance mMoveLastY;
|
||||
|
||||
/* ArrowResize state */
|
||||
LabelModelObject* mResizeObject;
|
||||
@@ -205,11 +209,13 @@ private:
|
||||
/* CreateDrag state */
|
||||
CreateType mCreateObjectType;
|
||||
LabelModelObject* mCreateObject;
|
||||
glabels::Distance mCreateX0;
|
||||
glabels::Distance mCreateY0;
|
||||
Distance mCreateX0;
|
||||
Distance mCreateY0;
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelEditor_h
|
||||
|
||||
+509
-501
File diff suppressed because it is too large
Load Diff
+40
-37
@@ -32,27 +32,28 @@
|
||||
#include "Merge/Merge.h"
|
||||
#include "Merge/Record.h"
|
||||
|
||||
// Forward References
|
||||
class ColorNode;
|
||||
class Handle;
|
||||
class LabelModelObject;
|
||||
class Region;
|
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
//////////////////////////////////////////////
|
||||
// LabelModel
|
||||
//////////////////////////////////////////////
|
||||
//////////////////////////////////////////////
|
||||
class LabelModel : public QObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class ColorNode;
|
||||
class Handle;
|
||||
class LabelModelObject;
|
||||
class Region;
|
||||
|
||||
///
|
||||
/// LabelModel
|
||||
///
|
||||
class LabelModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Lifecycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
LabelModel();
|
||||
virtual ~LabelModel() {}
|
||||
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void changed();
|
||||
void nameChanged();
|
||||
void sizeChanged();
|
||||
@@ -81,7 +82,7 @@ signals:
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
bool isModified() const;
|
||||
void setModified();
|
||||
void clearModified();
|
||||
@@ -93,15 +94,15 @@ public:
|
||||
int compressionLevel() const;
|
||||
void setCompressionLevel( int compressionLevel );
|
||||
|
||||
const glabels::Template* tmplate() const;
|
||||
const glabels::Frame* frame() const;
|
||||
void setTmplate( const glabels::Template* tmplate );
|
||||
const Template* tmplate() const;
|
||||
const Frame* frame() const;
|
||||
void setTmplate( const Template* tmplate );
|
||||
|
||||
bool rotate() const;
|
||||
void setRotate( bool rotate );
|
||||
|
||||
glabels::Distance w() const;
|
||||
glabels::Distance h() const;
|
||||
Distance w() const;
|
||||
Distance h() const;
|
||||
|
||||
const QList<LabelModelObject*>& objectList() const;
|
||||
|
||||
@@ -112,23 +113,23 @@ public:
|
||||
/////////////////////////////////
|
||||
// Manage objects
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void addObject( LabelModelObject* object );
|
||||
void deleteObject( LabelModelObject* object );
|
||||
|
||||
LabelModelObject* objectAt( double scale,
|
||||
const glabels::Distance& x,
|
||||
const glabels::Distance& y ) const;
|
||||
const Distance& x,
|
||||
const Distance& y ) const;
|
||||
|
||||
Handle* handleAt( double scale,
|
||||
const glabels::Distance& x,
|
||||
const glabels::Distance& y ) const;
|
||||
const Distance& x,
|
||||
const Distance& y ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Manipulate selection
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void selectObject( LabelModelObject* object );
|
||||
void unselectObject( LabelModelObject* object );
|
||||
void selectAll();
|
||||
@@ -141,7 +142,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Get selected objects
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
QList<LabelModelObject*> getSelection();
|
||||
LabelModelObject* getFirstSelectedObject();
|
||||
|
||||
@@ -149,7 +150,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Query selection capabilities
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
bool canSelectionText();
|
||||
bool canSelectionFill();
|
||||
bool canSelectionLineColor();
|
||||
@@ -159,7 +160,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Operations on selections
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void deleteSelection();
|
||||
void raiseSelectionToTop();
|
||||
void lowerSelectionToBottom();
|
||||
@@ -176,7 +177,7 @@ public:
|
||||
void alignSelectionVCenter();
|
||||
void centerSelectionHoriz();
|
||||
void centerSelectionVert();
|
||||
void moveSelection( const glabels::Distance& dx, const glabels::Distance& dy );
|
||||
void moveSelection( const Distance& dx, const Distance& dy );
|
||||
void setSelectionFontFamily( const QString& fontFamily );
|
||||
void setSelectionFontSize( double fontSize );
|
||||
void setSelectionFontWeight( QFont::Weight fontWeight );
|
||||
@@ -185,7 +186,7 @@ public:
|
||||
void setSelectionTextVAlign( Qt::Alignment textVAlign );
|
||||
void setSelectionTextLineSpacing( double textLineSpacing );
|
||||
void setSelectionTextColorNode( ColorNode textColorNode );
|
||||
void setSelectionLineWidth( const glabels::Distance& lineWidth );
|
||||
void setSelectionLineWidth( const Distance& lineWidth );
|
||||
void setSelectionLineColorNode( ColorNode lineColorNode );
|
||||
void setSelectionFillColorNode( ColorNode fillColorNode );
|
||||
|
||||
@@ -201,14 +202,14 @@ public:
|
||||
/////////////////////////////////
|
||||
// Drawing operations
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void draw( QPainter* painter, bool inEditor = true, merge::Record* record = 0 ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onObjectChanged();
|
||||
void onObjectMoved();
|
||||
void onMergeSourceChanged();
|
||||
@@ -218,19 +219,21 @@ private slots:
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
int mUntitledInstance;
|
||||
bool mModified;
|
||||
QString mFileName;
|
||||
int mCompressionLevel;
|
||||
const glabels::Template* mTmplate;
|
||||
const glabels::Frame* mFrame;
|
||||
const Template* mTmplate;
|
||||
const Frame* mFrame;
|
||||
bool mRotate;
|
||||
|
||||
QList<LabelModelObject*> mObjectList;
|
||||
|
||||
merge::Merge* mMerge;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelModel_h
|
||||
|
||||
@@ -25,50 +25,60 @@
|
||||
#include <QPen>
|
||||
|
||||
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelBoxObject::LabelModelBoxObject()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelBoxObject::LabelModelBoxObject()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object ) : LabelModelShapeObject( object )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object )
|
||||
: LabelModelShapeObject( object )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelBoxObject::~LabelModelBoxObject()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelBoxObject::~LabelModelBoxObject()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelBoxObject* LabelModelBoxObject::clone() const
|
||||
{
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelBoxObject* LabelModelBoxObject::clone() const
|
||||
{
|
||||
return new LabelModelBoxObject( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
QColor shadowColor = mShadowColorNode.color( record );
|
||||
@@ -106,14 +116,14 @@ void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::R
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
|
||||
@@ -121,14 +131,14 @@ void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::R
|
||||
painter->setBrush( fillColor );
|
||||
|
||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
|
||||
{
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
|
||||
{
|
||||
double s = 1 / scale;
|
||||
|
||||
QPainterPath path;
|
||||
@@ -155,4 +165,6 @@ QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,17 +25,20 @@
|
||||
#include "LabelModelShapeObject.h"
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Box Object
|
||||
///
|
||||
class LabelModelBoxObject : public LabelModelShapeObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Box Object
|
||||
///
|
||||
class LabelModelBoxObject : public LabelModelShapeObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
LabelModelBoxObject();
|
||||
LabelModelBoxObject( const LabelModelBoxObject* object );
|
||||
virtual ~LabelModelBoxObject();
|
||||
@@ -50,12 +53,14 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual QPainterPath hoverPath( double scale ) const;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelModelBoxObject_h
|
||||
|
||||
@@ -25,50 +25,60 @@
|
||||
#include <QPen>
|
||||
|
||||
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelEllipseObject::LabelModelEllipseObject()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelEllipseObject::LabelModelEllipseObject()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject* object ) : LabelModelShapeObject( object )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject* object )
|
||||
: LabelModelShapeObject( object )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelEllipseObject::~LabelModelEllipseObject()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelEllipseObject::~LabelModelEllipseObject()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelEllipseObject* LabelModelEllipseObject::clone() const
|
||||
{
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelEllipseObject* LabelModelEllipseObject::clone() const
|
||||
{
|
||||
return new LabelModelEllipseObject( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
QColor shadowColor = mShadowColorNode.color( record );
|
||||
@@ -106,14 +116,14 @@ void LabelModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merg
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
|
||||
@@ -121,14 +131,14 @@ void LabelModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merg
|
||||
painter->setBrush( fillColor );
|
||||
|
||||
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
|
||||
{
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
|
||||
{
|
||||
double s = 1 / scale;
|
||||
|
||||
QPainterPath path;
|
||||
@@ -155,4 +165,6 @@ QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,17 +25,20 @@
|
||||
#include "LabelModelShapeObject.h"
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Ellipse Object
|
||||
///
|
||||
class LabelModelEllipseObject : public LabelModelShapeObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Ellipse Object
|
||||
///
|
||||
class LabelModelEllipseObject : public LabelModelShapeObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
LabelModelEllipseObject();
|
||||
LabelModelEllipseObject( const LabelModelEllipseObject* object );
|
||||
virtual ~LabelModelEllipseObject();
|
||||
@@ -50,12 +53,14 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual QPainterPath hoverPath( double scale ) const;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelModelEllipseObject_h
|
||||
|
||||
@@ -30,22 +30,20 @@
|
||||
#include "Size.h"
|
||||
|
||||
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
}
|
||||
|
||||
///
|
||||
/// Static data
|
||||
///
|
||||
QImage* LabelModelImageObject::smDefaultImage = 0;
|
||||
|
||||
|
||||
///
|
||||
/// Static data
|
||||
///
|
||||
QImage* LabelModelImageObject::smDefaultImage = 0;
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelImageObject::LabelModelImageObject() : mImage(0), mSvg(0)
|
||||
{
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelImageObject::LabelModelImageObject() : mImage(0), mSvg(0)
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mHandles << new HandleNorthWest( this );
|
||||
@@ -61,23 +59,23 @@ LabelModelImageObject::LabelModelImageObject() : mImage(0), mSvg(0)
|
||||
{
|
||||
smDefaultImage = new QImage( ":images/checkerboard.png" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelImageObject::LabelModelImageObject( const LabelModelImageObject* object ) : LabelModelObject(object)
|
||||
{
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelImageObject::LabelModelImageObject( const LabelModelImageObject* object ) : LabelModelObject(object)
|
||||
{
|
||||
mFilenameNode = object->mFilenameNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelImageObject::~LabelModelImageObject()
|
||||
{
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelImageObject::~LabelModelImageObject()
|
||||
{
|
||||
delete mOutline;
|
||||
|
||||
foreach( Handle* handle, mHandles )
|
||||
@@ -85,32 +83,32 @@ LabelModelImageObject::~LabelModelImageObject()
|
||||
delete handle;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelImageObject* LabelModelImageObject::clone() const
|
||||
{
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelImageObject* LabelModelImageObject::clone() const
|
||||
{
|
||||
return new LabelModelImageObject( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Image filenameNode Property Getter
|
||||
///
|
||||
TextNode LabelModelImageObject::filenameNode( void ) const
|
||||
{
|
||||
///
|
||||
/// Image filenameNode Property Getter
|
||||
///
|
||||
TextNode LabelModelImageObject::filenameNode( void ) const
|
||||
{
|
||||
return mFilenameNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Image filenameNode Property Setter
|
||||
///
|
||||
void LabelModelImageObject::setFilenameNode( const TextNode& value )
|
||||
{
|
||||
///
|
||||
/// Image filenameNode Property Setter
|
||||
///
|
||||
void LabelModelImageObject::setFilenameNode( const TextNode& value )
|
||||
{
|
||||
if ( mFilenameNode != value )
|
||||
{
|
||||
mFilenameNode = value;
|
||||
@@ -118,38 +116,38 @@ void LabelModelImageObject::setFilenameNode( const TextNode& value )
|
||||
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Image originalSize Property Getter (assumes 72 DPI, i.e. 1pixel == 1pt)
|
||||
///
|
||||
Size LabelModelImageObject::originalSize() const
|
||||
{
|
||||
Size size( glabels::Distance::pt(72), glabels::Distance::pt(72) );
|
||||
///
|
||||
/// Image originalSize Property Getter (assumes 72 DPI, i.e. 1pixel == 1pt)
|
||||
///
|
||||
Size LabelModelImageObject::originalSize() const
|
||||
{
|
||||
Size size( Distance::pt(72), Distance::pt(72) );
|
||||
|
||||
if ( mImage )
|
||||
{
|
||||
QSize qsize = mImage->size();
|
||||
size.setW( glabels::Distance::pt( qsize.width() ) );
|
||||
size.setH( glabels::Distance::pt( qsize.height() ) );
|
||||
size.setW( Distance::pt( qsize.width() ) );
|
||||
size.setH( Distance::pt( qsize.height() ) );
|
||||
}
|
||||
else if ( mSvg )
|
||||
{
|
||||
QSize qsize = mSvg->defaultSize();
|
||||
size.setW( glabels::Distance::pt( qsize.width() ) );
|
||||
size.setH( glabels::Distance::pt( qsize.height() ) );
|
||||
size.setW( Distance::pt( qsize.width() ) );
|
||||
size.setH( Distance::pt( qsize.height() ) );
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
||||
|
||||
QColor shadowColor = mShadowColorNode.color( record );
|
||||
@@ -171,14 +169,14 @@ void LabelModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge:
|
||||
painter->drawRect( destRect );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelImageObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelImageObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
||||
|
||||
if ( inEditor && (mFilenameNode.isField() || (!mImage && !mSvg) ) )
|
||||
@@ -200,26 +198,26 @@ void LabelModelImageObject::drawObject( QPainter* painter, bool inEditor, merge:
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelImageObject::hoverPath( double scale ) const
|
||||
{
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelImageObject::hoverPath( double scale ) const
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Load image
|
||||
///
|
||||
void LabelModelImageObject::loadImage()
|
||||
{
|
||||
///
|
||||
/// Load image
|
||||
///
|
||||
void LabelModelImageObject::loadImage()
|
||||
{
|
||||
if ( mImage )
|
||||
{
|
||||
delete mImage;
|
||||
@@ -288,14 +286,14 @@ void LabelModelImageObject::loadImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create shadow image
|
||||
///
|
||||
QImage* LabelModelImageObject::createShadowImage( const QColor& color ) const
|
||||
{
|
||||
///
|
||||
/// Create shadow image
|
||||
///
|
||||
QImage* LabelModelImageObject::createShadowImage( const QColor& color ) const
|
||||
{
|
||||
int r = color.red();
|
||||
int g = color.green();
|
||||
int b = color.blue();
|
||||
@@ -313,4 +311,6 @@ QImage* LabelModelImageObject::createShadowImage( const QColor& color ) const
|
||||
}
|
||||
|
||||
return shadow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,17 +27,20 @@
|
||||
#include "LabelModelObject.h"
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Image Object
|
||||
///
|
||||
class LabelModelImageObject : public LabelModelObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Image Object
|
||||
///
|
||||
class LabelModelImageObject : public LabelModelObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
LabelModelImageObject();
|
||||
LabelModelImageObject( const LabelModelImageObject* object );
|
||||
virtual ~LabelModelImageObject();
|
||||
@@ -52,7 +55,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Image Property: filenameNode
|
||||
//
|
||||
@@ -73,7 +76,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual QPainterPath hoverPath( double scale ) const;
|
||||
@@ -89,14 +92,16 @@ protected:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
TextNode mFilenameNode;
|
||||
QImage* mImage;
|
||||
QSvgRenderer* mSvg;
|
||||
|
||||
static QImage* smDefaultImage;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelModelImageObject_h
|
||||
|
||||
@@ -25,17 +25,23 @@
|
||||
#include <QPen>
|
||||
|
||||
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelLineObject::LabelModelLineObject()
|
||||
{
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelLineObject::LabelModelLineObject()
|
||||
{
|
||||
mOutline = 0;
|
||||
|
||||
mHandles << new HandleP1( this );
|
||||
@@ -43,108 +49,109 @@ LabelModelLineObject::LabelModelLineObject()
|
||||
|
||||
mLineWidth = 1.0;
|
||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelLineObject::LabelModelLineObject( const LabelModelLineObject* object ) : LabelModelObject(object)
|
||||
{
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelLineObject::LabelModelLineObject( const LabelModelLineObject* object )
|
||||
: LabelModelObject(object)
|
||||
{
|
||||
mLineWidth = object->mLineWidth;
|
||||
mLineColorNode = object->mLineColorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelLineObject::~LabelModelLineObject()
|
||||
{
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelLineObject::~LabelModelLineObject()
|
||||
{
|
||||
foreach( Handle* handle, mHandles )
|
||||
{
|
||||
delete handle;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelLineObject* LabelModelLineObject::clone() const
|
||||
{
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelLineObject* LabelModelLineObject::clone() const
|
||||
{
|
||||
return new LabelModelLineObject( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Width Property Getter
|
||||
///
|
||||
glabels::Distance LabelModelLineObject::lineWidth( void ) const
|
||||
{
|
||||
///
|
||||
/// Line Width Property Getter
|
||||
///
|
||||
Distance LabelModelLineObject::lineWidth( void ) const
|
||||
{
|
||||
return mLineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Width Property Setter
|
||||
///
|
||||
void LabelModelLineObject::setLineWidth( const glabels::Distance& value )
|
||||
{
|
||||
///
|
||||
/// Line Width Property Setter
|
||||
///
|
||||
void LabelModelLineObject::setLineWidth( const Distance& value )
|
||||
{
|
||||
if ( mLineWidth != value )
|
||||
{
|
||||
mLineWidth = value;
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Color Node Property Getter
|
||||
///
|
||||
ColorNode LabelModelLineObject::lineColorNode( void ) const
|
||||
{
|
||||
///
|
||||
/// Line Color Node Property Getter
|
||||
///
|
||||
ColorNode LabelModelLineObject::lineColorNode( void ) const
|
||||
{
|
||||
return mLineColorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Color Node Property Setter
|
||||
///
|
||||
void LabelModelLineObject::setLineColorNode( const ColorNode& value )
|
||||
{
|
||||
///
|
||||
/// Line Color Node Property Setter
|
||||
///
|
||||
void LabelModelLineObject::setLineColorNode( const ColorNode& value )
|
||||
{
|
||||
if ( mLineColorNode != value )
|
||||
{
|
||||
mLineColorNode = value;
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Can Line Color Capability Implementation
|
||||
///
|
||||
bool LabelModelLineObject::canLineColor()
|
||||
{
|
||||
///
|
||||
/// Can Line Color Capability Implementation
|
||||
///
|
||||
bool LabelModelLineObject::canLineColor()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Can Line Width Capability Implementation
|
||||
///
|
||||
bool LabelModelLineObject::canLineWidth()
|
||||
{
|
||||
///
|
||||
/// Can Line Width Capability Implementation
|
||||
///
|
||||
bool LabelModelLineObject::canLineWidth()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelLineObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelLineObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor shadowColor = mShadowColorNode.color( record );
|
||||
|
||||
@@ -155,26 +162,26 @@ void LabelModelLineObject::drawShadow( QPainter* painter, bool inEditor, merge::
|
||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelLineObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelLineObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
|
||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelLineObject::hoverPath( double scale ) const
|
||||
{
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelLineObject::hoverPath( double scale ) const
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
if ( mLineColorNode.color().alpha() )
|
||||
@@ -197,4 +204,6 @@ QPainterPath LabelModelLineObject::hoverPath( double scale ) const
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,17 +25,20 @@
|
||||
#include "LabelModelObject.h"
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class LabelModelLineObject : public LabelModelObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class LabelModelLineObject : public LabelModelObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
LabelModelLineObject();
|
||||
LabelModelLineObject( const LabelModelLineObject* object );
|
||||
virtual ~LabelModelLineObject();
|
||||
@@ -50,12 +53,12 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Line Property: lineWidth
|
||||
//
|
||||
virtual glabels::Distance lineWidth( void ) const;
|
||||
virtual void setLineWidth( const glabels::Distance& value );
|
||||
virtual Distance lineWidth( void ) const;
|
||||
virtual void setLineWidth( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
@@ -68,7 +71,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual bool canLineColor();
|
||||
virtual bool canLineWidth();
|
||||
|
||||
@@ -76,7 +79,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual QPainterPath hoverPath( double scale ) const;
|
||||
@@ -85,11 +88,13 @@ protected:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
glabels::Distance mLineWidth;
|
||||
protected:
|
||||
Distance mLineWidth;
|
||||
ColorNode mLineColorNode;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelModelLineObject_h
|
||||
|
||||
+623
-598
File diff suppressed because it is too large
Load Diff
+57
-52
@@ -37,25 +37,28 @@
|
||||
#include "Merge/Record.h"
|
||||
|
||||
|
||||
// Forward References
|
||||
class Region;
|
||||
class Size;
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Object Base Class
|
||||
///
|
||||
class LabelModelObject : public QObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class Region;
|
||||
class Size;
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Object Base Class
|
||||
///
|
||||
class LabelModelObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
LabelModelObject();
|
||||
LabelModelObject( const LabelModelObject* object );
|
||||
public:
|
||||
public:
|
||||
virtual ~LabelModelObject();
|
||||
|
||||
|
||||
@@ -68,7 +71,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Signals
|
||||
///////////////////////////////////////////////////////////////
|
||||
signals:
|
||||
signals:
|
||||
void moved();
|
||||
void changed();
|
||||
|
||||
@@ -76,7 +79,7 @@ signals:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Common Properties
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// ID Property.
|
||||
//
|
||||
@@ -93,29 +96,29 @@ public:
|
||||
//
|
||||
// x0 Property ( x coordinate of origin )
|
||||
//
|
||||
glabels::Distance x0() const;
|
||||
void setX0( const glabels::Distance& value );
|
||||
Distance x0() const;
|
||||
void setX0( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// y0 Property ( y coordinate of origin )
|
||||
//
|
||||
glabels::Distance y0() const;
|
||||
void setY0( const glabels::Distance& value );
|
||||
Distance y0() const;
|
||||
void setY0( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// w Property ( width of bounding box )
|
||||
//
|
||||
glabels::Distance w() const;
|
||||
void setW( const glabels::Distance& value );
|
||||
Distance w() const;
|
||||
void setW( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// h Property ( height of bounding box )
|
||||
//
|
||||
glabels::Distance h() const;
|
||||
void setH( const glabels::Distance& value );
|
||||
Distance h() const;
|
||||
void setH( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
@@ -135,15 +138,15 @@ public:
|
||||
//
|
||||
// Shadow x Offset Property
|
||||
//
|
||||
glabels::Distance shadowX() const;
|
||||
void setShadowX( const glabels::Distance& value );
|
||||
Distance shadowX() const;
|
||||
void setShadowX( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Shadow y Offset Property
|
||||
//
|
||||
glabels::Distance shadowY() const;
|
||||
void setShadowY( const glabels::Distance& value );
|
||||
Distance shadowY() const;
|
||||
void setShadowY( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
@@ -163,7 +166,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Text Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Virtual Text Property: text
|
||||
//
|
||||
@@ -237,7 +240,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Image Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Virtual Image Property: filenameNode
|
||||
//
|
||||
@@ -253,12 +256,12 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Shape Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Virtual Shape Property: lineWidth
|
||||
//
|
||||
virtual glabels::Distance lineWidth() const;
|
||||
virtual void setLineWidth( const glabels::Distance& value );
|
||||
virtual Distance lineWidth() const;
|
||||
virtual void setLineWidth( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
@@ -278,7 +281,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Barcode Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Virtual Barcode Property: bcDataNode
|
||||
//
|
||||
@@ -324,7 +327,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capabilities (Overridden by concrete classes.)
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual bool canText() const;
|
||||
virtual bool canFill() const;
|
||||
virtual bool canLineColor() const;
|
||||
@@ -334,31 +337,31 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Position and Size methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
void setPosition( const glabels::Distance& x0, const glabels::Distance& y0 );
|
||||
void setPositionRelative( const glabels::Distance& dx, const glabels::Distance& dy );
|
||||
public:
|
||||
void setPosition( const Distance& x0, const Distance& y0 );
|
||||
void setPositionRelative( const Distance& dx, const Distance& dy );
|
||||
Size size() const;
|
||||
void setSize( const glabels::Distance& w, const glabels::Distance& h );
|
||||
void setSize( const Distance& w, const Distance& h );
|
||||
void setSize( const Size& size );
|
||||
void setSizeHonorAspect( const glabels::Distance& w, const glabels::Distance& h );
|
||||
void setWHonorAspect( const glabels::Distance& w );
|
||||
void setHHonorAspect( const glabels::Distance& h );
|
||||
void setSizeHonorAspect( const Distance& w, const Distance& h );
|
||||
void setWHonorAspect( const Distance& w );
|
||||
void setHHonorAspect( const Distance& h );
|
||||
Region getExtent();
|
||||
void rotate( double thetaDegs );
|
||||
void flipHoriz();
|
||||
void flipVert();
|
||||
bool isLocatedAt( double scale, const glabels::Distance& x, const glabels::Distance& y ) const;
|
||||
Handle* handleAt( double scale, const glabels::Distance& x, const glabels::Distance& y ) const;
|
||||
bool isLocatedAt( double scale, const Distance& x, const Distance& y ) const;
|
||||
Handle* handleAt( double scale, const Distance& x, const Distance& y ) const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||
virtual QPainterPath hoverPath( double scale ) const = 0;
|
||||
@@ -369,17 +372,17 @@ protected:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Protected Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
bool mSelectedFlag;
|
||||
|
||||
glabels::Distance mX0;
|
||||
glabels::Distance mY0;
|
||||
glabels::Distance mW;
|
||||
glabels::Distance mH;
|
||||
Distance mX0;
|
||||
Distance mY0;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
|
||||
bool mShadowState;
|
||||
glabels::Distance mShadowX;
|
||||
glabels::Distance mShadowY;
|
||||
Distance mShadowX;
|
||||
Distance mShadowY;
|
||||
double mShadowOpacity;
|
||||
ColorNode mShadowColorNode;
|
||||
|
||||
@@ -390,13 +393,15 @@ protected:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
static int msNextId;
|
||||
int mId;
|
||||
|
||||
QMatrix mMatrix;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelModelObject_h
|
||||
|
||||
@@ -25,11 +25,14 @@
|
||||
#include <QPen>
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelShapeObject::LabelModelShapeObject()
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelShapeObject::LabelModelShapeObject()
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mHandles << new HandleNorthWest( this );
|
||||
@@ -44,25 +47,25 @@ LabelModelShapeObject::LabelModelShapeObject()
|
||||
mLineWidth = 1.0;
|
||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelShapeObject::LabelModelShapeObject( const LabelModelShapeObject* object ) : LabelModelObject(object)
|
||||
{
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelShapeObject::LabelModelShapeObject( const LabelModelShapeObject* object ) : LabelModelObject(object)
|
||||
{
|
||||
mLineWidth = object->mLineWidth;
|
||||
mLineColorNode = object->mLineColorNode;
|
||||
mFillColorNode = object->mFillColorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelShapeObject::~LabelModelShapeObject()
|
||||
{
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelShapeObject::~LabelModelShapeObject()
|
||||
{
|
||||
delete mOutline;
|
||||
|
||||
foreach( Handle* handle, mHandles )
|
||||
@@ -70,97 +73,99 @@ LabelModelShapeObject::~LabelModelShapeObject()
|
||||
delete handle;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Width Property Getter
|
||||
///
|
||||
glabels::Distance LabelModelShapeObject::lineWidth( void ) const
|
||||
{
|
||||
///
|
||||
/// Line Width Property Getter
|
||||
///
|
||||
Distance LabelModelShapeObject::lineWidth( void ) const
|
||||
{
|
||||
return mLineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Width Property Setter
|
||||
///
|
||||
void LabelModelShapeObject::setLineWidth( const glabels::Distance& value )
|
||||
{
|
||||
///
|
||||
/// Line Width Property Setter
|
||||
///
|
||||
void LabelModelShapeObject::setLineWidth( const Distance& value )
|
||||
{
|
||||
if ( mLineWidth != value )
|
||||
{
|
||||
mLineWidth = value;
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Color Node Property Getter
|
||||
///
|
||||
ColorNode LabelModelShapeObject::lineColorNode( void ) const
|
||||
{
|
||||
///
|
||||
/// Line Color Node Property Getter
|
||||
///
|
||||
ColorNode LabelModelShapeObject::lineColorNode( void ) const
|
||||
{
|
||||
return mLineColorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Color Node Property Setter
|
||||
///
|
||||
void LabelModelShapeObject::setLineColorNode( const ColorNode& value )
|
||||
{
|
||||
///
|
||||
/// 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
|
||||
{
|
||||
///
|
||||
/// Fill Color Node Property Getter
|
||||
///
|
||||
ColorNode LabelModelShapeObject::fillColorNode( void ) const
|
||||
{
|
||||
return mFillColorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Fill Color Node Property Setter
|
||||
///
|
||||
void LabelModelShapeObject::setFillColorNode( const ColorNode& value )
|
||||
{
|
||||
///
|
||||
/// 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()
|
||||
{
|
||||
///
|
||||
/// Can Fill Capability Implementation
|
||||
///
|
||||
bool LabelModelShapeObject::canFill()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Can Line Color Capability Implementation
|
||||
///
|
||||
bool LabelModelShapeObject::canLineColor()
|
||||
{
|
||||
///
|
||||
/// Can Line Color Capability Implementation
|
||||
///
|
||||
bool LabelModelShapeObject::canLineColor()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Can Line Width Capability Implementation
|
||||
///
|
||||
bool LabelModelShapeObject::canLineWidth()
|
||||
{
|
||||
///
|
||||
/// Can Line Width Capability Implementation
|
||||
///
|
||||
bool LabelModelShapeObject::canLineWidth()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,32 +25,35 @@
|
||||
#include "LabelModelObject.h"
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Shape Object (Box or Ellipse)
|
||||
///
|
||||
class LabelModelShapeObject : public LabelModelObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Shape Object (Box or Ellipse)
|
||||
///
|
||||
class LabelModelShapeObject : public LabelModelObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
LabelModelShapeObject();
|
||||
LabelModelShapeObject( const LabelModelShapeObject* object );
|
||||
public:
|
||||
public:
|
||||
virtual ~LabelModelShapeObject();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Shape Property: lineWidth
|
||||
//
|
||||
virtual glabels::Distance lineWidth( void ) const;
|
||||
virtual void setLineWidth( const glabels::Distance& value );
|
||||
virtual Distance lineWidth( void ) const;
|
||||
virtual void setLineWidth( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
@@ -70,7 +73,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual bool canFill();
|
||||
virtual bool canLineColor();
|
||||
virtual bool canLineWidth();
|
||||
@@ -79,12 +82,14 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
glabels::Distance mLineWidth;
|
||||
protected:
|
||||
Distance mLineWidth;
|
||||
ColorNode mLineColorNode;
|
||||
ColorNode mFillColorNode;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelModelShapeObject_h
|
||||
|
||||
+215
-200
@@ -29,17 +29,23 @@
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const double marginPts = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelTextObject::LabelModelTextObject()
|
||||
{
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
LabelModelTextObject::LabelModelTextObject()
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mHandles << new HandleNorthWest( this );
|
||||
@@ -61,14 +67,15 @@ LabelModelTextObject::LabelModelTextObject()
|
||||
mTextHAlign = Qt::AlignLeft;
|
||||
mTextVAlign = Qt::AlignTop;
|
||||
mTextLineSpacing = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelTextObject::LabelModelTextObject( const LabelModelTextObject* object ) : LabelModelObject(object)
|
||||
{
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
LabelModelTextObject::LabelModelTextObject( const LabelModelTextObject* object )
|
||||
: LabelModelObject(object)
|
||||
{
|
||||
mText = object->mText;
|
||||
mFontFamily = object->mFontFamily;
|
||||
mFontSize = object->mFontSize;
|
||||
@@ -79,14 +86,14 @@ LabelModelTextObject::LabelModelTextObject( const LabelModelTextObject* object )
|
||||
mTextHAlign = object->mTextHAlign;
|
||||
mTextVAlign = object->mTextVAlign;
|
||||
mTextLineSpacing = object->mTextLineSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelTextObject::~LabelModelTextObject()
|
||||
{
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
LabelModelTextObject::~LabelModelTextObject()
|
||||
{
|
||||
delete mOutline;
|
||||
|
||||
foreach( Handle* handle, mHandles )
|
||||
@@ -94,262 +101,264 @@ LabelModelTextObject::~LabelModelTextObject()
|
||||
delete handle;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelTextObject* LabelModelTextObject::clone() const
|
||||
{
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
LabelModelTextObject* LabelModelTextObject::clone() const
|
||||
{
|
||||
return new LabelModelTextObject( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Text Property Getter
|
||||
///
|
||||
QString LabelModelTextObject::text( void ) const
|
||||
{
|
||||
///
|
||||
/// Text Property Getter
|
||||
///
|
||||
QString LabelModelTextObject::text( void ) const
|
||||
{
|
||||
return mText;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Text Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setText( const QString& value )
|
||||
{
|
||||
///
|
||||
/// Text Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setText( const QString& value )
|
||||
{
|
||||
if ( mText != value )
|
||||
{
|
||||
mText = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontFamily Property Getter
|
||||
///
|
||||
QString LabelModelTextObject::fontFamily( void ) const
|
||||
{
|
||||
///
|
||||
/// FontFamily Property Getter
|
||||
///
|
||||
QString LabelModelTextObject::fontFamily( void ) const
|
||||
{
|
||||
return mFontFamily;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontFamily Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontFamily( const QString& value )
|
||||
{
|
||||
///
|
||||
/// FontFamily Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontFamily( const QString& value )
|
||||
{
|
||||
if ( mFontFamily != value )
|
||||
{
|
||||
mFontFamily = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontSize Property Getter
|
||||
///
|
||||
double LabelModelTextObject::fontSize( void ) const
|
||||
{
|
||||
///
|
||||
/// FontSize Property Getter
|
||||
///
|
||||
double LabelModelTextObject::fontSize( void ) const
|
||||
{
|
||||
return mFontSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontSize Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontSize( double value )
|
||||
{
|
||||
///
|
||||
/// FontSize Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontSize( double value )
|
||||
{
|
||||
if ( mFontSize != value )
|
||||
{
|
||||
mFontSize = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontWeight Property Getter
|
||||
///
|
||||
QFont::Weight LabelModelTextObject::fontWeight( void ) const
|
||||
{
|
||||
///
|
||||
/// FontWeight Property Getter
|
||||
///
|
||||
QFont::Weight LabelModelTextObject::fontWeight( void ) const
|
||||
{
|
||||
return mFontWeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontWeight Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontWeight( QFont::Weight value )
|
||||
{
|
||||
///
|
||||
/// FontWeight Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontWeight( QFont::Weight value )
|
||||
{
|
||||
if ( mFontWeight != value )
|
||||
{
|
||||
mFontWeight = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontItalicFlag Property Getter
|
||||
///
|
||||
bool LabelModelTextObject::fontItalicFlag( void ) const
|
||||
{
|
||||
///
|
||||
/// FontItalicFlag Property Getter
|
||||
///
|
||||
bool LabelModelTextObject::fontItalicFlag( void ) const
|
||||
{
|
||||
return mFontItalicFlag;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontItalicFlag Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontItalicFlag( bool value )
|
||||
{
|
||||
///
|
||||
/// FontItalicFlag Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontItalicFlag( bool value )
|
||||
{
|
||||
if ( mFontItalicFlag != value )
|
||||
{
|
||||
mFontItalicFlag = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontUnderlineFlag Property Getter
|
||||
///
|
||||
bool LabelModelTextObject::fontUnderlineFlag( void ) const
|
||||
{
|
||||
///
|
||||
/// FontUnderlineFlag Property Getter
|
||||
///
|
||||
bool LabelModelTextObject::fontUnderlineFlag( void ) const
|
||||
{
|
||||
return mFontUnderlineFlag;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// FontUnderlineFlag Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontUnderlineFlag( bool value )
|
||||
{
|
||||
///
|
||||
/// FontUnderlineFlag Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setFontUnderlineFlag( bool value )
|
||||
{
|
||||
if ( mFontUnderlineFlag != value )
|
||||
{
|
||||
mFontUnderlineFlag = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Text Color Node Property Getter
|
||||
///
|
||||
ColorNode LabelModelTextObject::textColorNode( void ) const
|
||||
{
|
||||
///
|
||||
/// Text Color Node Property Getter
|
||||
///
|
||||
ColorNode LabelModelTextObject::textColorNode( void ) const
|
||||
{
|
||||
return mTextColorNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Text Color Node Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setTextColorNode( const ColorNode& value )
|
||||
{
|
||||
///
|
||||
/// Text Color Node Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setTextColorNode( const ColorNode& value )
|
||||
{
|
||||
if ( mTextColorNode != value )
|
||||
{
|
||||
mTextColorNode = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// TextHAlign Property Getter
|
||||
///
|
||||
Qt::Alignment LabelModelTextObject::textHAlign( void ) const
|
||||
{
|
||||
///
|
||||
/// TextHAlign Property Getter
|
||||
///
|
||||
Qt::Alignment LabelModelTextObject::textHAlign( void ) const
|
||||
{
|
||||
return mTextHAlign;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// TextHAlign Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setTextHAlign( Qt::Alignment value )
|
||||
{
|
||||
///
|
||||
/// TextHAlign Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setTextHAlign( Qt::Alignment value )
|
||||
{
|
||||
if ( mTextHAlign != value )
|
||||
{
|
||||
mTextHAlign = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// TextVAlign Property Getter
|
||||
///
|
||||
Qt::Alignment LabelModelTextObject::textVAlign( void ) const
|
||||
{
|
||||
///
|
||||
/// TextVAlign Property Getter
|
||||
///
|
||||
Qt::Alignment LabelModelTextObject::textVAlign( void ) const
|
||||
{
|
||||
return mTextVAlign;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// TextVAlign Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setTextVAlign( Qt::Alignment value )
|
||||
{
|
||||
///
|
||||
/// TextVAlign Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setTextVAlign( Qt::Alignment value )
|
||||
{
|
||||
if ( mTextVAlign != value )
|
||||
{
|
||||
mTextVAlign = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// TextLineSpacing Property Getter
|
||||
///
|
||||
double LabelModelTextObject::textLineSpacing( void ) const
|
||||
{
|
||||
///
|
||||
/// TextLineSpacing Property Getter
|
||||
///
|
||||
double LabelModelTextObject::textLineSpacing( void ) const
|
||||
{
|
||||
return mTextLineSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// TextLineSpacing Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setTextLineSpacing( double value )
|
||||
{
|
||||
///
|
||||
/// TextLineSpacing Property Setter
|
||||
///
|
||||
void LabelModelTextObject::setTextLineSpacing( double value )
|
||||
{
|
||||
if ( mTextLineSpacing != value )
|
||||
{
|
||||
mTextLineSpacing = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Can Text Capability Implementation
|
||||
///
|
||||
bool LabelModelTextObject::canText()
|
||||
{
|
||||
///
|
||||
/// Can Text Capability Implementation
|
||||
///
|
||||
bool LabelModelTextObject::canText()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelTextObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw shadow of object
|
||||
///
|
||||
void LabelModelTextObject::drawShadow( QPainter* painter,
|
||||
bool inEditor,
|
||||
merge::Record* record ) const
|
||||
{
|
||||
QColor textColor = mTextColorNode.color( record );
|
||||
|
||||
if ( textColor.alpha() )
|
||||
@@ -366,14 +375,16 @@ void LabelModelTextObject::drawShadow( QPainter* painter, bool inEditor, merge::
|
||||
drawText( painter, shadowColor, record );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelTextObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void LabelModelTextObject::drawObject( QPainter* painter,
|
||||
bool inEditor,
|
||||
merge::Record* record ) const
|
||||
{
|
||||
QColor textColor = mTextColorNode.color( record );
|
||||
|
||||
if ( inEditor )
|
||||
@@ -384,32 +395,32 @@ void LabelModelTextObject::drawObject( QPainter* painter, bool inEditor, merge::
|
||||
{
|
||||
drawText( painter, textColor, record );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelTextObject::hoverPath( double scale ) const
|
||||
{
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath LabelModelTextObject::hoverPath( double scale ) const
|
||||
{
|
||||
return mHoverPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Size updated
|
||||
///
|
||||
void LabelModelTextObject::sizeUpdated()
|
||||
{
|
||||
///
|
||||
/// Size updated
|
||||
///
|
||||
void LabelModelTextObject::sizeUpdated()
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Update cached information for editor view
|
||||
///
|
||||
void LabelModelTextObject::update()
|
||||
{
|
||||
///
|
||||
/// Update cached information for editor view
|
||||
///
|
||||
void LabelModelTextObject::update()
|
||||
{
|
||||
QFont font;
|
||||
font.setFamily( mFontFamily );
|
||||
font.setPointSizeF( mFontSize );
|
||||
@@ -486,14 +497,14 @@ void LabelModelTextObject::update()
|
||||
}
|
||||
|
||||
mHoverPath = hoverPath; // save new hover path
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw text in editor from cached information
|
||||
///
|
||||
void LabelModelTextObject::drawTextInEditor( QPainter* painter, const QColor& color ) const
|
||||
{
|
||||
///
|
||||
/// Draw text in editor from cached information
|
||||
///
|
||||
void LabelModelTextObject::drawTextInEditor( QPainter* painter, const QColor& color ) const
|
||||
{
|
||||
if ( mText.isEmpty() )
|
||||
{
|
||||
QColor mutedColor = color;
|
||||
@@ -509,15 +520,17 @@ void LabelModelTextObject::drawTextInEditor( QPainter* painter, const QColor& co
|
||||
{
|
||||
layout->draw( painter, QPointF( 0, 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw text in final printout or preview
|
||||
///
|
||||
void
|
||||
LabelModelTextObject::drawText( QPainter* painter, const QColor&color, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Draw text in final printout or preview
|
||||
///
|
||||
void
|
||||
LabelModelTextObject::drawText( QPainter* painter,
|
||||
const QColor& color,
|
||||
merge::Record* record ) const
|
||||
{
|
||||
QFont font;
|
||||
font.setFamily( mFontFamily );
|
||||
font.setPointSizeF( mFontSize );
|
||||
@@ -597,14 +610,14 @@ LabelModelTextObject::drawText( QPainter* painter, const QColor&color, merge::Re
|
||||
|
||||
// Cleanup
|
||||
qDeleteAll( layouts );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Expand text by replacing fields with their values from the given record
|
||||
///
|
||||
QString LabelModelTextObject::expandText( QString text, merge::Record* record ) const
|
||||
{
|
||||
///
|
||||
/// Expand text by replacing fields with their values from the given record
|
||||
///
|
||||
QString LabelModelTextObject::expandText( QString text, merge::Record* record ) const
|
||||
{
|
||||
if ( record )
|
||||
{
|
||||
foreach ( QString key, record->keys() )
|
||||
@@ -625,4 +638,6 @@ QString LabelModelTextObject::expandText( QString text, merge::Record* record )
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,17 +27,20 @@
|
||||
#include "LabelModelObject.h"
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class LabelModelTextObject : public LabelModelObject
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class LabelModelTextObject : public LabelModelObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
LabelModelTextObject();
|
||||
LabelModelTextObject( const LabelModelTextObject* object );
|
||||
virtual ~LabelModelTextObject();
|
||||
@@ -52,7 +55,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Text Property: text
|
||||
//
|
||||
@@ -126,14 +129,14 @@ public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
virtual bool canText();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
virtual QPainterPath hoverPath( double scale ) const;
|
||||
@@ -142,7 +145,7 @@ protected:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
virtual void sizeUpdated();
|
||||
void update();
|
||||
void drawTextInEditor( QPainter* painter, const QColor& color ) const;
|
||||
@@ -153,7 +156,7 @@ private:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QString mText;
|
||||
QString mFontFamily;
|
||||
double mFontSize;
|
||||
@@ -168,7 +171,9 @@ private:
|
||||
QList<QTextLayout*> mEditorLayouts;
|
||||
QPainterPath mHoverPath;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LabelModelTextObject_h
|
||||
|
||||
+7
-5
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "privateConstants.h"
|
||||
#include "Constants.h"
|
||||
|
||||
|
||||
namespace glabels
|
||||
@@ -37,6 +37,7 @@ namespace glabels
|
||||
const Distance& dy )
|
||||
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +45,7 @@ namespace glabels
|
||||
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0),
|
||||
mDx(other.mDx), mDy(other.mDy)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -87,10 +89,10 @@ namespace glabels
|
||||
{
|
||||
return ( (mNx == other->mNx) &&
|
||||
(mNy == other->mNy) &&
|
||||
(fabs(mX0 - other->mX0) < Constants::EPSILON) &&
|
||||
(fabs(mY0 - other->mY0) < Constants::EPSILON) &&
|
||||
(fabs(mDx - other->mDx) < Constants::EPSILON) &&
|
||||
(fabs(mDy - other->mDy) < Constants::EPSILON) );
|
||||
(fabs(mX0 - other->mX0) < EPSILON) &&
|
||||
(fabs(mY0 - other->mY0) < EPSILON) &&
|
||||
(fabs(mDx - other->mDx) < EPSILON) &&
|
||||
(fabs(mDy - other->mDy) < EPSILON) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
+518
-511
File diff suppressed because it is too large
Load Diff
+28
-21
@@ -33,29 +33,33 @@
|
||||
#include <QStackedWidget>
|
||||
#include <QToolBar>
|
||||
|
||||
// Forward References
|
||||
class LabelEditor;
|
||||
class LabelModel;
|
||||
class MergeView;
|
||||
class ObjectEditor;
|
||||
class PrintView;
|
||||
class PropertiesView;
|
||||
class StartupView;
|
||||
class UndoRedoModel;
|
||||
|
||||
|
||||
///
|
||||
/// MainWindow Widget
|
||||
///
|
||||
class MainWindow : public QMainWindow
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class LabelEditor;
|
||||
class LabelModel;
|
||||
class MergeView;
|
||||
class ObjectEditor;
|
||||
class PrintView;
|
||||
class PropertiesView;
|
||||
class StartupView;
|
||||
class UndoRedoModel;
|
||||
|
||||
|
||||
///
|
||||
/// MainWindow Widget
|
||||
///
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Lifecycle
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
MainWindow();
|
||||
virtual ~MainWindow();
|
||||
|
||||
@@ -63,7 +67,7 @@ public:
|
||||
/////////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
LabelModel* model() const;
|
||||
void setModel( LabelModel* label );
|
||||
bool isEmpty() const;
|
||||
@@ -72,14 +76,14 @@ public:
|
||||
/////////////////////////////////////
|
||||
// Events
|
||||
/////////////////////////////////////
|
||||
protected:
|
||||
protected:
|
||||
void closeEvent( QCloseEvent *event );
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
|
||||
void clipboardChanged();
|
||||
@@ -152,7 +156,7 @@ private slots:
|
||||
/////////////////////////////////////
|
||||
// Internal Private Methods
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
@@ -182,7 +186,7 @@ private:
|
||||
/////////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QMenu* fileMenu;
|
||||
QMenu* editMenu;
|
||||
QMenu* viewMenu;
|
||||
@@ -283,7 +287,10 @@ private:
|
||||
QAction* contextCopyAction;
|
||||
QAction* contextPasteAction;
|
||||
QAction* contextDeleteAction;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // MainWindow_h
|
||||
|
||||
@@ -31,15 +31,17 @@
|
||||
#include "TextSemicolonKeys.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Static data
|
||||
///
|
||||
namespace merge
|
||||
{
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
||||
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
||||
|
||||
QStringList Factory::mNameList;
|
||||
|
||||
|
||||
@@ -217,5 +219,6 @@ namespace merge
|
||||
mNameList << name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-2
@@ -26,9 +26,14 @@
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
class Merge; // Forward reference
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
// Forward references
|
||||
class Merge;
|
||||
|
||||
|
||||
///
|
||||
@@ -98,6 +103,9 @@ namespace merge
|
||||
static QStringList mNameList;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_Factory_h
|
||||
|
||||
@@ -23,9 +23,12 @@
|
||||
#include "Record.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
@@ -207,4 +210,6 @@ namespace merge
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-2
@@ -27,9 +27,14 @@
|
||||
#include <QList>
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
class Record; // Forward reference
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
// Forward references
|
||||
class Record;
|
||||
|
||||
|
||||
///
|
||||
@@ -111,6 +116,9 @@ namespace merge
|
||||
QList<Record*> mRecordList;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_Merge_h
|
||||
|
||||
@@ -21,9 +21,12 @@
|
||||
#include "None.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
@@ -119,4 +122,6 @@ namespace merge
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Merge.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// None Merge Backend
|
||||
///
|
||||
@@ -69,6 +72,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_None_h
|
||||
|
||||
@@ -21,9 +21,12 @@
|
||||
#include "Record.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
@@ -67,4 +70,6 @@ namespace merge
|
||||
mSelected = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// Merge Record
|
||||
///
|
||||
@@ -64,6 +67,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_Record_h
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
@@ -412,4 +415,6 @@ namespace merge
|
||||
return fields;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,9 +26,12 @@
|
||||
#include <QFile>
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// Text Merge Backend
|
||||
///
|
||||
@@ -75,6 +78,9 @@ namespace merge
|
||||
int mNFieldsMax;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_Text_h
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "TextColon.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
static const QString ID = "Text/Colon";
|
||||
|
||||
|
||||
@@ -77,4 +80,6 @@ namespace merge
|
||||
return new TextColon();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// TextColon Merge Backend
|
||||
///
|
||||
@@ -58,6 +61,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_TextColon_h
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "TextColonKeys.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
static const QString ID = "Text/Colon/Line1Keys";
|
||||
|
||||
|
||||
@@ -77,4 +80,6 @@ namespace merge
|
||||
return new TextColonKeys();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// TextColonKeys Merge Backend
|
||||
///
|
||||
@@ -58,6 +61,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_TextColonKeys_h
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "TextCsv.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
static const QString ID = "Text/Comma";
|
||||
|
||||
|
||||
@@ -77,4 +80,6 @@ namespace merge
|
||||
return new TextCsv();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// TextCsv Merge Backend
|
||||
///
|
||||
@@ -58,6 +61,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_TextCsv_h
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "TextCsvKeys.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
static const QString ID = "Text/Comma/Line1Keys";
|
||||
|
||||
|
||||
@@ -77,4 +80,6 @@ namespace merge
|
||||
return new TextCsvKeys();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// TextCsvKeys Merge Backend
|
||||
///
|
||||
@@ -58,6 +61,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_TextCsvKeys_h
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "TextSemicolon.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
static const QString ID = "Text/Semicolon";
|
||||
|
||||
|
||||
@@ -77,4 +80,6 @@ namespace merge
|
||||
return new TextSemicolon();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// TextSemicolon Merge Backend
|
||||
///
|
||||
@@ -58,6 +61,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_TextSemicolon_h
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "TextSemicolonKeys.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
static const QString ID = "Text/Semicolon/Keys";
|
||||
|
||||
|
||||
@@ -77,4 +80,6 @@ namespace merge
|
||||
return new TextSemicolonKeys();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// TextSemicolonKeys Merge Backend
|
||||
///
|
||||
@@ -58,6 +61,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_TextSemicolonKeys_h
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "TextTsv.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
static const QString ID = "Text/Tab";
|
||||
|
||||
|
||||
@@ -77,4 +80,6 @@ namespace merge
|
||||
return new TextTsv();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// TextTsv Merge Backend
|
||||
///
|
||||
@@ -58,6 +61,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_TextTsv_h
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "TextTsvKeys.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
static const QString ID = "Text/Tab/Line1Keys";
|
||||
|
||||
|
||||
@@ -77,4 +80,6 @@ namespace merge
|
||||
return new TextTsvKeys();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// TextTsvKeys Merge Backend
|
||||
///
|
||||
@@ -58,6 +61,9 @@ namespace merge
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // merge_TextTsvKeys_h
|
||||
|
||||
+95
-82
@@ -30,32 +30,36 @@
|
||||
#include "Merge/Factory.h"
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
MergeView::MergeView( QWidget *parent )
|
||||
: QWidget(parent), mModel(0), mBlock(false)
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
MergeView::MergeView( QWidget *parent )
|
||||
: QWidget(parent), mModel(0), mBlock(false)
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
mMergeFormatNames = merge::Factory::nameList();
|
||||
formatCombo->addItems( mMergeFormatNames );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
MergeView::~MergeView()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
MergeView::~MergeView()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Set Model
|
||||
///
|
||||
void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||
{
|
||||
///
|
||||
/// Set Model
|
||||
///
|
||||
void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||
{
|
||||
mModel = model;
|
||||
mUndoRedoModel = undoRedoModel;
|
||||
|
||||
@@ -71,15 +75,16 @@ void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||
|
||||
onMergeChanged();
|
||||
connect( mModel, SIGNAL(mergeChanged()), this, SLOT(onMergeChanged()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Merge changed handler
|
||||
///
|
||||
void MergeView::onMergeChanged()
|
||||
{
|
||||
int index = mMergeFormatNames.indexOf( merge::Factory::idToName( mModel->merge()->id() ) );
|
||||
///
|
||||
/// Merge changed handler
|
||||
///
|
||||
void MergeView::onMergeChanged()
|
||||
{
|
||||
QString name = merge::Factory::idToName( mModel->merge()->id() );
|
||||
int index = mMergeFormatNames.indexOf( name );
|
||||
mOldFormatComboIndex = index;
|
||||
formatCombo->setCurrentIndex( index );
|
||||
|
||||
@@ -115,32 +120,36 @@ void MergeView::onMergeChanged()
|
||||
loadHeaders( mModel->merge() );
|
||||
loadTable( mModel->merge() );
|
||||
|
||||
connect( mModel->merge(), SIGNAL(sourceChanged()), this, SLOT(onMergeSourceChanged()) );
|
||||
connect( mModel->merge(), SIGNAL(selectionChanged()), this, SLOT(onMergeSelectionChanged()) );
|
||||
connect( mModel->merge(), SIGNAL(sourceChanged()),
|
||||
this, SLOT(onMergeSourceChanged()) );
|
||||
|
||||
connect( recordsTable, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)) );
|
||||
}
|
||||
connect( mModel->merge(), SIGNAL(selectionChanged()),
|
||||
this, SLOT(onMergeSelectionChanged()) );
|
||||
|
||||
connect( recordsTable, SIGNAL(cellChanged(int,int)),
|
||||
this, SLOT(onCellChanged(int,int)) );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Merge source changed handler
|
||||
///
|
||||
void MergeView::onMergeSourceChanged()
|
||||
{
|
||||
///
|
||||
/// Merge source changed handler
|
||||
///
|
||||
void MergeView::onMergeSourceChanged()
|
||||
{
|
||||
locationButton->setText( mModel->merge()->source() );
|
||||
|
||||
recordsTable->clear();
|
||||
recordsTable->setColumnCount( 0 );
|
||||
loadHeaders( mModel->merge() );
|
||||
loadTable( mModel->merge() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Merge selection changed handler
|
||||
///
|
||||
void MergeView::onMergeSelectionChanged()
|
||||
{
|
||||
///
|
||||
/// Merge selection changed handler
|
||||
///
|
||||
void MergeView::onMergeSelectionChanged()
|
||||
{
|
||||
mBlock = true; // Don't recurse
|
||||
|
||||
const QList<merge::Record*>& records = mModel->merge()->recordList();
|
||||
@@ -155,28 +164,30 @@ void MergeView::onMergeSelectionChanged()
|
||||
}
|
||||
|
||||
mBlock = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Format combo changed handler
|
||||
void MergeView::onFormatComboActivated()
|
||||
{
|
||||
///
|
||||
/// Format combo changed handler
|
||||
///
|
||||
void MergeView::onFormatComboActivated()
|
||||
{
|
||||
int index = formatCombo->currentIndex();
|
||||
if ( index != mOldFormatComboIndex )
|
||||
{
|
||||
mOldFormatComboIndex = index;
|
||||
|
||||
mModel->setMerge( merge::Factory::createMerge( merge::Factory::indexToId(index) ) );
|
||||
QString id = merge::Factory::indexToId(index);
|
||||
mModel->setMerge( merge::Factory::createMerge( id ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Location button clicked handler
|
||||
///
|
||||
void MergeView::onLocationButtonClicked()
|
||||
{
|
||||
///
|
||||
/// Location button clicked handler
|
||||
///
|
||||
void MergeView::onLocationButtonClicked()
|
||||
{
|
||||
QString fileName =
|
||||
QFileDialog::getOpenFileName( this,
|
||||
tr("Select merge file"),
|
||||
@@ -187,32 +198,32 @@ void MergeView::onLocationButtonClicked()
|
||||
mModel->merge()->setSource( fileName );
|
||||
mCwd = QFileInfo( fileName ).absolutePath(); // Update CWD
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Select all button clicked handler
|
||||
///
|
||||
void MergeView::onSelectAllButtonClicked()
|
||||
{
|
||||
///
|
||||
/// Select all button clicked handler
|
||||
///
|
||||
void MergeView::onSelectAllButtonClicked()
|
||||
{
|
||||
mModel->merge()->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unselect all button clicked handler
|
||||
///
|
||||
void MergeView::onUnselectAllButtonClicked()
|
||||
{
|
||||
///
|
||||
/// Unselect all button clicked handler
|
||||
///
|
||||
void MergeView::onUnselectAllButtonClicked()
|
||||
{
|
||||
mModel->merge()->unselectAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Cell changed handler
|
||||
///
|
||||
void MergeView::onCellChanged( int iRow, int iCol )
|
||||
{
|
||||
///
|
||||
/// Cell changed handler
|
||||
///
|
||||
void MergeView::onCellChanged( int iRow, int iCol )
|
||||
{
|
||||
if ( !mBlock )
|
||||
{
|
||||
QTableWidgetItem* item = recordsTable->item( iRow, 0 );
|
||||
@@ -220,14 +231,14 @@ void MergeView::onCellChanged( int iRow, int iCol )
|
||||
|
||||
mModel->merge()->setSelected( iRow, state );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Load headers
|
||||
///
|
||||
void MergeView::loadHeaders( merge::Merge* merge )
|
||||
{
|
||||
///
|
||||
/// Load headers
|
||||
///
|
||||
void MergeView::loadHeaders( merge::Merge* merge )
|
||||
{
|
||||
mPrimaryKey = merge->primaryKey();
|
||||
mKeys = merge->keys();
|
||||
|
||||
@@ -261,14 +272,14 @@ void MergeView::loadHeaders( merge::Merge* merge )
|
||||
recordsTable->setHorizontalHeaderItem( iCol, fillItem );
|
||||
recordsTable->horizontalHeader()->setStretchLastSection( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Load table
|
||||
///
|
||||
void MergeView::loadTable( merge::Merge* merge )
|
||||
{
|
||||
///
|
||||
/// Load table
|
||||
///
|
||||
void MergeView::loadTable( merge::Merge* merge )
|
||||
{
|
||||
mBlock = true;
|
||||
|
||||
const QList<merge::Record*>& records = merge->recordList();
|
||||
@@ -288,7 +299,7 @@ void MergeView::loadTable( merge::Merge* merge )
|
||||
recordsTable->setItem( iRow, 0, item );
|
||||
recordsTable->resizeColumnToContents( 0 );
|
||||
|
||||
// Starting on second column, one column per field (even if empty), skip primary field
|
||||
// Starting on 2nd column, 1 column per field, skip primary field
|
||||
int iCol = 1;
|
||||
foreach ( QString key, mKeys )
|
||||
{
|
||||
@@ -315,4 +326,6 @@ void MergeView::loadTable( merge::Merge* merge )
|
||||
}
|
||||
|
||||
mBlock = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-13
@@ -26,23 +26,27 @@
|
||||
|
||||
#include "Merge/Merge.h"
|
||||
|
||||
// Forward references
|
||||
class LabelModel;
|
||||
class UndoRedoModel;
|
||||
|
||||
|
||||
///
|
||||
/// merge::Merge Property Editor Widget
|
||||
///
|
||||
class MergeView : public QWidget, public Ui_MergeView
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward references
|
||||
class LabelModel;
|
||||
class UndoRedoModel;
|
||||
|
||||
|
||||
///
|
||||
/// merge::Merge Property Editor Widget
|
||||
///
|
||||
class MergeView : public QWidget, public Ui_MergeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
MergeView( QWidget *parent = 0 );
|
||||
~MergeView();
|
||||
|
||||
@@ -56,7 +60,7 @@ public:
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
private slots:
|
||||
void onMergeChanged();
|
||||
void onMergeSourceChanged();
|
||||
void onMergeSelectionChanged();
|
||||
@@ -71,7 +75,7 @@ private slots:
|
||||
/////////////////////////////////
|
||||
// Private methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
void loadHeaders( merge::Merge* merge );
|
||||
void loadTable( merge::Merge* merge );
|
||||
|
||||
@@ -79,7 +83,7 @@ private:
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
private:
|
||||
QStringList mMergeFormatNames;
|
||||
|
||||
LabelModel* mModel;
|
||||
@@ -93,7 +97,9 @@ private:
|
||||
bool mBlock;
|
||||
int mOldFormatComboIndex;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // MergeView_h
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user