All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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/Utils.h"
14 #include "../utils/ScopedCursor.h"
15 #include "../Config.h"
16 #include "../Exception.h"
17 #include "../../../common/Exception.h"
18 #include "../../../dataaccess/dataset/DataSet.h"
19 #include "../../../dataaccess/dataset/ObjectId.h"
20 #include "../../../dataaccess/dataset/ObjectIdSet.h"
21 #include "../../../dataaccess/dataset/DataSetTypeCapabilities.h"
22 #include "../../../dataaccess/datasource/DataSourceManager.h"
23 #include "../../../dataaccess/datasource/DataSourceTransactor.h"
24 #include "../../../dataaccess/query/DataSetName.h"
25 #include "../../../dataaccess/query/Field.h"
26 #include "../../../dataaccess/query/From.h"
27 #include "../../../dataaccess/query/OrderBy.h"
28 #include "../../../dataaccess/query/OrderByItem.h"
29 #include "../../../dataaccess/query/Select.h"
30 #include "../../../dataaccess/utils/Utils.h"
31 #include "../../../geometry/Geometry.h"
32 #include "../../../maptools/DataSetLayer.h"
33 #include "../../../maptools/DataSetAdapterLayer.h"
34 #include "../../../maptools/QueryLayer.h"
35 #include "../../../statistics/qt/StatisticsDialog.h"
36 
37 // Qt
38 #include <QBoxLayout>
39 #include <QContextMenuEvent>
40 #include <QCursor>
41 #include <QDialogButtonBox>
42 #include <QHeaderView>
43 #include <QLabel>
44 #include <QMenu>
45 #include <QMessageBox>
46 #include <QPainter>
47 #include <QSpinBox>
48 
49 
50 // STL
51 #include <vector>
52 #include <memory>
53 
54 bool IsGeometryColumn(te::da::DataSet* dset, const size_t& col)
55 {
56  return dset->getPropertyDataType(col) == te::dt::GEOMETRY_TYPE;
57 }
58 
59 void GetGeometryColumnsPositions(te::da::DataSet* dset, std::vector<int>& cols)
60 {
61  size_t nProps = dset->getNumProperties();
62 
63  cols.clear();
64 
65  for(size_t i=0; i<nProps; i++)
66  if(IsGeometryColumn(dset, i))
67  cols.push_back((int)i);
68 }
69 
70 std::vector<int> GetHiddenSections(QHeaderView* hView, te::da::DataSet* dset)
71 {
72  std::vector<int> res;
73 
74  int sz = dset->getNumProperties();
75 
76  if(sz > 0)
77  {
78  for (int i=0; i<sz; i++)
79  if(hView->isSectionHidden(i) && !IsGeometryColumn(dset, i))
80  res.push_back(i);
81  }
82 
83  return res;
84 }
85 
86 QMenu* GetHiddenColumnsMenu(QHeaderView* hView, te::da::DataSet* dset, QMenu* hMnu)
87 {
88  std::vector<int> hSecs = GetHiddenSections(hView, dset);
89  std::vector<int>::iterator it;
90 
91  QMenu* mnu = new QMenu(hMnu);
92  mnu->setTitle(QObject::tr("Show hidden column"));
93 
94  if(hSecs.empty())
95  mnu->setEnabled(false);
96  else
97  for(it=hSecs.begin(); it!=hSecs.end(); ++it)
98  {
99  QString cName = hView->model()->headerData(*it, Qt::Horizontal, Qt::DisplayRole).toString();
100  QAction* act = new QAction(mnu);
101 
102  act->setText(cName);
103  act->setData(QVariant(*it));
104 
105  QString tt = QObject::tr("Turns column \"%1\" visible.").arg(cName);
106 
107  act->setToolTip(tt);
108 
109  mnu->addAction(act);
110  }
111 
112  return mnu;
113 }
114 
115 QAction* GetShowAllMenu(QHeaderView* hView, te::da::DataSet* dset, QMenu* hMnu)
116 {
117  QAction* act = new QAction(hMnu);
118  act->setText(QObject::tr("Show all columns"));
119  act->setEnabled(!GetHiddenSections(hView, dset).empty());
120 
121  return act;
122 }
123 
125 {
126  // Getting data source, if it is available
128 
129  if(layer->getType() == "DATASETLAYER")
130  {
131  const te::map::DataSetLayer* l = dynamic_cast<const te::map::DataSetLayer*>(layer);
132 
133  if(l != 0)
135  }
136  else if(layer->getType() == "DATASETADAPTERLAYER")
137  {
138  const te::map::DataSetAdapterLayer* l = dynamic_cast<const te::map::DataSetAdapterLayer*>(layer);
139 
140  if(l != 0)
142  }
143  else if(layer->getType() == "QUERYLAYER")
144  {
145  const te::map::QueryLayer* l = dynamic_cast<const te::map::QueryLayer*>(layer);
146 
147  if(l != 0)
149  }
150 
151  return ds;
152 }
153 
155 {
156  // Getting data source capabilities, if it is available
158 
159  if(ds.get() != 0)
160  {
161  const te::map::DataSetLayer* dl = dynamic_cast<const te::map::DataSetLayer*>(layer);
162 
163  if(dl != 0)
164  return ds->getCapabilities(dl->getDataSetName()).release();
165  }
166 
167  return 0;
168 }
169 
170 std::auto_ptr<te::da::Select> GetSelectExpression(const std::string& datasetName, const std::vector<std::string>& colsNames, const bool& asc)
171 {
172  te::da::Fields fields;
173 
174  fields.push_back(std::auto_ptr<te::da::Field>(new te::da::Field("*")));
175 
176  te::da::From from;
177 
178  from.push_back(std::auto_ptr<te::da::DataSetName>(new te::da::DataSetName(datasetName)));
179 
180  te::da::OrderBy order_by;
181 
182  for(size_t i=0; i<colsNames.size(); i++)
183  order_by.push_back(std::auto_ptr<te::da::OrderByItem>(new te::da::OrderByItem(colsNames[i], (asc) ? te::da::ASC : te::da::DESC)));
184 
185  return std::auto_ptr<te::da::Select>(new te::da::Select(fields, from, order_by));
186 }
187 
188 std::auto_ptr<te::da::Select> GetSelectExpression(const std::string& tableName, const te::da::DataSet* set, const std::vector<int>& cols, const bool& asc)
189 {
190  std::vector<std::string> colsNames;
191 
192  for(size_t i = 0; i < cols.size(); ++i)
193  colsNames.push_back(set->getPropertyName((size_t)cols[i]));
194 
195  return GetSelectExpression(tableName, colsNames, asc);
196 }
197 
198 std::auto_ptr<te::da::DataSet> GetDataSet(const te::map::AbstractLayer* layer, const te::da::DataSet* set, const std::vector<int>& cols, const bool& asc)
199 {
200  std::auto_ptr<te::da::Select> query = GetSelectExpression(layer->getSchema()->getName(), set, cols, asc);
201 
202  try
203  {
204  if(query.get() == 0)
205  throw std::string("Fail to generate query.");
206 
208 
209  if(dsc.get() == 0)
210  throw std::string("Fail to get data source.");
211 
212  return dsc->getTransactor()->query(query.get(), te::common::RANDOM);
213  }
214  catch(...)
215  {
216  return std::auto_ptr<te::da::DataSet>();
217  }
218 }
219 
220 std::auto_ptr<te::da::DataSet> GetDataSet(const te::map::AbstractLayer* layer, const std::vector<std::string>& colsNames, const bool& asc)
221 {
222  std::auto_ptr<te::da::Select> query;
223 
224  if(layer->getType() == "DATASETLAYER")
225  {
226  const te::map::DataSetLayer* l = dynamic_cast<const te::map::DataSetLayer*>(layer);
227 
228  if(l != 0)
229  query = GetSelectExpression(layer->getSchema()->getName(), colsNames, asc);
230  }
231  else if(layer->getType() == "DATASETADAPTERLAYER")
232  {
233  const te::map::DataSetAdapterLayer* l = dynamic_cast<const te::map::DataSetAdapterLayer*>(layer);
234 
235  if(l != 0)
236  query = GetSelectExpression(layer->getSchema()->getName(), colsNames, asc);
237  }
238  else if(layer->getType() == "QUERYLAYER")
239  {
240  const te::map::QueryLayer* l = dynamic_cast<const te::map::QueryLayer*>(layer);
241 
242  if(l != 0)
243  query.reset(new te::da::Select(l->getQuery()));
244  }
245 
246  try
247  {
248  if(query.get() == 0)
249  throw std::string("Fail to generate query.");
250 
252 
253  if(dsc.get() == 0)
254  throw std::string("Fail to get data source.");
255 
256  return dsc->getTransactor()->query(query.get(), te::common::RANDOM);
257  }
258  catch(...)
259  {
260  return std::auto_ptr<te::da::DataSet>();
261  }
262 }
263 
264 std::vector<QString> GetColumnsNames(te::da::DataSet* dset)
265 {
266  std::vector<QString> res;
267 
268  if(dset != 0)
269  {
270  size_t n = dset->getNumProperties();
271 
272  for(size_t i=0; i<n; i++)
273  if(!IsGeometryColumn(dset, i))
274  res.push_back(dset->getPropertyName(i).c_str());
275  }
276 
277  return res;
278 }
279 
280 std::auto_ptr<te::gm::Envelope> GetExtent(te::da::DataSet* dset, te::qt::widgets::Promoter* p, const int& rowPosition)
281 {
282  // Getting last select object bounding rectangle
283  std::vector<int> geoCols;
284 
285  GetGeometryColumnsPositions(dset, geoCols);
286 
287  if(!geoCols.empty())
288  {
289  int rpos = p->getLogicalRow(rowPosition);
290 
291  dset->move(rpos);
292 
293  size_t pos = (size_t)geoCols[0];
294 
295  std::auto_ptr<te::gm::Geometry> g = dset->getGeometry(pos);
296 
297  return std::auto_ptr<te::gm::Envelope> (new te::gm::Envelope(*g->getMBR()));
298  }
299 
300  return std::auto_ptr<te::gm::Envelope>();
301 }
302 
304 {
305  te::qt::widgets::HighlightDelegate* d = dynamic_cast<te::qt::widgets::HighlightDelegate*>(view->itemDelegate());
306 
307  if(d == 0)
308  return false;
309 
310  const te::da::ObjectIdSet* objs = d->getSelected();
311 
312  if(objs == 0)
313  return false;
314 
315  std::vector<size_t> cols = objs->getPropertyPos();
316  std::vector<size_t>::iterator it;
317 
318  for(it = cols.begin(); it != cols.end(); ++it)
319  if((size_t)col == *it)
320  return true;
321 
322  return false;
323 }
324 
326 {
327  if(dset != 0)
328  {
329  std::vector<int> geoCols;
330  std::vector<int>::iterator it;
331  GetGeometryColumnsPositions(dset, geoCols);
332 
333  for(it = geoCols.begin(); it != geoCols.end(); ++it)
334  view->hideColumn(*it);
335  }
336 }
337 
338 /*!
339  \class Filter for popup menus
340 */
341 class TablePopupFilter : public QObject
342 {
343  Q_OBJECT
344 
345  public:
346 
347  /*!
348  \brief Contructor.
349  */
351  QObject(view),
352  m_view(view),
353  m_hMenu(0),
354  m_vMenu(0),
355  m_vportMenu(0),
356  m_dset(0),
357  m_showOidsColumns(false),
358  m_enabled(true),
359  m_autoScrollEnabled(false),
360  m_promotionEnabled(false)
361  {
362  m_view->horizontalHeader()->installEventFilter(this);
363  m_view->verticalHeader()->installEventFilter(this);
364  m_view->viewport()->installEventFilter(this);
365 
366  m_view->connect(this, SIGNAL(createHistogram(const int&)), SLOT(createHistogram(const int&)));
367  m_view->connect(this, SIGNAL(hideColumn(const int&)), SLOT(hideColumn(const int&)));
368  m_view->connect(this, SIGNAL(showColumn(const int&)), SLOT(showColumn(const int&)));
369  m_view->connect(this, SIGNAL(removeColumn(const int&)), SLOT(removeColumn(const int&)));
370  m_view->connect(this, SIGNAL(enableAutoScroll(const bool&)), SLOT(setAutoScrollEnabled(const bool&)));
371  m_view->connect(this, SIGNAL(sortData(const bool&)), SLOT(sortByColumns(const bool&)));
372  m_view->connect(this, SIGNAL(renameColumn(const int&)), SLOT(renameColumn(const int&)));
373  m_view->connect(this, SIGNAL(retypeColumn(const int&)), SLOT(retypeColumn(const int&)));
374  m_view->connect(this, SIGNAL(changeColumnData(const int&)), SLOT(changeColumnData(const int&)));
375  m_view->connect(this, SIGNAL(enablePromotion(const bool&)), SLOT(setPromotionEnabled(const bool&)));
376  m_view->connect(this, SIGNAL(saveEditions()), SLOT(saveEditions()));
377  }
378 
379  /*!
380  \brief Destructor.
381  */
383  {
384  delete m_hMenu;
385  delete m_vMenu;
386  delete m_vportMenu;
387  }
388 
389  bool eventFilter(QObject* watched, QEvent* event)
390  {
391  if(!m_enabled)
392  return QObject::eventFilter(watched, event);
393 
394  QWidget* vport = m_view->viewport();
395  QHeaderView* hHdr = m_view->horizontalHeader();
396  QHeaderView* vHdr = m_view->verticalHeader();
397 
398  switch(event->type())
399  {
400  case QEvent::ContextMenu:
401  {
402  if(watched == hHdr)
403  {
404  delete m_hMenu;
405  m_hMenu = 0;
406 
407  QContextMenuEvent* evt = static_cast<QContextMenuEvent*>(event);
408  QPoint pos = evt->globalPos();
409 
410  m_columnPressed = hHdr->logicalIndex(hHdr->visualIndexAt(evt->pos().x()));
411  bool isPKey = IsPrimaryKey(m_columnPressed, m_view);
412 
413  if(m_columnPressed > 0 && !isPKey)
414  {
415  m_hMenu = new QMenu;
416 
417  QAction* act = new QAction(m_hMenu);
418  act->setText(tr("Hide column"));
419  act->setToolTip(tr("Hides the selected column."));
420 
421  m_hMenu->addAction(act);
422 
423  QMenu* hMnu = GetHiddenColumnsMenu(hHdr, m_dset, m_hMenu);
424 
425  if(m_columnPressed == -1)
426  act->setEnabled(false);
427 
428  m_hMenu->addAction(hMnu->menuAction());
429 
430  QAction* act2 = GetShowAllMenu(hHdr, m_dset, m_hMenu);
431  m_hMenu->addAction(act2);
432 
433  QAction* act3 = new QAction(m_hMenu);
434  act3->setText(tr("Reset columns order"));
435  act3->setToolTip(tr("Put all columns in the original order."));
436  m_hMenu->addAction(act3);
437 
438  m_hMenu->addSeparator();
439 
440  QAction* act5 = new QAction(m_hMenu);
441  act5->setText(tr("Sort data ASC"));
442  act5->setToolTip(tr("Sort data in ascendent order using selected columns."));
443  m_hMenu->addAction(act5);
444 
445  QAction* act9 = new QAction(m_hMenu);
446  act9->setText(tr("Sort data DESC"));
447  act9->setToolTip(tr("Sort data in descendent order using selected columns."));
448  m_hMenu->addAction(act9);
449 
450  m_hMenu->addSeparator();
451 
452  QAction* act4 = new QAction(m_hMenu);
453  act4->setText(tr("Histogram"));
454  act4->setToolTip(tr("Creates a new histogram based on the data of the selected colunm."));
455  m_hMenu->addAction(act4);
456 
457  QAction* act6 = new QAction(m_hMenu);
458  act6->setText(tr("Statistics"));
459  act6->setToolTip(tr("Show the statistics summary of the selected colunm."));
460  m_hMenu->addAction(act6);
461 
462  m_hMenu->addSeparator();
463 
464  // Signal / Slot connections
465  connect(act, SIGNAL(triggered()), SLOT(hideColumn()));
466  connect(hMnu, SIGNAL(triggered(QAction*)), SLOT(showColumn(QAction*)));
467 
468  connect(act4, SIGNAL(triggered()), SLOT(createHistogram()));
469 
470  m_view->connect(act2, SIGNAL(triggered()), SLOT(showAllColumns()));
471  m_view->connect(act3, SIGNAL(triggered()), SLOT(resetColumnsOrder()));
472 
473 
474  connect(act6, SIGNAL(triggered()), SLOT(showStatistics()));
475  connect (act5, SIGNAL(triggered()), SLOT(sortDataAsc()));
476  connect (act9, SIGNAL(triggered()), SLOT(sortDataDesc()));
477 
478 
479  if(m_caps.get())
480  {
481  QAction* act7 = new QAction(m_hMenu);
482  act7->setText(tr("Add column"));
483  act7->setToolTip(tr("Adds a column to the table."));
484  m_hMenu->addAction(act7);
485  act7->setEnabled(m_caps->supportsAddColumn());
486 
487  QAction* act8 = new QAction(m_hMenu);
488  act8->setText(tr("Remove column"));
489  act8->setToolTip(tr("Removes a column from the table."));
490  m_hMenu->addAction(act8);
491  act8->setEnabled(m_caps->supportsRemoveColumn());
492 
493  QAction* act10 = new QAction(m_hMenu);
494  act10->setText(tr("Rename column"));
495  act10->setToolTip(tr("Renames a column of the table."));
496  m_hMenu->addAction(act10);
497 
498  QAction* act11 = new QAction(m_hMenu);
499  act11->setText(tr("Change column type"));
500  act11->setToolTip(tr("Changes the type of a column of the table."));
501  m_hMenu->addAction(act11);
502 
503  QAction* act12 = new QAction(m_hMenu);
504  act12->setText(tr("Change column data"));
505  act12->setToolTip(tr("Changes the data of a column of the table."));
506  m_hMenu->addAction(act12);
507 
508  QAction* act13 = new QAction(m_hMenu);
509  act13->setText(tr("Save editions"));
510  act13->setToolTip(tr("Save pendent editions to layer."));
511  act13->setEnabled(m_view->hasEditions());
512  m_hMenu->addAction(act13);
513 
514  m_view->connect(act7, SIGNAL(triggered()), SLOT(addColumn()));
515 
516  connect(act8, SIGNAL(triggered()), SLOT(removeColumn()));
517  connect (act10, SIGNAL(triggered()), SLOT(renameColumn()));
518  connect (act11, SIGNAL(triggered()), SLOT(retypeColumn()));
519  connect (act12, SIGNAL(triggered()), SLOT(changeColumnData()));
520  connect (act13, SIGNAL(triggered()), SIGNAL(saveEditions()));
521  }
522 
523  m_hMenu->popup(pos);
524  }
525  }
526  else if(watched == vport)
527  {
528  }
529  else if(watched == vHdr)
530  {
531  delete m_vMenu;
532 
533  QContextMenuEvent* evt = static_cast<QContextMenuEvent*>(event);
534  QPoint pos = evt->globalPos();
535 
536  m_vMenu = new QMenu;
537  QAction* act = new QAction(m_vMenu);
538  act->setText(tr("Enable auto scroll"));
539  act->setToolTip(tr("Goes to the selected row."));
540 
541  act->setCheckable(true);
542  act->setChecked(m_autoScrollEnabled);
543 
544  m_vMenu->addAction(act);
545 
546  connect(act, SIGNAL(triggered()), SLOT(setAutoScrollEnabled()));
547 
548  act = new QAction(m_vMenu);
549  act->setText(tr("Enable promotion"));
550  act->setToolTip(tr("Enables promotion of selected rows."));
551 
552  act->setCheckable(true);
553  act->setChecked(m_promotionEnabled);
554 
555  m_vMenu->addSeparator();
556 
557  m_vMenu->addAction(act);
558 
559  connect(act, SIGNAL(triggered()), SLOT(enablePromotion()));
560 
561  m_vMenu->popup(pos);
562  }
563  }
564  break;
565 
566  default:
567  break;
568  }
569 
570  return QObject::eventFilter(watched, event);
571  }
572 
574  {
575  m_dset = dset;
576  }
577 
578  std::vector<int> getHiddenColumns()
579  {
580  return GetHiddenSections(m_view->horizontalHeader(), m_dset);
581  }
582 
583  void setEnabled(const bool& enabled)
584  {
585  m_enabled = enabled;
586  }
587 
589  {
590  m_caps.reset(caps);
591  }
592 
593  void setPromotionEnabled(const bool& enabled)
594  {
595  m_promotionEnabled = enabled;
596  }
597 
598  protected slots:
599 
601  {
603  }
604 
605  void hideColumn()
606  {
608  }
609 
610  void showColumn(QAction* act)
611  {
612  int column = act->data().toInt();
613 
614  emit showColumn(column);
615  }
616 
618  {
619  te::stat::StatisticsDialog statisticDialog;
620  std::string prop = m_dset->getPropertyName(m_columnPressed);
621  statisticDialog.setStatistics(m_dset, prop);
622  statisticDialog.exec();
623  }
624 
626  {
628  }
629 
631  {
633 
635  }
636 
637  void sortDataAsc()
638  {
639  emit sortData(true);
640  }
641 
643  {
644  emit sortData(false);
645  }
646 
648  {
650  }
651 
653  {
655  }
656 
658  {
660  }
661 
663  {
665 
667  }
668 
669  signals:
670 
671  void createHistogram(const int&);
672 
673  void hideColumn(const int&);
674 
675  void showColumn(const int&);
676 
677  void renameColumn(const int&);
678 
679  void retypeColumn(const int&);
680 
681  void changeColumnData(const int&);
682 
683  void selectObject(const int&, const bool&);
684 
685  void selectObjects(const int&, const int&);
686 
687  void enablePromotion(const bool&);
688 
689  void removeColumn(const int&);
690 
691  void enableAutoScroll(const bool&);
692 
693  void sortData(const bool&);
694 
695  void saveEditions();
696 
697  protected:
698 
700  QMenu* m_hMenu;
701  QMenu* m_vMenu;
702  QMenu* m_vportMenu;
704  std::auto_ptr<te::da::DataSetTypeCapabilities> m_caps;
706  bool m_enabled;
710 };
711 
713  QTableView(parent),
714  m_layer(0),
715  m_autoScrollEnabled(false),
716  m_doScroll(true),
717  m_promotionEnabled(false),
718  m_dset(0),
719  m_orderAsc(true)
720 {
721  m_model = new DataSetTableModel(this);
722 
723  setModel(m_model);
724 
725  setVerticalHeader(new DataSetTableVerticalHeader(this));
726  setHorizontalHeader(new DataSetTableHorizontalHeader(this));
727 
728 #if QT_VERSION >= 0x050000
729  horizontalHeader()->setSectionsMovable(true);
730 #else
731  horizontalHeader()->setMovable(true);
732 #endif
733 
734  setSelectionMode(QAbstractItemView::MultiSelection);
735  setSelectionBehavior(QAbstractItemView::SelectColumns);
736 
737  m_popupFilter = new TablePopupFilter(this);
738 
739  m_delegate = new HighlightDelegate(this);
740 
742 
743  m_delegate->setColor(Qt::green);
744 
745  setItemDelegate(m_delegate);
746 
747  connect(verticalHeader(), SIGNAL(selectedRow(const int&, const bool&)), SLOT(highlightRow(const int&, const bool&)));
748  connect(verticalHeader(), SIGNAL(selectedRows(const int&, const int&)), SLOT(highlightRows(const int&, const int&)));
749 }
750 
752 {
753  if (m_model->hasEditions())
754  {
755  QMessageBox msgBox(this);
756  msgBox.setText("There are unsaved changes on table.");
757  msgBox.setInformativeText("Do you want to save your changes?");
758  msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard);
759  msgBox.setDefaultButton(QMessageBox::Save);
760 
761  int ret = msgBox.exec();
762 
763  if(ret == QMessageBox::Save)
764  saveEditions();
765  }
766 }
767 
768 void te::qt::widgets::DataSetTableView::setLayer(const te::map::AbstractLayer* layer, const bool& clearEditor)
769 {
770  ScopedCursor cursor(Qt::WaitCursor);
771 
772  m_layer = layer;
773  std::auto_ptr<te::map::LayerSchema> sch = m_layer->getSchema();
774 
775  if (m_orderby.empty())
776  {
777  std::vector<te::dt::Property*> psps;
778 
779  if(sch->getPrimaryKey())
780  psps = sch->getPrimaryKey()->getProperties();
781  else
782  psps = sch->getProperties();
783 
784  std::vector<te::dt::Property*>::iterator it;
785 
786  for(it = psps.begin(); it != psps.end(); ++it)
787  m_orderby.push_back((*it)->getName());
788  }
789 
790  setDataSet(GetDataSet(m_layer, m_orderby, m_orderAsc).release(), clearEditor);
791  setLayerSchema(sch.get());
792 
794 
795  m_popupFilter->setDataSetTypeCapabilities(caps);
796 
797  if(caps)
798  m_model->setEditable(caps->supportsDataEdition());
799 
800  te::da::DataSourcePtr dsc = GetDataSource(m_layer);
801 
802  if(dsc.get() != 0)
803  {
804  setSelectionMode((dsc->getType().compare("OGR") == 0) ? SingleSelection : MultiSelection);
805  setSelectionBehavior((dsc->getType().compare("OGR") == 0) ? QAbstractItemView::SelectColumns : QAbstractItemView::SelectItems);
806  }
807 
808  highlightOIds(m_layer->getSelected());
809 }
810 
812 {
813  reset();
814 
815  m_model->setDataSet(dset, clearEditor);
816 
817  HideGeometryColumns(dset, this);
818 
819  m_popupFilter->setDataSet(dset);
820  m_delegate->setDataSet(dset);
821  m_dset = dset;
822 }
823 
825 {
826  te::da::ObjectIdSet* objs = 0;
827 
828  te::da::GetEmptyOIDSet(schema, objs);
829 
830  std::auto_ptr<te::da::ObjectIdSet> objs_ptr(objs);
831 
832  m_delegate->setObjectIdSet(objs_ptr.get());
833 
834  m_model->setPkeysColumns(objs_ptr->getPropertyPos());
835 
836  m_model->getPromoter()->preProcessKeys(m_dset, objs_ptr->getPropertyPos());
837 }
838 
840 {
841  if(oids == 0)
842  return;
843 
844  m_delegate->setObjectIdSet(oids);
845 
846  if(m_autoScrollEnabled && oids != 0 && oids->size() > 0)
847  {
848  size_t row = m_model->getPromoter()->map2Row(*oids->begin());
849 
850  scrollTo(m_model->index((int)row, 0));
851  }
852 
853  if(m_promotionEnabled)
854  promote(m_doScroll);
855 
856  viewport()->repaint();
857 }
858 
860 {
861  m_delegate->setColor(color);
862 
863  repaint();
864 }
865 
867 {
868  return m_model->hasEditions();
869 }
870 
872 {
873  int propType = m_dset->getPropertyDataType(column);
874 
875  if(propType == te::dt::DATETIME_TYPE || propType == te::dt::STRING_TYPE)
876  emit createChartDisplay(te::qt::widgets::createHistogramDisplay(m_dset, m_layer->getSchema().get(), column));
877  else
878  {
879  QDialog* dialog = new QDialog(this);
880  dialog->setFixedSize(160, 75);
881 
882  QBoxLayout* vLayout = new QBoxLayout(QBoxLayout::TopToBottom, dialog);
883  QBoxLayout* hLayout = new QBoxLayout(QBoxLayout::LeftToRight, dialog);
884 
885  QLabel* slicesProp = new QLabel(QString::fromStdString("Number of Slices: "), dialog);
886  hLayout->addWidget(slicesProp);
887 
888  QSpinBox* slicesSB = new QSpinBox(dialog);
889  slicesSB->setValue(5);
890  slicesSB->setMinimum(2);
891 
892  hLayout->addWidget(slicesSB);
893  vLayout->addLayout(hLayout);
894 
895  QDialogButtonBox* bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, dialog);
896  connect(bbox, SIGNAL(accepted()), dialog, SLOT(accept()));
897  connect(bbox, SIGNAL(rejected()), dialog, SLOT(reject()));
898  vLayout->addWidget(bbox);
899 
900  int res = dialog->exec();
901  if (res == QDialog::Accepted)
902  emit createChartDisplay(te::qt::widgets::createHistogramDisplay(m_dset, m_layer->getSchema().get(), column, slicesSB->value()));
903 
904  delete dialog;
905  }
906 }
907 
909 {
910  horizontalHeader()->hideSection(column);
911 }
912 
914 {
915  horizontalHeader()->showSection(column);
916 }
917 
919 {
920  RenameColumnDialog dlg(parentWidget());
921 
922  dlg.setOldColumnName(QString::fromStdString(m_dset->getPropertyName(column)));
923 
924  if(dlg.exec() == QDialog::Accepted)
925  {
926  std::string oldName = dlg.getOldName().toStdString();
927  std::string newName = dlg.getNewName().toStdString();
928  te::da::DataSourcePtr dsrc = GetDataSource(m_layer);
929 
930  if(dsrc.get() == 0)
931  throw Exception(tr("Fail to get data source.").toStdString());
932 
933  if(!dsrc->isPropertyNameValid(newName))
934  throw Exception(tr("Invalid column name. Choose another.").toStdString());
935 
936  dsrc->renameProperty(m_layer->getSchema()->getName(), oldName, newName);
937 
938  setLayer(m_layer);
939  }
940 }
941 
943 {
944  RetypeColumnDialog dlg(parentWidget());
945 
946  std::auto_ptr<te::da::DataSetType> schema = m_layer->getSchema();
947  te::dt::Property* prp;
948  std::string dsetName = schema->getName();
949  std::string columnName;
950 
951  prp = schema->getProperty(column);
952 
953  if(prp == 0)
954  throw Exception(tr("Fail to get property of the dataset.").toStdString());
955 
956  columnName = prp->getName();
957 
958  dlg.setTableName(dsetName.c_str());
959  dlg.setColumnName(columnName.c_str());
960  dlg.setType(prp->getType());
961 
962  if(dlg.exec() == QDialog::Accepted)
963  {
964  te::da::DataSourcePtr dsrc = GetDataSource(m_layer);
965 
966  if(dsrc.get() == 0)
967  throw Exception(tr("Fail to get data source.").toStdString());
968 
969  setDataSet(0);
970 
971  dsrc->changePropertyDefinition(dsetName, columnName, dlg.getProperty().release());
972 
973  setLayer(m_layer);
974  }
975 }
976 
978 {
979  if(m_dset == 0 || m_layer == 0)
980  return;
981 
982  std::auto_ptr<te::da::DataSetType> schema = m_layer->getSchema();
983  std::string dsetName = schema->getName();
984  std::string columnName = schema->getProperty(column)->getName();
985  std::vector<QString> cols = GetColumnsNames(m_dset);
986 
987  AlterDataDialog dlg(parentWidget());
988  dlg.setSelectedColumn(columnName.c_str());
989  dlg.setDataColumns(cols);
990 
991  if(dlg.exec() == QDialog::Accepted)
992  {
993  te::da::DataSourcePtr dsrc = GetDataSource(m_layer);
994 
995  if(dsrc.get() == 0)
996  throw Exception(tr("Fail to get data source.").toStdString());
997 
998  std::string sql;
999 
1000  if(dlg.alterAllData())
1001  sql = "UPDATE " + dsetName + " SET " + columnName + " = " + dlg.getExpression().toStdString();
1002 
1003  try
1004  {
1005  dsrc->execute(sql);
1006  setLayer(m_layer);
1007  }
1008  catch(te::common::Exception& e)
1009  {
1010  QMessageBox::information(this, tr("Updating data failure"), e.what());
1011  }
1012  catch(...)
1013  {
1014  QMessageBox::information(this, tr("Updating data failure"), tr("Data source operation fail for unknown reason."));
1015  }
1016  }
1017 }
1018 
1020 {
1021  std::vector<int> hCols = m_popupFilter->getHiddenColumns();
1022  std::vector<int>::iterator it;
1023 
1024  for (it=hCols.begin(); it!=hCols.end(); ++it)
1025  horizontalHeader()->showSection(*it);
1026 }
1027 
1029 {
1030  QHeaderView* hdr = horizontalHeader();
1031 
1032  int nCols = hdr->count();
1033 
1034  for(int i=0; i<nCols; i++)
1035  {
1036  int visCol = hdr->visualIndex(i);
1037 
1038  if(visCol != i)
1039  hdr->moveSection(visCol, i);
1040  }
1041 }
1042 
1043 void te::qt::widgets::DataSetTableView::highlightRow(const int& row, const bool& add)
1044 {
1045  te::da::ObjectIdSet* oids = m_model->getObjectIdSet(row, row);
1046 
1047  if(add)
1048  {
1049  te::da::ObjectId* oid = *oids->begin();
1050 
1051  if(m_delegate->getSelected()->contains(oid))
1052  {
1053  emit deselectOIds(oids);
1054 
1055  delete oids;
1056 
1057  m_delegate->setObjectIdSet(m_layer->getSelected());
1058 
1059  if(m_promotionEnabled)
1060  promote();
1061 
1062  viewport()->repaint();
1063 
1064  return;
1065  }
1066  }
1067 
1068  m_doScroll = false;
1069 
1070  emit selectOIds(oids, add, GetExtent(m_dset, m_model->getPromoter(), row).get());
1071 
1072  if(m_promotionEnabled)
1073  promote();
1074 
1075  viewport()->repaint();
1076 
1077  m_doScroll = true;
1078 }
1079 
1080 void te::qt::widgets::DataSetTableView::highlightRows(const int& initRow, const int& finalRow)
1081 {
1082  int ini,
1083  final;
1084 
1085  if(initRow < finalRow)
1086  {
1087  ini = initRow;
1088  final = finalRow;
1089  }
1090  else
1091  {
1092  ini = finalRow;
1093  final = initRow;
1094  }
1095 
1096  te::da::ObjectIdSet* oids = m_model->getObjectIdSet(ini, final);
1097 
1098  m_doScroll = false;
1099 
1100  emit selectOIds(oids, true, GetExtent(m_dset, m_model->getPromoter(), final).get());
1101 
1102  if(m_promotionEnabled)
1103  promote();
1104 
1105  viewport()->repaint();
1106 
1107  m_doScroll = false;
1108 }
1109 
1111 {
1112  ScopedCursor cursor(Qt::WaitCursor);
1113 
1114  setEnabled(false);
1115  m_model->setEnabled(false);
1116  m_popupFilter->setEnabled(false);
1117 
1118  const te::da::ObjectIdSet* oids = m_delegate->getSelected();
1119  m_model->promote(oids);
1120 
1121  m_popupFilter->setEnabled(true);
1122  m_model->setEnabled(true);
1123  setEnabled(true);
1124 
1125  viewport()->repaint();
1126 
1127  if(scroll)
1128  scrollToTop();
1129 }
1130 
1132 {
1133  //*********************
1134  // Sort by query
1135  //*********************
1136  try
1137  {
1138  ScopedCursor cursor(Qt::WaitCursor);
1139 
1140  std::vector<int> selCols;
1141 
1142  m_orderby.clear();
1143 
1144  int nCols = model()->columnCount();
1145 
1146  for(int i=0; i<nCols; i++)
1147  {
1148  int logRow = horizontalHeader()->logicalIndex(i);
1149  if(selectionModel()->isColumnSelected(logRow, QModelIndex()))
1150  {
1151  m_orderby.push_back(m_dset->getPropertyName((size_t)logRow));
1152  selCols.push_back(logRow);
1153  }
1154  }
1155 
1156  if(selCols.empty())
1157  return;
1158 
1159  std::auto_ptr<te::da::DataSet> dset = GetDataSet(m_layer, m_orderby, asc);
1160 
1161  if(dset.get() == 0)
1162  throw te::common::Exception(tr("Sort operation not supported by the source of data.").toStdString());
1163 
1164  setDataSet(dset.release());
1165 
1166  viewport()->repaint();
1167 
1168  setUpdatesEnabled(false);
1169 
1170  m_model->getPromoter()->preProcessKeys(m_dset, m_delegate->getSelected()->getPropertyPos());
1171 
1172  setUpdatesEnabled(true);
1173 
1174  if(m_promotionEnabled)
1175  promote();
1176  }
1177  catch(te::common::Exception& e)
1178  {
1179  QMessageBox::information(this, tr("Sorting columns failure"), tr("Could not sort data: ") + e.what());
1180  }
1181 }
1182 
1184 {
1185  m_model->showOIdsVisible(visible);
1186 
1187  horizontalHeader()->viewport()->repaint();
1188 }
1189 
1191 {
1192  if(m_layer == 0)
1193  return;
1194 
1195  try
1196  {
1197  AddColumnDialog dlg(parentWidget());
1198 
1199  std::auto_ptr<te::da::DataSetType> ds_t = m_layer->getSchema();
1200 
1201  std::string dsName = ds_t->getName();
1202  size_t n_prop = ds_t->getProperties().size();
1203  dlg.setTableName(dsName);
1204 
1205  if(dlg.exec() == QDialog::Accepted)
1206  {
1207  te::da::DataSourcePtr ds = GetDataSource(m_layer);
1208 
1209  if(ds.get() == 0)
1210  throw te::common::Exception(tr("Fail to get data source of the layer.").toStdString());
1211 
1212  std::auto_ptr<te::dt::Property> p(dlg.getNewProperty());
1213 
1214  if(p->getName().empty())
1215  throw te::common::Exception(tr("Name must not be empty.").toStdString());
1216 
1217  if(!ds->isPropertyNameValid(p->getName()))
1218  throw te::common::Exception(tr("The property name is invalid.").toStdString());
1219 
1220  if(ds->propertyExists(dsName, p->getName()))
1221  throw te::common::Exception(tr("There already exists a property with this name.").toStdString());
1222 
1223  ds->addProperty(dsName, p.get());
1224 
1225  if(ds->getType().compare("OGR") == 0)
1226  m_model->insertColumns(((int)n_prop-1), 0);
1227 
1228  setLayer(m_layer, false);
1229  }
1230  }
1231  catch(te::common::Exception& e)
1232  {
1233  QMessageBox::information(this, tr("Creating column failure"), tr("The column could not be created: ") + e.what());
1234  }
1235 }
1236 
1238 {
1239  try
1240  {
1241  if(QMessageBox::question(this, tr("Remove column"), tr("Are you sure you want to remove this column?"), QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
1242  {
1243  te::da::DataSourcePtr ds = GetDataSource(m_layer);
1244 
1245  if(ds.get() == 0)
1246  throw te::common::Exception(tr("Fail to get data source of the layer.").toStdString());
1247 
1248  std::auto_ptr<te::da::DataSetType> ds_t = m_layer->getSchema();
1249  std::string dsName = ds_t->getName();
1250 
1251  std::string pName = ds_t->getProperty(column)->getName();
1252 
1253  ds->dropProperty(dsName, pName);
1254 
1255  m_model->removeColumns(column, 0);
1256 
1257  setLayer(m_layer, false);
1258  }
1259  }
1260  catch(te::common::Exception& e)
1261  {
1262  QMessageBox::information(this, tr("Removing column failure"), tr("The column could not be removed: ") + e.what());
1263  }
1264 }
1265 
1267 {
1268  m_autoScrollEnabled = enable;
1269 }
1270 
1272 {
1273  m_promotionEnabled = enable;
1274 
1275  if(m_promotionEnabled)
1276  promote();
1277 
1278  m_popupFilter->setPromotionEnabled(m_promotionEnabled);
1279 }
1280 
1281 void te::qt::widgets::DataSetTableView::removeSelection(const int& initRow, const int& finalRow)
1282 {
1283  QItemSelection toRemove;
1284 
1285  for(int i=initRow; i<=finalRow; i++)
1286  {
1287  QModelIndexList idx = selectionModel()->selectedColumns(i);
1288 
1289  if(!idx.empty())
1290  toRemove.select(idx.first(), idx.last());
1291  }
1292 
1293  selectionModel()->select(toRemove, QItemSelectionModel::Deselect);
1294 }
1295 
1297 {
1298  try
1299  {
1300  ScopedCursor c(Qt::WaitCursor);
1301 
1302  std::vector< std::set<int> > ed;
1303 
1304  std::auto_ptr<te::map::LayerSchema> sch = m_layer->getSchema();
1305 
1306  std::auto_ptr<te::da::DataSet> md = m_model->getEditions(sch.get(), ed);
1307 
1308  te::da::DataSourcePtr ds = GetDataSource(m_layer);
1309 
1310  if(ds.get() == 0)
1311  throw te::common::Exception(tr("Fail to get data source from layer").toStdString());
1312 
1313  te::da::ObjectIdSet* objs = 0;
1314 
1315  te::da::GetEmptyOIDSet(sch.get(), objs);
1316 
1317  std::auto_ptr<te::da::ObjectIdSet> objs1(objs);
1318 
1319  ds->update(sch->getName(), md.get(), ed, objs1->getPropertyPos());
1320 
1321  setLayer(m_layer);
1322  }
1323  catch(te::common::Exception& e)
1324  {
1325  QMessageBox::warning(this, tr("Save edition failure"), e.what());
1326  }
1327 }
1328 
1329 #include "DataSetTableView.moc"
1330 
virtual const std::string & getType() const =0
It returns the layer type.
void sortByColumns(const bool &asc)
Sort by the selected columns.
A Qt dialog for reset data of a column in the table.
std::auto_ptr< te::dt::Property > getProperty()
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 &)
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 & getDataSetName() 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...
Definition: Field.h:50
TEDATAACCESSEXPORT void GetEmptyOIDSet(const DataSetType *type, ObjectIdSet *&set)
Returns an empty ObjectIdSet, with the definitions of fields that compose it.
Definition: Utils.cpp:283
TEQTWIDGETSEXPORT ChartDisplayWidget * createHistogramDisplay(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propId, int slices=10)
Histogram Creator.
Definition: Utils.cpp:517
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.
This is the base class for layers.
Definition: AbstractLayer.h:76
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1435
void promote(const bool &scroll=false)
Promotes the highlighted rows.
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.
Definition: Exception.cpp:58
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...
void retypeColumn(const int &column)
Changes teh type of a column in the table.
~TablePopupFilter()
Destructor.
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
A layer resulting from a query.
Definition: QueryLayer.h:50
void renameColumn(const int &column)
Rename a column of the table.
te::da::DataSet * m_dset
std::auto_ptr< te::da::DataSetTypeCapabilities > m_caps
It models a property definition.
Definition: Property.h:59
void setOldColumnName(const QString &name)
void setTableName(const QString &name)
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)
bool eventFilter(QObject *watched, QEvent *event)
te::da::DataSourcePtr GetDataSource(const te::map::AbstractLayer *layer)
std::auto_ptr< te::da::DataSet > GetDataSet(const te::map::AbstractLayer *layer, const te::da::DataSet *set, const std::vector< int > &cols, const bool &asc)
void setDataSet(te::da::DataSet *dset, const bool &clearEditor=true)
Updates the data set being visualized.
A layer with reference to a DataSetTypeConverter.
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.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
const std::string & getDataSourceId() const
void showAllColumns()
Shows all hidden columns.
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:53
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
A Qt dialog for inserting columns into a table.
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
std::size_t size() const
It returns the object id set size.
void GetGeometryColumnsPositions(te::da::DataSet *dset, std::vector< int > &cols)
const std::string & getDataSourceId() const
TEDATAACCESSEXPORT void Save(const std::string &fileName)
Definition: Serializer.cpp:197
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
void setLayer(const te::map::AbstractLayer *layer, const bool &clearEditor=true)
Sets the layer to be presented.
void highlightOIds(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
bool IsPrimaryKey(const int &col, te::qt::widgets::DataSetTableView *view)
const std::string & getDataSourceId() const
Definition: QueryLayer.cpp:291
TablePopupFilter * m_popupFilter
The menus popup filter.
void showColumn(QAction *act)
te::da::Select * getQuery() const
Definition: QueryLayer.cpp:279
bool hasEditions() const
Returns true if there are unsaved editions e false if there is not.
A class used for logical ordering of rows.
Definition: Promoter.h:69
QAction * GetShowAllMenu(QHeaderView *hView, te::da::DataSet *dset, QMenu *hMnu)
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
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 &)
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:143
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
void setDataSetTypeCapabilities(te::da::DataSetTypeCapabilities *caps)
void highlightRows(const int &initRow, const int &finalRow)
Select all rows from initRow to finalRow.
std::auto_ptr< te::gm::Envelope > GetExtent(te::da::DataSet *dset, te::qt::widgets::Promoter *p, const int &rowPosition)
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.
void setDataColumns(const std::vector< QString > &cols)
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
std::auto_ptr< te::da::Select > GetSelectExpression(const std::string &datasetName, const std::vector< std::string > &colsNames, const bool &asc)
A delegate for highlight the selected object ids.
size_t getLogicalRow(const size_t &visualRow)
Returns the logical position of the row visualRow.
Definition: Promoter.cpp:181
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
void sortData(const bool &)
A table model representing a te::da::DataSet.
QMenu * GetHiddenColumnsMenu(QHeaderView *hView, te::da::DataSet *dset, QMenu *hMnu)
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.
void setHighlightColor(const QColor &color)
Update the color to be used.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
std::vector< int > getHiddenColumns()
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
void showColumn(const int &column)
Shows the hidden column.
void saveEditions()
Saves all editions to the dataset.
void removeColumn(const int &column)
void setAutoScrollEnabled(const bool &enable)
Enable / disable auto-scroll.
void resetColumnsOrder()
Shows columns in the original order.
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48
void setPromotionEnabled(const bool &enable)
Enable / disable promotion.
virtual std::auto_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
A vertical header used for selecting rows at a table view.
const std::string & getName() const
It returns the property name.
Definition: Property.h:126
void setPromotionEnabled(const bool &enabled)