#endif
}
+QQuickTextInputPrivate::ExtraData::ExtraData()
+ : padding(0)
+ , topPadding(0)
+ , leftPadding(0)
+ , rightPadding(0)
+ , bottomPadding(0)
+ , explicitTopPadding(false)
+ , explicitLeftPadding(false)
+ , explicitRightPadding(false)
+ , explicitBottomPadding(false)
+{
+}
+
void QQuickTextInputPrivate::init()
{
Q_Q(QQuickTextInput);
{
Q_Q(QQuickTextInput);
qreal oldPadding = q->topPadding();
- topPadding = value;
- explicitTopPadding = !reset;
- if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding))) {
+ if (!reset || extra.isAllocated()) {
+ extra.value().topPadding = value;
+ extra.value().explicitTopPadding = !reset;
+ }
+ if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
updateLayout();
emit q->topPaddingChanged();
}
{
Q_Q(QQuickTextInput);
qreal oldPadding = q->leftPadding();
- leftPadding = value;
- explicitLeftPadding = !reset;
- if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding))) {
+ if (!reset || extra.isAllocated()) {
+ extra.value().leftPadding = value;
+ extra.value().explicitLeftPadding = !reset;
+ }
+ if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
updateLayout();
emit q->leftPaddingChanged();
}
{
Q_Q(QQuickTextInput);
qreal oldPadding = q->rightPadding();
- rightPadding = value;
- explicitRightPadding = !reset;
- if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding))) {
+ if (!reset || extra.isAllocated()) {
+ extra.value().rightPadding = value;
+ extra.value().explicitRightPadding = !reset;
+ }
+ if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
updateLayout();
emit q->rightPaddingChanged();
}
{
Q_Q(QQuickTextInput);
qreal oldPadding = q->bottomPadding();
- bottomPadding = value;
- explicitBottomPadding = !reset;
- if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding))) {
+ if (!reset || extra.isAllocated()) {
+ extra.value().bottomPadding = value;
+ extra.value().explicitBottomPadding = !reset;
+ }
+ if ((!reset && !qFuzzyCompare(oldPadding, value)) || (reset && !qFuzzyCompare(oldPadding, padding()))) {
updateLayout();
emit q->bottomPaddingChanged();
}
qreal QQuickTextInput::padding() const
{
Q_D(const QQuickTextInput);
- return d->padding;
+ return d->padding();
}
void QQuickTextInput::setPadding(qreal padding)
{
Q_D(QQuickTextInput);
- if (qFuzzyCompare(d->padding, padding))
+ if (qFuzzyCompare(d->padding(), padding))
return;
- d->padding = padding;
+
+ d->extra.value().padding = padding;
d->updateLayout();
emit paddingChanged();
- if (!d->explicitTopPadding)
+ if (!d->extra.isAllocated() || !d->extra->explicitTopPadding)
emit topPaddingChanged();
- if (!d->explicitLeftPadding)
+ if (!d->extra.isAllocated() || !d->extra->explicitLeftPadding)
emit leftPaddingChanged();
- if (!d->explicitRightPadding)
+ if (!d->extra.isAllocated() || !d->extra->explicitRightPadding)
emit rightPaddingChanged();
- if (!d->explicitBottomPadding)
+ if (!d->extra.isAllocated() || !d->extra->explicitBottomPadding)
emit bottomPaddingChanged();
}
qreal QQuickTextInput::topPadding() const
{
Q_D(const QQuickTextInput);
- if (d->explicitTopPadding)
- return d->topPadding;
- return d->padding;
+ if (d->extra.isAllocated() && d->extra->explicitTopPadding)
+ return d->extra->topPadding;
+ return d->padding();
}
void QQuickTextInput::setTopPadding(qreal padding)
qreal QQuickTextInput::leftPadding() const
{
Q_D(const QQuickTextInput);
- if (d->explicitLeftPadding)
- return d->leftPadding;
- return d->padding;
+ if (d->extra.isAllocated() && d->extra->explicitLeftPadding)
+ return d->extra->leftPadding;
+ return d->padding();
}
void QQuickTextInput::setLeftPadding(qreal padding)
qreal QQuickTextInput::rightPadding() const
{
Q_D(const QQuickTextInput);
- if (d->explicitRightPadding)
- return d->rightPadding;
- return d->padding;
+ if (d->extra.isAllocated() && d->extra->explicitRightPadding)
+ return d->extra->rightPadding;
+ return d->padding();
}
void QQuickTextInput::setRightPadding(qreal padding)
qreal QQuickTextInput::bottomPadding() const
{
Q_D(const QQuickTextInput);
- if (d->explicitBottomPadding)
- return d->bottomPadding;
- return d->padding;
+ if (d->extra.isAllocated() && d->extra->explicitBottomPadding)
+ return d->extra->bottomPadding;
+ return d->padding();
}
void QQuickTextInput::setBottomPadding(qreal padding)
#include <QtGui/qpalette.h>
#include <QtGui/qtextlayout.h>
#include <QtGui/qstylehints.h>
+#include <private/qlazilyallocated_p.h>
#include "qplatformdefs.h"
typedef QQuickTextInput Public;
+ struct ExtraData {
+ ExtraData();
+
+ qreal padding;
+ qreal topPadding;
+ qreal leftPadding;
+ qreal rightPadding;
+ qreal bottomPadding;
+ bool explicitTopPadding : 1;
+ bool explicitLeftPadding : 1;
+ bool explicitRightPadding : 1;
+ bool explicitBottomPadding : 1;
+ };
+ QLazilyAllocated<ExtraData> extra;
+
QQuickTextInputPrivate()
: hscroll(0)
, vscroll(0)
- , padding(0)
- , topPadding(0)
- , leftPadding(0)
- , rightPadding(0)
- , bottomPadding(0)
- , explicitTopPadding(false)
- , explicitLeftPadding(false)
- , explicitRightPadding(false)
- , explicitBottomPadding(false)
, cursorItem(0)
, textNode(0)
, m_maskData(0)
qreal hscroll;
qreal vscroll;
- qreal padding;
- qreal topPadding;
- qreal leftPadding;
- qreal rightPadding;
- qreal bottomPadding;
- bool explicitTopPadding;
- bool explicitLeftPadding;
- bool explicitRightPadding;
- bool explicitBottomPadding;
-
QTextLayout m_textLayout;
QString m_text;
QString m_inputMask;
qreal getImplicitWidth() const Q_DECL_OVERRIDE;
+ inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; }
void setTopPadding(qreal value, bool reset = false);
void setLeftPadding(qreal value, bool reset = false);
void setRightPadding(qreal value, bool reset = false);