Big-Ugly Style Update (#278)
* Bulk replaced tabs with spaces * Bulk removed trailing whitespace from lines * Replaced c-style comments with c++-style comments in file banners * Replace nested namespace definitions with single concise definitions (C++17), this keeps the indentation more manageable * Cleanup ordering and spacing of include directives * Bulk renaming of header file extensions from '.h' to '.hpp'. * Update CODING-STYLE.md * Update target_compile_features from cxx_std_11 to cxx_std_20. * Refresh .clang-format file. Still needs a lot of tweaking.
This commit is contained in:
+180
-22
@@ -1,28 +1,72 @@
|
|||||||
---
|
---
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
# BasedOnStyle: Google
|
|
||||||
AccessModifierOffset: -8
|
AccessModifierOffset: -8
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
AlignConsecutiveAssignments: true
|
AlignArrayOfStructures: None
|
||||||
AlignConsecutiveDeclarations: true
|
AlignConsecutiveAssignments:
|
||||||
AlignEscapedNewlinesLeft: true
|
Enabled: true
|
||||||
AlignOperands: true
|
AcrossEmptyLines: false
|
||||||
AlignTrailingComments: true
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: true
|
||||||
|
AlignConsecutiveBitFields:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveDeclarations:
|
||||||
|
Enabled: true
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: true
|
||||||
|
AlignConsecutiveMacros:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
AlignFunctionPointers: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveShortCaseStatements:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCaseColons: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
AllowShortBlocksOnASingleLine: false
|
AllowBreakBeforeNoexceptSpecifier: Never
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortCompoundRequirementOnASingleLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: None
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
AlwaysBreakTemplateDeclarations: true
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
BinPackArguments: false
|
BinPackArguments: false
|
||||||
BinPackParameters: false
|
BinPackParameters: false
|
||||||
BraceWrapping:
|
BitFieldColonSpacing: Both
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
AfterClass: true
|
AfterClass: true
|
||||||
AfterControlStatement: true
|
AfterControlStatement: Always
|
||||||
AfterEnum: true
|
AfterEnum: true
|
||||||
|
AfterExternBlock: false
|
||||||
AfterFunction: true
|
AfterFunction: true
|
||||||
AfterNamespace: true
|
AfterNamespace: true
|
||||||
AfterObjCDeclaration: true
|
AfterObjCDeclaration: true
|
||||||
@@ -30,62 +74,176 @@ BraceWrapping:
|
|||||||
AfterUnion: true
|
AfterUnion: true
|
||||||
BeforeCatch: true
|
BeforeCatch: true
|
||||||
BeforeElse: true
|
BeforeElse: true
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakAdjacentStringLiterals: true
|
||||||
|
BreakAfterAttributes: Leave
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakArrays: true
|
||||||
BreakBeforeBinaryOperators: None
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeConceptDeclarations: Always
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
BreakBeforeTernaryOperators: true
|
BreakBeforeTernaryOperators: true
|
||||||
BreakConstructorInitializersBeforeComma: false
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
ColumnLimit: 110
|
ColumnLimit: 110
|
||||||
CommentPragmas: '^ IWYU pragma:'
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
CompactNamespaces: false
|
||||||
ConstructorInitializerIndentWidth: 8
|
ConstructorInitializerIndentWidth: 8
|
||||||
ContinuationIndentWidth: 8
|
ContinuationIndentWidth: 8
|
||||||
Cpp11BracedListStyle: true
|
Cpp11BracedListStyle: true
|
||||||
DerivePointerAlignment: true
|
DerivePointerAlignment: true
|
||||||
DisableFormat: false
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
ExperimentalAutoDetectBinPacking: false
|
ExperimentalAutoDetectBinPacking: false
|
||||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
FixNamespaceComments: false
|
||||||
IncludeCategories:
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
- Regex: '^"[A-Z].*\.h'
|
- Regex: '^"[A-Z].*\.h'
|
||||||
Priority: 1
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
- Regex: '^<Q[A-Za-z]*\>'
|
- Regex: '^<Q[A-Za-z]*\>'
|
||||||
Priority: 2
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
- Regex: '^<[a-z]*>'
|
- Regex: '^<[a-z]*>'
|
||||||
Priority: 3
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
- Regex: '.*'
|
- Regex: '.*'
|
||||||
Priority: 4
|
Priority: 4
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
IndentCaseLabels: false
|
IndentCaseLabels: false
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentRequiresClause: true
|
||||||
IndentWidth: 8
|
IndentWidth: 8
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertBraces: false
|
||||||
|
InsertNewlineAtEOF: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
IntegerLiteralSeparator:
|
||||||
|
Binary: 0
|
||||||
|
BinaryMinDigits: 0
|
||||||
|
Decimal: 0
|
||||||
|
DecimalMinDigits: 0
|
||||||
|
Hex: 0
|
||||||
|
HexMinDigits: 0
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
KeepEmptyLinesAtEOF: false
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
LineEnding: DeriveLF
|
||||||
MacroBlockBegin: ''
|
MacroBlockBegin: ''
|
||||||
MacroBlockEnd: ''
|
MacroBlockEnd: ''
|
||||||
MaxEmptyLinesToKeep: 2
|
MaxEmptyLinesToKeep: 2
|
||||||
NamespaceIndentation: All
|
NamespaceIndentation: All
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
ObjCBlockIndentWidth: 2
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
ObjCSpaceAfterProperty: false
|
ObjCSpaceAfterProperty: false
|
||||||
ObjCSpaceBeforeProtocolList: false
|
ObjCSpaceBeforeProtocolList: false
|
||||||
|
PackConstructorInitializers: NextLine
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
PenaltyBreakBeforeFirstCallParameter: 1
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
PenaltyBreakComment: 300
|
PenaltyBreakComment: 300
|
||||||
PenaltyBreakFirstLessLess: 120
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakScopeResolution: 500
|
||||||
PenaltyBreakString: 1000
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
PenaltyExcessCharacter: 1000000
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
PenaltyReturnTypeOnItsOwnLine: 200
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
|
PPIndentWidth: -1
|
||||||
|
QualifierAlignment: Leave
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
SortIncludes: true
|
RemoveBracesLLVM: false
|
||||||
|
RemoveParentheses: Leave
|
||||||
|
RemoveSemicolon: false
|
||||||
|
RequiresClausePosition: OwnLine
|
||||||
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Leave
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SkipMacroDefinitionBody: false
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: LexicographicNumeric
|
||||||
SpaceAfterCStyleCast: false
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeJsonColon: false
|
||||||
SpaceBeforeParens: ControlStatements
|
SpaceBeforeParens: ControlStatements
|
||||||
SpaceInEmptyParentheses: false
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: true
|
||||||
|
AfterForeachMacros: true
|
||||||
|
AfterFunctionDefinitionName: false
|
||||||
|
AfterFunctionDeclarationName: false
|
||||||
|
AfterIfMacros: true
|
||||||
|
AfterOverloadedOperator: false
|
||||||
|
AfterPlacementOperator: true
|
||||||
|
AfterRequiresInClause: false
|
||||||
|
AfterRequiresInExpression: false
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
SpacesBeforeTrailingComments: 1
|
SpacesBeforeTrailingComments: 1
|
||||||
SpacesInAngles: false
|
SpacesInAngles: Never
|
||||||
SpacesInContainerLiterals: true
|
SpacesInContainerLiterals: true
|
||||||
SpacesInCStyleCastParentheses: false
|
SpacesInLineCommentPrefix:
|
||||||
SpacesInParentheses: true
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParens: Custom
|
||||||
|
SpacesInParensOptions:
|
||||||
|
InCStyleCasts: false
|
||||||
|
InConditionalStatements: true
|
||||||
|
InEmptyParentheses: false
|
||||||
|
Other: true
|
||||||
SpacesInSquareBrackets: false
|
SpacesInSquareBrackets: false
|
||||||
Standard: Cpp11
|
Standard: c++20
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: ForIndentation
|
UseTab: Never
|
||||||
|
VerilogBreakBetweenInstancePorts: true
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- STRINGIZE
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ if (Qt6Test_FOUND)
|
|||||||
enable_testing ()
|
enable_testing ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
#=======================================
|
#=======================================
|
||||||
# Subdirectories
|
# Subdirectories
|
||||||
#=======================================
|
#=======================================
|
||||||
|
|||||||
+505
-507
File diff suppressed because it is too large
Load Diff
@@ -1,98 +0,0 @@
|
|||||||
/* Backends.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Jaye 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 barcode_Backends_h
|
|
||||||
#define barcode_Backends_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Style.h"
|
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace barcode
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Backends Database
|
|
||||||
///
|
|
||||||
class Backends : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
Backends();
|
|
||||||
|
|
||||||
public:
|
|
||||||
static void init();
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Public Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static const QStringList& backendList();
|
|
||||||
static QString backendName( const QString& backendId );
|
|
||||||
static const QList<Style>& styleList();
|
|
||||||
static const Style& defaultStyle();
|
|
||||||
static const Style& style( const QString& backendId, const QString& StyleId );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
static void registerBackend( const QString &backendId, const QString &backendName );
|
|
||||||
|
|
||||||
static void registerStyle( const QString& id,
|
|
||||||
const QString& backendId,
|
|
||||||
const QString& name,
|
|
||||||
bool canText,
|
|
||||||
bool textOptional,
|
|
||||||
bool canChecksum,
|
|
||||||
bool checksumOptional,
|
|
||||||
const QString& defaultDigits,
|
|
||||||
bool canFreeForm,
|
|
||||||
int preferedN );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Members
|
|
||||||
/////////////////////////////////
|
|
||||||
static QStringList mBackendIdList;
|
|
||||||
static QMap<QString,QString> mBackendNameMap;
|
|
||||||
|
|
||||||
static QList<Style> mStyleList;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // barcode_Backends_h
|
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
// Backends.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014 Jaye 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 barcode_Backends_hpp
|
||||||
|
#define barcode_Backends_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Style.hpp"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::barcode
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Backends Database
|
||||||
|
///
|
||||||
|
class Backends : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
Backends();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void init();
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Public Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static const QStringList& backendList();
|
||||||
|
static QString backendName( const QString& backendId );
|
||||||
|
static const QList<Style>& styleList();
|
||||||
|
static const Style& defaultStyle();
|
||||||
|
static const Style& style( const QString& backendId, const QString& StyleId );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
static void registerBackend( const QString &backendId, const QString &backendName );
|
||||||
|
|
||||||
|
static void registerStyle( const QString& id,
|
||||||
|
const QString& backendId,
|
||||||
|
const QString& name,
|
||||||
|
bool canText,
|
||||||
|
bool textOptional,
|
||||||
|
bool canChecksum,
|
||||||
|
bool checksumOptional,
|
||||||
|
const QString& defaultDigits,
|
||||||
|
bool canFreeForm,
|
||||||
|
int preferedN );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Members
|
||||||
|
/////////////////////////////////
|
||||||
|
static QStringList mBackendIdList;
|
||||||
|
static QMap<QString,QString> mBackendNameMap;
|
||||||
|
|
||||||
|
static QList<Style> mStyleList;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // barcode_Backends_hpp
|
||||||
@@ -37,7 +37,7 @@ set (barcode_sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
set (barcode_qobject_headers
|
set (barcode_qobject_headers
|
||||||
Backends.h
|
Backends.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
qt6_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers})
|
qt6_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers})
|
||||||
@@ -50,10 +50,9 @@ add_library (Barcode STATIC
|
|||||||
${barcode_moc_sources}
|
${barcode_moc_sources}
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_compile_features (Barcode
|
target_compile_features (Barcode
|
||||||
# PUBLIC cxx_std_11
|
PUBLIC cxx_std_20
|
||||||
#)
|
)
|
||||||
set_property (TARGET Barcode PROPERTY CXX_STANDARD 11)
|
|
||||||
|
|
||||||
target_include_directories (Barcode
|
target_include_directories (Barcode
|
||||||
PUBLIC ..
|
PUBLIC ..
|
||||||
|
|||||||
+891
-893
File diff suppressed because it is too large
Load Diff
@@ -1,424 +0,0 @@
|
|||||||
/* GnuBarcode.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2017 Jaye 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 barcode_GnuBarcode_h
|
|
||||||
#define barcode_GnuBarcode_h
|
|
||||||
|
|
||||||
#if HAVE_GNU_BARCODE
|
|
||||||
|
|
||||||
#include "glbarcode/Barcode1dBase.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace barcode
|
|
||||||
{
|
|
||||||
namespace GnuBarcode
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GnuBarcode::Base base class for all GNU Barcodes
|
|
||||||
*
|
|
||||||
* Implements glbarcode::Barcode1dBase.
|
|
||||||
*/
|
|
||||||
class Base : public glbarcode::Barcode1dBase
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
int flags;
|
|
||||||
|
|
||||||
bool isAscii( const std::string& data ) const;
|
|
||||||
|
|
||||||
bool isNumericLengthValid( const std::string& data,
|
|
||||||
unsigned int nMin,
|
|
||||||
unsigned int nMax ) const;
|
|
||||||
|
|
||||||
bool isNumericLength1Valid( const std::string& data,
|
|
||||||
unsigned int nMin,
|
|
||||||
unsigned int nMax ) const;
|
|
||||||
|
|
||||||
bool isNumericLength2Valid( const std::string& data,
|
|
||||||
unsigned int nMin,
|
|
||||||
unsigned int nMax ) const;
|
|
||||||
|
|
||||||
void vectorize( const std::string& encodedData,
|
|
||||||
const std::string& displayText,
|
|
||||||
const std::string& cookedData,
|
|
||||||
double& w,
|
|
||||||
double& h ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAN Barcode (Any)
|
|
||||||
*/
|
|
||||||
class Ean : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAN-8 Barcode
|
|
||||||
*/
|
|
||||||
class Ean8 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAN-8+2 Barcode
|
|
||||||
*/
|
|
||||||
class Ean8_2 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAN-8+5 Barcode
|
|
||||||
*/
|
|
||||||
class Ean8_5 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAN-13 Barcode
|
|
||||||
*/
|
|
||||||
class Ean13 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAN-13+2 Barcode
|
|
||||||
*/
|
|
||||||
class Ean13_2 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EAN-13+5 Barcode
|
|
||||||
*/
|
|
||||||
class Ean13_5 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UPC Barcode (Any)
|
|
||||||
*/
|
|
||||||
class Upc : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UPC-A Barcode
|
|
||||||
*/
|
|
||||||
class UpcA : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UPC-A+2 Barcode
|
|
||||||
*/
|
|
||||||
class UpcA_2 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UPC-A+5 Barcode
|
|
||||||
*/
|
|
||||||
class UpcA_5 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UPC-E Barcode
|
|
||||||
*/
|
|
||||||
class UpcE : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UPC-E+2 Barcode
|
|
||||||
*/
|
|
||||||
class UpcE_2 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UPC-E+5 Barcode
|
|
||||||
*/
|
|
||||||
class UpcE_5 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ISBN Barcode
|
|
||||||
*/
|
|
||||||
class Isbn : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ISBN+5 Barcode
|
|
||||||
*/
|
|
||||||
class Isbn_5 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Code39 Barcode
|
|
||||||
*/
|
|
||||||
class Code39 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Code128 Barcode
|
|
||||||
*/
|
|
||||||
class Code128 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Code128C Barcode
|
|
||||||
*/
|
|
||||||
class Code128C : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Code128B Barcode
|
|
||||||
*/
|
|
||||||
class Code128B : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* I25 Barcode
|
|
||||||
*/
|
|
||||||
class I25 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CBR Barcode
|
|
||||||
*/
|
|
||||||
class Cbr : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MSI Barcode
|
|
||||||
*/
|
|
||||||
class Msi : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PLS Barcode
|
|
||||||
*/
|
|
||||||
class Pls : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Code93 Barcode
|
|
||||||
*/
|
|
||||||
class Code93 : public Base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
std::string encode( const std::string& cookedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // HAVE_GNU_BARCODE
|
|
||||||
|
|
||||||
#endif // barcode_GnuBarcode_h
|
|
||||||
@@ -0,0 +1,419 @@
|
|||||||
|
// GnuBarcode.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 Jaye 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 barcode_GnuBarcode_hpp
|
||||||
|
#define barcode_GnuBarcode_hpp
|
||||||
|
|
||||||
|
#if HAVE_GNU_BARCODE
|
||||||
|
|
||||||
|
|
||||||
|
#include "glbarcode/Barcode1dBase.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::barcode::GnuBarcode
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GnuBarcode::Base base class for all GNU Barcodes
|
||||||
|
*
|
||||||
|
* Implements glbarcode::Barcode1dBase.
|
||||||
|
*/
|
||||||
|
class Base : public glbarcode::Barcode1dBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
bool isAscii( const std::string& data ) const;
|
||||||
|
|
||||||
|
bool isNumericLengthValid( const std::string& data,
|
||||||
|
unsigned int nMin,
|
||||||
|
unsigned int nMax ) const;
|
||||||
|
|
||||||
|
bool isNumericLength1Valid( const std::string& data,
|
||||||
|
unsigned int nMin,
|
||||||
|
unsigned int nMax ) const;
|
||||||
|
|
||||||
|
bool isNumericLength2Valid( const std::string& data,
|
||||||
|
unsigned int nMin,
|
||||||
|
unsigned int nMax ) const;
|
||||||
|
|
||||||
|
void vectorize( const std::string& encodedData,
|
||||||
|
const std::string& displayText,
|
||||||
|
const std::string& cookedData,
|
||||||
|
double& w,
|
||||||
|
double& h ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAN Barcode (Any)
|
||||||
|
*/
|
||||||
|
class Ean : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAN-8 Barcode
|
||||||
|
*/
|
||||||
|
class Ean8 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAN-8+2 Barcode
|
||||||
|
*/
|
||||||
|
class Ean8_2 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAN-8+5 Barcode
|
||||||
|
*/
|
||||||
|
class Ean8_5 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAN-13 Barcode
|
||||||
|
*/
|
||||||
|
class Ean13 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAN-13+2 Barcode
|
||||||
|
*/
|
||||||
|
class Ean13_2 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAN-13+5 Barcode
|
||||||
|
*/
|
||||||
|
class Ean13_5 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UPC Barcode (Any)
|
||||||
|
*/
|
||||||
|
class Upc : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UPC-A Barcode
|
||||||
|
*/
|
||||||
|
class UpcA : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UPC-A+2 Barcode
|
||||||
|
*/
|
||||||
|
class UpcA_2 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UPC-A+5 Barcode
|
||||||
|
*/
|
||||||
|
class UpcA_5 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UPC-E Barcode
|
||||||
|
*/
|
||||||
|
class UpcE : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UPC-E+2 Barcode
|
||||||
|
*/
|
||||||
|
class UpcE_2 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UPC-E+5 Barcode
|
||||||
|
*/
|
||||||
|
class UpcE_5 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ISBN Barcode
|
||||||
|
*/
|
||||||
|
class Isbn : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ISBN+5 Barcode
|
||||||
|
*/
|
||||||
|
class Isbn_5 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code39 Barcode
|
||||||
|
*/
|
||||||
|
class Code39 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code128 Barcode
|
||||||
|
*/
|
||||||
|
class Code128 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code128C Barcode
|
||||||
|
*/
|
||||||
|
class Code128C : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code128B Barcode
|
||||||
|
*/
|
||||||
|
class Code128B : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I25 Barcode
|
||||||
|
*/
|
||||||
|
class I25 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CBR Barcode
|
||||||
|
*/
|
||||||
|
class Cbr : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MSI Barcode
|
||||||
|
*/
|
||||||
|
class Msi : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PLS Barcode
|
||||||
|
*/
|
||||||
|
class Pls : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code93 Barcode
|
||||||
|
*/
|
||||||
|
class Code93 : public Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
std::string encode( const std::string& cookedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // HAVE_GNU_BARCODE
|
||||||
|
|
||||||
|
#endif // barcode_GnuBarcode_hpp
|
||||||
@@ -1,91 +1,86 @@
|
|||||||
/* QrEncode.cpp
|
// QrEncode.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2017 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2017 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
// along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
//
|
||||||
|
|
||||||
#if HAVE_QRENCODE
|
#if HAVE_QRENCODE
|
||||||
|
|
||||||
#include "QrEncode.h"
|
|
||||||
|
#include "QrEncode.hpp"
|
||||||
|
|
||||||
#include <qrencode.h>
|
#include <qrencode.h>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels::barcode::QrEncode
|
||||||
{
|
{
|
||||||
namespace barcode
|
|
||||||
{
|
|
||||||
namespace QrEncode
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Static QrCode barcode creation method
|
* Static QrCode barcode creation method
|
||||||
*/
|
*/
|
||||||
glbarcode::Barcode* QrCode::create()
|
glbarcode::Barcode* QrCode::create()
|
||||||
{
|
{
|
||||||
return new QrCode();
|
return new QrCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QrCode data validation, implements glbarcode::Barcode2dBase::validate()
|
* QrCode data validation, implements glbarcode::Barcode2dBase::validate()
|
||||||
*/
|
*/
|
||||||
bool QrCode::validate( const std::string& rawData )
|
bool QrCode::validate( const std::string& rawData )
|
||||||
{
|
{
|
||||||
if ( rawData.size() == 0 )
|
if ( rawData.size() == 0 )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QrCode data encoding, implements glbarcode::Barcode2dBase::encode()
|
* QrCode data encoding, implements glbarcode::Barcode2dBase::encode()
|
||||||
*/
|
*/
|
||||||
bool QrCode::encode( const std::string& cookedData, glbarcode::Matrix<bool>& encodedData )
|
bool QrCode::encode( const std::string& cookedData, glbarcode::Matrix<bool>& encodedData )
|
||||||
{
|
{
|
||||||
QRcode *qrcode = QRcode_encodeString( cookedData.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1 );
|
QRcode *qrcode = QRcode_encodeString( cookedData.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1 );
|
||||||
if ( qrcode == nullptr )
|
if ( qrcode == nullptr )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int w = qrcode->width;
|
int w = qrcode->width;
|
||||||
encodedData.resize( w, w );
|
encodedData.resize( w, w );
|
||||||
|
|
||||||
|
|
||||||
for ( int iy = 0; iy < w; iy++ )
|
|
||||||
{
|
|
||||||
for ( int ix = 0; ix < w; ix++ )
|
|
||||||
{
|
|
||||||
encodedData[iy][ix] = qrcode->data[ iy*w + ix ] & 0x01;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QRcode_free( qrcode );
|
for ( int iy = 0; iy < w; iy++ )
|
||||||
|
{
|
||||||
|
for ( int ix = 0; ix < w; ix++ )
|
||||||
|
{
|
||||||
|
encodedData[iy][ix] = qrcode->data[ iy*w + ix ] & 0x01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
QRcode_free( qrcode );
|
||||||
}
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
/* QrEncode.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2017 Jaye 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 barcode_QrEncode_h
|
|
||||||
#define barcode_QrEncode_h
|
|
||||||
|
|
||||||
#if HAVE_QRENCODE
|
|
||||||
|
|
||||||
#include "glbarcode/Barcode2dBase.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace barcode
|
|
||||||
{
|
|
||||||
namespace QrEncode
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* QrEncode::QrCode QR Code Barcode
|
|
||||||
*
|
|
||||||
* Implements glbarcode::Barcode2dBase.
|
|
||||||
*/
|
|
||||||
class QrCode : public glbarcode::Barcode2dBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static Barcode* create();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool validate( const std::string& rawData ) override;
|
|
||||||
|
|
||||||
bool encode( const std::string& cookedData,
|
|
||||||
glbarcode::Matrix<bool>& encodedData ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // HAVE_QRENCODE
|
|
||||||
|
|
||||||
#endif // barcode_QrEncode_h
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// QrEncode.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 Jaye 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 barcode_QrEncode_hpp
|
||||||
|
#define barcode_QrEncode_hpp
|
||||||
|
|
||||||
|
#if HAVE_QRENCODE
|
||||||
|
|
||||||
|
|
||||||
|
#include "glbarcode/Barcode2dBase.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::barcode::QrEncode
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// QrEncode::QrCode QR Code Barcode
|
||||||
|
///
|
||||||
|
/// Implements glbarcode::Barcode2dBase.
|
||||||
|
///
|
||||||
|
class QrCode : public glbarcode::Barcode2dBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Barcode* create();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool validate( const std::string& rawData ) override;
|
||||||
|
|
||||||
|
bool encode( const std::string& cookedData,
|
||||||
|
glbarcode::Matrix<bool>& encodedData ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // HAVE_QRENCODE
|
||||||
|
|
||||||
|
#endif // barcode_QrEncode_hpp
|
||||||
+190
-192
@@ -1,225 +1,223 @@
|
|||||||
/* Style.cpp
|
// Style.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2013 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2013 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "Style.h"
|
|
||||||
|
|
||||||
#include "Backends.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "Style.hpp"
|
||||||
|
|
||||||
|
#include "Backends.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::barcode
|
||||||
{
|
{
|
||||||
namespace barcode
|
|
||||||
{
|
///
|
||||||
|
/// Default Constructor
|
||||||
///
|
///
|
||||||
/// Default Constructor
|
Style::Style ()
|
||||||
///
|
: mId( "" ),
|
||||||
Style::Style ()
|
mBackendId( "" ),
|
||||||
: mId( "" ),
|
mName( "" ),
|
||||||
mBackendId( "" ),
|
mCanText( false ),
|
||||||
mName( "" ),
|
mTextOptional( false ),
|
||||||
mCanText( false ),
|
mCanChecksum( false ),
|
||||||
mTextOptional( false ),
|
mChecksumOptional( false ),
|
||||||
mCanChecksum( false ),
|
mDefaultDigits( "" ),
|
||||||
mChecksumOptional( false ),
|
mCanFreeform( false ),
|
||||||
mDefaultDigits( "" ),
|
mPreferedN( 0 )
|
||||||
mCanFreeform( false ),
|
{
|
||||||
mPreferedN( 0 )
|
// empty
|
||||||
{
|
}
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
Style::Style ( const QString& id,
|
Style::Style ( const QString& id,
|
||||||
const QString& backendId,
|
const QString& backendId,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
bool canText,
|
bool canText,
|
||||||
bool textOptional,
|
bool textOptional,
|
||||||
bool canChecksum,
|
bool canChecksum,
|
||||||
bool checksumOptional,
|
bool checksumOptional,
|
||||||
const QString& defaultDigits,
|
const QString& defaultDigits,
|
||||||
bool canFreeform,
|
bool canFreeform,
|
||||||
int preferedN )
|
int preferedN )
|
||||||
: mId( id ),
|
: mId( id ),
|
||||||
mBackendId( backendId ),
|
mBackendId( backendId ),
|
||||||
mName( name ),
|
mName( name ),
|
||||||
mCanText( canText ),
|
mCanText( canText ),
|
||||||
mTextOptional( textOptional ),
|
mTextOptional( textOptional ),
|
||||||
mCanChecksum( canChecksum ),
|
mCanChecksum( canChecksum ),
|
||||||
mChecksumOptional( checksumOptional ),
|
mChecksumOptional( checksumOptional ),
|
||||||
mDefaultDigits( defaultDigits ),
|
mDefaultDigits( defaultDigits ),
|
||||||
mCanFreeform( canFreeform ),
|
mCanFreeform( canFreeform ),
|
||||||
mPreferedN( preferedN )
|
mPreferedN( preferedN )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// ID Property Getter
|
/// ID Property Getter
|
||||||
///
|
///
|
||||||
const QString& Style::id() const
|
const QString& Style::id() const
|
||||||
{
|
{
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Full ID Property Getter
|
/// Full ID Property Getter
|
||||||
///
|
///
|
||||||
QString Style::fullId() const
|
QString Style::fullId() const
|
||||||
{
|
{
|
||||||
if ( mBackendId == "" )
|
if ( mBackendId == "" )
|
||||||
{
|
{
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return mBackendId + "::" + mId;
|
return mBackendId + "::" + mId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Backend ID Property Getter
|
/// Backend ID Property Getter
|
||||||
///
|
///
|
||||||
const QString& Style::backendId() const
|
const QString& Style::backendId() const
|
||||||
{
|
{
|
||||||
return mBackendId;
|
return mBackendId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Name Property Getter
|
/// Name Property Getter
|
||||||
///
|
///
|
||||||
const QString& Style::name() const
|
const QString& Style::name() const
|
||||||
{
|
{
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Full Name Property Getter
|
/// Full Name Property Getter
|
||||||
///
|
///
|
||||||
QString Style::fullName() const
|
QString Style::fullName() const
|
||||||
{
|
{
|
||||||
if ( mBackendId == "" )
|
if ( mBackendId == "" )
|
||||||
{
|
{
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Backends::backendName(mBackendId) + " / " + mName;
|
return Backends::backendName(mBackendId) + " / " + mName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Text Property Getter
|
/// Can Text Property Getter
|
||||||
///
|
///
|
||||||
bool Style::canText() const
|
bool Style::canText() const
|
||||||
{
|
{
|
||||||
return mCanText;
|
return mCanText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Text Optional Property Getter
|
/// Text Optional Property Getter
|
||||||
///
|
///
|
||||||
bool Style::textOptional() const
|
bool Style::textOptional() const
|
||||||
{
|
{
|
||||||
return mTextOptional;
|
return mTextOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Checksum Property Getter
|
/// Can Checksum Property Getter
|
||||||
///
|
///
|
||||||
bool Style::canChecksum() const
|
bool Style::canChecksum() const
|
||||||
{
|
{
|
||||||
return mCanChecksum;
|
return mCanChecksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Checksum Optional Property Getter
|
/// Checksum Optional Property Getter
|
||||||
///
|
///
|
||||||
bool Style::checksumOptional() const
|
bool Style::checksumOptional() const
|
||||||
{
|
{
|
||||||
return mChecksumOptional;
|
return mChecksumOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Default Digits Property Getter
|
/// Default Digits Property Getter
|
||||||
///
|
///
|
||||||
const QString& Style::defaultDigits() const
|
const QString& Style::defaultDigits() const
|
||||||
{
|
{
|
||||||
return mDefaultDigits;
|
return mDefaultDigits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Can Freeform Property Getter
|
/// Can Freeform Property Getter
|
||||||
///
|
///
|
||||||
bool Style::canFreeform() const
|
bool Style::canFreeform() const
|
||||||
{
|
{
|
||||||
return mCanFreeform;
|
return mCanFreeform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Preferred N Property Getter
|
/// Preferred N Property Getter
|
||||||
///
|
///
|
||||||
int Style::preferedN() const
|
int Style::preferedN() const
|
||||||
{
|
{
|
||||||
return mPreferedN;
|
return mPreferedN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Generate Example Digits
|
/// Generate Example Digits
|
||||||
///
|
///
|
||||||
QString Style::exampleDigits( int n ) const
|
QString Style::exampleDigits( int n ) const
|
||||||
{
|
{
|
||||||
if ( mCanFreeform )
|
if ( mCanFreeform )
|
||||||
{
|
{
|
||||||
return QString( qMax( n, 1 ), QChar('0') );
|
return QString( qMax( n, 1 ), QChar('0') );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return mDefaultDigits;
|
return mDefaultDigits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// "Not equals" operator
|
/// "Not equals" operator
|
||||||
///
|
///
|
||||||
bool Style::operator!=( const Style& other ) const
|
bool Style::operator!=( const Style& other ) const
|
||||||
{
|
{
|
||||||
return (mBackendId != other.mBackendId) || (mId != other.mId);
|
return (mBackendId != other.mBackendId) || (mId != other.mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace barcode
|
}
|
||||||
} // namespace glabels
|
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
/* Style.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Jaye 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 barcode_Style_h
|
|
||||||
#define barcode_Style_h
|
|
||||||
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace barcode
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Style Type
|
|
||||||
///
|
|
||||||
class Style
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
Style ();
|
|
||||||
|
|
||||||
Style ( const QString& id,
|
|
||||||
const QString& backendId,
|
|
||||||
const QString& name,
|
|
||||||
bool canText,
|
|
||||||
bool textOptional,
|
|
||||||
bool canChecksum,
|
|
||||||
bool checksumOptional,
|
|
||||||
const QString& defaultDigits,
|
|
||||||
bool canFreeform,
|
|
||||||
int preferedN );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Properties
|
|
||||||
/////////////////////////////////
|
|
||||||
const QString& id() const;
|
|
||||||
|
|
||||||
QString fullId() const;
|
|
||||||
|
|
||||||
const QString& backendId() const;
|
|
||||||
|
|
||||||
const QString& name() const;
|
|
||||||
|
|
||||||
QString fullName() const;
|
|
||||||
|
|
||||||
bool canText() const;
|
|
||||||
|
|
||||||
bool textOptional() const;
|
|
||||||
|
|
||||||
bool canChecksum() const;
|
|
||||||
|
|
||||||
bool checksumOptional() const;
|
|
||||||
|
|
||||||
const QString& defaultDigits() const;
|
|
||||||
|
|
||||||
bool canFreeform() const;
|
|
||||||
|
|
||||||
int preferedN() const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
QString exampleDigits( int n ) const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Operators
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
bool operator!=( const Style& other ) const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Data
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
QString mId;
|
|
||||||
QString mBackendId;
|
|
||||||
QString mName;
|
|
||||||
bool mCanText;
|
|
||||||
bool mTextOptional;
|
|
||||||
bool mCanChecksum;
|
|
||||||
bool mChecksumOptional;
|
|
||||||
QString mDefaultDigits;
|
|
||||||
bool mCanFreeform;
|
|
||||||
int mPreferedN;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // barcode_Style_h
|
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
// Style.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2013 Jaye 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 barcode_Style_hpp
|
||||||
|
#define barcode_Style_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::barcode
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Style Type
|
||||||
|
///
|
||||||
|
class Style
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
Style ();
|
||||||
|
|
||||||
|
Style ( const QString& id,
|
||||||
|
const QString& backendId,
|
||||||
|
const QString& name,
|
||||||
|
bool canText,
|
||||||
|
bool textOptional,
|
||||||
|
bool canChecksum,
|
||||||
|
bool checksumOptional,
|
||||||
|
const QString& defaultDigits,
|
||||||
|
bool canFreeform,
|
||||||
|
int preferedN );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Properties
|
||||||
|
/////////////////////////////////
|
||||||
|
const QString& id() const;
|
||||||
|
|
||||||
|
QString fullId() const;
|
||||||
|
|
||||||
|
const QString& backendId() const;
|
||||||
|
|
||||||
|
const QString& name() const;
|
||||||
|
|
||||||
|
QString fullName() const;
|
||||||
|
|
||||||
|
bool canText() const;
|
||||||
|
|
||||||
|
bool textOptional() const;
|
||||||
|
|
||||||
|
bool canChecksum() const;
|
||||||
|
|
||||||
|
bool checksumOptional() const;
|
||||||
|
|
||||||
|
const QString& defaultDigits() const;
|
||||||
|
|
||||||
|
bool canFreeform() const;
|
||||||
|
|
||||||
|
int preferedN() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
QString exampleDigits( int n ) const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Operators
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
bool operator!=( const Style& other ) const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
QString mId;
|
||||||
|
QString mBackendId;
|
||||||
|
QString mName;
|
||||||
|
bool mCanText;
|
||||||
|
bool mTextOptional;
|
||||||
|
bool mCanChecksum;
|
||||||
|
bool mChecksumOptional;
|
||||||
|
QString mDefaultDigits;
|
||||||
|
bool mCanFreeform;
|
||||||
|
int mPreferedN;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // barcode_Style_hpp
|
||||||
+1543
-1548
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ set (merge_sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
set (merge_qobject_headers
|
set (merge_qobject_headers
|
||||||
Merge.h
|
Merge.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
qt6_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
|
qt6_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
|
||||||
@@ -33,10 +33,9 @@ add_library (Merge STATIC
|
|||||||
${merge_moc_sources}
|
${merge_moc_sources}
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_compile_features (Merge
|
target_compile_features (Merge
|
||||||
# PUBLIC cxx_std_11
|
PUBLIC cxx_std_20
|
||||||
#)
|
)
|
||||||
set_property (TARGET Merge PROPERTY CXX_STANDARD 11)
|
|
||||||
|
|
||||||
target_include_directories (Merge
|
target_include_directories (Merge
|
||||||
PUBLIC ..
|
PUBLIC ..
|
||||||
|
|||||||
+187
-189
@@ -1,222 +1,220 @@
|
|||||||
/* Merge/Factory.cpp
|
// Merge/Factory.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "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
|
#include "Factory.hpp"
|
||||||
|
|
||||||
|
#include "None.hpp"
|
||||||
|
#include "TextCsv.hpp"
|
||||||
|
#include "TextCsvKeys.hpp"
|
||||||
|
#include "TextTsv.hpp"
|
||||||
|
#include "TextTsvKeys.hpp"
|
||||||
|
#include "TextColon.hpp"
|
||||||
|
#include "TextColonKeys.hpp"
|
||||||
|
#include "TextSemicolon.hpp"
|
||||||
|
#include "TextSemicolonKeys.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
{
|
{
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Static data
|
// Static data
|
||||||
//
|
//
|
||||||
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
QMap<QString,Factory::BackendEntry> Factory::mBackendIdMap;
|
||||||
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
QMap<QString,Factory::BackendEntry> Factory::mBackendNameMap;
|
||||||
QStringList Factory::mNameList;
|
QStringList Factory::mNameList;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
Factory::Factory()
|
Factory::Factory()
|
||||||
{
|
{
|
||||||
registerBackend( None::id(),
|
registerBackend( None::id(),
|
||||||
tr("None"),
|
tr("None"),
|
||||||
NONE,
|
NONE,
|
||||||
&None::create );
|
&None::create );
|
||||||
|
|
||||||
registerBackend( TextCsv::id(),
|
|
||||||
tr("Text: Comma Separated Values (CSV)"),
|
|
||||||
FILE,
|
|
||||||
&TextCsv::create );
|
|
||||||
|
|
||||||
registerBackend( TextCsvKeys::id(),
|
registerBackend( TextCsv::id(),
|
||||||
tr("Text: Comma Separated Values (CSV), keys on line 1"),
|
tr("Text: Comma Separated Values (CSV)"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextCsvKeys::create );
|
&TextCsv::create );
|
||||||
|
|
||||||
registerBackend( TextTsv::id(),
|
registerBackend( TextCsvKeys::id(),
|
||||||
tr("Text: Tab Separated Values (TSV)"),
|
tr("Text: Comma Separated Values (CSV), keys on line 1"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextTsv::create );
|
&TextCsvKeys::create );
|
||||||
|
|
||||||
registerBackend( TextTsvKeys::id(),
|
registerBackend( TextTsv::id(),
|
||||||
tr("Text: Tab Separated Values (TSV), keys on line 1"),
|
tr("Text: Tab Separated Values (TSV)"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextTsvKeys::create );
|
&TextTsv::create );
|
||||||
|
|
||||||
registerBackend( TextColon::id(),
|
registerBackend( TextTsvKeys::id(),
|
||||||
tr("Text: Colon Separated Values"),
|
tr("Text: Tab Separated Values (TSV), keys on line 1"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextColon::create );
|
&TextTsvKeys::create );
|
||||||
|
|
||||||
registerBackend( TextColonKeys::id(),
|
registerBackend( TextColon::id(),
|
||||||
tr("Text: Colon Separated Values, keys on line 1"),
|
tr("Text: Colon Separated Values"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextColonKeys::create );
|
&TextColon::create );
|
||||||
|
|
||||||
registerBackend( TextSemicolon::id(),
|
registerBackend( TextColonKeys::id(),
|
||||||
tr("Text: Semicolon Separated Values"),
|
tr("Text: Colon Separated Values, keys on line 1"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextSemicolon::create );
|
&TextColonKeys::create );
|
||||||
|
|
||||||
registerBackend( TextSemicolonKeys::id(),
|
registerBackend( TextSemicolon::id(),
|
||||||
tr("Text: Semicolon Separated Values, keys on line 1"),
|
tr("Text: Semicolon Separated Values"),
|
||||||
FILE,
|
FILE,
|
||||||
&TextSemicolonKeys::create );
|
&TextSemicolon::create );
|
||||||
}
|
|
||||||
|
registerBackend( TextSemicolonKeys::id(),
|
||||||
|
tr("Text: Semicolon Separated Values, keys on line 1"),
|
||||||
|
FILE,
|
||||||
|
&TextSemicolonKeys::create );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Initialize
|
/// Initialize
|
||||||
///
|
///
|
||||||
void Factory::init()
|
void Factory::init()
|
||||||
{
|
{
|
||||||
static Factory* singletonInstance = nullptr;
|
static Factory* singletonInstance = nullptr;
|
||||||
if ( !singletonInstance )
|
if ( !singletonInstance )
|
||||||
{
|
{
|
||||||
singletonInstance = new Factory();
|
singletonInstance = new Factory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create Merge object
|
/// Create Merge object
|
||||||
///
|
///
|
||||||
Merge* Factory::createMerge( const QString& id )
|
Merge* Factory::createMerge( const QString& id )
|
||||||
{
|
{
|
||||||
QMap<QString,BackendEntry>::iterator iBackend = mBackendIdMap.find( id );
|
QMap<QString,BackendEntry>::iterator iBackend = mBackendIdMap.find( id );
|
||||||
if ( iBackend != mBackendIdMap.end() )
|
if ( iBackend != mBackendIdMap.end() )
|
||||||
{
|
{
|
||||||
return iBackend->create();
|
return iBackend->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
return None::create();
|
return None::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get name list
|
/// Get name list
|
||||||
///
|
///
|
||||||
QStringList Factory::nameList()
|
QStringList Factory::nameList()
|
||||||
{
|
{
|
||||||
return mNameList;
|
return mNameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Convert ID to name
|
/// Convert ID to name
|
||||||
///
|
///
|
||||||
QString Factory::idToName( const QString& id )
|
QString Factory::idToName( const QString& id )
|
||||||
{
|
{
|
||||||
if ( mBackendIdMap.contains( id ) )
|
if ( mBackendIdMap.contains( id ) )
|
||||||
{
|
{
|
||||||
return mBackendIdMap[id].name;
|
return mBackendIdMap[id].name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return tr("None");
|
return tr("None");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Convert name to ID
|
/// Convert name to ID
|
||||||
///
|
///
|
||||||
QString Factory::nameToId( const QString& name )
|
QString Factory::nameToId( const QString& name )
|
||||||
{
|
{
|
||||||
if ( mBackendNameMap.contains( name ) )
|
if ( mBackendNameMap.contains( name ) )
|
||||||
{
|
{
|
||||||
return mBackendNameMap[name].id;
|
return mBackendNameMap[name].id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "None";
|
return "None";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Convert ID to type
|
/// Convert ID to type
|
||||||
///
|
///
|
||||||
Factory::SourceType Factory::idToType( const QString& id )
|
Factory::SourceType Factory::idToType( const QString& id )
|
||||||
{
|
{
|
||||||
if ( mBackendIdMap.contains( id ) )
|
if ( mBackendIdMap.contains( id ) )
|
||||||
{
|
{
|
||||||
return mBackendIdMap[id].type;
|
return mBackendIdMap[id].type;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NONE;
|
return NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Lookup ID from index
|
/// Lookup ID from index
|
||||||
///
|
///
|
||||||
QString Factory::indexToId( int index )
|
QString Factory::indexToId( int index )
|
||||||
{
|
{
|
||||||
if ( (index > 0) && (index < mNameList.size()) )
|
if ( (index > 0) && (index < mNameList.size()) )
|
||||||
{
|
{
|
||||||
QString name = mNameList[index];
|
QString name = mNameList[index];
|
||||||
|
|
||||||
return mBackendNameMap[ name ].id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "None";
|
return mBackendNameMap[ name ].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "None";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Register backend
|
/// Register backend
|
||||||
///
|
///
|
||||||
void Factory::registerBackend( const QString& id,
|
void Factory::registerBackend( const QString& id,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
SourceType type,
|
SourceType type,
|
||||||
CreateFct create )
|
CreateFct create )
|
||||||
{
|
{
|
||||||
BackendEntry backend;
|
BackendEntry backend;
|
||||||
|
|
||||||
backend.id = id;
|
backend.id = id;
|
||||||
backend.name = name;
|
backend.name = name;
|
||||||
backend.type = type;
|
backend.type = type;
|
||||||
backend.create = create;
|
backend.create = create;
|
||||||
|
|
||||||
mBackendIdMap[ id ] = backend;
|
|
||||||
mBackendNameMap[ name ] = backend;
|
|
||||||
|
|
||||||
mNameList << name;
|
mBackendIdMap[ id ] = backend;
|
||||||
}
|
mBackendNameMap[ name ] = backend;
|
||||||
|
|
||||||
} // namespace merge
|
mNameList << name;
|
||||||
} // namespace glabels
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
/* Merge/Factory.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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:
|
|
||||||
using CreateFct = Merge* (*)();
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
// Merge/Factory.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_hpp
|
||||||
|
#define merge_Factory_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#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:
|
||||||
|
using CreateFct = Merge* (*)();
|
||||||
|
|
||||||
|
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_hpp
|
||||||
+167
-170
@@ -1,201 +1,198 @@
|
|||||||
/* Merge/Merge.cpp
|
// Merge/Merge.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2015-2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2015-2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "Merge.h"
|
#include "Merge.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels::merge
|
||||||
{
|
{
|
||||||
namespace merge
|
|
||||||
{
|
///
|
||||||
|
/// Constructor
|
||||||
///
|
///
|
||||||
/// Constructor
|
Merge::Merge( const Merge* merge )
|
||||||
///
|
: mId(merge->mId),
|
||||||
Merge::Merge( const Merge* merge )
|
mSource(merge->mSource),
|
||||||
: mId(merge->mId),
|
mRecordList(merge->mRecordList)
|
||||||
mSource(merge->mSource),
|
{
|
||||||
mRecordList(merge->mRecordList)
|
}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get id
|
/// Get id
|
||||||
///
|
///
|
||||||
QString Merge::id() const
|
QString Merge::id() const
|
||||||
{
|
{
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get source
|
/// Get source
|
||||||
///
|
///
|
||||||
QString Merge::source() const
|
QString Merge::source() const
|
||||||
{
|
{
|
||||||
return mSource;
|
return mSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set source
|
/// Set source
|
||||||
///
|
///
|
||||||
void Merge::setSource( const QString& source )
|
void Merge::setSource( const QString& source )
|
||||||
{
|
{
|
||||||
mSource = source;
|
mSource = source;
|
||||||
|
|
||||||
// Clear out any old records
|
// Clear out any old records
|
||||||
mRecordList.clear();
|
mRecordList.clear();
|
||||||
|
|
||||||
open();
|
open();
|
||||||
for ( Record record = readNextRecord(); !record.isEmpty(); record = readNextRecord() )
|
for ( Record record = readNextRecord(); !record.isEmpty(); record = readNextRecord() )
|
||||||
{
|
{
|
||||||
mRecordList.push_back( record );
|
mRecordList.push_back( record );
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
|
|
||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Reload source
|
/// Reload source
|
||||||
///
|
///
|
||||||
void Merge::reloadSource()
|
void Merge::reloadSource()
|
||||||
{
|
{
|
||||||
// temporary map of original selections
|
// temporary map of original selections
|
||||||
QMap<QString,bool> origSelectionMap;
|
QMap<QString,bool> origSelectionMap;
|
||||||
|
|
||||||
for ( auto& record : mRecordList )
|
for ( auto& record : mRecordList )
|
||||||
{
|
{
|
||||||
origSelectionMap[ record[ primaryKey() ] ] = record.isSelected();
|
origSelectionMap[ record[ primaryKey() ] ] = record.isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the original records
|
// Clear the original records
|
||||||
mRecordList.clear();
|
mRecordList.clear();
|
||||||
|
|
||||||
// Read the new records, preserve any original selections
|
// Read the new records, preserve any original selections
|
||||||
open();
|
open();
|
||||||
for ( Record record = readNextRecord(); !record.isEmpty(); record = readNextRecord() )
|
for ( Record record = readNextRecord(); !record.isEmpty(); record = readNextRecord() )
|
||||||
{
|
{
|
||||||
auto key = record[ primaryKey() ];
|
auto key = record[ primaryKey() ];
|
||||||
auto it = origSelectionMap.find( key );
|
auto it = origSelectionMap.find( key );
|
||||||
if ( it != origSelectionMap.end() )
|
if ( it != origSelectionMap.end() )
|
||||||
{
|
{
|
||||||
record.setSelected( it.value() );
|
record.setSelected( it.value() );
|
||||||
}
|
}
|
||||||
|
|
||||||
mRecordList.push_back( record );
|
mRecordList.push_back( record );
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
|
|
||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get record list
|
/// Get record list
|
||||||
///
|
///
|
||||||
const QList<Record>& Merge::recordList( ) const
|
const QList<Record>& Merge::recordList( ) const
|
||||||
{
|
{
|
||||||
return mRecordList;
|
return mRecordList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Select/unselect i'th record
|
/// Select/unselect i'th record
|
||||||
///
|
///
|
||||||
void Merge::setSelected( int i, bool state )
|
void Merge::setSelected( int i, bool state )
|
||||||
{
|
{
|
||||||
if ( (i >= 0) && (i < mRecordList.size()) )
|
if ( (i >= 0) && (i < mRecordList.size()) )
|
||||||
{
|
{
|
||||||
mRecordList[i].setSelected( state );
|
mRecordList[i].setSelected( state );
|
||||||
emit selectionChanged();
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Select all records
|
/// Select all records
|
||||||
///
|
///
|
||||||
void Merge::selectAll()
|
void Merge::selectAll()
|
||||||
{
|
{
|
||||||
for ( auto& record : mRecordList )
|
for ( auto& record : mRecordList )
|
||||||
{
|
{
|
||||||
record.setSelected( true );
|
record.setSelected( true );
|
||||||
}
|
}
|
||||||
emit selectionChanged();
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Unselect all records
|
|
||||||
///
|
|
||||||
void Merge::unselectAll()
|
|
||||||
{
|
|
||||||
for ( auto& record : mRecordList )
|
|
||||||
{
|
|
||||||
record.setSelected( false );
|
|
||||||
}
|
|
||||||
emit selectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Return count of selected records
|
|
||||||
///
|
|
||||||
int Merge::nSelectedRecords() const
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for ( const auto& record : mRecordList )
|
|
||||||
{
|
|
||||||
if ( record.isSelected() )
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Return list of selected records
|
/// Unselect all records
|
||||||
///
|
///
|
||||||
const QList<Record> Merge::selectedRecords() const
|
void Merge::unselectAll()
|
||||||
{
|
{
|
||||||
QList<Record> list;
|
for ( auto& record : mRecordList )
|
||||||
|
{
|
||||||
|
record.setSelected( false );
|
||||||
|
}
|
||||||
|
emit selectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
for ( const auto& record : mRecordList )
|
|
||||||
{
|
|
||||||
if ( record.isSelected() )
|
|
||||||
{
|
|
||||||
list.append( record );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
///
|
||||||
}
|
/// Return count of selected records
|
||||||
|
///
|
||||||
|
int Merge::nSelectedRecords() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
} // namespace merge
|
for ( const auto& record : mRecordList )
|
||||||
} // namespace glabels
|
{
|
||||||
|
if ( record.isSelected() )
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return list of selected records
|
||||||
|
///
|
||||||
|
const QList<Record> Merge::selectedRecords() const
|
||||||
|
{
|
||||||
|
QList<Record> list;
|
||||||
|
|
||||||
|
for ( const auto& record : mRecordList )
|
||||||
|
{
|
||||||
|
if ( record.isSelected() )
|
||||||
|
{
|
||||||
|
list.append( record );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
/* Merge/Merge.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015-2016 Jaye 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 "Record.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
// Forward references
|
|
||||||
class Record;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Merge Object
|
|
||||||
///
|
|
||||||
class Merge : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
protected:
|
|
||||||
Merge() = default;
|
|
||||||
Merge( const Merge* merge );
|
|
||||||
public:
|
|
||||||
virtual ~Merge() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
virtual Merge* clone() const = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Properties
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
QString id() const;
|
|
||||||
QString source() const;
|
|
||||||
void setSource( const QString& source );
|
|
||||||
void reloadSource();
|
|
||||||
|
|
||||||
const QList<Record>& recordList( ) const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Selection methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
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
|
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
// Merge/Merge.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2015-2016 Jaye 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_hpp
|
||||||
|
#define merge_Merge_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Record.hpp"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward references
|
||||||
|
class Record;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Merge Object
|
||||||
|
///
|
||||||
|
class Merge : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
protected:
|
||||||
|
Merge() = default;
|
||||||
|
Merge( const Merge* merge );
|
||||||
|
public:
|
||||||
|
virtual ~Merge() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
virtual Merge* clone() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Properties
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
QString id() const;
|
||||||
|
QString source() const;
|
||||||
|
void setSource( const QString& source );
|
||||||
|
void reloadSource();
|
||||||
|
|
||||||
|
const QList<Record>& recordList( ) const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Selection methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
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_hpp
|
||||||
+92
-94
@@ -1,117 +1,115 @@
|
|||||||
/* Merge/None.cpp
|
// Merge/None.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2015-2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2015-2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "None.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "None.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
{
|
{
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
None::None() : Merge()
|
None::None() : Merge()
|
||||||
{
|
{
|
||||||
mId = "None";
|
mId = "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
None::None( const None* merge ) : Merge( merge )
|
None::None( const None* merge ) : Merge( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
None* None::clone() const
|
None* None::clone() const
|
||||||
{
|
{
|
||||||
return new None( this );
|
return new None( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString None::id()
|
QString None::id()
|
||||||
{
|
{
|
||||||
return "None";
|
return "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* None::create()
|
Merge* None::create()
|
||||||
{
|
{
|
||||||
return new None();
|
return new None();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get key list
|
/// Get key list
|
||||||
///
|
///
|
||||||
QStringList None::keys() const
|
QStringList None::keys() const
|
||||||
{
|
{
|
||||||
QStringList emptyList;
|
QStringList emptyList;
|
||||||
return emptyList;
|
return emptyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get primary key
|
/// Get primary key
|
||||||
///
|
///
|
||||||
QString None::primaryKey() const
|
QString None::primaryKey() const
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Open source
|
/// Open source
|
||||||
///
|
///
|
||||||
void None::open()
|
void None::open()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Close source
|
/// Close source
|
||||||
///
|
///
|
||||||
void None::close()
|
void None::close()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Read next record
|
/// Read next record
|
||||||
///
|
///
|
||||||
Record None::readNextRecord()
|
Record None::readNextRecord()
|
||||||
{
|
{
|
||||||
return NullRecord();
|
return NullRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
}
|
||||||
} // namespace glabels
|
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
/* Merge/None.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015-2016 Jaye 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_None_h
|
|
||||||
#define merge_None_h
|
|
||||||
|
|
||||||
#include "Merge.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// None Merge Backend
|
|
||||||
///
|
|
||||||
struct None : public Merge
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
None();
|
|
||||||
None( const None* merge );
|
|
||||||
virtual ~None() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
None* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Implementation of virtual methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
QStringList keys() const override;
|
|
||||||
QString primaryKey() const override;
|
|
||||||
protected:
|
|
||||||
void open() override;
|
|
||||||
void close() override;
|
|
||||||
Record readNextRecord() override;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_None_h
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
// Merge/None.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2015-2016 Jaye 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_None_hpp
|
||||||
|
#define merge_None_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Merge.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// None Merge Backend
|
||||||
|
///
|
||||||
|
struct None : public Merge
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
None();
|
||||||
|
None( const None* merge );
|
||||||
|
virtual ~None() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
None* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Implementation of virtual methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
QStringList keys() const override;
|
||||||
|
QString primaryKey() const override;
|
||||||
|
protected:
|
||||||
|
void open() override;
|
||||||
|
void close() override;
|
||||||
|
Record readNextRecord() override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_None_hpp
|
||||||
+38
-40
@@ -1,47 +1,45 @@
|
|||||||
/* Merge/Record.cpp
|
// Merge/Record.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2013-2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2013-2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "Record.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "Record.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
{
|
{
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Is record selected?
|
/// Is record selected?
|
||||||
///
|
///
|
||||||
bool Record::isSelected() const
|
bool Record::isSelected() const
|
||||||
{
|
{
|
||||||
return mSelected;
|
return mSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set selected on not selected
|
/// Set selected on not selected
|
||||||
///
|
///
|
||||||
void Record::setSelected( bool value )
|
void Record::setSelected( bool value )
|
||||||
{
|
{
|
||||||
mSelected = value;
|
mSelected = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
}
|
||||||
} // namespace glabels
|
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
/* Merge/Record.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013-2016 Jaye 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_Record_h
|
|
||||||
#define merge_Record_h
|
|
||||||
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Merge Record
|
|
||||||
///
|
|
||||||
class Record : public QMap<QString,QString>
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Properties
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
bool isSelected() const;
|
|
||||||
void setSelected( bool value );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private data
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
bool mSelected{ true };
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
using NullRecord = const Record;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_Record_h
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
// Merge/Record.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2013-2016 Jaye 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_Record_hpp
|
||||||
|
#define merge_Record_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Merge Record
|
||||||
|
///
|
||||||
|
class Record : public QMap<QString,QString>
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Properties
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
bool isSelected() const;
|
||||||
|
void setSelected( bool value );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
bool mSelected{ true };
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
using NullRecord = const Record;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_Record_hpp
|
||||||
+370
-373
@@ -1,419 +1,416 @@
|
|||||||
/* Merge/Text.cpp
|
// Merge/Text.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "Text.h"
|
#include "Text.hpp"
|
||||||
|
|
||||||
#include "Record.h"
|
#include "Record.hpp"
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels::merge
|
||||||
{
|
{
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
Text::Text( QChar delimiter, bool line1HasKeys )
|
Text::Text( QChar delimiter, bool line1HasKeys )
|
||||||
: Merge(),
|
: Merge(),
|
||||||
mDelimeter(delimiter),
|
mDelimeter(delimiter),
|
||||||
mLine1HasKeys(line1HasKeys),
|
mLine1HasKeys(line1HasKeys),
|
||||||
mNFieldsMax(0)
|
mNFieldsMax(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
Text::Text( const Text* merge )
|
Text::Text( const Text* merge )
|
||||||
: Merge( merge ),
|
: Merge( merge ),
|
||||||
mDelimeter(merge->mDelimeter),
|
mDelimeter(merge->mDelimeter),
|
||||||
mLine1HasKeys(merge->mLine1HasKeys),
|
mLine1HasKeys(merge->mLine1HasKeys),
|
||||||
mKeys(merge->mKeys),
|
mKeys(merge->mKeys),
|
||||||
mNFieldsMax(merge->mNFieldsMax)
|
mNFieldsMax(merge->mNFieldsMax)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get key list
|
/// Get key list
|
||||||
///
|
///
|
||||||
QStringList Text::keys() const
|
QStringList Text::keys() const
|
||||||
{
|
{
|
||||||
QStringList keys;
|
QStringList keys;
|
||||||
for ( int iField = 0; iField < mNFieldsMax; iField++ )
|
for ( int iField = 0; iField < mNFieldsMax; iField++ )
|
||||||
{
|
{
|
||||||
keys << keyFromIndex(iField);
|
keys << keyFromIndex(iField);
|
||||||
}
|
}
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get primary key
|
/// Get primary key
|
||||||
///
|
///
|
||||||
QString Text::primaryKey() const
|
QString Text::primaryKey() const
|
||||||
{
|
{
|
||||||
return keyFromIndex(0);
|
return keyFromIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Open source
|
/// Open source
|
||||||
///
|
///
|
||||||
void Text::open()
|
void Text::open()
|
||||||
{
|
{
|
||||||
mKeys.clear();
|
mKeys.clear();
|
||||||
mNFieldsMax = 0;
|
mNFieldsMax = 0;
|
||||||
|
|
||||||
mFile.setFileName( source() );
|
mFile.setFileName( source() );
|
||||||
if (mFile.open( QIODevice::ReadOnly|QIODevice::Text ))
|
if (mFile.open( QIODevice::ReadOnly|QIODevice::Text ))
|
||||||
{
|
{
|
||||||
if ( mLine1HasKeys )
|
if ( mLine1HasKeys )
|
||||||
{
|
{
|
||||||
mKeys = parseLine();
|
mKeys = parseLine();
|
||||||
if ( (mKeys.size() == 1) && (mKeys[0] == "") )
|
if ( (mKeys.size() == 1) && (mKeys[0] == "") )
|
||||||
{
|
{
|
||||||
mKeys.clear();
|
mKeys.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mNFieldsMax = mKeys.size();
|
mNFieldsMax = mKeys.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Close source
|
/// Close source
|
||||||
///
|
///
|
||||||
void Text::close()
|
void Text::close()
|
||||||
{
|
{
|
||||||
if ( mFile.isOpen() )
|
if ( mFile.isOpen() )
|
||||||
{
|
{
|
||||||
mFile.close();
|
mFile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Read next record
|
/// Read next record
|
||||||
///
|
///
|
||||||
Record Text::readNextRecord()
|
Record Text::readNextRecord()
|
||||||
{
|
{
|
||||||
QStringList values = parseLine();
|
QStringList values = parseLine();
|
||||||
if ( !values.isEmpty() )
|
if ( !values.isEmpty() )
|
||||||
{
|
{
|
||||||
Record record;
|
Record record;
|
||||||
|
|
||||||
int iField = 0;
|
int iField = 0;
|
||||||
for ( const auto& value : values )
|
for ( const auto& value : values )
|
||||||
{
|
{
|
||||||
record[ keyFromIndex(iField) ] = value;
|
record[ keyFromIndex(iField) ] = value;
|
||||||
iField++;
|
iField++;
|
||||||
}
|
}
|
||||||
mNFieldsMax = std::max( mNFieldsMax, iField );
|
mNFieldsMax = std::max( mNFieldsMax, iField );
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NullRecord();
|
return NullRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Key from field index
|
/// Key from field index
|
||||||
///
|
///
|
||||||
QString Text::keyFromIndex( int iField ) const
|
QString Text::keyFromIndex( int iField ) const
|
||||||
{
|
{
|
||||||
if ( mLine1HasKeys && ( iField < mKeys.size() ) )
|
if ( mLine1HasKeys && ( iField < mKeys.size() ) )
|
||||||
{
|
{
|
||||||
return mKeys[iField];
|
return mKeys[iField];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QString::number( iField+1 );
|
return QString::number( iField+1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Parse line.
|
/// Parse line.
|
||||||
///
|
///
|
||||||
/// Attempt to be a robust parser of various CSV (and similar) formats.
|
/// Attempt to be a robust parser of various CSV (and similar) formats.
|
||||||
///
|
///
|
||||||
/// Based on CSV format described in RFC 4180 section 2.
|
/// Based on CSV format described in RFC 4180 section 2.
|
||||||
///
|
///
|
||||||
/// Additions to RFC 4180 rules:
|
/// Additions to RFC 4180 rules:
|
||||||
/// - delimeters and other special characters may be "escaped" by a leading
|
/// - delimeters and other special characters may be "escaped" by a leading
|
||||||
/// backslash (\)
|
/// backslash (\)
|
||||||
/// - C escape sequences for newline (\n) and tab (\t) are also translated.
|
/// - 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
|
/// - if quoted text is not followed by a delimeter, any additional text is
|
||||||
/// concatenated with quoted portion.
|
/// concatenated with quoted portion.
|
||||||
///
|
///
|
||||||
/// Returns a list of fields. A blank line is considered a line with one
|
/// Returns a list of fields. A blank line is considered a line with one
|
||||||
/// empty field. Returns an empty list when done.
|
/// empty field. Returns an empty list when done.
|
||||||
///
|
///
|
||||||
QStringList Text::parseLine()
|
QStringList Text::parseLine()
|
||||||
{
|
{
|
||||||
QStringList fields;
|
QStringList fields;
|
||||||
|
|
||||||
enum State
|
|
||||||
{
|
|
||||||
DELIM, QUOTED, QUOTED_QUOTE1, QUOTED_ESCAPED, SIMPLE, SIMPLE_ESCAPED, DONE
|
|
||||||
} state = DELIM;
|
|
||||||
|
|
||||||
QByteArray field;
|
enum State
|
||||||
|
{
|
||||||
while ( state != DONE )
|
DELIM, QUOTED, QUOTED_QUOTE1, QUOTED_ESCAPED, SIMPLE, SIMPLE_ESCAPED, DONE
|
||||||
{
|
} state = DELIM;
|
||||||
char c;
|
|
||||||
if ( mFile.getChar( &c ) )
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
|
|
||||||
case DELIM:
|
QByteArray field;
|
||||||
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
|
|
||||||
{
|
|
||||||
/* beginning of a simple field. */
|
|
||||||
field.append( c );
|
|
||||||
state = SIMPLE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QUOTED:
|
while ( state != DONE )
|
||||||
switch (c)
|
{
|
||||||
{
|
char c;
|
||||||
case '"':
|
if ( mFile.getChar( &c ) )
|
||||||
/* Possible end of field, but could be 1st of a pair. */
|
{
|
||||||
state = QUOTED_QUOTE1;
|
switch (state)
|
||||||
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:
|
case DELIM:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '\n':
|
case '\n':
|
||||||
/* line ended after quoted item */
|
/* last field is empty. */
|
||||||
fields << QString( field );
|
fields << "";
|
||||||
state = DONE;
|
state = DONE;
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '\r':
|
||||||
/* second quote, insert and stay quoted. */
|
/* ignore */
|
||||||
field.append( c );
|
state = DELIM;
|
||||||
state = QUOTED;
|
break;
|
||||||
break;
|
case '"':
|
||||||
case '\r':
|
/* start a quoted field. */
|
||||||
/* ignore and go to fallback */
|
state = QUOTED;
|
||||||
state = SIMPLE;
|
break;
|
||||||
break;
|
case '\\':
|
||||||
default:
|
/* simple field, but 1st character is an escape. */
|
||||||
if ( c == mDelimeter )
|
state = SIMPLE_ESCAPED;
|
||||||
{
|
break;
|
||||||
/* end of field. */
|
default:
|
||||||
fields << QString( field );
|
if ( c == mDelimeter )
|
||||||
field.clear();
|
{
|
||||||
state = DELIM;
|
/* field is empty. */
|
||||||
}
|
fields << "";
|
||||||
else
|
state = DELIM;
|
||||||
{
|
}
|
||||||
/* fallback if not a delim or another quote. */
|
else
|
||||||
field.append( c );
|
{
|
||||||
state = SIMPLE;
|
/* beginning of a simple field. */
|
||||||
}
|
field.append( c );
|
||||||
break;
|
state = SIMPLE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case QUOTED_ESCAPED:
|
case QUOTED:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'n':
|
case '"':
|
||||||
/* Decode "\n" as newline. */
|
/* Possible end of field, but could be 1st of a pair. */
|
||||||
field.append( '\n' );
|
state = QUOTED_QUOTE1;
|
||||||
state = QUOTED;
|
break;
|
||||||
break;
|
case '\\':
|
||||||
case 't':
|
/* Escape next character, or special escape, e.g. \n. */
|
||||||
/* Decode "\t" as tab. */
|
state = QUOTED_ESCAPED;
|
||||||
field.append( '\t' );
|
break;
|
||||||
state = QUOTED;
|
default:
|
||||||
break;
|
/* Use character literally. */
|
||||||
default:
|
field.append( c );
|
||||||
/* Use character literally. */
|
break;
|
||||||
field.append( c );
|
}
|
||||||
state = QUOTED;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SIMPLE:
|
case QUOTED_QUOTE1:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '\n':
|
case '\n':
|
||||||
/* line ended */
|
/* line ended after quoted item */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
state = DONE;
|
state = DONE;
|
||||||
break;
|
break;
|
||||||
case '\r':
|
case '"':
|
||||||
/* ignore */
|
/* second quote, insert and stay quoted. */
|
||||||
state = SIMPLE;
|
field.append( c );
|
||||||
break;
|
state = QUOTED;
|
||||||
case '\\':
|
break;
|
||||||
/* Escape next character, or special escape, e.g. \n. */
|
case '\r':
|
||||||
state = SIMPLE_ESCAPED;
|
/* ignore and go to fallback */
|
||||||
break;
|
state = SIMPLE;
|
||||||
default:
|
break;
|
||||||
if ( c == mDelimeter )
|
default:
|
||||||
{
|
if ( c == mDelimeter )
|
||||||
/* end of field. */
|
{
|
||||||
fields << QString( field );
|
/* end of field. */
|
||||||
field.clear();
|
fields << QString( field );
|
||||||
state = DELIM;
|
field.clear();
|
||||||
}
|
state = DELIM;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
/* Use character literally. */
|
{
|
||||||
field.append( c );
|
/* fallback if not a delim or another quote. */
|
||||||
state = SIMPLE;
|
field.append( c );
|
||||||
}
|
state = SIMPLE;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SIMPLE_ESCAPED:
|
case QUOTED_ESCAPED:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'n':
|
case 'n':
|
||||||
/* Decode "\n" as newline. */
|
/* Decode "\n" as newline. */
|
||||||
field.append( '\n' );
|
field.append( '\n' );
|
||||||
state = SIMPLE;
|
state = QUOTED;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
/* Decode "\t" as tab. */
|
/* Decode "\t" as tab. */
|
||||||
field.append( '\t' );
|
field.append( '\t' );
|
||||||
state = SIMPLE;
|
state = QUOTED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Use character literally. */
|
/* Use character literally. */
|
||||||
field.append( (char)c );
|
field.append( c );
|
||||||
state = SIMPLE;
|
state = QUOTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case SIMPLE:
|
||||||
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
|
switch (c)
|
||||||
break;
|
{
|
||||||
}
|
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:
|
||||||
else
|
switch (c)
|
||||||
{
|
{
|
||||||
/* Handle EOF (could also be an error while reading). */
|
case 'n':
|
||||||
switch (state)
|
/* 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;
|
||||||
|
|
||||||
case DELIM:
|
default:
|
||||||
/* EOF, no more lines. */
|
qWarning( "merge::Text::parseLine()::Should not be reached! #1" );
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case QUOTED:
|
}
|
||||||
/* File ended midway through quoted item. Truncate field. */
|
else
|
||||||
fields << QString( field );
|
{
|
||||||
break;
|
/* Handle EOF (could also be an error while reading). */
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
|
||||||
case QUOTED_QUOTE1:
|
case DELIM:
|
||||||
/* File ended after quoted item. */
|
/* EOF, no more lines. */
|
||||||
fields << QString( field );
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case QUOTED_ESCAPED:
|
case QUOTED:
|
||||||
/* File ended midway through quoted item. Truncate field. */
|
/* File ended midway through quoted item. Truncate field. */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIMPLE:
|
case QUOTED_QUOTE1:
|
||||||
/* File ended after simple item. */
|
/* File ended after quoted item. */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIMPLE_ESCAPED:
|
case QUOTED_ESCAPED:
|
||||||
/* File ended midway through escaped item. */
|
/* File ended midway through quoted item. Truncate field. */
|
||||||
fields << QString( field );
|
fields << QString( field );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case SIMPLE:
|
||||||
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
|
/* File ended after simple item. */
|
||||||
break;
|
fields << QString( field );
|
||||||
}
|
break;
|
||||||
|
|
||||||
state = DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return fields;
|
case SIMPLE_ESCAPED:
|
||||||
}
|
/* File ended midway through escaped item. */
|
||||||
|
fields << QString( field );
|
||||||
|
break;
|
||||||
|
|
||||||
} // namespace merge
|
default:
|
||||||
} // namespace glabels
|
qWarning( "merge::Text::parseLine()::Should not be reached! #2" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = DONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
/* Merge/Text.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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 );
|
|
||||||
virtual ~Text() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// 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
|
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// Merge/Text.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_hpp
|
||||||
|
#define merge_Text_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Merge.hpp"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Text Merge Backend
|
||||||
|
///
|
||||||
|
struct Text : public Merge
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
protected:
|
||||||
|
Text( QChar delimiter, bool line1HasKeys );
|
||||||
|
Text( const Text* merge );
|
||||||
|
virtual ~Text() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// 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_hpp
|
||||||
@@ -1,76 +1,77 @@
|
|||||||
/* Merge/TextColon.cpp
|
// Merge/TextColon.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "TextColon.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "TextColon.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
namespace merge
|
static const QString ID = "Text/Colon";
|
||||||
{
|
}
|
||||||
|
|
||||||
static const QString ID = "Text/Colon";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels::merge
|
||||||
/// Constructor
|
{
|
||||||
///
|
|
||||||
TextColon::TextColon() : Text(':',false)
|
///
|
||||||
{
|
/// Constructor
|
||||||
mId = ID;
|
///
|
||||||
}
|
TextColon::TextColon() : Text(':',false)
|
||||||
|
{
|
||||||
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextColon::TextColon( const TextColon* merge ) : Text( merge )
|
TextColon::TextColon( const TextColon* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
TextColon* TextColon::clone() const
|
TextColon* TextColon::clone() const
|
||||||
{
|
{
|
||||||
return new TextColon( this );
|
return new TextColon( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString TextColon::id()
|
QString TextColon::id()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* TextColon::create()
|
Merge* TextColon::create()
|
||||||
{
|
{
|
||||||
return new TextColon();
|
return new TextColon();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
}
|
||||||
} // namespace glabels
|
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Merge/TextColon.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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_TextColon_h
|
|
||||||
#define merge_TextColon_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Text.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// TextColon Merge Backend
|
|
||||||
///
|
|
||||||
struct TextColon : public Text
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
TextColon();
|
|
||||||
TextColon( const TextColon* merge );
|
|
||||||
virtual ~TextColon() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
TextColon* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextColon_h
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Merge/TextColon.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_TextColon_hpp
|
||||||
|
#define merge_TextColon_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Text.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// TextColon Merge Backend
|
||||||
|
///
|
||||||
|
struct TextColon : public Text
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextColon();
|
||||||
|
TextColon( const TextColon* merge );
|
||||||
|
virtual ~TextColon() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
TextColon* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_TextColon_hpp
|
||||||
@@ -1,76 +1,77 @@
|
|||||||
/* Merge/TextColonKeys.cpp
|
// Merge/TextColonKeys.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "TextColonKeys.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "TextColonKeys.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
namespace merge
|
static const QString ID = "Text/Colon/Line1Keys";
|
||||||
{
|
}
|
||||||
|
|
||||||
static const QString ID = "Text/Colon/Line1Keys";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextColonKeys::TextColonKeys() : Text(':',true)
|
|
||||||
{
|
|
||||||
mId = ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels::merge
|
||||||
/// Constructor
|
{
|
||||||
///
|
|
||||||
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
|
///
|
||||||
{
|
/// Constructor
|
||||||
}
|
///
|
||||||
|
TextColonKeys::TextColonKeys() : Text(':',true)
|
||||||
|
{
|
||||||
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextColonKeys* TextColonKeys::clone() const
|
TextColonKeys::TextColonKeys( const TextColonKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
return new TextColonKeys( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextColonKeys::id()
|
TextColonKeys* TextColonKeys::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextColonKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextColonKeys::create()
|
QString TextColonKeys::id()
|
||||||
{
|
{
|
||||||
return new TextColonKeys();
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
|
||||||
} // namespace glabels
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextColonKeys::create()
|
||||||
|
{
|
||||||
|
return new TextColonKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Merge/TextColonKeys.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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_TextColonKeys_h
|
|
||||||
#define merge_TextColonKeys_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Text.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// TextColonKeys Merge Backend
|
|
||||||
///
|
|
||||||
struct TextColonKeys : public Text
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
TextColonKeys();
|
|
||||||
TextColonKeys( const TextColonKeys* merge );
|
|
||||||
virtual ~TextColonKeys() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
TextColonKeys* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextColonKeys_h
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Merge/TextColonKeys.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_TextColonKeys_hpp
|
||||||
|
#define merge_TextColonKeys_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Text.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// TextColonKeys Merge Backend
|
||||||
|
///
|
||||||
|
struct TextColonKeys : public Text
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextColonKeys();
|
||||||
|
TextColonKeys( const TextColonKeys* merge );
|
||||||
|
virtual ~TextColonKeys() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
TextColonKeys* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_TextColonKeys_hpp
|
||||||
+65
-64
@@ -1,76 +1,77 @@
|
|||||||
/* Merge/TextCsv.cpp
|
// Merge/TextCsv.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "TextCsv.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "TextCsv.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
namespace merge
|
static const QString ID = "Text/Comma";
|
||||||
{
|
}
|
||||||
|
|
||||||
static const QString ID = "Text/Comma";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextCsv::TextCsv() : Text(',',false)
|
|
||||||
{
|
|
||||||
mId = ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels::merge
|
||||||
/// Constructor
|
{
|
||||||
///
|
|
||||||
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
|
///
|
||||||
{
|
/// Constructor
|
||||||
}
|
///
|
||||||
|
TextCsv::TextCsv() : Text(',',false)
|
||||||
|
{
|
||||||
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsv* TextCsv::clone() const
|
TextCsv::TextCsv( const TextCsv* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
return new TextCsv( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextCsv::id()
|
TextCsv* TextCsv::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextCsv( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextCsv::create()
|
QString TextCsv::id()
|
||||||
{
|
{
|
||||||
return new TextCsv();
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
|
||||||
} // namespace glabels
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextCsv::create()
|
||||||
|
{
|
||||||
|
return new TextCsv();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Merge/TextCsv.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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_TextCsv_h
|
|
||||||
#define merge_TextCsv_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Text.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// TextCsv Merge Backend
|
|
||||||
///
|
|
||||||
struct TextCsv : public Text
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
TextCsv();
|
|
||||||
TextCsv( const TextCsv* merge );
|
|
||||||
virtual ~TextCsv() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
TextCsv* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextCsv_h
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Merge/TextCsv.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_TextCsv_hpp
|
||||||
|
#define merge_TextCsv_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Text.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// TextCsv Merge Backend
|
||||||
|
///
|
||||||
|
struct TextCsv : public Text
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextCsv();
|
||||||
|
TextCsv( const TextCsv* merge );
|
||||||
|
virtual ~TextCsv() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
TextCsv* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_TextCsv_hpp
|
||||||
@@ -1,76 +1,77 @@
|
|||||||
/* Merge/TextCsvKeys.cpp
|
// Merge/TextCsvKeys.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "TextCsvKeys.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "TextCsvKeys.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
namespace merge
|
static const QString ID = "Text/Comma/Line1Keys";
|
||||||
{
|
}
|
||||||
|
|
||||||
static const QString ID = "Text/Comma/Line1Keys";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextCsvKeys::TextCsvKeys() : Text(',',true)
|
|
||||||
{
|
|
||||||
mId = ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels::merge
|
||||||
/// Constructor
|
{
|
||||||
///
|
|
||||||
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
|
///
|
||||||
{
|
/// Constructor
|
||||||
}
|
///
|
||||||
|
TextCsvKeys::TextCsvKeys() : Text(',',true)
|
||||||
|
{
|
||||||
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextCsvKeys* TextCsvKeys::clone() const
|
TextCsvKeys::TextCsvKeys( const TextCsvKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
return new TextCsvKeys( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextCsvKeys::id()
|
TextCsvKeys* TextCsvKeys::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextCsvKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextCsvKeys::create()
|
QString TextCsvKeys::id()
|
||||||
{
|
{
|
||||||
return new TextCsvKeys();
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
|
||||||
} // namespace glabels
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextCsvKeys::create()
|
||||||
|
{
|
||||||
|
return new TextCsvKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Merge/TextCsvKeys.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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_TextCsvKeys_h
|
|
||||||
#define merge_TextCsvKeys_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Text.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// TextCsvKeys Merge Backend
|
|
||||||
///
|
|
||||||
struct TextCsvKeys : public Text
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
TextCsvKeys();
|
|
||||||
TextCsvKeys( const TextCsvKeys* merge );
|
|
||||||
virtual ~TextCsvKeys() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
TextCsvKeys* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextCsvKeys_h
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Merge/TextCsvKeys.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_TextCsvKeys_hpp
|
||||||
|
#define merge_TextCsvKeys_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Text.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// TextCsvKeys Merge Backend
|
||||||
|
///
|
||||||
|
struct TextCsvKeys : public Text
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextCsvKeys();
|
||||||
|
TextCsvKeys( const TextCsvKeys* merge );
|
||||||
|
virtual ~TextCsvKeys() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
TextCsvKeys* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_TextCsvKeys_hpp
|
||||||
@@ -1,76 +1,77 @@
|
|||||||
/* Merge/TextSemicolon.cpp
|
// Merge/TextSemicolon.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "TextSemicolon.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "TextSemicolon.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
namespace merge
|
static const QString ID = "Text/Semicolon";
|
||||||
{
|
}
|
||||||
|
|
||||||
static const QString ID = "Text/Semicolon";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels::merge
|
||||||
/// Constructor
|
{
|
||||||
///
|
|
||||||
TextSemicolon::TextSemicolon() : Text(';',false)
|
///
|
||||||
{
|
/// Constructor
|
||||||
mId = ID;
|
///
|
||||||
}
|
TextSemicolon::TextSemicolon() : Text(';',false)
|
||||||
|
{
|
||||||
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextSemicolon::TextSemicolon( const TextSemicolon* merge ) : Text( merge )
|
TextSemicolon::TextSemicolon( const TextSemicolon* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
TextSemicolon* TextSemicolon::clone() const
|
TextSemicolon* TextSemicolon::clone() const
|
||||||
{
|
{
|
||||||
return new TextSemicolon( this );
|
return new TextSemicolon( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString TextSemicolon::id()
|
QString TextSemicolon::id()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* TextSemicolon::create()
|
Merge* TextSemicolon::create()
|
||||||
{
|
{
|
||||||
return new TextSemicolon();
|
return new TextSemicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
}
|
||||||
} // namespace glabels
|
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Merge/TextSemicolon.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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_TextSemicolon_h
|
|
||||||
#define merge_TextSemicolon_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Text.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// TextSemicolon Merge Backend
|
|
||||||
///
|
|
||||||
struct TextSemicolon : public Text
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
TextSemicolon();
|
|
||||||
TextSemicolon( const TextSemicolon* merge );
|
|
||||||
virtual ~TextSemicolon() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
TextSemicolon* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextSemicolon_h
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Merge/TextSemicolon.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_TextSemicolon_hpp
|
||||||
|
#define merge_TextSemicolon_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Text.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// TextSemicolon Merge Backend
|
||||||
|
///
|
||||||
|
struct TextSemicolon : public Text
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextSemicolon();
|
||||||
|
TextSemicolon( const TextSemicolon* merge );
|
||||||
|
virtual ~TextSemicolon() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
TextSemicolon* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_TextSemicolon_hpp
|
||||||
@@ -1,76 +1,77 @@
|
|||||||
/* Merge/TextSemicolonKeys.cpp
|
// Merge/TextSemicolonKeys.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "TextSemicolonKeys.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "TextSemicolonKeys.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
namespace merge
|
static const QString ID = "Text/Semicolon/Keys";
|
||||||
{
|
}
|
||||||
|
|
||||||
static const QString ID = "Text/Semicolon/Keys";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels::merge
|
||||||
/// Constructor
|
{
|
||||||
///
|
|
||||||
TextSemicolonKeys::TextSemicolonKeys() : Text(';',true)
|
///
|
||||||
{
|
/// Constructor
|
||||||
mId = ID;
|
///
|
||||||
}
|
TextSemicolonKeys::TextSemicolonKeys() : Text(';',true)
|
||||||
|
{
|
||||||
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextSemicolonKeys::TextSemicolonKeys( const TextSemicolonKeys* merge ) : Text( merge )
|
TextSemicolonKeys::TextSemicolonKeys( const TextSemicolonKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
TextSemicolonKeys* TextSemicolonKeys::clone() const
|
TextSemicolonKeys* TextSemicolonKeys::clone() const
|
||||||
{
|
{
|
||||||
return new TextSemicolonKeys( this );
|
return new TextSemicolonKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString TextSemicolonKeys::id()
|
QString TextSemicolonKeys::id()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* TextSemicolonKeys::create()
|
Merge* TextSemicolonKeys::create()
|
||||||
{
|
{
|
||||||
return new TextSemicolonKeys();
|
return new TextSemicolonKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
}
|
||||||
} // namespace glabels
|
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Merge/TextSemicolonKeys.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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_TextSemicolonKeys_h
|
|
||||||
#define merge_TextSemicolonKeys_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Text.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// TextSemicolonKeys Merge Backend
|
|
||||||
///
|
|
||||||
struct TextSemicolonKeys : public Text
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
TextSemicolonKeys();
|
|
||||||
TextSemicolonKeys( const TextSemicolonKeys* merge );
|
|
||||||
virtual ~TextSemicolonKeys() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
TextSemicolonKeys* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextSemicolonKeys_h
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Merge/TextSemicolonKeys.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_TextSemicolonKeys_hpp
|
||||||
|
#define merge_TextSemicolonKeys_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Text.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// TextSemicolonKeys Merge Backend
|
||||||
|
///
|
||||||
|
struct TextSemicolonKeys : public Text
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextSemicolonKeys();
|
||||||
|
TextSemicolonKeys( const TextSemicolonKeys* merge );
|
||||||
|
virtual ~TextSemicolonKeys() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
TextSemicolonKeys* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_TextSemicolonKeys_hpp
|
||||||
+65
-64
@@ -1,76 +1,77 @@
|
|||||||
/* Merge/TextTsv.cpp
|
// Merge/TextTsv.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "TextTsv.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "TextTsv.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
namespace merge
|
static const QString ID = "Text/Tab";
|
||||||
{
|
}
|
||||||
|
|
||||||
static const QString ID = "Text/Tab";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
TextTsv::TextTsv() : Text('\t',false)
|
|
||||||
{
|
|
||||||
mId = ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels::merge
|
||||||
/// Constructor
|
{
|
||||||
///
|
|
||||||
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
|
///
|
||||||
{
|
/// Constructor
|
||||||
}
|
///
|
||||||
|
TextTsv::TextTsv() : Text('\t',false)
|
||||||
|
{
|
||||||
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextTsv* TextTsv::clone() const
|
TextTsv::TextTsv( const TextTsv* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
return new TextTsv( this );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Clone
|
||||||
///
|
///
|
||||||
QString TextTsv::id()
|
TextTsv* TextTsv::clone() const
|
||||||
{
|
{
|
||||||
return ID;
|
return new TextTsv( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Get ID
|
||||||
///
|
///
|
||||||
Merge* TextTsv::create()
|
QString TextTsv::id()
|
||||||
{
|
{
|
||||||
return new TextTsv();
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace merge
|
|
||||||
} // namespace glabels
|
///
|
||||||
|
/// Create
|
||||||
|
///
|
||||||
|
Merge* TextTsv::create()
|
||||||
|
{
|
||||||
|
return new TextTsv();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Merge/TextTsv.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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_TextTsv_h
|
|
||||||
#define merge_TextTsv_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Text.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// TextTsv Merge Backend
|
|
||||||
///
|
|
||||||
struct TextTsv : public Text
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
TextTsv();
|
|
||||||
TextTsv( const TextTsv* merge );
|
|
||||||
virtual ~TextTsv() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
TextTsv* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextTsv_h
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Merge/TextTsv.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_TextTsv_hpp
|
||||||
|
#define merge_TextTsv_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Text.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// TextTsv Merge Backend
|
||||||
|
///
|
||||||
|
struct TextTsv : public Text
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextTsv();
|
||||||
|
TextTsv( const TextTsv* merge );
|
||||||
|
virtual ~TextTsv() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
TextTsv* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_TextTsv_hpp
|
||||||
@@ -1,76 +1,78 @@
|
|||||||
/* Merge/TextTsvKeys.cpp
|
// Merge/TextTsvKeys.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "TextTsvKeys.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
#include "TextTsvKeys.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
namespace merge
|
static const QString ID = "Text/Tab/Line1Keys";
|
||||||
{
|
}
|
||||||
|
|
||||||
static const QString ID = "Text/Tab/Line1Keys";
|
|
||||||
|
|
||||||
|
|
||||||
///
|
namespace glabels::merge
|
||||||
/// Constructor
|
{
|
||||||
///
|
|
||||||
TextTsvKeys::TextTsvKeys() : Text('\t',true)
|
///
|
||||||
{
|
/// Constructor
|
||||||
mId = ID;
|
///
|
||||||
}
|
TextTsvKeys::TextTsvKeys() : Text('\t',true)
|
||||||
|
{
|
||||||
|
mId = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
TextTsvKeys::TextTsvKeys( const TextTsvKeys* merge ) : Text( merge )
|
TextTsvKeys::TextTsvKeys( const TextTsvKeys* merge ) : Text( merge )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clone
|
/// Clone
|
||||||
///
|
///
|
||||||
TextTsvKeys* TextTsvKeys::clone() const
|
TextTsvKeys* TextTsvKeys::clone() const
|
||||||
{
|
{
|
||||||
return new TextTsvKeys( this );
|
return new TextTsvKeys( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get ID
|
/// Get ID
|
||||||
///
|
///
|
||||||
QString TextTsvKeys::id()
|
QString TextTsvKeys::id()
|
||||||
{
|
{
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create
|
/// Create
|
||||||
///
|
///
|
||||||
Merge* TextTsvKeys::create()
|
Merge* TextTsvKeys::create()
|
||||||
{
|
{
|
||||||
return new TextTsvKeys();
|
return new TextTsvKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace merge
|
|
||||||
} // namespace glabels
|
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Merge/TextTsvKeys.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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_TextTsvKeys_h
|
|
||||||
#define merge_TextTsvKeys_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "Text.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
namespace merge
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// TextTsvKeys Merge Backend
|
|
||||||
///
|
|
||||||
struct TextTsvKeys : public Text
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
TextTsvKeys();
|
|
||||||
TextTsvKeys( const TextTsvKeys* merge );
|
|
||||||
virtual ~TextTsvKeys() = default;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Object duplication
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
TextTsvKeys* clone() const override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Static methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
static QString id();
|
|
||||||
static Merge* create();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // merge_TextTsvKeys_h
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Merge/TextTsvKeys.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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_TextTsvKeys_hpp
|
||||||
|
#define merge_TextTsvKeys_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "Text.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels::merge
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// TextTsvKeys Merge Backend
|
||||||
|
///
|
||||||
|
struct TextTsvKeys : public Text
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
TextTsvKeys();
|
||||||
|
TextTsvKeys( const TextTsvKeys* merge );
|
||||||
|
virtual ~TextTsvKeys() = default;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Object duplication
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
TextTsvKeys* clone() const override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Static methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
static QString id();
|
||||||
|
static Merge* create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // merge_TextTsvKeys_hpp
|
||||||
+39
-20
@@ -4,29 +4,20 @@ Glabels Coding Style
|
|||||||
This file describes the coding style used in all glabels source code. Any
|
This file describes the coding style used in all glabels source code. Any
|
||||||
patches or pull requests should adhere to this style.
|
patches or pull requests should adhere to this style.
|
||||||
|
|
||||||
:bulb: **Note:** The top-level glabels source directory includes a *.clang-format* file.
|
|
||||||
This file can be used with `clang-format` to reformat code to a reasonable approximation
|
|
||||||
of the style described here.
|
|
||||||
|
|
||||||
|
|
||||||
Formatting
|
Formatting
|
||||||
----------
|
----------
|
||||||
|
|
||||||
### Tabs vs. Spaces
|
### Tabs vs. Spaces
|
||||||
|
|
||||||
Tabs are only used at the beginning of a line, and only used to express
|
Use spaces for all code indentation and line-to-line alignment of code elements.
|
||||||
indentation level. Spaces are used for any other type of vertical alignment,
|
(e.g. aligning function arguments). This ensures that the code displays
|
||||||
e.g. aligning function arguments. This ensures that the code displays
|
correctly everywhere.
|
||||||
correctly everywhere, regardless of the viewer's tab size, and does not inflict
|
|
||||||
the viewer with my choice of tab size (8 spaces).
|
|
||||||
|
|
||||||
I use the emacs smart-tabs-mode to automatically enforce this. See
|
|
||||||
https://www.emacswiki.org/emacs/SmartTabs for more information.
|
|
||||||
|
|
||||||
|
|
||||||
### Indentation Style
|
### Indentation Style
|
||||||
|
|
||||||
Glabels code uses the Allman style (a.k.a "BSD Style") of code indentation.
|
Glabels code uses the Allman[^1] style (a.k.a "BSD Style") of code indentation.
|
||||||
I.e. the brace associated with a control statement is placed on the next line,
|
I.e. the brace associated with a control statement is placed on the next line,
|
||||||
indented to the same level as the control statement. Statements within the
|
indented to the same level as the control statement. Statements within the
|
||||||
braces are indented to the next level.
|
braces are indented to the next level.
|
||||||
@@ -50,8 +41,6 @@ else
|
|||||||
|
|
||||||
Also applies to function, class and namespace declaration statements.
|
Also applies to function, class and namespace declaration statements.
|
||||||
|
|
||||||
See https://en.wikipedia.org/wiki/Indent_style#Allman_style for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
|
|
||||||
### Parenthesis
|
### Parenthesis
|
||||||
@@ -98,8 +87,8 @@ Code Organization
|
|||||||
Generally code is organized into modules. Usually a module defines a single
|
Generally code is organized into modules. Usually a module defines a single
|
||||||
class or a small namespace of functions/constants/etc. A module is defined by
|
class or a small namespace of functions/constants/etc. A module is defined by
|
||||||
two files: a header file (its specification) and an implementation file.
|
two files: a header file (its specification) and an implementation file.
|
||||||
Header filenames have a ".h" extension and implementation filenames have a
|
Header filenames have a `.hpp` extension[^2] and implementation filenames have a
|
||||||
".cpp" extension.
|
`.cpp` extension.
|
||||||
|
|
||||||
|
|
||||||
### Self-contained Headers
|
### Self-contained Headers
|
||||||
@@ -114,8 +103,8 @@ shall include its header file before any other includes.
|
|||||||
All header files should have an ifndef guard to prevent multiple inclusion.
|
All header files should have an ifndef guard to prevent multiple inclusion.
|
||||||
|
|
||||||
```
|
```
|
||||||
#ifndef ns_Module_h
|
#ifndef ns_Module_hpp
|
||||||
#define ns_Module_h
|
#define ns_Module_hpp
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
@@ -127,7 +116,7 @@ All header files should have an ifndef guard to prevent multiple inclusion.
|
|||||||
|
|
||||||
Header files should be included in the following order.
|
Header files should be included in the following order.
|
||||||
|
|
||||||
1. header file for this module (e.g. this would be "Foo.h" in "Foo.cpp").
|
1. header file for this module (e.g. this would be `Foo.hpp` in `Foo.cpp`).
|
||||||
2. Glabels header files.
|
2. Glabels header files.
|
||||||
3. Qt header files
|
3. Qt header files
|
||||||
3. C++ system header files (e.g. STL files)
|
3. C++ system header files (e.g. STL files)
|
||||||
@@ -152,3 +141,33 @@ include directives instead.
|
|||||||
|
|
||||||
- Private definitions are placed in unnamed namespaces to limit scope to the current translation unit.
|
- Private definitions are placed in unnamed namespaces to limit scope to the current translation unit.
|
||||||
- All other glabels code is placed in the top-level "glabels" namespace.
|
- All other glabels code is placed in the top-level "glabels" namespace.
|
||||||
|
- Nested namespace declarations should follow the more concise C++17 syntax
|
||||||
|
```
|
||||||
|
namespace glabels::model
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Notes
|
||||||
|
-----
|
||||||
|
|
||||||
|
### Emacs
|
||||||
|
|
||||||
|
The following is an excerpt from my emacs configuration supporting the style
|
||||||
|
```
|
||||||
|
(defun my-c++-hook ()
|
||||||
|
(setq c-default-style "bsd"
|
||||||
|
c-basic-offset 8
|
||||||
|
indent-tabs-mode nil
|
||||||
|
show-trailing-whitespace t))
|
||||||
|
|
||||||
|
(add-hook 'c++-mode-hook 'my-c++-hook)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
References
|
||||||
|
----------
|
||||||
|
[^1]: https://en.wikipedia.org/wiki/Indent_style#Allman_style
|
||||||
|
[^2]: [C++ Weekly - Ep 442 - Stop Using .h For C++ Header Files!](https://www.youtube.com/watch?v=mr3sOT-Delg)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ add_executable (glabels-batch-qt
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_compile_features (glabels-batch-qt
|
target_compile_features (glabels-batch-qt
|
||||||
PUBLIC cxx_std_11
|
PUBLIC cxx_std_20
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries (glabels-batch-qt
|
target_link_libraries (glabels-batch-qt
|
||||||
|
|||||||
+261
-260
@@ -1,32 +1,33 @@
|
|||||||
/* main.cpp
|
// main.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2013-2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2013-2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "model/FileUtil.h"
|
|
||||||
#include "model/Db.h"
|
|
||||||
#include "model/Model.h"
|
|
||||||
#include "model/PageRenderer.h"
|
|
||||||
#include "model/Version.h"
|
|
||||||
#include "model/XmlLabelParser.h"
|
|
||||||
|
|
||||||
#include "barcode/Backends.h"
|
#include "model/FileUtil.hpp"
|
||||||
#include "merge/Factory.h"
|
#include "model/Db.hpp"
|
||||||
|
#include "model/Model.hpp"
|
||||||
|
#include "model/PageRenderer.hpp"
|
||||||
|
#include "model/Version.hpp"
|
||||||
|
#include "model/XmlLabelParser.hpp"
|
||||||
|
|
||||||
|
#include "barcode/Backends.hpp"
|
||||||
|
#include "merge/Factory.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
@@ -41,16 +42,16 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
const QString STDOUT_FILENAME = "CON:";
|
const QString STDOUT_FILENAME = "CON:";
|
||||||
const QString STDIN_FILENAME = "CON:";
|
const QString STDIN_FILENAME = "CON:";
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
const QString STDOUT_FILENAME = "/dev/stdout";
|
const QString STDOUT_FILENAME = "/dev/stdout";
|
||||||
const QString STDIN_FILENAME = "/dev/stdin";
|
const QString STDIN_FILENAME = "/dev/stdin";
|
||||||
#else
|
#else
|
||||||
const QString STDOUT_FILENAME = "/dev/stdout";
|
const QString STDOUT_FILENAME = "/dev/stdout";
|
||||||
const QString STDIN_FILENAME = "/dev/stdin";
|
const QString STDIN_FILENAME = "/dev/stdin";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -58,253 +59,253 @@ namespace
|
|||||||
|
|
||||||
int main( int argc, char **argv )
|
int main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
QGuiApplication app( argc, argv );
|
QGuiApplication app( argc, 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::model::Version::LONG_STRING );
|
QCoreApplication::setApplicationVersion( glabels::model::Version::LONG_STRING );
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setup translators
|
// Setup translators
|
||||||
//
|
//
|
||||||
QLocale locale = QLocale::system();
|
QLocale locale = QLocale::system();
|
||||||
QString qtTranslationsDir = QLibraryInfo::path( QLibraryInfo::TranslationsPath );
|
QString qtTranslationsDir = QLibraryInfo::path( QLibraryInfo::TranslationsPath );
|
||||||
QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
|
QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
|
||||||
|
|
||||||
QTranslator qtTranslator;
|
|
||||||
if ( qtTranslator.load( locale, "qt", "_", qtTranslationsDir ) )
|
|
||||||
{
|
|
||||||
app.installTranslator(&qtTranslator);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTranslator glabelsTranslator;
|
QTranslator qtTranslator;
|
||||||
if ( glabelsTranslator.load( locale, "glabels", "_", myTranslationsDir ) )
|
if ( qtTranslator.load( locale, "qt", "_", qtTranslationsDir ) )
|
||||||
{
|
{
|
||||||
app.installTranslator(&glabelsTranslator);
|
app.installTranslator(&qtTranslator);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTranslator templatesTranslator;
|
QTranslator glabelsTranslator;
|
||||||
if ( templatesTranslator.load( locale, "templates", "_", myTranslationsDir ) )
|
if ( glabelsTranslator.load( locale, "glabels", "_", myTranslationsDir ) )
|
||||||
{
|
{
|
||||||
app.installTranslator(&templatesTranslator);
|
app.installTranslator(&glabelsTranslator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTranslator templatesTranslator;
|
||||||
|
if ( templatesTranslator.load( locale, "templates", "_", myTranslationsDir ) )
|
||||||
|
{
|
||||||
|
app.installTranslator(&templatesTranslator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parse command line
|
// Parse command line
|
||||||
//
|
//
|
||||||
const QList<QCommandLineOption> options = {
|
const QList<QCommandLineOption> options = {
|
||||||
{{"p","printer"},
|
{{"p","printer"},
|
||||||
QString( QCoreApplication::translate( "main", "Send output to <printer>. (Default=\"%1\")") ).arg( QPrinterInfo::defaultPrinterName() ),
|
QString( QCoreApplication::translate( "main", "Send output to <printer>. (Default=\"%1\")") ).arg( QPrinterInfo::defaultPrinterName() ),
|
||||||
QCoreApplication::translate( "main", "printer" ),
|
QCoreApplication::translate( "main", "printer" ),
|
||||||
QPrinterInfo::defaultPrinterName() },
|
QPrinterInfo::defaultPrinterName() },
|
||||||
|
|
||||||
{{"i","input"},
|
|
||||||
QCoreApplication::translate( "main", "Set merge input to <source> (typically a filename). Set to \"-\" for stdin." ),
|
|
||||||
QCoreApplication::translate( "main", "source" ),
|
|
||||||
"" },
|
|
||||||
|
|
||||||
{{"o","output"},
|
|
||||||
QCoreApplication::translate( "main", "Set output filename to <filename>. Set to \"-\" for stdout. (Default=\"output.pdf\")" ),
|
|
||||||
QCoreApplication::translate( "main", "filename" ),
|
|
||||||
"output.pdf" },
|
|
||||||
|
|
||||||
{{"s","sheets"},
|
|
||||||
QCoreApplication::translate( "main", "Set number of sheets to <n>. (Default=1)" ),
|
|
||||||
"n", "1" },
|
|
||||||
|
|
||||||
{{"c","copies"},
|
{{"i","input"},
|
||||||
QCoreApplication::translate( "main", "Set number of copies to <n>. (Default=1)" ),
|
QCoreApplication::translate( "main", "Set merge input to <source> (typically a filename). Set to \"-\" for stdin." ),
|
||||||
"n", "1" },
|
QCoreApplication::translate( "main", "source" ),
|
||||||
|
"" },
|
||||||
{{"a","collate"},
|
|
||||||
QCoreApplication::translate( "main", "Collate merge copies." ) },
|
|
||||||
|
|
||||||
{{"g","group"},
|
|
||||||
QCoreApplication::translate( "main", "Start each merge group on a new page." ) },
|
|
||||||
|
|
||||||
{{"f","first"},
|
|
||||||
QCoreApplication::translate( "main", "Set starting position to <n>. (Default=1)" ),
|
|
||||||
"n", "1" },
|
|
||||||
|
|
||||||
{{"l","outlines"},
|
{{"o","output"},
|
||||||
QCoreApplication::translate( "main", "Print label outlines." ) },
|
QCoreApplication::translate( "main", "Set output filename to <filename>. Set to \"-\" for stdout. (Default=\"output.pdf\")" ),
|
||||||
|
QCoreApplication::translate( "main", "filename" ),
|
||||||
{{"m","crop-marks"},
|
"output.pdf" },
|
||||||
QCoreApplication::translate( "main", "Print crop marks." ) },
|
|
||||||
|
|
||||||
{{"r","reverse"},
|
|
||||||
QCoreApplication::translate( "main", "Print in reverse (mirror image)." ) },
|
|
||||||
|
|
||||||
{{"D","define"},
|
{{"s","sheets"},
|
||||||
QCoreApplication::translate( "main", "Set user variable <var> to <value>" ),
|
QCoreApplication::translate( "main", "Set number of sheets to <n>. (Default=1)" ),
|
||||||
QCoreApplication::translate( "main", "var>=<value" ) }
|
"n", "1" },
|
||||||
};
|
|
||||||
|
{{"c","copies"},
|
||||||
|
QCoreApplication::translate( "main", "Set number of copies to <n>. (Default=1)" ),
|
||||||
|
"n", "1" },
|
||||||
|
|
||||||
|
{{"a","collate"},
|
||||||
|
QCoreApplication::translate( "main", "Collate merge copies." ) },
|
||||||
|
|
||||||
|
{{"g","group"},
|
||||||
|
QCoreApplication::translate( "main", "Start each merge group on a new page." ) },
|
||||||
|
|
||||||
|
{{"f","first"},
|
||||||
|
QCoreApplication::translate( "main", "Set starting position to <n>. (Default=1)" ),
|
||||||
|
"n", "1" },
|
||||||
|
|
||||||
|
{{"l","outlines"},
|
||||||
|
QCoreApplication::translate( "main", "Print label outlines." ) },
|
||||||
|
|
||||||
|
{{"m","crop-marks"},
|
||||||
|
QCoreApplication::translate( "main", "Print crop marks." ) },
|
||||||
|
|
||||||
|
{{"r","reverse"},
|
||||||
|
QCoreApplication::translate( "main", "Print in reverse (mirror image)." ) },
|
||||||
|
|
||||||
|
{{"D","define"},
|
||||||
|
QCoreApplication::translate( "main", "Set user variable <var> to <value>" ),
|
||||||
|
QCoreApplication::translate( "main", "var>=<value" ) }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription( QCoreApplication::translate( "main", "gLabels Label Designer (Batch Front-end)" ) );
|
parser.setApplicationDescription( QCoreApplication::translate( "main", "gLabels Label Designer (Batch Front-end)" ) );
|
||||||
parser.addOptions( options );
|
parser.addOptions( options );
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addVersionOption();
|
parser.addVersionOption();
|
||||||
parser.addOption( { { "V", "Version" }, QCoreApplication::translate( "main", "More detailed version information." ) } );
|
parser.addOption( { { "V", "Version" }, QCoreApplication::translate( "main", "More detailed version information." ) } );
|
||||||
parser.addPositionalArgument( "file",
|
parser.addPositionalArgument( "file",
|
||||||
QCoreApplication::translate( "main", "gLabels project file to print." ),
|
QCoreApplication::translate( "main", "gLabels project file to print." ),
|
||||||
"file" );
|
"file" );
|
||||||
parser.process( app );
|
parser.process( app );
|
||||||
|
|
||||||
// Handle verbose version option
|
// Handle verbose version option
|
||||||
if ( parser.isSet( "Version" ) )
|
if ( parser.isSet( "Version" ) )
|
||||||
{
|
{
|
||||||
QTextStream(stdout) << glabels::model::Version::details() << Qt::endl;
|
QTextStream(stdout) << glabels::model::Version::details() << Qt::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parse variable definitions from command line, if any
|
// Parse variable definitions from command line, if any
|
||||||
//
|
//
|
||||||
QMap<QString,QString> variableDefinitions;
|
QMap<QString,QString> variableDefinitions;
|
||||||
|
|
||||||
for ( QString definition : parser.values("define") )
|
|
||||||
{
|
|
||||||
QStringList parts = definition.split( '=' );
|
|
||||||
if ( parts.size() != 2 )
|
|
||||||
{
|
|
||||||
qWarning() << "Error: bad variable definition: " << definition;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
variableDefinitions[ parts[0] ] = parts[1];
|
for ( QString definition : parser.values("define") )
|
||||||
}
|
{
|
||||||
|
QStringList parts = definition.split( '=' );
|
||||||
|
if ( parts.size() != 2 )
|
||||||
|
{
|
||||||
|
qWarning() << "Error: bad variable definition: " << definition;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
variableDefinitions[ parts[0] ] = parts[1];
|
||||||
// Initialize subsystems
|
}
|
||||||
//
|
|
||||||
glabels::model::Settings::init();
|
|
||||||
glabels::model::Db::init();
|
|
||||||
glabels::merge::Factory::init();
|
|
||||||
glabels::barcode::Backends::init();
|
|
||||||
|
|
||||||
|
//
|
||||||
if ( parser.positionalArguments().size() == 1 )
|
// Initialize subsystems
|
||||||
{
|
//
|
||||||
qDebug() << "Batch mode.";
|
glabels::model::Settings::init();
|
||||||
|
glabels::model::Db::init();
|
||||||
|
glabels::merge::Factory::init();
|
||||||
|
glabels::barcode::Backends::init();
|
||||||
|
|
||||||
QString filename = parser.positionalArguments().constFirst();
|
|
||||||
if ( filename == "-" )
|
|
||||||
{
|
|
||||||
filename = STDIN_FILENAME;
|
|
||||||
}
|
|
||||||
qDebug() << "Project file =" << filename;
|
|
||||||
|
|
||||||
glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
|
if ( parser.positionalArguments().size() == 1 )
|
||||||
if ( model )
|
{
|
||||||
{
|
qDebug() << "Batch mode.";
|
||||||
model->variables().setVariables( variableDefinitions );
|
|
||||||
|
|
||||||
QPrinter printer( QPrinter::HighResolution );
|
QString filename = parser.positionalArguments().constFirst();
|
||||||
printer.setColorMode( QPrinter::Color );
|
if ( filename == "-" )
|
||||||
if ( parser.isSet("printer") )
|
{
|
||||||
{
|
filename = STDIN_FILENAME;
|
||||||
qDebug() << "Printer =" << parser.value("printer");
|
}
|
||||||
printer.setPrinterName( parser.value("printer") );
|
qDebug() << "Project file =" << filename;
|
||||||
}
|
|
||||||
else if ( parser.isSet("output") )
|
|
||||||
{
|
|
||||||
QString outputFilename = parser.value("output");
|
|
||||||
if ( outputFilename == "-" )
|
|
||||||
{
|
|
||||||
outputFilename = STDOUT_FILENAME;
|
|
||||||
}
|
|
||||||
qDebug() << "Output =" << outputFilename;
|
|
||||||
printer.setOutputFileName( outputFilename );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug() << "Batch mode. printer =" << QPrinterInfo::defaultPrinterName();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( parser.isSet( "input" ) )
|
glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
|
||||||
{
|
if ( model )
|
||||||
QString inputSource = parser.value( "input" );
|
{
|
||||||
if ( inputSource == "-" )
|
model->variables().setVariables( variableDefinitions );
|
||||||
{
|
|
||||||
inputSource = STDIN_FILENAME;
|
|
||||||
}
|
|
||||||
qDebug() << "Merge source =" << inputSource;
|
|
||||||
model->merge()->setSource( inputSource );
|
|
||||||
}
|
|
||||||
|
|
||||||
glabels::model::PageRenderer renderer( model );
|
|
||||||
if ( model->merge()->keys().empty() )
|
|
||||||
{
|
|
||||||
// Simple project (no merge)
|
|
||||||
if ( parser.isSet( "sheets" ) )
|
|
||||||
{
|
|
||||||
// Full sheets of simple items
|
|
||||||
renderer.setNCopies( parser.value( "sheets" ).toInt() * model->frame()->nLabels() );
|
|
||||||
renderer.setStartItem( 0 );
|
|
||||||
}
|
|
||||||
else if ( parser.isSet( "copies" ) )
|
|
||||||
{
|
|
||||||
// Partial sheet(s) of simple items
|
|
||||||
renderer.setNCopies( parser.value( "copies" ).toInt() );
|
|
||||||
renderer.setStartItem( parser.value( "first" ).toInt() - 1 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// One full sheet of simple items
|
|
||||||
renderer.setNCopies( model->frame()->nLabels() );
|
|
||||||
renderer.setStartItem( 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Project with merge
|
|
||||||
renderer.setNCopies( parser.value( "copies" ).toInt() );
|
|
||||||
renderer.setStartItem( parser.value( "first" ).toInt() - 1 );
|
|
||||||
renderer.setIsCollated( parser.isSet( "collate" ) );
|
|
||||||
renderer.setAreGroupsContiguous( !parser.isSet( "group" ) );
|
|
||||||
}
|
|
||||||
renderer.setPrintOutlines( parser.isSet( "outlines" ) );
|
|
||||||
renderer.setPrintCropMarks( parser.isSet( "crop-marks" ) );
|
|
||||||
renderer.setPrintReverse( parser.isSet( "reverse" ) );
|
|
||||||
|
|
||||||
// Item and page count summary
|
QPrinter printer( QPrinter::HighResolution );
|
||||||
if ( renderer.nPages() == 1 )
|
printer.setColorMode( QPrinter::Color );
|
||||||
{
|
if ( parser.isSet("printer") )
|
||||||
if ( renderer.nItems() == 1 )
|
{
|
||||||
{
|
qDebug() << "Printer =" << parser.value("printer");
|
||||||
qDebug() << "Printing 1 item on 1 page.";
|
printer.setPrinterName( parser.value("printer") );
|
||||||
}
|
}
|
||||||
else
|
else if ( parser.isSet("output") )
|
||||||
{
|
{
|
||||||
qDebug() << "Printing" << renderer.nItems() << "items on 1 page.";
|
QString outputFilename = parser.value("output");
|
||||||
}
|
if ( outputFilename == "-" )
|
||||||
}
|
{
|
||||||
else
|
outputFilename = STDOUT_FILENAME;
|
||||||
{
|
}
|
||||||
qDebug() << "Printing" << renderer.nItems() << "items on" << renderer.nPages() << "pages.";
|
qDebug() << "Output =" << outputFilename;
|
||||||
}
|
printer.setOutputFileName( outputFilename );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Batch mode. printer =" << QPrinterInfo::defaultPrinterName();
|
||||||
|
}
|
||||||
|
|
||||||
// Do it!
|
if ( parser.isSet( "input" ) )
|
||||||
renderer.print( &printer );
|
{
|
||||||
}
|
QString inputSource = parser.value( "input" );
|
||||||
}
|
if ( inputSource == "-" )
|
||||||
else
|
{
|
||||||
{
|
inputSource = STDIN_FILENAME;
|
||||||
if ( parser.positionalArguments().size() == 0 )
|
}
|
||||||
{
|
qDebug() << "Merge source =" << inputSource;
|
||||||
qWarning() << "Error: missing glabels project file.";
|
model->merge()->setSource( inputSource );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
glabels::model::PageRenderer renderer( model );
|
||||||
qWarning() << "Error: batch mode supports only one glabels project file.";
|
if ( model->merge()->keys().empty() )
|
||||||
}
|
{
|
||||||
return -1;
|
// Simple project (no merge)
|
||||||
}
|
if ( parser.isSet( "sheets" ) )
|
||||||
|
{
|
||||||
return 0;
|
// Full sheets of simple items
|
||||||
|
renderer.setNCopies( parser.value( "sheets" ).toInt() * model->frame()->nLabels() );
|
||||||
|
renderer.setStartItem( 0 );
|
||||||
|
}
|
||||||
|
else if ( parser.isSet( "copies" ) )
|
||||||
|
{
|
||||||
|
// Partial sheet(s) of simple items
|
||||||
|
renderer.setNCopies( parser.value( "copies" ).toInt() );
|
||||||
|
renderer.setStartItem( parser.value( "first" ).toInt() - 1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// One full sheet of simple items
|
||||||
|
renderer.setNCopies( model->frame()->nLabels() );
|
||||||
|
renderer.setStartItem( 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Project with merge
|
||||||
|
renderer.setNCopies( parser.value( "copies" ).toInt() );
|
||||||
|
renderer.setStartItem( parser.value( "first" ).toInt() - 1 );
|
||||||
|
renderer.setIsCollated( parser.isSet( "collate" ) );
|
||||||
|
renderer.setAreGroupsContiguous( !parser.isSet( "group" ) );
|
||||||
|
}
|
||||||
|
renderer.setPrintOutlines( parser.isSet( "outlines" ) );
|
||||||
|
renderer.setPrintCropMarks( parser.isSet( "crop-marks" ) );
|
||||||
|
renderer.setPrintReverse( parser.isSet( "reverse" ) );
|
||||||
|
|
||||||
|
// Item and page count summary
|
||||||
|
if ( renderer.nPages() == 1 )
|
||||||
|
{
|
||||||
|
if ( renderer.nItems() == 1 )
|
||||||
|
{
|
||||||
|
qDebug() << "Printing 1 item on 1 page.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Printing" << renderer.nItems() << "items on 1 page.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Printing" << renderer.nItems() << "items on" << renderer.nPages() << "pages.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do it!
|
||||||
|
renderer.print( &printer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( parser.positionalArguments().size() == 0 )
|
||||||
|
{
|
||||||
|
qWarning() << "Error: missing glabels project file.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "Error: batch mode supports only one glabels project file.";
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+69
-68
@@ -1,87 +1,88 @@
|
|||||||
/* AboutDialog.cpp
|
// AboutDialog.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "AboutDialog.h"
|
|
||||||
|
|
||||||
#include "model/Version.h"
|
#include "AboutDialog.hpp"
|
||||||
|
|
||||||
|
#include "model/Version.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QtDebug>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
AboutDialog::AboutDialog( QWidget *parent )
|
AboutDialog::AboutDialog( QWidget *parent )
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
QString version = tr("Version") + " " + model::Version::LONG_STRING;
|
QString version = tr("Version") + " " + model::Version::LONG_STRING;
|
||||||
|
|
||||||
QString description = tr("A program to create labels and business cards.");
|
|
||||||
|
|
||||||
QString copyright = "Copyright © 2018 Jaye Evins <evins@snaught.com>";
|
|
||||||
|
|
||||||
QString licenseParagraph1 =
|
|
||||||
tr( "gLabels is free software: you can redistribute it and/or modify "
|
|
||||||
"it under the terms of the GNU General Public License as published by "
|
|
||||||
"the Free Software Foundation, either version 3 of the License, or "
|
|
||||||
"(at your option) any later version." );
|
|
||||||
|
|
||||||
QString licenseParagraph2 =
|
QString description = tr("A program to create labels and business cards.");
|
||||||
tr( "gLabels 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." );
|
|
||||||
|
|
||||||
QString markup =
|
|
||||||
"<p align='center'>" + version + "</p>" +
|
|
||||||
"<p align='center'>" + description + "</p>" +
|
|
||||||
"<p align='center'>" + copyright + "</p>" +
|
|
||||||
"<p align='left'>" + licenseParagraph1 + "</p>" +
|
|
||||||
"<p align='left'>" + licenseParagraph2 + "</p>";
|
|
||||||
|
|
||||||
aboutLabel->setText( markup );
|
QString copyright = "Copyright © 2018 Jaye Evins <evins@snaught.com>";
|
||||||
}
|
|
||||||
|
QString licenseParagraph1 =
|
||||||
|
tr( "gLabels is free software: you can redistribute it and/or modify "
|
||||||
|
"it under the terms of the GNU General Public License as published by "
|
||||||
|
"the Free Software Foundation, either version 3 of the License, or "
|
||||||
|
"(at your option) any later version." );
|
||||||
|
|
||||||
|
QString licenseParagraph2 =
|
||||||
|
tr( "gLabels 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." );
|
||||||
|
|
||||||
|
QString markup =
|
||||||
|
"<p align='center'>" + version + "</p>" +
|
||||||
|
"<p align='center'>" + description + "</p>" +
|
||||||
|
"<p align='center'>" + copyright + "</p>" +
|
||||||
|
"<p align='left'>" + licenseParagraph1 + "</p>" +
|
||||||
|
"<p align='left'>" + licenseParagraph2 + "</p>";
|
||||||
|
|
||||||
|
aboutLabel->setText( markup );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// "License" Button Clicked Slot
|
/// "License" Button Clicked Slot
|
||||||
///
|
///
|
||||||
void AboutDialog::onLicenseButtonClicked()
|
void AboutDialog::onLicenseButtonClicked()
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl( QUrl("http://www.gnu.org/licenses/gpl-3.0.txt") );
|
QDesktopServices::openUrl( QUrl("http://www.gnu.org/licenses/gpl-3.0.txt") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// "Website" Button Clicked Slot
|
/// "Website" Button Clicked Slot
|
||||||
///
|
///
|
||||||
void AboutDialog::onWebsiteButtonClicked()
|
void AboutDialog::onWebsiteButtonClicked()
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl( QUrl(model::Version::WEBSITE) );
|
QDesktopServices::openUrl( QUrl(model::Version::WEBSITE) );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
/* AboutDialog.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Jaye 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 AboutDialog_h
|
|
||||||
#define AboutDialog_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "ui_AboutDialog.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// About Dialog Widget
|
|
||||||
///
|
|
||||||
class AboutDialog : public QDialog, public Ui_AboutDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
AboutDialog( QWidget *parent = nullptr );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Slots
|
|
||||||
/////////////////////////////////
|
|
||||||
private slots:
|
|
||||||
void onLicenseButtonClicked();
|
|
||||||
void onWebsiteButtonClicked();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // AboutDialog_h
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
// AboutDialog.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Jaye 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 AboutDialog_hpp
|
||||||
|
#define AboutDialog_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "ui_AboutDialog.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// About Dialog Widget
|
||||||
|
///
|
||||||
|
class AboutDialog : public QDialog, public Ui_AboutDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
AboutDialog( QWidget *parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onLicenseButtonClicked();
|
||||||
|
void onWebsiteButtonClicked();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // AboutDialog_hpp
|
||||||
+71
-70
@@ -1,88 +1,89 @@
|
|||||||
/* BarcodeMenu.cpp
|
// BarcodeMenu.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "BarcodeMenu.h"
|
|
||||||
|
|
||||||
#include "BarcodeMenuItem.h"
|
#include "BarcodeMenu.hpp"
|
||||||
|
|
||||||
#include "barcode/Backends.h"
|
#include "BarcodeMenuItem.hpp"
|
||||||
|
|
||||||
#include <QtDebug>
|
#include "barcode/Backends.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
BarcodeMenu::BarcodeMenu()
|
|
||||||
{
|
|
||||||
for ( const barcode::Style& bcStyle : barcode::Backends::styleList() )
|
|
||||||
{
|
|
||||||
if ( bcStyle.backendId() == "" )
|
|
||||||
{
|
|
||||||
auto* bcMenuItem = new BarcodeMenuItem( bcStyle );
|
|
||||||
connect( bcMenuItem, SIGNAL(activated(const barcode::Style&)),
|
|
||||||
this, SLOT(onMenuItemActivated(const barcode::Style&)) );
|
|
||||||
|
|
||||||
addAction( bcMenuItem );
|
///
|
||||||
}
|
/// Constructor
|
||||||
}
|
///
|
||||||
|
BarcodeMenu::BarcodeMenu()
|
||||||
|
{
|
||||||
|
for ( const barcode::Style& bcStyle : barcode::Backends::styleList() )
|
||||||
|
{
|
||||||
|
if ( bcStyle.backendId() == "" )
|
||||||
|
{
|
||||||
|
auto* bcMenuItem = new BarcodeMenuItem( bcStyle );
|
||||||
|
connect( bcMenuItem, SIGNAL(activated(const barcode::Style&)),
|
||||||
|
this, SLOT(onMenuItemActivated(const barcode::Style&)) );
|
||||||
|
|
||||||
for ( const QString& backendId : barcode::Backends::backendList() )
|
addAction( bcMenuItem );
|
||||||
{
|
}
|
||||||
QMenu* subMenu = addMenu( barcode::Backends::backendName( backendId ) );
|
}
|
||||||
|
|
||||||
for ( const barcode::Style& bcStyle : barcode::Backends::styleList() )
|
|
||||||
{
|
|
||||||
if ( bcStyle.backendId() == backendId )
|
|
||||||
{
|
|
||||||
auto* bcMenuItem = new BarcodeMenuItem( bcStyle );
|
|
||||||
connect( bcMenuItem, SIGNAL(activated(const barcode::Style&)),
|
|
||||||
this, SLOT(onMenuItemActivated(const barcode::Style&)) );
|
|
||||||
|
|
||||||
subMenu->addAction( bcMenuItem );
|
for ( const QString& backendId : barcode::Backends::backendList() )
|
||||||
}
|
{
|
||||||
}
|
QMenu* subMenu = addMenu( barcode::Backends::backendName( backendId ) );
|
||||||
}
|
|
||||||
}
|
for ( const barcode::Style& bcStyle : barcode::Backends::styleList() )
|
||||||
|
{
|
||||||
|
if ( bcStyle.backendId() == backendId )
|
||||||
|
{
|
||||||
|
auto* bcMenuItem = new BarcodeMenuItem( bcStyle );
|
||||||
|
connect( bcMenuItem, SIGNAL(activated(const barcode::Style&)),
|
||||||
|
this, SLOT(onMenuItemActivated(const barcode::Style&)) );
|
||||||
|
|
||||||
|
subMenu->addAction( bcMenuItem );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// bcStyle getter
|
/// bcStyle getter
|
||||||
///
|
///
|
||||||
barcode::Style BarcodeMenu::bcStyle() const
|
barcode::Style BarcodeMenu::bcStyle() const
|
||||||
{
|
{
|
||||||
return mBcStyle;
|
return mBcStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onMenuItemActivated slot
|
/// onMenuItemActivated slot
|
||||||
///
|
///
|
||||||
void BarcodeMenu::onMenuItemActivated( const barcode::Style& bcStyle )
|
void BarcodeMenu::onMenuItemActivated( const barcode::Style& bcStyle )
|
||||||
{
|
{
|
||||||
mBcStyle = bcStyle;
|
mBcStyle = bcStyle;
|
||||||
|
|
||||||
emit selectionChanged();
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
/* BarcodeMenu.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Jaye 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 BarcodeMenu_h
|
|
||||||
#define BarcodeMenu_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "barcode/Style.h"
|
|
||||||
|
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Menu
|
|
||||||
///
|
|
||||||
class BarcodeMenu : public QMenu
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
BarcodeMenu();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
/////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void selectionChanged();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Properties
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
barcode::Style bcStyle() const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Slots
|
|
||||||
/////////////////////////////////
|
|
||||||
private slots:
|
|
||||||
void onMenuItemActivated( const barcode::Style& bcStyle );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Data
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
barcode::Style mBcStyle;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeMenu_h
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
// BarcodeMenu.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014 Jaye 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 BarcodeMenu_hpp
|
||||||
|
#define BarcodeMenu_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "barcode/Style.hpp"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Menu
|
||||||
|
///
|
||||||
|
class BarcodeMenu : public QMenu
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
BarcodeMenu();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void selectionChanged();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Properties
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
barcode::Style bcStyle() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onMenuItemActivated( const barcode::Style& bcStyle );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
barcode::Style mBcStyle;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BarcodeMenu_hpp
|
||||||
@@ -1,79 +1,80 @@
|
|||||||
/* BarcodeMenuButton.cpp
|
// BarcodeMenuButton.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "BarcodeMenuButton.h"
|
|
||||||
|
|
||||||
#include "BarcodeMenuItem.h"
|
#include "BarcodeMenuButton.hpp"
|
||||||
|
|
||||||
#include "barcode/Backends.h"
|
#include "BarcodeMenuItem.hpp"
|
||||||
|
|
||||||
#include <QtDebug>
|
#include "barcode/Backends.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
|
||||||
: QPushButton(parent)
|
|
||||||
{
|
|
||||||
mMenu = new BarcodeMenu();
|
|
||||||
setMenu( mMenu );
|
|
||||||
|
|
||||||
mBcStyle = barcode::Backends::defaultStyle();
|
///
|
||||||
setText( mBcStyle.fullName() );
|
/// Constructor
|
||||||
|
///
|
||||||
|
BarcodeMenuButton::BarcodeMenuButton( QWidget* parent )
|
||||||
|
: QPushButton(parent)
|
||||||
|
{
|
||||||
|
mMenu = new BarcodeMenu();
|
||||||
|
setMenu( mMenu );
|
||||||
|
|
||||||
connect( mMenu, SIGNAL(selectionChanged()), this, SLOT(onMenuSelectionChanged()) );
|
mBcStyle = barcode::Backends::defaultStyle();
|
||||||
}
|
setText( mBcStyle.fullName() );
|
||||||
|
|
||||||
|
connect( mMenu, SIGNAL(selectionChanged()), this, SLOT(onMenuSelectionChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// bcStyle getter
|
/// bcStyle getter
|
||||||
///
|
///
|
||||||
barcode::Style BarcodeMenuButton::bcStyle() const
|
barcode::Style BarcodeMenuButton::bcStyle() const
|
||||||
{
|
{
|
||||||
return mBcStyle;
|
return mBcStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// bcStyle setter
|
/// bcStyle setter
|
||||||
///
|
///
|
||||||
void BarcodeMenuButton::setBcStyle( const barcode::Style& bcStyle )
|
void BarcodeMenuButton::setBcStyle( const barcode::Style& bcStyle )
|
||||||
{
|
{
|
||||||
mBcStyle = bcStyle;
|
mBcStyle = bcStyle;
|
||||||
setText( mBcStyle.fullName() );
|
setText( mBcStyle.fullName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onMenuStyleChanged slot
|
/// onMenuStyleChanged slot
|
||||||
///
|
///
|
||||||
void BarcodeMenuButton::onMenuSelectionChanged()
|
void BarcodeMenuButton::onMenuSelectionChanged()
|
||||||
{
|
{
|
||||||
mBcStyle = mMenu->bcStyle();
|
mBcStyle = mMenu->bcStyle();
|
||||||
setText( mBcStyle.fullName() );
|
setText( mBcStyle.fullName() );
|
||||||
|
|
||||||
emit selectionChanged();
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
/* BarcodeMenuButton.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Jaye 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 BarcodeMenuButton_h
|
|
||||||
#define BarcodeMenuButton_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "BarcodeMenu.h"
|
|
||||||
|
|
||||||
#include "barcode/Style.h"
|
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Menu Button
|
|
||||||
///
|
|
||||||
class BarcodeMenuButton : public QPushButton
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
BarcodeMenuButton( QWidget* parent = nullptr );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
/////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void selectionChanged();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Properties
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
barcode::Style bcStyle() const;
|
|
||||||
void setBcStyle( const barcode::Style& bcStyle );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Slots
|
|
||||||
/////////////////////////////////
|
|
||||||
private slots:
|
|
||||||
void onMenuSelectionChanged();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Data
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
BarcodeMenu* mMenu;
|
|
||||||
barcode::Style mBcStyle;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeMenuButton_h
|
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
// BarcodeMenuButton.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014 Jaye 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 BarcodeMenuButton_hpp
|
||||||
|
#define BarcodeMenuButton_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "BarcodeMenu.hpp"
|
||||||
|
|
||||||
|
#include "barcode/Style.hpp"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Menu Button
|
||||||
|
///
|
||||||
|
class BarcodeMenuButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
BarcodeMenuButton( QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void selectionChanged();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Properties
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
barcode::Style bcStyle() const;
|
||||||
|
void setBcStyle( const barcode::Style& bcStyle );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onMenuSelectionChanged();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
BarcodeMenu* mMenu;
|
||||||
|
barcode::Style mBcStyle;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BarcodeMenuButton_hpp
|
||||||
+45
-44
@@ -1,58 +1,59 @@
|
|||||||
/* BarcodeMenuItem.cpp
|
// BarcodeMenuItem.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "BarcodeMenuItem.h"
|
|
||||||
|
|
||||||
#include <QtDebug>
|
#include "BarcodeMenuItem.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
BarcodeMenuItem::BarcodeMenuItem( const barcode::Style& 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() );
|
||||||
|
|
||||||
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
|
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// bcStyle Property Getter
|
/// bcStyle Property Getter
|
||||||
///
|
///
|
||||||
barcode::Style BarcodeMenuItem::bcStyle() const
|
barcode::Style BarcodeMenuItem::bcStyle() const
|
||||||
{
|
{
|
||||||
return mBcStyle;
|
return mBcStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onTriggered slot
|
/// onTriggered slot
|
||||||
///
|
///
|
||||||
void BarcodeMenuItem::onTriggered()
|
void BarcodeMenuItem::onTriggered()
|
||||||
{
|
{
|
||||||
emit activated( mBcStyle );
|
emit activated( mBcStyle );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
/* BarcodeMenuItem.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Jaye 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 BarcodeMenuItem_h
|
|
||||||
#define BarcodeMenuItem_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "barcode/Style.h"
|
|
||||||
|
|
||||||
#include <QAction>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Barcode Menu Item
|
|
||||||
///
|
|
||||||
class BarcodeMenuItem : public QAction
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
BarcodeMenuItem( const barcode::Style& bcStyle, QObject* parent = nullptr );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
/////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void activated( const barcode::Style& bcStyle );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Properties
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
barcode::Style bcStyle() const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Slots
|
|
||||||
/////////////////////////////////
|
|
||||||
private slots:
|
|
||||||
void onTriggered();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Data
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
barcode::Style mBcStyle;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BarcodeMenuItem_h
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
// BarcodeMenuItem.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014 Jaye 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 BarcodeMenuItem_hpp
|
||||||
|
#define BarcodeMenuItem_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "barcode/Style.hpp"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Barcode Menu Item
|
||||||
|
///
|
||||||
|
class BarcodeMenuItem : public QAction
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
BarcodeMenuItem( const barcode::Style& bcStyle, QObject* parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void activated( const barcode::Style& bcStyle );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Properties
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
barcode::Style bcStyle() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onTriggered();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
barcode::Style mBcStyle;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BarcodeMenuItem_hpp
|
||||||
+30
-30
@@ -45,35 +45,35 @@ set (glabels_sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
set (glabels_qobject_headers
|
set (glabels_qobject_headers
|
||||||
AboutDialog.h
|
AboutDialog.hpp
|
||||||
BarcodeMenu.h
|
BarcodeMenu.hpp
|
||||||
BarcodeMenuButton.h
|
BarcodeMenuButton.hpp
|
||||||
BarcodeMenuItem.h
|
BarcodeMenuItem.hpp
|
||||||
ColorButton.h
|
ColorButton.hpp
|
||||||
ColorHistory.h
|
ColorHistory.hpp
|
||||||
ColorPaletteDialog.h
|
ColorPaletteDialog.hpp
|
||||||
ColorPaletteItem.h
|
ColorPaletteItem.hpp
|
||||||
EditVariableDialog.h
|
EditVariableDialog.hpp
|
||||||
FieldButton.h
|
FieldButton.hpp
|
||||||
File.h
|
File.hpp
|
||||||
LabelEditor.h
|
LabelEditor.hpp
|
||||||
MainWindow.h
|
MainWindow.hpp
|
||||||
MergeTableModel.h
|
MergeTableModel.hpp
|
||||||
MergeView.h
|
MergeView.hpp
|
||||||
ObjectEditor.h
|
ObjectEditor.hpp
|
||||||
PreferencesDialog.h
|
PreferencesDialog.hpp
|
||||||
PrinterMonitor.h
|
PrinterMonitor.hpp
|
||||||
PrintView.h
|
PrintView.hpp
|
||||||
PropertiesView.h
|
PropertiesView.hpp
|
||||||
Preview.h
|
Preview.hpp
|
||||||
ReportBugDialog.h
|
ReportBugDialog.hpp
|
||||||
SelectProductDialog.h
|
SelectProductDialog.hpp
|
||||||
SimplePreview.h
|
SimplePreview.hpp
|
||||||
StartupView.h
|
StartupView.hpp
|
||||||
TemplateDesigner.h
|
TemplateDesigner.hpp
|
||||||
TemplatePicker.h
|
TemplatePicker.hpp
|
||||||
UndoRedoModel.h
|
UndoRedoModel.hpp
|
||||||
VariablesView.h
|
VariablesView.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set (glabels_forms
|
set (glabels_forms
|
||||||
@@ -131,7 +131,7 @@ add_executable (glabels-qt WIN32
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_compile_features (glabels-qt
|
target_compile_features (glabels-qt
|
||||||
PUBLIC cxx_std_11
|
PUBLIC cxx_std_20
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories (glabels-qt
|
target_include_directories (glabels-qt
|
||||||
|
|||||||
+145
-144
@@ -1,184 +1,185 @@
|
|||||||
/* ColorButton.cpp
|
// ColorButton.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014-2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014-2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "ColorButton.h"
|
|
||||||
|
|
||||||
#include "ColorSwatch.h"
|
#include "ColorButton.hpp"
|
||||||
|
|
||||||
|
#include "ColorSwatch.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QtDebug>
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const int SWATCH_W = 64;
|
||||||
|
const int SWATCH_H = 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
ColorButton::ColorButton( QWidget* parent )
|
||||||
// Private
|
: QPushButton( parent ), mIsDefault(0), mDialog(nullptr)
|
||||||
//
|
{
|
||||||
namespace
|
// empty
|
||||||
{
|
}
|
||||||
const int SWATCH_W = 64;
|
|
||||||
const int SWATCH_H = 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ColorButton::ColorButton( QWidget* parent )
|
void ColorButton::init( const QString& defaultLabel,
|
||||||
: QPushButton( parent ), mIsDefault(0), mDialog(nullptr)
|
const QColor& defaultColor,
|
||||||
{
|
const QColor& color,
|
||||||
// empty
|
bool showUseFieldButton )
|
||||||
}
|
{
|
||||||
|
mDefaultColor = defaultColor;
|
||||||
|
mColorNode = model::ColorNode( color );
|
||||||
|
|
||||||
|
setMinimumSize( QSize( 85, 34 ) );
|
||||||
|
setIconSize( QSize(SWATCH_W, SWATCH_H) );
|
||||||
|
|
||||||
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
||||||
|
setText( "" );
|
||||||
|
setCheckable( true );
|
||||||
|
|
||||||
|
mDialog = new ColorPaletteDialog( defaultLabel,
|
||||||
|
defaultColor,
|
||||||
|
color,
|
||||||
|
showUseFieldButton );
|
||||||
|
|
||||||
|
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
|
||||||
|
connect( mDialog, SIGNAL(colorChanged(model::ColorNode,bool)),
|
||||||
|
this, SLOT(onPaletteDialogChanged(model::ColorNode,bool)) );
|
||||||
|
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
|
||||||
|
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::init( const QString& defaultLabel,
|
void ColorButton::setColorNode( model::ColorNode colorNode )
|
||||||
const QColor& defaultColor,
|
{
|
||||||
const QColor& color,
|
mIsDefault = false;
|
||||||
bool showUseFieldButton )
|
|
||||||
{
|
|
||||||
mDefaultColor = defaultColor;
|
|
||||||
mColorNode = model::ColorNode( color );
|
|
||||||
|
|
||||||
setMinimumSize( QSize( 85, 34 ) );
|
mColorNode = colorNode;
|
||||||
setIconSize( QSize(SWATCH_W, SWATCH_H) );
|
|
||||||
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
if ( colorNode.isField() )
|
||||||
setText( "" );
|
{
|
||||||
setCheckable( true );
|
setIcon( QIcon() );
|
||||||
|
setText( QString("${%1}").arg( colorNode.key() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
||||||
|
setText( "" );
|
||||||
|
}
|
||||||
|
|
||||||
mDialog = new ColorPaletteDialog( defaultLabel,
|
mDialog->setColorNode( colorNode );
|
||||||
defaultColor,
|
}
|
||||||
color,
|
|
||||||
showUseFieldButton );
|
|
||||||
|
|
||||||
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
|
|
||||||
connect( mDialog, SIGNAL(colorChanged(model::ColorNode,bool)),
|
|
||||||
this, SLOT(onPaletteDialogChanged(model::ColorNode,bool)) );
|
|
||||||
connect( mDialog, SIGNAL(accepted()), this, SLOT(onPaletteDialogAccepted()) );
|
|
||||||
connect( mDialog, SIGNAL(rejected()), this, SLOT(onPaletteDialogRejected()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setColorNode( model::ColorNode colorNode )
|
void ColorButton::setColor( QColor color )
|
||||||
{
|
{
|
||||||
mIsDefault = false;
|
mIsDefault = false;
|
||||||
|
|
||||||
mColorNode = colorNode;
|
mColorNode.setField( false );
|
||||||
|
mColorNode.setColor( color );
|
||||||
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
if ( colorNode.isField() )
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
||||||
{
|
setText( "" );
|
||||||
setIcon( QIcon() );
|
}
|
||||||
setText( QString("${%1}").arg( colorNode.key() ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
|
||||||
setText( "" );
|
|
||||||
}
|
|
||||||
|
|
||||||
mDialog->setColorNode( colorNode );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setColor( QColor color )
|
void ColorButton::setToDefault()
|
||||||
{
|
{
|
||||||
mIsDefault = false;
|
mIsDefault = true;
|
||||||
|
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
mColorNode.setColor( color );
|
mColorNode.setColor( mDefaultColor );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
|
||||||
setText( "" );
|
setText( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setToDefault()
|
model::ColorNode ColorButton::colorNode()
|
||||||
{
|
{
|
||||||
mIsDefault = true;
|
return mColorNode;
|
||||||
|
}
|
||||||
mColorNode.setField( false );
|
|
||||||
mColorNode.setColor( mDefaultColor );
|
|
||||||
mColorNode.setKey( "" );
|
|
||||||
|
|
||||||
setIcon( QIcon(ColorSwatch( SWATCH_W, SWATCH_H, mDefaultColor ) ) );
|
|
||||||
setText( "" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
model::ColorNode ColorButton::colorNode()
|
void ColorButton::setKeys( const merge::Merge* merge,
|
||||||
{
|
const model::Variables& variables )
|
||||||
return mColorNode;
|
{
|
||||||
}
|
mDialog->setKeys( merge, variables );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::setKeys( const merge::Merge* merge,
|
void ColorButton::onButtonToggled( bool checked )
|
||||||
const model::Variables& variables )
|
{
|
||||||
{
|
if ( checked )
|
||||||
mDialog->setKeys( merge, variables );
|
{
|
||||||
}
|
///
|
||||||
|
/// @TODO: improve positioning of dialog -- near edges of screen.
|
||||||
|
///
|
||||||
|
QPoint dialogPos( 0, height() );
|
||||||
|
mDialog->move( mapToGlobal(dialogPos) );
|
||||||
|
|
||||||
|
mDialog->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onButtonToggled( bool checked )
|
void ColorButton::onPaletteDialogAccepted()
|
||||||
{
|
{
|
||||||
if ( checked )
|
setChecked( false );
|
||||||
{
|
}
|
||||||
///
|
|
||||||
/// @TODO: improve positioning of dialog -- near edges of screen.
|
|
||||||
///
|
|
||||||
QPoint dialogPos( 0, height() );
|
|
||||||
mDialog->move( mapToGlobal(dialogPos) );
|
|
||||||
|
|
||||||
mDialog->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onPaletteDialogAccepted()
|
void ColorButton::onPaletteDialogRejected()
|
||||||
{
|
{
|
||||||
setChecked( false );
|
setChecked( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorButton::onPaletteDialogRejected()
|
void ColorButton::onPaletteDialogChanged( model::ColorNode colorNode, bool isDefault )
|
||||||
{
|
{
|
||||||
setChecked( false );
|
mColorNode = colorNode;
|
||||||
}
|
mIsDefault = isDefault;
|
||||||
|
|
||||||
|
if ( colorNode.isField() )
|
||||||
|
{
|
||||||
|
setIcon( QIcon() );
|
||||||
|
setText( QString("${%1}").arg( colorNode.key() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
||||||
|
setText( "" );
|
||||||
|
}
|
||||||
|
|
||||||
void ColorButton::onPaletteDialogChanged( model::ColorNode colorNode, bool isDefault )
|
emit colorChanged();
|
||||||
{
|
}
|
||||||
mColorNode = colorNode;
|
|
||||||
mIsDefault = isDefault;
|
|
||||||
|
|
||||||
if ( colorNode.isField() )
|
|
||||||
{
|
|
||||||
setIcon( QIcon() );
|
|
||||||
setText( QString("${%1}").arg( colorNode.key() ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
|
||||||
setText( "" );
|
|
||||||
}
|
|
||||||
|
|
||||||
emit colorChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
/* ColorButton.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014-2016 Jaye 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 ColorButton_h
|
|
||||||
#define ColorButton_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "ColorPaletteDialog.h"
|
|
||||||
|
|
||||||
#include "model/ColorNode.h"
|
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Color Button
|
|
||||||
///
|
|
||||||
class ColorButton : public QPushButton
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
ColorButton( QWidget* parent = nullptr );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
/////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void colorChanged();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Public Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
void init( const QString& defaultLabel,
|
|
||||||
const QColor& defaultColor,
|
|
||||||
const QColor& color,
|
|
||||||
bool showUseFieldButton = true );
|
|
||||||
|
|
||||||
void setColorNode( model::ColorNode colorNode );
|
|
||||||
void setColor( QColor color );
|
|
||||||
void setToDefault();
|
|
||||||
model::ColorNode colorNode();
|
|
||||||
|
|
||||||
void setKeys( const merge::Merge* merge,
|
|
||||||
const model::Variables& variables );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Slots
|
|
||||||
/////////////////////////////////
|
|
||||||
private slots:
|
|
||||||
void onButtonToggled( bool checked );
|
|
||||||
void onPaletteDialogAccepted();
|
|
||||||
void onPaletteDialogRejected();
|
|
||||||
void onPaletteDialogChanged( model::ColorNode colorNode, bool isDefault );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Members
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
QColor mDefaultColor;
|
|
||||||
bool mIsDefault;
|
|
||||||
model::ColorNode mColorNode;
|
|
||||||
|
|
||||||
ColorPaletteDialog* mDialog;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorButton_h
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
// ColorButton.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014-2016 Jaye 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 ColorButton_hpp
|
||||||
|
#define ColorButton_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "ColorPaletteDialog.hpp"
|
||||||
|
|
||||||
|
#include "model/ColorNode.hpp"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Button
|
||||||
|
///
|
||||||
|
class ColorButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
ColorButton( QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void colorChanged();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Public Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
void init( const QString& defaultLabel,
|
||||||
|
const QColor& defaultColor,
|
||||||
|
const QColor& color,
|
||||||
|
bool showUseFieldButton = true );
|
||||||
|
|
||||||
|
void setColorNode( model::ColorNode colorNode );
|
||||||
|
void setColor( QColor color );
|
||||||
|
void setToDefault();
|
||||||
|
model::ColorNode colorNode();
|
||||||
|
|
||||||
|
void setKeys( const merge::Merge* merge,
|
||||||
|
const model::Variables& variables );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onButtonToggled( bool checked );
|
||||||
|
void onPaletteDialogAccepted();
|
||||||
|
void onPaletteDialogRejected();
|
||||||
|
void onPaletteDialogChanged( model::ColorNode colorNode, bool isDefault );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Members
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
QColor mDefaultColor;
|
||||||
|
bool mIsDefault;
|
||||||
|
model::ColorNode mColorNode;
|
||||||
|
|
||||||
|
ColorPaletteDialog* mDialog;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ColorButton_hpp
|
||||||
+124
-129
@@ -1,155 +1,150 @@
|
|||||||
/* ColorHistory.cpp
|
// ColorHistory.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014-2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014-2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "ColorHistory.h"
|
|
||||||
|
|
||||||
|
#include "ColorHistory.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QtDebug>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
ColorHistory::ColorHistory()
|
ColorHistory* ColorHistory::instance()
|
||||||
{
|
{
|
||||||
// empty
|
static ColorHistory* singletonInstance = nullptr;
|
||||||
}
|
|
||||||
|
if ( singletonInstance == nullptr )
|
||||||
|
{
|
||||||
|
singletonInstance = new ColorHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
return singletonInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ColorHistory* ColorHistory::instance()
|
void ColorHistory::addColor( const QColor &color, const QString& name )
|
||||||
{
|
{
|
||||||
static ColorHistory* singletonInstance = nullptr;
|
QString nameColor = name + ":" + color.name();
|
||||||
|
|
||||||
if ( singletonInstance == nullptr )
|
QStringList nameColorList = readNameColorList();
|
||||||
{
|
|
||||||
singletonInstance = new ColorHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
return singletonInstance;
|
// Remove any occurrences of this color already in list
|
||||||
}
|
nameColorList.removeAll( nameColor );
|
||||||
|
|
||||||
|
// Now add to list
|
||||||
|
nameColorList.append( nameColor );
|
||||||
|
|
||||||
|
// Remove oldest colors, if size exceeds current max
|
||||||
|
while ( nameColorList.size() > MAX_COLORS )
|
||||||
|
{
|
||||||
|
nameColorList.removeFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
writeNameColorList( nameColorList );
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorHistory::addColor( const QColor &color, const QString& name )
|
QList<QColor> ColorHistory::getColors()
|
||||||
{
|
{
|
||||||
QString nameColor = name + ":" + color.name();
|
QList<QColor> colorList;
|
||||||
|
|
||||||
QStringList nameColorList = readNameColorList();
|
for ( QString& nameColor : readNameColorList() )
|
||||||
|
{
|
||||||
|
QStringList v = nameColor.split( ':' );
|
||||||
|
if ( v.size() == 2 )
|
||||||
|
{
|
||||||
|
colorList << QColor( v[1] );
|
||||||
|
}
|
||||||
|
else if ( v.size() == 1 )
|
||||||
|
{
|
||||||
|
// Old-style, no name
|
||||||
|
colorList << QColor( v[0] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Should not happen
|
||||||
|
qWarning() << "Invalid color history.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove any occurrences of this color already in list
|
return colorList;
|
||||||
nameColorList.removeAll( nameColor );
|
}
|
||||||
|
|
||||||
// Now add to list
|
|
||||||
nameColorList.append( nameColor );
|
|
||||||
|
|
||||||
// Remove oldest colors, if size exceeds current max
|
|
||||||
while ( nameColorList.size() > MAX_COLORS )
|
|
||||||
{
|
|
||||||
nameColorList.removeFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
writeNameColorList( nameColorList );
|
|
||||||
|
|
||||||
emit changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<QColor> ColorHistory::getColors()
|
QStringList ColorHistory::getNames()
|
||||||
{
|
{
|
||||||
QList<QColor> colorList;
|
QStringList nameList;
|
||||||
|
|
||||||
for ( QString& nameColor : readNameColorList() )
|
|
||||||
{
|
|
||||||
QStringList v = nameColor.split( ':' );
|
|
||||||
if ( v.size() == 2 )
|
|
||||||
{
|
|
||||||
colorList << QColor( v[1] );
|
|
||||||
}
|
|
||||||
else if ( v.size() == 1 )
|
|
||||||
{
|
|
||||||
// Old-style, no name
|
|
||||||
colorList << QColor( v[0] );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Should not happen
|
|
||||||
qWarning() << "Invalid color history.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return colorList;
|
for ( QString& nameColor : readNameColorList() )
|
||||||
}
|
{
|
||||||
|
QStringList v = nameColor.split( ':' );
|
||||||
|
if ( v.size() == 2 )
|
||||||
|
{
|
||||||
|
nameList << v[0];
|
||||||
|
}
|
||||||
|
else if ( v.size() == 1 )
|
||||||
|
{
|
||||||
|
// Old-style, no name
|
||||||
|
nameList << QString(tr("color %1")).arg( v[0] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Should not happen
|
||||||
|
qWarning() << "Invalid color history.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nameList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList ColorHistory::getNames()
|
QStringList ColorHistory::readNameColorList()
|
||||||
{
|
{
|
||||||
QStringList nameList;
|
QStringList defaultList;
|
||||||
|
QSettings settings;
|
||||||
for ( QString& nameColor : readNameColorList() )
|
|
||||||
{
|
|
||||||
QStringList v = nameColor.split( ':' );
|
|
||||||
if ( v.size() == 2 )
|
|
||||||
{
|
|
||||||
nameList << v[0];
|
|
||||||
}
|
|
||||||
else if ( v.size() == 1 )
|
|
||||||
{
|
|
||||||
// Old-style, no name
|
|
||||||
nameList << QString(tr("color %1")).arg( v[0] );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Should not happen
|
|
||||||
qWarning() << "Invalid color history.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nameList;
|
settings.beginGroup( "ColorHistory" );
|
||||||
}
|
QStringList nameColorList = settings.value( "colors", defaultList ).toStringList();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
// Remove oldest colors, if size exceeds current max
|
||||||
|
while ( nameColorList.size() > MAX_COLORS )
|
||||||
|
{
|
||||||
|
nameColorList.removeFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nameColorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList ColorHistory::readNameColorList()
|
void ColorHistory::writeNameColorList( const QStringList& nameColorList )
|
||||||
{
|
{
|
||||||
QStringList defaultList;
|
// Save
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
settings.beginGroup( "ColorHistory" );
|
||||||
settings.beginGroup( "ColorHistory" );
|
settings.setValue( "colors", nameColorList );
|
||||||
QStringList nameColorList = settings.value( "colors", defaultList ).toStringList();
|
settings.endGroup();
|
||||||
settings.endGroup();
|
}
|
||||||
|
|
||||||
// Remove oldest colors, if size exceeds current max
|
|
||||||
while ( nameColorList.size() > MAX_COLORS )
|
|
||||||
{
|
|
||||||
nameColorList.removeFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
return nameColorList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorHistory::writeNameColorList( const QStringList& nameColorList )
|
|
||||||
{
|
|
||||||
// Save
|
|
||||||
QSettings settings;
|
|
||||||
settings.beginGroup( "ColorHistory" );
|
|
||||||
settings.setValue( "colors", nameColorList );
|
|
||||||
settings.endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
/* ColorHistory.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014-2016 Jaye 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 ColorHistory_h
|
|
||||||
#define ColorHistory_h
|
|
||||||
|
|
||||||
|
|
||||||
#include <QColor>
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Color History
|
|
||||||
///
|
|
||||||
class ColorHistory : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
static const int MAX_COLORS = 9;
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
ColorHistory();
|
|
||||||
|
|
||||||
public:
|
|
||||||
static ColorHistory* instance();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
/////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void changed();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Public Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
void addColor( const QColor& color, const QString& name );
|
|
||||||
QList<QColor> getColors();
|
|
||||||
QStringList getNames();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
QStringList readNameColorList();
|
|
||||||
void writeNameColorList( const QStringList& nameColorList );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Members
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorHistory_h
|
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
// ColorHistory.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014-2016 Jaye 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 ColorHistory_hpp
|
||||||
|
#define ColorHistory_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color History
|
||||||
|
///
|
||||||
|
class ColorHistory : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const int MAX_COLORS = 9;
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
ColorHistory() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static ColorHistory* instance();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void changed();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Public Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
void addColor( const QColor& color, const QString& name );
|
||||||
|
QList<QColor> getColors();
|
||||||
|
QStringList getNames();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
QStringList readNameColorList();
|
||||||
|
void writeNameColorList( const QStringList& nameColorList );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Members
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ColorHistory_hpp
|
||||||
+249
-249
@@ -1,316 +1,316 @@
|
|||||||
/* ColorPaletteDialog.cpp
|
// ColorPaletteDialog.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014-2016 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014-2016 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "ColorPaletteDialog.h"
|
#include "ColorPaletteDialog.hpp"
|
||||||
|
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
#include <QDebug>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtDebug>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
// Static data
|
// Static data
|
||||||
//
|
//
|
||||||
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
ColorPaletteDialog::ColorTableEntry ColorPaletteDialog::mColorTable[] = {
|
||||||
|
|
||||||
{ "#ef2929", QT_TRANSLATE_NOOP("Color name", "Light Scarlet Red") },
|
{ "#ef2929", QT_TRANSLATE_NOOP("Color name", "Light Scarlet Red") },
|
||||||
{ "#fcaf3e", QT_TRANSLATE_NOOP("Color name", "Light Orange") },
|
{ "#fcaf3e", QT_TRANSLATE_NOOP("Color name", "Light Orange") },
|
||||||
{ "#fce94f", QT_TRANSLATE_NOOP("Color name", "Light Butter") },
|
{ "#fce94f", QT_TRANSLATE_NOOP("Color name", "Light Butter") },
|
||||||
{ "#8ae234", QT_TRANSLATE_NOOP("Color name", "Light Chameleon") },
|
{ "#8ae234", QT_TRANSLATE_NOOP("Color name", "Light Chameleon") },
|
||||||
{ "#729fcf", QT_TRANSLATE_NOOP("Color name", "Light Sky Blue") },
|
{ "#729fcf", QT_TRANSLATE_NOOP("Color name", "Light Sky Blue") },
|
||||||
{ "#ad7fa8", QT_TRANSLATE_NOOP("Color name", "Light Plum") },
|
{ "#ad7fa8", QT_TRANSLATE_NOOP("Color name", "Light Plum") },
|
||||||
{ "#e9b96e", QT_TRANSLATE_NOOP("Color name", "Light Chocolate") },
|
{ "#e9b96e", QT_TRANSLATE_NOOP("Color name", "Light Chocolate") },
|
||||||
{ "#888a85", QT_TRANSLATE_NOOP("Color name", "Light Aluminum 1") },
|
{ "#888a85", QT_TRANSLATE_NOOP("Color name", "Light Aluminum 1") },
|
||||||
{ "#eeeeec", QT_TRANSLATE_NOOP("Color name", "Light Aluminum 2") },
|
{ "#eeeeec", QT_TRANSLATE_NOOP("Color name", "Light Aluminum 2") },
|
||||||
|
|
||||||
{ "#cc0000", QT_TRANSLATE_NOOP("Color name", "Scarlet Red") },
|
{ "#cc0000", QT_TRANSLATE_NOOP("Color name", "Scarlet Red") },
|
||||||
{ "#f57900", QT_TRANSLATE_NOOP("Color name", "Orange") },
|
{ "#f57900", QT_TRANSLATE_NOOP("Color name", "Orange") },
|
||||||
{ "#edd400", QT_TRANSLATE_NOOP("Color name", "Butter") },
|
{ "#edd400", QT_TRANSLATE_NOOP("Color name", "Butter") },
|
||||||
{ "#73d216", QT_TRANSLATE_NOOP("Color name", "Chameleon") },
|
{ "#73d216", QT_TRANSLATE_NOOP("Color name", "Chameleon") },
|
||||||
{ "#3465a4", QT_TRANSLATE_NOOP("Color name", "Sky Blue") },
|
{ "#3465a4", QT_TRANSLATE_NOOP("Color name", "Sky Blue") },
|
||||||
{ "#75507b", QT_TRANSLATE_NOOP("Color name", "Plum") },
|
{ "#75507b", QT_TRANSLATE_NOOP("Color name", "Plum") },
|
||||||
{ "#c17d11", QT_TRANSLATE_NOOP("Color name", "Chocolate") },
|
{ "#c17d11", QT_TRANSLATE_NOOP("Color name", "Chocolate") },
|
||||||
{ "#555753", QT_TRANSLATE_NOOP("Color name", "Aluminum 1") },
|
{ "#555753", QT_TRANSLATE_NOOP("Color name", "Aluminum 1") },
|
||||||
{ "#d3d7cf", QT_TRANSLATE_NOOP("Color name", "Aluminum 2") },
|
{ "#d3d7cf", QT_TRANSLATE_NOOP("Color name", "Aluminum 2") },
|
||||||
|
|
||||||
{ "#a40000", QT_TRANSLATE_NOOP("Color name", "Dark Scarlet Red") },
|
{ "#a40000", QT_TRANSLATE_NOOP("Color name", "Dark Scarlet Red") },
|
||||||
{ "#ce5c00", QT_TRANSLATE_NOOP("Color name", "Dark Orange") },
|
{ "#ce5c00", QT_TRANSLATE_NOOP("Color name", "Dark Orange") },
|
||||||
{ "#c4a000", QT_TRANSLATE_NOOP("Color name", "Dark Butter") },
|
{ "#c4a000", QT_TRANSLATE_NOOP("Color name", "Dark Butter") },
|
||||||
{ "#4e9a06", QT_TRANSLATE_NOOP("Color name", "Dark Chameleon") },
|
{ "#4e9a06", QT_TRANSLATE_NOOP("Color name", "Dark Chameleon") },
|
||||||
{ "#204a87", QT_TRANSLATE_NOOP("Color name", "Dark Sky Blue") },
|
{ "#204a87", QT_TRANSLATE_NOOP("Color name", "Dark Sky Blue") },
|
||||||
{ "#5c3566", QT_TRANSLATE_NOOP("Color name", "Dark Plum") },
|
{ "#5c3566", QT_TRANSLATE_NOOP("Color name", "Dark Plum") },
|
||||||
{ "#8f5902", QT_TRANSLATE_NOOP("Color name", "Dark Chocolate") },
|
{ "#8f5902", QT_TRANSLATE_NOOP("Color name", "Dark Chocolate") },
|
||||||
{ "#2e3436", QT_TRANSLATE_NOOP("Color name", "Dark Aluminum 1") },
|
{ "#2e3436", QT_TRANSLATE_NOOP("Color name", "Dark Aluminum 1") },
|
||||||
{ "#babdb6", QT_TRANSLATE_NOOP("Color name", "Dark Aluminum 2") },
|
{ "#babdb6", QT_TRANSLATE_NOOP("Color name", "Dark Aluminum 2") },
|
||||||
|
|
||||||
{ "#000000", QT_TRANSLATE_NOOP("Color name", "Black") },
|
{ "#000000", QT_TRANSLATE_NOOP("Color name", "Black") },
|
||||||
{ "#2e3436", QT_TRANSLATE_NOOP("Color name", "Very Dark Gray") },
|
{ "#2e3436", QT_TRANSLATE_NOOP("Color name", "Very Dark Gray") },
|
||||||
{ "#555753", QT_TRANSLATE_NOOP("Color name", "Darker Gray") },
|
{ "#555753", QT_TRANSLATE_NOOP("Color name", "Darker Gray") },
|
||||||
{ "#888a85", QT_TRANSLATE_NOOP("Color name", "Dark Gray") },
|
{ "#888a85", QT_TRANSLATE_NOOP("Color name", "Dark Gray") },
|
||||||
{ "#babdb6", QT_TRANSLATE_NOOP("Color name", "Medium Gray") },
|
{ "#babdb6", QT_TRANSLATE_NOOP("Color name", "Medium Gray") },
|
||||||
{ "#d3d7cf", QT_TRANSLATE_NOOP("Color name", "Light Gray") },
|
{ "#d3d7cf", QT_TRANSLATE_NOOP("Color name", "Light Gray") },
|
||||||
{ "#eeeeec", QT_TRANSLATE_NOOP("Color name", "Lighter Gray") },
|
{ "#eeeeec", QT_TRANSLATE_NOOP("Color name", "Lighter Gray") },
|
||||||
{ "#f3f3f3", QT_TRANSLATE_NOOP("Color name", "Very Light Gray") },
|
{ "#f3f3f3", QT_TRANSLATE_NOOP("Color name", "Very Light Gray") },
|
||||||
{ "#ffffff", QT_TRANSLATE_NOOP("Color name", "White") }
|
{ "#ffffff", QT_TRANSLATE_NOOP("Color name", "White") }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
||||||
const QColor& defaultColor,
|
const QColor& defaultColor,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
bool showUseFieldButton,
|
bool showUseFieldButton,
|
||||||
QWidget* parent )
|
QWidget* parent )
|
||||||
: QDialog( parent )
|
: QDialog( parent )
|
||||||
{
|
{
|
||||||
mColorHistory = ColorHistory::instance();
|
mColorHistory = ColorHistory::instance();
|
||||||
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
|
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
|
||||||
|
|
||||||
mDefaultColor = defaultColor;
|
mDefaultColor = defaultColor;
|
||||||
mColorNode = model::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 );
|
||||||
|
|
||||||
auto* vLayout = new QVBoxLayout();
|
auto* vLayout = new QVBoxLayout();
|
||||||
vLayout->setContentsMargins( 0, 0, 0, 0 );
|
vLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
vLayout->setSpacing( 0 );
|
vLayout->setSpacing( 0 );
|
||||||
|
|
||||||
//
|
//
|
||||||
// Construct Standard Colors Grid
|
// Construct Standard Colors Grid
|
||||||
//
|
//
|
||||||
auto* standardColorsGroup = new QGroupBox( tr("Standard Colors") );
|
auto* standardColorsGroup = new QGroupBox( tr("Standard Colors") );
|
||||||
standardColorsGroup->setAlignment( Qt::AlignHCenter );
|
standardColorsGroup->setAlignment( Qt::AlignHCenter );
|
||||||
vLayout->addWidget( standardColorsGroup );
|
vLayout->addWidget( standardColorsGroup );
|
||||||
|
|
||||||
auto* mainPaletteLayout = new QGridLayout();
|
auto* mainPaletteLayout = new QGridLayout();
|
||||||
mainPaletteLayout->setSpacing( 0 );
|
mainPaletteLayout->setSpacing( 0 );
|
||||||
for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ )
|
for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ )
|
||||||
{
|
{
|
||||||
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
||||||
{
|
{
|
||||||
int i = iRow*PALETTE_COLS + iCol;
|
int i = iRow*PALETTE_COLS + iCol;
|
||||||
|
|
||||||
ColorPaletteItem* item = new ColorPaletteItem( i,
|
ColorPaletteItem* item = new ColorPaletteItem( i,
|
||||||
QColor( mColorTable[i].colorSpec ),
|
QColor( mColorTable[i].colorSpec ),
|
||||||
tr(mColorTable[i].trname) );
|
tr(mColorTable[i].trname) );
|
||||||
connect( item, SIGNAL(activated(int)),
|
connect( item, SIGNAL(activated(int)),
|
||||||
this, SLOT(onPaletteItemActivated(int)) );
|
this, SLOT(onPaletteItemActivated(int)) );
|
||||||
|
|
||||||
mainPaletteLayout->addWidget( item, iRow, iCol );
|
mainPaletteLayout->addWidget( item, iRow, iCol );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
standardColorsGroup->setLayout( mainPaletteLayout );
|
standardColorsGroup->setLayout( mainPaletteLayout );
|
||||||
|
|
||||||
//
|
//
|
||||||
// Construct Recent Colors Grid
|
// Construct Recent Colors Grid
|
||||||
//
|
//
|
||||||
auto* recentColorsGroup = new QGroupBox( tr("Recent Colors") );
|
auto* recentColorsGroup = new QGroupBox( tr("Recent Colors") );
|
||||||
recentColorsGroup->setAlignment( Qt::AlignHCenter );
|
recentColorsGroup->setAlignment( Qt::AlignHCenter );
|
||||||
vLayout->addWidget( recentColorsGroup );
|
vLayout->addWidget( recentColorsGroup );
|
||||||
|
|
||||||
auto* customPaletteLayout = new QHBoxLayout();
|
auto* customPaletteLayout = new QHBoxLayout();
|
||||||
customPaletteLayout->setSpacing( 0 );
|
customPaletteLayout->setSpacing( 0 );
|
||||||
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
||||||
{
|
{
|
||||||
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
|
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
|
||||||
mHistoryItem[iCol]->setEnabled( false );
|
mHistoryItem[iCol]->setEnabled( false );
|
||||||
connect( mHistoryItem[iCol], SIGNAL(activated(int)),
|
connect( mHistoryItem[iCol], SIGNAL(activated(int)),
|
||||||
this, SLOT(onHistoryItemActivated(int)) );
|
this, SLOT(onHistoryItemActivated(int)) );
|
||||||
|
|
||||||
customPaletteLayout->addWidget( mHistoryItem[iCol] );
|
customPaletteLayout->addWidget( mHistoryItem[iCol] );
|
||||||
}
|
}
|
||||||
recentColorsGroup->setLayout( customPaletteLayout );
|
recentColorsGroup->setLayout( customPaletteLayout );
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Construct Default (e.g. "No Fill") Button
|
// Construct Default (e.g. "No Fill") Button
|
||||||
//
|
//
|
||||||
auto* defaultColorButton = new QPushButton( defaultLabel );
|
auto* defaultColorButton = new QPushButton( defaultLabel );
|
||||||
defaultColorButton->setAutoDefault( false );
|
defaultColorButton->setAutoDefault( false );
|
||||||
defaultColorButton->setDefault( false );
|
defaultColorButton->setDefault( false );
|
||||||
connect( defaultColorButton, SIGNAL(clicked()), this, SLOT(onDefaultButtonClicked()) );
|
connect( defaultColorButton, SIGNAL(clicked()), this, SLOT(onDefaultButtonClicked()) );
|
||||||
vLayout->addWidget( defaultColorButton );
|
vLayout->addWidget( defaultColorButton );
|
||||||
|
|
||||||
//
|
|
||||||
// Construct Custom Color Button
|
|
||||||
//
|
|
||||||
auto* customColorButton = new QPushButton( tr("Custom color...") );
|
|
||||||
customColorButton->setAutoDefault( false );
|
|
||||||
customColorButton->setDefault( false );
|
|
||||||
connect( customColorButton, SIGNAL(clicked()), this, SLOT(onCustomColorButtonClicked()) );
|
|
||||||
vLayout->addWidget( customColorButton );
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Construct "Use field" Button
|
// Construct Custom Color Button
|
||||||
//
|
//
|
||||||
if ( showUseFieldButton )
|
auto* customColorButton = new QPushButton( tr("Custom color...") );
|
||||||
{
|
customColorButton->setAutoDefault( false );
|
||||||
mFieldButton = new FieldButton();
|
customColorButton->setDefault( false );
|
||||||
mFieldButton->setText( tr("Use substitution field") );
|
connect( customColorButton, SIGNAL(clicked()), this, SLOT(onCustomColorButtonClicked()) );
|
||||||
mFieldButton->setAutoDefault( false );
|
vLayout->addWidget( customColorButton );
|
||||||
mFieldButton->setDefault( false );
|
|
||||||
connect( mFieldButton, SIGNAL(keySelected(QString)), this, SLOT(onKeySelected(QString)) );
|
|
||||||
vLayout->addWidget( mFieldButton );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFieldButton = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
setLayout( vLayout );
|
//
|
||||||
|
// Construct "Use field" Button
|
||||||
|
//
|
||||||
|
if ( showUseFieldButton )
|
||||||
|
{
|
||||||
|
mFieldButton = new FieldButton();
|
||||||
|
mFieldButton->setText( tr("Use substitution field") );
|
||||||
|
mFieldButton->setAutoDefault( false );
|
||||||
|
mFieldButton->setDefault( false );
|
||||||
|
connect( mFieldButton, SIGNAL(keySelected(QString)), this, SLOT(onKeySelected(QString)) );
|
||||||
|
vLayout->addWidget( mFieldButton );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mFieldButton = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
loadCustomColorHistory();
|
setLayout( vLayout );
|
||||||
}
|
|
||||||
|
loadCustomColorHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::setColorNode( const model::ColorNode& colorNode )
|
void ColorPaletteDialog::setColorNode( const model::ColorNode& colorNode )
|
||||||
{
|
{
|
||||||
mColorNode = colorNode;
|
mColorNode = colorNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::setKeys( const merge::Merge* merge,
|
void ColorPaletteDialog::setKeys( const merge::Merge* merge,
|
||||||
const model::Variables& variables )
|
const model::Variables& variables )
|
||||||
{
|
{
|
||||||
if (mFieldButton)
|
if (mFieldButton)
|
||||||
{
|
{
|
||||||
mFieldButton->setKeys( merge, variables );
|
mFieldButton->setKeys( merge, variables );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
void ColorPaletteDialog::onPaletteItemActivated( int id )
|
||||||
{
|
{
|
||||||
model::ColorNode newColorNode;
|
model::ColorNode newColorNode;
|
||||||
newColorNode.setField( false );
|
newColorNode.setField( false );
|
||||||
newColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
newColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
||||||
newColorNode.setKey( "" );
|
newColorNode.setKey( "" );
|
||||||
|
|
||||||
if ( newColorNode != mColorNode )
|
if ( newColorNode != mColorNode )
|
||||||
{
|
{
|
||||||
mColorNode = newColorNode;
|
mColorNode = newColorNode;
|
||||||
|
|
||||||
mColorHistory->addColor( mColorNode.color(), mColorTable[id].trname );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
mColorHistory->addColor( mColorNode.color(), mColorTable[id].trname );
|
||||||
accept();
|
|
||||||
}
|
emit colorChanged( mColorNode, false );
|
||||||
}
|
accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
void ColorPaletteDialog::onHistoryItemActivated( int id )
|
||||||
{
|
{
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
mColorNode.setColor( mColorHistory->getColors()[id] );
|
mColorNode.setColor( mColorHistory->getColors()[id] );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onDefaultButtonClicked()
|
void ColorPaletteDialog::onDefaultButtonClicked()
|
||||||
{
|
{
|
||||||
mColorNode.setField( false );
|
mColorNode.setField( false );
|
||||||
mColorNode.setColor( mDefaultColor );
|
mColorNode.setColor( mDefaultColor );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
emit colorChanged( mColorNode, true );
|
emit colorChanged( mColorNode, true );
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onCustomColorButtonClicked()
|
void ColorPaletteDialog::onCustomColorButtonClicked()
|
||||||
{
|
{
|
||||||
QColorDialog dlg( mColorNode.color(), this );
|
QColorDialog dlg( mColorNode.color(), this );
|
||||||
dlg.setWindowTitle( tr("Custom Color") );
|
dlg.setWindowTitle( tr("Custom Color") );
|
||||||
|
|
||||||
if ( dlg.exec() )
|
if ( dlg.exec() )
|
||||||
{
|
{
|
||||||
model::ColorNode newColorNode;
|
model::ColorNode newColorNode;
|
||||||
|
|
||||||
newColorNode.setField( false );
|
newColorNode.setField( false );
|
||||||
newColorNode.setColor( dlg.currentColor() );
|
newColorNode.setColor( dlg.currentColor() );
|
||||||
newColorNode.setKey( "" );
|
newColorNode.setKey( "" );
|
||||||
|
|
||||||
if ( newColorNode != mColorNode )
|
if ( newColorNode != mColorNode )
|
||||||
{
|
{
|
||||||
mColorNode = newColorNode;
|
mColorNode = newColorNode;
|
||||||
|
|
||||||
// TRANSLATORS
|
|
||||||
//: %1 = color specification in hex. String must not contain a colon (:).
|
|
||||||
mColorHistory->addColor( mColorNode.color(),
|
|
||||||
QString(tr("Custom Color %1")).arg(mColorNode.color().name()) );
|
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
// TRANSLATORS
|
||||||
accept();
|
//: %1 = color specification in hex. String must not contain a colon (:).
|
||||||
}
|
mColorHistory->addColor( mColorNode.color(),
|
||||||
}
|
QString(tr("Custom Color %1")).arg(mColorNode.color().name()) );
|
||||||
}
|
|
||||||
|
emit colorChanged( mColorNode, false );
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onColorHistoryChanged()
|
void ColorPaletteDialog::onColorHistoryChanged()
|
||||||
{
|
{
|
||||||
loadCustomColorHistory();
|
loadCustomColorHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::loadCustomColorHistory()
|
void ColorPaletteDialog::loadCustomColorHistory()
|
||||||
{
|
{
|
||||||
QStringList nameList = mColorHistory->getNames();
|
QStringList nameList = mColorHistory->getNames();
|
||||||
QList<QColor> colorList = mColorHistory->getColors();
|
QList<QColor> colorList = mColorHistory->getColors();
|
||||||
|
|
||||||
int id = 0;
|
|
||||||
for ( QColor color : colorList )
|
|
||||||
{
|
|
||||||
mHistoryItem[id]->setColor( id, color, nameList[id] );
|
|
||||||
mHistoryItem[id]->setEnabled( true );
|
|
||||||
id++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( id < PALETTE_ROWS )
|
int id = 0;
|
||||||
{
|
for ( QColor color : colorList )
|
||||||
mHistoryItem[id]->setEnabled( false );
|
{
|
||||||
id++;
|
mHistoryItem[id]->setColor( id, color, nameList[id] );
|
||||||
}
|
mHistoryItem[id]->setEnabled( true );
|
||||||
}
|
id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( id < PALETTE_ROWS )
|
||||||
|
{
|
||||||
|
mHistoryItem[id]->setEnabled( false );
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onKeySelected( QString key )
|
void ColorPaletteDialog::onKeySelected( QString key )
|
||||||
{
|
{
|
||||||
mColorNode.setField( true );
|
mColorNode.setField( true );
|
||||||
mColorNode.setColor( QColor( 0xee, 0xee, 0xec ) );
|
mColorNode.setColor( QColor( 0xee, 0xee, 0xec ) );
|
||||||
mColorNode.setKey( key );
|
mColorNode.setKey( key );
|
||||||
|
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,119 +0,0 @@
|
|||||||
/* ColorPaletteDialog.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014-2016 Jaye 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 ColorPaletteDialog_h
|
|
||||||
#define ColorPaletteDialog_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "ColorHistory.h"
|
|
||||||
#include "ColorPaletteItem.h"
|
|
||||||
#include "FieldButton.h"
|
|
||||||
|
|
||||||
#include "model/ColorNode.h"
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Color Palette Dialog
|
|
||||||
///
|
|
||||||
class ColorPaletteDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
ColorPaletteDialog( const QString& defaultLabel,
|
|
||||||
const QColor& defaultColor,
|
|
||||||
const QColor& color,
|
|
||||||
bool showUseFieldButton = true,
|
|
||||||
QWidget* parent = nullptr );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
/////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void colorChanged( model::ColorNode colorNode, bool isDefault );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Public Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
void setColorNode( const model::ColorNode& colorNode );
|
|
||||||
|
|
||||||
void setKeys( const merge::Merge* merge,
|
|
||||||
const model::Variables& variables );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Slots
|
|
||||||
/////////////////////////////////
|
|
||||||
private slots:
|
|
||||||
void onPaletteItemActivated( int id );
|
|
||||||
void onHistoryItemActivated( int id );
|
|
||||||
void onDefaultButtonClicked();
|
|
||||||
void onCustomColorButtonClicked();
|
|
||||||
void onKeySelected( QString key );
|
|
||||||
void onColorHistoryChanged();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
void loadCustomColorHistory();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Members
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
QColor mDefaultColor;
|
|
||||||
model::ColorNode mColorNode;
|
|
||||||
|
|
||||||
static const int PALETTE_COLS = ColorHistory::MAX_COLORS;
|
|
||||||
static const int PALETTE_ROWS = 4;
|
|
||||||
|
|
||||||
struct ColorTableEntry {
|
|
||||||
QString colorSpec;
|
|
||||||
const char* trname;
|
|
||||||
};
|
|
||||||
|
|
||||||
static ColorTableEntry mColorTable[];
|
|
||||||
|
|
||||||
ColorHistory* mColorHistory;
|
|
||||||
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
|
||||||
|
|
||||||
FieldButton* mFieldButton;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorPaletteDialog_h
|
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
// ColorPaletteDialog.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014-2016 Jaye 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 ColorPaletteDialog_hpp
|
||||||
|
#define ColorPaletteDialog_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "ColorHistory.hpp"
|
||||||
|
#include "ColorPaletteItem.hpp"
|
||||||
|
#include "FieldButton.hpp"
|
||||||
|
|
||||||
|
#include "model/ColorNode.hpp"
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Palette Dialog
|
||||||
|
///
|
||||||
|
class ColorPaletteDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
ColorPaletteDialog( const QString& defaultLabel,
|
||||||
|
const QColor& defaultColor,
|
||||||
|
const QColor& color,
|
||||||
|
bool showUseFieldButton = true,
|
||||||
|
QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void colorChanged( model::ColorNode colorNode, bool isDefault );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Public Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
void setColorNode( const model::ColorNode& colorNode );
|
||||||
|
|
||||||
|
void setKeys( const merge::Merge* merge,
|
||||||
|
const model::Variables& variables );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onPaletteItemActivated( int id );
|
||||||
|
void onHistoryItemActivated( int id );
|
||||||
|
void onDefaultButtonClicked();
|
||||||
|
void onCustomColorButtonClicked();
|
||||||
|
void onKeySelected( QString key );
|
||||||
|
void onColorHistoryChanged();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
void loadCustomColorHistory();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Members
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
QColor mDefaultColor;
|
||||||
|
model::ColorNode mColorNode;
|
||||||
|
|
||||||
|
static const int PALETTE_COLS = ColorHistory::MAX_COLORS;
|
||||||
|
static const int PALETTE_ROWS = 4;
|
||||||
|
|
||||||
|
struct ColorTableEntry {
|
||||||
|
QString colorSpec;
|
||||||
|
const char* trname;
|
||||||
|
};
|
||||||
|
|
||||||
|
static ColorTableEntry mColorTable[];
|
||||||
|
|
||||||
|
ColorHistory* mColorHistory;
|
||||||
|
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
||||||
|
|
||||||
|
FieldButton* mFieldButton;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ColorPaletteDialog_hpp
|
||||||
+123
-122
@@ -1,146 +1,147 @@
|
|||||||
/* ColorPaletteItem.cpp
|
// ColorPaletteItem.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "ColorPaletteItem.h"
|
|
||||||
|
#include "ColorPaletteItem.hpp"
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const int border = 4;
|
||||||
|
const int wSwatch = 25;
|
||||||
|
const int hSwatch = 25;
|
||||||
|
|
||||||
|
const int outlineWidthPixels = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
///
|
||||||
// Private
|
/// Constructor From Data
|
||||||
//
|
///
|
||||||
namespace
|
ColorPaletteItem::ColorPaletteItem( int id,
|
||||||
{
|
const QColor& color,
|
||||||
const int border = 4;
|
const QString& tip,
|
||||||
const int wSwatch = 25;
|
QWidget* parent )
|
||||||
const int hSwatch = 25;
|
: QWidget(parent), mId(id), mColor(color), mTip(tip), mHover(false)
|
||||||
|
{
|
||||||
const int outlineWidthPixels = 1;
|
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
||||||
}
|
setMinimumSize( wSwatch+2*border+1, hSwatch+2*border+1 );
|
||||||
|
setToolTip( tip );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Color Property Setter
|
||||||
///
|
///
|
||||||
ColorPaletteItem::ColorPaletteItem( int id,
|
void ColorPaletteItem::setColor( int id,
|
||||||
const QColor& color,
|
const QColor& color,
|
||||||
const QString& tip,
|
const QString& tip )
|
||||||
QWidget* parent )
|
{
|
||||||
: QWidget(parent), mId(id), mColor(color), mTip(tip), mHover(false)
|
mId = id;
|
||||||
{
|
mColor = color;
|
||||||
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
mTip = tip;
|
||||||
setMinimumSize( wSwatch+2*border+1, hSwatch+2*border+1 );
|
|
||||||
setToolTip( tip );
|
setToolTip( tip );
|
||||||
}
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Color Property Setter
|
/// Paint Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::setColor( int id,
|
void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
||||||
const QColor& color,
|
{
|
||||||
const QString& tip )
|
QPainter painter(this);
|
||||||
{
|
|
||||||
mId = id;
|
|
||||||
mColor = color;
|
|
||||||
mTip = tip;
|
|
||||||
|
|
||||||
setToolTip( tip );
|
//
|
||||||
update();
|
// Draw swatch
|
||||||
}
|
//
|
||||||
|
if ( isEnabled() )
|
||||||
|
{
|
||||||
|
if ( mHover )
|
||||||
|
{
|
||||||
|
QPen pen( palette().color( QPalette::Text ) );
|
||||||
|
pen.setWidth( 2*outlineWidthPixels );
|
||||||
|
pen.setJoinStyle( Qt::MiterJoin );
|
||||||
|
painter.setPen( pen );
|
||||||
|
painter.setBrush( QBrush( mColor ) );
|
||||||
|
painter.drawRect( 1, 1, width()-2, height()-2 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QPen pen( palette().color( QPalette::Text ) );
|
||||||
|
pen.setWidth( outlineWidthPixels );
|
||||||
|
painter.setPen( pen );
|
||||||
|
painter.setBrush( QBrush( mColor ) );
|
||||||
|
painter.drawRect( border, border, wSwatch, hSwatch );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
}
|
||||||
/// Paint Event
|
else
|
||||||
///
|
{
|
||||||
void ColorPaletteItem::paintEvent( QPaintEvent* event )
|
QPen pen( palette().color( QPalette::Disabled, QPalette::Text ) );
|
||||||
{
|
pen.setWidth( outlineWidthPixels );
|
||||||
QPainter painter(this);
|
painter.setPen( pen );
|
||||||
|
painter.setBrush( QBrush( mColor ) );
|
||||||
|
painter.drawRect( border, border, wSwatch, hSwatch );
|
||||||
|
}
|
||||||
|
|
||||||
//
|
}
|
||||||
// Draw swatch
|
|
||||||
//
|
|
||||||
if ( isEnabled() )
|
|
||||||
{
|
|
||||||
if ( mHover )
|
|
||||||
{
|
|
||||||
QPen pen( palette().color( QPalette::Text ) );
|
|
||||||
pen.setWidth( 2*outlineWidthPixels );
|
|
||||||
pen.setJoinStyle( Qt::MiterJoin );
|
|
||||||
painter.setPen( pen );
|
|
||||||
painter.setBrush( QBrush( mColor ) );
|
|
||||||
painter.drawRect( 1, 1, width()-2, height()-2 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QPen pen( palette().color( QPalette::Text ) );
|
|
||||||
pen.setWidth( outlineWidthPixels );
|
|
||||||
painter.setPen( pen );
|
|
||||||
painter.setBrush( QBrush( mColor ) );
|
|
||||||
painter.drawRect( border, border, wSwatch, hSwatch );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QPen pen( palette().color( QPalette::Disabled, QPalette::Text ) );
|
|
||||||
pen.setWidth( outlineWidthPixels );
|
|
||||||
painter.setPen( pen );
|
|
||||||
painter.setBrush( QBrush( mColor ) );
|
|
||||||
painter.drawRect( border, border, wSwatch, hSwatch );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Enter Event
|
/// Enter Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::enterEvent( QEnterEvent* event )
|
void ColorPaletteItem::enterEvent( QEnterEvent* event )
|
||||||
{
|
{
|
||||||
mHover = true;
|
mHover = true;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Leave Event
|
/// Leave Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::leaveEvent( QEvent* event )
|
void ColorPaletteItem::leaveEvent( QEvent* event )
|
||||||
{
|
{
|
||||||
mHover = false;
|
mHover = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Mouse Press Event
|
/// Mouse Press Event
|
||||||
///
|
///
|
||||||
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
|
void ColorPaletteItem::mousePressEvent( QMouseEvent* event )
|
||||||
{
|
{
|
||||||
emit activated( mId );
|
emit activated( mId );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
/* ColorPaletteItem.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Jaye 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 ColorPaletteItem_h
|
|
||||||
#define ColorPaletteItem_h
|
|
||||||
|
|
||||||
|
|
||||||
#include <QColor>
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Color Palette Item
|
|
||||||
///
|
|
||||||
class ColorPaletteItem : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
ColorPaletteItem( int id,
|
|
||||||
const QColor& color,
|
|
||||||
const QString& tip,
|
|
||||||
QWidget* parent = nullptr );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
/////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void activated( int id );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Public Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
void setColor( int id,
|
|
||||||
const QColor& color,
|
|
||||||
const QString& tip );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Event handlers
|
|
||||||
/////////////////////////////////
|
|
||||||
protected:
|
|
||||||
void paintEvent( QPaintEvent* event ) override;
|
|
||||||
void enterEvent( QEnterEvent* event ) override;
|
|
||||||
void leaveEvent( QEvent* event ) override;
|
|
||||||
void mousePressEvent( QMouseEvent* event ) override;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Data
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
int mId;
|
|
||||||
QColor mColor;
|
|
||||||
QString mTip;
|
|
||||||
|
|
||||||
bool mHover;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorPaletteItem_h
|
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
// ColorPaletteItem.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014 Jaye 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 ColorPaletteItem_hpp
|
||||||
|
#define ColorPaletteItem_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Palette Item
|
||||||
|
///
|
||||||
|
class ColorPaletteItem : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
ColorPaletteItem( int id,
|
||||||
|
const QColor& color,
|
||||||
|
const QString& tip,
|
||||||
|
QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void activated( int id );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Public Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
void setColor( int id,
|
||||||
|
const QColor& color,
|
||||||
|
const QString& tip );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Event handlers
|
||||||
|
/////////////////////////////////
|
||||||
|
protected:
|
||||||
|
void paintEvent( QPaintEvent* event ) override;
|
||||||
|
void enterEvent( QEnterEvent* event ) override;
|
||||||
|
void leaveEvent( QEvent* event ) override;
|
||||||
|
void mousePressEvent( QMouseEvent* event ) override;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
int mId;
|
||||||
|
QColor mColor;
|
||||||
|
QString mTip;
|
||||||
|
|
||||||
|
bool mHover;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ColorPaletteItem_hpp
|
||||||
+47
-46
@@ -1,60 +1,61 @@
|
|||||||
/* ColorSwatch.cpp
|
// ColorSwatch.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "ColorSwatch.h"
|
|
||||||
|
#include "ColorSwatch.hpp"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const QColor outlineColor( 0, 0, 0 );
|
||||||
|
const double outlineWidthPixels = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
///
|
||||||
// Private
|
/// Constructor
|
||||||
//
|
///
|
||||||
namespace
|
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
||||||
{
|
: QPixmap( w, h )
|
||||||
const QColor outlineColor( 0, 0, 0 );
|
{
|
||||||
const double outlineWidthPixels = 1;
|
fill( Qt::transparent );
|
||||||
}
|
|
||||||
|
|
||||||
|
QPainter painter(this );
|
||||||
|
|
||||||
///
|
painter.setBackgroundMode( Qt::TransparentMode );
|
||||||
/// Constructor
|
|
||||||
///
|
|
||||||
ColorSwatch::ColorSwatch( int w, int h, const QColor& color )
|
|
||||||
: QPixmap( w, h )
|
|
||||||
{
|
|
||||||
fill( Qt::transparent );
|
|
||||||
|
|
||||||
QPainter painter(this );
|
QBrush brush( color );
|
||||||
|
QPen pen( outlineColor );
|
||||||
|
pen.setWidth( outlineWidthPixels );
|
||||||
|
|
||||||
painter.setBackgroundMode( Qt::TransparentMode );
|
painter.setBrush( brush );
|
||||||
|
painter.setPen( pen );
|
||||||
QBrush brush( color );
|
painter.drawRect( 1, 1, w-2, h-2 );
|
||||||
QPen pen( outlineColor );
|
}
|
||||||
pen.setWidth( outlineWidthPixels );
|
|
||||||
|
|
||||||
painter.setBrush( brush );
|
|
||||||
painter.setPen( pen );
|
|
||||||
painter.drawRect( 1, 1, w-2, h-2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
/* ColorSwatch.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 Jaye 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 ColorSwatch_h
|
|
||||||
#define ColorSwatch_h
|
|
||||||
|
|
||||||
|
|
||||||
#include <QPixmap>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Simple Preview Widget
|
|
||||||
///
|
|
||||||
class ColorSwatch : public QPixmap
|
|
||||||
{
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
ColorSwatch( int w, int h, const QColor& color );
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ColorSwatch_h
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// ColorSwatch.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014 Jaye 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 ColorSwatch_hpp
|
||||||
|
#define ColorSwatch_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Simple Preview Widget
|
||||||
|
///
|
||||||
|
class ColorSwatch : public QPixmap
|
||||||
|
{
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
ColorSwatch( int w, int h, const QColor& color );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ColorSwatch_hpp
|
||||||
+61
-60
@@ -1,24 +1,25 @@
|
|||||||
/* Cursors.cpp
|
// Cursors.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2013 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2013 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "Cursors.h"
|
|
||||||
|
#include "Cursors.hpp"
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
@@ -26,59 +27,59 @@
|
|||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
Cursors::Crosshair::Crosshair()
|
Cursors::Crosshair::Crosshair()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_crosshair.png"), 15, 15 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_crosshair.png"), 15, 15 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cursors::Move::Move()
|
Cursors::Move::Move()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_move.png"), 15, 15 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_move.png"), 15, 15 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cursors::Barcode::Barcode()
|
Cursors::Barcode::Barcode()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_barcode.png"), 7, 7 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_barcode.png"), 7, 7 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cursors::Box::Box()
|
Cursors::Box::Box()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_box.png"), 7, 7 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_box.png"), 7, 7 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cursors::Ellipse::Ellipse()
|
Cursors::Ellipse::Ellipse()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_ellipse.png"), 7, 7 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_ellipse.png"), 7, 7 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cursors::Image::Image()
|
Cursors::Image::Image()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_image.png"), 7, 7 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_image.png"), 7, 7 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cursors::Line::Line()
|
Cursors::Line::Line()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_line.png"), 7, 7 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_line.png"), 7, 7 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cursors::Text::Text()
|
Cursors::Text::Text()
|
||||||
: QCursor( QPixmap(":cursors/32x32/cursor_text.png"), 7, 7 )
|
: QCursor( QPixmap(":cursors/32x32/cursor_text.png"), 7, 7 )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
/* Cursors.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 Jaye 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 Cursors_h
|
|
||||||
#define Cursors_h
|
|
||||||
|
|
||||||
|
|
||||||
#include <QCursor>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Glabels Cursors
|
|
||||||
///
|
|
||||||
namespace Cursors
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
class Crosshair : public QCursor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Crosshair();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Move : public QCursor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Move();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Barcode : public QCursor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Barcode();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Box : public QCursor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Box();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Ellipse : public QCursor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Ellipse();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Image : public QCursor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Image();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Line : public QCursor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Line();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Text : public QCursor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Text();
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // Cursors_h
|
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
// Cursors.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2013 Jaye 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 Cursors_hpp
|
||||||
|
#define Cursors_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include <QCursor>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Glabels Cursors
|
||||||
|
///
|
||||||
|
namespace Cursors
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class Crosshair : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Crosshair();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Move : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Move();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Barcode : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Barcode();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Box : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Box();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Ellipse : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Ellipse();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Image : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Image();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Line : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Line();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Text : public QCursor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Text();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // Cursors_hpp
|
||||||
+188
-187
@@ -1,220 +1,221 @@
|
|||||||
/* EditVariableDialog.cpp
|
// EditVariableDialog.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2019 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2019 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "EditVariableDialog.h"
|
|
||||||
|
|
||||||
#include "model/Settings.h"
|
#include "EditVariableDialog.hpp"
|
||||||
|
|
||||||
|
#include "model/Settings.hpp"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// All variable types. (must be in sorted order)
|
// All variable types. (must be in sorted order)
|
||||||
const QVector<glabels::model::Variable::Type> allTypes = {
|
const QVector<glabels::model::Variable::Type> allTypes = {
|
||||||
glabels::model::Variable::Type::STRING,
|
glabels::model::Variable::Type::STRING,
|
||||||
glabels::model::Variable::Type::INTEGER,
|
glabels::model::Variable::Type::INTEGER,
|
||||||
glabels::model::Variable::Type::FLOATING_POINT,
|
glabels::model::Variable::Type::FLOATING_POINT,
|
||||||
glabels::model::Variable::Type::COLOR
|
glabels::model::Variable::Type::COLOR
|
||||||
};
|
};
|
||||||
|
|
||||||
// All variable increments. (must be in sorted order)
|
// All variable increments. (must be in sorted order)
|
||||||
const QVector<glabels::model::Variable::Increment> allIncrements = {
|
const QVector<glabels::model::Variable::Increment> allIncrements = {
|
||||||
glabels::model::Variable::Increment::NEVER,
|
glabels::model::Variable::Increment::NEVER,
|
||||||
glabels::model::Variable::Increment::PER_ITEM,
|
glabels::model::Variable::Increment::PER_ITEM,
|
||||||
glabels::model::Variable::Increment::PER_COPY,
|
glabels::model::Variable::Increment::PER_COPY,
|
||||||
glabels::model::Variable::Increment::PER_PAGE
|
glabels::model::Variable::Increment::PER_PAGE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
EditVariableDialog::EditVariableDialog( QWidget *parent )
|
EditVariableDialog::EditVariableDialog( QWidget *parent )
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
QRegularExpression reIdentifier( "[a-zA-Z_][a-zA-Z_0-9]*" );
|
QRegularExpression reIdentifier( "[a-zA-Z_][a-zA-Z_0-9]*" );
|
||||||
nameEdit->setValidator( new QRegularExpressionValidator( reIdentifier ) );
|
nameEdit->setValidator( new QRegularExpressionValidator( reIdentifier ) );
|
||||||
|
|
||||||
colorValueButton->init( tr("Default"),
|
colorValueButton->init( tr("Default"),
|
||||||
QColor(0,0,0,255),
|
QColor(0,0,0,255),
|
||||||
QColor(0,0,0,255),
|
QColor(0,0,0,255),
|
||||||
false );
|
false );
|
||||||
|
|
||||||
for ( auto type : allTypes )
|
|
||||||
{
|
|
||||||
typeCombo->addItem( model::Variable::typeToI18nString( type ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( auto type : allIncrements )
|
for ( auto type : allTypes )
|
||||||
{
|
{
|
||||||
incrementCombo->addItem( model::Variable::incrementToI18nString( type ) );
|
typeCombo->addItem( model::Variable::typeToI18nString( type ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
stepSizeEdit->setText( "1" );
|
for ( auto type : allIncrements )
|
||||||
}
|
{
|
||||||
|
incrementCombo->addItem( model::Variable::incrementToI18nString( type ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
stepSizeEdit->setText( "1" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set variable
|
/// Set variable
|
||||||
///
|
///
|
||||||
void EditVariableDialog::setVariable( const model::Variable& variable )
|
void EditVariableDialog::setVariable( const model::Variable& variable )
|
||||||
{
|
{
|
||||||
typeCombo->setCurrentIndex( static_cast<int>(variable.type()) );
|
typeCombo->setCurrentIndex( static_cast<int>(variable.type()) );
|
||||||
nameEdit->setText( variable.name() );
|
nameEdit->setText( variable.name() );
|
||||||
valueEdit->setText( variable.initialValue() );
|
valueEdit->setText( variable.initialValue() );
|
||||||
colorValueButton->setColor( QColor( variable.initialValue() ) );
|
colorValueButton->setColor( QColor( variable.initialValue() ) );
|
||||||
incrementCombo->setCurrentIndex( static_cast<int>(variable.increment()) );
|
incrementCombo->setCurrentIndex( static_cast<int>(variable.increment()) );
|
||||||
stepSizeEdit->setText( variable.stepSize() );
|
stepSizeEdit->setText( variable.stepSize() );
|
||||||
|
|
||||||
updateControls();
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Get variable
|
/// Get variable
|
||||||
///
|
///
|
||||||
model::Variable EditVariableDialog::variable() const
|
model::Variable EditVariableDialog::variable() const
|
||||||
{
|
{
|
||||||
return model::Variable( static_cast<model::Variable::Type>(typeCombo->currentIndex()),
|
return model::Variable( static_cast<model::Variable::Type>(typeCombo->currentIndex()),
|
||||||
nameEdit->text(),
|
nameEdit->text(),
|
||||||
valueEdit->text(),
|
valueEdit->text(),
|
||||||
static_cast<model::Variable::Increment>(incrementCombo->currentIndex()),
|
static_cast<model::Variable::Increment>(incrementCombo->currentIndex()),
|
||||||
stepSizeEdit->text() );
|
stepSizeEdit->text() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// nameEdit Changed
|
/// nameEdit Changed
|
||||||
///
|
///
|
||||||
void EditVariableDialog::onNameEditChanged()
|
void EditVariableDialog::onNameEditChanged()
|
||||||
{
|
{
|
||||||
validateCurrentInputs();
|
validateCurrentInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// typeCombo Changed
|
|
||||||
///
|
|
||||||
void EditVariableDialog::onTypeComboChanged()
|
|
||||||
{
|
|
||||||
updateControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// valueEdit Changed
|
|
||||||
///
|
|
||||||
void EditVariableDialog::onValueEditChanged()
|
|
||||||
{
|
|
||||||
validateCurrentInputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// colorValueButton Changed
|
|
||||||
///
|
|
||||||
void EditVariableDialog::onColorValueButtonChanged()
|
|
||||||
{
|
|
||||||
valueEdit->setText( colorValueButton->colorNode().color().name() );
|
|
||||||
validateCurrentInputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// incrementCombo Changed
|
|
||||||
///
|
|
||||||
void EditVariableDialog::onIncrementComboChanged()
|
|
||||||
{
|
|
||||||
updateControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// stepSizeEdit Changed
|
|
||||||
///
|
|
||||||
void EditVariableDialog::onStepSizeEditChanged()
|
|
||||||
{
|
|
||||||
validateCurrentInputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// update controls
|
/// typeCombo Changed
|
||||||
///
|
///
|
||||||
void EditVariableDialog::updateControls()
|
void EditVariableDialog::onTypeComboChanged()
|
||||||
{
|
{
|
||||||
auto type = static_cast<model::Variable::Type>(typeCombo->currentIndex());
|
updateControls();
|
||||||
auto increment = static_cast<model::Variable::Increment>(incrementCombo->currentIndex());
|
}
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
|
|
||||||
case model::Variable::Type::INTEGER:
|
|
||||||
valueEdit->setValidator( new QIntValidator() );
|
|
||||||
stepSizeEdit->setValidator( new QIntValidator() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case model::Variable::Type::FLOATING_POINT:
|
|
||||||
valueEdit->setValidator( new QDoubleValidator() );
|
|
||||||
stepSizeEdit->setValidator( new QDoubleValidator() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
valueEdit->setValidator( nullptr );
|
|
||||||
stepSizeEdit->setValidator( nullptr );
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
colorValueButton->setVisible( type == model::Variable::Type::COLOR );
|
|
||||||
|
|
||||||
bool isNumeric = ( type == model::Variable::Type::INTEGER ) ||
|
|
||||||
( type == model::Variable::Type::FLOATING_POINT );
|
|
||||||
|
|
||||||
incrementGroup->setVisible( isNumeric );
|
|
||||||
stepSizeLabel->setEnabled( isNumeric && (increment != model::Variable::Increment::NEVER) );
|
|
||||||
stepSizeEdit->setEnabled( isNumeric && (increment != model::Variable::Increment::NEVER) );
|
|
||||||
|
|
||||||
validateCurrentInputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// validate current inputs
|
/// valueEdit Changed
|
||||||
///
|
///
|
||||||
void EditVariableDialog::validateCurrentInputs()
|
void EditVariableDialog::onValueEditChanged()
|
||||||
{
|
{
|
||||||
bool hasValidIdentifier = nameEdit->hasAcceptableInput();
|
validateCurrentInputs();
|
||||||
bool hasValidValue = valueEdit->hasAcceptableInput();
|
}
|
||||||
bool hasValidStepSize = stepSizeEdit->hasAcceptableInput();
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// colorValueButton Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onColorValueButtonChanged()
|
||||||
|
{
|
||||||
|
valueEdit->setText( colorValueButton->colorNode().color().name() );
|
||||||
|
validateCurrentInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// incrementCombo Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onIncrementComboChanged()
|
||||||
|
{
|
||||||
|
updateControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// stepSizeEdit Changed
|
||||||
|
///
|
||||||
|
void EditVariableDialog::onStepSizeEditChanged()
|
||||||
|
{
|
||||||
|
validateCurrentInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// update controls
|
||||||
|
///
|
||||||
|
void EditVariableDialog::updateControls()
|
||||||
|
{
|
||||||
|
auto type = static_cast<model::Variable::Type>(typeCombo->currentIndex());
|
||||||
|
auto increment = static_cast<model::Variable::Increment>(incrementCombo->currentIndex());
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
|
||||||
|
case model::Variable::Type::INTEGER:
|
||||||
|
valueEdit->setValidator( new QIntValidator() );
|
||||||
|
stepSizeEdit->setValidator( new QIntValidator() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case model::Variable::Type::FLOATING_POINT:
|
||||||
|
valueEdit->setValidator( new QDoubleValidator() );
|
||||||
|
stepSizeEdit->setValidator( new QDoubleValidator() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
valueEdit->setValidator( nullptr );
|
||||||
|
stepSizeEdit->setValidator( nullptr );
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
colorValueButton->setVisible( type == model::Variable::Type::COLOR );
|
||||||
|
|
||||||
|
bool isNumeric = ( type == model::Variable::Type::INTEGER ) ||
|
||||||
|
( type == model::Variable::Type::FLOATING_POINT );
|
||||||
|
|
||||||
|
incrementGroup->setVisible( isNumeric );
|
||||||
|
stepSizeLabel->setEnabled( isNumeric && (increment != model::Variable::Increment::NEVER) );
|
||||||
|
stepSizeEdit->setEnabled( isNumeric && (increment != model::Variable::Increment::NEVER) );
|
||||||
|
|
||||||
|
validateCurrentInputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// validate current inputs
|
||||||
|
///
|
||||||
|
void EditVariableDialog::validateCurrentInputs()
|
||||||
|
{
|
||||||
|
bool hasValidIdentifier = nameEdit->hasAcceptableInput();
|
||||||
|
bool hasValidValue = valueEdit->hasAcceptableInput();
|
||||||
|
bool hasValidStepSize = stepSizeEdit->hasAcceptableInput();
|
||||||
|
|
||||||
|
bool isValid = hasValidIdentifier && hasValidValue && hasValidStepSize;
|
||||||
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled( isValid );
|
||||||
|
}
|
||||||
|
|
||||||
bool isValid = hasValidIdentifier && hasValidValue && hasValidStepSize;
|
|
||||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled( isValid );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
/* EditVariableDialog.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2019 Jaye 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 EditVariableDialog_h
|
|
||||||
#define EditVariableDialog_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "ui_EditVariableDialog.h"
|
|
||||||
#include "model/Variable.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// New Label Dialog Widget
|
|
||||||
///
|
|
||||||
class EditVariableDialog : public QDialog, public Ui_EditVariableDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
EditVariableDialog( QWidget *parent = nullptr );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Public methods
|
|
||||||
/////////////////////////////////
|
|
||||||
void setVariable( const model::Variable& variable );
|
|
||||||
model::Variable variable() const;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Slots
|
|
||||||
/////////////////////////////////
|
|
||||||
private slots:
|
|
||||||
void onNameEditChanged();
|
|
||||||
void onTypeComboChanged();
|
|
||||||
void onValueEditChanged();
|
|
||||||
void onColorValueButtonChanged();
|
|
||||||
void onIncrementComboChanged();
|
|
||||||
void onStepSizeEditChanged();
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private methods
|
|
||||||
/////////////////////////////////
|
|
||||||
void updateControls();
|
|
||||||
void validateCurrentInputs();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // EditVariableDialog_h
|
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
// EditVariableDialog.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019 Jaye 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 EditVariableDialog_hpp
|
||||||
|
#define EditVariableDialog_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "ui_EditVariableDialog.h"
|
||||||
|
|
||||||
|
#include "model/Variable.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// New Label Dialog Widget
|
||||||
|
///
|
||||||
|
class EditVariableDialog : public QDialog, public Ui_EditVariableDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
EditVariableDialog( QWidget *parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Public methods
|
||||||
|
/////////////////////////////////
|
||||||
|
void setVariable( const model::Variable& variable );
|
||||||
|
model::Variable variable() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onNameEditChanged();
|
||||||
|
void onTypeComboChanged();
|
||||||
|
void onValueEditChanged();
|
||||||
|
void onColorValueButtonChanged();
|
||||||
|
void onIncrementComboChanged();
|
||||||
|
void onStepSizeEditChanged();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private methods
|
||||||
|
/////////////////////////////////
|
||||||
|
void updateControls();
|
||||||
|
void validateCurrentInputs();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // EditVariableDialog_hpp
|
||||||
+74
-73
@@ -1,24 +1,25 @@
|
|||||||
/* FieldButton.cpp
|
// FieldButton.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2019 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2019 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "FieldButton.h"
|
|
||||||
|
#include "FieldButton.hpp"
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
@@ -27,64 +28,64 @@
|
|||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Constructor
|
/// Constructor
|
||||||
///
|
///
|
||||||
FieldButton::FieldButton( QWidget* parent ) : QPushButton(parent)
|
FieldButton::FieldButton( QWidget* parent ) : QPushButton(parent)
|
||||||
{
|
{
|
||||||
setEnabled( false );
|
setEnabled( false );
|
||||||
setMenu( &mMenu );
|
setMenu( &mMenu );
|
||||||
|
|
||||||
connect( &mMenu, SIGNAL(triggered(QAction*)),
|
connect( &mMenu, SIGNAL(triggered(QAction*)),
|
||||||
this, SLOT(onMenuActionTriggered(QAction*)) );
|
this, SLOT(onMenuActionTriggered(QAction*)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set Keys
|
/// Set Keys
|
||||||
///
|
///
|
||||||
void FieldButton::setKeys( const merge::Merge* merge,
|
void FieldButton::setKeys( const merge::Merge* merge,
|
||||||
const model::Variables& variables )
|
const model::Variables& variables )
|
||||||
{
|
{
|
||||||
// Clear old keys
|
// Clear old keys
|
||||||
mMenu.clear();
|
mMenu.clear();
|
||||||
|
|
||||||
// Add merge keys, if any
|
|
||||||
mMenu.addSection( tr("Merge fields") );
|
|
||||||
for ( auto& key : merge->keys() )
|
|
||||||
{
|
|
||||||
auto* action = mMenu.addAction( QString( "${%1}" ).arg( key ) );
|
|
||||||
action->setData( key );
|
|
||||||
}
|
|
||||||
if ( merge->keys().empty() )
|
|
||||||
{
|
|
||||||
auto* action = mMenu.addAction( "None" );
|
|
||||||
action->setEnabled( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add variable keys, if any
|
// Add merge keys, if any
|
||||||
mMenu.addSection( tr("Variables") );
|
mMenu.addSection( tr("Merge fields") );
|
||||||
for ( auto& key : variables.keys() )
|
for ( auto& key : merge->keys() )
|
||||||
{
|
{
|
||||||
auto* action = mMenu.addAction( QString( "${%1}" ).arg( key ) );
|
auto* action = mMenu.addAction( QString( "${%1}" ).arg( key ) );
|
||||||
action->setData( key );
|
action->setData( key );
|
||||||
}
|
}
|
||||||
if ( variables.keys().empty() )
|
if ( merge->keys().empty() )
|
||||||
{
|
{
|
||||||
auto* action = mMenu.addAction( "None" );
|
auto* action = mMenu.addAction( "None" );
|
||||||
action->setEnabled( false );
|
action->setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
setEnabled( !merge->keys().empty() || !variables.keys().empty() );
|
// Add variable keys, if any
|
||||||
}
|
mMenu.addSection( tr("Variables") );
|
||||||
|
for ( auto& key : variables.keys() )
|
||||||
|
{
|
||||||
|
auto* action = mMenu.addAction( QString( "${%1}" ).arg( key ) );
|
||||||
|
action->setData( key );
|
||||||
|
}
|
||||||
|
if ( variables.keys().empty() )
|
||||||
|
{
|
||||||
|
auto* action = mMenu.addAction( "None" );
|
||||||
|
action->setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
setEnabled( !merge->keys().empty() || !variables.keys().empty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// onMenuActionTriggered slot
|
/// onMenuActionTriggered slot
|
||||||
///
|
///
|
||||||
void FieldButton::onMenuActionTriggered( QAction* action )
|
void FieldButton::onMenuActionTriggered( QAction* action )
|
||||||
{
|
{
|
||||||
emit keySelected( action->data().toString() );
|
emit keySelected( action->data().toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
/* FieldButton.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2019 Jaye 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 FieldButton_h
|
|
||||||
#define FieldButton_h
|
|
||||||
|
|
||||||
|
|
||||||
#include "model/Variables.h"
|
|
||||||
#include "merge/Merge.h"
|
|
||||||
|
|
||||||
#include <QAction>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Field Button
|
|
||||||
///
|
|
||||||
class FieldButton : public QPushButton
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Life Cycle
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
FieldButton( QWidget* parent = nullptr );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Signals
|
|
||||||
/////////////////////////////////
|
|
||||||
signals:
|
|
||||||
void keySelected( QString key );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Public Methods
|
|
||||||
/////////////////////////////////
|
|
||||||
public:
|
|
||||||
void setKeys( const merge::Merge* merge,
|
|
||||||
const model::Variables& variables );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Slots
|
|
||||||
/////////////////////////////////
|
|
||||||
private slots:
|
|
||||||
void onMenuActionTriggered( QAction* action );
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
// Private Data
|
|
||||||
/////////////////////////////////
|
|
||||||
private:
|
|
||||||
QMenu mMenu;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // FieldButton_h
|
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
// FieldButton.hpp
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019 Jaye 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 FieldButton_hpp
|
||||||
|
#define FieldButton_hpp
|
||||||
|
|
||||||
|
|
||||||
|
#include "model/Variables.hpp"
|
||||||
|
#include "merge/Merge.hpp"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Field Button
|
||||||
|
///
|
||||||
|
class FieldButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
FieldButton( QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void keySelected( QString key );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Public Methods
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
void setKeys( const merge::Merge* merge,
|
||||||
|
const model::Variables& variables );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onMenuActionTriggered( QAction* action );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
QMenu mMenu;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // FieldButton_hpp
|
||||||
+260
-259
@@ -1,301 +1,302 @@
|
|||||||
/* File.cpp
|
// File.cpp
|
||||||
*
|
//
|
||||||
* Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
// Copyright (C) 2014 Jaye Evins <evins@snaught.com>
|
||||||
*
|
//
|
||||||
* This file is part of gLabels-qt.
|
// This file is part of gLabels-qt.
|
||||||
*
|
//
|
||||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
// (at your option) any later version.
|
||||||
*
|
//
|
||||||
* gLabels-qt is distributed in the hope that it will be useful,
|
// gLabels-qt is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
*
|
//
|
||||||
* You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
* 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 "File.h"
|
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "File.hpp"
|
||||||
#include "SelectProductDialog.h"
|
|
||||||
#include "TemplateDesigner.h"
|
|
||||||
|
|
||||||
#include "model/FileUtil.h"
|
#include "MainWindow.hpp"
|
||||||
#include "model/Model.h"
|
#include "SelectProductDialog.hpp"
|
||||||
#include "model/Settings.h"
|
#include "TemplateDesigner.hpp"
|
||||||
#include "model/XmlLabelParser.h"
|
|
||||||
#include "model/XmlLabelCreator.h"
|
|
||||||
|
|
||||||
|
#include "model/FileUtil.hpp"
|
||||||
|
#include "model/Model.hpp"
|
||||||
|
#include "model/Settings.hpp"
|
||||||
|
#include "model/XmlLabelParser.hpp"
|
||||||
|
#include "model/XmlLabelCreator.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtDebug>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
// Static data
|
// Static data
|
||||||
//
|
//
|
||||||
QString File::mCwd = ".";
|
QString File::mCwd = ".";
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// New Label Dialog
|
/// New Label Dialog
|
||||||
///
|
///
|
||||||
bool File::newLabel( MainWindow *window )
|
bool File::newLabel( MainWindow *window )
|
||||||
{
|
{
|
||||||
SelectProductDialog dialog( window );
|
SelectProductDialog dialog( window );
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
|
|
||||||
auto tmplate = dialog.tmplate();
|
auto tmplate = dialog.tmplate();
|
||||||
if ( !tmplate.isNull() )
|
if ( !tmplate.isNull() )
|
||||||
{
|
{
|
||||||
auto* model = new model::Model();
|
auto* model = new model::Model();
|
||||||
model->setTmplate( tmplate );
|
model->setTmplate( tmplate );
|
||||||
|
|
||||||
// Intelligently decide to rotate label by default
|
|
||||||
auto frame = tmplate.frame();
|
|
||||||
model->setRotate( frame->h() > frame->w() );
|
|
||||||
|
|
||||||
model->clearModified();
|
// Intelligently decide to rotate label by default
|
||||||
|
auto frame = tmplate.frame();
|
||||||
|
model->setRotate( frame->h() > frame->w() );
|
||||||
|
|
||||||
// Either apply to current window or open a new one
|
model->clearModified();
|
||||||
if ( window->isEmpty() )
|
|
||||||
{
|
|
||||||
window->setModel( model );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto *newWindow = new MainWindow();
|
|
||||||
newWindow->setModel( model );
|
|
||||||
newWindow->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
// Either apply to current window or open a new one
|
||||||
}
|
if ( window->isEmpty() )
|
||||||
else
|
{
|
||||||
{
|
window->setModel( model );
|
||||||
return false;
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
|
auto *newWindow = new MainWindow();
|
||||||
|
newWindow->setModel( model );
|
||||||
|
newWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Open File Dialog
|
/// Open File Dialog
|
||||||
///
|
///
|
||||||
void File::open( MainWindow *window )
|
void File::open( MainWindow *window )
|
||||||
{
|
{
|
||||||
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
// Either use the saved CWD from a previous open/save or grab it from the path of the current file
|
||||||
QString cwd = mCwd;
|
QString cwd = mCwd;
|
||||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||||
{
|
{
|
||||||
QFileInfo fileInfo( window->model()->fileName() );
|
QFileInfo fileInfo( window->model()->fileName() );
|
||||||
if ( fileInfo.isFile() )
|
if ( fileInfo.isFile() )
|
||||||
{
|
{
|
||||||
cwd = fileInfo.absolutePath();
|
cwd = fileInfo.absolutePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fileName =
|
|
||||||
QFileDialog::getOpenFileName( window,
|
|
||||||
tr("gLabels - Open Project"),
|
|
||||||
cwd,
|
|
||||||
tr("glabels files (*.glabels);;All files (*)")
|
|
||||||
);
|
|
||||||
if ( !fileName.isEmpty() )
|
|
||||||
{
|
|
||||||
model::Model *model = model::XmlLabelParser::readFile( fileName );
|
|
||||||
if ( model )
|
|
||||||
{
|
|
||||||
// Either apply to current window or open a new one
|
|
||||||
if ( window->isEmpty() )
|
|
||||||
{
|
|
||||||
window->setModel( model );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto *newWindow = new MainWindow();
|
|
||||||
newWindow->setModel( model );
|
|
||||||
newWindow->show();
|
|
||||||
}
|
|
||||||
model::Settings::addToRecentFileList( model->fileName() );
|
|
||||||
|
|
||||||
// Save CWD
|
QString fileName =
|
||||||
mCwd = QFileInfo( fileName ).absolutePath();
|
QFileDialog::getOpenFileName( window,
|
||||||
}
|
tr("gLabels - Open Project"),
|
||||||
else
|
cwd,
|
||||||
{
|
tr("glabels files (*.glabels);;All files (*)")
|
||||||
model::Settings::removeFromRecentFileList( fileName );
|
);
|
||||||
|
if ( !fileName.isEmpty() )
|
||||||
|
{
|
||||||
|
model::Model *model = model::XmlLabelParser::readFile( fileName );
|
||||||
|
if ( model )
|
||||||
|
{
|
||||||
|
// Either apply to current window or open a new one
|
||||||
|
if ( window->isEmpty() )
|
||||||
|
{
|
||||||
|
window->setModel( model );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto *newWindow = new MainWindow();
|
||||||
|
newWindow->setModel( model );
|
||||||
|
newWindow->show();
|
||||||
|
}
|
||||||
|
model::Settings::addToRecentFileList( model->fileName() );
|
||||||
|
|
||||||
QMessageBox msgBox;
|
// Save CWD
|
||||||
msgBox.setText( tr("Unable to open \"") + fileName + tr("\".") );
|
mCwd = QFileInfo( fileName ).absolutePath();
|
||||||
msgBox.setStandardButtons( QMessageBox::Ok );
|
}
|
||||||
msgBox.setDefaultButton( QMessageBox::Ok );
|
else
|
||||||
msgBox.exec();
|
{
|
||||||
}
|
model::Settings::removeFromRecentFileList( fileName );
|
||||||
}
|
|
||||||
}
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText( tr("Unable to open \"") + fileName + tr("\".") );
|
||||||
|
msgBox.setStandardButtons( QMessageBox::Ok );
|
||||||
|
msgBox.setDefaultButton( QMessageBox::Ok );
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Open file
|
/// Open file
|
||||||
///
|
///
|
||||||
void File::open( const QString& fileName, MainWindow *window )
|
void File::open( const QString& fileName, MainWindow *window )
|
||||||
{
|
{
|
||||||
if ( !fileName.isEmpty() )
|
if ( !fileName.isEmpty() )
|
||||||
{
|
{
|
||||||
model::Model *model = model::XmlLabelParser::readFile( fileName );
|
model::Model *model = model::XmlLabelParser::readFile( fileName );
|
||||||
if ( model )
|
if ( model )
|
||||||
{
|
{
|
||||||
// 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( model );
|
window->setModel( model );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto *newWindow = new MainWindow();
|
auto *newWindow = new MainWindow();
|
||||||
newWindow->setModel( model );
|
newWindow->setModel( model );
|
||||||
newWindow->show();
|
newWindow->show();
|
||||||
}
|
}
|
||||||
model::Settings::addToRecentFileList( model->fileName() );
|
model::Settings::addToRecentFileList( model->fileName() );
|
||||||
|
|
||||||
// Save CWD
|
// Save CWD
|
||||||
mCwd = QFileInfo( fileName ).absolutePath();
|
mCwd = QFileInfo( fileName ).absolutePath();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model::Settings::removeFromRecentFileList( fileName );
|
model::Settings::removeFromRecentFileList( fileName );
|
||||||
|
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText( tr("Unable to open \"") + fileName + tr("\".") );
|
msgBox.setText( tr("Unable to open \"") + fileName + tr("\".") );
|
||||||
msgBox.setStandardButtons( QMessageBox::Ok );
|
msgBox.setStandardButtons( QMessageBox::Ok );
|
||||||
msgBox.setDefaultButton( QMessageBox::Ok );
|
msgBox.setDefaultButton( QMessageBox::Ok );
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Save file
|
/// Save file
|
||||||
///
|
///
|
||||||
bool File::save( MainWindow *window )
|
bool File::save( MainWindow *window )
|
||||||
{
|
{
|
||||||
if ( window->model()->fileName().isEmpty() )
|
if ( window->model()->fileName().isEmpty() )
|
||||||
{
|
{
|
||||||
return saveAs( window );
|
return saveAs( window );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !window->model()->isModified() )
|
if ( !window->model()->isModified() )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
model::XmlLabelCreator::writeFile( window->model(), window->model()->fileName() );
|
model::XmlLabelCreator::writeFile( window->model(), window->model()->fileName() );
|
||||||
model::Settings::addToRecentFileList( window->model()->fileName() );
|
model::Settings::addToRecentFileList( window->model()->fileName() );
|
||||||
|
|
||||||
// Save CWD
|
// Save CWD
|
||||||
mCwd = QFileInfo( window->model()->fileName() ).absolutePath();
|
mCwd = QFileInfo( window->model()->fileName() ).absolutePath();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Save file as
|
/// Save file as
|
||||||
///
|
///
|
||||||
bool File::saveAs( MainWindow *window )
|
bool File::saveAs( MainWindow *window )
|
||||||
{
|
{
|
||||||
// Either use the saved CWD from a previous open/save or grab it from the path
|
// Either use the saved CWD from a previous open/save or grab it from the path
|
||||||
// of the current file.
|
// of the current file.
|
||||||
QString cwd = mCwd;
|
QString cwd = mCwd;
|
||||||
if ( window->model() && !window->model()->fileName().isEmpty() )
|
if ( window->model() && !window->model()->fileName().isEmpty() )
|
||||||
{
|
{
|
||||||
QFileInfo fileInfo( window->model()->fileName() );
|
QFileInfo fileInfo( window->model()->fileName() );
|
||||||
if ( fileInfo.isFile() )
|
if ( fileInfo.isFile() )
|
||||||
{
|
{
|
||||||
cwd = fileInfo.filePath();
|
cwd = fileInfo.filePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString rawFileName =
|
|
||||||
QFileDialog::getSaveFileName( window,
|
|
||||||
tr("gLabels - Save Project As"),
|
|
||||||
cwd,
|
|
||||||
tr("glabels files (*.glabels);;All files (*)"),
|
|
||||||
nullptr,
|
|
||||||
QFileDialog::DontConfirmOverwrite );
|
|
||||||
if ( !rawFileName.isEmpty() )
|
|
||||||
{
|
|
||||||
QString fileName = model::FileUtil::addExtension( rawFileName, ".glabels" );
|
|
||||||
|
|
||||||
|
|
||||||
if ( QFileInfo::exists(fileName) )
|
|
||||||
{
|
|
||||||
QMessageBox msgBox( window );
|
|
||||||
msgBox.setWindowTitle( tr("Save Label As") );
|
|
||||||
msgBox.setIcon( QMessageBox::Warning );
|
|
||||||
msgBox.setText( tr("%1 already exists.").arg(fileName) );
|
|
||||||
msgBox.setInformativeText( tr("Do you want to replace it?") );
|
|
||||||
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
|
|
||||||
msgBox.setDefaultButton( QMessageBox::No );
|
|
||||||
|
|
||||||
if ( msgBox.exec() == QMessageBox::No )
|
QString rawFileName =
|
||||||
{
|
QFileDialog::getSaveFileName( window,
|
||||||
return saveAs( window );
|
tr("gLabels - Save Project As"),
|
||||||
}
|
cwd,
|
||||||
}
|
tr("glabels files (*.glabels);;All files (*)"),
|
||||||
|
nullptr,
|
||||||
model::XmlLabelCreator::writeFile( window->model(), fileName );
|
QFileDialog::DontConfirmOverwrite );
|
||||||
model::Settings::addToRecentFileList( window->model()->fileName() );
|
if ( !rawFileName.isEmpty() )
|
||||||
|
{
|
||||||
// Save CWD
|
QString fileName = model::FileUtil::addExtension( rawFileName, ".glabels" );
|
||||||
mCwd = QFileInfo( fileName ).absolutePath();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
if ( QFileInfo::exists(fileName) )
|
||||||
/// Template Designer
|
{
|
||||||
///
|
QMessageBox msgBox( window );
|
||||||
void File::templateDesigner( MainWindow *window )
|
msgBox.setWindowTitle( tr("Save Label As") );
|
||||||
{
|
msgBox.setIcon( QMessageBox::Warning );
|
||||||
TemplateDesigner dialog( window );
|
msgBox.setText( tr("%1 already exists.").arg(fileName) );
|
||||||
dialog.exec();
|
msgBox.setInformativeText( tr("Do you want to replace it?") );
|
||||||
}
|
msgBox.setStandardButtons( QMessageBox::Yes | QMessageBox::No );
|
||||||
|
msgBox.setDefaultButton( QMessageBox::No );
|
||||||
|
|
||||||
|
if ( msgBox.exec() == QMessageBox::No )
|
||||||
|
{
|
||||||
|
return saveAs( window );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model::XmlLabelCreator::writeFile( window->model(), fileName );
|
||||||
|
model::Settings::addToRecentFileList( window->model()->fileName() );
|
||||||
|
|
||||||
|
// Save CWD
|
||||||
|
mCwd = QFileInfo( fileName ).absolutePath();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Close file
|
/// Template Designer
|
||||||
///
|
///
|
||||||
void File::close( MainWindow *window )
|
void File::templateDesigner( MainWindow *window )
|
||||||
{
|
{
|
||||||
window->close();
|
TemplateDesigner dialog( window );
|
||||||
}
|
dialog.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Exit, closing all windows
|
/// Close file
|
||||||
///
|
///
|
||||||
void File::exit()
|
void File::close( MainWindow *window )
|
||||||
{
|
{
|
||||||
for ( QWidget* qwidget : QApplication::topLevelWidgets() )
|
window->close();
|
||||||
{
|
}
|
||||||
if ( auto* window = qobject_cast<MainWindow*>(qwidget) )
|
|
||||||
{
|
|
||||||
window->close();
|
///
|
||||||
}
|
/// Exit, closing all windows
|
||||||
}
|
///
|
||||||
}
|
void File::exit()
|
||||||
|
{
|
||||||
|
for ( QWidget* qwidget : QApplication::topLevelWidgets() )
|
||||||
|
{
|
||||||
|
if ( auto* window = qobject_cast<MainWindow*>(qwidget) )
|
||||||
|
{
|
||||||
|
window->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace glabels
|
} // namespace glabels
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
/* File.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2017 Jaye 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 File_h
|
|
||||||
#define File_h
|
|
||||||
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
|
||||||
{
|
|
||||||
|
|
||||||
// Forward References
|
|
||||||
class MainWindow;
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// File Actions
|
|
||||||
///
|
|
||||||
/// Note: class provides a translation context for these static functions.
|
|
||||||
///
|
|
||||||
class File : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
static bool newLabel( MainWindow *window = nullptr );
|
|
||||||
static void open( MainWindow *window );
|
|
||||||
static void open( const QString& fileName, MainWindow *window );
|
|
||||||
static bool save( MainWindow *window );
|
|
||||||
static bool saveAs( MainWindow *window );
|
|
||||||
static void templateDesigner( MainWindow *window );
|
|
||||||
static void close( MainWindow *window );
|
|
||||||
static void exit();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static QString mCwd;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // File_h
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user