27 #include "../../../dataaccess/dataset/DataSetType.h"
28 #include "../../../dataaccess/dataset/DataSetTypeConverter.h"
29 #include "../../../dataaccess/dataset/Index.h"
30 #include "../../../dataaccess/dataset/PrimaryKey.h"
31 #include "../../../dataaccess/dataset/UniqueKey.h"
32 #include "../../../dataaccess/datasource/DataSourceTransactor.h"
33 #include "../../../dataaccess/datasource/DataSourceManager.h"
34 #include "../../../dataaccess/utils/Utils.h"
35 #include "../../../geometry/GeometryProperty.h"
36 #include "../../../qt/widgets/utils/ScopedCursor.h"
37 #include "../../../qt/widgets/srs/SRSManagerDialog.h"
41 #include "ui_DataSetOptionsWizardPageForm.h"
47 #include <boost/lexical_cast.hpp>
50 #include <QtGui/QIcon>
51 #include <QtGui/QMessageBox>
54 : QWizardPage(parent),
55 m_ui(new Ui::DataSetOptionsWizardPageForm)
62 QGridLayout* constraintLayout =
new QGridLayout(
m_ui->m_constraintWidget);
64 constraintLayout->setContentsMargins(0,0,0,0);
67 QGridLayout* dataSetLayout =
new QGridLayout(
m_ui->m_dataSetWidget);
69 dataSetLayout->setContentsMargins(0,0,0,0);
74 connect(
m_ui->m_selectedDatasetListWidget, SIGNAL(itemPressed(QListWidgetItem*)),
this, SLOT(
datasetPressed(QListWidgetItem*)));
90 m_ui->m_selectedDatasetListWidget->clear();
96 m_datasource = datasource;
98 m_targetDatasource = targetDatasource;
102 for(std::list<te::da::DataSetTypePtr>::const_iterator it = datasets.begin(); it != datasets.end(); ++it)
107 if((*it)->size() == 0)
113 m_datasets.insert(std::map<te::da::DataSetTypePtr, te::da::DataSetTypeConverter*>::value_type((*it), converter));
116 for(std::list<te::da::DataSetTypePtr>::const_iterator it = datasets.begin(); it != datasets.end(); ++it)
118 QString title = QString::fromStdString((*it)->getTitle());
120 QString name = QString::fromStdString((*it)->getName());
125 QListWidgetItem* item =
new QListWidgetItem(title);
127 m_ui->m_selectedDatasetListWidget->addItem(item);
129 if(datasets.size() == 1)
131 item->setSelected(
true);
132 datasetPressed(item);
136 if(datasets.size() != 1)
137 setControlsEnabled(
false);
147 m_ui->m_dataSetWidget->setVisible(!mode);
148 m_ui->m_constraintWidget->setVisible(!mode);
153 QListWidgetItem* item = m_ui->m_selectedDatasetListWidget->currentItem();
158 std::string dataSetAdapterName = item->text().toStdString();
160 std::map<te::da::DataSetTypePtr, te::da::DataSetTypeConverter*>::iterator it = m_datasets.begin();
162 while(it != m_datasets.end())
164 if(it->second->getConvertee()->getName() == dataSetAdapterName)
166 it->second->getResult()->setName(m_ui->m_datasetNameLineEdit->text().trimmed().toStdString());
167 it->second->getResult()->setTitle(m_ui->m_datasetTitleLineEdit->text().trimmed().toStdString());
169 if(it->second->getResult()->hasGeom())
174 geomProp->
setSRID(boost::lexical_cast<int>(m_ui->m_sridLineEdit->text().trimmed().toStdString()));
186 srsDialog.setWindowTitle(tr(
"Choose the SRS"));
188 if(srsDialog.exec() != QDialog::Rejected)
191 m_ui->m_sridLineEdit->setText(QString::number(srid.first));
200 std::string dataSetAdapterName = item->text().toStdString();
202 std::map<te::da::DataSetTypePtr, te::da::DataSetTypeConverter*>::iterator it = m_datasets.begin();
204 while(it != m_datasets.end())
206 if(it->second->getConvertee()->getName() == dataSetAdapterName)
211 m_ui->m_datasetNameLineEdit->setEnabled(
true);
212 m_ui->m_datasetNameLineEdit->setText(QString::fromStdString(dataset->
getName()));
214 m_ui->m_datasetTitleLineEdit->setEnabled(
true);
215 m_ui->m_datasetTitleLineEdit->setText(QString::fromStdString(dataset->
getTitle()));
219 m_ui->m_sridSearchToolButton->setEnabled(
true);
220 m_ui->m_sridLineEdit->setEnabled(
true);
225 m_ui->m_sridLineEdit->setText(QString::fromStdString(boost::lexical_cast<std::string>(geomProp->
getSRID())));
229 m_ui->m_sridSearchToolButton->setEnabled(
false);
230 m_ui->m_sridLineEdit->setEnabled(
false);
234 m_dataSetAdapterWidget->setAdapterParameters(it->second->getConvertee(), it->second, m_targetDatasource);
237 m_constraintWidget->setDataSetType(dataset);
300 QListWidgetItem* item = m_ui->m_selectedDatasetListWidget->currentItem();
305 std::string dataSetAdapterName = item->text().toStdString();
307 std::map<te::da::DataSetTypePtr, te::da::DataSetTypeConverter*>::const_iterator it = m_datasets.begin();
309 while(it != m_datasets.end())
311 if(it->second->getConvertee()->getName() == dataSetAdapterName)
323 m_ui->m_datasetNameLineEdit->clear();
324 m_ui->m_datasetTitleLineEdit->clear();
325 m_ui->m_sridLineEdit->clear();
330 m_ui->m_datasetNameLineEdit->setEnabled(enabled);
331 m_ui->m_datasetTitleLineEdit->setEnabled(enabled);
332 m_ui->m_sridLineEdit->setEnabled(enabled);
333 m_ui->m_sridSearchToolButton->setEnabled(enabled);
338 m_name = name.toStdString();
343 return dataset->getName() == m_name;
std::auto_ptr< te::qt::widgets::DataSetAdapterWidget > m_dataSetAdapterWidget
~DataSetOptionsWizardPage()
A dialog for creating a data set adapter.
bool operator()(const te::da::DataSetTypePtr &dataset) const
const std::string & getTitle() const
A human descriptive title for the DataSetType.
std::auto_ptr< te::qt::widgets::ConstraintsIndexesListWidget > m_constraintWidget
This class is used to list the constraints and indexes of a datasetype.
void setControlsEnabled(bool enabled)
void sridSearchToolButtonPressed()
void showSimpleMode(const bool &mode)
An converter for DataSetType.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
void set(const std::list< te::da::DataSetTypePtr > &datasets, const te::da::DataSourceInfoPtr &datasource, const te::da::DataSourceInfoPtr &targetDatasource)
const std::string & getName() const
It returns the property name.
FindByName(const QString &name)
A dialog used to build a SRSManagerDialog element.
DataSetOptionsWizardPage(QWidget *parent=0)
bool hasGeom() const
It returns true if the DataSetType has at least one geometry property; otherwise, it returns false...
boost::shared_ptr< DataSource > DataSourcePtr
Property * findFirstPropertyOfType(const int t) const
returns the first property of the given data type. Caller doesn't take ownership of the returned poin...
const std::pair< int, std::string > & getSelectedSRS() const
Returns the selected SRS in the window.
std::auto_ptr< Ui::DataSetOptionsWizardPageForm > m_ui
This file has the ConstraintsIndexesListWidget class.
A class that models the description of a dataset.
void datasetPressed(QListWidgetItem *item)
boost::shared_ptr< DataSetType > DataSetTypePtr
A class used to define the DataSetAdapterWidget class.
TEDATAACCESSEXPORT void LoadProperties(te::da::DataSetType *dataset, const std::string &datasourceId)
te::da::DataSetTypePtr getSelectedDataSet() const
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
const std::map< te::da::DataSetTypePtr, te::da::DataSetTypeConverter * > & getDatasets() const
An object that when created shows a cursor during its scope.