Skip to content

Commit 85a8c9f

Browse files
committed
Added Paper::type() to differentiate envelopes from sheets.
1 parent 993e1e4 commit 85a8c9f

File tree

4 files changed

+83
-44
lines changed

4 files changed

+83
-44
lines changed

model/Paper.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ namespace glabels::model
2929
const QString& name,
3030
Distance width,
3131
Distance height,
32-
const QString& pwgSize )
32+
const QString& pwgSize,
33+
Type type )
3334
: mId(id),
3435
mName(name),
3536
mWidth(width),
3637
mHeight(height),
37-
mPwgSize(pwgSize)
38+
mPwgSize(pwgSize),
39+
mType(type)
3840
{
3941
// empty
4042
}
@@ -70,6 +72,12 @@ namespace glabels::model
7072
}
7173

7274

75+
Paper::Type Paper::type() const
76+
{
77+
return mType;
78+
}
79+
80+
7381
bool Paper::isSizeIso() const
7482
{
7583
return mPwgSize.startsWith( "iso_" );

model/Paper.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ namespace glabels::model
3232

3333
class Paper
3434
{
35+
public:
36+
enum Type
37+
{
38+
SHEET,
39+
ENVELOPE,
40+
ROLL
41+
};
42+
43+
3544
public:
3645
Paper() = default;
3746
Paper( const QString& id,
3847
const QString& name,
3948
Distance width,
4049
Distance height,
41-
const QString& pwgSize );
50+
const QString& pwgSize,
51+
Type type = SHEET );
4252
~Paper() = default;
4353

4454
QString id() const;
@@ -53,15 +63,20 @@ namespace glabels::model
5363
/* PWG 5101.1-2002 size name */
5464
QString pwgSize() const;
5565

66+
Type type() const;
67+
5668
bool isSizeIso() const;
5769
bool isSizeUs() const;
5870

71+
5972
private:
6073
QString mId;
6174
QString mName;
6275
Distance mWidth;
6376
Distance mHeight;
6477
QString mPwgSize;
78+
Type mType;
79+
6580
};
6681

6782
}

model/XmlPaperParser.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,23 @@ namespace glabels::model
101101

102102
QString pwgSize = XmlUtil::getStringAttr( node, "pwg_size", "" );
103103

104-
return Paper( id, name, width, height, pwgSize );
104+
Paper::Type type;
105+
QString typeString = XmlUtil::getStringAttr( node, "type", "sheet" );
106+
if ( typeString == "sheet" )
107+
{
108+
type = Paper::SHEET;
109+
}
110+
else if ( typeString == "envelope" )
111+
{
112+
type = Paper::ENVELOPE;
113+
}
114+
else
115+
{
116+
qWarning() << "Warning: unknown paper type: " << typeString << ".";
117+
type = Paper::SHEET;
118+
}
119+
120+
return Paper( id, name, width, height, pwgSize, type );
105121
}
106122

107123

templates/paper-sizes.xml

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,55 @@
33
<Glabels-paper-sizes>
44

55
<!-- Most popular (at top of list) -->
6-
<Paper-size id="A4" name="A4" pwg_size="iso_a4" width="210mm" height="297mm"/>
7-
<Paper-size id="US-Letter" name="US Letter" pwg_size="na_letter" width="8.5in" height="11in"/>
6+
<Paper-size id="A4" name="A4" pwg_size="iso_a4" width="210mm" height="297mm" />
7+
<Paper-size id="US-Letter" name="US Letter" pwg_size="na_letter" width="8.5in" height="11in" />
88

99
<!-- Other US paper sizes -->
10-
<Paper-size id="US-Legal" name="US Legal" pwg_size="na_legal" width="8.5in" height="14in"/>
11-
<Paper-size id="US-Executive" name="US Executive" pwg_size="na_executive" width="7.25in" height="10.5in"/>
10+
<Paper-size id="US-Legal" name="US Legal" pwg_size="na_legal" width="8.5in" height="14in" />
11+
<Paper-size id="US-Executive" name="US Executive" pwg_size="na_executive" width="7.25in" height="10.5in" />
1212

