All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TextGridSettingsController.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 /*!
21  \file TextGridSettingsController.h
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
30 #include "../core/pattern/mvc/OutsideModelObservable.h"
31 #include "../core/pattern/mvc/Observable.h"
32 #include "TextGridSettingsModel.h"
33 
36 {
37 
38 }
39 
41 {
42 
43 }
44 
46 {
47  return m_update;
48 }
49 
51 {
52  TextGridSettingsModel* outsideModel = 0;
53 
54  if(m_model)
55  {
56  OutsideModelObservable* model = dynamic_cast<OutsideModelObservable*>(m_model);
57  outsideModel = dynamic_cast<TextGridSettingsModel*>(model);
58  }
59 
60  if(!outsideModel)
61  return;
62 
63  if(m_update.isNull())
64  {
65  Property prop = outsideModel->getOutsideProperty();
66 
67  m_update.setEditable(prop.isEditable());
68 
69  m_update.setName(prop.getName());
70  m_update.setValue(prop.getValue());
71  }
72 
73  Property property = outsideModel->containsOutsideSubProperty(name);
74 
75  if(!property.isNull())
76  {
77  if(property.getOptionChoices().empty())
78  {
79  if(property.getValue() != variant)
80  {
81  property.setValue(variant);
82  outsideModel->updateOutsideSubProperty(property);
83  }
84  else
85  {
86  return;
87  }
88  }
89  else
90  {
91  if(property.getOptionByCurrentChoice() != variant)
92  {
93  property.setOptionChoice(variant);
94  outsideModel->updateOutsideSubProperty(property);
95  }
96  else
97  {
98  return;
99  }
100  }
101 
102  addUpdateTextGridProperty(property);
103  }
104 }
105 
107 {
108  TextGridSettingsModel* outsideModel = 0;
109 
110  if(m_model)
111  {
112  OutsideModelObservable* model = dynamic_cast<OutsideModelObservable*>(m_model);
113  outsideModel = dynamic_cast<TextGridSettingsModel*>(model);
114  }
115 
116  if(!outsideModel)
117  return;
118 
119  if(m_textGridSettings.isNull())
120  {
121  Property prop = outsideModel->getOutsideProperty();
122  m_textGridSettings.setEditable(prop.isEditable());
123 
124  m_textGridSettings.setName(prop.getName());
125  m_textGridSettings.setValue(prop.getValue());
126  }
127 
128  if(!subProperty.isNull())
129  {
130  if(m_textGridSettings.containsSubProperty(subProperty))
131  {
132  m_textGridSettings.removeSubProperty(subProperty);
133  }
134  m_textGridSettings.addSubProperty(subProperty);
135 
136  if(m_update.containsSubProperty(subProperty))
137  {
138  m_update.removeSubProperty(subProperty);
139  }
140  m_update.addSubProperty(subProperty);
141  }
142 }
143 
145 {
146  m_update.clear();
147  m_textGridSettings.clear();
148 }
149 
151 {
152  TextGridSettingsModel* outsideModel = 0;
153  Property prop;
154 
155  if(m_model)
156  {
157  OutsideModelObservable* model = dynamic_cast<OutsideModelObservable*>(m_model);
158  outsideModel = dynamic_cast<TextGridSettingsModel*>(model);
159  }
160 
161  if(!outsideModel)
162  return prop;
163 
164  prop = outsideModel->containsOutsideSubProperty(name);
165 
166  return prop;
167 }
168 
Abstract class to represent an observable. "Model" part of MVC component.
Definition: Observable.h:56
std::string getName()
Method that returns the name of this property.
Definition: Property.cpp:57
Variant getValue()
Returns stored value.
Definition: Property.cpp:72
virtual Property getProperty(std::string name)
bool isNull()
Returns true if no value has been set, false otherwise.
Definition: Property.cpp:146
virtual void addUpdateProperty(std::string name, Variant variant)
virtual void updateOutsideSubProperty(Property subProperty)
Class acts like a union for some C++/TerraLib5 data types. Responsible for storing the value...
Definition: Variant.h:80
bool isEditable()
Returns true if property is editable, false otherwise.
Definition: Property.cpp:114
Abstract class to represent an observable. "Model" part of MVC widget. All classes representing the m...
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
Definition: Property.h:298
void setEditable(bool editable)
Sets true if property is editable, false otherwise.
Definition: Property.cpp:119
Abstract class to represent a controller. "Controller" part of MVC widget. All classes representing t...
virtual te::layout::Property containsOutsideSubProperty(std::string name)
A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object. Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
Definition: Property.h:47
virtual void addUpdateTextGridProperty(Property subProperty)