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>
46 m_ui(new Ui::SHP2ADODialogForm)
52 m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"data-exchange-shp-ado-hint").pixmap(112,48));
68 std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
70 while(it != layers.end())
83 if(dsPtr->getType() ==
"OGR")
84 m_ui->m_inputLayerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
89 if(m_ui->m_inputLayerComboBox->count() > 0)
91 QString s = m_ui->m_inputLayerComboBox->currentText();
93 m_ui->m_dataSetLineEdit->setText(s);
99 m_ui->m_outputDataSourceComboBox->clear();
101 std::vector<te::da::DataSourceInfoPtr> datasources;
105 for(std::size_t i = 0; i < datasources.size(); ++i)
109 if(datasource.get() == 0)
112 const std::string& title = datasource->getTitle();
114 m_ui->m_outputDataSourceComboBox->addItem(title.c_str(), QVariant::fromValue(datasource));
120 QMessageBox::information(
this,
"Help",
"Under development");
125 int idxLayer = m_ui->m_inputLayerComboBox->currentIndex();
129 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Input layer not selected."));
133 QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(idxLayer, Qt::UserRole);
138 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error getting selected layer."));
142 int idxDataSource = m_ui->m_outputDataSourceComboBox->currentIndex();
146 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Output data source not selected."));
150 QVariant varDataSource = m_ui->m_outputDataSourceComboBox->itemData(idxDataSource, Qt::UserRole);
155 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Error getting selected data source."));
159 if(m_ui->m_dataSetLineEdit->text().isEmpty())
161 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Data Set name not defined."));
168 std::auto_ptr<te::da::DataSetType> dsType = layer->getSchema();
172 if(dsType->size() == 0)
181 dsTypeResult->
setName(m_ui->m_dataSetLineEdit->text().toStdString());
184 std::map<std::string,std::string> nopt;
186 std::auto_ptr<te::da::DataSet> dataset = layer->getData();
188 targetDSPtr->createDataSet(dsTypeResult, nopt);
192 if(dataset->moveBeforeFirst())
193 targetDSPtr->add(dsTypeResult->getName(), dsAdapter.get(), targetDSPtr->getConnectionInfo());
195 QMessageBox::information(
this, tr(
"Exchanger"), tr(
"Layer exported successfully."));
197 catch(
const std::exception& e)
199 QString errMsg(tr(
"Error during exchanger. The reported error is: %1"));
201 errMsg = errMsg.arg(e.what());
203 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
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.
const std::string & getDataSourceId() const
A exchanger dialog from SHP to ADO operation.
A layer with reference to a dataset.
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr