added more cpp files for faster compile speeds
removed many obsolte elements many improvements and fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "../mapview/model/IHasEditableMeta.h"
|
||||
|
||||
#include "MetaEditWidget.h"
|
||||
#include "EditFields.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
@@ -19,6 +20,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
#include <QCheckBox>
|
||||
|
||||
QComboBox* getMaterials() {
|
||||
using namespace Floorplan;
|
||||
@@ -96,7 +98,7 @@ void ElementParamWidget::refresh() {
|
||||
|
||||
while ( QWidget* w = this->findChild<QWidget*>() ) {delete w;}
|
||||
delete this->layout();
|
||||
this->lay = new QGridLayout();
|
||||
this->lay = new QGridLayout(this);
|
||||
this->setLayout(lay);
|
||||
int r = 0;
|
||||
|
||||
@@ -107,7 +109,7 @@ void ElementParamWidget::refresh() {
|
||||
IHasMaterial* elem = dynamic_cast<IHasMaterial*>(el);
|
||||
if (elem) {
|
||||
material.cmb = getMaterials();
|
||||
material.lbl = new QLabel("material");
|
||||
material.lbl = new QLabel("material", this);
|
||||
lay->addWidget(material.lbl,r,0);
|
||||
lay->addWidget(material.cmb,r,1);
|
||||
connect(material.cmb , SIGNAL(currentIndexChanged(int)), this, SLOT(onMaterialChange()));
|
||||
@@ -121,7 +123,7 @@ void ElementParamWidget::refresh() {
|
||||
IHasObstacleType* elem = dynamic_cast<IHasObstacleType*>(el);
|
||||
if (elem) {
|
||||
obstacleType.cmb = getObstacleTypes();
|
||||
obstacleType.lbl = new QLabel("type");
|
||||
obstacleType.lbl = new QLabel("type", this);
|
||||
lay->addWidget(obstacleType.lbl,r,0);
|
||||
lay->addWidget(obstacleType.cmb,r,1);
|
||||
connect(obstacleType.cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(onObstacleTypeChange()));
|
||||
@@ -135,7 +137,7 @@ void ElementParamWidget::refresh() {
|
||||
MMFloorOutlinePolygon* elem = dynamic_cast<MMFloorOutlinePolygon*>(el);
|
||||
if (elem) {
|
||||
QComboBox* cmb = getOutlineMethods();
|
||||
QLabel* lbl = new QLabel("outline");
|
||||
QLabel* lbl = new QLabel("outline", this);
|
||||
lay->addWidget(lbl,r,0);
|
||||
lay->addWidget(cmb,r,1);
|
||||
cmb->setCurrentIndex((int)elem->getMethod());
|
||||
@@ -150,176 +152,21 @@ void ElementParamWidget::refresh() {
|
||||
{ // does the element have "parameters" ?
|
||||
IHasParams* elem = dynamic_cast<IHasParams*>(el);
|
||||
if (elem) {
|
||||
|
||||
for(int i = 0; i < elem->getNumParams(); ++i) {
|
||||
|
||||
const Param param = elem->getParamDesc(i);
|
||||
const ParamValue value = elem->getParamValue(i);
|
||||
|
||||
// skip Not-Available entries
|
||||
if (param.type == ParamType::NOT_AVAILABLE) {continue;}
|
||||
|
||||
lay->addWidget(new QLabel(param.name.c_str()),r,0);
|
||||
|
||||
switch(param.type) {
|
||||
|
||||
case ParamType::NOT_AVAILABLE:
|
||||
break;
|
||||
|
||||
case ParamType::ENUM: {
|
||||
QComboBox* cmb = new QComboBox();
|
||||
int idx = 0;
|
||||
for (const std::string& str : param.getEnumValues()) {cmb->addItem(str.c_str(), idx++);}
|
||||
cmb->setCurrentIndex(value.toInt());
|
||||
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( );
|
||||
chk->setChecked(value.toBool());
|
||||
if (param.readOnly) {
|
||||
chk->setEnabled(false);
|
||||
} else {
|
||||
connect(chk, &QCheckBox::clicked, [i,elem] (const bool checked) {
|
||||
elem->setParamValue(i, ParamValue(checked));
|
||||
});
|
||||
}
|
||||
lay->addWidget(chk,r,1);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::FLOAT: {
|
||||
const std::string str = std::to_string(value.toFloat());
|
||||
if (param.readOnly) {
|
||||
lay->addWidget(new QLabel(str.c_str()),r,1);
|
||||
} else {
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const float val = str.toFloat();
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::DOUBLE: {
|
||||
const std::string str = std::to_string(value.toDouble());
|
||||
if (param.readOnly) {
|
||||
lay->addWidget(new QLabel(str.c_str()),r,1);
|
||||
} else {
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const double val = str.toDouble();
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::INT: {
|
||||
const std::string str = std::to_string(value.toInt());
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const int val = str.toInt();
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::STRING: {
|
||||
const std::string str = value.toString();
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
elem->setParamValue(i, ParamValue(str.toStdString()));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::FILE: {
|
||||
const std::string str = value.toString();
|
||||
QLabel* lblFile = new QLabel(str.c_str());
|
||||
QPushButton* btn = new QPushButton("<");
|
||||
btn->setMaximumSize(32,32);
|
||||
connect(btn, &QPushButton::clicked, [i,elem,lblFile] (const bool checked) {
|
||||
(void) checked;
|
||||
QString res = QFileDialog::getOpenFileName();
|
||||
elem->setParamValue(i, ParamValue(res.toStdString()));
|
||||
lblFile->setText(res);
|
||||
});
|
||||
lay->addWidget(lblFile,r,1);
|
||||
lay->addWidget(btn,r,2);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::POINT2: {
|
||||
const Point2 p2 = value.toPoint2();
|
||||
QWidget* subWidget = new QWidget();
|
||||
QGridLayout* laySub = new QGridLayout(subWidget); laySub->setMargin(0);
|
||||
QLineEdit* txtX = new QLineEdit(QString::number(p2.x));
|
||||
QLineEdit* txtY = new QLineEdit(QString::number(p2.y));
|
||||
laySub->addWidget(txtX,0,0);
|
||||
laySub->addWidget(txtY,0,1);
|
||||
lay->addWidget(subWidget,r,1);
|
||||
auto onChange = [i,elem,txtX,txtY] (const QString& str) {
|
||||
(void) str;
|
||||
elem->setParamValue(i, ParamValue( Point2(txtX->text().toFloat(), txtY->text().toFloat()) ));
|
||||
};
|
||||
connect(txtX, &QLineEdit::textChanged, onChange);
|
||||
connect(txtY, &QLineEdit::textChanged, onChange);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::POINT3: {
|
||||
const Point3 p3 = value.toPoint3();
|
||||
QWidget* subWidget = new QWidget();
|
||||
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));
|
||||
laySub->addWidget(txtX,0,0);
|
||||
laySub->addWidget(txtY,0,1);
|
||||
laySub->addWidget(txtZ,0,2);
|
||||
lay->addWidget(subWidget,r,1);
|
||||
auto onChange = [i,elem,txtX,txtY,txtZ] (const QString& str) {
|
||||
(void) str;
|
||||
elem->setParamValue(i, ParamValue( Point3(txtX->text().toFloat(), txtY->text().toFloat(), txtZ->text().toFloat()) ));
|
||||
};
|
||||
connect(txtX, &QLineEdit::textChanged, onChange);
|
||||
connect(txtY, &QLineEdit::textChanged, onChange);
|
||||
connect(txtZ, &QLineEdit::textChanged, onChange);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
++r;
|
||||
|
||||
}
|
||||
EditFields::get(this, r, lay, elem);
|
||||
}
|
||||
|
||||
{ // does the element have editable metadata?
|
||||
IHasEditableMeta* elem = dynamic_cast<IHasEditableMeta*>(el);
|
||||
if (elem) {
|
||||
|
||||
QPushButton* btn = new QPushButton("edit");
|
||||
QPushButton* btn = new QPushButton("edit", this);
|
||||
connect(btn, &QPushButton::clicked, [elem] (const bool checked) {
|
||||
(void) checked;
|
||||
if (!elem->getMeta()) {elem->setMeta(new Floorplan::Meta());} // ensure meta-object is present
|
||||
MetaEditWidget* mew = new MetaEditWidget(elem->getMeta()); // edit
|
||||
mew->show();
|
||||
});
|
||||
lay->addWidget(new QLabel("Meta"),r,0);
|
||||
lay->addWidget(new QLabel("Meta", this),r,0);
|
||||
lay->addWidget(btn,r,1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ void LayerParamWidget::setElement(MapLayer* l) {
|
||||
delete this->layout();
|
||||
this->lay = new QGridLayout();
|
||||
this->setLayout(lay);
|
||||
// int r = 0;
|
||||
int r = 0;
|
||||
|
||||
|
||||
// {
|
||||
@@ -97,7 +97,7 @@ void LayerParamWidget::setElement(MapLayer* l) {
|
||||
{
|
||||
IHasParams* elem = dynamic_cast<IHasParams*>(l);
|
||||
if (elem) {
|
||||
EditFields::get(lay, elem);
|
||||
EditFields::get(this, r, lay, elem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class QLabel;
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
class QGridLayout;
|
||||
class IHasParams;
|
||||
|
||||
class LayerParamWidget : public QWidget {
|
||||
|
||||
@@ -48,6 +49,7 @@ private:
|
||||
QLabel* lbl;
|
||||
} height;
|
||||
|
||||
void buildFields(QGridLayout* lay, IHasParams* elem);
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
@@ -15,11 +15,13 @@ void MetaEditModel::setSource(Floorplan::Meta* meta) {
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
int MetaEditModel::rowCount(const QModelIndex &parent) const {
|
||||
int MetaEditModel::rowCount(const QModelIndex& parent) const {
|
||||
(void) parent;
|
||||
return (meta) ? (meta->size()) : (0);
|
||||
}
|
||||
|
||||
int MetaEditModel::columnCount(const QModelIndex &parent) const {
|
||||
int MetaEditModel::columnCount(const QModelIndex& parent) const {
|
||||
(void) parent;
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user