27 #include "../../../dataaccess/dataset/DataSet.h"
28 #include "../../../dataaccess/dataset/DataSetType.h"
29 #include "../../../dataaccess/dataset/ObjectIdSet.h"
30 #include "../../../dataaccess/datasource/DataSourceCapabilities.h"
31 #include "../../../dataaccess/query/FunctionNames.h"
32 #include "../../../dataaccess/query/QueryCapabilities.h"
33 #include "../../../dataaccess/utils/Utils.h"
34 #include "../../../maptools/DataSetLayer.h"
35 #include "../utils/ColorPickerToolButton.h"
38 #include "ui_QueryDialogForm.h"
41 #include <QtGui/QGridLayout>
42 #include <QtGui/QMessageBox>
52 m_ui(new Ui::QueryDialogForm)
57 QGridLayout* layout =
new QGridLayout(
m_ui->m_widget);
60 layout->setContentsMargins(0, 0, 0, 0);
68 QGridLayout* colorPickerLayout =
new QGridLayout(
m_ui->m_colorPickerFrame);
69 colorPickerLayout->setContentsMargins(0, 0, 0, 0);
77 m_ui->m_helpPushButton->setPageReference(
"widgets/query/query_dialog.html");
86 return m_whereClauseWidget.get();
91 m_whereClauseWidget->setLayerList(layerList);
93 m_ui->m_inputLayerComboBox->clear();
95 std::list<te::map::AbstractLayerPtr>::iterator it = layerList.begin();
97 while(it != layerList.end())
104 m_ui->m_inputLayerComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
109 if(m_ui->m_inputLayerComboBox->count() > 0)
111 QString s = m_ui->m_inputLayerComboBox->currentText();
113 onInputLayerActivated(s);
119 for(
int i = 0; i < m_ui->m_inputLayerComboBox->count(); ++i)
121 QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(i, Qt::UserRole);
126 m_ui->m_inputLayerComboBox->setCurrentIndex(i);
131 if(m_ui->m_inputLayerComboBox->count() > 0)
133 QString s = m_ui->m_inputLayerComboBox->currentText();
135 onInputLayerActivated(s);
141 return m_whereClauseWidget->getWhere();
146 m_whereClauseWidget->clear();
149 int idxLayer = m_ui->m_inputLayerComboBox->currentIndex();
151 QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(idxLayer, Qt::UserRole);
162 if(!dsPtr->isOpened())
165 m_whereClauseWidget->setDataSource(dsPtr);
168 std::vector<std::string> vecOperators;
169 std::vector<std::string> vecSpatialOperators;
170 std::vector<std::string> vecConnectors;
175 std::set<std::string>::iterator it;
180 vecOperators.push_back(*it);
187 vecOperators.push_back(*it);
191 m_whereClauseWidget->setOperatorsList(vecOperators);
196 vecSpatialOperators.push_back(*it);
203 vecSpatialOperators.clear();
214 m_whereClauseWidget->setSpatialOperatorsList(vecSpatialOperators);
219 vecConnectors.push_back(*it);
223 m_whereClauseWidget->setConnectorsList(vecConnectors);
226 std::auto_ptr<te::da::DataSetType> dsType = dsLayer->getSchema();
228 std::string dsName = dsType->getName();
229 std::string aliasName = dsName;
231 std::vector<std::pair<std::string, std::string> > list;
232 list.push_back(std::pair<std::string, std::string>(dsName, aliasName));
234 m_whereClauseWidget->setFromItems(list);
237 std::vector<std::string> inputProperties;
238 std::vector<std::string> geomProperties;
240 for(
size_t i = 0; i < dsType->size(); ++i)
242 std::string propName = dsType->getProperty(i)->getName();
245 geomProperties.push_back(propName);
247 inputProperties.push_back(propName);
250 m_whereClauseWidget->setAttributeList(inputProperties);
251 m_whereClauseWidget->setGeomAttributeList(geomProperties, dsLayer->getSRID());
258 if(wh == 0 || wh->
getExp() == 0)
260 QMessageBox::information(
this, tr(
"Query"), tr(
"Add a restriction expression first."));
265 int index = m_ui->m_inputLayerComboBox->currentIndex();
267 QVariant varLayer = m_ui->m_inputLayerComboBox->itemData(index, Qt::UserRole);
276 setCursor(Qt::WaitCursor);
282 std::auto_ptr<const te::map::LayerSchema> schema(layer->getSchema());
285 std::auto_ptr<te::da::DataSet> dataset = layer->getData(e);
286 assert(dataset.get());
288 if(m_ui->m_newSelRadioButton->isChecked())
291 dataset->moveBeforeFirst();
294 layer->clearSelected();
297 emit layerSelectedObjectsChanged(layer);
299 else if(m_ui->m_addSelRadioButton->isChecked())
302 dataset->moveBeforeFirst();
307 emit layerSelectedObjectsChanged(layer);
310 emit highlightLayerObjects(layer, dataset.get(), m_colorPicker->getColor());
312 setCursor(Qt::ArrowCursor);
316 catch(std::exception& e)
318 setCursor(Qt::ArrowCursor);
319 QMessageBox::information(
this, tr(
"Query"), e.what());
static const std::string sm_ST_Contains
static const std::string sm_ST_Intersects
static const std::string sm_ST_Disjoint
A layer with reference to a dataset.
TEDATAACCESSEXPORT ObjectIdSet * GenerateOIDSet(DataSet *dataset, const DataSetType *type)
This file defines a class for a Query Dialog Dialog.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
ColorPickerToolButton * m_colorPicker
te::da::Where * getWhere()
static const std::string sm_ST_Crosses
static const std::string sm_ST_Equals
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
void onApplyPushButtonClicked()
void setList(std::list< te::map::AbstractLayerPtr > &layerList)
This method is used to set the list of layers.
void setCurrentLayer(te::map::AbstractLayerPtr layer)
const QueryCapabilities & getQueryCapabilities() const
virtual Expression * clone() const =0
It creates a new copy of this expression.
const std::set< std::string > & getLogicalOperators() const
static const std::string sm_ST_Overlaps
const std::string & getDataSourceId() const
void setColor(const QColor &color)
std::auto_ptr< Ui::QueryDialogForm > m_ui
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
const std::set< std::string > & getSpatialTopologicOperators() const
This file has the DataSetWidget class.
This class is used to define the WHERE object of select operation.
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
QueryDialog(QWidget *parent=0, Qt::WindowFlags f=0)
A class that informs the query support of a given data source.
static const std::string sm_ST_Touches
boost::shared_ptr< DataSource > DataSourcePtr
const std::set< std::string > & getArithmeticOperators() const
void onInputLayerActivated(QString value)
Expression * getExp() const
This is an abstract class that models a query expression.
Custom tool button used to pick a color.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
te::qt::widgets::WhereClauseWidget * getWidget()
A class that can be used to model a filter expression that can be applied to a query.
static const std::string sm_ST_EnvelopeIntersects
std::auto_ptr< te::qt::widgets::WhereClauseWidget > m_whereClauseWidget
static const std::string sm_ST_Within
const std::set< std::string > & getComparsionOperators() const