27 #include "../../../../common/STLUtils.h" 28 #include "../../../../common/StringUtils.h" 29 #include "../../../../dataaccess/dataset/PrimaryKey.h" 30 #include "../core/form/BoolFormItem.h" 31 #include "../core/form/DateFormItem.h" 32 #include "../core/form/DoubleFormItem.h" 33 #include "../core/form/IntFormItem.h" 34 #include "../core/form/LabelFormItem.h" 35 #include "../core/form/PictureFormItem.h" 36 #include "../core/form/Serializer.h" 37 #include "../core/form/StringComboFormItem.h" 38 #include "../core/form/StringFormItem.h" 39 #include "../core/form/TimeFormItem.h" 40 #include "../core/form/Form.h" 41 #include "../core/form/Section.h" 43 #include "ui_BuilderFormsWizardPageForm.h" 46 #include <QListWidgetItem> 47 #include <QMessageBox> 50 #define FORM_TREE_ITEM 0 51 #define PROPERTY_TREE_ITEM 1 55 m_ui(new
Ui::BuilderFormsWizardPageForm),
64 this->setTitle(tr(
"GeoPackage Builder Forms Configurer"));
65 this->setSubTitle(tr(
"Used to configure Forms for each Gathering Layer selected."));
67 m_ui->m_saveFormItemToolButton->setIcon(QIcon::fromTheme(
"view-refresh"));
68 m_ui->m_removeFormItemToolButton->setIcon(QIcon::fromTheme(
"list-remove"));
70 m_ui->m_doubleLineEdit->setValidator(
new QDoubleValidator(
this));
71 m_ui->m_intLineEdit->setValidator(
new QIntValidator(
this));
74 m_ui->m_stackedWidget->setCurrentIndex(9);
103 std::list<te::map::AbstractLayerPtr>::iterator it =
m_list.begin();
105 while (it !=
m_list.end())
109 std::string layerName = l->getTitle();
112 std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
114 std::string pkAttrName =
"";
123 std::vector<te::dt::Property*> props = dsType->getProperties();
127 section->
setName(
"terramobile");
135 for (std::size_t t = 0; t < props.size(); ++t)
178 section->
getForms().push_back(form);
181 m_sectionsMap.insert(std::map<std::string, Section*>::value_type(layerName, section));
204 std::string propertyName = item->text(0).toUtf8().data();
208 std::string formName = parent->text(0).toUtf8().data();
223 std::string propType = formItem->
getType();
236 m_ui->m_stackedWidget->setCurrentIndex(0);
242 m_ui->m_stackedWidget->setCurrentIndex(1);
256 m_ui->m_doubleLineEdit->clear();
259 m_ui->m_stackedWidget->setCurrentIndex(2);
273 m_ui->m_intLineEdit->clear();
276 m_ui->m_stackedWidget->setCurrentIndex(3);
290 m_ui->m_labelLineEdit->clear();
293 m_ui->m_stackedWidget->setCurrentIndex(4);
299 m_ui->m_stackedWidget->setCurrentIndex(9);
313 m_ui->m_stringComboLineEdit->clear();
316 m_ui->m_listWidget->clear();
318 for (std::size_t t = 0; t < fi->
getValues().size(); ++t)
323 m_ui->m_stackedWidget->setCurrentIndex(5);
337 m_ui->m_stringLineEdit->clear();
340 m_ui->m_stackedWidget->setCurrentIndex(6);
346 m_ui->m_stackedWidget->setCurrentIndex(7);
349 m_ui->m_formItemLineEdit->setText(propertyName.c_str());
351 m_ui->m_descLineEdit->setText(formItem->
getLabel().c_str());
353 m_ui->m_descLineEdit->setEnabled(
true);
358 m_ui->m_saveFormItemToolButton->setEnabled(
true);
359 m_ui->m_removeFormItemToolButton->setEnabled(
true);
363 m_ui->m_stackedWidget->setCurrentIndex(8);
365 std::string formName = item->text(0).toUtf8().data();
371 m_ui->m_formItemsListWidget->clear();
373 for (std::size_t t = 0; t < form->
getItems().size(); ++t)
375 m_ui->m_formItemsListWidget->addItem(form->
getItems()[t]->getKey().c_str());
378 m_ui->m_formItemLineEdit->setText(formName.c_str());
380 m_ui->m_descLineEdit->clear();
382 m_ui->m_descLineEdit->setEnabled(
false);
387 m_ui->m_saveFormItemToolButton->setEnabled(
true);
388 m_ui->m_removeFormItemToolButton->setEnabled(
false);
396 if (
m_ui->m_stringComboValueLineEdit->text().isEmpty())
398 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Value not defined."));
402 m_ui->m_listWidget->addItem(
m_ui->m_stringComboValueLineEdit->text());
415 if (
m_ui->m_defaultValueBoolCheckBox->isChecked())
417 std::string value =
m_ui->m_boolComboBox->currentText().toUtf8().data();
433 if (
m_ui->m_defaultValueDoubleCheckBox->isChecked())
435 fi->
setValue(
m_ui->m_doubleLineEdit->text().toDouble());
442 if (
m_ui->m_defaultValueIntCheckBox->isChecked())
451 if (
m_ui->m_defaultValueLabelCheckBox->isChecked())
453 fi->
setValue(
m_ui->m_labelLineEdit->text().toUtf8().data());
464 if (
m_ui->m_defaultValueStringComboCheckBox->isChecked())
466 fi->
setValue(
m_ui->m_stringComboLineEdit->text().toUtf8().data());
469 std::vector<std::string> values;
471 for (
int i = 0; i <
m_ui->m_listWidget->count(); ++i)
473 values.push_back(
m_ui->m_listWidget->item(i)->text().toUtf8().data());
482 if (
m_ui->m_defaultValueStringCheckBox->isChecked())
484 fi->
setValue(
m_ui->m_stringLineEdit->text().toUtf8().data());
492 std::string desc =
"";
494 if (!
m_ui->m_descLineEdit->text().isEmpty())
496 desc =
m_ui->m_descLineEdit->text().toUtf8().data();
501 QMessageBox::information(
this, tr(
"Information"), tr(
"Form Item updated."));
505 std::vector<std::string> values;
507 for (
int i = 0; i <
m_ui->m_formItemsListWidget->count(); ++i)
509 values.push_back(
m_ui->m_formItemsListWidget->item(i)->text().toUtf8().data());
512 std::vector<AbstractFormItem*> backupItems;
521 for (std::size_t t = 0; t < values.size(); ++t)
523 for (std::size_t
p = 0;
p < backupItems.size(); ++
p)
525 if (values[t] == backupItems[
p]->getKey())
534 QMessageBox::information(
this, tr(
"Information"), tr(
"Form updated."));
556 QMessageBox::information(
this, tr(
"Information"), tr(
"Form item removed."));
564 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Form item not removed."));
569 QComboBox* cmbBox =
dynamic_cast<QComboBox*
>(sender());
579 QTreeWidgetItemIterator it(
m_ui->m_treeWidget);
585 QWidget* widget =
m_ui->m_treeWidget->itemWidget(item, 1);
587 if (widget && widget == cmbBox)
589 std::string propertyName = item->text(0).toUtf8().data();
593 std::string formName = parent->text(0).toUtf8().data();
600 formItem = form->
getItem(propertyName);
607 if (!form || !formItem)
613 std::string propType = cmbBox->itemText(index).toUtf8().data();
658 for (std::size_t t = 0; t < form->
getItems().size(); ++t)
675 std::map<std::string, Section*>::iterator it =
m_sectionsMap.begin();
694 m_ui->m_treeWidget->clear();
696 std::map<std::string, Section*>::iterator it =
m_sectionsMap.begin();
702 for (std::size_t t = 0; t < section->
getForms().size(); ++t)
707 item->setText(0, form->
getName().c_str());
708 item->setIcon(0, QIcon::fromTheme(
"document-info"));
710 m_ui->m_treeWidget->addTopLevelItem(item);
712 for (std::size_t
p = 0;
p < form->
getItems().size(); ++
p)
717 subItem->setText(0, formItem->
getKey().c_str());
718 subItem->setIcon(0, QIcon::fromTheme(
"layer-info"));
719 item->addChild(subItem);
720 item->setExpanded(
true);
722 std::string curType = formItem->
getType().c_str();
724 QComboBox* cmbProperty =
new QComboBox(
m_ui->m_treeWidget);
736 cmbProperty->setCurrentText(curType.c_str());
738 connect(cmbProperty, SIGNAL(activated(
int)),
this, SLOT(
onItemTypeChanged(
int)));
740 m_ui->m_treeWidget->setItemWidget(subItem, 1, cmbProperty);
747 m_ui->m_treeWidget->resizeColumnToContents(0);
748 m_ui->m_treeWidget->resizeColumnToContents(1);
751 m_ui->m_stackedWidget->setCurrentIndex(9);
752 m_ui->m_formItemLineEdit->clear();
753 m_ui->m_descLineEdit->clear();
758 m_ui->m_saveFormItemToolButton->setEnabled(
false);
759 m_ui->m_removeFormItemToolButton->setEnabled(
false);
762 m_ui->m_plainTextEdit->clear();
772 m_ui->m_plainTextEdit->appendPlainText(jsonStr.c_str());
void onTreeItemClicked(QTreeWidgetItem *item, int column)
This class defines the Section object.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
BuilderFormsWizardPage(QWidget *parent=0)
std::string ReplaceSpecialChars(const std::string &str, bool &changed)
It replace special characters of a string.
void onSaveFormItemToolButton()
std::map< std::string, Section * > & getSections()
Form * getForm(const std::string &formName)
te::qt::plugins::terramobile::Form * m_curForm
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
void setLayerList(std::list< te::map::AbstractLayerPtr > list)
~BuilderFormsWizardPage()
void onItemTypeChanged(int index)
Form
It specifies the form for the attribute.
std::map< std::string, Section * > m_sectionsMap
#define LAYER_GATHERING_STATUS_COLUMN
It describes a primary key (pk) constraint.
te::qt::plugins::terramobile::AbstractFormItem * m_curFormItem
std::string Write(te::qt::plugins::terramobile::Section *section)
#define LAYER_GATHERING_OBJID_COLUMN
std::list< te::map::AbstractLayerPtr > m_list
void setName(std::string name)
std::auto_ptr< Ui::BuilderFormsWizardPageForm > m_ui
std::vector< Form * > & getForms()
void onRemoveFormItemToolButtonPressed()
void onStringComboAddToolButtonPressed()
void setDescription(std::string desc)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
#define PROPERTY_TREE_ITEM