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.
|
||||||
|
|||||||
+49
-44
@@ -28,56 +28,61 @@
|
|||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
AboutDialog::AboutDialog( QWidget *parent )
|
|
||||||
: QDialog(parent)
|
|
||||||
{
|
{
|
||||||
setupUi( this );
|
|
||||||
|
|
||||||
QString version = tr("Version") + " " + Version::STRING;
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
AboutDialog::AboutDialog( QWidget *parent )
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
setupUi( this );
|
||||||
|
|
||||||
QString description = tr("A program to create labels and business cards.");
|
QString version = tr("Version") + " " + Version::STRING;
|
||||||
|
|
||||||
QString copyright = "Copyright © 2017 Jim Evins <evins@snaught.com>";
|
QString description = tr("A program to create labels and business cards.");
|
||||||
|
|
||||||
QString licenseParagraph1 =
|
QString copyright = "Copyright © 2017 Jim Evins <evins@snaught.com>";
|
||||||
tr( "gLabels is free software: you can redistribute it and/or modify "
|
|
||||||
"it under the terms of the GNU General Public License as published by "
|
|
||||||
"the Free Software Foundation, either version 3 of the License, or "
|
|
||||||
"(at your option) any later version." );
|
|
||||||
|
|
||||||
QString licenseParagraph2 =
|
QString licenseParagraph1 =
|
||||||
tr( "gLabels is distributed in the hope that it will be useful, "
|
tr( "gLabels is free software: you can redistribute it and/or modify "
|
||||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
|
"it under the terms of the GNU General Public License as published by "
|
||||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
|
"the Free Software Foundation, either version 3 of the License, or "
|
||||||
"GNU General Public License for more details." );
|
"(at your option) any later version." );
|
||||||
|
|
||||||
QString markup =
|
QString licenseParagraph2 =
|
||||||
"<p align='center'>" + version + "</p>" +
|
tr( "gLabels is distributed in the hope that it will be useful, "
|
||||||
"<p align='center'>" + description + "</p>" +
|
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
|
||||||
"<p align='center'>" + copyright + "</p>" +
|
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
|
||||||
"<p align='left'>" + licenseParagraph1 + "</p>" +
|
"GNU General Public License for more details." );
|
||||||
"<p align='left'>" + licenseParagraph2 + "</p>";
|
|
||||||
|
QString markup =
|
||||||
|
"<p align='center'>" + version + "</p>" +
|
||||||
|
"<p align='center'>" + description + "</p>" +
|
||||||
|
"<p align='center'>" + copyright + "</p>" +
|
||||||
|
"<p align='left'>" + licenseParagraph1 + "</p>" +
|
||||||
|
"<p align='left'>" + licenseParagraph2 + "</p>";
|
||||||
|
|
||||||
|
aboutLabel->setText( markup );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// "License" Button Clicked Slot
|
||||||
|
///
|
||||||
|
void AboutDialog::onLicenseButtonClicked()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl( QUrl("http://www.gnu.org/licenses/gpl-3.0.txt") );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// "Website" Button Clicked Slot
|
||||||
|
///
|
||||||
|
void AboutDialog::onWebsiteButtonClicked()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl( QUrl(Version::WEBSITE) );
|
||||||
|
}
|
||||||
|
|
||||||
aboutLabel->setText( markup );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// "License" Button Clicked Slot
|
|
||||||
///
|
|
||||||
void AboutDialog::onLicenseButtonClicked()
|
|
||||||
{
|
|
||||||
QDesktopServices::openUrl( QUrl("http://www.gnu.org/licenses/gpl-3.0.txt") );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// "Website" Button Clicked Slot
|
|
||||||
///
|
|
||||||
void AboutDialog::onWebsiteButtonClicked()
|
|
||||||
{
|
|
||||||
QDesktopServices::openUrl( QUrl(Version::WEBSITE) );
|
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-17
@@ -25,29 +25,34 @@
|
|||||||
#include "ui_AboutDialog.h"
|
#include "ui_AboutDialog.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// About Dialog Widget
|
|
||||||
///
|
|
||||||
class AboutDialog : public QDialog, public Ui_AboutDialog
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
///
|
||||||
|
/// About Dialog Widget
|
||||||
|
///
|
||||||
|
class AboutDialog : public QDialog, public Ui_AboutDialog
|
||||||
|
{
|
||||||
|
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
|
||||||
|
|||||||
+136
-132
@@ -21,159 +21,163 @@
|
|||||||
#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)"),
|
|
||||||
false, false, true, false, "12345-6789-12", false, 11 );
|
|
||||||
|
|
||||||
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
|
|
||||||
false, false, true, false, "12345", false, 5 );
|
|
||||||
|
|
||||||
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
|
|
||||||
false, false, true, false, "12345-6789", false, 9 );
|
|
||||||
|
|
||||||
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
|
|
||||||
false, false, true, false, "12345-6789-12", false, 11 );
|
|
||||||
|
|
||||||
registerStyle( "cepnet", "", tr("CEPNET"),
|
|
||||||
false, false, true, false, "12345-678", false, 8 );
|
|
||||||
|
|
||||||
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
|
|
||||||
false, false, true, false, "12345678901234567890", false, 20 );
|
|
||||||
|
|
||||||
registerStyle( "code39", "", tr("Code 39"),
|
|
||||||
true, true, true, true, "1234567890", true, 10 );
|
|
||||||
|
|
||||||
registerStyle( "code39ext", "", tr("Code 39 Extended"),
|
|
||||||
true, true, true, true, "1234567890", true, 10 );
|
|
||||||
|
|
||||||
registerStyle( "upc-A", "", tr("UPC-A"),
|
|
||||||
true, false, true, false, "12345678901", false, 11 );
|
|
||||||
|
|
||||||
registerStyle( "ean-13", "", tr("EAN-13"),
|
|
||||||
true, false, true, false, "123456789012", false, 12 );
|
|
||||||
|
|
||||||
registerStyle( "datamatrix", "", tr("DataMatrix"),
|
|
||||||
false, false, true, false, "1234567890AB", false, 12 );
|
|
||||||
|
|
||||||
registerStyle( "qrcode", "", tr("QRCode"),
|
|
||||||
false, false, true, false, "1234567890AB", false, 12 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BarcodeBackends::init( void )
|
|
||||||
{
|
|
||||||
static BarcodeBackends* singletonInstance = NULL;
|
|
||||||
|
|
||||||
if ( singletonInstance == NULL )
|
|
||||||
{
|
{
|
||||||
singletonInstance = new BarcodeBackends();
|
registerStyle( "postnet", "", tr("POSTNET (any)"),
|
||||||
}
|
false, false, true, false, "12345-6789-12", false, 11 );
|
||||||
}
|
|
||||||
|
|
||||||
|
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
|
||||||
|
false, false, true, false, "12345", false, 5 );
|
||||||
|
|
||||||
QString BarcodeBackends::BackendIdToName( const QString& backendId )
|
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
|
||||||
{
|
false, false, true, false, "12345-6789", false, 9 );
|
||||||
BackendMap::iterator i = mBackendIdMap.find( backendId );
|
|
||||||
if ( i != mBackendIdMap.end() )
|
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
|
||||||
{
|
false, false, true, false, "12345-6789-12", false, 11 );
|
||||||
return i.value();
|
|
||||||
|
registerStyle( "cepnet", "", tr("CEPNET"),
|
||||||
|
false, false, true, false, "12345-678", false, 8 );
|
||||||
|
|
||||||
|
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
|
||||||
|
false, false, true, false, "12345678901234567890", false, 20 );
|
||||||
|
|
||||||
|
registerStyle( "code39", "", tr("Code 39"),
|
||||||
|
true, true, true, true, "1234567890", true, 10 );
|
||||||
|
|
||||||
|
registerStyle( "code39ext", "", tr("Code 39 Extended"),
|
||||||
|
true, true, true, true, "1234567890", true, 10 );
|
||||||
|
|
||||||
|
registerStyle( "upc-A", "", tr("UPC-A"),
|
||||||
|
true, false, true, false, "12345678901", false, 11 );
|
||||||
|
|
||||||
|
registerStyle( "ean-13", "", tr("EAN-13"),
|
||||||
|
true, false, true, false, "123456789012", false, 12 );
|
||||||
|
|
||||||
|
registerStyle( "datamatrix", "", tr("DataMatrix"),
|
||||||
|
false, false, true, false, "1234567890AB", false, 12 );
|
||||||
|
|
||||||
|
registerStyle( "qrcode", "", tr("QRCode"),
|
||||||
|
false, false, true, false, "1234567890AB", false, 12 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void BarcodeBackends::init( void )
|
||||||
QString BarcodeBackends::BackendNameToId( const QString& backendName )
|
|
||||||
{
|
|
||||||
BackendMap::iterator i = mBackendNameMap.find( backendName );
|
|
||||||
if ( i != mBackendNameMap.end() )
|
|
||||||
{
|
{
|
||||||
return i.value();
|
static BarcodeBackends* singletonInstance = NULL;
|
||||||
|
|
||||||
|
if ( singletonInstance == NULL )
|
||||||
|
{
|
||||||
|
singletonInstance = new BarcodeBackends();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
QString BarcodeBackends::BackendIdToName( const QString& backendId )
|
||||||
const QList<QString>& BarcodeBackends::getBackendNameList()
|
|
||||||
{
|
|
||||||
return mBackendNameList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QList<QString>& BarcodeBackends::getNameList()
|
|
||||||
{
|
|
||||||
return mNameList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
|
|
||||||
{
|
|
||||||
StyleMap::iterator i = mStyleIdMap.find( id );
|
|
||||||
if ( i != mStyleIdMap.end() )
|
|
||||||
{
|
{
|
||||||
return i.value();
|
BackendMap::iterator i = mBackendIdMap.find( backendId );
|
||||||
|
if ( i != mBackendIdMap.end() )
|
||||||
|
{
|
||||||
|
return i.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
QString BarcodeBackends::BackendNameToId( const QString& backendName )
|
||||||
const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
|
|
||||||
{
|
|
||||||
StyleMap::iterator i = mStyleNameMap.find( name );
|
|
||||||
if ( i != mStyleNameMap.end() )
|
|
||||||
{
|
{
|
||||||
return i.value();
|
BackendMap::iterator i = mBackendNameMap.find( backendName );
|
||||||
|
if ( i != mBackendNameMap.end() )
|
||||||
|
{
|
||||||
|
return i.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QList<QString>& BarcodeBackends::getBackendNameList()
|
||||||
|
{
|
||||||
|
return mBackendNameList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QList<QString>& BarcodeBackends::getNameList()
|
||||||
|
{
|
||||||
|
return mNameList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BarcodeStyle* BarcodeBackends::lookupStyleFromId( const QString& id )
|
||||||
|
{
|
||||||
|
StyleMap::iterator i = mStyleIdMap.find( id );
|
||||||
|
if ( i != mStyleIdMap.end() )
|
||||||
|
{
|
||||||
|
return i.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BarcodeStyle* BarcodeBackends::lookupStyleFromName( const QString& name )
|
||||||
|
{
|
||||||
|
StyleMap::iterator i = mStyleNameMap.find( name );
|
||||||
|
if ( i != mStyleNameMap.end() )
|
||||||
|
{
|
||||||
|
return i.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BarcodeBackends::registerBackend( QString& id, QString& name)
|
||||||
|
{
|
||||||
|
mBackendNameList.append( name );
|
||||||
|
mBackendIdMap.insert( id, name );
|
||||||
|
mBackendNameMap.insert( name, id );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BarcodeBackends::registerStyle( const char* id,
|
||||||
|
const char* backendId,
|
||||||
|
const QString& name,
|
||||||
|
bool canText,
|
||||||
|
bool textOptional,
|
||||||
|
bool canChecksum,
|
||||||
|
bool checksumOptional,
|
||||||
|
const char* defaultDigits,
|
||||||
|
bool canFreeForm,
|
||||||
|
int preferedN )
|
||||||
|
{
|
||||||
|
BarcodeStyle* style = new BarcodeStyle( QString(id), QString(backendId), name,
|
||||||
|
canText, textOptional,
|
||||||
|
canChecksum, checksumOptional,
|
||||||
|
QString(defaultDigits),
|
||||||
|
canFreeForm, preferedN );
|
||||||
|
|
||||||
|
QString fqName = QString(backendId) + QString(".") + name; // Name may not be unique
|
||||||
|
|
||||||
|
mNameList.append( name );
|
||||||
|
mStyleIdMap.insert( id, style );
|
||||||
|
mStyleNameMap.insert( fqName, style );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BarcodeBackends::registerBackend( QString& id, QString& name)
|
|
||||||
{
|
|
||||||
mBackendNameList.append( name );
|
|
||||||
mBackendIdMap.insert( id, name );
|
|
||||||
mBackendNameMap.insert( name, id );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BarcodeBackends::registerStyle( const char* id,
|
|
||||||
const char* backendId,
|
|
||||||
const QString& name,
|
|
||||||
bool canText,
|
|
||||||
bool textOptional,
|
|
||||||
bool canChecksum,
|
|
||||||
bool checksumOptional,
|
|
||||||
const char* defaultDigits,
|
|
||||||
bool canFreeForm,
|
|
||||||
int preferedN )
|
|
||||||
{
|
|
||||||
BarcodeStyle* style = new BarcodeStyle( QString(id), QString(backendId), name,
|
|
||||||
canText, textOptional,
|
|
||||||
canChecksum, checksumOptional,
|
|
||||||
QString(defaultDigits), canFreeForm, preferedN );
|
|
||||||
|
|
||||||
QString fqName = QString(backendId) + QString(".") + name; // Name may not be unique
|
|
||||||
|
|
||||||
mNameList.append( name );
|
|
||||||
mStyleIdMap.insert( id, style );
|
|
||||||
mStyleNameMap.insert( fqName, style );
|
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-48
@@ -30,68 +30,73 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Backends Database
|
|
||||||
///
|
|
||||||
class BarcodeBackends : public QObject
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Barcode Backends Database
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
class BarcodeBackends : public QObject
|
||||||
BarcodeBackends();
|
{
|
||||||
|
|
||||||
public:
|
/////////////////////////////////
|
||||||
static void init( void );
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
BarcodeBackends();
|
||||||
|
|
||||||
/////////////////////////////////
|
public:
|
||||||
// Public Methods
|
static void init( void );
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString BackendIdToName( const QString& backendId );
|
|
||||||
static QString BackendNameToId( const QString& backendName );
|
|
||||||
|
|
||||||
static const QList<QString>& getBackendNameList();
|
/////////////////////////////////
|
||||||
static const QList<QString>& getNameList();
|
// Public Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString BackendIdToName( const QString& backendId );
|
||||||
|
static QString BackendNameToId( const QString& backendName );
|
||||||
|
|
||||||
static const BarcodeStyle* lookupStyleFromId( const QString& id );
|
static const QList<QString>& getBackendNameList();
|
||||||
static const BarcodeStyle* lookupStyleFromName( const QString& name );
|
static const QList<QString>& getNameList();
|
||||||
|
|
||||||
|
static const BarcodeStyle* lookupStyleFromId( const QString& id );
|
||||||
|
static const BarcodeStyle* lookupStyleFromName( const QString& name );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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,
|
||||||
const char* backendId,
|
const char* backendId,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
bool canText,
|
bool canText,
|
||||||
bool textOptional,
|
bool textOptional,
|
||||||
bool canChecksum,
|
bool canChecksum,
|
||||||
bool checksumOptional,
|
bool checksumOptional,
|
||||||
const char* defaultDigits,
|
const char* defaultDigits,
|
||||||
bool canFreeForm,
|
bool canFreeForm,
|
||||||
int preferedN );
|
int preferedN );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
typedef QMap<QString,QString> BackendMap;
|
typedef QMap<QString,QString> BackendMap;
|
||||||
static BackendMap mBackendIdMap;
|
static BackendMap mBackendIdMap;
|
||||||
static BackendMap mBackendNameMap;
|
static BackendMap mBackendNameMap;
|
||||||
|
|
||||||
typedef QMap<QString,BarcodeStyle*> StyleMap;
|
typedef QMap<QString,BarcodeStyle*> StyleMap;
|
||||||
static StyleMap mStyleIdMap;
|
static StyleMap mStyleIdMap;
|
||||||
static StyleMap mStyleNameMap;
|
static StyleMap mStyleNameMap;
|
||||||
|
|
||||||
static QList<QString> mBackendNameList;
|
static QList<QString> mBackendNameList;
|
||||||
static QList<QString> mNameList;
|
static QList<QString> mNameList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeBackends_h
|
#endif // BarcodeBackends_h
|
||||||
|
|||||||
+34
-29
@@ -25,38 +25,43 @@
|
|||||||
#include "BarcodeMenuItem.h"
|
#include "BarcodeMenuItem.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
BarcodeMenu::BarcodeMenu()
|
|
||||||
{
|
{
|
||||||
foreach ( QString name, BarcodeBackends::getNameList() )
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
BarcodeMenu::BarcodeMenu()
|
||||||
{
|
{
|
||||||
const BarcodeStyle* bcStyle = BarcodeBackends::lookupStyleFromName( name );
|
foreach ( QString name, BarcodeBackends::getNameList() )
|
||||||
|
{
|
||||||
|
const BarcodeStyle* bcStyle = BarcodeBackends::lookupStyleFromName( name );
|
||||||
|
|
||||||
BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle );
|
BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle );
|
||||||
connect( bcMenuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
|
connect( bcMenuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
|
||||||
|
|
||||||
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();
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-31
@@ -27,48 +27,53 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Menu
|
|
||||||
///
|
|
||||||
class BarcodeMenu : public QMenu
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Barcode Menu
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class BarcodeMenu : public QMenu
|
||||||
BarcodeMenu();
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
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,38 +25,43 @@
|
|||||||
#include "BarcodeMenuItem.h"
|
#include "BarcodeMenuItem.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
|
||||||
: QPushButton(parent)
|
|
||||||
{
|
{
|
||||||
mMenu = new BarcodeMenu();
|
|
||||||
setMenu( mMenu );
|
|
||||||
|
|
||||||
mBcStyle = BarcodeBackends::lookupStyleFromId( "" ); // Default style
|
///
|
||||||
setText( mBcStyle->name() );
|
/// Constructor
|
||||||
|
///
|
||||||
|
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
||||||
|
: QPushButton(parent)
|
||||||
|
{
|
||||||
|
mMenu = new BarcodeMenu();
|
||||||
|
setMenu( mMenu );
|
||||||
|
|
||||||
|
mBcStyle = BarcodeBackends::lookupStyleFromId( "" ); // Default style
|
||||||
|
setText( mBcStyle->name() );
|
||||||
|
|
||||||
|
connect( mMenu, SIGNAL(styleChanged()), this, SLOT(onMenuStyleChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// bcStyle getter
|
||||||
|
///
|
||||||
|
const BarcodeStyle* BarcodeMenuButton::bcStyle() const
|
||||||
|
{
|
||||||
|
return mBcStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// onMenuStyleChanged slot
|
||||||
|
///
|
||||||
|
void BarcodeMenuButton::onMenuStyleChanged()
|
||||||
|
{
|
||||||
|
mBcStyle = mMenu->bcStyle();
|
||||||
|
setText( mBcStyle->name() );
|
||||||
|
|
||||||
|
emit styleChanged();
|
||||||
|
}
|
||||||
|
|
||||||
connect( mMenu, SIGNAL(styleChanged()), this, SLOT(onMenuStyleChanged()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// bcStyle getter
|
|
||||||
///
|
|
||||||
const BarcodeStyle* BarcodeMenuButton::bcStyle() const
|
|
||||||
{
|
|
||||||
return mBcStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// onMenuStyleChanged slot
|
|
||||||
///
|
|
||||||
void BarcodeMenuButton::onMenuStyleChanged()
|
|
||||||
{
|
|
||||||
mBcStyle = mMenu->bcStyle();
|
|
||||||
setText( mBcStyle->name() );
|
|
||||||
|
|
||||||
emit styleChanged();
|
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-32
@@ -28,49 +28,54 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Menu Button
|
|
||||||
///
|
|
||||||
class BarcodeMenuButton : public QPushButton
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Barcode Menu Button
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class BarcodeMenuButton : public QPushButton
|
||||||
BarcodeMenuButton( QWidget* parent = 0 );
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
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
|
||||||
|
|||||||
+30
-25
@@ -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)
|
|
||||||
{
|
{
|
||||||
setText( bcStyle->name() );
|
|
||||||
|
|
||||||
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
|
///
|
||||||
}
|
/// Constructor From Data
|
||||||
|
///
|
||||||
|
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent )
|
||||||
///
|
: QAction(parent), mBcStyle(bcStyle)
|
||||||
/// bcStyle Property Getter
|
{
|
||||||
///
|
setText( bcStyle->name() );
|
||||||
const BarcodeStyle* BarcodeMenuItem::bcStyle() const
|
|
||||||
{
|
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
|
||||||
return mBcStyle;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// bcStyle Property Getter
|
||||||
/// onTriggered slot
|
///
|
||||||
///
|
const BarcodeStyle* BarcodeMenuItem::bcStyle() const
|
||||||
void BarcodeMenuItem::onTriggered()
|
{
|
||||||
{
|
return mBcStyle;
|
||||||
emit activated( mBcStyle );
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// onTriggered slot
|
||||||
|
///
|
||||||
|
void BarcodeMenuItem::onTriggered()
|
||||||
|
{
|
||||||
|
emit activated( mBcStyle );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-31
@@ -27,48 +27,53 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Menu Item
|
|
||||||
///
|
|
||||||
class BarcodeMenuItem : public QAction
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Barcode Menu Item
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class BarcodeMenuItem : public QAction
|
||||||
BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent = 0 );
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
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
|
||||||
|
|||||||
+137
-130
@@ -21,37 +21,41 @@
|
|||||||
#include "BarcodeStyle.h"
|
#include "BarcodeStyle.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Default Constructor
|
|
||||||
///
|
|
||||||
BarcodeStyle::BarcodeStyle ()
|
|
||||||
: mId( "" ),
|
|
||||||
mBackendId( "" ),
|
|
||||||
mName( "" ),
|
|
||||||
mCanText( false ),
|
|
||||||
mTextOptional( false ),
|
|
||||||
mCanChecksum( false ),
|
|
||||||
mChecksumOptional( false ),
|
|
||||||
mDefaultDigits( "" ),
|
|
||||||
mCanFreeform( false ),
|
|
||||||
mPreferedN( 0 )
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
///
|
||||||
|
/// Default Constructor
|
||||||
|
///
|
||||||
|
BarcodeStyle::BarcodeStyle ()
|
||||||
|
: mId( "" ),
|
||||||
|
mBackendId( "" ),
|
||||||
|
mName( "" ),
|
||||||
|
mCanText( false ),
|
||||||
|
mTextOptional( false ),
|
||||||
|
mCanChecksum( false ),
|
||||||
|
mChecksumOptional( false ),
|
||||||
|
mDefaultDigits( "" ),
|
||||||
|
mCanFreeform( false ),
|
||||||
|
mPreferedN( 0 )
|
||||||
|
{
|
||||||
|
// 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,
|
||||||
bool textOptional,
|
bool textOptional,
|
||||||
bool canChecksum,
|
bool canChecksum,
|
||||||
bool checksumOptional,
|
bool checksumOptional,
|
||||||
const QString& defaultDigits,
|
const QString& defaultDigits,
|
||||||
bool canFreeform,
|
bool canFreeform,
|
||||||
int preferedN )
|
int preferedN )
|
||||||
: mId( id ),
|
: mId( id ),
|
||||||
mBackendId( backendId ),
|
mBackendId( backendId ),
|
||||||
mName( name ),
|
mName( name ),
|
||||||
@@ -62,111 +66,114 @@ BarcodeStyle::BarcodeStyle ( const QString& id,
|
|||||||
mDefaultDigits( defaultDigits ),
|
mDefaultDigits( defaultDigits ),
|
||||||
mCanFreeform( canFreeform ),
|
mCanFreeform( canFreeform ),
|
||||||
mPreferedN( preferedN )
|
mPreferedN( preferedN )
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// ID Property Getter
|
|
||||||
///
|
|
||||||
const QString& BarcodeStyle::id() const
|
|
||||||
{
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Backend ID Property Getter
|
|
||||||
///
|
|
||||||
const QString& BarcodeStyle::backendId() const
|
|
||||||
{
|
|
||||||
return mBackendId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Name Property Getter
|
|
||||||
///
|
|
||||||
const QString& BarcodeStyle::name() const
|
|
||||||
{
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Text Property Getter
|
|
||||||
///
|
|
||||||
bool BarcodeStyle::canText() const
|
|
||||||
{
|
|
||||||
return mCanText;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Text Optional Property Getter
|
|
||||||
///
|
|
||||||
bool BarcodeStyle::textOptional() const
|
|
||||||
{
|
|
||||||
return mTextOptional;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Checksum Property Getter
|
|
||||||
///
|
|
||||||
bool BarcodeStyle::canChecksum() const
|
|
||||||
{
|
|
||||||
return mCanChecksum;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Checksum Optional Property Getter
|
|
||||||
///
|
|
||||||
bool BarcodeStyle::checksumOptional() const
|
|
||||||
{
|
|
||||||
return mChecksumOptional;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Default Digits Property Getter
|
|
||||||
///
|
|
||||||
const QString& BarcodeStyle::defaultDigits() const
|
|
||||||
{
|
|
||||||
return mDefaultDigits;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Freeform Property Getter
|
|
||||||
///
|
|
||||||
bool BarcodeStyle::canFreeform() const
|
|
||||||
{
|
|
||||||
return mCanFreeform;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Prefered N Property Getter
|
|
||||||
///
|
|
||||||
int BarcodeStyle::preferedN() const
|
|
||||||
{
|
|
||||||
return mPreferedN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Generate Example Digits
|
|
||||||
///
|
|
||||||
QString BarcodeStyle::exampleDigits( int n ) const
|
|
||||||
{
|
|
||||||
if ( mCanFreeform )
|
|
||||||
{
|
{
|
||||||
return QString( qMax( n, 1 ), QChar('0') );
|
// empty
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// ID Property Getter
|
||||||
|
///
|
||||||
|
const QString& BarcodeStyle::id() const
|
||||||
|
{
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Backend ID Property Getter
|
||||||
|
///
|
||||||
|
const QString& BarcodeStyle::backendId() const
|
||||||
|
{
|
||||||
|
return mBackendId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Name Property Getter
|
||||||
|
///
|
||||||
|
const QString& BarcodeStyle::name() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Text Property Getter
|
||||||
|
///
|
||||||
|
bool BarcodeStyle::canText() const
|
||||||
|
{
|
||||||
|
return mCanText;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Text Optional Property Getter
|
||||||
|
///
|
||||||
|
bool BarcodeStyle::textOptional() const
|
||||||
|
{
|
||||||
|
return mTextOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Checksum Property Getter
|
||||||
|
///
|
||||||
|
bool BarcodeStyle::canChecksum() const
|
||||||
|
{
|
||||||
|
return mCanChecksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Checksum Optional Property Getter
|
||||||
|
///
|
||||||
|
bool BarcodeStyle::checksumOptional() const
|
||||||
|
{
|
||||||
|
return mChecksumOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default Digits Property Getter
|
||||||
|
///
|
||||||
|
const QString& BarcodeStyle::defaultDigits() const
|
||||||
{
|
{
|
||||||
return mDefaultDigits;
|
return mDefaultDigits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Freeform Property Getter
|
||||||
|
///
|
||||||
|
bool BarcodeStyle::canFreeform() const
|
||||||
|
{
|
||||||
|
return mCanFreeform;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Prefered N Property Getter
|
||||||
|
///
|
||||||
|
int BarcodeStyle::preferedN() const
|
||||||
|
{
|
||||||
|
return mPreferedN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Generate Example Digits
|
||||||
|
///
|
||||||
|
QString BarcodeStyle::exampleDigits( int n ) const
|
||||||
|
{
|
||||||
|
if ( mCanFreeform )
|
||||||
|
{
|
||||||
|
return QString( qMax( n, 1 ), QChar('0') );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mDefaultDigits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+57
-52
@@ -24,77 +24,82 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Barcode Style Type
|
|
||||||
///
|
|
||||||
struct BarcodeStyle
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Barcode Style Type
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
struct BarcodeStyle
|
||||||
BarcodeStyle ();
|
{
|
||||||
|
|
||||||
BarcodeStyle ( const QString& id,
|
/////////////////////////////////
|
||||||
const QString& backendId,
|
// Life Cycle
|
||||||
const QString& name,
|
/////////////////////////////////
|
||||||
bool canText,
|
public:
|
||||||
bool textOptional,
|
BarcodeStyle ();
|
||||||
bool canChecksum,
|
|
||||||
bool checksumOptional,
|
BarcodeStyle ( const QString& id,
|
||||||
const QString& defaultDigits,
|
const QString& backendId,
|
||||||
bool canFreeform,
|
const QString& name,
|
||||||
int preferedN );
|
bool canText,
|
||||||
|
bool textOptional,
|
||||||
|
bool canChecksum,
|
||||||
|
bool checksumOptional,
|
||||||
|
const QString& defaultDigits,
|
||||||
|
bool canFreeform,
|
||||||
|
int preferedN );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
const QString& id() const;
|
const QString& id() const;
|
||||||
|
|
||||||
const QString& backendId() const;
|
const QString& backendId() const;
|
||||||
|
|
||||||
const QString& name() const;
|
const QString& name() const;
|
||||||
|
|
||||||
bool canText() const;
|
bool canText() const;
|
||||||
|
|
||||||
bool textOptional() const;
|
bool textOptional() const;
|
||||||
|
|
||||||
bool canChecksum() const;
|
bool canChecksum() const;
|
||||||
|
|
||||||
bool checksumOptional() const;
|
bool checksumOptional() const;
|
||||||
|
|
||||||
const QString& defaultDigits() const;
|
const QString& defaultDigits() const;
|
||||||
|
|
||||||
bool canFreeform() const;
|
bool canFreeform() const;
|
||||||
|
|
||||||
int preferedN() const;
|
int preferedN() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Methods
|
// 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;
|
||||||
bool mCanText;
|
bool mCanText;
|
||||||
bool mTextOptional;
|
bool mTextOptional;
|
||||||
bool mCanChecksum;
|
bool mCanChecksum;
|
||||||
bool mChecksumOptional;
|
bool mChecksumOptional;
|
||||||
QString mDefaultDigits;
|
QString mDefaultDigits;
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+140
-129
@@ -28,148 +28,159 @@
|
|||||||
#include "ColorSwatch.h"
|
#include "ColorSwatch.h"
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
const int SWATCH_W = 64;
|
|
||||||
const int SWATCH_H = 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
ColorButton::ColorButton( QWidget* parent )
|
// Private
|
||||||
: QPushButton( parent )
|
//
|
||||||
{
|
namespace
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color )
|
|
||||||
{
|
|
||||||
mDefaultColor = defaultColor;
|
|
||||||
mColorNode = ColorNode( color );
|
|
||||||
|
|
||||||
setMinimumSize( QSize( 85, 34 ) );
|
|
||||||
setIconSize( QSize(SWATCH_W, SWATCH_H) );
|
|
||||||
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
|
||||||
setText( "" );
|
|
||||||
setCheckable( true );
|
|
||||||
|
|
||||||
mDialog = new ColorPaletteDialog( defaultLabel, defaultColor, color );
|
|
||||||
|
|
||||||
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
|
|
||||||
connect( mDialog, SIGNAL(colorChanged(ColorNode,bool)),
|
|
||||||
this, SLOT(onPaletteDialogChanged(ColorNode,bool)) );
|
|
||||||
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
|
|
||||||
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setColorNode( ColorNode colorNode )
|
|
||||||
{
|
|
||||||
mIsDefault = false;
|
|
||||||
|
|
||||||
mColorNode = colorNode;
|
|
||||||
|
|
||||||
if ( colorNode.isField() )
|
|
||||||
{
|
{
|
||||||
setIcon( QIcon() );
|
const int SWATCH_W = 64;
|
||||||
setText( QString("${%1}").arg( colorNode.key() ) );
|
const int SWATCH_H = 24;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
ColorButton::ColorButton( QWidget* parent )
|
||||||
|
: QPushButton( parent )
|
||||||
{
|
{
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::init( const QString& defaultLabel,
|
||||||
|
const QColor& defaultColor,
|
||||||
|
const QColor& color )
|
||||||
|
{
|
||||||
|
mDefaultColor = defaultColor;
|
||||||
|
mColorNode = ColorNode( color );
|
||||||
|
|
||||||
|
setMinimumSize( QSize( 85, 34 ) );
|
||||||
|
setIconSize( QSize(SWATCH_W, SWATCH_H) );
|
||||||
|
|
||||||
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
||||||
|
setText( "" );
|
||||||
|
setCheckable( true );
|
||||||
|
|
||||||
|
mDialog = new ColorPaletteDialog( defaultLabel, defaultColor, color );
|
||||||
|
|
||||||
|
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
|
||||||
|
connect( mDialog, SIGNAL(colorChanged(ColorNode,bool)),
|
||||||
|
this, SLOT(onPaletteDialogChanged(ColorNode,bool)) );
|
||||||
|
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
|
||||||
|
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::setColorNode( ColorNode colorNode )
|
||||||
|
{
|
||||||
|
mIsDefault = false;
|
||||||
|
|
||||||
|
mColorNode = colorNode;
|
||||||
|
|
||||||
|
if ( colorNode.isField() )
|
||||||
|
{
|
||||||
|
setIcon( QIcon() );
|
||||||
|
setText( QString("${%1}").arg( colorNode.key() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
||||||
|
setText( "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
mDialog->setColorNode( colorNode );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::setColor( QColor color )
|
||||||
|
{
|
||||||
|
mIsDefault = false;
|
||||||
|
|
||||||
|
mColorNode.setField( false );
|
||||||
|
mColorNode.setColor( color );
|
||||||
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
||||||
setText( "" );
|
setText( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
mDialog->setColorNode( colorNode );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void ColorButton::setToDefault()
|
||||||
void ColorButton::setColor( QColor color )
|
|
||||||
{
|
|
||||||
mIsDefault = false;
|
|
||||||
|
|
||||||
mColorNode.setField( false );
|
|
||||||
mColorNode.setColor( color );
|
|
||||||
mColorNode.setKey( "" );
|
|
||||||
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
|
||||||
setText( "" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setToDefault()
|
|
||||||
{
|
|
||||||
mIsDefault = true;
|
|
||||||
|
|
||||||
mColorNode.setField( false );
|
|
||||||
mColorNode.setColor( mDefaultColor );
|
|
||||||
mColorNode.setKey( "" );
|
|
||||||
|
|
||||||
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
|
|
||||||
setText( "" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ColorNode ColorButton::colorNode()
|
|
||||||
{
|
|
||||||
return mColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setKeys( const QList<QString> keyList )
|
|
||||||
{
|
|
||||||
mDialog->setKeys( keyList );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::clearKeys()
|
|
||||||
{
|
|
||||||
mDialog->clearKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onButtonToggled( bool checked )
|
|
||||||
{
|
|
||||||
if ( checked )
|
|
||||||
{
|
{
|
||||||
///
|
mIsDefault = true;
|
||||||
/// @TODO: improve positioning of dialog -- near edges of screen.
|
|
||||||
///
|
|
||||||
QPoint dialogPos( 0, height() );
|
|
||||||
mDialog->move( mapToGlobal(dialogPos) );
|
|
||||||
|
|
||||||
mDialog->show();
|
mColorNode.setField( false );
|
||||||
}
|
mColorNode.setColor( mDefaultColor );
|
||||||
}
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
|
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
|
||||||
void ColorButton::onPaletteDialogAccepted()
|
|
||||||
{
|
|
||||||
setChecked( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onPaletteDialogRejected()
|
|
||||||
{
|
|
||||||
setChecked( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
|
||||||
{
|
|
||||||
mColorNode = colorNode;
|
|
||||||
mIsDefault = isDefault;
|
|
||||||
|
|
||||||
if ( colorNode.isField() )
|
|
||||||
{
|
|
||||||
setIcon( QIcon() );
|
|
||||||
setText( QString("${%1}").arg( colorNode.key() ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
|
||||||
setText( "" );
|
setText( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
emit colorChanged();
|
|
||||||
|
ColorNode ColorButton::colorNode()
|
||||||
|
{
|
||||||
|
return mColorNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::setKeys( const QList<QString> keyList )
|
||||||
|
{
|
||||||
|
mDialog->setKeys( keyList );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::clearKeys()
|
||||||
|
{
|
||||||
|
mDialog->clearKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::onButtonToggled( bool checked )
|
||||||
|
{
|
||||||
|
if ( checked )
|
||||||
|
{
|
||||||
|
///
|
||||||
|
/// @TODO: improve positioning of dialog -- near edges of screen.
|
||||||
|
///
|
||||||
|
QPoint dialogPos( 0, height() );
|
||||||
|
mDialog->move( mapToGlobal(dialogPos) );
|
||||||
|
|
||||||
|
mDialog->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::onPaletteDialogAccepted()
|
||||||
|
{
|
||||||
|
setChecked( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::onPaletteDialogRejected()
|
||||||
|
{
|
||||||
|
setChecked( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
||||||
|
{
|
||||||
|
mColorNode = colorNode;
|
||||||
|
mIsDefault = isDefault;
|
||||||
|
|
||||||
|
if ( colorNode.isField() )
|
||||||
|
{
|
||||||
|
setIcon( QIcon() );
|
||||||
|
setText( QString("${%1}").arg( colorNode.key() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
||||||
|
setText( "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+52
-47
@@ -28,67 +28,72 @@
|
|||||||
#include "ColorPaletteDialog.h"
|
#include "ColorPaletteDialog.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Button
|
|
||||||
///
|
|
||||||
class ColorButton : public QPushButton
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
///
|
||||||
|
/// Color Button
|
||||||
|
///
|
||||||
|
class ColorButton : public QPushButton
|
||||||
|
{
|
||||||
|
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 );
|
||||||
void setToDefault();
|
void setToDefault();
|
||||||
ColorNode colorNode();
|
ColorNode colorNode();
|
||||||
void setKeys( const QList<QString> keyList );
|
void setKeys( const QList<QString> keyList );
|
||||||
void clearKeys();
|
void clearKeys();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onButtonToggled( bool checked );
|
void onButtonToggled( bool checked );
|
||||||
void onPaletteDialogAccepted();
|
void onPaletteDialogAccepted();
|
||||||
void onPaletteDialogRejected();
|
void onPaletteDialogRejected();
|
||||||
void onPaletteDialogChanged( ColorNode colorNode, bool isDefault );
|
void onPaletteDialogChanged( ColorNode colorNode, bool isDefault );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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
|
||||||
|
|||||||
+71
-65
@@ -25,89 +25,95 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
ColorHistory::ColorHistory()
|
namespace glabels
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
|
ColorHistory::ColorHistory()
|
||||||
ColorHistory* ColorHistory::instance()
|
|
||||||
{
|
|
||||||
static ColorHistory* singletonInstance = 0;
|
|
||||||
|
|
||||||
if ( singletonInstance == 0 )
|
|
||||||
{
|
{
|
||||||
singletonInstance = new ColorHistory();
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
return singletonInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ColorHistory* ColorHistory::instance()
|
||||||
void ColorHistory::addColor( const QColor &color )
|
|
||||||
{
|
|
||||||
QList<QColor> colorList = readColorList();
|
|
||||||
|
|
||||||
// Remove any occurances of this color already in list
|
|
||||||
colorList.removeAll( color );
|
|
||||||
|
|
||||||
// Now add to list
|
|
||||||
colorList.append( color );
|
|
||||||
|
|
||||||
// Remove oldest colors, if size exceeds current max
|
|
||||||
while ( colorList.size() > MAX_COLORS )
|
|
||||||
{
|
{
|
||||||
colorList.removeFirst();
|
static ColorHistory* singletonInstance = 0;
|
||||||
|
|
||||||
|
if ( singletonInstance == 0 )
|
||||||
|
{
|
||||||
|
singletonInstance = new ColorHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
return singletonInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeColorList( colorList );
|
|
||||||
|
|
||||||
emit changed();
|
void ColorHistory::addColor( const QColor &color )
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<QColor> ColorHistory::getColors()
|
|
||||||
{
|
|
||||||
return readColorList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<QColor> ColorHistory::readColorList()
|
|
||||||
{
|
|
||||||
QStringList defaultList;
|
|
||||||
QSettings settings;
|
|
||||||
|
|
||||||
settings.beginGroup( "ColorHistory" );
|
|
||||||
QStringList colorNameList = settings.value( "colors", defaultList ).toStringList();
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
QList<QColor> colorList;
|
|
||||||
foreach ( QString colorName, colorNameList )
|
|
||||||
{
|
{
|
||||||
colorList << QColor( colorName );
|
QList<QColor> colorList = readColorList();
|
||||||
|
|
||||||
|
// Remove any occurances of this color already in list
|
||||||
|
colorList.removeAll( color );
|
||||||
|
|
||||||
|
// Now add to list
|
||||||
|
colorList.append( color );
|
||||||
|
|
||||||
|
// Remove oldest colors, if size exceeds current max
|
||||||
|
while ( colorList.size() > MAX_COLORS )
|
||||||
|
{
|
||||||
|
colorList.removeFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
writeColorList( colorList );
|
||||||
|
|
||||||
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove oldest colors, if size exceeds current max
|
|
||||||
while ( colorList.size() > MAX_COLORS )
|
QList<QColor> ColorHistory::getColors()
|
||||||
{
|
{
|
||||||
colorList.removeFirst();
|
return readColorList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return colorList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
QList<QColor> ColorHistory::readColorList()
|
||||||
void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
|
||||||
{
|
|
||||||
// Build name list
|
|
||||||
QStringList colorNameList;
|
|
||||||
foreach ( QColor color, colorList )
|
|
||||||
{
|
{
|
||||||
colorNameList << color.name();
|
QStringList defaultList;
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.beginGroup( "ColorHistory" );
|
||||||
|
QStringList colorNameList = settings.value( "colors", defaultList ).toStringList();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
QList<QColor> colorList;
|
||||||
|
foreach ( QString colorName, colorNameList )
|
||||||
|
{
|
||||||
|
colorList << QColor( colorName );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove oldest colors, if size exceeds current max
|
||||||
|
while ( colorList.size() > MAX_COLORS )
|
||||||
|
{
|
||||||
|
colorList.removeFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
return colorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorHistory::writeColorList( const QList<QColor>& colorList )
|
||||||
|
{
|
||||||
|
// Build name list
|
||||||
|
QStringList colorNameList;
|
||||||
|
foreach ( QColor color, colorList )
|
||||||
|
{
|
||||||
|
colorNameList << color.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save
|
||||||
|
QSettings settings;
|
||||||
|
settings.beginGroup( "ColorHistory" );
|
||||||
|
settings.setValue( "colors", colorNameList );
|
||||||
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save
|
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup( "ColorHistory" );
|
|
||||||
settings.setValue( "colors", colorNameList );
|
|
||||||
settings.endGroup();
|
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-36
@@ -26,55 +26,60 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color History
|
|
||||||
///
|
|
||||||
class ColorHistory : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
///
|
||||||
static const int MAX_COLORS = 9;
|
/// Color History
|
||||||
|
///
|
||||||
|
class ColorHistory : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
public:
|
||||||
// Life Cycle
|
static const int MAX_COLORS = 9;
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
ColorHistory();
|
|
||||||
|
|
||||||
public:
|
/////////////////////////////////
|
||||||
static ColorHistory* instance();
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
ColorHistory();
|
||||||
|
|
||||||
|
public:
|
||||||
|
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();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Methods
|
// Private Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QList<QColor> readColorList();
|
QList<QColor> readColorList();
|
||||||
void writeColorList( const QList<QColor>& colorList );
|
void writeColorList( const QList<QColor>& colorList );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorHistory_h
|
#endif // ColorHistory_h
|
||||||
|
|||||||
+169
-160
@@ -24,171 +24,180 @@
|
|||||||
#include "Merge/Record.h"
|
#include "Merge/Record.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Default Constructor
|
|
||||||
///
|
|
||||||
ColorNode::ColorNode()
|
|
||||||
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Default Constructor
|
||||||
/// Constructor From Data
|
///
|
||||||
///
|
ColorNode::ColorNode()
|
||||||
ColorNode::ColorNode( bool isField, const QColor& color, const QString& key )
|
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
|
||||||
: mIsField(isField), mColor(color), mKey(key)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor From Data
|
|
||||||
///
|
|
||||||
ColorNode::ColorNode( bool isField, uint32_t rgba, const QString& key )
|
|
||||||
: mIsField(isField), mKey(key)
|
|
||||||
{
|
|
||||||
mColor = QColor( (rgba >> 24) & 0xFF,
|
|
||||||
(rgba >> 16) & 0xFF,
|
|
||||||
(rgba >> 8) & 0xFF,
|
|
||||||
(rgba ) & 0xFF );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor From Color
|
|
||||||
///
|
|
||||||
ColorNode::ColorNode( const QColor& color )
|
|
||||||
: mIsField(false), mColor(color), mKey("")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor From Key
|
|
||||||
///
|
|
||||||
ColorNode::ColorNode( const QString& key )
|
|
||||||
: mIsField(true), mColor(QColor::fromRgba(0x00000000)), mKey(key)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// == Operator
|
|
||||||
///
|
|
||||||
bool ColorNode::operator==( const ColorNode& cn )
|
|
||||||
{
|
|
||||||
return (mIsField == cn.mIsField) &&
|
|
||||||
(mColor == cn.mColor) &&
|
|
||||||
(mKey == cn.mKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// != Operator
|
|
||||||
///
|
|
||||||
bool ColorNode::operator!=( const ColorNode& cn )
|
|
||||||
{
|
|
||||||
return (mIsField != cn.mIsField) ||
|
|
||||||
(mColor != cn.mColor) ||
|
|
||||||
(mKey != cn.mKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Field Flag Property Getter
|
|
||||||
///
|
|
||||||
bool ColorNode::isField() const
|
|
||||||
{
|
|
||||||
return mIsField;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Field Flag Property Setter
|
|
||||||
///
|
|
||||||
void ColorNode::setField( bool isField )
|
|
||||||
{
|
|
||||||
mIsField = isField;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Color Property Getter
|
|
||||||
///
|
|
||||||
const QColor& ColorNode::color() const
|
|
||||||
{
|
|
||||||
return mColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Color Property Setter
|
|
||||||
///
|
|
||||||
void ColorNode::setColor( const QColor& color )
|
|
||||||
{
|
|
||||||
mColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Key Property Getter
|
|
||||||
///
|
|
||||||
const QString& ColorNode::key() const
|
|
||||||
{
|
|
||||||
return mKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Key Property Setter
|
|
||||||
///
|
|
||||||
void ColorNode::setKey( const QString& key )
|
|
||||||
{
|
|
||||||
mKey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get color encoded as an RGBA 32-bit number
|
|
||||||
///
|
|
||||||
uint32_t ColorNode::rgba() const
|
|
||||||
{
|
|
||||||
uint32_t c =
|
|
||||||
mColor.red() << 24 |
|
|
||||||
mColor.green() << 16 |
|
|
||||||
mColor.blue() << 8 |
|
|
||||||
mColor.alpha();
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get color, expand if necessary
|
|
||||||
///
|
|
||||||
QColor ColorNode::color( merge::Record* record ) const
|
|
||||||
{
|
|
||||||
if ( mIsField )
|
|
||||||
{
|
{
|
||||||
if ( record == 0 )
|
// empty
|
||||||
{
|
|
||||||
return mColor;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( record->contains( mKey ) )
|
|
||||||
{
|
|
||||||
return QColor( (*record)[ mKey ] );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return mColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor From Data
|
||||||
|
///
|
||||||
|
ColorNode::ColorNode( bool isField, const QColor& color, const QString& key )
|
||||||
|
: mIsField(isField), mColor(color), mKey(key)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor From Data
|
||||||
|
///
|
||||||
|
ColorNode::ColorNode( bool isField, uint32_t rgba, const QString& key )
|
||||||
|
: mIsField(isField), mKey(key)
|
||||||
|
{
|
||||||
|
mColor = QColor( (rgba >> 24) & 0xFF,
|
||||||
|
(rgba >> 16) & 0xFF,
|
||||||
|
(rgba >> 8) & 0xFF,
|
||||||
|
(rgba ) & 0xFF );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor From Color
|
||||||
|
///
|
||||||
|
ColorNode::ColorNode( const QColor& color )
|
||||||
|
: mIsField(false), mColor(color), mKey("")
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor From Key
|
||||||
|
///
|
||||||
|
ColorNode::ColorNode( const QString& key )
|
||||||
|
: mIsField(true), mColor(QColor::fromRgba(0x00000000)), mKey(key)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// == Operator
|
||||||
|
///
|
||||||
|
bool ColorNode::operator==( const ColorNode& cn )
|
||||||
|
{
|
||||||
|
return (mIsField == cn.mIsField) &&
|
||||||
|
(mColor == cn.mColor) &&
|
||||||
|
(mKey == cn.mKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// != Operator
|
||||||
|
///
|
||||||
|
bool ColorNode::operator!=( const ColorNode& cn )
|
||||||
|
{
|
||||||
|
return (mIsField != cn.mIsField) ||
|
||||||
|
(mColor != cn.mColor) ||
|
||||||
|
(mKey != cn.mKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Field Flag Property Getter
|
||||||
|
///
|
||||||
|
bool ColorNode::isField() const
|
||||||
|
{
|
||||||
|
return mIsField;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Field Flag Property Setter
|
||||||
|
///
|
||||||
|
void ColorNode::setField( bool isField )
|
||||||
|
{
|
||||||
|
mIsField = isField;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Property Getter
|
||||||
|
///
|
||||||
|
const QColor& ColorNode::color() const
|
||||||
{
|
{
|
||||||
return mColor;
|
return mColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Property Setter
|
||||||
|
///
|
||||||
|
void ColorNode::setColor( const QColor& color )
|
||||||
|
{
|
||||||
|
mColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Key Property Getter
|
||||||
|
///
|
||||||
|
const QString& ColorNode::key() const
|
||||||
|
{
|
||||||
|
return mKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Key Property Setter
|
||||||
|
///
|
||||||
|
void ColorNode::setKey( const QString& key )
|
||||||
|
{
|
||||||
|
mKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get color encoded as an RGBA 32-bit number
|
||||||
|
///
|
||||||
|
uint32_t ColorNode::rgba() const
|
||||||
|
{
|
||||||
|
uint32_t c =
|
||||||
|
mColor.red() << 24 |
|
||||||
|
mColor.green() << 16 |
|
||||||
|
mColor.blue() << 8 |
|
||||||
|
mColor.alpha();
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get color, expand if necessary
|
||||||
|
///
|
||||||
|
QColor ColorNode::color( merge::Record* record ) const
|
||||||
|
{
|
||||||
|
if ( mIsField )
|
||||||
|
{
|
||||||
|
if ( record == 0 )
|
||||||
|
{
|
||||||
|
return mColor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( record->contains( mKey ) )
|
||||||
|
{
|
||||||
|
return QColor( (*record)[ mKey ] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+57
-52
@@ -30,78 +30,83 @@
|
|||||||
#include "Merge/Record.h"
|
#include "Merge/Record.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Node Type
|
|
||||||
///
|
|
||||||
struct ColorNode
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Color Node Type
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
struct ColorNode
|
||||||
ColorNode();
|
{
|
||||||
|
|
||||||
ColorNode( bool isField, const QColor& color, const QString& key );
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
ColorNode();
|
||||||
|
|
||||||
ColorNode( bool isField, uint32_t rgba, const QString& key );
|
ColorNode( bool isField, const QColor& color, const QString& key );
|
||||||
|
|
||||||
ColorNode( const QColor& color );
|
ColorNode( bool isField, uint32_t rgba, const QString& key );
|
||||||
|
|
||||||
ColorNode( const QString& key );
|
ColorNode( const QColor& color );
|
||||||
|
|
||||||
|
ColorNode( const QString& key );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Operators
|
// Operators
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool operator==( const ColorNode& cn );
|
bool operator==( const ColorNode& cn );
|
||||||
|
|
||||||
bool operator!=( const ColorNode& cn );
|
bool operator!=( const ColorNode& cn );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Field Flag Property
|
// Field Flag Property
|
||||||
//
|
//
|
||||||
bool isField() const;
|
bool isField() const;
|
||||||
void setField( bool isField );
|
void setField( bool isField );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Color Property
|
// Color Property
|
||||||
//
|
//
|
||||||
const QColor& color() const;
|
const QColor& color() const;
|
||||||
void setColor( const QColor& color );
|
void setColor( const QColor& color );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Key Property
|
// Key Property
|
||||||
//
|
//
|
||||||
const QString& key() const;
|
const QString& key() const;
|
||||||
void setKey( const QString& key );
|
void setKey( const QString& key );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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,96 +25,101 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
//
|
namespace glabels
|
||||||
// Private Configuration Data
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
const int border = 4;
|
|
||||||
const int hBox = 25;
|
|
||||||
const int outlineWidthPixels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor From Data
|
|
||||||
///
|
|
||||||
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
|
|
||||||
: QWidget(parent), mText(text), mHover(false)
|
|
||||||
{
|
|
||||||
setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
|
|
||||||
setMinimumSize( hBox+2*border+1, hBox+2*border+1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Paint Event
|
|
||||||
///
|
|
||||||
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
|
||||||
{
|
|
||||||
QPainter painter(this);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw background
|
// Private
|
||||||
//
|
//
|
||||||
if ( isEnabled() && mHover )
|
namespace
|
||||||
{
|
{
|
||||||
QLinearGradient gradient( 0, 0, 0, height() );
|
const int border = 4;
|
||||||
gradient.setColorAt( 0, palette().color( QPalette::Highlight ).lighter() );
|
const int hBox = 25;
|
||||||
gradient.setColorAt( 1, palette().color( QPalette::Highlight ) );
|
const int outlineWidthPixels = 1;
|
||||||
painter.setBrush( QBrush( gradient ) );
|
|
||||||
|
|
||||||
QPen pen( palette().color( QPalette::Text ) );
|
|
||||||
pen.setWidth( outlineWidthPixels );
|
|
||||||
painter.setPen( pen );
|
|
||||||
|
|
||||||
painter.drawRect( 0, 0, width()-1, height()-1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Draw text
|
|
||||||
//
|
|
||||||
painter.setBrush( QBrush( Qt::NoBrush ) );
|
|
||||||
|
|
||||||
if ( isEnabled() && mHover )
|
///
|
||||||
|
/// Constructor From Data
|
||||||
|
///
|
||||||
|
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
|
||||||
|
: QWidget(parent), mText(text), mHover(false)
|
||||||
{
|
{
|
||||||
painter.setPen( QPen( palette().color( QPalette::HighlightedText ) ) );
|
setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
|
||||||
}
|
setMinimumSize( hBox+2*border+1, hBox+2*border+1 );
|
||||||
else
|
|
||||||
{
|
|
||||||
painter.setPen( QPen( palette().color( QPalette::Text ) ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect textRect( border, border, width()-2*border, hBox );
|
|
||||||
|
|
||||||
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
|
///
|
||||||
}
|
/// Paint Event
|
||||||
|
///
|
||||||
|
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
||||||
///
|
{
|
||||||
/// Enter Event
|
QPainter painter(this);
|
||||||
///
|
|
||||||
void ColorPaletteButtonItem::enterEvent( QEvent* event )
|
//
|
||||||
{
|
// Draw background
|
||||||
mHover = true;
|
//
|
||||||
update();
|
if ( isEnabled() && mHover )
|
||||||
}
|
{
|
||||||
|
QLinearGradient gradient( 0, 0, 0, height() );
|
||||||
|
gradient.setColorAt( 0, palette().color( QPalette::Highlight ).lighter() );
|
||||||
///
|
gradient.setColorAt( 1, palette().color( QPalette::Highlight ) );
|
||||||
/// Leave Event
|
painter.setBrush( QBrush( gradient ) );
|
||||||
///
|
|
||||||
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
|
QPen pen( palette().color( QPalette::Text ) );
|
||||||
{
|
pen.setWidth( outlineWidthPixels );
|
||||||
mHover = false;
|
painter.setPen( pen );
|
||||||
update();
|
|
||||||
}
|
painter.drawRect( 0, 0, width()-1, height()-1 );
|
||||||
|
}
|
||||||
|
|
||||||
///
|
//
|
||||||
/// Mouse Press Event
|
// Draw text
|
||||||
///
|
//
|
||||||
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
|
painter.setBrush( QBrush( Qt::NoBrush ) );
|
||||||
{
|
|
||||||
emit activated();
|
if ( isEnabled() && mHover )
|
||||||
|
{
|
||||||
|
painter.setPen( QPen( palette().color( QPalette::HighlightedText ) ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
painter.setPen( QPen( palette().color( QPalette::Text ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect textRect( border, border, width()-2*border, hBox );
|
||||||
|
|
||||||
|
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Enter Event
|
||||||
|
///
|
||||||
|
void ColorPaletteButtonItem::enterEvent( QEvent* event )
|
||||||
|
{
|
||||||
|
mHover = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Leave Event
|
||||||
|
///
|
||||||
|
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
|
||||||
|
{
|
||||||
|
mHover = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Mouse Press Event
|
||||||
|
///
|
||||||
|
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
|
||||||
|
{
|
||||||
|
emit activated();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,45 +26,50 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Palette Item
|
|
||||||
///
|
|
||||||
class ColorPaletteButtonItem : public QWidget
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Color Palette Item
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class ColorPaletteButtonItem : public QWidget
|
||||||
ColorPaletteButtonItem( const QString& text, QWidget* parent = 0 );
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
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 );
|
||||||
void mousePressEvent( QMouseEvent* event );
|
void mousePressEvent( QMouseEvent* event );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QString mText;
|
QString mText;
|
||||||
|
|
||||||
bool mHover;
|
bool mHover;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorPaletteButtonItem_h
|
#endif // ColorPaletteButtonItem_h
|
||||||
|
|||||||
+253
-244
@@ -30,289 +30,298 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
namespace glabels
|
||||||
|
|
||||||
{ "#ef2929", tr("Light Scarlet Red", "Color name") },
|
|
||||||
{ "#fcaf3e", tr("Light Orange", "Color name") },
|
|
||||||
{ "#fce94f", tr("Light Butter", "Color name") },
|
|
||||||
{ "#8ae234", tr("Light Chameleon", "Color name") },
|
|
||||||
{ "#729fcf", tr("Light Sky Blue", "Color name") },
|
|
||||||
{ "#ad7fa8", tr("Light Plum", "Color name") },
|
|
||||||
{ "#e9b96e", tr("Light Chocolate", "Color name") },
|
|
||||||
{ "#888a85", tr("Light Aluminum 1", "Color name") },
|
|
||||||
{ "#eeeeec", tr("Light Aluminum 2", "Color name") },
|
|
||||||
|
|
||||||
{ "#cc0000", tr("Scarlet Red", "Color name") },
|
|
||||||
{ "#f57900", tr("Orange", "Color name") },
|
|
||||||
{ "#edd400", tr("Butter", "Color name") },
|
|
||||||
{ "#73d216", tr("Chameleon", "Color name") },
|
|
||||||
{ "#3465a4", tr("Sky Blue", "Color name") },
|
|
||||||
{ "#75507b", tr("Plum", "Color name") },
|
|
||||||
{ "#c17d11", tr("Chocolate", "Color name") },
|
|
||||||
{ "#555753", tr("Aluminum 1", "Color name") },
|
|
||||||
{ "#d3d7cf", tr("Aluminum 2", "Color name") },
|
|
||||||
|
|
||||||
{ "#a40000", tr("Dark Scarlet Red", "Color name") },
|
|
||||||
{ "#ce5c00", tr("Dark Orange", "Color name") },
|
|
||||||
{ "#c4a000", tr("Dark Butter", "Color name") },
|
|
||||||
{ "#4e9a06", tr("Dark Chameleon", "Color name") },
|
|
||||||
{ "#204a87", tr("Dark Sky Blue", "Color name") },
|
|
||||||
{ "#5c3566", tr("Dark Plum", "Color name") },
|
|
||||||
{ "#8f5902", tr("Dark Chocolate", "Color name") },
|
|
||||||
{ "#2e3436", tr("Dark Aluminum 1", "Color name") },
|
|
||||||
{ "#babdb6", tr("Dark Aluminum 2", "Color name") },
|
|
||||||
|
|
||||||
{ "#000000", tr("Black", "Color name") },
|
|
||||||
{ "#2e3436", tr("Very Dark Gray", "Color name") },
|
|
||||||
{ "#555753", tr("Darker Gray", "Color name") },
|
|
||||||
{ "#888a85", tr("Dark Gray", "Color name") },
|
|
||||||
{ "#babdb6", tr("Medium Gray", "Color name") },
|
|
||||||
{ "#d3d7cf", tr("Light Gray", "Color name") },
|
|
||||||
{ "#eeeeec", tr("Lighter Gray", "Color name") },
|
|
||||||
{ "#f3f3f3", tr("Very Light Gray", "Color name") },
|
|
||||||
{ "#ffffff", tr("White", "Color name") }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
|
||||||
const QColor& defaultColor,
|
|
||||||
const QColor& color,
|
|
||||||
QWidget* parent )
|
|
||||||
: QDialog( parent )
|
|
||||||
{
|
{
|
||||||
mColorHistory = ColorHistory::instance();
|
|
||||||
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
|
|
||||||
|
|
||||||
mDefaultColor = defaultColor;
|
//
|
||||||
mColorNode = ColorNode( color );
|
// Static data
|
||||||
|
//
|
||||||
|
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
||||||
|
|
||||||
setStyleSheet( ".glabels--ColorPaletteDialog {background: white; border: 1px solid black}" );
|
{ "#ef2929", tr("Light Scarlet Red", "Color name") },
|
||||||
setWindowFlags( Qt::Popup | Qt::FramelessWindowHint );
|
{ "#fcaf3e", tr("Light Orange", "Color name") },
|
||||||
|
{ "#fce94f", tr("Light Butter", "Color name") },
|
||||||
|
{ "#8ae234", tr("Light Chameleon", "Color name") },
|
||||||
|
{ "#729fcf", tr("Light Sky Blue", "Color name") },
|
||||||
|
{ "#ad7fa8", tr("Light Plum", "Color name") },
|
||||||
|
{ "#e9b96e", tr("Light Chocolate", "Color name") },
|
||||||
|
{ "#888a85", tr("Light Aluminum 1", "Color name") },
|
||||||
|
{ "#eeeeec", tr("Light Aluminum 2", "Color name") },
|
||||||
|
|
||||||
QVBoxLayout* vLayout = new QVBoxLayout();
|
{ "#cc0000", tr("Scarlet Red", "Color name") },
|
||||||
vLayout->setContentsMargins( 0, 0, 0, 0 );
|
{ "#f57900", tr("Orange", "Color name") },
|
||||||
vLayout->setSpacing( 0 );
|
{ "#edd400", tr("Butter", "Color name") },
|
||||||
|
{ "#73d216", tr("Chameleon", "Color name") },
|
||||||
|
{ "#3465a4", tr("Sky Blue", "Color name") },
|
||||||
|
{ "#75507b", tr("Plum", "Color name") },
|
||||||
|
{ "#c17d11", tr("Chocolate", "Color name") },
|
||||||
|
{ "#555753", tr("Aluminum 1", "Color name") },
|
||||||
|
{ "#d3d7cf", tr("Aluminum 2", "Color name") },
|
||||||
|
|
||||||
ColorPaletteButtonItem* defaultButton = new ColorPaletteButtonItem( defaultLabel );
|
{ "#a40000", tr("Dark Scarlet Red", "Color name") },
|
||||||
connect( defaultButton, SIGNAL(activated()), this, SLOT(onDefaultItemActivated()) );
|
{ "#ce5c00", tr("Dark Orange", "Color name") },
|
||||||
vLayout->addWidget( defaultButton );
|
{ "#c4a000", tr("Dark Butter", "Color name") },
|
||||||
|
{ "#4e9a06", tr("Dark Chameleon", "Color name") },
|
||||||
|
{ "#204a87", tr("Dark Sky Blue", "Color name") },
|
||||||
|
{ "#5c3566", tr("Dark Plum", "Color name") },
|
||||||
|
{ "#8f5902", tr("Dark Chocolate", "Color name") },
|
||||||
|
{ "#2e3436", tr("Dark Aluminum 1", "Color name") },
|
||||||
|
{ "#babdb6", tr("Dark Aluminum 2", "Color name") },
|
||||||
|
|
||||||
QFrame* hline1 = new QFrame;
|
{ "#000000", tr("Black", "Color name") },
|
||||||
hline1->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
{ "#2e3436", tr("Very Dark Gray", "Color name") },
|
||||||
hline1->setLineWidth( 1 );
|
{ "#555753", tr("Darker Gray", "Color name") },
|
||||||
vLayout->addWidget( hline1 );
|
{ "#888a85", tr("Dark Gray", "Color name") },
|
||||||
|
{ "#babdb6", tr("Medium Gray", "Color name") },
|
||||||
|
{ "#d3d7cf", tr("Light Gray", "Color name") },
|
||||||
|
{ "#eeeeec", tr("Lighter Gray", "Color name") },
|
||||||
|
{ "#f3f3f3", tr("Very Light Gray", "Color name") },
|
||||||
|
{ "#ffffff", tr("White", "Color name") }
|
||||||
|
|
||||||
QGridLayout* mainPaletteLayout = new QGridLayout();
|
};
|
||||||
mainPaletteLayout->setSpacing( 0 );
|
|
||||||
for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ )
|
|
||||||
|
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
||||||
|
const QColor& defaultColor,
|
||||||
|
const QColor& color,
|
||||||
|
QWidget* parent )
|
||||||
|
: QDialog( parent )
|
||||||
{
|
{
|
||||||
|
mColorHistory = ColorHistory::instance();
|
||||||
|
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
|
||||||
|
|
||||||
|
mDefaultColor = defaultColor;
|
||||||
|
mColorNode = ColorNode( color );
|
||||||
|
|
||||||
|
setStyleSheet( ".glabels--ColorPaletteDialog {background: white; border: 1px solid black}" );
|
||||||
|
setWindowFlags( Qt::Popup | Qt::FramelessWindowHint );
|
||||||
|
|
||||||
|
QVBoxLayout* vLayout = new QVBoxLayout();
|
||||||
|
vLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
vLayout->setSpacing( 0 );
|
||||||
|
|
||||||
|
ColorPaletteButtonItem* defaultButton = new ColorPaletteButtonItem( defaultLabel );
|
||||||
|
connect( defaultButton, SIGNAL(activated()), this, SLOT(onDefaultItemActivated()) );
|
||||||
|
vLayout->addWidget( defaultButton );
|
||||||
|
|
||||||
|
QFrame* hline1 = new QFrame;
|
||||||
|
hline1->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
||||||
|
hline1->setLineWidth( 1 );
|
||||||
|
vLayout->addWidget( hline1 );
|
||||||
|
|
||||||
|
QGridLayout* mainPaletteLayout = new QGridLayout();
|
||||||
|
mainPaletteLayout->setSpacing( 0 );
|
||||||
|
for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ )
|
||||||
|
{
|
||||||
|
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
||||||
|
{
|
||||||
|
int i = iRow*PALETTE_COLS + iCol;
|
||||||
|
|
||||||
|
ColorPaletteItem* item = new ColorPaletteItem( i,
|
||||||
|
QColor( mColorTable[i].colorSpec ),
|
||||||
|
mColorTable[i].name );
|
||||||
|
connect( item, SIGNAL(activated(int)), this, SLOT(onPaletteItemActivated(int)) );
|
||||||
|
|
||||||
|
mainPaletteLayout->addWidget( item, iRow, iCol );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vLayout->addLayout( mainPaletteLayout );
|
||||||
|
|
||||||
|
QFrame* hline2 = new QFrame;
|
||||||
|
hline2->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
||||||
|
hline2->setLineWidth( 1 );
|
||||||
|
vLayout->addWidget( hline2 );
|
||||||
|
|
||||||
|
QHBoxLayout* customPaletteLayout = new QHBoxLayout();
|
||||||
|
customPaletteLayout->setSpacing( 0 );
|
||||||
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
||||||
{
|
{
|
||||||
int i = iRow*PALETTE_COLS + iCol;
|
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
|
||||||
|
mHistoryItem[iCol]->setEnabled( false );
|
||||||
|
connect( mHistoryItem[iCol], SIGNAL(activated(int)), this, SLOT(onHistoryItemActivated(int)) );
|
||||||
|
|
||||||
ColorPaletteItem* item = new ColorPaletteItem( i,
|
customPaletteLayout->addWidget( mHistoryItem[iCol] );
|
||||||
QColor( mColorTable[i].colorSpec ),
|
}
|
||||||
mColorTable[i].name );
|
vLayout->addLayout( customPaletteLayout );
|
||||||
connect( item, SIGNAL(activated(int)), this, SLOT(onPaletteItemActivated(int)) );
|
|
||||||
|
|
||||||
mainPaletteLayout->addWidget( item, iRow, iCol );
|
|
||||||
|
QFrame* hline3 = new QFrame;
|
||||||
|
hline3->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
||||||
|
hline3->setLineWidth( 1 );
|
||||||
|
vLayout->addWidget( hline3 );
|
||||||
|
|
||||||
|
ColorPaletteButtonItem* customColorButton = new ColorPaletteButtonItem( tr("Custom color...") );
|
||||||
|
connect( customColorButton, SIGNAL(activated()), this, SLOT(onCustomColorItemActivated()) );
|
||||||
|
vLayout->addWidget( customColorButton );
|
||||||
|
|
||||||
|
QFrame* hline4 = new QFrame;
|
||||||
|
hline4->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
||||||
|
hline4->setLineWidth( 1 );
|
||||||
|
vLayout->addWidget( hline4 );
|
||||||
|
|
||||||
|
mMergeFieldCombo = new QComboBox();
|
||||||
|
mMergeFieldCombo->addItem( tr("Merge key...") );
|
||||||
|
mMergeFieldCombo->setMinimumSize( 34, 34 );
|
||||||
|
mMergeFieldCombo->setFrame( false );
|
||||||
|
mMergeFieldCombo->setEnabled( false );
|
||||||
|
connect( mMergeFieldCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboIndexChanged(int)) );
|
||||||
|
vLayout->addWidget( mMergeFieldCombo );
|
||||||
|
|
||||||
|
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
||||||
|
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(mMergeFieldCombo->model());
|
||||||
|
QStandardItem* item = model->item(0);
|
||||||
|
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
||||||
|
|
||||||
|
setLayout( vLayout );
|
||||||
|
|
||||||
|
loadCustomColorHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::setColorNode( const ColorNode& colorNode )
|
||||||
|
{
|
||||||
|
mColorNode = colorNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
||||||
|
{
|
||||||
|
mKeys = keyList;
|
||||||
|
|
||||||
|
// Clear old keys, (all entries, except item 0)
|
||||||
|
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
||||||
|
{
|
||||||
|
mMergeFieldCombo->removeItem( index );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new keys
|
||||||
|
if ( keyList.size() > 0 )
|
||||||
|
{
|
||||||
|
mMergeFieldCombo->addItems( keyList );
|
||||||
|
mMergeFieldCombo->setEnabled( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mMergeFieldCombo->setEnabled( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vLayout->addLayout( mainPaletteLayout );
|
|
||||||
|
|
||||||
QFrame* hline2 = new QFrame;
|
|
||||||
hline2->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
|
||||||
hline2->setLineWidth( 1 );
|
|
||||||
vLayout->addWidget( hline2 );
|
|
||||||
|
|
||||||
QHBoxLayout* customPaletteLayout = new QHBoxLayout();
|
void ColorPaletteDialog::clearKeys()
|
||||||
customPaletteLayout->setSpacing( 0 );
|
|
||||||
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
|
||||||
{
|
{
|
||||||
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
|
|
||||||
mHistoryItem[iCol]->setEnabled( false );
|
|
||||||
connect( mHistoryItem[iCol], SIGNAL(activated(int)), this, SLOT(onHistoryItemActivated(int)) );
|
|
||||||
|
|
||||||
customPaletteLayout->addWidget( mHistoryItem[iCol] );
|
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
||||||
}
|
{
|
||||||
vLayout->addLayout( customPaletteLayout );
|
mMergeFieldCombo->removeItem( index );
|
||||||
|
}
|
||||||
|
|
||||||
QFrame* hline3 = new QFrame;
|
|
||||||
hline3->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
|
||||||
hline3->setLineWidth( 1 );
|
|
||||||
vLayout->addWidget( hline3 );
|
|
||||||
|
|
||||||
ColorPaletteButtonItem* customColorButton = new ColorPaletteButtonItem( tr("Custom color...") );
|
|
||||||
connect( customColorButton, SIGNAL(activated()), this, SLOT(onCustomColorItemActivated()) );
|
|
||||||
vLayout->addWidget( customColorButton );
|
|
||||||
|
|
||||||
QFrame* hline4 = new QFrame;
|
|
||||||
hline4->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
|
||||||
hline4->setLineWidth( 1 );
|
|
||||||
vLayout->addWidget( hline4 );
|
|
||||||
|
|
||||||
mMergeFieldCombo = new QComboBox();
|
|
||||||
mMergeFieldCombo->addItem( tr("Merge key...") );
|
|
||||||
mMergeFieldCombo->setMinimumSize( 34, 34 );
|
|
||||||
mMergeFieldCombo->setFrame( false );
|
|
||||||
mMergeFieldCombo->setEnabled( false );
|
|
||||||
connect( mMergeFieldCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboIndexChanged(int)) );
|
|
||||||
vLayout->addWidget( mMergeFieldCombo );
|
|
||||||
|
|
||||||
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
|
||||||
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(mMergeFieldCombo->model());
|
|
||||||
QStandardItem* item = model->item(0);
|
|
||||||
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
|
||||||
|
|
||||||
setLayout( vLayout );
|
|
||||||
|
|
||||||
loadCustomColorHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::setColorNode( const ColorNode& colorNode )
|
|
||||||
{
|
|
||||||
mColorNode = colorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
|
||||||
{
|
|
||||||
mKeys = keyList;
|
|
||||||
|
|
||||||
// Clear old keys, (all entries, except item 0)
|
|
||||||
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
|
||||||
{
|
|
||||||
mMergeFieldCombo->removeItem( index );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new keys
|
|
||||||
if ( keyList.size() > 0 )
|
|
||||||
{
|
|
||||||
mMergeFieldCombo->addItems( keyList );
|
|
||||||
mMergeFieldCombo->setEnabled( true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mMergeFieldCombo->setEnabled( false );
|
mMergeFieldCombo->setEnabled( false );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::clearKeys()
|
void ColorPaletteDialog::onDefaultItemActivated()
|
||||||
{
|
|
||||||
|
|
||||||
for ( int index = mMergeFieldCombo->count()-1; index > 0; index-- )
|
|
||||||
{
|
{
|
||||||
mMergeFieldCombo->removeItem( index );
|
mColorNode.setField( false );
|
||||||
|
mColorNode.setColor( mDefaultColor );
|
||||||
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
|
emit colorChanged( mColorNode, true );
|
||||||
|
accept();
|
||||||
}
|
}
|
||||||
mMergeFieldCombo->setEnabled( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onDefaultItemActivated()
|
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
||||||
{
|
|
||||||
mColorNode.setField( false );
|
|
||||||
mColorNode.setColor( mDefaultColor );
|
|
||||||
mColorNode.setKey( "" );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, true );
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
|
||||||
{
|
|
||||||
mColorNode.setField( false );
|
|
||||||
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
|
||||||
mColorNode.setKey( "" );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
|
||||||
{
|
|
||||||
mColorNode.setField( false );
|
|
||||||
mColorNode.setColor( mColorHistory->getColors()[id] );
|
|
||||||
mColorNode.setKey( "" );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onCustomColorItemActivated()
|
|
||||||
{
|
|
||||||
QColorDialog dlg( mColorNode.color(), this );
|
|
||||||
dlg.setWindowTitle( tr("Custom Color") );
|
|
||||||
|
|
||||||
if ( dlg.exec() )
|
|
||||||
{
|
{
|
||||||
ColorNode newColorNode;
|
mColorNode.setField( false );
|
||||||
|
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
||||||
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
newColorNode.setField( false );
|
emit colorChanged( mColorNode, false );
|
||||||
newColorNode.setColor( dlg.currentColor() );
|
accept();
|
||||||
newColorNode.setKey( "" );
|
}
|
||||||
|
|
||||||
if ( newColorNode != mColorNode )
|
|
||||||
|
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
||||||
|
{
|
||||||
|
mColorNode.setField( false );
|
||||||
|
mColorNode.setColor( mColorHistory->getColors()[id] );
|
||||||
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
|
emit colorChanged( mColorNode, false );
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::onCustomColorItemActivated()
|
||||||
|
{
|
||||||
|
QColorDialog dlg( mColorNode.color(), this );
|
||||||
|
dlg.setWindowTitle( tr("Custom Color") );
|
||||||
|
|
||||||
|
if ( dlg.exec() )
|
||||||
{
|
{
|
||||||
mColorNode = newColorNode;
|
ColorNode newColorNode;
|
||||||
|
|
||||||
mColorHistory->addColor( mColorNode.color() );
|
newColorNode.setField( false );
|
||||||
|
newColorNode.setColor( dlg.currentColor() );
|
||||||
|
newColorNode.setKey( "" );
|
||||||
|
|
||||||
|
if ( newColorNode != mColorNode )
|
||||||
|
{
|
||||||
|
mColorNode = newColorNode;
|
||||||
|
|
||||||
|
mColorHistory->addColor( mColorNode.color() );
|
||||||
|
|
||||||
|
emit colorChanged( mColorNode, false );
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::onColorHistoryChanged()
|
||||||
|
{
|
||||||
|
loadCustomColorHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::loadCustomColorHistory()
|
||||||
|
{
|
||||||
|
QList<QColor> colorList = mColorHistory->getColors();
|
||||||
|
|
||||||
|
int id = 0;
|
||||||
|
foreach ( QColor color, colorList )
|
||||||
|
{
|
||||||
|
mHistoryItem[id]->setColor( id, color, QString(tr("Custom color #%1").arg(id+1) ) );
|
||||||
|
mHistoryItem[id]->setEnabled( true );
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( id < PALETTE_ROWS )
|
||||||
|
{
|
||||||
|
mHistoryItem[id]->setEnabled( false );
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::onComboIndexChanged( int index )
|
||||||
|
{
|
||||||
|
if ( index != 0 )
|
||||||
|
{
|
||||||
|
mColorNode.setField( true );
|
||||||
|
mColorNode.setColor( QColor("#eeeeec") );
|
||||||
|
mColorNode.setKey( mKeys[index-1] );
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onColorHistoryChanged()
|
void ColorPaletteDialog::showEvent( QShowEvent* event )
|
||||||
{
|
|
||||||
loadCustomColorHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::loadCustomColorHistory()
|
|
||||||
{
|
|
||||||
QList<QColor> colorList = mColorHistory->getColors();
|
|
||||||
|
|
||||||
int id = 0;
|
|
||||||
foreach ( QColor color, colorList )
|
|
||||||
{
|
{
|
||||||
mHistoryItem[id]->setColor( id, color, QString(tr("Custom color #%1").arg(id+1) ) );
|
mMergeFieldCombo->setCurrentIndex( 0 );
|
||||||
mHistoryItem[id]->setEnabled( true );
|
|
||||||
id++;
|
QDialog::showEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( id < PALETTE_ROWS )
|
|
||||||
{
|
|
||||||
mHistoryItem[id]->setEnabled( false );
|
|
||||||
id++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onComboIndexChanged( int index )
|
|
||||||
{
|
|
||||||
if ( index != 0 )
|
|
||||||
{
|
|
||||||
mColorNode.setField( true );
|
|
||||||
mColorNode.setColor( QColor("#eeeeec") );
|
|
||||||
mColorNode.setKey( mKeys[index-1] );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::showEvent( QShowEvent* event )
|
|
||||||
{
|
|
||||||
mMergeFieldCombo->setCurrentIndex( 0 );
|
|
||||||
|
|
||||||
QDialog::showEvent( event );
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,86 +31,91 @@
|
|||||||
#include "ColorPaletteButtonItem.h"
|
#include "ColorPaletteButtonItem.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Palette Dialog
|
|
||||||
///
|
|
||||||
class ColorPaletteDialog : public QDialog
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
///
|
||||||
|
/// Color Palette Dialog
|
||||||
|
///
|
||||||
|
class ColorPaletteDialog : public QDialog
|
||||||
|
{
|
||||||
|
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,
|
||||||
QWidget* parent = 0 );
|
QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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 );
|
||||||
void onCustomColorItemActivated();
|
void onCustomColorItemActivated();
|
||||||
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;
|
||||||
|
|
||||||
static const int PALETTE_COLS = ColorHistory::MAX_COLORS;
|
static const int PALETTE_COLS = ColorHistory::MAX_COLORS;
|
||||||
static const int PALETTE_ROWS = 4;
|
static const int PALETTE_ROWS = 4;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
QString colorSpec;
|
QString colorSpec;
|
||||||
QString name;
|
QString name;
|
||||||
} ColorTableEntry;
|
} ColorTableEntry;
|
||||||
|
|
||||||
static ColorTableEntry mColorTable[];
|
static ColorTableEntry mColorTable[];
|
||||||
|
|
||||||
ColorHistory* mColorHistory;
|
ColorHistory* mColorHistory;
|
||||||
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
||||||
|
|
||||||
QComboBox* mMergeFieldCombo;
|
QComboBox* mMergeFieldCombo;
|
||||||
QStringList mKeys;
|
QStringList mKeys;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorPaletteDialog_h
|
#endif // ColorPaletteDialog_h
|
||||||
|
|||||||
+102
-97
@@ -25,120 +25,125 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
//
|
namespace glabels
|
||||||
// Private Configuration Data
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
const int border = 4;
|
|
||||||
const int wSwatch = 25;
|
|
||||||
const int hSwatch = 25;
|
|
||||||
|
|
||||||
const int hoverBgOutlineWidthPixels = 1;
|
|
||||||
|
|
||||||
const int outlineWidthPixels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor From Data
|
|
||||||
///
|
|
||||||
ColorPaletteItem::ColorPaletteItem( int id,
|
|
||||||
const QColor& color,
|
|
||||||
const QString& tip,
|
|
||||||
QWidget* parent )
|
|
||||||
: QWidget(parent), mId(id), mColor(color), mTip(tip), mHover(false)
|
|
||||||
{
|
|
||||||
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
|
||||||
setMinimumSize( wSwatch+2*border+1, hSwatch+2*border+1 );
|
|
||||||
setToolTip( tip );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Color Property Setter
|
|
||||||
///
|
|
||||||
void ColorPaletteItem::setColor( int id,
|
|
||||||
const QColor& color,
|
|
||||||
const QString& tip )
|
|
||||||
{
|
|
||||||
mId = id;
|
|
||||||
mColor = color;
|
|
||||||
mTip = tip;
|
|
||||||
|
|
||||||
setToolTip( tip );
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Paint Event
|
|
||||||
///
|
|
||||||
void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
|
||||||
{
|
|
||||||
QPainter painter(this);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw swatch
|
// Private
|
||||||
//
|
//
|
||||||
if ( isEnabled() )
|
namespace
|
||||||
{
|
{
|
||||||
if ( mHover )
|
const int border = 4;
|
||||||
|
const int wSwatch = 25;
|
||||||
|
const int hSwatch = 25;
|
||||||
|
|
||||||
|
const int hoverBgOutlineWidthPixels = 1;
|
||||||
|
|
||||||
|
const int outlineWidthPixels = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor From Data
|
||||||
|
///
|
||||||
|
ColorPaletteItem::ColorPaletteItem( int id,
|
||||||
|
const QColor& color,
|
||||||
|
const QString& tip,
|
||||||
|
QWidget* parent )
|
||||||
|
: QWidget(parent), mId(id), mColor(color), mTip(tip), mHover(false)
|
||||||
|
{
|
||||||
|
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
||||||
|
setMinimumSize( wSwatch+2*border+1, hSwatch+2*border+1 );
|
||||||
|
setToolTip( tip );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Property Setter
|
||||||
|
///
|
||||||
|
void ColorPaletteItem::setColor( int id,
|
||||||
|
const QColor& color,
|
||||||
|
const QString& tip )
|
||||||
|
{
|
||||||
|
mId = id;
|
||||||
|
mColor = color;
|
||||||
|
mTip = tip;
|
||||||
|
|
||||||
|
setToolTip( tip );
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Paint Event
|
||||||
|
///
|
||||||
|
void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw swatch
|
||||||
|
//
|
||||||
|
if ( isEnabled() )
|
||||||
{
|
{
|
||||||
QPen pen( palette().color( QPalette::Text ) );
|
if ( mHover )
|
||||||
pen.setWidth( 2*outlineWidthPixels );
|
{
|
||||||
pen.setJoinStyle( Qt::MiterJoin );
|
QPen pen( palette().color( QPalette::Text ) );
|
||||||
painter.setPen( pen );
|
pen.setWidth( 2*outlineWidthPixels );
|
||||||
painter.setBrush( QBrush( mColor ) );
|
pen.setJoinStyle( Qt::MiterJoin );
|
||||||
painter.drawRect( 1, 1, width()-2, height()-2 );
|
painter.setPen( pen );
|
||||||
|
painter.setBrush( QBrush( mColor ) );
|
||||||
|
painter.drawRect( 1, 1, width()-2, height()-2 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QPen pen( palette().color( QPalette::Text ) );
|
||||||
|
pen.setWidth( outlineWidthPixels );
|
||||||
|
painter.setPen( pen );
|
||||||
|
painter.setBrush( QBrush( mColor ) );
|
||||||
|
painter.drawRect( border, border, wSwatch, hSwatch );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPen pen( palette().color( QPalette::Text ) );
|
QPen pen( palette().color( QPalette::Disabled, QPalette::Text ) );
|
||||||
pen.setWidth( outlineWidthPixels );
|
pen.setWidth( outlineWidthPixels );
|
||||||
painter.setPen( pen );
|
painter.setPen( pen );
|
||||||
painter.setBrush( QBrush( mColor ) );
|
painter.setBrush( QBrush( mColor ) );
|
||||||
painter.drawRect( border, border, wSwatch, hSwatch );
|
painter.drawRect( border, border, wSwatch, hSwatch );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Enter Event
|
||||||
|
///
|
||||||
|
void ColorPaletteItem::enterEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
QPen pen( palette().color( QPalette::Disabled, QPalette::Text ) );
|
mHover = true;
|
||||||
pen.setWidth( outlineWidthPixels );
|
update();
|
||||||
painter.setPen( pen );
|
}
|
||||||
painter.setBrush( QBrush( mColor ) );
|
|
||||||
painter.drawRect( border, border, wSwatch, hSwatch );
|
|
||||||
|
///
|
||||||
|
/// Leave Event
|
||||||
|
///
|
||||||
|
void ColorPaletteItem::leaveEvent( QEvent* event )
|
||||||
|
{
|
||||||
|
mHover = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Mouse Press Event
|
||||||
|
///
|
||||||
|
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
|
||||||
|
{
|
||||||
|
emit activated( mId );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Enter Event
|
|
||||||
///
|
|
||||||
void ColorPaletteItem::enterEvent( QEvent* event )
|
|
||||||
{
|
|
||||||
mHover = true;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Leave Event
|
|
||||||
///
|
|
||||||
void ColorPaletteItem::leaveEvent( QEvent* event )
|
|
||||||
{
|
|
||||||
mHover = false;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Mouse Press Event
|
|
||||||
///
|
|
||||||
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
|
|
||||||
{
|
|
||||||
emit activated( mId );
|
|
||||||
}
|
|
||||||
|
|||||||
+47
-42
@@ -26,59 +26,64 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Color Palette Item
|
|
||||||
///
|
|
||||||
class ColorPaletteItem : public QWidget
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Color Palette Item
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class ColorPaletteItem : public QWidget
|
||||||
ColorPaletteItem( int id,
|
{
|
||||||
const QColor& color,
|
Q_OBJECT
|
||||||
const QString& tip,
|
|
||||||
QWidget* parent = 0 );
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
ColorPaletteItem( int id,
|
||||||
|
const QColor& color,
|
||||||
|
const QString& tip,
|
||||||
|
QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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 );
|
||||||
void mousePressEvent( QMouseEvent* event );
|
void mousePressEvent( QMouseEvent* event );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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
|
||||||
|
|||||||
+33
-28
@@ -24,33 +24,38 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
//
|
namespace glabels
|
||||||
// Private Configuration Data
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
const QColor outlineColor( 0, 0, 0 );
|
|
||||||
const double outlineWidthPixels = 1;
|
//
|
||||||
}
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
///
|
{
|
||||||
/// Constructor
|
const QColor outlineColor( 0, 0, 0 );
|
||||||
///
|
const double outlineWidthPixels = 1;
|
||||||
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
}
|
||||||
: QPixmap( w, h )
|
|
||||||
{
|
|
||||||
fill( Qt::transparent );
|
///
|
||||||
|
/// Constructor
|
||||||
QPainter painter(this );
|
///
|
||||||
|
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
||||||
painter.setBackgroundMode( Qt::TransparentMode );
|
: QPixmap( w, h )
|
||||||
|
{
|
||||||
QBrush brush( color );
|
fill( Qt::transparent );
|
||||||
QPen pen( outlineColor );
|
|
||||||
pen.setWidth( outlineWidthPixels );
|
QPainter painter(this );
|
||||||
|
|
||||||
painter.setBrush( brush );
|
painter.setBackgroundMode( Qt::TransparentMode );
|
||||||
painter.setPen( pen );
|
|
||||||
painter.drawRect( 1, 1, w-2, h-2 );
|
QBrush brush( color );
|
||||||
|
QPen pen( outlineColor );
|
||||||
|
pen.setWidth( outlineWidthPixels );
|
||||||
|
|
||||||
|
painter.setBrush( brush );
|
||||||
|
painter.setPen( pen );
|
||||||
|
painter.drawRect( 1, 1, w-2, h-2 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -25,19 +25,24 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Simple Preview Widget
|
|
||||||
///
|
|
||||||
class ColorSwatch : public QPixmap
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Simple Preview Widget
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class ColorSwatch : public QPixmap
|
||||||
ColorSwatch( int w, int h, const QColor& color );
|
{
|
||||||
|
|
||||||
};
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
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
|
||||||
|
|||||||
+43
-32
@@ -23,37 +23,48 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
|
||||||
Cursors::Barcode::Barcode()
|
namespace glabels
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_barcode.png"), 7, 7 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Cursors::Box::Box()
|
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_box.png"), 7, 7 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Cursors::Ellipse::Ellipse()
|
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_ellipse.png"), 7, 7 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Cursors::Image::Image()
|
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_image.png"), 7, 7 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Cursors::Line::Line()
|
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_line.png"), 7, 7 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Cursors::Text::Text()
|
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_text.png"), 7, 7 )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Cursors::Barcode::Barcode()
|
||||||
|
: QCursor( QPixmap(":cursors/32x32/cursor_barcode.png"), 7, 7 )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Cursors::Box::Box()
|
||||||
|
: QCursor( QPixmap(":cursors/32x32/cursor_box.png"), 7, 7 )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Cursors::Ellipse::Ellipse()
|
||||||
|
: QCursor( QPixmap(":cursors/32x32/cursor_ellipse.png"), 7, 7 )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Cursors::Image::Image()
|
||||||
|
: QCursor( QPixmap(":cursors/32x32/cursor_image.png"), 7, 7 )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Cursors::Line::Line()
|
||||||
|
: QCursor( QPixmap(":cursors/32x32/cursor_line.png"), 7, 7 )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Cursors::Text::Text()
|
||||||
|
: QCursor( QPixmap(":cursors/32x32/cursor_text.png"), 7, 7 )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-34
@@ -25,53 +25,58 @@
|
|||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Glabels Cursors
|
|
||||||
///
|
|
||||||
namespace Cursors
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
class Barcode : public QCursor
|
/// Glabels Cursors
|
||||||
|
///
|
||||||
|
namespace Cursors
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
Barcode();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Box : public QCursor
|
class Barcode : public QCursor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Box();
|
Barcode();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Ellipse : public QCursor
|
class Box : public QCursor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Ellipse();
|
Box();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Image : public QCursor
|
class Ellipse : public QCursor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Image();
|
Ellipse();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Line : public QCursor
|
class Image : public QCursor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Line();
|
Image();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Text : public QCursor
|
class Line : public QCursor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Text();
|
Line();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Text : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -131,8 +131,8 @@ namespace glabels
|
|||||||
|
|
||||||
static QList<Template*> mTemplates;
|
static QList<Template*> mTemplates;
|
||||||
|
|
||||||
static QString mPaperNameOther;
|
static QString mPaperNameOther;
|
||||||
static QString mEmpty;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+75
-70
@@ -21,101 +21,106 @@
|
|||||||
#include "EnumUtil.h"
|
#include "EnumUtil.h"
|
||||||
|
|
||||||
|
|
||||||
namespace EnumUtil
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
QString weightToString( QFont::Weight weight )
|
namespace EnumUtil
|
||||||
{
|
{
|
||||||
switch (weight)
|
|
||||||
|
QString weightToString( QFont::Weight weight )
|
||||||
{
|
{
|
||||||
case QFont::Bold:
|
switch (weight)
|
||||||
return "bold";
|
{
|
||||||
break;
|
case QFont::Bold:
|
||||||
default:
|
return "bold";
|
||||||
return "normal";
|
break;
|
||||||
break;
|
default:
|
||||||
|
return "normal";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QFont::Weight stringToWeight( const QString& string )
|
QFont::Weight stringToWeight( const QString& string )
|
||||||
{
|
|
||||||
if ( string == "bold" )
|
|
||||||
{
|
{
|
||||||
return QFont::Bold;
|
if ( string == "bold" )
|
||||||
|
{
|
||||||
|
return QFont::Bold;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QFont::Normal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return QFont::Normal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString hAlignToString( Qt::Alignment align )
|
QString hAlignToString( Qt::Alignment align )
|
||||||
{
|
|
||||||
switch (align)
|
|
||||||
{
|
{
|
||||||
case Qt::AlignRight:
|
switch (align)
|
||||||
return "right";
|
{
|
||||||
break;
|
case Qt::AlignRight:
|
||||||
case Qt::AlignHCenter:
|
return "right";
|
||||||
return "center";
|
break;
|
||||||
break;
|
case Qt::AlignHCenter:
|
||||||
default:
|
return "center";
|
||||||
return "left";
|
break;
|
||||||
break;
|
default:
|
||||||
|
return "left";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Qt::Alignment stringToHAlign( const QString& string )
|
Qt::Alignment stringToHAlign( const QString& string )
|
||||||
{
|
|
||||||
if ( string == "right" )
|
|
||||||
{
|
{
|
||||||
return Qt::AlignRight;
|
if ( string == "right" )
|
||||||
|
{
|
||||||
|
return Qt::AlignRight;
|
||||||
|
}
|
||||||
|
else if ( string == "center" )
|
||||||
|
{
|
||||||
|
return Qt::AlignHCenter;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Qt::AlignLeft;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( string == "center" )
|
|
||||||
{
|
|
||||||
return Qt::AlignHCenter;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Qt::AlignLeft;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString vAlignToString( Qt::Alignment align )
|
QString vAlignToString( Qt::Alignment align )
|
||||||
{
|
|
||||||
switch (align)
|
|
||||||
{
|
{
|
||||||
case Qt::AlignBottom:
|
switch (align)
|
||||||
return "bottom";
|
{
|
||||||
break;
|
case Qt::AlignBottom:
|
||||||
case Qt::AlignVCenter:
|
return "bottom";
|
||||||
return "center";
|
break;
|
||||||
break;
|
case Qt::AlignVCenter:
|
||||||
default:
|
return "center";
|
||||||
return "top";
|
break;
|
||||||
break;
|
default:
|
||||||
|
return "top";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Qt::Alignment stringToVAlign( const QString& string )
|
Qt::Alignment stringToVAlign( const QString& string )
|
||||||
{
|
|
||||||
if ( string == "bottom" )
|
|
||||||
{
|
{
|
||||||
return Qt::AlignBottom;
|
if ( string == "bottom" )
|
||||||
}
|
{
|
||||||
else if ( string == "center" )
|
return Qt::AlignBottom;
|
||||||
{
|
}
|
||||||
return Qt::AlignVCenter;
|
else if ( string == "center" )
|
||||||
}
|
{
|
||||||
else
|
return Qt::AlignVCenter;
|
||||||
{
|
}
|
||||||
return Qt::AlignTop;
|
else
|
||||||
|
{
|
||||||
|
return Qt::AlignTop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-7
@@ -27,17 +27,22 @@
|
|||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
|
||||||
|
|
||||||
namespace EnumUtil
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
QString weightToString( QFont::Weight weight );
|
namespace EnumUtil
|
||||||
QFont::Weight stringToWeight( const QString& string );
|
{
|
||||||
|
|
||||||
QString hAlignToString( Qt::Alignment align );
|
QString weightToString( QFont::Weight weight );
|
||||||
Qt::Alignment stringToHAlign( const QString& string );
|
QFont::Weight stringToWeight( const QString& string );
|
||||||
|
|
||||||
QString vAlignToString( Qt::Alignment align );
|
QString hAlignToString( Qt::Alignment align );
|
||||||
Qt::Alignment stringToVAlign( const QString& string );
|
Qt::Alignment stringToHAlign( const QString& string );
|
||||||
|
|
||||||
|
QString vAlignToString( Qt::Alignment align );
|
||||||
|
Qt::Alignment stringToVAlign( const QString& string );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+68
-63
@@ -25,80 +25,85 @@
|
|||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
FieldButton::FieldButton( QWidget* parent )
|
|
||||||
: QComboBox(parent)
|
|
||||||
{
|
{
|
||||||
setEnabled( false );
|
|
||||||
|
|
||||||
connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)) );
|
///
|
||||||
}
|
/// Constructor
|
||||||
|
///
|
||||||
|
FieldButton::FieldButton( QWidget* parent )
|
||||||
void FieldButton::setName( const QString& name )
|
: QComboBox(parent)
|
||||||
{
|
|
||||||
mName = name;
|
|
||||||
if ( count() == 0 )
|
|
||||||
{
|
{
|
||||||
|
setEnabled( false );
|
||||||
|
|
||||||
|
connect( this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FieldButton::setName( const QString& name )
|
||||||
|
{
|
||||||
|
mName = name;
|
||||||
|
if ( count() == 0 )
|
||||||
|
{
|
||||||
|
addItem( mName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setItemText( 0, mName );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
||||||
|
const QStandardItemModel* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
||||||
|
QStandardItem* item = itemModel->item(0);
|
||||||
|
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FieldButton::setKeys( const QStringList& keyList )
|
||||||
|
{
|
||||||
|
// Clear old keys
|
||||||
|
clear();
|
||||||
addItem( mName );
|
addItem( mName );
|
||||||
|
|
||||||
|
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
||||||
|
const QStandardItemModel* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
||||||
|
QStandardItem* item = itemModel->item(0);
|
||||||
|
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
||||||
|
|
||||||
|
// Add new keys
|
||||||
|
if ( keyList.size() > 0 )
|
||||||
|
{
|
||||||
|
addItems( keyList );
|
||||||
|
setEnabled( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEnabled( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
void FieldButton::clearKeys()
|
||||||
{
|
{
|
||||||
setItemText( 0, mName );
|
clear();
|
||||||
|
addItem( mName );
|
||||||
|
|
||||||
|
setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
|
||||||
const QStandardItemModel* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
|
||||||
QStandardItem* item = itemModel->item(0);
|
|
||||||
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FieldButton::setKeys( const QStringList& keyList )
|
///
|
||||||
{
|
/// onMenuKeySelected slot
|
||||||
// Clear old keys
|
///
|
||||||
clear();
|
void FieldButton::onIndexChanged( int index )
|
||||||
addItem( mName );
|
|
||||||
|
|
||||||
// Item 0 is the ComboBox title, not an item intended for selection. So disable it.
|
|
||||||
const QStandardItemModel* itemModel = qobject_cast<const QStandardItemModel*>(model());
|
|
||||||
QStandardItem* item = itemModel->item(0);
|
|
||||||
item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
|
|
||||||
|
|
||||||
// Add new keys
|
|
||||||
if ( keyList.size() > 0 )
|
|
||||||
{
|
|
||||||
addItems( keyList );
|
|
||||||
setEnabled( true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setEnabled( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FieldButton::clearKeys()
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
addItem( mName );
|
|
||||||
|
|
||||||
setEnabled( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// onMenuKeySelected slot
|
|
||||||
///
|
|
||||||
void FieldButton::onIndexChanged( int index )
|
|
||||||
{
|
|
||||||
if ( index > 0 )
|
|
||||||
{
|
{
|
||||||
emit keySelected( itemText(index) );
|
if ( index > 0 )
|
||||||
|
{
|
||||||
|
emit keySelected( itemText(index) );
|
||||||
|
|
||||||
setCurrentIndex( 0 );
|
setCurrentIndex( 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-33
@@ -26,50 +26,55 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Field Button
|
|
||||||
///
|
|
||||||
class FieldButton : public QComboBox
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Field Button
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class FieldButton : public QComboBox
|
||||||
FieldButton( QWidget* parent = 0 );
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
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();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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
|
||||||
|
|||||||
+168
-163
@@ -33,80 +33,33 @@
|
|||||||
#include "XmlLabelCreator.h"
|
#include "XmlLabelCreator.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Static data
|
|
||||||
///
|
|
||||||
QString File::mCwd = ".";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// New Label Dialog
|
|
||||||
///
|
|
||||||
bool File::newLabel( MainWindow *window )
|
|
||||||
{
|
{
|
||||||
SelectProductDialog dialog( window );
|
|
||||||
dialog.exec();
|
|
||||||
|
|
||||||
const glabels::Template* tmplate = dialog.tmplate();
|
//
|
||||||
if ( tmplate )
|
// Static data
|
||||||
|
//
|
||||||
|
QString File::mCwd = ".";
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// New Label Dialog
|
||||||
|
///
|
||||||
|
bool File::newLabel( MainWindow *window )
|
||||||
{
|
{
|
||||||
LabelModel* label = new LabelModel();
|
SelectProductDialog dialog( window );
|
||||||
label->setTmplate( tmplate );
|
dialog.exec();
|
||||||
label->clearModified();
|
|
||||||
|
|
||||||
// Intelligently decide to rotate label by default
|
const Template* tmplate = dialog.tmplate();
|
||||||
const glabels::Frame* frame = tmplate->frames().first();
|
if ( tmplate )
|
||||||
label->setRotate( frame->h() > frame->w() );
|
|
||||||
|
|
||||||
// Either apply to current window or open a new one
|
|
||||||
if ( window->isEmpty() )
|
|
||||||
{
|
{
|
||||||
window->setModel( label );
|
LabelModel* label = new LabelModel();
|
||||||
}
|
label->setTmplate( tmplate );
|
||||||
else
|
label->clearModified();
|
||||||
{
|
|
||||||
MainWindow *newWindow = new MainWindow();
|
|
||||||
newWindow->setModel( label );
|
|
||||||
newWindow->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
// Intelligently decide to rotate label by default
|
||||||
}
|
const Frame* frame = tmplate->frames().first();
|
||||||
else
|
label->setRotate( frame->h() > frame->w() );
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Open File Dialog
|
|
||||||
///
|
|
||||||
void File::open( MainWindow *window )
|
|
||||||
{
|
|
||||||
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
|
||||||
QString cwd = mCwd;
|
|
||||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
|
||||||
{
|
|
||||||
QFileInfo fileInfo( window->model()->fileName() );
|
|
||||||
if ( fileInfo.isFile() )
|
|
||||||
{
|
|
||||||
cwd = fileInfo.absolutePath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString fileName =
|
|
||||||
QFileDialog::getOpenFileName( window,
|
|
||||||
tr("gLabels - Open Project"),
|
|
||||||
cwd,
|
|
||||||
tr("glabels files (*.glabels);;All files (*)")
|
|
||||||
);
|
|
||||||
if ( !fileName.isEmpty() )
|
|
||||||
{
|
|
||||||
LabelModel *label = XmlLabelParser::readFile( fileName );
|
|
||||||
if ( label )
|
|
||||||
{
|
|
||||||
label->setFileName( fileName );
|
|
||||||
|
|
||||||
// Either apply to current window or open a new one
|
// Either apply to current window or open a new one
|
||||||
if ( window->isEmpty() )
|
if ( window->isEmpty() )
|
||||||
@@ -120,123 +73,175 @@ void File::open( MainWindow *window )
|
|||||||
newWindow->show();
|
newWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save CWD
|
return true;
|
||||||
mCwd = QFileInfo( fileName ).absolutePath();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox msgBox;
|
return false;
|
||||||
msgBox.setText( tr("Unable to open \"") + fileName + tr("\".") );
|
|
||||||
msgBox.setStandardButtons( QMessageBox::Ok );
|
|
||||||
msgBox.setDefaultButton( QMessageBox::Ok );
|
|
||||||
msgBox.exec();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Save file
|
|
||||||
///
|
|
||||||
bool File::save( MainWindow *window )
|
|
||||||
{
|
|
||||||
if ( window->model()->fileName().isEmpty() )
|
|
||||||
{
|
|
||||||
return saveAs( window );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !window->model()->isModified() )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
XmlLabelCreator::writeFile( window->model(), window->model()->fileName() );
|
|
||||||
window->model()->clearModified();
|
|
||||||
|
|
||||||
// Save CWD
|
|
||||||
mCwd = QFileInfo( window->model()->fileName() ).absolutePath();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Save file as
|
|
||||||
///
|
|
||||||
bool File::saveAs( MainWindow *window )
|
|
||||||
{
|
|
||||||
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
|
||||||
QString cwd = mCwd;
|
|
||||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
|
||||||
{
|
|
||||||
QFileInfo fileInfo( window->model()->fileName() );
|
|
||||||
if ( fileInfo.isFile() )
|
|
||||||
{
|
|
||||||
cwd = fileInfo.filePath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString rawFileName =
|
|
||||||
QFileDialog::getSaveFileName( window,
|
///
|
||||||
tr("gLabels - Save Project As"),
|
/// Open File Dialog
|
||||||
cwd,
|
///
|
||||||
tr("glabels files (*.glabels);;All files (*)"),
|
void File::open( MainWindow *window )
|
||||||
0,
|
|
||||||
QFileDialog::DontConfirmOverwrite );
|
|
||||||
if ( !rawFileName.isEmpty() )
|
|
||||||
{
|
{
|
||||||
QString fileName = FileUtil::addExtension( rawFileName, ".glabels" );
|
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
||||||
|
QString cwd = mCwd;
|
||||||
|
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||||
if ( QFileInfo(fileName).exists() )
|
|
||||||
{
|
{
|
||||||
QMessageBox msgBox( window );
|
QFileInfo fileInfo( window->model()->fileName() );
|
||||||
msgBox.setWindowTitle( tr("Save Label As") );
|
if ( fileInfo.isFile() )
|
||||||
msgBox.setIcon( QMessageBox::Warning );
|
|
||||||
msgBox.setText( tr("%1 already exists.").arg(fileName) );
|
|
||||||
msgBox.setInformativeText( tr("Do you want to replace it?") );
|
|
||||||
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
|
|
||||||
msgBox.setDefaultButton( QMessageBox::No );
|
|
||||||
|
|
||||||
if ( msgBox.exec() == QMessageBox::No )
|
|
||||||
{
|
{
|
||||||
return saveAs( window );
|
cwd = fileInfo.absolutePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlLabelCreator::writeFile( window->model(), fileName );
|
QString fileName =
|
||||||
window->model()->setFileName( fileName );
|
QFileDialog::getOpenFileName( window,
|
||||||
|
tr("gLabels - Open Project"),
|
||||||
|
cwd,
|
||||||
|
tr("glabels files (*.glabels);;All files (*)")
|
||||||
|
);
|
||||||
|
if ( !fileName.isEmpty() )
|
||||||
|
{
|
||||||
|
LabelModel *label = XmlLabelParser::readFile( fileName );
|
||||||
|
if ( label )
|
||||||
|
{
|
||||||
|
label->setFileName( fileName );
|
||||||
|
|
||||||
|
// Either apply to current window or open a new one
|
||||||
|
if ( window->isEmpty() )
|
||||||
|
{
|
||||||
|
window->setModel( label );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainWindow *newWindow = new MainWindow();
|
||||||
|
newWindow->setModel( label );
|
||||||
|
newWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save CWD
|
||||||
|
mCwd = QFileInfo( fileName ).absolutePath();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText( tr("Unable to open \"") + fileName + tr("\".") );
|
||||||
|
msgBox.setStandardButtons( QMessageBox::Ok );
|
||||||
|
msgBox.setDefaultButton( QMessageBox::Ok );
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Save file
|
||||||
|
///
|
||||||
|
bool File::save( MainWindow *window )
|
||||||
|
{
|
||||||
|
if ( window->model()->fileName().isEmpty() )
|
||||||
|
{
|
||||||
|
return saveAs( window );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !window->model()->isModified() )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlLabelCreator::writeFile( window->model(), window->model()->fileName() );
|
||||||
window->model()->clearModified();
|
window->model()->clearModified();
|
||||||
|
|
||||||
// Save CWD
|
// Save CWD
|
||||||
mCwd = QFileInfo( fileName ).absolutePath();
|
mCwd = QFileInfo( window->model()->fileName() ).absolutePath();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Save file as
|
||||||
/// Close file
|
///
|
||||||
///
|
bool File::saveAs( MainWindow *window )
|
||||||
void File::close( MainWindow *window )
|
|
||||||
{
|
|
||||||
window->close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Exit, closing all windows
|
|
||||||
///
|
|
||||||
void File::exit()
|
|
||||||
{
|
|
||||||
foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
|
|
||||||
{
|
{
|
||||||
if ( MainWindow* window = qobject_cast<MainWindow*>(qwidget) )
|
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
||||||
|
QString cwd = mCwd;
|
||||||
|
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||||
{
|
{
|
||||||
window->close();
|
QFileInfo fileInfo( window->model()->fileName() );
|
||||||
|
if ( fileInfo.isFile() )
|
||||||
|
{
|
||||||
|
cwd = fileInfo.filePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString rawFileName =
|
||||||
|
QFileDialog::getSaveFileName( window,
|
||||||
|
tr("gLabels - Save Project As"),
|
||||||
|
cwd,
|
||||||
|
tr("glabels files (*.glabels);;All files (*)"),
|
||||||
|
0,
|
||||||
|
QFileDialog::DontConfirmOverwrite );
|
||||||
|
if ( !rawFileName.isEmpty() )
|
||||||
|
{
|
||||||
|
QString fileName = FileUtil::addExtension( rawFileName, ".glabels" );
|
||||||
|
|
||||||
|
|
||||||
|
if ( QFileInfo(fileName).exists() )
|
||||||
|
{
|
||||||
|
QMessageBox msgBox( window );
|
||||||
|
msgBox.setWindowTitle( tr("Save Label As") );
|
||||||
|
msgBox.setIcon( QMessageBox::Warning );
|
||||||
|
msgBox.setText( tr("%1 already exists.").arg(fileName) );
|
||||||
|
msgBox.setInformativeText( tr("Do you want to replace it?") );
|
||||||
|
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
|
||||||
|
msgBox.setDefaultButton( QMessageBox::No );
|
||||||
|
|
||||||
|
if ( msgBox.exec() == QMessageBox::No )
|
||||||
|
{
|
||||||
|
return saveAs( window );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlLabelCreator::writeFile( window->model(), fileName );
|
||||||
|
window->model()->setFileName( fileName );
|
||||||
|
window->model()->clearModified();
|
||||||
|
|
||||||
|
// Save CWD
|
||||||
|
mCwd = QFileInfo( fileName ).absolutePath();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Close file
|
||||||
|
///
|
||||||
|
void File::close( MainWindow *window )
|
||||||
|
{
|
||||||
|
window->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Exit, closing all windows
|
||||||
|
///
|
||||||
|
void File::exit()
|
||||||
|
{
|
||||||
|
foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
|
||||||
|
{
|
||||||
|
if ( MainWindow* window = qobject_cast<MainWindow*>(qwidget) )
|
||||||
|
{
|
||||||
|
window->close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-20
@@ -24,31 +24,37 @@
|
|||||||
|
|
||||||
#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
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
// Forward References
|
||||||
static bool newLabel( MainWindow *window = 0 );
|
class MainWindow;
|
||||||
static void open( MainWindow *window );
|
|
||||||
static bool save( MainWindow *window );
|
|
||||||
static bool saveAs( MainWindow *window );
|
|
||||||
static void close( MainWindow *window );
|
|
||||||
static void exit();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static QString mCwd;
|
|
||||||
|
|
||||||
};
|
///
|
||||||
|
/// File Actions
|
||||||
|
///
|
||||||
|
/// Note: class provides a translation context for these static functions.
|
||||||
|
///
|
||||||
|
class File : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static bool newLabel( MainWindow *window = 0 );
|
||||||
|
static void open( MainWindow *window );
|
||||||
|
static bool save( MainWindow *window );
|
||||||
|
static bool saveAs( MainWindow *window );
|
||||||
|
static void close( MainWindow *window );
|
||||||
|
static void exit();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QString mCwd;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // File_h
|
#endif // File_h
|
||||||
|
|||||||
+10
-5
@@ -21,17 +21,22 @@
|
|||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
||||||
|
|
||||||
namespace FileUtil
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
QString addExtension( const QString& rawFilename, const QString& extension )
|
namespace FileUtil
|
||||||
{
|
{
|
||||||
if ( rawFilename.endsWith( extension ) )
|
|
||||||
|
QString addExtension( const QString& rawFilename, const QString& extension )
|
||||||
{
|
{
|
||||||
return rawFilename;
|
if ( rawFilename.endsWith( extension ) )
|
||||||
|
{
|
||||||
|
return rawFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rawFilename + extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rawFilename + extension;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -25,10 +25,15 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace FileUtil
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
QString addExtension( const QString& rawFilename, const QString& extension );
|
namespace FileUtil
|
||||||
|
{
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
+557
-526
File diff suppressed because it is too large
Load Diff
+251
-245
@@ -27,304 +27,310 @@
|
|||||||
|
|
||||||
#include "Distance.h"
|
#include "Distance.h"
|
||||||
|
|
||||||
// Forward References
|
|
||||||
class LabelModelObject;
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
///
|
|
||||||
/// Handle Base Class
|
|
||||||
///
|
|
||||||
class Handle
|
|
||||||
{
|
{
|
||||||
////////////////////////////
|
|
||||||
// Location enumeration
|
// Forward References
|
||||||
////////////////////////////
|
class LabelModelObject;
|
||||||
public:
|
|
||||||
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Handle Base Class
|
||||||
////////////////////////////
|
///
|
||||||
protected:
|
class Handle
|
||||||
Handle( LabelModelObject* owner, Location location );
|
{
|
||||||
public:
|
////////////////////////////
|
||||||
virtual ~Handle();
|
// Location enumeration
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Duplication
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
virtual Handle* clone( LabelModelObject* newOwner ) const = 0;
|
protected:
|
||||||
|
Handle( LabelModelObject* owner, Location location );
|
||||||
|
public:
|
||||||
|
virtual ~Handle();
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Attribue Methods
|
// Duplication
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
LabelModelObject* owner() const;
|
virtual Handle* clone( LabelModelObject* newOwner ) const = 0;
|
||||||
Location location() const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Attribue Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
LabelModelObject* owner() const;
|
||||||
virtual void draw( QPainter* painter, double scale ) const = 0;
|
Location location() const;
|
||||||
virtual QPainterPath path( double scale ) const = 0;
|
|
||||||
protected:
|
|
||||||
void drawAt( QPainter* painter,
|
|
||||||
double scale,
|
|
||||||
const glabels::Distance& x,
|
|
||||||
const glabels::Distance& y,
|
|
||||||
QColor color ) const;
|
|
||||||
|
|
||||||
QPainterPath pathAt( double scale,
|
|
||||||
const glabels::Distance& x,
|
|
||||||
const glabels::Distance& y ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Protected Data
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
protected:
|
public:
|
||||||
LabelModelObject* mOwner;
|
virtual void draw( QPainter* painter, double scale ) const = 0;
|
||||||
Location mLocation;
|
virtual QPainterPath path( double scale ) const = 0;
|
||||||
|
protected:
|
||||||
|
void drawAt( QPainter* painter,
|
||||||
|
double scale,
|
||||||
|
const Distance& x,
|
||||||
|
const Distance& y,
|
||||||
|
QColor color ) const;
|
||||||
|
|
||||||
};
|
QPainterPath pathAt( double scale,
|
||||||
|
const Distance& x,
|
||||||
|
const Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleNorth Class
|
// Protected Data
|
||||||
///
|
////////////////////////////
|
||||||
class HandleNorth : public Handle
|
protected:
|
||||||
{
|
LabelModelObject* mOwner;
|
||||||
////////////////////////////
|
Location mLocation;
|
||||||
// Lifecycle Methods
|
|
||||||
////////////////////////////
|
};
|
||||||
public:
|
|
||||||
HandleNorth( LabelModelObject* owner );
|
|
||||||
virtual ~HandleNorth();
|
|
||||||
virtual HandleNorth* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleNorth Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleNorth : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleNorth( LabelModelObject* owner );
|
||||||
|
virtual ~HandleNorth();
|
||||||
|
virtual HandleNorth* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleNorthEast Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleNorthEast : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleNorthEast( LabelModelObject* owner );
|
|
||||||
virtual ~HandleNorthEast();
|
|
||||||
virtual HandleNorthEast* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleNorthEast Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleNorthEast : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleNorthEast( LabelModelObject* owner );
|
||||||
|
virtual ~HandleNorthEast();
|
||||||
|
virtual HandleNorthEast* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleEast Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleEast : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleEast( LabelModelObject* owner );
|
|
||||||
virtual ~HandleEast();
|
|
||||||
virtual HandleEast* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleEast Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleEast : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleEast( LabelModelObject* owner );
|
||||||
|
virtual ~HandleEast();
|
||||||
|
virtual HandleEast* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleSouthEast Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleSouthEast : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleSouthEast( LabelModelObject* owner );
|
|
||||||
virtual ~HandleSouthEast();
|
|
||||||
virtual HandleSouthEast* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleSouthEast Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleSouthEast : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleSouthEast( LabelModelObject* owner );
|
||||||
|
virtual ~HandleSouthEast();
|
||||||
|
virtual HandleSouthEast* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleSouth Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleSouth : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleSouth( LabelModelObject* owner );
|
|
||||||
virtual ~HandleSouth();
|
|
||||||
virtual HandleSouth* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleSouth Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleSouth : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleSouth( LabelModelObject* owner );
|
||||||
|
virtual ~HandleSouth();
|
||||||
|
virtual HandleSouth* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleSouthWest Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleSouthWest : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleSouthWest( LabelModelObject* owner );
|
|
||||||
virtual ~HandleSouthWest();
|
|
||||||
virtual HandleSouthWest* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleSouthWest Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleSouthWest : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleSouthWest( LabelModelObject* owner );
|
||||||
|
virtual ~HandleSouthWest();
|
||||||
|
virtual HandleSouthWest* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleWest Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleWest : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleWest( LabelModelObject* owner );
|
|
||||||
virtual ~HandleWest();
|
|
||||||
virtual HandleWest* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleWest Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleWest : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleWest( LabelModelObject* owner );
|
||||||
|
virtual ~HandleWest();
|
||||||
|
virtual HandleWest* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleNorthWest Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleNorthWest : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleNorthWest( LabelModelObject* owner );
|
|
||||||
virtual ~HandleNorthWest();
|
|
||||||
virtual HandleNorthWest* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleNorthWest Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleNorthWest : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleNorthWest( LabelModelObject* owner );
|
||||||
|
virtual ~HandleNorthWest();
|
||||||
|
virtual HandleNorthWest* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleP1 Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleP1 : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleP1( LabelModelObject* owner );
|
|
||||||
virtual ~HandleP1();
|
|
||||||
virtual HandleP1* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleP1 Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleP1 : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleP1( LabelModelObject* owner );
|
||||||
|
virtual ~HandleP1();
|
||||||
|
virtual HandleP1* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
///
|
////////////////////////////
|
||||||
/// HandleP2 Class
|
// Drawing Methods
|
||||||
///
|
////////////////////////////
|
||||||
class HandleP2 : public Handle
|
public:
|
||||||
{
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
////////////////////////////
|
virtual QPainterPath path( double scale ) const;
|
||||||
// Lifecycle Methods
|
};
|
||||||
////////////////////////////
|
|
||||||
public:
|
|
||||||
HandleP2( LabelModelObject* owner );
|
|
||||||
virtual ~HandleP2();
|
|
||||||
|
|
||||||
////////////////////////////
|
|
||||||
// Duplication
|
|
||||||
////////////////////////////
|
|
||||||
virtual HandleP2* clone( LabelModelObject* newOwner ) const;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Drawing Methods
|
/// HandleP2 Class
|
||||||
////////////////////////////
|
///
|
||||||
public:
|
class HandleP2 : public Handle
|
||||||
virtual void draw( QPainter* painter, double scale ) const;
|
{
|
||||||
virtual QPainterPath path( double scale ) const;
|
////////////////////////////
|
||||||
};
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
HandleP2( LabelModelObject* owner );
|
||||||
|
virtual ~HandleP2();
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// Duplication
|
||||||
|
////////////////////////////
|
||||||
|
virtual HandleP2* clone( LabelModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// Drawing Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
virtual void draw( QPainter* painter, double scale ) const;
|
||||||
|
virtual QPainterPath path( double scale ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // Handles_h
|
#endif // Handles_h
|
||||||
|
|||||||
+18
-13
@@ -26,20 +26,25 @@
|
|||||||
#include "AboutDialog.h"
|
#include "AboutDialog.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Display Help Contents
|
|
||||||
///
|
|
||||||
void Help::displayContents( QWidget *parent )
|
|
||||||
{
|
{
|
||||||
qDebug() << "TODO: Help::displayContents";
|
|
||||||
}
|
///
|
||||||
|
/// Display Help Contents
|
||||||
|
///
|
||||||
|
void Help::displayContents( QWidget *parent )
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-7
@@ -25,16 +25,20 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Help Actions
|
|
||||||
///
|
|
||||||
namespace Help
|
|
||||||
{
|
{
|
||||||
|
|
||||||
void displayContents( QWidget *parent );
|
///
|
||||||
void displayAbout( QWidget *parent );
|
/// Help Actions
|
||||||
|
///
|
||||||
|
namespace Help
|
||||||
|
{
|
||||||
|
|
||||||
|
void displayContents( QWidget *parent );
|
||||||
|
void displayAbout( QWidget *parent );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // Help_h
|
#endif // Help_h
|
||||||
|
|||||||
+308
-312
@@ -25,324 +25,320 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Glabels Icons
|
|
||||||
///
|
|
||||||
namespace Icons
|
|
||||||
{
|
{
|
||||||
|
|
||||||
class Arrow : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Arrow()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-arrow.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-arrow.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Barcode : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Barcode()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-barcode.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-barcode.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Box : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Box()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-box.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-box.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Ellipse : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Ellipse()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-ellipse.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-ellipse.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Image : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Image()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-image.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-image.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Line : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Line()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-line.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-line.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Text : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Text()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-text.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-text.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Merge : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Merge()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-merge.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-merge.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectProperties : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ObjectProperties()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-object-properties.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-object-properties.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignLeft : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignLeft()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-align-left.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignHCenter : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignHCenter()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-align-hcenter.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignRight : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignRight()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-align-right.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignBottom : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignBottom()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-align-bottom.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignVCenter : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignVCenter()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-align-vcenter.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignTop : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignTop()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-align-top.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CenterHoriz : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CenterHoriz()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-center-horiz.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CenterVert : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CenterVert()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-center-vert.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class FlipHoriz : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FlipHoriz()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-flip-horiz.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class FlipVert : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FlipVert()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-flip-vert.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class RotateLeft : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RotateLeft()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-rotate-left.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class RotateRight : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RotateRight()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-rotate-right.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class OrderBottom : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OrderBottom()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-order-bottom.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class OrderTop : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OrderTop()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-order-top.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignTextBottom : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignTextBottom()
|
|
||||||
{
|
|
||||||
addFile( ":icons/24x24/actions/glabels-align-text-bottom.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignTextMiddle : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignTextMiddle()
|
|
||||||
{
|
|
||||||
addFile( ":icons/24x24/actions/glabels-align-text-middle.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class AlignTextTop : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AlignTextTop()
|
|
||||||
{
|
|
||||||
addFile( ":icons/24x24/actions/glabels-align-text-top.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class BucketFill : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BucketFill()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-bucket-fill.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-bucket-fill.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Pencil : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Pencil()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/actions/glabels-pencil.png" );
|
|
||||||
addFile( ":icons/24x24/actions/glabels-pencil.png" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Glabels : public QIcon
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Glabels()
|
|
||||||
{
|
|
||||||
addFile( ":icons/16x16/apps/glabels.png" );
|
|
||||||
addFile( ":icons/24x24/apps/glabels.png" );
|
|
||||||
addFile( ":icons/32x32/apps/glabels.png" );
|
|
||||||
addFile( ":icons/48x48/apps/glabels.png" );
|
|
||||||
addFile( ":icons/scalable/apps/glabels.svg" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Fallback Icons. These are fallbacks for icons that would normally come from the current theme,
|
/// Glabels Icons
|
||||||
/// if supported. These icons are copied from the mate-icon-theme (GPL-v3 or CC-BY-SA-v3).
|
|
||||||
///
|
///
|
||||||
namespace Fallback
|
namespace Icons
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Arrow : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Arrow()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-arrow.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-arrow.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Barcode : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Barcode()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-barcode.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-barcode.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Box : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Box()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-box.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-box.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Ellipse : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Ellipse()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-ellipse.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-ellipse.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Image : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Image()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-image.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-image.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Line : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Line()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-line.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-line.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Text : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Text()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-text.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-text.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Merge : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Merge()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-merge.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-merge.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ObjectProperties : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjectProperties()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-object-properties.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-object-properties.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignLeft : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignLeft()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-align-left.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignHCenter : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignHCenter()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-align-hcenter.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignRight : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignRight()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-align-right.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignBottom : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignBottom()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-align-bottom.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignVCenter : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignVCenter()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-align-vcenter.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignTop : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignTop()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-align-top.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CenterHoriz : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CenterHoriz()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-center-horiz.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CenterVert : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CenterVert()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-center-vert.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class FlipHoriz : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FlipHoriz()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-flip-horiz.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class FlipVert : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FlipVert()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-flip-vert.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class RotateLeft : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RotateLeft()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-rotate-left.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class RotateRight : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RotateRight()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-rotate-right.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class OrderBottom : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OrderBottom()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-order-bottom.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class OrderTop : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OrderTop()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-order-top.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignTextBottom : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignTextBottom()
|
||||||
|
{
|
||||||
|
addFile( ":icons/24x24/actions/glabels-align-text-bottom.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignTextMiddle : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignTextMiddle()
|
||||||
|
{
|
||||||
|
addFile( ":icons/24x24/actions/glabels-align-text-middle.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AlignTextTop : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlignTextTop()
|
||||||
|
{
|
||||||
|
addFile( ":icons/24x24/actions/glabels-align-text-top.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BucketFill : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BucketFill()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-bucket-fill.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-bucket-fill.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Pencil : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Pencil()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/actions/glabels-pencil.png" );
|
||||||
|
addFile( ":icons/24x24/actions/glabels-pencil.png" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Glabels : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Glabels()
|
||||||
|
{
|
||||||
|
addFile( ":icons/16x16/apps/glabels.png" );
|
||||||
|
addFile( ":icons/24x24/apps/glabels.png" );
|
||||||
|
addFile( ":icons/32x32/apps/glabels.png" );
|
||||||
|
addFile( ":icons/48x48/apps/glabels.png" );
|
||||||
|
addFile( ":icons/scalable/apps/glabels.svg" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class EditCopy : public QIcon
|
class EditCopy : public QIcon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
+1142
-1139
File diff suppressed because it is too large
Load Diff
+163
-157
@@ -28,188 +28,194 @@
|
|||||||
|
|
||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
|
|
||||||
// Forward References
|
|
||||||
class LabelModel;
|
|
||||||
class LabelModelObject;
|
|
||||||
class UndoRedoModel;
|
|
||||||
class Handle;
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
///
|
|
||||||
/// LabelEditor Widget
|
|
||||||
///
|
|
||||||
class LabelEditor : public QWidget
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
// Forward References
|
||||||
// Lifecycle
|
class LabelModel;
|
||||||
/////////////////////////////////////
|
class LabelModelObject;
|
||||||
public:
|
class UndoRedoModel;
|
||||||
LabelEditor( QScrollArea* scrollArea, QWidget* parent = 0 );
|
class Handle;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
///
|
||||||
// Signals
|
/// LabelEditor Widget
|
||||||
/////////////////////////////////////
|
///
|
||||||
signals:
|
class LabelEditor : public QWidget
|
||||||
void contextMenuActivate();
|
{
|
||||||
void zoomChanged();
|
Q_OBJECT
|
||||||
void pointerMoved( const glabels::Distance& x, const glabels::Distance& y );
|
|
||||||
void pointerExited();
|
/////////////////////////////////////
|
||||||
void modeChanged();
|
// Lifecycle
|
||||||
|
/////////////////////////////////////
|
||||||
|
public:
|
||||||
|
LabelEditor( QScrollArea* scrollArea, QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Parameters
|
// Signals
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
signals:
|
||||||
double zoom() const;
|
void contextMenuActivate();
|
||||||
bool markupVisible() const;
|
void zoomChanged();
|
||||||
bool qridVisible() const;
|
void pointerMoved( const Distance& x, const Distance& y );
|
||||||
|
void pointerExited();
|
||||||
|
void modeChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Model
|
// Parameters
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel );
|
double zoom() const;
|
||||||
|
bool markupVisible() const;
|
||||||
|
bool qridVisible() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Visibility operations
|
// Model
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setGridVisible( bool visibleFlag );
|
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel );
|
||||||
void setMarkupVisible( bool visibleFlag );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Zoom operations
|
// Visibility operations
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void zoomIn();
|
void setGridVisible( bool visibleFlag );
|
||||||
void zoomOut();
|
void setMarkupVisible( bool visibleFlag );
|
||||||
void zoom1To1();
|
|
||||||
void zoomToFit();
|
|
||||||
bool isZoomMax() const;
|
|
||||||
bool isZoomMin() const;
|
|
||||||
private:
|
|
||||||
void setZoomReal( double zoom, bool zoomToFitFlag );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Mode operations
|
// Zoom operations
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void arrowMode();
|
void zoomIn();
|
||||||
void createBoxMode();
|
void zoomOut();
|
||||||
void createEllipseMode();
|
void zoom1To1();
|
||||||
void createLineMode();
|
void zoomToFit();
|
||||||
void createImageMode();
|
bool isZoomMax() const;
|
||||||
void createTextMode();
|
bool isZoomMin() const;
|
||||||
void createBarcodeMode();
|
private:
|
||||||
|
void setZoomReal( double zoom, bool zoomToFitFlag );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Event handlers
|
// Mode operations
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
protected:
|
public:
|
||||||
void resizeEvent( QResizeEvent* event );
|
void arrowMode();
|
||||||
void mousePressEvent( QMouseEvent* event );
|
void createBoxMode();
|
||||||
void mouseMoveEvent( QMouseEvent* event );
|
void createEllipseMode();
|
||||||
void mouseReleaseEvent( QMouseEvent* event );
|
void createLineMode();
|
||||||
void leaveEvent( QEvent* event );
|
void createImageMode();
|
||||||
void keyPressEvent( QKeyEvent* event );
|
void createTextMode();
|
||||||
void paintEvent( QPaintEvent* event );
|
void createBarcodeMode();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Private methods
|
// Event handlers
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
protected:
|
||||||
void handleResizeMotion( const glabels::Distance& xWorld,
|
void resizeEvent( QResizeEvent* event );
|
||||||
const glabels::Distance& yWorld );
|
void mousePressEvent( QMouseEvent* event );
|
||||||
|
void mouseMoveEvent( QMouseEvent* event );
|
||||||
void drawBgLayer( QPainter* painter );
|
void mouseReleaseEvent( QMouseEvent* event );
|
||||||
void drawGridLayer( QPainter* painter );
|
void leaveEvent( QEvent* event );
|
||||||
void drawMarkupLayer( QPainter* painter );
|
void keyPressEvent( QKeyEvent* event );
|
||||||
void drawObjectsLayer( QPainter* painter );
|
void paintEvent( QPaintEvent* event );
|
||||||
void drawFgLayer( QPainter* painter );
|
|
||||||
void drawHighlightLayer( QPainter* painter );
|
|
||||||
void drawSelectRegionLayer( QPainter* painter );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Private slots
|
// Private methods
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private slots:
|
private:
|
||||||
void onSettingsChanged();
|
void handleResizeMotion( const Distance& xWorld,
|
||||||
void onModelSizeChanged();
|
const Distance& yWorld );
|
||||||
|
|
||||||
|
void drawBgLayer( QPainter* painter );
|
||||||
|
void drawGridLayer( QPainter* painter );
|
||||||
|
void drawMarkupLayer( QPainter* painter );
|
||||||
|
void drawObjectsLayer( QPainter* painter );
|
||||||
|
void drawFgLayer( QPainter* painter );
|
||||||
|
void drawHighlightLayer( QPainter* painter );
|
||||||
|
void drawSelectRegionLayer( QPainter* painter );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Private slots
|
||||||
|
/////////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onSettingsChanged();
|
||||||
|
void onModelSizeChanged();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Private data
|
||||||
|
/////////////////////////////////////
|
||||||
|
private:
|
||||||
|
enum State {
|
||||||
|
IdleState,
|
||||||
|
ArrowSelectRegion,
|
||||||
|
ArrowMove,
|
||||||
|
ArrowResize,
|
||||||
|
CreateIdle,
|
||||||
|
CreateDrag
|
||||||
|
};
|
||||||
|
|
||||||
|
enum CreateType {
|
||||||
|
Box,
|
||||||
|
Ellipse,
|
||||||
|
Line,
|
||||||
|
Image,
|
||||||
|
Text,
|
||||||
|
Barcode
|
||||||
|
};
|
||||||
|
|
||||||
|
QScrollArea* mScrollArea;
|
||||||
|
|
||||||
|
double mZoom;
|
||||||
|
bool mZoomToFitFlag;
|
||||||
|
double mScale;
|
||||||
|
Distance mX0;
|
||||||
|
Distance mY0;
|
||||||
|
|
||||||
|
bool mMarkupVisible;
|
||||||
|
bool mGridVisible;
|
||||||
|
|
||||||
|
double mGridSpacing;
|
||||||
|
Distance mStepSize;
|
||||||
|
|
||||||
|
LabelModel* mModel;
|
||||||
|
UndoRedoModel* mUndoRedoModel;
|
||||||
|
|
||||||
|
State mState;
|
||||||
|
|
||||||
|
/* ArrowSelectRegion state */
|
||||||
|
bool mSelectRegionVisible;
|
||||||
|
Region mSelectRegion;
|
||||||
|
|
||||||
|
/* ArrowMove state */
|
||||||
|
Distance mMoveLastX;
|
||||||
|
Distance mMoveLastY;
|
||||||
|
|
||||||
|
/* ArrowResize state */
|
||||||
|
LabelModelObject* mResizeObject;
|
||||||
|
Handle* mResizeHandle;
|
||||||
|
bool mResizeHonorAspect;
|
||||||
|
|
||||||
|
/* CreateDrag state */
|
||||||
|
CreateType mCreateObjectType;
|
||||||
|
LabelModelObject* mCreateObject;
|
||||||
|
Distance mCreateX0;
|
||||||
|
Distance mCreateY0;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
|
||||||
// Private data
|
|
||||||
/////////////////////////////////////
|
|
||||||
private:
|
|
||||||
enum State {
|
|
||||||
IdleState,
|
|
||||||
ArrowSelectRegion,
|
|
||||||
ArrowMove,
|
|
||||||
ArrowResize,
|
|
||||||
CreateIdle,
|
|
||||||
CreateDrag
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CreateType {
|
}
|
||||||
Box,
|
|
||||||
Ellipse,
|
|
||||||
Line,
|
|
||||||
Image,
|
|
||||||
Text,
|
|
||||||
Barcode
|
|
||||||
};
|
|
||||||
|
|
||||||
QScrollArea* mScrollArea;
|
|
||||||
|
|
||||||
double mZoom;
|
|
||||||
bool mZoomToFitFlag;
|
|
||||||
double mScale;
|
|
||||||
glabels::Distance mX0;
|
|
||||||
glabels::Distance mY0;
|
|
||||||
|
|
||||||
bool mMarkupVisible;
|
|
||||||
bool mGridVisible;
|
|
||||||
|
|
||||||
double mGridSpacing;
|
|
||||||
glabels::Distance mStepSize;
|
|
||||||
|
|
||||||
LabelModel* mModel;
|
|
||||||
UndoRedoModel* mUndoRedoModel;
|
|
||||||
|
|
||||||
State mState;
|
|
||||||
|
|
||||||
/* ArrowSelectRegion state */
|
|
||||||
bool mSelectRegionVisible;
|
|
||||||
Region mSelectRegion;
|
|
||||||
|
|
||||||
/* ArrowMove state */
|
|
||||||
glabels::Distance mMoveLastX;
|
|
||||||
glabels::Distance mMoveLastY;
|
|
||||||
|
|
||||||
/* ArrowResize state */
|
|
||||||
LabelModelObject* mResizeObject;
|
|
||||||
Handle* mResizeHandle;
|
|
||||||
bool mResizeHonorAspect;
|
|
||||||
|
|
||||||
/* CreateDrag state */
|
|
||||||
CreateType mCreateObjectType;
|
|
||||||
LabelModelObject* mCreateObject;
|
|
||||||
glabels::Distance mCreateX0;
|
|
||||||
glabels::Distance mCreateY0;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelEditor_h
|
#endif // LabelEditor_h
|
||||||
|
|||||||
+1330
-1322
File diff suppressed because it is too large
Load Diff
+164
-161
@@ -32,205 +32,208 @@
|
|||||||
#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
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
// Forward References
|
||||||
|
class ColorNode;
|
||||||
|
class Handle;
|
||||||
|
class LabelModelObject;
|
||||||
|
class Region;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// LabelModel
|
||||||
|
///
|
||||||
|
class LabelModel : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModel();
|
LabelModel();
|
||||||
virtual ~LabelModel() {}
|
virtual ~LabelModel() {}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Save/restore model state
|
// Save/restore model state
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
LabelModel* save() const;
|
LabelModel* save() const;
|
||||||
void restore( const LabelModel *savedModel );
|
void restore( const LabelModel *savedModel );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
void modifiedChanged();
|
void modifiedChanged();
|
||||||
void mergeChanged();
|
void mergeChanged();
|
||||||
void mergeSourceChanged();
|
void mergeSourceChanged();
|
||||||
void mergeSelectionChanged();
|
void mergeSelectionChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool isModified() const;
|
bool isModified() const;
|
||||||
void setModified();
|
void setModified();
|
||||||
void clearModified();
|
void clearModified();
|
||||||
|
|
||||||
QString shortName();
|
QString shortName();
|
||||||
const QString& fileName() const;
|
const QString& fileName() const;
|
||||||
void setFileName( const QString &fileName );
|
void setFileName( const QString &fileName );
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
merge::Merge* merge() const;
|
merge::Merge* merge() const;
|
||||||
void setMerge( merge::Merge* merge );
|
void setMerge( merge::Merge* merge );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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();
|
||||||
void unselectAll();
|
void unselectAll();
|
||||||
void selectRegion( const Region& region );
|
void selectRegion( const Region& region );
|
||||||
bool isSelectionEmpty();
|
bool isSelectionEmpty();
|
||||||
bool isSelectionAtomic();
|
bool isSelectionAtomic();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Get selected objects
|
// Get selected objects
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QList<LabelModelObject*> getSelection();
|
QList<LabelModelObject*> getSelection();
|
||||||
LabelModelObject* getFirstSelectedObject();
|
LabelModelObject* getFirstSelectedObject();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Query selection capabilities
|
// Query selection capabilities
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool canSelectionText();
|
bool canSelectionText();
|
||||||
bool canSelectionFill();
|
bool canSelectionFill();
|
||||||
bool canSelectionLineColor();
|
bool canSelectionLineColor();
|
||||||
bool canSelectionLineWidth();
|
bool canSelectionLineWidth();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Operations on selections
|
// Operations on selections
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void deleteSelection();
|
void deleteSelection();
|
||||||
void raiseSelectionToTop();
|
void raiseSelectionToTop();
|
||||||
void lowerSelectionToBottom();
|
void lowerSelectionToBottom();
|
||||||
void rotateSelection( double thetaDegs );
|
void rotateSelection( double thetaDegs );
|
||||||
void rotateSelectionLeft();
|
void rotateSelectionLeft();
|
||||||
void rotateSelectionRight();
|
void rotateSelectionRight();
|
||||||
void flipSelectionHoriz();
|
void flipSelectionHoriz();
|
||||||
void flipSelectionVert();
|
void flipSelectionVert();
|
||||||
void alignSelectionLeft();
|
void alignSelectionLeft();
|
||||||
void alignSelectionRight();
|
void alignSelectionRight();
|
||||||
void alignSelectionHCenter();
|
void alignSelectionHCenter();
|
||||||
void alignSelectionTop();
|
void alignSelectionTop();
|
||||||
void alignSelectionBottom();
|
void alignSelectionBottom();
|
||||||
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 );
|
||||||
void setSelectionFontItalicFlag( bool fontItalicFlag );
|
void setSelectionFontItalicFlag( bool fontItalicFlag );
|
||||||
void setSelectionTextHAlign( Qt::Alignment textHAlign );
|
void setSelectionTextHAlign( Qt::Alignment textHAlign );
|
||||||
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 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Clipboard operations
|
// Clipboard operations
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
void copySelection();
|
void copySelection();
|
||||||
void cutSelection();
|
void cutSelection();
|
||||||
bool canPaste();
|
bool canPaste();
|
||||||
void paste();
|
void paste();
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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();
|
||||||
void onMergeSelectionChanged();
|
void onMergeSelectionChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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
|
||||||
|
|||||||
+127
-115
@@ -25,134 +25,146 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
const double slopPixels = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
///
|
// Private
|
||||||
/// Constructor
|
//
|
||||||
///
|
namespace
|
||||||
LabelModelBoxObject::LabelModelBoxObject()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Copy constructor
|
|
||||||
///
|
|
||||||
LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object ) : LabelModelShapeObject( object )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
LabelModelBoxObject::~LabelModelBoxObject()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Clone
|
|
||||||
///
|
|
||||||
LabelModelBoxObject* LabelModelBoxObject::clone() const
|
|
||||||
{
|
|
||||||
return new LabelModelBoxObject( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw shadow of object
|
|
||||||
///
|
|
||||||
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
|
||||||
|
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
|
||||||
|
|
||||||
if ( fillColor.alpha() )
|
|
||||||
{
|
{
|
||||||
painter->setPen( Qt::NoPen );
|
const double slopPixels = 2;
|
||||||
painter->setBrush( shadowColor );
|
}
|
||||||
|
|
||||||
if ( lineColor.alpha() )
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
LabelModelBoxObject::LabelModelBoxObject()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor
|
||||||
|
///
|
||||||
|
LabelModelBoxObject::LabelModelBoxObject( const LabelModelBoxObject* object )
|
||||||
|
: LabelModelShapeObject( object )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
LabelModelBoxObject::~LabelModelBoxObject()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clone
|
||||||
|
///
|
||||||
|
LabelModelBoxObject* LabelModelBoxObject::clone() const
|
||||||
|
{
|
||||||
|
return new LabelModelBoxObject( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw shadow of object
|
||||||
|
///
|
||||||
|
void LabelModelBoxObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
|
{
|
||||||
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
|
QColor shadowColor = mShadowColorNode.color( record );
|
||||||
|
|
||||||
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
|
if ( fillColor.alpha() )
|
||||||
{
|
{
|
||||||
/* Has FILL and OUTLINE: adjust size to account for line width. */
|
painter->setPen( Qt::NoPen );
|
||||||
painter->drawRect( QRectF( -mLineWidth.pt()/2,
|
painter->setBrush( shadowColor );
|
||||||
-mLineWidth.pt()/2,
|
|
||||||
(mW + mLineWidth).pt(),
|
if ( lineColor.alpha() )
|
||||||
(mH + mLineWidth).pt() ) );
|
{
|
||||||
|
/* Has FILL and OUTLINE: adjust size to account for line width. */
|
||||||
|
painter->drawRect( QRectF( -mLineWidth.pt()/2,
|
||||||
|
-mLineWidth.pt()/2,
|
||||||
|
(mW + mLineWidth).pt(),
|
||||||
|
(mH + mLineWidth).pt() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Has FILL, but no OUTLINE. */
|
||||||
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Has FILL, but no OUTLINE. */
|
if ( lineColor.alpha() )
|
||||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
{
|
||||||
|
/* Has only OUTLINE. */
|
||||||
|
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||||
|
painter->setBrush( Qt::NoBrush );
|
||||||
|
|
||||||
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw object itself
|
||||||
|
///
|
||||||
|
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
if ( lineColor.alpha() )
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
|
|
||||||
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
|
painter->setBrush( fillColor );
|
||||||
|
|
||||||
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Path to test for hover condition
|
||||||
|
///
|
||||||
|
QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
|
||||||
|
{
|
||||||
|
double s = 1 / scale;
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
|
if ( mFillColorNode.color().alpha() && mLineColorNode.color().alpha() )
|
||||||
{
|
{
|
||||||
/* Has only OUTLINE. */
|
path.addRect( -mLineWidth.pt()/2, -mLineWidth.pt()/2, (mW+mLineWidth).pt(), (mH+mLineWidth).pt() );
|
||||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
|
||||||
painter->setBrush( Qt::NoBrush );
|
|
||||||
|
|
||||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
|
||||||
}
|
}
|
||||||
|
else if ( mFillColorNode.color().alpha() && !(mLineColorNode.color().alpha()) )
|
||||||
|
{
|
||||||
|
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
}
|
||||||
|
else if ( mLineColorNode.color().alpha() )
|
||||||
|
{
|
||||||
|
path.addRect( (-mLineWidth.pt()/2) - s*slopPixels,
|
||||||
|
(-mLineWidth.pt()/2) - s*slopPixels,
|
||||||
|
(mW + mLineWidth).pt() + s*2*slopPixels,
|
||||||
|
(mH + mLineWidth).pt() + s*2*slopPixels );
|
||||||
|
path.closeSubpath();
|
||||||
|
path.addRect( mLineWidth.pt()/2 + s*slopPixels,
|
||||||
|
mLineWidth.pt()/2 + s*slopPixels,
|
||||||
|
(mW - mLineWidth).pt() - s*2*slopPixels,
|
||||||
|
(mH - mLineWidth).pt() - s*2*slopPixels );
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw object itself
|
|
||||||
///
|
|
||||||
void LabelModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
|
||||||
painter->setBrush( fillColor );
|
|
||||||
|
|
||||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Path to test for hover condition
|
|
||||||
///
|
|
||||||
QPainterPath LabelModelBoxObject::hoverPath( double scale ) const
|
|
||||||
{
|
|
||||||
double s = 1 / scale;
|
|
||||||
|
|
||||||
QPainterPath path;
|
|
||||||
|
|
||||||
if ( mFillColorNode.color().alpha() && mLineColorNode.color().alpha() )
|
|
||||||
{
|
|
||||||
path.addRect( -mLineWidth.pt()/2, -mLineWidth.pt()/2, (mW+mLineWidth).pt(), (mH+mLineWidth).pt() );
|
|
||||||
}
|
|
||||||
else if ( mFillColorNode.color().alpha() && !(mLineColorNode.color().alpha()) )
|
|
||||||
{
|
|
||||||
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
}
|
|
||||||
else if ( mLineColorNode.color().alpha() )
|
|
||||||
{
|
|
||||||
path.addRect( (-mLineWidth.pt()/2) - s*slopPixels,
|
|
||||||
(-mLineWidth.pt()/2) - s*slopPixels,
|
|
||||||
(mW + mLineWidth).pt() + s*2*slopPixels,
|
|
||||||
(mH + mLineWidth).pt() + s*2*slopPixels );
|
|
||||||
path.closeSubpath();
|
|
||||||
path.addRect( mLineWidth.pt()/2 + s*slopPixels,
|
|
||||||
mLineWidth.pt()/2 + s*slopPixels,
|
|
||||||
(mW - mLineWidth).pt() - s*2*slopPixels,
|
|
||||||
(mH - mLineWidth).pt() - s*2*slopPixels );
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,37 +25,42 @@
|
|||||||
#include "LabelModelShapeObject.h"
|
#include "LabelModelShapeObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Box Object
|
|
||||||
///
|
|
||||||
class LabelModelBoxObject : public LabelModelShapeObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Box Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class LabelModelBoxObject : public LabelModelShapeObject
|
||||||
LabelModelBoxObject();
|
{
|
||||||
LabelModelBoxObject( const LabelModelBoxObject* object );
|
Q_OBJECT
|
||||||
virtual ~LabelModelBoxObject();
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
|
LabelModelBoxObject();
|
||||||
|
LabelModelBoxObject( const LabelModelBoxObject* object );
|
||||||
|
virtual ~LabelModelBoxObject();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
virtual LabelModelBoxObject* clone() const;
|
virtual LabelModelBoxObject* clone() const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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
|
||||||
|
|||||||
+127
-115
@@ -25,134 +25,146 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
const double slopPixels = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
///
|
// Private
|
||||||
/// Constructor
|
//
|
||||||
///
|
namespace
|
||||||
LabelModelEllipseObject::LabelModelEllipseObject()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Copy constructor
|
|
||||||
///
|
|
||||||
LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject* object ) : LabelModelShapeObject( object )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
LabelModelEllipseObject::~LabelModelEllipseObject()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Clone
|
|
||||||
///
|
|
||||||
LabelModelEllipseObject* LabelModelEllipseObject::clone() const
|
|
||||||
{
|
|
||||||
return new LabelModelEllipseObject( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw shadow of object
|
|
||||||
///
|
|
||||||
void LabelModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
|
||||||
|
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
|
||||||
|
|
||||||
if ( fillColor.alpha() )
|
|
||||||
{
|
{
|
||||||
painter->setPen( Qt::NoPen );
|
const double slopPixels = 2;
|
||||||
painter->setBrush( shadowColor );
|
}
|
||||||
|
|
||||||
if ( lineColor.alpha() )
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
LabelModelEllipseObject::LabelModelEllipseObject()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor
|
||||||
|
///
|
||||||
|
LabelModelEllipseObject::LabelModelEllipseObject( const LabelModelEllipseObject* object )
|
||||||
|
: LabelModelShapeObject( object )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
LabelModelEllipseObject::~LabelModelEllipseObject()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clone
|
||||||
|
///
|
||||||
|
LabelModelEllipseObject* LabelModelEllipseObject::clone() const
|
||||||
|
{
|
||||||
|
return new LabelModelEllipseObject( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw shadow of object
|
||||||
|
///
|
||||||
|
void LabelModelEllipseObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
|
{
|
||||||
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
|
QColor shadowColor = mShadowColorNode.color( record );
|
||||||
|
|
||||||
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
|
if ( fillColor.alpha() )
|
||||||
{
|
{
|
||||||
/* Has FILL and OUTLINE: adjust size to account for line width. */
|
painter->setPen( Qt::NoPen );
|
||||||
painter->drawEllipse( QRectF( -mLineWidth.pt()/2,
|
painter->setBrush( shadowColor );
|
||||||
-mLineWidth.pt()/2,
|
|
||||||
(mW + mLineWidth).pt(),
|
if ( lineColor.alpha() )
|
||||||
(mH + mLineWidth).pt() ) );
|
{
|
||||||
|
/* Has FILL and OUTLINE: adjust size to account for line width. */
|
||||||
|
painter->drawEllipse( QRectF( -mLineWidth.pt()/2,
|
||||||
|
-mLineWidth.pt()/2,
|
||||||
|
(mW + mLineWidth).pt(),
|
||||||
|
(mH + mLineWidth).pt() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Has FILL, but no OUTLINE. */
|
||||||
|
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Has FILL, but no OUTLINE. */
|
if ( lineColor.alpha() )
|
||||||
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
{
|
||||||
|
/* Has only OUTLINE. */
|
||||||
|
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||||
|
painter->setBrush( Qt::NoBrush );
|
||||||
|
|
||||||
|
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw object itself
|
||||||
|
///
|
||||||
|
void LabelModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
if ( lineColor.alpha() )
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
|
|
||||||
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
|
painter->setBrush( fillColor );
|
||||||
|
|
||||||
|
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Path to test for hover condition
|
||||||
|
///
|
||||||
|
QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
|
||||||
|
{
|
||||||
|
double s = 1 / scale;
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
|
if ( mFillColorNode.color().alpha() && mLineColorNode.color().alpha() )
|
||||||
{
|
{
|
||||||
/* Has only OUTLINE. */
|
path.addEllipse( -mLineWidth.pt()/2, -mLineWidth.pt()/2, (mW+mLineWidth).pt(), (mH+mLineWidth).pt() );
|
||||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
|
||||||
painter->setBrush( Qt::NoBrush );
|
|
||||||
|
|
||||||
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
|
||||||
}
|
}
|
||||||
|
else if ( mFillColorNode.color().alpha() && !(mLineColorNode.color().alpha()) )
|
||||||
|
{
|
||||||
|
path.addEllipse( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
}
|
||||||
|
else if ( mLineColorNode.color().alpha() )
|
||||||
|
{
|
||||||
|
path.addEllipse( (-mLineWidth.pt()/2) - s*slopPixels,
|
||||||
|
(-mLineWidth.pt()/2) - s*slopPixels,
|
||||||
|
(mW + mLineWidth).pt() + s*2*slopPixels,
|
||||||
|
(mH + mLineWidth).pt() + s*2*slopPixels );
|
||||||
|
path.closeSubpath();
|
||||||
|
path.addEllipse( mLineWidth.pt()/2 + s*slopPixels,
|
||||||
|
mLineWidth.pt()/2 + s*slopPixels,
|
||||||
|
(mW - mLineWidth).pt() - s*2*slopPixels,
|
||||||
|
(mH - mLineWidth).pt() - s*2*slopPixels );
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw object itself
|
|
||||||
///
|
|
||||||
void LabelModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
|
||||||
painter->setBrush( fillColor );
|
|
||||||
|
|
||||||
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Path to test for hover condition
|
|
||||||
///
|
|
||||||
QPainterPath LabelModelEllipseObject::hoverPath( double scale ) const
|
|
||||||
{
|
|
||||||
double s = 1 / scale;
|
|
||||||
|
|
||||||
QPainterPath path;
|
|
||||||
|
|
||||||
if ( mFillColorNode.color().alpha() && mLineColorNode.color().alpha() )
|
|
||||||
{
|
|
||||||
path.addEllipse( -mLineWidth.pt()/2, -mLineWidth.pt()/2, (mW+mLineWidth).pt(), (mH+mLineWidth).pt() );
|
|
||||||
}
|
|
||||||
else if ( mFillColorNode.color().alpha() && !(mLineColorNode.color().alpha()) )
|
|
||||||
{
|
|
||||||
path.addEllipse( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
}
|
|
||||||
else if ( mLineColorNode.color().alpha() )
|
|
||||||
{
|
|
||||||
path.addEllipse( (-mLineWidth.pt()/2) - s*slopPixels,
|
|
||||||
(-mLineWidth.pt()/2) - s*slopPixels,
|
|
||||||
(mW + mLineWidth).pt() + s*2*slopPixels,
|
|
||||||
(mH + mLineWidth).pt() + s*2*slopPixels );
|
|
||||||
path.closeSubpath();
|
|
||||||
path.addEllipse( mLineWidth.pt()/2 + s*slopPixels,
|
|
||||||
mLineWidth.pt()/2 + s*slopPixels,
|
|
||||||
(mW - mLineWidth).pt() - s*2*slopPixels,
|
|
||||||
(mH - mLineWidth).pt() - s*2*slopPixels );
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,37 +25,42 @@
|
|||||||
#include "LabelModelShapeObject.h"
|
#include "LabelModelShapeObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Ellipse Object
|
|
||||||
///
|
|
||||||
class LabelModelEllipseObject : public LabelModelShapeObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Ellipse Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class LabelModelEllipseObject : public LabelModelShapeObject
|
||||||
LabelModelEllipseObject();
|
{
|
||||||
LabelModelEllipseObject( const LabelModelEllipseObject* object );
|
Q_OBJECT
|
||||||
virtual ~LabelModelEllipseObject();
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
|
LabelModelEllipseObject();
|
||||||
|
LabelModelEllipseObject( const LabelModelEllipseObject* object );
|
||||||
|
virtual ~LabelModelEllipseObject();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
virtual LabelModelEllipseObject* clone() const;
|
virtual LabelModelEllipseObject* clone() const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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
|
||||||
|
|||||||
+246
-246
@@ -30,287 +30,287 @@
|
|||||||
#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 );
|
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
|
||||||
mHandles << new HandleNorth( this );
|
|
||||||
mHandles << new HandleNorthEast( this );
|
|
||||||
mHandles << new HandleEast( this );
|
|
||||||
mHandles << new HandleSouthEast( this );
|
|
||||||
mHandles << new HandleSouth( this );
|
|
||||||
mHandles << new HandleSouthWest( this );
|
|
||||||
mHandles << new HandleWest( this );
|
|
||||||
|
|
||||||
if ( smDefaultImage == 0 )
|
|
||||||
{
|
{
|
||||||
smDefaultImage = new QImage( ":images/checkerboard.png" );
|
mOutline = new Outline( this );
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
mHandles << new HandleNorthWest( this );
|
||||||
|
mHandles << new HandleNorth( this );
|
||||||
|
mHandles << new HandleNorthEast( this );
|
||||||
|
mHandles << new HandleEast( this );
|
||||||
|
mHandles << new HandleSouthEast( this );
|
||||||
|
mHandles << new HandleSouth( this );
|
||||||
|
mHandles << new HandleSouthWest( this );
|
||||||
|
mHandles << new HandleWest( this );
|
||||||
|
|
||||||
///
|
if ( smDefaultImage == 0 )
|
||||||
/// Copy constructor
|
|
||||||
///
|
|
||||||
LabelModelImageObject::LabelModelImageObject( const LabelModelImageObject* object ) : LabelModelObject(object)
|
|
||||||
{
|
|
||||||
mFilenameNode = object->mFilenameNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
LabelModelImageObject::~LabelModelImageObject()
|
|
||||||
{
|
|
||||||
delete mOutline;
|
|
||||||
|
|
||||||
foreach( Handle* handle, mHandles )
|
|
||||||
{
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
mHandles.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Clone
|
|
||||||
///
|
|
||||||
LabelModelImageObject* LabelModelImageObject::clone() const
|
|
||||||
{
|
|
||||||
return new LabelModelImageObject( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Image filenameNode Property Getter
|
|
||||||
///
|
|
||||||
TextNode LabelModelImageObject::filenameNode( void ) const
|
|
||||||
{
|
|
||||||
return mFilenameNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Image filenameNode Property Setter
|
|
||||||
///
|
|
||||||
void LabelModelImageObject::setFilenameNode( const TextNode& value )
|
|
||||||
{
|
|
||||||
if ( mFilenameNode != value )
|
|
||||||
{
|
|
||||||
mFilenameNode = value;
|
|
||||||
loadImage();
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Image originalSize Property Getter (assumes 72 DPI, i.e. 1pixel == 1pt)
|
|
||||||
///
|
|
||||||
Size LabelModelImageObject::originalSize() const
|
|
||||||
{
|
|
||||||
Size size( glabels::Distance::pt(72), glabels::Distance::pt(72) );
|
|
||||||
|
|
||||||
if ( mImage )
|
|
||||||
{
|
|
||||||
QSize qsize = mImage->size();
|
|
||||||
size.setW( glabels::Distance::pt( qsize.width() ) );
|
|
||||||
size.setH( glabels::Distance::pt( qsize.height() ) );
|
|
||||||
}
|
|
||||||
else if ( mSvg )
|
|
||||||
{
|
|
||||||
QSize qsize = mSvg->defaultSize();
|
|
||||||
size.setW( glabels::Distance::pt( qsize.width() ) );
|
|
||||||
size.setH( glabels::Distance::pt( qsize.height() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw shadow of object
|
|
||||||
///
|
|
||||||
void LabelModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
|
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
|
||||||
|
|
||||||
if ( mImage && mImage->hasAlphaChannel() && (mImage->depth() == 32) )
|
|
||||||
{
|
|
||||||
QImage* shadowImage = createShadowImage( shadowColor );
|
|
||||||
painter->drawImage( destRect, *shadowImage );
|
|
||||||
delete shadowImage;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( mImage || inEditor )
|
|
||||||
{
|
{
|
||||||
painter->setBrush( shadowColor );
|
smDefaultImage = new QImage( ":images/checkerboard.png" );
|
||||||
painter->setPen( QPen( Qt::NoPen ) );
|
|
||||||
|
|
||||||
painter->drawRect( destRect );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
void LabelModelImageObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
LabelModelImageObject::LabelModelImageObject( const LabelModelImageObject* object ) : LabelModelObject(object)
|
||||||
{
|
|
||||||
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
|
|
||||||
if ( inEditor && (mFilenameNode.isField() || (!mImage && !mSvg) ) )
|
|
||||||
{
|
{
|
||||||
painter->save();
|
mFilenameNode = object->mFilenameNode;
|
||||||
painter->setRenderHint( QPainter::SmoothPixmapTransform, false );
|
|
||||||
painter->drawImage( destRect, *smDefaultImage );
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
else if ( mImage )
|
|
||||||
{
|
|
||||||
painter->drawImage( destRect, *mImage );
|
|
||||||
}
|
|
||||||
else if ( mSvg )
|
|
||||||
{
|
|
||||||
mSvg->render( painter, destRect );
|
|
||||||
}
|
|
||||||
else if ( mFilenameNode.isField() )
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Path to test for hover condition
|
|
||||||
///
|
|
||||||
QPainterPath LabelModelImageObject::hoverPath( double scale ) const
|
|
||||||
{
|
|
||||||
QPainterPath path;
|
|
||||||
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Load image
|
|
||||||
///
|
|
||||||
void LabelModelImageObject::loadImage()
|
|
||||||
{
|
|
||||||
if ( mImage )
|
|
||||||
{
|
|
||||||
delete mImage;
|
|
||||||
}
|
|
||||||
if ( mSvg )
|
|
||||||
{
|
|
||||||
delete mSvg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mFilenameNode.isField() )
|
|
||||||
{
|
|
||||||
mImage = 0;
|
|
||||||
mSvg = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QString filename = mFilenameNode.data();
|
|
||||||
QFileInfo fileInfo( filename );
|
|
||||||
|
|
||||||
if ( fileInfo.isReadable() )
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
LabelModelImageObject::~LabelModelImageObject()
|
||||||
|
{
|
||||||
|
delete mOutline;
|
||||||
|
|
||||||
|
foreach( Handle* handle, mHandles )
|
||||||
{
|
{
|
||||||
if ( (fileInfo.suffix() == "svg") || (fileInfo.suffix() == "SVG") )
|
delete handle;
|
||||||
|
}
|
||||||
|
mHandles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clone
|
||||||
|
///
|
||||||
|
LabelModelImageObject* LabelModelImageObject::clone() const
|
||||||
|
{
|
||||||
|
return new LabelModelImageObject( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Image filenameNode Property Getter
|
||||||
|
///
|
||||||
|
TextNode LabelModelImageObject::filenameNode( void ) const
|
||||||
|
{
|
||||||
|
return mFilenameNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Image filenameNode Property Setter
|
||||||
|
///
|
||||||
|
void LabelModelImageObject::setFilenameNode( const TextNode& value )
|
||||||
|
{
|
||||||
|
if ( mFilenameNode != value )
|
||||||
|
{
|
||||||
|
mFilenameNode = value;
|
||||||
|
loadImage();
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Image originalSize Property Getter (assumes 72 DPI, i.e. 1pixel == 1pt)
|
||||||
|
///
|
||||||
|
Size LabelModelImageObject::originalSize() const
|
||||||
|
{
|
||||||
|
Size size( Distance::pt(72), Distance::pt(72) );
|
||||||
|
|
||||||
|
if ( mImage )
|
||||||
|
{
|
||||||
|
QSize qsize = mImage->size();
|
||||||
|
size.setW( Distance::pt( qsize.width() ) );
|
||||||
|
size.setH( Distance::pt( qsize.height() ) );
|
||||||
|
}
|
||||||
|
else if ( mSvg )
|
||||||
|
{
|
||||||
|
QSize qsize = mSvg->defaultSize();
|
||||||
|
size.setW( Distance::pt( qsize.width() ) );
|
||||||
|
size.setH( Distance::pt( qsize.height() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw shadow of object
|
||||||
|
///
|
||||||
|
void LabelModelImageObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
|
{
|
||||||
|
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|
||||||
|
QColor shadowColor = mShadowColorNode.color( record );
|
||||||
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
|
if ( mImage && mImage->hasAlphaChannel() && (mImage->depth() == 32) )
|
||||||
|
{
|
||||||
|
QImage* shadowImage = createShadowImage( shadowColor );
|
||||||
|
painter->drawImage( destRect, *shadowImage );
|
||||||
|
delete shadowImage;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( mImage || inEditor )
|
||||||
{
|
{
|
||||||
mSvg = new QSvgRenderer( filename );
|
painter->setBrush( shadowColor );
|
||||||
if ( !mSvg->isValid() )
|
painter->setPen( QPen( Qt::NoPen ) );
|
||||||
{
|
|
||||||
mSvg = 0;
|
painter->drawRect( destRect );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Adjust size based on aspect ratio of SVG image
|
|
||||||
QRectF rect = mSvg->viewBoxF();
|
|
||||||
double aspectRatio = rect.height() / rect.width();
|
|
||||||
if ( mH > mW*aspectRatio )
|
|
||||||
{
|
|
||||||
mH = mW*aspectRatio;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mW = mH/aspectRatio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw object itself
|
||||||
|
///
|
||||||
|
void LabelModelImageObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
|
{
|
||||||
|
QRectF destRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|
||||||
|
if ( inEditor && (mFilenameNode.isField() || (!mImage && !mSvg) ) )
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHint( QPainter::SmoothPixmapTransform, false );
|
||||||
|
painter->drawImage( destRect, *smDefaultImage );
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
else if ( mImage )
|
||||||
|
{
|
||||||
|
painter->drawImage( destRect, *mImage );
|
||||||
|
}
|
||||||
|
else if ( mSvg )
|
||||||
|
{
|
||||||
|
mSvg->render( painter, destRect );
|
||||||
|
}
|
||||||
|
else if ( mFilenameNode.isField() )
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Path to test for hover condition
|
||||||
|
///
|
||||||
|
QPainterPath LabelModelImageObject::hoverPath( double scale ) const
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Load image
|
||||||
|
///
|
||||||
|
void LabelModelImageObject::loadImage()
|
||||||
|
{
|
||||||
|
if ( mImage )
|
||||||
|
{
|
||||||
|
delete mImage;
|
||||||
|
}
|
||||||
|
if ( mSvg )
|
||||||
|
{
|
||||||
|
delete mSvg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mFilenameNode.isField() )
|
||||||
|
{
|
||||||
|
mImage = 0;
|
||||||
|
mSvg = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString filename = mFilenameNode.data();
|
||||||
|
QFileInfo fileInfo( filename );
|
||||||
|
|
||||||
|
if ( fileInfo.isReadable() )
|
||||||
{
|
{
|
||||||
mImage = new QImage( filename );
|
if ( (fileInfo.suffix() == "svg") || (fileInfo.suffix() == "SVG") )
|
||||||
if ( mImage->isNull() )
|
|
||||||
{
|
{
|
||||||
mImage = 0;
|
mSvg = new QSvgRenderer( filename );
|
||||||
}
|
if ( !mSvg->isValid() )
|
||||||
else
|
|
||||||
{
|
|
||||||
// Adjust size based on aspect ratio of image
|
|
||||||
double imageW = mImage->width();
|
|
||||||
double imageH = mImage->height();
|
|
||||||
double aspectRatio = imageH / imageW;
|
|
||||||
if ( mH > mW*aspectRatio )
|
|
||||||
{
|
{
|
||||||
mH = mW*aspectRatio;
|
mSvg = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mW = mH/aspectRatio;
|
// Adjust size based on aspect ratio of SVG image
|
||||||
|
QRectF rect = mSvg->viewBoxF();
|
||||||
|
double aspectRatio = rect.height() / rect.width();
|
||||||
|
if ( mH > mW*aspectRatio )
|
||||||
|
{
|
||||||
|
mH = mW*aspectRatio;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mW = mH/aspectRatio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mImage = new QImage( filename );
|
||||||
|
if ( mImage->isNull() )
|
||||||
|
{
|
||||||
|
mImage = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Adjust size based on aspect ratio of image
|
||||||
|
double imageW = mImage->width();
|
||||||
|
double imageH = mImage->height();
|
||||||
|
double aspectRatio = imageH / imageW;
|
||||||
|
if ( mH > mW*aspectRatio )
|
||||||
|
{
|
||||||
|
mH = mW*aspectRatio;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mW = mH/aspectRatio;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// 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 g = color.green();
|
|
||||||
int b = color.blue();
|
|
||||||
int a = color.alpha();
|
|
||||||
|
|
||||||
QImage* shadow = new QImage( *mImage );
|
|
||||||
for ( int iy = 0; iy < shadow->height(); iy++ )
|
|
||||||
{
|
{
|
||||||
QRgb* scanLine = (QRgb*)shadow->scanLine( iy );
|
int r = color.red();
|
||||||
|
int g = color.green();
|
||||||
|
int b = color.blue();
|
||||||
|
int a = color.alpha();
|
||||||
|
|
||||||
for ( int ix = 0; ix < shadow->width(); ix++ )
|
QImage* shadow = new QImage( *mImage );
|
||||||
|
for ( int iy = 0; iy < shadow->height(); iy++ )
|
||||||
{
|
{
|
||||||
scanLine[ix] = qRgba( r, g, b, (a*qAlpha(scanLine[ix]))/255 );
|
QRgb* scanLine = (QRgb*)shadow->scanLine( iy );
|
||||||
|
|
||||||
|
for ( int ix = 0; ix < shadow->width(); ix++ )
|
||||||
|
{
|
||||||
|
scanLine[ix] = qRgba( r, g, b, (a*qAlpha(scanLine[ix]))/255 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shadow;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,76 +27,81 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Image Object
|
|
||||||
///
|
|
||||||
class LabelModelImageObject : public LabelModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Image Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class LabelModelImageObject : public LabelModelObject
|
||||||
LabelModelImageObject();
|
{
|
||||||
LabelModelImageObject( const LabelModelImageObject* object );
|
Q_OBJECT
|
||||||
virtual ~LabelModelImageObject();
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
|
LabelModelImageObject();
|
||||||
|
LabelModelImageObject( const LabelModelImageObject* object );
|
||||||
|
virtual ~LabelModelImageObject();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
virtual LabelModelImageObject* clone() const;
|
virtual LabelModelImageObject* clone() const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Image Property: filenameNode
|
// Image Property: filenameNode
|
||||||
//
|
//
|
||||||
virtual TextNode filenameNode( void ) const;
|
virtual TextNode filenameNode( void ) const;
|
||||||
virtual void setFilenameNode( const TextNode& value );
|
virtual void setFilenameNode( const TextNode& value );
|
||||||
|
|
||||||
//
|
//
|
||||||
// Image Property: originalSize
|
// Image Property: originalSize
|
||||||
//
|
//
|
||||||
virtual Size originalSize() const;
|
virtual Size originalSize() const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private
|
// Private
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
void loadImage();
|
void loadImage();
|
||||||
QImage* createShadowImage( const QColor& color ) const;
|
QImage* createShadowImage( const QColor& color ) const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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
|
||||||
|
|||||||
+156
-147
@@ -25,176 +25,185 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace glabels
|
||||||
{
|
{
|
||||||
const double slopPixels = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
///
|
// Private
|
||||||
/// Constructor
|
//
|
||||||
///
|
namespace
|
||||||
LabelModelLineObject::LabelModelLineObject()
|
|
||||||
{
|
|
||||||
mOutline = 0;
|
|
||||||
|
|
||||||
mHandles << new HandleP1( this );
|
|
||||||
mHandles << new HandleP2( this );
|
|
||||||
|
|
||||||
mLineWidth = 1.0;
|
|
||||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Copy constructor
|
|
||||||
///
|
|
||||||
LabelModelLineObject::LabelModelLineObject( const LabelModelLineObject* object ) : LabelModelObject(object)
|
|
||||||
{
|
|
||||||
mLineWidth = object->mLineWidth;
|
|
||||||
mLineColorNode = object->mLineColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
LabelModelLineObject::~LabelModelLineObject()
|
|
||||||
{
|
|
||||||
foreach( Handle* handle, mHandles )
|
|
||||||
{
|
{
|
||||||
delete handle;
|
const double slopPixels = 2;
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Constructor
|
||||||
///
|
///
|
||||||
LabelModelLineObject* LabelModelLineObject::clone() const
|
LabelModelLineObject::LabelModelLineObject()
|
||||||
{
|
|
||||||
return new LabelModelLineObject( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Width Property Getter
|
|
||||||
///
|
|
||||||
glabels::Distance LabelModelLineObject::lineWidth( void ) const
|
|
||||||
{
|
|
||||||
return mLineWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Width Property Setter
|
|
||||||
///
|
|
||||||
void LabelModelLineObject::setLineWidth( const glabels::Distance& value )
|
|
||||||
{
|
|
||||||
if ( mLineWidth != value )
|
|
||||||
{
|
{
|
||||||
mLineWidth = value;
|
mOutline = 0;
|
||||||
emit changed();
|
|
||||||
|
mHandles << new HandleP1( this );
|
||||||
|
mHandles << new HandleP2( this );
|
||||||
|
|
||||||
|
mLineWidth = 1.0;
|
||||||
|
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Color Node Property Getter
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
ColorNode LabelModelLineObject::lineColorNode( void ) const
|
LabelModelLineObject::LabelModelLineObject( const LabelModelLineObject* object )
|
||||||
{
|
: LabelModelObject(object)
|
||||||
return mLineColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Color Node Property Setter
|
|
||||||
///
|
|
||||||
void LabelModelLineObject::setLineColorNode( const ColorNode& value )
|
|
||||||
{
|
|
||||||
if ( mLineColorNode != value )
|
|
||||||
{
|
{
|
||||||
mLineColorNode = value;
|
mLineWidth = object->mLineWidth;
|
||||||
emit changed();
|
mLineColorNode = object->mLineColorNode;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Line Color Capability Implementation
|
/// Destructor
|
||||||
///
|
///
|
||||||
bool LabelModelLineObject::canLineColor()
|
LabelModelLineObject::~LabelModelLineObject()
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Line Width Capability Implementation
|
|
||||||
///
|
|
||||||
bool LabelModelLineObject::canLineWidth()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw shadow of object
|
|
||||||
///
|
|
||||||
void LabelModelLineObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
|
||||||
QColor shadowColor = mShadowColorNode.color( record );
|
|
||||||
|
|
||||||
shadowColor.setAlphaF( mShadowOpacity );
|
|
||||||
|
|
||||||
if ( lineColor.alpha() )
|
|
||||||
{
|
{
|
||||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
foreach( Handle* handle, mHandles )
|
||||||
|
{
|
||||||
|
delete handle;
|
||||||
|
}
|
||||||
|
mHandles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clone
|
||||||
|
///
|
||||||
|
LabelModelLineObject* LabelModelLineObject::clone() const
|
||||||
|
{
|
||||||
|
return new LabelModelLineObject( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Width Property Getter
|
||||||
|
///
|
||||||
|
Distance LabelModelLineObject::lineWidth( void ) const
|
||||||
|
{
|
||||||
|
return mLineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Width Property Setter
|
||||||
|
///
|
||||||
|
void LabelModelLineObject::setLineWidth( const Distance& value )
|
||||||
|
{
|
||||||
|
if ( mLineWidth != value )
|
||||||
|
{
|
||||||
|
mLineWidth = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Color Node Property Getter
|
||||||
|
///
|
||||||
|
ColorNode LabelModelLineObject::lineColorNode( void ) const
|
||||||
|
{
|
||||||
|
return mLineColorNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Color Node Property Setter
|
||||||
|
///
|
||||||
|
void LabelModelLineObject::setLineColorNode( const ColorNode& value )
|
||||||
|
{
|
||||||
|
if ( mLineColorNode != value )
|
||||||
|
{
|
||||||
|
mLineColorNode = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Line Color Capability Implementation
|
||||||
|
///
|
||||||
|
bool LabelModelLineObject::canLineColor()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Line Width Capability Implementation
|
||||||
|
///
|
||||||
|
bool LabelModelLineObject::canLineWidth()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw shadow of object
|
||||||
|
///
|
||||||
|
void LabelModelLineObject::drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
|
{
|
||||||
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
|
QColor shadowColor = mShadowColorNode.color( record );
|
||||||
|
|
||||||
|
shadowColor.setAlphaF( mShadowOpacity );
|
||||||
|
|
||||||
|
if ( lineColor.alpha() )
|
||||||
|
{
|
||||||
|
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||||
|
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw object itself
|
||||||
|
///
|
||||||
|
void LabelModelLineObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
|
{
|
||||||
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
|
|
||||||
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Path to test for hover condition
|
||||||
///
|
///
|
||||||
void LabelModelLineObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
QPainterPath LabelModelLineObject::hoverPath( double scale ) const
|
||||||
{
|
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
|
||||||
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Path to test for hover condition
|
|
||||||
///
|
|
||||||
QPainterPath LabelModelLineObject::hoverPath( double scale ) const
|
|
||||||
{
|
|
||||||
QPainterPath path;
|
|
||||||
|
|
||||||
if ( mLineColorNode.color().alpha() )
|
|
||||||
{
|
{
|
||||||
//
|
QPainterPath path;
|
||||||
// Build a thin rectangle representing line
|
|
||||||
//
|
|
||||||
double rPts = mLineWidth.pt()/2 + slopPixels / scale;
|
|
||||||
|
|
||||||
double lengthPts = sqrt( mW.pt()*mW.pt() + mH.pt()*mH.pt() );
|
if ( mLineColorNode.color().alpha() )
|
||||||
double dx = mH.pt() / lengthPts; // horizontal pitch of perpendicular line
|
{
|
||||||
double dy = mW.pt() / lengthPts; // vertical pitch of perpendicular line
|
//
|
||||||
|
// Build a thin rectangle representing line
|
||||||
|
//
|
||||||
|
double rPts = mLineWidth.pt()/2 + slopPixels / scale;
|
||||||
|
|
||||||
path.moveTo( rPts*dx, - rPts*dy );
|
double lengthPts = sqrt( mW.pt()*mW.pt() + mH.pt()*mH.pt() );
|
||||||
path.lineTo( mW.pt() + rPts*dx, mH.pt() - rPts*dy );
|
double dx = mH.pt() / lengthPts; // horizontal pitch of perpendicular line
|
||||||
path.lineTo( mW.pt() - rPts*dx, mH.pt() + rPts*dy );
|
double dy = mW.pt() / lengthPts; // vertical pitch of perpendicular line
|
||||||
path.lineTo( - rPts*dx, rPts*dy );
|
|
||||||
|
|
||||||
path.closeSubpath();
|
path.moveTo( rPts*dx, - rPts*dy );
|
||||||
|
path.lineTo( mW.pt() + rPts*dx, mH.pt() - rPts*dy );
|
||||||
|
path.lineTo( mW.pt() - rPts*dx, mH.pt() + rPts*dy );
|
||||||
|
path.lineTo( - rPts*dx, rPts*dy );
|
||||||
|
|
||||||
|
path.closeSubpath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,71 +25,76 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Line Object
|
|
||||||
///
|
|
||||||
class LabelModelLineObject : public LabelModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Line Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class LabelModelLineObject : public LabelModelObject
|
||||||
LabelModelLineObject();
|
{
|
||||||
LabelModelLineObject( const LabelModelLineObject* object );
|
Q_OBJECT
|
||||||
virtual ~LabelModelLineObject();
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
|
LabelModelLineObject();
|
||||||
|
LabelModelLineObject( const LabelModelLineObject* object );
|
||||||
|
virtual ~LabelModelLineObject();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
virtual LabelModelLineObject* clone() const;
|
virtual LabelModelLineObject* clone() const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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 );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Line Property: lineColorNode
|
// Line Property: lineColorNode
|
||||||
//
|
//
|
||||||
virtual ColorNode lineColorNode( void ) const;
|
virtual ColorNode lineColorNode( void ) const;
|
||||||
virtual void setLineColorNode( const ColorNode& value );
|
virtual void setLineColorNode( const ColorNode& value );
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canLineColor();
|
virtual bool canLineColor();
|
||||||
virtual bool canLineWidth();
|
virtual bool canLineWidth();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
glabels::Distance mLineWidth;
|
Distance mLineWidth;
|
||||||
ColorNode mLineColorNode;
|
ColorNode mLineColorNode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelLineObject_h
|
#endif // LabelModelLineObject_h
|
||||||
|
|||||||
+1027
-1002
File diff suppressed because it is too large
Load Diff
+314
-309
@@ -37,366 +37,371 @@
|
|||||||
#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
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
// Forward References
|
||||||
// Lifecycle Methods
|
class Region;
|
||||||
///////////////////////////////////////////////////////////////
|
class Size;
|
||||||
protected:
|
|
||||||
LabelModelObject();
|
|
||||||
LabelModelObject( const LabelModelObject* object );
|
|
||||||
public:
|
|
||||||
virtual ~LabelModelObject();
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Object duplication
|
/// Label Model Object Base Class
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
virtual LabelModelObject* clone() const = 0;
|
class LabelModelObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
protected:
|
||||||
|
LabelModelObject();
|
||||||
|
LabelModelObject( const LabelModelObject* object );
|
||||||
|
public:
|
||||||
|
virtual ~LabelModelObject();
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void moved();
|
|
||||||
void changed();
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
virtual LabelModelObject* clone() const = 0;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
// Common Properties
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
public:
|
|
||||||
//
|
|
||||||
// ID Property.
|
|
||||||
//
|
|
||||||
int id() const;
|
|
||||||
|
|
||||||
//
|
///////////////////////////////////////////////////////////////
|
||||||
// Selected Property.
|
// Signals
|
||||||
//
|
///////////////////////////////////////////////////////////////
|
||||||
bool isSelected() const;
|
signals:
|
||||||
void select( bool value = true );
|
void moved();
|
||||||
void unselect();
|
void changed();
|
||||||
|
|
||||||
|
|
||||||
//
|
///////////////////////////////////////////////////////////////
|
||||||
// x0 Property ( x coordinate of origin )
|
// Common Properties
|
||||||
//
|
///////////////////////////////////////////////////////////////
|
||||||
glabels::Distance x0() const;
|
public:
|
||||||
void setX0( const glabels::Distance& value );
|
//
|
||||||
|
// ID Property.
|
||||||
|
//
|
||||||
|
int id() const;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Selected Property.
|
||||||
|
//
|
||||||
|
bool isSelected() const;
|
||||||
|
void select( bool value = true );
|
||||||
|
void unselect();
|
||||||
|
|
||||||
//
|
|
||||||
// y0 Property ( y coordinate of origin )
|
|
||||||
//
|
|
||||||
glabels::Distance y0() const;
|
|
||||||
void setY0( const glabels::Distance& value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// x0 Property ( x coordinate of origin )
|
||||||
|
//
|
||||||
|
Distance x0() const;
|
||||||
|
void setX0( const Distance& value );
|
||||||
|
|
||||||
//
|
|
||||||
// w Property ( width of bounding box )
|
|
||||||
//
|
|
||||||
glabels::Distance w() const;
|
|
||||||
void setW( const glabels::Distance& value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// y0 Property ( y coordinate of origin )
|
||||||
|
//
|
||||||
|
Distance y0() const;
|
||||||
|
void setY0( const Distance& value );
|
||||||
|
|
||||||
//
|
|
||||||
// h Property ( height of bounding box )
|
|
||||||
//
|
|
||||||
glabels::Distance h() const;
|
|
||||||
void setH( const glabels::Distance& value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// w Property ( width of bounding box )
|
||||||
|
//
|
||||||
|
Distance w() const;
|
||||||
|
void setW( const Distance& value );
|
||||||
|
|
||||||
//
|
|
||||||
// Transformation Matrix Property
|
|
||||||
//
|
|
||||||
QMatrix matrix() const;
|
|
||||||
void setMatrix( const QMatrix& value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// h Property ( height of bounding box )
|
||||||
|
//
|
||||||
|
Distance h() const;
|
||||||
|
void setH( const Distance& value );
|
||||||
|
|
||||||
//
|
|
||||||
// Shadow State Property
|
|
||||||
//
|
|
||||||
bool shadow() const;
|
|
||||||
void setShadow( bool value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Transformation Matrix Property
|
||||||
|
//
|
||||||
|
QMatrix matrix() const;
|
||||||
|
void setMatrix( const QMatrix& value );
|
||||||
|
|
||||||
//
|
|
||||||
// Shadow x Offset Property
|
|
||||||
//
|
|
||||||
glabels::Distance shadowX() const;
|
|
||||||
void setShadowX( const glabels::Distance& value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Shadow State Property
|
||||||
|
//
|
||||||
|
bool shadow() const;
|
||||||
|
void setShadow( bool value );
|
||||||
|
|
||||||
//
|
|
||||||
// Shadow y Offset Property
|
|
||||||
//
|
|
||||||
glabels::Distance shadowY() const;
|
|
||||||
void setShadowY( const glabels::Distance& value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Shadow x Offset Property
|
||||||
|
//
|
||||||
|
Distance shadowX() const;
|
||||||
|
void setShadowX( const Distance& value );
|
||||||
|
|
||||||
//
|
|
||||||
// Shadow opacity Property
|
|
||||||
//
|
|
||||||
double shadowOpacity() const;
|
|
||||||
void setShadowOpacity( double value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Shadow y Offset Property
|
||||||
|
//
|
||||||
|
Distance shadowY() const;
|
||||||
|
void setShadowY( const Distance& value );
|
||||||
|
|
||||||
//
|
|
||||||
// Shadow Color Property
|
|
||||||
//
|
|
||||||
ColorNode shadowColorNode() const;
|
|
||||||
void setShadowColorNode( const ColorNode& value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Shadow opacity Property
|
||||||
|
//
|
||||||
|
double shadowOpacity() const;
|
||||||
|
void setShadowOpacity( double value );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
// Text Properties Virtual Interface
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
public:
|
|
||||||
//
|
|
||||||
// Virtual Text Property: text
|
|
||||||
//
|
|
||||||
virtual QString text() const;
|
|
||||||
virtual void setText( const QString &value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Shadow Color Property
|
||||||
|
//
|
||||||
|
ColorNode shadowColorNode() const;
|
||||||
|
void setShadowColorNode( const ColorNode& value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: fontFamily
|
|
||||||
//
|
|
||||||
virtual QString fontFamily() const;
|
|
||||||
virtual void setFontFamily( const QString &value );
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Text Properties Virtual Interface
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Virtual Text Property: text
|
||||||
|
//
|
||||||
|
virtual QString text() const;
|
||||||
|
virtual void setText( const QString &value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: fontSize
|
|
||||||
//
|
|
||||||
virtual double fontSize() const;
|
|
||||||
virtual void setFontSize( double value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Text Property: fontFamily
|
||||||
|
//
|
||||||
|
virtual QString fontFamily() const;
|
||||||
|
virtual void setFontFamily( const QString &value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: fontWeight
|
|
||||||
//
|
|
||||||
virtual QFont::Weight fontWeight() const;
|
|
||||||
virtual void setFontWeight( QFont::Weight value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Text Property: fontSize
|
||||||
|
//
|
||||||
|
virtual double fontSize() const;
|
||||||
|
virtual void setFontSize( double value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: fontItalicFlag
|
|
||||||
//
|
|
||||||
virtual bool fontItalicFlag() const;
|
|
||||||
virtual void setFontItalicFlag( bool value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Text Property: fontWeight
|
||||||
|
//
|
||||||
|
virtual QFont::Weight fontWeight() const;
|
||||||
|
virtual void setFontWeight( QFont::Weight value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: fontUnderlineFlag
|
|
||||||
//
|
|
||||||
virtual bool fontUnderlineFlag() const;
|
|
||||||
virtual void setFontUnderlineFlag( bool value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Text Property: fontItalicFlag
|
||||||
|
//
|
||||||
|
virtual bool fontItalicFlag() const;
|
||||||
|
virtual void setFontItalicFlag( bool value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: textColorNode
|
|
||||||
//
|
|
||||||
virtual ColorNode textColorNode() const;
|
|
||||||
virtual void setTextColorNode( const ColorNode &value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Text Property: fontUnderlineFlag
|
||||||
|
//
|
||||||
|
virtual bool fontUnderlineFlag() const;
|
||||||
|
virtual void setFontUnderlineFlag( bool value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: textHAlign
|
|
||||||
//
|
|
||||||
virtual Qt::Alignment textHAlign() const;
|
|
||||||
virtual void setTextHAlign( Qt::Alignment value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Text Property: textColorNode
|
||||||
|
//
|
||||||
|
virtual ColorNode textColorNode() const;
|
||||||
|
virtual void setTextColorNode( const ColorNode &value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: textVAlign
|
|
||||||
//
|
|
||||||
virtual Qt::Alignment textVAlign() const;
|
|
||||||
virtual void setTextVAlign( Qt::Alignment value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Text Property: textHAlign
|
||||||
|
//
|
||||||
|
virtual Qt::Alignment textHAlign() const;
|
||||||
|
virtual void setTextHAlign( Qt::Alignment value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Text Property: textLineSpacing
|
|
||||||
//
|
|
||||||
virtual double textLineSpacing() const;
|
|
||||||
virtual void setTextLineSpacing( double value );
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Text Property: textVAlign
|
||||||
|
//
|
||||||
|
virtual Qt::Alignment textVAlign() const;
|
||||||
|
virtual void setTextVAlign( Qt::Alignment value );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
// Image Properties Virtual Interface
|
//
|
||||||
///////////////////////////////////////////////////////////////
|
// Virtual Text Property: textLineSpacing
|
||||||
public:
|
//
|
||||||
//
|
virtual double textLineSpacing() const;
|
||||||
// Virtual Image Property: filenameNode
|
virtual void setTextLineSpacing( double value );
|
||||||
//
|
|
||||||
virtual TextNode filenameNode() const;
|
|
||||||
virtual void setFilenameNode( const TextNode &value );
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Image Properties Virtual Interface
|
||||||
//
|
///////////////////////////////////////////////////////////////
|
||||||
// Virtual Image Property: originalSize (read-only)
|
public:
|
||||||
//
|
//
|
||||||
virtual Size originalSize() const;
|
// Virtual Image Property: filenameNode
|
||||||
|
//
|
||||||
|
virtual TextNode filenameNode() const;
|
||||||
///////////////////////////////////////////////////////////////
|
virtual void setFilenameNode( const TextNode &value );
|
||||||
// Shape Properties Virtual Interface
|
|
||||||
///////////////////////////////////////////////////////////////
|
//
|
||||||
public:
|
// Virtual Image Property: originalSize (read-only)
|
||||||
//
|
//
|
||||||
// Virtual Shape Property: lineWidth
|
virtual Size originalSize() const;
|
||||||
//
|
|
||||||
virtual glabels::Distance lineWidth() const;
|
|
||||||
virtual void setLineWidth( const glabels::Distance& value );
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Shape Properties Virtual Interface
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
//
|
public:
|
||||||
// Virtual Shape Property: lineColorNode
|
//
|
||||||
//
|
// Virtual Shape Property: lineWidth
|
||||||
virtual ColorNode lineColorNode() const;
|
//
|
||||||
virtual void setLineColorNode( const ColorNode &value );
|
virtual Distance lineWidth() const;
|
||||||
|
virtual void setLineWidth( const Distance& value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Shape Property: fillColorNode
|
//
|
||||||
//
|
// Virtual Shape Property: lineColorNode
|
||||||
virtual ColorNode fillColorNode() const;
|
//
|
||||||
virtual void setFillColorNode( const ColorNode &value );
|
virtual ColorNode lineColorNode() const;
|
||||||
|
virtual void setLineColorNode( const ColorNode &value );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
// Barcode Properties Virtual Interface
|
//
|
||||||
///////////////////////////////////////////////////////////////
|
// Virtual Shape Property: fillColorNode
|
||||||
public:
|
//
|
||||||
//
|
virtual ColorNode fillColorNode() const;
|
||||||
// Virtual Barcode Property: bcDataNode
|
virtual void setFillColorNode( const ColorNode &value );
|
||||||
//
|
|
||||||
virtual TextNode bcDataNode() const;
|
|
||||||
virtual void setBcDataNode( const TextNode &value );
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Barcode Properties Virtual Interface
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
//
|
public:
|
||||||
// Virtual Barcode Property: bcTextFlag
|
//
|
||||||
//
|
// Virtual Barcode Property: bcDataNode
|
||||||
virtual bool bcTextFlag() const;
|
//
|
||||||
virtual void setBcTextFlag( bool value );
|
virtual TextNode bcDataNode() const;
|
||||||
|
virtual void setBcDataNode( const TextNode &value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Barcode Property: bcChecksumFlag
|
//
|
||||||
//
|
// Virtual Barcode Property: bcTextFlag
|
||||||
virtual bool bcChecksumFlag() const;
|
//
|
||||||
virtual void setBcChecksumFlag( bool value );
|
virtual bool bcTextFlag() const;
|
||||||
|
virtual void setBcTextFlag( bool value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Barcode Property: bcColorNode
|
//
|
||||||
//
|
// Virtual Barcode Property: bcChecksumFlag
|
||||||
virtual ColorNode bcColorNode() const;
|
//
|
||||||
virtual void setBcColorNode( const ColorNode &value );
|
virtual bool bcChecksumFlag() const;
|
||||||
|
virtual void setBcChecksumFlag( bool value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Barcode Property: bcStyle
|
//
|
||||||
//
|
// Virtual Barcode Property: bcColorNode
|
||||||
virtual BarcodeStyle bcStyle() const;
|
//
|
||||||
virtual void setBcStyle( const BarcodeStyle &value );
|
virtual ColorNode bcColorNode() const;
|
||||||
|
virtual void setBcColorNode( const ColorNode &value );
|
||||||
|
|
||||||
//
|
|
||||||
// Virtual Barcode Property: bcFormatDigits
|
//
|
||||||
//
|
// Virtual Barcode Property: bcStyle
|
||||||
virtual int bcFormatDigits() const;
|
//
|
||||||
virtual void setBcFormatDigits( int value );
|
virtual BarcodeStyle bcStyle() const;
|
||||||
|
virtual void setBcStyle( const BarcodeStyle &value );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
// Capabilities (Overridden by concrete classes.)
|
//
|
||||||
///////////////////////////////////////////////////////////////
|
// Virtual Barcode Property: bcFormatDigits
|
||||||
public:
|
//
|
||||||
virtual bool canText() const;
|
virtual int bcFormatDigits() const;
|
||||||
virtual bool canFill() const;
|
virtual void setBcFormatDigits( int value );
|
||||||
virtual bool canLineColor() const;
|
|
||||||
virtual bool canLineWidth() const;
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Capabilities (Overridden by concrete classes.)
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Position and Size methods
|
public:
|
||||||
///////////////////////////////////////////////////////////////
|
virtual bool canText() const;
|
||||||
public:
|
virtual bool canFill() const;
|
||||||
void setPosition( const glabels::Distance& x0, const glabels::Distance& y0 );
|
virtual bool canLineColor() const;
|
||||||
void setPositionRelative( const glabels::Distance& dx, const glabels::Distance& dy );
|
virtual bool canLineWidth() const;
|
||||||
Size size() const;
|
|
||||||
void setSize( const glabels::Distance& w, const glabels::Distance& h );
|
|
||||||
void setSize( const Size& size );
|
///////////////////////////////////////////////////////////////
|
||||||
void setSizeHonorAspect( const glabels::Distance& w, const glabels::Distance& h );
|
// Position and Size methods
|
||||||
void setWHonorAspect( const glabels::Distance& w );
|
///////////////////////////////////////////////////////////////
|
||||||
void setHHonorAspect( const glabels::Distance& h );
|
public:
|
||||||
Region getExtent();
|
void setPosition( const Distance& x0, const Distance& y0 );
|
||||||
void rotate( double thetaDegs );
|
void setPositionRelative( const Distance& dx, const Distance& dy );
|
||||||
void flipHoriz();
|
Size size() const;
|
||||||
void flipVert();
|
void setSize( const Distance& w, const Distance& h );
|
||||||
bool isLocatedAt( double scale, const glabels::Distance& x, const glabels::Distance& y ) const;
|
void setSize( const Size& size );
|
||||||
Handle* handleAt( double scale, const glabels::Distance& x, const glabels::Distance& y ) const;
|
void setSizeHonorAspect( const Distance& w, const Distance& h );
|
||||||
|
void setWHonorAspect( const Distance& w );
|
||||||
|
void setHHonorAspect( const Distance& h );
|
||||||
///////////////////////////////////////////////////////////////
|
Region getExtent();
|
||||||
// Drawing operations
|
void rotate( double thetaDegs );
|
||||||
///////////////////////////////////////////////////////////////
|
void flipHoriz();
|
||||||
public:
|
void flipVert();
|
||||||
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
bool isLocatedAt( double scale, const Distance& x, const Distance& y ) const;
|
||||||
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
Handle* handleAt( double scale, const Distance& x, const Distance& y ) const;
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
///////////////////////////////////////////////////////////////
|
||||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
// Drawing operations
|
||||||
virtual QPainterPath hoverPath( double scale ) const = 0;
|
///////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
virtual void sizeUpdated();
|
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||||
|
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
protected:
|
||||||
// Protected Members
|
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||||
///////////////////////////////////////////////////////////////
|
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||||
protected:
|
virtual QPainterPath hoverPath( double scale ) const = 0;
|
||||||
bool mSelectedFlag;
|
|
||||||
|
virtual void sizeUpdated();
|
||||||
glabels::Distance mX0;
|
|
||||||
glabels::Distance mY0;
|
|
||||||
glabels::Distance mW;
|
///////////////////////////////////////////////////////////////
|
||||||
glabels::Distance mH;
|
// Protected Members
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
bool mShadowState;
|
protected:
|
||||||
glabels::Distance mShadowX;
|
bool mSelectedFlag;
|
||||||
glabels::Distance mShadowY;
|
|
||||||
double mShadowOpacity;
|
Distance mX0;
|
||||||
ColorNode mShadowColorNode;
|
Distance mY0;
|
||||||
|
Distance mW;
|
||||||
QList<Handle*> mHandles;
|
Distance mH;
|
||||||
Outline* mOutline;
|
|
||||||
|
bool mShadowState;
|
||||||
|
Distance mShadowX;
|
||||||
///////////////////////////////////////////////////////////////
|
Distance mShadowY;
|
||||||
// Private Members
|
double mShadowOpacity;
|
||||||
///////////////////////////////////////////////////////////////
|
ColorNode mShadowColorNode;
|
||||||
private:
|
|
||||||
static int msNextId;
|
QList<Handle*> mHandles;
|
||||||
int mId;
|
Outline* mOutline;
|
||||||
|
|
||||||
QMatrix mMatrix;
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
};
|
// Private Members
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
private:
|
||||||
|
static int msNextId;
|
||||||
|
int mId;
|
||||||
|
|
||||||
|
QMatrix mMatrix;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelObject_h
|
#endif // LabelModelObject_h
|
||||||
|
|||||||
+127
-122
@@ -25,142 +25,147 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
LabelModelShapeObject::LabelModelShapeObject()
|
|
||||||
{
|
{
|
||||||
mOutline = new Outline( this );
|
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
///
|
||||||
mHandles << new HandleNorth( this );
|
/// Constructor
|
||||||
mHandles << new HandleNorthEast( this );
|
///
|
||||||
mHandles << new HandleEast( this );
|
LabelModelShapeObject::LabelModelShapeObject()
|
||||||
mHandles << new HandleSouthEast( this );
|
|
||||||
mHandles << new HandleSouth( this );
|
|
||||||
mHandles << new HandleSouthWest( this );
|
|
||||||
mHandles << new HandleWest( this );
|
|
||||||
|
|
||||||
mLineWidth = 1.0;
|
|
||||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
|
||||||
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Copy constructor
|
|
||||||
///
|
|
||||||
LabelModelShapeObject::LabelModelShapeObject( const LabelModelShapeObject* object ) : LabelModelObject(object)
|
|
||||||
{
|
|
||||||
mLineWidth = object->mLineWidth;
|
|
||||||
mLineColorNode = object->mLineColorNode;
|
|
||||||
mFillColorNode = object->mFillColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
LabelModelShapeObject::~LabelModelShapeObject()
|
|
||||||
{
|
|
||||||
delete mOutline;
|
|
||||||
|
|
||||||
foreach( Handle* handle, mHandles )
|
|
||||||
{
|
{
|
||||||
delete handle;
|
mOutline = new Outline( this );
|
||||||
|
|
||||||
|
mHandles << new HandleNorthWest( this );
|
||||||
|
mHandles << new HandleNorth( this );
|
||||||
|
mHandles << new HandleNorthEast( this );
|
||||||
|
mHandles << new HandleEast( this );
|
||||||
|
mHandles << new HandleSouthEast( this );
|
||||||
|
mHandles << new HandleSouth( this );
|
||||||
|
mHandles << new HandleSouthWest( this );
|
||||||
|
mHandles << new HandleWest( this );
|
||||||
|
|
||||||
|
mLineWidth = 1.0;
|
||||||
|
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||||
|
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Width Property Getter
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
glabels::Distance LabelModelShapeObject::lineWidth( void ) const
|
LabelModelShapeObject::LabelModelShapeObject( const LabelModelShapeObject* object ) : LabelModelObject(object)
|
||||||
{
|
|
||||||
return mLineWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Width Property Setter
|
|
||||||
///
|
|
||||||
void LabelModelShapeObject::setLineWidth( const glabels::Distance& value )
|
|
||||||
{
|
|
||||||
if ( mLineWidth != value )
|
|
||||||
{
|
{
|
||||||
mLineWidth = value;
|
mLineWidth = object->mLineWidth;
|
||||||
emit changed();
|
mLineColorNode = object->mLineColorNode;
|
||||||
|
mFillColorNode = object->mFillColorNode;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Color Node Property Getter
|
/// Destructor
|
||||||
///
|
///
|
||||||
ColorNode LabelModelShapeObject::lineColorNode( void ) const
|
LabelModelShapeObject::~LabelModelShapeObject()
|
||||||
{
|
|
||||||
return mLineColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Color Node Property Setter
|
|
||||||
///
|
|
||||||
void LabelModelShapeObject::setLineColorNode( const ColorNode& value )
|
|
||||||
{
|
|
||||||
if ( mLineColorNode != value )
|
|
||||||
{
|
{
|
||||||
mLineColorNode = value;
|
delete mOutline;
|
||||||
emit changed();
|
|
||||||
|
foreach( Handle* handle, mHandles )
|
||||||
|
{
|
||||||
|
delete handle;
|
||||||
|
}
|
||||||
|
mHandles.clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Fill Color Node Property Getter
|
/// Line Width Property Getter
|
||||||
///
|
///
|
||||||
ColorNode LabelModelShapeObject::fillColorNode( void ) const
|
Distance LabelModelShapeObject::lineWidth( void ) const
|
||||||
{
|
|
||||||
return mFillColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Fill Color Node Property Setter
|
|
||||||
///
|
|
||||||
void LabelModelShapeObject::setFillColorNode( const ColorNode& value )
|
|
||||||
{
|
|
||||||
if ( mFillColorNode != value )
|
|
||||||
{
|
{
|
||||||
mFillColorNode = value;
|
return mLineWidth;
|
||||||
emit changed();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Line Width Property Setter
|
||||||
/// Can Fill Capability Implementation
|
///
|
||||||
///
|
void LabelModelShapeObject::setLineWidth( const Distance& value )
|
||||||
bool LabelModelShapeObject::canFill()
|
{
|
||||||
{
|
if ( mLineWidth != value )
|
||||||
return true;
|
{
|
||||||
}
|
mLineWidth = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
///
|
}
|
||||||
/// Can Line Color Capability Implementation
|
|
||||||
///
|
|
||||||
bool LabelModelShapeObject::canLineColor()
|
///
|
||||||
{
|
/// Line Color Node Property Getter
|
||||||
return true;
|
///
|
||||||
}
|
ColorNode LabelModelShapeObject::lineColorNode( void ) const
|
||||||
|
{
|
||||||
|
return mLineColorNode;
|
||||||
///
|
}
|
||||||
/// Can Line Width Capability Implementation
|
|
||||||
///
|
|
||||||
bool LabelModelShapeObject::canLineWidth()
|
///
|
||||||
{
|
/// Line Color Node Property Setter
|
||||||
return true;
|
///
|
||||||
|
void LabelModelShapeObject::setLineColorNode( const ColorNode& value )
|
||||||
|
{
|
||||||
|
if ( mLineColorNode != value )
|
||||||
|
{
|
||||||
|
mLineColorNode = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fill Color Node Property Getter
|
||||||
|
///
|
||||||
|
ColorNode LabelModelShapeObject::fillColorNode( void ) const
|
||||||
|
{
|
||||||
|
return mFillColorNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fill Color Node Property Setter
|
||||||
|
///
|
||||||
|
void LabelModelShapeObject::setFillColorNode( const ColorNode& value )
|
||||||
|
{
|
||||||
|
if ( mFillColorNode != value )
|
||||||
|
{
|
||||||
|
mFillColorNode = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Fill Capability Implementation
|
||||||
|
///
|
||||||
|
bool LabelModelShapeObject::canFill()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Line Color Capability Implementation
|
||||||
|
///
|
||||||
|
bool LabelModelShapeObject::canLineColor()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Line Width Capability Implementation
|
||||||
|
///
|
||||||
|
bool LabelModelShapeObject::canLineWidth()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,66 +25,71 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Shape Object (Box or Ellipse)
|
|
||||||
///
|
|
||||||
class LabelModelShapeObject : public LabelModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Shape Object (Box or Ellipse)
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
protected:
|
class LabelModelShapeObject : public LabelModelObject
|
||||||
LabelModelShapeObject();
|
{
|
||||||
LabelModelShapeObject( const LabelModelShapeObject* object );
|
Q_OBJECT
|
||||||
public:
|
|
||||||
virtual ~LabelModelShapeObject();
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
protected:
|
||||||
|
LabelModelShapeObject();
|
||||||
|
LabelModelShapeObject( const LabelModelShapeObject* object );
|
||||||
|
public:
|
||||||
|
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 );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shape Property: lineColorNode
|
// Shape Property: lineColorNode
|
||||||
//
|
//
|
||||||
virtual ColorNode lineColorNode( void ) const;
|
virtual ColorNode lineColorNode( void ) const;
|
||||||
virtual void setLineColorNode( const ColorNode& value );
|
virtual void setLineColorNode( const ColorNode& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shape Property: fillColorNode
|
// Shape Property: fillColorNode
|
||||||
//
|
//
|
||||||
virtual ColorNode fillColorNode( void ) const;
|
virtual ColorNode fillColorNode( void ) const;
|
||||||
virtual void setFillColorNode( const ColorNode& value );
|
virtual void setFillColorNode( const ColorNode& value );
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canFill();
|
virtual bool canFill();
|
||||||
virtual bool canLineColor();
|
virtual bool canLineColor();
|
||||||
virtual bool canLineWidth();
|
virtual bool canLineWidth();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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
|
||||||
|
|||||||
+535
-520
File diff suppressed because it is too large
Load Diff
+113
-108
@@ -27,148 +27,153 @@
|
|||||||
#include "LabelModelObject.h"
|
#include "LabelModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Label Model Line Object
|
|
||||||
///
|
|
||||||
class LabelModelTextObject : public LabelModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Line Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class LabelModelTextObject : public LabelModelObject
|
||||||
LabelModelTextObject();
|
{
|
||||||
LabelModelTextObject( const LabelModelTextObject* object );
|
Q_OBJECT
|
||||||
virtual ~LabelModelTextObject();
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
|
LabelModelTextObject();
|
||||||
|
LabelModelTextObject( const LabelModelTextObject* object );
|
||||||
|
virtual ~LabelModelTextObject();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
virtual LabelModelTextObject* clone() const;
|
virtual LabelModelTextObject* clone() const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Text Property: text
|
// Text Property: text
|
||||||
//
|
//
|
||||||
virtual QString text() const;
|
virtual QString text() const;
|
||||||
virtual void setText( const QString &value );
|
virtual void setText( const QString &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontFamily
|
// Text Property: fontFamily
|
||||||
//
|
//
|
||||||
virtual QString fontFamily() const;
|
virtual QString fontFamily() const;
|
||||||
virtual void setFontFamily( const QString &value );
|
virtual void setFontFamily( const QString &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontSize
|
// Text Property: fontSize
|
||||||
//
|
//
|
||||||
virtual double fontSize() const;
|
virtual double fontSize() const;
|
||||||
virtual void setFontSize( double value );
|
virtual void setFontSize( double value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontWeight
|
// Text Property: fontWeight
|
||||||
//
|
//
|
||||||
virtual QFont::Weight fontWeight() const;
|
virtual QFont::Weight fontWeight() const;
|
||||||
virtual void setFontWeight( QFont::Weight value );
|
virtual void setFontWeight( QFont::Weight value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontItalicFlag
|
// Text Property: fontItalicFlag
|
||||||
//
|
//
|
||||||
virtual bool fontItalicFlag() const;
|
virtual bool fontItalicFlag() const;
|
||||||
virtual void setFontItalicFlag( bool value );
|
virtual void setFontItalicFlag( bool value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontUnderlineFlag
|
// Text Property: fontUnderlineFlag
|
||||||
//
|
//
|
||||||
virtual bool fontUnderlineFlag() const;
|
virtual bool fontUnderlineFlag() const;
|
||||||
virtual void setFontUnderlineFlag( bool value );
|
virtual void setFontUnderlineFlag( bool value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: textColorNode
|
// Text Property: textColorNode
|
||||||
//
|
//
|
||||||
virtual ColorNode textColorNode() const;
|
virtual ColorNode textColorNode() const;
|
||||||
virtual void setTextColorNode( const ColorNode &value );
|
virtual void setTextColorNode( const ColorNode &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: textHAlign
|
// Text Property: textHAlign
|
||||||
//
|
//
|
||||||
virtual Qt::Alignment textHAlign() const;
|
virtual Qt::Alignment textHAlign() const;
|
||||||
virtual void setTextHAlign( Qt::Alignment value );
|
virtual void setTextHAlign( Qt::Alignment value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: textVAlign
|
// Text Property: textVAlign
|
||||||
//
|
//
|
||||||
virtual Qt::Alignment textVAlign() const;
|
virtual Qt::Alignment textVAlign() const;
|
||||||
virtual void setTextVAlign( Qt::Alignment value );
|
virtual void setTextVAlign( Qt::Alignment value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: textLineSpacing
|
// Text Property: textLineSpacing
|
||||||
//
|
//
|
||||||
virtual double textLineSpacing() const;
|
virtual double textLineSpacing() const;
|
||||||
virtual void setTextLineSpacing( double value );
|
virtual void setTextLineSpacing( double value );
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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;
|
||||||
void drawText( QPainter* painter, const QColor&color, merge::Record* record ) const;
|
void drawText( QPainter* painter, const QColor&color, merge::Record* record ) const;
|
||||||
QString expandText( QString text, merge::Record* record ) const;
|
QString expandText( QString text, merge::Record* record ) const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QString mText;
|
QString mText;
|
||||||
QString mFontFamily;
|
QString mFontFamily;
|
||||||
double mFontSize;
|
double mFontSize;
|
||||||
QFont::Weight mFontWeight;
|
QFont::Weight mFontWeight;
|
||||||
bool mFontItalicFlag;
|
bool mFontItalicFlag;
|
||||||
bool mFontUnderlineFlag;
|
bool mFontUnderlineFlag;
|
||||||
ColorNode mTextColorNode;
|
ColorNode mTextColorNode;
|
||||||
Qt::Alignment mTextHAlign;
|
Qt::Alignment mTextHAlign;
|
||||||
Qt::Alignment mTextVAlign;
|
Qt::Alignment mTextVAlign;
|
||||||
double mTextLineSpacing;
|
double mTextLineSpacing;
|
||||||
|
|
||||||
QList<QTextLayout*> mEditorLayouts;
|
QList<QTextLayout*> mEditorLayouts;
|
||||||
QPainterPath mHoverPath;
|
QPainterPath mHoverPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // LabelModelTextObject_h
|
#endif // LabelModelTextObject_h
|
||||||
|
|||||||
+9
-7
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,12 +87,12 @@ namespace glabels
|
|||||||
|
|
||||||
bool Layout::isSimilarTo( const Layout *other )
|
bool Layout::isSimilarTo( const Layout *other )
|
||||||
{
|
{
|
||||||
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) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1443
-1436
File diff suppressed because it is too large
Load Diff
+227
-220
@@ -33,257 +33,264 @@
|
|||||||
#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
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
// Forward References
|
||||||
|
class LabelEditor;
|
||||||
|
class LabelModel;
|
||||||
|
class MergeView;
|
||||||
|
class ObjectEditor;
|
||||||
|
class PrintView;
|
||||||
|
class PropertiesView;
|
||||||
|
class StartupView;
|
||||||
|
class UndoRedoModel;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
///
|
||||||
// Lifecycle
|
/// MainWindow Widget
|
||||||
/////////////////////////////////////
|
///
|
||||||
public:
|
class MainWindow : public QMainWindow
|
||||||
MainWindow();
|
{
|
||||||
virtual ~MainWindow();
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Public Methods
|
// Lifecycle
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
LabelModel* model() const;
|
MainWindow();
|
||||||
void setModel( LabelModel* label );
|
virtual ~MainWindow();
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Events
|
// Public Methods
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
protected:
|
public:
|
||||||
void closeEvent( QCloseEvent *event );
|
LabelModel* model() const;
|
||||||
|
void setModel( LabelModel* label );
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Slots
|
// Events
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private slots:
|
protected:
|
||||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
void closeEvent( QCloseEvent *event );
|
||||||
|
|
||||||
void clipboardChanged();
|
|
||||||
|
|
||||||
void fileNew();
|
|
||||||
void fileOpen();
|
|
||||||
void fileSave();
|
|
||||||
void fileSaveAs();
|
|
||||||
void fileTemplateDesigner();
|
|
||||||
void fileClose();
|
|
||||||
void fileExit();
|
|
||||||
|
|
||||||
void editUndo();
|
|
||||||
void editRedo();
|
|
||||||
void editCut();
|
|
||||||
void editCopy();
|
|
||||||
void editPaste();
|
|
||||||
void editDelete();
|
|
||||||
void editSelectAll();
|
|
||||||
void editUnSelectAll();
|
|
||||||
void editPreferences();
|
|
||||||
|
|
||||||
void viewFileToolBar( bool );
|
|
||||||
void viewEditorToolBar( bool );
|
|
||||||
void viewGrid( bool );
|
|
||||||
void viewMarkup( bool );
|
|
||||||
void viewZoomIn();
|
|
||||||
void viewZoomOut();
|
|
||||||
void viewZoom1To1();
|
|
||||||
void viewZoomToFit();
|
|
||||||
|
|
||||||
void objectsArrowMode();
|
|
||||||
void objectsCreateText();
|
|
||||||
void objectsCreateBox();
|
|
||||||
void objectsCreateLine();
|
|
||||||
void objectsCreateEllipse();
|
|
||||||
void objectsCreateImage();
|
|
||||||
void objectsCreateBarcode();
|
|
||||||
void objectsOrderRaise();
|
|
||||||
void objectsOrderLower();
|
|
||||||
void objectsXformRotateLeft();
|
|
||||||
void objectsXformRotateRight();
|
|
||||||
void objectsXformFlipHoriz();
|
|
||||||
void objectsXformFlipVert();
|
|
||||||
void objectsAlignLeft();
|
|
||||||
void objectsAlignHCenter();
|
|
||||||
void objectsAlignRight();
|
|
||||||
void objectsAlignTop();
|
|
||||||
void objectsAlignVCenter();
|
|
||||||
void objectsAlignBottom();
|
|
||||||
void objectsCenterHoriz();
|
|
||||||
void objectsCenterVert();
|
|
||||||
|
|
||||||
void helpContents();
|
|
||||||
void helpAbout();
|
|
||||||
|
|
||||||
void onContextMenuActivate();
|
|
||||||
|
|
||||||
void onZoomChanged();
|
|
||||||
void onPointerMoved( double, double );
|
|
||||||
void onPointerExit();
|
|
||||||
|
|
||||||
void onNameChanged();
|
|
||||||
void onModifiedChanged();
|
|
||||||
void onSelectionChanged();
|
|
||||||
void onLabelChanged();
|
|
||||||
void onUndoRedoChanged();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Internal Private Methods
|
// Slots
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
private slots:
|
||||||
void createActions();
|
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||||
void createMenus();
|
|
||||||
void createToolBars();
|
|
||||||
void createStatusBar();
|
|
||||||
|
|
||||||
QWidget* createWelcomePage();
|
void clipboardChanged();
|
||||||
QWidget* createPropertiesPage();
|
|
||||||
QWidget* createEditorPage();
|
|
||||||
QWidget* createMergePage();
|
|
||||||
QWidget* createPrintPage();
|
|
||||||
|
|
||||||
void setWelcomeMode( bool );
|
void fileNew();
|
||||||
void setDocVerbsEnabled( bool );
|
void fileOpen();
|
||||||
void setDocModifiedVerbsEnabled( bool );
|
void fileSave();
|
||||||
void setPasteVerbsEnabled( bool );
|
void fileSaveAs();
|
||||||
void setSelectionVerbsEnabled( bool );
|
void fileTemplateDesigner();
|
||||||
void setMultiSelectionVerbsEnabled( bool );
|
void fileClose();
|
||||||
|
void fileExit();
|
||||||
|
|
||||||
void setTitle();
|
void editUndo();
|
||||||
|
void editRedo();
|
||||||
|
void editCut();
|
||||||
|
void editCopy();
|
||||||
|
void editPaste();
|
||||||
|
void editDelete();
|
||||||
|
void editSelectAll();
|
||||||
|
void editUnSelectAll();
|
||||||
|
void editPreferences();
|
||||||
|
|
||||||
void readSettings();
|
void viewFileToolBar( bool );
|
||||||
void writeSettings();
|
void viewEditorToolBar( bool );
|
||||||
|
void viewGrid( bool );
|
||||||
|
void viewMarkup( bool );
|
||||||
|
void viewZoomIn();
|
||||||
|
void viewZoomOut();
|
||||||
|
void viewZoom1To1();
|
||||||
|
void viewZoomToFit();
|
||||||
|
|
||||||
bool isOkToClose();
|
void objectsArrowMode();
|
||||||
|
void objectsCreateText();
|
||||||
|
void objectsCreateBox();
|
||||||
|
void objectsCreateLine();
|
||||||
|
void objectsCreateEllipse();
|
||||||
|
void objectsCreateImage();
|
||||||
|
void objectsCreateBarcode();
|
||||||
|
void objectsOrderRaise();
|
||||||
|
void objectsOrderLower();
|
||||||
|
void objectsXformRotateLeft();
|
||||||
|
void objectsXformRotateRight();
|
||||||
|
void objectsXformFlipHoriz();
|
||||||
|
void objectsXformFlipVert();
|
||||||
|
void objectsAlignLeft();
|
||||||
|
void objectsAlignHCenter();
|
||||||
|
void objectsAlignRight();
|
||||||
|
void objectsAlignTop();
|
||||||
|
void objectsAlignVCenter();
|
||||||
|
void objectsAlignBottom();
|
||||||
|
void objectsCenterHoriz();
|
||||||
|
void objectsCenterVert();
|
||||||
|
|
||||||
|
void helpContents();
|
||||||
|
void helpAbout();
|
||||||
|
|
||||||
|
void onContextMenuActivate();
|
||||||
|
|
||||||
|
void onZoomChanged();
|
||||||
|
void onPointerMoved( double, double );
|
||||||
|
void onPointerExit();
|
||||||
|
|
||||||
|
void onNameChanged();
|
||||||
|
void onModifiedChanged();
|
||||||
|
void onSelectionChanged();
|
||||||
|
void onLabelChanged();
|
||||||
|
void onUndoRedoChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Private Data
|
// Internal Private Methods
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QMenu* fileMenu;
|
void createActions();
|
||||||
QMenu* editMenu;
|
void createMenus();
|
||||||
QMenu* viewMenu;
|
void createToolBars();
|
||||||
QMenu* viewToolBarsMenu;
|
void createStatusBar();
|
||||||
QMenu* objectsMenu;
|
|
||||||
QMenu* objectsCreateMenu;
|
|
||||||
QMenu* objectsOrderMenu;
|
|
||||||
QMenu* objectsXformMenu;
|
|
||||||
QMenu* objectsAlignMenu;
|
|
||||||
QMenu* objectsCenterMenu;
|
|
||||||
QMenu* helpMenu;
|
|
||||||
|
|
||||||
QMenu* contextMenu;
|
QWidget* createWelcomePage();
|
||||||
QMenu* contextOrderMenu;
|
QWidget* createPropertiesPage();
|
||||||
QMenu* contextXformMenu;
|
QWidget* createEditorPage();
|
||||||
QMenu* contextAlignMenu;
|
QWidget* createMergePage();
|
||||||
QMenu* contextCenterMenu;
|
QWidget* createPrintPage();
|
||||||
QMenu* noSelectionContextMenu;
|
|
||||||
|
|
||||||
QToolBar* fileToolBar;
|
void setWelcomeMode( bool );
|
||||||
QToolBar* editorToolBar;
|
void setDocVerbsEnabled( bool );
|
||||||
|
void setDocModifiedVerbsEnabled( bool );
|
||||||
|
void setPasteVerbsEnabled( bool );
|
||||||
|
void setSelectionVerbsEnabled( bool );
|
||||||
|
void setMultiSelectionVerbsEnabled( bool );
|
||||||
|
|
||||||
LabelModel* mModel;
|
void setTitle();
|
||||||
UndoRedoModel* mUndoRedoModel;
|
|
||||||
|
|
||||||
QListWidget* mContents;
|
void readSettings();
|
||||||
QListWidgetItem* mWelcomeButton;
|
void writeSettings();
|
||||||
QListWidgetItem* mPropertiesButton;
|
|
||||||
QListWidgetItem* mEditorButton;
|
|
||||||
QListWidgetItem* mMergeButton;
|
|
||||||
QListWidgetItem* mPrintButton;
|
|
||||||
|
|
||||||
QStackedWidget* mPages;
|
bool isOkToClose();
|
||||||
StartupView* mWelcomeView;
|
|
||||||
PropertiesView* mPropertiesView;
|
|
||||||
QScrollArea* mLabelEditorScrollArea;
|
|
||||||
LabelEditor* mLabelEditor;
|
|
||||||
ObjectEditor* mObjectEditor;
|
|
||||||
MergeView* mMergeView;
|
|
||||||
PrintView* mPrintView;
|
|
||||||
|
|
||||||
QLabel* zoomInfoLabel;
|
|
||||||
QLabel* cursorInfoLabel;
|
|
||||||
|
|
||||||
QAction* fileNewAction;
|
/////////////////////////////////////
|
||||||
QAction* fileOpenAction;
|
// Private Data
|
||||||
QAction* fileSaveAction;
|
/////////////////////////////////////
|
||||||
QAction* fileSaveAsAction;
|
private:
|
||||||
QAction* fileTemplateDesignerAction;
|
QMenu* fileMenu;
|
||||||
QAction* fileCloseAction;
|
QMenu* editMenu;
|
||||||
QAction* fileExitAction;
|
QMenu* viewMenu;
|
||||||
|
QMenu* viewToolBarsMenu;
|
||||||
|
QMenu* objectsMenu;
|
||||||
|
QMenu* objectsCreateMenu;
|
||||||
|
QMenu* objectsOrderMenu;
|
||||||
|
QMenu* objectsXformMenu;
|
||||||
|
QMenu* objectsAlignMenu;
|
||||||
|
QMenu* objectsCenterMenu;
|
||||||
|
QMenu* helpMenu;
|
||||||
|
|
||||||
QAction* editUndoAction;
|
QMenu* contextMenu;
|
||||||
QAction* editRedoAction;
|
QMenu* contextOrderMenu;
|
||||||
QAction* editCutAction;
|
QMenu* contextXformMenu;
|
||||||
QAction* editCopyAction;
|
QMenu* contextAlignMenu;
|
||||||
QAction* editPasteAction;
|
QMenu* contextCenterMenu;
|
||||||
QAction* editDeleteAction;
|
QMenu* noSelectionContextMenu;
|
||||||
QAction* editSelectAllAction;
|
|
||||||
QAction* editUnSelectAllAction;
|
|
||||||
QAction* editPreferencesAction;
|
|
||||||
|
|
||||||
QAction* viewFileToolBarAction;
|
QToolBar* fileToolBar;
|
||||||
QAction* viewEditorToolBarAction;
|
QToolBar* editorToolBar;
|
||||||
QAction* viewGridAction;
|
|
||||||
QAction* viewMarkupAction;
|
|
||||||
QAction* viewZoomInAction;
|
|
||||||
QAction* viewZoomOutAction;
|
|
||||||
QAction* viewZoom1To1Action;
|
|
||||||
QAction* viewZoomToFitAction;
|
|
||||||
|
|
||||||
QAction* objectsArrowModeAction;
|
LabelModel* mModel;
|
||||||
QAction* objectsCreateTextAction;
|
UndoRedoModel* mUndoRedoModel;
|
||||||
QAction* objectsCreateBoxAction;
|
|
||||||
QAction* objectsCreateLineAction;
|
|
||||||
QAction* objectsCreateEllipseAction;
|
|
||||||
QAction* objectsCreateImageAction;
|
|
||||||
QAction* objectsCreateBarcodeAction;
|
|
||||||
QAction* objectsOrderRaiseAction;
|
|
||||||
QAction* objectsOrderLowerAction;
|
|
||||||
QAction* objectsXformRotateLeftAction;
|
|
||||||
QAction* objectsXformRotateRightAction;
|
|
||||||
QAction* objectsXformFlipHorizAction;
|
|
||||||
QAction* objectsXformFlipVertAction;
|
|
||||||
QAction* objectsAlignLeftAction;
|
|
||||||
QAction* objectsAlignHCenterAction;
|
|
||||||
QAction* objectsAlignRightAction;
|
|
||||||
QAction* objectsAlignTopAction;
|
|
||||||
QAction* objectsAlignVCenterAction;
|
|
||||||
QAction* objectsAlignBottomAction;
|
|
||||||
QAction* objectsCenterHorizAction;
|
|
||||||
QAction* objectsCenterVertAction;
|
|
||||||
|
|
||||||
QAction* helpContentsAction;
|
QListWidget* mContents;
|
||||||
QAction* helpAboutAction;
|
QListWidgetItem* mWelcomeButton;
|
||||||
|
QListWidgetItem* mPropertiesButton;
|
||||||
|
QListWidgetItem* mEditorButton;
|
||||||
|
QListWidgetItem* mMergeButton;
|
||||||
|
QListWidgetItem* mPrintButton;
|
||||||
|
|
||||||
QAction* contextCutAction;
|
QStackedWidget* mPages;
|
||||||
QAction* contextCopyAction;
|
StartupView* mWelcomeView;
|
||||||
QAction* contextPasteAction;
|
PropertiesView* mPropertiesView;
|
||||||
QAction* contextDeleteAction;
|
QScrollArea* mLabelEditorScrollArea;
|
||||||
};
|
LabelEditor* mLabelEditor;
|
||||||
|
ObjectEditor* mObjectEditor;
|
||||||
|
MergeView* mMergeView;
|
||||||
|
PrintView* mPrintView;
|
||||||
|
|
||||||
|
QLabel* zoomInfoLabel;
|
||||||
|
QLabel* cursorInfoLabel;
|
||||||
|
|
||||||
|
QAction* fileNewAction;
|
||||||
|
QAction* fileOpenAction;
|
||||||
|
QAction* fileSaveAction;
|
||||||
|
QAction* fileSaveAsAction;
|
||||||
|
QAction* fileTemplateDesignerAction;
|
||||||
|
QAction* fileCloseAction;
|
||||||
|
QAction* fileExitAction;
|
||||||
|
|
||||||
|
QAction* editUndoAction;
|
||||||
|
QAction* editRedoAction;
|
||||||
|
QAction* editCutAction;
|
||||||
|
QAction* editCopyAction;
|
||||||
|
QAction* editPasteAction;
|
||||||
|
QAction* editDeleteAction;
|
||||||
|
QAction* editSelectAllAction;
|
||||||
|
QAction* editUnSelectAllAction;
|
||||||
|
QAction* editPreferencesAction;
|
||||||
|
|
||||||
|
QAction* viewFileToolBarAction;
|
||||||
|
QAction* viewEditorToolBarAction;
|
||||||
|
QAction* viewGridAction;
|
||||||
|
QAction* viewMarkupAction;
|
||||||
|
QAction* viewZoomInAction;
|
||||||
|
QAction* viewZoomOutAction;
|
||||||
|
QAction* viewZoom1To1Action;
|
||||||
|
QAction* viewZoomToFitAction;
|
||||||
|
|
||||||
|
QAction* objectsArrowModeAction;
|
||||||
|
QAction* objectsCreateTextAction;
|
||||||
|
QAction* objectsCreateBoxAction;
|
||||||
|
QAction* objectsCreateLineAction;
|
||||||
|
QAction* objectsCreateEllipseAction;
|
||||||
|
QAction* objectsCreateImageAction;
|
||||||
|
QAction* objectsCreateBarcodeAction;
|
||||||
|
QAction* objectsOrderRaiseAction;
|
||||||
|
QAction* objectsOrderLowerAction;
|
||||||
|
QAction* objectsXformRotateLeftAction;
|
||||||
|
QAction* objectsXformRotateRightAction;
|
||||||
|
QAction* objectsXformFlipHorizAction;
|
||||||
|
QAction* objectsXformFlipVertAction;
|
||||||
|
QAction* objectsAlignLeftAction;
|
||||||
|
QAction* objectsAlignHCenterAction;
|
||||||
|
QAction* objectsAlignRightAction;
|
||||||
|
QAction* objectsAlignTopAction;
|
||||||
|
QAction* objectsAlignVCenterAction;
|
||||||
|
QAction* objectsAlignBottomAction;
|
||||||
|
QAction* objectsCenterHorizAction;
|
||||||
|
QAction* objectsCenterVertAction;
|
||||||
|
|
||||||
|
QAction* helpContentsAction;
|
||||||
|
QAction* helpAboutAction;
|
||||||
|
|
||||||
|
QAction* contextCutAction;
|
||||||
|
QAction* contextCopyAction;
|
||||||
|
QAction* contextPasteAction;
|
||||||
|
QAction* contextDeleteAction;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // MainWindow_h
|
#endif // MainWindow_h
|
||||||
|
|||||||
+159
-156
@@ -31,191 +31,194 @@
|
|||||||
#include "TextSemicolonKeys.h"
|
#include "TextSemicolonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// Static data
|
|
||||||
///
|
|
||||||
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
|
||||||
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
|
||||||
|
|
||||||
QStringList Factory::mNameList;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Factory::Factory()
|
|
||||||
{
|
{
|
||||||
registerBackend( None::id(),
|
|
||||||
tr("None"),
|
|
||||||
NONE,
|
|
||||||
&None::create );
|
|
||||||
|
|
||||||
registerBackend( TextCsv::id(),
|
//
|
||||||
tr("Text: Comma Separated Values (CSV)"),
|
// Static data
|
||||||
FILE,
|
//
|
||||||
&TextCsv::create );
|
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
||||||
|
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
||||||
registerBackend( TextCsvKeys::id(),
|
QStringList Factory::mNameList;
|
||||||
tr("Text: Comma Separated Values (CSV), keys on line 1"),
|
|
||||||
FILE,
|
|
||||||
&TextCsvKeys::create );
|
|
||||||
|
|
||||||
registerBackend( TextTsv::id(),
|
|
||||||
tr("Text: Tab Separated Values (TSV)"),
|
|
||||||
FILE,
|
|
||||||
&TextTsv::create );
|
|
||||||
|
|
||||||
registerBackend( TextTsvKeys::id(),
|
|
||||||
tr("Text: Tab Separated Values (TSV), keys on line 1"),
|
|
||||||
FILE,
|
|
||||||
&TextTsvKeys::create );
|
|
||||||
|
|
||||||
registerBackend( TextColon::id(),
|
|
||||||
tr("Text: Colon Separated Values"),
|
|
||||||
FILE,
|
|
||||||
&TextColon::create );
|
|
||||||
|
|
||||||
registerBackend( TextColonKeys::id(),
|
|
||||||
tr("Text: Colon Separated Values, keys on line 1"),
|
|
||||||
FILE,
|
|
||||||
&TextColonKeys::create );
|
|
||||||
|
|
||||||
registerBackend( TextSemicolon::id(),
|
|
||||||
tr("Text: Semicolon Separated Values"),
|
|
||||||
FILE,
|
|
||||||
&TextSemicolon::create );
|
|
||||||
|
|
||||||
registerBackend( TextSemicolonKeys::id(),
|
|
||||||
tr("Text: Semicolon Separated Values, keys on line 1"),
|
|
||||||
FILE,
|
|
||||||
&TextSemicolonKeys::create );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Initialize
|
/// Constructor
|
||||||
///
|
///
|
||||||
void Factory::init()
|
Factory::Factory()
|
||||||
{
|
|
||||||
static Factory* singletonInstance = 0;
|
|
||||||
if ( !singletonInstance )
|
|
||||||
{
|
{
|
||||||
singletonInstance = new Factory();
|
registerBackend( None::id(),
|
||||||
}
|
tr("None"),
|
||||||
}
|
NONE,
|
||||||
|
&None::create );
|
||||||
|
|
||||||
|
registerBackend( TextCsv::id(),
|
||||||
|
tr("Text: Comma Separated Values (CSV)"),
|
||||||
|
FILE,
|
||||||
|
&TextCsv::create );
|
||||||
|
|
||||||
///
|
registerBackend( TextCsvKeys::id(),
|
||||||
/// Create Merge object
|
tr("Text: Comma Separated Values (CSV), keys on line 1"),
|
||||||
///
|
FILE,
|
||||||
Merge* Factory::createMerge( const QString& id )
|
&TextCsvKeys::create );
|
||||||
{
|
|
||||||
QMap<QString,BackendEntry>::iterator iBackend = mBackendIdMap.find( id );
|
registerBackend( TextTsv::id(),
|
||||||
if ( iBackend != mBackendIdMap.end() )
|
tr("Text: Tab Separated Values (TSV)"),
|
||||||
{
|
FILE,
|
||||||
return iBackend->create();
|
&TextTsv::create );
|
||||||
|
|
||||||
|
registerBackend( TextTsvKeys::id(),
|
||||||
|
tr("Text: Tab Separated Values (TSV), keys on line 1"),
|
||||||
|
FILE,
|
||||||
|
&TextTsvKeys::create );
|
||||||
|
|
||||||
|
registerBackend( TextColon::id(),
|
||||||
|
tr("Text: Colon Separated Values"),
|
||||||
|
FILE,
|
||||||
|
&TextColon::create );
|
||||||
|
|
||||||
|
registerBackend( TextColonKeys::id(),
|
||||||
|
tr("Text: Colon Separated Values, keys on line 1"),
|
||||||
|
FILE,
|
||||||
|
&TextColonKeys::create );
|
||||||
|
|
||||||
|
registerBackend( TextSemicolon::id(),
|
||||||
|
tr("Text: Semicolon Separated Values"),
|
||||||
|
FILE,
|
||||||
|
&TextSemicolon::create );
|
||||||
|
|
||||||
|
registerBackend( TextSemicolonKeys::id(),
|
||||||
|
tr("Text: Semicolon Separated Values, keys on line 1"),
|
||||||
|
FILE,
|
||||||
|
&TextSemicolonKeys::create );
|
||||||
}
|
}
|
||||||
|
|
||||||
return None::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Initialize
|
||||||
/// Get name list
|
///
|
||||||
///
|
void Factory::init()
|
||||||
QStringList Factory::nameList()
|
|
||||||
{
|
|
||||||
return mNameList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Convert ID to name
|
|
||||||
///
|
|
||||||
QString Factory::idToName( const QString& id )
|
|
||||||
{
|
|
||||||
if ( mBackendIdMap.contains( id ) )
|
|
||||||
{
|
{
|
||||||
return mBackendIdMap[id].name;
|
static Factory* singletonInstance = 0;
|
||||||
|
if ( !singletonInstance )
|
||||||
|
{
|
||||||
|
singletonInstance = new Factory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return tr("None");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Convert name to ID
|
/// Create Merge object
|
||||||
///
|
///
|
||||||
QString Factory::nameToId( const QString& name )
|
Merge* Factory::createMerge( const QString& id )
|
||||||
{
|
|
||||||
if ( mBackendNameMap.contains( name ) )
|
|
||||||
{
|
{
|
||||||
return mBackendNameMap[name].id;
|
QMap<QString,BackendEntry>::iterator iBackend = mBackendIdMap.find( id );
|
||||||
|
if ( iBackend != mBackendIdMap.end() )
|
||||||
|
{
|
||||||
|
return iBackend->create();
|
||||||
|
}
|
||||||
|
|
||||||
|
return None::create();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get name list
|
||||||
|
///
|
||||||
|
QStringList Factory::nameList()
|
||||||
{
|
{
|
||||||
|
return mNameList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert ID to name
|
||||||
|
///
|
||||||
|
QString Factory::idToName( const QString& id )
|
||||||
|
{
|
||||||
|
if ( mBackendIdMap.contains( id ) )
|
||||||
|
{
|
||||||
|
return mBackendIdMap[id].name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return tr("None");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert name to ID
|
||||||
|
///
|
||||||
|
QString Factory::nameToId( const QString& name )
|
||||||
|
{
|
||||||
|
if ( mBackendNameMap.contains( name ) )
|
||||||
|
{
|
||||||
|
return mBackendNameMap[name].id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "None";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert ID to type
|
||||||
|
///
|
||||||
|
Factory::SourceType Factory::idToType( const QString& id )
|
||||||
|
{
|
||||||
|
if ( mBackendIdMap.contains( id ) )
|
||||||
|
{
|
||||||
|
return mBackendIdMap[id].type;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Lookup ID from index
|
||||||
|
///
|
||||||
|
QString Factory::indexToId( int index )
|
||||||
|
{
|
||||||
|
if ( (index > 0) && (index < mNameList.size()) )
|
||||||
|
{
|
||||||
|
QString name = mNameList[index];
|
||||||
|
|
||||||
|
return mBackendNameMap[ name ].id;
|
||||||
|
}
|
||||||
|
|
||||||
return "None";
|
return "None";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Convert ID to type
|
/// Register backend
|
||||||
///
|
///
|
||||||
Factory::SourceType Factory::idToType( const QString& id )
|
void Factory::registerBackend( const QString& id,
|
||||||
{
|
const QString& name,
|
||||||
if ( mBackendIdMap.contains( id ) )
|
SourceType type,
|
||||||
|
CreateFct create )
|
||||||
{
|
{
|
||||||
return mBackendIdMap[id].type;
|
BackendEntry backend;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
backend.id = id;
|
||||||
|
backend.name = name;
|
||||||
|
backend.type = type;
|
||||||
|
backend.create = create;
|
||||||
|
|
||||||
///
|
mBackendIdMap[ id ] = backend;
|
||||||
/// Lookup ID from index
|
mBackendNameMap[ name ] = backend;
|
||||||
///
|
|
||||||
QString Factory::indexToId( int index )
|
|
||||||
{
|
|
||||||
if ( (index > 0) && (index < mNameList.size()) )
|
|
||||||
{
|
|
||||||
QString name = mNameList[index];
|
|
||||||
|
|
||||||
return mBackendNameMap[ name ].id;
|
mNameList << name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "None";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Register backend
|
|
||||||
///
|
|
||||||
void Factory::registerBackend( const QString& id,
|
|
||||||
const QString& name,
|
|
||||||
SourceType type,
|
|
||||||
CreateFct create )
|
|
||||||
{
|
|
||||||
BackendEntry backend;
|
|
||||||
|
|
||||||
backend.id = id;
|
|
||||||
backend.name = name;
|
|
||||||
backend.type = type;
|
|
||||||
backend.create = create;
|
|
||||||
|
|
||||||
mBackendIdMap[ id ] = backend;
|
|
||||||
mBackendNameMap[ name ] = backend;
|
|
||||||
|
|
||||||
mNameList << name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+70
-62
@@ -26,78 +26,86 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
class Merge; // Forward reference
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Factory
|
|
||||||
///
|
|
||||||
class Factory
|
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(Factory)
|
|
||||||
|
// Forward references
|
||||||
|
class Merge;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Source Type
|
/// Factory
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class Factory
|
||||||
enum SourceType { NONE, FIXED, FILE };
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
protected:
|
|
||||||
Factory();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static void init();
|
|
||||||
|
|
||||||
static Merge* createMerge( const QString& id );
|
|
||||||
|
|
||||||
static QStringList nameList();
|
|
||||||
static QString idToName( const QString& id );
|
|
||||||
static QString nameToId( const QString& name );
|
|
||||||
static SourceType idToType( const QString& id );
|
|
||||||
static QString indexToId( int index );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// private methods
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
typedef Merge* (*CreateFct)();
|
|
||||||
|
|
||||||
static void registerBackend( const QString& id,
|
|
||||||
const QString& name,
|
|
||||||
SourceType type,
|
|
||||||
CreateFct create );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// private data
|
|
||||||
/////////////////////////////////
|
|
||||||
class BackendEntry
|
|
||||||
{
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(Factory)
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Source Type
|
||||||
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QString id;
|
enum SourceType { NONE, FIXED, FILE };
|
||||||
QString name;
|
|
||||||
SourceType type;
|
|
||||||
CreateFct create;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
protected:
|
||||||
|
Factory();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static void init();
|
||||||
|
|
||||||
|
static Merge* createMerge( const QString& id );
|
||||||
|
|
||||||
|
static QStringList nameList();
|
||||||
|
static QString idToName( const QString& id );
|
||||||
|
static QString nameToId( const QString& name );
|
||||||
|
static SourceType idToType( const QString& id );
|
||||||
|
static QString indexToId( int index );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// private methods
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
typedef Merge* (*CreateFct)();
|
||||||
|
|
||||||
|
static void registerBackend( const QString& id,
|
||||||
|
const QString& name,
|
||||||
|
SourceType type,
|
||||||
|
CreateFct create );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// private data
|
||||||
|
/////////////////////////////////
|
||||||
|
class BackendEntry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString id;
|
||||||
|
QString name;
|
||||||
|
SourceType type;
|
||||||
|
CreateFct create;
|
||||||
|
};
|
||||||
|
|
||||||
|
static QMap<QString,BackendEntry> mBackendIdMap;
|
||||||
|
static QMap<QString,BackendEntry> mBackendNameMap;
|
||||||
|
|
||||||
|
static QStringList mNameList;
|
||||||
};
|
};
|
||||||
|
|
||||||
static QMap<QString,BackendEntry> mBackendIdMap;
|
}
|
||||||
static QMap<QString,BackendEntry> mBackendNameMap;
|
|
||||||
|
|
||||||
static QStringList mNameList;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Factory_h
|
#endif // merge_Factory_h
|
||||||
|
|||||||
+143
-138
@@ -23,188 +23,193 @@
|
|||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Merge::Merge()
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Constructor
|
||||||
/// Constructor
|
///
|
||||||
///
|
Merge::Merge()
|
||||||
Merge::Merge( const Merge* merge ) : mSource(merge->mSource)
|
|
||||||
{
|
|
||||||
foreach ( Record* record, merge->mRecordList )
|
|
||||||
{
|
{
|
||||||
mRecordList << record->clone();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
Merge::~Merge()
|
Merge::Merge( const Merge* merge ) : mSource(merge->mSource)
|
||||||
{
|
|
||||||
foreach ( Record* record, mRecordList )
|
|
||||||
{
|
{
|
||||||
delete record;
|
foreach ( Record* record, merge->mRecordList )
|
||||||
|
{
|
||||||
|
mRecordList << record->clone();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mRecordList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get id
|
/// Destructor
|
||||||
///
|
///
|
||||||
QString Merge::id() const
|
Merge::~Merge()
|
||||||
{
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get source
|
|
||||||
///
|
|
||||||
QString Merge::source() const
|
|
||||||
{
|
|
||||||
return mSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Set source
|
|
||||||
///
|
|
||||||
void Merge::setSource( const QString& source )
|
|
||||||
{
|
|
||||||
mSource = source;
|
|
||||||
|
|
||||||
// Clear out any old records
|
|
||||||
foreach ( Record* record, mRecordList )
|
|
||||||
{
|
{
|
||||||
delete record;
|
foreach ( Record* record, mRecordList )
|
||||||
|
{
|
||||||
|
delete record;
|
||||||
|
}
|
||||||
|
mRecordList.clear();
|
||||||
}
|
}
|
||||||
mRecordList.clear();
|
|
||||||
|
|
||||||
open();
|
|
||||||
for ( Record* record = readNextRecord(); record != 0; record = readNextRecord() )
|
///
|
||||||
|
/// Get id
|
||||||
|
///
|
||||||
|
QString Merge::id() const
|
||||||
{
|
{
|
||||||
mRecordList.append( record );
|
return mId;
|
||||||
}
|
}
|
||||||
close();
|
|
||||||
|
|
||||||
emit sourceChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get record list
|
/// Get source
|
||||||
///
|
///
|
||||||
const QList<Record*>& Merge::recordList( void ) const
|
QString Merge::source() const
|
||||||
{
|
|
||||||
return mRecordList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Select matching record
|
|
||||||
///
|
|
||||||
void Merge::select( Record* record )
|
|
||||||
{
|
|
||||||
record->setSelected( true );
|
|
||||||
emit selectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Unselect matching record
|
|
||||||
///
|
|
||||||
void Merge::unselect( Record* record )
|
|
||||||
{
|
|
||||||
record->setSelected( false );
|
|
||||||
emit selectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Select/unselect i'th record
|
|
||||||
///
|
|
||||||
void Merge::setSelected( int i, bool state )
|
|
||||||
{
|
|
||||||
if ( (i >= 0) && (i < mRecordList.size()) )
|
|
||||||
{
|
{
|
||||||
mRecordList[i]->setSelected( state );
|
return mSource;
|
||||||
emit selectionChanged();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Select all records
|
/// Set source
|
||||||
///
|
///
|
||||||
void Merge::selectAll()
|
void Merge::setSource( const QString& source )
|
||||||
{
|
{
|
||||||
foreach ( Record* record, mRecordList )
|
mSource = source;
|
||||||
|
|
||||||
|
// Clear out any old records
|
||||||
|
foreach ( Record* record, mRecordList )
|
||||||
|
{
|
||||||
|
delete record;
|
||||||
|
}
|
||||||
|
mRecordList.clear();
|
||||||
|
|
||||||
|
open();
|
||||||
|
for ( Record* record = readNextRecord(); record != 0; record = readNextRecord() )
|
||||||
|
{
|
||||||
|
mRecordList.append( record );
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
|
||||||
|
emit sourceChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get record list
|
||||||
|
///
|
||||||
|
const QList<Record*>& Merge::recordList( void ) const
|
||||||
|
{
|
||||||
|
return mRecordList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Select matching record
|
||||||
|
///
|
||||||
|
void Merge::select( Record* record )
|
||||||
{
|
{
|
||||||
record->setSelected( true );
|
record->setSelected( true );
|
||||||
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
emit selectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Unselect all records
|
/// Unselect matching record
|
||||||
///
|
///
|
||||||
void Merge::unselectAll()
|
void Merge::unselect( Record* record )
|
||||||
{
|
|
||||||
foreach ( Record* record, mRecordList )
|
|
||||||
{
|
{
|
||||||
record->setSelected( false );
|
record->setSelected( false );
|
||||||
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
emit selectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Return count of selected records
|
/// Select/unselect i'th record
|
||||||
///
|
///
|
||||||
int Merge::nSelectedRecords() const
|
void Merge::setSelected( int i, bool state )
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
foreach ( Record* record, mRecordList )
|
|
||||||
{
|
{
|
||||||
if ( record->isSelected() )
|
if ( (i >= 0) && (i < mRecordList.size()) )
|
||||||
{
|
{
|
||||||
count++;
|
mRecordList[i]->setSelected( state );
|
||||||
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Select all records
|
||||||
/// Return list of selected records
|
///
|
||||||
///
|
void Merge::selectAll()
|
||||||
const QList<Record*> Merge::selectedRecords() const
|
|
||||||
{
|
|
||||||
QList<Record*> list;
|
|
||||||
|
|
||||||
foreach ( Record* record, mRecordList )
|
|
||||||
{
|
{
|
||||||
if ( record->isSelected() )
|
foreach ( Record* record, mRecordList )
|
||||||
{
|
{
|
||||||
list.append( record );
|
record->setSelected( true );
|
||||||
}
|
}
|
||||||
|
emit selectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Unselect all records
|
||||||
|
///
|
||||||
|
void Merge::unselectAll()
|
||||||
|
{
|
||||||
|
foreach ( Record* record, mRecordList )
|
||||||
|
{
|
||||||
|
record->setSelected( false );
|
||||||
|
}
|
||||||
|
emit selectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return count of selected records
|
||||||
|
///
|
||||||
|
int Merge::nSelectedRecords() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
foreach ( Record* record, mRecordList )
|
||||||
|
{
|
||||||
|
if ( record->isSelected() )
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return list of selected records
|
||||||
|
///
|
||||||
|
const QList<Record*> Merge::selectedRecords() const
|
||||||
|
{
|
||||||
|
QList<Record*> list;
|
||||||
|
|
||||||
|
foreach ( Record* record, mRecordList )
|
||||||
|
{
|
||||||
|
if ( record->isSelected() )
|
||||||
|
{
|
||||||
|
list.append( record );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+73
-65
@@ -27,90 +27,98 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
class Record; // Forward reference
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Merge Object
|
|
||||||
///
|
|
||||||
struct Merge : QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
// Forward references
|
||||||
|
class Record;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Merge Object
|
||||||
/////////////////////////////////
|
///
|
||||||
protected:
|
struct Merge : QObject
|
||||||
Merge();
|
{
|
||||||
Merge( const Merge* merge );
|
Q_OBJECT
|
||||||
public:
|
|
||||||
virtual ~Merge();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
virtual Merge* clone() const = 0;
|
protected:
|
||||||
|
Merge();
|
||||||
|
Merge( const Merge* merge );
|
||||||
|
public:
|
||||||
|
virtual ~Merge();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
virtual Merge* clone() const = 0;
|
||||||
QString id() const;
|
|
||||||
QString source() const;
|
|
||||||
void setSource( const QString& source );
|
|
||||||
|
|
||||||
const QList<Record*>& recordList( void ) const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Selection methods
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void select( Record* record );
|
QString id() const;
|
||||||
void unselect( Record* record );
|
QString source() const;
|
||||||
void setSelected( int i, bool state = true );
|
void setSource( const QString& source );
|
||||||
void selectAll();
|
|
||||||
void unselectAll();
|
|
||||||
|
|
||||||
int nSelectedRecords() const;
|
const QList<Record*>& recordList( void ) const;
|
||||||
const QList<Record*> selectedRecords() const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Virtual methods
|
// Selection methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual QStringList keys() const = 0;
|
void select( Record* record );
|
||||||
virtual QString primaryKey() const = 0;
|
void unselect( Record* record );
|
||||||
protected:
|
void setSelected( int i, bool state = true );
|
||||||
virtual void open() = 0;
|
void selectAll();
|
||||||
virtual void close() = 0;
|
void unselectAll();
|
||||||
virtual Record* readNextRecord() = 0;
|
|
||||||
|
int nSelectedRecords() const;
|
||||||
|
const QList<Record*> selectedRecords() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Virtual methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
public:
|
||||||
void sourceChanged();
|
virtual QStringList keys() const = 0;
|
||||||
void selectionChanged();
|
virtual QString primaryKey() const = 0;
|
||||||
|
protected:
|
||||||
|
virtual void open() = 0;
|
||||||
|
virtual void close() = 0;
|
||||||
|
virtual Record* readNextRecord() = 0;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private data
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
protected:
|
signals:
|
||||||
QString mId;
|
void sourceChanged();
|
||||||
private:
|
void selectionChanged();
|
||||||
QString mSource;
|
|
||||||
QList<Record*> mRecordList;
|
|
||||||
};
|
/////////////////////////////////
|
||||||
|
// Private data
|
||||||
|
/////////////////////////////////
|
||||||
|
protected:
|
||||||
|
QString mId;
|
||||||
|
private:
|
||||||
|
QString mSource;
|
||||||
|
QList<Record*> mRecordList;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Merge_h
|
#endif // merge_Merge_h
|
||||||
|
|||||||
+78
-73
@@ -21,102 +21,107 @@
|
|||||||
#include "None.h"
|
#include "None.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
None::None() : Merge()
|
|
||||||
{
|
{
|
||||||
mId = "None";
|
|
||||||
}
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
None::None() : Merge()
|
||||||
|
{
|
||||||
|
mId = "None";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
None::None( const None* merge ) : Merge( merge )
|
None::None( const None* merge ) : Merge( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
None::~None()
|
None::~None()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
None* None::clone() const
|
None* None::clone() const
|
||||||
{
|
{
|
||||||
return new None( this );
|
return new None( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString None::id()
|
QString None::id()
|
||||||
{
|
{
|
||||||
return "None";
|
return "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* None::create()
|
Merge* None::create()
|
||||||
{
|
{
|
||||||
return new None();
|
return new None();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get key list
|
/// Get key list
|
||||||
///
|
///
|
||||||
QStringList None::keys() const
|
QStringList None::keys() const
|
||||||
{
|
{
|
||||||
QStringList emptyList;
|
QStringList emptyList;
|
||||||
return emptyList;
|
return emptyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get primary key
|
/// Get primary key
|
||||||
///
|
///
|
||||||
QString None::primaryKey() const
|
QString None::primaryKey() const
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Open source
|
/// Open source
|
||||||
///
|
///
|
||||||
void None::open()
|
void None::open()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Close source
|
/// Close source
|
||||||
///
|
///
|
||||||
void None::close()
|
void None::close()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Read next record
|
/// Read next record
|
||||||
///
|
///
|
||||||
Record* None::readNextRecord()
|
Record* None::readNextRecord()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-33
@@ -24,51 +24,57 @@
|
|||||||
#include "Merge.h"
|
#include "Merge.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// None Merge Backend
|
|
||||||
///
|
|
||||||
struct None : public Merge
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// None Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
struct None : public Merge
|
||||||
None();
|
{
|
||||||
None( const None* merge );
|
|
||||||
virtual ~None();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
None();
|
||||||
|
None( const None* merge );
|
||||||
|
virtual ~None();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
None* clone() const;
|
None* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Implementation of virtual methods
|
// Implementation of virtual methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QStringList keys() const;
|
QStringList keys() const;
|
||||||
QString primaryKey() const;
|
QString primaryKey() const;
|
||||||
protected:
|
protected:
|
||||||
void open();
|
void open();
|
||||||
void close();
|
void close();
|
||||||
Record* readNextRecord();
|
Record* readNextRecord();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_None_h
|
#endif // merge_None_h
|
||||||
|
|||||||
+38
-33
@@ -21,50 +21,55 @@
|
|||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Record::Record() : mSelected( true )
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
Record::Record() : mSelected( true )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
Record::Record( const Record* record )
|
Record::Record( const Record* record )
|
||||||
: QMap<QString,QString>(*record), mSelected(record->mSelected)
|
: QMap<QString,QString>(*record), mSelected(record->mSelected)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
Record* Record::clone() const
|
Record* Record::clone() const
|
||||||
{
|
{
|
||||||
return new Record( this );
|
return new Record( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Is record selected?
|
/// Is record selected?
|
||||||
///
|
///
|
||||||
bool Record::isSelected() const
|
bool Record::isSelected() const
|
||||||
{
|
{
|
||||||
return mSelected;
|
return mSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set selected on not selected
|
/// Set selected on not selected
|
||||||
///
|
///
|
||||||
void Record::setSelected( bool value )
|
void Record::setSelected( bool value )
|
||||||
{
|
{
|
||||||
mSelected = value;
|
mSelected = value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-27
@@ -25,45 +25,51 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// Merge Record
|
|
||||||
///
|
|
||||||
struct Record : public QMap<QString,QString>
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Merge Record
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
struct Record : public QMap<QString,QString>
|
||||||
Record();
|
{
|
||||||
Record( const Record* record );
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
Record();
|
||||||
|
Record( const Record* record );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
Record* clone() const;
|
Record* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool isSelected() const;
|
bool isSelected() const;
|
||||||
void setSelected( bool value );
|
void setSelected( bool value );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private data
|
// Private data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
bool mSelected;
|
bool mSelected;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Record_h
|
#endif // merge_Record_h
|
||||||
|
|||||||
+335
-330
@@ -24,392 +24,397 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Text::Text( QChar delimiter, bool line1HasKeys )
|
|
||||||
: mNFieldsMax(0), mDelimeter(delimiter), mLine1HasKeys(line1HasKeys)
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Constructor
|
||||||
/// Constructor
|
///
|
||||||
///
|
Text::Text( QChar delimiter, bool line1HasKeys )
|
||||||
Text::Text( const Text* merge )
|
: mNFieldsMax(0), mDelimeter(delimiter), mLine1HasKeys(line1HasKeys)
|
||||||
: Merge( merge ),
|
|
||||||
mNFieldsMax(merge->mNFieldsMax),
|
|
||||||
mDelimeter(merge->mDelimeter), mLine1HasKeys(merge->mLine1HasKeys)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
Text::~Text()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get key list
|
|
||||||
///
|
|
||||||
QStringList Text::keys() const
|
|
||||||
{
|
|
||||||
QStringList keys;
|
|
||||||
for ( int iField = 0; iField < mNFieldsMax; iField++ )
|
|
||||||
{
|
{
|
||||||
keys << keyFromIndex(iField);
|
|
||||||
}
|
}
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get primary key
|
/// Constructor
|
||||||
///
|
///
|
||||||
QString Text::primaryKey() const
|
Text::Text( const Text* merge )
|
||||||
{
|
: Merge( merge ),
|
||||||
return keyFromIndex(0);
|
mNFieldsMax(merge->mNFieldsMax),
|
||||||
}
|
mDelimeter(merge->mDelimeter), mLine1HasKeys(merge->mLine1HasKeys)
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Open source
|
|
||||||
///
|
|
||||||
void Text::open()
|
|
||||||
{
|
|
||||||
mFile.setFileName( source() );
|
|
||||||
mFile.open( QIODevice::ReadOnly|QIODevice::Text );
|
|
||||||
|
|
||||||
mKeys.clear();
|
|
||||||
mNFieldsMax = 0;
|
|
||||||
|
|
||||||
if ( mLine1HasKeys && mFile.isOpen() )
|
|
||||||
{
|
{
|
||||||
mKeys = parseLine();
|
}
|
||||||
if ( (mKeys.size() == 1) && (mKeys[0] == "") )
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
Text::~Text()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get key list
|
||||||
|
///
|
||||||
|
QStringList Text::keys() const
|
||||||
|
{
|
||||||
|
QStringList keys;
|
||||||
|
for ( int iField = 0; iField < mNFieldsMax; iField++ )
|
||||||
{
|
{
|
||||||
mKeys.clear();
|
keys << keyFromIndex(iField);
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get primary key
|
||||||
|
///
|
||||||
|
QString Text::primaryKey() const
|
||||||
|
{
|
||||||
|
return keyFromIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Open source
|
||||||
|
///
|
||||||
|
void Text::open()
|
||||||
|
{
|
||||||
|
mFile.setFileName( source() );
|
||||||
|
mFile.open( QIODevice::ReadOnly|QIODevice::Text );
|
||||||
|
|
||||||
|
mKeys.clear();
|
||||||
|
mNFieldsMax = 0;
|
||||||
|
|
||||||
|
if ( mLine1HasKeys && mFile.isOpen() )
|
||||||
|
{
|
||||||
|
mKeys = parseLine();
|
||||||
|
if ( (mKeys.size() == 1) && (mKeys[0] == "") )
|
||||||
|
{
|
||||||
|
mKeys.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mNFieldsMax = mKeys.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Close source
|
||||||
|
///
|
||||||
|
void Text::close()
|
||||||
|
{
|
||||||
|
if ( mFile.isOpen() )
|
||||||
|
{
|
||||||
|
mFile.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Read next record
|
||||||
|
///
|
||||||
|
Record* Text::readNextRecord()
|
||||||
|
{
|
||||||
|
QStringList values = parseLine();
|
||||||
|
if ( !values.isEmpty() )
|
||||||
|
{
|
||||||
|
Record* record = new Record();
|
||||||
|
|
||||||
|
int iField = 0;
|
||||||
|
foreach ( QString value, values )
|
||||||
|
{
|
||||||
|
(*record)[ keyFromIndex(iField) ] = value;
|
||||||
|
iField++;
|
||||||
|
}
|
||||||
|
mNFieldsMax = std::max( mNFieldsMax, iField );
|
||||||
|
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Key from field index
|
||||||
|
///
|
||||||
|
QString Text::keyFromIndex( int iField ) const
|
||||||
|
{
|
||||||
|
if ( mLine1HasKeys && ( iField < mKeys.size() ) )
|
||||||
|
{
|
||||||
|
return mKeys[iField];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mNFieldsMax = mKeys.size();
|
return QString::number( iField+1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Close source
|
/// Parse line.
|
||||||
///
|
///
|
||||||
void Text::close()
|
/// Attempt to be a robust parser of various CSV (and similar) formats.
|
||||||
{
|
///
|
||||||
if ( mFile.isOpen() )
|
/// Based on CSV format described in RFC 4180 section 2.
|
||||||
|
///
|
||||||
|
/// Additions to RFC 4180 rules:
|
||||||
|
/// - delimeters and other special characters may be "escaped" by a leading
|
||||||
|
/// backslash (\)
|
||||||
|
/// - C escape sequences for newline (\n) and tab (\t) are also translated.
|
||||||
|
/// - if quoted text is not followed by a delimeter, any additional text is
|
||||||
|
/// concatenated with quoted portion.
|
||||||
|
///
|
||||||
|
/// Returns a list of fields. A blank line is considered a line with one
|
||||||
|
/// empty field. Returns an empty list when done.
|
||||||
|
///
|
||||||
|
QStringList Text::parseLine()
|
||||||
{
|
{
|
||||||
mFile.close();
|
QStringList fields;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
enum State
|
||||||
///
|
|
||||||
/// Read next record
|
|
||||||
///
|
|
||||||
Record* Text::readNextRecord()
|
|
||||||
{
|
|
||||||
QStringList values = parseLine();
|
|
||||||
if ( !values.isEmpty() )
|
|
||||||
{
|
|
||||||
Record* record = new Record();
|
|
||||||
|
|
||||||
int iField = 0;
|
|
||||||
foreach ( QString value, values )
|
|
||||||
{
|
{
|
||||||
(*record)[ keyFromIndex(iField) ] = value;
|
DELIM, QUOTED, QUOTED_QUOTE1, QUOTED_ESCAPED, SIMPLE, SIMPLE_ESCAPED, DONE
|
||||||
iField++;
|
} state = DELIM;
|
||||||
}
|
|
||||||
mNFieldsMax = std::max( mNFieldsMax, iField );
|
|
||||||
|
|
||||||
return record;
|
QByteArray field;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
while ( state != DONE )
|
||||||
///
|
|
||||||
/// Key from field index
|
|
||||||
///
|
|
||||||
QString Text::keyFromIndex( int iField ) const
|
|
||||||
{
|
|
||||||
if ( mLine1HasKeys && ( iField < mKeys.size() ) )
|
|
||||||
{
|
|
||||||
return mKeys[iField];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return QString::number( iField+1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Parse line.
|
|
||||||
///
|
|
||||||
/// Attempt to be a robust parser of various CSV (and similar) formats.
|
|
||||||
///
|
|
||||||
/// Based on CSV format described in RFC 4180 section 2.
|
|
||||||
///
|
|
||||||
/// Additions to RFC 4180 rules:
|
|
||||||
/// - delimeters and other special characters may be "escaped" by a leading
|
|
||||||
/// backslash (\)
|
|
||||||
/// - C escape sequences for newline (\n) and tab (\t) are also translated.
|
|
||||||
/// - if quoted text is not followed by a delimeter, any additional text is
|
|
||||||
/// concatenated with quoted portion.
|
|
||||||
///
|
|
||||||
/// Returns a list of fields. A blank line is considered a line with one
|
|
||||||
/// empty field. Returns an empty list when done.
|
|
||||||
///
|
|
||||||
QStringList Text::parseLine()
|
|
||||||
{
|
|
||||||
QStringList fields;
|
|
||||||
|
|
||||||
enum State
|
|
||||||
{
|
|
||||||
DELIM, QUOTED, QUOTED_QUOTE1, QUOTED_ESCAPED, SIMPLE, SIMPLE_ESCAPED, DONE
|
|
||||||
} state = DELIM;
|
|
||||||
|
|
||||||
QByteArray field;
|
|
||||||
|
|
||||||
while ( state != DONE )
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
if ( mFile.getChar( &c ) )
|
|
||||||
{
|
{
|
||||||
switch (state)
|
char c;
|
||||||
|
if ( mFile.getChar( &c ) )
|
||||||
{
|
{
|
||||||
|
switch (state)
|
||||||
case DELIM:
|
|
||||||
switch (c)
|
|
||||||
{
|
{
|
||||||
case '\n':
|
|
||||||
/* last field is empty. */
|
case DELIM:
|
||||||
fields << "";
|
switch (c)
|
||||||
state = DONE;
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
/* ignore */
|
|
||||||
state = DELIM;
|
|
||||||
break;
|
|
||||||
case '"':
|
|
||||||
/* start a quoted field. */
|
|
||||||
state = QUOTED;
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
/* simple field, but 1st character is an escape. */
|
|
||||||
state = SIMPLE_ESCAPED;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if ( c == mDelimeter )
|
|
||||||
{
|
{
|
||||||
/* field is empty. */
|
case '\n':
|
||||||
|
/* last field is empty. */
|
||||||
fields << "";
|
fields << "";
|
||||||
|
state = DONE;
|
||||||
|
break;
|
||||||
|
case '\r':
|
||||||
|
/* ignore */
|
||||||
state = DELIM;
|
state = DELIM;
|
||||||
}
|
break;
|
||||||
else
|
case '"':
|
||||||
{
|
/* start a quoted field. */
|
||||||
/* begining of a simple field. */
|
state = QUOTED;
|
||||||
field.append( c );
|
break;
|
||||||
state = SIMPLE;
|
case '\\':
|
||||||
|
/* simple field, but 1st character is an escape. */
|
||||||
|
state = SIMPLE_ESCAPED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if ( c == mDelimeter )
|
||||||
|
{
|
||||||
|
/* field is empty. */
|
||||||
|
fields << "";
|
||||||
|
state = DELIM;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* begining of a simple field. */
|
||||||
|
field.append( c );
|
||||||
|
state = SIMPLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QUOTED:
|
case QUOTED:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
|
||||||
case '"':
|
|
||||||
/* Possible end of field, but could be 1st of a pair. */
|
|
||||||
state = QUOTED_QUOTE1;
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
/* Escape next character, or special escape, e.g. \n. */
|
|
||||||
state = QUOTED_ESCAPED;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Use character literally. */
|
|
||||||
field.append( c );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QUOTED_QUOTE1:
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '\n':
|
|
||||||
/* line ended after quoted item */
|
|
||||||
fields << QString( field );
|
|
||||||
state = DONE;
|
|
||||||
break;
|
|
||||||
case '"':
|
|
||||||
/* second quote, insert and stay quoted. */
|
|
||||||
field.append( c );
|
|
||||||
state = QUOTED;
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
/* ignore and go to fallback */
|
|
||||||
state = SIMPLE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if ( c == mDelimeter )
|
|
||||||
{
|
|
||||||
/* end of field. */
|
|
||||||
fields << QString( field );
|
|
||||||
field.clear();
|
|
||||||
state = DELIM;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* fallback if not a delim or another quote. */
|
|
||||||
field.append( c );
|
|
||||||
state = SIMPLE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QUOTED_ESCAPED:
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 'n':
|
|
||||||
/* Decode "\n" as newline. */
|
|
||||||
field.append( '\n' );
|
|
||||||
state = QUOTED;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
/* Decode "\t" as tab. */
|
|
||||||
field.append( '\t' );
|
|
||||||
state = QUOTED;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Use character literally. */
|
|
||||||
field.append( c );
|
|
||||||
state = QUOTED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SIMPLE:
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '\n':
|
|
||||||
/* line ended */
|
|
||||||
fields << QString( field );
|
|
||||||
state = DONE;
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
/* ignore */
|
|
||||||
state = SIMPLE;
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
/* Escape next character, or special escape, e.g. \n. */
|
|
||||||
state = SIMPLE_ESCAPED;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if ( c == mDelimeter )
|
|
||||||
{
|
|
||||||
/* end of field. */
|
|
||||||
fields << QString( field );
|
|
||||||
field.clear();
|
|
||||||
state = DELIM;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
case '"':
|
||||||
|
/* Possible end of field, but could be 1st of a pair. */
|
||||||
|
state = QUOTED_QUOTE1;
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
/* Escape next character, or special escape, e.g. \n. */
|
||||||
|
state = QUOTED_ESCAPED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
/* Use character literally. */
|
/* Use character literally. */
|
||||||
field.append( c );
|
field.append( c );
|
||||||
state = SIMPLE;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SIMPLE_ESCAPED:
|
case QUOTED_QUOTE1:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'n':
|
case '\n':
|
||||||
/* Decode "\n" as newline. */
|
/* line ended after quoted item */
|
||||||
field.append( '\n' );
|
fields << QString( field );
|
||||||
state = SIMPLE;
|
state = DONE;
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
/* second quote, insert and stay quoted. */
|
||||||
|
field.append( c );
|
||||||
|
state = QUOTED;
|
||||||
|
break;
|
||||||
|
case '\r':
|
||||||
|
/* ignore and go to fallback */
|
||||||
|
state = SIMPLE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if ( c == mDelimeter )
|
||||||
|
{
|
||||||
|
/* end of field. */
|
||||||
|
fields << QString( field );
|
||||||
|
field.clear();
|
||||||
|
state = DELIM;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* fallback if not a delim or another quote. */
|
||||||
|
field.append( c );
|
||||||
|
state = SIMPLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 't':
|
|
||||||
/* Decode "\t" as tab. */
|
case QUOTED_ESCAPED:
|
||||||
field.append( '\t' );
|
switch (c)
|
||||||
state = SIMPLE;
|
{
|
||||||
|
case 'n':
|
||||||
|
/* Decode "\n" as newline. */
|
||||||
|
field.append( '\n' );
|
||||||
|
state = QUOTED;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
/* Decode "\t" as tab. */
|
||||||
|
field.append( '\t' );
|
||||||
|
state = QUOTED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* Use character literally. */
|
||||||
|
field.append( c );
|
||||||
|
state = QUOTED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SIMPLE:
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '\n':
|
||||||
|
/* line ended */
|
||||||
|
fields << QString( field );
|
||||||
|
state = DONE;
|
||||||
|
break;
|
||||||
|
case '\r':
|
||||||
|
/* ignore */
|
||||||
|
state = SIMPLE;
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
/* Escape next character, or special escape, e.g. \n. */
|
||||||
|
state = SIMPLE_ESCAPED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if ( c == mDelimeter )
|
||||||
|
{
|
||||||
|
/* end of field. */
|
||||||
|
fields << QString( field );
|
||||||
|
field.clear();
|
||||||
|
state = DELIM;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Use character literally. */
|
||||||
|
field.append( c );
|
||||||
|
state = SIMPLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SIMPLE_ESCAPED:
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'n':
|
||||||
|
/* Decode "\n" as newline. */
|
||||||
|
field.append( '\n' );
|
||||||
|
state = SIMPLE;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
/* Decode "\t" as tab. */
|
||||||
|
field.append( '\t' );
|
||||||
|
state = SIMPLE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* Use character literally. */
|
||||||
|
field.append( (char)c );
|
||||||
|
state = SIMPLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Use character literally. */
|
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
|
||||||
field.append( (char)c );
|
|
||||||
state = SIMPLE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Handle EOF (could also be an error while reading). */
|
|
||||||
switch (state)
|
|
||||||
{
|
{
|
||||||
|
/* Handle EOF (could also be an error while reading). */
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
|
||||||
case DELIM:
|
case DELIM:
|
||||||
/* EOF, no more lines. */
|
/* EOF, no more lines. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QUOTED:
|
case QUOTED:
|
||||||
/* File ended midway through quoted item. Truncate field. */
|
/* File ended midway through quoted item. Truncate field. */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QUOTED_QUOTE1:
|
case QUOTED_QUOTE1:
|
||||||
/* File ended after quoted item. */
|
/* File ended after quoted item. */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QUOTED_ESCAPED:
|
case QUOTED_ESCAPED:
|
||||||
/* File ended midway through quoted item. Truncate field. */
|
/* File ended midway through quoted item. Truncate field. */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIMPLE:
|
case SIMPLE:
|
||||||
/* File ended after simple item. */
|
/* File ended after simple item. */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIMPLE_ESCAPED:
|
case SIMPLE_ESCAPED:
|
||||||
/* File ended midway through escaped item. */
|
/* File ended midway through escaped item. */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
|
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = DONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-37
@@ -26,55 +26,61 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// Text Merge Backend
|
|
||||||
///
|
|
||||||
struct Text : public Merge
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Text Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
protected:
|
struct Text : public Merge
|
||||||
Text( QChar delimiter, bool line1HasKeys );
|
{
|
||||||
Text( const Text* merge );
|
|
||||||
virtual ~Text();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
protected:
|
||||||
|
Text( QChar delimiter, bool line1HasKeys );
|
||||||
|
Text( const Text* merge );
|
||||||
|
virtual ~Text();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Implementation of virtual methods
|
// Implementation of virtual methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QStringList keys() const;
|
QStringList keys() const;
|
||||||
QString primaryKey() const;
|
QString primaryKey() const;
|
||||||
protected:
|
protected:
|
||||||
void open();
|
void open();
|
||||||
void close();
|
void close();
|
||||||
Record* readNextRecord();
|
Record* readNextRecord();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private methods
|
// Private methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
QString keyFromIndex( int iField ) const;
|
QString keyFromIndex( int iField ) const;
|
||||||
QStringList parseLine();
|
QStringList parseLine();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private data
|
// Private data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QChar mDelimeter;
|
QChar mDelimeter;
|
||||||
bool mLine1HasKeys;
|
bool mLine1HasKeys;
|
||||||
|
|
||||||
QFile mFile;
|
QFile mFile;
|
||||||
QStringList mKeys;
|
QStringList mKeys;
|
||||||
int mNFieldsMax;
|
int mNFieldsMax;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Text_h
|
#endif // merge_Text_h
|
||||||
|
|||||||
+46
-41
@@ -21,60 +21,65 @@
|
|||||||
#include "TextColon.h"
|
#include "TextColon.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
static const QString ID = "Text/Colon";
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextColon::TextColon() : Text(':',false)
|
|
||||||
{
|
{
|
||||||
mId = ID;
|
static const QString ID = "Text/Colon";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextColon::TextColon( const TextColon* merge ) : Text( merge )
|
TextColon::TextColon() : Text(':',false)
|
||||||
{
|
{
|
||||||
}
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextColon::~TextColon()
|
TextColon::TextColon( const TextColon* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextColon* TextColon::clone() const
|
TextColon::~TextColon()
|
||||||
{
|
{
|
||||||
return new TextColon( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextColon::id()
|
TextColon* TextColon::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextColon( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextColon::create()
|
QString TextColon::id()
|
||||||
{
|
{
|
||||||
return new TextColon();
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextColon::create()
|
||||||
|
{
|
||||||
|
return new TextColon();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-24
@@ -24,40 +24,46 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// TextColon Merge Backend
|
|
||||||
///
|
|
||||||
struct TextColon : public Text
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// TextColon Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
struct TextColon : public Text
|
||||||
TextColon();
|
{
|
||||||
TextColon( const TextColon* merge );
|
|
||||||
virtual ~TextColon();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextColon();
|
||||||
|
TextColon( const TextColon* merge );
|
||||||
|
virtual ~TextColon();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextColon* clone() const;
|
TextColon* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextColon_h
|
#endif // merge_TextColon_h
|
||||||
|
|||||||
@@ -21,60 +21,65 @@
|
|||||||
#include "TextColonKeys.h"
|
#include "TextColonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
static const QString ID = "Text/Colon/Line1Keys";
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextColonKeys::TextColonKeys() : Text(':',true)
|
|
||||||
{
|
{
|
||||||
mId = ID;
|
static const QString ID = "Text/Colon/Line1Keys";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
|
TextColonKeys::TextColonKeys() : Text(':',true)
|
||||||
{
|
{
|
||||||
}
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextColonKeys::~TextColonKeys()
|
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextColonKeys* TextColonKeys::clone() const
|
TextColonKeys::~TextColonKeys()
|
||||||
{
|
{
|
||||||
return new TextColonKeys( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextColonKeys::id()
|
TextColonKeys* TextColonKeys::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextColonKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextColonKeys::create()
|
QString TextColonKeys::id()
|
||||||
{
|
{
|
||||||
return new TextColonKeys();
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextColonKeys::create()
|
||||||
|
{
|
||||||
|
return new TextColonKeys();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,40 +24,46 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// TextColonKeys Merge Backend
|
|
||||||
///
|
|
||||||
struct TextColonKeys : public Text
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// TextColonKeys Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
struct TextColonKeys : public Text
|
||||||
TextColonKeys();
|
{
|
||||||
TextColonKeys( const TextColonKeys* merge );
|
|
||||||
virtual ~TextColonKeys();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextColonKeys();
|
||||||
|
TextColonKeys( const TextColonKeys* merge );
|
||||||
|
virtual ~TextColonKeys();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextColonKeys* clone() const;
|
TextColonKeys* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextColonKeys_h
|
#endif // merge_TextColonKeys_h
|
||||||
|
|||||||
+46
-41
@@ -21,60 +21,65 @@
|
|||||||
#include "TextCsv.h"
|
#include "TextCsv.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
static const QString ID = "Text/Comma";
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextCsv::TextCsv() : Text(',',false)
|
|
||||||
{
|
{
|
||||||
mId = ID;
|
static const QString ID = "Text/Comma";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
|
TextCsv::TextCsv() : Text(',',false)
|
||||||
{
|
{
|
||||||
}
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsv::~TextCsv()
|
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextCsv* TextCsv::clone() const
|
TextCsv::~TextCsv()
|
||||||
{
|
{
|
||||||
return new TextCsv( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextCsv::id()
|
TextCsv* TextCsv::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextCsv( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextCsv::create()
|
QString TextCsv::id()
|
||||||
{
|
{
|
||||||
return new TextCsv();
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextCsv::create()
|
||||||
|
{
|
||||||
|
return new TextCsv();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-24
@@ -24,40 +24,46 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// TextCsv Merge Backend
|
|
||||||
///
|
|
||||||
struct TextCsv : public Text
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// TextCsv Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
struct TextCsv : public Text
|
||||||
TextCsv();
|
{
|
||||||
TextCsv( const TextCsv* merge );
|
|
||||||
virtual ~TextCsv();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextCsv();
|
||||||
|
TextCsv( const TextCsv* merge );
|
||||||
|
virtual ~TextCsv();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextCsv* clone() const;
|
TextCsv* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextCsv_h
|
#endif // merge_TextCsv_h
|
||||||
|
|||||||
@@ -21,60 +21,65 @@
|
|||||||
#include "TextCsvKeys.h"
|
#include "TextCsvKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
static const QString ID = "Text/Comma/Line1Keys";
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextCsvKeys::TextCsvKeys() : Text(',',true)
|
|
||||||
{
|
{
|
||||||
mId = ID;
|
static const QString ID = "Text/Comma/Line1Keys";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
|
TextCsvKeys::TextCsvKeys() : Text(',',true)
|
||||||
{
|
{
|
||||||
}
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsvKeys::~TextCsvKeys()
|
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextCsvKeys* TextCsvKeys::clone() const
|
TextCsvKeys::~TextCsvKeys()
|
||||||
{
|
{
|
||||||
return new TextCsvKeys( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextCsvKeys::id()
|
TextCsvKeys* TextCsvKeys::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextCsvKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextCsvKeys::create()
|
QString TextCsvKeys::id()
|
||||||
{
|
{
|
||||||
return new TextCsvKeys();
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextCsvKeys::create()
|
||||||
|
{
|
||||||
|
return new TextCsvKeys();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-24
@@ -24,40 +24,46 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// TextCsvKeys Merge Backend
|
|
||||||
///
|
|
||||||
struct TextCsvKeys : public Text
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// TextCsvKeys Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
struct TextCsvKeys : public Text
|
||||||
TextCsvKeys();
|
{
|
||||||
TextCsvKeys( const TextCsvKeys* merge );
|
|
||||||
virtual ~TextCsvKeys();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextCsvKeys();
|
||||||
|
TextCsvKeys( const TextCsvKeys* merge );
|
||||||
|
virtual ~TextCsvKeys();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextCsvKeys* clone() const;
|
TextCsvKeys* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextCsvKeys_h
|
#endif // merge_TextCsvKeys_h
|
||||||
|
|||||||
@@ -21,60 +21,65 @@
|
|||||||
#include "TextSemicolon.h"
|
#include "TextSemicolon.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
static const QString ID = "Text/Semicolon";
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextSemicolon::TextSemicolon() : Text(';',false)
|
|
||||||
{
|
{
|
||||||
mId = ID;
|
static const QString ID = "Text/Semicolon";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextSemicolon::TextSemicolon( const TextSemicolon* merge ) : Text( merge )
|
TextSemicolon::TextSemicolon() : Text(';',false)
|
||||||
{
|
{
|
||||||
}
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextSemicolon::~TextSemicolon()
|
TextSemicolon::TextSemicolon( const TextSemicolon* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextSemicolon* TextSemicolon::clone() const
|
TextSemicolon::~TextSemicolon()
|
||||||
{
|
{
|
||||||
return new TextSemicolon( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextSemicolon::id()
|
TextSemicolon* TextSemicolon::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextSemicolon( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextSemicolon::create()
|
QString TextSemicolon::id()
|
||||||
{
|
{
|
||||||
return new TextSemicolon();
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextSemicolon::create()
|
||||||
|
{
|
||||||
|
return new TextSemicolon();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,40 +24,46 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// TextSemicolon Merge Backend
|
|
||||||
///
|
|
||||||
struct TextSemicolon : public Text
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// TextSemicolon Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
struct TextSemicolon : public Text
|
||||||
TextSemicolon();
|
{
|
||||||
TextSemicolon( const TextSemicolon* merge );
|
|
||||||
virtual ~TextSemicolon();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextSemicolon();
|
||||||
|
TextSemicolon( const TextSemicolon* merge );
|
||||||
|
virtual ~TextSemicolon();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextSemicolon* clone() const;
|
TextSemicolon* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextSemicolon_h
|
#endif // merge_TextSemicolon_h
|
||||||
|
|||||||
@@ -21,60 +21,65 @@
|
|||||||
#include "TextSemicolonKeys.h"
|
#include "TextSemicolonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
static const QString ID = "Text/Semicolon/Keys";
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextSemicolonKeys::TextSemicolonKeys() : Text(';',true)
|
|
||||||
{
|
{
|
||||||
mId = ID;
|
static const QString ID = "Text/Semicolon/Keys";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextSemicolonKeys::TextSemicolonKeys( const TextSemicolonKeys* merge ) : Text( merge )
|
TextSemicolonKeys::TextSemicolonKeys() : Text(';',true)
|
||||||
{
|
{
|
||||||
}
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextSemicolonKeys::~TextSemicolonKeys()
|
TextSemicolonKeys::TextSemicolonKeys( const TextSemicolonKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextSemicolonKeys* TextSemicolonKeys::clone() const
|
TextSemicolonKeys::~TextSemicolonKeys()
|
||||||
{
|
{
|
||||||
return new TextSemicolonKeys( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextSemicolonKeys::id()
|
TextSemicolonKeys* TextSemicolonKeys::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextSemicolonKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextSemicolonKeys::create()
|
QString TextSemicolonKeys::id()
|
||||||
{
|
{
|
||||||
return new TextSemicolonKeys();
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextSemicolonKeys::create()
|
||||||
|
{
|
||||||
|
return new TextSemicolonKeys();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,40 +24,46 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// TextSemicolonKeys Merge Backend
|
|
||||||
///
|
|
||||||
struct TextSemicolonKeys : public Text
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// TextSemicolonKeys Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
struct TextSemicolonKeys : public Text
|
||||||
TextSemicolonKeys();
|
{
|
||||||
TextSemicolonKeys( const TextSemicolonKeys* merge );
|
|
||||||
virtual ~TextSemicolonKeys();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextSemicolonKeys();
|
||||||
|
TextSemicolonKeys( const TextSemicolonKeys* merge );
|
||||||
|
virtual ~TextSemicolonKeys();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextSemicolonKeys* clone() const;
|
TextSemicolonKeys* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextSemicolonKeys_h
|
#endif // merge_TextSemicolonKeys_h
|
||||||
|
|||||||
+46
-41
@@ -21,60 +21,65 @@
|
|||||||
#include "TextTsv.h"
|
#include "TextTsv.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
static const QString ID = "Text/Tab";
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextTsv::TextTsv() : Text('\t',false)
|
|
||||||
{
|
{
|
||||||
mId = ID;
|
static const QString ID = "Text/Tab";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
|
TextTsv::TextTsv() : Text('\t',false)
|
||||||
{
|
{
|
||||||
}
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextTsv::~TextTsv()
|
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextTsv* TextTsv::clone() const
|
TextTsv::~TextTsv()
|
||||||
{
|
{
|
||||||
return new TextTsv( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextTsv::id()
|
TextTsv* TextTsv::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextTsv( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextTsv::create()
|
QString TextTsv::id()
|
||||||
{
|
{
|
||||||
return new TextTsv();
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextTsv::create()
|
||||||
|
{
|
||||||
|
return new TextTsv();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-24
@@ -24,40 +24,46 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// TextTsv Merge Backend
|
|
||||||
///
|
|
||||||
struct TextTsv : public Text
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// TextTsv Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
struct TextTsv : public Text
|
||||||
TextTsv();
|
{
|
||||||
TextTsv( const TextTsv* merge );
|
|
||||||
virtual ~TextTsv();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextTsv();
|
||||||
|
TextTsv( const TextTsv* merge );
|
||||||
|
virtual ~TextTsv();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextTsv* clone() const;
|
TextTsv* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextTsv_h
|
#endif // merge_TextTsv_h
|
||||||
|
|||||||
@@ -21,60 +21,65 @@
|
|||||||
#include "TextTsvKeys.h"
|
#include "TextTsvKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
static const QString ID = "Text/Tab/Line1Keys";
|
|
||||||
|
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextTsvKeys::TextTsvKeys() : Text('\t',true)
|
|
||||||
{
|
{
|
||||||
mId = ID;
|
static const QString ID = "Text/Tab/Line1Keys";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextTsvKeys::TextTsvKeys( const TextTsvKeys* merge ) : Text( merge )
|
TextTsvKeys::TextTsvKeys() : Text('\t',true)
|
||||||
{
|
{
|
||||||
}
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextTsvKeys::~TextTsvKeys()
|
TextTsvKeys::TextTsvKeys( const TextTsvKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextTsvKeys* TextTsvKeys::clone() const
|
TextTsvKeys::~TextTsvKeys()
|
||||||
{
|
{
|
||||||
return new TextTsvKeys( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextTsvKeys::id()
|
TextTsvKeys* TextTsvKeys::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextTsvKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextTsvKeys::create()
|
QString TextTsvKeys::id()
|
||||||
{
|
{
|
||||||
return new TextTsvKeys();
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextTsvKeys::create()
|
||||||
|
{
|
||||||
|
return new TextTsvKeys();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-24
@@ -24,40 +24,46 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
namespace merge
|
||||||
/// TextTsvKeys Merge Backend
|
|
||||||
///
|
|
||||||
struct TextTsvKeys : public Text
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// TextTsvKeys Merge Backend
|
||||||
/////////////////////////////////
|
///
|
||||||
private:
|
struct TextTsvKeys : public Text
|
||||||
TextTsvKeys();
|
{
|
||||||
TextTsvKeys( const TextTsvKeys* merge );
|
|
||||||
virtual ~TextTsvKeys();
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextTsvKeys();
|
||||||
|
TextTsvKeys( const TextTsvKeys* merge );
|
||||||
|
virtual ~TextTsvKeys();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextTsvKeys* clone() const;
|
TextTsvKeys* clone() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextTsvKeys_h
|
#endif // merge_TextTsvKeys_h
|
||||||
|
|||||||
+266
-253
@@ -30,289 +30,302 @@
|
|||||||
#include "Merge/Factory.h"
|
#include "Merge/Factory.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
MergeView::MergeView( QWidget *parent )
|
|
||||||
: QWidget(parent), mModel(0), mBlock(false)
|
|
||||||
{
|
{
|
||||||
setupUi( this );
|
|
||||||
|
|
||||||
mMergeFormatNames = merge::Factory::nameList();
|
///
|
||||||
formatCombo->addItems( mMergeFormatNames );
|
/// Constructor
|
||||||
}
|
///
|
||||||
|
MergeView::MergeView( QWidget *parent )
|
||||||
|
: QWidget(parent), mModel(0), mBlock(false)
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
MergeView::~MergeView()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Set Model
|
|
||||||
///
|
|
||||||
void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
|
||||||
{
|
|
||||||
mModel = model;
|
|
||||||
mUndoRedoModel = undoRedoModel;
|
|
||||||
|
|
||||||
// Initialize CWD
|
|
||||||
if ( model->fileName().isEmpty() )
|
|
||||||
{
|
{
|
||||||
mCwd = ".";
|
setupUi( this );
|
||||||
}
|
|
||||||
else
|
mMergeFormatNames = merge::Factory::nameList();
|
||||||
{
|
formatCombo->addItems( mMergeFormatNames );
|
||||||
mCwd = QFileInfo( model->fileName() ).absolutePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMergeChanged();
|
|
||||||
connect( mModel, SIGNAL(mergeChanged()), this, SLOT(onMergeChanged()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Destructor
|
||||||
/// Merge changed handler
|
///
|
||||||
///
|
MergeView::~MergeView()
|
||||||
void MergeView::onMergeChanged()
|
|
||||||
{
|
|
||||||
int index = mMergeFormatNames.indexOf( merge::Factory::idToName( mModel->merge()->id() ) );
|
|
||||||
mOldFormatComboIndex = index;
|
|
||||||
formatCombo->setCurrentIndex( index );
|
|
||||||
|
|
||||||
switch ( merge::Factory::idToType( mModel->merge()->id() ) )
|
|
||||||
{
|
{
|
||||||
case merge::Factory::NONE:
|
// empty
|
||||||
case merge::Factory::FIXED:
|
}
|
||||||
locationLabel->setEnabled( false );
|
|
||||||
locationButton->setEnabled( false );
|
|
||||||
locationButton->setText( "" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case merge::Factory::FILE:
|
|
||||||
locationLabel->setEnabled( true );
|
///
|
||||||
locationButton->setEnabled( true );
|
/// Set Model
|
||||||
if ( mModel->merge()->source().isEmpty() )
|
///
|
||||||
|
void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||||
|
{
|
||||||
|
mModel = model;
|
||||||
|
mUndoRedoModel = undoRedoModel;
|
||||||
|
|
||||||
|
// Initialize CWD
|
||||||
|
if ( model->fileName().isEmpty() )
|
||||||
{
|
{
|
||||||
locationButton->setText( "Select file..." );
|
mCwd = ".";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
locationButton->setText( mModel->merge()->source() );
|
mCwd = QFileInfo( model->fileName() ).absolutePath();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
onMergeChanged();
|
||||||
qWarning( "MergeView::onMergeChanged()::Should not be reached!" );
|
connect( mModel, SIGNAL(mergeChanged()), this, SLOT(onMergeChanged()) );
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recordsTable->clear();
|
|
||||||
recordsTable->setColumnCount( 0 );
|
|
||||||
loadHeaders( mModel->merge() );
|
|
||||||
loadTable( mModel->merge() );
|
|
||||||
|
|
||||||
connect( mModel->merge(), SIGNAL(sourceChanged()), this, SLOT(onMergeSourceChanged()) );
|
///
|
||||||
connect( mModel->merge(), SIGNAL(selectionChanged()), this, SLOT(onMergeSelectionChanged()) );
|
/// Merge changed handler
|
||||||
|
///
|
||||||
connect( recordsTable, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)) );
|
void MergeView::onMergeChanged()
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Merge source changed handler
|
|
||||||
///
|
|
||||||
void MergeView::onMergeSourceChanged()
|
|
||||||
{
|
|
||||||
locationButton->setText( mModel->merge()->source() );
|
|
||||||
|
|
||||||
recordsTable->clear();
|
|
||||||
recordsTable->setColumnCount( 0 );
|
|
||||||
loadHeaders( mModel->merge() );
|
|
||||||
loadTable( mModel->merge() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Merge selection changed handler
|
|
||||||
///
|
|
||||||
void MergeView::onMergeSelectionChanged()
|
|
||||||
{
|
|
||||||
mBlock = true; // Don't recurse
|
|
||||||
|
|
||||||
const QList<merge::Record*>& records = mModel->merge()->recordList();
|
|
||||||
|
|
||||||
int iRow = 0;
|
|
||||||
foreach ( merge::Record* record, records )
|
|
||||||
{
|
|
||||||
QTableWidgetItem* item = recordsTable->item( iRow, 0 );
|
|
||||||
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
|
|
||||||
|
|
||||||
iRow++;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBlock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Format combo changed handler
|
|
||||||
void MergeView::onFormatComboActivated()
|
|
||||||
{
|
|
||||||
int index = formatCombo->currentIndex();
|
|
||||||
if ( index != mOldFormatComboIndex )
|
|
||||||
{
|
{
|
||||||
|
QString name = merge::Factory::idToName( mModel->merge()->id() );
|
||||||
|
int index = mMergeFormatNames.indexOf( name );
|
||||||
mOldFormatComboIndex = index;
|
mOldFormatComboIndex = index;
|
||||||
|
formatCombo->setCurrentIndex( index );
|
||||||
|
|
||||||
mModel->setMerge( merge::Factory::createMerge( merge::Factory::indexToId(index) ) );
|
switch ( merge::Factory::idToType( mModel->merge()->id() ) )
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Location button clicked handler
|
|
||||||
///
|
|
||||||
void MergeView::onLocationButtonClicked()
|
|
||||||
{
|
|
||||||
QString fileName =
|
|
||||||
QFileDialog::getOpenFileName( this,
|
|
||||||
tr("Select merge file"),
|
|
||||||
mCwd,
|
|
||||||
tr("All files (*)") );
|
|
||||||
if ( !fileName.isEmpty() )
|
|
||||||
{
|
|
||||||
mModel->merge()->setSource( fileName );
|
|
||||||
mCwd = QFileInfo( fileName ).absolutePath(); // Update CWD
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Select all button clicked handler
|
|
||||||
///
|
|
||||||
void MergeView::onSelectAllButtonClicked()
|
|
||||||
{
|
|
||||||
mModel->merge()->selectAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Unselect all button clicked handler
|
|
||||||
///
|
|
||||||
void MergeView::onUnselectAllButtonClicked()
|
|
||||||
{
|
|
||||||
mModel->merge()->unselectAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Cell changed handler
|
|
||||||
///
|
|
||||||
void MergeView::onCellChanged( int iRow, int iCol )
|
|
||||||
{
|
|
||||||
if ( !mBlock )
|
|
||||||
{
|
|
||||||
QTableWidgetItem* item = recordsTable->item( iRow, 0 );
|
|
||||||
bool state = (item->checkState() == Qt::Unchecked) ? false : true;
|
|
||||||
|
|
||||||
mModel->merge()->setSelected( iRow, state );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Load headers
|
|
||||||
///
|
|
||||||
void MergeView::loadHeaders( merge::Merge* merge )
|
|
||||||
{
|
|
||||||
mPrimaryKey = merge->primaryKey();
|
|
||||||
mKeys = merge->keys();
|
|
||||||
|
|
||||||
if ( mKeys.size() > 0 )
|
|
||||||
{
|
|
||||||
recordsTable->setColumnCount( mKeys.size() + 1 ); // Include extra column
|
|
||||||
|
|
||||||
// First column = primay Key
|
|
||||||
QTableWidgetItem* item = new QTableWidgetItem( mPrimaryKey );
|
|
||||||
item->setFlags( Qt::ItemIsEnabled );
|
|
||||||
recordsTable->setHorizontalHeaderItem( 0, item );
|
|
||||||
|
|
||||||
// Starting on second column, one column per key, skip primary Key
|
|
||||||
int iCol = 1;
|
|
||||||
foreach ( QString key, mKeys )
|
|
||||||
{
|
{
|
||||||
if ( key != mPrimaryKey )
|
case merge::Factory::NONE:
|
||||||
{
|
case merge::Factory::FIXED:
|
||||||
QTableWidgetItem* item = new QTableWidgetItem( key );
|
locationLabel->setEnabled( false );
|
||||||
item->setFlags( Qt::ItemIsEnabled );
|
locationButton->setEnabled( false );
|
||||||
recordsTable->setHorizontalHeaderItem( iCol, item );
|
locationButton->setText( "" );
|
||||||
|
break;
|
||||||
|
|
||||||
iCol++;
|
case merge::Factory::FILE:
|
||||||
|
locationLabel->setEnabled( true );
|
||||||
|
locationButton->setEnabled( true );
|
||||||
|
if ( mModel->merge()->source().isEmpty() )
|
||||||
|
{
|
||||||
|
locationButton->setText( "Select file..." );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
}
|
|
||||||
|
|
||||||
// Extra dummy column to fill any extra horizontal space
|
|
||||||
QTableWidgetItem* fillItem = new QTableWidgetItem();
|
|
||||||
fillItem->setFlags( Qt::NoItemFlags );
|
|
||||||
recordsTable->setHorizontalHeaderItem( iCol, fillItem );
|
|
||||||
recordsTable->horizontalHeader()->setStretchLastSection( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Load table
|
|
||||||
///
|
|
||||||
void MergeView::loadTable( merge::Merge* merge )
|
|
||||||
{
|
|
||||||
mBlock = true;
|
|
||||||
|
|
||||||
const QList<merge::Record*>& records = merge->recordList();
|
|
||||||
recordsTable->setRowCount( records.size() );
|
|
||||||
|
|
||||||
int iRow = 0;
|
|
||||||
foreach ( merge::Record* record, records )
|
|
||||||
{
|
|
||||||
// First column for primay field
|
|
||||||
QTableWidgetItem* item = new QTableWidgetItem();
|
|
||||||
if ( record->contains( mPrimaryKey ) )
|
|
||||||
{
|
|
||||||
item->setText( (*record)[mPrimaryKey] );
|
|
||||||
}
|
|
||||||
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
|
|
||||||
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
|
|
||||||
recordsTable->setItem( iRow, 0, item );
|
|
||||||
recordsTable->resizeColumnToContents( 0 );
|
|
||||||
|
|
||||||
// Starting on second column, one column per field (even if empty), skip primary field
|
|
||||||
int iCol = 1;
|
|
||||||
foreach ( QString key, mKeys )
|
|
||||||
{
|
|
||||||
if ( key != mPrimaryKey )
|
|
||||||
{
|
{
|
||||||
if ( record->contains( key ) )
|
locationButton->setText( mModel->merge()->source() );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
qWarning( "MergeView::onMergeChanged()::Should not be reached!" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
recordsTable->clear();
|
||||||
|
recordsTable->setColumnCount( 0 );
|
||||||
|
loadHeaders( mModel->merge() );
|
||||||
|
loadTable( mModel->merge() );
|
||||||
|
|
||||||
|
connect( mModel->merge(), SIGNAL(sourceChanged()),
|
||||||
|
this, SLOT(onMergeSourceChanged()) );
|
||||||
|
|
||||||
|
connect( mModel->merge(), SIGNAL(selectionChanged()),
|
||||||
|
this, SLOT(onMergeSelectionChanged()) );
|
||||||
|
|
||||||
|
connect( recordsTable, SIGNAL(cellChanged(int,int)),
|
||||||
|
this, SLOT(onCellChanged(int,int)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Merge source changed handler
|
||||||
|
///
|
||||||
|
void MergeView::onMergeSourceChanged()
|
||||||
|
{
|
||||||
|
locationButton->setText( mModel->merge()->source() );
|
||||||
|
|
||||||
|
recordsTable->clear();
|
||||||
|
recordsTable->setColumnCount( 0 );
|
||||||
|
loadHeaders( mModel->merge() );
|
||||||
|
loadTable( mModel->merge() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Merge selection changed handler
|
||||||
|
///
|
||||||
|
void MergeView::onMergeSelectionChanged()
|
||||||
|
{
|
||||||
|
mBlock = true; // Don't recurse
|
||||||
|
|
||||||
|
const QList<merge::Record*>& records = mModel->merge()->recordList();
|
||||||
|
|
||||||
|
int iRow = 0;
|
||||||
|
foreach ( merge::Record* record, records )
|
||||||
|
{
|
||||||
|
QTableWidgetItem* item = recordsTable->item( iRow, 0 );
|
||||||
|
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
|
||||||
|
|
||||||
|
iRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mBlock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Format combo changed handler
|
||||||
|
///
|
||||||
|
void MergeView::onFormatComboActivated()
|
||||||
|
{
|
||||||
|
int index = formatCombo->currentIndex();
|
||||||
|
if ( index != mOldFormatComboIndex )
|
||||||
|
{
|
||||||
|
mOldFormatComboIndex = index;
|
||||||
|
|
||||||
|
QString id = merge::Factory::indexToId(index);
|
||||||
|
mModel->setMerge( merge::Factory::createMerge( id ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Location button clicked handler
|
||||||
|
///
|
||||||
|
void MergeView::onLocationButtonClicked()
|
||||||
|
{
|
||||||
|
QString fileName =
|
||||||
|
QFileDialog::getOpenFileName( this,
|
||||||
|
tr("Select merge file"),
|
||||||
|
mCwd,
|
||||||
|
tr("All files (*)") );
|
||||||
|
if ( !fileName.isEmpty() )
|
||||||
|
{
|
||||||
|
mModel->merge()->setSource( fileName );
|
||||||
|
mCwd = QFileInfo( fileName ).absolutePath(); // Update CWD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Select all button clicked handler
|
||||||
|
///
|
||||||
|
void MergeView::onSelectAllButtonClicked()
|
||||||
|
{
|
||||||
|
mModel->merge()->selectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Unselect all button clicked handler
|
||||||
|
///
|
||||||
|
void MergeView::onUnselectAllButtonClicked()
|
||||||
|
{
|
||||||
|
mModel->merge()->unselectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Cell changed handler
|
||||||
|
///
|
||||||
|
void MergeView::onCellChanged( int iRow, int iCol )
|
||||||
|
{
|
||||||
|
if ( !mBlock )
|
||||||
|
{
|
||||||
|
QTableWidgetItem* item = recordsTable->item( iRow, 0 );
|
||||||
|
bool state = (item->checkState() == Qt::Unchecked) ? false : true;
|
||||||
|
|
||||||
|
mModel->merge()->setSelected( iRow, state );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Load headers
|
||||||
|
///
|
||||||
|
void MergeView::loadHeaders( merge::Merge* merge )
|
||||||
|
{
|
||||||
|
mPrimaryKey = merge->primaryKey();
|
||||||
|
mKeys = merge->keys();
|
||||||
|
|
||||||
|
if ( mKeys.size() > 0 )
|
||||||
|
{
|
||||||
|
recordsTable->setColumnCount( mKeys.size() + 1 ); // Include extra column
|
||||||
|
|
||||||
|
// First column = primay Key
|
||||||
|
QTableWidgetItem* item = new QTableWidgetItem( mPrimaryKey );
|
||||||
|
item->setFlags( Qt::ItemIsEnabled );
|
||||||
|
recordsTable->setHorizontalHeaderItem( 0, item );
|
||||||
|
|
||||||
|
// Starting on second column, one column per key, skip primary Key
|
||||||
|
int iCol = 1;
|
||||||
|
foreach ( QString key, mKeys )
|
||||||
|
{
|
||||||
|
if ( key != mPrimaryKey )
|
||||||
{
|
{
|
||||||
QTableWidgetItem* item = new QTableWidgetItem( (*record)[key] );
|
QTableWidgetItem* item = new QTableWidgetItem( key );
|
||||||
item->setFlags( Qt::ItemIsEnabled );
|
item->setFlags( Qt::ItemIsEnabled );
|
||||||
recordsTable->setItem( iRow, iCol, item );
|
recordsTable->setHorizontalHeaderItem( iCol, item );
|
||||||
recordsTable->resizeColumnToContents( iCol );
|
|
||||||
|
iCol++;
|
||||||
}
|
}
|
||||||
|
|
||||||
iCol++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extra dummy column to fill any extra horizontal space
|
||||||
|
QTableWidgetItem* fillItem = new QTableWidgetItem();
|
||||||
|
fillItem->setFlags( Qt::NoItemFlags );
|
||||||
|
recordsTable->setHorizontalHeaderItem( iCol, fillItem );
|
||||||
|
recordsTable->horizontalHeader()->setStretchLastSection( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra dummy column to fill any extra horizontal space
|
|
||||||
QTableWidgetItem* fillItem = new QTableWidgetItem();
|
|
||||||
fillItem->setFlags( Qt::NoItemFlags );
|
|
||||||
recordsTable->setItem( iRow, iCol, fillItem );
|
|
||||||
|
|
||||||
iRow++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mBlock = false;
|
|
||||||
|
///
|
||||||
|
/// Load table
|
||||||
|
///
|
||||||
|
void MergeView::loadTable( merge::Merge* merge )
|
||||||
|
{
|
||||||
|
mBlock = true;
|
||||||
|
|
||||||
|
const QList<merge::Record*>& records = merge->recordList();
|
||||||
|
recordsTable->setRowCount( records.size() );
|
||||||
|
|
||||||
|
int iRow = 0;
|
||||||
|
foreach ( merge::Record* record, records )
|
||||||
|
{
|
||||||
|
// First column for primay field
|
||||||
|
QTableWidgetItem* item = new QTableWidgetItem();
|
||||||
|
if ( record->contains( mPrimaryKey ) )
|
||||||
|
{
|
||||||
|
item->setText( (*record)[mPrimaryKey] );
|
||||||
|
}
|
||||||
|
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
|
||||||
|
item->setCheckState( record->isSelected() ? Qt::Checked : Qt::Unchecked );
|
||||||
|
recordsTable->setItem( iRow, 0, item );
|
||||||
|
recordsTable->resizeColumnToContents( 0 );
|
||||||
|
|
||||||
|
// Starting on 2nd column, 1 column per field, skip primary field
|
||||||
|
int iCol = 1;
|
||||||
|
foreach ( QString key, mKeys )
|
||||||
|
{
|
||||||
|
if ( key != mPrimaryKey )
|
||||||
|
{
|
||||||
|
if ( record->contains( key ) )
|
||||||
|
{
|
||||||
|
QTableWidgetItem* item = new QTableWidgetItem( (*record)[key] );
|
||||||
|
item->setFlags( Qt::ItemIsEnabled );
|
||||||
|
recordsTable->setItem( iRow, iCol, item );
|
||||||
|
recordsTable->resizeColumnToContents( iCol );
|
||||||
|
}
|
||||||
|
|
||||||
|
iCol++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extra dummy column to fill any extra horizontal space
|
||||||
|
QTableWidgetItem* fillItem = new QTableWidgetItem();
|
||||||
|
fillItem->setFlags( Qt::NoItemFlags );
|
||||||
|
recordsTable->setItem( iRow, iCol, fillItem );
|
||||||
|
|
||||||
|
iRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mBlock = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+57
-51
@@ -26,74 +26,80 @@
|
|||||||
|
|
||||||
#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
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
// Forward references
|
||||||
|
class LabelModel;
|
||||||
|
class UndoRedoModel;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// merge::Merge Property Editor Widget
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class MergeView : public QWidget, public Ui_MergeView
|
||||||
MergeView( QWidget *parent = 0 );
|
{
|
||||||
~MergeView();
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public methods
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel );
|
public:
|
||||||
|
MergeView( QWidget *parent = 0 );
|
||||||
|
~MergeView();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Public methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel );
|
||||||
void onMergeChanged();
|
|
||||||
void onMergeSourceChanged();
|
|
||||||
void onMergeSelectionChanged();
|
|
||||||
|
|
||||||
void onFormatComboActivated();
|
|
||||||
void onLocationButtonClicked();
|
|
||||||
void onSelectAllButtonClicked();
|
|
||||||
void onUnselectAllButtonClicked();
|
|
||||||
void onCellChanged( int iRow, int iCol );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private methods
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private slots:
|
||||||
void loadHeaders( merge::Merge* merge );
|
void onMergeChanged();
|
||||||
void loadTable( merge::Merge* merge );
|
void onMergeSourceChanged();
|
||||||
|
void onMergeSelectionChanged();
|
||||||
|
|
||||||
|
void onFormatComboActivated();
|
||||||
|
void onLocationButtonClicked();
|
||||||
|
void onSelectAllButtonClicked();
|
||||||
|
void onUnselectAllButtonClicked();
|
||||||
|
void onCellChanged( int iRow, int iCol );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QStringList mMergeFormatNames;
|
void loadHeaders( merge::Merge* merge );
|
||||||
|
void loadTable( merge::Merge* merge );
|
||||||
|
|
||||||
LabelModel* mModel;
|
|
||||||
UndoRedoModel* mUndoRedoModel;
|
|
||||||
|
|
||||||
QStringList mKeys;
|
/////////////////////////////////
|
||||||
QString mPrimaryKey;
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
QStringList mMergeFormatNames;
|
||||||
|
|
||||||
QString mCwd;
|
LabelModel* mModel;
|
||||||
|
UndoRedoModel* mUndoRedoModel;
|
||||||
|
|
||||||
bool mBlock;
|
QStringList mKeys;
|
||||||
int mOldFormatComboIndex;
|
QString mPrimaryKey;
|
||||||
|
|
||||||
};
|
QString mCwd;
|
||||||
|
|
||||||
|
bool mBlock;
|
||||||
|
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