16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 |
18 |
19 #include "headeredit.h" |
19 #include "headeredit.h" |
20 #include "ui_headeredit.h" |
20 #include "ui_headeredit.h" |
|
21 #include "parser.h" |
21 #include "../lddocument.h" |
22 #include "../lddocument.h" |
22 #include "../headerhistorymodel.h" |
23 #include "../headerhistorymodel.h" |
23 |
24 |
24 static const QStringList categories { |
25 static const QStringList categories { |
25 "", |
26 "", |
34 "Sticker", "Support", "Tail", "Tap", "Technic", "Tile", "Tipper", "Tractor", "Trailer", |
35 "Sticker", "Support", "Tail", "Tap", "Technic", "Tile", "Tipper", "Tractor", "Trailer", |
35 "Train", "Turntable", "Tyre", "Vehicle", "Wedge", "Wheel", "Winch", "Window", "Windscreen", |
36 "Train", "Turntable", "Tyre", "Vehicle", "Wedge", "Wheel", "Winch", "Window", "Windscreen", |
36 "Wing", "Znap", |
37 "Wing", "Znap", |
37 }; |
38 }; |
38 |
39 |
|
40 LDHeader::FileType headerTypeCast(int index) |
|
41 { |
|
42 if (Parser::typeStrings.values().contains(static_cast<LDHeader::FileType>(index))) |
|
43 return static_cast<LDHeader::FileType>(index); |
|
44 else |
|
45 return LDHeader::NoHeader; |
|
46 } |
|
47 |
39 HeaderEdit::HeaderEdit(QWidget* parent) : |
48 HeaderEdit::HeaderEdit(QWidget* parent) : |
40 QWidget {parent}, |
49 QWidget {parent}, |
41 ui {*new Ui_HeaderEdit}, |
50 ui {*new Ui_HeaderEdit}, |
42 headerHistoryModel {new HeaderHistoryModel {nullptr, this}} |
51 headerHistoryModel {new HeaderHistoryModel {nullptr, this}} |
43 { |
52 { |
91 qOverload<int>(&QComboBox::currentIndexChanged), |
100 qOverload<int>(&QComboBox::currentIndexChanged), |
92 [&](int index) |
101 [&](int index) |
93 { |
102 { |
94 if (this->hasValidHeader()) |
103 if (this->hasValidHeader()) |
95 this->m_header->category = ::categories.value(index); |
104 this->m_header->category = ::categories.value(index); |
|
105 } |
|
106 ); |
|
107 connect( |
|
108 ui.type, |
|
109 qOverload<int>(&QComboBox::currentIndexChanged), |
|
110 [&](int index) |
|
111 { |
|
112 if (this->hasValidHeader()) |
|
113 this->m_header->type = headerTypeCast(index + 1); |
96 } |
114 } |
97 ); |
115 ); |
98 connect( |
116 connect( |
99 ui.alias, |
117 ui.alias, |
100 &QCheckBox::stateChanged, |
118 &QCheckBox::stateChanged, |