summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/qfxborderimage.cpp4
-rw-r--r--src/declarative/fx/qfxborderimage.h7
-rw-r--r--src/declarative/fx/qfxgraphicsobjectcontainer.cpp119
-rw-r--r--src/declarative/fx/qfxgraphicsobjectcontainer.h8
-rw-r--r--src/declarative/fx/qfxgridview.cpp21
-rw-r--r--src/declarative/fx/qfxgridview.h7
-rw-r--r--src/declarative/fx/qfxitem.cpp26
-rw-r--r--src/declarative/fx/qfxitem.h2
-rw-r--r--src/declarative/fx/qfxlistview.cpp20
-rw-r--r--src/declarative/fx/qfxlistview.h5
-rw-r--r--src/declarative/fx/qfxpositioners.cpp1
-rw-r--r--src/declarative/fx/qfxpositioners.h3
-rw-r--r--src/declarative/fx/qfxtextedit.cpp16
-rw-r--r--src/declarative/fx/qfxtextedit.h6
-rw-r--r--src/declarative/fx/qfxtextedit_p.h4
-rw-r--r--src/declarative/fx/qfxtextinput.h2
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp102
17 files changed, 187 insertions, 166 deletions
diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp
index 6616912..8f98a11 100644
--- a/src/declarative/fx/qfxborderimage.cpp
+++ b/src/declarative/fx/qfxborderimage.cpp
@@ -273,7 +273,7 @@ void QFxBorderImage::setHorizontalTileMode(TileMode t)
Q_D(QFxBorderImage);
if (t != d->horizontalTileMode) {
d->horizontalTileMode = t;
- emit tileModeChanged();
+ emit horizontalTileModeChanged();
update();
}
}
@@ -289,7 +289,7 @@ void QFxBorderImage::setVerticalTileMode(TileMode t)
Q_D(QFxBorderImage);
if (t != d->verticalTileMode) {
d->verticalTileMode = t;
- emit tileModeChanged();
+ emit verticalTileModeChanged();
update();
}
}
diff --git a/src/declarative/fx/qfxborderimage.h b/src/declarative/fx/qfxborderimage.h
index eae9bd1..5bc1067 100644
--- a/src/declarative/fx/qfxborderimage.h
+++ b/src/declarative/fx/qfxborderimage.h
@@ -59,8 +59,8 @@ class Q_DECLARATIVE_EXPORT QFxBorderImage : public QFxImageBase
Q_ENUMS(TileMode)
Q_PROPERTY(QFxScaleGrid *border READ border CONSTANT)
- Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY tileModeChanged)
- Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY tileModeChanged)
+ Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged)
+ Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged)
public:
QFxBorderImage(QFxItem *parent=0);
@@ -80,7 +80,8 @@ public:
void setSource(const QUrl &url);
Q_SIGNALS:
- void tileModeChanged();
+ void horizontalTileModeChanged();
+ void verticalTileModeChanged();
protected:
QFxBorderImage(QFxBorderImagePrivate &dd, QFxItem *parent);
diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
index c0cac6c..5a61d12 100644
--- a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
+++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
@@ -43,9 +43,42 @@
#include <QGraphicsObject>
#include <QGraphicsWidget>
#include <QGraphicsSceneResizeEvent>
+#include <private/qfxitem_p.h>
QT_BEGIN_NAMESPACE
+class QFxGraphicsObjectContainerPrivate : public QFxItemPrivate
+{
+ Q_DECLARE_PUBLIC(QFxGraphicsObjectContainer)
+
+public:
+ QFxGraphicsObjectContainerPrivate() : QFxItemPrivate(), graphicsObject(0), syncedResize(false)
+ { }
+
+ void _q_updateSize();
+
+ void setFiltering(bool on)
+ {
+ Q_Q(QFxGraphicsObjectContainer);
+ if (graphicsObject && graphicsObject->isWidget()) {
+ if (!on) {
+ graphicsObject->removeEventFilter(q);
+ QObject::disconnect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::disconnect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ } else {
+ graphicsObject->installEventFilter(q);
+ QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ }
+ }
+ }
+
+
+ QGraphicsObject *graphicsObject;
+ bool syncedResize;
+};
+
+
/*!
\qmlclass GraphicsObjectContainer QFxGraphicsObjectContainer
\brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements.
@@ -61,7 +94,7 @@ QML_DEFINE_NOCREATE_TYPE(QGraphicsObject)
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GraphicsObjectContainer,QFxGraphicsObjectContainer)
QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent)
-: QFxItem(parent), _graphicsObject(0), _syncedResize(false)
+: QFxItem(*new QFxGraphicsObjectContainerPrivate, parent)
{
}
@@ -71,7 +104,8 @@ QFxGraphicsObjectContainer::~QFxGraphicsObjectContainer()
QGraphicsObject *QFxGraphicsObjectContainer::graphicsObject() const
{
- return _graphicsObject;
+ Q_D(const QFxGraphicsObjectContainer);
+ return d->graphicsObject;
}
/*!
@@ -80,30 +114,45 @@ QGraphicsObject *QFxGraphicsObjectContainer::graphicsObject() const
*/
void QFxGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object)
{
- if (object == _graphicsObject)
+ Q_D(QFxGraphicsObjectContainer);
+ if (object == d->graphicsObject)
return;
- //### what should we do with previously set object?
+ //### remove previously set item?
+
+ d->setFiltering(false);
+
+ d->graphicsObject = object;
- _graphicsObject = object;
+ if (d->graphicsObject) {
+ d->graphicsObject->setParentItem(this);
- if (_graphicsObject) {
- _graphicsObject->setParentItem(this);
+ if (d->syncedResize && d->graphicsObject->isWidget()) {
+ QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(d->graphicsObject);
+ QSizeF gwSize = gw->size(); //### should we use sizeHint?
+ QSizeF newSize = gwSize;
+ if (heightValid())
+ newSize.setHeight(height());
+ if (widthValid())
+ newSize.setWidth(width());
+ if (gwSize != newSize)
+ gw->resize(newSize);
- if (_syncedResize && _graphicsObject->isWidget()) {
- _graphicsObject->installEventFilter(this);
- QSizeF newSize = static_cast<QGraphicsWidget*>(_graphicsObject)->size(); //### use sizeHint?
- setImplicitWidth(newSize.width());
- setImplicitHeight(newSize.height());
+ gwSize = gw->size();
+ setImplicitWidth(gwSize.width());
+ setImplicitHeight(gwSize.height());
+
+ d->setFiltering(true);
}
}
}
QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value)
{
+ Q_D(QFxGraphicsObjectContainer);
if (change == ItemSceneHasChanged) {
- QGraphicsObject *o = _graphicsObject;
- _graphicsObject = 0;
+ QGraphicsObject *o = d->graphicsObject;
+ d->graphicsObject = 0;
setGraphicsObject(o);
}
return QFxItem::itemChange(change, value);
@@ -111,9 +160,10 @@ QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const
bool QFxGraphicsObjectContainer::eventFilter(QObject *watched, QEvent *e)
{
- if (watched == _graphicsObject && e->type() == QEvent::GraphicsSceneResize) {
- if (_graphicsObject && _graphicsObject->isWidget() && _syncedResize) {
- QSizeF newSize = static_cast<QGraphicsWidget*>(_graphicsObject)->size();
+ Q_D(QFxGraphicsObjectContainer);
+ if (watched == d->graphicsObject && e->type() == QEvent::GraphicsSceneResize) {
+ if (d->graphicsObject && d->graphicsObject->isWidget() && d->syncedResize) {
+ QSizeF newSize = static_cast<QGraphicsWidget*>(d->graphicsObject)->size();
setImplicitWidth(newSize.width());
setImplicitHeight(newSize.height());
}
@@ -142,40 +192,27 @@ bool QFxGraphicsObjectContainer::eventFilter(QObject *watched, QEvent *e)
*/
bool QFxGraphicsObjectContainer::synchronizedResizing() const
{
- return _syncedResize;
+ Q_D(const QFxGraphicsObjectContainer);
+ return d->syncedResize;
}
void QFxGraphicsObjectContainer::setSynchronizedResizing(bool on)
{
- if (on == _syncedResize)
+ Q_D(QFxGraphicsObjectContainer);
+ if (on == d->syncedResize)
return;
- if (_graphicsObject && _graphicsObject->isWidget()) {
- if (!on) {
- _graphicsObject->removeEventFilter(this);
- disconnect(this, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
- disconnect(this, SIGNAL(heightChanged()), this, SLOT(_q_updateSize()));
- }
- }
-
- _syncedResize = on;
-
- if (_graphicsObject && _graphicsObject->isWidget()) {
- if (on) {
- _graphicsObject->installEventFilter(this);
- connect(this, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
- connect(this, SIGNAL(heightChanged()), this, SLOT(_q_updateSize()));
- }
- }
+ d->syncedResize = on;
+ d->setFiltering(on);
}
-void QFxGraphicsObjectContainer::_q_updateSize()
+void QFxGraphicsObjectContainerPrivate::_q_updateSize()
{
- if (!_graphicsObject || !_graphicsObject->isWidget() || !_syncedResize)
+ if (!graphicsObject || !graphicsObject->isWidget() || !syncedResize)
return;
- QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(_graphicsObject);
- const QSizeF newSize(width(), height());
+ QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(graphicsObject);
+ const QSizeF newSize(width, height);
gw->resize(newSize);
//### will respecting the widgets min/max ever get us in trouble? (all other items always
@@ -189,3 +226,5 @@ void QFxGraphicsObjectContainer::_q_updateSize()
}
QT_END_NAMESPACE
+
+#include "moc_qfxgraphicsobjectcontainer.cpp"
diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h
index a8b7c8c..656a7f8 100644
--- a/src/declarative/fx/qfxgraphicsobjectcontainer.h
+++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h
@@ -51,6 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QGraphicsObject;
+class QFxGraphicsObjectContainerPrivate;
class Q_DECLARATIVE_EXPORT QFxGraphicsObjectContainer : public QFxItem
{
@@ -74,12 +75,9 @@ protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
bool eventFilter(QObject *watched, QEvent *e);
-private Q_SLOTS:
- void _q_updateSize();
-
private:
- QGraphicsObject *_graphicsObject;
- bool _syncedResize;
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxGraphicsObjectContainer)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index 9aa1198..6abe88e 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -145,11 +145,11 @@ public:
class QFxGridViewPrivate : public QFxFlickablePrivate
{
- Q_DECLARE_PUBLIC(QFxGridView);
+ Q_DECLARE_PUBLIC(QFxGridView)
public:
QFxGridViewPrivate()
- : model(0), currentItem(0), tmpCurrent(0), flow(QFxGridView::LeftToRight)
+ : model(0), currentItem(0), flow(QFxGridView::LeftToRight)
, visiblePos(0), visibleIndex(0) , currentIndex(-1)
, cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1)
, highlightComponent(0), highlight(0), trackedItem(0)
@@ -298,7 +298,6 @@ public:
QList<FxGridItem*> visibleItems;
QHash<QFxItem*,int> unrequestedItems;
FxGridItem *currentItem;
- QFxItem *tmpCurrent;
QFxGridView::Flow flow;
int visiblePos;
int visibleIndex;
@@ -640,10 +639,6 @@ void QFxGridViewPrivate::updateCurrent(int modelIndex)
return;
}
- if (tmpCurrent) {
- delete tmpCurrent;
- tmpCurrent = 0;
- }
FxGridItem *oldCurrentItem = currentItem;
currentIndex = modelIndex;
currentItem = createItem(modelIndex);
@@ -821,12 +816,8 @@ void QFxGridView::setCurrentIndex(int index)
QFxItem *QFxGridView::currentItem()
{
Q_D(QFxGridView);
- if (!d->currentItem) {
- // Always return something valid
- if (!d->tmpCurrent)
- d->tmpCurrent = new QFxItem(viewport());
- return d->tmpCurrent;
- }
+ if (!d->currentItem)
+ return 0;
return d->currentItem->item;
}
@@ -1000,7 +991,7 @@ void QFxGridView::setCellWidth(int cellWidth)
if (cellWidth != d->cellWidth && cellWidth > 0) {
d->cellWidth = qMax(1, cellWidth);
d->updateGrid();
- emit cellSizeChanged();
+ emit cellWidthChanged();
d->layout();
}
}
@@ -1017,7 +1008,7 @@ void QFxGridView::setCellHeight(int cellHeight)
if (cellHeight != d->cellHeight && cellHeight > 0) {
d->cellHeight = qMax(1, cellHeight);
d->updateGrid();
- emit cellSizeChanged();
+ emit cellHeightChanged();
d->layout();
}
}
diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h
index 08a7565..7f30f03 100644
--- a/src/declarative/fx/qfxgridview.h
+++ b/src/declarative/fx/qfxgridview.h
@@ -67,8 +67,8 @@ class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable
Q_PROPERTY(Flow flow READ flow WRITE setFlow)
Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
- Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellSizeChanged)
- Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellSizeChanged)
+ Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
+ Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
Q_CLASSINFO("DefaultProperty", "data")
public:
@@ -121,7 +121,8 @@ public Q_SLOTS:
Q_SIGNALS:
void countChanged();
void currentIndexChanged();
- void cellSizeChanged();
+ void cellWidthChanged();
+ void cellHeightChanged();
protected:
virtual void viewportMoved();
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 4d31aaa..a155d5a 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -408,12 +408,12 @@ public:
class QFxKeyNavigationAttached : public QObject, public QFxItemKeyFilter
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QFxKeyNavigationAttached);
+ Q_DECLARE_PRIVATE(QFxKeyNavigationAttached)
- Q_PROPERTY(QFxItem *left READ left WRITE setLeft NOTIFY changed);
- Q_PROPERTY(QFxItem *right READ right WRITE setRight NOTIFY changed);
- Q_PROPERTY(QFxItem *up READ up WRITE setUp NOTIFY changed);
- Q_PROPERTY(QFxItem *down READ down WRITE setDown NOTIFY changed);
+ Q_PROPERTY(QFxItem *left READ left WRITE setLeft NOTIFY changed)
+ Q_PROPERTY(QFxItem *right READ right WRITE setRight NOTIFY changed)
+ Q_PROPERTY(QFxItem *up READ up WRITE setUp NOTIFY changed)
+ Q_PROPERTY(QFxItem *down READ down WRITE setDown NOTIFY changed)
public:
QFxKeyNavigationAttached(QObject * = 0);
@@ -1257,12 +1257,6 @@ QFxKeysAttached *QFxKeysAttached::qmlAttachedProperties(QObject *obj)
*/
/*!
- \fn void QFxItem::activeFocusChanged()
-
- This signal is emitted when this item gains active focus.
-*/
-
-/*!
\fn void QFxItem::baselineOffsetChanged()
This signal is emitted when the baseline offset of the item
@@ -2260,16 +2254,6 @@ void QFxItem::setKeepMouseGrab(bool keep)
}
/*!
- This function emits the \e activeFocusChanged signal.
- \a flag is not used.
- */
-void QFxItem::activeFocusChanged(bool flag)
-{
- Q_UNUSED(flag);
- emit activeFocusChanged();
-}
-
-/*!
This function emits the \e focusChanged signal.
Subclasses overriding this function should call up
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index bde0c9e..b2aefe2 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -166,7 +166,6 @@ Q_SIGNALS:
void stateChanged(const QString &);
void focusChanged();
void wantsFocusChanged();
- void activeFocusChanged();
void parentChanged();
protected:
@@ -183,7 +182,6 @@ protected:
virtual void classBegin();
virtual void componentComplete();
virtual void focusChanged(bool);
- virtual void activeFocusChanged(bool);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void inputMethodEvent(QInputMethodEvent *);
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 1247021..604d16b 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -170,15 +170,15 @@ class QFxListViewPrivate : public QFxFlickablePrivate
public:
QFxListViewPrivate()
- : model(0), currentItem(0), tmpCurrent(0), orient(Qt::Vertical)
+ : model(0), currentItem(0), orient(Qt::Vertical)
, visiblePos(0), visibleIndex(0)
, averageSize(100.0), currentIndex(-1), requestedIndex(-1)
, highlightRangeStart(0), highlightRangeEnd(0)
, highlightComponent(0), highlight(0), trackedItem(0)
, moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0.0)
+ , highlightMoveSpeed(400), highlightResizeSpeed(400)
, ownModel(false), wrap(false), autoHighlight(true)
, haveHighlightRange(false), strictHighlightRange(false)
- , highlightMoveSpeed(400), highlightResizeSpeed(400)
{}
void init();
@@ -371,7 +371,6 @@ public:
QList<FxListItem*> visibleItems;
QHash<QFxItem*,int> unrequestedItems;
FxListItem *currentItem;
- QFxItem *tmpCurrent;
Qt::Orientation orient;
int visiblePos;
int visibleIndex;
@@ -752,10 +751,6 @@ void QFxListViewPrivate::updateCurrent(int modelIndex)
return;
}
- if (tmpCurrent) {
- delete tmpCurrent;
- tmpCurrent = 0;
- }
FxListItem *oldCurrentItem = currentItem;
currentIndex = modelIndex;
currentItem = createItem(modelIndex);
@@ -991,14 +986,8 @@ void QFxListView::setCurrentIndex(int index)
QFxItem *QFxListView::currentItem()
{
Q_D(QFxListView);
- if (!d->currentItem) {
- // Always return something valid
- if (!d->tmpCurrent) {
- d->tmpCurrent = new QFxItem;
- d->tmpCurrent->setParent(viewport());
- }
- return d->tmpCurrent;
- }
+ if (!d->currentItem)
+ return 0;
return d->currentItem->item;
}
@@ -1180,6 +1169,7 @@ void QFxListView::setOrientation(Qt::Orientation orientation)
setViewportHeight(-1);
d->clear();
refill();
+ emit orientationChanged();
d->updateCurrent(d->currentIndex);
}
}
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 3cff422..5a83604 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -72,7 +72,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
Q_PROPERTY(bool strictlyEnforceHighlightRange READ strictlyEnforceHighlightRange WRITE setStrictlyEnforceHighlightRange)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged)
@@ -106,7 +106,7 @@ public:
bool strictlyEnforceHighlightRange() const;
void setStrictlyEnforceHighlightRange(bool strict);
-
+
qreal preferredHighlightBegin() const;
void setPreferredHighlightBegin(qreal);
@@ -144,6 +144,7 @@ public Q_SLOTS:
Q_SIGNALS:
void countChanged();
void spacingChanged();
+ void orientationChanged();
void currentIndexChanged();
void currentSectionChanged();
void sectionExpressionChanged();
diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp
index e4500aa..f8e7213 100644
--- a/src/declarative/fx/qfxpositioners.cpp
+++ b/src/declarative/fx/qfxpositioners.cpp
@@ -97,6 +97,7 @@ void QFxBasePositioner::setSpacing(int s)
return;
d->_spacing = s;
prePositioning();
+ emit spacingChanged();
}
QmlTransition *QFxBasePositioner::move() const
diff --git a/src/declarative/fx/qfxpositioners.h b/src/declarative/fx/qfxpositioners.h
index 89a61d7..d62da08 100644
--- a/src/declarative/fx/qfxpositioners.h
+++ b/src/declarative/fx/qfxpositioners.h
@@ -59,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxBasePositioner : public QFxItem
{
Q_OBJECT
- Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
+ Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
Q_PROPERTY(QmlTransition *move READ move WRITE setMove)
Q_PROPERTY(QmlTransition *add READ add WRITE setAdd)
Q_PROPERTY(QmlTransition *remove READ remove WRITE setRemove)
@@ -93,6 +93,7 @@ protected:
Q_SIGNALS:
void layoutItemChanged();
+ void spacingChanged();
protected Q_SLOTS:
virtual void doPositioning()=0;
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index f4c2e4c..ccb8f7e 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -407,7 +407,7 @@ void QFxTextEdit::setCursorVisible(bool on)
return;
d->cursorVisible = on;
QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut);
- if (!on && !d->preserveSelection)
+ if (!on && !d->persistentSelection)
d->control->setCursorIsFocusIndicator(true);
d->control->processEvent(&focusEvent, QPointF(0, 0));
}
@@ -590,23 +590,23 @@ void QFxTextEdit::setFocusOnPress(bool on)
}
/*!
- \qmlproperty bool TextEdit::preserveSelection
+ \qmlproperty bool TextEdit::persistentSelection
Whether the TextEdit should keep the selection visible when it loses focus to another
item in the scene. By default this is set to true;
*/
-bool QFxTextEdit::preserveSelection() const
+bool QFxTextEdit::persistentSelection() const
{
Q_D(const QFxTextEdit);
- return d->preserveSelection;
+ return d->persistentSelection;
}
-void QFxTextEdit::setPreserveSelection(bool on)
+void QFxTextEdit::setPersistentSelection(bool on)
{
Q_D(QFxTextEdit);
- if (d->preserveSelection == on)
+ if (d->persistentSelection == on)
return;
- d->preserveSelection = on;
+ d->persistentSelection = on;
}
qreal QFxTextEdit::textMargin() const
@@ -822,7 +822,7 @@ void QFxTextEdit::keyReleaseEvent(QKeyEvent *event)
\overload
Handles changing of the focus property. Focus is applied to the control
even if the edit does not have active focus. This is because things
- like KeyProxy can give the behavior of focus even when activeFocus isn't
+ like KeyProxy can give the behavior of focus even when hasFocus() isn't
true.
*/
void QFxTextEdit::focusChanged(bool hasFocus)
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 1a5d968..f4f101a 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -83,7 +83,7 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress)
- Q_PROPERTY(bool preserveSelection READ preserveSelection WRITE setPreserveSelection)
+ Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection)
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin)
public:
@@ -154,8 +154,8 @@ public:
bool focusOnPress() const;
void setFocusOnPress(bool on);
- bool preserveSelection() const;
- void setPreserveSelection(bool on);
+ bool persistentSelection() const;
+ void setPersistentSelection(bool on);
qreal textMargin() const;
void setTextMargin(qreal margin);
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index 9c73db9..82481ff 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -70,7 +70,7 @@ public:
QFxTextEditPrivate()
: color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop),
dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false),
- preserveSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
+ persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
cursorComponent(0), cursor(0), format(QFxTextEdit::AutoText), document(0)
{
}
@@ -98,7 +98,7 @@ public:
bool richText;
bool cursorVisible;
bool focusOnPress;
- bool preserveSelection;
+ bool persistentSelection;
qreal textMargin;
int lastSelectionStart;
int lastSelectionEnd;
diff --git a/src/declarative/fx/qfxtextinput.h b/src/declarative/fx/qfxtextinput.h
index b1e8b14..d5d0450 100644
--- a/src/declarative/fx/qfxtextinput.h
+++ b/src/declarative/fx/qfxtextinput.h
@@ -193,7 +193,7 @@ private Q_SLOTS:
void updateRect(const QRect &r = QRect());
private:
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxTextInput);
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxTextInput)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index fb1cfcf..943f909 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -239,6 +239,10 @@ class QFxVisualDataModelPrivate : public QObjectPrivate
public:
QFxVisualDataModelPrivate(QmlContext *);
+ static QFxVisualDataModelPrivate *get(QFxVisualDataModel *m) {
+ return static_cast<QFxVisualDataModelPrivate *>(QObjectPrivate::get(m));
+ }
+
QGuard<QListModelInterface> m_listModelInterface;
QGuard<QAbstractItemModel> m_abstractItemModel;
QGuard<QFxVisualDataModel> m_visualItemModel;
@@ -264,10 +268,10 @@ public:
}
if (m_roles.count() == 1)
m_roleNames.insert(QLatin1String("modelData"), m_roles.at(0));
- } else if (m_modelList) {
+ } else if (m_listAccessor) {
m_roleNames.insert(QLatin1String("modelData"), 0);
- if (m_modelList->type() == QmlListAccessor::Instance) {
- if (QObject *object = m_modelList->at(0).value<QObject*>()) {
+ if (m_listAccessor->type() == QmlListAccessor::Instance) {
+ if (QObject *object = m_listAccessor->at(0).value<QObject*>()) {
int count = object->metaObject()->propertyCount();
for (int ii = 1; ii < count; ++ii) {
const QMetaProperty &prop = object->metaObject()->property(ii);
@@ -330,7 +334,7 @@ public:
QFxVisualDataModelData *data(QObject *item);
QVariant m_modelVariant;
- QmlListAccessor *m_modelList;
+ QmlListAccessor *m_listAccessor;
int modelCount() const {
if (m_visualItemModel)
@@ -339,8 +343,8 @@ public:
return m_listModelInterface->count();
if (m_abstractItemModel)
return m_abstractItemModel->rowCount();
- if (m_modelList)
- return m_modelList->count();
+ if (m_listAccessor)
+ return m_listAccessor->count();
return 0;
}
};
@@ -363,7 +367,8 @@ class QFxVisualDataModelData : public QObject
{
Q_OBJECT
public:
- QFxVisualDataModelData(int index, QFxVisualDataModelPrivate *model);
+ QFxVisualDataModelData(int index, QFxVisualDataModel *model);
+ ~QFxVisualDataModelData();
Q_PROPERTY(int index READ index NOTIFY indexChanged)
int index() const;
@@ -379,7 +384,7 @@ Q_SIGNALS:
private:
friend class QFxVisualDataModelDataMetaObject;
int m_index;
- QFxVisualDataModelPrivate *m_model;
+ QGuard<QFxVisualDataModel> m_model;
QFxVisualDataModelDataMetaObject *m_meta;
};
@@ -404,15 +409,19 @@ int QFxVisualDataModelDataMetaObject::createProperty(const char *name, const cha
QFxVisualDataModelData *data =
static_cast<QFxVisualDataModelData *>(object());
- if ((!data->m_model->m_listModelInterface || !data->m_model->m_abstractItemModel)
- && data->m_model->m_modelList) {
- data->m_model->ensureRoles();
- if (data->m_model->m_roleNames.contains(QLatin1String(name)))
+ if (!data->m_model)
+ return -1;
+
+ QFxVisualDataModelPrivate *model = QFxVisualDataModelPrivate::get(data->m_model);
+
+ if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
+ model->ensureRoles();
+ if (model->m_roleNames.contains(QLatin1String(name)))
return QmlOpenMetaObject::createProperty(name, type);
} else {
- data->m_model->ensureRoles();
+ model->ensureRoles();
const QLatin1String sname(name);
- if (data->m_model->m_roleNames.contains(sname))
+ if (model->m_roleNames.contains(sname))
return QmlOpenMetaObject::createProperty(name, type);
}
return -1;
@@ -425,45 +434,48 @@ QFxVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro
QFxVisualDataModelData *data =
static_cast<QFxVisualDataModelData *>(object());
+
+ Q_ASSERT(data->m_model);
+ QFxVisualDataModelPrivate *model = QFxVisualDataModelPrivate::get(data->m_model);
+
QString name = QLatin1String(prop.name());
- if ((!data->m_model->m_listModelInterface || !data->m_model->m_abstractItemModel)
- && data->m_model->m_modelList) {
+ if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
if (name == QLatin1String("modelData")) {
- if (data->m_model->m_modelList->type() == QmlListAccessor::Instance) {
- QObject *object = data->m_model->m_modelList->at(0).value<QObject*>();
+ if (model->m_listAccessor->type() == QmlListAccessor::Instance) {
+ QObject *object = model->m_listAccessor->at(0).value<QObject*>();
return object->metaObject()->property(1).read(object); // the first property after objectName
}
- return data->m_model->m_modelList->at(data->m_index);
+ return model->m_listAccessor->at(data->m_index);
} else {
// return any property of a single object instance.
- QObject *object = data->m_model->m_modelList->at(0).value<QObject*>();
+ QObject *object = model->m_listAccessor->at(0).value<QObject*>();
return object->property(prop.name());
}
- } else if (data->m_model->m_listModelInterface) {
- data->m_model->ensureRoles();
- QHash<QString,int>::const_iterator it = data->m_model->m_roleNames.find(name);
- if (it != data->m_model->m_roleNames.end()) {
+ } else if (model->m_listModelInterface) {
+ model->ensureRoles();
+ QHash<QString,int>::const_iterator it = model->m_roleNames.find(name);
+ if (it != model->m_roleNames.end()) {
roles.append(*it);
- QHash<int,QVariant> values = data->m_model->m_listModelInterface->data(data->m_index, QList<int>() << *it);
+ QHash<int,QVariant> values = model->m_listModelInterface->data(data->m_index, QList<int>() << *it);
if (values.isEmpty())
return QVariant();
else
return values.value(*it);
- } else if (data->m_model->m_roles.count() == 1 && name == QLatin1String("modelData")) {
+ } else if (model->m_roles.count() == 1 && name == QLatin1String("modelData")) {
//for compatability with other lists, assign modelData if there is only a single role
- QHash<int,QVariant> values = data->m_model->m_listModelInterface->data(data->m_index, QList<int>() << data->m_model->m_roles.first());
+ QHash<int,QVariant> values = model->m_listModelInterface->data(data->m_index, QList<int>() << model->m_roles.first());
if (values.isEmpty())
return QVariant();
else
return *values.begin();
}
- } else if (data->m_model->m_abstractItemModel) {
- data->m_model->ensureRoles();
- QHash<QString,int>::const_iterator it = data->m_model->m_roleNames.find(name);
- if (it != data->m_model->m_roleNames.end()) {
+ } else if (model->m_abstractItemModel) {
+ model->ensureRoles();
+ QHash<QString,int>::const_iterator it = model->m_roleNames.find(name);
+ if (it != model->m_roleNames.end()) {
roles.append(*it);
- QModelIndex index = data->m_model->m_abstractItemModel->index(data->m_index, 0);
- return data->m_model->m_abstractItemModel->data(index, *it);
+ QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0);
+ return model->m_abstractItemModel->data(index, *it);
}
}
Q_ASSERT(!"Can never be reached");
@@ -471,12 +483,16 @@ QFxVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro
}
QFxVisualDataModelData::QFxVisualDataModelData(int index,
- QFxVisualDataModelPrivate *model)
+ QFxVisualDataModel *model)
: m_index(index), m_model(model),
m_meta(new QFxVisualDataModelDataMetaObject(this))
{
}
+QFxVisualDataModelData::~QFxVisualDataModelData()
+{
+}
+
int QFxVisualDataModelData::index() const
{
return m_index;
@@ -531,7 +547,7 @@ QFxVisualDataModelParts::QFxVisualDataModelParts(QFxVisualDataModel *parent)
QFxVisualDataModelPrivate::QFxVisualDataModelPrivate(QmlContext *ctxt)
: m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0)
-, m_context(ctxt), m_parts(0), m_modelList(0)
+, m_context(ctxt), m_parts(0), m_listAccessor(0)
{
}
@@ -556,8 +572,8 @@ QFxVisualDataModel::QFxVisualDataModel(QmlContext *ctxt)
QFxVisualDataModel::~QFxVisualDataModel()
{
Q_D(QFxVisualDataModel);
- if (d->m_modelList)
- delete d->m_modelList;
+ if (d->m_listAccessor)
+ delete d->m_listAccessor;
}
QVariant QFxVisualDataModel::model() const
@@ -569,8 +585,8 @@ QVariant QFxVisualDataModel::model() const
void QFxVisualDataModel::setModel(const QVariant &model)
{
Q_D(QFxVisualDataModel);
- delete d->m_modelList;
- d->m_modelList = 0;
+ delete d->m_listAccessor;
+ d->m_listAccessor = 0;
d->m_modelVariant = model;
if (d->m_listModelInterface) {
// Assume caller has released all items.
@@ -642,8 +658,8 @@ void QFxVisualDataModel::setModel(const QVariant &model)
this, SLOT(_q_destroyingPackage(QmlPackage*)));
return;
}
- d->m_modelList = new QmlListAccessor;
- d->m_modelList->setList(model, d->m_context?d->m_context->engine():qmlEngine(this));
+ d->m_listAccessor = new QmlListAccessor;
+ d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this));
if (d->m_delegate && d->modelCount()) {
emit itemsInserted(0, d->modelCount());
emit countChanged();
@@ -752,7 +768,7 @@ QFxItem *QFxVisualDataModel::item(int index, const QByteArray &viewId, bool comp
QmlContext *ccontext = d->m_context;
if (!ccontext) ccontext = qmlContext(this);
QmlContext *ctxt = new QmlContext(ccontext);
- QFxVisualDataModelData *data = new QFxVisualDataModelData(index, d);
+ QFxVisualDataModelData *data = new QFxVisualDataModelData(index, this);
ctxt->setContextProperty(QLatin1String("model"), data);
ctxt->addDefaultObject(data);
nobj = d->m_delegate->beginCreate(ctxt);
@@ -821,7 +837,7 @@ QVariant QFxVisualDataModel::evaluate(int index, const QString &expression, QObj
QmlContext *ccontext = d->m_context;
if (!ccontext) ccontext = qmlContext(this);
QmlContext *ctxt = new QmlContext(ccontext);
- QFxVisualDataModelData *data = new QFxVisualDataModelData(index, d);
+ QFxVisualDataModelData *data = new QFxVisualDataModelData(index, this);
ctxt->addDefaultObject(data);
QmlExpression e(ctxt, expression, objectContext);
e.setTrackChange(false);