summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-11-23 23:17:06 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-11-23 23:17:06 (GMT)
commit31540e4b5177073d71b98e296ad7d59faf63b383 (patch)
tree6eaf3e50b1a351171db3d47b8e39e0ee7478bc54 /src
parent7d93b0762aff8bcd9cb22f12ebc88beb242f2a97 (diff)
parent8d263b7cbf6b0bd17deeb8b56c90e0232057b832 (diff)
downloadQt-31540e4b5177073d71b98e296ad7d59faf63b383.zip
Qt-31540e4b5177073d71b98e296ad7d59faf63b383.tar.gz
Qt-31540e4b5177073d71b98e296ad7d59faf63b383.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspainteditem.cpp24
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspainteditem_p.h7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit.cpp76
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit_p.h7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput.cpp18
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp39
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h4
-rw-r--r--src/declarative/qml/parser/qmljsast_p.h2
-rw-r--r--src/declarative/qml/qmlengine.cpp27
-rw-r--r--src/declarative/qml/qmlengine_p.h1
-rw-r--r--src/declarative/qml/qmlsqldatabase.cpp148
-rw-r--r--src/declarative/util/qmllistmodel.cpp6
-rw-r--r--src/declarative/util/qmlnumberformatter.cpp92
-rw-r--r--src/declarative/util/qmlstate_p_p.h25
-rw-r--r--src/declarative/util/qmlview.cpp4
17 files changed, 197 insertions, 287 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
index 6f953bc..d7d725b 100644
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
@@ -394,7 +394,7 @@ void QmlGraphicsBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *
p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
const QmlGraphicsScaleGrid *border = d->getScaleGrid();
- QMargins margins(border->top(), border->left(), border->bottom(), border->right());
+ QMargins margins(border->left(), border->top(), border->right(), border->bottom());
QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode);
qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules);
if (d->smooth) {
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index fb6afb1..263aea5 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -2307,7 +2307,7 @@ void QmlGraphicsItem::setBaselineOffset(qreal offset)
Opacity is an \e inherited attribute. That is, the opacity is
also applied individually to child items. In almost all cases this
is what you want. If you can spot the issue in the following
- example, you might need to use an opacity filter (not yet available) instead.
+ example, you might need to use an \l Opacity effect instead.
\table
\row
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp
index b1b1210..2f467e7 100644
--- a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp
@@ -223,10 +223,14 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *
}
QRegion topaint = p->clipRegion();
- if (topaint.isEmpty())
- topaint = effectiveClip;
- else
+ if (topaint.isEmpty()) {
+ if (effectiveClip.isEmpty())
+ topaint = QRect(0,0,p->device()->width(),p->device()->height());
+ else
+ topaint = effectiveClip;
+ } else {
topaint &= effectiveClip;
+ }
topaint &= content;
QRegion uncached(content);
@@ -323,27 +327,26 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *
}
/*!
- \qmlproperty int PaintedItem::cacheSize
+ \qmlproperty int PaintedItem::pixelCacheSize
This property holds the maximum number of pixels of image cache to
allow. The default is 0.1 megapixels. The cache will not be larger
- than the (unscaled) size of the item.
+ than the (unscaled) size of the WebView.
*/
-
/*!
- \property QmlGraphicsPaintedItem::cacheSize
+ \property QmlGraphicsPaintedItem::pixelCacheSize
The maximum number of pixels of image cache to allow. The default
is 0.1 megapixels. The cache will not be larger than the (unscaled)
size of the QmlGraphicsPaintedItem.
*/
-int QmlGraphicsPaintedItem::cacheSize() const
+int QmlGraphicsPaintedItem::pixelCacheSize() const
{
Q_D(const QmlGraphicsPaintedItem);
return d->max_imagecache_size;
}
-void QmlGraphicsPaintedItem::setCacheSize(int pixels)
+void QmlGraphicsPaintedItem::setPixelCacheSize(int pixels)
{
Q_D(QmlGraphicsPaintedItem);
if (pixels < d->max_imagecache_size) {
@@ -369,6 +372,8 @@ void QmlGraphicsPaintedItem::setCacheSize(int pixels)
d->max_imagecache_size = pixels;
}
+
+
/*!
\property QmlGraphicsPaintedItem::fillColor
@@ -419,5 +424,4 @@ void QmlGraphicsPaintedItem::setSmoothCache(bool on)
}
-
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h
index 0805330..f6bb078 100644
--- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h
@@ -58,9 +58,10 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsPaintedItem : public QmlGraphicsItem
Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize)
Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
- Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
+ Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize)
Q_PROPERTY(bool smoothCache READ smoothCache WRITE setSmoothCache)
+
public:
QmlGraphicsPaintedItem(QmlGraphicsItem *parent=0);
~QmlGraphicsPaintedItem();
@@ -68,8 +69,8 @@ public:
QSize contentsSize() const;
void setContentsSize(const QSize &);
- int cacheSize() const;
- void setCacheSize(int pixels);
+ int pixelCacheSize() const;
+ void setPixelCacheSize(int pixels);
bool smoothCache() const;
void setSmoothCache(bool on);
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
index b691304..2588f7d 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
@@ -686,29 +686,6 @@ Qt::TextInteractionFlags QmlGraphicsTextEdit::textInteractionFlags() const
}
/*!
- Returns the cursor for the point at the given \a pos on the
- text edit.
-*/
-QTextCursor QmlGraphicsTextEdit::cursorForPosition(const QPoint &pos) const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->cursorForPosition(pos);
-}
-
-/*!
- Returns the rectangle where the given text \a cursor is rendered
- within the text edit.
-*/
-QRect QmlGraphicsTextEdit::cursorRect(const QTextCursor &cursor) const
-{
- Q_D(const QmlGraphicsTextEdit);
- if (cursor.isNull())
- return QRect();
-
- return d->control->cursorRect(cursor).toRect();
-}
-
-/*!
Returns the rectangle where the text cursor is rendered
within the text edit.
*/
@@ -720,35 +697,6 @@ QRect QmlGraphicsTextEdit::cursorRect() const
/*!
- Sets the text cursor for the text edit to the given \a cursor.
-*/
-void QmlGraphicsTextEdit::setTextCursor(const QTextCursor &cursor)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->setTextCursor(cursor);
-}
-
-/*!
- Returns the text cursor for the text edit.
-*/
-QTextCursor QmlGraphicsTextEdit::textCursor() const
-{
- Q_D(const QmlGraphicsTextEdit);
- return d->control->textCursor();
-}
-
-/*!
-Moves the cursor by performing the given \a operation.
-
-If \a mode is QTextCursor::KeepAnchor, the cursor selects the text it moves over. This is the same effect that the user achieves when they hold down the Shift key and move the cursor with the cursor keys.
-*/
-void QmlGraphicsTextEdit::moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode)
-{
- Q_D(QmlGraphicsTextEdit);
- d->control->moveCursor(operation, mode);
-}
-
-/*!
\overload
Handles the given \a event.
*/
@@ -769,28 +717,7 @@ Handles the given key \a event.
void QmlGraphicsTextEdit::keyPressEvent(QKeyEvent *event)
{
Q_D(QmlGraphicsTextEdit);
- //### this causes non-standard cursor behavior in some cases.
- // is it still needed?
- /*QTextCursor c = textCursor();
- QTextCursor::MoveOperation op = QTextCursor::NoMove;
- if (event == QKeySequence::MoveToNextChar) {
- op = QTextCursor::Right;
- } else if (event == QKeySequence::MoveToPreviousChar) {
- op = QTextCursor::Left;
- } else if (event == QKeySequence::MoveToNextWord) {
- op = QTextCursor::WordRight;
- } else if (event == QKeySequence::MoveToPreviousWord) {
- op = QTextCursor::WordLeft;
- } else if (event == QKeySequence::MoveToNextLine) {
- op = QTextCursor::Down;
- } else if (event == QKeySequence::MoveToPreviousLine) {
- op = QTextCursor::Up;
- }
-
- if (op != QTextCursor::NoMove && !c.movePosition(op))
- event->ignore();
- else*/
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QmlGraphicsPaintedItem::keyPressEvent(event);
@@ -942,6 +869,7 @@ void QmlGraphicsTextEditPrivate::init()
q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
control = new QTextControl(q);
+ control->setIgnoreUnusedNavigationEvents(true);
QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF)));
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h
index fa95373..1ddfa6b 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextedit_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstextedit_p.h
@@ -169,15 +169,8 @@ public:
void setTextInteractionFlags(Qt::TextInteractionFlags flags);
Qt::TextInteractionFlags textInteractionFlags() const;
- QTextCursor cursorForPosition(const QPoint &pos) const;
- QRect cursorRect(const QTextCursor &cursor) const;
QRect cursorRect() const;
- void setTextCursor(const QTextCursor &cursor);
- QTextCursor textCursor() const;
-
- void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
-
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
Q_SIGNALS:
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
index 56f59d8..b7d4e8c 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
@@ -212,8 +212,9 @@ QmlGraphicsTextInput::HAlignment QmlGraphicsTextInput::hAlign() const
void QmlGraphicsTextInput::setHAlign(HAlignment align)
{
Q_D(QmlGraphicsTextInput);
+ if(align == d->hAlign)
+ return;
d->hAlign = align;
- //TODO: implement
}
bool QmlGraphicsTextInput::isReadOnly() const
@@ -650,6 +651,21 @@ void QmlGraphicsTextInput::drawContents(QPainter *p, const QRect &r)
}
QPoint offset = QPoint(0,0);
+ if(d->hAlign != AlignLeft){
+ QFontMetrics fm = QFontMetrics(d->font);
+ //###Is this using bearing appropriately?
+ int minLB = qMax(0, -fm.minLeftBearing());
+ int minRB = qMax(0, -fm.minRightBearing());
+ int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
+ int hOffset = 0;
+ if(d->hAlign == AlignRight){
+ hOffset = width() - widthUsed;
+ }else if(d->hAlign == AlignHCenter){
+ hOffset = (width() - widthUsed) / 2;
+ }
+ hOffset -= minLB;
+ offset = QPoint(hOffset, 0);
+ }
QRect clipRect = r;
d->control->draw(p, offset, clipRect, flags);
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
index e165e59..aedf787 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -434,45 +434,6 @@ void QmlGraphicsWebView::paintPage(const QRect& r)
}
/*!
- \qmlproperty int WebView::pixelCacheSize
-
- This property holds the maximum number of pixels of image cache to
- allow. The default is 0.1 megapixels. The cache will not be larger
- than the (unscaled) size of the WebView.
-*/
-int QmlGraphicsWebView::pixelCacheSize() const
-{
- Q_D(const QmlGraphicsWebView);
- return d->max_imagecache_size;
-}
-
-void QmlGraphicsWebView::setPixelCacheSize(int pixels)
-{
- Q_D(QmlGraphicsWebView);
- if (pixels < d->max_imagecache_size) {
- int cachesize=0;
- for (int i=0; i<d->imagecache.count(); ++i) {
- QRect area = d->imagecache[i]->area;
- cachesize += area.width()*area.height();
- }
- while (d->imagecache.count() && cachesize > pixels) {
- int oldest=-1;
- int age=-1;
- for (int i=0; i<d->imagecache.count(); ++i) {
- int a = d->imagecache[i]->age;
- if (a > age) {
- oldest = i;
- age = a;
- }
- }
- cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
- d->imagecache.removeAt(oldest);
- }
- }
- d->max_imagecache_size = pixels;
-}
-
-/*!
\qmlproperty list<object> WebView::javaScriptWindowObjects
This property is a list of object that are available from within
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
index fa7d19d..17546c1 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
@@ -100,7 +100,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem
Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged)
- Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize)
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
@@ -166,9 +165,6 @@ public:
QWebSettings *settings() const;
QmlGraphicsWebSettings *settingsObject() const;
- int pixelCacheSize() const;
- void setPixelCacheSize(int pixels);
-
bool renderingEnabled() const;
void setRenderingEnabled(bool);
diff --git a/src/declarative/qml/parser/qmljsast_p.h b/src/declarative/qml/parser/qmljsast_p.h
index b5f7264..388bc12 100644
--- a/src/declarative/qml/parser/qmljsast_p.h
+++ b/src/declarative/qml/parser/qmljsast_p.h
@@ -2653,7 +2653,7 @@ public:
{ kind = K; }
virtual SourceLocation firstSourceLocation() const
- { return lbracketToken; }
+ { return qualifiedId->identifierToken; }
virtual SourceLocation lastSourceLocation() const
{ return rbracketToken; }
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index e292e5c..0a00092 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -145,6 +145,12 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1));
qtObject.setProperty(QLatin1String("md5"),scriptEngine.newFunction(md5, 1));
+ //firebug/webkit compat
+ QScriptValue consoleObject = scriptEngine.newObject();
+ consoleObject.setProperty(QLatin1String("log"),scriptEngine.newFunction(consoleLog, 1));
+ consoleObject.setProperty(QLatin1String("debug"),scriptEngine.newFunction(consoleLog, 1));
+ scriptEngine.globalObject().setProperty(QLatin1String("console"), consoleObject);
+
scriptEngine.globalObject().setProperty(QLatin1String("createQmlObject"),
scriptEngine.newFunction(QmlEnginePrivate::createQmlObject, 1));
scriptEngine.globalObject().setProperty(QLatin1String("createComponent"),
@@ -800,7 +806,7 @@ QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngin
return e->newVariant(QVariant(ret));
}
-QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *e)
+QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *)
{
QByteArray data;
@@ -812,6 +818,25 @@ QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *e)
return QScriptValue(QLatin1String(result.toHex()));
}
+QScriptValue QmlEnginePrivate::consoleLog(QScriptContext *ctxt, QScriptEngine *e)
+{
+ if(ctxt->argumentCount() < 1)
+ return e->newVariant(QVariant(false));
+
+ QByteArray msg;
+
+ for (int i=0; i<ctxt->argumentCount(); ++i) {
+ if (!msg.isEmpty()) msg += ' ';
+ msg += ctxt->argument(i).toString().toLocal8Bit();
+ // does not support firebug "%[a-z]" formatting, since firebug really
+ // does just ignore the format letter, which makes it pointless.
+ }
+
+ qDebug("%s",msg.data());
+
+ return e->newVariant(QVariant(true));
+}
+
QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e)
{
if(ctxt->argumentCount() < 2)
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 2f41651..c11a399 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -269,6 +269,7 @@ public:
static QScriptValue playSound(QScriptContext*, QScriptEngine*);
static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*);
static QScriptValue md5(QScriptContext*, QScriptEngine*);
+ static QScriptValue consoleLog(QScriptContext*, QScriptEngine*);
static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; }
static QmlEngine *getEngine(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p->q_func(); }
diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp
index 9e4c198..d11e3cb 100644
--- a/src/declarative/qml/qmlsqldatabase.cpp
+++ b/src/declarative/qml/qmlsqldatabase.cpp
@@ -63,8 +63,6 @@
Q_DECLARE_METATYPE(QSqlDatabase)
Q_DECLARE_METATYPE(QSqlQuery)
-class QmlSqlQueryScriptClassPropertyIterator;
-
class QmlSqlQueryScriptClass: public QScriptClass {
public:
QmlSqlQueryScriptClass(QScriptEngine *engine) : QScriptClass(engine)
@@ -75,22 +73,13 @@ public:
QueryFlags queryProperty(const QScriptValue &object,
const QScriptString &name,
- QueryFlags flags, uint *id)
+ QueryFlags flags, uint *)
{
if (flags & HandlesReadAccess) {
if (name == str_length) {
return HandlesReadAccess;
} else if (name == str_forwardOnly) {
return flags;
- } else {
- bool ok;
- qint32 pos = name.toString().toInt(&ok);
- if (pos < 0 || !ok)
- return 0;
- QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object.data());
- *id = pos;
- if (*id < (uint)query.size())
- return HandlesReadAccess;
}
}
if (flags & HandlesWriteAccess)
@@ -100,29 +89,23 @@ public:
}
QScriptValue property(const QScriptValue &object,
- const QScriptString &name, uint id)
+ const QScriptString &name, uint)
{
QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object.data());
if (name == str_length) {
int s = query.size();
if (s<0) {
// Inefficient.
- query.last();
- return query.at()+1;
+ if (query.last()) {
+ return query.at()+1;
+ } else {
+ return 0;
+ }
} else {
return s;
}
} else if (name == str_forwardOnly) {
return query.isForwardOnly();
- } else {
- if ((uint)query.at() == id || query.seek(id)) { // Qt 4.6 doesn't optimize seek(at())
- QSqlRecord r = query.record();
- QScriptValue row = engine()->newObject();
- for (int j=0; j<r.count(); ++j) {
- row.setProperty(r.fieldName(j), QScriptValue(engine(),r.value(j).toString()));
- }
- return row;
- }
}
return engine()->undefinedValue();
}
@@ -145,81 +128,15 @@ public:
return QScriptValue::Undeletable;
}
- QScriptClassPropertyIterator *newIterator(const QScriptValue &object);
-
private:
QScriptString str_length;
QScriptString str_forwardOnly;
};
-class QmlSqlQueryScriptClassPropertyIterator : public QScriptClassPropertyIterator
-{
-public:
- QmlSqlQueryScriptClassPropertyIterator(const QScriptValue &object)
- : QScriptClassPropertyIterator(object)
- {
- toFront();
- }
+// If the spec changes to allow iteration, check git history...
+// class QmlSqlQueryScriptClassPropertyIterator : public QScriptClassPropertyIterator
- ~QmlSqlQueryScriptClassPropertyIterator()
- {
- }
-
- bool hasNext() const
- {
- QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object().data());
- return query.at() == m_index || query.seek(m_index); // Qt 4.6 doesn't optimize seek(at())
- }
- void next()
- {
- m_last = m_index;
- ++m_index;
- }
-
- bool hasPrevious() const
- {
- return (m_index > 0);
- }
-
- void previous()
- {
- --m_index;
- m_last = m_index;
- }
-
- void toFront()
- {
- m_index = 0;
- m_last = -1;
- }
-
- void toBack()
- {
- QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object().data());
- m_index = query.size();
- m_last = -1;
- }
-
- QScriptString name() const
- {
- return object().engine()->toStringHandle(QString::number(m_last));
- }
-
- uint id() const
- {
- return m_last;
- }
-
-private:
- int m_index;
- int m_last;
-};
-
-QScriptClassPropertyIterator *QmlSqlQueryScriptClass::newIterator(const QScriptValue &object)
-{
- return new QmlSqlQueryScriptClassPropertyIterator(object);
-}
enum SqlException {
UNKNOWN_ERR,
@@ -323,11 +240,10 @@ static QScriptValue qmlsqldatabase_executeSql_readonly(QScriptContext *context,
{
QString sql = context->argument(0).toString();
if (sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) {
- qmlsqldatabase_executeSql(context,engine);
+ return qmlsqldatabase_executeSql(context,engine);
} else {
THROW_SQL(SYNTAX_ERR,QmlEngine::tr("Read-only Transaction"))
}
- return engine->undefinedValue();
}
static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScriptEngine *engine)
@@ -349,7 +265,9 @@ static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScri
return engine->undefinedValue();
}
+ bool ok = true;
if (callback.isFunction()) {
+ ok = false;
db.transaction();
callback.call(QScriptValue(), QScriptValueList() << tx);
if (engine->hasUncaughtException()) {
@@ -359,17 +277,21 @@ static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScri
db.rollback();
THROW_SQL(0,QmlEngine::tr("SQL transaction failed"));
} else {
- context->thisObject().setProperty(QLatin1String("version"), to_version, QScriptValue::ReadOnly);
- QSettings ini(databaseFile(db.connectionName(),engine)+QLatin1String(".ini"),QSettings::IniFormat);
- ini.setValue(QLatin1String("Version"), to_version);
+ ok = true;
}
}
}
+ if (ok) {
+ context->thisObject().setProperty(QLatin1String("version"), to_version, QScriptValue::ReadOnly);
+ QSettings ini(databaseFile(db.connectionName(),engine)+QLatin1String(".ini"),QSettings::IniFormat);
+ ini.setValue(QLatin1String("Version"), to_version);
+ }
+
return engine->undefinedValue();
}
-static QScriptValue qmlsqldatabase_transaction(QScriptContext *context, QScriptEngine *engine)
+static QScriptValue qmlsqldatabase_transaction_shared(QScriptContext *context, QScriptEngine *engine, bool readOnly)
{
QSqlDatabase db = qscriptvalue_cast<QSqlDatabase>(context->thisObject());
QScriptValue callback = context->argument(0);
@@ -377,7 +299,8 @@ static QScriptValue qmlsqldatabase_transaction(QScriptContext *context, QScriptE
THROW_SQL(UNKNOWN_ERR,QmlEngine::tr("transaction: missing callback"));
QScriptValue instance = engine->newObject();
- instance.setProperty(QLatin1String("executeSql"), engine->newFunction(qmlsqldatabase_executeSql,1));
+ instance.setProperty(QLatin1String("executeSql"),
+ engine->newFunction(readOnly ? qmlsqldatabase_executeSql_readonly : qmlsqldatabase_executeSql,1));
QScriptValue tx = engine->newVariant(instance,qVariantFromValue(db));
db.transaction();
@@ -391,26 +314,13 @@ static QScriptValue qmlsqldatabase_transaction(QScriptContext *context, QScriptE
return engine->undefinedValue();
}
+static QScriptValue qmlsqldatabase_transaction(QScriptContext *context, QScriptEngine *engine)
+{
+ return qmlsqldatabase_transaction_shared(context,engine,false);
+}
static QScriptValue qmlsqldatabase_read_transaction(QScriptContext *context, QScriptEngine *engine)
{
- QSqlDatabase db = qscriptvalue_cast<QSqlDatabase>(context->thisObject());
- QScriptValue callback = context->argument(0);
- if (!callback.isFunction())
- return engine->undefinedValue();
-
- QScriptValue instance = engine->newObject();
- instance.setProperty(QLatin1String("executeSql"), engine->newFunction(qmlsqldatabase_executeSql_readonly,1));
- QScriptValue tx = engine->newVariant(instance,qVariantFromValue(db));
-
- db.transaction();
- callback.call(QScriptValue(), QScriptValueList() << tx);
- if (engine->hasUncaughtException()) {
- db.rollback();
- } else {
- if (!db.commit())
- db.rollback();
- }
- return engine->undefinedValue();
+ return qmlsqldatabase_transaction_shared(context,engine,true);
}
/*
@@ -439,6 +349,9 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng
if (QSqlDatabase::connectionNames().contains(dbid)) {
database = QSqlDatabase::database(dbid);
+ version = ini.value(QLatin1String("Version")).toString();
+ if (version != dbversion && !dbversion.isEmpty() && !version.isEmpty())
+ THROW_SQL(VERSION_ERR,QmlEngine::tr("SQL: database version mismatch"));
} else {
created = !QFile::exists(basename+QLatin1String(".sqlite"));
database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid);
@@ -456,6 +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();
}
database.setDatabaseName(basename+QLatin1String(".sqlite"));
}
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index a3c5c59..5491fd7 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -732,11 +732,11 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL
for(int jj = 0; jj < props.count(); ++jj) {
const QmlCustomParserProperty &nodeProp = props.at(jj);
if (nodeProp.name() == "") {
- error(nodeProp, QLatin1String("Cannot use default property in ListModel"));
+ error(nodeProp, QmlListModel::tr("ListElement: cannot use default property"));
return false;
}
if (nodeProp.name() == "id") {
- error(nodeProp, QLatin1String("Cannot use reserved \"id\" property in ListModel"));
+ error(nodeProp, QmlListModel::tr("ListElement: cannot use reserved \"id\" property"));
return false;
}
@@ -792,7 +792,7 @@ QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &cus
for(int ii = 0; ii < customProps.count(); ++ii) {
const QmlCustomParserProperty &prop = customProps.at(ii);
if(prop.name() != "") { // isn't default property
- error(prop, QLatin1String("Cannot use default property"));
+ error(prop, QmlListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name())));
return QByteArray();
}
diff --git a/src/declarative/util/qmlnumberformatter.cpp b/src/declarative/util/qmlnumberformatter.cpp
index b09be5b..fce35d9 100644
--- a/src/declarative/util/qmlnumberformatter.cpp
+++ b/src/declarative/util/qmlnumberformatter.cpp
@@ -97,7 +97,7 @@ QmlNumberFormatter::~QmlNumberFormatter()
\qmlproperty string NumberFormatter::text
The number in the specified format.
- <br>
+
If no format is specified the text will be empty.
*/
@@ -123,38 +123,82 @@ qreal QmlNumberFormatter::number() const
\qmlproperty string NumberFormatter::format
The particular format the number will adhere to during the conversion to text.
- <br>
+
The format syntax follows a style similar to the Unicode Standard (UTS35).
The table below shows the characters, patterns that can be used in the format.
- <table border="0" align="center">
- <tr style="background-color: #D6E2E8"><th> Character </th><th> Meaning </th></tr>
- <tr><td> # </td><td> Any digit(s), zero shows as absent (for leading/trailing zeroes) </td></tr>
- <tr><td> 0 </td><td> Implicit digit. Zero will show in the case that the input number is too small.</td></tr>
- <tr><td> . </td><td> Decimal separator. Output decimal seperator will be dependant on system locale.</td></tr>
- <tr><td> , </td><td> Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize)</td></tr>
- <tr><td> other </td><td> Any other character will be taken as a string literal and placed directly into the output string </td></tr>
- </table>
+ \table
+ \header
+ \o Character
+ \o Meaning
+ \row
+ \o #
+ \o Any digit(s), zero shows as absent (for leading/trailing zeroes).
+ \row
+ \o 0
+ \o Implicit digit. Zero will show in the case that the input number is too small.
+ \row
+ \o .
+ \o Decimal separator. Output decimal seperator will be dependant on system locale.
+ \row
+ \o ,
+ \o Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize).
+ \row
+ \o other
+ \o Any other character will be taken as a string literal and placed directly into the output string.
+ \endtable
- Invalid formats will not guarantee a meaningful text output.<br>
+ Invalid formats will not guarantee a meaningful text output.
- \note <i>Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point </i>
+ \note Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point.
The following table illustrates the output text created by applying some examples of numeric formats to the formatter.
- <table border="0" align="center">
- <tr style="background-color: #D6E2E8"><th> Format </th><th> Number </th><th> Output </th></tr>
- <tr><td> ### </td><td> 123456 </td><td> 123456 </td></tr>
- <tr><td> 000 </td><td> 123456 </td><td> 123456 </td></tr>
- <tr><td> ###### </td><td> 1234 </td><td> 1234 </td></tr>
- <tr><td> 000000 </td><td> 1234 </td><td> 001234 </td></tr>
- <tr><td> ##,##0.## </td><td> 1234.456 </td><td> 1,234.46 (for US locale)<br> 1 234,46 (for FR locale)</td></tr>
- <tr><td> 000000,000.# </td><td> 123456 </td><td> 000,123,456 (for US locale)<br> 000 123 456 (for FR locale)</td></tr>
- <tr><td> 0.0### </td><td> 0.999997 </td><td> 1.0 </td></tr>
- <tr><td> (000) 000 - 000 </td><td> 12345678 </td><td> (012) 345 - 678 </td></tr>
- <tr><td> #A</td><td>12</td><td>12A</td></tr>
- </table>
+ \table
+ \header
+ \o Format
+ \o Number
+ \o Output
+ \row
+ \o ###
+ \o 123456
+ \o 123456
+ \row
+ \o 000
+ \o 123456
+ \o 123456
+ \row
+ \o ######
+ \o 1234
+ \o 1234
+ \row
+ \o 000000
+ \o 1234
+ \o 001234
+ \row
+ \o ##,##0.##
+ \o 1234.456
+ \o 1,234.46 (for US locale)
+ \codeline 1 234,46 (for FR locale)
+ \row
+ \o 000000,000.#
+ \o 123456
+ \o 000,123,456 (for US locale)
+ \codeline 000 123 456 (for FR locale)
+ \row
+ \o 0.0###
+ \o 0.999997
+ \o 1.0
+ \row
+ \o (000) 000 - 000
+ \o 12345678
+ \o (012) 345 - 678
+ \row
+ \o #A
+ \o 12
+ \o 12A
+ \endtable
*/
QString QmlNumberFormatter::format() const
diff --git a/src/declarative/util/qmlstate_p_p.h b/src/declarative/util/qmlstate_p_p.h
index 095a7d2..75eb3fd 100644
--- a/src/declarative/util/qmlstate_p_p.h
+++ b/src/declarative/util/qmlstate_p_p.h
@@ -102,7 +102,30 @@ public:
QString name;
QmlBinding *when;
- QmlConcreteList<QmlStateOperation *> operations;
+
+ class OperationList;
+ struct OperationGuard : public QGuard<QmlStateOperation>
+ {
+ OperationGuard(QObject *obj, OperationList *l) : list(l) { (QGuard<QObject>&)*this = obj; }
+ OperationList *list;
+ void objectDestroyed(QmlStateOperation *) {
+ // we assume priv will always be destroyed after objectDestroyed calls
+ list->removeOne(*this);
+ }
+ };
+
+ typedef QList<OperationGuard> GuardedOpList;
+ class OperationList : public GuardedOpList, public QmlList<QmlStateOperation*>
+ {
+ public:
+ virtual void append(QmlStateOperation* v) { GuardedOpList::append(OperationGuard(v, this)); }
+ virtual void insert(int i, QmlStateOperation* v) { GuardedOpList::insert(i, OperationGuard(v, this)); }
+ virtual void clear() { GuardedOpList::clear(); }
+ virtual QmlStateOperation* at(int i) const { return GuardedOpList::at(i); }
+ virtual void removeAt(int i) { GuardedOpList::removeAt(i); }
+ virtual int count() const { return GuardedOpList::count(); }
+ };
+ OperationList operations;
QmlTransitionManager transitionManager;
diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp
index 63115bb..62bcc07 100644
--- a/src/declarative/util/qmlview.cpp
+++ b/src/declarative/util/qmlview.cpp
@@ -167,7 +167,11 @@ public:
...
view->execute();
...
+ view->show();
\endcode
+
+ To receive errors related to loading and executing QML with QmlView,
+ you can connect to the errors() signal.
*/
/*!