27 #include "../../../dataaccess/dataset/DataSetAdapter.h" 28 #include "../../../dataaccess/dataset/DataSetTypeConverter.h" 29 #include "../../../dataaccess/datasource/DataSourceInfo.h" 30 #include "../../../dataaccess/datasource/DataSourceInfoManager.h" 31 #include "../../../dataaccess/datasource/DataSourceManager.h" 32 #include "../../../dataaccess/utils/Utils.h" 33 #include "../../../geometry/GeometryProperty.h" 34 #include "../../../maptools/DataSetLayer.h" 36 #include "ui_SHP2ADODialogForm.h" 39 #include <QMessageBox> 44 te::qt::widgets::SHP2ADODialog::SHP2ADODialog(
QWidget* parent, Qt::WindowFlags f)
46 m_ui(new
Ui::SHP2ADODialogForm)
52 m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"data-exchange-shp-ado-hint").pixmap(112,48));
55 connect(m_ui->m_helpPushButton, SIGNAL(clicked()),
this, SLOT(onHelpPushButtonClicked()));
56 connect(m_ui->m_okPushButton, SIGNAL(clicked()),
this, SLOT(onOkPushButtonClicked()));
66 std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
68 while(it != layers.end())
72 std::string dsName = l->getDataSourceId();
76 if(dsPtr->getType() ==
"OGR")
77 m_ui->m_inputLayerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
82 if(
m_ui->m_inputLayerComboBox->count() > 0)
84 QString s =
m_ui->m_inputLayerComboBox->currentText();
86 m_ui->m_dataSetLineEdit->setText(s);
92 m_ui->m_outputDataSourceComboBox->clear();
94 std::vector<te::da::DataSourceInfoPtr> datasources;
98 for(std::size_t i = 0; i < datasources.size(); ++i)
102 if(datasource.get() ==
nullptr)
105 const std::string& title = datasource->getTitle();
107 m_ui->m_outputDataSourceComboBox->addItem(title.c_str(), QVariant::fromValue(datasource));
113 QMessageBox::information(
this,
"Help",
"Under development");
118 int idxLayer =
m_ui->m_inputLayerComboBox->currentIndex();
122 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Input layer not selected."));
126 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(idxLayer, Qt::UserRole);
131 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error getting selected layer."));
135 int idxDataSource =
m_ui->m_outputDataSourceComboBox->currentIndex();
139 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Output data source not selected."));
143 QVariant varDataSource =
m_ui->m_outputDataSourceComboBox->itemData(idxDataSource, Qt::UserRole);
148 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error getting selected data source."));
152 if(
m_ui->m_dataSetLineEdit->text().isEmpty())
154 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Data Set name not defined."));
161 std::unique_ptr<te::da::DataSetType> dsType = layer->getSchema();
163 if(dsType->size() == 0)
172 dsTypeResult->
setName(
m_ui->m_dataSetLineEdit->text().toUtf8().data());
175 std::map<std::string,std::string> nopt;
177 std::unique_ptr<te::da::DataSet> dataset = layer->getData();
179 targetDSPtr->createDataSet(dsTypeResult, nopt);
183 if(dataset->moveBeforeFirst())
184 targetDSPtr->add(dsTypeResult->getName(), dsAdapter.get(), nopt);
186 QMessageBox::information(
this, tr(
"Exchanger"), tr(
"Layer exported successfully."));
188 catch(
const std::exception& e)
190 QString errMsg(tr(
"Error during exchanger. The reported error is: %1"));
192 errMsg = errMsg.arg(e.what());
194 QMessageBox::information(
this, tr(
"Exchanger"), errMsg);
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
TEDATAACCESSEXPORT void LoadProperties(te::da::DataSetType *dataset, const std::string &datasourceId)
boost::shared_ptr< DataSource > DataSourcePtr
A class that models the description of a dataset.
DataSetType * getResult() const
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr) Q_DECLARE_METATYPE(te
An converter for DataSetType.
void setName(const std::string &name)
It sets the property name.
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
A exchanger dialog from SHP to ADO operation.
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr