DataSetTableDockWidget.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 #include "DataSetTableDockWidget.h"
21 
22 // TerraLib
23 #include "../../../maptools/AbstractLayer.h"
24 #include "../../../memory/DataSet.h"
25 #include "../../widgets/table/DataSetTableView.h"
26 #include "../../widgets/utils/ScopedCursor.h"
27 #include "../events/LayerEvents.h"
28 #include "../events/TableEvents.h"
29 #include "../ApplicationController.h"
30 #include "../Utils.h"
31 
33  : QDockWidget(parent, Qt::Widget),
34  m_layer(nullptr)
35 {
37 
38  setWidget(m_view);
39 
40  setAttribute(Qt::WA_DeleteOnClose, true);
41 
42  connect (m_view, SIGNAL(selectOIds(te::da::ObjectIdSet*, const bool&, te::gm::Envelope*)), SLOT(selectionChanged(te::da::ObjectIdSet*, const bool&, te::gm::Envelope*)));
43  connect (m_view, SIGNAL(deselectOIds(te::da::ObjectIdSet*)), SLOT(removeSelectedOIds(te::da::ObjectIdSet*)));
45  connect (m_view, SIGNAL(enableAutoPan(const bool&)), SLOT(onAutoPanEnabled(const bool&)));
46 
47  // Alternate Colors
49  {
50  m_view->setAlternatingRowColors(true);
52  }
53 }
54 
56 {
57  emit closed(this);
58 }
59 
61 {
62  m_layer = layer;
63 
64  if(m_layer == nullptr)
65  return;
66 
67  te::qt::widgets::ScopedCursor cursor(Qt::WaitCursor);
68 
69  m_view->setLayer(m_layer, true, editable);
70 
71  if(m_layer->getSelected() != nullptr)
73 
74  const char* lName = m_layer->getTitle().c_str();
75 
76  setWindowTitle(lName);
77 
78  setObjectName(QString("TableView_") + lName);
79 }
80 
82 {
83  return m_layer;
84 }
85 
87 {
88  m_view->setHighlightColor(color);
89 }
90 
92 {
93  emit createChartDisplay(chartWidget, getLayer());
94 }
95 
97 {
98  switch(evt->m_id)
99  {
101  {
103 
104  if(ev->m_layer->getId() == m_layer->getId())
105  m_view->highlightOIds(ev->m_layer->getSelected());
106  }
107  break;
108 
110  {
112  m_view->setAlternatingRowColors(ev->m_isAlternating);
113  if(ev->m_isAlternating)
114  {
116  }
117  else
118  {
119  m_view->setStyleSheet("background-color: white;");
120  }
121  }
122  break;
123 
124 
126  {
128 
129  for(std::list<te::map::AbstractLayerPtr>::iterator it = ev->m_layers.begin(); it != ev->m_layers.end(); ++it)
130  if((*it)->getId() == m_layer->getId())
131  {
132  this->close();
133  return;
134  }
135  }
136  break;
137 
138  }
139 }
140 
142 {
143  if (!add)
145 
146  m_layer->select(oids);
147 
149  emit triggered(&e);
150 }
151 
153 {
154  if(m_layer->getSelected() != nullptr)
155  {
156  m_layer->deselect(oids);
157 
159  emit triggered(&e);
160  }
161 }
162 
164 {
166  emit triggered(&e);
167 }
virtual const std::string & getId() const
It returns the layer id.
A dock widget for table view objects.
void triggered(te::qt::af::evt::Event *e)
void onApplicationTriggered(te::qt::af::evt::Event *evt)
Used for capture events sent by application framework.
This is the base class for layers.
Definition: AbstractLayer.h:77
te::map::AbstractLayerPtr m_layer
Layer whose selected objects were changed.
Definition: LayerEvents.h:218
virtual const std::string & getTitle() const
It returns the layer title.
This event signals that table has alternating row colors.
Definition: TableEvents.h:47
te::map::AbstractLayer * getLayer() const
Returns the layer being used.
A base class for application events.
void onAutoPanEnabled(const bool &enabled)
Enable or disable display auto pan to selecteds.
void chartDisplayCreated(te::qt::widgets::ChartDisplayWidget *chartWidget)
Broadcasts the creation of a new chartWidget to the application.
te::map::AbstractLayer * m_layer
Layer being visualized.
This event indicates that the selected objects of the layer were changed.
Definition: LayerEvents.h:204
This event signals that table has auto pan enabled.
Definition: TableEvents.h:74
void closed(te::qt::af::DataSetTableDockWidget *)
Emitted before this widget was closed.
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
DataSetTableDockWidget(QWidget *parent=0)
Constructor.
void setHighlightColor(QColor color)
Defines the color to be used as Highlight.
An Envelope defines a 2D rectangular region.
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
te::qt::widgets::DataSetTableView * m_view
The table view.
void highlightOIds(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
virtual void clearSelected()
It clears the selected group of this Layer.
void createChartDisplay(te::qt::widgets::ChartDisplayWidget *, te::map::AbstractLayer *layer)
Broadcasts the creation of a new chartWidget to the application.
virtual void select(te::da::ObjectIdSet *oids)
It adds the given oids to the selected group of this Layer.
A wdiget used to display a chart.
virtual const te::da::ObjectIdSet * getSelected() const
It returns the selected group of this Layer.
TEQTAFEXPORT QString GetStyleSheetFromSettings()
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
void setLayer(te::map::AbstractLayer *layer, const bool &clearEditor=true, const bool &editable=true)
Sets the layer to be presented.
std::list< te::map::AbstractLayerPtr > m_layers
Layer removed.
Definition: LayerEvents.h:154
void selectionChanged(te::da::ObjectIdSet *oids, const bool &add, te::gm::Envelope *env)
Used for selection changed on table view.
void setHighlightColor(const QColor &color)
Update the color to be used.
void setLayer(te::map::AbstractLayer *layer, const bool &editable=true)
Sets the layer to be showed on view. This DOES NOT takes the ownership of layer.
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48
void removeSelectedOIds(te::da::ObjectIdSet *oids)
Removes the oids from the list of selected in the Layer.
virtual void deselect(const te::da::ObjectIdSet *oids)
It removes the given oids from the selected group of this Layer.