summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp133
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview_p.h9
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h2
-rw-r--r--src/declarative/qml/qmlsqldatabase.cpp4
-rw-r--r--src/declarative/util/qmlanimation_p_p.h21
6 files changed, 157 insertions, 14 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index 9dd2ab4..144eed7 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -178,6 +178,7 @@ public:
, moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0.0)
, highlightMoveSpeed(400), highlightResizeSpeed(400), highlightRange(QmlGraphicsListView::NoHighlightRange)
, snapMode(QmlGraphicsListView::NoSnap), overshootDist(0.0)
+ , footerComponent(0), footer(0), headerComponent(0), header(0)
, ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false)
, correctFlick(true)
{}
@@ -209,7 +210,6 @@ public:
}
FxListItem *nextVisibleItem() const {
- qDebug() << "last vis";
const qreal pos = position();
bool foundFirst = false;
for (int i = 0; i < visibleItems.count(); ++i) {
@@ -404,9 +404,9 @@ public:
void updateViewport() {
Q_Q(QmlGraphicsListView);
if (orient == QmlGraphicsListView::Vertical)
- q->setViewportHeight(endPosition() - startPosition());
+ q->setViewportHeight(q->minYExtent() - q->maxYExtent());
else
- q->setViewportWidth(endPosition() - startPosition());
+ q->setViewportWidth(q->minXExtent() - q->maxXExtent());
}
@@ -434,6 +434,8 @@ public:
void updateCurrentSection();
void updateCurrent(int);
void updateAverage();
+ void updateHeader();
+ void updateFooter();
void fixupPosition();
virtual void fixupY();
virtual void fixupX();
@@ -469,6 +471,10 @@ public:
QmlGraphicsListView::HighlightRangeMode highlightRange;
QmlGraphicsListView::SnapMode snapMode;
qreal overshootDist;
+ QmlComponent *footerComponent;
+ FxListItem *footer;
+ QmlComponent *headerComponent;
+ FxListItem *header;
bool ownModel : 1;
bool wrap : 1;
@@ -491,7 +497,7 @@ void QmlGraphicsListViewPrivate::clear()
for (int i = 0; i < visibleItems.count(); ++i)
releaseItem(visibleItems.at(i));
visibleItems.clear();
- visiblePos = 0;
+ visiblePos = header ? header->size() : 0;
visibleIndex = 0;
releaseItem(currentItem);
currentItem = 0;
@@ -623,6 +629,10 @@ void QmlGraphicsListViewPrivate::refill(qreal from, qreal to)
updateAverage();
if (!sectionExpression.isEmpty())
updateCurrentSection();
+ if (header)
+ updateHeader();
+ if (footer)
+ updateFooter();
updateViewport();
}
}
@@ -647,6 +657,10 @@ void QmlGraphicsListViewPrivate::layout()
q->refill();
updateHighlight();
fixupPosition();
+ if (header)
+ updateHeader();
+ if (footer)
+ updateFooter();
updateUnrequestedPositions();
updateViewport();
}
@@ -860,6 +874,66 @@ void QmlGraphicsListViewPrivate::updateAverage()
averageSize = sum / visibleItems.count();
}
+void QmlGraphicsListViewPrivate::updateFooter()
+{
+ Q_Q(QmlGraphicsListView);
+ if (!footer && footerComponent) {
+ QmlGraphicsItem *item = 0;
+ QmlContext *context = new QmlContext(qmlContext(q));
+ QObject *nobj = footerComponent->create(context);
+ if (nobj) {
+ context->setParent(nobj);
+ item = qobject_cast<QmlGraphicsItem *>(nobj);
+ if (!item)
+ delete nobj;
+ } else {
+ delete context;
+ }
+ if (item) {
+ item->setParent(q->viewport());
+ item->setZValue(1);
+ footer = new FxListItem(item, q);
+ }
+ }
+ if (footer) {
+ if (visibleItems.count())
+ footer->setPosition(endPosition());
+ else
+ footer->setPosition(visiblePos);
+ }
+}
+
+void QmlGraphicsListViewPrivate::updateHeader()
+{
+ Q_Q(QmlGraphicsListView);
+ if (!header && headerComponent) {
+ QmlGraphicsItem *item = 0;
+ QmlContext *context = new QmlContext(qmlContext(q));
+ QObject *nobj = headerComponent->create(context);
+ if (nobj) {
+ context->setParent(nobj);
+ item = qobject_cast<QmlGraphicsItem *>(nobj);
+ if (!item)
+ delete nobj;
+ } else {
+ delete context;
+ }
+ if (item) {
+ item->setParent(q->viewport());
+ item->setZValue(1);
+ header = new FxListItem(item, q);
+ if (visibleItems.isEmpty())
+ visiblePos = header->size();
+ }
+ }
+ if (header) {
+ if (visibleItems.count())
+ header->setPosition(startPosition() - header->size());
+ else
+ header->setPosition(0);
+ }
+}
+
void QmlGraphicsListViewPrivate::fixupPosition()
{
if (orient == QmlGraphicsListView::Vertical)
@@ -1759,6 +1833,47 @@ void QmlGraphicsListView::setSnapMode(SnapMode mode)
}
}
+QmlComponent *QmlGraphicsListView::footer() const
+{
+ Q_D(const QmlGraphicsListView);
+ return d->footerComponent;
+}
+
+void QmlGraphicsListView::setFooter(QmlComponent *footer)
+{
+ Q_D(QmlGraphicsListView);
+ if (d->footerComponent != footer) {
+ if (d->footer) {
+ delete d->footer;
+ d->footer = 0;
+ }
+ d->footerComponent = footer;
+ d->updateFooter();
+ d->updateViewport();
+ }
+}
+
+QmlComponent *QmlGraphicsListView::header() const
+{
+ Q_D(const QmlGraphicsListView);
+ return d->headerComponent;
+}
+
+void QmlGraphicsListView::setHeader(QmlComponent *header)
+{
+ Q_D(QmlGraphicsListView);
+ if (d->headerComponent != header) {
+ if (d->header) {
+ delete d->header;
+ d->header = 0;
+ }
+ d->headerComponent = header;
+ d->updateHeader();
+ d->updateFooter();
+ d->updateViewport();
+ }
+}
+
void QmlGraphicsListView::viewportMoved()
{
Q_D(QmlGraphicsListView);
@@ -1813,6 +1928,8 @@ qreal QmlGraphicsListView::minYExtent() const
if (d->orient == QmlGraphicsListView::Horizontal)
return QmlGraphicsFlickable::minYExtent();
qreal extent = -d->startPosition();
+ if (d->header && d->visibleItems.count())
+ extent += d->header->size();
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
extent += d->highlightRangeStart;
@@ -1829,6 +1946,8 @@ qreal QmlGraphicsListView::maxYExtent() const
extent = -(d->positionAt(count()-1) - d->highlightRangeEnd);
else
extent = -(d->endPosition() - height() + 1);
+ if (d->footer)
+ extent -= d->footer->size();
qreal minY = minYExtent();
if (extent > minY)
extent = minY;
@@ -1841,6 +1960,8 @@ qreal QmlGraphicsListView::minXExtent() const
if (d->orient == QmlGraphicsListView::Vertical)
return QmlGraphicsFlickable::minXExtent();
qreal extent = -d->startPosition();
+ if (d->header)
+ extent += d->header->size();
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
extent += d->highlightRangeStart;
@@ -1857,6 +1978,8 @@ qreal QmlGraphicsListView::maxXExtent() const
extent = -(d->positionAt(count()-1) - d->highlightRangeEnd);
else
extent = -(d->endPosition() - width() + 1);
+ if (d->footer)
+ extent -= d->footer->size();
qreal minX = minXExtent();
if (extent > minX)
extent = minX;
@@ -2221,7 +2344,7 @@ void QmlGraphicsListView::itemsRemoved(int modelIndex, int count)
if (d->visibleItems.isEmpty()) {
d->visibleIndex = 0;
- d->visiblePos = 0;
+ d->visiblePos = d->header ? d->header->size() : 0;
d->timeline.clear();
d->setPosition(0);
if (d->model->count() == 0)
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h
index cc74056..241fb05 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h
@@ -84,6 +84,9 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsListView : public QmlGraphicsFlickable
Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode)
+ Q_PROPERTY(QmlComponent *header READ header WRITE setHeader)
+ Q_PROPERTY(QmlComponent *footer READ footer WRITE setFooter)
+
Q_ENUMS(HighlightRangeMode)
Q_ENUMS(Orientation)
Q_ENUMS(SnapMode)
@@ -149,6 +152,12 @@ public:
SnapMode snapMode() const;
void setSnapMode(SnapMode mode);
+ QmlComponent *footer() const;
+ void setFooter(QmlComponent *);
+
+ QmlComponent *header() const;
+ void setHeader(QmlComponent *);
+
static QmlGraphicsListViewAttached *qmlAttachedProperties(QObject *);
public Q_SLOTS:
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
index 5f5269f..3521638 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
@@ -562,7 +562,7 @@ QString QmlGraphicsTextEdit::selectedText() const
\qmlproperty bool TextEdit::focusOnPress
Whether the TextEdit should gain focus on a mouse press. By default this is
- set to false.
+ set to true.
*/
bool QmlGraphicsTextEdit::focusOnPress() const
{
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h b/src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h
index 4cbc56d..6541921 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstextedit_p_p.h
@@ -69,7 +69,7 @@ class QmlGraphicsTextEditPrivate : public QmlGraphicsPaintedItemPrivate
public:
QmlGraphicsTextEditPrivate()
: color("black"), imgDirty(true), hAlign(QmlGraphicsTextEdit::AlignLeft), vAlign(QmlGraphicsTextEdit::AlignTop),
- dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false),
+ dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(true),
persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
cursorComponent(0), cursor(0), format(QmlGraphicsTextEdit::AutoText), document(0)
{
diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp
index d11e3cb..5a7e94c 100644
--- a/src/declarative/qml/qmlsqldatabase.cpp
+++ b/src/declarative/qml/qmlsqldatabase.cpp
@@ -71,7 +71,7 @@ public:
str_forwardOnly = engine->toStringHandle(QLatin1String("forwardOnly")); // not in HTML5 (an optimization)
}
- QueryFlags queryProperty(const QScriptValue &object,
+ QueryFlags queryProperty(const QScriptValue &,
const QScriptString &name,
QueryFlags flags, uint *)
{
@@ -369,7 +369,7 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng
// Incompatible
THROW_SQL(VERSION_ERR,QmlEngine::tr("SQL: database version mismatch"));
}
- version = ini.value("Version").toString();
+ version = ini.value(QLatin1String("Version")).toString();
}
database.setDatabaseName(basename+QLatin1String(".sqlite"));
}
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index cb1c642..326e1c6 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -64,6 +64,7 @@
#include <qml.h>
#include <qmlcontext.h>
#include <private/qmltimeline_p_p.h>
+#include <QDebug>
QT_BEGIN_NAMESPACE
@@ -94,9 +95,9 @@ class QActionAnimation : public QAbstractAnimation
{
Q_OBJECT
public:
- QActionAnimation(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped) {}
+ QActionAnimation(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped), running(false) {}
QActionAnimation(QAbstractAnimationAction *action, QObject *parent = 0)
- : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped) {}
+ : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped), running(false) {}
virtual int duration() const { return 0; }
void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p)
{
@@ -111,17 +112,27 @@ protected:
virtual void updateState(State newState, State /*oldState*/)
{
if (newState == Running) {
- if (animAction)
+ if (animAction) {
+ running = true;
animAction->doAction();
+ running = false;
+ if (state() == Stopped && policy == DeleteWhenStopped) {
+ delete animAction;
+ animAction = 0;
+ }
+ }
} else if (newState == Stopped && policy == DeleteWhenStopped) {
- delete animAction;
- animAction = 0;
+ if (!running) {
+ delete animAction;
+ animAction = 0;
+ }
}
}
private:
QAbstractAnimationAction *animAction;
DeletionPolicy policy;
+ bool running;
};
//animates QmlTimeLineValue (assumes start and end values will be reals or compatible)