diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-06-23 06:07:11 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-06-23 06:07:11 (GMT) |
commit | 6d7120dc2081e10c46ffe8467b047affe81ed747 (patch) | |
tree | c454785971f36b8cab970f919d6a89c03685a260 /src | |
parent | b418419f23cec0880b6b351d304b1a755f82ab73 (diff) | |
parent | dd792c28d89fbdc23de0d40143f0ca900c6c4daa (diff) | |
download | Qt-6d7120dc2081e10c46ffe8467b047affe81ed747.zip Qt-6d7120dc2081e10c46ffe8467b047affe81ed747.tar.gz Qt-6d7120dc2081e10c46ffe8467b047affe81ed747.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
62 files changed, 823 insertions, 522 deletions
diff --git a/src/corelib/codecs/qfontlaocodec.cpp b/src/corelib/codecs/qfontlaocodec.cpp index 85017e0..6dd87de 100644 --- a/src/corelib/codecs/qfontlaocodec.cpp +++ b/src/corelib/codecs/qfontlaocodec.cpp @@ -97,8 +97,7 @@ QString QFontLaoCodec::convertToUnicode(const char *, int, ConverterState *) con QByteArray QFontLaoCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *) const { - QByteArray rstring; - rstring.resize(len); + QByteArray rstring(len, Qt::Uninitialized); uchar *rdata = (uchar *) rstring.data(); const QChar *sdata = uc; int i = 0; diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 6b9c77b..1bf76ea 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -225,11 +225,10 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState char *inBytes = const_cast<char *>(chars); #endif - QByteArray in; if (remainingCount) { // we have to prepend the remaining bytes from the previous conversion inBytesLeft += remainingCount; - in.resize(inBytesLeft); + QByteArray in(inBytesLeft, Qt::Uninitialized); inBytes = in.data(); memcpy(in.data(), remainingBuffer, remainingCount); @@ -238,9 +237,8 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState remainingCount = 0; } - QByteArray ba; size_t outBytesLeft = len * 2 + 2; - ba.resize(outBytesLeft); + QByteArray ba(outBytesLeft, Qt::Uninitialized); char *outBytes = ba.data(); do { size_t ret = iconv(state->cd, &inBytes, &inBytesLeft, &outBytes, &outBytesLeft); @@ -328,8 +326,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt state = new IconvState(QIconvCodec::createIconv_t(0, UTF16)); if (state->cd != reinterpret_cast<iconv_t>(-1)) { size_t outBytesLeft = len + 3; // +3 for the BOM - QByteArray ba; - ba.resize(outBytesLeft); + QByteArray ba(outBytesLeft, Qt::Uninitialized); outBytes = ba.data(); #if !defined(NO_BOM) @@ -358,18 +355,16 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt } size_t outBytesLeft = len; - QByteArray ba; - ba.resize(outBytesLeft); + QByteArray ba(outBytesLeft, Qt::Uninitialized); outBytes = ba.data(); // now feed iconv() the real data inBytes = const_cast<char *>(reinterpret_cast<const char *>(uc)); inBytesLeft = len * sizeof(QChar); - QByteArray in; if (convState && convState->remainingChars) { // we have one surrogate char to be prepended - in.resize(sizeof(QChar) + len); + QByteArray in(sizeof(QChar) + len, Qt::Uninitialized); inBytes = in.data(); QChar remaining = convState->state_data[0]; diff --git a/src/corelib/codecs/qisciicodec.cpp b/src/corelib/codecs/qisciicodec.cpp index a33fd0d..c054313 100644 --- a/src/corelib/codecs/qisciicodec.cpp +++ b/src/corelib/codecs/qisciicodec.cpp @@ -187,8 +187,7 @@ QByteArray QIsciiCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt } int invalid = 0; - QByteArray result; - result.resize(2*len); //worst case + QByteArray result(2 * len, Qt::Uninitialized); //worst case uchar *ch = reinterpret_cast<uchar *>(result.data()); @@ -250,8 +249,7 @@ QString QIsciiCodec::convertToUnicode(const char* chars, int len, ConverterState halant = state->state_data[0]; } - QString result; - result.resize(len); + QString result(len, Qt::Uninitialized); QChar *uc = result.data(); const int base = codecs[idx].base; diff --git a/src/corelib/codecs/qlatincodec.cpp b/src/corelib/codecs/qlatincodec.cpp index 176ae97..9113555 100644 --- a/src/corelib/codecs/qlatincodec.cpp +++ b/src/corelib/codecs/qlatincodec.cpp @@ -62,8 +62,7 @@ QString QLatin1Codec::convertToUnicode(const char *chars, int len, ConverterStat QByteArray QLatin1Codec::convertFromUnicode(const QChar *ch, int len, ConverterState *state) const { const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?'; - QByteArray r; - r.resize(len); + QByteArray r(len, Qt::Uninitialized); char *d = r.data(); int invalid = 0; for (int i = 0; i < len; ++i) { @@ -151,8 +150,7 @@ QString QLatin15Codec::convertToUnicode(const char* chars, int len, ConverterSta QByteArray QLatin15Codec::convertFromUnicode(const QChar *in, int length, ConverterState *state) const { const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?'; - QByteArray r; - r.resize(length); + QByteArray r(length, Qt::Uninitialized); char *d = r.data(); int invalid = 0; for (int i = 0; i < length; ++i) { diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp index aa7521d..0d14f67 100644 --- a/src/corelib/codecs/qsimplecodec.cpp +++ b/src/corelib/codecs/qsimplecodec.cpp @@ -676,8 +676,7 @@ QByteArray QSimpleTextCodec::convertFromUnicode(const QChar *in, int length, Con delete tmp; } - QByteArray r; - r.resize(length); + QByteArray r(length, Qt::Uninitialized); int i = length; int u; const QChar* ucp = in; diff --git a/src/corelib/codecs/qtsciicodec.cpp b/src/corelib/codecs/qtsciicodec.cpp index 7f660bf..c24d32d 100644 --- a/src/corelib/codecs/qtsciicodec.cpp +++ b/src/corelib/codecs/qtsciicodec.cpp @@ -82,8 +82,7 @@ QByteArray QTsciiCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt } int invalid = 0; - QByteArray rstr; - rstr.resize(len); + QByteArray rstr(len, Qt::Uninitialized); uchar* cursor = (uchar*)rstr.data(); for (int i = 0; i < len; i++) { QChar ch = uc[i]; diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index fe826ad..abae6f7 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -471,8 +471,7 @@ QByteArray QUtf32Codec::convertFromUnicode(const QChar *uc, int len, ConverterSt endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BE : LE; } - QByteArray d; - d.resize(length); + QByteArray d(length, Qt::Uninitialized); char *data = d.data(); if (!state || !(state->flags & IgnoreHeader)) { if (endian == BE) { diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 398cd48..2023327 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1543,7 +1543,7 @@ public: TitleBarArea // For move }; - enum Uninitialized { + enum Initialization { Uninitialized }; } diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index c42c9c9..fd7ddef 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -333,10 +333,13 @@ QSignalTransition *QState::addTransition(QObject *sender, const char *signal, return 0; } int offset = (*signal == '0'+QSIGNAL_CODE) ? 1 : 0; - if (sender->metaObject()->indexOfSignal(signal+offset) == -1) { - qWarning("QState::addTransition: no such signal %s::%s", - sender->metaObject()->className(), signal+offset); - return 0; + const QMetaObject *meta = sender->metaObject(); + if (meta->indexOfSignal(signal+offset) == -1) { + if (meta->indexOfSignal(QMetaObject::normalizedSignature(signal+offset)) == -1) { + qWarning("QState::addTransition: no such signal %s::%s", + meta->className(), signal+offset); + return 0; + } } QSignalTransition *trans = new QSignalTransition(sender, signal, QList<QAbstractState*>() << target); addTransition(trans); diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 758bdbe..682dd97 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1316,11 +1316,15 @@ void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transitio QByteArray signal = QSignalTransitionPrivate::get(transition)->signal; if (signal.startsWith('0'+QSIGNAL_CODE)) signal.remove(0, 1); - int signalIndex = sender->metaObject()->indexOfSignal(signal); + const QMetaObject *meta = sender->metaObject(); + int signalIndex = meta->indexOfSignal(signal); if (signalIndex == -1) { - qWarning("QSignalTransition: no such signal: %s::%s", - sender->metaObject()->className(), signal.constData()); - return; + signalIndex = meta->indexOfSignal(QMetaObject::normalizedSignature(signal)); + if (signalIndex == -1) { + qWarning("QSignalTransition: no such signal: %s::%s", + meta->className(), signal.constData()); + return; + } } QVector<int> &connectedSignalIndexes = connections[sender]; if (connectedSignalIndexes.size() <= signalIndex) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 0c45776..5d3386e 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1304,6 +1304,21 @@ QByteArray::QByteArray(int size, char ch) } /*! + \internal + + Constructs a byte array of size \a size with uninitialized contents. +*/ + +QByteArray::QByteArray(int size, Qt::Initialization) +{ + d = static_cast<Data *>(qMalloc(sizeof(Data)+size)); + d->ref = 1; + d->alloc = d->size = size; + d->data = d->array; + d->array[size] = '\0'; +} + +/*! Sets the size of the byte array to \a size bytes. If \a size is greater than the current size, the byte array is @@ -2977,8 +2992,7 @@ QByteArray QByteArray::simplified() const { if (d->size == 0) return *this; - QByteArray result; - result.resize(d->size); + QByteArray result(d->size, Qt::Uninitialized); const char *from = d->data; const char *fromend = from + d->size; int outc=0; @@ -3429,8 +3443,7 @@ QByteArray QByteArray::toBase64() const const char padchar = '='; int padlen = 0; - QByteArray tmp; - tmp.resize(((d->size * 4) / 3) + 3); + QByteArray tmp((d->size * 4) / 3 + 3, Qt::Uninitialized); int i = 0; char *out = tmp.data(); @@ -3768,8 +3781,7 @@ QByteArray QByteArray::fromBase64(const QByteArray &base64) { unsigned int buf = 0; int nbits = 0; - QByteArray tmp; - tmp.resize((base64.size() * 3) / 4); + QByteArray tmp((base64.size() * 3) / 4, Qt::Uninitialized); int offset = 0; for (int i = 0; i < base64.size(); ++i) { @@ -3817,8 +3829,7 @@ QByteArray QByteArray::fromBase64(const QByteArray &base64) */ QByteArray QByteArray::fromHex(const QByteArray &hexEncoded) { - QByteArray res; - res.resize((hexEncoded.size() + 1)/ 2); + QByteArray res((hexEncoded.size() + 1)/ 2, Qt::Uninitialized); uchar *result = (uchar *)res.data() + res.size(); bool odd_digit = true; @@ -3855,8 +3866,7 @@ QByteArray QByteArray::fromHex(const QByteArray &hexEncoded) */ QByteArray QByteArray::toHex() const { - QByteArray hex; - hex.resize(d->size*2); + QByteArray hex(d->size * 2, Qt::Uninitialized); char *hexData = hex.data(); const uchar *data = (const uchar *)d->data; for (int i = 0; i < d->size; ++i) { diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 5cd4d63..e494ac1 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -42,8 +42,8 @@ #ifndef QBYTEARRAY_H #define QBYTEARRAY_H -#include <QtCore/qglobal.h> #include <QtCore/qatomic.h> +#include <QtCore/qnamespace.h> #include <string.h> #include <stdarg.h> @@ -127,6 +127,7 @@ public: QByteArray(const char *); QByteArray(const char *, int size); QByteArray(int size, char c); + QByteArray(int size, Qt::Initialization); inline QByteArray(const QByteArray &); inline ~QByteArray(); diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index dba3d2a..3ff263d 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1012,14 +1012,13 @@ QString::QString(int size, QChar ch) } } -/*! - Constructs a string of the given \a size without initializing the - characters. This is only used in \c QStringBuilder::toString(). +/*! \fn QString::QString(int size, Qt::Initialization) + \internal - \internal + Constructs a string of the given \a size without initializing the + characters. This is only used in \c QStringBuilder::toString(). */ - -QString::QString(int size, enum Qt::Uninitialized) +QString::QString(int size, Qt::Initialization) { d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar)); d->ref = 1; diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 67716b8..6bb0d8e 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -579,7 +579,7 @@ public: bool isSimpleText() const { if (!d->clean) updateProperties(); return d->simpletext; } bool isRightToLeft() const { if (!d->clean) updateProperties(); return d->righttoleft; } - QString(int size, enum Qt::Uninitialized); + QString(int size, Qt::Initialization); private: #if defined(QT_NO_CAST_FROM_ASCII) && !defined(Q_NO_DECLARED_NOT_DEFINED) diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 44adba7..29d11ff 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -337,4 +337,51 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) #endif } +/*! + \qmlproperty int PaintedItem::cacheSize + + 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. +*/ + +/*! + \property QFxPaintedItem::cacheSize + + 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 QFxPaintedItem. +*/ +int QFxPaintedItem::cacheSize() const +{ + Q_D(const QFxPaintedItem); + return d->max_imagecache_size; +} + +void QFxPaintedItem::setCacheSize(int pixels) +{ + Q_D(QFxPaintedItem); + 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; +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h index e086894..b7db2d9 100644 --- a/src/declarative/fx/qfxpainteditem.h +++ b/src/declarative/fx/qfxpainteditem.h @@ -56,12 +56,14 @@ class QFxPaintedItemPrivate; class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem { Q_OBJECT -public: - QFxPaintedItem(QFxItem *parent=0); - ~QFxPaintedItem(); Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize) Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth) + Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize) + +public: + QFxPaintedItem(QFxItem *parent=0); + ~QFxPaintedItem(); #if defined(QFX_RENDER_QPAINTER) void paintContents(QPainter &painter); @@ -74,6 +76,10 @@ public: void setSmooth(bool); void setContentsSize(const QSize &); + + int cacheSize() const; + void setCacheSize(int pixels); + protected: QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent); diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h index d8d1a2a..21ac556 100644 --- a/src/declarative/fx/qfxpainteditem_p.h +++ b/src/declarative/fx/qfxpainteditem_p.h @@ -68,7 +68,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate public: QFxPaintedItemPrivate() - : max_imagecache_size(1000*1000), smooth(false) + : max_imagecache_size(100000), smooth(false) { } @@ -86,7 +86,7 @@ public: QList<ImageCacheItem*> imagecache; - const int max_imagecache_size; + int max_imagecache_size; bool smooth; QSize contentsSize; }; diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index dc7f60e..adb33e8 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -48,6 +48,7 @@ #include <QGraphicsSceneMouseEvent> #include <QtWebKit/QWebPage> #include <QtWebKit/QWebFrame> +#include <QtWebKit/QWebElement> #include "qml.h" #include "qmlbindablevalue.h" @@ -149,47 +150,17 @@ class QFxWebViewPrivate : public QFxPaintedItemPrivate public: QFxWebViewPrivate() : QFxPaintedItemPrivate(), page(0), idealwidth(0), idealheight(0), interactive(true), lastPress(0), lastRelease(0), mouseX(0), mouseY(0), - max_imagecache_size(100000), progress(1.0), pending(PendingNone) + progress(1.0), pending(PendingNone) { } QWebPage *page; - struct ImageCacheItem { - ImageCacheItem() : age(0) {} - ~ImageCacheItem() { } - int age; - QRect area; -#if defined(QFX_RENDER_QPAINTER) - QPixmap image; -#else - GLTexture image; -#endif - }; - QList<ImageCacheItem*> imagecache; - void dirtyCache(const QRect& dirt) - { - for (int i=0; i<imagecache.count(); ) { - if (imagecache[i]->area.intersects(dirt)) { - imagecache.removeAt(i); - } else { - ++i; - } - } - } - void clearCache() - { - foreach (ImageCacheItem* i, imagecache) - delete i; - imagecache.clear(); - } - int idealwidth; int idealheight; bool interactive; QMouseEvent *lastPress, *lastRelease; int mouseX, mouseY; - int max_imagecache_size; qreal progress; QBasicTimer dcTimer; QString statusBarMessage; @@ -459,9 +430,8 @@ void QFxWebView::setInteractive(bool i) void QFxWebView::updateCacheForVisibility() { - Q_D(QFxWebView); if (!isVisible()) - d->clearCache(); + clearCache(); } void QFxWebView::expandToWebPage() @@ -478,7 +448,7 @@ void QFxWebView::expandToWebPage() cs.setHeight(height()); if (cs != page()->viewportSize()) { page()->setViewportSize(cs); - d->clearCache(); + clearCache(); setImplicitWidth(cs.width()); setImplicitHeight(cs.height()); } @@ -501,53 +471,6 @@ void QFxWebView::paintPage(const QRect& r) update(); } -/*! - \qmlproperty int WebView::cacheSize - - 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. -*/ - -/*! - \property QFxWebView::cacheSize - - 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 QFxWebView. -*/ -int QFxWebView::cacheSize() const -{ - Q_D(const QFxWebView); - return d->max_imagecache_size; -} - -void QFxWebView::setCacheSize(int pixels) -{ - Q_D(QFxWebView); - 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; -} - void QFxWebView::dump(int depth) { QByteArray ba(depth * 4, ' '); @@ -787,7 +710,7 @@ QPixmap QFxWebView::icon() const /*! \qmlproperty real WebView::textSizeMultiplier - This property holds multiplier used to scale the text in a Web page + This property holds the multiplier used to scale the text in a Web page */ /*! Sets the value of the multiplier used to scale the text in a Web page to @@ -806,6 +729,31 @@ qreal QFxWebView::textSizeMultiplier() const return page()->mainFrame()->textSizeMultiplier(); } +/*! + \qmlproperty real WebView::zoomFactor + This property holds the multiplier used to scale the contents of a Web page. +*/ +void QFxWebView::setZoomFactor(qreal factor) +{ + Q_D(QFxWebView); + if (factor == page()->mainFrame()->zoomFactor()) + return; + + //reset viewport size so we resize correctly + page()->setViewportSize(QSize( + d->idealwidth>0 ? d->idealwidth : -1, + d->idealheight>0 ? d->idealheight : -1)); + + page()->mainFrame()->setZoomFactor(factor); + expandToWebPage(); + emit zoomFactorChanged(); +} + +qreal QFxWebView::zoomFactor() const +{ + return page()->mainFrame()->zoomFactor(); +} + void QFxWebView::setStatusBarMessage(const QString& s) { Q_D(QFxWebView); diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index f30fd0d..c9a62cc 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -81,6 +81,7 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged) Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false) + Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) Q_PROPERTY(QString status READ status NOTIFY statusChanged) Q_PROPERTY(int mouseX READ mouseX) @@ -95,8 +96,6 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged) - Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize) - Q_PROPERTY(QObject* reload READ reloadAction) Q_PROPERTY(QObject* back READ backAction) Q_PROPERTY(QObject* forward READ forwardAction) @@ -118,12 +117,12 @@ public: qreal textSizeMultiplier() const; void setTextSizeMultiplier(qreal); + qreal zoomFactor() const; + void setZoomFactor(qreal); + bool interactive() const; void setInteractive(bool); - int cacheSize() const; - void setCacheSize(int pixels); - int mouseX() const; int mouseY() const; @@ -170,6 +169,7 @@ Q_SIGNALS: void titleChanged(const QString&); void iconChanged(); void statusChanged(); + void zoomFactorChanged(); void loadStarted(); void loadFinished(); diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp index 2e8c8f6..c90ab47 100644 --- a/src/declarative/qml/qmlcustomparser.cpp +++ b/src/declarative/qml/qmlcustomparser.cpp @@ -136,6 +136,7 @@ QmlCustomParserNodePrivate::fromProperty(QmlParser::Property *p) } else { for(int ii = 0; ii < p->values.count(); ++ii) { Value *v = p->values.at(ii); + v->type = QmlParser::Value::Literal; if(v->object) { QmlCustomParserNode node = fromObject(v->object); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b2c04ca..a304027 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -797,7 +797,7 @@ QPointF QGraphicsItemPrivate::genericMapFromScene(const QPointF &pos, void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransform *viewTransform) const { // COMBINE - if (itemIsUntransformable() && viewTransform) { + if (viewTransform && itemIsUntransformable()) { *x = q_ptr->deviceTransform(*viewTransform); } else { if (transformData) @@ -819,7 +819,7 @@ void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransf void QGraphicsItemPrivate::combineTransformFromParent(QTransform *x, const QTransform *viewTransform) const { // COMBINE - if (itemIsUntransformable() && viewTransform) { + if (viewTransform && itemIsUntransformable()) { *x = q_ptr->deviceTransform(*viewTransform); } else { x->translate(pos.x(), pos.y()); diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 4d4c3b4..6c97886 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1424,6 +1424,63 @@ QGraphicsWidget *QGraphicsScenePrivate::windowForItem(const QGraphicsItem *item) return 0; } +QList<QGraphicsItem *> QGraphicsScenePrivate::topLevelItemsInStackingOrder(const QTransform *const viewTransform, + QRegion *exposedRegion) +{ + if (indexMethod == QGraphicsScene::NoIndex || !exposedRegion) { + if (needSortTopLevelItems) { + needSortTopLevelItems = false; + qStableSort(topLevelItems.begin(), topLevelItems.end(), qt_notclosestLeaf); + } + return topLevelItems; + } + + const QRectF exposedRect = exposedRegion->boundingRect().adjusted(-1, -1, 1, 1); + QRectF sceneRect; + QTransform invertedViewTransform(Qt::Uninitialized); + if (!viewTransform) { + sceneRect = exposedRect; + } else { + invertedViewTransform = viewTransform->inverted(); + sceneRect = invertedViewTransform.mapRect(exposedRect); + } + if (!largestUntransformableItem.isEmpty()) { + // ### Nuke this when we move the indexing code into a separate + // class. All the largestUntransformableItem code should then go + // away, and the estimate function should return untransformable + // items as well. + QRectF untr = largestUntransformableItem; + QRectF ltri = !viewTransform ? untr : invertedViewTransform.mapRect(untr); + ltri.adjust(-untr.width(), -untr.height(), untr.width(), untr.height()); + sceneRect.adjust(-ltri.width(), -ltri.height(), ltri.width(), ltri.height()); + } + + QList<QGraphicsItem *> tmp = estimateItemsInRect(sceneRect); + for (int i = 0; i < tmp.size(); ++i) + tmp.at(i)->topLevelItem()->d_ptr->itemDiscovered = 1; + + // Sort if the toplevel list is unsorted. + if (needSortTopLevelItems) { + needSortTopLevelItems = false; + qStableSort(topLevelItems.begin(), topLevelItems.end(), qt_notclosestLeaf); + } + + QList<QGraphicsItem *> tli; + for (int i = 0; i < topLevelItems.size(); ++i) { + // ### Investigate smarter ways. Looping through all top level + // items is not optimal. If the BSP tree is to have maximum + // effect, it should be possible to sort the subset of items + // quickly. We must use this approach for now, as it's the only + // current way to keep the stable sorting order (insertion order). + QGraphicsItem *item = topLevelItems.at(i); + if (item->d_ptr->itemDiscovered) { + item->d_ptr->itemDiscovered = 0; + tli << item; + } + } + return tli; +} + void QGraphicsScenePrivate::recursive_items_helper(QGraphicsItem *item, QRectF rect, QList<QGraphicsItem *> *items, const QTransform &parentTransform, @@ -5045,165 +5102,118 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte } void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, - const QTransform &viewTransform, + const QTransform *const viewTransform, QRegion *exposedRegion, QWidget *widget, - QList<QGraphicsItem *> *topLevelItems, qreal parentOpacity) { - // Calculate opacity. - qreal opacity; - bool invisibleButChildIgnoresParentOpacity = false; - if (item) { - if (!item->d_ptr->visible) - return; - opacity = item->d_ptr->combineOpacityFromParent(parentOpacity); - if (opacity == 0.0 && !(item->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)) { - invisibleButChildIgnoresParentOpacity = !item->d_ptr->childrenCombineOpacity(); - if (!invisibleButChildIgnoresParentOpacity) - return; - } - } else { - opacity = parentOpacity; - } - - // Item is invisible. - bool hasContents = item && !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents); - bool invisible = !hasContents || invisibleButChildIgnoresParentOpacity; - - // Calculate the full transform for this item. - bool wasDirtyParentSceneTransform = false; - bool dontDrawItem = true; - QTransform transform(Qt::Uninitialized); - if (item) { - if (item->d_ptr->itemIsUntransformable()) { - transform = item->deviceTransform(viewTransform); - } else { - if (item->d_ptr->dirtySceneTransform) { - item->d_ptr->sceneTransform = item->d_ptr->parent ? item->d_ptr->parent->d_ptr->sceneTransform - : QTransform(); - item->d_ptr->combineTransformFromParent(&item->d_ptr->sceneTransform); - item->d_ptr->dirtySceneTransform = 0; - wasDirtyParentSceneTransform = true; - } - transform = item->d_ptr->sceneTransform; - transform *= viewTransform; - } - - if (!invisible) { - QRectF brect = item->boundingRect(); - // ### This does not take the clip into account. - _q_adjustRect(&brect); - QRect viewBoundingRect = transform.mapRect(brect).toRect(); - item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect); - viewBoundingRect.adjust(-1, -1, 1, 1); - if (exposedRegion) - dontDrawItem = !exposedRegion->intersects(viewBoundingRect); - else - dontDrawItem = viewBoundingRect.isEmpty(); - } - } + Q_ASSERT(item); - // Find and sort children. - QList<QGraphicsItem *> tmp; - QList<QGraphicsItem *> *children = 0; - if (item) { - children = &item->d_ptr->children; - } else if (topLevelItems) { - children = topLevelItems; - } else if (indexMethod == QGraphicsScene::NoIndex || !exposedRegion) { - children = &this->topLevelItems; - } else { - QRectF sceneRect = viewTransform.inverted().mapRect(QRectF(exposedRegion->boundingRect().adjusted(-1, -1, 1, 1))); - if (!largestUntransformableItem.isEmpty()) { - // ### Nuke this when we move the indexing code into a separate - // class. All the largestUntransformableItem code should then go - // away, and the estimate function should return untransformable - // items as well. - QRectF untr = largestUntransformableItem; - QRectF ltri = viewTransform.inverted().mapRect(untr); - ltri.adjust(-untr.width(), -untr.height(), untr.width(), untr.height()); - sceneRect.adjust(-ltri.width(), -ltri.height(), ltri.width(), ltri.height()); - } - tmp = estimateItemsInRect(sceneRect); + if (!item->d_ptr->visible) + return; - QList<QGraphicsItem *> tli; - for (int i = 0; i < tmp.size(); ++i) - tmp.at(i)->topLevelItem()->d_ptr->itemDiscovered = 1; + const bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents); + const bool itemHasChildren = !item->d_ptr->children.isEmpty(); + if (!itemHasContents && !itemHasChildren) + return; // Item has neither contents nor children!(?) - // Sort if the toplevel list is unsorted. - if (needSortTopLevelItems) { - needSortTopLevelItems = false; - qStableSort(this->topLevelItems.begin(), - this->topLevelItems.end(), qt_notclosestLeaf); - } + const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity); + const bool itemIsFullyTransparent = (opacity < 0.0001); + if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity())) + return; - for (int i = 0; i < this->topLevelItems.size(); ++i) { - // ### Investigate smarter ways. Looping through all top level - // items is not optimal. If the BSP tree is to have maximum - // effect, it should be possible to sort the subset of items - // quickly. We must use this approach for now, as it's the only - // current way to keep the stable sorting order (insertion order). - QGraphicsItem *item = this->topLevelItems.at(i); - if (item->d_ptr->itemDiscovered) { - item->d_ptr->itemDiscovered = 0; - tli << item; + QTransform transform(Qt::Uninitialized); + QTransform *transformPtr = 0; +#define ENSURE_TRANSFORM_PTR \ + if (!transformPtr) { \ + Q_ASSERT(!itemIsUntransformable); \ + if (viewTransform) { \ + transform = item->d_ptr->sceneTransform; \ + transform *= *viewTransform; \ + transformPtr = &transform; \ + } else { \ + transformPtr = &item->d_ptr->sceneTransform; \ + } \ + } + + // Update the item's scene transform if the item is transformable; + // otherwise calculate the full transform, + bool wasDirtyParentSceneTransform = false; + const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable(); + if (itemIsUntransformable) { + transform = item->deviceTransform(viewTransform ? *viewTransform : QTransform()); + transformPtr = &transform; + } else if (item->d_ptr->dirtySceneTransform) { + item->d_ptr->sceneTransform = item->d_ptr->parent ? item->d_ptr->parent->d_ptr->sceneTransform + : QTransform(); + item->d_ptr->combineTransformFromParent(&item->d_ptr->sceneTransform); + item->d_ptr->dirtySceneTransform = 0; + wasDirtyParentSceneTransform = true; + } + + const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape); + bool drawItem = itemHasContents && !itemIsFullyTransparent; + if (drawItem) { + const QRectF brect = adjustedItemBoundingRect(item); + ENSURE_TRANSFORM_PTR + QRect viewBoundingRect = transformPtr->mapRect(brect).toRect(); + item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect); + viewBoundingRect.adjust(-1, -1, 1, 1); + drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect) : !viewBoundingRect.isEmpty(); + if (!drawItem) { + if (!itemHasChildren) + return; + if (itemClipsChildrenToShape) { + if (wasDirtyParentSceneTransform) + item->d_ptr->invalidateChildrenSceneTransform(); + return; } } + } // else we know for sure this item has children we must process. - tmp = tli; - children = &tmp; - } - - bool childClip = (item && (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)); - bool dontDrawChildren = item && hasContents && dontDrawItem && childClip; - childClip &= !dontDrawChildren && !children->isEmpty(); - if (item && invisible) - dontDrawItem = true; - - // Clip children. - if (childClip) { - painter->save(); - painter->setWorldTransform(transform); - painter->setClipPath(item->shape(), Qt::IntersectClip); - } - - if (!dontDrawChildren) { - if (item && item->d_ptr->needSortChildren) { + int i = 0; + if (itemHasChildren) { + if (item->d_ptr->needSortChildren) { item->d_ptr->needSortChildren = 0; - qStableSort(children->begin(), children->end(), qt_notclosestLeaf); - } else if (!item && needSortTopLevelItems && children != &tmp) { - needSortTopLevelItems = false; - qStableSort(children->begin(), children->end(), qt_notclosestLeaf); + qStableSort(item->d_ptr->children.begin(), item->d_ptr->children.end(), qt_notclosestLeaf); } - } - // Draw children behind - int i = 0; - if (!dontDrawChildren) { - // ### Don't visit children that don't ignore parent opacity if this - // item is invisible. - for (i = 0; i < children->size(); ++i) { - QGraphicsItem *child = children->at(i); + if (itemClipsChildrenToShape) { + painter->save(); + ENSURE_TRANSFORM_PTR + painter->setWorldTransform(*transformPtr); + painter->setClipPath(item->shape(), Qt::IntersectClip); + } + + // Draw children behind + for (i = 0; i < item->d_ptr->children.size(); ++i) { + QGraphicsItem *child = item->d_ptr->children.at(i); if (wasDirtyParentSceneTransform) child->d_ptr->dirtySceneTransform = 1; if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent)) break; - drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, - 0, opacity); + if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity)) + continue; + drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity); } } // Draw item - if (!dontDrawItem) { - item->d_ptr->initStyleOption(&styleOptionTmp, transform, exposedRegion ? *exposedRegion : QRegion(), exposedRegion == 0); - - bool clipsToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsToShape); - bool savePainter = clipsToShape || painterStateProtection; + if (drawItem) { + Q_ASSERT(!itemIsFullyTransparent); + Q_ASSERT(itemHasContents); + item->d_ptr->initStyleOption(&styleOptionTmp, transform, exposedRegion + ? *exposedRegion : QRegion(), exposedRegion == 0); + + const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape; + const bool savePainter = itemClipsToShape || painterStateProtection; if (savePainter) painter->save(); - if (!childClip) - painter->setWorldTransform(transform); - if (clipsToShape) + + if (!itemHasChildren || !itemClipsChildrenToShape) { + ENSURE_TRANSFORM_PTR + painter->setWorldTransform(*transformPtr); + } + if (itemClipsToShape) painter->setClipPath(item->shape(), Qt::IntersectClip); painter->setOpacity(opacity); @@ -5217,22 +5227,19 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * } // Draw children in front - if (!dontDrawChildren) { - // ### Don't visit children that don't ignore parent opacity if this - // item is invisible. - for (; i < children->size(); ++i) { - QGraphicsItem *child = children->at(i); + if (itemHasChildren) { + for (; i < item->d_ptr->children.size(); ++i) { + QGraphicsItem *child = item->d_ptr->children.at(i); if (wasDirtyParentSceneTransform) child->d_ptr->dirtySceneTransform = 1; - drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, - widget, 0, opacity); + if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity)) + continue; + drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity); } - } else if (wasDirtyParentSceneTransform) { - item->d_ptr->invalidateChildrenSceneTransform(); } // Restore child clip - if (childClip) + if (itemHasChildren && itemClipsChildrenToShape) painter->restore(); } @@ -5525,7 +5532,7 @@ void QGraphicsScene::drawItems(QPainter *painter, if (!item->d_ptr->itemDiscovered) { topLevelItems << item; item->d_ptr->itemDiscovered = 1; - d->drawSubtreeRecursive(item, painter, viewTransform, expose, widget); + d->drawSubtreeRecursive(item, painter, &viewTransform, expose, widget); } } diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index a8f6699..2f63e5b 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -206,6 +206,7 @@ public: void mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent); QGraphicsWidget *windowForItem(const QGraphicsItem *item) const; + QList<QGraphicsItem *> topLevelItemsInStackingOrder(const QTransform *const, QRegion *); void recursive_items_helper(QGraphicsItem *item, QRectF rect, QList<QGraphicsItem *> *items, const QTransform &parentTransform, const QTransform &viewTransform, Qt::ItemSelectionMode mode, Qt::SortOrder order, qreal parentOpacity = 1.0) const; @@ -259,10 +260,18 @@ public: void drawItemHelper(QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget, bool painterStateProtection); - - void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform &viewTransform, - QRegion *exposedRegion, QWidget *widget, - QList<QGraphicsItem *> *topLevelItems = 0, qreal parentOpacity = qreal(1.0)); + + inline void drawItems(QPainter *painter, const QTransform *const viewTransform, + QRegion *exposedRegion, QWidget *widget) + { + const QList<QGraphicsItem *> tli = topLevelItemsInStackingOrder(viewTransform, exposedRegion); + for (int i = 0; i < tli.size(); ++i) + drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget); + return; + } + + void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform *const, + QRegion *exposedRegion, QWidget *widget, qreal parentOpacity = qreal(1.0)); void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false, bool maybeDirtyClipPath = false, bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false); diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 553d71c..1ba87ec 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3298,8 +3298,8 @@ void QGraphicsView::paintEvent(QPaintEvent *event) // Items if (!(d->optimizationFlags & IndirectPainting)) { - d->scene->d_func()->drawSubtreeRecursive(0, &painter, viewTransform, &d->exposedRegion, - viewport(), 0); + d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0, + &d->exposedRegion, viewport()); } else { // Find all exposed items bool allItems = false; diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 942836a..babc5df 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -1085,10 +1085,8 @@ static void qt_set_input_encoding() } // Reads a KDE color setting -static QColor kdeColor(const QString &key) +static QColor kdeColor(const QString &key, const QSettings &kdeSettings) { - QSettings kdeSettings(QApplicationPrivate::kdeHome() + - QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); QVariant variant = kdeSettings.value(key); if (variant.isValid()) { QStringList values = variant.toStringList(); @@ -1307,36 +1305,40 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0, } if (kdeColors) { + const QSettings &theKdeSettings = + QSettings(QApplicationPrivate::kdeHome() + + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); + // Setup KDE palette QColor color; - color = kdeColor(QLatin1String("buttonBackground")); + color = kdeColor(QLatin1String("buttonBackground"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Button/BackgroundNormal")); + color = kdeColor(QLatin1String("Colors:Button/BackgroundNormal"), theKdeSettings); if (color.isValid()) btn = color; - color = kdeColor(QLatin1String("background")); + color = kdeColor(QLatin1String("background"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Window/BackgroundNormal")); + color = kdeColor(QLatin1String("Colors:Window/BackgroundNormal"), theKdeSettings); if (color.isValid()) bg = color; - color = kdeColor(QLatin1String("foreground")); + color = kdeColor(QLatin1String("foreground"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:View/ForegroundNormal")); + color = kdeColor(QLatin1String("Colors:View/ForegroundNormal"), theKdeSettings); if (color.isValid()) { fg = color; } - color = kdeColor(QLatin1String("windowForeground")); + color = kdeColor(QLatin1String("windowForeground"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Window/ForegroundNormal")); + color = kdeColor(QLatin1String("Colors:Window/ForegroundNormal"), theKdeSettings); if (color.isValid()) wfg = color; - color = kdeColor(QLatin1String("windowBackground")); + color = kdeColor(QLatin1String("windowBackground"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:View/BackgroundNormal")); + color = kdeColor(QLatin1String("Colors:View/BackgroundNormal"), theKdeSettings); if (color.isValid()) base = color; } @@ -1355,29 +1357,33 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0, } // Use KDE3 or KDE4 color settings if present if (kdeColors) { - QColor color = kdeColor(QLatin1String("selectBackground")); + const QSettings &theKdeSettings = + QSettings(QApplicationPrivate::kdeHome() + + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); + + QColor color = kdeColor(QLatin1String("selectBackground"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Selection/BackgroundNormal")); + color = kdeColor(QLatin1String("Colors:Selection/BackgroundNormal"), theKdeSettings); if (color.isValid()) highlight = color; - color = kdeColor(QLatin1String("selectForeground")); + color = kdeColor(QLatin1String("selectForeground"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Selection/ForegroundNormal")); + color = kdeColor(QLatin1String("Colors:Selection/ForegroundNormal"), theKdeSettings); if (color.isValid()) highlightText = color; - color = kdeColor(QLatin1String("alternateBackground")); + color = kdeColor(QLatin1String("alternateBackground"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:View/BackgroundAlternate")); + color = kdeColor(QLatin1String("Colors:View/BackgroundAlternate"), theKdeSettings); if (color.isValid()) pal.setColor(QPalette::AlternateBase, color); else pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110)); - color = kdeColor(QLatin1String("buttonForeground")); + color = kdeColor(QLatin1String("buttonForeground"), theKdeSettings); if (!color.isValid()) - color = kdeColor(QLatin1String("Colors:Button/ForegroundNormal")); + color = kdeColor(QLatin1String("Colors:Button/ForegroundNormal"), theKdeSettings); if (color.isValid()) pal.setColor(QPalette::ButtonText, color); } diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index 62addd3..221267f 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -198,7 +198,7 @@ QT_BEGIN_NAMESPACE QMatrix member functions *****************************************************************************/ /*! - \fn QMatrix::QMatrix(Qt::Uninitialized) + \fn QMatrix::QMatrix(Qt::Initialization) \internal */ diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index b2e5d70..aa4177c 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -61,7 +61,7 @@ class QVariant; class Q_GUI_EXPORT QMatrix // 2D transform matrix { public: - inline explicit QMatrix(enum Qt::Uninitialized) {} + inline explicit QMatrix(Qt::Initialization) {} QMatrix(); QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 78515ac..37f7b6d 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1771,10 +1771,10 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) static inline QRect toNormalizedFillRect(const QRectF &rect) { - int x1 = int(rect.x() + aliasedCoordinateDelta); - int y1 = int(rect.y() + aliasedCoordinateDelta); - int x2 = int(rect.right() + aliasedCoordinateDelta); - int y2 = int(rect.bottom() + aliasedCoordinateDelta); + int x1 = qRound(rect.x() + aliasedCoordinateDelta); + int y1 = qRound(rect.y() + aliasedCoordinateDelta); + int x2 = qRound(rect.right() + aliasedCoordinateDelta); + int y2 = qRound(rect.bottom() + aliasedCoordinateDelta); if (x2 < x1) qSwap(x1, x2); diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h index f94c353..30c22b2 100644 --- a/src/gui/painting/qstroker_p.h +++ b/src/gui/painting/qstroker_p.h @@ -179,7 +179,7 @@ private: }; -class QStroker : public QStrokerOps +class Q_GUI_EXPORT QStroker : public QStrokerOps { public: diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 85adb27..f0b2351 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -232,7 +232,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QTransform::QTransform(Qt::Uninitialized) + \fn QTransform::QTransform(Qt::Initialization) \internal */ diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index f99b0e7..291d35c 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -71,7 +71,7 @@ public: TxProject = 0x10 }; - inline explicit QTransform(enum Qt::Uninitialized) : affine(Qt::Uninitialized) {} + inline explicit QTransform(Qt::Initialization) : affine(Qt::Uninitialized) {} QTransform(); QTransform(qreal h11, qreal h12, qreal h13, qreal h21, qreal h22, qreal h23, diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 135bcda..3125304 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -155,6 +155,11 @@ QSize QDockAreaLayoutItem::maximumSize() const return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); } +bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const +{ + return perp(o, minimumSize()) == perp(o, maximumSize()); +} + bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const { if ((flags & GapItem) || placeHolderItem != 0) @@ -216,7 +221,7 @@ static quintptr tabId(const QDockAreaLayoutItem &item) #endif QDockAreaLayoutInfo::QDockAreaLayoutInfo() - : sep(0), dockPos(QInternal::LeftDock), o(Qt::Horizontal), rect(0, 0, -1, -1), mainWindow(0) + : sep(0), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0) #ifndef QT_NO_TABBAR , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) #endif @@ -226,7 +231,7 @@ QDockAreaLayoutInfo::QDockAreaLayoutInfo() QDockAreaLayoutInfo::QDockAreaLayoutInfo(int _sep, QInternal::DockPosition _dockPos, Qt::Orientation _o, int tbshape, QMainWindow *window) - : sep(_sep), dockPos(_dockPos), o(_o), rect(0, 0, -1, -1), mainWindow(window) + : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window) #ifndef QT_NO_TABBAR , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) #endif @@ -244,7 +249,7 @@ QSize QDockAreaLayoutInfo::size() const void QDockAreaLayoutInfo::clear() { item_list.clear(); - rect = QRect(0, 0, -1, -1); + rect = QRect(); #ifndef QT_NO_TABBAR tabbed = false; tabBar = 0; @@ -388,10 +393,9 @@ QSize QDockAreaLayoutInfo::sizeHint() const return QSize(0, 0); int a = 0, b = 0; - bool prev_gap = false; - bool first = true; int min_perp = 0; int max_perp = QWIDGETSIZE_MAX; + const QDockAreaLayoutItem *previous = 0; for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -409,14 +413,15 @@ QSize QDockAreaLayoutInfo::sizeHint() const } else #endif { - if (!first && !gap && !prev_gap) + if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem) + && !previous->hasFixedSize(o)) { a += sep; + } a += gap ? item.size : pick(o, size_hint); } b = qMax(b, perp(o, size_hint)); - prev_gap = gap; - first = false; + previous = &item; } max_perp = qMax(max_perp, min_perp); @@ -539,21 +544,20 @@ void QDockAreaLayoutInfo::fitItems() int max_size = realMaxSize(*this); int last_index = -1; - bool prev_gap = false; - bool first = true; + const QDockAreaLayoutItem *previous = 0; for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.skip()) continue; bool gap = item.flags & QDockAreaLayoutItem::GapItem; - if (!first && !gap && !prev_gap) { - QLayoutStruct &ls = layout_struct_list[j++]; - ls.init(); - ls.minimumSize = sep; - ls.maximumSize = sep; - ls.sizeHint = sep; - ls.empty = false; + if (previous && !gap) { + if (!(previous->flags & QDockAreaLayoutItem::GapItem)) { + QLayoutStruct &ls = layout_struct_list[j++]; + ls.init(); + ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : sep; + ls.empty = false; + } } if (item.flags & QDockAreaLayoutItem::KeepSize) { @@ -592,8 +596,7 @@ void QDockAreaLayoutInfo::fitItems() } item.flags &= ~QDockAreaLayoutItem::KeepSize; - prev_gap = gap; - first = false; + previous = &item; } layout_struct_list.resize(j); @@ -607,8 +610,8 @@ void QDockAreaLayoutInfo::fitItems() qGeomCalc(layout_struct_list, 0, j, pick(o, rect.topLeft()), size, 0); j = 0; - prev_gap = false; - first = true; + bool prev_gap = false; + bool first = true; for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.skip()) @@ -1408,11 +1411,12 @@ QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const if (next == -1 || (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) continue; - int margin = (sep == 1? 2 : 0); - if (pos >= item.pos + item.size - margin && item.pos + item.size + sep + margin > pos) { - QList<int> result; - result.append(i); - return result; + QRect sepRect = separatorRect(i); + if (!sepRect.isNull() && sep == 1) + sepRect.adjust(-2, -2, 2, 2); + //we also make sure we don't find a separator that's not there + if (sepRect.contains(_pos) && !item.hasFixedSize(o)) { + return QList<int>() << i; } } @@ -1478,6 +1482,12 @@ QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const return result; } +bool QDockAreaLayoutInfo::hasFixedSize() const +{ + return perp(o, minimumSize()) == perp(o, maximumSize()); +} + + void QDockAreaLayoutInfo::apply(bool animate) { QWidgetAnimator *widgetAnimator = mainWindowLayout()->widgetAnimator; @@ -1629,7 +1639,7 @@ void QDockAreaLayoutInfo::paintSeparators(QPainter *p, QWidget *widget, if (next == -1) break; QRect r = separatorRect(i); - if (clip.contains(r)) + if (clip.contains(r) && !item.hasFixedSize(o)) paintSep(p, widget, r, o, r.contains(mouse)); } } @@ -2009,10 +2019,8 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> void QDockAreaLayoutInfo::updateSeparatorWidgets() const { - QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this); - if (tabbed) { - that->separatorWidgets.clear(); + separatorWidgets.clear(); return; } @@ -2040,7 +2048,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const sepWidget = separatorWidgets.at(j); } else { sepWidget = mainWindowLayout()->getSeparatorWidget(); - that->separatorWidgets.append(sepWidget); + separatorWidgets.append(sepWidget); } j++; @@ -2053,10 +2061,10 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const sepWidget->show(); } - for (int k = j; k < that->separatorWidgets.size(); ++k) { - that->separatorWidgets[k]->hide(); + for (int k = j; k < separatorWidgets.size(); ++k) { + separatorWidgets[k]->hide(); } - that->separatorWidgets.resize(j); + separatorWidgets.resize(j); Q_ASSERT(separatorWidgets.size() == j); } @@ -2271,7 +2279,7 @@ QDockAreaLayout::QDockAreaLayout(QMainWindow *win) docks[QInternal::BottomDock] = QDockAreaLayoutInfo(sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win); centralWidgetItem = 0; - centralWidgetRect = QRect(0, 0, -1, -1); + corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea; corners[Qt::TopRightCorner] = Qt::TopDockWidgetArea; @@ -2442,9 +2450,9 @@ QList<int> QDockAreaLayout::findSeparator(const QPoint &pos) const if (info.isEmpty()) continue; QRect rect = separatorRect(i); - if (sep == 1) + if (!rect.isNull() && sep == 1) rect.adjust(-2, -2, 2, 2); - if (rect.contains(pos)) { + if (rect.contains(pos) && !info.hasFixedSize()) { result << i; break; } else if (info.rect.contains(pos)) { @@ -2504,9 +2512,10 @@ QRect QDockAreaLayout::itemRect(QList<int> path) const QRect QDockAreaLayout::separatorRect(int index) const { - if (docks[index].isEmpty()) + const QDockAreaLayoutInfo &dock = docks[index]; + if (dock.isEmpty()) return QRect(); - QRect r = docks[index].rect; + QRect r = dock.rect; switch (index) { case QInternal::LeftDock: return QRect(r.right() + 1, r.top(), sep, r.height()); @@ -2854,8 +2863,8 @@ void QDockAreaLayout::clear() for (int i = 0; i < QInternal::DockCount; ++i) docks[i].clear(); - rect = QRect(0, 0, -1, -1); - centralWidgetRect = QRect(0, 0, -1, -1); + rect = QRect(); + centralWidgetRect = QRect(); } QSize QDockAreaLayout::sizeHint() const @@ -3080,7 +3089,7 @@ void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget, if (dock.isEmpty()) continue; QRect r = separatorRect(i); - if (clip.contains(r)) { + if (clip.contains(r) && !dock.hasFixedSize()) { Qt::Orientation opposite = dock.o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal; paintSep(p, widget, r, opposite, r.contains(mouse)); @@ -3154,8 +3163,6 @@ int QDockAreaLayout::separatorMove(QList<int> separator, const QPoint &origin, // Allocates new sepearator widgets with getSeparatorWidget void QDockAreaLayout::updateSeparatorWidgets() const { - QDockAreaLayout *that = const_cast<QDockAreaLayout*>(this); - int j = 0; for (int i = 0; i < QInternal::DockCount; ++i) { @@ -3168,7 +3175,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const sepWidget = separatorWidgets.at(j); } else { sepWidget = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->getSeparatorWidget(); - that->separatorWidgets.append(sepWidget); + separatorWidgets.append(sepWidget); } j++; @@ -3183,7 +3190,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const for (int i = j; i < separatorWidgets.size(); ++i) separatorWidgets.at(i)->hide(); - that->separatorWidgets.resize(j); + separatorWidgets.resize(j); } QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h index 0b8d832..137aeba 100644 --- a/src/gui/widgets/qdockarealayout_p.h +++ b/src/gui/widgets/qdockarealayout_p.h @@ -103,6 +103,7 @@ struct QDockAreaLayoutItem QSize maximumSize() const; QSize sizeHint() const; bool expansive(Qt::Orientation o) const; + bool hasFixedSize(Qt::Orientation o) const; QLayoutItem *widgetItem; QDockAreaLayoutInfo *subinfo; @@ -167,6 +168,7 @@ public: void clear(); bool isEmpty() const; + bool hasFixedSize() const; QList<int> findSeparator(const QPoint &pos) const; int next(int idx) const; int prev(int idx) const; @@ -188,7 +190,7 @@ public: QMainWindowLayout *mainWindowLayout() const; int sep; - QVector<QWidget*> separatorWidgets; + mutable QVector<QWidget*> separatorWidgets; QInternal::DockPosition dockPos; Qt::Orientation o; QRect rect; @@ -231,7 +233,7 @@ public: QDockAreaLayout(QMainWindow *win); QDockAreaLayoutInfo docks[4]; int sep; // separator extent - QVector<QWidget*> separatorWidgets; + mutable QVector<QWidget*> separatorWidgets; bool isValid() const; diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 308f956..10e07d3 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -490,10 +490,10 @@ void QMainWindowLayoutState::clear() #ifndef QT_NO_DOCKWIDGET dockAreaLayout.clear(); #else - centralWidgetRect = QRect(0, 0, -1, -1); + centralWidgetRect = QRect(); #endif - rect = QRect(0, 0, -1, -1); + rect = QRect(); } bool QMainWindowLayoutState::isValid() const diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 6bbf4e8..fc55a2c 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1826,7 +1826,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if (d->scroll && d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) { int below_height = above_height + d->scroll->scrollOffset; - for(int i2 = i; i2 < (int)d->actionList.count(); i2++) + for(int i2 = i; i2 < d->actionList.count(); i2++) below_height += d->actionRects.value(d->actionList.at(i2)).height(); size.setHeight(below_height); } @@ -2263,7 +2263,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e) break; } } - if (e->button() == Qt::LeftButton || (e->button() == Qt::RightButton && isContextMenu)) + if (e->button() || isContextMenu) #endif d->activateAction(action, QAction::Trigger); } @@ -2746,7 +2746,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) if (d->hasHadMouse && !rect().contains(e->pos())) d->setCurrentAction(0); return; - } else if(e->buttons() & (Qt::LeftButton | Qt::RightButton)) { + } else if(e->buttons()) { d->mouseDown = this; } if (d->sloppyRegion.contains(e->pos())) { diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index efacd00..4977b31 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -1029,15 +1029,14 @@ void QPlainTextEditPrivate::ensureViewportLayouted() \section1 Using QPlainTextEdit as a Display Widget - The text is set or replaced using setPlainText() which deletes any - existing text and replaces it with the text passed in the - setPlainText() call. + The text is set or replaced using setPlainText() which deletes the + existing text and replaces it with the text passed to setPlainText(). - Text itself can be inserted using the QTextCursor class or using - the convenience functins insertPlainText(), appendPlainText() or + Text can be inserted using the QTextCursor class or using the + convenience functions insertPlainText(), appendPlainText() or paste(). - By default the text edit wraps words at whitespace to fit within + By default, the text edit wraps words at whitespace to fit within the text edit widget. The setLineWrapMode() function is used to specify the kind of line wrap you want, \l WidgetWidth or \l NoWrap if you don't want any wrapping. If you use word wrap to diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index aaab885..8a10355 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -567,7 +567,7 @@ bool QToolBarAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *item) void QToolBarAreaLayoutInfo::clear() { lines.clear(); - rect = QRect(0, 0, -1, -1); + rect = QRect(); } QRect QToolBarAreaLayoutInfo::itemRect(QList<int> path) const @@ -1101,7 +1101,7 @@ void QToolBarAreaLayout::clear() { for (int i = 0; i < QInternal::DockCount; ++i) docks[i].clear(); - rect = QRect(0, 0, -1, -1); + rect = QRect(); } QToolBarAreaLayoutItem &QToolBarAreaLayout::item(QList<int> path) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index ed2f220..907aaef 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -112,8 +112,6 @@ static void ensureInitialized() are supplied that take a request and optional data, and each return a QNetworkReply object. The returned object is used to obtain any data returned in response to the corresponding request. - the reply to is where most of the signals as well - as the downloaded data are posted. A simple download off the network could be accomplished with: \snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 0 @@ -122,7 +120,8 @@ static void ensureInitialized() takes is the QNetworkReply object containing the downloaded data as well as meta-data (headers, etc.). - \note The slot is responsible for deleting the object at that point. + \note After the request has finished, it is the responsibility of the user + to delete the QNetworkReply object at an appropriate time. A more involved example, assuming the manager is already existent, can be: diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index 5df6b0f..50aaa6a 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -81,6 +81,20 @@ QT_BEGIN_NAMESPACE use on the system to 50MB. Note you have to set the cache directory before it will work. + + A network disk cache can be enabled by: + + \snippet doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp 0 + + When sending requests, to control the preference of when to use the cache + and when to use the network, consider the following: + + \snippet doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp 1 + + To check whether the response came from the cache or from the network, the + following can be applied: + + \snippet doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp 2 */ /*! diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 1c86466..9dc7818 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -237,6 +237,7 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) w = rect.width(); h = rect.height(); d = otherData->d; + is_null = (w <= 0 || h <= 0); DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0); #if (Q_DIRECTFB_VERSION >= 0x010000) dfbSurface->ReleaseSource(dfbSurface); @@ -330,6 +331,8 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, data->dfbSurface->StretchBlit(data->dfbSurface, dfbSurface, 0, &destRect); data->w = size.width(); data->h = size.height(); + data->is_null = (data->w <= 0 || data->h <= 0); + #if (Q_DIRECTFB_VERSION >= 0x010000) data->dfbSurface->ReleaseSource(data->dfbSurface); #endif diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index ad6c38e..e81aef4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -60,22 +60,23 @@ public: ~QDirectFBPixmapData(); // Re-implemented from QPixmapData: - void resize(int width, int height); - void fromImage(const QImage &image, Qt::ImageConversionFlags flags); - void copy(const QPixmapData *data, const QRect &rect); - void fill(const QColor &color); - inline bool hasAlphaChannel() const { return alpha; } - QPixmap transformed(const QTransform &matrix, - Qt::TransformationMode mode) const; - QImage toImage() const; - QPaintEngine* paintEngine() const; + virtual void resize(int width, int height); + virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags); + virtual void copy(const QPixmapData *data, const QRect &rect); + virtual void fill(const QColor &color); + virtual QPixmap transformed(const QTransform &matrix, + Qt::TransformationMode mode) const; + virtual QImage toImage() const; + virtual QPaintEngine *paintEngine() const; virtual QImage *buffer(); + virtual int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);} + QImage *buffer(uint lockFlags); // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice - int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);} inline QImage::Format pixelFormat() const { return format; } static bool hasAlphaChannel(const QImage &img); + inline bool hasAlphaChannel() const { return alpha; } private: void invalidate(); QDirectFBPaintEngine *engine; diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp index b6ca82d..1a82377 100644 --- a/src/sql/drivers/db2/qsql_db2.cpp +++ b/src/sql/drivers/db2/qsql_db2.cpp @@ -1043,26 +1043,22 @@ QVariant QDB2Result::data(int field) case QVariant::Double: { QString value=qGetStringData(d->hStmt, field, info.length() + 1, isNull); - bool ok=false; - switch(d->precisionPolicy) { + switch(numericalPrecisionPolicy()) { case QSql::LowPrecisionInt32: - v = new QVariant(value.toInt(&ok)); + v = new QVariant(qGetIntData(d->hStmt, field, isNull)); break; case QSql::LowPrecisionInt64: - v = new QVariant(value.toLongLong(&ok)); + v = new QVariant(qGetBigIntData(d->hStmt, field, isNull)); break; case QSql::LowPrecisionDouble: - v = new QVariant(value.toDouble(&ok)); + v = new QVariant(qGetDoubleData(d->hStmt, field, isNull)); break; case QSql::HighPrecision: default: // length + 1 for the comma - v = new QVariant(value); - ok = true; + v = new QVariant(qGetStringData(d->hStmt, field, info.length() + 1, isNull)); break; } - if(!ok) - v = new QVariant(); break; } case QVariant::String: @@ -1146,6 +1142,10 @@ void QDB2Result::virtual_hook(int id, void *data) Q_ASSERT(data); *static_cast<bool*>(data) = nextResult(); break; + case QSqlResult::DetachFromResultSet: + if (d->hStmt) + SQLCloseCursor(d->hStmt); + break; default: QSqlResult::virtual_hook(id, data); } @@ -1177,7 +1177,7 @@ QDB2Driver::~QDB2Driver() delete d; } -bool QDB2Driver::open(const QString& db, const QString& user, const QString& password, const QString&, int, +bool QDB2Driver::open(const QString& db, const QString& user, const QString& password, const QString& host, int port, const QString& connOpts) { if (isOpen()) @@ -1200,6 +1200,8 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas setOpenError(true); return false; } + + QString protocol; // Set connection attributes const QStringList opts(connOpts.split(QLatin1Char(';'), QString::SkipEmptyParts)); for (int i = 0; i < opts.count(); ++i) { @@ -1230,7 +1232,10 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas } else if (opt == QLatin1String("SQL_ATTR_LOGIN_TIMEOUT")) { v = val.toUInt(); r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) v, 0); - } else { + } else if (opt.compare(QLatin1String("PROTOCOL"), Qt::CaseInsensitive) == 0) { + protocol = tmp; + } + else { qWarning("QDB2Driver::open: Unknown connection attribute '%s'", tmp.toLocal8Bit().constData()); } @@ -1239,9 +1244,18 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas "Unable to set connection attribute '%1'").arg(opt), d); } + if (protocol.isEmpty()) + protocol = QLatin1String("PROTOCOL=TCPIP"); + + if (port < 0 ) + port = 50000; + QString connQStr; - connQStr = QLatin1String("DSN=") + db + QLatin1String(";UID=") + user + QLatin1String(";PWD=") - + password; + connQStr = protocol + QLatin1String(";DATABASE=") + db + QLatin1String(";HOSTNAME=") + host + + QLatin1String(";PORT=") + QString::number(port) + QLatin1String(";UID=") + user + + QLatin1String(";PWD=") + password; + + SQLTCHAR connOut[SQL_MAX_OPTION_STRING_LENGTH]; SQLSMALLINT cb; @@ -1260,7 +1274,7 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas return false; } - d->user = user.toUpper(); + d->user = user; setOpen(true); setOpenError(false); return true; @@ -1305,10 +1319,25 @@ QSqlRecord QDB2Driver::record(const QString& tableName) const SQLHANDLE hStmt; QString catalog, schema, table; - qSplitTableQualifier(tableName.toUpper(), &catalog, &schema, &table); + qSplitTableQualifier(tableName, &catalog, &schema, &table); if (schema.isEmpty()) schema = d->user; + if (isIdentifierEscaped(catalog, QSqlDriver::TableName)) + catalog = stripDelimiters(catalog, QSqlDriver::TableName); + else + catalog = catalog.toUpper(); + + if (isIdentifierEscaped(schema, QSqlDriver::TableName)) + schema = stripDelimiters(schema, QSqlDriver::TableName); + else + schema = schema.toUpper(); + + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + else + table = table.toUpper(); + SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT, d->hDbc, &hStmt); @@ -1322,6 +1351,9 @@ QSqlRecord QDB2Driver::record(const QString& tableName) const (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY, SQL_IS_UINTEGER); + + //Aside: szSchemaName and szTableName parameters of SQLColumns + //are case sensitive search patterns, so no escaping is used. r = SQLColumns(hStmt, NULL, 0, @@ -1402,7 +1434,13 @@ QStringList QDB2Driver::tables(QSql::TableType type) const bool isNull; QString fieldVal = qGetStringData(hStmt, 2, -1, isNull); QString userVal = qGetStringData(hStmt, 1, -1, isNull); - if (userVal != d->user) + QString user = d->user; + if ( isIdentifierEscaped(user, QSqlDriver::TableName)) + user = stripDelimiters(user, QSqlDriver::TableName); + else + user = user.toUpper(); + + if (userVal != user) fieldVal = userVal + QLatin1Char('.') + fieldVal; tl.append(fieldVal); r = SQLFetchScroll(hStmt, @@ -1433,7 +1471,23 @@ QSqlIndex QDB2Driver::primaryIndex(const QString& tablename) const return index; } QString catalog, schema, table; - qSplitTableQualifier(tablename.toUpper(), &catalog, &schema, &table); + qSplitTableQualifier(tablename, &catalog, &schema, &table); + + if (isIdentifierEscaped(catalog, QSqlDriver::TableName)) + catalog = stripDelimiters(catalog, QSqlDriver::TableName); + else + catalog = catalog.toUpper(); + + if (isIdentifierEscaped(schema, QSqlDriver::TableName)) + schema = stripDelimiters(schema, QSqlDriver::TableName); + else + schema = schema.toUpper(); + + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + else + table = table.toUpper(); + r = SQLSetStmtAttr(hStmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY, @@ -1477,7 +1531,6 @@ bool QDB2Driver::hasFeature(DriverFeature f) const case BatchOperations: case LastInsertId: case SimpleLocking: - case LowPrecisionNumbers: case EventNotifications: return false; case BLOB: @@ -1485,6 +1538,8 @@ bool QDB2Driver::hasFeature(DriverFeature f) const case MultipleResultSets: case PreparedQueries: case PositionalPlaceholders: + case LowPrecisionNumbers: + case FinishQuery: return true; case Unicode: // this is the query that shows the codepage for the types: diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index 0698f26..d714327 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -1103,6 +1103,19 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx) // null value QVariant v; v.convert(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype, d->sqlda->sqlvar[i].sqlscale < 0)); + if(v.type() == QVariant::Double) { + switch(numericalPrecisionPolicy()) { + case QSql::LowPrecisionInt32: + v.convert(QVariant::Int); + break; + case QSql::LowPrecisionInt64: + v.convert(QVariant::LongLong); + break; + case QSql::HighPrecision: + v.convert(QVariant::String); + break; + } + } row[idx] = v; continue; } @@ -1168,6 +1181,27 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx) row[idx] = QVariant(); break; } + if (d->sqlda->sqlvar[i].sqlscale < 0) { + QVariant v = row[idx]; + switch(numericalPrecisionPolicy()) { + case QSql::LowPrecisionInt32: + if(v.convert(QVariant::Int)) + row[idx]=v; + break; + case QSql::LowPrecisionInt64: + if(v.convert(QVariant::LongLong)) + row[idx]=v; + break; + case QSql::LowPrecisionDouble: + if(v.convert(QVariant::Double)) + row[idx]=v; + break; + case QSql::HighPrecision: + if(v.convert(QVariant::String)) + row[idx]=v; + break; + } + } } return true; @@ -1339,7 +1373,6 @@ bool QIBaseDriver::hasFeature(DriverFeature f) const case LastInsertId: case BatchOperations: case SimpleLocking: - case LowPrecisionNumbers: case FinishQuery: case MultipleResultSets: return false; @@ -1349,6 +1382,7 @@ bool QIBaseDriver::hasFeature(DriverFeature f) const case Unicode: case BLOB: case EventNotifications: + case LowPrecisionNumbers: return true; } return false; @@ -1558,12 +1592,16 @@ QSqlRecord QIBaseDriver::record(const QString& tablename) const QSqlQuery q(createResult()); q.setForwardOnly(true); - + QString table = tablename; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + else + table = table.toUpper(); q.exec(QLatin1String("SELECT a.RDB$FIELD_NAME, b.RDB$FIELD_TYPE, b.RDB$FIELD_LENGTH, " "b.RDB$FIELD_SCALE, b.RDB$FIELD_PRECISION, a.RDB$NULL_FLAG " "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b " "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE " - "AND a.RDB$RELATION_NAME = '") + tablename.toUpper() + QLatin1String("' " + "AND a.RDB$RELATION_NAME = '") + table + QLatin1String("' " "ORDER BY a.RDB$FIELD_POSITION")); while (q.next()) { @@ -1591,12 +1629,18 @@ QSqlIndex QIBaseDriver::primaryIndex(const QString &table) const if (!isOpen()) return index; + QString tablename = table; + if (isIdentifierEscaped(tablename, QSqlDriver::TableName)) + tablename = stripDelimiters(tablename, QSqlDriver::TableName); + else + tablename = tablename.toUpper(); + QSqlQuery q(createResult()); q.setForwardOnly(true); q.exec(QLatin1String("SELECT a.RDB$INDEX_NAME, b.RDB$FIELD_NAME, d.RDB$FIELD_TYPE, d.RDB$FIELD_SCALE " "FROM RDB$RELATION_CONSTRAINTS a, RDB$INDEX_SEGMENTS b, RDB$RELATION_FIELDS c, RDB$FIELDS d " "WHERE a.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' " - "AND a.RDB$RELATION_NAME = '") + table.toUpper() + + "AND a.RDB$RELATION_NAME = '") + tablename + QLatin1String(" 'AND a.RDB$INDEX_NAME = b.RDB$INDEX_NAME " "AND c.RDB$RELATION_NAME = a.RDB$RELATION_NAME " "AND c.RDB$FIELD_NAME = b.RDB$FIELD_NAME " diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 46726a5..bfd65fc 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -254,6 +254,9 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags) case FIELD_TYPE_FLOAT : case FIELD_TYPE_DOUBLE : case FIELD_TYPE_DECIMAL : +#if defined(FIELD_TYPE_NEWDECIMAL) + case FIELD_TYPE_NEWDECIMAL: +#endif type = QVariant::Double; break; case FIELD_TYPE_DATE : diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index ca4b286..d5fb10f 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -1899,7 +1899,7 @@ void QOCIResult::virtual_hook(int id, void *data) QOCICols::execBatch(d, boundValues(), *reinterpret_cast<bool *>(data)); break; default: - QSqlResult::virtual_hook(id, data); + QSqlCachedResult::virtual_hook(id, data); } } diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 727c5ce..b70868d 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -598,6 +598,7 @@ QChar QODBCDriverPrivate::quoteChar() const return quote; } + bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) { // Set any connection attributes diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index db09e93..1ab8214 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -891,6 +891,16 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const QString schema; qSplitTableName(tbl, schema); + if (isIdentifierEscaped(tbl, QSqlDriver::TableName)) + tbl = stripDelimiters(tbl, QSqlDriver::TableName); + else + tbl = tbl.toLower(); + + if (isIdentifierEscaped(schema, QSqlDriver::TableName)) + schema = stripDelimiters(schema, QSqlDriver::TableName); + else + schema = schema.toLower(); + switch(d->pro) { case QPSQLDriver::Version6: stmt = QLatin1String("select pg_att1.attname, int(pg_att1.atttypid), pg_cl.relname " @@ -923,7 +933,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const "FROM pg_attribute, pg_class " "WHERE %1 pg_class.oid IN " "(SELECT indexrelid FROM pg_index WHERE indisprimary = true AND indrelid IN " - " (SELECT oid FROM pg_class WHERE lower(relname) = '%2')) " + " (SELECT oid FROM pg_class WHERE relname = '%2')) " "AND pg_attribute.attrelid = pg_class.oid " "AND pg_attribute.attisdropped = false " "ORDER BY pg_attribute.attnum"); @@ -931,11 +941,11 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const stmt = stmt.arg(QLatin1String("pg_table_is_visible(pg_class.oid) AND")); else stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from " - "pg_namespace where pg_namespace.nspname = '%1') AND ").arg(schema.toLower())); + "pg_namespace where pg_namespace.nspname = '%1') AND ").arg(schema)); break; } - i.exec(stmt.arg(tbl.toLower())); + i.exec(stmt.arg(tbl)); while (i.isActive() && i.next()) { QSqlField f(i.value(0).toString(), qDecodePSQLType(i.value(1).toInt())); idx.append(f); @@ -954,6 +964,16 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const QString schema; qSplitTableName(tbl, schema); + if (isIdentifierEscaped(tbl, QSqlDriver::TableName)) + tbl = stripDelimiters(tbl, QSqlDriver::TableName); + else + tbl = tbl.toLower(); + + if (isIdentifierEscaped(schema, QSqlDriver::TableName)) + schema = stripDelimiters(schema, QSqlDriver::TableName); + else + schema = schema.toLower(); + QString stmt; switch(d->pro) { case QPSQLDriver::Version6: @@ -998,7 +1018,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const "left join pg_attrdef on (pg_attrdef.adrelid = " "pg_attribute.attrelid and pg_attrdef.adnum = pg_attribute.attnum) " "where %1 " - "and lower(pg_class.relname) = '%2' " + "and pg_class.relname = '%2' " "and pg_attribute.attnum > 0 " "and pg_attribute.attrelid = pg_class.oid " "and pg_attribute.attisdropped = false " @@ -1007,12 +1027,12 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const stmt = stmt.arg(QLatin1String("pg_table_is_visible(pg_class.oid)")); else stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from " - "pg_namespace where pg_namespace.nspname = '%1')").arg(schema.toLower())); + "pg_namespace where pg_namespace.nspname = '%1')").arg(schema)); break; } QSqlQuery query(createResult()); - query.exec(stmt.arg(tbl.toLower())); + query.exec(stmt.arg(tbl)); if (d->pro >= QPSQLDriver::Version71) { while (query.next()) { int len = query.value(3).toInt(); diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 1a05873..8e1091b 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -289,7 +289,7 @@ void QSQLiteResult::virtual_hook(int id, void *data) sqlite3_reset(d->stmt); break; default: - QSqlResult::virtual_hook(id, data); + QSqlCachedResult::virtual_hook(id, data); } } @@ -656,9 +656,13 @@ QSqlIndex QSQLiteDriver::primaryIndex(const QString &tblname) const if (!isOpen()) return QSqlIndex(); + QString table = tblname; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + QSqlQuery q(createResult()); q.setForwardOnly(true); - return qGetTableInfo(q, tblname, true); + return qGetTableInfo(q, table, true); } QSqlRecord QSQLiteDriver::record(const QString &tbl) const @@ -666,9 +670,13 @@ QSqlRecord QSQLiteDriver::record(const QString &tbl) const if (!isOpen()) return QSqlRecord(); + QString table = tbl; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + QSqlQuery q(createResult()); q.setForwardOnly(true); - return qGetTableInfo(q, tbl); + return qGetTableInfo(q, table); } QVariant QSQLiteDriver::handle() const @@ -676,10 +684,10 @@ QVariant QSQLiteDriver::handle() const return qVariantFromValue(d->access); } -QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType /*type*/) const +QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const { QString res = identifier; - if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('"')) && identifier.right(1) != QString(QLatin1Char('"')) ) { + if(!identifier.isEmpty() && !isIdentifierEscaped(identifier, type) ) { res.replace(QLatin1Char('"'), QLatin1String("\"\"")); res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); res.replace(QLatin1Char('.'), QLatin1String("\".\"")); diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp index 790c1ef..1989c45 100644 --- a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp +++ b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp @@ -260,7 +260,7 @@ void QSQLite2Result::virtual_hook(int id, void *data) d->finalize(); break; default: - QSqlResult::virtual_hook(id, data); + QSqlCachedResult::virtual_hook(id, data); } } diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp index 5ddc4e4..e100863 100644 --- a/src/sql/drivers/tds/qsql_tds.cpp +++ b/src/sql/drivers/tds/qsql_tds.cpp @@ -293,6 +293,8 @@ QTDSResult::QTDSResult(const QTDSDriver* db) // insert d in error handler dict errs()->insert(d->dbproc, d); + dbcmd(d->dbproc, "set quoted_identifier on"); + dbsqlexec(d->dbproc); } QTDSResult::~QTDSResult() @@ -367,7 +369,7 @@ bool QTDSResult::gotoNext(QSqlCachedResult::ValueCache &values, int index) if (qIsNull(d->buffer.at(i * 2 + 1))) values[idx] = QVariant(QVariant::String); else - values[idx] = QString::fromLocal8Bit((const char*)d->buffer.at(i * 2)); + values[idx] = QString::fromLocal8Bit((const char*)d->buffer.at(i * 2)).trimmed(); break; case QVariant::ByteArray: { if (qIsNull(d->buffer.at(i * 2 + 1))) @@ -698,9 +700,14 @@ QSqlRecord QTDSDriver::record(const QString& tablename) const return info; QSqlQuery t(createResult()); t.setForwardOnly(true); + + QString table = tablename; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + QString stmt (QLatin1String("select name, type, length, prec from syscolumns " "where id = (select id from sysobjects where name = '%1')")); - t.exec(stmt.arg(tablename)); + t.exec(stmt.arg(table)); while (t.next()) { QSqlField f(t.value(0).toString().simplified(), qDecodeTDSType(t.value(1).toInt())); f.setLength(t.value(2).toInt()); @@ -770,13 +777,17 @@ QSqlIndex QTDSDriver::primaryIndex(const QString& tablename) const { QSqlRecord rec = record(tablename); - QSqlIndex idx(tablename); - if ((!isOpen()) || (tablename.isEmpty())) + QString table = tablename; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + + QSqlIndex idx(table); + if ((!isOpen()) || (table.isEmpty())) return QSqlIndex(); QSqlQuery t(createResult()); t.setForwardOnly(true); - t.exec(QString::fromLatin1("sp_helpindex '%1'").arg(tablename)); + t.exec(QString::fromLatin1("sp_helpindex '%1'").arg(table)); if (t.next()) { QStringList fNames = t.value(2).toString().simplified().split(QLatin1Char(',')); QRegExp regx(QLatin1String("\\s*(\\S+)(?:\\s+(DESC|desc))?\\s*")); diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp index 3cace06..ca51dc0 100644 --- a/src/sql/kernel/qsqlcachedresult.cpp +++ b/src/sql/kernel/qsqlcachedresult.cpp @@ -294,4 +294,17 @@ QSqlCachedResult::ValueCache &QSqlCachedResult::cache() return d->cache; } +void QSqlCachedResult::virtual_hook(int id, void *data) +{ + switch (id) { + case QSqlResult::DetachFromResultSet: + case QSqlResult::SetNumericalPrecision: + cleanup(); + break; + default: + QSqlResult::virtual_hook(id, data); + } +} + + QT_END_NAMESPACE diff --git a/src/sql/kernel/qsqlcachedresult_p.h b/src/sql/kernel/qsqlcachedresult_p.h index d19435c..a384b2e 100644 --- a/src/sql/kernel/qsqlcachedresult_p.h +++ b/src/sql/kernel/qsqlcachedresult_p.h @@ -89,6 +89,7 @@ protected: int colCount() const; ValueCache &cache(); + void virtual_hook(int id, void *data); private: bool cacheNext(); QSqlCachedResultPrivate *d; diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index 1c1595d..93c9d9f 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -905,7 +905,6 @@ QVariant QSqlResult::lastInsertId() const */ void QSqlResult::virtual_hook(int, void *) { - Q_ASSERT(false); } /*! \internal @@ -971,6 +970,7 @@ void QSqlResult::detachFromResultSet() void QSqlResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) { d->precisionPolicy = policy; + virtual_hook(SetNumericalPrecision, &policy); } /*! \internal diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 1acc846..156af26 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -98,7 +98,10 @@ bool QSqlTableModelPrivate::setRecord(int row, const QSqlRecord &record) int QSqlTableModelPrivate::nameToIndex(const QString &name) const { - return rec.indexOf(name); + QString fieldname = name; + if (db.driver()->isIdentifierEscaped(fieldname, QSqlDriver::FieldName)) + fieldname = db.driver()->stripDelimiters(fieldname, QSqlDriver::FieldName); + return rec.indexOf(fieldname); } void QSqlTableModelPrivate::initRecordAndPrimaryIndex() @@ -367,10 +370,7 @@ void QSqlTableModel::setTable(const QString &tableName) { Q_D(QSqlTableModel); clear(); - if(d->db.tables().contains(tableName.toUpper())) - d->tableName = tableName.toUpper(); - else - d->tableName = tableName; + d->tableName = tableName; d->initRecordAndPrimaryIndex(); d->initColOffsets(d->rec.count()); @@ -976,7 +976,9 @@ QString QSqlTableModel::orderByClause() const if (!f.isValid()) return s; - QString table = d->db.driver()->escapeIdentifier(d->tableName, QSqlDriver::TableName); + QString table = d->tableName; + //we can safely escape the field because it would have been obtained from the database + //and have the correct case QString field = d->db.driver()->escapeIdentifier(f.name(), QSqlDriver::FieldName); s.append(QLatin1String("ORDER BY ")).append(table).append(QLatin1Char('.')).append(field); s += d->sortOrder == Qt::AscendingOrder ? QLatin1String(" ASC") : QLatin1String(" DESC"); @@ -1317,8 +1319,12 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record) mrow.rec = d->rec; mrow.primaryValues = d->primaryValues(indexInQuery(createIndex(row, 0)).row()); } + QString fieldName; for (int i = 0; i < record.count(); ++i) { - int idx = mrow.rec.indexOf(record.fieldName(i)); + fieldName = record.fieldName(i); + if (d->db.driver()->isIdentifierEscaped(fieldName, QSqlDriver::FieldName)) + fieldName = d->db.driver()->stripDelimiters(fieldName, QSqlDriver::FieldName); + int idx = mrow.rec.indexOf(fieldName); if (idx == -1) isOk = false; else diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp index 6782429..e09f382 100644 --- a/src/svg/qsvggraphics.cpp +++ b/src/svg/qsvggraphics.cpp @@ -198,9 +198,8 @@ QRectF QSvgPath::bounds() const } QSvgPolygon::QSvgPolygon(QSvgNode *parent, const QPolygonF &poly) - : QSvgNode(parent), m_poly(poly) + : QSvgNode(parent), m_poly(poly), m_fillRule(Qt::WindingFill) { - } QRectF QSvgPolygon::bounds() const @@ -217,7 +216,7 @@ QRectF QSvgPolygon::bounds() const void QSvgPolygon::draw(QPainter *p, QSvgExtraStates &states) { - QT_SVG_DRAW_SHAPE(p->drawPolygon(m_poly)); + QT_SVG_DRAW_SHAPE(p->drawPolygon(m_poly, m_fillRule)); } diff --git a/src/svg/qsvggraphics_p.h b/src/svg/qsvggraphics_p.h index 8a412c4..4a19c7e 100644 --- a/src/svg/qsvggraphics_p.h +++ b/src/svg/qsvggraphics_p.h @@ -155,8 +155,13 @@ public: virtual void draw(QPainter *p, QSvgExtraStates &states); virtual Type type() const; virtual QRectF bounds() const; + void setFillRule(Qt::FillRule f) + { + m_fillRule = f; + } private: QPolygonF m_poly; + Qt::FillRule m_fillRule; }; class QSvgPolyline : public QSvgNode diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index e2c1312..345dcf3 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -497,10 +497,8 @@ static bool constructColor(const QString &colorStr, const QString &opacity, if (!resolveColor(colorStr, color, handler)) return false; if (!opacity.isEmpty()) { - qreal op = toDouble(opacity); - if (op <= 1) - op *= 255; - color.setAlpha(int(op)); + qreal op = qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity))); + color.setAlphaF(op); } return true; } @@ -641,15 +639,22 @@ static void parseBrush(QSvgNode *node, f = Qt::OddEvenFill; if (value.startsWith(QLatin1String("url"))) { value = value.remove(0, 3); + QSvgFillStyle *prop = new QSvgFillStyle(0); QSvgStyleProperty *style = styleFromUrl(node, value); if (style) { - QSvgFillStyle *prop = new QSvgFillStyle(style); - if (!opacity.isEmpty()) - prop->setFillOpacity(toDouble(opacity)); - node->appendStyleProperty(prop, myId); + prop->setFillStyle(style); } else { - qWarning("Couldn't resolve property: %s", qPrintable(idFromUrl(value))); + QString id = idFromUrl(value); + prop->setGradientId(id); + prop->setGradientResolved(false); } + if (!opacity.isEmpty()) { + qreal clampedOpacity = qMin(qreal(1.0), qMax(qreal(0.0), toDouble(opacity))); + prop->setFillOpacity(clampedOpacity); + } + if (!fillRule.isEmpty()) + prop->setFillRule(f); + node->appendStyleProperty(prop,myId); } else if (value != QLatin1String("none")) { QColor color; if (constructColor(value, opacity, color, handler)) { @@ -1377,6 +1382,11 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) y = y0 = arg[1] + offsetY; path.moveTo(x0, y0); arg.pop_front(); arg.pop_front(); + + // As per 1.2 spec 8.3.2 The "moveto" commands + // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands, + // the subsequent pairs shall be treated as implicit 'lineto' commands. + pathElem = QLatin1Char('l'); } break; case 'M': { @@ -1389,6 +1399,11 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) path.moveTo(x0, y0); arg.pop_front(); arg.pop_front(); + + // As per 1.2 spec 8.3.2 The "moveto" commands + // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands, + // the subsequent pairs shall be treated as implicit 'lineto' commands. + pathElem = QLatin1Char('L'); } break; case 'z': @@ -1943,7 +1958,7 @@ static void parseOpacity(QSvgNode *node, qreal op = value.toDouble(&ok); if (ok) { - QSvgOpacityStyle *opacity = new QSvgOpacityStyle(op); + QSvgOpacityStyle *opacity = new QSvgOpacityStyle(qMin(qreal(1.0), qMax(qreal(0.0), op))); node->appendStyleProperty(opacity, someId(attributes)); } } @@ -3570,8 +3585,34 @@ bool QSvgHandler::endElement(const QStringRef &localName) node->popFormat(); } - if (node == Graphics) + if (node == Graphics) { + // Iterate through the m_renderers to resolve any unresolved gradients. + QSvgNode* curNode = static_cast<QSvgNode*>(m_nodes.top()); + if (curNode->type() == QSvgNode::DOC || + curNode->type() == QSvgNode::G || + curNode->type() == QSvgNode::DEFS || + curNode->type() == QSvgNode::SWITCH) { + QSvgStructureNode* structureNode = static_cast<QSvgStructureNode*>(curNode); + QList<QSvgNode*> ren = structureNode->renderers(); + QList<QSvgNode*>::iterator itr = ren.begin(); + while (itr != ren.end()) { + QSvgNode *eleNode = *itr++; + QSvgFillStyle *prop = static_cast<QSvgFillStyle*>(eleNode->styleProperty(QSvgStyleProperty::FILL)); + if (prop && !(prop->isGradientResolved())) { + QString id = prop->getGradientId(); + QSvgStyleProperty *style = structureNode->scopeStyle(id); + if (style) { + prop->setFillStyle(style); + } else { + qWarning("Couldn't resolve property : %s",qPrintable(id)); + prop->setBrush(QBrush(Qt::NoBrush)); + } + } + } + } m_nodes.pop(); + } + else if (m_style && !m_skipNodes.isEmpty() && m_skipNodes.top() != Style) m_style = 0; diff --git a/src/svg/qsvgstructure.cpp b/src/svg/qsvgstructure.cpp index 67a21bf..c1ad4bf 100644 --- a/src/svg/qsvgstructure.cpp +++ b/src/svg/qsvgstructure.cpp @@ -68,13 +68,11 @@ void QSvgG::draw(QPainter *p, QSvgExtraStates &states) QList<QSvgNode*>::iterator itr = m_renderers.begin(); applyStyle(p, states); - if (displayMode() != QSvgNode::NoneMode) { - while (itr != m_renderers.end()) { - QSvgNode *node = *itr; - if (node->isVisible()) - node->draw(p, states); - ++itr; - } + while (itr != m_renderers.end()) { + QSvgNode *node = *itr; + if ((node->isVisible()) && (node->displayMode() != QSvgNode::NoneMode)) + node->draw(p, states); + ++itr; } revertStyle(p, states); } @@ -321,63 +319,61 @@ void QSvgSwitch::draw(QPainter *p, QSvgExtraStates &states) QList<QSvgNode*>::iterator itr = m_renderers.begin(); applyStyle(p, states); - if (displayMode() != QSvgNode::NoneMode) { - while (itr != m_renderers.end()) { - QSvgNode *node = *itr; - if (node->isVisible()) { - const QStringList &features = node->requiredFeatures(); - const QStringList &extensions = node->requiredExtensions(); - const QStringList &languages = node->requiredLanguages(); - const QStringList &formats = node->requiredFormats(); - const QStringList &fonts = node->requiredFonts(); - - bool okToRender = true; - if (!features.isEmpty()) { - QStringList::const_iterator sitr = features.constBegin(); - for (; sitr != features.constEnd(); ++sitr) { - if (!isSupportedSvgFeature(*sitr)) { - okToRender = false; - break; - } + while (itr != m_renderers.end()) { + QSvgNode *node = *itr; + if (node->isVisible() && (node->displayMode() != QSvgNode::NoneMode)) { + const QStringList &features = node->requiredFeatures(); + const QStringList &extensions = node->requiredExtensions(); + const QStringList &languages = node->requiredLanguages(); + const QStringList &formats = node->requiredFormats(); + const QStringList &fonts = node->requiredFonts(); + + bool okToRender = true; + if (!features.isEmpty()) { + QStringList::const_iterator sitr = features.constBegin(); + for (; sitr != features.constEnd(); ++sitr) { + if (!isSupportedSvgFeature(*sitr)) { + okToRender = false; + break; } } + } - if (okToRender && !extensions.isEmpty()) { - QStringList::const_iterator sitr = extensions.constBegin(); - for (; sitr != extensions.constEnd(); ++sitr) { - if (!isSupportedSvgExtension(*sitr)) { - okToRender = false; - break; - } + if (okToRender && !extensions.isEmpty()) { + QStringList::const_iterator sitr = extensions.constBegin(); + for (; sitr != extensions.constEnd(); ++sitr) { + if (!isSupportedSvgExtension(*sitr)) { + okToRender = false; + break; } } + } - if (okToRender && !languages.isEmpty()) { - QStringList::const_iterator sitr = languages.constBegin(); - okToRender = false; - for (; sitr != languages.constEnd(); ++sitr) { - if ((*sitr).startsWith(m_systemLanguagePrefix)) { - okToRender = true; - break; - } + if (okToRender && !languages.isEmpty()) { + QStringList::const_iterator sitr = languages.constBegin(); + okToRender = false; + for (; sitr != languages.constEnd(); ++sitr) { + if ((*sitr).startsWith(m_systemLanguagePrefix)) { + okToRender = true; + break; } } + } - if (okToRender && !formats.isEmpty()) { - okToRender = false; - } + if (okToRender && !formats.isEmpty()) { + okToRender = false; + } - if (okToRender && !fonts.isEmpty()) { - okToRender = false; - } + if (okToRender && !fonts.isEmpty()) { + okToRender = false; + } - if (okToRender) { - node->draw(p, states); - break; - } + if (okToRender) { + node->draw(p, states); + break; } - ++itr; } + ++itr; } revertStyle(p, states); } diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index fa996f4..fec6231 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -81,12 +81,12 @@ void QSvgQualityStyle::revert(QPainter *, QSvgExtraStates &) } QSvgFillStyle::QSvgFillStyle(const QBrush &brush) - : m_fill(brush), m_style(0), m_fillRuleSet(false), m_fillOpacitySet(false) + : m_fill(brush), m_style(0), m_fillRuleSet(false), m_fillOpacitySet(false), m_gradientResolved (true) { } QSvgFillStyle::QSvgFillStyle(QSvgStyleProperty *style) - : m_style(style), m_fillRuleSet(false), m_fillOpacitySet(false) + : m_style(style), m_fillRuleSet(false), m_fillOpacitySet(false), m_gradientResolved (true) { } @@ -107,6 +107,9 @@ static void recursivelySetFill(QSvgNode *node, Qt::FillRule f) if (node->type() == QSvgNode::PATH) { QSvgPath *path = static_cast<QSvgPath*>(node); path->qpath()->setFillRule(f); + } else if (node->type() == QSvgNode::POLYGON) { + QSvgPolygon *polygon = static_cast<QSvgPolygon*>(node); + polygon->setFillRule(f); } else if (node->type() == QSvgNode::G) { QList<QSvgNode*> renderers = static_cast<QSvgG*>(node)->renderers(); foreach(QSvgNode *n, renderers) { diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h index 4bbc6cf..e65b6f5 100644 --- a/src/svg/qsvgstyle_p.h +++ b/src/svg/qsvgstyle_p.h @@ -229,6 +229,38 @@ public: { return m_fill; } + + void setGradientId(const QString &Id) + { + m_gradientId = Id; + } + + QString getGradientId() const + { + return m_gradientId; + } + + + void setGradientResolved(bool resolved) + { + m_gradientResolved = resolved; + } + + bool isGradientResolved() const + { + return m_gradientResolved; + } + + void setFillStyle(QSvgStyleProperty* style) + { + m_style = style; + } + + void setBrush(QBrush brush) + { + m_fill = brush; + } + private: // fill v v 'inherit' | <Paint.datatype> // fill-opacity v v 'inherit' | <OpacityValue.datatype> @@ -241,6 +273,8 @@ private: bool m_fillOpacitySet; qreal m_fillOpacity; qreal m_oldOpacity; + QString m_gradientId; + bool m_gradientResolved; }; class QSvgViewportFillStyle : public QSvgStyleProperty diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp index de214bb..3058569 100644 --- a/src/svg/qsvgtinydocument.cpp +++ b/src/svg/qsvgtinydocument.cpp @@ -231,8 +231,10 @@ void QSvgTinyDocument::draw(QPainter *p, const QRectF &bounds) m_time.start(); } - p->save(); + if (displayMode() == QSvgNode::NoneMode) + return; + p->save(); //sets default style on the painter //### not the most optimal way mapSourceToTarget(p, bounds); @@ -244,7 +246,7 @@ void QSvgTinyDocument::draw(QPainter *p, const QRectF &bounds) applyStyle(p, m_states); while (itr != m_renderers.end()) { QSvgNode *node = *itr; - if (node->isVisible()) + if ((node->isVisible()) && (node->displayMode() != QSvgNode::NoneMode)) node->draw(p, m_states); ++itr; } @@ -262,6 +264,12 @@ void QSvgTinyDocument::draw(QPainter *p, const QString &id, qDebug("Couldn't find node %s. Skipping rendering.", qPrintable(id)); return; } + if (m_time.isNull()) { + m_time.start(); + } + + if (node->displayMode() == QSvgNode::NoneMode) + return; p->save(); diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 4a9675a..64c1312 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -139,7 +139,7 @@ namespace QTest { if (!counter.deref()) { QTest::testLogger->addMessage(QAbstractTestLogger::QSystem, - "Maximum amount of warnings exceeded."); + "Maximum amount of warnings exceeded. Use -maxwarnings to override."); return; } } |