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"
|
||||
|
||||
|
||||
namespace glabels::barcode
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
QStringList Backends::mBackendIdList;
|
||||
QMap<QString,QString> Backends::mBackendNameMap;
|
||||
|
||||
QList<Style> Backends::mStyleList;
|
||||
|
||||
|
||||
Backends::Backends()
|
||||
namespace barcode
|
||||
{
|
||||
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"),
|
||||
true, true, true, true, "1234567890", true, 10 );
|
||||
QList<Style> Backends::mStyleList;
|
||||
|
||||
|
||||
registerStyle( "upc-a", "", tr("UPC-A"),
|
||||
true, false, true, false, "12345678901", false, 11 );
|
||||
Backends::Backends()
|
||||
{
|
||||
registerStyle( "code39", "", tr("Code 39"),
|
||||
true, true, true, true, "1234567890", true, 10 );
|
||||
|
||||
registerStyle( "ean-13", "", tr("EAN-13"),
|
||||
true, false, true, false, "123456789012", false, 12 );
|
||||
registerStyle( "code39ext", "", tr("Code 39 Extended"),
|
||||
true, true, true, true, "1234567890", true, 10 );
|
||||
|
||||
registerStyle( "postnet", "", tr("POSTNET (any)"),
|
||||
false, false, true, false, "12345-6789-12", false, 11 );
|
||||
registerStyle( "upc-a", "", tr("UPC-A"),
|
||||
true, false, true, false, "12345678901", false, 11 );
|
||||
|
||||
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
|
||||
false, false, true, false, "12345", false, 5 );
|
||||
registerStyle( "ean-13", "", tr("EAN-13"),
|
||||
true, false, true, false, "123456789012", false, 12 );
|
||||
|
||||
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
|
||||
false, false, true, false, "12345-6789", false, 9 );
|
||||
registerStyle( "postnet", "", tr("POSTNET (any)"),
|
||||
false, false, true, false, "12345-6789-12", false, 11 );
|
||||
|
||||
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
|
||||
false, false, true, false, "12345-6789-12", false, 11 );
|
||||
registerStyle( "postnet-5", "", tr("POSTNET-5 (ZIP only)"),
|
||||
false, false, true, false, "12345", false, 5 );
|
||||
|
||||
registerStyle( "cepnet", "", tr("CEPNET"),
|
||||
false, false, true, false, "12345-678", false, 8 );
|
||||
registerStyle( "postnet-9", "", tr("POSTNET-9 (ZIP+4)"),
|
||||
false, false, true, false, "12345-6789", false, 9 );
|
||||
|
||||
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
|
||||
false, false, true, false, "12345678901234567890", false, 20 );
|
||||
registerStyle( "postnet-11", "", tr("POSTNET-11 (DPBC)"),
|
||||
false, false, true, false, "12345-6789-12", false, 11 );
|
||||
|
||||
registerStyle( "datamatrix", "", tr("IEC16022 (DataMatrix)"),
|
||||
false, false, true, false, "1234567890AB", false, 12 );
|
||||
registerStyle( "cepnet", "", tr("CEPNET"),
|
||||
false, false, true, false, "12345-678", false, 8 );
|
||||
|
||||
registerStyle( "onecode", "", tr("USPS Intelligent Mail"),
|
||||
false, false, true, false, "12345678901234567890", false, 20 );
|
||||
|
||||
registerStyle( "datamatrix", "", tr("IEC16022 (DataMatrix)"),
|
||||
false, false, true, false, "1234567890AB", false, 12 );
|
||||
|
||||
#if HAVE_GNU_BARCODE
|
||||
//
|
||||
// GNU Barcode backend
|
||||
//
|
||||
registerBackend( "gnu-barcode", "GNU Barcode" );
|
||||
//
|
||||
// GNU Barcode backend
|
||||
//
|
||||
registerBackend( "gnu-barcode", "GNU Barcode" );
|
||||
|
||||
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+2", GnuBarcode::Ean8_2::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+2", GnuBarcode::Ean13_2::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-a", GnuBarcode::UpcA::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-e", GnuBarcode::UpcE::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::isbn", GnuBarcode::Isbn::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::code128", GnuBarcode::Code128::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::code128c", GnuBarcode::Code128C::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::code128b", GnuBarcode::Code128B::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::i25", GnuBarcode::I25::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::cbr", GnuBarcode::Cbr::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::msi", GnuBarcode::Msi::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::pls", GnuBarcode::Pls::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::code93", GnuBarcode::Code93::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+2", GnuBarcode::Ean8_2::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+2", GnuBarcode::Ean13_2::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-a", GnuBarcode::UpcA::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-e", GnuBarcode::UpcE::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::isbn", GnuBarcode::Isbn::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::code128", GnuBarcode::Code128::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::code128c", GnuBarcode::Code128C::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::code128b", GnuBarcode::Code128B::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::i25", GnuBarcode::I25::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::cbr", GnuBarcode::Cbr::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::msi", GnuBarcode::Msi::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::pls", GnuBarcode::Pls::create );
|
||||
glbarcode::Factory::registerType( "gnu-barcode::code93", GnuBarcode::Code93::create );
|
||||
|
||||
registerStyle( "ean", "gnu-barcode", tr("EAN (any)"),
|
||||
true, true, true, false, "000000000000 00000", false, 17 );
|
||||
registerStyle( "ean-8", "gnu-barcode", tr("EAN-8"),
|
||||
true, true, true, false, "0000000", false, 7 );
|
||||
registerStyle( "ean-8+2", "gnu-barcode", tr("EAN-8+2"),
|
||||
true, true, true, false, "0000000 00", false, 9 );
|
||||
registerStyle( "ean-8+5", "gnu-barcode", tr("EAN-8+5"),
|
||||
true, true, true, false, "0000000 00000", false, 12 );
|
||||
registerStyle( "ean-13", "gnu-barcode", tr("EAN-13"),
|
||||
true, true, true, false, "000000000000", false, 12 );
|
||||
registerStyle( "ean-13+2", "gnu-barcode", tr("EAN-13+2"),
|
||||
true, true, true, false, "000000000000 00", false, 14 );
|
||||
registerStyle( "ean-13+5", "gnu-barcode", tr("EAN-13+5"),
|
||||
true, true, true, false, "000000000000 00000", false, 17 );
|
||||
registerStyle( "upc", "gnu-barcode", tr("UPC (UPC-A or UPC-E)"),
|
||||
true, true, true, false, "00000000000 00000", false, 16 );
|
||||
registerStyle( "upc-a", "gnu-barcode", tr("UPC-A"),
|
||||
true, true, true, false, "00000000000", false, 11 );
|
||||
registerStyle( "upc-a+2", "gnu-barcode", tr("UPC-A +2"),
|
||||
true, true, true, false, "00000000000 00", false, 13 );
|
||||
registerStyle( "upc-a+5", "gnu-barcode", tr("UPC-A +5"),
|
||||
true, true, true, false, "00000000000 00000", false, 16 );
|
||||
registerStyle( "upc-e", "gnu-barcode", tr("UPC-E"),
|
||||
true, true, true, false, "000000", false, 6 );
|
||||
registerStyle( "upc-e+2", "gnu-barcode", tr("UPC-E +2"),
|
||||
true, true, true, false, "000000 00", false, 8 );
|
||||
registerStyle( "upc-e+5", "gnu-barcode", tr("UPC-E +5"),
|
||||
true, true, true, false, "000000 00000", false, 11 );
|
||||
registerStyle( "isbn", "gnu-barcode", tr("ISBN"),
|
||||
true, true, true, true, "0-00000-000-0", false, 10 );
|
||||
registerStyle( "isbn+5", "gnu-barcode", tr("ISBN +5"),
|
||||
true, true, true, true, "0-00000-000-0 00000", false, 15 );
|
||||
registerStyle( "code39", "gnu-barcode", tr("Code 39"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "code128", "gnu-barcode", tr("Code 128"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "code128c", "gnu-barcode", tr("Code 128C"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code128b", "gnu-barcode", tr("Code 128B"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "i25", "gnu-barcode", tr("Interleaved 2 of 5"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "cbr", "gnu-barcode", tr("Codabar"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "msi", "gnu-barcode", tr("MSI"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "pls", "gnu-barcode", tr("Plessey"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "code93", "gnu-barcode", tr("Code 93"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "ean", "gnu-barcode", tr("EAN (any)"),
|
||||
true, true, true, false, "000000000000 00000", false, 17 );
|
||||
registerStyle( "ean-8", "gnu-barcode", tr("EAN-8"),
|
||||
true, true, true, false, "0000000", false, 7 );
|
||||
registerStyle( "ean-8+2", "gnu-barcode", tr("EAN-8+2"),
|
||||
true, true, true, false, "0000000 00", false, 9 );
|
||||
registerStyle( "ean-8+5", "gnu-barcode", tr("EAN-8+5"),
|
||||
true, true, true, false, "0000000 00000", false, 12 );
|
||||
registerStyle( "ean-13", "gnu-barcode", tr("EAN-13"),
|
||||
true, true, true, false, "000000000000", false, 12 );
|
||||
registerStyle( "ean-13+2", "gnu-barcode", tr("EAN-13+2"),
|
||||
true, true, true, false, "000000000000 00", false, 14 );
|
||||
registerStyle( "ean-13+5", "gnu-barcode", tr("EAN-13+5"),
|
||||
true, true, true, false, "000000000000 00000", false, 17 );
|
||||
registerStyle( "upc", "gnu-barcode", tr("UPC (UPC-A or UPC-E)"),
|
||||
true, true, true, false, "00000000000 00000", false, 16 );
|
||||
registerStyle( "upc-a", "gnu-barcode", tr("UPC-A"),
|
||||
true, true, true, false, "00000000000", false, 11 );
|
||||
registerStyle( "upc-a+2", "gnu-barcode", tr("UPC-A +2"),
|
||||
true, true, true, false, "00000000000 00", false, 13 );
|
||||
registerStyle( "upc-a+5", "gnu-barcode", tr("UPC-A +5"),
|
||||
true, true, true, false, "00000000000 00000", false, 16 );
|
||||
registerStyle( "upc-e", "gnu-barcode", tr("UPC-E"),
|
||||
true, true, true, false, "000000", false, 6 );
|
||||
registerStyle( "upc-e+2", "gnu-barcode", tr("UPC-E +2"),
|
||||
true, true, true, false, "000000 00", false, 8 );
|
||||
registerStyle( "upc-e+5", "gnu-barcode", tr("UPC-E +5"),
|
||||
true, true, true, false, "000000 00000", false, 11 );
|
||||
registerStyle( "isbn", "gnu-barcode", tr("ISBN"),
|
||||
true, true, true, true, "0-00000-000-0", false, 10 );
|
||||
registerStyle( "isbn+5", "gnu-barcode", tr("ISBN +5"),
|
||||
true, true, true, true, "0-00000-000-0 00000", false, 15 );
|
||||
registerStyle( "code39", "gnu-barcode", tr("Code 39"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "code128", "gnu-barcode", tr("Code 128"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "code128c", "gnu-barcode", tr("Code 128C"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code128b", "gnu-barcode", tr("Code 128B"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "i25", "gnu-barcode", tr("Interleaved 2 of 5"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "cbr", "gnu-barcode", tr("Codabar"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "msi", "gnu-barcode", tr("MSI"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "pls", "gnu-barcode", tr("Plessey"),
|
||||
true, true, true, true, "0000000000", true, 10 );
|
||||
registerStyle( "code93", "gnu-barcode", tr("Code 93"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
#endif // HAVE_GNU_BARCODE
|
||||
|
||||
#if HAVE_QRENCODE
|
||||
//
|
||||
// Libqrencode backend
|
||||
//
|
||||
registerBackend( "qrencode", "QREncode" );
|
||||
//
|
||||
// Libqrencode backend
|
||||
//
|
||||
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)"),
|
||||
false, false, true, false, "1234567890AB", false, 12 );
|
||||
registerStyle( "qrcode", "qrencode", tr("IEC18004 (QRCode)"),
|
||||
false, false, true, false, "1234567890AB", false, 12 );
|
||||
#endif // HAVE_QRENCODE
|
||||
|
||||
#if HAVE_ZINT
|
||||
//
|
||||
// Zint barcode backend
|
||||
//
|
||||
registerBackend( "zint", "Zint" );
|
||||
//
|
||||
// Zint barcode backend
|
||||
//
|
||||
registerBackend( "zint", "Zint" );
|
||||
|
||||
glbarcode::Factory::registerType( "zint::ausp", Zint::AusP::create );
|
||||
glbarcode::Factory::registerType( "zint::ausrp", Zint::AusRP::create );
|
||||
glbarcode::Factory::registerType( "zint::ausrt", Zint::AusRT::create );
|
||||
glbarcode::Factory::registerType( "zint::ausrd", Zint::AusRD::create );
|
||||
glbarcode::Factory::registerType( "zint::aztec", Zint::Aztec::create );
|
||||
glbarcode::Factory::registerType( "zint::azrun", Zint::Azrun::create );
|
||||
glbarcode::Factory::registerType( "zint::cbr", Zint::Cbr::create );
|
||||
glbarcode::Factory::registerType( "zint::code1", Zint::Code1::create );
|
||||
glbarcode::Factory::registerType( "zint::code11", Zint::Code11::create );
|
||||
glbarcode::Factory::registerType( "zint::c16k", Zint::C16k::create );
|
||||
glbarcode::Factory::registerType( "zint::c25m", Zint::C25m::create );
|
||||
glbarcode::Factory::registerType( "zint::c25i", Zint::C25i::create );
|
||||
glbarcode::Factory::registerType( "zint::c25dl", Zint::C25dl::create );
|
||||
glbarcode::Factory::registerType( "zint::code32", Zint::Code32::create );
|
||||
glbarcode::Factory::registerType( "zint::code39", Zint::Code39::create );
|
||||
glbarcode::Factory::registerType( "zint::code39e", Zint::Code39e::create );
|
||||
glbarcode::Factory::registerType( "zint::code49", Zint::Code49::create );
|
||||
glbarcode::Factory::registerType( "zint::code93", Zint::Code93::create );
|
||||
glbarcode::Factory::registerType( "zint::code128", Zint::Code128::create );
|
||||
glbarcode::Factory::registerType( "zint::code128b", Zint::Code128b::create );
|
||||
glbarcode::Factory::registerType( "zint::daft", Zint::Daft::create );
|
||||
glbarcode::Factory::registerType( "zint::dmtx", Zint::Dmtx::create );
|
||||
glbarcode::Factory::registerType( "zint::dpl", Zint::Dpl::create );
|
||||
glbarcode::Factory::registerType( "zint::dpi", Zint::Dpi::create );
|
||||
glbarcode::Factory::registerType( "zint::kix", Zint::Kix::create );
|
||||
glbarcode::Factory::registerType( "zint::ean", Zint::Ean::create );
|
||||
glbarcode::Factory::registerType( "zint::gmtx", Zint::Gmtx::create );
|
||||
glbarcode::Factory::registerType( "zint::gs1128", Zint::Gs1128::create );
|
||||
glbarcode::Factory::registerType( "zint::rss14", Zint::Rss14::create );
|
||||
glbarcode::Factory::registerType( "zint::rssltd", Zint::Rssltd::create );
|
||||
glbarcode::Factory::registerType( "zint::rssexp", Zint::Rssexp::create );
|
||||
glbarcode::Factory::registerType( "zint::rsss", Zint::Rsss::create );
|
||||
glbarcode::Factory::registerType( "zint::rssso", Zint::Rssso::create );
|
||||
glbarcode::Factory::registerType( "zint::rssse", Zint::Rssse::create );
|
||||
glbarcode::Factory::registerType( "zint::hibc128", Zint::Hibc128::create );
|
||||
glbarcode::Factory::registerType( "zint::hibc39", Zint::Hibc39::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcdm", Zint::Hibcdm::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcqr", Zint::Hibcqr::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcpdf", Zint::Hibcpdf::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcmpdf", Zint::Hibcmpdf::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcaz", Zint::Hibcaz::create );
|
||||
glbarcode::Factory::registerType( "zint::i25", Zint::I25::create );
|
||||
glbarcode::Factory::registerType( "zint::isbn", Zint::Isbn::create );
|
||||
glbarcode::Factory::registerType( "zint::itf14", Zint::Itf14::create );
|
||||
glbarcode::Factory::registerType( "zint::japan", Zint::Japan::create );
|
||||
glbarcode::Factory::registerType( "zint::korea", Zint::Korea::create );
|
||||
glbarcode::Factory::registerType( "zint::logm", Zint::Logm::create );
|
||||
glbarcode::Factory::registerType( "zint::maxi", Zint::Maxi::create );
|
||||
glbarcode::Factory::registerType( "zint::mpdf", Zint::Mpdf::create );
|
||||
glbarcode::Factory::registerType( "zint::mqr", Zint::Mqr::create );
|
||||
glbarcode::Factory::registerType( "zint::msi", Zint::Msi::create );
|
||||
glbarcode::Factory::registerType( "zint::nve", Zint::Nve::create );
|
||||
glbarcode::Factory::registerType( "zint::pdf", Zint::Pdf::create );
|
||||
glbarcode::Factory::registerType( "zint::pdft", Zint::Pdft::create );
|
||||
glbarcode::Factory::registerType( "zint::plan", Zint::Plan::create );
|
||||
glbarcode::Factory::registerType( "zint::postnet", Zint::Postnet::create );
|
||||
glbarcode::Factory::registerType( "zint::pharma", Zint::Pharma::create );
|
||||
glbarcode::Factory::registerType( "zint::pharma2", Zint::Pharma2::create );
|
||||
glbarcode::Factory::registerType( "zint::pzn", Zint::Pzn::create );
|
||||
glbarcode::Factory::registerType( "zint::qr", Zint::Qr::create );
|
||||
glbarcode::Factory::registerType( "zint::rm4", Zint::Rm4::create );
|
||||
glbarcode::Factory::registerType( "zint::tele", Zint::Tele::create );
|
||||
glbarcode::Factory::registerType( "zint::telex", Zint::Telex::create );
|
||||
glbarcode::Factory::registerType( "zint::upc-a", Zint::UpcA::create );
|
||||
glbarcode::Factory::registerType( "zint::upc-e", Zint::UpcE::create );
|
||||
glbarcode::Factory::registerType( "zint::usps", Zint::Usps::create );
|
||||
glbarcode::Factory::registerType( "zint::pls", Zint::Pls::create );
|
||||
glbarcode::Factory::registerType( "zint::ausp", Zint::AusP::create );
|
||||
glbarcode::Factory::registerType( "zint::ausrp", Zint::AusRP::create );
|
||||
glbarcode::Factory::registerType( "zint::ausrt", Zint::AusRT::create );
|
||||
glbarcode::Factory::registerType( "zint::ausrd", Zint::AusRD::create );
|
||||
glbarcode::Factory::registerType( "zint::aztec", Zint::Aztec::create );
|
||||
glbarcode::Factory::registerType( "zint::azrun", Zint::Azrun::create );
|
||||
glbarcode::Factory::registerType( "zint::cbr", Zint::Cbr::create );
|
||||
glbarcode::Factory::registerType( "zint::code1", Zint::Code1::create );
|
||||
glbarcode::Factory::registerType( "zint::code11", Zint::Code11::create );
|
||||
glbarcode::Factory::registerType( "zint::c16k", Zint::C16k::create );
|
||||
glbarcode::Factory::registerType( "zint::c25m", Zint::C25m::create );
|
||||
glbarcode::Factory::registerType( "zint::c25i", Zint::C25i::create );
|
||||
glbarcode::Factory::registerType( "zint::c25dl", Zint::C25dl::create );
|
||||
glbarcode::Factory::registerType( "zint::code32", Zint::Code32::create );
|
||||
glbarcode::Factory::registerType( "zint::code39", Zint::Code39::create );
|
||||
glbarcode::Factory::registerType( "zint::code39e", Zint::Code39e::create );
|
||||
glbarcode::Factory::registerType( "zint::code49", Zint::Code49::create );
|
||||
glbarcode::Factory::registerType( "zint::code93", Zint::Code93::create );
|
||||
glbarcode::Factory::registerType( "zint::code128", Zint::Code128::create );
|
||||
glbarcode::Factory::registerType( "zint::code128b", Zint::Code128b::create );
|
||||
glbarcode::Factory::registerType( "zint::daft", Zint::Daft::create );
|
||||
glbarcode::Factory::registerType( "zint::dmtx", Zint::Dmtx::create );
|
||||
glbarcode::Factory::registerType( "zint::dpl", Zint::Dpl::create );
|
||||
glbarcode::Factory::registerType( "zint::dpi", Zint::Dpi::create );
|
||||
glbarcode::Factory::registerType( "zint::kix", Zint::Kix::create );
|
||||
glbarcode::Factory::registerType( "zint::ean", Zint::Ean::create );
|
||||
glbarcode::Factory::registerType( "zint::gmtx", Zint::Gmtx::create );
|
||||
glbarcode::Factory::registerType( "zint::gs1128", Zint::Gs1128::create );
|
||||
glbarcode::Factory::registerType( "zint::rss14", Zint::Rss14::create );
|
||||
glbarcode::Factory::registerType( "zint::rssltd", Zint::Rssltd::create );
|
||||
glbarcode::Factory::registerType( "zint::rssexp", Zint::Rssexp::create );
|
||||
glbarcode::Factory::registerType( "zint::rsss", Zint::Rsss::create );
|
||||
glbarcode::Factory::registerType( "zint::rssso", Zint::Rssso::create );
|
||||
glbarcode::Factory::registerType( "zint::rssse", Zint::Rssse::create );
|
||||
glbarcode::Factory::registerType( "zint::hibc128", Zint::Hibc128::create );
|
||||
glbarcode::Factory::registerType( "zint::hibc39", Zint::Hibc39::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcdm", Zint::Hibcdm::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcqr", Zint::Hibcqr::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcpdf", Zint::Hibcpdf::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcmpdf", Zint::Hibcmpdf::create );
|
||||
glbarcode::Factory::registerType( "zint::hibcaz", Zint::Hibcaz::create );
|
||||
glbarcode::Factory::registerType( "zint::i25", Zint::I25::create );
|
||||
glbarcode::Factory::registerType( "zint::isbn", Zint::Isbn::create );
|
||||
glbarcode::Factory::registerType( "zint::itf14", Zint::Itf14::create );
|
||||
glbarcode::Factory::registerType( "zint::japan", Zint::Japan::create );
|
||||
glbarcode::Factory::registerType( "zint::korea", Zint::Korea::create );
|
||||
glbarcode::Factory::registerType( "zint::logm", Zint::Logm::create );
|
||||
glbarcode::Factory::registerType( "zint::maxi", Zint::Maxi::create );
|
||||
glbarcode::Factory::registerType( "zint::mpdf", Zint::Mpdf::create );
|
||||
glbarcode::Factory::registerType( "zint::mqr", Zint::Mqr::create );
|
||||
glbarcode::Factory::registerType( "zint::msi", Zint::Msi::create );
|
||||
glbarcode::Factory::registerType( "zint::nve", Zint::Nve::create );
|
||||
glbarcode::Factory::registerType( "zint::pdf", Zint::Pdf::create );
|
||||
glbarcode::Factory::registerType( "zint::pdft", Zint::Pdft::create );
|
||||
glbarcode::Factory::registerType( "zint::plan", Zint::Plan::create );
|
||||
glbarcode::Factory::registerType( "zint::postnet", Zint::Postnet::create );
|
||||
glbarcode::Factory::registerType( "zint::pharma", Zint::Pharma::create );
|
||||
glbarcode::Factory::registerType( "zint::pharma2", Zint::Pharma2::create );
|
||||
glbarcode::Factory::registerType( "zint::pzn", Zint::Pzn::create );
|
||||
glbarcode::Factory::registerType( "zint::qr", Zint::Qr::create );
|
||||
glbarcode::Factory::registerType( "zint::rm4", Zint::Rm4::create );
|
||||
glbarcode::Factory::registerType( "zint::tele", Zint::Tele::create );
|
||||
glbarcode::Factory::registerType( "zint::telex", Zint::Telex::create );
|
||||
glbarcode::Factory::registerType( "zint::upc-a", Zint::UpcA::create );
|
||||
glbarcode::Factory::registerType( "zint::upc-e", Zint::UpcE::create );
|
||||
glbarcode::Factory::registerType( "zint::usps", Zint::Usps::create );
|
||||
glbarcode::Factory::registerType( "zint::pls", Zint::Pls::create );
|
||||
|
||||
registerStyle( "ausp", "zint", tr("Austraila Post Standard"),
|
||||
false, false, true, false, "12345678901234567890123", true, 23 );
|
||||
registerStyle( "ausp", "zint", tr("Austraila Post Standard"),
|
||||
false, false, true, false, "12345678901234567890123", true, 23 );
|
||||
|
||||
registerStyle( "ausrp", "zint", tr("Australia Post Reply Paid"),
|
||||
false, false, true, false, "12345678", true, 8 );
|
||||
registerStyle( "ausrp", "zint", tr("Australia Post Reply Paid"),
|
||||
false, false, true, false, "12345678", true, 8 );
|
||||
|
||||
registerStyle( "ausrt", "zint", tr("Australia Post Route Code"),
|
||||
false, false, true, false, "12345678", true, 8 );
|
||||
registerStyle( "ausrt", "zint", tr("Australia Post Route Code"),
|
||||
false, false, true, false, "12345678", true, 8 );
|
||||
|
||||
registerStyle( "ausrd", "zint", tr("Australia Post Redirect"),
|
||||
false, false, true, false, "12345678", true, 8 );
|
||||
registerStyle( "ausrd", "zint", tr("Australia Post Redirect"),
|
||||
false, false, true, false, "12345678", true, 8 );
|
||||
|
||||
registerStyle( "aztec", "zint", tr("Aztec Code"),
|
||||
false, false, true, false, "1234567890", true, 10 );
|
||||
registerStyle( "aztec", "zint", tr("Aztec Code"),
|
||||
false, false, true, false, "1234567890", true, 10 );
|
||||
|
||||
registerStyle( "azrun", "zint", tr("Aztec Rune"),
|
||||
false, false, true, false, "255", true, 3 );
|
||||
registerStyle( "azrun", "zint", tr("Aztec Rune"),
|
||||
false, false, true, false, "255", true, 3 );
|
||||
|
||||
registerStyle( "cbr", "zint", tr("Codabar"),
|
||||
true, true, true, false, "ABCDABCDAB", true, 10 );
|
||||
registerStyle( "cbr", "zint", tr("Codabar"),
|
||||
true, true, true, false, "ABCDABCDAB", true, 10 );
|
||||
|
||||
registerStyle( "code1", "zint", tr("Code One"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code1", "zint", tr("Code One"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "code11", "zint", tr("Code 11"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code11", "zint", tr("Code 11"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "c16k", "zint", tr("Code 16K"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "c16k", "zint", tr("Code 16K"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "c25m", "zint", tr("Code 2 of 5 Matrix"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "c25m", "zint", tr("Code 2 of 5 Matrix"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "c25i", "zint", tr("Code 2 of 5 IATA"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "c25i", "zint", tr("Code 2 of 5 IATA"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "c25dl", "zint", tr("Code 2 of 5 Data Logic"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "c25dl", "zint", tr("Code 2 of 5 Data Logic"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "code32", "zint", tr("Code 32 (Italian Pharmacode)"),
|
||||
true, true, true, false, "12345678", true, 8 );
|
||||
registerStyle( "code32", "zint", tr("Code 32 (Italian Pharmacode)"),
|
||||
true, true, true, false, "12345678", true, 8 );
|
||||
|
||||
registerStyle( "code39", "zint", tr("Code 39"),
|
||||
true, true, false, false, "0000000000", true, 10 );
|
||||
registerStyle( "code39", "zint", tr("Code 39"),
|
||||
true, true, false, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "code39e", "zint", tr("Code 39 Extended"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code39e", "zint", tr("Code 39 Extended"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "code49", "zint", tr("Code 49"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code49", "zint", tr("Code 49"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "code93", "zint", tr("Code 93"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code93", "zint", tr("Code 93"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "code128", "zint", tr("Code 128"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code128", "zint", tr("Code 128"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "code128b", "zint", tr("Code 128 (Mode C supression)"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "code128b", "zint", tr("Code 128 (Mode C supression)"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "daft", "zint", tr("DAFT Code"),
|
||||
false, false, false, false, "DAFTDAFTDAFTDAFT", true, 16 );
|
||||
registerStyle( "daft", "zint", tr("DAFT Code"),
|
||||
false, false, false, false, "DAFTDAFTDAFTDAFT", true, 16 );
|
||||
|
||||
registerStyle( "dmtx", "zint", tr("Data Matrix"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "dmtx", "zint", tr("Data Matrix"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "dpl", "zint", tr("Deutsche Post Leitcode"),
|
||||
true, true, true, false, "1234567890123", true, 13 );
|
||||
registerStyle( "dpl", "zint", tr("Deutsche Post Leitcode"),
|
||||
true, true, true, false, "1234567890123", true, 13 );
|
||||
|
||||
registerStyle( "dpi", "zint", tr("Deutsche Post Identcode"),
|
||||
true, true, true, false, "12345678901", true, 11 );
|
||||
registerStyle( "dpi", "zint", tr("Deutsche Post Identcode"),
|
||||
true, true, true, false, "12345678901", true, 11 );
|
||||
|
||||
registerStyle( "kix", "zint", tr("Dutch Post KIX Code"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "kix", "zint", tr("Dutch Post KIX Code"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "ean", "zint", tr("EAN"),
|
||||
true, true, true, false, "1234567890123", false, 13 );
|
||||
registerStyle( "ean", "zint", tr("EAN"),
|
||||
true, true, true, false, "1234567890123", false, 13 );
|
||||
|
||||
registerStyle( "gmtx", "zint", tr("Grid Matrix"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "gmtx", "zint", tr("Grid Matrix"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "gs1-128", "zint", tr("GS1-128"),
|
||||
true, true, true, false, "[01]12345678901234", false, 18 );
|
||||
registerStyle( "gs1-128", "zint", tr("GS1-128"),
|
||||
true, true, true, false, "[01]12345678901234", false, 18 );
|
||||
|
||||
registerStyle( "rss14", "zint", tr("GS1 DataBar-14"),
|
||||
true, true, true, false, "1234567890123", true, 13 );
|
||||
registerStyle( "rss14", "zint", tr("GS1 DataBar-14"),
|
||||
true, true, true, false, "1234567890123", true, 13 );
|
||||
|
||||
registerStyle( "rssltd", "zint", "GS1 DataBar-14 Limited",
|
||||
true, true, true, false, "1234567890123", true, 13 );
|
||||
registerStyle( "rssltd", "zint", "GS1 DataBar-14 Limited",
|
||||
true, true, true, false, "1234567890123", true, 13 );
|
||||
|
||||
registerStyle( "rssexp", "zint", "GS1 DataBar Extended",
|
||||
true, true, true, false, "[01]12345678901234", false, 18 );
|
||||
registerStyle( "rssexp", "zint", "GS1 DataBar Extended",
|
||||
true, true, true, false, "[01]12345678901234", false, 18 );
|
||||
|
||||
registerStyle( "rsss", "zint", tr("GS1 DataBar-14 Stacked"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "rsss", "zint", tr("GS1 DataBar-14 Stacked"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "rssso", "zint", tr("GS1 DataBar-14 Stacked Omni."),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "rssso", "zint", tr("GS1 DataBar-14 Stacked Omni."),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "rssse", "zint", tr("GS1 DataBar Extended Stacked"),
|
||||
false, false, true, false, "[01]12345678901234", false, 18 );
|
||||
registerStyle( "rssse", "zint", tr("GS1 DataBar Extended Stacked"),
|
||||
false, false, true, false, "[01]12345678901234", false, 18 );
|
||||
|
||||
registerStyle( "hibc128", "zint", tr("HIBC Code 128"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "hibc128", "zint", tr("HIBC Code 128"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "hibc39", "zint", tr("HIBC Code 39"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "hibc39", "zint", tr("HIBC Code 39"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "hibcdm", "zint", tr("HIBC Data Matrix"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "hibcdm", "zint", tr("HIBC Data Matrix"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "hibcqr", "zint", tr("HIBC QR Code"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "hibcqr", "zint", tr("HIBC QR Code"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "hibcpdf", "zint", tr("HIBC PDF417"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "hibcpdf", "zint", tr("HIBC PDF417"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "hibcmpdf", "zint", tr("HIBC Micro PDF417"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "hibcmpdf", "zint", tr("HIBC Micro PDF417"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "hibcaz", "zint", tr("HIBC Aztec Code"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "hibcaz", "zint", tr("HIBC Aztec Code"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "i25", "zint", tr("Interleaved 2 of 5"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "i25", "zint", tr("Interleaved 2 of 5"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "isbn", "zint", tr("ISBN"),
|
||||
true, true, true, false, "123456789", false, 9 );
|
||||
registerStyle( "isbn", "zint", tr("ISBN"),
|
||||
true, true, true, false, "123456789", false, 9 );
|
||||
|
||||
registerStyle( "itf14", "zint", tr("ITF-14"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "itf14", "zint", tr("ITF-14"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "japan", "zint", tr("Japanese Postal"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "japan", "zint", tr("Japanese Postal"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "korea", "zint", tr("Korean Postal"),
|
||||
true, true, true, false, "123456", false, 6 );
|
||||
registerStyle( "korea", "zint", tr("Korean Postal"),
|
||||
true, true, true, false, "123456", false, 6 );
|
||||
|
||||
registerStyle( "logm", "zint", tr("LOGMARS"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "logm", "zint", tr("LOGMARS"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "maxi", "zint", tr("Maxicode"),
|
||||
false, false, false, false, "0000000000", true, 10 );
|
||||
registerStyle( "maxi", "zint", tr("Maxicode"),
|
||||
false, false, false, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "mpdf", "zint", tr("Micro PDF417"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "mpdf", "zint", tr("Micro PDF417"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "mqr", "zint", tr("Micro QR Code"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "mqr", "zint", tr("Micro QR Code"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "msi", "zint", tr("MSI Plessey"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "msi", "zint", tr("MSI Plessey"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "nve", "zint", tr("NVE-18"),
|
||||
true, true, true, false, "12345678901234567", false, 17 );
|
||||
registerStyle( "nve", "zint", tr("NVE-18"),
|
||||
true, true, true, false, "12345678901234567", false, 17 );
|
||||
|
||||
registerStyle( "pdf", "zint", tr("PDF417"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "pdf", "zint", tr("PDF417"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "pdft", "zint", tr("PDF417 Truncated"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "pdft", "zint", tr("PDF417 Truncated"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "plan", "zint", tr("PLANET"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "plan", "zint", tr("PLANET"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "postnet", "zint", tr("PostNet"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "postnet", "zint", tr("PostNet"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "pharma", "zint", tr("Pharmacode"),
|
||||
false, false, true, false, "123456", false, 6 );
|
||||
registerStyle( "pharma", "zint", tr("Pharmacode"),
|
||||
false, false, true, false, "123456", false, 6 );
|
||||
|
||||
registerStyle( "pharma2", "zint", tr("Pharmacode 2-track"),
|
||||
false, false, true, false, "12345678", false, 8 );
|
||||
registerStyle( "pharma2", "zint", tr("Pharmacode 2-track"),
|
||||
false, false, true, false, "12345678", false, 8 );
|
||||
|
||||
registerStyle( "pzn", "zint", tr("Pharmazentral Nummer (PZN)"),
|
||||
true, true, true, false, "123456", false, 6 );
|
||||
registerStyle( "pzn", "zint", tr("Pharmazentral Nummer (PZN)"),
|
||||
true, true, true, false, "123456", false, 6 );
|
||||
|
||||
registerStyle( "qr", "zint", tr("QR Code"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "qr", "zint", tr("QR Code"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "rm4", "zint", tr("Royal Mail 4-State"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "rm4", "zint", tr("Royal Mail 4-State"),
|
||||
false, false, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "tele", "zint", tr("Telepen"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "tele", "zint", tr("Telepen"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "telex", "zint", tr("Telepen Numeric"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "telex", "zint", tr("Telepen Numeric"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
|
||||
registerStyle( "upc-a", "zint", tr("UPC-A"),
|
||||
true, true, true, false, "12345678901", false, 11 );
|
||||
registerStyle( "upc-a", "zint", tr("UPC-A"),
|
||||
true, true, true, false, "12345678901", false, 11 );
|
||||
|
||||
registerStyle( "upc-e", "zint", tr("UPC-E"),
|
||||
true, true, true, false, "1234567", false, 7 );
|
||||
registerStyle( "upc-e", "zint", tr("UPC-E"),
|
||||
true, true, true, false, "1234567", false, 7 );
|
||||
|
||||
registerStyle( "usps", "zint", tr("USPS One Code"),
|
||||
false, false, true, false, "12345678901234567890", true, 20 );
|
||||
registerStyle( "usps", "zint", tr("USPS One Code"),
|
||||
false, false, true, false, "12345678901234567890", true, 20 );
|
||||
|
||||
registerStyle( "pls", "zint", tr("UK Plessey"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
registerStyle( "pls", "zint", tr("UK Plessey"),
|
||||
true, true, true, false, "0000000000", true, 10 );
|
||||
#endif // HAVE_ZINT
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Backends::init()
|
||||
{
|
||||
static Backends* singletonInstance = nullptr;
|
||||
|
||||
if ( singletonInstance == nullptr )
|
||||
{
|
||||
singletonInstance = new Backends();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const QStringList& Backends::backendList()
|
||||
{
|
||||
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 )
|
||||
void Backends::init()
|
||||
{
|
||||
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 )
|
||||
{
|
||||
mBackendIdList.append( backendId );
|
||||
mBackendNameMap[ backendId ] = backendName;
|
||||
}
|
||||
const Style& Backends::defaultStyle()
|
||||
{
|
||||
return mStyleList[0];
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
const Style& Backends::style( const QString& backendId, const QString& StyleId )
|
||||
{
|
||||
foreach ( const Style& bcStyle, mStyleList )
|
||||
{
|
||||
if ( (bcStyle.backendId() == backendId) && (bcStyle.id() == StyleId) )
|
||||
{
|
||||
return bcStyle;
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::barcode
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Backends Database
|
||||
///
|
||||
class Backends : public QObject
|
||||
namespace barcode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///
|
||||
/// Backends Database
|
||||
///
|
||||
class Backends : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
Backends();
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
Backends();
|
||||
|
||||
public:
|
||||
static void init();
|
||||
public:
|
||||
static void init();
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static const QStringList& backendList();
|
||||
static QString backendName( const QString& backendId );
|
||||
static const QList<Style>& styleList();
|
||||
static const Style& defaultStyle();
|
||||
static const Style& style( const QString& backendId, const QString& StyleId );
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static const QStringList& backendList();
|
||||
static QString backendName( const QString& backendId );
|
||||
static const QList<Style>& styleList();
|
||||
static const Style& defaultStyle();
|
||||
static const Style& style( const QString& backendId, const QString& StyleId );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
static void registerBackend( const QString &backendId, const QString &backendName );
|
||||
/////////////////////////////////
|
||||
// Private Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
static void registerBackend( const QString &backendId, const QString &backendName );
|
||||
|
||||
static void 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 );
|
||||
static void 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 );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Members
|
||||
/////////////////////////////////
|
||||
static QStringList mBackendIdList;
|
||||
static QMap<QString,QString> mBackendNameMap;
|
||||
/////////////////////////////////
|
||||
// Private Members
|
||||
/////////////////////////////////
|
||||
static QStringList mBackendIdList;
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::barcode
|
||||
namespace glabels
|
||||
{
|
||||
namespace GnuBarcode
|
||||
namespace barcode
|
||||
{
|
||||
|
||||
/**
|
||||
* GnuBarcode::Base base class for all GNU Barcodes
|
||||
*
|
||||
* Implements glbarcode::Barcode1dBase.
|
||||
*/
|
||||
class Base : public glbarcode::Barcode1dBase
|
||||
namespace GnuBarcode
|
||||
{
|
||||
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,
|
||||
unsigned int nMin,
|
||||
unsigned int nMax ) const;
|
||||
bool isNumericLengthValid( const std::string& data,
|
||||
unsigned int nMin,
|
||||
unsigned int nMax ) const;
|
||||
|
||||
bool isNumericLength1Valid( const std::string& data,
|
||||
unsigned int nMin,
|
||||
unsigned int nMax ) const;
|
||||
bool isNumericLength1Valid( const std::string& data,
|
||||
unsigned int nMin,
|
||||
unsigned int nMax ) const;
|
||||
|
||||
bool isNumericLength2Valid( const std::string& data,
|
||||
unsigned int nMin,
|
||||
unsigned int nMax ) const;
|
||||
bool isNumericLength2Valid( const std::string& data,
|
||||
unsigned int nMin,
|
||||
unsigned int nMax ) const;
|
||||
|
||||
void vectorize( const std::string& encodedData,
|
||||
const std::string& displayText,
|
||||
const std::string& cookedData,
|
||||
double& w,
|
||||
double& h ) override;
|
||||
};
|
||||
void vectorize( const std::string& encodedData,
|
||||
const std::string& displayText,
|
||||
const std::string& cookedData,
|
||||
double& w,
|
||||
double& h ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EAN Barcode (Any)
|
||||
*/
|
||||
class Ean : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* EAN Barcode (Any)
|
||||
*/
|
||||
class Ean : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EAN-8 Barcode
|
||||
*/
|
||||
class Ean8 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* EAN-8 Barcode
|
||||
*/
|
||||
class Ean8 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EAN-8+2 Barcode
|
||||
*/
|
||||
class Ean8_2 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* EAN-8+2 Barcode
|
||||
*/
|
||||
class Ean8_2 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EAN-8+5 Barcode
|
||||
*/
|
||||
class Ean8_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* EAN-8+5 Barcode
|
||||
*/
|
||||
class Ean8_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EAN-13 Barcode
|
||||
*/
|
||||
class Ean13 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* EAN-13 Barcode
|
||||
*/
|
||||
class Ean13 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EAN-13+2 Barcode
|
||||
*/
|
||||
class Ean13_2 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* EAN-13+2 Barcode
|
||||
*/
|
||||
class Ean13_2 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* EAN-13+5 Barcode
|
||||
*/
|
||||
class Ean13_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* EAN-13+5 Barcode
|
||||
*/
|
||||
class Ean13_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* UPC Barcode (Any)
|
||||
*/
|
||||
class Upc : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* UPC Barcode (Any)
|
||||
*/
|
||||
class Upc : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* UPC-A Barcode
|
||||
*/
|
||||
class UpcA : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* UPC-A Barcode
|
||||
*/
|
||||
class UpcA : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* UPC-A+2 Barcode
|
||||
*/
|
||||
class UpcA_2 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* UPC-A+2 Barcode
|
||||
*/
|
||||
class UpcA_2 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* UPC-A+5 Barcode
|
||||
*/
|
||||
class UpcA_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* UPC-A+5 Barcode
|
||||
*/
|
||||
class UpcA_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* UPC-E Barcode
|
||||
*/
|
||||
class UpcE : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* UPC-E Barcode
|
||||
*/
|
||||
class UpcE : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* UPC-E+2 Barcode
|
||||
*/
|
||||
class UpcE_2 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* UPC-E+2 Barcode
|
||||
*/
|
||||
class UpcE_2 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* UPC-E+5 Barcode
|
||||
*/
|
||||
class UpcE_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* UPC-E+5 Barcode
|
||||
*/
|
||||
class UpcE_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* ISBN Barcode
|
||||
*/
|
||||
class Isbn : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* ISBN Barcode
|
||||
*/
|
||||
class Isbn : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* ISBN+5 Barcode
|
||||
*/
|
||||
class Isbn_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* ISBN+5 Barcode
|
||||
*/
|
||||
class Isbn_5 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Code39 Barcode
|
||||
*/
|
||||
class Code39 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* Code39 Barcode
|
||||
*/
|
||||
class Code39 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Code128 Barcode
|
||||
*/
|
||||
class Code128 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* Code128 Barcode
|
||||
*/
|
||||
class Code128 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Code128C Barcode
|
||||
*/
|
||||
class Code128C : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* Code128C Barcode
|
||||
*/
|
||||
class Code128C : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Code128B Barcode
|
||||
*/
|
||||
class Code128B : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* Code128B Barcode
|
||||
*/
|
||||
class Code128B : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* I25 Barcode
|
||||
*/
|
||||
class I25 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* I25 Barcode
|
||||
*/
|
||||
class I25 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* CBR Barcode
|
||||
*/
|
||||
class Cbr : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* CBR Barcode
|
||||
*/
|
||||
class Cbr : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* MSI Barcode
|
||||
*/
|
||||
class Msi : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* MSI Barcode
|
||||
*/
|
||||
class Msi : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* PLS Barcode
|
||||
*/
|
||||
class Pls : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* PLS Barcode
|
||||
*/
|
||||
class Pls : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Code93 Barcode
|
||||
*/
|
||||
class Code93 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
/**
|
||||
* Code93 Barcode
|
||||
*/
|
||||
class Code93 : public Base
|
||||
{
|
||||
public:
|
||||
static Barcode* create();
|
||||
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
protected:
|
||||
bool validate( const std::string& rawData ) override;
|
||||
std::string encode( const std::string& cookedData ) override;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,65 +25,69 @@
|
||||
#include <qrencode.h>
|
||||
|
||||
|
||||
namespace glabels::barcode
|
||||
namespace glabels
|
||||
{
|
||||
namespace QrEncode
|
||||
namespace barcode
|
||||
{
|
||||
|
||||
/*
|
||||
* Static QrCode barcode creation method
|
||||
*/
|
||||
glbarcode::Barcode* QrCode::create()
|
||||
namespace QrEncode
|
||||
{
|
||||
return new QrCode();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* QrCode data validation, implements glbarcode::Barcode2dBase::validate()
|
||||
*/
|
||||
bool QrCode::validate( const std::string& rawData )
|
||||
{
|
||||
if ( rawData.size() == 0 )
|
||||
/*
|
||||
* Static QrCode barcode creation method
|
||||
*/
|
||||
glbarcode::Barcode* QrCode::create()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
return new QrCode();
|
||||
}
|
||||
|
||||
|
||||
int w = qrcode->width;
|
||||
encodedData.resize( w, w );
|
||||
|
||||
|
||||
for ( int iy = 0; iy < w; iy++ )
|
||||
/*
|
||||
* QrCode data validation, implements glbarcode::Barcode2dBase::validate()
|
||||
*/
|
||||
bool QrCode::validate( const std::string& rawData )
|
||||
{
|
||||
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
|
||||
|
||||
+19
-16
@@ -26,28 +26,31 @@
|
||||
#include "glbarcode/Barcode2dBase.h"
|
||||
|
||||
|
||||
namespace glabels::barcode
|
||||
namespace glabels
|
||||
{
|
||||
namespace QrEncode
|
||||
namespace barcode
|
||||
{
|
||||
|
||||
/**
|
||||
* QrEncode::QrCode QR Code Barcode
|
||||
*
|
||||
* Implements glbarcode::Barcode2dBase.
|
||||
*/
|
||||
class QrCode : public glbarcode::Barcode2dBase
|
||||
namespace QrEncode
|
||||
{
|
||||
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,
|
||||
glbarcode::Matrix<bool>& encodedData ) override;
|
||||
};
|
||||
private:
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::barcode
|
||||
namespace glabels
|
||||
{
|
||||
namespace barcode
|
||||
{
|
||||
|
||||
///
|
||||
/// Default Constructor
|
||||
///
|
||||
Style::Style ()
|
||||
: mId( "" ),
|
||||
mBackendId( "" ),
|
||||
mName( "" ),
|
||||
mCanText( false ),
|
||||
mTextOptional( false ),
|
||||
mCanChecksum( false ),
|
||||
mChecksumOptional( false ),
|
||||
mDefaultDigits( "" ),
|
||||
mCanFreeform( false ),
|
||||
mPreferedN( 0 )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
///
|
||||
/// Default Constructor
|
||||
///
|
||||
Style::Style ()
|
||||
: mId( "" ),
|
||||
mBackendId( "" ),
|
||||
mName( "" ),
|
||||
mCanText( false ),
|
||||
mTextOptional( false ),
|
||||
mCanChecksum( false ),
|
||||
mChecksumOptional( false ),
|
||||
mDefaultDigits( "" ),
|
||||
mCanFreeform( false ),
|
||||
mPreferedN( 0 )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
Style::Style ( const QString& id,
|
||||
const QString& backendId,
|
||||
const QString& name,
|
||||
bool canText,
|
||||
bool textOptional,
|
||||
bool canChecksum,
|
||||
bool checksumOptional,
|
||||
const QString& defaultDigits,
|
||||
bool canFreeform,
|
||||
int preferedN )
|
||||
: mId( id ),
|
||||
mBackendId( backendId ),
|
||||
mName( name ),
|
||||
mCanText( canText ),
|
||||
mTextOptional( textOptional ),
|
||||
mCanChecksum( canChecksum ),
|
||||
mChecksumOptional( checksumOptional ),
|
||||
mDefaultDigits( defaultDigits ),
|
||||
mCanFreeform( canFreeform ),
|
||||
mPreferedN( preferedN )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
///
|
||||
/// Constructor From Data
|
||||
///
|
||||
Style::Style ( const QString& id,
|
||||
const QString& backendId,
|
||||
const QString& name,
|
||||
bool canText,
|
||||
bool textOptional,
|
||||
bool canChecksum,
|
||||
bool checksumOptional,
|
||||
const QString& defaultDigits,
|
||||
bool canFreeform,
|
||||
int preferedN )
|
||||
: mId( id ),
|
||||
mBackendId( backendId ),
|
||||
mName( name ),
|
||||
mCanText( canText ),
|
||||
mTextOptional( textOptional ),
|
||||
mCanChecksum( canChecksum ),
|
||||
mChecksumOptional( checksumOptional ),
|
||||
mDefaultDigits( defaultDigits ),
|
||||
mCanFreeform( canFreeform ),
|
||||
mPreferedN( preferedN )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// ID Property Getter
|
||||
///
|
||||
const QString& Style::id() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Full ID Property Getter
|
||||
///
|
||||
QString Style::fullId() const
|
||||
{
|
||||
if ( mBackendId == "" )
|
||||
///
|
||||
/// ID Property Getter
|
||||
///
|
||||
const QString& Style::id() const
|
||||
{
|
||||
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
|
||||
///
|
||||
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 )
|
||||
///
|
||||
/// Backend ID Property Getter
|
||||
///
|
||||
const QString& Style::backendId() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// "Not equals" operator
|
||||
///
|
||||
bool Style::operator!=( const Style& other ) const
|
||||
{
|
||||
return mId != other.mId;
|
||||
}
|
||||
///
|
||||
/// 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') );
|
||||
}
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::barcode
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Style Type
|
||||
///
|
||||
class Style
|
||||
namespace barcode
|
||||
{
|
||||
|
||||
///
|
||||
/// Style Type
|
||||
///
|
||||
class Style
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Style ();
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Style ();
|
||||
|
||||
Style ( 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 ( const QString& id,
|
||||
const QString& backendId,
|
||||
const QString& name,
|
||||
bool canText,
|
||||
bool textOptional,
|
||||
bool canChecksum,
|
||||
bool checksumOptional,
|
||||
const QString& defaultDigits,
|
||||
bool canFreeform,
|
||||
int preferedN );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
const QString& id() const;
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
const QString& id() const;
|
||||
|
||||
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
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QString exampleDigits( int n ) const;
|
||||
/////////////////////////////////
|
||||
// Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QString exampleDigits( int n ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Operators
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool operator!=( const Style& other ) const;
|
||||
/////////////////////////////////
|
||||
// Operators
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool operator!=( const Style& other ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
QString mId;
|
||||
QString mBackendId;
|
||||
QString mName;
|
||||
bool mCanText;
|
||||
bool mTextOptional;
|
||||
bool mCanChecksum;
|
||||
bool mChecksumOptional;
|
||||
QString mDefaultDigits;
|
||||
bool mCanFreeform;
|
||||
int mPreferedN;
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
QString mId;
|
||||
QString mBackendId;
|
||||
QString mName;
|
||||
bool mCanText;
|
||||
bool mTextOptional;
|
||||
bool mCanChecksum;
|
||||
bool mChecksumOptional;
|
||||
QString mDefaultDigits;
|
||||
bool mCanFreeform;
|
||||
int mPreferedN;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+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"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
||||
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
||||
QStringList Factory::mNameList;
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Factory::Factory()
|
||||
namespace merge
|
||||
{
|
||||
registerBackend( None::id(),
|
||||
tr("None"),
|
||||
NONE,
|
||||
&None::create );
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
||||
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
||||
QStringList Factory::mNameList;
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Factory::Factory()
|
||||
{
|
||||
registerBackend( None::id(),
|
||||
tr("None"),
|
||||
NONE,
|
||||
&None::create );
|
||||
|
||||
registerBackend( TextCsv::id(),
|
||||
tr("Text: Comma Separated Values (CSV)"),
|
||||
FILE,
|
||||
&TextCsv::create );
|
||||
registerBackend( TextCsv::id(),
|
||||
tr("Text: Comma Separated Values (CSV)"),
|
||||
FILE,
|
||||
&TextCsv::create );
|
||||
|
||||
registerBackend( TextCsvKeys::id(),
|
||||
tr("Text: Comma Separated Values (CSV), keys on line 1"),
|
||||
FILE,
|
||||
&TextCsvKeys::create );
|
||||
registerBackend( TextCsvKeys::id(),
|
||||
tr("Text: Comma Separated Values (CSV), keys on line 1"),
|
||||
FILE,
|
||||
&TextCsvKeys::create );
|
||||
|
||||
registerBackend( TextTsv::id(),
|
||||
tr("Text: Tab Separated Values (TSV)"),
|
||||
FILE,
|
||||
&TextTsv::create );
|
||||
registerBackend( TextTsv::id(),
|
||||
tr("Text: Tab Separated Values (TSV)"),
|
||||
FILE,
|
||||
&TextTsv::create );
|
||||
|
||||
registerBackend( TextTsvKeys::id(),
|
||||
tr("Text: Tab Separated Values (TSV), keys on line 1"),
|
||||
FILE,
|
||||
&TextTsvKeys::create );
|
||||
registerBackend( TextTsvKeys::id(),
|
||||
tr("Text: Tab Separated Values (TSV), keys on line 1"),
|
||||
FILE,
|
||||
&TextTsvKeys::create );
|
||||
|
||||
registerBackend( TextColon::id(),
|
||||
tr("Text: Colon Separated Values"),
|
||||
FILE,
|
||||
&TextColon::create );
|
||||
registerBackend( TextColon::id(),
|
||||
tr("Text: Colon Separated Values"),
|
||||
FILE,
|
||||
&TextColon::create );
|
||||
|
||||
registerBackend( TextColonKeys::id(),
|
||||
tr("Text: Colon Separated Values, keys on line 1"),
|
||||
FILE,
|
||||
&TextColonKeys::create );
|
||||
registerBackend( TextColonKeys::id(),
|
||||
tr("Text: Colon Separated Values, keys on line 1"),
|
||||
FILE,
|
||||
&TextColonKeys::create );
|
||||
|
||||
registerBackend( TextSemicolon::id(),
|
||||
tr("Text: Semicolon Separated Values"),
|
||||
FILE,
|
||||
&TextSemicolon::create );
|
||||
registerBackend( TextSemicolon::id(),
|
||||
tr("Text: Semicolon Separated Values"),
|
||||
FILE,
|
||||
&TextSemicolon::create );
|
||||
|
||||
registerBackend( TextSemicolonKeys::id(),
|
||||
tr("Text: Semicolon Separated Values, keys on line 1"),
|
||||
FILE,
|
||||
&TextSemicolonKeys::create );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Initialize
|
||||
///
|
||||
void Factory::init()
|
||||
{
|
||||
static Factory* singletonInstance = nullptr;
|
||||
if ( !singletonInstance )
|
||||
{
|
||||
singletonInstance = new Factory();
|
||||
registerBackend( TextSemicolonKeys::id(),
|
||||
tr("Text: Semicolon Separated Values, keys on line 1"),
|
||||
FILE,
|
||||
&TextSemicolonKeys::create );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create Merge object
|
||||
///
|
||||
Merge* Factory::createMerge( const QString& id )
|
||||
{
|
||||
QMap<QString,BackendEntry>::iterator iBackend = mBackendIdMap.find( id );
|
||||
if ( iBackend != mBackendIdMap.end() )
|
||||
///
|
||||
/// Initialize
|
||||
///
|
||||
void Factory::init()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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;
|
||||
return None::create();
|
||||
}
|
||||
else
|
||||
{
|
||||
return tr("None");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Convert name to ID
|
||||
///
|
||||
QString Factory::nameToId( const QString& name )
|
||||
{
|
||||
if ( mBackendNameMap.contains( name ) )
|
||||
///
|
||||
/// Get name list
|
||||
///
|
||||
QStringList Factory::nameList()
|
||||
{
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Convert ID to type
|
||||
///
|
||||
Factory::SourceType Factory::idToType( const QString& id )
|
||||
{
|
||||
if ( mBackendIdMap.contains( id ) )
|
||||
///
|
||||
/// Register backend
|
||||
///
|
||||
void Factory::registerBackend( const QString& id,
|
||||
const QString& name,
|
||||
SourceType type,
|
||||
CreateFct create )
|
||||
{
|
||||
return mBackendIdMap[id].type;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
BackendEntry backend;
|
||||
|
||||
|
||||
///
|
||||
/// 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";
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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;
|
||||
backend.id = id;
|
||||
backend.name = name;
|
||||
backend.type = type;
|
||||
backend.create = create;
|
||||
|
||||
mBackendIdMap[ id ] = backend;
|
||||
mBackendNameMap[ name ] = backend;
|
||||
mBackendIdMap[ id ] = backend;
|
||||
mBackendNameMap[ name ] = backend;
|
||||
|
||||
mNameList << name;
|
||||
}
|
||||
mNameList << name;
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
+70
-67
@@ -27,80 +27,83 @@
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward references
|
||||
class Merge;
|
||||
|
||||
|
||||
///
|
||||
/// Factory
|
||||
///
|
||||
class Factory
|
||||
namespace merge
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Factory)
|
||||
|
||||
// Forward references
|
||||
class Merge;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// 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
|
||||
///
|
||||
/// Factory
|
||||
///
|
||||
class Factory
|
||||
{
|
||||
public:
|
||||
QString id;
|
||||
QString name;
|
||||
SourceType type;
|
||||
CreateFct create;
|
||||
};
|
||||
Q_DECLARE_TR_FUNCTIONS(Factory)
|
||||
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
namespace merge
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Merge::Merge()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Merge::Merge( const Merge* merge ) : mSource(merge->mSource)
|
||||
{
|
||||
foreach ( Record* record, merge->mRecordList )
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Merge::Merge()
|
||||
{
|
||||
mRecordList << record->clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
Merge::~Merge()
|
||||
{
|
||||
foreach ( Record* record, mRecordList )
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Merge::Merge( const Merge* merge ) : mSource(merge->mSource)
|
||||
{
|
||||
delete record;
|
||||
foreach ( Record* record, merge->mRecordList )
|
||||
{
|
||||
mRecordList << record->clone();
|
||||
}
|
||||
}
|
||||
mRecordList.clear();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get id
|
||||
///
|
||||
QString Merge::id() const
|
||||
{
|
||||
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 )
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
Merge::~Merge()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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();
|
||||
emit sourceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Select all records
|
||||
///
|
||||
void Merge::selectAll()
|
||||
{
|
||||
foreach ( Record* record, mRecordList )
|
||||
///
|
||||
/// Get record list
|
||||
///
|
||||
const QList<Record*>& Merge::recordList( ) const
|
||||
{
|
||||
return mRecordList;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Select matching record
|
||||
///
|
||||
void Merge::select( Record* record )
|
||||
{
|
||||
record->setSelected( true );
|
||||
emit selectionChanged();
|
||||
}
|
||||
emit selectionChanged();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unselect all records
|
||||
///
|
||||
void Merge::unselectAll()
|
||||
{
|
||||
foreach ( Record* record, mRecordList )
|
||||
|
||||
///
|
||||
/// Unselect matching record
|
||||
///
|
||||
void Merge::unselect( Record* record )
|
||||
{
|
||||
record->setSelected( false );
|
||||
emit selectionChanged();
|
||||
}
|
||||
emit selectionChanged();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Return count of selected records
|
||||
///
|
||||
int Merge::nSelectedRecords() const
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
foreach ( Record* record, mRecordList )
|
||||
///
|
||||
/// Select/unselect i'th record
|
||||
///
|
||||
void Merge::setSelected( int i, bool state )
|
||||
{
|
||||
if ( record->isSelected() )
|
||||
if ( (i >= 0) && (i < mRecordList.size()) )
|
||||
{
|
||||
count++;
|
||||
mRecordList[i]->setSelected( state );
|
||||
emit selectionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Return list of selected records
|
||||
///
|
||||
const QList<Record*> Merge::selectedRecords() const
|
||||
{
|
||||
QList<Record*> list;
|
||||
|
||||
foreach ( Record* record, mRecordList )
|
||||
///
|
||||
/// Select all records
|
||||
///
|
||||
void Merge::selectAll()
|
||||
{
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward references
|
||||
class Record;
|
||||
|
||||
|
||||
///
|
||||
/// Merge Object
|
||||
///
|
||||
struct Merge : QObject
|
||||
namespace merge
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// 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();
|
||||
// Forward references
|
||||
class Record;
|
||||
|
||||
|
||||
int nSelectedRecords() const;
|
||||
const QList<Record*> selectedRecords() const;
|
||||
///
|
||||
/// Merge Object
|
||||
///
|
||||
struct Merge : QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// 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;
|
||||
/////////////////////////////////
|
||||
// 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;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// 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:
|
||||
void sourceChanged();
|
||||
void selectionChanged();
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void sourceChanged();
|
||||
void selectionChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
protected:
|
||||
QString mId;
|
||||
private:
|
||||
QString mSource;
|
||||
QList<Record*> mRecordList;
|
||||
};
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
protected:
|
||||
QString mId;
|
||||
private:
|
||||
QString mSource;
|
||||
QList<Record*> mRecordList;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+79
-76
@@ -21,102 +21,105 @@
|
||||
#include "None.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
None::None() : Merge()
|
||||
namespace merge
|
||||
{
|
||||
mId = "None";
|
||||
}
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
None::None() : Merge()
|
||||
{
|
||||
mId = "None";
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
None::None( const None* merge ) : Merge( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
None::None( const None* merge ) : Merge( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
None::~None()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
None::~None()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
None* None::clone() const
|
||||
{
|
||||
return new None( this );
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
None* None::clone() const
|
||||
{
|
||||
return new None( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString None::id()
|
||||
{
|
||||
return "None";
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString None::id()
|
||||
{
|
||||
return "None";
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* None::create()
|
||||
{
|
||||
return new None();
|
||||
}
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* None::create()
|
||||
{
|
||||
return new None();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get key list
|
||||
///
|
||||
QStringList None::keys() const
|
||||
{
|
||||
QStringList emptyList;
|
||||
return emptyList;
|
||||
}
|
||||
///
|
||||
/// Get key list
|
||||
///
|
||||
QStringList None::keys() const
|
||||
{
|
||||
QStringList emptyList;
|
||||
return emptyList;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get primary key
|
||||
///
|
||||
QString None::primaryKey() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
///
|
||||
/// Get primary key
|
||||
///
|
||||
QString None::primaryKey() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Open source
|
||||
///
|
||||
void None::open()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Open source
|
||||
///
|
||||
void None::open()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Close source
|
||||
///
|
||||
void None::close()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Close source
|
||||
///
|
||||
void None::close()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Read next record
|
||||
///
|
||||
Record* None::readNextRecord()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
///
|
||||
/// Read next record
|
||||
///
|
||||
Record* None::readNextRecord()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
+37
-34
@@ -24,51 +24,54 @@
|
||||
#include "Merge.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// None Merge Backend
|
||||
///
|
||||
struct None : public Merge
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
None();
|
||||
None( const None* merge );
|
||||
~None() override;
|
||||
///
|
||||
/// None Merge Backend
|
||||
///
|
||||
struct None : public Merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
None();
|
||||
None( const None* merge );
|
||||
~None() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
None* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
None* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Implementation of virtual methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QStringList keys() const override;
|
||||
QString primaryKey() const override;
|
||||
protected:
|
||||
void open() override;
|
||||
void close() override;
|
||||
Record* readNextRecord() override;
|
||||
/////////////////////////////////
|
||||
// Implementation of virtual methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QStringList keys() const override;
|
||||
QString primaryKey() const override;
|
||||
protected:
|
||||
void open() override;
|
||||
void close() override;
|
||||
Record* readNextRecord() override;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+39
-36
@@ -21,50 +21,53 @@
|
||||
#include "Record.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Record::Record() : mSelected( true )
|
||||
namespace merge
|
||||
{
|
||||
}
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Record::Record() : mSelected( true )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Record::Record( const Record* record )
|
||||
: QMap<QString,QString>(*record), mSelected(record->mSelected)
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Record::Record( const Record* record )
|
||||
: QMap<QString,QString>(*record), mSelected(record->mSelected)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
Record* Record::clone() const
|
||||
{
|
||||
return new Record( this );
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
Record* Record::clone() const
|
||||
{
|
||||
return new Record( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Is record selected?
|
||||
///
|
||||
bool Record::isSelected() const
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
///
|
||||
/// Is record selected?
|
||||
///
|
||||
bool Record::isSelected() const
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Set selected on not selected
|
||||
///
|
||||
void Record::setSelected( bool value )
|
||||
{
|
||||
mSelected = value;
|
||||
}
|
||||
///
|
||||
/// Set selected on not selected
|
||||
///
|
||||
void Record::setSelected( bool value )
|
||||
{
|
||||
mSelected = value;
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
+31
-28
@@ -26,45 +26,48 @@
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Merge Record
|
||||
///
|
||||
struct Record : public QMap<QString,QString>
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Record();
|
||||
Record( const Record* record );
|
||||
///
|
||||
/// Merge Record
|
||||
///
|
||||
struct Record : public QMap<QString,QString>
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Record();
|
||||
Record( const Record* record );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
Record* clone() const;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
Record* clone() const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool isSelected() const;
|
||||
void setSelected( bool value );
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool isSelected() const;
|
||||
void setSelected( bool value );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
bool mSelected;
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
bool mSelected;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+339
-336
@@ -25,392 +25,395 @@
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Text::Text( QChar delimiter, bool line1HasKeys )
|
||||
: mDelimeter(delimiter), mLine1HasKeys(line1HasKeys), mNFieldsMax(0)
|
||||
namespace merge
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Text::Text( const Text* merge )
|
||||
: 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++ )
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Text::Text( QChar delimiter, bool line1HasKeys )
|
||||
: mDelimeter(delimiter), mLine1HasKeys(line1HasKeys), mNFieldsMax(0)
|
||||
{
|
||||
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() )
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Text::Text( const Text* merge )
|
||||
: Merge( merge ),
|
||||
mDelimeter(merge->mDelimeter), mLine1HasKeys(merge->mLine1HasKeys),
|
||||
mNFieldsMax(merge->mNFieldsMax)
|
||||
{
|
||||
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
|
||||
{
|
||||
mNFieldsMax = mKeys.size();
|
||||
return QString::number( iField+1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Close source
|
||||
///
|
||||
void Text::close()
|
||||
{
|
||||
if ( mFile.isOpen() )
|
||||
///
|
||||
/// 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()
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
QStringList fields;
|
||||
|
||||
enum State
|
||||
{
|
||||
DELIM, QUOTED, QUOTED_QUOTE1, QUOTED_ESCAPED, SIMPLE, SIMPLE_ESCAPED, DONE
|
||||
} state = DELIM;
|
||||
|
||||
QByteArray field;
|
||||
|
||||
while ( state != DONE )
|
||||
{
|
||||
char c;
|
||||
if ( mFile.getChar( &c ) )
|
||||
enum State
|
||||
{
|
||||
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 ) )
|
||||
{
|
||||
|
||||
case DELIM:
|
||||
switch (c)
|
||||
switch (state)
|
||||
{
|
||||
case '\n':
|
||||
/* last field is empty. */
|
||||
fields << "";
|
||||
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 )
|
||||
|
||||
case DELIM:
|
||||
switch (c)
|
||||
{
|
||||
/* field is empty. */
|
||||
case '\n':
|
||||
/* last field is empty. */
|
||||
fields << "";
|
||||
state = DONE;
|
||||
break;
|
||||
case '\r':
|
||||
/* ignore */
|
||||
state = DELIM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* begining of a simple field. */
|
||||
field.append( c );
|
||||
state = SIMPLE;
|
||||
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. */
|
||||
fields << "";
|
||||
state = DELIM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* begining of a simple field. */
|
||||
field.append( c );
|
||||
state = SIMPLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case QUOTED:
|
||||
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 QUOTED:
|
||||
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 );
|
||||
state = SIMPLE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SIMPLE_ESCAPED:
|
||||
switch (c)
|
||||
{
|
||||
case 'n':
|
||||
/* Decode "\n" as newline. */
|
||||
field.append( '\n' );
|
||||
state = SIMPLE;
|
||||
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 't':
|
||||
/* Decode "\t" as tab. */
|
||||
field.append( '\t' );
|
||||
state = SIMPLE;
|
||||
|
||||
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
|
||||
{
|
||||
/* 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:
|
||||
/* Use character literally. */
|
||||
field.append( (char)c );
|
||||
state = SIMPLE;
|
||||
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Handle EOF (could also be an error while reading). */
|
||||
switch (state)
|
||||
else
|
||||
{
|
||||
/* Handle EOF (could also be an error while reading). */
|
||||
switch (state)
|
||||
{
|
||||
|
||||
case DELIM:
|
||||
/* EOF, no more lines. */
|
||||
break;
|
||||
case DELIM:
|
||||
/* EOF, no more lines. */
|
||||
break;
|
||||
|
||||
case QUOTED:
|
||||
/* File ended midway through quoted item. Truncate field. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
case QUOTED:
|
||||
/* File ended midway through quoted item. Truncate field. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
|
||||
case QUOTED_QUOTE1:
|
||||
/* File ended after quoted item. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
case QUOTED_QUOTE1:
|
||||
/* File ended after quoted item. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
|
||||
case QUOTED_ESCAPED:
|
||||
/* File ended midway through quoted item. Truncate field. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
case QUOTED_ESCAPED:
|
||||
/* File ended midway through quoted item. Truncate field. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
|
||||
case SIMPLE:
|
||||
/* File ended after simple item. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
case SIMPLE:
|
||||
/* File ended after simple item. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
|
||||
case SIMPLE_ESCAPED:
|
||||
/* File ended midway through escaped item. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
case SIMPLE_ESCAPED:
|
||||
/* File ended midway through escaped item. */
|
||||
fields << QString( field );
|
||||
break;
|
||||
|
||||
default:
|
||||
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
|
||||
break;
|
||||
}
|
||||
|
||||
state = DONE;
|
||||
state = DONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return fields;
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
+41
-38
@@ -26,55 +26,58 @@
|
||||
#include <QFile>
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Text Merge Backend
|
||||
///
|
||||
struct Text : public Merge
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
protected:
|
||||
Text( QChar delimiter, bool line1HasKeys );
|
||||
Text( const Text* merge );
|
||||
~Text() override;
|
||||
///
|
||||
/// Text Merge Backend
|
||||
///
|
||||
struct Text : public Merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
protected:
|
||||
Text( QChar delimiter, bool line1HasKeys );
|
||||
Text( const Text* merge );
|
||||
~Text() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Implementation of virtual methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QStringList keys() const override;
|
||||
QString primaryKey() const override;
|
||||
protected:
|
||||
void open() override;
|
||||
void close() override;
|
||||
Record* readNextRecord() override;
|
||||
/////////////////////////////////
|
||||
// Implementation of virtual methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QStringList keys() const override;
|
||||
QString primaryKey() const override;
|
||||
protected:
|
||||
void open() override;
|
||||
void close() override;
|
||||
Record* readNextRecord() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private methods
|
||||
/////////////////////////////////
|
||||
QString keyFromIndex( int iField ) const;
|
||||
QStringList parseLine();
|
||||
/////////////////////////////////
|
||||
// Private methods
|
||||
/////////////////////////////////
|
||||
QString keyFromIndex( int iField ) const;
|
||||
QStringList parseLine();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
QChar mDelimeter;
|
||||
bool mLine1HasKeys;
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
QChar mDelimeter;
|
||||
bool mLine1HasKeys;
|
||||
|
||||
QFile mFile;
|
||||
QStringList mKeys;
|
||||
int mNFieldsMax;
|
||||
};
|
||||
QFile mFile;
|
||||
QStringList mKeys;
|
||||
int mNFieldsMax;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,61 +21,64 @@
|
||||
#include "TextColon.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
static const QString ID = "Text/Colon";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextColon::TextColon() : Text(':',false)
|
||||
namespace merge
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
static const QString ID = "Text/Colon";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextColon::TextColon( const TextColon* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextColon::TextColon() : Text(':',false)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextColon::~TextColon()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextColon::TextColon( const TextColon* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextColon* TextColon::clone() const
|
||||
{
|
||||
return new TextColon( this );
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextColon::~TextColon()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextColon::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextColon* TextColon::clone() const
|
||||
{
|
||||
return new TextColon( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextColon::create()
|
||||
{
|
||||
return new TextColon();
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextColon::id()
|
||||
{
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// TextColon Merge Backend
|
||||
///
|
||||
struct TextColon : public Text
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextColon();
|
||||
TextColon( const TextColon* merge );
|
||||
~TextColon() override;
|
||||
///
|
||||
/// TextColon Merge Backend
|
||||
///
|
||||
struct TextColon : public Text
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextColon();
|
||||
TextColon( const TextColon* merge );
|
||||
~TextColon() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextColon* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextColon* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,61 +21,64 @@
|
||||
#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
|
||||
///
|
||||
TextColonKeys::TextColonKeys() : Text(':',true)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextColonKeys::TextColonKeys() : Text(':',true)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextColonKeys::~TextColonKeys()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextColonKeys::~TextColonKeys()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextColonKeys* TextColonKeys::clone() const
|
||||
{
|
||||
return new TextColonKeys( this );
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextColonKeys* TextColonKeys::clone() const
|
||||
{
|
||||
return new TextColonKeys( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextColonKeys::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextColonKeys::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextColonKeys::create()
|
||||
{
|
||||
return new TextColonKeys();
|
||||
}
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextColonKeys::create()
|
||||
{
|
||||
return new TextColonKeys();
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
@@ -25,40 +25,43 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// TextColonKeys Merge Backend
|
||||
///
|
||||
struct TextColonKeys : public Text
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextColonKeys();
|
||||
TextColonKeys( const TextColonKeys* merge );
|
||||
~TextColonKeys() override;
|
||||
///
|
||||
/// TextColonKeys Merge Backend
|
||||
///
|
||||
struct TextColonKeys : public Text
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextColonKeys();
|
||||
TextColonKeys( const TextColonKeys* merge );
|
||||
~TextColonKeys() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextColonKeys* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextColonKeys* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+46
-43
@@ -21,61 +21,64 @@
|
||||
#include "TextCsv.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
namespace merge
|
||||
{
|
||||
|
||||
static const QString ID = "Text/Comma";
|
||||
static const QString ID = "Text/Comma";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextCsv::TextCsv() : Text(',',false)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextCsv::TextCsv() : Text(',',false)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextCsv::~TextCsv()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextCsv::~TextCsv()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextCsv* TextCsv::clone() const
|
||||
{
|
||||
return new TextCsv( this );
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextCsv* TextCsv::clone() const
|
||||
{
|
||||
return new TextCsv( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextCsv::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextCsv::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextCsv::create()
|
||||
{
|
||||
return new TextCsv();
|
||||
}
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextCsv::create()
|
||||
{
|
||||
return new TextCsv();
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
+28
-25
@@ -25,40 +25,43 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// TextCsv Merge Backend
|
||||
///
|
||||
struct TextCsv : public Text
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextCsv();
|
||||
TextCsv( const TextCsv* merge );
|
||||
~TextCsv() override;
|
||||
///
|
||||
/// TextCsv Merge Backend
|
||||
///
|
||||
struct TextCsv : public Text
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextCsv();
|
||||
TextCsv( const TextCsv* merge );
|
||||
~TextCsv() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextCsv* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextCsv* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,61 +21,64 @@
|
||||
#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
|
||||
///
|
||||
TextCsvKeys::TextCsvKeys() : Text(',',true)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextCsvKeys::TextCsvKeys() : Text(',',true)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextCsvKeys::~TextCsvKeys()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextCsvKeys::~TextCsvKeys()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextCsvKeys* TextCsvKeys::clone() const
|
||||
{
|
||||
return new TextCsvKeys( this );
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextCsvKeys* TextCsvKeys::clone() const
|
||||
{
|
||||
return new TextCsvKeys( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextCsvKeys::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextCsvKeys::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextCsvKeys::create()
|
||||
{
|
||||
return new TextCsvKeys();
|
||||
}
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextCsvKeys::create()
|
||||
{
|
||||
return new TextCsvKeys();
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
@@ -25,40 +25,43 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// TextCsvKeys Merge Backend
|
||||
///
|
||||
struct TextCsvKeys : public Text
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextCsvKeys();
|
||||
TextCsvKeys( const TextCsvKeys* merge );
|
||||
~TextCsvKeys() override;
|
||||
///
|
||||
/// TextCsvKeys Merge Backend
|
||||
///
|
||||
struct TextCsvKeys : public Text
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextCsvKeys();
|
||||
TextCsvKeys( const TextCsvKeys* merge );
|
||||
~TextCsvKeys() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextCsvKeys* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextCsvKeys* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,61 +21,64 @@
|
||||
#include "TextSemicolon.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
static const QString ID = "Text/Semicolon";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextSemicolon::TextSemicolon() : Text(';',false)
|
||||
namespace merge
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
static const QString ID = "Text/Semicolon";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextSemicolon::TextSemicolon( const TextSemicolon* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextSemicolon::TextSemicolon() : Text(';',false)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextSemicolon::~TextSemicolon()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextSemicolon::TextSemicolon( const TextSemicolon* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextSemicolon* TextSemicolon::clone() const
|
||||
{
|
||||
return new TextSemicolon( this );
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextSemicolon::~TextSemicolon()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextSemicolon::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextSemicolon* TextSemicolon::clone() const
|
||||
{
|
||||
return new TextSemicolon( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextSemicolon::create()
|
||||
{
|
||||
return new TextSemicolon();
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextSemicolon::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextSemicolon::create()
|
||||
{
|
||||
return new TextSemicolon();
|
||||
}
|
||||
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
@@ -25,40 +25,43 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// TextSemicolon Merge Backend
|
||||
///
|
||||
struct TextSemicolon : public Text
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextSemicolon();
|
||||
TextSemicolon( const TextSemicolon* merge );
|
||||
~TextSemicolon() override;
|
||||
///
|
||||
/// TextSemicolon Merge Backend
|
||||
///
|
||||
struct TextSemicolon : public Text
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextSemicolon();
|
||||
TextSemicolon( const TextSemicolon* merge );
|
||||
~TextSemicolon() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextSemicolon* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextSemicolon* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,61 +21,64 @@
|
||||
#include "TextSemicolonKeys.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
static const QString ID = "Text/Semicolon/Keys";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextSemicolonKeys::TextSemicolonKeys() : Text(';',true)
|
||||
namespace merge
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
static const QString ID = "Text/Semicolon/Keys";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextSemicolonKeys::TextSemicolonKeys( const TextSemicolonKeys* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextSemicolonKeys::TextSemicolonKeys() : Text(';',true)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextSemicolonKeys::~TextSemicolonKeys()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextSemicolonKeys::TextSemicolonKeys( const TextSemicolonKeys* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextSemicolonKeys* TextSemicolonKeys::clone() const
|
||||
{
|
||||
return new TextSemicolonKeys( this );
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextSemicolonKeys::~TextSemicolonKeys()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextSemicolonKeys::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextSemicolonKeys* TextSemicolonKeys::clone() const
|
||||
{
|
||||
return new TextSemicolonKeys( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextSemicolonKeys::create()
|
||||
{
|
||||
return new TextSemicolonKeys();
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextSemicolonKeys::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextSemicolonKeys::create()
|
||||
{
|
||||
return new TextSemicolonKeys();
|
||||
}
|
||||
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
@@ -25,40 +25,43 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// TextSemicolonKeys Merge Backend
|
||||
///
|
||||
struct TextSemicolonKeys : public Text
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextSemicolonKeys();
|
||||
TextSemicolonKeys( const TextSemicolonKeys* merge );
|
||||
~TextSemicolonKeys() override;
|
||||
///
|
||||
/// TextSemicolonKeys Merge Backend
|
||||
///
|
||||
struct TextSemicolonKeys : public Text
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextSemicolonKeys();
|
||||
TextSemicolonKeys( const TextSemicolonKeys* merge );
|
||||
~TextSemicolonKeys() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextSemicolonKeys* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextSemicolonKeys* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+46
-43
@@ -21,61 +21,64 @@
|
||||
#include "TextTsv.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
namespace merge
|
||||
{
|
||||
|
||||
static const QString ID = "Text/Tab";
|
||||
static const QString ID = "Text/Tab";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextTsv::TextTsv() : Text('\t',false)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextTsv::TextTsv() : Text('\t',false)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextTsv::~TextTsv()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextTsv::~TextTsv()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextTsv* TextTsv::clone() const
|
||||
{
|
||||
return new TextTsv( this );
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextTsv* TextTsv::clone() const
|
||||
{
|
||||
return new TextTsv( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextTsv::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextTsv::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextTsv::create()
|
||||
{
|
||||
return new TextTsv();
|
||||
}
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextTsv::create()
|
||||
{
|
||||
return new TextTsv();
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
+28
-25
@@ -25,40 +25,43 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// TextTsv Merge Backend
|
||||
///
|
||||
struct TextTsv : public Text
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextTsv();
|
||||
TextTsv( const TextTsv* merge );
|
||||
~TextTsv() override;
|
||||
///
|
||||
/// TextTsv Merge Backend
|
||||
///
|
||||
struct TextTsv : public Text
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextTsv();
|
||||
TextTsv( const TextTsv* merge );
|
||||
~TextTsv() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextTsv* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextTsv* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,61 +21,64 @@
|
||||
#include "TextTsvKeys.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
static const QString ID = "Text/Tab/Line1Keys";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextTsvKeys::TextTsvKeys() : Text('\t',true)
|
||||
namespace merge
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
static const QString ID = "Text/Tab/Line1Keys";
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextTsvKeys::TextTsvKeys( const TextTsvKeys* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextTsvKeys::TextTsvKeys() : Text('\t',true)
|
||||
{
|
||||
mId = ID;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextTsvKeys::~TextTsvKeys()
|
||||
{
|
||||
}
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
TextTsvKeys::TextTsvKeys( const TextTsvKeys* merge ) : Text( merge )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextTsvKeys* TextTsvKeys::clone() const
|
||||
{
|
||||
return new TextTsvKeys( this );
|
||||
}
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
TextTsvKeys::~TextTsvKeys()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextTsvKeys::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
TextTsvKeys* TextTsvKeys::clone() const
|
||||
{
|
||||
return new TextTsvKeys( this );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextTsvKeys::create()
|
||||
{
|
||||
return new TextTsvKeys();
|
||||
}
|
||||
///
|
||||
/// Get ID
|
||||
///
|
||||
QString TextTsvKeys::id()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
} // namespace glabels::merge
|
||||
|
||||
///
|
||||
/// Create
|
||||
///
|
||||
Merge* TextTsvKeys::create()
|
||||
{
|
||||
return new TextTsvKeys();
|
||||
}
|
||||
|
||||
} // namespace merge
|
||||
} // namespace glabels
|
||||
|
||||
@@ -25,40 +25,43 @@
|
||||
#include "Text.h"
|
||||
|
||||
|
||||
namespace glabels::merge
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// TextTsvKeys Merge Backend
|
||||
///
|
||||
struct TextTsvKeys : public Text
|
||||
namespace merge
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextTsvKeys();
|
||||
TextTsvKeys( const TextTsvKeys* merge );
|
||||
~TextTsvKeys() override;
|
||||
///
|
||||
/// TextTsvKeys Merge Backend
|
||||
///
|
||||
struct TextTsvKeys : public Text
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
TextTsvKeys();
|
||||
TextTsvKeys( const TextTsvKeys* merge );
|
||||
~TextTsvKeys() override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextTsvKeys* clone() const override;
|
||||
/////////////////////////////////
|
||||
// Object duplication
|
||||
/////////////////////////////////
|
||||
public:
|
||||
TextTsvKeys* clone() const override;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
/////////////////////////////////
|
||||
// Static methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static QString id();
|
||||
static Merge* create();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+22
-19
@@ -21,25 +21,28 @@
|
||||
#include "Category.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
Category::Category( const QString &id, const QString &name )
|
||||
: mId(id), mName(name)
|
||||
namespace model
|
||||
{
|
||||
// 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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class Category
|
||||
namespace model
|
||||
{
|
||||
|
||||
public:
|
||||
Category( const QString& id, const QString& name );
|
||||
class Category
|
||||
{
|
||||
|
||||
QString id() const;
|
||||
QString name() const;
|
||||
public:
|
||||
Category( const QString& id, const QString& name );
|
||||
|
||||
QString id() const;
|
||||
QString name() const;
|
||||
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
QString mName;
|
||||
private:
|
||||
QString mId;
|
||||
QString mName;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+171
-168
@@ -23,180 +23,183 @@
|
||||
#include "merge/Record.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Default Constructor
|
||||
///
|
||||
ColorNode::ColorNode()
|
||||
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
|
||||
namespace model
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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 )
|
||||
///
|
||||
/// Default Constructor
|
||||
///
|
||||
ColorNode::ColorNode()
|
||||
: mIsField(false), mColor(QColor::fromRgba(0x00000000)), mKey("")
|
||||
{
|
||||
if ( record == nullptr )
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( record->contains( mKey ) )
|
||||
{
|
||||
return QColor( (*record)[ mKey ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
}
|
||||
// empty
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
} // 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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Color Node Type
|
||||
///
|
||||
struct ColorNode
|
||||
namespace model
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
ColorNode();
|
||||
///
|
||||
/// Color Node Type
|
||||
///
|
||||
struct 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
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool operator==( const ColorNode& cn );
|
||||
/////////////////////////////////
|
||||
// Operators
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool operator==( const ColorNode& cn );
|
||||
|
||||
bool operator!=( const ColorNode& cn );
|
||||
bool operator!=( const ColorNode& cn );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Field Flag Property
|
||||
//
|
||||
bool isField() const;
|
||||
void setField( bool isField );
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Field Flag Property
|
||||
//
|
||||
bool isField() const;
|
||||
void setField( bool isField );
|
||||
|
||||
|
||||
//
|
||||
// Color Property
|
||||
//
|
||||
const QColor& color() const;
|
||||
void setColor( const QColor& color );
|
||||
//
|
||||
// Color Property
|
||||
//
|
||||
const QColor& color() const;
|
||||
void setColor( const QColor& color );
|
||||
|
||||
|
||||
//
|
||||
// Key Property
|
||||
//
|
||||
const QString& key() const;
|
||||
void setKey( const QString& key );
|
||||
//
|
||||
// Key Property
|
||||
//
|
||||
const QString& key() const;
|
||||
void setKey( const QString& key );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Misc. Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
uint32_t rgba() const;
|
||||
QColor color( merge::Record* record ) const;
|
||||
/////////////////////////////////
|
||||
// Misc. Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
uint32_t rgba() const;
|
||||
QColor color( merge::Record* record ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
bool mIsField;
|
||||
QColor mColor;
|
||||
QString mKey;
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
bool mIsField;
|
||||
QColor mColor;
|
||||
QString mKey;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
-6
@@ -22,15 +22,18 @@
|
||||
#define model_Config_h
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace Config
|
||||
namespace model
|
||||
{
|
||||
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
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
namespace model
|
||||
{
|
||||
|
||||
const double PTS_PER_PT = 1.0;
|
||||
const double PTS_PER_INCH = 72.0;
|
||||
const double PTS_PER_MM = 2.83464566929;
|
||||
const double PTS_PER_CM = (10.0*PTS_PER_MM);
|
||||
const double PTS_PER_PICA = 12.0;
|
||||
const double PTS_PER_PT = 1.0;
|
||||
const double PTS_PER_INCH = 72.0;
|
||||
const double PTS_PER_MM = 2.83464566929;
|
||||
const double PTS_PER_CM = (10.0*PTS_PER_MM);
|
||||
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
|
||||
|
||||
+57
-54
@@ -23,88 +23,91 @@
|
||||
#include "ModelImageObject.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
DataCache::DataCache()
|
||||
namespace model
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
DataCache::DataCache( const QList<ModelObject*>& objects )
|
||||
{
|
||||
foreach( ModelObject* object, objects )
|
||||
DataCache::DataCache()
|
||||
{
|
||||
if ( ModelImageObject* imageObject = dynamic_cast<ModelImageObject*>(object) )
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
DataCache::DataCache( const QList<ModelObject*>& objects )
|
||||
{
|
||||
foreach( ModelObject* object, objects )
|
||||
{
|
||||
TextNode filenameNode = imageObject->filenameNode();
|
||||
if ( !filenameNode.isField() )
|
||||
if ( ModelImageObject* imageObject = dynamic_cast<ModelImageObject*>(object) )
|
||||
{
|
||||
if ( const QImage* image = imageObject->image() )
|
||||
TextNode filenameNode = imageObject->filenameNode();
|
||||
if ( !filenameNode.isField() )
|
||||
{
|
||||
addImage( filenameNode.data(), *image );
|
||||
}
|
||||
else
|
||||
{
|
||||
QByteArray svg = imageObject->svg();
|
||||
if ( !svg.isEmpty() )
|
||||
if ( const QImage* image = imageObject->image() )
|
||||
{
|
||||
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
|
||||
{
|
||||
return mImageMap.contains( name );
|
||||
}
|
||||
bool DataCache::hasImage( const QString& name ) const
|
||||
{
|
||||
return mImageMap.contains( name );
|
||||
}
|
||||
|
||||
|
||||
QImage DataCache::getImage( const QString& name ) const
|
||||
{
|
||||
return mImageMap[ name ];
|
||||
}
|
||||
QImage DataCache::getImage( const QString& name ) const
|
||||
{
|
||||
return mImageMap[ name ];
|
||||
}
|
||||
|
||||
|
||||
void DataCache::addImage( const QString& name, const QImage& image )
|
||||
{
|
||||
mImageMap[ name ] = image;
|
||||
}
|
||||
void DataCache::addImage( const QString& name, const QImage& image )
|
||||
{
|
||||
mImageMap[ name ] = image;
|
||||
}
|
||||
|
||||
|
||||
QList<QString> DataCache::imageNames() const
|
||||
{
|
||||
return mImageMap.keys();
|
||||
}
|
||||
QList<QString> DataCache::imageNames() const
|
||||
{
|
||||
return mImageMap.keys();
|
||||
}
|
||||
|
||||
|
||||
bool DataCache::hasSvg( const QString& name ) const
|
||||
{
|
||||
return mSvgMap.contains( name );
|
||||
}
|
||||
bool DataCache::hasSvg( const QString& name ) const
|
||||
{
|
||||
return mSvgMap.contains( name );
|
||||
}
|
||||
|
||||
|
||||
QByteArray DataCache::getSvg( const QString& name ) const
|
||||
{
|
||||
return mSvgMap[ name ];
|
||||
}
|
||||
QByteArray DataCache::getSvg( const QString& name ) const
|
||||
{
|
||||
return mSvgMap[ name ];
|
||||
}
|
||||
|
||||
|
||||
void DataCache::addSvg( const QString& name, const QByteArray& svg )
|
||||
{
|
||||
mSvgMap[ name ] = svg;
|
||||
}
|
||||
void DataCache::addSvg( const QString& name, const QByteArray& svg )
|
||||
{
|
||||
mSvgMap[ name ] = svg;
|
||||
}
|
||||
|
||||
|
||||
QList<QString> DataCache::svgNames() const
|
||||
{
|
||||
return mSvgMap.keys();
|
||||
}
|
||||
QList<QString> DataCache::svgNames() const
|
||||
{
|
||||
return mSvgMap.keys();
|
||||
}
|
||||
|
||||
|
||||
} // namespace glabels::model
|
||||
}
|
||||
}
|
||||
|
||||
+21
-18
@@ -25,33 +25,36 @@
|
||||
#include "Model.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class DataCache
|
||||
namespace model
|
||||
{
|
||||
public:
|
||||
DataCache();
|
||||
|
||||
class DataCache
|
||||
{
|
||||
public:
|
||||
DataCache();
|
||||
|
||||
DataCache( const QList<ModelObject*>& objects );
|
||||
DataCache( const QList<ModelObject*>& objects );
|
||||
|
||||
bool hasImage( const QString& name ) const;
|
||||
QImage getImage( const QString& name ) const;
|
||||
void addImage( const QString& name, const QImage& image );
|
||||
QList<QString> imageNames() const;
|
||||
bool hasImage( const QString& name ) const;
|
||||
QImage getImage( const QString& name ) const;
|
||||
void addImage( const QString& name, const QImage& image );
|
||||
QList<QString> imageNames() const;
|
||||
|
||||
bool hasSvg( const QString& name ) const;
|
||||
QByteArray getSvg( const QString& name ) const;
|
||||
void addSvg( const QString& name, const QByteArray& svg );
|
||||
QList<QString> svgNames() const;
|
||||
bool hasSvg( const QString& name ) const;
|
||||
QByteArray getSvg( const QString& name ) const;
|
||||
void addSvg( const QString& name, const QByteArray& svg );
|
||||
QList<QString> svgNames() const;
|
||||
|
||||
|
||||
private:
|
||||
QMap<QString,QImage> mImageMap;
|
||||
QMap<QString,QByteArray> mSvgMap;
|
||||
private:
|
||||
QMap<QString,QImage> mImageMap;
|
||||
QMap<QString,QByteArray> mSvgMap;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+568
-565
File diff suppressed because it is too large
Load Diff
+74
-71
@@ -33,108 +33,111 @@
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class Db
|
||||
namespace model
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Db)
|
||||
|
||||
private:
|
||||
Db();
|
||||
class Db
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Db)
|
||||
|
||||
private:
|
||||
Db();
|
||||
|
||||
|
||||
public:
|
||||
static void init();
|
||||
static Db* instance();
|
||||
public:
|
||||
static void init();
|
||||
static Db* instance();
|
||||
|
||||
|
||||
static const QList<Paper*>& papers();
|
||||
static const QStringList& paperIds();
|
||||
static const QStringList& paperNames();
|
||||
static const QList<Paper*>& papers();
|
||||
static const QStringList& paperIds();
|
||||
static const QStringList& paperNames();
|
||||
|
||||
static const QList<Category*>& categories();
|
||||
static const QStringList& categoryIds();
|
||||
static const QStringList& categoryNames();
|
||||
static const QList<Category*>& categories();
|
||||
static const QStringList& categoryIds();
|
||||
static const QStringList& categoryNames();
|
||||
|
||||
static const QList<Vendor*>& vendors();
|
||||
static const QStringList& vendorNames();
|
||||
static const QList<Vendor*>& vendors();
|
||||
static const QStringList& vendorNames();
|
||||
|
||||
static const QList<Template*>& templates();
|
||||
static const QList<Template*>& templates();
|
||||
|
||||
|
||||
static void registerPaper( Paper *paper );
|
||||
static const Paper *lookupPaperFromName( const QString& name );
|
||||
static const Paper *lookupPaperFromId( const QString& id );
|
||||
static QString lookupPaperIdFromName( const QString& name );
|
||||
static QString lookupPaperNameFromId( const QString& id );
|
||||
static bool isPaperIdKnown( const QString& id );
|
||||
static bool isPaperIdOther( const QString& id );
|
||||
static void registerPaper( Paper *paper );
|
||||
static const Paper *lookupPaperFromName( const QString& name );
|
||||
static const Paper *lookupPaperFromId( const QString& id );
|
||||
static QString lookupPaperIdFromName( const QString& name );
|
||||
static QString lookupPaperNameFromId( const QString& id );
|
||||
static bool isPaperIdKnown( const QString& id );
|
||||
static bool isPaperIdOther( const QString& id );
|
||||
|
||||
static void registerCategory( Category *category );
|
||||
static const Category *lookupCategoryFromName( const QString& name );
|
||||
static const Category *lookupCategoryFromId( const QString& id );
|
||||
static QString lookupCategoryIdFromName( const QString& name );
|
||||
static QString lookupCategoryNameFromId( const QString& id );
|
||||
static bool isCategoryIdKnown( const QString& id );
|
||||
static void registerCategory( Category *category );
|
||||
static const Category *lookupCategoryFromName( const QString& name );
|
||||
static const Category *lookupCategoryFromId( const QString& id );
|
||||
static QString lookupCategoryIdFromName( const QString& name );
|
||||
static QString lookupCategoryNameFromId( const QString& id );
|
||||
static bool isCategoryIdKnown( const QString& id );
|
||||
|
||||
static void registerVendor( Vendor *vendor );
|
||||
static const Vendor *lookupVendorFromName( const QString& name );
|
||||
static QString lookupVendorUrlFromName( const QString& name );
|
||||
static bool isVendorNameKnown( const QString& id );
|
||||
static void registerVendor( Vendor *vendor );
|
||||
static const Vendor *lookupVendorFromName( const QString& name );
|
||||
static QString lookupVendorUrlFromName( const QString& name );
|
||||
static bool isVendorNameKnown( const QString& id );
|
||||
|
||||
static void registerTemplate( Template *tmplate );
|
||||
static const Template *lookupTemplateFromName( const QString& name );
|
||||
static const Template *lookupTemplateFromBrandPart( const QString& brand,
|
||||
const QString& part );
|
||||
static bool isTemplateKnown( const QString& brand, const QString& part );
|
||||
static QStringList getNameListOfSimilarTemplates( const QString& name );
|
||||
static void registerTemplate( Template *tmplate );
|
||||
static const Template *lookupTemplateFromName( const QString& name );
|
||||
static const Template *lookupTemplateFromBrandPart( const QString& brand,
|
||||
const QString& part );
|
||||
static bool isTemplateKnown( const QString& brand, const QString& part );
|
||||
static QStringList getNameListOfSimilarTemplates( const QString& name );
|
||||
|
||||
static void registerUserTemplate( Template *tmplate );
|
||||
static void deleteUserTemplateByName( const QString& name );
|
||||
static void deleteUserTemplateByBrandPart( const QString& brand,
|
||||
const QString& part );
|
||||
static void registerUserTemplate( Template *tmplate );
|
||||
static void deleteUserTemplateByName( const QString& name );
|
||||
static void deleteUserTemplateByBrandPart( const QString& brand,
|
||||
const QString& part );
|
||||
|
||||
static void printKnownPapers();
|
||||
static void printKnownCategories();
|
||||
static void printKnownVendors();
|
||||
static void printKnownTemplates();
|
||||
static void printKnownPapers();
|
||||
static void printKnownCategories();
|
||||
static void printKnownVendors();
|
||||
static void printKnownTemplates();
|
||||
|
||||
|
||||
private:
|
||||
static QDir systemTemplatesDir();
|
||||
private:
|
||||
static QDir systemTemplatesDir();
|
||||
|
||||
static void readPapers();
|
||||
static void readPapersFromDir( const QDir& dir );
|
||||
static void readPapers();
|
||||
static void readPapersFromDir( const QDir& dir );
|
||||
|
||||
static void readCategories();
|
||||
static void readCategoriesFromDir( const QDir& dir );
|
||||
static void readCategories();
|
||||
static void readCategoriesFromDir( const QDir& dir );
|
||||
|
||||
static void readVendors();
|
||||
static void readVendorsFromDir( const QDir& dir );
|
||||
static void readVendors();
|
||||
static void readVendorsFromDir( const QDir& dir );
|
||||
|
||||
static void readTemplates();
|
||||
static void readTemplatesFromDir( const QDir& dir );
|
||||
static void readTemplates();
|
||||
static void readTemplatesFromDir( const QDir& dir );
|
||||
|
||||
|
||||
private:
|
||||
static QList<Paper*> mPapers;
|
||||
static QStringList mPaperIds;
|
||||
static QStringList mPaperNames;
|
||||
private:
|
||||
static QList<Paper*> mPapers;
|
||||
static QStringList mPaperIds;
|
||||
static QStringList mPaperNames;
|
||||
|
||||
static QList<Category*> mCategories;
|
||||
static QStringList mCategoryIds;
|
||||
static QStringList mCategoryNames;
|
||||
static QList<Category*> mCategories;
|
||||
static QStringList mCategoryIds;
|
||||
static QStringList mCategoryNames;
|
||||
|
||||
static QList<Vendor*> mVendors;
|
||||
static QStringList mVendorNames;
|
||||
static QList<Vendor*> mVendors;
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
Distance::Distance( double d, Units::Enum unitsEnum )
|
||||
namespace model
|
||||
{
|
||||
switch (unitsEnum)
|
||||
|
||||
Distance::Distance( double d, Units::Enum unitsEnum )
|
||||
{
|
||||
case Units::PT:
|
||||
mDPts = d;
|
||||
break;
|
||||
case Units::IN:
|
||||
mDPts = d * PTS_PER_INCH;
|
||||
break;
|
||||
case Units::MM:
|
||||
mDPts = d * PTS_PER_MM;
|
||||
break;
|
||||
case Units::CM:
|
||||
mDPts = d * PTS_PER_CM;
|
||||
break;
|
||||
case Units::PC:
|
||||
mDPts = d * PTS_PER_PICA;
|
||||
break;
|
||||
default:
|
||||
mDPts = d;
|
||||
break;
|
||||
switch (unitsEnum)
|
||||
{
|
||||
case Units::PT:
|
||||
mDPts = d;
|
||||
break;
|
||||
case Units::IN:
|
||||
mDPts = d * PTS_PER_INCH;
|
||||
break;
|
||||
case Units::MM:
|
||||
mDPts = d * PTS_PER_MM;
|
||||
break;
|
||||
case Units::CM:
|
||||
mDPts = d * PTS_PER_CM;
|
||||
break;
|
||||
case Units::PC:
|
||||
mDPts = d * PTS_PER_PICA;
|
||||
break;
|
||||
default:
|
||||
mDPts = d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Distance::Distance( double d, const Units& units )
|
||||
{
|
||||
switch (units.toEnum())
|
||||
Distance::Distance( double d, const Units& units )
|
||||
{
|
||||
case Units::PT:
|
||||
mDPts = d;
|
||||
break;
|
||||
case Units::IN:
|
||||
mDPts = d * PTS_PER_INCH;
|
||||
break;
|
||||
case Units::MM:
|
||||
mDPts = d * PTS_PER_MM;
|
||||
break;
|
||||
case Units::CM:
|
||||
mDPts = d * PTS_PER_CM;
|
||||
break;
|
||||
case Units::PC:
|
||||
mDPts = d * PTS_PER_PICA;
|
||||
break;
|
||||
default:
|
||||
mDPts = d;
|
||||
break;
|
||||
switch (units.toEnum())
|
||||
{
|
||||
case Units::PT:
|
||||
mDPts = d;
|
||||
break;
|
||||
case Units::IN:
|
||||
mDPts = d * PTS_PER_INCH;
|
||||
break;
|
||||
case Units::MM:
|
||||
mDPts = d * PTS_PER_MM;
|
||||
break;
|
||||
case Units::CM:
|
||||
mDPts = d * PTS_PER_CM;
|
||||
break;
|
||||
case Units::PC:
|
||||
mDPts = d * PTS_PER_PICA;
|
||||
break;
|
||||
default:
|
||||
mDPts = d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Distance::Distance( double d, const QString& unitsId )
|
||||
{
|
||||
Units units = Units( unitsId );
|
||||
Distance::Distance( double d, const QString& unitsId )
|
||||
{
|
||||
Units units = Units( unitsId );
|
||||
|
||||
switch (units.toEnum())
|
||||
{
|
||||
case Units::PT:
|
||||
mDPts = d;
|
||||
break;
|
||||
case Units::IN:
|
||||
mDPts = d * PTS_PER_INCH;
|
||||
break;
|
||||
case Units::MM:
|
||||
mDPts = d * PTS_PER_MM;
|
||||
break;
|
||||
case Units::CM:
|
||||
mDPts = d * PTS_PER_CM;
|
||||
break;
|
||||
case Units::PC:
|
||||
mDPts = d * PTS_PER_PICA;
|
||||
break;
|
||||
default:
|
||||
mDPts = d;
|
||||
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 << "\"";
|
||||
switch (units.toEnum())
|
||||
{
|
||||
case Units::PT:
|
||||
mDPts = d;
|
||||
break;
|
||||
case Units::IN:
|
||||
mDPts = d * PTS_PER_INCH;
|
||||
break;
|
||||
case Units::MM:
|
||||
mDPts = d * PTS_PER_MM;
|
||||
break;
|
||||
case Units::CM:
|
||||
mDPts = d * PTS_PER_CM;
|
||||
break;
|
||||
case Units::PC:
|
||||
mDPts = d * PTS_PER_PICA;
|
||||
break;
|
||||
default:
|
||||
mDPts = d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Distance( value, unitsString );
|
||||
}
|
||||
|
||||
|
||||
double Distance::inUnits( const Units& units ) const
|
||||
{
|
||||
double d;
|
||||
|
||||
switch (units.toEnum())
|
||||
Distance Distance::fromString( const QString& string )
|
||||
{
|
||||
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;
|
||||
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 );
|
||||
}
|
||||
|
||||
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 d;
|
||||
|
||||
switch (unitsEnum)
|
||||
double Distance::inUnits( Units::Enum unitsEnum ) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
double d;
|
||||
|
||||
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
|
||||
{
|
||||
return inUnits( Units( unitsId ) );
|
||||
double Distance::inUnits( const QString& unitsId ) const
|
||||
{
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class Distance
|
||||
namespace model
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Distance)
|
||||
|
||||
public:
|
||||
Distance();
|
||||
Distance( double d, Units::Enum unitsEnum = Units::PT );
|
||||
Distance( double d, const Units& units );
|
||||
Distance( double d, const QString& unitsId );
|
||||
class Distance
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Distance)
|
||||
|
||||
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 );
|
||||
public:
|
||||
Distance();
|
||||
Distance( double d, Units::Enum unitsEnum = Units::PT );
|
||||
Distance( double d, const Units& units );
|
||||
Distance( double d, const QString& unitsId );
|
||||
|
||||
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 in() const;
|
||||
double mm() const;
|
||||
double cm() const;
|
||||
double pc() const;
|
||||
double inUnits( const Units& units ) const;
|
||||
double inUnits( Units::Enum unitsEnum ) const;
|
||||
double inUnits( const QString& unitsId ) const;
|
||||
double pt() const;
|
||||
double in() const;
|
||||
double mm() const;
|
||||
double cm() const;
|
||||
double pc() const;
|
||||
double inUnits( const Units& units ) const;
|
||||
double inUnits( Units::Enum unitsEnum ) const;
|
||||
double inUnits( const QString& unitsId ) const;
|
||||
|
||||
|
||||
QString toString( const Units& units ) const;
|
||||
QString toString( Units::Enum unitsEnum ) const;
|
||||
QString toString( const QString& unitsId ) const;
|
||||
QString toString( const Units& units ) const;
|
||||
QString toString( Units::Enum unitsEnum ) const;
|
||||
QString toString( const QString& unitsId ) const;
|
||||
|
||||
|
||||
Distance& operator+=( const Distance& d );
|
||||
Distance& operator-=( const Distance& d );
|
||||
Distance operator-();
|
||||
Distance& operator+=( const Distance& d );
|
||||
Distance& operator-=( const Distance& d );
|
||||
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*( double x, const Distance& d );
|
||||
friend inline Distance operator*( const Distance& d, double x );
|
||||
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& 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*( const Distance& d, double x );
|
||||
friend inline double operator/( const Distance& d1, const Distance& d2 );
|
||||
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 min( 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 fabs( const Distance& d );
|
||||
friend inline Distance min( 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 );
|
||||
|
||||
|
||||
private:
|
||||
double mDPts;
|
||||
private:
|
||||
double mDPts;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,199 +106,202 @@ namespace glabels::model
|
||||
|
||||
#include "Constants.h"
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
inline Distance::Distance() : mDPts(0)
|
||||
namespace model
|
||||
{
|
||||
}
|
||||
|
||||
inline Distance::Distance() : mDPts(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline Distance Distance::pt( double dPts )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dPts;
|
||||
return d;
|
||||
}
|
||||
inline Distance Distance::pt( double dPts )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dPts;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
inline Distance Distance::in( double dInches )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dInches * PTS_PER_INCH;
|
||||
return d;
|
||||
}
|
||||
inline Distance Distance::in( double dInches )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dInches * PTS_PER_INCH;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
inline Distance Distance::mm( double dMm )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dMm * PTS_PER_MM;
|
||||
return d;
|
||||
}
|
||||
inline Distance Distance::mm( double dMm )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dMm * PTS_PER_MM;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
inline Distance Distance::cm( double dCm )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dCm * PTS_PER_CM;
|
||||
return d;
|
||||
}
|
||||
inline Distance Distance::cm( double dCm )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dCm * PTS_PER_CM;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
inline Distance Distance::pc( double dPicas )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dPicas * PTS_PER_PICA;
|
||||
return d;
|
||||
}
|
||||
inline Distance Distance::pc( double dPicas )
|
||||
{
|
||||
Distance d;
|
||||
d.mDPts = dPicas * PTS_PER_PICA;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
inline double Distance::pt() const
|
||||
{
|
||||
return mDPts;
|
||||
}
|
||||
inline double Distance::pt() const
|
||||
{
|
||||
return mDPts;
|
||||
}
|
||||
|
||||
|
||||
inline double Distance::in() const
|
||||
{
|
||||
return mDPts / PTS_PER_INCH;
|
||||
}
|
||||
inline double Distance::in() const
|
||||
{
|
||||
return mDPts / PTS_PER_INCH;
|
||||
}
|
||||
|
||||
|
||||
inline double Distance::mm() const
|
||||
{
|
||||
return mDPts / PTS_PER_MM;
|
||||
}
|
||||
inline double Distance::mm() const
|
||||
{
|
||||
return mDPts / PTS_PER_MM;
|
||||
}
|
||||
|
||||
|
||||
inline double Distance::cm() const
|
||||
{
|
||||
return mDPts / PTS_PER_CM;
|
||||
}
|
||||
inline double Distance::cm() const
|
||||
{
|
||||
return mDPts / PTS_PER_CM;
|
||||
}
|
||||
|
||||
|
||||
inline double Distance::pc() const
|
||||
{
|
||||
return mDPts / PTS_PER_PICA;
|
||||
}
|
||||
inline double Distance::pc() const
|
||||
{
|
||||
return mDPts / PTS_PER_PICA;
|
||||
}
|
||||
|
||||
|
||||
inline Distance& Distance::operator+=( const Distance& d )
|
||||
{
|
||||
mDPts += d.mDPts;
|
||||
return *this;
|
||||
}
|
||||
inline Distance& Distance::operator+=( const Distance& d )
|
||||
{
|
||||
mDPts += d.mDPts;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Distance& Distance::operator-=( const Distance& d )
|
||||
{
|
||||
mDPts -= d.mDPts;
|
||||
return *this;
|
||||
}
|
||||
inline Distance& Distance::operator-=( const Distance& d )
|
||||
{
|
||||
mDPts -= d.mDPts;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Distance Distance::operator-()
|
||||
{
|
||||
return Distance::pt( -mDPts );
|
||||
}
|
||||
inline Distance Distance::operator-()
|
||||
{
|
||||
return Distance::pt( -mDPts );
|
||||
}
|
||||
|
||||
|
||||
inline Distance operator+( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return Distance::pt( d1.mDPts + d2.mDPts );
|
||||
}
|
||||
inline Distance operator+( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return Distance::pt( d1.mDPts + d2.mDPts );
|
||||
}
|
||||
|
||||
|
||||
inline Distance operator-( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return Distance::pt( d1.mDPts - d2.mDPts );
|
||||
}
|
||||
inline Distance operator-( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return Distance::pt( d1.mDPts - d2.mDPts );
|
||||
}
|
||||
|
||||
|
||||
inline Distance operator*( double x, const Distance& d )
|
||||
{
|
||||
return Distance::pt( x * d.mDPts );
|
||||
}
|
||||
inline Distance operator*( double x, const Distance& d )
|
||||
{
|
||||
return Distance::pt( x * d.mDPts );
|
||||
}
|
||||
|
||||
|
||||
inline Distance operator*( const Distance& d, double x )
|
||||
{
|
||||
return Distance::pt( d.mDPts * x );
|
||||
}
|
||||
inline Distance operator*( const Distance& d, double x )
|
||||
{
|
||||
return Distance::pt( d.mDPts * x );
|
||||
}
|
||||
|
||||
|
||||
inline double operator/( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts / d2.mDPts;
|
||||
}
|
||||
inline double operator/( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts / d2.mDPts;
|
||||
}
|
||||
|
||||
|
||||
inline Distance operator/( const Distance& d, double x )
|
||||
{
|
||||
return Distance::pt( d.mDPts / x );
|
||||
}
|
||||
inline Distance operator/( const Distance& d, double x )
|
||||
{
|
||||
return Distance::pt( d.mDPts / x );
|
||||
}
|
||||
|
||||
|
||||
inline bool operator<( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts < d2.mDPts;
|
||||
}
|
||||
inline bool operator<( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts < d2.mDPts;
|
||||
}
|
||||
|
||||
|
||||
inline bool operator<=( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts <= d2.mDPts;
|
||||
}
|
||||
inline bool operator<=( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts <= d2.mDPts;
|
||||
}
|
||||
|
||||
|
||||
inline bool operator>( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts > d2.mDPts;
|
||||
}
|
||||
inline bool operator>( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts > d2.mDPts;
|
||||
}
|
||||
|
||||
|
||||
inline bool operator>=( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts >= d2.mDPts;
|
||||
}
|
||||
inline bool operator>=( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts >= d2.mDPts;
|
||||
}
|
||||
|
||||
|
||||
inline bool operator==( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts == d2.mDPts;
|
||||
}
|
||||
inline bool operator==( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts == d2.mDPts;
|
||||
}
|
||||
|
||||
|
||||
inline bool operator!=( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts != d2.mDPts;
|
||||
}
|
||||
inline bool operator!=( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return d1.mDPts != d2.mDPts;
|
||||
}
|
||||
|
||||
|
||||
inline Distance fabs( const Distance& d )
|
||||
{
|
||||
return Distance::pt( qFabs( d.mDPts ) );
|
||||
}
|
||||
inline Distance fabs( const Distance& d )
|
||||
{
|
||||
return Distance::pt( qFabs( d.mDPts ) );
|
||||
}
|
||||
|
||||
|
||||
inline Distance min( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return (d1.mDPts < d2.mDPts) ? d1 : d2;
|
||||
}
|
||||
inline Distance min( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return (d1.mDPts < d2.mDPts) ? d1 : d2;
|
||||
}
|
||||
|
||||
|
||||
inline Distance max( const Distance& d1, const Distance& d2 )
|
||||
{
|
||||
return (d1.mDPts > d2.mDPts) ? d1 : d2;
|
||||
inline Distance max( const Distance& d1, const Distance& 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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
QString FileUtil::addExtension( const QString& rawFilename, const QString& extension )
|
||||
namespace model
|
||||
{
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
namespace FileUtil
|
||||
namespace model
|
||||
{
|
||||
|
||||
QString addExtension( const QString& rawFilename, const QString& extension );
|
||||
namespace FileUtil
|
||||
{
|
||||
|
||||
QDir systemTemplatesDir();
|
||||
QDir userTemplatesDir();
|
||||
QString addExtension( const QString& rawFilename, const QString& extension );
|
||||
|
||||
QDir systemTemplatesDir();
|
||||
QDir userTemplatesDir();
|
||||
|
||||
QDir translationsDir();
|
||||
}
|
||||
|
||||
QDir translationsDir();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+97
-94
@@ -25,114 +25,117 @@
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
Frame::Frame( const QString& id )
|
||||
: mId(id), mNLabels(0), mLayoutDescription("")
|
||||
namespace model
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Frame::Frame( const Frame& other )
|
||||
{
|
||||
mId = other.mId;
|
||||
mNLabels = 0;
|
||||
|
||||
foreach ( Layout *layout, mLayouts )
|
||||
Frame::Frame( const QString& id )
|
||||
: mId(id), mNLabels(0), mLayoutDescription("")
|
||||
{
|
||||
addLayout( layout->dup() );
|
||||
// empty
|
||||
}
|
||||
|
||||
foreach ( Markup *markup, mMarkups )
|
||||
|
||||
|
||||
Frame::Frame( const Frame& other )
|
||||
{
|
||||
addMarkup( markup->dup() );
|
||||
}
|
||||
}
|
||||
mId = other.mId;
|
||||
mNLabels = 0;
|
||||
|
||||
|
||||
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++ )
|
||||
foreach ( Layout *layout, mLayouts )
|
||||
{
|
||||
for ( int ix = 0; ix < layout->nx(); ix++ )
|
||||
{
|
||||
origins[i++] = Point( ix*layout->dx() + layout->x0(), iy*layout->dy() + layout->y0() );
|
||||
}
|
||||
addLayout( layout->dup() );
|
||||
}
|
||||
|
||||
foreach ( Markup *markup, mMarkups )
|
||||
{
|
||||
addMarkup( markup->dup() );
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
QString Frame::id() const
|
||||
{
|
||||
/*
|
||||
* 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);
|
||||
return mId;
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
int Frame::nLabels() const
|
||||
{
|
||||
/* Translators: %1 is the total number of labels on a page (sheet). */
|
||||
mLayoutDescription = QString( tr("%1 per sheet") ).arg(mNLabels);
|
||||
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++ )
|
||||
{
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward references
|
||||
class Markup;
|
||||
|
||||
|
||||
class Frame
|
||||
namespace model
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Frame)
|
||||
|
||||
protected:
|
||||
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;
|
||||
|
||||
// Forward references
|
||||
class Markup;
|
||||
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
int mNLabels;
|
||||
QString mLayoutDescription;
|
||||
class Frame
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Frame)
|
||||
|
||||
QList<Layout*> mLayouts;
|
||||
QList<Markup*> mMarkups;
|
||||
};
|
||||
protected:
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
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)
|
||||
namespace model
|
||||
{
|
||||
Distance wReal = (mW == 0) ? 2*mR1 : mW;
|
||||
Distance hReal = (mH == 0) ? 2*mR1 : mH;
|
||||
|
||||
//
|
||||
// Create path
|
||||
//
|
||||
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;
|
||||
|
||||
//
|
||||
// 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)
|
||||
*/
|
||||
@@ -51,168 +204,18 @@ namespace glabels::model
|
||||
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() );
|
||||
clipPath.addRect( size.pt(), size.pt(), (wReal-2*size).pt(), (hReal-2*size).pt() );
|
||||
|
||||
mPath.addPath( outerPath & clipPath );
|
||||
mPath.closeSubpath();
|
||||
path.addPath( outerPath & clipPath );
|
||||
path.closeSubpath();
|
||||
|
||||
/*
|
||||
* 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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class FrameCd : public Frame
|
||||
namespace model
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FrameCd)
|
||||
|
||||
public:
|
||||
FrameCd( const Distance& r1,
|
||||
const Distance& r2,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& waste,
|
||||
const QString& id = "0" );
|
||||
class FrameCd : public Frame
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FrameCd)
|
||||
|
||||
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;
|
||||
Distance r2() const;
|
||||
Distance waste() const;
|
||||
Frame *dup() const override;
|
||||
|
||||
Distance w() const override;
|
||||
Distance h() const override;
|
||||
Distance r1() const;
|
||||
Distance r2() const;
|
||||
Distance waste() const;
|
||||
|
||||
QString sizeDescription( const Units& units ) const override;
|
||||
bool isSimilarTo( Frame* other ) const override;
|
||||
Distance w() const override;
|
||||
Distance h() const override;
|
||||
|
||||
const QPainterPath& path() const override;
|
||||
const QPainterPath& clipPath() const override;
|
||||
QPainterPath marginPath( const Distance& size ) const override;
|
||||
QString sizeDescription( const Units& units ) const override;
|
||||
bool isSimilarTo( Frame* other ) const override;
|
||||
|
||||
const QPainterPath& path() const override;
|
||||
const QPainterPath& clipPath() const override;
|
||||
QPainterPath marginPath( const Distance& size ) const override;
|
||||
|
||||
|
||||
private:
|
||||
Distance mR1;
|
||||
Distance mR2;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mWaste;
|
||||
private:
|
||||
Distance mR1;
|
||||
Distance mR2;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mWaste;
|
||||
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+86
-82
@@ -24,107 +24,111 @@
|
||||
#include "StrUtil.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
FrameEllipse::FrameEllipse( const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& waste,
|
||||
const QString& id )
|
||||
: Frame(id), mW(w), mH(h), mWaste(waste)
|
||||
namespace model
|
||||
{
|
||||
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 )
|
||||
: Frame(other), mW(other.mW), mH(other.mH), mWaste(other.mWaste), mPath(other.mPath)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
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 )
|
||||
FrameEllipse::FrameEllipse( const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& waste,
|
||||
const QString& id )
|
||||
: Frame(id), mW(w), mH(h), mWaste(waste)
|
||||
{
|
||||
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()) );
|
||||
mPath.addEllipse( 0, 0, mW.pt(), mH.pt() );
|
||||
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(), (mW+2*mWaste).pt(), (mH+2*mWaste).pt() );
|
||||
}
|
||||
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",
|
||||
mW.inUnits(units),
|
||||
mH.inUnits(units),
|
||||
qPrintable(units.toTrName()) );
|
||||
// empty
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FrameEllipse::isSimilarTo( Frame* other ) const
|
||||
{
|
||||
if ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
|
||||
Frame* FrameEllipse::dup() const
|
||||
{
|
||||
if ( (fabs( mW - otherEllipse->mW ) <= EPSILON) &&
|
||||
(fabs( mH - otherEllipse->mH ) <= EPSILON) )
|
||||
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 )
|
||||
{
|
||||
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
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
bool FrameEllipse::isSimilarTo( Frame* other ) const
|
||||
{
|
||||
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
|
||||
{
|
||||
return mClipPath;
|
||||
}
|
||||
const QPainterPath& FrameEllipse::clipPath() const
|
||||
{
|
||||
return mClipPath;
|
||||
}
|
||||
|
||||
|
||||
QPainterPath FrameEllipse::marginPath( const Distance& size ) const
|
||||
{
|
||||
Distance w = mW - 2*size;
|
||||
Distance h = mH - 2*size;
|
||||
QPainterPath FrameEllipse::marginPath( const Distance& size ) const
|
||||
{
|
||||
Distance w = mW - 2*size;
|
||||
Distance h = mH - 2*size;
|
||||
|
||||
QPainterPath path;
|
||||
path.addEllipse( size.pt(), size.pt(), w.pt(), h.pt() );
|
||||
QPainterPath path;
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class FrameEllipse : public Frame
|
||||
namespace model
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FrameEllipse)
|
||||
|
||||
class FrameEllipse : public Frame
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FrameEllipse)
|
||||
|
||||
public:
|
||||
FrameEllipse( const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& waste,
|
||||
const QString& id = "0" );
|
||||
public:
|
||||
FrameEllipse( const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& waste,
|
||||
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 h() const override;
|
||||
Distance w() const override;
|
||||
Distance h() const override;
|
||||
|
||||
QString sizeDescription( const Units& units ) const override;
|
||||
bool isSimilarTo( Frame* other ) const override;
|
||||
QString sizeDescription( const Units& units ) const override;
|
||||
bool isSimilarTo( Frame* other ) const override;
|
||||
|
||||
const QPainterPath& path() 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:
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mWaste;
|
||||
private:
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mWaste;
|
||||
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+116
-113
@@ -24,129 +24,132 @@
|
||||
#include "StrUtil.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
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)
|
||||
namespace model
|
||||
{
|
||||
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 FrameRect &other )
|
||||
: Frame(other),
|
||||
mW(other.mW), mH(other.mH), mR(other.mR), mXWaste(other.mXWaste),
|
||||
mYWaste(other.mYWaste), mPath(other.mPath)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
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 )
|
||||
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)
|
||||
{
|
||||
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()) );
|
||||
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() );
|
||||
}
|
||||
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",
|
||||
mW.inUnits(units),
|
||||
mH.inUnits(units),
|
||||
qPrintable(units.toTrName()) );
|
||||
// empty
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FrameRect::isSimilarTo( Frame* other ) const
|
||||
{
|
||||
if ( FrameRect *otherRect = dynamic_cast<FrameRect*>(other) )
|
||||
|
||||
Frame* FrameRect::dup() const
|
||||
{
|
||||
if ( (fabs( mW - otherRect->mW ) <= EPSILON) &&
|
||||
(fabs( mH - otherRect->mH ) <= EPSILON) )
|
||||
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 )
|
||||
{
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class FrameRect : public Frame
|
||||
namespace model
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FrameRect)
|
||||
|
||||
public:
|
||||
FrameRect( const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& r,
|
||||
const Distance& xWaste,
|
||||
const Distance& yWaste,
|
||||
const QString& id = "0" );
|
||||
class FrameRect : public Frame
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FrameRect)
|
||||
|
||||
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;
|
||||
Distance xWaste() const;
|
||||
Distance yWaste() const;
|
||||
Frame* dup() const override;
|
||||
|
||||
Distance w() const override;
|
||||
Distance h() const override;
|
||||
Distance r() const;
|
||||
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;
|
||||
const QPainterPath& clipPath() const override;
|
||||
QPainterPath marginPath( const Distance& size ) const override;
|
||||
bool isSimilarTo( Frame* other ) const override;
|
||||
|
||||
const QPainterPath& path() const override;
|
||||
const QPainterPath& clipPath() const override;
|
||||
QPainterPath marginPath( const Distance& size ) const override;
|
||||
|
||||
|
||||
private:
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mR;
|
||||
Distance mXWaste;
|
||||
Distance mYWaste;
|
||||
private:
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mR;
|
||||
Distance mXWaste;
|
||||
Distance mYWaste;
|
||||
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+98
-95
@@ -24,111 +24,114 @@
|
||||
#include "StrUtil.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
FrameRound::FrameRound( const Distance& r,
|
||||
const Distance& waste,
|
||||
const QString& id )
|
||||
: Frame(id), mR(r), mWaste(waste)
|
||||
namespace model
|
||||
{
|
||||
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 )
|
||||
: Frame(other), mR(other.mR), mWaste(other.mWaste), mPath(other.mPath)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
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 )
|
||||
FrameRound::FrameRound( const Distance& r,
|
||||
const Distance& waste,
|
||||
const QString& id )
|
||||
: Frame(id), mR(r), mWaste(waste)
|
||||
{
|
||||
QString dStr = StrUtil::formatFraction( 2 * mR.in() );
|
||||
|
||||
return QString().sprintf( "%s %s %s",
|
||||
qPrintable(dStr),
|
||||
qPrintable(units.toTrName()),
|
||||
qPrintable(tr("diameter")) );
|
||||
mPath.addEllipse( 0, 0, 2*mR.pt(), 2*mR.pt() );
|
||||
mClipPath.addEllipse( -mWaste.pt(), -mWaste.pt(),
|
||||
2*(mR+mWaste).pt(), 2*(mR+mWaste).pt() );
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
FrameRound::FrameRound( const FrameRound& other )
|
||||
: Frame(other), mR(other.mR), mWaste(other.mWaste), mPath(other.mPath)
|
||||
{
|
||||
return QString().sprintf( "%.5g %s %s",
|
||||
2 * mR.inUnits(units),
|
||||
qPrintable(units.toTrName()),
|
||||
qPrintable(tr("diameter")) );
|
||||
// empty
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FrameRound::isSimilarTo( Frame* other ) const
|
||||
{
|
||||
if ( FrameRound *otherRound = dynamic_cast<FrameRound*>(other) )
|
||||
Frame* FrameRound::dup() const
|
||||
{
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class FrameRound : public Frame
|
||||
namespace model
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FrameRound)
|
||||
|
||||
public:
|
||||
FrameRound( const Distance& r,
|
||||
const Distance& waste,
|
||||
const QString& id = "0" );
|
||||
class FrameRound : public Frame
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FrameRound)
|
||||
|
||||
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;
|
||||
Distance waste() const;
|
||||
Frame *dup() const override;
|
||||
|
||||
Distance w() const override;
|
||||
Distance h() const override;
|
||||
Distance r() const;
|
||||
Distance waste() const;
|
||||
|
||||
QString sizeDescription( const Units& units ) const override;
|
||||
bool isSimilarTo( Frame* other ) const override;
|
||||
Distance w() const override;
|
||||
Distance h() const override;
|
||||
|
||||
const QPainterPath& path() const override;
|
||||
const QPainterPath& clipPath() const override;
|
||||
QPainterPath marginPath( const Distance& size ) const override;
|
||||
QString sizeDescription( const Units& units ) const override;
|
||||
bool isSimilarTo( Frame* other ) const override;
|
||||
|
||||
const QPainterPath& path() const override;
|
||||
const QPainterPath& clipPath() const override;
|
||||
QPainterPath marginPath( const Distance& size ) const override;
|
||||
|
||||
|
||||
private:
|
||||
Distance mR;
|
||||
Distance mWaste;
|
||||
private:
|
||||
Distance mR;
|
||||
Distance mWaste;
|
||||
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
QPainterPath mPath;
|
||||
QPainterPath mClipPath;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+538
-535
File diff suppressed because it is too large
Load Diff
+251
-248
@@ -28,308 +28,311 @@
|
||||
#include <QPainterPath>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class ModelObject;
|
||||
|
||||
|
||||
///
|
||||
/// Handle Base Class
|
||||
///
|
||||
class Handle
|
||||
namespace model
|
||||
{
|
||||
////////////////////////////
|
||||
// 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();
|
||||
|
||||
// Forward References
|
||||
class ModelObject;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Duplication
|
||||
////////////////////////////
|
||||
virtual Handle* clone( ModelObject* newOwner ) const = 0;
|
||||
///
|
||||
/// Handle Base Class
|
||||
///
|
||||
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
|
||||
////////////////////////////
|
||||
ModelObject* owner() const;
|
||||
Location location() const;
|
||||
////////////////////////////
|
||||
// Attribue Methods
|
||||
////////////////////////////
|
||||
ModelObject* owner() const;
|
||||
Location location() const;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const = 0;
|
||||
virtual QPainterPath path( double scale ) const = 0;
|
||||
protected:
|
||||
void drawAt( QPainter* painter,
|
||||
double scale,
|
||||
const Distance& x,
|
||||
const Distance& y,
|
||||
QColor color ) const;
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter, double scale ) const = 0;
|
||||
virtual QPainterPath path( double scale ) const = 0;
|
||||
protected:
|
||||
void drawAt( QPainter* painter,
|
||||
double scale,
|
||||
const Distance& x,
|
||||
const Distance& y,
|
||||
QColor color ) const;
|
||||
|
||||
QPainterPath pathAt( double scale,
|
||||
const Distance& x,
|
||||
const Distance& y ) const;
|
||||
QPainterPath pathAt( double scale,
|
||||
const Distance& x,
|
||||
const Distance& y ) const;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Protected Data
|
||||
////////////////////////////
|
||||
protected:
|
||||
ModelObject* mOwner;
|
||||
Location mLocation;
|
||||
////////////////////////////
|
||||
// Protected Data
|
||||
////////////////////////////
|
||||
protected:
|
||||
ModelObject* mOwner;
|
||||
Location mLocation;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Class
|
||||
///
|
||||
class HandleNorth : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorth( ModelObject* owner );
|
||||
~HandleNorth() override;
|
||||
HandleNorth* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleNorth Class
|
||||
///
|
||||
class HandleNorth : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorth( ModelObject* owner );
|
||||
~HandleNorth() override;
|
||||
HandleNorth* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Class
|
||||
///
|
||||
class HandleNorthEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorthEast( ModelObject* owner );
|
||||
~HandleNorthEast() override;
|
||||
HandleNorthEast* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleNorthEast Class
|
||||
///
|
||||
class HandleNorthEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorthEast( ModelObject* owner );
|
||||
~HandleNorthEast() override;
|
||||
HandleNorthEast* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Class
|
||||
///
|
||||
class HandleEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleEast( ModelObject* owner );
|
||||
~HandleEast() override;
|
||||
HandleEast* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleEast Class
|
||||
///
|
||||
class HandleEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleEast( ModelObject* owner );
|
||||
~HandleEast() override;
|
||||
HandleEast* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Class
|
||||
///
|
||||
class HandleSouthEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouthEast( ModelObject* owner );
|
||||
~HandleSouthEast() override;
|
||||
HandleSouthEast* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleSouthEast Class
|
||||
///
|
||||
class HandleSouthEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouthEast( ModelObject* owner );
|
||||
~HandleSouthEast() override;
|
||||
HandleSouthEast* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Class
|
||||
///
|
||||
class HandleSouth : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouth( ModelObject* owner );
|
||||
~HandleSouth() override;
|
||||
HandleSouth* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleSouth Class
|
||||
///
|
||||
class HandleSouth : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouth( ModelObject* owner );
|
||||
~HandleSouth() override;
|
||||
HandleSouth* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Class
|
||||
///
|
||||
class HandleSouthWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouthWest( ModelObject* owner );
|
||||
~HandleSouthWest() override;
|
||||
HandleSouthWest* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleSouthWest Class
|
||||
///
|
||||
class HandleSouthWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouthWest( ModelObject* owner );
|
||||
~HandleSouthWest() override;
|
||||
HandleSouthWest* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Class
|
||||
///
|
||||
class HandleWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleWest( ModelObject* owner );
|
||||
~HandleWest() override;
|
||||
HandleWest* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleWest Class
|
||||
///
|
||||
class HandleWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleWest( ModelObject* owner );
|
||||
~HandleWest() override;
|
||||
HandleWest* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Class
|
||||
///
|
||||
class HandleNorthWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorthWest( ModelObject* owner );
|
||||
~HandleNorthWest() override;
|
||||
HandleNorthWest* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleNorthWest Class
|
||||
///
|
||||
class HandleNorthWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorthWest( ModelObject* owner );
|
||||
~HandleNorthWest() override;
|
||||
HandleNorthWest* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Class
|
||||
///
|
||||
class HandleP1 : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleP1( ModelObject* owner );
|
||||
~HandleP1() override;
|
||||
HandleP1* clone( ModelObject* newOwner ) const override;
|
||||
///
|
||||
/// HandleP1 Class
|
||||
///
|
||||
class HandleP1 : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleP1( ModelObject* owner );
|
||||
~HandleP1() override;
|
||||
HandleP1* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Class
|
||||
///
|
||||
class HandleP2 : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleP2( ModelObject* owner );
|
||||
~HandleP2() override;
|
||||
///
|
||||
/// HandleP2 Class
|
||||
///
|
||||
class HandleP2 : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleP2( ModelObject* owner );
|
||||
~HandleP2() override;
|
||||
|
||||
////////////////////////////
|
||||
// Duplication
|
||||
////////////////////////////
|
||||
HandleP2* clone( ModelObject* newOwner ) const override;
|
||||
////////////////////////////
|
||||
// Duplication
|
||||
////////////////////////////
|
||||
HandleP2* clone( ModelObject* newOwner ) const override;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, double scale ) const override;
|
||||
QPainterPath path( double scale ) const override;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+63
-60
@@ -25,80 +25,83 @@
|
||||
#include <cmath>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
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)
|
||||
namespace model
|
||||
{
|
||||
// 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 )
|
||||
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0),
|
||||
mDx(other.mDx), mDy(other.mDy)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
Layout::Layout( const Layout& other )
|
||||
: mNx(other.mNx), mNy(other.mNy), mX0(other.mX0), mY0(other.mY0),
|
||||
mDx(other.mDx), mDy(other.mDy)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
int Layout::nx() const
|
||||
{
|
||||
return mNx;
|
||||
}
|
||||
int Layout::nx() const
|
||||
{
|
||||
return mNx;
|
||||
}
|
||||
|
||||
|
||||
int Layout::ny() const
|
||||
{
|
||||
return mNy;
|
||||
}
|
||||
int Layout::ny() const
|
||||
{
|
||||
return mNy;
|
||||
}
|
||||
|
||||
|
||||
Distance Layout::x0() const
|
||||
{
|
||||
return mX0;
|
||||
}
|
||||
Distance Layout::x0() const
|
||||
{
|
||||
return mX0;
|
||||
}
|
||||
|
||||
|
||||
Distance Layout::y0() const
|
||||
{
|
||||
return mY0;
|
||||
}
|
||||
Distance Layout::y0() const
|
||||
{
|
||||
return mY0;
|
||||
}
|
||||
|
||||
|
||||
Distance Layout::dx() const
|
||||
{
|
||||
return mDx;
|
||||
}
|
||||
Distance Layout::dx() const
|
||||
{
|
||||
return mDx;
|
||||
}
|
||||
|
||||
|
||||
Distance Layout::dy() const
|
||||
{
|
||||
return mDy;
|
||||
Distance Layout::dy() const
|
||||
{
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class Layout
|
||||
namespace model
|
||||
{
|
||||
|
||||
class Layout
|
||||
{
|
||||
|
||||
public:
|
||||
Layout( int nx,
|
||||
int ny,
|
||||
const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& dx,
|
||||
const Distance& dy );
|
||||
public:
|
||||
Layout( int nx,
|
||||
int ny,
|
||||
const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& dx,
|
||||
const Distance& dy );
|
||||
|
||||
Layout( const Layout &other );
|
||||
Layout( const Layout &other );
|
||||
|
||||
int nx() const;
|
||||
int ny() const;
|
||||
int nx() const;
|
||||
int ny() const;
|
||||
|
||||
Distance x0() const;
|
||||
Distance y0() const;
|
||||
Distance x0() const;
|
||||
Distance y0() const;
|
||||
|
||||
Distance dx() const;
|
||||
Distance dy() const;
|
||||
Distance dx() const;
|
||||
Distance dy() const;
|
||||
|
||||
bool isSimilarTo( const Layout *other );
|
||||
bool isSimilarTo( const Layout *other );
|
||||
|
||||
Layout* dup() const;
|
||||
Layout* dup() const;
|
||||
|
||||
|
||||
private:
|
||||
int mNx;
|
||||
int mNy;
|
||||
Distance mX0;
|
||||
Distance mY0;
|
||||
Distance mDx;
|
||||
Distance mDy;
|
||||
private:
|
||||
int mNx;
|
||||
int mNy;
|
||||
Distance mX0;
|
||||
Distance mY0;
|
||||
Distance mDx;
|
||||
Distance mDy;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+136
-133
@@ -21,192 +21,195 @@
|
||||
#include "Markup.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
const QPainterPath& Markup::path() const
|
||||
namespace model
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
const QPainterPath& Markup::path() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
|
||||
MarkupMargin::MarkupMargin( const Frame* frame,
|
||||
const Distance& size )
|
||||
: mFrame(frame), mSize(size)
|
||||
{
|
||||
mPath = frame->marginPath( size );
|
||||
}
|
||||
MarkupMargin::MarkupMargin( const Frame* frame,
|
||||
const Distance& size )
|
||||
: mFrame(frame), mSize(size)
|
||||
{
|
||||
mPath = frame->marginPath( size );
|
||||
}
|
||||
|
||||
|
||||
Markup* MarkupMargin::dup() const
|
||||
{
|
||||
return new MarkupMargin( mFrame, mSize );
|
||||
}
|
||||
Markup* MarkupMargin::dup() const
|
||||
{
|
||||
return new MarkupMargin( mFrame, mSize );
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupMargin::size() const
|
||||
{
|
||||
return mSize;
|
||||
}
|
||||
Distance MarkupMargin::size() const
|
||||
{
|
||||
return mSize;
|
||||
}
|
||||
|
||||
|
||||
MarkupLine::MarkupLine( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& x2,
|
||||
const Distance& y2 )
|
||||
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
||||
{
|
||||
mPath.moveTo( x1.pt(), y1.pt() );
|
||||
mPath.lineTo( x2.pt(), y2.pt() );
|
||||
}
|
||||
MarkupLine::MarkupLine( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& x2,
|
||||
const Distance& y2 )
|
||||
: mX1(x1), mY1(y1), mX2(x2), mY2(y2)
|
||||
{
|
||||
mPath.moveTo( x1.pt(), y1.pt() );
|
||||
mPath.lineTo( x2.pt(), y2.pt() );
|
||||
}
|
||||
|
||||
|
||||
Markup* MarkupLine::dup() const
|
||||
{
|
||||
return new MarkupLine( mX1, mY1, mX2, mY2 );
|
||||
}
|
||||
Markup* MarkupLine::dup() const
|
||||
{
|
||||
return new MarkupLine( mX1, mY1, mX2, mY2 );
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupLine::x1() const
|
||||
{
|
||||
return mX1;
|
||||
}
|
||||
Distance MarkupLine::x1() const
|
||||
{
|
||||
return mX1;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupLine::y1() const
|
||||
{
|
||||
return mY1;
|
||||
}
|
||||
Distance MarkupLine::y1() const
|
||||
{
|
||||
return mY1;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupLine::x2() const
|
||||
{
|
||||
return mX2;
|
||||
}
|
||||
Distance MarkupLine::x2() const
|
||||
{
|
||||
return mX2;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupLine::y2() const
|
||||
{
|
||||
return mY2;
|
||||
}
|
||||
Distance MarkupLine::y2() const
|
||||
{
|
||||
return mY2;
|
||||
}
|
||||
|
||||
|
||||
MarkupRect::MarkupRect( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& 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() );
|
||||
}
|
||||
MarkupRect::MarkupRect( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& 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() );
|
||||
}
|
||||
|
||||
|
||||
Markup* MarkupRect::dup() const
|
||||
{
|
||||
return new MarkupRect( mX1, mY1, mW, mH, mR );
|
||||
}
|
||||
Markup* MarkupRect::dup() const
|
||||
{
|
||||
return new MarkupRect( mX1, mY1, mW, mH, mR );
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupRect::x1() const
|
||||
{
|
||||
return mX1;
|
||||
}
|
||||
Distance MarkupRect::x1() const
|
||||
{
|
||||
return mX1;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupRect::y1() const
|
||||
{
|
||||
return mY1;
|
||||
}
|
||||
Distance MarkupRect::y1() const
|
||||
{
|
||||
return mY1;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupRect::w() const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
Distance MarkupRect::w() const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupRect::h() const
|
||||
{
|
||||
return mH;
|
||||
}
|
||||
Distance MarkupRect::h() const
|
||||
{
|
||||
return mH;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupRect::r() const
|
||||
{
|
||||
return mR;
|
||||
}
|
||||
Distance MarkupRect::r() const
|
||||
{
|
||||
return mR;
|
||||
}
|
||||
|
||||
|
||||
MarkupEllipse::MarkupEllipse( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& w,
|
||||
const Distance& h )
|
||||
: mX1(x1), mY1(y1), mW(w), mH(h)
|
||||
{
|
||||
mPath.addEllipse( x1.pt(), y1.pt(), w.pt(), h.pt() );
|
||||
}
|
||||
MarkupEllipse::MarkupEllipse( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& w,
|
||||
const Distance& h )
|
||||
: mX1(x1), mY1(y1), mW(w), mH(h)
|
||||
{
|
||||
mPath.addEllipse( x1.pt(), y1.pt(), w.pt(), h.pt() );
|
||||
}
|
||||
|
||||
|
||||
Markup* MarkupEllipse::dup() const
|
||||
{
|
||||
return new MarkupEllipse( mX1, mY1, mW, mH );
|
||||
}
|
||||
Markup* MarkupEllipse::dup() const
|
||||
{
|
||||
return new MarkupEllipse( mX1, mY1, mW, mH );
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupEllipse::x1() const
|
||||
{
|
||||
return mX1;
|
||||
}
|
||||
Distance MarkupEllipse::x1() const
|
||||
{
|
||||
return mX1;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupEllipse::y1() const
|
||||
{
|
||||
return mY1;
|
||||
}
|
||||
Distance MarkupEllipse::y1() const
|
||||
{
|
||||
return mY1;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupEllipse::w() const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
Distance MarkupEllipse::w() const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupEllipse::h() const
|
||||
{
|
||||
return mH;
|
||||
}
|
||||
Distance MarkupEllipse::h() const
|
||||
{
|
||||
return mH;
|
||||
}
|
||||
|
||||
|
||||
MarkupCircle::MarkupCircle( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& r )
|
||||
: mX0(x0), mY0(y0), mR(r)
|
||||
{
|
||||
mPath.addEllipse( (x0-r).pt(), (y0-r).pt(), 2*r.pt(), 2*r.pt() );
|
||||
}
|
||||
MarkupCircle::MarkupCircle( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& r )
|
||||
: mX0(x0), mY0(y0), mR(r)
|
||||
{
|
||||
mPath.addEllipse( (x0-r).pt(), (y0-r).pt(), 2*r.pt(), 2*r.pt() );
|
||||
}
|
||||
|
||||
Markup* MarkupCircle::dup() const
|
||||
{
|
||||
return new MarkupCircle( mX0, mY0, mR );
|
||||
}
|
||||
Markup* MarkupCircle::dup() const
|
||||
{
|
||||
return new MarkupCircle( mX0, mY0, mR );
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupCircle::x0() const
|
||||
{
|
||||
return mX0;
|
||||
}
|
||||
Distance MarkupCircle::x0() const
|
||||
{
|
||||
return mX0;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupCircle::y0() const
|
||||
{
|
||||
return mY0;
|
||||
}
|
||||
Distance MarkupCircle::y0() const
|
||||
{
|
||||
return mY0;
|
||||
}
|
||||
|
||||
|
||||
Distance MarkupCircle::r() const
|
||||
{
|
||||
return mR;
|
||||
}
|
||||
Distance MarkupCircle::r() const
|
||||
{
|
||||
return mR;
|
||||
}
|
||||
|
||||
} // namespace glabels::model
|
||||
}
|
||||
}
|
||||
|
||||
+95
-92
@@ -27,129 +27,132 @@
|
||||
#include <QPainterPath>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class Markup
|
||||
namespace model
|
||||
{
|
||||
public:
|
||||
virtual Markup* dup() const = 0;
|
||||
|
||||
const QPainterPath& path() const;
|
||||
class Markup
|
||||
{
|
||||
public:
|
||||
virtual Markup* dup() const = 0;
|
||||
|
||||
protected:
|
||||
QPainterPath mPath;
|
||||
};
|
||||
const QPainterPath& path() const;
|
||||
|
||||
protected:
|
||||
QPainterPath mPath;
|
||||
};
|
||||
|
||||
|
||||
class MarkupMargin : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupMargin( const Frame* frame,
|
||||
const Distance& size );
|
||||
class MarkupMargin : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupMargin( const Frame* frame,
|
||||
const Distance& size );
|
||||
|
||||
Distance size() const;
|
||||
Distance size() const;
|
||||
|
||||
Markup* dup() const override;
|
||||
Markup* dup() const override;
|
||||
|
||||
private:
|
||||
const Frame* mFrame;
|
||||
Distance mSize;
|
||||
};
|
||||
private:
|
||||
const Frame* mFrame;
|
||||
Distance mSize;
|
||||
};
|
||||
|
||||
|
||||
class MarkupLine : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupLine( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& x2,
|
||||
const Distance& y2 );
|
||||
class MarkupLine : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupLine( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& x2,
|
||||
const Distance& y2 );
|
||||
|
||||
Distance x1() const;
|
||||
Distance y1() const;
|
||||
Distance x2() const;
|
||||
Distance y2() const;
|
||||
Distance x1() const;
|
||||
Distance y1() const;
|
||||
Distance x2() const;
|
||||
Distance y2() const;
|
||||
|
||||
Markup* dup() const override;
|
||||
Markup* dup() const override;
|
||||
|
||||
private:
|
||||
Distance mX1;
|
||||
Distance mY1;
|
||||
Distance mX2;
|
||||
Distance mY2;
|
||||
};
|
||||
private:
|
||||
Distance mX1;
|
||||
Distance mY1;
|
||||
Distance mX2;
|
||||
Distance mY2;
|
||||
};
|
||||
|
||||
|
||||
class MarkupRect : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupRect( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& r );
|
||||
class MarkupRect : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupRect( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const Distance& r );
|
||||
|
||||
Distance x1() const;
|
||||
Distance y1() const;
|
||||
Distance w() const;
|
||||
Distance h() const;
|
||||
Distance r() const;
|
||||
Distance x1() const;
|
||||
Distance y1() const;
|
||||
Distance w() const;
|
||||
Distance h() const;
|
||||
Distance r() const;
|
||||
|
||||
Markup* dup() const override;
|
||||
Markup* dup() const override;
|
||||
|
||||
private:
|
||||
Distance mX1;
|
||||
Distance mY1;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mR;
|
||||
};
|
||||
private:
|
||||
Distance mX1;
|
||||
Distance mY1;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mR;
|
||||
};
|
||||
|
||||
|
||||
class MarkupEllipse : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupEllipse( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& w,
|
||||
const Distance& h );
|
||||
class MarkupEllipse : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupEllipse( const Distance& x1,
|
||||
const Distance& y1,
|
||||
const Distance& w,
|
||||
const Distance& h );
|
||||
|
||||
Distance x1() const;
|
||||
Distance y1() const;
|
||||
Distance w() const;
|
||||
Distance h() const;
|
||||
Distance x1() const;
|
||||
Distance y1() const;
|
||||
Distance w() const;
|
||||
Distance h() const;
|
||||
|
||||
Markup* dup() const override;
|
||||
Markup* dup() const override;
|
||||
|
||||
private:
|
||||
Distance mX1;
|
||||
Distance mY1;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
};
|
||||
private:
|
||||
Distance mX1;
|
||||
Distance mY1;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
};
|
||||
|
||||
|
||||
class MarkupCircle : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupCircle( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& r );
|
||||
class MarkupCircle : public Markup
|
||||
{
|
||||
public:
|
||||
MarkupCircle( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& r );
|
||||
|
||||
Distance x0() const;
|
||||
Distance y0() const;
|
||||
Distance r() const;
|
||||
Distance x0() const;
|
||||
Distance y0() const;
|
||||
Distance r() const;
|
||||
|
||||
Markup* dup() const override;
|
||||
Markup* dup() const override;
|
||||
|
||||
private:
|
||||
Distance mX0;
|
||||
Distance mY0;
|
||||
Distance mR;
|
||||
};
|
||||
private:
|
||||
Distance mX0;
|
||||
Distance mY0;
|
||||
Distance mR;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1266
-1263
File diff suppressed because it is too large
Load Diff
+164
-161
@@ -33,206 +33,209 @@
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class ColorNode;
|
||||
class Handle;
|
||||
class ModelObject;
|
||||
class Region;
|
||||
|
||||
///
|
||||
/// Model
|
||||
///
|
||||
class Model : public QObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
// Forward References
|
||||
class ColorNode;
|
||||
class Handle;
|
||||
class ModelObject;
|
||||
class Region;
|
||||
|
||||
///
|
||||
/// Model
|
||||
///
|
||||
class Model : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Lifecycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Model();
|
||||
~Model() override {}
|
||||
/////////////////////////////////
|
||||
// Lifecycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Model();
|
||||
~Model() override {}
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Save/restore model state
|
||||
/////////////////////////////////
|
||||
Model* save() const;
|
||||
void restore( const Model *savedModel );
|
||||
/////////////////////////////////
|
||||
// Save/restore model state
|
||||
/////////////////////////////////
|
||||
Model* save() const;
|
||||
void restore( const Model *savedModel );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void changed();
|
||||
void nameChanged();
|
||||
void sizeChanged();
|
||||
void selectionChanged();
|
||||
void modifiedChanged();
|
||||
void mergeChanged();
|
||||
void mergeSourceChanged();
|
||||
void mergeSelectionChanged();
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void changed();
|
||||
void nameChanged();
|
||||
void sizeChanged();
|
||||
void selectionChanged();
|
||||
void modifiedChanged();
|
||||
void mergeChanged();
|
||||
void mergeSourceChanged();
|
||||
void mergeSelectionChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool isModified() const;
|
||||
void setModified();
|
||||
void clearModified();
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool isModified() const;
|
||||
void setModified();
|
||||
void clearModified();
|
||||
|
||||
QString shortName();
|
||||
const QString& fileName() const;
|
||||
void setFileName( const QString &fileName );
|
||||
QString shortName();
|
||||
const QString& fileName() const;
|
||||
void setFileName( const QString &fileName );
|
||||
|
||||
int compressionLevel() const;
|
||||
void setCompressionLevel( int compressionLevel );
|
||||
int compressionLevel() const;
|
||||
void setCompressionLevel( int compressionLevel );
|
||||
|
||||
const Template* tmplate() const;
|
||||
const Frame* frame() const;
|
||||
void setTmplate( const Template* tmplate );
|
||||
const Template* tmplate() const;
|
||||
const Frame* frame() const;
|
||||
void setTmplate( const Template* tmplate );
|
||||
|
||||
bool rotate() const;
|
||||
void setRotate( bool rotate );
|
||||
bool rotate() const;
|
||||
void setRotate( bool rotate );
|
||||
|
||||
Distance w() const;
|
||||
Distance h() const;
|
||||
Distance w() const;
|
||||
Distance h() const;
|
||||
|
||||
const QList<ModelObject*>& objectList() const;
|
||||
const QList<ModelObject*>& objectList() const;
|
||||
|
||||
merge::Merge* merge() const;
|
||||
void setMerge( merge::Merge* merge );
|
||||
merge::Merge* merge() const;
|
||||
void setMerge( merge::Merge* merge );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Manage objects
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void addObject( ModelObject* object );
|
||||
void deleteObject( ModelObject* object );
|
||||
/////////////////////////////////
|
||||
// Manage objects
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void addObject( ModelObject* object );
|
||||
void deleteObject( ModelObject* object );
|
||||
|
||||
ModelObject* objectAt( double scale,
|
||||
const Distance& x,
|
||||
const Distance& y ) const;
|
||||
ModelObject* objectAt( 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;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Manipulate selection
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void selectObject( ModelObject* object );
|
||||
void unselectObject( ModelObject* object );
|
||||
void selectAll();
|
||||
void unselectAll();
|
||||
void selectRegion( const Region& region );
|
||||
bool isSelectionEmpty();
|
||||
bool isSelectionAtomic();
|
||||
/////////////////////////////////
|
||||
// Manipulate selection
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void selectObject( ModelObject* object );
|
||||
void unselectObject( ModelObject* object );
|
||||
void selectAll();
|
||||
void unselectAll();
|
||||
void selectRegion( const Region& region );
|
||||
bool isSelectionEmpty();
|
||||
bool isSelectionAtomic();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Get selected objects
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QList<ModelObject*> getSelection();
|
||||
ModelObject* getFirstSelectedObject();
|
||||
/////////////////////////////////
|
||||
// Get selected objects
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QList<ModelObject*> getSelection();
|
||||
ModelObject* getFirstSelectedObject();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Query selection capabilities
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool canSelectionText();
|
||||
bool canSelectionFill();
|
||||
bool canSelectionLineColor();
|
||||
bool canSelectionLineWidth();
|
||||
/////////////////////////////////
|
||||
// Query selection capabilities
|
||||
/////////////////////////////////
|
||||
public:
|
||||
bool canSelectionText();
|
||||
bool canSelectionFill();
|
||||
bool canSelectionLineColor();
|
||||
bool canSelectionLineWidth();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Operations on selections
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void deleteSelection();
|
||||
void raiseSelectionToTop();
|
||||
void lowerSelectionToBottom();
|
||||
void rotateSelection( double thetaDegs );
|
||||
void rotateSelectionLeft();
|
||||
void rotateSelectionRight();
|
||||
void flipSelectionHoriz();
|
||||
void flipSelectionVert();
|
||||
void alignSelectionLeft();
|
||||
void alignSelectionRight();
|
||||
void alignSelectionHCenter();
|
||||
void alignSelectionTop();
|
||||
void alignSelectionBottom();
|
||||
void alignSelectionVCenter();
|
||||
void centerSelectionHoriz();
|
||||
void centerSelectionVert();
|
||||
void moveSelection( const Distance& dx, const Distance& dy );
|
||||
void setSelectionFontFamily( const QString& fontFamily );
|
||||
void setSelectionFontSize( double fontSize );
|
||||
void setSelectionFontWeight( QFont::Weight fontWeight );
|
||||
void setSelectionFontItalicFlag( bool fontItalicFlag );
|
||||
void setSelectionTextHAlign( Qt::Alignment textHAlign );
|
||||
void setSelectionTextVAlign( Qt::Alignment textVAlign );
|
||||
void setSelectionTextLineSpacing( double textLineSpacing );
|
||||
void setSelectionTextColorNode( ColorNode textColorNode );
|
||||
void setSelectionLineWidth( const Distance& lineWidth );
|
||||
void setSelectionLineColorNode( ColorNode lineColorNode );
|
||||
void setSelectionFillColorNode( ColorNode fillColorNode );
|
||||
/////////////////////////////////
|
||||
// Operations on selections
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void deleteSelection();
|
||||
void raiseSelectionToTop();
|
||||
void lowerSelectionToBottom();
|
||||
void rotateSelection( double thetaDegs );
|
||||
void rotateSelectionLeft();
|
||||
void rotateSelectionRight();
|
||||
void flipSelectionHoriz();
|
||||
void flipSelectionVert();
|
||||
void alignSelectionLeft();
|
||||
void alignSelectionRight();
|
||||
void alignSelectionHCenter();
|
||||
void alignSelectionTop();
|
||||
void alignSelectionBottom();
|
||||
void alignSelectionVCenter();
|
||||
void centerSelectionHoriz();
|
||||
void centerSelectionVert();
|
||||
void moveSelection( const Distance& dx, const Distance& dy );
|
||||
void setSelectionFontFamily( const QString& fontFamily );
|
||||
void setSelectionFontSize( double fontSize );
|
||||
void setSelectionFontWeight( QFont::Weight fontWeight );
|
||||
void setSelectionFontItalicFlag( bool fontItalicFlag );
|
||||
void setSelectionTextHAlign( Qt::Alignment textHAlign );
|
||||
void setSelectionTextVAlign( Qt::Alignment textVAlign );
|
||||
void setSelectionTextLineSpacing( double textLineSpacing );
|
||||
void setSelectionTextColorNode( ColorNode textColorNode );
|
||||
void setSelectionLineWidth( const Distance& lineWidth );
|
||||
void setSelectionLineColorNode( ColorNode lineColorNode );
|
||||
void setSelectionFillColorNode( ColorNode fillColorNode );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Clipboard operations
|
||||
/////////////////////////////////
|
||||
void copySelection();
|
||||
void cutSelection();
|
||||
bool canPaste();
|
||||
void paste();
|
||||
/////////////////////////////////
|
||||
// Clipboard operations
|
||||
/////////////////////////////////
|
||||
void copySelection();
|
||||
void cutSelection();
|
||||
bool canPaste();
|
||||
void paste();
|
||||
|
||||
/////////////////////////////////
|
||||
// Drawing operations
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, bool inEditor = true, merge::Record* record = nullptr ) const;
|
||||
/////////////////////////////////
|
||||
// Drawing operations
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, bool inEditor = true, merge::Record* record = nullptr ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
void onObjectChanged();
|
||||
void onObjectMoved();
|
||||
void onMergeSourceChanged();
|
||||
void onMergeSelectionChanged();
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
void onObjectChanged();
|
||||
void onObjectMoved();
|
||||
void onMergeSourceChanged();
|
||||
void onMergeSelectionChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
int mUntitledInstance;
|
||||
bool mModified;
|
||||
QString mFileName;
|
||||
int mCompressionLevel;
|
||||
const Template* mTmplate;
|
||||
const Frame* mFrame;
|
||||
bool mRotate;
|
||||
/////////////////////////////////
|
||||
// Private data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
int mUntitledInstance;
|
||||
bool mModified;
|
||||
QString mFileName;
|
||||
int mCompressionLevel;
|
||||
const Template* mTmplate;
|
||||
const Frame* mFrame;
|
||||
bool mRotate;
|
||||
|
||||
QList<ModelObject*> mObjectList;
|
||||
QList<ModelObject*> mObjectList;
|
||||
|
||||
merge::Merge* mMerge;
|
||||
};
|
||||
merge::Merge* mMerge;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+445
-442
@@ -35,497 +35,500 @@
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
namespace model
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
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
|
||||
///
|
||||
ModelBarcodeObject::ModelBarcodeObject()
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelBarcodeObject::ModelBarcodeObject()
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
|
||||
mBcStyle = barcode::Backends::defaultStyle();
|
||||
mBcTextFlag = mBcStyle.canText();
|
||||
mBcChecksumFlag = mBcStyle.canChecksum();
|
||||
mBcFormatDigits = mBcStyle.preferedN();
|
||||
mBcData = "";
|
||||
mBcColorNode = ColorNode( Qt::black );
|
||||
mBcStyle = barcode::Backends::defaultStyle();
|
||||
mBcTextFlag = mBcStyle.canText();
|
||||
mBcChecksumFlag = mBcStyle.canChecksum();
|
||||
mBcFormatDigits = mBcStyle.preferedN();
|
||||
mBcData = "";
|
||||
mBcColorNode = ColorNode( Qt::black );
|
||||
|
||||
mEditorBarcode = nullptr;
|
||||
mEditorDefaultBarcode = nullptr;
|
||||
mEditorBarcode = nullptr;
|
||||
mEditorDefaultBarcode = nullptr;
|
||||
|
||||
update(); // Initialize cached editor layouts
|
||||
}
|
||||
update(); // Initialize cached editor layouts
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelBarcodeObject::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 )
|
||||
: ModelObject( x0, y0, w, h, matrix )
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelBarcodeObject::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 )
|
||||
: ModelObject( x0, y0, w, h, matrix )
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
|
||||
mBcStyle = bcStyle;
|
||||
mBcTextFlag = bcTextFlag;
|
||||
mBcChecksumFlag = bcChecksumFlag;
|
||||
mBcData = bcData;
|
||||
mBcColorNode = bcColorNode;
|
||||
mBcStyle = bcStyle;
|
||||
mBcTextFlag = bcTextFlag;
|
||||
mBcChecksumFlag = bcChecksumFlag;
|
||||
mBcData = bcData;
|
||||
mBcColorNode = bcColorNode;
|
||||
|
||||
mEditorBarcode = nullptr;
|
||||
mEditorDefaultBarcode = nullptr;
|
||||
mEditorBarcode = nullptr;
|
||||
mEditorDefaultBarcode = nullptr;
|
||||
|
||||
update(); // Initialize cached editor layouts
|
||||
}
|
||||
update(); // Initialize cached editor layouts
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
ModelBarcodeObject::ModelBarcodeObject( const ModelBarcodeObject* 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 )
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
ModelBarcodeObject::ModelBarcodeObject( const ModelBarcodeObject* object )
|
||||
: ModelObject(object)
|
||||
{
|
||||
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
|
||||
///
|
||||
ModelBarcodeObject* ModelBarcodeObject::clone() const
|
||||
{
|
||||
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 )
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
ModelBarcodeObject::~ModelBarcodeObject()
|
||||
{
|
||||
mBcData = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
delete mOutline;
|
||||
|
||||
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;
|
||||
}
|
||||
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 )
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
ModelBarcodeObject* ModelBarcodeObject::clone() const
|
||||
{
|
||||
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() );
|
||||
return new ModelBarcodeObject( this );
|
||||
}
|
||||
|
||||
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() )
|
||||
///
|
||||
/// bcData Property Getter
|
||||
///
|
||||
QString ModelBarcodeObject::bcData() const
|
||||
{
|
||||
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 ) );
|
||||
glbarcode::QtRenderer renderer(painter);
|
||||
mEditorBarcode->render( renderer );
|
||||
return mBcTextFlag;
|
||||
}
|
||||
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
|
||||
///
|
||||
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 );
|
||||
}
|
||||
///
|
||||
/// bcChecksumFlag Property Getter
|
||||
///
|
||||
bool ModelBarcodeObject::bcChecksumFlag() const
|
||||
{
|
||||
return mBcChecksumFlag;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
/// 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();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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()) )
|
||||
///
|
||||
/// Barcode Style Property Getter
|
||||
///
|
||||
barcode::Style ModelBarcodeObject::bcStyle() const
|
||||
{
|
||||
double scaleX = wPts / textRect.width();
|
||||
double scaleY = hPts / textRect.height();
|
||||
font.setPointSizeF( 6 * std::min( scaleX, scaleY ) );
|
||||
return mBcStyle;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 );
|
||||
///
|
||||
/// Barcode Style Property Setter
|
||||
///
|
||||
void ModelBarcodeObject::setBcStyle( const barcode::Style& value )
|
||||
{
|
||||
if ( mBcStyle != value )
|
||||
{
|
||||
mBcStyle = value;
|
||||
update();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Render text
|
||||
//
|
||||
painter->setFont( font );
|
||||
painter->setPen( QPen( color ) );
|
||||
painter->drawText( QRectF( 0, 0, mW.pt(), mH.pt() ), Qt::AlignCenter, shortText );
|
||||
}
|
||||
|
||||
///
|
||||
/// 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.
|
||||
}
|
||||
|
||||
|
||||
} // 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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class ModelBarcodeObject : public ModelObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelBarcodeObject();
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class ModelBarcodeObject : public ModelObject
|
||||
{
|
||||
Q_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() );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelBarcodeObject();
|
||||
|
||||
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
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelBarcodeObject* clone() const override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Object duplication
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelBarcodeObject* clone() const override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Barcode Property: bcData
|
||||
//
|
||||
QString bcData() const override;
|
||||
void setBcData( const QString &value ) override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Barcode Property: bcData
|
||||
//
|
||||
QString bcData() const override;
|
||||
void setBcData( const QString &value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Barcode Property: bcTextFlag
|
||||
//
|
||||
bool bcTextFlag() const override;
|
||||
void setBcTextFlag( bool value ) override;
|
||||
//
|
||||
// Barcode Property: bcTextFlag
|
||||
//
|
||||
bool bcTextFlag() const override;
|
||||
void setBcTextFlag( bool value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Barcode Property: bcChecksumFlag
|
||||
//
|
||||
bool bcChecksumFlag() const override;
|
||||
void setBcChecksumFlag( bool value ) override;
|
||||
//
|
||||
// Barcode Property: bcChecksumFlag
|
||||
//
|
||||
bool bcChecksumFlag() const override;
|
||||
void setBcChecksumFlag( bool value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Barcode Property: bcColorNode
|
||||
//
|
||||
ColorNode bcColorNode() const override;
|
||||
void setBcColorNode( const ColorNode &value ) override;
|
||||
//
|
||||
// Barcode Property: bcColorNode
|
||||
//
|
||||
ColorNode bcColorNode() const override;
|
||||
void setBcColorNode( const ColorNode &value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Barcode Property: bcStyle
|
||||
//
|
||||
barcode::Style bcStyle() const override;
|
||||
void setBcStyle( const barcode::Style &value ) override;
|
||||
//
|
||||
// Barcode Property: bcStyle
|
||||
//
|
||||
barcode::Style bcStyle() const override;
|
||||
void setBcStyle( const barcode::Style &value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Barcode Property: bcFormatDigits
|
||||
//
|
||||
int bcFormatDigits() const override;
|
||||
void setBcFormatDigits( int value ) override;
|
||||
//
|
||||
// Barcode Property: bcFormatDigits
|
||||
//
|
||||
int bcFormatDigits() const override;
|
||||
void setBcFormatDigits( int value ) override;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
void sizeUpdated() override;
|
||||
void update();
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
void sizeUpdated() override;
|
||||
void update();
|
||||
|
||||
void drawBcInEditor( QPainter* painter, const QColor& color ) const;
|
||||
void drawBc( QPainter* painter, const QColor& color, merge::Record* record ) const;
|
||||
void drawPlaceHolder( QPainter* painter, const QColor& color, const QString& text ) const;
|
||||
void drawBcInEditor( QPainter* painter, const QColor& color ) const;
|
||||
void drawBc( QPainter* painter, const QColor& color, merge::Record* record ) const;
|
||||
void drawPlaceHolder( QPainter* painter, const QColor& color, const QString& text ) const;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
barcode::Style mBcStyle;
|
||||
bool mBcTextFlag;
|
||||
bool mBcChecksumFlag;
|
||||
int mBcFormatDigits;
|
||||
RawText mBcData;
|
||||
ColorNode mBcColorNode;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
barcode::Style mBcStyle;
|
||||
bool mBcTextFlag;
|
||||
bool mBcChecksumFlag;
|
||||
int mBcFormatDigits;
|
||||
RawText mBcData;
|
||||
ColorNode mBcColorNode;
|
||||
|
||||
glbarcode::Barcode* mEditorBarcode;
|
||||
glbarcode::Barcode* mEditorDefaultBarcode;
|
||||
glbarcode::Barcode* mEditorBarcode;
|
||||
glbarcode::Barcode* mEditorDefaultBarcode;
|
||||
|
||||
QPainterPath mHoverPath;
|
||||
QPainterPath mHoverPath;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+154
-151
@@ -24,171 +24,174 @@
|
||||
#include <QPen>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
namespace model
|
||||
{
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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() )
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( shadowColor );
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
|
||||
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->drawRect( QRectF( -mLineWidth.pt()/2,
|
||||
-mLineWidth.pt()/2,
|
||||
(mW + mLineWidth).pt(),
|
||||
(mH + mLineWidth).pt() ) );
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( shadowColor );
|
||||
|
||||
if ( lineColor.alpha() )
|
||||
{
|
||||
/* Has FILL and OUTLINE: adjust size to account for line width. */
|
||||
painter->drawRect( QRectF( -mLineWidth.pt()/2,
|
||||
-mLineWidth.pt()/2,
|
||||
(mW + mLineWidth).pt(),
|
||||
(mH + mLineWidth).pt() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Has FILL, but no OUTLINE. */
|
||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Has FILL, but no OUTLINE. */
|
||||
painter->drawRect( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( lineColor.alpha() )
|
||||
{
|
||||
/* Has only OUTLINE. */
|
||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||
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
|
||||
///
|
||||
void ModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void ModelBoxObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
|
||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||
painter->setBrush( fillColor );
|
||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Box Object
|
||||
///
|
||||
class ModelBoxObject : public ModelShapeObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelBoxObject();
|
||||
///
|
||||
/// Label Model Box Object
|
||||
///
|
||||
class ModelBoxObject : public ModelShapeObject
|
||||
{
|
||||
Q_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() );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelBoxObject();
|
||||
|
||||
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
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelBoxObject* clone() const override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Object duplication
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelBoxObject* clone() const override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+154
-151
@@ -24,171 +24,174 @@
|
||||
#include <QPen>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
namespace model
|
||||
{
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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() )
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( shadowColor );
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
|
||||
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->drawEllipse( QRectF( -mLineWidth.pt()/2,
|
||||
-mLineWidth.pt()/2,
|
||||
(mW + mLineWidth).pt(),
|
||||
(mH + mLineWidth).pt() ) );
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( shadowColor );
|
||||
|
||||
if ( lineColor.alpha() )
|
||||
{
|
||||
/* 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
|
||||
{
|
||||
/* Has FILL, but no OUTLINE. */
|
||||
painter->drawEllipse( QRectF( 0, 0, mW.pt(), mH.pt() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( lineColor.alpha() )
|
||||
{
|
||||
/* Has only OUTLINE. */
|
||||
painter->setPen( QPen( shadowColor, mLineWidth.pt() ) );
|
||||
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
|
||||
///
|
||||
void ModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
///
|
||||
/// Draw object itself
|
||||
///
|
||||
void ModelEllipseObject::drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const
|
||||
{
|
||||
QColor lineColor = mLineColorNode.color( record );
|
||||
QColor fillColor = mFillColorNode.color( record );
|
||||
|
||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||
painter->setBrush( fillColor );
|
||||
painter->setPen( QPen( lineColor, mLineWidth.pt() ) );
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Ellipse Object
|
||||
///
|
||||
class ModelEllipseObject : public ModelShapeObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelEllipseObject();
|
||||
///
|
||||
/// Label Model Ellipse Object
|
||||
///
|
||||
class ModelEllipseObject : public ModelShapeObject
|
||||
{
|
||||
Q_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() );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelEllipseObject();
|
||||
|
||||
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
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelEllipseObject* clone() const override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Object duplication
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelEllipseObject* clone() const override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+475
-472
File diff suppressed because it is too large
Load Diff
+105
-102
@@ -27,134 +27,137 @@
|
||||
#include <QSvgRenderer>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Image Object
|
||||
///
|
||||
class ModelImageObject : public ModelObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelImageObject();
|
||||
///
|
||||
/// Label Model Image Object
|
||||
///
|
||||
class ModelImageObject : public ModelObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
ModelImageObject( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const TextNode& filenameNode,
|
||||
const QMatrix& matrix = QMatrix(),
|
||||
bool shadowState = false,
|
||||
const Distance& shadowX = 0,
|
||||
const Distance& shadowY = 0,
|
||||
double shadowOpacity = 1.0,
|
||||
const ColorNode& shadowColorNode = ColorNode() );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelImageObject();
|
||||
|
||||
ModelImageObject( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const QString& filename,
|
||||
const QImage& image,
|
||||
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,
|
||||
const Distance& y0,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const TextNode& filenameNode,
|
||||
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,
|
||||
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 Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const QString& filename,
|
||||
const QImage& image,
|
||||
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( 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
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelImageObject* clone() const override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Object duplication
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelImageObject* clone() const override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Image Property: filenameNode
|
||||
//
|
||||
TextNode filenameNode() const override;
|
||||
void setFilenameNode( const TextNode& value ) override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Image Property: filenameNode
|
||||
//
|
||||
TextNode filenameNode() const override;
|
||||
void setFilenameNode( const TextNode& value ) override;
|
||||
|
||||
//
|
||||
// Image Property: image
|
||||
//
|
||||
const QImage* image() const override;
|
||||
void setImage( const QImage& value ) override;
|
||||
void setImage( const QString& name, const QImage& value ) override;
|
||||
//
|
||||
// Image Property: image
|
||||
//
|
||||
const QImage* image() const override;
|
||||
void setImage( const QImage& value ) override;
|
||||
void setImage( const QString& name, const QImage& value ) override;
|
||||
|
||||
//
|
||||
// Image Property: svg
|
||||
//
|
||||
QByteArray svg() const override;
|
||||
void setSvg( const QString& name, const QByteArray& value ) override;
|
||||
//
|
||||
// Image Property: svg
|
||||
//
|
||||
QByteArray svg() const override;
|
||||
void setSvg( const QString& name, const QByteArray& value ) override;
|
||||
|
||||
//
|
||||
// Property: naturalSize
|
||||
//
|
||||
Size naturalSize() const override;
|
||||
//
|
||||
// Property: naturalSize
|
||||
//
|
||||
Size naturalSize() const override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////
|
||||
void loadImage();
|
||||
QImage* createShadowImage( const QColor& color ) const;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////
|
||||
void loadImage();
|
||||
QImage* createShadowImage( const QColor& color ) const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
TextNode mFilenameNode;
|
||||
QImage* mImage;
|
||||
QSvgRenderer* mSvgRenderer;
|
||||
QByteArray mSvg;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
TextNode mFilenameNode;
|
||||
QImage* mImage;
|
||||
QSvgRenderer* mSvgRenderer;
|
||||
QByteArray mSvg;
|
||||
|
||||
static QImage* smDefaultImage;
|
||||
static QImage* smDefaultImage;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+184
-181
@@ -24,220 +24,223 @@
|
||||
#include <QPen>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
namespace model
|
||||
{
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
const double slopPixels = 2;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelLineObject::ModelLineObject()
|
||||
{
|
||||
mOutline = nullptr;
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelLineObject::ModelLineObject()
|
||||
{
|
||||
mOutline = nullptr;
|
||||
|
||||
mHandles << new HandleP1( this );
|
||||
mHandles << new HandleP2( this );
|
||||
mHandles << new HandleP1( this );
|
||||
mHandles << new HandleP2( this );
|
||||
|
||||
mLineWidth = 1.0;
|
||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||
}
|
||||
mLineWidth = 1.0;
|
||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelLineObject::ModelLineObject( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& dx,
|
||||
const Distance& dy,
|
||||
const Distance& lineWidth,
|
||||
const ColorNode& lineColorNode,
|
||||
const QMatrix& matrix,
|
||||
bool shadowState,
|
||||
const Distance& shadowX,
|
||||
const Distance& shadowY,
|
||||
double shadowOpacity,
|
||||
const ColorNode& shadowColorNode )
|
||||
: ModelObject( x0, y0, dx, dy,
|
||||
matrix,
|
||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelLineObject::ModelLineObject( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& dx,
|
||||
const Distance& dy,
|
||||
const Distance& lineWidth,
|
||||
const ColorNode& lineColorNode,
|
||||
const QMatrix& matrix,
|
||||
bool shadowState,
|
||||
const Distance& shadowX,
|
||||
const Distance& shadowY,
|
||||
double shadowOpacity,
|
||||
const ColorNode& shadowColorNode )
|
||||
: ModelObject( x0, y0, dx, dy,
|
||||
matrix,
|
||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
|
||||
mLineWidth = lineWidth;
|
||||
mLineColorNode = lineColorNode;
|
||||
}
|
||||
mLineWidth = lineWidth;
|
||||
mLineColorNode = lineColorNode;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
ModelLineObject::ModelLineObject( const ModelLineObject* object )
|
||||
: ModelObject(object)
|
||||
{
|
||||
mLineWidth = object->mLineWidth;
|
||||
mLineColorNode = object->mLineColorNode;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
ModelLineObject::~ModelLineObject()
|
||||
{
|
||||
foreach( Handle* handle, mHandles )
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
ModelLineObject::ModelLineObject( const ModelLineObject* object )
|
||||
: ModelObject(object)
|
||||
{
|
||||
delete handle;
|
||||
mLineWidth = object->mLineWidth;
|
||||
mLineColorNode = object->mLineColorNode;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
ModelLineObject* ModelLineObject::clone() const
|
||||
{
|
||||
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 )
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
ModelLineObject::~ModelLineObject()
|
||||
{
|
||||
mLineWidth = value;
|
||||
emit changed();
|
||||
foreach( Handle* handle, mHandles )
|
||||
{
|
||||
delete handle;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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 )
|
||||
///
|
||||
/// Clone
|
||||
///
|
||||
ModelLineObject* ModelLineObject::clone() const
|
||||
{
|
||||
mLineColorNode = value;
|
||||
emit changed();
|
||||
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;
|
||||
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
|
||||
///
|
||||
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() )
|
||||
///
|
||||
/// Can Line Color Capability Implementation
|
||||
///
|
||||
bool ModelLineObject::canLineColor()
|
||||
{
|
||||
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() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
QPainterPath ModelLineObject::hoverPath( double scale ) const
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
if ( mLineColorNode.color().alpha() )
|
||||
///
|
||||
/// Path to test for hover condition
|
||||
///
|
||||
QPainterPath ModelLineObject::hoverPath( double scale ) const
|
||||
{
|
||||
//
|
||||
// Build a thin rectangle representing line
|
||||
//
|
||||
double rPts = mLineWidth.pt()/2 + slopPixels / scale;
|
||||
QPainterPath path;
|
||||
|
||||
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
|
||||
if ( mLineColorNode.color().alpha() )
|
||||
{
|
||||
//
|
||||
// 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.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.moveTo( rPts*dx, - rPts*dy );
|
||||
path.lineTo( mW.pt() + rPts*dx, mH.pt() - rPts*dy );
|
||||
path.lineTo( mW.pt() - rPts*dx, mH.pt() + rPts*dy );
|
||||
path.lineTo( - rPts*dx, rPts*dy );
|
||||
|
||||
path.closeSubpath();
|
||||
path.closeSubpath();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
} // namespace glabels::model
|
||||
}
|
||||
|
||||
+67
-64
@@ -25,90 +25,93 @@
|
||||
#include "ModelObject.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class ModelLineObject : public ModelObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelLineObject();
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class ModelLineObject : public ModelObject
|
||||
{
|
||||
Q_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() );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelLineObject();
|
||||
|
||||
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
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelLineObject* clone() const override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Object duplication
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelLineObject* clone() const override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Line Property: lineWidth
|
||||
//
|
||||
Distance lineWidth() const override;
|
||||
void setLineWidth( const Distance& value ) override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Line Property: lineWidth
|
||||
//
|
||||
Distance lineWidth() const override;
|
||||
void setLineWidth( const Distance& value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Line Property: lineColorNode
|
||||
//
|
||||
ColorNode lineColorNode() const override;
|
||||
void setLineColorNode( const ColorNode& value ) override;
|
||||
//
|
||||
// Line Property: lineColorNode
|
||||
//
|
||||
ColorNode lineColorNode() const override;
|
||||
void setLineColorNode( const ColorNode& value ) override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual bool canLineColor();
|
||||
virtual bool canLineWidth();
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual bool canLineColor();
|
||||
virtual bool canLineWidth();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
Distance mLineWidth;
|
||||
ColorNode mLineColorNode;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
Distance mLineWidth;
|
||||
ColorNode mLineColorNode;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1111
-1108
File diff suppressed because it is too large
Load Diff
+302
-299
@@ -37,399 +37,402 @@
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward References
|
||||
class Region;
|
||||
class Size;
|
||||
|
||||
|
||||
///
|
||||
/// Label Model Object Base Class
|
||||
///
|
||||
class ModelObject : public QObject
|
||||
namespace model
|
||||
{
|
||||
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;
|
||||
// Forward References
|
||||
class Region;
|
||||
class Size;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Object duplication
|
||||
///////////////////////////////////////////////////////////////
|
||||
virtual ModelObject* clone() const = 0;
|
||||
///
|
||||
/// Label Model Object Base Class
|
||||
///
|
||||
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:
|
||||
void moved();
|
||||
void changed();
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Signals
|
||||
///////////////////////////////////////////////////////////////
|
||||
signals:
|
||||
void moved();
|
||||
void changed();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Common Properties
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// ID Property.
|
||||
//
|
||||
int id() const;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Common Properties
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// ID Property.
|
||||
//
|
||||
int id() const;
|
||||
|
||||
//
|
||||
// Selected Property.
|
||||
//
|
||||
bool isSelected() const;
|
||||
void select( bool value = true );
|
||||
void unselect();
|
||||
//
|
||||
// Selected Property.
|
||||
//
|
||||
bool isSelected() const;
|
||||
void select( bool value = true );
|
||||
void unselect();
|
||||
|
||||
|
||||
//
|
||||
// x0 Property ( x coordinate of origin )
|
||||
//
|
||||
Distance x0() const;
|
||||
void setX0( const Distance& value );
|
||||
//
|
||||
// x0 Property ( x coordinate of origin )
|
||||
//
|
||||
Distance x0() const;
|
||||
void setX0( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// y0 Property ( y coordinate of origin )
|
||||
//
|
||||
Distance y0() const;
|
||||
void setY0( const Distance& value );
|
||||
//
|
||||
// y0 Property ( y coordinate of origin )
|
||||
//
|
||||
Distance y0() const;
|
||||
void setY0( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// w Property ( width of bounding box )
|
||||
//
|
||||
Distance w() const;
|
||||
void setW( const Distance& value );
|
||||
//
|
||||
// w Property ( width of bounding box )
|
||||
//
|
||||
Distance w() const;
|
||||
void setW( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// h Property ( height of bounding box )
|
||||
//
|
||||
Distance h() const;
|
||||
void setH( const Distance& value );
|
||||
//
|
||||
// h Property ( height of bounding box )
|
||||
//
|
||||
Distance h() const;
|
||||
void setH( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Transformation Matrix Property
|
||||
//
|
||||
QMatrix matrix() const;
|
||||
void setMatrix( const QMatrix& value );
|
||||
//
|
||||
// Transformation Matrix Property
|
||||
//
|
||||
QMatrix matrix() const;
|
||||
void setMatrix( const QMatrix& value );
|
||||
|
||||
|
||||
//
|
||||
// Shadow State Property
|
||||
//
|
||||
bool shadow() const;
|
||||
void setShadow( bool value );
|
||||
//
|
||||
// Shadow State Property
|
||||
//
|
||||
bool shadow() const;
|
||||
void setShadow( bool value );
|
||||
|
||||
|
||||
//
|
||||
// Shadow x Offset Property
|
||||
//
|
||||
Distance shadowX() const;
|
||||
void setShadowX( const Distance& value );
|
||||
//
|
||||
// Shadow x Offset Property
|
||||
//
|
||||
Distance shadowX() const;
|
||||
void setShadowX( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Shadow y Offset Property
|
||||
//
|
||||
Distance shadowY() const;
|
||||
void setShadowY( const Distance& value );
|
||||
//
|
||||
// Shadow y Offset Property
|
||||
//
|
||||
Distance shadowY() const;
|
||||
void setShadowY( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Shadow opacity Property
|
||||
//
|
||||
double shadowOpacity() const;
|
||||
void setShadowOpacity( double value );
|
||||
//
|
||||
// Shadow opacity Property
|
||||
//
|
||||
double shadowOpacity() const;
|
||||
void setShadowOpacity( double value );
|
||||
|
||||
|
||||
//
|
||||
// Shadow Color Property
|
||||
//
|
||||
ColorNode shadowColorNode() const;
|
||||
void setShadowColorNode( const ColorNode& value );
|
||||
//
|
||||
// Shadow Color Property
|
||||
//
|
||||
ColorNode shadowColorNode() const;
|
||||
void setShadowColorNode( const ColorNode& value );
|
||||
|
||||
|
||||
//
|
||||
// Natural Size Property (read-only)
|
||||
//
|
||||
virtual Size naturalSize() const;
|
||||
//
|
||||
// Natural Size Property (read-only)
|
||||
//
|
||||
virtual Size naturalSize() const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Text Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Virtual Text Property: text
|
||||
//
|
||||
virtual QString text() const;
|
||||
virtual void setText( const QString &value );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Text Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Virtual Text Property: text
|
||||
//
|
||||
virtual QString text() const;
|
||||
virtual void setText( const QString &value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: fontFamily
|
||||
//
|
||||
virtual QString fontFamily() const;
|
||||
virtual void setFontFamily( const QString &value );
|
||||
//
|
||||
// Virtual Text Property: fontFamily
|
||||
//
|
||||
virtual QString fontFamily() const;
|
||||
virtual void setFontFamily( const QString &value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: fontSize
|
||||
//
|
||||
virtual double fontSize() const;
|
||||
virtual void setFontSize( double value );
|
||||
//
|
||||
// Virtual Text Property: fontSize
|
||||
//
|
||||
virtual double fontSize() const;
|
||||
virtual void setFontSize( double value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: fontWeight
|
||||
//
|
||||
virtual QFont::Weight fontWeight() const;
|
||||
virtual void setFontWeight( QFont::Weight value );
|
||||
//
|
||||
// Virtual Text Property: fontWeight
|
||||
//
|
||||
virtual QFont::Weight fontWeight() const;
|
||||
virtual void setFontWeight( QFont::Weight value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: fontItalicFlag
|
||||
//
|
||||
virtual bool fontItalicFlag() const;
|
||||
virtual void setFontItalicFlag( bool value );
|
||||
//
|
||||
// Virtual Text Property: fontItalicFlag
|
||||
//
|
||||
virtual bool fontItalicFlag() const;
|
||||
virtual void setFontItalicFlag( bool value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: fontUnderlineFlag
|
||||
//
|
||||
virtual bool fontUnderlineFlag() const;
|
||||
virtual void setFontUnderlineFlag( bool value );
|
||||
//
|
||||
// Virtual Text Property: fontUnderlineFlag
|
||||
//
|
||||
virtual bool fontUnderlineFlag() const;
|
||||
virtual void setFontUnderlineFlag( bool value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: textColorNode
|
||||
//
|
||||
virtual ColorNode textColorNode() const;
|
||||
virtual void setTextColorNode( const ColorNode &value );
|
||||
//
|
||||
// Virtual Text Property: textColorNode
|
||||
//
|
||||
virtual ColorNode textColorNode() const;
|
||||
virtual void setTextColorNode( const ColorNode &value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: textHAlign
|
||||
//
|
||||
virtual Qt::Alignment textHAlign() const;
|
||||
virtual void setTextHAlign( Qt::Alignment value );
|
||||
//
|
||||
// Virtual Text Property: textHAlign
|
||||
//
|
||||
virtual Qt::Alignment textHAlign() const;
|
||||
virtual void setTextHAlign( Qt::Alignment value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: textVAlign
|
||||
//
|
||||
virtual Qt::Alignment textVAlign() const;
|
||||
virtual void setTextVAlign( Qt::Alignment value );
|
||||
//
|
||||
// Virtual Text Property: textVAlign
|
||||
//
|
||||
virtual Qt::Alignment textVAlign() const;
|
||||
virtual void setTextVAlign( Qt::Alignment value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Text Property: textLineSpacing
|
||||
//
|
||||
virtual double textLineSpacing() const;
|
||||
virtual void setTextLineSpacing( double value );
|
||||
//
|
||||
// Virtual Text Property: textLineSpacing
|
||||
//
|
||||
virtual double textLineSpacing() const;
|
||||
virtual void setTextLineSpacing( double value );
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Image Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Virtual Image Property: filenameNode
|
||||
//
|
||||
virtual TextNode filenameNode() const;
|
||||
virtual void setFilenameNode( const TextNode &value );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Image Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Virtual Image Property: filenameNode
|
||||
//
|
||||
virtual TextNode filenameNode() const;
|
||||
virtual void setFilenameNode( const TextNode &value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Image Property: image
|
||||
//
|
||||
virtual const QImage* image() const;
|
||||
virtual void setImage( const QImage& value );
|
||||
virtual void setImage( const QString& name, const QImage& value );
|
||||
//
|
||||
// Virtual Image Property: image
|
||||
//
|
||||
virtual const QImage* image() const;
|
||||
virtual void setImage( const QImage& value );
|
||||
virtual void setImage( const QString& name, const QImage& value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Image Property: svg
|
||||
//
|
||||
virtual QByteArray svg() const;
|
||||
virtual void setSvg( const QString& name, const QByteArray& value );
|
||||
//
|
||||
// Virtual Image Property: svg
|
||||
//
|
||||
virtual QByteArray svg() const;
|
||||
virtual void setSvg( const QString& name, const QByteArray& value );
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Shape Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Virtual Shape Property: lineWidth
|
||||
//
|
||||
virtual Distance lineWidth() const;
|
||||
virtual void setLineWidth( const Distance& value );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Shape Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Virtual Shape Property: lineWidth
|
||||
//
|
||||
virtual Distance lineWidth() const;
|
||||
virtual void setLineWidth( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Shape Property: lineColorNode
|
||||
//
|
||||
virtual ColorNode lineColorNode() const;
|
||||
virtual void setLineColorNode( const ColorNode &value );
|
||||
//
|
||||
// Virtual Shape Property: lineColorNode
|
||||
//
|
||||
virtual ColorNode lineColorNode() const;
|
||||
virtual void setLineColorNode( const ColorNode &value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Shape Property: fillColorNode
|
||||
//
|
||||
virtual ColorNode fillColorNode() const;
|
||||
virtual void setFillColorNode( const ColorNode &value );
|
||||
//
|
||||
// Virtual Shape Property: fillColorNode
|
||||
//
|
||||
virtual ColorNode fillColorNode() const;
|
||||
virtual void setFillColorNode( const ColorNode &value );
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Barcode Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Virtual Barcode Property: bcData
|
||||
//
|
||||
virtual QString bcData() const;
|
||||
virtual void setBcData( const QString& value );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Barcode Properties Virtual Interface
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Virtual Barcode Property: bcData
|
||||
//
|
||||
virtual QString bcData() const;
|
||||
virtual void setBcData( const QString& value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Barcode Property: bcTextFlag
|
||||
//
|
||||
virtual bool bcTextFlag() const;
|
||||
virtual void setBcTextFlag( bool value );
|
||||
//
|
||||
// Virtual Barcode Property: bcTextFlag
|
||||
//
|
||||
virtual bool bcTextFlag() const;
|
||||
virtual void setBcTextFlag( bool value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Barcode Property: bcChecksumFlag
|
||||
//
|
||||
virtual bool bcChecksumFlag() const;
|
||||
virtual void setBcChecksumFlag( bool value );
|
||||
//
|
||||
// Virtual Barcode Property: bcChecksumFlag
|
||||
//
|
||||
virtual bool bcChecksumFlag() const;
|
||||
virtual void setBcChecksumFlag( bool value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Barcode Property: bcColorNode
|
||||
//
|
||||
virtual ColorNode bcColorNode() const;
|
||||
virtual void setBcColorNode( const ColorNode &value );
|
||||
//
|
||||
// Virtual Barcode Property: bcColorNode
|
||||
//
|
||||
virtual ColorNode bcColorNode() const;
|
||||
virtual void setBcColorNode( const ColorNode &value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Barcode Property: bcStyle
|
||||
//
|
||||
virtual barcode::Style bcStyle() const;
|
||||
virtual void setBcStyle( const barcode::Style &value );
|
||||
//
|
||||
// Virtual Barcode Property: bcStyle
|
||||
//
|
||||
virtual barcode::Style bcStyle() const;
|
||||
virtual void setBcStyle( const barcode::Style &value );
|
||||
|
||||
|
||||
//
|
||||
// Virtual Barcode Property: bcFormatDigits
|
||||
//
|
||||
virtual int bcFormatDigits() const;
|
||||
virtual void setBcFormatDigits( int value );
|
||||
//
|
||||
// Virtual Barcode Property: bcFormatDigits
|
||||
//
|
||||
virtual int bcFormatDigits() const;
|
||||
virtual void setBcFormatDigits( int value );
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capabilities (Overridden by concrete classes.)
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual bool canText() const;
|
||||
virtual bool canFill() const;
|
||||
virtual bool canLineColor() const;
|
||||
virtual bool canLineWidth() const;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capabilities (Overridden by concrete classes.)
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual bool canText() const;
|
||||
virtual bool canFill() const;
|
||||
virtual bool canLineColor() const;
|
||||
virtual bool canLineWidth() const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Position and Size methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
void setPosition( const Distance& x0, const Distance& y0 );
|
||||
void setPositionRelative( const Distance& dx, const Distance& dy );
|
||||
Size size() const;
|
||||
void setSize( const Distance& w, const Distance& h );
|
||||
void setSize( const Size& size );
|
||||
void setSizeHonorAspect( const Distance& w, const Distance& h );
|
||||
void setWHonorAspect( const Distance& w );
|
||||
void setHHonorAspect( const Distance& h );
|
||||
Region getExtent();
|
||||
void rotate( double thetaDegs );
|
||||
void flipHoriz();
|
||||
void flipVert();
|
||||
bool isLocatedAt( double scale, const Distance& x, const Distance& y ) const;
|
||||
Handle* handleAt( double scale, const Distance& x, const Distance& y ) const;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Position and Size methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
void setPosition( const Distance& x0, const Distance& y0 );
|
||||
void setPositionRelative( const Distance& dx, const Distance& dy );
|
||||
Size size() const;
|
||||
void setSize( const Distance& w, const Distance& h );
|
||||
void setSize( const Size& size );
|
||||
void setSizeHonorAspect( const Distance& w, const Distance& h );
|
||||
void setWHonorAspect( const Distance& w );
|
||||
void setHHonorAspect( const Distance& h );
|
||||
Region getExtent();
|
||||
void rotate( double thetaDegs );
|
||||
void flipHoriz();
|
||||
void flipVert();
|
||||
bool isLocatedAt( double scale, const Distance& x, const Distance& y ) const;
|
||||
Handle* handleAt( double scale, const Distance& x, const Distance& y ) const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, bool inEditor, merge::Record* record ) const;
|
||||
void drawSelectionHighlight( QPainter* painter, double scale ) const;
|
||||
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||
virtual QPainterPath hoverPath( double scale ) const = 0;
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||
virtual void drawObject( QPainter* painter, bool inEditor, merge::Record* record ) const = 0;
|
||||
virtual QPainterPath hoverPath( double scale ) const = 0;
|
||||
|
||||
virtual void sizeUpdated();
|
||||
virtual void sizeUpdated();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Protected Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
bool mSelectedFlag;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Protected Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
bool mSelectedFlag;
|
||||
|
||||
Distance mX0;
|
||||
Distance mY0;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
Distance mX0;
|
||||
Distance mY0;
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
|
||||
bool mShadowState;
|
||||
Distance mShadowX;
|
||||
Distance mShadowY;
|
||||
double mShadowOpacity;
|
||||
ColorNode mShadowColorNode;
|
||||
bool mShadowState;
|
||||
Distance mShadowX;
|
||||
Distance mShadowY;
|
||||
double mShadowOpacity;
|
||||
ColorNode mShadowColorNode;
|
||||
|
||||
QList<Handle*> mHandles;
|
||||
Outline* mOutline;
|
||||
QList<Handle*> mHandles;
|
||||
Outline* mOutline;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
static int msNextId;
|
||||
int mId;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
static int msNextId;
|
||||
int mId;
|
||||
|
||||
QMatrix mMatrix;
|
||||
QMatrix mMatrix;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+157
-154
@@ -24,184 +24,187 @@
|
||||
#include <QPen>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelShapeObject::ModelShapeObject()
|
||||
namespace model
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelShapeObject::ModelShapeObject()
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mLineWidth = 1.0;
|
||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
|
||||
}
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
|
||||
mLineWidth = 1.0;
|
||||
mLineColorNode = ColorNode( QColor( 0, 0, 0 ) );
|
||||
mFillColorNode = ColorNode( QColor( 0, 255, 0 ) );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelShapeObject::ModelShapeObject( 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 )
|
||||
: ModelObject( x0, y0, w, h,
|
||||
matrix,
|
||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
ModelShapeObject::ModelShapeObject( 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 )
|
||||
: ModelObject( x0, y0, w, h,
|
||||
matrix,
|
||||
shadowState, shadowX, shadowY, shadowOpacity, shadowColorNode )
|
||||
{
|
||||
mOutline = new Outline( this );
|
||||
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
|
||||
mLineWidth = lineWidth;
|
||||
mLineColorNode = lineColorNode;
|
||||
mFillColorNode = fillColorNode;
|
||||
}
|
||||
mLineWidth = lineWidth;
|
||||
mLineColorNode = lineColorNode;
|
||||
mFillColorNode = fillColorNode;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
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 )
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
ModelShapeObject::ModelShapeObject( const ModelShapeObject* object ) : ModelObject(object)
|
||||
{
|
||||
delete handle;
|
||||
mLineWidth = object->mLineWidth;
|
||||
mLineColorNode = object->mLineColorNode;
|
||||
mFillColorNode = object->mFillColorNode;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Width Property Getter
|
||||
///
|
||||
Distance ModelShapeObject::lineWidth() const
|
||||
{
|
||||
return mLineWidth;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Line Width Property Setter
|
||||
///
|
||||
void ModelShapeObject::setLineWidth( const Distance& value )
|
||||
{
|
||||
if ( mLineWidth != value )
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
ModelShapeObject::~ModelShapeObject()
|
||||
{
|
||||
mLineWidth = value;
|
||||
emit changed();
|
||||
delete mOutline;
|
||||
|
||||
foreach( Handle* handle, mHandles )
|
||||
{
|
||||
delete handle;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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 )
|
||||
///
|
||||
/// Line Width Property Getter
|
||||
///
|
||||
Distance ModelShapeObject::lineWidth() const
|
||||
{
|
||||
mLineColorNode = value;
|
||||
emit changed();
|
||||
return mLineWidth;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
ColorNode ModelShapeObject::fillColorNode() const
|
||||
{
|
||||
return mFillColorNode;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Fill Color Node Property Setter
|
||||
///
|
||||
void ModelShapeObject::setFillColorNode( const ColorNode& value )
|
||||
{
|
||||
if ( mFillColorNode != value )
|
||||
///
|
||||
/// Fill Color Node Property Getter
|
||||
///
|
||||
ColorNode ModelShapeObject::fillColorNode() const
|
||||
{
|
||||
mFillColorNode = value;
|
||||
emit changed();
|
||||
return mFillColorNode;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Fill Color Node Property Setter
|
||||
///
|
||||
void ModelShapeObject::setFillColorNode( const ColorNode& value )
|
||||
{
|
||||
if ( mFillColorNode != value )
|
||||
{
|
||||
mFillColorNode = value;
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Can Fill Capability Implementation
|
||||
///
|
||||
bool ModelShapeObject::canFill()
|
||||
{
|
||||
return true;
|
||||
///
|
||||
/// Can Fill Capability Implementation
|
||||
///
|
||||
bool ModelShapeObject::canFill()
|
||||
{
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Shape Object (Box or Ellipse)
|
||||
///
|
||||
class ModelShapeObject : public ModelObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
ModelShapeObject();
|
||||
///
|
||||
/// Label Model Shape Object (Box or Ellipse)
|
||||
///
|
||||
class ModelShapeObject : public ModelObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
ModelShapeObject( 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 );
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
ModelShapeObject();
|
||||
|
||||
ModelShapeObject( const ModelShapeObject* object );
|
||||
public:
|
||||
~ModelShapeObject() override;
|
||||
ModelShapeObject( 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( const ModelShapeObject* object );
|
||||
public:
|
||||
~ModelShapeObject() override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Shape Property: lineWidth
|
||||
//
|
||||
Distance lineWidth() const override;
|
||||
void setLineWidth( const Distance& value ) override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Shape Property: lineWidth
|
||||
//
|
||||
Distance lineWidth() const override;
|
||||
void setLineWidth( const Distance& value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Shape Property: lineColorNode
|
||||
//
|
||||
ColorNode lineColorNode() const override;
|
||||
void setLineColorNode( const ColorNode& value ) override;
|
||||
//
|
||||
// Shape Property: lineColorNode
|
||||
//
|
||||
ColorNode lineColorNode() const override;
|
||||
void setLineColorNode( const ColorNode& value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Shape Property: fillColorNode
|
||||
//
|
||||
ColorNode fillColorNode() const override;
|
||||
void setFillColorNode( const ColorNode& value ) override;
|
||||
//
|
||||
// Shape Property: fillColorNode
|
||||
//
|
||||
ColorNode fillColorNode() const override;
|
||||
void setFillColorNode( const ColorNode& value ) override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual bool canFill();
|
||||
virtual bool canLineColor();
|
||||
virtual bool canLineWidth();
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual bool canFill();
|
||||
virtual bool canLineColor();
|
||||
virtual bool canLineWidth();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
Distance mLineWidth;
|
||||
ColorNode mLineColorNode;
|
||||
ColorNode mFillColorNode;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
Distance mLineWidth;
|
||||
ColorNode mLineColorNode;
|
||||
ColorNode mFillColorNode;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+632
-629
File diff suppressed because it is too large
Load Diff
+137
-134
@@ -28,181 +28,184 @@
|
||||
#include <QTextLayout>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class ModelTextObject : public ModelObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelTextObject();
|
||||
///
|
||||
/// Label Model Line Object
|
||||
///
|
||||
class ModelTextObject : public ModelObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Lifecycle Methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
ModelTextObject();
|
||||
|
||||
ModelTextObject( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const QString& text,
|
||||
const QString& fontFamily,
|
||||
double fontSize,
|
||||
QFont::Weight fontWeight,
|
||||
bool fontItalicFlag,
|
||||
bool fontUnderlineFlag,
|
||||
ColorNode textColorNode,
|
||||
Qt::Alignment textHAlign,
|
||||
Qt::Alignment textVAlign,
|
||||
double textLineSpacing,
|
||||
const QMatrix& matrix = QMatrix(),
|
||||
bool shadowState = false,
|
||||
const Distance& shadowX = 0,
|
||||
const Distance& shadowY = 0,
|
||||
double shadowOpacity = 1.0,
|
||||
const ColorNode& shadowColorNode = ColorNode() );
|
||||
ModelTextObject( const Distance& x0,
|
||||
const Distance& y0,
|
||||
const Distance& w,
|
||||
const Distance& h,
|
||||
const QString& text,
|
||||
const QString& fontFamily,
|
||||
double fontSize,
|
||||
QFont::Weight fontWeight,
|
||||
bool fontItalicFlag,
|
||||
bool fontUnderlineFlag,
|
||||
ColorNode textColorNode,
|
||||
Qt::Alignment textHAlign,
|
||||
Qt::Alignment textVAlign,
|
||||
double textLineSpacing,
|
||||
const QMatrix& matrix = QMatrix(),
|
||||
bool shadowState = false,
|
||||
const Distance& shadowX = 0,
|
||||
const Distance& shadowY = 0,
|
||||
double shadowOpacity = 1.0,
|
||||
const ColorNode& shadowColorNode = ColorNode() );
|
||||
|
||||
ModelTextObject( const ModelTextObject* object );
|
||||
ModelTextObject( const ModelTextObject* object );
|
||||
|
||||
~ModelTextObject() override;
|
||||
~ModelTextObject() override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Object duplication
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelTextObject* clone() const override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Object duplication
|
||||
///////////////////////////////////////////////////////////////
|
||||
ModelTextObject* clone() const override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Text Property: text
|
||||
//
|
||||
QString text() const override;
|
||||
void setText( const QString &value ) override;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Property Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// Text Property: text
|
||||
//
|
||||
QString text() const override;
|
||||
void setText( const QString &value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: fontFamily
|
||||
//
|
||||
QString fontFamily() const override;
|
||||
void setFontFamily( const QString &value ) override;
|
||||
//
|
||||
// Text Property: fontFamily
|
||||
//
|
||||
QString fontFamily() const override;
|
||||
void setFontFamily( const QString &value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: fontSize
|
||||
//
|
||||
double fontSize() const override;
|
||||
void setFontSize( double value ) override;
|
||||
//
|
||||
// Text Property: fontSize
|
||||
//
|
||||
double fontSize() const override;
|
||||
void setFontSize( double value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: fontWeight
|
||||
//
|
||||
QFont::Weight fontWeight() const override;
|
||||
void setFontWeight( QFont::Weight value ) override;
|
||||
//
|
||||
// Text Property: fontWeight
|
||||
//
|
||||
QFont::Weight fontWeight() const override;
|
||||
void setFontWeight( QFont::Weight value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: fontItalicFlag
|
||||
//
|
||||
bool fontItalicFlag() const override;
|
||||
void setFontItalicFlag( bool value ) override;
|
||||
//
|
||||
// Text Property: fontItalicFlag
|
||||
//
|
||||
bool fontItalicFlag() const override;
|
||||
void setFontItalicFlag( bool value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: fontUnderlineFlag
|
||||
//
|
||||
bool fontUnderlineFlag() const override;
|
||||
void setFontUnderlineFlag( bool value ) override;
|
||||
//
|
||||
// Text Property: fontUnderlineFlag
|
||||
//
|
||||
bool fontUnderlineFlag() const override;
|
||||
void setFontUnderlineFlag( bool value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: textColorNode
|
||||
//
|
||||
ColorNode textColorNode() const override;
|
||||
void setTextColorNode( const ColorNode &value ) override;
|
||||
//
|
||||
// Text Property: textColorNode
|
||||
//
|
||||
ColorNode textColorNode() const override;
|
||||
void setTextColorNode( const ColorNode &value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: textHAlign
|
||||
//
|
||||
Qt::Alignment textHAlign() const override;
|
||||
void setTextHAlign( Qt::Alignment value ) override;
|
||||
//
|
||||
// Text Property: textHAlign
|
||||
//
|
||||
Qt::Alignment textHAlign() const override;
|
||||
void setTextHAlign( Qt::Alignment value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: textVAlign
|
||||
//
|
||||
Qt::Alignment textVAlign() const override;
|
||||
void setTextVAlign( Qt::Alignment value ) override;
|
||||
//
|
||||
// Text Property: textVAlign
|
||||
//
|
||||
Qt::Alignment textVAlign() const override;
|
||||
void setTextVAlign( Qt::Alignment value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Text Property: textLineSpacing
|
||||
//
|
||||
double textLineSpacing() const override;
|
||||
void setTextLineSpacing( double value ) override;
|
||||
//
|
||||
// Text Property: textLineSpacing
|
||||
//
|
||||
double textLineSpacing() const override;
|
||||
void setTextLineSpacing( double value ) override;
|
||||
|
||||
|
||||
//
|
||||
// Property: naturalSize
|
||||
//
|
||||
Size naturalSize() const override;
|
||||
//
|
||||
// Property: naturalSize
|
||||
//
|
||||
Size naturalSize() const override;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual bool canText();
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Capability Implementations
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
virtual bool canText();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Drawing operations
|
||||
///////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
void drawShadow( 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;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
void sizeUpdated() override;
|
||||
void update();
|
||||
void drawTextInEditor( QPainter* painter, const QColor& color ) const;
|
||||
void drawText( QPainter* painter, const QColor&color, merge::Record* record ) const;
|
||||
QString expandText( QString text, merge::Record* record ) const;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
void sizeUpdated() override;
|
||||
void update();
|
||||
void drawTextInEditor( QPainter* painter, const QColor& color ) const;
|
||||
void drawText( QPainter* painter, const QColor&color, merge::Record* record ) const;
|
||||
QString expandText( QString text, merge::Record* record ) const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
RawText mText;
|
||||
QString mFontFamily;
|
||||
double mFontSize;
|
||||
QFont::Weight mFontWeight;
|
||||
bool mFontItalicFlag;
|
||||
bool mFontUnderlineFlag;
|
||||
ColorNode mTextColorNode;
|
||||
Qt::Alignment mTextHAlign;
|
||||
Qt::Alignment mTextVAlign;
|
||||
double mTextLineSpacing;
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
///////////////////////////////////////////////////////////////
|
||||
private:
|
||||
RawText mText;
|
||||
QString mFontFamily;
|
||||
double mFontSize;
|
||||
QFont::Weight mFontWeight;
|
||||
bool mFontItalicFlag;
|
||||
bool mFontUnderlineFlag;
|
||||
ColorNode mTextColorNode;
|
||||
Qt::Alignment mTextHAlign;
|
||||
Qt::Alignment mTextVAlign;
|
||||
double mTextLineSpacing;
|
||||
|
||||
QList<QTextLayout*> mEditorLayouts;
|
||||
QPainterPath mHoverPath;
|
||||
QList<QTextLayout*> mEditorLayouts;
|
||||
QPainterPath mHoverPath;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+86
-83
@@ -25,111 +25,114 @@
|
||||
#include <QColor>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
namespace model
|
||||
{
|
||||
const qreal dashSize = 2;
|
||||
|
||||
const double slopPixels = 2;
|
||||
const double outlineWidthPixels = 1;
|
||||
const QColor outlineColor1( 0, 0, 0 );
|
||||
const QColor outlineColor2( 255, 255, 255 );
|
||||
}
|
||||
//
|
||||
// Private
|
||||
//
|
||||
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::Outline( ModelObject* owner )
|
||||
: mOwner(owner)
|
||||
{
|
||||
mDashes << dashSize << dashSize;
|
||||
///
|
||||
/// Outline Constructor
|
||||
///
|
||||
Outline::Outline( ModelObject* owner )
|
||||
: mOwner(owner)
|
||||
{
|
||||
mDashes << dashSize << dashSize;
|
||||
|
||||
mPen1.setColor( outlineColor1 );
|
||||
mPen1.setWidth( outlineWidthPixels );
|
||||
mPen1.setCosmetic( true );
|
||||
mPen1.setCapStyle( Qt::FlatCap );
|
||||
mPen1.setDashPattern( mDashes );
|
||||
mPen1.setColor( outlineColor1 );
|
||||
mPen1.setWidth( outlineWidthPixels );
|
||||
mPen1.setCosmetic( true );
|
||||
mPen1.setCapStyle( Qt::FlatCap );
|
||||
mPen1.setDashPattern( mDashes );
|
||||
|
||||
mPen2.setColor( outlineColor2 );
|
||||
mPen2.setWidth( outlineWidthPixels );
|
||||
mPen2.setCosmetic( true );
|
||||
mPen2.setCapStyle( Qt::FlatCap );
|
||||
mPen2.setDashPattern( mDashes );
|
||||
mPen2.setDashOffset( dashSize );
|
||||
}
|
||||
mPen2.setColor( outlineColor2 );
|
||||
mPen2.setWidth( outlineWidthPixels );
|
||||
mPen2.setCosmetic( true );
|
||||
mPen2.setCapStyle( Qt::FlatCap );
|
||||
mPen2.setDashPattern( mDashes );
|
||||
mPen2.setDashOffset( dashSize );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Outline Copy constructor
|
||||
///
|
||||
Outline::Outline( const Outline* outline, ModelObject* newOwner )
|
||||
: mOwner(newOwner)
|
||||
{
|
||||
mDashes = outline->mDashes;
|
||||
mPen1 = outline->mPen1;
|
||||
mPen2 = outline->mPen2;
|
||||
}
|
||||
///
|
||||
/// Outline Copy constructor
|
||||
///
|
||||
Outline::Outline( const Outline* outline, ModelObject* newOwner )
|
||||
: mOwner(newOwner)
|
||||
{
|
||||
mDashes = outline->mDashes;
|
||||
mPen1 = outline->mPen1;
|
||||
mPen2 = outline->mPen2;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Outline Destructor
|
||||
///
|
||||
Outline::~Outline()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
///
|
||||
/// Outline Destructor
|
||||
///
|
||||
Outline::~Outline()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Clone Outline
|
||||
///
|
||||
Outline* Outline::clone( ModelObject* newOwner ) const
|
||||
{
|
||||
return new Outline( this, newOwner );
|
||||
}
|
||||
///
|
||||
/// Clone Outline
|
||||
///
|
||||
Outline* Outline::clone( ModelObject* newOwner ) const
|
||||
{
|
||||
return new Outline( this, newOwner );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Outline
|
||||
///
|
||||
void Outline::draw( QPainter* painter ) const
|
||||
{
|
||||
painter->save();
|
||||
///
|
||||
/// Draw Outline
|
||||
///
|
||||
void Outline::draw( QPainter* painter ) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->setBrush( Qt::NoBrush );
|
||||
painter->setBrush( Qt::NoBrush );
|
||||
|
||||
painter->setPen( mPen1 );
|
||||
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||
painter->setPen( mPen1 );
|
||||
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||
|
||||
painter->setPen( mPen2 );
|
||||
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||
painter->setPen( mPen2 );
|
||||
painter->drawRect( QRectF( 0, 0, mOwner->w().pt(), mOwner->h().pt() ) );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create path for testing for hover condition
|
||||
///
|
||||
QPainterPath Outline::hoverPath( double scale ) const
|
||||
{
|
||||
double s = 1 / scale;
|
||||
///
|
||||
/// Create path for testing for hover condition
|
||||
///
|
||||
QPainterPath Outline::hoverPath( double scale ) const
|
||||
{
|
||||
double s = 1 / scale;
|
||||
|
||||
QPainterPath path;
|
||||
QPainterPath path;
|
||||
|
||||
path.addRect( -s*slopPixels, -s*slopPixels,
|
||||
mOwner->w().pt()+s*2*slopPixels, mOwner->h().pt()+s*2*slopPixels );
|
||||
path.closeSubpath();
|
||||
path.addRect( s*slopPixels, s*slopPixels,
|
||||
mOwner->w().pt()-s*2*slopPixels, mOwner->h().pt()-s*2*slopPixels );
|
||||
path.addRect( -s*slopPixels, -s*slopPixels,
|
||||
mOwner->w().pt()+s*2*slopPixels, mOwner->h().pt()+s*2*slopPixels );
|
||||
path.closeSubpath();
|
||||
path.addRect( s*slopPixels, s*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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward references
|
||||
class ModelObject;
|
||||
|
||||
|
||||
///
|
||||
/// Outline Base Class
|
||||
///
|
||||
class Outline
|
||||
namespace model
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
Outline( ModelObject* owner );
|
||||
Outline( const Outline* outline, ModelObject* newOwner );
|
||||
virtual ~Outline();
|
||||
|
||||
// Forward references
|
||||
class ModelObject;
|
||||
|
||||
|
||||
///
|
||||
/// Outline Base Class
|
||||
///
|
||||
class Outline
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
Outline( ModelObject* owner );
|
||||
Outline( const Outline* outline, ModelObject* newOwner );
|
||||
virtual ~Outline();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Duplication
|
||||
////////////////////////////
|
||||
Outline* clone( ModelObject* newOwner ) const;
|
||||
////////////////////////////
|
||||
// Duplication
|
||||
////////////////////////////
|
||||
Outline* clone( ModelObject* newOwner ) const;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter ) const;
|
||||
QPainterPath hoverPath( double scale ) const;
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter ) const;
|
||||
QPainterPath hoverPath( double scale ) const;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Private Data
|
||||
////////////////////////////
|
||||
private:
|
||||
ModelObject* mOwner;
|
||||
////////////////////////////
|
||||
// Private Data
|
||||
////////////////////////////
|
||||
private:
|
||||
ModelObject* mOwner;
|
||||
|
||||
QVector<qreal> mDashes;
|
||||
QPen mPen1;
|
||||
QPen mPen2;
|
||||
QVector<qreal> mDashes;
|
||||
QPen mPen1;
|
||||
QPen mPen2;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+360
-357
@@ -29,401 +29,404 @@
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
namespace model
|
||||
{
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
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 )
|
||||
//
|
||||
// Private
|
||||
//
|
||||
namespace
|
||||
{
|
||||
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 )
|
||||
{
|
||||
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 )
|
||||
PageRenderer::PageRenderer( const Model* model )
|
||||
: mModel(nullptr), mNCopies(0), mStartLabel(0),
|
||||
mPrintOutlines(false), mPrintCropMarks(false), mPrintReverse(false),
|
||||
mIPage(0), mIsMerge(false), mNPages(0)
|
||||
{
|
||||
return QRectF( 0, 0, mModel->tmplate()->pageWidth().pt(), mModel->tmplate()->pageHeight().pt() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return QRectF( 0, 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PageRenderer::updateNPages()
|
||||
{
|
||||
if ( mModel )
|
||||
{
|
||||
if ( mIsMerge )
|
||||
if ( model )
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
if ( mLastLabel % mNLabelsPerPage )
|
||||
{
|
||||
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 );
|
||||
mNPages = mLastLabel / mNLabelsPerPage;
|
||||
if ( mLastLabel % mNLabelsPerPage )
|
||||
{
|
||||
mNPages++;
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
int iRecord = 0;
|
||||
int iStart = 0;
|
||||
int iEnd = mNLabelsPerPage;
|
||||
|
||||
if ( iPage == 0 )
|
||||
///
|
||||
/// Print
|
||||
///
|
||||
void PageRenderer::print( QPrinter* printer ) const
|
||||
{
|
||||
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 )
|
||||
{
|
||||
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() );
|
||||
QPainter painter( printer );
|
||||
|
||||
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 );
|
||||
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() )
|
||||
for ( int iPage = 0; iPage < mNPages; iPage++ )
|
||||
{
|
||||
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++ )
|
||||
if ( iPage )
|
||||
{
|
||||
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() );
|
||||
printer->newPage();
|
||||
}
|
||||
|
||||
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();
|
||||
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() );
|
||||
printMergePage( painter, iPage );
|
||||
}
|
||||
else
|
||||
{
|
||||
printSimplePage( painter, iPage );
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if ( mPrintOutlines )
|
||||
void PageRenderer::printMergePage( QPainter* painter, int iPage ) const
|
||||
{
|
||||
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->setBrush( QBrush( Qt::NoBrush ) );
|
||||
painter->setPen( QPen( labelOutlineColor, labelOutlineWidth ) );
|
||||
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->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();
|
||||
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
// Forward references
|
||||
class Model;
|
||||
|
||||
|
||||
///
|
||||
/// PageRenderer Widget
|
||||
///
|
||||
class PageRenderer : public QObject
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
// Forward references
|
||||
class Model;
|
||||
|
||||
|
||||
///
|
||||
/// PageRenderer Widget
|
||||
///
|
||||
class PageRenderer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
PageRenderer( const Model* model = nullptr );
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
public:
|
||||
PageRenderer( const Model* model = nullptr );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void setModel( const Model* model );
|
||||
const Model* model() const;
|
||||
void setNCopies( int nCopies );
|
||||
void setStartLabel( int startLabel );
|
||||
void setPrintOutlines( bool printOutlinesFlag );
|
||||
void setPrintCropMarks( bool printCropMarksFlag );
|
||||
void setPrintReverse( bool printReverseFlag );
|
||||
void setIPage( int iPage );
|
||||
int nItems() const;
|
||||
int nPages() const;
|
||||
QRectF pageRect() const;
|
||||
void print( QPrinter* printer ) const;
|
||||
void printPage( QPainter* painter ) const;
|
||||
void printPage( QPainter* painter, int iPage ) const;
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void setModel( const Model* model );
|
||||
const Model* model() const;
|
||||
void setNCopies( int nCopies );
|
||||
void setStartLabel( int startLabel );
|
||||
void setPrintOutlines( bool printOutlinesFlag );
|
||||
void setPrintCropMarks( bool printCropMarksFlag );
|
||||
void setPrintReverse( bool printReverseFlag );
|
||||
void setIPage( int iPage );
|
||||
int nItems() const;
|
||||
int nPages() const;
|
||||
QRectF pageRect() const;
|
||||
void print( QPrinter* printer ) const;
|
||||
void printPage( QPainter* painter ) const;
|
||||
void printPage( QPainter* painter, int iPage ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void changed();
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
void onModelChanged();
|
||||
/////////////////////////////////
|
||||
// Private slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
void onModelChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Internal Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
void updateNPages();
|
||||
void printSimplePage( QPainter* painter, int iPage ) const;
|
||||
void printMergePage( QPainter* painter, int iPage ) const;
|
||||
void printCropMarks( QPainter* painter ) const;
|
||||
void printOutline( QPainter* painter ) const;
|
||||
void clipLabel( QPainter* painter ) const;
|
||||
void printLabel( QPainter* painter, merge::Record* record ) const;
|
||||
/////////////////////////////////
|
||||
// Internal Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
void updateNPages();
|
||||
void printSimplePage( QPainter* painter, int iPage ) const;
|
||||
void printMergePage( QPainter* painter, int iPage ) const;
|
||||
void printCropMarks( QPainter* painter ) const;
|
||||
void printOutline( QPainter* painter ) const;
|
||||
void clipLabel( QPainter* painter ) const;
|
||||
void printLabel( QPainter* painter, merge::Record* record ) const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
const Model* mModel;
|
||||
const merge::Merge* mMerge;
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
const Model* mModel;
|
||||
const merge::Merge* mMerge;
|
||||
|
||||
int mNCopies;
|
||||
int mStartLabel;
|
||||
int mLastLabel;
|
||||
bool mPrintOutlines;
|
||||
bool mPrintCropMarks;
|
||||
bool mPrintReverse;
|
||||
int mIPage;
|
||||
int mNCopies;
|
||||
int mStartLabel;
|
||||
int mLastLabel;
|
||||
bool mPrintOutlines;
|
||||
bool mPrintCropMarks;
|
||||
bool mPrintReverse;
|
||||
int mIPage;
|
||||
|
||||
bool mIsMerge;
|
||||
int mNPages;
|
||||
int mNLabelsPerPage;
|
||||
bool mIsMerge;
|
||||
int mNPages;
|
||||
int mNLabelsPerPage;
|
||||
|
||||
QVector<Point> mOrigins;
|
||||
};
|
||||
QVector<Point> mOrigins;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+42
-39
@@ -21,59 +21,62 @@
|
||||
#include "Paper.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
namespace model
|
||||
{
|
||||
|
||||
Paper::Paper( const QString& id,
|
||||
const QString& name,
|
||||
const Distance& width,
|
||||
const Distance& height,
|
||||
const QString& pwgSize )
|
||||
: mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
Paper::Paper( const QString& id,
|
||||
const QString& name,
|
||||
const Distance& width,
|
||||
const Distance& height,
|
||||
const QString& pwgSize )
|
||||
: mId(id), mName(name), mWidth(width), mHeight(height), mPwgSize(pwgSize)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
QString Paper::id() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
QString Paper::id() const
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
|
||||
|
||||
QString Paper::name() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
QString Paper::name() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
|
||||
Distance Paper::width() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
Distance Paper::width() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
|
||||
Distance Paper::height() const
|
||||
{
|
||||
return mHeight;
|
||||
}
|
||||
Distance Paper::height() const
|
||||
{
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
|
||||
QString Paper::pwgSize() const
|
||||
{
|
||||
return mPwgSize;
|
||||
}
|
||||
QString Paper::pwgSize() const
|
||||
{
|
||||
return mPwgSize;
|
||||
}
|
||||
|
||||
|
||||
bool Paper::isSizeIso() const
|
||||
{
|
||||
return mPwgSize.startsWith( "iso_" );
|
||||
}
|
||||
bool Paper::isSizeIso() const
|
||||
{
|
||||
return mPwgSize.startsWith( "iso_" );
|
||||
}
|
||||
|
||||
|
||||
bool Paper::isSizeUs() const
|
||||
{
|
||||
return mPwgSize.startsWith( "na_" );
|
||||
}
|
||||
bool Paper::isSizeUs() const
|
||||
{
|
||||
return mPwgSize.startsWith( "na_" );
|
||||
}
|
||||
|
||||
} // namespace glabels::model
|
||||
}
|
||||
}
|
||||
|
||||
+29
-26
@@ -27,41 +27,44 @@
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class Paper
|
||||
namespace model
|
||||
{
|
||||
public:
|
||||
Paper( const QString& id,
|
||||
const QString& name,
|
||||
const Distance& width,
|
||||
const Distance& height,
|
||||
const QString& pwgSize );
|
||||
|
||||
QString id() const;
|
||||
QString name() const;
|
||||
class Paper
|
||||
{
|
||||
public:
|
||||
Paper( const QString& id,
|
||||
const QString& name,
|
||||
const Distance& width,
|
||||
const Distance& height,
|
||||
const QString& pwgSize );
|
||||
|
||||
/* Width */
|
||||
Distance width() const;
|
||||
QString id() const;
|
||||
QString name() const;
|
||||
|
||||
/* Height */
|
||||
Distance height() const;
|
||||
/* Width */
|
||||
Distance width() const;
|
||||
|
||||
/* PWG 5101.1-2002 size name */
|
||||
QString pwgSize() const;
|
||||
/* Height */
|
||||
Distance height() const;
|
||||
|
||||
bool isSizeIso() const;
|
||||
bool isSizeUs() const;
|
||||
/* PWG 5101.1-2002 size name */
|
||||
QString pwgSize() const;
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
QString mName;
|
||||
Distance mWidth;
|
||||
Distance mHeight;
|
||||
QString mPwgSize;
|
||||
};
|
||||
bool isSizeIso() const;
|
||||
bool isSizeUs() const;
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
QString mName;
|
||||
Distance mWidth;
|
||||
Distance mHeight;
|
||||
QString mPwgSize;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+33
-30
@@ -21,44 +21,47 @@
|
||||
#include "Point.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
Point::Point() : mX(Distance(0)), mY(Distance(0))
|
||||
namespace model
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
Point::Point() : mX(Distance(0)), mY(Distance(0))
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Point::Point( Distance x, Distance y ) : mX(x), mY(y)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
Point::Point( Distance x, Distance y ) : mX(x), mY(y)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Distance Point::x() const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
Distance Point::x() const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
|
||||
Distance Point::y() const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
|
||||
bool Point::operator<( const Point &other ) const
|
||||
{
|
||||
if ( mY < other.mY )
|
||||
Distance Point::y() const
|
||||
{
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class Point
|
||||
namespace model
|
||||
{
|
||||
public:
|
||||
Point();
|
||||
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
Point();
|
||||
|
||||
Point( Distance x, Distance y );
|
||||
Point( Distance x, Distance y );
|
||||
|
||||
Distance x() const;
|
||||
Distance y() const;
|
||||
Distance x() const;
|
||||
Distance y() const;
|
||||
|
||||
bool operator<( const Point &other ) const;
|
||||
bool operator<( const Point &other ) const;
|
||||
|
||||
|
||||
private:
|
||||
Distance mX;
|
||||
Distance mY;
|
||||
};
|
||||
private:
|
||||
Distance mX;
|
||||
Distance mY;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+111
-108
@@ -22,128 +22,131 @@
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor from QString
|
||||
///
|
||||
RawText::RawText( const QString& string ) : mString(string)
|
||||
namespace model
|
||||
{
|
||||
tokenize();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Constructor from C string operator
|
||||
///
|
||||
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 )
|
||||
///
|
||||
/// Constructor from QString
|
||||
///
|
||||
RawText::RawText( const QString& string ) : mString(string)
|
||||
{
|
||||
if ( token.isField )
|
||||
{
|
||||
text += token.field.evaluate( record );
|
||||
}
|
||||
else
|
||||
{
|
||||
text += token.text;
|
||||
}
|
||||
tokenize();
|
||||
}
|
||||
|
||||
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() )
|
||||
///
|
||||
/// Constructor from C string operator
|
||||
///
|
||||
RawText::RawText( const char* cString ) : mString(QString(cString))
|
||||
{
|
||||
SubstitutionField field;
|
||||
if ( SubstitutionField::parse( s, field ) )
|
||||
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 )
|
||||
{
|
||||
// Finalize current text token, if apropos
|
||||
if ( !token.text.isEmpty() )
|
||||
if ( token.isField )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
// Create and finalize field token
|
||||
token.isField = true;
|
||||
token.text = "";
|
||||
token.field = field;
|
||||
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 );
|
||||
}
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Raw Text Type
|
||||
///
|
||||
struct RawText
|
||||
namespace model
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// 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;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
void tokenize();
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
QString mString;
|
||||
|
||||
struct Token
|
||||
///
|
||||
/// Raw Text Type
|
||||
///
|
||||
struct RawText
|
||||
{
|
||||
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"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Region::Region() : mX1(0), mY1(0), mX2(0), mY2(0)
|
||||
namespace model
|
||||
{
|
||||
// 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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Label Region Type
|
||||
///
|
||||
struct Region
|
||||
namespace model
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Constructors
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Region();
|
||||
Region( const Distance& x1, const Distance& y1,
|
||||
const Distance& x2, const Distance& y2 );
|
||||
///
|
||||
/// Label Region Type
|
||||
///
|
||||
struct Region
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Constructors
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Region();
|
||||
Region( const Distance& x1, const Distance& y1,
|
||||
const Distance& x2, const Distance& y2 );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// X1 Property
|
||||
//
|
||||
Distance x1() const;
|
||||
void setX1( const Distance& value );
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// X1 Property
|
||||
//
|
||||
Distance x1() const;
|
||||
void setX1( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// Y1 Property
|
||||
//
|
||||
Distance y1() const;
|
||||
void setY1( const Distance& value );
|
||||
//
|
||||
// Y1 Property
|
||||
//
|
||||
Distance y1() const;
|
||||
void setY1( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// X2 Property
|
||||
//
|
||||
Distance x2() const;
|
||||
void setX2( const Distance& value );
|
||||
//
|
||||
// X2 Property
|
||||
//
|
||||
Distance x2() const;
|
||||
void setX2( const Distance& value );
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Y2 Property
|
||||
//
|
||||
Distance y2() const;
|
||||
void setY2( const Distance& value );
|
||||
//
|
||||
// Y2 Property
|
||||
//
|
||||
Distance y2() const;
|
||||
void setY2( const Distance& value );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QRectF rect() const;
|
||||
/////////////////////////////////
|
||||
// Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QRectF rect() const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
Distance mX1;
|
||||
Distance mY1;
|
||||
Distance mX2;
|
||||
Distance mY2;
|
||||
};
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
Distance mX1;
|
||||
Distance mY1;
|
||||
Distance mX2;
|
||||
Distance mY2;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+227
-224
@@ -25,237 +25,240 @@
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
Settings* Settings::mInstance = nullptr;
|
||||
|
||||
|
||||
Settings::Settings()
|
||||
namespace model
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
//
|
||||
// Static data
|
||||
//
|
||||
Settings* Settings::mInstance = nullptr;
|
||||
|
||||
|
||||
void Settings::init()
|
||||
{
|
||||
if ( mInstance == nullptr )
|
||||
Settings::Settings()
|
||||
{
|
||||
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();
|
||||
// empty
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Settings Singleton Class
|
||||
///
|
||||
class Settings : public QSettings
|
||||
namespace model
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
///
|
||||
/// Settings Singleton Class
|
||||
///
|
||||
class Settings : public QSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class PageSizeFamilty { ISO, US, };
|
||||
public:
|
||||
enum class PageSizeFamilty { ISO, US, };
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
Settings();
|
||||
/////////////////////////////////
|
||||
// Life Cycle
|
||||
/////////////////////////////////
|
||||
private:
|
||||
Settings();
|
||||
|
||||
public:
|
||||
static void init();
|
||||
static Settings* instance();
|
||||
public:
|
||||
static void init();
|
||||
static Settings* instance();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void changed();
|
||||
/////////////////////////////////
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Accessors
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static Units units();
|
||||
static void setUnits( const Units& units );
|
||||
/////////////////////////////////
|
||||
// Accessors
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static Units units();
|
||||
static void setUnits( const Units& units );
|
||||
|
||||
static bool searchIsoPaperSizes();
|
||||
static void setSearchIsoPaperSizes( bool searchIsoPaperSizes );
|
||||
static bool searchIsoPaperSizes();
|
||||
static void setSearchIsoPaperSizes( bool searchIsoPaperSizes );
|
||||
|
||||
static bool searchUsPaperSizes();
|
||||
static void setSearchUsPaperSizes( bool searchUsPaperSizes );
|
||||
static bool searchUsPaperSizes();
|
||||
static void setSearchUsPaperSizes( bool searchUsPaperSizes );
|
||||
|
||||
static bool searchOtherPaperSizes();
|
||||
static void setSearchOtherPaperSizes( bool searchOtherPaperSizes );
|
||||
static bool searchOtherPaperSizes();
|
||||
static void setSearchOtherPaperSizes( bool searchOtherPaperSizes );
|
||||
|
||||
static bool searchAllCategories();
|
||||
static void setSearchAllCategories( bool searchAllCategories );
|
||||
static bool searchAllCategories();
|
||||
static void setSearchAllCategories( bool searchAllCategories );
|
||||
|
||||
static QStringList searchCategoryList();
|
||||
static void setSearchCategoryList( const QStringList& searchCategoryList );
|
||||
static QStringList searchCategoryList();
|
||||
static void setSearchCategoryList( const QStringList& searchCategoryList );
|
||||
|
||||
static QStringList recentTemplateList();
|
||||
static void addToRecentTemplateList( const QString& name );
|
||||
static QStringList recentTemplateList();
|
||||
static void addToRecentTemplateList( const QString& name );
|
||||
|
||||
|
||||
private:
|
||||
static Settings* mInstance;
|
||||
private:
|
||||
static Settings* mInstance;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+71
-68
@@ -21,74 +21,77 @@
|
||||
#include "Size.h"
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
Size::Size() : mW(0), mH(0)
|
||||
namespace model
|
||||
{
|
||||
// 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>
|
||||
|
||||
|
||||
namespace glabels::model
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
///
|
||||
/// Size Type
|
||||
///
|
||||
class Size
|
||||
namespace model
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Constructors
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Size();
|
||||
Size( const Distance& w, const Distance& h );
|
||||
///
|
||||
/// Size Type
|
||||
///
|
||||
class Size
|
||||
{
|
||||
|
||||
/////////////////////////////////
|
||||
// Constructors
|
||||
/////////////////////////////////
|
||||
public:
|
||||
Size();
|
||||
Size( const Distance& w, const Distance& h );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// w Property
|
||||
//
|
||||
Distance w() const;
|
||||
void setW( const Distance& value );
|
||||
/////////////////////////////////
|
||||
// Properties
|
||||
/////////////////////////////////
|
||||
public:
|
||||
//
|
||||
// w Property
|
||||
//
|
||||
Distance w() const;
|
||||
void setW( const Distance& value );
|
||||
|
||||
|
||||
//
|
||||
// H Property
|
||||
//
|
||||
Distance h() const;
|
||||
void setH( const Distance& value );
|
||||
//
|
||||
// H Property
|
||||
//
|
||||
Distance h() const;
|
||||
void setH( const Distance& value );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QSizeF qSizeF() const;
|
||||
/////////////////////////////////
|
||||
// Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QSizeF qSizeF() const;
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
Distance mW;
|
||||
Distance mH;
|
||||
/////////////////////////////////
|
||||
// Private Data
|
||||
/////////////////////////////////
|
||||
private:
|
||||
Distance mW;
|
||||
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