From 469b9a0f2ddf4bd1d2719619f3e4e52afbc7731f Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 30 Mar 2009 16:44:55 +0200 Subject: Doc: Synchronized the QTransform constructor arguments with the class documentation and updated a diagram. Task-number: 228201 Reviewed-by: TrustMe --- doc/src/diagrams/qtransform-representation.sk | 103 ++++++++++++++++++++++++++ src/gui/painting/qtransform.cpp | 19 +++-- 2 files changed, 114 insertions(+), 8 deletions(-) create mode 100644 doc/src/diagrams/qtransform-representation.sk diff --git a/doc/src/diagrams/qtransform-representation.sk b/doc/src/diagrams/qtransform-representation.sk new file mode 100644 index 0000000..17dcbfe --- /dev/null +++ b/doc/src/diagrams/qtransform-representation.sk @@ -0,0 +1,103 @@ +##Sketch 1 2 +document() +layout('A4',0) +layer('Layer 1',1,1,0,0,(0,0,0)) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,190,760) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,190,695) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,190,630) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,320,760) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,320,695) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,320,630) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,255,760) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,255,695) +lp((0,0,1)) +lw(2) +r(65,0,0,-65,255,630) +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m33',(329.16,589.968)) +G() +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('dy',(274.828,577.768)) +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m32',(264.16,602.768)) +G_() +G() +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m31',(199.16,602.768)) +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('dx',(209.828,577.8)) +G_() +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m11',(199.16,719.968)) +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m12',(264.16,719.968)) +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m13',(329.16,719.968)) +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m21',(199.16,654.968)) +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m22',(264.16,654.968)) +fp((0,0,0)) +le() +lw(1) +Fn('Helvetica') +Fs(24) +txt('m23',(329.16,654.968)) +guidelayer('Guide Lines',1,0,0,1,(0,0,1)) +grid((0,0,5,5),1,(0,0,1),'Grid') diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index da8c428..c70208c 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -168,10 +168,10 @@ QT_BEGIN_NAMESPACE \image qtransform-representation.png - A QTransform object contains a 3 x 3 matrix. The \c dx and \c dy - elements specify horizontal and vertical translation. The \c m11 - and \c m22 elements specify horizontal and vertical scaling. The - \c m21 and \c m12 elements specify horizontal and vertical \e shearing. + A QTransform object contains a 3 x 3 matrix. The \c m31 (\c dx) and + \c m32 (\c dy) elements specify horizontal and vertical translation. + The \c m11 and \c m22 elements specify horizontal and vertical scaling. + The \c m21 and \c m12 elements specify horizontal and vertical \e shearing. And finally, the \c m13 and \c m23 elements specify horizontal and vertical projection, with \c m33 as an additional projection factor. @@ -246,8 +246,10 @@ QTransform::QTransform() } /*! - Constructs a matrix with the elements, \a h11, \a h12, \a h13, - \a h21, \a h22, \a h23, \a h31, \a h32, \a h33. + \fn QTransform::QTransform(qreal m11, qreal m12, qreal m13, qreal m21, qreal m22, qreal m23, qreal m31, qreal m32, qreal m33) + + Constructs a matrix with the elements, \a m11, \a m12, \a m13, + \a m21, \a m22, \a m23, \a m31, \a m32, \a m33. \sa setMatrix() */ @@ -263,8 +265,9 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h13, } /*! - Constructs a matrix with the elements, \a h11, \a h12, \a h21, \a - h22, \a dx and \a dy. + \fn QTransform::QTransform(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy) + + Constructs a matrix with the elements, \a m11, \a m12, \a m21, \a m22, \a dx and \a dy. \sa setMatrix() */ -- cgit v0.12 From 7ce9e9160ce04e6ab7e4219af9de6c24a9d2889c Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 30 Mar 2009 16:48:26 +0200 Subject: Doc: Synchronized the QTransform constructor arguments with the class documentation and updated a diagram. Task-number: 228201 Reviewed-by: TrustMe --- doc/src/images/qtransform-representation.png | Bin 17892 -> 17385 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/src/images/qtransform-representation.png b/doc/src/images/qtransform-representation.png index 2608872..883d5dc 100644 Binary files a/doc/src/images/qtransform-representation.png and b/doc/src/images/qtransform-representation.png differ -- cgit v0.12 From 259175c6d55d7add0b25fd552b9dadc256e45def Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 30 Mar 2009 17:03:01 +0200 Subject: Doc: Fixed typo. Reviewed-by: TrustMe --- src/corelib/kernel/qmetatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 4d7d309..ce10bae 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1255,7 +1255,7 @@ void QMetaType::destroy(int type, void *data) \relates QMetaType \threadsafe - Registers the type name \a typeName to the type \c{T}. Returns + Registers the type name \a typeName for the type \c{T}. Returns the internal ID used by QMetaType. Any class or struct that has a public default constructor, a public copy constructor and a public destructor can be registered. -- cgit v0.12 From 51a59f48f5b92e1c55dae5da0ffa9fbb492abc6b Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 30 Mar 2009 17:19:21 +0200 Subject: Explicitely mentioned in the doc that the format string for qDebug, qWarning and qFatal should be in Latin1. Reviewed-by: Thiago --- src/corelib/global/qglobal.cpp | 11 +++++++---- src/corelib/tools/qstring.cpp | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 90020f7..08ecf3c 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2022,7 +2022,8 @@ void qt_message_output(QtMsgType msgType, const char *buf) during compilation. If you pass the function a format string and a list of arguments, - it works in similar way to the C printf() function. + it works in similar way to the C printf() function. The format + should be a Latin-1 string. Example: @@ -2068,7 +2069,8 @@ void qDebug(const char *msg, ...) QT_FATAL_WARNINGS is defined. This function takes a format string and a list of arguments, - similar to the C printf() function. + similar to the C printf() function. The format should be a Latin-1 + string. Example: \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 26 @@ -2106,8 +2108,9 @@ void qWarning(const char *msg, ...) message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the debugger. - This function takes a format string and a list of arguments, similar - to the C printf() function. + This function takes a format string and a list of arguments, + similar to the C printf() function. The format should be a Latin-1 + string. Example: \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 28 diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 1b29adc..9c637ac 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4864,7 +4864,8 @@ QString QString::toUpper() const a pointer to a zero-terminated array of unicode characters of type ushort (as returned by QString::utf16()). - \note This function expects a UTF-8 string for %s. + \note This function expects a UTF-8 string for %s and Latin-1 for + the format string. The format string supports most of the conversion specifiers provided by printf() in the standard C++ library. It doesn't -- cgit v0.12 From a9ffdee9c0e8ba092bb20759300157c1e45bc407 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 30 Mar 2009 08:30:23 -0700 Subject: Rename function Everything else capitalizes both the F and the B. s/Fb/FB/g Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 2 +- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h | 2 +- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 6 +++--- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 2 +- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 8dbad53..5e71640 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -50,7 +50,7 @@ QDirectFBPaintDevice::~QDirectFBPaintDevice() } -IDirectFBSurface *QDirectFBPaintDevice::directFbSurface() const +IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const { return dfbSurface; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 7096124..89a3087 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -56,7 +56,7 @@ class QDirectFBPaintDevice : public QCustomRasterPaintDevice public: ~QDirectFBPaintDevice(); - IDirectFBSurface *directFbSurface() const; + IDirectFBSurface *directFBSurface() const; void lockDirectFB(); void unlockDirectFB(); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 28386e5..da4f367 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -340,7 +340,7 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) } if (dfbDevice) - surface = dfbDevice->directFbSurface(); + surface = dfbDevice->directFBSurface(); if (!surface) { qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x", @@ -641,7 +641,7 @@ void QDirectFBPaintEnginePrivate::drawPixmap(const QRectF &dest, QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); - IDirectFBSurface *s = dfbData->directFbSurface(); + IDirectFBSurface *s = dfbData->directFBSurface(); const QRect sr = src.toRect(); const QRect dr = ::mapRect(transform, dest); const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; @@ -674,7 +674,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); - IDirectFBSurface *s = dfbData->directFbSurface(); + IDirectFBSurface *s = dfbData->directFBSurface(); const QRect dr = ::mapRect(transform, dest); DFBResult result = DFB_OK; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 3099205..9f5c055 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -108,7 +108,7 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) return; } - IDirectFBSurface *src = static_cast(data)->directFbSurface(); + IDirectFBSurface *src = static_cast(data)->directFBSurface(); const QImage::Format format = (data->hasAlphaChannel() ? QDirectFBScreen::instance()->alphaPixmapFormat() : QDirectFBScreen::instance()->pixelFormat()); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index db9672a..87a5910 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1033,7 +1033,7 @@ void QDirectFBScreen::compose(const QRegion ®ion) if (surface->key() == QLatin1String("directfb")) { QDirectFBSurface *s = static_cast(surface); - blit(s->directFbSurface(), offset, r); + blit(s->directFBSurface(), offset, r); } else { blit(surface->image(), offset, r); } @@ -1082,7 +1082,7 @@ void QDirectFBScreen::compose(const QRegion ®ion) if (surface->key() == QLatin1String("directfb")) { QDirectFBSurface *s = static_cast(surface); - blit(s->directFbSurface(), offset, r); + blit(s->directFBSurface(), offset, r); } else { blit(surface->image(), offset, r); } -- cgit v0.12 From 6a303f13616fe1f54086092952b0d740534ca52a Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 30 Mar 2009 17:40:53 +0200 Subject: Doc: Exclude the internal Phonon classes from the Assistant documentation. Task-number: 247060 Reviewed-by: TrustMe --- tools/qdoc3/test/qt-api-only.qdocconf | 2 +- tools/qdoc3/test/qt-build-docs.qdocconf | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/test/qt-api-only.qdocconf b/tools/qdoc3/test/qt-api-only.qdocconf index 2e91ba2..bc5656b 100644 --- a/tools/qdoc3/test/qt-api-only.qdocconf +++ b/tools/qdoc3/test/qt-api-only.qdocconf @@ -9,7 +9,7 @@ url = ./ # Ensures that the documentation for the tools is not included in the generated # .qhp file. -qhp.Qt.excluded = $QT_SOURCE_TREE/doc/src/assistant-manual.qdoc \ +qhp.Qt.excluded += $QT_SOURCE_TREE/doc/src/assistant-manual.qdoc \ $QT_SOURCE_TREE/doc/src/examples/simpletextviewer.qdoc \ $QT_SOURCE_TREE/doc/src/designer-manual.qdoc \ $QT_SOURCE_TREE/doc/src/examples/calculatorbuilder.qdoc \ diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index a085768..25cdc5a 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -92,7 +92,11 @@ excludedirs = $QT_SOURCE_TREE/src/3rdparty/clucene \ $QT_SOURCE_TREE/src/3rdparty/webkit/WebCore \ $QT_SOURCE_TREE/src/3rdparty/wintab \ $QT_SOURCE_TREE/src/3rdparty/zlib \ - $QT_SOURCE_TREE/doc/src/snippets + $QT_SOURCE_TREE/doc/src/snippets \ + $QT_SOURCE_TREE/src/3rdparty/phonon/gstreamer \ + $QT_SOURCE_TREE/src/3rdparty/phonon/ds9 \ + $QT_SOURCE_TREE/src/3rdparty/phonon/qt7 \ + $QT_SOURCE_TREE/src/3rdparty/phonon/waveout sources.fileextensions = "*.cpp *.qdoc *.mm" examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp" -- cgit v0.12 From 2cb93d0c1f80c572c5cfa5074a6cfae81a3b28d2 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Thu, 5 Mar 2009 17:34:21 -0500 Subject: Improvements to follow the behavior of web servers and other browsers, specifically match the behavior of Firefox which servers test against. - When updating the cache metadata don't update content-* headers - Don't lowercase headers names when updating them - Fixed a typo in QNETWORKACCESSHTTPBACKEND_DEBUG code Originally seen on http://www.bibelbund.de/htm/99-4-306.htm where on refresh the 304 will set the content type of text/plain. Signed-off-by: Thiago Macieira Signed-off-by: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 4b41aa7..227a578 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -951,6 +951,7 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo QList newHeaders = rawHeaderList(); foreach (QByteArray header, newHeaders) { + QByteArray originalHeader = header; header = header.toLower(); bool hop_by_hop = (header == "connection" @@ -974,19 +975,32 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo continue; } + it = cacheHeaders.findRawHeader(header); + if (it != cacheHeaders.rawHeaders.constEnd()) { + // Match the behavior of Firefox and assume Cache-Control: "no-transform" + if (header == "content-encoding" + || header == "content-range" + || header == "content-type") + continue; + + // For MS servers that send "Content-Length: 0" on 304 responses + // ignore this too + if (header == "content-length") + continue; + } + #if defined(QNETWORKACCESSHTTPBACKEND_DEBUG) QByteArray n = rawHeader(header); QByteArray o; - it = cacheHeaders.findRawHeader(header); if (it != cacheHeaders.rawHeaders.constEnd()) o = (*it).second; - if (n != o && header != "Date") { + if (n != o && header != "date") { qDebug() << "replacing" << header; qDebug() << "new" << n; qDebug() << "old" << o; } #endif - cacheHeaders.setRawHeader(header, rawHeader(header)); + cacheHeaders.setRawHeader(originalHeader, rawHeader(header)); } metaData.setRawHeaders(cacheHeaders.rawHeaders); -- cgit v0.12 From ca7651e37599e0743ea37036dd3c7f891565fed8 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Fri, 20 Mar 2009 15:11:06 -0400 Subject: When loading a url straight from cache call finished so the QNetworkReply::finished() signal is emited. Signed-off-by: Thiago Macieira Signed-off-by: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 227a578..b09e9a6 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -527,8 +527,10 @@ void QNetworkAccessHttpBackend::postRequest() foreach (const QByteArray &header, headers) httpRequest.setHeaderField(header, request().rawHeader(header)); - if (loadedFromCache) + if (loadedFromCache) { + QNetworkAccessBackend::finished(); return; // no need to send the request! :) + } httpReply = http->sendRequest(httpRequest); httpReply->setParent(this); -- cgit v0.12 From fe6f08387f726d45536c13c00604b8290237af51 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Thu, 19 Feb 2009 13:16:41 -0500 Subject: Check for a redirection after setting the headers. If there is a redirection the location header will be used to determine where to go. Signed-off-by: Thiago Macieira Signed-off-by: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index b09e9a6..401dc71 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -888,8 +888,6 @@ bool QNetworkAccessHttpBackend::sendCacheContents(const QNetworkCacheMetaData &m if (status < 100) status = 200; // fake it - checkForRedirect(status); - setAttribute(QNetworkRequest::HttpStatusCodeAttribute, status); setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute)); setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true); @@ -900,6 +898,8 @@ bool QNetworkAccessHttpBackend::sendCacheContents(const QNetworkCacheMetaData &m for ( ; it != end; ++it) setRawHeader(it->first, it->second); + checkForRedirect(status); + writeDownstreamData(contents); #if defined(QNETWORKACCESSHTTPBACKEND_DEBUG) qDebug() << "Successfully sent cache:" << url() << contents->size() << "bytes"; -- cgit v0.12 From 79f02e7dbd28f3a60deeb083afb3c74a14430a88 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Mon, 16 Mar 2009 14:05:22 -0400 Subject: When parsing a cookie string the ',' character is special because it is used in the date and to differentiate between multiple cookies. When there are multiple set-cookie headers rather then combining them with ', ' use '\n' like Firefox because we are 100% sure that we have multiple cookies and using , can result in cases where the , is interpreted as as part of the date such as the following set-cookie:a=b; expires=2009 mar 10 set-cookie:c=d Combined the old way they result in the second cookie being ignored a=b; expires=2009 mar 10, c=d Using '\n' moves our cookie parser closer to Firefox's algorithm which will result in more behavior and bug for bug compatibility. Attempting to be smarter about the , will result in incompatibility with Firefox's implementation (as my first attempt at fixing this bug resulted). Also when parsing multiple cookies when we have an error don't return an empty list of cookies, but return the list of cookies we were able to parse successfully so far. Signed-off-by: Thiago Macieira Signed-off-by: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 8 ++++++-- src/network/access/qnetworkcookie.cpp | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 401dc71..a52b5a0 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -769,8 +769,12 @@ void QNetworkAccessHttpBackend::replyHeaderChanged() for (; it != end; ++it) { QByteArray value = rawHeader(it->first); - if (!value.isEmpty()) - value += ", "; + if (!value.isEmpty()) { + if (it->first.toLower() == "set-cookie") + value += "\n"; + else + value += ", "; + } value += it->second; setRawHeader(it->first, value); } diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 1235960..5c28ff3 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -543,11 +543,17 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin while (position < length) { QNetworkCookie cookie; + // When there are multiple SetCookie headers they are join with a new line + // \n will always be the start of a new cookie + int endOfSetCookie = cookieString.indexOf('\n'); + if (endOfSetCookie == -1) + endOfSetCookie = length; + // The first part is always the "NAME=VALUE" part QPair field = nextField(cookieString, position); if (field.first.isEmpty() || field.second.isNull()) // parsing error - return QList(); + break; cookie.setName(field.first); cookie.setValue(field.second); @@ -664,6 +670,8 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin } position = nextNonWhitespace(cookieString, position); + if (position > endOfSetCookie) + endOfCookie = true; } result += cookie; -- cgit v0.12 From b790584708a8090211c1897e85f8b3d6df7afa29 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Mar 2009 12:59:56 +0100 Subject: Fix bug introduced by last patch. Make sure that we can handle two Set-Cookie headers. Signed-off-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 5c28ff3..a327bc0 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -559,7 +559,7 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin position = nextNonWhitespace(cookieString, position); bool endOfCookie = false; - while (!endOfCookie && position < length) + while (!endOfCookie && position < endOfSetCookie) switch (cookieString.at(position++)) { case ',': // end of the cookie -- cgit v0.12 From 0fe33578f03a0966c42f9fc44d80a49495f87878 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Thu, 26 Feb 2009 12:21:37 -0500 Subject: Change cookie expiration reading to match the behavior of Firefox. Rather then only allowing the three date formats that are in the rfc allow a much wider set of date strings. Because many browsers support this many websites send dates strings that are not in the rfc format. See documentation in parseDateString for more details about the implementation. Signed-off-by: Thiago Macieira Signed-off-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 437 +++++++++++++++++++++++++++++----- 1 file changed, 384 insertions(+), 53 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index a327bc0..b127f18 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -49,6 +49,7 @@ #include "QtCore/qlist.h" #include "QtCore/qlocale.h" #include "QtCore/qstring.h" +#include "QtCore/qstringlist.h" #include "QtCore/qurl.h" #include "private/qobject_p.h" @@ -513,6 +514,385 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const return result; } +static const char zones[] = + "pst\0" // -8 + "pdt\0" + "mst\0" // -7 + "mdt\0" + "cst\0" // -6 + "cdt\0" + "est\0" // -5 + "edt\0" + "ast\0" // -4 + "nst\0" // -3 + "gmt\0" // 0 + "utc\0" + "bst\0" + "met\0" // 1 + "eet\0" // 2 + "jst\0" // 9 + "\0"; +static int zoneOffsets[] = {-8, -8, -7, -7, -6, -6, -5, -5, -4, -3, 0, 0, 0, 1, 2, 9 }; + +static const char months[] = + "jan\0" + "feb\0" + "mar\0" + "apr\0" + "may\0" + "jun\0" + "jul\0" + "aug\0" + "sep\0" + "oct\0" + "nov\0" + "dec\0" + "\0"; + +static inline bool isNumber(char s) { return s >= '0' && s <= '9'; } +static inline bool isTerminator (char c) { return c == '\n' || c == '\r'; } +static inline bool isValueSeparator (char c) { return isTerminator(c) || c == ';'; } +static inline bool isWhitespace (char c) { return c == ' ' || c == '\t'; } + +static bool checkStaticArray(int &val, const QByteArray &dateString, int at, const char *array, size_t size) { + if (dateString[at] < 'a' || dateString[at] > 'z') + return false; + if (val == -1 && dateString.length() >= at + 3) { + int j = 0; + size_t i = 0; + while (i <= size) { + const char *str(array + i); + if (str[0] == dateString[at] + && str[1] == dateString[at + 1] + && str[2] == dateString[at + 2]) { + val = j; + return true; + } + i += strlen(str) + 1; + ++j; + } + } + return false; +} + +//#define PARSEDATESTRINGDEBUG + +#define ADAY 1 +#define AMONTH 2 +#define AYEAR 4 + +/* + Parse all the date formats that Firefox can. + + The official format is: + expires=ddd(d)?, dd-MMM-yyyy hh:mm:ss GMT + + But browsers have been supporting a very wide range of date + strings. To work on many sites we need to support more then + just the official date format. + + For reference see Firefox's PR_ParseTimeStringToExplodedTime in + prtime.c. The Firefox date parser is coded in a very complex way + and is slightly over ~700 lines long. While this implementation + will be slightly slower for the non standard dates it is smaller, + more readable, and maintainable. + + Or in their own words: + "} // else what the hell is this." +*/ +static QDateTime parseDateString(const QByteArray &dateString) +{ + QTime time; + // placeholders for values when we are not sure it is a year, month or day + int unknown[3] = {-1, -1, -1}; + int month = -1; + int day = -1; + int year = -1; + int zoneOffset = -1; + + // hour:minute:second.ms pm + QRegExp timeRx(QLatin1String("(\\d{1,2}):(\\d{1,2})(:(\\d{1,2})|)(\\.(\\d{1,3})|)((\\s{0,}(am|pm))|)")); + + int at = 0; + while (at < dateString.length()) { +#ifdef PARSEDATESTRINGDEBUG + qDebug() << dateString.mid(at); +#endif + bool isNum = isNumber(dateString[at]); + + // Month + if (!isNum + && checkStaticArray(month, dateString, at, months, sizeof(months)- 1)) { + ++month; +#ifdef PARSEDATESTRINGDEBUG + qDebug() << "Month:" << month; +#endif + at += 3; + continue; + } + // Zone + if (!isNum + && zoneOffset == -1 + && checkStaticArray(zoneOffset, dateString, at, zones, sizeof(zones)- 1)) { + int sign = (at >= 0 && dateString[at - 1] == '-') ? -1 : 1; + zoneOffset = sign * zoneOffsets[zoneOffset] * 60 * 60; +#ifdef PARSEDATESTRINGDEBUG + qDebug() << "Zone:" << month; +#endif + at += 3; + continue; + } + // Zone offset + if (!isNum + && (zoneOffset == -1 || zoneOffset == 0) // Can only go after gmt + && (dateString[at] == '+' || dateString[at] == '-') + && (at == 0 + || isWhitespace(dateString[at - 1]) + || dateString[at - 1] == ',' + || (dateString[at - 1] == 't'))) { + + int end = 1; + while (dateString[at + end] >= '0' && dateString[at + end] <= '9' + && end < 5) + ++end; + int minutes = 0; + int hours = 0; + switch (end - 1) { + case 4: + minutes = atoi(dateString.mid(at + 3, 2).constData()); + // fall through + case 2: + hours = atoi(dateString.mid(at + 1, 2).constData()); + break; + case 1: + hours = atoi(dateString.mid(at + 1, 1).constData()); + break; + default: + at += end; + continue; + } + if (end != 1) { + int sign = dateString[at] == '-' ? -1 : 1; + zoneOffset = sign * ((minutes * 60) + (hours * 60 * 60)); +#ifdef PARSEDATESTRINGDEBUG + qDebug() << "Zone offset:" << zoneOffset << hours << minutes; +#endif + at += end; + continue; + } + } + + // Time + if (isNum && time.isNull() + && dateString.length() >= at + 3 + && (dateString[at + 2] == ':' || dateString[at + 1] == ':')) { + // While the date can be found all over the string the format + // for the time is set and a nice regexp can be used. + int pos = timeRx.indexIn(QLatin1String(dateString), at); + if (pos != -1) { + QStringList list = timeRx.capturedTexts(); + int h = atoi(list.at(1).toLatin1().constData()); + int m = atoi(list.at(2).toLatin1().constData()); + int s = atoi(list.at(4).toLatin1().constData()); + int ms = atoi(list.at(6).toLatin1().constData()); + if (h < 12 && !list.at(9).isEmpty()) + if (list.at(9) == QLatin1String("pm")) + h += 12; + time = QTime(h, m, s, ms); +#ifdef PARSEDATESTRINGDEBUG + qDebug() << "Time:" << list << timeRx.matchedLength(); +#endif + at += timeRx.matchedLength(); + continue; + } + } + + // 4 digit Year + if (isNum + && year == -1 + && dateString.length() >= at + 3) { + if (isNumber(dateString[at + 1]) + && isNumber(dateString[at + 2]) + && isNumber(dateString[at + 3])) { + year = atoi(dateString.mid(at, 4).constData()); + at += 4; +#ifdef PARSEDATESTRINGDEBUG + qDebug() << "Year:" << year; +#endif + continue; + } + } + + // a one or two digit number + // Could be month, day or year + if (isNum) { + int length = 1; + if (dateString.length() >= at + 1 + && isNumber(dateString[at + 1])) + ++length; + int x = atoi(dateString.mid(at, length).constData()); + if (year == -1 && (x > 31 || x == 0)) { + year = x; + } else { + if (unknown[0] == -1) unknown[0] = x; + else if (unknown[1] == -1) unknown[1] = x; + else if (unknown[2] == -1) unknown[2] = x; + } + at += length; +#ifdef PARSEDATESTRINGDEBUG + qDebug() << "Saving" << x; +#endif + continue; + } + + // Unknown character, typically a weekday such as 'Mon' + ++at; + } + + // Once we are done parsing the string take the digits in unknown + // and determine which is the unknown year/month/day + + int couldBe[3] = { 0, 0, 0 }; + int unknownCount = 3; + for (int i = 0; i < unknownCount; ++i) { + if (unknown[i] == -1) { + couldBe[i] = ADAY | AYEAR | AMONTH; + unknownCount = i; + continue; + } + + if (unknown[i] >= 1) + couldBe[i] = ADAY; + + if (month == -1 && unknown[i] >= 1 && unknown[i] <= 12) + couldBe[i] |= AMONTH; + + if (year == -1) + couldBe[i] |= AYEAR; + } + + // For any possible day make sure one of the values that could be a month + // can contain that day. + // For any possible month make sure one of the values that can be a + // day that month can have. + // Example: 31 11 06 + // 31 can't be a day because 11 and 6 don't have 31 days + for (int i = 0; i < unknownCount; ++i) { + int currentValue = unknown[i]; + bool findMatchingMonth = couldBe[i] & ADAY && currentValue >= 29; + bool findMatchingDay = couldBe[i] & AMONTH; + if (!findMatchingMonth || !findMatchingDay) + continue; + for (int j = 0; j < 3; ++j) { + if (j == i) + continue; + for (int k = 0; k < 2; ++k) { + if (k == 0 && !(findMatchingMonth && (couldBe[j] & AMONTH))) + continue; + else if (k == 1 && !(findMatchingDay && (couldBe[j] & ADAY))) + continue; + int m = currentValue; + int d = unknown[j]; + if (k == 0) + qSwap(m, d); + if (m == -1) m = month; + bool found = true; + switch(m) { + case 2: + // When we get 29 and the year ends up having only 28 + // See date.isValid below + // Example: 29 23 Feb + if (d <= 29) + found = false; + break; + case 4: case 6: case 9: case 11: + if (d <= 30) + found = false; + break; + default: + if (d > 0 && d <= 31) + found = false; + } + if (k == 0) findMatchingMonth = found; + else if (k == 1) findMatchingDay = found; + } + } + if (findMatchingMonth) + couldBe[i] &= ~ADAY; + if (findMatchingDay) + couldBe[i] &= ~AMONTH; + } + + // First set the year/month/day that have been deduced + // and reduce the set as we go along to deduce more + for (int i = 0; i < unknownCount; ++i) { + int unset = 0; + for (int j = 0; j < 3; ++j) { + if (couldBe[j] == ADAY && day == -1) { + day = unknown[j]; + unset |= ADAY; + } else if (couldBe[j] == AMONTH && month == -1) { + month = unknown[j]; + unset |= AMONTH; + } else if (couldBe[j] == AYEAR && year == -1) { + year = unknown[j]; + unset |= AYEAR; + } else { + // common case + break; + } + couldBe[j] &= ~unset; + } + } + + // Now fallback to a standardized order to fill in the rest with + for (int i = 0; i < unknownCount; ++i) { + if (couldBe[i] & AMONTH && month == -1) month = unknown[i]; + else if (couldBe[i] & ADAY && day == -1) day = unknown[i]; + else if (couldBe[i] & AYEAR && year == -1) year = unknown[i]; + } +#ifdef PARSEDATESTRINGDEBUG + qDebug() << "Final set" << year << month << day; +#endif + + if (year == -1 || month == -1 || day == -1) { +#ifdef PARSEDATESTRINGDEBUG + qDebug() << "Parser failure" << year << month << day; +#endif + return QDateTime(); + } + + // Y2k behavior + int y2k = 0; + if (year < 70) + y2k = 2000; + else if (year < 100) + y2k = 1900; + + QDate date(year + y2k, month, day); + + // When we were given a bad cookie that when parsed + // set the day to 29 and the year to one that doesn't + // have the 29th of Feb rather then adding the extra + // complicated checking earlier just swap here. + // Example: 29 23 Feb + if (!date.isValid()) + date = QDate(day + y2k, month, year); + + QDateTime dateTime; + + if (zoneOffset == -1) { + dateTime = QDateTime(date, time); + dateTime = dateTime.toTimeSpec(Qt::UTC); + } else { + dateTime = QDateTime(date, time, Qt::UTC); + dateTime = dateTime.addSecs(zoneOffset); + } + if (!dateTime.isValid()) + return QDateTime(); + return dateTime; +} + /*! Parses the cookie string \a cookieString as received from a server response in the "Set-Cookie:" header. If there's a parsing error, @@ -572,64 +952,15 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin field.first = field.first.toLower(); // everything but the NAME=VALUE is case-insensitive if (field.first == "expires") { - static const char dateFormats[] = - "d-MMM-yyyy hh:mm:ss\0" - "d MMM yyyy hh:mm:ss\0" - "d-MMM-yy hh:mm:ss\0" - "\0"; - - // expires is a special case because it contains a naked comma - // and naked spaces. The format is: - // expires=ddd(d)?, dd-MMM-yyyy hh:mm:ss GMT - // but we also accept standard HTTP dates - - // make sure we're at the comma - if (position >= length || cookieString.at(position) != ',') - // invalid cookie string - return QList(); - - ++position; + position -= field.second.length(); int end; for (end = position; end < length; ++end) - if (cookieString.at(end) == ',' || cookieString.at(end) == ';') + if (isValueSeparator(cookieString.at(end))) break; - QByteArray datestring = cookieString.mid(position, end - position).trimmed(); + QByteArray dateString = cookieString.mid(position, end - position).trimmed(); position = end; - if (datestring.endsWith(" GMT") || datestring.endsWith(" UTC")) - datestring.chop(4); - else if (datestring.endsWith(" +0000")) - datestring.chop(6); - - size_t i = 0; - int j = 0; - QLocale cLocale = QLocale::c(); - QDateTime dt; - do { - QLatin1String df(dateFormats + i); - i += strlen(dateFormats + i) + 1; - -#ifndef QT_NO_DATESTRING - dt = cLocale.toDateTime(QString::fromLatin1(datestring), df); - - // some cookies are set with a two-digit year - // (although this is not allowed); this is interpreted as a year - // in the 20th century by QDateTime. - // Work around this case here (assuming 00-69 is 21st century, - // 70-99 is 20th century) - QDate date = dt.date(); - if (j == 2 && date.year() >= 1900 && date.year() < 1970) - dt = dt.addYears(100); - if (date.year() >= 0 && date.year() < 100) - dt = dt.addYears(1900); -#endif - j++; - } while (!dt.isValid() && i <= sizeof dateFormats - 1); - if (!dt.isValid()) - // invalid cookie string - return QList(); - - dt.setTimeSpec(Qt::UTC); + QDateTime dt = parseDateString(dateString.toLower()); cookie.setExpirationDate(dt); } else if (field.first == "domain") { QByteArray rawDomain = field.second; -- cgit v0.12 From 83dc49feaf56bdf469388174972fa6fc815b844b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Mar 2009 14:52:03 +0100 Subject: Fix a few issues introduced by Ben's last patch. Test if we're not past the end of the array before we attempt to read it. Dates without timezone information are taken to be UTC, so merge the code. If the date parsing failed, don't add a malformed cookie. Better to have no cookie than to have it for past its expiration date. Also update the autotests, since we now can cope with some of the invalid cookies seen on the net. Signed-off-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 39 +++++++++++++++--------- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 11 +++---- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index b127f18..56cb539 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -549,17 +549,25 @@ static const char months[] = "dec\0" "\0"; -static inline bool isNumber(char s) { return s >= '0' && s <= '9'; } -static inline bool isTerminator (char c) { return c == '\n' || c == '\r'; } -static inline bool isValueSeparator (char c) { return isTerminator(c) || c == ';'; } -static inline bool isWhitespace (char c) { return c == ' ' || c == '\t'; } +static inline bool isNumber(char s) +{ return s >= '0' && s <= '9'; } -static bool checkStaticArray(int &val, const QByteArray &dateString, int at, const char *array, size_t size) { +static inline bool isTerminator(char c) +{ return c == '\n' || c == '\r'; } + +static inline bool isValueSeparator(char c) +{ return isTerminator(c) || c == ';'; } + +static inline bool isWhitespace(char c) +{ return c == ' ' || c == '\t'; } + +static bool checkStaticArray(int &val, const QByteArray &dateString, int at, const char *array, int size) +{ if (dateString[at] < 'a' || dateString[at] > 'z') return false; if (val == -1 && dateString.length() >= at + 3) { int j = 0; - size_t i = 0; + int i = 0; while (i <= size) { const char *str(array + i); if (str[0] == dateString[at] @@ -652,8 +660,7 @@ static QDateTime parseDateString(const QByteArray &dateString) || (dateString[at - 1] == 't'))) { int end = 1; - while (dateString[at + end] >= '0' && dateString[at + end] <= '9' - && end < 5) + while (end < 5 && dateString[at + end] >= '0' && dateString[at + end] <= '9') ++end; int minutes = 0; int hours = 0; @@ -879,13 +886,9 @@ static QDateTime parseDateString(const QByteArray &dateString) if (!date.isValid()) date = QDate(day + y2k, month, year); - QDateTime dateTime; + QDateTime dateTime(date, time, Qt::UTC); - if (zoneOffset == -1) { - dateTime = QDateTime(date, time); - dateTime = dateTime.toTimeSpec(Qt::UTC); - } else { - dateTime = QDateTime(date, time, Qt::UTC); + if (zoneOffset != -1) { dateTime = dateTime.addSecs(zoneOffset); } if (!dateTime.isValid()) @@ -961,6 +964,11 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin QByteArray dateString = cookieString.mid(position, end - position).trimmed(); position = end; QDateTime dt = parseDateString(dateString.toLower()); + if (!dt.isValid()) { + cookie = QNetworkCookie(); + endOfCookie = true; + continue; + } cookie.setExpirationDate(dt); } else if (field.first == "domain") { QByteArray rawDomain = field.second; @@ -1005,7 +1013,8 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin endOfCookie = true; } - result += cookie; + if (!cookie.name().isEmpty()) + result += cookie; } return result; diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 9010db4..4da17d9 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -315,6 +315,9 @@ void tst_QNetworkCookie::parseSingleCookie_data() cookie.setExpirationDate(QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59), Qt::UTC)); QTest::newRow("network2") << "__siteid=1; expires=Fri, 31-Dec-9999 23:59:59 GMT; path=/" << cookie; + cookie = QNetworkCookie("YM.LC", "v=2&m=9993_262838_159_1558_1063_0_5649_4012_3776161073,9426_260205_549_1295_1336_0_5141_4738_3922731647,6733_258196_952_1364_643_0_3560_-1_0,3677_237633_1294_1294_19267_0_3244_29483_4102206176,1315_235149_1693_1541_941_0_3224_1691_1861378060,1858_214311_2100_1298_19538_0_2873_30900_716411652,6258_212007_2506_1285_1017_0_2868_3606_4288540264,3743_207884_2895_1362_2759_0_2545_7114_3388520216,2654_205253_3257_1297_1332_0_2504_4682_3048534803,1891_184881_3660_1291_19079_0_978_29178_2592538685&f=1&n=20&s=date&o=down&e=1196548712&b=Inbox&u=removed"); + cookie.setPath("/"); + cookie.setDomain("mail.yahoo.com"); QTest::newRow("network3") << "YM.LC=v=2&m=9993_262838_159_1558_1063_0_5649_4012_3776161073,9426_260205_549_1295_1336_0_5141_4738_3922731647,6733_258196_952_1364_643_0_3560_-1_0,3677_237633_1294_1294_19267_0_3244_29483_4102206176,1315_235149_1693_1541_941_0_3224_1691_1861378060,1858_214311_2100_1298_19538_0_2873_30900_716411652,6258_212007_2506_1285_1017_0_2868_3606_4288540264,3743_207884_2895_1362_2759_0_2545_7114_3388520216,2654_205253_3257_1297_1332_0_2504_4682_3048534803,1891_184881_3660_1291_19079_0_978_29178_2592538685&f=1&n=20&s=date&o=down&e=1196548712&b=Inbox&u=removed; path=/; domain=mail.yahoo.com" << cookie; cookie = QNetworkCookie("__ac", "c2hhdXNtYW46U2FTYW80Wm8%3D"); @@ -330,9 +333,9 @@ void tst_QNetworkCookie::parseSingleCookie() QList result = QNetworkCookie::parseCookies(cookieString.toLatin1()); - QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort); - QEXPECT_FAIL("network3", "Cookie value contains commas, violating the HTTP spec", Abort); + //QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort); QCOMPARE(result.count(), 1); + QEXPECT_FAIL("network3", "Cookie value contains commas, violating the HTTP spec", Abort); QCOMPARE(result.at(0), expectedCookie); result = QNetworkCookie::parseCookies(result.at(0).toRawForm()); @@ -358,9 +361,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data() // reason: malformed NAME=VALUE pair QTest::newRow("invalid-05") << "foo" << list; QTest::newRow("invalid-06") << "=b" << list; - QTest::newRow("invalid-08") << "a=b,foo" << list; QTest::newRow("invalid-09") << "foo,a=b" << list; - QTest::newRow("invalid-10") << "a=b,=b" << list; QTest::newRow("invalid-11") << ";path=/" << list; // reason: malformed expiration date string @@ -369,8 +370,6 @@ void tst_QNetworkCookie::parseMultipleCookies_data() QTest::newRow("invalid-14") << "a=b;expires=foobar, abc" << list; QTest::newRow("invalid-15") << "a=b;expires=foobar, dd-mmm-yyyy hh:mm:ss GMT; path=/" << list; QTest::newRow("invalid-16") << "a=b;expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list; - QTest::newRow("invalid-17") << "a=b,c=d;expires=" << list; - QTest::newRow("invalid-18") << "a=b, c=d; expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list; QNetworkCookie cookie; cookie.setName("a"); -- cgit v0.12 From 36b7256f87f97a84f1a1331c68d5ef7783aef9ab Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Mar 2009 15:47:04 +0100 Subject: When doing date comparisons, force to the same timezone. It's the logical time that matters, not the exact date representation. Signed-off-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 56cb539..852fcd6 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -164,7 +164,7 @@ bool QNetworkCookie::operator==(const QNetworkCookie &other) const return true; return d->name == other.d->name && d->value == other.d->value && - d->expirationDate == other.d->expirationDate && + d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && d->domain == other.d->domain && d->path == other.d->path && d->secure == other.d->secure && -- cgit v0.12 From fde8457213eaa3da881d1afa8f9f2294acdc4877 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Mar 2009 15:47:59 +0100 Subject: Fix parsing of dates: if the month is followed by a dash, it's not the negative sign. I don't know why, but this only triggers for the month of October Signed-off-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 852fcd6..286c5f6 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -636,6 +636,8 @@ static QDateTime parseDateString(const QByteArray &dateString) qDebug() << "Month:" << month; #endif at += 3; + if (at < dateString.length() && dateString[at] == '-') + ++at; continue; } // Zone -- cgit v0.12 From 9cc1b5573affdfcf1862369afe387c8fdf8474e6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Mar 2009 15:48:18 +0100 Subject: Fix accesses past-the-end of the byte array Signed-off-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 286c5f6..4846618 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -662,7 +662,8 @@ static QDateTime parseDateString(const QByteArray &dateString) || (dateString[at - 1] == 't'))) { int end = 1; - while (end < 5 && dateString[at + end] >= '0' && dateString[at + end] <= '9') + while (end < 5 && dateString.length() > at+end + && dateString[at + end] >= '0' && dateString[at + end] <= '9') ++end; int minutes = 0; int hours = 0; @@ -736,7 +737,7 @@ static QDateTime parseDateString(const QByteArray &dateString) // Could be month, day or year if (isNum) { int length = 1; - if (dateString.length() >= at + 1 + if (dateString.length() > at + 1 && isNumber(dateString[at + 1])) ++length; int x = atoi(dateString.mid(at, length).constData()); -- cgit v0.12 From ece28c5e497c5a7ce1f7671094c5ff3e58d176c5 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Thu, 26 Mar 2009 15:53:09 +0100 Subject: Autotest: more date-time parsing tests for QNetworkCookie Signoff-by: Thiago Macieira Signed-off-by: Peter Hartmann --- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 264 +++++++++++++++++++++++ 1 file changed, 264 insertions(+) diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 4da17d9..2187b61 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -286,8 +286,263 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("expiration3") << "a=b; expires=Wednesday, 09-Nov-1999 23:12:40 GMT " << cookie; QTest::newRow("expiration-utc") << "a=b;expires=Wednesday, 09-Nov-1999 23:12:40 UTC" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("time-0") << "a=b;expires=14 Apr 89 03:20" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 0), Qt::UTC)); + QTest::newRow("time-1") << "a=b;expires=14 Apr 89 03:20:12" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-2") << "a=b;expires=14 Apr 89 03:20:12.88" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-3") << "a=b;expires=14 Apr 89 03:20:12.88am" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-4") << "a=b;expires=14 Apr 89 03:20:12.88pm" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-5") << "a=b;expires=14 Apr 89 03:20:12.88 Am" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-6") << "a=b;expires=14 Apr 89 03:20:12.88 PM" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-7") << "a=b;expires=14 Apr 89 3:20:12.88 PM" << cookie; + + // normal months + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-1") << "a=b;expires=Jan 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 2, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-2") << "a=b;expires=Feb 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-3") << "a=b;expires=mar 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-4") << "a=b;expires=Apr 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 5, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-5") << "a=b;expires=May 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 6, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-6") << "a=b;expires=Jun 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 7, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-7") << "a=b;expires=Jul 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 8, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-8") << "a=b;expires=Aug 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 9, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-9") << "a=b;expires=Sep 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 10, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-10") << "a=b;expires=Oct 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 11, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-11") << "a=b;expires=Nov 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 12, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-12") << "a=b;expires=Dec 1 89 1:1" << cookie; + + // extra months + cookie.setExpirationDate(QDateTime(QDate(1989, 12, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-13") << "a=b;expires=December 1 89 1:1" << cookie; + QTest::newRow("months-14") << "a=b;expires=1 89 1:1 Dec" << cookie; + //cookie.setExpirationDate(QDateTime()); + //QTest::newRow("months-15") << "a=b;expires=1 89 1:1 De" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2024, 2, 29), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-16") << "a=b;expires=2024 29 Feb 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2024, 2, 29), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-17") << "a=b;expires=Fri, 29-Feb-2024 01:01:00 GMT" << cookie; + QTest::newRow("months-18") << "a=b;expires=2024 29 Feb 1:1 GMT" << cookie; + + // normal offsets + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-0") << "a=b;expires=Jan 1 89 8:0 PST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-1") << "a=b;expires=Jan 1 89 8:0 PDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-2") << "a=b;expires=Jan 1 89 7:0 MST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-3") << "a=b;expires=Jan 1 89 7:0 MDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-4") << "a=b;expires=Jan 1 89 6:0 CST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-5") << "a=b;expires=Jan 1 89 6:0 CDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-6") << "a=b;expires=Jan 1 89 5:0 EST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-7") << "a=b;expires=Jan 1 89 5:0 EDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-8") << "a=b;expires=Jan 1 89 4:0 AST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-9") << "a=b;expires=Jan 1 89 3:0 NST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-10") << "a=b;expires=Jan 1 89 0:0 GMT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-11") << "a=b;expires=Jan 1 89 0:0 BST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-12") << "a=b;expires=Jan 1 89 23:0 MET" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-13") << "a=b;expires=Jan 1 89 22:0 EET" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-14") << "a=b;expires=Jan 1 89 15:0 JST" << cookie; + + // extra offsets + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-14") << "a=b;expires=Jan 1 89 15:0 JST+1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-15") << "a=b;expires=Jan 1 89 0:0 GMT+1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-15b") << "a=b;expires=Jan 1 89 1:0 GMT-1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-16") << "a=b;expires=Jan 1 89 0:0 GMT+01" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 5), Qt::UTC)); + QTest::newRow("zoneoffset-17") << "a=b;expires=Jan 1 89 0:0 GMT+0105" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-18") << "a=b;expires=Jan 1 89 0:0 GMT+015" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-19") << "a=b;expires=Jan 1 89 0:0 GM" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-19b") << "a=b;expires=Jan 1 89 0:0 GMT" << cookie; + + // offsets from gmt + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-20") << "a=b;expires=Jan 1 89 0:0 +1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-21") << "a=b;expires=Jan 1 89 0:0 +01" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("zoneoffset-22") << "a=b;expires=Jan 1 89 0:0 +0101" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-23") << "a=b;expires=Jan 1 89 1:0 -1" << cookie; + + // Y2k + cookie.setExpirationDate(QDateTime(QDate(2000, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-0") << "a=b;expires=Jan 1 00 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-1") << "a=b;expires=Jan 1 70 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1971, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-2") << "a=b;expires=Jan 1 71 0:0" << cookie; + + // Day, month, year + cookie.setExpirationDate(QDateTime(QDate(2013, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("date-0") << "a=b;expires=Jan 2 13 0:0" << cookie; + QTest::newRow("date-1") << "a=b;expires=1-2-13 0:0" << cookie; + QTest::newRow("date-2") << "a=b;expires=1/2/13 0:0" << cookie; + QTest::newRow("date-3") << "a=b;expires=Jan 2 13 0:0" << cookie; + QTest::newRow("date-4") << "a=b;expires=Jan 2, 13 0:0" << cookie; + QTest::newRow("date-5") << "a=b;expires=1-2-13 0:0" << cookie; + QTest::newRow("date-6") << "a=b;expires=1/2/13 0:0" << cookie; + + // Known Year, determine month and day + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 13), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownyear-0") << "a=b;expires=13/1/95 0:0" << cookie; + QTest::newRow("knownyear-1") << "a=b;expires=95/13/1 0:0" << cookie; + QTest::newRow("knownyear-2") << "a=b;expires=1995/1/13 0:0" << cookie; + QTest::newRow("knownyear-3") << "a=b;expires=1995/13/1 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownyear-4") << "a=b;expires=1/2/95 0:0" << cookie; + QTest::newRow("knownyear-5") << "a=b;expires=95/1/2 0:0" << cookie; + + // Known Year, Known day, determining month + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 13), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownYD-0") << "a=b;expires=13/1/95 0:0" << cookie; + QTest::newRow("knownYD-1") << "a=b;expires=1/13/95 0:0" << cookie; + QTest::newRow("knownYD-2") << "a=b;expires=95/13/1 0:0" << cookie; + QTest::newRow("knownYD-3") << "a=b;expires=95/1/13 0:0" << cookie; + + // Month comes before Year + cookie.setExpirationDate(QDateTime(QDate(2021, 03, 26), QTime(0, 0), Qt::UTC)); + QTest::newRow("month-0") << "a=b;expires=26/03/21 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2015, 12, 30), QTime(16, 25, 0, 0), Qt::UTC)); + QTest::newRow("month-1") << "a=b;expires=wed 16:25pm December 2015 30" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 11), QTime(16, 25, 0, 0), Qt::UTC)); + QTest::newRow("month-2") << "a=b;expires=16:25 11 31 11" << cookie; + + // The very ambiguous cases + // Matching Firefox's behavior of guessing month, day, year in those cases + cookie.setExpirationDate(QDateTime(QDate(2013, 10, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-0") << "a=b;expires=10/2/13 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2013, 2, 10), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-1") << "a=b;expires=2/10/13 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2010, 2, 3), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-2") << "a=b;expires=2/3/10 0:0" << cookie; + + // FYI If you try these in Firefox it wont set a cookie for the following two string + // because 03 is turned into the year at which point it is expired + cookie.setExpirationDate(QDateTime(QDate(2003, 2, 10), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-3") << "a=b;expires=2/10/3 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2003, 10, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-4") << "a=b;expires=10/2/3 0:0" << cookie; + + // These are the cookies that firefox's source says it can parse + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("firefox-0") << "a=b;expires=14 Apr 89 03:20" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("firefox-1") << "a=b;expires=14 Apr 89 03:20 GMT" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 17), QTime(4, 1, 33, 0), Qt::UTC)); + QTest::newRow("firefox-2") << "a=b;expires=Fri, 17 Mar 89 4:01:33" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 17), QTime(4, 1, 0, 0), Qt::UTC)); + QTest::newRow("firefox-3") << "a=b;expires=Fri, 17 Mar 89 4:01 GMT" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 16), QTime(16-8, 12, 0, 0), Qt::UTC)); + QTest::newRow("firefox-4") << "a=b;expires=Mon Jan 16 16:12 PDT 1989" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 16), QTime(17, 42, 0, 0), Qt::UTC)); + QTest::newRow("firefox-5") << "a=b;expires=Mon Jan 16 16:12 +0130 1989" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1992, 5, 6), QTime(16-9, 41, 0, 0), Qt::UTC)); + QTest::newRow("firefox-6") << "a=b;expires=6 May 1992 16:41-JST (Wednesday)" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(10, 59, 12, 82), Qt::UTC)); + QTest::newRow("firefox-7") << "a=b;expires=22-AUG-1993 10:59:12.82" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(22, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-8") << "a=b;expires=22-AUG-1993 10:59pm" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(12, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-9") << "a=b;expires=22-AUG-1993 12:59am" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(12, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-10") << "a=b;expires=22-AUG-1993 12:59 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 8, 4), QTime(15, 54, 0, 0), Qt::UTC)); + QTest::newRow("firefox-11") << "a=b;expires=Friday, August 04, 1995 3:54 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 21), QTime(16, 24, 34, 0), Qt::UTC)); + QTest::newRow("firefox-12") << "a=b;expires=06/21/95 04:24:34 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 20), QTime(21, 7, 0, 0), Qt::UTC)); + QTest::newRow("firefox-13") << "a=b;expires=20/06/95 21:07" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 8), QTime(19-5, 32, 48, 0), Qt::UTC)); + QTest::newRow("firefox-14") << "a=b;expires=95-06-08 19:32:48 EDT" << cookie; + + // Edge cases caught by fuzzing + // These are about the default cause creates dates that don't exits + cookie.setExpirationDate(QDateTime(QDate(2030, 2, 25), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-0") << "a=b; expires=30 -000002 1:1 25;" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 20), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-1") << "a=b; expires=31 11 20 1:1;" << cookie; + + // April only has 30 days + cookie.setExpirationDate(QDateTime(QDate(2031, 4, 30), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-2") << "a=b; expires=31 30 4 1:1" << cookie; + + // 9 must be the month so 31 can't be the day + cookie.setExpirationDate(QDateTime(QDate(2031, 9, 21), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-3") << "a=b; expires=31 21 9 1:1" << cookie; + + // Year is known, then fallback to defaults of filling in month and day + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 1), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-4") << "a=b; expires=31 11 01 1:1" << cookie; + + // 2 must be the month so 30 can't be the day + cookie.setExpirationDate(QDateTime(QDate(2030, 2, 20), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-5") << "a=b; expires=30 02 20 1:1" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2021, 12, 22), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-6") << "a=b; expires=2021 12 22 1:1" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2029, 2, 23), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-7") << "a=b; expires=29 23 Feb 1:1" << cookie; + + // 11 and 6 don't have 31 days + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 06), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-8") << "a=b; expires=31 11 06 1:1" << cookie; + // two-digit years: // from 70 until 99, we assume 20th century + cookie.setExpirationDate(QDateTime(QDate(1999, 11, 9), QTime(23, 12, 40), Qt::UTC)); QTest::newRow("expiration-2digit1") << "a=b; expires=Wednesday, 09-Nov-99 23:12:40 GMT " << cookie; cookie.setExpirationDate(QDateTime(QDate(1970, 1, 1), QTime(23, 12, 40), Qt::UTC)); QTest::newRow("expiration-2digit2") << "a=b; expires=Thursday, 01-Jan-70 23:12:40 GMT " << cookie; @@ -340,6 +595,15 @@ void tst_QNetworkCookie::parseSingleCookie() result = QNetworkCookie::parseCookies(result.at(0).toRawForm()); QCOMPARE(result.count(), 1); + + // Drop any millisecond information, if there's any + QDateTime dt = expectedCookie.expirationDate(); + if (dt.isValid()) { + QTime t = dt.time(); + dt.setTime(t.addMSecs(-t.msec())); + expectedCookie.setExpirationDate(dt); + } + QCOMPARE(result.at(0), expectedCookie); } -- cgit v0.12 From 37b61133eed38dbb8a7b87fce18b6ea016469fdc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Mar 2009 16:00:53 +0100 Subject: Fix parsing of multiple cookies that are separated by a newline Signed-off-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 2 +- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 4846618..fed0afc 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -931,7 +931,7 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin // When there are multiple SetCookie headers they are join with a new line // \n will always be the start of a new cookie - int endOfSetCookie = cookieString.indexOf('\n'); + int endOfSetCookie = cookieString.indexOf('\n', position); if (endOfSetCookie == -1) endOfSetCookie = length; diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 2187b61..36a4b45 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -680,6 +680,26 @@ void tst_QNetworkCookie::parseMultipleCookies_data() list << cookie; QTest::newRow("network1") << "id=51706646077999719 bb=\"K14144t\"_AAQ\"ototrK_A_ttot44AQ4KwoRQtoto| adv=; Domain=.bluestreak.com; expires=Tuesday 05-Dec-2017 09:11:07 GMT; path=/;" << list; + QNetworkCookie cookieA; + cookieA.setName("a"); + cookieA.setValue("b"); + + QNetworkCookie cookieB; + cookieB.setName("c"); + cookieB.setValue("d"); + + // NewLine + cookieA.setExpirationDate(QDateTime(QDate(2009, 3, 10), QTime(7, 0, 0, 0), Qt::UTC)); + cookieB.setExpirationDate(QDateTime(QDate(2009, 3, 20), QTime(7, 0, 0, 0), Qt::UTC)); + list = QList() << cookieA << cookieB; + QTest::newRow("real-0") << "a=b; expires=Tue Mar 10 07:00:00 2009 GMT\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list; + QTest::newRow("real-1") << "a=b; expires=Tue Mar 10 07:00:00 2009 GMT\n\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list; + QTest::newRow("real-2") << "a=b; expires=Mar 10 07:00:00 2009 GMT, Tue\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list; + + // Match firefox's behavior + cookieA.setPath("/foo"); + list = QList() << cookieA << cookieB; + QTest::newRow("real-3") << "a=b; expires=Mar 10 07:00:00 2009 GMT, Tue; path=/foo\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list; } void tst_QNetworkCookie::parseMultipleCookies() -- cgit v0.12 From 1e7d1500e9351d8fc0cd7d3bc017e974aa45b035 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 30 Mar 2009 08:58:40 -0700 Subject: Compile with QT_NO_DIRECTFB_WM s/QDirectFBSurface/QDirectFBScreen/g Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 00d1781..4ba1102 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -154,7 +154,7 @@ void QDirectFBSurface::setGeometry(const QRect &rect, const QRegion &mask) description.width = rect.width(); description.height = rect.height(); QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, - QDirectFBSurface::instance()->pixelFormat()); + QDirectFBScreen::instance()->pixelFormat()); dfbSurface = QDirectFBScreen::instance()->createDFBSurface(&description, false); } else { Q_ASSERT(dfbSurface); -- cgit v0.12 From 9340b75300d90d055056cdd68d10725de7829bdd Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 30 Mar 2009 09:00:49 -0700 Subject: Compile with QT_NO_DIRECTFB_PREALLOCATED Use the right surface for locking/unlocking. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 87a5910..3a6b3a2 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -161,13 +161,13 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCr if (surface) { char *mem; int bpl; - surface->Lock(dfbSurface, DSLF_WRITE, (void**)&mem, &bpl); + surface->Lock(surface, DSLF_WRITE, (void**)&mem, &bpl); const int h = img.height(); for (int i = 0; i < h; ++i) { memcpy(mem, img.scanLine(i), bpl); mem += bpl; } - surface->Unlock(ret); + surface->Unlock(surface); } #endif #ifndef QT_NO_DIRECTFB_PALETTE -- cgit v0.12 From b91da630b8b1d043bd8ebe52df6fd9c562564d89 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Mon, 30 Mar 2009 18:08:37 +0200 Subject: Doc: Swapping \a with \c to fix a qdoc warning --- src/corelib/io/qtextstream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 512332e..ed9d0aa 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -1370,7 +1370,7 @@ QTextStream::FieldAlignment QTextStream::fieldAlignment() const \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 5 - The string \a s contains: + The string \c s contains: \snippet doc/src/snippets/code/src_corelib_io_qtextstream.cpp 6 -- cgit v0.12 From e475c68f22732553caad350608f2539db7694979 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 30 Mar 2009 18:11:04 +0200 Subject: Doc: Added a code snippet to illustrate the opening of local files. Task-number: 223087 Reviewed-by: TrustMe --- doc/src/snippets/code/src_gui_util_qdesktopservices.cpp | 5 ++++- src/gui/util/qdesktopservices.cpp | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp b/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp index a9c630b..5001984 100644 --- a/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp +++ b/doc/src/snippets/code/src_gui_util_qdesktopservices.cpp @@ -11,7 +11,10 @@ public slots: QDesktopServices::setUrlHandler("help", helpInstance, "showHelp"); //! [0] - //! [1] mailto:user@foo.com?subject=Test&body=Just a test //! [1] + +//! [2] +QDesktopServices::openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl::TolerantMode)); +//! [2] diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 0fe1d69..84aa16e 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -157,6 +157,11 @@ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler) If the URL is a reference to a local file (i.e., the URL scheme is "file") then it will be opened with a suitable application instead of a Web browser. + The following example opens a file on the Windows file system residing on a path + that contains spaces: + + \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 2 + If a \c mailto URL is specified, the user's e-mail client will be used to open a composer window containing the options specified in the URL, similar to the way \c mailto links are handled by a Web browser. -- cgit v0.12 From ca119ee4b440c1ebbd456417a60167e2998de4d9 Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Mon, 30 Mar 2009 18:45:50 +0200 Subject: Fix the parsing of October dates. The code was looking for a 't' to detect GMT-nnnn. It should really be checking for 'gmt'. Signed-off-by: Thiago Macieira --- src/network/access/qnetworkcookie.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index fed0afc..b82d8f9 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -636,8 +636,6 @@ static QDateTime parseDateString(const QByteArray &dateString) qDebug() << "Month:" << month; #endif at += 3; - if (at < dateString.length() && dateString[at] == '-') - ++at; continue; } // Zone @@ -659,7 +657,10 @@ static QDateTime parseDateString(const QByteArray &dateString) && (at == 0 || isWhitespace(dateString[at - 1]) || dateString[at - 1] == ',' - || (dateString[at - 1] == 't'))) { + || (at >= 3 + && (dateString[at - 3] == 'g') + && (dateString[at - 2] == 'm') + && (dateString[at - 1] == 't')))) { int end = 1; while (end < 5 && dateString.length() > at+end -- cgit v0.12 From 1f695f65df9d78dc10c0277a9914c65902168c1c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 30 Mar 2009 15:12:55 -0700 Subject: Take out todos that have been done Clipping for drawLines works fine. textureBrushes are now accelerated Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index da4f367..90fc446 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -380,7 +380,6 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &p) void QDirectFBPaintEnginePrivate::setBrush(const QBrush &b) { - // TODO: accelerate texture pattern brush = b; simpleBrush = (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased); @@ -509,8 +508,6 @@ void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) const for (int i = 0; i < n; ++i) { const QLine l = transform.map(lines[i]); - // TODO: clip! - regions[i].x1 = l.x1(); regions[i].y1 = l.y1(); regions[i].x2 = l.x2(); @@ -526,8 +523,6 @@ void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) const for (int i = 0; i < n; ++i) { const QLine l = transform.map(lines[i]).toLine(); - // TODO: clip! - regions[i].x1 = l.x1(); regions[i].y1 = l.y1(); regions[i].x2 = l.x2(); -- cgit v0.12 From 8c21eabd758e7350b6736d968d4a30b03e75b2c3 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 31 Mar 2009 13:16:54 +1000 Subject: Fixes: QPSQL: datetime or time fields with negative time zone offsets not handled correctly Now also removes negative timestamps. Task-number: 249059 Reviewed-by: Justin McPherson --- src/sql/drivers/psql/qsql_psql.cpp | 6 +++-- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 40 +++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index e33dd95..afe45fc 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -351,8 +351,9 @@ QVariant QPSQLResult::data(int i) #ifndef QT_NO_DATESTRING if (str.isEmpty()) return QVariant(QTime()); - if (str.at(str.length() - 3) == QLatin1Char('+')) + if (str.at(str.length() - 3) == QLatin1Char('+') || str.at(str.length() - 3) == QLatin1Char('-')) // strip the timezone + // TODO: fix this when timestamp support comes into QDateTime return QVariant(QTime::fromString(str.left(str.length() - 3), Qt::ISODate)); return QVariant(QTime::fromString(str, Qt::ISODate)); #else @@ -365,7 +366,8 @@ QVariant QPSQLResult::data(int i) if (dtval.length() < 10) return QVariant(QDateTime()); // remove the timezone - if (dtval.at(dtval.length() - 3) == QLatin1Char('+')) + // TODO: fix this when timestamp support comes into QDateTime + if (dtval.at(dtval.length() - 3) == QLatin1Char('+') || dtval.at(dtval.length() - 3) == QLatin1Char('-')) dtval.chop(3); // milliseconds are sometimes returned with 2 digits only if (dtval.at(dtval.length() - 3).isPunct()) diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 349db65..d8ad15a 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -148,8 +148,10 @@ private slots: void psql_schemas(); void psql_escapedIdentifiers_data(){ psql_schemas_data(); } void psql_escapedIdentifiers(); - void psql_escapeBytea_data() { generic_data(); } + void psql_escapeBytea_data() { psql_schemas_data(); } void psql_escapeBytea(); + void bug_249059_data() { psql_schemas_data(); } + void bug_249059(); void mysqlOdbc_unsignedIntegers_data() { generic_data(); } void mysqlOdbc_unsignedIntegers(); @@ -337,7 +339,8 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) << qTableName("qtestBindBool") << qTableName("qtest_sqlguid") << qTableName("uint_table") - << qTableName("uint_test"); + << qTableName("uint_test") + << qTableName("bug_249059"); QSqlQuery q(0, db); if (db.driverName().startsWith("QPSQL")) @@ -1594,7 +1597,6 @@ void tst_QSqlDatabase::psql_escapeBytea() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QPSQL"); const char dta[4] = {'\x71', '\x14', '\x32', '\x81'}; QByteArray ba(dta, 4); @@ -1621,6 +1623,38 @@ void tst_QSqlDatabase::psql_escapeBytea() QCOMPARE(i, 4); } +void tst_QSqlDatabase::bug_249059() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + QString tableName = qTableName("bug_249059"); + QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dt timestamp, t time)").arg(tableName))); + + QSqlQuery iq(db); + QVERIFY_SQL(iq, prepare(QString("INSERT INTO %1 VALUES (?, ?)").arg(tableName))); + iq.bindValue(0, QVariant(QString("2001-09-09 04:05:06.789 -5:00"))); + iq.bindValue(1, QVariant(QString("04:05:06.789 -5:00"))); + QVERIFY_SQL(iq, exec()); + iq.bindValue(0, QVariant(QString("2001-09-09 04:05:06.789 +5:00"))); + iq.bindValue(1, QVariant(QString("04:05:06.789 +5:00"))); + QVERIFY_SQL(iq, exec()); + + QVERIFY_SQL(q, exec(QString("SELECT dt, t FROM %1").arg(tableName))); + QVERIFY_SQL(q, next()); + QDateTime dt1=q.value(0).toDateTime(); + QTime t1=q.value(1).toTime(); + QVERIFY_SQL(q, next()); + QDateTime dt2=q.value(0).toDateTime(); + QTime t2=q.value(1).toTime(); + + // These will fail when timezone support is added, when that's the case, set the second record to 14:05:06.789 and it should work correctly + QCOMPARE(dt1, dt2); + QCOMPARE(t1, t2); +} + // This test should be rewritten to work with Oracle as well - or the Oracle driver // should be fixed to make this test pass (handle overflows) void tst_QSqlDatabase::precisionPolicy() -- cgit v0.12 From 4f197396e028ca0537643f7ae69f6951c498d672 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 31 Mar 2009 10:41:53 +0200 Subject: Add missing copyright headers and the "we mean it" section. These were reported by mkdist Reviewed-by: TrustMe --- tools/configure/tools.cpp | 41 ++++++++++++++++++++++++++ tools/configure/tools.h | 41 ++++++++++++++++++++++++++ tools/designer/src/lib/shared/plugindialog_p.h | 11 +++++++ 3 files changed, 93 insertions(+) diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp index ae1ecda..5d12ea5 100644 --- a/tools/configure/tools.cpp +++ b/tools/configure/tools.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "tools.h" #include diff --git a/tools/configure/tools.h b/tools/configure/tools.h index e95ff13..68a439a 100644 --- a/tools/configure/tools.h +++ b/tools/configure/tools.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef _TOOLS_H_ #define _TOOLS_H_ diff --git a/tools/designer/src/lib/shared/plugindialog_p.h b/tools/designer/src/lib/shared/plugindialog_p.h index d50a804..a2601d4 100644 --- a/tools/designer/src/lib/shared/plugindialog_p.h +++ b/tools/designer/src/lib/shared/plugindialog_p.h @@ -42,6 +42,17 @@ #ifndef PLUGINDIALOG_H #define PLUGINDIALOG_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "ui_plugindialog.h" QT_BEGIN_NAMESPACE -- cgit v0.12 From a0601e169c114f66c5fb932a6cc8606a8151bebc Mon Sep 17 00:00:00 2001 From: jasplin Date: Tue, 31 Mar 2009 11:05:06 +0200 Subject: compile on Linux. Reviewed-by: Samuel --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 45a25a4..cb0b436 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1051,7 +1051,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph Q_ASSERT(antialias); uchar *convoluted = new uchar[bitmap.rows*bitmap.pitch]; bool useLegacyLcdFilter = false; -#if defined(FT_LCD_FILTER_H) +#if defined(FC_LCD_FILTER) && defined(FT_LCD_FILTER_H) useLegacyLcdFilter = (lcdFilterType == FT_LCD_FILTER_LEGACY); #endif uchar *buffer = bitmap.buffer; -- cgit v0.12 From 3d370dc92466b010bfe6cdd82411f7e3d13da7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 31 Mar 2009 11:07:07 +0200 Subject: Fix text drawing and perspective transforms for the Windows, PDF and PostScript print engines. The PDF/PostScript does not support perspective transforms, so it has to be emulated through our draw_helper() fallback. PostScript doesn't support alpha blending, so all perspective drawing needs to be forced through the alpha print engine. Task-number: 249754 Reviewed-by: Samuel --- src/gui/painting/qpaintengine_alpha.cpp | 12 ++++++++++-- src/gui/painting/qpaintengine_alpha_p.h | 1 + src/gui/painting/qpdf.cpp | 5 +++++ src/gui/painting/qprintengine_win.cpp | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpaintengine_alpha.cpp b/src/gui/painting/qpaintengine_alpha.cpp index e38f6a4..74cbebe 100644 --- a/src/gui/painting/qpaintengine_alpha.cpp +++ b/src/gui/painting/qpaintengine_alpha.cpp @@ -80,6 +80,7 @@ bool QAlphaPaintEngine::begin(QPaintDevice *pdev) d->m_advancedPen = false; d->m_advancedBrush = false; d->m_complexTransform = false; + d->m_emulateProjectiveTransforms = false; // clear alpha region d->m_alphargn = QRegion(); @@ -116,6 +117,9 @@ void QAlphaPaintEngine::updateState(const QPaintEngineState &state) if (flags & QPaintEngine::DirtyTransform) { d->m_transform = state.transform(); d->m_complexTransform = (d->m_transform.type() > QTransform::TxScale); + d->m_emulateProjectiveTransforms = !(d->m_savedcaps & QPaintEngine::PerspectiveTransform) + && !(d->m_savedcaps & QPaintEngine::AlphaBlend) + && (d->m_transform.type() >= QTransform::TxProject); } if (flags & QPaintEngine::DirtyPen) { d->m_pen = state.pen(); @@ -163,7 +167,9 @@ void QAlphaPaintEngine::drawPath(const QPainterPath &path) if (d->m_pass == 0) { d->m_continueCall = false; - if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush) { + if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush + || d->m_emulateProjectiveTransforms) + { d->addAlphaRect(tr); } if (d->m_picengine) @@ -187,7 +193,9 @@ void QAlphaPaintEngine::drawPolygon(const QPointF *points, int pointCount, Polyg if (d->m_pass == 0) { d->m_continueCall = false; - if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush) { + if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush + || d->m_emulateProjectiveTransforms) + { d->addAlphaRect(tr); } diff --git a/src/gui/painting/qpaintengine_alpha_p.h b/src/gui/painting/qpaintengine_alpha_p.h index f510c73..f7d7a34 100644 --- a/src/gui/painting/qpaintengine_alpha_p.h +++ b/src/gui/painting/qpaintengine_alpha_p.h @@ -113,6 +113,7 @@ public: bool m_advancedPen; bool m_advancedBrush; bool m_complexTransform; + bool m_emulateProjectiveTransforms; bool m_continueCall; QTransform m_transform; diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index b010209..55006f6 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1106,6 +1106,11 @@ void QPdfBaseEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) if (!d->hasPen || (d->clipEnabled && d->allClipped)) return; + if (d->stroker.matrix.type() >= QTransform::TxProject) { + QPaintEngine::drawTextItem(p, textItem); + return; + } + *d->currentPage << "q\n"; if(!d->simplePen) *d->currentPage << QPdf::generateMatrix(d->stroker.matrix); diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp index d48b525..c8674b7 100644 --- a/src/gui/painting/qprintengine_win.cpp +++ b/src/gui/painting/qprintengine_win.cpp @@ -369,7 +369,7 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem QRgb brushColor = state->pen().brush().color().rgb(); bool fallBack = state->pen().brush().style() != Qt::SolidPattern || qAlpha(brushColor) != 0xff - || QT_WA_INLINE(false, d->txop >= QTransform::TxScale) + || QT_WA_INLINE(d->txop >= QTransform::TxProject, d->txop >= QTransform::TxScale) || ti.fontEngine->type() != QFontEngine::Win; -- cgit v0.12 From b311ebf246a0af16f851dd16c92594c238a0048f Mon Sep 17 00:00:00 2001 From: kh Date: Tue, 31 Mar 2009 11:49:24 +0200 Subject: fixes search for non latin1 characters while parsing html files, we removed some entities the should have been converted to there native representation, thus we were not able to find them Task-number: 247732 Reviewed-by: hjk --- .../lib/qhelpsearchindexreader_clucene.cpp | 114 ++++-- .../lib/qhelpsearchindexreader_clucene_p.h | 15 +- .../lib/qhelpsearchindexwriter_clucene.cpp | 408 ++++++++++++++++++++- 3 files changed, 482 insertions(+), 55 deletions(-) diff --git a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp index 82a3a17..a1ba001 100644 --- a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp @@ -83,9 +83,8 @@ void QHelpSearchIndexReader::cancelSearching() mutex.unlock(); } -void QHelpSearchIndexReader::search(const QString &collectionFile, - const QString &indexFilesFolder, - const QList &queryList) +void QHelpSearchIndexReader::search(const QString &collectionFile, const QString &indexFilesFolder, + const QList &queryList) { QMutexLocker lock(&mutex); @@ -147,17 +146,16 @@ void QHelpSearchIndexReader::run() try { #endif QCLuceneBooleanQuery booleanQuery; - if (!buildQuery(booleanQuery, queryList)) { + QCLuceneStandardAnalyzer analyzer; + if (!buildQuery(booleanQuery, queryList, analyzer)) { emit searchingFinished(0); return; } const QStringList attribList = engine.filterAttributes(engine.currentFilter()); if (!attribList.isEmpty()) { - QCLuceneStandardAnalyzer analyzer; QCLuceneQuery* query = QCLuceneQueryParser::parse(QLatin1String("+") - + attribList.join(QLatin1String(" +")), QLatin1String("attribute"), - analyzer); + + attribList.join(QLatin1String(" +")), QLatin1String("attribute"), analyzer); if (!query) { emit searchingFinished(0); @@ -168,10 +166,26 @@ void QHelpSearchIndexReader::run() QCLuceneIndexSearcher indexSearcher(indexPath); QCLuceneHits hits = indexSearcher.search(booleanQuery); - const QStringList namespaceList = engine.registeredDocumentations(); + + bool boost = true; + QCLuceneBooleanQuery tryHarderQuery; + if (hits.length() == 0) { + if (buildTryHarderQuery(tryHarderQuery, queryList, analyzer)) { + if (!attribList.isEmpty()) { + QCLuceneQuery* query = QCLuceneQueryParser::parse(QLatin1String("+") + + attribList.join(QLatin1String(" +")), QLatin1String("attribute"), + analyzer); + tryHarderQuery.add(query, true, true, false); + } + hits = indexSearcher.search(tryHarderQuery); + boost = (hits.length() == 0); + } + } QSet pathSet; QCLuceneDocument document; + const QStringList namespaceList = engine.registeredDocumentations(); + for (qint32 i = 0; i < hits.length(); i++) { document = hits.document(i); const QString path = document.get(QLatin1String("path")); @@ -192,8 +206,8 @@ void QHelpSearchIndexReader::run() } indexSearcher.close(); - int count = hitList.count(); - if (count > 0) + const int count = hitList.count(); + if ((count > 0) && boost) boostSearchHits(engine, hitList, queryList); emit searchingFinished(hitList.count()); @@ -206,11 +220,9 @@ void QHelpSearchIndexReader::run() } } -bool QHelpSearchIndexReader::defaultQuery(const QString &term, - QCLuceneBooleanQuery &booleanQuery) +bool QHelpSearchIndexReader::defaultQuery(const QString &term, QCLuceneBooleanQuery &booleanQuery, + QCLuceneStandardAnalyzer &analyzer) { - QCLuceneStandardAnalyzer analyzer; - const QLatin1String c("content"); const QLatin1String t("titleTokenized"); @@ -226,21 +238,23 @@ bool QHelpSearchIndexReader::defaultQuery(const QString &term, } bool QHelpSearchIndexReader::buildQuery(QCLuceneBooleanQuery &booleanQuery, - const QList &queryList) + const QList &queryList, QCLuceneStandardAnalyzer &analyzer) { foreach (const QHelpSearchQuery query, queryList) { switch (query.fieldName) { case QHelpSearchQuery::FUZZY: { const QLatin1String fuzzy("~"); - foreach (const QString term, query.wordList) { - if (term.isEmpty() || !defaultQuery(term.toLower() + fuzzy, booleanQuery)) + foreach (const QString &term, query.wordList) { + if (term.isEmpty() + || !defaultQuery(term.toLower() + fuzzy, booleanQuery, analyzer)) { return false; + } } } break; case QHelpSearchQuery::WITHOUT: { QStringList stopWords = QCLuceneStopAnalyzer().englishStopWords(); - foreach (const QString term, query.wordList) { + foreach (const QString &term, query.wordList) { if (stopWords.contains(term, Qt::CaseInsensitive)) continue; @@ -259,14 +273,14 @@ bool QHelpSearchIndexReader::buildQuery(QCLuceneBooleanQuery &booleanQuery, } break; case QHelpSearchQuery::PHRASE: { - const QString term = query.wordList.at(0).toLower(); + const QString &term = query.wordList.at(0).toLower(); if (term.contains(QLatin1Char(' '))) { QStringList termList = term.split(QLatin1String(" ")); QCLucenePhraseQuery *q = new QCLucenePhraseQuery(); QStringList stopWords = QCLuceneStopAnalyzer().englishStopWords(); - foreach (const QString t, termList) { - if (!stopWords.contains(t, Qt::CaseInsensitive)) - q->addTerm(QCLuceneTerm(QLatin1String("content"), t.toLower())); + foreach (const QString &term, termList) { + if (!stopWords.contains(term, Qt::CaseInsensitive)) + q->addTerm(QCLuceneTerm(QLatin1String("content"), term.toLower())); } booleanQuery.add(q, true, true, false); } else { @@ -286,7 +300,7 @@ bool QHelpSearchIndexReader::buildQuery(QCLuceneBooleanQuery &booleanQuery, case QHelpSearchQuery::ALL: { QStringList stopWords = QCLuceneStopAnalyzer().englishStopWords(); - foreach (const QString term, query.wordList) { + foreach (const QString &term, query.wordList) { if (stopWords.contains(term, Qt::CaseInsensitive)) continue; @@ -302,9 +316,8 @@ bool QHelpSearchIndexReader::buildQuery(QCLuceneBooleanQuery &booleanQuery, } break; case QHelpSearchQuery::DEFAULT: { - QCLuceneStandardAnalyzer analyzer; - foreach (const QString t, query.wordList) { - QCLuceneQuery *query = QCLuceneQueryParser::parse(t.toLower(), + foreach (const QString &term, query.wordList) { + QCLuceneQuery *query = QCLuceneQueryParser::parse(term.toLower(), QLatin1String("content"), analyzer); if (query) @@ -313,8 +326,8 @@ bool QHelpSearchIndexReader::buildQuery(QCLuceneBooleanQuery &booleanQuery, } break; case QHelpSearchQuery::ATLEAST: { - foreach (const QString term, query.wordList) { - if (term.isEmpty() || !defaultQuery(term.toLower(), booleanQuery)) + foreach (const QString &term, query.wordList) { + if (term.isEmpty() || !defaultQuery(term.toLower(), booleanQuery, analyzer)) return false; } } @@ -324,16 +337,38 @@ bool QHelpSearchIndexReader::buildQuery(QCLuceneBooleanQuery &booleanQuery, return true; } +bool QHelpSearchIndexReader::buildTryHarderQuery(QCLuceneBooleanQuery &booleanQuery, + const QList &queryList, QCLuceneStandardAnalyzer &analyzer) +{ + bool retVal = false; + foreach (const QHelpSearchQuery query, queryList) { + switch (query.fieldName) { + default: break; + case QHelpSearchQuery::DEFAULT: { + foreach (const QString &term, query.wordList) { + QCLuceneQuery *query = QCLuceneQueryParser::parse(term.toLower(), + QLatin1String("content"), analyzer); + + if (query) { + retVal = true; + booleanQuery.add(query, true, false, false); + } + } + } break; + } + } + return retVal; +} + void QHelpSearchIndexReader::boostSearchHits(const QHelpEngineCore &engine, - QList &hitList, - const QList &queryList) + QList &hitList, const QList &queryList) { foreach (const QHelpSearchQuery query, queryList) { if (query.fieldName != QHelpSearchQuery::DEFAULT) continue; QString joinedQuery = query.wordList.join(QLatin1String(" ")); - + QCLuceneStandardAnalyzer analyzer; QCLuceneQuery *parsedQuery = QCLuceneQueryParser::parse( joinedQuery, QLatin1String("content"), analyzer); @@ -351,8 +386,7 @@ void QHelpSearchIndexReader::boostSearchHits(const QHelpEngineCore &engine, QStringList searchTerms; while (index != -1) { nextIndex = joinedQuery.indexOf(QLatin1String("content:"), index + 1); - term = joinedQuery.mid(index + length, nextIndex - (length + index)) - .simplified(); + term = joinedQuery.mid(index + length, nextIndex - (length + index)).simplified(); if (term.startsWith(QLatin1String("\"")) && term.endsWith(QLatin1String("\""))) { searchTerms.append(term.remove(QLatin1String("\""))); @@ -370,17 +404,19 @@ void QHelpSearchIndexReader::boostSearchHits(const QHelpEngineCore &engine, QString data = QString::fromUtf8(engine.fileData(hit.first)); int counter = 0; - foreach (const QString& term, searchTerms) + foreach (const QString &term, searchTerms) counter += data.count(term, Qt::CaseInsensitive); hitMap.insertMulti(counter, hit); } QList boostedList; - QMap::const_iterator i; - for (i = hitMap.constEnd(), --i; i != hitMap.constBegin(); --i) - boostedList.append(i.value()); - boostedList += hitList.mid(count - 1, hitList.count()); - + QMap::const_iterator it = hitMap.constEnd(); + do { + --it; + boostedList.append(it.value()); + } while (it != hitMap.constBegin()); + boostedList += hitList.mid(count, hitList.count()); + hitList = boostedList; } } diff --git a/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h b/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h index 892c4e6..f7536e9 100644 --- a/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h +++ b/tools/assistant/lib/qhelpsearchindexreader_clucene_p.h @@ -54,6 +54,8 @@ // #include "qhelpsearchengine.h" + +#include "fulltextsearch/qanalyzer_p.h" #include "fulltextsearch/qquery_p.h" #include @@ -93,12 +95,13 @@ signals: private: void run(); - bool defaultQuery(const QString &term, - QCLuceneBooleanQuery &booleanQuery); - bool buildQuery(QCLuceneBooleanQuery &booleanQuery, - const QList &queryList); - void boostSearchHits(const QHelpEngineCore &engine, - QList &hitList, + bool defaultQuery(const QString &term, QCLuceneBooleanQuery &booleanQuery, + QCLuceneStandardAnalyzer &analyzer); + bool buildQuery(QCLuceneBooleanQuery &booleanQuery, const QList &queryList, + QCLuceneStandardAnalyzer &analyzer); + bool buildTryHarderQuery(QCLuceneBooleanQuery &booleanQuery, + const QList &queryList, QCLuceneStandardAnalyzer &analyzer); + void boostSearchHits(const QHelpEngineCore &engine, QList &hitList, const QList &queryList); private: diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp index e53bbae..195c490 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp @@ -59,16 +59,340 @@ #include #include +#include "private/qfunctions_p.h" + QT_BEGIN_NAMESPACE namespace qt { namespace fulltextsearch { namespace clucene { +// taken from qtexthtmlparser +static const struct QTextHtmlEntity +{ + const char *name; + quint16 code; +} entities[] = { + { "AElig", 0x00c6 }, + { "AMP", 38 }, + { "Aacute", 0x00c1 }, + { "Acirc", 0x00c2 }, + { "Agrave", 0x00c0 }, + { "Alpha", 0x0391 }, + { "Aring", 0x00c5 }, + { "Atilde", 0x00c3 }, + { "Auml", 0x00c4 }, + { "Beta", 0x0392 }, + { "Ccedil", 0x00c7 }, + { "Chi", 0x03a7 }, + { "Dagger", 0x2021 }, + { "Delta", 0x0394 }, + { "ETH", 0x00d0 }, + { "Eacute", 0x00c9 }, + { "Ecirc", 0x00ca }, + { "Egrave", 0x00c8 }, + { "Epsilon", 0x0395 }, + { "Eta", 0x0397 }, + { "Euml", 0x00cb }, + { "GT", 62 }, + { "Gamma", 0x0393 }, + { "Iacute", 0x00cd }, + { "Icirc", 0x00ce }, + { "Igrave", 0x00cc }, + { "Iota", 0x0399 }, + { "Iuml", 0x00cf }, + { "Kappa", 0x039a }, + { "LT", 60 }, + { "Lambda", 0x039b }, + { "Mu", 0x039c }, + { "Ntilde", 0x00d1 }, + { "Nu", 0x039d }, + { "OElig", 0x0152 }, + { "Oacute", 0x00d3 }, + { "Ocirc", 0x00d4 }, + { "Ograve", 0x00d2 }, + { "Omega", 0x03a9 }, + { "Omicron", 0x039f }, + { "Oslash", 0x00d8 }, + { "Otilde", 0x00d5 }, + { "Ouml", 0x00d6 }, + { "Phi", 0x03a6 }, + { "Pi", 0x03a0 }, + { "Prime", 0x2033 }, + { "Psi", 0x03a8 }, + { "QUOT", 34 }, + { "Rho", 0x03a1 }, + { "Scaron", 0x0160 }, + { "Sigma", 0x03a3 }, + { "THORN", 0x00de }, + { "Tau", 0x03a4 }, + { "Theta", 0x0398 }, + { "Uacute", 0x00da }, + { "Ucirc", 0x00db }, + { "Ugrave", 0x00d9 }, + { "Upsilon", 0x03a5 }, + { "Uuml", 0x00dc }, + { "Xi", 0x039e }, + { "Yacute", 0x00dd }, + { "Yuml", 0x0178 }, + { "Zeta", 0x0396 }, + { "aacute", 0x00e1 }, + { "acirc", 0x00e2 }, + { "acute", 0x00b4 }, + { "aelig", 0x00e6 }, + { "agrave", 0x00e0 }, + { "alefsym", 0x2135 }, + { "alpha", 0x03b1 }, + { "amp", 38 }, + { "and", 0x22a5 }, + { "ang", 0x2220 }, + { "apos", 0x0027 }, + { "aring", 0x00e5 }, + { "asymp", 0x2248 }, + { "atilde", 0x00e3 }, + { "auml", 0x00e4 }, + { "bdquo", 0x201e }, + { "beta", 0x03b2 }, + { "brvbar", 0x00a6 }, + { "bull", 0x2022 }, + { "cap", 0x2229 }, + { "ccedil", 0x00e7 }, + { "cedil", 0x00b8 }, + { "cent", 0x00a2 }, + { "chi", 0x03c7 }, + { "circ", 0x02c6 }, + { "clubs", 0x2663 }, + { "cong", 0x2245 }, + { "copy", 0x00a9 }, + { "crarr", 0x21b5 }, + { "cup", 0x222a }, + { "curren", 0x00a4 }, + { "dArr", 0x21d3 }, + { "dagger", 0x2020 }, + { "darr", 0x2193 }, + { "deg", 0x00b0 }, + { "delta", 0x03b4 }, + { "diams", 0x2666 }, + { "divide", 0x00f7 }, + { "eacute", 0x00e9 }, + { "ecirc", 0x00ea }, + { "egrave", 0x00e8 }, + { "empty", 0x2205 }, + { "emsp", 0x2003 }, + { "ensp", 0x2002 }, + { "epsilon", 0x03b5 }, + { "equiv", 0x2261 }, + { "eta", 0x03b7 }, + { "eth", 0x00f0 }, + { "euml", 0x00eb }, + { "euro", 0x20ac }, + { "exist", 0x2203 }, + { "fnof", 0x0192 }, + { "forall", 0x2200 }, + { "frac12", 0x00bd }, + { "frac14", 0x00bc }, + { "frac34", 0x00be }, + { "frasl", 0x2044 }, + { "gamma", 0x03b3 }, + { "ge", 0x2265 }, + { "gt", 62 }, + { "hArr", 0x21d4 }, + { "harr", 0x2194 }, + { "hearts", 0x2665 }, + { "hellip", 0x2026 }, + { "iacute", 0x00ed }, + { "icirc", 0x00ee }, + { "iexcl", 0x00a1 }, + { "igrave", 0x00ec }, + { "image", 0x2111 }, + { "infin", 0x221e }, + { "int", 0x222b }, + { "iota", 0x03b9 }, + { "iquest", 0x00bf }, + { "isin", 0x2208 }, + { "iuml", 0x00ef }, + { "kappa", 0x03ba }, + { "lArr", 0x21d0 }, + { "lambda", 0x03bb }, + { "lang", 0x2329 }, + { "laquo", 0x00ab }, + { "larr", 0x2190 }, + { "lceil", 0x2308 }, + { "ldquo", 0x201c }, + { "le", 0x2264 }, + { "lfloor", 0x230a }, + { "lowast", 0x2217 }, + { "loz", 0x25ca }, + { "lrm", 0x200e }, + { "lsaquo", 0x2039 }, + { "lsquo", 0x2018 }, + { "lt", 60 }, + { "macr", 0x00af }, + { "mdash", 0x2014 }, + { "micro", 0x00b5 }, + { "middot", 0x00b7 }, + { "minus", 0x2212 }, + { "mu", 0x03bc }, + { "nabla", 0x2207 }, + { "nbsp", 0x00a0 }, + { "ndash", 0x2013 }, + { "ne", 0x2260 }, + { "ni", 0x220b }, + { "not", 0x00ac }, + { "notin", 0x2209 }, + { "nsub", 0x2284 }, + { "ntilde", 0x00f1 }, + { "nu", 0x03bd }, + { "oacute", 0x00f3 }, + { "ocirc", 0x00f4 }, + { "oelig", 0x0153 }, + { "ograve", 0x00f2 }, + { "oline", 0x203e }, + { "omega", 0x03c9 }, + { "omicron", 0x03bf }, + { "oplus", 0x2295 }, + { "or", 0x22a6 }, + { "ordf", 0x00aa }, + { "ordm", 0x00ba }, + { "oslash", 0x00f8 }, + { "otilde", 0x00f5 }, + { "otimes", 0x2297 }, + { "ouml", 0x00f6 }, + { "para", 0x00b6 }, + { "part", 0x2202 }, + { "percnt", 0x0025 }, + { "permil", 0x2030 }, + { "perp", 0x22a5 }, + { "phi", 0x03c6 }, + { "pi", 0x03c0 }, + { "piv", 0x03d6 }, + { "plusmn", 0x00b1 }, + { "pound", 0x00a3 }, + { "prime", 0x2032 }, + { "prod", 0x220f }, + { "prop", 0x221d }, + { "psi", 0x03c8 }, + { "quot", 34 }, + { "rArr", 0x21d2 }, + { "radic", 0x221a }, + { "rang", 0x232a }, + { "raquo", 0x00bb }, + { "rarr", 0x2192 }, + { "rceil", 0x2309 }, + { "rdquo", 0x201d }, + { "real", 0x211c }, + { "reg", 0x00ae }, + { "rfloor", 0x230b }, + { "rho", 0x03c1 }, + { "rlm", 0x200f }, + { "rsaquo", 0x203a }, + { "rsquo", 0x2019 }, + { "sbquo", 0x201a }, + { "scaron", 0x0161 }, + { "sdot", 0x22c5 }, + { "sect", 0x00a7 }, + { "shy", 0x00ad }, + { "sigma", 0x03c3 }, + { "sigmaf", 0x03c2 }, + { "sim", 0x223c }, + { "spades", 0x2660 }, + { "sub", 0x2282 }, + { "sube", 0x2286 }, + { "sum", 0x2211 }, + { "sup", 0x2283 }, + { "sup1", 0x00b9 }, + { "sup2", 0x00b2 }, + { "sup3", 0x00b3 }, + { "supe", 0x2287 }, + { "szlig", 0x00df }, + { "tau", 0x03c4 }, + { "there4", 0x2234 }, + { "theta", 0x03b8 }, + { "thetasym", 0x03d1 }, + { "thinsp", 0x2009 }, + { "thorn", 0x00fe }, + { "tilde", 0x02dc }, + { "times", 0x00d7 }, + { "trade", 0x2122 }, + { "uArr", 0x21d1 }, + { "uacute", 0x00fa }, + { "uarr", 0x2191 }, + { "ucirc", 0x00fb }, + { "ugrave", 0x00f9 }, + { "uml", 0x00a8 }, + { "upsih", 0x03d2 }, + { "upsilon", 0x03c5 }, + { "uuml", 0x00fc }, + { "weierp", 0x2118 }, + { "xi", 0x03be }, + { "yacute", 0x00fd }, + { "yen", 0x00a5 }, + { "yuml", 0x00ff }, + { "zeta", 0x03b6 }, + { "zwj", 0x200d }, + { "zwnj", 0x200c } +}; + +Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &entityStr, const QTextHtmlEntity &entity) +{ + return entityStr < QLatin1String(entity.name); +} + +Q_STATIC_GLOBAL_OPERATOR bool operator<(const QTextHtmlEntity &entity, const QString &entityStr) +{ + return QLatin1String(entity.name) < entityStr; +} + +static QChar resolveEntity(const QString &entity) +{ + const QTextHtmlEntity *start = &entities[0]; + const QTextHtmlEntity *end = &entities[(sizeof(entities) / sizeof(entities[0]))]; + const QTextHtmlEntity *e = qBinaryFind(start, end, entity); + if (e == end) + return QChar(); + return e->code; +} + +static const uint latin1Extended[0xA0 - 0x80] = { + 0x20ac, // 0x80 + 0x0081, // 0x81 direct mapping + 0x201a, // 0x82 + 0x0192, // 0x83 + 0x201e, // 0x84 + 0x2026, // 0x85 + 0x2020, // 0x86 + 0x2021, // 0x87 + 0x02C6, // 0x88 + 0x2030, // 0x89 + 0x0160, // 0x8A + 0x2039, // 0x8B + 0x0152, // 0x8C + 0x008D, // 0x8D direct mapping + 0x017D, // 0x8E + 0x008F, // 0x8F directmapping + 0x0090, // 0x90 directmapping + 0x2018, // 0x91 + 0x2019, // 0x92 + 0x201C, // 0x93 + 0X201D, // 0x94 + 0x2022, // 0x95 + 0x2013, // 0x96 + 0x2014, // 0x97 + 0x02DC, // 0x98 + 0x2122, // 0x99 + 0x0161, // 0x9A + 0x203A, // 0x9B + 0x0153, // 0x9C + 0x009D, // 0x9D direct mapping + 0x017E, // 0x9E + 0x0178 // 0x9F +}; +// end taken from qtexthtmlparser + class DocumentHelper { public: - DocumentHelper(const QString& fileName, const QByteArray &data) + DocumentHelper(const QString &fileName, const QByteArray &data) : fileName(fileName) , data(readData(data)) {} ~DocumentHelper() {} @@ -131,8 +455,15 @@ private: while (j < length) { c = buf[j++]; if (c == QLatin1Char('<') || c == QLatin1Char('&')) { - if (count > 1) + if (count > 1 && c != QLatin1Char('&')) parsedContent.append(QLatin1Char(' ')); + else if (c == QLatin1Char('&')) { + // Note: this will modify the counter j, in case we sucessful parsed the entity + // we will have modified the counter to stay 1 before the closing ';', so + // the following if condition will be met with if (c == QLatin1Char(';')) + parsedContent.append(parseEntity(length, buf, j)); + } + count = 0; valid = false; continue; @@ -157,6 +488,63 @@ private: return parsedContent; } + // taken from qtexthtmlparser + // parses an entity after "&", and returns it + QString parseEntity(int len, const QChar *buf, int &pos) const + { + int recover = pos; + QString entity; + while (pos < len) { + QChar c = buf[pos++]; + if (c.isSpace() || pos - recover > 9) { + goto error; + } + if (c == QLatin1Char(';')) { + pos--; + break; + } + entity += c; + } + { + QChar resolved = resolveEntity(entity); + if (!resolved.isNull()) + return QString(resolved); + } + if (entity.length() > 1 && entity.at(0) == QLatin1Char('#')) { + entity.remove(0, 1); // removing leading # + + int base = 10; + bool ok = false; + + if (entity.at(0).toLower() == QLatin1Char('x')) { // hex entity? + entity.remove(0, 1); + base = 16; + } + + uint uc = entity.toUInt(&ok, base); + if (ok) { + if (uc >= 0x80 && uc < 0x80 + (sizeof(latin1Extended) / sizeof(latin1Extended[0]))) + uc = latin1Extended[uc - 0x80]; // windows latin 1 extended + QString str; + if (uc > 0xffff) { + // surrogate pair + uc -= 0x10000; + ushort high = uc/0x400 + 0xd800; + ushort low = uc%0x400 + 0xdc00; + str.append(QChar(high)); + str.append(QChar(low)); + } else { + str.append(QChar(uc)); + } + return str; + } + } + error: + pos = recover; + return QLatin1String(" "); + } + // end taken from qtexthtmlparser + private: QString fileName; QString data; @@ -239,7 +627,7 @@ void QHelpSearchIndexWriter::run() // old style qhc file < 4.4.2, need to convert... const QStringList indexedNamespaces = engine.customValue(oldKey). toString().split(QLatin1String("|"), QString::SkipEmptyParts); - foreach (const QString& nameSpace, indexedNamespaces) + foreach (const QString &nameSpace, indexedNamespaces) indexMap.insert(nameSpace, QDateTime()); engine.removeCustomValue(oldKey); } else { @@ -294,7 +682,7 @@ void QHelpSearchIndexWriter::run() } if (QCLuceneIndexReader::indexExists(indexPath) && !reindex) { - foreach(const QString& namespaceName, registeredDocs) { + foreach(const QString &namespaceName, registeredDocs) { mutexLocker.relock(); if (m_cancel) { emit indexingFinished(); @@ -342,7 +730,7 @@ void QHelpSearchIndexWriter::run() writer->setMaxFieldLength(QCLuceneIndexWriter::DEFAULT_MAX_FIELD_LENGTH); QStringList namespaces; - foreach(const QString& namespaceName, registeredDocs) { + foreach(const QString &namespaceName, registeredDocs) { mutexLocker.relock(); if (m_cancel) { writer->close(); @@ -367,7 +755,7 @@ void QHelpSearchIndexWriter::run() break; } else { bool bail = false; - foreach (const QStringList& attributes, attributeSets) { + foreach (const QStringList &attributes, attributeSets) { const QList docFiles = indexableFiles(&engine, namespaceName, attributes); if (!addDocuments(docFiles, engine, attributes, namespaceName, @@ -397,7 +785,7 @@ void QHelpSearchIndexWriter::run() mutexLocker.unlock(); QStringList indexedNamespaces = indexMap.keys(); - foreach(const QString& namespaceName, indexedNamespaces) { + foreach(const QString &namespaceName, indexedNamespaces) { mutexLocker.relock(); if (m_cancel) break; @@ -422,7 +810,7 @@ bool QHelpSearchIndexWriter::addDocuments(const QList docFiles, const QString attrList = attributes.join(QLatin1String(" ")); locker.unlock(); - foreach(const QUrl& url, docFiles) { + foreach(const QUrl &url, docFiles) { QCLuceneDocument document; DocumentHelper helper(url.toString(), engine.fileData(url)); if (helper.addFieldsToDocument(&document, namespaceName, attrList)) @@ -450,8 +838,8 @@ void QHelpSearchIndexWriter::removeDocuments(const QString &indexPath, reader.close(); } -bool QHelpSearchIndexWriter::writeIndexMap(QHelpEngineCore& engine, - const QMap& indexMap) +bool QHelpSearchIndexWriter::writeIndexMap(QHelpEngineCore &engine, + const QMap &indexMap) { QByteArray bArray; -- cgit v0.12 From 665c4c1e587daf3b2880f5f1802a0bb8a3f10e2b Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Tue, 31 Mar 2009 13:02:15 +0200 Subject: Doc - marking QPrintDialog::printer(), setPrinter() and addButton() as Unix only functions, part of Qt 3 Support. Task-number: 248752 and 245244 Reviewed-by: Simon Hausmann --- doc/src/qprintdialog.qdoc | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/doc/src/qprintdialog.qdoc b/doc/src/qprintdialog.qdoc index 6cac1c9..a4cd18b 100644 --- a/doc/src/qprintdialog.qdoc +++ b/doc/src/qprintdialog.qdoc @@ -39,26 +39,34 @@ ** ****************************************************************************/ +#ifdef QT3_SUPPORT /*! - \fn QPrinter *QPrintDialog::printer() const + \fn QPrinter *QPrintDialog::printer() const - Returns a pointer to the printer this dialog configures, or 0 if - this dialog does not operate on any printer. + Returns a pointer to the printer this dialog configures, or 0 if + this dialog does not operate on any printer. + + This function is available for Unix platforms only. */ /*! - \fn void QPrintDialog::setPrinter(QPrinter *printer, bool pickupSettings) + \fn void QPrintDialog::setPrinter(QPrinter *printer, bool pickupSettings) + + Sets this dialog to configure printer \a printer, or no printer if \a printer + is null. If \a pickupSettings is true, the dialog reads most of + its settings from \a printer. If \a pickupSettings is false (the + default) the dialog keeps its old settings. - Sets this dialog to configure printer \a printer, or no printer if \a printer - is null. If \a pickupSettings is true, the dialog reads most of - its settings from \a printer. If \a pickupSettings is false (the - default) the dialog keeps its old settings. + This function is available for Unix platforms only. */ /*! - \fn void QPrintDialog::addButton(QPushButton *button) + \fn void QPrintDialog::addButton(QPushButton *button) + + Adds the \a button to the layout of the print dialog. The added + buttons are arranged from the left to the right below the + last groupbox of the printdialog. - Adds the \a button to the layout of the print dialog. The added - buttons are arranged from the left to the right below the - last groupbox of the printdialog. + This function is available for Unix platforms only. */ +#endif -- cgit v0.12 From 8de6bbfa0f3819cd13fc5fd5acc3eb1f7689db73 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 31 Mar 2009 13:15:49 +0200 Subject: Update the license on this code to match the rest. These sources had the old headers. Update to the new LGPL ones. Reviewed-by: TrustMe --- src/gui/math3d/qfixedpt.cpp | 32 ++++++++++++++++++++++- src/gui/math3d/qfixedpt.h | 32 ++++++++++++++++++++++- src/gui/math3d/qgenericmatrix.cpp | 32 ++++++++++++++++++++++- src/gui/math3d/qgenericmatrix.h | 32 ++++++++++++++++++++++- src/gui/math3d/qmath3dglobal.h | 32 ++++++++++++++++++++++- src/gui/math3d/qmath3dutil.cpp | 32 ++++++++++++++++++++++- src/gui/math3d/qmath3dutil_p.h | 32 ++++++++++++++++++++++- src/gui/math3d/qmatrix4x4.cpp | 32 ++++++++++++++++++++++- src/gui/math3d/qmatrix4x4.h | 32 ++++++++++++++++++++++- src/gui/math3d/qquaternion.cpp | 32 ++++++++++++++++++++++- src/gui/math3d/qquaternion.h | 32 ++++++++++++++++++++++- src/gui/math3d/qvector2d.cpp | 32 ++++++++++++++++++++++- src/gui/math3d/qvector2d.h | 32 ++++++++++++++++++++++- src/gui/math3d/qvector3d.cpp | 32 ++++++++++++++++++++++- src/gui/math3d/qvector3d.h | 32 ++++++++++++++++++++++- src/gui/math3d/qvector4d.cpp | 32 ++++++++++++++++++++++- src/gui/math3d/qvector4d.h | 32 ++++++++++++++++++++++- tests/auto/math3d/qfixedpt/tst_qfixedpt.cpp | 32 ++++++++++++++++++++++- tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 32 ++++++++++++++++++++++- tests/auto/math3d/qquaternion/tst_qquaternion.cpp | 32 ++++++++++++++++++++++- tests/auto/math3d/qvectornd/tst_qvectornd.cpp | 32 ++++++++++++++++++++++- tests/auto/math3d/shared/math3dincludes.cpp | 32 ++++++++++++++++++++++- tests/auto/math3d/shared/math3dincludes.h | 32 ++++++++++++++++++++++- 23 files changed, 713 insertions(+), 23 deletions(-) diff --git a/src/gui/math3d/qfixedpt.cpp b/src/gui/math3d/qfixedpt.cpp index e7e61b6..93f2150 100644 --- a/src/gui/math3d/qfixedpt.cpp +++ b/src/gui/math3d/qfixedpt.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qfixedpt.h b/src/gui/math3d/qfixedpt.h index ecbcad4..142f62f 100644 --- a/src/gui/math3d/qfixedpt.h +++ b/src/gui/math3d/qfixedpt.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp index cb48909..734c1e6 100644 --- a/src/gui/math3d/qgenericmatrix.cpp +++ b/src/gui/math3d/qgenericmatrix.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h index 26a0e48..dbeaaf3 100644 --- a/src/gui/math3d/qgenericmatrix.h +++ b/src/gui/math3d/qgenericmatrix.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qmath3dglobal.h b/src/gui/math3d/qmath3dglobal.h index ee5e734..c2f7184 100644 --- a/src/gui/math3d/qmath3dglobal.h +++ b/src/gui/math3d/qmath3dglobal.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qmath3dutil.cpp b/src/gui/math3d/qmath3dutil.cpp index 91d4b15..ad84162 100644 --- a/src/gui/math3d/qmath3dutil.cpp +++ b/src/gui/math3d/qmath3dutil.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qmath3dutil_p.h b/src/gui/math3d/qmath3dutil_p.h index 1cb0bb9..fa4c156 100644 --- a/src/gui/math3d/qmath3dutil_p.h +++ b/src/gui/math3d/qmath3dutil_p.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 9941ca8..bcb3066 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 8ef73bf..6428b20 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index 730844f..121ff51 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index cc71b7d..6ba63ec 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp index 13d6cc9..0426fc5 100644 --- a/src/gui/math3d/qvector2d.cpp +++ b/src/gui/math3d/qvector2d.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index 55452b0..a72ecc5 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index f0b3aeb..32068ee 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h index dd1d014..8f8f3b4 100644 --- a/src/gui/math3d/qvector3d.h +++ b/src/gui/math3d/qvector3d.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index 1239df0..4287806 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 078c328..4ac6ae8 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/math3d/qfixedpt/tst_qfixedpt.cpp b/tests/auto/math3d/qfixedpt/tst_qfixedpt.cpp index f8c8d09..ef333a6 100644 --- a/tests/auto/math3d/qfixedpt/tst_qfixedpt.cpp +++ b/tests/auto/math3d/qfixedpt/tst_qfixedpt.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 3d92adf..8a7dd49 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp index 252bdc7..325cb40 100644 --- a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp index 48a41b9..83bacdf 100644 --- a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/math3d/shared/math3dincludes.cpp b/tests/auto/math3d/shared/math3dincludes.cpp index c4e1533..725079d 100644 --- a/tests/auto/math3d/shared/math3dincludes.cpp +++ b/tests/auto/math3d/shared/math3dincludes.cpp @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/math3d/shared/math3dincludes.h b/tests/auto/math3d/shared/math3dincludes.h index 9e406ee..23b0f16 100644 --- a/tests/auto/math3d/shared/math3dincludes.h +++ b/tests/auto/math3d/shared/math3dincludes.h @@ -5,7 +5,37 @@ ** ** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From 6efb2e5836da7f83ec484bc93230649d027fb0c9 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 31 Mar 2009 13:56:03 +0200 Subject: Add Windows7 and Snow Leopard as values QSysInfo. It's likely these OS's will show up before we are done with 4.5, so it is worthwhile to have these values here, so that both we and other developers can do nice things with them. Reviewed-by: Prasanth Ullattil --- src/corelib/global/qglobal.cpp | 21 +++++++++++++++------ src/corelib/global/qglobal.h | 6 +++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 08ecf3c..68c213e 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1054,6 +1054,7 @@ bool qSharedBuild() \value WV_XP Windows XP (operating system version 5.1) \value WV_2003 Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2) \value WV_VISTA Windows Vista, Windows Server 2008 (operating system version 6.0) + \value WV_WINDOWS7 Windows 7 (operating system version 6.1) Alternatively, you may use the following macros which correspond directly to the Windows operating system version number: @@ -1062,6 +1063,7 @@ bool qSharedBuild() \value WV_5_1 Operating system version 5.1, corresponds to Windows XP \value WV_5_2 Operating system version 5.2, corresponds to Windows Server 2003, Windows Server 2003 R2, Windows Home Server, and Windows XP Professional x64 Edition \value WV_6_0 Operating system version 6.0, corresponds to Windows Vista and Windows Server 2008 + \value WV_6_1 Operating system version 6.1, corresponds to Windows 7 CE-based versions: @@ -1095,6 +1097,7 @@ bool qSharedBuild() \value MV_10_3 Mac OS X 10.3 \value MV_10_4 Mac OS X 10.4 \value MV_10_5 Mac OS X 10.5 + \value MV_10_6 Mac OS X 10.6 \value MV_Unknown An unknown and currently unsupported platform \value MV_CHEETAH Apple codename for MV_10_0 @@ -1103,6 +1106,7 @@ bool qSharedBuild() \value MV_PANTHER Apple codename for MV_10_3 \value MV_TIGER Apple codename for MV_10_4 \value MV_LEOPARD Apple codename for MV_10_5 + \value MV_SNOWLEOPARD Apple codename for MV_10_6 \sa WinVersion */ @@ -1631,16 +1635,19 @@ QSysInfo::WinVersion QSysInfo::windowsVersion() default: // VER_PLATFORM_WIN32_NT if (osver.dwMajorVersion < 5) { winver = QSysInfo::WV_NT; - } else if (osver.dwMajorVersion == 6) { - winver = QSysInfo::WV_VISTA; - } else if (osver.dwMinorVersion == 0) { + } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) { winver = QSysInfo::WV_2000; - } else if (osver.dwMinorVersion == 1) { + } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) { winver = QSysInfo::WV_XP; - } else if (osver.dwMinorVersion == 2) { + } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) { winver = QSysInfo::WV_2003; + } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) { + winver = QSysInfo::WV_VISTA; + } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) { + winver = QSysInfo::WV_WINDOWS7; } else { - qWarning("Qt: Untested Windows version detected!"); + qWarning("Qt: Untested Windows version %d.%d detected!", + osver.dwMajorVersion, osver.dwMinorVersion); winver = QSysInfo::WV_NT_based; } } @@ -1667,6 +1674,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion() winver = QSysInfo::WV_XP; else if (override == "VISTA") winver = QSysInfo::WV_VISTA; + else if (override == "WINDOWS7") + winver = QSysInfo::WV_WINDOWS7; } #endif diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 210f713..81af295 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1309,6 +1309,7 @@ public: WV_XP = 0x0030, WV_2003 = 0x0040, WV_VISTA = 0x0080, + WV_WINDOWS7 = 0x0090, WV_NT_based = 0x00f0, /* version numbers */ @@ -1317,6 +1318,7 @@ public: WV_5_1 = WV_XP, WV_5_2 = WV_2003, WV_6_0 = WV_VISTA, + WV_6_1 = WV_WINDOWS7, WV_CE = 0x0100, WV_CENET = 0x0200, @@ -1340,6 +1342,7 @@ public: MV_10_3 = 0x0005, MV_10_4 = 0x0006, MV_10_5 = 0x0007, + MV_10_6 = 0x0008, /* codenames */ MV_CHEETAH = MV_10_0, @@ -1347,7 +1350,8 @@ public: MV_JAGUAR = MV_10_2, MV_PANTHER = MV_10_3, MV_TIGER = MV_10_4, - MV_LEOPARD = MV_10_5 + MV_LEOPARD = MV_10_5, + MV_SNOWLEOPARD = MV_10_6 }; static const MacVersion MacintoshVersion; #endif -- cgit v0.12 From b620b46ec07879c1baa35d59f3baa00fde88a3b8 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 31 Mar 2009 14:13:12 +0200 Subject: Detailed description of QMetaType contradicts documentation of QMetaType::type() QMetaType::type() returns 0 for unknown types, not -1. Task-number: 248890 Reviewed By: Kavindra Devi Palaraja --- doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp index 355a237..783852b 100644 --- a/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp +++ b/doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp @@ -33,7 +33,7 @@ MyStruct s2 = var.value(); //! [3] int id = QMetaType::type("MyClass"); -if (id != -1) { +if (id == 0) { void *myClassPtr = QMetaType::construct(id); ... QMetaType::destroy(id, myClassPtr); -- cgit v0.12 From 9562f4a39ca9ca2c59bd621ac8e33af8b8006043 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 31 Mar 2009 14:42:45 +0200 Subject: Fix bug in QDirIterator that clear the cache of the fileinfo We basically store the currentFileInfo and use another one to continue moving into the dir. Task-number: 247645 Reviewed-by: Olivier --- src/corelib/io/qdiriterator.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 46c7dd8..a2c5321 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -116,7 +116,9 @@ public: QAbstractFileEngine *engine; QStack fileEngineIterators; QString path; - QFileInfo fileInfo; + QFileInfo nextFileInfo; + //This fileinfo is the current that we will return from the public API + QFileInfo currentFileInfo; QString currentFilePath; QDirIterator::IteratorFlags iteratorFlags; QDir::Filters filters; @@ -140,8 +142,8 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList this->filters = filters; this->nameFilters = nameFilters; - fileInfo.setFile(path); - pushSubDirectory(fileInfo.isSymLink() ? fileInfo.canonicalFilePath() : path, + nextFileInfo.setFile(path); + pushSubDirectory(nextFileInfo.isSymLink() ? nextFileInfo.canonicalFilePath() : path, nameFilters, filters); } @@ -160,12 +162,12 @@ void QDirIteratorPrivate::pushSubDirectory(const QString &path, const QStringLis QDir::Filters filters) { if (iteratorFlags & QDirIterator::FollowSymlinks) { - if (fileInfo.filePath() != path) - fileInfo.setFile(path); - if (fileInfo.isSymLink()) { - visitedLinks << fileInfo.canonicalFilePath(); + if (nextFileInfo.filePath() != path) + nextFileInfo.setFile(path); + if (nextFileInfo.isSymLink()) { + visitedLinks << nextFileInfo.canonicalFilePath(); } else { - visitedLinks << fileInfo.absoluteFilePath(); + visitedLinks << nextFileInfo.absoluteFilePath(); } } @@ -213,15 +215,16 @@ void QDirIteratorPrivate::advance() while (it->hasNext()) { it->next(); if (matchesFilters(it)) { - fileInfo = it->currentFileInfo(); + currentFileInfo = nextFileInfo; + nextFileInfo = it->currentFileInfo(); // Signal that we want to follow this entry. - followNextDir = shouldFollowDirectory(fileInfo); - + followNextDir = shouldFollowDirectory(nextFileInfo); //We found a matching entry. return; } else if (iteratorFlags & QDirIterator::Subdirectories) { QFileInfo fileInfo = it->currentFileInfo(); + if (!shouldFollowDirectory(fileInfo)) continue; QString subDir = it->currentFilePath(); @@ -238,6 +241,7 @@ void QDirIteratorPrivate::advance() if (!foundDirectory) delete fileEngineIterators.pop(); } + currentFileInfo = nextFileInfo; done = true; } @@ -518,9 +522,7 @@ bool QDirIterator::hasNext() const */ QString QDirIterator::fileName() const { - if (d->fileInfo.path() != d->currentFilePath) - d->fileInfo.setFile(d->currentFilePath); - return d->fileInfo.fileName(); + return d->currentFileInfo.fileName(); } /*! @@ -543,9 +545,7 @@ QString QDirIterator::filePath() const */ QFileInfo QDirIterator::fileInfo() const { - if (d->fileInfo.filePath() != d->currentFilePath) - d->fileInfo.setFile(d->currentFilePath); - return d->fileInfo; + return d->currentFileInfo; } /*! -- cgit v0.12 From f870d559aa3a3c56f4fe34ada49d613b45963377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 31 Mar 2009 14:47:53 +0200 Subject: Add an example of how to write a custom layout for QGraphicsLayouts. Flowlayout... Documentation will follow. --- examples/graphicsview/flowlayout/flowlayout.cpp | 169 ++++++++++++++++++++++++ examples/graphicsview/flowlayout/flowlayout.h | 36 +++++ examples/graphicsview/flowlayout/flowlayout.pro | 12 ++ examples/graphicsview/flowlayout/main.cpp | 14 ++ examples/graphicsview/flowlayout/window.cpp | 20 +++ examples/graphicsview/flowlayout/window.h | 7 + 6 files changed, 258 insertions(+) create mode 100644 examples/graphicsview/flowlayout/flowlayout.cpp create mode 100644 examples/graphicsview/flowlayout/flowlayout.h create mode 100644 examples/graphicsview/flowlayout/flowlayout.pro create mode 100644 examples/graphicsview/flowlayout/main.cpp create mode 100644 examples/graphicsview/flowlayout/window.cpp create mode 100644 examples/graphicsview/flowlayout/window.h diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp new file mode 100644 index 0000000..d1676bc --- /dev/null +++ b/examples/graphicsview/flowlayout/flowlayout.cpp @@ -0,0 +1,169 @@ +#include "flowlayout.h" +#include +#include + +FlowLayout::FlowLayout() +{ + m_spacing[0] = 6; + m_spacing[1] = 6; + QSizePolicy sp = sizePolicy(); + sp.setHeightForWidth(true); + setSizePolicy(sp); +} + +void FlowLayout::insertItem(int index, QGraphicsLayoutItem *item) +{ + item->setParentLayoutItem(this); + if (uint(index) > uint(m_items.count())) + index = m_items.count(); + m_items.insert(index, item); + invalidate(); +} + +int FlowLayout::count() const +{ + return m_items.count(); +} + +QGraphicsLayoutItem *FlowLayout::itemAt(int index) const +{ + return m_items.value(index); +} + +void FlowLayout::removeAt(int index) +{ + m_items.removeAt(index); +} + +qreal FlowLayout::spacing(Qt::Orientation o) const +{ + return m_spacing[int(o) - 1]; +} + +void FlowLayout::setSpacing(Qt::Orientations o, qreal spacing) +{ + if (o & Qt::Horizontal) + m_spacing[0] = spacing; + if (o & Qt::Vertical) + m_spacing[1] = spacing; +} + +void FlowLayout::setGeometry(const QRectF &geom) +{ + QGraphicsLayout::setGeometry(geom); + doLayout(geom, true); +} + +qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) +{ + QPointF tl = geom.topLeft(); + qreal maxw = geom.width(); + + qreal left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + maxw = maxw - left - right; + qreal x = 0; + qreal y = 0; + qreal maxRowHeight = 0; + QSizeF pref; + for (int i = 0; i < m_items.count(); ++i) { + QGraphicsLayoutItem *item = m_items.at(i); + pref = item->effectiveSizeHint(Qt::PreferredSize); + maxRowHeight = qMax(maxRowHeight, pref.height()); + + qreal next_x; + next_x = x + pref.width(); + if (next_x > maxw) { + if (x == 0) { + pref.setWidth(maxw); + } else { + x = 0; + next_x = pref.width(); + } + y += maxRowHeight + spacing(Qt::Vertical); + maxRowHeight = 0; + } + + if (applyNewGeometry) + item->setGeometry(QRectF(QPointF(left + x, top + y), pref)); + x = next_x + spacing(Qt::Horizontal); + } + maxRowHeight = qMax(maxRowHeight, pref.height()); + return top + y + maxRowHeight + bottom; +} + +QSizeF FlowLayout::minSize(const QSizeF &constraint) const +{ + QSizeF size(0, 0); + qreal left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + if (constraint.width() > 0) { // height for width + FlowLayout *that = const_cast(this); + qreal height = that->doLayout(QRectF(QPointF(0,0), constraint), false); + size = QSizeF(constraint.width(), height); + } else { + QGraphicsLayoutItem *item; + foreach (item, m_items) + size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize)); + size += QSize(left + right, top + bottom); + } + return size; +} + +QSizeF FlowLayout::prefSize() const +{ + qreal left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + + QGraphicsLayoutItem *item; + qreal maxh = 0; + qreal totalWidth = 0; + foreach (item, m_items) { + if (totalWidth > 0) + totalWidth += spacing(Qt::Horizontal); + QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize); + totalWidth += pref.width(); + maxh = qMax(maxh, pref.height()); + } + maxh += spacing(Qt::Vertical); + + const qreal goldenAspectRatio = 1.61803399; + qreal w = qSqrt(totalWidth * maxh * goldenAspectRatio) + left + right; + + return minSize(QSizeF(w, -1)); +} + +QSizeF FlowLayout::maxSize() const +{ + QGraphicsLayoutItem *item; + qreal totalWidth = 0; + qreal totalHeight = 0; + foreach (item, m_items) { + if (totalWidth > 0) + totalWidth += spacing(Qt::Horizontal); + if (totalHeight > 0) + totalHeight += spacing(Qt::Vertical); + QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize); + totalWidth += pref.width(); + totalHeight += pref.height(); + } + + qreal left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + return QSizeF(left + totalWidth + right, top + totalHeight + bottom); +} + +QSizeF FlowLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + switch (which) { + case Qt::PreferredSize: + return prefSize(); + case Qt::MinimumSize: + return minSize(constraint); + case Qt::MaximumSize: + return maxSize(); + default: + break; + } + return constraint; +} diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h new file mode 100644 index 0000000..ab3d33b --- /dev/null +++ b/examples/graphicsview/flowlayout/flowlayout.h @@ -0,0 +1,36 @@ +#include + +class FlowLayout : public QGraphicsLayout +{ +public: + FlowLayout(); + inline void addItem(QGraphicsLayoutItem *item); + void insertItem(int index, QGraphicsLayoutItem *item); + void setSpacing(Qt::Orientations o, qreal spacing); + qreal spacing(Qt::Orientation o) const; + + // inherited functions + void setGeometry(const QRectF &geom); + + int count() const; + QGraphicsLayoutItem *itemAt(int index) const; + void removeAt(int index); + +protected: + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; + +private: + qreal doLayout(const QRectF &geom, bool applyNewGeometry); + QSizeF minSize(const QSizeF &constraint) const; + QSizeF prefSize() const; + QSizeF maxSize() const; + + QList m_items; + qreal m_spacing[2]; +}; + + +inline void FlowLayout::addItem(QGraphicsLayoutItem *item) +{ + insertItem(-1, item); +} diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro new file mode 100644 index 0000000..c029d6c --- /dev/null +++ b/examples/graphicsview/flowlayout/flowlayout.pro @@ -0,0 +1,12 @@ +###################################################################### +# Automatically generated by qmake (2.01a) ma 30. mar 12:46:15 2009 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += flowlayout.h window.h +SOURCES += flowlayout.cpp main.cpp window.cpp diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp new file mode 100644 index 0000000..a7af2d4 --- /dev/null +++ b/examples/graphicsview/flowlayout/main.cpp @@ -0,0 +1,14 @@ +#include +#include "window.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QGraphicsScene scene; + QGraphicsView *view = new QGraphicsView(&scene); + Window *w = new Window; + scene.addItem(w); + view->show(); + return app.exec(); +} \ No newline at end of file diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp new file mode 100644 index 0000000..b632bc9 --- /dev/null +++ b/examples/graphicsview/flowlayout/window.cpp @@ -0,0 +1,20 @@ +#include +#include +#include "flowlayout.h" +#include "window.h" + +Window::Window() +: QGraphicsWidget(0, Qt::Window) +{ + FlowLayout *lay = new FlowLayout; + QString sentence(QLatin1String("I am not bothered by the fact that I am unknown. I am bothered when I do not know others.")); + QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts); + for (int i = 0; i < words.count(); ++i) { + QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); + QLabel *label = new QLabel(words.at(i)); + label->setFrameStyle(QFrame::Box | QFrame::Plain); + proxy->setWidget(label); + lay->addItem(proxy); + } + setLayout(lay); +} \ No newline at end of file diff --git a/examples/graphicsview/flowlayout/window.h b/examples/graphicsview/flowlayout/window.h new file mode 100644 index 0000000..50dac92 --- /dev/null +++ b/examples/graphicsview/flowlayout/window.h @@ -0,0 +1,7 @@ +#include + +class Window : public QGraphicsWidget { + Q_OBJECT +public: + Window(); +}; \ No newline at end of file -- cgit v0.12 From 2d13592054d1d6f049ecc1599913cb8c7541ef69 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 31 Mar 2009 15:19:07 +0200 Subject: QProcess::start() segfaults on empty program Handle cases where QProcess::start() and startDetached() are passed a null, empty, or "invalid" program string instead of crashing. Task-number: 247865 Reviewed-by: Andreas Aardal Hanssen --- src/corelib/io/qprocess.cpp | 9 +++++++++ tests/auto/qprocess/tst_qprocess.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index a9d8ee2..f16f996 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1601,6 +1601,13 @@ static QStringList parseCombinedArgString(const QString &program) void QProcess::start(const QString &program, OpenMode mode) { QStringList args = parseCombinedArgString(program); + if (args.isEmpty()) { + Q_D(QProcess); + d->processError = QProcess::FailedToStart; + setErrorString(tr("No program defined")); + emit error(d->processError); + return; + } QString prog = args.first(); args.removeFirst(); @@ -1769,6 +1776,8 @@ bool QProcess::startDetached(const QString &program, bool QProcess::startDetached(const QString &program) { QStringList args = parseCombinedArgString(program); + if (args.isEmpty()) + return false; QString prog = args.first(); args.removeFirst(); diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index f0dae5d..cb2b1bf 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -139,6 +139,8 @@ private slots: void switchReadChannels(); void setWorkingDirectory(); void startFinishStartFinish(); + void invalidProgramString_data(); + void invalidProgramString(); // keep these at the end, since they use lots of processes and sometimes // caused obscure failures to occur in tests that followed them (esp. on the Mac) @@ -2000,5 +2002,29 @@ void tst_QProcess::startFinishStartFinish() } } +//----------------------------------------------------------------------------- +void tst_QProcess::invalidProgramString_data() +{ + QTest::addColumn("programString"); + QTest::newRow("null string") << QString(); + QTest::newRow("empty string") << QString(""); + QTest::newRow("only blank string") << QString(" "); +} + +void tst_QProcess::invalidProgramString() +{ + QFETCH(QString, programString); + QProcess process; + + qRegisterMetaType("QProcess::ProcessError"); + QSignalSpy spy(&process, SIGNAL(error(QProcess::ProcessError))); + + process.start(programString); + QCOMPARE(process.error(), QProcess::FailedToStart); + QCOMPARE(spy.count(), 1); + + QVERIFY(!QProcess::startDetached(programString)); +} + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" -- cgit v0.12 From 0aaf811061f86c1b09670fff1e304d997bd34411 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 31 Mar 2009 16:34:00 +0200 Subject: Get the qt7 phonon plugin to minimally compile on 10.6 We need to protect some overridden type and that is done in qmacdefines_mac.h, so just include that. To top this off, a function has changed that was introduced in 10.5. In order to use it properly, we would need to do lots of version checking and shuffling between types and it seems like more trouble that it's worth at the moment. We may have to do that in the future, but we'll deal with that then. --- src/3rdparty/phonon/qt7/audionode.mm | 16 +++++++++------- src/3rdparty/phonon/qt7/backendinfo.mm | 1 + src/3rdparty/phonon/qt7/quicktimevideoplayer.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/phonon/qt7/audionode.mm b/src/3rdparty/phonon/qt7/audionode.mm index cb9e82f..961230c 100644 --- a/src/3rdparty/phonon/qt7/audionode.mm +++ b/src/3rdparty/phonon/qt7/audionode.mm @@ -68,13 +68,15 @@ void AudioNode::createAndConnectAUNodes() << QString(!FindNextComponent(0, &description) ? "ERROR: COMPONENT NOT FOUND!" : "OK!")) OSStatus err = noErr; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) - err = AUGraphAddNode(m_audioGraph->audioGraphRef(), &description, &m_auNode); - else -#endif - err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode); - + + // The proper function to call here is AUGraphAddNode() but the type has + // changed between 10.5 and 10.6. it's still OK to call this function, but + // if we want to use the proper thing we need to move over to + // AudioComponentDescription everywhere, which is very similar to the + // ComponentDescription, but a different size. however, + // AudioComponentDescription only exists on 10.6+. More fun than we need to + // deal with at the moment, so we'll take the "deprecated" warning instead. + err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode); BACKEND_ASSERT2(err != kAUGraphErr_OutputNodeErr, "A MediaObject can only be connected to one audio output device.", FATAL_ERROR) BACKEND_ASSERT2(err == noErr, "Could not create new AUNode.", FATAL_ERROR) } diff --git a/src/3rdparty/phonon/qt7/backendinfo.mm b/src/3rdparty/phonon/qt7/backendinfo.mm index e173f05..0d51db0 100644 --- a/src/3rdparty/phonon/qt7/backendinfo.mm +++ b/src/3rdparty/phonon/qt7/backendinfo.mm @@ -22,6 +22,7 @@ #include #include +#include #import #ifdef QUICKTIME_C_API_AVAILABLE diff --git a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h index 0b3aec2..b80570a 100644 --- a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h +++ b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h @@ -20,6 +20,7 @@ #include "backendheader.h" +#include #import #import -- cgit v0.12 From 22500faf878063df5fbd0392aaa876340e9f9c77 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 31 Mar 2009 16:52:33 +0200 Subject: Add more enums for the search fields. Again these aren't adding symbols, but these enums are available on earlier versions of Mac OS X (10.3) and we can use them. However, it's silly to have to go back to 10.6 just to find the enums. These will come in handy shortly. --- src/gui/styles/qmacstyle_mac.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index fad9995..a88617c 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -132,6 +132,13 @@ enum { kThemePushButtonTexturedSmall = 32, kThemePushButtonTexturedMini = 33 }; + +/* Search fields */ +enum { + kHIThemeFrameTextFieldRound = 1000, + kHIThemeFrameTextFieldRoundSmall = 1001, + kHIThemeFrameTextFieldRoundMini = 1002 +} #endif // Resolve these at run-time, since the functions was moved in Leopard. -- cgit v0.12 From 69c6f94c6cd6320a02ade785bb8ac5f02c1204de Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 31 Mar 2009 14:55:33 +0200 Subject: Doc: Removed a reference to a deprecated function. Reported by a former Doc Manager. Reviewed-by: TrustMe --- src/gui/dialogs/qcolordialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp index b744dca..3aa04f6 100644 --- a/src/gui/dialogs/qcolordialog.cpp +++ b/src/gui/dialogs/qcolordialog.cpp @@ -1523,10 +1523,10 @@ static const Qt::WindowFlags DefaultWindowFlags = If you require a modeless dialog, use the QColorDialog constructor. \endomit - The static getColor() function shows the dialog, and allows the - user to specify a color. The getRgba() function does the same, but - also allows the user to specify a color with an alpha channel - (transparency) value. + The static getColor() function shows the dialog, and allows the user to + specify a color. This function can also be used to let users choose a + color with a level of transparency: pass the ShowAlphaChannel option as + an additional argument. The user can store customCount() different custom colors. The custom colors are shared by all color dialogs, and remembered -- cgit v0.12 From 1b9ed030accb14783ad269ced6897779022273ad Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 31 Mar 2009 16:53:36 +0200 Subject: Doc: Clarified that the main use case for QRegion is as a clipping primitive not as a rendering primitive. Task-number: 183493 Reviewed-by: TrustMe --- src/gui/painting/qregion.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 8169ef8..c88af7c 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -65,9 +65,17 @@ QT_BEGIN_NAMESPACE \ingroup shared QRegion is used with QPainter::setClipRegion() to limit the paint - area to what needs to be painted. There is also a - QWidget::repaint() function that takes a QRegion parameter. - QRegion is the best tool for reducing flicker. + area to what needs to be painted. There is also a QWidget::repaint() + function that takes a QRegion parameter. QRegion is the best tool for + minimizing the amount of screen area to be updated by a repaint. + + This class is not suitable for constructing shapes for rendering, especially + as outlines. Use QPainterPath to create paths and shapes for use with + QPainter. + + QRegion is an \l{implicitly shared} class. + + \section1 Creating and Using Regions A region can be created from a rectangle, an ellipse, a polygon or a bitmap. Complex regions may be created by combining simple @@ -84,8 +92,6 @@ QT_BEGIN_NAMESPACE Example of using complex regions: \snippet doc/src/snippets/code/src_gui_painting_qregion.cpp 0 - QRegion is an \l{implicitly shared} class. - \warning Due to window system limitations, the whole coordinate space for a region is limited to the points between -32767 and 32767 on Windows 95/98/ME. You can circumvent this limitation by using a QPainterPath. @@ -93,7 +99,7 @@ QT_BEGIN_NAMESPACE \section1 Additional License Information On Embedded Linux, Windows CE and X11 platforms, parts of this class rely on - code obtained under the following license: + code obtained under the following licenses: \legalese Copyright (c) 1987 X Consortium @@ -120,9 +126,7 @@ QT_BEGIN_NAMESPACE in this Software without prior written authorization from the X Consortium. \endlegalese - \raw HTML -
- \endraw + \br \legalese Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. -- cgit v0.12 From 981be3911e925c3f501cc85cdecf9dc3f2a73f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 31 Mar 2009 17:03:06 +0200 Subject: Improve example so that we can demonstrate custom layout items. Should show better how to reimplement setGeometry(), sizeHint() --- doc/src/examples/basicgraphicslayouts.qdoc | 55 ++++++++++++++++------ .../basicgraphicslayouts/layoutitem.cpp | 50 ++++++++++++++++---- .../graphicsview/basicgraphicslayouts/layoutitem.h | 12 +++-- 3 files changed, 90 insertions(+), 27 deletions(-) diff --git a/doc/src/examples/basicgraphicslayouts.qdoc b/doc/src/examples/basicgraphicslayouts.qdoc index 92571af..9696fb6 100644 --- a/doc/src/examples/basicgraphicslayouts.qdoc +++ b/doc/src/examples/basicgraphicslayouts.qdoc @@ -45,6 +45,7 @@ The Basic Graphics Layouts example shows how to use the layout classes in QGraphicsView: QGraphicsLinearLayout and QGraphicsGridLayout. + In addition to that it shows how to write your own custom layout item. \image basicgraphicslayouts-example.png Screenshot of the Basic Layouts Example @@ -115,26 +116,24 @@ \section1 LayoutItem Class Definition - The \c LayoutItem class is a subclass of QGraphicsWidget. It has a - constructor, a destructor, and a reimplementation of the - {QGraphicsItem::paint()}{paint()} function. + The \c LayoutItem class is a subclass of QGraphicsLayoutItem and + QGraphicsItem. It has a constructor, a destructor, and some required + reimplementations. + Since it inherits QGraphicsLayoutItem it must reimplement + {QGraphicsLayoutItem::setGeometry()}{setGeometry()} and + {QGraphicsLayoutItem::sizeHint()}{sizeHint()}. + In addition to that it inherits QGraphicsItem, so it must reimplement + {QGraphicsItem::boundingRect()}{boundingRect()} and + {QGraphicsItem::paint()}{paint()}. \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.h 0 - The \c LayoutItem class also has a private instance of QPixmap, \c pix. - - \note We subclass QGraphicsWidget so that \c LayoutItem objects can - be automatically plugged into a layout, as QGraphicsWidget is a - specialization of QGraphicsLayoutItem. + The \c LayoutItem class also has a private instance of QPixmap, \c m_pix. \section1 LayoutItem Class Implementation - In \c{LayoutItem}'s constructor, \c pix is instantiated and the - \c{QT_original_R.png} image is loaded into it. We set the size of - \c LayoutItem to be slightly larger than the size of the pixmap as we - require some space around it for borders that we will paint later. - Alternatively, you could scale the pixmap to prevent the item from - becoming smaller than the pixmap. + In \c{LayoutItem}'s constructor, \c m_pix is instantiated and the + \c{block.png} image is loaded into it. \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 0 @@ -148,4 +147,32 @@ \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 2 + The reimplementation of {QGraphicsItem::boundingRect()}{boundingRect()} + will set the top left corner at (0,0), and the size of it will be + the size of the layout items + {QGraphicsLayoutItem::geometry()}{geometry()}. This is the area that + we paint within. + + \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 3 + + + The reimplementation of {QGraphicsLayoutItem::setGeometry()}{setGeometry()} + simply calls its baseclass implementation. However, since this will change + the boundingRect we must also call + {QGraphicsItem::prepareGeometryChange()}{prepareGeometryChange()}. + Finally, we move the item according to \c geom.topLeft(). + + \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 4 + + + Since we don't want the size of the item to be smaller than the pixmap, we + must make sure that we return a size hint that is larger than \c m_pix. + We also add some extra space around for borders that we will paint later. + Alternatively, you could scale the pixmap to prevent the item from + becoming smaller than the pixmap. + The preferred size is the same as the minimum size hint, while we set + maximum to be a large value + + \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 5 + */ \ No newline at end of file diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp b/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp index 8216b6e..7311b65 100644 --- a/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp +++ b/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp @@ -43,19 +43,18 @@ //! [0] LayoutItem::LayoutItem(QGraphicsItem *parent/* = 0*/) - : QGraphicsWidget(parent) + : QGraphicsLayoutItem(), QGraphicsItem(parent) { - pix = new QPixmap(QLatin1String(":/images/block.png")); - // Do not allow a size smaller than the pixmap with two frames around it. - setMinimumSize(pix->size() + QSize(12, 12)); + m_pix = new QPixmap(QLatin1String(":/images/block.png")); + setGraphicsItem(this); } //! [0] LayoutItem::~LayoutItem() { - delete pix; + delete m_pix; } - + //! [1] void LayoutItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget /*= 0*/) @@ -64,8 +63,8 @@ void LayoutItem::paint(QPainter *painter, Q_UNUSED(option); QRectF frame(QPointF(0,0), geometry().size()); - qreal w = pix->width(); - qreal h = pix->height(); + qreal w = m_pix->width(); + qreal h = m_pix->height(); QGradientStops stops; //! [1] @@ -94,6 +93,39 @@ void LayoutItem::paint(QPainter *painter, gradient.setStops(stops); painter->setBrush(QBrush(gradient)); painter->drawRoundedRect(innerFrame, 10.0, 10.0); - painter->drawPixmap(pixpos, *pix); + painter->drawPixmap(pixpos, *m_pix); } //! [2] + +//! [3] +QRectF LayoutItem::boundingRect() const +{ + return QRectF(QPointF(0,0), geometry().size()); +} +//! [3] + +//! [4] +void LayoutItem::setGeometry(const QRectF &geom) +{ + prepareGeometryChange(); + QGraphicsLayoutItem::setGeometry(geom); + setPos(geom.topLeft()); +} +//! [4] + +//! [5] +QSizeF LayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + switch (which) { + case Qt::MinimumSize: + case Qt::PreferredSize: + // Do not allow a size smaller than the pixmap with two frames around it. + return m_pix->size() + QSize(12, 12); + case Qt::MaximumSize: + return QSizeF(1000,1000); + default: + break; + } + return constraint; +} +//! [5] diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.h b/examples/graphicsview/basicgraphicslayouts/layoutitem.h index cbda636..8ec9038 100644 --- a/examples/graphicsview/basicgraphicslayouts/layoutitem.h +++ b/examples/graphicsview/basicgraphicslayouts/layoutitem.h @@ -44,18 +44,22 @@ #include //! [0] -class LayoutItem : public QGraphicsWidget +class LayoutItem : public QGraphicsLayoutItem, public QGraphicsItem { - Q_OBJECT - public: LayoutItem(QGraphicsItem *parent = 0); ~LayoutItem(); + // Inherited from QGraphicsLayoutItem + void setGeometry(const QRectF &geom); + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; + + // Inherited from QGraphicsItem + QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); private: - QPixmap *pix; + QPixmap *m_pix; }; //! [0] -- cgit v0.12 From a78f2ea2313df413dc8f7659c6dc3d098b18c263 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 31 Mar 2009 17:07:20 +0200 Subject: compile with QIODEVICE_DEBUG remove Qt3Support calls and include ctype.h for isprint() --- src/corelib/io/qiodevice.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index c739054..b6c4eb1 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -48,6 +48,10 @@ #include "qstringlist.h" #include +#ifdef QIODEVICE_DEBUG +# include +#endif + QT_BEGIN_NAMESPACE #ifdef QIODEVICE_DEBUG @@ -362,7 +366,7 @@ QIODevice::QIODevice() { #if defined QIODEVICE_DEBUG QFile *file = qobject_cast(this); - printf("%p QIODevice::QIODevice(\"%s\") %s\n", this, className(), + printf("%p QIODevice::QIODevice(\"%s\") %s\n", this, metaObject()->className(), qPrintable(file ? file->fileName() : QString())); #endif } @@ -375,7 +379,7 @@ QIODevice::QIODevice(QObject *parent) : QObject(*new QIODevicePrivate, parent) { #if defined QIODEVICE_DEBUG - printf("%p QIODevice::QIODevice(%p \"%s\")\n", this, parent, className()); + printf("%p QIODevice::QIODevice(%p \"%s\")\n", this, parent, metaObject()->className()); #endif } -- cgit v0.12 From fb0c8a29f5ab04ac1a4697e2ae12eccea4dbca7e Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 31 Mar 2009 17:35:33 +0200 Subject: Doc: Noted the difference between the qLowerBound() functions. Task-number: 160621 Reviewed-by: TrustMe --- doc/src/qalgorithms.qdoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/src/qalgorithms.qdoc b/doc/src/qalgorithms.qdoc index 459fb81..b33c250 100644 --- a/doc/src/qalgorithms.qdoc +++ b/doc/src/qalgorithms.qdoc @@ -490,7 +490,10 @@ of \a value in the variable passed as a reference in argument \a n. \overload - This is the same as qLowerBound(\a{container}.begin(), \a{container}.end(), value); + For read-only iteration over containers, this function is broadly equivalent to + qLowerBound(\a{container}.begin(), \a{container}.end(), value). However, since it + returns a const iterator, you cannot use it to modify the container; for example, + to insert items. */ /*! \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value) -- cgit v0.12 From 9d4ddc4c1eb9c0aba31f99a0e8beb6f5a13188ca Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 31 Mar 2009 17:38:40 +0200 Subject: Doc: Made it clearer that QProcess::start() only starts a new process if one is not already running. Task-number: 231513 Reviewed-by: TrustMe --- src/corelib/io/qprocess.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index f16f996..a128482 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1476,11 +1476,15 @@ QByteArray QProcess::readAllStandardError() } /*! - Starts the program \a program in a new process, passing the - command line arguments in \a arguments. The OpenMode is set to \a - mode. QProcess will immediately enter the Starting state. If the - process starts successfully, QProcess will emit started(); - otherwise, error() will be emitted. + Starts the program \a program in a new process, if one is not already + running, passing the command line arguments in \a arguments. The OpenMode + is set to \a mode. + + The QProcess object will immediately enter the Starting state. If the + process starts successfully, QProcess will emit started(); otherwise, + error() will be emitted. If the QProcess object is already running a + process, a warning may be printed at the console, and the existing + process will continue running. Note that arguments that contain spaces are not passed to the process as separate arguments. @@ -1577,10 +1581,10 @@ static QStringList parseCombinedArgString(const QString &program) /*! \overload - Starts the program \a program in a new process. \a program is a - single string of text containing both the program name and its - arguments. The arguments are separated by one or more - spaces. For example: + Starts the program \a program in a new process, if one is not already + running. \a program is a single string of text containing both the + program name and its arguments. The arguments are separated by one or + more spaces. For example: \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 5 @@ -1589,6 +1593,9 @@ static QStringList parseCombinedArgString(const QString &program) \snippet doc/src/snippets/code/src_corelib_io_qprocess.cpp 6 + If the QProcess object is already running a process, a warning may be + printed at the console, and the existing process will continue running. + Note that, on Windows, quotes need to be both escaped and quoted. For example, the above code would be specified in the following way to ensure that \c{"My Documents"} is used as the argument to -- cgit v0.12 From 0b8309b6b7820c0036f1f8cd2253477e67a8b165 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 31 Mar 2009 18:25:28 +0200 Subject: use ftruncate() to resize a buffered file using truncate() on the file name was a bad idea, since the OS had to open it again - on some file systems, this would just error out, so QFile::resize() failed by default. Reviewed-by: Thiago --- src/corelib/io/qfsfileengine_unix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 0d88b06..8a0a3f5 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -935,6 +935,8 @@ bool QFSFileEngine::setSize(qint64 size) Q_D(QFSFileEngine); if (d->fd != -1) return !QT_FTRUNCATE(d->fd, size); + if (d->fh) + return !QT_FTRUNCATE(QT_FILENO(d->fh), size); return !QT_TRUNCATE(d->nativeFilePath.constData(), size); } -- cgit v0.12 From 12849e1767f3f881c9060368c3a14fae6e5a9ef1 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 31 Mar 2009 00:26:10 -0700 Subject: Prevent crash on resizing The crash was caused by out-of-bounds reading on the raster engine's clipping structures since our size had changed size last lock. This code makes sure the clipData structures are atleast as tall as the current height of the paint device. Reviewed-by: Tom Cooksey --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 90fc446..450c7f4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -243,6 +243,7 @@ public: SurfaceCache *surfaceCache; QTransform transform; + int lastLockedHeight; private: // QRegion rectsToClippedRegion(const QRect *rects, int n) const; // QRegion rectsToClippedRegion(const QRectF *rects, int n) const; @@ -267,9 +268,9 @@ private: QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), forceRasterPrimitives(false), simplePen(false), - simpleBrush(false), matrixRotShear(false), matrixScale(false), fbWidth(-1), fbHeight(-1), - opacity(255), drawFlags(0), blitFlags(0), duffFlags(0), dirtyFlags(false), dirtyClip(true), - dfbHandledClip(false), dfbDevice(0), q(p) + simpleBrush(false), matrixRotShear(false), matrixScale(false), lastLockedHeight(-1), + fbWidth(-1), fbHeight(-1), opacity(255), drawFlags(0), blitFlags(0), duffFlags(0), + dirtyFlags(false), dirtyClip(true), dfbHandledClip(false), dfbDevice(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); surfaceCache = new SurfaceCache; @@ -311,6 +312,8 @@ void QDirectFBPaintEnginePrivate::lock() // We will potentially get a new pointer to the buffer after a // lock so we need to call the base implementation of prepare so // it updates its rasterBuffer to point to the new buffer address. + lastLockedHeight = dfbDevice->height(); + Q_ASSERT(dfbDevice); prepare(dfbDevice); } @@ -330,6 +333,7 @@ void QDirectFBPaintEnginePrivate::setTransform(const QTransform &m) void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) { + lastLockedHeight = -1; if (device->devType() == QInternal::CustomRaster) dfbDevice = static_cast(device); else if (device->devType() == QInternal::Pixmap) { @@ -927,6 +931,9 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); d->setClipDirty(); + const QPoint bottom = d->transform.map(QPoint(0, path.controlPointRect().y2)); + if (bottom.y() >= d->lastLockedHeight) + d->lock(); QRasterPaintEngine::clip(path, op); } @@ -934,10 +941,15 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); d->setClipDirty(); + if (!d->clip()->hasRectClip && d->clip()->enabled) { + const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); + if (bottom.y() >= d->lastLockedHeight) + d->lock(); + } + QRasterPaintEngine::clip(rect, op); } - void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) { Q_D(QDirectFBPaintEngine); -- cgit v0.12 From 810bbcd38e8f829ccc6702f5cdf2bb97bbca97cc Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 30 Mar 2009 21:51:33 -0700 Subject: No sense in detecting the format twice Use the format passed in to the function rather than detecting it again based on hasAlphaChannel(). Reviewed-by: Tom Cooksey --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 3a6b3a2..fd6f48a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -249,14 +249,10 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription } IDirectFBSurface *QDirectFBScreen::copyToDFBSurface(const QImage &img, - QImage::Format format, + QImage::Format pixmapFormat, SurfaceCreationOptions options) { QImage image = img; - const QImage::Format pixmapFormat = image.hasAlphaChannel() - ? QDirectFBScreen::alphaPixmapFormat() - : QDirectFBScreen::pixelFormat(); - if (QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN #ifdef QT_NO_DIRECTFB_PREALLOCATED || image.format() != pixmapFormat @@ -266,7 +262,7 @@ IDirectFBSurface *QDirectFBScreen::copyToDFBSurface(const QImage &img, } - IDirectFBSurface *dfbSurface = createDFBSurface(img.size(), format, options); + IDirectFBSurface *dfbSurface = createDFBSurface(img.size(), pixmapFormat, options); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fromImage() Couldn't create surface"); return 0; -- cgit v0.12 From c2417c61aeda9de8a8e4c876ea42d6076d4078b0 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 31 Mar 2009 10:27:59 -0700 Subject: Remove these convenience functions. They only make sense under the assumption that there most of the time is no transform. With Falcon this isn't really the case. Reviewed-by: Tom Cooksey --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 34 ++++++++-------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 450c7f4..b8354d9 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -61,17 +61,6 @@ static inline uint ALPHA_MUL(uint x, uint a) return t; } -static inline QRect mapRect(const QTransform &transform, const QRect &rect) -{ - return (transform.isIdentity() ? rect : transform.mapRect(rect)); -} - -static inline QRect mapRect(const QTransform &transform, const QRectF &rect) -{ - return (transform.isIdentity() ? rect : transform.mapRect(rect)). - toRect(); -} - class SurfaceCache { public: @@ -542,7 +531,7 @@ QRegion QDirectFBPaintEnginePrivate::rectsToClippedRegion(const QRect *rects, QRegion region; for (int i = 0; i < n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = transform.mapRect(rects[i]); region += clip & r; } @@ -555,7 +544,7 @@ QRegion QDirectFBPaintEnginePrivate::rectsToClippedRegion(const QRectF *rects, QRegion region; for (int i = 0; i < n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = transform.mapRect(rects[i]).toRect(); region += clip & r; } @@ -584,7 +573,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) const { QVarLengthArray dfbRects(n); for (int i = 0; i < n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = transform.mapRect(rects[i]); dfbRects[i].x = r.x(); dfbRects[i].y = r.y(); dfbRects[i].w = r.width(); @@ -597,7 +586,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) const { QVarLengthArray dfbRects(n); for (int i = 0; i < n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = transform.mapRect(rects[i]).toRect(); dfbRects[i].x = r.x(); dfbRects[i].y = r.y(); dfbRects[i].w = r.width(); @@ -609,7 +598,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) const void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) const { for (int i = 0; i < n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = transform.mapRect(rects[i]); surface->DrawRectangle(surface, r.x(), r.y(), r.width() + 1, r.height() + 1); } @@ -618,7 +607,7 @@ void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) const void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) const { for (int i = 0; i < n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = transform.mapRect(rects[i]).toRect(); surface->DrawRectangle(surface, r.x(), r.y(), r.width() + 1, r.height() + 1); } @@ -642,7 +631,7 @@ void QDirectFBPaintEnginePrivate::drawPixmap(const QRectF &dest, QDirectFBPixmapData *dfbData = static_cast(data); IDirectFBSurface *s = dfbData->directFBSurface(); const QRect sr = src.toRect(); - const QRect dr = ::mapRect(transform, dest); + const QRect dr = transform.mapRect(dest).toRect(); const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; DFBResult result; @@ -674,6 +663,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); IDirectFBSurface *s = dfbData->directFBSurface(); + const QRect dr = transform.mapRect(dest).toRect(); const QRect dr = ::mapRect(transform, dest); DFBResult result = DFB_OK; @@ -696,7 +686,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, result = surface->BatchBlit(surface, s, rects.constData(), points.constData(), points.size()); } else { - const QRect sr = ::mapRect(transform, QRect(0, 0, pixmap.width(), pixmap.height())); + const QRect sr = transform.mapRect(QRect(0, 0, pixmap.width(), pixmap.height())); const int dx = sr.width(); const int dy = sr.height(); const DFBRectangle sRect = { 0, 0, dx, dy }; @@ -769,7 +759,7 @@ void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest, } const QRect sr = src.toRect(); - const QRect dr = ::mapRect(transform, dest); + const QRect dr = transform.mapRect(dest).toRect(); const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); @@ -1197,7 +1187,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) d->unlock(); d->updateFlags(); d->setDFBColor(brush.color()); - const QRect r = ::mapRect(d->transform, rect); + const QRect r = d->transform.mapRect(rect).toRect(); d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()); return; } @@ -1229,7 +1219,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) d->unlock(); d->updateFlags(); d->setDFBColor(color); - const QRect r = ::mapRect(d->transform, rect); + const QRect r = d->transform.mapRect(rect).toRect(); d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()); } -- cgit v0.12 From 4d878fe43bef5ff6387c3bb73587315efa21424d Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 31 Mar 2009 10:40:34 -0700 Subject: Compile I messed up the cherry-pick merge and left one of these in. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index b8354d9..3b6ea80 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -664,7 +664,6 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, QDirectFBPixmapData *dfbData = static_cast(data); IDirectFBSurface *s = dfbData->directFBSurface(); const QRect dr = transform.mapRect(dest).toRect(); - const QRect dr = ::mapRect(transform, dest); DFBResult result = DFB_OK; if (!matrixScale && dr == QRect(0, 0, fbWidth, fbHeight)) { -- cgit v0.12 From ac96e93728541897203a8d1bcbdf9e43c4af8758 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 31 Mar 2009 19:53:21 +0200 Subject: Doc: Fixed the screenshots and example description to match the code. Task-number: 242369 Reviewed-by: TrustMe --- doc/src/examples/extension.qdoc | 11 +++++------ doc/src/images/extension-example.png | Bin 7676 -> 9929 bytes doc/src/images/extension_more.png | Bin 9309 -> 13523 bytes 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/src/examples/extension.qdoc b/doc/src/examples/extension.qdoc index 8a0ca3a..02e0698 100644 --- a/doc/src/examples/extension.qdoc +++ b/doc/src/examples/extension.qdoc @@ -80,9 +80,9 @@ user type a word to search for, we need several \l {QCheckBox}{QCheckBox}es to facilitate the search options, and we need three \l {QPushButton}{QPushButton}s: the \gui Find button to - start a search, the \gui More button to enable an advanced search, - and the \gui Close button to exit the application. Finally, we - need a QWidget representing the application's extension part. + start a search and the \gui More button to enable an advanced search. + Finally, we need a QWidget representing the application's extension + part. \section1 FindDialog Class Implementation @@ -128,8 +128,7 @@ the connection makes sure that the extension widget is shown depending on the state of \gui More button. - We also connect the \gui Close button to the QWidget::close() - slot, and we put the checkboxes associated with the advanced + We also put the check boxes associated with the advanced search options into a layout we install on the extension widget. \snippet examples/dialogs/extension/finddialog.cpp 4 @@ -137,7 +136,7 @@ Before we create the main layout, we create several child layouts for the widgets: First we allign the QLabel ans its buddy, the QLineEdit, using a QHBoxLayout. Then we vertically allign the - QLabel and QLineEdit with the checkboxes associated with the + QLabel and QLineEdit with the check boxes associated with the simple search, using a QVBoxLayout. We also create a QVBoxLayout for the buttons. In the end we lay out the two latter layouts and the extension widget using a QGridLayout. diff --git a/doc/src/images/extension-example.png b/doc/src/images/extension-example.png index dfaacc0..18fab52 100644 Binary files a/doc/src/images/extension-example.png and b/doc/src/images/extension-example.png differ diff --git a/doc/src/images/extension_more.png b/doc/src/images/extension_more.png index 2b06809..407af27 100644 Binary files a/doc/src/images/extension_more.png and b/doc/src/images/extension_more.png differ -- cgit v0.12 From ba8c15b71b006ddb5c74f0c97288d98541221328 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 31 Mar 2009 22:53:52 +0200 Subject: Subject: Compile fix on Windows Reviewed-by: Anders Bakken --- src/corelib/io/qdiriterator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index a2c5321..b14f436 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -201,8 +201,8 @@ void QDirIteratorPrivate::advance() QString subDir = it->currentFilePath(); #ifdef Q_OS_WIN - if (fileInfo.isSymLink()) - subDir = fileInfo.canonicalFilePath(); + if (currentFileInfo.isSymLink()) + subDir = currentFileInfo.canonicalFilePath(); #endif pushSubDirectory(subDir, it->nameFilters(), it->filters()); } -- cgit v0.12 From 831d2742b7c41924f052acd81620e8bfc58afde7 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 1 Apr 2009 14:09:00 +1000 Subject: DB Autotest cleanup Make db autotest data set generation more consistent, slightly faster. Also, add ability to easily generate a set of a single databases entries worth of criteria to test. --- tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp | 20 ++- .../q3sqlselectcursor/tst_q3sqlselectcursor.cpp | 12 +- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 158 +++++-------------- tests/auto/qsqlquery/tst_qsqlquery.cpp | 95 +++--------- tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp | 12 +- tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp | 167 +++++++++++---------- tests/auto/qsqlthread/tst_qsqlthread.cpp | 10 +- 7 files changed, 182 insertions(+), 292 deletions(-) diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp index c06485d..2d91186 100644 --- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp +++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp @@ -89,7 +89,7 @@ private slots: void unicode(); void precision_data() { generic_data(); } void precision(); - void insertORA_data(); + void insertORA_data() { generic_data("QOCI"); } void insertORA(); void batchInsert_data() { generic_data(); } void batchInsert(); @@ -101,7 +101,7 @@ private slots: void insertFieldNameContainsWS(); // For task 117996 private: - void generic_data(); + void generic_data(const QString &engine=QString()); void createTestTables( QSqlDatabase db ); void dropTestTables( QSqlDatabase db ); void populateTestTables( QSqlDatabase db ); @@ -117,10 +117,14 @@ tst_Q3SqlCursor::~tst_Q3SqlCursor() { } -void tst_Q3SqlCursor::generic_data() +void tst_Q3SqlCursor::generic_data(const QString &engine) { - if ( dbs.fillTestTable() == 0 ) - QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_Q3SqlCursor::createTestTables( QSqlDatabase db ) @@ -429,12 +433,6 @@ static QString dumpUtf8( const QString& str ) return res; } -void tst_Q3SqlCursor::insertORA_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - void tst_Q3SqlCursor::insertORA() { QFETCH( QString, dbName ); diff --git a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp index a8c5940..9ab74f0 100644 --- a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp +++ b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp @@ -76,7 +76,7 @@ private slots: void _exec(); private: - void generic_data(); + void generic_data(const QString &engine=QString()); void createTestTables( QSqlDatabase db ); void dropTestTables( QSqlDatabase db ); void populateTestTables( QSqlDatabase db ); @@ -92,10 +92,14 @@ tst_Q3SqlSelectCursor::~tst_Q3SqlSelectCursor() { } -void tst_Q3SqlSelectCursor::generic_data() +void tst_Q3SqlSelectCursor::generic_data(const QString& engine) { - if ( dbs.fillTestTable() == 0 ) - QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_Q3SqlSelectCursor::createTestTables( QSqlDatabase db ) diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index d8ad15a..e10a0ca 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -93,28 +93,28 @@ private slots: void addDatabase(); //database specific tests - void recordMySQL_data(); + void recordMySQL_data() { generic_data("QMYSQL"); } void recordMySQL(); - void recordPSQL_data(); + void recordPSQL_data() { generic_data("QPSQL"); } void recordPSQL(); - void recordOCI_data(); + void recordOCI_data() { generic_data("QOCI"); } void recordOCI(); - void recordTDS_data(); + void recordTDS_data() { generic_data("QTDS"); } void recordTDS(); - void recordDB2_data(); + void recordDB2_data() { generic_data("QDB2"); } void recordDB2(); - void recordSQLite_data(); + void recordSQLite_data() { generic_data("QSQLITE"); } void recordSQLite(); - void recordAccess_data(); + void recordAccess_data() { generic_data("QODBC"); } void recordAccess(); - void recordSQLServer_data(); + void recordSQLServer_data() { generic_data("QODBC"); } void recordSQLServer(); - void recordIBase_data(); + void recordIBase_data() {generic_data("QIBASE"); } void recordIBase(); - void eventNotificationIBase_data() { generic_data(); } + void eventNotificationIBase_data() { generic_data("QIBASE"); } void eventNotificationIBase(); - void eventNotificationPSQL_data() { generic_data(); } + void eventNotificationPSQL_data() { generic_data("QPSQL"); } void eventNotificationPSQL(); //database specific 64 bit integer test @@ -141,61 +141,61 @@ private slots: void precisionPolicy_data() { generic_data(); } void precisionPolicy(); - void db2_valueCacheUpdate_data() { generic_data(); } + void db2_valueCacheUpdate_data() { generic_data("QDB2"); } void db2_valueCacheUpdate(); - void psql_schemas_data(); + void psql_schemas_data() { generic_data("QPSQL"); } void psql_schemas(); - void psql_escapedIdentifiers_data(){ psql_schemas_data(); } + void psql_escapedIdentifiers_data() { generic_data("QPSQL"); } void psql_escapedIdentifiers(); - void psql_escapeBytea_data() { psql_schemas_data(); } + void psql_escapeBytea_data() { generic_data("QPSQL"); } void psql_escapeBytea(); - void bug_249059_data() { psql_schemas_data(); } + void bug_249059_data() { generic_data("QPSQL"); } void bug_249059(); void mysqlOdbc_unsignedIntegers_data() { generic_data(); } void mysqlOdbc_unsignedIntegers(); - void mysql_multiselect_data() { generic_data(); } + void mysql_multiselect_data() { generic_data("QMYSQL"); } void mysql_multiselect(); // For task 144331 void accessOdbc_strings_data() { generic_data(); } void accessOdbc_strings(); - void ibase_numericFields_data() { generic_data(); } + void ibase_numericFields_data() { generic_data("QIBASE"); } void ibase_numericFields(); // For task 125053 - void ibase_fetchBlobs_data() { generic_data(); } + void ibase_fetchBlobs_data() { generic_data("QIBASE"); } void ibase_fetchBlobs(); // For task 143471 - void ibase_useCustomCharset_data() { generic_data(); } + void ibase_useCustomCharset_data() { generic_data("QIBASE"); } void ibase_useCustomCharset(); // For task 134608 - void ibase_procWithoutReturnValues_data() { generic_data(); } // For task 165423 + void ibase_procWithoutReturnValues_data() { generic_data("QIBASE"); } // For task 165423 void ibase_procWithoutReturnValues(); - void ibase_procWithReturnValues_data() { generic_data(); } // For task 177530 + void ibase_procWithReturnValues_data() { generic_data("QIBASE"); } // For task 177530 void ibase_procWithReturnValues(); - void odbc_reopenDatabase_data() { generic_data(); } + void odbc_reopenDatabase_data() { generic_data("QODBC"); } void odbc_reopenDatabase(); - void odbc_uniqueidentifier_data() { generic_data(); } + void odbc_uniqueidentifier_data() { generic_data("QODBC"); } void odbc_uniqueidentifier(); // For task 141822 - void odbc_uintfield_data() { generic_data(); } + void odbc_uintfield_data() { generic_data("QODBC"); } void odbc_uintfield(); - void odbc_bindBoolean_data() { generic_data(); } + void odbc_bindBoolean_data() { generic_data("QODBC"); } void odbc_bindBoolean(); - void oci_serverDetach_data() { generic_data(); } + void oci_serverDetach_data() { generic_data("QOCI"); } void oci_serverDetach(); // For task 154518 - void oci_xmltypeSupport_data() { generic_data(); } + void oci_xmltypeSupport_data() { generic_data("QOCI"); } void oci_xmltypeSupport(); - void oci_fieldLength_data() { generic_data(); } + void oci_fieldLength_data() { generic_data("QOCI"); } void oci_fieldLength(); - void sqlite_bindAndFetchUInt_data() { generic_data(); } + void sqlite_bindAndFetchUInt_data() { generic_data("QSQLITE3"); } void sqlite_bindAndFetchUInt(); private: void createTestTables(QSqlDatabase db); void dropTestTables(QSqlDatabase db); void populateTestTables(QSqlDatabase db); - void generic_data(); + void generic_data(const QString &engine=QString()); #ifdef QT3_SUPPORT void testRecordInfo(const FieldDef fieldDefs[], const Q3SqlRecordInfo& inf); @@ -397,70 +397,14 @@ void tst_QSqlDatabase::cleanup() { } -void tst_QSqlDatabase::recordOCI_data() +void tst_QSqlDatabase::generic_data(const QString& engine) { - if (dbs.fillTestTable("QOCI") == 0) - QSKIP("No Oracle database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordPSQL_data() -{ - if (dbs.fillTestTable("QPSQL") == 0) - QSKIP("No PostgreSQL database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordMySQL_data() -{ - if (dbs.fillTestTable("QMYSQL") == 0) - QSKIP("No MySQL database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordTDS_data() -{ - if (dbs.fillTestTable("QTDS") == 0) - QSKIP("No TDS database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordDB2_data() -{ - if (dbs.fillTestTable("QDB2") == 0) - QSKIP("No DB2 database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordSQLite_data() -{ - if (dbs.fillTestTable("QSQLITE") == 0) - QSKIP("No SQLite database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordAccess_data() -{ - if (dbs.fillTestTable("QODBC") == 0) - QSKIP("No ODBC database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordSQLServer_data() -{ - if (dbs.fillTestTable("QODBC") == 0) - QSKIP("No ODBC database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::recordIBase_data() -{ - if (dbs.fillTestTable("QIBASE") == 0) - QSKIP("No Interbase database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::psql_schemas_data() -{ - if (dbs.fillTestTable("QPSQL") == 0) - QSKIP("No Postgres database drivers are available in this Qt configuration", SkipAll); -} - -void tst_QSqlDatabase::generic_data() -{ - if (dbs.fillTestTable() == 0) - QSKIP("No database drivers are available in this Qt configuration", SkipAll); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_QSqlDatabase::addDatabase() @@ -888,7 +832,6 @@ void tst_QSqlDatabase::recordTDS() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QTDS"); static const FieldDef fieldDefs[] = { FieldDef("tinyint", QVariant::Int, 255), @@ -937,7 +880,6 @@ void tst_QSqlDatabase::recordOCI() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QOCI"); // runtime check for Oracle version since V8 doesn't support TIMESTAMPs if (tst_Databases::getOraVersion(db) >= 9) { @@ -1013,7 +955,6 @@ void tst_QSqlDatabase::recordPSQL() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QPSQL"); FieldDef byteadef; if (db.driver()->hasFeature(QSqlDriver::BLOB)) @@ -1098,7 +1039,6 @@ void tst_QSqlDatabase::recordMySQL() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QMYSQL"); FieldDef bin10, varbin10; int major = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt(); @@ -1177,7 +1117,6 @@ void tst_QSqlDatabase::recordDB2() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QDB2"); static const FieldDef fieldDefs[] = { FieldDef("char(20)", QVariant::String, QString("Blah1")), @@ -1223,7 +1162,6 @@ void tst_QSqlDatabase::recordIBase() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); static const FieldDef fieldDefs[] = { FieldDef("char(20)", QVariant::String, QString("Blah1"), false), @@ -1254,7 +1192,6 @@ void tst_QSqlDatabase::recordSQLite() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QSQLITE"); static const FieldDef fieldDefs[] = { // The affinity of these fields are TEXT so SQLite should give us strings, not ints or doubles. @@ -1801,7 +1738,6 @@ void tst_QSqlDatabase::ibase_numericFields() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QSqlQuery q(db); QString tableName = qTableName("numericfields"); @@ -1875,7 +1811,6 @@ void tst_QSqlDatabase::ibase_fetchBlobs() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QString tableName = qTableName("qtest_ibaseblobs"); QSqlQuery q(db); @@ -1908,7 +1843,6 @@ void tst_QSqlDatabase::ibase_procWithoutReturnValues() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QSqlQuery q(db); QString procName = qTableName("qtest_proc1"); @@ -1989,11 +1923,6 @@ void tst_QSqlDatabase::odbc_reopenDatabase() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - if (!tst_Databases::isSqlServer(db)) { - QSKIP("SQL Server (ODBC) specific test", SkipSingle); - return; - } - QSqlQuery q(db); QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest"))); QVERIFY_SQL(q, next()); @@ -2008,7 +1937,6 @@ void tst_QSqlDatabase::odbc_bindBoolean() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QODBC"); QSqlQuery q(db); QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool") + "(id int, boolvalue bit)")); @@ -2037,7 +1965,6 @@ void tst_QSqlDatabase::mysql_multiselect() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QMYSQL"); QSqlQuery q(db); QVERIFY_SQL(q, exec("select version()")); @@ -2059,7 +1986,6 @@ void tst_QSqlDatabase::ibase_useCustomCharset() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QString nonlatin1string("��"); db.close(); @@ -2083,7 +2009,6 @@ void tst_QSqlDatabase::oci_serverDetach() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QOCI"); for (int i = 0; i < 2; i++) { db.close(); @@ -2104,7 +2029,6 @@ void tst_QSqlDatabase::oci_xmltypeSupport() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QOCI"); QString tableName = qTableName("qtest_xmltype"); QString xml("MY_TABLE"); @@ -2133,7 +2057,6 @@ void tst_QSqlDatabase::oci_fieldLength() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QOCI"); QString tableName = qTableName("qtest"); QSqlQuery q(db); @@ -2198,7 +2121,6 @@ void tst_QSqlDatabase::odbc_uintfield() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QODBC"); QString tableName = qTableName("uint_table"); unsigned int val = 4294967295U; @@ -2260,7 +2182,6 @@ void tst_QSqlDatabase::eventNotificationIBase() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QIBASE"); QString procedureName = qTableName("posteventProc"); QSqlDriver *driver=db.driver(); @@ -2290,7 +2211,6 @@ void tst_QSqlDatabase::eventNotificationPSQL() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QPSQL"); QSqlQuery query(db); QString procedureName = qTableName("posteventProc"); @@ -2311,7 +2231,6 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QSQLITE3"); QSqlQuery q(db); QString tableName = qTableName("uint_test"); @@ -2333,7 +2252,6 @@ void tst_QSqlDatabase::db2_valueCacheUpdate() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QDB2"); QString tableName = qTableName("qtest"); QSqlQuery q(db); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 684d6ac..8d77589 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -93,7 +93,7 @@ private slots: void transaction(); void record_data() { generic_data(); } void record(); - void record_sqlite_data() { generic_data(); } + void record_sqlite_data() { generic_data("QSQLITE"); } void record_sqlite(); void finish_data() { generic_data(); } void finish(); @@ -107,13 +107,13 @@ private slots: void forwardOnly(); // bug specific tests - void bitField_data(); + void bitField_data() {generic_data("QTDS"); } void bitField(); - void nullBlob_data(); + void nullBlob_data() { generic_data("QOCI"); } void nullBlob(); void blob_data() { generic_data(); } void blob(); - void rawField_data(); + void rawField_data() { generic_data("QOCI"); } void rawField(); void precision_data() { generic_data(); } void precision(); @@ -129,19 +129,19 @@ private slots: void char1SelectUnicode(); void synonyms_data() { generic_data(); } void synonyms(); - void oraOutValues_data(); + void oraOutValues_data() { generic_data("QOCI"); } void oraOutValues(); - void mysqlOutValues_data(); + void mysqlOutValues_data() { generic_data("QMYSQL"); } void mysqlOutValues(); - void oraClob_data() { oraOutValues_data(); } + void oraClob_data() { generic_data("QOCI"); } void oraClob(); - void oraLong_data() { oraOutValues_data(); } + void oraLong_data() { generic_data("QOCI"); } void oraLong(); - void outValuesDB2_data(); + void outValuesDB2_data() { generic_data("QDB2"); } void outValuesDB2(); - void storedProceduresIBase_data(); + void storedProceduresIBase_data() {generic_data("QIBASE"); } void storedProceduresIBase(); - void oraRowId_data(); + void oraRowId_data() { generic_data("QOCI"); } void oraRowId(); void prepare_bind_exec_data() { generic_data(); } void prepare_bind_exec(); @@ -175,13 +175,13 @@ private slots: void emptyTableNavigate(); #ifdef NOT_READY_YET - void bug217003_data() { generic_data(); } - void bug217003(); + void task_217003_data() { generic_data(); } + void task_217003(); #endif private: // returns all database connections - void generic_data(); + void generic_data(const QString &engine=QString()); void dropTestTables( QSqlDatabase db ); void createTestTables( QSqlDatabase db ); void populateTestTables( QSqlDatabase db ); @@ -247,28 +247,14 @@ void tst_QSqlQuery::cleanup() } } -void tst_QSqlQuery::bitField_data() +void tst_QSqlQuery::generic_data(const QString& engine) { - if ( dbs.fillTestTable( "QTDS" ) == 0 ) - QSKIP( "No TDS database drivers are available in this Qt configuration", SkipAll ); -} - -void tst_QSqlQuery::nullBlob_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - -void tst_QSqlQuery::rawField_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - -void tst_QSqlQuery::generic_data() -{ - if ( dbs.fillTestTable() == 0 ) - QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) @@ -421,12 +407,6 @@ void tst_QSqlQuery::char1SelectUnicode() QSKIP( "Database not unicode capable", SkipSingle ); } -void tst_QSqlQuery::oraRowId_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::oraRowId() { QFETCH( QString, dbName ); @@ -461,12 +441,6 @@ void tst_QSqlQuery::oraRowId() QCOMPARE( q.value( 0 ).toString(), QString( "b" ) ); } -void tst_QSqlQuery::mysqlOutValues_data() -{ - if ( dbs.fillTestTable( "QMYSQL" ) == 0 ) - QSKIP( "No MySQL database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::mysqlOutValues() { QFETCH( QString, dbName ); @@ -517,12 +491,6 @@ void tst_QSqlQuery::mysqlOutValues() QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) ); } -void tst_QSqlQuery::oraOutValues_data() -{ - if ( dbs.fillTestTable( "QOCI" ) == 0 ) - QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::oraOutValues() { QFETCH( QString, dbName ); @@ -670,18 +638,11 @@ void tst_QSqlQuery::oraClob() QVERIFY( q.value( 1 ).toByteArray() == loong.toLatin1() ); } -void tst_QSqlQuery::storedProceduresIBase_data() -{ - if ( dbs.fillTestTable( "QIBASE" ) == 0 ) - QSKIP( "No Interbase database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::storedProceduresIBase() { QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QIBASE" ); QSqlQuery q( db ); q.exec( "drop procedure " + qTableName( "TESTPROC" ) ); @@ -713,12 +674,6 @@ void tst_QSqlQuery::storedProceduresIBase() q.exec( "drop procedure " + qTableName( "TestProc" ) ); } -void tst_QSqlQuery::outValuesDB2_data() -{ - if ( dbs.fillTestTable( "QDB2" ) == 0 ) - QSKIP( "No DB2 database drivers are available in this Qt configuration", SkipAll ); -} - void tst_QSqlQuery::outValuesDB2() { QFETCH( QString, dbName ); @@ -1355,7 +1310,6 @@ void tst_QSqlQuery::nullBlob() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QOCI" ); QSqlQuery q( db ); QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_nullblob" ) + " (id int primary key, bb blob)" ) ); @@ -1385,7 +1339,6 @@ void tst_QSqlQuery::rawField() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QOCI" ); QSqlQuery q( db ); q.setForwardOnly( true ); @@ -2103,7 +2056,6 @@ void tst_QSqlQuery::record_sqlite() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QSQLITE" ); QSqlQuery q( db ); @@ -2131,7 +2083,6 @@ void tst_QSqlQuery::oraLong() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - DBMS_SPECIFIC( db, "QOCI" ); QSqlQuery q( db ); @@ -2158,7 +2109,7 @@ void tst_QSqlQuery::execErrorRecovery() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr" ) + " (id int primary key)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr" ) + " (id int not null primary key)" ) ); QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_exerr" ) + " values (?)" ) ); q.addBindValue( 1 ); @@ -2698,7 +2649,7 @@ void tst_QSqlQuery::emptyTableNavigate() } #ifdef NOT_READY_YET -void tst_QSqlQuery::bug217003() +void tst_QSqlQuery::task_217003() { QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp index 63202f8..88b5770 100644 --- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -95,7 +95,7 @@ private slots: void setQueryWithNoRowsInResultSet(); private: - void generic_data(); + void generic_data(const QString &engine=QString()); void dropTestTables(QSqlDatabase db); void createTestTables(QSqlDatabase db); void populateTestTables(QSqlDatabase db); @@ -202,10 +202,14 @@ void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db) tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp") << qTableName("test3tmp")); } -void tst_QSqlQueryModel::generic_data() +void tst_QSqlQueryModel::generic_data(const QString& engine) { - if (dbs.fillTestTable() == 0) - QSKIP("No database drivers are available in this Qt configuration", SkipAll); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_QSqlQueryModel::init() diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index 6015d1c..d4affe4 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -66,38 +66,59 @@ public: tst_Databases dbs; public slots: - void initTestCase_data(); void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); private slots: + void select_data() { generic_data(); } void select(); + void submitAll_data() { generic_data(); } void submitAll(); - void setRecord_data(); + void setRecord_data() { generic_data(); } void setRecord(); + void insertRow_data() { generic_data(); } void insertRow(); + void insertRecord_data() { generic_data(); } void insertRecord(); + void insertMultiRecords_data() { generic_data(); } void insertMultiRecords(); + void removeRow_data() { generic_data(); } void removeRow(); + void removeRows_data() { generic_data(); } void removeRows(); + void removeInsertedRow_data() { generic_data(); } void removeInsertedRow(); + void setFilter_data() { generic_data(); } void setFilter(); + void setInvalidFilter_data() { generic_data(); } void setInvalidFilter(); + void emptyTable_data() { generic_data(); } void emptyTable(); + void tablesAndSchemas_data() { generic_data("QPSQL"); } void tablesAndSchemas(); + void whitespaceInIdentifiers_data() { generic_data(); } void whitespaceInIdentifiers(); + void primaryKeyOrder_data() { generic_data("QSQLITE"); } void primaryKeyOrder(); + void sqlite_bigTable_data() { generic_data("QSQLITE"); } void sqlite_bigTable(); // bug specific tests + void insertRecordBeforeSelect_data() { generic_data(); } void insertRecordBeforeSelect(); + void submitAllOnInvalidTable_data() { generic_data(); } void submitAllOnInvalidTable(); + void insertRecordsInLoop_data() { generic_data(); } void insertRecordsInLoop(); + void sqlite_attachedDatabase_data() { generic_data("QSQLITE"); } void sqlite_attachedDatabase(); // For task 130799 + +private: + void generic_data(const QString& engine=QString()); }; tst_QSqlTableModel::tst_QSqlTableModel() @@ -121,7 +142,8 @@ void tst_QSqlTableModel::dropTestTables() << qTableName("test2") << qTableName("test3") << qTableName("emptytable") - << qTableName("bigtable"); + << qTableName("bigtable") + << qTableName("foo"); if (testWhiteSpaceNames(db.driverName())) tableNames << qTableName("qtestw hitespace"); @@ -160,16 +182,16 @@ void tst_QSqlTableModel::repopulateTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - QVERIFY_SQL( q, exec("delete from " + qTableName("test"))); + q.exec("delete from " + qTableName("test")); QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)")); QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)")); QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(3, 'vohi', 3)")); - QVERIFY_SQL( q, exec("delete from " + qTableName("test2"))); + q.exec("delete from " + qTableName("test2")); QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(1, 'herr')")); QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(2, 'mister')")); - QVERIFY_SQL( q, exec("delete from " + qTableName("test3"))); + q.exec("delete from " + qTableName("test3")); QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(1, 'foo', 'bar')")); QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(2, 'baz', 'joe')")); } @@ -182,11 +204,13 @@ void tst_QSqlTableModel::recreateTestTables() repopulateTestTables(); } -void tst_QSqlTableModel::initTestCase_data() +void tst_QSqlTableModel::generic_data(const QString &engine) { - if (dbs.fillTestTable() == 0) { - qWarning("NO DATABASES"); - QSKIP("No database drivers are available in this Qt configuration", SkipAll); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); } } @@ -212,7 +236,7 @@ void tst_QSqlTableModel::cleanup() void tst_QSqlTableModel::select() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -245,58 +269,51 @@ void tst_QSqlTableModel::select() QCOMPARE(model.data(model.index(3, 3)), QVariant()); } -void tst_QSqlTableModel::setRecord_data() -{ - QTest::addColumn("submitpolicy"); - QTest::newRow("OnFieldChange") << (uint)QSqlTableModel::OnFieldChange; - QTest::newRow("OnRowChange") << (uint)QSqlTableModel::OnRowChange; - QTest::newRow("OnManualSubmit") << (uint)QSqlTableModel::OnManualSubmit; -} - void tst_QSqlTableModel::setRecord() { - // This needs to be tested with ODBC, which requires a manual change to qsqldatabase\tst_databases.h - // to ensure an ODBC db is added - - QFETCH_GLOBAL(QString, dbName); - QFETCH(uint, submitpolicy); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QSqlTableModel model(0, db); - model.setEditStrategy((QSqlTableModel::EditStrategy)submitpolicy); - model.setTable(qTableName("test3")); - model.setSort(0, Qt::AscendingOrder); - QVERIFY_SQL(model, select()); + QList policies = QList() << QSqlTableModel::OnFieldChange << QSqlTableModel::OnRowChange << QSqlTableModel::OnManualSubmit; + + foreach( QSqlTableModel::EditStrategy submitpolicy, policies) { + + QSqlTableModel model(0, db); + model.setEditStrategy((QSqlTableModel::EditStrategy)submitpolicy); + model.setTable(qTableName("test3")); + model.setSort(0, Qt::AscendingOrder); + QVERIFY_SQL(model, select()); - for (int i = 0; i < model.rowCount(); ++i) { - QSignalSpy spy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); - - QSqlRecord rec = model.record(i); - rec.setValue(1, rec.value(1).toString() + 'X'); - rec.setValue(2, rec.value(2).toString() + 'X'); - QVERIFY(model.setRecord(i, rec)); - - if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnManualSubmit) - QVERIFY(model.submitAll()); - else { - // dataChanged() is not emitted when submitAll() is called - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(0).count(), 2); - QCOMPARE(qvariant_cast(spy.at(0).at(0)), model.index(i, 1)); - QCOMPARE(qvariant_cast(spy.at(0).at(1)), model.index(i, 1)); + for (int i = 0; i < model.rowCount(); ++i) { + QSignalSpy spy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + + QSqlRecord rec = model.record(i); + rec.setValue(1, rec.value(1).toString() + 'X'); + rec.setValue(2, rec.value(2).toString() + 'X'); + QVERIFY(model.setRecord(i, rec)); + + if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnManualSubmit) + QVERIFY(model.submitAll()); + else { + // dataChanged() is not emitted when submitAll() is called + QCOMPARE(spy.count(), 2); + QCOMPARE(spy.at(0).count(), 2); + QCOMPARE(qvariant_cast(spy.at(0).at(0)), model.index(i, 1)); + QCOMPARE(qvariant_cast(spy.at(0).at(1)), model.index(i, 1)); + } } - } - QCOMPARE(model.data(model.index(0, 1)).toString(), QString("fooX")); - QCOMPARE(model.data(model.index(0, 2)).toString(), QString("barX")); - QCOMPARE(model.data(model.index(1, 1)).toString(), QString("bazX")); - QCOMPARE(model.data(model.index(1, 2)).toString(), QString("joeX")); + QCOMPARE(model.data(model.index(0, 1)).toString(), QString("fooX")); + QCOMPARE(model.data(model.index(0, 2)).toString(), QString("barX")); + QCOMPARE(model.data(model.index(1, 1)).toString(), QString("bazX")); + QCOMPARE(model.data(model.index(1, 2)).toString(), QString("joeX")); + } } void tst_QSqlTableModel::insertRow() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -321,7 +338,7 @@ void tst_QSqlTableModel::insertRow() void tst_QSqlTableModel::insertRecord() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -354,7 +371,7 @@ void tst_QSqlTableModel::insertRecord() void tst_QSqlTableModel::insertMultiRecords() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -403,7 +420,7 @@ void tst_QSqlTableModel::insertMultiRecords() void tst_QSqlTableModel::submitAll() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -438,7 +455,7 @@ void tst_QSqlTableModel::submitAll() void tst_QSqlTableModel::removeRow() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -484,7 +501,7 @@ void tst_QSqlTableModel::removeRow() void tst_QSqlTableModel::removeRows() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -533,7 +550,7 @@ void tst_QSqlTableModel::removeRows() void tst_QSqlTableModel::removeInsertedRow() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -565,7 +582,7 @@ void tst_QSqlTableModel::removeInsertedRow() void tst_QSqlTableModel::emptyTable() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -584,12 +601,10 @@ void tst_QSqlTableModel::emptyTable() void tst_QSqlTableModel::tablesAndSchemas() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QPSQL"); - QSqlQuery q(db); q.exec("DROP SCHEMA " + qTableName("testschema") + " CASCADE"); QVERIFY_SQL( q, exec("create schema " + qTableName("testschema"))); @@ -607,7 +622,7 @@ void tst_QSqlTableModel::tablesAndSchemas() void tst_QSqlTableModel::whitespaceInIdentifiers() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -623,16 +638,16 @@ void tst_QSqlTableModel::whitespaceInIdentifiers() void tst_QSqlTableModel::primaryKeyOrder() { - QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "primaryKeyOrderTest"); - db.setDatabaseName(":memory:"); - QVERIFY_SQL(db, open()); + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); QSqlQuery q(db); - QVERIFY_SQL( q, exec("create table foo(a varchar(20), id int primary key, b varchar(20))")); + QVERIFY_SQL( q, exec("create table "+qTableName("foo")+"(a varchar(20), id int not null primary key, b varchar(20))")); QSqlTableModel model(0, db); - model.setTable("foo"); + model.setTable(qTableName("foo")); QSqlIndex pk = model.primaryKey(); QCOMPARE(pk.count(), 1); @@ -652,7 +667,7 @@ void tst_QSqlTableModel::primaryKeyOrder() void tst_QSqlTableModel::setInvalidFilter() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -671,7 +686,7 @@ void tst_QSqlTableModel::setInvalidFilter() void tst_QSqlTableModel::setFilter() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -724,12 +739,10 @@ void tst_QSqlTableModel::setFilter() void tst_QSqlTableModel::sqlite_bigTable() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QSQLITE"); - bool hasTransactions = db.driver()->hasFeature(QSqlDriver::Transactions); if (hasTransactions) QVERIFY(db.transaction()); QSqlQuery q(db); @@ -763,7 +776,7 @@ void tst_QSqlTableModel::sqlite_bigTable() // had first been called. void tst_QSqlTableModel::insertRecordBeforeSelect() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -796,7 +809,7 @@ void tst_QSqlTableModel::insertRecordBeforeSelect() // are inserted and submitted on a non-existing table. void tst_QSqlTableModel::submitAllOnInvalidTable() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -828,7 +841,7 @@ void tst_QSqlTableModel::submitAllOnInvalidTable() // For task 147575: the rowsRemoved signal emitted from the model was lying void tst_QSqlTableModel::insertRecordsInLoop() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); @@ -866,12 +879,10 @@ void tst_QSqlTableModel::insertRecordsInLoop() void tst_QSqlTableModel::sqlite_attachedDatabase() { - QFETCH_GLOBAL(QString, dbName); + QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - DBMS_SPECIFIC(db, "QSQLITE"); - QSqlDatabase attachedDb = QSqlDatabase::cloneDatabase(db, db.driverName() + QLatin1String("attached")); attachedDb.setDatabaseName(db.databaseName()+QLatin1String("attached.dat")); QVERIFY_SQL(attachedDb, open()); diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp index 94e0f98..d871be4 100644 --- a/tests/auto/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp @@ -286,10 +286,14 @@ tst_QSqlThread::~tst_QSqlThread() { } -void tst_QSqlThread::generic_data() +void tst_QSqlThread::generic_data(const QString& engine) { - if (dbs.fillTestTable() == 0) - QSKIP("No database drivers are available in this Qt configuration", SkipAll); + if ( dbs.fillTestTable(engine) == 0 ) { + if(engine.isEmpty()) + QSKIP( "No database drivers are available in this Qt configuration", SkipAll ); + else + QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll ); + } } void tst_QSqlThread::dropTestTables() -- cgit v0.12 From 59a4daf8097c67918003efbc1a1071e2de63990a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 1 Apr 2009 10:12:25 +0200 Subject: Revert "Make use of a thread-specific variable in qFlagLocation." This reverts commit ba25c4a832516124bcd97758de9eede32797c5a0. I hadn't meant to merge this commit as it is not ready and not OK'ed by Brad yet. --- src/corelib/kernel/qobject.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 0e632db..05015c0 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2179,29 +2179,13 @@ void QObject::deleteLater() Signals and slots *****************************************************************************/ -// list taken from http://en.wikipedia.org/wiki/Thread-Specific_Storage -#if defined(Q_OS_WIN) -// Some people like to dynamically load Qt (LoadLibrary), so we can't use this -#elif defined(Q_CC_GNU) && !defined(Q_WS_QWS) -// GCC has warnings about this not being ported to all archs -// So we only enable what we know to work. More archs can be added later, like Mac -# if defined(Q_OS_LINUX) && (defined(QT_ARCH_I386) || defined(QT_ARCH_X86_64) || defined(QT_ARCH_IA64)) -# define THRSPECIFIC __thread __attribute__((tls_model("local-dynamic"))) -# endif -#elif defined(Q_CC_SUN) || defined(Q_CC_INTEL) || defined(Q_CC_XLC) -# define THRSPECIFIC __thread -#endif - -#ifndef THRSPECIFIC -# define THRSPECIFIC -#endif const int flagged_locations_count = 2; -static THRSPECIFIC const char* flagged_locations[flagged_locations_count] = {0}; +static const char* flagged_locations[flagged_locations_count] = {0}; const char *qFlagLocation(const char *method) { - static THRSPECIFIC int idx = 0; + static int idx = 0; flagged_locations[idx] = method; idx = (idx+1) % flagged_locations_count; return method; -- cgit v0.12 From 4edf0c16170f0f727536c6eaefca92b40d03f835 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 1 Apr 2009 10:30:43 +0200 Subject: Subject: A couple of minor doc fixes Reviewed-by: Morten Engvoldsen --- doc/src/platform-notes.qdoc | 1 - src/gui/painting/qprinter.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/src/platform-notes.qdoc b/doc/src/platform-notes.qdoc index d5eee27..6532d1e 100644 --- a/doc/src/platform-notes.qdoc +++ b/doc/src/platform-notes.qdoc @@ -493,7 +493,6 @@ \row \row \o aCC series 3 \o \o \o \o \bold{X} \o \bold{X} \row \o aCC series 6 \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} - \row \o MIPSpro 7.4.2m \o{5,1} \e{Unsupported - see the Unsupported Platforms table} \row \o xlC 6 \o \o \o \o \bold{X} \o \bold{X} \row \o \l{Known Issues in %VERSION%}{Intel CC 10 (see note)} \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp index 413f4a1..6c309c7 100644 --- a/src/gui/painting/qprinter.cpp +++ b/src/gui/painting/qprinter.cpp @@ -849,7 +849,7 @@ void QPrinter::setPrinterName(const QString &name) Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostScript printer; otherwise returns false. - To detect other failures check the output of QPainter::begin() or QPainter::nextPage(). + To detect other failures check the output of QPainter::begin() or QPrinter::newPage(). \snippet doc/src/snippets/printing-qprinter/errors.cpp 0 -- cgit v0.12 From 6e6aea73d322165bebc6199b95db915a17f588f6 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Wed, 1 Apr 2009 11:27:53 +0200 Subject: Add a semi-colon. Grr... I know it was there before I committed it. --- src/gui/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index a88617c..5d08c58 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -138,7 +138,7 @@ enum { kHIThemeFrameTextFieldRound = 1000, kHIThemeFrameTextFieldRoundSmall = 1001, kHIThemeFrameTextFieldRoundMini = 1002 -} +}; #endif // Resolve these at run-time, since the functions was moved in Leopard. -- cgit v0.12 From 21b8f37ba1c29450d46abe3d86f6215d42e5f232 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 1 Apr 2009 11:32:41 +0200 Subject: Subject: Mention setProxy() should be called before setHost() in the doc Reviewed-by: Kavindra Devi Palaraja --- src/network/access/qhttp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttp.cpp b/src/network/access/qhttp.cpp index 0141ae2..96ccc91 100644 --- a/src/network/access/qhttp.cpp +++ b/src/network/access/qhttp.cpp @@ -2120,6 +2120,10 @@ int QHttp::setUser(const QString &userName, const QString &password) Web proxy cache server (from \l http://www.squid.org/). For transparent proxying, such as SOCKS5, use QNetworkProxy instead. + \note setProxy() has to be called before setHost() for it to take effect. + If setProxy() is called after setHost(), then it will not apply until after + setHost() is called again. + \sa QFtp::setProxy() */ int QHttp::setProxy(const QString &host, int port, @@ -2139,7 +2143,7 @@ int QHttp::setProxy(const QString &host, int port, is QNetworkProxy::HttpCachingProxy, QHttp will behave like the previous function. - Note: for compatibility with Qt 4.3, if the proxy type is + \note for compatibility with Qt 4.3, if the proxy type is QNetworkProxy::HttpProxy and the request type is unencrypted (that is, ConnectionModeHttp), QHttp will treat the proxy as a caching proxy. -- cgit v0.12 From 665d338817900f3474d41359df39285515921f34 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 26 Mar 2009 16:03:44 +0100 Subject: Subject: added options to CONFIG in qmake Details: added some non documented options for COFIG in the qmake manual Fields Reviewed-by: Geir Vattekar Reviewed-by: Marius Storm-Olsen Task-number: 248432 --- doc/src/qmake-manual.qdoc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/src/qmake-manual.qdoc b/doc/src/qmake-manual.qdoc index 30da8c6..27cfa0b 100644 --- a/doc/src/qmake-manual.qdoc +++ b/doc/src/qmake-manual.qdoc @@ -367,15 +367,20 @@ \row \o debug \o The project is to be built in debug mode. \row \o debug_and_release \o The project is built in \e both debug and release modes. + \row \o debug_and_release_target \o The project is built in \e both debug + and release modes. TARGET is built into \e both the debug and release directories. \row \o build_all \o If \c debug_and_release is specified, the project is built in both debug and release modes by default. + \row \o autogen_precompile_source \o Automatically generates a \c .cpp file that includes + the precompiled header file specified in the .pro file. \row \o ordered \o When using the \c subdirs template, this option specifies that the directories listed should be processed in the order in which they are given. \row \o warn_on \o The compiler should output as many warnings as possible. This is ignored if \c warn_off is specified. \row \o warn_off \o The compiler should output as few warnings as possible. - \endtable + \row \o copy_dir_files \o Enables the install rule to also copy directories, not just files. + \endtable The \c debug_and_release option is special in that it enables \e both debug and release versions of a project to be built. In such a case, the Makefile that -- cgit v0.12 From 914c2c25d0a60bc5c9d14f405a49b08a162c8908 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 27 Mar 2009 14:17:51 +0100 Subject: Subject: Replaced comment with a better one. Details: Replaced the comment for QButton::setDown(bool). It was kind of narrow. Reviewed-by: Geir Vattekar --- doc/src/porting4-removedvirtual.qdocinc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/porting4-removedvirtual.qdocinc b/doc/src/porting4-removedvirtual.qdocinc index 3eedad2..1af4fa6 100644 --- a/doc/src/porting4-removedvirtual.qdocinc +++ b/doc/src/porting4-removedvirtual.qdocinc @@ -22,7 +22,7 @@ \row \o void QButton::drawButtonLabel(QPainter *) \o Use Q3Button instead or reimplement QButton::paintEvent(). \row \o void QButton::setAccel(const QKeySequence &) \o Setter. \row \o void QButton::setAutoRepeat(bool) \o Setter. -\row \o void QButton::setDown(bool) \o Setter. +\row \o void QButton::setDown(bool) \o Use Q3Button instead or reimplement or port to the new QPushButton API. \row \o void QButton::setPixmap(const QPixmap &) \o Setter. \row \o void QButton::setState(ToggleState) \o Setter. \row \o void QButton::setText(const QString &) \o Use the QAbstractButton::setText() setter function. -- cgit v0.12 From 14d9633f576429b29257ed43143abc6de3918e5d Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 30 Mar 2009 13:48:46 +0200 Subject: Adding note to the qFuzzyCompare doc Adding note about how comparing using 0.0 will fail, and an example on how to do it. Reviewed-by: David Boddie Reviewed-by: Geir Vattekar --- doc/src/snippets/code/src_corelib_global_qglobal.cpp | 8 ++++++++ src/corelib/global/qglobal.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/doc/src/snippets/code/src_corelib_global_qglobal.cpp index 72663e9..287181a 100644 --- a/doc/src/snippets/code/src_corelib_global_qglobal.cpp +++ b/doc/src/snippets/code/src_corelib_global_qglobal.cpp @@ -456,3 +456,11 @@ class MyClass : public QObject //! [45] QWidget w = QWidget(); //! [45] + +//! [46] + // Instead of comparing with 0.0 + qFuzzyCompare(0.0,1.0e-200); // This will return false + // Compare adding 1 to both values will fix the problem + qFuzzyCompare(1 + 0.0, 1 + 1.0e-200); // This will return true +//! [46] + diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 68c213e..69d0a53 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2942,7 +2942,12 @@ bool QInternal::callFunction(InternalFunction func, void **args) Compares the floating point value \a p1 and \a p2 and returns \c true if they are considered equal, otherwise \c false. - + + Note that comparing values where either \a p1 or \a p2 is 0.0 will not work. + The solution to this is to compare against values greater than or equal to 1.0 + + \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 46 + The two numbers are compared in a relative way, where the exactness is stronger the smaller the numbers are. */ -- cgit v0.12 From 84741443a8f7971e6b715f15f71f7a1a8ef05353 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 30 Mar 2009 15:10:05 +0200 Subject: Changes: Clearifying docs on qInstallMsgHandler Details: Added comment about QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT on http://doc.trolltech.com/4.5/qtglobal.html#qInstallMsgHandler Review-by: Geir Vattekar --- src/corelib/global/qglobal.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 69d0a53..1645279 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1934,9 +1934,11 @@ QString qt_error_string(int errorCode) The message handler is a function that prints out debug messages, warnings, critical and fatal error messages. The Qt library (debug - version) contains hundreds of warning messages that are printed + mode) contains hundreds of warning messages that are printed when internal errors (usually invalid function arguments) - occur. If you implement your own message handler, you get total + occur. Qt built in release mode also contains such warnings unless + QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT have been set during + compilation. If you implement your own message handler, you get total control of these messages. The default message handler prints the message to the standard -- cgit v0.12 From 9969f5383711454389435370ae71b6f19d3b2255 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Wed, 1 Apr 2009 10:45:59 +0200 Subject: Subject: Added platform spec. note about type convertion Details: Added a note to the description about using POSIX functions for converting between data types such as floats and strings Task-number: 244600 Reviewed-by: Denis Dzyubenko Reviewed-by: Geir Vattekar --- src/corelib/kernel/qcoreapplication.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index b3f9f1a..a23b2dd 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -377,6 +377,14 @@ QString qAppName() QLibrary) can be retrieved with libraryPaths() and manipulated by setLibraryPaths(), addLibraryPath(), and removeLibraryPath(). + On Unix/Linux Qt is configured to use the system local settings by + default. This can cause a conflict when using POSIX functions, for + instance, when converting between data types such as floats and + strings, since the notation may differ between locales. To get + around this problem call the POSIX function setlocale(LC_NUMERIC,"C") + right after initializing QApplication or QCoreApplication to reset + the locale that is used for number formatting to "C"-locale. + \sa QApplication, QAbstractEventDispatcher, QEventLoop, {Semaphores Example}, {Wait Conditions Example} */ -- cgit v0.12 From e58807c2d750f41cbe88d49baa5ab42d0f61f5e7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 31 Mar 2009 15:23:53 +0200 Subject: one more bogus trolltech => qtsoftware rename --- tools/linguist/linguist/phrase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/linguist/phrase.cpp b/tools/linguist/linguist/phrase.cpp index 563c72d..300f6e8 100644 --- a/tools/linguist/linguist/phrase.cpp +++ b/tools/linguist/linguist/phrase.cpp @@ -243,7 +243,7 @@ bool PhraseBook::load(const QString &fileName, bool *langGuessed) // don't click on these! reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), false); reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true); - reader.setFeature(QLatin1String("http://qtsoftware.com/xml/features/report-whitespace" + reader.setFeature(QLatin1String("http://trolltech.com/xml/features/report-whitespace" "-only-CharData"), false); QphHandler *hand = new QphHandler(this); reader.setContentHandler(hand); -- cgit v0.12 From a5386aa328260157368877b44f2d8d40871f02cf Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 31 Mar 2009 16:11:54 +0200 Subject: do not crash upon dnd-ing text into non-focused lineedit Task-number: 249519 --- tools/linguist/linguist/messageeditor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/linguist/linguist/messageeditor.cpp b/tools/linguist/linguist/messageeditor.cpp index 16908bf..dc8b8e4 100644 --- a/tools/linguist/linguist/messageeditor.cpp +++ b/tools/linguist/linguist/messageeditor.cpp @@ -786,6 +786,7 @@ void MessageEditor::selectAll() void MessageEditor::emitTranslationChanged() { + static_cast(sender())->getEditor()->setFocus(); // DND proofness updateBeginFromSource(); updateUndoRedo(); emit translationChanged(translations(m_currentModel)); @@ -793,6 +794,7 @@ void MessageEditor::emitTranslationChanged() void MessageEditor::emitTranslatorCommentChanged() { + static_cast(sender())->getEditor()->setFocus(); // DND proofness updateUndoRedo(); emit translatorCommentChanged(m_editors[m_currentModel].transCommentText->getTranslation()); } -- cgit v0.12 From eeb83668baf0f396f60882976437299746372217 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 31 Mar 2009 16:50:43 +0200 Subject: normalize file names makes tool tips less ugly Task-number: 246114 --- tools/linguist/linguist/formpreviewview.cpp | 2 +- tools/linguist/linguist/mainwindow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/linguist/linguist/formpreviewview.cpp b/tools/linguist/linguist/formpreviewview.cpp index 990414b..184f01b 100644 --- a/tools/linguist/linguist/formpreviewview.cpp +++ b/tools/linguist/linguist/formpreviewview.cpp @@ -473,7 +473,7 @@ void FormPreviewView::setSourceContext(int model, MessageItem *messageItem) } QDir dir = QFileInfo(m_dataModel->srcFileName(model)).dir(); - QString fileName = dir.absoluteFilePath(messageItem->fileName()); + QString fileName = QDir::cleanPath(dir.absoluteFilePath(messageItem->fileName())); if (m_lastFormName != fileName) { delete m_form; m_form = 0; diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index 6ee0dd8..84200d4 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -1535,7 +1535,7 @@ void MainWindow::selectedMessageChanged(const QModelIndex &sortedIndex, const QM } else { m_sourceAndFormView->setCurrentWidget(m_sourceCodeView); QDir dir = QFileInfo(m_dataModel->srcFileName(model)).dir(); - QString fileName = dir.absoluteFilePath(m->fileName()); + QString fileName = QDir::cleanPath(dir.absoluteFilePath(m->fileName())); m_sourceCodeView->setSourceContext(fileName, m->lineNumber()); } m_errorsView->setEnabled(true); -- cgit v0.12 From 5ec8a27470d4004a60a2d9fc6bd757bbebae1fd7 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 1 Apr 2009 12:21:50 +0200 Subject: QComboBox with Qt::NoFocus triggers a crash. The showPopup() from a combobox triggers a crash. This happens only for a combobox which dosen't accept focus and it has been recreated. This is due to some invalid widget pointer stored in the input context. Task-number: 249576 Reviewed-by: ddenis --- src/gui/kernel/qapplication.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index c4224ed..09f0f91 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2055,9 +2055,13 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) QWidget *prev = focus_widget; focus_widget = focus; - if (prev && reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason && - prev->testAttribute(Qt::WA_InputMethodEnabled)) { - QInputContext *qic = prev->inputContext(); + if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason + && prev->testAttribute(Qt::WA_InputMethodEnabled)) + // Do reset the input context, in case the new focus widget won't accept keyboard input + // or it is not created fully yet. + || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled) + || !focus_widget->testAttribute(Qt::WA_WState_Created))))) { + QInputContext *qic = prev->inputContext(); if(qic) { qic->reset(); qic->setFocusWidget(0); -- cgit v0.12 From 7ff89f9ee6d7c11a42300299cb699185dc020379 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 1 Apr 2009 11:21:45 +0200 Subject: QNetworkInterface: fix listing of all interfaces Before, we returned 0 for many interfaces because we picked up the IPv6 address regardless whether it was 0 or not. Reviewed-by: Prasanth Ullattil Task-number: 249312 --- src/network/kernel/qnetworkinterface_win.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index 9540c18..de97629 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -173,14 +173,14 @@ static QList interfaceListingWinXP() interfaces << iface; iface->index = 0; - if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex)) + if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex) && ptr->Ipv6IfIndex != 0) iface->index = ptr->Ipv6IfIndex; else if (ptr->IfIndex != 0) iface->index = ptr->IfIndex; iface->flags = QNetworkInterface::CanBroadcast; - if (ptr->OperStatus == IfOperStatusUp) - iface->flags |= QNetworkInterface::IsUp | QNetworkInterface::IsRunning; + if (ptr->OperStatus == IfOperStatusUp) + iface->flags |= QNetworkInterface::IsUp | QNetworkInterface::IsRunning; if ((ptr->Flags & IP_ADAPTER_NO_MULTICAST) == 0) iface->flags |= QNetworkInterface::CanMulticast; -- cgit v0.12 From 69e20859bc54b1bfd9ec1a71e034d597ab466a03 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 1 Apr 2009 13:04:44 +0200 Subject: QThread::start(): priority has no effect on Linux systems The default scheduling policy on Linux doesn't allow specifying thread priorities, so the priority passed to start() and setPriority() has no effect. Document this. Task number: 249997 Reviewed-by: Kavindra Devi Palaraja --- src/corelib/thread/qthread.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 7f87897..2fb6335 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -297,6 +297,12 @@ void QAdoptedThread::run() priority parameter. If the thread is already running, this function does nothing. + The effect of the \a priority parameter is dependent on the + operating system's scheduling policy. In particular, the \a priority + will be ignored on systems that do not support thread priorities + (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler + for more details). + \sa run(), terminate() */ @@ -590,6 +596,12 @@ void QThread::cleanup() The \a priority argument can be any value in the \c QThread::Priority enum except for \c InheritPriorty. + The effect of the \a priority parameter is dependent on the + operating system's scheduling policy. In particular, the \a priority + will be ignored on systems that do not support thread priorities + (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler + for more details). + \sa Priority priority() start() */ -- cgit v0.12 From 8006e8bcb427a3949b6b4eec80b65bb58b5fdb8a Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 1 Apr 2009 13:24:19 +0200 Subject: QTextStream autotest: do not test against "imap.troll.no" ... but test against the test server. Reviewed-by: ogoffart --- tests/auto/qtextstream/tst_qtextstream.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index a60433a..5a6cce8 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -60,6 +60,8 @@ #include #include +#include "../network-settings.h" + static const char *TestFileName = "testfile"; Q_DECLARE_METATYPE(qlonglong) @@ -1229,7 +1231,7 @@ void tst_QTextStream::stillOpenWhenAtEnd() QSKIP("Qt/CE: Cannot test network on emulator", SkipAll); #endif QTcpSocket socket; - socket.connectToHost("imap.troll.no", 143); + socket.connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket.waitForReadyRead(5000)); QTextStream stream2(&socket); -- cgit v0.12 From 363636a3aa8abce0344388c0357a237e0d23baa3 Mon Sep 17 00:00:00 2001 From: kh Date: Wed, 1 Apr 2009 13:34:48 +0200 Subject: strip fragment and other parts from url in case of pdf Task-number: part of 238496 Reviewed-by: hjk --- tools/assistant/tools/assistant/helpviewer.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 9817f23..6b049e8 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -201,10 +201,14 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, { const QUrl &url = request.url(); if (isLocalUrl(url)) { - if (url.path().endsWith(QLatin1String("pdf"))) { - QString fileName = url.toString(); - fileName = QDir::tempPath() + QDir::separator() + fileName.right - (fileName.length() - fileName.lastIndexOf(QChar('/'))); + const QString& path = url.path(); + if (path.endsWith(QLatin1String(".pdf"))) { + const int lastDash = path.lastIndexOf(QChar('/')); + QString fileName = QDir::tempPath() + QDir::separator(); + if (lastDash < 0) + fileName += path; + else + fileName += path.mid(lastDash + 1, path.length()); QFile tmpFile(QDir::cleanPath(fileName)); if (tmpFile.open(QIODevice::ReadWrite)) { @@ -396,15 +400,19 @@ void HelpViewer::zoomOut(int range) bool HelpViewer::launchedWithExternalApp(const QUrl &url) { - bool isPdf = url.path().endsWith(QLatin1String("pdf")); + bool isPdf = url.path().endsWith(QLatin1String(".pdf")); if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("ftp") || url.scheme() == QLatin1String("mailto") || isPdf) { bool launched = false; if (isPdf && url.scheme() == QLatin1String("qthelp")) { - QString fileName = url.toString(); - fileName = QDir::tempPath() + QDir::separator() + fileName.right - (fileName.length() - fileName.lastIndexOf(QLatin1Char('/'))); + const QString& path = url.path(); + const int lastDash = path.lastIndexOf(QChar('/')); + QString fileName = QDir::tempPath() + QDir::separator(); + if (lastDash < 0) + fileName += path; + else + fileName += path.mid(lastDash + 1, path.length()); QFile tmpFile(QDir::cleanPath(fileName)); if (tmpFile.open(QIODevice::ReadWrite)) { -- cgit v0.12 From f6830ef93552005b5dc9fee2d9649f9915842615 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 1 Apr 2009 15:06:01 +0200 Subject: Subject: Fix typo in CompositionMode section Reviewed-by: TrustMe --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index e2d9b32..fe6cc69 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1293,7 +1293,7 @@ void QPainterPrivate::updateState(QPainterState *newState) destination. Note that composition transformation operates pixelwise. For that - reason, there is a difference between using the grahic primitive + reason, there is a difference between using the graphic primitive itself and its bounding rectangle: The bounding rect contains pixels with alpha == 0 (i.e the pixels surrounding the primitive). These pixels will overwrite the other image's pixels, -- cgit v0.12 From b224b6006e823435297c2f0b82c835f5987f9b10 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 31 Mar 2009 13:40:34 +0200 Subject: Input Method cannot be enabled in License Wizard and Class Wizard Input methods didn't work properly wor widgets inside QWizardPage because the widget got focus before it was shown and input context wasn't initialized properly. The fix is to postpone qinputcontext->setFocusWidget call until the widget is created (input context will be initialized in the QWidget::create_sys function). Task-number: 244604 Reviewed-by: Prasanth Ullattil --- src/gui/inputmethod/qximinputcontext_x11.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp index 1c8560f..c320fb4 100644 --- a/src/gui/inputmethod/qximinputcontext_x11.cpp +++ b/src/gui/inputmethod/qximinputcontext_x11.cpp @@ -437,7 +437,8 @@ void QXIMInputContext::create_xim() // reinitialize input context after the input method // server (like SCIM) has been launched without // requiring the user to manually switch focus. - if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) + if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled) + && focusWidget->testAttribute(Qt::WA_WState_Created)) setFocusWidget(focusWidget); } // following code fragment is not required for immodule -- cgit v0.12 From ebd82c4fb5d7e9b417baca199b6f9e6893318536 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 1 Apr 2009 11:04:29 +0200 Subject: Removed obsolete internal function that focuses input context. Reviewed-by: TrustMe --- src/gui/kernel/qwidget.cpp | 22 ---------------------- src/gui/kernel/qwidget_p.h | 2 -- src/gui/kernel/qwidget_x11.cpp | 1 - 3 files changed, 25 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 09162ee..fd3d304 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -235,28 +235,6 @@ QWindowSurface *QWidgetPrivate::createDefaultWindowSurface() /*! \internal - This is an internal function, you should never call this. - - This function is called to focus associated input context. The - code intends to eliminate duplicate focus for the context even if - the context is shared between widgets - - \sa QInputContext::setFocus() - */ -void QWidgetPrivate::focusInputContext() -{ -#ifndef QT_NO_IM - Q_Q(QWidget); - QInputContext *qic = q->inputContext(); - if (qic) { - if(qic->focusWidget() != q) - qic->setFocusWidget(q); - } -#endif // QT_NO_IM -} - -/*! - \internal */ void QWidgetPrivate::scrollChildren(int dx, int dy) { diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index f254c4a..9e93f66 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -354,8 +354,6 @@ public: void setWindowIcon_sys(bool forceReset = false); void setWindowOpacity_sys(qreal opacity); - void focusInputContext(); - void adjustQuitOnCloseAttribute(); #if defined(Q_WS_X11) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index a12b50c..e71bc2f 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1516,7 +1516,6 @@ void QWidget::activateWindow() X11->userTime = X11->time; qt_net_update_user_time(tlw, X11->userTime); XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); - d->focusInputContext(); } } -- cgit v0.12 From aaf765dfb797da6b72807fad61fd2a1d19187c0c Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 1 Apr 2009 11:19:26 +0200 Subject: Marked QWidget::resetInputContext() function as obsolete. Fixed the behavior of the function that was broken by me some time ago. But anyway this function is for convenience only since QInputContext that operates on the widget is available to the user directly. Reviewed-by: Prasanth Ullattil --- src/gui/kernel/qwidget.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index fd3d304..f92d660 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -308,20 +308,24 @@ void QWidget::setInputContext(QInputContext *context) /*! + \obsolete + This function can be called on the widget that currently has focus to reset the input method operating on it. - \sa QInputContext, QInputContext::reset() + This function is providing for convenience, instead you should use + \l{QInputContext::}{reset()} on the input context that was + returned by inputContext(). + + \sa QInputContext, inputContext(), QInputContext::reset() */ void QWidget::resetInputContext() { if (!hasFocus()) return; #ifndef QT_NO_IM - if (!d_func()->ic) - return; QInputContext *qic = this->inputContext(); - if( qic ) + if(qic) qic->reset(); #endif // QT_NO_IM } -- cgit v0.12 From f3dbe7d3ebac51b32cf7cc227032fa87a087c682 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 1 Apr 2009 10:18:06 +0200 Subject: Improved IME handling on Windows. QWizard sets focus on a widget when switching to a page before the widget becomes visible, which caused problems with our ime handling which didn't enable ime correctly. The fix is to refactor the code to enable ime handling whenever someone tells input context to set focus by calling QInputContext::setFocusWidget instead of relying on FocusIn/Out events and duplicating updateImeStatus calls all over Qt.. Task-number: 244604 Reviewed-by: Prasanth Ullattil --- src/gui/inputmethod/qinputcontext_p.h | 4 ---- src/gui/inputmethod/qwininputcontext_p.h | 1 + src/gui/inputmethod/qwininputcontext_win.cpp | 11 ++++++++++- src/gui/inputmethod/qwsinputcontext_p.h | 1 + src/gui/inputmethod/qwsinputcontext_qws.cpp | 11 +++++++++-- src/gui/kernel/qwidget.cpp | 14 -------------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/gui/inputmethod/qinputcontext_p.h b/src/gui/inputmethod/qinputcontext_p.h index 8c1b8de..a5e3d91 100644 --- a/src/gui/inputmethod/qinputcontext_p.h +++ b/src/gui/inputmethod/qinputcontext_p.h @@ -84,10 +84,6 @@ public: {} QWidget *focusWidget; - -#if defined(Q_WS_WIN) || defined(Q_WS_QWS) - static void updateImeStatus(QWidget *w, bool hasFocus); -#endif }; QT_END_NAMESPACE diff --git a/src/gui/inputmethod/qwininputcontext_p.h b/src/gui/inputmethod/qwininputcontext_p.h index 38d7e32..c6ad19e 100644 --- a/src/gui/inputmethod/qwininputcontext_p.h +++ b/src/gui/inputmethod/qwininputcontext_p.h @@ -83,6 +83,7 @@ public: static void TranslateMessage(const MSG *msg); static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + static void updateImeStatus(QWidget *w, bool hasFocus); static void enablePopupChild(QWidget *w, bool e); static void enable(QWidget *w, bool e); diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp index 720f0b8..663184f 100644 --- a/src/gui/inputmethod/qwininputcontext_win.cpp +++ b/src/gui/inputmethod/qwininputcontext_win.cpp @@ -753,7 +753,7 @@ inline void enableIme(QWidget *w, bool value) } -void QInputContextPrivate::updateImeStatus(QWidget *w, bool hasFocus) +void QWinInputContext::updateImeStatus(QWidget *w, bool hasFocus) { if (!w) return; @@ -822,6 +822,15 @@ void QWinInputContext::enable(QWidget *w, bool e) void QWinInputContext::setFocusWidget(QWidget *w) { + QWidget *oldFocus = focusWidget(); + if (oldFocus == w) + return; + if (w) { + QWinInputContext::updateImeStatus(w, true); + } else { + if (oldFocus) + QWinInputContext::updateImeStatus(oldFocus , false); + } QInputContext::setFocusWidget(w); update(); } diff --git a/src/gui/inputmethod/qwsinputcontext_p.h b/src/gui/inputmethod/qwsinputcontext_p.h index 20811da..835cb3f 100644 --- a/src/gui/inputmethod/qwsinputcontext_p.h +++ b/src/gui/inputmethod/qwsinputcontext_p.h @@ -87,6 +87,7 @@ public: static bool translateIMEvent(QWidget *w, const QWSIMEvent *e); static bool translateIMQueryEvent(QWidget *w, const QWSIMQueryEvent *e); static bool translateIMInitEvent(const QWSIMInitEvent *e); + static void updateImeStatus(QWidget *w, bool hasFocus); }; QT_END_NAMESPACE diff --git a/src/gui/inputmethod/qwsinputcontext_qws.cpp b/src/gui/inputmethod/qwsinputcontext_qws.cpp index 46ac13d..6180c48 100644 --- a/src/gui/inputmethod/qwsinputcontext_qws.cpp +++ b/src/gui/inputmethod/qwsinputcontext_qws.cpp @@ -73,10 +73,17 @@ void QWSInputContext::reset() void QWSInputContext::setFocusWidget( QWidget *w ) { - QWidget *oldFocus = focusWidget(); + QWidget *oldFocus = focusWidget(); if (oldFocus == w) return; + if (w) { + QWSInputContext::updateImeStatus(w, true); + } else { + if (oldFocus) + QWSInputContext::updateImeStatus(oldFocus, false); + } + if (oldFocus) { QWidget *tlw = oldFocus->window(); int winid = tlw->internalWinId(); @@ -224,7 +231,7 @@ bool QWSInputContext::translateIMEvent(QWidget *w, const QWSIMEvent *e) Q_GUI_EXPORT void (*qt_qws_inputMethodStatusChanged)(QWidget*) = 0; -void QInputContextPrivate::updateImeStatus(QWidget *w, bool hasFocus) +void QWSInputContext::updateImeStatus(QWidget *w, bool hasFocus) { Q_UNUSED(hasFocus); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ce14c82..eb51024 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2967,10 +2967,6 @@ void QWidgetPrivate::setEnabled_helper(bool enable) #if defined(Q_WS_MAC) setEnabled_helper_sys(enable); #endif -#if defined (Q_WS_WIN) - if (q->hasFocus()) - QInputContextPrivate::updateImeStatus(q, true); -#endif QEvent e(QEvent::EnabledChange); QApplication::sendEvent(q, &e); #ifdef QT3_SUPPORT @@ -7644,16 +7640,10 @@ bool QWidget::event(QEvent *event) } break; case QEvent::FocusIn: -#if defined(Q_WS_WIN) - QInputContextPrivate::updateImeStatus(this, true); -#endif focusInEvent((QFocusEvent*)event); break; case QEvent::FocusOut: -#if defined(Q_WS_WIN) - QInputContextPrivate::updateImeStatus(this, false); -#endif focusOutEvent((QFocusEvent*)event); break; @@ -9849,10 +9839,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) #endif break; case Qt::WA_InputMethodEnabled: { -#if defined(Q_WS_WIN) || (defined(Q_WS_QWS) && !defined(QT_NO_QWS_INPUTMETHODS)) - if (hasFocus()) - QInputContextPrivate::updateImeStatus(this, true); -#endif QInputContext *ic = d->ic; if (!ic) { // implicitly create input context only if we have a focus -- cgit v0.12 From 3ab68cbf5436e3e66d0297b01af661bedecb8766 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 1 Apr 2009 11:01:08 +0200 Subject: Give input context focus only when widget is enabled. When disabling a widget that accepts keyboard input we disable input context by calling QInputContext::setFocusWidget(0). Reviewed-by: Prasanth Ullattil --- src/gui/inputmethod/qximinputcontext_x11.cpp | 4 +++- src/gui/kernel/qapplication.cpp | 5 +++-- src/gui/kernel/qwidget.cpp | 13 +++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp index 1c8560f..b43a134 100644 --- a/src/gui/inputmethod/qximinputcontext_x11.cpp +++ b/src/gui/inputmethod/qximinputcontext_x11.cpp @@ -437,7 +437,9 @@ void QXIMInputContext::create_xim() // reinitialize input context after the input method // server (like SCIM) has been launched without // requiring the user to manually switch focus. - if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) + if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled) + && focusWidget->testAttribute(Qt::WA_WState_Created) + && focusWidget->isEnabled()) setFocusWidget(focusWidget); } // following code fragment is not required for immodule diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index c4224ed..8ede230 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2086,8 +2086,9 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) if(focus && QApplicationPrivate::focus_widget == focus) { if (focus->testAttribute(Qt::WA_InputMethodEnabled)) { QInputContext *qic = focus->inputContext(); - if (qic && focus_widget->testAttribute(Qt::WA_WState_Created)) - qic->setFocusWidget( focus_widget ); + if (qic && focus->testAttribute(Qt::WA_WState_Created) + && focus->isEnabled()) + qic->setFocusWidget(focus); } QFocusEvent in(QEvent::FocusIn, reason); QPointer that = focus; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index eb51024..61b4543 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2967,6 +2967,15 @@ void QWidgetPrivate::setEnabled_helper(bool enable) #if defined(Q_WS_MAC) setEnabled_helper_sys(enable); #endif + if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) { + QInputContext *qic = inputContext(); + if (enable) { + qic->setFocusWidget(q); + } else { + qic->reset(); + qic->setFocusWidget(0); + } + } QEvent e(QEvent::EnabledChange); QApplication::sendEvent(q, &e); #ifdef QT3_SUPPORT @@ -9808,7 +9817,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) parentWidget()->d_func()->enforceNativeChildren(); if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) d->createWinId(); - if (ic) + if (ic && isEnabled()) ic->setFocusWidget(this); break; } @@ -9846,7 +9855,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) ic = d->inputContext(); } if (ic) { - if (on && hasFocus() && ic->focusWidget() != this) { + if (on && hasFocus() && ic->focusWidget() != this && isEnabled()) { ic->setFocusWidget(this); } else if (!on && ic->focusWidget() == this) { ic->reset(); -- cgit v0.12 From 3879372da9164d7bc6c00b4a00f2dfc03ce7e33e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 9 Dec 2008 21:20:03 +0100 Subject: Use templates to remove code duplication in qdrawhelper. Reviewed-by: Samuel --- src/gui/painting/qdrawhelper.cpp | 427 +++++++++++++-------------------------- 1 file changed, 141 insertions(+), 286 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index efdc778..484d87f 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -425,10 +425,8 @@ static const DestStoreProc destStoreProc[QImage::NImageFormats] = We need 5 fetch methods per surface type: untransformed - transformed - transformed tiled - transformed bilinear - transformed bilinear tiled + transformed (tiled and not tiled) + transformed bilinear (tiled and not tiled) We don't need bounds checks for untransformed, but we need them for the other ones. @@ -671,7 +669,9 @@ qt_fetchUntransformed(uint *, const Operato return ((const uint *)scanLine) + x; } -static const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data, +template /* either BlendTransformed or BlendTransformedTiled */ +Q_STATIC_TEMPLATE_FUNCTION +const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { FetchPixelProc fetch = fetchPixelProc[data->texture.format]; @@ -698,84 +698,23 @@ static const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, int px = fx >> 16; int py = fy >> 16; - bool out = (px < 0) || (px >= image_width) - || (py < 0) || (py >= image_height); + if (blendType == BlendTransformedTiled) { + px %= image_width; + py %= image_height; + if (px < 0) px += image_width; + if (py < 0) py += image_height; - const uchar *scanLine = data->texture.scanLine(py); - *b = out ? uint(0) : fetch(scanLine, px, data->texture.colorTable); - fx += fdx; - fy += fdy; - ++b; - } - } else { - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - qreal fx = data->m21 * cy + data->m11 * cx + data->dx; - qreal fy = data->m22 * cy + data->m12 * cx + data->dy; - qreal fw = data->m23 * cy + data->m13 * cx + data->m33; - - while (b < end) { - const qreal iw = fw == 0 ? 1 : 1 / fw; - const qreal tx = fx * iw; - const qreal ty = fy * iw; - const int px = int(tx) - (tx < 0); - const int py = int(ty) - (ty < 0); - - bool out = (px < 0) || (px >= image_width) - || (py < 0) || (py >= image_height); - - const uchar *scanLine = data->texture.scanLine(py); - *b = out ? uint(0) : fetch(scanLine, px, data->texture.colorTable); - fx += fdx; - fy += fdy; - fw += fdw; - //force increment to avoid /0 - if (!fw) { - fw += fdw; + const uchar *scanLine = data->texture.scanLine(py); + *b = fetch(scanLine, px, data->texture.colorTable); + } else { + if ((px < 0) || (px >= image_width) + || (py < 0) || (py >= image_height)) { + *b = uint(0); + } else { + const uchar *scanLine = data->texture.scanLine(py); + *b = fetch(scanLine, px, data->texture.colorTable); + } } - ++b; - } - } - - return buffer; -} - -static const uint * QT_FASTCALL fetchTransformedTiled(uint *buffer, const Operator *, const QSpanData *data, - int y, int x, int length) -{ - FetchPixelProc fetch = fetchPixelProc[data->texture.format]; - - int image_width = data->texture.width; - int image_height = data->texture.height; - - const qreal cx = x + 0.5; - const qreal cy = y + 0.5; - - const uint *end = buffer + length; - uint *b = buffer; - if (data->fast_matrix) { - // The increment pr x in the scanline - int fdx = (int)(data->m11 * fixed_scale); - int fdy = (int)(data->m12 * fixed_scale); - - int fx = int((data->m21 * cy - + data->m11 * cx + data->dx) * fixed_scale); - int fy = int((data->m22 * cy - + data->m12 * cx + data->dy) * fixed_scale); - - while (b < end) { - int px = fx >> 16; - int py = fy >> 16; - - px %= image_width; - py %= image_height; - if (px < 0) px += image_width; - if (py < 0) py += image_height; - - const uchar *scanLine = data->texture.scanLine(py); - *b = fetch(scanLine, px, data->texture.colorTable); fx += fdx; fy += fdy; ++b; @@ -796,13 +735,23 @@ static const uint * QT_FASTCALL fetchTransformedTiled(uint *buffer, const Operat int px = int(tx) - (tx < 0); int py = int(ty) - (ty < 0); - px %= image_width; - py %= image_height; - if (px < 0) px += image_width; - if (py < 0) py += image_height; + if (blendType == BlendTransformedTiled) { + px %= image_width; + py %= image_height; + if (px < 0) px += image_width; + if (py < 0) py += image_height; - const uchar *scanLine = data->texture.scanLine(py); - *b = fetch(scanLine, px, data->texture.colorTable); + const uchar *scanLine = data->texture.scanLine(py); + *b = fetch(scanLine, px, data->texture.colorTable); + } else { + if ((px < 0) || (px >= image_width) + || (py < 0) || (py >= image_height)) { + *b = uint(0); + } else { + const uchar *scanLine = data->texture.scanLine(py); + *b = fetch(scanLine, px, data->texture.colorTable); + } + } fx += fdx; fy += fdy; fw += fdw; @@ -817,8 +766,10 @@ static const uint * QT_FASTCALL fetchTransformedTiled(uint *buffer, const Operat return buffer; } -static const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data, - int y, int x, int length) +template /* BlendTransformedBilinear or BlendTransformedBilinearTiled */ +Q_STATIC_TEMPLATE_FUNCTION +const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length) { FetchPixelProc fetch = fetchPixelProc[data->texture.format]; @@ -853,130 +804,27 @@ static const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Ope int idistx = 256 - distx; int idisty = 256 - disty; - x1 = qBound(0, x1, image_width - 1); - x2 = qBound(0, x2, image_width - 1); - y1 = qBound(0, y1, image_height - 1); - y2 = qBound(0, y2, image_height - 1); - - const uchar *s1 = data->texture.scanLine(y1); - const uchar *s2 = data->texture.scanLine(y2); - - uint tl = fetch(s1, x1, data->texture.colorTable); - uint tr = fetch(s1, x2, data->texture.colorTable); - uint bl = fetch(s2, x1, data->texture.colorTable); - uint br = fetch(s2, x2, data->texture.colorTable); - - uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); - uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); - *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); - - fx += fdx; - fy += fdy; - ++b; - } - } else { - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - qreal fx = data->m21 * cy + data->m11 * cx + data->dx; - qreal fy = data->m22 * cy + data->m12 * cx + data->dy; - qreal fw = data->m23 * cy + data->m13 * cx + data->m33; - - while (b < end) { - const qreal iw = fw == 0 ? 1 : 1 / fw; - const qreal px = fx * iw - 0.5; - const qreal py = fy * iw - 0.5; - - int x1 = int(px) - (px < 0); - int x2 = x1 + 1; - int y1 = int(py) - (py < 0); - int y2 = y1 + 1; - - int distx = int((px - x1) * 256); - int disty = int((py - y1) * 256); - int idistx = 256 - distx; - int idisty = 256 - disty; - - x1 = qBound(0, x1, image_width - 1); - x2 = qBound(0, x2, image_width - 1); - y1 = qBound(0, y1, image_height - 1); - y2 = qBound(0, y2, image_height - 1); - - const uchar *s1 = data->texture.scanLine(y1); - const uchar *s2 = data->texture.scanLine(y2); - - uint tl = fetch(s1, x1, data->texture.colorTable); - uint tr = fetch(s1, x2, data->texture.colorTable); - uint bl = fetch(s2, x1, data->texture.colorTable); - uint br = fetch(s2, x2, data->texture.colorTable); - - uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); - uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); - *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); - - fx += fdx; - fy += fdy; - fw += fdw; - //force increment to avoid /0 - if (!fw) { - fw += fdw; + if (blendType == BlendTransformedBilinearTiled) { + x1 %= image_width; + x2 %= image_width; + y1 %= image_height; + y2 %= image_height; + + if (x1 < 0) x1 += image_width; + if (x2 < 0) x2 += image_width; + if (y1 < 0) y1 += image_height; + if (y2 < 0) y2 += image_height; + + Q_ASSERT(x1 >= 0 && x1 < image_width); + Q_ASSERT(x2 >= 0 && x2 < image_width); + Q_ASSERT(y1 >= 0 && y1 < image_height); + Q_ASSERT(y2 >= 0 && y2 < image_height); + } else { + x1 = qBound(0, x1, image_width - 1); + x2 = qBound(0, x2, image_width - 1); + y1 = qBound(0, y1, image_height - 1); + y2 = qBound(0, y2, image_height - 1); } - ++b; - } - } - - return buffer; -} - -static const uint * QT_FASTCALL fetchTransformedBilinearTiled(uint *buffer, const Operator *, const QSpanData *data, - int y, int x, int length) -{ - FetchPixelProc fetch = fetchPixelProc[data->texture.format]; - - int image_width = data->texture.width; - int image_height = data->texture.height; - - const qreal cx = x + 0.5; - const qreal cy = y + 0.5; - - const uint *end = buffer + length; - uint *b = buffer; - if (data->fast_matrix) { - // The increment pr x in the scanline - int fdx = (int)(data->m11 * fixed_scale); - int fdy = (int)(data->m12 * fixed_scale); - - int fx = int((data->m21 * cy + data->m11 * cx + data->dx) * fixed_scale); - int fy = int((data->m22 * cy + data->m12 * cx + data->dy) * fixed_scale); - - fx -= half_point; - fy -= half_point; - while (b < end) { - int x1 = (fx >> 16); - int x2 = x1 + 1; - int y1 = (fy >> 16); - int y2 = y1 + 1; - - int distx = ((fx - (x1 << 16)) >> 8); - int disty = ((fy - (y1 << 16)) >> 8); - int idistx = 256 - distx; - int idisty = 256 - disty; - - x1 %= image_width; - x2 %= image_width; - y1 %= image_height; - y2 %= image_height; - - if (x1 < 0) x1 += image_width; - if (x2 < 0) x2 += image_width; - if (y1 < 0) y1 += image_height; - if (y2 < 0) y2 += image_height; - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); @@ -1018,20 +866,27 @@ static const uint * QT_FASTCALL fetchTransformedBilinearTiled(uint *buffer, cons int idistx = 256 - distx; int idisty = 256 - disty; - x1 %= image_width; - x2 %= image_width; - y1 %= image_height; - y2 %= image_height; - - if (x1 < 0) x1 += image_width; - if (x2 < 0) x2 += image_width; - if (y1 < 0) y1 += image_height; - if (y2 < 0) y2 += image_height; - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); + if (blendType == BlendTransformedBilinearTiled) { + x1 %= image_width; + x2 %= image_width; + y1 %= image_height; + y2 %= image_height; + + if (x1 < 0) x1 += image_width; + if (x2 < 0) x2 += image_width; + if (y1 < 0) y1 += image_height; + if (y2 < 0) y2 += image_height; + + Q_ASSERT(x1 >= 0 && x1 < image_width); + Q_ASSERT(x2 >= 0 && x2 < image_width); + Q_ASSERT(y1 >= 0 && y1 < image_height); + Q_ASSERT(y2 >= 0 && y2 < image_height); + } else { + x1 = qBound(0, x1, image_width - 1); + x2 = qBound(0, x2, image_width - 1); + y1 = qBound(0, y1, image_height - 1); + y2 = qBound(0, y2, image_height - 1); + } const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); @@ -1135,75 +990,75 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { // Transformed { 0, // Invalid - fetchTransformed, // Mono - fetchTransformed, // MonoLsb - fetchTransformed, // Indexed8 - fetchTransformed, // RGB32 - fetchTransformed, // ARGB32 - fetchTransformed, // ARGB32_Premultiplied - fetchTransformed, // RGB16 - fetchTransformed, // ARGB8565_Premultiplied - fetchTransformed, // RGB666 - fetchTransformed, // ARGB6666_Premultiplied - fetchTransformed, // RGB555 - fetchTransformed, // ARGB8555_Premultiplied - fetchTransformed, // RGB888 - fetchTransformed, // RGB444 - fetchTransformed, // ARGB4444_Premultiplied + fetchTransformed, // Mono + fetchTransformed, // MonoLsb + fetchTransformed, // Indexed8 + fetchTransformed, // RGB32 + fetchTransformed, // ARGB32 + fetchTransformed, // ARGB32_Premultiplied + fetchTransformed, // RGB16 + fetchTransformed, // ARGB8565_Premultiplied + fetchTransformed, // RGB666 + fetchTransformed, // ARGB6666_Premultiplied + fetchTransformed, // RGB555 + fetchTransformed, // ARGB8555_Premultiplied + fetchTransformed, // RGB888 + fetchTransformed, // RGB444 + fetchTransformed, // ARGB4444_Premultiplied }, { 0, // TransformedTiled - fetchTransformedTiled, // Mono - fetchTransformedTiled, // MonoLsb - fetchTransformedTiled, // Indexed8 - fetchTransformedTiled, // RGB32 - fetchTransformedTiled, // ARGB32 - fetchTransformedTiled, // ARGB32_Premultiplied - fetchTransformedTiled, // RGB16 - fetchTransformedTiled, // ARGB8565_Premultiplied - fetchTransformedTiled, // RGB666 - fetchTransformedTiled, // ARGB6666_Premultiplied - fetchTransformedTiled, // RGB555 - fetchTransformedTiled, // ARGB8555_Premultiplied - fetchTransformedTiled, // RGB888 - fetchTransformedTiled, // RGB444 - fetchTransformedTiled, // ARGB4444_Premultiplied + fetchTransformed, // Mono + fetchTransformed, // MonoLsb + fetchTransformed, // Indexed8 + fetchTransformed, // RGB32 + fetchTransformed, // ARGB32 + fetchTransformed, // ARGB32_Premultiplied + fetchTransformed, // RGB16 + fetchTransformed, // ARGB8565_Premultiplied + fetchTransformed, // RGB666 + fetchTransformed, // ARGB6666_Premultiplied + fetchTransformed, // RGB555 + fetchTransformed, // ARGB8555_Premultiplied + fetchTransformed, // RGB888 + fetchTransformed, // RGB444 + fetchTransformed, // ARGB4444_Premultiplied }, { 0, // Bilinear - fetchTransformedBilinear, // Mono - fetchTransformedBilinear, // MonoLsb - fetchTransformedBilinear, // Indexed8 - fetchTransformedBilinear, // RGB32 - fetchTransformedBilinear, // ARGB32 - fetchTransformedBilinear, // ARGB32_Premultiplied - fetchTransformedBilinear, // RGB16 - fetchTransformedBilinear, // ARGB8565_Premultiplied - fetchTransformedBilinear, // RGB666 - fetchTransformedBilinear, // ARGB6666_Premultiplied - fetchTransformedBilinear, // RGB555 - fetchTransformedBilinear, // ARGB8555_Premultiplied - fetchTransformedBilinear, // RGB888 - fetchTransformedBilinear, // RGB444 - fetchTransformedBilinear // ARGB4444_Premultiplied + fetchTransformedBilinear, // Mono + fetchTransformedBilinear, // MonoLsb + fetchTransformedBilinear, // Indexed8 + fetchTransformedBilinear, // RGB32 + fetchTransformedBilinear, // ARGB32 + fetchTransformedBilinear, // ARGB32_Premultiplied + fetchTransformedBilinear, // RGB16 + fetchTransformedBilinear, // ARGB8565_Premultiplied + fetchTransformedBilinear, // RGB666 + fetchTransformedBilinear, // ARGB6666_Premultiplied + fetchTransformedBilinear, // RGB555 + fetchTransformedBilinear, // ARGB8555_Premultiplied + fetchTransformedBilinear, // RGB888 + fetchTransformedBilinear, // RGB444 + fetchTransformedBilinear // ARGB4444_Premultiplied }, { 0, // BilinearTiled - fetchTransformedBilinearTiled, // Mono - fetchTransformedBilinearTiled, // MonoLsb - fetchTransformedBilinearTiled, // Indexed8 - fetchTransformedBilinearTiled, // RGB32 - fetchTransformedBilinearTiled, // ARGB32 - fetchTransformedBilinearTiled, // ARGB32_Premultiplied - fetchTransformedBilinearTiled, // RGB16 - fetchTransformedBilinearTiled, // ARGB8565_Premultiplied - fetchTransformedBilinearTiled, // RGB666 - fetchTransformedBilinearTiled, // ARGB6666_Premultiplied - fetchTransformedBilinearTiled, // RGB555 - fetchTransformedBilinearTiled, // ARGB8555_Premultiplied - fetchTransformedBilinearTiled, // RGB888 - fetchTransformedBilinearTiled, // RGB444 - fetchTransformedBilinearTiled // ARGB4444_Premultiplied + fetchTransformedBilinear, // Mono + fetchTransformedBilinear, // MonoLsb + fetchTransformedBilinear, // Indexed8 + fetchTransformedBilinear, // RGB32 + fetchTransformedBilinear, // ARGB32 + fetchTransformedBilinear, // ARGB32_Premultiplied + fetchTransformedBilinear, // RGB16 + fetchTransformedBilinear, // ARGB8565_Premultiplied + fetchTransformedBilinear, // RGB666 + fetchTransformedBilinear, // ARGB6666_Premultiplied + fetchTransformedBilinear, // RGB555 + fetchTransformedBilinear, // ARGB8555_Premultiplied + fetchTransformedBilinear, // RGB888 + fetchTransformedBilinear, // RGB444 + fetchTransformedBilinear // ARGB4444_Premultiplied }, }; -- cgit v0.12 From 792dff08e362b050463ecbd976617acb0ed1a105 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 24 Feb 2009 14:25:29 +0100 Subject: Ensure that fetchPixel is inlined in RGB32 cases in fetchTransformedBilinear. Reviewed-by: Samuel --- src/gui/painting/qdrawhelper.cpp | 64 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 484d87f..f8c5475 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -766,12 +766,12 @@ const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const return buffer; } -template /* BlendTransformedBilinear or BlendTransformedBilinearTiled */ +template /* blendType = BlendTransformedBilinear or BlendTransformedBilinearTiled */ Q_STATIC_TEMPLATE_FUNCTION const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { - FetchPixelProc fetch = fetchPixelProc[data->texture.format]; + FetchPixelProc fetch = (format != QImage::Format_Invalid) ? FetchPixelProc(qt_fetchPixel) : fetchPixelProc[data->texture.format]; int image_width = data->texture.width; int image_height = data->texture.height; @@ -1026,39 +1026,39 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { }, { 0, // Bilinear - fetchTransformedBilinear, // Mono - fetchTransformedBilinear, // MonoLsb - fetchTransformedBilinear, // Indexed8 - fetchTransformedBilinear, // RGB32 - fetchTransformedBilinear, // ARGB32 - fetchTransformedBilinear, // ARGB32_Premultiplied - fetchTransformedBilinear, // RGB16 - fetchTransformedBilinear, // ARGB8565_Premultiplied - fetchTransformedBilinear, // RGB666 - fetchTransformedBilinear, // ARGB6666_Premultiplied - fetchTransformedBilinear, // RGB555 - fetchTransformedBilinear, // ARGB8555_Premultiplied - fetchTransformedBilinear, // RGB888 - fetchTransformedBilinear, // RGB444 - fetchTransformedBilinear // ARGB4444_Premultiplied + fetchTransformedBilinear, // Mono + fetchTransformedBilinear, // MonoLsb + fetchTransformedBilinear, // Indexed8 + fetchTransformedBilinear, // RGB32 + fetchTransformedBilinear, // ARGB32 + fetchTransformedBilinear, // ARGB32_Premultiplied + fetchTransformedBilinear, // RGB16 + fetchTransformedBilinear, // ARGB8565_Premultiplied + fetchTransformedBilinear, // RGB666 + fetchTransformedBilinear, // ARGB6666_Premultiplied + fetchTransformedBilinear, // RGB555 + fetchTransformedBilinear, // ARGB8555_Premultiplied + fetchTransformedBilinear, // RGB888 + fetchTransformedBilinear, // RGB444 + fetchTransformedBilinear // ARGB4444_Premultiplied }, { 0, // BilinearTiled - fetchTransformedBilinear, // Mono - fetchTransformedBilinear, // MonoLsb - fetchTransformedBilinear, // Indexed8 - fetchTransformedBilinear, // RGB32 - fetchTransformedBilinear, // ARGB32 - fetchTransformedBilinear, // ARGB32_Premultiplied - fetchTransformedBilinear, // RGB16 - fetchTransformedBilinear, // ARGB8565_Premultiplied - fetchTransformedBilinear, // RGB666 - fetchTransformedBilinear, // ARGB6666_Premultiplied - fetchTransformedBilinear, // RGB555 - fetchTransformedBilinear, // ARGB8555_Premultiplied - fetchTransformedBilinear, // RGB888 - fetchTransformedBilinear, // RGB444 - fetchTransformedBilinear // ARGB4444_Premultiplied + fetchTransformedBilinear, // Mono + fetchTransformedBilinear, // MonoLsb + fetchTransformedBilinear, // Indexed8 + fetchTransformedBilinear, // RGB32 + fetchTransformedBilinear, // ARGB32 + fetchTransformedBilinear, // ARGB32_Premultiplied + fetchTransformedBilinear, // RGB16 + fetchTransformedBilinear, // ARGB8565_Premultiplied + fetchTransformedBilinear, // RGB666 + fetchTransformedBilinear, // ARGB6666_Premultiplied + fetchTransformedBilinear, // RGB555 + fetchTransformedBilinear, // ARGB8555_Premultiplied + fetchTransformedBilinear, // RGB888 + fetchTransformedBilinear, // RGB444 + fetchTransformedBilinear // ARGB4444_Premultiplied }, }; -- cgit v0.12 From 95d2bd114974ec60cff1cdfbd45f18c2c0e85108 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 24 Feb 2009 13:16:42 +0100 Subject: Remove some VC6 Template workaround in the drawhelper code Reviewed-by: Samuel --- src/gui/painting/qdrawhelper.cpp | 448 ++++++++------------------------------- 1 file changed, 91 insertions(+), 357 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index f8c5475..47dbf1b 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -157,46 +157,9 @@ static uint * QT_FASTCALL destFetchRGB16(uint *buffer, QRasterBuffer *rasterBuff return buffer; } -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL) -template -class QEnumToType -{ -public: - inline EnumType operator()() const - { - return EnumType(value); - } -}; -template -class QImageFormatToType -{ -public: - inline QImage::Format operator()() const - { - return format; - } -}; -// Would have used QEnumToType instead of creating a specialized version for QImageFormatToType, -// but that causes internal compiler error on VC6 -#define Q_TEMPLATE_IMAGEFORMAT_FIX(format) , const QImageFormatToType &imageFormatType -#define Q_TEMPLATE_IMAGEFORMAT_CALL(format) , QImageFormatToType() -#define Q_TEMPLATE_ENUM_FIX(Type, Value) , const QEnumToType &enumTemplateType -#define Q_TEMPLATE_ENUM_CALL(Type, Value) , QEnumToType() -#define Q_TEMPLATE_FIX(Type) , const QTypeInfo &templateType -#define Q_TEMPLATE_CALL(Type) , QTypeInfo() -#else -#define Q_TEMPLATE_IMAGEFORMAT_FIX(format) -#define Q_TEMPLATE_IMAGEFORMAT_CALL(format) -#define Q_TEMPLATE_ENUM_FIX(Type, Value) -#define Q_TEMPLATE_ENUM_CALL(Type, Value) -#define Q_TEMPLATE_FIX(Type) -#define Q_TEMPLATE_CALL(Type) -#endif - template Q_STATIC_TEMPLATE_FUNCTION uint * QT_FASTCALL destFetch(uint *buffer, QRasterBuffer *rasterBuffer, - int x, int y, int length - Q_TEMPLATE_FIX(DST)) + int x, int y, int length) { const DST *src = reinterpret_cast(rasterBuffer->scanLine(y)) + x; quint32 *dest = reinterpret_cast(buffer); @@ -205,28 +168,7 @@ Q_STATIC_TEMPLATE_FUNCTION uint * QT_FASTCALL destFetch(uint *buffer, QRasterBuf return buffer; } -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL) -#define DEST_FETCH_DECL(DST) \ - static uint * QT_FASTCALL destFetch_##DST(uint *buffer, \ - QRasterBuffer *rasterBuffer, \ - int x, int y, int length) \ - { \ - return destFetch(buffer, rasterBuffer, x, y, length Q_TEMPLATE_CALL(DST)); \ - } - -DEST_FETCH_DECL(qargb8565) -DEST_FETCH_DECL(qrgb666) -DEST_FETCH_DECL(qargb6666) -DEST_FETCH_DECL(qrgb555) -DEST_FETCH_DECL(qrgb888) -DEST_FETCH_DECL(qargb8555) -DEST_FETCH_DECL(qrgb444) -DEST_FETCH_DECL(qargb4444) -#undef DEST_FETCH_DECL -# define SPANFUNC_POINTER_DESTFETCH(Arg) destFetch_##Arg -#else // !VC6 && !VC2002 # define SPANFUNC_POINTER_DESTFETCH(Arg) destFetch -#endif static const DestFetchProc destFetchProc[QImage::NImageFormats] = { @@ -366,8 +308,7 @@ static void QT_FASTCALL destStoreRGB16(QRasterBuffer *rasterBuffer, int x, int y template Q_STATIC_TEMPLATE_FUNCTION void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, int x, int y, - const uint *buffer, int length - Q_TEMPLATE_FIX(DST)) + const uint *buffer, int length) { DST *dest = reinterpret_cast(rasterBuffer->scanLine(y)) + x; const quint32 *src = reinterpret_cast(buffer); @@ -375,28 +316,7 @@ Q_STATIC_TEMPLATE_FUNCTION void QT_FASTCALL destStore(QRasterBuffer *rasterBuffe *dest++ = DST(*src++); } -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL) -# define DEST_STORE_DECL(DST) \ - static void QT_FASTCALL destStore_##DST(QRasterBuffer *rasterBuffer, \ - int x, int y, \ - const uint *buffer, int length) \ - { \ - destStore(rasterBuffer, x, y, buffer, length Q_TEMPLATE_CALL(DST)); \ - } - -DEST_STORE_DECL(qargb8565) -DEST_STORE_DECL(qrgb555) -DEST_STORE_DECL(qrgb666) -DEST_STORE_DECL(qargb6666) -DEST_STORE_DECL(qargb8555) -DEST_STORE_DECL(qrgb888) -DEST_STORE_DECL(qrgb444) -DEST_STORE_DECL(qargb4444) -# undef DEST_FETCH_DECL -# define SPANFUNC_POINTER_DESTSTORE(DEST) destStore_##DEST -#else // !VC6 && !VC2002 # define SPANFUNC_POINTER_DESTSTORE(DEST) destStore -#endif static const DestStoreProc destStoreProc[QImage::NImageFormats] = { @@ -434,14 +354,12 @@ static const DestStoreProc destStoreProc[QImage::NImageFormats] = */ template -Q_STATIC_TEMPLATE_FUNCTION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, const QVector *rgb - Q_TEMPLATE_IMAGEFORMAT_FIX(format)); +Q_STATIC_TEMPLATE_FUNCTION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, const QVector *rgb); template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, const QVector *rgb - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_Mono)) + int x, const QVector *rgb) { bool pixel = scanLine[x>>3] & (0x80 >> (x & 7)); if (rgb) return PREMUL(rgb->at(pixel ? 1 : 0)); @@ -451,8 +369,7 @@ uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, const QVector *rgb - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_MonoLSB)) + int x, const QVector *rgb) { bool pixel = scanLine[x>>3] & (0x1 << (x & 7)); if (rgb) return PREMUL(rgb->at(pixel ? 1 : 0)); @@ -462,8 +379,7 @@ uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, const QVector *rgb - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_Indexed8)) + int x, const QVector *rgb) { return PREMUL(rgb->at(scanLine[x])); } @@ -471,8 +387,7 @@ uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB32)) + int x, const QVector *) { return PREMUL(((const uint *)scanLine)[x]); } @@ -480,8 +395,7 @@ uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB32_Premultiplied)) + int x, const QVector *) { return ((const uint *)scanLine)[x]; } @@ -489,8 +403,7 @@ uint QT_FASTCALL qt_fetchPixel(const uchar template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB16)) + int x, const QVector *) { return qConvertRgb16To32(((const ushort *)scanLine)[x]); } @@ -499,8 +412,7 @@ template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, - const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB8565_Premultiplied)) + const QVector *) { const qargb8565 color = reinterpret_cast(scanLine)[x]; return qt_colorConvert(color, 0); @@ -510,8 +422,7 @@ template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, - const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB666)) + const QVector *) { const qrgb666 color = reinterpret_cast(scanLine)[x]; return qt_colorConvert(color, 0); @@ -521,8 +432,7 @@ template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, - const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB6666_Premultiplied)) + const QVector *) { const qargb6666 color = reinterpret_cast(scanLine)[x]; return qt_colorConvert(color, 0); @@ -532,8 +442,7 @@ template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, - const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB555)) + const QVector *) { const qrgb555 color = reinterpret_cast(scanLine)[x]; return qt_colorConvert(color, 0); @@ -543,8 +452,7 @@ template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, - const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB8555_Premultiplied)) + const QVector *) { const qargb8555 color = reinterpret_cast(scanLine)[x]; return qt_colorConvert(color, 0); @@ -554,8 +462,7 @@ template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, - const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB888)) + const QVector *) { const qrgb888 color = reinterpret_cast(scanLine)[x]; return qt_colorConvert(color, 0); @@ -565,8 +472,7 @@ template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, - const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_RGB444)) + const QVector *) { const qrgb444 color = reinterpret_cast(scanLine)[x]; return qt_colorConvert(color, 0); @@ -576,8 +482,7 @@ template<> Q_STATIC_TEMPLATE_SPECIALIZATION uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, int x, - const QVector * - Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB4444_Premultiplied)) + const QVector *) { const qargb4444 color = reinterpret_cast(scanLine)[x]; return qt_colorConvert(color, 0); @@ -585,38 +490,7 @@ uint QT_FASTCALL qt_fetchPixel(const ucha typedef uint (QT_FASTCALL *FetchPixelProc)(const uchar *scanLine, int x, const QVector *); -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL) - -// explicit template instantiations needed to compile with VC6 and VC2002 - -#define SPANFUNC_INSTANTIATION_FETCHPIXEL(Arg) \ - static inline uint fetchPixel_##Arg(const uchar * scanLine, int x, const QVector * rgb) \ -{ \ - return qt_fetchPixel(scanLine, x, rgb Q_TEMPLATE_IMAGEFORMAT_CALL(QImage::Arg)); \ -} - -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_Mono); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_MonoLSB); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_Indexed8); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB32_Premultiplied); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB32); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB16); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB8565_Premultiplied); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB666); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB6666_Premultiplied); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB555); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB8555_Premultiplied); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB888); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_RGB444); -SPANFUNC_INSTANTIATION_FETCHPIXEL(Format_ARGB4444_Premultiplied); - -#undef SPANFUNC_INSTANTIATION_FETCHPIXEL - -#define SPANFUNC_POINTER_FETCHPIXEL(Arg) fetchPixel_##Arg - -#else // !VC6 && !VC2002 -# define SPANFUNC_POINTER_FETCHPIXEL(Arg) qt_fetchPixel -#endif +#define SPANFUNC_POINTER_FETCHPIXEL(Arg) qt_fetchPixel static const FetchPixelProc fetchPixelProc[QImage::NImageFormats] = @@ -651,11 +525,11 @@ enum TextureBlendType { template Q_STATIC_TEMPLATE_FUNCTION const uint * QT_FASTCALL qt_fetchUntransformed(uint *buffer, const Operator *, const QSpanData *data, - int y, int x, int length Q_TEMPLATE_IMAGEFORMAT_FIX(format)) + int y, int x, int length) { const uchar *scanLine = data->texture.scanLine(y); for (int i = 0; i < length; ++i) - buffer[i] = qt_fetchPixel(scanLine, x + i, data->texture.colorTable Q_TEMPLATE_IMAGEFORMAT_CALL(format)); + buffer[i] = qt_fetchPixel(scanLine, x + i, data->texture.colorTable); return buffer; } @@ -663,7 +537,7 @@ template <> Q_STATIC_TEMPLATE_SPECIALIZATION const uint * QT_FASTCALL qt_fetchUntransformed(uint *, const Operator *, const QSpanData *data, - int y, int x, int Q_TEMPLATE_IMAGEFORMAT_FIX(QImage::Format_ARGB32_Premultiplied)) + int y, int x, int) { const uchar *scanLine = data->texture.scanLine(y); return ((const uint *)scanLine) + x; @@ -914,39 +788,7 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * return buffer; } -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL) - -// explicit template instantiations needed to compile with VC6 and VC2002 - -#define SPANFUNC_POINTER_FETCHUNTRANSFORMED(Arg) \ - const uint *qt_fetchUntransformed_##Arg(uint *buffer, const Operator *op, const QSpanData *data, \ - int y, int x, int length) \ -{ \ - return qt_fetchUntransformed(buffer, op, data, y, x, length Q_TEMPLATE_IMAGEFORMAT_CALL(QImage::Arg)); \ -} - -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_Mono); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_MonoLSB); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_Indexed8); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB32_Premultiplied); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB32); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB16); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB8565_Premultiplied); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB666); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB6666_Premultiplied); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB555); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB8555_Premultiplied); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB888); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_RGB444); -SPANFUNC_POINTER_FETCHUNTRANSFORMED(Format_ARGB4444_Premultiplied); - -#undef SPANFUNC_POINTER_FETCHUNTRANSFORMED - -#define SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Arg) qt_fetchUntransformed_##Arg - -#else // !VC6 && !VC2002 -# define SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Arg) qt_fetchUntransformed -#endif +#define SPANFUNC_POINTER_FETCHHUNTRANSFORMED(Arg) qt_fetchUntransformed static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { // Untransformed @@ -3075,8 +2917,7 @@ static void blend_color_argb(int count, const QSpan *spans, void *userData) } template -Q_STATIC_TEMPLATE_FUNCTION void blendColor(int count, const QSpan *spans, void *userData - Q_TEMPLATE_FIX(T)) +Q_STATIC_TEMPLATE_FUNCTION void blendColor(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); Operator op = getOperator(data, spans, count); @@ -3122,28 +2963,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendColor(int count, const QSpan *spans, void * blend_color_generic(count, spans, userData); } -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL) -#define BLEND_COLOR_DECL(DST) \ - static void blendColor_##DST(int count, \ - const QSpan *spans, \ - void *userData) \ - { \ - blendColor(count, spans, userData Q_TEMPLATE_CALL(DST)); \ - } - -BLEND_COLOR_DECL(qargb8565) -BLEND_COLOR_DECL(qrgb666) -BLEND_COLOR_DECL(qargb6666) -BLEND_COLOR_DECL(qrgb555) -BLEND_COLOR_DECL(qargb8555) -BLEND_COLOR_DECL(qrgb888) -BLEND_COLOR_DECL(qrgb444) -BLEND_COLOR_DECL(qargb4444) -#undef DEST_FETCH_DECL -#define SPANFUNC_POINTER_BLENDCOLOR(DST) blendColor_##DST -#else // !VC6 && !VC2002 -# define SPANFUNC_POINTER_BLENDCOLOR(DST) blendColor -#endif +#define SPANFUNC_POINTER_BLENDCOLOR(DST) blendColor static void blend_color_rgb16(int count, const QSpan *spans, void *userData) { @@ -3222,8 +3042,7 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData) } template -Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -3258,8 +3077,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, } template -Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -3310,13 +3128,12 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSp } template -Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_argb(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_argb(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { - blend_untransformed_generic(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod)); + blend_untransformed_generic(count, spans, userData); return; } @@ -4562,8 +4379,7 @@ void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userDat if (mode != QPainter::CompositionMode_SourceOver && mode != QPainter::CompositionMode_Source) { - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); return; } @@ -4625,8 +4441,7 @@ static void blend_untransformed_rgb888(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } static void blend_untransformed_argb6666(int count, const QSpan *spans, @@ -4641,8 +4456,7 @@ static void blend_untransformed_argb6666(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } static void blend_untransformed_rgb666(int count, const QSpan *spans, @@ -4657,8 +4471,7 @@ static void blend_untransformed_rgb666(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } static void blend_untransformed_argb8565(int count, const QSpan *spans, @@ -4673,8 +4486,7 @@ static void blend_untransformed_argb8565(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } static void blend_untransformed_rgb565(int count, const QSpan *spans, @@ -4689,8 +4501,7 @@ static void blend_untransformed_rgb565(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } static void blend_untransformed_argb8555(int count, const QSpan *spans, @@ -4705,8 +4516,7 @@ static void blend_untransformed_argb8555(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } static void blend_untransformed_rgb555(int count, const QSpan *spans, @@ -4721,8 +4531,7 @@ static void blend_untransformed_rgb555(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } static void blend_untransformed_argb4444(int count, const QSpan *spans, @@ -4737,8 +4546,7 @@ static void blend_untransformed_argb4444(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } static void blend_untransformed_rgb444(int count, const QSpan *spans, @@ -4753,13 +4561,11 @@ static void blend_untransformed_rgb444(int count, const QSpan *spans, blendUntransformed(count, spans, userData); else #endif - blend_untransformed_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_untransformed_generic(count, spans, userData); } template -Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_generic(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_generic(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -4813,13 +4619,12 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_generic(int count, const QSpan *span } template -Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_argb(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_tiled_argb(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { - blend_tiled_generic(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod)); + blend_tiled_generic(count, spans, userData); return; } @@ -4875,8 +4680,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void * if (mode != QPainter::CompositionMode_SourceOver && mode != QPainter::CompositionMode_Source) { - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); return; } @@ -4946,8 +4750,7 @@ static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData) @@ -4961,8 +4764,7 @@ static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData) @@ -4976,8 +4778,7 @@ static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) @@ -4991,8 +4792,7 @@ static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) @@ -5006,8 +4806,7 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData) @@ -5021,8 +4820,7 @@ static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData) @@ -5036,8 +4834,7 @@ static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData) @@ -5051,8 +4848,7 @@ static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData) @@ -5066,19 +4862,17 @@ static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData) blendTiled(count, spans, userData); else #endif - blend_tiled_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_tiled_generic(count, spans, userData); } template -Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { - blend_src_generic(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod)); + blend_src_generic(count, spans, userData); return; } @@ -5257,8 +5051,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan if (mode != QPainter::CompositionMode_SourceOver) { - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); return; } @@ -5461,8 +5254,7 @@ static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, voi blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData) @@ -5476,8 +5268,7 @@ static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, v blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData) @@ -5491,8 +5282,7 @@ static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, voi blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData) @@ -5506,8 +5296,7 @@ static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, v blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, @@ -5522,8 +5311,7 @@ static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData) @@ -5537,8 +5325,7 @@ static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, v blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData) @@ -5552,8 +5339,7 @@ static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, voi blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData) @@ -5567,8 +5353,7 @@ static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, v blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData) @@ -5582,18 +5367,16 @@ static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, voi blendTransformedBilinear(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } template -Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_tiled_argb(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_tiled_argb(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { - blend_src_generic(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod)); + blend_src_generic(count, spans, userData); return; } @@ -5779,13 +5562,12 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_tiled_argb(int count, } template -Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_argb(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_argb(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { - blend_src_generic(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod)); + blend_src_generic(count, spans, userData); return; } @@ -5907,8 +5689,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans, QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; if (mode != QPainter::CompositionMode_SourceOver) { - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); return; } @@ -6057,8 +5838,7 @@ static void blend_transformed_rgb888(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_argb6666(int count, const QSpan *spans, @@ -6073,8 +5853,7 @@ static void blend_transformed_argb6666(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_rgb666(int count, const QSpan *spans, @@ -6089,8 +5868,7 @@ static void blend_transformed_rgb666(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_argb8565(int count, const QSpan *spans, @@ -6105,8 +5883,7 @@ static void blend_transformed_argb8565(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_rgb565(int count, const QSpan *spans, @@ -6121,8 +5898,7 @@ static void blend_transformed_rgb565(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_argb8555(int count, const QSpan *spans, @@ -6137,8 +5913,7 @@ static void blend_transformed_argb8555(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_rgb555(int count, const QSpan *spans, @@ -6153,8 +5928,7 @@ static void blend_transformed_rgb555(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_argb4444(int count, const QSpan *spans, @@ -6169,8 +5943,7 @@ static void blend_transformed_argb4444(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_rgb444(int count, const QSpan *spans, @@ -6185,18 +5958,16 @@ static void blend_transformed_rgb444(int count, const QSpan *spans, blendTransformed(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } template -Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData - Q_TEMPLATE_ENUM_FIX(SpanMethod, spanMethod)) +Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { - blend_src_generic(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, spanMethod)); + blend_src_generic(count, spans, userData); return; } @@ -6330,8 +6101,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *sp QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; if (mode != QPainter::CompositionMode_SourceOver) { - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); return; } @@ -6481,8 +6251,7 @@ static void blend_transformed_tiled_rgb888(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_tiled_argb6666(int count, const QSpan *spans, @@ -6497,8 +6266,7 @@ static void blend_transformed_tiled_argb6666(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_tiled_rgb666(int count, const QSpan *spans, @@ -6513,8 +6281,7 @@ static void blend_transformed_tiled_rgb666(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_tiled_argb8565(int count, const QSpan *spans, @@ -6529,8 +6296,7 @@ static void blend_transformed_tiled_argb8565(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, @@ -6545,8 +6311,7 @@ static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_tiled_argb8555(int count, const QSpan *spans, @@ -6561,8 +6326,7 @@ static void blend_transformed_tiled_argb8555(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_tiled_rgb555(int count, const QSpan *spans, @@ -6577,8 +6341,7 @@ static void blend_transformed_tiled_rgb555(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_tiled_argb4444(int count, const QSpan *spans, @@ -6593,8 +6356,7 @@ static void blend_transformed_tiled_argb4444(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } static void blend_transformed_tiled_rgb444(int count, const QSpan *spans, @@ -6609,36 +6371,10 @@ static void blend_transformed_tiled_rgb444(int count, const QSpan *spans, blendTransformedTiled(count, spans, userData); else #endif - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); -} - -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 && !defined(Q_CC_INTEL) - -// explicit template instantiations needed to compile with VC6 and VC2002 - -#define SPANFUNC_INSTANTIATION(Name, Arg) \ -static inline void Name##_##Arg(int count, const QSpan *spans, void *userData) \ -{ \ - Name(count, spans, userData Q_TEMPLATE_ENUM_CALL(SpanMethod, Arg)); \ + blend_src_generic(count, spans, userData); } -SPANFUNC_INSTANTIATION(blend_untransformed_generic, RegularSpans); -SPANFUNC_INSTANTIATION(blend_untransformed_argb, RegularSpans); -SPANFUNC_INSTANTIATION(blend_tiled_generic, RegularSpans); -SPANFUNC_INSTANTIATION(blend_tiled_argb, RegularSpans); -SPANFUNC_INSTANTIATION(blend_src_generic, RegularSpans); -SPANFUNC_INSTANTIATION(blend_transformed_argb, RegularSpans); -SPANFUNC_INSTANTIATION(blend_transformed_tiled_argb, RegularSpans); -SPANFUNC_INSTANTIATION(blend_transformed_bilinear_argb, RegularSpans); -SPANFUNC_INSTANTIATION(blend_transformed_bilinear_tiled_argb, RegularSpans); -#undef SPANFUNC_INSTANTIATION - -#define SPANFUNC_POINTER(Name, Arg) Name##_##Arg - -#else // !VC6 && !VC2002 # define SPANFUNC_POINTER(Name, Arg) Name -#endif /* Image formats here are target formats */ @@ -7005,8 +6741,7 @@ static void qt_gradient_quint32(int count, const QSpan *spans, void *userData) } } else { - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } } @@ -7054,8 +6789,7 @@ static void qt_gradient_quint16(int count, const QSpan *spans, void *userData) data->solid.color = oldColor; } else { - blend_src_generic(count, spans, userData - Q_TEMPLATE_ENUM_CALL(SpanMethod, RegularSpans)); + blend_src_generic(count, spans, userData); } } -- cgit v0.12 From 815eb0e1d05318dfdd3cadb7f45c7e8e80ff4790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 31 Mar 2009 20:00:18 +0200 Subject: Optimize blend functions for short adjacent spans. When drawing antialiased primitives it's quite common to have several very short (often just one pixel) spans adjacent to each other. This patch makes it possible to fetch several adjacent spans at a time, avoiding the overhead of calling fetch on every single span. Reviewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper.cpp | 118 +++++++++++++++++++++++++++++++-------- 1 file changed, 96 insertions(+), 22 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 47dbf1b..7e73304 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -3041,41 +3041,115 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData) blend_color_generic(count, spans, userData); } -template -Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, void *userData) +template +void handleSpans(int count, const QSpan *spans, const QSpanData *data, T &handler) { - QSpanData *data = reinterpret_cast(userData); - - uint buffer[buffer_size]; - uint src_buffer[buffer_size]; - Operator op = getOperator(data, spans, count); - uint const_alpha = 256; if (data->type == QSpanData::Texture) const_alpha = data->texture.const_alpha; - while (count--) { + int coverage = 0; + while (count) { int x = spans->x; - int length = spans->len; - const int coverage = (spans->coverage * const_alpha) >> 8; + const int y = spans->y; + int right = x + spans->len; + + // compute length of adjacent spans + for (int i = 1; i < count && spans[i].y == y && spans[i].x == right; ++i) + right += spans[i].len; + int length = right - x; + while (length) { int l = qMin(buffer_size, length); - const uint *src = op.src_fetch(src_buffer, &op, data, spans->y, x, l); - if (spanMethod == RegularSpans) { - uint *dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, spans->y, l) : buffer; - op.func(dest, src, l, coverage); - if (op.dest_store) - op.dest_store(data->rasterBuffer, x, spans->y, dest, l); - } else { - drawBufferSpan(data, src, l, x, spans->y, l, coverage); - } - x += l; length -= l; + + int process_length = l; + int process_x = x; + + const uint *src = handler.fetch(process_x, y, process_length); + int offset = 0; + while (l > 0) { + if (x == spans->x) // new span? + coverage = (spans->coverage * const_alpha) >> 8; + + int right = spans->x + spans->len; + int len = qMin(l, right - x); + + handler.process(x, y, len, coverage, src, offset); + + l -= len; + x += len; + offset += len; + + if (x == right) { // done with current span? + ++spans; + --count; + } + } + handler.store(process_x, y, process_length); } - ++spans; } } +struct QBlendBase +{ + QBlendBase(QSpanData *d, Operator o) + : data(d) + , op(o) + , dest(0) + { + } + + QSpanData *data; + Operator op; + + uint *dest; + + uint buffer[buffer_size]; + uint src_buffer[buffer_size]; +}; + +template +class BlendSrcGeneric : public QBlendBase +{ +public: + BlendSrcGeneric(QSpanData *d, Operator o) + : QBlendBase(d, o) + { + } + + const uint *fetch(int x, int y, int len) + { + if (spanMethod == RegularSpans) + dest = op.dest_fetch ? op.dest_fetch(buffer, data->rasterBuffer, x, y, len) : buffer; + + return op.src_fetch(src_buffer, &op, data, y, x, len); + } + + void process(int x, int y, int len, int coverage, const uint *src, int offset) + { + if (spanMethod == RegularSpans) + op.func(dest + offset, src + offset, len, coverage); + else + drawBufferSpan(data, src + offset, len, x, y, len, coverage); + } + + void store(int x, int y, int len) + { + if (spanMethod == RegularSpans && op.dest_store) { + op.dest_store(data->rasterBuffer, x, y, dest, len); + } + } +}; + +template +Q_STATIC_TEMPLATE_FUNCTION void blend_src_generic(int count, const QSpan *spans, void *userData) +{ + QSpanData *data = reinterpret_cast(userData); + BlendSrcGeneric blend(data, getOperator(data, spans, count)); + handleSpans(count, spans, data, blend); +} + template Q_STATIC_TEMPLATE_FUNCTION void blend_untransformed_generic(int count, const QSpan *spans, void *userData) { -- cgit v0.12 From 1df41e19604d8c8945ad8e55e36016e480446576 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Wed, 1 Apr 2009 16:04:58 +0200 Subject: Doc - clarified that QMessageBox's predefined icons are not defined in QMessageBox, but provided by the style. Task-number: 249946 Reviewed-by: TrustMe --- src/gui/dialogs/qmessagebox.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index f343405..1967837 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -532,11 +532,11 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) \section2 Severity Levels and the Icon and Pixmap Properties - QMessageBox supports four predefined message severity levels, or - message types, which really only differ in the predefined icon - they each show. Specify one of the four predefined message types - by setting the \l{QMessageBox::icon} {icon} property to one of the - \l{QMessageBox::Icon} {predefined Icons}. The following rules are + QMessageBox supports four predefined message severity levels, or message + types, which really only differ in the predefined icon they each show. + Specify one of the four predefined message types by setting the + \l{QMessageBox::icon}{icon} property to one of the + \l{QMessageBox::Icon}{predefined icons}. The following rules are guidelines: \table @@ -558,17 +558,17 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) \o For reporting critical errors. \endtable - The default value is \l{QMessageBox::NoIcon} {No Icon}. The - message boxes are otherwise the same for all cases. When using a - standard icon, use the one recommended in the table, or use the - one recommended by the style guidelines for your platform. If none - of the standard icons is right for your message box, you can use a - custom icon by setting the \l{QMessageBox::iconPixmap} {icon - pixmap} property instead of setting the \l{QMessageBox::icon} - {icon} property. - - In summary, to set an icon, use \e{either} setIcon() for one of - the standard icons, \e{or} setIconPixmap() for a custom icon. + \l{QMessageBox::Icon}{Predefined icons} are not defined by QMessageBox, but + provided by the style. The default value is \l{QMessageBox::NoIcon} + {No Icon}. The message boxes are otherwise the same for all cases. When + using a standard icon, use the one recommended in the table, or use the + one recommended by the style guidelines for your platform. If none of the + standard icons is right for your message box, you can use a custom icon by + setting the \l{QMessageBox::iconPixmap}{icon pixmap} property instead of + setting the \l{QMessageBox::icon}{icon} property. + + In summary, to set an icon, use \e{either} setIcon() for one of the + standard icons, \e{or} setIconPixmap() for a custom icon. \section1 The Static Functions API -- cgit v0.12 From 6eac95b553f4a2958c2c58127441f2705b05b0a3 Mon Sep 17 00:00:00 2001 From: kh Date: Wed, 1 Apr 2009 16:17:18 +0200 Subject: don't open the TopicChooser if no link is avaliable Task-number: none Reviewed-by: hjk --- tools/assistant/tools/assistant/indexwindow.cpp | 56 ++++++++++--------------- tools/assistant/tools/assistant/indexwindow.h | 2 + 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index e7575fa..4bd6f4f 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -122,10 +122,9 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e) m_indexWidget->setCurrentIndex(idx); break; case Qt::Key_Escape: - emit escapePressed(); + emit escapePressed(); break; - default: - ; + default: ; // stop complaining } } else if (obj == m_indexWidget && e->type() == QEvent::ContextMenu) { QContextMenuEvent *ctxtEvent = static_cast(e); @@ -140,44 +139,15 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e) if (curTab == action) m_indexWidget->activateCurrentItem(); else if (newTab == action) { - QHelpIndexModel *model = - qobject_cast(m_indexWidget->model()); - QString keyword = model->data(idx, Qt::DisplayRole).toString(); - if (model) { - QMap links = model->linksForKeyword(keyword); - if (links.count() == 1) { - CentralWidget::instance()-> - setSourceInNewTab(links.constBegin().value()); - } else { - TopicChooser tc(this, keyword, links); - if (tc.exec() == QDialog::Accepted) { - CentralWidget::instance()->setSourceInNewTab(tc.link()); - } - } - } + open(m_indexWidget, idx); } } } else if (m_indexWidget && obj == m_indexWidget->viewport() && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *mouseEvent = static_cast(e); QModelIndex idx = m_indexWidget->indexAt(mouseEvent->pos()); - if (idx.isValid() && mouseEvent->button()==Qt::MidButton) { - QHelpIndexModel *model = - qobject_cast(m_indexWidget->model()); - QString keyword = model->data(idx, Qt::DisplayRole).toString(); - if (model) { - QMap links = model->linksForKeyword(keyword); - if (links.count() > 1) { - TopicChooser tc(this, keyword, links); - if (tc.exec() == QDialog::Accepted) { - CentralWidget::instance()->setSourceInNewTab(tc.link()); - } - } else if (links.count() == 1) { - CentralWidget::instance()-> - setSourceInNewTab(links.constBegin().value()); - } - } - } + if (idx.isValid() && mouseEvent->button()==Qt::MidButton) + open(m_indexWidget, idx); } #ifdef Q_OS_MAC else if (obj == m_indexWidget && e->type() == QEvent::KeyPress) { @@ -213,4 +183,20 @@ void IndexWindow::focusInEvent(QFocusEvent *e) } } +void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) +{ + QHelpIndexModel *model = qobject_cast(indexWidget->model()); + if (model) { + QString keyword = model->data(index, Qt::DisplayRole).toString(); + QMap links = model->linksForKeyword(keyword); + if (links.count() > 1) { + TopicChooser tc(this, keyword, links); + if (tc.exec() == QDialog::Accepted) + CentralWidget::instance()->setSourceInNewTab(tc.link()); + } else if (links.count() == 1) { + CentralWidget::instance()->setSourceInNewTab(links.constBegin().value()); + } + } +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/indexwindow.h b/tools/assistant/tools/assistant/indexwindow.h index f1f57f9..14ed83c 100644 --- a/tools/assistant/tools/assistant/indexwindow.h +++ b/tools/assistant/tools/assistant/indexwindow.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QHelpIndexWidget; class QHelpEngine; +class QModelIndex; class IndexWindow : public QWidget { @@ -79,6 +80,7 @@ private slots: private: bool eventFilter(QObject *obj, QEvent *e); void focusInEvent(QFocusEvent *e); + void open(QHelpIndexWidget *indexWidget, const QModelIndex &index); QLineEdit *m_searchLineEdit; QHelpIndexWidget *m_indexWidget; -- cgit v0.12 From ef46fa38e50b807c6122dc37d84d2944069ef3ea Mon Sep 17 00:00:00 2001 From: kh Date: Wed, 1 Apr 2009 16:18:12 +0200 Subject: don't invoke the current item without selection Task-number: none Reviewed-by: hjk --- tools/assistant/tools/assistant/contentwindow.cpp | 41 +++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index ef272e8..24e7ca9 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -118,19 +118,24 @@ void ContentWindow::keyPressEvent(QKeyEvent *e) bool ContentWindow::eventFilter(QObject *o, QEvent *e) { - if (m_contentWidget && o == m_contentWidget->viewport() && e->type() - == QEvent::MouseButtonRelease) { + if (m_contentWidget && o == m_contentWidget->viewport() + && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *me = static_cast(e); - if (m_contentWidget->indexAt(me->pos()).isValid() - && me->button() == Qt::LeftButton) { - itemClicked(m_contentWidget->currentIndex()); - } else if (m_contentWidget->indexAt(me->pos()).isValid() - && me->button() == Qt::MidButton) { - QHelpContentModel *contentModel = - qobject_cast(m_contentWidget->model()); - QHelpContentItem *itm = - contentModel->contentItemAt(m_contentWidget->currentIndex()); - CentralWidget::instance()->setSourceInNewTab(itm->url()); + QModelIndex index = m_contentWidget->indexAt(me->pos()); + QItemSelectionModel *sm = m_contentWidget->selectionModel(); + + if (index.isValid() && (sm && sm->isSelected(index))) { + if (me->button() == Qt::LeftButton) { + itemClicked(index); + } else if (me->button() == Qt::MidButton) { + QHelpContentModel *contentModel = + qobject_cast(m_contentWidget->model()); + if (contentModel) { + QHelpContentItem *itm = contentModel->contentItemAt(index); + if (itm) + CentralWidget::instance()->setSourceInNewTab(itm->url()); + } + } } } return QWidget::eventFilter(o, e); @@ -160,14 +165,14 @@ void ContentWindow::showContextMenu(const QPoint &pos) void ContentWindow::itemClicked(const QModelIndex &index) { - if (!index.isValid()) - return; QHelpContentModel *contentModel = qobject_cast(m_contentWidget->model()); - QHelpContentItem *itm = - contentModel->contentItemAt(index); - if (itm) - emit linkActivated(itm->url()); + + if (contentModel) { + QHelpContentItem *itm = contentModel->contentItemAt(index); + if (itm) + emit linkActivated(itm->url()); + } } QT_END_NAMESPACE -- cgit v0.12 From 1375c1cb91a3233ca50f3ca9ef5d63bda038614b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 1 Apr 2009 17:21:32 +0200 Subject: Exclude the autotools subdirectory when importing from WebKit trunk. Reviewed-by: Trust Me --- util/webkit/mkdist-webkit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 1268b5e..cfbde00 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -10,7 +10,7 @@ excluded_directories="$excluded_directories PlanetWebKit" excluded_directories="$excluded_directories SunSpider" excluded_directories="$excluded_directories WebKitExamplePlugins" -excluded_directories="$excluded_directories symbols.filter" +excluded_directories="$excluded_directories autotools" excluded_directories="$excluded_directories JavaScriptCore/Makefile" excluded_directories="$excluded_directories Makefile" excluded_directories="$excluded_directories Makefile.shared" -- cgit v0.12 From 214d5e9f7e15610c411983ee797c826f5e4132d3 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 1 Apr 2009 17:22:34 +0200 Subject: Fix WebKit import from the trunk. WebCore/plugins/wx is gone. Reviewed-by: Trust me --- util/webkit/mkdist-webkit | 1 - 1 file changed, 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index cfbde00..4fcfa8d 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -87,7 +87,6 @@ excluded_directories="$excluded_directories WebCore/platform/image-decoders/ico" excluded_directories="$excluded_directories WebCore/platform/image-decoders/jpeg" excluded_directories="$excluded_directories WebCore/platform/image-decoders/xbm" -excluded_directories="$excluded_directories WebCore/plugins/wx" excluded_directories="$excluded_directories WebCore/plugins/gtk" excluded_directories="$excluded_directories WebCore/platform/symbian WebCore/platform/wx" -- cgit v0.12 From 2034996740c51d1231dbfa7af7eb9271541682bb Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 1 Apr 2009 17:28:11 +0200 Subject: Fix up WebKit import from the trunk. acinclude.m4 has been moved to autotools/ Reviewed-by: Trust me --- util/webkit/mkdist-webkit | 1 - 1 file changed, 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 4fcfa8d..ab7557c 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -114,7 +114,6 @@ files_to_remove="$files_to_remove WebKit/qt/Api/qcookiejar.h" files_to_remove="$files_to_remove WebKit/qt/Api/qcookiejar.cpp" files_to_remove="$files_to_remove WebCore/rendering/RenderThemeMac.mm" -files_to_remove="$files_to_remove acinclude.m4" files_to_remove="$files_to_remove autogen.sh" files_to_remove="$files_to_remove configure.ac" -- cgit v0.12 From 2f53d62b7c2583e05f2a61c37b237b604d9e9d3b Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 1 Apr 2009 16:36:19 +0200 Subject: Doc: Minor language fixes and tidying. Reviewed-by: TrustMe --- doc/src/phonon-api.qdoc | 2 +- doc/src/phonon.qdoc | 2 +- doc/src/qnamespace.qdoc | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/src/phonon-api.qdoc b/doc/src/phonon-api.qdoc index 147ded3..3d04c68 100644 --- a/doc/src/phonon-api.qdoc +++ b/doc/src/phonon-api.qdoc @@ -2568,7 +2568,7 @@ details. Phonon also provides EffectWidget, which lets the user modify the - parameters of an effect an the fly, e.g., with comboboxes. + parameters of an effect an the fly; e.g., with combo boxes. \sa {Phonon Module}, EffectWidget */ diff --git a/doc/src/phonon.qdoc b/doc/src/phonon.qdoc index fa84b96..9470e61 100644 --- a/doc/src/phonon.qdoc +++ b/doc/src/phonon.qdoc @@ -49,7 +49,7 @@ \section1 Introduction Qt uses the Phonon multimedia framework to provide functionality - for playback of the most common multimedia formats.The media can + for playback of the most common multimedia formats. The media can be read from files or streamed over a network, using a QURL to a file. diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc index 6220795..e6a1a36 100644 --- a/doc/src/qnamespace.qdoc +++ b/doc/src/qnamespace.qdoc @@ -508,11 +508,11 @@ \value DirectConnection When emitted, the signal is immediately delivered to the slot. \value QueuedConnection When emitted, the signal is queued until the event loop is able to deliver it to the slot. - \value - BlockingQueuedConnection Same as QueuedConnection, except that the current thread blocks + \value BlockingQueuedConnection + Same as QueuedConnection, except that the current thread blocks until the slot has been delivered. This connection type should only be used for receivers in a different thread. Note that misuse - of this type can lead to dead locks in your application. + of this type can lead to deadlocks in your application. \value AutoConnection If the signal is emitted from the thread in which the receiving object lives, the slot is invoked directly, as with -- cgit v0.12 From 6869506819aa705fab4d20e8f683bc75e1d2f5c2 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 1 Apr 2009 16:37:14 +0200 Subject: Doc: Trivial fixes. Reviewed-by: TrustMe --- src/corelib/global/qglobal.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 1645279..8324d05 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2944,12 +2944,12 @@ bool QInternal::callFunction(InternalFunction func, void **args) Compares the floating point value \a p1 and \a p2 and returns \c true if they are considered equal, otherwise \c false. - + Note that comparing values where either \a p1 or \a p2 is 0.0 will not work. - The solution to this is to compare against values greater than or equal to 1.0 - + The solution to this is to compare against values greater than or equal to 1.0. + \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 46 - + The two numbers are compared in a relative way, where the exactness is stronger the smaller the numbers are. */ -- cgit v0.12 From 3ffcbdcfe10e7ef6eec1135a449b91a55e0b2bb6 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 1 Apr 2009 16:38:15 +0200 Subject: Doc: Updated the deployment documentation with the QtScriptTools module and references to Phonon documentation. Task-number: 212939 Reviewed-by: TrustMe --- doc/src/deployment.qdoc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/src/deployment.qdoc b/doc/src/deployment.qdoc index 7e02f1a..d9f7c1a 100644 --- a/doc/src/deployment.qdoc +++ b/doc/src/deployment.qdoc @@ -91,7 +91,7 @@ The disadvantage with the shared library approach is that you will get more files to deploy. For more information, see \l{sharedlibrary.html}{Creating Shared Libraries}. - + \section1 Deploying Qt's Libraries \table @@ -111,13 +111,14 @@ \o \l {QtNetwork} \o \l {QtOpenGL} \o \l {QtScript} - \o \l {QtSql} + \o \l {QtScriptTools} \row + \o \l {QtSql} \o \l {QtSvg} \o \l {QtWebKit} \o \l {QtXml} - \o \l {QtXmlPatterns} \row + \o \l {QtXmlPatterns} \o \l {Phonon Module}{Phonon} \o \l {Qt3Support} \endtable @@ -178,11 +179,13 @@ Please see \l{QtWebKit Module#License Information}{the QtWebKit module documentation} for more information. - \row \o Phonon \o Phonon + \row \o \l{Phonon Module}{Phonon} \o Phonon \o Phonon relies on the native multimedia engines on different platforms. Phonon itself is licensed under the GNU LGPL version 2. Please see \l{Phonon Module#License Information}{the Phonon module documentation} - for more information. + for more information on licensing and the + \l{Phonon Overview#Backends}{Phonon Overview} for details of the backends + in use on different platforms. \endtable \section1 Platform-Specific Notes -- cgit v0.12 From a6b3f4e3d77d417e471f3fec34fdafe87af4c2d5 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 1 Apr 2009 16:59:51 +0200 Subject: Doc: Clarified the usage of QImage::dotsPerMeterX() and QImage::dotsPerMeterY(). Task-number: 240164 Reviewed-by: Jan Erik Hanssen --- src/gui/image/qimage.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 558d574..dc236e4 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4937,10 +4937,12 @@ int QImage::dotsPerMeterY() const meter, to \a x. Together with dotsPerMeterY(), this number defines the intended - scale and aspect ratio of the image. + scale and aspect ratio of the image, and determines the scale + at which QPainter will draw graphics on the image. It does not + change the scale or aspect ratio of the image when it is rendered + on other paint devices. - \sa dotsPerMeterX(), {QImage#Image Information}{Image - Information} + \sa dotsPerMeterX(), {QImage#Image Information}{Image Information} */ void QImage::setDotsPerMeterX(int x) { @@ -4957,10 +4959,12 @@ void QImage::setDotsPerMeterX(int x) to \a y. Together with dotsPerMeterX(), this number defines the intended - scale and aspect ratio of the image. + scale and aspect ratio of the image, and determines the scale + at which QPainter will draw graphics on the image. It does not + change the scale or aspect ratio of the image when it is rendered + on other paint devices. - \sa dotsPerMeterY(), {QImage#Image Information}{Image - Information} + \sa dotsPerMeterY(), {QImage#Image Information}{Image Information} */ void QImage::setDotsPerMeterY(int y) { -- cgit v0.12 From d0a3f5029dbfd37a53af6512db63c86a4130aad3 Mon Sep 17 00:00:00 2001 From: Bill King Date: Thu, 2 Apr 2009 10:27:44 +1000 Subject: Cleanup and minor fixes of db testcase support code --- tests/auto/qsqldatabase/tst_databases.h | 39 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index b529b7e..9c19048 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -105,10 +105,11 @@ inline static QString qTableName( const QString& prefix, QSqlDriver* driver = 0 inline static bool testWhiteSpaceNames( const QString &name ) { - return name.startsWith( "QPSQL" ) +/* return name.startsWith( "QPSQL" ) || name.startsWith( "QODBC" ) || name.startsWith( "QSQLITE" ) - || name.startsWith( "QMYSQL" ); + || name.startsWith( "QMYSQL" );*/ + return name != QLatin1String("QSQLITE2"); } inline static QString toHex( const QString& binary ) @@ -203,14 +204,14 @@ public: { // addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/pony.troll.no", "scott", "tiger" ); // Oracle 9i on horsehead // addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/ustest.troll.no", "scott", "tiger", "" ); // Oracle 9i on horsehead -// addDb( "QOCI8", "ICE", "scott", "tiger", "" ); // Oracle 8 on iceblink +// addDb( "QOCI8", "//iceblink.nokia.troll.no:1521/ice.troll.no", "scott", "tiger", "" ); // Oracle 8 on iceblink (not currently working) // addDb( "QOCI", "//silence.nokia.troll.no:1521/testdb", "scott", "tiger" ); // Oracle 10g on silence // addDb( "QOCI", "//oracle10g-nokia.trolltech.com.au:1521/XE", "scott", "tiger" ); // Oracle 10gexpress on xen // This requires a local ODBC data source to be configured( pointing to a MySql database ) // addDb( "QODBC", "mysqlodbc", "troll", "trond" ); // addDb( "QODBC", "SqlServer", "troll", "trond" ); -// addDb( "QTDS7", "testdb", "troll", "trondk", "horsehead" ); +// addDb( "QTDS7", "testdb", "troll", "trondk", "horsehead.nokia.troll.no" ); // addDb( "QODBC", "silencetestdb", "troll", "trond", "silence" ); // addDb( "QODBC", "horseheadtestdb", "troll", "trondk", "horsehead" ); @@ -231,7 +232,7 @@ public: // addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "postgres74-nokia.trolltech.com.au" ); // Version 7.4.19-1.el4_6.1 // addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "postgres81-nokia.trolltech.com.au" ); // Version 8.1.11-1.el5_1.1 -// addDb( "QDB2", "testdb", "troll", "trond", "silence" ); // DB2 v9.1 on silence +// addDb( "QDB2", "testdb", "troll", "trond", "silence.nokia.troll.no" ); // DB2 v9.1 on silence // yes - interbase really wants the physical path on the host machine. // addDb( "QIBASE", "/opt/interbase/qttest.gdb", "SYSDBA", "masterkey", "horsehead.nokia.troll.no" ); @@ -240,10 +241,6 @@ public: // addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "firebird1-nokia.trolltech.com.au" ); // Firebird 1.5.5 // addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "firebird2-nokia.trolltech.com.au" ); // Firebird 2.1.1 -// Anders' local Firebird and InterBase test databases -// addDb("QIBASE", "localhost:c:\\Firebird\\Firebird_2_0\\TESTDB.FDB", "SYSDBA", "masterkey", ""); // FireBird 2.0 -// addDb("QIBASE", "localhost:c:\\Borland\\InterBase\\TESTDB_UTF8.IB", "SYSDBA", "masterkey", ""); // InterBase 2007 Developer - // use in-memory database to prevent local files // addDb("QSQLITE", ":memory:"); addDb( "QSQLITE", QDir::toNativeSeparators(QDir::tempPath()+"/foo.db") ); @@ -312,20 +309,22 @@ public: // drop a table only if it exists to prevent warnings static void safeDropTables( QSqlDatabase db, const QStringList& tableNames ) { - int wasDropped = true; + bool wasDropped; QSqlQuery q( db ); QStringList dbtables=db.tables(); - foreach(QString tableName, tableNames) - { - - if ( dbtables.contains( tableName, Qt::CaseSensitive ) ) - wasDropped = q.exec( "drop table " + db.driver()->escapeIdentifier( tableName, QSqlDriver::TableName ) ); - else if ( dbtables.contains( tableName, Qt::CaseInsensitive ) ) - wasDropped = q.exec( "drop table " + tableName ); - + foreach(const QString &tableName, tableNames) { + wasDropped = true; + foreach(const QString dbtablesName, dbtables) { + if(dbtablesName.toUpper() == tableName.toUpper()) { + dbtables.removeAll(dbtablesName); + wasDropped = q.exec("drop table " + db.driver()->escapeIdentifier( dbtablesName, QSqlDriver::TableName )); + if(!wasDropped) + wasDropped = q.exec("drop table " + dbtablesName); + } + } if ( !wasDropped ) - qWarning() << "unable to drop table" << tableName << ':' << q.lastError().text(); + qWarning() << dbToString(db) << "unable to drop table" << tableName << ':' << q.lastError().text() << "tables:" << dbtables; } } @@ -401,7 +400,7 @@ public: static QByteArray printError( const QSqlError& err, const QSqlDatabase& db ) { - return QString( db.driverName() + ": '" + err.driverText() + "' || '" + err.databaseText() + "'" ).toLocal8Bit(); + return QString( dbToString(db) + ": '" + err.driverText() + "' || '" + err.databaseText() + "'" ).toLocal8Bit(); } static bool isSqlServer( QSqlDatabase db ) -- cgit v0.12 From ea66ff84b5eac1846afcaf80b3d24297be0dce8f Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 2 Apr 2009 08:11:59 +0200 Subject: Simplify WebKit import script Don't require any arguments by default, get the repo path from git config and updated the default tag. Reviewed-by: Trust me --- util/webkit/mkdist-webkit | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 1268b5e..0644564 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -1,7 +1,24 @@ #!/bin/bash -repository="git://git.dev.troll.no/webkit-mirror" -tag="qtwebkit-merged-into-qt-4-4" +die() { + echo $* + exit 1 +} + +default_tag="origin/qtwebkit-4.5" + +if [ $# -eq 0 ]; then + tag="$default_tag" +elif [ $# -eq 1 ]; then + tag=$1 +else + die "usage: $0 [commit (defaults to $default_tag)]" +fi + +repository=`git config qtwebkit.url` +if [ -z "$repository" ]; then + die "error: cannot locate webkit git repository. please run git config --global qtwebkit.url /path-or-url/to/webkit/repo" +fi excluded_directories="LayoutTests JavaScriptGlue WebKitLibraries WebKitSite WebKitTools WebCore/platform/cf WebCore/platform/gtk WebCore/platform/chromium" excluded_directories="$excluded_directories PageLoadTests" @@ -138,20 +155,6 @@ files_to_remove="$files_to_remove WebCore/WebCoreSources.bkl" files_to_remove="$files_to_remove WebCore/webcore-base.bkl" files_to_remove="$files_to_remove WebCore/webcore-wx.bkl" -if [ $# -eq 1 ]; then - tag=$1 -fi - -if [ $# -eq 2 ]; then - repository=$1 - tag=$2 -fi - -die() { - echo $* - exit 1 -} - require_clean_work_tree() { # test if working tree is dirty git rev-parse --verify HEAD > /dev/null && -- cgit v0.12 From 8044128f7cd9919bac6da34fd7b886d60a2d4e9e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 2 Apr 2009 08:17:30 +0200 Subject: Changed WebKit import script to default to import from the trunk instead of 4.5 Reviewed-by: Trust me --- util/webkit/mkdist-webkit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 2e6334d..3b513b4 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -5,7 +5,7 @@ die() { exit 1 } -default_tag="origin/qtwebkit-4.5" +default_tag="origin/svn/master" if [ $# -eq 0 ]; then tag="$default_tag" -- cgit v0.12 From 1f9074b743c727165f21149a09fd08e32157faaf Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 1 Apr 2009 17:04:50 +0200 Subject: Fix slowdown regression in QGraphicsItem::ItemCoordinateCache Right before Qt 4.5.0 was released, Alexis and I submitted change 7e9b000ee418ef2d9c8fadb2c6b8870e0335bd5e, which accidentally introduced a rounding error causing items whose bounding rect contains fractional numbers (e.g., QRectF(-0.5, -0.5, 11, 11)), to always be drawn with a one-pixel strech even if otherwise untransformed. This caused a significant slowdown for pixmap items and any shape item that uses almost any pen width != 0, if they enable ItemCoordinateCache. The fix is to consistently use the aligned rectangle both when generating the cache pixmap and when drawing it. Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsscene.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 1f78a18..ff46e2e 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4595,16 +4595,17 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte if (cacheMode == QGraphicsItem::ItemCoordinateCache) { QSize pixmapSize; bool fixedCacheSize = false; + QRectF brectAligned = brect.toAlignedRect(); if ((fixedCacheSize = itemCache->fixedSize.isValid())) { pixmapSize = itemCache->fixedSize; } else { - pixmapSize = brect.toAlignedRect().size(); + pixmapSize = brectAligned.size().toSize(); } // Create or recreate the pixmap. int adjust = itemCache->fixedSize.isValid() ? 0 : 2; QSize adjustSize(adjust*2, adjust*2); - QRectF br = brect.adjusted(-adjust, -adjust, adjust, adjust); + QRectF br = brectAligned.adjusted(-adjust, -adjust, adjust, adjust); if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) { pix = QPixmap(pixmapSize + adjustSize); itemCache->exposed.clear(); @@ -4614,9 +4615,11 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte // Redraw any newly exposed areas. if (itemCache->allExposed || !itemCache->exposed.isEmpty()) { // Fit the item's bounding rect into the pixmap's coordinates. - const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height()); QTransform itemToPixmap; - itemToPixmap.scale(scale.x(), scale.y()); + if (fixedCacheSize) { + const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height()); + itemToPixmap.scale(scale.x(), scale.y()); + } itemToPixmap.translate(-br.x(), -br.y()); // Generate the item's exposedRect and map its list of expose -- cgit v0.12 From 88482ebf36a5fdd0cfaa24c7029b42e19090c6f0 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 2 Apr 2009 09:09:28 +0200 Subject: Doc - fixed a typo: iterartor -> iterator Reviewed-by: Trust me --- src/corelib/tools/qlinkedlist.cpp | 4 ++-- src/corelib/tools/qlistdata.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp index a3cbecc..c454224 100644 --- a/src/corelib/tools/qlinkedlist.cpp +++ b/src/corelib/tools/qlinkedlist.cpp @@ -652,7 +652,7 @@ QLinkedListData QLinkedListData::shared_null = { Constructs an uninitialized iterator. Functions like operator*() and operator++() should not be called - on an uninitialized iterartor. Use operator=() to assign a value + on an uninitialized iterator. Use operator=() to assign a value to it before using it. \sa QLinkedList::begin() QLinkedList::end() @@ -858,7 +858,7 @@ QLinkedListData QLinkedListData::shared_null = { Constructs an uninitialized iterator. Functions like operator*() and operator++() should not be called - on an uninitialized iterartor. Use operator=() to assign a value + on an uninitialized iterator. Use operator=() to assign a value to it before using it. \sa QLinkedList::constBegin() QLinkedList::constEnd() diff --git a/src/corelib/tools/qlistdata.cpp b/src/corelib/tools/qlistdata.cpp index 2b1c086..d7c39a7 100644 --- a/src/corelib/tools/qlistdata.cpp +++ b/src/corelib/tools/qlistdata.cpp @@ -1193,7 +1193,7 @@ void **QListData::erase(void **xi) Constructs an uninitialized iterator. Functions like operator*() and operator++() should not be called - on an uninitialized iterartor. Use operator=() to assign a value + on an uninitialized iterator. Use operator=() to assign a value to it before using it. \sa QList::begin() QList::end() @@ -1416,7 +1416,7 @@ void **QListData::erase(void **xi) Constructs an uninitialized iterator. Functions like operator*() and operator++() should not be called - on an uninitialized iterartor. Use operator=() to assign a value + on an uninitialized iterator. Use operator=() to assign a value to it before using it. \sa QList::constBegin() QList::constEnd() -- cgit v0.12 From 7a53f2071a6ef09993445b20d88206f3999302cb Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 2 Apr 2009 09:53:15 +0200 Subject: Visual tweaks on the new dial Increased contrast and size of indicator line. Reviewed-by: nrc --- src/gui/styles/qstylehelper.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index bd67f93..3320970 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -252,6 +252,7 @@ void QStyleHelper::drawDial(const QStyleOptionSlider *option, QPainter *painter) p->setBrush(Qt::NoBrush); p->setPen(buttonColor.lighter(110)); p->drawEllipse(br.adjusted(1, 1, -1, -1)); + if (option->state & QStyle::State_HasFocus) { QColor highlight = pal.highlight().color(); highlight.setHsv(highlight.hue(), @@ -274,20 +275,19 @@ void QStyleHelper::drawDial(const QStyleOptionSlider *option, QPainter *painter) dialRect.center().y() + dialRect.width(), dialRect.width()*2, dialRect.center().x(), dialRect.center().y()); - dialGradient.setColorAt(1, buttonColor.darker(130)); - dialGradient.setColorAt(0.201, buttonColor.darker(105)); - dialGradient.setColorAt(0.2, buttonColor.darker(104)); - dialGradient.setColorAt(0, buttonColor.darker(102)); + dialGradient.setColorAt(1, buttonColor.darker(140)); + dialGradient.setColorAt(0.4, buttonColor.darker(120)); + dialGradient.setColorAt(0, buttonColor.darker(110)); + if (penSize > 3.0) { + painter->setPen(QPen(QColor(0, 0, 0, 25), penSize)); + painter->drawLine(calcRadialPos(option, 0.90), calcRadialPos(option, 0.96)); + } painter->setBrush(dialGradient); painter->setPen(QColor(255, 255, 255, 150)); painter->drawEllipse(dialRect.adjusted(-1, -1, 1, 1)); - painter->setPen(QColor(0, 0, 0, 50)); + painter->setPen(QColor(0, 0, 0, 80)); painter->drawEllipse(dialRect); - if (penSize > 3.0) { - painter->setPen(QPen(QColor(0, 0, 0, 16), penSize/2.0)); - painter->drawLine(calcRadialPos(option, 0.95), calcRadialPos(option, 0.97)); - } painter->restore(); } #endif //QT_NO_DIAL -- cgit v0.12 From 4e036ebbc6351a9bd6597e89a803f5c4de746092 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 1 Apr 2009 12:26:03 +0200 Subject: optimize duplicate resolution use pointers in the index hash to avoid needless allocs and copies --- tools/linguist/shared/translator.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 3721204..9ac1dd8 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -416,25 +416,46 @@ void Translator::dropTranslations() } } +struct TranslatorMessagePtr { + TranslatorMessagePtr(const TranslatorMessage &tm) + { + ptr = &tm; + } + + const TranslatorMessage *ptr; +}; + +Q_DECLARE_TYPEINFO(TranslatorMessagePtr, Q_MOVABLE_TYPE); + +static inline int qHash(TranslatorMessagePtr tmp) +{ + return qHash(*tmp.ptr); +} + +static inline bool operator==(TranslatorMessagePtr tmp1, TranslatorMessagePtr tmp2) +{ + return *tmp1.ptr == *tmp2.ptr; +} + QList Translator::findDuplicates() const { - QHash dups; + QHash dups; foreach (const TranslatorMessage &msg, m_messages) dups[msg]++; QList ret; - QHash::ConstIterator it = dups.constBegin(), end = dups.constEnd(); + QHash::ConstIterator it = dups.constBegin(), end = dups.constEnd(); for (; it != end; ++it) if (it.value() > 1) - ret.append(it.key()); + ret.append(*it.key().ptr); return ret; } void Translator::resolveDualEncoded() { - QHash dups; + QHash dups; for (int i = 0; i < m_messages.count();) { const TranslatorMessage &msg = m_messages.at(i); - QHash::ConstIterator it = dups.constFind(msg); + QHash::ConstIterator it = dups.constFind(msg); if (it != dups.constEnd()) { TranslatorMessage &omsg = m_messages[*it]; if (omsg.isUtf8() != msg.isUtf8() && !omsg.isNonUtf8()) { -- cgit v0.12 From 385bb34a9dc8e7bd6d1d3c11247862b87978d629 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 1 Apr 2009 17:51:27 +0200 Subject: duplicate message handling improvements - lrelease will not abort on duplicates any more - lconvert now gets noisy, but only if messages within one file are duplicated (combining files with identical messages is ok) - lupdate stays silent, but will eliminate duplicates again - consolidate handling of dual-encoded and duplicate messages - for performance - instead of the format loader, now the app is responsible for calling the duplicate handler. this allows for the fine-grained control necessary for optimal performance. Task-number: 247738 --- tools/linguist/lconvert/main.cpp | 2 + tools/linguist/linguist/messagemodel.cpp | 10 ++-- tools/linguist/lrelease/main.cpp | 15 +----- tools/linguist/lupdate/main.cpp | 1 + tools/linguist/shared/qm.cpp | 1 - tools/linguist/shared/translator.cpp | 79 ++++++++++++++----------------- tools/linguist/shared/translator.h | 5 +- tools/linguist/shared/translatormessage.h | 26 ++++++++++ tools/linguist/shared/ts.cpp | 6 +-- 9 files changed, 77 insertions(+), 68 deletions(-) diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 2842bc7..9ccc60e 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -210,6 +210,7 @@ int main(int argc, char *argv[]) qWarning() << qPrintable(cd.error()); return 2; } + Translator::reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose); for (int i = 1; i < inFiles.size(); ++i) { Translator tr2; @@ -217,6 +218,7 @@ int main(int argc, char *argv[]) qWarning() << qPrintable(cd.error()); return 2; } + Translator::reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose); for (int j = 0; j < tr2.messageCount(); ++j) tr.replaceSorted(tr2.message(j)); } diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index b049ab9..7a8063b 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -209,19 +209,19 @@ bool DataModel::load(const QString &fileName, bool *langGuessed, QWidget *parent return false; } - QList dupes = tor.findDuplicates(); + QSet dupes = tor.resolveDuplicates(); if (!dupes.isEmpty()) { QString err = tr("Duplicate messages found in '%1':").arg(Qt::escape(fileName)); int numdups = 0; - foreach (const TranslatorMessage &msg, dupes) { + foreach (const TranslatorMessagePtr &msg, dupes) { if (++numdups >= 5) { err += tr("

[more duplicates omitted]"); break; } err += tr("

* Context: %1
* Source: %2") - .arg(Qt::escape(msg.context()), Qt::escape(msg.sourceText())); - if (!msg.comment().isEmpty()) - err += tr("
* Comment: %3").arg(Qt::escape(msg.comment())); + .arg(Qt::escape(msg->context()), Qt::escape(msg->sourceText())); + if (!msg->comment().isEmpty()) + err += tr("
* Comment: %3").arg(Qt::escape(msg->comment())); } QMessageBox::warning(parent, QObject::tr("Qt Linguist"), err); } diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index f1fdb3a..3bcc998 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -94,19 +94,6 @@ static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbo } else { if (!cd.errors().isEmpty()) printOut(cd.error()); - const QList dupes = tor.findDuplicates(); - if (!dupes.isEmpty()) { - qWarning("lrelease error: duplicate messages found in '%s':", - qPrintable(tsFileName)); - foreach (const TranslatorMessage &msg, dupes) { - qWarning("\n* Context: %s\n* Source: %s", - qPrintable(msg.context()), - qPrintable(msg.sourceText())); - if (!msg.comment().isEmpty()) - qWarning("\n* Comment: %s", qPrintable(msg.comment())); - } - ok = false; - } } return ok; } @@ -115,6 +102,8 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName, bool verbose, bool ignoreUnfinished, bool removeIdentical, TranslatorSaveMode mode) { + Translator::reportDuplicates(tor.resolveDuplicates(), qmFileName, verbose); + if (verbose) printOut(QCoreApplication::tr( "Updating '%1'...\n").arg(qmFileName)); if (removeIdentical) { diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 5869838..b537b6e 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -146,6 +146,7 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil *fail = true; continue; } + tor.resolveDuplicates(); cd.clearErrors(); if (!codecForTr.isEmpty() && codecForTr != tor.codecName()) qWarning("lupdate warning: Codec for tr() '%s' disagrees with " diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index d19b519..5563ac5 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -659,7 +659,6 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) msg.setComment(comment); translator.append(msg); } - translator.resolveDualEncoded(); return ok; } diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 9ac1dd8..312bb71 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -416,59 +416,52 @@ void Translator::dropTranslations() } } -struct TranslatorMessagePtr { - TranslatorMessagePtr(const TranslatorMessage &tm) - { - ptr = &tm; - } - - const TranslatorMessage *ptr; -}; - -Q_DECLARE_TYPEINFO(TranslatorMessagePtr, Q_MOVABLE_TYPE); - -static inline int qHash(TranslatorMessagePtr tmp) +QSet Translator::resolveDuplicates() { - return qHash(*tmp.ptr); -} - -static inline bool operator==(TranslatorMessagePtr tmp1, TranslatorMessagePtr tmp2) -{ - return *tmp1.ptr == *tmp2.ptr; -} - -QList Translator::findDuplicates() const -{ - QHash dups; - foreach (const TranslatorMessage &msg, m_messages) - dups[msg]++; - QList ret; - QHash::ConstIterator it = dups.constBegin(), end = dups.constEnd(); - for (; it != end; ++it) - if (it.value() > 1) - ret.append(*it.key().ptr); - return ret; -} - -void Translator::resolveDualEncoded() -{ - QHash dups; + QSet dups; + QHash refs; for (int i = 0; i < m_messages.count();) { const TranslatorMessage &msg = m_messages.at(i); - QHash::ConstIterator it = dups.constFind(msg); - if (it != dups.constEnd()) { + QHash::ConstIterator it = refs.constFind(msg); + if (it != refs.constEnd()) { TranslatorMessage &omsg = m_messages[*it]; if (omsg.isUtf8() != msg.isUtf8() && !omsg.isNonUtf8()) { + // Dual-encoded message omsg.setUtf8(true); omsg.setNonUtf8(true); - m_messages.removeAt(i); - continue; + } else { + // Duplicate + dups.insert(omsg); } - // Regular dupe; will complain later + if (!omsg.isTranslated() && msg.isTranslated()) + omsg.setTranslations(msg.translations()); + m_messages.removeAt(i); + } else { + refs[msg] = i; + ++i; + } + } + return dups; +} + +void Translator::reportDuplicates(const QSet &dupes, + const QString &fileName, bool verbose) +{ + if (!dupes.isEmpty()) { + if (!verbose) { + qWarning("Warning: dropping duplicate messages in '%s'\n(try -verbose for more info).", + qPrintable(fileName)); } else { - dups[msg] = i; + qWarning("Warning: dropping duplicate messages in '%s':", qPrintable(fileName)); + foreach (const TranslatorMessagePtr &msg, dupes) { + qWarning("\n* Context: %s\n* Source: %s", + qPrintable(msg->context()), + qPrintable(msg->sourceText())); + if (!msg->comment().isEmpty()) + qWarning("* Comment: %s", qPrintable(msg->comment())); + } + qWarning(); } - ++i; } } diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 8908305..6b88b23 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -127,9 +127,10 @@ public: void stripNonPluralForms(); void stripIdenticalSourceTranslations(); void dropTranslations(); - QList findDuplicates() const; - void resolveDualEncoded(); void makeFileNamesAbsolute(const QDir &originalPath); + QSet resolveDuplicates(); + static void reportDuplicates(const QSet &dupes, + const QString &fileName, bool verbose); void setCodecName(const QByteArray &name); QByteArray codecName() const { return m_codecName; } diff --git a/tools/linguist/shared/translatormessage.h b/tools/linguist/shared/translatormessage.h index 363019e..7d31925 100644 --- a/tools/linguist/shared/translatormessage.h +++ b/tools/linguist/shared/translatormessage.h @@ -179,6 +179,32 @@ Q_DECLARE_TYPEINFO(TranslatorMessage, Q_MOVABLE_TYPE); int qHash(const TranslatorMessage &msg); +struct TranslatorMessagePtr { + TranslatorMessagePtr(const TranslatorMessage &tm) + { + ptr = &tm; + } + + inline const TranslatorMessage *operator->() const + { + return ptr; + } + + const TranslatorMessage *ptr; +}; + +Q_DECLARE_TYPEINFO(TranslatorMessagePtr, Q_MOVABLE_TYPE); + +static inline int qHash(TranslatorMessagePtr tmp) +{ + return qHash(*tmp.ptr); +} + +static inline bool operator==(TranslatorMessagePtr tmp1, TranslatorMessagePtr tmp2) +{ + return *tmp1.ptr == *tmp2.ptr; +} + QT_END_NAMESPACE #endif // QT_NO_TRANSLATION diff --git a/tools/linguist/shared/ts.cpp b/tools/linguist/shared/ts.cpp index 8a6d365..22f2a1b 100644 --- a/tools/linguist/shared/ts.cpp +++ b/tools/linguist/shared/ts.cpp @@ -242,7 +242,7 @@ bool TSReader::read(Translator &translator) STRING(userdata); STRING(utf8); STRING(value); - STRING(version); + //STRING(version); STRING(yes); static const QString strextrans(QLatin1String("extra-")); @@ -266,15 +266,13 @@ bool TSReader::read(Translator &translator) QString currentFile; QXmlStreamAttributes atts = attributes(); - QString version = atts.value(strversion).toString(); + //QString version = atts.value(strversion).toString(); translator.setLanguageCode(atts.value(strlanguage).toString()); translator.setSourceLanguageCode(atts.value(strsourcelanguage).toString()); while (!atEnd()) { readNext(); if (isEndElement()) { // found, finish local loop - if (version == QLatin1String("1.1")) - translator.resolveDualEncoded(); break; } else if (isWhiteSpace()) { // ignore these, just whitespace -- cgit v0.12 From db36d8397aa21d947abd969ee35e017935705217 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 2 Apr 2009 09:59:19 +0200 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to origin/qtwebkit-4.5 ( 9c6a4a25fe741b43dd64f5dbaeccfb647cb321fb ) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes in WebKit since the last update: ++ b/WebKit/qt/ChangeLog 2009-04-02 Takumi Asaki Reviewed by Simon Hausmann. Fix pre-edit handling of text fields with input methods. The input method sends an empty preeditString() if all characters of the preedit should be deleted. So inputMethodEvent() has to use preeditString() if it's empty. * Api/qwebpage.cpp: (QWebPagePrivate::inputMethodEvent): 2009-03-30 Simon Hausmann Rubber-stamped by Tor Arne Vestbø. Document that setHtml/setContent loads only the html/data immediately, not external objects. * Api/qwebframe.cpp: * Api/qwebview.cpp: --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp | 4 ++++ src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 6 +++--- src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp | 4 ++++ src/3rdparty/webkit/WebKit/qt/ChangeLog | 22 ++++++++++++++++++++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 96840d0..1ebf6ef 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 1beae2b64b5b1e9b97e82dc94de18ebac1c19efc + 9c6a4a25fe741b43dd64f5dbaeccfb647cb321fb diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp index ae71356..5dc6363 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp @@ -534,6 +534,8 @@ void QWebFrame::load(const QNetworkRequest &req, Sets the content of this frame to \a html. \a baseUrl is optional and used to resolve relative URLs in the document, such as referenced images or stylesheets. + The \a html is loaded immediately; external objects are loaded asynchronously. + When using this method WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. It is also possible @@ -558,6 +560,8 @@ void QWebFrame::setHtml(const QString &html, const QUrl &baseUrl) External objects referenced in the content are located relative to \a baseUrl. + The \a data is loaded immediately; external objects are loaded asynchronously. + \sa toHtml() */ void QWebFrame::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index 636b6e8..de37383 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -896,14 +896,14 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) return; } - if (!ev->preeditString().isEmpty()) { + if (!ev->commitString().isEmpty()) + editor->confirmComposition(ev->commitString()); + else { QString preedit = ev->preeditString(); // ### FIXME: use the provided QTextCharFormat (use color at least) Vector underlines; underlines.append(CompositionUnderline(0, preedit.length(), Color(0,0,0), false)); editor->setComposition(preedit, underlines, preedit.length(), 0); - } else if (!ev->commitString().isEmpty()) { - editor->confirmComposition(ev->commitString()); } ev->accept(); } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp index ea503a1..a843eba 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp @@ -289,6 +289,8 @@ void QWebView::load(const QNetworkRequest &request, External objects such as stylesheets or images referenced in the HTML document are located relative to \a baseUrl. + The \a html is loaded immediately; external objects are loaded asynchronously. + When using this method, WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified @@ -309,6 +311,8 @@ void QWebView::setHtml(const QString &html, const QUrl &baseUrl) External objects referenced in the content are located relative to \a baseUrl. + The \a data is loaded immediately; external objects are loaded asynchronously. + \sa load(), setHtml(), QWebFrame::toHtml() */ void QWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 32d27cd..41ca520 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,25 @@ +2009-04-02 Takumi Asaki + + Reviewed by Simon Hausmann. + + Fix pre-edit handling of text fields with input methods. + + The input method sends an empty preeditString() if all characters of + the preedit should be deleted. So inputMethodEvent() has to use + preeditString() if it's empty. + + * Api/qwebpage.cpp: + (QWebPagePrivate::inputMethodEvent): + +2009-03-30 Simon Hausmann + + Rubber-stamped by Tor Arne Vestbø. + + Document that setHtml/setContent loads only the html/data immediately, not external objects. + + * Api/qwebframe.cpp: + * Api/qwebview.cpp: + 2009-03-26 Simon Hausmann Rubber-stamped by Tor Arne Vestbø. -- cgit v0.12 From 212fbb28c5d0d560b46d5c00d457677a5f5d21dd Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Thu, 2 Apr 2009 10:42:23 +0200 Subject: Doc - moving this file to the Creator branch instead. --- doc/src/tutorials/addressbook-sdk.qdoc | 179 --------------------------------- 1 file changed, 179 deletions(-) delete mode 100644 doc/src/tutorials/addressbook-sdk.qdoc diff --git a/doc/src/tutorials/addressbook-sdk.qdoc b/doc/src/tutorials/addressbook-sdk.qdoc deleted file mode 100644 index b6b257d..0000000 --- a/doc/src/tutorials/addressbook-sdk.qdoc +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page tutorials-addressbook-sdk.html - - \startpage {index.html}{Qt Reference Documentation} - \nextpage \l{Designing the User Interface}{Chapter 1} - - \title Address Book Tutorial - \ingroup howto - \ingroup tutorials - \brief An introduction to GUI programming with Qt and Qt Creator, - describing in detail how to put together a simple yet fully- - functioning application. - - This tutorial gives an introduction to GUI programming using the Qt SDK. - - ### Screenshot - - In the process, we will learn about some basic technologies provided by - Qt, such as: - - \list - \o Widgets and layout managers - \o Container classes - \o Signals and slots - \o Input and output devices - \endlist - - If you are completely new to Qt, please read \l{How to Learn Qt} if you - have not already done so. - - The tutorial's source code is located in Qt's - \c{examples/tutorials/addressbook} directory. - - Tutorial chapters: - - \list 1 - \o \l{Designing the User Interface} - \o \l{Adding Addresses} - \o \l{Navigating between Entries} - \o \l{Editing and Removing Addresses} - \o \l{Adding a Find Function} - \o \l{Loading and Saving} - \o \l{Additional Features} - \endlist - - Although this little application does not look much like a fully-fledged - modern GUI application, it uses many of the basic techniques that are used - in more complex applications. After you have worked through it, we - recommend checking out the \l{mainwindows/application}{Application} - example, which presents a small GUI application, with menus, toolbars, a - status bar, and so on. -*/ - - -/*! - \page tutorials-addressbook-sdk-part1.html - \contentspage {Address Book Tutorial}{Contents} - \nextpage \l{Adding Addresses}{Chapter 2} - \title Address Book 1 - Designing the User Interface - - The first part of this tutorial covers the design of the basic graphical - user interface (GUI) we use for the Address Book application. - - The first step to creating a GUI program is to design the user interface. - In this chapter, our goal is to set up the labels and input fields needed - to implement a basic address book application. The figure below is a - screenshot of our expected output. - - \image addressbook-tutorial-part1-screenshot.png - - We begin by launching Qt Creator and use it to generate a new project. To - do this, select \gui New from the \gui File menu. In the - \gui{New File or Project} dialog. Follow the step by step guide on how to - create a \gui Project with Qt Creator, refer to the document - \l{Creating a Project in Qt Creator}{here}. Ensure that you select QWidget - as your subclass and name it \c AddressBook. - - There are five files generated in this \gui{Project}: - - \list - \o \c{addressbook.pro} - the project file, - \o \c{addressbook.h} - the definition file for the \c AddressBook - class, - \o \c{addressbook.cpp} - the implementation file for the - \c AddressBook class, - \o \c{main.cpp} - the file containing a \c main() function, with an - instance of \c AddressBook, and - \o \c{addressbook.ui} - the user interface file created with \QD. - \endlist - - Now we have all the files we need, let's move on to designing the user - interface. - - \section1 Placing the Widgets on the Form - - In the \gui{Project Sidebar}, double-click on the \c{addressbook.ui} file. - The \QD plugin will be launched, allowing you to design your program's user - interface. - - We require two \l{QLabel}s to label the input fields as well as a - QLineEdit and a QTextEdit as the input fields. So, drag those widgets from - the \gui{Widget Box} to your form. In the \gui{Property Editor}, set their - \gui{objectName} property to \c nameLabel and \c addressLabel for the - \l{QLabel}s, \c nameLine for the QLineEdit and finally, \c addressText for - the QTextEdit. - - Next, we have to position the widgets properly, according to the screenshot - earlier. We use a QGridLayout to position our labels and input fields in a - structured manner. QGridLayout divides the available space into a grid and - places widgets in the cells we specify with row and column numbers. The - diagram below shows the layout cells and the position of our widgets. - - \image addressbook-tutorial-part1-labeled-screenshot.png - - - \section1 Qt Programming - Subclassing - - When writing Qt programs, we usually subclass Qt objects to add - functionality. This is one of the essential concepts behind creating custom - widgets or collections of standard widgets. Subclassing to extend or change - the behavior of a widget has the following advantages: - - \list - \o We can write implementations of virtual or pure virtual functions - to obtain exactly what we need, falling back on the base class's - implementation when necessary. - \o It allows us to encapsulate parts of the user interface within a - class, so that the other parts of the application do not need to - know about the individual widgets in the user interface. - \o The subclass can be used to create multiple custom widgets in the - same application or library, and the code for the subclass can be - reused in other projects. - \endlist - - - - -*/ -- cgit v0.12 From 578188ee7899bfabc5ab45758f59acafaa26cc8c Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 1 Apr 2009 15:51:17 +0200 Subject: Wrong property type (QVariant&) generated by ActiveQt This was due to an incorrect type defenition in the typelibrary for a particular COM object. Enven in such cases we should not generate an incorrect type. Task-number: 248612 Reviewed-by: Volker Hilsheimer --- src/activeqt/container/qaxbase.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index 1ec704a..44c3e9e 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -1660,11 +1660,15 @@ private: QMap property_list; void addProperty(const QByteArray &type, const QByteArray &name, uint flags) { + QByteArray propertyType(type); + if (propertyType.endsWith("&")) + propertyType.chop(1); + Property &prop = property_list[name]; - if (!type.isEmpty() && type != "HRESULT") { - prop.type = replaceType(type); - if (prop.type != type) - prop.realType = type; + if (!propertyType.isEmpty() && propertyType != "HRESULT") { + prop.type = replaceType(propertyType); + if (prop.type != propertyType) + prop.realType = propertyType; } if (flags & Writable) flags |= Stored; -- cgit v0.12 From d399b858f9f3c50c82da197cd8bdd05110a092fe Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 2 Apr 2009 11:30:49 +0200 Subject: Compile error on VisualStudio 2005 Reviewed-by: Samuel --- src/gui/painting/qdrawhelper.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 7e73304..ae936fe 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -488,6 +488,15 @@ uint QT_FASTCALL qt_fetchPixel(const ucha return qt_colorConvert(color, 0); } +template<> +Q_STATIC_TEMPLATE_SPECIALIZATION +uint QT_FASTCALL qt_fetchPixel(const uchar *, + int , + const QVector *) +{ + return 0; +} + typedef uint (QT_FASTCALL *FetchPixelProc)(const uchar *scanLine, int x, const QVector *); #define SPANFUNC_POINTER_FETCHPIXEL(Arg) qt_fetchPixel -- cgit v0.12 From 227b0b1e2cfa94912180fb401ddac83a2b5525d7 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 2 Apr 2009 12:49:13 +0200 Subject: Doc: Added a note about copying by value in QMetaProperty and included details about BlockingQueuedConnection in QMetaObject::invokeMethod(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: 187869 Task-number: 216742 Reviewed-by: Thiago Macieira Reviewed-by: Morten Sørvig --- src/corelib/kernel/qmetaobject.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 719398c..b65f956 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1007,6 +1007,11 @@ enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value a QEvent will be sent and the member is invoked as soon as the application enters the main event loop. + \o If \a type is Qt::BlockingQueuedConnection, the method will be invoked in + the same way as for Qt::QueuedConnection, except that the current thread + will block until the event is delivered. Using this connection type to + communicate between objects in the same thread will lead to deadlocks. + \o If \a type is Qt::AutoConnection, the member is invoked synchronously if \a obj lives in the same thread as the caller; otherwise it will invoke the member asynchronously. @@ -1897,6 +1902,12 @@ static QByteArray qualifiedName(const QMetaEnum &e) \ingroup objectmodel + Property meta-data is obtained from an object's meta-object. See + QMetaObject::property() and QMetaObject::propertyCount() for + details. + + \section1 Property Meta-Data + A property has a name() and a type(), as well as various attributes that specify its behavior: isReadable(), isWritable(), isDesignable(), isScriptable(), and isStored(). @@ -1912,9 +1923,10 @@ static QByteArray qualifiedName(const QMetaEnum &e) functions. See QObject::setProperty() and QObject::property() for details. - You get property meta-data through an object's meta-object. See - QMetaObject::property() and QMetaObject::propertyCount() for - details. + \section1 Copying and Assignment + + QMetaProperty objects can be copied by value. However, each copy will + refer to the same underlying property meta-data. \sa QMetaObject, QMetaEnum, QMetaMethod, {Qt's Property System} */ -- cgit v0.12 From e008504b5ec34975e34adf3b1a2b7170d0e4dd38 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Thu, 2 Apr 2009 12:45:38 +0200 Subject: Fixing some CoreText errors. Apparently CoreText is too good for us and always gives us fractional information. Which would be food for design metrics, but not good for drawing to the screen. The upshot of it is that we do the ceiling of every value we get. This is as stop gap solution for the moment. Things in Creator should look better now. Also added the ability to disable kerning. Reviewed-by: Simon Hausmann --- src/gui/text/qfontengine_mac.mm | 31 ++++++++++++++++++------------- src/gui/text/qfontengine_p.h | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 40d145a..425cab2 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -120,7 +120,7 @@ OSStatus QMacFontPath::closePath(void *data) #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool) +QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning) : QFontEngineMulti(0) { this->fontDef = fontDef; @@ -149,11 +149,15 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con CFRetain(ctfont); } - const void *keys[] = { NSFontAttributeName }; - const void *values[] = { ctfont }; - attributeDict = CFDictionaryCreate(0, keys, values, 1, + attributeDict = CFDictionaryCreateMutable(0, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + CFDictionaryAddValue(attributeDict, NSFontAttributeName, ctfont); + if (!kerning) { + float zero = 0.0; + QCFType noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero); + CFDictionaryAddValue(attributeDict, kCTKernAttributeName, &noKern); + } QCoreTextFontEngine *fe = new QCoreTextFontEngine(ctfont, fontDef, this); fe->ref.ref(); @@ -277,10 +281,11 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x); outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i + 1].y - tmpPoints[i].y); } - double runWidth = ceil(CTRunGetTypographicBounds(run, range, 0, 0, 0)); - runWidth += tmpPoints[0].x; + CGSize lastGlyphAdvance; + CTFontGetAdvancesForGlyphs(runFont, kCTFontHorizontalOrientation, tmpGlyphs + glyphCount - 1, &lastGlyphAdvance, 1); + outGlyphs[rtl ? 0 : (glyphCount - 1)] = tmpGlyphs[glyphCount - 1] | fontIndex; - outAdvances_x[rtl ? 0 : (glyphCount - 1)] = QFixed::fromReal(runWidth - tmpPoints[glyphCount - 1].x); + outAdvances_x[rtl ? 0 : (glyphCount - 1)] = QFixed::fromReal(lastGlyphAdvance.width).ceil(); } outGlyphs += glyphCount; outAttributes += glyphCount; @@ -365,26 +370,26 @@ glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph) ret.y = -QFixed::fromReal(rect.origin.y) - ret.height; CGSize advances[1]; CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, advances, 1); - ret.xoff = QFixed::fromReal(advances[0].width); - ret.yoff = QFixed::fromReal(advances[0].height); + ret.xoff = QFixed::fromReal(advances[0].width).ceil(); + ret.yoff = QFixed::fromReal(advances[0].height).ceil(); return ret; } QFixed QCoreTextFontEngine::ascent() const { - return QFixed::fromReal(CTFontGetAscent(ctfont)); + return QFixed::fromReal(CTFontGetAscent(ctfont)).ceil(); } QFixed QCoreTextFontEngine::descent() const { - return QFixed::fromReal(CTFontGetDescent(ctfont)); + return QFixed::fromReal(CTFontGetDescent(ctfont)).ceil(); } QFixed QCoreTextFontEngine::leading() const { - return QFixed::fromReal(CTFontGetLeading(ctfont)); + return QFixed::fromReal(CTFontGetLeading(ctfont)).ceil(); } QFixed QCoreTextFontEngine::xHeight() const { - return QFixed::fromReal(CTFontGetXHeight(ctfont)); + return QFixed::fromReal(CTFontGetXHeight(ctfont)).ceil(); } QFixed QCoreTextFontEngine::averageCharWidth() const { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index e289aa9..176c728 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -480,7 +480,7 @@ private: uint fontIndexForFont(CTFontRef id) const; CTFontRef ctfont; - mutable QCFType attributeDict; + mutable QCFType attributeDict; friend class QFontDialogPrivate; }; -- cgit v0.12 From 7887095d3a95335251e5c82c3ac7069c5d05a30d Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 2 Apr 2009 13:19:25 +0200 Subject: fix 223949: Qt's translation should be installed only if Linguists translation is found --- tools/linguist/linguist/main.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/linguist/linguist/main.cpp b/tools/linguist/linguist/main.cpp index 018fbc5..a6a0d27 100644 --- a/tools/linguist/linguist/main.cpp +++ b/tools/linguist/linguist/main.cpp @@ -80,12 +80,15 @@ int main(int argc, char **argv) } QTranslator translator; - translator.load(QLatin1String("linguist_") + QLocale::system().name(), resourceDir); - app.installTranslator(&translator); - QTranslator qtTranslator; - qtTranslator.load(QLatin1String("qt_") + QLocale::system().name(), resourceDir); - app.installTranslator(&qtTranslator); + QString sysLocale = QLocale::system().name(); + if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)) { + app.installTranslator(&translator); + if (qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) + app.installTranslator(&qtTranslator); + else + app.removeTranslator(&translator); + } app.setOrganizationName(QLatin1String("Trolltech")); app.setApplicationName(QLatin1String("Linguist")); -- cgit v0.12 From ca582d6cb205461cfcdf448749b46ee654faa5fd Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 2 Apr 2009 13:19:42 +0200 Subject: Improved stylesheet support for setting background and foreground roles This makes sure that style sheets set both ButtonText and WindowText roles for all widgets. This fixes among other things the fact that you could not configure text colors for combo box popups on Mac, Gtk and CleanLooks or set the background for the whole scrollbar. Task-number: 160713 Reviewed-by: ogoffart --- src/gui/styles/gtksymbols.cpp | 4 ++-- src/gui/styles/qgtkstyle.cpp | 10 +++++++++- src/gui/styles/qstylesheetstyle.cpp | 26 +++++++------------------- src/gui/widgets/qcombobox.cpp | 2 +- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index 3fbf233..f60c980 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -529,14 +529,14 @@ void QGtk::applyGtkSystemPalette(QWidget *widget) ensureWidgetPalette(menubar, QLS("GtkMenuBar")); else if (QToolBar *toolbar = qobject_cast (widget)) ensureWidgetPalette(toolbar, QLS("GtkToolbar")); - else if (QMenu *menubar = qobject_cast (widget)) { + else if (QMenu *menu = qobject_cast (widget)) { // This really applies to the combo box rendering since // QComboBox copies the palette from a QMenu QPalette pal = widget->palette(); GdkColor gdkBg = QGtk::gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL]; QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); pal.setBrush(QPalette::Base, bgColor); - menubar->setPalette(pal); + menu->setPalette(pal); } widget->setAttribute(Qt::WA_SetPalette, false); } diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 582962a..81d7cb8 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -2593,16 +2593,24 @@ void QGtkStyle::drawControl(ControlElement element, opt.rect = vCheckRect; drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); } - painter->drawPixmap(pmr.topLeft(), pixmap); } GdkColor gdkText = gtkMenuItem->style->fg[GTK_STATE_NORMAL]; GdkColor gdkDText = gtkMenuItem->style->fg[GTK_STATE_INSENSITIVE]; GdkColor gdkHText = gtkMenuItem->style->fg[GTK_STATE_PRELIGHT]; + uint resolve_mask = option->palette.resolve(); QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8); + if (resolve_mask & (1 << QPalette::ButtonText)) { + textColor = option->palette.buttonText().color(); + disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText);; + } + QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8); + if (resolve_mask & (1 << QPalette::HighlightedText)) { + highlightedTextColor = option->palette.highlightedText().color(); + } if (selected) painter->setPen(highlightedTextColor); diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index a39eeb7..49ac57a 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1514,20 +1514,11 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const QWidget *w, bool embedded) { -#ifdef QT_NO_COMBOBOX - const bool isReadOnlyCombo = false; -#else - const bool isReadOnlyCombo = qobject_cast(w) != 0; -#endif - if (bg && bg->brush.style() != Qt::NoBrush) { - if (isReadOnlyCombo) { - p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp - p->setBrush(cg, QPalette::Button, bg->brush); // for plastique - } else { - p->setBrush(cg, w->backgroundRole(), bg->brush); - //p->setBrush(cg, QPalette::Window, bg->brush); - } + p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp + p->setBrush(cg, QPalette::Button, bg->brush); // for plastique + p->setBrush(cg, w->backgroundRole(), bg->brush); + p->setBrush(cg, QPalette::Window, bg->brush); } if (embedded) { @@ -1542,12 +1533,9 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q return; if (pal->foreground.style() != Qt::NoBrush) { - if (isReadOnlyCombo) { - p->setBrush(cg, QPalette::ButtonText, pal->foreground); - } else { - p->setBrush(cg, w->foregroundRole(), pal->foreground); - p->setBrush(cg, QPalette::WindowText, pal->foreground); - } + p->setBrush(cg, QPalette::ButtonText, pal->foreground); + p->setBrush(cg, w->foregroundRole(), pal->foreground); + p->setBrush(cg, QPalette::WindowText, pal->foreground); p->setBrush(cg, QPalette::Text, pal->foreground); } if (pal->selectionBackground.style() != Qt::NoBrush) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index c7e2590..09a51fe 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -109,7 +109,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt const QModelIndex &index) const { QStyleOptionMenuItem menuOption; - menuOption.palette = QComboBoxPrivate::viewContainerPalette(mCombo).resolve(QApplication::palette("QMenu")); + menuOption.palette = option.palette.resolve(QApplication::palette("QMenu")); menuOption.state = QStyle::State_None; if (mCombo->window()->isActiveWindow()) menuOption.state = QStyle::State_Active; -- cgit v0.12 From 975a9ed5ee3de9c720cc103923fe1a4f6665a4c6 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Thu, 2 Apr 2009 13:26:06 +0200 Subject: Doc - fixing a broken link in the documentation of QWebPage Reviewed-by: Simon Hausmann --- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index de37383..14288e2 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -1095,7 +1095,7 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const This enum describes the types of action which can be performed on the web page. Actions only have an effect when they are applicable. The availability of - actions can be be determined by checking \l{QAction::}{enabled()} on the + actions can be be determined by checking \l{QAction::}{isEnabled()} on the action returned by \l{QWebPage::}{action()}. One method of enabling the text editing, cursor movement, and text selection actions -- cgit v0.12 From 16f691bad83a29c7c7fdeb3398a3fdadfdaa2949 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 2 Apr 2009 13:27:25 +0200 Subject: Completed 4.5.1 changelog for Designer/uic. --- dist/changes-4.5.1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/changes-4.5.1 b/dist/changes-4.5.1 index 4e3fcc7..fac0b5d 100644 --- a/dist/changes-4.5.1 +++ b/dist/changes-4.5.1 @@ -80,7 +80,13 @@ Qt for Windows CE - Designer - + * [249097] Fixed a crash related to undoing a QGridLayout re-layouting + operation. + * [247995] Fixed a crash occurring after layout operations that cause + an instance of QGridLayout or QFormLayout to shrink. + * [248000] Fixed a crash ocurring when re-layouting empty grid layouts. + * [245961] Restricted objectname-validation to known object name + properties only. - Linguist - Linguist GUI @@ -97,7 +103,11 @@ Qt for Windows CE - uic - + * [244998] Fixed include file generation for phonon widgets. + * [248070] Fixed code generation for QStringList-type properties to use + encoding properly. + * [242447] Made uic generate class-specific code correctly in the case + of multiple levels of inheritance. - uic3 -- cgit v0.12 From ba1dee09daef790883e53d91f4f02865c75e6d57 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 2 Apr 2009 13:27:03 +0200 Subject: cosmetic bug in qmake msvc_nmake generator fixed When generating nmake makefiles, the same inference rules were generated several times. Reviewed-by: mariusSO --- qmake/generators/win32/msvc_nmake.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 4b1b66d..b5904cc 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -244,14 +244,14 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) project->variables().remove("QMAKE_RUN_CC"); QHash source_directories; - source_directories.insertMulti(".", (void*)1); + source_directories.insert(".", (void*)1); QString directories[] = { QString("UI_SOURCES_DIR"), QString("UI_DIR"), QString() }; for(int y = 0; !directories[y].isNull(); y++) { QString dirTemp = project->first(directories[y]); if (dirTemp.endsWith("\\")) dirTemp.truncate(dirTemp.length()-1); if(!dirTemp.isEmpty()) - source_directories.insertMulti(dirTemp, (void*)1); + source_directories.insert(dirTemp, (void*)1); } QString srcs[] = { QString("SOURCES"), QString("GENERATED_SOURCES"), QString() }; for(int x = 0; !srcs[x].isNull(); x++) { @@ -262,7 +262,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) sep = "/"; QString dir = (*sit).section(sep, 0, -2); if(!dir.isEmpty() && !source_directories[dir]) - source_directories.insertMulti(dir, (void*)1); + source_directories.insert(dir, (void*)1); } } -- cgit v0.12 From c02ad8a6f03fb2c23e854783e7620a5a43d991c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 1 Apr 2009 18:21:37 +0200 Subject: Improve performance of text blitting in raster paint engine. Use INTERPOLATE_PIXEL_255 instead of two BYTE_MUL's. Reviewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index ae936fe..789d96a 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -7077,7 +7077,7 @@ static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer, #endif { int ialpha = 255 - coverage; - dest[i] = BYTE_MUL(c, uint(coverage)) + BYTE_MUL(dest[i], ialpha); + dest[i] = INTERPOLATE_PIXEL_255(c, coverage, dest[i], ialpha); } } } @@ -7118,7 +7118,7 @@ static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer, #endif { int ialpha = 255 - coverage; - dest[xp] = BYTE_MUL(c, uint(coverage)) + BYTE_MUL(dest[xp], ialpha); + dest[xp] = INTERPOLATE_PIXEL_255(c, coverage, dest[xp], ialpha); } } -- cgit v0.12 From 2b47dac1f7e0822e9ac2ef1ce98746e35faf995d Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 2 Apr 2009 15:07:01 +0200 Subject: Implement the filter for resource browser Task: 249659 Reviewed-by: Friedemann Kleint --- tools/designer/src/lib/shared/qtresourceview.cpp | 189 +++++++++++++++++++---- tools/designer/src/lib/shared/qtresourceview_p.h | 1 + 2 files changed, 164 insertions(+), 26 deletions(-) diff --git a/tools/designer/src/lib/shared/qtresourceview.cpp b/tools/designer/src/lib/shared/qtresourceview.cpp index d956491..2b59605 100644 --- a/tools/designer/src/lib/shared/qtresourceview.cpp +++ b/tools/designer/src/lib/shared/qtresourceview.cpp @@ -44,6 +44,7 @@ #include "qtresourcemodel_p.h" #include "qtresourceeditordialog_p.h" #include "iconloader_p.h" +#include "filterwidget_p.h" // For FilterWidget #include @@ -144,6 +145,7 @@ public: void slotReloadResources(); void slotCopyResourcePath(); void slotListWidgetContextMenuRequested(const QPoint &pos); + void slotFilterChanged(const QString &pattern); void createPaths(); QTreeWidgetItem *createPath(const QString &path, QTreeWidgetItem *parent); void createResources(const QString &path); @@ -152,16 +154,20 @@ public: void restoreSettings(); void saveSettings(); void updateActions(); + void filterOutResources(); QPixmap makeThumbnail(const QPixmap &pix) const; QDesignerFormEditorInterface *m_core; QtResourceModel *m_resourceModel; QToolBar *m_toolBar; + qdesigner_internal::FilterWidget *m_filterWidget; QTreeWidget *m_treeWidget; QListWidget *m_listWidget; QSplitter *m_splitter; - QMap m_pathToContents; // full path to contents file names + QMap m_pathToContents; // full path to contents file names (full path to its resource filenames) + QMap m_pathToParentPath; // full path to full parent path + QMap m_pathToSubPaths; // full path to full sub paths QMap m_pathToItem; QMap m_itemToPath; QMap m_resourceToItem; @@ -175,6 +181,7 @@ public: bool m_ignoreGuiSignals; QString m_settingsKey; bool m_resourceEditingEnabled; + QString m_filterPattern; }; QtResourceViewPrivate::QtResourceViewPrivate(QDesignerFormEditorInterface *core) : @@ -251,6 +258,12 @@ void QtResourceViewPrivate::slotListWidgetContextMenuRequested(const QPoint &pos menu.exec(m_listWidget->mapToGlobal(pos)); } +void QtResourceViewPrivate::slotFilterChanged(const QString &pattern) +{ + m_filterPattern = pattern; + filterOutResources(); +} + void QtResourceViewPrivate::storeExpansionState() { QMapIterator it(m_pathToItem); @@ -294,6 +307,7 @@ void QtResourceViewPrivate::updateActions() m_editResourcesAction->setVisible(m_resourceEditingEnabled); m_editResourcesAction->setEnabled(resourceActive); m_reloadResourcesAction->setEnabled(resourceActive); + m_filterWidget->setEnabled(resourceActive); } void QtResourceViewPrivate::slotResourceSetActivated(QtResourceSet *resourceSet) @@ -307,6 +321,8 @@ void QtResourceViewPrivate::slotResourceSetActivated(QtResourceSet *resourceSet) const QString currentResource = m_itemToResource.value(m_listWidget->currentItem()); m_treeWidget->clear(); m_pathToContents.clear(); + m_pathToParentPath.clear(); + m_pathToSubPaths.clear(); m_pathToItem.clear(); m_itemToPath.clear(); m_listWidget->clear(); @@ -320,6 +336,7 @@ void QtResourceViewPrivate::slotResourceSetActivated(QtResourceSet *resourceSet) q_ptr->selectResource(currentResource); else if (!currentPath.isEmpty()) q_ptr->selectResource(currentPath); + filterOutResources(); } void QtResourceViewPrivate::slotCurrentPathChanged(QTreeWidgetItem *item) @@ -362,9 +379,6 @@ void QtResourceViewPrivate::createPaths() const QString root(QLatin1Char(':')); - QMap pathToParentPath; // full path to full parent path - QMap pathToSubPaths; // full path to full sub paths - QMap contents = m_resourceModel->contents(); QMapIterator itContents(contents); while (itContents.hasNext()) { @@ -372,11 +386,11 @@ void QtResourceViewPrivate::createPaths() const QFileInfo fi(filePath); QString dirPath = fi.absolutePath(); m_pathToContents[dirPath].append(fi.fileName()); - while (!pathToParentPath.contains(dirPath) && dirPath != root) { + while (!m_pathToParentPath.contains(dirPath) && dirPath != root) { // create all parent paths const QFileInfo fd(dirPath); const QString parentDirPath = fd.absolutePath(); - pathToParentPath[dirPath] = parentDirPath; - pathToSubPaths[parentDirPath].append(dirPath); + m_pathToParentPath[dirPath] = parentDirPath; + m_pathToSubPaths[parentDirPath].append(dirPath); dirPath = parentDirPath; } } @@ -387,13 +401,126 @@ void QtResourceViewPrivate::createPaths() QPair pathToParentItem = pathToParentItemQueue.dequeue(); const QString path = pathToParentItem.first; QTreeWidgetItem *item = createPath(path, pathToParentItem.second); - QStringList subPaths = pathToSubPaths.value(path); + QStringList subPaths = m_pathToSubPaths.value(path); QStringListIterator itSubPaths(subPaths); while (itSubPaths.hasNext()) pathToParentItemQueue.enqueue(qMakePair(itSubPaths.next(), item)); } } +void QtResourceViewPrivate::filterOutResources() +{ + QMap pathToMatchingContents; // true means the path has any matching contents + QMap pathToVisible; // true means the path has to be shown + + // 1) we go from root path recursively. + // 2) we check every path if it contains at least one matching resource - if empty we add it + // to pathToMatchingContents and pathToVisible with false, if non empty + // we add it with true and change every parent path in pathToVisible to true. + // 3) we hide these items which has pathToVisible value false. + + const bool matchAll = m_filterPattern.isEmpty(); + const QString root(QLatin1Char(':')); + + QQueue pathQueue; + pathQueue.enqueue(root); + while (!pathQueue.isEmpty()) { + const QString path = pathQueue.dequeue(); + + QStringList fileNames = m_pathToContents.value(path); + QStringListIterator it(fileNames); + bool hasContents = matchAll; + if (!matchAll) { // the case filter is not empty - we check if the path contains anything + while (it.hasNext()) { + QString fileName = it.next(); + hasContents = fileName.contains(m_filterPattern, Qt::CaseInsensitive); + if (hasContents) // the path contains at least one resource which matches the filter + break; + } + } + + pathToMatchingContents[path] = hasContents; + pathToVisible[path] = hasContents; + + if (hasContents) { // if the path is going to be shown we need to show all its parent paths + QString parentPath = m_pathToParentPath.value(path); + while (!parentPath.isEmpty()) { + QString p = parentPath; + if (pathToVisible.value(p)) // parent path is already shown, we break the loop + break; + pathToVisible[p] = true; + parentPath = m_pathToParentPath.value(p); + } + } + + QStringList subPaths = m_pathToSubPaths.value(path); // we do the same for children paths + QStringListIterator itSubPaths(subPaths); + while (itSubPaths.hasNext()) + pathQueue.enqueue(itSubPaths.next()); + } + + // we setup here new path and resource to be activated + const QString currentPath = m_itemToPath.value(m_treeWidget->currentItem()); + QString newCurrentPath = currentPath; + QString currentResource = m_itemToResource.value(m_listWidget->currentItem()); + if (!matchAll) { + bool searchForNewPathWithContents = true; + + if (!currentPath.isEmpty()) { // if the currentPath is empty we will search for a new path too + QMap::ConstIterator it = pathToMatchingContents.constFind(currentPath); + if (it != pathToMatchingContents.constEnd() && it.value()) // the current item has contents, we don't need to search for another path + searchForNewPathWithContents = false; + } + + if (searchForNewPathWithContents) { + // we find the first path with the matching contents + QMap::ConstIterator itContents = pathToMatchingContents.constBegin(); + while (itContents != pathToMatchingContents.constEnd()) { + if (itContents.value()) { + newCurrentPath = itContents.key(); // the new path will be activated + break; + } + + itContents++; + } + } + + QFileInfo fi(currentResource); + if (!fi.fileName().contains(m_filterPattern, Qt::CaseInsensitive)) { // the case when the current resource is filtered out + const QStringList fileNames = m_pathToContents.value(newCurrentPath); + QStringListIterator it(fileNames); + while (it.hasNext()) { // we try to select the first matching resource from the newCurrentPath + QString fileName = it.next(); + if (fileName.contains(m_filterPattern, Qt::CaseInsensitive)) { + QDir dirPath(newCurrentPath); + currentResource = dirPath.absoluteFilePath(fileName); // the new resource inside newCurrentPath will be activated + break; + } + } + } + } + + QTreeWidgetItem *newCurrentItem = m_pathToItem.value(newCurrentPath); + if (currentPath != newCurrentPath) + m_treeWidget->setCurrentItem(newCurrentItem); + else + slotCurrentPathChanged(newCurrentItem); // trigger filtering on the current path + + QListWidgetItem *currentResourceItem = m_resourceToItem.value(currentResource); + if (currentResourceItem) { + m_listWidget->setCurrentItem(currentResourceItem); + m_listWidget->scrollToItem(currentResourceItem); + } + + QMapIterator it(pathToVisible); // hide all paths filtered out + while (it.hasNext()) { + const QString path = it.next().key(); + QTreeWidgetItem *item = m_pathToItem.value(path); + if (item) + item->setHidden(!it.value()); + } +} + QTreeWidgetItem *QtResourceViewPrivate::createPath(const QString &path, QTreeWidgetItem *parent) { QTreeWidgetItem *item = 0; @@ -417,27 +544,32 @@ QTreeWidgetItem *QtResourceViewPrivate::createPath(const QString &path, QTreeWid void QtResourceViewPrivate::createResources(const QString &path) { + const bool matchAll = m_filterPattern.isEmpty(); + QDir dir(path); - QStringList files = m_pathToContents.value(path); - QStringListIterator it(files); + QStringList fileNames = m_pathToContents.value(path); + QStringListIterator it(fileNames); while (it.hasNext()) { - QString file = it.next(); - QString filePath = dir.absoluteFilePath(file); - QFileInfo fi(filePath); - if (fi.isFile()) { - QListWidgetItem *item = new QListWidgetItem(fi.fileName(), m_listWidget); - const QPixmap pix = QPixmap(filePath); - if (pix.isNull()) { - item->setToolTip(filePath); - } else { - item->setIcon(QIcon(makeThumbnail(pix))); - const QSize size = pix.size(); - item->setToolTip(QtResourceView::tr("Size: %1 x %2\n%3").arg(size.width()).arg(size.height()).arg(filePath)); + QString fileName = it.next(); + const bool showProperty = matchAll || fileName.contains(m_filterPattern, Qt::CaseInsensitive); + if (showProperty) { + QString filePath = dir.absoluteFilePath(fileName); + QFileInfo fi(filePath); + if (fi.isFile()) { + QListWidgetItem *item = new QListWidgetItem(fi.fileName(), m_listWidget); + const QPixmap pix = QPixmap(filePath); + if (pix.isNull()) { + item->setToolTip(filePath); + } else { + item->setIcon(QIcon(makeThumbnail(pix))); + const QSize size = pix.size(); + item->setToolTip(QtResourceView::tr("Size: %1 x %2\n%3").arg(size.width()).arg(size.height()).arg(filePath)); + } + item->setFlags(item->flags() | Qt::ItemIsDragEnabled); + item->setData(Qt::UserRole, filePath); + m_itemToResource[item] = filePath; + m_resourceToItem[filePath] = item; } - item->setFlags(item->flags() | Qt::ItemIsDragEnabled); - item->setData(Qt::UserRole, filePath); - m_itemToResource[item] = filePath; - m_resourceToItem[filePath] = item; } } } @@ -464,6 +596,11 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare connect(d_ptr->m_copyResourcePathAction, SIGNAL(triggered()), this, SLOT(slotCopyResourcePath())); d_ptr->m_copyResourcePathAction->setEnabled(false); + //d_ptr->m_filterWidget = new qdesigner_internal::FilterWidget(0, qdesigner_internal::FilterWidget::LayoutAlignNone); + d_ptr->m_filterWidget = new qdesigner_internal::FilterWidget(d_ptr->m_toolBar); + d_ptr->m_toolBar->addWidget(d_ptr->m_filterWidget); + connect(d_ptr->m_filterWidget, SIGNAL(filterChanged(QString)), this, SLOT(slotFilterChanged(QString))); + d_ptr->m_splitter = new QSplitter; d_ptr->m_splitter->setChildrenCollapsible(false); d_ptr->m_splitter->addWidget(d_ptr->m_treeWidget); diff --git a/tools/designer/src/lib/shared/qtresourceview_p.h b/tools/designer/src/lib/shared/qtresourceview_p.h index 33162c5..f78c5af 100644 --- a/tools/designer/src/lib/shared/qtresourceview_p.h +++ b/tools/designer/src/lib/shared/qtresourceview_p.h @@ -113,6 +113,7 @@ private: Q_PRIVATE_SLOT(d_func(), void slotReloadResources()) Q_PRIVATE_SLOT(d_func(), void slotCopyResourcePath()) Q_PRIVATE_SLOT(d_func(), void slotListWidgetContextMenuRequested(const QPoint &pos)) + Q_PRIVATE_SLOT(d_func(), void slotFilterChanged(const QString &pattern)) }; class QDESIGNER_SHARED_EXPORT QtResourceViewDialog : public QDialog -- cgit v0.12 From ceb253c234f840f7aeec10fa4450e840c6b242f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 2 Apr 2009 15:58:33 +0200 Subject: Don't need to update visibility and enabled if the item is destructing This actually caused a crash, since we would call the pure virtual boundingRect() function in setVisibleHelper(). (The 'update' argument was set to true.) Reviewed-by: andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 17 +++++++++-------- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 25 ++++++++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 11a37f5..c5f5889 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -854,15 +854,16 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de updateAncestorFlag(QGraphicsItem::ItemClipsChildrenToShape); updateAncestorFlag(QGraphicsItem::ItemIgnoresTransformations); - // Update item visible / enabled. - if (!visible && !explicitlyHidden) - setVisibleHelper(true, /* explicit = */ false); - if (!enabled && !explicitlyDisabled) - setEnabledHelper(true, /* explicit = */ false); - - // If the item is being deleted, the whole scene will be updated. - if (!deleting) + if (!deleting) { + // Update item visible / enabled. + if (!visible && !explicitlyHidden) + setVisibleHelper(true, /* explicit = */ false); + if (!enabled && !explicitlyDisabled) + setEnabledHelper(true, /* explicit = */ false); + + // If the item is being deleted, the whole scene will be updated. updateHelper(); + } } if (scene) { diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 7964c9b..af40e67 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -512,6 +512,17 @@ void tst_QGraphicsItem::destruction() QCOMPARE(itemDeleted, 59); } QCOMPARE(itemDeleted, 109); + { + QGraphicsScene *scene = new QGraphicsScene; + QGraphicsRectItem *parent = new QGraphicsRectItem; + Item *child = new Item; + child->setParentItem(parent); + parent->setVisible(false); + scene->addItem(parent); + QCOMPARE(child->parentItem(), parent); + delete scene; + QCOMPARE(itemDeleted, 110); + } } void tst_QGraphicsItem::deleteChildItem() @@ -4499,7 +4510,7 @@ void tst_QGraphicsItem::itemClipsChildrenToShape2() QPainter painter(&image); scene.render(&painter); painter.end(); - + QCOMPARE(image.pixel(5, 5), QColor(0, 0, 255).rgba()); QCOMPARE(image.pixel(5, 10), QRgb(0)); QCOMPARE(image.pixel(10, 5), QRgb(0)); @@ -5156,7 +5167,7 @@ void tst_QGraphicsItem::task240400_clickOnTextItem() QVERIFY(selectable ? item->isSelected() : !item->isSelected()); - // + // if (textFlags & Qt::TextEditorInteraction) QVERIFY(item->textCursor().columnNumber() > column); else @@ -5169,7 +5180,7 @@ void tst_QGraphicsItem::task243707_addChildBeforeParent() // inconsistent internal state that can cause a crash. This test shows // one such crash. QGraphicsScene scene; - QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget *widget = new QGraphicsWidget; QGraphicsWidget *widget2 = new QGraphicsWidget(widget); scene.addItem(widget2); QVERIFY(!widget2->parentItem()); @@ -5285,7 +5296,7 @@ void tst_QGraphicsItem::itemTransform_unrelated() QCOMPARE(stranger1->itemTransform(stranger2).map(QPointF(10, 10)), QPointF(10, 10)); QCOMPARE(stranger2->itemTransform(stranger1).map(QPointF(10, 10)), QPointF(10, 10)); } - + void tst_QGraphicsItem::opacity_data() { QTest::addColumn("p_opacity"); @@ -5494,7 +5505,7 @@ void tst_QGraphicsItem::nestedClipping() l1->setData(0, "l1"); l2->setData(0, "l2"); l3->setData(0, "l3"); - + QGraphicsView view(&scene); view.show(); #ifdef Q_WS_X11 @@ -5522,7 +5533,7 @@ void tst_QGraphicsItem::nestedClipping() QCOMPARE(image.pixel(80, 130), qRgba(255, 255, 0, 255)); QCOMPARE(image.pixel(92, 105), qRgba(0, 255, 0, 255)); QCOMPARE(image.pixel(105, 105), qRgba(0, 0, 255, 255)); -#if 0 +#if 0 // Enable this to compare if the test starts failing. image.save("nestedClipping_reference.png"); #endif @@ -5664,7 +5675,7 @@ void tst_QGraphicsItem::tabChangesFocus_data() void tst_QGraphicsItem::tabChangesFocus() { QFETCH(bool, tabChangesFocus); - + QGraphicsScene scene; QGraphicsTextItem *item = scene.addText("Hello"); item->setTabChangesFocus(tabChangesFocus); -- cgit v0.12 From a2fcc4a5ae6addf3688a3686cc89ae20d5426242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 26 Mar 2009 16:00:14 +0100 Subject: QFile::rename didn't always return false when method failed The fallback implementation for rename would return true in some situations where the move failed. Also the destination file might be created and left there in these cases. Task-number: 244500 Reviewed-by: mariusSO --- src/corelib/io/qfile.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index d8f08c9..986c6f5 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -731,10 +731,16 @@ QFile::rename(const QString &newName) } if (read == -1) { d->setError(QFile::RenameError, in.errorString()); - return true; + error = true; + } + if(!error) { + if (!in.remove()) { + d->setError(QFile::RenameError, tr("Cannot remove source file")); + error = true; + } } - if(!error) - in.remove(); + if (error) + out.remove(); return !error; } } -- cgit v0.12 From 8d50038174faf315a389010af3a680d865f6843a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 26 Mar 2009 16:53:18 +0100 Subject: Renaming a file does not change QFile's fileName QFile made no attempt to reset the file name on a rename. We now reset the fileEngine's fileName if it was able to handle the rename. Otherwise, we call setFileName, which will result in reallocation of the fileEngine. Task-number: 244485 Reviewed-by: mariusSO --- src/corelib/io/qfile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 986c6f5..f0a6676 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -712,6 +712,9 @@ QFile::rename(const QString &newName) if(error() == QFile::NoError) { if (fileEngine()->rename(newName)) { unsetError(); + // engine was able to handle the new name so we just reset it + fileEngine()->setFileName(newName); + d->fileName = newName; return true; } @@ -741,6 +744,8 @@ QFile::rename(const QString &newName) } if (error) out.remove(); + else + setFileName(newName); return !error; } } -- cgit v0.12 From 57ec397f66e611c7802c8cdbb8a0232b91ac78f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 2 Apr 2009 11:15:03 +0200 Subject: Delete temporary file if copy was unsuccessful This is an untested bugfix -- comes solely from reading the code. In QFile::copy's fallback implementation a (temporary) file is created for block copying from the source file. When Qt is built without temporary file support this doesn't seem to be deleted in case of an error while block copying or renaming to the final destination. Reviewed-by: mariusSO --- src/corelib/io/qfile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index f0a6676..d7da800 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -900,7 +900,10 @@ QFile::copy(const QString &newName) error = true; d->setError(QFile::CopyError, tr("Cannot create %1 for output").arg(newName)); } -#ifndef QT_NO_TEMPORARYFILE +#ifdef QT_NO_TEMPORARYFILE + if (error) + out.remove(); +#else if (!error) out.setAutoRemove(false); #endif -- cgit v0.12 From d9e3fd083217f3b03f211d64e7d78b36da90bf51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 19 Mar 2009 12:37:02 +0100 Subject: Remove dependency on Qt3 support from qmake tests Qt3 support prevented the tests from running on Mac Cocoa. Also started some Spring cleaning (it's just around the corner!) and applied some YAGNI :-) Reviewed-by: NRC Reviewed-by: mariusSO --- tests/auto/qmake/qmake.pro | 2 - tests/auto/qmake/testcompiler.cpp | 205 ++++++++++---------------------------- tests/auto/qmake/testcompiler.h | 29 ++---- tests/auto/qmake/tst_qmake.cpp | 16 ++- 4 files changed, 67 insertions(+), 185 deletions(-) diff --git a/tests/auto/qmake/qmake.pro b/tests/auto/qmake/qmake.pro index 59cc2be..8cae6be 100644 --- a/tests/auto/qmake/qmake.pro +++ b/tests/auto/qmake/qmake.pro @@ -2,8 +2,6 @@ load(qttest_p4) HEADERS += testcompiler.h SOURCES += tst_qmake.cpp testcompiler.cpp -contains(QT_CONFIG, qt3support): QT += qt3support - cross_compile: DEFINES += QMAKE_CROSS_COMPILED diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp index bfc8905..c25b851 100644 --- a/tests/auto/qmake/testcompiler.cpp +++ b/tests/auto/qmake/testcompiler.cpp @@ -44,9 +44,7 @@ #include #include -#ifdef QT3_SUPPORT - -#include +#include #include #ifdef Q_OS_WIN32 # include @@ -59,6 +57,7 @@ QString targetName( BuildType buildMode, const QString& target, const QString& version ) { + Q_UNUSED(version); QString targetName = target; #if defined (Q_OS_WIN32) @@ -135,120 +134,49 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v TestCompiler::TestCompiler() { - exit_ok = FALSE; - childProc = 0; - setBaseCommands( "", "", FALSE ); + setBaseCommands( "", "" ); } TestCompiler::~TestCompiler() { - if (childProc) - delete childProc; } -bool TestCompiler::runChild( bool showOutput, QStringList argList, QStringList *envList ) +bool TestCompiler::runCommand( QString cmdline ) { - //qDebug() << "executing" << argList; - exit_ok = FALSE; - if (childProc) - delete childProc; - - child_show = showOutput; - if ( showOutput ) { - - QString S = argList.join(" "); - addMakeResult( S ); - } + testOutput_.append("Running command: " + cmdline); - childProc = new Q3Process(argList, this, argList.join(" ").latin1()); - Q_ASSERT(childProc); - - connect(childProc,SIGNAL(readyReadStdout()),this,SLOT(childHasData())); - connect(childProc,SIGNAL(processExited()),this,SLOT(childReady())); - - if (!childProc->start( envList )) { - - addMakeResult( "Error executing '" + argList[0] + "'." ); - childReady(); - return FALSE; + QProcess child; + child.start(cmdline); + if (!child.waitForStarted(-1)) { + testOutput_.append( "Unable to start child process." ); + return false; } - while (childProc != 0 && childProc->isRunning()) { - qApp->processEvents(); + bool failed = false; + child.setReadChannel(QProcess::StandardError); + while (QProcess::Running == child.state()) { + if (child.waitForReadyRead(1000)) { + QString output = child.readAllStandardError(); + testOutput_.append(output); + + output.prepend('\n'); + if (output.contains("\nProject MESSAGE: FAILED")) + failed = true; + } } - childReady(); - - return exit_ok; -} - -void TestCompiler::childReady() -{ - if (childProc != 0) { - childHasData(); - - QString S; - int pos; - while (childProc->canReadLineStderr()) { - S = childProc->readLineStderr(); - do { - pos = S.find("\t"); - if (pos >= 0) { - S.remove(pos,1); - S.insert(pos," "); - } - } while (pos >= 0); - - if (child_show) - addMakeResult( S ); - } + child.waitForFinished(-1); - exit_ok = childProc->normalExit() && childProc->exitStatus() == 0; - delete childProc; - } - childProc = 0; -} - -void TestCompiler::childHasData() -{ - QString S; - int pos; - while (childProc->canReadLineStderr()) { - - S = childProc->readLineStderr(); - do { - pos = S.find("\t"); - if (pos >= 0) { - S.remove(pos,1); - S.insert(pos," "); - } - - } while (pos >= 0); - - if ( S.startsWith("Project MESSAGE: FAILED") ) - QTest::qFail( S, __FILE__, __LINE__ ); - else if ( S.startsWith("Project MESSAGE: SKIPPED") ) - QTest::qSkip( S, QTest::SkipSingle, __FILE__, __LINE__ ); - else if (child_show) - addMakeResult( S ); - } + return failed + ? false + : (child.exitStatus() == QProcess::NormalExit) + && (child.exitCode() == 0); } -void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd, bool qwsMode ) +void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) { - qws_mode = qwsMode; - make_cmd = makeCmd; - - // not sure if i need this, but it doesn't hurt - if (make_cmd.startsWith("\"")) - make_cmd = make_cmd.remove(0,1); - if (make_cmd.endsWith("\"")) - make_cmd = make_cmd.remove(make_cmd.length()-1,1); - - qmake_cmd = qmakeCmd; - // also not sure if i need this, but it doesn't hurt... - if(qmake_cmd.length() >= 2 && (qmake_cmd.at(0) == '"' || qmake_cmd.at(0) == '\'') && qmake_cmd.at(qmake_cmd.length()-1) == qmake_cmd.at(0)) - qmake_cmd = qmake_cmd.mid(1, qmake_cmd.length()-2); + makeCmd_ = makeCmd; + qmakeCmd_ = qmakeCmd; } bool TestCompiler::cleanAll( const QString &workPath, const QString &destPath, const QString &exeName, const QString &exeExt ) @@ -256,7 +184,7 @@ bool TestCompiler::cleanAll( const QString &workPath, const QString &destPath, c QDir D(workPath); if (!D.exists()) { - addMakeResult( "Directory '" + workPath + "' doesn't exist" ); + testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); return FALSE; } @@ -269,11 +197,7 @@ bool TestCompiler::cleanAll( const QString &workPath, const QString &destPath, c if (Fi.exists()) { // Run make clean - QStringList args; - args = QStringList::split( " ", make_cmd ); - args.append("clean"); - - return runChild( FALSE, args, 0 ); + return runCommand( makeCmd_ + " clean" ); } return TRUE; @@ -284,7 +208,7 @@ bool TestCompiler::makeClean( const QString &workPath ) QDir D; if (!D.exists(workPath)) { - addMakeResult( "Directory '" + workPath + "' doesn't exist" ); + testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); return FALSE; } @@ -293,11 +217,7 @@ bool TestCompiler::makeClean( const QString &workPath ) if (Fi.exists()) { // Run make clean - QStringList args; - args = QStringList::split( " ", make_cmd ); - args.append("clean"); - - return runChild( FALSE, args, 0 ); + return runCommand( makeCmd_ + " clean" ); } return TRUE; @@ -307,20 +227,15 @@ bool TestCompiler::makeDistClean( const QString &workPath ) { QDir D; if (!D.exists(workPath)) { - addMakeResult( "Directory '" + workPath + "' doesn't exist" ); + testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); return FALSE; } D.setCurrent(workPath); QFileInfo Fi( workPath + "/Makefile"); - if (Fi.exists()) { - // Run make distclean - QStringList args; - args = QStringList::split( " ", make_cmd ); - args.append("distclean"); - - return runChild( FALSE, args, 0 ); - } + if (Fi.exists()) + // Run make distclean + return runCommand( makeCmd_ + " distclean" ); return TRUE; @@ -328,26 +243,22 @@ bool TestCompiler::makeDistClean( const QString &workPath ) bool TestCompiler::qmake( const QString &workDir, const QString &proName, const QString &buildDir ) { - // Now start qmake and generate the makefile - - QDir D( workDir ); - // Make sure we start in the right directory + QDir D; D.setCurrent( workDir ); if (D.exists("Makefile")) - D.remove("Makefile"); - - QStringList args; - args = QStringList::split( " ", qmake_cmd ); + D.remove("Makefile"); - QString project_fname = workDir + "/" + proName + ".pro"; - QString makefile_fname = (buildDir.isNull()?QString():(buildDir + "/")) + "Makefile"; + QString projectFile = proName; + QString makeFile = buildDir; + if (!projectFile.endsWith(".pro")) + projectFile += ".pro"; + if (!makeFile.isEmpty() && !makeFile.endsWith('/')) + makeFile += '/'; + makeFile += "Makefile"; - args.append( project_fname ); - args.append( "-o" ); - args.append( makefile_fname ); - - return runChild( TRUE, args, 0 ); + // Now start qmake and generate the makefile + return runCommand( qmakeCmd_ + " " + projectFile + " -o " + makeFile ); } bool TestCompiler::make( const QString &workPath, const QString &target ) @@ -355,14 +266,13 @@ bool TestCompiler::make( const QString &workPath, const QString &target ) QDir D; D.setCurrent( workPath ); - QStringList args; - args = QStringList::split( " ", make_cmd ); - if ( make_cmd.lower().find("nmake") >= 0) - args.append("/NOLOGO"); - if ( !target.isNull() ) - args.append(target); + QString cmdline = makeCmd_; + if ( cmdline.contains("nmake", Qt::CaseInsensitive) ) + cmdline.append(" /NOLOGO"); + if ( !target.isEmpty() ) + cmdline += " " + target; - return runChild( TRUE, args, 0 ); + return runCommand( cmdline ); } bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ) @@ -371,10 +281,6 @@ bool TestCompiler::exists( const QString &destDir, const QString &exeName, Build return f.exists(); } -void TestCompiler::addMakeResult( const QString &result ) -{ - make_result.append( result ); -} bool TestCompiler::removeMakefile( const QString &workPath ) { @@ -385,6 +291,3 @@ bool TestCompiler::removeMakefile( const QString &workPath ) else return TRUE; } - -#endif //QT3_SUPPORT - diff --git a/tests/auto/qmake/testcompiler.h b/tests/auto/qmake/testcompiler.h index 597d440..12d8878 100644 --- a/tests/auto/qmake/testcompiler.h +++ b/tests/auto/qmake/testcompiler.h @@ -41,14 +41,9 @@ #ifndef TESTCOMPILER_H #define TESTCOMPILER_H - -#ifdef QT3_SUPPORT - #include #include -QT_FORWARD_DECLARE_CLASS(Q3Process) - #define COMPILE_ERROR "Compile error" #define COMPILE_SUCCESS "Compile successfull" #define COMPILE_NOT_AVAIL "Binary not available for testing" @@ -64,7 +59,7 @@ public: TestCompiler(); virtual ~TestCompiler(); - void setBaseCommands( QString makeCmd, QString qmakeCmd, bool qwsMode ); + void setBaseCommands( QString makeCmd, QString qmakeCmd ); // builds a complete project, e.g. qmake, make clean, make and exists. bool buildProject( const QString &project, BuildType buildType, const QString &targetName, const QString &destPath, const QString &version ); @@ -86,25 +81,13 @@ public: bool removeMakefile( const QString &workPath ); private: - QString make_cmd; - QString qmake_cmd; + bool runCommand( QString cmdLine ); - Q3Process *childProc; - QStringList env_list; - - bool child_show; - bool qws_mode; - bool exit_ok; - -private: - bool runChild( bool showOutput, QStringList argList, QStringList *envList ); - void addMakeResult( const QString &result ); - QStringList make_result; + QString makeCmd_; + QString qmakeCmd_; -private slots: - void childReady(); - void childHasData(); + // need to make this available somewhere + QStringList testOutput_; }; -#endif // QT3_SUPPORT #endif // TESTCOMPILER_H diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index facf0bb..884a2c4 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -42,11 +42,9 @@ #include -#if !defined(QMAKE_CROSS_COMPILED) && defined(QT3_SUPPORT) +#if !defined(QMAKE_CROSS_COMPILED) #include -#include - #include "testcompiler.h" @@ -104,16 +102,16 @@ tst_qmake::tst_qmake() { QString cmd = QString("qmake \"QT_VERSION=%1\"").arg(QT_VERSION); #ifdef Q_CC_MSVC - test_compiler.setBaseCommands( "nmake", cmd, FALSE ); + test_compiler.setBaseCommands( "nmake", cmd ); #elif defined(Q_CC_MINGW) - test_compiler.setBaseCommands( "mingw32-make", cmd, FALSE ); + test_compiler.setBaseCommands( "mingw32-make", cmd ); #elif defined(Q_OS_WIN) && defined(Q_CC_GNU) - test_compiler.setBaseCommands( "mmmake", cmd, FALSE ); + test_compiler.setBaseCommands( "mmmake", cmd ); #else - test_compiler.setBaseCommands( "make", cmd, FALSE ); + test_compiler.setBaseCommands( "make", cmd ); #endif QDir dir; - base_path = dir.currentDirPath(); + base_path = dir.currentPath(); } tst_qmake::~tst_qmake() @@ -406,7 +404,7 @@ void tst_qmake::bundle_spaces() // make (-n). TestCompiler local_tc; - local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++", FALSE); + local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++"); QVERIFY( local_tc.qmake(workDir, "bundle-spaces") ); -- cgit v0.12 From 0d026b267badbf7890b02256826f0ff3821fcec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 2 Apr 2009 15:47:54 +0200 Subject: Spring cleaning in qmake tests And some indentation fixes in qmake itself. Fixes indentation; TRUE => true; FALSE => false; #includes and #defines cleanup; removes dead code; comments... and somewhere along the way marked a function static. Reviewed-by: mariusSO --- qmake/generators/makefile.h | 6 +- qmake/generators/metamakefile.cpp | 2 +- qmake/project.cpp | 2 +- tests/auto/qmake/testcompiler.cpp | 109 +++++++-------------- tests/auto/qmake/testcompiler.h | 17 +--- .../auto/qmake/testdata/shadow_files_build/README | 2 +- tests/auto/qmake/tst_qmake.cpp | 18 ++-- 7 files changed, 49 insertions(+), 107 deletions(-) diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h index a26a247..cf09a6a 100644 --- a/qmake/generators/makefile.h +++ b/qmake/generators/makefile.h @@ -109,7 +109,7 @@ protected: struct SubTarget { QString name; - QString in_directory, out_directory; + QString in_directory, out_directory; QString profile, target, makefile; QStringList depends; }; @@ -183,8 +183,8 @@ protected: void filterIncludedFiles(const QString &); virtual void processSources() { - filterIncludedFiles("SOURCES"); - filterIncludedFiles("GENERATED_SOURCES"); + filterIncludedFiles("SOURCES"); + filterIncludedFiles("GENERATED_SOURCES"); } //for cross-platform dependent directories diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index f0683a7..3f60791 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -360,7 +360,7 @@ SubdirsMetaMakefileGenerator::init() } --recurseDepth; - Option::output.setFileName(old_output); + Option::output.setFileName(old_output); Option::output_dir = old_output_dir; qmake_setpwd(oldpwd); } diff --git a/qmake/project.cpp b/qmake/project.cpp index 8d49788..eef32db 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1105,7 +1105,7 @@ QMakeProject::parse(const QString &t, QMap &place, int num } } } - } else if(!parens && *(d+d_off) == QLatin1Char('}')) { + } else if(!parens && *(d+d_off) == QLatin1Char('}')) { if(start_block) { --start_block; } else if(!scope_blocks.count()) { diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp index c25b851..b518da8 100644 --- a/tests/auto/qmake/testcompiler.cpp +++ b/tests/auto/qmake/testcompiler.cpp @@ -39,23 +39,12 @@ ** ****************************************************************************/ - #include "testcompiler.h" -#include -#include - -#include -#include -#ifdef Q_OS_WIN32 -# include -#endif -#include +#include +#include -#undef SHOW_QDEBUG -#undef SHOW_COMPLETENESS - -QString targetName( BuildType buildMode, const QString& target, const QString& version ) +static QString targetName( BuildType buildMode, const QString& target, const QString& version ) { Q_UNUSED(version); QString targetName = target; @@ -64,23 +53,23 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v switch (buildMode) { case Exe: // app - targetName.append(".exe"); - break; + targetName.append(".exe"); + break; case Dll: // dll - if (version != "") { - QStringList ver = QStringList::split(".", version); - targetName.append(ver.first()); - } + if (version != "") { + QStringList ver = QStringList::split(".", version); + targetName.append(ver.first()); + } targetName.append(".dll"); - break; + break; case Lib: // lib #ifdef Q_CC_GNU targetName.prepend("lib"); targetName.append(".a"); #else - targetName.append(".lib"); + targetName.append(".lib"); #endif - break; + break; case Plain: // no conversion break; @@ -89,16 +78,16 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v switch (buildMode) { case Exe: // app - targetName += ".app/Contents/MacOS/" + target.section('/', -1); - break; + targetName += ".app/Contents/MacOS/" + target.section('/', -1); + break; case Dll: // dll - targetName.prepend("lib"); + targetName.prepend("lib"); targetName.append("." + version + ".dylib"); - break; + break; case Lib: // lib - targetName.prepend("lib"); - targetName.append(".a"); - break; + targetName.prepend("lib"); + targetName.append(".a"); + break; case Plain: // no conversion break; @@ -107,9 +96,9 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v switch (buildMode) { case Exe: // app - break; + break; case Dll: // dll - targetName.prepend("lib"); + targetName.prepend("lib"); #if defined (Q_OS_HPUX) && !defined (__ia64) targetName.append(".sl"); #elif defined (Q_OS_AIX) @@ -117,11 +106,11 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v #else targetName.append(".so"); #endif - break; + break; case Lib: // lib - targetName.prepend("lib"); - targetName.append(".a"); - break; + targetName.prepend("lib"); + targetName.append(".a"); + break; case Plain: // no conversion break; @@ -130,8 +119,6 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v return targetName; } - - TestCompiler::TestCompiler() { setBaseCommands( "", "" ); @@ -179,48 +166,21 @@ void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) qmakeCmd_ = qmakeCmd; } -bool TestCompiler::cleanAll( const QString &workPath, const QString &destPath, const QString &exeName, const QString &exeExt ) -{ - QDir D(workPath); - if (!D.exists()) { - - testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return FALSE; - } - - D.setCurrent(workPath); - // must delete at least the executable file to be able to easily and safely - // verify that the compilation was a success. - D.remove( destPath + "/" + exeName + exeExt ); - D.remove( workPath + "/Makefile"); - QFileInfo Fi( workPath + "/Makefile"); - if (Fi.exists()) { - - // Run make clean - return runCommand( makeCmd_ + " clean" ); - } - - return TRUE; -} - bool TestCompiler::makeClean( const QString &workPath ) { QDir D; if (!D.exists(workPath)) { - testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return FALSE; + return false; } D.setCurrent(workPath); QFileInfo Fi( workPath + "/Makefile"); - if (Fi.exists()) { - - // Run make clean - return runCommand( makeCmd_ + " clean" ); - } + if (Fi.exists()) + // Run make clean + return runCommand( makeCmd_ + " clean" ); - return TRUE; + return true; } bool TestCompiler::makeDistClean( const QString &workPath ) @@ -228,7 +188,7 @@ bool TestCompiler::makeDistClean( const QString &workPath ) QDir D; if (!D.exists(workPath)) { testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return FALSE; + return false; } D.setCurrent(workPath); @@ -237,7 +197,7 @@ bool TestCompiler::makeDistClean( const QString &workPath ) // Run make distclean return runCommand( makeCmd_ + " distclean" ); - return TRUE; + return true; } @@ -281,13 +241,12 @@ bool TestCompiler::exists( const QString &destDir, const QString &exeName, Build return f.exists(); } - bool TestCompiler::removeMakefile( const QString &workPath ) { QDir D; D.setCurrent( workPath ); if ( D.exists( "Makefile" ) ) - return D.remove( "Makefile" ); + return D.remove( "Makefile" ); else - return TRUE; + return true; } diff --git a/tests/auto/qmake/testcompiler.h b/tests/auto/qmake/testcompiler.h index 12d8878..90f7fea 100644 --- a/tests/auto/qmake/testcompiler.h +++ b/tests/auto/qmake/testcompiler.h @@ -41,19 +41,14 @@ #ifndef TESTCOMPILER_H #define TESTCOMPILER_H -#include -#include - -#define COMPILE_ERROR "Compile error" -#define COMPILE_SUCCESS "Compile successfull" -#define COMPILE_NOT_AVAIL "Binary not available for testing" -#define SELF_TEST "self-test" +#include +#include enum BuildType { Exe, Dll, Lib, Plain }; class TestCompiler : public QObject { -Q_OBJECT + Q_OBJECT public: TestCompiler(); @@ -61,9 +56,6 @@ public: void setBaseCommands( QString makeCmd, QString qmakeCmd ); - // builds a complete project, e.g. qmake, make clean, make and exists. - bool buildProject( const QString &project, BuildType buildType, const QString &targetName, const QString &destPath, const QString &version ); - // executes a make clean in the specified workPath bool makeClean( const QString &workPath ); // executes a make dist clean in the specified workPath @@ -72,9 +64,6 @@ public: bool qmake( const QString &workDir, const QString &proName, const QString &buildDir = QString() ); // executes a make in the specified workPath, with an optional target (eg. install) bool make( const QString &workPath, const QString &target = QString() ); - // executes a make clean and then deletes the makefile in workpath + deletes the executable - // in destPath. - bool cleanAll( const QString &workPath, const QString &destPath, const QString &exeName, const QString &exeExt ); // checks if the executable exists in destDir bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ); // removes the makefile diff --git a/tests/auto/qmake/testdata/shadow_files_build/README b/tests/auto/qmake/testdata/shadow_files_build/README index 46017fc..15e48c0 100644 --- a/tests/auto/qmake/testdata/shadow_files_build/README +++ b/tests/auto/qmake/testdata/shadow_files_build/README @@ -1 +1 @@ -Here to ensure include_dir_build exists +Here to ensure shadow_files_build exists, used by the shadow_files test. diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 884a2c4..07389e9 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -39,19 +39,13 @@ ** ****************************************************************************/ - -#include - #if !defined(QMAKE_CROSS_COMPILED) -#include - #include "testcompiler.h" -#include - -//TESTED_CLASS= -//TESTED_FILES=corelib/tools/qlocale.h corelib/tools/qlocale.cpp +#include +#include +#include class tst_qmake : public QObject { @@ -61,12 +55,12 @@ public: tst_qmake(); virtual ~tst_qmake(); - public slots: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); + private slots: void simple_app(); void simple_lib(); @@ -253,10 +247,10 @@ void tst_qmake::duplicateLibraryEntries() void tst_qmake::export_across_file_boundaries() { // This relies on features so we need to set the QMAKEFEATURES environment variable - putenv("QMAKEFEATURES=."); + putenv("QMAKEFEATURES=."); QString workDir = base_path + "/testdata/export_across_file_boundaries"; QVERIFY( test_compiler.qmake( workDir, "foo" )); - putenv("QMAKEFEATURES="); + putenv("QMAKEFEATURES="); } void tst_qmake::include_dir() -- cgit v0.12 From 605746fd14ff68f19a806bb54882fb967fccc8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 19 Mar 2009 13:36:56 +0100 Subject: In qmake tests, allow child environment to be manipulated ... without having to change the parent process's environment. Reviewed-by: mariusSO --- tests/auto/qmake/testcompiler.cpp | 13 +++++++++++++ tests/auto/qmake/testcompiler.h | 3 +++ tests/auto/qmake/tst_qmake.cpp | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp index b518da8..122a2b8 100644 --- a/tests/auto/qmake/testcompiler.cpp +++ b/tests/auto/qmake/testcompiler.cpp @@ -133,6 +133,9 @@ bool TestCompiler::runCommand( QString cmdline ) testOutput_.append("Running command: " + cmdline); QProcess child; + if (!environment_.empty()) + child.setEnvironment(QProcess::systemEnvironment() + environment_); + child.start(cmdline); if (!child.waitForStarted(-1)) { testOutput_.append( "Unable to start child process." ); @@ -166,6 +169,16 @@ void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) qmakeCmd_ = qmakeCmd; } +void TestCompiler::resetEnvironment() +{ + environment_.clear(); +} + +void TestCompiler::addToEnvironment( QString varAssignment ) +{ + environment_.push_back(varAssignment); +} + bool TestCompiler::makeClean( const QString &workPath ) { QDir D; diff --git a/tests/auto/qmake/testcompiler.h b/tests/auto/qmake/testcompiler.h index 90f7fea..41e5177 100644 --- a/tests/auto/qmake/testcompiler.h +++ b/tests/auto/qmake/testcompiler.h @@ -55,6 +55,8 @@ public: virtual ~TestCompiler(); void setBaseCommands( QString makeCmd, QString qmakeCmd ); + void resetEnvironment(); + void addToEnvironment( QString varAssignment ); // executes a make clean in the specified workPath bool makeClean( const QString &workPath ); @@ -74,6 +76,7 @@ private: QString makeCmd_; QString qmakeCmd_; + QStringList environment_; // need to make this available somewhere QStringList testOutput_; diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 07389e9..70f1f3c 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -247,10 +247,10 @@ void tst_qmake::duplicateLibraryEntries() void tst_qmake::export_across_file_boundaries() { // This relies on features so we need to set the QMAKEFEATURES environment variable - putenv("QMAKEFEATURES=."); + test_compiler.addToEnvironment("QMAKEFEATURES=."); QString workDir = base_path + "/testdata/export_across_file_boundaries"; QVERIFY( test_compiler.qmake( workDir, "foo" )); - putenv("QMAKEFEATURES="); + test_compiler.resetEnvironment(); } void tst_qmake::include_dir() -- cgit v0.12 From cfa31244eb9d16214360626723253d6a363a8d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 2 Apr 2009 11:03:58 +0200 Subject: Small changes in qmake's fileFixify Removed dead code and simplified conditionals. This should not otherwise change behavior or output of qmake in any way. Reviewed-by: mariusSO --- qmake/generators/makefile.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index d0fbcbe..3e5452e 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2735,16 +2735,9 @@ MakefileGenerator::fileFixify(const QString& file, const QString &out_d, const Q ret.prepend(pwd); ret = Option::fixPathToTargetOS(ret, false, canon); } else { //fix it.. - QString qfile(Option::fixPathToLocalOS(ret, true, canon)), in_dir(in_d), out_dir(out_d); + QString out_dir = QDir(Option::output_dir).absoluteFilePath(out_d); + QString in_dir = QDir(pwd).absoluteFilePath(in_d); { - if(out_dir.isNull() || QDir::isRelativePath(out_dir)) - out_dir.prepend(Option::output_dir + "/"); - else if(out_dir == ".") - out_dir = pwd; - if(in_dir.isEmpty() || QDir::isRelativePath(in_dir)) - in_dir.prepend(pwd); - else if(in_dir == ".") - in_dir = pwd; QFileInfo in_fi(fileInfo(in_dir)); if(in_fi.exists()) in_dir = in_fi.canonicalFilePath(); @@ -2753,6 +2746,7 @@ MakefileGenerator::fileFixify(const QString& file, const QString &out_d, const Q out_dir = out_fi.canonicalFilePath(); } + QString qfile(Option::fixPathToLocalOS(ret, true, canon)); QFileInfo qfileinfo(fileInfo(qfile)); if(out_dir != in_dir || !qfileinfo.isRelative()) { if(qfileinfo.isRelative()) { -- cgit v0.12 From db4040f7bf1e36b9568e7a99dc090acf03b0ddd0 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 2 Apr 2009 16:42:36 +0200 Subject: make the configured namespace part of QT_BUILD_KEY The eclipse integration is namespaced, but it pulls in system plugins like the oxygen style. This breaks as the (non-namespaced) style plugin does not find a suitable QApplication instantiated (only a namespace one is there) Reviewed-by: thiago Task-number: 250185 --- configure | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure b/configure index f0b7f90..f79b1e2 100755 --- a/configure +++ b/configure @@ -6177,6 +6177,9 @@ TARGET_OPERATING_SYSTEM=`echo $XPLATFORM | cut -f 2- -d/ | cut -f -1 -d-` # when cross-compiling, don't include build-host information (build key is target specific) QT_BUILD_KEY="$CFG_USER_BUILD_KEY $CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPILER $BUILD_OPTIONS" +if [ -n "$QT_NAMESPACE" ]; then + QT_BUILD_KEY="$QT_BUILD_KEY $QT_NAMESPACE" +fi MAC_NEED_TWO_BUILD_KEYS="no" if [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" ]; then QT_BUILD_KEY_CARBON=$QT_BUILD_KEY -- cgit v0.12 From 0c508410dd42714b9854b523c851ef699ebcf7d7 Mon Sep 17 00:00:00 2001 From: kh Date: Thu, 2 Apr 2009 17:58:51 +0200 Subject: fixes empty tab after pdf file open Task-number: none Reviewed-by: --global --- tools/assistant/tools/assistant/contentwindow.cpp | 21 +++++++++++++++------ tools/assistant/tools/assistant/contentwindow.h | 2 ++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 24e7ca9..89060bd 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -132,7 +132,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) qobject_cast(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); - if (itm) + if (itm && !isPdfFile(itm)) CentralWidget::instance()->setSourceInNewTab(itm->url()); } } @@ -146,16 +146,19 @@ void ContentWindow::showContextMenu(const QPoint &pos) if (!m_contentWidget->indexAt(pos).isValid()) return; - QMenu menu; - QAction *curTab = menu.addAction(tr("Open Link")); - QAction *newTab = menu.addAction(tr("Open Link in New Tab")); - menu.move(m_contentWidget->mapToGlobal(pos)); - QHelpContentModel *contentModel = qobject_cast(m_contentWidget->model()); QHelpContentItem *itm = contentModel->contentItemAt(m_contentWidget->currentIndex()); + QMenu menu; + QAction *curTab = menu.addAction(tr("Open Link")); + QAction *newTab = menu.addAction(tr("Open Link in New Tab")); + if (isPdfFile(itm)) + newTab->setEnabled(false); + + menu.move(m_contentWidget->mapToGlobal(pos)); + QAction *action = menu.exec(); if (curTab == action) emit linkActivated(itm->url()); @@ -175,4 +178,10 @@ void ContentWindow::itemClicked(const QModelIndex &index) } } +bool ContentWindow::isPdfFile(QHelpContentItem *item) const +{ + const QString &path = item->url().path(); + return path.endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive); +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/contentwindow.h b/tools/assistant/tools/assistant/contentwindow.h index ab8f8dd..ddc3e7c 100644 --- a/tools/assistant/tools/assistant/contentwindow.h +++ b/tools/assistant/tools/assistant/contentwindow.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE class QHelpEngine; +class QHelpContentItem; class QHelpContentWidget; class ContentWindow : public QWidget @@ -75,6 +76,7 @@ private: void focusInEvent(QFocusEvent *e); void keyPressEvent(QKeyEvent *e); bool eventFilter(QObject *o, QEvent *e); + bool isPdfFile(QHelpContentItem *item) const; QHelpEngine *m_helpEngine; QHelpContentWidget *m_contentWidget; -- cgit v0.12 From 468f189d73fefaeb0769365f78762dc2aa63683d Mon Sep 17 00:00:00 2001 From: kh Date: Thu, 2 Apr 2009 18:00:34 +0200 Subject: fixes empty tab after pdf file open Task-number: none Reviewed-by: --global --- tools/assistant/tools/assistant/indexwindow.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 4bd6f4f..0beb5ee 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -189,13 +189,20 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) if (model) { QString keyword = model->data(index, Qt::DisplayRole).toString(); QMap links = model->linksForKeyword(keyword); + + QUrl url; if (links.count() > 1) { TopicChooser tc(this, keyword, links); - if (tc.exec() == QDialog::Accepted) - CentralWidget::instance()->setSourceInNewTab(tc.link()); + if (tc.exec() == QDialog::Accepted) + url = tc.link(); } else if (links.count() == 1) { - CentralWidget::instance()->setSourceInNewTab(links.constBegin().value()); + url = links.constBegin().value(); } + + if (url.path().endsWith(QLatin1String(".pdf"), Qt::CaseInsensitive)) + CentralWidget::instance()->setSource(url); + else + CentralWidget::instance()->setSourceInNewTab(url); } } -- cgit v0.12 From 8eeda065bbf039bb3305d716b8163c723c7ad1c0 Mon Sep 17 00:00:00 2001 From: kh Date: Thu, 2 Apr 2009 18:01:47 +0200 Subject: fixes empty tab after pdf file open, new tab after middle mouse click Task-number: none Reviewed-by: --global --- tools/assistant/tools/assistant/helpviewer.cpp | 59 ++++++++++++++++++++++++-- tools/assistant/tools/assistant/helpviewer.h | 1 + 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 6b049e8..f7225fa 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -164,6 +164,7 @@ public: protected: virtual QWebPage *createWindow(QWebPage::WebWindowType); + virtual void triggerAction(WebAction action, bool checked = false); virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); @@ -171,16 +172,30 @@ protected: private: CentralWidget *centralWidget; QHelpEngine *helpEngine; + bool closeNewTabIfNeeded; + + friend class HelpViewer; + Qt::MouseButtons m_pressedButtons; + Qt::KeyboardModifiers m_keyboardModifiers; }; HelpPage::HelpPage(CentralWidget *central, QHelpEngine *engine, QObject *parent) - : QWebPage(parent), centralWidget(central), helpEngine(engine) + : QWebPage(parent) + , centralWidget(central) + , helpEngine(engine) + , closeNewTabIfNeeded(false) + , m_pressedButtons(Qt::NoButton) + , m_keyboardModifiers(Qt::NoModifier) { } QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) { - return centralWidget->newEmptyTab()->page(); + HelpPage* newPage = static_cast(centralWidget->newEmptyTab()->page()); + if (newPage) + newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; + closeNewTabIfNeeded = false; + return newPage; } static bool isLocalUrl(const QUrl &url) @@ -196,10 +211,24 @@ static bool isLocalUrl(const QUrl &url) return false; } +void HelpPage::triggerAction(WebAction action, bool checked) +{ + switch (action) { + case OpenLinkInNewWindow: + closeNewTabIfNeeded = true; + default: // fall through + QWebPage::triggerAction(action, checked); + break; + } +} + bool HelpPage::acceptNavigationRequest(QWebFrame *, - const QNetworkRequest &request, QWebPage::NavigationType) + const QNetworkRequest &request, QWebPage::NavigationType type) { const QUrl &url = request.url(); + const bool closeNewTab = closeNewTabIfNeeded; + closeNewTabIfNeeded = false; + if (isLocalUrl(url)) { const QString& path = url.path(); if (path.endsWith(QLatin1String(".pdf"))) { @@ -216,8 +245,22 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, tmpFile.close(); } QDesktopServices::openUrl(QUrl(tmpFile.fileName())); + + if (closeNewTab) + QMetaObject::invokeMethod(CentralWidget::instance(), "closeTab"); return false; } + + if (type == QWebPage::NavigationTypeLinkClicked + && (m_keyboardModifiers & Qt::ControlModifier + || m_pressedButtons == Qt::MidButton)) { + HelpViewer* viewer = centralWidget->newEmptyTab(); + if (viewer) + CentralWidget::instance()->setSource(url); + m_pressedButtons = Qt::NoButton; + m_keyboardModifiers = Qt::NoModifier; + return false; + } return true; } @@ -332,6 +375,16 @@ void HelpViewer::actionChanged() emit forwardAvailable(a->isEnabled()); } +void HelpViewer::mousePressEvent(QMouseEvent *event) +{ + HelpPage *currentPage = static_cast(page()); + if (currentPage) { + currentPage->m_pressedButtons = event->buttons(); + currentPage->m_keyboardModifiers = event->modifiers(); + } + QWebView::mousePressEvent(event); +} + #else // !defined(QT_NO_WEBKIT) HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index af5c197..eea7340 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -107,6 +107,7 @@ Q_SIGNALS: protected: virtual void wheelEvent(QWheelEvent *); void mouseReleaseEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *event); private Q_SLOTS: void actionChanged(); -- cgit v0.12 From 4ef666941209530ef266a34c3b32dc07642eef9a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 2 Apr 2009 11:55:55 +0200 Subject: fix wrong evaluation of arguments to qmake functions cherry-pick 28dacdfdf3eed04ec47a1e8eb206bd3ffb979c08 from creator --- tools/linguist/shared/profileevaluator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp index aa529c1..eb6e2a7 100644 --- a/tools/linguist/shared/profileevaluator.cpp +++ b/tools/linguist/shared/profileevaluator.cpp @@ -1002,9 +1002,10 @@ bool ProFileEvaluator::Private::isActiveConfig(const QString &config, bool regex QStringList ProFileEvaluator::Private::evaluateExpandFunction(const QString &func, const QString &arguments) { QStringList argumentsList = split_arg_list(arguments); + QStringList args; for (int i = 0; i < argumentsList.count(); ++i) - args += expandVariableReferences(argumentsList[i]); + args += expandVariableReferences(argumentsList[i]).join(Option::field_sep); enum ExpandFunc { E_MEMBER=1, E_FIRST, E_LAST, E_CAT, E_FROMFILE, E_EVAL, E_LIST, E_SPRINTF, E_JOIN, E_SPLIT, E_BASENAME, E_DIRNAME, E_SECTION, -- cgit v0.12 From 5fa1cba8220b5a73aa45c83a0878a6f7c3060343 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 2 Apr 2009 12:02:39 +0200 Subject: fix evaluation of CONFIG() and contains() cherry-picked from creator's b3ec859c80bd0656cfc48cfe6514ec4f631b8206 --- tools/linguist/shared/profileevaluator.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp index eb6e2a7..a0771b4 100644 --- a/tools/linguist/shared/profileevaluator.cpp +++ b/tools/linguist/shared/profileevaluator.cpp @@ -1266,10 +1266,11 @@ bool ProFileEvaluator::Private::evaluateConditionalFunction(const QString &funct for (int mut = 0; mut < mutuals.count(); mut++) { if (configs[i] == mutuals[mut].trimmed()) { cond = (configs[i] == args[0]); - break; + goto done_T_CONFIG; } } } + done_T_CONFIG: break; } case CF_CONTAINS: { @@ -1296,12 +1297,12 @@ bool ProFileEvaluator::Private::evaluateConditionalFunction(const QString &funct for (int mut = 0; mut < mutuals.count(); mut++) { if (val == mutuals[mut].trimmed()) { cond = (regx.exactMatch(val) || val == args[1]); - break; + goto done_T_CONTAINS; } } } } - + done_T_CONTAINS: break; } case CF_COUNT: { -- cgit v0.12 From 3570e978058816745101a69b552ad9d07e349542 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 2 Apr 2009 15:12:17 +0200 Subject: re-initialize some variables for each file --- tools/linguist/shared/profileevaluator.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp index a0771b4..ce53c27 100644 --- a/tools/linguist/shared/profileevaluator.cpp +++ b/tools/linguist/shared/profileevaluator.cpp @@ -157,11 +157,6 @@ ProFileEvaluator::Private::Private(ProFileEvaluator *q_) m_prevLineNo = 0; m_prevProFile = 0; m_verbose = true; - m_block = 0; - m_commentItem = 0; - m_syntaxError = 0; - m_lineNo = 0; - m_contNextLine = false; } bool ProFileEvaluator::Private::read(ProFile *pro) @@ -172,8 +167,12 @@ bool ProFileEvaluator::Private::read(ProFile *pro) return false; } + m_block = 0; + m_commentItem = 0; + m_contNextLine = false; m_syntaxError = false; m_lineNo = 1; + m_blockstack.clear(); m_blockstack.push(pro); QTextStream ts(&file); -- cgit v0.12 From 33fedde08f263c6aaa46c2fa0fdf93896c7eaa64 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 31 Mar 2009 14:38:57 +0200 Subject: re-apply improved version of 3aff9113a9702ea6f7e099a73136a718ae1b992f this time, it can deal with directories which are absolute to start with. Reviewed-by: mariusSO --- mkspecs/features/moc.prf | 5 ++++- mkspecs/features/uic.prf | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index faa9871..d3ad4b2 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -61,7 +61,10 @@ QMAKE_EXTRA_COMPILERS += moc_source INCREDIBUILD_XGE += moc_source #make sure we can include these files -INCLUDEPATH += $$MOC_DIR +moc_dir_short = $$MOC_DIR +win32:moc_dir_short ~= s,^.:,/, +contains(moc_dir_short, ^[/\\].*):INCLUDEPATH += $$MOC_DIR +else:INCLUDEPATH += $$OUT_PWD/$$MOC_DIR #auto depend on moc unix:!no_mocdepend { diff --git a/mkspecs/features/uic.prf b/mkspecs/features/uic.prf index 885fad7..f03d623 100644 --- a/mkspecs/features/uic.prf +++ b/mkspecs/features/uic.prf @@ -34,7 +34,10 @@ isEmpty(QMAKE_MOD_UIC):QMAKE_MOD_UIC = ui_ INCREDIBUILD_XGE += uic } -INCLUDEPATH += $$UI_HEADERS_DIR +ui_dir_short = $$UI_HEADERS_DIR +win32:ui_dir_short ~= s,^.:,/, +contains(ui_dir_short, ^[/\\].*):INCLUDEPATH += $$UI_HEADERS_DIR +else:INCLUDEPATH += $$OUT_PWD/$$UI_HEADERS_DIR uic3 { isEmpty(FORMS3) { -- cgit v0.12 From c99638c9ba4b233c8d0e822a1bf6e26b885e029d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 2 Apr 2009 17:55:23 +0200 Subject: make relative #include relative to the current file i.e., use "", not <> and thus rely on the include path --- src/network/kernel/qauthenticator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 4f477bd..c9161f8 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -#include <../3rdparty/des/des.cpp> +#include "../../3rdparty/des/des.cpp" static QByteArray qNtlmPhase1(); static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phase2data); -- cgit v0.12 From 7c09fda559760b8488d3130a5932fee04b2f6979 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 2 Apr 2009 18:52:51 +0200 Subject: Make mkdist-webkit work from in-source builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explicitly unset QTDIR_build, to make sure we generate Makefiles with real rules to call the extra tools. Reviewed-by: Tor Arne Vestbø --- util/webkit/mkdist-webkit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 0644564..d4e6d9e 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -254,7 +254,7 @@ echo "generating extra sources" mkdir tmp && cd tmp && mkdir -p ../generated && - qmake -o Makefile QT_CONFIG+=phonon GENERATED_SOURCES_DIR=`pwd`/../generated OUTPUT_DIR=`pwd` ../$proj.pro && + qmake -o Makefile CONFIG-=QTDIR_build QT_CONFIG+=phonon GENERATED_SOURCES_DIR=`pwd`/../generated OUTPUT_DIR=`pwd` ../$proj.pro && make generated_files && perl -pi -e "s,$absSrcDir/,,g" ../generated/*.cpp ../generated/*.h && git add ../generated && -- cgit v0.12 From fb5790e1b1d4ddeac19a2996c806744509de4ac8 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 2 Apr 2009 19:09:52 +0200 Subject: Only set system style when it actually changes This issue would cause Qt Creator and similar apps with proxy styles to loose their custom styling whenever any x11 system settings changed. This happened because we would re-read the settings and override the system style even if the system style did not actually change would be set on the application. We Task-number: 250199 Reviewed-by: ogoffart --- src/gui/kernel/qapplication_x11.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 6babda9..260a9a4 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -887,11 +887,15 @@ bool QApplicationPrivate::x11_apply_settings() } } + static QString currentStyleName = stylename; if (QCoreApplication::startingUp()) { if (!stylename.isEmpty() && !QApplicationPrivate::styleOverride) QApplicationPrivate::styleOverride = new QString(stylename); } else { - QApplication::setStyle(stylename); + if (currentStyleName != stylename) { + currentStyleName = stylename; + QApplication::setStyle(stylename); + } } int num = -- cgit v0.12 From b2b11265d9cf20706eadca61c37d931886eb35cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 2 Apr 2009 17:17:16 +0200 Subject: Adding auto-tests for commits a2fcc4a5 and 8d500381 Task-number: 244500 Task-number: 244485 Reviewed-by: ossi Reviewed-by: thiago --- tests/auto/qfile/rename-fallback.qrc | 5 +++ tests/auto/qfile/test/test.pro | 2 +- tests/auto/qfile/tst_qfile.cpp | 46 ++++++++++++++++++++++++ tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 26 ++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qfile/rename-fallback.qrc diff --git a/tests/auto/qfile/rename-fallback.qrc b/tests/auto/qfile/rename-fallback.qrc new file mode 100644 index 0000000..c8a894a --- /dev/null +++ b/tests/auto/qfile/rename-fallback.qrc @@ -0,0 +1,5 @@ + + + rename-fallback.qrc + + diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro index 2293bd7..68f4c05 100644 --- a/tests/auto/qfile/test/test.pro +++ b/tests/auto/qfile/test/test.pro @@ -17,7 +17,7 @@ QT = core network DEFINES += SRCDIR=\\\"$$PWD/../\\\" } -RESOURCES += ../qfile.qrc +RESOURCES += ../qfile.qrc ../rename-fallback.qrc TARGET = ../tst_qfile diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 48902c7..829e0b3 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -169,6 +169,8 @@ private slots: void rename_data(); void rename(); void renameWithAtEndSpecialFile() const; + void renameFallback(); + void renameMultiple(); void appendAndRead(); void miscWithUncPathAsCurrentDir(); void standarderror(); @@ -214,6 +216,14 @@ void tst_QFile::cleanup() { // TODO: Add cleanup code here. // This will be executed immediately after each test is run. + + // for renameFallback() + QFile::remove("file-rename-destination.txt"); + + // for renameMultiple() + QFile::remove("file-to-be-renamed.txt"); + QFile::remove("file-renamed-once.txt"); + QFile::remove("file-renamed-twice.txt"); } void tst_QFile::initTestCase() @@ -2091,6 +2101,42 @@ void tst_QFile::renameWithAtEndSpecialFile() const QVERIFY(QFile::rename(newName, originalName)); } +void tst_QFile::renameFallback() +{ + // Using a resource file both to trigger QFile::rename's fallback handling + // and as a *read-only* source whose move should fail. + QFile file(":/rename-fallback.qrc"); + QVERIFY(file.exists() && "(test-precondition)"); + QFile::remove("file-rename-destination.txt"); + + QVERIFY(!file.rename("file-rename-destination.txt")); + QVERIFY(!QFile::exists("file-rename-destination.txt")); +} + +void tst_QFile::renameMultiple() +{ + // create the file if it doesn't exist + QFile file("file-to-be-renamed.txt"); + QVERIFY(file.open(QIODevice::ReadWrite) && "(test-precondition)"); + + // any stale files from previous test failures? + QFile::remove("file-renamed-once.txt"); + QFile::remove("file-renamed-twice.txt"); + + // begin testing + QVERIFY(file.rename("file-renamed-once.txt")); + QCOMPARE(file.fileName(), QString("file-renamed-once.txt")); + QVERIFY(file.rename("file-renamed-twice.txt")); + QCOMPARE(file.fileName(), QString("file-renamed-twice.txt")); + + QVERIFY(!QFile::exists("file-to-be-renamed.txt")); + QVERIFY(!QFile::exists("file-renamed-once.txt")); + QVERIFY(QFile::exists("file-renamed-twice.txt")); + + file.remove(); + QVERIFY(!QFile::exists("file-renamed-twice.txt")); +} + void tst_QFile::appendAndRead() { QFile writeFile(QLatin1String("appendfile.txt")); diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index d2a2546..9364af4 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -77,6 +77,7 @@ private slots: void resize(); void openOnRootDrives(); void stressTest(); + void rename(); public: }; @@ -335,5 +336,30 @@ void tst_QTemporaryFile::stressTest() } } +void tst_QTemporaryFile::rename() +{ + // This test checks that the temporary file is deleted, even after a + // rename. + + QDir dir; + QVERIFY(!dir.exists("temporary-file.txt")); + + QString tempname; + { + QTemporaryFile file(dir.filePath("temporary-file.XXXXXX")); + + QVERIFY(file.open()); + tempname = file.fileName(); + QVERIFY(dir.exists(tempname)); + + QVERIFY(file.rename("temporary-file.txt")); + QVERIFY(!dir.exists(tempname)); + QVERIFY(dir.exists("temporary-file.txt")); + } + + QVERIFY(!dir.exists(tempname)); + QVERIFY(!dir.exists("temporary-file.txt")); +} + QTEST_MAIN(tst_QTemporaryFile) #include "tst_qtemporaryfile.moc" -- cgit v0.12 From 2fb02e7b4a7937b8b215012790766078bf581e7c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 1 Apr 2009 11:38:50 +0200 Subject: don't lose codecForTr in c++ parser --- tools/linguist/lupdate/cpp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 31f1361..42aa2f0 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1800,7 +1800,9 @@ void loadCPP(Translator &translator, const QStringList &filenames, ConversionDat if (ts.codec()->name() == "UTF-16") translator.setCodecName("System"); parser.setInput(ts, filename); - parser.setTranslator(new Translator); + Translator *tor = new Translator; + tor->setCodecName(translator.codecName()); + parser.setTranslator(tor); QSet inclusions; parser.parse(cd.m_defaultContext, cd, inclusions); CppFiles::setResults(filename, parser.getResults()); -- cgit v0.12 From 00f2031c60bc472544b509586ee31c643ab2e81d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 2 Apr 2009 19:36:16 +0200 Subject: amend 3570e978058816745101a69b552ad9d07e349542 for master --- tools/linguist/shared/profileevaluator.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp index ec69156..14355b3 100644 --- a/tools/linguist/shared/profileevaluator.cpp +++ b/tools/linguist/shared/profileevaluator.cpp @@ -234,15 +234,15 @@ public: ProFileEvaluator::Private::Private(ProFileEvaluator *q_) : q(q_) { + // Global parser state m_prevLineNo = 0; m_prevProFile = 0; + + // Configuration, more or less m_verbose = true; - m_block = 0; - m_commentItem = 0; - m_syntaxError = 0; - m_lineNo = 0; - m_contNextLine = false; m_cumulative = true; + + // Evaluator state m_updateCondition = false; m_condition = ConditionFalse; m_invertNext = false; @@ -258,6 +258,7 @@ bool ProFileEvaluator::Private::read(ProFile *pro) return false; } + // Parser state m_block = 0; m_commentItem = 0; m_contNextLine = false; -- cgit v0.12 From 87a711f1b32b737231c87a4b0cde986582ef8af5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 2 Apr 2009 20:17:33 +0200 Subject: some more quoting for qmake ... sometimes, even two reviews are not enough ... --- mkspecs/features/moc.prf | 2 +- mkspecs/features/uic.prf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index d3ad4b2..f1dcf37 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -63,7 +63,7 @@ INCREDIBUILD_XGE += moc_source #make sure we can include these files moc_dir_short = $$MOC_DIR win32:moc_dir_short ~= s,^.:,/, -contains(moc_dir_short, ^[/\\].*):INCLUDEPATH += $$MOC_DIR +contains(moc_dir_short, ^[/\\\\].*):INCLUDEPATH += $$MOC_DIR else:INCLUDEPATH += $$OUT_PWD/$$MOC_DIR #auto depend on moc diff --git a/mkspecs/features/uic.prf b/mkspecs/features/uic.prf index f03d623..c7b1686 100644 --- a/mkspecs/features/uic.prf +++ b/mkspecs/features/uic.prf @@ -36,7 +36,7 @@ isEmpty(QMAKE_MOD_UIC):QMAKE_MOD_UIC = ui_ ui_dir_short = $$UI_HEADERS_DIR win32:ui_dir_short ~= s,^.:,/, -contains(ui_dir_short, ^[/\\].*):INCLUDEPATH += $$UI_HEADERS_DIR +contains(ui_dir_short, ^[/\\\\].*):INCLUDEPATH += $$UI_HEADERS_DIR else:INCLUDEPATH += $$OUT_PWD/$$UI_HEADERS_DIR uic3 { -- cgit v0.12 From 3f51c30f030a5517273a62bdd48dfe96c98852ee Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Tue, 3 Mar 2009 18:36:58 +0100 Subject: Keymap support for QWS. This patch adds support for keymaps to the QWSKeyboardHandler. The keymaps can be generated by the kmap2qmap tool (see tools/ directory). The source keymaps can be standard Linux .kmap files. Changes to Qt: * completely refactored the Tty and Usb (now known as LinuxInput) handlers * removed the LinuxIS plugin (handled by LinuxInput now) * removed support for iPAQ, EBX and Zylonite keypads (obsolete hardware) * removed support for RAW tty mode. This could be re-added, for non-Linux systems by implementing a PC/AT scan-code to Linux keycode converter. New features for Tty and LinuxInput (ex Usb) handlers: * support for keymaps QWS_KEYBOARD=..:keymap=/path/to/x.qmap:.. * support for dead keys and the compose key * support for lock LEDs * support for key repeat rates (in ms): QWS_KEYBOARD=..:repeat-delay=x:repear-rate=y:.. * the default keymap supports latin1 composing via AltGr: QWS_KEYBOARD=..:enable-compose:.. * ctrl+alt+backspace application zapping can be disabled: QWS_KEYBOARD=..:disable-zap:.. * added virtual filter functions to both the Tty and the LinuxInput handlers. (QWSKeyboardHandler::processKeycode should be virtual in the first place, but that would be BIC) Still missing: * extended documentation for QWS_KEYBOARD Reviewed-By: Paul Olav Tvete Reviewed-By: Harald Fernengel --- configure | 2 +- src/gui/embedded/embedded.pri | 19 +- src/gui/embedded/qkbd_defaultmap_qws_p.h | 744 ++++++++++++++++ src/gui/embedded/qkbd_qws.cpp | 480 ++++++++++- src/gui/embedded/qkbd_qws.h | 22 + src/gui/embedded/qkbd_qws_p.h | 77 ++ src/gui/embedded/qkbddriverfactory_qws.cpp | 14 +- src/gui/embedded/qkbdlinuxinput_qws.cpp | 241 ++++++ src/gui/embedded/qkbdlinuxinput_qws.h | 79 ++ src/gui/embedded/qkbdsl5000_qws.cpp | 25 +- src/gui/embedded/qkbdsl5000_qws.h | 19 +- src/gui/embedded/qkbdtty_qws.cpp | 301 ++++--- src/gui/embedded/qkbdtty_qws.h | 8 +- src/gui/embedded/qkbdusb_qws.cpp | 401 --------- src/gui/embedded/qkbdusb_qws.h | 77 -- src/plugins/kbddrivers/kbddrivers.pro | 3 +- src/plugins/kbddrivers/linuxinput/linuxinput.pro | 14 + src/plugins/kbddrivers/linuxinput/main.cpp | 77 ++ src/plugins/kbddrivers/linuxis/README | 1 - src/plugins/kbddrivers/linuxis/linuxis.pro | 11 - .../kbddrivers/linuxis/linuxiskbddriverplugin.cpp | 87 -- .../kbddrivers/linuxis/linuxiskbddriverplugin.h | 58 -- .../kbddrivers/linuxis/linuxiskbdhandler.cpp | 171 ---- src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h | 80 -- src/plugins/kbddrivers/usb/main.cpp | 77 -- src/plugins/kbddrivers/usb/usb.pro | 14 - tools/kmap2qmap/kmap2qmap.pro | 12 + tools/kmap2qmap/main.cpp | 948 +++++++++++++++++++++ tools/tools.pro | 2 + 29 files changed, 2912 insertions(+), 1152 deletions(-) create mode 100644 src/gui/embedded/qkbd_defaultmap_qws_p.h create mode 100644 src/gui/embedded/qkbd_qws_p.h create mode 100644 src/gui/embedded/qkbdlinuxinput_qws.cpp create mode 100644 src/gui/embedded/qkbdlinuxinput_qws.h delete mode 100644 src/gui/embedded/qkbdusb_qws.cpp delete mode 100644 src/gui/embedded/qkbdusb_qws.h create mode 100644 src/plugins/kbddrivers/linuxinput/linuxinput.pro create mode 100644 src/plugins/kbddrivers/linuxinput/main.cpp delete mode 100644 src/plugins/kbddrivers/linuxis/README delete mode 100644 src/plugins/kbddrivers/linuxis/linuxis.pro delete mode 100644 src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp delete mode 100644 src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h delete mode 100644 src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp delete mode 100644 src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h delete mode 100644 src/plugins/kbddrivers/usb/main.cpp delete mode 100644 src/plugins/kbddrivers/usb/usb.pro create mode 100644 tools/kmap2qmap/kmap2qmap.pro create mode 100644 tools/kmap2qmap/main.cpp diff --git a/configure b/configure index f79b1e2..2822f74 100755 --- a/configure +++ b/configure @@ -601,7 +601,7 @@ CFG_GFX_ON="linuxfb multiscreen" CFG_GFX_PLUGIN_AVAILABLE= CFG_GFX_PLUGIN= CFG_GFX_OFF= -CFG_KBD_AVAILABLE="tty usb sl5000 yopy vr41xx qvfb" +CFG_KBD_AVAILABLE="tty linuxinput sl5000 yopy vr41xx qvfb" CFG_KBD_ON="tty" #default, see QMakeVar above CFG_MOUSE_AVAILABLE="pc bus linuxtp yopy vr41xx tslib qvfb" CFG_MOUSE_ON="pc linuxtp" #default, see QMakeVar above diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri index 95c4132..4a9aa3f 100644 --- a/src/gui/embedded/embedded.pri +++ b/src/gui/embedded/embedded.pri @@ -89,6 +89,8 @@ embedded { HEADERS += embedded/qscreendriverplugin_qws.h \ embedded/qscreendriverfactory_qws.h \ embedded/qkbd_qws.h \ + embedded/qkbd_qws_p.h \ + embedded/qkbd_defaultmap_qws_p.h \ embedded/qkbddriverplugin_qws.h \ embedded/qkbddriverfactory_qws.h \ embedded/qmouse_qws.h \ @@ -152,17 +154,11 @@ embedded { contains( kbd-drivers, tty ) { HEADERS +=embedded/qkbdtty_qws.h SOURCES +=embedded/qkbdtty_qws.cpp - !contains( kbd-drivers, pc101 ) { - kbd-drivers += pc101 - } } - contains( kbd-drivers, usb ) { - HEADERS +=embedded/qkbdusb_qws.h - SOURCES +=embedded/qkbdusb_qws.cpp - !contains( kbd-drivers, pc101 ) { - kbd-drivers += pc101 - } + contains( kbd-drivers, linuxinput ) { + HEADERS +=embedded/qkbdlinuxinput_qws.h + SOURCES +=embedded/qkbdlinuxinput_qws.cpp } contains( kbd-drivers, um ) { @@ -170,11 +166,6 @@ embedded { SOURCES +=embedded/qkbdum_qws.cpp } - contains( kbd-drivers, pc101 ) { - HEADERS +=embedded/qkbdpc101_qws.h - SOURCES +=embedded/qkbdpc101_qws.cpp - } - contains( kbd-drivers, yopy ) { HEADERS +=embedded/qkbdyopy_qws.h SOURCES +=embedded/qkbdyopy_qws.cpp diff --git a/src/gui/embedded/qkbd_defaultmap_qws_p.h b/src/gui/embedded/qkbd_defaultmap_qws_p.h new file mode 100644 index 0000000..34ce69e --- /dev/null +++ b/src/gui/embedded/qkbd_defaultmap_qws_p.h @@ -0,0 +1,744 @@ +#ifndef QWSKEYBOARDHANDLER_DEFAULTMAP_H +#define QWSKEYBOARDHANDLER_DEFAULTMAP_H + +const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = { + { 1, 0xffff, 0x01000000, 0x00, 0x00, 0x0000 }, + { 2, 0x0031, 0x00000031, 0x00, 0x00, 0x0000 }, + { 2, 0x0021, 0x00000021, 0x01, 0x00, 0x0000 }, + { 3, 0x0032, 0x00000032, 0x00, 0x00, 0x0000 }, + { 3, 0x0040, 0x00000040, 0x01, 0x00, 0x0000 }, + { 3, 0x0040, 0x00000040, 0x02, 0x00, 0x0000 }, + { 4, 0x0033, 0x00000033, 0x00, 0x00, 0x0000 }, + { 4, 0x0023, 0x00000023, 0x01, 0x00, 0x0000 }, + { 4, 0xffff, 0x01000000, 0x04, 0x00, 0x0000 }, + { 5, 0x0034, 0x00000034, 0x00, 0x00, 0x0000 }, + { 5, 0x0024, 0x00000024, 0x01, 0x00, 0x0000 }, + { 5, 0x0024, 0x00000024, 0x02, 0x00, 0x0000 }, + { 5, 0x005c, 0x0400005c, 0x04, 0x00, 0x0000 }, + { 6, 0x0035, 0x00000035, 0x00, 0x00, 0x0000 }, + { 6, 0x0025, 0x00000025, 0x01, 0x00, 0x0000 }, + { 6, 0x005d, 0x0400005d, 0x04, 0x00, 0x0000 }, + { 7, 0x0036, 0x00000036, 0x00, 0x00, 0x0000 }, + { 7, 0x005e, 0x0000005e, 0x01, 0x00, 0x0000 }, + { 7, 0x005e, 0x01001252, 0x02, 0x01, 0x0000 }, + { 7, 0x005e, 0x0400005e, 0x04, 0x00, 0x0000 }, + { 8, 0x0037, 0x00000037, 0x00, 0x00, 0x0000 }, + { 8, 0x0026, 0x00000026, 0x01, 0x00, 0x0000 }, + { 8, 0x007b, 0x0000007b, 0x02, 0x00, 0x0000 }, + { 8, 0x005f, 0x0400005f, 0x04, 0x00, 0x0000 }, + { 9, 0x0038, 0x00000038, 0x00, 0x00, 0x0000 }, + { 9, 0x002a, 0x0000002a, 0x01, 0x00, 0x0000 }, + { 9, 0x005b, 0x0000005b, 0x02, 0x00, 0x0000 }, + { 9, 0xffff, 0x01000003, 0x04, 0x00, 0x0000 }, + { 10, 0x0039, 0x00000039, 0x00, 0x00, 0x0000 }, + { 10, 0x0028, 0x00000028, 0x01, 0x00, 0x0000 }, + { 10, 0x005d, 0x0000005d, 0x02, 0x00, 0x0000 }, + { 11, 0x0030, 0x00000030, 0x00, 0x00, 0x0000 }, + { 11, 0x0029, 0x00000029, 0x01, 0x00, 0x0000 }, + { 11, 0x007d, 0x0000007d, 0x02, 0x00, 0x0000 }, + { 12, 0x002d, 0x0000002d, 0x00, 0x00, 0x0000 }, + { 12, 0x005f, 0x0000005f, 0x01, 0x00, 0x0000 }, + { 12, 0x005c, 0x0000005c, 0x02, 0x00, 0x0000 }, + { 12, 0x005f, 0x0400005f, 0x04, 0x00, 0x0000 }, + { 12, 0x005f, 0x0400005f, 0x05, 0x00, 0x0000 }, + { 13, 0x003d, 0x0000003d, 0x00, 0x00, 0x0000 }, + { 13, 0x002b, 0x0000002b, 0x01, 0x00, 0x0000 }, + { 14, 0xffff, 0x01000003, 0x00, 0x00, 0x0000 }, + { 14, 0xffff, 0x01000000, 0x0c, 0x08, 0x0300 }, + { 15, 0xffff, 0x01000001, 0x00, 0x00, 0x0000 }, + { 16, 0x0071, 0x00000051, 0x00, 0x00, 0x0000 }, + { 16, 0x0051, 0x00000051, 0x01, 0x00, 0x0000 }, + { 16, 0x0071, 0x00000051, 0x02, 0x00, 0x0000 }, + { 16, 0x0051, 0x00000051, 0x03, 0x00, 0x0000 }, + { 16, 0x0071, 0x04000051, 0x04, 0x00, 0x0000 }, + { 16, 0x0071, 0x04000051, 0x05, 0x00, 0x0000 }, + { 16, 0x0071, 0x04000051, 0x06, 0x00, 0x0000 }, + { 16, 0x0071, 0x04000051, 0x07, 0x00, 0x0000 }, + { 16, 0x0071, 0x08000051, 0x08, 0x00, 0x0000 }, + { 16, 0x0071, 0x08000051, 0x09, 0x00, 0x0000 }, + { 16, 0x0071, 0x08000051, 0x0a, 0x00, 0x0000 }, + { 16, 0x0071, 0x08000051, 0x0b, 0x00, 0x0000 }, + { 16, 0x0071, 0x0c000051, 0x0c, 0x00, 0x0000 }, + { 16, 0x0071, 0x0c000051, 0x0d, 0x00, 0x0000 }, + { 16, 0x0071, 0x0c000051, 0x0e, 0x00, 0x0000 }, + { 16, 0x0071, 0x0c000051, 0x0f, 0x00, 0x0000 }, + { 17, 0x0077, 0x00000057, 0x00, 0x00, 0x0000 }, + { 17, 0x0057, 0x00000057, 0x01, 0x00, 0x0000 }, + { 17, 0x0077, 0x00000057, 0x02, 0x00, 0x0000 }, + { 17, 0x0057, 0x00000057, 0x03, 0x00, 0x0000 }, + { 17, 0x0077, 0x04000057, 0x04, 0x00, 0x0000 }, + { 17, 0x0077, 0x04000057, 0x05, 0x00, 0x0000 }, + { 17, 0x0077, 0x04000057, 0x06, 0x00, 0x0000 }, + { 17, 0x0077, 0x04000057, 0x07, 0x00, 0x0000 }, + { 17, 0x0077, 0x08000057, 0x08, 0x00, 0x0000 }, + { 17, 0x0077, 0x08000057, 0x09, 0x00, 0x0000 }, + { 17, 0x0077, 0x08000057, 0x0a, 0x00, 0x0000 }, + { 17, 0x0077, 0x08000057, 0x0b, 0x00, 0x0000 }, + { 17, 0x0077, 0x0c000057, 0x0c, 0x00, 0x0000 }, + { 17, 0x0077, 0x0c000057, 0x0d, 0x00, 0x0000 }, + { 17, 0x0077, 0x0c000057, 0x0e, 0x00, 0x0000 }, + { 17, 0x0077, 0x0c000057, 0x0f, 0x00, 0x0000 }, + { 18, 0x0065, 0x00000045, 0x00, 0x00, 0x0000 }, + { 18, 0x0045, 0x00000045, 0x01, 0x00, 0x0000 }, + { 18, 0x0065, 0x00000045, 0x02, 0x00, 0x0000 }, + { 18, 0x0045, 0x00000045, 0x03, 0x00, 0x0000 }, + { 18, 0x0065, 0x04000045, 0x04, 0x00, 0x0000 }, + { 18, 0x0065, 0x04000045, 0x05, 0x00, 0x0000 }, + { 18, 0x0065, 0x04000045, 0x06, 0x00, 0x0000 }, + { 18, 0x0065, 0x04000045, 0x07, 0x00, 0x0000 }, + { 18, 0x0065, 0x08000045, 0x08, 0x00, 0x0000 }, + { 18, 0x0065, 0x08000045, 0x09, 0x00, 0x0000 }, + { 18, 0x0065, 0x08000045, 0x0a, 0x00, 0x0000 }, + { 18, 0x0065, 0x08000045, 0x0b, 0x00, 0x0000 }, + { 18, 0x0065, 0x0c000045, 0x0c, 0x00, 0x0000 }, + { 18, 0x0065, 0x0c000045, 0x0d, 0x00, 0x0000 }, + { 18, 0x0065, 0x0c000045, 0x0e, 0x00, 0x0000 }, + { 18, 0x0065, 0x0c000045, 0x0f, 0x00, 0x0000 }, + { 19, 0x0072, 0x00000052, 0x00, 0x00, 0x0000 }, + { 19, 0x0052, 0x00000052, 0x01, 0x00, 0x0000 }, + { 19, 0x0072, 0x00000052, 0x02, 0x00, 0x0000 }, + { 19, 0x0052, 0x00000052, 0x03, 0x00, 0x0000 }, + { 19, 0x0072, 0x04000052, 0x04, 0x00, 0x0000 }, + { 19, 0x0072, 0x04000052, 0x05, 0x00, 0x0000 }, + { 19, 0x0072, 0x04000052, 0x06, 0x00, 0x0000 }, + { 19, 0x0072, 0x04000052, 0x07, 0x00, 0x0000 }, + { 19, 0x0072, 0x08000052, 0x08, 0x00, 0x0000 }, + { 19, 0x0072, 0x08000052, 0x09, 0x00, 0x0000 }, + { 19, 0x0072, 0x08000052, 0x0a, 0x00, 0x0000 }, + { 19, 0x0072, 0x08000052, 0x0b, 0x00, 0x0000 }, + { 19, 0x0072, 0x0c000052, 0x0c, 0x00, 0x0000 }, + { 19, 0x0072, 0x0c000052, 0x0d, 0x00, 0x0000 }, + { 19, 0x0072, 0x0c000052, 0x0e, 0x00, 0x0000 }, + { 19, 0x0072, 0x0c000052, 0x0f, 0x00, 0x0000 }, + { 20, 0x0074, 0x00000054, 0x00, 0x00, 0x0000 }, + { 20, 0x0054, 0x00000054, 0x01, 0x00, 0x0000 }, + { 20, 0x0074, 0x00000054, 0x02, 0x00, 0x0000 }, + { 20, 0x0054, 0x00000054, 0x03, 0x00, 0x0000 }, + { 20, 0x0074, 0x04000054, 0x04, 0x00, 0x0000 }, + { 20, 0x0074, 0x04000054, 0x05, 0x00, 0x0000 }, + { 20, 0x0074, 0x04000054, 0x06, 0x00, 0x0000 }, + { 20, 0x0074, 0x04000054, 0x07, 0x00, 0x0000 }, + { 20, 0x0074, 0x08000054, 0x08, 0x00, 0x0000 }, + { 20, 0x0074, 0x08000054, 0x09, 0x00, 0x0000 }, + { 20, 0x0074, 0x08000054, 0x0a, 0x00, 0x0000 }, + { 20, 0x0074, 0x08000054, 0x0b, 0x00, 0x0000 }, + { 20, 0x0074, 0x0c000054, 0x0c, 0x00, 0x0000 }, + { 20, 0x0074, 0x0c000054, 0x0d, 0x00, 0x0000 }, + { 20, 0x0074, 0x0c000054, 0x0e, 0x00, 0x0000 }, + { 20, 0x0074, 0x0c000054, 0x0f, 0x00, 0x0000 }, + { 21, 0x0079, 0x00000059, 0x00, 0x00, 0x0000 }, + { 21, 0x0059, 0x00000059, 0x01, 0x00, 0x0000 }, + { 21, 0x0079, 0x00000059, 0x02, 0x00, 0x0000 }, + { 21, 0x0059, 0x00000059, 0x03, 0x00, 0x0000 }, + { 21, 0x0079, 0x04000059, 0x04, 0x00, 0x0000 }, + { 21, 0x0079, 0x04000059, 0x05, 0x00, 0x0000 }, + { 21, 0x0079, 0x04000059, 0x06, 0x00, 0x0000 }, + { 21, 0x0079, 0x04000059, 0x07, 0x00, 0x0000 }, + { 21, 0x0079, 0x08000059, 0x08, 0x00, 0x0000 }, + { 21, 0x0079, 0x08000059, 0x09, 0x00, 0x0000 }, + { 21, 0x0079, 0x08000059, 0x0a, 0x00, 0x0000 }, + { 21, 0x0079, 0x08000059, 0x0b, 0x00, 0x0000 }, + { 21, 0x0079, 0x0c000059, 0x0c, 0x00, 0x0000 }, + { 21, 0x0079, 0x0c000059, 0x0d, 0x00, 0x0000 }, + { 21, 0x0079, 0x0c000059, 0x0e, 0x00, 0x0000 }, + { 21, 0x0079, 0x0c000059, 0x0f, 0x00, 0x0000 }, + { 22, 0x0075, 0x00000055, 0x00, 0x00, 0x0000 }, + { 22, 0x0055, 0x00000055, 0x01, 0x00, 0x0000 }, + { 22, 0x0075, 0x00000055, 0x02, 0x00, 0x0000 }, + { 22, 0x0055, 0x00000055, 0x03, 0x00, 0x0000 }, + { 22, 0x0075, 0x04000055, 0x04, 0x00, 0x0000 }, + { 22, 0x0075, 0x04000055, 0x05, 0x00, 0x0000 }, + { 22, 0x0075, 0x04000055, 0x06, 0x00, 0x0000 }, + { 22, 0x0075, 0x04000055, 0x07, 0x00, 0x0000 }, + { 22, 0x0075, 0x08000055, 0x08, 0x00, 0x0000 }, + { 22, 0x0075, 0x08000055, 0x09, 0x00, 0x0000 }, + { 22, 0x0075, 0x08000055, 0x0a, 0x00, 0x0000 }, + { 22, 0x0075, 0x08000055, 0x0b, 0x00, 0x0000 }, + { 22, 0x0075, 0x0c000055, 0x0c, 0x00, 0x0000 }, + { 22, 0x0075, 0x0c000055, 0x0d, 0x00, 0x0000 }, + { 22, 0x0075, 0x0c000055, 0x0e, 0x00, 0x0000 }, + { 22, 0x0075, 0x0c000055, 0x0f, 0x00, 0x0000 }, + { 23, 0x0069, 0x00000049, 0x00, 0x00, 0x0000 }, + { 23, 0x0049, 0x00000049, 0x01, 0x00, 0x0000 }, + { 23, 0x0069, 0x00000049, 0x02, 0x00, 0x0000 }, + { 23, 0x0049, 0x00000049, 0x03, 0x00, 0x0000 }, + { 23, 0x0069, 0x04000049, 0x04, 0x00, 0x0000 }, + { 23, 0x0069, 0x04000049, 0x05, 0x00, 0x0000 }, + { 23, 0x0069, 0x04000049, 0x06, 0x00, 0x0000 }, + { 23, 0x0069, 0x04000049, 0x07, 0x00, 0x0000 }, + { 23, 0x0069, 0x08000049, 0x08, 0x00, 0x0000 }, + { 23, 0x0069, 0x08000049, 0x09, 0x00, 0x0000 }, + { 23, 0x0069, 0x08000049, 0x0a, 0x00, 0x0000 }, + { 23, 0x0069, 0x08000049, 0x0b, 0x00, 0x0000 }, + { 23, 0x0069, 0x0c000049, 0x0c, 0x00, 0x0000 }, + { 23, 0x0069, 0x0c000049, 0x0d, 0x00, 0x0000 }, + { 23, 0x0069, 0x0c000049, 0x0e, 0x00, 0x0000 }, + { 23, 0x0069, 0x0c000049, 0x0f, 0x00, 0x0000 }, + { 24, 0x006f, 0x0000004f, 0x00, 0x00, 0x0000 }, + { 24, 0x004f, 0x0000004f, 0x01, 0x00, 0x0000 }, + { 24, 0x006f, 0x0000004f, 0x02, 0x00, 0x0000 }, + { 24, 0x004f, 0x0000004f, 0x03, 0x00, 0x0000 }, + { 24, 0x006f, 0x0400004f, 0x04, 0x00, 0x0000 }, + { 24, 0x006f, 0x0400004f, 0x05, 0x00, 0x0000 }, + { 24, 0x006f, 0x0400004f, 0x06, 0x00, 0x0000 }, + { 24, 0x006f, 0x0400004f, 0x07, 0x00, 0x0000 }, + { 24, 0x006f, 0x0800004f, 0x08, 0x00, 0x0000 }, + { 24, 0x006f, 0x0800004f, 0x09, 0x00, 0x0000 }, + { 24, 0x006f, 0x0800004f, 0x0a, 0x00, 0x0000 }, + { 24, 0x006f, 0x0800004f, 0x0b, 0x00, 0x0000 }, + { 24, 0x006f, 0x0c00004f, 0x0c, 0x00, 0x0000 }, + { 24, 0x006f, 0x0c00004f, 0x0d, 0x00, 0x0000 }, + { 24, 0x006f, 0x0c00004f, 0x0e, 0x00, 0x0000 }, + { 24, 0x006f, 0x0c00004f, 0x0f, 0x00, 0x0000 }, + { 25, 0x0070, 0x00000050, 0x00, 0x00, 0x0000 }, + { 25, 0x0050, 0x00000050, 0x01, 0x00, 0x0000 }, + { 25, 0x0070, 0x00000050, 0x02, 0x00, 0x0000 }, + { 25, 0x0050, 0x00000050, 0x03, 0x00, 0x0000 }, + { 25, 0x0070, 0x04000050, 0x04, 0x00, 0x0000 }, + { 25, 0x0070, 0x04000050, 0x05, 0x00, 0x0000 }, + { 25, 0x0070, 0x04000050, 0x06, 0x00, 0x0000 }, + { 25, 0x0070, 0x04000050, 0x07, 0x00, 0x0000 }, + { 25, 0x0070, 0x08000050, 0x08, 0x00, 0x0000 }, + { 25, 0x0070, 0x08000050, 0x09, 0x00, 0x0000 }, + { 25, 0x0070, 0x08000050, 0x0a, 0x00, 0x0000 }, + { 25, 0x0070, 0x08000050, 0x0b, 0x00, 0x0000 }, + { 25, 0x0070, 0x0c000050, 0x0c, 0x00, 0x0000 }, + { 25, 0x0070, 0x0c000050, 0x0d, 0x00, 0x0000 }, + { 25, 0x0070, 0x0c000050, 0x0e, 0x00, 0x0000 }, + { 25, 0x0070, 0x0c000050, 0x0f, 0x00, 0x0000 }, + { 26, 0x005b, 0x0000005b, 0x00, 0x00, 0x0000 }, + { 26, 0x007b, 0x0000007b, 0x01, 0x00, 0x0000 }, + { 26, 0xffff, 0x01000000, 0x04, 0x00, 0x0000 }, + { 27, 0x005d, 0x0000005d, 0x00, 0x00, 0x0000 }, + { 27, 0x007d, 0x0000007d, 0x01, 0x00, 0x0000 }, + { 27, 0x007e, 0x0000007e, 0x02, 0x00, 0x0000 }, + { 27, 0x005d, 0x0400005d, 0x04, 0x00, 0x0000 }, + { 28, 0xffff, 0x01000004, 0x00, 0x00, 0x0000 }, + { 28, 0x006d, 0x0c00004d, 0x08, 0x00, 0x0000 }, + { 29, 0xffff, 0x01000021, 0x00, 0x04, 0x0004 }, + { 30, 0x0061, 0x00000041, 0x00, 0x00, 0x0000 }, + { 30, 0x0041, 0x00000041, 0x01, 0x00, 0x0000 }, + { 30, 0x0061, 0x00000041, 0x02, 0x00, 0x0000 }, + { 30, 0x0041, 0x00000041, 0x03, 0x00, 0x0000 }, + { 30, 0x0061, 0x04000041, 0x04, 0x00, 0x0000 }, + { 30, 0x0061, 0x04000041, 0x05, 0x00, 0x0000 }, + { 30, 0x0061, 0x04000041, 0x06, 0x00, 0x0000 }, + { 30, 0x0061, 0x04000041, 0x07, 0x00, 0x0000 }, + { 30, 0x0061, 0x08000041, 0x08, 0x00, 0x0000 }, + { 30, 0x0061, 0x08000041, 0x09, 0x00, 0x0000 }, + { 30, 0x0061, 0x08000041, 0x0a, 0x00, 0x0000 }, + { 30, 0x0061, 0x08000041, 0x0b, 0x00, 0x0000 }, + { 30, 0x0061, 0x0c000041, 0x0c, 0x00, 0x0000 }, + { 30, 0x0061, 0x0c000041, 0x0d, 0x00, 0x0000 }, + { 30, 0x0061, 0x0c000041, 0x0e, 0x00, 0x0000 }, + { 30, 0x0061, 0x0c000041, 0x0f, 0x00, 0x0000 }, + { 31, 0x0073, 0x00000053, 0x00, 0x00, 0x0000 }, + { 31, 0x0053, 0x00000053, 0x01, 0x00, 0x0000 }, + { 31, 0x0073, 0x00000053, 0x02, 0x00, 0x0000 }, + { 31, 0x0053, 0x00000053, 0x03, 0x00, 0x0000 }, + { 31, 0x0073, 0x04000053, 0x04, 0x00, 0x0000 }, + { 31, 0x0073, 0x04000053, 0x05, 0x00, 0x0000 }, + { 31, 0x0073, 0x04000053, 0x06, 0x00, 0x0000 }, + { 31, 0x0073, 0x04000053, 0x07, 0x00, 0x0000 }, + { 31, 0x0073, 0x08000053, 0x08, 0x00, 0x0000 }, + { 31, 0x0073, 0x08000053, 0x09, 0x00, 0x0000 }, + { 31, 0x0073, 0x08000053, 0x0a, 0x00, 0x0000 }, + { 31, 0x0073, 0x08000053, 0x0b, 0x00, 0x0000 }, + { 31, 0x0073, 0x0c000053, 0x0c, 0x00, 0x0000 }, + { 31, 0x0073, 0x0c000053, 0x0d, 0x00, 0x0000 }, + { 31, 0x0073, 0x0c000053, 0x0e, 0x00, 0x0000 }, + { 31, 0x0073, 0x0c000053, 0x0f, 0x00, 0x0000 }, + { 32, 0x0064, 0x00000044, 0x00, 0x00, 0x0000 }, + { 32, 0x0044, 0x00000044, 0x01, 0x00, 0x0000 }, + { 32, 0x0064, 0x00000044, 0x02, 0x00, 0x0000 }, + { 32, 0x0044, 0x00000044, 0x03, 0x00, 0x0000 }, + { 32, 0x0064, 0x04000044, 0x04, 0x00, 0x0000 }, + { 32, 0x0064, 0x04000044, 0x05, 0x00, 0x0000 }, + { 32, 0x0064, 0x04000044, 0x06, 0x00, 0x0000 }, + { 32, 0x0064, 0x04000044, 0x07, 0x00, 0x0000 }, + { 32, 0x0064, 0x08000044, 0x08, 0x00, 0x0000 }, + { 32, 0x0064, 0x08000044, 0x09, 0x00, 0x0000 }, + { 32, 0x0064, 0x08000044, 0x0a, 0x00, 0x0000 }, + { 32, 0x0064, 0x08000044, 0x0b, 0x00, 0x0000 }, + { 32, 0x0064, 0x0c000044, 0x0c, 0x00, 0x0000 }, + { 32, 0x0064, 0x0c000044, 0x0d, 0x00, 0x0000 }, + { 32, 0x0064, 0x0c000044, 0x0e, 0x00, 0x0000 }, + { 32, 0x0064, 0x0c000044, 0x0f, 0x00, 0x0000 }, + { 33, 0x0066, 0x00000046, 0x00, 0x00, 0x0000 }, + { 33, 0x0046, 0x00000046, 0x01, 0x00, 0x0000 }, + { 33, 0x0066, 0x00000046, 0x02, 0x00, 0x0000 }, + { 33, 0x0046, 0x00000046, 0x03, 0x00, 0x0000 }, + { 33, 0x0066, 0x04000046, 0x04, 0x00, 0x0000 }, + { 33, 0x0066, 0x04000046, 0x05, 0x00, 0x0000 }, + { 33, 0x0066, 0x04000046, 0x06, 0x00, 0x0000 }, + { 33, 0x0066, 0x04000046, 0x07, 0x00, 0x0000 }, + { 33, 0x0066, 0x08000046, 0x08, 0x00, 0x0000 }, + { 33, 0x0066, 0x08000046, 0x09, 0x00, 0x0000 }, + { 33, 0x0066, 0x08000046, 0x0a, 0x00, 0x0000 }, + { 33, 0x0066, 0x08000046, 0x0b, 0x00, 0x0000 }, + { 33, 0x0066, 0x0c000046, 0x0c, 0x00, 0x0000 }, + { 33, 0x0066, 0x0c000046, 0x0d, 0x00, 0x0000 }, + { 33, 0x0066, 0x0c000046, 0x0e, 0x00, 0x0000 }, + { 33, 0x0066, 0x0c000046, 0x0f, 0x00, 0x0000 }, + { 34, 0x0067, 0x00000047, 0x00, 0x00, 0x0000 }, + { 34, 0x0047, 0x00000047, 0x01, 0x00, 0x0000 }, + { 34, 0x0067, 0x00000047, 0x02, 0x00, 0x0000 }, + { 34, 0x0047, 0x00000047, 0x03, 0x00, 0x0000 }, + { 34, 0x0067, 0x04000047, 0x04, 0x00, 0x0000 }, + { 34, 0x0067, 0x04000047, 0x05, 0x00, 0x0000 }, + { 34, 0x0067, 0x04000047, 0x06, 0x00, 0x0000 }, + { 34, 0x0067, 0x04000047, 0x07, 0x00, 0x0000 }, + { 34, 0x0067, 0x08000047, 0x08, 0x00, 0x0000 }, + { 34, 0x0067, 0x08000047, 0x09, 0x00, 0x0000 }, + { 34, 0x0067, 0x08000047, 0x0a, 0x00, 0x0000 }, + { 34, 0x0067, 0x08000047, 0x0b, 0x00, 0x0000 }, + { 34, 0x0067, 0x0c000047, 0x0c, 0x00, 0x0000 }, + { 34, 0x0067, 0x0c000047, 0x0d, 0x00, 0x0000 }, + { 34, 0x0067, 0x0c000047, 0x0e, 0x00, 0x0000 }, + { 34, 0x0067, 0x0c000047, 0x0f, 0x00, 0x0000 }, + { 35, 0x0068, 0x00000048, 0x00, 0x00, 0x0000 }, + { 35, 0x0048, 0x00000048, 0x01, 0x00, 0x0000 }, + { 35, 0x0068, 0x00000048, 0x02, 0x00, 0x0000 }, + { 35, 0x0048, 0x00000048, 0x03, 0x00, 0x0000 }, + { 35, 0x0068, 0x04000048, 0x04, 0x00, 0x0000 }, + { 35, 0x0068, 0x04000048, 0x05, 0x00, 0x0000 }, + { 35, 0x0068, 0x04000048, 0x06, 0x00, 0x0000 }, + { 35, 0x0068, 0x04000048, 0x07, 0x00, 0x0000 }, + { 35, 0x0068, 0x08000048, 0x08, 0x00, 0x0000 }, + { 35, 0x0068, 0x08000048, 0x09, 0x00, 0x0000 }, + { 35, 0x0068, 0x08000048, 0x0a, 0x00, 0x0000 }, + { 35, 0x0068, 0x08000048, 0x0b, 0x00, 0x0000 }, + { 35, 0x0068, 0x0c000048, 0x0c, 0x00, 0x0000 }, + { 35, 0x0068, 0x0c000048, 0x0d, 0x00, 0x0000 }, + { 35, 0x0068, 0x0c000048, 0x0e, 0x00, 0x0000 }, + { 35, 0x0068, 0x0c000048, 0x0f, 0x00, 0x0000 }, + { 36, 0x006a, 0x0000004a, 0x00, 0x00, 0x0000 }, + { 36, 0x004a, 0x0000004a, 0x01, 0x00, 0x0000 }, + { 36, 0x006a, 0x0000004a, 0x02, 0x00, 0x0000 }, + { 36, 0x004a, 0x0000004a, 0x03, 0x00, 0x0000 }, + { 36, 0x006a, 0x0400004a, 0x04, 0x00, 0x0000 }, + { 36, 0x006a, 0x0400004a, 0x05, 0x00, 0x0000 }, + { 36, 0x006a, 0x0400004a, 0x06, 0x00, 0x0000 }, + { 36, 0x006a, 0x0400004a, 0x07, 0x00, 0x0000 }, + { 36, 0x006a, 0x0800004a, 0x08, 0x00, 0x0000 }, + { 36, 0x006a, 0x0800004a, 0x09, 0x00, 0x0000 }, + { 36, 0x006a, 0x0800004a, 0x0a, 0x00, 0x0000 }, + { 36, 0x006a, 0x0800004a, 0x0b, 0x00, 0x0000 }, + { 36, 0x006a, 0x0c00004a, 0x0c, 0x00, 0x0000 }, + { 36, 0x006a, 0x0c00004a, 0x0d, 0x00, 0x0000 }, + { 36, 0x006a, 0x0c00004a, 0x0e, 0x00, 0x0000 }, + { 36, 0x006a, 0x0c00004a, 0x0f, 0x00, 0x0000 }, + { 37, 0x006b, 0x0000004b, 0x00, 0x00, 0x0000 }, + { 37, 0x004b, 0x0000004b, 0x01, 0x00, 0x0000 }, + { 37, 0x006b, 0x0000004b, 0x02, 0x00, 0x0000 }, + { 37, 0x004b, 0x0000004b, 0x03, 0x00, 0x0000 }, + { 37, 0x006b, 0x0400004b, 0x04, 0x00, 0x0000 }, + { 37, 0x006b, 0x0400004b, 0x05, 0x00, 0x0000 }, + { 37, 0x006b, 0x0400004b, 0x06, 0x00, 0x0000 }, + { 37, 0x006b, 0x0400004b, 0x07, 0x00, 0x0000 }, + { 37, 0x006b, 0x0800004b, 0x08, 0x00, 0x0000 }, + { 37, 0x006b, 0x0800004b, 0x09, 0x00, 0x0000 }, + { 37, 0x006b, 0x0800004b, 0x0a, 0x00, 0x0000 }, + { 37, 0x006b, 0x0800004b, 0x0b, 0x00, 0x0000 }, + { 37, 0x006b, 0x0c00004b, 0x0c, 0x00, 0x0000 }, + { 37, 0x006b, 0x0c00004b, 0x0d, 0x00, 0x0000 }, + { 37, 0x006b, 0x0c00004b, 0x0e, 0x00, 0x0000 }, + { 37, 0x006b, 0x0c00004b, 0x0f, 0x00, 0x0000 }, + { 38, 0x006c, 0x0000004c, 0x00, 0x00, 0x0000 }, + { 38, 0x004c, 0x0000004c, 0x01, 0x00, 0x0000 }, + { 38, 0x006c, 0x0000004c, 0x02, 0x00, 0x0000 }, + { 38, 0x004c, 0x0000004c, 0x03, 0x00, 0x0000 }, + { 38, 0x006c, 0x0400004c, 0x04, 0x00, 0x0000 }, + { 38, 0x006c, 0x0400004c, 0x05, 0x00, 0x0000 }, + { 38, 0x006c, 0x0400004c, 0x06, 0x00, 0x0000 }, + { 38, 0x006c, 0x0400004c, 0x07, 0x00, 0x0000 }, + { 38, 0x006c, 0x0800004c, 0x08, 0x00, 0x0000 }, + { 38, 0x006c, 0x0800004c, 0x09, 0x00, 0x0000 }, + { 38, 0x006c, 0x0800004c, 0x0a, 0x00, 0x0000 }, + { 38, 0x006c, 0x0800004c, 0x0b, 0x00, 0x0000 }, + { 38, 0x006c, 0x0c00004c, 0x0c, 0x00, 0x0000 }, + { 38, 0x006c, 0x0c00004c, 0x0d, 0x00, 0x0000 }, + { 38, 0x006c, 0x0c00004c, 0x0e, 0x00, 0x0000 }, + { 38, 0x006c, 0x0c00004c, 0x0f, 0x00, 0x0000 }, + { 39, 0x003b, 0x0000003b, 0x00, 0x00, 0x0000 }, + { 39, 0x003a, 0x0000003a, 0x01, 0x00, 0x0000 }, + { 40, 0x0027, 0x00000027, 0x00, 0x00, 0x0000 }, + { 40, 0x0022, 0x00000022, 0x01, 0x00, 0x0000 }, + { 40, 0x0027, 0x01001251, 0x02, 0x01, 0x0000 }, + { 40, 0x0022, 0x01001257, 0x03, 0x01, 0x0000 }, + { 40, 0x0067, 0x04000047, 0x04, 0x00, 0x0000 }, + { 41, 0x0060, 0x00000060, 0x00, 0x00, 0x0000 }, + { 41, 0x007e, 0x0000007e, 0x01, 0x00, 0x0000 }, + { 41, 0x0060, 0x01001250, 0x02, 0x01, 0x0000 }, + { 41, 0x007e, 0x01001253, 0x03, 0x01, 0x0000 }, + { 42, 0xffff, 0x01000020, 0x00, 0x04, 0x0001 }, + { 43, 0x005c, 0x0000005c, 0x00, 0x00, 0x0000 }, + { 43, 0x007c, 0x0000007c, 0x01, 0x00, 0x0000 }, + { 43, 0x005c, 0x0400005c, 0x04, 0x00, 0x0000 }, + { 44, 0x007a, 0x0000005a, 0x00, 0x00, 0x0000 }, + { 44, 0x005a, 0x0000005a, 0x01, 0x00, 0x0000 }, + { 44, 0x007a, 0x0000005a, 0x02, 0x00, 0x0000 }, + { 44, 0x005a, 0x0000005a, 0x03, 0x00, 0x0000 }, + { 44, 0x007a, 0x0400005a, 0x04, 0x00, 0x0000 }, + { 44, 0x007a, 0x0400005a, 0x05, 0x00, 0x0000 }, + { 44, 0x007a, 0x0400005a, 0x06, 0x00, 0x0000 }, + { 44, 0x007a, 0x0400005a, 0x07, 0x00, 0x0000 }, + { 44, 0x007a, 0x0800005a, 0x08, 0x00, 0x0000 }, + { 44, 0x007a, 0x0800005a, 0x09, 0x00, 0x0000 }, + { 44, 0x007a, 0x0800005a, 0x0a, 0x00, 0x0000 }, + { 44, 0x007a, 0x0800005a, 0x0b, 0x00, 0x0000 }, + { 44, 0x007a, 0x0c00005a, 0x0c, 0x00, 0x0000 }, + { 44, 0x007a, 0x0c00005a, 0x0d, 0x00, 0x0000 }, + { 44, 0x007a, 0x0c00005a, 0x0e, 0x00, 0x0000 }, + { 44, 0x007a, 0x0c00005a, 0x0f, 0x00, 0x0000 }, + { 45, 0x0078, 0x00000058, 0x00, 0x00, 0x0000 }, + { 45, 0x0058, 0x00000058, 0x01, 0x00, 0x0000 }, + { 45, 0x0078, 0x00000058, 0x02, 0x00, 0x0000 }, + { 45, 0x0058, 0x00000058, 0x03, 0x00, 0x0000 }, + { 45, 0x0078, 0x04000058, 0x04, 0x00, 0x0000 }, + { 45, 0x0078, 0x04000058, 0x05, 0x00, 0x0000 }, + { 45, 0x0078, 0x04000058, 0x06, 0x00, 0x0000 }, + { 45, 0x0078, 0x04000058, 0x07, 0x00, 0x0000 }, + { 45, 0x0078, 0x08000058, 0x08, 0x00, 0x0000 }, + { 45, 0x0078, 0x08000058, 0x09, 0x00, 0x0000 }, + { 45, 0x0078, 0x08000058, 0x0a, 0x00, 0x0000 }, + { 45, 0x0078, 0x08000058, 0x0b, 0x00, 0x0000 }, + { 45, 0x0078, 0x0c000058, 0x0c, 0x00, 0x0000 }, + { 45, 0x0078, 0x0c000058, 0x0d, 0x00, 0x0000 }, + { 45, 0x0078, 0x0c000058, 0x0e, 0x00, 0x0000 }, + { 45, 0x0078, 0x0c000058, 0x0f, 0x00, 0x0000 }, + { 46, 0x0063, 0x00000043, 0x00, 0x00, 0x0000 }, + { 46, 0x0043, 0x00000043, 0x01, 0x00, 0x0000 }, + { 46, 0x0063, 0x00000043, 0x02, 0x00, 0x0000 }, + { 46, 0x0043, 0x00000043, 0x03, 0x00, 0x0000 }, + { 46, 0x0063, 0x04000043, 0x04, 0x00, 0x0000 }, + { 46, 0x0063, 0x04000043, 0x05, 0x00, 0x0000 }, + { 46, 0x0063, 0x04000043, 0x06, 0x00, 0x0000 }, + { 46, 0x0063, 0x04000043, 0x07, 0x00, 0x0000 }, + { 46, 0x0063, 0x08000043, 0x08, 0x00, 0x0000 }, + { 46, 0x0063, 0x08000043, 0x09, 0x00, 0x0000 }, + { 46, 0x0063, 0x08000043, 0x0a, 0x00, 0x0000 }, + { 46, 0x0063, 0x08000043, 0x0b, 0x00, 0x0000 }, + { 46, 0x0063, 0x0c000043, 0x0c, 0x00, 0x0000 }, + { 46, 0x0063, 0x0c000043, 0x0d, 0x00, 0x0000 }, + { 46, 0x0063, 0x0c000043, 0x0e, 0x00, 0x0000 }, + { 46, 0x0063, 0x0c000043, 0x0f, 0x00, 0x0000 }, + { 47, 0x0076, 0x00000056, 0x00, 0x00, 0x0000 }, + { 47, 0x0056, 0x00000056, 0x01, 0x00, 0x0000 }, + { 47, 0x0076, 0x00000056, 0x02, 0x00, 0x0000 }, + { 47, 0x0056, 0x00000056, 0x03, 0x00, 0x0000 }, + { 47, 0x0076, 0x04000056, 0x04, 0x00, 0x0000 }, + { 47, 0x0076, 0x04000056, 0x05, 0x00, 0x0000 }, + { 47, 0x0076, 0x04000056, 0x06, 0x00, 0x0000 }, + { 47, 0x0076, 0x04000056, 0x07, 0x00, 0x0000 }, + { 47, 0x0076, 0x08000056, 0x08, 0x00, 0x0000 }, + { 47, 0x0076, 0x08000056, 0x09, 0x00, 0x0000 }, + { 47, 0x0076, 0x08000056, 0x0a, 0x00, 0x0000 }, + { 47, 0x0076, 0x08000056, 0x0b, 0x00, 0x0000 }, + { 47, 0x0076, 0x0c000056, 0x0c, 0x00, 0x0000 }, + { 47, 0x0076, 0x0c000056, 0x0d, 0x00, 0x0000 }, + { 47, 0x0076, 0x0c000056, 0x0e, 0x00, 0x0000 }, + { 47, 0x0076, 0x0c000056, 0x0f, 0x00, 0x0000 }, + { 48, 0x0062, 0x00000042, 0x00, 0x00, 0x0000 }, + { 48, 0x0042, 0x00000042, 0x01, 0x00, 0x0000 }, + { 48, 0x0062, 0x00000042, 0x02, 0x00, 0x0000 }, + { 48, 0x0042, 0x00000042, 0x03, 0x00, 0x0000 }, + { 48, 0x0062, 0x04000042, 0x04, 0x00, 0x0000 }, + { 48, 0x0062, 0x04000042, 0x05, 0x00, 0x0000 }, + { 48, 0x0062, 0x04000042, 0x06, 0x00, 0x0000 }, + { 48, 0x0062, 0x04000042, 0x07, 0x00, 0x0000 }, + { 48, 0x0062, 0x08000042, 0x08, 0x00, 0x0000 }, + { 48, 0x0062, 0x08000042, 0x09, 0x00, 0x0000 }, + { 48, 0x0062, 0x08000042, 0x0a, 0x00, 0x0000 }, + { 48, 0x0062, 0x08000042, 0x0b, 0x00, 0x0000 }, + { 48, 0x0062, 0x0c000042, 0x0c, 0x00, 0x0000 }, + { 48, 0x0062, 0x0c000042, 0x0d, 0x00, 0x0000 }, + { 48, 0x0062, 0x0c000042, 0x0e, 0x00, 0x0000 }, + { 48, 0x0062, 0x0c000042, 0x0f, 0x00, 0x0000 }, + { 49, 0x006e, 0x0000004e, 0x00, 0x00, 0x0000 }, + { 49, 0x004e, 0x0000004e, 0x01, 0x00, 0x0000 }, + { 49, 0x006e, 0x0000004e, 0x02, 0x00, 0x0000 }, + { 49, 0x004e, 0x0000004e, 0x03, 0x00, 0x0000 }, + { 49, 0x006e, 0x0400004e, 0x04, 0x00, 0x0000 }, + { 49, 0x006e, 0x0400004e, 0x05, 0x00, 0x0000 }, + { 49, 0x006e, 0x0400004e, 0x06, 0x00, 0x0000 }, + { 49, 0x006e, 0x0400004e, 0x07, 0x00, 0x0000 }, + { 49, 0x006e, 0x0800004e, 0x08, 0x00, 0x0000 }, + { 49, 0x006e, 0x0800004e, 0x09, 0x00, 0x0000 }, + { 49, 0x006e, 0x0800004e, 0x0a, 0x00, 0x0000 }, + { 49, 0x006e, 0x0800004e, 0x0b, 0x00, 0x0000 }, + { 49, 0x006e, 0x0c00004e, 0x0c, 0x00, 0x0000 }, + { 49, 0x006e, 0x0c00004e, 0x0d, 0x00, 0x0000 }, + { 49, 0x006e, 0x0c00004e, 0x0e, 0x00, 0x0000 }, + { 49, 0x006e, 0x0c00004e, 0x0f, 0x00, 0x0000 }, + { 50, 0x006d, 0x0000004d, 0x00, 0x00, 0x0000 }, + { 50, 0x004d, 0x0000004d, 0x01, 0x00, 0x0000 }, + { 50, 0x006d, 0x0000004d, 0x02, 0x00, 0x0000 }, + { 50, 0x004d, 0x0000004d, 0x03, 0x00, 0x0000 }, + { 50, 0x006d, 0x0400004d, 0x04, 0x00, 0x0000 }, + { 50, 0x006d, 0x0400004d, 0x05, 0x00, 0x0000 }, + { 50, 0x006d, 0x0400004d, 0x06, 0x00, 0x0000 }, + { 50, 0x006d, 0x0400004d, 0x07, 0x00, 0x0000 }, + { 50, 0x006d, 0x0800004d, 0x08, 0x00, 0x0000 }, + { 50, 0x006d, 0x0800004d, 0x09, 0x00, 0x0000 }, + { 50, 0x006d, 0x0800004d, 0x0a, 0x00, 0x0000 }, + { 50, 0x006d, 0x0800004d, 0x0b, 0x00, 0x0000 }, + { 50, 0x006d, 0x0c00004d, 0x0c, 0x00, 0x0000 }, + { 50, 0x006d, 0x0c00004d, 0x0d, 0x00, 0x0000 }, + { 50, 0x006d, 0x0c00004d, 0x0e, 0x00, 0x0000 }, + { 50, 0x006d, 0x0c00004d, 0x0f, 0x00, 0x0000 }, + { 51, 0x002c, 0x0000002c, 0x00, 0x00, 0x0000 }, + { 51, 0x003c, 0x0000003c, 0x01, 0x00, 0x0000 }, + { 51, 0x002c, 0x0100125b, 0x02, 0x01, 0x0000 }, + { 52, 0x002e, 0x0000002e, 0x00, 0x00, 0x0000 }, + { 52, 0x003e, 0x0000003e, 0x01, 0x00, 0x0000 }, + { 52, 0xffff, 0x01001120, 0x02, 0x00, 0x0000 }, + { 53, 0x002f, 0x0000002f, 0x00, 0x00, 0x0000 }, + { 53, 0x003f, 0x0000003f, 0x01, 0x00, 0x0000 }, + { 53, 0xffff, 0x01000003, 0x04, 0x00, 0x0000 }, + { 54, 0xffff, 0x01000020, 0x00, 0x04, 0x0001 }, + { 55, 0x002a, 0x2000002a, 0x00, 0x00, 0x0000 }, + { 56, 0xffff, 0x01000023, 0x00, 0x04, 0x0008 }, + { 57, 0x0020, 0x00000020, 0x00, 0x00, 0x0000 }, + { 58, 0xffff, 0x01000024, 0x00, 0x00, 0x0000 }, + { 59, 0xffff, 0x01000030, 0x00, 0x00, 0x0000 }, + { 59, 0xffff, 0x0100003c, 0x01, 0x00, 0x0000 }, + { 59, 0xffff, 0x01000048, 0x04, 0x00, 0x0000 }, + { 59, 0xffff, 0x01000000, 0x0c, 0x08, 0x0100 }, + { 60, 0xffff, 0x01000031, 0x00, 0x00, 0x0000 }, + { 60, 0xffff, 0x0100003d, 0x01, 0x00, 0x0000 }, + { 60, 0xffff, 0x01000049, 0x04, 0x00, 0x0000 }, + { 60, 0xffff, 0x01000000, 0x0c, 0x08, 0x0101 }, + { 61, 0xffff, 0x01000032, 0x00, 0x00, 0x0000 }, + { 61, 0xffff, 0x0100003e, 0x01, 0x00, 0x0000 }, + { 61, 0xffff, 0x0100004a, 0x04, 0x00, 0x0000 }, + { 61, 0xffff, 0x01000000, 0x0c, 0x08, 0x0102 }, + { 62, 0xffff, 0x01000033, 0x00, 0x00, 0x0000 }, + { 62, 0xffff, 0x0100003f, 0x01, 0x00, 0x0000 }, + { 62, 0xffff, 0x0100004b, 0x04, 0x00, 0x0000 }, + { 62, 0xffff, 0x01000000, 0x0c, 0x08, 0x0103 }, + { 63, 0xffff, 0x01000034, 0x00, 0x00, 0x0000 }, + { 63, 0xffff, 0x01000040, 0x01, 0x00, 0x0000 }, + { 63, 0xffff, 0x0100004c, 0x04, 0x00, 0x0000 }, + { 63, 0xffff, 0x01000000, 0x0c, 0x08, 0x0104 }, + { 64, 0xffff, 0x01000035, 0x00, 0x00, 0x0000 }, + { 64, 0xffff, 0x01000041, 0x01, 0x00, 0x0000 }, + { 64, 0xffff, 0x0100004d, 0x04, 0x00, 0x0000 }, + { 64, 0xffff, 0x01000000, 0x0c, 0x08, 0x0105 }, + { 65, 0xffff, 0x01000036, 0x00, 0x00, 0x0000 }, + { 65, 0xffff, 0x01000042, 0x01, 0x00, 0x0000 }, + { 65, 0xffff, 0x0100004e, 0x04, 0x00, 0x0000 }, + { 65, 0xffff, 0x01000000, 0x0c, 0x08, 0x0106 }, + { 66, 0xffff, 0x01000037, 0x00, 0x00, 0x0000 }, + { 66, 0xffff, 0x01000043, 0x01, 0x00, 0x0000 }, + { 66, 0xffff, 0x0100004f, 0x04, 0x00, 0x0000 }, + { 66, 0xffff, 0x01000000, 0x0c, 0x08, 0x0107 }, + { 67, 0xffff, 0x01000038, 0x00, 0x00, 0x0000 }, + { 67, 0xffff, 0x01000044, 0x01, 0x00, 0x0000 }, + { 67, 0xffff, 0x01000050, 0x04, 0x00, 0x0000 }, + { 67, 0xffff, 0x01000000, 0x0c, 0x08, 0x0108 }, + { 68, 0xffff, 0x01000039, 0x00, 0x00, 0x0000 }, + { 68, 0xffff, 0x01000045, 0x01, 0x00, 0x0000 }, + { 68, 0xffff, 0x01000051, 0x04, 0x00, 0x0000 }, + { 68, 0xffff, 0x01000000, 0x0c, 0x08, 0x0109 }, + { 69, 0xffff, 0x01000025, 0x00, 0x00, 0x0000 }, + { 70, 0xffff, 0x01000026, 0x00, 0x00, 0x0000 }, + { 70, 0xffff, 0x01000026, 0x08, 0x00, 0x0000 }, + { 71, 0x0037, 0x20000037, 0x00, 0x00, 0x0000 }, + { 72, 0x0038, 0x20000038, 0x00, 0x00, 0x0000 }, + { 73, 0x0039, 0x20000039, 0x00, 0x00, 0x0000 }, + { 74, 0x002d, 0x2000002d, 0x00, 0x00, 0x0000 }, + { 75, 0x0034, 0x20000034, 0x00, 0x00, 0x0000 }, + { 76, 0x0035, 0x20000035, 0x00, 0x00, 0x0000 }, + { 77, 0x0036, 0x20000036, 0x00, 0x00, 0x0000 }, + { 78, 0x002b, 0x2000002b, 0x00, 0x00, 0x0000 }, + { 79, 0x0031, 0x20000031, 0x00, 0x00, 0x0000 }, + { 80, 0x0032, 0x20000032, 0x00, 0x00, 0x0000 }, + { 81, 0x0033, 0x20000033, 0x00, 0x00, 0x0000 }, + { 82, 0x0030, 0x20000030, 0x00, 0x00, 0x0000 }, + { 83, 0x002e, 0x2000002e, 0x00, 0x00, 0x0000 }, + { 83, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 }, + { 83, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 }, + { 86, 0x003c, 0x0000003c, 0x00, 0x00, 0x0000 }, + { 86, 0x003e, 0x0000003e, 0x01, 0x00, 0x0000 }, + { 86, 0x007c, 0x0000007c, 0x02, 0x00, 0x0000 }, + { 87, 0xffff, 0x0100003a, 0x00, 0x00, 0x0000 }, + { 87, 0xffff, 0x01000046, 0x01, 0x00, 0x0000 }, + { 87, 0xffff, 0x01000052, 0x04, 0x00, 0x0000 }, + { 87, 0xffff, 0x01000000, 0x0c, 0x08, 0x010a }, + { 88, 0xffff, 0x0100003b, 0x00, 0x00, 0x0000 }, + { 88, 0xffff, 0x01000047, 0x01, 0x00, 0x0000 }, + { 88, 0xffff, 0x01000000, 0x0c, 0x08, 0x010b }, + { 96, 0xffff, 0x21000005, 0x00, 0x00, 0x0000 }, + { 97, 0xffff, 0x01000021, 0x00, 0x04, 0x0004 }, + { 98, 0x002f, 0x2000002f, 0x00, 0x00, 0x0000 }, + { 99, 0x005c, 0x0400005c, 0x00, 0x00, 0x0000 }, + { 100, 0xffff, 0x01001103, 0x00, 0x04, 0x0002 }, + { 102, 0xffff, 0x01000010, 0x00, 0x00, 0x0000 }, + { 103, 0xffff, 0x01000013, 0x00, 0x00, 0x0000 }, + { 104, 0xffff, 0x01000016, 0x00, 0x00, 0x0000 }, + { 105, 0xffff, 0x01000012, 0x00, 0x00, 0x0000 }, + { 105, 0xffff, 0x01000000, 0x0c, 0x08, 0x0180 }, + { 106, 0xffff, 0x01000014, 0x00, 0x00, 0x0000 }, + { 106, 0xffff, 0x01000000, 0x0c, 0x08, 0x0181 }, + { 107, 0xffff, 0x01000011, 0x00, 0x00, 0x0000 }, + { 108, 0xffff, 0x01000015, 0x00, 0x00, 0x0000 }, + { 109, 0xffff, 0x01000017, 0x00, 0x00, 0x0000 }, + { 110, 0xffff, 0x01000006, 0x00, 0x00, 0x0000 }, + { 111, 0xffff, 0x01000007, 0x00, 0x00, 0x0000 }, + { 111, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 }, + { 111, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 }, + { 119, 0xffff, 0x01000008, 0x00, 0x00, 0x0000 }, +}; + +const QWSKeyboard::Composing QWSKbPrivate::s_keycompose_default[] = { + { 0x0060, 0x0041, 0x00c0 }, + { 0x0060, 0x0061, 0x00e0 }, + { 0x0027, 0x0041, 0x00c1 }, + { 0x0027, 0x0061, 0x00e1 }, + { 0x005e, 0x0041, 0x00c2 }, + { 0x005e, 0x0061, 0x00e2 }, + { 0x007e, 0x0041, 0x00c3 }, + { 0x007e, 0x0061, 0x00e3 }, + { 0x0022, 0x0041, 0x00c4 }, + { 0x0022, 0x0061, 0x00e4 }, + { 0x002d, 0x0061, 0x00aa }, + { 0x002d, 0x0041, 0x00aa }, + { 0x004f, 0x0041, 0x00c5 }, + { 0x006f, 0x0061, 0x00e5 }, + { 0x0030, 0x0041, 0x00c5 }, + { 0x0030, 0x0061, 0x00e5 }, + { 0x0041, 0x0041, 0x00c5 }, + { 0x0061, 0x0061, 0x00e5 }, + { 0x00b0, 0x0041, 0x00c5 }, + { 0x00b0, 0x0061, 0x00e5 }, + { 0x0041, 0x0045, 0x00c6 }, + { 0x0061, 0x0065, 0x00e6 }, + { 0x002c, 0x0043, 0x00c7 }, + { 0x002c, 0x0063, 0x00e7 }, + { 0x005e, 0x0043, 0x00c7 }, + { 0x005e, 0x0063, 0x00e7 }, + { 0x0060, 0x0045, 0x00c8 }, + { 0x0060, 0x0065, 0x00e8 }, + { 0x0027, 0x0045, 0x00c9 }, + { 0x0027, 0x0065, 0x00e9 }, + { 0x005e, 0x0045, 0x00ca }, + { 0x005e, 0x0065, 0x00ea }, + { 0x0022, 0x0045, 0x00cb }, + { 0x0022, 0x0065, 0x00eb }, + { 0x0060, 0x0049, 0x00cc }, + { 0x0060, 0x0069, 0x00ec }, + { 0x0027, 0x0049, 0x00cd }, + { 0x0027, 0x0069, 0x00ed }, + { 0x005e, 0x0049, 0x00ce }, + { 0x005e, 0x0069, 0x00ee }, + { 0x0022, 0x0049, 0x00cf }, + { 0x0022, 0x0069, 0x00ef }, + { 0x002d, 0x0044, 0x00d0 }, + { 0x002d, 0x0064, 0x00f0 }, + { 0x005e, 0x0044, 0x00d0 }, + { 0x005e, 0x0064, 0x00f0 }, + { 0x007e, 0x004e, 0x00d1 }, + { 0x007e, 0x006e, 0x00f1 }, + { 0x005e, 0x004e, 0x00d1 }, + { 0x005e, 0x006e, 0x00f1 }, + { 0x0060, 0x004f, 0x00d2 }, + { 0x0060, 0x006f, 0x00f2 }, + { 0x0027, 0x004f, 0x00d3 }, + { 0x0027, 0x006f, 0x00f3 }, + { 0x005e, 0x004f, 0x00d4 }, + { 0x005e, 0x006f, 0x00f4 }, + { 0x007e, 0x004f, 0x00d5 }, + { 0x007e, 0x006f, 0x00f5 }, + { 0x0022, 0x004f, 0x00d6 }, + { 0x0022, 0x006f, 0x00f6 }, + { 0x002f, 0x004f, 0x00d8 }, + { 0x002f, 0x006f, 0x00f8 }, + { 0x002d, 0x006f, 0x00ba }, + { 0x002d, 0x004f, 0x00ba }, + { 0x0060, 0x0055, 0x00d9 }, + { 0x0060, 0x0075, 0x00f9 }, + { 0x0027, 0x0055, 0x00da }, + { 0x0027, 0x0075, 0x00fa }, + { 0x005e, 0x0055, 0x00db }, + { 0x005e, 0x0075, 0x00fb }, + { 0x0022, 0x0055, 0x00dc }, + { 0x0022, 0x0075, 0x00fc }, + { 0x0027, 0x0059, 0x00dd }, + { 0x0027, 0x0079, 0x00fd }, + { 0x0054, 0x0048, 0x00de }, + { 0x0074, 0x0068, 0x00fe }, + { 0x0073, 0x0073, 0x00df }, + { 0x0022, 0x0079, 0x00ff }, + { 0x0073, 0x007a, 0x00df }, + { 0x006e, 0x006e, 0x00f1 }, + { 0x006e, 0x0068, 0x00f1 }, + { 0x004e, 0x0059, 0x00d1 }, + { 0x004e, 0x004e, 0x00d1 }, + { 0x004e, 0x0048, 0x00d1 }, + { 0x004e, 0x0079, 0x00d1 }, + { 0x004e, 0x006e, 0x00d1 }, + { 0x004e, 0x0068, 0x00d1 }, + { 0x002d, 0x004c, 0x00a3 }, + { 0x003c, 0x003c, 0x00ab }, + { 0x003e, 0x003e, 0x00bb }, + { 0x003f, 0x003f, 0x00bf }, + { 0x005e, 0x003f, 0x00bf }, + { 0x0021, 0x0021, 0x00a1 }, + { 0x005e, 0x0021, 0x00a1 }, + { 0x005e, 0x0031, 0x00b9 }, + { 0x005e, 0x0032, 0x00b2 }, + { 0x005e, 0x0033, 0x00b3 }, + { 0x002b, 0x002d, 0x00b1 }, + { 0x0063, 0x003d, 0x00a2 }, + { 0x0063, 0x002f, 0x00a2 }, + { 0x002f, 0x0063, 0x00a2 }, + { 0x002d, 0x0063, 0x00a2 }, + { 0x002d, 0x0043, 0x00a2 }, + { 0x004c, 0x003d, 0x00a3 }, + { 0x002d, 0x004c, 0x00a3 }, + { 0x002d, 0x006c, 0x00a3 }, + { 0x005e, 0x002a, 0x00d7 }, + { 0x005e, 0x0078, 0x00d7 }, + { 0x0078, 0x0078, 0x00d7 }, + { 0x005e, 0x002e, 0x00b7 }, + { 0x002e, 0x002e, 0x00b7 }, + { 0x005e, 0x002f, 0x00f7 }, + { 0x005e, 0x003a, 0x00f7 }, + { 0x002d, 0x003a, 0x00f7 }, + { 0x003a, 0x002d, 0x00f7 }, + { 0x0059, 0x003d, 0x00a5 }, + { 0x002d, 0x0059, 0x00a5 }, + { 0x002d, 0x006c, 0x00a5 }, + { 0x0028, 0x0063, 0x00a9 }, + { 0x0022, 0x0063, 0x00a9 }, + { 0x002d, 0x0061, 0x00aa }, + { 0x002d, 0x0041, 0x00aa }, + { 0x002d, 0x006f, 0x00ba }, + { 0x002d, 0x004f, 0x00ba }, + { 0x0028, 0x0072, 0x00ae }, + { 0x0022, 0x0072, 0x00ae }, + { 0x006d, 0x0075, 0x00b5 }, + { 0x0031, 0x0034, 0x0152 }, + { 0x0031, 0x0032, 0x0153 }, + { 0x0033, 0x0034, 0x0178 }, + { 0x0065, 0x003d, 0x20ac }, + { 0x002d, 0x0065, 0x20ac }, + { 0x002d, 0x0045, 0x20ac }, + { 0x0076, 0x0053, 0x0160 }, + { 0x005e, 0x0053, 0x0160 }, + { 0x0076, 0x0073, 0x0161 }, + { 0x005e, 0x0073, 0x0161 }, + { 0x0076, 0x005a, 0x017d }, + { 0x005e, 0x005a, 0x017d }, + { 0x0076, 0x007a, 0x017e }, + { 0x005e, 0x007a, 0x017e }, + { 0x004f, 0x0045, 0x0152 }, + { 0x004f, 0x0065, 0x0152 }, + { 0x006f, 0x0065, 0x0153 }, + { 0x0022, 0x0059, 0x0178 }, + { 0x0069, 0x006a, 0x00ff }, + { 0x0049, 0x004a, 0x0178 }, +}; + +#endif diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp index 8cf87db..120d2a1 100644 --- a/src/gui/embedded/qkbd_qws.cpp +++ b/src/gui/embedded/qkbd_qws.cpp @@ -40,56 +40,216 @@ ****************************************************************************/ #include "qkbd_qws.h" +#include "qkbd_qws_p.h" #ifndef QT_NO_QWS_KEYBOARD +#include +#include + #include "qwindowsystem_qws.h" #include "qscreen_qws.h" #include "qtimer.h" #include +//#define QT_DEBUG_KEYMAP + + QT_BEGIN_NAMESPACE class QWSKbPrivate : public QObject { Q_OBJECT public: - QWSKbPrivate(QWSKeyboardHandler *h) { - handler = h; - arTimer = new QTimer(this); - arTimer->setSingleShot(true); - connect(arTimer, SIGNAL(timeout()), SLOT(autoRepeat())); - repeatdelay = 400; - repeatperiod = 80; + QWSKbPrivate(QWSKeyboardHandler *h, const QString &device) + : m_handler(h), m_modifiers(0), m_composing(0), m_dead_unicode(0xffff), + m_no_zap(false), m_do_compose(false), + m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0) + { + m_ar_timer = new QTimer(this); + m_ar_timer->setSingleShot(true); + connect(m_ar_timer, SIGNAL(timeout()), SLOT(autoRepeat())); + m_ar_delay = 400; + m_ar_period = 80; + + memset(m_locks, 0, sizeof(m_locks)); + + QString keymap; + QStringList args = device.split(QLatin1Char(':')); + foreach (const QString &arg, args) { + if (arg.startsWith(QLatin1String("keymap="))) + keymap = arg.mid(7); + else if (arg == QLatin1String("disable-zap")) + m_no_zap = true; + else if (arg == QLatin1String("enable-compose")) + m_do_compose = true; + else if (arg.startsWith(QLatin1String("repeat-delay="))) + m_ar_delay = arg.mid(13).toInt(); + else if (arg.startsWith(QLatin1String("repeat-rate="))) + m_ar_period = arg.mid(12).toInt(); + } + + if (keymap.isEmpty() || !loadKeymap(keymap)) + unloadKeymap(); } - void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod) { - unicode = uni; - keycode = code; - modifier = mod; - arTimer->start(repeatdelay); + ~QWSKbPrivate() + { + unloadKeymap(); } - void endAutoRepeat() { - arTimer->stop(); + + void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod) + { + m_ar_unicode = uni; + m_ar_keycode = code; + m_ar_modifier = mod; + m_ar_timer->start(m_ar_delay); } + void endAutoRepeat() + { + m_ar_timer->stop(); + } + + static Qt::KeyboardModifiers toQtModifiers(quint8 mod) + { + Qt::KeyboardModifiers qtmod = Qt::NoModifier; + + if (mod & (QWSKeyboard::ModShift | QWSKeyboard::ModShiftL | QWSKeyboard::ModShiftR)) + qtmod |= Qt::ShiftModifier; + if (mod & (QWSKeyboard::ModControl | QWSKeyboard::ModCtrlL | QWSKeyboard::ModCtrlR)) + qtmod |= Qt::ControlModifier; + if (mod & QWSKeyboard::ModAlt) + qtmod |= Qt::AltModifier; + + return qtmod; + } + + void unloadKeymap(); + bool loadKeymap(const QString &file); + private slots: - void autoRepeat() { - handler->processKeyEvent(unicode, keycode, modifier, false, true); - handler->processKeyEvent(unicode, keycode, modifier, true, true); - arTimer->start(repeatperiod); + void autoRepeat() + { + m_handler->processKeyEvent(m_ar_unicode, m_ar_keycode, m_ar_modifier, false, true); + m_handler->processKeyEvent(m_ar_unicode, m_ar_keycode, m_ar_modifier, true, true); + m_ar_timer->start(m_ar_period); } private: - QWSKeyboardHandler *handler; - int unicode; - int keycode; - Qt::KeyboardModifiers modifier; - int repeatdelay; - int repeatperiod; - QTimer *arTimer; + QWSKeyboardHandler *m_handler; + + // auto repeat simulation + int m_ar_unicode; + int m_ar_keycode; + Qt::KeyboardModifiers m_ar_modifier; + int m_ar_delay; + int m_ar_period; + QTimer *m_ar_timer; + + // keymap handling + quint8 m_modifiers; + quint8 m_locks[3]; + int m_composing; + quint16 m_dead_unicode; + + bool m_no_zap; + bool m_do_compose; + + const QWSKeyboard::Mapping *m_keymap; + int m_keymap_size; + const QWSKeyboard::Composing *m_keycompose; + int m_keycompose_size; + + static const QWSKeyboard::Mapping s_keymap_default[]; + static const QWSKeyboard::Composing s_keycompose_default[]; + + friend class QWSKeyboardHandler; }; +// simple builtin US keymap +#include "qkbd_defaultmap_qws_p.h" + +// the unloadKeymap() function needs to be AFTER the defaultmap include, +// since the sizeof(s_keymap_default) wouldn't work otherwise. + +void QWSKbPrivate::unloadKeymap() +{ + if (m_keymap && m_keymap != s_keymap_default) + delete [] m_keymap; + if (m_keycompose && m_keycompose != s_keycompose_default) + delete [] m_keycompose; + + m_keymap = s_keymap_default; + m_keymap_size = sizeof(s_keymap_default) / sizeof(s_keymap_default[0]); + m_keycompose = s_keycompose_default; + m_keycompose_size = sizeof(s_keycompose_default) / sizeof(s_keycompose_default[0]); + + // reset state, so we could switch keymaps at runtime + m_modifiers = 0; + memset(m_locks, 0, sizeof(m_locks)); + m_composing = 0; + m_dead_unicode = 0xffff; +} + +bool QWSKbPrivate::loadKeymap(const QString &file) +{ + QFile f(file); + + if (!f.open(QIODevice::ReadOnly)) { + qWarning("Could not open keymap file '%s'", qPrintable(file)); + return false; + } + + // .qmap files have a very simple structure: + // quint32 magic (QWSKeyboard::FileMagic) + // quint32 version (1) + // quint32 keymap_size (# of struct QWSKeyboard::Mappings) + // quint32 keycompose_size (# of struct QWSKeyboard::Composings) + // all QWSKeyboard::Mappings via QDataStream::operator(<<|>>) + // all QWSKeyboard::Composings via QDataStream::operator(<<|>>) + + quint32 qmap_magic, qmap_version, qmap_keymap_size, qmap_keycompose_size; + + QDataStream ds(&f); + + ds >> qmap_magic >> qmap_version >> qmap_keymap_size >> qmap_keycompose_size; + + if (ds.status() != QDataStream::Ok || qmap_magic != QWSKeyboard::FileMagic || qmap_version != 1 || qmap_keymap_size == 0) { + qWarning("'%s' is ot a valid.qmap keymap file.", qPrintable(file)); + return false; + } + + QWSKeyboard::Mapping *qmap_keymap = new QWSKeyboard::Mapping[qmap_keymap_size]; + QWSKeyboard::Composing *qmap_keycompose = qmap_keycompose_size ? new QWSKeyboard::Composing[qmap_keycompose_size] : 0; + + for (quint32 i = 0; i < qmap_keymap_size; ++i) + ds >> qmap_keymap[i]; + for (quint32 i = 0; i < qmap_keycompose_size; ++i) + ds >> qmap_keycompose[i]; + + if (ds.status() != QDataStream::Ok) { + delete [] qmap_keymap; + delete [] qmap_keycompose; + + qWarning("Keymap file '%s' can not be loaded.", qPrintable(file)); + return false; + } + + // unload currently active and clear state + unloadKeymap(); + + m_keymap = qmap_keymap; + m_keymap_size = qmap_keymap_size; + m_keycompose = qmap_keycompose; + m_keycompose_size = qmap_keycompose_size; + + m_do_compose = true; + + return true; +} + + /*! \class QWSKeyboardHandler \ingroup qws @@ -132,18 +292,29 @@ private: /*! - Constructs a keyboard driver. + Constructs a keyboard driver. The \a device argument is passed by the + QWS_KEYBOARD environment variable. Call the QWSServer::setKeyboardHandler() function to make the newly created keyboard driver, the primary driver. Note that the primary driver is controlled by the system, i.e., the system will delete it upon exit. */ +QWSKeyboardHandler::QWSKeyboardHandler(const QString &device) +{ + d = new QWSKbPrivate(this, device); +} + +/*! + \overload +*/ QWSKeyboardHandler::QWSKeyboardHandler() { - d = new QWSKbPrivate(this); + d = new QWSKbPrivate(this, QString()); } + + /*! Destroys this keyboard driver. @@ -172,7 +343,10 @@ QWSKeyboardHandler::~QWSKeyboardHandler() event is caused by an auto-repeat mechanism and not an actual key press. - \sa beginAutoRepeat(), endAutoRepeat(), transformDirKey() + Note that this function does not handle key mapping. Please use + processKeycode() if you need that functionality. + + \sa processKeycode(), beginAutoRepeat(), endAutoRepeat(), transformDirKey() */ void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat) @@ -241,6 +415,256 @@ void QWSKeyboardHandler::endAutoRepeat() d->endAutoRepeat(); } +/*! + \enum QWSKeyboardHandler::KeycodeAction + + This enum describes the various special actions that actual + QWSKeyboardHandler implementations have to take care of. + + \value None No further action required. + + \value CapsLockOn Set the state of the Caps lock LED to on. + \value CapsLockOff Set the state of the Caps lock LED to off. + \value NumLockOn Set the state of the Num lock LED to on. + \value NumLockOff Set the state of the Num lock LED to off. + \value ScrollLockOn Set the state of the Scroll lock LED to on. + \value ScrollLockOff Set the state of the Scroll lock LED to off. + + \value PreviousConsole Switch to the previous virtual console (by + default Ctrl+Alt+Left on Linux). + \value NextConsole Switch to the next virtual console (by default + Ctrl+Alt+Right on Linux). + \value SwitchConsoleFirst Switch to the first virtual console (0). + \value SwitchConsoleLast Switch to the last virtual console (255). + \value SwitchConsoleMask If the KeyAction value is between SwitchConsoleFirst + and SwitchConsoleLast, you can use this mask to get + the specific virtual console number to switch to. + + \value Reboot Reboot the machine - this is ignored in both the TTY and + LinuxInput handlers though (by default Ctrl+Alt+Del on Linux). + + \sa processKeycode() +*/ + +/*! + \fn QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool isPress, bool autoRepeat) + + Maps \a keycode according to a keymap and sends that key event to the + \l{Qt for Embedded Linux} server application. + + Please see the QWS_KEYBOARD documentation for a description on how to + create and use keymap files. + + The key event is identified by its \a keycode value and the \a isPress + and \a autoRepeat parameters. + + The \a keycode parameter is \bold NOT the Qt keycode value as defined by + the Qt::Key enum. This functions expects a standard Linux 16 bit kernel + keycode as it is used in the Linux Input Event sub-system. This + \a keycode is transformed to a Qt::Key code by using either a + compiled-in US keyboard layout or by dynamically loading a keymap at + startup which can be specified via the QWS_KEYBOARD environment + variable. + + The \a isPress parameter is true if the event is a key press event and + \a autoRepeat is true if the event is caused by an auto-repeat mechanism + and not an actual key press. + + The return value indicates if the actual QWSKeyboardHandler + implementation needs to take care of a special action, like console + switching or LED handling. + + Standard Linux console keymaps can be found at the + \l {http://lct.sourceforege.net}{LCT project} + + If standard Linux console keymaps are used, \a keycode must be one of the + standardized values defined in \c /usr/include/linux/input.h + + \sa processKeyEvent(), KeycodeAction +*/ + +QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat) +{ + KeycodeAction result = None; + bool first_press = pressed && !autorepeat; + + const QWSKeyboard::Mapping *map_plain = 0; + const QWSKeyboard::Mapping *map_withmod = 0; + + // get a specific and plain mapping for the keycode and the current modifiers + for (int i = 0; i < d->m_keymap_size && !(map_plain && map_withmod); ++i) { + const QWSKeyboard::Mapping *m = d->m_keymap + i; + if (m->keycode == keycode) { + if (m->modifiers == 0) + map_plain = m; + + quint8 testmods = d->m_modifiers; + if (d->m_locks[0] /*CapsLock*/ && (m->flags & QWSKeyboard::IsLetter)) + testmods ^= QWSKeyboard::ModShift; + if (m->modifiers == testmods) + map_withmod = m; + } + } + +#ifdef QT_DEBUG_KEYMAP + qWarning("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", \ + keycode, d->m_modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, \ + map_plain ? map_plain - d->m_keymap : -1, \ + map_withmod ? map_withmod - d->m_keymap : -1, \ + d->m_keymap_size); +#endif + + const QWSKeyboard::Mapping *it = map_withmod ? map_withmod : map_plain; + + if (!it) { +#ifdef QT_DEBUG_KEYMAP + // we couldn't even find a plain mapping + qWarning("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, d->m_modifiers); +#endif + return result; + } + + bool skip = false; + quint16 unicode = it->unicode; + quint32 qtcode = it->qtcode; + + if ((it->flags & QWSKeyboard::IsModifier) && it->special) { + // this is a modifier, i.e. Shift, Alt, ... + if (pressed) + d->m_modifiers |= quint8(it->special); + else + d->m_modifiers &= ~quint8(it->special); + } else if (qtcode >= Qt::Key_CapsLock && qtcode <= Qt::Key_ScrollLock) { + // (Caps|Num|Scroll)Lock + if (first_press) { + quint8 &lock = d->m_locks[qtcode - Qt::Key_CapsLock]; + lock ^= 1; + + switch (qtcode) { + case Qt::Key_CapsLock : result = lock ? CapsLockOn : CapsLockOff; break; + case Qt::Key_NumLock : result = lock ? NumLockOn : NumLockOff; break; + case Qt::Key_ScrollLock: result = lock ? ScrollLockOn : ScrollLockOff; break; + default : break; + } + } + } else if ((it->flags & QWSKeyboard::IsSystem) && it->special && first_press) { + switch (it->special) { + case QWSKeyboard::SystemReboot: + result = Reboot; + break; + + case QWSKeyboard::SystemZap: + if (!d->m_no_zap) + qApp->quit(); + break; + + case QWSKeyboard::SystemConsolePrevious: + result = PreviousConsole; + break; + + case QWSKeyboard::SystemConsoleNext: + result = NextConsole; + break; + + default: + if (it->special >= QWSKeyboard::SystemConsoleFirst && + it->special <= QWSKeyboard::SystemConsoleLast) { + result = KeycodeAction(SwitchConsoleFirst + ((it->special & QWSKeyboard::SystemConsoleMask) & SwitchConsoleMask)); + } + break; + } + + skip = true; // no need to tell QWS about it + } else if ((qtcode == Qt::Key_Multi_key) && d->m_do_compose) { + // the Compose key was pressed + if (first_press) + d->m_composing = 2; + skip = true; + } else if ((it->flags & QWSKeyboard::IsDead) && d->m_do_compose) { + // a Dead key was pressed + if (first_press && d->m_composing == 1 && d->m_dead_unicode == unicode) { // twice + d->m_composing = 0; + qtcode = Qt::Key_unknown; // otherwise it would be Qt::Key_Dead... + } else if (first_press && unicode != 0xffff) { + d->m_dead_unicode = unicode; + d->m_composing = 1; + skip = true; + } else { + skip = true; + } + } + + if (!skip) { + // a normal key was pressed + const int modmask = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier; + + // we couldn't find a specific mapping for the current modifiers, + // or that mapping didn't have special modifiers: + // so just report the plain mapping with additional modifiers. + if ((it == map_plain && it != map_withmod) || + (map_withmod && !(map_withmod->qtcode & modmask))) { + qtcode |= QWSKbPrivate::toQtModifiers(d->m_modifiers); + } + + if (d->m_composing == 2 && first_press && !(it->flags & QWSKeyboard::IsModifier)) { + // the last key press was the Compose key + if (unicode != 0xffff) { + int idx = 0; + // check if this code is in the compose table at all + for ( ; idx < d->m_keycompose_size; ++idx) { + if (d->m_keycompose[idx].first == unicode) + break; + } + if (idx < d->m_keycompose_size) { + // found it -> simulate a Dead key press + d->m_dead_unicode = unicode; + unicode = 0xffff; + d->m_composing = 1; + skip = true; + } else { + d->m_composing = 0; + } + } else { + d->m_composing = 0; + } + } else if (d->m_composing == 1 && first_press && !(it->flags & QWSKeyboard::IsModifier)) { + // the last key press was a Dead key + bool valid = false; + if (unicode != 0xffff) { + int idx = 0; + // check if this code is in the compose table at all + for ( ; idx < d->m_keycompose_size; ++idx) { + if (d->m_keycompose[idx].first == d->m_dead_unicode && d->m_keycompose[idx].second == unicode) + break; + } + if (idx < d->m_keycompose_size) { + quint16 composed = d->m_keycompose[idx].result; + if (composed != 0xffff) { + unicode = composed; + qtcode = Qt::Key_unknown; + valid = true; + } + } + } + if (!valid) { + unicode = d->m_dead_unicode; + qtcode = Qt::Key_unknown; + } + d->m_composing = 0; + } + + if (!skip) { +#ifdef QT_DEBUG_KEYMAP + qWarning("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask)); +#endif + + // send the result to the QWS server + processKeyEvent(unicode, qtcode & ~modmask, Qt::KeyboardModifiers(qtcode & modmask), pressed, autorepeat); + } + } + return result; +} + QT_END_NAMESPACE #include "qkbd_qws.moc" diff --git a/src/gui/embedded/qkbd_qws.h b/src/gui/embedded/qkbd_qws.h index 8809f0a..171adc0 100644 --- a/src/gui/embedded/qkbd_qws.h +++ b/src/gui/embedded/qkbd_qws.h @@ -58,11 +58,33 @@ class Q_GUI_EXPORT QWSKeyboardHandler { public: QWSKeyboardHandler(); + QWSKeyboardHandler(const QString &device); virtual ~QWSKeyboardHandler(); virtual void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat); + enum KeycodeAction { + None = 0, + + CapsLockOff = 0x01000000, + CapsLockOn = 0x01000001, + NumLockOff = 0x02000000, + NumLockOn = 0x02000001, + ScrollLockOff = 0x03000000, + ScrollLockOn = 0x03000001, + + Reboot = 0x04000000, + + PreviousConsole = 0x05000000, + NextConsole = 0x05000001, + SwitchConsoleFirst = 0x06000000, + SwitchConsoleLast = 0x0600007f, + SwitchConsoleMask = 0x0000007f, + }; + + KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat); + protected: int transformDirKey(int key); void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod); diff --git a/src/gui/embedded/qkbd_qws_p.h b/src/gui/embedded/qkbd_qws_p.h new file mode 100644 index 0000000..f7dcdaf --- /dev/null +++ b/src/gui/embedded/qkbd_qws_p.h @@ -0,0 +1,77 @@ +#ifndef QWSKEYBOARD_P_H +#define QWSKEYBOARD_P_H + +#include + +namespace QWSKeyboard { + const quint32 FileMagic = 0x514d4150; // 'QMAP' + + struct Mapping { + quint16 keycode; + quint16 unicode; + quint32 qtcode; + quint8 modifiers; + quint8 flags; + quint16 special; + + }; + + enum Flags { + IsDead = 0x01, + IsLetter = 0x02, + IsModifier = 0x04, + IsSystem = 0x08, + }; + + enum System { + SystemConsoleFirst = 0x0100, + SystemConsoleMask = 0x007f, + SystemConsoleLast = 0x017f, + SystemConsolePrevious = 0x0180, + SystemConsoleNext = 0x0181, + SystemReboot = 0x0200, + SystemZap = 0x0300, + }; + + struct Composing { + quint16 first; + quint16 second; + quint16 result; + }; + + enum Modifiers { + ModPlain = 0x00, + ModShift = 0x01, + ModAltGr = 0x02, + ModControl = 0x04, + ModAlt = 0x08, + ModShiftL = 0x10, + ModShiftR = 0x20, + ModCtrlL = 0x40, + ModCtrlR = 0x80, + // ModCapsShift = 0x100, // not supported! + }; +}; + +inline QDataStream &operator>>(QDataStream &ds, QWSKeyboard::Mapping &m) +{ + return ds >> m.keycode >> m.unicode >> m.qtcode >> m.modifiers >> m.flags >> m.special; +} + +inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Mapping &m) +{ + return ds << m.keycode << m.unicode << m.qtcode << m.modifiers << m.flags << m.special; +} + +inline QDataStream &operator>>(QDataStream &ds, QWSKeyboard::Composing &c) +{ + return ds >> c.first >> c.second >> c.result; +} + +inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Composing &c) +{ + return ds << c.first << c.second << c.result; +} + + +#endif // QWSKEYBOARD_H diff --git a/src/gui/embedded/qkbddriverfactory_qws.cpp b/src/gui/embedded/qkbddriverfactory_qws.cpp index 1ade652..dbfac5c 100644 --- a/src/gui/embedded/qkbddriverfactory_qws.cpp +++ b/src/gui/embedded/qkbddriverfactory_qws.cpp @@ -45,7 +45,7 @@ #include "qapplication.h" #include "qkbdtty_qws.h" -#include "qkbdusb_qws.h" +#include "qkbdlinuxinput_qws.h" #include "qkbdum_qws.h" #include "qkbdsl5000_qws.h" #include "qkbdvfb_qws.h" @@ -121,9 +121,11 @@ QWSKeyboardHandler *QKbdDriverFactory::create(const QString& key, const QString& if (driver == QLatin1String("tty") || driver.isEmpty()) return new QWSTtyKeyboardHandler(device); # endif -# ifndef QT_NO_QWS_KBD_USB - if (driver == QLatin1String("usb")) - return new QWSUsbKeyboardHandler(device); +# ifndef QT_NO_QWS_KBD_LINUXINPUT + if (driver == QLatin1String("linuxinput") || \ + driver == QLatin1String("usb") || \ + driver == QLatin1String("linuxis")) + return new QWSLinuxInputKeyboardHandler(device); # endif # ifndef QT_NO_QWS_KBD_UM if (driver == QLatin1String("um") || driver == QLatin1String("qvfbkeyboard")) @@ -168,8 +170,8 @@ QStringList QKbdDriverFactory::keys() #ifndef QT_NO_QWS_KBD_TTY list << QLatin1String("TTY"); #endif -#ifndef QT_NO_QWS_KBD_USB - list << QLatin1String("USB"); +#ifndef QT_NO_QWS_KBD_LINUXINPUT + list << QLatin1String("LinuxInput"); #endif #ifndef QT_NO_QWS_KBD_UM list << QLatin1String("UM"); diff --git a/src/gui/embedded/qkbdlinuxinput_qws.cpp b/src/gui/embedded/qkbdlinuxinput_qws.cpp new file mode 100644 index 0000000..d04b09f --- /dev/null +++ b/src/gui/embedded/qkbdlinuxinput_qws.cpp @@ -0,0 +1,241 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qkbdlinuxinput_qws.h" + +#ifndef QT_NO_QWS_KEYBOARD + +#include +#include + +#include + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + + +class QWSLinuxInputKbPrivate : public QObject +{ + Q_OBJECT +public: + QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *, const QString &); + ~QWSLinuxInputKbPrivate(); + +private: + void switchLed(int, bool); + +private Q_SLOTS: + void readKeycode(); + +private: + QWSLinuxInputKeyboardHandler *m_handler; + int m_fd; + int m_tty_fd; + struct termios m_tty_attr; +}; + +QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device) + : QWSKeyboardHandler(device) +{ + d = new QWSLinuxInputKbPrivate(this, device); +} + +QWSLinuxInputKeyboardHandler::~QWSLinuxInputKeyboardHandler() +{ + delete d; +} + +bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &) +{ + return false; +} + +QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, const QString &device) + : m_handler(h), m_fd(-1), m_tty_fd(-1) + +{ + setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler")); + + QString dev = QLatin1String("/dev/input/event1"); + int repeat_delay = -1; + int repeat_rate = -1; + + QStringList args = device.split(QLatin1Char(':')); + foreach (const QString &arg, args) { + if (arg.startsWith(QLatin1String("repeat_delay="))) + repeat_delay = arg.mid(13).toInt(); + else if (arg.startsWith(QLatin1String("repeat_rate="))) + repeat_rate = arg.mid(12).toInt(); + else if (arg.startsWith(QLatin1String("/dev/"))) + dev = arg; + } + + m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0); + if (m_fd >= 0) { + if (repeat_delay > 0 && repeat_rate > 0) { + int kbdrep[2] = { repeat_delay, repeat_rate }; + ::ioctl(m_fd, EVIOCSREP, kbdrep); + } + + QSocketNotifier *notifier; + notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); + connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode())); + + // play nice in case we are started from a shell (e.g. for debugging) + m_tty_fd = isatty(0) ? 0 : -1; + + if (m_tty_fd >= 0) { + // save tty config for restore. + tcgetattr(m_tty_fd, &m_tty_attr); + + struct ::termios termdata; + tcgetattr(m_tty_fd, &termdata); + + // setting this tranlation mode is also needed in INPUT mode to prevent + // the shell from also interpreting codes, if the process has a tty + // attached: e.g. Ctrl+C wouldn't copy, but kill the application. + ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW); + + // set the tty layer to pass-through + termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + termdata.c_oflag = 0; + termdata.c_cflag = CREAD | CS8; + termdata.c_lflag = 0; + termdata.c_cc[VTIME]=0; + termdata.c_cc[VMIN]=1; + cfsetispeed(&termdata, 9600); + cfsetospeed(&termdata, 9600); + tcsetattr(m_tty_fd, TCSANOW, &termdata); + } + } else { + qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno)); + return; + } +} + +QWSLinuxInputKbPrivate::~QWSLinuxInputKbPrivate() +{ + if (m_tty_fd >= 0) { + ::ioctl(m_tty_fd, KDSKBMODE, K_XLATE); + tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr); + } + if (m_fd >= 0) + QT_CLOSE(m_fd); +} + +void QWSLinuxInputKbPrivate::switchLed(int led, bool state) +{ + struct ::input_event led_ie; + ::gettimeofday(&led_ie.time, 0); + led_ie.type = EV_LED; + led_ie.code = led; + led_ie.value = state; + + QT_WRITE(m_fd, &led_ie, sizeof(led_ie)); +} + +void QWSLinuxInputKbPrivate::readKeycode() +{ + struct ::input_event buffer[32]; + int n = 0; + + forever { + n = QT_READ(m_fd, reinterpret_cast(buffer) + n, sizeof(buffer) - n); + + if (n == 0) { + qWarning("Got EOF from the input device."); + return; + } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) { + qWarning("Could not read from input device: %s", strerror(errno)); + return; + } else if (n % sizeof(buffer[0]) == 0) { + break; + } + } + + n /= sizeof(buffer[0]); + + for (int i = 0; i < n; ++i) { + if (buffer[i].type != EV_KEY) + continue; + + quint16 code = buffer[i].code; + qint32 value = buffer[i].value; + + if (m_handler->filterInputEvent(code, value)) + continue; + + QWSKeyboardHandler::KeycodeAction ka; + ka = m_handler->processKeycode(code, value != 0, value == 2); + + switch (ka) { + case QWSKeyboardHandler::CapsLockOn: + case QWSKeyboardHandler::CapsLockOff: + switchLed(LED_CAPSL, ka == QWSKeyboardHandler::CapsLockOn); + break; + + case QWSKeyboardHandler::NumLockOn: + case QWSKeyboardHandler::NumLockOff: + switchLed(LED_NUML, ka == QWSKeyboardHandler::NumLockOn); + break; + + case QWSKeyboardHandler::ScrollLockOn: + case QWSKeyboardHandler::ScrollLockOff: + switchLed(LED_SCROLLL, ka == QWSKeyboardHandler::ScrollLockOn); + break; + + default: + // ignore console switching and reboot + break; + } + } +} + +QT_END_NAMESPACE + +#include "qkbdlinuxinput_qws.moc" + +#endif // QT_NO_QWS_KEYBOARD diff --git a/src/gui/embedded/qkbdlinuxinput_qws.h b/src/gui/embedded/qkbdlinuxinput_qws.h new file mode 100644 index 0000000..5fa8214 --- /dev/null +++ b/src/gui/embedded/qkbdlinuxinput_qws.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QKBDLINUXINPUT_QWS_H +#define QKBDLINUXINPUT_QWS_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +#ifndef QT_NO_QWS_KEYBOARD + +#ifndef QT_NO_QWS_KBD_LINUXINPUT + +class QWSLinuxInputKbPrivate; + +class QWSLinuxInputKeyboardHandler : public QWSKeyboardHandler +{ +public: + QWSLinuxInputKeyboardHandler(const QString&); + virtual ~QWSLinuxInputKeyboardHandler(); + + virtual bool filterInputEvent(quint16 &input_code, qint32 &input_value); + +private: + QWSLinuxInputKbPrivate *d; +}; + +#endif // QT_NO_QWS_KBD_LINUXINPUT + +#endif // QT_NO_QWS_KEYBOARD + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QKBDLINUXINPUT_QWS_H diff --git a/src/gui/embedded/qkbdsl5000_qws.cpp b/src/gui/embedded/qkbdsl5000_qws.cpp index bc412b6..1e8095e 100644 --- a/src/gui/embedded/qkbdsl5000_qws.cpp +++ b/src/gui/embedded/qkbdsl5000_qws.cpp @@ -195,6 +195,13 @@ static const int keyMSize = sizeof(sl5000KeyMap)/sizeof(QWSKeyMap)-1; QWSSL5000KeyboardHandler::QWSSL5000KeyboardHandler(const QString &device) : QWSTtyKeyboardHandler(device) { + shift = false; + alt = false; + ctrl = false; + extended = 0; + prevuni = 0; + prevkey = 0; + caps = false; meta = false; fn = false; numLock = false; @@ -220,7 +227,7 @@ const QWSKeyMap *QWSSL5000KeyboardHandler::keyMap() const return sl5000KeyMap; } -void QWSSL5000KeyboardHandler::doKey(uchar code) +bool QWSSL5000KeyboardHandler::filterKeycode(char &code) { int keyCode = Qt::Key_unknown; bool release = false; @@ -239,19 +246,19 @@ void QWSSL5000KeyboardHandler::doKey(uchar code) else if (code == 0x52) { unicode='Z'-'@'; scan=Qt::Key_Z; } // Undo if (scan) { processKeyEvent(unicode, scan, Qt::ControlModifier, !release, false); - return; + return true; } } if (code < keyMSize) { - keyCode = keyMap()[code].key_code; + keyCode = keyMap()[int(code)].key_code; } bool repeatable = true; if (release && (keyCode == Qt::Key_F34 || keyCode == Qt::Key_F35)) - return; // no release for power and light keys - if (keyCode >= Qt::Key_F1 && keyCode <= Qt::Key_F35 + return true; // no release for power and light keys + if ((keyCode >= Qt::Key_F1 && keyCode <= Qt::Key_F35) || keyCode == Qt::Key_Escape || keyCode == Qt::Key_Home || keyCode == Qt::Key_Shift || keyCode == Qt::Key_Meta) repeatable = false; @@ -318,11 +325,11 @@ void QWSSL5000KeyboardHandler::doKey(uchar code) keyCode = Qt::Key_QuoteLeft; unicode = '`'; } else if (bCtrl) - unicode = keyMap()[code].ctrl_unicode ? keyMap()[code].ctrl_unicode : 0xffff; + unicode = keyMap()[int(code)].ctrl_unicode ? keyMap()[int(code)].ctrl_unicode : 0xffff; else if (bCaps) - unicode = keyMap()[code].shift_unicode ? keyMap()[code].shift_unicode : 0xffff; + unicode = keyMap()[int(code)].shift_unicode ? keyMap()[int(code)].shift_unicode : 0xffff; else - unicode = keyMap()[code].unicode ? keyMap()[code].unicode : 0xffff; + unicode = keyMap()[int(code)].unicode ? keyMap()[int(code)].unicode : 0xffff; } modifiers = 0; @@ -349,6 +356,8 @@ void QWSSL5000KeyboardHandler::doKey(uchar code) beginAutoRepeat(prevuni, prevkey, modifiers); else endAutoRepeat(); + + return true; } QT_END_NAMESPACE diff --git a/src/gui/embedded/qkbdsl5000_qws.h b/src/gui/embedded/qkbdsl5000_qws.h index 514d602..a96e038 100644 --- a/src/gui/embedded/qkbdsl5000_qws.h +++ b/src/gui/embedded/qkbdsl5000_qws.h @@ -52,7 +52,13 @@ QT_MODULE(Gui) #ifndef QT_NO_QWS_KBD_SL5000 -class QWSSL5000KbPrivate; +struct QWSKeyMap { + uint key_code; + ushort unicode; + ushort shift_unicode; + ushort ctrl_unicode; +}; + class QWSSL5000KeyboardHandler : public QWSTtyKeyboardHandler { @@ -60,14 +66,21 @@ public: explicit QWSSL5000KeyboardHandler(const QString&); virtual ~QWSSL5000KeyboardHandler(); - virtual void doKey(uchar scancode); + bool filterKeycode(char &keycode); virtual const QWSKeyMap *keyMap() const; private: + bool shift; + bool alt; + bool ctrl; + bool caps; + uint extended:2; + Qt::KeyboardModifiers modifiers; + int prevuni; + int prevkey; bool meta; bool fn; bool numLock; - QWSSL5000KbPrivate *d; }; #endif // QT_NO_QWS_KBD_SL5000 diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp index b588e55..37ed510 100644 --- a/src/gui/embedded/qkbdtty_qws.cpp +++ b/src/gui/embedded/qkbdtty_qws.cpp @@ -43,64 +43,57 @@ #if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_TTY) -#include "qscreen_qws.h" - -#include "qwindowsystem_qws.h" -#include "qapplication.h" -#include "qsocketnotifier.h" -#include "qnamespace.h" -#include "qtimer.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include -#include +#include -#ifdef Q_OS_LINUX -#include -#include -#endif +#include +#include -QT_BEGIN_NAMESPACE +#if defined Q_OS_LINUX +# include +# include //TODO: move vt handling somewhere else (QLinuxFbScreen?) -#define VTACQSIG SIGUSR1 -#define VTRELSIG SIGUSR2 +# include "qscreen_qws.h" +# include "qwindowsystem_qws.h" +# include "qapplication.h" +# include "private/qwindowsurface_qws_p.h" +# include "private/qwssignalhandler_p.h" -static int vtQws = 0; -static int kbdFD = -1; +# define VTACQSIG SIGUSR1 +# define VTRELSIG SIGUSR2 +#endif -//=========================================================================== -// -// Tty keyboard -// +QT_BEGIN_NAMESPACE class QWSTtyKbPrivate : public QObject { Q_OBJECT public: - QWSTtyKbPrivate(QWSPC101KeyboardHandler *, const QString &device); + QWSTtyKbPrivate(QWSTtyKeyboardHandler *handler, const QString &device); ~QWSTtyKbPrivate(); -private slots: - void readKeyboardData(); - void handleTtySwitch(int); +private: + void switchLed(char, bool); + void switchConsole(int vt); + +private Q_SLOTS: + void readKeycode(); + void handleConsoleSwitch(int sig); private: - QWSPC101KeyboardHandler *handler; - struct termios origTermData; + QWSTtyKeyboardHandler *m_handler; + int m_tty_fd; + struct termios m_tty_attr; + char m_last_keycode; + int m_vt_qws; }; + QWSTtyKeyboardHandler::QWSTtyKeyboardHandler(const QString &device) - : QWSPC101KeyboardHandler(device) + : QWSKeyboardHandler(device) { d = new QWSTtyKbPrivate(this, device); } @@ -110,59 +103,63 @@ QWSTtyKeyboardHandler::~QWSTtyKeyboardHandler() delete d; } -void QWSTtyKeyboardHandler::processKeyEvent(int unicode, int keycode, - Qt::KeyboardModifiers modifiers, bool isPress, - bool autoRepeat) +bool QWSTtyKeyboardHandler::filterKeycode(char &) { -#if defined(Q_OS_LINUX) - // Virtual console switching - int term = 0; - bool ctrl = modifiers & Qt::ControlModifier; - bool alt = modifiers & Qt::AltModifier; - if (ctrl && alt && keycode >= Qt::Key_F1 && keycode <= Qt::Key_F10) - term = keycode - Qt::Key_F1 + 1; - else if (ctrl && alt && keycode == Qt::Key_Left) - term = qMax(vtQws - 1, 1); - else if (ctrl && alt && keycode == Qt::Key_Right) - term = qMin(vtQws + 1, 10); - if (term && isPress) { - ioctl(kbdFD, VT_ACTIVATE, term); - return; - } -#endif - - QWSPC101KeyboardHandler::processKeyEvent(unicode, keycode, modifiers, - isPress, autoRepeat); + return false; } - -QWSTtyKbPrivate::QWSTtyKbPrivate(QWSPC101KeyboardHandler *h, const QString &device) : handler(h) +QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device) + : m_handler(h), m_tty_fd(-1), m_last_keycode(0), m_vt_qws(0) { - kbdFD = ::open(device.isEmpty()?"/dev/tty0":device.toLatin1().constData(), O_RDWR|O_NDELAY, 0); + setObjectName(QLatin1String("TTY Keyboard Handler")); #ifndef QT_NO_QWS_SIGNALHANDLER QWSSignalHandler::instance()->addObject(this); #endif - if (kbdFD >= 0) { + QString dev = QLatin1String("/dev/tty0"); + int repeat_delay = -1; + int repeat_rate = -1; + + QStringList args = device.split(QLatin1Char(':')); + foreach (const QString &arg, args) { + if (arg.startsWith(QLatin1String("repeat_delay="))) + repeat_delay = arg.mid(13).toInt(); + else if (arg.startsWith(QLatin1String("repeat_rate="))) + repeat_rate = arg.mid(12).toInt(); + else if (arg.startsWith(QLatin1String("/dev/"))) + dev = arg; + } + + m_tty_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0); + if (m_tty_fd >= 0) { + if (repeat_delay > 0 && repeat_rate > 0) { +#if defined(Q_OS_LINUX) + struct ::kbd_repeat kbdrep = { repeat_delay, repeat_rate }; + ::ioctl(m_tty_fd, KDKBDREP, &kbdrep); +#endif + } + QSocketNotifier *notifier; - notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this); - connect(notifier, SIGNAL(activated(int)),this, - SLOT(readKeyboardData())); + notifier = new QSocketNotifier(m_tty_fd, QSocketNotifier::Read, this); + connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode())); - // save for restore. - tcgetattr(kbdFD, &origTermData); + // save tty config for restore. + tcgetattr(m_tty_fd, &m_tty_attr); - struct termios termdata; - tcgetattr(kbdFD, &termdata); + struct ::termios termdata; + tcgetattr(m_tty_fd, &termdata); #if defined(Q_OS_LINUX) -# ifdef QT_QWS_USE_KEYCODES - ioctl(kbdFD, KDSKBMODE, K_MEDIUMRAW); -# else - ioctl(kbdFD, KDSKBMODE, K_RAW); -# endif + // PLEASE NOTE: + // The tty keycode interface can only report keycodes 0x01 .. 0x7f + // KEY_MAX is however defined to 0x1ff. In practice this is sufficient + // for a PC style keyboard though. + // we don't support K_RAW anymore - if you need, you habe to add a + // scan- to keycode converter. + ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW); #endif + // set the tty layer to pass-through termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); termdata.c_oflag = 0; termdata.c_cflag = CREAD | CS8; @@ -171,50 +168,146 @@ QWSTtyKbPrivate::QWSTtyKbPrivate(QWSPC101KeyboardHandler *h, const QString &devi termdata.c_cc[VMIN]=1; cfsetispeed(&termdata, 9600); cfsetospeed(&termdata, 9600); - tcsetattr(kbdFD, TCSANOW, &termdata); + tcsetattr(m_tty_fd, TCSANOW, &termdata); #if defined(Q_OS_LINUX) - - connect(QApplication::instance(), SIGNAL(unixSignal(int)), this, SLOT(handleTtySwitch(int))); + // VT switching is handled via unix signals + connect(QApplication::instance(), SIGNAL(unixSignal(int)), this, SLOT(handleConsoleSwitch(int))); QApplication::instance()->watchUnixSignal(VTACQSIG, true); QApplication::instance()->watchUnixSignal(VTRELSIG, true); - struct vt_mode vtMode; - ioctl(kbdFD, VT_GETMODE, &vtMode); + struct ::vt_mode vtMode; + if (::ioctl(m_tty_fd, VT_GETMODE, &vtMode) == 0) { + vtMode.mode = VT_PROCESS; + vtMode.relsig = VTRELSIG; + vtMode.acqsig = VTACQSIG; - // let us control VT switching - vtMode.mode = VT_PROCESS; - vtMode.relsig = VTRELSIG; - vtMode.acqsig = VTACQSIG; - ioctl(kbdFD, VT_SETMODE, &vtMode); + if (::ioctl(m_tty_fd, VT_SETMODE, &vtMode) == 0) { + struct ::vt_stat vtStat; + ::memset(&vtStat, 0, sizeof(vtStat)); - struct vt_stat vtStat; - ioctl(kbdFD, VT_GETSTATE, &vtStat); - vtQws = vtStat.v_active; + if (::ioctl(m_tty_fd, VT_GETSTATE, &vtStat) == 0 ) { + m_vt_qws = vtStat.v_active; + } + } + } + + if (!m_vt_qws) + qWarning("Could not initialize virtual console switching"); #endif } else { - qCritical("Cannot open keyboard: %s", strerror(errno)); + qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno)); + return; } } QWSTtyKbPrivate::~QWSTtyKbPrivate() { - if (kbdFD >= 0) { + if (m_tty_fd >= 0) { #if defined(Q_OS_LINUX) - ioctl(kbdFD, KDSKBMODE, K_XLATE); + ::ioctl(m_tty_fd, KDSKBMODE, K_XLATE); #endif - tcsetattr(kbdFD, TCSANOW, &origTermData); - ::close(kbdFD); - kbdFD = -1; + tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr); } } -void QWSTtyKbPrivate::handleTtySwitch(int sig) + + +void QWSTtyKbPrivate::switchLed(char led, bool state) { #if defined(Q_OS_LINUX) + char ledstate; + + ::ioctl(m_tty_fd, KDGETLED, &ledstate); + if (state) + ledstate |= led; + else + ledstate &= ~led; + ::ioctl(m_tty_fd, KDSETLED, ledstate); +#endif +} + +void QWSTtyKbPrivate::readKeycode() +{ + char buffer[32]; + int n = 0; + + forever { + n = QT_READ(m_tty_fd, buffer + n, 32 - n); + + if (n == 0) { + qWarning("Got EOF from the input device."); + return; + } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) { + qWarning("Could not read from input device: %s", strerror(errno)); + return; + } else { + break; + } + } + + for (int i = 0; i < n; ++i) { + if (m_handler->filterKeycode(buffer[i])) + continue; + + QWSKeyboardHandler::KeycodeAction ka; + ka = m_handler->processKeycode(buffer[i] & 0x7f, (buffer[i] & 0x80) == 0x00, buffer[i] == m_last_keycode); + m_last_keycode = buffer[i]; + +qWarning("Special: %08x", ka); + switch (ka) { + case QWSKeyboardHandler::CapsLockOn: + case QWSKeyboardHandler::CapsLockOff: + switchLed(LED_CAP, ka == QWSKeyboardHandler::CapsLockOn); + break; + + case QWSKeyboardHandler::NumLockOn: + case QWSKeyboardHandler::NumLockOff: + switchLed(LED_NUM, ka == QWSKeyboardHandler::NumLockOn); + break; + + case QWSKeyboardHandler::ScrollLockOn: + case QWSKeyboardHandler::ScrollLockOff: + switchLed(LED_SCR, ka == QWSKeyboardHandler::ScrollLockOn); + break; + + case QWSKeyboardHandler::PreviousConsole: + switchConsole(qBound(1, m_vt_qws - 1, 10)); + break; + + case QWSKeyboardHandler::NextConsole: + switchConsole(qBound(1, m_vt_qws + 1, 10)); + break; + + default: + if (ka >= QWSKeyboardHandler::SwitchConsoleFirst && + ka <= QWSKeyboardHandler::SwitchConsoleLast) { + switchConsole(1 + (ka & QWSKeyboardHandler::SwitchConsoleMask)); + } + //ignore reboot + break; + } + } +} + + +void QWSTtyKbPrivate::switchConsole(int vt) +{ +#if defined(Q_OS_LINUX) + if (m_vt_qws && vt && (m_tty_fd >= 0 )) + ::ioctl(m_tty_fd, VT_ACTIVATE, vt); +#endif +} + +void QWSTtyKbPrivate::handleConsoleSwitch(int sig) +{ +#if defined(Q_OS_LINUX) + // received a notification from the kernel that the current VT is + // changing: either enable or disable QWS painting accordingly. + if (sig == VTACQSIG) { - if (ioctl(kbdFD, VT_RELDISP, VT_ACKACQ) == 0) { + if (::ioctl(m_tty_fd, VT_RELDISP, VT_ACKACQ) == 0) { qwsServer->enablePainting(true); qt_screen->restore(); qwsServer->resumeMouse(); @@ -236,9 +329,9 @@ void QWSTtyKbPrivate::handleTtySwitch(int sig) } if (!allWindowsHidden) { - ioctl(kbdFD, VT_RELDISP, 0); // abort console switch + ::ioctl(m_tty_fd, VT_RELDISP, 0); // abort console switch qwsServer->enablePainting(true); - } else if (ioctl(kbdFD, VT_RELDISP, 1) == 0) { + } else if (::ioctl(m_tty_fd, VT_RELDISP, 1) == 0) { qt_screen->save(); qwsServer->suspendMouse(); } else { @@ -248,14 +341,6 @@ void QWSTtyKbPrivate::handleTtySwitch(int sig) #endif } -void QWSTtyKbPrivate::readKeyboardData() -{ - unsigned char buf[81]; - int n = read(kbdFD, buf, 80); - for (int loop = 0; loop < n; loop++) - handler->doKey(buf[loop]); -} - QT_END_NAMESPACE #include "qkbdtty_qws.moc" diff --git a/src/gui/embedded/qkbdtty_qws.h b/src/gui/embedded/qkbdtty_qws.h index 4f93d6c..fc3eaa1 100644 --- a/src/gui/embedded/qkbdtty_qws.h +++ b/src/gui/embedded/qkbdtty_qws.h @@ -42,7 +42,7 @@ #ifndef QKBDTTY_QWS_H #define QKBDTTY_QWS_H -#include +#include QT_BEGIN_HEADER @@ -56,15 +56,13 @@ QT_MODULE(Gui) class QWSTtyKbPrivate; -class QWSTtyKeyboardHandler : public QWSPC101KeyboardHandler +class QWSTtyKeyboardHandler : public QWSKeyboardHandler { public: explicit QWSTtyKeyboardHandler(const QString&); virtual ~QWSTtyKeyboardHandler(); -protected: - virtual void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers, - bool isPress, bool autoRepeat); + virtual bool filterKeycode(char &code); private: QWSTtyKbPrivate *d; diff --git a/src/gui/embedded/qkbdusb_qws.cpp b/src/gui/embedded/qkbdusb_qws.cpp deleted file mode 100644 index e35ac55..0000000 --- a/src/gui/embedded/qkbdusb_qws.cpp +++ /dev/null @@ -1,401 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qkbdusb_qws.h" - -#ifndef QT_NO_QWS_KEYBOARD - -#include "qscreen_qws.h" - -#include "qwindowsystem_qws.h" -#include "qapplication.h" -#include "qsocketnotifier.h" -#include "qnamespace.h" -#include "qtimer.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef Q_OS_LINUX -#include -#include -#endif - -QT_BEGIN_NAMESPACE - -/* USB driver */ - - -class QWSUsbKbPrivate : public QObject -{ - Q_OBJECT -public: - QWSUsbKbPrivate(QWSPC101KeyboardHandler *, const QString &); - ~QWSUsbKbPrivate(); - -private slots: - void readKeyboardData(); - -private: - QWSPC101KeyboardHandler *handler; - int fd; -#ifdef QT_QWS_ZYLONITE - bool shift; -#endif -}; - -QWSUsbKeyboardHandler::QWSUsbKeyboardHandler(const QString &device) - : QWSPC101KeyboardHandler(device) -{ - d = new QWSUsbKbPrivate(this, device); -} - -QWSUsbKeyboardHandler::~QWSUsbKeyboardHandler() -{ - delete d; -} - -QWSUsbKbPrivate::QWSUsbKbPrivate(QWSPC101KeyboardHandler *h, const QString &device) : handler(h) -{ -#ifdef QT_QWS_ZYLONITE - shift = FALSE; -#endif - fd = ::open(device.isEmpty()?"/dev/input/event1":device.toLocal8Bit(),O_RDONLY, 0); - if (fd >= 0) { - QSocketNotifier *notifier; - notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(notifier, SIGNAL(activated(int)),this, - SLOT(readKeyboardData())); - } -} - -QWSUsbKbPrivate::~QWSUsbKbPrivate() -{ - ::close(fd); -} - -void QWSUsbKbPrivate::readKeyboardData() -{ - input_event event; - if (read(fd, &event, sizeof(input_event)) != sizeof(input_event)) - return; - - if (event.type != EV_KEY) - return; - -#ifdef QT_QWS_ZYLONITE - qDebug("keypressed: code=%03d (%s)\n",event.code,((event.value)!=0) ? "Down":"Up"); - int modifiers=0; - int unicode=0xffff; - int key_code=0; - - switch(event.code) - { - case 0xA2: - key_code = ((!shift) ? Qt::Key_0 : Qt::Key_Plus ); - unicode = ((!shift) ? 0x30 : 0x2B ); - break; - case 0x70: - key_code = ((!shift) ? Qt::Key_1 : Qt::Key_At ); - unicode = ((!shift) ? 0x31 : 0x40 ); - break; - case 0x72: - key_code = ((!shift) ? Qt::Key_2 : Qt::Key_Ampersand ); - unicode = ((!shift) ? 0x32 : 0x26 ); - break; - case 0x74: - key_code = ((!shift) ? Qt::Key_3 : Qt::Key_At ); - unicode = ((!shift) ? 0x33 : 0x3F ); - break; - case 0x80: - key_code = ((!shift) ? Qt::Key_4 : Qt::Key_Minus ); - unicode = ((!shift) ? 0x34 : 0x2D ); - break; - case 0x82: - key_code = ((!shift) ? Qt::Key_5 : Qt::Key_Apostrophe); - unicode = ((!shift) ? 0x35 : 0x27 ); - break; - case 0x84: - key_code = ((!shift) ? Qt::Key_6 : Qt::Key_Slash ); - unicode = ((!shift) ? 0x36 : 0x5C ); - break; - case 0x90: - key_code = ((!shift) ? Qt::Key_7 : Qt::Key_Colon ); - unicode = ((!shift) ? 0x37 : 0x3A ); - break; - case 0x92: - key_code = ((!shift) ? Qt::Key_8 : Qt::Key_Semicolon ); - unicode = ((!shift) ? 0x38 : 0x3B ); - break; - case 0x94: - key_code = ((!shift) ? Qt::Key_9 : Qt::Key_QuoteDbl ); - unicode = ((!shift) ? 0x39 : 0x22 ); - break; - case 0x0: - key_code = Qt::Key_A; - unicode = ((!shift) ? 0x61 : 0x41 ); - break; - case 0x10: - key_code = Qt::Key_B; - unicode = ((!shift) ? 0x62 : 0x42 ); - break; - case 0x20: - key_code = Qt::Key_C; - unicode = ((!shift) ? 0x63 : 0x43 ); - break; - case 0x30: - key_code = Qt::Key_D; - unicode = ((!shift) ? 0x64 : 0x44 ); - break; - case 0x40: - key_code = Qt::Key_E; - unicode = ((!shift) ? 0x65 : 0x45 ); - break; - case 0x50: - key_code = Qt::Key_F; - unicode = ((!shift) ? 0x66 : 0x46 ); - break; - case 0x01: - key_code = Qt::Key_G; - unicode = ((!shift) ? 0x67 : 0x47 ); - break; - case 0x11: - key_code = Qt::Key_H; - unicode = ((!shift) ? 0x68 : 0x48 ); - break; - case 0x21: - key_code = Qt::Key_I; - unicode = ((!shift) ? 0x69 : 0x49 ); - break; - case 0x31: - key_code = Qt::Key_J; - unicode = ((!shift) ? 0x6A : 0x4A ); - break; - case 0x41: - key_code = Qt::Key_K; - unicode = ((!shift) ? 0x6B : 0x4B ); - break; - case 0x51: - key_code = Qt::Key_L; - unicode = ((!shift) ? 0x6C : 0x4C ); - break; - case 0x02: - key_code = Qt::Key_M; - unicode = ((!shift) ? 0x6D : 0x4D ); - break; - case 0x12: - key_code = Qt::Key_N; - unicode = ((!shift) ? 0x6E : 0x4E ); - break; - case 0x22: - key_code = Qt::Key_O; - unicode = ((!shift) ? 0x6F : 0x4F ); - break; - case 0x32: - key_code = Qt::Key_P; - unicode = ((!shift) ? 0x70 : 0x50 ); - break; - case 0x42: - key_code = Qt::Key_Q; - unicode = ((!shift) ? 0x71 : 0x51 ); - break; - case 0x52: - key_code = Qt::Key_R; - unicode = ((!shift) ? 0x72 : 0x52 ); - break; - case 0x03: - key_code = Qt::Key_S; - unicode = ((!shift) ? 0x73 : 0x53 ); - break; - case 0x13: - key_code = Qt::Key_T; - unicode = ((!shift) ? 0x74 : 0x54 ); - break; - case 0x23: - key_code = Qt::Key_U; - unicode = ((!shift) ? 0x75 : 0x55 ); - break; - case 0x33: - key_code = Qt::Key_V; - unicode = ((!shift) ? 0x76 : 0x56 ); - break; - case 0x43: - key_code = Qt::Key_W; - unicode = ((!shift) ? 0x77 : 0x57 ); - break; - case 0x53: - key_code = Qt::Key_X; - unicode = ((!shift) ? 0x78 : 0x58 ); - break; - case 0x24: - key_code = Qt::Key_Y; - unicode = ((!shift) ? 0x79 : 0x59 ); - break; - case 0x34: - key_code = Qt::Key_Z; - unicode = ((!shift) ? 0x7A : 0x5A ); - break; - case 0xA4: - key_code = ((!shift) ? Qt::Key_NumberSign : Qt::Key_Period); - unicode = ((!shift) ? 0x23 : 0x2E ); - break; - case 0xA0: - key_code = ((!shift) ? Qt::Key_Asterisk : Qt::Key_NumberSign ); - unicode = ((!shift) ? 0x2A : 0x2C ); - break; - case 0x25: - key_code = Qt::Key_Space; - unicode = 0x20; - break; - case 0x06: - key_code = Qt::Key_Up; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x16: - key_code = Qt::Key_Down; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x26: - key_code = Qt::Key_Left; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x36: - key_code = Qt::Key_Right; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x46: - key_code = Qt::Key_Select; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x61: - key_code = Qt::Key_No; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x60: - key_code = Qt::Key_Call; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x55: - key_code = Qt::Key_Hangup; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x62: - key_code = Qt::Key_Context1; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x63: - key_code = Qt::Key_No; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x05: - key_code = Qt::Key_Home; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x15: - key_code = Qt::Key_Shift; - unicode = 0xffff; modifiers |= Qt::ShiftModifier; - if(event.value==0) break; - if(shift) { - shift = FALSE; - qWarning("Caps Off!"); - } else { - shift = TRUE; - qWarning("Caps On!"); - } - break; - case 0x1C: - key_code = ((!shift) ? Qt::Key_Back : Qt::Key_Enter ); - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x19: - key_code = Qt::Key_Context2; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x1A: - key_code = Qt::Key_Context3; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - case 0x1B: - key_code = Qt::Key_Context4; - unicode = 0xffff; modifiers |= Qt::KeypadModifier; - break; - } - if(shift) modifiers |= Qt::ShiftModifier; - handler->processKeyEvent(unicode, key_code, (Qt::KeyboardModifiers)modifiers, event.value!=0, false); -#else - - int key=event.code; -#ifndef QT_QWS_USE_KEYCODES - // Handle SOME keys, otherwise it's useless. - - if(key==103) { - handler->processKeyEvent(0, Qt::Key_Up, 0, event.value!=0, false); - } else if(key==106) { - handler->processKeyEvent(0, Qt::Key_Right, 0, event.value!=0, false ); - } else if(key==108) { - handler->processKeyEvent(0, Qt::Key_Down, 0, event.value!=0, false); - } else if(key==105) { - handler->processKeyEvent(0, Qt::Key_Left, 0, event.value!=0, false); - } else - -#endif - - { - if(event.value == 0) { - key=key | 0x80; - } - handler->doKey(key); - } -#endif -} - -QT_END_NAMESPACE - -#include "qkbdusb_qws.moc" - -#endif // QT_NO_QWS_KEYBOARD diff --git a/src/gui/embedded/qkbdusb_qws.h b/src/gui/embedded/qkbdusb_qws.h deleted file mode 100644 index 81d0103..0000000 --- a/src/gui/embedded/qkbdusb_qws.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QKBDUSB_QWS_H -#define QKBDUSB_QWS_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_QWS_KEYBOARD - -#ifndef QT_NO_QWS_KBD_USB - -class QWSUsbKbPrivate; - -class QWSUsbKeyboardHandler : public QWSPC101KeyboardHandler -{ -public: - QWSUsbKeyboardHandler(const QString&); - virtual ~QWSUsbKeyboardHandler(); - -private: - QWSUsbKbPrivate *d; -}; - -#endif // QT_NO_QWS_KBD_USB - -#endif // QT_NO_QWS_KEYBOARD - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QKBDUSB_QWS_H diff --git a/src/plugins/kbddrivers/kbddrivers.pro b/src/plugins/kbddrivers/kbddrivers.pro index 6605972..a34b780 100644 --- a/src/plugins/kbddrivers/kbddrivers.pro +++ b/src/plugins/kbddrivers/kbddrivers.pro @@ -1,6 +1,5 @@ TEMPLATE = subdirs -contains(kbd-plugins, usb): SUBDIRS += usb +contains(kbd-plugins, linuxinput): SUBDIRS += linuxinput contains(kbd-plugins, sl5000): SUBDIRS += sl5000 contains(kbd-plugins, vr41xx): SUBDIRS += vr41xx contains(kbd-plugins, yopy): SUBDIRS += yopy -contains(kbd-plugins, linuxis): SUBDIRS += linuxis diff --git a/src/plugins/kbddrivers/linuxinput/linuxinput.pro b/src/plugins/kbddrivers/linuxinput/linuxinput.pro new file mode 100644 index 0000000..862a220 --- /dev/null +++ b/src/plugins/kbddrivers/linuxinput/linuxinput.pro @@ -0,0 +1,14 @@ +TARGET = qlinuxinputkbddriver +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers +target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers +INSTALLS += target + +DEFINES += QT_QWS_KBD_LINUXINPUT + +HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.h + +SOURCES = main.cpp \ + $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.cpp + diff --git a/src/plugins/kbddrivers/linuxinput/main.cpp b/src/plugins/kbddrivers/linuxinput/main.cpp new file mode 100644 index 0000000..45d06c4 --- /dev/null +++ b/src/plugins/kbddrivers/linuxinput/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +QT_BEGIN_NAMESPACE + +class QLinuxInputKbdDriver : public QKbdDriverPlugin +{ +public: + QLinuxInputKbdDriver(); + + QStringList keys() const; + QWSKeyboardHandler* create(const QString &driver, const QString &device); +}; + +QLinuxInputKbdDriver::QLinuxInputKbdDriver() + : QKbdDriverPlugin() +{ +} + +QStringList QLinuxInputKbdDriver::keys() const +{ + return (QStringList() << QLatin1String("LinuxInput")); +} + +QWSKeyboardHandler* QLinuxInputKbdDriver::create(const QString &driver, + const QString &device) +{ + Q_UNUSED(device); + if (driver.compare(QLatin1String("LinuxInput"), Qt::CaseInsensitive)) + return 0; + return new QWSLinuxInputKeyboardHandler(driver, device); +} + +Q_EXPORT_PLUGIN2(qwslinuxinputkbddriver, QLinuxInputKbdDriver) + +QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/linuxis/README b/src/plugins/kbddrivers/linuxis/README deleted file mode 100644 index 37a9a89..0000000 --- a/src/plugins/kbddrivers/linuxis/README +++ /dev/null @@ -1 +0,0 @@ -This is a keypad/only keyboard driver based on the Linux input subsystem. diff --git a/src/plugins/kbddrivers/linuxis/linuxis.pro b/src/plugins/kbddrivers/linuxis/linuxis.pro deleted file mode 100644 index 5e652b5..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxis.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = linuxiskbdhandler -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -CONFIG+=no_tr - -HEADERS = linuxiskbddriverplugin.h linuxiskbdhandler.h -SOURCES = linuxiskbddriverplugin.cpp linuxiskbdhandler.cpp diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp b/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp deleted file mode 100644 index 79cd298..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "linuxiskbddriverplugin.h" -#include "linuxiskbdhandler.h" - -#include -#if 1 -#define qLog(x) qDebug() -#else -#define qLog(x) while (0) qDebug() -#endif - -LinuxInputSubsystemKbdDriverPlugin::LinuxInputSubsystemKbdDriverPlugin( QObject *parent ) - : QKbdDriverPlugin( parent ) -{ -} - -LinuxInputSubsystemKbdDriverPlugin::~LinuxInputSubsystemKbdDriverPlugin() -{ -} - -QWSKeyboardHandler* LinuxInputSubsystemKbdDriverPlugin::create(const QString &driver, const QString &device) -{ - if (device.isEmpty()) { - return create( driver ); - } - if( driver.toLower() == "linuxis" || driver.toLower() == "linuxiskbdhandler" ) { - qLog(Input) << "Before call LinuxInputSubsystemKbdHandler(" << device << ")"; - return new LinuxInputSubsystemKbdHandler(device); - } - return 0; -} - -QWSKeyboardHandler* LinuxInputSubsystemKbdDriverPlugin::create( const QString &driver) -{ - if( driver.toLower() == "linuxis" || driver.toLower() == "linuxiskbdhandler" ) { - qLog(Input) << "Before call LinuxInputSubsystemKbdHandler()"; - return new LinuxInputSubsystemKbdHandler(); - } - return 0; -} - -QStringList LinuxInputSubsystemKbdDriverPlugin::keys() const -{ - return QStringList() << "linuxis" << "linuxiskbdhandler"; -} - -Q_EXPORT_PLUGIN2(qwslinuxiskbdhandler, LinuxInputSubsystemKbdDriverPlugin) diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h b/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h deleted file mode 100644 index b5f599f..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxiskbddriverplugin.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LINUXISKBDDRIVERPLUGIN_H -#define LINUXISKBDDRIVERPLUGIN_H - -#include - -class LinuxInputSubsystemKbdDriverPlugin : public QKbdDriverPlugin { - Q_OBJECT -public: - LinuxInputSubsystemKbdDriverPlugin( QObject *parent = 0 ); - ~LinuxInputSubsystemKbdDriverPlugin(); - - QWSKeyboardHandler* create(const QString& driver, const QString& device); - QWSKeyboardHandler* create(const QString& driver); - QStringList keys()const; -}; - -#endif // LINUXISKBDDRIVERPLUGIN_H diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp b/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp deleted file mode 100644 index 99b98b7..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "linuxiskbdhandler.h" - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#if 1 -#define qLog(x) qDebug() -#else -#define qLog(x) while (0) qDebug() -#endif - -struct LinuxInputSubsystemKbdHandler::keytable_s LinuxInputSubsystemKbdHandler::keytable[] = { - { KEY_PAGEDOWN, 0xffff, Qt::Key_Context1 }, - { KEY_END, 0xffff, Qt::Key_Back }, - { KEY_RIGHTCTRL, 0xffff, Qt::Key_Home }, - { KEY_SPACE, 0xffff, Qt::Key_Menu }, - { KEY_ENTER, 0xffff, Qt::Key_Select }, - { KEY_UP, 0xffff, Qt::Key_Up }, - { KEY_LEFT, 0xffff, Qt::Key_Left }, - { KEY_RIGHT, 0xffff, Qt::Key_Right }, - { KEY_DOWN, 0xffff, Qt::Key_Down }, - { KEY_POWER, 0xffff, Qt::Key_Call }, - { KEY_BACKSPACE, 0xffff, Qt::Key_Backspace }, - { KEY_F1, 0xffff, Qt::Key_Hangup }, - { KEY_KP1, '1', Qt::Key_1 }, - { KEY_KP2, '2', Qt::Key_2 }, - { KEY_KP3, '3', Qt::Key_3 }, - { KEY_KP4, '4', Qt::Key_4 }, - { KEY_KP5, '5', Qt::Key_5 }, - { KEY_KP6, '6', Qt::Key_6 }, - { KEY_KP7, '7', Qt::Key_7 }, - { KEY_KP8, '8', Qt::Key_8 }, - { KEY_KP9, '9', Qt::Key_9 }, - { KEY_KP0, '0', Qt::Key_0 }, - { KEY_APOSTROPHE, '*', Qt::Key_Asterisk }, - { KEY_3, '#', Qt::Key_NumberSign }, - { KEY_F2, 0xffff, Qt::Key_F2 }, - { KEY_F3, 0xffff, Qt::Key_F3 }, - { KEY_F4, 0xffff, Qt::Key_F4 }, - { KEY_F5, 0xffff, Qt::Key_F5 }, - { KEY_F6, 0xffff, Qt::Key_F6 }, - { KEY_F7, 0xffff, Qt::Key_VolumeUp }, - { KEY_F8, 0xffff, Qt::Key_VolumeDown }, - { KEY_F9, 0xffff, Qt::Key_F9 }, - { 0, 0, Qt::Key_unknown }, -}; - -struct LinuxInputSubsystemKbdHandler::keymap_s LinuxInputSubsystemKbdHandler::keymap[KEY_MAX]; - -LinuxInputSubsystemKbdHandler::LinuxInputSubsystemKbdHandler(const QString &device) -{ - qLog(Input) << "Loaded LinuxInputSubsystem keypad plugin!"; - setObjectName( "LinuxInputSubsystem Keypad Handler" ); - kbdFD = ::open(device.toLocal8Bit().constData(), O_RDONLY, 0); - if (kbdFD >= 0) { - qLog(Input) << "Opened" << device << "as keypad input"; -#if 0 - struct kbd_repeat kbdrep; - kbdrep.delay = 500; /* ms */ - kbdrep.period = 250; /* ms */ - ioctl(kbdFD, KDKBDREP, &kbdrep); -#endif - m_notify = new QSocketNotifier( kbdFD, QSocketNotifier::Read, this ); - connect( m_notify, SIGNAL(activated(int)), this, SLOT(readKbdData())); - } else { - qWarning("Cannot open '%s' for keypad (%s)", - device.toLocal8Bit().constData(), strerror(errno)); - return; - } - shift = false; - - initmap(); -} - -LinuxInputSubsystemKbdHandler::~LinuxInputSubsystemKbdHandler() -{ -} - -void LinuxInputSubsystemKbdHandler::initmap() -{ - for (int i = 0; i < KEY_MAX; i++) { - keymap[i].unicode = 0xffff; - keymap[i].keycode = Qt::Key_unknown; - } - for (int i = 0; keytable[i].unicode; i++) { - int idx = keytable[i].code; - keymap[idx].unicode = keytable[i].unicode; - keymap[idx].keycode = keytable[i].keycode; - } -} - -void LinuxInputSubsystemKbdHandler::readKbdData() -{ - struct input_event *ie; - struct input_event iebuf[32]; - - uint n = ::read(kbdFD, iebuf, sizeof(iebuf)); - - bool pressed; - bool autorepeat; - int modifiers = 0; - int unicode, keycode; - - n /= sizeof(struct input_event); - ie = iebuf; - for (uint i = 0; i < n; i++) { - - pressed = ie->value != 0; - autorepeat = ie->value == 2; - qLog() << "keyEvent" << hex << ie->type << ie->code << ie->value; - unicode = keymap[ie->code].unicode; - keycode = keymap[ie->code].keycode; - - processKeyEvent(unicode, keycode, (Qt::KeyboardModifiers)modifiers, - pressed, autorepeat); - - ie++; - } - -} - diff --git a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h b/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h deleted file mode 100644 index 3211309..0000000 --- a/src/plugins/kbddrivers/linuxis/linuxiskbdhandler.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LINUXISKBDHANDLER_H -#define LINUXISKBDHANDLER_H - -#include -#include - -class QSocketNotifier; -class LinuxInputSubsystemKbdHandler : public QObject, public QWSKeyboardHandler { - Q_OBJECT -public: - LinuxInputSubsystemKbdHandler(const QString &device = QString("/dev/input/event0")); - ~LinuxInputSubsystemKbdHandler(); - - struct keytable_s { - int code; - int unicode; - int keycode; - }; - - struct keymap_s { - int unicode; - int keycode; - }; - -private: - void initmap(); - - QSocketNotifier *m_notify; - int kbdFD; - bool shift; - - static struct keytable_s keytable[]; - static struct keymap_s keymap[]; - -private Q_SLOTS: - void readKbdData(); -}; - -#endif // LINUXISKBDHANDLER_H diff --git a/src/plugins/kbddrivers/usb/main.cpp b/src/plugins/kbddrivers/usb/main.cpp deleted file mode 100644 index 1d6ab89..0000000 --- a/src/plugins/kbddrivers/usb/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -QT_BEGIN_NAMESPACE - -class QUsbKbdDriver : public QKbdDriverPlugin -{ -public: - QUsbKbdDriver(); - - QStringList keys() const; - QWSKeyboardHandler* create(const QString &driver, const QString &device); -}; - -QUsbKbdDriver::QUsbKbdDriver() - : QKbdDriverPlugin() -{ -} - -QStringList QUsbKbdDriver::keys() const -{ - return (QStringList() << QLatin1String("Usb")); -} - -QWSKeyboardHandler* QUsbKbdDriver::create(const QString &driver, - const QString &device) -{ - Q_UNUSED(device); - if (driver.compare(QLatin1String("Usb"), Qt::CaseInsensitive)) - return 0; - return new QWSUsbKeyboardHandler(driver); -} - -Q_EXPORT_PLUGIN2(qwsusbkbddriver, QUsbKbdDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/usb/usb.pro b/src/plugins/kbddrivers/usb/usb.pro deleted file mode 100644 index 4187255..0000000 --- a/src/plugins/kbddrivers/usb/usb.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qusbkbddriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -DEFINES += QT_QWS_KBD_USB - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdusb_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdusb_qws.cpp - diff --git a/tools/kmap2qmap/kmap2qmap.pro b/tools/kmap2qmap/kmap2qmap.pro new file mode 100644 index 0000000..cc8200b --- /dev/null +++ b/tools/kmap2qmap/kmap2qmap.pro @@ -0,0 +1,12 @@ + +TEMPLATE = app +DESTDIR = ../../bin +QT = core +CONFIG += console +CONFIG -= app_bundle + +DEPENDPATH += $$QT_SOURCE_TREE/src/gui/embedded +INCLUDEPATH += $$QT_SOURCE_TREE/src/gui/embedded + +# Input +SOURCES += main.cpp diff --git a/tools/kmap2qmap/main.cpp b/tools/kmap2qmap/main.cpp new file mode 100644 index 0000000..5e80b23 --- /dev/null +++ b/tools/kmap2qmap/main.cpp @@ -0,0 +1,948 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qkbd_qws_p.h" + +using namespace std; + + +struct modifier_map_t { + const char *symbol; + quint8 modifier; + quint32 qtmodifier; +}; + +static const struct modifier_map_t modifier_map[] = { + { "plain", QWSKeyboard::ModPlain, Qt::NoModifier }, + { "shift", QWSKeyboard::ModShift, Qt::ShiftModifier }, + { "altgr", QWSKeyboard::ModAltGr, Qt::AltModifier }, + { "control", QWSKeyboard::ModControl, Qt::ControlModifier }, + { "alt", QWSKeyboard::ModAlt, Qt::AltModifier }, + { "meta", QWSKeyboard::ModAlt, Qt::AltModifier }, + { "shiftl", QWSKeyboard::ModShiftL, Qt::ShiftModifier }, + { "shiftr", QWSKeyboard::ModShiftR, Qt::ShiftModifier }, + { "ctrll", QWSKeyboard::ModCtrlL, Qt::ControlModifier }, + { "ctrlr", QWSKeyboard::ModCtrlR, Qt::ControlModifier }, +}; + +static const int modifier_map_size = sizeof(modifier_map)/sizeof(modifier_map_t); + + +struct symbol_map_t { + const char *symbol; + quint32 qtcode; +}; + +static const struct symbol_map_t symbol_map[] = { + { "space", Qt::Key_Space }, + { "exclam", Qt::Key_Exclam }, + { "quotedbl", Qt::Key_QuoteDbl }, + { "numbersign", Qt::Key_NumberSign }, + { "dollar", Qt::Key_Dollar }, + { "percent", Qt::Key_Percent }, + { "ampersand", Qt::Key_Ampersand }, + { "apostrophe", Qt::Key_Apostrophe }, + { "parenleft", Qt::Key_ParenLeft }, + { "parenright", Qt::Key_ParenRight }, + { "asterisk", Qt::Key_Asterisk }, + { "plus", Qt::Key_Plus }, + { "comma", Qt::Key_Comma }, + { "minus", Qt::Key_Minus }, + { "period", Qt::Key_Period }, + { "slash", Qt::Key_Slash }, + { "zero", Qt::Key_0 }, + { "one", Qt::Key_1 }, + { "two", Qt::Key_2 }, + { "three", Qt::Key_3 }, + { "four", Qt::Key_4 }, + { "five", Qt::Key_5 }, + { "six", Qt::Key_6 }, + { "seven", Qt::Key_7 }, + { "eight", Qt::Key_8 }, + { "nine", Qt::Key_9 }, + { "colon", Qt::Key_Colon }, + { "semicolon", Qt::Key_Semicolon }, + { "less", Qt::Key_Less }, + { "equal", Qt::Key_Equal }, + { "greater", Qt::Key_Greater }, + { "question", Qt::Key_Question }, + { "at", Qt::Key_At }, + { "bracketleft", Qt::Key_BracketLeft }, + { "backslash", Qt::Key_Backslash }, + { "bracketright", Qt::Key_BracketRight }, + { "asciicircum", Qt::Key_AsciiCircum }, + { "underscore", Qt::Key_Underscore }, + { "grave", Qt::Key_QuoteLeft }, + { "braceleft", Qt::Key_BraceLeft }, + { "bar", Qt::Key_Bar }, + { "braceright", Qt::Key_BraceRight }, + { "asciitilde", Qt::Key_AsciiTilde }, + { "nobreakspace", Qt::Key_nobreakspace }, + { "exclamdown", Qt::Key_exclamdown }, + { "cent", Qt::Key_cent }, + { "sterling", Qt::Key_sterling }, + { "currency", Qt::Key_currency }, + { "yen", Qt::Key_yen }, + { "brokenbar", Qt::Key_brokenbar }, + { "section", Qt::Key_section }, + { "diaeresis", Qt::Key_diaeresis }, + { "copyright", Qt::Key_copyright }, + { "ordfeminine", Qt::Key_ordfeminine }, + { "guillemotleft", Qt::Key_guillemotleft }, + { "notsign", Qt::Key_notsign }, + { "hyphen", Qt::Key_hyphen }, + { "registered", Qt::Key_registered }, + { "macron", Qt::Key_macron }, + { "degree", Qt::Key_degree }, + { "plusminus", Qt::Key_plusminus }, + { "twosuperior", Qt::Key_twosuperior }, + { "threesuperior", Qt::Key_threesuperior }, + { "acute", Qt::Key_acute }, + { "mu", Qt::Key_mu }, + { "paragraph", Qt::Key_paragraph }, + { "periodcentered", Qt::Key_periodcentered }, + { "cedilla", Qt::Key_cedilla }, + { "onesuperior", Qt::Key_onesuperior }, + { "masculine", Qt::Key_masculine }, + { "guillemotright", Qt::Key_guillemotright }, + { "onequarter", Qt::Key_onequarter }, + { "onehalf", Qt::Key_onehalf }, + { "threequarters", Qt::Key_threequarters }, + { "questiondown", Qt::Key_questiondown }, + { "Agrave", Qt::Key_Agrave }, + { "Aacute", Qt::Key_Aacute }, + { "Acircumflex", Qt::Key_Acircumflex }, + { "Atilde", Qt::Key_Atilde }, + { "Adiaeresis", Qt::Key_Adiaeresis }, + { "Aring", Qt::Key_Aring }, + { "AE", Qt::Key_AE }, + { "Ccedilla", Qt::Key_Ccedilla }, + { "Egrave", Qt::Key_Egrave }, + { "Eacute", Qt::Key_Eacute }, + { "Ecircumflex", Qt::Key_Ecircumflex }, + { "Ediaeresis", Qt::Key_Ediaeresis }, + { "Igrave", Qt::Key_Igrave }, + { "Iacute", Qt::Key_Iacute }, + { "Icircumflex", Qt::Key_Icircumflex }, + { "Idiaeresis", Qt::Key_Idiaeresis }, + { "ETH", Qt::Key_ETH }, + { "Ntilde", Qt::Key_Ntilde }, + { "Ograve", Qt::Key_Ograve }, + { "Oacute", Qt::Key_Oacute }, + { "Ocircumflex", Qt::Key_Ocircumflex }, + { "Otilde", Qt::Key_Otilde }, + { "Odiaeresis", Qt::Key_Odiaeresis }, + { "multiply", Qt::Key_multiply }, + { "Ooblique", Qt::Key_Ooblique }, + { "Ugrave", Qt::Key_Ugrave }, + { "Uacute", Qt::Key_Uacute }, + { "Ucircumflex", Qt::Key_Ucircumflex }, + { "Udiaeresis", Qt::Key_Udiaeresis }, + { "Yacute", Qt::Key_Yacute }, + { "THORN", Qt::Key_THORN }, + { "ssharp", Qt::Key_ssharp }, + + { "agrave", 0xe0 /*Qt::Key_agrave*/ }, + { "aacute", 0xe1 /*Qt::Key_aacute*/ }, + { "acircumflex", 0xe2 /*Qt::Key_acircumflex*/ }, + { "atilde", 0xe3 /*Qt::Key_atilde*/ }, + { "adiaeresis", 0xe4 /*Qt::Key_adiaeresis*/ }, + { "aring", 0xe5 /*Qt::Key_aring*/ }, + { "ae", 0xe6 /*Qt::Key_ae*/ }, + { "ccedilla", 0xe7 /*Qt::Key_ccedilla*/ }, + { "egrave", 0xe8 /*Qt::Key_egrave*/ }, + { "eacute", 0xe9 /*Qt::Key_eacute*/ }, + { "ecircumflex", 0xea /*Qt::Key_ecircumflex*/ }, + { "ediaeresis", 0xeb /*Qt::Key_ediaeresis*/ }, + { "igrave", 0xec /*Qt::Key_igrave*/ }, + { "iacute", 0xed /*Qt::Key_iacute*/ }, + { "icircumflex", 0xee /*Qt::Key_icircumflex*/ }, + { "idiaeresis", 0xef /*Qt::Key_idiaeresis*/ }, + { "eth", 0xf0 /*Qt::Key_eth*/ }, + { "ntilde", 0xf1 /*Qt::Key_ntilde*/ }, + { "ograve", 0xf2 /*Qt::Key_ograve*/ }, + { "oacute", 0xf3 /*Qt::Key_oacute*/ }, + { "ocircumflex", 0xf4 /*Qt::Key_ocircumflex*/ }, + { "otilde", 0xf5 /*Qt::Key_otilde*/ }, + { "odiaeresis", 0xf6 /*Qt::Key_odiaeresis*/ }, + { "division", Qt::Key_division }, + { "oslash", 0xf8 /*Qt::Key_oslash*/ }, + { "ugrave", 0xf9 /*Qt::Key_ugrave*/ }, + { "uacute", 0xfa /*Qt::Key_uacute*/ }, + { "ucircumflex", 0xfb /*Qt::Key_ucircumflex*/ }, + { "udiaeresis", 0xfc /*Qt::Key_udiaeresis*/ }, + { "yacute", 0xfd /*Qt::Key_yacute*/ }, + { "thorn", 0xfe /*Qt::Key_thorn*/ }, + { "ydiaeresis", Qt::Key_ydiaeresis }, + + { "F1", Qt::Key_F1 }, + { "F2", Qt::Key_F2 }, + { "F3", Qt::Key_F3 }, + { "F4", Qt::Key_F4 }, + { "F5", Qt::Key_F5 }, + { "F6", Qt::Key_F6 }, + { "F7", Qt::Key_F7 }, + { "F8", Qt::Key_F8 }, + { "F9", Qt::Key_F9 }, + { "F10", Qt::Key_F10 }, + { "F11", Qt::Key_F11 }, + { "F12", Qt::Key_F12 }, + { "F13", Qt::Key_F13 }, + { "F14", Qt::Key_F14 }, + { "F15", Qt::Key_F15 }, + { "F16", Qt::Key_F16 }, + { "F17", Qt::Key_F17 }, + { "F18", Qt::Key_F18 }, + { "F19", Qt::Key_F19 }, + { "F20", Qt::Key_F20 }, + { "F21", Qt::Key_F21 }, + { "F22", Qt::Key_F22 }, + { "F23", Qt::Key_F23 }, + { "F24", Qt::Key_F24 }, + { "F25", Qt::Key_F25 }, + { "F26", Qt::Key_F26 }, + { "F27", Qt::Key_F27 }, + { "F28", Qt::Key_F28 }, + { "F29", Qt::Key_F29 }, + { "F30", Qt::Key_F30 }, + { "F31", Qt::Key_F31 }, + { "F32", Qt::Key_F32 }, + { "F33", Qt::Key_F33 }, + { "F34", Qt::Key_F34 }, + { "F35", Qt::Key_F35 }, + + { "BackSpace", Qt::Key_Backspace }, + { "Tab", Qt::Key_Tab }, + { "Escape", Qt::Key_Escape }, + { "Delete", Qt::Key_Backspace }, // what's the difference between "Delete" and "BackSpace"?? + { "Return", Qt::Key_Return }, + { "Break", Qt::Key_unknown }, //TODO: why doesn't Qt support the 'Break' key? + { "Caps_Lock", Qt::Key_CapsLock }, + { "Num_Lock", Qt::Key_NumLock }, + { "Scroll_Lock", Qt::Key_ScrollLock }, + { "Caps_On", Qt::Key_CapsLock }, + { "Compose", Qt::Key_Multi_key }, + { "Bare_Num_Lock", Qt::Key_NumLock }, + { "Find", Qt::Key_Home }, + { "Insert", Qt::Key_Insert }, + { "Remove", Qt::Key_Delete }, + { "Select", Qt::Key_End }, + { "Prior", Qt::Key_PageUp }, + { "Next", Qt::Key_PageDown }, + { "Help", Qt::Key_Help }, + { "Pause", Qt::Key_Pause }, + + { "KP_0", Qt::Key_0 | Qt::KeypadModifier }, + { "KP_1", Qt::Key_1 | Qt::KeypadModifier }, + { "KP_2", Qt::Key_2 | Qt::KeypadModifier }, + { "KP_3", Qt::Key_3 | Qt::KeypadModifier }, + { "KP_4", Qt::Key_4 | Qt::KeypadModifier }, + { "KP_5", Qt::Key_5 | Qt::KeypadModifier }, + { "KP_6", Qt::Key_6 | Qt::KeypadModifier }, + { "KP_7", Qt::Key_7 | Qt::KeypadModifier }, + { "KP_8", Qt::Key_8 | Qt::KeypadModifier }, + { "KP_9", Qt::Key_9 | Qt::KeypadModifier }, + { "KP_Add", Qt::Key_Plus | Qt::KeypadModifier }, + { "KP_Subtract", Qt::Key_Minus | Qt::KeypadModifier }, + { "KP_Multiply", Qt::Key_Asterisk | Qt::KeypadModifier }, + { "KP_Divide", Qt::Key_Slash | Qt::KeypadModifier }, + { "KP_Enter", Qt::Key_Enter | Qt::KeypadModifier }, + { "KP_Comma", Qt::Key_Comma | Qt::KeypadModifier }, + { "KP_Period", Qt::Key_Period | Qt::KeypadModifier }, + { "KP_MinPlus", Qt::Key_plusminus | Qt::KeypadModifier }, + + { "dead_grave", Qt::Key_Dead_Grave }, + { "dead_acute", Qt::Key_Dead_Acute }, + { "dead_circumflex", Qt::Key_Dead_Circumflex }, + { "dead_tilde", Qt::Key_Dead_Tilde }, + { "dead_diaeresis", Qt::Key_Dead_Diaeresis }, + { "dead_cedilla", Qt::Key_Dead_Cedilla }, + + { "Down", Qt::Key_Down }, + { "Left", Qt::Key_Left }, + { "Right", Qt::Key_Right }, + { "Up", Qt::Key_Up }, + { "Shift", Qt::Key_Shift }, + { "AltGr", Qt::Key_AltGr }, + { "Control", Qt::Key_Control }, + { "Alt", Qt::Key_Alt }, + { "ShiftL", Qt::Key_Shift }, + { "ShiftR", Qt::Key_Shift }, + { "CtrlL", Qt::Key_Control }, + { "CtrlR", Qt::Key_Control }, +}; + +static const int symbol_map_size = sizeof(symbol_map)/sizeof(symbol_map_t); + + +struct symbol_dead_unicode_t { + quint32 dead; + quint16 unicode; +}; + +static const symbol_dead_unicode_t symbol_dead_unicode[] = { + { Qt::Key_Dead_Grave, '`' }, + { Qt::Key_Dead_Acute, '\'' }, + { Qt::Key_Dead_Circumflex, '^' }, + { Qt::Key_Dead_Tilde, '~' }, + { Qt::Key_Dead_Diaeresis, '"' }, + { Qt::Key_Dead_Cedilla, ',' }, +}; + +static const int symbol_dead_unicode_size = sizeof(symbol_dead_unicode)/sizeof(symbol_dead_unicode_t); + + +struct symbol_synonyms_t { + const char *from; + const char *to; +}; + +static const symbol_synonyms_t symbol_synonyms[] = { + { "Control_h", "BackSpace" }, + { "Control_i", "Tab" }, + { "Control_j", "Linefeed" }, + { "Home", "Find" }, + { "End", "Select" }, + { "PageUp", "Prior" }, + { "PageDown", "Next" }, + { "multiplication", "multiply" }, + { "pound", "sterling" }, + { "pilcrow", "paragraph" }, + { "Oslash", "Ooblique" }, + { "Shift_L", "ShiftL" }, + { "Shift_R", "ShiftR" }, + { "Control_L", "CtrlL" }, + { "Control_R", "CtrlR" }, + { "AltL", "Alt" }, + { "AltR", "AltGr" }, + { "Alt_L", "Alt" }, + { "Alt_R", "AltGr" }, + { "AltGr_L", "Alt" }, + { "AltGr_R", "AltGr" }, + { "tilde", "asciitilde" }, + { "circumflex", "asciicircum" }, + { "dead_ogonek", "dead_cedilla" }, + { "dead_caron", "dead_circumflex" }, + { "dead_breve", "dead_tilde" }, + { "dead_doubleacute", "dead_tilde" }, + { "no-break_space", "nobreakspace" }, + { "paragraph_sign", "section" }, + { "soft_hyphen", "hyphen" }, + { "rightanglequote", "guillemotright" }, +}; + +static const int symbol_synonyms_size = sizeof(symbol_synonyms)/sizeof(symbol_synonyms_t); + +// makes the generated array in --header mode a bit more human readable +static bool operator<(const QWSKeyboard::Mapping &m1, const QWSKeyboard::Mapping &m2) +{ + return m1.keycode != m2.keycode ? m1.keycode < m2.keycode : m1.modifiers < m2.modifiers; +} + +class KeymapParser { +public: + KeymapParser(); + ~KeymapParser(); + + bool parseKmap(QFile *kmap); + bool generateQmap(QFile *qmap); + bool generateHeader(QFile *qmap); + + int parseWarningCount() const { return m_warning_count; } + +private: + bool parseSymbol(const QByteArray &str, const QTextCodec *codec, quint16 &unicode, quint32 &qtcode, quint8 &flags, quint16 &special); + bool parseCompose(const QByteArray &str, const QTextCodec *codec, quint16 &unicode); + bool parseModifier(const QByteArray &str, quint8 &modifier); + + void updateMapping(quint16 keycode = 0, quint8 modifiers = 0, quint16 unicode = 0xffff, quint32 qtcode = Qt::Key_unknown, quint8 flags = 0, quint16 = 0); + + static quint32 toQtModifiers(quint8 modifiers); + static QList tokenize(const QByteArray &line); + + +private: + QList m_keymap; + QList m_keycompose; + + int m_warning_count; +}; + + + +int main(int argc, char **argv) +{ + int header = 0; + if (argc >= 2 && !qstrcmp(argv[1], "--header")) + header = 1; + + if (argc < (3 + header)) { + fprintf(stderr, "Usage: kmap2qmap [--header] [ ...] \n"); + fprintf(stderr, " --header can be used to generate Qt's default compiled in qmap.\n"); + return 1; + } + + QVector kmaps(argc - header - 2); + for (int i = 0; i < kmaps.size(); ++i) { + kmaps [i] = new QFile(QString::fromLocal8Bit(argv[i + 1 + header])); + + if (!kmaps[i]->open(QIODevice::ReadOnly)) { + fprintf(stderr, "Could not read from '%s'.\n", argv[i + 1 + header]); + return 2; + } + } + QFile *qmap = new QFile(QString::fromLocal8Bit(argv[argc - 1])); + + if (!qmap->open(QIODevice::WriteOnly)) { + fprintf(stderr, "Could not write to '%s'.\n", argv[argc - 1]); + return 3; + } + + KeymapParser p; + + for (int i = 0; i < kmaps.size(); ++i) { + if (!p.parseKmap(kmaps[i])) { + fprintf(stderr, "Parsing kmap '%s' failed.\n", qPrintable(kmaps[i]->fileName())); + return 4; + } + } + + if (p.parseWarningCount()) { + fprintf(stderr, "\nParsing the specified keymap(s) produced %d warning(s).\n" \ + "Your generated qmap might not be complete.\n", \ + p.parseWarningCount()); + } + if (!(header ? p.generateHeader(qmap) : p.generateQmap(qmap))) { + fprintf(stderr, "Generating the qmap failed.\n"); + return 5; + } + + qDeleteAll(kmaps); + delete qmap; + + return 0; +} + + +KeymapParser::KeymapParser() + : m_warning_count(0) +{ } + + +KeymapParser::~KeymapParser() +{ } + + +bool KeymapParser::generateHeader(QFile *f) +{ + QTextStream ts(f); + + ts << "#ifndef QWSKEYBOARDHANDLER_DEFAULTMAP_H" << endl; + ts << "#define QWSKEYBOARDHANDLER_DEFAULTMAP_H" << endl << endl; + + ts << "const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = {" << endl; + + for (int i = 0; i < m_keymap.size(); ++i) { + const QWSKeyboard::Mapping &m = m_keymap.at(i); + QString s; + s.sprintf(" { %3d, 0x%04x, 0x%08x, 0x%02x, 0x%02x, 0x%04x },\n", m.keycode, m.unicode, m.qtcode, m.modifiers, m.flags, m.special); + ts << s; + } + + ts << "};" << endl << endl; + + ts << "const QWSKeyboard::Composing QWSKbPrivate::s_keycompose_default[] = {" << endl; + + for (int i = 0; i < m_keycompose.size(); ++i) { + const QWSKeyboard::Composing &c = m_keycompose.at(i); + QString s; + s.sprintf(" { 0x%04x, 0x%04x, 0x%04x },\n", c.first, c.second, c.result); + ts << s; + } + ts << "};" << endl << endl; + + ts << "#endif" << endl; + + return (ts.status() == QTextStream::Ok); +} + + +bool KeymapParser::generateQmap(QFile *f) +{ + QDataStream ds(f); + + ds << quint32(QWSKeyboard::FileMagic) << quint32(1 /* version */) << quint32(m_keymap.size()) << quint32(m_keycompose.size()); + + if (ds.status() != QDataStream::Ok) + return false; + + for (int i = 0; i < m_keymap.size(); ++i) + ds << m_keymap[i]; + + for (int i = 0; i < m_keycompose.size(); ++i) + ds << m_keycompose[i]; + + return (ds.status() == QDataStream::Ok); +} + + +QList KeymapParser::tokenize(const QByteArray &line) +{ + bool quoted = false, separator = true; + QList result; + QByteArray token; + + for (int i = 0; i < line.length(); ++i) { + QChar c = line.at(i); + + if (!quoted && c == '#' && separator) + break; + else if (!quoted && c == '"' && separator) + quoted = true; + else if (quoted && c == '"') + quoted = false; + else if (!quoted && c.isSpace()) { + separator = true; + if (!token.isEmpty()) { + result.append(token); + token.truncate(0); + } + } + else { + separator = false; + token.append(c); + } + } + if (!token.isEmpty()) + result.append(token); + return result; +} + + +#define parseWarning(s) do { qWarning("Warning: keymap file '%s', line %d: %s", qPrintable(f->fileName()), lineno, s); ++m_warning_count; } while (false) + +bool KeymapParser::parseKmap(QFile *f) +{ + QByteArray line; + int lineno = 0; + QList keymaps; + QTextCodec *codec = QTextCodec::codecForName("iso8859-1"); + + for (int i = 0; i <= 256; ++i) + keymaps << i; + + while (!f->atEnd() && !f->error()) { + line = f->readLine(); + lineno++; + + QList tokens = tokenize(line); + + if (tokens.isEmpty()) + continue; + + if (tokens[0] == "keymaps") { + keymaps.clear(); + + if (tokens.count() > 1) { + foreach (const QByteArray §ion, tokens[1].split(',')) { + int dashpos = section.indexOf('-'); + + //qWarning("Section %s", section.constData()); + int end = section.mid(dashpos + 1).toInt(); + int start = end; + if (dashpos > 0) + start = section.left(dashpos).toInt(); + + if (start <= end && start >=0 && end <= 256) { + for (int i = start; i <= end; ++i) { + //qWarning("appending keymap %d", i); + keymaps.append(i); + } + } + else + parseWarning("keymaps has an invalid range"); + } + qSort(keymaps); + } + else + parseWarning("keymaps with more than one argument"); + } + else if (tokens[0] == "alt_is_meta") { + // simply ignore it for now + } + else if (tokens[0] == "include") { + if (tokens.count() == 2) { + QString incname = QString::fromLocal8Bit(tokens[1]); + bool found = false; + QList searchpath; + QFileInfo fi(*f); + + if (!incname.endsWith(QLatin1String(".kmap")) && !incname.endsWith(QLatin1String(".inc"))) + incname.append(QLatin1String(".inc")); + + QDir d = fi.dir(); + searchpath << d; + if (d.cdUp() && d.cd(QLatin1String("include"))) + searchpath << d; + searchpath << QDir::current(); + + foreach (const QDir &path, searchpath) { + QFile f2(path.filePath(incname)); + //qWarning(" -- trying to include %s", qPrintable(f2.fileName())); + if (f2.open(QIODevice::ReadOnly)) { + if (!parseKmap(&f2)) + parseWarning("could not parse keymap include"); + found = true; + } + } + + if (!found) + parseWarning("could not locate keymap include"); + } else + parseWarning("include doesn't have exactly one argument"); + } + else if (tokens[0] == "charset") { + if (tokens.count() == 2) { + codec = QTextCodec::codecForName(tokens[1]); + if (!codec) { + parseWarning("could not parse codec definition"); + codec = QTextCodec::codecForName("iso8859-1"); + } + } else + parseWarning("codec doesn't habe exactly one argument"); + } + else if (tokens[0] == "strings") { + // simply ignore those - they have no meaning for QWS + } + else if (tokens[0] == "compose") { + if (tokens.count() == 5 && tokens[3] == "to") { + QWSKeyboard::Composing c = { 0xffff, 0xffff, 0xffff }; + + if (!parseCompose(tokens[1], codec, c.first)) + parseWarning("could not parse first compose symbol"); + if (!parseCompose(tokens[2], codec, c.second)) + parseWarning("could not parse second compose symbol"); + if (!parseCompose(tokens[4], codec, c.result)) + parseWarning("could not parse resulting compose symbol"); + + if (c.first != 0xffff && c.second != 0xffff && c.result != 0xffff) { + m_keycompose << c; + } + } else + parseWarning("non-standard compose line"); + } + else { + int kcpos = tokens.indexOf("keycode"); + + if (kcpos >= 0 && kcpos < (tokens.count()-3) && tokens[kcpos+2] == "=") { + quint16 keycode = tokens[kcpos+1].toInt(); + + if (keycode <= 0 || keycode > 0x1ff /* KEY_MAX */) { + parseWarning("keycode out of range [0..0x1ff]"); + break; + } + + bool line_modifiers = (kcpos > 0); + + quint8 modifiers = 0; //, modifiers_mask = 0xff; + for (int i = 0; i < kcpos; ++i) { + quint8 mod; + if (!parseModifier(tokens[i], mod)) { + parseWarning("unknown modifier prefix for keycode"); + continue; + } + modifiers |= mod; + } + + int kccount = tokens.count() - kcpos - 3; // 3 : 'keycode' 'X' '=' + + if (line_modifiers && kccount > 1) { + parseWarning("line has modifiers, but more than one keycode"); + break; + } + + // only process one symbol when a prefix modifer was specified + for (int i = 0; i < (line_modifiers ? 1 : kccount); ++i) { + if (!line_modifiers) + modifiers = keymaps[i]; + + quint32 qtcode; + quint16 unicode; + quint16 special; + quint8 flags; + if (!parseSymbol(tokens[i + kcpos + 3], codec, unicode, qtcode, flags, special)) { + parseWarning((QByteArray("symbol could not be parsed: ") + tokens[i + kcpos + 3]).constData()); + break; + } + + if (qtcode == Qt::Key_unknown && unicode == 0xffff) // VoidSymbol + continue; + + if (!line_modifiers && kccount == 1) { + if ((unicode >= 'A' && unicode <= 'Z') || (unicode >= 'a' && unicode <= 'z')) { + quint16 other_unicode = (unicode >= 'A' && unicode <= 'Z') ? unicode - 'A' + 'a' : unicode - 'a' + 'A'; + quint16 lower_unicode = (unicode >= 'A' && unicode <= 'Z') ? unicode - 'A' + 'a' : unicode; + + // a single a-z|A-Z value results in a very flags mapping: see below + + updateMapping(keycode, QWSKeyboard::ModPlain, unicode, qtcode, flags, 0); + + updateMapping(keycode, QWSKeyboard::ModShift, other_unicode, qtcode, flags, 0); + + updateMapping(keycode, QWSKeyboard::ModAltGr, unicode, qtcode, flags, 0); + updateMapping(keycode, QWSKeyboard::ModAltGr | QWSKeyboard::ModShift, other_unicode, qtcode, flags, 0); + + updateMapping(keycode, QWSKeyboard::ModControl, lower_unicode, qtcode | Qt::ControlModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModControl | QWSKeyboard::ModShift, lower_unicode, qtcode | Qt::ControlModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModControl | QWSKeyboard::ModAltGr, lower_unicode, qtcode | Qt::ControlModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModControl | QWSKeyboard::ModAltGr | QWSKeyboard::ModShift, lower_unicode, qtcode | Qt::ControlModifier, flags, 0); + + updateMapping(keycode, QWSKeyboard::ModAlt, unicode, qtcode | Qt::AltModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModAlt | QWSKeyboard::ModShift, unicode, qtcode | Qt::AltModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModAlt | QWSKeyboard::ModAltGr, unicode, qtcode | Qt::AltModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModAlt | QWSKeyboard::ModAltGr | QWSKeyboard::ModShift, unicode, qtcode | Qt::AltModifier, flags, 0); + + updateMapping(keycode, QWSKeyboard::ModAlt | QWSKeyboard::ModControl, lower_unicode, qtcode | Qt::ControlModifier | Qt::AltModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModAlt | QWSKeyboard::ModControl | QWSKeyboard::ModShift, lower_unicode, qtcode | Qt::ControlModifier | Qt::AltModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModAlt | QWSKeyboard::ModControl | QWSKeyboard::ModAltGr, lower_unicode, qtcode | Qt::ControlModifier | Qt::AltModifier, flags, 0); + updateMapping(keycode, QWSKeyboard::ModAlt | QWSKeyboard::ModControl | QWSKeyboard::ModAltGr | QWSKeyboard::ModShift, lower_unicode, qtcode | Qt::ControlModifier | Qt::AltModifier, flags, 0); + } + else { + // a single value results in that mapping regardless of the modifier + //for (int mod = 0; mod <= 255; ++mod) + // updateMapping(keycode, quint8(mod), unicode, qtcode | toQtModifiers(mod), flags, special); + + // we can save a lot of space in the qmap, since we do that anyway in the kbd handler: + updateMapping(keycode, QWSKeyboard::ModPlain, unicode, qtcode, flags, special); + } + } + else { + // "normal" mapping + updateMapping(keycode, modifiers, unicode, qtcode, flags, special); + } + } + } + } + } + qSort(m_keymap); + return !m_keymap.isEmpty(); +} + + + +void KeymapParser::updateMapping(quint16 keycode, quint8 modifiers, quint16 unicode, quint32 qtcode, quint8 flags, quint16 special) +{ + for (int i = 0; i < m_keymap.size(); ++i) { + QWSKeyboard::Mapping &m = m_keymap[i]; + + if (m.keycode == keycode && m.modifiers == modifiers) { + m.unicode = unicode; + m.qtcode = qtcode; + m.flags = flags; + m.special = special; + return; + } + } + QWSKeyboard::Mapping m = { keycode, unicode, qtcode, modifiers, flags, special }; + m_keymap << m; +} + + +quint32 KeymapParser::toQtModifiers(quint8 modifiers) +{ + quint32 qtmodifiers = Qt::NoModifier; + + for (int i = 0; i < modifier_map_size; ++i) { + if (modifiers & modifier_map[i].modifier) + qtmodifiers |= modifier_map[i].qtmodifier; + } + return qtmodifiers; +} + + +bool KeymapParser::parseModifier(const QByteArray &str, quint8 &modifier) +{ + QByteArray lstr = str.toLower(); + + for (int i = 0; i < modifier_map_size; ++i) { + if (lstr == modifier_map[i].symbol) { + modifier = modifier_map[i].modifier; + return true; + } + } + return false; +} + + +bool KeymapParser::parseCompose(const QByteArray &str, const QTextCodec *codec, quint16 &unicode) +{ + if (str == "'\\''") { + unicode = '\''; + return true; + } else if (str.length() == 3 && str.startsWith('\'') && str.endsWith('\'')) { + QString temp = codec->toUnicode(str.constData() + 1, str.length() - 2); + if (temp.length() != 1) + return false; + unicode = temp[0].unicode(); + return true; + } else { + quint32 code = str.toUInt(); + if (code > 255) + return false; + char c[2]; + c[0] = char(code); + c[1] = 0; + QString temp = codec->toUnicode(c); + if (temp.length() != 1) + return false; + unicode = temp[0].unicode(); + return true; + } +} + + +bool KeymapParser::parseSymbol(const QByteArray &str, const QTextCodec * /*codec*/, quint16 &unicode, quint32 &qtcode, quint8 &flags, quint16 &special) +{ + flags = (str[0] == '+') ? QWSKeyboard::IsLetter : 0; + QByteArray sym = (flags & QWSKeyboard::IsLetter) ? str.right(str.length() - 1) : str; + + special = 0; + qtcode = Qt::Key_unknown; + unicode = 0xffff; + + if (sym == "VoidSymbol" || sym == "nul") + return true; + + bool try_to_find_qtcode = false; + + if (sym[0] >= '0' && sym[0] <= '9') { // kernel internal action number + return false; + } else if (sym.length() == 6 && sym[1] == '+' && (sym[0] == 'U' || sym[0] == 'u')) { // unicode + bool ok; + unicode = sym.mid(2).toUInt(&ok, 16); + if (!ok) + return false; + try_to_find_qtcode = true; + } else { // symbolic + for (int i = 0; i < symbol_synonyms_size; ++i) { + if (sym == symbol_synonyms[i].from) { + sym = symbol_synonyms[i].to; + break; + } + } + + quint32 qtmod = 0; + + // parse prepended modifiers + forever { + int underpos = sym.indexOf('_'); + + if (underpos <= 0) + break; + QByteArray modsym = sym.left(underpos); + QByteArray nomodsym = sym.mid(underpos + 1); + quint8 modifier = 0; + + if (!parseModifier(modsym, modifier)) + break; + + qtmod |= toQtModifiers(modifier); + sym = nomodsym; + } + + if (qtcode == Qt::Key_unknown) { + quint8 modcode; + // check if symbol is a modifier + if (parseModifier(sym, modcode)) { + special = modcode; + flags |= QWSKeyboard::IsModifier; + } + + // map symbol to Qt key code + for (int i = 0; i < symbol_map_size; ++i) { + if (sym == symbol_map[i].symbol) { + qtcode = symbol_map[i].qtcode; + break; + } + } + + // a-zA-Z is not in the table to save space + if (qtcode == Qt::Key_unknown && sym.length() == 1) { + char letter = sym.at(0); + + if (letter >= 'a' && letter <= 'z') { + qtcode = Qt::Key_A + letter - 'a'; + unicode = letter; + } + else if (letter >= 'A' && letter <= 'Z') { + qtcode = Qt::Key_A + letter - 'A'; + unicode = letter; + } + } + // System keys + if (qtcode == Qt::Key_unknown) { + quint16 sys = 0; + + if (sym == "Decr_Console") { + sys = QWSKeyboard::SystemConsolePrevious; + } else if (sym == "Incr_Console") { + sys = QWSKeyboard::SystemConsoleNext; + } else if (sym.startsWith("Console_")) { + int console = sym.mid(8).toInt() - 1; + if (console >= 0 && console <= (QWSKeyboard::SystemConsoleLast - QWSKeyboard::SystemConsoleFirst)) { + sys = QWSKeyboard::SystemConsoleFirst + console; + } + } else if (sym == "Boot") { + sys = QWSKeyboard::SystemReboot; + } else if (sym == "QtZap") { + sys = QWSKeyboard::SystemZap; + } + + if (sys) { + flags |= QWSKeyboard::IsSystem; + special = sys; + qtcode = Qt::Key_Escape; // just a dummy + } + } + + // map Qt key codes in the iso-8859-1 range to unicode + if (qtcode != Qt::Key_unknown && unicode == 0xffff) { + quint32 qtcode_no_mod = qtcode & ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier); + if (qtcode_no_mod <= 0x000000ff) // iso-8859-1 + unicode = quint16(qtcode_no_mod); + } + + // flag dead keys + if (qtcode >= Qt::Key_Dead_Grave && qtcode <= Qt::Key_Dead_Horn) { + flags = QWSKeyboard::IsDead; + + for (int i = 0; i < symbol_dead_unicode_size; ++i) { + if (symbol_dead_unicode[i].dead == qtcode) { + unicode = symbol_dead_unicode[i].unicode; + break; + } + } + } + } + if ((qtcode == Qt::Key_unknown) && (unicode == 0xffff)) + return false; + + qtcode |= qtmod; + } + + // map unicode in the iso-8859-1 range to Qt key codes + if (unicode >= 0x0020 && unicode <= 0x00ff && qtcode == Qt::Key_unknown) + qtcode = unicode; // iso-8859-1 + + return true; +} + diff --git a/tools/tools.pro b/tools/tools.pro index ffc5d63..c76174c 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -22,6 +22,8 @@ mac { SUBDIRS += macdeployqt } +SUBDIRS += kmap2qmap + contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns embedded: SUBDIRS += makeqpf -- cgit v0.12 From d0f2051a8fe7cb44a04b0a540baafd1aeed06092 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Thu, 2 Apr 2009 22:44:54 +0200 Subject: Make QWS a bit more OS independent. Some patches needed to support QWS on non-Linux platforms. Reviewed-by: Paul Olav Tvete Reviewed-by: Harald Fernengel --- src/gui/embedded/qkbdum_qws.cpp | 9 +++++---- src/gui/embedded/qscreen_qws.cpp | 8 +++++--- src/gui/embedded/qwscommand_qws.cpp | 1 - src/gui/embedded/qwssignalhandler.cpp | 6 ++++-- src/gui/kernel/qapplication_qws.cpp | 9 +++++---- src/gui/text/qfontdatabase_qws.cpp | 5 +++-- src/gui/text/qfontengine_qpf.cpp | 12 ++++++------ src/gui/text/qfontengine_qws.cpp | 2 +- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/gui/embedded/qkbdum_qws.cpp b/src/gui/embedded/qkbdum_qws.cpp index d525c66..fa05d6c 100644 --- a/src/gui/embedded/qkbdum_qws.cpp +++ b/src/gui/embedded/qkbdum_qws.cpp @@ -54,6 +54,7 @@ #include #include #include +#include "qplatformdefs.h" QT_BEGIN_NAMESPACE @@ -81,13 +82,13 @@ QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(const QString &device) { kbdBuffer = new unsigned char [kbdBufferLen]; - if ((kbdFD = open((const char *)device.toLocal8Bit(), O_RDONLY | O_NDELAY)) < 0) { + if ((kbdFD = QT_OPEN((const char *)device.toLocal8Bit(), O_RDONLY | O_NDELAY, 0)) < 0) { qDebug("Cannot open %s (%s)", (const char *)device.toLocal8Bit(), strerror(errno)); } else { // Clear pending input char buf[2]; - while (read(kbdFD, buf, 1) > 0) { } + while (QT_READ(kbdFD, buf, 1) > 0) { } notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this); connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData())); @@ -97,7 +98,7 @@ QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(const QString &device) QWSUmKeyboardHandlerPrivate::~QWSUmKeyboardHandlerPrivate() { if (kbdFD >= 0) - close(kbdFD); + QT_CLOSE(kbdFD); delete [] kbdBuffer; } @@ -106,7 +107,7 @@ void QWSUmKeyboardHandlerPrivate::readKeyboardData() { int n; do { - n = read(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); + n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); if (n > 0) kbdIdx += n; } while (n > 0); diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index 6741f2c..ff48403 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -198,10 +198,12 @@ void QScreenCursor::set(const QImage &image, int hotx, int hoty) */ void QScreenCursor::move(int x, int y) { - const QRegion r = boundingRect(); + QRegion r = boundingRect(); pos = QPoint(x,y); - if (enable && !hwaccel) - qt_screen->exposeRegion(r | boundingRect(), 0); + if (enable && !hwaccel) { + r |= boundingRect(); + qt_screen->exposeRegion(r, 0); + } } diff --git a/src/gui/embedded/qwscommand_qws.cpp b/src/gui/embedded/qwscommand_qws.cpp index 88e33a3..b0fd78b 100644 --- a/src/gui/embedded/qwscommand_qws.cpp +++ b/src/gui/embedded/qwscommand_qws.cpp @@ -43,7 +43,6 @@ #include "qtransportauth_qws.h" #include "qtransportauth_qws_p.h" -#include #include // #define QWSCOMMAND_DEBUG 1 // Uncomment to debug client/server communication diff --git a/src/gui/embedded/qwssignalhandler.cpp b/src/gui/embedded/qwssignalhandler.cpp index 0946fb6..e85bd36 100644 --- a/src/gui/embedded/qwssignalhandler.cpp +++ b/src/gui/embedded/qwssignalhandler.cpp @@ -44,8 +44,10 @@ #ifndef QT_NO_QWS_SIGNALHANDLER #include -#include -#include +#ifndef QT_NO_QWS_MULTIPROCESS +# include +# include +#endif #include QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index 2deda8e..fcfd2a4 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -195,14 +195,14 @@ QString qws_dataDir() if (!result.isEmpty()) return result; QByteArray dataDir = QString(QLatin1String("/tmp/qtembedded-%1")).arg(qws_display_id).toLocal8Bit(); - if (mkdir(dataDir, 0700)) { + if (QT_MKDIR(dataDir, 0700)) { if (errno != EEXIST) { qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData()); } } - struct stat buf; - if (lstat(dataDir, &buf)) + QT_STATBUF buf; + if (QT_LSTAT(dataDir, &buf)) qFatal("stat failed for Qt for Embedded Linux data directory: %s", dataDir.constData()); if (!S_ISDIR(buf.st_mode)) @@ -2280,7 +2280,8 @@ void qt_init(QApplicationPrivate *priv, int type) qt_appType = QApplication::Type(type); qws_single_process = true; QWSServer::startup(flags); - setenv("QWS_DISPLAY", qws_display_spec.constData(), 0); + if (!display) // if not already set + qputenv("QWS_DISPLAY", qws_display_spec); } if(qt_is_gui_used) { diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp index eb8a0cf..f62a6d1 100644 --- a/src/gui/text/qfontdatabase_qws.cpp +++ b/src/gui/text/qfontdatabase_qws.cpp @@ -58,6 +58,7 @@ #include "qabstractfontengine_qws.h" #include "qabstractfontengine_p.h" #include +#include "qplatformdefs.h" // for mmap #include @@ -127,7 +128,7 @@ void QFontDatabasePrivate::addQPF2File(const QByteArray &file) struct stat st; if (stat(file.constData(), &st)) return; - int f = ::open(file, O_RDONLY); + int f = ::open(file, O_RDONLY, 0); if (f < 0) return; const uchar *data = (const uchar *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, f, 0); @@ -675,7 +676,7 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp, qDebug() << "Resource not valid" << size->fileName; } #else - int f = ::open(size->fileName, O_RDONLY); + int f = ::open(size->fileName, O_RDONLY, 0); if (f >= 0) { QFontEngineQPF *fe = new QFontEngineQPF(request, f); if (fe->isValid()) diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp index e9fcac4..b7d1c59 100644 --- a/src/gui/text/qfontengine_qpf.cpp +++ b/src/gui/text/qfontengine_qpf.cpp @@ -252,7 +252,7 @@ QList QFontEngineQPF::cleanUpAfterClientCrash(const QList &cras for (int i = 0; i < int(dir.count()); ++i) { const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i])); - int fd = ::open(fileName.constData(), O_RDONLY); + int fd = ::open(fileName.constData(), O_RDONLY, 0); if (fd >= 0) { void *header = ::mmap(0, sizeof(QFontEngineQPF::Header), PROT_READ, MAP_SHARED, fd, 0); if (header && header != MAP_FAILED) { @@ -331,9 +331,9 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng qDebug() << "found existing qpf:" << fileName; #endif if (::access(encodedName, W_OK | R_OK) == 0) - fd = ::open(encodedName, O_RDWR); + fd = ::open(encodedName, O_RDWR, 0); else if (::access(encodedName, R_OK) == 0) - fd = ::open(encodedName, O_RDONLY); + fd = ::open(encodedName, O_RDONLY, 0); } else { #if defined(DEBUG_FONTENGINE) qDebug() << "creating qpf on the fly:" << fileName; @@ -347,7 +347,7 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng generator.generate(); buffer.close(); const QByteArray &data = buffer.data(); - ::write(fd, data.constData(), data.size()); + QT_WRITE(fd, data.constData(), data.size()); } } } @@ -893,8 +893,8 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph) g.y = qRound(metrics.y); g.advance = qRound(metrics.xoff); - ::write(fd, &g, sizeof(g)); - ::write(fd, img.bits(), img.numBytes()); + QT_WRITE(fd, &g, sizeof(g)); + QT_WRITE(fd, img.bits(), img.numBytes()); glyphPos = oldSize - glyphDataOffset; #if 0 && defined(DEBUG_FONTENGINE) diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp index d776329..10aef4c 100644 --- a/src/gui/text/qfontengine_qws.cpp +++ b/src/gui/text/qfontengine_qws.cpp @@ -387,7 +387,7 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) { cache_cost = 1; - int f = ::open( QFile::encodeName(fn), O_RDONLY ); + int f = ::open( QFile::encodeName(fn), O_RDONLY, 0); Q_ASSERT(f>=0); QT_STATBUF st; if ( QT_FSTAT( f, &st ) ) -- cgit v0.12 From 36f79cff893e446cafa579dd2a7dc841e0a0d4e7 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 3 Apr 2009 07:51:37 +1000 Subject: Build breakage: QStringList declaration missing in qkbd_qws.cpp Reviewed-by: trustme --- src/gui/embedded/qkbd_qws.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp index 120d2a1..dc92a01 100644 --- a/src/gui/embedded/qkbd_qws.cpp +++ b/src/gui/embedded/qkbd_qws.cpp @@ -46,6 +46,7 @@ #include #include +#include #include "qwindowsystem_qws.h" #include "qscreen_qws.h" -- cgit v0.12 From 4dc364f4e94e0c5604a70edf245ae5e9b1c97eaa Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 3 Apr 2009 12:17:30 +1000 Subject: Add information about QT_* defines that are needed to make PowerVR work The QT_QWS_CLIENTBLIT and QT_NO_QWS_CURSOR defines must be supplied or the direct paint regions used by the PowerVR driver won't work. Reviewed-by: trustme --- src/plugins/gfxdrivers/powervr/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/gfxdrivers/powervr/README b/src/plugins/gfxdrivers/powervr/README index b830066..ec02efb 100644 --- a/src/plugins/gfxdrivers/powervr/README +++ b/src/plugins/gfxdrivers/powervr/README @@ -8,6 +8,9 @@ is built as two libraries: The actual QScreen plugin used by Qt (in the pvreglscreen directory) and a WSEGL plugin for the PowerVR drivers (in the QWSWSEGL directory). +Qt/Embedded needs to be configured with the QT_QWS_CLIENTBLIT and +QT_NO_QWS_CURSOR defines. + The PowerVR drivers provide the WSEGL plugin API to allow window systems such as QWS to integrate correctly. In order to use the integration, the WSEGL plugin (libpvrQWSWSEGL.so, usually installed into the Qt library directory) must be in -- cgit v0.12 From 2772d0455446000eb9aab882b884805d8a2a5d93 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 3 Apr 2009 12:59:23 +1000 Subject: Suppress unnecessary "Could not re-create the temporary EGL surface" warnings The wrong temporary surface id was being used to recreate the EGL surface. It was "tempSurface" when it should have been -1. Reviewed-by: Ian Walters --- src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp index 3a94851..b0ffbf1 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp @@ -381,7 +381,7 @@ void PvrEglSurfaceHolder::removeSurface() // create the temporary surface again. if (surface == EGL_NO_SURFACE && dpy != EGL_NO_DISPLAY) { surface = eglCreateWindowSurface - (dpy, config, (EGLNativeWindowType)tempSurface, NULL); + (dpy, config, (EGLNativeWindowType)(-1), NULL); if (surface == EGL_NO_SURFACE) qWarning("Could not re-create the temporary EGL surface"); } -- cgit v0.12 From b2a8a4e0297a7850cf938d85fbfd90cd272d15c2 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 3 Apr 2009 08:54:27 +0200 Subject: My changes --- dist/changes-4.5.1 | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/changes-4.5.1 b/dist/changes-4.5.1 index fac0b5d..1d2286e 100644 --- a/dist/changes-4.5.1 +++ b/dist/changes-4.5.1 @@ -87,6 +87,7 @@ Qt for Windows CE * [248000] Fixed a crash ocurring when re-layouting empty grid layouts. * [245961] Restricted objectname-validation to known object name properties only. + * [245503] Fixed redundant backslashes in string property in property browser. - Linguist - Linguist GUI -- cgit v0.12 From d684546573785ce40fb5de2b8b3aad88e9958709 Mon Sep 17 00:00:00 2001 From: jasplin Date: Fri, 3 Apr 2009 10:03:56 +0200 Subject: Fix focus policy propagation bug in QCompleter. Commit 4a00810cc394b7da99ddb2d13eb045352ede25d3 ensures that setting the focus policy of a widget applies to its proxy (if any) as well. This propagation effect is however unfortunate for a QCompleter in PopupCompletion mode. The client widget (typically a QLineEdit or a QTextEdit) acts as the focus proxy to the popup menu. Internally, the completer sets the focus policy of the popup menu to NoFocus, but this should not affect the focus policy of the editor. Reviewed-by: janarve Task-number: 250064 --- src/gui/util/qcompleter.cpp | 7 ++++ tests/auto/qcompleter/tst_qcompleter.cpp | 58 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index aeb7e91..7571dfe 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -1079,7 +1079,14 @@ void QCompleter::setPopup(QAbstractItemView *popup) popup->setModel(d->proxy); popup->hide(); popup->setParent(0, Qt::Popup); + + Qt::FocusPolicy origPolicy; + if (d->widget) + origPolicy = d->widget->focusPolicy(); popup->setFocusPolicy(Qt::NoFocus); + if (d->widget) + d->widget->setFocusPolicy(origPolicy); + popup->setFocusProxy(d->widget); popup->installEventFilter(this); popup->setItemDelegate(new QCompleterItemDelegate(popup)); diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 67b9b67..656995a 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -141,6 +141,7 @@ private slots: void task178797_activatedOnReturn(); void task189564_omitNonSelectableItems(); void task246056_setCompletionPrefix(); + void task250064_lostFocus(); private: void filter(); @@ -1126,5 +1127,62 @@ void tst_QCompleter::task246056_setCompletionPrefix() QTest::keyPress(comboBox->completer()->popup(), Qt::Key_Enter); // don't crash! } +class task250064_TextEdit : public QTextEdit +{ +public: + QCompleter *completer; + + task250064_TextEdit() + { + completer = new QCompleter; + completer->setWidget(this); + } + + void keyPressEvent (QKeyEvent *e) + { + completer->popup(); + QTextEdit::keyPressEvent(e); + } +}; + +class task250064_Widget : public QWidget +{ + Q_OBJECT +public: + task250064_TextEdit *textEdit; + + task250064_Widget(task250064_TextEdit *textEdit) + : textEdit(textEdit) + { + QTabWidget *tabWidget = new QTabWidget; + tabWidget->setFocusPolicy(Qt::ClickFocus); + tabWidget->addTab(textEdit, "untitled"); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->addWidget(tabWidget); + + textEdit->setPlainText("bla bla bla"); + textEdit->setFocus(); + } + + void setCompletionModel() + { + textEdit->completer->setModel(0); + } +}; + +void tst_QCompleter::task250064_lostFocus() +{ + task250064_TextEdit *textEdit = new task250064_TextEdit; + task250064_Widget *widget = new task250064_Widget(textEdit); + widget->show(); + QTest::qWait(100); + QTest::keyPress(textEdit, 'a'); + Qt::FocusPolicy origPolicy = textEdit->focusPolicy(); + QVERIFY(origPolicy != Qt::NoFocus); + widget->setCompletionModel(); + QCOMPARE(textEdit->focusPolicy(), origPolicy); +} + QTEST_MAIN(tst_QCompleter) #include "tst_qcompleter.moc" -- cgit v0.12 From 6c2dd295b2ca2f9125fe072d035a3784ce748718 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Fri, 3 Apr 2009 10:47:07 +0200 Subject: Removed usage of NaN in SVG gradients. Since there is no way to find out if gradient stops have been added to a gradient, a gradient stop at NaN was earlier used in the SVG module to mark the gradient as empty. This could cause floating point exceptions. The usage of NaN has now been replaced by a boolean in QSvgGradientStyle. Duplicate entry "qxmlpatterns" was removed from auto.pro in the auto test directory. Task-number: 250146 Reviewed-by: Samuel --- src/svg/qsvghandler.cpp | 12 ++++-------- src/svg/qsvgstyle.cpp | 13 ++++++------- src/svg/qsvgstyle_p.h | 11 +++++++++++ tests/auto/auto.pro | 3 +-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 56dab5f..18ba71c 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -2649,7 +2649,6 @@ static QSvgStyleProperty *createLinearGradientNode(QSvgNode *node, } QLinearGradient *grad = new QLinearGradient(nx1, ny1, nx2, ny2); - grad->setColorAt(qQNaN(), QColor()); grad->setInterpolationMode(QGradient::ComponentInterpolation); QSvgGradientStyle *prop = new QSvgGradientStyle(grad); parseBaseGradient(node, attributes, prop, handler); @@ -2783,7 +2782,6 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node, nfy = toDouble(fy); QRadialGradient *grad = new QRadialGradient(ncx, ncy, nr, nfx, nfy); - grad->setColorAt(qQNaN(), QColor()); grad->setInterpolationMode(QGradient::ComponentInterpolation); QSvgGradientStyle *prop = new QSvgGradientStyle(grad); @@ -2929,12 +2927,9 @@ static bool parseStopNode(QSvgStyleProperty *parent, QGradient *grad = style->qgradient(); offset = qMin(qreal(1), qMax(qreal(0), offset)); // Clamp to range [0, 1] - QGradientStops stops = grad->stops(); - // Check if the gradient is marked as empty (marked with one single stop at NaN). - if ((stops.size() == 1) && qIsNaN(stops.at(0).first)) { - stops.clear(); - grad->setStops(stops); - } else { + QGradientStops stops; + if (style->gradientStopsSet()) { + stops = grad->stops(); // If the stop offset equals the one previously added, add an epsilon to make it greater. if (offset <= stops.back().first) offset = stops.back().first + FLT_EPSILON; @@ -2950,6 +2945,7 @@ static bool parseStopNode(QSvgStyleProperty *parent, } grad->setColorAt(offset, color); + style->setGradientStopsSet(true); if (!colorOK) style->addResolve(offset); return true; diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index 389f68f..4a40bed 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -231,7 +231,7 @@ void QSvgSolidColorStyle::revert(QPainter *p, QSvgExtraStates &) } QSvgGradientStyle::QSvgGradientStyle(QGradient *grad) - : m_gradient(grad) + : m_gradient(grad), m_gradientStopsSet(false) { } @@ -256,14 +256,13 @@ void QSvgGradientStyle::apply(QPainter *p, const QRectF &/*rect*/, QSvgNode *, Q } // If the gradient is marked as empty, insert transparent black - QGradientStops stops = m_gradient->stops(); - if (stops.size() == 1 && qIsNaN(stops.at(0).first)) - m_gradient->setStops(QGradientStops() << QGradientStop(0.0, QColor(0, 0, 0, 0))); - - QGradient gradient = *m_gradient; + if (!m_gradientStopsSet) { + m_gradient->setColorAt(0.0, QColor(0, 0, 0, 0)); + m_gradientStopsSet = true; + } QBrush brush; - brush = QBrush(gradient); + brush = QBrush(*m_gradient); if (!m_matrix.isIdentity()) brush.setMatrix(m_matrix); diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h index ff4058b..058ba35 100644 --- a/src/svg/qsvgstyle_p.h +++ b/src/svg/qsvgstyle_p.h @@ -376,6 +376,16 @@ public: } void addResolve(qreal offset); + + bool gradientStopsSet() const + { + return m_gradientStopsSet; + } + + void setGradientStopsSet(bool set) + { + m_gradientStopsSet = set; + } private: QGradient *m_gradient; QList m_resolvePoints; @@ -386,6 +396,7 @@ private: QSvgTinyDocument *m_doc; QString m_link; + bool m_gradientStopsSet; }; class QSvgTransformStyle : public QSvgStyleProperty diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 41c73a3..60e6657 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -407,8 +407,7 @@ SUBDIRS += checkxmlfiles \ xmlpatternsdiagnosticsts \ xmlpatternsview \ xmlpatternsxqts \ - xmlpatternsxslts \ - xmlpatterns + xmlpatternsxslts xmlpatternsdiagnosticsts.depends = xmlpatternsxqts xmlpatternsview.depends = xmlpatternsxqts -- cgit v0.12 From d154911914ca8c98db623d558a4d85fe92c45550 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 3 Apr 2009 12:56:01 +0200 Subject: Use the standard 'type name = value' variable declaration for POD types. C++ is nice, but we don't have to use confusing syntax when plain old C works (and is correct). This apparently fixes a compilation error on MSVC 6, that doesn't like the constructor-like initialisation for POD types. Reviewed-by: Trust Me BT: yes --- src/network/access/qnetworkcookie.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index b82d8f9..01a743b 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -569,7 +569,7 @@ static bool checkStaticArray(int &val, const QByteArray &dateString, int at, con int j = 0; int i = 0; while (i <= size) { - const char *str(array + i); + const char *str = array + i; if (str[0] == dateString[at] && str[1] == dateString[at + 1] && str[2] == dateString[at + 2]) { -- cgit v0.12 From dcff85182dda913b45867e27fde3f37e61ae86d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 3 Apr 2009 13:29:20 +0200 Subject: BT: Compilation on WinCE. Reviewed-by: Kim --- src/opengl/qglpixelbuffer_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qglpixelbuffer_win.cpp b/src/opengl/qglpixelbuffer_win.cpp index e81a576..e3228cc 100644 --- a/src/opengl/qglpixelbuffer_win.cpp +++ b/src/opengl/qglpixelbuffer_win.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include -- cgit v0.12 From b652130dc00dfab7322751275e42f59943c7e8e3 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 1 Apr 2009 11:07:16 +0200 Subject: Add config test for XLib Previously, it was entirely possible to successfully configure Qt/X11 without any X11 installed. The problems would only start showing up once you stated building. This is not very useful if you're cross-compiling and trying to setup the paths correctly. Reviewed-by: Denis --- config.tests/x11/xlib/xlib.cpp | 9 +++++++++ config.tests/x11/xlib/xlib.pro | 3 +++ configure | 8 ++++++++ 3 files changed, 20 insertions(+) create mode 100644 config.tests/x11/xlib/xlib.cpp create mode 100644 config.tests/x11/xlib/xlib.pro diff --git a/config.tests/x11/xlib/xlib.cpp b/config.tests/x11/xlib/xlib.cpp new file mode 100644 index 0000000..8d25bf5 --- /dev/null +++ b/config.tests/x11/xlib/xlib.cpp @@ -0,0 +1,9 @@ +#include + +int main(int, char **) +{ + Display *d = XOpenDisplay(NULL); + XCloseDisplay(d); + return 0; +} + diff --git a/config.tests/x11/xlib/xlib.pro b/config.tests/x11/xlib/xlib.pro new file mode 100644 index 0000000..658161e --- /dev/null +++ b/config.tests/x11/xlib/xlib.pro @@ -0,0 +1,3 @@ +CONFIG += x11 +CONFIG -= qt +SOURCES = xlib.cpp diff --git a/configure b/configure index f79b1e2..7e66a98 100755 --- a/configure +++ b/configure @@ -4727,6 +4727,14 @@ if [ "$PLATFORM_X11" = "yes" ]; then X11TESTS_FLAGS="$X11TESTS_FLAGS -fpermissive" fi + # Check we actually have X11 :-) + if ! "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xlib "XLib" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then + echo "Basic XLib functionality test failed!" + echo " You might need to modify the include and library search paths by editing" + echo " QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in ${XQMAKESPEC}." + exit 1 + fi + # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es1cl = ES 1.x common lite, es2 = OpenGL ES 2.x) if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/opengl "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then -- cgit v0.12 From ed9fe24ecce5a21f93c88c08d2034bf175808fa3 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 1 Apr 2009 11:39:09 +0200 Subject: Use QMAKE_LIBS_OPENGL_QT in the GL ES config tests The OpenGL ES config tests are there to test if there's enough to build QtOpenGL, not OpenGL applications using Qt. Therefore we should use QMAKE_LIBS_OPENGL_QT rather than QMAKE_LIBS_OPENGL. This is mostely because Qt needs to link against EGL whereas Qt applications do not. Reviewed-by: TrustMe --- config.tests/unix/opengles1/opengles1.pro | 2 +- config.tests/unix/opengles1cl/opengles1cl.pro | 2 +- config.tests/unix/opengles2/opengles2.pro | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.tests/unix/opengles1/opengles1.pro b/config.tests/unix/opengles1/opengles1.pro index d800a5d..ad8dd31 100644 --- a/config.tests/unix/opengles1/opengles1.pro +++ b/config.tests/unix/opengles1/opengles1.pro @@ -6,4 +6,4 @@ for(p, QMAKE_LIBDIR_OPENGL) { } CONFIG -= qt -LIBS += $$QMAKE_LIBS_OPENGL +LIBS += $$QMAKE_LIBS_OPENGL_QT diff --git a/config.tests/unix/opengles1cl/opengles1cl.pro b/config.tests/unix/opengles1cl/opengles1cl.pro index c9addf9..415cdbb 100644 --- a/config.tests/unix/opengles1cl/opengles1cl.pro +++ b/config.tests/unix/opengles1cl/opengles1cl.pro @@ -6,4 +6,4 @@ for(p, QMAKE_LIBDIR_OPENGL) { } CONFIG -= qt -LIBS += $$QMAKE_LIBS_OPENGL +LIBS += $$QMAKE_LIBS_OPENGL_QT diff --git a/config.tests/unix/opengles2/opengles2.pro b/config.tests/unix/opengles2/opengles2.pro index 13f95a1..0dfae42 100644 --- a/config.tests/unix/opengles2/opengles2.pro +++ b/config.tests/unix/opengles2/opengles2.pro @@ -6,4 +6,4 @@ for(p, QMAKE_LIBDIR_OPENGL) { } CONFIG -= qt -LIBS += $$QMAKE_LIBS_OPENGL +LIBS += $$QMAKE_LIBS_OPENGL_QT -- cgit v0.12 From 10f0b31dd1b3193bf4c068edde5979881c82ece7 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 3 Apr 2009 13:49:13 +0200 Subject: Fix a crash in QFileDialog with a proxy on it. The main problem is that enterDirectory received a QModelIndex that can be a proxy index and not a source index if there is a proxy set on the QFileDialog. This fix basically discover some other crashes in the completer. The problem was that we didn't apply the proxy to the completer too. So we basically messed up source and proxy indexes. Both have a proxy set now and convert the model indexes if needed. Task-number:250194 Reviewed-by:jasplin --- src/gui/dialogs/qfiledialog.cpp | 27 ++++++++++++++--- src/gui/dialogs/qfiledialog_p.h | 39 +++++++++++++------------ tests/auto/qfiledialog/tst_qfiledialog.cpp | 47 ++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 22 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 2ce5563..5131271 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -2124,6 +2124,7 @@ void QFileDialogPrivate::createWidgets() #ifndef QT_NO_COMPLETER completer = new QFSCompletor(model, q); qFileDialogUi->fileNameEdit->setCompleter(completer); + completer->sourceModel = model; QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_autoCompleteFileName(QString))); #endif // QT_NO_COMPLETER @@ -2246,12 +2247,21 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel) proxyModel->setSourceModel(d->model); d->qFileDialogUi->listView->setModel(d->proxyModel); d->qFileDialogUi->treeView->setModel(d->proxyModel); +#ifndef QT_NO_COMPLETER + d->completer->setModel(d->proxyModel); + d->completer->proxyModel = d->proxyModel; +#endif connect(d->proxyModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(_q_rowsInserted(const QModelIndex &))); } else { d->proxyModel = 0; d->qFileDialogUi->listView->setModel(d->model); d->qFileDialogUi->treeView->setModel(d->model); +#ifndef QT_NO_COMPLETER + d->completer->setModel(d->model); + d->completer->sourceModel = d->model; + d->completer->proxyModel = 0; +#endif connect(d->model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(_q_rowsInserted(const QModelIndex &))); } @@ -2764,8 +2774,9 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index) { Q_Q(QFileDialog); // My Computer or a directory - QString path = index.data(QFileSystemModel::FilePathRole).toString(); - if (path.isEmpty() || model->isDir(index)) { + QModelIndex sourceIndex = mapToSource(index); + QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); + if (path.isEmpty() || model->isDir(sourceIndex)) { q->setDirectory(path); emit q->directoryEntered(path); if (fileMode == QFileDialog::Directory @@ -3139,7 +3150,11 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e) QString QFSCompletor::pathFromIndex(const QModelIndex &index) const { - const QFileSystemModel *dirModel = static_cast(model()); + const QFileSystemModel *dirModel; + if (proxyModel) + dirModel = qobject_cast(proxyModel->sourceModel()); + else + dirModel = sourceModel; QString currentLocation = dirModel->rootPath(); QString path = index.data(QFileSystemModel::FilePathRole).toString(); if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) { @@ -3185,7 +3200,11 @@ QStringList QFSCompletor::splitPath(const QString &path) const bool startsFromRoot = path[0] == sep[0]; #endif if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) { - const QFileSystemModel *dirModel = static_cast(model()); + const QFileSystemModel *dirModel; + if (proxyModel) + dirModel = qobject_cast(proxyModel->sourceModel()); + else + dirModel = sourceModel; QString currentLocation = QDir::toNativeSeparators(dirModel->rootPath()); if (currentLocation.contains(sep) && path != currentLocation) { QStringList currentLocationList = splitPath(currentLocation); diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/gui/dialogs/qfiledialog_p.h index 8cb2cb0..dc24390 100644 --- a/src/gui/dialogs/qfiledialog_p.h +++ b/src/gui/dialogs/qfiledialog_p.h @@ -91,6 +91,26 @@ class QCompleter; class QHBoxLayout; class Ui_QFileDialog; +#ifndef QT_NO_COMPLETER +/*! + QCompleter that can deal with QFileSystemModel + */ +class QFSCompletor : public QCompleter { +public: + QFSCompletor(QAbstractItemModel *model, QObject *parent = 0) : QCompleter(model, parent), proxyModel(0), sourceModel(0) + { +#ifdef Q_OS_WIN + setCaseSensitivity(Qt::CaseInsensitive); +#endif + } + QString pathFromIndex(const QModelIndex &index) const; + QStringList splitPath(const QString& path) const; + + QAbstractProxyModel *proxyModel; + QFileSystemModel *sourceModel; +}; +#endif // QT_NO_COMPLETER + struct QFileDialogArgs { QFileDialogArgs() : parent(0), mode(QFileDialog::AnyFile) {} @@ -255,7 +275,7 @@ public: // data QStringList watching; QFileSystemModel *model; - QCompleter *completer; + QFSCompletor *completer; QFileDialog::FileMode fileMode; QFileDialog::AcceptMode acceptMode; @@ -434,23 +454,6 @@ inline QString QFileDialogPrivate::rootPath() const { inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return QString(); } #endif -#ifndef QT_NO_COMPLETER -/*! - QCompleter that can deal with QFileSystemModel - */ -class QFSCompletor : public QCompleter { -public: - QFSCompletor(QAbstractItemModel *model, QObject *parent = 0) : QCompleter(model, parent) - { -#ifdef Q_OS_WIN - setCaseSensitivity(Qt::CaseInsensitive); -#endif - } - QString pathFromIndex(const QModelIndex &index) const; - QStringList splitPath(const QString& path) const; -}; -#endif // QT_NO_COMPLETER - QT_END_NAMESPACE #endif // QT_NO_FILEDIALOG diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index b03d459..bade586 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -1526,6 +1526,42 @@ private: }; +class sortProxy : public QSortFilterProxyModel +{ +public: + sortProxy(QObject *parent) : QSortFilterProxyModel(parent) + { + } +protected: + virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const + { + QFileSystemModel * const model = qobject_cast(sourceModel()); + const QFileInfo leftInfo(model->fileInfo(left)); + const QFileInfo rightInfo(model->fileInfo(right)); + + if (leftInfo.isDir() == rightInfo.isDir()) + return(leftInfo.filePath().compare(rightInfo.filePath(),Qt::CaseInsensitive) < 0); + else if (leftInfo.isDir()) + return(false); + else + return(true); + } +}; + +class CrashDialog : public QNonNativeFileDialog +{ + Q_OBJECT + +public: + CrashDialog(QWidget *parent, const QString &caption, const +QString &dir, const QString &filter) + : QNonNativeFileDialog(parent, caption, dir, filter) + { + sortProxy *proxyModel = new sortProxy(this); + setProxyModel(proxyModel); + } +}; + void tst_QFiledialog::task227304_proxyOnFileDialog() { QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); @@ -1537,6 +1573,17 @@ void tst_QFiledialog::task227304_proxyOnFileDialog() QTest::keyClick(edit, Qt::Key_S); QTest::qWait(200); QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); + + CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") ); + dialog->setFileMode(QFileDialog::ExistingFile); + dialog->show(); + + QListView *list = qFindChild(dialog, "listView"); + QTest::qWait(200); + QTest::keyClick(list, Qt::Key_Down); + QTest::keyClick(list, Qt::Key_Return); + QTest::qWait(200); + } void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() -- cgit v0.12 From ee3ed6a5ae30b8283c9077f0af23863440675a19 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 3 Apr 2009 13:29:55 +0200 Subject: Do not loose WindowType flags when setting translucent background in X11 This fixes KRunner on XMonad. The Qt::Dialog flag of the krunner dialog was lost when the Qt::WA_TranslucentBackground was set, leading to incorrect behaviour in some window manager (such as xmonad) Reviewed-by: Samuel --- src/gui/kernel/qwidget_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index e71bc2f..ea8af93 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -898,7 +898,7 @@ void QWidgetPrivate::x11UpdateIsOpaque() bool visible = q->isVisible(); if (visible) q->hide(); - q->setParent(q->parentWidget(), q->windowFlags() & ~Qt::WindowType_Mask); + q->setParent(q->parentWidget(), q->windowFlags()); q->move(pos); if (visible) q->show(); -- cgit v0.12 From f9e0b4e7d57b568ab20b7c77e284f966ff6baf41 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 3 Apr 2009 13:35:08 +0200 Subject: Fixes crash in QTreeView with QSortFilterProxyModel If we get an hover event while the model gets invalidated, we might ends up calling itemDecorationAt before the viewitem is refreshed. Can be reproduced in KTorrent (Relates to KDE bug 172198) or Kopete trunk Reviewed-by: Thierry --- src/gui/itemviews/qtreeview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 2aa0c57..0117db2 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -3507,6 +3507,7 @@ void QTreeViewPrivate::updateScrollBars() int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const { + const_cast(q_func())->executeDelayedItemsLayout(); int x = pos.x(); int column = header->logicalIndexAt(x); if (column != 0) -- cgit v0.12 From 2a8e39999cb3f5be9bb16ffb5ddfe118d18f9ef1 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 3 Apr 2009 18:19:47 +0200 Subject: QGtkStyle: Fix styling and palette issues related to combo box Well actually this change is a bit bigger than just that. *We no longer override the palette you provide in polish so it should be a bit more frienly toward custom application changes. * Another issue was that we would generate the palette information when we got the style callback from gtkButton but then the line edits might not yet have been polished. Hence we now return from the callback and instead post the update for later. * We had to modify the PE_Frame entry to draw a raised menu when the custom combo box delegate was used. * We now simply ignore custom qtconfig palette entries when using GtkStyle since they only cause trouble with it. Task-number: 250142 Reviewed-by: nrc --- src/gui/kernel/qapplication_x11.cpp | 7 ++-- src/gui/styles/gtksymbols.cpp | 68 +++++++++++++++++++++---------------- src/gui/styles/gtksymbols_p.h | 11 +++++- src/gui/styles/qgtkstyle.cpp | 40 +++++++++++++++++++--- src/gui/widgets/qcombobox_p.h | 2 +- 5 files changed, 89 insertions(+), 39 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 260a9a4..10fb886 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -829,8 +829,11 @@ bool QApplicationPrivate::x11_apply_settings() QColor(strlist[i])); } - if (groupCount == QPalette::NColorGroups) - QApplicationPrivate::setSystemPalette(pal); + // ### Fix properly for 4.6 + if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) { + if (groupCount == QPalette::NColorGroups) + QApplicationPrivate::setSystemPalette(pal); + } int kdeSessionVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt(); diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index f60c980..8123d32 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -75,6 +75,7 @@ QT_BEGIN_NAMESPACE static bool displayDepth = -1; +Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler) typedef QHash WidgetMap; Q_GLOBAL_STATIC(WidgetMap, gtkWidgetMap) @@ -486,11 +487,11 @@ static void init_gtk_menu() } // Updates window/windowtext palette based on the indicated gtk widget -static void ensureWidgetPalette(QWidget* widget, const QString >kWidgetName) +static QPalette gtkWidgetPalette(const QString >kWidgetName) { GtkWidget *gtkWidget = QGtk::gtkWidget(gtkWidgetName); Q_ASSERT(gtkWidget); - QPalette pal = widget->palette(); + QPalette pal = QApplication::palette(); GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL]; GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL]; GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE]; @@ -503,8 +504,14 @@ static void ensureWidgetPalette(QWidget* widget, const QString >kWidgetName) pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor); pal.setBrush(QPalette::All, QPalette::ButtonText, textColor); pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor); - widget->setPalette(pal); - widget->setAttribute(Qt::WA_SetPalette, false); + if (gtkWidgetName == QLS("GtkMenu")) { + // This really applies to the combo box rendering since + // QComboBox copies the palette from a QMenu + GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL]; + QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); + pal.setBrush(QPalette::Base, bgColor); + } + return pal; } bool QGtk::isKDE4Session() @@ -515,44 +522,45 @@ bool QGtk::isKDE4Session() return (version == 4); } -// Maps a Gtk widget palettes to a Qt widget -void QGtk::applyGtkSystemPalette(QWidget *widget) +void QGtk::applyCustomPaletteHash() { - // Do not apply if the widget has a custom palette; - if (widget->testAttribute(Qt::WA_SetPalette)) - return; + QPalette menuPal = gtkWidgetPalette(QLS("GtkMenu")); + GdkColor gdkBg = QGtk::gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL]; + QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); + menuPal.setBrush(QPalette::Base, bgColor); + qApp->setPalette(menuPal, "QMenu"); - QPalette pal; - if (QStatusBar *statusbar = qobject_cast (widget)) - ensureWidgetPalette(statusbar, QLS("GtkStatusbar")); - else if (QMenuBar *menubar = qobject_cast (widget)) - ensureWidgetPalette(menubar, QLS("GtkMenuBar")); - else if (QToolBar *toolbar = qobject_cast (widget)) - ensureWidgetPalette(toolbar, QLS("GtkToolbar")); - else if (QMenu *menu = qobject_cast (widget)) { - // This really applies to the combo box rendering since - // QComboBox copies the palette from a QMenu - QPalette pal = widget->palette(); - GdkColor gdkBg = QGtk::gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL]; - QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); - pal.setBrush(QPalette::Base, bgColor); - menu->setPalette(pal); - } - widget->setAttribute(Qt::WA_SetPalette, false); + QPalette toolbarPal = gtkWidgetPalette(QLS("GtkToolbar")); + qApp->setPalette(toolbarPal, "QToolBar"); + + QPalette menuBarPal = gtkWidgetPalette(QLS("GtkMenuBar")); + qApp->setPalette(menuBarPal, "QMenuBar"); } static void gtkStyleSetCallback(GtkWidget*, GtkStyle*, void*) { + // We have to let this function return and complete the event + // loop to ensure that all gtk widgets have been styled before + // updating + QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection); +} + +void QGtkStyleUpdateScheduler::updateTheme() +{ static QString oldTheme(QLS("qt_not_set")); QPixmapCache::clear(); - qApp->setFont(QGtk::getThemeFont()); - QGtk::initGtkWidgets(); if (oldTheme != getThemeName()) { oldTheme = getThemeName(); - QApplicationPrivate::setSystemPalette(qApp->style()->standardPalette()); + qApp->setFont(QGtk::getThemeFont()); + QPalette newPalette = qApp->style()->standardPalette(); + QApplicationPrivate::setSystemPalette(newPalette); + QApplication::setPalette(newPalette); + QGtk::applyCustomPaletteHash(); QList widgets = QApplication::allWidgets(); + // Notify all widgets that size metrics might have changed foreach (QWidget *widget, widgets) { - QGtk::applyGtkSystemPalette(widget); + QEvent e(QEvent::StyleChange); + QApplication::sendEvent(widget, &e); } } } diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h index 0cea542..74c5dc3 100644 --- a/src/gui/styles/gtksymbols_p.h +++ b/src/gui/styles/gtksymbols_p.h @@ -204,7 +204,7 @@ public: static void cleanup_gtk_widgets(); static void initGtkWidgets(); static bool isKDE4Session(); - static void applyGtkSystemPalette(QWidget* widget); + static void applyCustomPaletteHash(); static QFont getThemeFont(); static bool isThemeAvailable() { return gtkStyle() != 0; } @@ -329,6 +329,15 @@ public: static Ptr_gconf_client_get_string gconf_client_get_string; }; +// Helper to ensure that we have polished all our gtk widgets +// before updating our own palettes +class QGtkStyleUpdateScheduler : public QObject +{ + Q_OBJECT +public slots: + void updateTheme(); +}; + QT_END_NAMESPACE #endif // !QT_NO_STYLE_GTK diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 81d7cb8..6354ce7 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -38,7 +38,6 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - #include "qgtkstyle.h" #if !defined(QT_NO_STYLE_GTK) @@ -138,6 +137,30 @@ static const char * const dock_widget_restore_xpm[] = }; +class QGtkStyleFilter : public QObject +{ +public: + QGtkStyleFilter() { + qApp->installEventFilter(this); + } + +private: + bool eventFilter(QObject *obj, QEvent *e); +}; + +bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e) +{ + if (e->type() == QEvent::ApplicationPaletteChange) { + // Only do this the first time since this will also + // generate applicationPaletteChange events + extern QHash *qt_app_palettes_hash(); //qapplication.cpp + if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) { + QGtk::applyCustomPaletteHash(); + } + } + return QObject::eventFilter(obj, e); +} + class QGtkStylePrivate : public QCleanlooksStylePrivate { Q_DECLARE_PUBLIC(QGtkStyle) @@ -145,6 +168,7 @@ public: QGtkStylePrivate() : QCleanlooksStylePrivate() {} + QGtkStyleFilter filter; }; static const int groupBoxBottomMargin = 2; // space below the groupbox @@ -217,6 +241,7 @@ static QString uniqueName(const QString &key, const QStyleOption *option, const Constructs a QGtkStyle object. */ QGtkStyle::QGtkStyle() + : QCleanlooksStyle(*new QGtkStylePrivate) { QGtk::initGtkWidgets(); } @@ -313,7 +338,7 @@ void QGtkStyle::polish(QPalette &palette) if (!QGtk::isThemeAvailable()) QCleanlooksStyle::polish(palette); else - palette = standardPalette(); + palette = palette.resolve(standardPalette()); } /*! @@ -328,6 +353,7 @@ void QGtkStyle::polish(QApplication *app) if (app->desktopSettingsAware() && QGtk::isThemeAvailable()) { QApplicationPrivate::setSystemPalette(standardPalette()); QApplicationPrivate::setSystemFont(QGtk::getThemeFont()); + QGtk::applyCustomPaletteHash(); if (!QGtk::isKDE4Session()) { qt_filedialog_open_filename_hook = &QGtk::openFilename; qt_filedialog_save_filename_hook = &QGtk::saveFilename; @@ -357,12 +383,12 @@ void QGtkStyle::unpolish(QApplication *app) /*! \reimp */ + void QGtkStyle::polish(QWidget *widget) { QCleanlooksStyle::polish(widget); if (!QGtk::isThemeAvailable()) return; - if (qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) @@ -375,8 +401,6 @@ void QGtkStyle::polish(QWidget *widget) widget->setAttribute(Qt::WA_Hover); else if (QTreeView *tree = qobject_cast (widget)) tree->viewport()->setAttribute(Qt::WA_Hover); - - QGtk::applyGtkSystemPalette(widget); } /*! @@ -647,6 +671,12 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, switch (element) { case PE_Frame: { + if (widget && widget->inherits("QComboBoxPrivateContainer")){ + QStyleOption copy = *option; + copy.state |= State_Raised; + drawPrimitive(PE_PanelMenu, ©, painter, widget); + break; + } // Drawing the entire itemview frame is very expensive, especially on the native X11 engine // Instead we cheat a bit and draw a border image without the center part, hence only scaling // thin rectangular images diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index f1203dc..c39a231 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -265,7 +265,7 @@ protected: const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionMenuItem opt = getStyleOption(option, index); - painter->eraseRect(option.rect); + painter->fillRect(option.rect, opt.palette.background()); mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo); } QSize sizeHint(const QStyleOptionViewItem &option, -- cgit v0.12 From 72020cb52ac7f6ed8c71a42f01ca818180830964 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Fri, 3 Apr 2009 18:55:05 +0200 Subject: Forgot to remove a debug output Reviewed-by: TrustMe --- src/gui/embedded/qkbdtty_qws.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp index 37ed510..8311ba7 100644 --- a/src/gui/embedded/qkbdtty_qws.cpp +++ b/src/gui/embedded/qkbdtty_qws.cpp @@ -255,7 +255,6 @@ void QWSTtyKbPrivate::readKeycode() ka = m_handler->processKeycode(buffer[i] & 0x7f, (buffer[i] & 0x80) == 0x00, buffer[i] == m_last_keycode); m_last_keycode = buffer[i]; -qWarning("Special: %08x", ka); switch (ka) { case QWSKeyboardHandler::CapsLockOn: case QWSKeyboardHandler::CapsLockOff: -- cgit v0.12 From 4cdb847d93842df26859581906c943f0da78d775 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 3 Apr 2009 16:16:38 -0700 Subject: Silence warning and beautify code Even though these variables couldn't really be used uninitialized GCC 4.3.2 thinks it could. This is nicer, more readable and faster anyway. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 28 ++++------------------ .../gfxdrivers/directfb/qdirectfbpaintdevice.h | 9 +++++++ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 5e71640..edbfa7d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -123,7 +123,6 @@ QSize QDirectFBPaintDevice::size() const return QSize(w, h); } - int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const { if (!dfbSurface) @@ -132,40 +131,21 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const int w, h; dfbSurface->GetSize(dfbSurface, &w, &h); - int dpmX, dpmY; // Dots-per-meter ;-) - - // Do some common calculations: - switch (metric) { - case QPaintDevice::PdmWidthMM: - case QPaintDevice::PdmPhysicalDpiX: - case QPaintDevice::PdmDpiX: - dpmX = (screen->deviceWidth() * 1000) / screen->physicalWidth(); - break; - case QPaintDevice::PdmHeightMM: - case QPaintDevice::PdmPhysicalDpiY: - case QPaintDevice::PdmDpiY: - dpmY = (screen->deviceHeight() * 1000) / screen->physicalHeight(); - break; - default: - break; - } - - // Now use those calculations switch (metric) { case QPaintDevice::PdmWidth: return w; case QPaintDevice::PdmHeight: return h; case QPaintDevice::PdmWidthMM: - return (w * 1000) / dpmX; + return (w * 1000) / dotsPerMeterX(); case QPaintDevice::PdmHeightMM: - return (h * 1000) / dpmY; + return (h * 1000) / dotsPerMeterY(); case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmDpiX: - return (dpmX * 254) / 10000; // 0.0254 meters-per-inch + return (dotsPerMeterX() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmDpiY: - return (dpmY * 254) / 10000; // 0.0254 meters-per-inch + return (dotsPerMeterY() * 254) / 10000; // 0.0254 meters-per-inch case QPaintDevice::PdmDepth: DFBSurfacePixelFormat format; dfbSurface->GetPixelFormat(dfbSurface, &format); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 89a3087..a11064b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -78,6 +78,15 @@ protected: screen(scr), forceRaster(false) {} + inline int dotsPerMeterX() const + { + return (screen->deviceWidth() * 1000) / screen->physicalWidth(); + } + inline int dotsPerMeterY() const + { + return (screen->deviceHeight() * 1000) / screen->physicalHeight(); + } + IDirectFBSurface *dfbSurface; QImage *lockedImage; QDirectFBScreen *screen; -- cgit v0.12 From 3cfa6a8b5338c2490dda498ba4a27a2917675b72 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 3 Apr 2009 17:05:19 -0700 Subject: QScreen::flush() no longer draws the titlebar We don't need to chain to the base class anymore. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 4ba1102..c495805 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -332,11 +332,6 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, dfbWindow->SetOpacity(dfbWindow, winOpacity); } #endif - - // XXX: have to call the base function first as the decoration is - // currently painted there - QWSWindowSurface::flush(widget, region, offset); - #ifndef QT_NO_DIRECTFB_WM if (region.numRects() > 1) { const QVector rects = region.rects(); -- cgit v0.12 From 11fdefebdd26e5cef4736384f2f3ad0cafc2db1e Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 3 Apr 2009 17:34:09 -0700 Subject: Add some timing capabilities Add some frames-per-second output for debugging when QT_DIRECTFB_TIMING is defined. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/directfb.pro | 1 + src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp | 18 +++++++++++++++++- src/plugins/gfxdrivers/directfb/qdirectfbsurface.h | 8 ++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index 96eb536..399044e 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -12,6 +12,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers #DEFINES += QT_NO_DIRECTFB_PREALLOCATED #DEFINES += QT_NO_DIRECTFB_MOUSE #DEFINES += QT_NO_DIRECTFB_KEYBOARD +#DEFINES += QT_DIRECTFB_TIMING target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index c495805..ef208af 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -58,6 +58,10 @@ QDirectFBSurface::QDirectFBSurface(QDirectFBScreen* scr) , engine(0) { setSurfaceFlags(Opaque | Buffered); +#ifdef QT_DIRECTFB_TIMING + frames = 0; + timer.start(); +#endif } QDirectFBSurface::QDirectFBSurface(QDirectFBScreen* scr, QWidget *widget) @@ -72,6 +76,10 @@ QDirectFBSurface::QDirectFBSurface(QDirectFBScreen* scr, QWidget *widget) setSurfaceFlags(Opaque | RegionReserved); else setSurfaceFlags(Opaque | Buffered); +#ifdef QT_DIRECTFB_TIMING + frames = 0; + timer.start(); +#endif } QDirectFBSurface::~QDirectFBSurface() @@ -307,7 +315,6 @@ inline bool isWidgetOpaque(const QWidget *w) return false; } - void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { @@ -350,6 +357,15 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, dfbSurface->Flip(dfbSurface, &dfbReg, DSFLIP_ONSYNC); } #endif +#ifdef QT_DIRECTFB_TIMING + enum { Secs = 3 }; + ++frames; + if (timer.elapsed() >= Secs * 1000) { + qDebug("%d fps", int(double(frames) / double(Secs))); + frames = 0; + timer.restart(); + } +#endif } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h index a9cdb7d..9e2791c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h @@ -50,6 +50,10 @@ #include #include +#ifdef QT_DIRECTFB_TIMING +#include +#endif + QT_BEGIN_HEADER QT_MODULE(Gui) @@ -95,6 +99,10 @@ private: bool onscreen; QList bufferImages; +#ifdef QT_DIRECTFB_TIMING + int frames; + QTime timer; +#endif }; QT_END_HEADER -- cgit v0.12 From 219bc135ff23119072c2ac25dfb609e303987663 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 3 Apr 2009 16:19:50 +0200 Subject: Make the configure.exe program work for the commercial release licenses. Reviewed-by: TrustMe BT: yes --- configure.exe | Bin 1939968 -> 1134592 bytes tools/configure/tools.cpp | 35 ++++++++++++++--------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/configure.exe b/configure.exe index 54e8a60..13ca0e5 100644 Binary files a/configure.exe and b/configure.exe differ diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp index 5d12ea5..760c101 100644 --- a/tools/configure/tools.cpp +++ b/tools/configure/tools.cpp @@ -142,25 +142,28 @@ void Tools::checkLicense(QMap &dictionary, QMap &dictionary, QMap Date: Mon, 6 Apr 2009 08:08:05 +0200 Subject: Update the qmake documentation regarding when the .qmake.cache is processed. Reviewed-by: TrustMe --- doc/src/qmake-manual.qdoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/src/qmake-manual.qdoc b/doc/src/qmake-manual.qdoc index 27cfa0b..39581a2 100644 --- a/doc/src/qmake-manual.qdoc +++ b/doc/src/qmake-manual.qdoc @@ -3080,6 +3080,9 @@ called \c{.qmake.cache} in parent directories of the current directory. If it fails to find this file, it will silently ignore this step of processing. + If it finds a \c{.qmake.cache} file then it will process this file first before + it processes the project file. + \target LibDepend \section1 Library Dependencies -- cgit v0.12 From b11659ba9ea4532583398f6e539e78ed79a0c600 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 3 Apr 2009 16:51:21 +0200 Subject: Fix QNetworkReply's automatic pushing of a cache when the cache is more than 64k. This issue was found by Warwick: the copyReadyRead() slot is called only once as a result of readyRead(), but since there's no more data to be received (the source QIODevice is a QBuffer), we'll never get a readyRead() again. So, if we don't have a limited buffer size, we should read everything. This applies to QFile as well. The side-effect is that we cause the entire QFile to be loaded to memory, so if you had a 2 GB cache entry, you'll probably run out of memory. Future optimisations: - don't memcpy the data from a QBuffer into another buffer - find a way to avoid loading the entire contents of the file (probably not possible with the default QNetworkDiskCache since that may compress the data, so we won't know the size and thus can't fake finished()) Reviewed-by: Warwick Allison --- src/network/access/qnetworkreplyimpl.cpp | 44 ++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index eaa572f..79c3d1a 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -131,27 +131,37 @@ void QNetworkReplyImplPrivate::_q_copyReadyRead() if (!copyDevice && !q->isOpen()) return; - qint64 bytesToRead = nextDownstreamBlockSize(); - if (bytesToRead == 0) - // we'll be called again, eventually - return; + forever { + qint64 bytesToRead = nextDownstreamBlockSize(); + if (bytesToRead == 0) + // we'll be called again, eventually + break; - bytesToRead = qBound(1, bytesToRead, copyDevice->bytesAvailable()); - char *ptr = readBuffer.reserve(bytesToRead); - qint64 bytesActuallyRead = copyDevice->read(ptr, bytesToRead); - if (bytesActuallyRead == -1) { - readBuffer.chop(bytesToRead); - backendNotify(NotifyCopyFinished); - return; - } + bytesToRead = qBound(1, bytesToRead, copyDevice->bytesAvailable()); + char *ptr = readBuffer.reserve(bytesToRead); + qint64 bytesActuallyRead = copyDevice->read(ptr, bytesToRead); + if (bytesActuallyRead == -1) { + readBuffer.chop(bytesToRead); + backendNotify(NotifyCopyFinished); + return; + } - if (bytesActuallyRead != bytesToRead) - readBuffer.chop(bytesToRead - bytesActuallyRead); + if (bytesActuallyRead != bytesToRead) + readBuffer.chop(bytesToRead - bytesActuallyRead); - if (!copyDevice->isSequential() && copyDevice->atEnd()) - backendNotify(NotifyCopyFinished); + if (!copyDevice->isSequential() && copyDevice->atEnd()) { + backendNotify(NotifyCopyFinished); + break; + } + + bytesDownloaded += bytesActuallyRead; + } + + if (bytesDownloaded == lastBytesDownloaded) { + // we didn't read anything + return; + } - bytesDownloaded += bytesActuallyRead; lastBytesDownloaded = bytesDownloaded; QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); emit q->downloadProgress(bytesDownloaded, -- cgit v0.12 From c350892f55a1d8633be54f09e6e4596f4687bc89 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 6 Apr 2009 10:20:56 +0200 Subject: Fix up color matching on 64-bit Cocoa. It seems that GetThemeTextColor is not available at all for 64-bit versions of the operating system and there is no good equivalent. We were using a technique where we would create a small pixmap and then use HIThemeSetTextFillColor() with the proper enum. However, this function will silently set a black color if it doesn't know about the enum. So, we get black when we really shouldn't. It also seems to produce colors that are a bit different from the Carbon function. So, in the meantime, just hard code the values in. It might break if you are hacking the resources in Mac OS X, but we'll have to live with that until we get a real function. Task-number: 248918 Reviewed-by: Prasanth Ullattil --- src/gui/kernel/qt_mac.cpp | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp index 4703475..b1247e8 100644 --- a/src/gui/kernel/qt_mac.cpp +++ b/src/gui/kernel/qt_mac.cpp @@ -131,16 +131,47 @@ QColor qcolorForTheme(ThemeBrush brush) QColor qcolorForThemeTextColor(ThemeTextColor themeColor) { -#ifndef QT_MAC_USE_COCOA +#ifdef QT_OS_MAC32 RGBColor c; GetThemeTextColor(themeColor, 32, true, &c); - return QColor(c.red / 265, c.green / 256, c.blue / 256); + QColor color = QColor(c.red / 265, c.green / 256, c.blue / 256); + return color; #else - QNativeImage nativeImage(16,16, QNativeImage::systemFormat()); - CGRect cgrect = CGRectMake(0, 0, 16, 16); - HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal); - CGContextFillRect(nativeImage.cg, cgrect); - return QColor(nativeImage.image.pixel(0 , 0)); + // There is no equivalent to GetThemeTextColor in 64-bit and it was rather bad that + // I didn't file a request to implement this for Snow Leopard. So, in the meantime + // I've encoded the values from the GetThemeTextColor. This is not exactly ideal + // as if someone really wants to mess with themeing, these colors will be wrong. + // It also means that we need to make sure the values for differences between + // OS releases (and it will be likely that we are a step behind.) + switch (themeColor) { + case kThemeTextColorAlertActive: + case kThemeTextColorTabFrontActive: + case kThemeTextColorBevelButtonActive: + case kThemeTextColorListView: + case kThemeTextColorPlacardActive: + case kThemeTextColorPopupButtonActive: + case kThemeTextColorPopupLabelActive: + case kThemeTextColorPushButtonActive: + return Qt::black; + case kThemeTextColorAlertInactive: + case kThemeTextColorDialogInactive: + case kThemeTextColorPlacardInactive: + return QColor(67, 69, 69, 255); + case kThemeTextColorPopupButtonInactive: + case kThemeTextColorPopupLabelInactive: + case kThemeTextColorPushButtonInactive: + case kThemeTextColorTabFrontInactive: + case kThemeTextColorBevelButtonInactive: + return QColor(123, 127, 127, 255); + default: { + QNativeImage nativeImage(16,16, QNativeImage::systemFormat()); + CGRect cgrect = CGRectMake(0, 0, 16, 16); + HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal); + CGContextFillRect(nativeImage.cg, cgrect); + QColor color = nativeImage.image.pixel(0,0); + return QColor(nativeImage.image.pixel(0 , 0)); + } + } #endif } QT_END_NAMESPACE -- cgit v0.12 From 638b61dec0d335b12d48fe561b19a0f0f6ef83a3 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 1 Apr 2009 13:04:44 +0200 Subject: QThread::start(): priority has no effect on Linux systems The default scheduling policy on Linux doesn't allow specifying thread priorities, so the priority passed to start() and setPriority() has no effect. Document this. Task number: 249997 Reviewed-by: Kavindra Devi Palaraja --- src/corelib/thread/qthread.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 7f87897..2fb6335 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -297,6 +297,12 @@ void QAdoptedThread::run() priority parameter. If the thread is already running, this function does nothing. + The effect of the \a priority parameter is dependent on the + operating system's scheduling policy. In particular, the \a priority + will be ignored on systems that do not support thread priorities + (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler + for more details). + \sa run(), terminate() */ @@ -590,6 +596,12 @@ void QThread::cleanup() The \a priority argument can be any value in the \c QThread::Priority enum except for \c InheritPriorty. + The effect of the \a priority parameter is dependent on the + operating system's scheduling policy. In particular, the \a priority + will be ignored on systems that do not support thread priorities + (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler + for more details). + \sa Priority priority() start() */ -- cgit v0.12 From b4bfe3456f2979be2befd58d0b33fab668c700e9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 6 Apr 2009 10:42:25 +0200 Subject: Fixes: QTextStream crashes on large inputs The buffer was only shrinked if we reach exactly the end of it. Reviewed-by: Andreas Reviewed-by: Thiago Task-number: 221316 --- src/corelib/io/qtextstream.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index ed9d0aa..73408dc 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -409,6 +409,7 @@ public: QString writeBuffer; QString readBuffer; int readBufferOffset; + int readConverterSavedStateOffset; //the offset between readBufferStartDevicePos and that start of the buffer qint64 readBufferStartDevicePos; // streaming parameters @@ -435,6 +436,7 @@ QTextStreamPrivate::QTextStreamPrivate(QTextStream *q_ptr) #ifndef QT_NO_TEXTCODEC readConverterSavedState(0), #endif + readConverterSavedStateOffset(0), locale(QLocale::C) { this->q_ptr = q_ptr; @@ -833,6 +835,10 @@ inline void QTextStreamPrivate::consume(int size) readBufferOffset = 0; readBuffer.clear(); saveConverterState(device->pos()); + } else if (readBufferOffset > QTEXTSTREAM_BUFFERSIZE) { + readBuffer = readBuffer.remove(0,readBufferOffset); + readConverterSavedStateOffset += readBufferOffset; + readBufferOffset = 0; } } } @@ -854,6 +860,7 @@ inline void QTextStreamPrivate::saveConverterState(qint64 newPos) #endif readBufferStartDevicePos = newPos; + readConverterSavedStateOffset = 0; } /*! \internal @@ -1218,7 +1225,7 @@ qint64 QTextStream::pos() const // Rewind the device to get to the current position Ensure that // readBufferOffset is unaffected by fillReadBuffer() - int oldReadBufferOffset = d->readBufferOffset; + int oldReadBufferOffset = d->readBufferOffset + d->readConverterSavedStateOffset; while (d->readBuffer.size() < oldReadBufferOffset) { if (!thatd->fillReadBuffer(1)) return qint64(-1); -- cgit v0.12 From 66f839869049bc98765bbdd8d1331c7abdf6d5df Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 31 Mar 2009 16:52:06 +0200 Subject: Benchmark for QTableView and spans --- tests/benchmarks/qtableview/qtableview.pro | 6 + tests/benchmarks/qtableview/tst_qtableview.cpp | 193 +++++++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 tests/benchmarks/qtableview/qtableview.pro create mode 100644 tests/benchmarks/qtableview/tst_qtableview.cpp diff --git a/tests/benchmarks/qtableview/qtableview.pro b/tests/benchmarks/qtableview/qtableview.pro new file mode 100644 index 0000000..02bc530 --- /dev/null +++ b/tests/benchmarks/qtableview/qtableview.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qtableview + +SOURCES += tst_qtableview.cpp + diff --git a/tests/benchmarks/qtableview/tst_qtableview.cpp b/tests/benchmarks/qtableview/tst_qtableview.cpp new file mode 100644 index 0000000..5674177 --- /dev/null +++ b/tests/benchmarks/qtableview/tst_qtableview.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +//TESTED_FILES= + +class QtTestTableModel: public QAbstractTableModel +{ + Q_OBJECT + + +public: + QtTestTableModel(int rows = 0, int columns = 0, QObject *parent = 0) + : QAbstractTableModel(parent), + row_count(rows), + column_count(columns) {} + + int rowCount(const QModelIndex& = QModelIndex()) const { return row_count; } + int columnCount(const QModelIndex& = QModelIndex()) const { return column_count; } + bool isEditable(const QModelIndex &) const { return true; } + + QVariant data(const QModelIndex &idx, int role) const + { + if (!idx.isValid() || idx.row() >= row_count || idx.column() >= column_count) { + qWarning() << "Invalid modelIndex [%d,%d,%p]" << idx; + return QVariant(); + } + + if (role == Qt::DisplayRole || role == Qt::EditRole) + return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column()).arg(0); + + return QVariant(); + } + + int row_count; + int column_count; +}; + + + + +class tst_QTableView : public QObject +{ + Q_OBJECT + +public: + tst_QTableView(); + virtual ~tst_QTableView(); + +public slots: + void init(); + void cleanup(); + +private slots: + void spanInit(); + void spanDraw(); + void spanSelectColumn(); + void spanSelectAll(); +private: + static inline void spanInit_helper(QTableView *); +}; + +tst_QTableView::tst_QTableView() +{ +} + +tst_QTableView::~tst_QTableView() +{ +} + +void tst_QTableView::init() +{ +} + +void tst_QTableView::cleanup() +{ +} + +void tst_QTableView::spanInit_helper(QTableView *view) +{ + for (int i=0; i < 40; i++) { + view->setSpan(1+i%2, 1+4*i, 1+i%3, 2); + } + + for (int i=1; i < 40; i++) { + view->setSpan(6 + i*7, 4, 4, 50); + } +} + +void tst_QTableView::spanInit() +{ + QtTestTableModel model(500, 500); + QTableView v; + v.setModel(&model); + + QBENCHMARK { + spanInit_helper(&v); + } +} + +void tst_QTableView::spanDraw() +{ + QtTestTableModel model(500, 500); + QTableView v; + v.setModel(&model); + + spanInit_helper(&v); + v.show(); + v.resize(500,500); + QTest::qWait(30); + + QImage image(500, 500, QImage::Format_ARGB32_Premultiplied); + QPainter painter(&image); + QBENCHMARK { + v.render(&painter); + } +} + +void tst_QTableView::spanSelectAll() +{ + QtTestTableModel model(500, 500); + QTableView v; + v.setModel(&model); + + spanInit_helper(&v); + v.show(); + QTest::qWait(30); + + QBENCHMARK { + v.selectAll(); + } +} + +void tst_QTableView::spanSelectColumn() +{ + QtTestTableModel model(500, 500); + QTableView v; + v.setModel(&model); + + spanInit_helper(&v); + v.show(); + QTest::qWait(30); + + QBENCHMARK { + v.selectColumn(22); + } +} + +QTEST_MAIN(tst_QTableView) +#include "tst_qtableview.moc" -- cgit v0.12 From db8dfc29de6bde8d4a4c65d8d5f7d3d579b859bb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 30 Mar 2009 19:04:16 +0200 Subject: Sppedup QTreeView with spans. Introduce an index to lookup spans in a certain index in a logaritmic time instead of linear. Behaviour change include that it is no longer possible to have spans with height or with of 0 (but this made no sens anyway) Reviewed-by: Marius Bugge Monsen Task-number: 244651 --- src/gui/itemviews/qtableview.cpp | 313 ++++++++++++++++++++----------- src/gui/itemviews/qtableview_p.h | 98 ++++++---- tests/auto/qtableview/tst_qtableview.cpp | 5 +- 3 files changed, 267 insertions(+), 149 deletions(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 6ec79a9..8756dce 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -59,6 +59,138 @@ QT_BEGIN_NAMESPACE +/** \internal + Add a span to the collection. the collection takes the ownership. + */ +void QSpanCollection::addSpan(QSpanCollection::Span *span) +{ + spans.append(span); + Index::iterator it_y = index.lowerBound(-span->top()); + if (it_y == index.end() || it_y.key() != -span->top()) { + //there is no spans that starts with the row in the index, so create a sublist for it. + SubIndex sub_index; + if (it_y != index.end()) { + //the previouslist is the list of spans that sarts _before_ the row of the span. + // and which may intersect this row. + const SubIndex previousList = it_y.value(); + foreach(Span *s, previousList) { + //If a subspans intersect the row, we need to split it into subspans + if(s->bottom() >= span->top()) + sub_index.insert(-s->left(), s); + } + } + it_y = index.insert(-span->top(), sub_index); + //we will insert span to *it_y in the later loop + } + + //insert the span as supspan in all the lists that intesects the span + while(-it_y.key() <= span->bottom()) { + (*it_y).insert(-span->left(), span); + if(it_y == index.begin()) + break; + --it_y; + } +} + + +/** \internal +* Has to be called after the height and width of a span is changed. +* +* old_height is the height before the change +* +* if the size of the span is now 0x0 the span will be deleted. +*/ +void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height) +{ + if (old_height < span->height()) { + //add the span as subspan in all the lists that intersect the new covered columns + Index::iterator it_y = index.lowerBound(-(span->top() + old_height - 1)); + Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list + while (-it_y.key() <= span->bottom()) { + (*it_y).insert(-span->left(), span); + if(it_y == index.begin()) + break; + --it_y; + } + } else if (old_height > span->height()) { + //remove the span from all the subspans lists that intersect the columns not covered anymore + Index::iterator it_y = index.lowerBound(-span->bottom()); + Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list + while (-it_y.key() <= span->top() + old_height -1) { + if(-it_y.key() != span->bottom()) { + (*it_y).remove(-span->left()); + if (it_y->isEmpty()) { + it_y = index.erase(it_y) - 1; + } + } + if(it_y == index.begin()) + break; + --it_y; + } + } + + if (span->width() == 0 && span->height() == 0) { + spans.removeOne(span); + delete span; + } +} + +/** \internal + * \return a spans that spans over cell x,y (column,row) or 0 if there is none. + */ +QSpanCollection::Span *QSpanCollection::spanAt(int x, int y) const +{ + Index::const_iterator it_y = index.lowerBound(-y); + if (it_y == index.end()) + return 0; + SubIndex::const_iterator it_x = (*it_y).lowerBound(-x); + if (it_x == (*it_y).end()) + return 0; + Span *span = *it_x; + if (span->right() >= x && span->bottom() >= y) + return span; + return 0; +} + + +/** \internal +* remove and deletes all spans inside the collection +*/ +void QSpanCollection::clear() +{ + qDeleteAll(spans); + index.clear(); + spans.clear(); +} + +/** \internal + * return a list to all the spans that spans over cells in the given rectangle + */ +QList QSpanCollection::spansInRect(int x, int y, int w, int h) const +{ + QSet list; + Index::const_iterator it_y = index.lowerBound(-y); + if(it_y == index.end()) + --it_y; + while(-it_y.key() <= y + h) { + SubIndex::const_iterator it_x = (*it_y).lowerBound(-x); + if (it_x == (*it_y).end()) + --it_x; + while(-it_x.key() <= x + w) { + Span *s = *it_x; + if (s->bottom() >= y && s->right() >= x) + list << s; + if (it_x == (*it_y).begin()) + break; + --it_x; + } + if(it_y == index.begin()) + break; + --it_y; + } + return list.toList(); +} + class QTableCornerButton : public QAbstractButton { Q_OBJECT @@ -149,35 +281,40 @@ void QTableViewPrivate::trimHiddenSelections(QItemSelectionRange *range) const */ void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan) { - if (row < 0 || column < 0 || rowSpan < 0 || columnSpan < 0) + if (row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0) { + qWarning() << "QTableView::setSpan: invalid span given: (" << row << "," << column << "," << rowSpan << "," << columnSpan << ")"; return; - Span sp(row, column, rowSpan, columnSpan); - QList::iterator it; - for (it = spans.begin(); it != spans.end(); ++it) { - if (((*it).top() == sp.top()) && ((*it).left() == sp.left())) { - if ((sp.height() == 1) && (sp.width() == 1)) - spans.erase(it); // "Implicit" span (1, 1), no need to store it - else - *it = sp; // Replace + } + QSpanCollection::Span *sp = spans.spanAt(column, row); + if (sp) { + if (sp->top() != row || sp->left() != column) { + qWarning() << "QTableView::setSpan: span cannot overlap"; return; } + if (rowSpan == 1 && columnSpan == 1) { + rowSpan = columnSpan = 0; + } + const int old_height = sp->height(); + sp->m_bottom = row + rowSpan - 1; + sp->m_right = column + columnSpan - 1; + spans.updateSpan(sp, old_height); + return; } - spans.append(sp); + sp = new QSpanCollection::Span(row, column, rowSpan, columnSpan); + spans.addSpan(sp); } /*! \internal Gets the span information for the cell at (\a row, \a column). */ -QTableViewPrivate::Span QTableViewPrivate::span(int row, int column) const +QSpanCollection::Span QTableViewPrivate::span(int row, int column) const { - QList::const_iterator it; - for (it = spans.constBegin(); it != spans.constEnd(); ++it) { - Span span = *it; - if (isInSpan(row, column, span)) - return span; - } - return Span(row, column, 1, 1); + QSpanCollection::Span *sp = spans.spanAt(column, row); + if (sp) + return *sp; + + return QSpanCollection::Span(row, column, 1, 1); } /*! @@ -233,67 +370,9 @@ bool QTableViewPrivate::spanContainsSection(const QHeaderView *header, int logic /*! \internal - Returns true if one or more spans intersect column \a column. -*/ -bool QTableViewPrivate::spansIntersectColumn(int column) const -{ - QList::const_iterator it; - for (it = spans.constBegin(); it != spans.constEnd(); ++it) { - Span span = *it; - if (spanContainsColumn(column, span.left(), span.width())) - return true; - } - return false; -} - -/*! - \internal - Returns true if one or more spans intersect row \a row. -*/ -bool QTableViewPrivate::spansIntersectRow(int row) const -{ - QList::const_iterator it; - for (it = spans.constBegin(); it != spans.constEnd(); ++it) { - Span span = *it; - if (spanContainsRow(row, span.top(), span.height())) - return true; - } - return false; -} - -/*! - \internal - Returns true if one or more spans intersect one or more columns. -*/ -bool QTableViewPrivate::spansIntersectColumns(const QList &columns) const -{ - QList::const_iterator it; - for (it = columns.constBegin(); it != columns.constEnd(); ++it) { - if (spansIntersectColumn(*it)) - return true; - } - return false; -} - -/*! - \internal - Returns true if one or more spans intersect one or more rows. -*/ -bool QTableViewPrivate::spansIntersectRows(const QList &rows) const -{ - QList::const_iterator it; - for (it = rows.constBegin(); it != rows.constEnd(); ++it) { - if (spansIntersectRow(*it)) - return true; - } - return false; -} - -/*! - \internal Returns the visual rect for the given \a span. */ -QRect QTableViewPrivate::visualSpanRect(const Span &span) const +QRect QTableViewPrivate::visualSpanRect(const QSpanCollection::Span &span) const { Q_Q(const QTableView); // vertical @@ -319,42 +398,54 @@ QRect QTableViewPrivate::visualSpanRect(const Span &span) const preparation for the main drawing loop. \a drawn is a QBitArray of visualRowCountxvisualCoulumnCount which say if particular cell has been drawn */ -void QTableViewPrivate::drawAndClipSpans(const QRect &area, QPainter *painter, +void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter, const QStyleOptionViewItemV4 &option, QBitArray *drawn, int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn) { bool alternateBase = false; QRegion region = viewport->rect(); - QList::const_iterator it; - for (it = spans.constBegin(); it != spans.constEnd(); ++it) { - Span span = *it; + QList visibleSpans; + bool sectionMoved = verticalHeader->sectionsMoved() || horizontalHeader->sectionsMoved(); - int row = span.top(); - int col = span.left(); + if (!sectionMoved) { + visibleSpans = spans.spansInRect(logicalColumn(firstVisualColumn), logicalRow(firstVisualRow), + lastVisualColumn - firstVisualColumn + 1, lastVisualRow - firstVisualRow + 1); + } else { + QSet set; + for(int x = firstVisualColumn; x <= lastVisualColumn; x++) + for(int y = firstVisualRow; y <= lastVisualRow; y++) + set.insert(spans.spanAt(x,y)); + set.remove(0); + visibleSpans = set.toList(); + } + + foreach (QSpanCollection::Span *span, visibleSpans) { + int row = span->top(); + int col = span->left(); if (isHidden(row, col)) continue; QModelIndex index = model->index(row, col, root); if (!index.isValid()) continue; - QRect rect = visualSpanRect(span); + QRect rect = visualSpanRect(*span); rect.translate(scrollDelayOffset); - if (!rect.intersects(area)) + if (!area.intersects(rect)) continue; QStyleOptionViewItemV4 opt = option; opt.rect = rect; - alternateBase = alternatingColors && (span.top() & 1); + alternateBase = alternatingColors && (span->top() & 1); if (alternateBase) opt.features |= QStyleOptionViewItemV2::Alternate; else opt.features &= ~QStyleOptionViewItemV2::Alternate; drawCell(painter, opt, index); region -= rect; - for (int r = span.top(); r <= span.bottom(); ++r) { + for (int r = span->top(); r <= span->bottom(); ++r) { const int vr = visualRow(r); if (vr < firstVisualRow || vr > lastVisualRow) continue; - for (int c = span.left(); c <= span.right(); ++c) { + for (int c = span->left(); c <= span->right(); ++c) { const int vc = visualColumn(c); if (vc < firstVisualColumn || vc > lastVisualColumn) continue; @@ -753,7 +844,8 @@ void QTableView::paintEvent(QPaintEvent *event) uint x = horizontalHeader->length() - horizontalHeader->offset() - (rightToLeft ? 0 : 1); uint y = verticalHeader->length() - verticalHeader->offset() - 1; - QVector rects = event->region().rects(); + const QRegion region = event->region().translated(offset); + const QVector rects = region.rects(); //firstVisualRow is the visual index of the first visible row. lastVisualRow is the visual index of the last visible Row. //same goes for ...VisualColumn @@ -773,9 +865,13 @@ void QTableView::paintEvent(QPaintEvent *event) QBitArray drawn((lastVisualRow - firstVisualRow + 1) * (lastVisualColumn - firstVisualColumn + 1)); + if (d->hasSpans()) { + d->drawAndClipSpans(region, &painter, option, &drawn, + firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn); + } + for (int i = 0; i < rects.size(); ++i) { QRect dirtyArea = rects.at(i); - dirtyArea.translate(offset); dirtyArea.setBottom(qMin(dirtyArea.bottom(), int(y))); if (rightToLeft) { dirtyArea.setLeft(qMax(dirtyArea.left(), d->viewport->width() - int(x))); @@ -783,10 +879,6 @@ void QTableView::paintEvent(QPaintEvent *event) dirtyArea.setRight(qMin(dirtyArea.right(), int(x))); } - if (d->hasSpans()) - d->drawAndClipSpans(dirtyArea, &painter, option, &drawn, - firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn); - // get the horizontal start and end visual sections int left = horizontalHeader->visualIndexAt(dirtyArea.left()); int right = horizontalHeader->visualIndexAt(dirtyArea.right()); @@ -913,7 +1005,7 @@ QModelIndex QTableView::indexAt(const QPoint &pos) const int c = columnAt(pos.x()); if (r >= 0 && c >= 0) { if (d->hasSpans()) { - QTableViewPrivate::Span span = d->span(r, c); + QSpanCollection::Span span = d->span(r, c); r = span.top(); c = span.left(); } @@ -1011,14 +1103,14 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi --visualRow; if (d->hasSpans()) { int row = d->logicalRow(visualRow); - QTableViewPrivate::Span span = d->span(row, current.column()); + QSpanCollection::Span span = d->span(row, current.column()); visualRow = d->visualRow(span.top()); visualColumn = d->visualColumn(span.left()); } break; case MoveDown: if (d->hasSpans()) { - QTableViewPrivate::Span span = d->span(current.row(), current.column()); + QSpanCollection::Span span = d->span(current.row(), current.column()); visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); } #ifdef QT_KEYPAD_NAVIGATION @@ -1030,7 +1122,7 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi ++visualRow; if (d->hasSpans()) { int row = d->logicalRow(visualRow); - QTableViewPrivate::Span span = d->span(row, current.column()); + QSpanCollection::Span span = d->span(row, current.column()); visualColumn = d->visualColumn(span.left()); } break; @@ -1058,7 +1150,7 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi --visualColumn; if (d->hasSpans()) { int column = d->logicalColumn(visualColumn); - QTableViewPrivate::Span span = d->span(current.row(), column); + QSpanCollection::Span span = d->span(current.row(), column); visualRow = d->visualRow(span.top()); visualColumn = d->visualColumn(span.left()); } @@ -1078,7 +1170,7 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi } // else MoveRight case MoveRight: if (d->hasSpans()) { - QTableViewPrivate::Span span = d->span(current.row(), current.column()); + QSpanCollection::Span span = d->span(current.row(), current.column()); visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width())); } ++visualColumn; @@ -1086,7 +1178,7 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi ++visualColumn; if (d->hasSpans()) { int column = d->logicalColumn(visualColumn); - QTableViewPrivate::Span span = d->span(current.row(), column); + QSpanCollection::Span span = d->span(current.row(), column); visualRow = d->visualRow(span.top()); } break; @@ -1161,9 +1253,8 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF int right = qMax(d->visualColumn(tl.column()), d->visualColumn(br.column())); do { expanded = false; - QList::const_iterator it; - for (it = d->spans.constBegin(); it != d->spans.constEnd(); ++it) { - QTableViewPrivate::Span span = *it; + foreach (QSpanCollection::Span *it, d->spans.spans) { + const QSpanCollection::Span &span = *it; int t = d->visualRow(span.top()); int l = d->visualColumn(span.left()); int b = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); @@ -1874,7 +1965,7 @@ QRect QTableView::visualRect(const QModelIndex &index) const d->executePostedLayout(); if (d->hasSpans()) { - QTableViewPrivate::Span span = d->span(index.row(), index.column()); + QSpanCollection::Span span = d->span(index.row(), index.column()); return d->visualSpanRect(span); } @@ -1903,7 +1994,7 @@ void QTableView::scrollTo(const QModelIndex &index, ScrollHint hint) || isIndexHidden(index)) return; - QTableViewPrivate::Span span; + QSpanCollection::Span span; if (d->hasSpans()) span = d->span(index.row(), index.column()); @@ -2058,7 +2149,7 @@ void QTableView::timerEvent(QTimerEvent *event) QRect rect; int viewportHeight = d->viewport->height(); int viewportWidth = d->viewport->width(); - if (d->hasSpans() && d->spansIntersectColumns(d->columnsToUpdate)) { + if (d->hasSpans()) { rect = QRect(0, 0, viewportWidth, viewportHeight); } else { for (int i = d->columnsToUpdate.size()-1; i >= 0; --i) { @@ -2083,7 +2174,7 @@ void QTableView::timerEvent(QTimerEvent *event) int viewportHeight = d->viewport->height(); int viewportWidth = d->viewport->width(); int top; - if (d->hasSpans() && d->spansIntersectRows(d->rowsToUpdate)) { + if (d->hasSpans()) { top = 0; } else { top = viewportHeight; @@ -2114,7 +2205,7 @@ void QTableView::rowMoved(int, int oldIndex, int newIndex) updateGeometries(); int logicalOldIndex = d->verticalHeader->logicalIndex(oldIndex); int logicalNewIndex = d->verticalHeader->logicalIndex(newIndex); - if (d->hasSpans() && (d->spansIntersectRow(logicalOldIndex) || d->spansIntersectRow(logicalNewIndex))) { + if (d->hasSpans()) { d->viewport->update(); } else { int oldTop = rowViewportPosition(logicalOldIndex); @@ -2142,7 +2233,7 @@ void QTableView::columnMoved(int, int oldIndex, int newIndex) updateGeometries(); int logicalOldIndex = d->horizontalHeader->logicalIndex(oldIndex); int logicalNewIndex = d->horizontalHeader->logicalIndex(newIndex); - if (d->hasSpans() && (d->spansIntersectColumn(logicalOldIndex) || d->spansIntersectColumn(logicalNewIndex))) { + if (d->hasSpans()) { d->viewport->update(); } else { int oldLeft = columnViewportPosition(logicalOldIndex); @@ -2325,7 +2416,7 @@ bool QTableView::isIndexHidden(const QModelIndex &index) const if (isRowHidden(index.row()) || isColumnHidden(index.column())) return true; if (d->hasSpans()) { - QTableViewPrivate::Span span = d->span(index.row(), index.column()); + QSpanCollection::Span span = d->span(index.row(), index.column()); return !((span.top() == index.row()) && (span.left() == index.column())); } return false; diff --git a/src/gui/itemviews/qtableview_p.h b/src/gui/itemviews/qtableview_p.h index b08eabd..3f3dd36 100644 --- a/src/gui/itemviews/qtableview_p.h +++ b/src/gui/itemviews/qtableview_p.h @@ -53,12 +53,69 @@ // We mean it. // +#include +#include +#include +#include #include "private/qabstractitemview_p.h" #ifndef QT_NO_TABLEVIEW QT_BEGIN_NAMESPACE +/** \internal +* +* This is a list of span with a binary index to look up quickly a span at a certain index. +* +* The index is a map of map. +* spans are mentaly divided into sub spans so that the start of any subspans doesn't overlap +* with any other subspans. There is no real representation of the subspans. +* The key of the first map is the row where the subspan starts, the value of the first map is +* a list (map) of all subspans that starts at the same row. It is indexed with its row +*/ +class QSpanCollection +{ +public: + struct Span + { + int m_top; + int m_left; + int m_bottom; + int m_right; + Span() + : m_top(-1), m_left(-1), m_bottom(-1), m_right(-1) { } + Span(int row, int column, int rowCount, int columnCount) + : m_top(row), m_left(column), m_bottom(row+rowCount-1), m_right(column+columnCount-1) { } + inline int top() const { return m_top; } + inline int left() const { return m_left; } + inline int bottom() const { return m_bottom; } + inline int right() const { return m_right; } + inline int height() const { return m_bottom - m_top + 1; } + inline int width() const { return m_right - m_left + 1; } + }; + + ~QSpanCollection() + { + qDeleteAll(spans); + } + + void addSpan(Span *span); + void updateSpan(Span *span, int old_height); + Span *spanAt(int x, int y) const; + void clear(); + QList spansInRect(int x, int y, int w, int h) const; + + QList spans; //lists of all spans +private: + //the indexes are negative so the QMap::lowerBound do what i need. + typedef QMap SubIndex; + typedef QMap Index; + Index index; +}; + +Q_DECLARE_TYPEINFO ( QSpanCollection::Span, Q_MOVABLE_TYPE); + + class QTableViewPrivate : public QAbstractItemViewPrivate { Q_DECLARE_PUBLIC(QTableView) @@ -98,11 +155,7 @@ public: int sectionSpanEndLogical(const QHeaderView *header, int logical, int span) const; int sectionSpanSize(const QHeaderView *header, int logical, int span) const; bool spanContainsSection(const QHeaderView *header, int logical, int spanLogical, int span) const; - bool spansIntersectColumn(int column) const; - bool spansIntersectRow(int row) const; - bool spansIntersectColumns(const QList &columns) const; - bool spansIntersectRows(const QList &rows) const; - void drawAndClipSpans(const QRect &area, QPainter *painter, + void drawAndClipSpans(const QRegion &area, QPainter *painter, const QStyleOptionViewItemV4 &option, QBitArray *drawn, int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn); void drawCell(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index); @@ -121,27 +174,10 @@ public: bool sortingEnabled; bool geometryRecursionBlock; - struct Span - { - int m_top; - int m_left; - int m_bottom; - int m_right; - Span() - : m_top(-1), m_left(-1), m_bottom(-1), m_right(-1) { } - Span(int row, int column, int rowCount, int columnCount) - : m_top(row), m_left(column), m_bottom(row+rowCount-1), m_right(column+columnCount-1) { } - inline int top() const { return m_top; } - inline int left() const { return m_left; } - inline int bottom() const { return m_bottom; } - inline int right() const { return m_right; } - inline int height() const { return m_bottom - m_top + 1; } - inline int width() const { return m_right - m_left + 1; } - }; - QList spans; + QSpanCollection spans; void setSpan(int row, int column, int rowSpan, int columnSpan); - Span span(int row, int column) const; + QSpanCollection::Span span(int row, int column) const; inline int rowSpan(int row, int column) const { return span(row, column).height(); } @@ -149,17 +185,7 @@ public: return span(row, column).width(); } inline bool hasSpans() const { - return !spans.isEmpty(); - } - inline bool spanContainsRow(int row, int spanRow, int span) const { - return spanContainsSection(verticalHeader, row, spanRow, span); - } - inline bool spanContainsColumn(int column, int spanColumn, int span) const { - return spanContainsSection(horizontalHeader, column, spanColumn, span); - } - inline bool isInSpan(int row, int column, const Span &span) const { - return spanContainsRow(row, span.top(), span.height()) - && spanContainsColumn(column, span.left(), span.width()); + return !spans.spans.isEmpty(); } inline int rowSpanHeight(int row, int span) const { return sectionSpanSize(verticalHeader, row, span); @@ -194,7 +220,7 @@ public: return isColumnHidden(c) || !isCellEnabled(r, c); } - QRect visualSpanRect(const Span &span) const; + QRect visualSpanRect(const QSpanCollection::Span &span) const; void _q_selectRow(int row); void _q_selectColumn(int column); diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index a9b41d8..9595155 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -2540,6 +2540,7 @@ void tst_QTableView::span_data() << 2 << 1 << false; + /* This makes no sens. QTest::newRow("top left 2x0") << 10 << 10 << -1 << -1 @@ -2554,7 +2555,7 @@ void tst_QTableView::span_data() << 0 << 0 << 0 << 2 << 0 << 2 - << false; + << false;*/ QTest::newRow("invalid 2x2") << 10 << 10 @@ -2628,7 +2629,7 @@ void tst_QTableView::span() view.hideRow(hiddenRow); view.hideColumn(hiddenColumn); view.show(); - + QCOMPARE(view.rowSpan(row, column), expectedRowSpan); QCOMPARE(view.columnSpan(row, column), expectedColumnSpan); -- cgit v0.12 From 718905c097a7f3bbf9805a2561cd855a0b2d8f59 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 31 Mar 2009 19:43:43 +0200 Subject: Speed up selectAll in QTreeView with spans When we had spans, in order to have the selection rect, we took the slow path in all cases, even if the header section did not move. Now, take the fast path if the sections did not move. This requires few adjustement to the code: we cannot call visualRect anymore since the index may be within a span. Task-number: 244651 Reviewed-by: Marius Bugge Monsen --- src/gui/itemviews/qtableview.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 8756dce..757ecf2 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -1344,7 +1344,7 @@ QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) co bool verticalMoved = verticalHeader()->sectionsMoved(); bool horizontalMoved = horizontalHeader()->sectionsMoved(); - if ((verticalMoved && horizontalMoved) || d->hasSpans()) { + if ((verticalMoved && horizontalMoved) || (d->hasSpans() && (verticalMoved || horizontalMoved))) { for (int i = 0; i < selection.count(); ++i) { QItemSelectionRange range = selection.at(i); if (range.parent() != d->root || !range.isValid()) @@ -1387,9 +1387,19 @@ QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) co if (range.parent() != d->root || !range.isValid()) continue; d->trimHiddenSelections(&range); - QRect tl = visualRect(range.topLeft()); - QRect br = visualRect(range.bottomRight()); - selectionRegion += QRegion(tl|br); + + const int rtop = rowViewportPosition(range.top()); + const int rbottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom()); + const int rleft = columnViewportPosition(range.left()); + const int rright = columnViewportPosition(range.right()) + columnWidth(range.right()); + selectionRegion += QRect(QPoint(rleft, rtop), QPoint(rright, rbottom)); + if (d->hasSpans()) { + foreach (QSpanCollection::Span *s, + d->spans.spansInRect(range.left(), range.top(), range.width(), range.height())) { + if (range.contains(s->top(), s->left(), range.parent())) + selectionRegion += d->visualSpanRect(*s); + } + } } } -- cgit v0.12 From b67938a45ae548de42773a735d9284848ac46d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 6 Apr 2009 11:30:24 +0200 Subject: Add missing license headers. --- examples/graphicsview/flowlayout/flowlayout.cpp | 43 ++++++++++++++++++++++++- examples/graphicsview/flowlayout/flowlayout.h | 41 +++++++++++++++++++++++ examples/graphicsview/flowlayout/main.cpp | 43 ++++++++++++++++++++++++- examples/graphicsview/flowlayout/window.cpp | 43 ++++++++++++++++++++++++- examples/graphicsview/flowlayout/window.h | 43 ++++++++++++++++++++++++- 5 files changed, 209 insertions(+), 4 deletions(-) diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp index d1676bc..9bbe8a4 100644 --- a/examples/graphicsview/flowlayout/flowlayout.cpp +++ b/examples/graphicsview/flowlayout/flowlayout.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "flowlayout.h" #include #include @@ -106,7 +147,7 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const foreach (item, m_items) size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize)); size += QSize(left + right, top + bottom); - } + } return size; } diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h index ab3d33b..a78a83a 100644 --- a/examples/graphicsview/flowlayout/flowlayout.h +++ b/examples/graphicsview/flowlayout/flowlayout.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include class FlowLayout : public QGraphicsLayout diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp index a7af2d4..d1a40c7 100644 --- a/examples/graphicsview/flowlayout/main.cpp +++ b/examples/graphicsview/flowlayout/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include "window.h" @@ -11,4 +52,4 @@ int main(int argc, char **argv) scene.addItem(w); view->show(); return app.exec(); -} \ No newline at end of file +} diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp index b632bc9..f14066e 100644 --- a/examples/graphicsview/flowlayout/window.cpp +++ b/examples/graphicsview/flowlayout/window.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include #include "flowlayout.h" @@ -17,4 +58,4 @@ Window::Window() lay->addItem(proxy); } setLayout(lay); -} \ No newline at end of file +} diff --git a/examples/graphicsview/flowlayout/window.h b/examples/graphicsview/flowlayout/window.h index 50dac92..6d315f5 100644 --- a/examples/graphicsview/flowlayout/window.h +++ b/examples/graphicsview/flowlayout/window.h @@ -1,7 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include class Window : public QGraphicsWidget { Q_OBJECT public: Window(); -}; \ No newline at end of file +}; -- cgit v0.12 From 1e32cdefa382b16eaffc663594ccab1dbe1faebb Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 6 Apr 2009 11:30:45 +0200 Subject: BT: Fix a crash when running a widget window modal when it has no parent We changed the logic for determining sheets, but it seems we forgot to take the parentWidget() into account. It's required for WindowModality to make any sense. Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwidget_mac.mm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 7a586e1..f2a532f 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -295,9 +295,7 @@ bool qt_mac_is_macsheet(const QWidget *w) Qt::WindowModality modality = w->windowModality(); if (modality == Qt::ApplicationModal) return false; - if (modality == Qt::WindowModal || w->windowType() == Qt::Sheet) - return true; - return false; + return w->parentWidget() && (modality == Qt::WindowModal || w->windowType() == Qt::Sheet); } bool qt_mac_is_macdrawer(const QWidget *w) @@ -4583,11 +4581,11 @@ void QWidgetPrivate::setModal_sys() OSWindowRef windowRef = qt_mac_window_for(q); #ifdef QT_MAC_USE_COCOA - bool windowIsSheet = [windowRef styleMask] & NSDocModalWindowMask; + bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask; - if (q->windowModality() == Qt::WindowModal){ + if (windowParent && q->windowModality() == Qt::WindowModal){ // Window should be window-modal, which implies a sheet. - if (!windowIsSheet) + if (!alreadySheet) recreateMacWindow(); if ([windowRef isKindOfClass:[NSPanel class]]){ // If the primary window of the sheet parent is a child of a modal dialog, @@ -4601,7 +4599,7 @@ void QWidgetPrivate::setModal_sys() } } else { // Window shold not be window-modal, and as such, not a sheet. - if (windowIsSheet){ + if (alreadySheet){ // NB: the following call will call setModal_sys recursivly: recreateMacWindow(); windowRef = qt_mac_window_for(q); -- cgit v0.12 From 73cffd26dcfbfee48caf86329d636361d02e5c03 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 6 Apr 2009 10:38:54 +0200 Subject: Fix moc autotest failures We have to pass the correct include paths when testing the multiple inheritance warning, because we want moc to find the QtGui and QObject headers. In addition we have to adjust the line numbers and include QObject in the qobject test to avoid a warning about the unknown QObject superclass. Reviewed-by: Bradley T. Hughes --- tests/auto/moc/forgotten-qinterface.h | 2 ++ tests/auto/moc/tst_moc.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/auto/moc/forgotten-qinterface.h b/tests/auto/moc/forgotten-qinterface.h index a11793b..370a3d0 100644 --- a/tests/auto/moc/forgotten-qinterface.h +++ b/tests/auto/moc/forgotten-qinterface.h @@ -39,6 +39,8 @@ ** ****************************************************************************/ +#include + struct MyInterface { virtual ~MyInterface() {} diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index 39f4f23..1499536 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -851,7 +851,10 @@ void tst_Moc::warnOnMultipleInheritance() QVERIFY(!qgetenv("QTDIR").isNull()); QProcess proc; - proc.start("moc", QStringList(srcify("warn-on-multiple-qobject-subclasses.h"))); + QStringList args; + args << "-I" << qgetenv("QTDIR") + "/include/QtGui" + << srcify("warn-on-multiple-qobject-subclasses.h"); + proc.start("moc", args); QVERIFY(proc.waitForFinished()); QCOMPARE(proc.exitCode(), 0); QByteArray mocOut = proc.readAllStandardOutput(); @@ -873,14 +876,17 @@ void tst_Moc::forgottenQInterface() QVERIFY(!qgetenv("QTDIR").isNull()); QProcess proc; - proc.start("moc", QStringList(srcify("forgotten-qinterface.h"))); + QStringList args; + args << "-I" << qgetenv("QTDIR") + "/include/QtCore" + << srcify("forgotten-qinterface.h"); + proc.start("moc", args); QVERIFY(proc.waitForFinished()); QCOMPARE(proc.exitCode(), 0); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError()); QCOMPARE(mocWarning, QString(SRCDIR) + - QString("/forgotten-qinterface.h:53: Warning: Class Test implements the interface MyInterface but does not list it in Q_INTERFACES. qobject_cast to MyInterface will not work!\n")); + QString("/forgotten-qinterface.h:55: Warning: Class Test implements the interface MyInterface but does not list it in Q_INTERFACES. qobject_cast to MyInterface will not work!\n")); #else QSKIP("Only tested on linux/gcc", SkipAll); #endif -- cgit v0.12 From 10ba12c7b73b89761a43a450c2932c8a56bf64db Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 6 Apr 2009 10:58:51 +0200 Subject: Moc autotest cleanup Remove unused QTDIR tests. Reviewed-by: Bradley T. Hughes --- tests/auto/moc/tst_moc.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index 1499536..4d31dfc 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -584,8 +584,6 @@ void tst_Moc::warnOnExtraSignalSlotQualifiaction() QSKIP("Not tested when cross-compiled", SkipAll); #endif #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) - QVERIFY(!qgetenv("QTDIR").isNull()); - QProcess proc; proc.start("moc", QStringList(srcify("extraqualification.h"))); QVERIFY(proc.waitForFinished()); @@ -630,8 +628,6 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() QSKIP("Not tested when cross-compiled", SkipAll); #endif #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) - QVERIFY(!qgetenv("QTDIR").isNull()); - QProcess proc; proc.setWorkingDirectory(QString(SRCDIR) + "/task71021"); proc.start("moc", QStringList("../Header")); @@ -957,8 +953,6 @@ void tst_Moc::frameworkSearchPath() QSKIP("Not tested when cross-compiled", SkipAll); #endif #if defined(Q_OS_UNIX) - QVERIFY(!qgetenv("QTDIR").isNull()); - QStringList args; args << "-F" << srcify(".") << srcify("interface-from-framework.h") @@ -997,8 +991,6 @@ void tst_Moc::templateGtGt() QSKIP("Not tested when cross-compiled", SkipAll); #endif #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) - QVERIFY(!qgetenv("QTDIR").isNull()); - QProcess proc; proc.start("moc", QStringList(srcify("template-gtgt.h"))); QVERIFY(proc.waitForFinished()); @@ -1015,8 +1007,6 @@ void tst_Moc::templateGtGt() void tst_Moc::defineMacroViaCmdline() { #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) - QVERIFY(!qgetenv("QTDIR").isNull()); - QProcess proc; QStringList args; @@ -1105,8 +1095,6 @@ void tst_Moc::warnOnPropertyWithoutREAD() QSKIP("Not tested when cross-compiled", SkipAll); #endif #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) - QVERIFY(!qgetenv("QTDIR").isNull()); - QProcess proc; proc.start("moc", QStringList(srcify("warn-on-property-without-read.h"))); QVERIFY(proc.waitForFinished()); -- cgit v0.12 From d071b3528f51aaded18029f2f22e8db03e47a2a6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 6 Apr 2009 11:00:05 +0200 Subject: Remove QTDIR dependency from moc autotest Use qmake -query QT_INSTALL_HEADERS at test startup time instead of relying on the dead QTDIR environment variable. Reviewed-by: Bradley T. Hughes --- tests/auto/moc/tst_moc.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index 4d31dfc..4e4f6e7 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -466,6 +466,8 @@ public: inline tst_Moc() {} private slots: + void initTestCase(); + void slotWithException() throw(MyStruct); void dontStripNamespaces(); void oldStyleCasts(); @@ -519,8 +521,28 @@ private: bool user2() { return false; }; bool user3() { return false; }; bool userFunction(){ return false; }; + +private: + QString qtIncludePath; }; +void tst_Moc::initTestCase() +{ +#if defined(Q_OS_UNIX) + QProcess proc; + proc.start("qmake", QStringList() << "-query" << "QT_INSTALL_HEADERS"); + QVERIFY(proc.waitForFinished()); + QCOMPARE(proc.exitCode(), 0); + QByteArray output = proc.readAllStandardOutput(); + QVERIFY(!output.isEmpty()); + QCOMPARE(proc.readAllStandardError(), QByteArray()); + qtIncludePath = QString::fromLocal8Bit(output).trimmed(); + QFileInfo fi(qtIncludePath); + QVERIFY(fi.exists()); + QVERIFY(fi.isDir()); +#endif +} + void tst_Moc::slotWithException() throw(MyStruct) { // be happy @@ -552,8 +574,6 @@ void tst_Moc::oldStyleCasts() QSKIP("Not tested when cross-compiled", SkipAll); #endif #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) - QVERIFY(!qgetenv("QTDIR").isNull()); - QProcess proc; proc.start("moc", QStringList(srcify("/oldstyle-casts.h"))); QVERIFY(proc.waitForFinished()); @@ -564,7 +584,7 @@ void tst_Moc::oldStyleCasts() QStringList args; args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "." - << "-I" << qgetenv("QTDIR") + "/include" << "-o" << "/dev/null" << "-"; + << "-I" << qtIncludePath << "-o" << "/dev/null" << "-"; proc.start("gcc", args); QVERIFY(proc.waitForStarted()); proc.write(mocOut); @@ -639,7 +659,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() QStringList args; args << "-c" << "-x" << "c++" << "-I" << ".." - << "-I" << qgetenv("QTDIR") + "/include" << "-o" << "/dev/null" << "-"; + << "-I" << qtIncludePath << "-o" << "/dev/null" << "-"; proc.start("gcc", args); QVERIFY(proc.waitForStarted()); proc.write(mocOut); @@ -844,11 +864,9 @@ void tst_Moc::warnOnMultipleInheritance() QSKIP("Not tested when cross-compiled", SkipAll); #endif #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) - QVERIFY(!qgetenv("QTDIR").isNull()); - QProcess proc; QStringList args; - args << "-I" << qgetenv("QTDIR") + "/include/QtGui" + args << "-I" << qtIncludePath + "/QtGui" << srcify("warn-on-multiple-qobject-subclasses.h"); proc.start("moc", args); QVERIFY(proc.waitForFinished()); @@ -869,11 +887,9 @@ void tst_Moc::forgottenQInterface() QSKIP("Not tested when cross-compiled", SkipAll); #endif #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) - QVERIFY(!qgetenv("QTDIR").isNull()); - QProcess proc; QStringList args; - args << "-I" << qgetenv("QTDIR") + "/include/QtCore" + args << "-I" << qtIncludePath + "/QtCore" << srcify("forgotten-qinterface.h"); proc.start("moc", args); QVERIFY(proc.waitForFinished()); -- cgit v0.12 From cf42b485ebc1ab3e1f0a804b8c4e404fa99f1f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 6 Apr 2009 14:13:39 +0200 Subject: Fix a small bugs in the example. +two small cleanups. --- examples/graphicsview/flowlayout/flowlayout.cpp | 6 +++--- examples/graphicsview/flowlayout/flowlayout.h | 2 +- examples/graphicsview/flowlayout/window.cpp | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp index 9bbe8a4..d36c37f 100644 --- a/examples/graphicsview/flowlayout/flowlayout.cpp +++ b/examples/graphicsview/flowlayout/flowlayout.cpp @@ -74,6 +74,7 @@ QGraphicsLayoutItem *FlowLayout::itemAt(int index) const void FlowLayout::removeAt(int index) { m_items.removeAt(index); + invalidate(); } qreal FlowLayout::spacing(Qt::Orientation o) const @@ -95,7 +96,7 @@ void FlowLayout::setGeometry(const QRectF &geom) doLayout(geom, true); } -qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) +qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const { QPointF tl = geom.topLeft(); qreal maxw = geom.width(); @@ -139,8 +140,7 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const qreal left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); if (constraint.width() > 0) { // height for width - FlowLayout *that = const_cast(this); - qreal height = that->doLayout(QRectF(QPointF(0,0), constraint), false); + qreal height = doLayout(QRectF(QPointF(0,0), constraint), false); size = QSizeF(constraint.width(), height); } else { QGraphicsLayoutItem *item; diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h index a78a83a..c1e5635 100644 --- a/examples/graphicsview/flowlayout/flowlayout.h +++ b/examples/graphicsview/flowlayout/flowlayout.h @@ -61,7 +61,7 @@ protected: QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; private: - qreal doLayout(const QRectF &geom, bool applyNewGeometry); + qreal doLayout(const QRectF &geom, bool applyNewGeometry) const; QSizeF minSize(const QSizeF &constraint) const; QSizeF prefSize() const; QSizeF maxSize() const; diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp index f14066e..dd53b56 100644 --- a/examples/graphicsview/flowlayout/window.cpp +++ b/examples/graphicsview/flowlayout/window.cpp @@ -48,7 +48,9 @@ Window::Window() : QGraphicsWidget(0, Qt::Window) { FlowLayout *lay = new FlowLayout; - QString sentence(QLatin1String("I am not bothered by the fact that I am unknown. I am bothered when I do not know others.")); + QLatin1String wiseWords("I am not bothered by the fact that I am unknown." + "I am bothered when I do not know others. (Confucius)"); + QString sentence(wiseWords); QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts); for (int i = 0; i < words.count(); ++i) { QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); -- cgit v0.12 From 939623b2bc8e441618ee1a1886cc656880bee62b Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 7 Apr 2009 12:32:04 +1000 Subject: Make OpenGL/ES 1.1 CommonLite and OpenGL/ES 1.0 builds work Reviewed-by: trustme --- src/opengl/qgl_cl_p.h | 2 +- src/opengl/qglframebufferobject.cpp | 4 ++++ src/opengl/qglpixelbuffer_egl.cpp | 8 +++++-- src/opengl/qpaintengine_opengl.cpp | 44 ++++++++++++++++++------------------- src/opengl/qwindowsurface_gl.cpp | 4 ++++ 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/opengl/qgl_cl_p.h b/src/opengl/qgl_cl_p.h index e514ff5..c05a7d7 100644 --- a/src/opengl/qgl_cl_p.h +++ b/src/opengl/qgl_cl_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE inline void glTexParameterf (GLenum target, GLenum pname, GLfloat param) { - glTexParameterx(target, pname, param); + glTexParameterx(target, pname, FLOAT2X(param)); } inline void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 8524dfa..4ba9213 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef QT_OPENGL_ES_1_CL +#include "qgl_cl_p.h" +#endif + QT_BEGIN_NAMESPACE extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp index 964efa2..5390fd1 100644 --- a/src/opengl/qglpixelbuffer_egl.cpp +++ b/src/opengl/qglpixelbuffer_egl.cpp @@ -47,6 +47,10 @@ #include #include +#ifdef QT_OPENGL_ES_1_CL +#include "qgl_cl_p.h" +#endif + QT_BEGIN_NAMESPACE #ifdef EGL_BIND_TO_TEXTURE_RGBA @@ -188,8 +192,8 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, d->req_size.width(), d->req_size.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, d->req_size.width(), d->req_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); return texture; #else return 0; diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 976a021..88fd379 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -1983,7 +1983,7 @@ public: void QOpenGLTrapezoidToArrayTessellator::addTrap(const Trapezoid &trap) { // On OpenGL ES we convert the trap to 2 triangles -#ifndef QT_OPENGL_ES_1 +#ifndef QT_OPENGL_ES if (size > allocated - 8) { #else if (size > allocated - 12) { @@ -1994,31 +1994,31 @@ void QOpenGLTrapezoidToArrayTessellator::addTrap(const Trapezoid &trap) QGLTrapezoid t = toGLTrapezoid(trap); -#ifndef QT_OPENGL_ES_1 - vertices[size++] = t.topLeftX; - vertices[size++] = t.top; - vertices[size++] = t.topRightX; - vertices[size++] = t.top; - vertices[size++] = t.bottomRightX; - vertices[size++] = t.bottom; - vertices[size++] = t.bottomLeftX; - vertices[size++] = t.bottom; +#ifndef QT_OPENGL_ES + vertices[size++] = f2vt(t.topLeftX); + vertices[size++] = f2vt(t.top); + vertices[size++] = f2vt(t.topRightX); + vertices[size++] = f2vt(t.top); + vertices[size++] = f2vt(t.bottomRightX); + vertices[size++] = f2vt(t.bottom); + vertices[size++] = f2vt(t.bottomLeftX); + vertices[size++] = f2vt(t.bottom); #else // First triangle - vertices[size++] = t.topLeftX; - vertices[size++] = t.top; - vertices[size++] = t.topRightX; - vertices[size++] = t.top; - vertices[size++] = t.bottomRightX; - vertices[size++] = t.bottom; + vertices[size++] = f2vt(t.topLeftX); + vertices[size++] = f2vt(t.top); + vertices[size++] = f2vt(t.topRightX); + vertices[size++] = f2vt(t.top); + vertices[size++] = f2vt(t.bottomRightX); + vertices[size++] = f2vt(t.bottom); // Second triangle - vertices[size++] = t.bottomLeftX; - vertices[size++] = t.bottom; - vertices[size++] = t.topLeftX; - vertices[size++] = t.top; - vertices[size++] = t.bottomRightX; - vertices[size++] = t.bottom; + vertices[size++] = f2vt(t.bottomLeftX); + vertices[size++] = f2vt(t.bottom); + vertices[size++] = f2vt(t.topLeftX); + vertices[size++] = f2vt(t.top); + vertices[size++] = f2vt(t.bottomRightX); + vertices[size++] = f2vt(t.bottom); #endif } diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 3dd3064..837ccf2 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -76,6 +76,10 @@ #define GLX_SAMPLES_ARB 100001 #endif +#ifdef QT_OPENGL_ES_1_CL +#include "qgl_cl_p.h" +#endif + QT_BEGIN_NAMESPACE // -- cgit v0.12