Seamly2D
Code documentation
pmsystems.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 1 6, 2017
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2017 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #include "pmsystems.h"
53 #include "../vmisc/def.h"
54 #include "../vmisc/vabstractapplication.h"
55 
56 #include <QComboBox>
57 
58 // pattern making systems codes
59 const QString p0_S = QStringLiteral("p0");
60 const QString p1_S = QStringLiteral("p1");
61 const QString p2_S = QStringLiteral("p2");
62 const QString p3_S = QStringLiteral("p3");
63 const QString p4_S = QStringLiteral("p4");
64 const QString p5_S = QStringLiteral("p5");
65 const QString p6_S = QStringLiteral("p6");
66 const QString p7_S = QStringLiteral("p7");
67 const QString p8_S = QStringLiteral("p8");
68 const QString p9_S = QStringLiteral("p9");
69 const QString p10_S = QStringLiteral("p10");
70 const QString p11_S = QStringLiteral("p11");
71 const QString p12_S = QStringLiteral("p12");
72 const QString p13_S = QStringLiteral("p13");
73 const QString p14_S = QStringLiteral("p14");
74 const QString p15_S = QStringLiteral("p15");
75 const QString p16_S = QStringLiteral("p16");
76 const QString p17_S = QStringLiteral("p17");
77 const QString p18_S = QStringLiteral("p18");
78 const QString p19_S = QStringLiteral("p19");
79 const QString p20_S = QStringLiteral("p20");
80 const QString p21_S = QStringLiteral("p21");
81 const QString p22_S = QStringLiteral("p22");
82 const QString p23_S = QStringLiteral("p23");
83 const QString p24_S = QStringLiteral("p24");
84 const QString p25_S = QStringLiteral("p25");
85 const QString p26_S = QStringLiteral("p26");
86 const QString p27_S = QStringLiteral("p27");
87 const QString p28_S = QStringLiteral("p28");
88 const QString p29_S = QStringLiteral("p29");
89 const QString p30_S = QStringLiteral("p30");
90 const QString p31_S = QStringLiteral("p31");
91 const QString p32_S = QStringLiteral("p32");
92 const QString p33_S = QStringLiteral("p33");
93 const QString p34_S = QStringLiteral("p34");
94 const QString p35_S = QStringLiteral("p35");
95 const QString p36_S = QStringLiteral("p36");
96 const QString p37_S = QStringLiteral("p37");
97 const QString p38_S = QStringLiteral("p38");
98 const QString p39_S = QStringLiteral("p39");
99 const QString p40_S = QStringLiteral("p40");
100 const QString p41_S = QStringLiteral("p41");
101 const QString p42_S = QStringLiteral("p42");
102 const QString p43_S = QStringLiteral("p43");
103 const QString p44_S = QStringLiteral("p44");
104 const QString p45_S = QStringLiteral("p45");
105 const QString p46_S = QStringLiteral("p46");
106 const QString p47_S = QStringLiteral("p47");
107 const QString p48_S = QStringLiteral("p48");
108 const QString p49_S = QStringLiteral("p49");
109 const QString p50_S = QStringLiteral("p50");
110 const QString p51_S = QStringLiteral("p51");
111 const QString p52_S = QStringLiteral("p52");
112 const QString p53_S = QStringLiteral("p53");
113 const QString p54_S = QStringLiteral("p54");
114 const QString p998_S = QStringLiteral("p998");
115 
116 //---------------------------------------------------------------------------------------------------------------------
117 QStringList ListPMSystems()
118 {
119  QStringList list;
120  list << p0_S
121  << p1_S
122  << p2_S
123  << p3_S
124  << p4_S
125  << p5_S
126  << p6_S
127  << p7_S
128  << p8_S
129  << p9_S
130  << p10_S
131  << p11_S
132  << p12_S
133  << p13_S
134  << p14_S
135  << p15_S
136  << p16_S
137  << p17_S
138  << p18_S
139  << p19_S
140  << p20_S
141  << p21_S
142  << p22_S
143  << p23_S
144  << p24_S
145  << p25_S
146  << p26_S
147  << p27_S
148  << p28_S
149  << p29_S
150  << p30_S
151  << p31_S
152  << p32_S
153  << p33_S
154  << p34_S
155  << p35_S
156  << p36_S
157  << p37_S
158  << p38_S
159  << p39_S
160  << p40_S
161  << p41_S
162  << p42_S
163  << p43_S
164  << p44_S
165  << p45_S
166  << p46_S
167  << p47_S
168  << p48_S
169  << p49_S
170  << p50_S
171  << p51_S
172  << p52_S
173  << p53_S
174  << p54_S
175  << p998_S;
176 
177  return list;
178 }
179 
180 //---------------------------------------------------------------------------------------------------------------------
181 void InitPMSystems(QComboBox *systemCombo)
182 {
183  const QStringList listSystems = ListPMSystems();
184  QMap<QString, QString> systems;
185  for (int i = 0; i < listSystems.size()-1; ++i)
186  {
187  systems.insert(qApp->TrVars()->PMSystemName(listSystems.at(i)) + " ("+listSystems.at(i)+")", listSystems.at(i));
188  }
189 
190 // * The default option (blank field or 'None') should appear at the top of the list.
191 // * The list should be sorted alphabetically so users can find their system easily.
192 
193  SCASSERT(systemCombo != nullptr)
194  systemCombo->addItem(qApp->TrVars()->PMSystemName(listSystems.at(listSystems.size()-1)),
195  listSystems.at(listSystems.size()-1));
196 
197  QMap<QString, QString>::const_iterator i = systems.constBegin();
198  while (i != systems.constEnd())
199  {
200  systemCombo->addItem(i.key(), i.value());
201  ++i;
202  }
203 }
#define SCASSERT(cond)
Definition: def.h:317
const QString p49_S
Definition: pmsystems.cpp:108
const QString p19_S
Definition: pmsystems.cpp:78
const QString p48_S
Definition: pmsystems.cpp:107
const QString p50_S
Definition: pmsystems.cpp:109
const QString p27_S
Definition: pmsystems.cpp:86
const QString p32_S
Definition: pmsystems.cpp:91
const QString p30_S
Definition: pmsystems.cpp:89
const QString p20_S
Definition: pmsystems.cpp:79
const QString p33_S
Definition: pmsystems.cpp:92
const QString p998_S
Definition: pmsystems.cpp:114
const QString p54_S
Definition: pmsystems.cpp:113
const QString p23_S
Definition: pmsystems.cpp:82
const QString p34_S
Definition: pmsystems.cpp:93
const QString p47_S
Definition: pmsystems.cpp:106
const QString p25_S
Definition: pmsystems.cpp:84
const QString p39_S
Definition: pmsystems.cpp:98
const QString p16_S
Definition: pmsystems.cpp:75
const QString p21_S
Definition: pmsystems.cpp:80
void InitPMSystems(QComboBox *systemCombo)
Definition: pmsystems.cpp:181
const QString p18_S
Definition: pmsystems.cpp:77
const QString p38_S
Definition: pmsystems.cpp:97
const QString p36_S
Definition: pmsystems.cpp:95
const QString p1_S
Definition: pmsystems.cpp:60
const QString p43_S
Definition: pmsystems.cpp:102
const QString p8_S
Definition: pmsystems.cpp:67
const QString p9_S
Definition: pmsystems.cpp:68
const QString p3_S
Definition: pmsystems.cpp:62
const QString p15_S
Definition: pmsystems.cpp:74
const QString p24_S
Definition: pmsystems.cpp:83
const QString p35_S
Definition: pmsystems.cpp:94
const QString p31_S
Definition: pmsystems.cpp:90
const QString p14_S
Definition: pmsystems.cpp:73
const QString p4_S
Definition: pmsystems.cpp:63
const QString p28_S
Definition: pmsystems.cpp:87
const QString p13_S
Definition: pmsystems.cpp:72
const QString p22_S
Definition: pmsystems.cpp:81
const QString p42_S
Definition: pmsystems.cpp:101
const QString p46_S
Definition: pmsystems.cpp:105
const QString p40_S
Definition: pmsystems.cpp:99
const QString p12_S
Definition: pmsystems.cpp:71
const QString p11_S
Definition: pmsystems.cpp:70
const QString p51_S
Definition: pmsystems.cpp:110
const QString p53_S
Definition: pmsystems.cpp:112
const QString p29_S
Definition: pmsystems.cpp:88
const QString p5_S
Definition: pmsystems.cpp:64
const QString p52_S
Definition: pmsystems.cpp:111
const QString p37_S
Definition: pmsystems.cpp:96
const QString p26_S
Definition: pmsystems.cpp:85
const QString p0_S
Definition: pmsystems.cpp:59
const QString p44_S
Definition: pmsystems.cpp:103
const QString p10_S
Definition: pmsystems.cpp:69
const QString p2_S
Definition: pmsystems.cpp:61
const QString p45_S
Definition: pmsystems.cpp:104
const QString p7_S
Definition: pmsystems.cpp:66
QStringList ListPMSystems()
Definition: pmsystems.cpp:117
const QString p17_S
Definition: pmsystems.cpp:76
const QString p6_S
Definition: pmsystems.cpp:65
const QString p41_S
Definition: pmsystems.cpp:100
#define qApp
Definition: vapplication.h:67