From 299f9546f24b5ea288588ed4161a8e516e9391b1 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 8 May 2009 13:41:19 +1000 Subject: Fix flickr2 --- demos/declarative/flickr/content/ImageDetails.qml | 1 - demos/declarative/flickr/flickr2.qml | 83 ++++++++++------------- 2 files changed, 35 insertions(+), 49 deletions(-) diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 8677efc..5c2d885 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -74,7 +74,6 @@ Flipable { Rect { anchors.fill: parent; color: "black"; opacity: 0.4; pen.color: "white"; pen.width: 2 } -// Loading { anchors.centeredIn: parent; visible: BigImage.status } Progress { anchors.centeredIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status } Flickable { id: Flick; width: Container.width - 10; height: Container.height - 10 diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index f5f569e..d1fc0cd 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -30,7 +30,7 @@ Item { delegate: Package { Item { id: Wrapper; width: 85; height: 85; scale: {1.0} - z: RightBox.PathView.z + z: PathViewPackage.PathView.z property real angle: 0 * 0 transform: [ @@ -41,24 +41,23 @@ Item { ] Connection { - sender: ImageDetails; signal: "closed()" + sender: Background.imageDetails; signal: "closed()" script: { if (Wrapper.state == 'Details') Wrapper.state = '' } } Script { function photoClicked() { - ImageDetails.photoTitle = title; - ImageDetails.flickableArea.yPosition = 0; - ImageDetails.fullScreenArea.source = ""; - ImageDetails.photoDescription = description; - ImageDetails.photoTags = tags; - ImageDetails.photoWidth = photoWidth; - ImageDetails.photoHeight = photoHeight; - ImageDetails.photoType = photoType; - ImageDetails.photoAuthor = photoAuthor; - ImageDetails.photoDate = photoDate; - ImageDetails.photoUrl = url; - ImageDetails.rating = 0; + Background.imageDetails.photoTitle = title; + Background.imageDetails.flickableArea.yPosition = 0; + Background.imageDetails.photoDescription = description; + Background.imageDetails.photoTags = tags; + Background.imageDetails.photoWidth = photoWidth; + Background.imageDetails.photoHeight = photoHeight; + Background.imageDetails.photoType = photoType; + Background.imageDetails.photoAuthor = photoAuthor; + Background.imageDetails.photoDate = photoDate; + Background.imageDetails.photoUrl = url; + Background.imageDetails.rating = 0; Wrapper.state = "Details"; } } @@ -82,12 +81,12 @@ Item { states: [ State { name: "Details" - SetProperties { target: ImageDetails; z: 2 } - ParentChange { target: Wrapper; parent: ImageDetails.frontContainer } + SetProperties { target: Background.imageDetails; z: 2 } + ParentChange { target: Wrapper; parent: Background.imageDetails.frontContainer } SetProperties { target: Wrapper; x: 45; y: 35; scale: 1; z: 1000 } SetProperties { target: Rotation; angle: 0 } SetProperties { target: Shadows; opacity: 0 } - SetProperties { target: ImageDetails; y: 20 } + SetProperties { target: Background.imageDetails; y: 20 } SetProperties { target: PhotoGridView; y: "-480" } SetProperties { target: PhotoPathView; y: "-480" } SetProperties { target: CloseButton; opacity: 0 } @@ -114,35 +113,35 @@ Item { } Item { - Package.name: "rightBox" - id: RightBox; width: 85; height: 85 + Package.name: "pathView" + id: PathViewPackage; width: 85; height: 85 } Item { - Package.name: "leftBox" - id: LeftBox; width: 85; height: 85 + Package.name: "gridView" + id: GridViewPackage; width: 85; height: 85 } Item { id: MyItem - state: MainWindow.showPathView ? "right" : "left" + state: MainWindow.showPathView ? "pathView" : "gridView" states: [ State { - name: "left" - SetProperty { target: Wrapper; property: "moveToParent"; value: LeftBox } + name: "gridView" + SetProperty { target: Wrapper; property: "moveToParent"; value: GridViewPackage } }, State { - name: "right" - SetProperty { target: Wrapper; property: "scale"; value: RightBox.PathView.scale } - SetProperty { target: Wrapper; property: "scale"; binding: "RightBox.PathView.scale" } - SetProperty { target: Wrapper; property: "angle"; value: RightBox.PathView.angle } - SetProperty { target: Wrapper; property: "angle"; binding: "RightBox.PathView.angle" } - SetProperty { target: Wrapper; property: "moveToParent"; value: RightBox } + name: "pathView" + SetProperty { target: Wrapper; property: "scale"; value: PathViewPackage.PathView.scale } + SetProperty { target: Wrapper; property: "scale"; binding: "PathViewPackage.PathView.scale" } + SetProperty { target: Wrapper; property: "angle"; value: PathViewPackage.PathView.angle } + SetProperty { target: Wrapper; property: "angle"; binding: "PathViewPackage.PathView.angle" } + SetProperty { target: Wrapper; property: "moveToParent"; value: PathViewPackage } } ] transitions: [ Transition { - toState: "right" + toState: "pathView" SequentialAnimation { SetPropertyAction { target: Wrapper; property: "moveToParent" } ParallelAnimation { @@ -158,7 +157,7 @@ Item { } }, Transition { - toState: "left" + toState: "gridView" SequentialAnimation { PauseAnimation { duration: Math.floor(index/7)*100 } SetPropertyAction { target: Wrapper; property: "moveToParent" } @@ -182,17 +181,18 @@ Item { Item { id: Background + property var imageDetails: ImageDetails Image { source: "content/pics/background.png"; opaque: true } GridView { - id: PhotoGridView; model: MyVisualModel.parts.leftBox + id: PhotoGridView; model: MyVisualModel.parts.gridView cellWidth: 105; cellHeight: 105; x:32; y: 80; width: 800; height: 330; z: 1 cacheBuffer: 100 } PathView { - id: PhotoPathView; model: MyVisualModel.parts.rightBox + id: PhotoPathView; model: MyVisualModel.parts.pathView y: 80; width: 800; height: 330; z: 1 pathItemCount: 10; snapPosition: 0.001 path: Path { @@ -225,7 +225,7 @@ Item { PathLine { x: 950; y: 40 } PathPercent { value: 1.0 } PathAttribute { name: "scale"; value: 0.9 } - PathAttribute { name: "angle"; value: -45 } + PathAttribute { name: "angle"; value: 45 } } } @@ -243,19 +243,6 @@ Item { anchors.top: CloseButton.top onClicked: { FeedModel.reload(); } } - - states: [ - State { - name: "PathView" - } - ] - - transitions: [ - Transition { - fromState: "*"; toState: "*" - NumericAnimation { properties: "y"; duration: 650; easing: "easeOutBounce(amplitude:0.1)" } - } - ] } Text { -- cgit v0.12 From 089bcd8a643dc206e23cac14c5fc03fc0acb02d8 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 8 May 2009 14:06:02 +1000 Subject: Add tags to flickr2 --- demos/declarative/flickr/flickr2.qml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index d1fc0cd..52f8675 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -10,7 +10,7 @@ Item { model: XmlListModel { id: FeedModel - property string tags : "" + property string tags : TagsEdit.text source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2" query: "doc($src)/rss/channel/item" namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" @@ -89,7 +89,8 @@ Item { SetProperties { target: Background.imageDetails; y: 20 } SetProperties { target: PhotoGridView; y: "-480" } SetProperties { target: PhotoPathView; y: "-480" } - SetProperties { target: CloseButton; opacity: 0 } + SetProperties { target: ViewModeButton; opacity: 0 } + SetProperties { target: TagsEdit; opacity: 0 } SetProperties { target: FetchButton; opacity: 0 } SetProperties { target: CategoryText; y: "-50" } } @@ -232,17 +233,25 @@ Item { ImageDetails { id: ImageDetails; width: 750; x: 25; y: 500; height: 410 } MediaButton { - id: CloseButton; x: 680; y: 410; text: "View Mode" + id: ViewModeButton; x: 680; y: 410; text: "View Mode" onClicked: { if (MainWindow.showPathView == true) MainWindow.showPathView = false; else MainWindow.showPathView = true } } MediaButton { id: FetchButton text: "Update" - anchors.right: CloseButton.left; anchors.rightMargin: 5 - anchors.top: CloseButton.top + anchors.right: ViewModeButton.left; anchors.rightMargin: 5 + anchors.top: ViewModeButton.top onClicked: { FeedModel.reload(); } } + + MediaLineEdit { + id: TagsEdit; + label: "Tags" + anchors.right: FetchButton.left; anchors.rightMargin: 5 + anchors.top: ViewModeButton.top + } + } Text { -- cgit v0.12 From 225b30555b34885c028fc7a5f79a805cf5167669 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 8 May 2009 14:27:10 +1000 Subject: Add expression watcher support --- src/declarative/debugger/debugger.pri | 6 +- src/declarative/debugger/qmldebugger.cpp | 33 ++++------ src/declarative/debugger/qmldebugger.h | 5 +- src/declarative/debugger/qmlobjecttree.cpp | 75 ++++++++++++++++++++++ src/declarative/debugger/qmlobjecttree_p.h | 86 +++++++++++++++++++++++++ src/declarative/debugger/qmlpropertyview.cpp | 16 +---- src/declarative/debugger/qmlwatches.cpp | 93 +++++++++++++++++++--------- src/declarative/debugger/qmlwatches_p.h | 8 +-- 8 files changed, 252 insertions(+), 70 deletions(-) create mode 100644 src/declarative/debugger/qmlobjecttree.cpp create mode 100644 src/declarative/debugger/qmlobjecttree_p.h diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri index bf693d9..4df7e51 100644 --- a/src/declarative/debugger/debugger.pri +++ b/src/declarative/debugger/debugger.pri @@ -1,9 +1,11 @@ SOURCES += debugger/qmldebugger.cpp \ debugger/qmldebuggerstatus.cpp \ debugger/qmlpropertyview.cpp \ - debugger/qmlwatches.cpp + debugger/qmlwatches.cpp \ + debugger/qmlobjecttree.cpp HEADERS += debugger/qmldebugger.h \ debugger/qmldebuggerstatus.h \ debugger/qmlpropertyview_p.h \ - debugger/qmlwatches_p.h + debugger/qmlwatches_p.h \ + debugger/qmlobjecttree_p.h diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp index 907b91b..76d6b10 100644 --- a/src/declarative/debugger/qmldebugger.cpp +++ b/src/declarative/debugger/qmldebugger.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,7 @@ #include #include #include +#include #include #include @@ -75,10 +77,11 @@ QmlDebugger::QmlDebugger(QWidget *parent) treeWid->setLayout(vlayout); splitter->addWidget(treeWid); - m_tree = new QTreeWidget(treeWid); + m_tree = new QmlObjectTree(treeWid); m_tree->setHeaderHidden(true); QObject::connect(m_tree, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(itemClicked(QTreeWidgetItem *))); QObject::connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem *))); + QObject::connect(m_tree, SIGNAL(addWatch(QObject*,QString)), this, SLOT(addWatch(QObject*,QString))); vlayout->addWidget(m_tree); QPushButton *pb = new QPushButton("Refresh", treeWid); @@ -113,29 +116,17 @@ QmlDebugger::QmlDebugger(QWidget *parent) setGeometry(0, 100, 800, 600); } -class QmlDebuggerItem : public QTreeWidgetItem +void QmlDebugger::itemDoubleClicked(QTreeWidgetItem *) { -public: - QmlDebuggerItem(QTreeWidget *wid) - : QTreeWidgetItem(wid), startLine(-1), endLine(-1) - { - } - - QmlDebuggerItem(QTreeWidgetItem *item) - : QTreeWidgetItem(item), startLine(-1), endLine(-1) - { - } - - int startLine; - int endLine; - QUrl url; - - QPointer object; - QPointer bindableValue; -}; +} -void QmlDebugger::itemDoubleClicked(QTreeWidgetItem *i) +void QmlDebugger::addWatch(QObject *obj, const QString &expr) { + QmlContext *ctxt = qmlContext(obj); + if(ctxt) { + QmlExpressionObject *e= new QmlExpressionObject(ctxt, expr, obj, m_watches); + m_watches->addWatch(e); + } } void QmlDebugger::highlightObject(quint32 id) diff --git a/src/declarative/debugger/qmldebugger.h b/src/declarative/debugger/qmldebugger.h index 6495a49..ddb846b 100644 --- a/src/declarative/debugger/qmldebugger.h +++ b/src/declarative/debugger/qmldebugger.h @@ -59,6 +59,8 @@ class QmlDebuggerItem; class QTableView; class QmlPropertyView; class QmlWatches; +class QmlObjectTree; +class QmlContext; class QmlDebugger : public QWidget { Q_OBJECT @@ -74,11 +76,12 @@ private slots: void itemClicked(QTreeWidgetItem *); void itemDoubleClicked(QTreeWidgetItem *); void highlightObject(quint32); + void addWatch(QObject *, const QString &); private: void buildTree(QObject *obj, QmlDebuggerItem *parent); bool makeItem(QObject *obj, QmlDebuggerItem *item); - QTreeWidget *m_tree; + QmlObjectTree *m_tree; QTreeWidget *m_warnings; QTableView *m_watchTable; QmlWatches *m_watches; diff --git a/src/declarative/debugger/qmlobjecttree.cpp b/src/declarative/debugger/qmlobjecttree.cpp new file mode 100644 index 0000000..fb6825a --- /dev/null +++ b/src/declarative/debugger/qmlobjecttree.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +QmlObjectTree::QmlObjectTree(QWidget *parent) +: QTreeWidget(parent) +{ +} + +void QmlObjectTree::mousePressEvent(QMouseEvent *me) +{ + QTreeWidget::mousePressEvent(me); + if(me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) { + QAction action("Add watch...", 0); + QList actions; + actions << &action; + QmlDebuggerItem *item = static_cast(currentItem()); + if(item && qmlContext(item->object) && + QMenu::exec(actions, me->globalPos())) { + + bool ok = false; + QString watch = QInputDialog::getText(this, "Watch expression", "Expression:", QLineEdit::Normal, QString(), &ok); + + if(ok && !watch.isEmpty()) + emit addWatch(item->object, watch); + } + } +} + diff --git a/src/declarative/debugger/qmlobjecttree_p.h b/src/declarative/debugger/qmlobjecttree_p.h new file mode 100644 index 0000000..4e6d484 --- /dev/null +++ b/src/declarative/debugger/qmlobjecttree_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLOBJECTTREE_P_H +#define QMLOBJECTTREE_P_H + +#include +#include +#include + +class QmlBindableValue; +class QmlDebuggerItem : public QTreeWidgetItem +{ +public: + QmlDebuggerItem(QTreeWidget *wid) + : QTreeWidgetItem(wid), startLine(-1), endLine(-1) + { + } + + QmlDebuggerItem(QTreeWidgetItem *item) + : QTreeWidgetItem(item), startLine(-1), endLine(-1) + { + } + + int startLine; + int endLine; + QUrl url; + + QPointer object; + QPointer bindableValue; +}; + +class QmlContext; +class QmlObjectTree : public QTreeWidget +{ + Q_OBJECT +public: + QmlObjectTree(QWidget *parent = 0); + +signals: + void addWatch(QObject *, const QString &); + +protected: + virtual void mousePressEvent(QMouseEvent *); +}; + +#endif // QMLOBJECTTREE_P_H + diff --git a/src/declarative/debugger/qmlpropertyview.cpp b/src/declarative/debugger/qmlpropertyview.cpp index eda97b7..e32393c 100644 --- a/src/declarative/debugger/qmlpropertyview.cpp +++ b/src/declarative/debugger/qmlpropertyview.cpp @@ -136,17 +136,8 @@ void QmlPropertyView::itemDoubleClicked(QTreeWidgetItem *i) m_watches->addWatch(objectId, item->property.name()); item->setForeground(0, Qt::red); } - } else if(item->exprId) { - - if(m_watches->hasWatch(item->exprId)) { - m_watches->remWatch(item->exprId); - item->setForeground(1, Qt::green); - } else { - m_watches->addWatch(item->exprId); - item->setForeground(1, Qt::darkGreen); - } - } + } void QmlPropertyView::setObject(QObject *object) @@ -206,10 +197,7 @@ void QmlPropertyView::setObject(QObject *object) QmlPropertyViewItem *binding = new QmlPropertyViewItem(item); binding->exprId = iter.value().second; binding->setText(1, iter.value().first); - if (m_watches->hasWatch(binding->exprId)) - binding->setForeground(1, Qt::darkGreen); - else - binding->setForeground(1, Qt::green); + binding->setForeground(1, Qt::green); ++iter; } diff --git a/src/declarative/debugger/qmlwatches.cpp b/src/declarative/debugger/qmlwatches.cpp index 1cc9469..bac4cbd 100644 --- a/src/declarative/debugger/qmlwatches.cpp +++ b/src/declarative/debugger/qmlwatches.cpp @@ -44,6 +44,7 @@ #include #include #include +#include QString QmlWatches::objectToString(QObject *obj) { @@ -69,6 +70,10 @@ public: int column, QmlWatches *parent = 0); + QmlWatchesProxy(QmlExpressionObject *object, + int column, + QmlWatches *parent = 0); + public slots: void refresh(); @@ -76,15 +81,25 @@ private: QmlWatches *m_watches; QObject *m_object; QMetaProperty m_property; + + QmlExpressionObject *m_expr; int m_column; }; +QmlWatchesProxy::QmlWatchesProxy(QmlExpressionObject *object, + int column, + QmlWatches *parent) +: QObject(parent), m_watches(parent), m_object(0), m_expr(object), m_column(column) +{ + QObject::connect(m_expr, SIGNAL(valueChanged()), this, SLOT(refresh())); +} + QmlWatchesProxy::QmlWatchesProxy(QObject *object, const QMetaProperty &prop, int column, QmlWatches *parent) : QObject(parent), m_watches(parent), m_object(object), m_property(prop), - m_column(column) + m_expr(0), m_column(column) { static int refreshIdx = -1; if(refreshIdx == -1) @@ -96,7 +111,10 @@ QmlWatchesProxy::QmlWatchesProxy(QObject *object, void QmlWatchesProxy::refresh() { - QVariant v = m_property.read(m_object); + QVariant v; + if(m_expr) v = m_expr->value(); + else v= m_property.read(m_object); + m_watches->addValue(m_column, v); } @@ -110,6 +128,24 @@ bool QmlWatches::hasWatch(quint32 objectId, const QByteArray &property) return m_watches.contains(qMakePair(objectId, property)); } +void QmlWatches::addWatch(QmlExpressionObject *expr) +{ + int oldColumn = columnCount(QModelIndex()); + + m_watches.append(qMakePair(quint32(0), QByteArray())); + + beginInsertColumns(QModelIndex(), oldColumn, oldColumn); + endInsertColumns(); + + m_columnNames.append(expr->expression()); + + QmlWatchesProxy *proxy = new QmlWatchesProxy(expr, oldColumn, this); + m_proxies.append(proxy); + + proxy->refresh(); + m_values[m_values.count() - 1].first = true; +} + void QmlWatches::addWatch(quint32 objectId, const QByteArray &property) { if(hasWatch(objectId, property)) @@ -117,7 +153,6 @@ void QmlWatches::addWatch(quint32 objectId, const QByteArray &property) int oldColumn = columnCount(QModelIndex()); - m_watches.append(qMakePair(objectId, property)); beginInsertColumns(QModelIndex(), oldColumn, oldColumn); @@ -128,36 +163,38 @@ void QmlWatches::addWatch(quint32 objectId, const QByteArray &property) QMetaProperty prop = obj->metaObject()->property(obj->metaObject()->indexOfProperty(property.constData())); QmlWatchesProxy *proxy = new QmlWatchesProxy(obj, prop, oldColumn, this); + m_proxies.append(proxy); proxy->refresh(); m_values[m_values.count() - 1].first = true; } void QmlWatches::remWatch(quint32 objectId, const QByteArray &property) { - m_watches.removeAll(qMakePair(objectId, property)); -} - -bool QmlWatches::hasWatch(quint32 exprId) -{ - return m_exprWatches.contains(exprId); -} - -void QmlWatches::remWatch(quint32 exprId) -{ - m_exprWatches.removeAll(exprId); -} - -void QmlWatches::addWatch(quint32 exprId) -{ - if (hasWatch(exprId)) - return; - - int oldColumn = columnCount(QModelIndex()); - - m_exprWatches.append(exprId); - - beginInsertColumns(QModelIndex(), oldColumn, oldColumn); - endInsertColumns(); + QPair watch = qMakePair(objectId, property); + for(int ii = 0; ii < m_watches.count(); ++ii) { + if(m_watches.at(ii) == watch) { + m_watches.removeAt(ii); + m_columnNames.removeAt(ii); + if(m_proxies.at(ii)) + delete m_proxies.at(ii); + m_proxies.removeAt(ii); + + + for(QList::Iterator iter = m_values.begin(); + iter != m_values.end(); + ) { + if(iter->column == ii) { + iter = m_values.erase(iter); + } else { + if(iter->column > ii) + --iter->column; + ++iter; + } + } + reset(); + return; + } + } } quint32 QmlWatches::objectId(QObject *object) @@ -210,7 +247,7 @@ void QmlWatches::addValue(int column, const QVariant &value) int QmlWatches::columnCount(const QModelIndex &) const { - return m_watches.count() + m_exprWatches.count(); + return m_watches.count(); } int QmlWatches::rowCount(const QModelIndex &) const diff --git a/src/declarative/debugger/qmlwatches_p.h b/src/declarative/debugger/qmlwatches_p.h index 4570a4f..6c383a1 100644 --- a/src/declarative/debugger/qmlwatches_p.h +++ b/src/declarative/debugger/qmlwatches_p.h @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE class QmlWatchesProxy; +class QmlExpressionObject; + class QmlWatches : public QAbstractTableModel { Q_OBJECT @@ -62,9 +64,7 @@ public: void addWatch(quint32 objectId, const QByteArray &property); void remWatch(quint32 objectId, const QByteArray &property); - bool hasWatch(quint32 exprId); - void remWatch(quint32 exprId); - void addWatch(quint32 exprId); + void addWatch(QmlExpressionObject *); quint32 objectId(QObject *); QObject *object(quint32); @@ -79,7 +79,6 @@ protected: private: friend class QmlWatchesProxy; QList > m_watches; - QList m_exprWatches; void addValue(int, const QVariant &); struct Value { @@ -89,6 +88,7 @@ private: }; QList m_values; QStringList m_columnNames; + QList > m_proxies; quint32 m_uniqueId; QHash, quint32> *> m_objects; -- cgit v0.12 From 4849a1db2f21390a040936c39dd8c65132c6e54a Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 8 May 2009 15:02:02 +1000 Subject: phonebrowser.qml is gone --- doc/src/declarative/examples.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 5ffcbf6..31c8a5d 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -14,7 +14,7 @@ There are several illustrative QML examples available. From your build directory, \code - bin/qmlviewer $QT_SOURCE_DIR/demos/declarative/phonebrowser/phonebrowser.qml + bin/qmlviewer $QT_SOURCE_DIR/demos/declarative/flickr/flickr.qml \endcode Many other simple examples can be found under the \c examples/declarative sub -- cgit v0.12