All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataSetTableView.cpp
Go to the documentation of this file.
1 #include "AddColumnDialog.h"
2 #include "DataSetTableView.h"
3 #include "DataSetTableModel.h"
4 #include "HighlightDelegate.h"
6 #include "Promoter.h"
7 
8 // TerraLib include files
9 #include "../../../common/Exception.h"
10 #include "../../../dataaccess/dataset/DataSet.h"
11 #include "../../../dataaccess/dataset/ObjectId.h"
12 #include "../../../dataaccess/dataset/ObjectIdSet.h"
13 #include "../../../dataaccess/datasource/DataSourceCapabilities.h"
14 #include "../../../dataaccess/datasource/DataSourceManager.h"
15 #include "../../../dataaccess/datasource/DataSourceTransactor.h"
16 #include "../../../dataaccess/query/DataSetName.h"
17 #include "../../../dataaccess/query/Field.h"
18 #include "../../../dataaccess/query/From.h"
19 #include "../../../dataaccess/query/OrderBy.h"
20 #include "../../../dataaccess/query/OrderByItem.h"
21 #include "../../../dataaccess/query/Select.h"
22 #include "../../../dataaccess/utils/Utils.h"
23 #include "../../../maptools/DataSetLayer.h"
24 #include "../../../statistics/qt/StatisticsDialog.h"
25 #include "../utils/ScopedCursor.h"
26 
27 
28 // Qt
29 #include <QtGui/QHeaderView>
30 #include <QtGui/QContextMenuEvent>
31 #include <QtGui/QMenu>
32 #include <QtGui/QCursor>
33 #include <QtGui/QPainter>
34 #include <QtGui/QMessageBox>
35 
36 // STL
37 #include <vector>
38 #include <memory>
39 
40 bool IsGeometryColumn(te::da::DataSet* dset, const size_t& col)
41 {
42  return dset->getPropertyDataType(col) == te::dt::GEOMETRY_TYPE;
43 }
44 
45 void GetGeometryColumnsPositions(te::da::DataSet* dset, std::vector<int>& cols)
46 {
47  size_t nProps = dset->getNumProperties();
48 
49  cols.clear();
50 
51  for(size_t i=0; i<nProps; i++)
52  if(IsGeometryColumn(dset, i))
53  cols.push_back((int)i);
54 }
55 
56 std::vector<int> GetHiddenSections(QHeaderView* hView, te::da::DataSet* dset)
57 {
58  std::vector<int> res;
59 
60  int sz = hView->count();
61 
62  if(sz > 0)
63  {
64  for (int i=0; i<sz; i++)
65  if(hView->isSectionHidden(i) && !IsGeometryColumn(dset, i))
66  res.push_back(i);
67  }
68 
69  return res;
70 }
71 
72 QMenu* GetHiddenColumnsMenu(QHeaderView* hView, te::da::DataSet* dset, QMenu* hMnu)
73 {
74  std::vector<int> hSecs = GetHiddenSections(hView, dset);
75  std::vector<int>::iterator it;
76 
77  QMenu* mnu = new QMenu(hMnu);
78  mnu->setTitle(QObject::tr("Show hidden column"));
79 
80  if(hSecs.empty())
81  mnu->setEnabled(false);
82  else
83  for(it=hSecs.begin(); it!=hSecs.end(); ++it)
84  {
85  QString cName = hView->model()->headerData(*it, Qt::Horizontal, Qt::DisplayRole).toString();
86  QAction* act = new QAction(mnu);
87 
88  act->setText(cName);
89  act->setData(QVariant(*it));
90  act->setToolTip(QObject::tr("Turns column \"") + cName + "\" visible.");
91 
92  mnu->addAction(act);
93  }
94 
95  return mnu;
96 }
97 
98 QAction* GetShowAllMenu(QHeaderView* hView, te::da::DataSet* dset, QMenu* hMnu)
99 {
100  QAction* act = new QAction(hMnu);
101  act->setText(QObject::tr("Show all columns"));
102  act->setEnabled(!GetHiddenSections(hView, dset).empty());
103 
104  return act;
105 }
106 
108 {
109  // Getting data source, if it is available
111 
112  const te::map::DataSetLayer* l = dynamic_cast<const te::map::DataSetLayer*>(layer);
113 
114  if(l != 0)
116 
117  return ds;
118 }
119 
121 {
122  // Getting data source capabilities, if it is available
124 
125  if(ds.get() != 0)
126  return (&ds->getCapabilities());
127 
128  return 0;
129 }
130 
131 std::auto_ptr<te::da::Select> GetSelectExpression(const std::string& tableName, const te::da::DataSet* set, const std::vector<int>& cols, const bool& asc)
132 {
133  te::da::Fields fields;
134 
135  fields.push_back(std::auto_ptr<te::da::Field>(new te::da::Field("*")));
136 
137  te::da::From from;
138 
139  from.push_back(std::auto_ptr<te::da::DataSetName>(new te::da::DataSetName(tableName)));
140 
141  te::da::OrderBy order_by;
142 
143  for(size_t i=0; i<cols.size(); i++)
144  order_by.push_back(std::auto_ptr<te::da::OrderByItem>(new te::da::OrderByItem(set->getPropertyName(cols[(int)i]), (asc) ? te::da::ASC : te::da::DESC)));
145 
146  return std::auto_ptr<te::da::Select>(new te::da::Select(fields, from, order_by));
147 }
148 
149 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)
150 {
151  std::auto_ptr<te::da::Select> query = GetSelectExpression(layer->getSchema()->getName(), set, cols, asc);
152 
153  try
154  {
155  if(query.get() == 0)
156  throw std::string("Fail to generate query.");
157 
159 
160  if(dsc.get() == 0)
161  throw std::string("Fail to get data source.");
162 
163  return dsc->getTransactor()->query(query.get(), te::common::RANDOM);
164  }
165  catch(...)
166  {
167  return std::auto_ptr<te::da::DataSet>();
168  }
169 }
170 
171 /*!
172  \class Filter for popup menus
173 */
174 class TablePopupFilter : public QObject
175 {
176  Q_OBJECT
177 
178  public:
179 
180  /*!
181  \brief Contructor.
182  */
184  QObject(view),
185  m_view(view),
186  m_hMenu(0),
187  m_vMenu(0),
188  m_vportMenu(0),
189  m_dset(0),
190  m_caps(0),
191  m_showOidsColumns(false),
192  m_enabled(true),
193  m_autoScrollEnabled(false)
194  {
195  m_view->horizontalHeader()->installEventFilter(this);
196  m_view->verticalHeader()->installEventFilter(this);
197  m_view->viewport()->installEventFilter(this);
198 
199  m_view->connect(this, SIGNAL(hideColumn(const int&)), SLOT(hideColumn(const int&)));
200  m_view->connect(this, SIGNAL(showColumn(const int&)), SLOT(showColumn(const int&)));
201  m_view->connect(this, SIGNAL(removeColumn(const int&)), SLOT(removeColumn(const int&)));
202  m_view->connect(this, SIGNAL(enableAutoScroll(const bool&)), SLOT(setAutoScrollEnabled(const bool&)));
203  m_view->connect(this, SIGNAL(sortData(const bool&)), SLOT(sortByColumns(const bool&)));
204  }
205 
206  /*!
207  \brief Destructor.
208  */
210  {
211  delete m_hMenu;
212  delete m_vMenu;
213  delete m_vportMenu;
214  }
215 
216  bool eventFilter(QObject* watched, QEvent* event)
217  {
218  if(!m_enabled)
219  return QObject::eventFilter(watched, event);
220 
221  QWidget* vport = m_view->viewport();
222  QHeaderView* hHdr = m_view->horizontalHeader();
223  QHeaderView* vHdr = m_view->verticalHeader();
224 
225  switch(event->type())
226  {
227  case QEvent::ContextMenu:
228  {
229  if(watched == hHdr)
230  {
231  delete m_hMenu;
232 
233  QContextMenuEvent* evt = static_cast<QContextMenuEvent*>(event);
234  QPoint pos = evt->globalPos();
235 
236  m_columnPressed = hHdr->logicalIndex(hHdr->visualIndexAt(evt->pos().x()));
237 
238  m_hMenu = new QMenu;
239 
240  QAction* act = new QAction(m_hMenu);
241  act->setText(tr("Hide column"));
242  act->setToolTip(tr("Hides the selected column."));
243 
244  m_hMenu->addAction(act);
245 
246  QMenu* hMnu = GetHiddenColumnsMenu(hHdr, m_dset, m_hMenu);
247 
248  if(m_columnPressed == -1)
249  act->setEnabled(false);
250 
251  m_hMenu->addAction(hMnu->menuAction());
252 
253  QAction* act2 = GetShowAllMenu(hHdr, m_dset, m_hMenu);
254  m_hMenu->addAction(act2);
255 
256  QAction* act3 = new QAction(m_hMenu);
257  act3->setText(tr("Reset columns order"));
258  act3->setToolTip(tr("Put all columns in the original order."));
259  m_hMenu->addAction(act3);
260 
261  m_hMenu->addSeparator();
262 
263  QAction* act5 = new QAction(m_hMenu);
264  act5->setText(tr("Sort data ASC"));
265  act5->setToolTip(tr("Sort data in ascendent order using selected columns."));
266  m_hMenu->addAction(act5);
267 
268  QAction* act9 = new QAction(m_hMenu);
269  act9->setText(tr("Sort data DESC"));
270  act9->setToolTip(tr("Sort data in descendent order using selected columns."));
271  m_hMenu->addAction(act9);
272 
273  m_hMenu->addSeparator();
274 
275  QAction* act6 = new QAction(m_hMenu);
276  act6->setText(tr("Statistics"));
277  act6->setToolTip(tr("Show the statistics summary of the selected colunm."));
278  m_hMenu->addAction(act6);
279 
280  m_hMenu->addSeparator();
281 
282  QAction* act7 = new QAction(m_hMenu);
283  act7->setText(tr("Add column"));
284  act7->setToolTip(tr("Adds a column to the table."));
285  m_hMenu->addAction(act7);
286 
287  bool updatePermition = false;
289  updatePermition = true;
290 
291  act7->setEnabled(updatePermition);
292 
293  QAction* act8 = new QAction(m_hMenu);
294  act8->setText(tr("Remove column"));
295  act8->setToolTip(tr("Removes a column from the table."));
296  m_hMenu->addAction(act8);
297 
298  act8->setEnabled(updatePermition);
299 
300  // Signal / Slot connections
301  connect(act, SIGNAL(triggered()), SLOT(hideColumn()));
302  connect(hMnu, SIGNAL(triggered(QAction*)), SLOT(showColumn(QAction*)));
303  connect(act8, SIGNAL(triggered()), SLOT(removeColumn()));
304 
305  m_view->connect(act2, SIGNAL(triggered()), SLOT(showAllColumns()));
306  m_view->connect(act3, SIGNAL(triggered()), SLOT(resetColumnsOrder()));
307  m_view->connect(act7, SIGNAL(triggered()), SLOT(addColumn()));
308 
309  connect(act6, SIGNAL(triggered()), SLOT(showStatistics()));
310  connect (act5, SIGNAL(triggered()), SLOT(sortDataAsc()));
311  connect (act9, SIGNAL(triggered()), SLOT(sortDataDesc()));
312 
313  m_hMenu->popup(pos);
314  }
315  else if(watched == vport)
316  {
317  }
318  else if(watched == vHdr)
319  {
320  delete m_vMenu;
321 
322  QContextMenuEvent* evt = static_cast<QContextMenuEvent*>(event);
323  QPoint pos = evt->globalPos();
324 
325  m_vMenu = new QMenu;
326  QAction* act = new QAction(m_vMenu);
327  act->setText(tr("Enable auto scroll"));
328  act->setToolTip(tr("Goes to the selected row."));
329 
330  act->setCheckable(true);
331  act->setChecked(m_autoScrollEnabled);
332 
333  m_vMenu->addAction(act);
334 
335  connect(act, SIGNAL(triggered()), SLOT(setAutoScrollEnabled()));
336 
337  m_vMenu->addSeparator();
338 
339  act = new QAction(m_vportMenu);
340  act->setText(tr("Promote selected rows"));
341  act->setToolTip(tr("Reorder rows"));
342  m_vMenu->addAction(act);
343 
344  m_view->connect(act, SIGNAL(triggered()), SLOT(promote()));
345 
346  m_vMenu->popup(pos);
347  }
348  }
349  break;
350 
351  default:
352  break;
353  }
354 
355  return QObject::eventFilter(watched, event);
356  }
357 
359  {
360  m_dset = dset;
361  }
362 
363  std::vector<int> getHiddenColumns()
364  {
365  return GetHiddenSections(m_view->horizontalHeader(), m_dset);
366  }
367 
368  void setEnabled(const bool& enabled)
369  {
370  m_enabled = enabled;
371  }
372 
374  {
375  m_caps = caps;
376  }
377 
378  protected slots:
379 
380  void hideColumn()
381  {
383  }
384 
385  void showColumn(QAction* act)
386  {
387  int column = act->data().toInt();
388 
389  emit showColumn(column);
390  }
391 
393  {
394  te::stat::StatisticsDialog statisticDialog;
395  std::string prop = m_dset->getPropertyName(m_columnPressed);
396  statisticDialog.setStatistics(m_dset, prop);
397  statisticDialog.exec();
398  }
399 
401  {
403  }
404 
406  {
408 
410  }
411 
412  void sortDataAsc()
413  {
414  emit sortData(true);
415  }
416 
418  {
419  emit sortData(false);
420  }
421 
422  signals:
423 
424  void hideColumn(const int&);
425 
426  void showColumn(const int&);
427 
428  void selectObject(const int&, const bool&);
429 
430  void selectObjects(const int& initRow, const int& finalRow);
431 
432  void promote();
433 
434  void removeColumn(const int&);
435 
436  void enableAutoScroll(const bool&);
437 
438  void sortData(const bool&);
439 
440  protected:
441 
443  QMenu* m_hMenu;
444  QMenu* m_vMenu;
445  QMenu* m_vportMenu;
449  bool m_enabled;
452 };
453 
455 QTableView(parent),
456 m_layer(0),
457 m_autoScrollEnabled(false),
458 m_isSorted(false),
459 m_isPromoted(false),
460 m_dset(0)
461 {
462  m_model = new DataSetTableModel(this);
463 
464  setModel(m_model);
465 
466  horizontalHeader()->setMovable(true);
467  setVerticalHeader(new DataSetTableVerticalHeader(this));
468 
469  setSelectionMode(QAbstractItemView::MultiSelection);
470 
471  m_popupFilter = new TablePopupFilter(this);
472 
473  m_delegate = new HighlightDelegate(this);
474 
476 
477  m_delegate->setColor(Qt::green);
478 
479  setItemDelegate(m_delegate);
480 
481  connect(verticalHeader(), SIGNAL(selectedRow(const int&, const bool&)), SLOT(highlightRow(const int&, const bool&)));
482  connect(verticalHeader(), SIGNAL(selectedRows(const int&, const int&)), SLOT(highlightRows(const int&, const int&)));
483 }
484 
486 {
487 }
488 
490 {
491  ScopedCursor cursor(Qt::WaitCursor);
492 
493  m_layer = layer;
494  setDataSet(m_layer->getData(te::common::RANDOM).release());
495  setLayerSchema(m_layer->getSchema().get());
496 
497  m_popupFilter->setDataSourceCapabilities(GetCapabilities(m_layer));
498 
499  te::da::DataSourcePtr dsc = GetDataSource(m_layer);
500 
501  if(dsc.get() != 0)
502  {
503  setSelectionMode((dsc->getType().compare("OGR") == 0) ? SingleSelection : MultiSelection);
504  setSelectionBehavior((dsc->getType().compare("OGR") == 0) ? QAbstractItemView::SelectColumns : QAbstractItemView::SelectItems);
505  }
506 }
507 
509 {
510  m_model->setDataSet(dset);
511 
512  std::vector<int> geoCols;
513  std::vector<int>::iterator it;
514  GetGeometryColumnsPositions(dset, geoCols);
515 
516  for(it = geoCols.begin(); it != geoCols.end(); ++it)
517  hideColumn(*it);
518 
519  m_popupFilter->setDataSet(dset);
520  m_delegate->setDataSet(dset);
521  m_dset = dset;
522 }
523 
525 {
526  te::da::ObjectIdSet* objs = 0;
527 
528  te::da::GetEmptyOIDSet(schema, objs);
529 
530  m_delegate->setObjectIdSet(objs);
531 
532  m_model->setPkeysColumns(objs->getPropertyPos());
533 
534  m_model->getPromoter()->preProcessKeys(m_dset, objs->getPropertyPos());
535 }
536 
538 {
539  m_delegate->setObjectIdSet(oids);
540 
541  if(m_autoScrollEnabled && oids != 0 && oids->size() > 0)
542  {
543  size_t row = m_model->getPromoter()->map2Row(*oids->begin());
544 
545  scrollTo(m_model->index((int)row, 0));
546  }
547 
548  viewport()->repaint();
549 }
550 
552 {
553  horizontalHeader()->hideSection(column);
554 }
555 
557 {
558  horizontalHeader()->showSection(column);
559 }
560 
562 {
563  std::vector<int> hCols = m_popupFilter->getHiddenColumns();
564  std::vector<int>::iterator it;
565 
566  for (it=hCols.begin(); it!=hCols.end(); ++it)
567  horizontalHeader()->showSection(*it);
568 }
569 
571 {
572  QHeaderView* hdr = horizontalHeader();
573 
574  int nCols = hdr->count();
575 
576  for(int i=0; i<nCols; i++)
577  {
578  int visCol = hdr->visualIndex(i);
579 
580  if(visCol != i)
581  hdr->moveSection(visCol, i);
582  }
583 }
584 
585 void te::qt::widgets::DataSetTableView::highlightRow(const int& row, const bool& add)
586 {
587 // removeSelection(row, row);
588 
589  te::da::ObjectIdSet* oids = m_model->getObjectIdSet(row, row);
590 
591  if(add)
592  {
593  te::da::ObjectId* oid = *oids->begin();
594 
595  if(m_delegate->getSelected()->contains(oid))
596  {
597  emit deselectOIds(oids);
598 
599  delete oids;
600 
601  m_delegate->setObjectIdSet(m_layer->getSelected());
602 
603  viewport()->repaint();
604 
605  return;
606  }
607  }
608 
609  emit selectOIds(oids, add);
610 }
611 
612 void te::qt::widgets::DataSetTableView::highlightRows(const int& initRow, const int& finalRow)
613 {
614  int ini,
615  final;
616 
617  if(initRow < finalRow)
618  {
619  ini = initRow;
620  final = finalRow;
621  }
622  else
623  {
624  ini = finalRow;
625  final = initRow;
626  }
627 
628 // removeSelection(ini, final);
629 
630  te::da::ObjectIdSet* oids = m_model->getObjectIdSet(ini, final);
631 
632  emit selectOIds(oids, true);
633 
634  viewport()->repaint();
635 }
636 
638 {
639  ScopedCursor cursor(Qt::WaitCursor);
640 
641  setEnabled(false);
642  m_model->setEnabled(false);
643  m_popupFilter->setEnabled(false);
644 
645  const te::da::ObjectIdSet* oids = m_delegate->getSelected();
646  m_model->promote(oids);
647 
648  m_popupFilter->setEnabled(true);
649  m_model->setEnabled(true);
650  setEnabled(true);
651 
652  m_isPromoted = true;
653  m_isSorted = false;
654 
655  viewport()->repaint();
656 
657  scrollToTop();
658 }
659 
661 {
662  //*********************
663  // Sort by query
664  //*********************
665  try
666  {
667  ScopedCursor cursor(Qt::WaitCursor);
668 
669  std::vector<int> selCols;
670 
671  int nCols = model()->columnCount();
672 
673  for(int i=0; i<nCols; i++)
674  {
675  int logCol = verticalHeader()->logicalIndex(i);
676 
677  if(selectionModel()->isColumnSelected(i, QModelIndex()))
678  selCols.push_back(i);
679  }
680 
681  if(selCols.empty())
682  return;
683 
684  std::auto_ptr<te::da::DataSet> dset = GetDataSet(m_layer, m_dset, selCols, asc);
685 
686  if(dset.get() == 0)
687  throw te::common::Exception(tr("Sort operation not supported by the source of data.").toStdString());
688 
689  setDataSet(dset.release());
690 
691  viewport()->repaint();
692 
693  setUpdatesEnabled(false);
694 
695  m_model->getPromoter()->preProcessKeys(m_dset, m_delegate->getSelected()->getPropertyPos());
696 
697  setUpdatesEnabled(true);
698  }
699  catch(te::common::Exception& e)
700  {
701  QMessageBox::information(this, tr("Sorting columns failure"), tr("Could not sort data: ") + e.what());
702  }
703 }
704 
706 {
707  m_model->showOIdsVisible(visible);
708 
709  horizontalHeader()->viewport()->repaint();
710 }
711 
713 {
714  if(m_layer == 0)
715  return;
716 
717  try
718  {
719  AddColumnDialog dlg(parentWidget());
720 
721  std::auto_ptr<te::da::DataSetType> ds_t = m_layer->getSchema();
722 
723  std::string dsName = ds_t->getName();
724  size_t n_prop = ds_t->getProperties().size();
725  dlg.setTableName(dsName);
726 
727  if(dlg.exec() == QDialog::Accepted)
728  {
729  te::da::DataSourcePtr ds = GetDataSource(m_layer);
730 
731  if(ds.get() == 0)
732  throw te::common::Exception(tr("Fail to get data source of the layer.").toStdString());
733 
734  std::auto_ptr<te::dt::Property> p(dlg.getNewProperty());
735 
736  if(p->getName().empty())
737  throw te::common::Exception(tr("Name must not be empty.").toStdString());
738 
739  if(!ds->isPropertyNameValid(p->getName()))
740  throw te::common::Exception(tr("The property name is invalid.").toStdString());
741 
742  if(ds->propertyExists(dsName, p->getName()))
743  throw te::common::Exception(tr("There already exists a property with this name.").toStdString());
744 
745  ds->addProperty(dsName, p.get());
746 
747  m_model->insertColumns((int)n_prop-1, 0);
748 
749  setLayer(m_layer);
750  }
751  }
752  catch(te::common::Exception& e)
753  {
754  QMessageBox::information(this, tr("Creating column failure"), tr("The column could not be created: ") + e.what());
755  }
756 }
757 
759 {
760  try
761  {
762  if(QMessageBox::question(this, tr("Remove column"), tr("Are you sure you want to remove this column?"), QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
763  {
764  te::da::DataSourcePtr ds = GetDataSource(m_layer);
765 
766  if(ds.get() == 0)
767  throw te::common::Exception(tr("Fail to get data source of the layer.").toStdString());
768 
769  std::auto_ptr<te::da::DataSetType> ds_t = m_layer->getSchema();
770  std::string dsName = ds_t->getName();
771 
772  std::string pName = ds_t->getProperty(column)->getName();
773 
774  ds->dropProperty(dsName, pName);
775 
776  m_model->removeColumns(column, 0);
777 
778  setLayer(m_layer);
779  }
780  }
781  catch(te::common::Exception& e)
782  {
783  QMessageBox::information(this, tr("Removing column failure"), tr("The column could not be removed: ") + e.what());
784  }
785 }
786 
788 {
789  m_autoScrollEnabled = enable;
790 }
791 
792 
793 void te::qt::widgets::DataSetTableView::removeSelection(const int& initRow, const int& finalRow)
794 {
795  QItemSelection toRemove;
796 
797  for(int i=initRow; i<=finalRow; i++)
798  {
799  QModelIndexList idx = selectionModel()->selectedColumns(i);
800 
801  if(!idx.empty())
802  toRemove.select(idx.first(), idx.last());
803  }
804 
805  selectionModel()->select(toRemove, QItemSelectionModel::Deselect);
806 }
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
A layer with reference to a dataset.
Definition: DataSetLayer.h:47
void showColumn(const int &column)
Shows the hidden column.
const std::vector< std::size_t > & getPropertyPos() const
It returns the property positions used to generated the oids.
Defines an mechanism for logical ordering of rows.
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 delegate for highlight the selected object ids.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
bool eventFilter(QObject *watched, QEvent *event)
void setPromoter(Promoter *promoter)
Sets the promoter being used.
te::qt::widgets::DataSetTableView * m_view
DataSetTableModel * m_model
The model to be used.
This is the base class for layers.
Definition: AbstractLayer.h:76
void addColumn()
Add column to the table.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
virtual te::common::AccessPolicy getAccessPolicy() const =0
It returns the read and write permission associated to the dataset.
void promote()
Promotes the highlighted rows.
QAction * GetShowAllMenu(QHeaderView *hView, te::da::DataSet *dset, QMenu *hMnu)
const te::da::DataSourceCapabilities * m_caps
void selectObjects(const int &initRow, const int &finalRow)
void hideColumn(const int &column)
Hides the column at position column.
A table model representing a te::da::DataSet.
void GetCapabilities(OGRDataSource *ds, te::da::DataSourceCapabilities &caps)
Definition: DataSource.cpp:73
The Field class can be used to model an expression that takes part of the output items of a SELECT...
Definition: Field.h:50
void showAllColumns()
Shows all hidden columns.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
virtual std::auto_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
TEDATAACCESSEXPORT void GetEmptyOIDSet(const DataSetType *type, ObjectIdSet *&set)
Returns an empty ObjectIdSet, with the definitions of fields that compose it.
Definition: Utils.cpp:282
void removeSelection(const int &initRow, const int &finalRow)
void setDataSourceCapabilities(const te::da::DataSourceCapabilities *caps)
te::dt::Property * getNewProperty() const
const std::string & getDataSourceId() const
void highlightRow(const int &row, const bool &add)
Used to highlight the data when the mouse is clicked over a row in the table.
virtual const char * what() const
It outputs the exception message.
Definition: Exception.cpp:58
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
Definition: OrderByItem.h:53
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...
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
Defines a vertical header for a dataset table view.
void setAutoScrollEnabled(const bool &enable)
Enable / disable auto-scroll.
std::vector< int > getHiddenColumns()
Promoter * getPromoter()
Returns the pointer to the promoter being used.
void enableAutoScroll(const bool &)
DataSetTableView(QWidget *parent=0)
Constructor.
std::vector< int > GetHiddenSections(QHeaderView *hView, te::da::DataSet *dset)
std::size_t size() const
It returns the object id set size.
A Qt dialog for inserting columns into a table.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1395
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
Definition: OrderBy.h:37
void setTableName(const std::string &name)
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
std::auto_ptr< te::da::Select > GetSelectExpression(const std::string &tableName, const te::da::DataSet *set, const std::vector< int > &cols, const bool &asc)
TablePopupFilter(te::qt::widgets::DataSetTableView *view)
Contructor.
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
void setEnabled(const bool &enabled)
~TablePopupFilter()
Destructor.
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
void setDataSet(te::da::DataSet *dset)
bool IsGeometryColumn(te::da::DataSet *dset, const size_t &col)
void setStatistics(te::da::DataSet *dataSet, const std::string prop)
A class that models the description of a dataset.
Definition: DataSetType.h:72
void highlightRows(const int &initRow, const int &finalRow)
Select all rows from initRow to finalRow.
void setLayer(const te::map::AbstractLayer *layer)
Sets the layer to be presented.
te::da::DataSet * m_dset
An specialization of QItemDelegate to be used with te::map::AbstractTable objects.
void showColumn(QAction *act)
void sortData(const bool &)
TablePopupFilter * m_popupFilter
The menus popup filter.
void sortByColumns(const bool &asc)
Sort by the selected columns.
A table view for a dataset.
void removeColumn(const int &column)
void selectObject(const int &, const bool &)
void highlightOIds(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
void GetGeometryColumnsPositions(te::da::DataSet *dset, std::vector< int > &cols)
te::da::DataSourcePtr GetDataSource(const te::map::AbstractLayer *layer)
virtual ~DataSetTableView()
Virtual destructor.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:111
void setDataSet(te::da::DataSet *dset)
Updates the data set being visualized.
A model based on te::da::DataSet.
QMenu * GetHiddenColumnsMenu(QHeaderView *hView, te::da::DataSet *dset, QMenu *hMnu)
void setOIdsColumnsVisible(const bool &visible)
Shows or hides the icon sinalizing the columns that identify each row.
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)
HighlightDelegate * m_delegate
Delegate used for rendering selected rows.
void resetColumnsOrder()
Shows columns in the original order.
virtual void setColor(const QColor &c)
Update the color group.
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48
A vertical header used for selecting rows at a table view.