1313
<!-- Other ISO A series sizes -->
14-
<Paper-size id="A0" name="A0" pwg_size="iso_a0" width="841mm" height="1189mm"/>
15-
<Paper-size id="A1" name="A1" pwg_size="iso_a1" width="594mm" height="841mm"/>
16-
<Paper-size id="A2" name="A2" pwg_size="iso_a2" width="420mm" height="594mm"/>
17-
<Paper-size id="A3" name="A3" pwg_size="iso_a3" width="297mm" height="420mm"/>
18-
<Paper-size id="A5" name="A5" pwg_size="iso_a5" width="148mm" height="210mm"/>
19-
<Paper-size id="A6" name="A6" pwg_size="iso_a6" width="105mm" height="148mm"/>
20-
<Paper-size id="A7" name="A7" pwg_size="iso_a7" width="74mm" height="105mm"/>
21-
<Paper-size id="A8" name="A8" pwg_size="iso_a8" width="52mm" height="74mm"/>
22-
<Paper-size id="A9" name="A9" pwg_size="iso_a9" width="37mm" height="52mm"/>
23-
<Paper-size id="A10" name="A10" pwg_size="iso_a10" width="26mm" height="37mm"/>
14+
<Paper-size id="A0" name="A0" pwg_size="iso_a0" width="841mm" height="1189mm" />
15+
<Paper-size id="A1" name="A1" pwg_size="iso_a1" width="594mm" height="841mm" />
16+
<Paper-size id="A2" name="A2" pwg_size="iso_a2" width="420mm" height="594mm" />
17+
<Paper-size id="A3" name="A3" pwg_size="iso_a3" width="297mm" height="420mm" />
18+
<Paper-size id="A5" name="A5" pwg_size="iso_a5" width="148mm" height="210mm" />
19+
<Paper-size id="A6" name="A6" pwg_size="iso_a6" width="105mm" height="148mm" />
20+
<Paper-size id="A7" name="A7" pwg_size="iso_a7" width="74mm" height="105mm" />
21+
<Paper-size id="A8" name="A8" pwg_size="iso_a8" width="52mm" height="74mm" />
22+
<Paper-size id="A9" name="A9" pwg_size="iso_a9" width="37mm" height="52mm" />
23+
<Paper-size id="A10" name="A10" pwg_size="iso_a10" width="26mm" height="37mm" />
2424

2525
<!-- ISO B series sizes -->
26-
<Paper-size id="B0" name="B0" pwg_size="iso_b0" width="1000mm" height="1414mm"/>
27-
<Paper-size id="B1" name="B1" pwg_size="iso_b1" width="707mm" height="1000mm"/>
28-
<Paper-size id="B2" name="B2" pwg_size="iso_b2" width="500mm" height="707mm"/>
29-
<Paper-size id="B3" name="B3" pwg_size="iso_b3" width="353mm" height="500mm"/>
30-
<Paper-size id="B4" name="B4" pwg_size="iso_b4" width="250mm" height="353mm"/>
31-
<Paper-size id="B5" name="B5" pwg_size="iso_b5" width="176mm" height="250mm"/>
32-
<Paper-size id="B6" name="B6" pwg_size="iso_b6" width="125mm" height="176mm"/>
33-
<Paper-size id="B7" name="B7" pwg_size="iso_b7" width="88mm" height="125mm"/>
34-
<Paper-size id="B8" name="B8" pwg_size="iso_b8" width="62mm" height="88mm"/>
35-
<Paper-size id="B9" name="B9" pwg_size="iso_b9" width="44mm" height="62mm"/>
36-
<Paper-size id="B10" name="B10" pwg_size="iso_b10" width="31mm" height="44mm"/>
26+
<Paper-size id="B0" name="B0" pwg_size="iso_b0" width="1000mm" height="1414mm" />
27+
<Paper-size id="B1" name="B1" pwg_size="iso_b1" width="707mm" height="1000mm" />
28+
<Paper-size id="B2" name="B2" pwg_size="iso_b2" width="500mm" height="707mm" />
29+
<Paper-size id="B3" name="B3" pwg_size="iso_b3" width="353mm" height="500mm" />
30+
<Paper-size id="B4" name="B4" pwg_size="iso_b4" width="250mm" height="353mm" />
31+
<Paper-size id="B5" name="B5" pwg_size="iso_b5" width="176mm" height="250mm" />
32+
<Paper-size id="B6" name="B6" pwg_size="iso_b6" width="125mm" height="176mm" />
33+
<Paper-size id="B7" name="B7" pwg_size="iso_b7" width="88mm" height="125mm" />
34+
<Paper-size id="B8" name="B8" pwg_size="iso_b8" width="62mm" height="88mm" />
35+
<Paper-size id="B9" name="B9" pwg_size="iso_b9" width="44mm" height="62mm" />
36+
<Paper-size id="B10" name="B10" pwg_size="iso_b10" width="31mm" height="44mm" />
3737

