src/widgets/headeredit.cpp

changeset 1384
4c134708be05
parent 1368
36105978da93
--- a/src/widgets/headeredit.cpp	Thu Apr 05 22:56:37 2018 +0300
+++ b/src/widgets/headeredit.cpp	Wed Apr 25 18:55:15 2018 +0300
@@ -18,6 +18,7 @@
 
 #include "headeredit.h"
 #include "ui_headeredit.h"
+#include "parser.h"
 #include "../lddocument.h"
 #include "../headerhistorymodel.h"
 
@@ -36,6 +37,14 @@
 	"Wing", "Znap",
 };
 
+LDHeader::FileType headerTypeCast(int index)
+{
+	if (Parser::typeStrings.values().contains(static_cast<LDHeader::FileType>(index)))
+		return static_cast<LDHeader::FileType>(index);
+	else
+		return LDHeader::NoHeader;
+}
+
 HeaderEdit::HeaderEdit(QWidget* parent) :
 	QWidget {parent},
 	ui {*new Ui_HeaderEdit},
@@ -96,6 +105,15 @@
 		}
 	);
 	connect(
+		ui.type,
+		qOverload<int>(&QComboBox::currentIndexChanged),
+		[&](int index)
+		{
+			if (this->hasValidHeader())
+				this->m_header->type = headerTypeCast(index + 1);
+		}
+	);
+	connect(
 		ui.alias,
 		&QCheckBox::stateChanged,
 		[&](int state)

mercurial