added more cpp files for faster compile speeds

removed many obsolte elements
many improvements and fixes
This commit is contained in:
2018-07-20 15:00:43 +02:00
parent 7ee4e122e8
commit 5d002c3f2b
43 changed files with 1257 additions and 1361 deletions

View File

@@ -7,15 +7,17 @@
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QComboBox>
#include <QCheckBox>
#include <QFileDialog>
#include "../mapview/model/IHasParams.h"
class EditFields {
public:
static void get(QGridLayout* lay, IHasParams* elem) {
int r = 0;
static void get(QWidget* parent, int& r, QGridLayout* lay, IHasParams* elem) {
for(int i = 0; i < elem->getNumParams(); ++i) {
@@ -29,8 +31,24 @@ public:
switch(param.type) {
case ParamType::NOT_AVAILABLE:
break;
case ParamType::ENUM: {
QComboBox* cmb = new QComboBox(parent);
int idx = 0;
for (const std::string& str : param.getEnumValues()) {cmb->addItem(str.c_str(), idx++);}
cmb->setCurrentIndex(value.toInt());
cmb->connect(cmb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [i, elem, cmb] (int idx) {
(void) idx;
elem->setParamValue(i, cmb->currentData().toInt() );
});
lay->addWidget(cmb,r,1);
break;
}
case ParamType::BOOL: {
QCheckBox* chk = new QCheckBox( );
QCheckBox* chk = new QCheckBox(parent);
chk->setChecked(value.toBool());
if (param.readOnly) {
chk->setEnabled(false);
@@ -46,9 +64,9 @@ public:
case ParamType::FLOAT: {
const std::string str = std::to_string(value.toFloat());
if (param.readOnly) {
lay->addWidget(new QLabel(str.c_str()),r,1);
lay->addWidget(new QLabel(str.c_str(), parent),r,1);
} else {
QLineEdit* le = new QLineEdit( str.c_str() );
QLineEdit* le = new QLineEdit(str.c_str(), parent);
le->connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
const float val = str.toFloat();
elem->setParamValue(i, ParamValue(val));
@@ -61,11 +79,11 @@ public:
case ParamType::DOUBLE: {
const std::string str = std::to_string(value.toDouble());
if (param.readOnly) {
lay->addWidget(new QLabel(str.c_str()),r,1);
lay->addWidget(new QLabel(str.c_str(), parent),r,1);
} else {
QLineEdit* le = new QLineEdit( str.c_str() );
QLineEdit* le = new QLineEdit(str.c_str(), parent);
le->connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
const float val = str.toDouble();
const double val = str.toDouble();
elem->setParamValue(i, ParamValue(val));
});
lay->addWidget(le,r,1);
@@ -75,7 +93,7 @@ public:
case ParamType::INT: {
const std::string str = std::to_string(value.toInt());
QLineEdit* le = new QLineEdit( str.c_str() );
QLineEdit* le = new QLineEdit(str.c_str(), parent);
le->connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
const int val = str.toInt();
elem->setParamValue(i, ParamValue(val));
@@ -86,7 +104,7 @@ public:
case ParamType::STRING: {
const std::string str = value.toString();
QLineEdit* le = new QLineEdit( str.c_str() );
QLineEdit* le = new QLineEdit(str.c_str(), parent);
le->connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
elem->setParamValue(i, ParamValue(str.toStdString()));
});
@@ -96,8 +114,8 @@ public:
case ParamType::FILE: {
const std::string str = value.toString();
QLabel* lblFile = new QLabel(str.c_str());
QPushButton* btn = new QPushButton("<");
QLabel* lblFile = new QLabel(str.c_str(), parent);
QPushButton* btn = new QPushButton("<",parent);
btn->setMaximumSize(32,32);
btn->connect(btn, &QPushButton::clicked, [i,elem,lblFile] (const bool checked) {
(void) checked;
@@ -112,10 +130,10 @@ public:
case ParamType::POINT2: {
const Point2 p2 = value.toPoint2();
QWidget* subWidget = new QWidget();
QWidget* subWidget = new QWidget(parent);
QGridLayout* laySub = new QGridLayout(subWidget); laySub->setMargin(0);
QLineEdit* txtX = new QLineEdit(QString::number(p2.x));
QLineEdit* txtY = new QLineEdit(QString::number(p2.y));
QLineEdit* txtX = new QLineEdit(QString::number(p2.x), subWidget);
QLineEdit* txtY = new QLineEdit(QString::number(p2.y), subWidget);
laySub->addWidget(txtX,0,0);
laySub->addWidget(txtY,0,1);
lay->addWidget(subWidget,r,1);
@@ -130,11 +148,11 @@ public:
case ParamType::POINT3: {
const Point3 p3 = value.toPoint3();
QWidget* subWidget = new QWidget();
QWidget* subWidget = new QWidget(parent);
QGridLayout* laySub = new QGridLayout(subWidget); laySub->setMargin(0);
QLineEdit* txtX = new QLineEdit(QString::number(p3.x));
QLineEdit* txtY = new QLineEdit(QString::number(p3.y));
QLineEdit* txtZ = new QLineEdit(QString::number(p3.z));
QLineEdit* txtX = new QLineEdit(QString::number(p3.x), subWidget);
QLineEdit* txtY = new QLineEdit(QString::number(p3.y), subWidget);
QLineEdit* txtZ = new QLineEdit(QString::number(p3.z), subWidget);
laySub->addWidget(txtX,0,0);
laySub->addWidget(txtY,0,1);
laySub->addWidget(txtZ,0,2);
@@ -149,8 +167,8 @@ public:
break;
}
case ParamType::NOT_AVAILABLE:
break;
}