All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PropertiesItemPropertyBrowser.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2014 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 /*!
21  \file PropertyBrowser.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
30 #include "GridSettingsOutside.h"
31 #include "GridSettingsModel.h"
32 #include "GridSettingsController.h"
33 
34 // Qt
35 #include "../../../../../../third-party/qt/propertybrowser/qtvariantproperty.h"
36 #include "../../../../../../third-party/qt/propertybrowser/qteditorfactory.h"
37 #include "ItemController.h"
38 
40  PropertyBrowser(parent),
41  m_gridSettings(0)
42 {
43 
44 }
45 
47 {
49 
50  closeAllWindows();
51 }
52 
54 {
56 
57  m_propGridSettingsName = "";
58 }
59 
61 {
62  if(PropertyBrowser::addProperty(property))
63  return true;
64 
65  QtProperty* qproperty = 0;
66  QtVariantProperty* vproperty = 0;
67 
68  if(property.getType() == DataTypeGridSettings)
69  {
70  qproperty = m_strDlgManager->addProperty(tr(property.getName().c_str()));
71  m_strDlgManager->setValue(qproperty, property.getValue().toString().c_str());
72 
73  /*The sub properties should not appear in this case,
74  because will be previewed in the dialog window will be opened.*/
75  m_propGridSettingsName = property.getName();
76  m_dlgProperty = property;
77  }
78 
79  if(qproperty)
80  {
81  addPropertyItem(qproperty, QLatin1String(property.getName().c_str()));
82  return true;
83  }
84 
85  return false;
86 }
87 
88 void te::layout::PropertiesItemPropertyBrowser::onSetDlg(QWidget *parent, QtProperty * prop)
89 {
90  if(prop->propertyName().toStdString().compare(m_propGridSettingsName) == 0)
91  {
92  connect(parent, SIGNAL(showDlg()), this, SLOT(onShowGridSettingsDlg()));
93  }
94 }
95 
97 {
98  if(!m_gridSettings)
99  {
101  model->setOutsideProperty(m_dlgProperty);
102  GridSettingsController* controller = new GridSettingsController(model);
103 
104  Observer* obs = const_cast<Observer*>(controller->getView());
105  OutsideObserver* observer = dynamic_cast<OutsideObserver*>(obs);
106  m_gridSettings = dynamic_cast<GridSettingsOutside*>(observer);
107  connect(m_gridSettings, SIGNAL(updateProperty()), this, SLOT(onUpdateGridSettingsProperty()));
108  }
109 
110  if(m_gridSettings)
111  {
112  if(m_propGridSettingsName.compare("") != 0)
113  {
114  Observable* obs = dynamic_cast<Observable*>(m_gridSettings->getModel());
115  if(obs)
116  {
117  GridSettingsModel* modelObs = dynamic_cast<GridSettingsModel*>(obs);
118  if(modelObs)
119  {
120  modelObs->setOutsideProperty(m_dlgProperty);
121  }
122 
123  ItemController* itCtrl = dynamic_cast<ItemController*>(m_gridSettings->getController());
124  if(itCtrl)
125  {
126  GridSettingsController* gridController = dynamic_cast<GridSettingsController*>(itCtrl);
127  if(gridController)
128  {
129  gridController->clearUpdate();
130  }
131  }
132  }
133 
134  m_gridSettings->load();
135  m_gridSettings->show();
136  }
137  }
138 }
139 
141 {
142  GridSettingsController* controller = dynamic_cast<GridSettingsController*>(m_gridSettings->getController());
143  if(controller)
144  {
145  Property prop = controller->updateProperty();
146 
147  if(prop.isNull())
148  return;
149 
150  emit updateOutside(prop);
151  }
152 }
153 
155 {
156  if(m_gridSettings)
157  {
158  if(block)
159  {
160  m_gridSettings->blockComponents();
161  }
162  else
163  {
164  m_gridSettings->load();
165  m_gridSettings->unblockComponents();
166  }
167  }
168 }
169 
171 {
172  if(m_gridSettings)
173  {
174  if(!m_gridSettings->isHidden())
175  {
176  m_gridSettings->close();
177  }
178  }
179 }
std::string getName()
Definition: Property.cpp:49
Variant getValue()
Definition: Property.cpp:74
virtual bool addProperty(Property property)
LayoutPropertyDataType getType()
Definition: Property.cpp:59
std::string toString()
Definition: Variant.cpp:237
virtual void setOutsideProperty(Property property)
void onSetDlg(QWidget *parent, QtProperty *prop)