30 #include "ui_TextGridSettings.h"
31 #include "../../core/pattern/mvc/OutsideObserver.h"
32 #include "../../core/pattern/mvc/OutsideController.h"
33 #include "../../core/pattern/singleton/Context.h"
34 #include "../../outside/TextGridSettingsController.h"
35 #include "../../core/enum/Enums.h"
36 #include "../../core/property/TextGridSettingsConfigProperties.h"
44 #include <QColorDialog>
49 m_ui(new Ui::TextGridSettings)
62 delete m_propertiesNames;
63 m_propertiesNames = 0;
69 m_ui->lneEdtBorderWidth->setValidator(
new QDoubleValidator(
this));
70 m_ui->lneEdtColumnsNumber->setValidator(
new QDoubleValidator(
this));
72 m_ui->lneEdtColumnsWidth->setValidator(
new QDoubleValidator(
this));
73 m_ui->lneEdtRowsNumber->setValidator(
new QDoubleValidator(
this));
75 m_ui->lneEdtTablePadding->setValidator(
new QDoubleValidator(
this));
76 m_ui->lneEdtTableSpacing->setValidator(
new QDoubleValidator(
this));
78 m_ui->lneEdtTableWidth->setValidator(
new QDoubleValidator(
this));
80 m_ui->frmBorderColor->setAutoFillBackground(
true);
81 m_ui->frmBorderColor->installEventFilter(
this);
83 m_ui->frmHeaderHorizontalColor->setAutoFillBackground(
true);
84 m_ui->frmHeaderHorizontalColor->installEventFilter(
this);
86 m_ui->frmHeaderVerticalColor->setAutoFillBackground(
true);
87 m_ui->frmHeaderVerticalColor->installEventFilter(
this);
89 m_ui->frmRowsEven->setAutoFillBackground(
true);
90 m_ui->frmRowsEven->installEventFilter(
this);
92 m_ui->frmRowsOdd->setAutoFillBackground(
true);
93 m_ui->frmRowsOdd->installEventFilter(
this);
95 m_ui->frmTableColor->setAutoFillBackground(
true);
96 m_ui->frmTableColor->installEventFilter(
this);
101 setVisible(context.
isShow());
102 if(context.
isShow() ==
true)
116 QPointF posF = pos();
117 qreal valuex = posF.x();
118 qreal valuey = posF.y();
121 coordinate.
x = valuex;
122 coordinate.
y = valuey;
129 initCombo(m_ui->cmbColumnsWidthConstraints, m_propertiesNames->getColumnWidthConstraints());
131 initCombo(m_ui->cmbTableWidthConstraints, m_propertiesNames->getWidthConstraints());
133 initCombo(m_ui->cmbHeaderAlign, m_propertiesNames->getHeaderAlignment());
135 initCombo(m_ui->cmbBorderStyle, m_propertiesNames->getBorderStyle());
137 initCombo(m_ui->cmbCellAlign, m_propertiesNames->getCellAlignment());
139 initDouble(m_ui->lneEdtBorderWidth, m_propertiesNames->getBorderWidth());
141 initInt(m_ui->lneEdtColumnsNumber, m_propertiesNames->getColumnNumber());
143 initDouble(m_ui->lneEdtColumnsWidth, m_propertiesNames->getColumnWidth());
145 initInt(m_ui->lneEdtRowsNumber, m_propertiesNames->getRowNumber());
147 initDouble(m_ui->lneEdtTablePadding, m_propertiesNames->getPadding());
149 initDouble(m_ui->lneEdtTableSpacing, m_propertiesNames->getSpacing());
151 initDouble(m_ui->lneEdtTableWidth, m_propertiesNames->getWidth());
153 initColor(m_ui->frmBorderColor, m_propertiesNames->getBorderGridColor());
155 initColor(m_ui->frmHeaderHorizontalColor, m_propertiesNames->getHeaderHorizontalColor());
157 initColor(m_ui->frmHeaderVerticalColor, m_propertiesNames->getHeaderVerticalColor());
159 initColor(m_ui->frmRowsEven, m_propertiesNames->getEvenRow());
161 initColor(m_ui->frmRowsOdd, m_propertiesNames->getOddRow());
163 initColor(m_ui->frmTableColor, m_propertiesNames->getTableColor());
170 QPalette ptt(widget->palette());
171 QBrush brush = ptt.brush(widget->backgroundRole());
173 QColor bColor = brush.color();
174 rgbaColor.
setColor(bColor.red(), bColor.green(), bColor.blue());
176 QColor color = QColorDialog::getColor(brush.color(),
this,
"Color" );
181 QPalette paltt(widget->palette());
182 paltt.
setColor(widget->backgroundRole(), color);
183 widget->setPalette(paltt);
184 widget->setAutoFillBackground(
true);
186 rgbaColor.
setColor(color.red(), color.green(), color.blue());
193 QObjectList list = children();
195 QList<QObject*>::Iterator it;
196 for(it = list.begin() ; it != list.end() ; ++it)
198 QObject* obj = (*it);
199 QWidget* w =
dynamic_cast<QWidget*
>(obj);
204 w->setEnabled(
false);
212 QObjectList list = children();
214 QList<QObject*>::Iterator it;
215 for(it = list.begin() ; it != list.end() ; ++it)
217 QObject* obj = (*it);
218 QWidget* w =
dynamic_cast<QWidget*
>(obj);
231 emit updateProperty();
253 controller->
addUpdateProperty(m_propertiesNames->getColumnWidthConstraints(), variant);
265 controller->
addUpdateProperty(m_propertiesNames->getWidthConstraints(), variant);
397 QLineEdit* edit =
dynamic_cast<QLineEdit*
>(widget);
415 QLineEdit* edit =
dynamic_cast<QLineEdit*
>(widget);
418 edit->setText(convert.str().c_str());
429 convert.precision(15);
434 QLineEdit* edit =
dynamic_cast<QLineEdit*
>(widget);
437 edit->setText(convert.str().c_str());
449 QCheckBox* chk =
dynamic_cast<QCheckBox*
>(widget);
468 if(!qcolor.isValid())
474 QPalette paltt(widget->palette());
475 paltt.
setColor(widget->backgroundRole(), qcolor);
476 widget->setPalette(paltt);
477 widget->setAutoFillBackground(
true);
488 QComboBox* combo =
dynamic_cast<QComboBox*
>(widget);
515 index = combo->findData(variant);
518 combo->setCurrentIndex(index);
524 if(event->type() != QEvent::MouseButtonPress)
525 return QWidget::eventFilter(watched, event);
530 if(watched == m_ui->frmBorderColor)
532 wgt = m_ui->frmBorderColor;
533 name = m_propertiesNames->getBorderGridColor();
535 else if(watched == m_ui->frmHeaderHorizontalColor)
537 wgt = m_ui->frmHeaderHorizontalColor;
538 name = m_propertiesNames->getHeaderHorizontalColor();
540 else if(watched == m_ui->frmHeaderVerticalColor)
542 wgt = m_ui->frmHeaderVerticalColor;
543 name = m_propertiesNames->getHeaderVerticalColor();
545 else if(watched == m_ui->frmRowsEven)
547 wgt = m_ui->frmRowsEven;
548 name = m_propertiesNames->getEvenRow();
550 else if(watched == m_ui->frmRowsOdd)
552 wgt = m_ui->frmRowsOdd;
553 name = m_propertiesNames->getOddRow();
555 else if(watched == m_ui->frmTableColor)
557 wgt = m_ui->frmTableColor;
558 name = m_propertiesNames->getTableColor();
575 return QWidget::eventFilter(watched, event);
Abstract class to represent an observable. "Model" part of MVC component.
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
virtual void on_lneEdtRowsNumber_editingFinished()
virtual void blockComponents()
virtual void initColor(QWidget *widget, std::string nameComponent)
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.
TextGridSettingsConfigProperties * m_propertiesNames
int getRed() const
It returns the red component color value (a value from 0 to 255).
virtual EnumType * getDataTypeBool() const
Returns value that represents type bool belonging to enumeration.
virtual Property getProperty(std::string name)
virtual EnumType * getDataTypeDouble() const
Returns value that represents type double belonging to enumeration.
virtual void addUpdateProperty(std::string name, Variant variant)
virtual EnumType * getDataTypeInt() const
Returns value that represents type integer belonging to enumeration.
Abstract class to represent an observer. "View" part of MVC widget. All classes representing the grap...
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
int getGreen() const
It returns the green component color value (a value from 0 to 255).
std::auto_ptr< Ui::TextGridSettings > m_ui
virtual void on_lneEdtTableSpacing_editingFinished()
An utility struct for representing 2D coordinates.
virtual bool eventFilter(QObject *watched, QEvent *event)
virtual void updateObserver(ContextItem context)
Reimplemented from Observer.
virtual void initString(QWidget *widget, std::string nameComponent)
static Enums & getInstance()
It returns a reference to the singleton instance.
virtual void on_cmbColumnsWidthConstraints_currentIndexChanged(const QString &text)
TextGridSettingsOutside(OutsideController *controller, Observable *o)
Class to represent a data type enumeration. Ex.: int, double, bool, te::color::RGBAColor (color)...
virtual void clearUpdate()
virtual void on_cmbTableWidthConstraints_currentIndexChanged(const QString &text)
virtual void on_cmbHeaderAlign_currentIndexChanged(const QString &text)
virtual void on_lneEdtBorderWidth_editingFinished()
Class acts like a union for some C++/TerraLib5 data types. Responsible for storing the value...
virtual EnumType * getDataTypeColor() const
Returns value that represents type te::color::RGBAColor** (color) belonging to enumeration.
double toDouble()
Returns the value of double type. (The setValue method received a double)
virtual void initCombo(QWidget *widget, std::string nameComponent)
virtual void initBool(QWidget *widget, std::string nameComponent)
virtual void on_lneEdtColumnsNumber_editingFinished()
virtual void unblockComponents()
virtual void on_pbApply_clicked()
virtual te::color::RGBAColor configColor(QWidget *widget)
virtual void on_cmbCellAlign_currentIndexChanged(const QString &text)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
virtual void on_lneEdtTableWidth_editingFinished()
std::string toString()
Returns the value of string type. (The setValue method received a string)
std::string convert(const path &v)
URI path to string.
virtual void on_lneEdtColumnsWidth_editingFinished()
virtual void initInt(QWidget *widget, std::string nameComponent)
virtual te::gm::Coord2D getPosition()
Method that returns the position llx, lly Reimplement this function in a ItemObserver subclass to pro...
te::color::RGBAColor toColor()
Returns the value of te::color::RGBAColor type. (The setValue method received a te::color::RGBAColor)...
Abstract class to represent a controller. "Controller" part of MVC widget. All classes representing t...
virtual void on_pbCancel_clicked()
virtual EnumType * getDataTypeString() const
Returns value that represents type string belonging to enumeration.
virtual void on_cmbBorderStyle_currentIndexChanged(const QString &text)
virtual ~TextGridSettingsOutside()
EnumType * getType()
Returns the type of this property.
virtual void on_lneEdtTablePadding_editingFinished()
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)
virtual void setPosition(const double &x, const double &y)
Change coordinate llx,lly of the MVC widget. Reimplement this function in a ItemController subclass t...
virtual void initDouble(QWidget *widget, std::string nameComponent)
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.