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.
|
- 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
|
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
|
#endif // ns_Module_h
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Include Directives
|
### Include Directives
|
||||||
|
|
||||||
Header files should be included in the following order.
|
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
|
Do not use forward declarations to any external entities. Use the appropriate
|
||||||
include directives instead.
|
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"
|
#include "Version.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
AboutDialog::AboutDialog( QWidget *parent )
|
|
||||||
: QDialog(parent)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
AboutDialog::AboutDialog( QWidget *parent )
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
QString version = tr("Version") + " " + Version::STRING;
|
QString version = tr("Version") + " " + Version::STRING;
|
||||||
@@ -62,22 +65,24 @@ AboutDialog::AboutDialog( QWidget *parent )
|
|||||||
"<p align='left'>" + licenseParagraph2 + "</p>";
|
"<p align='left'>" + licenseParagraph2 + "</p>";
|
||||||
|
|
||||||
aboutLabel->setText( markup );
|
aboutLabel->setText( markup );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// "License" Button Clicked Slot
|
/// "License" Button Clicked Slot
|
||||||
///
|
///
|
||||||
void AboutDialog::onLicenseButtonClicked()
|
void AboutDialog::onLicenseButtonClicked()
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl( QUrl("http://www.gnu.org/licenses/gpl-3.0.txt") );
|
QDesktopServices::openUrl( QUrl("http://www.gnu.org/licenses/gpl-3.0.txt") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// "Website" Button Clicked Slot
|
/// "Website" Button Clicked Slot
|
||||||
///
|
///
|
||||||
void AboutDialog::onWebsiteButtonClicked()
|
void AboutDialog::onWebsiteButtonClicked()
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl( QUrl(Version::WEBSITE) );
|
QDesktopServices::openUrl( QUrl(Version::WEBSITE) );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-7
@@ -25,29 +25,34 @@
|
|||||||
#include "ui_AboutDialog.h"
|
#include "ui_AboutDialog.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// About Dialog Widget
|
|
||||||
///
|
|
||||||
class AboutDialog : public QDialog, public Ui_AboutDialog
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// About Dialog Widget
|
||||||
|
///
|
||||||
|
class AboutDialog : public QDialog, public Ui_AboutDialog
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
AboutDialog( QWidget *parent = 0 );
|
AboutDialog( QWidget *parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onLicenseButtonClicked();
|
void onLicenseButtonClicked();
|
||||||
void onWebsiteButtonClicked();
|
void onWebsiteButtonClicked();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // AboutDialog_h
|
#endif // AboutDialog_h
|
||||||
|
|||||||
+43
-39
@@ -21,23 +21,24 @@
|
|||||||
#include "BarcodeBackends.h"
|
#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::mStyleIdMap;
|
||||||
BarcodeBackends::StyleMap BarcodeBackends::mStyleNameMap;
|
BarcodeBackends::StyleMap BarcodeBackends::mStyleNameMap;
|
||||||
|
|
||||||
QList<QString> BarcodeBackends::mBackendNameList;
|
QList<QString> BarcodeBackends::mBackendNameList;
|
||||||
QList<QString> BarcodeBackends::mNameList;
|
QList<QString> BarcodeBackends::mNameList;
|
||||||
|
|
||||||
|
|
||||||
BarcodeBackends::BarcodeBackends()
|
BarcodeBackends::BarcodeBackends()
|
||||||
{
|
{
|
||||||
registerStyle( "postnet", "", tr("POSTNET (any)"),
|
registerStyle( "postnet", "", tr("POSTNET (any)"),
|
||||||
false, false, true, false, "12345-6789-12", false, 11 );
|
false, false, true, false, "12345-6789-12", false, 11 );
|
||||||
|
|
||||||
@@ -73,22 +74,22 @@ BarcodeBackends::BarcodeBackends()
|
|||||||
|
|
||||||
registerStyle( "qrcode", "", tr("QRCode"),
|
registerStyle( "qrcode", "", tr("QRCode"),
|
||||||
false, false, true, false, "1234567890AB", false, 12 );
|
false, false, true, false, "1234567890AB", false, 12 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BarcodeBackends::init( void )
|
void BarcodeBackends::init( void )
|
||||||
{
|
{
|
||||||
static BarcodeBackends* singletonInstance = NULL;
|
static BarcodeBackends* singletonInstance = NULL;
|
||||||
|
|
||||||
if ( singletonInstance == NULL )
|
if ( singletonInstance == NULL )
|
||||||
{
|
{
|
||||||
singletonInstance = new BarcodeBackends();
|
singletonInstance = new BarcodeBackends();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString BarcodeBackends::BackendIdToName( const QString& backendId )
|
QString BarcodeBackends::BackendIdToName( const QString& backendId )
|
||||||
{
|
{
|
||||||
BackendMap::iterator i = mBackendIdMap.find( backendId );
|
BackendMap::iterator i = mBackendIdMap.find( backendId );
|
||||||
if ( i != mBackendIdMap.end() )
|
if ( i != mBackendIdMap.end() )
|
||||||
{
|
{
|
||||||
@@ -96,11 +97,11 @@ QString BarcodeBackends::BackendIdToName( const QString& backendId )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString BarcodeBackends::BackendNameToId( const QString& backendName )
|
QString BarcodeBackends::BackendNameToId( const QString& backendName )
|
||||||
{
|
{
|
||||||
BackendMap::iterator i = mBackendNameMap.find( backendName );
|
BackendMap::iterator i = mBackendNameMap.find( backendName );
|
||||||
if ( i != mBackendNameMap.end() )
|
if ( i != mBackendNameMap.end() )
|
||||||
{
|
{
|
||||||
@@ -108,23 +109,23 @@ QString BarcodeBackends::BackendNameToId( const QString& backendName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QList<QString>& BarcodeBackends::getBackendNameList()
|
const QList<QString>& BarcodeBackends::getBackendNameList()
|
||||||
{
|
{
|
||||||
return mBackendNameList;
|
return mBackendNameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QList<QString>& BarcodeBackends::getNameList()
|
const QList<QString>& BarcodeBackends::getNameList()
|
||||||
{
|
{
|
||||||
return mNameList;
|
return mNameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
|
const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
|
||||||
{
|
{
|
||||||
StyleMap::iterator i = mStyleIdMap.find( id );
|
StyleMap::iterator i = mStyleIdMap.find( id );
|
||||||
if ( i != mStyleIdMap.end() )
|
if ( i != mStyleIdMap.end() )
|
||||||
{
|
{
|
||||||
@@ -132,11 +133,11 @@ const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
|
const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
|
||||||
{
|
{
|
||||||
StyleMap::iterator i = mStyleNameMap.find( name );
|
StyleMap::iterator i = mStyleNameMap.find( name );
|
||||||
if ( i != mStyleNameMap.end() )
|
if ( i != mStyleNameMap.end() )
|
||||||
{
|
{
|
||||||
@@ -144,18 +145,18 @@ const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BarcodeBackends::registerBackend( QString& id, QString& name)
|
void BarcodeBackends::registerBackend( QString& id, QString& name)
|
||||||
{
|
{
|
||||||
mBackendNameList.append( name );
|
mBackendNameList.append( name );
|
||||||
mBackendIdMap.insert( id, name );
|
mBackendIdMap.insert( id, name );
|
||||||
mBackendNameMap.insert( name, id );
|
mBackendNameMap.insert( name, id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BarcodeBackends::registerStyle( const char* id,
|
void BarcodeBackends::registerStyle( const char* id,
|
||||||
const char* backendId,
|
const char* backendId,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
bool canText,
|
bool canText,
|
||||||
@@ -165,15 +166,18 @@ void BarcodeBackends::registerStyle( const char* id,
|
|||||||
const char* defaultDigits,
|
const char* defaultDigits,
|
||||||
bool canFreeForm,
|
bool canFreeForm,
|
||||||
int preferedN )
|
int preferedN )
|
||||||
{
|
{
|
||||||
BarcodeStyle* style = new BarcodeStyle( QString(id), QString(backendId), name,
|
BarcodeStyle* style = new BarcodeStyle( QString(id), QString(backendId), name,
|
||||||
canText, textOptional,
|
canText, textOptional,
|
||||||
canChecksum, checksumOptional,
|
canChecksum, checksumOptional,
|
||||||
QString(defaultDigits), canFreeForm, preferedN );
|
QString(defaultDigits),
|
||||||
|
canFreeForm, preferedN );
|
||||||
|
|
||||||
QString fqName = QString(backendId) + QString(".") + name; // Name may not be unique
|
QString fqName = QString(backendId) + QString(".") + name; // Name may not be unique
|
||||||
|
|
||||||
mNameList.append( name );
|
mNameList.append( name );
|
||||||
mStyleIdMap.insert( id, style );
|
mStyleIdMap.insert( id, style );
|
||||||
mStyleNameMap.insert( fqName, style );
|
mStyleNameMap.insert( fqName, style );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,25 +30,28 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Backends Database
|
|
||||||
///
|
|
||||||
class BarcodeBackends : public QObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Backends Database
|
||||||
|
///
|
||||||
|
class BarcodeBackends : public QObject
|
||||||
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
BarcodeBackends();
|
BarcodeBackends();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void init( void );
|
static void init( void );
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString BackendIdToName( const QString& backendId );
|
static QString BackendIdToName( const QString& backendId );
|
||||||
static QString BackendNameToId( const QString& backendName );
|
static QString BackendNameToId( const QString& backendName );
|
||||||
|
|
||||||
@@ -62,7 +65,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Methods
|
// Private Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
static void registerBackend( QString &id, QString &name);
|
static void registerBackend( QString &id, QString &name);
|
||||||
|
|
||||||
static void registerStyle( const char* id,
|
static void registerStyle( const char* id,
|
||||||
@@ -91,7 +94,9 @@ private:
|
|||||||
static QList<QString> mBackendNameList;
|
static QList<QString> mBackendNameList;
|
||||||
static QList<QString> mNameList;
|
static QList<QString> mNameList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeBackends_h
|
#endif // BarcodeBackends_h
|
||||||
|
|||||||
+21
-16
@@ -25,11 +25,14 @@
|
|||||||
#include "BarcodeMenuItem.h"
|
#include "BarcodeMenuItem.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
BarcodeMenu::BarcodeMenu()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
BarcodeMenu::BarcodeMenu()
|
||||||
|
{
|
||||||
foreach ( QString name, BarcodeBackends::getNameList() )
|
foreach ( QString name, BarcodeBackends::getNameList() )
|
||||||
{
|
{
|
||||||
const BarcodeStyle* bcStyle = BarcodeBackends::lookupStyleFromName( name );
|
const BarcodeStyle* bcStyle = BarcodeBackends::lookupStyleFromName( name );
|
||||||
@@ -39,24 +42,26 @@ BarcodeMenu::BarcodeMenu()
|
|||||||
|
|
||||||
addAction( bcMenuItem );
|
addAction( bcMenuItem );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// bcStyle getter
|
/// bcStyle getter
|
||||||
///
|
///
|
||||||
const BarcodeStyle* BarcodeMenu::bcStyle() const
|
const BarcodeStyle* BarcodeMenu::bcStyle() const
|
||||||
{
|
{
|
||||||
return mBcStyle;
|
return mBcStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onMenuItemActivated slot
|
/// onMenuItemActivated slot
|
||||||
///
|
///
|
||||||
void BarcodeMenu::onMenuItemActivated( BarcodeStyle *bcStyle )
|
void BarcodeMenu::onMenuItemActivated( BarcodeStyle *bcStyle )
|
||||||
{
|
{
|
||||||
mBcStyle = bcStyle;
|
mBcStyle = bcStyle;
|
||||||
|
|
||||||
emit styleChanged();
|
emit styleChanged();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -27,48 +27,53 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Menu
|
|
||||||
///
|
|
||||||
class BarcodeMenu : public QMenu
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Menu
|
||||||
|
///
|
||||||
|
class BarcodeMenu : public QMenu
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
BarcodeMenu();
|
BarcodeMenu();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void styleChanged();
|
void styleChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
const BarcodeStyle* bcStyle() const;
|
const BarcodeStyle* bcStyle() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onMenuItemActivated( BarcodeStyle *bcStyle );
|
void onMenuItemActivated( BarcodeStyle *bcStyle );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
BarcodeStyle* mBcStyle;
|
BarcodeStyle* mBcStyle;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeMenu_h
|
#endif // BarcodeMenu_h
|
||||||
|
|||||||
@@ -25,12 +25,15 @@
|
|||||||
#include "BarcodeMenuItem.h"
|
#include "BarcodeMenuItem.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
|
||||||
: QPushButton(parent)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
||||||
|
: QPushButton(parent)
|
||||||
|
{
|
||||||
mMenu = new BarcodeMenu();
|
mMenu = new BarcodeMenu();
|
||||||
setMenu( mMenu );
|
setMenu( mMenu );
|
||||||
|
|
||||||
@@ -38,25 +41,27 @@ BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
|||||||
setText( mBcStyle->name() );
|
setText( mBcStyle->name() );
|
||||||
|
|
||||||
connect( mMenu, SIGNAL(styleChanged()), this, SLOT(onMenuStyleChanged()) );
|
connect( mMenu, SIGNAL(styleChanged()), this, SLOT(onMenuStyleChanged()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// bcStyle getter
|
/// bcStyle getter
|
||||||
///
|
///
|
||||||
const BarcodeStyle* BarcodeMenuButton::bcStyle() const
|
const BarcodeStyle* BarcodeMenuButton::bcStyle() const
|
||||||
{
|
{
|
||||||
return mBcStyle;
|
return mBcStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onMenuStyleChanged slot
|
/// onMenuStyleChanged slot
|
||||||
///
|
///
|
||||||
void BarcodeMenuButton::onMenuStyleChanged()
|
void BarcodeMenuButton::onMenuStyleChanged()
|
||||||
{
|
{
|
||||||
mBcStyle = mMenu->bcStyle();
|
mBcStyle = mMenu->bcStyle();
|
||||||
setText( mBcStyle->name() );
|
setText( mBcStyle->name() );
|
||||||
|
|
||||||
emit styleChanged();
|
emit styleChanged();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -28,49 +28,54 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Menu Button
|
|
||||||
///
|
|
||||||
class BarcodeMenuButton : public QPushButton
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Menu Button
|
||||||
|
///
|
||||||
|
class BarcodeMenuButton : public QPushButton
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
BarcodeMenuButton( QWidget* parent = 0 );
|
BarcodeMenuButton( QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void styleChanged();
|
void styleChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
const BarcodeStyle* bcStyle() const;
|
const BarcodeStyle* bcStyle() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onMenuStyleChanged();
|
void onMenuStyleChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
BarcodeMenu* mMenu;
|
BarcodeMenu* mMenu;
|
||||||
const BarcodeStyle* mBcStyle;
|
const BarcodeStyle* mBcStyle;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeMenuButton_h
|
#endif // BarcodeMenuButton_h
|
||||||
|
|||||||
+22
-17
@@ -21,31 +21,36 @@
|
|||||||
#include "BarcodeMenuItem.h"
|
#include "BarcodeMenuItem.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor From Data
|
|
||||||
///
|
|
||||||
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent )
|
|
||||||
: QAction(parent), mBcStyle(bcStyle)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor From Data
|
||||||
|
///
|
||||||
|
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent )
|
||||||
|
: QAction(parent), mBcStyle(bcStyle)
|
||||||
|
{
|
||||||
setText( bcStyle->name() );
|
setText( bcStyle->name() );
|
||||||
|
|
||||||
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
|
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// bcStyle Property Getter
|
/// bcStyle Property Getter
|
||||||
///
|
///
|
||||||
const BarcodeStyle* BarcodeMenuItem::bcStyle() const
|
const BarcodeStyle* BarcodeMenuItem::bcStyle() const
|
||||||
{
|
{
|
||||||
return mBcStyle;
|
return mBcStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onTriggered slot
|
/// onTriggered slot
|
||||||
///
|
///
|
||||||
void BarcodeMenuItem::onTriggered()
|
void BarcodeMenuItem::onTriggered()
|
||||||
{
|
{
|
||||||
emit activated( mBcStyle );
|
emit activated( mBcStyle );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -27,48 +27,53 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Menu Item
|
|
||||||
///
|
|
||||||
class BarcodeMenuItem : public QAction
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Menu Item
|
||||||
|
///
|
||||||
|
class BarcodeMenuItem : public QAction
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent = 0 );
|
BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void activated( const BarcodeStyle* bcStyle );
|
void activated( const BarcodeStyle* bcStyle );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
const BarcodeStyle* bcStyle() const;
|
const BarcodeStyle* bcStyle() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onTriggered();
|
void onTriggered();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
const BarcodeStyle* mBcStyle;
|
const BarcodeStyle* mBcStyle;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeMenuItem_h
|
#endif // BarcodeMenuItem_h
|
||||||
|
|||||||
+84
-77
@@ -21,10 +21,13 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Default Constructor
|
{
|
||||||
///
|
|
||||||
BarcodeStyle::BarcodeStyle ()
|
///
|
||||||
|
/// Default Constructor
|
||||||
|
///
|
||||||
|
BarcodeStyle::BarcodeStyle ()
|
||||||
: mId( "" ),
|
: mId( "" ),
|
||||||
mBackendId( "" ),
|
mBackendId( "" ),
|
||||||
mName( "" ),
|
mName( "" ),
|
||||||
@@ -35,14 +38,15 @@ BarcodeStyle::BarcodeStyle ()
|
|||||||
mDefaultDigits( "" ),
|
mDefaultDigits( "" ),
|
||||||
mCanFreeform( false ),
|
mCanFreeform( false ),
|
||||||
mPreferedN( 0 )
|
mPreferedN( 0 )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
BarcodeStyle::BarcodeStyle ( const QString& id,
|
BarcodeStyle::BarcodeStyle ( const QString& id,
|
||||||
const QString& backendId,
|
const QString& backendId,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
bool canText,
|
bool canText,
|
||||||
@@ -62,105 +66,106 @@ BarcodeStyle::BarcodeStyle ( const QString& id,
|
|||||||
mDefaultDigits( defaultDigits ),
|
mDefaultDigits( defaultDigits ),
|
||||||
mCanFreeform( canFreeform ),
|
mCanFreeform( canFreeform ),
|
||||||
mPreferedN( preferedN )
|
mPreferedN( preferedN )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// ID Property Getter
|
/// ID Property Getter
|
||||||
///
|
///
|
||||||
const QString& BarcodeStyle::id() const
|
const QString& BarcodeStyle::id() const
|
||||||
{
|
{
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Backend ID Property Getter
|
/// Backend ID Property Getter
|
||||||
///
|
///
|
||||||
const QString& BarcodeStyle::backendId() const
|
const QString& BarcodeStyle::backendId() const
|
||||||
{
|
{
|
||||||
return mBackendId;
|
return mBackendId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Name Property Getter
|
/// Name Property Getter
|
||||||
///
|
///
|
||||||
const QString& BarcodeStyle::name() const
|
const QString& BarcodeStyle::name() const
|
||||||
{
|
{
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Text Property Getter
|
/// Can Text Property Getter
|
||||||
///
|
///
|
||||||
bool BarcodeStyle::canText() const
|
bool BarcodeStyle::canText() const
|
||||||
{
|
{
|
||||||
return mCanText;
|
return mCanText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Text Optional Property Getter
|
/// Text Optional Property Getter
|
||||||
///
|
///
|
||||||
bool BarcodeStyle::textOptional() const
|
bool BarcodeStyle::textOptional() const
|
||||||
{
|
{
|
||||||
return mTextOptional;
|
return mTextOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Checksum Property Getter
|
/// Can Checksum Property Getter
|
||||||
///
|
///
|
||||||
bool BarcodeStyle::canChecksum() const
|
bool BarcodeStyle::canChecksum() const
|
||||||
{
|
{
|
||||||
return mCanChecksum;
|
return mCanChecksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Checksum Optional Property Getter
|
/// Checksum Optional Property Getter
|
||||||
///
|
///
|
||||||
bool BarcodeStyle::checksumOptional() const
|
bool BarcodeStyle::checksumOptional() const
|
||||||
{
|
{
|
||||||
return mChecksumOptional;
|
return mChecksumOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Default Digits Property Getter
|
/// Default Digits Property Getter
|
||||||
///
|
///
|
||||||
const QString& BarcodeStyle::defaultDigits() const
|
const QString& BarcodeStyle::defaultDigits() const
|
||||||
{
|
{
|
||||||
return mDefaultDigits;
|
return mDefaultDigits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Freeform Property Getter
|
/// Can Freeform Property Getter
|
||||||
///
|
///
|
||||||
bool BarcodeStyle::canFreeform() const
|
bool BarcodeStyle::canFreeform() const
|
||||||
{
|
{
|
||||||
return mCanFreeform;
|
return mCanFreeform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Prefered N Property Getter
|
/// Prefered N Property Getter
|
||||||
///
|
///
|
||||||
int BarcodeStyle::preferedN() const
|
int BarcodeStyle::preferedN() const
|
||||||
{
|
{
|
||||||
return mPreferedN;
|
return mPreferedN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Generate Example Digits
|
/// Generate Example Digits
|
||||||
///
|
///
|
||||||
QString BarcodeStyle::exampleDigits( int n ) const
|
QString BarcodeStyle::exampleDigits( int n ) const
|
||||||
{
|
{
|
||||||
if ( mCanFreeform )
|
if ( mCanFreeform )
|
||||||
{
|
{
|
||||||
return QString( qMax( n, 1 ), QChar('0') );
|
return QString( qMax( n, 1 ), QChar('0') );
|
||||||
@@ -169,4 +174,6 @@ QString BarcodeStyle::exampleDigits( int n ) const
|
|||||||
{
|
{
|
||||||
return mDefaultDigits;
|
return mDefaultDigits;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-8
@@ -24,16 +24,19 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Style Type
|
|
||||||
///
|
|
||||||
struct BarcodeStyle
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Style Type
|
||||||
|
///
|
||||||
|
struct BarcodeStyle
|
||||||
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
BarcodeStyle ();
|
BarcodeStyle ();
|
||||||
|
|
||||||
BarcodeStyle ( const QString& id,
|
BarcodeStyle ( const QString& id,
|
||||||
@@ -75,14 +78,14 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Methods
|
// Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QString exampleDigits( int n ) const;
|
QString exampleDigits( int n ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QString mId;
|
QString mId;
|
||||||
QString mBackendId;
|
QString mBackendId;
|
||||||
QString mName;
|
QString mName;
|
||||||
@@ -94,7 +97,9 @@ private:
|
|||||||
bool mCanFreeform;
|
bool mCanFreeform;
|
||||||
int mPreferedN;
|
int mPreferedN;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeStyle_h
|
#endif // BarcodeStyle_h
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace glabels
|
|||||||
Category::Category( const QString &id, const QString &name )
|
Category::Category( const QString &id, const QString &name )
|
||||||
: mId(id), mName(name)
|
: mId(id), mName(name)
|
||||||
{
|
{
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+48
-37
@@ -28,21 +28,30 @@
|
|||||||
#include "ColorSwatch.h"
|
#include "ColorSwatch.h"
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const int SWATCH_W = 64;
|
const int SWATCH_W = 64;
|
||||||
const int SWATCH_H = 24;
|
const int SWATCH_H = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ColorButton::ColorButton( QWidget* parent )
|
ColorButton::ColorButton( QWidget* parent )
|
||||||
: QPushButton( 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;
|
mDefaultColor = defaultColor;
|
||||||
mColorNode = ColorNode( color );
|
mColorNode = ColorNode( color );
|
||||||
|
|
||||||
@@ -60,11 +69,11 @@ void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor,
|
|||||||
this, SLOT(onPaletteDialogChanged(ColorNode,bool)) );
|
this, SLOT(onPaletteDialogChanged(ColorNode,bool)) );
|
||||||
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
|
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
|
||||||
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
|
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setColorNode( ColorNode colorNode )
|
void ColorButton::setColorNode( ColorNode colorNode )
|
||||||
{
|
{
|
||||||
mIsDefault = false;
|
mIsDefault = false;
|
||||||
|
|
||||||
mColorNode = colorNode;
|
mColorNode = colorNode;
|
||||||
@@ -81,11 +90,11 @@ void ColorButton::setColorNode( ColorNode colorNode )
|
|||||||
}
|
}
|
||||||
|
|
||||||
mDialog->setColorNode( colorNode );
|
mDialog->setColorNode( colorNode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setColor( QColor color )
|
void ColorButton::setColor( QColor color )
|
||||||
{
|
{
|
||||||
mIsDefault = false;
|
mIsDefault = false;
|
||||||
|
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
@@ -94,11 +103,11 @@ void ColorButton::setColor( QColor color )
|
|||||||
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
||||||
setText( "" );
|
setText( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setToDefault()
|
void ColorButton::setToDefault()
|
||||||
{
|
{
|
||||||
mIsDefault = true;
|
mIsDefault = true;
|
||||||
|
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
@@ -107,29 +116,29 @@ void ColorButton::setToDefault()
|
|||||||
|
|
||||||
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
|
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
|
||||||
setText( "" );
|
setText( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ColorNode ColorButton::colorNode()
|
ColorNode ColorButton::colorNode()
|
||||||
{
|
{
|
||||||
return mColorNode;
|
return mColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setKeys( const QList<QString> keyList )
|
void ColorButton::setKeys( const QList<QString> keyList )
|
||||||
{
|
{
|
||||||
mDialog->setKeys( keyList );
|
mDialog->setKeys( keyList );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::clearKeys()
|
void ColorButton::clearKeys()
|
||||||
{
|
{
|
||||||
mDialog->clearKeys();
|
mDialog->clearKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onButtonToggled( bool checked )
|
void ColorButton::onButtonToggled( bool checked )
|
||||||
{
|
{
|
||||||
if ( checked )
|
if ( checked )
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
@@ -140,23 +149,23 @@ void ColorButton::onButtonToggled( bool checked )
|
|||||||
|
|
||||||
mDialog->show();
|
mDialog->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onPaletteDialogAccepted()
|
void ColorButton::onPaletteDialogAccepted()
|
||||||
{
|
{
|
||||||
setChecked( false );
|
setChecked( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onPaletteDialogRejected()
|
void ColorButton::onPaletteDialogRejected()
|
||||||
{
|
{
|
||||||
setChecked( false );
|
setChecked( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
||||||
{
|
{
|
||||||
mColorNode = colorNode;
|
mColorNode = colorNode;
|
||||||
mIsDefault = isDefault;
|
mIsDefault = isDefault;
|
||||||
|
|
||||||
@@ -172,4 +181,6 @@ void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit colorChanged();
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-11
@@ -28,32 +28,35 @@
|
|||||||
#include "ColorPaletteDialog.h"
|
#include "ColorPaletteDialog.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Button
|
|
||||||
///
|
|
||||||
class ColorButton : public QPushButton
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Button
|
||||||
|
///
|
||||||
|
class ColorButton : public QPushButton
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
ColorButton( QWidget* parent = 0 );
|
ColorButton( QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void colorChanged();
|
void colorChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color );
|
void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color );
|
||||||
void setColorNode( ColorNode colorNode );
|
void setColorNode( ColorNode colorNode );
|
||||||
void setColor( QColor color );
|
void setColor( QColor color );
|
||||||
@@ -66,7 +69,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onButtonToggled( bool checked );
|
void onButtonToggled( bool checked );
|
||||||
void onPaletteDialogAccepted();
|
void onPaletteDialogAccepted();
|
||||||
void onPaletteDialogRejected();
|
void onPaletteDialogRejected();
|
||||||
@@ -76,19 +79,21 @@ private slots:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Methods
|
// Private Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QColor mDefaultColor;
|
QColor mDefaultColor;
|
||||||
bool mIsDefault;
|
bool mIsDefault;
|
||||||
ColorNode mColorNode;
|
ColorNode mColorNode;
|
||||||
|
|
||||||
ColorPaletteDialog* mDialog;
|
ColorPaletteDialog* mDialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorButton_h
|
#endif // ColorButton_h
|
||||||
|
|||||||
+22
-16
@@ -25,13 +25,17 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
ColorHistory::ColorHistory()
|
namespace glabels
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
ColorHistory::ColorHistory()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ColorHistory* ColorHistory::instance()
|
ColorHistory* ColorHistory::instance()
|
||||||
{
|
{
|
||||||
static ColorHistory* singletonInstance = 0;
|
static ColorHistory* singletonInstance = 0;
|
||||||
|
|
||||||
if ( singletonInstance == 0 )
|
if ( singletonInstance == 0 )
|
||||||
@@ -40,11 +44,11 @@ ColorHistory* ColorHistory::instance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return singletonInstance;
|
return singletonInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorHistory::addColor( const QColor &color )
|
void ColorHistory::addColor( const QColor &color )
|
||||||
{
|
{
|
||||||
QList<QColor> colorList = readColorList();
|
QList<QColor> colorList = readColorList();
|
||||||
|
|
||||||
// Remove any occurances of this color already in list
|
// Remove any occurances of this color already in list
|
||||||
@@ -62,17 +66,17 @@ void ColorHistory::addColor( const QColor &color )
|
|||||||
writeColorList( colorList );
|
writeColorList( colorList );
|
||||||
|
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QColor> ColorHistory::getColors()
|
QList<QColor> ColorHistory::getColors()
|
||||||
{
|
{
|
||||||
return readColorList();
|
return readColorList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QColor> ColorHistory::readColorList()
|
QList<QColor> ColorHistory::readColorList()
|
||||||
{
|
{
|
||||||
QStringList defaultList;
|
QStringList defaultList;
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
@@ -93,11 +97,11 @@ QList<QColor> ColorHistory::readColorList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return colorList;
|
return colorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
||||||
{
|
{
|
||||||
// Build name list
|
// Build name list
|
||||||
QStringList colorNameList;
|
QStringList colorNameList;
|
||||||
foreach ( QColor color, colorList )
|
foreach ( QColor color, colorList )
|
||||||
@@ -110,4 +114,6 @@ void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
|||||||
settings.beginGroup( "ColorHistory" );
|
settings.beginGroup( "ColorHistory" );
|
||||||
settings.setValue( "colors", colorNameList );
|
settings.setValue( "colors", colorNameList );
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-12
@@ -26,37 +26,40 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color History
|
|
||||||
///
|
|
||||||
class ColorHistory : public QObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color History
|
||||||
|
///
|
||||||
|
class ColorHistory : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int MAX_COLORS = 9;
|
static const int MAX_COLORS = 9;
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
ColorHistory();
|
ColorHistory();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ColorHistory* instance();
|
static ColorHistory* instance();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void addColor( const QColor &color );
|
void addColor( const QColor &color );
|
||||||
QList<QColor> getColors();
|
QList<QColor> getColors();
|
||||||
|
|
||||||
@@ -64,7 +67,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Methods
|
// Private Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QList<QColor> readColorList();
|
QList<QColor> readColorList();
|
||||||
void writeColorList( const QList<QColor>& colorList );
|
void writeColorList( const QList<QColor>& colorList );
|
||||||
|
|
||||||
@@ -72,9 +75,11 @@ private:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorHistory_h
|
#endif // ColorHistory_h
|
||||||
|
|||||||
+98
-89
@@ -24,136 +24,143 @@
|
|||||||
#include "Merge/Record.h"
|
#include "Merge/Record.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Default Constructor
|
{
|
||||||
///
|
|
||||||
ColorNode::ColorNode()
|
///
|
||||||
|
/// Default Constructor
|
||||||
|
///
|
||||||
|
ColorNode::ColorNode()
|
||||||
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
|
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
ColorNode::ColorNode( bool isField, const QColor& color, const QString& key )
|
ColorNode::ColorNode( bool isField, const QColor& color, const QString& key )
|
||||||
: mIsField(isField), mColor(color), mKey(key)
|
: mIsField(isField), mColor(color), mKey(key)
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
ColorNode::ColorNode( bool isField, uint32_t rgba, const QString& key )
|
ColorNode::ColorNode( bool isField, uint32_t rgba, const QString& key )
|
||||||
: mIsField(isField), mKey(key)
|
: mIsField(isField), mKey(key)
|
||||||
{
|
{
|
||||||
mColor = QColor( (rgba >> 24) & 0xFF,
|
mColor = QColor( (rgba >> 24) & 0xFF,
|
||||||
(rgba >> 16) & 0xFF,
|
(rgba >> 16) & 0xFF,
|
||||||
(rgba >> 8) & 0xFF,
|
(rgba >> 8) & 0xFF,
|
||||||
(rgba ) & 0xFF );
|
(rgba ) & 0xFF );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Color
|
/// Constructor From Color
|
||||||
///
|
///
|
||||||
ColorNode::ColorNode( const QColor& color )
|
ColorNode::ColorNode( const QColor& color )
|
||||||
: mIsField(false), mColor(color), mKey("")
|
: mIsField(false), mColor(color), mKey("")
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Key
|
/// Constructor From Key
|
||||||
///
|
///
|
||||||
ColorNode::ColorNode( const QString& key )
|
ColorNode::ColorNode( const QString& key )
|
||||||
: mIsField(true), mColor(QColor::fromRgba(0x00000000)), mKey(key)
|
: mIsField(true), mColor(QColor::fromRgba(0x00000000)), mKey(key)
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// == Operator
|
/// == Operator
|
||||||
///
|
///
|
||||||
bool ColorNode::operator==( const ColorNode& cn )
|
bool ColorNode::operator==( const ColorNode& cn )
|
||||||
{
|
{
|
||||||
return (mIsField == cn.mIsField) &&
|
return (mIsField == cn.mIsField) &&
|
||||||
(mColor == cn.mColor) &&
|
(mColor == cn.mColor) &&
|
||||||
(mKey == cn.mKey);
|
(mKey == cn.mKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// != Operator
|
/// != Operator
|
||||||
///
|
///
|
||||||
bool ColorNode::operator!=( const ColorNode& cn )
|
bool ColorNode::operator!=( const ColorNode& cn )
|
||||||
{
|
{
|
||||||
return (mIsField != cn.mIsField) ||
|
return (mIsField != cn.mIsField) ||
|
||||||
(mColor != cn.mColor) ||
|
(mColor != cn.mColor) ||
|
||||||
(mKey != cn.mKey);
|
(mKey != cn.mKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Field Flag Property Getter
|
/// Field Flag Property Getter
|
||||||
///
|
///
|
||||||
bool ColorNode::isField() const
|
bool ColorNode::isField() const
|
||||||
{
|
{
|
||||||
return mIsField;
|
return mIsField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Field Flag Property Setter
|
/// Field Flag Property Setter
|
||||||
///
|
///
|
||||||
void ColorNode::setField( bool isField )
|
void ColorNode::setField( bool isField )
|
||||||
{
|
{
|
||||||
mIsField = isField;
|
mIsField = isField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Color Property Getter
|
/// Color Property Getter
|
||||||
///
|
///
|
||||||
const QColor& ColorNode::color() const
|
const QColor& ColorNode::color() const
|
||||||
{
|
{
|
||||||
return mColor;
|
return mColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Color Property Setter
|
/// Color Property Setter
|
||||||
///
|
///
|
||||||
void ColorNode::setColor( const QColor& color )
|
void ColorNode::setColor( const QColor& color )
|
||||||
{
|
{
|
||||||
mColor = color;
|
mColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Key Property Getter
|
/// Key Property Getter
|
||||||
///
|
///
|
||||||
const QString& ColorNode::key() const
|
const QString& ColorNode::key() const
|
||||||
{
|
{
|
||||||
return mKey;
|
return mKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Key Property Setter
|
/// Key Property Setter
|
||||||
///
|
///
|
||||||
void ColorNode::setKey( const QString& key )
|
void ColorNode::setKey( const QString& key )
|
||||||
{
|
{
|
||||||
mKey = key;
|
mKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get color encoded as an RGBA 32-bit number
|
/// Get color encoded as an RGBA 32-bit number
|
||||||
///
|
///
|
||||||
uint32_t ColorNode::rgba() const
|
uint32_t ColorNode::rgba() const
|
||||||
{
|
{
|
||||||
uint32_t c =
|
uint32_t c =
|
||||||
mColor.red() << 24 |
|
mColor.red() << 24 |
|
||||||
mColor.green() << 16 |
|
mColor.green() << 16 |
|
||||||
@@ -161,14 +168,14 @@ uint32_t ColorNode::rgba() const
|
|||||||
mColor.alpha();
|
mColor.alpha();
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get color, expand if necessary
|
/// Get color, expand if necessary
|
||||||
///
|
///
|
||||||
QColor ColorNode::color( merge::Record* record ) const
|
QColor ColorNode::color( merge::Record* record ) const
|
||||||
{
|
{
|
||||||
if ( mIsField )
|
if ( mIsField )
|
||||||
{
|
{
|
||||||
if ( record == 0 )
|
if ( record == 0 )
|
||||||
@@ -191,4 +198,6 @@ QColor ColorNode::color( merge::Record* record ) const
|
|||||||
{
|
{
|
||||||
return mColor;
|
return mColor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -30,16 +30,19 @@
|
|||||||
#include "Merge/Record.h"
|
#include "Merge/Record.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Node Type
|
|
||||||
///
|
|
||||||
struct ColorNode
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Node Type
|
||||||
|
///
|
||||||
|
struct ColorNode
|
||||||
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
ColorNode();
|
ColorNode();
|
||||||
|
|
||||||
ColorNode( bool isField, const QColor& color, const QString& key );
|
ColorNode( bool isField, const QColor& color, const QString& key );
|
||||||
@@ -54,7 +57,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Operators
|
// Operators
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool operator==( const ColorNode& cn );
|
bool operator==( const ColorNode& cn );
|
||||||
|
|
||||||
bool operator!=( const ColorNode& cn );
|
bool operator!=( const ColorNode& cn );
|
||||||
@@ -63,7 +66,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Field Flag Property
|
// Field Flag Property
|
||||||
//
|
//
|
||||||
@@ -88,7 +91,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Misc. Methods
|
// Misc. Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
uint32_t rgba() const;
|
uint32_t rgba() const;
|
||||||
QColor color( merge::Record* record ) const;
|
QColor color( merge::Record* record ) const;
|
||||||
|
|
||||||
@@ -96,12 +99,14 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
bool mIsField;
|
bool mIsField;
|
||||||
QColor mColor;
|
QColor mColor;
|
||||||
QString mKey;
|
QString mKey;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorNode_h
|
#endif // ColorNode_h
|
||||||
|
|||||||
@@ -25,33 +25,36 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
//
|
namespace glabels
|
||||||
// Private Configuration Data
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const int border = 4;
|
const int border = 4;
|
||||||
const int hBox = 25;
|
const int hBox = 25;
|
||||||
const int outlineWidthPixels = 1;
|
const int outlineWidthPixels = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
|
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
|
||||||
: QWidget(parent), mText(text), mHover(false)
|
: QWidget(parent), mText(text), mHover(false)
|
||||||
{
|
{
|
||||||
setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
|
setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
|
||||||
setMinimumSize( hBox+2*border+1, hBox+2*border+1 );
|
setMinimumSize( hBox+2*border+1, hBox+2*border+1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Paint Event
|
/// Paint Event
|
||||||
///
|
///
|
||||||
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -88,33 +91,35 @@ void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
|||||||
QRect textRect( border, border, width()-2*border, hBox );
|
QRect textRect( border, border, width()-2*border, hBox );
|
||||||
|
|
||||||
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
|
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Enter Event
|
/// Enter Event
|
||||||
///
|
///
|
||||||
void ColorPaletteButtonItem::enterEvent( QEvent* event )
|
void ColorPaletteButtonItem::enterEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
mHover = true;
|
mHover = true;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Leave Event
|
/// Leave Event
|
||||||
///
|
///
|
||||||
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
|
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
mHover = false;
|
mHover = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Mouse Press Event
|
/// Mouse Press Event
|
||||||
///
|
///
|
||||||
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
|
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
|
||||||
{
|
{
|
||||||
emit activated();
|
emit activated();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,31 +26,34 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Palette Item
|
|
||||||
///
|
|
||||||
class ColorPaletteButtonItem : public QWidget
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Palette Item
|
||||||
|
///
|
||||||
|
class ColorPaletteButtonItem : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
ColorPaletteButtonItem( const QString& text, QWidget* parent = 0 );
|
ColorPaletteButtonItem( const QString& text, QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void activated();
|
void activated();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Event handlers
|
// Event handlers
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void paintEvent( QPaintEvent* event );
|
void paintEvent( QPaintEvent* event );
|
||||||
void enterEvent( QEvent* event );
|
void enterEvent( QEvent* event );
|
||||||
void leaveEvent( QEvent* event );
|
void leaveEvent( QEvent* event );
|
||||||
@@ -60,11 +63,13 @@ protected:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QString mText;
|
QString mText;
|
||||||
|
|
||||||
bool mHover;
|
bool mHover;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorPaletteButtonItem_h
|
#endif // ColorPaletteButtonItem_h
|
||||||
|
|||||||
@@ -30,7 +30,13 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Static data
|
||||||
|
//
|
||||||
|
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
||||||
|
|
||||||
{ "#ef2929", tr("Light Scarlet Red", "Color name") },
|
{ "#ef2929", tr("Light Scarlet Red", "Color name") },
|
||||||
{ "#fcaf3e", tr("Light Orange", "Color name") },
|
{ "#fcaf3e", tr("Light Orange", "Color name") },
|
||||||
@@ -71,15 +77,16 @@ ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
|||||||
{ "#eeeeec", tr("Lighter Gray", "Color name") },
|
{ "#eeeeec", tr("Lighter Gray", "Color name") },
|
||||||
{ "#f3f3f3", tr("Very Light Gray", "Color name") },
|
{ "#f3f3f3", tr("Very Light Gray", "Color name") },
|
||||||
{ "#ffffff", tr("White", "Color name") }
|
{ "#ffffff", tr("White", "Color name") }
|
||||||
};
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
||||||
const QColor& defaultColor,
|
const QColor& defaultColor,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
QWidget* parent )
|
QWidget* parent )
|
||||||
: QDialog( parent )
|
: QDialog( parent )
|
||||||
{
|
{
|
||||||
mColorHistory = ColorHistory::instance();
|
mColorHistory = ColorHistory::instance();
|
||||||
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
|
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
|
||||||
|
|
||||||
@@ -168,17 +175,17 @@ ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
|||||||
setLayout( vLayout );
|
setLayout( vLayout );
|
||||||
|
|
||||||
loadCustomColorHistory();
|
loadCustomColorHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::setColorNode( const ColorNode& colorNode )
|
void ColorPaletteDialog::setColorNode( const ColorNode& colorNode )
|
||||||
{
|
{
|
||||||
mColorNode = colorNode;
|
mColorNode = colorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
||||||
{
|
{
|
||||||
mKeys = keyList;
|
mKeys = keyList;
|
||||||
|
|
||||||
// Clear old keys, (all entries, except item 0)
|
// Clear old keys, (all entries, except item 0)
|
||||||
@@ -197,55 +204,55 @@ void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
|||||||
{
|
{
|
||||||
mMergeFieldCombo->setEnabled( false );
|
mMergeFieldCombo->setEnabled( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::clearKeys()
|
void ColorPaletteDialog::clearKeys()
|
||||||
{
|
{
|
||||||
|
|
||||||
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
||||||
{
|
{
|
||||||
mMergeFieldCombo->removeItem( index );
|
mMergeFieldCombo->removeItem( index );
|
||||||
}
|
}
|
||||||
mMergeFieldCombo->setEnabled( false );
|
mMergeFieldCombo->setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onDefaultItemActivated()
|
void ColorPaletteDialog::onDefaultItemActivated()
|
||||||
{
|
{
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
mColorNode.setColor( mDefaultColor );
|
mColorNode.setColor( mDefaultColor );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
emit colorChanged( mColorNode, true );
|
emit colorChanged( mColorNode, true );
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
||||||
{
|
{
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
||||||
{
|
{
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
mColorNode.setColor( mColorHistory->getColors()[id] );
|
mColorNode.setColor( mColorHistory->getColors()[id] );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onCustomColorItemActivated()
|
void ColorPaletteDialog::onCustomColorItemActivated()
|
||||||
{
|
{
|
||||||
QColorDialog dlg( mColorNode.color(), this );
|
QColorDialog dlg( mColorNode.color(), this );
|
||||||
dlg.setWindowTitle( tr("Custom Color") );
|
dlg.setWindowTitle( tr("Custom Color") );
|
||||||
|
|
||||||
@@ -267,17 +274,17 @@ void ColorPaletteDialog::onCustomColorItemActivated()
|
|||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onColorHistoryChanged()
|
void ColorPaletteDialog::onColorHistoryChanged()
|
||||||
{
|
{
|
||||||
loadCustomColorHistory();
|
loadCustomColorHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::loadCustomColorHistory()
|
void ColorPaletteDialog::loadCustomColorHistory()
|
||||||
{
|
{
|
||||||
QList<QColor> colorList = mColorHistory->getColors();
|
QList<QColor> colorList = mColorHistory->getColors();
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
@@ -293,11 +300,11 @@ void ColorPaletteDialog::loadCustomColorHistory()
|
|||||||
mHistoryItem[id]->setEnabled( false );
|
mHistoryItem[id]->setEnabled( false );
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onComboIndexChanged( int index )
|
void ColorPaletteDialog::onComboIndexChanged( int index )
|
||||||
{
|
{
|
||||||
if ( index != 0 )
|
if ( index != 0 )
|
||||||
{
|
{
|
||||||
mColorNode.setField( true );
|
mColorNode.setField( true );
|
||||||
@@ -307,12 +314,14 @@ void ColorPaletteDialog::onComboIndexChanged( int index )
|
|||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::showEvent( QShowEvent* event )
|
void ColorPaletteDialog::showEvent( QShowEvent* event )
|
||||||
{
|
{
|
||||||
mMergeFieldCombo->setCurrentIndex( 0 );
|
mMergeFieldCombo->setCurrentIndex( 0 );
|
||||||
|
|
||||||
QDialog::showEvent( event );
|
QDialog::showEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,18 +31,21 @@
|
|||||||
#include "ColorPaletteButtonItem.h"
|
#include "ColorPaletteButtonItem.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Palette Dialog
|
|
||||||
///
|
|
||||||
class ColorPaletteDialog : public QDialog
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Palette Dialog
|
||||||
|
///
|
||||||
|
class ColorPaletteDialog : public QDialog
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
ColorPaletteDialog( const QString& defaultLabel,
|
ColorPaletteDialog( const QString& defaultLabel,
|
||||||
const QColor& defaultColor,
|
const QColor& defaultColor,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
@@ -52,14 +55,14 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void colorChanged( ColorNode colorNode, bool isDefault );
|
void colorChanged( ColorNode colorNode, bool isDefault );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setColorNode( const ColorNode& colorNode );
|
void setColorNode( const ColorNode& colorNode );
|
||||||
void setKeys( const QStringList& keyList );
|
void setKeys( const QStringList& keyList );
|
||||||
void clearKeys();
|
void clearKeys();
|
||||||
@@ -68,7 +71,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onDefaultItemActivated();
|
void onDefaultItemActivated();
|
||||||
void onPaletteItemActivated( int id );
|
void onPaletteItemActivated( int id );
|
||||||
void onHistoryItemActivated( int id );
|
void onHistoryItemActivated( int id );
|
||||||
@@ -76,21 +79,21 @@ private slots:
|
|||||||
void onColorHistoryChanged();
|
void onColorHistoryChanged();
|
||||||
void onComboIndexChanged( int index );
|
void onComboIndexChanged( int index );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent( QShowEvent* event );
|
void showEvent( QShowEvent* event );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Methods
|
// Private Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void loadCustomColorHistory();
|
void loadCustomColorHistory();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QColor mDefaultColor;
|
QColor mDefaultColor;
|
||||||
ColorNode mColorNode;
|
ColorNode mColorNode;
|
||||||
|
|
||||||
@@ -110,7 +113,9 @@ private:
|
|||||||
QComboBox* mMergeFieldCombo;
|
QComboBox* mMergeFieldCombo;
|
||||||
QStringList mKeys;
|
QStringList mKeys;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorPaletteDialog_h
|
#endif // ColorPaletteDialog_h
|
||||||
|
|||||||
@@ -25,11 +25,14 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
//
|
namespace glabels
|
||||||
// Private Configuration Data
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const int border = 4;
|
const int border = 4;
|
||||||
const int wSwatch = 25;
|
const int wSwatch = 25;
|
||||||
const int hSwatch = 25;
|
const int hSwatch = 25;
|
||||||
@@ -37,45 +40,45 @@ namespace
|
|||||||
const int hoverBgOutlineWidthPixels = 1;
|
const int hoverBgOutlineWidthPixels = 1;
|
||||||
|
|
||||||
const int outlineWidthPixels = 1;
|
const int outlineWidthPixels = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
ColorPaletteItem::ColorPaletteItem( int id,
|
ColorPaletteItem::ColorPaletteItem( int id,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
const QString& tip,
|
const QString& tip,
|
||||||
QWidget* parent )
|
QWidget* parent )
|
||||||
: QWidget(parent), mId(id), mColor(color), mTip(tip), mHover(false)
|
: QWidget(parent), mId(id), mColor(color), mTip(tip), mHover(false)
|
||||||
{
|
{
|
||||||
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
||||||
setMinimumSize( wSwatch+2*border+1, hSwatch+2*border+1 );
|
setMinimumSize( wSwatch+2*border+1, hSwatch+2*border+1 );
|
||||||
setToolTip( tip );
|
setToolTip( tip );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Color Property Setter
|
/// Color Property Setter
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::setColor( int id,
|
void ColorPaletteItem::setColor( int id,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
const QString& tip )
|
const QString& tip )
|
||||||
{
|
{
|
||||||
mId = id;
|
mId = id;
|
||||||
mColor = color;
|
mColor = color;
|
||||||
mTip = tip;
|
mTip = tip;
|
||||||
|
|
||||||
setToolTip( tip );
|
setToolTip( tip );
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Paint Event
|
/// Paint Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -112,33 +115,35 @@ void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
|||||||
painter.drawRect( border, border, wSwatch, hSwatch );
|
painter.drawRect( border, border, wSwatch, hSwatch );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Enter Event
|
/// Enter Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::enterEvent( QEvent* event )
|
void ColorPaletteItem::enterEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
mHover = true;
|
mHover = true;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Leave Event
|
/// Leave Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::leaveEvent( QEvent* event )
|
void ColorPaletteItem::leaveEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
mHover = false;
|
mHover = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Mouse Press Event
|
/// Mouse Press Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
|
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
|
||||||
{
|
{
|
||||||
emit activated( mId );
|
emit activated( mId );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -26,17 +26,20 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Palette Item
|
|
||||||
///
|
|
||||||
class ColorPaletteItem : public QWidget
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Palette Item
|
||||||
|
///
|
||||||
|
class ColorPaletteItem : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
ColorPaletteItem( int id,
|
ColorPaletteItem( int id,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
const QString& tip,
|
const QString& tip,
|
||||||
@@ -46,14 +49,14 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void activated( int id );
|
void activated( int id );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setColor( int id,
|
void setColor( int id,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
const QString& tip );
|
const QString& tip );
|
||||||
@@ -62,7 +65,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Event handlers
|
// Event handlers
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void paintEvent( QPaintEvent* event );
|
void paintEvent( QPaintEvent* event );
|
||||||
void enterEvent( QEvent* event );
|
void enterEvent( QEvent* event );
|
||||||
void leaveEvent( QEvent* event );
|
void leaveEvent( QEvent* event );
|
||||||
@@ -72,13 +75,15 @@ protected:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
int mId;
|
int mId;
|
||||||
QColor mColor;
|
QColor mColor;
|
||||||
QString mTip;
|
QString mTip;
|
||||||
|
|
||||||
bool mHover;
|
bool mHover;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorPaletteItem_h
|
#endif // ColorPaletteItem_h
|
||||||
|
|||||||
+15
-10
@@ -24,22 +24,25 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
//
|
namespace glabels
|
||||||
// Private Configuration Data
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const QColor outlineColor( 0, 0, 0 );
|
const QColor outlineColor( 0, 0, 0 );
|
||||||
const double outlineWidthPixels = 1;
|
const double outlineWidthPixels = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
||||||
: QPixmap( w, h )
|
: QPixmap( w, h )
|
||||||
{
|
{
|
||||||
fill( Qt::transparent );
|
fill( Qt::transparent );
|
||||||
|
|
||||||
QPainter painter(this );
|
QPainter painter(this );
|
||||||
@@ -53,4 +56,6 @@ ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
|||||||
painter.setBrush( brush );
|
painter.setBrush( brush );
|
||||||
painter.setPen( pen );
|
painter.setPen( pen );
|
||||||
painter.drawRect( 1, 1, w-2, h-2 );
|
painter.drawRect( 1, 1, w-2, h-2 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-6
@@ -25,19 +25,24 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Simple Preview Widget
|
|
||||||
///
|
|
||||||
class ColorSwatch : public QPixmap
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Simple Preview Widget
|
||||||
|
///
|
||||||
|
class ColorSwatch : public QPixmap
|
||||||
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
ColorSwatch( int w, int h, const QColor& color );
|
ColorSwatch( int w, int h, const QColor& color );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorSwatch_h
|
#endif // ColorSwatch_h
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace glabels
|
|||||||
const double PTS_PER_CM = (10.0*PTS_PER_MM);
|
const double PTS_PER_CM = (10.0*PTS_PER_MM);
|
||||||
const double PTS_PER_PICA = 12.0;
|
const double PTS_PER_PICA = 12.0;
|
||||||
|
|
||||||
|
const Distance EPSILON( 0.5, Units::PT );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // glabels_Constants_h
|
#endif // glabels_Constants_h
|
||||||
|
|||||||
+28
-17
@@ -23,37 +23,48 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
|
||||||
Cursors::Barcode::Barcode()
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
Cursors::Barcode::Barcode()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_barcode.png"), 7, 7 )
|
: 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 )
|
: 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 )
|
: 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 )
|
: 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 )
|
: 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 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_text.png"), 7, 7 )
|
||||||
{
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -25,12 +25,15 @@
|
|||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Glabels Cursors
|
|
||||||
///
|
|
||||||
namespace Cursors
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Glabels Cursors
|
||||||
|
///
|
||||||
|
namespace Cursors
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
class Barcode : public QCursor
|
class Barcode : public QCursor
|
||||||
{
|
{
|
||||||
@@ -73,6 +76,8 @@ namespace Cursors
|
|||||||
Text();
|
Text();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+23
-16
@@ -32,18 +32,26 @@
|
|||||||
#include "XmlVendorParser.h"
|
#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
|
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;
|
QList<Paper*> Db::mPapers;
|
||||||
QStringList Db::mPaperIds;
|
QStringList Db::mPaperIds;
|
||||||
QStringList Db::mPaperNames;
|
QStringList Db::mPaperNames;
|
||||||
@@ -53,9 +61,8 @@ namespace glabels
|
|||||||
QList<Vendor*> Db::mVendors;
|
QList<Vendor*> Db::mVendors;
|
||||||
QStringList Db::mVendorNames;
|
QStringList Db::mVendorNames;
|
||||||
QList<Template*> Db::mTemplates;
|
QList<Template*> Db::mTemplates;
|
||||||
|
|
||||||
QString Db::mPaperNameOther;
|
QString Db::mPaperNameOther;
|
||||||
QString Db::mEmpty = "";
|
|
||||||
|
|
||||||
Db::Db()
|
Db::Db()
|
||||||
{
|
{
|
||||||
@@ -204,7 +211,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
qWarning() << "Unknown paper name: " << name;
|
qWarning() << "Unknown paper name: " << name;
|
||||||
return mEmpty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -225,7 +232,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
qWarning() << "Unknown paper id: " << id;
|
qWarning() << "Unknown paper id: " << id;
|
||||||
return mEmpty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -318,7 +325,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
qWarning() << "Unknown category name: " << name;
|
qWarning() << "Unknown category name: " << name;
|
||||||
return mEmpty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -334,7 +341,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
qWarning() << "Unknown category id: " << id;
|
qWarning() << "Unknown category id: " << id;
|
||||||
return mEmpty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -399,7 +406,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
qWarning() << "Unknown vendor name: " << name;
|
qWarning() << "Unknown vendor name: " << name;
|
||||||
return mEmpty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -132,7 +132,7 @@ namespace glabels
|
|||||||
static QList<Template*> mTemplates;
|
static QList<Template*> mTemplates;
|
||||||
|
|
||||||
static QString mPaperNameOther;
|
static QString mPaperNameOther;
|
||||||
static QString mEmpty;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,12 @@
|
|||||||
#include "EnumUtil.h"
|
#include "EnumUtil.h"
|
||||||
|
|
||||||
|
|
||||||
namespace EnumUtil
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace EnumUtil
|
||||||
|
{
|
||||||
|
|
||||||
QString weightToString( QFont::Weight weight )
|
QString weightToString( QFont::Weight weight )
|
||||||
{
|
{
|
||||||
switch (weight)
|
switch (weight)
|
||||||
@@ -118,4 +121,6 @@ namespace EnumUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -27,9 +27,12 @@
|
|||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
|
||||||
|
|
||||||
namespace EnumUtil
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace EnumUtil
|
||||||
|
{
|
||||||
|
|
||||||
QString weightToString( QFont::Weight weight );
|
QString weightToString( QFont::Weight weight );
|
||||||
QFont::Weight stringToWeight( const QString& string );
|
QFont::Weight stringToWeight( const QString& string );
|
||||||
|
|
||||||
@@ -39,6 +42,8 @@ namespace EnumUtil
|
|||||||
QString vAlignToString( Qt::Alignment align );
|
QString vAlignToString( Qt::Alignment align );
|
||||||
Qt::Alignment stringToVAlign( const QString& string );
|
Qt::Alignment stringToVAlign( const QString& string );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+25
-20
@@ -25,20 +25,23 @@
|
|||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
FieldButton::FieldButton( QWidget* parent )
|
|
||||||
: QComboBox(parent)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
FieldButton::FieldButton( QWidget* parent )
|
||||||
|
: QComboBox(parent)
|
||||||
|
{
|
||||||
setEnabled( false );
|
setEnabled( false );
|
||||||
|
|
||||||
connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)) );
|
connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FieldButton::setName( const QString& name )
|
void FieldButton::setName( const QString& name )
|
||||||
{
|
{
|
||||||
mName = name;
|
mName = name;
|
||||||
if ( count() == 0 )
|
if ( count() == 0 )
|
||||||
{
|
{
|
||||||
@@ -53,11 +56,11 @@ void FieldButton::setName( const QString& name )
|
|||||||
const QStandardItemModel* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
const QStandardItemModel* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
||||||
QStandardItem* item = itemModel->item(0);
|
QStandardItem* item = itemModel->item(0);
|
||||||
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FieldButton::setKeys( const QStringList& keyList )
|
void FieldButton::setKeys( const QStringList& keyList )
|
||||||
{
|
{
|
||||||
// Clear old keys
|
// Clear old keys
|
||||||
clear();
|
clear();
|
||||||
addItem( mName );
|
addItem( mName );
|
||||||
@@ -77,28 +80,30 @@ void FieldButton::setKeys( const QStringList& keyList )
|
|||||||
{
|
{
|
||||||
setEnabled( false );
|
setEnabled( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FieldButton::clearKeys()
|
void FieldButton::clearKeys()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
addItem( mName );
|
addItem( mName );
|
||||||
|
|
||||||
setEnabled( false );
|
setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onMenuKeySelected slot
|
/// onMenuKeySelected slot
|
||||||
///
|
///
|
||||||
void FieldButton::onIndexChanged( int index )
|
void FieldButton::onIndexChanged( int index )
|
||||||
{
|
{
|
||||||
if ( index > 0 )
|
if ( index > 0 )
|
||||||
{
|
{
|
||||||
emit keySelected( itemText(index) );
|
emit keySelected( itemText(index) );
|
||||||
|
|
||||||
setCurrentIndex( 0 );
|
setCurrentIndex( 0 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -26,31 +26,34 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Field Button
|
|
||||||
///
|
|
||||||
class FieldButton : public QComboBox
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Field Button
|
||||||
|
///
|
||||||
|
class FieldButton : public QComboBox
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
FieldButton( QWidget* parent = 0 );
|
FieldButton( QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void keySelected( QString key );
|
void keySelected( QString key );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setName( const QString& name = "" );
|
void setName( const QString& name = "" );
|
||||||
void setKeys( const QStringList& keyList );
|
void setKeys( const QStringList& keyList );
|
||||||
void clearKeys();
|
void clearKeys();
|
||||||
@@ -59,17 +62,19 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onIndexChanged( int index );
|
void onIndexChanged( int index );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QString mName;
|
QString mName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // FieldButton_h
|
#endif // FieldButton_h
|
||||||
|
|||||||
+47
-42
@@ -33,21 +33,24 @@
|
|||||||
#include "XmlLabelCreator.h"
|
#include "XmlLabelCreator.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Static data
|
|
||||||
///
|
|
||||||
QString File::mCwd = ".";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// New Label Dialog
|
|
||||||
///
|
|
||||||
bool File::newLabel( MainWindow *window )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Static data
|
||||||
|
//
|
||||||
|
QString File::mCwd = ".";
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// New Label Dialog
|
||||||
|
///
|
||||||
|
bool File::newLabel( MainWindow *window )
|
||||||
|
{
|
||||||
SelectProductDialog dialog( window );
|
SelectProductDialog dialog( window );
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
|
|
||||||
const glabels::Template* tmplate = dialog.tmplate();
|
const Template* tmplate = dialog.tmplate();
|
||||||
if ( tmplate )
|
if ( tmplate )
|
||||||
{
|
{
|
||||||
LabelModel* label = new LabelModel();
|
LabelModel* label = new LabelModel();
|
||||||
@@ -55,7 +58,7 @@ bool File::newLabel( MainWindow *window )
|
|||||||
label->clearModified();
|
label->clearModified();
|
||||||
|
|
||||||
// Intelligently decide to rotate label by default
|
// 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() );
|
label->setRotate( frame->h() > frame->w() );
|
||||||
|
|
||||||
// Either apply to current window or open a new one
|
// Either apply to current window or open a new one
|
||||||
@@ -76,14 +79,14 @@ bool File::newLabel( MainWindow *window )
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Open File Dialog
|
/// Open File Dialog
|
||||||
///
|
///
|
||||||
void File::open( MainWindow *window )
|
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
|
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
||||||
QString cwd = mCwd;
|
QString cwd = mCwd;
|
||||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||||
@@ -132,14 +135,14 @@ void File::open( MainWindow *window )
|
|||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Save file
|
/// Save file
|
||||||
///
|
///
|
||||||
bool File::save( MainWindow *window )
|
bool File::save( MainWindow *window )
|
||||||
{
|
{
|
||||||
if ( window->model()->fileName().isEmpty() )
|
if ( window->model()->fileName().isEmpty() )
|
||||||
{
|
{
|
||||||
return saveAs( window );
|
return saveAs( window );
|
||||||
@@ -157,14 +160,14 @@ bool File::save( MainWindow *window )
|
|||||||
mCwd = QFileInfo( window->model()->fileName() ).absolutePath();
|
mCwd = QFileInfo( window->model()->fileName() ).absolutePath();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Save file as
|
/// Save file as
|
||||||
///
|
///
|
||||||
bool File::saveAs( MainWindow *window )
|
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
|
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
||||||
QString cwd = mCwd;
|
QString cwd = mCwd;
|
||||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||||
@@ -215,23 +218,23 @@ bool File::saveAs( MainWindow *window )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Close file
|
/// Close file
|
||||||
///
|
///
|
||||||
void File::close( MainWindow *window )
|
void File::close( MainWindow *window )
|
||||||
{
|
{
|
||||||
window->close();
|
window->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Exit, closing all windows
|
/// Exit, closing all windows
|
||||||
///
|
///
|
||||||
void File::exit()
|
void File::exit()
|
||||||
{
|
{
|
||||||
foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
|
foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
|
||||||
{
|
{
|
||||||
if ( MainWindow* window = qobject_cast<MainWindow*>(qwidget) )
|
if ( MainWindow* window = qobject_cast<MainWindow*>(qwidget) )
|
||||||
@@ -239,4 +242,6 @@ void File::exit()
|
|||||||
window->close();
|
window->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-12
@@ -24,20 +24,24 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
// Forward References
|
|
||||||
class MainWindow;
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
///
|
|
||||||
/// File Actions
|
|
||||||
///
|
|
||||||
/// Note: class provides a translation context for these static functions.
|
|
||||||
///
|
|
||||||
class File : public QObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward References
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// File Actions
|
||||||
|
///
|
||||||
|
/// Note: class provides a translation context for these static functions.
|
||||||
|
///
|
||||||
|
class File : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool newLabel( MainWindow *window = 0 );
|
static bool newLabel( MainWindow *window = 0 );
|
||||||
static void open( MainWindow *window );
|
static void open( MainWindow *window );
|
||||||
static bool save( MainWindow *window );
|
static bool save( MainWindow *window );
|
||||||
@@ -45,10 +49,12 @@ public:
|
|||||||
static void close( MainWindow *window );
|
static void close( MainWindow *window );
|
||||||
static void exit();
|
static void exit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString mCwd;
|
static QString mCwd;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // File_h
|
#endif // File_h
|
||||||
|
|||||||
@@ -21,9 +21,12 @@
|
|||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
||||||
|
|
||||||
namespace FileUtil
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace FileUtil
|
||||||
|
{
|
||||||
|
|
||||||
QString addExtension( const QString& rawFilename, const QString& extension )
|
QString addExtension( const QString& rawFilename, const QString& extension )
|
||||||
{
|
{
|
||||||
if ( rawFilename.endsWith( extension ) )
|
if ( rawFilename.endsWith( extension ) )
|
||||||
@@ -34,4 +37,6 @@ namespace FileUtil
|
|||||||
return rawFilename + extension;
|
return rawFilename + extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -25,11 +25,16 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace FileUtil
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace FileUtil
|
||||||
|
{
|
||||||
|
|
||||||
QString addExtension( const QString& rawFilename, const QString& extension );
|
QString addExtension( const QString& rawFilename, const QString& extension );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace glabels
|
|||||||
Frame::Frame( const QString& id )
|
Frame::Frame( const QString& id )
|
||||||
: mId(id), mNLabels(0), mLayoutDescription("")
|
: mId(id), mNLabels(0), mLayoutDescription("")
|
||||||
{
|
{
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "privateConstants.h"
|
#include "Constants.h"
|
||||||
#include "StrUtil.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),
|
: mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
||||||
mPath(other.mPath), Frame(other)
|
mPath(other.mPath), Frame(other)
|
||||||
{
|
{
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -160,10 +161,10 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( FrameCd *otherCd = dynamic_cast<FrameCd*>(other) )
|
if ( FrameCd *otherCd = dynamic_cast<FrameCd*>(other) )
|
||||||
{
|
{
|
||||||
if ( (fabs( mW - otherCd->mW ) <= Constants::EPSILON) &&
|
if ( (fabs( mW - otherCd->mW ) <= EPSILON) &&
|
||||||
(fabs( mH - otherCd->mH ) <= Constants::EPSILON) &&
|
(fabs( mH - otherCd->mH ) <= EPSILON) &&
|
||||||
(fabs( mR1 - otherCd->mR1 ) <= Constants::EPSILON) &&
|
(fabs( mR1 - otherCd->mR1 ) <= EPSILON) &&
|
||||||
(fabs( mR2 - otherCd->mR2 ) <= Constants::EPSILON) )
|
(fabs( mR2 - otherCd->mR2 ) <= EPSILON) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "FrameEllipse.h"
|
#include "FrameEllipse.h"
|
||||||
|
|
||||||
|
|
||||||
#include "privateConstants.h"
|
#include "Constants.h"
|
||||||
#include "StrUtil.h"
|
#include "StrUtil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -41,6 +41,7 @@ namespace glabels
|
|||||||
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
||||||
: mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath), Frame(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 ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
||||||
{
|
{
|
||||||
if ( (fabs( mW - otherEllipse->mW ) <= Constants::EPSILON) &&
|
if ( (fabs( mW - otherEllipse->mW ) <= EPSILON) &&
|
||||||
(fabs( mH - otherEllipse->mH ) <= Constants::EPSILON) )
|
(fabs( mH - otherEllipse->mH ) <= EPSILON) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "FrameRect.h"
|
#include "FrameRect.h"
|
||||||
|
|
||||||
|
|
||||||
#include "privateConstants.h"
|
#include "Constants.h"
|
||||||
#include "StrUtil.h"
|
#include "StrUtil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -48,6 +48,7 @@ namespace glabels
|
|||||||
: mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
|
: mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
|
||||||
mYWaste(other.mYWaste), mPath(other.mPath), Frame(other)
|
mYWaste(other.mYWaste), mPath(other.mPath), Frame(other)
|
||||||
{
|
{
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -113,8 +114,8 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
if ( FrameRect *otherRect = dynamic_cast<FrameRect*>(other) )
|
if ( FrameRect *otherRect = dynamic_cast<FrameRect*>(other) )
|
||||||
{
|
{
|
||||||
if ( (fabs( mW - otherRect->mW ) <= Constants::EPSILON) &&
|
if ( (fabs( mW - otherRect->mW ) <= EPSILON) &&
|
||||||
(fabs( mH - otherRect->mH ) <= Constants::EPSILON) )
|
(fabs( mH - otherRect->mH ) <= EPSILON) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "FrameRound.h"
|
#include "FrameRound.h"
|
||||||
|
|
||||||
|
|
||||||
#include "privateConstants.h"
|
#include "Constants.h"
|
||||||
#include "StrUtil.h"
|
#include "StrUtil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -34,13 +34,15 @@ namespace glabels
|
|||||||
: mR(r), mWaste(waste), Frame(id)
|
: mR(r), mWaste(waste), Frame(id)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
|
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 )
|
FrameRound::FrameRound( const FrameRound& other )
|
||||||
: mR(other.mR), mWaste(other.mWaste), mPath(other.mPath), Frame(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 ( FrameRound *otherRound = dynamic_cast<FrameRound*>(other) )
|
||||||
{
|
{
|
||||||
if ( fabs( mR - otherRound->mR ) <= Constants::EPSILON )
|
if ( fabs( mR - otherRound->mR ) <= EPSILON )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+373
-342
@@ -27,61 +27,69 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const double handlePixels = 7;
|
const double handlePixels = 7;
|
||||||
const double handleOutlineWidthPixels = 1;
|
const double handleOutlineWidthPixels = 1;
|
||||||
|
|
||||||
const QColor handleFillColor( 0, 192, 0, 96 );
|
const QColor handleFillColor( 0, 192, 0, 96 );
|
||||||
const QColor originHandleFillColor( 192, 0, 0, 96 );
|
const QColor originHandleFillColor( 192, 0, 0, 96 );
|
||||||
const QColor handleOutlineColor( 0, 0, 0, 192 );
|
const QColor handleOutlineColor( 0, 0, 0, 192 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Handle Constructor
|
/// Handle Constructor
|
||||||
///
|
///
|
||||||
Handle::Handle( LabelModelObject* owner, Location location )
|
Handle::Handle( LabelModelObject* owner, Location location )
|
||||||
: mOwner(owner), mLocation(location)
|
: mOwner(owner), mLocation(location)
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Handle Destructor
|
/// Handle Destructor
|
||||||
///
|
///
|
||||||
Handle::~Handle()
|
Handle::~Handle()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Handle owner
|
/// Handle owner
|
||||||
///
|
///
|
||||||
LabelModelObject* Handle::owner() const
|
LabelModelObject* Handle::owner() const
|
||||||
{
|
{
|
||||||
return mOwner;
|
return mOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Handle location
|
/// Handle location
|
||||||
///
|
///
|
||||||
Handle::Location Handle::location() const
|
Handle::Location Handle::location() const
|
||||||
{
|
{
|
||||||
return mLocation;
|
return mLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Handle at x,y
|
/// Draw Handle at x,y
|
||||||
///
|
///
|
||||||
void Handle::drawAt( QPainter* painter,
|
void Handle::drawAt( QPainter* painter,
|
||||||
double scale,
|
double scale,
|
||||||
const glabels::Distance& x,
|
const Distance& x,
|
||||||
const glabels::Distance& y,
|
const Distance& y,
|
||||||
QColor color ) const
|
QColor color ) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->translate( x.pt(), y.pt() );
|
painter->translate( x.pt(), y.pt() );
|
||||||
@@ -95,19 +103,20 @@ void Handle::drawAt( QPainter* painter,
|
|||||||
painter->setPen( pen );
|
painter->setPen( pen );
|
||||||
painter->setBrush( color );
|
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();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create Handle path at x,y
|
/// Create Handle path at x,y
|
||||||
///
|
///
|
||||||
QPainterPath Handle::pathAt( double scale,
|
QPainterPath Handle::pathAt( double scale,
|
||||||
const glabels::Distance& x,
|
const Distance& x,
|
||||||
const glabels::Distance& y ) const
|
const Distance& y ) const
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
double s = 1/scale;
|
double s = 1/scale;
|
||||||
@@ -116,443 +125,465 @@ QPainterPath Handle::pathAt( double scale,
|
|||||||
path.translate( x.pt(), y.pt() );
|
path.translate( x.pt(), y.pt() );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorth Constructor
|
/// HandleNorth Constructor
|
||||||
///
|
///
|
||||||
HandleNorth::HandleNorth( LabelModelObject* owner )
|
HandleNorth::HandleNorth( LabelModelObject* owner )
|
||||||
: Handle( owner, N )
|
: Handle( owner, N )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorth Destructor
|
/// HandleNorth Destructor
|
||||||
///
|
///
|
||||||
HandleNorth::~HandleNorth()
|
HandleNorth::~HandleNorth()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorth Clone
|
/// HandleNorth Clone
|
||||||
///
|
///
|
||||||
HandleNorth* HandleNorth::clone( LabelModelObject* newOwner ) const
|
HandleNorth* HandleNorth::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleNorth( newOwner );
|
return new HandleNorth( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleNorth
|
/// Draw HandleNorth
|
||||||
///
|
///
|
||||||
void HandleNorth::draw( QPainter* painter, double scale ) const
|
void HandleNorth::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, mOwner->w()/2, 0, handleFillColor );
|
drawAt( painter, scale, mOwner->w()/2, 0, handleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorth Path
|
/// HandleNorth Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleNorth::path( double scale ) const
|
QPainterPath HandleNorth::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, mOwner->w()/2, 0 );
|
return pathAt( scale, mOwner->w()/2, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthEast Constructor
|
/// HandleNorthEast Constructor
|
||||||
///
|
///
|
||||||
HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
|
HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
|
||||||
: Handle( owner, NE )
|
: Handle( owner, NE )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthEast Destructor
|
/// HandleNorthEast Destructor
|
||||||
///
|
///
|
||||||
HandleNorthEast::~HandleNorthEast()
|
HandleNorthEast::~HandleNorthEast()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthEast Clone
|
/// HandleNorthEast Clone
|
||||||
///
|
///
|
||||||
HandleNorthEast* HandleNorthEast::clone( LabelModelObject* newOwner ) const
|
HandleNorthEast* HandleNorthEast::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleNorthEast( newOwner );
|
return new HandleNorthEast( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleNorthEast
|
/// Draw HandleNorthEast
|
||||||
///
|
///
|
||||||
void HandleNorthEast::draw( QPainter* painter, double scale ) const
|
void HandleNorthEast::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, mOwner->w(), 0, handleFillColor );
|
drawAt( painter, scale, mOwner->w(), 0, handleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthEast Path
|
/// HandleNorthEast Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleNorthEast::path( double scale ) const
|
QPainterPath HandleNorthEast::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, mOwner->w(), 0 );
|
return pathAt( scale, mOwner->w(), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleEast Constructor
|
/// HandleEast Constructor
|
||||||
///
|
///
|
||||||
HandleEast::HandleEast( LabelModelObject* owner )
|
HandleEast::HandleEast( LabelModelObject* owner )
|
||||||
: Handle( owner, E )
|
: Handle( owner, E )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleEast Destructor
|
/// HandleEast Destructor
|
||||||
///
|
///
|
||||||
HandleEast::~HandleEast()
|
HandleEast::~HandleEast()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleEast Clone
|
/// HandleEast Clone
|
||||||
///
|
///
|
||||||
HandleEast* HandleEast::clone( LabelModelObject* newOwner ) const
|
HandleEast* HandleEast::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleEast( newOwner );
|
return new HandleEast( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleEast
|
/// Draw HandleEast
|
||||||
///
|
///
|
||||||
void HandleEast::draw( QPainter* painter, double scale ) const
|
void HandleEast::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, mOwner->w(), mOwner->h()/2, handleFillColor );
|
drawAt( painter, scale, mOwner->w(), mOwner->h()/2, handleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleEast Path
|
/// HandleEast Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleEast::path( double scale ) const
|
QPainterPath HandleEast::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, mOwner->w(), mOwner->h()/2 );
|
return pathAt( scale, mOwner->w(), mOwner->h()/2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthEast Constructor
|
/// HandleSouthEast Constructor
|
||||||
///
|
///
|
||||||
HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
|
HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
|
||||||
: Handle( owner, SE )
|
: Handle( owner, SE )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthEast Destructor
|
/// HandleSouthEast Destructor
|
||||||
///
|
///
|
||||||
HandleSouthEast::~HandleSouthEast()
|
HandleSouthEast::~HandleSouthEast()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthEast Clone
|
/// HandleSouthEast Clone
|
||||||
///
|
///
|
||||||
HandleSouthEast* HandleSouthEast::clone( LabelModelObject* newOwner ) const
|
HandleSouthEast* HandleSouthEast::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleSouthEast( newOwner );
|
return new HandleSouthEast( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleSouthEast
|
/// Draw HandleSouthEast
|
||||||
///
|
///
|
||||||
void HandleSouthEast::draw( QPainter* painter, double scale ) const
|
void HandleSouthEast::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, mOwner->w(), mOwner->h(), handleFillColor );
|
drawAt( painter, scale, mOwner->w(), mOwner->h(), handleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthEast Path
|
/// HandleSouthEast Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleSouthEast::path( double scale ) const
|
QPainterPath HandleSouthEast::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, mOwner->w(), mOwner->h() );
|
return pathAt( scale, mOwner->w(), mOwner->h() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouth Constructor
|
/// HandleSouth Constructor
|
||||||
///
|
///
|
||||||
HandleSouth::HandleSouth( LabelModelObject* owner )
|
HandleSouth::HandleSouth( LabelModelObject* owner )
|
||||||
: Handle( owner, S )
|
: Handle( owner, S )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouth Destructor
|
/// HandleSouth Destructor
|
||||||
///
|
///
|
||||||
HandleSouth::~HandleSouth()
|
HandleSouth::~HandleSouth()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouth Clone
|
/// HandleSouth Clone
|
||||||
///
|
///
|
||||||
HandleSouth* HandleSouth::clone( LabelModelObject* newOwner ) const
|
HandleSouth* HandleSouth::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleSouth( newOwner );
|
return new HandleSouth( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleSouth
|
/// Draw HandleSouth
|
||||||
///
|
///
|
||||||
void HandleSouth::draw( QPainter* painter, double scale ) const
|
void HandleSouth::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, mOwner->w()/2, mOwner->h(), handleFillColor );
|
drawAt( painter, scale, mOwner->w()/2, mOwner->h(), handleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouth Path
|
/// HandleSouth Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleSouth::path( double scale ) const
|
QPainterPath HandleSouth::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, mOwner->w()/2, mOwner->h() );
|
return pathAt( scale, mOwner->w()/2, mOwner->h() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthWest Constructor
|
/// HandleSouthWest Constructor
|
||||||
///
|
///
|
||||||
HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
|
HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
|
||||||
: Handle( owner, SW )
|
: Handle( owner, SW )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthWest Destructor
|
/// HandleSouthWest Destructor
|
||||||
///
|
///
|
||||||
HandleSouthWest::~HandleSouthWest()
|
HandleSouthWest::~HandleSouthWest()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthWest Clone
|
/// HandleSouthWest Clone
|
||||||
///
|
///
|
||||||
HandleSouthWest* HandleSouthWest::clone( LabelModelObject* newOwner ) const
|
HandleSouthWest* HandleSouthWest::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleSouthWest( newOwner );
|
return new HandleSouthWest( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleSouthWest
|
/// Draw HandleSouthWest
|
||||||
///
|
///
|
||||||
void HandleSouthWest::draw( QPainter* painter, double scale ) const
|
void HandleSouthWest::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, 0, mOwner->h(), handleFillColor );
|
drawAt( painter, scale, 0, mOwner->h(), handleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthWest Path
|
/// HandleSouthWest Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleSouthWest::path( double scale ) const
|
QPainterPath HandleSouthWest::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, 0, mOwner->h() );
|
return pathAt( scale, 0, mOwner->h() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleWest Constructor
|
/// HandleWest Constructor
|
||||||
///
|
///
|
||||||
HandleWest::HandleWest( LabelModelObject* owner )
|
HandleWest::HandleWest( LabelModelObject* owner )
|
||||||
: Handle( owner, W )
|
: Handle( owner, W )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleWest Destructor
|
/// HandleWest Destructor
|
||||||
///
|
///
|
||||||
HandleWest::~HandleWest()
|
HandleWest::~HandleWest()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleWest Clone
|
/// HandleWest Clone
|
||||||
///
|
///
|
||||||
HandleWest* HandleWest::clone( LabelModelObject* newOwner ) const
|
HandleWest* HandleWest::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleWest( newOwner );
|
return new HandleWest( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleWest
|
/// Draw HandleWest
|
||||||
///
|
///
|
||||||
void HandleWest::draw( QPainter* painter, double scale ) const
|
void HandleWest::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, 0, mOwner->h()/2, handleFillColor );
|
drawAt( painter, scale, 0, mOwner->h()/2, handleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleWest Path
|
/// HandleWest Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleWest::path( double scale ) const
|
QPainterPath HandleWest::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, 0, mOwner->h()/2 );
|
return pathAt( scale, 0, mOwner->h()/2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthWest Constructor
|
/// HandleNorthWest Constructor
|
||||||
///
|
///
|
||||||
HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
|
HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
|
||||||
: Handle( owner, NW )
|
: Handle( owner, NW )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthWest Destructor
|
/// HandleNorthWest Destructor
|
||||||
///
|
///
|
||||||
HandleNorthWest::~HandleNorthWest()
|
HandleNorthWest::~HandleNorthWest()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthWest Clone
|
/// HandleNorthWest Clone
|
||||||
///
|
///
|
||||||
HandleNorthWest* HandleNorthWest::clone( LabelModelObject* newOwner ) const
|
HandleNorthWest* HandleNorthWest::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleNorthWest( newOwner );
|
return new HandleNorthWest( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleNorthWest
|
/// Draw HandleNorthWest
|
||||||
///
|
///
|
||||||
void HandleNorthWest::draw( QPainter* painter, double scale ) const
|
void HandleNorthWest::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, 0, 0, originHandleFillColor );
|
drawAt( painter, scale, 0, 0, originHandleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthWest Path
|
/// HandleNorthWest Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleNorthWest::path( double scale ) const
|
QPainterPath HandleNorthWest::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, 0, 0 );
|
return pathAt( scale, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP1 Constructor
|
/// HandleP1 Constructor
|
||||||
///
|
///
|
||||||
HandleP1::HandleP1( LabelModelObject* owner )
|
HandleP1::HandleP1( LabelModelObject* owner )
|
||||||
: Handle( owner, P1 )
|
: Handle( owner, P1 )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP1 Destructor
|
/// HandleP1 Destructor
|
||||||
///
|
///
|
||||||
HandleP1::~HandleP1()
|
HandleP1::~HandleP1()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP1 Clone
|
/// HandleP1 Clone
|
||||||
///
|
///
|
||||||
HandleP1* HandleP1::clone( LabelModelObject* newOwner ) const
|
HandleP1* HandleP1::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleP1( newOwner );
|
return new HandleP1( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleP1
|
/// Draw HandleP1
|
||||||
///
|
///
|
||||||
void HandleP1::draw( QPainter* painter, double scale ) const
|
void HandleP1::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, 0, 0, originHandleFillColor );
|
drawAt( painter, scale, 0, 0, originHandleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP1 Path
|
/// HandleP1 Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleP1::path( double scale ) const
|
QPainterPath HandleP1::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, 0, 0 );
|
return pathAt( scale, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP2 Constructor
|
/// HandleP2 Constructor
|
||||||
///
|
///
|
||||||
HandleP2::HandleP2( LabelModelObject* owner )
|
HandleP2::HandleP2( LabelModelObject* owner )
|
||||||
: Handle( owner, P2 )
|
: Handle( owner, P2 )
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP2 Destructor
|
/// HandleP2 Destructor
|
||||||
///
|
///
|
||||||
HandleP2::~HandleP2()
|
HandleP2::~HandleP2()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP2 Clone
|
/// HandleP2 Clone
|
||||||
///
|
///
|
||||||
HandleP2* HandleP2::clone( LabelModelObject* newOwner ) const
|
HandleP2* HandleP2::clone( LabelModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new HandleP2( newOwner );
|
return new HandleP2( newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw HandleP2
|
/// Draw HandleP2
|
||||||
///
|
///
|
||||||
void HandleP2::draw( QPainter* painter, double scale ) const
|
void HandleP2::draw( QPainter* painter, double scale ) const
|
||||||
{
|
{
|
||||||
drawAt( painter, scale, mOwner->w(), mOwner->h(), handleFillColor );
|
drawAt( painter, scale, mOwner->w(), mOwner->h(), handleFillColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP2 Path
|
/// HandleP2 Path
|
||||||
///
|
///
|
||||||
QPainterPath HandleP2::path( double scale ) const
|
QPainterPath HandleP2::path( double scale ) const
|
||||||
{
|
{
|
||||||
return pathAt( scale, mOwner->w(), mOwner->h() );
|
return pathAt( scale, mOwner->w(), mOwner->h() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+104
-98
@@ -27,28 +27,32 @@
|
|||||||
|
|
||||||
#include "Distance.h"
|
#include "Distance.h"
|
||||||
|
|
||||||
// Forward References
|
|
||||||
class LabelModelObject;
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
///
|
|
||||||
/// Handle Base Class
|
|
||||||
///
|
|
||||||
class Handle
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward References
|
||||||
|
class LabelModelObject;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Handle Base Class
|
||||||
|
///
|
||||||
|
class Handle
|
||||||
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Location enumeration
|
// Location enumeration
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
|
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
Handle( LabelModelObject* owner, Location location );
|
Handle( LabelModelObject* owner, Location location );
|
||||||
public:
|
public:
|
||||||
virtual ~Handle();
|
virtual ~Handle();
|
||||||
|
|
||||||
|
|
||||||
@@ -68,40 +72,40 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const = 0;
|
virtual void draw( QPainter* painter, double scale ) const = 0;
|
||||||
virtual QPainterPath path( double scale ) const = 0;
|
virtual QPainterPath path( double scale ) const = 0;
|
||||||
protected:
|
protected:
|
||||||
void drawAt( QPainter* painter,
|
void drawAt( QPainter* painter,
|
||||||
double scale,
|
double scale,
|
||||||
const glabels::Distance& x,
|
const Distance& x,
|
||||||
const glabels::Distance& y,
|
const Distance& y,
|
||||||
QColor color ) const;
|
QColor color ) const;
|
||||||
|
|
||||||
QPainterPath pathAt( double scale,
|
QPainterPath pathAt( double scale,
|
||||||
const glabels::Distance& x,
|
const Distance& x,
|
||||||
const glabels::Distance& y ) const;
|
const Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Protected Data
|
// Protected Data
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
LabelModelObject* mOwner;
|
LabelModelObject* mOwner;
|
||||||
Location mLocation;
|
Location mLocation;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorth Class
|
/// HandleNorth Class
|
||||||
///
|
///
|
||||||
class HandleNorth : public Handle
|
class HandleNorth : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleNorth( LabelModelObject* owner );
|
HandleNorth( LabelModelObject* owner );
|
||||||
virtual ~HandleNorth();
|
virtual ~HandleNorth();
|
||||||
virtual HandleNorth* clone( LabelModelObject* newOwner ) const;
|
virtual HandleNorth* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -110,21 +114,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthEast Class
|
/// HandleNorthEast Class
|
||||||
///
|
///
|
||||||
class HandleNorthEast : public Handle
|
class HandleNorthEast : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleNorthEast( LabelModelObject* owner );
|
HandleNorthEast( LabelModelObject* owner );
|
||||||
virtual ~HandleNorthEast();
|
virtual ~HandleNorthEast();
|
||||||
virtual HandleNorthEast* clone( LabelModelObject* newOwner ) const;
|
virtual HandleNorthEast* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -133,21 +137,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleEast Class
|
/// HandleEast Class
|
||||||
///
|
///
|
||||||
class HandleEast : public Handle
|
class HandleEast : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleEast( LabelModelObject* owner );
|
HandleEast( LabelModelObject* owner );
|
||||||
virtual ~HandleEast();
|
virtual ~HandleEast();
|
||||||
virtual HandleEast* clone( LabelModelObject* newOwner ) const;
|
virtual HandleEast* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -156,21 +160,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthEast Class
|
/// HandleSouthEast Class
|
||||||
///
|
///
|
||||||
class HandleSouthEast : public Handle
|
class HandleSouthEast : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleSouthEast( LabelModelObject* owner );
|
HandleSouthEast( LabelModelObject* owner );
|
||||||
virtual ~HandleSouthEast();
|
virtual ~HandleSouthEast();
|
||||||
virtual HandleSouthEast* clone( LabelModelObject* newOwner ) const;
|
virtual HandleSouthEast* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -179,21 +183,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouth Class
|
/// HandleSouth Class
|
||||||
///
|
///
|
||||||
class HandleSouth : public Handle
|
class HandleSouth : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleSouth( LabelModelObject* owner );
|
HandleSouth( LabelModelObject* owner );
|
||||||
virtual ~HandleSouth();
|
virtual ~HandleSouth();
|
||||||
virtual HandleSouth* clone( LabelModelObject* newOwner ) const;
|
virtual HandleSouth* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -202,21 +206,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthWest Class
|
/// HandleSouthWest Class
|
||||||
///
|
///
|
||||||
class HandleSouthWest : public Handle
|
class HandleSouthWest : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleSouthWest( LabelModelObject* owner );
|
HandleSouthWest( LabelModelObject* owner );
|
||||||
virtual ~HandleSouthWest();
|
virtual ~HandleSouthWest();
|
||||||
virtual HandleSouthWest* clone( LabelModelObject* newOwner ) const;
|
virtual HandleSouthWest* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -225,21 +229,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleWest Class
|
/// HandleWest Class
|
||||||
///
|
///
|
||||||
class HandleWest : public Handle
|
class HandleWest : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleWest( LabelModelObject* owner );
|
HandleWest( LabelModelObject* owner );
|
||||||
virtual ~HandleWest();
|
virtual ~HandleWest();
|
||||||
virtual HandleWest* clone( LabelModelObject* newOwner ) const;
|
virtual HandleWest* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -248,21 +252,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthWest Class
|
/// HandleNorthWest Class
|
||||||
///
|
///
|
||||||
class HandleNorthWest : public Handle
|
class HandleNorthWest : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleNorthWest( LabelModelObject* owner );
|
HandleNorthWest( LabelModelObject* owner );
|
||||||
virtual ~HandleNorthWest();
|
virtual ~HandleNorthWest();
|
||||||
virtual HandleNorthWest* clone( LabelModelObject* newOwner ) const;
|
virtual HandleNorthWest* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -271,21 +275,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP1 Class
|
/// HandleP1 Class
|
||||||
///
|
///
|
||||||
class HandleP1 : public Handle
|
class HandleP1 : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleP1( LabelModelObject* owner );
|
HandleP1( LabelModelObject* owner );
|
||||||
virtual ~HandleP1();
|
virtual ~HandleP1();
|
||||||
virtual HandleP1* clone( LabelModelObject* newOwner ) const;
|
virtual HandleP1* clone( LabelModelObject* newOwner ) const;
|
||||||
@@ -294,21 +298,21 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP2 Class
|
/// HandleP2 Class
|
||||||
///
|
///
|
||||||
class HandleP2 : public Handle
|
class HandleP2 : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleP2( LabelModelObject* owner );
|
HandleP2( LabelModelObject* owner );
|
||||||
virtual ~HandleP2();
|
virtual ~HandleP2();
|
||||||
|
|
||||||
@@ -321,10 +325,12 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
virtual QPainterPath path( double scale ) const;
|
virtual QPainterPath path( double scale ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // Handles_h
|
#endif // Handles_h
|
||||||
|
|||||||
+15
-10
@@ -26,20 +26,25 @@
|
|||||||
#include "AboutDialog.h"
|
#include "AboutDialog.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Display Help Contents
|
|
||||||
///
|
|
||||||
void Help::displayContents( QWidget *parent )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Display Help Contents
|
||||||
|
///
|
||||||
|
void Help::displayContents( QWidget *parent )
|
||||||
|
{
|
||||||
qDebug() << "TODO: Help::displayContents";
|
qDebug() << "TODO: Help::displayContents";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Display Help->About Dialog
|
/// Display Help->About Dialog
|
||||||
///
|
///
|
||||||
void Help::displayAbout( QWidget *parent )
|
void Help::displayAbout( QWidget *parent )
|
||||||
{
|
{
|
||||||
AboutDialog dialog( parent );
|
AboutDialog dialog( parent );
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-5
@@ -25,16 +25,20 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Help Actions
|
|
||||||
///
|
|
||||||
namespace Help
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Help Actions
|
||||||
|
///
|
||||||
|
namespace Help
|
||||||
|
{
|
||||||
|
|
||||||
void displayContents( QWidget *parent );
|
void displayContents( QWidget *parent );
|
||||||
void displayAbout( QWidget *parent );
|
void displayAbout( QWidget *parent );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // Help_h
|
#endif // Help_h
|
||||||
|
|||||||
+7
-11
@@ -25,12 +25,15 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Glabels Icons
|
|
||||||
///
|
|
||||||
namespace Icons
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Glabels Icons
|
||||||
|
///
|
||||||
|
namespace Icons
|
||||||
|
{
|
||||||
|
|
||||||
class Arrow : public QIcon
|
class Arrow : public QIcon
|
||||||
{
|
{
|
||||||
public:
|
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
|
class EditCopy : public QIcon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
+295
-292
@@ -42,15 +42,17 @@
|
|||||||
#include "UndoRedoModel.h"
|
#include "UndoRedoModel.h"
|
||||||
|
|
||||||
|
|
||||||
//
|
namespace glabels
|
||||||
// Private Configuration Data
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const int nZoomLevels = 11;
|
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 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 double ZOOM_TO_FIT_PAD = 16.0;
|
||||||
|
|
||||||
const QColor backgroundColor( 192, 192, 192 );
|
const QColor backgroundColor( 192, 192, 192 );
|
||||||
@@ -64,7 +66,7 @@ namespace
|
|||||||
|
|
||||||
const QColor gridLineColor( 192, 192, 192 );
|
const QColor gridLineColor( 192, 192, 192 );
|
||||||
const double gridLineWidthPixels = 1;
|
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 QColor markupLineColor( 240, 99, 99 );
|
||||||
const double markupLineWidthPixels = 1;
|
const double markupLineWidthPixels = 1;
|
||||||
@@ -72,16 +74,15 @@ namespace
|
|||||||
const QColor selectRegionFillColor( 192, 192, 255, 128 );
|
const QColor selectRegionFillColor( 192, 192, 255, 128 );
|
||||||
const QColor selectRegionOutlineColor( 0, 0, 255, 128 );
|
const QColor selectRegionOutlineColor( 0, 0, 255, 128 );
|
||||||
const double selectRegionOutlineWidthPixels = 3;
|
const double selectRegionOutlineWidthPixels = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Constructor
|
||||||
/// Constructor
|
///
|
||||||
///
|
LabelEditor::LabelEditor( QScrollArea* scrollArea, QWidget* parent )
|
||||||
LabelEditor::LabelEditor( QScrollArea* scrollArea, QWidget* parent )
|
|
||||||
: QWidget(parent), mScrollArea(scrollArea)
|
: QWidget(parent), mScrollArea(scrollArea)
|
||||||
{
|
{
|
||||||
mState = IdleState;
|
mState = IdleState;
|
||||||
|
|
||||||
mModel = 0;
|
mModel = 0;
|
||||||
@@ -95,45 +96,45 @@ LabelEditor::LabelEditor( QScrollArea* scrollArea, QWidget* parent )
|
|||||||
|
|
||||||
connect( Settings::instance(), SIGNAL(changed()), this, SLOT(onSettingsChanged()) );
|
connect( Settings::instance(), SIGNAL(changed()), this, SLOT(onSettingsChanged()) );
|
||||||
onSettingsChanged();
|
onSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Zoom property
|
/// Zoom property
|
||||||
///
|
///
|
||||||
double
|
double
|
||||||
LabelEditor::zoom() const
|
LabelEditor::zoom() const
|
||||||
{
|
{
|
||||||
return mZoom;
|
return mZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Markup visible? property
|
/// Markup visible? property
|
||||||
///
|
///
|
||||||
bool
|
bool
|
||||||
LabelEditor::markupVisible() const
|
LabelEditor::markupVisible() const
|
||||||
{
|
{
|
||||||
return mMarkupVisible;
|
return mMarkupVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Grid visible? property
|
/// Grid visible? property
|
||||||
///
|
///
|
||||||
bool
|
bool
|
||||||
LabelEditor::qridVisible() const
|
LabelEditor::qridVisible() const
|
||||||
{
|
{
|
||||||
return mGridVisible;
|
return mGridVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Model Parameter Setter
|
/// Model Parameter Setter
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
LabelEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||||
{
|
{
|
||||||
mModel = model;
|
mModel = model;
|
||||||
mUndoRedoModel = undoRedoModel;
|
mUndoRedoModel = undoRedoModel;
|
||||||
|
|
||||||
@@ -147,37 +148,37 @@ LabelEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
|||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Grid Visibility Parameter Setter
|
/// Grid Visibility Parameter Setter
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::setGridVisible( bool visibleFlag )
|
LabelEditor::setGridVisible( bool visibleFlag )
|
||||||
{
|
{
|
||||||
mGridVisible = visibleFlag;
|
mGridVisible = visibleFlag;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Markup Visibility Parameter Setter
|
/// Markup Visibility Parameter Setter
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::setMarkupVisible( bool visibleFlag )
|
LabelEditor::setMarkupVisible( bool visibleFlag )
|
||||||
{
|
{
|
||||||
mMarkupVisible = visibleFlag;
|
mMarkupVisible = visibleFlag;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Zoom In "One Notch"
|
/// Zoom In "One Notch"
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::zoomIn()
|
LabelEditor::zoomIn()
|
||||||
{
|
{
|
||||||
// Find closest standard zoom level to our current zoom
|
// Find closest standard zoom level to our current zoom
|
||||||
// Start with 2nd largest scale
|
// Start with 2nd largest scale
|
||||||
int i_min = 1;
|
int i_min = 1;
|
||||||
@@ -195,15 +196,15 @@ LabelEditor::zoomIn()
|
|||||||
|
|
||||||
// Zoom in one notch
|
// Zoom in one notch
|
||||||
setZoomReal( zoomLevels[i_min-1], false );
|
setZoomReal( zoomLevels[i_min-1], false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Zoom Out "One Notch"
|
/// Zoom Out "One Notch"
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::zoomOut()
|
LabelEditor::zoomOut()
|
||||||
{
|
{
|
||||||
// Find closest standard zoom level to our current zoom
|
// Find closest standard zoom level to our current zoom
|
||||||
// Start with largest scale, end on 2nd smallest
|
// Start with largest scale, end on 2nd smallest
|
||||||
int i_min = 0;
|
int i_min = 0;
|
||||||
@@ -221,25 +222,25 @@ LabelEditor::zoomOut()
|
|||||||
|
|
||||||
// Zoom out one notch
|
// Zoom out one notch
|
||||||
setZoomReal( zoomLevels[i_min+1], false );
|
setZoomReal( zoomLevels[i_min+1], false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Zoom To 1:1 Scale
|
/// Zoom To 1:1 Scale
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::zoom1To1()
|
LabelEditor::zoom1To1()
|
||||||
{
|
{
|
||||||
setZoomReal( 1.0, false );
|
setZoomReal( 1.0, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Zoom To Fit
|
/// Zoom To Fit
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::zoomToFit()
|
LabelEditor::zoomToFit()
|
||||||
{
|
{
|
||||||
double wPixels = mScrollArea->maximumViewportSize().width();
|
double wPixels = mScrollArea->maximumViewportSize().width();
|
||||||
double hPixels = mScrollArea->maximumViewportSize().height();
|
double hPixels = mScrollArea->maximumViewportSize().height();
|
||||||
|
|
||||||
@@ -252,35 +253,35 @@ LabelEditor::zoomToFit()
|
|||||||
newZoom = qMax( newZoom, zoomLevels[nZoomLevels-1] );
|
newZoom = qMax( newZoom, zoomLevels[nZoomLevels-1] );
|
||||||
|
|
||||||
setZoomReal( newZoom, true );
|
setZoomReal( newZoom, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Is Zoom at Maximum?
|
/// Is Zoom at Maximum?
|
||||||
///
|
///
|
||||||
bool
|
bool
|
||||||
LabelEditor::isZoomMax() const
|
LabelEditor::isZoomMax() const
|
||||||
{
|
{
|
||||||
return mZoom >= zoomLevels[0];
|
return mZoom >= zoomLevels[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Is Zoom at Minimum?
|
/// Is Zoom at Minimum?
|
||||||
///
|
///
|
||||||
bool
|
bool
|
||||||
LabelEditor::isZoomMin() const
|
LabelEditor::isZoomMin() const
|
||||||
{
|
{
|
||||||
return mZoom <= zoomLevels[nZoomLevels-1];
|
return mZoom <= zoomLevels[nZoomLevels-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set Zoom to Value
|
/// Set Zoom to Value
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::setZoomReal( double zoom, bool zoomToFitFlag )
|
LabelEditor::setZoomReal( double zoom, bool zoomToFitFlag )
|
||||||
{
|
{
|
||||||
mZoom = zoom;
|
mZoom = zoom;
|
||||||
mZoomToFitFlag = zoomToFitFlag;
|
mZoomToFitFlag = zoomToFitFlag;
|
||||||
|
|
||||||
@@ -297,92 +298,92 @@ LabelEditor::setZoomReal( double zoom, bool zoomToFitFlag )
|
|||||||
update();
|
update();
|
||||||
|
|
||||||
emit zoomChanged();
|
emit zoomChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Arrow mode (normal mode)
|
/// Arrow mode (normal mode)
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::arrowMode()
|
LabelEditor::arrowMode()
|
||||||
{
|
{
|
||||||
setCursor( Qt::ArrowCursor );
|
setCursor( Qt::ArrowCursor );
|
||||||
|
|
||||||
mState = IdleState;
|
mState = IdleState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create box mode
|
/// Create box mode
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::createBoxMode()
|
LabelEditor::createBoxMode()
|
||||||
{
|
{
|
||||||
setCursor( Cursors::Box() );
|
setCursor( Cursors::Box() );
|
||||||
|
|
||||||
mCreateObjectType = Box;
|
mCreateObjectType = Box;
|
||||||
mState = CreateIdle;
|
mState = CreateIdle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create ellipse mode
|
/// Create ellipse mode
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::createEllipseMode()
|
LabelEditor::createEllipseMode()
|
||||||
{
|
{
|
||||||
setCursor( Cursors::Ellipse() );
|
setCursor( Cursors::Ellipse() );
|
||||||
|
|
||||||
mCreateObjectType = Ellipse;
|
mCreateObjectType = Ellipse;
|
||||||
mState = CreateIdle;
|
mState = CreateIdle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create image mode
|
/// Create image mode
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::createImageMode()
|
LabelEditor::createImageMode()
|
||||||
{
|
{
|
||||||
setCursor( Cursors::Image() );
|
setCursor( Cursors::Image() );
|
||||||
|
|
||||||
mCreateObjectType = Image;
|
mCreateObjectType = Image;
|
||||||
mState = CreateIdle;
|
mState = CreateIdle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create line mode
|
/// Create line mode
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::createLineMode()
|
LabelEditor::createLineMode()
|
||||||
{
|
{
|
||||||
setCursor( Cursors::Line() );
|
setCursor( Cursors::Line() );
|
||||||
|
|
||||||
mCreateObjectType = Line;
|
mCreateObjectType = Line;
|
||||||
mState = CreateIdle;
|
mState = CreateIdle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create text mode
|
/// Create text mode
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::createTextMode()
|
LabelEditor::createTextMode()
|
||||||
{
|
{
|
||||||
setCursor( Cursors::Text() );
|
setCursor( Cursors::Text() );
|
||||||
|
|
||||||
mCreateObjectType = Text;
|
mCreateObjectType = Text;
|
||||||
mState = CreateIdle;
|
mState = CreateIdle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Resize Event Handler
|
/// Resize Event Handler
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::resizeEvent( QResizeEvent *event )
|
LabelEditor::resizeEvent( QResizeEvent *event )
|
||||||
{
|
{
|
||||||
if ( mModel )
|
if ( mModel )
|
||||||
{
|
{
|
||||||
if ( mZoomToFitFlag )
|
if ( mZoomToFitFlag )
|
||||||
@@ -398,15 +399,15 @@ LabelEditor::resizeEvent( QResizeEvent *event )
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Mouse Button Press Event Handler
|
/// Mouse Button Press Event Handler
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::mousePressEvent( QMouseEvent* event )
|
LabelEditor::mousePressEvent( QMouseEvent* event )
|
||||||
{
|
{
|
||||||
if ( mModel )
|
if ( mModel )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -418,8 +419,8 @@ LabelEditor::mousePressEvent( QMouseEvent* event )
|
|||||||
transform.translate( mX0.pt(), mY0.pt() );
|
transform.translate( mX0.pt(), mY0.pt() );
|
||||||
|
|
||||||
QPointF pWorld = transform.inverted().map( event->pos() );
|
QPointF pWorld = transform.inverted().map( event->pos() );
|
||||||
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
|
Distance xWorld = Distance::pt( pWorld.x() );
|
||||||
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
|
Distance yWorld = Distance::pt( pWorld.y() );
|
||||||
|
|
||||||
|
|
||||||
if ( event->button() & Qt::LeftButton )
|
if ( event->button() & Qt::LeftButton )
|
||||||
@@ -564,15 +565,15 @@ LabelEditor::mousePressEvent( QMouseEvent* event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Mouse Movement Event Handler
|
/// Mouse Movement Event Handler
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::mouseMoveEvent( QMouseEvent* event )
|
LabelEditor::mouseMoveEvent( QMouseEvent* event )
|
||||||
{
|
{
|
||||||
if ( mModel )
|
if ( mModel )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -584,8 +585,8 @@ LabelEditor::mouseMoveEvent( QMouseEvent* event )
|
|||||||
transform.translate( mX0.pt(), mY0.pt() );
|
transform.translate( mX0.pt(), mY0.pt() );
|
||||||
|
|
||||||
QPointF pWorld = transform.inverted().map( event->pos() );
|
QPointF pWorld = transform.inverted().map( event->pos() );
|
||||||
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
|
Distance xWorld = Distance::pt( pWorld.x() );
|
||||||
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
|
Distance yWorld = Distance::pt( pWorld.y() );
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -666,15 +667,15 @@ LabelEditor::mouseMoveEvent( QMouseEvent* event )
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Mouse Button Release Event Handler
|
/// Mouse Button Release Event Handler
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::mouseReleaseEvent( QMouseEvent* event )
|
LabelEditor::mouseReleaseEvent( QMouseEvent* event )
|
||||||
{
|
{
|
||||||
if ( mModel )
|
if ( mModel )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -686,8 +687,8 @@ LabelEditor::mouseReleaseEvent( QMouseEvent* event )
|
|||||||
transform.translate( mX0.pt(), mY0.pt() );
|
transform.translate( mX0.pt(), mY0.pt() );
|
||||||
|
|
||||||
QPointF pWorld = transform.inverted().map( event->pos() );
|
QPointF pWorld = transform.inverted().map( event->pos() );
|
||||||
glabels::Distance xWorld = glabels::Distance::pt( pWorld.x() );
|
Distance xWorld = Distance::pt( pWorld.x() );
|
||||||
glabels::Distance yWorld = glabels::Distance::pt( pWorld.y() );
|
Distance yWorld = Distance::pt( pWorld.y() );
|
||||||
|
|
||||||
|
|
||||||
if ( event->button() & Qt::LeftButton )
|
if ( event->button() & Qt::LeftButton )
|
||||||
@@ -742,29 +743,29 @@ LabelEditor::mouseReleaseEvent( QMouseEvent* event )
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Leave Event Handler
|
/// Leave Event Handler
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::leaveEvent( QEvent* event )
|
LabelEditor::leaveEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
if ( mModel )
|
if ( mModel )
|
||||||
{
|
{
|
||||||
emit pointerExited();
|
emit pointerExited();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Handle resize motion
|
/// Handle resize motion
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
|
LabelEditor::handleResizeMotion( const Distance& xWorld,
|
||||||
const glabels::Distance& yWorld )
|
const Distance& yWorld )
|
||||||
{
|
{
|
||||||
QPointF p( xWorld.pt(), yWorld.pt() );
|
QPointF p( xWorld.pt(), yWorld.pt() );
|
||||||
Handle::Location location = mResizeHandle->location();
|
Handle::Location location = mResizeHandle->location();
|
||||||
|
|
||||||
@@ -853,22 +854,22 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
|
|||||||
{
|
{
|
||||||
case Handle::E:
|
case Handle::E:
|
||||||
case Handle::W:
|
case Handle::W:
|
||||||
mResizeObject->setWHonorAspect( glabels::Distance::pt(w) );
|
mResizeObject->setWHonorAspect( Distance::pt(w) );
|
||||||
break;
|
break;
|
||||||
case Handle::N:
|
case Handle::N:
|
||||||
case Handle::S:
|
case Handle::S:
|
||||||
mResizeObject->setHHonorAspect( glabels::Distance::pt(h) );
|
mResizeObject->setHHonorAspect( Distance::pt(h) );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mResizeObject->setSizeHonorAspect( glabels::Distance::pt(w),
|
mResizeObject->setSizeHonorAspect( Distance::pt(w),
|
||||||
glabels::Distance::pt(h) );
|
Distance::pt(h) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mResizeObject->setSize( glabels::Distance::pt(w),
|
mResizeObject->setSize( Distance::pt(w),
|
||||||
glabels::Distance::pt(h) );
|
Distance::pt(h) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -894,8 +895,8 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mResizeObject->setSize( glabels::Distance::pt(w),
|
mResizeObject->setSize( Distance::pt(w),
|
||||||
glabels::Distance::pt(h) );
|
Distance::pt(h) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -904,16 +905,16 @@ LabelEditor::handleResizeMotion( const glabels::Distance& xWorld,
|
|||||||
QPointF p0( x0, y0 );
|
QPointF p0( x0, y0 );
|
||||||
p0 = mResizeObject->matrix().map( p0 );
|
p0 = mResizeObject->matrix().map( p0 );
|
||||||
p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
|
p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
|
||||||
mResizeObject->setPosition( glabels::Distance::pt(p0.x()),
|
mResizeObject->setPosition( Distance::pt(p0.x()),
|
||||||
glabels::Distance::pt(p0.y()) );
|
Distance::pt(p0.y()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Key Press Event Handler
|
/// Key Press Event Handler
|
||||||
void
|
void
|
||||||
LabelEditor::keyPressEvent( QKeyEvent* event )
|
LabelEditor::keyPressEvent( QKeyEvent* event )
|
||||||
{
|
{
|
||||||
if ( mState == IdleState )
|
if ( mState == IdleState )
|
||||||
{
|
{
|
||||||
switch (event->key())
|
switch (event->key())
|
||||||
@@ -921,22 +922,22 @@ LabelEditor::keyPressEvent( QKeyEvent* event )
|
|||||||
|
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
mUndoRedoModel->checkpoint( tr("Move") );
|
mUndoRedoModel->checkpoint( tr("Move") );
|
||||||
mModel->moveSelection( -mStepSize, glabels::Distance(0) );
|
mModel->moveSelection( -mStepSize, Distance(0) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
mUndoRedoModel->checkpoint( tr("Move") );
|
mUndoRedoModel->checkpoint( tr("Move") );
|
||||||
mModel->moveSelection( glabels::Distance(0), -mStepSize );
|
mModel->moveSelection( Distance(0), -mStepSize );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
mUndoRedoModel->checkpoint( tr("Move") );
|
mUndoRedoModel->checkpoint( tr("Move") );
|
||||||
mModel->moveSelection( mStepSize, glabels::Distance(0) );
|
mModel->moveSelection( mStepSize, Distance(0) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
mUndoRedoModel->checkpoint( tr("Move") );
|
mUndoRedoModel->checkpoint( tr("Move") );
|
||||||
mModel->moveSelection( glabels::Distance(0), mStepSize );
|
mModel->moveSelection( Distance(0), mStepSize );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
@@ -955,15 +956,15 @@ LabelEditor::keyPressEvent( QKeyEvent* event )
|
|||||||
{
|
{
|
||||||
QWidget::keyPressEvent( event );
|
QWidget::keyPressEvent( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Paint Event Handler
|
/// Paint Event Handler
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::paintEvent( QPaintEvent* event )
|
LabelEditor::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
if ( mModel )
|
if ( mModel )
|
||||||
{
|
{
|
||||||
QPainter painter( this );
|
QPainter painter( this );
|
||||||
@@ -990,15 +991,15 @@ LabelEditor::paintEvent( QPaintEvent* event )
|
|||||||
drawHighlightLayer( &painter );
|
drawHighlightLayer( &painter );
|
||||||
drawSelectRegionLayer( &painter );
|
drawSelectRegionLayer( &painter );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Background Layer
|
/// Draw Background Layer
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::drawBgLayer( QPainter* painter )
|
LabelEditor::drawBgLayer( QPainter* painter )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Draw shadow
|
* Draw shadow
|
||||||
*/
|
*/
|
||||||
@@ -1035,22 +1036,22 @@ LabelEditor::drawBgLayer( QPainter* painter )
|
|||||||
painter->drawPath( mModel->frame()->path() );
|
painter->drawPath( mModel->frame()->path() );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Grid Layer
|
/// Draw Grid Layer
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::drawGridLayer( QPainter* painter )
|
LabelEditor::drawGridLayer( QPainter* painter )
|
||||||
{
|
{
|
||||||
if ( mGridVisible )
|
if ( mGridVisible )
|
||||||
{
|
{
|
||||||
glabels::Distance w = mModel->frame()->w();
|
Distance w = mModel->frame()->w();
|
||||||
glabels::Distance h = mModel->frame()->h();
|
Distance h = mModel->frame()->h();
|
||||||
|
|
||||||
glabels::Distance x0, y0;
|
Distance x0, y0;
|
||||||
if ( dynamic_cast<const glabels::FrameRect*>( mModel->frame() ) )
|
if ( dynamic_cast<const FrameRect*>( mModel->frame() ) )
|
||||||
{
|
{
|
||||||
x0 = gridSpacing;
|
x0 = gridSpacing;
|
||||||
y0 = gridSpacing;
|
y0 = gridSpacing;
|
||||||
@@ -1075,27 +1076,27 @@ LabelEditor::drawGridLayer( QPainter* painter )
|
|||||||
pen.setCosmetic( true );
|
pen.setCosmetic( true );
|
||||||
painter->setPen( pen );
|
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() );
|
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->drawLine( 0, y.pt(), w.pt(), y.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Markup Layer
|
/// Draw Markup Layer
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::drawMarkupLayer( QPainter* painter )
|
LabelEditor::drawMarkupLayer( QPainter* painter )
|
||||||
{
|
{
|
||||||
if ( mMarkupVisible )
|
if ( mMarkupVisible )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
@@ -1112,32 +1113,32 @@ LabelEditor::drawMarkupLayer( QPainter* painter )
|
|||||||
painter->translate( -mModel->frame()->w().pt(), 0 );
|
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->drawPath( markup->path() );
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Objects Layer
|
/// Draw Objects Layer
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::drawObjectsLayer( QPainter* painter )
|
LabelEditor::drawObjectsLayer( QPainter* painter )
|
||||||
{
|
{
|
||||||
mModel->draw( painter );
|
mModel->draw( painter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Foreground Layer
|
/// Draw Foreground Layer
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::drawFgLayer( QPainter* painter )
|
LabelEditor::drawFgLayer( QPainter* painter )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Draw label outline
|
* Draw label outline
|
||||||
*/
|
*/
|
||||||
@@ -1156,15 +1157,15 @@ LabelEditor::drawFgLayer( QPainter* painter )
|
|||||||
painter->drawPath( mModel->frame()->path() );
|
painter->drawPath( mModel->frame()->path() );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Highlight Layer
|
/// Draw Highlight Layer
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::drawHighlightLayer( QPainter* painter )
|
LabelEditor::drawHighlightLayer( QPainter* painter )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
foreach ( LabelModelObject* object, mModel->objectList() )
|
foreach ( LabelModelObject* object, mModel->objectList() )
|
||||||
@@ -1176,15 +1177,15 @@ LabelEditor::drawHighlightLayer( QPainter* painter )
|
|||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Select Region Layer
|
/// Draw Select Region Layer
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelEditor::drawSelectRegionLayer( QPainter* painter )
|
LabelEditor::drawSelectRegionLayer( QPainter* painter )
|
||||||
{
|
{
|
||||||
if ( mSelectRegionVisible )
|
if ( mSelectRegionVisible )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
@@ -1199,25 +1200,25 @@ LabelEditor::drawSelectRegionLayer( QPainter* painter )
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Settings changed handler
|
/// Settings changed handler
|
||||||
///
|
///
|
||||||
void LabelEditor::onSettingsChanged()
|
void LabelEditor::onSettingsChanged()
|
||||||
{
|
{
|
||||||
glabels::Units units = Settings::units();
|
Units units = Settings::units();
|
||||||
|
|
||||||
mStepSize = glabels::Distance( units.resolution(), units );
|
mStepSize = Distance( units.resolution(), units );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Model size changed handler
|
/// Model size changed handler
|
||||||
///
|
///
|
||||||
void LabelEditor::onModelSizeChanged()
|
void LabelEditor::onModelSizeChanged()
|
||||||
{
|
{
|
||||||
if (mZoomToFitFlag)
|
if (mZoomToFitFlag)
|
||||||
{
|
{
|
||||||
double wPixels = mScrollArea->maximumViewportSize().width();
|
double wPixels = mScrollArea->maximumViewportSize().width();
|
||||||
@@ -1247,4 +1248,6 @@ void LabelEditor::onModelSizeChanged()
|
|||||||
update();
|
update();
|
||||||
|
|
||||||
emit zoomChanged();
|
emit zoomChanged();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-33
@@ -28,34 +28,38 @@
|
|||||||
|
|
||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
|
|
||||||
// Forward References
|
|
||||||
class LabelModel;
|
|
||||||
class LabelModelObject;
|
|
||||||
class UndoRedoModel;
|
|
||||||
class Handle;
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
///
|
|
||||||
/// LabelEditor Widget
|
|
||||||
///
|
|
||||||
class LabelEditor : public QWidget
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward References
|
||||||
|
class LabelModel;
|
||||||
|
class LabelModelObject;
|
||||||
|
class UndoRedoModel;
|
||||||
|
class Handle;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// LabelEditor Widget
|
||||||
|
///
|
||||||
|
class LabelEditor : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelEditor( QScrollArea* scrollArea, QWidget* parent = 0 );
|
LabelEditor( QScrollArea* scrollArea, QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void contextMenuActivate();
|
void contextMenuActivate();
|
||||||
void zoomChanged();
|
void zoomChanged();
|
||||||
void pointerMoved( const glabels::Distance& x, const glabels::Distance& y );
|
void pointerMoved( const Distance& x, const Distance& y );
|
||||||
void pointerExited();
|
void pointerExited();
|
||||||
void modeChanged();
|
void modeChanged();
|
||||||
|
|
||||||
@@ -63,7 +67,7 @@ signals:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Parameters
|
// Parameters
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
double zoom() const;
|
double zoom() const;
|
||||||
bool markupVisible() const;
|
bool markupVisible() const;
|
||||||
bool qridVisible() const;
|
bool qridVisible() const;
|
||||||
@@ -72,14 +76,14 @@ public:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Model
|
// Model
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel );
|
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Visibility operations
|
// Visibility operations
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setGridVisible( bool visibleFlag );
|
void setGridVisible( bool visibleFlag );
|
||||||
void setMarkupVisible( bool visibleFlag );
|
void setMarkupVisible( bool visibleFlag );
|
||||||
|
|
||||||
@@ -87,21 +91,21 @@ public:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Zoom operations
|
// Zoom operations
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
void zoom1To1();
|
void zoom1To1();
|
||||||
void zoomToFit();
|
void zoomToFit();
|
||||||
bool isZoomMax() const;
|
bool isZoomMax() const;
|
||||||
bool isZoomMin() const;
|
bool isZoomMin() const;
|
||||||
private:
|
private:
|
||||||
void setZoomReal( double zoom, bool zoomToFitFlag );
|
void setZoomReal( double zoom, bool zoomToFitFlag );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Mode operations
|
// Mode operations
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void arrowMode();
|
void arrowMode();
|
||||||
void createBoxMode();
|
void createBoxMode();
|
||||||
void createEllipseMode();
|
void createEllipseMode();
|
||||||
@@ -114,7 +118,7 @@ public:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Event handlers
|
// Event handlers
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent( QResizeEvent* event );
|
void resizeEvent( QResizeEvent* event );
|
||||||
void mousePressEvent( QMouseEvent* event );
|
void mousePressEvent( QMouseEvent* event );
|
||||||
void mouseMoveEvent( QMouseEvent* event );
|
void mouseMoveEvent( QMouseEvent* event );
|
||||||
@@ -127,9 +131,9 @@ protected:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Private methods
|
// Private methods
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void handleResizeMotion( const glabels::Distance& xWorld,
|
void handleResizeMotion( const Distance& xWorld,
|
||||||
const glabels::Distance& yWorld );
|
const Distance& yWorld );
|
||||||
|
|
||||||
void drawBgLayer( QPainter* painter );
|
void drawBgLayer( QPainter* painter );
|
||||||
void drawGridLayer( QPainter* painter );
|
void drawGridLayer( QPainter* painter );
|
||||||
@@ -143,7 +147,7 @@ private:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Private slots
|
// Private slots
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
void onModelSizeChanged();
|
void onModelSizeChanged();
|
||||||
|
|
||||||
@@ -151,7 +155,7 @@ private slots:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Private data
|
// Private data
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
enum State {
|
enum State {
|
||||||
IdleState,
|
IdleState,
|
||||||
ArrowSelectRegion,
|
ArrowSelectRegion,
|
||||||
@@ -175,14 +179,14 @@ private:
|
|||||||
double mZoom;
|
double mZoom;
|
||||||
bool mZoomToFitFlag;
|
bool mZoomToFitFlag;
|
||||||
double mScale;
|
double mScale;
|
||||||
glabels::Distance mX0;
|
Distance mX0;
|
||||||
glabels::Distance mY0;
|
Distance mY0;
|
||||||
|
|
||||||
bool mMarkupVisible;
|
bool mMarkupVisible;
|
||||||
bool mGridVisible;
|
bool mGridVisible;
|
||||||
|
|
||||||
double mGridSpacing;
|
double mGridSpacing;
|
||||||
glabels::Distance mStepSize;
|
Distance mStepSize;
|
||||||
|
|
||||||
LabelModel* mModel;
|
LabelModel* mModel;
|
||||||
UndoRedoModel* mUndoRedoModel;
|
UndoRedoModel* mUndoRedoModel;
|
||||||
@@ -194,8 +198,8 @@ private:
|
|||||||
Region mSelectRegion;
|
Region mSelectRegion;
|
||||||
|
|
||||||
/* ArrowMove state */
|
/* ArrowMove state */
|
||||||
glabels::Distance mMoveLastX;
|
Distance mMoveLastX;
|
||||||
glabels::Distance mMoveLastY;
|
Distance mMoveLastY;
|
||||||
|
|
||||||
/* ArrowResize state */
|
/* ArrowResize state */
|
||||||
LabelModelObject* mResizeObject;
|
LabelModelObject* mResizeObject;
|
||||||
@@ -205,11 +209,13 @@ private:
|
|||||||
/* CreateDrag state */
|
/* CreateDrag state */
|
||||||
CreateType mCreateObjectType;
|
CreateType mCreateObjectType;
|
||||||
LabelModelObject* mCreateObject;
|
LabelModelObject* mCreateObject;
|
||||||
glabels::Distance mCreateX0;
|
Distance mCreateX0;
|
||||||
glabels::Distance mCreateY0;
|
Distance mCreateY0;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelEditor_h
|
#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/Merge.h"
|
||||||
#include "Merge/Record.h"
|
#include "Merge/Record.h"
|
||||||
|
|
||||||
// Forward References
|
|
||||||
class ColorNode;
|
|
||||||
class Handle;
|
|
||||||
class LabelModelObject;
|
|
||||||
class Region;
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
//////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
// LabelModel
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
class LabelModel : public QObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward References
|
||||||
|
class ColorNode;
|
||||||
|
class Handle;
|
||||||
|
class LabelModelObject;
|
||||||
|
class Region;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// LabelModel
|
||||||
|
///
|
||||||
|
class LabelModel : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModel();
|
LabelModel();
|
||||||
virtual ~LabelModel() {}
|
virtual ~LabelModel() {}
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
@@ -81,7 +82,7 @@ signals:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool isModified() const;
|
bool isModified() const;
|
||||||
void setModified();
|
void setModified();
|
||||||
void clearModified();
|
void clearModified();
|
||||||
@@ -93,15 +94,15 @@ public:
|
|||||||
int compressionLevel() const;
|
int compressionLevel() const;
|
||||||
void setCompressionLevel( int compressionLevel );
|
void setCompressionLevel( int compressionLevel );
|
||||||
|
|
||||||
const glabels::Template* tmplate() const;
|
const Template* tmplate() const;
|
||||||
const glabels::Frame* frame() const;
|
const Frame* frame() const;
|
||||||
void setTmplate( const glabels::Template* tmplate );
|
void setTmplate( const Template* tmplate );
|
||||||
|
|
||||||
bool rotate() const;
|
bool rotate() const;
|
||||||
void setRotate( bool rotate );
|
void setRotate( bool rotate );
|
||||||
|
|
||||||
glabels::Distance w() const;
|
Distance w() const;
|
||||||
glabels::Distance h() const;
|
Distance h() const;
|
||||||
|
|
||||||
const QList<LabelModelObject*>& objectList() const;
|
const QList<LabelModelObject*>& objectList() const;
|
||||||
|
|
||||||
@@ -112,23 +113,23 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Manage objects
|
// Manage objects
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void addObject( LabelModelObject* object );
|
void addObject( LabelModelObject* object );
|
||||||
void deleteObject( LabelModelObject* object );
|
void deleteObject( LabelModelObject* object );
|
||||||
|
|
||||||
LabelModelObject* objectAt( double scale,
|
LabelModelObject* objectAt( double scale,
|
||||||
const glabels::Distance& x,
|
const Distance& x,
|
||||||
const glabels::Distance& y ) const;
|
const Distance& y ) const;
|
||||||
|
|
||||||
Handle* handleAt( double scale,
|
Handle* handleAt( double scale,
|
||||||
const glabels::Distance& x,
|
const Distance& x,
|
||||||
const glabels::Distance& y ) const;
|
const Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Manipulate selection
|
// Manipulate selection
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void selectObject( LabelModelObject* object );
|
void selectObject( LabelModelObject* object );
|
||||||
void unselectObject( LabelModelObject* object );
|
void unselectObject( LabelModelObject* object );
|
||||||
void selectAll();
|
void selectAll();
|
||||||
@@ -141,7 +142,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Get selected objects
|
// Get selected objects
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QList<LabelModelObject*> getSelection();
|
QList<LabelModelObject*> getSelection();
|
||||||
LabelModelObject* getFirstSelectedObject();
|
LabelModelObject* getFirstSelectedObject();
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Query selection capabilities
|
// Query selection capabilities
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool canSelectionText();
|
bool canSelectionText();
|
||||||
bool canSelectionFill();
|
bool canSelectionFill();
|
||||||
bool canSelectionLineColor();
|
bool canSelectionLineColor();
|
||||||
@@ -159,7 +160,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Operations on selections
|
// Operations on selections
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void deleteSelection();
|
void deleteSelection();
|
||||||
void raiseSelectionToTop();
|
void raiseSelectionToTop();
|
||||||
void lowerSelectionToBottom();
|
void lowerSelectionToBottom();
|
||||||
@@ -176,7 +177,7 @@ public:
|
|||||||
void alignSelectionVCenter();
|
void alignSelectionVCenter();
|
||||||
void centerSelectionHoriz();
|
void centerSelectionHoriz();
|
||||||
void centerSelectionVert();
|
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 setSelectionFontFamily( const QString& fontFamily );
|
||||||
void setSelectionFontSize( double fontSize );
|
void setSelectionFontSize( double fontSize );
|
||||||
void setSelectionFontWeight( QFont::Weight fontWeight );
|
void setSelectionFontWeight( QFont::Weight fontWeight );
|
||||||
@@ -185,7 +186,7 @@ public:
|
|||||||
void setSelectionTextVAlign( Qt::Alignment textVAlign );
|
void setSelectionTextVAlign( Qt::Alignment textVAlign );
|
||||||
void setSelectionTextLineSpacing( double textLineSpacing );
|
void setSelectionTextLineSpacing( double textLineSpacing );
|
||||||
void setSelectionTextColorNode( ColorNode textColorNode );
|
void setSelectionTextColorNode( ColorNode textColorNode );
|
||||||
void setSelectionLineWidth( const glabels::Distance& lineWidth );
|
void setSelectionLineWidth( const Distance& lineWidth );
|
||||||
void setSelectionLineColorNode( ColorNode lineColorNode );
|
void setSelectionLineColorNode( ColorNode lineColorNode );
|
||||||
void setSelectionFillColorNode( ColorNode fillColorNode );
|
void setSelectionFillColorNode( ColorNode fillColorNode );
|
||||||
|
|
||||||
@@ -201,14 +202,14 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, bool inEditor = true, merge::Record* record = 0 ) const;
|
void draw( QPainter* painter, bool inEditor = true, merge::Record* record = 0 ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onObjectChanged();
|
void onObjectChanged();
|
||||||
void onObjectMoved();
|
void onObjectMoved();
|
||||||
void onMergeSourceChanged();
|
void onMergeSourceChanged();
|
||||||
@@ -218,19 +219,21 @@ private slots:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private data
|
// Private data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
int mUntitledInstance;
|
int mUntitledInstance;
|
||||||
bool mModified;
|
bool mModified;
|
||||||
QString mFileName;
|
QString mFileName;
|
||||||
int mCompressionLevel;
|
int mCompressionLevel;
|
||||||
const glabels::Template* mTmplate;
|
const Template* mTmplate;
|
||||||
const glabels::Frame* mFrame;
|
const Frame* mFrame;
|
||||||
bool mRotate;
|
bool mRotate;
|
||||||
|
|
||||||
QList<LabelModelObject*> mObjectList;
|
QList<LabelModelObject*> mObjectList;
|
||||||
|
|
||||||
merge::Merge* mMerge;
|
merge::Merge* mMerge;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModel_h
|
#endif // LabelModel_h
|
||||||
|
|||||||
@@ -25,50 +25,60 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const double slopPixels = 2;
|
const double slopPixels = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
LabelModelBoxObject::LabelModelBoxObject()
|
LabelModelBoxObject::LabelModelBoxObject()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object ) : LabelModelShapeObject( object )
|
LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object )
|
||||||
{
|
: LabelModelShapeObject( object )
|
||||||
}
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
LabelModelBoxObject::~LabelModelBoxObject()
|
LabelModelBoxObject::~LabelModelBoxObject()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
LabelModelBoxObject* LabelModelBoxObject::clone() const
|
LabelModelBoxObject* LabelModelBoxObject::clone() const
|
||||||
{
|
{
|
||||||
return new LabelModelBoxObject( this );
|
return new LabelModelBoxObject( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
QColor shadowColor = mShadowColorNode.color( record );
|
||||||
@@ -106,14 +116,14 @@ void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::R
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
|
|
||||||
@@ -121,14 +131,14 @@ void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::R
|
|||||||
painter->setBrush( fillColor );
|
painter->setBrush( fillColor );
|
||||||
|
|
||||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Path to test for hover condition
|
/// Path to test for hover condition
|
||||||
///
|
///
|
||||||
QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
|
QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
|
||||||
{
|
{
|
||||||
double s = 1 / scale;
|
double s = 1 / scale;
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
@@ -155,4 +165,6 @@ QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,20 @@
|
|||||||
#include "LabelModelShapeObject.h"
|
#include "LabelModelShapeObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Box Object
|
|
||||||
///
|
|
||||||
class LabelModelBoxObject : public LabelModelShapeObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Label Model Box Object
|
||||||
|
///
|
||||||
|
class LabelModelBoxObject : public LabelModelShapeObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModelBoxObject();
|
LabelModelBoxObject();
|
||||||
LabelModelBoxObject( const LabelModelBoxObject* object );
|
LabelModelBoxObject( const LabelModelBoxObject* object );
|
||||||
virtual ~LabelModelBoxObject();
|
virtual ~LabelModelBoxObject();
|
||||||
@@ -50,12 +53,14 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||||
virtual void drawObject( 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;
|
virtual QPainterPath hoverPath( double scale ) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelBoxObject_h
|
#endif // LabelModelBoxObject_h
|
||||||
|
|||||||
@@ -25,50 +25,60 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const double slopPixels = 2;
|
const double slopPixels = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
LabelModelEllipseObject::LabelModelEllipseObject()
|
LabelModelEllipseObject::LabelModelEllipseObject()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject* object ) : LabelModelShapeObject( object )
|
LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject* object )
|
||||||
{
|
: LabelModelShapeObject( object )
|
||||||
}
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
LabelModelEllipseObject::~LabelModelEllipseObject()
|
LabelModelEllipseObject::~LabelModelEllipseObject()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
LabelModelEllipseObject* LabelModelEllipseObject::clone() const
|
LabelModelEllipseObject* LabelModelEllipseObject::clone() const
|
||||||
{
|
{
|
||||||
return new LabelModelEllipseObject( this );
|
return new LabelModelEllipseObject( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void LabelModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
QColor shadowColor = mShadowColorNode.color( record );
|
||||||
@@ -106,14 +116,14 @@ void LabelModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void LabelModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
|
|
||||||
@@ -121,14 +131,14 @@ void LabelModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merg
|
|||||||
painter->setBrush( fillColor );
|
painter->setBrush( fillColor );
|
||||||
|
|
||||||
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Path to test for hover condition
|
/// Path to test for hover condition
|
||||||
///
|
///
|
||||||
QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
|
QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
|
||||||
{
|
{
|
||||||
double s = 1 / scale;
|
double s = 1 / scale;
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
@@ -155,4 +165,6 @@ QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,20 @@
|
|||||||
#include "LabelModelShapeObject.h"
|
#include "LabelModelShapeObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Ellipse Object
|
|
||||||
///
|
|
||||||
class LabelModelEllipseObject : public LabelModelShapeObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Label Model Ellipse Object
|
||||||
|
///
|
||||||
|
class LabelModelEllipseObject : public LabelModelShapeObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModelEllipseObject();
|
LabelModelEllipseObject();
|
||||||
LabelModelEllipseObject( const LabelModelEllipseObject* object );
|
LabelModelEllipseObject( const LabelModelEllipseObject* object );
|
||||||
virtual ~LabelModelEllipseObject();
|
virtual ~LabelModelEllipseObject();
|
||||||
@@ -50,12 +53,14 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||||
virtual void drawObject( 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;
|
virtual QPainterPath hoverPath( double scale ) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelEllipseObject_h
|
#endif // LabelModelEllipseObject_h
|
||||||
|
|||||||
@@ -30,22 +30,20 @@
|
|||||||
#include "Size.h"
|
#include "Size.h"
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
///
|
||||||
|
/// Static data
|
||||||
|
///
|
||||||
|
QImage* LabelModelImageObject::smDefaultImage = 0;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Static data
|
/// Constructor
|
||||||
///
|
///
|
||||||
QImage* LabelModelImageObject::smDefaultImage = 0;
|
LabelModelImageObject::LabelModelImageObject() : mImage(0), mSvg(0)
|
||||||
|
{
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
LabelModelImageObject::LabelModelImageObject() : mImage(0), mSvg(0)
|
|
||||||
{
|
|
||||||
mOutline = new Outline( this );
|
mOutline = new Outline( this );
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
mHandles << new HandleNorthWest( this );
|
||||||
@@ -61,23 +59,23 @@ LabelModelImageObject::LabelModelImageObject() : mImage(0), mSvg(0)
|
|||||||
{
|
{
|
||||||
smDefaultImage = new QImage( ":images/checkerboard.png" );
|
smDefaultImage = new QImage( ":images/checkerboard.png" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
LabelModelImageObject::LabelModelImageObject( const LabelModelImageObject* object ) : LabelModelObject(object)
|
LabelModelImageObject::LabelModelImageObject( const LabelModelImageObject* object ) : LabelModelObject(object)
|
||||||
{
|
{
|
||||||
mFilenameNode = object->mFilenameNode;
|
mFilenameNode = object->mFilenameNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
LabelModelImageObject::~LabelModelImageObject()
|
LabelModelImageObject::~LabelModelImageObject()
|
||||||
{
|
{
|
||||||
delete mOutline;
|
delete mOutline;
|
||||||
|
|
||||||
foreach( Handle* handle, mHandles )
|
foreach( Handle* handle, mHandles )
|
||||||
@@ -85,32 +83,32 @@ LabelModelImageObject::~LabelModelImageObject()
|
|||||||
delete handle;
|
delete handle;
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
mHandles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
LabelModelImageObject* LabelModelImageObject::clone() const
|
LabelModelImageObject* LabelModelImageObject::clone() const
|
||||||
{
|
{
|
||||||
return new LabelModelImageObject( this );
|
return new LabelModelImageObject( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Image filenameNode Property Getter
|
/// Image filenameNode Property Getter
|
||||||
///
|
///
|
||||||
TextNode LabelModelImageObject::filenameNode( void ) const
|
TextNode LabelModelImageObject::filenameNode( void ) const
|
||||||
{
|
{
|
||||||
return mFilenameNode;
|
return mFilenameNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Image filenameNode Property Setter
|
/// Image filenameNode Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelImageObject::setFilenameNode( const TextNode& value )
|
void LabelModelImageObject::setFilenameNode( const TextNode& value )
|
||||||
{
|
{
|
||||||
if ( mFilenameNode != value )
|
if ( mFilenameNode != value )
|
||||||
{
|
{
|
||||||
mFilenameNode = value;
|
mFilenameNode = value;
|
||||||
@@ -118,38 +116,38 @@ void LabelModelImageObject::setFilenameNode( const TextNode& value )
|
|||||||
|
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Image originalSize Property Getter (assumes 72 DPI, i.e. 1pixel == 1pt)
|
/// Image originalSize Property Getter (assumes 72 DPI, i.e. 1pixel == 1pt)
|
||||||
///
|
///
|
||||||
Size LabelModelImageObject::originalSize() const
|
Size LabelModelImageObject::originalSize() const
|
||||||
{
|
{
|
||||||
Size size( glabels::Distance::pt(72), glabels::Distance::pt(72) );
|
Size size( Distance::pt(72), Distance::pt(72) );
|
||||||
|
|
||||||
if ( mImage )
|
if ( mImage )
|
||||||
{
|
{
|
||||||
QSize qsize = mImage->size();
|
QSize qsize = mImage->size();
|
||||||
size.setW( glabels::Distance::pt( qsize.width() ) );
|
size.setW( Distance::pt( qsize.width() ) );
|
||||||
size.setH( glabels::Distance::pt( qsize.height() ) );
|
size.setH( Distance::pt( qsize.height() ) );
|
||||||
}
|
}
|
||||||
else if ( mSvg )
|
else if ( mSvg )
|
||||||
{
|
{
|
||||||
QSize qsize = mSvg->defaultSize();
|
QSize qsize = mSvg->defaultSize();
|
||||||
size.setW( glabels::Distance::pt( qsize.width() ) );
|
size.setW( Distance::pt( qsize.width() ) );
|
||||||
size.setH( glabels::Distance::pt( qsize.height() ) );
|
size.setH( Distance::pt( qsize.height() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void LabelModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
QColor shadowColor = mShadowColorNode.color( record );
|
||||||
@@ -171,14 +169,14 @@ void LabelModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge:
|
|||||||
painter->drawRect( destRect );
|
painter->drawRect( destRect );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void LabelModelImageObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelImageObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|
||||||
if ( inEditor && (mFilenameNode.isField() || (!mImage && !mSvg) ) )
|
if ( inEditor && (mFilenameNode.isField() || (!mImage && !mSvg) ) )
|
||||||
@@ -200,26 +198,26 @@ void LabelModelImageObject::drawObject( QPainter* painter, bool inEditor, merge:
|
|||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Path to test for hover condition
|
/// Path to test for hover condition
|
||||||
///
|
///
|
||||||
QPainterPath LabelModelImageObject::hoverPath( double scale ) const
|
QPainterPath LabelModelImageObject::hoverPath( double scale ) const
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Load image
|
/// Load image
|
||||||
///
|
///
|
||||||
void LabelModelImageObject::loadImage()
|
void LabelModelImageObject::loadImage()
|
||||||
{
|
{
|
||||||
if ( mImage )
|
if ( mImage )
|
||||||
{
|
{
|
||||||
delete mImage;
|
delete mImage;
|
||||||
@@ -288,14 +286,14 @@ void LabelModelImageObject::loadImage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create shadow image
|
/// Create shadow image
|
||||||
///
|
///
|
||||||
QImage* LabelModelImageObject::createShadowImage( const QColor& color ) const
|
QImage* LabelModelImageObject::createShadowImage( const QColor& color ) const
|
||||||
{
|
{
|
||||||
int r = color.red();
|
int r = color.red();
|
||||||
int g = color.green();
|
int g = color.green();
|
||||||
int b = color.blue();
|
int b = color.blue();
|
||||||
@@ -313,4 +311,6 @@ QImage* LabelModelImageObject::createShadowImage( const QColor& color ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return shadow;
|
return shadow;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,17 +27,20 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Image Object
|
|
||||||
///
|
|
||||||
class LabelModelImageObject : public LabelModelObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Label Model Image Object
|
||||||
|
///
|
||||||
|
class LabelModelImageObject : public LabelModelObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModelImageObject();
|
LabelModelImageObject();
|
||||||
LabelModelImageObject( const LabelModelImageObject* object );
|
LabelModelImageObject( const LabelModelImageObject* object );
|
||||||
virtual ~LabelModelImageObject();
|
virtual ~LabelModelImageObject();
|
||||||
@@ -52,7 +55,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Image Property: filenameNode
|
// Image Property: filenameNode
|
||||||
//
|
//
|
||||||
@@ -73,7 +76,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||||
virtual void drawObject( 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;
|
virtual QPainterPath hoverPath( double scale ) const;
|
||||||
@@ -89,14 +92,16 @@ protected:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
TextNode mFilenameNode;
|
TextNode mFilenameNode;
|
||||||
QImage* mImage;
|
QImage* mImage;
|
||||||
QSvgRenderer* mSvg;
|
QSvgRenderer* mSvg;
|
||||||
|
|
||||||
static QImage* smDefaultImage;
|
static QImage* smDefaultImage;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelImageObject_h
|
#endif // LabelModelImageObject_h
|
||||||
|
|||||||
@@ -25,17 +25,23 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const double slopPixels = 2;
|
const double slopPixels = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
LabelModelLineObject::LabelModelLineObject()
|
LabelModelLineObject::LabelModelLineObject()
|
||||||
{
|
{
|
||||||
mOutline = 0;
|
mOutline = 0;
|
||||||
|
|
||||||
mHandles << new HandleP1( this );
|
mHandles << new HandleP1( this );
|
||||||
@@ -43,108 +49,109 @@ LabelModelLineObject::LabelModelLineObject()
|
|||||||
|
|
||||||
mLineWidth = 1.0;
|
mLineWidth = 1.0;
|
||||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
LabelModelLineObject::LabelModelLineObject( const LabelModelLineObject* object ) : LabelModelObject(object)
|
LabelModelLineObject::LabelModelLineObject( const LabelModelLineObject* object )
|
||||||
{
|
: LabelModelObject(object)
|
||||||
|
{
|
||||||
mLineWidth = object->mLineWidth;
|
mLineWidth = object->mLineWidth;
|
||||||
mLineColorNode = object->mLineColorNode;
|
mLineColorNode = object->mLineColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
LabelModelLineObject::~LabelModelLineObject()
|
LabelModelLineObject::~LabelModelLineObject()
|
||||||
{
|
{
|
||||||
foreach( Handle* handle, mHandles )
|
foreach( Handle* handle, mHandles )
|
||||||
{
|
{
|
||||||
delete handle;
|
delete handle;
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
mHandles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
LabelModelLineObject* LabelModelLineObject::clone() const
|
LabelModelLineObject* LabelModelLineObject::clone() const
|
||||||
{
|
{
|
||||||
return new LabelModelLineObject( this );
|
return new LabelModelLineObject( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Width Property Getter
|
/// Line Width Property Getter
|
||||||
///
|
///
|
||||||
glabels::Distance LabelModelLineObject::lineWidth( void ) const
|
Distance LabelModelLineObject::lineWidth( void ) const
|
||||||
{
|
{
|
||||||
return mLineWidth;
|
return mLineWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Width Property Setter
|
/// Line Width Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelLineObject::setLineWidth( const glabels::Distance& value )
|
void LabelModelLineObject::setLineWidth( const Distance& value )
|
||||||
{
|
{
|
||||||
if ( mLineWidth != value )
|
if ( mLineWidth != value )
|
||||||
{
|
{
|
||||||
mLineWidth = value;
|
mLineWidth = value;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Color Node Property Getter
|
/// Line Color Node Property Getter
|
||||||
///
|
///
|
||||||
ColorNode LabelModelLineObject::lineColorNode( void ) const
|
ColorNode LabelModelLineObject::lineColorNode( void ) const
|
||||||
{
|
{
|
||||||
return mLineColorNode;
|
return mLineColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Color Node Property Setter
|
/// Line Color Node Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelLineObject::setLineColorNode( const ColorNode& value )
|
void LabelModelLineObject::setLineColorNode( const ColorNode& value )
|
||||||
{
|
{
|
||||||
if ( mLineColorNode != value )
|
if ( mLineColorNode != value )
|
||||||
{
|
{
|
||||||
mLineColorNode = value;
|
mLineColorNode = value;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Line Color Capability Implementation
|
/// Can Line Color Capability Implementation
|
||||||
///
|
///
|
||||||
bool LabelModelLineObject::canLineColor()
|
bool LabelModelLineObject::canLineColor()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Line Width Capability Implementation
|
/// Can Line Width Capability Implementation
|
||||||
///
|
///
|
||||||
bool LabelModelLineObject::canLineWidth()
|
bool LabelModelLineObject::canLineWidth()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void LabelModelLineObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelLineObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
QColor shadowColor = mShadowColorNode.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->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||||
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void LabelModelLineObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelLineObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Path to test for hover condition
|
/// Path to test for hover condition
|
||||||
///
|
///
|
||||||
QPainterPath LabelModelLineObject::hoverPath( double scale ) const
|
QPainterPath LabelModelLineObject::hoverPath( double scale ) const
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
if ( mLineColorNode.color().alpha() )
|
if ( mLineColorNode.color().alpha() )
|
||||||
@@ -197,4 +204,6 @@ QPainterPath LabelModelLineObject::hoverPath( double scale ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,20 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Line Object
|
|
||||||
///
|
|
||||||
class LabelModelLineObject : public LabelModelObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Label Model Line Object
|
||||||
|
///
|
||||||
|
class LabelModelLineObject : public LabelModelObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModelLineObject();
|
LabelModelLineObject();
|
||||||
LabelModelLineObject( const LabelModelLineObject* object );
|
LabelModelLineObject( const LabelModelLineObject* object );
|
||||||
virtual ~LabelModelLineObject();
|
virtual ~LabelModelLineObject();
|
||||||
@@ -50,12 +53,12 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Line Property: lineWidth
|
// Line Property: lineWidth
|
||||||
//
|
//
|
||||||
virtual glabels::Distance lineWidth( void ) const;
|
virtual Distance lineWidth( void ) const;
|
||||||
virtual void setLineWidth( const glabels::Distance& value );
|
virtual void setLineWidth( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -68,7 +71,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canLineColor();
|
virtual bool canLineColor();
|
||||||
virtual bool canLineWidth();
|
virtual bool canLineWidth();
|
||||||
|
|
||||||
@@ -76,7 +79,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||||
virtual void drawObject( 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;
|
virtual QPainterPath hoverPath( double scale ) const;
|
||||||
@@ -85,11 +88,13 @@ protected:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
glabels::Distance mLineWidth;
|
Distance mLineWidth;
|
||||||
ColorNode mLineColorNode;
|
ColorNode mLineColorNode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelLineObject_h
|
#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"
|
#include "Merge/Record.h"
|
||||||
|
|
||||||
|
|
||||||
// Forward References
|
namespace glabels
|
||||||
class Region;
|
|
||||||
class Size;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Label Model Object Base Class
|
|
||||||
///
|
|
||||||
class LabelModelObject : public QObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward References
|
||||||
|
class Region;
|
||||||
|
class Size;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Label Model Object Base Class
|
||||||
|
///
|
||||||
|
class LabelModelObject : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
LabelModelObject();
|
LabelModelObject();
|
||||||
LabelModelObject( const LabelModelObject* object );
|
LabelModelObject( const LabelModelObject* object );
|
||||||
public:
|
public:
|
||||||
virtual ~LabelModelObject();
|
virtual ~LabelModelObject();
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +71,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void moved();
|
void moved();
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
@@ -76,7 +79,7 @@ signals:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Common Properties
|
// Common Properties
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// ID Property.
|
// ID Property.
|
||||||
//
|
//
|
||||||
@@ -93,29 +96,29 @@ public:
|
|||||||
//
|
//
|
||||||
// x0 Property ( x coordinate of origin )
|
// x0 Property ( x coordinate of origin )
|
||||||
//
|
//
|
||||||
glabels::Distance x0() const;
|
Distance x0() const;
|
||||||
void setX0( const glabels::Distance& value );
|
void setX0( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// y0 Property ( y coordinate of origin )
|
// y0 Property ( y coordinate of origin )
|
||||||
//
|
//
|
||||||
glabels::Distance y0() const;
|
Distance y0() const;
|
||||||
void setY0( const glabels::Distance& value );
|
void setY0( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// w Property ( width of bounding box )
|
// w Property ( width of bounding box )
|
||||||
//
|
//
|
||||||
glabels::Distance w() const;
|
Distance w() const;
|
||||||
void setW( const glabels::Distance& value );
|
void setW( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// h Property ( height of bounding box )
|
// h Property ( height of bounding box )
|
||||||
//
|
//
|
||||||
glabels::Distance h() const;
|
Distance h() const;
|
||||||
void setH( const glabels::Distance& value );
|
void setH( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -135,15 +138,15 @@ public:
|
|||||||
//
|
//
|
||||||
// Shadow x Offset Property
|
// Shadow x Offset Property
|
||||||
//
|
//
|
||||||
glabels::Distance shadowX() const;
|
Distance shadowX() const;
|
||||||
void setShadowX( const glabels::Distance& value );
|
void setShadowX( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow y Offset Property
|
// Shadow y Offset Property
|
||||||
//
|
//
|
||||||
glabels::Distance shadowY() const;
|
Distance shadowY() const;
|
||||||
void setShadowY( const glabels::Distance& value );
|
void setShadowY( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -163,7 +166,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Text Properties Virtual Interface
|
// Text Properties Virtual Interface
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Virtual Text Property: text
|
// Virtual Text Property: text
|
||||||
//
|
//
|
||||||
@@ -237,7 +240,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Image Properties Virtual Interface
|
// Image Properties Virtual Interface
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Virtual Image Property: filenameNode
|
// Virtual Image Property: filenameNode
|
||||||
//
|
//
|
||||||
@@ -253,12 +256,12 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Shape Properties Virtual Interface
|
// Shape Properties Virtual Interface
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Virtual Shape Property: lineWidth
|
// Virtual Shape Property: lineWidth
|
||||||
//
|
//
|
||||||
virtual glabels::Distance lineWidth() const;
|
virtual Distance lineWidth() const;
|
||||||
virtual void setLineWidth( const glabels::Distance& value );
|
virtual void setLineWidth( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -278,7 +281,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Barcode Properties Virtual Interface
|
// Barcode Properties Virtual Interface
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcDataNode
|
// Virtual Barcode Property: bcDataNode
|
||||||
//
|
//
|
||||||
@@ -324,7 +327,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capabilities (Overridden by concrete classes.)
|
// Capabilities (Overridden by concrete classes.)
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canText() const;
|
virtual bool canText() const;
|
||||||
virtual bool canFill() const;
|
virtual bool canFill() const;
|
||||||
virtual bool canLineColor() const;
|
virtual bool canLineColor() const;
|
||||||
@@ -334,31 +337,31 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Position and Size methods
|
// Position and Size methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setPosition( const glabels::Distance& x0, const glabels::Distance& y0 );
|
void setPosition( const Distance& x0, const Distance& y0 );
|
||||||
void setPositionRelative( const glabels::Distance& dx, const glabels::Distance& dy );
|
void setPositionRelative( const Distance& dx, const Distance& dy );
|
||||||
Size size() const;
|
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 setSize( const Size& size );
|
||||||
void setSizeHonorAspect( const glabels::Distance& w, const glabels::Distance& h );
|
void setSizeHonorAspect( const Distance& w, const Distance& h );
|
||||||
void setWHonorAspect( const glabels::Distance& w );
|
void setWHonorAspect( const Distance& w );
|
||||||
void setHHonorAspect( const glabels::Distance& h );
|
void setHHonorAspect( const Distance& h );
|
||||||
Region getExtent();
|
Region getExtent();
|
||||||
void rotate( double thetaDegs );
|
void rotate( double thetaDegs );
|
||||||
void flipHoriz();
|
void flipHoriz();
|
||||||
void flipVert();
|
void flipVert();
|
||||||
bool isLocatedAt( 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 glabels::Distance& x, const glabels::Distance& y ) const;
|
Handle* handleAt( double scale, const Distance& x, const Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||||
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
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 void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||||
virtual QPainterPath hoverPath( double scale ) const = 0;
|
virtual QPainterPath hoverPath( double scale ) const = 0;
|
||||||
@@ -369,17 +372,17 @@ protected:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Protected Members
|
// Protected Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
bool mSelectedFlag;
|
bool mSelectedFlag;
|
||||||
|
|
||||||
glabels::Distance mX0;
|
Distance mX0;
|
||||||
glabels::Distance mY0;
|
Distance mY0;
|
||||||
glabels::Distance mW;
|
Distance mW;
|
||||||
glabels::Distance mH;
|
Distance mH;
|
||||||
|
|
||||||
bool mShadowState;
|
bool mShadowState;
|
||||||
glabels::Distance mShadowX;
|
Distance mShadowX;
|
||||||
glabels::Distance mShadowY;
|
Distance mShadowY;
|
||||||
double mShadowOpacity;
|
double mShadowOpacity;
|
||||||
ColorNode mShadowColorNode;
|
ColorNode mShadowColorNode;
|
||||||
|
|
||||||
@@ -390,13 +393,15 @@ protected:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
static int msNextId;
|
static int msNextId;
|
||||||
int mId;
|
int mId;
|
||||||
|
|
||||||
QMatrix mMatrix;
|
QMatrix mMatrix;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelObject_h
|
#endif // LabelModelObject_h
|
||||||
|
|||||||
@@ -25,11 +25,14 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
LabelModelShapeObject::LabelModelShapeObject()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
LabelModelShapeObject::LabelModelShapeObject()
|
||||||
|
{
|
||||||
mOutline = new Outline( this );
|
mOutline = new Outline( this );
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
mHandles << new HandleNorthWest( this );
|
||||||
@@ -44,25 +47,25 @@ LabelModelShapeObject::LabelModelShapeObject()
|
|||||||
mLineWidth = 1.0;
|
mLineWidth = 1.0;
|
||||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||||
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
|
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
LabelModelShapeObject::LabelModelShapeObject( const LabelModelShapeObject* object ) : LabelModelObject(object)
|
LabelModelShapeObject::LabelModelShapeObject( const LabelModelShapeObject* object ) : LabelModelObject(object)
|
||||||
{
|
{
|
||||||
mLineWidth = object->mLineWidth;
|
mLineWidth = object->mLineWidth;
|
||||||
mLineColorNode = object->mLineColorNode;
|
mLineColorNode = object->mLineColorNode;
|
||||||
mFillColorNode = object->mFillColorNode;
|
mFillColorNode = object->mFillColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
LabelModelShapeObject::~LabelModelShapeObject()
|
LabelModelShapeObject::~LabelModelShapeObject()
|
||||||
{
|
{
|
||||||
delete mOutline;
|
delete mOutline;
|
||||||
|
|
||||||
foreach( Handle* handle, mHandles )
|
foreach( Handle* handle, mHandles )
|
||||||
@@ -70,97 +73,99 @@ LabelModelShapeObject::~LabelModelShapeObject()
|
|||||||
delete handle;
|
delete handle;
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
mHandles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Width Property Getter
|
/// Line Width Property Getter
|
||||||
///
|
///
|
||||||
glabels::Distance LabelModelShapeObject::lineWidth( void ) const
|
Distance LabelModelShapeObject::lineWidth( void ) const
|
||||||
{
|
{
|
||||||
return mLineWidth;
|
return mLineWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Width Property Setter
|
/// Line Width Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelShapeObject::setLineWidth( const glabels::Distance& value )
|
void LabelModelShapeObject::setLineWidth( const Distance& value )
|
||||||
{
|
{
|
||||||
if ( mLineWidth != value )
|
if ( mLineWidth != value )
|
||||||
{
|
{
|
||||||
mLineWidth = value;
|
mLineWidth = value;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Color Node Property Getter
|
/// Line Color Node Property Getter
|
||||||
///
|
///
|
||||||
ColorNode LabelModelShapeObject::lineColorNode( void ) const
|
ColorNode LabelModelShapeObject::lineColorNode( void ) const
|
||||||
{
|
{
|
||||||
return mLineColorNode;
|
return mLineColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Color Node Property Setter
|
/// Line Color Node Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelShapeObject::setLineColorNode( const ColorNode& value )
|
void LabelModelShapeObject::setLineColorNode( const ColorNode& value )
|
||||||
{
|
{
|
||||||
if ( mLineColorNode != value )
|
if ( mLineColorNode != value )
|
||||||
{
|
{
|
||||||
mLineColorNode = value;
|
mLineColorNode = value;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Fill Color Node Property Getter
|
/// Fill Color Node Property Getter
|
||||||
///
|
///
|
||||||
ColorNode LabelModelShapeObject::fillColorNode( void ) const
|
ColorNode LabelModelShapeObject::fillColorNode( void ) const
|
||||||
{
|
{
|
||||||
return mFillColorNode;
|
return mFillColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Fill Color Node Property Setter
|
/// Fill Color Node Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelShapeObject::setFillColorNode( const ColorNode& value )
|
void LabelModelShapeObject::setFillColorNode( const ColorNode& value )
|
||||||
{
|
{
|
||||||
if ( mFillColorNode != value )
|
if ( mFillColorNode != value )
|
||||||
{
|
{
|
||||||
mFillColorNode = value;
|
mFillColorNode = value;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Fill Capability Implementation
|
/// Can Fill Capability Implementation
|
||||||
///
|
///
|
||||||
bool LabelModelShapeObject::canFill()
|
bool LabelModelShapeObject::canFill()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Line Color Capability Implementation
|
/// Can Line Color Capability Implementation
|
||||||
///
|
///
|
||||||
bool LabelModelShapeObject::canLineColor()
|
bool LabelModelShapeObject::canLineColor()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Line Width Capability Implementation
|
/// Can Line Width Capability Implementation
|
||||||
///
|
///
|
||||||
bool LabelModelShapeObject::canLineWidth()
|
bool LabelModelShapeObject::canLineWidth()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,32 +25,35 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Shape Object (Box or Ellipse)
|
|
||||||
///
|
|
||||||
class LabelModelShapeObject : public LabelModelObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Label Model Shape Object (Box or Ellipse)
|
||||||
|
///
|
||||||
|
class LabelModelShapeObject : public LabelModelObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
LabelModelShapeObject();
|
LabelModelShapeObject();
|
||||||
LabelModelShapeObject( const LabelModelShapeObject* object );
|
LabelModelShapeObject( const LabelModelShapeObject* object );
|
||||||
public:
|
public:
|
||||||
virtual ~LabelModelShapeObject();
|
virtual ~LabelModelShapeObject();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Shape Property: lineWidth
|
// Shape Property: lineWidth
|
||||||
//
|
//
|
||||||
virtual glabels::Distance lineWidth( void ) const;
|
virtual Distance lineWidth( void ) const;
|
||||||
virtual void setLineWidth( const glabels::Distance& value );
|
virtual void setLineWidth( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -70,7 +73,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canFill();
|
virtual bool canFill();
|
||||||
virtual bool canLineColor();
|
virtual bool canLineColor();
|
||||||
virtual bool canLineWidth();
|
virtual bool canLineWidth();
|
||||||
@@ -79,12 +82,14 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
glabels::Distance mLineWidth;
|
Distance mLineWidth;
|
||||||
ColorNode mLineColorNode;
|
ColorNode mLineColorNode;
|
||||||
ColorNode mFillColorNode;
|
ColorNode mFillColorNode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelShapeObject_h
|
#endif // LabelModelShapeObject_h
|
||||||
|
|||||||
+215
-200
@@ -29,17 +29,23 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
const double marginPts = 3;
|
const double marginPts = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
LabelModelTextObject::LabelModelTextObject()
|
LabelModelTextObject::LabelModelTextObject()
|
||||||
{
|
{
|
||||||
mOutline = new Outline( this );
|
mOutline = new Outline( this );
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
mHandles << new HandleNorthWest( this );
|
||||||
@@ -61,14 +67,15 @@ LabelModelTextObject::LabelModelTextObject()
|
|||||||
mTextHAlign = Qt::AlignLeft;
|
mTextHAlign = Qt::AlignLeft;
|
||||||
mTextVAlign = Qt::AlignTop;
|
mTextVAlign = Qt::AlignTop;
|
||||||
mTextLineSpacing = 1;
|
mTextLineSpacing = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
LabelModelTextObject::LabelModelTextObject( const LabelModelTextObject* object ) : LabelModelObject(object)
|
LabelModelTextObject::LabelModelTextObject( const LabelModelTextObject* object )
|
||||||
{
|
: LabelModelObject(object)
|
||||||
|
{
|
||||||
mText = object->mText;
|
mText = object->mText;
|
||||||
mFontFamily = object->mFontFamily;
|
mFontFamily = object->mFontFamily;
|
||||||
mFontSize = object->mFontSize;
|
mFontSize = object->mFontSize;
|
||||||
@@ -79,14 +86,14 @@ LabelModelTextObject::LabelModelTextObject( const LabelModelTextObject* object )
|
|||||||
mTextHAlign = object->mTextHAlign;
|
mTextHAlign = object->mTextHAlign;
|
||||||
mTextVAlign = object->mTextVAlign;
|
mTextVAlign = object->mTextVAlign;
|
||||||
mTextLineSpacing = object->mTextLineSpacing;
|
mTextLineSpacing = object->mTextLineSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
LabelModelTextObject::~LabelModelTextObject()
|
LabelModelTextObject::~LabelModelTextObject()
|
||||||
{
|
{
|
||||||
delete mOutline;
|
delete mOutline;
|
||||||
|
|
||||||
foreach( Handle* handle, mHandles )
|
foreach( Handle* handle, mHandles )
|
||||||
@@ -94,262 +101,264 @@ LabelModelTextObject::~LabelModelTextObject()
|
|||||||
delete handle;
|
delete handle;
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
mHandles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
LabelModelTextObject* LabelModelTextObject::clone() const
|
LabelModelTextObject* LabelModelTextObject::clone() const
|
||||||
{
|
{
|
||||||
return new LabelModelTextObject( this );
|
return new LabelModelTextObject( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Text Property Getter
|
/// Text Property Getter
|
||||||
///
|
///
|
||||||
QString LabelModelTextObject::text( void ) const
|
QString LabelModelTextObject::text( void ) const
|
||||||
{
|
{
|
||||||
return mText;
|
return mText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Text Property Setter
|
/// Text Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setText( const QString& value )
|
void LabelModelTextObject::setText( const QString& value )
|
||||||
{
|
{
|
||||||
if ( mText != value )
|
if ( mText != value )
|
||||||
{
|
{
|
||||||
mText = value;
|
mText = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontFamily Property Getter
|
/// FontFamily Property Getter
|
||||||
///
|
///
|
||||||
QString LabelModelTextObject::fontFamily( void ) const
|
QString LabelModelTextObject::fontFamily( void ) const
|
||||||
{
|
{
|
||||||
return mFontFamily;
|
return mFontFamily;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontFamily Property Setter
|
/// FontFamily Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setFontFamily( const QString& value )
|
void LabelModelTextObject::setFontFamily( const QString& value )
|
||||||
{
|
{
|
||||||
if ( mFontFamily != value )
|
if ( mFontFamily != value )
|
||||||
{
|
{
|
||||||
mFontFamily = value;
|
mFontFamily = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontSize Property Getter
|
/// FontSize Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelTextObject::fontSize( void ) const
|
double LabelModelTextObject::fontSize( void ) const
|
||||||
{
|
{
|
||||||
return mFontSize;
|
return mFontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontSize Property Setter
|
/// FontSize Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setFontSize( double value )
|
void LabelModelTextObject::setFontSize( double value )
|
||||||
{
|
{
|
||||||
if ( mFontSize != value )
|
if ( mFontSize != value )
|
||||||
{
|
{
|
||||||
mFontSize = value;
|
mFontSize = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontWeight Property Getter
|
/// FontWeight Property Getter
|
||||||
///
|
///
|
||||||
QFont::Weight LabelModelTextObject::fontWeight( void ) const
|
QFont::Weight LabelModelTextObject::fontWeight( void ) const
|
||||||
{
|
{
|
||||||
return mFontWeight;
|
return mFontWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontWeight Property Setter
|
/// FontWeight Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setFontWeight( QFont::Weight value )
|
void LabelModelTextObject::setFontWeight( QFont::Weight value )
|
||||||
{
|
{
|
||||||
if ( mFontWeight != value )
|
if ( mFontWeight != value )
|
||||||
{
|
{
|
||||||
mFontWeight = value;
|
mFontWeight = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontItalicFlag Property Getter
|
/// FontItalicFlag Property Getter
|
||||||
///
|
///
|
||||||
bool LabelModelTextObject::fontItalicFlag( void ) const
|
bool LabelModelTextObject::fontItalicFlag( void ) const
|
||||||
{
|
{
|
||||||
return mFontItalicFlag;
|
return mFontItalicFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontItalicFlag Property Setter
|
/// FontItalicFlag Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setFontItalicFlag( bool value )
|
void LabelModelTextObject::setFontItalicFlag( bool value )
|
||||||
{
|
{
|
||||||
if ( mFontItalicFlag != value )
|
if ( mFontItalicFlag != value )
|
||||||
{
|
{
|
||||||
mFontItalicFlag = value;
|
mFontItalicFlag = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontUnderlineFlag Property Getter
|
/// FontUnderlineFlag Property Getter
|
||||||
///
|
///
|
||||||
bool LabelModelTextObject::fontUnderlineFlag( void ) const
|
bool LabelModelTextObject::fontUnderlineFlag( void ) const
|
||||||
{
|
{
|
||||||
return mFontUnderlineFlag;
|
return mFontUnderlineFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// FontUnderlineFlag Property Setter
|
/// FontUnderlineFlag Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setFontUnderlineFlag( bool value )
|
void LabelModelTextObject::setFontUnderlineFlag( bool value )
|
||||||
{
|
{
|
||||||
if ( mFontUnderlineFlag != value )
|
if ( mFontUnderlineFlag != value )
|
||||||
{
|
{
|
||||||
mFontUnderlineFlag = value;
|
mFontUnderlineFlag = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Text Color Node Property Getter
|
/// Text Color Node Property Getter
|
||||||
///
|
///
|
||||||
ColorNode LabelModelTextObject::textColorNode( void ) const
|
ColorNode LabelModelTextObject::textColorNode( void ) const
|
||||||
{
|
{
|
||||||
return mTextColorNode;
|
return mTextColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Text Color Node Property Setter
|
/// Text Color Node Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setTextColorNode( const ColorNode& value )
|
void LabelModelTextObject::setTextColorNode( const ColorNode& value )
|
||||||
{
|
{
|
||||||
if ( mTextColorNode != value )
|
if ( mTextColorNode != value )
|
||||||
{
|
{
|
||||||
mTextColorNode = value;
|
mTextColorNode = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextHAlign Property Getter
|
/// TextHAlign Property Getter
|
||||||
///
|
///
|
||||||
Qt::Alignment LabelModelTextObject::textHAlign( void ) const
|
Qt::Alignment LabelModelTextObject::textHAlign( void ) const
|
||||||
{
|
{
|
||||||
return mTextHAlign;
|
return mTextHAlign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextHAlign Property Setter
|
/// TextHAlign Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setTextHAlign( Qt::Alignment value )
|
void LabelModelTextObject::setTextHAlign( Qt::Alignment value )
|
||||||
{
|
{
|
||||||
if ( mTextHAlign != value )
|
if ( mTextHAlign != value )
|
||||||
{
|
{
|
||||||
mTextHAlign = value;
|
mTextHAlign = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextVAlign Property Getter
|
/// TextVAlign Property Getter
|
||||||
///
|
///
|
||||||
Qt::Alignment LabelModelTextObject::textVAlign( void ) const
|
Qt::Alignment LabelModelTextObject::textVAlign( void ) const
|
||||||
{
|
{
|
||||||
return mTextVAlign;
|
return mTextVAlign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextVAlign Property Setter
|
/// TextVAlign Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setTextVAlign( Qt::Alignment value )
|
void LabelModelTextObject::setTextVAlign( Qt::Alignment value )
|
||||||
{
|
{
|
||||||
if ( mTextVAlign != value )
|
if ( mTextVAlign != value )
|
||||||
{
|
{
|
||||||
mTextVAlign = value;
|
mTextVAlign = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextLineSpacing Property Getter
|
/// TextLineSpacing Property Getter
|
||||||
///
|
///
|
||||||
double LabelModelTextObject::textLineSpacing( void ) const
|
double LabelModelTextObject::textLineSpacing( void ) const
|
||||||
{
|
{
|
||||||
return mTextLineSpacing;
|
return mTextLineSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextLineSpacing Property Setter
|
/// TextLineSpacing Property Setter
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::setTextLineSpacing( double value )
|
void LabelModelTextObject::setTextLineSpacing( double value )
|
||||||
{
|
{
|
||||||
if ( mTextLineSpacing != value )
|
if ( mTextLineSpacing != value )
|
||||||
{
|
{
|
||||||
mTextLineSpacing = value;
|
mTextLineSpacing = value;
|
||||||
update();
|
update();
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Can Text Capability Implementation
|
/// Can Text Capability Implementation
|
||||||
///
|
///
|
||||||
bool LabelModelTextObject::canText()
|
bool LabelModelTextObject::canText()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw shadow of object
|
/// Draw shadow of object
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelTextObject::drawShadow( QPainter* painter,
|
||||||
{
|
bool inEditor,
|
||||||
|
merge::Record* record ) const
|
||||||
|
{
|
||||||
QColor textColor = mTextColorNode.color( record );
|
QColor textColor = mTextColorNode.color( record );
|
||||||
|
|
||||||
if ( textColor.alpha() )
|
if ( textColor.alpha() )
|
||||||
@@ -366,14 +375,16 @@ void LabelModelTextObject::drawShadow( QPainter* painter, bool inEditor, merge::
|
|||||||
drawText( painter, shadowColor, record );
|
drawText( painter, shadowColor, record );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void LabelModelTextObject::drawObject( QPainter* painter,
|
||||||
{
|
bool inEditor,
|
||||||
|
merge::Record* record ) const
|
||||||
|
{
|
||||||
QColor textColor = mTextColorNode.color( record );
|
QColor textColor = mTextColorNode.color( record );
|
||||||
|
|
||||||
if ( inEditor )
|
if ( inEditor )
|
||||||
@@ -384,32 +395,32 @@ void LabelModelTextObject::drawObject( QPainter* painter, bool inEditor, merge::
|
|||||||
{
|
{
|
||||||
drawText( painter, textColor, record );
|
drawText( painter, textColor, record );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Path to test for hover condition
|
/// Path to test for hover condition
|
||||||
///
|
///
|
||||||
QPainterPath LabelModelTextObject::hoverPath( double scale ) const
|
QPainterPath LabelModelTextObject::hoverPath( double scale ) const
|
||||||
{
|
{
|
||||||
return mHoverPath;
|
return mHoverPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Size updated
|
/// Size updated
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::sizeUpdated()
|
void LabelModelTextObject::sizeUpdated()
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Update cached information for editor view
|
/// Update cached information for editor view
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::update()
|
void LabelModelTextObject::update()
|
||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setFamily( mFontFamily );
|
font.setFamily( mFontFamily );
|
||||||
font.setPointSizeF( mFontSize );
|
font.setPointSizeF( mFontSize );
|
||||||
@@ -486,14 +497,14 @@ void LabelModelTextObject::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mHoverPath = hoverPath; // save new hover path
|
mHoverPath = hoverPath; // save new hover path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw text in editor from cached information
|
/// Draw text in editor from cached information
|
||||||
///
|
///
|
||||||
void LabelModelTextObject::drawTextInEditor( QPainter* painter, const QColor& color ) const
|
void LabelModelTextObject::drawTextInEditor( QPainter* painter, const QColor& color ) const
|
||||||
{
|
{
|
||||||
if ( mText.isEmpty() )
|
if ( mText.isEmpty() )
|
||||||
{
|
{
|
||||||
QColor mutedColor = color;
|
QColor mutedColor = color;
|
||||||
@@ -509,15 +520,17 @@ void LabelModelTextObject::drawTextInEditor( QPainter* painter, const QColor& co
|
|||||||
{
|
{
|
||||||
layout->draw( painter, QPointF( 0, 0 ) );
|
layout->draw( painter, QPointF( 0, 0 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw text in final printout or preview
|
/// Draw text in final printout or preview
|
||||||
///
|
///
|
||||||
void
|
void
|
||||||
LabelModelTextObject::drawText( QPainter* painter, const QColor&color, merge::Record* record ) const
|
LabelModelTextObject::drawText( QPainter* painter,
|
||||||
{
|
const QColor& color,
|
||||||
|
merge::Record* record ) const
|
||||||
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setFamily( mFontFamily );
|
font.setFamily( mFontFamily );
|
||||||
font.setPointSizeF( mFontSize );
|
font.setPointSizeF( mFontSize );
|
||||||
@@ -597,14 +610,14 @@ LabelModelTextObject::drawText( QPainter* painter, const QColor&color, merge::Re
|
|||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
qDeleteAll( layouts );
|
qDeleteAll( layouts );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Expand text by replacing fields with their values from the given record
|
/// Expand text by replacing fields with their values from the given record
|
||||||
///
|
///
|
||||||
QString LabelModelTextObject::expandText( QString text, merge::Record* record ) const
|
QString LabelModelTextObject::expandText( QString text, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
if ( record )
|
if ( record )
|
||||||
{
|
{
|
||||||
foreach ( QString key, record->keys() )
|
foreach ( QString key, record->keys() )
|
||||||
@@ -625,4 +638,6 @@ QString LabelModelTextObject::expandText( QString text, merge::Record* record )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,17 +27,20 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Line Object
|
|
||||||
///
|
|
||||||
class LabelModelTextObject : public LabelModelObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Label Model Line Object
|
||||||
|
///
|
||||||
|
class LabelModelTextObject : public LabelModelObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModelTextObject();
|
LabelModelTextObject();
|
||||||
LabelModelTextObject( const LabelModelTextObject* object );
|
LabelModelTextObject( const LabelModelTextObject* object );
|
||||||
virtual ~LabelModelTextObject();
|
virtual ~LabelModelTextObject();
|
||||||
@@ -52,7 +55,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Text Property: text
|
// Text Property: text
|
||||||
//
|
//
|
||||||
@@ -126,14 +129,14 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canText();
|
virtual bool canText();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||||
virtual void drawObject( 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;
|
virtual QPainterPath hoverPath( double scale ) const;
|
||||||
@@ -142,7 +145,7 @@ protected:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private methods
|
// Private methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
virtual void sizeUpdated();
|
virtual void sizeUpdated();
|
||||||
void update();
|
void update();
|
||||||
void drawTextInEditor( QPainter* painter, const QColor& color ) const;
|
void drawTextInEditor( QPainter* painter, const QColor& color ) const;
|
||||||
@@ -153,7 +156,7 @@ private:
|
|||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QString mText;
|
QString mText;
|
||||||
QString mFontFamily;
|
QString mFontFamily;
|
||||||
double mFontSize;
|
double mFontSize;
|
||||||
@@ -168,7 +171,9 @@ private:
|
|||||||
QList<QTextLayout*> mEditorLayouts;
|
QList<QTextLayout*> mEditorLayouts;
|
||||||
QPainterPath mHoverPath;
|
QPainterPath mHoverPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelTextObject_h
|
#endif // LabelModelTextObject_h
|
||||||
|
|||||||
+7
-5
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "privateConstants.h"
|
#include "Constants.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
@@ -37,6 +37,7 @@ namespace glabels
|
|||||||
const Distance& dy )
|
const Distance& dy )
|
||||||
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(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),
|
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0),
|
||||||
mDx(other.mDx), mDy(other.mDy)
|
mDx(other.mDx), mDy(other.mDy)
|
||||||
{
|
{
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -87,10 +89,10 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
return ( (mNx == other->mNx) &&
|
return ( (mNx == other->mNx) &&
|
||||||
(mNy == other->mNy) &&
|
(mNy == other->mNy) &&
|
||||||
(fabs(mX0 - other->mX0) < Constants::EPSILON) &&
|
(fabs(mX0 - other->mX0) < EPSILON) &&
|
||||||
(fabs(mY0 - other->mY0) < Constants::EPSILON) &&
|
(fabs(mY0 - other->mY0) < EPSILON) &&
|
||||||
(fabs(mDx - other->mDx) < Constants::EPSILON) &&
|
(fabs(mDx - other->mDx) < EPSILON) &&
|
||||||
(fabs(mDy - other->mDy) < Constants::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 <QStackedWidget>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
// Forward References
|
|
||||||
class LabelEditor;
|
|
||||||
class LabelModel;
|
|
||||||
class MergeView;
|
|
||||||
class ObjectEditor;
|
|
||||||
class PrintView;
|
|
||||||
class PropertiesView;
|
|
||||||
class StartupView;
|
|
||||||
class UndoRedoModel;
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
///
|
|
||||||
/// MainWindow Widget
|
|
||||||
///
|
|
||||||
class MainWindow : public QMainWindow
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 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
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
@@ -63,7 +67,7 @@ public:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModel* model() const;
|
LabelModel* model() const;
|
||||||
void setModel( LabelModel* label );
|
void setModel( LabelModel* label );
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
@@ -72,14 +76,14 @@ public:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Events
|
// Events
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void closeEvent( QCloseEvent *event );
|
void closeEvent( QCloseEvent *event );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||||
|
|
||||||
void clipboardChanged();
|
void clipboardChanged();
|
||||||
@@ -152,7 +156,7 @@ private slots:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Internal Private Methods
|
// Internal Private Methods
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void createActions();
|
void createActions();
|
||||||
void createMenus();
|
void createMenus();
|
||||||
void createToolBars();
|
void createToolBars();
|
||||||
@@ -182,7 +186,7 @@ private:
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QMenu* fileMenu;
|
QMenu* fileMenu;
|
||||||
QMenu* editMenu;
|
QMenu* editMenu;
|
||||||
QMenu* viewMenu;
|
QMenu* viewMenu;
|
||||||
@@ -283,7 +287,10 @@ private:
|
|||||||
QAction* contextCopyAction;
|
QAction* contextCopyAction;
|
||||||
QAction* contextPasteAction;
|
QAction* contextPasteAction;
|
||||||
QAction* contextDeleteAction;
|
QAction* contextDeleteAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // MainWindow_h
|
#endif // MainWindow_h
|
||||||
|
|||||||
@@ -31,15 +31,17 @@
|
|||||||
#include "TextSemicolonKeys.h"
|
#include "TextSemicolonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// Static data
|
{
|
||||||
///
|
|
||||||
|
//
|
||||||
|
// Static data
|
||||||
|
//
|
||||||
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
||||||
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
||||||
|
|
||||||
QStringList Factory::mNameList;
|
QStringList Factory::mNameList;
|
||||||
|
|
||||||
|
|
||||||
@@ -217,5 +219,6 @@ namespace merge
|
|||||||
mNameList << name;
|
mNameList << name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+10
-2
@@ -26,9 +26,14 @@
|
|||||||
#include <QMap>
|
#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;
|
static QStringList mNameList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Factory_h
|
#endif // merge_Factory_h
|
||||||
|
|||||||
@@ -23,9 +23,12 @@
|
|||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
@@ -207,4 +210,6 @@ namespace merge
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -27,9 +27,14 @@
|
|||||||
#include <QList>
|
#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;
|
QList<Record*> mRecordList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Merge_h
|
#endif // merge_Merge_h
|
||||||
|
|||||||
@@ -21,9 +21,12 @@
|
|||||||
#include "None.h"
|
#include "None.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
@@ -119,4 +122,6 @@ namespace merge
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Merge.h"
|
#include "Merge.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// None Merge Backend
|
/// None Merge Backend
|
||||||
///
|
///
|
||||||
@@ -69,6 +72,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_None_h
|
#endif // merge_None_h
|
||||||
|
|||||||
@@ -21,9 +21,12 @@
|
|||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
@@ -67,4 +70,6 @@ namespace merge
|
|||||||
mSelected = value;
|
mSelected = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,12 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Merge Record
|
/// Merge Record
|
||||||
///
|
///
|
||||||
@@ -64,6 +67,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Record_h
|
#endif // merge_Record_h
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
@@ -412,4 +415,6 @@ namespace merge
|
|||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,12 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Text Merge Backend
|
/// Text Merge Backend
|
||||||
///
|
///
|
||||||
@@ -75,6 +78,9 @@ namespace merge
|
|||||||
int mNFieldsMax;
|
int mNFieldsMax;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Text_h
|
#endif // merge_Text_h
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
#include "TextColon.h"
|
#include "TextColon.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
static const QString ID = "Text/Colon";
|
static const QString ID = "Text/Colon";
|
||||||
|
|
||||||
|
|
||||||
@@ -77,4 +80,6 @@ namespace merge
|
|||||||
return new TextColon();
|
return new TextColon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextColon Merge Backend
|
/// TextColon Merge Backend
|
||||||
///
|
///
|
||||||
@@ -58,6 +61,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextColon_h
|
#endif // merge_TextColon_h
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
#include "TextColonKeys.h"
|
#include "TextColonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
static const QString ID = "Text/Colon/Line1Keys";
|
static const QString ID = "Text/Colon/Line1Keys";
|
||||||
|
|
||||||
|
|
||||||
@@ -77,4 +80,6 @@ namespace merge
|
|||||||
return new TextColonKeys();
|
return new TextColonKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextColonKeys Merge Backend
|
/// TextColonKeys Merge Backend
|
||||||
///
|
///
|
||||||
@@ -58,6 +61,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextColonKeys_h
|
#endif // merge_TextColonKeys_h
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
#include "TextCsv.h"
|
#include "TextCsv.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
static const QString ID = "Text/Comma";
|
static const QString ID = "Text/Comma";
|
||||||
|
|
||||||
|
|
||||||
@@ -77,4 +80,6 @@ namespace merge
|
|||||||
return new TextCsv();
|
return new TextCsv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextCsv Merge Backend
|
/// TextCsv Merge Backend
|
||||||
///
|
///
|
||||||
@@ -58,6 +61,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextCsv_h
|
#endif // merge_TextCsv_h
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
#include "TextCsvKeys.h"
|
#include "TextCsvKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
static const QString ID = "Text/Comma/Line1Keys";
|
static const QString ID = "Text/Comma/Line1Keys";
|
||||||
|
|
||||||
|
|
||||||
@@ -77,4 +80,6 @@ namespace merge
|
|||||||
return new TextCsvKeys();
|
return new TextCsvKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextCsvKeys Merge Backend
|
/// TextCsvKeys Merge Backend
|
||||||
///
|
///
|
||||||
@@ -58,6 +61,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextCsvKeys_h
|
#endif // merge_TextCsvKeys_h
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
#include "TextSemicolon.h"
|
#include "TextSemicolon.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
static const QString ID = "Text/Semicolon";
|
static const QString ID = "Text/Semicolon";
|
||||||
|
|
||||||
|
|
||||||
@@ -77,4 +80,6 @@ namespace merge
|
|||||||
return new TextSemicolon();
|
return new TextSemicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextSemicolon Merge Backend
|
/// TextSemicolon Merge Backend
|
||||||
///
|
///
|
||||||
@@ -58,6 +61,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextSemicolon_h
|
#endif // merge_TextSemicolon_h
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
#include "TextSemicolonKeys.h"
|
#include "TextSemicolonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
static const QString ID = "Text/Semicolon/Keys";
|
static const QString ID = "Text/Semicolon/Keys";
|
||||||
|
|
||||||
|
|
||||||
@@ -77,4 +80,6 @@ namespace merge
|
|||||||
return new TextSemicolonKeys();
|
return new TextSemicolonKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextSemicolonKeys Merge Backend
|
/// TextSemicolonKeys Merge Backend
|
||||||
///
|
///
|
||||||
@@ -58,6 +61,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextSemicolonKeys_h
|
#endif // merge_TextSemicolonKeys_h
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
#include "TextTsv.h"
|
#include "TextTsv.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
static const QString ID = "Text/Tab";
|
static const QString ID = "Text/Tab";
|
||||||
|
|
||||||
|
|
||||||
@@ -77,4 +80,6 @@ namespace merge
|
|||||||
return new TextTsv();
|
return new TextTsv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextTsv Merge Backend
|
/// TextTsv Merge Backend
|
||||||
///
|
///
|
||||||
@@ -58,6 +61,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextTsv_h
|
#endif // merge_TextTsv_h
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
#include "TextTsvKeys.h"
|
#include "TextTsvKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
static const QString ID = "Text/Tab/Line1Keys";
|
static const QString ID = "Text/Tab/Line1Keys";
|
||||||
|
|
||||||
|
|
||||||
@@ -77,4 +80,6 @@ namespace merge
|
|||||||
return new TextTsvKeys();
|
return new TextTsvKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,12 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// TextTsvKeys Merge Backend
|
/// TextTsvKeys Merge Backend
|
||||||
///
|
///
|
||||||
@@ -58,6 +61,9 @@ namespace merge
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextTsvKeys_h
|
#endif // merge_TextTsvKeys_h
|
||||||
|
|||||||
+95
-82
@@ -30,32 +30,36 @@
|
|||||||
#include "Merge/Factory.h"
|
#include "Merge/Factory.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
MergeView::MergeView( QWidget *parent )
|
|
||||||
: QWidget(parent), mModel(0), mBlock(false)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
MergeView::MergeView( QWidget *parent )
|
||||||
|
: QWidget(parent), mModel(0), mBlock(false)
|
||||||
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
mMergeFormatNames = merge::Factory::nameList();
|
mMergeFormatNames = merge::Factory::nameList();
|
||||||
formatCombo->addItems( mMergeFormatNames );
|
formatCombo->addItems( mMergeFormatNames );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
MergeView::~MergeView()
|
MergeView::~MergeView()
|
||||||
{
|
{
|
||||||
}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set Model
|
/// Set Model
|
||||||
///
|
///
|
||||||
void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||||
{
|
{
|
||||||
mModel = model;
|
mModel = model;
|
||||||
mUndoRedoModel = undoRedoModel;
|
mUndoRedoModel = undoRedoModel;
|
||||||
|
|
||||||
@@ -71,15 +75,16 @@ void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
|||||||
|
|
||||||
onMergeChanged();
|
onMergeChanged();
|
||||||
connect( mModel, SIGNAL(mergeChanged()), this, SLOT(onMergeChanged()) );
|
connect( mModel, SIGNAL(mergeChanged()), this, SLOT(onMergeChanged()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Merge changed handler
|
/// Merge changed handler
|
||||||
///
|
///
|
||||||
void MergeView::onMergeChanged()
|
void MergeView::onMergeChanged()
|
||||||
{
|
{
|
||||||
int index = mMergeFormatNames.indexOf( merge::Factory::idToName( mModel->merge()->id() ) );
|
QString name = merge::Factory::idToName( mModel->merge()->id() );
|
||||||
|
int index = mMergeFormatNames.indexOf( name );
|
||||||
mOldFormatComboIndex = index;
|
mOldFormatComboIndex = index;
|
||||||
formatCombo->setCurrentIndex( index );
|
formatCombo->setCurrentIndex( index );
|
||||||
|
|
||||||
@@ -115,32 +120,36 @@ void MergeView::onMergeChanged()
|
|||||||
loadHeaders( mModel->merge() );
|
loadHeaders( mModel->merge() );
|
||||||
loadTable( mModel->merge() );
|
loadTable( mModel->merge() );
|
||||||
|
|
||||||
connect( mModel->merge(), SIGNAL(sourceChanged()), this, SLOT(onMergeSourceChanged()) );
|
connect( mModel->merge(), SIGNAL(sourceChanged()),
|
||||||
connect( mModel->merge(), SIGNAL(selectionChanged()), this, SLOT(onMergeSelectionChanged()) );
|
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
|
/// Merge source changed handler
|
||||||
///
|
///
|
||||||
void MergeView::onMergeSourceChanged()
|
void MergeView::onMergeSourceChanged()
|
||||||
{
|
{
|
||||||
locationButton->setText( mModel->merge()->source() );
|
locationButton->setText( mModel->merge()->source() );
|
||||||
|
|
||||||
recordsTable->clear();
|
recordsTable->clear();
|
||||||
recordsTable->setColumnCount( 0 );
|
recordsTable->setColumnCount( 0 );
|
||||||
loadHeaders( mModel->merge() );
|
loadHeaders( mModel->merge() );
|
||||||
loadTable( mModel->merge() );
|
loadTable( mModel->merge() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Merge selection changed handler
|
/// Merge selection changed handler
|
||||||
///
|
///
|
||||||
void MergeView::onMergeSelectionChanged()
|
void MergeView::onMergeSelectionChanged()
|
||||||
{
|
{
|
||||||
mBlock = true; // Don't recurse
|
mBlock = true; // Don't recurse
|
||||||
|
|
||||||
const QList<merge::Record*>& records = mModel->merge()->recordList();
|
const QList<merge::Record*>& records = mModel->merge()->recordList();
|
||||||
@@ -155,28 +164,30 @@ void MergeView::onMergeSelectionChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mBlock = false;
|
mBlock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Format combo changed handler
|
/// Format combo changed handler
|
||||||
void MergeView::onFormatComboActivated()
|
///
|
||||||
{
|
void MergeView::onFormatComboActivated()
|
||||||
|
{
|
||||||
int index = formatCombo->currentIndex();
|
int index = formatCombo->currentIndex();
|
||||||
if ( index != mOldFormatComboIndex )
|
if ( index != mOldFormatComboIndex )
|
||||||
{
|
{
|
||||||
mOldFormatComboIndex = index;
|
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
|
/// Location button clicked handler
|
||||||
///
|
///
|
||||||
void MergeView::onLocationButtonClicked()
|
void MergeView::onLocationButtonClicked()
|
||||||
{
|
{
|
||||||
QString fileName =
|
QString fileName =
|
||||||
QFileDialog::getOpenFileName( this,
|
QFileDialog::getOpenFileName( this,
|
||||||
tr("Select merge file"),
|
tr("Select merge file"),
|
||||||
@@ -187,32 +198,32 @@ void MergeView::onLocationButtonClicked()
|
|||||||
mModel->merge()->setSource( fileName );
|
mModel->merge()->setSource( fileName );
|
||||||
mCwd = QFileInfo( fileName ).absolutePath(); // Update CWD
|
mCwd = QFileInfo( fileName ).absolutePath(); // Update CWD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Select all button clicked handler
|
/// Select all button clicked handler
|
||||||
///
|
///
|
||||||
void MergeView::onSelectAllButtonClicked()
|
void MergeView::onSelectAllButtonClicked()
|
||||||
{
|
{
|
||||||
mModel->merge()->selectAll();
|
mModel->merge()->selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Unselect all button clicked handler
|
/// Unselect all button clicked handler
|
||||||
///
|
///
|
||||||
void MergeView::onUnselectAllButtonClicked()
|
void MergeView::onUnselectAllButtonClicked()
|
||||||
{
|
{
|
||||||
mModel->merge()->unselectAll();
|
mModel->merge()->unselectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Cell changed handler
|
/// Cell changed handler
|
||||||
///
|
///
|
||||||
void MergeView::onCellChanged( int iRow, int iCol )
|
void MergeView::onCellChanged( int iRow, int iCol )
|
||||||
{
|
{
|
||||||
if ( !mBlock )
|
if ( !mBlock )
|
||||||
{
|
{
|
||||||
QTableWidgetItem* item = recordsTable->item( iRow, 0 );
|
QTableWidgetItem* item = recordsTable->item( iRow, 0 );
|
||||||
@@ -220,14 +231,14 @@ void MergeView::onCellChanged( int iRow, int iCol )
|
|||||||
|
|
||||||
mModel->merge()->setSelected( iRow, state );
|
mModel->merge()->setSelected( iRow, state );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Load headers
|
/// Load headers
|
||||||
///
|
///
|
||||||
void MergeView::loadHeaders( merge::Merge* merge )
|
void MergeView::loadHeaders( merge::Merge* merge )
|
||||||
{
|
{
|
||||||
mPrimaryKey = merge->primaryKey();
|
mPrimaryKey = merge->primaryKey();
|
||||||
mKeys = merge->keys();
|
mKeys = merge->keys();
|
||||||
|
|
||||||
@@ -261,14 +272,14 @@ void MergeView::loadHeaders( merge::Merge* merge )
|
|||||||
recordsTable->setHorizontalHeaderItem( iCol, fillItem );
|
recordsTable->setHorizontalHeaderItem( iCol, fillItem );
|
||||||
recordsTable->horizontalHeader()->setStretchLastSection( true );
|
recordsTable->horizontalHeader()->setStretchLastSection( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Load table
|
/// Load table
|
||||||
///
|
///
|
||||||
void MergeView::loadTable( merge::Merge* merge )
|
void MergeView::loadTable( merge::Merge* merge )
|
||||||
{
|
{
|
||||||
mBlock = true;
|
mBlock = true;
|
||||||
|
|
||||||
const QList<merge::Record*>& records = merge->recordList();
|
const QList<merge::Record*>& records = merge->recordList();
|
||||||
@@ -288,7 +299,7 @@ void MergeView::loadTable( merge::Merge* merge )
|
|||||||
recordsTable->setItem( iRow, 0, item );
|
recordsTable->setItem( iRow, 0, item );
|
||||||
recordsTable->resizeColumnToContents( 0 );
|
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;
|
int iCol = 1;
|
||||||
foreach ( QString key, mKeys )
|
foreach ( QString key, mKeys )
|
||||||
{
|
{
|
||||||
@@ -315,4 +326,6 @@ void MergeView::loadTable( merge::Merge* merge )
|
|||||||
}
|
}
|
||||||
|
|
||||||
mBlock = false;
|
mBlock = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-13
@@ -26,23 +26,27 @@
|
|||||||
|
|
||||||
#include "Merge/Merge.h"
|
#include "Merge/Merge.h"
|
||||||
|
|
||||||
// Forward references
|
|
||||||
class LabelModel;
|
|
||||||
class UndoRedoModel;
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
///
|
|
||||||
/// merge::Merge Property Editor Widget
|
|
||||||
///
|
|
||||||
class MergeView : public QWidget, public Ui_MergeView
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward references
|
||||||
|
class LabelModel;
|
||||||
|
class UndoRedoModel;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// merge::Merge Property Editor Widget
|
||||||
|
///
|
||||||
|
class MergeView : public QWidget, public Ui_MergeView
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
MergeView( QWidget *parent = 0 );
|
MergeView( QWidget *parent = 0 );
|
||||||
~MergeView();
|
~MergeView();
|
||||||
|
|
||||||
@@ -56,7 +60,7 @@ public:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onMergeChanged();
|
void onMergeChanged();
|
||||||
void onMergeSourceChanged();
|
void onMergeSourceChanged();
|
||||||
void onMergeSelectionChanged();
|
void onMergeSelectionChanged();
|
||||||
@@ -71,7 +75,7 @@ private slots:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private methods
|
// Private methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void loadHeaders( merge::Merge* merge );
|
void loadHeaders( merge::Merge* merge );
|
||||||
void loadTable( merge::Merge* merge );
|
void loadTable( merge::Merge* merge );
|
||||||
|
|
||||||
@@ -79,7 +83,7 @@ private:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QStringList mMergeFormatNames;
|
QStringList mMergeFormatNames;
|
||||||
|
|
||||||
LabelModel* mModel;
|
LabelModel* mModel;
|
||||||
@@ -93,7 +97,9 @@ private:
|
|||||||
bool mBlock;
|
bool mBlock;
|
||||||
int mOldFormatComboIndex;
|
int mOldFormatComboIndex;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // MergeView_h
|
#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