All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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(0)
35 {
37 
39 
40  setWidget(m_view);
41 
42  setAttribute(Qt::WA_DeleteOnClose, true);
43 
44  connect (m_view, SIGNAL(selectOIds(te::da::ObjectIdSet*, const bool&, te::gm::Envelope*)), SLOT(selectionChanged(te::da::ObjectIdSet*, const bool&, te::gm::Envelope*)));
45  connect (m_view, SIGNAL(deselectOIds(te::da::ObjectIdSet*)), SLOT(removeSelectedOIds(te::da::ObjectIdSet*)));
47 
48  // Alternate Colors
50  {
51  m_view->setAlternatingRowColors(true);
53  }
54 }
55 
57 {
58  emit closed(this);
59 }
60 
62 {
63  m_layer = layer;
64 
65  if(m_layer == 0)
66  return;
67 
68  te::qt::widgets::ScopedCursor cursor(Qt::WaitCursor);
69 
70  m_view->setLayer(m_layer);
71 
72  if(m_layer->getSelected() != 0)
73  m_view->highlightOIds(m_layer->getSelected());
74 
75  const char* lName = m_layer->getTitle().c_str();
76 
77  setWindowTitle(lName);
78 
79  setObjectName(QString("TableView_") + lName);
80 }
81 
83 {
84  return m_layer;
85 }
86 
88 {
89  emit createChartDisplay(chartWidget, getLayer());
90 }
91 
93 {
94  switch(evt->m_id)
95  {
97  {
99 
100  if(ev->m_layer->getId() == m_layer->getId())
101  m_view->highlightOIds(ev->m_layer->getSelected());
102  }
103  break;
104 
106  {
108  m_view->setAlternatingRowColors(ev->m_isAlternating);
109  if(ev->m_isAlternating)
110  {
112  }
113  else
114  {
115  m_view->setStyleSheet("background-color: white;");
116  }
117  }
118  break;
119 
120 
122  {
124 
125  if(ev->m_layer->getId() == m_layer->getId())
126  {
127  this->close();
128  }
129  }
130  break;
131 
132  }
133 }
134 
136 {
137  if (!add)
138  m_layer->clearSelected();
139 
140  m_layer->select(oids);
141 
144 }
145 
147 {
148  if(m_layer->getSelected() != 0)
149  {
150  m_layer->deselect(oids);
151 
154  }
155 }
A dock widget for table view objects.
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:76
te::map::AbstractLayerPtr m_layer
Layer whose selected objects were changed.
Definition: LayerEvents.h:192
void setLayer(te::map::AbstractLayer *layer)
Sets the layer to be showed on view. This DOES NOT takes the ownership of layer.
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.
Definition: Event.h:59
void chartDisplayCreated(te::qt::widgets::ChartDisplayWidget *chartWidget)
Broadcasts the creation of a new chartWidget to the application.
This event indicates that the selected objects of the layer were changed.
Definition: LayerEvents.h:178
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
Definition: Utils.cpp:755
DataSetTableDockWidget(QWidget *parent=0)
Constructor.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
Definition: Utils.cpp:727
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
int m_id
Identifier.
Definition: Event.h:70
te::qt::widgets::DataSetTableView * m_view
The table view.
void createChartDisplay(te::qt::widgets::ChartDisplayWidget *, te::map::AbstractLayer *layer)
Broadcasts the creation of a new chartWidget to the application.
A wdiget used to display a chart.
void broadcast(te::qt::af::evt::Event *evt)
Send events in broadcast for all registered components.
TEQTAFEXPORT QString GetStyleSheetFromSettings()
Definition: Utils.cpp:738
te::map::AbstractLayerPtr m_layer
Layer removed.
Definition: LayerEvents.h:124
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
This event signals that a layer is to be removed from the layer explorer.
Definition: LayerEvents.h:111
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.
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.