Restructuring directory layout. Move towards "Modern CMake" usage.

This commit is contained in:
Jim Evins
2017-11-23 22:15:24 -05:00
parent 8bec3594ec
commit b8ee5e1f73
198 changed files with 4509 additions and 5324 deletions
+5 -1
View File
@@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 2.8.12)
############################################################################### ###############################################################################
# gLabels Label Designer Project # gLabels Label Designer Project
############################################################################### ###############################################################################
project (glabels) project (glabels-qt)
# #
# Path for locally defined cmake modules # Path for locally defined cmake modules
@@ -35,6 +35,7 @@ if (MINGW)
set (CMAKE_PREFIX_PATH ${MINGW_BASE_DIR} ) set (CMAKE_PREFIX_PATH ${MINGW_BASE_DIR} )
endif () endif ()
find_package (Qt5Core 5.4 REQUIRED)
find_package (Qt5Widgets 5.4 REQUIRED) find_package (Qt5Widgets 5.4 REQUIRED)
find_package (Qt5PrintSupport 5.4 REQUIRED) find_package (Qt5PrintSupport 5.4 REQUIRED)
find_package (Qt5Xml 5.4 REQUIRED) find_package (Qt5Xml 5.4 REQUIRED)
@@ -71,7 +72,10 @@ endif ()
# Subdirectories # Subdirectories
#======================================= #=======================================
add_subdirectory (glbarcode) add_subdirectory (glbarcode)
add_subdirectory (backends)
add_subdirectory (model)
add_subdirectory (glabels) add_subdirectory (glabels)
add_subdirectory (glabels-batch)
add_subdirectory (templates) add_subdirectory (templates)
add_subdirectory (translations) add_subdirectory (translations)
add_subdirectory (data) add_subdirectory (data)
+8
View File
@@ -0,0 +1,8 @@
#=======================================
# Subdirectories
#=======================================
add_subdirectory (barcode)
add_subdirectory (merge)
@@ -1,4 +1,4 @@
/* BarcodeBackends.cpp /* Backends.cpp
* *
* Copyright (C) 2014 Jim Evins <evins@snaught.com> * Copyright (C) 2014 Jim Evins <evins@snaught.com>
* *
@@ -18,28 +18,28 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>. * along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "BarcodeBackends.h" #include "Backends.h"
#include "GnuBarcode.h"
#include "QrEncode.h"
#include "Zint.h"
#include "glbarcode/Factory.h" #include "glbarcode/Factory.h"
#include "BarcodeBackends/GnuBarcode.h"
#include "BarcodeBackends/QrEncode.h"
#include "BarcodeBackends/Zint.h"
namespace glabels::barcode
namespace glabels
{ {
// //
// Static data // Static data
// //
QStringList BarcodeBackends::mBackendIdList; QStringList Backends::mBackendIdList;
QMap<QString,QString> BarcodeBackends::mBackendNameMap; QMap<QString,QString> Backends::mBackendNameMap;
QList<BarcodeStyle> BarcodeBackends::mStyleList; QList<Style> Backends::mStyleList;
BarcodeBackends::BarcodeBackends() Backends::Backends()
{ {
registerStyle( "code39", "", tr("Code 39"), registerStyle( "code39", "", tr("Code 39"),
true, true, true, true, "1234567890", true, 10 ); true, true, true, true, "1234567890", true, 10 );
@@ -449,44 +449,44 @@ namespace glabels
} }
void BarcodeBackends::init() void Backends::init()
{ {
static BarcodeBackends* singletonInstance = nullptr; static Backends* singletonInstance = nullptr;
if ( singletonInstance == nullptr ) if ( singletonInstance == nullptr )
{ {
singletonInstance = new BarcodeBackends(); singletonInstance = new Backends();
} }
} }
const QStringList& BarcodeBackends::backendList() const QStringList& Backends::backendList()
{ {
return mBackendIdList; return mBackendIdList;
} }
QString BarcodeBackends::backendName( const QString& backendId ) QString Backends::backendName( const QString& backendId )
{ {
return mBackendNameMap[ backendId ]; return mBackendNameMap[ backendId ];
} }
const QList<BarcodeStyle>& BarcodeBackends::styleList() const QList<Style>& Backends::styleList()
{ {
return mStyleList; return mStyleList;
} }
const BarcodeStyle& BarcodeBackends::defaultStyle() const Style& Backends::defaultStyle()
{ {
return mStyleList[0]; return mStyleList[0];
} }
const BarcodeStyle& BarcodeBackends::style( const QString& backendId, const QString& StyleId ) const Style& Backends::style( const QString& backendId, const QString& StyleId )
{ {
foreach ( const BarcodeStyle& bcStyle, mStyleList ) foreach ( const Style& bcStyle, mStyleList )
{ {
if ( (bcStyle.backendId() == backendId) && (bcStyle.id() == StyleId) ) if ( (bcStyle.backendId() == backendId) && (bcStyle.id() == StyleId) )
{ {
@@ -498,14 +498,14 @@ namespace glabels
} }
void BarcodeBackends::registerBackend( const QString& backendId, const QString& backendName ) void Backends::registerBackend( const QString& backendId, const QString& backendName )
{ {
mBackendIdList.append( backendId ); mBackendIdList.append( backendId );
mBackendNameMap[ backendId ] = backendName; mBackendNameMap[ backendId ] = backendName;
} }
void BarcodeBackends::registerStyle( const QString& id, void Backends::registerStyle( const QString& id,
const QString& backendId, const QString& backendId,
const QString& name, const QString& name,
bool canText, bool canText,
@@ -516,7 +516,7 @@ namespace glabels
bool canFreeForm, bool canFreeForm,
int preferedN ) int preferedN )
{ {
BarcodeStyle style( id, backendId, name, Style style( id, backendId, name,
canText, textOptional, canText, textOptional,
canChecksum, checksumOptional, canChecksum, checksumOptional,
defaultDigits, defaultDigits,
@@ -525,4 +525,4 @@ namespace glabels
mStyleList.append( style ); mStyleList.append( style );
} }
} // namespace glabels } // namespace glabels::barcode
@@ -1,4 +1,4 @@
/* BarcodeBackends.h /* Backends.h
* *
* Copyright (C) 2014 Jim Evins <evins@snaught.com> * Copyright (C) 2014 Jim Evins <evins@snaught.com>
* *
@@ -18,11 +18,11 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>. * along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef BarcodeBackends_h #ifndef barcode_Backends_h
#define BarcodeBackends_h #define barcode_Backends_h
#include "BarcodeStyle.h" #include "Style.h"
#include <QList> #include <QList>
#include <QMap> #include <QMap>
@@ -30,13 +30,13 @@
#include <QString> #include <QString>
namespace glabels namespace glabels::barcode
{ {
/// ///
/// Barcode Backends Database /// Backends Database
/// ///
class BarcodeBackends : public QObject class Backends : public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -45,7 +45,7 @@ namespace glabels
// Life Cycle // Life Cycle
///////////////////////////////// /////////////////////////////////
private: private:
BarcodeBackends(); Backends();
public: public:
static void init(); static void init();
@@ -56,9 +56,9 @@ namespace glabels
public: public:
static const QStringList& backendList(); static const QStringList& backendList();
static QString backendName( const QString& backendId ); static QString backendName( const QString& backendId );
static const QList<BarcodeStyle>& styleList(); static const QList<Style>& styleList();
static const BarcodeStyle& defaultStyle(); static const Style& defaultStyle();
static const BarcodeStyle& style( const QString& backendId, const QString& StyleId ); static const Style& style( const QString& backendId, const QString& StyleId );
///////////////////////////////// /////////////////////////////////
@@ -85,11 +85,11 @@ namespace glabels
static QStringList mBackendIdList; static QStringList mBackendIdList;
static QMap<QString,QString> mBackendNameMap; static QMap<QString,QString> mBackendNameMap;
static QList<BarcodeStyle> mStyleList; static QList<Style> mStyleList;
}; };
} }
#endif // BarcodeBackends_h #endif // barcode_Backends_h
+66
View File
@@ -0,0 +1,66 @@
project (Barcode LANGUAGES CXX)
#=======================================
# Handle optional dependencies
#=======================================
if (${GNUBARCODE_FOUND})
add_definitions (-DHAVE_GNU_BARCODE=1)
set (OPTIONAL_GNUBARCODE GNU::BARCODE)
else ()
set (OPTIONAL_GNUBARCODE "")
endif ()
if (${LIBQRENCODE_FOUND})
add_definitions (-DHAVE_QRENCODE=1)
set (OPTIONAL_QRENCODE QRENCODE::QRENCODE)
else ()
set (OPTIONAL_QRENCODE "")
endif ()
if (${LIBZINT_FOUND})
add_definitions (-DHAVE_ZINT=1)
set (OPTIONAL_ZINT ZINT::ZINT)
else ()
set (OPTIONAL_ZINT "")
endif ()
#=======================================
# Sources
#=======================================
set (barcode_sources
Backends.cpp
Style.cpp
GnuBarcode.cpp
QrEncode.cpp
Zint.cpp
)
set (barcode_qobject_headers
Backends.h
)
qt5_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers})
#=====================================
# Target
#=====================================
add_library (Barcode STATIC
${barcode_sources}
${barcode_moc_sources}
)
target_compile_features (Barcode
PUBLIC cxx_std_11
)
target_include_directories (Barcode
PUBLIC ..
)
target_link_libraries (Barcode
glbarcode
Qt5::Core
${OPTIONAL_GNUBARCODE}
${OPTIONAL_ZINT}
${OPTIONAL_QRENCODE}
)
@@ -34,7 +34,7 @@ namespace
} }
namespace glabels namespace glabels::barcode
{ {
namespace GnuBarcode namespace GnuBarcode
{ {
@@ -26,7 +26,7 @@
#include "glbarcode/Barcode1dBase.h" #include "glbarcode/Barcode1dBase.h"
namespace glabels namespace glabels::barcode
{ {
namespace GnuBarcode namespace GnuBarcode
{ {
@@ -25,7 +25,7 @@
#include <qrencode.h> #include <qrencode.h>
namespace glabels namespace glabels::barcode
{ {
namespace QrEncode namespace QrEncode
{ {
@@ -26,7 +26,7 @@
#include "glbarcode/Barcode2dBase.h" #include "glbarcode/Barcode2dBase.h"
namespace glabels namespace glabels::barcode
{ {
namespace QrEncode namespace QrEncode
{ {
@@ -1,4 +1,4 @@
/* BarcodeStyle.cpp /* Style.cpp
* *
* Copyright (C) 2013 Jim Evins <evins@snaught.com> * Copyright (C) 2013 Jim Evins <evins@snaught.com>
* *
@@ -18,16 +18,16 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>. * along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "BarcodeStyle.h" #include "Style.h"
namespace glabels namespace glabels::barcode
{ {
/// ///
/// Default Constructor /// Default Constructor
/// ///
BarcodeStyle::BarcodeStyle () Style::Style ()
: mId( "" ), : mId( "" ),
mBackendId( "" ), mBackendId( "" ),
mName( "" ), mName( "" ),
@@ -46,7 +46,7 @@ namespace glabels
/// ///
/// Constructor From Data /// Constructor From Data
/// ///
BarcodeStyle::BarcodeStyle ( const QString& id, Style::Style ( const QString& id,
const QString& backendId, const QString& backendId,
const QString& name, const QString& name,
bool canText, bool canText,
@@ -74,7 +74,7 @@ namespace glabels
/// ///
/// ID Property Getter /// ID Property Getter
/// ///
const QString& BarcodeStyle::id() const const QString& Style::id() const
{ {
return mId; return mId;
} }
@@ -83,7 +83,7 @@ namespace glabels
/// ///
/// Full ID Property Getter /// Full ID Property Getter
/// ///
QString BarcodeStyle::fullId() const QString Style::fullId() const
{ {
if ( mBackendId == "" ) if ( mBackendId == "" )
{ {
@@ -99,7 +99,7 @@ namespace glabels
/// ///
/// Backend ID Property Getter /// Backend ID Property Getter
/// ///
const QString& BarcodeStyle::backendId() const const QString& Style::backendId() const
{ {
return mBackendId; return mBackendId;
} }
@@ -108,7 +108,7 @@ namespace glabels
/// ///
/// Name Property Getter /// Name Property Getter
/// ///
const QString& BarcodeStyle::name() const const QString& Style::name() const
{ {
return mName; return mName;
} }
@@ -117,7 +117,7 @@ namespace glabels
/// ///
/// Can Text Property Getter /// Can Text Property Getter
/// ///
bool BarcodeStyle::canText() const bool Style::canText() const
{ {
return mCanText; return mCanText;
} }
@@ -126,7 +126,7 @@ namespace glabels
/// ///
/// Text Optional Property Getter /// Text Optional Property Getter
/// ///
bool BarcodeStyle::textOptional() const bool Style::textOptional() const
{ {
return mTextOptional; return mTextOptional;
} }
@@ -135,7 +135,7 @@ namespace glabels
/// ///
/// Can Checksum Property Getter /// Can Checksum Property Getter
/// ///
bool BarcodeStyle::canChecksum() const bool Style::canChecksum() const
{ {
return mCanChecksum; return mCanChecksum;
} }
@@ -144,7 +144,7 @@ namespace glabels
/// ///
/// Checksum Optional Property Getter /// Checksum Optional Property Getter
/// ///
bool BarcodeStyle::checksumOptional() const bool Style::checksumOptional() const
{ {
return mChecksumOptional; return mChecksumOptional;
} }
@@ -153,7 +153,7 @@ namespace glabels
/// ///
/// Default Digits Property Getter /// Default Digits Property Getter
/// ///
const QString& BarcodeStyle::defaultDigits() const const QString& Style::defaultDigits() const
{ {
return mDefaultDigits; return mDefaultDigits;
} }
@@ -162,7 +162,7 @@ namespace glabels
/// ///
/// Can Freeform Property Getter /// Can Freeform Property Getter
/// ///
bool BarcodeStyle::canFreeform() const bool Style::canFreeform() const
{ {
return mCanFreeform; return mCanFreeform;
} }
@@ -171,7 +171,7 @@ namespace glabels
/// ///
/// Prefered N Property Getter /// Prefered N Property Getter
/// ///
int BarcodeStyle::preferedN() const int Style::preferedN() const
{ {
return mPreferedN; return mPreferedN;
} }
@@ -180,7 +180,7 @@ namespace glabels
/// ///
/// Generate Example Digits /// Generate Example Digits
/// ///
QString BarcodeStyle::exampleDigits( int n ) const QString Style::exampleDigits( int n ) const
{ {
if ( mCanFreeform ) if ( mCanFreeform )
{ {
@@ -196,9 +196,9 @@ namespace glabels
/// ///
/// "Not equals" operator /// "Not equals" operator
/// ///
bool BarcodeStyle::operator!=( const BarcodeStyle& other ) const bool Style::operator!=( const Style& other ) const
{ {
return mId != other.mId; return mId != other.mId;
} }
} // namespace glabels } // namespace glabels::barcode
@@ -1,4 +1,4 @@
/* BarcodeStyle.h /* Style.h
* *
* Copyright (C) 2013 Jim Evins <evins@snaught.com> * Copyright (C) 2013 Jim Evins <evins@snaught.com>
* *
@@ -18,29 +18,29 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>. * along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef BarcodeStyle_h #ifndef barcode_Style_h
#define BarcodeStyle_h #define barcode_Style_h
#include <QString> #include <QString>
namespace glabels namespace glabels::barcode
{ {
/// ///
/// Barcode Style Type /// Style Type
/// ///
class BarcodeStyle class Style
{ {
///////////////////////////////// /////////////////////////////////
// Life Cycle // Life Cycle
///////////////////////////////// /////////////////////////////////
public: public:
BarcodeStyle (); Style ();
BarcodeStyle ( const QString& id, Style ( const QString& id,
const QString& backendId, const QString& backendId,
const QString& name, const QString& name,
bool canText, bool canText,
@@ -89,7 +89,7 @@ namespace glabels
// Operators // Operators
///////////////////////////////// /////////////////////////////////
public: public:
bool operator!=( const BarcodeStyle& other ) const; bool operator!=( const Style& other ) const;
///////////////////////////////// /////////////////////////////////
@@ -112,4 +112,4 @@ namespace glabels
} }
#endif // BarcodeStyle_h #endif // barcode_Style_h
@@ -34,7 +34,7 @@ namespace
} }
namespace glabels namespace glabels::barcode
{ {
namespace Zint namespace Zint
{ {
@@ -26,7 +26,7 @@
#include "glbarcode/Barcode1dBase.h" #include "glbarcode/Barcode1dBase.h"
namespace glabels namespace glabels::barcode
{ {
namespace Zint namespace Zint
{ {
+46
View File
@@ -0,0 +1,46 @@
project (Merge LANGUAGES CXX)
#=====================================
# Sources
#=====================================
set (merge_sources
Factory.cpp
Record.cpp
Merge.cpp
None.cpp
Text.cpp
TextCsv.cpp
TextCsvKeys.cpp
TextTsv.cpp
TextTsvKeys.cpp
TextColon.cpp
TextColonKeys.cpp
TextSemicolon.cpp
TextSemicolonKeys.cpp
)
set (merge_qobject_headers
Merge.h
)
qt5_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
#=====================================
# Target
#=====================================
add_library (Merge STATIC
${merge_sources}
${merge_moc_sources}
)
target_compile_features (Merge
PUBLIC cxx_std_11
)
target_include_directories (Merge
PUBLIC ..
)
target_link_libraries (Merge
Qt5::Core
)
+219
View File
@@ -0,0 +1,219 @@
/* Merge/Factory.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Factory.h"
#include "None.h"
#include "TextCsv.h"
#include "TextCsvKeys.h"
#include "TextTsv.h"
#include "TextTsvKeys.h"
#include "TextColon.h"
#include "TextColonKeys.h"
#include "TextSemicolon.h"
#include "TextSemicolonKeys.h"
namespace glabels::merge
{
//
// Static data
//
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
QStringList Factory::mNameList;
///
/// Constructor
///
Factory::Factory()
{
registerBackend( None::id(),
tr("None"),
NONE,
&None::create );
registerBackend( TextCsv::id(),
tr("Text: Comma Separated Values (CSV)"),
FILE,
&TextCsv::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( TextTsvKeys::id(),
tr("Text: Tab Separated Values (TSV), keys on line 1"),
FILE,
&TextTsvKeys::create );
registerBackend( TextColon::id(),
tr("Text: Colon Separated Values"),
FILE,
&TextColon::create );
registerBackend( TextColonKeys::id(),
tr("Text: Colon Separated Values, keys on line 1"),
FILE,
&TextColonKeys::create );
registerBackend( TextSemicolon::id(),
tr("Text: Semicolon Separated Values"),
FILE,
&TextSemicolon::create );
registerBackend( TextSemicolonKeys::id(),
tr("Text: Semicolon Separated Values, keys on line 1"),
FILE,
&TextSemicolonKeys::create );
}
///
/// Initialize
///
void Factory::init()
{
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;
}
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";
}
///
/// Register backend
///
void Factory::registerBackend( const QString& id,
const QString& name,
SourceType type,
CreateFct create )
{
BackendEntry backend;
backend.id = id;
backend.name = name;
backend.type = type;
backend.create = create;
mBackendIdMap[ id ] = backend;
mBackendNameMap[ name ] = backend;
mNameList << name;
}
} // namespace glabels::merge
+107
View File
@@ -0,0 +1,107 @@
/* Merge/Factory.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Factory_h
#define merge_Factory_h
#include <QCoreApplication>
#include <QStringList>
#include <QMap>
namespace glabels::merge
{
// Forward references
class Merge;
///
/// Factory
///
class Factory
{
Q_DECLARE_TR_FUNCTIONS(Factory)
/////////////////////////////////
// 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;
};
}
#endif // merge_Factory_h
+210
View File
@@ -0,0 +1,210 @@
/* Merge/Merge.cpp
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Merge.h"
#include "Record.h"
namespace glabels::merge
{
///
/// Constructor
///
Merge::Merge()
{
}
///
/// Constructor
///
Merge::Merge( const Merge* merge ) : mSource(merge->mSource)
{
foreach ( Record* record, merge->mRecordList )
{
mRecordList << record->clone();
}
}
///
/// Destructor
///
Merge::~Merge()
{
foreach ( Record* record, mRecordList )
{
delete record;
}
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 )
{
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();
}
}
///
/// Select all records
///
void Merge::selectAll()
{
foreach ( Record* record, mRecordList )
{
record->setSelected( true );
}
emit selectionChanged();
}
///
/// Unselect all records
///
void Merge::unselectAll()
{
foreach ( Record* record, mRecordList )
{
record->setSelected( false );
}
emit selectionChanged();
}
///
/// Return count of selected records
///
int Merge::nSelectedRecords() const
{
int count = 0;
foreach ( Record* record, mRecordList )
{
if ( record->isSelected() )
{
count++;
}
}
return count;
}
///
/// Return list of selected records
///
const QList<Record*> Merge::selectedRecords() const
{
QList<Record*> list;
foreach ( Record* record, mRecordList )
{
if ( record->isSelected() )
{
list.append( record );
}
}
return list;
}
} // namespace glabels::merge
+120
View File
@@ -0,0 +1,120 @@
/* Merge/Merge.h
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Merge_h
#define merge_Merge_h
#include <QObject>
#include <QString>
#include <QStringList>
#include <QList>
namespace glabels::merge
{
// Forward references
class Record;
///
/// Merge Object
///
struct Merge : QObject
{
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();
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();
/////////////////////////////////
// Private data
/////////////////////////////////
protected:
QString mId;
private:
QString mSource;
QList<Record*> mRecordList;
};
}
#endif // merge_Merge_h
+122
View File
@@ -0,0 +1,122 @@
/* Merge/None.cpp
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "None.h"
namespace glabels::merge
{
///
/// Constructor
///
None::None() : Merge()
{
mId = "None";
}
///
/// Constructor
///
None::None( const None* merge ) : Merge( merge )
{
}
///
/// Destructor
///
None::~None()
{
}
///
/// Clone
///
None* None::clone() const
{
return new None( this );
}
///
/// Get ID
///
QString None::id()
{
return "None";
}
///
/// Create
///
Merge* None::create()
{
return new None();
}
///
/// Get key list
///
QStringList None::keys() const
{
QStringList emptyList;
return emptyList;
}
///
/// Get primary key
///
QString None::primaryKey() const
{
return "";
}
///
/// Open source
///
void None::open()
{
}
///
/// Close source
///
void None::close()
{
}
///
/// Read next record
///
Record* None::readNextRecord()
{
return nullptr;
}
} // namespace glabels::merge
@@ -24,10 +24,7 @@
#include "Merge.h" #include "Merge.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -74,7 +71,5 @@ namespace glabels
} }
}
#endif // merge_None_h #endif // merge_None_h
@@ -21,10 +21,7 @@
#include "Record.h" #include "Record.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -70,6 +67,4 @@ namespace glabels
mSelected = value; mSelected = value;
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -26,10 +26,7 @@
#include <QMap> #include <QMap>
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -70,7 +67,5 @@ namespace glabels
} }
}
#endif // merge_Record_h #endif // merge_Record_h
+416
View File
@@ -0,0 +1,416 @@
/* Merge/Text.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Text.h"
#include "Record.h"
#include <QtDebug>
namespace glabels::merge
{
///
/// Constructor
///
Text::Text( QChar delimiter, bool line1HasKeys )
: mDelimeter(delimiter), mLine1HasKeys(line1HasKeys), mNFieldsMax(0)
{
}
///
/// 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++ )
{
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
{
return QString::number( iField+1 );
}
}
///
/// Parse line.
///
/// Attempt to be a robust parser of various CSV (and similar) formats.
///
/// Based on CSV format described in RFC 4180 section 2.
///
/// Additions to RFC 4180 rules:
/// - delimeters and other special characters may be "escaped" by a leading
/// backslash (\)
/// - C escape sequences for newline (\n) and tab (\t) are also translated.
/// - if quoted text is not followed by a delimeter, any additional text is
/// concatenated with quoted portion.
///
/// Returns a list of fields. A blank line is considered a line with one
/// empty field. Returns an empty list when done.
///
QStringList Text::parseLine()
{
QStringList fields;
enum State
{
DELIM, QUOTED, QUOTED_QUOTE1, QUOTED_ESCAPED, SIMPLE, SIMPLE_ESCAPED, DONE
} state = DELIM;
QByteArray field;
while ( state != DONE )
{
char c;
if ( mFile.getChar( &c ) )
{
switch (state)
{
case DELIM:
switch (c)
{
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 )
{
/* field is empty. */
fields << "";
state = DELIM;
}
else
{
/* begining of a simple field. */
field.append( c );
state = SIMPLE;
}
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
{
/* 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:
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
break;
}
}
else
{
/* Handle EOF (could also be an error while reading). */
switch (state)
{
case DELIM:
/* EOF, no more lines. */
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_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_ESCAPED:
/* File ended midway through escaped item. */
fields << QString( field );
break;
default:
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
break;
}
state = DONE;
}
}
return fields;
}
} // namespace glabels::merge
+81
View File
@@ -0,0 +1,81 @@
/* Merge/Text.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Text_h
#define merge_Text_h
#include "Merge.h"
#include <QFile>
namespace glabels::merge
{
///
/// 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;
/////////////////////////////////
// Private methods
/////////////////////////////////
QString keyFromIndex( int iField ) const;
QStringList parseLine();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
QChar mDelimeter;
bool mLine1HasKeys;
QFile mFile;
QStringList mKeys;
int mNFieldsMax;
};
}
#endif // merge_Text_h
@@ -21,11 +21,9 @@
#include "TextColon.h" #include "TextColon.h"
namespace glabels namespace glabels::merge
{ {
namespace merge
{
static const QString ID = "Text/Colon"; static const QString ID = "Text/Colon";
@@ -80,6 +78,4 @@ namespace glabels
return new TextColon(); return new TextColon();
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -25,10 +25,7 @@
#include "Text.h" #include "Text.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -64,7 +61,5 @@ namespace glabels
} }
}
#endif // merge_TextColon_h #endif // merge_TextColon_h
@@ -21,11 +21,9 @@
#include "TextColonKeys.h" #include "TextColonKeys.h"
namespace glabels namespace glabels::merge
{ {
namespace merge
{
static const QString ID = "Text/Colon/Line1Keys"; static const QString ID = "Text/Colon/Line1Keys";
@@ -80,6 +78,4 @@ namespace glabels
return new TextColonKeys(); return new TextColonKeys();
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -25,10 +25,7 @@
#include "Text.h" #include "Text.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -64,7 +61,5 @@ namespace glabels
} }
}
#endif // merge_TextColonKeys_h #endif // merge_TextColonKeys_h
@@ -21,11 +21,9 @@
#include "TextCsv.h" #include "TextCsv.h"
namespace glabels namespace glabels::merge
{ {
namespace merge
{
static const QString ID = "Text/Comma"; static const QString ID = "Text/Comma";
@@ -80,6 +78,4 @@ namespace glabels
return new TextCsv(); return new TextCsv();
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -25,10 +25,7 @@
#include "Text.h" #include "Text.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -64,7 +61,5 @@ namespace glabels
} }
}
#endif // merge_TextCsv_h #endif // merge_TextCsv_h
@@ -21,11 +21,9 @@
#include "TextCsvKeys.h" #include "TextCsvKeys.h"
namespace glabels namespace glabels::merge
{ {
namespace merge
{
static const QString ID = "Text/Comma/Line1Keys"; static const QString ID = "Text/Comma/Line1Keys";
@@ -80,6 +78,4 @@ namespace glabels
return new TextCsvKeys(); return new TextCsvKeys();
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -25,10 +25,7 @@
#include "Text.h" #include "Text.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -64,7 +61,5 @@ namespace glabels
} }
}
#endif // merge_TextCsvKeys_h #endif // merge_TextCsvKeys_h
@@ -21,11 +21,9 @@
#include "TextSemicolon.h" #include "TextSemicolon.h"
namespace glabels namespace glabels::merge
{ {
namespace merge
{
static const QString ID = "Text/Semicolon"; static const QString ID = "Text/Semicolon";
@@ -80,6 +78,4 @@ namespace glabels
return new TextSemicolon(); return new TextSemicolon();
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -25,10 +25,7 @@
#include "Text.h" #include "Text.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -64,7 +61,5 @@ namespace glabels
} }
}
#endif // merge_TextSemicolon_h #endif // merge_TextSemicolon_h
@@ -21,11 +21,9 @@
#include "TextSemicolonKeys.h" #include "TextSemicolonKeys.h"
namespace glabels namespace glabels::merge
{ {
namespace merge
{
static const QString ID = "Text/Semicolon/Keys"; static const QString ID = "Text/Semicolon/Keys";
@@ -80,6 +78,4 @@ namespace glabels
return new TextSemicolonKeys(); return new TextSemicolonKeys();
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -25,10 +25,7 @@
#include "Text.h" #include "Text.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -64,7 +61,5 @@ namespace glabels
} }
}
#endif // merge_TextSemicolonKeys_h #endif // merge_TextSemicolonKeys_h
@@ -21,11 +21,9 @@
#include "TextTsv.h" #include "TextTsv.h"
namespace glabels namespace glabels::merge
{ {
namespace merge
{
static const QString ID = "Text/Tab"; static const QString ID = "Text/Tab";
@@ -80,6 +78,4 @@ namespace glabels
return new TextTsv(); return new TextTsv();
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -25,10 +25,7 @@
#include "Text.h" #include "Text.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -64,7 +61,5 @@ namespace glabels
} }
}
#endif // merge_TextTsv_h #endif // merge_TextTsv_h
@@ -21,11 +21,9 @@
#include "TextTsvKeys.h" #include "TextTsvKeys.h"
namespace glabels namespace glabels::merge
{ {
namespace merge
{
static const QString ID = "Text/Tab/Line1Keys"; static const QString ID = "Text/Tab/Line1Keys";
@@ -80,6 +78,4 @@ namespace glabels
return new TextTsvKeys(); return new TextTsvKeys();
} }
} // namespace merge } // namespace glabels::merge
} // namespace glabels
@@ -25,10 +25,7 @@
#include "Text.h" #include "Text.h"
namespace glabels namespace glabels::merge
{
namespace merge
{ {
/// ///
@@ -64,7 +61,5 @@ namespace glabels
} }
}
#endif // merge_TextTsvKeys_h #endif // merge_TextTsvKeys_h
+26 -5
View File
@@ -2,15 +2,36 @@
# Once done this will define # Once done this will define
# #
# GNUBARCODE_FOUND - System has GNU Barcode # GNUBARCODE_FOUND - System has GNU Barcode
# GNUBARCODE_INCLUDE_DIR - The GNU Barcode include directory # GNUBARCODE_INCLUDE_DIRS - The GNU Barcode include directory
# GNUBARCODE_LIBRARIES - The libraries needed to use GNU Barcode # GNUBARCODE_LIBRARIES - The libraries needed to use GNU Barcode
# GNUBARCODE_DEFINITIONS - Definitions needed to use GNU Barcode
# GNUBARCODE_VERSION_STRING - the version of GNU Barcode found # GNUBARCODE_VERSION_STRING - the version of GNU Barcode found
set (GNUBARCODE_DEFINITIONS "") set (GNUBARCODE_DEFINITIONS "")
find_path (GNUBARCODE_INCLUDE_DIR NAMES barcode.h PATH_SUFFIXES barcode) find_path (GNUBARCODE_INCLUDE_DIR NAMES barcode.h PATH_SUFFIXES barcode)
find_library (GNUBARCODE_LIBRARIES NAMES barcode ) find_library (GNUBARCODE_LIBRARY NAMES barcode )
if (GNUBARCODE_LIBRARY AND GNUBARCODE_INCLUDE_DIR)
set (GNUBARCODE_INCLUDE_DIRS ${GNUBARCODE_INCLUDE_DIR})
set (GNUBARCODE_LIBRARIES ${GNUBARCODE_LIBRARY})
set (GNUBARCODE_DEFINITIONS "")
if (NOT TARGET GNU::BARCODE)
add_library (GNU::BARCODE UNKNOWN IMPORTED)
set_target_properties (GNU::BARCODE PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${GNUBARCODE_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${GNUBARCODE_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${GNUBARCODE_LIBRARY}"
)
endif ()
endif ()
if (GNUBARCODE_INCLUDE_DIR AND EXISTS "${GNUBARCODE_INCLUDE_DIR}/barcode.h") if (GNUBARCODE_INCLUDE_DIR AND EXISTS "${GNUBARCODE_INCLUDE_DIR}/barcode.h")
file (STRINGS "${GNUBARCODE_INCLUDE_DIR}/barcode.h" BARCODE_H REGEX "^#define BARCODE_VERSION *\"[^\"]*\"") file (STRINGS "${GNUBARCODE_INCLUDE_DIR}/barcode.h" BARCODE_H REGEX "^#define BARCODE_VERSION *\"[^\"]*\"")
@@ -20,8 +41,8 @@ endif()
# handle the QUIETLY and REQUIRED arguments and set GNUBARCODE_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set GNUBARCODE_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuBarcode find_package_handle_standard_args(GnuBarcode
REQUIRED_VARS GNUBARCODE_LIBRARIES GNUBARCODE_INCLUDE_DIR REQUIRED_VARS GNUBARCODE_LIBRARY GNUBARCODE_INCLUDE_DIR
VERSION_VAR GNUBARCODE_VERSION_STRING) VERSION_VAR GNUBARCODE_VERSION_STRING)
mark_as_advanced(GNUBARCODE_INCLUDE_DIR GNUBARCODE_LIBRARIES) mark_as_advanced(GNUBARCODE_INCLUDE_DIR GNUBARCODE_LIBRARY)
+25 -5
View File
@@ -2,7 +2,7 @@
# Once done this will define # Once done this will define
# #
# LIBQRENCODE_FOUND - System has LibQrencode # LIBQRENCODE_FOUND - System has LibQrencode
# LIBQRENCODE_INCLUDE_DIR - The LibQrencode include directory # LIBQRENCODE_INCLUDE_DIRS - The LibQrencode include directory
# LIBQRENCODE_LIBRARIES - The libraries needed to use LibQrencode # LIBQRENCODE_LIBRARIES - The libraries needed to use LibQrencode
# LIBQRENCODE_DEFINITIONS - Compiler switches required for using LibQrencode # LIBQRENCODE_DEFINITIONS - Compiler switches required for using LibQrencode
# LIBQRENCODE_VERSION_STRING - the version of LibQrencode found # LIBQRENCODE_VERSION_STRING - the version of LibQrencode found
@@ -19,12 +19,32 @@ find_path(LIBQRENCODE_INCLUDE_DIR NAMES qrencode.h
PATH_SUFFIXES libqrencode PATH_SUFFIXES libqrencode
) )
find_library(LIBQRENCODE_LIBRARIES NAMES qrencode libqrencode find_library(LIBQRENCODE_LIBRARY NAMES qrencode libqrencode
HINTS HINTS
${PC_LIBQRENCODE_LIBDIR} ${PC_LIBQRENCODE_LIBDIR}
${PC_LIBQRENCODE_LIBRARY_DIRS} ${PC_LIBQRENCODE_LIBRARY_DIRS}
) )
if (LIBQRENCODE_LIBRARY AND LIBQRENCODE_INCLUDE_DIR)
set (LIBQRENCODE_INCLUDE_DIRS ${LIBQRENCODE_INCLUDE_DIR})
set (LIBQRENCODE_LIBRARIES ${LIBQRENCODE_LIBRARY})
set (LIBQRENCODE_DEFINITIONS "")
if (NOT TARGET QRENCODE::QRENCODE)
add_library (QRENCODE::QRENCODE UNKNOWN IMPORTED)
set_target_properties (QRENCODE::QRENCODE PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${LIBQRENCODE_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBQRENCODE_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${LIBQRENCODE_LIBRARY}"
)
endif ()
endif ()
if(PC_LIBQRENCODE_VERSION) if(PC_LIBQRENCODE_VERSION)
set(LIBQRENCODE_VERSION_STRING ${PC_LIBQRENCODE_VERSION}) set(LIBQRENCODE_VERSION_STRING ${PC_LIBQRENCODE_VERSION})
endif() endif()
@@ -32,8 +52,8 @@ endif()
# handle the QUIETLY and REQUIRED arguments and set LIBQRENCODE_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set LIBQRENCODE_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibQrencode find_package_handle_standard_args(LibQrencode
REQUIRED_VARS LIBQRENCODE_LIBRARIES LIBQRENCODE_INCLUDE_DIR REQUIRED_VARS LIBQRENCODE_LIBRARY LIBQRENCODE_INCLUDE_DIR
VERSION_VAR LIBQRENCODE_VERSION_STRING) VERSION_VAR LIBQRENCODE_VERSION_STRING)
mark_as_advanced(LIBQRENCODE_INCLUDE_DIR LIBQRENCODE_LIBRARIES) mark_as_advanced(LIBQRENCODE_INCLUDE_DIR LIBQRENCODE_LIBRARY)
+25 -4
View File
@@ -2,8 +2,9 @@
# Once done this will define # Once done this will define
# #
# LIBZINT_FOUND - System has Zint barcode # LIBZINT_FOUND - System has Zint barcode
# LIBZINT_INCLUDE_DIR - The Zint barcode include directory # LIBZINT_INCLUDE_DIRS - The Zint barcode include directory
# LIBZINT_LIBRARIES - The libraries needed to use Zint barcode # LIBZINT_LIBRARIES - The libraries needed to use Zint barcode
# LIBZINT_DEFINITIONS - Definitions needed to use Zint barcode
# LIBZINT_VERSION_STRING - the version of Zint barcode found # LIBZINT_VERSION_STRING - the version of Zint barcode found
set (LIBZINT_DEFINITIONS "") set (LIBZINT_DEFINITIONS "")
@@ -12,6 +13,26 @@ find_path (LIBZINT_INCLUDE_DIR NAMES zint.h)
find_library (LIBZINT_LIBRARIES NAMES zint ) find_library (LIBZINT_LIBRARIES NAMES zint )
if (LIBZINT_LIBRARY AND LIBZINT_INCLUDE_DIR)
set (LIBZINT_INCLUDE_DIRS ${LIBZINT_INCLUDE_DIR})
set (LIBZINT_LIBRARIES ${LIBZINT_LIBRARY})
set (LIBZINT_DEFINITIONS "")
if (NOT TARGET ZINT::ZINT)
add_library (ZINT::ZINT UNKNOWN IMPORTED)
set_target_properties (ZINT::ZINT PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${LIBZINT_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBZINT_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${LIBZINT_LIBRARY}"
)
endif ()
endif ()
if (LIBZINT_INCLUDE_DIR AND EXISTS "${LIBZINT_INCLUDE_DIR}/zint.h") if (LIBZINT_INCLUDE_DIR AND EXISTS "${LIBZINT_INCLUDE_DIR}/zint.h")
file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MAJOR_H REGEX "^#define ZINT_VERSION_MAJOR *[0-9]*") file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MAJOR_H REGEX "^#define ZINT_VERSION_MAJOR *[0-9]*")
file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MINOR_H REGEX "^#define ZINT_VERSION_MINOR *[0-9]*") file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MINOR_H REGEX "^#define ZINT_VERSION_MINOR *[0-9]*")
@@ -25,8 +46,8 @@ endif()
# handle the QUIETLY and REQUIRED arguments and set LIBZINT_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set LIBZINT_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibZint find_package_handle_standard_args(LibZint
REQUIRED_VARS LIBZINT_LIBRARIES LIBZINT_INCLUDE_DIR REQUIRED_VARS LIBZINT_LIBRARY LIBZINT_INCLUDE_DIR
VERSION_VAR LIBZINT_VERSION_STRING) VERSION_VAR LIBZINT_VERSION_STRING)
mark_as_advanced(LIBZINT_INCLUDE_DIR LIBZINT_LIBRARIES) mark_as_advanced(LIBZINT_INCLUDE_DIR LIBZINT_LIBRARY)
+29
View File
@@ -0,0 +1,29 @@
project (glabels-batch LANGUAGES CXX)
#=======================================
# Sources
#=======================================
set (glabels-batch_sources
main.cpp
)
#=====================================
# Target
#=====================================
add_executable (glabels-batch-qt WIN32
${glabels-batch_sources}
)
target_compile_features (glabels-batch-qt
PUBLIC cxx_std_11
)
target_link_libraries (glabels-batch-qt
Model
)
#=======================================
# Install
#=======================================
install (TARGETS glabels-batch-qt RUNTIME DESTINATION bin)
@@ -1,4 +1,4 @@
/* glabels-batch_main.cpp /* main.cpp
* *
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com> * Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
* *
@@ -18,16 +18,16 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>. * along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "BarcodeBackends.h" #include "model/FileUtil.h"
#include "FileUtil.h" #include "model/Db.h"
#include "Db.h" #include "model/Model.h"
#include "LabelModel.h" #include "model/PageRenderer.h"
#include "PageRenderer.h" #include "model/Settings.h"
#include "Settings.h" #include "model/Version.h"
#include "Version.h" #include "model/XmlLabelParser.h"
#include "XmlLabelParser.h"
#include "Merge/Factory.h" #include "barcode/Backends.h"
#include "merge/Factory.h"
#include <QApplication> #include <QApplication>
#include <QCommandLineParser> #include <QCommandLineParser>
@@ -46,14 +46,14 @@ int main( int argc, char **argv )
QCoreApplication::setOrganizationName( "glabels.org" ); QCoreApplication::setOrganizationName( "glabels.org" );
QCoreApplication::setOrganizationDomain( "glabels.org" ); QCoreApplication::setOrganizationDomain( "glabels.org" );
QCoreApplication::setApplicationName( "glabels-batch-qt" ); QCoreApplication::setApplicationName( "glabels-batch-qt" );
QCoreApplication::setApplicationVersion( glabels::Version::STRING ); QCoreApplication::setApplicationVersion( glabels::model::Version::STRING );
// //
// Setup translators // Setup translators
// //
QLocale locale = QLocale::system(); QLocale locale = QLocale::system();
QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath ); QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
QString myTranslationsDir = glabels::FileUtil::translationsDir().canonicalPath(); QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
QTranslator qtTranslator; QTranslator qtTranslator;
if ( qtTranslator.load( locale, "qt", "_", qtTranslationsDir ) ) if ( qtTranslator.load( locale, "qt", "_", qtTranslationsDir ) )
@@ -125,18 +125,18 @@ int main( int argc, char **argv )
// //
// Initialize subsystems // Initialize subsystems
// //
glabels::Settings::init(); glabels::model::Settings::init();
glabels::Db::init(); glabels::model::Db::init();
glabels::merge::Factory::init(); glabels::merge::Factory::init();
glabels::BarcodeBackends::init(); glabels::barcode::Backends::init();
if ( parser.positionalArguments().size() == 1 ) if ( parser.positionalArguments().size() == 1 )
{ {
QString filename = parser.positionalArguments().first(); QString filename = parser.positionalArguments().first();
glabels::LabelModel *label = glabels::XmlLabelParser::readFile( filename ); glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
if ( label ) if ( model )
{ {
QPrinter printer( QPrinter::HighResolution ); QPrinter printer( QPrinter::HighResolution );
printer.setColorMode( QPrinter::Color ); printer.setColorMode( QPrinter::Color );
@@ -155,7 +155,7 @@ int main( int argc, char **argv )
qDebug() << "Batch mode. printer =" << QPrinterInfo::defaultPrinterName(); qDebug() << "Batch mode. printer =" << QPrinterInfo::defaultPrinterName();
} }
glabels::PageRenderer renderer( label ); glabels::model::PageRenderer renderer( model );
renderer.setNCopies( 1 ); renderer.setNCopies( 1 );
renderer.setStartLabel( parser.value( "first" ).toInt() - 1 ); renderer.setStartLabel( parser.value( "first" ).toInt() - 1 );
renderer.setPrintOutlines( parser.isSet( "outlines" ) ); renderer.setPrintOutlines( parser.isSet( "outlines" ) );
+3 -3
View File
@@ -20,7 +20,7 @@
#include "AboutDialog.h" #include "AboutDialog.h"
#include "Version.h" #include "model/Version.h"
#include <QDesktopServices> #include <QDesktopServices>
#include <QUrl> #include <QUrl>
@@ -38,7 +38,7 @@ namespace glabels
{ {
setupUi( this ); setupUi( this );
QString version = tr("Version") + " " + Version::STRING; QString version = tr("Version") + " " + model::Version::STRING;
QString description = tr("A program to create labels and business cards."); QString description = tr("A program to create labels and business cards.");
@@ -81,7 +81,7 @@ namespace glabels
/// ///
void AboutDialog::onWebsiteButtonClicked() void AboutDialog::onWebsiteButtonClicked()
{ {
QDesktopServices::openUrl( QUrl(Version::WEBSITE) ); QDesktopServices::openUrl( QUrl(model::Version::WEBSITE) );
} }
} // namespace glabels } // namespace glabels
-32
View File
@@ -1,32 +0,0 @@
#=======================================
# Sources
#=======================================
set (barcode_sources
GnuBarcode.cpp
QrEncode.cpp
Zint.cpp
)
add_library (Barcode STATIC
${barcode_sources}
)
#=======================================
# Where to find stuff
#=======================================
include_directories (
)
link_directories (
)
#=======================================
# Subdirectories
#=======================================
#=======================================
# Install
#=======================================
+12 -11
View File
@@ -20,9 +20,10 @@
#include "BarcodeMenu.h" #include "BarcodeMenu.h"
#include "BarcodeBackends.h"
#include "BarcodeMenuItem.h" #include "BarcodeMenuItem.h"
#include "barcode/Backends.h"
#include <QtDebug> #include <QtDebug>
@@ -34,29 +35,29 @@ namespace glabels
/// ///
BarcodeMenu::BarcodeMenu() BarcodeMenu::BarcodeMenu()
{ {
foreach ( const BarcodeStyle& bcStyle, BarcodeBackends::styleList() ) foreach ( const barcode::Style& bcStyle, barcode::Backends::styleList() )
{ {
if ( bcStyle.backendId() == "" ) if ( bcStyle.backendId() == "" )
{ {
BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle ); BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle );
connect( bcMenuItem, SIGNAL(activated(const BarcodeStyle&)), connect( bcMenuItem, SIGNAL(activated(const barcode::Style&)),
this, SLOT(onMenuItemActivated(const BarcodeStyle&)) ); this, SLOT(onMenuItemActivated(const barcode::Style&)) );
addAction( bcMenuItem ); addAction( bcMenuItem );
} }
} }
foreach ( const QString& backendId, BarcodeBackends::backendList() ) foreach ( const QString& backendId, barcode::Backends::backendList() )
{ {
QMenu* subMenu = addMenu( BarcodeBackends::backendName( backendId ) ); QMenu* subMenu = addMenu( barcode::Backends::backendName( backendId ) );
foreach ( const BarcodeStyle& bcStyle, BarcodeBackends::styleList() ) foreach ( const barcode::Style& bcStyle, barcode::Backends::styleList() )
{ {
if ( bcStyle.backendId() == backendId ) if ( bcStyle.backendId() == backendId )
{ {
BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle ); BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle );
connect( bcMenuItem, SIGNAL(activated(const BarcodeStyle&)), connect( bcMenuItem, SIGNAL(activated(const barcode::Style&)),
this, SLOT(onMenuItemActivated(const BarcodeStyle&)) ); this, SLOT(onMenuItemActivated(const barcode::Style&)) );
subMenu->addAction( bcMenuItem ); subMenu->addAction( bcMenuItem );
} }
@@ -68,7 +69,7 @@ namespace glabels
/// ///
/// bcStyle getter /// bcStyle getter
/// ///
BarcodeStyle BarcodeMenu::bcStyle() const barcode::Style BarcodeMenu::bcStyle() const
{ {
return mBcStyle; return mBcStyle;
} }
@@ -77,7 +78,7 @@ namespace glabels
/// ///
/// onMenuItemActivated slot /// onMenuItemActivated slot
/// ///
void BarcodeMenu::onMenuItemActivated( const BarcodeStyle& bcStyle ) void BarcodeMenu::onMenuItemActivated( const barcode::Style& bcStyle )
{ {
mBcStyle = bcStyle; mBcStyle = bcStyle;
+4 -4
View File
@@ -22,7 +22,7 @@
#define BarcodeMenu_h #define BarcodeMenu_h
#include "BarcodeStyle.h" #include "barcode/Style.h"
#include <QMenu> #include <QMenu>
@@ -55,21 +55,21 @@ namespace glabels
// Properties // Properties
///////////////////////////////// /////////////////////////////////
public: public:
BarcodeStyle bcStyle() const; barcode::Style bcStyle() const;
///////////////////////////////// /////////////////////////////////
// Slots // Slots
///////////////////////////////// /////////////////////////////////
private slots: private slots:
void onMenuItemActivated( const BarcodeStyle& bcStyle ); void onMenuItemActivated( const barcode::Style& bcStyle );
///////////////////////////////// /////////////////////////////////
// Private Data // Private Data
///////////////////////////////// /////////////////////////////////
private: private:
BarcodeStyle mBcStyle; barcode::Style mBcStyle;
}; };
+5 -4
View File
@@ -20,9 +20,10 @@
#include "BarcodeMenuButton.h" #include "BarcodeMenuButton.h"
#include "BarcodeBackends.h"
#include "BarcodeMenuItem.h" #include "BarcodeMenuItem.h"
#include "barcode/Backends.h"
#include <QtDebug> #include <QtDebug>
@@ -38,7 +39,7 @@ namespace glabels
mMenu = new BarcodeMenu(); mMenu = new BarcodeMenu();
setMenu( mMenu ); setMenu( mMenu );
mBcStyle = BarcodeBackends::defaultStyle(); mBcStyle = barcode::Backends::defaultStyle();
setText( mBcStyle.name() ); setText( mBcStyle.name() );
connect( mMenu, SIGNAL(selectionChanged()), this, SLOT(onMenuSelectionChanged()) ); connect( mMenu, SIGNAL(selectionChanged()), this, SLOT(onMenuSelectionChanged()) );
@@ -48,7 +49,7 @@ namespace glabels
/// ///
/// bcStyle getter /// bcStyle getter
/// ///
BarcodeStyle BarcodeMenuButton::bcStyle() const barcode::Style BarcodeMenuButton::bcStyle() const
{ {
return mBcStyle; return mBcStyle;
} }
@@ -57,7 +58,7 @@ namespace glabels
/// ///
/// bcStyle setter /// bcStyle setter
/// ///
void BarcodeMenuButton::setBcStyle( const BarcodeStyle& bcStyle ) void BarcodeMenuButton::setBcStyle( const barcode::Style& bcStyle )
{ {
mBcStyle = bcStyle; mBcStyle = bcStyle;
setText( mBcStyle.name() ); setText( mBcStyle.name() );
+5 -4
View File
@@ -23,7 +23,8 @@
#include "BarcodeMenu.h" #include "BarcodeMenu.h"
#include "BarcodeStyle.h"
#include "barcode/Style.h"
#include <QPushButton> #include <QPushButton>
@@ -56,8 +57,8 @@ namespace glabels
// Properties // Properties
///////////////////////////////// /////////////////////////////////
public: public:
BarcodeStyle bcStyle() const; barcode::Style bcStyle() const;
void setBcStyle( const BarcodeStyle& bcStyle ); void setBcStyle( const barcode::Style& bcStyle );
///////////////////////////////// /////////////////////////////////
@@ -72,7 +73,7 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
private: private:
BarcodeMenu* mMenu; BarcodeMenu* mMenu;
BarcodeStyle mBcStyle; barcode::Style mBcStyle;
}; };
+2 -2
View File
@@ -29,7 +29,7 @@ namespace glabels
/// ///
/// Constructor From Data /// Constructor From Data
/// ///
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle& bcStyle, QObject* parent ) BarcodeMenuItem::BarcodeMenuItem( const barcode::Style& bcStyle, QObject* parent )
: QAction(parent), mBcStyle(bcStyle) : QAction(parent), mBcStyle(bcStyle)
{ {
setText( bcStyle.name() ); setText( bcStyle.name() );
@@ -41,7 +41,7 @@ namespace glabels
/// ///
/// bcStyle Property Getter /// bcStyle Property Getter
/// ///
BarcodeStyle BarcodeMenuItem::bcStyle() const barcode::Style BarcodeMenuItem::bcStyle() const
{ {
return mBcStyle; return mBcStyle;
} }
+5 -5
View File
@@ -22,7 +22,7 @@
#define BarcodeMenuItem_h #define BarcodeMenuItem_h
#include "BarcodeStyle.h" #include "barcode/Style.h"
#include <QAction> #include <QAction>
@@ -41,21 +41,21 @@ namespace glabels
// Life Cycle // Life Cycle
///////////////////////////////// /////////////////////////////////
public: public:
BarcodeMenuItem( const BarcodeStyle& bcStyle, QObject* parent = nullptr ); BarcodeMenuItem( const barcode::Style& bcStyle, QObject* parent = nullptr );
///////////////////////////////// /////////////////////////////////
// Signals // Signals
///////////////////////////////// /////////////////////////////////
signals: signals:
void activated( const BarcodeStyle& bcStyle ); void activated( const barcode::Style& bcStyle );
///////////////////////////////// /////////////////////////////////
// Properties // Properties
///////////////////////////////// /////////////////////////////////
public: public:
BarcodeStyle bcStyle() const; barcode::Style bcStyle() const;
///////////////////////////////// /////////////////////////////////
@@ -69,7 +69,7 @@ namespace glabels
// Private Data // Private Data
///////////////////////////////// /////////////////////////////////
private: private:
BarcodeStyle mBcStyle; barcode::Style mBcStyle;
}; };
+15 -241
View File
@@ -1,138 +1,45 @@
#======================================= project (glabels LANGUAGES CXX)
# Compilation
#=======================================
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_compile_options (-std=c++11 -g)
if (NOT WIN32)
add_compile_options (-fPIC)
endif ()
# Uncomment to build with pedantic flags
#add_compile_options (-Werror -Wall -Wpedantic)
#add_definitions (-DQT_DISABLE_DEPRECATED_BEFORE=0x050400)
if (${GNUBARCODE_FOUND})
add_definitions (-DHAVE_GNU_BARCODE=1)
else (${GNUBARCODE_FOUND})
set (GNUBARCODE_INCLUDE_DIR "")
set (GNUBARCODE_LIBRARIES "")
endif (${GNUBARCODE_FOUND})
if (${LIBQRENCODE_FOUND})
add_definitions (-DHAVE_QRENCODE=1)
else (${LIBQRENCODE_FOUND})
set (LIBQRENCODE_INCLUDE_DIR "")
set (LIBQRENCODE_LIBRARIES "")
endif (${LIBQRENCODE_FOUND})
if (${LIBZINT_FOUND})
add_definitions (-DHAVE_ZINT=1)
else (${LIBZINT_FOUND})
set (LIBZINT_INCLUDE_DIR "")
set (LIBZINT_LIBRARIES "")
endif (${LIBZINT_FOUND})
#=======================================
# Auto-generate Version.h
#=======================================
configure_file (Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/Version.h @ONLY)
configure_file (Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Config.h @ONLY)
#======================================= #=======================================
# Sources # Sources
#======================================= #=======================================
#
# glabels executable
#
set (glabels_sources set (glabels_sources
glabels_main.cpp main.cpp
AboutDialog.cpp AboutDialog.cpp
BarcodeBackends.cpp
BarcodeMenu.cpp BarcodeMenu.cpp
BarcodeMenuButton.cpp BarcodeMenuButton.cpp
BarcodeMenuItem.cpp BarcodeMenuItem.cpp
BarcodeStyle.cpp
Category.cpp
ColorButton.cpp ColorButton.cpp
ColorHistory.cpp ColorHistory.cpp
ColorNode.cpp
ColorPaletteDialog.cpp ColorPaletteDialog.cpp
ColorPaletteItem.cpp ColorPaletteItem.cpp
ColorPaletteButtonItem.cpp ColorPaletteButtonItem.cpp
ColorSwatch.cpp ColorSwatch.cpp
Cursors.cpp Cursors.cpp
DataCache.cpp
Db.cpp
Distance.cpp
FieldButton.cpp FieldButton.cpp
File.cpp File.cpp
FileUtil.cpp
Frame.cpp
FrameCd.cpp
FrameEllipse.cpp
FrameRect.cpp
FrameRound.cpp
Handles.cpp
Help.cpp Help.cpp
Icons.cpp Icons.cpp
LabelEditor.cpp LabelEditor.cpp
LabelModel.cpp
LabelModelObject.cpp
LabelModelBarcodeObject.cpp
LabelModelBoxObject.cpp
LabelModelEllipseObject.cpp
LabelModelImageObject.cpp
LabelModelLineObject.cpp
LabelModelShapeObject.cpp
LabelModelTextObject.cpp
Layout.cpp
MainWindow.cpp MainWindow.cpp
Markup.cpp
MergeView.cpp MergeView.cpp
MiniPreviewPixmap.cpp MiniPreviewPixmap.cpp
ObjectEditor.cpp ObjectEditor.cpp
Outline.cpp
PageRenderer.cpp
Paper.cpp
Point.cpp
PreferencesDialog.cpp PreferencesDialog.cpp
PrintView.cpp PrintView.cpp
PropertiesView.cpp PropertiesView.cpp
Preview.cpp Preview.cpp
PreviewOverlayItem.cpp PreviewOverlayItem.cpp
RawText.cpp
Region.cpp
SelectProductDialog.cpp SelectProductDialog.cpp
Settings.cpp
SimplePreview.cpp SimplePreview.cpp
Size.cpp
StartupView.cpp StartupView.cpp
StrUtil.cpp
SubstitutionField.cpp
Template.cpp
TemplatePicker.cpp TemplatePicker.cpp
TemplatePickerItem.cpp TemplatePickerItem.cpp
TextNode.cpp
UndoRedoModel.cpp UndoRedoModel.cpp
Units.cpp
Vendor.cpp
XmlCategoryParser.cpp
XmlLabelCreator.cpp
XmlLabelParser.cpp
XmlPaperParser.cpp
XmlTemplateCreator.cpp
XmlTemplateParser.cpp
XmlUtil.cpp
XmlVendorParser.cpp
) )
set (glabels_qobject_headers set (glabels_qobject_headers
AboutDialog.h AboutDialog.h
BarcodeBackends.h
BarcodeMenu.h BarcodeMenu.h
BarcodeMenuButton.h BarcodeMenuButton.h
BarcodeMenuItem.h BarcodeMenuItem.h
@@ -144,25 +51,14 @@ set (glabels_qobject_headers
FieldButton.h FieldButton.h
File.h File.h
LabelEditor.h LabelEditor.h
LabelModel.h
LabelModelObject.h
LabelModelBarcodeObject.h
LabelModelBoxObject.h
LabelModelEllipseObject.h
LabelModelImageObject.h
LabelModelLineObject.h
LabelModelShapeObject.h
LabelModelTextObject.h
MainWindow.h MainWindow.h
MergeView.h MergeView.h
ObjectEditor.h ObjectEditor.h
PageRenderer.h
PreferencesDialog.h PreferencesDialog.h
PrintView.h PrintView.h
PropertiesView.h PropertiesView.h
Preview.h Preview.h
SelectProductDialog.h SelectProductDialog.h
Settings.h
SimplePreview.h SimplePreview.h
StartupView.h StartupView.h
TemplatePicker.h TemplatePicker.h
@@ -195,6 +91,9 @@ if (WIN32)
set (glabels_win_rc glabels.rc) set (glabels_win_rc glabels.rc)
endif () endif ()
#=====================================
# Target
#=====================================
add_executable (glabels-qt WIN32 add_executable (glabels-qt WIN32
${glabels_sources} ${glabels_sources}
${glabels_moc_sources} ${glabels_moc_sources}
@@ -203,144 +102,19 @@ add_executable (glabels-qt WIN32
${glabels_win_rc} ${glabels_win_rc}
) )
target_compile_features (glabels-qt
PUBLIC cxx_std_11
)
target_include_directories (glabels-qt
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries (glabels-qt target_link_libraries (glabels-qt
Barcode Model
Merge Qt5::Widgets
glbarcode
${Qt5Widgets_LIBRARIES}
${Qt5PrintSupport_LIBRARIES}
${Qt5Xml_LIBRARIES}
${Qt5Svg_LIBRARIES}
${ZLIB_LIBRARIES}
${GNUBARCODE_LIBRARIES}
${LIBQRENCODE_LIBRARIES}
${LIBZINT_LIBRARIES}
) )
#
# glabels-batch executable
#
set (glabels-batch_sources
glabels-batch_main.cpp
BarcodeBackends.cpp
BarcodeStyle.cpp
Category.cpp
ColorNode.cpp
DataCache.cpp
Db.cpp
Distance.cpp
FileUtil.cpp
Frame.cpp
FrameCd.cpp
FrameEllipse.cpp
FrameRect.cpp
FrameRound.cpp
Handles.cpp
LabelModel.cpp
LabelModelObject.cpp
LabelModelBarcodeObject.cpp
LabelModelBoxObject.cpp
LabelModelEllipseObject.cpp
LabelModelImageObject.cpp
LabelModelLineObject.cpp
LabelModelShapeObject.cpp
LabelModelTextObject.cpp
Layout.cpp
Markup.cpp
Outline.cpp
PageRenderer.cpp
Paper.cpp
Point.cpp
RawText.cpp
Region.cpp
Settings.cpp
Size.cpp
StrUtil.cpp
SubstitutionField.cpp
Template.cpp
TextNode.cpp
Units.cpp
Vendor.cpp
XmlCategoryParser.cpp
XmlLabelCreator.cpp
XmlLabelParser.cpp
XmlPaperParser.cpp
XmlTemplateCreator.cpp
XmlTemplateParser.cpp
XmlUtil.cpp
XmlVendorParser.cpp
)
set (glabels-batch_qobject_headers
BarcodeBackends.h
LabelModel.h
LabelModelObject.h
LabelModelBarcodeObject.h
LabelModelBoxObject.h
LabelModelEllipseObject.h
LabelModelImageObject.h
LabelModelLineObject.h
LabelModelShapeObject.h
LabelModelTextObject.h
PageRenderer.h
Settings.h
)
qt5_wrap_cpp (glabels-batch_moc_sources ${glabels-batch_qobject_headers})
if (WIN32)
# Windows resource file
set (glabels-batch_win_rc glabels-batch.rc)
endif ()
add_executable (glabels-batch-qt WIN32
${glabels-batch_sources}
${glabels-batch_moc_sources}
${glabels-batch_win_rc}
)
target_link_libraries (glabels-batch-qt
Barcode
Merge
glbarcode
${Qt5PrintSupport_LIBRARIES}
${Qt5Xml_LIBRARIES}
${Qt5Svg_LIBRARIES}
${ZLIB_LIBRARIES}
${GNUBARCODE_LIBRARIES}
${LIBQRENCODE_LIBRARIES}
${LIBZINT_LIBRARIES}
)
#=======================================
# Where to find stuff
#=======================================
include_directories (
${glabels_SOURCE_DIR}
${ZLIB_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5PrintSupport_INCLUDE_DIRS}
${Qt5Xml_INCLUDE_DIRS}
${Qt5Svg_INCLUDE_DIRS}
${GNUBARCODE_INCLUDE_DIR}
${LIBQRENCODE_INCLUDE_DIR}
${LIBZINT_INCLUDE_DIR}
)
link_directories (
)
#=======================================
# Subdirectories
#=======================================
add_subdirectory (BarcodeBackends)
add_subdirectory (Merge)
add_subdirectory (unit_tests)
#======================================= #=======================================
# Install # Install
#======================================= #=======================================
+6 -6
View File
@@ -52,7 +52,7 @@ namespace glabels
const QColor& color ) const QColor& color )
{ {
mDefaultColor = defaultColor; mDefaultColor = defaultColor;
mColorNode = ColorNode( color ); mColorNode = model::ColorNode( color );
setMinimumSize( QSize( 85, 34 ) ); setMinimumSize( QSize( 85, 34 ) );
setIconSize( QSize(SWATCH_W, SWATCH_H) ); setIconSize( QSize(SWATCH_W, SWATCH_H) );
@@ -64,14 +64,14 @@ namespace glabels
mDialog = new ColorPaletteDialog( defaultLabel, defaultColor, color ); mDialog = new ColorPaletteDialog( defaultLabel, defaultColor, color );
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) ); connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
connect( mDialog, SIGNAL(colorChanged(ColorNode,bool)), connect( mDialog, SIGNAL(colorChanged(model::ColorNode,bool)),
this, SLOT(onPaletteDialogChanged(ColorNode,bool)) ); this, SLOT(onPaletteDialogChanged(model::ColorNode,bool)) );
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) ); connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) ); connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
} }
void ColorButton::setColorNode( ColorNode colorNode ) void ColorButton::setColorNode( model::ColorNode colorNode )
{ {
mIsDefault = false; mIsDefault = false;
@@ -118,7 +118,7 @@ namespace glabels
} }
ColorNode ColorButton::colorNode() model::ColorNode ColorButton::colorNode()
{ {
return mColorNode; return mColorNode;
} }
@@ -163,7 +163,7 @@ namespace glabels
} }
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault ) void ColorButton::onPaletteDialogChanged( model::ColorNode colorNode, bool isDefault )
{ {
mColorNode = colorNode; mColorNode = colorNode;
mIsDefault = isDefault; mIsDefault = isDefault;
+6 -5
View File
@@ -22,9 +22,10 @@
#define ColorButton_h #define ColorButton_h
#include "ColorNode.h"
#include "ColorPaletteDialog.h" #include "ColorPaletteDialog.h"
#include "model/ColorNode.h"
#include <QPushButton> #include <QPushButton>
@@ -58,10 +59,10 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
public: public:
void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color ); void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color );
void setColorNode( ColorNode colorNode ); void setColorNode( model::ColorNode colorNode );
void setColor( QColor color ); void setColor( QColor color );
void setToDefault(); void setToDefault();
ColorNode colorNode(); model::ColorNode colorNode();
void setKeys( const QList<QString> keyList ); void setKeys( const QList<QString> keyList );
void clearKeys(); void clearKeys();
@@ -73,7 +74,7 @@ namespace glabels
void onButtonToggled( bool checked ); void onButtonToggled( bool checked );
void onPaletteDialogAccepted(); void onPaletteDialogAccepted();
void onPaletteDialogRejected(); void onPaletteDialogRejected();
void onPaletteDialogChanged( ColorNode colorNode, bool isDefault ); void onPaletteDialogChanged( model::ColorNode colorNode, bool isDefault );
///////////////////////////////// /////////////////////////////////
@@ -88,7 +89,7 @@ namespace glabels
private: private:
QColor mDefaultColor; QColor mDefaultColor;
bool mIsDefault; bool mIsDefault;
ColorNode mColorNode; model::ColorNode mColorNode;
ColorPaletteDialog* mDialog; ColorPaletteDialog* mDialog;
}; };
+3 -3
View File
@@ -90,7 +90,7 @@ namespace glabels
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) ); connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
mDefaultColor = defaultColor; mDefaultColor = defaultColor;
mColorNode = ColorNode( color ); mColorNode = model::ColorNode( color );
setStyleSheet( ".glabels--ColorPaletteDialog {background: white; border: 1px solid black}" ); setStyleSheet( ".glabels--ColorPaletteDialog {background: white; border: 1px solid black}" );
setWindowFlags( Qt::Popup | Qt::FramelessWindowHint ); setWindowFlags( Qt::Popup | Qt::FramelessWindowHint );
@@ -177,7 +177,7 @@ namespace glabels
} }
void ColorPaletteDialog::setColorNode( const ColorNode& colorNode ) void ColorPaletteDialog::setColorNode( const model::ColorNode& colorNode )
{ {
mColorNode = colorNode; mColorNode = colorNode;
} }
@@ -257,7 +257,7 @@ namespace glabels
if ( dlg.exec() ) if ( dlg.exec() )
{ {
ColorNode newColorNode; model::ColorNode newColorNode;
newColorNode.setField( false ); newColorNode.setField( false );
newColorNode.setColor( dlg.currentColor() ); newColorNode.setColor( dlg.currentColor() );
+5 -4
View File
@@ -22,11 +22,12 @@
#define ColorPaletteDialog_h #define ColorPaletteDialog_h
#include "ColorNode.h"
#include "ColorHistory.h" #include "ColorHistory.h"
#include "ColorPaletteItem.h" #include "ColorPaletteItem.h"
#include "ColorPaletteButtonItem.h" #include "ColorPaletteButtonItem.h"
#include "model/ColorNode.h"
#include <QComboBox> #include <QComboBox>
#include <QDialog> #include <QDialog>
@@ -56,14 +57,14 @@ namespace glabels
// Signals // Signals
///////////////////////////////// /////////////////////////////////
signals: signals:
void colorChanged( ColorNode colorNode, bool isDefault ); void colorChanged( model::ColorNode colorNode, bool isDefault );
///////////////////////////////// /////////////////////////////////
// Public Methods // Public Methods
///////////////////////////////// /////////////////////////////////
public: public:
void setColorNode( const ColorNode& colorNode ); void setColorNode( const model::ColorNode& colorNode );
void setKeys( const QStringList& keyList ); void setKeys( const QStringList& keyList );
void clearKeys(); void clearKeys();
@@ -95,7 +96,7 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
private: private:
QColor mDefaultColor; QColor mDefaultColor;
ColorNode mColorNode; model::ColorNode mColorNode;
static const int PALETTE_COLS = ColorHistory::MAX_COLORS; static const int PALETTE_COLS = ColorHistory::MAX_COLORS;
static const int PALETTE_ROWS = 4; static const int PALETTE_ROWS = 4;
-103
View File
@@ -1,103 +0,0 @@
/* Distance.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_Distance_h
#define glabels_Distance_h
#include "Units.h"
#include <QCoreApplication>
#include <QString>
namespace glabels
{
class Distance
{
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 );
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;
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-();
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 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;
};
}
#include "Distance.inl"
#endif // glabels_Distance_h
+21 -20
View File
@@ -20,12 +20,13 @@
#include "File.h" #include "File.h"
#include "FileUtil.h"
#include "LabelModel.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "SelectProductDialog.h" #include "SelectProductDialog.h"
#include "XmlLabelParser.h"
#include "XmlLabelCreator.h" #include "model/FileUtil.h"
#include "model/Model.h"
#include "model/XmlLabelParser.h"
#include "model/XmlLabelCreator.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
@@ -49,26 +50,26 @@ namespace glabels
SelectProductDialog dialog; SelectProductDialog dialog;
dialog.exec(); dialog.exec();
const Template* tmplate = dialog.tmplate(); const model::Template* tmplate = dialog.tmplate();
if ( tmplate ) if ( tmplate )
{ {
LabelModel* label = new LabelModel(); model::Model* model = new model::Model();
label->setTmplate( tmplate ); model->setTmplate( tmplate );
label->clearModified(); model->clearModified();
// Intelligently decide to rotate label by default // Intelligently decide to rotate label by default
const Frame* frame = tmplate->frames().first(); const model::Frame* frame = tmplate->frames().first();
label->setRotate( frame->h() > frame->w() ); model->setRotate( frame->h() > frame->w() );
// Either apply to current window or open a new one // Either apply to current window or open a new one
if ( window->isEmpty() ) if ( window->isEmpty() )
{ {
window->setModel( label ); window->setModel( model );
} }
else else
{ {
MainWindow *newWindow = new MainWindow(); MainWindow *newWindow = new MainWindow();
newWindow->setModel( label ); newWindow->setModel( model );
newWindow->show(); newWindow->show();
} }
@@ -105,20 +106,20 @@ namespace glabels
); );
if ( !fileName.isEmpty() ) if ( !fileName.isEmpty() )
{ {
LabelModel *label = XmlLabelParser::readFile( fileName ); model::Model *model = model::XmlLabelParser::readFile( fileName );
if ( label ) if ( model )
{ {
label->setFileName( fileName ); model->setFileName( fileName );
// Either apply to current window or open a new one // Either apply to current window or open a new one
if ( window->isEmpty() ) if ( window->isEmpty() )
{ {
window->setModel( label ); window->setModel( model );
} }
else else
{ {
MainWindow *newWindow = new MainWindow(); MainWindow *newWindow = new MainWindow();
newWindow->setModel( label ); newWindow->setModel( model );
newWindow->show(); newWindow->show();
} }
@@ -152,7 +153,7 @@ namespace glabels
return true; return true;
} }
XmlLabelCreator::writeFile( window->model(), window->model()->fileName() ); model::XmlLabelCreator::writeFile( window->model(), window->model()->fileName() );
window->model()->clearModified(); window->model()->clearModified();
// Save CWD // Save CWD
@@ -187,7 +188,7 @@ namespace glabels
QFileDialog::DontConfirmOverwrite ); QFileDialog::DontConfirmOverwrite );
if ( !rawFileName.isEmpty() ) if ( !rawFileName.isEmpty() )
{ {
QString fileName = FileUtil::addExtension( rawFileName, ".glabels" ); QString fileName = model::FileUtil::addExtension( rawFileName, ".glabels" );
if ( QFileInfo(fileName).exists() ) if ( QFileInfo(fileName).exists() )
@@ -206,7 +207,7 @@ namespace glabels
} }
} }
XmlLabelCreator::writeFile( window->model(), fileName ); model::XmlLabelCreator::writeFile( window->model(), fileName );
window->model()->setFileName( fileName ); window->model()->setFileName( fileName );
window->model()->clearModified(); window->model()->clearModified();
+83 -82
View File
@@ -21,22 +21,23 @@
#include "LabelEditor.h" #include "LabelEditor.h"
#include "Cursors.h" #include "Cursors.h"
#include "FrameCd.h"
#include "FrameEllipse.h"
#include "FrameRect.h"
#include "FrameRound.h"
#include "LabelModel.h"
#include "LabelModelObject.h"
#include "LabelModelBarcodeObject.h"
#include "LabelModelBoxObject.h"
#include "LabelModelEllipseObject.h"
#include "LabelModelImageObject.h"
#include "LabelModelLineObject.h"
#include "LabelModelTextObject.h"
#include "Markup.h"
#include "Settings.h"
#include "UndoRedoModel.h" #include "UndoRedoModel.h"
#include "model/FrameCd.h"
#include "model/FrameEllipse.h"
#include "model/FrameRect.h"
#include "model/FrameRound.h"
#include "model/Model.h"
#include "model/ModelObject.h"
#include "model/ModelBarcodeObject.h"
#include "model/ModelBoxObject.h"
#include "model/ModelEllipseObject.h"
#include "model/ModelImageObject.h"
#include "model/ModelLineObject.h"
#include "model/ModelTextObject.h"
#include "model/Markup.h"
#include "model/Settings.h"
#include <QMouseEvent> #include <QMouseEvent>
#include <QtMath> #include <QtMath>
#include <QtDebug> #include <QtDebug>
@@ -66,7 +67,7 @@ namespace glabels
const QColor gridLineColor( 192, 192, 192 ); const QColor gridLineColor( 192, 192, 192 );
const double gridLineWidthPixels = 1; const double gridLineWidthPixels = 1;
const Distance gridSpacing = Distance::pt(9); // TODO: determine from locale. const model::Distance gridSpacing = model::Distance::pt(9); // TODO: determine from locale.
const QColor markupLineColor( 240, 99, 99 ); const QColor markupLineColor( 240, 99, 99 );
const double markupLineWidthPixels = 1; const double markupLineWidthPixels = 1;
@@ -94,7 +95,7 @@ namespace glabels
setMouseTracking( true ); setMouseTracking( true );
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
connect( Settings::instance(), SIGNAL(changed()), this, SLOT(onSettingsChanged()) ); connect( model::Settings::instance(), SIGNAL(changed()), this, SLOT(onSettingsChanged()) );
onSettingsChanged(); onSettingsChanged();
} }
@@ -133,7 +134,7 @@ namespace glabels
/// Model Parameter Setter /// Model Parameter Setter
/// ///
void void
LabelEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel ) LabelEditor::setModel( model::Model* model, UndoRedoModel* undoRedoModel )
{ {
mModel = model; mModel = model;
mUndoRedoModel = undoRedoModel; mUndoRedoModel = undoRedoModel;
@@ -246,7 +247,7 @@ namespace glabels
double x_scale = ( wPixels - ZOOM_TO_FIT_PAD ) / mModel->w().pt(); double x_scale = ( wPixels - ZOOM_TO_FIT_PAD ) / mModel->w().pt();
double y_scale = ( hPixels - ZOOM_TO_FIT_PAD ) / mModel->h().pt(); double y_scale = ( hPixels - ZOOM_TO_FIT_PAD ) / mModel->h().pt();
double newZoom = qMin( x_scale, y_scale ) * PTS_PER_INCH / physicalDpiX(); double newZoom = qMin( x_scale, y_scale ) * model::PTS_PER_INCH / physicalDpiX();
// Limits // Limits
newZoom = qMin( newZoom, zoomLevels[0] ); newZoom = qMin( newZoom, zoomLevels[0] );
@@ -286,7 +287,7 @@ namespace glabels
mZoomToFitFlag = zoomToFitFlag; mZoomToFitFlag = zoomToFitFlag;
/* Actual scale depends on DPI of display (assume DpiX == DpiY). */ /* Actual scale depends on DPI of display (assume DpiX == DpiY). */
mScale = zoom * physicalDpiX() / PTS_PER_INCH; mScale = zoom * physicalDpiX() / model::PTS_PER_INCH;
setMinimumSize( mScale*mModel->w().pt() + ZOOM_TO_FIT_PAD, setMinimumSize( mScale*mModel->w().pt() + ZOOM_TO_FIT_PAD,
mScale*mModel->h().pt() + ZOOM_TO_FIT_PAD ); mScale*mModel->h().pt() + ZOOM_TO_FIT_PAD );
@@ -432,8 +433,8 @@ namespace glabels
transform.translate( mX0.pt(), mY0.pt() ); transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->pos() ); QPointF pWorld = transform.inverted().map( event->pos() );
Distance xWorld = Distance::pt( pWorld.x() ); model::Distance xWorld = model::Distance::pt( pWorld.x() );
Distance yWorld = Distance::pt( pWorld.y() ); model::Distance yWorld = model::Distance::pt( pWorld.y() );
if ( event->button() & Qt::LeftButton ) if ( event->button() & Qt::LeftButton )
@@ -446,8 +447,8 @@ namespace glabels
case IdleState: case IdleState:
{ {
LabelModelObject* object = nullptr; model::ModelObject* object = nullptr;
Handle* handle = nullptr; model::Handle* handle = nullptr;
if ( mModel->isSelectionAtomic() && if ( mModel->isSelectionAtomic() &&
(handle = mModel->handleAt( mScale, xWorld, yWorld )) != nullptr ) (handle = mModel->handleAt( mScale, xWorld, yWorld )) != nullptr )
{ {
@@ -521,22 +522,22 @@ namespace glabels
switch ( mCreateObjectType ) switch ( mCreateObjectType )
{ {
case Box: case Box:
mCreateObject = new LabelModelBoxObject(); mCreateObject = new model::ModelBoxObject();
break; break;
case Ellipse: case Ellipse:
mCreateObject = new LabelModelEllipseObject(); mCreateObject = new model::ModelEllipseObject();
break; break;
case Line: case Line:
mCreateObject = new LabelModelLineObject(); mCreateObject = new model::ModelLineObject();
break; break;
case Image: case Image:
mCreateObject = new LabelModelImageObject(); mCreateObject = new model::ModelImageObject();
break; break;
case Text: case Text:
mCreateObject = new LabelModelTextObject(); mCreateObject = new model::ModelTextObject();
break; break;
case Barcode: case Barcode:
mCreateObject = new LabelModelBarcodeObject(); mCreateObject = new model::ModelBarcodeObject();
break; break;
default: default:
qDebug() << "LabelEditor::mousePressEvent: Invalid creation type. Should not happen!"; qDebug() << "LabelEditor::mousePressEvent: Invalid creation type. Should not happen!";
@@ -598,8 +599,8 @@ namespace glabels
transform.translate( mX0.pt(), mY0.pt() ); transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->pos() ); QPointF pWorld = transform.inverted().map( event->pos() );
Distance xWorld = Distance::pt( pWorld.x() ); model::Distance xWorld = model::Distance::pt( pWorld.x() );
Distance yWorld = Distance::pt( pWorld.y() ); model::Distance yWorld = model::Distance::pt( pWorld.y() );
/* /*
@@ -700,8 +701,8 @@ namespace glabels
transform.translate( mX0.pt(), mY0.pt() ); transform.translate( mX0.pt(), mY0.pt() );
QPointF pWorld = transform.inverted().map( event->pos() ); QPointF pWorld = transform.inverted().map( event->pos() );
Distance xWorld = Distance::pt( pWorld.x() ); model::Distance xWorld = model::Distance::pt( pWorld.x() );
Distance yWorld = Distance::pt( pWorld.y() ); model::Distance yWorld = model::Distance::pt( pWorld.y() );
if ( event->button() & Qt::LeftButton ) if ( event->button() & Qt::LeftButton )
@@ -779,11 +780,11 @@ namespace glabels
/// Handle resize motion /// Handle resize motion
/// ///
void void
LabelEditor::handleResizeMotion( const Distance& xWorld, LabelEditor::handleResizeMotion( const model::Distance& xWorld,
const Distance& yWorld ) const model::Distance& yWorld )
{ {
QPointF p( xWorld.pt(), yWorld.pt() ); QPointF p( xWorld.pt(), yWorld.pt() );
Handle::Location location = mResizeHandle->location(); model::Handle::Location location = mResizeHandle->location();
/* /*
* Change point to object relative coordinates * Change point to object relative coordinates
@@ -809,39 +810,39 @@ namespace glabels
double w, h; double w, h;
switch ( location ) switch ( location )
{ {
case Handle::NW: case model::Handle::NW:
w = std::max( x2 - p.x(), 0.0 ); w = std::max( x2 - p.x(), 0.0 );
h = std::max( y2 - p.y(), 0.0 ); h = std::max( y2 - p.y(), 0.0 );
break; break;
case Handle::N: case model::Handle::N:
w = x2 - x1; w = x2 - x1;
h = std::max( y2 - p.y(), 0.0 ); h = std::max( y2 - p.y(), 0.0 );
break; break;
case Handle::NE: case model::Handle::NE:
w = std::max( p.x() - x1, 0.0 ); w = std::max( p.x() - x1, 0.0 );
h = std::max( y2 - p.y(), 0.0 ); h = std::max( y2 - p.y(), 0.0 );
break; break;
case Handle::E: case model::Handle::E:
w = std::max( p.x() - x1, 0.0 ); w = std::max( p.x() - x1, 0.0 );
h = y2 - y1; h = y2 - y1;
break; break;
case Handle::SE: case model::Handle::SE:
w = std::max( p.x() - x1, 0.0 ); w = std::max( p.x() - x1, 0.0 );
h = std::max( p.y() - y1, 0.0 ); h = std::max( p.y() - y1, 0.0 );
break; break;
case Handle::S: case model::Handle::S:
w = x2 - x1; w = x2 - x1;
h = std::max( p.y() - y1, 0.0 ); h = std::max( p.y() - y1, 0.0 );
break; break;
case Handle::SW: case model::Handle::SW:
w = std::max( x2 - p.x(), 0.0 ); w = std::max( x2 - p.x(), 0.0 );
h = std::max( p.y() - y1, 0.0 ); h = std::max( p.y() - y1, 0.0 );
break; break;
case Handle::W: case model::Handle::W:
w = std::max( x2 - p.x(), 0.0 ); w = std::max( x2 - p.x(), 0.0 );
h = y2 - y1; h = y2 - y1;
break; break;
case Handle::P1: case model::Handle::P1:
x1 = p.x(); x1 = p.x();
y1 = p.y(); y1 = p.y();
w = x2 - p.x(); w = x2 - p.x();
@@ -849,7 +850,7 @@ namespace glabels
x0 = x0 + x1; x0 = x0 + x1;
y0 = y0 + y1; y0 = y0 + y1;
break; break;
case Handle::P2: case model::Handle::P2:
w = p.x() - x1; w = p.x() - x1;
h = p.y() - y1; h = p.y() - y1;
x0 = x0 + x1; x0 = x0 + x1;
@@ -862,30 +863,30 @@ namespace glabels
/* /*
* Set size * Set size
*/ */
if ( !(location == Handle::P1) && !(location == Handle::P2) ) if ( !(location == model::Handle::P1) && !(location == model::Handle::P2) )
{ {
if ( mResizeHonorAspect ) if ( mResizeHonorAspect )
{ {
switch ( location ) switch ( location )
{ {
case Handle::E: case model::Handle::E:
case Handle::W: case model::Handle::W:
mResizeObject->setWHonorAspect( Distance::pt(w) ); mResizeObject->setWHonorAspect( model::Distance::pt(w) );
break; break;
case Handle::N: case model::Handle::N:
case Handle::S: case model::Handle::S:
mResizeObject->setHHonorAspect( Distance::pt(h) ); mResizeObject->setHHonorAspect( model::Distance::pt(h) );
break; break;
default: default:
mResizeObject->setSizeHonorAspect( Distance::pt(w), mResizeObject->setSizeHonorAspect( model::Distance::pt(w),
Distance::pt(h) ); model::Distance::pt(h) );
break; break;
} }
} }
else else
{ {
mResizeObject->setSize( Distance::pt(w), mResizeObject->setSize( model::Distance::pt(w),
Distance::pt(h) ); model::Distance::pt(h) );
} }
/* /*
@@ -893,16 +894,16 @@ namespace glabels
*/ */
switch ( location ) switch ( location )
{ {
case Handle::NW: case model::Handle::NW:
x0 += x2 - mResizeObject->w().pt(); x0 += x2 - mResizeObject->w().pt();
y0 += y2 - mResizeObject->h().pt(); y0 += y2 - mResizeObject->h().pt();
break; break;
case Handle::N: case model::Handle::N:
case Handle::NE: case model::Handle::NE:
y0 += y2 - mResizeObject->h().pt(); y0 += y2 - mResizeObject->h().pt();
break; break;
case Handle::W: case model::Handle::W:
case Handle::SW: case model::Handle::SW:
x0 += x2 - mResizeObject->w().pt(); x0 += x2 - mResizeObject->w().pt();
break; break;
default: default:
@@ -911,8 +912,8 @@ namespace glabels
} }
else else
{ {
mResizeObject->setSize( Distance::pt(w), mResizeObject->setSize( model::Distance::pt(w),
Distance::pt(h) ); model::Distance::pt(h) );
} }
/* /*
@@ -921,8 +922,8 @@ namespace glabels
QPointF p0( x0, y0 ); QPointF p0( x0, y0 );
p0 = mResizeObject->matrix().map( p0 ); p0 = mResizeObject->matrix().map( p0 );
p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() ); p0 += QPointF( mResizeObject->x0().pt(), mResizeObject->y0().pt() );
mResizeObject->setPosition( Distance::pt(p0.x()), mResizeObject->setPosition( model::Distance::pt(p0.x()),
Distance::pt(p0.y()) ); model::Distance::pt(p0.y()) );
} }
@@ -938,22 +939,22 @@ namespace glabels
case Qt::Key_Left: case Qt::Key_Left:
mUndoRedoModel->checkpoint( tr("Move") ); mUndoRedoModel->checkpoint( tr("Move") );
mModel->moveSelection( -mStepSize, Distance(0) ); mModel->moveSelection( -mStepSize, model::Distance(0) );
break; break;
case Qt::Key_Up: case Qt::Key_Up:
mUndoRedoModel->checkpoint( tr("Move") ); mUndoRedoModel->checkpoint( tr("Move") );
mModel->moveSelection( Distance(0), -mStepSize ); mModel->moveSelection( model::Distance(0), -mStepSize );
break; break;
case Qt::Key_Right: case Qt::Key_Right:
mUndoRedoModel->checkpoint( tr("Move") ); mUndoRedoModel->checkpoint( tr("Move") );
mModel->moveSelection( mStepSize, Distance(0) ); mModel->moveSelection( mStepSize, model::Distance(0) );
break; break;
case Qt::Key_Down: case Qt::Key_Down:
mUndoRedoModel->checkpoint( tr("Move") ); mUndoRedoModel->checkpoint( tr("Move") );
mModel->moveSelection( Distance(0), mStepSize ); mModel->moveSelection( model::Distance(0), mStepSize );
break; break;
case Qt::Key_Delete: case Qt::Key_Delete:
@@ -1063,11 +1064,11 @@ namespace glabels
{ {
if ( mGridVisible ) if ( mGridVisible )
{ {
Distance w = mModel->frame()->w(); model::Distance w = mModel->frame()->w();
Distance h = mModel->frame()->h(); model::Distance h = mModel->frame()->h();
Distance x0, y0; model::Distance x0, y0;
if ( dynamic_cast<const FrameRect*>( mModel->frame() ) ) if ( dynamic_cast<const model::FrameRect*>( mModel->frame() ) )
{ {
x0 = gridSpacing; x0 = gridSpacing;
y0 = gridSpacing; y0 = gridSpacing;
@@ -1092,12 +1093,12 @@ namespace glabels
pen.setCosmetic( true ); pen.setCosmetic( true );
painter->setPen( pen ); painter->setPen( pen );
for ( Distance x = x0; x < w; x += gridSpacing ) for ( model::Distance x = x0; x < w; x += gridSpacing )
{ {
painter->drawLine( x.pt(), 0, x.pt(), h.pt() ); painter->drawLine( x.pt(), 0, x.pt(), h.pt() );
} }
for ( Distance y = y0; y < h; y += gridSpacing ) for ( model::Distance y = y0; y < h; y += gridSpacing )
{ {
painter->drawLine( 0, y.pt(), w.pt(), y.pt() ); painter->drawLine( 0, y.pt(), w.pt(), y.pt() );
} }
@@ -1129,7 +1130,7 @@ namespace glabels
painter->translate( -mModel->frame()->w().pt(), 0 ); painter->translate( -mModel->frame()->w().pt(), 0 );
} }
foreach( Markup* markup, mModel->frame()->markups() ) foreach( model::Markup* markup, mModel->frame()->markups() )
{ {
painter->drawPath( markup->path() ); painter->drawPath( markup->path() );
} }
@@ -1184,7 +1185,7 @@ namespace glabels
{ {
painter->save(); painter->save();
foreach ( LabelModelObject* object, mModel->objectList() ) foreach ( model::ModelObject* object, mModel->objectList() )
{ {
if ( object->isSelected() ) if ( object->isSelected() )
{ {
@@ -1224,9 +1225,9 @@ namespace glabels
/// ///
void LabelEditor::onSettingsChanged() void LabelEditor::onSettingsChanged()
{ {
Units units = Settings::units(); model::Units units = model::Settings::units();
mStepSize = Distance( units.resolution(), units ); mStepSize = model::Distance( units.resolution(), units );
} }
@@ -1242,7 +1243,7 @@ namespace glabels
double x_scale = ( wPixels - ZOOM_TO_FIT_PAD ) / mModel->w().pt(); double x_scale = ( wPixels - ZOOM_TO_FIT_PAD ) / mModel->w().pt();
double y_scale = ( hPixels - ZOOM_TO_FIT_PAD ) / mModel->h().pt(); double y_scale = ( hPixels - ZOOM_TO_FIT_PAD ) / mModel->h().pt();
double newZoom = qMin( x_scale, y_scale ) * PTS_PER_INCH / physicalDpiX(); double newZoom = qMin( x_scale, y_scale ) * model::PTS_PER_INCH / physicalDpiX();
// Limits // Limits
newZoom = qMin( newZoom, zoomLevels[0] ); newZoom = qMin( newZoom, zoomLevels[0] );
@@ -1252,7 +1253,7 @@ namespace glabels
} }
/* Actual scale depends on DPI of display (assume DpiX == DpiY). */ /* Actual scale depends on DPI of display (assume DpiX == DpiY). */
mScale = mZoom * physicalDpiX() / PTS_PER_INCH; mScale = mZoom * physicalDpiX() / model::PTS_PER_INCH;
setMinimumSize( mScale*mModel->w().pt() + ZOOM_TO_FIT_PAD, setMinimumSize( mScale*mModel->w().pt() + ZOOM_TO_FIT_PAD,
mScale*mModel->h().pt() + ZOOM_TO_FIT_PAD ); mScale*mModel->h().pt() + ZOOM_TO_FIT_PAD );
+20 -20
View File
@@ -22,7 +22,10 @@
#define LabelEditor_h #define LabelEditor_h
#include "Region.h" #include "model/Handles.h"
#include "model/Model.h"
#include "model/ModelObject.h"
#include "model/Region.h"
#include <QPainter> #include <QPainter>
#include <QScrollArea> #include <QScrollArea>
@@ -33,10 +36,7 @@ namespace glabels
{ {
// Forward References // Forward References
class LabelModel;
class LabelModelObject;
class UndoRedoModel; class UndoRedoModel;
class Handle;
/// ///
@@ -59,7 +59,7 @@ namespace glabels
signals: signals:
void contextMenuActivate(); void contextMenuActivate();
void zoomChanged(); void zoomChanged();
void pointerMoved( const Distance& x, const Distance& y ); void pointerMoved( const model::Distance& x, const model::Distance& y );
void pointerExited(); void pointerExited();
void modeChanged(); void modeChanged();
@@ -77,7 +77,7 @@ namespace glabels
// Model // Model
///////////////////////////////////// /////////////////////////////////////
public: public:
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel ); void setModel( model::Model* model, UndoRedoModel* undoRedoModel );
///////////////////////////////////// /////////////////////////////////////
@@ -132,8 +132,8 @@ namespace glabels
// Private methods // Private methods
///////////////////////////////////// /////////////////////////////////////
private: private:
void handleResizeMotion( const Distance& xWorld, void handleResizeMotion( const model::Distance& xWorld,
const Distance& yWorld ); const model::Distance& yWorld );
void drawBgLayer( QPainter* painter ); void drawBgLayer( QPainter* painter );
void drawGridLayer( QPainter* painter ); void drawGridLayer( QPainter* painter );
@@ -179,38 +179,38 @@ namespace glabels
double mZoom; double mZoom;
bool mZoomToFitFlag; bool mZoomToFitFlag;
double mScale; double mScale;
Distance mX0; model::Distance mX0;
Distance mY0; model::Distance mY0;
bool mMarkupVisible; bool mMarkupVisible;
bool mGridVisible; bool mGridVisible;
double mGridSpacing; double mGridSpacing;
Distance mStepSize; model::Distance mStepSize;
LabelModel* mModel; model::Model* mModel;
UndoRedoModel* mUndoRedoModel; UndoRedoModel* mUndoRedoModel;
State mState; State mState;
/* ArrowSelectRegion state */ /* ArrowSelectRegion state */
bool mSelectRegionVisible; bool mSelectRegionVisible;
Region mSelectRegion; model::Region mSelectRegion;
/* ArrowMove state */ /* ArrowMove state */
Distance mMoveLastX; model::Distance mMoveLastX;
Distance mMoveLastY; model::Distance mMoveLastY;
/* ArrowResize state */ /* ArrowResize state */
LabelModelObject* mResizeObject; model::ModelObject* mResizeObject;
Handle* mResizeHandle; model::Handle* mResizeHandle;
bool mResizeHonorAspect; bool mResizeHonorAspect;
/* CreateDrag state */ /* CreateDrag state */
CreateType mCreateObjectType; CreateType mCreateObjectType;
LabelModelObject* mCreateObject; model::ModelObject* mCreateObject;
Distance mCreateX0; model::Distance mCreateX0;
Distance mCreateY0; model::Distance mCreateY0;
}; };
+6 -5
View File
@@ -20,12 +20,10 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "Db.h"
#include "File.h" #include "File.h"
#include "Help.h" #include "Help.h"
#include "Icons.h" #include "Icons.h"
#include "LabelEditor.h" #include "LabelEditor.h"
#include "LabelModel.h"
#include "MergeView.h" #include "MergeView.h"
#include "ObjectEditor.h" #include "ObjectEditor.h"
#include "PreferencesDialog.h" #include "PreferencesDialog.h"
@@ -34,6 +32,9 @@
#include "StartupView.h" #include "StartupView.h"
#include "UndoRedoModel.h" #include "UndoRedoModel.h"
#include "model/Db.h"
#include "model/Model.h"
#include <QClipboard> #include <QClipboard>
#include <QFrame> #include <QFrame>
#include <QMessageBox> #include <QMessageBox>
@@ -151,7 +152,7 @@ namespace glabels
/// ///
/// Get model accessor /// Get model accessor
/// ///
LabelModel* MainWindow::model() const model::Model* MainWindow::model() const
{ {
return mModel; return mModel;
} }
@@ -160,9 +161,9 @@ namespace glabels
/// ///
/// Set model accessor /// Set model accessor
/// ///
void MainWindow::setModel( LabelModel *label ) void MainWindow::setModel( model::Model* model )
{ {
mModel = label; mModel = model;
mUndoRedoModel = new UndoRedoModel( mModel ); mUndoRedoModel = new UndoRedoModel( mModel );
mPropertiesView->setModel( mModel, mUndoRedoModel ); mPropertiesView->setModel( mModel, mUndoRedoModel );
+4 -4
View File
@@ -21,6 +21,7 @@
#ifndef MainWindow_h #ifndef MainWindow_h
#define MainWindow_h #define MainWindow_h
#include <model/Model.h>
#include <QAction> #include <QAction>
#include <QCloseEvent> #include <QCloseEvent>
@@ -39,7 +40,6 @@ namespace glabels
// Forward References // Forward References
class LabelEditor; class LabelEditor;
class LabelModel;
class MergeView; class MergeView;
class ObjectEditor; class ObjectEditor;
class PrintView; class PrintView;
@@ -68,8 +68,8 @@ namespace glabels
// Public Methods // Public Methods
///////////////////////////////////// /////////////////////////////////////
public: public:
LabelModel* model() const; model::Model* model() const;
void setModel( LabelModel* label ); void setModel( model::Model* model );
bool isEmpty() const; bool isEmpty() const;
@@ -209,7 +209,7 @@ namespace glabels
QToolBar* fileToolBar; QToolBar* fileToolBar;
QToolBar* editorToolBar; QToolBar* editorToolBar;
LabelModel* mModel; model::Model* mModel;
UndoRedoModel* mUndoRedoModel; UndoRedoModel* mUndoRedoModel;
QListWidget* mContents; QListWidget* mContents;
-50
View File
@@ -1,50 +0,0 @@
#=======================================
# Sources
#=======================================
set (merge_sources
Factory.cpp
Record.cpp
Merge.cpp
None.cpp
Text.cpp
TextCsv.cpp
TextCsvKeys.cpp
TextTsv.cpp
TextTsvKeys.cpp
TextColon.cpp
TextColonKeys.cpp
TextSemicolon.cpp
TextSemicolonKeys.cpp
)
set (merge_qobject_headers
Merge.h
)
qt5_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
add_library (Merge STATIC
${merge_sources}
${merge_moc_sources}
)
#=======================================
# Where to find stuff
#=======================================
include_directories (
${Qt5Widgets_INCLUDE_DIRS}
)
link_directories (
)
#=======================================
# Subdirectories
#=======================================
#=======================================
# Install
#=======================================
-224
View File
@@ -1,224 +0,0 @@
/* Merge/Factory.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Factory.h"
#include "None.h"
#include "TextCsv.h"
#include "TextCsvKeys.h"
#include "TextTsv.h"
#include "TextTsvKeys.h"
#include "TextColon.h"
#include "TextColonKeys.h"
#include "TextSemicolon.h"
#include "TextSemicolonKeys.h"
namespace glabels
{
namespace merge
{
//
// Static data
//
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
QStringList Factory::mNameList;
///
/// Constructor
///
Factory::Factory()
{
registerBackend( None::id(),
tr("None"),
NONE,
&None::create );
registerBackend( TextCsv::id(),
tr("Text: Comma Separated Values (CSV)"),
FILE,
&TextCsv::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( TextTsvKeys::id(),
tr("Text: Tab Separated Values (TSV), keys on line 1"),
FILE,
&TextTsvKeys::create );
registerBackend( TextColon::id(),
tr("Text: Colon Separated Values"),
FILE,
&TextColon::create );
registerBackend( TextColonKeys::id(),
tr("Text: Colon Separated Values, keys on line 1"),
FILE,
&TextColonKeys::create );
registerBackend( TextSemicolon::id(),
tr("Text: Semicolon Separated Values"),
FILE,
&TextSemicolon::create );
registerBackend( TextSemicolonKeys::id(),
tr("Text: Semicolon Separated Values, keys on line 1"),
FILE,
&TextSemicolonKeys::create );
}
///
/// Initialize
///
void Factory::init()
{
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;
}
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";
}
///
/// Register backend
///
void Factory::registerBackend( const QString& id,
const QString& name,
SourceType type,
CreateFct create )
{
BackendEntry backend;
backend.id = id;
backend.name = name;
backend.type = type;
backend.create = create;
mBackendIdMap[ id ] = backend;
mBackendNameMap[ name ] = backend;
mNameList << name;
}
} // namespace merge
} // namespace glabels
-112
View File
@@ -1,112 +0,0 @@
/* Merge/Factory.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Factory_h
#define merge_Factory_h
#include <QCoreApplication>
#include <QStringList>
#include <QMap>
namespace glabels
{
namespace merge
{
// Forward references
class Merge;
///
/// Factory
///
class Factory
{
Q_DECLARE_TR_FUNCTIONS(Factory)
/////////////////////////////////
// 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;
};
}
}
#endif // merge_Factory_h
-215
View File
@@ -1,215 +0,0 @@
/* Merge/Merge.cpp
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Merge.h"
#include "Record.h"
namespace glabels
{
namespace merge
{
///
/// Constructor
///
Merge::Merge()
{
}
///
/// Constructor
///
Merge::Merge( const Merge* merge ) : mSource(merge->mSource)
{
foreach ( Record* record, merge->mRecordList )
{
mRecordList << record->clone();
}
}
///
/// Destructor
///
Merge::~Merge()
{
foreach ( Record* record, mRecordList )
{
delete record;
}
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 )
{
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();
}
}
///
/// Select all records
///
void Merge::selectAll()
{
foreach ( Record* record, mRecordList )
{
record->setSelected( true );
}
emit selectionChanged();
}
///
/// Unselect all records
///
void Merge::unselectAll()
{
foreach ( Record* record, mRecordList )
{
record->setSelected( false );
}
emit selectionChanged();
}
///
/// Return count of selected records
///
int Merge::nSelectedRecords() const
{
int count = 0;
foreach ( Record* record, mRecordList )
{
if ( record->isSelected() )
{
count++;
}
}
return count;
}
///
/// Return list of selected records
///
const QList<Record*> Merge::selectedRecords() const
{
QList<Record*> list;
foreach ( Record* record, mRecordList )
{
if ( record->isSelected() )
{
list.append( record );
}
}
return list;
}
} // namespace merge
} // namespace glabels
-125
View File
@@ -1,125 +0,0 @@
/* Merge/Merge.h
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Merge_h
#define merge_Merge_h
#include <QObject>
#include <QString>
#include <QStringList>
#include <QList>
namespace glabels
{
namespace merge
{
// Forward references
class Record;
///
/// Merge Object
///
struct Merge : QObject
{
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();
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();
/////////////////////////////////
// Private data
/////////////////////////////////
protected:
QString mId;
private:
QString mSource;
QList<Record*> mRecordList;
};
}
}
#endif // merge_Merge_h
-127
View File
@@ -1,127 +0,0 @@
/* Merge/None.cpp
*
* Copyright (C) 2015-2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "None.h"
namespace glabels
{
namespace merge
{
///
/// Constructor
///
None::None() : Merge()
{
mId = "None";
}
///
/// Constructor
///
None::None( const None* merge ) : Merge( merge )
{
}
///
/// Destructor
///
None::~None()
{
}
///
/// Clone
///
None* None::clone() const
{
return new None( this );
}
///
/// Get ID
///
QString None::id()
{
return "None";
}
///
/// Create
///
Merge* None::create()
{
return new None();
}
///
/// Get key list
///
QStringList None::keys() const
{
QStringList emptyList;
return emptyList;
}
///
/// Get primary key
///
QString None::primaryKey() const
{
return "";
}
///
/// Open source
///
void None::open()
{
}
///
/// Close source
///
void None::close()
{
}
///
/// Read next record
///
Record* None::readNextRecord()
{
return nullptr;
}
} // namespace merge
} // namespace glabels
-421
View File
@@ -1,421 +0,0 @@
/* Merge/Text.cpp
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Text.h"
#include "Record.h"
#include <QtDebug>
namespace glabels
{
namespace merge
{
///
/// Constructor
///
Text::Text( QChar delimiter, bool line1HasKeys )
: mDelimeter(delimiter), mLine1HasKeys(line1HasKeys), mNFieldsMax(0)
{
}
///
/// 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++ )
{
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
{
return QString::number( iField+1 );
}
}
///
/// Parse line.
///
/// Attempt to be a robust parser of various CSV (and similar) formats.
///
/// Based on CSV format described in RFC 4180 section 2.
///
/// Additions to RFC 4180 rules:
/// - delimeters and other special characters may be "escaped" by a leading
/// backslash (\)
/// - C escape sequences for newline (\n) and tab (\t) are also translated.
/// - if quoted text is not followed by a delimeter, any additional text is
/// concatenated with quoted portion.
///
/// Returns a list of fields. A blank line is considered a line with one
/// empty field. Returns an empty list when done.
///
QStringList Text::parseLine()
{
QStringList fields;
enum State
{
DELIM, QUOTED, QUOTED_QUOTE1, QUOTED_ESCAPED, SIMPLE, SIMPLE_ESCAPED, DONE
} state = DELIM;
QByteArray field;
while ( state != DONE )
{
char c;
if ( mFile.getChar( &c ) )
{
switch (state)
{
case DELIM:
switch (c)
{
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 )
{
/* field is empty. */
fields << "";
state = DELIM;
}
else
{
/* begining of a simple field. */
field.append( c );
state = SIMPLE;
}
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
{
/* 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:
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
break;
}
}
else
{
/* Handle EOF (could also be an error while reading). */
switch (state)
{
case DELIM:
/* EOF, no more lines. */
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_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_ESCAPED:
/* File ended midway through escaped item. */
fields << QString( field );
break;
default:
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
break;
}
state = DONE;
}
}
return fields;
}
} // namespace merge
} // namespace glabels
-86
View File
@@ -1,86 +0,0 @@
/* Merge/Text.h
*
* Copyright (C) 2016 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef merge_Text_h
#define merge_Text_h
#include "Merge.h"
#include <QFile>
namespace glabels
{
namespace merge
{
///
/// 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;
/////////////////////////////////
// Private methods
/////////////////////////////////
QString keyFromIndex( int iField ) const;
QStringList parseLine();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
QChar mDelimeter;
bool mLine1HasKeys;
QFile mFile;
QStringList mKeys;
int mNFieldsMax;
};
}
}
#endif // merge_Text_h
+2 -4
View File
@@ -20,9 +20,7 @@
#include "MergeView.h" #include "MergeView.h"
#include "LabelModel.h" #include "merge/Factory.h"
#include "Merge/Factory.h"
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
@@ -59,7 +57,7 @@ namespace glabels
/// ///
/// Set Model /// Set Model
/// ///
void MergeView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel ) void MergeView::setModel( model::Model* model, UndoRedoModel* undoRedoModel )
{ {
mModel = model; mModel = model;
mUndoRedoModel = undoRedoModel; mUndoRedoModel = undoRedoModel;
+5 -4
View File
@@ -24,14 +24,15 @@
#include "ui_MergeView.h" #include "ui_MergeView.h"
#include "Merge/Merge.h" #include "model/Model.h"
#include "merge/Merge.h"
namespace glabels namespace glabels
{ {
// Forward references // Forward references
class LabelModel;
class UndoRedoModel; class UndoRedoModel;
@@ -54,7 +55,7 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
// Public methods // Public methods
///////////////////////////////// /////////////////////////////////
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel ); void setModel( model::Model* model, UndoRedoModel* undoRedoModel );
///////////////////////////////// /////////////////////////////////
@@ -86,7 +87,7 @@ namespace glabels
private: private:
QStringList mMergeFormatNames; QStringList mMergeFormatNames;
LabelModel* mModel; model::Model* mModel;
UndoRedoModel* mUndoRedoModel; UndoRedoModel* mUndoRedoModel;
QStringList mKeys; QStringList mKeys;
+11 -11
View File
@@ -20,7 +20,7 @@
#include "MiniPreviewPixmap.h" #include "MiniPreviewPixmap.h"
#include "Template.h" #include "model/Template.h"
namespace glabels namespace glabels
@@ -47,14 +47,14 @@ namespace glabels
} }
MiniPreviewPixmap::MiniPreviewPixmap( const Template* tmplate, int width, int height ) MiniPreviewPixmap::MiniPreviewPixmap( const model::Template* tmplate, int width, int height )
: QPixmap( width, height ) : QPixmap( width, height )
{ {
draw( tmplate, width, height ); draw( tmplate, width, height );
} }
void MiniPreviewPixmap::draw( const Template* tmplate, int width, int height ) void MiniPreviewPixmap::draw( const model::Template* tmplate, int width, int height )
{ {
fill( Qt::transparent ); fill( Qt::transparent );
@@ -76,8 +76,8 @@ namespace glabels
} }
painter.scale( scale, scale ); painter.scale( scale, scale );
Distance xOffset = ( Distance::pt(width/scale) - tmplate->pageWidth() ) / 2; model::Distance xOffset = ( model::Distance::pt(width/scale) - tmplate->pageWidth() ) / 2;
Distance yOffset = ( Distance::pt(height/scale) - tmplate->pageHeight() ) / 2; model::Distance yOffset = ( model::Distance::pt(height/scale) - tmplate->pageHeight() ) / 2;
painter.translate( xOffset.pt(), yOffset.pt() ); painter.translate( xOffset.pt(), yOffset.pt() );
drawPaper( painter, tmplate, scale ); drawPaper( painter, tmplate, scale );
@@ -85,7 +85,7 @@ namespace glabels
} }
void MiniPreviewPixmap::drawPaper( QPainter& painter, const Template* tmplate, double scale ) void MiniPreviewPixmap::drawPaper( QPainter& painter, const model::Template* tmplate, double scale )
{ {
QBrush brush( paperColor ); QBrush brush( paperColor );
QPen pen( paperOutlineColor ); QPen pen( paperOutlineColor );
@@ -101,7 +101,7 @@ namespace glabels
} }
void MiniPreviewPixmap::drawLabelOutlines( QPainter& painter, const Template* tmplate, double scale ) void MiniPreviewPixmap::drawLabelOutlines( QPainter& painter, const model::Template* tmplate, double scale )
{ {
QBrush brush( labelColor ); QBrush brush( labelColor );
QPen pen( labelOutlineColor ); QPen pen( labelOutlineColor );
@@ -112,10 +112,10 @@ namespace glabels
painter.setBrush( brush ); painter.setBrush( brush );
painter.setPen( pen ); painter.setPen( pen );
Frame *frame = tmplate->frames().first(); model::Frame *frame = tmplate->frames().first();
QVector<Point> origins = frame->getOrigins(); QVector<model::Point> origins = frame->getOrigins();
foreach ( Point p0, origins ) foreach ( model::Point p0, origins )
{ {
drawLabelOutline( painter, frame, p0 ); drawLabelOutline( painter, frame, p0 );
} }
@@ -124,7 +124,7 @@ namespace glabels
} }
void MiniPreviewPixmap::drawLabelOutline( QPainter& painter, const Frame* frame, const Point& p0 ) void MiniPreviewPixmap::drawLabelOutline( QPainter& painter, const model::Frame* frame, const model::Point& p0 )
{ {
painter.save(); painter.save();
+8 -11
View File
@@ -22,7 +22,9 @@
#define glabels_MiniPreviewPixmap_h #define glabels_MiniPreviewPixmap_h
#include "Point.h" #include "model/Frame.h"
#include "model/Point.h"
#include "model/Template.h"
#include <QPixmap> #include <QPixmap>
#include <QPainter> #include <QPainter>
@@ -31,25 +33,20 @@
namespace glabels namespace glabels
{ {
// Forward references
class Template;
class Frame;
class MiniPreviewPixmap : public QPixmap class MiniPreviewPixmap : public QPixmap
{ {
public: public:
MiniPreviewPixmap(); MiniPreviewPixmap();
MiniPreviewPixmap( const Template* tmplate, int width, int height ); MiniPreviewPixmap( const model::Template* tmplate, int width, int height );
private: private:
void draw( const Template* tmplate, int width, int height ); void draw( const model::Template* tmplate, int width, int height );
void drawPaper( QPainter& painter, const Template* tmplate, double scale ); void drawPaper( QPainter& painter, const model::Template* tmplate, double scale );
void drawLabelOutlines( QPainter& painter, const Template* tmplate, double scale ); void drawLabelOutlines( QPainter& painter, const model::Template* tmplate, double scale );
void drawLabelOutline( QPainter& painter, const Frame *frame, const Point& point0 ); void drawLabelOutline( QPainter& painter, const model::Frame *frame, const model::Point& point0 );
}; };
+36 -35
View File
@@ -20,19 +20,20 @@
#include "ObjectEditor.h" #include "ObjectEditor.h"
#include "LabelModel.h"
#include "LabelModelObject.h"
#include "LabelModelBarcodeObject.h"
#include "LabelModelBoxObject.h"
#include "LabelModelEllipseObject.h"
#include "LabelModelImageObject.h"
#include "LabelModelLineObject.h"
#include "LabelModelTextObject.h"
#include "Settings.h"
#include "Size.h"
#include "UndoRedoModel.h" #include "UndoRedoModel.h"
#include "Merge/Merge.h" #include "model/Model.h"
#include "model/ModelObject.h"
#include "model/ModelBarcodeObject.h"
#include "model/ModelBoxObject.h"
#include "model/ModelEllipseObject.h"
#include "model/ModelImageObject.h"
#include "model/ModelLineObject.h"
#include "model/ModelTextObject.h"
#include "model/Settings.h"
#include "model/Size.h"
#include "merge/Merge.h"
#include <QFileDialog> #include <QFileDialog>
#include <QtMath> #include <QtMath>
@@ -73,14 +74,14 @@ namespace glabels
setEnabled( false ); setEnabled( false );
hidePages(); hidePages();
connect( Settings::instance(), SIGNAL(changed()), connect( model::Settings::instance(), SIGNAL(changed()),
this, SLOT(onSettingsChanged()) ); this, SLOT(onSettingsChanged()) );
onSettingsChanged(); onSettingsChanged();
} }
void ObjectEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel ) void ObjectEditor::setModel( model::Model* model, UndoRedoModel* undoRedoModel )
{ {
mModel = model; mModel = model;
mUndoRedoModel = undoRedoModel; mUndoRedoModel = undoRedoModel;
@@ -117,7 +118,7 @@ namespace glabels
{ {
mBlocked = true; mBlocked = true;
TextNode filenameNode = mObject->filenameNode(); model::TextNode filenameNode = mObject->filenameNode();
if ( filenameNode.isField() ) if ( filenameNode.isField() )
{ {
@@ -188,7 +189,7 @@ namespace glabels
sizeWSpin->setValue( mObject->w().inUnits(mUnits) ); sizeWSpin->setValue( mObject->w().inUnits(mUnits) );
sizeHSpin->setValue( mObject->h().inUnits(mUnits) ); sizeHSpin->setValue( mObject->h().inUnits(mUnits) );
Size originalSize = mObject->naturalSize(); model::Size originalSize = mObject->naturalSize();
QString originalSizeString = QString( "%1: %2 x %3 %4" ) QString originalSizeString = QString( "%1: %2 x %3 %4" )
.arg( tr("Original size") ) .arg( tr("Original size") )
.arg( originalSize.w().inUnits(mUnits), 0, 'f', mSpinDigits ) .arg( originalSize.w().inUnits(mUnits), 0, 'f', mSpinDigits )
@@ -249,7 +250,7 @@ namespace glabels
{ {
mBlocked = true; mBlocked = true;
BarcodeStyle bcStyle = mObject->bcStyle(); barcode::Style bcStyle = mObject->bcStyle();
barcodeShowTextCheck->setEnabled( bcStyle.textOptional() ); barcodeShowTextCheck->setEnabled( bcStyle.textOptional() );
barcodeChecksumCheck->setEnabled( bcStyle.checksumOptional() ); barcodeChecksumCheck->setEnabled( bcStyle.checksumOptional() );
@@ -302,7 +303,7 @@ namespace glabels
void ObjectEditor::onSettingsChanged() void ObjectEditor::onSettingsChanged()
{ {
mUnits = Settings::units(); mUnits = model::Settings::units();
mSpinDigits = mUnits.resolutionDigits(); mSpinDigits = mUnits.resolutionDigits();
mSpinStep = mUnits.resolution(); mSpinStep = mUnits.resolution();
@@ -318,7 +319,7 @@ namespace glabels
{ {
mBlocked = true; mBlocked = true;
Distance whMax = std::max( mModel->w(), mModel->h() ); model::Distance whMax = std::max( mModel->w(), mModel->h() );
posXSpin->setRange( -whMax.inUnits(mUnits), 2*whMax.inUnits(mUnits) ); posXSpin->setRange( -whMax.inUnits(mUnits), 2*whMax.inUnits(mUnits) );
posYSpin->setRange( -whMax.inUnits(mUnits), 2*whMax.inUnits(mUnits) ); posYSpin->setRange( -whMax.inUnits(mUnits), 2*whMax.inUnits(mUnits) );
@@ -345,7 +346,7 @@ namespace glabels
{ {
mObject = mModel->getFirstSelectedObject(); mObject = mModel->getFirstSelectedObject();
if ( dynamic_cast<LabelModelBoxObject*>(mObject) ) if ( dynamic_cast<model::ModelBoxObject*>(mObject) )
{ {
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-box.svg") ); titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-box.svg") );
titleLabel->setText( tr("Box object properties") ); titleLabel->setText( tr("Box object properties") );
@@ -366,7 +367,7 @@ namespace glabels
setEnabled( true ); setEnabled( true );
} }
else if ( dynamic_cast<LabelModelEllipseObject*>(mObject) ) else if ( dynamic_cast<model::ModelEllipseObject*>(mObject) )
{ {
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-ellipse.svg") ); titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-ellipse.svg") );
titleLabel->setText( tr("Ellipse object properties") ); titleLabel->setText( tr("Ellipse object properties") );
@@ -387,7 +388,7 @@ namespace glabels
setEnabled( true ); setEnabled( true );
} }
else if ( dynamic_cast<LabelModelImageObject*>(mObject) ) else if ( dynamic_cast<model::ModelImageObject*>(mObject) )
{ {
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-image.svg") ); titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-image.svg") );
titleLabel->setText( tr("Image object properties") ); titleLabel->setText( tr("Image object properties") );
@@ -407,7 +408,7 @@ namespace glabels
setEnabled( true ); setEnabled( true );
} }
else if ( dynamic_cast<LabelModelLineObject*>(mObject) ) else if ( dynamic_cast<model::ModelLineObject*>(mObject) )
{ {
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-line.svg") ); titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-line.svg") );
titleLabel->setText( tr("Line object properties") ); titleLabel->setText( tr("Line object properties") );
@@ -428,7 +429,7 @@ namespace glabels
setEnabled( true ); setEnabled( true );
} }
else if ( dynamic_cast<LabelModelTextObject*>(mObject) ) else if ( dynamic_cast<model::ModelTextObject*>(mObject) )
{ {
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-text.svg") ); titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-text.svg") );
titleLabel->setText( tr("Text object properties") ); titleLabel->setText( tr("Text object properties") );
@@ -447,7 +448,7 @@ namespace glabels
setEnabled( true ); setEnabled( true );
} }
else if ( dynamic_cast<LabelModelBarcodeObject*>(mObject) ) else if ( dynamic_cast<model::ModelBarcodeObject*>(mObject) )
{ {
titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-barcode.svg") ); titleImageLabel->setPixmap( QPixmap(":icons/24x24/actions/glabels-barcode.svg") );
titleLabel->setText( tr("Barcode object properties") ); titleLabel->setText( tr("Barcode object properties") );
@@ -537,7 +538,7 @@ namespace glabels
mUndoRedoModel->checkpoint( tr("Line") ); mUndoRedoModel->checkpoint( tr("Line") );
mObject->setLineWidth( Distance::pt(lineWidthSpin->value()) ); mObject->setLineWidth( model::Distance::pt(lineWidthSpin->value()) );
mObject->setLineColorNode( lineColorButton->colorNode() ); mObject->setLineColorNode( lineColorButton->colorNode() );
mBlocked = false; mBlocked = false;
@@ -595,7 +596,7 @@ namespace glabels
if ( !filename.isEmpty() ) if ( !filename.isEmpty() )
{ {
mUndoRedoModel->checkpoint( tr("Set image") ); mUndoRedoModel->checkpoint( tr("Set image") );
mObject->setFilenameNode( TextNode( false, filename ) ); mObject->setFilenameNode( model::TextNode( false, filename ) );
// Save CWD for next open // Save CWD for next open
QFileInfo fileInfo( filename ); QFileInfo fileInfo( filename );
@@ -607,7 +608,7 @@ namespace glabels
void ObjectEditor::onImageKeySelected( QString key ) void ObjectEditor::onImageKeySelected( QString key )
{ {
mUndoRedoModel->checkpoint( tr("Set image") ); mUndoRedoModel->checkpoint( tr("Set image") );
mObject->setFilenameNode( TextNode( true, key ) ); mObject->setFilenameNode( model::TextNode( true, key ) );
} }
@@ -619,8 +620,8 @@ namespace glabels
mUndoRedoModel->checkpoint( tr("Move") ); mUndoRedoModel->checkpoint( tr("Move") );
Distance x = Distance(posXSpin->value(), mUnits); model::Distance x = model::Distance(posXSpin->value(), mUnits);
Distance y = Distance(posYSpin->value(), mUnits); model::Distance y = model::Distance(posYSpin->value(), mUnits);
mObject->setPosition( x, y ); mObject->setPosition( x, y );
@@ -637,8 +638,8 @@ namespace glabels
mUndoRedoModel->checkpoint( tr("Size") ); mUndoRedoModel->checkpoint( tr("Size") );
Distance spinW = Distance(sizeWSpin->value(), mUnits); model::Distance spinW = model::Distance(sizeWSpin->value(), mUnits);
Distance spinH = Distance(sizeHSpin->value(), mUnits); model::Distance spinH = model::Distance(sizeHSpin->value(), mUnits);
if ( sizeAspectCheck->isChecked() ) if ( sizeAspectCheck->isChecked() )
{ {
@@ -671,7 +672,7 @@ namespace glabels
mUndoRedoModel->checkpoint( tr("Size") ); mUndoRedoModel->checkpoint( tr("Size") );
Distance spinLength = Distance(sizeLineLengthSpin->value(), mUnits); model::Distance spinLength = model::Distance(sizeLineLengthSpin->value(), mUnits);
double spinAngleRads = qDegreesToRadians( sizeLineAngleSpin->value() ); double spinAngleRads = qDegreesToRadians( sizeLineAngleSpin->value() );
mObject->setSize( spinLength*qCos(spinAngleRads), mObject->setSize( spinLength*qCos(spinAngleRads),
@@ -718,7 +719,7 @@ namespace glabels
{ {
mBlocked = true; mBlocked = true;
BarcodeStyle bcStyle = barcodeStyleButton->bcStyle(); barcode::Style bcStyle = barcodeStyleButton->bcStyle();
barcodeShowTextCheck->setEnabled( bcStyle.textOptional() ); barcodeShowTextCheck->setEnabled( bcStyle.textOptional() );
barcodeChecksumCheck->setEnabled( bcStyle.checksumOptional() ); barcodeChecksumCheck->setEnabled( bcStyle.checksumOptional() );
@@ -765,8 +766,8 @@ namespace glabels
mUndoRedoModel->checkpoint( tr("Shadow") ); mUndoRedoModel->checkpoint( tr("Shadow") );
mObject->setShadow( shadowEnableCheck->isChecked() ); mObject->setShadow( shadowEnableCheck->isChecked() );
mObject->setShadowX( Distance(shadowXSpin->value(), mUnits) ); mObject->setShadowX( model::Distance(shadowXSpin->value(), mUnits) );
mObject->setShadowY( Distance(shadowYSpin->value(), mUnits) ); mObject->setShadowY( model::Distance(shadowYSpin->value(), mUnits) );
mObject->setShadowColorNode( shadowColorButton->colorNode() ); mObject->setShadowColorNode( shadowColorButton->colorNode() );
mObject->setShadowOpacity( shadowOpacitySpin->value()/100.0 ); mObject->setShadowOpacity( shadowOpacitySpin->value()/100.0 );
+6 -7
View File
@@ -24,7 +24,8 @@
#include "ui_ObjectEditor.h" #include "ui_ObjectEditor.h"
#include "Distance.h" #include "model/Model.h"
#include "model/ModelObject.h"
#include <QButtonGroup> #include <QButtonGroup>
@@ -33,8 +34,6 @@ namespace glabels
{ {
// Forward references // Forward references
class LabelModel;
class LabelModelObject;
class UndoRedoModel; class UndoRedoModel;
@@ -56,7 +55,7 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
// Public methods // Public methods
///////////////////////////////// /////////////////////////////////
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel ); void setModel( model::Model* model, UndoRedoModel* undoRedoModel );
///////////////////////////////// /////////////////////////////////
@@ -105,11 +104,11 @@ namespace glabels
// Private data // Private data
///////////////////////////////// /////////////////////////////////
private: private:
LabelModel* mModel; model::Model* mModel;
LabelModelObject* mObject; model::ModelObject* mObject;
UndoRedoModel* mUndoRedoModel; UndoRedoModel* mUndoRedoModel;
Units mUnits; model::Units mUnits;
int mSpinDigits; int mSpinDigits;
double mSpinStep; double mSpinStep;
+11 -11
View File
@@ -20,7 +20,7 @@
#include "PreferencesDialog.h" #include "PreferencesDialog.h"
#include "Settings.h" #include "model/Settings.h"
namespace glabels namespace glabels
@@ -34,18 +34,18 @@ namespace glabels
{ {
setupUi( this ); setupUi( this );
switch ( Settings::units().toEnum() ) switch ( model::Settings::units().toEnum() )
{ {
case Units::IN: case model::Units::IN:
unitsInchesRadio->setChecked( true ); unitsInchesRadio->setChecked( true );
break; break;
case Units::MM: case model::Units::MM:
unitsMillimetersRadio->setChecked( true ); unitsMillimetersRadio->setChecked( true );
break; break;
case Units::CM: case model::Units::CM:
unitsCentimetersRadio->setChecked( true ); unitsCentimetersRadio->setChecked( true );
break; break;
case Units::PC: case model::Units::PC:
unitsPicasRadio->setChecked( true ); unitsPicasRadio->setChecked( true );
break; break;
default: default:
@@ -62,23 +62,23 @@ namespace glabels
{ {
if ( unitsInchesRadio->isChecked() ) if ( unitsInchesRadio->isChecked() )
{ {
Settings::setUnits( Units::in() ); model::Settings::setUnits( model::Units::in() );
} }
else if ( unitsMillimetersRadio->isChecked() ) else if ( unitsMillimetersRadio->isChecked() )
{ {
Settings::setUnits( Units::mm() ); model::Settings::setUnits( model::Units::mm() );
} }
else if ( unitsCentimetersRadio->isChecked() ) else if ( unitsCentimetersRadio->isChecked() )
{ {
Settings::setUnits( Units::cm() ); model::Settings::setUnits( model::Units::cm() );
} }
else if ( unitsPicasRadio->isChecked() ) else if ( unitsPicasRadio->isChecked() )
{ {
Settings::setUnits( Units::pc() ); model::Settings::setUnits( model::Units::pc() );
} }
else else
{ {
Settings::setUnits( Units::pt() ); model::Settings::setUnits( model::Units::pt() );
} }
} }
+9 -10
View File
@@ -20,7 +20,6 @@
#include "Preview.h" #include "Preview.h"
#include "LabelModel.h"
#include "PreviewOverlayItem.h" #include "PreviewOverlayItem.h"
#include <QGraphicsDropShadowEffect> #include <QGraphicsDropShadowEffect>
@@ -70,7 +69,7 @@ namespace glabels
/// ///
/// Set renderer /// Set renderer
/// ///
void Preview::setRenderer( const PageRenderer* renderer ) void Preview::setRenderer( const model::PageRenderer* renderer )
{ {
mRenderer = renderer; mRenderer = renderer;
@@ -91,10 +90,10 @@ namespace glabels
if ( mModel != nullptr ) if ( mModel != nullptr )
{ {
// Set scene up with a 5% margin around paper // Set scene up with a 5% margin around paper
Distance x = -0.05 * mModel->tmplate()->pageWidth(); model::Distance x = -0.05 * mModel->tmplate()->pageWidth();
Distance y = -0.05 * mModel->tmplate()->pageHeight(); model::Distance y = -0.05 * mModel->tmplate()->pageHeight();
Distance w = 1.10 * mModel->tmplate()->pageWidth(); model::Distance w = 1.10 * mModel->tmplate()->pageWidth();
Distance h = 1.10 * mModel->tmplate()->pageHeight(); model::Distance h = 1.10 * mModel->tmplate()->pageHeight();
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() ); mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio ); fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
@@ -131,7 +130,7 @@ namespace glabels
/// ///
/// Draw Paper /// Draw Paper
/// ///
void Preview::drawPaper( const Distance& pw, const Distance& ph ) void Preview::drawPaper( const model::Distance& pw, const model::Distance& ph )
{ {
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(); QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
shadowEffect->setColor( shadowColor ); shadowEffect->setColor( shadowColor );
@@ -157,9 +156,9 @@ namespace glabels
/// ///
void Preview::drawLabels() void Preview::drawLabels()
{ {
Frame *frame = mModel->tmplate()->frames().first(); model::Frame *frame = mModel->tmplate()->frames().first();
foreach (Point origin, frame->getOrigins() ) foreach (model::Point origin, frame->getOrigins() )
{ {
drawLabel( origin.x(), origin.y(), frame->path() ); drawLabel( origin.x(), origin.y(), frame->path() );
} }
@@ -169,7 +168,7 @@ namespace glabels
/// ///
/// Draw a Single Label at x,y /// Draw a Single Label at x,y
/// ///
void Preview::drawLabel( const Distance& x, const Distance& y, const QPainterPath& path ) void Preview::drawLabel( const model::Distance& x, const model::Distance& y, const QPainterPath& path )
{ {
QBrush brush( Qt::NoBrush ); QBrush brush( Qt::NoBrush );
QPen pen( labelOutlineColor ); QPen pen( labelOutlineColor );
+8 -10
View File
@@ -22,7 +22,9 @@
#define Preview_h #define Preview_h
#include "PageRenderer.h" #include "model/Distance.h"
#include "model/Model.h"
#include "model/PageRenderer.h"
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsScene> #include <QGraphicsScene>
@@ -31,10 +33,6 @@
namespace glabels namespace glabels
{ {
// Forward references
class LabelModel;
/// ///
/// Preview Widget /// Preview Widget
/// ///
@@ -54,7 +52,7 @@ namespace glabels
// Renderer // Renderer
///////////////////////////////// /////////////////////////////////
public: public:
void setRenderer( const PageRenderer* renderer ); void setRenderer( const model::PageRenderer* renderer );
private slots: private slots:
void onRendererChanged(); void onRendererChanged();
@@ -71,9 +69,9 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
private: private:
void clearScene(); void clearScene();
void drawPaper( const Distance& pw, const Distance& ph ); void drawPaper( const model::Distance& pw, const model::Distance& ph );
void drawLabels(); void drawLabels();
void drawLabel( const Distance& x, const Distance& y, const QPainterPath& path ); void drawLabel( const model::Distance& x, const model::Distance& y, const QPainterPath& path );
void drawPreviewOverlay(); void drawPreviewOverlay();
@@ -82,8 +80,8 @@ namespace glabels
// Private Data // Private Data
///////////////////////////////// /////////////////////////////////
private: private:
const LabelModel* mModel; const model::Model* mModel;
const PageRenderer* mRenderer; const model::PageRenderer* mRenderer;
QGraphicsScene* mScene; QGraphicsScene* mScene;
}; };
+2 -2
View File
@@ -20,7 +20,7 @@
#include "PreviewOverlayItem.h" #include "PreviewOverlayItem.h"
#include "PageRenderer.h" #include "model/PageRenderer.h"
#include <QtDebug> #include <QtDebug>
@@ -28,7 +28,7 @@
namespace glabels namespace glabels
{ {
PreviewOverlayItem::PreviewOverlayItem( const PageRenderer* renderer, QGraphicsItem* parent ) PreviewOverlayItem::PreviewOverlayItem( const model::PageRenderer* renderer, QGraphicsItem* parent )
: QGraphicsItem(parent), mRenderer(renderer) : QGraphicsItem(parent), mRenderer(renderer)
{ {
// empty // empty
+4 -6
View File
@@ -22,16 +22,14 @@
#define PreviewOverlayItem_h #define PreviewOverlayItem_h
#include "model/PageRenderer.h"
#include <QGraphicsItem> #include <QGraphicsItem>
namespace glabels namespace glabels
{ {
// Forward references
class PageRenderer;
/// ///
/// PreviewOverlayItem Widget /// PreviewOverlayItem Widget
/// ///
@@ -42,7 +40,7 @@ namespace glabels
// Life Cycle // Life Cycle
///////////////////////////////// /////////////////////////////////
public: public:
PreviewOverlayItem( const PageRenderer* renderer, QGraphicsItem* parent = nullptr ); PreviewOverlayItem( const model::PageRenderer* renderer, QGraphicsItem* parent = nullptr );
///////////////////////////////////// /////////////////////////////////////
@@ -57,7 +55,7 @@ namespace glabels
// Private Data // Private Data
///////////////////////////////// /////////////////////////////////
private: private:
const PageRenderer* mRenderer; const model::PageRenderer* mRenderer;
}; };
+1 -3
View File
@@ -20,8 +20,6 @@
#include "PrintView.h" #include "PrintView.h"
#include "LabelModel.h"
#include <QPrintDialog> #include <QPrintDialog>
#include <QtDebug> #include <QtDebug>
@@ -57,7 +55,7 @@ namespace glabels
/// ///
/// Set Model /// Set Model
/// ///
void PrintView::setModel( LabelModel* model ) void PrintView::setModel( model::Model* model )
{ {
mModel = model; mModel = model;
mRenderer.setModel( mModel ); mRenderer.setModel( mModel );
+5 -8
View File
@@ -24,7 +24,8 @@
#include "ui_PrintView.h" #include "ui_PrintView.h"
#include "PageRenderer.h" #include "model/Model.h"
#include "model/PageRenderer.h"
#include <QPrinter> #include <QPrinter>
@@ -32,10 +33,6 @@
namespace glabels namespace glabels
{ {
// Forward references
class LabelModel;
/// ///
/// Print View Widget /// Print View Widget
/// ///
@@ -55,7 +52,7 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
// Public methods // Public methods
///////////////////////////////// /////////////////////////////////
void setModel( LabelModel* model ); void setModel( model::Model* model );
///////////////////////////////// /////////////////////////////////
@@ -72,9 +69,9 @@ namespace glabels
// Private Data // Private Data
///////////////////////////////// /////////////////////////////////
private: private:
LabelModel* mModel; model::Model* mModel;
QPrinter* mPrinter; QPrinter* mPrinter;
PageRenderer mRenderer; model::PageRenderer mRenderer;
bool mBlocked; bool mBlocked;
+15 -15
View File
@@ -20,12 +20,12 @@
#include "PropertiesView.h" #include "PropertiesView.h"
#include "Db.h"
#include "LabelModel.h"
#include "SelectProductDialog.h" #include "SelectProductDialog.h"
#include "Settings.h"
#include "UndoRedoModel.h" #include "UndoRedoModel.h"
#include "model/Db.h"
#include "model/Settings.h"
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <QtDebug> #include <QtDebug>
@@ -51,7 +51,7 @@ namespace glabels
similarBrowser->setAttribute(Qt::WA_TranslucentBackground); similarBrowser->setAttribute(Qt::WA_TranslucentBackground);
similarBrowser->viewport()->setAutoFillBackground(false); similarBrowser->viewport()->setAutoFillBackground(false);
connect( Settings::instance(), SIGNAL(changed()), connect( model::Settings::instance(), SIGNAL(changed()),
this, SLOT(onSettingsChanged()) ); this, SLOT(onSettingsChanged()) );
onSettingsChanged(); onSettingsChanged();
@@ -70,7 +70,7 @@ namespace glabels
/// ///
/// Set Model /// Set Model
/// ///
void PropertiesView::setModel( LabelModel* model, UndoRedoModel* undoRedoModel ) void PropertiesView::setModel( model::Model* model, UndoRedoModel* undoRedoModel )
{ {
mModel = model; mModel = model;
mUndoRedoModel = undoRedoModel; mUndoRedoModel = undoRedoModel;
@@ -86,7 +86,7 @@ namespace glabels
/// ///
void PropertiesView::onSettingsChanged() void PropertiesView::onSettingsChanged()
{ {
mUnits = Settings::units(); mUnits = model::Settings::units();
if (mModel) if (mModel)
{ {
onLabelSizeChanged(); onLabelSizeChanged();
@@ -99,14 +99,14 @@ namespace glabels
/// ///
void PropertiesView::onLabelSizeChanged() void PropertiesView::onLabelSizeChanged()
{ {
const Template *tmplate = mModel->tmplate(); const model::Template* tmplate = mModel->tmplate();
const Frame *frame = tmplate->frames().first(); const model::Frame* frame = tmplate->frames().first();
bool isRotated = mModel->rotate(); bool isRotated = mModel->rotate();
preview->setTemplate( tmplate ); preview->setTemplate( tmplate );
preview->setRotate( isRotated ); preview->setRotate( isRotated );
const Vendor *vendor = Db::lookupVendorFromName( tmplate->brand() ); const model::Vendor* vendor = model::Db::lookupVendorFromName( tmplate->brand() );
if ( (vendor != nullptr) && (vendor->url() != nullptr) ) if ( (vendor != nullptr) && (vendor->url() != nullptr) )
{ {
QString markup = QString( "<a href='%1'>%2</a>" ) QString markup = QString( "<a href='%1'>%2</a>" )
@@ -131,7 +131,7 @@ namespace glabels
descriptionLabel->setText( tmplate->description() ); descriptionLabel->setText( tmplate->description() );
QString pgSizeString = Db::lookupPaperNameFromId( tmplate->paperId() ); QString pgSizeString = model::Db::lookupPaperNameFromId( tmplate->paperId() );
pageSizeLabel->setText( pgSizeString ); pageSizeLabel->setText( pgSizeString );
QString labelSizeString = frame->sizeDescription( mUnits ); QString labelSizeString = frame->sizeDescription( mUnits );
@@ -140,7 +140,7 @@ namespace glabels
QString layoutString = frame->layoutDescription(); QString layoutString = frame->layoutDescription();
layoutLabel->setText( layoutString ); layoutLabel->setText( layoutString );
QStringList list = Db::getNameListOfSimilarTemplates( tmplate->name() ); QStringList list = model::Db::getNameListOfSimilarTemplates( tmplate->name() );
if ( list.isEmpty() ) if ( list.isEmpty() )
{ {
similarProductsGroupBox->hide(); similarProductsGroupBox->hide();
@@ -181,8 +181,8 @@ namespace glabels
/// ///
void PropertiesView::onOrientationActivated() void PropertiesView::onOrientationActivated()
{ {
const Template *tmplate = mModel->tmplate(); const model::Template* tmplate = mModel->tmplate();
const Frame *frame = tmplate->frames().first(); const model::Frame* frame = tmplate->frames().first();
// Make sure index actually changed. // Make sure index actually changed.
int index = orientationCombo->currentIndex(); int index = orientationCombo->currentIndex();
@@ -216,7 +216,7 @@ namespace glabels
SelectProductDialog selectProductDialog( this ); SelectProductDialog selectProductDialog( this );
selectProductDialog.exec(); selectProductDialog.exec();
const Template* tmplate = selectProductDialog.tmplate(); const model::Template* tmplate = selectProductDialog.tmplate();
if ( tmplate ) if ( tmplate )
{ {
mUndoRedoModel->checkpoint( tr("Change Product") ); mUndoRedoModel->checkpoint( tr("Change Product") );
@@ -224,7 +224,7 @@ namespace glabels
mModel->setTmplate( tmplate ); mModel->setTmplate( tmplate );
// Don't rotate circular or round labels // Don't rotate circular or round labels
const Frame *frame = tmplate->frames().first(); const model::Frame *frame = tmplate->frames().first();
if ( frame->w() == frame->h() ) if ( frame->w() == frame->h() )
{ {
mModel->setRotate( false ); mModel->setRotate( false );
+5 -5
View File
@@ -24,14 +24,14 @@
#include "ui_PropertiesView.h" #include "ui_PropertiesView.h"
#include "Units.h" #include "model/Model.h"
#include "model/Units.h"
namespace glabels namespace glabels
{ {
// Forward references // Forward references
class LabelModel;
class UndoRedoModel; class UndoRedoModel;
@@ -54,7 +54,7 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
// Public methods // Public methods
///////////////////////////////// /////////////////////////////////
void setModel( LabelModel* model, UndoRedoModel* undoRedoModel ); void setModel( model::Model* model, UndoRedoModel* undoRedoModel );
///////////////////////////////// /////////////////////////////////
@@ -71,9 +71,9 @@ namespace glabels
// Private Data // Private Data
///////////////////////////////// /////////////////////////////////
private: private:
LabelModel* mModel; model::Model* mModel;
UndoRedoModel* mUndoRedoModel; UndoRedoModel* mUndoRedoModel;
Units mUnits; model::Units mUnits;
int mOldOrientationIndex; int mOldOrientationIndex;
}; };
+21 -20
View File
@@ -20,10 +20,11 @@
#include "SelectProductDialog.h" #include "SelectProductDialog.h"
#include "Db.h"
#include "Settings.h"
#include "TemplatePickerItem.h" #include "TemplatePickerItem.h"
#include "model/Db.h"
#include "model/Settings.h"
#include <QtDebug> #include <QtDebug>
@@ -38,18 +39,18 @@ namespace glabels
{ {
setupUi( this ); setupUi( this );
pageSizeIsoCheck->setChecked( Settings::searchIsoPaperSizes() ); pageSizeIsoCheck->setChecked( model::Settings::searchIsoPaperSizes() );
pageSizeUsCheck->setChecked( Settings::searchUsPaperSizes() ); pageSizeUsCheck->setChecked( model::Settings::searchUsPaperSizes() );
pageSizeOtherCheck->setChecked( Settings::searchOtherPaperSizes() ); pageSizeOtherCheck->setChecked( model::Settings::searchOtherPaperSizes() );
allCategoriesRadio->setChecked( Settings::searchAllCategories() ); allCategoriesRadio->setChecked( model::Settings::searchAllCategories() );
selectedCategoriesRadio->setChecked( !Settings::searchAllCategories() ); selectedCategoriesRadio->setChecked( !model::Settings::searchAllCategories() );
categoriesCheckContainer->setEnabled( !Settings::searchAllCategories() ); categoriesCheckContainer->setEnabled( !model::Settings::searchAllCategories() );
mCategoryIdList = Settings::searchCategoryList(); mCategoryIdList = model::Settings::searchCategoryList();
QList<Category*> categories = Db::categories(); QList<model::Category*> categories = model::Db::categories();
foreach ( Category *category, categories ) foreach ( model::Category *category, categories )
{ {
QCheckBox* check = new QCheckBox( category->name() ); QCheckBox* check = new QCheckBox( category->name() );
check->setChecked( mCategoryIdList.contains( category->id() ) ); check->setChecked( mCategoryIdList.contains( category->id() ) );
@@ -60,10 +61,10 @@ namespace glabels
connect( check, SIGNAL(clicked()), this, SLOT(onCategoryCheckClicked()) ); connect( check, SIGNAL(clicked()), this, SLOT(onCategoryCheckClicked()) );
} }
QList<Template*> tmplates = Db::templates(); QList<model::Template*> tmplates = model::Db::templates();
templatePicker->setTemplates( tmplates ); templatePicker->setTemplates( tmplates );
if ( Settings::recentTemplateList().count() > 0 ) if ( model::Settings::recentTemplateList().count() > 0 )
{ {
modeNotebook->setCurrentIndex(1); modeNotebook->setCurrentIndex(1);
} }
@@ -75,7 +76,7 @@ namespace glabels
/// ///
/// Get selected template /// Get selected template
/// ///
const Template* SelectProductDialog::tmplate() const const model::Template* SelectProductDialog::tmplate() const
{ {
if ( !mCanceled ) if ( !mCanceled )
{ {
@@ -106,7 +107,7 @@ namespace glabels
break; break;
case 1: case 1:
// Recent Tab // Recent Tab
templatePicker->applyFilter( Settings::recentTemplateList() ); templatePicker->applyFilter( model::Settings::recentTemplateList() );
break; break;
default: default:
qDebug() << "onModeTabChanged(): unknown tab!"; qDebug() << "onModeTabChanged(): unknown tab!";
@@ -142,9 +143,9 @@ namespace glabels
/// ///
void SelectProductDialog::onPageSizeCheckClicked() void SelectProductDialog::onPageSizeCheckClicked()
{ {
Settings::setSearchIsoPaperSizes( pageSizeIsoCheck->isChecked() ); model::Settings::setSearchIsoPaperSizes( pageSizeIsoCheck->isChecked() );
Settings::setSearchUsPaperSizes( pageSizeUsCheck->isChecked() ); model::Settings::setSearchUsPaperSizes( pageSizeUsCheck->isChecked() );
Settings::setSearchOtherPaperSizes( pageSizeOtherCheck->isChecked() ); model::Settings::setSearchOtherPaperSizes( pageSizeOtherCheck->isChecked() );
templatePicker->applyFilter( searchEntry->text(), templatePicker->applyFilter( searchEntry->text(),
pageSizeIsoCheck->isChecked(), pageSizeIsoCheck->isChecked(),
@@ -170,7 +171,7 @@ namespace glabels
allCategoriesRadio->isChecked(), allCategoriesRadio->isChecked(),
mCategoryIdList ); mCategoryIdList );
Settings::setSearchAllCategories( allCategoriesRadio->isChecked() ); model::Settings::setSearchAllCategories( allCategoriesRadio->isChecked() );
} }
@@ -189,7 +190,7 @@ namespace glabels
mCategoryIdList ); mCategoryIdList );
Settings::setSearchCategoryList( mCategoryIdList ); model::Settings::setSearchCategoryList( mCategoryIdList );
} }
+1 -1
View File
@@ -48,7 +48,7 @@ namespace glabels
///////////////////////////////// /////////////////////////////////
// Accessors // Accessors
///////////////////////////////// /////////////////////////////////
const Template* tmplate() const; const model::Template* tmplate() const;
///////////////////////////////// /////////////////////////////////
+17 -17
View File
@@ -74,7 +74,7 @@ namespace glabels
/// ///
/// Template Property Setter /// Template Property Setter
/// ///
void SimplePreview::setTemplate( const Template *tmplate ) void SimplePreview::setTemplate( const model::Template *tmplate )
{ {
mTmplate = tmplate; mTmplate = tmplate;
update(); update();
@@ -110,10 +110,10 @@ namespace glabels
if ( mTmplate != nullptr ) if ( mTmplate != nullptr )
{ {
// Set scene up with a 5% margin around paper // Set scene up with a 5% margin around paper
Distance x = -0.05 * mTmplate->pageWidth(); model::Distance x = -0.05 * mTmplate->pageWidth();
Distance y = -0.05 * mTmplate->pageHeight(); model::Distance y = -0.05 * mTmplate->pageHeight();
Distance w = 1.10 * mTmplate->pageWidth(); model::Distance w = 1.10 * mTmplate->pageWidth();
Distance h = 1.10 * mTmplate->pageHeight(); model::Distance h = 1.10 * mTmplate->pageHeight();
mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() ); mScene->setSceneRect( x.pt(), y.pt(), w.pt(), h.pt() );
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio ); fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
@@ -141,7 +141,7 @@ namespace glabels
/// ///
/// Draw Paper /// Draw Paper
/// ///
void SimplePreview::drawPaper( const Distance& pw, const Distance& ph ) void SimplePreview::drawPaper( const model::Distance& pw, const model::Distance& ph )
{ {
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(); QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
shadowEffect->setColor( shadowColor ); shadowEffect->setColor( shadowColor );
@@ -167,9 +167,9 @@ namespace glabels
/// ///
void SimplePreview::drawLabels() void SimplePreview::drawLabels()
{ {
Frame *frame = mTmplate->frames().first(); model::Frame *frame = mTmplate->frames().first();
foreach (Point origin, frame->getOrigins() ) foreach (model::Point origin, frame->getOrigins() )
{ {
drawLabel( origin.x(), origin.y(), frame->path() ); drawLabel( origin.x(), origin.y(), frame->path() );
} }
@@ -179,8 +179,8 @@ namespace glabels
/// ///
/// Draw a Single Label at x,y /// Draw a Single Label at x,y
/// ///
void SimplePreview::drawLabel( const Distance& x, void SimplePreview::drawLabel( const model::Distance& x,
const Distance& y, const model::Distance& y,
const QPainterPath& path ) const QPainterPath& path )
{ {
QBrush brush( labelColor ); QBrush brush( labelColor );
@@ -202,12 +202,12 @@ namespace glabels
/// ///
void SimplePreview::drawArrow() void SimplePreview::drawArrow()
{ {
Frame *frame = mTmplate->frames().first(); model::Frame *frame = mTmplate->frames().first();
Distance w = frame->w(); model::Distance w = frame->w();
Distance h = frame->h(); model::Distance h = frame->h();
Distance minWH = min( w, h ); model::Distance minWH = min( w, h );
QPen pen( arrowColor ); QPen pen( arrowColor );
pen.setWidthF( 0.25*minWH.pt()*arrowScale ); pen.setWidthF( 0.25*minWH.pt()*arrowScale );
@@ -216,9 +216,9 @@ namespace glabels
QBrush brush( upColor ); QBrush brush( upColor );
Point origin = frame->getOrigins().first(); model::Point origin = frame->getOrigins().first();
Distance x0 = origin.x(); model::Distance x0 = origin.x();
Distance y0 = origin.y(); model::Distance y0 = origin.y();
QPainterPath path; QPainterPath path;
path.moveTo( 0, minWH.pt()*arrowScale/3 ); path.moveTo( 0, minWH.pt()*arrowScale/3 );
+5 -5
View File
@@ -22,7 +22,7 @@
#define SimplePreview_h #define SimplePreview_h
#include "Template.h" #include "model/Template.h"
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsScene> #include <QGraphicsScene>
@@ -51,7 +51,7 @@ namespace glabels
// Properties // Properties
///////////////////////////////// /////////////////////////////////
public: public:
void setTemplate( const Template *tmplate ); void setTemplate( const model::Template *tmplate );
void setRotate( bool rotateFlag ); void setRotate( bool rotateFlag );
@@ -68,9 +68,9 @@ namespace glabels
private: private:
void update(); void update();
void clearScene(); void clearScene();
void drawPaper( const Distance& pw, const Distance& ph ); void drawPaper( const model::Distance& pw, const model::Distance& ph );
void drawLabels(); void drawLabels();
void drawLabel( const Distance& x, const Distance& y, const QPainterPath& path ); void drawLabel( const model::Distance& x, const model::Distance& y, const QPainterPath& path );
void drawArrow(); void drawArrow();
@@ -78,7 +78,7 @@ namespace glabels
// Private Data // Private Data
///////////////////////////////// /////////////////////////////////
private: private:
const Template *mTmplate; const model::Template* mTmplate;
bool mRotateFlag; bool mRotateFlag;
QGraphicsScene* mScene; QGraphicsScene* mScene;
+3 -3
View File
@@ -45,9 +45,9 @@ namespace glabels
/// ///
/// Set List of Templates to Pick From /// Set List of Templates to Pick From
/// ///
void TemplatePicker::setTemplates( const QList <Template*> &tmplates ) void TemplatePicker::setTemplates( const QList <model::Template*> &tmplates )
{ {
foreach (Template *tmplate, tmplates) foreach (model::Template *tmplate, tmplates)
{ {
new TemplatePickerItem( tmplate, this ); new TemplatePickerItem( tmplate, this );
} }
@@ -135,7 +135,7 @@ namespace glabels
/// ///
/// Get Currently Selected Template /// Get Currently Selected Template
/// ///
const Template *TemplatePicker::selectedTemplate() const model::Template *TemplatePicker::selectedTemplate()
{ {
QList<QListWidgetItem *> items = selectedItems(); QList<QListWidgetItem *> items = selectedItems();
if ( items.isEmpty() ) if ( items.isEmpty() )
+3 -3
View File
@@ -22,7 +22,7 @@
#define TemplatePicker_h #define TemplatePicker_h
#include "Template.h" #include "model/Template.h"
#include <QList> #include <QList>
#include <QListWidget> #include <QListWidget>
@@ -50,7 +50,7 @@ namespace glabels
// Properties // Properties
///////////////////////////////// /////////////////////////////////
public: public:
void setTemplates( const QList <Template*> &tmplates ); void setTemplates( const QList <model::Template*> &tmplates );
///////////////////////////////// /////////////////////////////////
@@ -62,7 +62,7 @@ namespace glabels
void applyFilter( const QStringList& names ); void applyFilter( const QStringList& names );
const Template *selectedTemplate(); const model::Template *selectedTemplate();
}; };
+2 -2
View File
@@ -33,7 +33,7 @@ namespace glabels
/// ///
/// Constructor /// Constructor
/// ///
TemplatePickerItem::TemplatePickerItem( Template *tmplate, QListWidget *parent ) TemplatePickerItem::TemplatePickerItem( model::Template *tmplate, QListWidget *parent )
: QListWidgetItem(parent) : QListWidgetItem(parent)
{ {
mTmplate = tmplate; mTmplate = tmplate;
@@ -48,7 +48,7 @@ namespace glabels
/// ///
/// Template Property Getter /// Template Property Getter
/// ///
const Template *TemplatePickerItem::tmplate() const const model::Template *TemplatePickerItem::tmplate() const
{ {
return mTmplate; return mTmplate;
} }
+4 -4
View File
@@ -22,7 +22,7 @@
#define TemplatePickerItem_h #define TemplatePickerItem_h
#include "Template.h" #include "model/Template.h"
#include <QLabel> #include <QLabel>
#include <QListWidget> #include <QListWidget>
@@ -43,21 +43,21 @@ namespace glabels
// Life Cycle // Life Cycle
///////////////////////////////// /////////////////////////////////
public: public:
TemplatePickerItem( Template *tmplate, QListWidget *parent = nullptr ); TemplatePickerItem( model::Template *tmplate, QListWidget *parent = nullptr );
///////////////////////////////// /////////////////////////////////
// Properties // Properties
///////////////////////////////// /////////////////////////////////
public: public:
const Template *tmplate() const; const model::Template *tmplate() const;
///////////////////////////////// /////////////////////////////////
// Private Data // Private Data
///////////////////////////////// /////////////////////////////////
private: private:
Template *mTmplate; model::Template *mTmplate;
}; };
+3 -3
View File
@@ -20,7 +20,7 @@
#include "UndoRedoModel.h" #include "UndoRedoModel.h"
#include "LabelModel.h" #include "model/Model.h"
namespace glabels namespace glabels
@@ -29,7 +29,7 @@ namespace glabels
/// ///
/// Constructor /// Constructor
/// ///
UndoRedoModel::UndoRedoModel( LabelModel* model ) UndoRedoModel::UndoRedoModel( model::Model* model )
{ {
mModel = model; mModel = model;
mNewSelection = true; mNewSelection = true;
@@ -178,7 +178,7 @@ namespace glabels
/// ///
/// State constructor /// State constructor
/// ///
UndoRedoModel::State::State( LabelModel* model, const QString& description ) UndoRedoModel::State::State( model::Model* model, const QString& description )
{ {
this->model = model->save(); this->model = model->save();
this->description = description; this->description = description;
+6 -8
View File
@@ -22,6 +22,8 @@
#define UndoRedoModel_h #define UndoRedoModel_h
#include "model/Model.h"
#include <QList> #include <QList>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
@@ -30,10 +32,6 @@
namespace glabels namespace glabels
{ {
// Forward references
class LabelModel;
/// ///
/// UndoRedoModel /// UndoRedoModel
/// ///
@@ -46,7 +44,7 @@ namespace glabels
// Life Cycle // Life Cycle
///////////////////////////////// /////////////////////////////////
public: public:
UndoRedoModel( LabelModel* model ); UndoRedoModel( model::Model* model );
~UndoRedoModel() override; ~UndoRedoModel() override;
@@ -84,10 +82,10 @@ namespace glabels
class State class State
{ {
public: public:
State( LabelModel* model, const QString& description ); State( model::Model* model, const QString& description );
~State(); ~State();
LabelModel* model; model::Model* model;
QString description; QString description;
}; };
@@ -112,7 +110,7 @@ namespace glabels
// Private data // Private data
///////////////////////////////// /////////////////////////////////
private: private:
LabelModel *mModel; model::Model* mModel;
Stack mUndoStack; Stack mUndoStack;
Stack mRedoStack; Stack mRedoStack;
-82
View File
@@ -1,82 +0,0 @@
/* XmlLabelCreator.h
*
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XmlLabelCreator_h
#define XmlLabelCreator_h
#include <QObject>
#include <QDomElement>
namespace glabels
{
// Forward references
class LabelModel;
class LabelModelObject;
class LabelModelBoxObject;
class LabelModelEllipseObject;
class LabelModelLineObject;
class LabelModelImageObject;
class LabelModelBarcodeObject;
class LabelModelTextObject;
///
/// XmlLabelCreator
///
class XmlLabelCreator : public QObject
{
Q_OBJECT
public:
static void writeFile( const LabelModel* label, const QString& fileName );
static void writeBuffer( const LabelModel* label, QByteArray& buffer );
static void serializeObjects( const QList<LabelModelObject*>& objects, QByteArray& buffer );
private:
static void createDoc( QDomDocument& doc, const LabelModel* label );
static void createRootNode( const LabelModel* label );
static void createObjectsNode( QDomElement &parent, const QList<LabelModelObject*>& objects, bool rotate );
static void createObjectBoxNode( QDomElement &parent, const LabelModelBoxObject* object );
static void createObjectEllipseNode( QDomElement &parent, const LabelModelEllipseObject* object );
static void createObjectLineNode( QDomElement &parent, const LabelModelLineObject* object );
static void createObjectImageNode( QDomElement &parent, const LabelModelImageObject* object );
static void createObjectBarcodeNode( QDomElement &parent, const LabelModelBarcodeObject* object );
static void createObjectTextNode( QDomElement &parent, const LabelModelTextObject* object );
static void createPNode( QDomElement &parent, const QString& blockText );
static void createPositionAttrs( QDomElement &node, const LabelModelObject* object );
static void createSizeAttrs( QDomElement &node, const LabelModelObject* object );
static void createLineAttrs( QDomElement &node, const LabelModelObject* object );
static void createFillAttrs( QDomElement &node, const LabelModelObject* object );
static void createAffineAttrs( QDomElement &node, const LabelModelObject* object );
static void createShadowAttrs( QDomElement &node, const LabelModelObject* object );
static void createMergeNode( QDomElement &parent, const LabelModel* label );
static void createDataNode( QDomElement &parent, const QList<LabelModelObject*>& objects );
static void createPngFileNode( QDomElement &parent, const QString& name, const QImage& image );
static void createSvgFileNode( QDomElement &parent, const QString& name, const QByteArray& svg );
};
}
#endif // XmlLabelCreator_h
+19 -18
View File
@@ -1,4 +1,4 @@
/* glabels_main.cpp /* main.cpp
* *
* Copyright (C) 2013-2016 Jim Evins <evins@snaught.com> * Copyright (C) 2013-2016 Jim Evins <evins@snaught.com>
* *
@@ -18,16 +18,17 @@
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>. * along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "BarcodeBackends.h"
#include "FileUtil.h"
#include "Db.h"
#include "LabelModel.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "Settings.h"
#include "Version.h"
#include "XmlLabelParser.h"
#include "Merge/Factory.h" #include "model/FileUtil.h"
#include "model/Db.h"
#include "model/Model.h"
#include "model/Settings.h"
#include "model/Version.h"
#include "model/XmlLabelParser.h"
#include "barcode/Backends.h"
#include "merge/Factory.h"
#include <QApplication> #include <QApplication>
#include <QCommandLineParser> #include <QCommandLineParser>
@@ -44,14 +45,14 @@ int main( int argc, char **argv )
QCoreApplication::setOrganizationName( "glabels.org" ); QCoreApplication::setOrganizationName( "glabels.org" );
QCoreApplication::setOrganizationDomain( "glabels.org" ); QCoreApplication::setOrganizationDomain( "glabels.org" );
QCoreApplication::setApplicationName( "glabels-qt" ); QCoreApplication::setApplicationName( "glabels-qt" );
QCoreApplication::setApplicationVersion( glabels::Version::STRING ); QCoreApplication::setApplicationVersion( glabels::model::Version::STRING );
// //
// Setup translators // Setup translators
// //
QLocale locale = QLocale::system(); QLocale locale = QLocale::system();
QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath ); QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
QString myTranslationsDir = glabels::FileUtil::translationsDir().canonicalPath(); QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
QTranslator qtTranslator; QTranslator qtTranslator;
if ( qtTranslator.load( locale, "qt", "_", qtTranslationsDir ) ) if ( qtTranslator.load( locale, "qt", "_", qtTranslationsDir ) )
@@ -87,10 +88,10 @@ int main( int argc, char **argv )
// //
// Initialize subsystems // Initialize subsystems
// //
glabels::Settings::init(); glabels::model::Settings::init();
glabels::Db::init(); glabels::model::Db::init();
glabels::merge::Factory::init(); glabels::merge::Factory::init();
glabels::BarcodeBackends::init(); glabels::barcode::Backends::init();
// //
@@ -99,12 +100,12 @@ int main( int argc, char **argv )
bool openedFiles = false; bool openedFiles = false;
foreach ( QString filename, parser.positionalArguments() ) foreach ( QString filename, parser.positionalArguments() )
{ {
glabels::LabelModel *label = glabels::XmlLabelParser::readFile( filename ); glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
if ( label ) if ( model )
{ {
label->setFileName( filename ); model->setFileName( filename );
glabels::MainWindow *newWindow = new glabels::MainWindow(); glabels::MainWindow *newWindow = new glabels::MainWindow();
newWindow->setModel( label ); newWindow->setModel( model );
newWindow->show(); newWindow->show();
openedFiles = true; openedFiles = true;
} }
+16 -22
View File
@@ -1,21 +1,9 @@
#======================================= project (glbarcode LANGUAGES CXX)
# Compilation
#=======================================
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_compile_options (-std=c++11 -g)
if (NOT WIN32)
add_compile_options (-fPIC)
endif ()
# Uncomment to build with pedantic flags
#add_compile_options (-Werror -Wall -Wpedantic)
#======================================= #=======================================
# Sources # Sources
#======================================= #=======================================
set (LIB_SOURCES set (GLBARCODE_SOURCES
Factory.cpp Factory.cpp
Barcode.cpp Barcode.cpp
Barcode1dBase.cpp Barcode1dBase.cpp
@@ -38,15 +26,21 @@ set (LIB_SOURCES
QtRenderer.cpp QtRenderer.cpp
) )
add_library (glbarcode #=====================================
${LIB_SOURCES} # Target
#=====================================
add_library (glbarcode STATIC
${GLBARCODE_SOURCES}
) )
target_compile_features (glbarcode
#======================================= PUBLIC cxx_std_11
# Where to find stuff
#=======================================
include_directories (
${Qt5Widgets_INCLUDE_DIRS}
) )
target_include_directories (glbarcode
PUBLIC ..
)
target_link_libraries (glbarcode
Qt5::Widgets
)

Some files were not shown because too many files have changed in this diff Show More