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