summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-08-19 05:20:04 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-08-19 05:20:04 (GMT)
commit3556cc32978f59ce6e6f23f984ed1f0a5f475c4f (patch)
tree9f8d105120af0bb4e9b9da2f66a0184c23526750
parent9a954d44aa20e0eb21bdf2820941bd7a1908096d (diff)
parentebdda1575dcb815e89b2d9ee16a8dc2928f61b4c (diff)
downloadQt-3556cc32978f59ce6e6f23f984ed1f0a5f475c4f.zip
Qt-3556cc32978f59ce6e6f23f984ed1f0a5f475c4f.tar.gz
Qt-3556cc32978f59ce6e6f23f984ed1f0a5f475c4f.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: src/declarative/fx/qfxmouseregion.cpp
-rw-r--r--demos/declarative/calculator/calculator.qml2
-rw-r--r--demos/declarative/contacts/Contact.qml5
-rw-r--r--demos/declarative/flickr/content/MediaLineEdit.qml2
-rw-r--r--demos/declarative/flickr/content/Slider.qml2
-rw-r--r--doc/src/snippets/declarative/drag.qml6
-rw-r--r--examples/declarative/dial/dial.qml2
-rw-r--r--examples/declarative/minehunt/Description.qml2
-rw-r--r--examples/declarative/mouseregion/mouse.qml3
-rw-r--r--examples/declarative/slideswitch/Switch.qml2
-rw-r--r--examples/declarative/velocity/Day.qml2
-rw-r--r--src/declarative/fx/qfxevents_p.h2
-rw-r--r--src/declarative/fx/qfxitem.cpp2
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp86
-rw-r--r--src/declarative/fx/qfxmouseregion.h22
-rw-r--r--src/declarative/fx/qfxmouseregion_p.h14
-rw-r--r--src/declarative/fx/qfxtextinput.cpp8
-rw-r--r--src/declarative/fx/qfxtextinput.h3
-rw-r--r--src/declarative/qml/qmlcompiler.cpp10
-rw-r--r--src/declarative/util/qmlbind.cpp20
-rw-r--r--src/declarative/util/qmlconnection.cpp20
-rw-r--r--src/declarative/util/qmlscript.cpp12
-rw-r--r--src/declarative/util/qmlsetproperties.cpp55
-rw-r--r--src/declarative/util/qmlstate.cpp34
-rw-r--r--src/declarative/util/qmltransition.cpp28
-rw-r--r--tests/auto/declarative/anchors/tst_anchors.cpp6
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp17
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp6
-rw-r--r--tests/auto/declarative/pathview/data/pathview.qml2
-rw-r--r--tests/auto/declarative/pathview/tst_pathview.cpp18
-rw-r--r--tests/auto/declarative/repeater/tst_repeater.cpp6
30 files changed, 169 insertions, 230 deletions
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml
index f766a30..56bdc4d 100644
--- a/demos/declarative/calculator/calculator.qml
+++ b/demos/declarative/calculator/calculator.qml
@@ -8,7 +8,7 @@ Rect {
Script { source: "calculator.js" }
VerticalPositioner {
- x: 2; spacing: 10; margin: 2
+ x: 2; spacing: 10;
Rect {
id: Container
diff --git a/demos/declarative/contacts/Contact.qml b/demos/declarative/contacts/Contact.qml
index c6ed906..d02157c 100644
--- a/demos/declarative/contacts/Contact.qml
+++ b/demos/declarative/contacts/Contact.qml
@@ -82,9 +82,10 @@ Item {
}
VerticalPositioner {
id: layout
- anchors.fill: parent
+ width: contents.width
+ height:contents.height
+ anchors.centerIn: parent
spacing: 5
- margin: 5
ContactField {
id: labelField
anchors.left: layout.left
diff --git a/demos/declarative/flickr/content/MediaLineEdit.qml b/demos/declarative/flickr/content/MediaLineEdit.qml
index e175b4e..1642d44 100644
--- a/demos/declarative/flickr/content/MediaLineEdit.qml
+++ b/demos/declarative/flickr/content/MediaLineEdit.qml
@@ -86,7 +86,7 @@ Item {
text: Container.label + "..."
}
- TextEdit {
+ TextInput {
id: Editor
font.bold: true
color: "white"
diff --git a/demos/declarative/flickr/content/Slider.qml b/demos/declarative/flickr/content/Slider.qml
index a2ec420..24f6f90 100644
--- a/demos/declarative/flickr/content/Slider.qml
+++ b/demos/declarative/flickr/content/Slider.qml
@@ -29,7 +29,7 @@ Item {
MouseRegion {
anchors.fill: parent; drag.target: parent
- drag.axis: "x"; drag.minimumX: 2; drag.maximumX: Slider.xMax+2
+ drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: Slider.xMax+2
onPositionChanged: { value = (maximum - minimum) * (Handle.x-2) / Slider.xMax + minimum; }
}
}
diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/declarative/drag.qml
index 2191b6f..8b1765b 100644
--- a/doc/src/snippets/declarative/drag.qml
+++ b/doc/src/snippets/declarative/drag.qml
@@ -9,9 +9,9 @@ Rect {
MouseRegion {
anchors.fill: parent
drag.target: pic
- drag.axis: "x"
- drag.xmin: 0
- drag.xmax: blurtest.width-pic.width
+ drag.axis: "XAxis"
+ drag.minimumX: 0
+ drag.maximumX: blurtest.width-pic.width
}
}
}
diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial.qml
index 75bd9b1..75bd65c 100644
--- a/examples/declarative/dial/dial.qml
+++ b/examples/declarative/dial/dial.qml
@@ -26,7 +26,7 @@ Rect {
}
MouseRegion {
anchors.fill: parent
- drag.target: parent; drag.axis: "x"; drag.minimumX: 2; drag.maximumX: 128
+ drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: 128
}
}
}
diff --git a/examples/declarative/minehunt/Description.qml b/examples/declarative/minehunt/Description.qml
index cf02bff..2bc182f 100644
--- a/examples/declarative/minehunt/Description.qml
+++ b/examples/declarative/minehunt/Description.qml
@@ -7,7 +7,7 @@ Item {
MouseRegion {
anchors.fill: parent
drag.target: Page
- drag.axis: "xy"
+ drag.axis: "XandYAxis"
drag.minimumX: 0
drag.maximumX: 1000
drag.minimumY: 0
diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml
index 34c6e66..0cb8bb9 100644
--- a/examples/declarative/mouseregion/mouse.qml
+++ b/examples/declarative/mouseregion/mouse.qml
@@ -8,6 +8,7 @@ Rect {
color: "red"
Text { text: "Click"; anchors.centerIn: parent }
MouseRegion {
+ hoverEnabled: true
onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
onClicked: { print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') }
@@ -24,7 +25,7 @@ Rect {
Text { text: "Drag"; anchors.centerIn: parent }
MouseRegion {
drag.target: parent
- drag.axis: "x"
+ drag.axis: "XAxis"
drag.minimumX: 0
drag.maximumX: 150
onPressed: { print('press') }
diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml
index b5de9ec..b476be2 100644
--- a/examples/declarative/slideswitch/Switch.qml
+++ b/examples/declarative/slideswitch/Switch.qml
@@ -36,7 +36,7 @@ Item {
anchors.fill: Knob
onClicked: { toggle() }
onReleased: { dorelease() }
- drag.target: Knob; drag.axis: "x"; drag.minimumX: 1; drag.maximumX: 78
+ drag.target: Knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
}
states: [
State {
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index c959b0c..d67eabe 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -70,7 +70,7 @@ Rect {
onClicked: { MyText.focus = true }
anchors.fill: parent
drag.target: StickyPage
- drag.axis: "xy"
+ drag.axis: "XandYAxis"
drag.minimumY: 0
drag.maximumY: 500
drag.minimumX: 0
diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h
index fbf0c5f..7b0c24c 100644
--- a/src/declarative/fx/qfxevents_p.h
+++ b/src/declarative/fx/qfxevents_p.h
@@ -105,7 +105,7 @@ public:
QFxMouseEvent(int x, int y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers
, bool isClick=false, bool wasHeld=false)
: _x(x), _y(y), _button(button), _buttons(buttons), _modifiers(modifiers)
- , _wasHeld(wasHeld), _isClick(isClick), _accepted(false) {}
+ , _wasHeld(wasHeld), _isClick(isClick), _accepted(true) {}
int x() const { return _x; }
int y() const { return _y; }
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 1ab252c..4ec0a85 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -331,7 +331,7 @@ void QFxContents::setItem(QFxItem *item)
\code
Item {
focus: true
- key.onLeftPressed: print("move left")
+ Keys.onLeftPressed: print("move left")
}
\endcode
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index dc0f6b8..1da3c69 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -51,7 +51,7 @@ static const int PressAndHoldDelay = 800;
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Drag,QFxDrag)
QFxDrag::QFxDrag(QObject *parent)
-: QObject(parent), _target(0), _xmin(0), _xmax(0), _ymin(0), _ymax(0)
+: QObject(parent), _target(0), _axis(XandYAxis), _xmin(0), _xmax(0), _ymin(0), _ymax(0)
{
}
@@ -69,12 +69,12 @@ void QFxDrag::setTarget(QFxItem *t)
_target = t;
}
-QString QFxDrag::axis() const
+QFxDrag::Axis QFxDrag::axis() const
{
return _axis;
}
-void QFxDrag::setAxis(const QString &a)
+void QFxDrag::setAxis(QFxDrag::Axis a)
{
_axis = a;
}
@@ -138,7 +138,7 @@ void QFxDrag::setYmax(qreal m)
example extended so as to give a different color when you right click.
\snippet doc/src/snippets/declarative/mouseregion.qml 1
- For basic key handling, see \l Keys.
+ For basic key handling, see the \l {Keys}{Keys attached property}.
MouseRegion is an invisible item: it is never painted.
@@ -164,6 +164,8 @@ void QFxDrag::setYmax(qreal m)
The \l {MouseEvent}{mouse} parameter provides information about the mouse, including the x and y
position, and any buttons currently pressed.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
*/
/*!
@@ -175,6 +177,8 @@ void QFxDrag::setYmax(qreal m)
The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
position of the release of the click, and whether the click wasHeld.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
*/
/*!
@@ -183,6 +187,12 @@ void QFxDrag::setYmax(qreal m)
This handler is called when there is a press.
The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
position and which button was pressed.
+
+ The \e accepted property of the MouseEvent parameter determines whether this MouseRegion
+ will handle the press \b {and all future mouse events until release}. The default is to accept
+ the event and not allow other MouseRegions beneath this one to handle the event. If \e accepted
+ is set to false, \b {no further events will be sent to this MouseRegion} until the button is next
+ pressed.
*/
/*!
@@ -191,6 +201,8 @@ void QFxDrag::setYmax(qreal m)
This handler is called when there is a release.
The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
position of the release of the click, and whether the click wasHeld.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
*/
/*!
@@ -199,6 +211,8 @@ void QFxDrag::setYmax(qreal m)
This handler is called when there is a long press (currently 800ms).
The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
position of the press, and which button is pressed.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
*/
/*!
@@ -207,6 +221,8 @@ void QFxDrag::setYmax(qreal m)
This handler is called when there is a double-click (a press followed by a release followed by a press).
The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
position of the release of the click, and whether the click wasHeld.
+
+ The \e accepted property of the MouseEvent parameter is ignored in this handler.
*/
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,MouseRegion,QFxMouseRegion)
@@ -287,16 +303,17 @@ void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
else {
d->longPress = false;
d->saveEvent(event);
- d->dragX = drag()->axis().contains(QLatin1String("x"));
- d->dragY = drag()->axis().contains(QLatin1String("y"));
+ d->dragX = drag()->axis() & QFxDrag::XAxis;
+ d->dragY = drag()->axis() & QFxDrag::YAxis;
d->dragged = false;
+ setHovered(true);
d->start = event->pos();
d->startScene = event->scenePos();
- // ### we should only start timer if pressAndHold is connected to (but connectNotify doesn't work)
- d->pressAndHoldTimer.start(PressAndHoldDelay, this);
+ // we should only start timer if pressAndHold is connected to.
+ if (d->isConnected("pressAndHold(QFxMouseEvent*)"))
+ d->pressAndHoldTimer.start(PressAndHoldDelay, this);
setKeepMouseGrab(false);
- setPressed(true);
- event->accept();
+ event->setAccepted(setPressed(true));
}
}
@@ -366,7 +383,6 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
d->moved = true;
QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
emit positionChanged(&me);
- event->accept();
}
@@ -378,7 +394,9 @@ void QFxMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
else {
d->saveEvent(event);
setPressed(false);
- event->accept();
+ // If we don't accept hover, we need to reset containsMouse.
+ if (!acceptHoverEvents())
+ setHovered(false);
}
}
@@ -388,11 +406,13 @@ void QFxMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
if (!d->absorb)
QFxItem::mouseDoubleClickEvent(event);
else {
- d->saveEvent(event);
- setPressed(true);
- QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
- emit this->doubleClicked(&me);
- event->accept();
+ QFxItem::mouseDoubleClickEvent(event);
+ if (event->isAccepted()) {
+ // Only deliver the event if we have accepted the press.
+ d->saveEvent(event);
+ QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
+ emit this->doubleClicked(&me);
+ }
}
}
@@ -447,10 +467,22 @@ void QFxMouseRegion::timerEvent(QTimerEvent *event)
}
/*!
+ \qmlproperty bool hoverEnabled
+ This property holds whether hover events are handled.
+
+ By default, mouse events are only handled in response to a button event, or when a button is
+ pressed. Hover enables handling of all mouse events even when no mouse button is
+ pressed.
+
+ This property affects the containsMouse property and the onEntered, onExited and onPositionChanged signals.
+*/
+
+/*!
\qmlproperty bool MouseRegion::containsMouse
This property holds whether the mouse is currently inside the mouse region.
- \warning This property is only partially implemented -- it is only valid when the mouse is pressed, and not for hover events.
+ \warning This property is only partially implemented -- it is only valid when the mouse is moved over the
+ region. If the region moves under the mouse, \e containsMouse will not change.
*/
bool QFxMouseRegion::hovered() const
{
@@ -511,7 +543,7 @@ void QFxMouseRegion::setAcceptedButtons(Qt::MouseButtons buttons)
}
}
-void QFxMouseRegion::setPressed(bool p)
+bool QFxMouseRegion::setPressed(bool p)
{
Q_D(QFxMouseRegion);
bool isclick = d->pressed == true && p == false && d->dragged == false && d->hovered == true;
@@ -529,7 +561,9 @@ void QFxMouseRegion::setPressed(bool p)
}
emit pressedChanged();
+ return me.isAccepted();
}
+ return false;
}
QFxDrag *QFxMouseRegion::drag()
@@ -540,18 +574,18 @@ QFxDrag *QFxMouseRegion::drag()
/*!
\qmlproperty Item MouseRegion::drag.target
- \qmlproperty string MouseRegion::drag.axis
- \qmlproperty real MouseRegion::drag.xmin
- \qmlproperty real MouseRegion::drag.xmax
- \qmlproperty real MouseRegion::drag.ymin
- \qmlproperty real MouseRegion::drag.ymax
+ \qmlproperty Axis MouseRegion::drag.axis
+ \qmlproperty real MouseRegion::drag.minimumX
+ \qmlproperty real MouseRegion::drag.maximumX
+ \qmlproperty real MouseRegion::drag.minimumY
+ \qmlproperty real MouseRegion::drag.maximumY
drag provides a convenient way to make an item draggable.
\list
\i \c target specifies the item to drag.
- \i \c axis specifies whether dragging can be done horizontally (x), vertically (y), or both (x,y)
- \i the min and max properties limit how far the target can be dragged along the corresponding axes.
+ \i \c axis specifies whether dragging can be done horizontally (XAxis), vertically (YAxis), or both (XandYAxis)
+ \i the minimum and maximum properties limit how far the target can be dragged along the corresponding axes.
\endlist
The following example uses drag to reduce the opacity of an image as it moves to the right:
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index f2d22d3..ae54ff6 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -54,21 +54,26 @@ class Q_DECLARATIVE_EXPORT QFxDrag : public QObject
{
Q_OBJECT
+ Q_ENUMS(Axis)
Q_PROPERTY(QFxItem *target READ target WRITE setTarget)
- Q_PROPERTY(QString axis READ axis WRITE setAxis) //### enum
+ Q_PROPERTY(Axis axis READ axis WRITE setAxis)
Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin)
Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax)
Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin)
Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax)
//### consider drag and drop
+
public:
QFxDrag(QObject *parent=0);
~QFxDrag();
QFxItem *target() const;
void setTarget(QFxItem *);
- QString axis() const;
- void setAxis(const QString &);
+
+ enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
+ Axis axis() const;
+ void setAxis(Axis);
+
qreal xmin() const;
void setXmin(qreal);
qreal xmax() const;
@@ -80,7 +85,7 @@ public:
private:
QFxItem *_target;
- QString _axis;
+ Axis _axis;
qreal _xmin;
qreal _xmax;
qreal _ymin;
@@ -100,8 +105,9 @@ class Q_DECLARATIVE_EXPORT QFxMouseRegion : public QFxItem
Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
+ Q_PROPERTY(bool hoverEnabled READ acceptHoverEvents WRITE setAcceptHoverEvents)
Q_PROPERTY(QFxDrag *drag READ drag) //### add flicking to QFxDrag or add a QFxFlick ???
- //### trackingEnabled?
+
public:
QFxMouseRegion(QFxItem *parent=0);
~QFxMouseRegion();
@@ -115,9 +121,6 @@ public:
bool hovered() const;
bool pressed() const;
- void setHovered(bool);
- void setPressed(bool);
-
Qt::MouseButtons acceptedButtons() const;
void setAcceptedButtons(Qt::MouseButtons buttons);
@@ -139,6 +142,9 @@ Q_SIGNALS:
void exited();
protected:
+ void setHovered(bool);
+ bool setPressed(bool);
+
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/fx/qfxmouseregion_p.h b/src/declarative/fx/qfxmouseregion_p.h
index 1501a81..70df8d1 100644
--- a/src/declarative/fx/qfxmouseregion_p.h
+++ b/src/declarative/fx/qfxmouseregion_p.h
@@ -74,7 +74,6 @@ public:
{
Q_Q(QFxMouseRegion);
q->setAcceptedMouseButtons(Qt::LeftButton);
- q->setAcceptHoverEvents(true);
}
void saveEvent(QGraphicsSceneMouseEvent *event) {
@@ -84,6 +83,19 @@ public:
lastModifiers = event->modifiers();
}
+ bool isConnected(const char *signal) {
+ Q_Q(QFxMouseRegion);
+ int idx = QFxMouseRegion::staticMetaObject.indexOfSignal(signal);
+ if (idx < 32) {
+ quint32 mask = 1 << idx;
+ return QObjectPrivate::get(q)->connectedSignals[0] & mask;
+ } else if (idx < 64) {
+ quint32 mask = 1 << (idx-32);
+ return QObjectPrivate::get(q)->connectedSignals[1] & mask;
+ }
+ return false;
+ }
+
bool absorb : 1;
bool hovered : 1;
bool pressed : 1;
diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp
index a2e2a11..164739f 100644
--- a/src/declarative/fx/qfxtextinput.cpp
+++ b/src/declarative/fx/qfxtextinput.cpp
@@ -194,6 +194,7 @@ void QFxTextInput::setHAlign(HAlignment align)
{
Q_D(QFxTextInput);
d->hAlign = align;
+ //TODO: implement
}
bool QFxTextInput::isReadOnly() const
@@ -513,6 +514,13 @@ void QFxTextInput::drawContents(QPainter *p, const QRect &r)
p->restore();
}
+void QFxTextInput::selectAll()
+{
+ Q_D(QFxTextInput);
+ d->control->setSelection(0, d->control->text().length());
+}
+
+
/*!
\qmlproperty bool TextInput::smooth
diff --git a/src/declarative/fx/qfxtextinput.h b/src/declarative/fx/qfxtextinput.h
index fe72f1e..b5812d4 100644
--- a/src/declarative/fx/qfxtextinput.h
+++ b/src/declarative/fx/qfxtextinput.h
@@ -169,6 +169,9 @@ protected:
void focusChanged(bool hasFocus);
+public Q_SLOTS:
+ void selectAll();
+
private Q_SLOTS:
void updateSize();
void q_textChanged();
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index dea41ab..e04c876 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1201,9 +1201,13 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
// default property or to sub-objects (which are always in binding
// sub-contexts)
COMPILE_CHECK(buildIdProperty(prop, obj));
- if (prop->type == QVariant::String &&
- prop->values.at(0)->value.isString())
+ if (prop->type == QVariant::String){
+ if(!prop->values.at(0)->value.isString()){
+ //Need to convert to string to assign to the QString id property
+ prop->values.at(0)->value = Variant(prop->values.at(0)->value.asString());
+ }
COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
+ }
} else if (isAttachedPropertyName(prop->name)) {
@@ -1629,7 +1633,7 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop,
// children: [ Item {}, Item {} ]
// }
//
-// We allow assignming multiple values to single value properties
+// We allow assigning multiple values to single value properties
bool QmlCompiler::buildPropertyAssignment(QmlParser::Property *prop,
QmlParser::Object *obj,
const BindingContext &ctxt)
diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp
index 2ba8802..f3b5fa4 100644
--- a/src/declarative/util/qmlbind.cpp
+++ b/src/declarative/util/qmlbind.cpp
@@ -73,8 +73,8 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Bind,QmlBind)
to QML by C++. In these cases, regular property binding doesn't work. Bind
allows you to bind any value to any property.
- For example, imagine a C++ application that maps an "app.enteredText"
- property into QML. You could use Bind to update the enteredText property
+ For example, imagine a C++ application that maps an "app.enteredText"
+ property into QML. You could use Bind to update the enteredText property
like this.
\code
TextEdit { id: myTextField; text: "Please type here..." }
@@ -83,7 +83,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Bind,QmlBind)
Whenever the text in the TextEdit is updated, the C++ property will be
updated also.
- If the bind target or bind property is changed, the bound value is
+ If the bind target or bind property is changed, the bound value is
immediately pushed onto the new target.
\sa {qmlforcpp}{Qt Declarative Markup Language For C++ Programmers}
@@ -126,10 +126,6 @@ void QmlBind::setWhen(bool v)
\qmlproperty Object Bind::target
The object to be updated.
- */
-/*!
- \property QmlBind::target
- \brief the object to be updated.
*/
QObject *QmlBind::object()
{
@@ -148,10 +144,6 @@ void QmlBind::setObject(QObject *obj)
\qmlproperty string Bind::property
The property to be updated.
- */
-/*!
- \property QmlBind::property
- \brief the property of the target to be updated.
*/
QString QmlBind::property() const
{
@@ -169,12 +161,8 @@ void QmlBind::setProperty(const QString &p)
/*!
\qmlproperty any Bind::value
- The value to be set on the target object and property. This can be a
+ The value to be set on the target object and property. This can be a
constant (which isn't very useful), or a bound expression.
- */
-/*!
- \property QmlBind::value
- \brief the value to bind to.
*/
QVariant QmlBind::value() const
{
diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp
index 24bb61f..83804a5 100644
--- a/src/declarative/util/qmlconnection.cpp
+++ b/src/declarative/util/qmlconnection.cpp
@@ -134,16 +134,6 @@ QmlConnection::~QmlConnection()
By default, the sender is assumed to be the parent of the Connection.
*/
-
-/*!
- \property QmlConnection::sender
- \brief the object that sends the signal.
-
- By default, the sender is assumed to be the parent of the Connection.
-
- Note that the set/get methods are setSignalSender() and signalSender(),
- due to the pre-existence of QObject::sender().
-*/
QObject *QmlConnection::signalSender() const
{
Q_D(const QmlConnection);
@@ -233,11 +223,6 @@ void QmlConnection::componentComplete()
This is the default attribute of Connection.
*/
-
-/*!
- \property QmlConnection::script
- \brief the JavaScript executed whenever the signal is sent.
-*/
QString QmlConnection::script() const
{
Q_D(const QmlConnection);
@@ -275,11 +260,6 @@ Connection {
}
\endqml
*/
-
-/*!
- \property QmlConnection::signal
- \brief the signal from the sender to which the script is attached.
-*/
QString QmlConnection::signal() const
{
Q_D(const QmlConnection);
diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp
index 6bc21a2..0bff047 100644
--- a/src/declarative/util/qmlscript.cpp
+++ b/src/declarative/util/qmlscript.cpp
@@ -109,10 +109,6 @@ QmlScript::QmlScript(QObject *parent) : QObject(*(new QmlScriptPrivate), parent)
\default
JavaScript code to execute.
*/
-/*!
- \property QmlScript::script
- \brief a script snippet.
-*/
QString QmlScript::script() const
{
Q_D(const QmlScript);
@@ -131,10 +127,6 @@ void QmlScript::setScript(const QString &script)
Setting this property causes the Script element to read JavaScript code from
the file specified.
- */
-/*!
- \property QmlScript::source
- \brief the path to a script file.
*/
QUrl QmlScript::source() const
{
@@ -148,7 +140,7 @@ void QmlScript::setSource(const QUrl &source)
if (d->url == source)
return;
d->url = qmlContext(this)->resolvedUrl(source);
-
+
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
if (d->url.scheme() == QLatin1String("file")) {
QFile file(d->url.toLocalFile());
@@ -198,7 +190,7 @@ void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &s
if (scriptEngine->uncaughtException().isError()){
QScriptValue exception = scriptEngine->uncaughtException();
if (!exception.property(QLatin1String("fileName")).toString().isEmpty()){
- qWarning() << exception.property(QLatin1String("fileName")).toString()
+ qWarning() << exception.property(QLatin1String("fileName")).toString()
<< scriptEngine->uncaughtExceptionLineNumber()
<< exception.toString();
diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp
index a08f4ba..e7be329 100644
--- a/src/declarative/util/qmlsetproperties.cpp
+++ b/src/declarative/util/qmlsetproperties.cpp
@@ -56,9 +56,8 @@ QT_BEGIN_NAMESPACE
\qmlclass SetProperties QmlSetProperties
\brief The SetProperties element describes new property values for a state.
- SetProperties is a convenience element for changing many properties on a single
- object. It allows you to specify the property names and values similar to how
- you normally would specify them for the actual item:
+ SetProperties changes the properties of an item. It allows you to specify the property
+ names and values similar to how you normally would specify them for the actual item:
\code
SetProperties {
@@ -68,38 +67,12 @@ QT_BEGIN_NAMESPACE
width: 48
}
\endcode
-
- \c target is a property of \c SetProperties, so if the property you want to change
- is named \e target you will have to use \l SetProperty instead. You should also
- use \l SetProperty if you want to update the binding for a property,
- as SetProperties does not support this.
*/
/*!
\internal
\class QmlSetProperties
\brief The QmlSetProperties class describes new property values for a state.
-
- \ingroup group_states
-
- QmlSetProperties is a convenience class for changing many properties on a single
- object. It allows you to specify the property names and values similar to how
- you normally would specify them for the actual item:
-
- \code
- SetProperties {
- target: myRect
- x: 52
- y: 300
- width: 48
- }
- \endcode
-
- \c target is a property of \c SetProperties, so if the property you want to change
- is named \e target you will have to use QmlSetProperty instead. You should also use QmlSetProperty
- if you want to update the binding for a property, as QmlSetProperties does not support this.
-
- \sa QmlSetProperty
*/
/*!
@@ -107,15 +80,11 @@ QT_BEGIN_NAMESPACE
This property holds the object that the properties to change belong to
*/
-/*!
- \property QmlSetProperties::target
- \brief the object that the properties to change belong to
-*/
class QmlSetPropertiesPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlSetProperties)
public:
- QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true),
+ QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true),
isExplicit(false) {}
QObject *object;
@@ -141,9 +110,9 @@ public:
virtual void setCustomData(QObject *, const QByteArray &);
};
-void
-QmlSetPropertiesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
- const QByteArray &pre,
+void
+QmlSetPropertiesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
+ const QByteArray &pre,
const QmlCustomParserProperty &prop)
{
QByteArray propName = pre + prop.name();
@@ -156,7 +125,7 @@ QmlSetPropertiesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
continue;
} else if(value.userType() == qMetaTypeId<QmlCustomParserProperty>()) {
- QmlCustomParserProperty prop =
+ QmlCustomParserProperty prop =
qvariant_cast<QmlCustomParserProperty>(value);
QByteArray pre = propName + ".";
compileList(list, pre, prop);
@@ -167,8 +136,8 @@ QmlSetPropertiesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
}
}
-QByteArray
-QmlSetPropertiesParser::compile(const QList<QmlCustomParserProperty> &props,
+QByteArray
+QmlSetPropertiesParser::compile(const QList<QmlCustomParserProperty> &props,
bool *ok)
{
*ok = true;
@@ -238,10 +207,10 @@ void QmlSetPropertiesPrivate::decode()
data.clear();
}
-void QmlSetPropertiesParser::setCustomData(QObject *object,
+void QmlSetPropertiesParser::setCustomData(QObject *object,
const QByteArray &data)
{
- QmlSetPropertiesPrivate *p =
+ QmlSetPropertiesPrivate *p =
static_cast<QmlSetPropertiesPrivate *>(QObjectPrivate::get(object));
p->data = data;
p->decoded = false;
@@ -310,7 +279,7 @@ QmlSetProperties::ActionList QmlSetProperties::actions()
QByteArray property = d->properties.at(ii).first;
- Action a(d->object, QString::fromLatin1(property),
+ Action a(d->object, QString::fromLatin1(property),
d->properties.at(ii).second);
if (a.property.isValid()) {
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index 9967486..ce94aa8 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -168,13 +168,6 @@ QmlState::~QmlState()
Each state should have a unique name.
*/
-
-/*!
- \property QmlState::name
- \brief the name of the state
-
- Each state should have a unique name.
-*/
QString QmlState::name() const
{
Q_D(const QmlState);
@@ -200,14 +193,6 @@ bool QmlState::isWhenKnown() const
This should be set to an expression that evaluates to true when you want the state to
be applied.
*/
-
-/*!
- \property QmlState::when
- \brief when the state should be applied
-
- This should be set to an expression that evaluates to true when you want the state to
- be applied.
-*/
QmlBinding *QmlState::when() const
{
Q_D(const QmlState);
@@ -229,16 +214,6 @@ void QmlState::setWhen(QmlBinding *when)
The state being extended is treated as the base state in regards to
the changes specified by the extending state.
*/
-
-/*!
- \property QmlState::extends
- \brief the state that this state extends
-
- The state being extended is treated as the base state in regards to
- the changes specified by the extending state.
-
- \sa operations
-*/
QString QmlState::extends() const
{
Q_D(const QmlState);
@@ -260,15 +235,6 @@ void QmlState::setExtends(const QString &extends)
extends another state, then the changes are applied against the state being
extended.
*/
-
-/*!
- \property QmlState::operations
- \brief the changes to apply for this state
-
- By default these changes are applied against the default state. If the state
- extends another state, then the changes are applied against the state being
- extended.
-*/
QmlList<QmlStateOperation *> *QmlState::operations()
{
Q_D(QmlState);
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index a9b8cb3..fd22f6b 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -198,14 +198,6 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions,
}
\endcode
*/
-
-/*!
- \property QmlTransition::fromState
- \brief a selector indicating which states, when left, should trigger the transition.
-
- fromState is used in conjunction with toState to determine when a transition should
- be applied. The default value is "*" (any state).
-*/
QString QmlTransition::fromState() const
{
Q_D(const QmlTransition);
@@ -224,14 +216,6 @@ void QmlTransition::setFromState(const QString &f)
The default value is false.
*/
-
-
-/*!
- \property QmlTransition::reversible
- \brief whether the transition should be automatically reversed when the conditions that triggered this transition are reversed.
-
- The default value is false.
-*/
bool QmlTransition::reversible() const
{
Q_D(const QmlTransition);
@@ -244,13 +228,6 @@ void QmlTransition::setReversible(bool r)
d->reversible = r;
}
-/*!
- \property QmlTransition::toState
- \brief a selector indicating which states, when entered, should trigger the transition.
-
- toState is used in conjunction with fromState to determine when a transition should
- be applied. The default value is "*" (any state).
-*/
QString QmlTransition::toState() const
{
Q_D(const QmlTransition);
@@ -272,11 +249,6 @@ void QmlTransition::setToState(const QString &t)
which contains all the animations, and assign that to operations.
\default
*/
-
-/*!
- \property QmlTransition::operations
- \brief a list of the transition animations to be run.
-*/
QmlList<QmlAbstractAnimation *>* QmlTransition::operations()
{
Q_D(QmlTransition);
diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp
index 4830169..98ede65 100644
--- a/tests/auto/declarative/anchors/tst_anchors.cpp
+++ b/tests/auto/declarative/anchors/tst_anchors.cpp
@@ -25,15 +25,15 @@ private slots:
Find an item with the specified id.
*/
template<typename T>
-T *tst_anchors::findItem(QFxItem *parent, const QString &id)
+T *tst_anchors::findItem(QFxItem *parent, const QString &objectName)
{
const QMetaObject &mo = T::staticMetaObject;
for (int i = 0; i < parent->QSimpleCanvasItem::children().count(); ++i) {
QFxItem *item = qobject_cast<QFxItem*>(parent->QSimpleCanvasItem::children().at(i));
- if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
return static_cast<T*>(item);
}
- item = findItem<T>(item, id);
+ item = findItem<T>(item, objectName);
if (item)
return static_cast<T*>(item);
}
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index 466a7de..cd4678e 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -21,7 +21,7 @@ private slots:
private:
QFxView *createView(const QString &filename);
template<typename T>
- T *findItem(QFxItem *parent, const QString &id, int index=0);
+ T *findItem(QFxItem *parent, const QString &id, int index=-1);
};
tst_QFxLayouts::tst_QFxLayouts()
@@ -197,16 +197,19 @@ QFxView *tst_QFxLayouts::createView(const QString &filename)
}
/*
- Find an item with the specified id. If index is supplied then the
+ Find an item with the specified objectName. If index is supplied then the
item must also evaluate the {index} expression equal to index
*/
template<typename T>
-T *tst_QFxLayouts::findItem(QFxItem *parent, const QString &id, int index)
+T *tst_QFxLayouts::findItem(QFxItem *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = parent->children()->at(i);
- if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
+ for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
+ QFxItem *item = qobject_cast<QFxItem*>(parent->QGraphicsObject::children().at(i));
+ if(!item)
+ continue;
+ //qDebug() << item << item->objectName();
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QmlExpression e(qmlContext(item), "index", item);
e.setTrackChange(false);
@@ -216,7 +219,7 @@ T *tst_QFxLayouts::findItem(QFxItem *parent, const QString &id, int index)
return static_cast<T*>(item);
}
}
- item = findItem<T>(item, id, index);
+ item = findItem<T>(item, objectName, index);
if (item)
return static_cast<T*>(item);
}
diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
index 8cf0a85..8bf9c8a 100644
--- a/tests/auto/declarative/listview/tst_listview.cpp
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -456,14 +456,14 @@ QFxView *tst_QFxListView::createView(const QString &filename)
item must also evaluate the {index} expression equal to index
*/
template<typename T>
-T *tst_QFxListView::findItem(QFxItem *parent, const QString &id, int index)
+T *tst_QFxListView::findItem(QFxItem *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
qDebug() << parent->children()->count() << "children";
for (int i = 0; i < parent->children()->count(); ++i) {
QFxItem *item = parent->children()->at(i);
qDebug() << "try" << item;
- if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QmlExpression e(qmlContext(item), "index", item);
e.setTrackChange(false);
@@ -473,7 +473,7 @@ T *tst_QFxListView::findItem(QFxItem *parent, const QString &id, int index)
return static_cast<T*>(item);
}
}
- item = findItem<T>(item, id, index);
+ item = findItem<T>(item, objectName, index);
if (item)
return static_cast<T*>(item);
}
diff --git a/tests/auto/declarative/pathview/data/pathview.qml b/tests/auto/declarative/pathview/data/pathview.qml
index 5bf2085..7040e4c 100644
--- a/tests/auto/declarative/pathview/data/pathview.qml
+++ b/tests/auto/declarative/pathview/data/pathview.qml
@@ -12,7 +12,7 @@ Rect {
height: 20
width: 60
color: "white"
- pen.color: "black"
+ border.color: "black"
Text {
text: index
}
diff --git a/tests/auto/declarative/pathview/tst_pathview.cpp b/tests/auto/declarative/pathview/tst_pathview.cpp
index 92890ba..9cae961 100644
--- a/tests/auto/declarative/pathview/tst_pathview.cpp
+++ b/tests/auto/declarative/pathview/tst_pathview.cpp
@@ -101,7 +101,7 @@ tst_QFxPathView::tst_QFxPathView()
void tst_QFxPathView::items()
{
- QFxView *canvas = createView(SRCDIR "/data/pathview.xml");
+ QFxView *canvas = createView(SRCDIR "/data/pathview.qml");
TestModel model;
model.addItem("Fred", "12345");
@@ -133,7 +133,7 @@ void tst_QFxPathView::items()
void tst_QFxPathView::pathMoved()
{
- QFxView *canvas = createView(SRCDIR "/data/pathview.xml");
+ QFxView *canvas = createView(SRCDIR "/data/pathview.qml");
TestModel model;
model.addItem("Ben", "12345");
@@ -176,7 +176,7 @@ void tst_QFxPathView::pathMoved()
void tst_QFxPathView::limitedItems()
{
- QFxView *canvas = createView(SRCDIR "/data/pathview.xml");
+ QFxView *canvas = createView(SRCDIR "/data/pathview.qml");
TestModel model;
for(int i=0; i<100; i++)
@@ -220,23 +220,23 @@ QFxView *tst_QFxPathView::createView(const QString &filename)
QFile file(filename);
file.open(QFile::ReadOnly);
- QString xml = file.readAll();
- canvas->setQml(xml, filename);
+ QString qml = file.readAll();
+ canvas->setQml(qml, filename);
return canvas;
}
/*
- Find an item with the specified id. If index is supplied then the
+ Find an item with the specified objectName. If index is supplied then the
item must also evaluate the {index} expression equal to index
*/
template<typename T>
-T *tst_QFxPathView::findItem(QFxItem *parent, const QString &id, int index)
+T *tst_QFxPathView::findItem(QFxItem *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
for (int i = 0; i < parent->children()->count(); ++i) {
QFxItem *item = parent->children()->at(i);
- if (mo.cast(item) && (id.isEmpty() || item->id() == id)) {
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QmlExpression e(qmlContext(item), "index", item);
e.setTrackChange(false);
@@ -246,7 +246,7 @@ T *tst_QFxPathView::findItem(QFxItem *parent, const QString &id, int index)
return static_cast<T*>(item);
}
}
- item = findItem<T>(item, id, index);
+ item = findItem<T>(item, objectName, index);
if (item)
return static_cast<T*>(item);
}
diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp
index 0d3ec98..0e7c187 100644
--- a/tests/auto/declarative/repeater/tst_repeater.cpp
+++ b/tests/auto/declarative/repeater/tst_repeater.cpp
@@ -72,13 +72,13 @@ QFxView *tst_QFxRepeater::createView(const QString &filename)
}
template<typename T>
-T *tst_QFxRepeater::findItem(QFxItem *parent, const QString &id)
+T *tst_QFxRepeater::findItem(QFxItem *parent, const QString &objectName)
{
const QMetaObject &mo = T::staticMetaObject;
- if (mo.cast(parent) && (id.isEmpty() || parent->id() == id))
+ if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
return static_cast<T*>(parent);
for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = findItem<T>(parent->children()->at(i), id);
+ QFxItem *item = findItem<T>(parent->children()->at(i), objectName);
if (item)
return static_cast<T*>(item);
}