3838
<!-- Envelopes -->
39-
<Paper-size id="number10" name="#10 Envelope" pwg_size="na_number-10" width="4.125in" height="9.5in"/>
40-
<Paper-size id="monarch" name="Monarch Envelope" pwg_size="na_monarch" width="3.875in" height="7.5in"/>
41-
<Paper-size id="c5" name="C5" pwg_size="iso_c5" width="162mm" height="229mm"/>
42-
<Paper-size id="c6" name="C6" pwg_size="iso_c6" width="114mm" height="162mm"/>
43-
<Paper-size id="dl" name="DL" pwg_size="iso_dl" width="110mm" height="220mm"/>
39+
<Paper-size id="number10" name="#10" pwg_size="na_number-10" width="4.125in" height="9.5in" type="envelope" />
40+
<Paper-size id="monarch" name="Monarch" pwg_size="na_monarch" width="3.875in" height="7.5in" type="envelope" />
41+
<Paper-size id="c5" name="C5" pwg_size="iso_c5" width="162mm" height="229mm" type="envelope" />
42+
<Paper-size id="c6" name="C6" pwg_size="iso_c6" width="114mm" height="162mm" type="envelope" />
43+
<Paper-size id="dl" name="DL" pwg_size="iso_dl" width="110mm" height="220mm" type="envelope" />
4444

4545
<!-- ISO 217 -->
46-
<Paper-size id="RA0" name="RA0" pwg_size="iso_ra0" width="860mm" height="1220mm"/>
47-
<Paper-size id="RA1" name="RA1" pwg_size="iso_ra1" width="610mm" height="860mm"/>
48-
<Paper-size id="RA2" name="RA2" pwg_size="iso_ra2" width="430mm" height="610mm"/>
49-
<Paper-size id="RA3" name="RA3" pwg_size="iso_ra3" width="305mm" height="430mm"/>
50-
<Paper-size id="RA4" name="RA4" pwg_size="iso_ra4" width="215mm" height="305mm"/>
51-
<Paper-size id="SRA0" name="SRA0" pwg_size="iso_sra0" width="900mm" height="1280mm"/>
52-
<Paper-size id="SRA1" name="SRA1" pwg_size="iso_sra1" width="640mm" height="900mm"/>
53-
<Paper-size id="SRA2" name="SRA2" pwg_size="iso_sra2" width="450mm" height="640mm"/>
54-
<Paper-size id="SRA3" name="SRA3" pwg_size="iso_sra3" width="320mm" height="450mm"/>
55-
<Paper-size id="SRA4" name="SRA4" pwg_size="iso_sra4" width="225mm" height="320mm"/>
46+
<Paper-size id="RA0" name="RA0" pwg_size="iso_ra0" width="860mm" height="1220mm" />
47+
<Paper-size id="RA1" name="RA1" pwg_size="iso_ra1" width="610mm" height="860mm" />
48+
<Paper-size id="RA2" name="RA2" pwg_size="iso_ra2" width="430mm" height="610mm" />
49+
<Paper-size id="RA3" name="RA3" pwg_size="iso_ra3" width="305mm" height="430mm" />
50+
<Paper-size id="RA4" name="RA4" pwg_size="iso_ra4" width="215mm" height="305mm" />
51+
<Paper-size id="SRA0" name="SRA0" pwg_size="iso_sra0" width="900mm" height="1280mm" />
52+
<Paper-size id="SRA1" name="SRA1" pwg_size="iso_sra1" width="640mm" height="900mm" />
53+
<Paper-size id="SRA2" name="SRA2" pwg_size="iso_sra2" width="450mm" height="640mm" />
54+
<Paper-size id="SRA3" name="SRA3" pwg_size="iso_sra3" width="320mm" height="450mm" />
55+
<Paper-size id="SRA4" name="SRA4" pwg_size="iso_sra4" width="225mm" height="320mm" />
5656

5757
</Glabels-paper-sizes>

0 commit comments

Comments
 (0)