All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataSetTableDockWidget.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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 
38  setWidget(m_view);
39 
40  setAttribute(Qt::WA_DeleteOnClose, true);
41 
42  connect (m_view, SIGNAL(selectOIds(te::da::ObjectIdSet*, const bool&)), SLOT(selectionChanged(te::da::ObjectIdSet*, const bool&)));
43  connect (m_view, SIGNAL(deselectOIds(te::da::ObjectIdSet*)), SLOT(removeSelectedOIds(te::da::ObjectIdSet*)));
44 
45  // Alternate Colors
47  {
48  m_view->setAlternatingRowColors(true);
50  }
51 }
52 
54 {
55  emit closed(this);
56 }
57 
59 {
60  m_layer = layer;
61 
62  if(m_layer == 0)
63  return;
64 
65  te::qt::widgets::ScopedCursor cursor(Qt::WaitCursor);
66 
67  m_view->setLayer(m_layer);
68 
69  if(m_layer->getSelected() != 0)
70  m_view->highlightOIds(m_layer->getSelected());
71 
72  const char* lName = m_layer->getTitle().c_str();
73 
74  setWindowTitle(lName);
75 
76  setObjectName(QString("TableView_") + lName);
77 }
78 
80 {
81  return m_layer;
82 }
83 
85 {
86  switch(evt->m_id)
87  {
89  {
91 
92  if(ev->m_layer->getId() == m_layer->getId())
93  m_view->highlightOIds(ev->m_layer->getSelected());
94  }
95  break;
96 
98  {
100  m_view->setAlternatingRowColors(ev->m_isAlternating);
101  if(ev->m_isAlternating)
102  {
104  }
105  else
106  {
107  m_view->setStyleSheet("background-color: white;");
108  }
109  }
110  break;
111 
112 
114  {
116 
117  if(ev->m_layer->getId() == m_layer->getId())
118  {
119  this->close();
120  }
121  }
122  break;
123 
124  }
125 }
126 
128 {
129  if (!add)
130  m_layer->clearSelected();
131 
132  m_layer->select(oids);
133 
136 }
137 
139 {
140  if(m_layer->getSelected() != 0)
141  m_layer->deselect(oids);
142 }
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
te::map::AbstractLayer * getLayer() const
Returns the layer being used.
void setLayer(te::map::AbstractLayer *layer)
Sets the layer to be showed on view. This DOES NOT takes the ownership of layer.
This is the base class for layers.
Definition: AbstractLayer.h:76
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
Definition: Utils.cpp:643
static ApplicationController & getInstance()
It gives access to the controller singleton.
void removeSelectedOIds(te::da::ObjectIdSet *oids)
Removes the oids from the list of selected in the Layer.
te::map::AbstractLayerPtr m_layer
Layer whose selected objects were changed.
Definition: LayerEvents.h:186
A dock widget for table view objects.
This event signals that table has alternating row colors.
Definition: TableEvents.h:47
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
Definition: Utils.cpp:615
int m_id
Identifier.
Definition: Event.h:70
te::map::AbstractLayerPtr m_layer
Layer removed.
Definition: LayerEvents.h:119
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
te::qt::widgets::DataSetTableView * m_view
The table view.
A base class for application events.
Definition: Event.h:59
void selectionChanged(te::da::ObjectIdSet *oids, const bool &add)
Used for selection changed on table view.
This event signals that a layer is to be removed from the layer explorer.
Definition: LayerEvents.h:106
TEQTAFEXPORT QString GetStyleSheetFromSettings()
Definition: Utils.cpp:626
DataSetTableDockWidget(QWidget *parent=0)
Constructor.
This event indicates that the selected objects of the layer were changed.
Definition: LayerEvents.h:173
void broadcast(te::qt::af::evt::Event *evt)
Send events in broadcast for all registered components.
void onApplicationTriggered(te::qt::af::evt::Event *evt)
Used for capture events sent by application framework.
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48