30 #include "../../../core/property/Properties.h"
31 #include "../../../core/enum/Enums.h"
40 m_variantPropertyEditorManager(0),
41 m_variantPropertyEditorFactory(0)
48 if(m_variantPropertyEditorManager)
50 delete m_variantPropertyEditorManager;
51 m_variantPropertyEditorManager = 0;
54 if(m_variantPropertyEditorFactory)
56 delete m_variantPropertyEditorFactory;
57 m_variantPropertyEditorFactory = 0;
63 m_variantPropertyEditorManager =
new QtVariantPropertyManager;
64 m_variantPropertyEditorFactory =
new QtVariantEditorFactory;
69 QtVariantProperty* vproperty = 0;
76 if(!m_variantPropertyEditorManager)
88 int type = getVariantType(property.
getType());
89 vproperty = m_variantPropertyEditorManager->addProperty(type, tr(property.
getName().c_str()));
90 changeQtVariantPropertyValue(vproperty, property);
92 addPropertyItem(vproperty, QLatin1String(property.
getName().c_str()));
99 std::vector<Variant> vrt =
property.getOptionChoices();
103 strList.push_back(v.
toString().c_str());
108 vproperty->setAttribute(
"enumNames", strList);
116 QVariant variant = findPropertyValue(name);
118 if(variant.isNull() || !variant.isValid())
123 QtProperty*
property = findProperty(name);
124 EnumType* type = getLayoutType(variant.type(), name);
126 QtVariantProperty* vproperty = 0;
129 vproperty =
dynamic_cast<QtVariantProperty*
>(property);
144 prop.
setValue(variant.toString().toStdString(), type);
148 prop.
setValue(variant.toString().toStdString(), type);
151 list = variant.toStringList();
152 value = list.value(vproperty->value().toInt()).toStdString();
154 foreach(QString s, list)
159 if(value.compare(s.toStdString()) == 0)
168 prop.
setValue(variant.toDouble(), type);
172 prop.
setValue(variant.toInt(), type);
176 prop.
setValue(variant.toBool(), type);
180 qcolor = variant.value<QColor>();
183 color.
setColor(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha());
189 qfont = variant.value<QFont>();
190 font.
setFamily(qfont.family().toStdString());
209 QtVariantProperty* vproperty = 0;
210 QtProperty* prop = 0;
219 case QVariant::StringList:
220 prop = findProperty(name);
221 vproperty =
dynamic_cast<QtVariantProperty*
>(prop);
224 if(QtVariantPropertyManager::enumTypeId() == vproperty->propertyType())
228 else if(QtVariantPropertyManager::groupTypeId() == vproperty->propertyType())
245 case QVariant::Color:
260 int type = QVariant::Invalid;
275 type = QtVariantPropertyManager::enumTypeId();
279 type = QtVariantPropertyManager::groupTypeId();
287 type = QVariant::Int;
291 type = QVariant::Bool;
295 type = QVariant::Color;
299 type = QVariant::Font;
314 m_changeProperty =
true;
329 addAttribute(vproperty, property);
350 color =
property.getValue().toColor();
351 qcolor.setRed(color.
getRed());
353 qcolor.setBlue(color.
getBlue());
355 vproperty->setValue(qcolor);
359 font =
property.getValue().toFont();
362 qfont.setBold(font.
isBold());
367 vproperty->setValue(qfont);
374 m_changeProperty =
false;
381 return m_variantPropertyEditorFactory;
386 return m_variantPropertyEditorManager;
391 std::string name =
property.getName();
392 QtProperty* qprop = findProperty(name);
398 QtVariantProperty* vproperty = m_variantPropertyEditorManager->variantProperty(qprop);
404 changeQtVariantPropertyValue(vproperty, property);
std::string getName()
Method that returns the name of this property.
virtual bool updateProperty(Property property)
SimpleData< std::string, STRING_TYPE > String
bool isBold()
Returns true if font use bold, false otherwise.
Variant getValue()
Returns stored value.
virtual EnumDataType * getEnumDataType()
Returns data type enumeration.
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
bool isStrikeout()
Returns true if font use strikeout, false otherwise.
void setStrikeout(bool strikeout)
Sets font with strikeout style.
int getRed() const
It returns the red component color value (a value from 0 to 255).
void addOption(Variant variant)
virtual EnumType * getDataTypeBool() const
Returns value that represents type bool belonging to enumeration.
virtual void addAttribute(QtVariantProperty *vproperty, Property property)
void setKerning(bool kerning)
Sets font with kerning style.
virtual EnumType * getDataTypeDouble() const
Returns value that represents type double belonging to enumeration.
virtual EnumType * getDataTypeInt() const
Returns value that represents type integer belonging to enumeration.
int getPointSize()
Returns point size of the font.
virtual EnumType * getDataTypeNone() const
Returns value that represents type none belonging to enumeration.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
Variant getOptionByCurrentChoice()
int getGreen() const
It returns the green component color value (a value from 0 to 255).
virtual EnumType * getLayoutType(QVariant::Type type, std::string name="")
virtual EnumType * getDataTypeGroup() const
Returns value that represents type Group (string) belonging to enumeration.
void setPointSize(int point)
Sets point size of the font.
virtual Property getProperty(std::string name)
virtual ~VariantPropertiesBrowser()
void setBold(bool bold)
Sets font with bold style.
static Enums & getInstance()
It returns a reference to the singleton instance.
QtVariantPropertyManager * getVariantPropertyManager()
QtVariantEditorFactory * getVariantEditorFactory()
virtual QtVariantProperty * addProperty(Property property)
Class to represent a data type enumeration. Ex.: int, double, bool, te::color::RGBAColor (color)...
virtual void createManager()
virtual void clear()
Reset state of object. Null state.
void setFamily(std::string family)
Returns font family name.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
Class acts like a union for some C++/TerraLib5 data types. Responsible for storing the value...
virtual bool changeQtVariantPropertyValue(QtVariantProperty *vproperty, Property property)
void setUnderline(bool underline)
Sets font with underline style.
bool isItalic()
Returns true if font use italic, false otherwise.
virtual EnumType * getDataTypeColor() const
Returns value that represents type te::color::RGBAColor** (color) belonging to enumeration.
bool isUnderline()
Returns true if font use underline, false otherwise.
double toDouble()
Returns the value of double type. (The setValue method received a double)
virtual int getVariantType(EnumType *dataType)
VariantPropertiesBrowser(QObject *parent=0)
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
virtual EnumType * getDataTypeFont() const
Returns value that represents type Font belonging to enumeration.
virtual EnumType * getDataTypeStringList() const
Returns value that represents type StringList (string) belonging to enumeration.
SimpleData< double, DOUBLE_TYPE > Double
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
void setItalic(bool italic)
Sets font with italic style.
std::string getFamily()
Sets font family name.
std::string toString()
Returns the value of string type. (The setValue method received a string)
void setName(std::string name)
Sets the name of this property.
virtual EnumType * getDataTypeString() const
Returns value that represents type string belonging to enumeration.
Manage properties variants values.
EnumType * getType()
Returns the type of this property.
void setOptionChoice(Variant variant)
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.
int toInt()
Returns the value of int type. (The setValue method received a int)
bool isKerning()
Returns true if font use kerning, false otherwise.
bool toBool()
Returns the value of boolean type. (The setValue method received a boolean)
void setValue(ValueType value, EnumType *type)
Stores a copy of value.