From 4bc81bb1cb3cd4a0a3fe071e00556124e770d7ac Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 08:56:24 +1000 Subject: Handle QAbstractItemModel layoutChanged() signal Treated identically to reset. Task-number: QTBUG-13146 --- src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 65b14cf..c6b8514 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -714,6 +714,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); + QObject::disconnect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_modelReset())); d->m_abstractItemModel = 0; } else if (d->m_visualItemModel) { QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)), @@ -761,6 +762,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); + QObject::connect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_modelReset())); d->m_metaDataCacheable = true; return; } -- cgit v0.12 From 6f4d7ef066fef92eda4ae9c1ba5a380c9e2ed95b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 26 Aug 2010 09:01:41 +1000 Subject: Remove unused code. --- src/declarative/util/qdeclarativelistmodel.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 0162beb..7504c23 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -58,9 +58,6 @@ Q_DECLARE_METATYPE(QListModelInterface *) QT_BEGIN_NAMESPACE -#define DATA_ROLE_ID 1 -#define DATA_ROLE_NAME "data" - QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListModelData::instructions() const { return (QDeclarativeListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData)); -- cgit v0.12 From 08df2a17f4f0ed9b5ce69ad91e3849260acda092 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 09:19:37 +1000 Subject: Add test for VisualItemModel layoutChanged() handling Task-number: QTBUG-13146 --- .../qdeclarativevisualdatamodel/data/datalist.qml | 15 ++++++++++ .../tst_qdeclarativevisualdatamodel.cpp | 35 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml new file mode 100644 index 0000000..a798f77 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + Text { objectName: "display"; text: display } + } + } +} diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index e0f32ea..3cd786f 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -83,6 +83,7 @@ public: private slots: void rootIndex(); + void updateLayout(); void objectListModel(); private: @@ -155,6 +156,40 @@ void tst_qdeclarativevisualdatamodel::rootIndex() delete obj; } +void tst_qdeclarativevisualdatamodel::updateLayout() +{ + QDeclarativeView view; + + QStandardItemModel model; + initStandardTreeModel(&model); + + view.rootContext()->setContextProperty("myModel", &model); + + view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml")); + + QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QDeclarativeItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QDeclarativeText *name = findItem(contentItem, "display", 0); + QCOMPARE(name->text(), QString("Row 1 Item")); + name = findItem(contentItem, "display", 1); + QCOMPARE(name->text(), QString("Row 2 Item")); + name = findItem(contentItem, "display", 2); + QCOMPARE(name->text(), QString("Row 3 Item")); + + model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder); + + name = findItem(contentItem, "display", 0); + QCOMPARE(name->text(), QString("Row 3 Item")); + name = findItem(contentItem, "display", 1); + QCOMPARE(name->text(), QString("Row 2 Item")); + name = findItem(contentItem, "display", 2); + QCOMPARE(name->text(), QString("Row 1 Item")); +} + void tst_qdeclarativevisualdatamodel::objectListModel() { QDeclarativeView view; -- cgit v0.12 From af6d440e241b9b9127b76a40c4c5ef051cf02401 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 26 Aug 2010 10:36:06 +1000 Subject: Remove dead code. --- src/declarative/util/qdeclarativexmllistmodel.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 7b3d4a8..02bf370 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -466,8 +466,6 @@ public: QList roleObjects; static void append_role(QDeclarativeListProperty *list, QDeclarativeXmlListModelRole *role); static void clear_role(QDeclarativeListProperty *list); - static void removeAt_role(QDeclarativeListProperty *list, int i); - static void insert_role(QDeclarativeListProperty *list, int i, QDeclarativeXmlListModelRole *role); QList > data; int redirectCount; }; -- cgit v0.12 From 8bedba8ecb9cde3de68defea3e2b062504224aa6 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 11:44:03 +1000 Subject: Fix ListView.view attached property with VisualItemModel We assumed that the attached object was created at the same time as the item. Task-number: QTBUG-13166 Reviewed-by: Aaron Kennedy --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativegridview_p.h | 12 ++++++++++-- src/declarative/graphicsitems/qdeclarativelistview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativelistview_p.h | 12 ++++++++++-- .../auto/declarative/qdeclarativelistview/data/itemlist.qml | 6 +++--- .../qdeclarativelistview/tst_qdeclarativelistview.cpp | 1 + 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index d67e69a..37beab5 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -64,7 +64,7 @@ public: FxGridItem(QDeclarativeItem *i, QDeclarativeGridView *v) : item(i), view(v) { attached = static_cast(qmlAttachedPropertiesObject(item)); if (attached) - attached->m_view = view; + attached->setView(view); } ~FxGridItem() {} diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h index d6bbaf3..fdb6f94 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview_p.h +++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h @@ -43,6 +43,7 @@ #define QDECLARATIVEGRIDVIEW_H #include "private/qdeclarativeflickable_p.h" +#include "private/qdeclarativeguard_p.h" QT_BEGIN_HEADER @@ -220,8 +221,14 @@ public: : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} ~QDeclarativeGridViewAttached() {} - Q_PROPERTY(QDeclarativeGridView *view READ view CONSTANT) + Q_PROPERTY(QDeclarativeGridView *view READ view WRITE setView NOTIFY viewChanged) QDeclarativeGridView *view() { return m_view; } + void setView(QDeclarativeGridView *view) { + if (view != m_view) { + m_view = view; + emit viewChanged(); + } + } Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) bool isCurrentItem() const { return m_isCurrent; } @@ -249,9 +256,10 @@ Q_SIGNALS: void delayRemoveChanged(); void add(); void remove(); + void viewChanged(); public: - QDeclarativeGridView *m_view; + QDeclarativeGuard m_view; bool m_isCurrent : 1; bool m_delayRemove : 1; }; diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 2e2e08c..f80c73a 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -96,7 +96,7 @@ public: FxListItem(QDeclarativeItem *i, QDeclarativeListView *v) : item(i), section(0), view(v) { attached = static_cast(qmlAttachedPropertiesObject(item)); if (attached) - attached->m_view = view; + attached->setView(view); } ~FxListItem() {} qreal position() const { diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h index b264861..14925d7 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h @@ -43,6 +43,7 @@ #define QDECLARATIVELISTVIEW_H #include "private/qdeclarativeflickable_p.h" +#include "private/qdeclarativeguard_p.h" QT_BEGIN_HEADER @@ -268,8 +269,14 @@ public: : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} ~QDeclarativeListViewAttached() {} - Q_PROPERTY(QDeclarativeListView *view READ view CONSTANT) + Q_PROPERTY(QDeclarativeListView *view READ view WRITE setView NOTIFY viewChanged) QDeclarativeListView *view() { return m_view; } + void setView(QDeclarativeListView *view) { + if (view != m_view) { + m_view = view; + emit viewChanged(); + } + } Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) bool isCurrentItem() const { return m_isCurrent; } @@ -327,9 +334,10 @@ Q_SIGNALS: void delayRemoveChanged(); void add(); void remove(); + void viewChanged(); public: - QDeclarativeListView *m_view; + QDeclarativeGuard m_view; mutable QString m_section; QString m_prevSection; QString m_nextSection; diff --git a/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml b/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml index 66728d6..9ea5953 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml @@ -13,17 +13,17 @@ Rectangle { objectName: "itemModel" Rectangle { objectName: "item1" - height: view.height; width: view.width; color: "#FFFEF0" + height: ListView.view.height; width: view.width; color: "#FFFEF0" Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } } Rectangle { objectName: "item2" - height: view.height; width: view.width; color: "#F0FFF7" + height: ListView.view.height; width: view.width; color: "#F0FFF7" Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } } Rectangle { objectName: "item3" - height: view.height; width: view.width; color: "#F4F0FF" + height: ListView.view.height; width: view.width; color: "#F4F0FF" Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } } } diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 9c24e03..491ac0f 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1066,6 +1066,7 @@ void tst_QDeclarativeListView::itemList() QDeclarativeItem *item = findItem(contentItem, "item1"); QTRY_VERIFY(item); QTRY_COMPARE(item->x(), 0.0); + QCOMPARE(item->height(), listview->height()); QDeclarativeText *text = findItem(contentItem, "text1"); QTRY_VERIFY(text); -- cgit v0.12 From d630c627ed1dfbcfb48f907d2d37048b049830a5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 13:51:38 +1000 Subject: Avoid Flickable view jumping when drag threashold is exceeded. Task-number: QTBUG-13176 --- src/declarative/graphicsitems/qdeclarativeflickable.cpp | 10 ++++++++-- src/declarative/graphicsitems/qdeclarativeflickable_p_p.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index a6e8c85..a710190 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -653,6 +653,8 @@ void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEven timeline.clear(); hData.velocity = 0; vData.velocity = 0; + hData.dragStartOffset = 0; + vData.dragStartOffset = 0; lastPos = QPoint(); QDeclarativeItemPrivate::start(lastPosTime); pressPos = event->pos(); @@ -675,7 +677,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (q->yflick()) { int dy = int(event->pos().y() - pressPos.y()); if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - qreal newY = dy + vData.pressPos; + if (!vMoved) + vData.dragStartOffset = dy; + qreal newY = dy + vData.pressPos - vData.dragStartOffset; const qreal minY = q->minYExtent(); const qreal maxY = q->maxYExtent(); if (newY > minY) @@ -705,7 +709,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (q->xflick()) { int dx = int(event->pos().x() - pressPos.x()); if (qAbs(dx) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - qreal newX = dx + hData.pressPos; + if (!hMoved) + hData.dragStartOffset = dx; + qreal newX = dx + hData.pressPos - hData.dragStartOffset; const qreal minX = q->minXExtent(); const qreal maxX = q->maxXExtent(); if (newX > minX) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index b919e1b..c398faa 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -96,6 +96,7 @@ public: QDeclarativeTimeLineValueProxy move; qreal viewSize; qreal pressPos; + qreal dragStartOffset; qreal velocity; qreal flickTarget; QDeclarativeFlickablePrivate::Velocity smoothVelocity; -- cgit v0.12 From 58a76965e20c4c66ab2dc9cf73aa72b1cfddfbeb Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 14:11:58 +1000 Subject: ListView.view and GridView.view properties should not be writable. Task-number: QTBUG-13166 --- src/declarative/graphicsitems/qdeclarativegridview_p.h | 2 +- src/declarative/graphicsitems/qdeclarativelistview_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h index fdb6f94..ee632b1 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview_p.h +++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h @@ -221,7 +221,7 @@ public: : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} ~QDeclarativeGridViewAttached() {} - Q_PROPERTY(QDeclarativeGridView *view READ view WRITE setView NOTIFY viewChanged) + Q_PROPERTY(QDeclarativeGridView *view READ view NOTIFY viewChanged) QDeclarativeGridView *view() { return m_view; } void setView(QDeclarativeGridView *view) { if (view != m_view) { diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h index 14925d7..8fbff49 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h @@ -269,7 +269,7 @@ public: : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} ~QDeclarativeListViewAttached() {} - Q_PROPERTY(QDeclarativeListView *view READ view WRITE setView NOTIFY viewChanged) + Q_PROPERTY(QDeclarativeListView *view READ view NOTIFY viewChanged) QDeclarativeListView *view() { return m_view; } void setView(QDeclarativeListView *view) { if (view != m_view) { -- cgit v0.12 From 2af41f34eca0effced19b59d4c3327e3e4b627cb Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 26 Aug 2010 13:31:27 +1000 Subject: Add quit buttons to declarative demos Task-number: QTBUG-13048 Reviewed-by: Martin Jones --- demos/declarative/calculator/Core/calculator.js | 10 +++---- demos/declarative/calculator/calculator.qml | 16 +++++------ .../minehunt/MinehuntCore/pics/quit.png | Bin 0 -> 583 bytes demos/declarative/minehunt/main.cpp | 1 + demos/declarative/minehunt/minehunt.qml | 12 +++++++++ demos/declarative/photoviewer/photoviewer.qml | 5 ++++ demos/declarative/rssnews/rssnews.qml | 20 +++++++++++++- demos/declarative/snake/snake.qml | 6 +++++ demos/declarative/twitter/TwitterCore/TitleBar.qml | 12 ++++++++- .../twitter/TwitterCore/images/quit.png | Bin 0 -> 2369 bytes demos/declarative/webbrowser/content/Header.qml | 30 ++++++++++++++++++--- 11 files changed, 92 insertions(+), 20 deletions(-) create mode 100644 demos/declarative/minehunt/MinehuntCore/pics/quit.png create mode 100644 demos/declarative/twitter/TwitterCore/images/quit.png diff --git a/demos/declarative/calculator/Core/calculator.js b/demos/declarative/calculator/Core/calculator.js index 16cc309..7c363c7 100644 --- a/demos/declarative/calculator/Core/calculator.js +++ b/demos/declarative/calculator/Core/calculator.js @@ -74,6 +74,11 @@ function doOperation(op) { memory = display.text.valueOf() } else if (op == leftArrow) { display.text = display.text.toString().slice(0, -1) + if (display.text.length == 0) { + display.text = "0" + } + } else if (op == "Off") { + Qt.quit(); } else if (op == "C") { display.text = "0" } else if (op == "AC") { @@ -82,10 +87,5 @@ function doOperation(op) { lastOp = "" display.text ="0" } - - if (op == rotateRight) - main.state = "orientation " + Orientation.Landscape - if (op == rotateLeft) - main.state = '' } diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 288455b..68c922b 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -58,7 +58,7 @@ Rectangle { property string plusminus : "\u00b1" function doOp(operation) { CalcEngine.doOperation(operation) } - + Item { id: main state: "orientation " + runtime.orientation @@ -70,8 +70,10 @@ Rectangle { anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } - Row { - Display { id: display; width: box.width; height: 64 } + Display { + id: display + width: box.width-3 + height: 64 } Column { @@ -82,11 +84,7 @@ Rectangle { Row { spacing: 6 - - Button { - id: rotateButton - width: column.w; height: column.h; color: 'purple'; operation: rotateRight - } + Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" } Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } @@ -103,7 +101,7 @@ Rectangle { } Grid { - id: grid; rows: 4; columns: 5; spacing: 6 + id: grid; rows: 5; columns: 5; spacing: 6 property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) diff --git a/demos/declarative/minehunt/MinehuntCore/pics/quit.png b/demos/declarative/minehunt/MinehuntCore/pics/quit.png new file mode 100644 index 0000000..b822057 Binary files /dev/null and b/demos/declarative/minehunt/MinehuntCore/pics/quit.png differ diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index fc223dd..8bbaee9 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -59,6 +59,7 @@ int main(int argc, char *argv[]) #endif canvas.engine()->rootContext()->setContextObject(game); canvas.setSource(QString("minehunt.qml")); + QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit())); #ifdef Q_OS_SYMBIAN canvas.showFullScreen(); diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index 136f56a..a7daa90 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -67,6 +67,18 @@ Item { x: 20; spacing: 20 anchors.bottom: field.bottom; anchors.bottomMargin: 15 + Image { + source: "MinehuntCore/pics/quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + y: 10 + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -20 + onClicked: Qt.quit() + } + } Column { spacing: 2 Image { source: "MinehuntCore/pics/bomb-color.png" } diff --git a/demos/declarative/photoviewer/photoviewer.qml b/demos/declarative/photoviewer/photoviewer.qml index 4ed3105..3072ea2 100644 --- a/demos/declarative/photoviewer/photoviewer.qml +++ b/demos/declarative/photoviewer/photoviewer.qml @@ -81,6 +81,11 @@ Rectangle { onClicked: mainWindow.editMode = !mainWindow.editMode anchors.horizontalCenter: parent.horizontalCenter } + Button { + id: quitButton; label: qsTr("Quit"); rotation: -2; + onClicked: Qt.quit() + anchors.horizontalCenter: parent.horizontalCenter + } } Rectangle { diff --git a/demos/declarative/rssnews/rssnews.qml b/demos/declarative/rssnews/rssnews.qml index def3e2c..fb5b5a3 100644 --- a/demos/declarative/rssnews/rssnews.qml +++ b/demos/declarative/rssnews/rssnews.qml @@ -71,6 +71,7 @@ Rectangle { id: categories anchors.fill: parent model: rssFeeds + footer: quitButtonDelegate delegate: CategoryDelegate {} highlight: Rectangle { color: "steelblue" } highlightMoveSpeed: 9999999 @@ -87,7 +88,24 @@ Rectangle { delegate: NewsDelegate {} } } - + Component { + id: quitButtonDelegate + Item { + width: categories.width; height: 60 + Text { + text: "Quit" + font { family: "Helvetica"; pixelSize: 16; bold: true } + anchors { + left: parent.left; leftMargin: 15 + verticalCenter: parent.verticalCenter + } + } + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + } ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right } Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" } } diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml index ed3bac9..12ad71c 100644 --- a/demos/declarative/snake/snake.qml +++ b/demos/declarative/snake/snake.qml @@ -194,6 +194,12 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter } + Content.Button { + text: "Quit" + anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter } + onClicked: Qt.quit(); + } + Text { color: activePalette.text text: "Score: " + score; font.bold: true diff --git a/demos/declarative/twitter/TwitterCore/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml index 558bc18..479aa20 100644 --- a/demos/declarative/twitter/TwitterCore/TitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml @@ -58,10 +58,20 @@ Item { rssModel.tags = editor.text } + Image { + id: quitButton + x: 5 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } Text { id: categoryText anchors { - left: parent.left; right: tagButton.left; leftMargin: 10; rightMargin: 10 + left: quitButton.right; right: tagButton.left; leftMargin: 5; rightMargin: 10 verticalCenter: parent.verticalCenter } elide: Text.ElideLeft diff --git a/demos/declarative/twitter/TwitterCore/images/quit.png b/demos/declarative/twitter/TwitterCore/images/quit.png new file mode 100644 index 0000000..5bda1b6 Binary files /dev/null and b/demos/declarative/twitter/TwitterCore/images/quit.png differ diff --git a/demos/declarative/webbrowser/content/Header.qml b/demos/declarative/webbrowser/content/Header.qml index 5abf440..d3ccae3 100644 --- a/demos/declarative/webbrowser/content/Header.qml +++ b/demos/declarative/webbrowser/content/Header.qml @@ -51,7 +51,6 @@ Image { x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width ? -webView.contentX+webView.contentWidth-webView.width : 0 - y: { if (webView.progress < 1.0) return 0; @@ -59,7 +58,6 @@ Image { webView.contentY < 0 ? -webView.contentY : webView.contentY > height ? -height : -webView.contentY } } - Column { width: parent.width @@ -101,14 +99,38 @@ Image { Button { id: reloadButton - anchors { right: parent.right; rightMargin: 4 } + anchors { right: quitButton.left; rightMargin: 10 } action: webView.reload; image: "pics/view-refresh.png" visible: webView.progress == 1.0 && !header.urlChanged } + Text { + id: quitButton + color: "white" + style: Text.Sunken + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 18 + width: 60 + text: "Quit" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + Rectangle { + width: 1 + y: 5 + height: parent.height-10 + anchors.right: parent.left + color: "darkgray" + } + } Button { id: stopButton - anchors { right: parent.right; rightMargin: 4 } + anchors { right: quitButton.left; rightMargin: 10 } action: webView.stop; image: "pics/edit-delete.png" visible: webView.progress < 1.0 && !header.urlChanged } -- cgit v0.12 From f936a199e44a8d443240368f748f7be87cffc186 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 26 Aug 2010 15:43:53 +1000 Subject: Make declarative examples a bit more qt-like. --- .../minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg | Bin 30730 -> 0 bytes .../minehunt/MinehuntCore/pics/background.png | Bin 0 -> 313930 bytes demos/declarative/minehunt/minehunt.qml | 2 +- .../webbrowser/content/pics/edit-delete.png | Bin 1333 -> 831 bytes .../webbrowser/content/pics/go-jump-locationbar.png | Bin 714 -> 408 bytes .../webbrowser/content/pics/go-next-view.png | Bin 1187 -> 1310 bytes .../webbrowser/content/pics/go-previous-view.png | Bin 1226 -> 1080 bytes examples/declarative/animation/states/qt-logo.png | Bin 0 -> 5149 bytes examples/declarative/animation/states/states.qml | 8 ++++---- examples/declarative/animation/states/transitions.qml | 8 ++++---- examples/declarative/animation/states/user.png | Bin 4886 -> 0 bytes .../declarative/imageelements/image/ImageCell.qml | 2 +- .../declarative/imageelements/image/face-smile.png | Bin 15408 -> 0 bytes examples/declarative/imageelements/image/qt-logo.png | Bin 0 -> 5149 bytes .../modelviews/listview/content/pics/arrow-down.png | Bin 892 -> 0 bytes .../modelviews/listview/content/pics/arrow-up.png | Bin 929 -> 0 bytes .../modelviews/listview/content/pics/list-delete.png | Bin 1074 -> 0 bytes examples/declarative/positioners/add.png | Bin 1577 -> 810 bytes examples/declarative/positioners/del.png | Bin 1661 -> 488 bytes 19 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 demos/declarative/minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg create mode 100644 demos/declarative/minehunt/MinehuntCore/pics/background.png create mode 100644 examples/declarative/animation/states/qt-logo.png delete mode 100644 examples/declarative/animation/states/user.png delete mode 100644 examples/declarative/imageelements/image/face-smile.png create mode 100644 examples/declarative/imageelements/image/qt-logo.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/arrow-down.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/arrow-up.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/list-delete.png diff --git a/demos/declarative/minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg b/demos/declarative/minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg deleted file mode 100644 index 445567f..0000000 Binary files a/demos/declarative/minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg and /dev/null differ diff --git a/demos/declarative/minehunt/MinehuntCore/pics/background.png b/demos/declarative/minehunt/MinehuntCore/pics/background.png new file mode 100644 index 0000000..3734a27 Binary files /dev/null and b/demos/declarative/minehunt/MinehuntCore/pics/background.png differ diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index 136f56a..bc1bf4b 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -49,7 +49,7 @@ Item { width: 450; height: 450 - Image { source: "MinehuntCore/pics/No-Ones-Laughing-3.jpg"; anchors.fill: parent; fillMode: Image.Tile } + Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile } Grid { anchors.horizontalCenter: parent.horizontalCenter diff --git a/demos/declarative/webbrowser/content/pics/edit-delete.png b/demos/declarative/webbrowser/content/pics/edit-delete.png index 351659b..df2a147 100644 Binary files a/demos/declarative/webbrowser/content/pics/edit-delete.png and b/demos/declarative/webbrowser/content/pics/edit-delete.png differ diff --git a/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png b/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png index 636fe38..61f779c 100644 Binary files a/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png and b/demos/declarative/webbrowser/content/pics/go-jump-locationbar.png differ diff --git a/demos/declarative/webbrowser/content/pics/go-next-view.png b/demos/declarative/webbrowser/content/pics/go-next-view.png index 3bce02d..a585cab 100644 Binary files a/demos/declarative/webbrowser/content/pics/go-next-view.png and b/demos/declarative/webbrowser/content/pics/go-next-view.png differ diff --git a/demos/declarative/webbrowser/content/pics/go-previous-view.png b/demos/declarative/webbrowser/content/pics/go-previous-view.png index 3ec011e..612fb34 100644 Binary files a/demos/declarative/webbrowser/content/pics/go-previous-view.png and b/demos/declarative/webbrowser/content/pics/go-previous-view.png differ diff --git a/examples/declarative/animation/states/qt-logo.png b/examples/declarative/animation/states/qt-logo.png new file mode 100644 index 0000000..14ddf2a Binary files /dev/null and b/examples/declarative/animation/states/qt-logo.png differ diff --git a/examples/declarative/animation/states/states.qml b/examples/declarative/animation/states/states.qml index 77101d0..34cdae3 100644 --- a/examples/declarative/animation/states/states.qml +++ b/examples/declarative/animation/states/states.qml @@ -48,14 +48,14 @@ Rectangle { Image { id: userIcon x: topLeftRect.x; y: topLeftRect.y - source: "user.png" + source: "qt-logo.png" } Rectangle { id: topLeftRect anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 64; height: 64 + width: 46; height: 54 color: "Transparent"; border.color: "Gray"; radius: 6 // Clicking in here sets the state to the default state, returning the image to @@ -67,7 +67,7 @@ Rectangle { id: middleRightRect anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 64; height: 64 + width: 46; height: 54 color: "Transparent"; border.color: "Gray"; radius: 6 // Clicking in here sets the state to 'middleRight' @@ -78,7 +78,7 @@ Rectangle { id: bottomLeftRect anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 64; height: 64 + width: 46; height: 54 color: "Transparent"; border.color: "Gray"; radius: 6 // Clicking in here sets the state to 'bottomLeft' diff --git a/examples/declarative/animation/states/transitions.qml b/examples/declarative/animation/states/transitions.qml index 1df60ae..884779c 100644 --- a/examples/declarative/animation/states/transitions.qml +++ b/examples/declarative/animation/states/transitions.qml @@ -54,14 +54,14 @@ Rectangle { Image { id: userIcon x: topLeftRect.x; y: topLeftRect.y - source: "user.png" + source: "qt-logo.png" } Rectangle { id: topLeftRect anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 64; height: 64 + width: 46; height: 54 color: "Transparent"; border.color: "Gray"; radius: 6 // Clicking in here sets the state to the default state, returning the image to @@ -73,7 +73,7 @@ Rectangle { id: middleRightRect anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 64; height: 64 + width: 46; height: 54 color: "Transparent"; border.color: "Gray"; radius: 6 // Clicking in here sets the state to 'middleRight' @@ -84,7 +84,7 @@ Rectangle { id: bottomLeftRect anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 64; height: 64 + width: 46; height: 54 color: "Transparent"; border.color: "Gray"; radius: 6 // Clicking in here sets the state to 'bottomLeft' diff --git a/examples/declarative/animation/states/user.png b/examples/declarative/animation/states/user.png deleted file mode 100644 index dd7d7a2..0000000 Binary files a/examples/declarative/animation/states/user.png and /dev/null differ diff --git a/examples/declarative/imageelements/image/ImageCell.qml b/examples/declarative/imageelements/image/ImageCell.qml index bd232b9..71a17fe 100644 --- a/examples/declarative/imageelements/image/ImageCell.qml +++ b/examples/declarative/imageelements/image/ImageCell.qml @@ -48,7 +48,7 @@ Item { Image { id: image width: parent.width; height: parent.height - captionItem.height - source: "face-smile.png" + source: "qt-logo.png" clip: true // only makes a difference if mode is PreserveAspectCrop smooth: true } diff --git a/examples/declarative/imageelements/image/face-smile.png b/examples/declarative/imageelements/image/face-smile.png deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/imageelements/image/face-smile.png and /dev/null differ diff --git a/examples/declarative/imageelements/image/qt-logo.png b/examples/declarative/imageelements/image/qt-logo.png new file mode 100644 index 0000000..14ddf2a Binary files /dev/null and b/examples/declarative/imageelements/image/qt-logo.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/arrow-down.png b/examples/declarative/modelviews/listview/content/pics/arrow-down.png deleted file mode 100644 index 63331a5..0000000 Binary files a/examples/declarative/modelviews/listview/content/pics/arrow-down.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/arrow-up.png b/examples/declarative/modelviews/listview/content/pics/arrow-up.png deleted file mode 100644 index 4459024..0000000 Binary files a/examples/declarative/modelviews/listview/content/pics/arrow-up.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/list-delete.png b/examples/declarative/modelviews/listview/content/pics/list-delete.png deleted file mode 100644 index 9640f6b..0000000 Binary files a/examples/declarative/modelviews/listview/content/pics/list-delete.png and /dev/null differ diff --git a/examples/declarative/positioners/add.png b/examples/declarative/positioners/add.png index f29d84b..1ee4542 100644 Binary files a/examples/declarative/positioners/add.png and b/examples/declarative/positioners/add.png differ diff --git a/examples/declarative/positioners/del.png b/examples/declarative/positioners/del.png index 1d753a3..8d2eaed 100644 Binary files a/examples/declarative/positioners/del.png and b/examples/declarative/positioners/del.png differ -- cgit v0.12 From dac9c7f42765a46d445aae35fd0e85b402ceb164 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 16:00:37 +1000 Subject: Fix off-by-one at end when views scroll to keep currentItem visible. endPosition() is the last pixel of the item, i.e. width-1, so must add one to ensure the entire item is visible. Task-number: QTBUG-12822 --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 12 ++++++------ src/declarative/graphicsitems/qdeclarativelistview.cpp | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 37beab5..a0faf14 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -2212,7 +2212,7 @@ void QDeclarativeGridView::trackedPositionChanged() if (trackedPos < d->startPosition() + d->highlightRangeStart) { pos = d->startPosition(); } else if (d->trackedItem->endRowPos() > d->endPosition() - d->size() + d->highlightRangeEnd) { - pos = d->endPosition() - d->size(); + pos = d->endPosition() - d->size() + 1; if (pos < d->startPosition()) pos = d->startPosition(); } else { @@ -2226,14 +2226,14 @@ void QDeclarativeGridView::trackedPositionChanged() } else { if (trackedPos < viewPos && d->currentItem->rowPos() < viewPos) { pos = d->currentItem->rowPos() < trackedPos ? trackedPos : d->currentItem->rowPos(); - } else if (d->trackedItem->endRowPos() > viewPos + d->size() - && d->currentItem->endRowPos() > viewPos + d->size()) { - if (d->trackedItem->endRowPos() < d->currentItem->endRowPos()) { - pos = d->trackedItem->endRowPos() - d->size(); + } else if (d->trackedItem->endRowPos() >= viewPos + d->size() + && d->currentItem->endRowPos() >= viewPos + d->size()) { + if (d->trackedItem->endRowPos() <= d->currentItem->endRowPos()) { + pos = d->trackedItem->endRowPos() - d->size() + 1; if (d->rowSize() > d->size()) pos = trackedPos; } else { - pos = d->currentItem->endRowPos() - d->size(); + pos = d->currentItem->endRowPos() - d->size() + 1; if (d->rowSize() > d->size()) pos = d->currentItem->rowPos(); } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index f80c73a..d3d46f7 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2652,7 +2652,7 @@ void QDeclarativeListView::trackedPositionChanged() if (trackedPos < d->startPosition() + d->highlightRangeStart) { pos = d->startPosition(); } else if (d->trackedItem->endPosition() > d->endPosition() - d->size() + d->highlightRangeEnd) { - pos = d->endPosition() - d->size(); + pos = d->endPosition() - d->size() + 1; if (pos < d->startPosition()) pos = d->startPosition(); } else { @@ -2666,14 +2666,14 @@ void QDeclarativeListView::trackedPositionChanged() } else { if (trackedPos < viewPos && d->currentItem->position() < viewPos) { pos = d->currentItem->position() < trackedPos ? trackedPos : d->currentItem->position(); - } else if (d->trackedItem->endPosition() > viewPos + d->size() - && d->currentItem->endPosition() > viewPos + d->size()) { - if (d->trackedItem->endPosition() < d->currentItem->endPosition()) { - pos = d->trackedItem->endPosition() - d->size(); - if (d->trackedItem->size() > d->size()) + } else if (d->trackedItem->endPosition() >= viewPos + d->size() + && d->currentItem->endPosition() >= viewPos + d->size()) { + if (d->trackedItem->endPosition() <= d->currentItem->endPosition()) { + pos = d->trackedItem->endPosition() - d->size() + 1; + if (d->trackedItem->size() > d->size()) pos = trackedPos; } else { - pos = d->currentItem->endPosition() - d->size(); + pos = d->currentItem->endPosition() - d->size() + 1; if (d->currentItem->size() > d->size()) pos = d->currentItem->position(); } -- cgit v0.12 From 55991e39819007b5c6d0662808d522cf32c383a4 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 16:41:46 +1000 Subject: Revert 4bc81bb1cb3cd4a0a3fe071e00556124e770d7ac QAbstractItemModel calls that for all sorts of reasons. Task-number: QTBUG-13146 --- src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index c6b8514..65b14cf 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -714,7 +714,6 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_modelReset())); d->m_abstractItemModel = 0; } else if (d->m_visualItemModel) { QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)), @@ -762,7 +761,6 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); - QObject::connect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_modelReset())); d->m_metaDataCacheable = true; return; } -- cgit v0.12 From 48d057b8f4ae70d9ea43d4a234ff63956a70c3b6 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 16:47:22 +1000 Subject: Fix ListView and GridView tests following off-by-one fixes. Our tests were verifying incorrect positions... Task-number: QTBUG-12822 --- .../declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp | 4 ++-- .../declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 1a28b71..896d69e 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -590,7 +590,7 @@ void tst_QDeclarativeGridView::currentIndex() QCOMPARE(gridview->currentIndex(), 35); QCOMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 35)); QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y()); - QCOMPARE(gridview->contentY(), 399.0); + QCOMPARE(gridview->contentY(), 400.0); gridview->moveCurrentIndexRight(); QCOMPARE(gridview->currentIndex(), 36); @@ -629,7 +629,7 @@ void tst_QDeclarativeGridView::currentIndex() gridview->moveCurrentIndexLeft(); QCOMPARE(gridview->currentIndex(), model.count()-1); - QTRY_COMPARE(gridview->contentY(), 879.0); + QTRY_COMPARE(gridview->contentY(), 880.0); gridview->moveCurrentIndexRight(); QCOMPARE(gridview->currentIndex(), 0); diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 491ac0f..e7c61db 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -979,7 +979,7 @@ void tst_QDeclarativeListView::currentIndex() // current item should be 20th item at startup // and current item should be in view QCOMPARE(listview->currentIndex(), 20); - QCOMPARE(listview->contentY(), 99.0); + QCOMPARE(listview->contentY(), 100.0); QCOMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 20)); QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); -- cgit v0.12 From ff10e44642d65b2dde50579c4994aa9def43f4c0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 26 Aug 2010 17:18:21 +1000 Subject: Handle layoutChanged() properly in QML views. Update all visible items when layoutChanged() is emitted. Task-number: QTBUG-13146 --- src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 8 ++++++++ src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h | 1 + .../declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 65b14cf..b4e8bda 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -714,6 +714,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); + QObject::disconnect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); d->m_abstractItemModel = 0; } else if (d->m_visualItemModel) { QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)), @@ -761,6 +762,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)), this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int))); QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); + QObject::connect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); d->m_metaDataCacheable = true; return; } @@ -1332,6 +1334,12 @@ void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles); } +void QDeclarativeVisualDataModel::_q_layoutChanged() +{ + Q_D(QDeclarativeVisualDataModel); + _q_itemsChanged(0, count(), d->m_roles); +} + void QDeclarativeVisualDataModel::_q_modelReset() { emit modelReset(); diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h index 50d2c53..e159786 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h @@ -194,6 +194,7 @@ private Q_SLOTS: void _q_rowsRemoved(const QModelIndex &,int,int); void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int); void _q_dataChanged(const QModelIndex&,const QModelIndex&); + void _q_layoutChanged(); void _q_modelReset(); void _q_createdPackage(int index, QDeclarativePackage *package); void _q_destroyingPackage(QDeclarativePackage *package); diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index e7c61db..bf4754d 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1002,7 +1002,7 @@ void tst_QDeclarativeListView::currentIndex() listview->decrementCurrentIndex(); QCOMPARE(listview->currentIndex(), model.count()-1); - QTRY_COMPARE(listview->contentY(), 279.0); + QTRY_COMPARE(listview->contentY(), 280.0); listview->incrementCurrentIndex(); QCOMPARE(listview->currentIndex(), 0); -- cgit v0.12 From f2245941f0d1bc8244aa0d88437f0a42c9bba1fc Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 27 Aug 2010 12:12:03 +1000 Subject: Update example screenshot in doc. --- doc/src/images/qml-image-example.png | Bin 58184 -> 49584 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/src/images/qml-image-example.png b/doc/src/images/qml-image-example.png index c1951c0..8d9846f 100644 Binary files a/doc/src/images/qml-image-example.png and b/doc/src/images/qml-image-example.png differ -- cgit v0.12