summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-05-25 08:24:19 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-05-25 08:24:19 (GMT)
commit2814766c9e26159a1d45c50f1204f72d4f7bae91 (patch)
tree2219ed2e0b7fcd1013f438deda14d9ce571fea57 /src
parentffcbe13f0adc7ada8f04b74ed60660b033ee242f (diff)
parent55664a0ef4b88b67c9931c7d2f6853e5fa0a9716 (diff)
downloadQt-2814766c9e26159a1d45c50f1204f72d4f7bae91.zip
Qt-2814766c9e26159a1d45c50f1204f72d4f7bae91.tar.gz
Qt-2814766c9e26159a1d45c50f1204f72d4f7bae91.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/thread/qreadwritelock.cpp4
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp3
-rw-r--r--src/corelib/tools/qchar.cpp38
-rw-r--r--src/corelib/tools/qstring.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp14
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp45
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h4
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp8
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp17
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp20
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp20
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp317
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h4
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp21
-rw-r--r--src/declarative/qml/qdeclarativeinclude.cpp14
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp2
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp6
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp12
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp12
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp145
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp208
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp34
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp3
-rw-r--r--src/gui/image/qicon.cpp3
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp2
-rw-r--r--src/gui/styles/qcommonstyle.cpp3
-rw-r--r--src/gui/styles/qmacstyle_mac.mm2
-rw-r--r--src/gui/styles/qplastiquestyle.cpp2
-rw-r--r--src/gui/styles/qproxystyle.cpp2
-rw-r--r--src/gui/styles/qstyle_p.h1
-rw-r--r--src/gui/styles/qstylehelper.cpp3
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp2
-rw-r--r--src/gui/styles/qwindowsstyle.cpp8
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp7
-rw-r--r--src/gui/widgets/qmenu.cpp12
-rw-r--r--src/imports/folderlistmodel/plugin.cpp53
-rw-r--r--src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp14
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp8
43 files changed, 694 insertions, 419 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 26d9e7d..7093dee 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -2432,8 +2432,6 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
#if defined(Q_OS_SYMBIAN)
#ifdef SYMBIAN_BUILD_GCE
-//RWsPointerCursor is fixed, so don't use low performance sprites
-#define Q_SYMBIAN_FIXED_POINTER_CURSORS
#define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
#define Q_SYMBIAN_WINDOW_SIZE_CACHE
#define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp
index bd07a97..1a9eb0b 100644
--- a/src/corelib/thread/qreadwritelock.cpp
+++ b/src/corelib/thread/qreadwritelock.cpp
@@ -252,7 +252,7 @@ bool QReadWriteLock::tryLockForRead(int timeout)
while (d->accessCount < 0 || d->waitingWriters) {
++d->waitingReaders;
- bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : timeout);
+ bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout));
--d->waitingReaders;
if (!success)
return false;
@@ -374,7 +374,7 @@ bool QReadWriteLock::tryLockForWrite(int timeout)
while (d->accessCount != 0) {
++d->waitingWriters;
- bool success = d->writerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : timeout);
+ bool success = d->writerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout));
--d->waitingWriters;
if (!success)
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index 4a05dd8..b371b0e 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -63,7 +63,8 @@ static void report_error(int code, const char *where, const char *what)
-struct QWaitConditionPrivate {
+class QWaitConditionPrivate {
+public:
pthread_mutex_t mutex;
pthread_cond_t cond;
int waiters;
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index ddb1516..ed0af4e 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -1480,9 +1480,9 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion
if (!d || (canonical && tag != QChar::Canonical))
continue;
- s.replace(uc - utf16, ucs4 > 0x10000 ? 2 : 1, (const QChar *)d, length);
- // since the insert invalidates the pointers and we do decomposition recursive
int pos = uc - utf16;
+ s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast<const QChar *>(d), length);
+ // since the insert invalidates the pointers and we do decomposition recursive
utf16 = reinterpret_cast<unsigned short *>(s.data());
uc = utf16 + pos + length;
}
@@ -1567,46 +1567,52 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
int p2 = pos+1;
uint u1 = s.at(pos).unicode();
if (QChar(u1).isHighSurrogate()) {
- ushort low = s.at(pos+1).unicode();
+ ushort low = s.at(p2).unicode();
if (QChar(low).isLowSurrogate()) {
- p2++;
u1 = QChar::surrogateToUcs4(u1, low);
if (p2 >= l)
break;
+ ++p2;
}
}
uint u2 = s.at(p2).unicode();
- if (QChar(u2).isHighSurrogate() && p2 < l-1) {
+ if (QChar(u2).isHighSurrogate() && p2 < l) {
ushort low = s.at(p2+1).unicode();
if (QChar(low).isLowSurrogate()) {
- p2++;
u2 = QChar::surrogateToUcs4(u2, low);
+ ++p2;
}
}
- int c2 = QChar::combiningClass(u2);
- if (QChar::unicodeVersion(u2) > version)
- c2 = 0;
-
+ ushort c2 = 0;
+ {
+ const QUnicodeTables::Properties *p = qGetProp(u2);
+ if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
+ c2 = p->combiningClass;
+ }
if (c2 == 0) {
pos = p2+1;
continue;
}
- int c1 = QChar::combiningClass(u1);
- if (QChar::unicodeVersion(u1) > version)
- c1 = 0;
+
+ ushort c1 = 0;
+ {
+ const QUnicodeTables::Properties *p = qGetProp(u1);
+ if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
+ c1 = p->combiningClass;
+ }
if (c1 > c2) {
QChar *uc = s.data();
int p = pos;
// exchange characters
- if (u2 < 0x10000) {
+ if (!QChar::requiresSurrogates(u2)) {
uc[p++] = u2;
} else {
uc[p++] = QChar::highSurrogate(u2);
uc[p++] = QChar::lowSurrogate(u2);
}
- if (u1 < 0x10000) {
+ if (!QChar::requiresSurrogates(u1)) {
uc[p++] = u1;
} else {
uc[p++] = QChar::highSurrogate(u1);
@@ -1618,7 +1624,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
--pos;
} else {
++pos;
- if (u1 > 0x10000)
+ if (QChar::requiresSurrogates(u1))
++pos;
}
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 612c492..6acbcec 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -939,11 +939,11 @@ int QString::toWCharArray(wchar_t *array) const
const unsigned short *uc = utf16();
for (int i = 0; i < length(); ++i) {
uint u = uc[i];
- if (u >= 0xd800 && u < 0xdc00 && i < length()-1) {
+ if (QChar::isHighSurrogate(u) && i + 1 < length()) {
ushort low = uc[i+1];
- if (low >= 0xdc00 && low < 0xe000) {
+ if (QChar::isLowSurrogate(low)) {
+ u = QChar::surrogateToUcs4(u, low);
++i;
- u = (u - 0xd800)*0x400 + (low - 0xdc00) + 0x10000;
}
}
*a = wchar_t(u);
@@ -6195,8 +6195,10 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::
if (simple)
return;
- QString &s = *data;
- if (version != UNICODE_DATA_VERSION) {
+ if (version == QChar::Unicode_Unassigned) {
+ version = UNICODE_DATA_VERSION;
+ } else if (version != UNICODE_DATA_VERSION) {
+ QString &s = *data;
for (int i = 0; i < NumNormalizationCorrections; ++i) {
const NormalizationCorrection &n = uc_normalization_corrections[i];
if (n.version > version) {
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
index c81c2d2..32a6321 100644
--- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
@@ -45,7 +45,7 @@
#ifndef QT_NO_MOVIE
#include <qdeclarativeinfo.h>
-#include <qdeclarativeengine.h>
+#include <private/qdeclarativeengine_p.h>
#include <QMovie>
#include <QNetworkRequest>
@@ -180,14 +180,6 @@ int QDeclarativeAnimatedImage::frameCount() const
return d->_movie->frameCount();
}
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
void QDeclarativeAnimatedImage::setSource(const QUrl &url)
{
Q_D(QDeclarativeAnimatedImage);
@@ -209,7 +201,7 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url)
d->status = Null;
} else {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
//### should be unified with movieRequestFinished
d->_movie = new QMovie(lf);
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
index 229e15b..1f1e453 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -42,8 +42,8 @@
#include "private/qdeclarativeborderimage_p.h"
#include "private/qdeclarativeborderimage_p_p.h"
-#include <qdeclarativeengine.h>
#include <qdeclarativeinfo.h>
+#include <private/qdeclarativeengine_p.h>
#include <QNetworkRequest>
#include <QNetworkReply>
@@ -152,16 +152,6 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage()
The URL may be absolute, or relative to the URL of the component.
*/
-
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
-
void QDeclarativeBorderImage::setSource(const QUrl &url)
{
Q_D(QDeclarativeBorderImage);
@@ -210,7 +200,7 @@ void QDeclarativeBorderImage::load()
d->status = Loading;
if (d->url.path().endsWith(QLatin1String("sci"))) {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(d->url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
QFile file(lf);
file.open(QIODevice::ReadOnly);
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 9547884..2841ac3 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -2681,7 +2681,13 @@ bool QDeclarativeItem::sceneEvent(QEvent *event)
}
}
-/*! \internal */
+/*!
+ \reimp
+
+ Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is \e not called
+ during initial widget polishing. Items wishing to optimize start-up construction
+ should instead consider using componentComplete().
+*/
QVariant QDeclarativeItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 40d37a2..7b00d2f 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -523,7 +523,7 @@ void QDeclarativeTextEdit::setCursorVisible(bool on)
QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut);
if (!on && !d->persistentSelection)
d->control->setCursorIsFocusIndicator(true);
- d->control->processEvent(&focusEvent, QPointF(0, 0));
+ d->control->processEvent(&focusEvent, QPointF(0, -d->yoff));
emit cursorVisibleChanged(d->cursorVisible);
}
@@ -860,7 +860,7 @@ Qt::TextInteractionFlags QDeclarativeTextEdit::textInteractionFlags() const
QRect QDeclarativeTextEdit::cursorRect() const
{
Q_D(const QDeclarativeTextEdit);
- return d->control->cursorRect().toRect();
+ return d->control->cursorRect().toRect().translated(0,-d->yoff);
}
@@ -872,7 +872,7 @@ bool QDeclarativeTextEdit::event(QEvent *event)
{
Q_D(QDeclarativeTextEdit);
if (event->type() == QEvent::ShortcutOverride) {
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, -d->yoff));
return event->isAccepted();
}
return QDeclarativePaintedItem::event(event);
@@ -887,7 +887,7 @@ void QDeclarativeTextEdit::keyPressEvent(QKeyEvent *event)
Q_D(QDeclarativeTextEdit);
keyPressPreHandler(event);
if (!event->isAccepted())
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
QDeclarativePaintedItem::keyPressEvent(event);
}
@@ -901,7 +901,7 @@ void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event)
Q_D(QDeclarativeTextEdit);
keyReleasePreHandler(event);
if (!event->isAccepted())
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
QDeclarativePaintedItem::keyReleaseEvent(event);
}
@@ -942,7 +942,7 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!hadFocus && hasFocus())
d->clickCausedFocus = true;
if (event->type() != QEvent::GraphicsSceneMouseDoubleClick || d->selectByMouse)
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
QDeclarativePaintedItem::mousePressEvent(event);
}
@@ -959,7 +959,7 @@ void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
d->clickCausedFocus = false;
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
QDeclarativePaintedItem::mouseReleaseEvent(event);
}
@@ -972,7 +972,7 @@ void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event
{
Q_D(QDeclarativeTextEdit);
if (d->selectByMouse) {
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
QDeclarativePaintedItem::mouseDoubleClickEvent(event);
} else {
@@ -988,7 +988,7 @@ void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
if (d->selectByMouse) {
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, -d->yoff));
if (!event->isAccepted())
QDeclarativePaintedItem::mouseMoveEvent(event);
event->setAccepted(true);
@@ -1004,7 +1004,7 @@ Handles the given input method \a event.
void QDeclarativeTextEdit::inputMethodEvent(QInputMethodEvent *event)
{
Q_D(QDeclarativeTextEdit);
- d->control->processEvent(event, QPointF(0, 0));
+ d->control->processEvent(event, QPointF(0, -d->yoff));
}
/*!
@@ -1026,13 +1026,20 @@ void QDeclarativeTextEdit::drawContents(QPainter *painter, const QRect &bounds)
Q_D(QDeclarativeTextEdit);
painter->setRenderHint(QPainter::TextAntialiasing, true);
+ painter->translate(0,d->yoff);
- d->control->drawContents(painter, bounds);
+ d->control->drawContents(painter, bounds.translated(0,-d->yoff));
+
+ painter->translate(0,-d->yoff);
}
-void QDeclarativeTextEdit::updateImgCache(const QRectF &r)
+void QDeclarativeTextEdit::updateImgCache(const QRectF &rf)
{
- dirtyCache(r.toRect());
+ Q_D(const QDeclarativeTextEdit);
+ QRect r = rf.toRect();
+ if (r != QRect(0,0,INT_MAX,INT_MAX)) // Don't translate "everything"
+ r = r.translated(0,d->yoff);
+ dirtyCache(r);
emit update();
}
@@ -1141,18 +1148,20 @@ void QDeclarativeTextEdit::updateSize()
d->document->setTextWidth(width());
dy -= (int)d->document->size().height();
- int yoff = 0;
if (heightValid()) {
if (d->vAlign == AlignBottom)
- yoff = dy;
+ d->yoff = dy;
else if (d->vAlign == AlignVCenter)
- yoff = dy/2;
+ d->yoff = dy/2;
+ } else {
+ d->yoff = 0;
}
- setBaselineOffset(fm.ascent() + yoff + d->textMargin);
+ setBaselineOffset(fm.ascent() + d->yoff + d->textMargin);
//### need to comfirm cost of always setting these
int newWidth = qCeil(d->document->idealWidth());
- d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well?
+ if (!widthValid())
+ d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug)
int cursorWidth = 1;
if(d->cursor)
cursorWidth = d->cursor->width();
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index 885620d..d96796c 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -73,7 +73,8 @@ public:
persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0),
wrapMode(QDeclarativeTextEdit::NoWrap),
- selectByMouse(false)
+ selectByMouse(false),
+ yoff(0)
{
}
@@ -112,6 +113,7 @@ public:
QTextControl *control;
QDeclarativeTextEdit::WrapMode wrapMode;
bool selectByMouse;
+ int yoff;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 8230941..882e981 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -191,7 +191,9 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
data->error.setUrl(url);
data->error.setLine(line);
data->error.setColumn(-1);
- data->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(data->property.propertyType())));
+ data->error.setDescription(QLatin1String("Unable to assign [undefined] to ")
+ + QLatin1String(QMetaType::typeName(data->property.propertyType()))
+ + QLatin1String(" ") + data->property.name());
} else if (!scriptValue.isRegExp() && scriptValue.isFunction()) {
@@ -353,8 +355,6 @@ void QDeclarativeAbstractBinding::removeFromObject()
if (m_prevBinding) {
int index = propertyIndex();
- Q_ASSERT(m_object);
-
*m_prevBinding = m_nextBinding;
if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding;
m_prevBinding = 0;
@@ -363,7 +363,7 @@ void QDeclarativeAbstractBinding::removeFromObject()
if (index & 0xFF000000) {
// Value type - we don't remove the proxy from the object. It will sit their happily
// doing nothing for ever more.
- } else {
+ } else if (m_object) {
QDeclarativeData *data = QDeclarativeData::get(m_object, false);
if (data) data->clearBindingBit(index);
}
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index b5bf972..d27aced 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -1089,6 +1089,23 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
fetch.line = prop->location.start.line;
output->bytecode << fetch;
+ if (!prop->value->metadata.isEmpty()) {
+ QDeclarativeInstruction meta;
+ meta.type = QDeclarativeInstruction::StoreMetaObject;
+ meta.line = 0;
+ meta.storeMeta.data = output->indexForByteArray(prop->value->metadata);
+ meta.storeMeta.aliasData = output->indexForByteArray(prop->value->synthdata);
+ meta.storeMeta.propertyCache = output->propertyCaches.count();
+ // ### Surely the creation of this property cache could be more efficient
+ QDeclarativePropertyCache *propertyCache =
+ enginePrivate->cache(prop->value->metaObject()->superClass())->copy();
+ propertyCache->append(engine, prop->value->metaObject(), QDeclarativePropertyCache::Data::NoFlags,
+ QDeclarativePropertyCache::Data::IsVMEFunction);
+
+ output->propertyCaches << propertyCache;
+ output->bytecode << meta;
+ }
+
genObjectBody(prop->value);
QDeclarativeInstruction pop;
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 3f11425..7aa17e8 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -549,15 +549,19 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
Returns an object instance from this component, or null if object creation fails.
The object will be created in the same context as the one in which the component
- was created.
+ was created. This function will always return null when called on components
+ which were not created in QML.
Note that if the returned object is to be displayed, its \c parent must be set to
- an existing item in a scene, or else the object will not be visible.
+ an existing item in a scene, or else the object will not be visible. The parent
+ argument is required to help you avoid this, you must explicitly pass in null if
+ you wish to create an object without setting a parent.
*/
/*!
\internal
- A version of create which returns a scriptObject, for use in script
+ A version of create which returns a scriptObject, for use in script.
+ This function will only work on components created in QML.
Sets graphics object parent because forgetting to do this is a frequent
and serious problem.
@@ -576,10 +580,12 @@ QScriptValue QDeclarativeComponent::createObject(QObject* parent)
bool needParent = (gobj != 0);
if(parent){
ret->setParent(parent);
- QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent);
- if(gparent){
- gobj->setParentItem(gparent);
- needParent = false;
+ if (gobj) {
+ QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parent);
+ if(gparent){
+ gobj->setParentItem(gparent);
+ needParent = false;
+ }
}
}
if(needParent)
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index e4405f7..26b2a9b 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -334,23 +334,11 @@ void QDeclarativeCompositeTypeManager::resourceReplyFinished()
reply->deleteLater();
}
-// XXX this beyonds in QUrl::toLocalFile()
-// WARNING, there is a copy of this function in qdeclarativeengine.cpp
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
- if (url.authority().isEmpty())
- return QLatin1Char(':') + url.path();
- return QString();
- }
- return url.toLocalFile();
-}
-
void QDeclarativeCompositeTypeManager::loadResource(QDeclarativeCompositeTypeResource *resource)
{
QUrl url(resource->url);
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
QFile file(lf);
@@ -378,7 +366,7 @@ void QDeclarativeCompositeTypeManager::loadSource(QDeclarativeCompositeTypeData
{
QUrl url(unit->imports.baseUrl());
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
QFile file(lf);
@@ -716,7 +704,7 @@ void QDeclarativeCompositeTypeManager::compile(QDeclarativeCompositeTypeData *un
foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
if (imp.type == QDeclarativeScriptParser::Import::File && imp.qualifier.isEmpty()) {
QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir")));
- if (toLocalFileOrQrc(importUrl).isEmpty()) {
+ if (QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty()) {
// Import requires remote qmldir
resourceList.prepend(importUrl);
}
@@ -726,7 +714,7 @@ void QDeclarativeCompositeTypeManager::compile(QDeclarativeCompositeTypeData *un
QUrl importUrl;
if (!unit->imports.baseUrl().scheme().isEmpty())
importUrl = unit->imports.baseUrl().resolved(QUrl(QLatin1String("qmldir")));
- if (!importUrl.scheme().isEmpty() && toLocalFileOrQrc(importUrl).isEmpty())
+ if (!importUrl.scheme().isEmpty() && QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl).isEmpty())
resourceList.prepend(importUrl);
for (int ii = 0; ii < resourceList.count(); ++ii) {
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 0a75532..a7384a9 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -151,6 +151,61 @@ void QDeclarativeEnginePrivate::defineModule()
qmlRegisterType<QDeclarativeBinding>();
}
+/*!
+\qmlclass Qt QDeclarativeEnginePrivate
+\brief The QML Global Qt Object
+
+The Qt object provides useful enums and functions from Qt, for use in all QML
+files. Note that you do note create instances of this type, but instead use
+the members of the global "Qt" object.
+
+\section1 Enums
+
+The Qt object contains all enums in the Qt namespace. For example, you can
+access the AlignLeft member of the Qt::AlignmentFlag enum with \c Qt.AlignLeft.
+
+For a full list of enums, see the \l{Qt Namespace} documentation.
+
+\section1 Types
+The Qt object also contains helper functions for creating objects of specific
+data types. This is primarily useful when setting the properties of an item
+when the property has one of the following types:
+
+\list
+\o Color
+\o Rect
+\o Point
+\o Size
+\o Vector3D
+\endlist
+
+There are also string based constructors for these types, see \l{qdeclarativebasictypes.html}{Qml Types}.
+
+\section1 Date/Time Formatters
+
+The Qt object contains several functions for formatting dates and times.
+
+\list
+ \o \l{Qt::formatDateTime}{string Qt.formatDateTime(datetime date, variant format)
+ \o \l{Qt::formatDate}{string Qt.formatDate(datetime date, variant format)
+ \o \l{Qt::formatTime}{string Qt.formatTime(datetime date, variant format)
+\endlist
+
+The format specification is described at \l{Qt::formatDateTime}{Qt.formatDateTime}.
+
+
+\section1 Dynamic Object Creation
+The following functions on the global object allow you to dynamically create QML
+items from files or strings. See \l{Dynamic Object Management} for an overview
+of their use.
+
+\list
+ \o \l{Qt::createComponent}{object Qt.createComponent(url)}
+ \o \l{Qt::createQmlObject}{object Qt.createQmlObject(string qml, object parent, string filepath)}
+\endlist
+*/
+
+
QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
: captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false),
outputWarningsToStdErr(true), contextClass(0), sharedContext(0), sharedScope(0),
@@ -169,6 +224,11 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
globalClass = new QDeclarativeGlobalScriptClass(&scriptEngine);
}
+/*!
+\qmlmethod url Qt::resolvedUrl(url)
+This function returns \c url resolved relative to the URL of the
+caller.
+*/
QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
{
if (p) {
@@ -216,7 +276,7 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr
qtObject.setProperty(QLatin1String("rect"), newFunction(QDeclarativeEnginePrivate::rect, 4));
qtObject.setProperty(QLatin1String("point"), newFunction(QDeclarativeEnginePrivate::point, 2));
qtObject.setProperty(QLatin1String("size"), newFunction(QDeclarativeEnginePrivate::size, 2));
- qtObject.setProperty(QLatin1String("vector3d"), newFunction(QDeclarativeEnginePrivate::vector, 3));
+ qtObject.setProperty(QLatin1String("vector3d"), newFunction(QDeclarativeEnginePrivate::vector3d, 3));
if (mainthread) {
//color helpers
@@ -961,6 +1021,47 @@ QDeclarativeContextData *QDeclarativeEnginePrivate::getContext(QScriptContext *c
return contextClass->contextFromValue(scopeNode);
}
+
+QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
+{
+ if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
+ if (url.authority().isEmpty())
+ return QLatin1Char(':') + url.path();
+ return QString();
+ }
+ return url.toLocalFile();
+}
+
+/*!
+\qmlmethod object Qt::createComponent(url)
+
+This function takes the URL of a QML file as its only argument. It returns
+a component object which can be used to create and load that QML file.
+
+Here is an example. Remember that QML files that might be loaded
+over the network cannot be expected to be ready immediately.
+
+\snippet doc/src/snippets/declarative/componentCreation.js 0
+\codeline
+\snippet doc/src/snippets/declarative/componentCreation.js 1
+
+If you are certain the files will be local, you could simplify to:
+
+\snippet doc/src/snippets/declarative/componentCreation.js 2
+
+The methods and properties of the \l {Component} element are defined in its own
+page, but when using it dynamically only two methods are usually used.
+ \l {Component::createObject()}{Component.createObject()} returns the created object or \c null if there is an error.
+If there is an error, \l {Component::errorString()}{Component.errorString()} describes
+the error that occurred. Note that createObject() takes exactly one argument, which is set
+to the parent of the created object. Graphical objects without a parent will not appear
+on the scene, but if you do not wish to parent the item at this point you can safely pass
+in null.
+
+If you want to just create an arbitrary string of QML, instead of
+loading a QML file, consider the \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()} function.
+*/
+
QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QScriptEngine *engine)
{
QDeclarativeEnginePrivate *activeEnginePriv =
@@ -984,6 +1085,34 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS
}
}
+/*!
+\qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath)
+
+Creates a new object from the specified string of QML. It requires a
+second argument, which is the id of an existing QML object to use as
+the new object's parent. If a third argument is provided, this is used
+for error reporting as the filepath that the QML came from.
+
+Example (where \c targetItem is the id of an existing QML item):
+
+\snippet doc/src/snippets/declarative/createQmlObject.qml 0
+
+This function is intended for use inside QML only. It is intended to behave
+similarly to eval, but for creating QML elements.
+
+Returns the created object, \c or null if there is an error. In the case of an
+error, a QtScript Error object is thrown. This object has the additional property,
+qmlErrors, which is an array of all the errors encountered when trying to execute the
+QML. Each object in the array has the members \c lineNumber, \c columnNumber, \c fileName and \c message.
+
+Note that this function returns immediately, and therefore may not work if
+the QML loads new components. If you are trying to load a new component,
+for example from a QML file, consider the \l{Qt.createComponent(url file)}{Qt.createComponent()} function
+instead. 'New components' refers to external QML files that have not yet
+been loaded, and so it is safe to use \c Qt.createQmlObject() to load built-in
+components.
+*/
+
QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
{
QDeclarativeEnginePrivate *activeEnginePriv =
@@ -1074,6 +1203,10 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
return activeEnginePriv->objectClass->newQObject(obj, QMetaType::QObjectStar);
}
+/*!
+\qmlmethod bool Qt::isQtObject(object)
+Returns true if \c object is a valid reference to a Qt or QML object, otherwise false.
+*/
QScriptValue QDeclarativeEnginePrivate::isQtObject(QScriptContext *ctxt, QScriptEngine *engine)
{
if (ctxt->argumentCount() == 0)
@@ -1082,7 +1215,11 @@ QScriptValue QDeclarativeEnginePrivate::isQtObject(QScriptContext *ctxt, QScript
return QScriptValue(engine, 0 != ctxt->argument(0).toQObject());
}
-QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine)
+/*!
+\qmlmethod Qt::vector3d(real x, real y, real z)
+This function returns a Vector3D with the specified \c x, \c y and \c z.
+*/
+QScriptValue QDeclarativeEnginePrivate::vector3d(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 3)
return ctxt->throwError(QLatin1String("Qt.vector(): Invalid arguments"));
@@ -1092,6 +1229,10 @@ QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngi
return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QVector3D(x, y, z)));
}
+/*!
+\qmlmethod string Qt::formatDate(datetime date, variant format)
+This function returns the string representation of \c date, formatted according to \c format.
+*/
QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine)
{
int argCount = ctxt->argumentCount();
@@ -1113,6 +1254,12 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE
return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
}
+/*!
+\qmlmethod string Qt::formatTime(datetime time, variant format)
+This function returns the string representation of \c time, formatted according to \c format.
+
+See Qt::formatDateTime for how to define \c format.
+*/
QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptEngine*engine)
{
int argCount = ctxt->argumentCount();
@@ -1134,6 +1281,75 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE
return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
}
+/*!
+\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format)
+This function returns the string representation of \c dateTime, formatted according to \c format.
+
+\c format for the date/time formatting functions is be specified as follows.
+
+ These expressions may be used for the date:
+
+ \table
+ \header \i Expression \i Output
+ \row \i d \i the day as number without a leading zero (1 to 31)
+ \row \i dd \i the day as number with a leading zero (01 to 31)
+ \row \i ddd
+ \i the abbreviated localized day name (e.g. 'Mon' to 'Sun').
+ Uses QDate::shortDayName().
+ \row \i dddd
+ \i the long localized day name (e.g. 'Monday' to 'Qt::Sunday').
+ Uses QDate::longDayName().
+ \row \i M \i the month as number without a leading zero (1-12)
+ \row \i MM \i the month as number with a leading zero (01-12)
+ \row \i MMM
+ \i the abbreviated localized month name (e.g. 'Jan' to 'Dec').
+ Uses QDate::shortMonthName().
+ \row \i MMMM
+ \i the long localized month name (e.g. 'January' to 'December').
+ Uses QDate::longMonthName().
+ \row \i yy \i the year as two digit number (00-99)
+ \row \i yyyy \i the year as four digit number
+ \endtable
+
+ These expressions may be used for the time:
+
+ \table
+ \header \i Expression \i Output
+ \row \i h
+ \i the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
+ \row \i hh
+ \i the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
+ \row \i m \i the minute without a leading zero (0 to 59)
+ \row \i mm \i the minute with a leading zero (00 to 59)
+ \row \i s \i the second without a leading zero (0 to 59)
+ \row \i ss \i the second with a leading zero (00 to 59)
+ \row \i z \i the milliseconds without leading zeroes (0 to 999)
+ \row \i zzz \i the milliseconds with leading zeroes (000 to 999)
+ \row \i AP
+ \i use AM/PM display. \e AP will be replaced by either "AM" or "PM".
+ \row \i ap
+ \i use am/pm display. \e ap will be replaced by either "am" or "pm".
+ \endtable
+
+ All other input characters will be ignored. Any sequence of characters that
+ are enclosed in singlequotes will be treated as text and not be used as an
+ expression. Two consecutive singlequotes ("''") are replaced by a singlequote
+ in the output.
+
+ Example format strings (assumed that the date and time is 21 May 2001
+ 14:13:09):
+
+ \table
+ \header \i Format \i Result
+ \row \i dd.MM.yyyy \i 21.05.2001
+ \row \i ddd MMMM d yy \i Tue May 21 01
+ \row \i hh:mm:ss.zzz \i 14:13:09.042
+ \row \i h:m:s ap \i 2:13:9 pm
+ \endtable
+
+If no format is specified the locale's short format is used. Alternatively, you can specify
+\c Qt.DefaultLocaleLongDate to get the locale's long format.
+*/
QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScriptEngine*engine)
{
int argCount = ctxt->argumentCount();
@@ -1155,6 +1371,12 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
}
+/*!
+\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
+
+This function returns a Color with the specified \c red, \c green, \c blue and \c alpha components.
+All components should be in the range 0-1 inclusive.
+*/
QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine)
{
int argCount = ctxt->argumentCount();
@@ -1177,6 +1399,12 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine
return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromRgbF(r, g, b, a)));
}
+/*!
+\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha)
+
+This function returns a Color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
+All components should be in the range 0-1 inclusive.
+*/
QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine *engine)
{
int argCount = ctxt->argumentCount();
@@ -1199,6 +1427,11 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine
return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromHslF(h, s, l, a)));
}
+/*!
+\qmlmethod rect Qt::rect(int x, int y, int width, int height)
+
+This function returns a Rect with the top-left corner at \c x, \c y and the specified \c width and \c height.
+*/
QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 4)
@@ -1215,6 +1448,10 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine
return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QRectF(x, y, w, h)));
}
+/*!
+\qmlmethod point Qt::point(int x, int y)
+This function returns a Point with the specified \c x and \c y coordinates.
+*/
QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 2)
@@ -1224,6 +1461,10 @@ QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngin
return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QPointF(x, y)));
}
+/*!
+\qmlmethod Qt::size(int width, int height)
+This function returns as Size with the specified \c width and \c height.
+*/
QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 2)
@@ -1233,6 +1474,20 @@ QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine
return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QSizeF(w, h)));
}
+/*!
+\qmlmethod color Qt::lighter(color baseColor, real factor)
+This function returns a color lighter than \c baseColor by the \c factor provided.
+
+If the factor is greater than 1.0, this functions returns a lighter color.
+Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0,
+the return color is darker, but we recommend using the Qt.darker() function for this purpose.
+If the factor is 0 or negative, the return value is unspecified.
+
+The function converts the current RGB color to HSV, multiplies the value (V) component
+by factor and converts the color back to RGB.
+
+If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5).
+*/
QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 1 && ctxt->argumentCount() != 2)
@@ -1255,6 +1510,21 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng
return qScriptValueFromValue(engine, qVariantFromValue(color));
}
+/*!
+\qmlmethod color Qt::darker(color baseColor, real factor)
+This function returns a color darker than \c baseColor by the \c factor provided.
+
+If the factor is greater than 1.0, this function returns a darker color.
+Setting factor to 3.0 returns a color that has one-third the brightness.
+If the factor is less than 1.0, the return color is lighter, but we recommend using
+the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return
+value is unspecified.
+
+The function converts the current RGB color to HSV, divides the value (V) component
+by factor and converts the color back to RGB.
+
+If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0).
+*/
QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 1 && ctxt->argumentCount() != 2)
@@ -1277,6 +1547,10 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi
return qScriptValueFromValue(engine, qVariantFromValue(color));
}
+/*!
+\qmlmethod bool Qt::openUrlExternally(url target)
+This function attempts to open the specified \c target url in an external application, based on the user's desktop preferences. It will return true if it succeeds, and false otherwise.
+*/
QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
{
if(ctxt->argumentCount() < 1)
@@ -1288,6 +1562,11 @@ QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QSc
return QScriptValue(e, ret);
}
+/*!
+\qmlmethod list<string> Qt::fontFamilies()
+This function returns a list of the font families available to the application.
+*/
+
QScriptValue QDeclarativeEnginePrivate::fontFamilies(QScriptContext *ctxt, QScriptEngine *e)
{
if(ctxt->argumentCount() != 0)
@@ -1298,6 +1577,10 @@ QScriptValue QDeclarativeEnginePrivate::fontFamilies(QScriptContext *ctxt, QScri
return p->scriptValueFromVariant(database.families());
}
+/*!
+\qmlmethod string Qt::md5(data)
+This function returns a hex string of the md5 hash of \c data.
+*/
QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *)
{
if (ctxt->argumentCount() != 1)
@@ -1309,6 +1592,10 @@ QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine
return QScriptValue(QLatin1String(result.toHex()));
}
+/*!
+\qmlmethod string Qt::btoa(data)
+Binary to ASCII - this function returns a base64 encoding of \c data.
+*/
QScriptValue QDeclarativeEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine *)
{
if (ctxt->argumentCount() != 1)
@@ -1319,6 +1606,11 @@ QScriptValue QDeclarativeEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine
return QScriptValue(QLatin1String(data.toBase64()));
}
+/*!
+\qmlmethod string Qt::atob(data)
+ASCII to binary - this function returns a base64 decoding of \c data.
+*/
+
QScriptValue QDeclarativeEnginePrivate::atob(QScriptContext *ctxt, QScriptEngine *)
{
if (ctxt->argumentCount() != 1)
@@ -1413,6 +1705,13 @@ void QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate *engine, const
dumpwarning(error);
}
+/*!
+\qmlmethod Qt::quit()
+This function causes the QDeclarativeEngine::quit() signal to be emitted.
+Within the \l {Qt Declarative UI Runtime}{qml} application this causes the
+launcher application to exit.
+*/
+
QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptEngine *e)
{
QDeclarativeEnginePrivate *qe = get (e);
@@ -1420,6 +1719,20 @@ QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptE
return QScriptValue();
}
+/*!
+\qmlmethod color Qt::tint(color baseColor, color tintColor)
+ This function allows tinting one color with another.
+
+ The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red tint by having the tint color be pure red which is only 1/16th opaque.
+
+ \qml
+ Rectangle { x: 0; width: 80; height: 80; color: "lightsteelblue" }
+ Rectangle { x: 100; width: 80; height: 80; color: Qt.tint("lightsteelblue", "#10FF0000") }
+ \endqml
+ \image declarative-rect_tint.png
+
+ Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color.
+*/
QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 2)
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 0b1c17d..804476c 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -283,7 +283,7 @@ public:
static QScriptValue createComponent(QScriptContext*, QScriptEngine*);
static QScriptValue createQmlObject(QScriptContext*, QScriptEngine*);
static QScriptValue isQtObject(QScriptContext*, QScriptEngine*);
- static QScriptValue vector(QScriptContext*, QScriptEngine*);
+ static QScriptValue vector3d(QScriptContext*, QScriptEngine*);
static QScriptValue rgba(QScriptContext*, QScriptEngine*);
static QScriptValue hsla(QScriptContext*, QScriptEngine*);
static QScriptValue point(QScriptContext*, QScriptEngine*);
@@ -315,6 +315,8 @@ public:
static QDeclarativeEngine *get(QDeclarativeEnginePrivate *p) { return p->q_func(); }
QDeclarativeContextData *getContext(QScriptContext *);
+ static QString urlToLocalFileOrQrc(const QUrl& url);
+
static void defineModule();
};
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 0c87671..c658a31 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -49,22 +49,13 @@
#include <QtDeclarative/qdeclarativeextensioninterface.h>
#include <private/qdeclarativeglobal_p.h>
#include <private/qdeclarativetypenamecache_p.h>
+#include <private/qdeclarativeengine_p.h>
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
- if (url.authority().isEmpty())
- return QLatin1Char(':') + url.path();
- return QString();
- }
- return url.toLocalFile();
-}
-
static bool greaterThan(const QString &s1, const QString &s2)
{
return s1 > s2;
@@ -262,7 +253,7 @@ bool QDeclarativeImportedNamespace::find_helper(int i, const QByteArray& type, i
if (!typeWasDeclaredInQmldir && !isLibrary.at(i)) {
// XXX search non-files too! (eg. zip files, see QT-524)
- QFileInfo f(toLocalFileOrQrc(url));
+ QFileInfo f(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url));
if (f.exists()) {
if (base && *base == url) { // no recursion
if (typeRecursionDetected)
@@ -415,15 +406,15 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
if (importType == QDeclarativeScriptParser::Import::File && qmldircomponents.isEmpty()) {
QUrl importUrl = base.resolved(QUrl(uri + QLatin1String("/qmldir")));
- QString localFileOrQrc = toLocalFileOrQrc(importUrl);
+ QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl);
if (!localFileOrQrc.isEmpty()) {
- QString dir = toLocalFileOrQrc(base.resolved(QUrl(uri)));
+ QString dir = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri)));
if (dir.isEmpty() || !QDir().exists(dir)) {
if (errorString)
*errorString = QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri_arg);
return false; // local import dirs must exist
}
- uri = resolvedUri(toLocalFileOrQrc(base.resolved(QUrl(uri))), database);
+ uri = resolvedUri(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri))), database);
if (uri.endsWith(QLatin1Char('/')))
uri.chop(1);
if (QFile::exists(localFileOrQrc)) {
@@ -433,7 +424,7 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
} else {
if (prefix.isEmpty()) {
// directory must at least exist for valid import
- QString localFileOrQrc = toLocalFileOrQrc(base.resolved(QUrl(uri)));
+ QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri)));
if (localFileOrQrc.isEmpty() || !QDir().exists(localFileOrQrc)) {
if (errorString) {
if (localFileOrQrc.isEmpty())
diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp
index 4cde54b..388f252 100644
--- a/src/declarative/qml/qdeclarativeinclude.cpp
+++ b/src/declarative/qml/qdeclarativeinclude.cpp
@@ -172,16 +172,6 @@ void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback
}
}
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- if (url.scheme() == QLatin1String("qrc")) {
- if (url.authority().isEmpty())
- return QLatin1Char(':') + url.path();
- return QString();
- }
- return url.toLocalFile();
-}
-
QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *engine)
{
if (ctxt->argumentCount() == 0)
@@ -200,7 +190,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e
urlString = url.toString();
}
- QString localFile = toLocalFileOrQrc(url);
+ QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
QScriptValue func = ctxt->argument(1);
if (!func.isFunction())
@@ -269,7 +259,7 @@ QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEn
urlString = url.toString();
}
- QString localFile = toLocalFileOrQrc(url);
+ QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
QScriptValue func = ctxt->argument(1);
if (!func.isFunction())
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index 8b64e0e..aca01b2 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -623,7 +623,7 @@ private:
inline void cleanup();
- void *data[4];
+ char data[4 * sizeof(void *)];
int type;
};
}
diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp
index 13e9c26..7aea7cb 100644
--- a/src/declarative/qml/qdeclarativevmemetaobject.cpp
+++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp
@@ -381,7 +381,7 @@ QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(QObject *obj,
const QMetaObject *other,
const QDeclarativeVMEMetaData *meta,
QDeclarativeCompiledData *cdata)
-: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj)->outerContext),
+: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj, true)->outerContext),
metaData(meta), data(0), methods(0), parent(0)
{
compiledData->addref();
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 8182998..1550351 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -189,7 +189,7 @@ QScriptValue QDeclarativeWorkerScriptEnginePrivate::onMessage(QScriptContext *ct
if (!script)
return engine->undefinedValue();
- if (ctxt->argumentCount() >= 1)
+ if (ctxt->argumentCount() >= 1)
script->callback = ctxt->argument(0);
return script->callback;
@@ -277,10 +277,10 @@ void QDeclarativeWorkerScriptEnginePrivate::processMessage(int id, const QVarian
void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
{
- if (url.isRelative() || url.scheme() != QLatin1String("file"))
+ if (url.isRelative())
return;
- QString fileName = url.toLocalFile();
+ QString fileName = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
QFile f(fileName);
if (f.open(QIODevice::ReadOnly)) {
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index adfcd62..c73f827 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -53,6 +53,7 @@
#include <QFontDatabase>
#include <private/qobject_p.h>
+#include <private/qdeclarativeengine_p.h>
#include <qdeclarativeinfo.h>
QT_BEGIN_NAMESPACE
@@ -98,15 +99,6 @@ QDeclarativeFontLoader::~QDeclarativeFontLoader()
{
}
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
-
/*!
\qmlproperty url FontLoader::source
The url of the font to load.
@@ -127,7 +119,7 @@ void QDeclarativeFontLoader::setSource(const QUrl &url)
d->status = Loading;
emit statusChanged();
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(d->url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
int id = QFontDatabase::addApplicationFont(lf);
if (id != -1) {
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index d9ce42c..a4ddf46 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -66,14 +66,6 @@ static const int maxImageRequestCount = 8;
QT_BEGIN_NAMESPACE
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
class QDeclarativeImageReaderEvent : public QEvent
{
public:
@@ -269,7 +261,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event)
}
QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image));
} else {
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
// Image is local - load/decode immediately
QImage image;
@@ -613,7 +605,7 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
if (!async) {
- QString lf = toLocalFileOrQrc(url);
+ QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
if (!lf.isEmpty()) {
status = QDeclarativePixmapReply::Ready;
if (!QPixmapCache::find(strKey,pixmap)) {
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index cae1d3a..d08e37b 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -42,7 +42,7 @@
#include "private/qdeclarativexmllistmodel_p.h"
#include <qdeclarativecontext.h>
-#include <qdeclarativeengine.h>
+#include <qdeclarativeengine_p.h>
#include <QDebug>
#include <QStringList>
@@ -83,12 +83,14 @@ typedef QPair<int, int> QDeclarativeXmlListRange;
The name for the role. This name is used to access the model data for this role from Qml.
\qml
- XmlRole { name: "title"; query: "title/string()" }
-
- ...
+ XmlListModel {
+ id: xmlModel
+ ...
+ XmlRole { name: "title"; query: "title/string()" }
+ }
- Component {
- id: myDelegate
+ ListView {
+ model: xmlModel
Text { text: title }
}
\endqml
@@ -122,11 +124,11 @@ struct XmlQueryJob
QString query;
QString namespaces;
QStringList roleQueries;
+ QList<void*> roleQueryErrorId; // the ptr to send back if there is an error
QStringList keyRoleQueries;
QStringList keyRoleResultsCache;
};
-
class QDeclarativeXmlQuery : public QThread
{
Q_OBJECT
@@ -166,6 +168,7 @@ public:
continue;
}
job.roleQueries << roleObjects->at(i)->query();
+ job.roleQueryErrorId << static_cast<void*>(roleObjects->at(i));
if (roleObjects->at(i)->isKey())
job.keyRoleQueries << job.roleQueries.last();
}
@@ -181,6 +184,7 @@ public:
Q_SIGNALS:
void queryCompleted(const QDeclarativeXmlQueryResult &);
+ void error(void*, const QString&);
protected:
void run() {
@@ -346,26 +350,24 @@ void QDeclarativeXmlQuery::doSubQueryJob()
}
job.keyRoleResultsCache = keyRoleResults;
-
// Get the new values for each role.
//### we might be able to condense even further (query for everything in one go)
const QStringList &queries = job.roleQueries;
for (int i = 0; i < queries.size(); ++i) {
- if (queries[i].isEmpty()) {
- QList<QVariant> resultList;
- for (int j = 0; j < m_size; ++j)
- resultList << QVariant();
- m_modelData << resultList;
- continue;
- }
- subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + queries[i] + QLatin1String(" return if ($v) then ") + queries[i] + QLatin1String(" else \"\")"));
- QXmlResultItems resultItems;
- subquery.evaluateTo(&resultItems);
- QXmlItem item(resultItems.next());
QList<QVariant> resultList;
- while (!item.isNull()) {
- resultList << item.toAtomicValue(); //### we used to trim strings
- item = resultItems.next();
+ if (!queries[i].isEmpty()) {
+ subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + queries[i] + QLatin1String(" return if ($v) then ") + queries[i] + QLatin1String(" else \"\")"));
+ if (subquery.isValid()) {
+ QXmlResultItems resultItems;
+ subquery.evaluateTo(&resultItems);
+ QXmlItem item(resultItems.next());
+ while (!item.isNull()) {
+ resultList << item.toAtomicValue(); //### we used to trim strings
+ item = resultItems.next();
+ }
+ } else {
+ emit error(job.roleQueryErrorId.at(i), queries[i]);
+ }
}
//### should warn here if things have gone wrong.
while (resultList.count() < m_size)
@@ -412,6 +414,16 @@ public:
, reply(0), status(QDeclarativeXmlListModel::Null), progress(0.0)
, queryId(-1), roleObjects(), redirectCount(0) {}
+
+ void notifyQueryStarted(bool remoteSource) {
+ Q_Q(QDeclarativeXmlListModel);
+ progress = remoteSource ? 0.0 : 1.0;
+ status = QDeclarativeXmlListModel::Loading;
+ errorString.clear();
+ emit q->progressChanged(progress);
+ emit q->statusChanged(status);
+ }
+
bool isComponentComplete;
QUrl src;
QString xml;
@@ -556,6 +568,8 @@ QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
{
connect(globalXmlQuery(), SIGNAL(queryCompleted(QDeclarativeXmlQueryResult)),
this, SLOT(queryCompleted(QDeclarativeXmlQueryResult)));
+ connect(globalXmlQuery(), SIGNAL(error(void*,QString)),
+ this, SLOT(queryError(void*,QString)));
}
QDeclarativeXmlListModel::~QDeclarativeXmlListModel()
@@ -727,6 +741,42 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati
}
/*!
+ \qmlmethod object XmlListModel::get(int index)
+
+ Returns the item at \a index in the model.
+
+ For example, for a model like this:
+
+ \qml
+ XmlListModel {
+ id: model
+ source: "http://mysite.com/feed.xml"
+ query: "/feed/entry"
+ XmlRole { name: "title"; query: "title/string()" }
+ }
+ \endqml
+
+ This will access the \c title value for the first item in the model:
+
+ \qml
+ var title = model.get(0).title;
+ \endqml
+*/
+QScriptValue QDeclarativeXmlListModel::get(int index) const
+{
+ Q_D(const QDeclarativeXmlListModel);
+
+ QScriptEngine *sengine = QDeclarativeEnginePrivate::getScriptEngine(qmlContext(this)->engine());
+ if (index < 0 || index >= count())
+ return sengine->undefinedValue();
+
+ QScriptValue sv = sengine->newObject();
+ for (int i=0; i<d->roleObjects.count(); i++)
+ sv.setProperty(d->roleObjects[i]->name(), qScriptValueFromValue(sengine, d->data.value(i).value(index)));
+ return sv;
+}
+
+/*!
\qmlproperty enumeration XmlListModel::status
Specifies the model loading status, which can be one of the following:
@@ -824,36 +874,21 @@ void QDeclarativeXmlListModel::reload()
if (!d->xml.isEmpty()) {
d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache);
- d->progress = 1.0;
- d->status = Loading;
- d->errorString.clear();
- emit progressChanged(d->progress);
- emit statusChanged(d->status);
- return;
- }
+ d->notifyQueryStarted(false);
- if (d->src.isEmpty()) {
+ } else if (d->src.isEmpty()) {
d->queryId = XMLLISTMODEL_CLEAR_ID;
- d->progress = 1.0;
- d->status = Loading;
- d->errorString.clear();
- emit progressChanged(d->progress);
- emit statusChanged(d->status);
+ d->notifyQueryStarted(false);
QTimer::singleShot(0, this, SLOT(dataCleared()));
- return;
- }
- d->progress = 0.0;
- d->status = Loading;
- d->errorString.clear();
- emit progressChanged(d->progress);
- emit statusChanged(d->status);
-
- QNetworkRequest req(d->src);
- d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
- QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
- QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
+ } else {
+ d->notifyQueryStarted(true);
+ QNetworkRequest req(d->src);
+ d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
+ QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ }
}
#define XMLLISTMODEL_MAX_REDIRECT 16
@@ -929,6 +964,19 @@ void QDeclarativeXmlListModel::dataCleared()
queryCompleted(r);
}
+void QDeclarativeXmlListModel::queryError(void* object, const QString& error)
+{
+ // Be extra careful, object may no longer exist, it's just an ID.
+ Q_D(QDeclarativeXmlListModel);
+ for (int i=0; i<d->roleObjects.count(); i++) {
+ if (d->roleObjects.at(i) == static_cast<QDeclarativeXmlListModelRole*>(object)) {
+ qmlInfo(d->roleObjects.at(i)) << QObject::tr("invalid query: \"%1\"").arg(error);
+ return;
+ }
+ }
+ qmlInfo(this) << QObject::tr("invalid query: \"%1\"").arg(error);
+}
+
void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult &result)
{
Q_D(QDeclarativeXmlListModel);
@@ -960,7 +1008,6 @@ void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult &
}
} else {
-
for (int i=0; i<result.removed.count(); i++)
emit itemsRemoved(result.removed[i].first, result.removed[i].second);
for (int i=0; i<result.inserted.count(); i++)
diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h
index 7101c57..8d848c8 100644
--- a/src/declarative/util/qdeclarativexmllistmodel_p.h
+++ b/src/declarative/util/qdeclarativexmllistmodel_p.h
@@ -47,6 +47,7 @@
#include <QtCore/qurl.h>
#include <QtCore/qstringlist.h>
+#include <QtScript/qscriptvalue.h>
#include <private/qlistmodelinterface_p.h>
@@ -109,6 +110,8 @@ public:
QString namespaceDeclarations() const;
void setNamespaceDeclarations(const QString&);
+ Q_INVOKABLE QScriptValue get(int index) const;
+
enum Status { Null, Ready, Loading, Error };
Status status() const;
qreal progress() const;
@@ -139,6 +142,7 @@ private Q_SLOTS:
void requestProgress(qint64,qint64);
void dataCleared();
void queryCompleted(const QDeclarativeXmlQueryResult &);
+ void queryError(void* object, const QString& error);
private:
Q_DECLARE_PRIVATE(QDeclarativeXmlListModel)
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 2030f1a..c4ee99a 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -5643,6 +5643,14 @@ void QGraphicsItem::update(const QRectF &rect)
viewport, which does not benefit from scroll optimizations), this function
is equivalent to calling update(\a rect).
+ \bold{Note:} Scrolling is only supported when QGraphicsItem::ItemCoordinateCache
+ is enabled; in all other cases calling this function is equivalent to calling
+ update(\a rect). If you for sure know that the item is opaque and not overlapped
+ by other items, you can map the \a rect to viewport coordinates and scroll the
+ viewport.
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 19
+
\sa boundingRect()
*/
void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
@@ -5652,153 +5660,73 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
return;
if (!d->scene)
return;
- if (d->cacheMode != NoCache) {
- QGraphicsItemCache *c;
- bool scrollCache = qFuzzyIsNull(dx - int(dx)) && qFuzzyIsNull(dy - int(dy))
- && (c = (QGraphicsItemCache *)qVariantValue<void *>(d_ptr->extra(QGraphicsItemPrivate::ExtraCacheData)))
- && (d->cacheMode == ItemCoordinateCache && !c->fixedSize.isValid());
- if (scrollCache) {
- QPixmap pix;
- if (QPixmapCache::find(c->key, &pix)) {
- // Adjust with 2 pixel margin. Notice the loss of precision
- // when converting to QRect.
- int adjust = 2;
- QRectF scrollRect = !rect.isNull() ? rect : boundingRect();
- QRectF br = boundingRect().adjusted(-adjust, -adjust, adjust, adjust);
- QRect irect = scrollRect.toRect().translated(-br.x(), -br.y());
-
- pix.scroll(dx, dy, irect);
-
- QPixmapCache::replace(c->key, pix);
-
- // Translate the existing expose.
- foreach (QRectF exposedRect, c->exposed)
- c->exposed += exposedRect.translated(dx, dy) & scrollRect;
-
- // Calculate exposure.
- QRegion exposed;
- QRect r = scrollRect.toRect();
- exposed += r;
- exposed -= r.translated(dx, dy);
- foreach (QRect rect, exposed.rects())
- update(rect);
- d->scene->d_func()->markDirty(this);
- } else {
- update(rect);
- }
- } else {
- // ### This is very slow, and can be done much better. If the cache is
- // local and matches the below criteria for rotation and scaling, we
- // can easily scroll. And if the cache is in device coordinates, we
- // can scroll both the viewport and the cache.
- update(rect);
- }
+
+ // Accelerated scrolling means moving pixels from one location to another
+ // and only redraw the newly exposed area. The following requirements must
+ // be fulfilled in order to do that:
+ //
+ // 1) Item is opaque.
+ // 2) Item is not overlapped by other items.
+ //
+ // There's (yet) no way to detect whether an item is opaque or not, which means
+ // we cannot do accelerated scrolling unless the cache is enabled. In case of using
+ // DeviceCoordinate cache we also have to take the device transform into account in
+ // order to determine whether we can do accelerated scrolling or not. That's left out
+ // for simplicity here, but it is definitely something we can consider in the future
+ // as a performance improvement.
+ if (d->cacheMode != QGraphicsItem::ItemCoordinateCache
+ || !qFuzzyIsNull(dx - int(dx)) || !qFuzzyIsNull(dy - int(dy))) {
+ update(rect);
return;
}
- QRectF scrollRect = !rect.isNull() ? rect : boundingRect();
- int couldntScroll = d->scene->views().size();
- foreach (QGraphicsView *view, d->scene->views()) {
- if (view->viewport()->inherits("QGLWidget")) {
- // ### Please replace with a widget attribute; any widget that
- // doesn't support partial updates / doesn't support scrolling
- // should be skipped in this code. Qt::WA_NoPartialUpdates or so.
- continue;
- }
+ QGraphicsItemCache *cache = d->extraItemCache();
+ if (cache->allExposed || cache->fixedSize.isValid()) {
+ // Cache is either invalidated or item is scaled (see QGraphicsItem::setCacheMode).
+ update(rect);
+ return;
+ }
- static const QLineF up(0, 0, 0, -1);
- static const QLineF down(0, 0, 0, 1);
- static const QLineF left(0, 0, -1, 0);
- static const QLineF right(0, 0, 1, 0);
-
- QTransform deviceTr = deviceTransform(view->viewportTransform());
- QRect deviceScrollRect = deviceTr.mapRect(scrollRect).toRect();
- QLineF v1 = deviceTr.map(right);
- QLineF v2 = deviceTr.map(down);
- QLineF u1 = v1.unitVector(); u1.translate(-v1.p1());
- QLineF u2 = v2.unitVector(); u2.translate(-v2.p1());
- bool noScroll = false;
-
- // Check if the delta resolves to ints in device space.
- QPointF deviceDelta = deviceTr.map(QPointF(dx, dy));
- if ((deviceDelta.x() - int(deviceDelta.x()))
- || (deviceDelta.y() - int(deviceDelta.y()))) {
- noScroll = true;
- } else {
- // Check if the unit vectors have no fraction in device space.
- qreal v1l = v1.length();
- if (v1l - int(v1l)) {
- noScroll = true;
- } else {
- dx *= v1.length();
- }
- qreal v2l = v2.length();
- if (v2l - int(v2l)) {
- noScroll = true;
- } else {
- dy *= v2.length();
- }
- }
+ QPixmap cachedPixmap;
+ if (!QPixmapCache::find(cache->key, &cachedPixmap)) {
+ update(rect);
+ return;
+ }
- if (!noScroll) {
- if (u1 == right) {
- if (u2 == up) {
- // flipped
- dy = -dy;
- } else if (u2 == down) {
- // normal
- } else {
- noScroll = true;
- }
- } else if (u1 == left) {
- if (u2 == up) {
- // mirrored & flipped / rotated 180 degrees
- dx = -dx;
- dy = -dy;
- } else if (u2 == down) {
- // mirrored
- dx = -dx;
- } else {
- noScroll = true;
- }
- } else if (u1 == up) {
- if (u2 == left) {
- // rotated -90 & mirrored
- qreal tmp = dy;
- dy = -dx;
- dx = -tmp;
- } else if (u2 == right) {
- // rotated -90
- qreal tmp = dy;
- dy = -dx;
- dx = tmp;
- } else {
- noScroll = true;
- }
- } else if (u1 == down) {
- if (u2 == left) {
- // rotated 90
- qreal tmp = dy;
- dy = dx;
- dx = -tmp;
- } else if (u2 == right) {
- // rotated 90 & mirrored
- qreal tmp = dy;
- dy = dx;
- dx = tmp;
- } else {
- noScroll = true;
- }
- }
- }
+ QRegion exposed;
+ const bool scrollEntirePixmap = rect.isNull();
+ if (scrollEntirePixmap) {
+ // Scroll entire pixmap.
+ cachedPixmap.scroll(dx, dy, cachedPixmap.rect(), &exposed);
+ } else {
+ if (!rect.intersects(cache->boundingRect))
+ return; // Nothing to scroll.
+ // Scroll sub-rect of pixmap. The rect is in item coordinates
+ // so we have to translate it to pixmap coordinates.
+ QRect scrollRect = rect.toAlignedRect();
+ cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);
+ }
- if (!noScroll) {
- view->viewport()->scroll(int(dx), int(dy), deviceScrollRect);
- --couldntScroll;
- }
+ QPixmapCache::replace(cache->key, cachedPixmap);
+
+ // Translate the existing expose.
+ for (int i = 0; i < cache->exposed.size(); ++i) {
+ QRectF &e = cache->exposed[i];
+ if (!scrollEntirePixmap && !e.intersects(rect))
+ continue;
+ e.translate(dx, dy);
}
- if (couldntScroll)
- update(rect);
+
+ // Append newly exposed areas. Note that the exposed region is currently
+ // in pixmap coordinates, so we have to translate it to item coordinates.
+ exposed.translate(cache->boundingRect.topLeft());
+ const QVector<QRect> exposedRects = exposed.rects();
+ for (int i = 0; i < exposedRects.size(); ++i)
+ cache->exposed += exposedRects.at(i);
+
+ // Trigger update. This will redraw the newly exposed area and make sure
+ // the pixmap is re-blitted in case there are overlapping items.
+ d->scene->d_func()->markDirty(this, rect);
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 4b09a7e..ae0abf9 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -2545,12 +2545,16 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
return;
}
- if (d->unpolishedItems.isEmpty()) {
- QMetaMethod method = metaObject()->method(d->polishItemsIndex);
- method.invoke(this, Qt::QueuedConnection);
+ // QDeclarativeItems do not rely on initial itemChanged message, as the componentComplete
+ // function allows far more opportunity for delayed-construction optimization.
+ if (!item->d_ptr->isDeclarativeItem) {
+ if (d->unpolishedItems.isEmpty()) {
+ QMetaMethod method = metaObject()->method(d->polishItemsIndex);
+ method.invoke(this, Qt::QueuedConnection);
+ }
+ d->unpolishedItems.append(item);
+ item->d_ptr->pendingPolish = true;
}
- d->unpolishedItems.append(item);
- item->d_ptr->pendingPolish = true;
// Detach this item from its parent if the parent's scene is different
// from this scene.
@@ -4372,11 +4376,6 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
bool pixmapFound;
QGraphicsItemCache *itemCache = itemd->extraItemCache();
if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
- if (itemCache->boundingRect != brect.toRect()) {
- itemCache->boundingRect = brect.toRect();
- itemCache->allExposed = true;
- itemCache->exposed.clear();
- }
pixmapKey = itemCache->key;
} else {
pixmapKey = itemCache->deviceData.value(widget).key;
@@ -4389,19 +4388,24 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
QSize pixmapSize;
bool fixedCacheSize = false;
- QRectF brectAligned = brect.toAlignedRect();
+ QRect br = brect.toAlignedRect();
if ((fixedCacheSize = itemCache->fixedSize.isValid())) {
pixmapSize = itemCache->fixedSize;
} else {
- pixmapSize = brectAligned.size().toSize();
+ pixmapSize = br.size();
}
// Create or recreate the pixmap.
int adjust = itemCache->fixedSize.isValid() ? 0 : 2;
QSize adjustSize(adjust*2, adjust*2);
- QRectF br = brectAligned.adjusted(-adjust, -adjust, adjust, adjust);
+ br.adjust(-adjust, -adjust, adjust, adjust);
if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) {
pix = QPixmap(pixmapSize + adjustSize);
+ itemCache->boundingRect = br;
+ itemCache->exposed.clear();
+ itemCache->allExposed = true;
+ } else if (itemCache->boundingRect != br) {
+ itemCache->boundingRect = br;
itemCache->exposed.clear();
itemCache->allExposed = true;
}
@@ -4455,10 +4459,10 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
// qpixmap-image-transform-pixmap roundtrip.
if (newPainterOpacity != oldPainterOpacity) {
painter->setOpacity(newPainterOpacity);
- painter->drawPixmap(br, pix, QRectF(QPointF(), pix.size()));
+ painter->drawPixmap(br.topLeft(), pix);
painter->setOpacity(oldPainterOpacity);
} else {
- painter->drawPixmap(br, pix, QRectF(QPointF(), pix.size()));
+ painter->drawPixmap(br.topLeft(), pix);
}
return;
}
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index 076e8626..28070da 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -79,7 +79,8 @@ void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFl
resolveLayoutDirection();
q->unsetWindowFrameMargins();
- flags |= QGraphicsItem::ItemUsesExtendedStyleOption | QGraphicsItem::ItemSendsGeometryChanges;
+ flags |= QGraphicsItem::ItemUsesExtendedStyleOption;
+ flags |= QGraphicsItem::ItemSendsGeometryChanges;
if (windowFlags & Qt::Window)
flags |= QGraphicsItem::ItemIsPanel;
}
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 7696632..a2f429a 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -55,7 +55,6 @@
#include "qcache.h"
#include "qdebug.h"
#include "private/qguiplatformplugin_p.h"
-#include "private/qstylehelper_p.h"
#ifdef Q_WS_MAC
#include <private/qt_mac_p.h>
@@ -67,6 +66,8 @@
#include "private/qkde_p.h"
#endif
+#include "private/qstylehelper_p.h"
+
#ifndef QT_NO_ICON
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index d9f7df0..883f511 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -44,7 +44,6 @@
#if !defined(QT_NO_STYLE_CLEANLOOKS) || defined(QT_PLUGIN)
-#include <private/qstylehelper_p.h>
#include "qwindowsstyle_p.h"
#include <qcombobox.h>
#include <qpushbutton.h>
@@ -67,6 +66,7 @@
#include <qtoolbar.h>
#include <qwizard.h>
#include <qlibrary.h>
+#include <private/qstylehelper_p.h>
#define CL_MAX(a,b) (a)>(b) ? (a):(b) // ### qMin/qMax does not work for vc6
#define CL_MIN(a,b) (a)<(b) ? (a):(b) // remove this when it is working
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 8036728..4978565 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -65,7 +65,6 @@
#include <qrubberband.h>
#include <private/qcommonstylepixmaps_p.h>
#include <private/qmath_p.h>
-#include <private/qstylehelper_p.h>
#include <qdebug.h>
#include <qtextformat.h>
#include <qwizard.h>
@@ -88,6 +87,8 @@
# include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#include <private/qstylehelper_p.h>
+
QT_BEGIN_NAMESPACE
/*!
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index d3ffed8..7fcdaf2 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -56,7 +56,6 @@
#include <private/qpaintengine_mac_p.h>
#include <private/qpainter_p.h>
#include <private/qprintengine_mac_p.h>
-#include <private/qstylehelper_p.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qcheckbox.h>
@@ -101,6 +100,7 @@
#include <QtGui/qgraphicsproxywidget.h>
#include <QtGui/qgraphicsview.h>
#include <private/qt_cocoa_helpers_mac_p.h>
+#include <private/qstylehelper_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index fbb5e4d..c8711f6 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/gui/styles/qplastiquestyle.cpp
@@ -50,7 +50,6 @@ static const int ProgressBarFps = 25;
static const int blueFrameWidth = 2; // with of line edit focus frame
#include "qwindowsstyle_p.h"
-#include <private/qstylehelper_p.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qabstractitemview.h>
@@ -88,6 +87,7 @@ static const int blueFrameWidth = 2; // with of line edit focus frame
#include <qprocess.h>
#include <qvarlengtharray.h>
#include <limits.h>
+#include <private/qstylehelper_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qproxystyle.cpp b/src/gui/styles/qproxystyle.cpp
index 5235350..511c025 100644
--- a/src/gui/styles/qproxystyle.cpp
+++ b/src/gui/styles/qproxystyle.cpp
@@ -40,11 +40,11 @@
****************************************************************************/
#include <qstyle.h>
-#include <private/qstyle_p.h>
#include <private/qproxystyle_p.h>
#include <private/qapplication_p.h>
#include "qproxystyle.h"
#include "qstylefactory.h"
+#include <private/qstyle_p.h>
#if !defined(QT_NO_STYLE_PROXY) || defined(QT_PLUGIN)
diff --git a/src/gui/styles/qstyle_p.h b/src/gui/styles/qstyle_p.h
index 4729032..745092f 100644
--- a/src/gui/styles/qstyle_p.h
+++ b/src/gui/styles/qstyle_p.h
@@ -43,7 +43,6 @@
#define QSTYLE_P_H
#include "private/qobject_p.h"
-#include "private/qstylehelper_p.h"
#include <QtGui/qstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp
index d09d7fa..ccdbf8c 100644
--- a/src/gui/styles/qstylehelper.cpp
+++ b/src/gui/styles/qstylehelper.cpp
@@ -39,8 +39,6 @@
**
****************************************************************************/
-#include "qstylehelper_p.h"
-
#include <qstyleoption.h>
#include <qpainter.h>
#include <qpixmapcache.h>
@@ -54,6 +52,7 @@
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#include "qstylehelper_p.h"
#include <qstringbuilder.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index 67eb1ef..4e7b92c 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -80,6 +80,8 @@ extern bool qt_wince_is_smartphone(); //defined in qguifunctions_wince.cp
extern bool qt_wince_is_windows_mobile_65(); //defined in qguifunctions_wince.cpp
#endif // Q_WS_WINCE
+#include "qstylehelper_p.h"
+
QT_BEGIN_NAMESPACE
static const int windowsItemFrame = 1; // menu item frame width
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 1653baa..0314c6f 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -41,7 +41,6 @@
#include "qwindowsstyle.h"
#include "qwindowsstyle_p.h"
-#include <private/qstylehelper_p.h>
#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
@@ -70,13 +69,14 @@
#include <private/qmath_p.h>
#include <qmath.h>
-
#ifdef Q_WS_X11
#include "qfileinfo.h"
#include "qdir.h"
#include <private/qt_x11_p.h>
#endif
+#include <private/qstylehelper_p.h>
+
QT_BEGIN_NAMESPACE
#if defined(Q_WS_WIN)
@@ -1911,7 +1911,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
p->setPen(discol);
}
- int xm = QWindowsStylePrivate::windowsItemFrame + checkcol + QWindowsStylePrivate::windowsItemHMargin;
+ int xm = int(QWindowsStylePrivate::windowsItemFrame) + checkcol + int(QWindowsStylePrivate::windowsItemHMargin);
int xpos = menuitem->rect.x() + xm;
QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
@@ -3223,7 +3223,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
w += checkcol;
- w += QWindowsStylePrivate::windowsRightBorder + 10;
+ w += int(QWindowsStylePrivate::windowsRightBorder) + 10;
sz.setWidth(w);
}
break;
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 3b2e4e9..a7aa2ce 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -78,6 +78,9 @@ QT_BEGIN_NAMESPACE
extern double qt_pointSize(double pixelSize, int dpi);
extern double qt_pixelSize(double pointSize, int dpi);
+// from qapplication.cpp
+extern bool qt_is_gui_used;
+
static inline void capitalize (char *s)
{
bool space = true;
@@ -1938,7 +1941,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
} else if (X11->has_fontconfig) {
fe = loadFc(d, script, req);
- if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize) {
+ if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize && mainThread && qt_is_gui_used) {
QFontEngine *xlfdFontEngine = loadXlfd(d->screen, script, req);
if (xlfdFontEngine->fontDef.family == fe->fontDef.family) {
delete fe;
@@ -1950,7 +1953,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
#endif
- } else if (mainThread) {
+ } else if (mainThread && qt_is_gui_used) {
fe = loadXlfd(d->screen, script, req);
}
if (!fe) {
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 4698be4..469c7d4 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -983,19 +983,9 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
return false;
}
-class ExceptionGuard
-{
-public:
- inline ExceptionGuard(bool *w = 0) : watched(w) { Q_ASSERT(!(*watched)); *watched = true; }
- inline ~ExceptionGuard() { *watched = false; }
- inline operator bool() { return *watched; }
-private:
- bool *watched;
-};
-
void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self)
{
- ExceptionGuard guard(&activationRecursionGuard);
+ QBoolBlocker guard(activationRecursionGuard);
#ifdef QT3_SUPPORT
const int actionId = q_func()->findIdForAction(action);
#endif
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index d4569f7..555df3c 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -6,35 +6,34 @@
**
** This file is part of the plugins of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
index 6a7383a..fccb9d4 100644
--- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp
@@ -179,7 +179,8 @@ void QDeclarativeFolderListModel::setFolder(const QUrl &folder)
if (folder == d->folder)
return;
QModelIndex index = d->model.index(folder.toLocalFile());
- if (index.isValid() && d->model.isDir(index)) {
+ if ((index.isValid() && d->model.isDir(index)) || folder.toLocalFile().isEmpty()) {
+
d->folder = folder;
QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
emit folderChanged();
@@ -188,26 +189,23 @@ void QDeclarativeFolderListModel::setFolder(const QUrl &folder)
QUrl QDeclarativeFolderListModel::parentFolder() const
{
- QUrl r;
QString localFile = d->folder.toLocalFile();
if (!localFile.isEmpty()) {
QDir dir(localFile);
-#if defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WIN)
if (dir.isRoot())
dir.setPath("");
else
#endif
dir.cdUp();
- r = d->folder;
- r.setPath(dir.path());
+ localFile = dir.path();
} else {
int pos = d->folder.path().lastIndexOf(QLatin1Char('/'));
if (pos == -1)
return QUrl();
- r = d->folder;
- r.setPath(d->folder.path().left(pos));
+ localFile = d->folder.path().left(pos);
}
- return r;
+ return QUrl::fromLocalFile(localFile);
}
/*!
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 10fdc6f..fe36247 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -595,8 +595,9 @@ QNetworkCookieJar *QNetworkAccessManager::cookieJar() const
\note QNetworkAccessManager takes ownership of the \a cookieJar object.
- QNetworkAccessManager will set the parent of the \a cookieJar
- passed to itself, so that the cookie jar is deleted when this
+ If \a cookieJar is in the same thread as this QNetworkAccessManager,
+ it will set the parent of the \a cookieJar
+ so that the cookie jar is deleted when this
object is deleted as well. If you want to share cookie jars
between different QNetworkAccessManager objects, you may want to
set the cookie jar's parent to 0 after calling this function.
@@ -621,7 +622,8 @@ void QNetworkAccessManager::setCookieJar(QNetworkCookieJar *cookieJar)
if (d->cookieJar && d->cookieJar->parent() == this)
delete d->cookieJar;
d->cookieJar = cookieJar;
- d->cookieJar->setParent(this);
+ if (thread() == cookieJar->thread())
+ d->cookieJar->setParent(this);
}
}