26 #include "../../../../dataaccess/datasource/DataSource.h" 27 #include "../../../../dataaccess/datasource/DataSourceFactory.h" 28 #include "../../../../dataaccess/datasource/DataSourceInfo.h" 29 #include "../../../../dataaccess/datasource/DataSourceInfoManager.h" 30 #include "../../../../dataaccess/utils/Utils.h" 31 #include "../core/GeopackageSynchronizer.h" 33 #include "ui_GeoPackageSynchronizerDialogForm.h" 36 #include <QFileDialog> 37 #include <QMessageBox> 43 m_ui(new
Ui::GeoPackageSynchronizerDialogForm)
62 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Open GeoPackage File"),
"", tr(
"GeoPackage File (*.gpkg *.GPKG)"));
64 if (fileName.isEmpty())
69 m_ui->m_geopackageLineEdit->setText(fileName);
72 std::map<std::string, std::string> connInfo;
73 connInfo[
"URI"] = fileName.toUtf8().data();
76 dsGPKG->setConnectionInfo(connInfo);
79 std::vector<std::string> dsNames = dsGPKG->getDataSetNames();
81 m_ui->m_gatheringComboBox->clear();
83 for (std::size_t t = 0; t < dsNames.size(); ++t)
85 std::string connInfo =
"";
86 std::string sql =
"SELECT datasource_uri FROM tm_layer_settings WHERE layer_name = '" + dsNames[t] +
"';";
87 std::auto_ptr<te::da::DataSet> dataSetQuery = dsGPKG->query(sql);
89 if (!dataSetQuery->isEmpty())
91 dataSetQuery->moveFirst();
92 connInfo = dataSetQuery->getAsString(0);
95 m_ui->m_gatheringComboBox->addItem(dsNames[t].c_str(), QVariant(connInfo.c_str()));
101 std::string connInfo =
m_ui->m_gatheringComboBox->itemData(index).toString().toUtf8().data();
103 for (
int i = 0; i <
m_ui->m_layerComboBox->count(); ++i)
105 QVariant varLayer =
m_ui->m_layerComboBox->itemData(i, Qt::UserRole);
108 std::string dsId = l->getDataSourceId();
111 std::string dsConnInfo = dsInfoPtr->getConnInfoAsString();
113 if (dsConnInfo == connInfo)
115 m_ui->m_layerComboBox->setCurrentIndex(i);
124 std::map<std::string, std::string> connInfo;
125 connInfo[
"URI"] =
m_ui->m_geopackageLineEdit->text().toUtf8().data();
128 dsGPKG->setConnectionInfo(connInfo);
132 std::string inputDs =
m_ui->m_gatheringComboBox->currentText().toUtf8().data();
135 QVariant varLayer =
m_ui->m_layerComboBox->currentData(Qt::UserRole);
138 std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
140 std::string outputDataSet = dsType->getTitle();
152 catch (
const std::exception& e)
154 QMessageBox::warning(
this, tr(
"Warning"), e.what());
160 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Internal Error."));
165 QMessageBox::information(
this, tr(
"Information"), tr(
"Synchronizer Done."));
170 m_ui->m_layerComboBox->clear();
172 std::list<te::map::AbstractLayerPtr>::iterator it = list.begin();
174 while (it != list.end())
178 std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
180 if (dsType->hasGeom())
181 m_ui->m_layerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
This file is used to Synchronizer operation.
boost::shared_ptr< DataSource > DataSourcePtr
void setInputParameters(te::da::DataSource *inputDataSource, std::string inputDataSet, te::da::DataSource *outputDataSource, std::string outputDataset)
void onSynchronizePushButtonClicked()
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
void setLayerList(std::list< te::map::AbstractLayerPtr > list)
void onGeopackageToolButtonClicked()
~GeoPackageSynchronizerDialog()
std::auto_ptr< Ui::GeoPackageSynchronizerDialogForm > m_ui
GeoPackageSynchronizerDialog(QWidget *parent=0, Qt::WindowFlags f=0)
void onGatheringComboBoxActivated(int index)
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr