diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-05-08 03:34:11 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-05-08 03:34:11 (GMT) |
commit | d3b4366dd383400e5804eff07c4d226abf06c977 (patch) | |
tree | 2631aa82079ec491a5fea1009e2e68c0e48436d1 /src/declarative/fx | |
parent | 2ce79831de76b32ef2b0b96aef7301a83cdcf73a (diff) | |
parent | 674f6502671e969264bb7450a507ca04ab149b6a (diff) | |
download | Qt-d3b4366dd383400e5804eff07c4d226abf06c977.zip Qt-d3b4366dd383400e5804eff07c4d226abf06c977.tar.gz Qt-d3b4366dd383400e5804eff07c4d226abf06c977.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx')
-rw-r--r-- | src/declarative/fx/qfxblendedimage.cpp | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxflickable.cpp | 12 | ||||
-rw-r--r-- | src/declarative/fx/qfxflickable.h | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxgridview.cpp | 21 | ||||
-rw-r--r-- | src/declarative/fx/qfxgridview.h | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxhighlightfilter.cpp | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfximage.cpp | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxkeyproxy.cpp | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 24 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.h | 7 | ||||
-rw-r--r-- | src/declarative/fx/qfxparticles.cpp | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxpathview.cpp | 12 | ||||
-rw-r--r-- | src/declarative/fx/qfxpixmap.cpp | 7 | ||||
-rw-r--r-- | src/declarative/fx/qfxpixmap.h | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit.cpp | 42 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit.h | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit_p.h | 3 |
17 files changed, 82 insertions, 84 deletions
diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp index 3326ea8..79b8e41 100644 --- a/src/declarative/fx/qfxblendedimage.cpp +++ b/src/declarative/fx/qfxblendedimage.cpp @@ -101,7 +101,7 @@ void QFxBlendedImage::setPrimaryUrl(const QString &url) if (primSrc == url) return; if (!primSrc.isEmpty()) - QFxPixmap::cancelGet(primUrl,this,SLOT(primaryLoaded())); + QFxPixmap::cancelGet(primUrl,this); primSrc = url; primUrl = qmlContext(this)->resolvedUrl(url); if (!primSrc.isEmpty()) @@ -129,7 +129,7 @@ void QFxBlendedImage::setSecondaryUrl(const QString &url) if (secSrc == url) return; if (!secSrc.isEmpty()) - QFxPixmap::cancelGet(secUrl,this,SLOT(secondaryLoaded())); + QFxPixmap::cancelGet(secUrl,this); secSrc = url; secUrl = qmlContext(this)->resolvedUrl(url); if (!secSrc.isEmpty()) diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 52b142b..890bb31 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -116,6 +116,8 @@ void QFxFlickablePrivate::init() QObject::connect(_flick, SIGNAL(topChanged()), q, SIGNAL(positionChanged())); QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(&elasticY, SIGNAL(updated()), q, SLOT(ticked())); + QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange())); + QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(widthChange())); } void QFxFlickablePrivate::fixupX() @@ -914,23 +916,21 @@ void QFxFlickable::setViewportWidth(int w) d->updateBeginningEnd(); } -void QFxFlickable::setWidth(int w) +void QFxFlickable::widthChange() { Q_D(QFxFlickable); - QFxItem::setWidth(w); if (d->vWidth < 0) { - d->_flick->setWidth(w); + d->_flick->setWidth(width()); emit viewportWidthChanged(); d->updateBeginningEnd(); } } -void QFxFlickable::setHeight(int h) +void QFxFlickable::heightChange() { Q_D(QFxFlickable); - QFxItem::setHeight(h); if (d->vHeight < 0) { - d->_flick->setHeight(h); + d->_flick->setHeight(height()); emit viewportHeightChanged(); d->updateBeginningEnd(); } diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h index 1281788..c5a0593 100644 --- a/src/declarative/fx/qfxflickable.h +++ b/src/declarative/fx/qfxflickable.h @@ -133,8 +133,6 @@ public: qreal pageYPosition() const; qreal pageHeight() const; - virtual void setWidth(int); - virtual void setHeight(int); QFxItem *viewport(); Q_SIGNALS: @@ -165,6 +163,8 @@ protected Q_SLOTS: virtual void ticked(); void movementStarting(); void movementEnding(); + void heightChange(); + void widthChange(); protected: virtual qreal minXExtent() const; diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index acfb57e..9e6f2c9 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -319,6 +319,8 @@ void QFxGridViewPrivate::init() { Q_Q(QFxGridView); q->setOptions(QFxGridView::IsFocusRealm); + QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(sizeChange())); + QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(sizeChange())); } void QFxGridViewPrivate::clear() @@ -996,26 +998,9 @@ void QFxGridView::setCellHeight(int cellHeight) } } -/*! - \reimp -*/ -void QFxGridView::setHeight(int height) -{ - Q_D(QFxGridView); - QFxFlickable::setHeight(height); - if (isComponentComplete()) { - d->updateGrid(); - d->layout(); - } -} - -/*! - \reimp -*/ -void QFxGridView::setWidth(int width) +void QFxGridView::sizeChange() { Q_D(QFxGridView); - QFxFlickable::setWidth(width); if (isComponentComplete()) { d->updateGrid(); d->layout(); diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h index c612804..2bbfc40 100644 --- a/src/declarative/fx/qfxgridview.h +++ b/src/declarative/fx/qfxgridview.h @@ -109,9 +109,6 @@ public: int cellHeight() const; void setCellHeight(int); - virtual void setHeight(int height); - virtual void setWidth(int width); - static QObject *qmlAttachedProperties(QObject *); Q_SIGNALS: @@ -134,6 +131,7 @@ private Q_SLOTS: void itemsInserted(int index, int count); void itemsRemoved(int index, int count); void destroyRemoved(); + void sizeChange(); private: void refill(); diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp index 862a698..a22ad98 100644 --- a/src/declarative/fx/qfxhighlightfilter.cpp +++ b/src/declarative/fx/qfxhighlightfilter.cpp @@ -149,7 +149,7 @@ void QFxHighlightFilter::setSource(const QString &f) if (d->source == f) return; if (!d->source.isEmpty()) - QFxPixmap::cancelGet(d->url, this, SLOT(imageLoaded())); + QFxPixmap::cancelGet(d->url, this); d->source = f; d->url = qmlContext(this)->resolvedUrl(f); #if defined(QFX_RENDER_OPENGL2) diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index d66846d..e1ac2c7 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -865,9 +865,9 @@ void QFxImage::setSource(const QString &url) } if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this, SLOT(requestFinished())); + QFxPixmap::cancelGet(d->url, this); if (!d->sciurl.isEmpty()) - QFxPixmap::cancelGet(d->sciurl, this, SLOT(requestFinished())); + QFxPixmap::cancelGet(d->sciurl, this); d->source = url; d->url = qmlContext(this)->resolvedUrl(url); diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp index 1bb54ec..848b2d9 100644 --- a/src/declarative/fx/qfxkeyproxy.cpp +++ b/src/declarative/fx/qfxkeyproxy.cpp @@ -94,9 +94,9 @@ QList<QFxItem *> *QFxKeyProxy::targets() const void QFxKeyProxy::keyPressEvent(QKeyEvent *e) { for (int ii = 0; ii < d->targets.count(); ++ii) { - QSimpleCanvasItem *i = d->targets.at(ii); + QSimpleCanvasItem *i = canvas()->focusItem(d->targets.at(ii)); if (i) - canvas()->focusItem(i)->keyPressEvent(e); + i->keyPressEvent(e); if (e->isAccepted()) return; } @@ -105,9 +105,9 @@ void QFxKeyProxy::keyPressEvent(QKeyEvent *e) void QFxKeyProxy::keyReleaseEvent(QKeyEvent *e) { for (int ii = 0; ii < d->targets.count(); ++ii) { - QSimpleCanvasItem *i = d->targets.at(ii); + QSimpleCanvasItem *i = canvas()->focusItem(d->targets.at(ii)); if (i) - canvas()->focusItem(i)->keyReleaseEvent(e); + i->keyReleaseEvent(e); if (e->isAccepted()) return; } diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index b256c4a..ad752a7 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -356,6 +356,8 @@ void QFxListViewPrivate::init() { Q_Q(QFxListView); q->setOptions(QFxListView::IsFocusRealm); + QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(refill())); + QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(refill())); } void QFxListViewPrivate::clear() @@ -1190,28 +1192,6 @@ QString QFxListView::currentSection() const return d->currentSection; } -/*! - \reimp -*/ -void QFxListView::setHeight(int height) -{ - Q_D(QFxListView); - QFxFlickable::setHeight(height); - if (d->orient == Qt::Vertical && isComponentComplete()) - refill(); -} - -/*! - \reimp -*/ -void QFxListView::setWidth(int width) -{ - Q_D(QFxListView); - QFxFlickable::setWidth(width); - if (d->orient == Qt::Horizontal && isComponentComplete()) - refill(); -} - void QFxListView::viewportMoved() { Q_D(QFxListView); diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index f15db0c..40c2496 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -116,9 +116,6 @@ public: void setSectionExpression(const QString &); QString currentSection() const; - virtual void setHeight(int height); - virtual void setWidth(int width); - static QObject *qmlAttachedProperties(QObject *); Q_SIGNALS: @@ -137,10 +134,8 @@ protected: virtual void keyReleaseEvent(QKeyEvent *); virtual void componentComplete(); -private: - void refill(); - private Q_SLOTS: + void refill(); void trackedPositionChanged(); void itemResized(); void itemsInserted(int index, int count); diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp index 8535a73..1aaf256 100644 --- a/src/declarative/fx/qfxparticles.cpp +++ b/src/declarative/fx/qfxparticles.cpp @@ -635,7 +635,7 @@ void QFxParticles::setSource(const QString &name) return; if (!d->source.isEmpty()) - QFxPixmap::cancelGet(d->url, this, SLOT(imageLoaded())); + QFxPixmap::cancelGet(d->url, this); if (name.isEmpty()) { d->source = name; d->url = QUrl(); diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 2b39d6e..77d5fa2 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -157,7 +157,6 @@ void QFxPathView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemCreated(int, QFxItem*)), this, SLOT(itemCreated(int,QFxItem*))); for (int i=0; i<d->items.count(); i++){ QFxItem *p = d->items[i]; - attachedProperties.remove(p); d->model->release(p); } d->items.clear(); @@ -557,7 +556,6 @@ void QFxPathViewPrivate::regenerate() Q_Q(QFxPathView); for (int i=0; i<items.count(); i++){ QFxItem *p = items[i]; - q->attachedProperties.remove(p); model->release(p); } items.clear(); @@ -631,7 +629,6 @@ void QFxPathView::refill() while(wrapIndex-- >= 0){ QFxItem* p = d->items.takeFirst(); d->updateItem(p, 0.0); - attachedProperties.remove(p); d->model->release(p); d->firstIndex++; d->firstIndex %= d->model->count(); @@ -645,7 +642,6 @@ void QFxPathView::refill() while(wrapIndex++ < d->items.count()-1){ QFxItem* p = d->items.takeLast(); d->updateItem(p, 1.0); - attachedProperties.remove(p); d->model->release(p); d->firstIndex--; if (d->firstIndex < 0) @@ -704,7 +700,6 @@ void QFxPathView::itemsRemoved(int modelIndex, int count) if (d->pathItems == -1) { for (int i = 0; i < count; ++i) { QFxItem* p = d->items.takeAt(modelIndex); - attachedProperties.remove(p); d->model->release(p); } d->snapToCurrent(); @@ -876,8 +871,11 @@ void QFxPathViewPrivate::snapToCurrent() QHash<QObject*, QObject*> QFxPathView::attachedProperties; QObject *QFxPathView::qmlAttachedProperties(QObject *obj) { - QFxPathViewAttached *rv = new QFxPathViewAttached(obj); - attachedProperties.insert(obj, rv); + QObject *rv = attachedProperties.value(obj); + if (!rv) { + rv = new QFxPathViewAttached(obj); + attachedProperties.insert(obj, rv); + } return rv; } diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp index 3fdd8e5..0e5a10f 100644 --- a/src/declarative/fx/qfxpixmap.cpp +++ b/src/declarative/fx/qfxpixmap.cpp @@ -275,15 +275,18 @@ QNetworkReply *QFxPixmap::get(QmlEngine *engine, const QUrl& url, QObject* obj, /*! Stops the given slot being invoked if the given url finishes loading. May also cancel loading (eg. if no other pending request). + + Any connections to the QNetworkReply returned by get() will be + disconnected. */ -void QFxPixmap::cancelGet(const QUrl& url, QObject* obj, const char* slot) +void QFxPixmap::cancelGet(const QUrl& url, QObject* obj) { QString key = url.toString(); QFxPixmapCache::Iterator iter = qfxPixmapCache.find(key); if (iter == qfxPixmapCache.end()) return; if ((*iter)->reply) - QObject::disconnect((*iter)->reply, SIGNAL(finished()), obj, slot); + QObject::disconnect((*iter)->reply, 0, obj, 0); // XXX - loading not cancelled. Need to revisit caching } diff --git a/src/declarative/fx/qfxpixmap.h b/src/declarative/fx/qfxpixmap.h index 748991e..297dba7 100644 --- a/src/declarative/fx/qfxpixmap.h +++ b/src/declarative/fx/qfxpixmap.h @@ -67,7 +67,7 @@ public: QFxPixmap &operator=(const QFxPixmap &); static QNetworkReply *get(QmlEngine *, const QUrl& url, QObject*, const char* slot); - static void cancelGet(const QUrl& url, QObject* obj, const char* slot); + static void cancelGet(const QUrl& url, QObject* obj); bool isNull() const; diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index bf7a16d..3bc9696 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -377,6 +377,28 @@ void QFxTextEdit::setWrap(bool w) updateSize(); } +/*! + \property QFxTextEdit::cursorVisible + \brief If true the text edit shows a cursor. + + This property is set and unset when the text edit gets focus, but it can also + be set directly (useful, for example, if a KeyProxy might forward keys to it). +*/ +bool QFxTextEdit::isCursorVisible() const +{ + Q_D(const QFxTextEdit); + return d->cursorVisible; +} + +void QFxTextEdit::setCursorVisible(bool on) +{ + Q_D(QFxTextEdit); + if (d->cursorVisible == on) + return; + d->cursorVisible = on; + QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut); + d->control->processEvent(&focusEvent, QPointF(0, 0)); +} void QFxTextEdit::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) @@ -591,8 +613,15 @@ void QFxTextEdit::keyReleaseEvent(QKeyEvent *event) void QFxTextEdit::focusChanged(bool hasFocus) { Q_D(QFxTextEdit); - QFocusEvent focusEvent(hasFocus ? QEvent::FocusIn : QEvent::FocusOut); - d->control->processEvent(&focusEvent, QPointF(0, 0)); +} + +/*! + Causes all text to be selected. +*/ +void QFxTextEdit::selectAll() +{ + Q_D(QFxTextEdit); + d->control->selectAll(); } static QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e) @@ -737,6 +766,7 @@ void QFxTextEditPrivate::init() document->setDocumentMargin(0); document->setUndoRedoEnabled(false); // flush undo buffer. document->setUndoRedoEnabled(true); + updateDefaultTextOption(); } void QFxTextEdit::q_textChanged() @@ -785,14 +815,13 @@ void QFxTextEdit::updateSize() void QFxTextEditPrivate::updateDefaultTextOption() { - QTextDocument *doc = control->document(); - - QTextOption opt = doc->defaultTextOption(); + QTextOption opt = document->defaultTextOption(); int oldAlignment = opt.alignment(); opt.setAlignment((Qt::Alignment)(int)(hAlign | vAlign)); QTextOption::WrapMode oldWrapMode = opt.wrapMode(); +qDebug() << "wrap mode is" << opt.wrapMode(); if (wrap) opt.setWrapMode(QTextOption::WordWrap); else @@ -800,7 +829,8 @@ void QFxTextEditPrivate::updateDefaultTextOption() if (oldWrapMode == opt.wrapMode() && oldAlignment == opt.alignment()) return; - doc->setDefaultTextOption(opt); +qDebug() << "wrap mode set to" << opt.wrapMode(); + document->setDefaultTextOption(opt); } QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h index e5e9421..068a25a 100644 --- a/src/declarative/fx/qfxtextedit.h +++ b/src/declarative/fx/qfxtextedit.h @@ -75,7 +75,9 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem Q_PROPERTY(bool wrap READ wrap WRITE setWrap) Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat) Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) + Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible) Q_CLASSINFO("DefaultProperty", "text") + public: QFxTextEdit(QFxItem *parent=0); @@ -118,6 +120,9 @@ public: bool wrap() const; void setWrap(bool w); + bool isCursorVisible() const; + void setCursorVisible(bool on); + virtual void dump(int depth); virtual QString propertyInfo() const; @@ -145,6 +150,9 @@ Q_SIGNALS: void textChanged(const QString &); void cursorPositionChanged(); +public Q_SLOTS: + void selectAll(); + private Q_SLOTS: void fontChanged(); void updateImgCache(const QRectF &rect); diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h index b583dbe..f4591f5 100644 --- a/src/declarative/fx/qfxtextedit_p.h +++ b/src/declarative/fx/qfxtextedit_p.h @@ -68,7 +68,7 @@ class QFxTextEditPrivate : public QFxPaintedItemPrivate public: QFxTextEditPrivate() - : font(0), color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop), dirty(false), wrap(false), richText(false), format(QFxTextEdit::AutoText), document(0) + : font(0), color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop), dirty(false), wrap(false), richText(false), cursorVisible(false), format(QFxTextEdit::AutoText), document(0) { } @@ -93,6 +93,7 @@ public: bool dirty; bool wrap; bool richText; + bool cursorVisible; QFxTextEdit::TextFormat format; QTextDocument *document; QTextControl *control; |