22 #include "../../../core/uri/URI.h" 23 #include "../../../dataaccess/dataset/DataSet.h" 24 #include "../../../dataaccess/datasource/DataSourceManager.h" 25 #include "../../../dataaccess/datasource/DataSourceTransactor.h" 26 #include "../../../dataaccess/query/DataSetName.h" 27 #include "../../../dataaccess/query/Field.h" 28 #include "../../../dataaccess/query/From.h" 29 #include "../../../dataaccess/query/OrderBy.h" 30 #include "../../../dataaccess/query/OrderByItem.h" 31 #include "../../../dataaccess/query/Select.h" 32 #include "../../../dataaccess/utils/Utils.h" 33 #include "../../../maptools/DataSetLayer.h" 34 #include "../../../maptools/DataSetAdapterLayer.h" 35 #include "../../../maptools/QueryLayer.h" 40 #include <QtGui/QMouseEvent> 45 #include <QMessageBox> 73 setDropIndicatorShown(
true);
77 setAcceptDrops(
false);
78 setDropIndicatorShown(
false);
99 if(e->button() == Qt::LeftButton)
103 int c =
m_view->columnAt(e->pos().x());
105 QItemSelectionModel* sel =
m_view->selectionModel();
107 QItemSelectionModel::SelectionFlag selF = (sel->isColumnSelected(c, QModelIndex())) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
109 if(
m_view->selectionMode() == QAbstractItemView::SingleSelection)
113 QModelIndex tl =
m_view->model()->index(0, c);
114 QModelIndex
br =
m_view->model()->index(model()->rowCount()-1, c);
116 QItemSelection newSel(tl, br);
118 sel->select(newSel, selF);
123 QPainter painter(&p);
124 QRect r = painter.boundingRect(p.rect(), Qt::AlignCenter,
"Link Table");
125 r = QRect(0, 0, r.width(), r.height());
126 QPoint hotSpot(r.center());
127 QPixmap pixmap(r.size());
129 painter.begin(&pixmap);
130 painter.setPen(QPen(Qt::blue));
131 painter.drawText(r,
"Link Table");
134 QMimeData *mimeData =
new QMimeData;
135 mimeData->setText(
"TerraView: Link Table");
140 std::string sid(ds->getId());
141 mimeData->setData(
"DataSourceId", sid.c_str());
142 std::string stype(ds->getType());
143 mimeData->setData(
"DataSourceType", stype.c_str());
146 connInfo.setNum((
unsigned long long)&
m_connInfo);
147 mimeData->setData(
"DataSourceConnInfo", connInfo.toUtf8().data());
149 mimeData->setData(
"LayerName", lname.c_str());
151 mimeData->setData(
"LayerTitle", ltytle.c_str());
153 mimeData->setData(
"LayerId", lid.c_str());
155 mimeData->setData(
"LayerType", ltype.c_str());
158 size_t col = logicalIndexAt(e->pos());
161 mimeData->setData(
"FieldNumber", s.toUtf8().data());
164 mimeData->setData(
"FieldName", colName.c_str());
168 mimeData->setData(
"FieldType", s.toUtf8().data());
171 drag.setMimeData(mimeData);
172 drag.setPixmap(pixmap);
173 drag.setHotSpot(hotSpot);
175 drag.exec(Qt::LinkAction);
190 QHeaderView::mousePressEvent(e);
198 const QMimeData* mdata = e->mimeData();
199 if(mdata->text() ==
"TerraView: Link Table")
200 e->setAccepted(
true);
202 e->setAccepted(
false);
210 const QMimeData* mdata = e->mimeData();
211 if(mdata->text() ==
"TerraView: Link Table")
212 e->setAccepted(
true);
214 e->setAccepted(
false);
222 const QMimeData* mdata = e->mimeData();
223 std::string text = mdata->text().toUtf8().data();
224 if(text ==
"TerraView: Link Table")
226 e->setDropAction(Qt::LinkAction);
239 if(mdata->data(
"DataSourceId").isNull() ==
false)
243 QString connInfo(mdata->data(
"DataSourceConnInfo").data());
252 QMessageBox::warning(
this,
"Link Error",
"The data are from different sources");
258 QMessageBox::warning(
this,
"Link Error",
"The data are from the same layer");
264 QString fromFieldNumber(mdata->data(
"FieldNumber").data());
267 QString fromFieldType(mdata->data(
"FieldType").data());
274 QMessageBox::warning(
this,
"Link Error",
"Field types do not match");
279 if(mdata->data(
"DataSourceId").isNull() ==
false &&
m_layer)
291 if(layer->
getType() ==
"DATASETLAYER")
298 else if(layer->
getType() ==
"DATASETADAPTERLAYER")
305 else if(layer->
getType() ==
"QUERYLAYER")
virtual const std::string & getId() const
It returns the layer id.
This is the base class for layers.
boost::shared_ptr< DataSource > DataSourcePtr
virtual const std::string & getTitle() const
It returns the layer title.
virtual const std::string & getType() const =0
It returns the layer type.
A layer resulting from a query.
static te::dt::Date ds(2010, 01, 01)
A layer with reference to a DataSetTypeConverter.
A table view for a dataset.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
A dataset is the unit of information manipulated by the data access module of TerraLib.
A layer with reference to a dataset.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
virtual const std::string & getDataSourceId() const