From 136c8210cc98bc6d9b17fd4d517d9d399f30e6c2 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jul 2009 16:58:42 +1000 Subject: Don't bounce around when removing the current item. --- src/declarative/fx/qfxlistview.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 3d97dfa..a78fed5 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -278,6 +278,18 @@ public: return -1; } + int lastVisibleIndex() const { + int lastIndex = -1; + for (int i = visibleItems.count()-1; i >= 0; --i) { + FxListItem *listItem = visibleItems.at(i); + if (listItem->index != -1) { + lastIndex = listItem->index; + break; + } + } + return lastIndex; + } + // map a model index to visibleItems index. // These may differ if removed items are still present in the visible list, // e.g. doing a removal animation @@ -542,7 +554,7 @@ void QFxListViewPrivate::layout() pos += item->size(); } // move current item if it is after the visible items. - if (currentItem && currentIndex > visibleItems.last()->index) + if (currentItem && currentIndex > lastVisibleIndex()) currentItem->setPosition(currentItem->position() + (visibleItems.last()->endPosition() - oldEnd)); } if (!isValid()) @@ -647,7 +659,8 @@ void QFxListViewPrivate::createHighlight() const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x"); highlightPosAnimator = new QmlFollow(q); highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp)); - highlightPosAnimator->setSpring(3); + highlightPosAnimator->setEpsilon(0.25); + highlightPosAnimator->setSpring(2.5); highlightPosAnimator->setDamping(0.3); highlightPosAnimator->setEnabled(autoHighlight); const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width"); -- cgit v0.12 From 8358e5b93efcb119cc7dd036c8f5f4ae960f702e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 30 Jul 2009 11:55:50 +0200 Subject: Fixed AST visiting, so UiProgram *members* are visited again. --- src/declarative/qml/parser/qmljsast.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/qml/parser/qmljsast.cpp b/src/declarative/qml/parser/qmljsast.cpp index caf81e5..11a98b6 100644 --- a/src/declarative/qml/parser/qmljsast.cpp +++ b/src/declarative/qml/parser/qmljsast.cpp @@ -792,6 +792,7 @@ void UiProgram::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(imports, visitor); + accept(members, visitor); } visitor->endVisit(this); -- cgit v0.12 From a80468f33d8216ab06c23551b9f6a7b2722ddc14 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 31 Jul 2009 10:51:42 +1000 Subject: Docs --- src/declarative/util/qmlpalette.cpp | 34 +++++++++++++++++++++++++--------- src/declarative/util/qmlpalette.h | 10 +++++----- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp index 3a6dadc..25576f1 100644 --- a/src/declarative/util/qmlpalette.cpp +++ b/src/declarative/util/qmlpalette.cpp @@ -55,10 +55,24 @@ public: QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Palette,QmlPalette) /*! - \internal - \class QmlPalette + \qmlclass Palette QmlPalette \ingroup group_utility - \brief The QmlPalette class gives access to the Qt palettes. + \brief The Palette item gives access to the Qt palettes. + \sa QPalette + + + \code + Palette { id: MyPalette; colorGroup: "Active" } + + Rect { + width: 640; height: 480 + color: MyPalette.window + Text { + anchors.fill: parent + text: "Hello!"; color: MyPalette.windowText + } + } + \endcode */ QmlPalette::QmlPalette(QObject *parent) : QObject(*(new QmlPalettePrivate), parent) @@ -73,12 +87,20 @@ QmlPalette::~QmlPalette() { } +/*! + \qmlproperty Palette::window + \brief The window (general background) color of the current color group. +*/ QColor QmlPalette::window() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Window); } +/*! + \qmlproperty Palette::windowText + \brief The window text (general foreground) color of the current color group. +*/ QColor QmlPalette::windowText() const { Q_D(const QmlPalette); @@ -174,12 +196,6 @@ void QmlPalette::setColorGroup(ColorGroup colorGroup) emit paletteChanged(); } -QPalette QmlPalette::palette() const -{ - Q_D(const QmlPalette); - return d->palette; -} - bool QmlPalette::eventFilter(QObject *watched, QEvent *event) { if (watched == qApp) { diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h index 3030557..b601881 100644 --- a/src/declarative/util/qmlpalette.h +++ b/src/declarative/util/qmlpalette.h @@ -99,19 +99,19 @@ public: QColor highlight() const; QColor highlightedText() const; - QPalette palette() const; - ColorGroup colorGroup() const; void setColorGroup(ColorGroup); - bool virtual eventFilter(QObject *watched, QEvent *event); - bool virtual event(QEvent *event); - Q_INVOKABLE QColor lighter(const QColor&) const; Q_INVOKABLE QColor darker(const QColor&) const; Q_SIGNALS: void paletteChanged(); + +private: + bool eventFilter(QObject *watched, QEvent *event); + bool event(QEvent *event); + }; QT_END_NAMESPACE -- cgit v0.12 From 62b79ded0e4267d06ecf26ae7fc6b73d8b335df8 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 31 Jul 2009 11:16:44 +1000 Subject: QmlFontFamily improvements Add a 'status' property instead of 'loading'. Improve documentaion. --- src/declarative/util/qmlfontfamily.cpp | 33 +++++++++++++++++++++++++-------- src/declarative/util/qmlfontfamily.h | 10 +++++++--- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/declarative/util/qmlfontfamily.cpp b/src/declarative/util/qmlfontfamily.cpp index e539085..a82527b 100644 --- a/src/declarative/util/qmlfontfamily.cpp +++ b/src/declarative/util/qmlfontfamily.cpp @@ -57,14 +57,14 @@ class QmlFontFamilyPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlFontFamily); public: - QmlFontFamilyPrivate() : reply(0), loading(false) {} + QmlFontFamilyPrivate() : reply(0), status(QmlFontFamily::Null) {} void addFontToDatabase(const QByteArray &); QUrl url; QString name; QNetworkReply *reply; - bool loading; + QmlFontFamily::Status status; }; QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) @@ -72,6 +72,15 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) /*! \qmlclass FontFamily QmlFontFamily \ingroup group_utility + \brief This item allows using fonts by name or url. + + \code + FontFamily { id: FixedFont; name: "Courier" } + FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + + Text { text: "Fixed-size font"; font.family: FixedFont.name } + Text { text: "Fancy font"; font.family: WebFont.name } + \endcode */ QmlFontFamily::QmlFontFamily(QObject *parent) : QObject(*(new QmlFontFamilyPrivate), parent) @@ -82,6 +91,10 @@ QmlFontFamily::~QmlFontFamily() { } +/*! + \qmlproperty FontFamily::source + The source for the font. +*/ QUrl QmlFontFamily::source() const { Q_D(const QmlFontFamily); @@ -95,8 +108,8 @@ void QmlFontFamily::setSource(const QUrl &url) return; d->url = qmlContext(this)->resolvedUrl(url); - d->loading = true; - emit loadingChanged(); + d->status = Loading; + emit statusChanged(); #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML if (d->url.scheme() == QLatin1String("file")) { QFile file(d->url.toLocalFile()); @@ -128,10 +141,10 @@ void QmlFontFamily::setName(const QString &name) emit nameChanged(); } -bool QmlFontFamily::isLoading() const +QmlFontFamily::Status QmlFontFamily::status() const { Q_D(const QmlFontFamily); - return d->loading; + return d->status; } void QmlFontFamily::replyFinished() @@ -140,6 +153,9 @@ void QmlFontFamily::replyFinished() if (!d->reply->error()) { QByteArray ba = d->reply->readAll(); d->addFontToDatabase(ba); + } else { + d->status = Error; + emit statusChanged(); } d->reply->deleteLater(); d->reply = 0; @@ -153,11 +169,12 @@ void QmlFontFamilyPrivate::addFontToDatabase(const QByteArray &ba) if (id != -1) { name = QFontDatabase::applicationFontFamilies(id).at(0); emit q->nameChanged(); - loading = false; - emit q->loadingChanged(); + status = QmlFontFamily::Ready; } else { + status = QmlFontFamily::Error; qWarning() << "Cannot load font: " << name << url; } + emit q->statusChanged(); } QT_END_NAMESPACE diff --git a/src/declarative/util/qmlfontfamily.h b/src/declarative/util/qmlfontfamily.h index c647f67..17b6635 100644 --- a/src/declarative/util/qmlfontfamily.h +++ b/src/declarative/util/qmlfontfamily.h @@ -56,12 +56,15 @@ class Q_DECLARATIVE_EXPORT QmlFontFamily : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QmlFontFamily) + Q_ENUMS(Status) Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) public: + enum Status { Null = 0, Ready, Loading, Error }; + QmlFontFamily(QObject *parent = 0); ~QmlFontFamily(); @@ -71,14 +74,14 @@ public: QString name() const; void setName(const QString &name); - bool isLoading() const; + Status status() const; private Q_SLOTS: void replyFinished(); Q_SIGNALS: void nameChanged(); - void loadingChanged(); + void statusChanged(); }; QT_END_NAMESPACE @@ -88,3 +91,4 @@ QML_DECLARE_TYPE(QmlFontFamily) QT_END_HEADER #endif // QMLFONTFAMILY_H + -- cgit v0.12