DataSetTableView.cpp
Go to the documentation of this file.
1 #include "AddColumnDialog.h"
2 #include "DataSetTableModel.h"
5 #include "DataSetTableView.h"
6 #include "HighlightDelegate.h"
7 #include "Promoter.h"
8 #include "RenameColumnDialog.h"
9 #include "RetypeColumnDialog.h"
10 #include "AlterDataDialog.h"
11 
12 // TerraLib include files
13 #include "../charts/HistogramDataWidget.h"
14 #include "../charts/Utils.h"
15 #include "../utils/ScopedCursor.h"
16 #include "../Config.h"
17 #include "../Exception.h"
18 #include "../../../common/Exception.h"
19 #ifndef Q_MOC_RUN
20 #include "../../../core/logger/Logger.h"
21 #include "../../../dataaccess/dataset/DataSet.h"
22 #include "../../../dataaccess/dataset/DataSetCapabilities.h"
23 #include "../../../dataaccess/dataset/ObjectId.h"
24 #include "../../../dataaccess/dataset/ObjectIdSet.h"
25 #include "../../../dataaccess/dataset/DataSetTypeCapabilities.h"
26 #include "../../../dataaccess/datasource/DataSourceCapabilities.h"
27 #include "../../../dataaccess/datasource/DataSourceManager.h"
28 #include "../../../dataaccess/datasource/DataSourceTransactor.h"
29 #include "../../../dataaccess/query/DataSetName.h"
30 #include "../../../dataaccess/query/Field.h"
31 #include "../../../dataaccess/query/From.h"
32 #include "../../../dataaccess/query/In.h"
33 #include "../../../dataaccess/query/Literal.h"
34 #include "../../../dataaccess/query/Or.h"
35 #include "../../../dataaccess/query/OrderBy.h"
36 #include "../../../dataaccess/query/OrderByItem.h"
37 #include "../../../dataaccess/query/Select.h"
38 #include "../../../dataaccess/utils/Utils.h"
39 #include "../../../geometry/Geometry.h"
40 #include "../../../maptools/DataSetLayer.h"
41 #include "../../../maptools/DataSetAdapterLayer.h"
42 #include "../../../maptools/QueryLayer.h"
43 #include "../../../statistics/qt/StatisticsDialog.h"
44 #include "../../../st/maptools/ObservationDataSetLayer.h"
45 #include "../../../st/maptools/TimeSeriesDataSetLayer.h"
46 #include "../../../st/maptools/TrajectoryDataSetLayer.h"
47 #endif
48 
49 // Qt
50 #include <QBoxLayout>
51 #include <QContextMenuEvent>
52 #include <QCursor>
53 #include <QDialogButtonBox>
54 #include <QHeaderView>
55 #include <QLabel>
56 #include <QMenu>
57 #include <QMessageBox>
58 #include <QPainter>
59 #include <QSpinBox>
60 
61 
62 // STL
63 #include <string>
64 #include <memory>
65 #include <vector>
66 
67 
68 
69 bool IsGeometryColumn(te::da::DataSet* dset, const size_t& col)
70 {
71  return dset->getPropertyDataType(col) == te::dt::GEOMETRY_TYPE;
72 }
73 
74 void GetGeometryColumnsPositions(te::da::DataSet* dset, std::vector<int>& cols)
75 {
76  size_t nProps = dset->getNumProperties();
77 
78  cols.clear();
79 
80  for(size_t i=0; i<nProps; i++)
81  if(IsGeometryColumn(dset, i))
82  cols.push_back(static_cast<int>(i));
83 }
84 
85 std::vector<int> GetHiddenSections(QHeaderView* hView, te::da::DataSet* dset)
86 {
87  std::vector<int> res;
88 
89  std::size_t sz = dset->getNumProperties();
90 
91  if(sz > 0)
92  {
93  for (int i=0; i<static_cast<int>(sz); i++)
94  if(hView->isSectionHidden(i) && !IsGeometryColumn(dset, static_cast<size_t>(i)))
95  res.push_back(i);
96  }
97 
98  return res;
99 }
100 
101 QMenu* GetHiddenColumnsMenu(QHeaderView* hView, te::da::DataSet* dset, QMenu* hMnu)
102 {
103  std::vector<int> hSecs = GetHiddenSections(hView, dset);
104  std::vector<int>::iterator it;
105 
106  QMenu* mnu = new QMenu(hMnu);
107  mnu->setTitle(QObject::tr("Show hidden column"));
108 
109  if(hSecs.empty())
110  mnu->setEnabled(false);
111  else
112  for(it=hSecs.begin(); it!=hSecs.end(); ++it)
113  {
114  QString cName = hView->model()->headerData(*it, Qt::Horizontal, Qt::DisplayRole).toString();
115  QAction* act = new QAction(mnu);
116 
117  act->setText(cName);
118  act->setData(QVariant(*it));
119 
120  QString tt = QObject::tr("Turns column \"%1\" visible.").arg(cName);
121 
122  act->setToolTip(tt);
123 
124  mnu->addAction(act);
125  }
126 
127  return mnu;
128 }
129 
130 QAction* GetShowAllMenu(QHeaderView* hView, te::da::DataSet* dset, QMenu* hMnu)
131 {
132  QAction* act = new QAction(hMnu);
133  act->setText(QObject::tr("Show all columns"));
134  act->setEnabled(!GetHiddenSections(hView, dset).empty());
135 
136  return act;
137 }
138 
140 {
141  // Getting data source, if it is available
143 
144  if(layer->getType() == "DATASETLAYER")
145  {
146  const te::map::DataSetLayer* l = dynamic_cast<const te::map::DataSetLayer*>(layer);
147 
148  if(l != nullptr)
150  }
151  else if(layer->getType() == "DATASETADAPTERLAYER")
152  {
153  const te::map::DataSetAdapterLayer* l = dynamic_cast<const te::map::DataSetAdapterLayer*>(layer);
154 
155  if(l != nullptr)
157  }
158  else if(layer->getType() == "QUERYLAYER")
159  {
160  const te::map::QueryLayer* l = dynamic_cast<const te::map::QueryLayer*>(layer);
161 
162  if(l != nullptr)
164  }
165  else if(layer->getType() == "OBSERVATIONDATASETLAYER")
166  {
167  const te::st::ObservationDataSetLayer* l = dynamic_cast<const te::st::ObservationDataSetLayer*>(layer);
168 
169  if(l != nullptr)
171  }
172  else if(layer->getType() == "TIMESERIESDATASETLAYER")
173  {
174  const te::st::TimeSeriesDataSetLayer* l = dynamic_cast<const te::st::TimeSeriesDataSetLayer*>(layer);
175 
176  if(l != nullptr)
178  }
179  else if(layer->getType() == "TRAJECTORYDATASETLAYER")
180  {
181  const te::st::TrajectoryDataSetLayer* l = dynamic_cast<const te::st::TrajectoryDataSetLayer*>(layer);
182 
183  if(l != nullptr)
185  }
186  return ds;
187 }
188 
190 {
191  // Getting data source capabilities, if it is available
193 
194  if(ds.get() != nullptr)
195  {
196  const te::map::DataSetLayer* dl = dynamic_cast<const te::map::DataSetLayer*>(layer);
197 
198  if(dl != nullptr)
199  return ds->getCapabilities(dl->getDataSetName()).release();
200  }
201 
202  return nullptr;
203 }
204 
205 std::unique_ptr<te::da::Select> GetSelectExpression(const std::string& datasetName, const std::vector<std::string>& colsNames, const bool& asc)
206 {
207  te::da::Fields fields;
208 
209  fields.push_back(new te::da::Field("*"));
210 
211  te::da::From from;
212 
213  from.push_back(new te::da::DataSetName(datasetName));
214 
215  te::da::OrderBy order_by;
216 
217  for(size_t i=0; i<colsNames.size(); i++)
218  order_by.push_back(new te::da::OrderByItem(colsNames[i], (asc) ? te::da::ASC : te::da::DESC));
219 
220  if (!order_by.empty())
221  return std::unique_ptr<te::da::Select>(new te::da::Select(fields, from, order_by));
222  else
223  return std::unique_ptr<te::da::Select>(new te::da::Select(fields, from));
224 }
225 
226 std::unique_ptr<te::da::Select> GetSelectExpression(const std::string& tableName, const te::da::DataSet* set, const std::vector<int>& cols, const bool& asc)
227 {
228  std::vector<std::string> colsNames;
229 
230  for(size_t i = 0; i < cols.size(); ++i)
231  colsNames.push_back(set->getPropertyName((size_t)cols[i]));
232 
233  return GetSelectExpression(tableName, colsNames, asc);
234 }
235 
236 std::unique_ptr<te::da::DataSet> GetDataSet(const te::map::AbstractLayer* layer, const te::da::DataSet* set, const std::vector<int>& cols, const bool& asc)
237 {
238  std::unique_ptr<te::da::Select> query = GetSelectExpression(layer->getSchema()->getName(), set, cols, asc);
239 
240  try
241  {
242  if(query.get() == nullptr)
243  throw std::string("Fail to generate query.");
244 
246 
247  if(dsc.get() == nullptr)
248  throw std::string("Fail to get data source.");
249 
250  dsc->setEncoding(layer->getEncoding());
251 
252  return dsc->getTransactor()->query(query.get(), te::common::RANDOM);
253  }
254  catch(...)
255  {
256  return std::unique_ptr<te::da::DataSet>();
257  }
258 }
259 
260 std::unique_ptr<te::da::Select> GetDataSetQuery(const te::map::AbstractLayer* layer, const std::vector<std::string>& colsNames, const bool& asc)
261 {
262  std::unique_ptr<te::da::Select> query;
263 
264  if(layer->getType() == "DATASETLAYER")
265  {
266  const te::map::DataSetLayer* l = dynamic_cast<const te::map::DataSetLayer*>(layer);
267 
268  if(l != nullptr)
269  query = GetSelectExpression(layer->getSchema()->getName(), colsNames, asc);
270  }
271  else if(layer->getType() == "DATASETADAPTERLAYER")
272  {
273  const te::map::DataSetAdapterLayer* l = dynamic_cast<const te::map::DataSetAdapterLayer*>(layer);
274 
275  if(l != nullptr)
276  query = GetSelectExpression(layer->getSchema()->getName(), colsNames, asc);
277  }
278  else if(layer->getType() == "QUERYLAYER")
279  {
280  const te::map::QueryLayer* l = dynamic_cast<const te::map::QueryLayer*>(layer);
281 
282  if (l != nullptr)
283  {
284  query.reset(new te::da::Select(l->getQuery()));
285  te::da::OrderBy* order_by = new te::da::OrderBy();
286 
287  for (size_t i = 0; i<colsNames.size(); i++)
288  order_by->push_back(new te::da::OrderByItem(colsNames[i], (asc) ? te::da::ASC : te::da::DESC));
289 
290  query->setOrderBy(order_by);
291  }
292  }
293  else if(layer->getType() == "OBSERVATIONDATASETLAYER")
294  {
295  const te::st::ObservationDataSetLayer* l = dynamic_cast<const te::st::ObservationDataSetLayer*>(layer);
296 
297  if(l != nullptr)
298  query = GetSelectExpression(layer->getSchema()->getName(), colsNames, asc);
299  }
300  else if(layer->getType() == "TIMESERIESDATASETLAYER")
301  {
302  const te::st::TimeSeriesDataSetLayer* l = dynamic_cast<const te::st::TimeSeriesDataSetLayer*>(layer);
303 
304  if(l != nullptr)
305  query = GetSelectExpression(layer->getSchema()->getName(), colsNames, asc);
306  }
307  else if(layer->getType() == "TRAJECTORYDATASETLAYER")
308  {
309  const te::st::TrajectoryDataSetLayer* l = dynamic_cast<const te::st::TrajectoryDataSetLayer*>(layer);
310 
311  if(l != nullptr)
312  query = GetSelectExpression(layer->getSchema()->getName(), colsNames, asc);
313  }
314 
315  try
316  {
317  if(query.get() == nullptr)
318  throw std::string("Fail to generate query.");
319 
320  return query;
321  }
322  catch(...)
323  {
324  return std::unique_ptr<te::da::Select>();
325  }
326 }
327 
328 std::vector<QString> GetColumnsNames(te::da::DataSet* dset)
329 {
330  std::vector<QString> res;
331 
332  if(dset != nullptr)
333  {
334  size_t n = dset->getNumProperties();
335 
336  for(size_t i=0; i<n; i++)
337  if(!IsGeometryColumn(dset, i))
338  res.push_back(dset->getPropertyName(i).c_str());
339  }
340 
341  return res;
342 }
343 
344 std::unique_ptr<te::gm::Envelope> GetExtent(te::da::DataSet* dset, te::qt::widgets::Promoter* p, const int& rowPosition)
345 {
346  // Getting last select object bounding rectangle
347  std::vector<int> geoCols;
348 
349  GetGeometryColumnsPositions(dset, geoCols);
350 
351  if(!geoCols.empty())
352  {
353  std::size_t rpos = p->getLogicalRow(rowPosition);
354 
355  dset->move(rpos);
356 
357  size_t pos = (size_t)geoCols[0];
358 
359  if(dset->isNull(pos))
360  return std::unique_ptr<te::gm::Envelope>();
361 
362  std::unique_ptr<te::gm::Geometry> g = dset->getGeometry(pos);
363 
364  return std::unique_ptr<te::gm::Envelope> (new te::gm::Envelope(*g->getMBR()));
365  }
366 
367  return std::unique_ptr<te::gm::Envelope>();
368 }
369 
371 {
372  te::qt::widgets::HighlightDelegate* d = dynamic_cast<te::qt::widgets::HighlightDelegate*>(view->itemDelegate());
373 
374  if(d == nullptr)
375  return false;
376 
377  const te::da::ObjectIdSet* objs = d->getSelected();
378 
379  if(objs == nullptr)
380  return false;
381 
382  std::vector<size_t> cols = objs->getPropertyPos();
383  std::vector<size_t>::iterator it;
384 
385  for(it = cols.begin(); it != cols.end(); ++it)
386  if((size_t)col == *it)
387  return true;
388 
389  return false;
390 }
391 
393 {
394  if(dset != nullptr)
395  {
396  std::vector<int> geoCols;
397  std::vector<int>::iterator it;
398  GetGeometryColumnsPositions(dset, geoCols);
399 
400  for(it = geoCols.begin(); it != geoCols.end(); ++it)
401  view->hideColumn(*it);
402  }
403 }
404 
406 {
407  if(dset != nullptr)
408  {
409  size_t nProps = dset->getNumProperties();
410 
411  for(std::size_t i = 0; i < nProps; ++i)
412  if(dset->getPropertyName(i) == "tsvector")
413  view->hideColumn((int)i);
414  }
415 }
416 
417 /*!
418  \class Filter for popup menus
419 */
420 class TablePopupFilter : public QObject
421 {
422  Q_OBJECT
423 
424  public:
425 
426  /*!
427  \brief Contructor.
428  */
430  QObject(view),
431  m_view(view),
432  m_hMenu(nullptr),
433  m_vMenu(nullptr),
434  m_vportMenu(nullptr),
435  m_dset(nullptr),
436  m_showOidsColumns(false),
437  m_enabled(true),
438  m_autoPanEnabled(false),
439  m_autoScrollEnabled(false),
440  m_promotionEnabled(false),
441  m_isOGR(false),
442  m_isEditable(true)
443  {
444  m_view->horizontalHeader()->installEventFilter(this);
445  m_view->verticalHeader()->installEventFilter(this);
446  m_view->viewport()->installEventFilter(this);
447 
448  m_view->connect(this, SIGNAL(createHistogram(const int&)), SLOT(createHistogram(const int&)));
449  m_view->connect(this, SIGNAL(createNormalDistribution(const int&)), SLOT(createNormalDistribution(const int&)));
450  m_view->connect(this, SIGNAL(hideColumn(const int&)), SLOT(hideColumn(const int&)));
451  m_view->connect(this, SIGNAL(showColumn(const int&)), SLOT(showColumn(const int&)));
452  m_view->connect(this, SIGNAL(removeColumn(const int&)), SLOT(removeColumn(const int&)));
453  m_view->connect(this, SIGNAL(enableAutoPan(const bool&)), SLOT(setAutoPanEnabled(const bool&)));
454  m_view->connect(this, SIGNAL(enableAutoScroll(const bool&)), SLOT(setAutoScrollEnabled(const bool&)));
455  m_view->connect(this, SIGNAL(sortData(const bool&, const int&)), SLOT(sortByColumns(const bool&, const int&)));
456  m_view->connect(this, SIGNAL(renameColumn(const int&)), SLOT(renameColumn(const int&)));
457  m_view->connect(this, SIGNAL(retypeColumn(const int&)), SLOT(retypeColumn(const int&)));
458  m_view->connect(this, SIGNAL(changeColumnData(const int&)), SLOT(changeColumnData(const int&)));
459  m_view->connect(this, SIGNAL(enablePromotion(const bool&)), SLOT(setPromotionEnabled(const bool&)));
460  m_view->connect(this, SIGNAL(saveEditions()), SLOT(saveEditions()));
461  }
462 
463  /*!
464  \brief Destructor.
465  */
466  ~TablePopupFilter() override
467  {
468  delete m_hMenu;
469  delete m_vMenu;
470  delete m_vportMenu;
471  }
472 
473  bool eventFilter(QObject* watched, QEvent* event) override
474  {
475  if(!m_enabled)
476  return QObject::eventFilter(watched, event);
477 
478  QWidget* vport = m_view->viewport();
479  QHeaderView* hHdr = m_view->horizontalHeader();
480  QHeaderView* vHdr = m_view->verticalHeader();
481 
482  switch(event->type())
483  {
484  case QEvent::ContextMenu:
485  {
486  if(watched == hHdr)
487  {
488  delete m_hMenu;
489  m_hMenu = nullptr;
490 
491  QContextMenuEvent* evt = static_cast<QContextMenuEvent*>(event);
492  QPoint pos = evt->globalPos();
493 
494  m_columnPressed = hHdr->logicalIndex(hHdr->visualIndexAt(evt->pos().x()));
495  bool isPKey = IsPrimaryKey(m_columnPressed, m_view);
496 
497  if(m_columnPressed > 0 && !isPKey)
498  {
499  m_hMenu = new QMenu;
500 
501  QAction* act = new QAction(m_hMenu);
502  act->setText(tr("Hide column"));
503  act->setToolTip(tr("Hides the selected column."));
504 
505  m_hMenu->addAction(act);
506 
507  QMenu* hMnu = GetHiddenColumnsMenu(hHdr, m_dset, m_hMenu);
508 
509  if(m_columnPressed == -1)
510  act->setEnabled(false);
511 
512  m_hMenu->addAction(hMnu->menuAction());
513 
514  QAction* act2 = GetShowAllMenu(hHdr, m_dset, m_hMenu);
515  m_hMenu->addAction(act2);
516 
517  QAction* act3 = new QAction(m_hMenu);
518  act3->setText(tr("Reset columns order"));
519  act3->setToolTip(tr("Put all columns in the original order."));
520  m_hMenu->addAction(act3);
521 
522  m_hMenu->addSeparator();
523 
524  QAction* act5 = new QAction(m_hMenu);
525  act5->setText(tr("Sort data ASC"));
526  act5->setToolTip(tr("Sort data in ascendent order using selected columns."));
527  m_hMenu->addAction(act5);
528 
529  QAction* act9 = new QAction(m_hMenu);
530  act9->setText(tr("Sort data DESC"));
531  act9->setToolTip(tr("Sort data in descendent order using selected columns."));
532  m_hMenu->addAction(act9);
533 
534  m_hMenu->addSeparator();
535 
536  QAction* act4 = new QAction(m_hMenu);
537  act4->setText(tr("Histogram"));
538  act4->setToolTip(tr("Creates a new histogram based on the data of the selected colunm."));
539  m_hMenu->addAction(act4);
540 
541  QAction* act10 = new QAction(m_hMenu);
542  act10->setText(tr("Normal Probability"));
543  act10->setToolTip(tr("Show a chart that displays the normal probability curve."));
544  m_hMenu->addAction(act10);
545 
546  QAction* act6 = new QAction(m_hMenu);
547  act6->setText(tr("Statistics"));
548  act6->setToolTip(tr("Show the statistics summary of the selected colunm."));
549  m_hMenu->addAction(act6);
550 
551  m_hMenu->addSeparator();
552 
553  // Signal / Slot connections
554  connect(act, SIGNAL(triggered()), SLOT(hideColumn()));
555  connect(hMnu, SIGNAL(triggered(QAction*)), SLOT(showColumn(QAction*)));
556 
557  connect(act4, SIGNAL(triggered()), SLOT(createHistogram()));
558 
559  m_view->connect(act2, SIGNAL(triggered()), SLOT(showAllColumns()));
560  m_view->connect(act3, SIGNAL(triggered()), SLOT(resetColumnsOrder()));
561 
562 
563  connect(act6, SIGNAL(triggered()), SLOT(showStatistics()));
564  connect(act5, SIGNAL(triggered()), SLOT(sortDataAsc()));
565  connect(act9, SIGNAL(triggered()), SLOT(sortDataDesc()));
566  connect(act10, SIGNAL(triggered()), SLOT(createNormalDistribution()));
567 
568  if(m_caps.get())
569  {
570  QAction* act7 = new QAction(m_hMenu);
571  act7->setText(tr("Add column"));
572  act7->setToolTip(tr("Adds a column to the table."));
573  if (m_caps->supportsAddColumn() && m_isEditable)
574  {
575  act7->setEnabled(true);
576  }
577  else
578  {
579  act7->setEnabled(false);
580  }
581  m_hMenu->addAction(act7);
582 
583  QAction* act8 = new QAction(m_hMenu);
584  act8->setText(tr("Remove column"));
585  act8->setToolTip(tr("Removes a column from the table."));
586  if (m_caps->supportsRemoveColumn() && m_isEditable)
587  {
588  act8->setEnabled(true);
589  }
590  else
591  {
592  act8->setEnabled(false);
593  }
594  m_hMenu->addAction(act8);
595 
596  QAction* act10 = new QAction(m_hMenu);
597  act10->setText(tr("Rename column"));
598  act10->setToolTip(tr("Renames a column of the table."));
599  act10->setEnabled(m_isEditable);
600  m_hMenu->addAction(act10);
601 
602  QAction* act11 = new QAction(m_hMenu);
603  act11->setText(tr("Change column type"));
604  act11->setToolTip(tr("Changes the type of a column of the table."));
605  if (m_isEditable && !m_isOGR)
606  {
607  act11->setEnabled(true);
608  }
609  else
610  {
611  act11->setEnabled(false);
612  }
613  m_hMenu->addAction(act11);
614 
615  QAction* act12 = new QAction(m_hMenu);
616  act12->setText(tr("Change column data"));
617  act12->setToolTip(tr("Changes the data of a column of the table."));
618  if (m_isEditable && !m_isOGR)
619  {
620  act12->setEnabled(true);
621  }
622  else
623  {
624  act12->setEnabled(false);
625  }
626  m_hMenu->addAction(act12);
627 
628  QAction* act13 = new QAction(m_hMenu);
629  act13->setText(tr("Save editions"));
630  act13->setToolTip(tr("Save pendent editions to layer."));
631  if (m_isEditable && m_view->hasEditions())
632  {
633  act13->setEnabled(true);
634  }
635  else
636  {
637  act13->setEnabled(false);
638  }
639  m_hMenu->addAction(act13);
640 
641  m_view->connect(act7, SIGNAL(triggered()), SLOT(addColumn()));
642 
643  connect(act8, SIGNAL(triggered()), SLOT(removeColumn()));
644  connect (act10, SIGNAL(triggered()), SLOT(renameColumn()));
645  connect (act11, SIGNAL(triggered()), SLOT(retypeColumn()));
646  connect (act12, SIGNAL(triggered()), SLOT(changeColumnData()));
647  connect (act13, SIGNAL(triggered()), SIGNAL(saveEditions()));
648  }
649 
650  m_hMenu->popup(pos);
651  }
652  else
653  {
654  m_hMenu = new QMenu;
655 
656  QAction* act = new QAction(m_hMenu);
657  act->setText(tr("Hide column"));
658  act->setToolTip(tr("Hides the selected column."));
659 
660  m_hMenu->addAction(act);
661 
662  QMenu* hMnu = GetHiddenColumnsMenu(hHdr, m_dset, m_hMenu);
663 
664  if (m_columnPressed == -1)
665  act->setEnabled(false);
666 
667  m_hMenu->addAction(hMnu->menuAction());
668 
669  QAction* act2 = GetShowAllMenu(hHdr, m_dset, m_hMenu);
670  m_hMenu->addAction(act2);
671 
672  QAction* act3 = new QAction(m_hMenu);
673  act3->setText(tr("Reset columns order"));
674  act3->setToolTip(tr("Put all columns in the original order."));
675  m_hMenu->addAction(act3);
676 
677  m_hMenu->addSeparator();
678 
679  QAction* act5 = new QAction(m_hMenu);
680  act5->setText(tr("Sort data ASC"));
681  act5->setToolTip(tr("Sort data in ascendent order using selected columns."));
682  m_hMenu->addAction(act5);
683 
684  QAction* act9 = new QAction(m_hMenu);
685  act9->setText(tr("Sort data DESC"));
686  act9->setToolTip(tr("Sort data in descendent order using selected columns."));
687  m_hMenu->addAction(act9);
688 
689  m_hMenu->addSeparator();
690 
691  QAction* act4 = new QAction(m_hMenu);
692  act4->setText(tr("Histogram"));
693  act4->setToolTip(tr("Creates a new histogram based on the data of the selected colunm."));
694  m_hMenu->addAction(act4);
695 
696  QAction* act10 = new QAction(m_hMenu);
697  act10->setText(tr("Normal Probability"));
698  act10->setToolTip(tr("Show a chart that displays the normal probability curve."));
699  m_hMenu->addAction(act10);
700 
701  QAction* act6 = new QAction(m_hMenu);
702  act6->setText(tr("Statistics"));
703  act6->setToolTip(tr("Show the statistics summary of the selected colunm."));
704  m_hMenu->addAction(act6);
705 
706  m_hMenu->addSeparator();
707 
708  // Signal / Slot connections
709  connect(act, SIGNAL(triggered()), SLOT(hideColumn()));
710  connect(hMnu, SIGNAL(triggered(QAction*)), SLOT(showColumn(QAction*)));
711 
712  connect(act4, SIGNAL(triggered()), SLOT(createHistogram()));
713 
714  m_view->connect(act2, SIGNAL(triggered()), SLOT(showAllColumns()));
715  m_view->connect(act3, SIGNAL(triggered()), SLOT(resetColumnsOrder()));
716 
717 
718  connect(act6, SIGNAL(triggered()), SLOT(showStatistics()));
719  connect(act5, SIGNAL(triggered()), SLOT(sortDataAsc()));
720  connect(act9, SIGNAL(triggered()), SLOT(sortDataDesc()));
721  connect(act10, SIGNAL(triggered()), SLOT(createNormalDistribution()));
722 
723  if (m_caps.get() && m_isEditable)
724  {
725  QAction* act7 = new QAction(m_hMenu);
726  act7->setText(tr("Add column"));
727  act7->setToolTip(tr("Adds a column to the table."));
728  m_hMenu->addAction(act7);
729  act7->setEnabled(m_caps->supportsAddColumn());
730 
731  m_view->connect(act7, SIGNAL(triggered()), SLOT(addColumn()));
732  }
733 
734  m_hMenu->popup(pos);
735  }
736  }
737  else if(watched == vport)
738  {
739  }
740  else if(watched == vHdr)
741  {
742  delete m_vMenu;
743 
744  QContextMenuEvent* evt = static_cast<QContextMenuEvent*>(event);
745  QPoint pos = evt->globalPos();
746 
747  m_vMenu = new QMenu;
748  QAction* act = new QAction(m_vMenu);
749  act->setText(tr("Enable auto scroll"));
750  act->setToolTip(tr("Goes to the selected row."));
751 
752  act->setCheckable(true);
753  act->setChecked(m_autoScrollEnabled);
754 
755  m_vMenu->addAction(act);
756 
757  connect(act, SIGNAL(triggered()), SLOT(setAutoScrollEnabled()));
758 
759  act = new QAction(m_vMenu);
760  act->setText(tr("Enable promotion"));
761  act->setToolTip(tr("Enables promotion of selected rows."));
762 
763  act->setCheckable(true);
764  act->setChecked(m_promotionEnabled);
765 
766  m_vMenu->addSeparator();
767 
768  m_vMenu->addAction(act);
769 
770  connect(act, SIGNAL(triggered()), SLOT(enablePromotion()));
771 
772  act = new QAction(m_vMenu);
773  act->setText(tr("Enable auto pan"));
774  act->setToolTip(tr("Pan to the selected row."));
775 
776  act->setCheckable(true);
777  act->setChecked(m_autoPanEnabled);
778 
779  m_vMenu->addSeparator();
780 
781  m_vMenu->addAction(act);
782 
783  connect(act, SIGNAL(triggered()), SLOT(setAutoPanEnabled()));
784 
785  m_vMenu->popup(pos);
786  }
787  }
788  break;
789 
790  default:
791  break;
792  }
793 
794  return QObject::eventFilter(watched, event);
795  }
796 
798  {
799  m_dset = dset;
800  }
801 
802  std::vector<int> getHiddenColumns()
803  {
804  return GetHiddenSections(m_view->horizontalHeader(), m_dset);
805  }
806 
807  void setEnabled(const bool& enabled)
808  {
809  m_enabled = enabled;
810  }
811 
813  {
814  m_caps.reset(caps);
815  }
816 
817  void setPromotionEnabled(const bool& enabled)
818  {
819  m_promotionEnabled = enabled;
820  }
821 
822  void setIsOGR(const bool& isOGR)
823  {
824  m_isOGR = isOGR;
825  }
826 
827  void setIsEditable(const bool& isEditable)
828  {
829  m_isEditable = isEditable;
830  }
831 
832  protected slots:
833 
835  {
837  }
838 
840  {
842  }
843 
844  void hideColumn()
845  {
847  }
848 
849  void showColumn(QAction* act)
850  {
851  int column = act->data().toInt();
852 
853  emit showColumn(column);
854  }
855 
857  {
858  te::stat::StatisticsDialog statisticDialog;
859 
860  std::string prop = m_dset->getPropertyName(m_columnPressed);
861 
862  try
863  {
865  const te::da::ObjectIdSet* oidSet = layer->getSelected();
866 
867  if(oidSet == nullptr || oidSet->size() == 0)
868  {
869  statisticDialog.setStatistics(m_dset, prop);
870  }
871  else
872  {
873  std::unique_ptr<te::da::DataSet> dset = layer->getData(oidSet);
874  statisticDialog.setStatistics(dset.get(), prop);
875  }
876  statisticDialog.exec();
877  }
878  catch (const te::common::Exception& e)
879  {
880  QMessageBox::information(m_view, tr("Show statistics"), e.what());
881  }
882  }
883 
885  {
887  }
888 
890  {
892 
894  }
895 
897  {
899 
901  }
902 
903  void sortDataAsc()
904  {
905  emit sortData(true, m_columnPressed);
906  }
907 
909  {
910  emit sortData(false, m_columnPressed);
911  }
912 
914  {
916  }
917 
919  {
921  }
922 
924  {
926  }
927 
929  {
931 
933  }
934 
935  signals:
936 
937  void createHistogram(const int&);
938 
939  void createNormalDistribution(const int&);
940 
941  void hideColumn(const int&);
942 
943  void showColumn(const int&);
944 
945  void renameColumn(const int&);
946 
947  void retypeColumn(const int&);
948 
949  void changeColumnData(const int&);
950 
951  void selectObject(const int&, const bool&);
952 
953  void selectObjects(const int&, const int&);
954 
955  void enableAutoPan(const bool&);
956 
957  void enablePromotion(const bool&);
958 
959  void removeColumn(const int&);
960 
961  void enableAutoScroll(const bool&);
962 
963  void sortData(const bool&, const int&);
964 
965  void saveEditions();
966 
967  protected:
968 
970  QMenu* m_hMenu;
971  QMenu* m_vMenu;
972  QMenu* m_vportMenu;
974  std::unique_ptr<te::da::DataSetTypeCapabilities> m_caps;
976  bool m_enabled;
981  bool m_isOGR;
983 };
984 
986  QTableView(parent),
987  m_layer(nullptr),
988  m_autoScrollEnabled(false),
989  m_doScroll(true),
990  m_promotionEnabled(false),
991  m_dset(nullptr),
992  m_orderAsc(true)
993 {
994  m_model = new DataSetTableModel(this);
995 
996  setModel(m_model);
997 
998  setVerticalHeader(new DataSetTableVerticalHeader(this));
999  setHorizontalHeader(new DataSetTableHorizontalHeader(this));
1000 
1001 #if QT_VERSION >= 0x050000
1002  horizontalHeader()->setSectionsMovable(true);
1003 #else
1004  horizontalHeader()->setMovable(true);
1005 #endif
1006 
1007  setSelectionMode(QAbstractItemView::MultiSelection);
1008  setSelectionBehavior(QAbstractItemView::SelectColumns);
1009 
1010  m_popupFilter = new TablePopupFilter(this);
1011 
1012  m_delegate = new HighlightDelegate(this);
1013 
1015 
1016  m_delegate->setColor(Qt::green);
1017 
1018  setItemDelegate(m_delegate);
1019 
1020  connect(verticalHeader(), SIGNAL(selectedRow(const int&, const bool&)), SLOT(highlightRow(const int&, const bool&)));
1021  connect(verticalHeader(), SIGNAL(selectedRows(const int&, const int&)), SLOT(highlightRows(const int&, const int&)));
1022 
1023  connect(m_popupFilter, SIGNAL(enableAutoPan(const bool&)), this, SIGNAL(enableAutoPan(const bool&)));
1024 }
1025 
1027 {
1028  if (m_model->hasEditions())
1029  {
1030  QMessageBox msgBox(this);
1031  msgBox.setText("There are unsaved changes on table.");
1032  msgBox.setInformativeText("Do you want to save your changes?");
1033  msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
1034  msgBox.setDefaultButton(QMessageBox::Save);
1035 
1036  int ret = msgBox.exec();
1037 
1038  if(ret == QMessageBox::Save)
1039  saveEditions();
1040  }
1041 }
1042 
1044 {
1045  DataSetTableHorizontalHeader* hheader = static_cast<DataSetTableHorizontalHeader*>(horizontalHeader());
1046  hheader->setDragDrop(true);
1047 }
1048 
1050 {
1051  DataSetTableHorizontalHeader* hheader = static_cast<DataSetTableHorizontalHeader*>(horizontalHeader());
1052  return hheader->getDragDrop();
1053 }
1054 
1056 {
1057  DataSetTableHorizontalHeader* hheader = static_cast<DataSetTableHorizontalHeader*>(horizontalHeader());
1058  hheader->setAcceptDrop(true);
1059 }
1060 
1062 {
1063  DataSetTableHorizontalHeader* hheader = static_cast<DataSetTableHorizontalHeader*>(horizontalHeader());
1064  return hheader->getAcceptDrop();
1065 }
1066 
1067 void te::qt::widgets::DataSetTableView::setLayer(te::map::AbstractLayer* layer, const bool& clearEditor, const bool& editable)
1068 {
1069  ScopedCursor cursor(Qt::WaitCursor);
1070 
1071  m_layer = layer;
1072  DataSetTableHorizontalHeader* hheader = static_cast<DataSetTableHorizontalHeader*>(horizontalHeader());
1073  hheader->setLayer(m_layer);
1074 
1075  std::unique_ptr<te::map::LayerSchema> sch = m_layer->getSchema();
1076 
1077  if (m_orderby.empty())
1078  {
1079  std::vector<te::dt::Property*> psps;
1080 
1081  if(sch->getPrimaryKey())
1082  psps = sch->getPrimaryKey()->getProperties();
1083 
1084  std::vector<te::dt::Property*>::iterator it;
1085 
1086  for(it = psps.begin(); it != psps.end(); ++it)
1087  m_orderby.push_back((*it)->getName());
1088  }
1089 
1090  std::unique_ptr<te::da::Select> query = GetDataSetQuery(m_layer, m_orderby, m_orderAsc);
1091 
1093 
1094  if(dsc.get() == nullptr)
1095  throw std::string("Fail to get data source.");
1096 
1097  dsc->setEncoding(m_layer->getEncoding());
1098 
1099  const te::da::DataSourceCapabilities& cap = dsc->getCapabilities();
1101  const bool isConnected = dsCap.isConnected();
1102 
1103  m_transactor = dsc->getTransactor();
1104 
1105  std::unique_ptr<te::da::DataSet> ds = m_transactor->query(query.get(), te::common::RANDOM, isConnected);
1106 
1107  setDataSet(ds.release(), clearEditor);
1108 
1109  setLayerSchema(sch.get());
1110 
1112 
1114 
1115  if(caps)
1116  m_model->setEditable(caps->supportsDataEdition());
1117 
1118  if (!editable)
1119  m_model->setEditable(false);
1120 
1121  if(dsc.get() != nullptr)
1122  {
1123  bool isOGR = (dsc->getType().compare("OGR") == 0);
1124  setSelectionMode(isOGR ? SingleSelection : MultiSelection);
1125  setSelectionBehavior(isOGR ? QAbstractItemView::SelectColumns : QAbstractItemView::SelectItems);
1126  m_popupFilter->setIsOGR(isOGR);
1127  m_popupFilter->setIsEditable(editable);
1128  }
1129 
1131 }
1132 
1134 {
1135  return m_layer;
1136 }
1137 
1139 {
1140  reset();
1141 
1142  m_model->setDataSet(dset, clearEditor);
1143  DataSetTableHorizontalHeader* hheader = static_cast<DataSetTableHorizontalHeader*>(horizontalHeader());
1144  hheader->setDataSet(dset);
1145 
1146  HideGeometryColumns(dset, this);
1147  HideTsVectorColumn(dset, this);
1148 
1149  m_popupFilter->setDataSet(dset);
1150  m_delegate->setDataSet(dset);
1151  m_dset = dset;
1152 }
1153 
1155 {
1156  te::da::ObjectIdSet* objs = nullptr;
1157 
1158  te::da::GetEmptyOIDSet(schema, objs);
1159 
1160  std::unique_ptr<te::da::ObjectIdSet> objs_ptr(objs);
1161 
1162  m_delegate->setObjectIdSet(objs_ptr.get());
1163 
1164  m_model->setPkeysColumns(objs_ptr->getPropertyPos());
1165 
1166 // m_model->getPromoter()->preProcessKeys(m_dset, objs_ptr->getPropertyPos());
1167 }
1168 
1170 {
1171  if(oids == nullptr)
1172  return;
1173 
1174  m_delegate->setObjectIdSet(oids);
1175 
1176  if(m_autoScrollEnabled && oids != nullptr && oids->size() > 0)
1177  {
1178  size_t row = m_model->getPromoter()->map2Row(*oids->begin());
1179 
1180  scrollTo(m_model->index((int)row, 0));
1181  }
1182 
1183  if(m_promotionEnabled)
1185 
1186  viewport()->repaint();
1187 }
1188 
1190 {
1191  m_delegate->setColor(color);
1192 
1193  repaint();
1194 }
1195 
1197 {
1198  return m_model->hasEditions();
1199 }
1200 
1202 {
1203  QDialog* dialog = new QDialog(this);
1204  dialog->setFixedSize(160, 75);
1205 
1206  // Histogram data Widget
1208  histogramWidget->setHistogramProperty(column);
1209 
1210  // Adjusting...
1211  QGridLayout* layout = new QGridLayout(dialog);
1212  layout->addWidget(histogramWidget);
1213 
1214  QDialogButtonBox* bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, dialog);
1215  connect(bbox, SIGNAL(accepted()), dialog, SLOT(accept()));
1216  connect(bbox, SIGNAL(rejected()), dialog, SLOT(reject()));
1217 
1218  layout->addWidget(bbox);
1219  layout->setSizeConstraint(QLayout::SetFixedSize);
1220 
1221  int res = dialog->exec();
1222  if (res == QDialog::Accepted)
1223  {
1224  emit createChartDisplay(te::qt::widgets::createHistogramDisplay(m_layer, column, histogramWidget->getSummaryFunction(), histogramWidget->getHistogram()));
1225  }
1226 
1227  delete dialog;
1228 }
1229 
1231 {
1232  int propType = m_layer->getData()->getPropertyDataType(column);
1233  if(propType >= te::dt::INT16_TYPE && propType <= te::dt::NUMERIC_TYPE)
1234  {
1236  }
1237  else
1238  {
1239  QString msgErr(tr("This operation is not available for this type of data"));
1240  QString msgTitle(tr("TNormal Probability"));
1241  QMessageBox::warning(this, msgTitle, msgErr);
1242  }
1243 }
1244 
1246 {
1247  horizontalHeader()->hideSection(column);
1248 }
1249 
1251 {
1252  horizontalHeader()->showSection(column);
1253 }
1254 
1256 {
1257  RenameColumnDialog dlg(parentWidget());
1258 
1259  std::string dsName = m_layer->getSchema()->getName();
1260  std::string currentName = m_dset->getPropertyName(column);
1261  dlg.setOldColumnName(QString::fromUtf8(currentName.c_str()));
1262 
1263  if(dlg.exec() == QDialog::Accepted)
1264  {
1265  std::string oldName = dlg.getOldName().toUtf8().data();
1266  std::string newName = dlg.getNewName().toUtf8().data();
1268 
1269  if(dsrc.get() == nullptr)
1270  throw Exception(tr("Fail to get data source.").toUtf8().data());
1271 
1272  if(!dsrc->isPropertyNameValid(newName))
1273  {
1274  QMessageBox::warning(this, tr("TerraView"), tr("Invalid column name. Choose another."));
1275  return;
1276  }
1277 
1278  if (dsrc->propertyExists(dsName, newName))
1279  {
1280  QString msg = tr("The column could not be renamed: There already exists a property with this name.");
1281  TE_LOG_INFO(msg.toUtf8().data());
1282  QMessageBox::warning(this, tr("TerraView"), msg);
1283  return;
1284  }
1285 
1286  try
1287  {
1288  dsrc->renameProperty(dsName, oldName, newName);
1289  }
1290  catch (const te::common::Exception& e)
1291  {
1292  QMessageBox::information(this, tr("Rename Column"), tr("The column could not be renamed: ") + e.what());
1293  }
1294 
1295  m_layer->setOutOfDate();
1296 
1297  setLayer(m_layer);
1298  }
1299 }
1300 
1302 {
1303  RetypeColumnDialog dlg(parentWidget());
1304 
1305  std::unique_ptr<te::da::DataSetType> schema = m_layer->getSchema();
1306  te::dt::Property* prp;
1307  std::string dsetName = schema->getName();
1308  std::string columnName;
1309 
1310  prp = schema->getProperty(column);
1311 
1312  if(prp == nullptr)
1313  throw Exception(tr("Fail to get property of the dataset.").toUtf8().data());
1314 
1315  columnName = prp->getName();
1316 
1317  dlg.setTableName(dsetName.c_str());
1318  dlg.setColumnName(columnName.c_str());
1319  dlg.setType(prp->getType());
1320 
1321  if(dlg.exec() == QDialog::Accepted)
1322  {
1324 
1325  if(dsrc.get() == nullptr)
1326  throw Exception(tr("Fail to get data source.").toUtf8().data());
1327 
1328  setDataSet(nullptr);
1329 
1330  dsrc->changePropertyDefinition(dsetName, columnName, dlg.getProperty().release());
1331 
1332  m_layer->setOutOfDate();
1333 
1334  setLayer(m_layer);
1335  }
1336 }
1337 
1339 {
1340  if(m_dset == nullptr || m_layer == nullptr)
1341  return;
1342 
1343  std::unique_ptr<te::da::DataSetType> schema = m_layer->getSchema();
1344  te::da::PrimaryKey* pk = schema->getPrimaryKey();
1345  std::string dsetName = schema->getName();
1346  te::dt::Property* prop = schema->getProperty(column);
1347  std::string columnName = prop->getName();
1348  std::vector<QString> cols = GetColumnsNames(m_dset);
1349 
1350  std::map<std::string, int> pkColumnsType;
1351 
1352  if (pk == nullptr)
1353  throw Exception(tr("The layer must have a primary key.").toUtf8().data());
1354 
1355  std::vector<te::dt::Property*> pkProps = pk->getProperties();
1356 
1357  for (size_t i = 0; i < pkProps.size(); i++)
1358  {
1359  pkColumnsType[pkProps[i]->getName()] = pkProps[i]->getType();
1360  }
1361 
1362  AlterDataDialog dlg(parentWidget());
1363  dlg.setSelectedColumn(columnName.c_str());
1364  dlg.setDataColumns(cols);
1365  if (prop->getType() == te::dt::STRING_TYPE)
1366  dlg.setHelpLabelText(tr("This is a string column, use single quotes"));
1367 
1368  if(dlg.exec() == QDialog::Accepted)
1369  {
1371 
1372  if(dsrc.get() == nullptr)
1373  throw Exception(tr("Fail to get data source.").toUtf8().data());
1374 
1375  std::string sql = "UPDATE " + dsetName + " SET " + columnName + " = " + dlg.getExpression().toUtf8().data();
1376 
1377  try
1378  {
1379  //TODO: create class Update at dataaccess/query to do this operations
1380  //Obs: not working when the dataset primary key has more than two properties
1381  if (!dlg.alterAllData())
1382  {
1383  const te::da::ObjectIdSet* objSet = m_layer->getSelected();
1384 
1386 
1387  te::da::In* inExp = dynamic_cast<te::da::In*>(exp);
1388  te::da::Or* orExp = dynamic_cast<te::da::Or*>(exp);
1389 
1390  te::da::In* orFirstInExp = nullptr;
1391  te::da::In* orSecondInExp = nullptr;
1392 
1393  std::string orFirstInExpStr = " IN (";
1394  std::string orSecondInExpStr = " IN (";
1395 
1396  if (orExp) // more than one properties at primary key
1397  {
1398  orFirstInExp = dynamic_cast<te::da::In*>(orExp->getFirst());
1399  orSecondInExp = dynamic_cast<te::da::In*>(orExp->getSecond());
1400 
1401  for (std::size_t i = 0; i < orFirstInExp->getNumArgs(); ++i)
1402  {
1403  te::da::Expression* a1 = orFirstInExp->getArg(i);
1404 
1405  te::da::Literal* l1 = dynamic_cast<te::da::Literal*>(a1);
1406 
1407  std::string inStr = l1->getValue()->toString();
1408 
1409  if (pkColumnsType[objSet->getPropertyNames()[0]] == te::dt::STRING_TYPE)
1410  inStr = "'" + inStr + "'";
1411 
1412  if (i == orFirstInExp->getNumArgs() - 1)
1413  orFirstInExpStr += inStr + ")";
1414  else
1415  orFirstInExpStr += inStr + ",";
1416  }
1417 
1418  for (std::size_t i = 0; i < orSecondInExp->getNumArgs(); ++i)
1419  {
1420  te::da::Expression* a1 = orSecondInExp->getArg(i);
1421 
1422  te::da::Literal* l1 = dynamic_cast<te::da::Literal*>(a1);
1423 
1424  std::string inStr = l1->getValue()->toString();
1425 
1426  if (pkColumnsType[objSet->getPropertyNames()[1]] == te::dt::STRING_TYPE)
1427  inStr = "'" + inStr + "'";
1428 
1429  if (i == orSecondInExp->getNumArgs() - 1)
1430  orSecondInExpStr += inStr + ")";
1431  else
1432  orSecondInExpStr += inStr + ",";
1433  }
1434 
1435  sql += " WHERE " + objSet->getPropertyNames()[0] + orFirstInExpStr + " AND " + objSet->getPropertyNames()[1] + orSecondInExpStr;
1436 
1437  }
1438  else if (inExp)
1439  {
1440 
1441  std::string inExpStr = " IN (";
1442 
1443  for (std::size_t i = 0; i < inExp->getNumArgs(); ++i)
1444  {
1445  te::da::Expression* a1 = inExp->getArg(i);
1446 
1447  te::da::Literal* l1 = dynamic_cast<te::da::Literal*>(a1);
1448 
1449  std::string inStr = l1->getValue()->toString();
1450 
1451  if (pkColumnsType[objSet->getPropertyNames()[0]] == te::dt::STRING_TYPE)
1452  inStr = "'" + inStr + "'";
1453 
1454  if (i == inExp->getNumArgs() - 1)
1455  {
1456  inExpStr += inStr + ")";
1457  }
1458  else
1459  {
1460  inExpStr += inStr + ",";
1461  }
1462  }
1463 
1464  sql += " WHERE " + objSet->getPropertyNames()[0] + inExpStr;
1465  }
1466 
1467  }
1468 
1469  // Ignore \n
1470  std::replace(sql.begin(), sql.end(), '\n', ' ');
1471 
1472  dsrc->execute(sql);
1473 
1474  m_layer->setOutOfDate();
1475 
1476  setLayer(m_layer);
1477  }
1478  catch(te::common::Exception& e)
1479  {
1480  QMessageBox::information(this, tr("Updating data failure"), e.what());
1481  }
1482  catch(...)
1483  {
1484  QMessageBox::information(this, tr("Updating data failure"), tr("Data source operation fail for unknown reason."));
1485  }
1486  }
1487 }
1488 
1490 {
1491  std::vector<int> hCols = m_popupFilter->getHiddenColumns();
1492  std::vector<int>::iterator it;
1493 
1494  for (it=hCols.begin(); it!=hCols.end(); ++it)
1495  horizontalHeader()->showSection(*it);
1496 }
1497 
1499 {
1500  QHeaderView* hdr = horizontalHeader();
1501 
1502  int nCols = hdr->count();
1503 
1504  for(int i=0; i<nCols; i++)
1505  {
1506  int visCol = hdr->visualIndex(i);
1507 
1508  if(visCol != i)
1509  hdr->moveSection(visCol, i);
1510  }
1511 }
1512 
1513 void te::qt::widgets::DataSetTableView::highlightRow(const int& row, const bool& add)
1514 {
1515  te::da::ObjectIdSet* oids = m_model->getObjectIdSet(row, row);
1516 
1517  if(add)
1518  {
1519  te::da::ObjectId* oid = *oids->begin();
1520 
1521  if(m_delegate->getSelected()->contains(oid))
1522  {
1523  emit deselectOIds(oids);
1524 
1525  delete oids;
1526 
1528 
1529  if(m_promotionEnabled)
1530  promote();
1531 
1532  viewport()->repaint();
1533 
1534  return;
1535  }
1536  }
1537 
1538  m_doScroll = false;
1539 
1540  emit selectOIds(oids, add, GetExtent(m_dset, m_model->getPromoter(), row).get());
1541 
1542  if(m_promotionEnabled)
1543  promote();
1544 
1545  viewport()->repaint();
1546 
1547  m_doScroll = true;
1548 }
1549 
1550 void te::qt::widgets::DataSetTableView::highlightRows(const int& initRow, const int& finalRow)
1551 {
1552  int ini,
1553  final;
1554 
1555  if(initRow < finalRow)
1556  {
1557  ini = initRow;
1558  final = finalRow;
1559  }
1560  else
1561  {
1562  ini = finalRow;
1563  final = initRow;
1564  }
1565 
1566  te::da::ObjectIdSet* oids = m_model->getObjectIdSet(ini, final);
1567 
1568  m_doScroll = false;
1569 
1570  emit selectOIds(oids, true, GetExtent(m_dset, m_model->getPromoter(), final).get());
1571 
1572  if(m_promotionEnabled)
1573  promote();
1574 
1575  viewport()->repaint();
1576 
1577  m_doScroll = false;
1578 }
1579 
1581 {
1582  ScopedCursor cursor(Qt::WaitCursor);
1583 
1584  setEnabled(false);
1585  m_model->setEnabled(false);
1586  m_popupFilter->setEnabled(false);
1587 
1588  const te::da::ObjectIdSet* oids = m_delegate->getSelected();
1589  m_model->promote(oids);
1590 
1591  m_popupFilter->setEnabled(true);
1592  m_model->setEnabled(true);
1593  setEnabled(true);
1594 
1595  viewport()->repaint();
1596 
1597  if(scroll)
1598  scrollToTop();
1599 }
1600 
1602 {
1603  //*********************
1604  // Sort by query
1605  //*********************
1606  try
1607  {
1608  ScopedCursor cursor(Qt::WaitCursor);
1609  std::vector<int> selCols;
1610  std::string prop = m_dset->getPropertyName(static_cast<size_t>(col));
1611 
1612  m_orderby.clear();
1613 
1614  int nCols = model()->columnCount();
1615 
1616  for(int i=0; i<nCols; i++)
1617  {
1618  int logRow = horizontalHeader()->logicalIndex(i);
1619  if(selectionModel()->isColumnSelected(logRow, QModelIndex()))
1620  {
1621  m_orderby.push_back(m_dset->getPropertyName(static_cast<size_t>(logRow)));
1622  selCols.push_back(logRow);
1623  }
1624  }
1625 
1626  if(selCols.empty())
1627  m_orderby.push_back(m_dset->getPropertyName(static_cast<size_t>(col)));
1628 
1629  selCols.push_back(col);
1630 
1631  std::unique_ptr<te::da::Select> query = GetDataSetQuery(m_layer, m_orderby, asc);
1632 
1634 
1635  if(dsc.get() == nullptr)
1636  throw std::string("Fail to get data source.");
1637 
1638  dsc->setEncoding(m_layer->getEncoding());
1639 
1640  const te::da::DataSourceCapabilities& cap = dsc->getCapabilities();
1642  const bool isConnected = dsCap.isConnected();
1643 
1644  m_transactor = dsc->getTransactor();
1645 
1646  std::unique_ptr<te::da::DataSet> dset = m_transactor->query(query.get(), te::common::RANDOM, isConnected);
1647 
1648  if(dset.get() == nullptr)
1649  throw te::common::Exception(tr("Sort operation not supported by the source of data.").toUtf8().data());
1650 
1651  setDataSet(dset.release());
1652 
1653  viewport()->repaint();
1654 
1655  setUpdatesEnabled(false);
1656 
1658 
1659  setUpdatesEnabled(true);
1660 
1661  if(m_promotionEnabled)
1662  promote();
1663  }
1664  catch(te::common::Exception& e)
1665  {
1666  QMessageBox::information(this, tr("Sorting columns failure"), tr("Could not sort data: ") + e.what());
1667  }
1668 }
1669 
1671 {
1672  m_model->showOIdsVisible(visible);
1673 
1674  horizontalHeader()->viewport()->repaint();
1675 }
1676 
1678 {
1679  if(m_layer == nullptr)
1680  return;
1681 
1682  try
1683  {
1684  AddColumnDialog dlg(parentWidget());
1685 
1686  std::unique_ptr<te::da::DataSetType> ds_t = m_layer->getSchema();
1687 
1688  std::string dsName = ds_t->getName();
1689  size_t n_prop = ds_t->getProperties().size();
1690  dlg.setTableName(dsName);
1691 
1692  if(dlg.exec() == QDialog::Accepted)
1693  {
1695 
1696  if(ds.get() == nullptr)
1697  throw te::common::Exception(tr("Fail to get data source of the layer.").toUtf8().data());
1698 
1699  std::unique_ptr<te::dt::Property> p(dlg.getNewProperty());
1700 
1701  if(p->getName().empty())
1702  throw te::common::Exception(tr("Name must not be empty.").toUtf8().data());
1703 
1704  if(!ds->isPropertyNameValid(p->getName()))
1705  throw te::common::Exception(tr("The property name is invalid.").toUtf8().data());
1706 
1707  if(ds->propertyExists(dsName, p->getName()))
1708  throw te::common::Exception(tr("There already exists a property with this name.").toUtf8().data());
1709 
1710  ds->addProperty(dsName, p.get());
1711 
1712  if(ds->getType().compare("OGR") == 0)
1713  m_model->insertColumns(((int)n_prop-1), 0);
1714 
1715  m_layer->setOutOfDate();
1716 
1717  setLayer(m_layer, false);
1718  }
1719  }
1720  catch(te::common::Exception& e)
1721  {
1722  QMessageBox::information(this, tr("Creating column failure"), tr("The column could not be created: ") + e.what());
1723  }
1724 }
1725 
1727 {
1728  try
1729  {
1730  if(QMessageBox::question(this, tr("Remove column"), tr("Are you sure you want to remove this column?"), QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
1731  {
1733 
1734  if(ds.get() == nullptr)
1735  throw te::common::Exception(tr("Fail to get data source of the layer.").toUtf8().data());
1736 
1737  std::unique_ptr<te::da::DataSetType> ds_t = m_layer->getSchema();
1738  std::string dsName = ds_t->getName();
1739 
1740  std::string pName = ds_t->getProperty(column)->getName();
1741 
1742  ds->dropProperty(dsName, pName);
1743 
1744  m_model->removeColumns(column, 0);
1745 
1746  m_layer->setOutOfDate();
1747 
1748  setLayer(m_layer, false);
1749  }
1750  }
1751  catch(te::common::Exception& e)
1752  {
1753  QMessageBox::information(this, tr("Removing column failure"), tr("The column could not be removed: ") + e.what());
1754  }
1755 }
1756 
1758 {
1759  m_autoPanEnabled = enable;
1760 }
1761 
1763 {
1764  m_autoScrollEnabled = enable;
1765 
1767 }
1768 
1770 {
1771  m_promotionEnabled = enable;
1772 
1774 
1775  if(m_promotionEnabled)
1776  promote();
1777 
1779 }
1780 
1781 void te::qt::widgets::DataSetTableView::removeSelection(const int& initRow, const int& finalRow)
1782 {
1783  QItemSelection toRemove;
1784 
1785  for(int i=initRow; i<=finalRow; i++)
1786  {
1787  QModelIndexList idx = selectionModel()->selectedColumns(i);
1788 
1789  if(!idx.empty())
1790  toRemove.select(idx.first(), idx.last());
1791  }
1792 
1793  selectionModel()->select(toRemove, QItemSelectionModel::Deselect);
1794 }
1795 
1797 {
1798  try
1799  {
1800  ScopedCursor c(Qt::WaitCursor);
1801 
1802  std::vector< std::set<int> > ed;
1803 
1804  std::unique_ptr<te::map::LayerSchema> sch = m_layer->getSchema();
1805 
1806  std::unique_ptr<te::da::DataSet> md = m_model->getEditions(sch.get(), ed);
1807 
1809 
1810  if(ds.get() == nullptr)
1811  throw te::common::Exception(tr("Fail to get data source from layer").toUtf8().data());
1812 
1813  te::da::ObjectIdSet* objs = nullptr;
1814 
1815  te::da::GetEmptyOIDSet(sch.get(), objs);
1816 
1817  std::unique_ptr<te::da::ObjectIdSet> objs1(objs);
1818 
1819  ds->update(sch->getName(), md.get(), ed, objs1->getPropertyPos());
1820 
1821  setLayer(m_layer);
1822  }
1823  catch(te::common::Exception& e)
1824  {
1825  QMessageBox::warning(this, tr("Save edition failure"), e.what());
1826  }
1827 }
1828 
1829 #include "DataSetTableView.moc"
1830 
TEQTWIDGETSEXPORT ChartDisplayWidget * createNormalDistribution(te::da::DataSet *dataset, int propId)
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
Expression * getArg(std::size_t i) const
It returns the i-th function argument.
bool hasEditions() const
Returns true if there are unsaved editions.
A widget used to adjust a histogram&#39;s input data.
std::unique_ptr< te::da::Select > GetSelectExpression(const std::string &datasetName, const std::vector< std::string > &colsNames, const bool &asc)
#define slots
A Qt dialog for reset data of a column in the table.
void enableAutoPan(const bool &)
TEXSDEXPORT void Save(All *all, te::xml::AbstractWriter &writer)
An specialization of QItemDelegate to be used with te::map::AbstractTable objects.
bool IsGeometryColumn(te::da::DataSet *dset, const size_t &col)
void enableAutoScroll(const bool &)
Expression * getFirst() const
It returns the first function argument.
std::vector< QString > GetColumnsNames(te::da::DataSet *dset)
void highlightRow(const int &row, const bool &add)
Used to highlight the data when the mouse is clicked over a row in the table.
const std::string & getDataSourceId() const
A class that informs what kind of constraint and index is supported by a given data source...
te::da::DataSetTypeCapabilities * GetCapabilities(const te::map::AbstractLayer *layer)
virtual void setColor(const QColor &c)
Update the color group.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
TEDATAACCESSEXPORT void GetEmptyOIDSet(const DataSetType *type, ObjectIdSet *&set)
Returns an empty ObjectIdSet, with the definitions of fields that compose it.
A layer with reference to a dataset that contains trajectories.
std::vector< int > GetHiddenSections(QHeaderView *hView, te::da::DataSet *dset)
void setPromoter(Promoter *promoter)
Sets the promoter being used.
A Qt dialog for renaming columns into a table.
A model based on te::da::DataSet.
Defines a vertical header for a dataset table view.
A layer with reference to a dataset that contains observations.
This is the base class for layers.
Definition: AbstractLayer.h:77
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
std::unique_ptr< te::da::DataSetTypeCapabilities > m_caps
boost::shared_ptr< DataSource > DataSourcePtr
te::qt::widgets::Histogram * getHistogram()
Returns a pointer to the widget&#39;s form.
bool m_doScroll
Flag to force or not scrolling.
virtual const std::string & getType() const =0
It returns the layer type.
void promote(const bool &scroll=false)
Promotes the highlighted rows.
size_t map2Row(te::da::ObjectId *oid)
Given an object id returns its row.
Definition: Promoter.cpp:224
bool eventFilter(QObject *watched, QEvent *event) override
Base exception class for plugin module.
void changeColumnData(const int &column)
Shows the change column data dialog.
A class that models the description of a dataset.
Definition: DataSetType.h:72
void setDataSet(te::da::DataSet *dset)
void setStatistics(te::da::DataSet *dataSet, const std::string prop)
virtual const char * what() const
It outputs the exception message.
Defines an mechanism for logical ordering of rows.
virtual void setLayerSchema(const te::da::DataSetType *schema)
Sets the schema of the data set. It is used to define the primary keys and create the ObjectIdSet...
std::unique_ptr< te::da::DataSet > getEditions(const te::da::DataSetType *type, std::vector< std::set< int > > &ps)
Returns a memory dataset to be saved.
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
void setIsEditable(const bool &isEditable)
void retypeColumn(const int &column)
Changes teh type of a column in the table.
TEQTWIDGETSEXPORT ChartDisplayWidget * createHistogramDisplay(te::map::AbstractLayer *layer, int propId, int slices=10, int stat=-1)
Histogram Creator.
void setPkeysColumns(const std::vector< size_t > &pkeys)
Sets the columns used as pkeys, for presentation purposes.
virtual void setOutOfDate()
Its indicate that the layer schema is out of date.
void selectObject(const int &, const bool &)
void setEnabled(const bool &enabled)
void setTableName(const std::string &name)
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
Definition: OrderBy.h:37
te::da::ObjectIdSet * getObjectIdSet(const int &initRow, const int &finalRow)
Returns the ObjectIdSet begining with row initRow and ending in finalRow.
std::unique_ptr< te::da::Select > GetDataSetQuery(const te::map::AbstractLayer *layer, const std::vector< std::string > &colsNames, const bool &asc)
void setDragDrop(bool b)
Sets the drag drop on the horizontal header. When the drag drop is enabled, you lose the ability to s...
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
te::map::AbstractLayer * getLayer()
Gets selected layer.
A layer resulting from a query.
Definition: QueryLayer.h:50
static te::dt::Date ds(2010, 01, 01)
void setHistogramProperty(int propId)
Sets the property to be used in order to generate the histogram.
void renameColumn(const int &column)
Rename a column of the table.
A class that informs what the dataset implementation of a given data source can perform.
void setIsOGR(const bool &isOGR)
void showOIdsVisible(const bool &visible)
Shows an icon for indentify the columns that are used for identify objects.
te::da::DataSet * m_dset
#define TE_LOG_INFO(message)
Use this tag in order to log a message to the TerraLib default logger with the INFO level...
Definition: Logger.h:315
void setHelpLabelText(const QString &text)
It models a property definition.
Definition: Property.h:59
void setOldColumnName(const QString &name)
std::vector< std::string > m_orderby
Order by columns.
void setTableName(const QString &name)
This is an abstract class that models a query expression.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
Definition: PrimaryKey.h:109
void createChartDisplay(te::qt::widgets::ChartDisplayWidget *)
virtual bool move(std::size_t i)=0
It moves the dataset internal pointer to a given position.
void HideGeometryColumns(te::da::DataSet *dset, te::qt::widgets::DataSetTableView *view)
te::core::EncodingType getEncoding() const
It returns the encoding type.
te::da::DataSourcePtr GetDataSource(const te::map::AbstractLayer *layer)
void setDataSet(te::da::DataSet *dset, const bool &clearEditor=true)
Updates the data set being visualized.
unsigned int unsigned int nCols
bool m_autoScrollEnabled
Auto scroll enabling.
void createNormalDistribution(const int &column)
Creates a new chart that displays the normal distribution based on the data at position column...
A layer with reference to a DataSetTypeConverter.
virtual std::string toString() const =0
It returns the data value in a string notation.
void setLayer(const te::map::AbstractLayer *layer)
Sets the layer to get drag and drop information.
DataSetTableModel * m_model
The model to be used.
void addColumn()
Add column to the table.
A table view for a dataset.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
te::dt::Property * getNewProperty() const
void hideColumn(const int &column)
Hides the column at position column.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
An Envelope defines a 2D rectangular region.
bool getDragDrop()
Gets the drag drop flag.
void showAllColumns()
Shows all hidden columns.
This class models a literal value.
DataSetTableView(QWidget *parent=0)
Constructor.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
A Qt dialog for inserting columns into a table.
This class represents an unique id for a data set element.
std::size_t size() const
It returns the object id set size.
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
void GetGeometryColumnsPositions(te::da::DataSet *dset, std::vector< int > &cols)
std::string getSummaryFunction()
Returns the name of the chosen summary function. Default is None.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
virtual ~DataSetTableView()
Virtual destructor.
void setColumnName(const QString &name)
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
const std::string & getDataSourceId() const
void highlightOIds(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
bool IsPrimaryKey(const int &col, te::qt::widgets::DataSetTableView *view)
void deselectOIds(te::da::ObjectIdSet *)
TablePopupFilter * m_popupFilter
The menus popup filter.
te::gm::Polygon * p
void showColumn(QAction *act)
void setAcceptDrop(bool b)
Sets the drop on the horizontal header.
te::da::Select * getQuery() const
Definition: QueryLayer.cpp:363
std::unique_ptr< te::gm::Envelope > GetExtent(te::da::DataSet *dset, te::qt::widgets::Promoter *p, const int &rowPosition)
bool hasEditions() const
Returns true if there are unsaved editions e false if there is not.
void promote(const te::da::ObjectIdSet *oids)
Promotes the rows identified by oids.
A class used for logical ordering of rows.
Definition: Promoter.h:69
std::unique_ptr< te::da::DataSet > GetDataSet(const te::map::AbstractLayer *layer, const te::da::DataSet *set, const std::vector< int > &cols, const bool &asc)
QAction * GetShowAllMenu(QHeaderView *hView, te::da::DataSet *dset, QMenu *hMnu)
~TablePopupFilter() override
Destructor.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
bool getAcceptDrop()
Gets accept drop flag.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
virtual void setObjectIdSet(const te::da::ObjectIdSet *objs)
Sets the object id set. It WILL NOT TAKE the ownership of the objs.
const std::string & getDataSourceId() const
bool m_autoPanEnabled
Auto pan enabling.
void createHistogram(const int &column)
Creates a new histogram based on the data at position column.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
te::qt::widgets::DataSetTableView * m_view
void selectObjects(const int &, const int &)
rasterPointer reset(te::rst::RasterFactory::make("MEM", new te::rst::Grid(nCols, nLines), bandsProps, std::map< std::string, std::string >(), 0, 0))
void setSelectedColumn(const QString &colName)
HighlightDelegate * m_delegate
Delegate used for rendering selected rows.
void removeSelection(const int &initRow, const int &finalRow)
int getType() const
It returns the property data type.
Definition: Property.h:161
A dataset is the unit of information manipulated by the data access module of TerraLib.
void setEnabled(const bool &enabled)
Enable or disable the dataset presentation.
void setDataSetTypeCapabilities(te::da::DataSetTypeCapabilities *caps)
virtual const te::da::ObjectIdSet * getSelected() const
It returns the selected group of this Layer.
void setEditable(const bool &editable)
Sets if the model is editable or not.
const std::string & getDataSetName() const
void preProcessKeys(te::da::DataSet *dset, const std::vector< size_t > &pkeys)
Proccess primary keys and stores it.
Definition: Promoter.cpp:153
virtual std::unique_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const =0
It gets the dataset identified by the layer name.
void highlightRows(const int &initRow, const int &finalRow)
Select all rows from initRow to finalRow.
virtual void setDataSet(te::da::DataSet *dset)
Sets the current data set being used. This method DOES NOT take the ownership of the dset...
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
void setDataSet(te::da::DataSet *dset, const bool &clearEditor=true)
Updates the data being used.
void HideTsVectorColumn(te::da::DataSet *dset, te::qt::widgets::DataSetTableView *view)
Promoter * getPromoter()
Returns the pointer to the promoter being used.
void setOIdsColumnsVisible(const bool &visible)
Shows or hides the icon sinalizing the columns that identify each row.
A layer with reference to a dataset that contains trajectories.
bool contains(ObjectId *oid) const
It returns if the object id set contains the given oid.
te::map::AbstractLayer * m_layer
Pointer to the layer being presented.
void setDataColumns(const std::vector< QString > &cols)
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
A delegate for highlight the selected object ids.
te::gm::LineString * l1
const std::vector< std::string > & getPropertyNames() const
It returns the property names used to generated the oids.
size_t getLogicalRow(const size_t &visualRow)
Returns the logical position of the row visualRow.
Definition: Promoter.cpp:185
Expression * getExpressionByInClause(const std::string source="") const
te::da::DataSet * m_dset
Data set being used.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
void setAutoPanEnabled(const bool &enable)
A class that represents the IN operator.
Definition: In.h:52
const std::vector< std::size_t > & getPropertyPos() const
It returns the property positions used to generated the oids.
A layer with reference to a dataset.
Definition: DataSetLayer.h:47
std::unique_ptr< te::dt::Property > getProperty()
void setLayer(te::map::AbstractLayer *layer, const bool &clearEditor=true, const bool &editable=true)
Sets the layer to be presented.
A table model representing a te::da::DataSet.
void setDataSet(te::da::DataSet *dset)
Sets the data set to get drag and drop information.
bool m_orderAsc
Flag that sinalizes if the it is sorted in ascending sorting.
QMenu * GetHiddenColumnsMenu(QHeaderView *hView, te::da::DataSet *dset, QMenu *hMnu)
virtual const std::string & getName() const
It returns the constraint name.
Definition: Constraint.h:119
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
Definition: OrderByItem.h:53
virtual const te::da::ObjectIdSet * getSelected() const
Returns the identifiers of the rows highlighted.
TablePopupFilter(te::qt::widgets::DataSetTableView *view)
Contructor.
Expression * getSecond() const
It returns the second function argument.
void setHighlightColor(const QColor &color)
Update the color to be used.
const DataSetCapabilities & getDataSetCapabilities() const
std::unique_ptr< te::da::DataSourceTransactor > m_transactor
Pointer to the transactor, to keep data while table is open.
std::vector< int > getHiddenColumns()
terralib_conf cmake set(SWIG_MAIN_FILE"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/terralib/binding/swig/TerraLibLUA.i") file(GLOB TERRALIB_SWIG_SCRIPT_FILE $
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
te::dt::AbstractData * getValue() const
It returns the value associated to the literal.
void showColumn(const int &column)
Shows the hidden column.
void sortByColumns(const bool &asc, const int &col)
Sort by the selected columns.
void enableAutoPan(const bool &)
virtual const std::string & getDataSourceId() const
void saveEditions()
Saves all editions to the dataset.
std::size_t getNumArgs() const
It returns the number of arguments informed to the function.
void removeColumn(const int &column)
unsigned int col
void setAutoScrollEnabled(const bool &enable)
Enable / disable auto-scroll.
bool m_promotionEnabled
Promotion enabled.
void resetColumnsOrder()
Shows columns in the original order.
void selectOIds(te::da::ObjectIdSet *, const bool &, te::gm::Envelope *)
Emmite when objects was selected.
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48
void setPromotionEnabled(const bool &enable)
Enable / disable promotion.
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
A vertical header used for selecting rows at a table view.
const std::string & getName() const
It returns the property name.
Definition: Property.h:127
void sortData(const bool &, const int &)
void setPromotionEnabled(const bool &enabled)