Removed C++17 nested namespace definitions. Should build on trusty again.
This commit is contained in:
+394
-391
@@ -27,502 +27,505 @@
|
|||||||
#include "glbarcode/Factory.h"
|
#include "glbarcode/Factory.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::barcode
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace barcode
|
||||||
//
|
|
||||||
// Static data
|
|
||||||
//
|
|
||||||
QStringList Backends::mBackendIdList;
|
|
||||||
QMap<QString,QString> Backends::mBackendNameMap;
|
|
||||||
|
|
||||||
QList<Style> Backends::mStyleList;
|
|
||||||
|
|
||||||
|
|
||||||
Backends::Backends()
|
|
||||||
{
|
{
|
||||||
registerStyle( "code39", "", tr("Code 39"),
|
|
||||||
true, true, true, true, "1234567890", true, 10 );
|
//
|
||||||
|
// Static data
|
||||||
|
//
|
||||||
|
QStringList Backends::mBackendIdList;
|
||||||
|
QMap<QString,QString> Backends::mBackendNameMap;
|
||||||
|
|
||||||
registerStyle( "code39ext", "", tr("Code 39 Extended"),
|
QList<Style> Backends::mStyleList;
|
||||||
true, true, true, true, "1234567890", true, 10 );
|
|
||||||
|
|
||||||
registerStyle( "upc-a", "", tr("UPC-A"),
|
Backends::Backends()
|
||||||
true, false, true, false, "12345678901", false, 11 );
|
{
|
||||||
|
registerStyle( "code39", "", tr("Code 39"),
|
||||||
|
true, true, true, true, "1234567890", true, 10 );
|
||||||
|
|
||||||
registerStyle( "ean-13", "", tr("EAN-13"),
|
registerStyle( "code39ext", "", tr("Code 39 Extended"),
|
||||||
true, false, true, false, "123456789012", false, 12 );
|
true, true, true, true, "1234567890", true, 10 );
|
||||||
|
|
||||||
registerStyle( "postnet", "", tr("POSTNET (any)"),
|
registerStyle( "upc-a", "", tr("UPC-A"),
|
||||||
false, false, true, false, "12345-6789-12", false, 11 );
|
true, false, true, false, "12345678901", false, 11 );
|
||||||
|
|
||||||
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
|
registerStyle( "ean-13", "", tr("EAN-13"),
|
||||||
false, false, true, false, "12345", false, 5 );
|
true, false, true, false, "123456789012", false, 12 );
|
||||||
|
|
||||||
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
|
registerStyle( "postnet", "", tr("POSTNET (any)"),
|
||||||
false, false, true, false, "12345-6789", false, 9 );
|
false, false, true, false, "12345-6789-12", false, 11 );
|
||||||
|
|
||||||
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
|
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
|
||||||
false, false, true, false, "12345-6789-12", false, 11 );
|
false, false, true, false, "12345", false, 5 );
|
||||||
|
|
||||||
registerStyle( "cepnet", "", tr("CEPNET"),
|
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
|
||||||
false, false, true, false, "12345-678", false, 8 );
|
false, false, true, false, "12345-6789", false, 9 );
|
||||||
|
|
||||||
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
|
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
|
||||||
false, false, true, false, "12345678901234567890", false, 20 );
|
false, false, true, false, "12345-6789-12", false, 11 );
|
||||||
|
|
||||||
registerStyle( "datamatrix", "", tr("IEC16022 (DataMatrix)"),
|
registerStyle( "cepnet", "", tr("CEPNET"),
|
||||||
false, false, true, false, "1234567890AB", false, 12 );
|
false, false, true, false, "12345-678", false, 8 );
|
||||||
|
|
||||||
|
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
|
||||||
|
false, false, true, false, "12345678901234567890", false, 20 );
|
||||||
|
|
||||||
|
registerStyle( "datamatrix", "", tr("IEC16022 (DataMatrix)"),
|
||||||
|
false, false, true, false, "1234567890AB", false, 12 );
|
||||||
|
|
||||||
#if HAVE_GNU_BARCODE
|
#if HAVE_GNU_BARCODE
|
||||||
//
|
//
|
||||||
// GNU Barcode backend
|
// GNU Barcode backend
|
||||||
//
|
//
|
||||||
registerBackend( "gnu-barcode", "GNU Barcode" );
|
registerBackend( "gnu-barcode", "GNU Barcode" );
|
||||||
|
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::ean", GnuBarcode::Ean::create );
|
glbarcode::Factory::registerType( "gnu-barcode::ean", GnuBarcode::Ean::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::ean-8", GnuBarcode::Ean8::create );
|
glbarcode::Factory::registerType( "gnu-barcode::ean-8", GnuBarcode::Ean8::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::ean-8+2", GnuBarcode::Ean8_2::create );
|
glbarcode::Factory::registerType( "gnu-barcode::ean-8+2", GnuBarcode::Ean8_2::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::ean-8+5", GnuBarcode::Ean8_5::create );
|
glbarcode::Factory::registerType( "gnu-barcode::ean-8+5", GnuBarcode::Ean8_5::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::ean-13", GnuBarcode::Ean13::create );
|
glbarcode::Factory::registerType( "gnu-barcode::ean-13", GnuBarcode::Ean13::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::ean-13+2", GnuBarcode::Ean13_2::create );
|
glbarcode::Factory::registerType( "gnu-barcode::ean-13+2", GnuBarcode::Ean13_2::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::ean-13+5", GnuBarcode::Ean13_5::create );
|
glbarcode::Factory::registerType( "gnu-barcode::ean-13+5", GnuBarcode::Ean13_5::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::upc", GnuBarcode::Upc::create );
|
glbarcode::Factory::registerType( "gnu-barcode::upc", GnuBarcode::Upc::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::upc-a", GnuBarcode::UpcA::create );
|
glbarcode::Factory::registerType( "gnu-barcode::upc-a", GnuBarcode::UpcA::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::upc-a+2", GnuBarcode::UpcA_2::create );
|
glbarcode::Factory::registerType( "gnu-barcode::upc-a+2", GnuBarcode::UpcA_2::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::upc-a+5", GnuBarcode::UpcA_5::create );
|
glbarcode::Factory::registerType( "gnu-barcode::upc-a+5", GnuBarcode::UpcA_5::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::upc-e", GnuBarcode::UpcE::create );
|
glbarcode::Factory::registerType( "gnu-barcode::upc-e", GnuBarcode::UpcE::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::upc-e+2", GnuBarcode::UpcE_2::create );
|
glbarcode::Factory::registerType( "gnu-barcode::upc-e+2", GnuBarcode::UpcE_2::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::upc-e+5", GnuBarcode::UpcE_5::create );
|
glbarcode::Factory::registerType( "gnu-barcode::upc-e+5", GnuBarcode::UpcE_5::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::isbn", GnuBarcode::Isbn::create );
|
glbarcode::Factory::registerType( "gnu-barcode::isbn", GnuBarcode::Isbn::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::isbn+5", GnuBarcode::Isbn_5::create );
|
glbarcode::Factory::registerType( "gnu-barcode::isbn+5", GnuBarcode::Isbn_5::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::code39", GnuBarcode::Code39::create );
|
glbarcode::Factory::registerType( "gnu-barcode::code39", GnuBarcode::Code39::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::code128", GnuBarcode::Code128::create );
|
glbarcode::Factory::registerType( "gnu-barcode::code128", GnuBarcode::Code128::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::code128c", GnuBarcode::Code128C::create );
|
glbarcode::Factory::registerType( "gnu-barcode::code128c", GnuBarcode::Code128C::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::code128b", GnuBarcode::Code128B::create );
|
glbarcode::Factory::registerType( "gnu-barcode::code128b", GnuBarcode::Code128B::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::i25", GnuBarcode::I25::create );
|
glbarcode::Factory::registerType( "gnu-barcode::i25", GnuBarcode::I25::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::cbr", GnuBarcode::Cbr::create );
|
glbarcode::Factory::registerType( "gnu-barcode::cbr", GnuBarcode::Cbr::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::msi", GnuBarcode::Msi::create );
|
glbarcode::Factory::registerType( "gnu-barcode::msi", GnuBarcode::Msi::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::pls", GnuBarcode::Pls::create );
|
glbarcode::Factory::registerType( "gnu-barcode::pls", GnuBarcode::Pls::create );
|
||||||
glbarcode::Factory::registerType( "gnu-barcode::code93", GnuBarcode::Code93::create );
|
glbarcode::Factory::registerType( "gnu-barcode::code93", GnuBarcode::Code93::create );
|
||||||
|
|
||||||
registerStyle( "ean", "gnu-barcode", tr("EAN (any)"),
|
registerStyle( "ean", "gnu-barcode", tr("EAN (any)"),
|
||||||
true, true, true, false, "000000000000 00000", false, 17 );
|
true, true, true, false, "000000000000 00000", false, 17 );
|
||||||
registerStyle( "ean-8", "gnu-barcode", tr("EAN-8"),
|
registerStyle( "ean-8", "gnu-barcode", tr("EAN-8"),
|
||||||
true, true, true, false, "0000000", false, 7 );
|
true, true, true, false, "0000000", false, 7 );
|
||||||
registerStyle( "ean-8+2", "gnu-barcode", tr("EAN-8+2"),
|
registerStyle( "ean-8+2", "gnu-barcode", tr("EAN-8+2"),
|
||||||
true, true, true, false, "0000000 00", false, 9 );
|
true, true, true, false, "0000000 00", false, 9 );
|
||||||
registerStyle( "ean-8+5", "gnu-barcode", tr("EAN-8+5"),
|
registerStyle( "ean-8+5", "gnu-barcode", tr("EAN-8+5"),
|
||||||
true, true, true, false, "0000000 00000", false, 12 );
|
true, true, true, false, "0000000 00000", false, 12 );
|
||||||
registerStyle( "ean-13", "gnu-barcode", tr("EAN-13"),
|
registerStyle( "ean-13", "gnu-barcode", tr("EAN-13"),
|
||||||
true, true, true, false, "000000000000", false, 12 );
|
true, true, true, false, "000000000000", false, 12 );
|
||||||
registerStyle( "ean-13+2", "gnu-barcode", tr("EAN-13+2"),
|
registerStyle( "ean-13+2", "gnu-barcode", tr("EAN-13+2"),
|
||||||
true, true, true, false, "000000000000 00", false, 14 );
|
true, true, true, false, "000000000000 00", false, 14 );
|
||||||
registerStyle( "ean-13+5", "gnu-barcode", tr("EAN-13+5"),
|
registerStyle( "ean-13+5", "gnu-barcode", tr("EAN-13+5"),
|
||||||
true, true, true, false, "000000000000 00000", false, 17 );
|
true, true, true, false, "000000000000 00000", false, 17 );
|
||||||
registerStyle( "upc", "gnu-barcode", tr("UPC (UPC-A or UPC-E)"),
|
registerStyle( "upc", "gnu-barcode", tr("UPC (UPC-A or UPC-E)"),
|
||||||
true, true, true, false, "00000000000 00000", false, 16 );
|
true, true, true, false, "00000000000 00000", false, 16 );
|
||||||
registerStyle( "upc-a", "gnu-barcode", tr("UPC-A"),
|
registerStyle( "upc-a", "gnu-barcode", tr("UPC-A"),
|
||||||
true, true, true, false, "00000000000", false, 11 );
|
true, true, true, false, "00000000000", false, 11 );
|
||||||
registerStyle( "upc-a+2", "gnu-barcode", tr("UPC-A +2"),
|
registerStyle( "upc-a+2", "gnu-barcode", tr("UPC-A +2"),
|
||||||
true, true, true, false, "00000000000 00", false, 13 );
|
true, true, true, false, "00000000000 00", false, 13 );
|
||||||
registerStyle( "upc-a+5", "gnu-barcode", tr("UPC-A +5"),
|
registerStyle( "upc-a+5", "gnu-barcode", tr("UPC-A +5"),
|
||||||
true, true, true, false, "00000000000 00000", false, 16 );
|
true, true, true, false, "00000000000 00000", false, 16 );
|
||||||
registerStyle( "upc-e", "gnu-barcode", tr("UPC-E"),
|
registerStyle( "upc-e", "gnu-barcode", tr("UPC-E"),
|
||||||
true, true, true, false, "000000", false, 6 );
|
true, true, true, false, "000000", false, 6 );
|
||||||
registerStyle( "upc-e+2", "gnu-barcode", tr("UPC-E +2"),
|
registerStyle( "upc-e+2", "gnu-barcode", tr("UPC-E +2"),
|
||||||
true, true, true, false, "000000 00", false, 8 );
|
true, true, true, false, "000000 00", false, 8 );
|
||||||
registerStyle( "upc-e+5", "gnu-barcode", tr("UPC-E +5"),
|
registerStyle( "upc-e+5", "gnu-barcode", tr("UPC-E +5"),
|
||||||
true, true, true, false, "000000 00000", false, 11 );
|
true, true, true, false, "000000 00000", false, 11 );
|
||||||
registerStyle( "isbn", "gnu-barcode", tr("ISBN"),
|
registerStyle( "isbn", "gnu-barcode", tr("ISBN"),
|
||||||
true, true, true, true, "0-00000-000-0", false, 10 );
|
true, true, true, true, "0-00000-000-0", false, 10 );
|
||||||
registerStyle( "isbn+5", "gnu-barcode", tr("ISBN +5"),
|
registerStyle( "isbn+5", "gnu-barcode", tr("ISBN +5"),
|
||||||
true, true, true, true, "0-00000-000-0 00000", false, 15 );
|
true, true, true, true, "0-00000-000-0 00000", false, 15 );
|
||||||
registerStyle( "code39", "gnu-barcode", tr("Code 39"),
|
registerStyle( "code39", "gnu-barcode", tr("Code 39"),
|
||||||
true, true, true, true, "0000000000", true, 10 );
|
true, true, true, true, "0000000000", true, 10 );
|
||||||
registerStyle( "code128", "gnu-barcode", tr("Code 128"),
|
registerStyle( "code128", "gnu-barcode", tr("Code 128"),
|
||||||
true, true, true, true, "0000000000", true, 10 );
|
true, true, true, true, "0000000000", true, 10 );
|
||||||
registerStyle( "code128c", "gnu-barcode", tr("Code 128C"),
|
registerStyle( "code128c", "gnu-barcode", tr("Code 128C"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
registerStyle( "code128b", "gnu-barcode", tr("Code 128B"),
|
registerStyle( "code128b", "gnu-barcode", tr("Code 128B"),
|
||||||
true, true, true, true, "0000000000", true, 10 );
|
true, true, true, true, "0000000000", true, 10 );
|
||||||
registerStyle( "i25", "gnu-barcode", tr("Interleaved 2 of 5"),
|
registerStyle( "i25", "gnu-barcode", tr("Interleaved 2 of 5"),
|
||||||
true, true, true, true, "0000000000", true, 10 );
|
true, true, true, true, "0000000000", true, 10 );
|
||||||
registerStyle( "cbr", "gnu-barcode", tr("Codabar"),
|
registerStyle( "cbr", "gnu-barcode", tr("Codabar"),
|
||||||
true, true, true, true, "0000000000", true, 10 );
|
true, true, true, true, "0000000000", true, 10 );
|
||||||
registerStyle( "msi", "gnu-barcode", tr("MSI"),
|
registerStyle( "msi", "gnu-barcode", tr("MSI"),
|
||||||
true, true, true, true, "0000000000", true, 10 );
|
true, true, true, true, "0000000000", true, 10 );
|
||||||
registerStyle( "pls", "gnu-barcode", tr("Plessey"),
|
registerStyle( "pls", "gnu-barcode", tr("Plessey"),
|
||||||
true, true, true, true, "0000000000", true, 10 );
|
true, true, true, true, "0000000000", true, 10 );
|
||||||
registerStyle( "code93", "gnu-barcode", tr("Code 93"),
|
registerStyle( "code93", "gnu-barcode", tr("Code 93"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
#endif // HAVE_GNU_BARCODE
|
#endif // HAVE_GNU_BARCODE
|
||||||
|
|
||||||
#if HAVE_QRENCODE
|
#if HAVE_QRENCODE
|
||||||
//
|
//
|
||||||
// Libqrencode backend
|
// Libqrencode backend
|
||||||
//
|
//
|
||||||
registerBackend( "qrencode", "QREncode" );
|
registerBackend( "qrencode", "QREncode" );
|
||||||
|
|
||||||
glbarcode::Factory::registerType( "qrencode::qrcode", QrEncode::QrCode::create );
|
glbarcode::Factory::registerType( "qrencode::qrcode", QrEncode::QrCode::create );
|
||||||
|
|
||||||
registerStyle( "qrcode", "qrencode", tr("IEC18004 (QRCode)"),
|
registerStyle( "qrcode", "qrencode", tr("IEC18004 (QRCode)"),
|
||||||
false, false, true, false, "1234567890AB", false, 12 );
|
false, false, true, false, "1234567890AB", false, 12 );
|
||||||
#endif // HAVE_QRENCODE
|
#endif // HAVE_QRENCODE
|
||||||
|
|
||||||
#if HAVE_ZINT
|
#if HAVE_ZINT
|
||||||
//
|
//
|
||||||
// Zint barcode backend
|
// Zint barcode backend
|
||||||
//
|
//
|
||||||
registerBackend( "zint", "Zint" );
|
registerBackend( "zint", "Zint" );
|
||||||
|
|
||||||
glbarcode::Factory::registerType( "zint::ausp", Zint::AusP::create );
|
glbarcode::Factory::registerType( "zint::ausp", Zint::AusP::create );
|
||||||
glbarcode::Factory::registerType( "zint::ausrp", Zint::AusRP::create );
|
glbarcode::Factory::registerType( "zint::ausrp", Zint::AusRP::create );
|
||||||
glbarcode::Factory::registerType( "zint::ausrt", Zint::AusRT::create );
|
glbarcode::Factory::registerType( "zint::ausrt", Zint::AusRT::create );
|
||||||
glbarcode::Factory::registerType( "zint::ausrd", Zint::AusRD::create );
|
glbarcode::Factory::registerType( "zint::ausrd", Zint::AusRD::create );
|
||||||
glbarcode::Factory::registerType( "zint::aztec", Zint::Aztec::create );
|
glbarcode::Factory::registerType( "zint::aztec", Zint::Aztec::create );
|
||||||
glbarcode::Factory::registerType( "zint::azrun", Zint::Azrun::create );
|
glbarcode::Factory::registerType( "zint::azrun", Zint::Azrun::create );
|
||||||
glbarcode::Factory::registerType( "zint::cbr", Zint::Cbr::create );
|
glbarcode::Factory::registerType( "zint::cbr", Zint::Cbr::create );
|
||||||
glbarcode::Factory::registerType( "zint::code1", Zint::Code1::create );
|
glbarcode::Factory::registerType( "zint::code1", Zint::Code1::create );
|
||||||
glbarcode::Factory::registerType( "zint::code11", Zint::Code11::create );
|
glbarcode::Factory::registerType( "zint::code11", Zint::Code11::create );
|
||||||
glbarcode::Factory::registerType( "zint::c16k", Zint::C16k::create );
|
glbarcode::Factory::registerType( "zint::c16k", Zint::C16k::create );
|
||||||
glbarcode::Factory::registerType( "zint::c25m", Zint::C25m::create );
|
glbarcode::Factory::registerType( "zint::c25m", Zint::C25m::create );
|
||||||
glbarcode::Factory::registerType( "zint::c25i", Zint::C25i::create );
|
glbarcode::Factory::registerType( "zint::c25i", Zint::C25i::create );
|
||||||
glbarcode::Factory::registerType( "zint::c25dl", Zint::C25dl::create );
|
glbarcode::Factory::registerType( "zint::c25dl", Zint::C25dl::create );
|
||||||
glbarcode::Factory::registerType( "zint::code32", Zint::Code32::create );
|
glbarcode::Factory::registerType( "zint::code32", Zint::Code32::create );
|
||||||
glbarcode::Factory::registerType( "zint::code39", Zint::Code39::create );
|
glbarcode::Factory::registerType( "zint::code39", Zint::Code39::create );
|
||||||
glbarcode::Factory::registerType( "zint::code39e", Zint::Code39e::create );
|
glbarcode::Factory::registerType( "zint::code39e", Zint::Code39e::create );
|
||||||
glbarcode::Factory::registerType( "zint::code49", Zint::Code49::create );
|
glbarcode::Factory::registerType( "zint::code49", Zint::Code49::create );
|
||||||
glbarcode::Factory::registerType( "zint::code93", Zint::Code93::create );
|
glbarcode::Factory::registerType( "zint::code93", Zint::Code93::create );
|
||||||
glbarcode::Factory::registerType( "zint::code128", Zint::Code128::create );
|
glbarcode::Factory::registerType( "zint::code128", Zint::Code128::create );
|
||||||
glbarcode::Factory::registerType( "zint::code128b", Zint::Code128b::create );
|
glbarcode::Factory::registerType( "zint::code128b", Zint::Code128b::create );
|
||||||
glbarcode::Factory::registerType( "zint::daft", Zint::Daft::create );
|
glbarcode::Factory::registerType( "zint::daft", Zint::Daft::create );
|
||||||
glbarcode::Factory::registerType( "zint::dmtx", Zint::Dmtx::create );
|
glbarcode::Factory::registerType( "zint::dmtx", Zint::Dmtx::create );
|
||||||
glbarcode::Factory::registerType( "zint::dpl", Zint::Dpl::create );
|
glbarcode::Factory::registerType( "zint::dpl", Zint::Dpl::create );
|
||||||
glbarcode::Factory::registerType( "zint::dpi", Zint::Dpi::create );
|
glbarcode::Factory::registerType( "zint::dpi", Zint::Dpi::create );
|
||||||
glbarcode::Factory::registerType( "zint::kix", Zint::Kix::create );
|
glbarcode::Factory::registerType( "zint::kix", Zint::Kix::create );
|
||||||
glbarcode::Factory::registerType( "zint::ean", Zint::Ean::create );
|
glbarcode::Factory::registerType( "zint::ean", Zint::Ean::create );
|
||||||
glbarcode::Factory::registerType( "zint::gmtx", Zint::Gmtx::create );
|
glbarcode::Factory::registerType( "zint::gmtx", Zint::Gmtx::create );
|
||||||
glbarcode::Factory::registerType( "zint::gs1128", Zint::Gs1128::create );
|
glbarcode::Factory::registerType( "zint::gs1128", Zint::Gs1128::create );
|
||||||
glbarcode::Factory::registerType( "zint::rss14", Zint::Rss14::create );
|
glbarcode::Factory::registerType( "zint::rss14", Zint::Rss14::create );
|
||||||
glbarcode::Factory::registerType( "zint::rssltd", Zint::Rssltd::create );
|
glbarcode::Factory::registerType( "zint::rssltd", Zint::Rssltd::create );
|
||||||
glbarcode::Factory::registerType( "zint::rssexp", Zint::Rssexp::create );
|
glbarcode::Factory::registerType( "zint::rssexp", Zint::Rssexp::create );
|
||||||
glbarcode::Factory::registerType( "zint::rsss", Zint::Rsss::create );
|
glbarcode::Factory::registerType( "zint::rsss", Zint::Rsss::create );
|
||||||
glbarcode::Factory::registerType( "zint::rssso", Zint::Rssso::create );
|
glbarcode::Factory::registerType( "zint::rssso", Zint::Rssso::create );
|
||||||
glbarcode::Factory::registerType( "zint::rssse", Zint::Rssse::create );
|
glbarcode::Factory::registerType( "zint::rssse", Zint::Rssse::create );
|
||||||
glbarcode::Factory::registerType( "zint::hibc128", Zint::Hibc128::create );
|
glbarcode::Factory::registerType( "zint::hibc128", Zint::Hibc128::create );
|
||||||
glbarcode::Factory::registerType( "zint::hibc39", Zint::Hibc39::create );
|
glbarcode::Factory::registerType( "zint::hibc39", Zint::Hibc39::create );
|
||||||
glbarcode::Factory::registerType( "zint::hibcdm", Zint::Hibcdm::create );
|
glbarcode::Factory::registerType( "zint::hibcdm", Zint::Hibcdm::create );
|
||||||
glbarcode::Factory::registerType( "zint::hibcqr", Zint::Hibcqr::create );
|
glbarcode::Factory::registerType( "zint::hibcqr", Zint::Hibcqr::create );
|
||||||
glbarcode::Factory::registerType( "zint::hibcpdf", Zint::Hibcpdf::create );
|
glbarcode::Factory::registerType( "zint::hibcpdf", Zint::Hibcpdf::create );
|
||||||
glbarcode::Factory::registerType( "zint::hibcmpdf", Zint::Hibcmpdf::create );
|
glbarcode::Factory::registerType( "zint::hibcmpdf", Zint::Hibcmpdf::create );
|
||||||
glbarcode::Factory::registerType( "zint::hibcaz", Zint::Hibcaz::create );
|
glbarcode::Factory::registerType( "zint::hibcaz", Zint::Hibcaz::create );
|
||||||
glbarcode::Factory::registerType( "zint::i25", Zint::I25::create );
|
glbarcode::Factory::registerType( "zint::i25", Zint::I25::create );
|
||||||
glbarcode::Factory::registerType( "zint::isbn", Zint::Isbn::create );
|
glbarcode::Factory::registerType( "zint::isbn", Zint::Isbn::create );
|
||||||
glbarcode::Factory::registerType( "zint::itf14", Zint::Itf14::create );
|
glbarcode::Factory::registerType( "zint::itf14", Zint::Itf14::create );
|
||||||
glbarcode::Factory::registerType( "zint::japan", Zint::Japan::create );
|
glbarcode::Factory::registerType( "zint::japan", Zint::Japan::create );
|
||||||
glbarcode::Factory::registerType( "zint::korea", Zint::Korea::create );
|
glbarcode::Factory::registerType( "zint::korea", Zint::Korea::create );
|
||||||
glbarcode::Factory::registerType( "zint::logm", Zint::Logm::create );
|
glbarcode::Factory::registerType( "zint::logm", Zint::Logm::create );
|
||||||
glbarcode::Factory::registerType( "zint::maxi", Zint::Maxi::create );
|
glbarcode::Factory::registerType( "zint::maxi", Zint::Maxi::create );
|
||||||
glbarcode::Factory::registerType( "zint::mpdf", Zint::Mpdf::create );
|
glbarcode::Factory::registerType( "zint::mpdf", Zint::Mpdf::create );
|
||||||
glbarcode::Factory::registerType( "zint::mqr", Zint::Mqr::create );
|
glbarcode::Factory::registerType( "zint::mqr", Zint::Mqr::create );
|
||||||
glbarcode::Factory::registerType( "zint::msi", Zint::Msi::create );
|
glbarcode::Factory::registerType( "zint::msi", Zint::Msi::create );
|
||||||
glbarcode::Factory::registerType( "zint::nve", Zint::Nve::create );
|
glbarcode::Factory::registerType( "zint::nve", Zint::Nve::create );
|
||||||
glbarcode::Factory::registerType( "zint::pdf", Zint::Pdf::create );
|
glbarcode::Factory::registerType( "zint::pdf", Zint::Pdf::create );
|
||||||
glbarcode::Factory::registerType( "zint::pdft", Zint::Pdft::create );
|
glbarcode::Factory::registerType( "zint::pdft", Zint::Pdft::create );
|
||||||
glbarcode::Factory::registerType( "zint::plan", Zint::Plan::create );
|
glbarcode::Factory::registerType( "zint::plan", Zint::Plan::create );
|
||||||
glbarcode::Factory::registerType( "zint::postnet", Zint::Postnet::create );
|
glbarcode::Factory::registerType( "zint::postnet", Zint::Postnet::create );
|
||||||
glbarcode::Factory::registerType( "zint::pharma", Zint::Pharma::create );
|
glbarcode::Factory::registerType( "zint::pharma", Zint::Pharma::create );
|
||||||
glbarcode::Factory::registerType( "zint::pharma2", Zint::Pharma2::create );
|
glbarcode::Factory::registerType( "zint::pharma2", Zint::Pharma2::create );
|
||||||
glbarcode::Factory::registerType( "zint::pzn", Zint::Pzn::create );
|
glbarcode::Factory::registerType( "zint::pzn", Zint::Pzn::create );
|
||||||
glbarcode::Factory::registerType( "zint::qr", Zint::Qr::create );
|
glbarcode::Factory::registerType( "zint::qr", Zint::Qr::create );
|
||||||
glbarcode::Factory::registerType( "zint::rm4", Zint::Rm4::create );
|
glbarcode::Factory::registerType( "zint::rm4", Zint::Rm4::create );
|
||||||
glbarcode::Factory::registerType( "zint::tele", Zint::Tele::create );
|
glbarcode::Factory::registerType( "zint::tele", Zint::Tele::create );
|
||||||
glbarcode::Factory::registerType( "zint::telex", Zint::Telex::create );
|
glbarcode::Factory::registerType( "zint::telex", Zint::Telex::create );
|
||||||
glbarcode::Factory::registerType( "zint::upc-a", Zint::UpcA::create );
|
glbarcode::Factory::registerType( "zint::upc-a", Zint::UpcA::create );
|
||||||
glbarcode::Factory::registerType( "zint::upc-e", Zint::UpcE::create );
|
glbarcode::Factory::registerType( "zint::upc-e", Zint::UpcE::create );
|
||||||
glbarcode::Factory::registerType( "zint::usps", Zint::Usps::create );
|
glbarcode::Factory::registerType( "zint::usps", Zint::Usps::create );
|
||||||
glbarcode::Factory::registerType( "zint::pls", Zint::Pls::create );
|
glbarcode::Factory::registerType( "zint::pls", Zint::Pls::create );
|
||||||
|
|
||||||
registerStyle( "ausp", "zint", tr("Austraila Post Standard"),
|
registerStyle( "ausp", "zint", tr("Austraila Post Standard"),
|
||||||
false, false, true, false, "12345678901234567890123", true, 23 );
|
false, false, true, false, "12345678901234567890123", true, 23 );
|
||||||
|
|
||||||
registerStyle( "ausrp", "zint", tr("Australia Post Reply Paid"),
|
registerStyle( "ausrp", "zint", tr("Australia Post Reply Paid"),
|
||||||
false, false, true, false, "12345678", true, 8 );
|
false, false, true, false, "12345678", true, 8 );
|
||||||
|
|
||||||
registerStyle( "ausrt", "zint", tr("Australia Post Route Code"),
|
registerStyle( "ausrt", "zint", tr("Australia Post Route Code"),
|
||||||
false, false, true, false, "12345678", true, 8 );
|
false, false, true, false, "12345678", true, 8 );
|
||||||
|
|
||||||
registerStyle( "ausrd", "zint", tr("Australia Post Redirect"),
|
registerStyle( "ausrd", "zint", tr("Australia Post Redirect"),
|
||||||
false, false, true, false, "12345678", true, 8 );
|
false, false, true, false, "12345678", true, 8 );
|
||||||
|
|
||||||
registerStyle( "aztec", "zint", tr("Aztec Code"),
|
registerStyle( "aztec", "zint", tr("Aztec Code"),
|
||||||
false, false, true, false, "1234567890", true, 10 );
|
false, false, true, false, "1234567890", true, 10 );
|
||||||
|
|
||||||
registerStyle( "azrun", "zint", tr("Aztec Rune"),
|
registerStyle( "azrun", "zint", tr("Aztec Rune"),
|
||||||
false, false, true, false, "255", true, 3 );
|
false, false, true, false, "255", true, 3 );
|
||||||
|
|
||||||
registerStyle( "cbr", "zint", tr("Codabar"),
|
registerStyle( "cbr", "zint", tr("Codabar"),
|
||||||
true, true, true, false, "ABCDABCDAB", true, 10 );
|
true, true, true, false, "ABCDABCDAB", true, 10 );
|
||||||
|
|
||||||
registerStyle( "code1", "zint", tr("Code One"),
|
registerStyle( "code1", "zint", tr("Code One"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "code11", "zint", tr("Code 11"),
|
registerStyle( "code11", "zint", tr("Code 11"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "c16k", "zint", tr("Code 16K"),
|
registerStyle( "c16k", "zint", tr("Code 16K"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "c25m", "zint", tr("Code 2 of 5 Matrix"),
|
registerStyle( "c25m", "zint", tr("Code 2 of 5 Matrix"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "c25i", "zint", tr("Code 2 of 5 IATA"),
|
registerStyle( "c25i", "zint", tr("Code 2 of 5 IATA"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "c25dl", "zint", tr("Code 2 of 5 Data Logic"),
|
registerStyle( "c25dl", "zint", tr("Code 2 of 5 Data Logic"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "code32", "zint", tr("Code 32 (Italian Pharmacode)"),
|
registerStyle( "code32", "zint", tr("Code 32 (Italian Pharmacode)"),
|
||||||
true, true, true, false, "12345678", true, 8 );
|
true, true, true, false, "12345678", true, 8 );
|
||||||
|
|
||||||
registerStyle( "code39", "zint", tr("Code 39"),
|
registerStyle( "code39", "zint", tr("Code 39"),
|
||||||
true, true, false, false, "0000000000", true, 10 );
|
true, true, false, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "code39e", "zint", tr("Code 39 Extended"),
|
registerStyle( "code39e", "zint", tr("Code 39 Extended"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "code49", "zint", tr("Code 49"),
|
registerStyle( "code49", "zint", tr("Code 49"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "code93", "zint", tr("Code 93"),
|
registerStyle( "code93", "zint", tr("Code 93"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "code128", "zint", tr("Code 128"),
|
registerStyle( "code128", "zint", tr("Code 128"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "code128b", "zint", tr("Code 128 (Mode C supression)"),
|
registerStyle( "code128b", "zint", tr("Code 128 (Mode C supression)"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "daft", "zint", tr("DAFT Code"),
|
registerStyle( "daft", "zint", tr("DAFT Code"),
|
||||||
false, false, false, false, "DAFTDAFTDAFTDAFT", true, 16 );
|
false, false, false, false, "DAFTDAFTDAFTDAFT", true, 16 );
|
||||||
|
|
||||||
registerStyle( "dmtx", "zint", tr("Data Matrix"),
|
registerStyle( "dmtx", "zint", tr("Data Matrix"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "dpl", "zint", tr("Deutsche Post Leitcode"),
|
registerStyle( "dpl", "zint", tr("Deutsche Post Leitcode"),
|
||||||
true, true, true, false, "1234567890123", true, 13 );
|
true, true, true, false, "1234567890123", true, 13 );
|
||||||
|
|
||||||
registerStyle( "dpi", "zint", tr("Deutsche Post Identcode"),
|
registerStyle( "dpi", "zint", tr("Deutsche Post Identcode"),
|
||||||
true, true, true, false, "12345678901", true, 11 );
|
true, true, true, false, "12345678901", true, 11 );
|
||||||
|
|
||||||
registerStyle( "kix", "zint", tr("Dutch Post KIX Code"),
|
registerStyle( "kix", "zint", tr("Dutch Post KIX Code"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "ean", "zint", tr("EAN"),
|
registerStyle( "ean", "zint", tr("EAN"),
|
||||||
true, true, true, false, "1234567890123", false, 13 );
|
true, true, true, false, "1234567890123", false, 13 );
|
||||||
|
|
||||||
registerStyle( "gmtx", "zint", tr("Grid Matrix"),
|
registerStyle( "gmtx", "zint", tr("Grid Matrix"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "gs1-128", "zint", tr("GS1-128"),
|
registerStyle( "gs1-128", "zint", tr("GS1-128"),
|
||||||
true, true, true, false, "[01]12345678901234", false, 18 );
|
true, true, true, false, "[01]12345678901234", false, 18 );
|
||||||
|
|
||||||
registerStyle( "rss14", "zint", tr("GS1 DataBar-14"),
|
registerStyle( "rss14", "zint", tr("GS1 DataBar-14"),
|
||||||
true, true, true, false, "1234567890123", true, 13 );
|
true, true, true, false, "1234567890123", true, 13 );
|
||||||
|
|
||||||
registerStyle( "rssltd", "zint", "GS1 DataBar-14 Limited",
|
registerStyle( "rssltd", "zint", "GS1 DataBar-14 Limited",
|
||||||
true, true, true, false, "1234567890123", true, 13 );
|
true, true, true, false, "1234567890123", true, 13 );
|
||||||
|
|
||||||
registerStyle( "rssexp", "zint", "GS1 DataBar Extended",
|
registerStyle( "rssexp", "zint", "GS1 DataBar Extended",
|
||||||
true, true, true, false, "[01]12345678901234", false, 18 );
|
true, true, true, false, "[01]12345678901234", false, 18 );
|
||||||
|
|
||||||
registerStyle( "rsss", "zint", tr("GS1 DataBar-14 Stacked"),
|
registerStyle( "rsss", "zint", tr("GS1 DataBar-14 Stacked"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "rssso", "zint", tr("GS1 DataBar-14 Stacked Omni."),
|
registerStyle( "rssso", "zint", tr("GS1 DataBar-14 Stacked Omni."),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "rssse", "zint", tr("GS1 DataBar Extended Stacked"),
|
registerStyle( "rssse", "zint", tr("GS1 DataBar Extended Stacked"),
|
||||||
false, false, true, false, "[01]12345678901234", false, 18 );
|
false, false, true, false, "[01]12345678901234", false, 18 );
|
||||||
|
|
||||||
registerStyle( "hibc128", "zint", tr("HIBC Code 128"),
|
registerStyle( "hibc128", "zint", tr("HIBC Code 128"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "hibc39", "zint", tr("HIBC Code 39"),
|
registerStyle( "hibc39", "zint", tr("HIBC Code 39"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "hibcdm", "zint", tr("HIBC Data Matrix"),
|
registerStyle( "hibcdm", "zint", tr("HIBC Data Matrix"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "hibcqr", "zint", tr("HIBC QR Code"),
|
registerStyle( "hibcqr", "zint", tr("HIBC QR Code"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "hibcpdf", "zint", tr("HIBC PDF417"),
|
registerStyle( "hibcpdf", "zint", tr("HIBC PDF417"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "hibcmpdf", "zint", tr("HIBC Micro PDF417"),
|
registerStyle( "hibcmpdf", "zint", tr("HIBC Micro PDF417"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "hibcaz", "zint", tr("HIBC Aztec Code"),
|
registerStyle( "hibcaz", "zint", tr("HIBC Aztec Code"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "i25", "zint", tr("Interleaved 2 of 5"),
|
registerStyle( "i25", "zint", tr("Interleaved 2 of 5"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "isbn", "zint", tr("ISBN"),
|
registerStyle( "isbn", "zint", tr("ISBN"),
|
||||||
true, true, true, false, "123456789", false, 9 );
|
true, true, true, false, "123456789", false, 9 );
|
||||||
|
|
||||||
registerStyle( "itf14", "zint", tr("ITF-14"),
|
registerStyle( "itf14", "zint", tr("ITF-14"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "japan", "zint", tr("Japanese Postal"),
|
registerStyle( "japan", "zint", tr("Japanese Postal"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "korea", "zint", tr("Korean Postal"),
|
registerStyle( "korea", "zint", tr("Korean Postal"),
|
||||||
true, true, true, false, "123456", false, 6 );
|
true, true, true, false, "123456", false, 6 );
|
||||||
|
|
||||||
registerStyle( "logm", "zint", tr("LOGMARS"),
|
registerStyle( "logm", "zint", tr("LOGMARS"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "maxi", "zint", tr("Maxicode"),
|
registerStyle( "maxi", "zint", tr("Maxicode"),
|
||||||
false, false, false, false, "0000000000", true, 10 );
|
false, false, false, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "mpdf", "zint", tr("Micro PDF417"),
|
registerStyle( "mpdf", "zint", tr("Micro PDF417"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "mqr", "zint", tr("Micro QR Code"),
|
registerStyle( "mqr", "zint", tr("Micro QR Code"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "msi", "zint", tr("MSI Plessey"),
|
registerStyle( "msi", "zint", tr("MSI Plessey"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "nve", "zint", tr("NVE-18"),
|
registerStyle( "nve", "zint", tr("NVE-18"),
|
||||||
true, true, true, false, "12345678901234567", false, 17 );
|
true, true, true, false, "12345678901234567", false, 17 );
|
||||||
|
|
||||||
registerStyle( "pdf", "zint", tr("PDF417"),
|
registerStyle( "pdf", "zint", tr("PDF417"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "pdft", "zint", tr("PDF417 Truncated"),
|
registerStyle( "pdft", "zint", tr("PDF417 Truncated"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "plan", "zint", tr("PLANET"),
|
registerStyle( "plan", "zint", tr("PLANET"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "postnet", "zint", tr("PostNet"),
|
registerStyle( "postnet", "zint", tr("PostNet"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "pharma", "zint", tr("Pharmacode"),
|
registerStyle( "pharma", "zint", tr("Pharmacode"),
|
||||||
false, false, true, false, "123456", false, 6 );
|
false, false, true, false, "123456", false, 6 );
|
||||||
|
|
||||||
registerStyle( "pharma2", "zint", tr("Pharmacode 2-track"),
|
registerStyle( "pharma2", "zint", tr("Pharmacode 2-track"),
|
||||||
false, false, true, false, "12345678", false, 8 );
|
false, false, true, false, "12345678", false, 8 );
|
||||||
|
|
||||||
registerStyle( "pzn", "zint", tr("Pharmazentral Nummer (PZN)"),
|
registerStyle( "pzn", "zint", tr("Pharmazentral Nummer (PZN)"),
|
||||||
true, true, true, false, "123456", false, 6 );
|
true, true, true, false, "123456", false, 6 );
|
||||||
|
|
||||||
registerStyle( "qr", "zint", tr("QR Code"),
|
registerStyle( "qr", "zint", tr("QR Code"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "rm4", "zint", tr("Royal Mail 4-State"),
|
registerStyle( "rm4", "zint", tr("Royal Mail 4-State"),
|
||||||
false, false, true, false, "0000000000", true, 10 );
|
false, false, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "tele", "zint", tr("Telepen"),
|
registerStyle( "tele", "zint", tr("Telepen"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "telex", "zint", tr("Telepen Numeric"),
|
registerStyle( "telex", "zint", tr("Telepen Numeric"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
|
|
||||||
registerStyle( "upc-a", "zint", tr("UPC-A"),
|
registerStyle( "upc-a", "zint", tr("UPC-A"),
|
||||||
true, true, true, false, "12345678901", false, 11 );
|
true, true, true, false, "12345678901", false, 11 );
|
||||||
|
|
||||||
registerStyle( "upc-e", "zint", tr("UPC-E"),
|
registerStyle( "upc-e", "zint", tr("UPC-E"),
|
||||||
true, true, true, false, "1234567", false, 7 );
|
true, true, true, false, "1234567", false, 7 );
|
||||||
|
|
||||||
registerStyle( "usps", "zint", tr("USPS One Code"),
|
registerStyle( "usps", "zint", tr("USPS One Code"),
|
||||||
false, false, true, false, "12345678901234567890", true, 20 );
|
false, false, true, false, "12345678901234567890", true, 20 );
|
||||||
|
|
||||||
registerStyle( "pls", "zint", tr("UK Plessey"),
|
registerStyle( "pls", "zint", tr("UK Plessey"),
|
||||||
true, true, true, false, "0000000000", true, 10 );
|
true, true, true, false, "0000000000", true, 10 );
|
||||||
#endif // HAVE_ZINT
|
#endif // HAVE_ZINT
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Backends::init()
|
|
||||||
{
|
|
||||||
static Backends* singletonInstance = nullptr;
|
|
||||||
|
|
||||||
if ( singletonInstance == nullptr )
|
|
||||||
{
|
|
||||||
singletonInstance = new Backends();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QStringList& Backends::backendList()
|
void Backends::init()
|
||||||
{
|
|
||||||
return mBackendIdList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString Backends::backendName( const QString& backendId )
|
|
||||||
{
|
|
||||||
return mBackendNameMap[ backendId ];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QList<Style>& Backends::styleList()
|
|
||||||
{
|
|
||||||
return mStyleList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Style& Backends::defaultStyle()
|
|
||||||
{
|
|
||||||
return mStyleList[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Style& Backends::style( const QString& backendId, const QString& StyleId )
|
|
||||||
{
|
|
||||||
foreach ( const Style& bcStyle, mStyleList )
|
|
||||||
{
|
{
|
||||||
if ( (bcStyle.backendId() == backendId) && (bcStyle.id() == StyleId) )
|
static Backends* singletonInstance = nullptr;
|
||||||
|
|
||||||
|
if ( singletonInstance == nullptr )
|
||||||
{
|
{
|
||||||
return bcStyle;
|
singletonInstance = new Backends();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultStyle();
|
|
||||||
}
|
const QStringList& Backends::backendList()
|
||||||
|
{
|
||||||
|
return mBackendIdList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Backends::backendName( const QString& backendId )
|
||||||
|
{
|
||||||
|
return mBackendNameMap[ backendId ];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QList<Style>& Backends::styleList()
|
||||||
|
{
|
||||||
|
return mStyleList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Backends::registerBackend( const QString& backendId, const QString& backendName )
|
const Style& Backends::defaultStyle()
|
||||||
{
|
{
|
||||||
mBackendIdList.append( backendId );
|
return mStyleList[0];
|
||||||
mBackendNameMap[ backendId ] = backendName;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Backends::registerStyle( const QString& id,
|
const Style& Backends::style( const QString& backendId, const QString& StyleId )
|
||||||
const QString& backendId,
|
{
|
||||||
const QString& name,
|
foreach ( const Style& bcStyle, mStyleList )
|
||||||
bool canText,
|
{
|
||||||
bool textOptional,
|
if ( (bcStyle.backendId() == backendId) && (bcStyle.id() == StyleId) )
|
||||||
bool canChecksum,
|
{
|
||||||
bool checksumOptional,
|
return bcStyle;
|
||||||
const QString& defaultDigits,
|
}
|
||||||
bool canFreeForm,
|
}
|
||||||
int preferedN )
|
|
||||||
{
|
|
||||||
Style style( id, backendId, name,
|
|
||||||
canText, textOptional,
|
|
||||||
canChecksum, checksumOptional,
|
|
||||||
defaultDigits,
|
|
||||||
canFreeForm, preferedN );
|
|
||||||
|
|
||||||
mStyleList.append( style );
|
return defaultStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::barcode
|
|
||||||
|
void Backends::registerBackend( const QString& backendId, const QString& backendName )
|
||||||
|
{
|
||||||
|
mBackendIdList.append( backendId );
|
||||||
|
mBackendNameMap[ backendId ] = backendName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Backends::registerStyle( const QString& id,
|
||||||
|
const QString& backendId,
|
||||||
|
const QString& name,
|
||||||
|
bool canText,
|
||||||
|
bool textOptional,
|
||||||
|
bool canChecksum,
|
||||||
|
bool checksumOptional,
|
||||||
|
const QString& defaultDigits,
|
||||||
|
bool canFreeForm,
|
||||||
|
int preferedN )
|
||||||
|
{
|
||||||
|
Style style( id, backendId, name,
|
||||||
|
canText, textOptional,
|
||||||
|
canChecksum, checksumOptional,
|
||||||
|
defaultDigits,
|
||||||
|
canFreeForm, preferedN );
|
||||||
|
|
||||||
|
mStyleList.append( style );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace barcode
|
||||||
|
} //namespace glabels
|
||||||
|
|||||||
+48
-45
@@ -30,65 +30,68 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::barcode
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace barcode
|
||||||
///
|
|
||||||
/// Backends Database
|
|
||||||
///
|
|
||||||
class Backends : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
///
|
||||||
|
/// Backends Database
|
||||||
|
///
|
||||||
|
class Backends : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
Backends();
|
Backends();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void init();
|
static void init();
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static const QStringList& backendList();
|
static const QStringList& backendList();
|
||||||
static QString backendName( const QString& backendId );
|
static QString backendName( const QString& backendId );
|
||||||
static const QList<Style>& styleList();
|
static const QList<Style>& styleList();
|
||||||
static const Style& defaultStyle();
|
static const Style& defaultStyle();
|
||||||
static const Style& style( const QString& backendId, const QString& StyleId );
|
static const Style& style( const QString& backendId, const QString& StyleId );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Methods
|
// Private Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
static void registerBackend( const QString &backendId, const QString &backendName );
|
static void registerBackend( const QString &backendId, const QString &backendName );
|
||||||
|
|
||||||
static void registerStyle( const QString& id,
|
static void registerStyle( 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 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
static QStringList mBackendIdList;
|
static QStringList mBackendIdList;
|
||||||
static QMap<QString,QString> mBackendNameMap;
|
static QMap<QString,QString> mBackendNameMap;
|
||||||
|
|
||||||
static QList<Style> mStyleList;
|
static QList<Style> mStyleList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+691
-688
File diff suppressed because it is too large
Load Diff
+305
-302
@@ -26,392 +26,395 @@
|
|||||||
#include "glbarcode/Barcode1dBase.h"
|
#include "glbarcode/Barcode1dBase.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::barcode
|
namespace glabels
|
||||||
{
|
{
|
||||||
namespace GnuBarcode
|
namespace barcode
|
||||||
{
|
{
|
||||||
|
namespace GnuBarcode
|
||||||
/**
|
|
||||||
* GnuBarcode::Base base class for all GNU Barcodes
|
|
||||||
*
|
|
||||||
* Implements glbarcode::Barcode1dBase.
|
|
||||||
*/
|
|
||||||
class Base : public glbarcode::Barcode1dBase
|
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
int flags;
|
/**
|
||||||
|
* GnuBarcode::Base base class for all GNU Barcodes
|
||||||
|
*
|
||||||
|
* Implements glbarcode::Barcode1dBase.
|
||||||
|
*/
|
||||||
|
class Base : public glbarcode::Barcode1dBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
int flags;
|
||||||
|
|
||||||
bool isAscii( const std::string& data ) const;
|
bool isAscii( const std::string& data ) const;
|
||||||
|
|
||||||
bool isNumericLengthValid( const std::string& data,
|
bool isNumericLengthValid( const std::string& data,
|
||||||
unsigned int nMin,
|
unsigned int nMin,
|
||||||
unsigned int nMax ) const;
|
unsigned int nMax ) const;
|
||||||
|
|
||||||
bool isNumericLength1Valid( const std::string& data,
|
bool isNumericLength1Valid( const std::string& data,
|
||||||
unsigned int nMin,
|
unsigned int nMin,
|
||||||
unsigned int nMax ) const;
|
unsigned int nMax ) const;
|
||||||
|
|
||||||
bool isNumericLength2Valid( const std::string& data,
|
bool isNumericLength2Valid( const std::string& data,
|
||||||
unsigned int nMin,
|
unsigned int nMin,
|
||||||
unsigned int nMax ) const;
|
unsigned int nMax ) const;
|
||||||
|
|
||||||
void vectorize( const std::string& encodedData,
|
void vectorize( const std::string& encodedData,
|
||||||
const std::string& displayText,
|
const std::string& displayText,
|
||||||
const std::string& cookedData,
|
const std::string& cookedData,
|
||||||
double& w,
|
double& w,
|
||||||
double& h ) override;
|
double& h ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EAN Barcode (Any)
|
* EAN Barcode (Any)
|
||||||
*/
|
*/
|
||||||
class Ean : public Base
|
class Ean : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EAN-8 Barcode
|
* EAN-8 Barcode
|
||||||
*/
|
*/
|
||||||
class Ean8 : public Base
|
class Ean8 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EAN-8+2 Barcode
|
* EAN-8+2 Barcode
|
||||||
*/
|
*/
|
||||||
class Ean8_2 : public Base
|
class Ean8_2 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EAN-8+5 Barcode
|
* EAN-8+5 Barcode
|
||||||
*/
|
*/
|
||||||
class Ean8_5 : public Base
|
class Ean8_5 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EAN-13 Barcode
|
* EAN-13 Barcode
|
||||||
*/
|
*/
|
||||||
class Ean13 : public Base
|
class Ean13 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EAN-13+2 Barcode
|
* EAN-13+2 Barcode
|
||||||
*/
|
*/
|
||||||
class Ean13_2 : public Base
|
class Ean13_2 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EAN-13+5 Barcode
|
* EAN-13+5 Barcode
|
||||||
*/
|
*/
|
||||||
class Ean13_5 : public Base
|
class Ean13_5 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UPC Barcode (Any)
|
* UPC Barcode (Any)
|
||||||
*/
|
*/
|
||||||
class Upc : public Base
|
class Upc : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UPC-A Barcode
|
* UPC-A Barcode
|
||||||
*/
|
*/
|
||||||
class UpcA : public Base
|
class UpcA : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UPC-A+2 Barcode
|
* UPC-A+2 Barcode
|
||||||
*/
|
*/
|
||||||
class UpcA_2 : public Base
|
class UpcA_2 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UPC-A+5 Barcode
|
* UPC-A+5 Barcode
|
||||||
*/
|
*/
|
||||||
class UpcA_5 : public Base
|
class UpcA_5 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UPC-E Barcode
|
* UPC-E Barcode
|
||||||
*/
|
*/
|
||||||
class UpcE : public Base
|
class UpcE : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UPC-E+2 Barcode
|
* UPC-E+2 Barcode
|
||||||
*/
|
*/
|
||||||
class UpcE_2 : public Base
|
class UpcE_2 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UPC-E+5 Barcode
|
* UPC-E+5 Barcode
|
||||||
*/
|
*/
|
||||||
class UpcE_5 : public Base
|
class UpcE_5 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ISBN Barcode
|
* ISBN Barcode
|
||||||
*/
|
*/
|
||||||
class Isbn : public Base
|
class Isbn : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ISBN+5 Barcode
|
* ISBN+5 Barcode
|
||||||
*/
|
*/
|
||||||
class Isbn_5 : public Base
|
class Isbn_5 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code39 Barcode
|
* Code39 Barcode
|
||||||
*/
|
*/
|
||||||
class Code39 : public Base
|
class Code39 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code128 Barcode
|
* Code128 Barcode
|
||||||
*/
|
*/
|
||||||
class Code128 : public Base
|
class Code128 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code128C Barcode
|
* Code128C Barcode
|
||||||
*/
|
*/
|
||||||
class Code128C : public Base
|
class Code128C : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code128B Barcode
|
* Code128B Barcode
|
||||||
*/
|
*/
|
||||||
class Code128B : public Base
|
class Code128B : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I25 Barcode
|
* I25 Barcode
|
||||||
*/
|
*/
|
||||||
class I25 : public Base
|
class I25 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CBR Barcode
|
* CBR Barcode
|
||||||
*/
|
*/
|
||||||
class Cbr : public Base
|
class Cbr : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MSI Barcode
|
* MSI Barcode
|
||||||
*/
|
*/
|
||||||
class Msi : public Base
|
class Msi : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PLS Barcode
|
* PLS Barcode
|
||||||
*/
|
*/
|
||||||
class Pls : public Base
|
class Pls : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code93 Barcode
|
* Code93 Barcode
|
||||||
*/
|
*/
|
||||||
class Code93 : public Base
|
class Code93 : public Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Barcode* create();
|
static Barcode* create();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate( const std::string& rawData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
std::string encode( const std::string& cookedData ) override;
|
std::string encode( const std::string& cookedData ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,65 +25,69 @@
|
|||||||
#include <qrencode.h>
|
#include <qrencode.h>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::barcode
|
namespace glabels
|
||||||
{
|
{
|
||||||
namespace QrEncode
|
namespace barcode
|
||||||
{
|
{
|
||||||
|
namespace QrEncode
|
||||||
/*
|
|
||||||
* Static QrCode barcode creation method
|
|
||||||
*/
|
|
||||||
glbarcode::Barcode* QrCode::create()
|
|
||||||
{
|
{
|
||||||
return new QrCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/*
|
||||||
/*
|
* Static QrCode barcode creation method
|
||||||
* QrCode data validation, implements glbarcode::Barcode2dBase::validate()
|
*/
|
||||||
*/
|
glbarcode::Barcode* QrCode::create()
|
||||||
bool QrCode::validate( const std::string& rawData )
|
|
||||||
{
|
|
||||||
if ( rawData.size() == 0 )
|
|
||||||
{
|
{
|
||||||
return false;
|
return new QrCode();
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* QrCode data encoding, implements glbarcode::Barcode2dBase::encode()
|
|
||||||
*/
|
|
||||||
bool QrCode::encode( const std::string& cookedData, glbarcode::Matrix<bool>& encodedData )
|
|
||||||
{
|
|
||||||
QRcode *qrcode = QRcode_encodeString( cookedData.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1 );
|
|
||||||
if ( qrcode == NULL )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int w = qrcode->width;
|
/*
|
||||||
encodedData.resize( w, w );
|
* QrCode data validation, implements glbarcode::Barcode2dBase::validate()
|
||||||
|
*/
|
||||||
|
bool QrCode::validate( const std::string& rawData )
|
||||||
for ( int iy = 0; iy < w; iy++ )
|
|
||||||
{
|
{
|
||||||
for ( int ix = 0; ix < w; ix++ )
|
if ( rawData.size() == 0 )
|
||||||
{
|
{
|
||||||
encodedData[iy][ix] = qrcode->data[ iy*w + ix ] & 0x01;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QRcode_free( qrcode );
|
/*
|
||||||
QRcode_clearCache();
|
* QrCode data encoding, implements glbarcode::Barcode2dBase::encode()
|
||||||
|
*/
|
||||||
|
bool QrCode::encode( const std::string& cookedData, glbarcode::Matrix<bool>& encodedData )
|
||||||
|
{
|
||||||
|
QRcode *qrcode = QRcode_encodeString( cookedData.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1 );
|
||||||
|
if ( qrcode == NULL )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int w = qrcode->width;
|
||||||
|
encodedData.resize( w, w );
|
||||||
|
|
||||||
|
|
||||||
|
for ( int iy = 0; iy < w; iy++ )
|
||||||
|
{
|
||||||
|
for ( int ix = 0; ix < w; ix++ )
|
||||||
|
{
|
||||||
|
encodedData[iy][ix] = qrcode->data[ iy*w + ix ] & 0x01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QRcode_free( qrcode );
|
||||||
|
QRcode_clearCache();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // HAVE_QRENCODE
|
#endif // HAVE_QRENCODE
|
||||||
|
|||||||
+19
-16
@@ -26,28 +26,31 @@
|
|||||||
#include "glbarcode/Barcode2dBase.h"
|
#include "glbarcode/Barcode2dBase.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::barcode
|
namespace glabels
|
||||||
{
|
{
|
||||||
namespace QrEncode
|
namespace barcode
|
||||||
{
|
{
|
||||||
|
namespace QrEncode
|
||||||
/**
|
|
||||||
* QrEncode::QrCode QR Code Barcode
|
|
||||||
*
|
|
||||||
* Implements glbarcode::Barcode2dBase.
|
|
||||||
*/
|
|
||||||
class QrCode : public glbarcode::Barcode2dBase
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
private:
|
/**
|
||||||
bool validate( const std::string& rawData ) override;
|
* QrEncode::QrCode QR Code Barcode
|
||||||
|
*
|
||||||
|
* Implements glbarcode::Barcode2dBase.
|
||||||
|
*/
|
||||||
|
class QrCode : public glbarcode::Barcode2dBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
bool encode( const std::string& cookedData,
|
private:
|
||||||
glbarcode::Matrix<bool>& encodedData ) override;
|
bool validate( const std::string& rawData ) override;
|
||||||
};
|
|
||||||
|
|
||||||
|
bool encode( const std::string& cookedData,
|
||||||
|
glbarcode::Matrix<bool>& encodedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+163
-160
@@ -21,184 +21,187 @@
|
|||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::barcode
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace barcode
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Default Constructor
|
/// Default Constructor
|
||||||
///
|
///
|
||||||
Style::Style ()
|
Style::Style ()
|
||||||
: mId( "" ),
|
: mId( "" ),
|
||||||
mBackendId( "" ),
|
mBackendId( "" ),
|
||||||
mName( "" ),
|
mName( "" ),
|
||||||
mCanText( false ),
|
mCanText( false ),
|
||||||
mTextOptional( false ),
|
mTextOptional( false ),
|
||||||
mCanChecksum( false ),
|
mCanChecksum( false ),
|
||||||
mChecksumOptional( false ),
|
mChecksumOptional( false ),
|
||||||
mDefaultDigits( "" ),
|
mDefaultDigits( "" ),
|
||||||
mCanFreeform( false ),
|
mCanFreeform( false ),
|
||||||
mPreferedN( 0 )
|
mPreferedN( 0 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
Style::Style ( const QString& id,
|
Style::Style ( 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 ),
|
||||||
mCanText( canText ),
|
mCanText( canText ),
|
||||||
mTextOptional( textOptional ),
|
mTextOptional( textOptional ),
|
||||||
mCanChecksum( canChecksum ),
|
mCanChecksum( canChecksum ),
|
||||||
mChecksumOptional( checksumOptional ),
|
mChecksumOptional( checksumOptional ),
|
||||||
mDefaultDigits( defaultDigits ),
|
mDefaultDigits( defaultDigits ),
|
||||||
mCanFreeform( canFreeform ),
|
mCanFreeform( canFreeform ),
|
||||||
mPreferedN( preferedN )
|
mPreferedN( preferedN )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// ID Property Getter
|
/// ID Property Getter
|
||||||
///
|
///
|
||||||
const QString& Style::id() const
|
const QString& Style::id() const
|
||||||
{
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Full ID Property Getter
|
|
||||||
///
|
|
||||||
QString Style::fullId() const
|
|
||||||
{
|
|
||||||
if ( mBackendId == "" )
|
|
||||||
{
|
{
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Full ID Property Getter
|
||||||
|
///
|
||||||
|
QString Style::fullId() const
|
||||||
{
|
{
|
||||||
return mBackendId + "::" + mId;
|
if ( mBackendId == "" )
|
||||||
|
{
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mBackendId + "::" + mId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Backend ID Property Getter
|
/// Backend ID Property Getter
|
||||||
///
|
///
|
||||||
const QString& Style::backendId() const
|
const QString& Style::backendId() const
|
||||||
{
|
|
||||||
return mBackendId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Name Property Getter
|
|
||||||
///
|
|
||||||
const QString& Style::name() const
|
|
||||||
{
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Text Property Getter
|
|
||||||
///
|
|
||||||
bool Style::canText() const
|
|
||||||
{
|
|
||||||
return mCanText;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Text Optional Property Getter
|
|
||||||
///
|
|
||||||
bool Style::textOptional() const
|
|
||||||
{
|
|
||||||
return mTextOptional;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Checksum Property Getter
|
|
||||||
///
|
|
||||||
bool Style::canChecksum() const
|
|
||||||
{
|
|
||||||
return mCanChecksum;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Checksum Optional Property Getter
|
|
||||||
///
|
|
||||||
bool Style::checksumOptional() const
|
|
||||||
{
|
|
||||||
return mChecksumOptional;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Default Digits Property Getter
|
|
||||||
///
|
|
||||||
const QString& Style::defaultDigits() const
|
|
||||||
{
|
|
||||||
return mDefaultDigits;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Freeform Property Getter
|
|
||||||
///
|
|
||||||
bool Style::canFreeform() const
|
|
||||||
{
|
|
||||||
return mCanFreeform;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Prefered N Property Getter
|
|
||||||
///
|
|
||||||
int Style::preferedN() const
|
|
||||||
{
|
|
||||||
return mPreferedN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Generate Example Digits
|
|
||||||
///
|
|
||||||
QString Style::exampleDigits( int n ) const
|
|
||||||
{
|
|
||||||
if ( mCanFreeform )
|
|
||||||
{
|
{
|
||||||
return QString( qMax( n, 1 ), QChar('0') );
|
return mBackendId;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Name Property Getter
|
||||||
|
///
|
||||||
|
const QString& Style::name() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Text Property Getter
|
||||||
|
///
|
||||||
|
bool Style::canText() const
|
||||||
|
{
|
||||||
|
return mCanText;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Text Optional Property Getter
|
||||||
|
///
|
||||||
|
bool Style::textOptional() const
|
||||||
|
{
|
||||||
|
return mTextOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Checksum Property Getter
|
||||||
|
///
|
||||||
|
bool Style::canChecksum() const
|
||||||
|
{
|
||||||
|
return mCanChecksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Checksum Optional Property Getter
|
||||||
|
///
|
||||||
|
bool Style::checksumOptional() const
|
||||||
|
{
|
||||||
|
return mChecksumOptional;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default Digits Property Getter
|
||||||
|
///
|
||||||
|
const QString& Style::defaultDigits() const
|
||||||
{
|
{
|
||||||
return mDefaultDigits;
|
return mDefaultDigits;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// "Not equals" operator
|
/// Can Freeform Property Getter
|
||||||
///
|
///
|
||||||
bool Style::operator!=( const Style& other ) const
|
bool Style::canFreeform() const
|
||||||
{
|
{
|
||||||
return mId != other.mId;
|
return mCanFreeform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Prefered N Property Getter
|
||||||
|
///
|
||||||
|
int Style::preferedN() const
|
||||||
|
{
|
||||||
|
return mPreferedN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Generate Example Digits
|
||||||
|
///
|
||||||
|
QString Style::exampleDigits( int n ) const
|
||||||
|
{
|
||||||
|
if ( mCanFreeform )
|
||||||
|
{
|
||||||
|
return QString( qMax( n, 1 ), QChar('0') );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mDefaultDigits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// "Not equals" operator
|
||||||
|
///
|
||||||
|
bool Style::operator!=( const Style& other ) const
|
||||||
|
{
|
||||||
|
return mId != other.mId;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace glabels::barcode
|
} // namespace barcode
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+63
-60
@@ -25,90 +25,93 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::barcode
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace barcode
|
||||||
///
|
|
||||||
/// Style Type
|
|
||||||
///
|
|
||||||
class Style
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Style Type
|
||||||
|
///
|
||||||
|
class Style
|
||||||
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
Style ();
|
Style ();
|
||||||
|
|
||||||
Style ( const QString& id,
|
Style ( 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 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
const QString& id() const;
|
const QString& id() const;
|
||||||
|
|
||||||
QString fullId() const;
|
QString fullId() 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;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Operators
|
// Operators
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
bool operator!=( const Style& other ) const;
|
bool operator!=( const Style& other ) 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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+891
-887
File diff suppressed because it is too large
Load Diff
+895
-892
File diff suppressed because it is too large
Load Diff
+158
-155
@@ -31,189 +31,192 @@
|
|||||||
#include "TextSemicolonKeys.h"
|
#include "TextSemicolonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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,
|
// Static data
|
||||||
&None::create );
|
//
|
||||||
|
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(),
|
registerBackend( TextCsv::id(),
|
||||||
tr("Text: Comma Separated Values (CSV)"),
|
tr("Text: Comma Separated Values (CSV)"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextCsv::create );
|
&TextCsv::create );
|
||||||
|
|
||||||
registerBackend( TextCsvKeys::id(),
|
registerBackend( TextCsvKeys::id(),
|
||||||
tr("Text: Comma Separated Values (CSV), keys on line 1"),
|
tr("Text: Comma Separated Values (CSV), keys on line 1"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextCsvKeys::create );
|
&TextCsvKeys::create );
|
||||||
|
|
||||||
registerBackend( TextTsv::id(),
|
registerBackend( TextTsv::id(),
|
||||||
tr("Text: Tab Separated Values (TSV)"),
|
tr("Text: Tab Separated Values (TSV)"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextTsv::create );
|
&TextTsv::create );
|
||||||
|
|
||||||
registerBackend( TextTsvKeys::id(),
|
registerBackend( TextTsvKeys::id(),
|
||||||
tr("Text: Tab Separated Values (TSV), keys on line 1"),
|
tr("Text: Tab Separated Values (TSV), keys on line 1"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextTsvKeys::create );
|
&TextTsvKeys::create );
|
||||||
|
|
||||||
registerBackend( TextColon::id(),
|
registerBackend( TextColon::id(),
|
||||||
tr("Text: Colon Separated Values"),
|
tr("Text: Colon Separated Values"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextColon::create );
|
&TextColon::create );
|
||||||
|
|
||||||
registerBackend( TextColonKeys::id(),
|
registerBackend( TextColonKeys::id(),
|
||||||
tr("Text: Colon Separated Values, keys on line 1"),
|
tr("Text: Colon Separated Values, keys on line 1"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextColonKeys::create );
|
&TextColonKeys::create );
|
||||||
|
|
||||||
registerBackend( TextSemicolon::id(),
|
registerBackend( TextSemicolon::id(),
|
||||||
tr("Text: Semicolon Separated Values"),
|
tr("Text: Semicolon Separated Values"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextSemicolon::create );
|
&TextSemicolon::create );
|
||||||
|
|
||||||
registerBackend( TextSemicolonKeys::id(),
|
registerBackend( TextSemicolonKeys::id(),
|
||||||
tr("Text: Semicolon Separated Values, keys on line 1"),
|
tr("Text: Semicolon Separated Values, keys on line 1"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextSemicolonKeys::create );
|
&TextSemicolonKeys::create );
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Initialize
|
|
||||||
///
|
|
||||||
void Factory::init()
|
|
||||||
{
|
|
||||||
static Factory* singletonInstance = nullptr;
|
|
||||||
if ( !singletonInstance )
|
|
||||||
{
|
|
||||||
singletonInstance = new Factory();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create Merge object
|
/// Initialize
|
||||||
///
|
///
|
||||||
Merge* Factory::createMerge( const QString& id )
|
void Factory::init()
|
||||||
{
|
|
||||||
QMap<QString,BackendEntry>::iterator iBackend = mBackendIdMap.find( id );
|
|
||||||
if ( iBackend != mBackendIdMap.end() )
|
|
||||||
{
|
{
|
||||||
return iBackend->create();
|
static Factory* singletonInstance = nullptr;
|
||||||
|
if ( !singletonInstance )
|
||||||
|
{
|
||||||
|
singletonInstance = new Factory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create Merge object
|
||||||
|
///
|
||||||
|
Merge* Factory::createMerge( const QString& id )
|
||||||
|
{
|
||||||
|
QMap<QString,BackendEntry>::iterator iBackend = mBackendIdMap.find( id );
|
||||||
|
if ( iBackend != mBackendIdMap.end() )
|
||||||
|
{
|
||||||
|
return iBackend->create();
|
||||||
|
}
|
||||||
|
|
||||||
return None::create();
|
return None::create();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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
|
/// Get name list
|
||||||
///
|
///
|
||||||
QString Factory::nameToId( const QString& name )
|
QStringList Factory::nameList()
|
||||||
{
|
|
||||||
if ( mBackendNameMap.contains( name ) )
|
|
||||||
{
|
{
|
||||||
return mBackendNameMap[name].id;
|
return mNameList;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 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;
|
||||||
/// Lookup ID from index
|
backend.type = type;
|
||||||
///
|
backend.create = create;
|
||||||
QString Factory::indexToId( int index )
|
|
||||||
{
|
|
||||||
if ( (index > 0) && (index < mNameList.size()) )
|
|
||||||
{
|
|
||||||
QString name = mNameList[index];
|
|
||||||
|
|
||||||
return mBackendNameMap[ name ].id;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
mBackendIdMap[ id ] = backend;
|
||||||
mBackendNameMap[ name ] = backend;
|
mBackendNameMap[ name ] = backend;
|
||||||
|
|
||||||
mNameList << name;
|
mNameList << name;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+70
-67
@@ -27,80 +27,83 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
// Forward references
|
|
||||||
class 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
|
|
||||||
{
|
{
|
||||||
public:
|
Q_DECLARE_TR_FUNCTIONS(Factory)
|
||||||
QString id;
|
|
||||||
QString name;
|
|
||||||
SourceType type;
|
|
||||||
CreateFct create;
|
|
||||||
};
|
|
||||||
|
|
||||||
static QMap<QString,BackendEntry> mBackendIdMap;
|
|
||||||
static QMap<QString,BackendEntry> mBackendNameMap;
|
|
||||||
|
|
||||||
static QStringList mNameList;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Source Type
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
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
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString id;
|
||||||
|
QString name;
|
||||||
|
SourceType type;
|
||||||
|
CreateFct create;
|
||||||
|
};
|
||||||
|
|
||||||
|
static QMap<QString,BackendEntry> mBackendIdMap;
|
||||||
|
static QMap<QString,BackendEntry> mBackendNameMap;
|
||||||
|
|
||||||
|
static QStringList mNameList;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+148
-145
@@ -23,188 +23,191 @@
|
|||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
Merge::Merge()
|
Merge::Merge()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
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 != nullptr; record = readNextRecord() )
|
///
|
||||||
|
/// Get id
|
||||||
|
///
|
||||||
|
QString Merge::id() const
|
||||||
{
|
{
|
||||||
mRecordList.append( record );
|
return mId;
|
||||||
}
|
}
|
||||||
close();
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 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;
|
||||||
|
}
|
||||||
|
mRecordList.clear();
|
||||||
|
|
||||||
|
open();
|
||||||
|
for ( Record* record = readNextRecord(); record != nullptr; record = readNextRecord() )
|
||||||
|
{
|
||||||
|
mRecordList.append( record );
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
|
||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get record list
|
|
||||||
///
|
|
||||||
const QList<Record*>& Merge::recordList( ) 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 );
|
|
||||||
emit selectionChanged();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Select all records
|
/// Get record list
|
||||||
///
|
///
|
||||||
void Merge::selectAll()
|
const QList<Record*>& Merge::recordList( ) const
|
||||||
{
|
{
|
||||||
foreach ( Record* record, mRecordList )
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
///
|
||||||
|
/// Unselect all records
|
||||||
|
///
|
||||||
|
void Merge::unselectAll()
|
||||||
|
{
|
||||||
|
foreach ( Record* record, mRecordList )
|
||||||
|
{
|
||||||
|
record->setSelected( false );
|
||||||
|
}
|
||||||
|
emit selectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
|
||||||
|
///
|
||||||
|
/// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+78
-75
@@ -28,92 +28,95 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
// Forward references
|
|
||||||
class Record;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Merge Object
|
|
||||||
///
|
|
||||||
struct Merge : QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
|
// Forward references
|
||||||
/////////////////////////////////
|
class Record;
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
protected:
|
|
||||||
Merge();
|
|
||||||
Merge( const Merge* merge );
|
|
||||||
public:
|
|
||||||
~Merge() override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
virtual Merge* clone() const = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Properties
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
QString id() const;
|
|
||||||
QString source() const;
|
|
||||||
void setSource( const QString& source );
|
|
||||||
|
|
||||||
const QList<Record*>& recordList( void ) const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Selection methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
void select( Record* record );
|
|
||||||
void unselect( Record* record );
|
|
||||||
void setSelected( int i, bool state = true );
|
|
||||||
void selectAll();
|
|
||||||
void unselectAll();
|
|
||||||
|
|
||||||
int nSelectedRecords() const;
|
///
|
||||||
const QList<Record*> selectedRecords() const;
|
/// Merge Object
|
||||||
|
///
|
||||||
|
struct Merge : QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Virtual methods
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
protected:
|
||||||
virtual QStringList keys() const = 0;
|
Merge();
|
||||||
virtual QString primaryKey() const = 0;
|
Merge( const Merge* merge );
|
||||||
protected:
|
public:
|
||||||
virtual void open() = 0;
|
~Merge() override;
|
||||||
virtual void close() = 0;
|
|
||||||
virtual Record* readNextRecord() = 0;
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
virtual Merge* clone() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Properties
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
QString id() const;
|
||||||
|
QString source() const;
|
||||||
|
void setSource( const QString& source );
|
||||||
|
|
||||||
|
const QList<Record*>& recordList( void ) const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Selection methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
void select( Record* record );
|
||||||
|
void unselect( Record* record );
|
||||||
|
void setSelected( int i, bool state = true );
|
||||||
|
void selectAll();
|
||||||
|
void unselectAll();
|
||||||
|
|
||||||
|
int nSelectedRecords() const;
|
||||||
|
const QList<Record*> selectedRecords() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Virtual methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
virtual QStringList keys() const = 0;
|
||||||
|
virtual QString primaryKey() const = 0;
|
||||||
|
protected:
|
||||||
|
virtual void open() = 0;
|
||||||
|
virtual void close() = 0;
|
||||||
|
virtual Record* readNextRecord() = 0;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void sourceChanged();
|
void sourceChanged();
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private data
|
// Private data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
QString mId;
|
QString mId;
|
||||||
private:
|
private:
|
||||||
QString mSource;
|
QString mSource;
|
||||||
QList<Record*> mRecordList;
|
QList<Record*> mRecordList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+79
-76
@@ -21,102 +21,105 @@
|
|||||||
#include "None.h"
|
#include "None.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+37
-34
@@ -24,51 +24,54 @@
|
|||||||
#include "Merge.h"
|
#include "Merge.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~None() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
None();
|
||||||
|
None( const None* merge );
|
||||||
|
~None() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
None* clone() const override;
|
None* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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 override;
|
QStringList keys() const override;
|
||||||
QString primaryKey() const override;
|
QString primaryKey() const override;
|
||||||
protected:
|
protected:
|
||||||
void open() override;
|
void open() override;
|
||||||
void close() override;
|
void close() override;
|
||||||
Record* readNextRecord() override;
|
Record* readNextRecord() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+39
-36
@@ -21,50 +21,53 @@
|
|||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+31
-28
@@ -26,45 +26,48 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+339
-336
@@ -25,392 +25,395 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Text::Text( QChar delimiter, bool line1HasKeys )
|
|
||||||
: mDelimeter(delimiter), mLine1HasKeys(line1HasKeys), mNFieldsMax(0)
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Constructor
|
||||||
/// Constructor
|
///
|
||||||
///
|
Text::Text( QChar delimiter, bool line1HasKeys )
|
||||||
Text::Text( const Text* merge )
|
: mDelimeter(delimiter), mLine1HasKeys(line1HasKeys), mNFieldsMax(0)
|
||||||
: Merge( merge ),
|
|
||||||
mDelimeter(merge->mDelimeter), mLine1HasKeys(merge->mLine1HasKeys),
|
|
||||||
mNFieldsMax(merge->mNFieldsMax)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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);
|
mDelimeter(merge->mDelimeter), mLine1HasKeys(merge->mLine1HasKeys),
|
||||||
}
|
mNFieldsMax(merge->mNFieldsMax)
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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 nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 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;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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 nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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
|
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)
|
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)
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+41
-38
@@ -26,55 +26,58 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~Text() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
protected:
|
||||||
|
Text( QChar delimiter, bool line1HasKeys );
|
||||||
|
Text( const Text* merge );
|
||||||
|
~Text() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Implementation of virtual methods
|
// Implementation of virtual methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QStringList keys() const override;
|
QStringList keys() const override;
|
||||||
QString primaryKey() const override;
|
QString primaryKey() const override;
|
||||||
protected:
|
protected:
|
||||||
void open() override;
|
void open() override;
|
||||||
void close() override;
|
void close() override;
|
||||||
Record* readNextRecord() override;
|
Record* readNextRecord() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,61 +21,64 @@
|
|||||||
#include "TextColon.h"
|
#include "TextColon.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
static const QString ID = "Text/Colon";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextColon::create()
|
||||||
|
{
|
||||||
|
return new TextColon();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+28
-25
@@ -25,40 +25,43 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~TextColon() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextColon();
|
||||||
|
TextColon( const TextColon* merge );
|
||||||
|
~TextColon() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextColon* clone() const override;
|
TextColon* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,61 +21,64 @@
|
|||||||
#include "TextColonKeys.h"
|
#include "TextColonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
static const QString ID = "Text/Colon/Line1Keys";
|
static const QString ID = "Text/Colon/Line1Keys";
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextColonKeys::TextColonKeys() : Text(':',true)
|
TextColonKeys::TextColonKeys() : Text(':',true)
|
||||||
{
|
{
|
||||||
mId = ID;
|
mId = ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
|
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextColonKeys::~TextColonKeys()
|
TextColonKeys::~TextColonKeys()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
TextColonKeys* TextColonKeys::clone() const
|
TextColonKeys* TextColonKeys::clone() const
|
||||||
{
|
{
|
||||||
return new TextColonKeys( this );
|
return new TextColonKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString TextColonKeys::id()
|
QString TextColonKeys::id()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* TextColonKeys::create()
|
Merge* TextColonKeys::create()
|
||||||
{
|
{
|
||||||
return new TextColonKeys();
|
return new TextColonKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
@@ -25,40 +25,43 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~TextColonKeys() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextColonKeys();
|
||||||
|
TextColonKeys( const TextColonKeys* merge );
|
||||||
|
~TextColonKeys() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextColonKeys* clone() const override;
|
TextColonKeys* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+46
-43
@@ -21,61 +21,64 @@
|
|||||||
#include "TextCsv.h"
|
#include "TextCsv.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
static const QString ID = "Text/Comma";
|
static const QString ID = "Text/Comma";
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsv::TextCsv() : Text(',',false)
|
TextCsv::TextCsv() : Text(',',false)
|
||||||
{
|
{
|
||||||
mId = ID;
|
mId = ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
|
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextCsv::~TextCsv()
|
TextCsv::~TextCsv()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
TextCsv* TextCsv::clone() const
|
TextCsv* TextCsv::clone() const
|
||||||
{
|
{
|
||||||
return new TextCsv( this );
|
return new TextCsv( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString TextCsv::id()
|
QString TextCsv::id()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* TextCsv::create()
|
Merge* TextCsv::create()
|
||||||
{
|
{
|
||||||
return new TextCsv();
|
return new TextCsv();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+28
-25
@@ -25,40 +25,43 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~TextCsv() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextCsv();
|
||||||
|
TextCsv( const TextCsv* merge );
|
||||||
|
~TextCsv() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextCsv* clone() const override;
|
TextCsv* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,61 +21,64 @@
|
|||||||
#include "TextCsvKeys.h"
|
#include "TextCsvKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
static const QString ID = "Text/Comma/Line1Keys";
|
static const QString ID = "Text/Comma/Line1Keys";
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsvKeys::TextCsvKeys() : Text(',',true)
|
TextCsvKeys::TextCsvKeys() : Text(',',true)
|
||||||
{
|
{
|
||||||
mId = ID;
|
mId = ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
|
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextCsvKeys::~TextCsvKeys()
|
TextCsvKeys::~TextCsvKeys()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
TextCsvKeys* TextCsvKeys::clone() const
|
TextCsvKeys* TextCsvKeys::clone() const
|
||||||
{
|
{
|
||||||
return new TextCsvKeys( this );
|
return new TextCsvKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString TextCsvKeys::id()
|
QString TextCsvKeys::id()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* TextCsvKeys::create()
|
Merge* TextCsvKeys::create()
|
||||||
{
|
{
|
||||||
return new TextCsvKeys();
|
return new TextCsvKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
@@ -25,40 +25,43 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~TextCsvKeys() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextCsvKeys();
|
||||||
|
TextCsvKeys( const TextCsvKeys* merge );
|
||||||
|
~TextCsvKeys() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextCsvKeys* clone() const override;
|
TextCsvKeys* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,61 +21,64 @@
|
|||||||
#include "TextSemicolon.h"
|
#include "TextSemicolon.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
static const QString ID = "Text/Semicolon";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextSemicolon::create()
|
||||||
|
{
|
||||||
|
return new TextSemicolon();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
@@ -25,40 +25,43 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~TextSemicolon() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextSemicolon();
|
||||||
|
TextSemicolon( const TextSemicolon* merge );
|
||||||
|
~TextSemicolon() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextSemicolon* clone() const override;
|
TextSemicolon* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,61 +21,64 @@
|
|||||||
#include "TextSemicolonKeys.h"
|
#include "TextSemicolonKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
static const QString ID = "Text/Semicolon/Keys";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextSemicolonKeys::create()
|
||||||
|
{
|
||||||
|
return new TextSemicolonKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
@@ -25,40 +25,43 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~TextSemicolonKeys() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextSemicolonKeys();
|
||||||
|
TextSemicolonKeys( const TextSemicolonKeys* merge );
|
||||||
|
~TextSemicolonKeys() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextSemicolonKeys* clone() const override;
|
TextSemicolonKeys* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+46
-43
@@ -21,61 +21,64 @@
|
|||||||
#include "TextTsv.h"
|
#include "TextTsv.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
|
{
|
||||||
|
|
||||||
static const QString ID = "Text/Tab";
|
static const QString ID = "Text/Tab";
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextTsv::TextTsv() : Text('\t',false)
|
TextTsv::TextTsv() : Text('\t',false)
|
||||||
{
|
{
|
||||||
mId = ID;
|
mId = ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
|
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor
|
/// Destructor
|
||||||
///
|
///
|
||||||
TextTsv::~TextTsv()
|
TextTsv::~TextTsv()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
TextTsv* TextTsv::clone() const
|
TextTsv* TextTsv::clone() const
|
||||||
{
|
{
|
||||||
return new TextTsv( this );
|
return new TextTsv( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString TextTsv::id()
|
QString TextTsv::id()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* TextTsv::create()
|
Merge* TextTsv::create()
|
||||||
{
|
{
|
||||||
return new TextTsv();
|
return new TextTsv();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
+28
-25
@@ -25,40 +25,43 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~TextTsv() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextTsv();
|
||||||
|
TextTsv( const TextTsv* merge );
|
||||||
|
~TextTsv() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextTsv* clone() const override;
|
TextTsv* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,61 +21,64 @@
|
|||||||
#include "TextTsvKeys.h"
|
#include "TextTsvKeys.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::merge
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace merge
|
||||||
static const QString ID = "Text/Tab/Line1Keys";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::merge
|
|
||||||
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextTsvKeys::create()
|
||||||
|
{
|
||||||
|
return new TextTsvKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace merge
|
||||||
|
} // namespace glabels
|
||||||
|
|||||||
@@ -25,40 +25,43 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::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 );
|
|
||||||
~TextTsvKeys() override;
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextTsvKeys();
|
||||||
|
TextTsvKeys( const TextTsvKeys* merge );
|
||||||
|
~TextTsvKeys() override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
TextTsvKeys* clone() const override;
|
TextTsvKeys* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Static methods
|
// Static methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static QString id();
|
static QString id();
|
||||||
static Merge* create();
|
static Merge* create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+22
-19
@@ -21,25 +21,28 @@
|
|||||||
#include "Category.h"
|
#include "Category.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
Category::Category( const QString &id, const QString &name )
|
|
||||||
: mId(id), mName(name)
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
|
Category::Category( const QString &id, const QString &name )
|
||||||
|
: mId(id), mName(name)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Category::id() const
|
||||||
|
{
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Category::name() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString Category::id() const
|
|
||||||
{
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString Category::name() const
|
|
||||||
{
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+14
-11
@@ -25,25 +25,28 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class Category
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
class Category
|
||||||
Category( const QString& id, const QString& name );
|
{
|
||||||
|
|
||||||
QString id() const;
|
public:
|
||||||
QString name() const;
|
Category( const QString& id, const QString& name );
|
||||||
|
|
||||||
|
QString id() const;
|
||||||
|
QString name() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mId;
|
QString mId;
|
||||||
QString mName;
|
QString mName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+171
-168
@@ -23,180 +23,183 @@
|
|||||||
#include "merge/Record.h"
|
#include "merge/Record.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Default Constructor
|
|
||||||
///
|
|
||||||
ColorNode::ColorNode()
|
|
||||||
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// 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)
|
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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 == nullptr )
|
// 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;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
///
|
||||||
|
/// 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 == nullptr )
|
||||||
|
{
|
||||||
|
return mColor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( record->contains( mKey ) )
|
||||||
|
{
|
||||||
|
return QColor( (*record)[ mKey ] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+57
-54
@@ -30,82 +30,85 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// 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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-6
@@ -22,15 +22,18 @@
|
|||||||
#define model_Config_h
|
#define model_Config_h
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
namespace Config
|
|
||||||
{
|
{
|
||||||
const QString PROJECT_SOURCE_DIR = "@glabels-qt_SOURCE_DIR@";
|
|
||||||
const QString PROJECT_BUILD_DIR = "@glabels-qt_BINARY_DIR@";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
namespace Config
|
||||||
|
{
|
||||||
|
const QString PROJECT_SOURCE_DIR = "@glabels-qt_SOURCE_DIR@";
|
||||||
|
const QString PROJECT_BUILD_DIR = "@glabels-qt_BINARY_DIR@";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-7
@@ -22,16 +22,20 @@
|
|||||||
#define model_Constants_h
|
#define model_Constants_h
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
|
||||||
const double PTS_PER_PT = 1.0;
|
const double PTS_PER_PT = 1.0;
|
||||||
const double PTS_PER_INCH = 72.0;
|
const double PTS_PER_INCH = 72.0;
|
||||||
const double PTS_PER_MM = 2.83464566929;
|
const double PTS_PER_MM = 2.83464566929;
|
||||||
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 );
|
const Distance EPSILON( 0.5, Units::PT );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // model_Constants_h
|
#endif // model_Constants_h
|
||||||
|
|||||||
+57
-54
@@ -23,88 +23,91 @@
|
|||||||
#include "ModelImageObject.h"
|
#include "ModelImageObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
DataCache::DataCache()
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
DataCache::DataCache()
|
||||||
DataCache::DataCache( const QList<ModelObject*>& objects )
|
|
||||||
{
|
|
||||||
foreach( ModelObject* object, objects )
|
|
||||||
{
|
{
|
||||||
if ( ModelImageObject* imageObject = dynamic_cast<ModelImageObject*>(object) )
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DataCache::DataCache( const QList<ModelObject*>& objects )
|
||||||
|
{
|
||||||
|
foreach( ModelObject* object, objects )
|
||||||
{
|
{
|
||||||
TextNode filenameNode = imageObject->filenameNode();
|
if ( ModelImageObject* imageObject = dynamic_cast<ModelImageObject*>(object) )
|
||||||
if ( !filenameNode.isField() )
|
|
||||||
{
|
{
|
||||||
if ( const QImage* image = imageObject->image() )
|
TextNode filenameNode = imageObject->filenameNode();
|
||||||
|
if ( !filenameNode.isField() )
|
||||||
{
|
{
|
||||||
addImage( filenameNode.data(), *image );
|
if ( const QImage* image = imageObject->image() )
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QByteArray svg = imageObject->svg();
|
|
||||||
if ( !svg.isEmpty() )
|
|
||||||
{
|
{
|
||||||
addSvg( filenameNode.data(), svg );
|
addImage( filenameNode.data(), *image );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QByteArray svg = imageObject->svg();
|
||||||
|
if ( !svg.isEmpty() )
|
||||||
|
{
|
||||||
|
addSvg( filenameNode.data(), svg );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool DataCache::hasImage( const QString& name ) const
|
bool DataCache::hasImage( const QString& name ) const
|
||||||
{
|
{
|
||||||
return mImageMap.contains( name );
|
return mImageMap.contains( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QImage DataCache::getImage( const QString& name ) const
|
QImage DataCache::getImage( const QString& name ) const
|
||||||
{
|
{
|
||||||
return mImageMap[ name ];
|
return mImageMap[ name ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataCache::addImage( const QString& name, const QImage& image )
|
void DataCache::addImage( const QString& name, const QImage& image )
|
||||||
{
|
{
|
||||||
mImageMap[ name ] = image;
|
mImageMap[ name ] = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QString> DataCache::imageNames() const
|
QList<QString> DataCache::imageNames() const
|
||||||
{
|
{
|
||||||
return mImageMap.keys();
|
return mImageMap.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DataCache::hasSvg( const QString& name ) const
|
bool DataCache::hasSvg( const QString& name ) const
|
||||||
{
|
{
|
||||||
return mSvgMap.contains( name );
|
return mSvgMap.contains( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray DataCache::getSvg( const QString& name ) const
|
QByteArray DataCache::getSvg( const QString& name ) const
|
||||||
{
|
{
|
||||||
return mSvgMap[ name ];
|
return mSvgMap[ name ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataCache::addSvg( const QString& name, const QByteArray& svg )
|
void DataCache::addSvg( const QString& name, const QByteArray& svg )
|
||||||
{
|
{
|
||||||
mSvgMap[ name ] = svg;
|
mSvgMap[ name ] = svg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QString> DataCache::svgNames() const
|
QList<QString> DataCache::svgNames() const
|
||||||
{
|
{
|
||||||
return mSvgMap.keys();
|
return mSvgMap.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
}
|
||||||
|
}
|
||||||
|
|||||||
+21
-18
@@ -25,33 +25,36 @@
|
|||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class DataCache
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
DataCache();
|
class DataCache
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DataCache();
|
||||||
|
|
||||||
DataCache( const QList<ModelObject*>& objects );
|
DataCache( const QList<ModelObject*>& objects );
|
||||||
|
|
||||||
bool hasImage( const QString& name ) const;
|
bool hasImage( const QString& name ) const;
|
||||||
QImage getImage( const QString& name ) const;
|
QImage getImage( const QString& name ) const;
|
||||||
void addImage( const QString& name, const QImage& image );
|
void addImage( const QString& name, const QImage& image );
|
||||||
QList<QString> imageNames() const;
|
QList<QString> imageNames() const;
|
||||||
|
|
||||||
bool hasSvg( const QString& name ) const;
|
bool hasSvg( const QString& name ) const;
|
||||||
QByteArray getSvg( const QString& name ) const;
|
QByteArray getSvg( const QString& name ) const;
|
||||||
void addSvg( const QString& name, const QByteArray& svg );
|
void addSvg( const QString& name, const QByteArray& svg );
|
||||||
QList<QString> svgNames() const;
|
QList<QString> svgNames() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<QString,QImage> mImageMap;
|
QMap<QString,QImage> mImageMap;
|
||||||
QMap<QString,QByteArray> mSvgMap;
|
QMap<QString,QByteArray> mSvgMap;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+568
-565
File diff suppressed because it is too large
Load Diff
+74
-71
@@ -33,108 +33,111 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class Db
|
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(Db)
|
|
||||||
|
|
||||||
private:
|
class Db
|
||||||
Db();
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(Db)
|
||||||
|
|
||||||
|
private:
|
||||||
|
Db();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void init();
|
static void init();
|
||||||
static Db* instance();
|
static Db* instance();
|
||||||
|
|
||||||
|
|
||||||
static const QList<Paper*>& papers();
|
static const QList<Paper*>& papers();
|
||||||
static const QStringList& paperIds();
|
static const QStringList& paperIds();
|
||||||
static const QStringList& paperNames();
|
static const QStringList& paperNames();
|
||||||
|
|
||||||
static const QList<Category*>& categories();
|
static const QList<Category*>& categories();
|
||||||
static const QStringList& categoryIds();
|
static const QStringList& categoryIds();
|
||||||
static const QStringList& categoryNames();
|
static const QStringList& categoryNames();
|
||||||
|
|
||||||
static const QList<Vendor*>& vendors();
|
static const QList<Vendor*>& vendors();
|
||||||
static const QStringList& vendorNames();
|
static const QStringList& vendorNames();
|
||||||
|
|
||||||
static const QList<Template*>& templates();
|
static const QList<Template*>& templates();
|
||||||
|
|
||||||
|
|
||||||
static void registerPaper( Paper *paper );
|
static void registerPaper( Paper *paper );
|
||||||
static const Paper *lookupPaperFromName( const QString& name );
|
static const Paper *lookupPaperFromName( const QString& name );
|
||||||
static const Paper *lookupPaperFromId( const QString& id );
|
static const Paper *lookupPaperFromId( const QString& id );
|
||||||
static QString lookupPaperIdFromName( const QString& name );
|
static QString lookupPaperIdFromName( const QString& name );
|
||||||
static QString lookupPaperNameFromId( const QString& id );
|
static QString lookupPaperNameFromId( const QString& id );
|
||||||
static bool isPaperIdKnown( const QString& id );
|
static bool isPaperIdKnown( const QString& id );
|
||||||
static bool isPaperIdOther( const QString& id );
|
static bool isPaperIdOther( const QString& id );
|
||||||
|
|
||||||
static void registerCategory( Category *category );
|
static void registerCategory( Category *category );
|
||||||
static const Category *lookupCategoryFromName( const QString& name );
|
static const Category *lookupCategoryFromName( const QString& name );
|
||||||
static const Category *lookupCategoryFromId( const QString& id );
|
static const Category *lookupCategoryFromId( const QString& id );
|
||||||
static QString lookupCategoryIdFromName( const QString& name );
|
static QString lookupCategoryIdFromName( const QString& name );
|
||||||
static QString lookupCategoryNameFromId( const QString& id );
|
static QString lookupCategoryNameFromId( const QString& id );
|
||||||
static bool isCategoryIdKnown( const QString& id );
|
static bool isCategoryIdKnown( const QString& id );
|
||||||
|
|
||||||
static void registerVendor( Vendor *vendor );
|
static void registerVendor( Vendor *vendor );
|
||||||
static const Vendor *lookupVendorFromName( const QString& name );
|
static const Vendor *lookupVendorFromName( const QString& name );
|
||||||
static QString lookupVendorUrlFromName( const QString& name );
|
static QString lookupVendorUrlFromName( const QString& name );
|
||||||
static bool isVendorNameKnown( const QString& id );
|
static bool isVendorNameKnown( const QString& id );
|
||||||
|
|
||||||
static void registerTemplate( Template *tmplate );
|
static void registerTemplate( Template *tmplate );
|
||||||
static const Template *lookupTemplateFromName( const QString& name );
|
static const Template *lookupTemplateFromName( const QString& name );
|
||||||
static const Template *lookupTemplateFromBrandPart( const QString& brand,
|
static const Template *lookupTemplateFromBrandPart( const QString& brand,
|
||||||
const QString& part );
|
const QString& part );
|
||||||
static bool isTemplateKnown( const QString& brand, const QString& part );
|
static bool isTemplateKnown( const QString& brand, const QString& part );
|
||||||
static QStringList getNameListOfSimilarTemplates( const QString& name );
|
static QStringList getNameListOfSimilarTemplates( const QString& name );
|
||||||
|
|
||||||
static void registerUserTemplate( Template *tmplate );
|
static void registerUserTemplate( Template *tmplate );
|
||||||
static void deleteUserTemplateByName( const QString& name );
|
static void deleteUserTemplateByName( const QString& name );
|
||||||
static void deleteUserTemplateByBrandPart( const QString& brand,
|
static void deleteUserTemplateByBrandPart( const QString& brand,
|
||||||
const QString& part );
|
const QString& part );
|
||||||
|
|
||||||
static void printKnownPapers();
|
static void printKnownPapers();
|
||||||
static void printKnownCategories();
|
static void printKnownCategories();
|
||||||
static void printKnownVendors();
|
static void printKnownVendors();
|
||||||
static void printKnownTemplates();
|
static void printKnownTemplates();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QDir systemTemplatesDir();
|
static QDir systemTemplatesDir();
|
||||||
|
|
||||||
static void readPapers();
|
static void readPapers();
|
||||||
static void readPapersFromDir( const QDir& dir );
|
static void readPapersFromDir( const QDir& dir );
|
||||||
|
|
||||||
static void readCategories();
|
static void readCategories();
|
||||||
static void readCategoriesFromDir( const QDir& dir );
|
static void readCategoriesFromDir( const QDir& dir );
|
||||||
|
|
||||||
static void readVendors();
|
static void readVendors();
|
||||||
static void readVendorsFromDir( const QDir& dir );
|
static void readVendorsFromDir( const QDir& dir );
|
||||||
|
|
||||||
static void readTemplates();
|
static void readTemplates();
|
||||||
static void readTemplatesFromDir( const QDir& dir );
|
static void readTemplatesFromDir( const QDir& dir );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QList<Paper*> mPapers;
|
static QList<Paper*> mPapers;
|
||||||
static QStringList mPaperIds;
|
static QStringList mPaperIds;
|
||||||
static QStringList mPaperNames;
|
static QStringList mPaperNames;
|
||||||
|
|
||||||
static QList<Category*> mCategories;
|
static QList<Category*> mCategories;
|
||||||
static QStringList mCategoryIds;
|
static QStringList mCategoryIds;
|
||||||
static QStringList mCategoryNames;
|
static QStringList mCategoryNames;
|
||||||
|
|
||||||
static QList<Vendor*> mVendors;
|
static QList<Vendor*> mVendors;
|
||||||
static QStringList mVendorNames;
|
static QStringList mVendorNames;
|
||||||
|
|
||||||
static QList<Template*> mTemplates;
|
static QList<Template*> mTemplates;
|
||||||
|
|
||||||
static QString mPaperNameOther;
|
static QString mPaperNameOther;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+160
-157
@@ -24,184 +24,187 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
Distance::Distance( double d, Units::Enum unitsEnum )
|
|
||||||
{
|
{
|
||||||
switch (unitsEnum)
|
|
||||||
|
Distance::Distance( double d, Units::Enum unitsEnum )
|
||||||
{
|
{
|
||||||
case Units::PT:
|
switch (unitsEnum)
|
||||||
mDPts = d;
|
{
|
||||||
break;
|
case Units::PT:
|
||||||
case Units::IN:
|
mDPts = d;
|
||||||
mDPts = d * PTS_PER_INCH;
|
break;
|
||||||
break;
|
case Units::IN:
|
||||||
case Units::MM:
|
mDPts = d * PTS_PER_INCH;
|
||||||
mDPts = d * PTS_PER_MM;
|
break;
|
||||||
break;
|
case Units::MM:
|
||||||
case Units::CM:
|
mDPts = d * PTS_PER_MM;
|
||||||
mDPts = d * PTS_PER_CM;
|
break;
|
||||||
break;
|
case Units::CM:
|
||||||
case Units::PC:
|
mDPts = d * PTS_PER_CM;
|
||||||
mDPts = d * PTS_PER_PICA;
|
break;
|
||||||
break;
|
case Units::PC:
|
||||||
default:
|
mDPts = d * PTS_PER_PICA;
|
||||||
mDPts = d;
|
break;
|
||||||
break;
|
default:
|
||||||
|
mDPts = d;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance::Distance( double d, const Units& units )
|
Distance::Distance( double d, const Units& units )
|
||||||
{
|
|
||||||
switch (units.toEnum())
|
|
||||||
{
|
{
|
||||||
case Units::PT:
|
switch (units.toEnum())
|
||||||
mDPts = d;
|
{
|
||||||
break;
|
case Units::PT:
|
||||||
case Units::IN:
|
mDPts = d;
|
||||||
mDPts = d * PTS_PER_INCH;
|
break;
|
||||||
break;
|
case Units::IN:
|
||||||
case Units::MM:
|
mDPts = d * PTS_PER_INCH;
|
||||||
mDPts = d * PTS_PER_MM;
|
break;
|
||||||
break;
|
case Units::MM:
|
||||||
case Units::CM:
|
mDPts = d * PTS_PER_MM;
|
||||||
mDPts = d * PTS_PER_CM;
|
break;
|
||||||
break;
|
case Units::CM:
|
||||||
case Units::PC:
|
mDPts = d * PTS_PER_CM;
|
||||||
mDPts = d * PTS_PER_PICA;
|
break;
|
||||||
break;
|
case Units::PC:
|
||||||
default:
|
mDPts = d * PTS_PER_PICA;
|
||||||
mDPts = d;
|
break;
|
||||||
break;
|
default:
|
||||||
|
mDPts = d;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance::Distance( double d, const QString& unitsId )
|
Distance::Distance( double d, const QString& unitsId )
|
||||||
{
|
{
|
||||||
Units units = Units( unitsId );
|
Units units = Units( unitsId );
|
||||||
|
|
||||||
switch (units.toEnum())
|
switch (units.toEnum())
|
||||||
{
|
{
|
||||||
case Units::PT:
|
case Units::PT:
|
||||||
mDPts = d;
|
mDPts = d;
|
||||||
break;
|
break;
|
||||||
case Units::IN:
|
case Units::IN:
|
||||||
mDPts = d * PTS_PER_INCH;
|
mDPts = d * PTS_PER_INCH;
|
||||||
break;
|
break;
|
||||||
case Units::MM:
|
case Units::MM:
|
||||||
mDPts = d * PTS_PER_MM;
|
mDPts = d * PTS_PER_MM;
|
||||||
break;
|
break;
|
||||||
case Units::CM:
|
case Units::CM:
|
||||||
mDPts = d * PTS_PER_CM;
|
mDPts = d * PTS_PER_CM;
|
||||||
break;
|
break;
|
||||||
case Units::PC:
|
case Units::PC:
|
||||||
mDPts = d * PTS_PER_PICA;
|
mDPts = d * PTS_PER_PICA;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mDPts = d;
|
mDPts = d;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance Distance::fromString( const QString& string )
|
|
||||||
{
|
|
||||||
QString stringCopy = string;
|
|
||||||
QTextStream valueStream( &stringCopy, QIODevice::ReadOnly );
|
|
||||||
|
|
||||||
double value;
|
|
||||||
QString unitsString;
|
|
||||||
valueStream >> value >> unitsString;
|
|
||||||
|
|
||||||
if ( !unitsString.isEmpty() && !Units::isIdValid( unitsString ) )
|
|
||||||
{
|
|
||||||
qWarning() << "Invalid Units in string: \"" << string << "\"";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Distance( value, unitsString );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Distance Distance::fromString( const QString& string )
|
||||||
double Distance::inUnits( const Units& units ) const
|
|
||||||
{
|
|
||||||
double d;
|
|
||||||
|
|
||||||
switch (units.toEnum())
|
|
||||||
{
|
{
|
||||||
case Units::PT:
|
QString stringCopy = string;
|
||||||
d = pt();
|
QTextStream valueStream( &stringCopy, QIODevice::ReadOnly );
|
||||||
break;
|
|
||||||
case Units::IN:
|
double value;
|
||||||
d = in();
|
QString unitsString;
|
||||||
break;
|
valueStream >> value >> unitsString;
|
||||||
case Units::MM:
|
|
||||||
d = mm();
|
if ( !unitsString.isEmpty() && !Units::isIdValid( unitsString ) )
|
||||||
break;
|
{
|
||||||
case Units::CM:
|
qWarning() << "Invalid Units in string: \"" << string << "\"";
|
||||||
d = cm();
|
}
|
||||||
break;
|
|
||||||
case Units::PC:
|
return Distance( value, unitsString );
|
||||||
d = pc();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
double Distance::inUnits( const Units& units ) const
|
||||||
|
{
|
||||||
|
double d;
|
||||||
|
|
||||||
|
switch (units.toEnum())
|
||||||
|
{
|
||||||
|
case Units::PT:
|
||||||
|
d = pt();
|
||||||
|
break;
|
||||||
|
case Units::IN:
|
||||||
|
d = in();
|
||||||
|
break;
|
||||||
|
case Units::MM:
|
||||||
|
d = mm();
|
||||||
|
break;
|
||||||
|
case Units::CM:
|
||||||
|
d = cm();
|
||||||
|
break;
|
||||||
|
case Units::PC:
|
||||||
|
d = pc();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double Distance::inUnits( Units::Enum unitsEnum ) const
|
double Distance::inUnits( Units::Enum unitsEnum ) const
|
||||||
{
|
|
||||||
double d;
|
|
||||||
|
|
||||||
switch (unitsEnum)
|
|
||||||
{
|
{
|
||||||
case Units::PT:
|
double d;
|
||||||
d = pt();
|
|
||||||
break;
|
|
||||||
case Units::IN:
|
|
||||||
d = in();
|
|
||||||
break;
|
|
||||||
case Units::MM:
|
|
||||||
d = mm();
|
|
||||||
break;
|
|
||||||
case Units::CM:
|
|
||||||
d = cm();
|
|
||||||
break;
|
|
||||||
case Units::PC:
|
|
||||||
d = pc();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
switch (unitsEnum)
|
||||||
}
|
{
|
||||||
|
case Units::PT:
|
||||||
|
d = pt();
|
||||||
|
break;
|
||||||
|
case Units::IN:
|
||||||
|
d = in();
|
||||||
|
break;
|
||||||
|
case Units::MM:
|
||||||
|
d = mm();
|
||||||
|
break;
|
||||||
|
case Units::CM:
|
||||||
|
d = cm();
|
||||||
|
break;
|
||||||
|
case Units::PC:
|
||||||
|
d = pc();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double Distance::inUnits( const QString& unitsId ) const
|
double Distance::inUnits( const QString& unitsId ) const
|
||||||
{
|
{
|
||||||
return inUnits( Units( unitsId ) );
|
return inUnits( Units( unitsId ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Distance::toString( const Units& units ) const
|
||||||
|
{
|
||||||
|
return QString::number( inUnits(units) ) + units.toIdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Distance::toString( Units::Enum unitsEnum ) const
|
||||||
|
{
|
||||||
|
Units units(unitsEnum);
|
||||||
|
return QString::number( inUnits(units) ) + units.toIdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Distance::toString( const QString& unitsId ) const
|
||||||
|
{
|
||||||
|
Units units(unitsId);
|
||||||
|
return QString::number( inUnits(units) ) + units.toIdString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString Distance::toString( const Units& units ) const
|
|
||||||
{
|
|
||||||
return QString::number( inUnits(units) ) + units.toIdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString Distance::toString( Units::Enum unitsEnum ) const
|
|
||||||
{
|
|
||||||
Units units(unitsEnum);
|
|
||||||
return QString::number( inUnits(units) ) + units.toIdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString Distance::toString( const QString& unitsId ) const
|
|
||||||
{
|
|
||||||
Units units(unitsId);
|
|
||||||
return QString::number( inUnits(units) ) + units.toIdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+188
-182
@@ -29,71 +29,74 @@
|
|||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class Distance
|
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(Distance)
|
|
||||||
|
|
||||||
public:
|
class Distance
|
||||||
Distance();
|
{
|
||||||
Distance( double d, Units::Enum unitsEnum = Units::PT );
|
Q_DECLARE_TR_FUNCTIONS(Distance)
|
||||||
Distance( double d, const Units& units );
|
|
||||||
Distance( double d, const QString& unitsId );
|
|
||||||
|
|
||||||
static Distance pt( double dPts );
|
public:
|
||||||
static Distance in( double dInches );
|
Distance();
|
||||||
static Distance mm( double dMm );
|
Distance( double d, Units::Enum unitsEnum = Units::PT );
|
||||||
static Distance cm( double dCm );
|
Distance( double d, const Units& units );
|
||||||
static Distance pc( double dPicas );
|
Distance( double d, const QString& unitsId );
|
||||||
static Distance fromString( const QString& string );
|
|
||||||
|
static Distance pt( double dPts );
|
||||||
|
static Distance in( double dInches );
|
||||||
|
static Distance mm( double dMm );
|
||||||
|
static Distance cm( double dCm );
|
||||||
|
static Distance pc( double dPicas );
|
||||||
|
static Distance fromString( const QString& string );
|
||||||
|
|
||||||
|
|
||||||
double pt() const;
|
double pt() const;
|
||||||
double in() const;
|
double in() const;
|
||||||
double mm() const;
|
double mm() const;
|
||||||
double cm() const;
|
double cm() const;
|
||||||
double pc() const;
|
double pc() const;
|
||||||
double inUnits( const Units& units ) const;
|
double inUnits( const Units& units ) const;
|
||||||
double inUnits( Units::Enum unitsEnum ) const;
|
double inUnits( Units::Enum unitsEnum ) const;
|
||||||
double inUnits( const QString& unitsId ) const;
|
double inUnits( const QString& unitsId ) const;
|
||||||
|
|
||||||
|
|
||||||
QString toString( const Units& units ) const;
|
QString toString( const Units& units ) const;
|
||||||
QString toString( Units::Enum unitsEnum ) const;
|
QString toString( Units::Enum unitsEnum ) const;
|
||||||
QString toString( const QString& unitsId ) const;
|
QString toString( const QString& unitsId ) const;
|
||||||
|
|
||||||
|
|
||||||
Distance& operator+=( const Distance& d );
|
Distance& operator+=( const Distance& d );
|
||||||
Distance& operator-=( const Distance& d );
|
Distance& operator-=( const Distance& d );
|
||||||
Distance operator-();
|
Distance operator-();
|
||||||
|
|
||||||
friend inline Distance operator+( const Distance& d1, const Distance& d2 );
|
friend inline Distance operator+( const Distance& d1, const Distance& d2 );
|
||||||
friend inline Distance operator-( const Distance& d1, const Distance& d2 );
|
friend inline Distance operator-( const Distance& d1, const Distance& d2 );
|
||||||
friend inline Distance operator*( double x, const Distance& d );
|
friend inline Distance operator*( double x, const Distance& d );
|
||||||
friend inline Distance operator*( const Distance& d, double x );
|
friend inline Distance operator*( const Distance& d, double x );
|
||||||
friend inline double operator/( const Distance& d1, const Distance& d2 );
|
friend inline double operator/( const Distance& d1, const Distance& d2 );
|
||||||
friend inline Distance operator/( const Distance& d, double x );
|
friend inline Distance operator/( const Distance& d, double x );
|
||||||
|
|
||||||
friend inline bool operator<( const Distance& d1, const Distance& d2 );
|
friend inline bool operator<( const Distance& d1, const Distance& d2 );
|
||||||
friend inline bool operator<=( const Distance& d1, const Distance& d2 );
|
friend inline bool operator<=( const Distance& d1, const Distance& d2 );
|
||||||
friend inline bool operator>( const Distance& d1, const Distance& d2 );
|
friend inline bool operator>( const Distance& d1, const Distance& d2 );
|
||||||
friend inline bool operator>=( const Distance& d1, const Distance& d2 );
|
friend inline bool operator>=( const Distance& d1, const Distance& d2 );
|
||||||
friend inline bool operator==( const Distance& d1, const Distance& d2 );
|
friend inline bool operator==( const Distance& d1, const Distance& d2 );
|
||||||
friend inline bool operator!=( const Distance& d1, const Distance& d2 );
|
friend inline bool operator!=( const Distance& d1, const Distance& d2 );
|
||||||
|
|
||||||
friend inline Distance fabs( const Distance& d );
|
friend inline Distance fabs( const Distance& d );
|
||||||
friend inline Distance min( const Distance& d1, const Distance& d2 );
|
friend inline Distance min( const Distance& d1, const Distance& d2 );
|
||||||
friend inline Distance max( const Distance& d1, const Distance& d2 );
|
friend inline Distance max( const Distance& d1, const Distance& d2 );
|
||||||
friend inline Distance fmod( const Distance& d1, const Distance& d2 );
|
friend inline Distance fmod( const Distance& d1, const Distance& d2 );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mDPts;
|
double mDPts;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,199 +106,202 @@ namespace glabels::model
|
|||||||
|
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
inline Distance::Distance() : mDPts(0)
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
inline Distance::Distance() : mDPts(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance Distance::pt( double dPts )
|
inline Distance Distance::pt( double dPts )
|
||||||
{
|
{
|
||||||
Distance d;
|
Distance d;
|
||||||
d.mDPts = dPts;
|
d.mDPts = dPts;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance Distance::in( double dInches )
|
inline Distance Distance::in( double dInches )
|
||||||
{
|
{
|
||||||
Distance d;
|
Distance d;
|
||||||
d.mDPts = dInches * PTS_PER_INCH;
|
d.mDPts = dInches * PTS_PER_INCH;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance Distance::mm( double dMm )
|
inline Distance Distance::mm( double dMm )
|
||||||
{
|
{
|
||||||
Distance d;
|
Distance d;
|
||||||
d.mDPts = dMm * PTS_PER_MM;
|
d.mDPts = dMm * PTS_PER_MM;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance Distance::cm( double dCm )
|
inline Distance Distance::cm( double dCm )
|
||||||
{
|
{
|
||||||
Distance d;
|
Distance d;
|
||||||
d.mDPts = dCm * PTS_PER_CM;
|
d.mDPts = dCm * PTS_PER_CM;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance Distance::pc( double dPicas )
|
inline Distance Distance::pc( double dPicas )
|
||||||
{
|
{
|
||||||
Distance d;
|
Distance d;
|
||||||
d.mDPts = dPicas * PTS_PER_PICA;
|
d.mDPts = dPicas * PTS_PER_PICA;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Distance::pt() const
|
inline double Distance::pt() const
|
||||||
{
|
{
|
||||||
return mDPts;
|
return mDPts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Distance::in() const
|
inline double Distance::in() const
|
||||||
{
|
{
|
||||||
return mDPts / PTS_PER_INCH;
|
return mDPts / PTS_PER_INCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Distance::mm() const
|
inline double Distance::mm() const
|
||||||
{
|
{
|
||||||
return mDPts / PTS_PER_MM;
|
return mDPts / PTS_PER_MM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Distance::cm() const
|
inline double Distance::cm() const
|
||||||
{
|
{
|
||||||
return mDPts / PTS_PER_CM;
|
return mDPts / PTS_PER_CM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double Distance::pc() const
|
inline double Distance::pc() const
|
||||||
{
|
{
|
||||||
return mDPts / PTS_PER_PICA;
|
return mDPts / PTS_PER_PICA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance& Distance::operator+=( const Distance& d )
|
inline Distance& Distance::operator+=( const Distance& d )
|
||||||
{
|
{
|
||||||
mDPts += d.mDPts;
|
mDPts += d.mDPts;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance& Distance::operator-=( const Distance& d )
|
inline Distance& Distance::operator-=( const Distance& d )
|
||||||
{
|
{
|
||||||
mDPts -= d.mDPts;
|
mDPts -= d.mDPts;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance Distance::operator-()
|
inline Distance Distance::operator-()
|
||||||
{
|
{
|
||||||
return Distance::pt( -mDPts );
|
return Distance::pt( -mDPts );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance operator+( const Distance& d1, const Distance& d2 )
|
inline Distance operator+( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return Distance::pt( d1.mDPts + d2.mDPts );
|
return Distance::pt( d1.mDPts + d2.mDPts );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance operator-( const Distance& d1, const Distance& d2 )
|
inline Distance operator-( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return Distance::pt( d1.mDPts - d2.mDPts );
|
return Distance::pt( d1.mDPts - d2.mDPts );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance operator*( double x, const Distance& d )
|
inline Distance operator*( double x, const Distance& d )
|
||||||
{
|
{
|
||||||
return Distance::pt( x * d.mDPts );
|
return Distance::pt( x * d.mDPts );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance operator*( const Distance& d, double x )
|
inline Distance operator*( const Distance& d, double x )
|
||||||
{
|
{
|
||||||
return Distance::pt( d.mDPts * x );
|
return Distance::pt( d.mDPts * x );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double operator/( const Distance& d1, const Distance& d2 )
|
inline double operator/( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return d1.mDPts / d2.mDPts;
|
return d1.mDPts / d2.mDPts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance operator/( const Distance& d, double x )
|
inline Distance operator/( const Distance& d, double x )
|
||||||
{
|
{
|
||||||
return Distance::pt( d.mDPts / x );
|
return Distance::pt( d.mDPts / x );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool operator<( const Distance& d1, const Distance& d2 )
|
inline bool operator<( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return d1.mDPts < d2.mDPts;
|
return d1.mDPts < d2.mDPts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool operator<=( const Distance& d1, const Distance& d2 )
|
inline bool operator<=( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return d1.mDPts <= d2.mDPts;
|
return d1.mDPts <= d2.mDPts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool operator>( const Distance& d1, const Distance& d2 )
|
inline bool operator>( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return d1.mDPts > d2.mDPts;
|
return d1.mDPts > d2.mDPts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool operator>=( const Distance& d1, const Distance& d2 )
|
inline bool operator>=( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return d1.mDPts >= d2.mDPts;
|
return d1.mDPts >= d2.mDPts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool operator==( const Distance& d1, const Distance& d2 )
|
inline bool operator==( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return d1.mDPts == d2.mDPts;
|
return d1.mDPts == d2.mDPts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool operator!=( const Distance& d1, const Distance& d2 )
|
inline bool operator!=( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return d1.mDPts != d2.mDPts;
|
return d1.mDPts != d2.mDPts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance fabs( const Distance& d )
|
inline Distance fabs( const Distance& d )
|
||||||
{
|
{
|
||||||
return Distance::pt( qFabs( d.mDPts ) );
|
return Distance::pt( qFabs( d.mDPts ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance min( const Distance& d1, const Distance& d2 )
|
inline Distance min( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return (d1.mDPts < d2.mDPts) ? d1 : d2;
|
return (d1.mDPts < d2.mDPts) ? d1 : d2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance max( const Distance& d1, const Distance& d2 )
|
inline Distance max( const Distance& d1, const Distance& d2 )
|
||||||
{
|
{
|
||||||
return (d1.mDPts > d2.mDPts) ? d1 : d2;
|
return (d1.mDPts > d2.mDPts) ? d1 : d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Distance fmod( const Distance& d1, const Distance& d2 )
|
||||||
|
{
|
||||||
|
return Distance::pt( std::fmod( d1.mDPts, d2.mDPts ) );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Distance fmod( const Distance& d1, const Distance& d2 )
|
|
||||||
{
|
|
||||||
return Distance::pt( std::fmod( d1.mDPts, d2.mDPts ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+57
-54
@@ -25,63 +25,66 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
QString FileUtil::addExtension( const QString& rawFilename, const QString& extension )
|
|
||||||
{
|
{
|
||||||
if ( rawFilename.endsWith( extension ) )
|
|
||||||
|
QString FileUtil::addExtension( const QString& rawFilename, const QString& extension )
|
||||||
{
|
{
|
||||||
return rawFilename;
|
if ( rawFilename.endsWith( extension ) )
|
||||||
|
{
|
||||||
|
return rawFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rawFilename + extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDir FileUtil::systemTemplatesDir()
|
||||||
|
{
|
||||||
|
QDir dir;
|
||||||
|
|
||||||
|
// First, try finding templates directory relative to application path
|
||||||
|
dir.cd( QApplication::applicationDirPath() );
|
||||||
|
if ( (dir.dirName() == "bin") &&
|
||||||
|
dir.cdUp() && dir.cd( "share" ) && dir.cd( "glabels-qt" ) && dir.cd( "templates" ) )
|
||||||
|
{
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next, try running out of the source directory.
|
||||||
|
if ( dir.cd( Config::PROJECT_SOURCE_DIR ) && dir.cd( "templates" ) )
|
||||||
|
{
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
qFatal( "Cannot locate system template directory!" );
|
||||||
|
return QDir("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDir FileUtil::translationsDir()
|
||||||
|
{
|
||||||
|
QDir dir;
|
||||||
|
|
||||||
|
// First, try finding translations directory relative to application path
|
||||||
|
dir.cd( QApplication::applicationDirPath() );
|
||||||
|
if ( (dir.dirName() == "bin") &&
|
||||||
|
dir.cdUp() && dir.cd( "share" ) && dir.cd( "glabels-qt" ) && dir.cd( "translations" ) )
|
||||||
|
{
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next, try running out of the source directory.
|
||||||
|
if ( dir.cd( Config::PROJECT_BUILD_DIR ) && dir.cd( "translations" ) )
|
||||||
|
{
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
qFatal( "Cannot locate system template directory!" );
|
||||||
|
return QDir("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
return rawFilename + extension;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QDir FileUtil::systemTemplatesDir()
|
|
||||||
{
|
|
||||||
QDir dir;
|
|
||||||
|
|
||||||
// First, try finding templates directory relative to application path
|
|
||||||
dir.cd( QApplication::applicationDirPath() );
|
|
||||||
if ( (dir.dirName() == "bin") &&
|
|
||||||
dir.cdUp() && dir.cd( "share" ) && dir.cd( "glabels-qt" ) && dir.cd( "templates" ) )
|
|
||||||
{
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next, try running out of the source directory.
|
|
||||||
if ( dir.cd( Config::PROJECT_SOURCE_DIR ) && dir.cd( "templates" ) )
|
|
||||||
{
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
qFatal( "Cannot locate system template directory!" );
|
|
||||||
return QDir("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QDir FileUtil::translationsDir()
|
|
||||||
{
|
|
||||||
QDir dir;
|
|
||||||
|
|
||||||
// First, try finding translations directory relative to application path
|
|
||||||
dir.cd( QApplication::applicationDirPath() );
|
|
||||||
if ( (dir.dirName() == "bin") &&
|
|
||||||
dir.cdUp() && dir.cd( "share" ) && dir.cd( "glabels-qt" ) && dir.cd( "translations" ) )
|
|
||||||
{
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next, try running out of the source directory.
|
|
||||||
if ( dir.cd( Config::PROJECT_BUILD_DIR ) && dir.cd( "translations" ) )
|
|
||||||
{
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
qFatal( "Cannot locate system template directory!" );
|
|
||||||
return QDir("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+11
-8
@@ -26,20 +26,23 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
namespace FileUtil
|
|
||||||
{
|
{
|
||||||
|
|
||||||
QString addExtension( const QString& rawFilename, const QString& extension );
|
namespace FileUtil
|
||||||
|
{
|
||||||
|
|
||||||
QDir systemTemplatesDir();
|
QString addExtension( const QString& rawFilename, const QString& extension );
|
||||||
QDir userTemplatesDir();
|
|
||||||
|
QDir systemTemplatesDir();
|
||||||
|
QDir userTemplatesDir();
|
||||||
|
|
||||||
|
QDir translationsDir();
|
||||||
|
}
|
||||||
|
|
||||||
QDir translationsDir();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+97
-94
@@ -25,114 +25,117 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
Frame::Frame( const QString& id )
|
|
||||||
: mId(id), mNLabels(0), mLayoutDescription("")
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Frame::Frame( const QString& id )
|
||||||
Frame::Frame( const Frame& other )
|
: mId(id), mNLabels(0), mLayoutDescription("")
|
||||||
{
|
|
||||||
mId = other.mId;
|
|
||||||
mNLabels = 0;
|
|
||||||
|
|
||||||
foreach ( Layout *layout, mLayouts )
|
|
||||||
{
|
{
|
||||||
addLayout( layout->dup() );
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( Markup *markup, mMarkups )
|
|
||||||
|
Frame::Frame( const Frame& other )
|
||||||
{
|
{
|
||||||
addMarkup( markup->dup() );
|
mId = other.mId;
|
||||||
}
|
mNLabels = 0;
|
||||||
}
|
|
||||||
|
|
||||||
|
foreach ( Layout *layout, mLayouts )
|
||||||
QString Frame::id() const
|
|
||||||
{
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int Frame::nLabels() const
|
|
||||||
{
|
|
||||||
return mNLabels;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString Frame::layoutDescription() const
|
|
||||||
{
|
|
||||||
return mLayoutDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QList<Layout*>& Frame::layouts() const
|
|
||||||
{
|
|
||||||
return mLayouts;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QList<Markup*>& Frame::markups() const
|
|
||||||
{
|
|
||||||
return mMarkups;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QVector<Point> Frame::getOrigins() const
|
|
||||||
{
|
|
||||||
QVector<Point> origins( nLabels() );
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
foreach ( Layout *layout, mLayouts )
|
|
||||||
{
|
|
||||||
for ( int iy = 0; iy < layout->ny(); iy++ )
|
|
||||||
{
|
{
|
||||||
for ( int ix = 0; ix < layout->nx(); ix++ )
|
addLayout( layout->dup() );
|
||||||
{
|
}
|
||||||
origins[i++] = Point( ix*layout->dx() + layout->x0(), iy*layout->dy() + layout->y0() );
|
|
||||||
}
|
foreach ( Markup *markup, mMarkups )
|
||||||
|
{
|
||||||
|
addMarkup( markup->dup() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stable_sort( origins.begin(), origins.end() );
|
|
||||||
|
|
||||||
return origins;
|
QString Frame::id() const
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Frame::addLayout( Layout *layout )
|
|
||||||
{
|
|
||||||
mLayouts << layout;
|
|
||||||
|
|
||||||
// Update total number of labels
|
|
||||||
mNLabels += layout->nx() * layout->ny();
|
|
||||||
|
|
||||||
// Update layout description
|
|
||||||
if ( mLayouts.size() == 1 )
|
|
||||||
{
|
{
|
||||||
/*
|
return mId;
|
||||||
* Translators: %1 = number of labels across a page,
|
|
||||||
* %2 = number of labels down a page,
|
|
||||||
* %3 = total number of labels on a page (sheet).
|
|
||||||
*/
|
|
||||||
mLayoutDescription = QString( tr("%1 x %2 (%3 per sheet)") )
|
|
||||||
.arg(layout->nx()).arg(layout->ny()).arg(mNLabels);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
int Frame::nLabels() const
|
||||||
{
|
{
|
||||||
/* Translators: %1 is the total number of labels on a page (sheet). */
|
return mNLabels;
|
||||||
mLayoutDescription = QString( tr("%1 per sheet") ).arg(mNLabels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Frame::layoutDescription() const
|
||||||
|
{
|
||||||
|
return mLayoutDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QList<Layout*>& Frame::layouts() const
|
||||||
|
{
|
||||||
|
return mLayouts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QList<Markup*>& Frame::markups() const
|
||||||
|
{
|
||||||
|
return mMarkups;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVector<Point> Frame::getOrigins() const
|
||||||
|
{
|
||||||
|
QVector<Point> origins( nLabels() );
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
foreach ( Layout *layout, mLayouts )
|
||||||
|
{
|
||||||
|
for ( int iy = 0; iy < layout->ny(); iy++ )
|
||||||
|
{
|
||||||
|
for ( int ix = 0; ix < layout->nx(); ix++ )
|
||||||
|
{
|
||||||
|
origins[i++] = Point( ix*layout->dx() + layout->x0(), iy*layout->dy() + layout->y0() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::stable_sort( origins.begin(), origins.end() );
|
||||||
|
|
||||||
|
return origins;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Frame::addLayout( Layout *layout )
|
||||||
|
{
|
||||||
|
mLayouts << layout;
|
||||||
|
|
||||||
|
// Update total number of labels
|
||||||
|
mNLabels += layout->nx() * layout->ny();
|
||||||
|
|
||||||
|
// Update layout description
|
||||||
|
if ( mLayouts.size() == 1 )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Translators: %1 = number of labels across a page,
|
||||||
|
* %2 = number of labels down a page,
|
||||||
|
* %3 = total number of labels on a page (sheet).
|
||||||
|
*/
|
||||||
|
mLayoutDescription = QString( tr("%1 x %2 (%3 per sheet)") )
|
||||||
|
.arg(layout->nx()).arg(layout->ny()).arg(mNLabels);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Translators: %1 is the total number of labels on a page (sheet). */
|
||||||
|
mLayoutDescription = QString( tr("%1 per sheet") ).arg(mNLabels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Frame::addMarkup( Markup *markup )
|
||||||
|
{
|
||||||
|
mMarkups << markup;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Frame::addMarkup( Markup *markup )
|
|
||||||
{
|
|
||||||
mMarkups << markup;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+46
-43
@@ -33,55 +33,58 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
// Forward references
|
|
||||||
class Markup;
|
|
||||||
|
|
||||||
|
|
||||||
class Frame
|
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(Frame)
|
|
||||||
|
// Forward references
|
||||||
protected:
|
class Markup;
|
||||||
Frame( const QString& id = "0" );
|
|
||||||
Frame( const Frame& other );
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Frame* dup() const = 0;
|
|
||||||
|
|
||||||
QString id() const;
|
|
||||||
int nLabels() const;
|
|
||||||
QString layoutDescription() const;
|
|
||||||
const QList<Layout*>& layouts() const;
|
|
||||||
const QList<Markup*>& markups() const;
|
|
||||||
|
|
||||||
QVector<Point> getOrigins() const;
|
|
||||||
|
|
||||||
void addLayout( Layout* layout );
|
|
||||||
void addMarkup( Markup* markup );
|
|
||||||
|
|
||||||
virtual Distance w() const = 0;
|
|
||||||
virtual Distance h() const = 0;
|
|
||||||
|
|
||||||
virtual QString sizeDescription( const Units& units ) const = 0;
|
|
||||||
virtual bool isSimilarTo( Frame* other ) const = 0;
|
|
||||||
|
|
||||||
virtual const QPainterPath& path() const = 0;
|
|
||||||
virtual const QPainterPath& clipPath() const = 0;
|
|
||||||
virtual QPainterPath marginPath( const Distance& size ) const = 0;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
class Frame
|
||||||
QString mId;
|
{
|
||||||
int mNLabels;
|
Q_DECLARE_TR_FUNCTIONS(Frame)
|
||||||
QString mLayoutDescription;
|
|
||||||
|
|
||||||
QList<Layout*> mLayouts;
|
protected:
|
||||||
QList<Markup*> mMarkups;
|
Frame( const QString& id = "0" );
|
||||||
};
|
Frame( const Frame& other );
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual Frame* dup() const = 0;
|
||||||
|
|
||||||
|
QString id() const;
|
||||||
|
int nLabels() const;
|
||||||
|
QString layoutDescription() const;
|
||||||
|
const QList<Layout*>& layouts() const;
|
||||||
|
const QList<Markup*>& markups() const;
|
||||||
|
|
||||||
|
QVector<Point> getOrigins() const;
|
||||||
|
|
||||||
|
void addLayout( Layout* layout );
|
||||||
|
void addMarkup( Markup* markup );
|
||||||
|
|
||||||
|
virtual Distance w() const = 0;
|
||||||
|
virtual Distance h() const = 0;
|
||||||
|
|
||||||
|
virtual QString sizeDescription( const Units& units ) const = 0;
|
||||||
|
virtual bool isSimilarTo( Frame* other ) const = 0;
|
||||||
|
|
||||||
|
virtual const QPainterPath& path() const = 0;
|
||||||
|
virtual const QPainterPath& clipPath() const = 0;
|
||||||
|
virtual QPainterPath marginPath( const Distance& size ) const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mId;
|
||||||
|
int mNLabels;
|
||||||
|
QString mLayoutDescription;
|
||||||
|
|
||||||
|
QList<Layout*> mLayouts;
|
||||||
|
QList<Markup*> mMarkups;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+174
-171
@@ -26,24 +26,177 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
FrameCd::FrameCd( const Distance& r1,
|
|
||||||
const Distance& r2,
|
|
||||||
const Distance& w,
|
|
||||||
const Distance& h,
|
|
||||||
const Distance& waste,
|
|
||||||
const QString& id )
|
|
||||||
: Frame(id), mR1(r1), mR2(r2), mW(w), mH(h), mWaste(waste)
|
|
||||||
{
|
{
|
||||||
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
|
||||||
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
|
||||||
|
|
||||||
//
|
FrameCd::FrameCd( const Distance& r1,
|
||||||
// Create path
|
const Distance& r2,
|
||||||
//
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id )
|
||||||
|
: Frame(id), mR1(r1), mR2(r2), mW(w), mH(h), mWaste(waste)
|
||||||
{
|
{
|
||||||
|
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||||
|
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create path
|
||||||
|
//
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Construct outer subpath (may be clipped if it's a business card CD)
|
||||||
|
*/
|
||||||
|
QPainterPath outerPath;
|
||||||
|
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
|
||||||
|
|
||||||
|
QPainterPath clipPath;
|
||||||
|
clipPath.addRect( 0, 0, wReal.pt(), hReal.pt() );
|
||||||
|
|
||||||
|
mPath.addPath( outerPath & clipPath );
|
||||||
|
mPath.closeSubpath();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add inner subpath
|
||||||
|
*/
|
||||||
|
mPath.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create clip path
|
||||||
|
//
|
||||||
|
{
|
||||||
|
Distance r1Clip = mR1 + mWaste;
|
||||||
|
Distance r2Clip = mR2 - mWaste;
|
||||||
|
Distance wClip = (mW == 0) ? 2*r1Clip : mW + 2*mWaste;
|
||||||
|
Distance hClip = (mH == 0) ? 2*r1Clip : mH + 2*mWaste;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct outer subpath (may be clipped if it's a business card CD)
|
||||||
|
*/
|
||||||
|
QPainterPath outerPath;
|
||||||
|
outerPath.addEllipse( (wReal/2 - r1Clip).pt(), (hReal/2 - r1Clip).pt(), 2*r1Clip.pt(), 2*r1Clip.pt() );
|
||||||
|
|
||||||
|
QPainterPath clipPath;
|
||||||
|
clipPath.addRect( -mWaste.pt(), -mWaste.pt(), wClip.pt(), hClip.pt() );
|
||||||
|
|
||||||
|
mClipPath.addPath( outerPath & clipPath );
|
||||||
|
mClipPath.closeSubpath();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add inner subpath
|
||||||
|
*/
|
||||||
|
mClipPath.addEllipse( (wReal/2 - r2Clip).pt(), (hReal/2 - r2Clip).pt(), 2*r2Clip.pt(), 2*r2Clip.pt() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FrameCd::FrameCd( const FrameCd& other )
|
||||||
|
: Frame(other),
|
||||||
|
mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
||||||
|
mPath(other.mPath)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Frame* FrameCd::dup() const
|
||||||
|
{
|
||||||
|
return new FrameCd( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameCd::w() const
|
||||||
|
{
|
||||||
|
return (mW == 0) ? 2*mR1 : mW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameCd::h() const
|
||||||
|
{
|
||||||
|
return (mH == 0) ? 2*mR1 : mH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameCd::r1() const
|
||||||
|
{
|
||||||
|
return mR1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameCd::r2() const
|
||||||
|
{
|
||||||
|
return mR2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameCd::waste() const
|
||||||
|
{
|
||||||
|
return mWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString FrameCd::sizeDescription( const Units& units ) const
|
||||||
|
{
|
||||||
|
if ( units.toEnum() == Units::IN )
|
||||||
|
{
|
||||||
|
QString dStr = StrUtil::formatFraction( 2 * mR1.in() );
|
||||||
|
|
||||||
|
return QString().sprintf( "%s %s %s",
|
||||||
|
qPrintable(dStr),
|
||||||
|
qPrintable(units.toTrName()),
|
||||||
|
qPrintable(tr("diameter")) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QString().sprintf( "%.5g %s %s",
|
||||||
|
2 * mR1.inUnits(units),
|
||||||
|
qPrintable(units.toTrName()),
|
||||||
|
qPrintable(tr("diameter")) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FrameCd::isSimilarTo( Frame* other ) const
|
||||||
|
{
|
||||||
|
if ( FrameCd *otherCd = dynamic_cast<FrameCd*>(other) )
|
||||||
|
{
|
||||||
|
if ( (fabs( mW - otherCd->mW ) <= EPSILON) &&
|
||||||
|
(fabs( mH - otherCd->mH ) <= EPSILON) &&
|
||||||
|
(fabs( mR1 - otherCd->mR1 ) <= EPSILON) &&
|
||||||
|
(fabs( mR2 - otherCd->mR2 ) <= EPSILON) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameCd::path() const
|
||||||
|
{
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameCd::clipPath() const
|
||||||
|
{
|
||||||
|
return mClipPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPainterPath FrameCd::marginPath( const Distance& size ) const
|
||||||
|
{
|
||||||
|
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||||
|
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
||||||
|
|
||||||
|
Distance r1 = mR1 - size;
|
||||||
|
Distance r2 = mR2 + size;
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct outer subpath (may be clipped if it's a business card CD)
|
* Construct outer subpath (may be clipped if it's a business card CD)
|
||||||
*/
|
*/
|
||||||
@@ -51,168 +204,18 @@ namespace glabels::model
|
|||||||
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
|
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
|
||||||
|
|
||||||
QPainterPath clipPath;
|
QPainterPath clipPath;
|
||||||
clipPath.addRect( 0, 0, wReal.pt(), hReal.pt() );
|
clipPath.addRect( size.pt(), size.pt(), (wReal-2*size).pt(), (hReal-2*size).pt() );
|
||||||
|
|
||||||
mPath.addPath( outerPath & clipPath );
|
path.addPath( outerPath & clipPath );
|
||||||
mPath.closeSubpath();
|
path.closeSubpath();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add inner subpath
|
* Add inner subpath
|
||||||
*/
|
*/
|
||||||
mPath.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
|
path.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Create clip path
|
|
||||||
//
|
|
||||||
{
|
|
||||||
Distance r1Clip = mR1 + mWaste;
|
|
||||||
Distance r2Clip = mR2 - mWaste;
|
|
||||||
Distance wClip = (mW == 0) ? 2*r1Clip : mW + 2*mWaste;
|
|
||||||
Distance hClip = (mH == 0) ? 2*r1Clip : mH + 2*mWaste;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Construct outer subpath (may be clipped if it's a business card CD)
|
|
||||||
*/
|
|
||||||
QPainterPath outerPath;
|
|
||||||
outerPath.addEllipse( (wReal/2 - r1Clip).pt(), (hReal/2 - r1Clip).pt(), 2*r1Clip.pt(), 2*r1Clip.pt() );
|
|
||||||
|
|
||||||
QPainterPath clipPath;
|
|
||||||
clipPath.addRect( -mWaste.pt(), -mWaste.pt(), wClip.pt(), hClip.pt() );
|
|
||||||
|
|
||||||
mClipPath.addPath( outerPath & clipPath );
|
|
||||||
mClipPath.closeSubpath();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add inner subpath
|
|
||||||
*/
|
|
||||||
mClipPath.addEllipse( (wReal/2 - r2Clip).pt(), (hReal/2 - r2Clip).pt(), 2*r2Clip.pt(), 2*r2Clip.pt() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FrameCd::FrameCd( const FrameCd& other )
|
|
||||||
: Frame(other),
|
|
||||||
mR1(other.mR1), mR2(other.mR2), mW(other.mW), mH(other.mH), mWaste(other.mWaste),
|
|
||||||
mPath(other.mPath)
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Frame* FrameCd::dup() const
|
|
||||||
{
|
|
||||||
return new FrameCd( *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameCd::w() const
|
|
||||||
{
|
|
||||||
return (mW == 0) ? 2*mR1 : mW;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameCd::h() const
|
|
||||||
{
|
|
||||||
return (mH == 0) ? 2*mR1 : mH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameCd::r1() const
|
|
||||||
{
|
|
||||||
return mR1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameCd::r2() const
|
|
||||||
{
|
|
||||||
return mR2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameCd::waste() const
|
|
||||||
{
|
|
||||||
return mWaste;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString FrameCd::sizeDescription( const Units& units ) const
|
|
||||||
{
|
|
||||||
if ( units.toEnum() == Units::IN )
|
|
||||||
{
|
|
||||||
QString dStr = StrUtil::formatFraction( 2 * mR1.in() );
|
|
||||||
|
|
||||||
return QString().sprintf( "%s %s %s",
|
|
||||||
qPrintable(dStr),
|
|
||||||
qPrintable(units.toTrName()),
|
|
||||||
qPrintable(tr("diameter")) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return QString().sprintf( "%.5g %s %s",
|
|
||||||
2 * mR1.inUnits(units),
|
|
||||||
qPrintable(units.toTrName()),
|
|
||||||
qPrintable(tr("diameter")) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool FrameCd::isSimilarTo( Frame* other ) const
|
|
||||||
{
|
|
||||||
if ( FrameCd *otherCd = dynamic_cast<FrameCd*>(other) )
|
|
||||||
{
|
|
||||||
if ( (fabs( mW - otherCd->mW ) <= EPSILON) &&
|
|
||||||
(fabs( mH - otherCd->mH ) <= EPSILON) &&
|
|
||||||
(fabs( mR1 - otherCd->mR1 ) <= EPSILON) &&
|
|
||||||
(fabs( mR2 - otherCd->mR2 ) <= EPSILON) )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QPainterPath& FrameCd::path() const
|
|
||||||
{
|
|
||||||
return mPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QPainterPath& FrameCd::clipPath() const
|
|
||||||
{
|
|
||||||
return mClipPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameCd::marginPath( const Distance& size ) const
|
|
||||||
{
|
|
||||||
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
|
||||||
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
|
||||||
|
|
||||||
Distance r1 = mR1 - size;
|
|
||||||
Distance r2 = mR2 + size;
|
|
||||||
|
|
||||||
QPainterPath path;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Construct outer subpath (may be clipped if it's a business card CD)
|
|
||||||
*/
|
|
||||||
QPainterPath outerPath;
|
|
||||||
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
|
|
||||||
|
|
||||||
QPainterPath clipPath;
|
|
||||||
clipPath.addRect( size.pt(), size.pt(), (wReal-2*size).pt(), (hReal-2*size).pt() );
|
|
||||||
|
|
||||||
path.addPath( outerPath & clipPath );
|
|
||||||
path.closeSubpath();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add inner subpath
|
|
||||||
*/
|
|
||||||
path.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+35
-32
@@ -25,52 +25,55 @@
|
|||||||
#include "Frame.h"
|
#include "Frame.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class FrameCd : public Frame
|
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(FrameCd)
|
|
||||||
|
|
||||||
public:
|
class FrameCd : public Frame
|
||||||
FrameCd( const Distance& r1,
|
{
|
||||||
const Distance& r2,
|
Q_DECLARE_TR_FUNCTIONS(FrameCd)
|
||||||
const Distance& w,
|
|
||||||
const Distance& h,
|
|
||||||
const Distance& waste,
|
|
||||||
const QString& id = "0" );
|
|
||||||
|
|
||||||
FrameCd( const FrameCd &other );
|
public:
|
||||||
|
FrameCd( const Distance& r1,
|
||||||
|
const Distance& r2,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id = "0" );
|
||||||
|
|
||||||
Frame *dup() const override;
|
FrameCd( const FrameCd &other );
|
||||||
|
|
||||||
Distance r1() const;
|
Frame *dup() const override;
|
||||||
Distance r2() const;
|
|
||||||
Distance waste() const;
|
|
||||||
|
|
||||||
Distance w() const override;
|
Distance r1() const;
|
||||||
Distance h() const override;
|
Distance r2() const;
|
||||||
|
Distance waste() const;
|
||||||
|
|
||||||
QString sizeDescription( const Units& units ) const override;
|
Distance w() const override;
|
||||||
bool isSimilarTo( Frame* other ) const override;
|
Distance h() const override;
|
||||||
|
|
||||||
const QPainterPath& path() const override;
|
QString sizeDescription( const Units& units ) const override;
|
||||||
const QPainterPath& clipPath() const override;
|
bool isSimilarTo( Frame* other ) const override;
|
||||||
QPainterPath marginPath( const Distance& size ) const override;
|
|
||||||
|
const QPainterPath& path() const override;
|
||||||
|
const QPainterPath& clipPath() const override;
|
||||||
|
QPainterPath marginPath( const Distance& size ) const override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mR1;
|
Distance mR1;
|
||||||
Distance mR2;
|
Distance mR2;
|
||||||
Distance mW;
|
Distance mW;
|
||||||
Distance mH;
|
Distance mH;
|
||||||
Distance mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
QPainterPath mClipPath;
|
QPainterPath mClipPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+86
-82
@@ -24,107 +24,111 @@
|
|||||||
#include "StrUtil.h"
|
#include "StrUtil.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
FrameEllipse::FrameEllipse( const Distance& w,
|
|
||||||
const Distance& h,
|
|
||||||
const Distance& waste,
|
|
||||||
const QString& id )
|
|
||||||
: Frame(id), mW(w), mH(h), mWaste(waste)
|
|
||||||
{
|
{
|
||||||
mPath.addEllipse( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(), (mW+2*mWaste).pt(), (mH+2*mWaste).pt() );
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
FrameEllipse::FrameEllipse( const Distance& w,
|
||||||
: Frame(other), mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath)
|
const Distance& h,
|
||||||
{
|
const Distance& waste,
|
||||||
// empty
|
const QString& id )
|
||||||
}
|
: Frame(id), mW(w), mH(h), mWaste(waste)
|
||||||
|
|
||||||
|
|
||||||
Frame* FrameEllipse::dup() const
|
|
||||||
{
|
|
||||||
return new FrameEllipse( *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameEllipse::w() const
|
|
||||||
{
|
|
||||||
return mW;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameEllipse::h() const
|
|
||||||
{
|
|
||||||
return mH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameEllipse::waste() const
|
|
||||||
{
|
|
||||||
return mWaste;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString FrameEllipse::sizeDescription( const Units& units ) const
|
|
||||||
{
|
|
||||||
if ( units.toEnum() == Units::IN )
|
|
||||||
{
|
{
|
||||||
QString wStr = StrUtil::formatFraction( mW.in() );
|
mPath.addEllipse( 0, 0, mW.pt(), mH.pt() );
|
||||||
QString hStr = StrUtil::formatFraction( mH.in() );
|
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(), (mW+2*mWaste).pt(), (mH+2*mWaste).pt() );
|
||||||
|
|
||||||
return QString().sprintf( "%s x %s %s",
|
|
||||||
qPrintable(wStr),
|
|
||||||
qPrintable(hStr),
|
|
||||||
qPrintable(units.toTrName()) );
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
FrameEllipse::FrameEllipse( const FrameEllipse& other )
|
||||||
|
: Frame(other), mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath)
|
||||||
{
|
{
|
||||||
return QString().sprintf( "%.5g x %.5g %s",
|
// empty
|
||||||
mW.inUnits(units),
|
|
||||||
mH.inUnits(units),
|
|
||||||
qPrintable(units.toTrName()) );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool FrameEllipse::isSimilarTo( Frame* other ) const
|
Frame* FrameEllipse::dup() const
|
||||||
{
|
|
||||||
if ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
|
||||||
{
|
{
|
||||||
if ( (fabs( mW - otherEllipse->mW ) <= EPSILON) &&
|
return new FrameEllipse( *this );
|
||||||
(fabs( mH - otherEllipse->mH ) <= EPSILON) )
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameEllipse::w() const
|
||||||
|
{
|
||||||
|
return mW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameEllipse::h() const
|
||||||
|
{
|
||||||
|
return mH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameEllipse::waste() const
|
||||||
|
{
|
||||||
|
return mWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString FrameEllipse::sizeDescription( const Units& units ) const
|
||||||
|
{
|
||||||
|
if ( units.toEnum() == Units::IN )
|
||||||
{
|
{
|
||||||
return true;
|
QString wStr = StrUtil::formatFraction( mW.in() );
|
||||||
|
QString hStr = StrUtil::formatFraction( mH.in() );
|
||||||
|
|
||||||
|
return QString().sprintf( "%s x %s %s",
|
||||||
|
qPrintable(wStr),
|
||||||
|
qPrintable(hStr),
|
||||||
|
qPrintable(units.toTrName()) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QString().sprintf( "%.5g x %.5g %s",
|
||||||
|
mW.inUnits(units),
|
||||||
|
mH.inUnits(units),
|
||||||
|
qPrintable(units.toTrName()) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QPainterPath& FrameEllipse::path() const
|
bool FrameEllipse::isSimilarTo( Frame* other ) const
|
||||||
{
|
{
|
||||||
return mPath;
|
if ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
||||||
}
|
{
|
||||||
|
if ( (fabs( mW - otherEllipse->mW ) <= EPSILON) &&
|
||||||
|
(fabs( mH - otherEllipse->mH ) <= EPSILON) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameEllipse::path() const
|
||||||
|
{
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const QPainterPath& FrameEllipse::clipPath() const
|
const QPainterPath& FrameEllipse::clipPath() const
|
||||||
{
|
{
|
||||||
return mClipPath;
|
return mClipPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameEllipse::marginPath( const Distance& size ) const
|
QPainterPath FrameEllipse::marginPath( const Distance& size ) const
|
||||||
{
|
{
|
||||||
Distance w = mW - 2*size;
|
Distance w = mW - 2*size;
|
||||||
Distance h = mH - 2*size;
|
Distance h = mH - 2*size;
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addEllipse( size.pt(), size.pt(), w.pt(), h.pt() );
|
path.addEllipse( size.pt(), size.pt(), w.pt(), h.pt() );
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+29
-26
@@ -25,46 +25,49 @@
|
|||||||
#include "Frame.h"
|
#include "Frame.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class FrameEllipse : public Frame
|
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(FrameEllipse)
|
|
||||||
|
class FrameEllipse : public Frame
|
||||||
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(FrameEllipse)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FrameEllipse( const Distance& w,
|
FrameEllipse( const Distance& w,
|
||||||
const Distance& h,
|
const Distance& h,
|
||||||
const Distance& waste,
|
const Distance& waste,
|
||||||
const QString& id = "0" );
|
const QString& id = "0" );
|
||||||
|
|
||||||
FrameEllipse( const FrameEllipse& other );
|
FrameEllipse( const FrameEllipse& other );
|
||||||
|
|
||||||
Frame* dup() const override;
|
Frame* dup() const override;
|
||||||
|
|
||||||
Distance waste() const;
|
Distance waste() const;
|
||||||
|
|
||||||
Distance w() const override;
|
Distance w() const override;
|
||||||
Distance h() const override;
|
Distance h() const override;
|
||||||
|
|
||||||
QString sizeDescription( const Units& units ) const override;
|
QString sizeDescription( const Units& units ) const override;
|
||||||
bool isSimilarTo( Frame* other ) const override;
|
bool isSimilarTo( Frame* other ) const override;
|
||||||
|
|
||||||
const QPainterPath& path() const override;
|
const QPainterPath& path() const override;
|
||||||
const QPainterPath& clipPath() const override;
|
const QPainterPath& clipPath() const override;
|
||||||
QPainterPath marginPath( const Distance& size ) const override;
|
QPainterPath marginPath( const Distance& size ) const override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mW;
|
Distance mW;
|
||||||
Distance mH;
|
Distance mH;
|
||||||
Distance mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
QPainterPath mClipPath;
|
QPainterPath mClipPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+116
-113
@@ -24,129 +24,132 @@
|
|||||||
#include "StrUtil.h"
|
#include "StrUtil.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
FrameRect::FrameRect( const Distance& w,
|
|
||||||
const Distance& h,
|
|
||||||
const Distance& r,
|
|
||||||
const Distance& xWaste,
|
|
||||||
const Distance& yWaste,
|
|
||||||
const QString& id )
|
|
||||||
: Frame(id), mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste)
|
|
||||||
{
|
{
|
||||||
mPath.addRoundedRect( 0, 0, mW.pt(), mH.pt(), mR.pt(), mR.pt() );
|
|
||||||
|
|
||||||
mClipPath.addRoundedRect( -mXWaste.pt(), -mYWaste.pt(),
|
|
||||||
mW.pt() + 2*mXWaste.pt(), mH.pt() + 2*mYWaste.pt(),
|
|
||||||
mR.pt(), mR.pt() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
FrameRect::FrameRect( const Distance& w,
|
||||||
FrameRect::FrameRect( const FrameRect &other )
|
const Distance& h,
|
||||||
: Frame(other),
|
const Distance& r,
|
||||||
mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
|
const Distance& xWaste,
|
||||||
mYWaste(other.mYWaste), mPath(other.mPath)
|
const Distance& yWaste,
|
||||||
{
|
const QString& id )
|
||||||
// empty
|
: Frame(id), mW(w), mH(h), mR(r), mXWaste(xWaste), mYWaste(yWaste)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Frame* FrameRect::dup() const
|
|
||||||
{
|
|
||||||
return new FrameRect( *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRect::w() const
|
|
||||||
{
|
|
||||||
return mW;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRect::h() const
|
|
||||||
{
|
|
||||||
return mH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRect::r() const
|
|
||||||
{
|
|
||||||
return mR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRect::xWaste() const
|
|
||||||
{
|
|
||||||
return mXWaste;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRect::yWaste() const
|
|
||||||
{
|
|
||||||
return mYWaste;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString FrameRect::sizeDescription( const Units& units ) const
|
|
||||||
{
|
|
||||||
if ( units.toEnum() == Units::IN )
|
|
||||||
{
|
{
|
||||||
QString wStr = StrUtil::formatFraction( mW.in() );
|
mPath.addRoundedRect( 0, 0, mW.pt(), mH.pt(), mR.pt(), mR.pt() );
|
||||||
QString hStr = StrUtil::formatFraction( mH.in() );
|
|
||||||
|
mClipPath.addRoundedRect( -mXWaste.pt(), -mYWaste.pt(),
|
||||||
return QString().sprintf( "%s x %s %s",
|
mW.pt() + 2*mXWaste.pt(), mH.pt() + 2*mYWaste.pt(),
|
||||||
qPrintable(wStr),
|
mR.pt(), mR.pt() );
|
||||||
qPrintable(hStr),
|
|
||||||
qPrintable(units.toTrName()) );
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
FrameRect::FrameRect( const FrameRect &other )
|
||||||
|
: Frame(other),
|
||||||
|
mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
|
||||||
|
mYWaste(other.mYWaste), mPath(other.mPath)
|
||||||
{
|
{
|
||||||
return QString().sprintf( "%.5g x %.5g %s",
|
// empty
|
||||||
mW.inUnits(units),
|
|
||||||
mH.inUnits(units),
|
|
||||||
qPrintable(units.toTrName()) );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool FrameRect::isSimilarTo( Frame* other ) const
|
Frame* FrameRect::dup() const
|
||||||
{
|
|
||||||
if ( FrameRect *otherRect = dynamic_cast<FrameRect*>(other) )
|
|
||||||
{
|
{
|
||||||
if ( (fabs( mW - otherRect->mW ) <= EPSILON) &&
|
return new FrameRect( *this );
|
||||||
(fabs( mH - otherRect->mH ) <= EPSILON) )
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRect::w() const
|
||||||
|
{
|
||||||
|
return mW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRect::h() const
|
||||||
|
{
|
||||||
|
return mH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRect::r() const
|
||||||
|
{
|
||||||
|
return mR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRect::xWaste() const
|
||||||
|
{
|
||||||
|
return mXWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRect::yWaste() const
|
||||||
|
{
|
||||||
|
return mYWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString FrameRect::sizeDescription( const Units& units ) const
|
||||||
|
{
|
||||||
|
if ( units.toEnum() == Units::IN )
|
||||||
{
|
{
|
||||||
return true;
|
QString wStr = StrUtil::formatFraction( mW.in() );
|
||||||
|
QString hStr = StrUtil::formatFraction( mH.in() );
|
||||||
|
|
||||||
|
return QString().sprintf( "%s x %s %s",
|
||||||
|
qPrintable(wStr),
|
||||||
|
qPrintable(hStr),
|
||||||
|
qPrintable(units.toTrName()) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QString().sprintf( "%.5g x %.5g %s",
|
||||||
|
mW.inUnits(units),
|
||||||
|
mH.inUnits(units),
|
||||||
|
qPrintable(units.toTrName()) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
|
bool FrameRect::isSimilarTo( Frame* other ) const
|
||||||
|
{
|
||||||
|
if ( FrameRect *otherRect = dynamic_cast<FrameRect*>(other) )
|
||||||
|
{
|
||||||
|
if ( (fabs( mW - otherRect->mW ) <= EPSILON) &&
|
||||||
|
(fabs( mH - otherRect->mH ) <= EPSILON) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameRect::path() const
|
||||||
|
{
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameRect::clipPath() const
|
||||||
|
{
|
||||||
|
return mClipPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPainterPath FrameRect::marginPath( const Distance& size ) const
|
||||||
|
{
|
||||||
|
Distance w = mW - 2*size;
|
||||||
|
Distance h = mH - 2*size;
|
||||||
|
Distance r = std::max( mR - size, Distance(0.0) );
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
path.addRoundedRect( size.pt(), size.pt(), w.pt(), h.pt(), r.pt(), r.pt() );
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const QPainterPath& FrameRect::path() const
|
|
||||||
{
|
|
||||||
return mPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QPainterPath& FrameRect::clipPath() const
|
|
||||||
{
|
|
||||||
return mClipPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameRect::marginPath( const Distance& size ) const
|
|
||||||
{
|
|
||||||
Distance w = mW - 2*size;
|
|
||||||
Distance h = mH - 2*size;
|
|
||||||
Distance r = std::max( mR - size, Distance(0.0) );
|
|
||||||
|
|
||||||
QPainterPath path;
|
|
||||||
path.addRoundedRect( size.pt(), size.pt(), w.pt(), h.pt(), r.pt(), r.pt() );
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+35
-32
@@ -25,53 +25,56 @@
|
|||||||
#include "Frame.h"
|
#include "Frame.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class FrameRect : public Frame
|
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(FrameRect)
|
|
||||||
|
|
||||||
public:
|
class FrameRect : public Frame
|
||||||
FrameRect( const Distance& w,
|
{
|
||||||
const Distance& h,
|
Q_DECLARE_TR_FUNCTIONS(FrameRect)
|
||||||
const Distance& r,
|
|
||||||
const Distance& xWaste,
|
|
||||||
const Distance& yWaste,
|
|
||||||
const QString& id = "0" );
|
|
||||||
|
|
||||||
FrameRect( const FrameRect& other );
|
public:
|
||||||
|
FrameRect( const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& r,
|
||||||
|
const Distance& xWaste,
|
||||||
|
const Distance& yWaste,
|
||||||
|
const QString& id = "0" );
|
||||||
|
|
||||||
Frame* dup() const override;
|
FrameRect( const FrameRect& other );
|
||||||
|
|
||||||
Distance r() const;
|
Frame* dup() const override;
|
||||||
Distance xWaste() const;
|
|
||||||
Distance yWaste() const;
|
|
||||||
|
|
||||||
Distance w() const override;
|
Distance r() const;
|
||||||
Distance h() const override;
|
Distance xWaste() const;
|
||||||
|
Distance yWaste() const;
|
||||||
|
|
||||||
QString sizeDescription( const Units& units ) const override;
|
Distance w() const override;
|
||||||
|
Distance h() const override;
|
||||||
|
|
||||||
bool isSimilarTo( Frame* other ) const override;
|
QString sizeDescription( const Units& units ) const override;
|
||||||
|
|
||||||
const QPainterPath& path() const override;
|
bool isSimilarTo( Frame* other ) const override;
|
||||||
const QPainterPath& clipPath() const override;
|
|
||||||
QPainterPath marginPath( const Distance& size ) const override;
|
const QPainterPath& path() const override;
|
||||||
|
const QPainterPath& clipPath() const override;
|
||||||
|
QPainterPath marginPath( const Distance& size ) const override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mW;
|
Distance mW;
|
||||||
Distance mH;
|
Distance mH;
|
||||||
Distance mR;
|
Distance mR;
|
||||||
Distance mXWaste;
|
Distance mXWaste;
|
||||||
Distance mYWaste;
|
Distance mYWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
QPainterPath mClipPath;
|
QPainterPath mClipPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+98
-95
@@ -24,111 +24,114 @@
|
|||||||
#include "StrUtil.h"
|
#include "StrUtil.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
FrameRound::FrameRound( const Distance& r,
|
|
||||||
const Distance& waste,
|
|
||||||
const QString& id )
|
|
||||||
: Frame(id), mR(r), mWaste(waste)
|
|
||||||
{
|
{
|
||||||
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
|
|
||||||
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(),
|
|
||||||
2*(mR+mWaste).pt(), 2*(mR+mWaste).pt() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FrameRound::FrameRound( const FrameRound& other )
|
FrameRound::FrameRound( const Distance& r,
|
||||||
: Frame(other), mR(other.mR), mWaste(other.mWaste), mPath(other.mPath)
|
const Distance& waste,
|
||||||
{
|
const QString& id )
|
||||||
// empty
|
: Frame(id), mR(r), mWaste(waste)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Frame* FrameRound::dup() const
|
|
||||||
{
|
|
||||||
return new FrameRound( *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRound::w() const
|
|
||||||
{
|
|
||||||
return 2*mR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRound::h() const
|
|
||||||
{
|
|
||||||
return 2*mR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRound::r() const
|
|
||||||
{
|
|
||||||
return mR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Distance FrameRound::waste() const
|
|
||||||
{
|
|
||||||
return mWaste;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString FrameRound::sizeDescription( const Units& units ) const
|
|
||||||
{
|
|
||||||
if ( units.toEnum() == Units::IN )
|
|
||||||
{
|
{
|
||||||
QString dStr = StrUtil::formatFraction( 2 * mR.in() );
|
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
|
||||||
|
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(),
|
||||||
return QString().sprintf( "%s %s %s",
|
2*(mR+mWaste).pt(), 2*(mR+mWaste).pt() );
|
||||||
qPrintable(dStr),
|
|
||||||
qPrintable(units.toTrName()),
|
|
||||||
qPrintable(tr("diameter")) );
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
FrameRound::FrameRound( const FrameRound& other )
|
||||||
|
: Frame(other), mR(other.mR), mWaste(other.mWaste), mPath(other.mPath)
|
||||||
{
|
{
|
||||||
return QString().sprintf( "%.5g %s %s",
|
// empty
|
||||||
2 * mR.inUnits(units),
|
|
||||||
qPrintable(units.toTrName()),
|
|
||||||
qPrintable(tr("diameter")) );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Frame* FrameRound::dup() const
|
||||||
bool FrameRound::isSimilarTo( Frame* other ) const
|
|
||||||
{
|
|
||||||
if ( FrameRound *otherRound = dynamic_cast<FrameRound*>(other) )
|
|
||||||
{
|
{
|
||||||
if ( fabs( mR - otherRound->mR ) <= EPSILON )
|
return new FrameRound( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRound::w() const
|
||||||
|
{
|
||||||
|
return 2*mR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRound::h() const
|
||||||
|
{
|
||||||
|
return 2*mR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRound::r() const
|
||||||
|
{
|
||||||
|
return mR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance FrameRound::waste() const
|
||||||
|
{
|
||||||
|
return mWaste;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString FrameRound::sizeDescription( const Units& units ) const
|
||||||
|
{
|
||||||
|
if ( units.toEnum() == Units::IN )
|
||||||
{
|
{
|
||||||
return true;
|
QString dStr = StrUtil::formatFraction( 2 * mR.in() );
|
||||||
|
|
||||||
|
return QString().sprintf( "%s %s %s",
|
||||||
|
qPrintable(dStr),
|
||||||
|
qPrintable(units.toTrName()),
|
||||||
|
qPrintable(tr("diameter")) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QString().sprintf( "%.5g %s %s",
|
||||||
|
2 * mR.inUnits(units),
|
||||||
|
qPrintable(units.toTrName()),
|
||||||
|
qPrintable(tr("diameter")) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
|
bool FrameRound::isSimilarTo( Frame* other ) const
|
||||||
|
{
|
||||||
|
if ( FrameRound *otherRound = dynamic_cast<FrameRound*>(other) )
|
||||||
|
{
|
||||||
|
if ( fabs( mR - otherRound->mR ) <= EPSILON )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameRound::path() const
|
||||||
|
{
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPainterPath& FrameRound::clipPath() const
|
||||||
|
{
|
||||||
|
return mClipPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPainterPath FrameRound::marginPath( const Distance& size ) const
|
||||||
|
{
|
||||||
|
Distance r = mR - size;
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
path.addEllipse( size.pt(), size.pt(), 2*r.pt(), 2*r.pt() );
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const QPainterPath& FrameRound::path() const
|
|
||||||
{
|
|
||||||
return mPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QPainterPath& FrameRound::clipPath() const
|
|
||||||
{
|
|
||||||
return mClipPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QPainterPath FrameRound::marginPath( const Distance& size ) const
|
|
||||||
{
|
|
||||||
Distance r = mR - size;
|
|
||||||
|
|
||||||
QPainterPath path;
|
|
||||||
path.addEllipse( size.pt(), size.pt(), 2*r.pt(), 2*r.pt() );
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+28
-25
@@ -25,45 +25,48 @@
|
|||||||
#include "Frame.h"
|
#include "Frame.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class FrameRound : public Frame
|
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(FrameRound)
|
|
||||||
|
|
||||||
public:
|
class FrameRound : public Frame
|
||||||
FrameRound( const Distance& r,
|
{
|
||||||
const Distance& waste,
|
Q_DECLARE_TR_FUNCTIONS(FrameRound)
|
||||||
const QString& id = "0" );
|
|
||||||
|
|
||||||
FrameRound( const FrameRound &other );
|
public:
|
||||||
|
FrameRound( const Distance& r,
|
||||||
|
const Distance& waste,
|
||||||
|
const QString& id = "0" );
|
||||||
|
|
||||||
Frame *dup() const override;
|
FrameRound( const FrameRound &other );
|
||||||
|
|
||||||
Distance r() const;
|
Frame *dup() const override;
|
||||||
Distance waste() const;
|
|
||||||
|
|
||||||
Distance w() const override;
|
Distance r() const;
|
||||||
Distance h() const override;
|
Distance waste() const;
|
||||||
|
|
||||||
QString sizeDescription( const Units& units ) const override;
|
Distance w() const override;
|
||||||
bool isSimilarTo( Frame* other ) const override;
|
Distance h() const override;
|
||||||
|
|
||||||
const QPainterPath& path() const override;
|
QString sizeDescription( const Units& units ) const override;
|
||||||
const QPainterPath& clipPath() const override;
|
bool isSimilarTo( Frame* other ) const override;
|
||||||
QPainterPath marginPath( const Distance& size ) const override;
|
|
||||||
|
const QPainterPath& path() const override;
|
||||||
|
const QPainterPath& clipPath() const override;
|
||||||
|
QPainterPath marginPath( const Distance& size ) const override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mR;
|
Distance mR;
|
||||||
Distance mWaste;
|
Distance mWaste;
|
||||||
|
|
||||||
QPainterPath mPath;
|
QPainterPath mPath;
|
||||||
QPainterPath mClipPath;
|
QPainterPath mClipPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+538
-535
File diff suppressed because it is too large
Load Diff
+251
-248
@@ -28,308 +28,311 @@
|
|||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
// Forward References
|
|
||||||
class ModelObject;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Handle Base Class
|
|
||||||
///
|
|
||||||
class Handle
|
|
||||||
{
|
{
|
||||||
////////////////////////////
|
|
||||||
// Location enumeration
|
// Forward References
|
||||||
////////////////////////////
|
class ModelObject;
|
||||||
public:
|
|
||||||
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
|
||||||
// Lifecycle Methods
|
|
||||||
////////////////////////////
|
|
||||||
protected:
|
|
||||||
Handle( ModelObject* owner, Location location );
|
|
||||||
public:
|
|
||||||
virtual ~Handle();
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
///
|
||||||
// Duplication
|
/// Handle Base Class
|
||||||
////////////////////////////
|
///
|
||||||
virtual Handle* clone( ModelObject* newOwner ) const = 0;
|
class Handle
|
||||||
|
{
|
||||||
|
////////////////////////////
|
||||||
|
// Location enumeration
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
enum Location { NW, N, NE, E, SE, S, SW, W, P1, P2 };
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
protected:
|
||||||
|
Handle( ModelObject* owner, Location location );
|
||||||
|
public:
|
||||||
|
virtual ~Handle();
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// Duplication
|
||||||
|
////////////////////////////
|
||||||
|
virtual Handle* clone( ModelObject* newOwner ) const = 0;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Attribue Methods
|
// Attribue Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
ModelObject* owner() const;
|
ModelObject* owner() const;
|
||||||
Location location() const;
|
Location location() const;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual void draw( QPainter* painter, double scale ) const = 0;
|
virtual void draw( QPainter* painter, double scale ) const = 0;
|
||||||
virtual QPainterPath path( double scale ) const = 0;
|
virtual QPainterPath path( double scale ) const = 0;
|
||||||
protected:
|
protected:
|
||||||
void drawAt( QPainter* painter,
|
void drawAt( QPainter* painter,
|
||||||
double scale,
|
double scale,
|
||||||
const Distance& x,
|
const Distance& x,
|
||||||
const Distance& y,
|
const Distance& y,
|
||||||
QColor color ) const;
|
QColor color ) const;
|
||||||
|
|
||||||
QPainterPath pathAt( double scale,
|
QPainterPath pathAt( double scale,
|
||||||
const Distance& x,
|
const Distance& x,
|
||||||
const Distance& y ) const;
|
const Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Protected Data
|
// Protected Data
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
ModelObject* mOwner;
|
ModelObject* mOwner;
|
||||||
Location mLocation;
|
Location mLocation;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorth Class
|
/// HandleNorth Class
|
||||||
///
|
///
|
||||||
class HandleNorth : public Handle
|
class HandleNorth : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleNorth( ModelObject* owner );
|
HandleNorth( ModelObject* owner );
|
||||||
~HandleNorth() override;
|
~HandleNorth() override;
|
||||||
HandleNorth* clone( ModelObject* newOwner ) const override;
|
HandleNorth* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthEast Class
|
/// HandleNorthEast Class
|
||||||
///
|
///
|
||||||
class HandleNorthEast : public Handle
|
class HandleNorthEast : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleNorthEast( ModelObject* owner );
|
HandleNorthEast( ModelObject* owner );
|
||||||
~HandleNorthEast() override;
|
~HandleNorthEast() override;
|
||||||
HandleNorthEast* clone( ModelObject* newOwner ) const override;
|
HandleNorthEast* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleEast Class
|
/// HandleEast Class
|
||||||
///
|
///
|
||||||
class HandleEast : public Handle
|
class HandleEast : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleEast( ModelObject* owner );
|
HandleEast( ModelObject* owner );
|
||||||
~HandleEast() override;
|
~HandleEast() override;
|
||||||
HandleEast* clone( ModelObject* newOwner ) const override;
|
HandleEast* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthEast Class
|
/// HandleSouthEast Class
|
||||||
///
|
///
|
||||||
class HandleSouthEast : public Handle
|
class HandleSouthEast : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleSouthEast( ModelObject* owner );
|
HandleSouthEast( ModelObject* owner );
|
||||||
~HandleSouthEast() override;
|
~HandleSouthEast() override;
|
||||||
HandleSouthEast* clone( ModelObject* newOwner ) const override;
|
HandleSouthEast* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouth Class
|
/// HandleSouth Class
|
||||||
///
|
///
|
||||||
class HandleSouth : public Handle
|
class HandleSouth : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleSouth( ModelObject* owner );
|
HandleSouth( ModelObject* owner );
|
||||||
~HandleSouth() override;
|
~HandleSouth() override;
|
||||||
HandleSouth* clone( ModelObject* newOwner ) const override;
|
HandleSouth* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleSouthWest Class
|
/// HandleSouthWest Class
|
||||||
///
|
///
|
||||||
class HandleSouthWest : public Handle
|
class HandleSouthWest : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleSouthWest( ModelObject* owner );
|
HandleSouthWest( ModelObject* owner );
|
||||||
~HandleSouthWest() override;
|
~HandleSouthWest() override;
|
||||||
HandleSouthWest* clone( ModelObject* newOwner ) const override;
|
HandleSouthWest* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleWest Class
|
/// HandleWest Class
|
||||||
///
|
///
|
||||||
class HandleWest : public Handle
|
class HandleWest : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleWest( ModelObject* owner );
|
HandleWest( ModelObject* owner );
|
||||||
~HandleWest() override;
|
~HandleWest() override;
|
||||||
HandleWest* clone( ModelObject* newOwner ) const override;
|
HandleWest* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleNorthWest Class
|
/// HandleNorthWest Class
|
||||||
///
|
///
|
||||||
class HandleNorthWest : public Handle
|
class HandleNorthWest : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleNorthWest( ModelObject* owner );
|
HandleNorthWest( ModelObject* owner );
|
||||||
~HandleNorthWest() override;
|
~HandleNorthWest() override;
|
||||||
HandleNorthWest* clone( ModelObject* newOwner ) const override;
|
HandleNorthWest* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP1 Class
|
/// HandleP1 Class
|
||||||
///
|
///
|
||||||
class HandleP1 : public Handle
|
class HandleP1 : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleP1( ModelObject* owner );
|
HandleP1( ModelObject* owner );
|
||||||
~HandleP1() override;
|
~HandleP1() override;
|
||||||
HandleP1* clone( ModelObject* newOwner ) const override;
|
HandleP1* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// HandleP2 Class
|
/// HandleP2 Class
|
||||||
///
|
///
|
||||||
class HandleP2 : public Handle
|
class HandleP2 : public Handle
|
||||||
{
|
{
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Lifecycle Methods
|
// Lifecycle Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
HandleP2( ModelObject* owner );
|
HandleP2( ModelObject* owner );
|
||||||
~HandleP2() override;
|
~HandleP2() override;
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Duplication
|
// Duplication
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
HandleP2* clone( ModelObject* newOwner ) const override;
|
HandleP2* clone( ModelObject* newOwner ) const override;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, double scale ) const override;
|
void draw( QPainter* painter, double scale ) const override;
|
||||||
QPainterPath path( double scale ) const override;
|
QPainterPath path( double scale ) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+63
-60
@@ -25,80 +25,83 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
Layout::Layout( int nx,
|
|
||||||
int ny,
|
|
||||||
const Distance& x0,
|
|
||||||
const Distance& y0,
|
|
||||||
const Distance& dx,
|
|
||||||
const Distance& dy )
|
|
||||||
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
}
|
Layout::Layout( int nx,
|
||||||
|
int ny,
|
||||||
|
const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& dx,
|
||||||
|
const Distance& dy )
|
||||||
|
: mNx(nx), mNy(ny), mX0(x0), mY0(y0), mDx(dx), mDy(dy)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Layout::Layout( const Layout& other )
|
Layout::Layout( const Layout& other )
|
||||||
: 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
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Layout::nx() const
|
int Layout::nx() const
|
||||||
{
|
{
|
||||||
return mNx;
|
return mNx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Layout::ny() const
|
int Layout::ny() const
|
||||||
{
|
{
|
||||||
return mNy;
|
return mNy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance Layout::x0() const
|
Distance Layout::x0() const
|
||||||
{
|
{
|
||||||
return mX0;
|
return mX0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance Layout::y0() const
|
Distance Layout::y0() const
|
||||||
{
|
{
|
||||||
return mY0;
|
return mY0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance Layout::dx() const
|
Distance Layout::dx() const
|
||||||
{
|
{
|
||||||
return mDx;
|
return mDx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance Layout::dy() const
|
Distance Layout::dy() const
|
||||||
{
|
{
|
||||||
return mDy;
|
return mDy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Layout::isSimilarTo( const Layout *other )
|
||||||
|
{
|
||||||
|
return ( (mNx == other->mNx) &&
|
||||||
|
(mNy == other->mNy) &&
|
||||||
|
(fabs(mX0 - other->mX0) < EPSILON) &&
|
||||||
|
(fabs(mY0 - other->mY0) < EPSILON) &&
|
||||||
|
(fabs(mDx - other->mDx) < EPSILON) &&
|
||||||
|
(fabs(mDy - other->mDy) < EPSILON) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Layout* Layout::dup() const
|
||||||
|
{
|
||||||
|
Layout *other = new Layout( *this );
|
||||||
|
return other;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Layout::isSimilarTo( const Layout *other )
|
|
||||||
{
|
|
||||||
return ( (mNx == other->mNx) &&
|
|
||||||
(mNy == other->mNy) &&
|
|
||||||
(fabs(mX0 - other->mX0) < EPSILON) &&
|
|
||||||
(fabs(mY0 - other->mY0) < EPSILON) &&
|
|
||||||
(fabs(mDx - other->mDx) < EPSILON) &&
|
|
||||||
(fabs(mDy - other->mDy) < EPSILON) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Layout* Layout::dup() const
|
|
||||||
{
|
|
||||||
Layout *other = new Layout( *this );
|
|
||||||
return other;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+30
-27
@@ -25,46 +25,49 @@
|
|||||||
#include "Distance.h"
|
#include "Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class Layout
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Layout
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Layout( int nx,
|
Layout( int nx,
|
||||||
int ny,
|
int ny,
|
||||||
const Distance& x0,
|
const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& dx,
|
const Distance& dx,
|
||||||
const Distance& dy );
|
const Distance& dy );
|
||||||
|
|
||||||
Layout( const Layout &other );
|
Layout( const Layout &other );
|
||||||
|
|
||||||
int nx() const;
|
int nx() const;
|
||||||
int ny() const;
|
int ny() const;
|
||||||
|
|
||||||
Distance x0() const;
|
Distance x0() const;
|
||||||
Distance y0() const;
|
Distance y0() const;
|
||||||
|
|
||||||
Distance dx() const;
|
Distance dx() const;
|
||||||
Distance dy() const;
|
Distance dy() const;
|
||||||
|
|
||||||
bool isSimilarTo( const Layout *other );
|
bool isSimilarTo( const Layout *other );
|
||||||
|
|
||||||
Layout* dup() const;
|
Layout* dup() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mNx;
|
int mNx;
|
||||||
int mNy;
|
int mNy;
|
||||||
Distance mX0;
|
Distance mX0;
|
||||||
Distance mY0;
|
Distance mY0;
|
||||||
Distance mDx;
|
Distance mDx;
|
||||||
Distance mDy;
|
Distance mDy;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+136
-133
@@ -21,192 +21,195 @@
|
|||||||
#include "Markup.h"
|
#include "Markup.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
const QPainterPath& Markup::path() const
|
|
||||||
{
|
{
|
||||||
return mPath;
|
|
||||||
}
|
const QPainterPath& Markup::path() const
|
||||||
|
{
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupMargin::MarkupMargin( const Frame* frame,
|
MarkupMargin::MarkupMargin( const Frame* frame,
|
||||||
const Distance& size )
|
const Distance& size )
|
||||||
: mFrame(frame), mSize(size)
|
: mFrame(frame), mSize(size)
|
||||||
{
|
{
|
||||||
mPath = frame->marginPath( size );
|
mPath = frame->marginPath( size );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Markup* MarkupMargin::dup() const
|
Markup* MarkupMargin::dup() const
|
||||||
{
|
{
|
||||||
return new MarkupMargin( mFrame, mSize );
|
return new MarkupMargin( mFrame, mSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupMargin::size() const
|
Distance MarkupMargin::size() const
|
||||||
{
|
{
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupLine::MarkupLine( const Distance& x1,
|
MarkupLine::MarkupLine( const Distance& x1,
|
||||||
const Distance& y1,
|
const Distance& y1,
|
||||||
const Distance& x2,
|
const Distance& x2,
|
||||||
const Distance& y2 )
|
const Distance& y2 )
|
||||||
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
||||||
{
|
{
|
||||||
mPath.moveTo( x1.pt(), y1.pt() );
|
mPath.moveTo( x1.pt(), y1.pt() );
|
||||||
mPath.lineTo( x2.pt(), y2.pt() );
|
mPath.lineTo( x2.pt(), y2.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Markup* MarkupLine::dup() const
|
Markup* MarkupLine::dup() const
|
||||||
{
|
{
|
||||||
return new MarkupLine( mX1, mY1, mX2, mY2 );
|
return new MarkupLine( mX1, mY1, mX2, mY2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupLine::x1() const
|
Distance MarkupLine::x1() const
|
||||||
{
|
{
|
||||||
return mX1;
|
return mX1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupLine::y1() const
|
Distance MarkupLine::y1() const
|
||||||
{
|
{
|
||||||
return mY1;
|
return mY1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupLine::x2() const
|
Distance MarkupLine::x2() const
|
||||||
{
|
{
|
||||||
return mX2;
|
return mX2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupLine::y2() const
|
Distance MarkupLine::y2() const
|
||||||
{
|
{
|
||||||
return mY2;
|
return mY2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupRect::MarkupRect( const Distance& x1,
|
MarkupRect::MarkupRect( const Distance& x1,
|
||||||
const Distance& y1,
|
const Distance& y1,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h,
|
const Distance& h,
|
||||||
const Distance& r )
|
const Distance& r )
|
||||||
: mX1(x1), mY1(y1), mW(w), mH(h), mR(r)
|
: mX1(x1), mY1(y1), mW(w), mH(h), mR(r)
|
||||||
{
|
{
|
||||||
mPath.addRoundedRect( x1.pt(), y1.pt(), w.pt(), h.pt(), r.pt(), r.pt() );
|
mPath.addRoundedRect( x1.pt(), y1.pt(), w.pt(), h.pt(), r.pt(), r.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Markup* MarkupRect::dup() const
|
Markup* MarkupRect::dup() const
|
||||||
{
|
{
|
||||||
return new MarkupRect( mX1, mY1, mW, mH, mR );
|
return new MarkupRect( mX1, mY1, mW, mH, mR );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupRect::x1() const
|
Distance MarkupRect::x1() const
|
||||||
{
|
{
|
||||||
return mX1;
|
return mX1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupRect::y1() const
|
Distance MarkupRect::y1() const
|
||||||
{
|
{
|
||||||
return mY1;
|
return mY1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupRect::w() const
|
Distance MarkupRect::w() const
|
||||||
{
|
{
|
||||||
return mW;
|
return mW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupRect::h() const
|
Distance MarkupRect::h() const
|
||||||
{
|
{
|
||||||
return mH;
|
return mH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupRect::r() const
|
Distance MarkupRect::r() const
|
||||||
{
|
{
|
||||||
return mR;
|
return mR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupEllipse::MarkupEllipse( const Distance& x1,
|
MarkupEllipse::MarkupEllipse( const Distance& x1,
|
||||||
const Distance& y1,
|
const Distance& y1,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h )
|
const Distance& h )
|
||||||
: mX1(x1), mY1(y1), mW(w), mH(h)
|
: mX1(x1), mY1(y1), mW(w), mH(h)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( x1.pt(), y1.pt(), w.pt(), h.pt() );
|
mPath.addEllipse( x1.pt(), y1.pt(), w.pt(), h.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Markup* MarkupEllipse::dup() const
|
Markup* MarkupEllipse::dup() const
|
||||||
{
|
{
|
||||||
return new MarkupEllipse( mX1, mY1, mW, mH );
|
return new MarkupEllipse( mX1, mY1, mW, mH );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupEllipse::x1() const
|
Distance MarkupEllipse::x1() const
|
||||||
{
|
{
|
||||||
return mX1;
|
return mX1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupEllipse::y1() const
|
Distance MarkupEllipse::y1() const
|
||||||
{
|
{
|
||||||
return mY1;
|
return mY1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupEllipse::w() const
|
Distance MarkupEllipse::w() const
|
||||||
{
|
{
|
||||||
return mW;
|
return mW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupEllipse::h() const
|
Distance MarkupEllipse::h() const
|
||||||
{
|
{
|
||||||
return mH;
|
return mH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MarkupCircle::MarkupCircle( const Distance& x0,
|
MarkupCircle::MarkupCircle( const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& r )
|
const Distance& r )
|
||||||
: mX0(x0), mY0(y0), mR(r)
|
: mX0(x0), mY0(y0), mR(r)
|
||||||
{
|
{
|
||||||
mPath.addEllipse( (x0-r).pt(), (y0-r).pt(), 2*r.pt(), 2*r.pt() );
|
mPath.addEllipse( (x0-r).pt(), (y0-r).pt(), 2*r.pt(), 2*r.pt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
Markup* MarkupCircle::dup() const
|
Markup* MarkupCircle::dup() const
|
||||||
{
|
{
|
||||||
return new MarkupCircle( mX0, mY0, mR );
|
return new MarkupCircle( mX0, mY0, mR );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupCircle::x0() const
|
Distance MarkupCircle::x0() const
|
||||||
{
|
{
|
||||||
return mX0;
|
return mX0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupCircle::y0() const
|
Distance MarkupCircle::y0() const
|
||||||
{
|
{
|
||||||
return mY0;
|
return mY0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance MarkupCircle::r() const
|
Distance MarkupCircle::r() const
|
||||||
{
|
{
|
||||||
return mR;
|
return mR;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::model
|
}
|
||||||
|
}
|
||||||
|
|||||||
+95
-92
@@ -27,129 +27,132 @@
|
|||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class Markup
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
virtual Markup* dup() const = 0;
|
|
||||||
|
|
||||||
const QPainterPath& path() const;
|
class Markup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual Markup* dup() const = 0;
|
||||||
|
|
||||||
protected:
|
const QPainterPath& path() const;
|
||||||
QPainterPath mPath;
|
|
||||||
};
|
protected:
|
||||||
|
QPainterPath mPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupMargin : public Markup
|
class MarkupMargin : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupMargin( const Frame* frame,
|
MarkupMargin( const Frame* frame,
|
||||||
const Distance& size );
|
const Distance& size );
|
||||||
|
|
||||||
Distance size() const;
|
Distance size() const;
|
||||||
|
|
||||||
Markup* dup() const override;
|
Markup* dup() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Frame* mFrame;
|
const Frame* mFrame;
|
||||||
Distance mSize;
|
Distance mSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupLine : public Markup
|
class MarkupLine : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupLine( const Distance& x1,
|
MarkupLine( const Distance& x1,
|
||||||
const Distance& y1,
|
const Distance& y1,
|
||||||
const Distance& x2,
|
const Distance& x2,
|
||||||
const Distance& y2 );
|
const Distance& y2 );
|
||||||
|
|
||||||
Distance x1() const;
|
Distance x1() const;
|
||||||
Distance y1() const;
|
Distance y1() const;
|
||||||
Distance x2() const;
|
Distance x2() const;
|
||||||
Distance y2() const;
|
Distance y2() const;
|
||||||
|
|
||||||
Markup* dup() const override;
|
Markup* dup() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mX1;
|
Distance mX1;
|
||||||
Distance mY1;
|
Distance mY1;
|
||||||
Distance mX2;
|
Distance mX2;
|
||||||
Distance mY2;
|
Distance mY2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupRect : public Markup
|
class MarkupRect : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupRect( const Distance& x1,
|
MarkupRect( const Distance& x1,
|
||||||
const Distance& y1,
|
const Distance& y1,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h,
|
const Distance& h,
|
||||||
const Distance& r );
|
const Distance& r );
|
||||||
|
|
||||||
Distance x1() const;
|
Distance x1() const;
|
||||||
Distance y1() const;
|
Distance y1() const;
|
||||||
Distance w() const;
|
Distance w() const;
|
||||||
Distance h() const;
|
Distance h() const;
|
||||||
Distance r() const;
|
Distance r() const;
|
||||||
|
|
||||||
Markup* dup() const override;
|
Markup* dup() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mX1;
|
Distance mX1;
|
||||||
Distance mY1;
|
Distance mY1;
|
||||||
Distance mW;
|
Distance mW;
|
||||||
Distance mH;
|
Distance mH;
|
||||||
Distance mR;
|
Distance mR;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupEllipse : public Markup
|
class MarkupEllipse : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupEllipse( const Distance& x1,
|
MarkupEllipse( const Distance& x1,
|
||||||
const Distance& y1,
|
const Distance& y1,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h );
|
const Distance& h );
|
||||||
|
|
||||||
Distance x1() const;
|
Distance x1() const;
|
||||||
Distance y1() const;
|
Distance y1() const;
|
||||||
Distance w() const;
|
Distance w() const;
|
||||||
Distance h() const;
|
Distance h() const;
|
||||||
|
|
||||||
Markup* dup() const override;
|
Markup* dup() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mX1;
|
Distance mX1;
|
||||||
Distance mY1;
|
Distance mY1;
|
||||||
Distance mW;
|
Distance mW;
|
||||||
Distance mH;
|
Distance mH;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupCircle : public Markup
|
class MarkupCircle : public Markup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkupCircle( const Distance& x0,
|
MarkupCircle( const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& r );
|
const Distance& r );
|
||||||
|
|
||||||
Distance x0() const;
|
Distance x0() const;
|
||||||
Distance y0() const;
|
Distance y0() const;
|
||||||
Distance r() const;
|
Distance r() const;
|
||||||
|
|
||||||
Markup* dup() const override;
|
Markup* dup() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mX0;
|
Distance mX0;
|
||||||
Distance mY0;
|
Distance mY0;
|
||||||
Distance mR;
|
Distance mR;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1266
-1263
File diff suppressed because it is too large
Load Diff
+164
-161
@@ -33,206 +33,209 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
// Forward References
|
|
||||||
class ColorNode;
|
|
||||||
class Handle;
|
|
||||||
class ModelObject;
|
|
||||||
class Region;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Model
|
|
||||||
///
|
|
||||||
class Model : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
// Forward References
|
||||||
|
class ColorNode;
|
||||||
|
class Handle;
|
||||||
|
class ModelObject;
|
||||||
|
class Region;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Model
|
||||||
|
///
|
||||||
|
class Model : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
Model();
|
Model();
|
||||||
~Model() override {}
|
~Model() override {}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Save/restore model state
|
// Save/restore model state
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
Model* save() const;
|
Model* save() const;
|
||||||
void restore( const Model *savedModel );
|
void restore( const Model *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 Template* tmplate() const;
|
const Template* tmplate() const;
|
||||||
const Frame* frame() const;
|
const Frame* frame() const;
|
||||||
void setTmplate( const Template* tmplate );
|
void setTmplate( const Template* tmplate );
|
||||||
|
|
||||||
bool rotate() const;
|
bool rotate() const;
|
||||||
void setRotate( bool rotate );
|
void setRotate( bool rotate );
|
||||||
|
|
||||||
Distance w() const;
|
Distance w() const;
|
||||||
Distance h() const;
|
Distance h() const;
|
||||||
|
|
||||||
const QList<ModelObject*>& objectList() const;
|
const QList<ModelObject*>& 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( ModelObject* object );
|
void addObject( ModelObject* object );
|
||||||
void deleteObject( ModelObject* object );
|
void deleteObject( ModelObject* object );
|
||||||
|
|
||||||
ModelObject* objectAt( double scale,
|
ModelObject* objectAt( double scale,
|
||||||
const Distance& x,
|
const Distance& x,
|
||||||
const Distance& y ) const;
|
const Distance& y ) const;
|
||||||
|
|
||||||
Handle* handleAt( double scale,
|
Handle* handleAt( double scale,
|
||||||
const Distance& x,
|
const Distance& x,
|
||||||
const Distance& y ) const;
|
const Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Manipulate selection
|
// Manipulate selection
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void selectObject( ModelObject* object );
|
void selectObject( ModelObject* object );
|
||||||
void unselectObject( ModelObject* object );
|
void unselectObject( ModelObject* 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<ModelObject*> getSelection();
|
QList<ModelObject*> getSelection();
|
||||||
ModelObject* getFirstSelectedObject();
|
ModelObject* 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 Distance& dx, const 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 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 = nullptr ) const;
|
void draw( QPainter* painter, bool inEditor = true, merge::Record* record = nullptr ) 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 Template* mTmplate;
|
const Template* mTmplate;
|
||||||
const Frame* mFrame;
|
const Frame* mFrame;
|
||||||
bool mRotate;
|
bool mRotate;
|
||||||
|
|
||||||
QList<ModelObject*> mObjectList;
|
QList<ModelObject*> mObjectList;
|
||||||
|
|
||||||
merge::Merge* mMerge;
|
merge::Merge* mMerge;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+445
-442
@@ -35,497 +35,500 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
//
|
|
||||||
// Private
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
const QColor fillColor = QColor( 224, 224, 224, 255 );
|
|
||||||
const Distance pad = Distance::pt(4);
|
//
|
||||||
const Distance minW = Distance::pt(18);
|
// Private
|
||||||
const Distance minH = Distance::pt(18);
|
//
|
||||||
}
|
namespace
|
||||||
|
{
|
||||||
|
const QColor fillColor = QColor( 224, 224, 224, 255 );
|
||||||
|
const Distance pad = Distance::pt(4);
|
||||||
|
const Distance minW = Distance::pt(18);
|
||||||
|
const Distance minH = Distance::pt(18);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
ModelBarcodeObject::ModelBarcodeObject()
|
ModelBarcodeObject::ModelBarcodeObject()
|
||||||
{
|
{
|
||||||
mOutline = new Outline( this );
|
mOutline = new Outline( this );
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
mHandles << new HandleNorthWest( this );
|
||||||
mHandles << new HandleNorth( this );
|
mHandles << new HandleNorth( this );
|
||||||
mHandles << new HandleNorthEast( this );
|
mHandles << new HandleNorthEast( this );
|
||||||
mHandles << new HandleEast( this );
|
mHandles << new HandleEast( this );
|
||||||
mHandles << new HandleSouthEast( this );
|
mHandles << new HandleSouthEast( this );
|
||||||
mHandles << new HandleSouth( this );
|
mHandles << new HandleSouth( this );
|
||||||
mHandles << new HandleSouthWest( this );
|
mHandles << new HandleSouthWest( this );
|
||||||
mHandles << new HandleWest( this );
|
mHandles << new HandleWest( this );
|
||||||
|
|
||||||
mBcStyle = barcode::Backends::defaultStyle();
|
mBcStyle = barcode::Backends::defaultStyle();
|
||||||
mBcTextFlag = mBcStyle.canText();
|
mBcTextFlag = mBcStyle.canText();
|
||||||
mBcChecksumFlag = mBcStyle.canChecksum();
|
mBcChecksumFlag = mBcStyle.canChecksum();
|
||||||
mBcFormatDigits = mBcStyle.preferedN();
|
mBcFormatDigits = mBcStyle.preferedN();
|
||||||
mBcData = "";
|
mBcData = "";
|
||||||
mBcColorNode = ColorNode( Qt::black );
|
mBcColorNode = ColorNode( Qt::black );
|
||||||
|
|
||||||
mEditorBarcode = nullptr;
|
mEditorBarcode = nullptr;
|
||||||
mEditorDefaultBarcode = nullptr;
|
mEditorDefaultBarcode = nullptr;
|
||||||
|
|
||||||
update(); // Initialize cached editor layouts
|
update(); // Initialize cached editor layouts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
ModelBarcodeObject::ModelBarcodeObject( const Distance& x0,
|
ModelBarcodeObject::ModelBarcodeObject( const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h,
|
const Distance& h,
|
||||||
const barcode::Style& bcStyle,
|
const barcode::Style& bcStyle,
|
||||||
bool bcTextFlag,
|
bool bcTextFlag,
|
||||||
bool bcChecksumFlag,
|
bool bcChecksumFlag,
|
||||||
QString bcData,
|
QString bcData,
|
||||||
const ColorNode& bcColorNode,
|
const ColorNode& bcColorNode,
|
||||||
const QMatrix& matrix )
|
const QMatrix& matrix )
|
||||||
: ModelObject( x0, y0, w, h, matrix )
|
: ModelObject( x0, y0, w, h, matrix )
|
||||||
{
|
{
|
||||||
mOutline = new Outline( this );
|
mOutline = new Outline( this );
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
mHandles << new HandleNorthWest( this );
|
||||||
mHandles << new HandleNorth( this );
|
mHandles << new HandleNorth( this );
|
||||||
mHandles << new HandleNorthEast( this );
|
mHandles << new HandleNorthEast( this );
|
||||||
mHandles << new HandleEast( this );
|
mHandles << new HandleEast( this );
|
||||||
mHandles << new HandleSouthEast( this );
|
mHandles << new HandleSouthEast( this );
|
||||||
mHandles << new HandleSouth( this );
|
mHandles << new HandleSouth( this );
|
||||||
mHandles << new HandleSouthWest( this );
|
mHandles << new HandleSouthWest( this );
|
||||||
mHandles << new HandleWest( this );
|
mHandles << new HandleWest( this );
|
||||||
|
|
||||||
mBcStyle = bcStyle;
|
mBcStyle = bcStyle;
|
||||||
mBcTextFlag = bcTextFlag;
|
mBcTextFlag = bcTextFlag;
|
||||||
mBcChecksumFlag = bcChecksumFlag;
|
mBcChecksumFlag = bcChecksumFlag;
|
||||||
mBcData = bcData;
|
mBcData = bcData;
|
||||||
mBcColorNode = bcColorNode;
|
mBcColorNode = bcColorNode;
|
||||||
|
|
||||||
mEditorBarcode = nullptr;
|
mEditorBarcode = nullptr;
|
||||||
mEditorDefaultBarcode = nullptr;
|
mEditorDefaultBarcode = nullptr;
|
||||||
|
|
||||||
update(); // Initialize cached editor layouts
|
update(); // Initialize cached editor layouts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
ModelBarcodeObject::ModelBarcodeObject( const ModelBarcodeObject* object )
|
ModelBarcodeObject::ModelBarcodeObject( const ModelBarcodeObject* object )
|
||||||
: ModelObject(object)
|
: ModelObject(object)
|
||||||
{
|
|
||||||
mBcStyle = object->mBcStyle;
|
|
||||||
mBcTextFlag = object->mBcTextFlag;
|
|
||||||
mBcChecksumFlag = object->mBcChecksumFlag;
|
|
||||||
mBcFormatDigits = object->mBcFormatDigits;
|
|
||||||
mBcData = object->mBcData;
|
|
||||||
mBcColorNode = object->mBcColorNode;
|
|
||||||
|
|
||||||
mEditorBarcode = nullptr;
|
|
||||||
mEditorDefaultBarcode = nullptr;
|
|
||||||
|
|
||||||
update(); // Initialize cached editor layouts
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
ModelBarcodeObject::~ModelBarcodeObject()
|
|
||||||
{
|
|
||||||
delete mOutline;
|
|
||||||
|
|
||||||
foreach( Handle* handle, mHandles )
|
|
||||||
{
|
{
|
||||||
delete handle;
|
mBcStyle = object->mBcStyle;
|
||||||
|
mBcTextFlag = object->mBcTextFlag;
|
||||||
|
mBcChecksumFlag = object->mBcChecksumFlag;
|
||||||
|
mBcFormatDigits = object->mBcFormatDigits;
|
||||||
|
mBcData = object->mBcData;
|
||||||
|
mBcColorNode = object->mBcColorNode;
|
||||||
|
|
||||||
|
mEditorBarcode = nullptr;
|
||||||
|
mEditorDefaultBarcode = nullptr;
|
||||||
|
|
||||||
|
update(); // Initialize cached editor layouts
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
|
||||||
|
|
||||||
delete mEditorBarcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
ModelBarcodeObject* ModelBarcodeObject::clone() const
|
ModelBarcodeObject::~ModelBarcodeObject()
|
||||||
{
|
|
||||||
return new ModelBarcodeObject( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// bcData Property Getter
|
|
||||||
///
|
|
||||||
QString ModelBarcodeObject::bcData() const
|
|
||||||
{
|
|
||||||
return mBcData.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// bcData Property Setter
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::setBcData( const QString& value )
|
|
||||||
{
|
|
||||||
if ( mBcData.toString() != value )
|
|
||||||
{
|
{
|
||||||
mBcData = value;
|
delete mOutline;
|
||||||
update();
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
foreach( Handle* handle, mHandles )
|
||||||
|
{
|
||||||
|
delete handle;
|
||||||
|
}
|
||||||
|
mHandles.clear();
|
||||||
|
|
||||||
///
|
|
||||||
/// bcTextFlag Property Getter
|
|
||||||
///
|
|
||||||
bool ModelBarcodeObject::bcTextFlag() const
|
|
||||||
{
|
|
||||||
return mBcTextFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// bcTextFlag Property Setter
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::setBcTextFlag( bool value )
|
|
||||||
{
|
|
||||||
if ( mBcTextFlag != value )
|
|
||||||
{
|
|
||||||
mBcTextFlag = value;
|
|
||||||
update();
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// bcChecksumFlag Property Getter
|
|
||||||
///
|
|
||||||
bool ModelBarcodeObject::bcChecksumFlag() const
|
|
||||||
{
|
|
||||||
return mBcChecksumFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// bcChecksumFlag Property Setter
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::setBcChecksumFlag( bool value )
|
|
||||||
{
|
|
||||||
if ( mBcChecksumFlag != value )
|
|
||||||
{
|
|
||||||
mBcChecksumFlag = value;
|
|
||||||
update();
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Color Node Property Getter
|
|
||||||
///
|
|
||||||
ColorNode ModelBarcodeObject::bcColorNode() const
|
|
||||||
{
|
|
||||||
return mBcColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Color Node Property Setter
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::setBcColorNode( const ColorNode& value )
|
|
||||||
{
|
|
||||||
if ( mBcColorNode != value )
|
|
||||||
{
|
|
||||||
mBcColorNode = value;
|
|
||||||
update();
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Style Property Getter
|
|
||||||
///
|
|
||||||
barcode::Style ModelBarcodeObject::bcStyle() const
|
|
||||||
{
|
|
||||||
return mBcStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Style Property Setter
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::setBcStyle( const barcode::Style& value )
|
|
||||||
{
|
|
||||||
if ( mBcStyle != value )
|
|
||||||
{
|
|
||||||
mBcStyle = value;
|
|
||||||
update();
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Format Digits Property Getter
|
|
||||||
///
|
|
||||||
int ModelBarcodeObject::bcFormatDigits() const
|
|
||||||
{
|
|
||||||
return mBcFormatDigits;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Format Digits Property Setter
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::setBcFormatDigits( int value )
|
|
||||||
{
|
|
||||||
if ( mBcFormatDigits != value )
|
|
||||||
{
|
|
||||||
mBcFormatDigits = value;
|
|
||||||
update();
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw shadow of object
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::drawShadow( QPainter* painter,
|
|
||||||
bool inEditor,
|
|
||||||
merge::Record* record ) const
|
|
||||||
{
|
|
||||||
// Barcodes don't support shadows.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw object itself
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::drawObject( QPainter* painter,
|
|
||||||
bool inEditor,
|
|
||||||
merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QColor bcColor = mBcColorNode.color( record );
|
|
||||||
|
|
||||||
if ( inEditor )
|
|
||||||
{
|
|
||||||
drawBcInEditor( painter, bcColor );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
drawBc( painter, bcColor, record );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Path to test for hover condition
|
|
||||||
///
|
|
||||||
QPainterPath ModelBarcodeObject::hoverPath( double scale ) const
|
|
||||||
{
|
|
||||||
return mHoverPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Size updated
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::sizeUpdated()
|
|
||||||
{
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Update cached information for editor view
|
|
||||||
///
|
|
||||||
void ModelBarcodeObject::update()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Build barcode from data
|
|
||||||
//
|
|
||||||
if ( mEditorBarcode )
|
|
||||||
{
|
|
||||||
delete mEditorBarcode;
|
delete mEditorBarcode;
|
||||||
}
|
}
|
||||||
mEditorBarcode = glbarcode::Factory::createBarcode( mBcStyle.fullId().toStdString() );
|
|
||||||
if ( !mEditorBarcode )
|
|
||||||
{
|
|
||||||
qWarning() << "Invalid barcode style" << mBcStyle.fullId() << "using \"code39\".";
|
|
||||||
mBcStyle = barcode::Backends::defaultStyle();
|
|
||||||
mEditorBarcode = glbarcode::Factory::createBarcode( mBcStyle.id().toStdString() );
|
|
||||||
}
|
|
||||||
mEditorBarcode->setChecksum(mBcChecksumFlag);
|
|
||||||
mEditorBarcode->setShowText(mBcTextFlag);
|
|
||||||
|
|
||||||
mEditorBarcode->build( mBcData.toStdString(), mW.pt(), mH.pt() );
|
|
||||||
|
|
||||||
//
|
///
|
||||||
// Build a place holder barcode to display in editor, if cannot display actual barcode
|
/// Clone
|
||||||
//
|
///
|
||||||
if ( mEditorDefaultBarcode )
|
ModelBarcodeObject* ModelBarcodeObject::clone() const
|
||||||
{
|
{
|
||||||
delete mEditorDefaultBarcode;
|
return new ModelBarcodeObject( this );
|
||||||
}
|
|
||||||
mEditorDefaultBarcode = glbarcode::Factory::createBarcode( mBcStyle.fullId().toStdString() );
|
|
||||||
if ( !mEditorDefaultBarcode )
|
|
||||||
{
|
|
||||||
qWarning() << "Invalid barcode style" << mBcStyle.fullId() << "using \"code39\".";
|
|
||||||
mBcStyle = barcode::Backends::defaultStyle();
|
|
||||||
mEditorDefaultBarcode = glbarcode::Factory::createBarcode( mBcStyle.id().toStdString() );
|
|
||||||
}
|
|
||||||
mEditorDefaultBarcode->setChecksum(mBcChecksumFlag);
|
|
||||||
mEditorDefaultBarcode->setShowText(mBcTextFlag);
|
|
||||||
|
|
||||||
mEditorDefaultBarcode->build( mBcStyle.defaultDigits().toStdString(), mW.pt(), mH.pt() );
|
|
||||||
|
|
||||||
//
|
|
||||||
// Adjust size
|
|
||||||
//
|
|
||||||
if ( mEditorBarcode->isDataValid() )
|
|
||||||
{
|
|
||||||
mW = Distance::pt( mEditorBarcode->width() );
|
|
||||||
mH = Distance::pt( mEditorBarcode->height() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mW = Distance::pt( mEditorDefaultBarcode->width() );
|
|
||||||
mH = Distance::pt( mEditorDefaultBarcode->height() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath path;
|
|
||||||
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
mHoverPath = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// bcData Property Getter
|
||||||
/// Draw barcode in editor from cached information
|
///
|
||||||
///
|
QString ModelBarcodeObject::bcData() const
|
||||||
void ModelBarcodeObject::drawBcInEditor( QPainter* painter, const QColor& color ) const
|
|
||||||
{
|
|
||||||
if ( mBcData.isEmpty() )
|
|
||||||
{
|
{
|
||||||
drawPlaceHolder( painter, color, tr("No barcode data") );
|
return mBcData.toString();
|
||||||
}
|
}
|
||||||
else if ( mBcData.hasPlaceHolders() )
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// bcData Property Setter
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::setBcData( const QString& value )
|
||||||
{
|
{
|
||||||
drawPlaceHolder( painter, color, mBcData.toString() );
|
if ( mBcData.toString() != value )
|
||||||
|
{
|
||||||
|
mBcData = value;
|
||||||
|
update();
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( mEditorBarcode->isDataValid() )
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// bcTextFlag Property Getter
|
||||||
|
///
|
||||||
|
bool ModelBarcodeObject::bcTextFlag() const
|
||||||
{
|
{
|
||||||
painter->setPen( QPen( color ) );
|
return mBcTextFlag;
|
||||||
glbarcode::QtRenderer renderer(painter);
|
|
||||||
mEditorBarcode->render( renderer );
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// bcTextFlag Property Setter
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::setBcTextFlag( bool value )
|
||||||
{
|
{
|
||||||
drawPlaceHolder( painter, color, tr("Invalid barcode data") );
|
if ( mBcTextFlag != value )
|
||||||
|
{
|
||||||
|
mBcTextFlag = value;
|
||||||
|
update();
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw barcode in final printout or preview
|
/// bcChecksumFlag Property Getter
|
||||||
///
|
///
|
||||||
void
|
bool ModelBarcodeObject::bcChecksumFlag() const
|
||||||
ModelBarcodeObject::drawBc( QPainter* painter,
|
{
|
||||||
const QColor& color,
|
return mBcChecksumFlag;
|
||||||
merge::Record* record ) const
|
}
|
||||||
{
|
|
||||||
painter->setPen( QPen( color ) );
|
|
||||||
|
|
||||||
glbarcode::Barcode* bc = glbarcode::Factory::createBarcode( mBcStyle.fullId().toStdString() );
|
|
||||||
bc->setChecksum(mBcChecksumFlag);
|
|
||||||
bc->setShowText(mBcTextFlag);
|
|
||||||
|
|
||||||
bc->build( mBcData.toStdString(), mW.pt(), mH.pt() );
|
|
||||||
|
|
||||||
glbarcode::QtRenderer renderer(painter);
|
|
||||||
bc->render( renderer );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw barcode place holder in editor
|
/// bcChecksumFlag Property Setter
|
||||||
///
|
///
|
||||||
void
|
void ModelBarcodeObject::setBcChecksumFlag( bool value )
|
||||||
ModelBarcodeObject::drawPlaceHolder( QPainter* painter,
|
{
|
||||||
const QColor& color,
|
if ( mBcChecksumFlag != value )
|
||||||
const QString& text ) const
|
{
|
||||||
{
|
mBcChecksumFlag = value;
|
||||||
QString shortText = text.left( 32 ); // Don't let the text get out of hand
|
update();
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Color Node Property Getter
|
||||||
|
///
|
||||||
|
ColorNode ModelBarcodeObject::bcColorNode() const
|
||||||
|
{
|
||||||
|
return mBcColorNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Color Node Property Setter
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::setBcColorNode( const ColorNode& value )
|
||||||
|
{
|
||||||
|
if ( mBcColorNode != value )
|
||||||
|
{
|
||||||
|
mBcColorNode = value;
|
||||||
|
update();
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Render box
|
|
||||||
//
|
|
||||||
painter->setPen( Qt::NoPen );
|
|
||||||
painter->setBrush( QBrush( fillColor ) );
|
|
||||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
|
||||||
|
|
||||||
//
|
///
|
||||||
// Render default barcode
|
/// Barcode Style Property Getter
|
||||||
//
|
///
|
||||||
painter->setPen( QPen( color ) );
|
barcode::Style ModelBarcodeObject::bcStyle() const
|
||||||
glbarcode::QtRenderer renderer(painter);
|
|
||||||
mEditorDefaultBarcode->render( renderer );
|
|
||||||
|
|
||||||
//
|
|
||||||
// Determine font size for text
|
|
||||||
//
|
|
||||||
QFont font( "Sans" );
|
|
||||||
font.setPointSizeF( 6 );
|
|
||||||
|
|
||||||
QFontMetricsF fm( font );
|
|
||||||
QRectF textRect = fm.boundingRect( shortText );
|
|
||||||
|
|
||||||
double wPts = (mW - 2*pad).pt();
|
|
||||||
double hPts = (mH - 2*pad).pt();
|
|
||||||
if ( (wPts < textRect.width()) || (hPts < textRect.height()) )
|
|
||||||
{
|
{
|
||||||
double scaleX = wPts / textRect.width();
|
return mBcStyle;
|
||||||
double scaleY = hPts / textRect.height();
|
|
||||||
font.setPointSizeF( 6 * std::min( scaleX, scaleY ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Render hole for text (font size may have changed above)
|
|
||||||
//
|
|
||||||
fm = QFontMetricsF( font );
|
|
||||||
textRect = fm.boundingRect( shortText );
|
|
||||||
|
|
||||||
QRectF holeRect( (mW.pt() - textRect.width())/2 - pad.pt(),
|
|
||||||
(mH.pt() - textRect.height())/2 - pad.pt(),
|
|
||||||
textRect.width() + 2*pad.pt(),
|
|
||||||
textRect.height() + 2*pad.pt() );
|
|
||||||
|
|
||||||
painter->setPen( Qt::NoPen );
|
///
|
||||||
painter->setBrush( QBrush( fillColor ) );
|
/// Barcode Style Property Setter
|
||||||
painter->drawRect( holeRect );
|
///
|
||||||
|
void ModelBarcodeObject::setBcStyle( const barcode::Style& value )
|
||||||
|
{
|
||||||
|
if ( mBcStyle != value )
|
||||||
|
{
|
||||||
|
mBcStyle = value;
|
||||||
|
update();
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Render text
|
///
|
||||||
//
|
/// Barcode Format Digits Property Getter
|
||||||
painter->setFont( font );
|
///
|
||||||
painter->setPen( QPen( color ) );
|
int ModelBarcodeObject::bcFormatDigits() const
|
||||||
painter->drawText( QRectF( 0, 0, mW.pt(), mH.pt() ), Qt::AlignCenter, shortText );
|
{
|
||||||
}
|
return mBcFormatDigits;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Format Digits Property Setter
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::setBcFormatDigits( int value )
|
||||||
|
{
|
||||||
|
if ( mBcFormatDigits != value )
|
||||||
|
{
|
||||||
|
mBcFormatDigits = value;
|
||||||
|
update();
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw shadow of object
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::drawShadow( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record ) const
|
||||||
|
{
|
||||||
|
// Barcodes don't support shadows.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
///
|
||||||
|
/// Draw object itself
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::drawObject( QPainter* painter,
|
||||||
|
bool inEditor,
|
||||||
|
merge::Record* record ) const
|
||||||
|
{
|
||||||
|
QColor bcColor = mBcColorNode.color( record );
|
||||||
|
|
||||||
|
if ( inEditor )
|
||||||
|
{
|
||||||
|
drawBcInEditor( painter, bcColor );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drawBc( painter, bcColor, record );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Path to test for hover condition
|
||||||
|
///
|
||||||
|
QPainterPath ModelBarcodeObject::hoverPath( double scale ) const
|
||||||
|
{
|
||||||
|
return mHoverPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Size updated
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::sizeUpdated()
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Update cached information for editor view
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::update()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Build barcode from data
|
||||||
|
//
|
||||||
|
if ( mEditorBarcode )
|
||||||
|
{
|
||||||
|
delete mEditorBarcode;
|
||||||
|
}
|
||||||
|
mEditorBarcode = glbarcode::Factory::createBarcode( mBcStyle.fullId().toStdString() );
|
||||||
|
if ( !mEditorBarcode )
|
||||||
|
{
|
||||||
|
qWarning() << "Invalid barcode style" << mBcStyle.fullId() << "using \"code39\".";
|
||||||
|
mBcStyle = barcode::Backends::defaultStyle();
|
||||||
|
mEditorBarcode = glbarcode::Factory::createBarcode( mBcStyle.id().toStdString() );
|
||||||
|
}
|
||||||
|
mEditorBarcode->setChecksum(mBcChecksumFlag);
|
||||||
|
mEditorBarcode->setShowText(mBcTextFlag);
|
||||||
|
|
||||||
|
mEditorBarcode->build( mBcData.toStdString(), mW.pt(), mH.pt() );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build a place holder barcode to display in editor, if cannot display actual barcode
|
||||||
|
//
|
||||||
|
if ( mEditorDefaultBarcode )
|
||||||
|
{
|
||||||
|
delete mEditorDefaultBarcode;
|
||||||
|
}
|
||||||
|
mEditorDefaultBarcode = glbarcode::Factory::createBarcode( mBcStyle.fullId().toStdString() );
|
||||||
|
if ( !mEditorDefaultBarcode )
|
||||||
|
{
|
||||||
|
qWarning() << "Invalid barcode style" << mBcStyle.fullId() << "using \"code39\".";
|
||||||
|
mBcStyle = barcode::Backends::defaultStyle();
|
||||||
|
mEditorDefaultBarcode = glbarcode::Factory::createBarcode( mBcStyle.id().toStdString() );
|
||||||
|
}
|
||||||
|
mEditorDefaultBarcode->setChecksum(mBcChecksumFlag);
|
||||||
|
mEditorDefaultBarcode->setShowText(mBcTextFlag);
|
||||||
|
|
||||||
|
mEditorDefaultBarcode->build( mBcStyle.defaultDigits().toStdString(), mW.pt(), mH.pt() );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Adjust size
|
||||||
|
//
|
||||||
|
if ( mEditorBarcode->isDataValid() )
|
||||||
|
{
|
||||||
|
mW = Distance::pt( mEditorBarcode->width() );
|
||||||
|
mH = Distance::pt( mEditorBarcode->height() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mW = Distance::pt( mEditorDefaultBarcode->width() );
|
||||||
|
mH = Distance::pt( mEditorDefaultBarcode->height() );
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
path.addRect( 0, 0, mW.pt(), mH.pt() );
|
||||||
|
mHoverPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw barcode in editor from cached information
|
||||||
|
///
|
||||||
|
void ModelBarcodeObject::drawBcInEditor( QPainter* painter, const QColor& color ) const
|
||||||
|
{
|
||||||
|
if ( mBcData.isEmpty() )
|
||||||
|
{
|
||||||
|
drawPlaceHolder( painter, color, tr("No barcode data") );
|
||||||
|
}
|
||||||
|
else if ( mBcData.hasPlaceHolders() )
|
||||||
|
{
|
||||||
|
drawPlaceHolder( painter, color, mBcData.toString() );
|
||||||
|
}
|
||||||
|
else if ( mEditorBarcode->isDataValid() )
|
||||||
|
{
|
||||||
|
painter->setPen( QPen( color ) );
|
||||||
|
glbarcode::QtRenderer renderer(painter);
|
||||||
|
mEditorBarcode->render( renderer );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drawPlaceHolder( painter, color, tr("Invalid barcode data") );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw barcode in final printout or preview
|
||||||
|
///
|
||||||
|
void
|
||||||
|
ModelBarcodeObject::drawBc( QPainter* painter,
|
||||||
|
const QColor& color,
|
||||||
|
merge::Record* record ) const
|
||||||
|
{
|
||||||
|
painter->setPen( QPen( color ) );
|
||||||
|
|
||||||
|
glbarcode::Barcode* bc = glbarcode::Factory::createBarcode( mBcStyle.fullId().toStdString() );
|
||||||
|
bc->setChecksum(mBcChecksumFlag);
|
||||||
|
bc->setShowText(mBcTextFlag);
|
||||||
|
|
||||||
|
bc->build( mBcData.toStdString(), mW.pt(), mH.pt() );
|
||||||
|
|
||||||
|
glbarcode::QtRenderer renderer(painter);
|
||||||
|
bc->render( renderer );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw barcode place holder in editor
|
||||||
|
///
|
||||||
|
void
|
||||||
|
ModelBarcodeObject::drawPlaceHolder( QPainter* painter,
|
||||||
|
const QColor& color,
|
||||||
|
const QString& text ) const
|
||||||
|
{
|
||||||
|
QString shortText = text.left( 32 ); // Don't let the text get out of hand
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render box
|
||||||
|
//
|
||||||
|
painter->setPen( Qt::NoPen );
|
||||||
|
painter->setBrush( QBrush( fillColor ) );
|
||||||
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render default barcode
|
||||||
|
//
|
||||||
|
painter->setPen( QPen( color ) );
|
||||||
|
glbarcode::QtRenderer renderer(painter);
|
||||||
|
mEditorDefaultBarcode->render( renderer );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine font size for text
|
||||||
|
//
|
||||||
|
QFont font( "Sans" );
|
||||||
|
font.setPointSizeF( 6 );
|
||||||
|
|
||||||
|
QFontMetricsF fm( font );
|
||||||
|
QRectF textRect = fm.boundingRect( shortText );
|
||||||
|
|
||||||
|
double wPts = (mW - 2*pad).pt();
|
||||||
|
double hPts = (mH - 2*pad).pt();
|
||||||
|
if ( (wPts < textRect.width()) || (hPts < textRect.height()) )
|
||||||
|
{
|
||||||
|
double scaleX = wPts / textRect.width();
|
||||||
|
double scaleY = hPts / textRect.height();
|
||||||
|
font.setPointSizeF( 6 * std::min( scaleX, scaleY ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render hole for text (font size may have changed above)
|
||||||
|
//
|
||||||
|
fm = QFontMetricsF( font );
|
||||||
|
textRect = fm.boundingRect( shortText );
|
||||||
|
|
||||||
|
QRectF holeRect( (mW.pt() - textRect.width())/2 - pad.pt(),
|
||||||
|
(mH.pt() - textRect.height())/2 - pad.pt(),
|
||||||
|
textRect.width() + 2*pad.pt(),
|
||||||
|
textRect.height() + 2*pad.pt() );
|
||||||
|
|
||||||
|
painter->setPen( Qt::NoPen );
|
||||||
|
painter->setBrush( QBrush( fillColor ) );
|
||||||
|
painter->drawRect( holeRect );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render text
|
||||||
|
//
|
||||||
|
painter->setFont( font );
|
||||||
|
painter->setPen( QPen( color ) );
|
||||||
|
painter->drawText( QRectF( 0, 0, mW.pt(), mH.pt() ), Qt::AlignCenter, shortText );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+99
-96
@@ -29,137 +29,140 @@
|
|||||||
#include "glbarcode/Barcode.h"
|
#include "glbarcode/Barcode.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Label Model Line Object
|
|
||||||
///
|
|
||||||
class ModelBarcodeObject : public ModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Line Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class ModelBarcodeObject : public ModelObject
|
||||||
ModelBarcodeObject();
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
ModelBarcodeObject( const Distance& x0,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& y0,
|
// Lifecycle Methods
|
||||||
const Distance& w,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& h,
|
public:
|
||||||
const barcode::Style& bcStyle,
|
ModelBarcodeObject();
|
||||||
bool bcTextFlag,
|
|
||||||
bool bcChecksumFlag,
|
|
||||||
QString bcData,
|
|
||||||
const ColorNode& bcColorNode,
|
|
||||||
const QMatrix& matrix = QMatrix() );
|
|
||||||
|
|
||||||
ModelBarcodeObject( const ModelBarcodeObject* object );
|
ModelBarcodeObject( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const barcode::Style& bcStyle,
|
||||||
|
bool bcTextFlag,
|
||||||
|
bool bcChecksumFlag,
|
||||||
|
QString bcData,
|
||||||
|
const ColorNode& bcColorNode,
|
||||||
|
const QMatrix& matrix = QMatrix() );
|
||||||
|
|
||||||
~ModelBarcodeObject() override;
|
ModelBarcodeObject( const ModelBarcodeObject* object );
|
||||||
|
|
||||||
|
~ModelBarcodeObject() override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
ModelBarcodeObject* clone() const override;
|
ModelBarcodeObject* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Barcode Property: bcData
|
// Barcode Property: bcData
|
||||||
//
|
//
|
||||||
QString bcData() const override;
|
QString bcData() const override;
|
||||||
void setBcData( const QString &value ) override;
|
void setBcData( const QString &value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Barcode Property: bcTextFlag
|
// Barcode Property: bcTextFlag
|
||||||
//
|
//
|
||||||
bool bcTextFlag() const override;
|
bool bcTextFlag() const override;
|
||||||
void setBcTextFlag( bool value ) override;
|
void setBcTextFlag( bool value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Barcode Property: bcChecksumFlag
|
// Barcode Property: bcChecksumFlag
|
||||||
//
|
//
|
||||||
bool bcChecksumFlag() const override;
|
bool bcChecksumFlag() const override;
|
||||||
void setBcChecksumFlag( bool value ) override;
|
void setBcChecksumFlag( bool value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Barcode Property: bcColorNode
|
// Barcode Property: bcColorNode
|
||||||
//
|
//
|
||||||
ColorNode bcColorNode() const override;
|
ColorNode bcColorNode() const override;
|
||||||
void setBcColorNode( const ColorNode &value ) override;
|
void setBcColorNode( const ColorNode &value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Barcode Property: bcStyle
|
// Barcode Property: bcStyle
|
||||||
//
|
//
|
||||||
barcode::Style bcStyle() const override;
|
barcode::Style bcStyle() const override;
|
||||||
void setBcStyle( const barcode::Style &value ) override;
|
void setBcStyle( const barcode::Style &value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Barcode Property: bcFormatDigits
|
// Barcode Property: bcFormatDigits
|
||||||
//
|
//
|
||||||
int bcFormatDigits() const override;
|
int bcFormatDigits() const override;
|
||||||
void setBcFormatDigits( int value ) override;
|
void setBcFormatDigits( int value ) override;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private methods
|
// Private methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void sizeUpdated() override;
|
void sizeUpdated() override;
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
void drawBcInEditor( QPainter* painter, const QColor& color ) const;
|
void drawBcInEditor( QPainter* painter, const QColor& color ) const;
|
||||||
void drawBc( QPainter* painter, const QColor& color, merge::Record* record ) const;
|
void drawBc( QPainter* painter, const QColor& color, merge::Record* record ) const;
|
||||||
void drawPlaceHolder( QPainter* painter, const QColor& color, const QString& text ) const;
|
void drawPlaceHolder( QPainter* painter, const QColor& color, const QString& text ) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
barcode::Style mBcStyle;
|
barcode::Style mBcStyle;
|
||||||
bool mBcTextFlag;
|
bool mBcTextFlag;
|
||||||
bool mBcChecksumFlag;
|
bool mBcChecksumFlag;
|
||||||
int mBcFormatDigits;
|
int mBcFormatDigits;
|
||||||
RawText mBcData;
|
RawText mBcData;
|
||||||
ColorNode mBcColorNode;
|
ColorNode mBcColorNode;
|
||||||
|
|
||||||
glbarcode::Barcode* mEditorBarcode;
|
glbarcode::Barcode* mEditorBarcode;
|
||||||
glbarcode::Barcode* mEditorDefaultBarcode;
|
glbarcode::Barcode* mEditorDefaultBarcode;
|
||||||
|
|
||||||
QPainterPath mHoverPath;
|
QPainterPath mHoverPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+154
-151
@@ -24,171 +24,174 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
//
|
|
||||||
// Private
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
const double slopPixels = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
///
|
// Private
|
||||||
/// Constructor
|
//
|
||||||
///
|
namespace
|
||||||
ModelBoxObject::ModelBoxObject()
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
ModelBoxObject::ModelBoxObject( const Distance& x0,
|
|
||||||
const Distance& y0,
|
|
||||||
const Distance& w,
|
|
||||||
const Distance& h,
|
|
||||||
const Distance& lineWidth,
|
|
||||||
const ColorNode& lineColorNode,
|
|
||||||
const ColorNode& fillColorNode,
|
|
||||||
const QMatrix& matrix,
|
|
||||||
bool shadowState,
|
|
||||||
const Distance& shadowX,
|
|
||||||
const Distance& shadowY,
|
|
||||||
double shadowOpacity,
|
|
||||||
const ColorNode& shadowColorNode )
|
|
||||||
: ModelShapeObject( x0, y0, w, h,
|
|
||||||
lineWidth, lineColorNode, fillColorNode,
|
|
||||||
matrix,
|
|
||||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Copy constructor
|
|
||||||
///
|
|
||||||
ModelBoxObject::ModelBoxObject( const ModelBoxObject* object )
|
|
||||||
: ModelShapeObject( object )
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
ModelBoxObject::~ModelBoxObject()
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Clone
|
|
||||||
///
|
|
||||||
ModelBoxObject* ModelBoxObject::clone() const
|
|
||||||
{
|
|
||||||
return new ModelBoxObject( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw shadow of object
|
|
||||||
///
|
|
||||||
void ModelBoxObject::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
|
||||||
|
///
|
||||||
|
ModelBoxObject::ModelBoxObject()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
ModelBoxObject::ModelBoxObject( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& lineWidth,
|
||||||
|
const ColorNode& lineColorNode,
|
||||||
|
const ColorNode& fillColorNode,
|
||||||
|
const QMatrix& matrix,
|
||||||
|
bool shadowState,
|
||||||
|
const Distance& shadowX,
|
||||||
|
const Distance& shadowY,
|
||||||
|
double shadowOpacity,
|
||||||
|
const ColorNode& shadowColorNode )
|
||||||
|
: ModelShapeObject( x0, y0, w, h,
|
||||||
|
lineWidth, lineColorNode, fillColorNode,
|
||||||
|
matrix,
|
||||||
|
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor
|
||||||
|
///
|
||||||
|
ModelBoxObject::ModelBoxObject( const ModelBoxObject* object )
|
||||||
|
: ModelShapeObject( object )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
ModelBoxObject::~ModelBoxObject()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clone
|
||||||
|
///
|
||||||
|
ModelBoxObject* ModelBoxObject::clone() const
|
||||||
|
{
|
||||||
|
return new ModelBoxObject( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw shadow of object
|
||||||
|
///
|
||||||
|
void ModelBoxObject::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() ) );
|
||||||
else
|
painter->setBrush( Qt::NoBrush );
|
||||||
{
|
|
||||||
if ( lineColor.alpha() )
|
|
||||||
{
|
|
||||||
/* Has only OUTLINE. */
|
|
||||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
|
||||||
painter->setBrush( Qt::NoBrush );
|
|
||||||
|
|
||||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void ModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
painter->setBrush( fillColor );
|
painter->setBrush( fillColor );
|
||||||
|
|
||||||
|
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Path to test for hover condition
|
||||||
|
///
|
||||||
|
QPainterPath ModelBoxObject::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;
|
||||||
|
}
|
||||||
|
|
||||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Path to test for hover condition
|
|
||||||
///
|
|
||||||
QPainterPath ModelBoxObject::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;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+42
-39
@@ -25,57 +25,60 @@
|
|||||||
#include "ModelShapeObject.h"
|
#include "ModelShapeObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Label Model Box Object
|
|
||||||
///
|
|
||||||
class ModelBoxObject : public ModelShapeObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Box Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class ModelBoxObject : public ModelShapeObject
|
||||||
ModelBoxObject();
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
ModelBoxObject( const Distance& x0,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& y0,
|
// Lifecycle Methods
|
||||||
const Distance& w,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& h,
|
public:
|
||||||
const Distance& lineWidth,
|
ModelBoxObject();
|
||||||
const ColorNode& lineColorNode,
|
|
||||||
const ColorNode& fillColorNode,
|
|
||||||
const QMatrix& matrix = QMatrix(),
|
|
||||||
bool shadowState = false,
|
|
||||||
const Distance& shadowX = 0,
|
|
||||||
const Distance& shadowY = 0,
|
|
||||||
double shadowOpacity = 1.0,
|
|
||||||
const ColorNode& shadowColorNode = ColorNode() );
|
|
||||||
|
|
||||||
ModelBoxObject( const ModelBoxObject* object );
|
ModelBoxObject( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& lineWidth,
|
||||||
|
const ColorNode& lineColorNode,
|
||||||
|
const ColorNode& fillColorNode,
|
||||||
|
const QMatrix& matrix = QMatrix(),
|
||||||
|
bool shadowState = false,
|
||||||
|
const Distance& shadowX = 0,
|
||||||
|
const Distance& shadowY = 0,
|
||||||
|
double shadowOpacity = 1.0,
|
||||||
|
const ColorNode& shadowColorNode = ColorNode() );
|
||||||
|
|
||||||
|
ModelBoxObject( const ModelBoxObject* object );
|
||||||
|
|
||||||
~ModelBoxObject() override;
|
~ModelBoxObject() override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
ModelBoxObject* clone() const override;
|
ModelBoxObject* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+154
-151
@@ -24,171 +24,174 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
//
|
|
||||||
// Private
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
const double slopPixels = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
///
|
// Private
|
||||||
/// Constructor
|
//
|
||||||
///
|
namespace
|
||||||
ModelEllipseObject::ModelEllipseObject()
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
ModelEllipseObject::ModelEllipseObject( const Distance& x0,
|
|
||||||
const Distance& y0,
|
|
||||||
const Distance& w,
|
|
||||||
const Distance& h,
|
|
||||||
const Distance& lineWidth,
|
|
||||||
const ColorNode& lineColorNode,
|
|
||||||
const ColorNode& fillColorNode,
|
|
||||||
const QMatrix& matrix,
|
|
||||||
bool shadowState,
|
|
||||||
const Distance& shadowX,
|
|
||||||
const Distance& shadowY,
|
|
||||||
double shadowOpacity,
|
|
||||||
const ColorNode& shadowColorNode )
|
|
||||||
: ModelShapeObject( x0, y0, w, h,
|
|
||||||
lineWidth, lineColorNode, fillColorNode,
|
|
||||||
matrix,
|
|
||||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Copy constructor
|
|
||||||
///
|
|
||||||
ModelEllipseObject::ModelEllipseObject( const ModelEllipseObject* object )
|
|
||||||
: ModelShapeObject( object )
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
ModelEllipseObject::~ModelEllipseObject()
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Clone
|
|
||||||
///
|
|
||||||
ModelEllipseObject* ModelEllipseObject::clone() const
|
|
||||||
{
|
|
||||||
return new ModelEllipseObject( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw shadow of object
|
|
||||||
///
|
|
||||||
void ModelEllipseObject::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
|
||||||
|
///
|
||||||
|
ModelEllipseObject::ModelEllipseObject()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
ModelEllipseObject::ModelEllipseObject( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& lineWidth,
|
||||||
|
const ColorNode& lineColorNode,
|
||||||
|
const ColorNode& fillColorNode,
|
||||||
|
const QMatrix& matrix,
|
||||||
|
bool shadowState,
|
||||||
|
const Distance& shadowX,
|
||||||
|
const Distance& shadowY,
|
||||||
|
double shadowOpacity,
|
||||||
|
const ColorNode& shadowColorNode )
|
||||||
|
: ModelShapeObject( x0, y0, w, h,
|
||||||
|
lineWidth, lineColorNode, fillColorNode,
|
||||||
|
matrix,
|
||||||
|
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Copy constructor
|
||||||
|
///
|
||||||
|
ModelEllipseObject::ModelEllipseObject( const ModelEllipseObject* object )
|
||||||
|
: ModelShapeObject( object )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
ModelEllipseObject::~ModelEllipseObject()
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clone
|
||||||
|
///
|
||||||
|
ModelEllipseObject* ModelEllipseObject::clone() const
|
||||||
|
{
|
||||||
|
return new ModelEllipseObject( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw shadow of object
|
||||||
|
///
|
||||||
|
void ModelEllipseObject::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() ) );
|
||||||
else
|
painter->setBrush( Qt::NoBrush );
|
||||||
{
|
|
||||||
if ( lineColor.alpha() )
|
|
||||||
{
|
|
||||||
/* Has only OUTLINE. */
|
|
||||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
|
||||||
painter->setBrush( Qt::NoBrush );
|
|
||||||
|
|
||||||
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw object itself
|
/// Draw object itself
|
||||||
///
|
///
|
||||||
void ModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
void ModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
QColor lineColor = mLineColorNode.color( record );
|
||||||
QColor fillColor = mFillColorNode.color( record );
|
QColor fillColor = mFillColorNode.color( record );
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||||
painter->setBrush( fillColor );
|
painter->setBrush( fillColor );
|
||||||
|
|
||||||
|
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Path to test for hover condition
|
||||||
|
///
|
||||||
|
QPainterPath ModelEllipseObject::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;
|
||||||
|
}
|
||||||
|
|
||||||
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Path to test for hover condition
|
|
||||||
///
|
|
||||||
QPainterPath ModelEllipseObject::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;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+42
-39
@@ -25,57 +25,60 @@
|
|||||||
#include "ModelShapeObject.h"
|
#include "ModelShapeObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Label Model Ellipse Object
|
|
||||||
///
|
|
||||||
class ModelEllipseObject : public ModelShapeObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Ellipse Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class ModelEllipseObject : public ModelShapeObject
|
||||||
ModelEllipseObject();
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
ModelEllipseObject( const Distance& x0,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& y0,
|
// Lifecycle Methods
|
||||||
const Distance& w,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& h,
|
public:
|
||||||
const Distance& lineWidth,
|
ModelEllipseObject();
|
||||||
const ColorNode& lineColorNode,
|
|
||||||
const ColorNode& fillColorNode,
|
|
||||||
const QMatrix& matrix = QMatrix(),
|
|
||||||
bool shadowState = false,
|
|
||||||
const Distance& shadowX = 0,
|
|
||||||
const Distance& shadowY = 0,
|
|
||||||
double shadowOpacity = 1.0,
|
|
||||||
const ColorNode& shadowColorNode = ColorNode() );
|
|
||||||
|
|
||||||
ModelEllipseObject( const ModelEllipseObject* object );
|
ModelEllipseObject( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& lineWidth,
|
||||||
|
const ColorNode& lineColorNode,
|
||||||
|
const ColorNode& fillColorNode,
|
||||||
|
const QMatrix& matrix = QMatrix(),
|
||||||
|
bool shadowState = false,
|
||||||
|
const Distance& shadowX = 0,
|
||||||
|
const Distance& shadowY = 0,
|
||||||
|
double shadowOpacity = 1.0,
|
||||||
|
const ColorNode& shadowColorNode = ColorNode() );
|
||||||
|
|
||||||
~ModelEllipseObject() override;
|
ModelEllipseObject( const ModelEllipseObject* object );
|
||||||
|
|
||||||
|
~ModelEllipseObject() override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
ModelEllipseObject* clone() const override;
|
ModelEllipseObject* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+475
-472
File diff suppressed because it is too large
Load Diff
+105
-102
@@ -27,134 +27,137 @@
|
|||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Label Model Image Object
|
|
||||||
///
|
|
||||||
class ModelImageObject : public ModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Image Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class ModelImageObject : public ModelObject
|
||||||
ModelImageObject();
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
ModelImageObject( const Distance& x0,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& y0,
|
// Lifecycle Methods
|
||||||
const Distance& w,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& h,
|
public:
|
||||||
const TextNode& filenameNode,
|
ModelImageObject();
|
||||||
const QMatrix& matrix = QMatrix(),
|
|
||||||
bool shadowState = false,
|
|
||||||
const Distance& shadowX = 0,
|
|
||||||
const Distance& shadowY = 0,
|
|
||||||
double shadowOpacity = 1.0,
|
|
||||||
const ColorNode& shadowColorNode = ColorNode() );
|
|
||||||
|
|
||||||
ModelImageObject( const Distance& x0,
|
ModelImageObject( const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h,
|
const Distance& h,
|
||||||
const QString& filename,
|
const TextNode& filenameNode,
|
||||||
const QImage& image,
|
const QMatrix& matrix = QMatrix(),
|
||||||
const QMatrix& matrix = QMatrix(),
|
bool shadowState = false,
|
||||||
bool shadowState = false,
|
const Distance& shadowX = 0,
|
||||||
const Distance& shadowX = 0,
|
const Distance& shadowY = 0,
|
||||||
const Distance& shadowY = 0,
|
double shadowOpacity = 1.0,
|
||||||
double shadowOpacity = 1.0,
|
const ColorNode& shadowColorNode = ColorNode() );
|
||||||
const ColorNode& shadowColorNode = ColorNode() );
|
|
||||||
|
|
||||||
ModelImageObject( const Distance& x0,
|
ModelImageObject( const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h,
|
const Distance& h,
|
||||||
const QString& filename,
|
const QString& filename,
|
||||||
const QByteArray& svg,
|
const QImage& image,
|
||||||
const QMatrix& matrix = QMatrix(),
|
const QMatrix& matrix = QMatrix(),
|
||||||
bool shadowState = false,
|
bool shadowState = false,
|
||||||
const Distance& shadowX = 0,
|
const Distance& shadowX = 0,
|
||||||
const Distance& shadowY = 0,
|
const Distance& shadowY = 0,
|
||||||
double shadowOpacity = 1.0,
|
double shadowOpacity = 1.0,
|
||||||
const ColorNode& shadowColorNode = ColorNode() );
|
const ColorNode& shadowColorNode = ColorNode() );
|
||||||
|
|
||||||
ModelImageObject( const ModelImageObject* object );
|
ModelImageObject( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const QString& filename,
|
||||||
|
const QByteArray& svg,
|
||||||
|
const QMatrix& matrix = QMatrix(),
|
||||||
|
bool shadowState = false,
|
||||||
|
const Distance& shadowX = 0,
|
||||||
|
const Distance& shadowY = 0,
|
||||||
|
double shadowOpacity = 1.0,
|
||||||
|
const ColorNode& shadowColorNode = ColorNode() );
|
||||||
|
|
||||||
|
ModelImageObject( const ModelImageObject* object );
|
||||||
|
|
||||||
~ModelImageObject() override;
|
~ModelImageObject() override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
ModelImageObject* clone() const override;
|
ModelImageObject* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Image Property: filenameNode
|
// Image Property: filenameNode
|
||||||
//
|
//
|
||||||
TextNode filenameNode() const override;
|
TextNode filenameNode() const override;
|
||||||
void setFilenameNode( const TextNode& value ) override;
|
void setFilenameNode( const TextNode& value ) override;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Image Property: image
|
// Image Property: image
|
||||||
//
|
//
|
||||||
const QImage* image() const override;
|
const QImage* image() const override;
|
||||||
void setImage( const QImage& value ) override;
|
void setImage( const QImage& value ) override;
|
||||||
void setImage( const QString& name, const QImage& value ) override;
|
void setImage( const QString& name, const QImage& value ) override;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Image Property: svg
|
// Image Property: svg
|
||||||
//
|
//
|
||||||
QByteArray svg() const override;
|
QByteArray svg() const override;
|
||||||
void setSvg( const QString& name, const QByteArray& value ) override;
|
void setSvg( const QString& name, const QByteArray& value ) override;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Property: naturalSize
|
// Property: naturalSize
|
||||||
//
|
//
|
||||||
Size naturalSize() const override;
|
Size naturalSize() const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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* mSvgRenderer;
|
QSvgRenderer* mSvgRenderer;
|
||||||
QByteArray mSvg;
|
QByteArray mSvg;
|
||||||
|
|
||||||
static QImage* smDefaultImage;
|
static QImage* smDefaultImage;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+184
-181
@@ -24,220 +24,223 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
//
|
|
||||||
// Private
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
const double slopPixels = 2;
|
|
||||||
}
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const double slopPixels = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
ModelLineObject::ModelLineObject()
|
ModelLineObject::ModelLineObject()
|
||||||
{
|
{
|
||||||
mOutline = nullptr;
|
mOutline = nullptr;
|
||||||
|
|
||||||
mHandles << new HandleP1( this );
|
mHandles << new HandleP1( this );
|
||||||
mHandles << new HandleP2( this );
|
mHandles << new HandleP2( this );
|
||||||
|
|
||||||
mLineWidth = 1.0;
|
mLineWidth = 1.0;
|
||||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
ModelLineObject::ModelLineObject( const Distance& x0,
|
ModelLineObject::ModelLineObject( const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& dx,
|
const Distance& dx,
|
||||||
const Distance& dy,
|
const Distance& dy,
|
||||||
const Distance& lineWidth,
|
const Distance& lineWidth,
|
||||||
const ColorNode& lineColorNode,
|
const ColorNode& lineColorNode,
|
||||||
const QMatrix& matrix,
|
const QMatrix& matrix,
|
||||||
bool shadowState,
|
bool shadowState,
|
||||||
const Distance& shadowX,
|
const Distance& shadowX,
|
||||||
const Distance& shadowY,
|
const Distance& shadowY,
|
||||||
double shadowOpacity,
|
double shadowOpacity,
|
||||||
const ColorNode& shadowColorNode )
|
const ColorNode& shadowColorNode )
|
||||||
: ModelObject( x0, y0, dx, dy,
|
: ModelObject( x0, y0, dx, dy,
|
||||||
matrix,
|
matrix,
|
||||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
||||||
{
|
{
|
||||||
mOutline = new Outline( this );
|
mOutline = new Outline( this );
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
mHandles << new HandleNorthWest( this );
|
||||||
mHandles << new HandleNorth( this );
|
mHandles << new HandleNorth( this );
|
||||||
mHandles << new HandleNorthEast( this );
|
mHandles << new HandleNorthEast( this );
|
||||||
mHandles << new HandleEast( this );
|
mHandles << new HandleEast( this );
|
||||||
mHandles << new HandleSouthEast( this );
|
mHandles << new HandleSouthEast( this );
|
||||||
mHandles << new HandleSouth( this );
|
mHandles << new HandleSouth( this );
|
||||||
mHandles << new HandleSouthWest( this );
|
mHandles << new HandleSouthWest( this );
|
||||||
mHandles << new HandleWest( this );
|
mHandles << new HandleWest( this );
|
||||||
|
|
||||||
mLineWidth = lineWidth;
|
mLineWidth = lineWidth;
|
||||||
mLineColorNode = lineColorNode;
|
mLineColorNode = lineColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
ModelLineObject::ModelLineObject( const ModelLineObject* object )
|
ModelLineObject::ModelLineObject( const ModelLineObject* object )
|
||||||
: ModelObject(object)
|
: ModelObject(object)
|
||||||
{
|
|
||||||
mLineWidth = object->mLineWidth;
|
|
||||||
mLineColorNode = object->mLineColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
ModelLineObject::~ModelLineObject()
|
|
||||||
{
|
|
||||||
foreach( Handle* handle, mHandles )
|
|
||||||
{
|
{
|
||||||
delete handle;
|
mLineWidth = object->mLineWidth;
|
||||||
|
mLineColorNode = object->mLineColorNode;
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Destructor
|
||||||
///
|
///
|
||||||
ModelLineObject* ModelLineObject::clone() const
|
ModelLineObject::~ModelLineObject()
|
||||||
{
|
|
||||||
return new ModelLineObject( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Width Property Getter
|
|
||||||
///
|
|
||||||
Distance ModelLineObject::lineWidth() const
|
|
||||||
{
|
|
||||||
return mLineWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Width Property Setter
|
|
||||||
///
|
|
||||||
void ModelLineObject::setLineWidth( const Distance& value )
|
|
||||||
{
|
|
||||||
if ( mLineWidth != value )
|
|
||||||
{
|
{
|
||||||
mLineWidth = value;
|
foreach( Handle* handle, mHandles )
|
||||||
emit changed();
|
{
|
||||||
|
delete handle;
|
||||||
|
}
|
||||||
|
mHandles.clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Color Node Property Getter
|
/// Clone
|
||||||
///
|
///
|
||||||
ColorNode ModelLineObject::lineColorNode() const
|
ModelLineObject* ModelLineObject::clone() const
|
||||||
{
|
|
||||||
return mLineColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Color Node Property Setter
|
|
||||||
///
|
|
||||||
void ModelLineObject::setLineColorNode( const ColorNode& value )
|
|
||||||
{
|
|
||||||
if ( mLineColorNode != value )
|
|
||||||
{
|
{
|
||||||
mLineColorNode = value;
|
return new ModelLineObject( this );
|
||||||
emit changed();
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Width Property Getter
|
||||||
|
///
|
||||||
|
Distance ModelLineObject::lineWidth() const
|
||||||
|
{
|
||||||
|
return mLineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Width Property Setter
|
||||||
|
///
|
||||||
|
void ModelLineObject::setLineWidth( const Distance& value )
|
||||||
|
{
|
||||||
|
if ( mLineWidth != value )
|
||||||
|
{
|
||||||
|
mLineWidth = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Color Node Property Getter
|
||||||
|
///
|
||||||
|
ColorNode ModelLineObject::lineColorNode() const
|
||||||
|
{
|
||||||
|
return mLineColorNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Color Node Property Setter
|
||||||
|
///
|
||||||
|
void ModelLineObject::setLineColorNode( const ColorNode& value )
|
||||||
|
{
|
||||||
|
if ( mLineColorNode != value )
|
||||||
|
{
|
||||||
|
mLineColorNode = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Line Color Capability Implementation
|
/// Can Line Color Capability Implementation
|
||||||
///
|
///
|
||||||
bool ModelLineObject::canLineColor()
|
bool ModelLineObject::canLineColor()
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Line Width Capability Implementation
|
|
||||||
///
|
|
||||||
bool ModelLineObject::canLineWidth()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Draw shadow of object
|
|
||||||
///
|
|
||||||
void ModelLineObject::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() ) );
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Line Width Capability Implementation
|
||||||
|
///
|
||||||
|
bool ModelLineObject::canLineWidth()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Draw shadow of object
|
||||||
|
///
|
||||||
|
void ModelLineObject::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 ModelLineObject::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
|
|
||||||
///
|
|
||||||
void ModelLineObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QColor lineColor = mLineColorNode.color( record );
|
|
||||||
|
|
||||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
|
||||||
painter->drawLine( 0, 0, mW.pt(), mH.pt() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Path to test for hover condition
|
/// Path to test for hover condition
|
||||||
///
|
///
|
||||||
QPainterPath ModelLineObject::hoverPath( double scale ) const
|
QPainterPath ModelLineObject::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;
|
||||||
|
|
||||||
|
double lengthPts = sqrt( mW.pt()*mW.pt() + mH.pt()*mH.pt() );
|
||||||
|
double dx = mH.pt() / lengthPts; // horizontal pitch of perpendicular line
|
||||||
|
double dy = mW.pt() / lengthPts; // vertical pitch of perpendicular line
|
||||||
|
|
||||||
path.moveTo( rPts*dx, - rPts*dy );
|
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( 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.lineTo( - rPts*dx, rPts*dy );
|
||||||
|
|
||||||
path.closeSubpath();
|
path.closeSubpath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+67
-64
@@ -25,90 +25,93 @@
|
|||||||
#include "ModelObject.h"
|
#include "ModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Label Model Line Object
|
|
||||||
///
|
|
||||||
class ModelLineObject : public ModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Line Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class ModelLineObject : public ModelObject
|
||||||
ModelLineObject();
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
ModelLineObject( const Distance& x0,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& y0,
|
// Lifecycle Methods
|
||||||
const Distance& w,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& h,
|
public:
|
||||||
const Distance& lineWidth,
|
ModelLineObject();
|
||||||
const ColorNode& lineColorNode,
|
|
||||||
const QMatrix& matrix = QMatrix(),
|
|
||||||
bool shadowState = false,
|
|
||||||
const Distance& shadowX = 0,
|
|
||||||
const Distance& shadowY = 0,
|
|
||||||
double shadowOpacity = 1.0,
|
|
||||||
const ColorNode& shadowColorNode = ColorNode() );
|
|
||||||
|
|
||||||
ModelLineObject( const ModelLineObject* object );
|
ModelLineObject( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& lineWidth,
|
||||||
|
const ColorNode& lineColorNode,
|
||||||
|
const QMatrix& matrix = QMatrix(),
|
||||||
|
bool shadowState = false,
|
||||||
|
const Distance& shadowX = 0,
|
||||||
|
const Distance& shadowY = 0,
|
||||||
|
double shadowOpacity = 1.0,
|
||||||
|
const ColorNode& shadowColorNode = ColorNode() );
|
||||||
|
|
||||||
|
ModelLineObject( const ModelLineObject* object );
|
||||||
|
|
||||||
~ModelLineObject() override;
|
~ModelLineObject() override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
ModelLineObject* clone() const override;
|
ModelLineObject* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Line Property: lineWidth
|
// Line Property: lineWidth
|
||||||
//
|
//
|
||||||
Distance lineWidth() const override;
|
Distance lineWidth() const override;
|
||||||
void setLineWidth( const Distance& value ) override;
|
void setLineWidth( const Distance& value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Line Property: lineColorNode
|
// Line Property: lineColorNode
|
||||||
//
|
//
|
||||||
ColorNode lineColorNode() const override;
|
ColorNode lineColorNode() const override;
|
||||||
void setLineColorNode( const ColorNode& value ) override;
|
void setLineColorNode( const ColorNode& value ) override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canLineColor();
|
virtual bool canLineColor();
|
||||||
virtual bool canLineWidth();
|
virtual bool canLineWidth();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
Distance mLineWidth;
|
Distance mLineWidth;
|
||||||
ColorNode mLineColorNode;
|
ColorNode mLineColorNode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1111
-1108
File diff suppressed because it is too large
Load Diff
+302
-299
@@ -37,399 +37,402 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
// Forward References
|
|
||||||
class Region;
|
|
||||||
class Size;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Label Model Object Base Class
|
|
||||||
///
|
|
||||||
class ModelObject : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
// Forward References
|
||||||
// Lifecycle Methods
|
class Region;
|
||||||
///////////////////////////////////////////////////////////////
|
class Size;
|
||||||
protected:
|
|
||||||
ModelObject();
|
|
||||||
|
|
||||||
ModelObject( const Distance& x0,
|
|
||||||
const Distance& y0,
|
|
||||||
const Distance& w,
|
|
||||||
const Distance& h,
|
|
||||||
const QMatrix& matrix = QMatrix(),
|
|
||||||
bool shadowState = false,
|
|
||||||
const Distance& shadowX = 0,
|
|
||||||
const Distance& shadowY = 0,
|
|
||||||
double shadowOpacity = 1.0,
|
|
||||||
const ColorNode& shadowColorNode = ColorNode() );
|
|
||||||
|
|
||||||
ModelObject( const ModelObject* object );
|
|
||||||
|
|
||||||
public:
|
|
||||||
~ModelObject() override;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Object duplication
|
/// Label Model Object Base Class
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
virtual ModelObject* clone() const = 0;
|
class ModelObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
protected:
|
||||||
|
ModelObject();
|
||||||
|
|
||||||
|
ModelObject( const Distance& x0,
|
||||||
|
const Distance& y0,
|
||||||
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const QMatrix& matrix = QMatrix(),
|
||||||
|
bool shadowState = false,
|
||||||
|
const Distance& shadowX = 0,
|
||||||
|
const Distance& shadowY = 0,
|
||||||
|
double shadowOpacity = 1.0,
|
||||||
|
const ColorNode& shadowColorNode = ColorNode() );
|
||||||
|
|
||||||
|
ModelObject( const ModelObject* object );
|
||||||
|
|
||||||
|
public:
|
||||||
|
~ModelObject() override;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
virtual ModelObject* clone() const = 0;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void moved();
|
void moved();
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Common Properties
|
// Common Properties
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// ID Property.
|
// ID Property.
|
||||||
//
|
//
|
||||||
int id() const;
|
int id() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Selected Property.
|
// Selected Property.
|
||||||
//
|
//
|
||||||
bool isSelected() const;
|
bool isSelected() const;
|
||||||
void select( bool value = true );
|
void select( bool value = true );
|
||||||
void unselect();
|
void unselect();
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// x0 Property ( x coordinate of origin )
|
// x0 Property ( x coordinate of origin )
|
||||||
//
|
//
|
||||||
Distance x0() const;
|
Distance x0() const;
|
||||||
void setX0( const Distance& value );
|
void setX0( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// y0 Property ( y coordinate of origin )
|
// y0 Property ( y coordinate of origin )
|
||||||
//
|
//
|
||||||
Distance y0() const;
|
Distance y0() const;
|
||||||
void setY0( const Distance& value );
|
void setY0( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// w Property ( width of bounding box )
|
// w Property ( width of bounding box )
|
||||||
//
|
//
|
||||||
Distance w() const;
|
Distance w() const;
|
||||||
void setW( const Distance& value );
|
void setW( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// h Property ( height of bounding box )
|
// h Property ( height of bounding box )
|
||||||
//
|
//
|
||||||
Distance h() const;
|
Distance h() const;
|
||||||
void setH( const Distance& value );
|
void setH( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Transformation Matrix Property
|
// Transformation Matrix Property
|
||||||
//
|
//
|
||||||
QMatrix matrix() const;
|
QMatrix matrix() const;
|
||||||
void setMatrix( const QMatrix& value );
|
void setMatrix( const QMatrix& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow State Property
|
// Shadow State Property
|
||||||
//
|
//
|
||||||
bool shadow() const;
|
bool shadow() const;
|
||||||
void setShadow( bool value );
|
void setShadow( bool value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow x Offset Property
|
// Shadow x Offset Property
|
||||||
//
|
//
|
||||||
Distance shadowX() const;
|
Distance shadowX() const;
|
||||||
void setShadowX( const Distance& value );
|
void setShadowX( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow y Offset Property
|
// Shadow y Offset Property
|
||||||
//
|
//
|
||||||
Distance shadowY() const;
|
Distance shadowY() const;
|
||||||
void setShadowY( const Distance& value );
|
void setShadowY( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow opacity Property
|
// Shadow opacity Property
|
||||||
//
|
//
|
||||||
double shadowOpacity() const;
|
double shadowOpacity() const;
|
||||||
void setShadowOpacity( double value );
|
void setShadowOpacity( double value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shadow Color Property
|
// Shadow Color Property
|
||||||
//
|
//
|
||||||
ColorNode shadowColorNode() const;
|
ColorNode shadowColorNode() const;
|
||||||
void setShadowColorNode( const ColorNode& value );
|
void setShadowColorNode( const ColorNode& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Natural Size Property (read-only)
|
// Natural Size Property (read-only)
|
||||||
//
|
//
|
||||||
virtual Size naturalSize() const;
|
virtual Size naturalSize() const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Text Properties Virtual Interface
|
// Text Properties Virtual Interface
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Virtual Text Property: text
|
// Virtual Text Property: text
|
||||||
//
|
//
|
||||||
virtual QString text() const;
|
virtual QString text() const;
|
||||||
virtual void setText( const QString &value );
|
virtual void setText( const QString &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: fontFamily
|
// Virtual Text Property: fontFamily
|
||||||
//
|
//
|
||||||
virtual QString fontFamily() const;
|
virtual QString fontFamily() const;
|
||||||
virtual void setFontFamily( const QString &value );
|
virtual void setFontFamily( const QString &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: fontSize
|
// Virtual Text Property: fontSize
|
||||||
//
|
//
|
||||||
virtual double fontSize() const;
|
virtual double fontSize() const;
|
||||||
virtual void setFontSize( double value );
|
virtual void setFontSize( double value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: fontWeight
|
// Virtual 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 );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: fontItalicFlag
|
// Virtual Text Property: fontItalicFlag
|
||||||
//
|
//
|
||||||
virtual bool fontItalicFlag() const;
|
virtual bool fontItalicFlag() const;
|
||||||
virtual void setFontItalicFlag( bool value );
|
virtual void setFontItalicFlag( bool value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: fontUnderlineFlag
|
// Virtual Text Property: fontUnderlineFlag
|
||||||
//
|
//
|
||||||
virtual bool fontUnderlineFlag() const;
|
virtual bool fontUnderlineFlag() const;
|
||||||
virtual void setFontUnderlineFlag( bool value );
|
virtual void setFontUnderlineFlag( bool value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: textColorNode
|
// Virtual Text Property: textColorNode
|
||||||
//
|
//
|
||||||
virtual ColorNode textColorNode() const;
|
virtual ColorNode textColorNode() const;
|
||||||
virtual void setTextColorNode( const ColorNode &value );
|
virtual void setTextColorNode( const ColorNode &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: textHAlign
|
// Virtual 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 );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: textVAlign
|
// Virtual 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 );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Text Property: textLineSpacing
|
// Virtual Text Property: textLineSpacing
|
||||||
//
|
//
|
||||||
virtual double textLineSpacing() const;
|
virtual double textLineSpacing() const;
|
||||||
virtual void setTextLineSpacing( double value );
|
virtual void setTextLineSpacing( double value );
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Image Properties Virtual Interface
|
// Image Properties Virtual Interface
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Virtual Image Property: filenameNode
|
// Virtual Image Property: filenameNode
|
||||||
//
|
//
|
||||||
virtual TextNode filenameNode() const;
|
virtual TextNode filenameNode() const;
|
||||||
virtual void setFilenameNode( const TextNode &value );
|
virtual void setFilenameNode( const TextNode &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Image Property: image
|
// Virtual Image Property: image
|
||||||
//
|
//
|
||||||
virtual const QImage* image() const;
|
virtual const QImage* image() const;
|
||||||
virtual void setImage( const QImage& value );
|
virtual void setImage( const QImage& value );
|
||||||
virtual void setImage( const QString& name, const QImage& value );
|
virtual void setImage( const QString& name, const QImage& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Image Property: svg
|
// Virtual Image Property: svg
|
||||||
//
|
//
|
||||||
virtual QByteArray svg() const;
|
virtual QByteArray svg() const;
|
||||||
virtual void setSvg( const QString& name, const QByteArray& value );
|
virtual void setSvg( const QString& name, const QByteArray& value );
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Shape Properties Virtual Interface
|
// Shape Properties Virtual Interface
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Virtual Shape Property: lineWidth
|
// Virtual Shape Property: lineWidth
|
||||||
//
|
//
|
||||||
virtual Distance lineWidth() const;
|
virtual Distance lineWidth() const;
|
||||||
virtual void setLineWidth( const Distance& value );
|
virtual void setLineWidth( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Shape Property: lineColorNode
|
// Virtual Shape Property: lineColorNode
|
||||||
//
|
//
|
||||||
virtual ColorNode lineColorNode() const;
|
virtual ColorNode lineColorNode() const;
|
||||||
virtual void setLineColorNode( const ColorNode &value );
|
virtual void setLineColorNode( const ColorNode &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Shape Property: fillColorNode
|
// Virtual Shape Property: fillColorNode
|
||||||
//
|
//
|
||||||
virtual ColorNode fillColorNode() const;
|
virtual ColorNode fillColorNode() const;
|
||||||
virtual void setFillColorNode( const ColorNode &value );
|
virtual void setFillColorNode( const ColorNode &value );
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Barcode Properties Virtual Interface
|
// Barcode Properties Virtual Interface
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcData
|
// Virtual Barcode Property: bcData
|
||||||
//
|
//
|
||||||
virtual QString bcData() const;
|
virtual QString bcData() const;
|
||||||
virtual void setBcData( const QString& value );
|
virtual void setBcData( const QString& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcTextFlag
|
// Virtual Barcode Property: bcTextFlag
|
||||||
//
|
//
|
||||||
virtual bool bcTextFlag() const;
|
virtual bool bcTextFlag() const;
|
||||||
virtual void setBcTextFlag( bool value );
|
virtual void setBcTextFlag( bool value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcChecksumFlag
|
// Virtual Barcode Property: bcChecksumFlag
|
||||||
//
|
//
|
||||||
virtual bool bcChecksumFlag() const;
|
virtual bool bcChecksumFlag() const;
|
||||||
virtual void setBcChecksumFlag( bool value );
|
virtual void setBcChecksumFlag( bool value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcColorNode
|
// Virtual Barcode Property: bcColorNode
|
||||||
//
|
//
|
||||||
virtual ColorNode bcColorNode() const;
|
virtual ColorNode bcColorNode() const;
|
||||||
virtual void setBcColorNode( const ColorNode &value );
|
virtual void setBcColorNode( const ColorNode &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcStyle
|
// Virtual Barcode Property: bcStyle
|
||||||
//
|
//
|
||||||
virtual barcode::Style bcStyle() const;
|
virtual barcode::Style bcStyle() const;
|
||||||
virtual void setBcStyle( const barcode::Style &value );
|
virtual void setBcStyle( const barcode::Style &value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Virtual Barcode Property: bcFormatDigits
|
// Virtual Barcode Property: bcFormatDigits
|
||||||
//
|
//
|
||||||
virtual int bcFormatDigits() const;
|
virtual int bcFormatDigits() const;
|
||||||
virtual void setBcFormatDigits( int value );
|
virtual void setBcFormatDigits( int value );
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capabilities (Overridden by concrete classes.)
|
// Capabilities (Overridden by concrete classes.)
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canText() const;
|
virtual bool canText() const;
|
||||||
virtual bool canFill() const;
|
virtual bool canFill() const;
|
||||||
virtual bool canLineColor() const;
|
virtual bool canLineColor() const;
|
||||||
virtual bool canLineWidth() const;
|
virtual bool canLineWidth() const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Position and Size methods
|
// Position and Size methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setPosition( const Distance& x0, const Distance& y0 );
|
void setPosition( const Distance& x0, const Distance& y0 );
|
||||||
void setPositionRelative( const Distance& dx, const Distance& dy );
|
void setPositionRelative( const Distance& dx, const Distance& dy );
|
||||||
Size size() const;
|
Size size() const;
|
||||||
void setSize( const Distance& w, const Distance& h );
|
void setSize( const Distance& w, const Distance& h );
|
||||||
void setSize( const Size& size );
|
void setSize( const Size& size );
|
||||||
void setSizeHonorAspect( const Distance& w, const Distance& h );
|
void setSizeHonorAspect( const Distance& w, const Distance& h );
|
||||||
void setWHonorAspect( const Distance& w );
|
void setWHonorAspect( const Distance& w );
|
||||||
void setHHonorAspect( const Distance& h );
|
void setHHonorAspect( const Distance& h );
|
||||||
Region getExtent();
|
Region getExtent();
|
||||||
void rotate( double thetaDegs );
|
void rotate( double thetaDegs );
|
||||||
void flipHoriz();
|
void flipHoriz();
|
||||||
void flipVert();
|
void flipVert();
|
||||||
bool isLocatedAt( double scale, const Distance& x, const Distance& y ) const;
|
bool isLocatedAt( double scale, const Distance& x, const Distance& y ) const;
|
||||||
Handle* handleAt( double scale, const Distance& x, const Distance& y ) const;
|
Handle* handleAt( double scale, const Distance& x, const Distance& y ) const;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||||
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||||
virtual QPainterPath hoverPath( double scale ) const = 0;
|
virtual QPainterPath hoverPath( double scale ) const = 0;
|
||||||
|
|
||||||
virtual void sizeUpdated();
|
virtual void sizeUpdated();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Protected Members
|
// Protected Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
bool mSelectedFlag;
|
bool mSelectedFlag;
|
||||||
|
|
||||||
Distance mX0;
|
Distance mX0;
|
||||||
Distance mY0;
|
Distance mY0;
|
||||||
Distance mW;
|
Distance mW;
|
||||||
Distance mH;
|
Distance mH;
|
||||||
|
|
||||||
bool mShadowState;
|
bool mShadowState;
|
||||||
Distance mShadowX;
|
Distance mShadowX;
|
||||||
Distance mShadowY;
|
Distance mShadowY;
|
||||||
double mShadowOpacity;
|
double mShadowOpacity;
|
||||||
ColorNode mShadowColorNode;
|
ColorNode mShadowColorNode;
|
||||||
|
|
||||||
QList<Handle*> mHandles;
|
QList<Handle*> mHandles;
|
||||||
Outline* mOutline;
|
Outline* mOutline;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private Members
|
// Private Members
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
static int msNextId;
|
static int msNextId;
|
||||||
int mId;
|
int mId;
|
||||||
|
|
||||||
QMatrix mMatrix;
|
QMatrix mMatrix;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+157
-154
@@ -24,184 +24,187 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
ModelShapeObject::ModelShapeObject()
|
|
||||||
{
|
{
|
||||||
mOutline = new Outline( this );
|
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
///
|
||||||
mHandles << new HandleNorth( this );
|
/// Constructor
|
||||||
mHandles << new HandleNorthEast( this );
|
///
|
||||||
mHandles << new HandleEast( this );
|
ModelShapeObject::ModelShapeObject()
|
||||||
mHandles << new HandleSouthEast( this );
|
{
|
||||||
mHandles << new HandleSouth( this );
|
mOutline = new Outline( this );
|
||||||
mHandles << new HandleSouthWest( this );
|
|
||||||
mHandles << new HandleWest( this );
|
|
||||||
|
|
||||||
mLineWidth = 1.0;
|
mHandles << new HandleNorthWest( this );
|
||||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
mHandles << new HandleNorth( this );
|
||||||
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
|
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 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
ModelShapeObject::ModelShapeObject( const Distance& x0,
|
ModelShapeObject::ModelShapeObject( const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h,
|
const Distance& h,
|
||||||
const Distance& lineWidth,
|
const Distance& lineWidth,
|
||||||
const ColorNode& lineColorNode,
|
const ColorNode& lineColorNode,
|
||||||
const ColorNode& fillColorNode,
|
const ColorNode& fillColorNode,
|
||||||
const QMatrix& matrix,
|
const QMatrix& matrix,
|
||||||
bool shadowState,
|
bool shadowState,
|
||||||
const Distance& shadowX,
|
const Distance& shadowX,
|
||||||
const Distance& shadowY,
|
const Distance& shadowY,
|
||||||
double shadowOpacity,
|
double shadowOpacity,
|
||||||
const ColorNode& shadowColorNode )
|
const ColorNode& shadowColorNode )
|
||||||
: ModelObject( x0, y0, w, h,
|
: ModelObject( x0, y0, w, h,
|
||||||
matrix,
|
matrix,
|
||||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
||||||
{
|
{
|
||||||
mOutline = new Outline( this );
|
mOutline = new Outline( this );
|
||||||
|
|
||||||
mHandles << new HandleNorthWest( this );
|
mHandles << new HandleNorthWest( this );
|
||||||
mHandles << new HandleNorth( this );
|
mHandles << new HandleNorth( this );
|
||||||
mHandles << new HandleNorthEast( this );
|
mHandles << new HandleNorthEast( this );
|
||||||
mHandles << new HandleEast( this );
|
mHandles << new HandleEast( this );
|
||||||
mHandles << new HandleSouthEast( this );
|
mHandles << new HandleSouthEast( this );
|
||||||
mHandles << new HandleSouth( this );
|
mHandles << new HandleSouth( this );
|
||||||
mHandles << new HandleSouthWest( this );
|
mHandles << new HandleSouthWest( this );
|
||||||
mHandles << new HandleWest( this );
|
mHandles << new HandleWest( this );
|
||||||
|
|
||||||
mLineWidth = lineWidth;
|
mLineWidth = lineWidth;
|
||||||
mLineColorNode = lineColorNode;
|
mLineColorNode = lineColorNode;
|
||||||
mFillColorNode = fillColorNode;
|
mFillColorNode = fillColorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
///
|
///
|
||||||
ModelShapeObject::ModelShapeObject( const ModelShapeObject* object ) : ModelObject(object)
|
ModelShapeObject::ModelShapeObject( const ModelShapeObject* object ) : ModelObject(object)
|
||||||
{
|
|
||||||
mLineWidth = object->mLineWidth;
|
|
||||||
mLineColorNode = object->mLineColorNode;
|
|
||||||
mFillColorNode = object->mFillColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
ModelShapeObject::~ModelShapeObject()
|
|
||||||
{
|
|
||||||
delete mOutline;
|
|
||||||
|
|
||||||
foreach( Handle* handle, mHandles )
|
|
||||||
{
|
{
|
||||||
delete handle;
|
mLineWidth = object->mLineWidth;
|
||||||
|
mLineColorNode = object->mLineColorNode;
|
||||||
|
mFillColorNode = object->mFillColorNode;
|
||||||
}
|
}
|
||||||
mHandles.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Width Property Getter
|
/// Destructor
|
||||||
///
|
///
|
||||||
Distance ModelShapeObject::lineWidth() const
|
ModelShapeObject::~ModelShapeObject()
|
||||||
{
|
|
||||||
return mLineWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Width Property Setter
|
|
||||||
///
|
|
||||||
void ModelShapeObject::setLineWidth( const Distance& value )
|
|
||||||
{
|
|
||||||
if ( mLineWidth != value )
|
|
||||||
{
|
{
|
||||||
mLineWidth = value;
|
delete mOutline;
|
||||||
emit changed();
|
|
||||||
|
foreach( Handle* handle, mHandles )
|
||||||
|
{
|
||||||
|
delete handle;
|
||||||
|
}
|
||||||
|
mHandles.clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Line Color Node Property Getter
|
/// Line Width Property Getter
|
||||||
///
|
///
|
||||||
ColorNode ModelShapeObject::lineColorNode() const
|
Distance ModelShapeObject::lineWidth() const
|
||||||
{
|
|
||||||
return mLineColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Line Color Node Property Setter
|
|
||||||
///
|
|
||||||
void ModelShapeObject::setLineColorNode( const ColorNode& value )
|
|
||||||
{
|
|
||||||
if ( mLineColorNode != value )
|
|
||||||
{
|
{
|
||||||
mLineColorNode = value;
|
return mLineWidth;
|
||||||
emit changed();
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Width Property Setter
|
||||||
|
///
|
||||||
|
void ModelShapeObject::setLineWidth( const Distance& value )
|
||||||
|
{
|
||||||
|
if ( mLineWidth != value )
|
||||||
|
{
|
||||||
|
mLineWidth = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Color Node Property Getter
|
||||||
|
///
|
||||||
|
ColorNode ModelShapeObject::lineColorNode() const
|
||||||
|
{
|
||||||
|
return mLineColorNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Line Color Node Property Setter
|
||||||
|
///
|
||||||
|
void ModelShapeObject::setLineColorNode( const ColorNode& value )
|
||||||
|
{
|
||||||
|
if ( mLineColorNode != value )
|
||||||
|
{
|
||||||
|
mLineColorNode = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Fill Color Node Property Getter
|
/// Fill Color Node Property Getter
|
||||||
///
|
///
|
||||||
ColorNode ModelShapeObject::fillColorNode() const
|
ColorNode ModelShapeObject::fillColorNode() const
|
||||||
{
|
|
||||||
return mFillColorNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Fill Color Node Property Setter
|
|
||||||
///
|
|
||||||
void ModelShapeObject::setFillColorNode( const ColorNode& value )
|
|
||||||
{
|
|
||||||
if ( mFillColorNode != value )
|
|
||||||
{
|
{
|
||||||
mFillColorNode = value;
|
return mFillColorNode;
|
||||||
emit changed();
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Fill Color Node Property Setter
|
||||||
|
///
|
||||||
|
void ModelShapeObject::setFillColorNode( const ColorNode& value )
|
||||||
|
{
|
||||||
|
if ( mFillColorNode != value )
|
||||||
|
{
|
||||||
|
mFillColorNode = value;
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Fill Capability Implementation
|
/// Can Fill Capability Implementation
|
||||||
///
|
///
|
||||||
bool ModelShapeObject::canFill()
|
bool ModelShapeObject::canFill()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Line Color Capability Implementation
|
||||||
|
///
|
||||||
|
bool ModelShapeObject::canLineColor()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Can Line Width Capability Implementation
|
||||||
|
///
|
||||||
|
bool ModelShapeObject::canLineWidth()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Line Color Capability Implementation
|
|
||||||
///
|
|
||||||
bool ModelShapeObject::canLineColor()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Can Line Width Capability Implementation
|
|
||||||
///
|
|
||||||
bool ModelShapeObject::canLineWidth()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+65
-62
@@ -25,85 +25,88 @@
|
|||||||
#include "ModelObject.h"
|
#include "ModelObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Label Model Shape Object (Box or Ellipse)
|
|
||||||
///
|
|
||||||
class ModelShapeObject : public ModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Shape Object (Box or Ellipse)
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
protected:
|
class ModelShapeObject : public ModelObject
|
||||||
ModelShapeObject();
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
ModelShapeObject( const Distance& x0,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& y0,
|
// Lifecycle Methods
|
||||||
const Distance& w,
|
///////////////////////////////////////////////////////////////
|
||||||
const Distance& h,
|
protected:
|
||||||
const Distance& lineWidth,
|
ModelShapeObject();
|
||||||
const ColorNode& lineColorNode,
|
|
||||||
const ColorNode& fillColorNode,
|
|
||||||
const QMatrix& matrix,
|
|
||||||
bool shadowState,
|
|
||||||
const Distance& shadowX,
|
|
||||||
const Distance& shadowY,
|
|
||||||
double shadowOpacity,
|
|
||||||
const ColorNode& shadowColorNode );
|
|
||||||
|
|
||||||
ModelShapeObject( const ModelShapeObject* object );
|
ModelShapeObject( const Distance& x0,
|
||||||
public:
|
const Distance& y0,
|
||||||
~ModelShapeObject() override;
|
const Distance& w,
|
||||||
|
const Distance& h,
|
||||||
|
const Distance& lineWidth,
|
||||||
|
const ColorNode& lineColorNode,
|
||||||
|
const ColorNode& fillColorNode,
|
||||||
|
const QMatrix& matrix,
|
||||||
|
bool shadowState,
|
||||||
|
const Distance& shadowX,
|
||||||
|
const Distance& shadowY,
|
||||||
|
double shadowOpacity,
|
||||||
|
const ColorNode& shadowColorNode );
|
||||||
|
|
||||||
|
ModelShapeObject( const ModelShapeObject* object );
|
||||||
|
public:
|
||||||
|
~ModelShapeObject() override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Shape Property: lineWidth
|
// Shape Property: lineWidth
|
||||||
//
|
//
|
||||||
Distance lineWidth() const override;
|
Distance lineWidth() const override;
|
||||||
void setLineWidth( const Distance& value ) override;
|
void setLineWidth( const Distance& value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shape Property: lineColorNode
|
// Shape Property: lineColorNode
|
||||||
//
|
//
|
||||||
ColorNode lineColorNode() const override;
|
ColorNode lineColorNode() const override;
|
||||||
void setLineColorNode( const ColorNode& value ) override;
|
void setLineColorNode( const ColorNode& value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Shape Property: fillColorNode
|
// Shape Property: fillColorNode
|
||||||
//
|
//
|
||||||
ColorNode fillColorNode() const override;
|
ColorNode fillColorNode() const override;
|
||||||
void setFillColorNode( const ColorNode& value ) override;
|
void setFillColorNode( const ColorNode& value ) override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// 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:
|
||||||
Distance mLineWidth;
|
Distance mLineWidth;
|
||||||
ColorNode mLineColorNode;
|
ColorNode mLineColorNode;
|
||||||
ColorNode mFillColorNode;
|
ColorNode mFillColorNode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+632
-629
File diff suppressed because it is too large
Load Diff
+137
-134
@@ -28,181 +28,184 @@
|
|||||||
#include <QTextLayout>
|
#include <QTextLayout>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Label Model Line Object
|
|
||||||
///
|
|
||||||
class ModelTextObject : public ModelObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
// Lifecycle Methods
|
/// Label Model Line Object
|
||||||
///////////////////////////////////////////////////////////////
|
///
|
||||||
public:
|
class ModelTextObject : public ModelObject
|
||||||
ModelTextObject();
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
|
ModelTextObject();
|
||||||
|
|
||||||
ModelTextObject( const Distance& x0,
|
ModelTextObject( const Distance& x0,
|
||||||
const Distance& y0,
|
const Distance& y0,
|
||||||
const Distance& w,
|
const Distance& w,
|
||||||
const Distance& h,
|
const Distance& h,
|
||||||
const QString& text,
|
const QString& text,
|
||||||
const QString& fontFamily,
|
const QString& fontFamily,
|
||||||
double fontSize,
|
double fontSize,
|
||||||
QFont::Weight fontWeight,
|
QFont::Weight fontWeight,
|
||||||
bool fontItalicFlag,
|
bool fontItalicFlag,
|
||||||
bool fontUnderlineFlag,
|
bool fontUnderlineFlag,
|
||||||
ColorNode textColorNode,
|
ColorNode textColorNode,
|
||||||
Qt::Alignment textHAlign,
|
Qt::Alignment textHAlign,
|
||||||
Qt::Alignment textVAlign,
|
Qt::Alignment textVAlign,
|
||||||
double textLineSpacing,
|
double textLineSpacing,
|
||||||
const QMatrix& matrix = QMatrix(),
|
const QMatrix& matrix = QMatrix(),
|
||||||
bool shadowState = false,
|
bool shadowState = false,
|
||||||
const Distance& shadowX = 0,
|
const Distance& shadowX = 0,
|
||||||
const Distance& shadowY = 0,
|
const Distance& shadowY = 0,
|
||||||
double shadowOpacity = 1.0,
|
double shadowOpacity = 1.0,
|
||||||
const ColorNode& shadowColorNode = ColorNode() );
|
const ColorNode& shadowColorNode = ColorNode() );
|
||||||
|
|
||||||
ModelTextObject( const ModelTextObject* object );
|
ModelTextObject( const ModelTextObject* object );
|
||||||
|
|
||||||
~ModelTextObject() override;
|
~ModelTextObject() override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Object duplication
|
// Object duplication
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
ModelTextObject* clone() const override;
|
ModelTextObject* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Property Implementations
|
// Property Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Text Property: text
|
// Text Property: text
|
||||||
//
|
//
|
||||||
QString text() const override;
|
QString text() const override;
|
||||||
void setText( const QString &value ) override;
|
void setText( const QString &value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontFamily
|
// Text Property: fontFamily
|
||||||
//
|
//
|
||||||
QString fontFamily() const override;
|
QString fontFamily() const override;
|
||||||
void setFontFamily( const QString &value ) override;
|
void setFontFamily( const QString &value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontSize
|
// Text Property: fontSize
|
||||||
//
|
//
|
||||||
double fontSize() const override;
|
double fontSize() const override;
|
||||||
void setFontSize( double value ) override;
|
void setFontSize( double value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontWeight
|
// Text Property: fontWeight
|
||||||
//
|
//
|
||||||
QFont::Weight fontWeight() const override;
|
QFont::Weight fontWeight() const override;
|
||||||
void setFontWeight( QFont::Weight value ) override;
|
void setFontWeight( QFont::Weight value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontItalicFlag
|
// Text Property: fontItalicFlag
|
||||||
//
|
//
|
||||||
bool fontItalicFlag() const override;
|
bool fontItalicFlag() const override;
|
||||||
void setFontItalicFlag( bool value ) override;
|
void setFontItalicFlag( bool value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: fontUnderlineFlag
|
// Text Property: fontUnderlineFlag
|
||||||
//
|
//
|
||||||
bool fontUnderlineFlag() const override;
|
bool fontUnderlineFlag() const override;
|
||||||
void setFontUnderlineFlag( bool value ) override;
|
void setFontUnderlineFlag( bool value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: textColorNode
|
// Text Property: textColorNode
|
||||||
//
|
//
|
||||||
ColorNode textColorNode() const override;
|
ColorNode textColorNode() const override;
|
||||||
void setTextColorNode( const ColorNode &value ) override;
|
void setTextColorNode( const ColorNode &value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: textHAlign
|
// Text Property: textHAlign
|
||||||
//
|
//
|
||||||
Qt::Alignment textHAlign() const override;
|
Qt::Alignment textHAlign() const override;
|
||||||
void setTextHAlign( Qt::Alignment value ) override;
|
void setTextHAlign( Qt::Alignment value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: textVAlign
|
// Text Property: textVAlign
|
||||||
//
|
//
|
||||||
Qt::Alignment textVAlign() const override;
|
Qt::Alignment textVAlign() const override;
|
||||||
void setTextVAlign( Qt::Alignment value ) override;
|
void setTextVAlign( Qt::Alignment value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Text Property: textLineSpacing
|
// Text Property: textLineSpacing
|
||||||
//
|
//
|
||||||
double textLineSpacing() const override;
|
double textLineSpacing() const override;
|
||||||
void setTextLineSpacing( double value ) override;
|
void setTextLineSpacing( double value ) override;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Property: naturalSize
|
// Property: naturalSize
|
||||||
//
|
//
|
||||||
Size naturalSize() const override;
|
Size naturalSize() const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Capability Implementations
|
// Capability Implementations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual bool canText();
|
virtual bool canText();
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Drawing operations
|
// Drawing operations
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const override;
|
||||||
QPainterPath hoverPath( double scale ) const override;
|
QPainterPath hoverPath( double scale ) const override;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Private methods
|
// Private methods
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void sizeUpdated() override;
|
void sizeUpdated() override;
|
||||||
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:
|
||||||
RawText mText;
|
RawText 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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+86
-83
@@ -25,111 +25,114 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
//
|
|
||||||
// Private
|
|
||||||
//
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
const qreal dashSize = 2;
|
|
||||||
|
|
||||||
const double slopPixels = 2;
|
//
|
||||||
const double outlineWidthPixels = 1;
|
// Private
|
||||||
const QColor outlineColor1( 0, 0, 0 );
|
//
|
||||||
const QColor outlineColor2( 255, 255, 255 );
|
namespace
|
||||||
}
|
{
|
||||||
|
const qreal dashSize = 2;
|
||||||
|
|
||||||
|
const double slopPixels = 2;
|
||||||
|
const double outlineWidthPixels = 1;
|
||||||
|
const QColor outlineColor1( 0, 0, 0 );
|
||||||
|
const QColor outlineColor2( 255, 255, 255 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Outline Constructor
|
/// Outline Constructor
|
||||||
///
|
///
|
||||||
Outline::Outline( ModelObject* owner )
|
Outline::Outline( ModelObject* owner )
|
||||||
: mOwner(owner)
|
: mOwner(owner)
|
||||||
{
|
{
|
||||||
mDashes << dashSize << dashSize;
|
mDashes << dashSize << dashSize;
|
||||||
|
|
||||||
mPen1.setColor( outlineColor1 );
|
mPen1.setColor( outlineColor1 );
|
||||||
mPen1.setWidth( outlineWidthPixels );
|
mPen1.setWidth( outlineWidthPixels );
|
||||||
mPen1.setCosmetic( true );
|
mPen1.setCosmetic( true );
|
||||||
mPen1.setCapStyle( Qt::FlatCap );
|
mPen1.setCapStyle( Qt::FlatCap );
|
||||||
mPen1.setDashPattern( mDashes );
|
mPen1.setDashPattern( mDashes );
|
||||||
|
|
||||||
mPen2.setColor( outlineColor2 );
|
mPen2.setColor( outlineColor2 );
|
||||||
mPen2.setWidth( outlineWidthPixels );
|
mPen2.setWidth( outlineWidthPixels );
|
||||||
mPen2.setCosmetic( true );
|
mPen2.setCosmetic( true );
|
||||||
mPen2.setCapStyle( Qt::FlatCap );
|
mPen2.setCapStyle( Qt::FlatCap );
|
||||||
mPen2.setDashPattern( mDashes );
|
mPen2.setDashPattern( mDashes );
|
||||||
mPen2.setDashOffset( dashSize );
|
mPen2.setDashOffset( dashSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Outline Copy constructor
|
/// Outline Copy constructor
|
||||||
///
|
///
|
||||||
Outline::Outline( const Outline* outline, ModelObject* newOwner )
|
Outline::Outline( const Outline* outline, ModelObject* newOwner )
|
||||||
: mOwner(newOwner)
|
: mOwner(newOwner)
|
||||||
{
|
{
|
||||||
mDashes = outline->mDashes;
|
mDashes = outline->mDashes;
|
||||||
mPen1 = outline->mPen1;
|
mPen1 = outline->mPen1;
|
||||||
mPen2 = outline->mPen2;
|
mPen2 = outline->mPen2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Outline Destructor
|
/// Outline Destructor
|
||||||
///
|
///
|
||||||
Outline::~Outline()
|
Outline::~Outline()
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone Outline
|
/// Clone Outline
|
||||||
///
|
///
|
||||||
Outline* Outline::clone( ModelObject* newOwner ) const
|
Outline* Outline::clone( ModelObject* newOwner ) const
|
||||||
{
|
{
|
||||||
return new Outline( this, newOwner );
|
return new Outline( this, newOwner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Draw Outline
|
/// Draw Outline
|
||||||
///
|
///
|
||||||
void Outline::draw( QPainter* painter ) const
|
void Outline::draw( QPainter* painter ) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->setBrush( Qt::NoBrush );
|
painter->setBrush( Qt::NoBrush );
|
||||||
|
|
||||||
painter->setPen( mPen1 );
|
painter->setPen( mPen1 );
|
||||||
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||||
|
|
||||||
painter->setPen( mPen2 );
|
painter->setPen( mPen2 );
|
||||||
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create path for testing for hover condition
|
/// Create path for testing for hover condition
|
||||||
///
|
///
|
||||||
QPainterPath Outline::hoverPath( double scale ) const
|
QPainterPath Outline::hoverPath( double scale ) const
|
||||||
{
|
{
|
||||||
double s = 1 / scale;
|
double s = 1 / scale;
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
path.addRect( -s*slopPixels, -s*slopPixels,
|
path.addRect( -s*slopPixels, -s*slopPixels,
|
||||||
mOwner->w().pt()+s*2*slopPixels, mOwner->h().pt()+s*2*slopPixels );
|
mOwner->w().pt()+s*2*slopPixels, mOwner->h().pt()+s*2*slopPixels );
|
||||||
path.closeSubpath();
|
path.closeSubpath();
|
||||||
path.addRect( s*slopPixels, s*slopPixels,
|
path.addRect( s*slopPixels, s*slopPixels,
|
||||||
mOwner->w().pt()-s*2*slopPixels, mOwner->h().pt()-s*2*slopPixels );
|
mOwner->w().pt()-s*2*slopPixels, mOwner->h().pt()-s*2*slopPixels );
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::model
|
}
|
||||||
|
}
|
||||||
|
|||||||
+39
-36
@@ -26,53 +26,56 @@
|
|||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
// Forward references
|
|
||||||
class ModelObject;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Outline Base Class
|
|
||||||
///
|
|
||||||
class Outline
|
|
||||||
{
|
{
|
||||||
////////////////////////////
|
|
||||||
// Lifecycle Methods
|
// Forward references
|
||||||
////////////////////////////
|
class ModelObject;
|
||||||
public:
|
|
||||||
Outline( ModelObject* owner );
|
|
||||||
Outline( const Outline* outline, ModelObject* newOwner );
|
///
|
||||||
virtual ~Outline();
|
/// Outline Base Class
|
||||||
|
///
|
||||||
|
class Outline
|
||||||
|
{
|
||||||
|
////////////////////////////
|
||||||
|
// Lifecycle Methods
|
||||||
|
////////////////////////////
|
||||||
|
public:
|
||||||
|
Outline( ModelObject* owner );
|
||||||
|
Outline( const Outline* outline, ModelObject* newOwner );
|
||||||
|
virtual ~Outline();
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Duplication
|
// Duplication
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
Outline* clone( ModelObject* newOwner ) const;
|
Outline* clone( ModelObject* newOwner ) const;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Drawing Methods
|
// Drawing Methods
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
public:
|
public:
|
||||||
void draw( QPainter* painter ) const;
|
void draw( QPainter* painter ) const;
|
||||||
QPainterPath hoverPath( double scale ) const;
|
QPainterPath hoverPath( double scale ) const;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
private:
|
private:
|
||||||
ModelObject* mOwner;
|
ModelObject* mOwner;
|
||||||
|
|
||||||
QVector<qreal> mDashes;
|
QVector<qreal> mDashes;
|
||||||
QPen mPen1;
|
QPen mPen1;
|
||||||
QPen mPen2;
|
QPen mPen2;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+360
-357
@@ -29,401 +29,404 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private
|
// Private
|
||||||
//
|
//
|
||||||
namespace
|
namespace
|
||||||
{
|
|
||||||
const QColor labelOutlineColor( 0, 0, 0 );
|
|
||||||
const double labelOutlineWidth = 0.25;
|
|
||||||
const double tickOffset = 2.25;
|
|
||||||
const double tickLength = 18;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PageRenderer::PageRenderer( const Model* model )
|
|
||||||
: mModel(nullptr), mNCopies(0), mStartLabel(0),
|
|
||||||
mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false),
|
|
||||||
mIPage(0), mIsMerge(false), mNPages(0)
|
|
||||||
{
|
|
||||||
if ( model )
|
|
||||||
{
|
{
|
||||||
setModel( model );
|
const QColor labelOutlineColor( 0, 0, 0 );
|
||||||
|
const double labelOutlineWidth = 0.25;
|
||||||
|
const double tickOffset = 2.25;
|
||||||
|
const double tickLength = 18;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::setModel( const Model* model )
|
PageRenderer::PageRenderer( const Model* model )
|
||||||
{
|
: mModel(nullptr), mNCopies(0), mStartLabel(0),
|
||||||
mModel = model;
|
mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false),
|
||||||
|
mIPage(0), mIsMerge(false), mNPages(0)
|
||||||
connect( mModel, SIGNAL(changed()), this, SLOT(onModelChanged()) );
|
|
||||||
|
|
||||||
onModelChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Model* PageRenderer::model() const
|
|
||||||
{
|
|
||||||
return mModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::onModelChanged()
|
|
||||||
{
|
|
||||||
mMerge = mModel->merge();
|
|
||||||
mOrigins = mModel->frame()->getOrigins();
|
|
||||||
mNLabelsPerPage = mModel->frame()->nLabels();
|
|
||||||
mIsMerge = ( dynamic_cast<const merge::None*>(mMerge) == nullptr );
|
|
||||||
updateNPages();
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::setNCopies( int nCopies )
|
|
||||||
{
|
|
||||||
mNCopies = nCopies;
|
|
||||||
updateNPages();
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::setStartLabel( int startLabel )
|
|
||||||
{
|
|
||||||
mStartLabel = startLabel;
|
|
||||||
updateNPages();
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::setPrintOutlines( bool printOutlinesFlag )
|
|
||||||
{
|
|
||||||
mPrintOutlines = printOutlinesFlag;
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::setPrintCropMarks( bool printCropMarksFlag )
|
|
||||||
{
|
|
||||||
mPrintCropMarks = printCropMarksFlag;
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::setPrintReverse( bool printReverseFlag )
|
|
||||||
{
|
|
||||||
mPrintReverse = printReverseFlag;
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::setIPage( int iPage )
|
|
||||||
{
|
|
||||||
mIPage = iPage;
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PageRenderer::nItems() const
|
|
||||||
{
|
|
||||||
return mLastLabel - mStartLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PageRenderer::nPages() const
|
|
||||||
{
|
|
||||||
return mNPages;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QRectF PageRenderer::pageRect() const
|
|
||||||
{
|
|
||||||
if ( mModel )
|
|
||||||
{
|
{
|
||||||
return QRectF( 0, 0, mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
|
if ( model )
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return QRectF( 0, 0, 0, 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::updateNPages()
|
|
||||||
{
|
|
||||||
if ( mModel )
|
|
||||||
{
|
|
||||||
if ( mIsMerge )
|
|
||||||
{
|
{
|
||||||
mLastLabel = mStartLabel + mNCopies*mMerge->nSelectedRecords();
|
setModel( model );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::setModel( const Model* model )
|
||||||
|
{
|
||||||
|
mModel = model;
|
||||||
|
|
||||||
|
connect( mModel, SIGNAL(changed()), this, SLOT(onModelChanged()) );
|
||||||
|
|
||||||
|
onModelChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Model* PageRenderer::model() const
|
||||||
|
{
|
||||||
|
return mModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::onModelChanged()
|
||||||
|
{
|
||||||
|
mMerge = mModel->merge();
|
||||||
|
mOrigins = mModel->frame()->getOrigins();
|
||||||
|
mNLabelsPerPage = mModel->frame()->nLabels();
|
||||||
|
mIsMerge = ( dynamic_cast<const merge::None*>(mMerge) == nullptr );
|
||||||
|
updateNPages();
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::setNCopies( int nCopies )
|
||||||
|
{
|
||||||
|
mNCopies = nCopies;
|
||||||
|
updateNPages();
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::setStartLabel( int startLabel )
|
||||||
|
{
|
||||||
|
mStartLabel = startLabel;
|
||||||
|
updateNPages();
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::setPrintOutlines( bool printOutlinesFlag )
|
||||||
|
{
|
||||||
|
mPrintOutlines = printOutlinesFlag;
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::setPrintCropMarks( bool printCropMarksFlag )
|
||||||
|
{
|
||||||
|
mPrintCropMarks = printCropMarksFlag;
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::setPrintReverse( bool printReverseFlag )
|
||||||
|
{
|
||||||
|
mPrintReverse = printReverseFlag;
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::setIPage( int iPage )
|
||||||
|
{
|
||||||
|
mIPage = iPage;
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PageRenderer::nItems() const
|
||||||
|
{
|
||||||
|
return mLastLabel - mStartLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PageRenderer::nPages() const
|
||||||
|
{
|
||||||
|
return mNPages;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QRectF PageRenderer::pageRect() const
|
||||||
|
{
|
||||||
|
if ( mModel )
|
||||||
|
{
|
||||||
|
return QRectF( 0, 0, mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLastLabel = mStartLabel + mNCopies;
|
return QRectF( 0, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::updateNPages()
|
||||||
|
{
|
||||||
|
if ( mModel )
|
||||||
|
{
|
||||||
|
if ( mIsMerge )
|
||||||
|
{
|
||||||
|
mLastLabel = mStartLabel + mNCopies*mMerge->nSelectedRecords();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLastLabel = mStartLabel + mNCopies;
|
||||||
|
}
|
||||||
|
|
||||||
mNPages = mLastLabel / mNLabelsPerPage;
|
mNPages = mLastLabel / mNLabelsPerPage;
|
||||||
if ( mLastLabel % mNLabelsPerPage )
|
if ( mLastLabel % mNLabelsPerPage )
|
||||||
{
|
{
|
||||||
mNPages++;
|
mNPages++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mNPages = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Print
|
|
||||||
///
|
|
||||||
void PageRenderer::print( QPrinter* printer ) const
|
|
||||||
{
|
|
||||||
QSizeF pageSize( mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
|
|
||||||
printer->setPageSize( QPageSize(pageSize, QPageSize::Point) );
|
|
||||||
printer->setFullPage( true );
|
|
||||||
printer->setPageMargins( 0, 0, 0, 0, QPrinter::Point );
|
|
||||||
|
|
||||||
QPainter painter( printer );
|
|
||||||
|
|
||||||
QRectF rectPx = printer->paperRect( QPrinter::DevicePixel );
|
|
||||||
QRectF rectPts = printer->paperRect( QPrinter::Point );
|
|
||||||
painter.scale( rectPx.width()/rectPts.width(), rectPx.height()/rectPts.height() );
|
|
||||||
|
|
||||||
for ( int iPage = 0; iPage < mNPages; iPage++ )
|
|
||||||
{
|
|
||||||
if ( iPage )
|
|
||||||
{
|
|
||||||
printer->newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
printPage( &painter, iPage );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Print page using persistent page number
|
|
||||||
///
|
|
||||||
void PageRenderer::printPage( QPainter* painter ) const
|
|
||||||
{
|
|
||||||
printPage( painter, mIPage );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Print page
|
|
||||||
///
|
|
||||||
void PageRenderer::printPage( QPainter* painter, int iPage ) const
|
|
||||||
{
|
|
||||||
if ( mModel )
|
|
||||||
{
|
|
||||||
if ( mIsMerge )
|
|
||||||
{
|
|
||||||
printMergePage( painter, iPage );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printSimplePage( painter, iPage );
|
mNPages = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
|
|
||||||
{
|
|
||||||
int iStart = 0;
|
|
||||||
int iEnd = mNLabelsPerPage;
|
|
||||||
|
|
||||||
if ( iPage == 0 )
|
|
||||||
{
|
|
||||||
iStart = mStartLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (mLastLabel / mNLabelsPerPage) == iPage )
|
|
||||||
{
|
|
||||||
iEnd = mLastLabel % mNLabelsPerPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
printCropMarks( painter );
|
|
||||||
|
|
||||||
for ( int i = iStart; i < iEnd; i++ )
|
|
||||||
{
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
|
||||||
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
clipLabel( painter );
|
|
||||||
printLabel( painter, nullptr );
|
|
||||||
|
|
||||||
painter->restore(); // From before clip
|
|
||||||
|
|
||||||
printOutline( painter );
|
|
||||||
|
|
||||||
painter->restore(); // From before translation
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::printMergePage( QPainter* painter, int iPage ) const
|
///
|
||||||
{
|
/// Print
|
||||||
int iRecord = 0;
|
///
|
||||||
int iStart = 0;
|
void PageRenderer::print( QPrinter* printer ) const
|
||||||
int iEnd = mNLabelsPerPage;
|
|
||||||
|
|
||||||
if ( iPage == 0 )
|
|
||||||
{
|
{
|
||||||
iStart = mStartLabel;
|
QSizeF pageSize( mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
|
||||||
}
|
printer->setPageSize( QPageSize(pageSize, QPageSize::Point) );
|
||||||
|
printer->setFullPage( true );
|
||||||
|
printer->setPageMargins( 0, 0, 0, 0, QPrinter::Point );
|
||||||
|
|
||||||
if ( (mLastLabel / mNLabelsPerPage) == iPage )
|
QPainter painter( printer );
|
||||||
{
|
|
||||||
iEnd = mLastLabel % mNLabelsPerPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<merge::Record*> records = mMerge->selectedRecords();
|
|
||||||
if ( records.size() )
|
|
||||||
{
|
|
||||||
iRecord = (iPage*mNLabelsPerPage + iStart - mStartLabel) % records.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
printCropMarks( painter );
|
|
||||||
|
|
||||||
for ( int i = iStart; i < iEnd; i++ )
|
|
||||||
{
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
|
||||||
|
|
||||||
painter->save();
|
QRectF rectPx = printer->paperRect( QPrinter::DevicePixel );
|
||||||
|
QRectF rectPts = printer->paperRect( QPrinter::Point );
|
||||||
|
painter.scale( rectPx.width()/rectPts.width(), rectPx.height()/rectPts.height() );
|
||||||
|
|
||||||
clipLabel( painter );
|
for ( int iPage = 0; iPage < mNPages; iPage++ )
|
||||||
printLabel( painter, records[iRecord] );
|
|
||||||
|
|
||||||
painter->restore(); // From before clip
|
|
||||||
|
|
||||||
printOutline( painter );
|
|
||||||
|
|
||||||
painter->restore(); // From before translation
|
|
||||||
|
|
||||||
iRecord = (iRecord + 1) % records.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::printCropMarks( QPainter* painter ) const
|
|
||||||
{
|
|
||||||
if ( mPrintCropMarks )
|
|
||||||
{
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
painter->setBrush( QBrush( Qt::NoBrush ) );
|
|
||||||
painter->setPen( QPen( labelOutlineColor, labelOutlineWidth ) );
|
|
||||||
|
|
||||||
Distance w = mModel->frame()->w();
|
|
||||||
Distance h = mModel->frame()->h();
|
|
||||||
|
|
||||||
foreach ( Layout* layout, mModel->frame()->layouts() )
|
|
||||||
{
|
{
|
||||||
Distance xMin = layout->x0();
|
if ( iPage )
|
||||||
Distance yMin = layout->y0();
|
|
||||||
Distance xMax = layout->x0() + layout->dx()*(layout->nx()-1) + w;
|
|
||||||
Distance yMax = layout->y0() + layout->dy()*(layout->ny()-1) + h;
|
|
||||||
|
|
||||||
for ( int ix = 0; ix < layout->nx(); ix++ )
|
|
||||||
{
|
{
|
||||||
Distance x1 = xMin + ix*layout->dx();
|
printer->newPage();
|
||||||
Distance x2 = x1 + w;
|
|
||||||
|
|
||||||
Distance y1 = max( yMin-tickOffset, Distance::pt(0) );
|
|
||||||
Distance y2 = max( y1-tickLength, Distance::pt(0) );
|
|
||||||
|
|
||||||
Distance y3 = min( yMax+tickOffset, mModel->tmplate()->pageHeight() );
|
|
||||||
Distance y4 = min( y3+tickLength, mModel->tmplate()->pageHeight() );
|
|
||||||
|
|
||||||
painter->drawLine( x1.pt(), y1.pt(), x1.pt(), y2.pt() );
|
|
||||||
painter->drawLine( x2.pt(), y1.pt(), x2.pt(), y2.pt() );
|
|
||||||
painter->drawLine( x1.pt(), y3.pt(), x1.pt(), y4.pt() );
|
|
||||||
painter->drawLine( x2.pt(), y3.pt(), x2.pt(), y4.pt() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int iy = 0; iy < layout->ny(); iy++ )
|
printPage( &painter, iPage );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Print page using persistent page number
|
||||||
|
///
|
||||||
|
void PageRenderer::printPage( QPainter* painter ) const
|
||||||
|
{
|
||||||
|
printPage( painter, mIPage );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Print page
|
||||||
|
///
|
||||||
|
void PageRenderer::printPage( QPainter* painter, int iPage ) const
|
||||||
|
{
|
||||||
|
if ( mModel )
|
||||||
|
{
|
||||||
|
if ( mIsMerge )
|
||||||
{
|
{
|
||||||
Distance y1 = yMin + iy*layout->dy();
|
printMergePage( painter, iPage );
|
||||||
Distance y2 = y1 + h;
|
}
|
||||||
|
else
|
||||||
Distance x1 = max( xMin-tickOffset, Distance::pt(0) );
|
{
|
||||||
Distance x2 = max( x1-tickLength, Distance::pt(0) );
|
printSimplePage( painter, iPage );
|
||||||
|
|
||||||
Distance x3 = min( xMax+tickOffset, mModel->tmplate()->pageWidth() );
|
|
||||||
Distance x4 = min( x3+tickLength, mModel->tmplate()->pageWidth() );
|
|
||||||
|
|
||||||
painter->drawLine( x1.pt(), y1.pt(), x2.pt(), y1.pt() );
|
|
||||||
painter->drawLine( x1.pt(), y2.pt(), x2.pt(), y2.pt() );
|
|
||||||
painter->drawLine( x3.pt(), y1.pt(), x4.pt(), y1.pt() );
|
|
||||||
painter->drawLine( x3.pt(), y2.pt(), x4.pt(), y2.pt() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
void PageRenderer::printSimplePage( QPainter* painter, int iPage ) const
|
||||||
|
{
|
||||||
|
int iStart = 0;
|
||||||
|
int iEnd = mNLabelsPerPage;
|
||||||
|
|
||||||
|
if ( iPage == 0 )
|
||||||
|
{
|
||||||
|
iStart = mStartLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (mLastLabel / mNLabelsPerPage) == iPage )
|
||||||
|
{
|
||||||
|
iEnd = mLastLabel % mNLabelsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
printCropMarks( painter );
|
||||||
|
|
||||||
|
for ( int i = iStart; i < iEnd; i++ )
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||||
|
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
clipLabel( painter );
|
||||||
|
printLabel( painter, nullptr );
|
||||||
|
|
||||||
|
painter->restore(); // From before clip
|
||||||
|
|
||||||
|
printOutline( painter );
|
||||||
|
|
||||||
|
painter->restore(); // From before translation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::printOutline( QPainter* painter ) const
|
void PageRenderer::printMergePage( QPainter* painter, int iPage ) const
|
||||||
{
|
{
|
||||||
if ( mPrintOutlines )
|
int iRecord = 0;
|
||||||
|
int iStart = 0;
|
||||||
|
int iEnd = mNLabelsPerPage;
|
||||||
|
|
||||||
|
if ( iPage == 0 )
|
||||||
|
{
|
||||||
|
iStart = mStartLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (mLastLabel / mNLabelsPerPage) == iPage )
|
||||||
|
{
|
||||||
|
iEnd = mLastLabel % mNLabelsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<merge::Record*> records = mMerge->selectedRecords();
|
||||||
|
if ( records.size() )
|
||||||
|
{
|
||||||
|
iRecord = (iPage*mNLabelsPerPage + iStart - mStartLabel) % records.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
printCropMarks( painter );
|
||||||
|
|
||||||
|
for ( int i = iStart; i < iEnd; i++ )
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
painter->translate( mOrigins[i].x().pt(), mOrigins[i].y().pt() );
|
||||||
|
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
clipLabel( painter );
|
||||||
|
printLabel( painter, records[iRecord] );
|
||||||
|
|
||||||
|
painter->restore(); // From before clip
|
||||||
|
|
||||||
|
printOutline( painter );
|
||||||
|
|
||||||
|
painter->restore(); // From before translation
|
||||||
|
|
||||||
|
iRecord = (iRecord + 1) % records.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::printCropMarks( QPainter* painter ) const
|
||||||
|
{
|
||||||
|
if ( mPrintCropMarks )
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
painter->setBrush( QBrush( Qt::NoBrush ) );
|
||||||
|
painter->setPen( QPen( labelOutlineColor, labelOutlineWidth ) );
|
||||||
|
|
||||||
|
Distance w = mModel->frame()->w();
|
||||||
|
Distance h = mModel->frame()->h();
|
||||||
|
|
||||||
|
foreach ( Layout* layout, mModel->frame()->layouts() )
|
||||||
|
{
|
||||||
|
Distance xMin = layout->x0();
|
||||||
|
Distance yMin = layout->y0();
|
||||||
|
Distance xMax = layout->x0() + layout->dx()*(layout->nx()-1) + w;
|
||||||
|
Distance yMax = layout->y0() + layout->dy()*(layout->ny()-1) + h;
|
||||||
|
|
||||||
|
for ( int ix = 0; ix < layout->nx(); ix++ )
|
||||||
|
{
|
||||||
|
Distance x1 = xMin + ix*layout->dx();
|
||||||
|
Distance x2 = x1 + w;
|
||||||
|
|
||||||
|
Distance y1 = max( yMin-tickOffset, Distance::pt(0) );
|
||||||
|
Distance y2 = max( y1-tickLength, Distance::pt(0) );
|
||||||
|
|
||||||
|
Distance y3 = min( yMax+tickOffset, mModel->tmplate()->pageHeight() );
|
||||||
|
Distance y4 = min( y3+tickLength, mModel->tmplate()->pageHeight() );
|
||||||
|
|
||||||
|
painter->drawLine( x1.pt(), y1.pt(), x1.pt(), y2.pt() );
|
||||||
|
painter->drawLine( x2.pt(), y1.pt(), x2.pt(), y2.pt() );
|
||||||
|
painter->drawLine( x1.pt(), y3.pt(), x1.pt(), y4.pt() );
|
||||||
|
painter->drawLine( x2.pt(), y3.pt(), x2.pt(), y4.pt() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( int iy = 0; iy < layout->ny(); iy++ )
|
||||||
|
{
|
||||||
|
Distance y1 = yMin + iy*layout->dy();
|
||||||
|
Distance y2 = y1 + h;
|
||||||
|
|
||||||
|
Distance x1 = max( xMin-tickOffset, Distance::pt(0) );
|
||||||
|
Distance x2 = max( x1-tickLength, Distance::pt(0) );
|
||||||
|
|
||||||
|
Distance x3 = min( xMax+tickOffset, mModel->tmplate()->pageWidth() );
|
||||||
|
Distance x4 = min( x3+tickLength, mModel->tmplate()->pageWidth() );
|
||||||
|
|
||||||
|
painter->drawLine( x1.pt(), y1.pt(), x2.pt(), y1.pt() );
|
||||||
|
painter->drawLine( x1.pt(), y2.pt(), x2.pt(), y2.pt() );
|
||||||
|
painter->drawLine( x3.pt(), y1.pt(), x4.pt(), y1.pt() );
|
||||||
|
painter->drawLine( x3.pt(), y2.pt(), x4.pt(), y2.pt() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::printOutline( QPainter* painter ) const
|
||||||
|
{
|
||||||
|
if ( mPrintOutlines )
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
painter->setBrush( QBrush( Qt::NoBrush ) );
|
||||||
|
painter->setPen( QPen( labelOutlineColor, labelOutlineWidth ) );
|
||||||
|
|
||||||
|
painter->drawPath( mModel->frame()->path() );
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::clipLabel( QPainter* painter ) const
|
||||||
|
{
|
||||||
|
painter->setClipPath( mModel->frame()->clipPath() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PageRenderer::printLabel( QPainter* painter, merge::Record* record ) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->setBrush( QBrush( Qt::NoBrush ) );
|
if ( mModel->rotate() )
|
||||||
painter->setPen( QPen( labelOutlineColor, labelOutlineWidth ) );
|
{
|
||||||
|
painter->rotate( -90.0 );
|
||||||
|
painter->translate( -mModel->w().pt(), 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mPrintReverse )
|
||||||
|
{
|
||||||
|
painter->translate( mModel->w().pt(), 0 );
|
||||||
|
painter->scale( -1, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
mModel->draw( painter, false, record );
|
||||||
|
|
||||||
painter->drawPath( mModel->frame()->path() );
|
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PageRenderer::clipLabel( QPainter* painter ) const
|
|
||||||
{
|
|
||||||
painter->setClipPath( mModel->frame()->clipPath() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PageRenderer::printLabel( QPainter* painter, merge::Record* record ) const
|
|
||||||
{
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
if ( mModel->rotate() )
|
|
||||||
{
|
|
||||||
painter->rotate( -90.0 );
|
|
||||||
painter->translate( -mModel->w().pt(), 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( mPrintReverse )
|
|
||||||
{
|
|
||||||
painter->translate( mModel->w().pt(), 0 );
|
|
||||||
painter->scale( -1, 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
mModel->draw( painter, false, record );
|
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+76
-73
@@ -33,96 +33,99 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
// Forward references
|
|
||||||
class Model;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// PageRenderer Widget
|
|
||||||
///
|
|
||||||
class PageRenderer : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
// Forward references
|
||||||
|
class Model;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// PageRenderer Widget
|
||||||
|
///
|
||||||
|
class PageRenderer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
PageRenderer( const Model* model = nullptr );
|
PageRenderer( const Model* model = nullptr );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setModel( const Model* model );
|
void setModel( const Model* model );
|
||||||
const Model* model() const;
|
const Model* model() const;
|
||||||
void setNCopies( int nCopies );
|
void setNCopies( int nCopies );
|
||||||
void setStartLabel( int startLabel );
|
void setStartLabel( int startLabel );
|
||||||
void setPrintOutlines( bool printOutlinesFlag );
|
void setPrintOutlines( bool printOutlinesFlag );
|
||||||
void setPrintCropMarks( bool printCropMarksFlag );
|
void setPrintCropMarks( bool printCropMarksFlag );
|
||||||
void setPrintReverse( bool printReverseFlag );
|
void setPrintReverse( bool printReverseFlag );
|
||||||
void setIPage( int iPage );
|
void setIPage( int iPage );
|
||||||
int nItems() const;
|
int nItems() const;
|
||||||
int nPages() const;
|
int nPages() const;
|
||||||
QRectF pageRect() const;
|
QRectF pageRect() const;
|
||||||
void print( QPrinter* printer ) const;
|
void print( QPrinter* printer ) const;
|
||||||
void printPage( QPainter* painter ) const;
|
void printPage( QPainter* painter ) const;
|
||||||
void printPage( QPainter* painter, int iPage ) const;
|
void printPage( QPainter* painter, int iPage ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private slots
|
// Private slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onModelChanged();
|
void onModelChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Internal Methods
|
// Internal Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void updateNPages();
|
void updateNPages();
|
||||||
void printSimplePage( QPainter* painter, int iPage ) const;
|
void printSimplePage( QPainter* painter, int iPage ) const;
|
||||||
void printMergePage( QPainter* painter, int iPage ) const;
|
void printMergePage( QPainter* painter, int iPage ) const;
|
||||||
void printCropMarks( QPainter* painter ) const;
|
void printCropMarks( QPainter* painter ) const;
|
||||||
void printOutline( QPainter* painter ) const;
|
void printOutline( QPainter* painter ) const;
|
||||||
void clipLabel( QPainter* painter ) const;
|
void clipLabel( QPainter* painter ) const;
|
||||||
void printLabel( QPainter* painter, merge::Record* record ) const;
|
void printLabel( QPainter* painter, merge::Record* record ) const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
const Model* mModel;
|
const Model* mModel;
|
||||||
const merge::Merge* mMerge;
|
const merge::Merge* mMerge;
|
||||||
|
|
||||||
int mNCopies;
|
int mNCopies;
|
||||||
int mStartLabel;
|
int mStartLabel;
|
||||||
int mLastLabel;
|
int mLastLabel;
|
||||||
bool mPrintOutlines;
|
bool mPrintOutlines;
|
||||||
bool mPrintCropMarks;
|
bool mPrintCropMarks;
|
||||||
bool mPrintReverse;
|
bool mPrintReverse;
|
||||||
int mIPage;
|
int mIPage;
|
||||||
|
|
||||||
bool mIsMerge;
|
bool mIsMerge;
|
||||||
int mNPages;
|
int mNPages;
|
||||||
int mNLabelsPerPage;
|
int mNLabelsPerPage;
|
||||||
|
|
||||||
QVector<Point> mOrigins;
|
QVector<Point> mOrigins;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+42
-39
@@ -21,59 +21,62 @@
|
|||||||
#include "Paper.h"
|
#include "Paper.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
|
{
|
||||||
|
|
||||||
Paper::Paper( const QString& id,
|
Paper::Paper( const QString& id,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const Distance& width,
|
const Distance& width,
|
||||||
const Distance& height,
|
const Distance& height,
|
||||||
const QString& pwgSize )
|
const QString& pwgSize )
|
||||||
: mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
: mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Paper::id() const
|
QString Paper::id() const
|
||||||
{
|
{
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Paper::name() const
|
QString Paper::name() const
|
||||||
{
|
{
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance Paper::width() const
|
Distance Paper::width() const
|
||||||
{
|
{
|
||||||
return mWidth;
|
return mWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance Paper::height() const
|
Distance Paper::height() const
|
||||||
{
|
{
|
||||||
return mHeight;
|
return mHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Paper::pwgSize() const
|
QString Paper::pwgSize() const
|
||||||
{
|
{
|
||||||
return mPwgSize;
|
return mPwgSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Paper::isSizeIso() const
|
bool Paper::isSizeIso() const
|
||||||
{
|
{
|
||||||
return mPwgSize.startsWith( "iso_" );
|
return mPwgSize.startsWith( "iso_" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Paper::isSizeUs() const
|
bool Paper::isSizeUs() const
|
||||||
{
|
{
|
||||||
return mPwgSize.startsWith( "na_" );
|
return mPwgSize.startsWith( "na_" );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels::model
|
}
|
||||||
|
}
|
||||||
|
|||||||
+29
-26
@@ -27,41 +27,44 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class Paper
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
Paper( const QString& id,
|
|
||||||
const QString& name,
|
|
||||||
const Distance& width,
|
|
||||||
const Distance& height,
|
|
||||||
const QString& pwgSize );
|
|
||||||
|
|
||||||
QString id() const;
|
class Paper
|
||||||
QString name() const;
|
{
|
||||||
|
public:
|
||||||
|
Paper( const QString& id,
|
||||||
|
const QString& name,
|
||||||
|
const Distance& width,
|
||||||
|
const Distance& height,
|
||||||
|
const QString& pwgSize );
|
||||||
|
|
||||||
/* Width */
|
QString id() const;
|
||||||
Distance width() const;
|
QString name() const;
|
||||||
|
|
||||||
/* Height */
|
/* Width */
|
||||||
Distance height() const;
|
Distance width() const;
|
||||||
|
|
||||||
/* PWG 5101.1-2002 size name */
|
/* Height */
|
||||||
QString pwgSize() const;
|
Distance height() const;
|
||||||
|
|
||||||
bool isSizeIso() const;
|
/* PWG 5101.1-2002 size name */
|
||||||
bool isSizeUs() const;
|
QString pwgSize() const;
|
||||||
|
|
||||||
private:
|
bool isSizeIso() const;
|
||||||
QString mId;
|
bool isSizeUs() const;
|
||||||
QString mName;
|
|
||||||
Distance mWidth;
|
|
||||||
Distance mHeight;
|
|
||||||
QString mPwgSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mId;
|
||||||
|
QString mName;
|
||||||
|
Distance mWidth;
|
||||||
|
Distance mHeight;
|
||||||
|
QString mPwgSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+33
-30
@@ -21,44 +21,47 @@
|
|||||||
#include "Point.h"
|
#include "Point.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
Point::Point() : mX(Distance(0)), mY(Distance(0))
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
}
|
Point::Point() : mX(Distance(0)), mY(Distance(0))
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Point::Point( Distance x, Distance y ) : mX(x), mY(y)
|
Point::Point( Distance x, Distance y ) : mX(x), mY(y)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance Point::x() const
|
Distance Point::x() const
|
||||||
{
|
{
|
||||||
return mX;
|
return mX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Distance Point::y() const
|
Distance Point::y() const
|
||||||
{
|
|
||||||
return mY;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Point::operator<( const Point &other ) const
|
|
||||||
{
|
|
||||||
if ( mY < other.mY )
|
|
||||||
{
|
{
|
||||||
return true;
|
return mY;
|
||||||
}
|
}
|
||||||
else if ( mY == other.mY )
|
|
||||||
{
|
|
||||||
return mX < other.mX;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
bool Point::operator<( const Point &other ) const
|
||||||
|
{
|
||||||
|
if ( mY < other.mY )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if ( mY == other.mY )
|
||||||
|
{
|
||||||
|
return mX < other.mX;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+16
-13
@@ -25,27 +25,30 @@
|
|||||||
#include "Distance.h"
|
#include "Distance.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
class Point
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
Point();
|
class Point
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Point();
|
||||||
|
|
||||||
Point( Distance x, Distance y );
|
Point( Distance x, Distance y );
|
||||||
|
|
||||||
Distance x() const;
|
Distance x() const;
|
||||||
Distance y() const;
|
Distance y() const;
|
||||||
|
|
||||||
bool operator<( const Point &other ) const;
|
bool operator<( const Point &other ) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Distance mX;
|
Distance mX;
|
||||||
Distance mY;
|
Distance mY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+111
-108
@@ -22,128 +22,131 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Constructor from QString
|
|
||||||
///
|
|
||||||
RawText::RawText( const QString& string ) : mString(string)
|
|
||||||
{
|
{
|
||||||
tokenize();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Constructor from QString
|
||||||
/// Constructor from C string operator
|
///
|
||||||
///
|
RawText::RawText( const QString& string ) : mString(string)
|
||||||
RawText::RawText( const char* cString ) : mString(QString(cString))
|
|
||||||
{
|
|
||||||
tokenize();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Access as QString
|
|
||||||
///
|
|
||||||
QString RawText::toString() const
|
|
||||||
{
|
|
||||||
return mString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Access as std::string
|
|
||||||
///
|
|
||||||
std::string RawText::toStdString() const
|
|
||||||
{
|
|
||||||
return mString.toStdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Expand all place holders
|
|
||||||
///
|
|
||||||
QString RawText::expand( merge::Record* record ) const
|
|
||||||
{
|
|
||||||
QString text;
|
|
||||||
|
|
||||||
foreach ( const Token& token, mTokens )
|
|
||||||
{
|
{
|
||||||
if ( token.isField )
|
tokenize();
|
||||||
{
|
|
||||||
text += token.field.evaluate( record );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
text += token.text;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///
|
||||||
///
|
/// Constructor from C string operator
|
||||||
/// Does raw text contain place holders?
|
///
|
||||||
///
|
RawText::RawText( const char* cString ) : mString(QString(cString))
|
||||||
bool RawText::hasPlaceHolders() const
|
|
||||||
{
|
|
||||||
QRegularExpression re("\\${\\w+}");
|
|
||||||
return mString.contains( re );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Is raw text empty?
|
|
||||||
///
|
|
||||||
bool RawText::isEmpty() const
|
|
||||||
{
|
|
||||||
return mString.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Tokenize string
|
|
||||||
///
|
|
||||||
void RawText::tokenize()
|
|
||||||
{
|
|
||||||
Token token;
|
|
||||||
|
|
||||||
QStringRef s = &mString;
|
|
||||||
while ( s.size() )
|
|
||||||
{
|
{
|
||||||
SubstitutionField field;
|
tokenize();
|
||||||
if ( SubstitutionField::parse( s, field ) )
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Access as QString
|
||||||
|
///
|
||||||
|
QString RawText::toString() const
|
||||||
|
{
|
||||||
|
return mString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Access as std::string
|
||||||
|
///
|
||||||
|
std::string RawText::toStdString() const
|
||||||
|
{
|
||||||
|
return mString.toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Expand all place holders
|
||||||
|
///
|
||||||
|
QString RawText::expand( merge::Record* record ) const
|
||||||
|
{
|
||||||
|
QString text;
|
||||||
|
|
||||||
|
foreach ( const Token& token, mTokens )
|
||||||
{
|
{
|
||||||
// Finalize current text token, if apropos
|
if ( token.isField )
|
||||||
if ( !token.text.isEmpty() )
|
|
||||||
{
|
{
|
||||||
token.isField = false;
|
text += token.field.evaluate( record );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text += token.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Does raw text contain place holders?
|
||||||
|
///
|
||||||
|
bool RawText::hasPlaceHolders() const
|
||||||
|
{
|
||||||
|
QRegularExpression re("\\${\\w+}");
|
||||||
|
return mString.contains( re );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Is raw text empty?
|
||||||
|
///
|
||||||
|
bool RawText::isEmpty() const
|
||||||
|
{
|
||||||
|
return mString.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Tokenize string
|
||||||
|
///
|
||||||
|
void RawText::tokenize()
|
||||||
|
{
|
||||||
|
Token token;
|
||||||
|
|
||||||
|
QStringRef s = &mString;
|
||||||
|
while ( s.size() )
|
||||||
|
{
|
||||||
|
SubstitutionField field;
|
||||||
|
if ( SubstitutionField::parse( s, field ) )
|
||||||
|
{
|
||||||
|
// Finalize current text token, if apropos
|
||||||
|
if ( !token.text.isEmpty() )
|
||||||
|
{
|
||||||
|
token.isField = false;
|
||||||
|
mTokens.append( token );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create and finalize field token
|
||||||
|
token.isField = true;
|
||||||
|
token.text = "";
|
||||||
|
token.field = field;
|
||||||
mTokens.append( token );
|
mTokens.append( token );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// Create and finalize field token
|
{
|
||||||
token.isField = true;
|
token.text += s[0];
|
||||||
token.text = "";
|
s = s.mid(1);
|
||||||
token.field = field;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finalize last text token, if apropos
|
||||||
|
if ( !token.text.isEmpty() )
|
||||||
|
{
|
||||||
|
token.isField = false;
|
||||||
mTokens.append( token );
|
mTokens.append( token );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
token.text += s[0];
|
|
||||||
s = s.mid(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finalize last text token, if apropos
|
|
||||||
if ( !token.text.isEmpty() )
|
|
||||||
{
|
|
||||||
token.isField = false;
|
|
||||||
mTokens.append( token );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
}
|
||||||
|
}
|
||||||
|
|||||||
+47
-44
@@ -27,57 +27,60 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Raw Text Type
|
|
||||||
///
|
|
||||||
struct RawText
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Life Cycle
|
/// Raw Text Type
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
struct RawText
|
||||||
RawText() = default;
|
|
||||||
RawText( const QString& string );
|
|
||||||
RawText( const char* cString );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Misc. Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
QString toString() const;
|
|
||||||
std::string toStdString() const;
|
|
||||||
QString expand( merge::Record* record ) const;
|
|
||||||
bool hasPlaceHolders() const;
|
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
void tokenize();
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Data
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
QString mString;
|
|
||||||
|
|
||||||
struct Token
|
|
||||||
{
|
{
|
||||||
bool isField;
|
|
||||||
QString text;
|
/////////////////////////////////
|
||||||
SubstitutionField field;
|
// Life Cycle
|
||||||
};
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
RawText() = default;
|
||||||
|
RawText( const QString& string );
|
||||||
|
RawText( const char* cString );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Misc. Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
QString toString() const;
|
||||||
|
std::string toStdString() const;
|
||||||
|
QString expand( merge::Record* record ) const;
|
||||||
|
bool hasPlaceHolders() const;
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
|
||||||
QList<Token> mTokens;
|
/////////////////////////////////
|
||||||
|
// Private Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
void tokenize();
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
QString mString;
|
||||||
|
|
||||||
};
|
struct Token
|
||||||
|
{
|
||||||
|
bool isField;
|
||||||
|
QString text;
|
||||||
|
SubstitutionField field;
|
||||||
|
};
|
||||||
|
|
||||||
|
QList<Token> mTokens;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+111
-108
@@ -21,114 +21,117 @@
|
|||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Region::Region() : mX1(0), mY1(0), mX2(0), mY2(0)
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
Region::Region() : mX1(0), mY1(0), mX2(0), mY2(0)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
Region::Region( const Distance& x1, const Distance& y1,
|
||||||
|
const Distance& x2, const Distance& y2 )
|
||||||
|
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get x1
|
||||||
|
///
|
||||||
|
Distance Region::x1() const
|
||||||
|
{
|
||||||
|
return mX1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set x1
|
||||||
|
///
|
||||||
|
void Region::setX1( const Distance& value )
|
||||||
|
{
|
||||||
|
mX1 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get y1
|
||||||
|
///
|
||||||
|
Distance Region::y1() const
|
||||||
|
{
|
||||||
|
return mY1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set y1
|
||||||
|
///
|
||||||
|
void Region::setY1( const Distance& value )
|
||||||
|
{
|
||||||
|
mY1 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get x2
|
||||||
|
///
|
||||||
|
Distance Region::x2() const
|
||||||
|
{
|
||||||
|
return mX2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set x2
|
||||||
|
///
|
||||||
|
void Region::setX2( const Distance& value )
|
||||||
|
{
|
||||||
|
mX2 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get y2
|
||||||
|
///
|
||||||
|
Distance Region::y2() const
|
||||||
|
{
|
||||||
|
return mY2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set y2
|
||||||
|
///
|
||||||
|
void Region::setY2( const Distance& value )
|
||||||
|
{
|
||||||
|
mY2 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert to a QRectF
|
||||||
|
///
|
||||||
|
QRectF Region::rect() const
|
||||||
|
{
|
||||||
|
QRectF r;
|
||||||
|
|
||||||
|
r.setX( min( mX1, mX2 ).pt() );
|
||||||
|
r.setY( min( mY1, mY2 ).pt() );
|
||||||
|
r.setWidth( fabs( mX2 - mX1 ).pt() );
|
||||||
|
r.setHeight( fabs( mY2 - mY1 ).pt() );
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Region::Region( const Distance& x1, const Distance& y1,
|
|
||||||
const Distance& x2, const Distance& y2 )
|
|
||||||
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get x1
|
|
||||||
///
|
|
||||||
Distance Region::x1() const
|
|
||||||
{
|
|
||||||
return mX1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Set x1
|
|
||||||
///
|
|
||||||
void Region::setX1( const Distance& value )
|
|
||||||
{
|
|
||||||
mX1 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get y1
|
|
||||||
///
|
|
||||||
Distance Region::y1() const
|
|
||||||
{
|
|
||||||
return mY1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Set y1
|
|
||||||
///
|
|
||||||
void Region::setY1( const Distance& value )
|
|
||||||
{
|
|
||||||
mY1 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get x2
|
|
||||||
///
|
|
||||||
Distance Region::x2() const
|
|
||||||
{
|
|
||||||
return mX2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Set x2
|
|
||||||
///
|
|
||||||
void Region::setX2( const Distance& value )
|
|
||||||
{
|
|
||||||
mX2 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get y2
|
|
||||||
///
|
|
||||||
Distance Region::y2() const
|
|
||||||
{
|
|
||||||
return mY2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Set y2
|
|
||||||
///
|
|
||||||
void Region::setY2( const Distance& value )
|
|
||||||
{
|
|
||||||
mY2 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Convert to a QRectF
|
|
||||||
///
|
|
||||||
QRectF Region::rect() const
|
|
||||||
{
|
|
||||||
QRectF r;
|
|
||||||
|
|
||||||
r.setX( min( mX1, mX2 ).pt() );
|
|
||||||
r.setY( min( mY1, mY2 ).pt() );
|
|
||||||
r.setWidth( fabs( mX2 - mX1 ).pt() );
|
|
||||||
r.setHeight( fabs( mY2 - mY1 ).pt() );
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+54
-51
@@ -27,74 +27,77 @@
|
|||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Label Region Type
|
|
||||||
///
|
|
||||||
struct Region
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Constructors
|
/// Label Region Type
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
struct Region
|
||||||
Region();
|
{
|
||||||
Region( const Distance& x1, const Distance& y1,
|
|
||||||
const Distance& x2, const Distance& y2 );
|
/////////////////////////////////
|
||||||
|
// Constructors
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
Region();
|
||||||
|
Region( const Distance& x1, const Distance& y1,
|
||||||
|
const Distance& x2, const Distance& y2 );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// X1 Property
|
// X1 Property
|
||||||
//
|
//
|
||||||
Distance x1() const;
|
Distance x1() const;
|
||||||
void setX1( const Distance& value );
|
void setX1( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Y1 Property
|
// Y1 Property
|
||||||
//
|
//
|
||||||
Distance y1() const;
|
Distance y1() const;
|
||||||
void setY1( const Distance& value );
|
void setY1( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// X2 Property
|
// X2 Property
|
||||||
//
|
//
|
||||||
Distance x2() const;
|
Distance x2() const;
|
||||||
void setX2( const Distance& value );
|
void setX2( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Y2 Property
|
// Y2 Property
|
||||||
//
|
//
|
||||||
Distance y2() const;
|
Distance y2() const;
|
||||||
void setY2( const Distance& value );
|
void setY2( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Methods
|
// Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QRectF rect() const;
|
QRectF rect() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
Distance mX1;
|
Distance mX1;
|
||||||
Distance mY1;
|
Distance mY1;
|
||||||
Distance mX2;
|
Distance mX2;
|
||||||
Distance mY2;
|
Distance mY2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+227
-224
@@ -25,237 +25,240 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
//
|
|
||||||
// Static data
|
|
||||||
//
|
|
||||||
Settings* Settings::mInstance = nullptr;
|
|
||||||
|
|
||||||
|
|
||||||
Settings::Settings()
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
}
|
//
|
||||||
|
// Static data
|
||||||
|
//
|
||||||
|
Settings* Settings::mInstance = nullptr;
|
||||||
|
|
||||||
|
|
||||||
void Settings::init()
|
Settings::Settings()
|
||||||
{
|
|
||||||
if ( mInstance == nullptr )
|
|
||||||
{
|
{
|
||||||
mInstance = new Settings();
|
// empty
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Settings* Settings::instance()
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
|
|
||||||
return mInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Units Settings::units()
|
|
||||||
{
|
|
||||||
// Guess at a suitable default
|
|
||||||
QString defaultIdString;
|
|
||||||
if ( QLocale::system().measurementSystem() == QLocale::ImperialSystem )
|
|
||||||
{
|
|
||||||
defaultIdString = Units(Units::IN).toIdString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
defaultIdString = Units(Units::MM).toIdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
mInstance->beginGroup( "Locale" );
|
|
||||||
QString idString = mInstance->value( "units", defaultIdString ).toString();
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
return Units( idString );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Settings::setUnits( const Units& units )
|
|
||||||
{
|
|
||||||
QString idString = units.toIdString();
|
|
||||||
|
|
||||||
mInstance->beginGroup( "Locale" );
|
|
||||||
mInstance->setValue( "units", idString );
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
emit mInstance->changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Settings::searchIsoPaperSizes()
|
|
||||||
{
|
|
||||||
// Guess at a suitable default
|
|
||||||
bool defaultValue;
|
|
||||||
switch (QLocale::system().country())
|
|
||||||
{
|
|
||||||
case QLocale::UnitedStates:
|
|
||||||
case QLocale::Canada:
|
|
||||||
defaultValue = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
defaultValue = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
bool returnValue = mInstance->value( "isoPaperSizes", defaultValue ).toBool();
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Settings::setSearchIsoPaperSizes( bool searchIsoPaperSizes )
|
|
||||||
{
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
mInstance->setValue( "isoPaperSizes", searchIsoPaperSizes );
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
emit mInstance->changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Settings::searchUsPaperSizes()
|
|
||||||
{
|
|
||||||
// Guess at a suitable default
|
|
||||||
bool defaultValue;
|
|
||||||
switch (QLocale::system().country())
|
|
||||||
{
|
|
||||||
case QLocale::UnitedStates:
|
|
||||||
case QLocale::Canada:
|
|
||||||
defaultValue = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
defaultValue = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
bool returnValue = mInstance->value( "usPaperSizes", defaultValue ).toBool();
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Settings::setSearchUsPaperSizes( bool searchUsPaperSizes )
|
|
||||||
{
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
mInstance->setValue( "usPaperSizes", searchUsPaperSizes );
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
emit mInstance->changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Settings::searchOtherPaperSizes()
|
|
||||||
{
|
|
||||||
// Guess at a suitable default
|
|
||||||
bool defaultValue = true;
|
|
||||||
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
bool returnValue = mInstance->value( "otherPaperSizes", defaultValue ).toBool();
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Settings::setSearchOtherPaperSizes( bool searchOtherPaperSizes )
|
|
||||||
{
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
mInstance->setValue( "otherPaperSizes", searchOtherPaperSizes );
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
emit mInstance->changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Settings::searchAllCategories()
|
|
||||||
{
|
|
||||||
// Guess at a suitable default
|
|
||||||
bool defaultValue = true;
|
|
||||||
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
bool returnValue = mInstance->value( "allCategories", defaultValue ).toBool();
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Settings::setSearchAllCategories( bool searchAllCategories )
|
|
||||||
{
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
mInstance->setValue( "allCategories", searchAllCategories );
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
emit mInstance->changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QStringList Settings::searchCategoryList()
|
|
||||||
{
|
|
||||||
QStringList defaultList;
|
|
||||||
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
QStringList returnList = mInstance->value( "categoryList", defaultList ).toStringList();
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Settings::setSearchCategoryList( const QStringList& searchCategoryList )
|
|
||||||
{
|
|
||||||
mInstance->beginGroup( "Search" );
|
|
||||||
mInstance->setValue( "categoryList", searchCategoryList );
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
emit mInstance->changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QStringList Settings::recentTemplateList()
|
|
||||||
{
|
|
||||||
QStringList defaultList;
|
|
||||||
|
|
||||||
mInstance->beginGroup( "Recent" );
|
|
||||||
QStringList returnList = mInstance->value( "templates", defaultList ).toStringList();
|
|
||||||
mInstance->endGroup();
|
|
||||||
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Settings::addToRecentTemplateList( const QString& name )
|
|
||||||
{
|
|
||||||
mInstance->beginGroup( "Recent" );
|
|
||||||
|
|
||||||
QStringList list = mInstance->value( "templates" ).toStringList();
|
|
||||||
|
|
||||||
list.removeAll( name );
|
|
||||||
list.prepend( name );
|
|
||||||
while ( list.count() > 10 )
|
|
||||||
{
|
|
||||||
list.removeLast();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mInstance->setValue( "templates", list );
|
|
||||||
|
|
||||||
mInstance->endGroup();
|
void Settings::init()
|
||||||
|
{
|
||||||
|
if ( mInstance == nullptr )
|
||||||
|
{
|
||||||
|
mInstance = new Settings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Settings* Settings::instance()
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
|
||||||
|
return mInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Units Settings::units()
|
||||||
|
{
|
||||||
|
// Guess at a suitable default
|
||||||
|
QString defaultIdString;
|
||||||
|
if ( QLocale::system().measurementSystem() == QLocale::ImperialSystem )
|
||||||
|
{
|
||||||
|
defaultIdString = Units(Units::IN).toIdString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
defaultIdString = Units(Units::MM).toIdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
mInstance->beginGroup( "Locale" );
|
||||||
|
QString idString = mInstance->value( "units", defaultIdString ).toString();
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
return Units( idString );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Settings::setUnits( const Units& units )
|
||||||
|
{
|
||||||
|
QString idString = units.toIdString();
|
||||||
|
|
||||||
|
mInstance->beginGroup( "Locale" );
|
||||||
|
mInstance->setValue( "units", idString );
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
emit mInstance->changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Settings::searchIsoPaperSizes()
|
||||||
|
{
|
||||||
|
// Guess at a suitable default
|
||||||
|
bool defaultValue;
|
||||||
|
switch (QLocale::system().country())
|
||||||
|
{
|
||||||
|
case QLocale::UnitedStates:
|
||||||
|
case QLocale::Canada:
|
||||||
|
defaultValue = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
defaultValue = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
bool returnValue = mInstance->value( "isoPaperSizes", defaultValue ).toBool();
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Settings::setSearchIsoPaperSizes( bool searchIsoPaperSizes )
|
||||||
|
{
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
mInstance->setValue( "isoPaperSizes", searchIsoPaperSizes );
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
emit mInstance->changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Settings::searchUsPaperSizes()
|
||||||
|
{
|
||||||
|
// Guess at a suitable default
|
||||||
|
bool defaultValue;
|
||||||
|
switch (QLocale::system().country())
|
||||||
|
{
|
||||||
|
case QLocale::UnitedStates:
|
||||||
|
case QLocale::Canada:
|
||||||
|
defaultValue = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
defaultValue = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
bool returnValue = mInstance->value( "usPaperSizes", defaultValue ).toBool();
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Settings::setSearchUsPaperSizes( bool searchUsPaperSizes )
|
||||||
|
{
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
mInstance->setValue( "usPaperSizes", searchUsPaperSizes );
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
emit mInstance->changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Settings::searchOtherPaperSizes()
|
||||||
|
{
|
||||||
|
// Guess at a suitable default
|
||||||
|
bool defaultValue = true;
|
||||||
|
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
bool returnValue = mInstance->value( "otherPaperSizes", defaultValue ).toBool();
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Settings::setSearchOtherPaperSizes( bool searchOtherPaperSizes )
|
||||||
|
{
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
mInstance->setValue( "otherPaperSizes", searchOtherPaperSizes );
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
emit mInstance->changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Settings::searchAllCategories()
|
||||||
|
{
|
||||||
|
// Guess at a suitable default
|
||||||
|
bool defaultValue = true;
|
||||||
|
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
bool returnValue = mInstance->value( "allCategories", defaultValue ).toBool();
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Settings::setSearchAllCategories( bool searchAllCategories )
|
||||||
|
{
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
mInstance->setValue( "allCategories", searchAllCategories );
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
emit mInstance->changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList Settings::searchCategoryList()
|
||||||
|
{
|
||||||
|
QStringList defaultList;
|
||||||
|
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
QStringList returnList = mInstance->value( "categoryList", defaultList ).toStringList();
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
return returnList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Settings::setSearchCategoryList( const QStringList& searchCategoryList )
|
||||||
|
{
|
||||||
|
mInstance->beginGroup( "Search" );
|
||||||
|
mInstance->setValue( "categoryList", searchCategoryList );
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
emit mInstance->changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList Settings::recentTemplateList()
|
||||||
|
{
|
||||||
|
QStringList defaultList;
|
||||||
|
|
||||||
|
mInstance->beginGroup( "Recent" );
|
||||||
|
QStringList returnList = mInstance->value( "templates", defaultList ).toStringList();
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
return returnList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Settings::addToRecentTemplateList( const QString& name )
|
||||||
|
{
|
||||||
|
mInstance->beginGroup( "Recent" );
|
||||||
|
|
||||||
|
QStringList list = mInstance->value( "templates" ).toStringList();
|
||||||
|
|
||||||
|
list.removeAll( name );
|
||||||
|
list.prepend( name );
|
||||||
|
while ( list.count() > 10 )
|
||||||
|
{
|
||||||
|
list.removeLast();
|
||||||
|
}
|
||||||
|
|
||||||
|
mInstance->setValue( "templates", list );
|
||||||
|
|
||||||
|
mInstance->endGroup();
|
||||||
|
|
||||||
|
emit mInstance->changed();
|
||||||
|
}
|
||||||
|
|
||||||
emit mInstance->changed();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+46
-43
@@ -28,69 +28,72 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Settings Singleton Class
|
|
||||||
///
|
|
||||||
class Settings : public QSettings
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
///
|
||||||
|
/// Settings Singleton Class
|
||||||
|
///
|
||||||
|
class Settings : public QSettings
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class PageSizeFamilty { ISO, US, };
|
enum class PageSizeFamilty { ISO, US, };
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
Settings();
|
Settings();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void init();
|
static void init();
|
||||||
static Settings* instance();
|
static Settings* instance();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Accessors
|
// Accessors
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
static Units units();
|
static Units units();
|
||||||
static void setUnits( const Units& units );
|
static void setUnits( const Units& units );
|
||||||
|
|
||||||
static bool searchIsoPaperSizes();
|
static bool searchIsoPaperSizes();
|
||||||
static void setSearchIsoPaperSizes( bool searchIsoPaperSizes );
|
static void setSearchIsoPaperSizes( bool searchIsoPaperSizes );
|
||||||
|
|
||||||
static bool searchUsPaperSizes();
|
static bool searchUsPaperSizes();
|
||||||
static void setSearchUsPaperSizes( bool searchUsPaperSizes );
|
static void setSearchUsPaperSizes( bool searchUsPaperSizes );
|
||||||
|
|
||||||
static bool searchOtherPaperSizes();
|
static bool searchOtherPaperSizes();
|
||||||
static void setSearchOtherPaperSizes( bool searchOtherPaperSizes );
|
static void setSearchOtherPaperSizes( bool searchOtherPaperSizes );
|
||||||
|
|
||||||
static bool searchAllCategories();
|
static bool searchAllCategories();
|
||||||
static void setSearchAllCategories( bool searchAllCategories );
|
static void setSearchAllCategories( bool searchAllCategories );
|
||||||
|
|
||||||
static QStringList searchCategoryList();
|
static QStringList searchCategoryList();
|
||||||
static void setSearchCategoryList( const QStringList& searchCategoryList );
|
static void setSearchCategoryList( const QStringList& searchCategoryList );
|
||||||
|
|
||||||
static QStringList recentTemplateList();
|
static QStringList recentTemplateList();
|
||||||
static void addToRecentTemplateList( const QString& name );
|
static void addToRecentTemplateList( const QString& name );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Settings* mInstance;
|
static Settings* mInstance;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+71
-68
@@ -21,74 +21,77 @@
|
|||||||
#include "Size.h"
|
#include "Size.h"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Size::Size() : mW(0), mH(0)
|
|
||||||
{
|
{
|
||||||
// empty
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
Size::Size() : mW(0), mH(0)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
Size::Size( const Distance& w, const Distance& h ) : mW(w), mH(h)
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get w
|
||||||
|
///
|
||||||
|
Distance Size::w() const
|
||||||
|
{
|
||||||
|
return mW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set w
|
||||||
|
///
|
||||||
|
void Size::setW( const Distance& value )
|
||||||
|
{
|
||||||
|
mW = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Get h
|
||||||
|
///
|
||||||
|
Distance Size::h() const
|
||||||
|
{
|
||||||
|
return mH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set h
|
||||||
|
///
|
||||||
|
void Size::setH( const Distance& value )
|
||||||
|
{
|
||||||
|
mH = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert to a QSizeF
|
||||||
|
///
|
||||||
|
QSizeF Size::qSizeF() const
|
||||||
|
{
|
||||||
|
QSizeF s;
|
||||||
|
|
||||||
|
s.setWidth( mW.pt() );
|
||||||
|
s.setHeight( mH.pt() );
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
Size::Size( const Distance& w, const Distance& h ) : mW(w), mH(h)
|
|
||||||
{
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get w
|
|
||||||
///
|
|
||||||
Distance Size::w() const
|
|
||||||
{
|
|
||||||
return mW;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Set w
|
|
||||||
///
|
|
||||||
void Size::setW( const Distance& value )
|
|
||||||
{
|
|
||||||
mW = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Get h
|
|
||||||
///
|
|
||||||
Distance Size::h() const
|
|
||||||
{
|
|
||||||
return mH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Set h
|
|
||||||
///
|
|
||||||
void Size::setH( const Distance& value )
|
|
||||||
{
|
|
||||||
mH = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Convert to a QSizeF
|
|
||||||
///
|
|
||||||
QSizeF Size::qSizeF() const
|
|
||||||
{
|
|
||||||
QSizeF s;
|
|
||||||
|
|
||||||
s.setWidth( mW.pt() );
|
|
||||||
s.setHeight( mH.pt() );
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels::model
|
|
||||||
|
|||||||
+41
-38
@@ -27,57 +27,60 @@
|
|||||||
#include <QSizeF>
|
#include <QSizeF>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels::model
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
namespace model
|
||||||
///
|
|
||||||
/// Size Type
|
|
||||||
///
|
|
||||||
class Size
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////
|
///
|
||||||
// Constructors
|
/// Size Type
|
||||||
/////////////////////////////////
|
///
|
||||||
public:
|
class Size
|
||||||
Size();
|
{
|
||||||
Size( const Distance& w, const Distance& h );
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Constructors
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
Size();
|
||||||
|
Size( const Distance& w, const Distance& h );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// w Property
|
// w Property
|
||||||
//
|
//
|
||||||
Distance w() const;
|
Distance w() const;
|
||||||
void setW( const Distance& value );
|
void setW( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// H Property
|
// H Property
|
||||||
//
|
//
|
||||||
Distance h() const;
|
Distance h() const;
|
||||||
void setH( const Distance& value );
|
void setH( const Distance& value );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Methods
|
// Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QSizeF qSizeF() const;
|
QSizeF qSizeF() const;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
Distance mW;
|
Distance mW;
|
||||||
Distance mH;
|
Distance mH;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user