summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-20 08:33:57 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-20 08:33:57 (GMT)
commitc0a02f5c67d3de5e16fd506df83fef968e09c798 (patch)
tree53643122e75a4d549159a9ec6000aa5b6c4a1e03 /src/declarative
parent86529642cfdc5cc5a94b735042d0807e3b57e9e1 (diff)
parent3182e16fa31a7def9775375971bea203af419d76 (diff)
downloadQt-c0a02f5c67d3de5e16fd506df83fef968e09c798.zip
Qt-c0a02f5c67d3de5e16fd506df83fef968e09c798.tar.gz
Qt-c0a02f5c67d3de5e16fd506df83fef968e09c798.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.cpp14
-rw-r--r--src/declarative/extra/qfxanimatedimageitem_p.h3
-rw-r--r--src/declarative/extra/qfxflowview.cpp4
-rw-r--r--src/declarative/extra/qfxflowview.h6
-rw-r--r--src/declarative/extra/qmlbehaviour.cpp4
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp4
-rw-r--r--src/declarative/fx/qfxgridview.cpp6
-rw-r--r--src/declarative/fx/qfximage.cpp6
-rw-r--r--src/declarative/fx/qfxlineedit.cpp164
-rw-r--r--src/declarative/fx/qfxlineedit.h39
-rw-r--r--src/declarative/fx/qfxlineedit_p.h3
-rw-r--r--src/declarative/fx/qfxlistview.cpp10
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp2
-rw-r--r--src/declarative/qml/qmlcompiler.cpp2
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp1
-rw-r--r--src/declarative/util/qmlfollow.cpp30
-rw-r--r--src/declarative/util/qmlfollow.h3
-rw-r--r--src/declarative/util/qmllistmodel.cpp4
18 files changed, 164 insertions, 141 deletions
diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp
index d22959a..5516a00 100644
--- a/src/declarative/extra/qfxanimatedimageitem.cpp
+++ b/src/declarative/extra/qfxanimatedimageitem.cpp
@@ -112,12 +112,15 @@ bool QFxAnimatedImageItem::isPlaying() const
void QFxAnimatedImageItem::setPlaying(bool play)
{
Q_D(QFxAnimatedImageItem);
+ if(play == d->playing)
+ return;
+ d->playing = play;
if (!d->_movie)
return;
if (play)
d->_movie->start();
else
- d->_movie->stop();
+ d->_movie->setPaused(true);
}
/*!
@@ -166,7 +169,7 @@ void QFxAnimatedImageItem::setSource(const QUrl &url)
d->reply = 0;
}
- d->url = url;
+ d->url = qmlContext(this)->resolvedUrl(url);
if (url.isEmpty()) {
delete d->_movie;
@@ -188,7 +191,7 @@ void QFxAnimatedImageItem::movieRequestFinished()
Q_D(QFxAnimatedImageItem);
d->_movie = new QMovie(d->reply);
if (!d->_movie->isValid()){
- qWarning() << "Error Reading File " << d->url;
+ qWarning() << "Error Reading Animated Image File " << d->url;
delete d->_movie;
d->_movie = 0;
return;
@@ -198,7 +201,10 @@ void QFxAnimatedImageItem::movieRequestFinished()
connect(d->_movie, SIGNAL(frameChanged(int)),
this, SLOT(movieUpdate()));
d->_movie->setCacheMode(QMovie::CacheAll);
- d->_movie->start();
+ if(d->playing)
+ d->_movie->start();
+ else
+ d->_movie->jumpToFrame(0);
setPixmap(d->_movie->currentPixmap());
}
diff --git a/src/declarative/extra/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h
index e7d8fb8..d743ba4 100644
--- a/src/declarative/extra/qfxanimatedimageitem_p.h
+++ b/src/declarative/extra/qfxanimatedimageitem_p.h
@@ -65,10 +65,11 @@ class QFxAnimatedImageItemPrivate : public QFxImagePrivate
public:
QFxAnimatedImageItemPrivate()
- : _movie(0)
+ : playing(true), _movie(0)
{
}
+ bool playing;
QMovie *_movie;
};
diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp
index 412cbc8..1676512 100644
--- a/src/declarative/extra/qfxflowview.cpp
+++ b/src/declarative/extra/qfxflowview.cpp
@@ -49,8 +49,8 @@ QT_BEGIN_NAMESPACE
class QFxFlowViewAttached : public QObject
{
Q_OBJECT
-Q_PROPERTY(int row READ row NOTIFY posChanged);
-Q_PROPERTY(int column READ column NOTIFY posChanged);
+Q_PROPERTY(int row READ row NOTIFY posChanged)
+Q_PROPERTY(int column READ column NOTIFY posChanged)
public:
QFxFlowViewAttached(QObject *parent);
diff --git a/src/declarative/extra/qfxflowview.h b/src/declarative/extra/qfxflowview.h
index 126f567..c2b30a3 100644
--- a/src/declarative/extra/qfxflowview.h
+++ b/src/declarative/extra/qfxflowview.h
@@ -58,8 +58,8 @@ class Q_DECLARATIVE_EXPORT QFxFlowView : public QFxItem
{
Q_OBJECT
Q_PROPERTY(QFxVisualItemModel *model READ model WRITE setModel)
- Q_PROPERTY(int column READ columns WRITE setColumns);
- Q_PROPERTY(bool vertical READ vertical WRITE setVertical);
+ Q_PROPERTY(int column READ columns WRITE setColumns)
+ Q_PROPERTY(bool vertical READ vertical WRITE setVertical)
public:
QFxFlowView();
@@ -101,7 +101,7 @@ private:
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QFxFlowView);
+QML_DECLARE_TYPE(QFxFlowView)
QT_END_HEADER
diff --git a/src/declarative/extra/qmlbehaviour.cpp b/src/declarative/extra/qmlbehaviour.cpp
index c7ab1da..92a85b0 100644
--- a/src/declarative/extra/qmlbehaviour.cpp
+++ b/src/declarative/extra/qmlbehaviour.cpp
@@ -57,8 +57,8 @@ public:
QmlBehaviourData(QObject *parent)
: QObject(parent) {}
- Q_PROPERTY(QVariant endValue READ endValue NOTIFY valuesChanged);
- Q_PROPERTY(QVariant startValue READ startValue NOTIFY valuesChanged);
+ Q_PROPERTY(QVariant endValue READ endValue NOTIFY valuesChanged)
+ Q_PROPERTY(QVariant startValue READ startValue NOTIFY valuesChanged)
QVariant endValue() const { return e; }
QVariant startValue() const { return s; }
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index 7f0029d..91ad538 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -432,6 +432,10 @@ QHash<int,QVariant> QmlXmlListModel::data(int index, const QList<int> &roles) co
return rv;
}
+/*!
+ \qmlproperty int XmlListModel::count
+ The number of data entries in the model.
+*/
int QmlXmlListModel::count() const
{
Q_D(const QmlXmlListModel);
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index 905af3b..3c80e98 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -59,10 +59,10 @@ public:
attachedProperties.remove(parent());
}
- Q_PROPERTY(QFxGridView *view READ view);
+ Q_PROPERTY(QFxGridView *view READ view)
QFxGridView *view() { return m_view; }
- Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged);
+ Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
bool isCurrentItem() const { return m_isCurrent; }
void setIsCurrentItem(bool c) {
if (m_isCurrent != c) {
@@ -71,7 +71,7 @@ public:
}
}
- Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged);
+ Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
bool delayRemove() const { return m_delayRemove; }
void setDelayRemove(bool delay) {
if (m_delayRemove != delay) {
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 027b22a..69030d2 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -464,6 +464,12 @@ QUrl QFxImage::source() const
return d->url;
}
+/*!
+ \qmlproperty bool Image::preserveAspect
+
+ Whether the image's aspect ratio should be preserved when resizing. By default this
+ is false.
+*/
bool QFxImage::preserveAspect() const
{
Q_D(const QFxImage);
diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp
index da79979..bafd782 100644
--- a/src/declarative/fx/qfxlineedit.cpp
+++ b/src/declarative/fx/qfxlineedit.cpp
@@ -104,32 +104,6 @@ void QFxLineEdit::setColor(const QColor &c)
d->color = c;
}
-/*
-QFxText::TextStyle QFxLineEdit::style() const
-{
- Q_D(const QFxLineEdit);
- return d->style;
-}
-
-void QFxLineEdit::setStyle(QFxText::TextStyle style)
-{
- Q_D(QFxLineEdit);
- d->style = style;
-}
-
-QColor QFxLineEdit::styleColor() const
-{
- Q_D(const QFxLineEdit);
- return d->styleColor;
-}
-
-void QFxLineEdit::setStyleColor(const QColor &c)
-{
- Q_D(QFxLineEdit);
- d->styleColor = c;
-}
-*/
-
QFxText::HAlignment QFxLineEdit::hAlign() const
{
Q_D(const QFxLineEdit);
@@ -142,19 +116,6 @@ void QFxLineEdit::setHAlign(QFxText::HAlignment align)
d->hAlign = align;
}
-QFxText::VAlignment QFxLineEdit::vAlign() const
-{
- Q_D(const QFxLineEdit);
- return d->vAlign;
-}
-
-void QFxLineEdit::setVAlign(QFxText::VAlignment align)
-{
- Q_D(QFxLineEdit);
- d->vAlign = align;
-}
-
-//### Should this also toggle cursor visibility?
bool QFxLineEdit::isReadOnly() const
{
Q_D(const QFxLineEdit);
@@ -190,16 +151,60 @@ void QFxLineEdit::setCursorPosition(int cp)
d->control->moveCursor(cp);
}
-int QFxLineEdit::selectionLength() const
+/*!
+ \qmlproperty int LineEdit::selectionStart
+
+ The cursor position before the first character in the current selection.
+ Setting this and selectionEnd allows you to specify a selection in the
+ text edit.
+
+ Note that if selectionStart == selectionEnd then there is no current
+ selection. If you attempt to set selectionStart to a value outside of
+ the current text, selectionStart will not be changed.
+
+ \sa selectionEnd, cursorPosition, selectedText
+*/
+int QFxLineEdit::selectionStart() const
+{
+ Q_D(const QFxLineEdit);
+ return d->lastSelectionStart;
+}
+
+void QFxLineEdit::setSelectionStart(int s)
+{
+ Q_D(QFxLineEdit);
+ if(d->lastSelectionStart == s || s < 0 || s > text().length())
+ return;
+ d->lastSelectionStart = s;
+ d->control->setSelection(s, d->lastSelectionEnd - s);
+}
+
+/*!
+ \qmlproperty int LineEdit::selectionEnd
+
+ The cursor position after the last character in the current selection.
+ Setting this and selectionStart allows you to specify a selection in the
+ text edit.
+
+ Note that if selectionStart == selectionEnd then there is no current
+ selection. If you attempt to set selectionEnd to a value outside of
+ the current text, selectionEnd will not be changed.
+
+ \sa selectionStart, cursorPosition, selectedText
+*/
+int QFxLineEdit::selectionEnd() const
{
Q_D(const QFxLineEdit);
- return d->control->selectionEnd() - d->control->selectionStart();
+ return d->lastSelectionEnd;
}
-void QFxLineEdit::setSelectionLength(int len)
+void QFxLineEdit::setSelectionEnd(int s)
{
Q_D(QFxLineEdit);
- d->control->setSelection(d->control->cursor(), len);
+ if(d->lastSelectionEnd == s || s < 0 || s > text().length())
+ return;
+ d->lastSelectionEnd = s;
+ d->control->setSelection(d->lastSelectionStart, s - d->lastSelectionStart);
}
QString QFxLineEdit::selectedText() const
@@ -404,41 +409,8 @@ void QFxLineEdit::drawContents(QPainter *p, const QRect &r)
if (d->control->hasSelectedText())
flags |= QLineControl::DrawSelections;
- //TODO: Clean up this cut'n'pasted section from QLineEdit
- QRect lineRect(r);
-
- int cix = qRound(d->control->cursorToX());
-
- // horizontal scrolling. d->hscroll is the left indent from the beginning
- // of the text line to the left edge of lineRect. we update this value
- // depending on the delta from the last paint event; in effect this means
- // the below code handles all scrolling based on the textline (widthUsed,
- // minLB, minRB), the line edit rect (lineRect) and the cursor position
- // (cix).
- QFontMetrics fm = QApplication::fontMetrics();
- int minLB = qMax(0, -fm.minLeftBearing());
- int minRB = qMax(0, -fm.minRightBearing());
- int widthUsed = d->control->width() + minRB;
- if ((minLB + widthUsed) <= lineRect.width()) {
- // text fits in lineRect; use hscroll for alignment
- d->hscroll = 0;
- d->hscroll -= minLB;
- } else if (cix - d->hscroll >= lineRect.width()) {
- // text doesn't fit, cursor is to the right of lineRect (scroll right)
- d->hscroll = cix - lineRect.width() + 1;
- } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) {
- // text doesn't fit, cursor is to the left of lineRect (scroll left)
- d->hscroll = cix;
- }
- // the y offset is there to keep the baseline constant in case we have script changes in the text.
- QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
+ d->control->draw(p, QPoint(0,0), r, flags);
- if(d->hscroll != d->oldScroll)
- moveCursor();
-
- d->control->draw(p, topLeft, r, flags);
-
- d->oldScroll = d->hscroll;
p->restore();
}
@@ -448,13 +420,12 @@ void QFxLineEditPrivate::init()
control->setCursorWidth(1);
control->setPasswordCharacter(QLatin1Char('*'));
control->setLayoutDirection(Qt::LeftToRight);
- control->setSelection(0,0);
q->setSmooth(true);
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setOptions(QFxLineEdit::AcceptsInputMethods | QFxLineEdit::SimpleItem
| QFxLineEdit::HasContents | QFxLineEdit::MouseEvents);
q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
- q, SIGNAL(cursorPositionChanged()));
+ q, SLOT(cursorPosChanged()));
q->connect(control, SIGNAL(selectionChanged()),
q, SLOT(selectionChanged()));
q->connect(control, SIGNAL(textChanged(const QString &)),
@@ -472,16 +443,43 @@ void QFxLineEditPrivate::init()
font = new QmlFont();
q->updateSize();
oldValidity = control->hasAcceptableInput();
- oldSelectLength = q->selectionLength();
+ lastSelectionStart = 0;
+ lastSelectionEnd = 0;
+}
+
+void QFxLineEdit::cursorPosChanged()
+{
+ Q_D(QFxLineEdit);
+ emit cursorPositionChanged();
+
+ if(!d->control->hasSelectedText()){
+ if(d->lastSelectionStart != d->control->cursor()){
+ d->lastSelectionStart = d->control->cursor();
+ emit selectionStartChanged();
+ }
+ if(d->lastSelectionEnd != d->control->cursor()){
+ d->lastSelectionEnd = d->control->cursor();
+ emit selectionEndChanged();
+ }
+ }
}
void QFxLineEdit::selectionChanged()
{
Q_D(QFxLineEdit);
emit selectedTextChanged();
- if(selectionLength() != d->oldSelectLength){
- d->oldSelectLength = selectionLength();
- emit selectionLengthChanged();
+
+ if(d->lastSelectionStart != d->control->selectionStart()){
+ d->lastSelectionStart = d->control->selectionStart();
+ if(d->lastSelectionStart == -1)
+ d->lastSelectionStart = d->control->cursor();
+ emit selectionStartChanged();
+ }
+ if(d->lastSelectionEnd != d->control->selectionEnd()){
+ d->lastSelectionEnd = d->control->selectionEnd();
+ if(d->lastSelectionEnd == -1)
+ d->lastSelectionEnd = d->control->cursor();
+ emit selectionEndChanged();
}
}
diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h
index e053c54..2c22d4b 100644
--- a/src/declarative/fx/qfxlineedit.h
+++ b/src/declarative/fx/qfxlineedit.h
@@ -62,17 +62,13 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QmlFont *font READ font)
Q_PROPERTY(QColor color READ color WRITE setColor)
- /*
- Q_PROPERTY(QFxText::TextStyle style READ style WRITE setStyle)
- Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor)
Q_PROPERTY(QFxText::HAlignment hAlign READ hAlign WRITE setHAlign)
- Q_PROPERTY(QFxText::VAlignment vAlign READ vAlign WRITE setVAlign)
- */
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly);
Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength);
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged);
- Q_PROPERTY(int selectionLength READ selectionLength WRITE setSelectionLength NOTIFY selectionLengthChanged);
+ Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
+ Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged);
Q_PROPERTY(QObject* validator READ validator WRITE setValidator);
@@ -81,10 +77,6 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem
Q_PROPERTY(uint echoMode READ echoMode WRITE setEchoMode);
Q_PROPERTY(QmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate);
- /*
- Q_PROPERTY(int scrollDuration READ scrollDuration SET setScrollDuration NOTIFY scrollDurationChanged);
- */
-
public:
QFxLineEdit(QFxItem* parent=0);
~QFxLineEdit();
@@ -100,20 +92,9 @@ public:
//### Should we have this function or x variants of properties?
Q_INVOKABLE int xToPos(int x);
- /*
- QFxText::TextStyle style() const;
- void setStyle(QFxText::TextStyle style);
-
- QColor styleColor() const;
- void setStyleColor(const QColor &c);
- */
-
QFxText::HAlignment hAlign() const;
void setHAlign(QFxText::HAlignment align);
- QFxText::VAlignment vAlign() const;
- void setVAlign(QFxText::VAlignment align);
-
bool isReadOnly() const;
void setReadOnly(bool);
@@ -123,8 +104,11 @@ public:
int cursorPosition() const;
void setCursorPosition(int cp);
- int selectionLength() const;
- void setSelectionLength(int len);
+ int selectionStart() const;
+ void setSelectionStart(int);
+
+ int selectionEnd() const;
+ void setSelectionEnd(int);
QString selectedText() const;
@@ -140,18 +124,14 @@ public:
QmlComponent* cursorDelegate() const;
void setCursorDelegate(QmlComponent*);
- /*
- int scrollDuration() const;
- void setScrollDuration(int);
- */
-
bool hasAcceptableInput() const;
void drawContents(QPainter *p,const QRect &r);
Q_SIGNALS:
void textChanged();
void cursorPositionChanged();
- void selectionLengthChanged();
+ void selectionStartChanged();
+ void selectionEndChanged();
void selectedTextChanged();
void accepted();
void acceptableInputChanged();
@@ -174,6 +154,7 @@ private slots:
void updateAll();
void createCursor();
void moveCursor();
+ void cursorPosChanged();
private:
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxLineEdit);
diff --git a/src/declarative/fx/qfxlineedit_p.h b/src/declarative/fx/qfxlineedit_p.h
index a0ab19c..a18dea7 100644
--- a/src/declarative/fx/qfxlineedit_p.h
+++ b/src/declarative/fx/qfxlineedit_p.h
@@ -89,7 +89,8 @@ public:
QPointer<QmlComponent> cursorComponent;
QPointer<QFxItem> cursorItem;
- int oldSelectLength;
+ int lastSelectionStart;
+ int lastSelectionEnd;
int oldHeight;
int oldWidth;
bool oldValidity;
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 351365d..50564fb 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -59,10 +59,10 @@ public:
attachedProperties.remove(parent());
}
- Q_PROPERTY(QFxListView *view READ view);
+ Q_PROPERTY(QFxListView *view READ view)
QFxListView *view() { return m_view; }
- Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged);
+ Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
bool isCurrentItem() const { return m_isCurrent; }
void setIsCurrentItem(bool c) {
if (m_isCurrent != c) {
@@ -71,7 +71,7 @@ public:
}
}
- Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged);
+ Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged)
QString prevSection() const { return m_prevSection; }
void setPrevSection(const QString &sect) {
if (m_prevSection != sect) {
@@ -80,7 +80,7 @@ public:
}
}
- Q_PROPERTY(QString section READ section NOTIFY sectionChanged);
+ Q_PROPERTY(QString section READ section NOTIFY sectionChanged)
QString section() const { return m_section; }
void setSection(const QString &sect) {
if (m_section != sect) {
@@ -89,7 +89,7 @@ public:
}
}
- Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged);
+ Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
bool delayRemove() const { return m_delayRemove; }
void setDelayRemove(bool delay) {
if (m_delayRemove != delay) {
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index eb10df3..1b15a48 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -160,7 +160,7 @@ Q_OBJECT
public:
QFxVisualItemModelData(int index, QFxVisualItemModelPrivate *model);
- Q_PROPERTY(int index READ index NOTIFY indexChanged);
+ Q_PROPERTY(int index READ index NOTIFY indexChanged)
int index() const;
void setIndex(int index);
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 138be29..477e6a5 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -940,7 +940,7 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj,
COMPILE_EXCEPTION(obj, "Invalid component id specification");
if (idProp) {
- QString idVal = idProp->values.first()->primitive().toUtf8();
+ QString idVal = idProp->values.first()->primitive();
if (compileState.ids.contains(idVal))
COMPILE_EXCEPTION(obj, "id is not unique");
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index 9af5c3c..3037051 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -251,7 +251,6 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit,
error.setUrl(url);
error.setDescription(tr("Import %1 unavailable").arg(imp.uri));
unit->errors << error;
-qDebug() << "ERR";
ok = false;
}
}
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp
index b8e6685..1e6fea2 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlfollow.cpp
@@ -56,7 +56,7 @@ class QmlFollowPrivate : public QObjectPrivate
public:
QmlFollowPrivate()
: sourceValue(0), maxVelocity(0), lastTime(0)
- , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), modulus(0.0), enabled(true), mode(Track), clock(this) {}
+ , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01), modulus(0.0), enabled(true), mode(Track), clock(this) {}
QmlMetaProperty property;
qreal currentValue;
@@ -164,8 +164,10 @@ void QmlFollowPrivate::tick(int time)
}
lastTime = time;
}
- emit q->valueChanged(currentValue);
property.write(currentValue);
+ emit q->valueChanged(currentValue);
+ if (clock.state() != QAbstractAnimation::Running)
+ emit q->syncChanged();
}
void QmlFollowPrivate::updateMode()
@@ -183,12 +185,15 @@ void QmlFollowPrivate::start()
if (!enabled)
return;
+ Q_Q(QmlFollow);
if (mode == QmlFollowPrivate::Track) {
currentValue = sourceValue;
property.write(currentValue);
} else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) {
lastTime = 0;
+ currentValue = property.read().toDouble();
clock.start(); // infinity??
+ emit q->syncChanged();
}
}
@@ -261,8 +266,10 @@ qreal QmlFollow::sourceValue() const
void QmlFollow::setSourceValue(qreal value)
{
Q_D(QmlFollow);
- d->sourceValue = value;
- d->start();
+ if (d->sourceValue != value) {
+ d->sourceValue = value;
+ d->start();
+ }
}
/*!
@@ -338,7 +345,7 @@ void QmlFollow::setDamping(qreal damping)
to 0 to be considered equal to zero. This will depend on the usage of the value.
For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
- The default is 0.005. Small performance improvements can result in tuning this
+ The default is 0.01. Small performance improvements can result in tuning this
value.
*/
qreal QmlFollow::epsilon() const
@@ -397,6 +404,19 @@ void QmlFollow::setEnabled(bool enabled)
d->stop();
}
+/*!
+ \qmlproperty bool Follow::inSync
+ This property is true when target is equal to the source; otherwise
+ false. If inSync is true the target is not being animated.
+
+ If \l enabled is false then inSync will also be false.
+*/
+bool QmlFollow::inSync() const
+{
+ Q_D(const QmlFollow);
+ return d->enabled && d->clock.state() != QAbstractAnimation::Running;
+}
+
qreal QmlFollow::value() const
{
Q_D(const QmlFollow);
diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlfollow.h
index 07e15e9..e0a588b 100644
--- a/src/declarative/util/qmlfollow.h
+++ b/src/declarative/util/qmlfollow.h
@@ -68,6 +68,7 @@ class Q_DECLARATIVE_EXPORT QmlFollow : public QmlPropertyValueSource,
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
Q_PROPERTY(qreal followValue READ value NOTIFY valueChanged)
Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
+ Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged)
public:
QmlFollow(QObject *parent=0);
@@ -89,11 +90,13 @@ public:
void setModulus(qreal modulus);
bool enabled() const;
void setEnabled(bool enabled);
+ bool inSync() const;
qreal value() const;
Q_SIGNALS:
void valueChanged(qreal);
+ void syncChanged();
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index a969100..0c167c0 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -330,6 +330,10 @@ QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const
return rv;
}
+/*!
+ \qmlproperty int ListModel::count
+ The number of data entries in the model.
+*/
int QmlListModel::count() const
{
if (!_root) return 0;