From d82ab0709286f6b6816064affee4705d821830ec Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 5 Aug 2009 18:19:11 +0200 Subject: Make QIconloader use resource directory as fallback Instead of using different paths on Mac and Windows we now simply use ":\icons" on all platforms. It is a little more effort to create resources but it is certainly the Qt way to do it. :) Reviewed-by: ogoffart --- src/gui/image/qicon.cpp | 13 ++++--------- src/gui/image/qiconloader.cpp | 7 +++++-- tests/auto/qicon/tst_qicon.cpp | 3 +-- tests/auto/qicon/tst_qicon.qrc | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index a4ea6af..e23677f 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -888,10 +888,9 @@ void QIcon::setThemeSearchPaths(const QStringList &paths) On X11, the search path will use the XDG_DATA_DIRS environment variable if available. - On Windows the search path defaults to [Application Directory]/icons - - On Mac the default search path will search in the - [Contents/Resources/icons] part of the application bundle. + By default all platforms will have the resource directory + ":\icons" as their fallback. You can use "rcc -project" + to generate a resource file from your icon theme. \sa setThemeSearchPaths(), fromTheme(), setThemeName() */ @@ -906,7 +905,7 @@ QStringList QIcon::themeSearchPaths() Sets the current icon theme to \a name. The \a name should correspond to a directory name in the - current themeSearchPath() containing an index.theme + themeSearchPath() containing an index.theme file describing it's contents. \sa themeSearchPaths(), themeName() @@ -939,10 +938,6 @@ QString QIcon::themeName() icon theme. If no such icon is found in the current theme \a fallback is return instead. - To use an icon theme on Windows or Mac, you will need to - bundle a compliant theme with your application and make sure - it is located in your themeSarchPaths. - The lastest version of the freedesktop icon specification and naming spesification can be obtained here: http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 279703c..cb1cc61 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -187,14 +187,17 @@ QStringList QIconLoader::themeSearchPaths() const QDir homeDir(QDir::homePath() + QLatin1String("/.icons")); if (homeDir.exists()) m_iconDirs.prepend(homeDir.path()); - -#elif defined(Q_WS_WIN) +#endif + +#if defined(Q_WS_WIN) m_iconDirs.append(qApp->applicationDirPath() + QLatin1String("/icons")); #elif defined(Q_WS_MAC) m_iconDirs.append(qApp->applicationDirPath() + QLatin1String("/../Resources/icons")); #endif + // Allways add resource directory as search path + m_iconDirs.append(QLatin1String(":/icons")); } return m_iconDirs; } diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index b614ab9..bacf7a5 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -609,8 +609,7 @@ void tst_QIcon::task184901_badCache() void tst_QIcon::fromTheme() { - const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/"); - QString searchPath = prefix + QLatin1String("/icons"); + QString searchPath = QLatin1String(":/icons"); QIcon::setThemeSearchPaths(QStringList() << searchPath); QVERIFY(QIcon::themeSearchPaths().size() == 1); QCOMPARE(searchPath, QIcon::themeSearchPaths()[0]); diff --git a/tests/auto/qicon/tst_qicon.qrc b/tests/auto/qicon/tst_qicon.qrc index 1e1a030..7925a33 100644 --- a/tests/auto/qicon/tst_qicon.qrc +++ b/tests/auto/qicon/tst_qicon.qrc @@ -2,5 +2,19 @@ image.png rect.png +./icons/testtheme/16x16/actions/appointment-new.png +./icons/testtheme/22x22/actions/appointment-new.png +./icons/testtheme/32x32/actions/appointment-new.png +./icons/testtheme/index.theme +./icons/testtheme/scalable/actions/svg-only.svg +./icons/themeparent/16x16/actions/address-book-new.png +./icons/themeparent/16x16/actions/appointment-new.png +./icons/themeparent/22x22/actions/address-book-new.png +./icons/themeparent/22x22/actions/appointment-new.png +./icons/themeparent/32x32/actions/address-book-new.png +./icons/themeparent/32x32/actions/appointment-new.png +./icons/themeparent/index.theme +./icons/themeparent/scalable/actions/address-book-new.svg +./icons/themeparent/scalable/actions/appointment-new.svg -- cgit v0.12 From dcdbb81f28bc8fc4bb7fedf78421e473413da1a7 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 11 Aug 2009 15:32:56 +0200 Subject: Fix reversed progress bars on Vista This issue seems to be caused by change a6782030 and was caused by incorrectly applying paranthesis to the expression. Task-number: 259515 Reviewed-by: joao --- src/gui/styles/qwindowsvistastyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index a54c701..3789854 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -1094,7 +1094,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption XPThemeData theme(widget, painter, QLatin1String("PROGRESS"), vertical ? PP_FILLVERT : PP_FILL); theme.rect = option->rect; - bool reverse = bar->direction == (Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted); + bool reverse = (bar->direction == Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted); QTime current = QTime::currentTime(); if (isIndeterminate) { -- cgit v0.12 From 6cf224de00ebf0681cd32a34866bdc3d16e0f45d Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 31 Aug 2009 07:04:12 +0200 Subject: Invalidate cached QVectorPath when QPainterPath changes Reviewed-by: Samuel --- src/gui/painting/qpainterpath.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index ff133b6..cb9ea80 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -3215,6 +3215,8 @@ void QPainterPath::setDirty(bool dirty) { d_func()->dirtyBounds = dirty; d_func()->dirtyControlBounds = dirty; + delete d_func()->pathConverter; + d_func()->pathConverter = 0; } void QPainterPath::computeBoundingRect() const -- cgit v0.12 From b0295e82d08605a5a40803895544e57eeb6c8dc3 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 31 Aug 2009 07:19:23 +0200 Subject: Don't crash when convert Indexed8 without colortable to QPixmap This implicitly adds "grayscale" support for indexed 8, but only for the conversion. The alternative would be leave the pixels uninitialized which would be less nice... Reviewed-by: Samuel --- src/gui/image/qimage.cpp | 6 ++++++ tests/auto/qpixmap/tst_qpixmap.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d48d427..0358ba0 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2904,6 +2904,12 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt: Q_ASSERT(src->height == dest->height); QVector colorTable = fix_color_table(src->colortable, dest->format); + if (colorTable.size() == 0) { + colorTable.resize(256); + for (int i=0; i<256; ++i) + colorTable[i] = qRgb(i, i, i); + + } int w = src->width; const uchar *src_data = src->data; diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 8dd5f5f..9422327 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -83,6 +83,9 @@ private slots: void fromImage_data(); void fromImage(); + void fromUninitializedImage_data(); + void fromUninitializedImage(); + void convertFromImage_data(); void convertFromImage(); @@ -266,6 +269,32 @@ void tst_QPixmap::fromImage() QCOMPARE(result, image); } + +void tst_QPixmap::fromUninitializedImage_data() +{ + QTest::addColumn("format"); + + QTest::newRow("Format_Mono") << QImage::Format_Mono; + QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB; + QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8; + QTest::newRow("Format_RGB32") << QImage::Format_RGB32; + QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32; + QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("Format_RGB16") << QImage::Format_RGB16; +} + +void tst_QPixmap::fromUninitializedImage() +{ + QFETCH(QImage::Format, format); + + QImage image(100, 100, format); + QPixmap pix = QPixmap::fromImage(image); + + // it simply shouldn't crash... + QVERIFY(true); + +} + void tst_QPixmap::convertFromImage_data() { QTest::addColumn("img1"); -- cgit v0.12 From 9d24605add8daabfa55e1085e71ed47b14ed7d83 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 31 Aug 2009 16:46:59 +0200 Subject: QNAM HTTP Code: Some tests where failing ietf.org changed their server to use gzip, therefore our check for the content-length reply header was bogus. Rev-By: Peter Hartmann --- tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp | 8 ++++++-- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index c54bf3c..639464e 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -177,7 +177,9 @@ void tst_QHttpNetworkConnection::head() QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); - QCOMPARE(reply->contentLength(), qint64(contentLength)); + // only check it if it is set + if (reply->contentLength() != -1) + QCOMPARE(reply->contentLength(), qint64(contentLength)); QVERIFY(reply->isFinished()); @@ -237,7 +239,9 @@ void tst_QHttpNetworkConnection::get() QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); - QCOMPARE(reply->contentLength(), qint64(contentLength)); + // only check it if it is set + if (reply->contentLength() != -1) + QCOMPARE(reply->contentLength(), qint64(contentLength)); stopWatch.start(); QByteArray ba; diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 3216a6a..48a48f4 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1081,8 +1081,10 @@ void tst_QNetworkReply::getFromHttp() QCOMPARE(reply->url(), request.url()); QCOMPARE(reply->error(), QNetworkReply::NoError); QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - - QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size()); + QCOMPARE(reply->size(), reference.size()); + // only compare when the header is set. + if (reply->header(QNetworkRequest::ContentLengthHeader).isValid()) + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size()); QCOMPARE(reply->readAll(), reference.readAll()); } -- cgit v0.12 From 7c06af4528d7aa7186b12546c261d5d2a0a3641d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 27 Aug 2009 18:56:47 +0200 Subject: Reset QTemporaryFile's state after failed open() on Windows This fixes a regression introduced in 4.5.2 where QTemporaryFile would no longer attempt to generate a random name after a failed open. Under certain situations, this led to a non-random file being left behind in QDir::tempPath when using the fallback implementation of QFile::copy. Avoid calling QFSFileEngine::setFileName() on a template, so as not to process it as file name. By consistently not calling setFileTemplate in the constructor, we also delay allocation of the fileEngine. Changes made to that function also keep it from unnecessarily allocating the fileEngine. Task-number: 260165 Reviewed-by: Thiago Macieira --- src/corelib/io/qtemporaryfile.cpp | 38 ++++++++--- tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 82 ++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index bd039c8..47fa257 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -292,14 +292,20 @@ class QTemporaryFileEngine : public QFSFileEngine Q_DECLARE_PRIVATE(QFSFileEngine) public: QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true) - : QFSFileEngine(file), filePathIsTemplate(fileIsTemplate) + : QFSFileEngine(), filePathIsTemplate(fileIsTemplate) { + Q_D(QFSFileEngine); + d->filePath = file; + + if (!filePathIsTemplate) + QFSFileEngine::setFileName(file); } ~QTemporaryFileEngine(); bool isReallyOpen(); void setFileName(const QString &file); + void setFileTemplate(const QString &fileTemplate); bool open(QIODevice::OpenMode flags); bool remove(); @@ -336,6 +342,13 @@ void QTemporaryFileEngine::setFileName(const QString &file) QFSFileEngine::setFileName(file); } +void QTemporaryFileEngine::setFileTemplate(const QString &fileTemplate) +{ + Q_D(QFSFileEngine); + if (filePathIsTemplate) + d->filePath = fileTemplate; +} + bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) { Q_D(QFSFileEngine); @@ -382,12 +395,19 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) return false; } + QString template_ = d->filePath; d->filePath = QString::fromLocal8Bit(filename); - filePathIsTemplate = false; d->nativeInitFileName(); - d->closeFileHandle = true; delete [] filename; - return QFSFileEngine::open(openMode); + + if (QFSFileEngine::open(openMode)) { + filePathIsTemplate = false; + return true; + } + + d->filePath = template_; + d->nativeFilePath.clear(); + return false; #endif } @@ -533,7 +553,8 @@ QTemporaryFile::QTemporaryFile() QTemporaryFile::QTemporaryFile(const QString &templateName) : QFile(*new QTemporaryFilePrivate, 0) { - setFileTemplate(templateName); + Q_D(QTemporaryFile); + d->templateName = templateName; } /*! @@ -567,7 +588,8 @@ QTemporaryFile::QTemporaryFile(QObject *parent) QTemporaryFile::QTemporaryFile(const QString &templateName, QObject *parent) : QFile(*new QTemporaryFilePrivate, parent) { - setFileTemplate(templateName); + Q_D(QTemporaryFile); + d->templateName = templateName; } #endif @@ -671,10 +693,10 @@ QString QTemporaryFile::fileTemplate() const */ void QTemporaryFile::setFileTemplate(const QString &name) { - Q_ASSERT(!isOpen()); Q_D(QTemporaryFile); - fileEngine()->setFileName(name); d->templateName = name; + if (d->fileEngine) + static_cast(d->fileEngine)->setFileTemplate(name); } /*! diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index 2541b48..73486e7 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -89,6 +89,8 @@ private slots: void renameFdLeak(); void reOpenThroughQFile(); void keepOpenMode(); + void resetTemplateAfterError(); + void setTemplateAfterOpen(); public: }; @@ -472,5 +474,85 @@ void tst_QTemporaryFile::keepOpenMode() } } +void tst_QTemporaryFile::resetTemplateAfterError() +{ + // calling setFileTemplate on a failed open + + QString tempPath = QDir::tempPath(); + + QString const fileTemplate("destination/qt_temp_file_test.XXXXXX"); + QString const fileTemplate2(tempPath + "/qt_temp_file_test.XXXXXX"); + + QVERIFY2( QDir(tempPath).exists() || QDir().mkpath(tempPath), "Test precondition" ); + QVERIFY2( !QFile::exists("destination"), "Test precondition" ); + QVERIFY2( !QFile::exists(fileTemplate2) || QFile::remove(fileTemplate2), "Test precondition" ); + + QFile file(fileTemplate2); + QByteArray fileContent("This file is intentionally NOT left empty."); + + QVERIFY( file.open(QIODevice::ReadWrite | QIODevice::Truncate) ); + QCOMPARE( file.write(fileContent), (qint64)fileContent.size() ); + QVERIFY( file.flush() ); + + QString fileName; + { + QTemporaryFile temp; + + QVERIFY( temp.fileName().isEmpty() ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + + temp.setFileTemplate( fileTemplate ); + + QVERIFY( temp.fileName().isEmpty() ); + QCOMPARE( temp.fileTemplate(), fileTemplate ); + + QVERIFY( !temp.open() ); + + QVERIFY( temp.fileName().isEmpty() ); + QCOMPARE( temp.fileTemplate(), fileTemplate ); + + temp.setFileTemplate( fileTemplate2 ); + QVERIFY( temp.open() ); + + fileName = temp.fileName(); + QVERIFY( QFile::exists(fileName) ); + QVERIFY( !fileName.isEmpty() ); + QVERIFY2( fileName != fileTemplate2, + ("Generated name shouldn't be same as template: " + fileTemplate2).toLocal8Bit().constData() ); + } + + QVERIFY( !QFile::exists(fileName) ); + + file.seek(0); + QCOMPARE( QString(file.readAll()), QString(fileContent) ); + QVERIFY( file.remove() ); +} + +void tst_QTemporaryFile::setTemplateAfterOpen() +{ + QTemporaryFile temp; + + QVERIFY( temp.fileName().isEmpty() ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + + QVERIFY( temp.open() ); + + QString const fileName = temp.fileName(); + QString const newTemplate("funny-path/funny-name-XXXXXX.tmp"); + + QVERIFY( !fileName.isEmpty() ); + QVERIFY( QFile::exists(fileName) ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + QVERIFY( temp.fileTemplate() != newTemplate ); + + temp.close(); // QTemporaryFile::setFileTemplate will assert on isOpen() up to 4.5.2 + temp.setFileTemplate(newTemplate); + QCOMPARE( temp.fileTemplate(), newTemplate ); + + QVERIFY( temp.open() ); + QCOMPARE( temp.fileName(), fileName ); + QCOMPARE( temp.fileTemplate(), newTemplate ); +} + QTEST_MAIN(tst_QTemporaryFile) #include "tst_qtemporaryfile.moc" -- cgit v0.12 From 20cc50a21eb5841b3a3e8546877e805f5a4df528 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 31 Aug 2009 19:33:10 +0200 Subject: Fix #error line not to have a ' as it's not correct Merge-request: 753 Reviewed-by: Thiago Macieira --- src/3rdparty/webkit/WebCore/DerivedSources.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebCore/DerivedSources.cpp b/src/3rdparty/webkit/WebCore/DerivedSources.cpp index f698913..aaf8983 100644 --- a/src/3rdparty/webkit/WebCore/DerivedSources.cpp +++ b/src/3rdparty/webkit/WebCore/DerivedSources.cpp @@ -334,5 +334,5 @@ // want StaticConstructors.h to "pollute" all the source files we #include here // accidentally, so we'll throw an error whenever any file includes it. #ifdef StaticConstructors_h -#error Don't include any file in DerivedSources.cpp that includes StaticConstructors.h +#error Do not include any file in DerivedSources.cpp that includes StaticConstructors.h #endif -- cgit v0.12 From d1bb06923e825ac7079863d15d0d946d4c5aa19c Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Mon, 31 Aug 2009 13:17:16 +1000 Subject: Added description of visualIndex condition to docs for logicalIndex() Fix for task: 214373 --- src/gui/itemviews/qheaderview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index a1c3e4e..4dbd6dc 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1047,7 +1047,9 @@ int QHeaderView::visualIndex(int logicalIndex) const /*! Returns the logicalIndex for the section at the given \a visualIndex - position, or -1 otherwise. + position, or -1 if visualIndex < 0 or visualIndex >= QHeaderView::count(). + + Note that the visualIndex is not affected by hidden sections. \sa visualIndex(), sectionPosition() */ -- cgit v0.12 From 397fb3ece0fb556bc158cf1e826145196d2e6e95 Mon Sep 17 00:00:00 2001 From: Peter Yard Date: Tue, 1 Sep 2009 10:02:56 +1000 Subject: Doc for QSslError constructor parameters fixed each cons. --- src/network/ssl/qsslerror.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp index 69d2ccd..d47c91d 100644 --- a/src/network/ssl/qsslerror.cpp +++ b/src/network/ssl/qsslerror.cpp @@ -105,10 +105,8 @@ public: }; /*! - Constructs a QSslError object. The two optional arguments specify the \a - error that occurred, and which \a certificate the error relates to. + Constructs a QSslError object with no error and default certificate. - \sa QSslCertificate */ // RVCT compiler in debug build does not like about default values in const- @@ -120,6 +118,11 @@ QSslError::QSslError() d->certificate = QSslCertificate(); } +/*! + Constructs a QSslError object. The argument specifies the \a + error that occurred. + +*/ QSslError::QSslError(SslError error) : d(new QSslErrorPrivate) { @@ -127,6 +130,12 @@ QSslError::QSslError(SslError error) d->certificate = QSslCertificate(); } +/*! + Constructs a QSslError object. The two arguments specify the \a + error that occurred, and which \a certificate the error relates to. + + \sa QSslCertificate +*/ QSslError::QSslError(SslError error, const QSslCertificate &certificate) : d(new QSslErrorPrivate) { -- cgit v0.12 From 7a5d0d0b9f8b9203aa3921b2eb9fd7c77095c685 Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Mon, 31 Aug 2009 17:18:10 +1000 Subject: Update the qmake autotest: re MSVC test failure findMocs and findDeps When MSVC is used the default DESTDIR makes use a release/debug suffix. For these tests DESTDIR needs to be "."/ Minor code cleanup was done whilst correcting these effected .pro files Reviewed-by: Lincoln Ramsay --- tests/auto/qmake/testdata/findDeps/findDeps.pro | 7 ++----- tests/auto/qmake/testdata/findMocs/findMocs.pro | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/auto/qmake/testdata/findDeps/findDeps.pro b/tests/auto/qmake/testdata/findDeps/findDeps.pro index e0a2b86..43577b5 100644 --- a/tests/auto/qmake/testdata/findDeps/findDeps.pro +++ b/tests/auto/qmake/testdata/findDeps/findDeps.pro @@ -1,11 +1,8 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Mar 12 11:08:20 2009 -###################################################################### - TEMPLATE = app -TARGET = +TARGET = findDeps DEPENDPATH += . INCLUDEPATH += . +DESTDIR = ./ # Input HEADERS += object1.h \ diff --git a/tests/auto/qmake/testdata/findMocs/findMocs.pro b/tests/auto/qmake/testdata/findMocs/findMocs.pro index daa3c7f..1469b4c 100644 --- a/tests/auto/qmake/testdata/findMocs/findMocs.pro +++ b/tests/auto/qmake/testdata/findMocs/findMocs.pro @@ -1,11 +1,8 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Mar 11 16:11:09 2009 -###################################################################### - TEMPLATE = app -TARGET = +TARGET = findMocs DEPENDPATH += . INCLUDEPATH += . +DESTDIR = ./ # Input HEADERS += object1.h object2.h object3.h object4.h object5.h object6.h object7.h -- cgit v0.12 From d80748df828b92f376ca779ab83776f3c9f53ce1 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 1 Sep 2009 11:21:30 +1000 Subject: Update QML doc style. --- tools/qdoc3/test/classic.css | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index f97bdbe..c0bc3d47 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -251,45 +251,25 @@ span.string,span.char .qmlname { white-space: nowrap; - font-weight: bold; - font-size: 125%; } .qmltype { - font-weight: bold; - font-size: 125%; -} - -.qmlproto, .qmldoc { - // border-top: 1px solid #84b0c7; + text-align: center; + font-size: 160%; } .qmlproto { - padding: 0; - //background-color: #e4e4e4;//#d5e1e8; - //font-weight: bold; - //-webkit-border-top-left-radius: 8px; - //-webkit-border-top-right-radius: 8px; - //-moz-border-radius-topleft: 8px; - //-moz-border-radius-topright: 8px; + background-color: #eee; + border-width: 1px; + border-style: solid; + border-color: #ddd; + font-weight: bold; + padding: 6px 0px 6px 10px; + margin: 42px 0px 0px 0px; } .qmldoc { - border-top: 1px solid #e4e4e4; - //padding: 2px 5px; - //background-color: #eef3f5; - //border-top-width: 0; - //-webkit-border-bottom-left-radius: 8px; - //-webkit-border-bottom-right-radius: 8px; - //-moz-border-radius-bottomleft: 8px; - //-moz-border-radius-bottomright: 8px; -} - -.qmldoc p, .qmldoc dl, .qmldoc ul { - //margin: 6px 0; } *.qmlitem p { - //margin-top: 0px; - //margin-bottom: 0px; } -- cgit v0.12 From 28635d8aeefbd0aa807f333769a0ab9fea9324b0 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 1 Sep 2009 13:08:02 +1000 Subject: Fixes determination of end of odbc string on deficient driver Adds some cleanups (using QVarLengthArray), and reverting to the initial and correct calculation (when the driver doesn't deem fit to return SQL_NO_DATA). --- src/sql/drivers/odbc/qsql_odbc.cpp | 12 ++++---- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 41 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 742d596..2692c96 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -323,12 +323,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni colSize *= 2; // a tiny bit faster, since it saves a SQLGetData() call } } - char* buf = new char[colSize]; + QVarLengthArray buf(colSize); while (true) { r = SQLGetData(hStmt, column+1, unicode ? SQL_C_WCHAR : SQL_C_CHAR, - (SQLPOINTER)buf, + (SQLPOINTER)buf.data(), colSize, &lengthIndicator); if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { @@ -343,11 +343,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni // colSize-1: remove 0 termination when there is more data to fetch int rSize = (r == SQL_SUCCESS_WITH_INFO) ? (unicode ? colSize-2 : colSize-1) : lengthIndicator; if (unicode) { - fieldVal += QString((QChar*) buf, rSize / 2); + fieldVal += QString((const QChar*) buf.constData(), rSize / 2); } else { - fieldVal += QString::fromAscii(buf, rSize); + fieldVal += QString::fromAscii(buf.constData(), rSize); } - if (lengthIndicator - fieldVal.size() <= 0) { + memset(buf.data(), 0, colSize); + if (lengthIndicator < colSize) { // workaround for Drivermanagers that don't return SQL_NO_DATA break; } @@ -359,7 +360,6 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni break; } } - delete[] buf; return fieldVal; } diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index a6b887a..e9a0670 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -180,6 +180,8 @@ private slots: void odbc_uintfield(); void odbc_bindBoolean_data() { generic_data("QODBC"); } void odbc_bindBoolean(); + void odbc_testqGetString_data() { generic_data("QODBC"); } + void odbc_testqGetString(); void oci_serverDetach_data() { generic_data("QOCI"); } void oci_serverDetach(); // For task 154518 @@ -347,6 +349,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) << qTableName("numericfields") << qTableName("qtest_ibaseblobs") << qTableName("qtestBindBool") + << qTableName("testqGetString") << qTableName("qtest_sqlguid") << qTableName("uint_table") << qTableName("uint_test") @@ -2024,6 +2027,44 @@ void tst_QSqlDatabase::odbc_bindBoolean() QCOMPARE(q.value(1).toBool(), false); } +void tst_QSqlDatabase::odbc_testqGetString() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlQuery q(db); + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))")); + + QString largeString; + largeString.fill('A', 65536); + + // Bind and insert + QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("testqGetString") + " VALUES(?, ?)")); + q.bindValue(0, 1); + q.bindValue(1, largeString); + QVERIFY_SQL(q, exec()); + q.bindValue(0, 2); + q.bindValue(1, largeString+QLatin1Char('B')); + QVERIFY_SQL(q, exec()); + q.bindValue(0, 3); + q.bindValue(1, largeString+QLatin1Char('B')+QLatin1Char('C')); + QVERIFY_SQL(q, exec()); + + // Retrive + QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + qTableName("testqGetString") + " ORDER BY id")); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QCOMPARE(q.value(1).toString().length(), 65536); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 2); + QCOMPARE(q.value(1).toString().length(), 65537); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 3); + QCOMPARE(q.value(1).toString().length(), 65538); +} + + void tst_QSqlDatabase::mysql_multiselect() { QFETCH(QString, dbName); -- cgit v0.12 From ec581ee164cbdab1a321d44f0795a79d62faf569 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 1 Sep 2009 13:27:21 +1000 Subject: Update license headers. Reviewed-by: Trust Me --- tests/auto/qmargins/tst_qmargins.cpp | 27 ++++++++++----------- .../qtabletevent/device_information/main.cpp | 28 +++++++++++----------- .../qtabletevent/device_information/tabletwidget.h | 26 ++++++++++---------- .../manual/qtabletevent/event_compression/main.cpp | 28 +++++++++++----------- 4 files changed, 54 insertions(+), 55 deletions(-) diff --git a/tests/auto/qmargins/tst_qmargins.cpp b/tests/auto/qmargins/tst_qmargins.cpp index 070aa19..6ee2495 100644 --- a/tests/auto/qmargins/tst_qmargins.cpp +++ b/tests/auto/qmargins/tst_qmargins.cpp @@ -9,8 +9,8 @@ ** 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. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,25 +21,24 @@ ** 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 +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** 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 have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ - #include #include diff --git a/tests/manual/qtabletevent/device_information/main.cpp b/tests/manual/qtabletevent/device_information/main.cpp index 0c2eda3..69867bc 100644 --- a/tests/manual/qtabletevent/device_information/main.cpp +++ b/tests/manual/qtabletevent/device_information/main.cpp @@ -3,14 +3,14 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the test suite module of the Qt Toolkit. +** 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. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** 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 +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** 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 have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index b16e9ed..d3ccb32 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -9,8 +9,8 @@ ** 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. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** 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 +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** 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 have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/manual/qtabletevent/event_compression/main.cpp b/tests/manual/qtabletevent/event_compression/main.cpp index 3b869e3..26611d3 100644 --- a/tests/manual/qtabletevent/event_compression/main.cpp +++ b/tests/manual/qtabletevent/event_compression/main.cpp @@ -3,14 +3,14 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the test suite module of the Qt Toolkit. +** 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. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -21,20 +21,20 @@ ** 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 +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this ** package. ** -** 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 have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v0.12 From b2d9dc8c487a8b87347a7d45a6c4f9dc827ddbfe Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 1 Sep 2009 13:57:30 +1000 Subject: Add #define's for highp/mediump after #version/#extension headers GLSL shaders require that #version and #extension must appear before any other code. The #define's we insert for highp/mediump/etc must therefore be moved down to just after them. Reviewed-by: Gunnar Sletta --- src/opengl/qglshaderprogram.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index c4d9322..56b55d0 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -501,6 +501,25 @@ bool QGLShader::compile(const char *source) return d->compile(this); } else if (d->shader) { QVarLengthArray src; + int headerLen = 0; + while (source && source[headerLen] == '#') { + // Skip #version and #extension directives at the start of + // the shader code. We need to insert the qualifierDefines + // and redefineHighp just after them. + if (qstrncmp(source + headerLen, "#version", 8) != 0 && + qstrncmp(source + headerLen, "#extension", 10) != 0) { + break; + } + while (source[headerLen] != '\0' && source[headerLen] != '\n') + ++headerLen; + if (source[headerLen] == '\n') + ++headerLen; + } + QByteArray header; + if (headerLen > 0) { + header = QByteArray(source, headerLen); + src.append(header.constData()); + } #ifdef QGL_DEFINE_QUALIFIERS src.append(qualifierDefines); #endif @@ -509,7 +528,7 @@ bool QGLShader::compile(const char *source) d->shaderType == PartialFragmentShader) src.append(redefineHighp); #endif - src.append(source); + src.append(source + headerLen); QGLContextGroup *ctx = d->ctx; glShaderSource(d->shader, src.size(), src.data(), 0); return d->compile(this); -- cgit v0.12 From 632c430a70e2aa50d57c80e35e15391f0b859749 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 1 Sep 2009 09:58:30 +0200 Subject: doc: Fixed several qdoc errors. Also removed four function declarations from QMargins that had no definitions. --- src/corelib/tools/qmargins.cpp | 8 +++----- src/corelib/tools/qmargins.h | 5 ----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index df08da1..747ea5e 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE \class QMargins \ingroup painting - \brief The QMargins + \brief The QMargins class defines the four margins of a rectangle. QMargin defines a set of four margins; left, top, right and bottom, that describe the size of the borders surrounding a rectangle. @@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE Constructs a margins object with all margins set to 0. - \sa isValid() + \sa isNull() */ /*! @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE Constructs margins with the given \a left, \a top, \a right, \a bottom - \sa setWidth(), setHeight() + \sa setLeft(), setRight(), setTop(), setBottom() */ /*! @@ -86,8 +86,6 @@ QT_BEGIN_NAMESPACE Returns true if all margins are is 0; otherwise returns false. - - \sa isValid(), isEmpty() */ diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index be918cc..2691c62 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -68,11 +68,6 @@ public: void setRight(int right); void setBottom(int bottom); - int &rleft(); - int &rtop(); - int &rright(); - int &rbottom(); - private: int m_left; int m_top; -- cgit v0.12 From 76d18f5f06f55c7f908ceb9fba4cac41c0c852f8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 31 Aug 2009 20:27:13 +0200 Subject: QMetaObject::normalizeType: fix out-of-bound access. As reported in merge request 1375 Also use QVarLenghtArray instead of manually allocated char* Reviewed-by: Thierry --- src/corelib/kernel/qmetaobject.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 30f1cc8..c311465 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -943,7 +943,7 @@ QByteArray QMetaObject::normalizedType(const char *type) if (!type || !*type) return result; - QVarLengthArray stackbuf((int)strlen(type)); + QVarLengthArray stackbuf(int(strlen(type)) + 1); qRemoveWhitespace(type, stackbuf.data()); int templdepth = 0; qNormalizeType(stackbuf.data(), templdepth, result); @@ -968,10 +968,9 @@ QByteArray QMetaObject::normalizedSignature(const char *method) if (!method || !*method) return result; int len = int(strlen(method)); - char stackbuf[64]; - char *buf = (len >= 64 ? new char[len+1] : stackbuf); - qRemoveWhitespace(method, buf); - char *d = buf; + QVarLengthArray stackbuf(len + 1); + char *d = stackbuf.data(); + qRemoveWhitespace(method, d); result.reserve(len); @@ -987,8 +986,6 @@ QByteArray QMetaObject::normalizedSignature(const char *method) result += *d++; } - if (buf != stackbuf) - delete [] buf; return result; } -- cgit v0.12 From 16edcd5ff94ecc731146e3703aaf25cd6bb3fb67 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Tue, 1 Sep 2009 10:14:07 +0200 Subject: Implement QSslCertificate::version() and QSslCertificate::serialNumber() Task-number: 251830 Merge-request: 1383 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcertificate.cpp | 8 ++++++++ src/network/ssl/qsslsocket_openssl_symbols.cpp | 2 ++ src/network/ssl/qsslsocket_openssl_symbols_p.h | 1 + 3 files changed, 11 insertions(+) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 666770d..5db6d0a 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -250,6 +250,10 @@ void QSslCertificate::clear() */ QByteArray QSslCertificate::version() const { + if (d->versionString.isEmpty() && d->x509) + d->versionString = + QByteArray::number( qlonglong(q_ASN1_INTEGER_get( d->x509->cert_info->version )) ); + return d->versionString; } @@ -258,6 +262,10 @@ QByteArray QSslCertificate::version() const */ QByteArray QSslCertificate::serialNumber() const { + if (d->serialNumberString.isEmpty() && d->x509) + d->serialNumberString = + QByteArray::number( qlonglong(q_ASN1_INTEGER_get( d->x509->cert_info->serialNumber )) ); + return d->serialNumberString; } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 5b04a57..d3dcd51 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -94,6 +94,7 @@ QT_BEGIN_NAMESPACE #ifdef SSLEAY_MACROS DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return 0, return) #endif +DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return) DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return) DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return) DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return) @@ -608,6 +609,7 @@ bool q_resolveOpenSslSymbols() #ifdef SSLEAY_MACROS RESOLVEFUNC(ASN1_dup) #endif + RESOLVEFUNC(ASN1_INTEGER_get) RESOLVEFUNC(ASN1_STRING_data) RESOLVEFUNC(ASN1_STRING_length) RESOLVEFUNC(BIO_ctrl) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index f9c92e5..30762ca 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -201,6 +201,7 @@ QT_BEGIN_NAMESPACE #endif // !defined QT_LINKED_OPENSSL bool q_resolveOpenSslSymbols(); +long q_ASN1_INTEGER_get(ASN1_INTEGER *a); unsigned char * q_ASN1_STRING_data(ASN1_STRING *a); int q_ASN1_STRING_length(ASN1_STRING *a); long q_BIO_ctrl(BIO *a, int b, long c, void *d); -- cgit v0.12 From 8f1596ae9b64870c54958611552c71b0b390038f Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Tue, 1 Sep 2009 10:14:08 +0200 Subject: QSslCertificate: Add + 1 to serialNumber Merge-request: 1383 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcertificate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 5db6d0a..c128da9 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -252,7 +252,7 @@ QByteArray QSslCertificate::version() const { if (d->versionString.isEmpty() && d->x509) d->versionString = - QByteArray::number( qlonglong(q_ASN1_INTEGER_get( d->x509->cert_info->version )) ); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version))); return d->versionString; } @@ -264,7 +264,7 @@ QByteArray QSslCertificate::serialNumber() const { if (d->serialNumberString.isEmpty() && d->x509) d->serialNumberString = - QByteArray::number( qlonglong(q_ASN1_INTEGER_get( d->x509->cert_info->serialNumber )) ); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber)) + 1); return d->serialNumberString; } -- cgit v0.12 From 67d5b1b800df55c61241c7fa33feeeea41a31513 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 1 Sep 2009 10:30:11 +0200 Subject: QSslCertificate: fix previous patch, add autotest and documentation The +1 must be added to the version, not the serial number. Reviewed-by: trustme --- src/network/ssl/qsslcertificate.cpp | 6 +++--- tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index c128da9..3793b1e 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -252,19 +252,19 @@ QByteArray QSslCertificate::version() const { if (d->versionString.isEmpty() && d->x509) d->versionString = - QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version))); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1); return d->versionString; } /*! - Returns the certificate's serial number string. + Returns the certificate's serial number string in decimal format. */ QByteArray QSslCertificate::serialNumber() const { if (d->serialNumberString.isEmpty() && d->x509) d->serialNumberString = - QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber)) + 1); + QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber))); return d->serialNumberString; } diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index add48c4..4dfb6b9 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -267,6 +267,8 @@ void tst_QSslCertificate::compareCertificates( QCOMPARE(cert1.alternateSubjectNames(), cert2.alternateSubjectNames()); QCOMPARE(cert1.effectiveDate(), cert2.effectiveDate()); QCOMPARE(cert1.expiryDate(), cert2.expiryDate()); + QCOMPARE(cert1.version(), cert2.version()); + QCOMPARE(cert1.serialNumber(), cert2.serialNumber()); // ### add more functions here ... } @@ -677,7 +679,9 @@ void tst_QSslCertificate::certInfo() QCOMPARE(cert.subjectInfo("C"), QString("NO")); QCOMPARE(cert.subjectInfo("ST"), QString()); - QCOMPARE(cert.version(), QByteArray()); + QCOMPARE(cert.version(), QByteArray::number(1)); + QCOMPARE(cert.serialNumber(), QByteArray::number(17)); + QCOMPARE(cert.toPem().constData(), (const char*)pem); QCOMPARE(cert.toDer(), QByteArray::fromHex(der)); -- cgit v0.12 From f39ead322f7b2e485cc6767b609eb5bc8a10b0ea Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Tue, 1 Sep 2009 10:40:49 +0200 Subject: qlist.h uses memcpy() without including or Attempting to make use of the inlined QList::node_copy without including or with gcc 4.4 results in (e.g.) /usr/lib64/qt4/include/QtCore/qlist.h: In member function "void QList::node_copy(QList::Node*, QList::Node*, QList::Node*) [with T = net::Port]": /usr/lib64/qt4/include/QtCore/qlist.h:600: instantiated from "void QList::detach_helper() [with T = net::Port]" /usr/lib64/qt4/include/QtCore/qlist.h:121: instantiated from "void QList::detach() [with T = net::Port]" /usr/lib64/qt4/include/QtCore/qlist.h:462: instantiated from "void QList::append(const T&) [with T = net::Port]" /usr/src/ark/BUILD/kdenetwork/kget/transfer-plugins/bittorrent/libbtcore/net/portlist.cpp:54: instantiated from here /usr/lib64/qt4/include/QtCore/qlist.h:388: error: "memcpy" was not declared in this scope Task-number: reported, but not yet assigned a number Merge-request: 1388 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index ba8ae56..c2bdbee 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -52,6 +52,7 @@ #endif #include +#include QT_BEGIN_HEADER -- cgit v0.12 From a985aaccfcaf2e24b7094875f2e6f51d80c45997 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 1 Sep 2009 10:31:37 +0200 Subject: Reduce the flickering caused by QAxClientSite::EnableModeless Lock the updates during this call from the activex control. Task-number: 257593 Reviewed-by: Trust Me --- src/activeqt/container/qaxwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 621c836..22e7a82 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -1437,6 +1437,7 @@ extern Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent; HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) { + LockWindowUpdate(host->window()->winId()); EnableWindow(host->window()->winId(), fEnable); if (!fEnable) { @@ -1447,6 +1448,7 @@ HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) QApplicationPrivate::leaveModal(host); } qt_win_ignoreNextMouseReleaseEvent = false; + LockWindowUpdate(0); return S_OK; } -- cgit v0.12 From efe61b3b44c0c391d4c11bd061e531f03bf8fb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Sep 2009 09:55:13 +0200 Subject: Fixed poor utilization of depth buffer range in GL 2 paint engine. Before this patch we were only able to do 20 or so IntersectClips before failing, this patch instead adapts to the fixed point nature of typical depth buffer implementations and lets us do ~2^15 IntersectClip operations before failing, which should be a reasonable limit for any real-world application. Using the following mapping of old floating point depths to integer depths: -1.0 -> 0, -0.5 -> 1, 0.0 -> 2, 0.25 -> 3, 0.5 -> 4, 0.625 -> 5, etc.. Reviewed-by: Tom --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 51 +++++++++++----------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 19 ++++++-- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index a976a02..0c01263 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -380,7 +380,7 @@ void QGL2PaintEngineExPrivate::useSimpleShader() } if (simpleShaderDepthUniformDirty) { - shaderManager->simpleProgram()->setUniformValue("depth", (GLfloat)q->state()->currentDepth); + shaderManager->simpleProgram()->setUniformValue("depth", normalizedDeviceDepth(q->state()->currentDepth)); simpleShaderDepthUniformDirty = false; } } @@ -731,7 +731,6 @@ void QGL2PaintEngineExPrivate::resetGLState() glActiveTexture(GL_TEXTURE0); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); - glDepthFunc(GL_LESS); glDepthMask(true); glClearDepth(1); } @@ -959,7 +958,7 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) } if (depthUniformDirty) { - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), (GLfloat)q->state()->currentDepth); + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), normalizedDeviceDepth(q->state()->currentDepth)); depthUniformDirty = false; } @@ -1351,7 +1350,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) if (!d->inRenderText) { glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); glDepthMask(false); } @@ -1441,7 +1440,7 @@ void QGL2PaintEngineEx::ensureActive() if (d->needsSync) { glViewport(0, 0, d->width, d->height); glDepthMask(false); - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); setState(state()); d->needsSync = false; } @@ -1492,7 +1491,7 @@ void QGL2PaintEngineEx::clipEnabledChanged() d->regenerateDepthClip(); } else { if (d->use_system_clip) { - state()->currentDepth = -0.5f; + state()->currentDepth = 0; } else { state()->depthTestEnabled = false; } @@ -1501,7 +1500,7 @@ void QGL2PaintEngineEx::clipEnabledChanged() } } -void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth) +void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint depth) { transferMode(BrushDrawingMode); @@ -1510,7 +1509,7 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth) if (q->state()->needsDepthBufferClear) { glDepthMask(true); - glClearDepth(0.5); + glClearDepth(rawDepth(2)); glClear(GL_DEPTH_BUFFER_BIT); q->state()->needsDepthBufferClear = false; glDepthMask(false); @@ -1532,7 +1531,7 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth) glColorMask(false, false, false, false); glDepthMask(true); - shaderManager->simpleProgram()->setUniformValue("depth", depth); + shaderManager->simpleProgram()->setUniformValue("depth", normalizedDeviceDepth(depth)); simpleShaderDepthUniformDirty = true; glEnable(GL_DEPTH_TEST); @@ -1596,12 +1595,12 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) glDepthFunc(GL_ALWAYS); - state()->maxDepth = 0.5f; + state()->maxDepth = 4; d->writeClip(qtVectorPathForPath(path), state()->maxDepth); - state()->currentDepth = 0.25f; + state()->currentDepth = 3; state()->depthTestEnabled = true; - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); } @@ -1610,7 +1609,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) if (d->use_system_clip) { glEnable(GL_DEPTH_TEST); state()->depthTestEnabled = true; - state()->currentDepth = -0.5; + state()->currentDepth = 0; } else { glDisable(GL_DEPTH_TEST); state()->depthTestEnabled = false; @@ -1618,18 +1617,18 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) state()->canRestoreClip = false; break; case Qt::IntersectClip: - state()->maxDepth = (1.0f + state()->maxDepth) * 0.5; + ++state()->maxDepth; d->writeClip(path, state()->maxDepth); - state()->currentDepth = 1.5 * state()->maxDepth - 0.5f; + state()->currentDepth = state()->maxDepth - 1; state()->depthTestEnabled = true; break; case Qt::ReplaceClip: d->systemStateChanged(); state()->rectangleClip = QRect(); - state()->maxDepth = 0.5f; + state()->maxDepth = 4; glDepthFunc(GL_ALWAYS); d->writeClip(path, state()->maxDepth); - state()->currentDepth = 0.25f; + state()->currentDepth = 3; state()->canRestoreClip = false; state()->depthTestEnabled = true; break; @@ -1641,7 +1640,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) break; } - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); if (state()->depthTestEnabled) { glEnable(GL_DEPTH_TEST); d->simpleShaderDepthUniformDirty = true; @@ -1672,8 +1671,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged() glDisable(GL_SCISSOR_TEST); - q->state()->currentDepth = -0.5f; - q->state()->maxDepth = 0.5f; + q->state()->currentDepth = 1; + q->state()->maxDepth = 4; q->state()->rectangleClip = QRect(0, 0, width, height); @@ -1708,8 +1707,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged() path.addRegion(systemClip); glDepthFunc(GL_ALWAYS); - writeClip(qtVectorPathForPath(path), 0.0f); - glDepthFunc(GL_LEQUAL); + writeClip(qtVectorPathForPath(path), 2); + glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); q->state()->depthTestEnabled = true; @@ -1718,7 +1717,7 @@ void QGL2PaintEngineExPrivate::systemStateChanged() q->transformChanged(); } - q->state()->currentDepth = -0.5f; + q->state()->currentDepth = 1; simpleShaderDepthUniformDirty = true; depthUniformDirty = true; } @@ -1757,7 +1756,7 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state) if (old_state && old_state != s && old_state->canRestoreClip) { d->updateDepthScissorTest(); glDepthMask(false); - glDepthFunc(GL_LEQUAL); + glDepthFunc(GL_LESS); s->maxDepth = old_state->maxDepth; } else { d->regenerateDepthClip(); @@ -1802,8 +1801,8 @@ QOpenGL2PaintEngineState::QOpenGL2PaintEngineState() needsDepthBufferClear = true; depthTestEnabled = false; scissorTestEnabled = false; - currentDepth = -0.5f; - maxDepth = 0.5f; + currentDepth = 1; + maxDepth = 4; canRestoreClip = true; hasRectangleClip = false; } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 58fcde1..552e390 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -82,8 +82,8 @@ public: bool depthTestEnabled; bool scissorTestEnabled; - qreal currentDepth; - qreal maxDepth; + uint maxDepth; + uint currentDepth; bool canRestoreClip; QRect rectangleClip; @@ -230,13 +230,26 @@ public: QGLEngineShaderManager* shaderManager; - void writeClip(const QVectorPath &path, float depth); + void writeClip(const QVectorPath &path, uint depth); void updateDepthScissorTest(); void setScissor(const QRect &rect); void regenerateDepthClip(); void systemStateChanged(); uint use_system_clip : 1; + static inline GLfloat rawDepth(uint depth) + { + // assume at least 16 bits in the depth buffer, and + // use 2^15 depth levels to be safe with regard to + // rounding issues etc + return depth * (1.0f / GLfloat((1 << 15) - 1)); + } + + static inline GLfloat normalizedDeviceDepth(uint depth) + { + return 2.0f * rawDepth(depth) - 1.0f; + } + uint location(QGLEngineShaderManager::Uniform uniform) { return shaderManager->getUniformLocation(uniform); -- cgit v0.12 From fa7bed077d882d32e208c6f3879bac6355bb3726 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 31 Aug 2009 14:36:37 +0200 Subject: QNAM HTTP Code: Pipelining used queue from wrong side Do it as it was done in dequeueAndSendRequest. Reviewed-by: TrustMe --- src/network/access/qhttpnetworkconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index e68aa3a..da9ec09 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -519,7 +519,7 @@ bool QHttpNetworkConnectionPrivate::fillPipeline(QList &queue, if (queue.isEmpty()) return true; - for (int i = 0; i < queue.length(); i++) { + for (int i = queue.count() - 1; i >= 0; --i) { HttpMessagePair messagePair = queue.at(i); const QHttpNetworkRequest &request = messagePair.first; -- cgit v0.12 From ab45aa26a040bdf84dc923792f5f384dd51f906d Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 1 Sep 2009 11:35:22 +0200 Subject: Make test more reliable - wait after show. This test failed randomly in the past, and more often on a KDE4 desktop with a slow graphics card. --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 2acb76d..aa1f2b8 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -5420,6 +5420,7 @@ void tst_QGraphicsItem::contextMenuEventPropagation() qt_x11_wait_for_window_manager(&view); #endif view.resize(200, 200); + QTest::qWait(250); QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10), view.viewport()->mapToGlobal(QPoint(10, 10))); -- cgit v0.12 From 72d7a8e5d7cc5cf498078648f01a20869245d75e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 1 Sep 2009 11:47:18 +0200 Subject: Fix compilation of QAbstractItemModel test --- tests/auto/qabstractitemmodel/dynamictreemodel.cpp | 9 +++------ tests/auto/qabstractitemmodel/dynamictreemodel.h | 9 +++------ tests/auto/qabstractitemmodel/qabstractitemmodel.pro | 2 +- tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp b/tests/auto/qabstractitemmodel/dynamictreemodel.cpp index 6425dcd..dd0615d 100644 --- a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp +++ b/tests/auto/qabstractitemmodel/dynamictreemodel.cpp @@ -41,13 +41,10 @@ #include "dynamictreemodel.h" -#include -#include -#include +#include +#include +#include -#include - -#include DynamicTreeModel::DynamicTreeModel(QObject *parent) : QAbstractItemModel(parent), diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.h b/tests/auto/qabstractitemmodel/dynamictreemodel.h index d84bf68..a769c38 100644 --- a/tests/auto/qabstractitemmodel/dynamictreemodel.h +++ b/tests/auto/qabstractitemmodel/dynamictreemodel.h @@ -42,14 +42,11 @@ #ifndef DYNAMICTREEMODEL_H #define DYNAMICTREEMODEL_H -#include +#include -#include -#include +#include +#include -#include - -#include template class QList; diff --git a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro index 84ed5a2..a31868b 100644 --- a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro +++ b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro @@ -2,5 +2,5 @@ load(qttest_p4) SOURCES += tst_qabstractitemmodel.cpp dynamictreemodel.cpp HEADERS += dynamictreemodel.h -QT = core + diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp index da65e7d..58832c7 100644 --- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include //TESTED_CLASS=QAbstractListModel QAbstractTableModel //TESTED_FILES= -- cgit v0.12 From bfa9b7e5cb1cd91aa0efad14bd91f14144e1acb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 31 Aug 2009 14:07:42 +0200 Subject: doc: Also mention HSL --- src/gui/painting/qcolor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 422d5a3..173c870 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -298,7 +298,7 @@ QT_BEGIN_NAMESPACE /*! \enum QColor::Spec - The type of color specified, either RGB, HSV or CMYK. + The type of color specified, either RGB, HSV, CMYK or HSL. \value Rgb \value Hsv -- cgit v0.12 From 22ac5bb9aac73b0c7d319f2cdc42dd5bcd59f2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 31 Aug 2009 16:02:23 +0200 Subject: Microoptimizations in QCleanLooksStyle Shaved 4K off the size of a release build of libQtGui. Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qcleanlooksstyle.cpp | 364 ++++++++++++++++++++++-------------- 1 file changed, 224 insertions(+), 140 deletions(-) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 6d957ca..20f1d26 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -561,14 +561,20 @@ static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTi QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110)); painter->setPen(QPen(mdiButtonBorderColor, 1)); - painter->drawLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()); - painter->drawLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()); - painter->drawLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2); - painter->drawLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2); - painter->drawPoint(tmp.left() + 1, tmp.top() + 1); - painter->drawPoint(tmp.right() - 1, tmp.top() + 1); - painter->drawPoint(tmp.left() + 1, tmp.bottom() - 1); - painter->drawPoint(tmp.right() - 1, tmp.bottom() - 1); + const QLine lines[4] = { + QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()), + QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()), + QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2), + QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(tmp.left() + 1, tmp.top() + 1), + QPoint(tmp.right() - 1, tmp.top() + 1), + QPoint(tmp.left() + 1, tmp.bottom() - 1), + QPoint(tmp.right() - 1, tmp.bottom() - 1) + }; + painter->drawPoints(points, 4); painter->setPen(titleBarHighlight); painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1); @@ -900,14 +906,17 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, QRect r = rect.adjusted(0, 1, 0, -1); painter->setPen(buttonShadowAlpha); painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1)); - painter->drawPoint(r.right() - 1, r.top()); - painter->drawPoint(r.right(), r.top() + 1); - painter->drawPoint(r.right() - 1, r.bottom()); - painter->drawPoint(r.right(), r.bottom() - 1); - painter->drawPoint(r.left() + 1, r.top() ); - painter->drawPoint(r.left(), r.top() + 1); - painter->drawPoint(r.left() + 1, r.bottom() ); - painter->drawPoint(r.left(), r.bottom() - 1); + const QPoint points[8] = { + QPoint(r.right() - 1, r.top()), + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.bottom()), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.left() + 1, r.top() ), + QPoint(r.left(), r.top() + 1), + QPoint(r.left() + 1, r.bottom() ), + QPoint(r.left(), r.bottom() - 1) + }; + painter->drawPoints(points, 8); painter->setPen(QPen(option->palette.background().color(), 1)); painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1)); @@ -939,10 +948,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom())); - painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QPoint points2[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + painter->drawPoints(points2, 4); painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); painter->setPen(oldPen); } @@ -1040,10 +1052,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->setBrush(QBrush(dark.darker(120), Qt::Dense4Pattern)); painter->setBrushOrigin(rect.topLeft()); painter->setPen(Qt::NoPen); - painter->drawRect(rect.left(), rect.top(), rect.width(), 1); // Top - painter->drawRect(rect.left(), rect.bottom(), rect.width(), 1); // Bottom - painter->drawRect(rect.left(), rect.top(), 1, rect.height()); // Left - painter->drawRect(rect.right(), rect.top(), 1, rect.height()); // Right + const QRect rects[4] = { + QRect(rect.left(), rect.top(), rect.width(), 1), // Top + QRect(rect.left(), rect.bottom(), rect.width(), 1), // Bottom + QRect(rect.left(), rect.top(), 1, rect.height()), // Left + QRect(rect.right(), rect.top(), 1, rect.height()) // Right + }; + painter->drawRects(rects, 4); painter->restore(); } break; @@ -1065,18 +1080,24 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (isDefault) { r = option->rect.adjusted(0, 1, 0, -1); painter->setPen(QPen(Qt::black, 0)); - painter->drawLine(QPoint(r.left() + 2, r.top()), - QPoint(r.right() - 2, r.top())); - painter->drawLine(QPoint(r.left(), r.top() + 2), - QPoint(r.left(), r.bottom() - 2)); - painter->drawLine(QPoint(r.right(), r.top() + 2), - QPoint(r.right(), r.bottom() - 2)); - painter->drawLine(QPoint(r.left() + 2, r.bottom()), - QPoint(r.right() - 2, r.bottom())); - painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.top()), + QPoint(r.right() - 2, r.top())), + QLine(QPoint(r.left(), r.top() + 2), + QPoint(r.left(), r.bottom() - 2)), + QLine(QPoint(r.right(), r.top() + 2), + QPoint(r.right(), r.bottom() - 2)), + QLine(QPoint(r.left() + 2, r.bottom()), + QPoint(r.right() - 2, r.bottom())) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + painter->drawPoints(points, 4); painter->setPen(oldPen); } return; @@ -1140,10 +1161,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, QPoint(r.right(), r.bottom() - 2)); p->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom())); - p->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - p->drawPoint(QPoint(r.right() - 1, r.top() + 1)); - p->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - p->drawPoint(QPoint(r.left() + 1, r.top() + 1)); + const QPoint points[4] = { + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1), + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1) + }; + p->drawPoints(points, 4); if (!isDefault && !hasFocus && isEnabled) p->setPen(QPen(darkOutline.darker(110), 0)); @@ -1163,14 +1187,17 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, topShadow.setAlpha(60); p->setPen(topShadow); - p->drawPoint(QPoint(r.right(), r.top() + 1)); - p->drawPoint(QPoint(r.right() - 1, r.top() )); - p->drawPoint(QPoint(r.right(), r.bottom() - 1)); - p->drawPoint(QPoint(r.right() - 1, r.bottom() )); - p->drawPoint(QPoint(r.left() + 1, r.bottom())); - p->drawPoint(QPoint(r.left(), r.bottom() - 1)); - p->drawPoint(QPoint(r.left() + 1, r.top())); - p->drawPoint(QPoint(r.left(), r.top() + 1)); + const QPoint points2[8] = { + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.top() ), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.right() - 1, r.bottom() ), + QPoint(r.left() + 1, r.bottom()), + QPoint(r.left(), r.bottom() - 1), + QPoint(r.left() + 1, r.top()), + QPoint(r.left(), r.top() + 1) + }; + p->drawPoints(points2, 8); topShadow.setAlpha(30); p->setPen(topShadow); @@ -1183,18 +1210,24 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (isDefault) { r.adjust(-1, -1, 1, 1); p->setPen(buttonShadowAlpha.darker(120)); - p->drawLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)); - p->drawLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)); - p->drawLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)); - p->drawLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)); - p->drawPoint(r.topRight() + QPoint(-2, 1)); - p->drawPoint(r.topRight() + QPoint(-1, 2)); - p->drawPoint(r.bottomRight() + QPoint(-1, -2)); - p->drawPoint(r.bottomRight() + QPoint(-2, -1)); - p->drawPoint(r.topLeft() + QPoint(1, 2)); - p->drawPoint(r.topLeft() + QPoint(2, 1)); - p->drawPoint(r.bottomLeft() + QPoint(1, -2)); - p->drawPoint(r.bottomLeft() + QPoint(2, -1)); + const QLine lines[4] = { + QLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)), + QLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)), + QLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)), + QLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)) + }; + p->drawLines(lines, 4); + const QPoint points3[8] = { + r.topRight() + QPoint(-2, 1), + r.topRight() + QPoint(-1, 2), + r.bottomRight() + QPoint(-1, -2), + r.bottomRight() + QPoint(-2, -1), + r.topLeft() + QPoint(1, 2), + r.topLeft() + QPoint(2, 1), + r.bottomLeft() + QPoint(1, -2), + r.bottomLeft() + QPoint(2, -1) + }; + p->drawPoints(points3, 8); } painter->setPen(oldPen); painter->setBrush(oldBrush); @@ -1307,12 +1340,15 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, painter->drawLine(innerBottomLine); painter->setPen(alphaCornerColor); - painter->drawPoint(leftBottomInnerCorner1); - painter->drawPoint(leftBottomInnerCorner2); - painter->drawPoint(rightBottomInnerCorner1); - painter->drawPoint(rightBottomInnerCorner2); - painter->drawPoint(leftTopInnerCorner1); - painter->drawPoint(leftTopInnerCorner2); + const QPoint points[6] = { + leftBottomInnerCorner1, + leftBottomInnerCorner2, + rightBottomInnerCorner1, + rightBottomInnerCorner2, + leftTopInnerCorner1, + leftTopInnerCorner2 + }; + painter->drawPoints(points, 6); } #endif // QT_NO_TABWIDGET painter->restore(); @@ -1670,19 +1706,25 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o painter->fillRect(rect, option->palette.base()); QColor borderColor = dark.lighter(110); painter->setPen(QPen(borderColor, 0)); - painter->drawLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())); - painter->drawLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())); - painter->drawLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)); - painter->drawLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)); + const QLine lines[4] = { + QLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())), + QLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())), + QLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)), + QLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)) + }; + painter->drawLines(lines, 4); QColor alphaCorner = mergedColors(borderColor, option->palette.background().color()); QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); //corner smoothing painter->setPen(alphaCorner); - painter->drawPoint(rect.topRight()); - painter->drawPoint(rect.topLeft()); - painter->drawPoint(rect.bottomRight()); - painter->drawPoint(rect.bottomLeft()); + const QPoint points[4] = { + rect.topRight(), + rect.topLeft(), + rect.bottomRight(), + rect.bottomLeft() + }; + painter->drawPoints(points, 4); //inner shadow painter->setPen(innerShadow); @@ -1807,10 +1849,13 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o option->palette.highlight()); painter->setPen(QPen(highlightOutline, 0)); - painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); - painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())), + QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())), + QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), + QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())) + }; + painter->drawLines(lines, 4); //draw text QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; @@ -1864,10 +1909,13 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o highlight); r = r.adjusted(-1, 0, 1, 0); painter->setPen(QPen(highlightOutline, 0)); - painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)); - painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)); - painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)), + QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)), + QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), + QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())) + }; + painter->drawLines(lines, 4); } else { painter->fillRect(option->rect, menuBackground); } @@ -2447,14 +2495,17 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp cachePainter.setPen(topShadow); // antialias corners - cachePainter.drawPoint(QPoint(r.right(), r.top() + 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.top() )); - cachePainter.drawPoint(QPoint(r.right(), r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() )); - cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom())); - cachePainter.drawPoint(QPoint(r.left(), r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.left() + 1, r.top())); - cachePainter.drawPoint(QPoint(r.left(), r.top() + 1)); + const QPoint points[8] = { + QPoint(r.right(), r.top() + 1), + QPoint(r.right() - 1, r.top() ), + QPoint(r.right(), r.bottom() - 1), + QPoint(r.right() - 1, r.bottom() ), + QPoint(r.left() + 1, r.bottom()), + QPoint(r.left(), r.bottom() - 1), + QPoint(r.left() + 1, r.top()), + QPoint(r.left(), r.top() + 1) + }; + cachePainter.drawPoints(points, 8); // draw frame topShadow.setAlpha(30); @@ -2482,10 +2533,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp cachePainter.setPen(QPen(darkOutline, 1)); // top and bottom lines - cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())); - cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); - cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); - cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())), + QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())), + QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)) + }; + cachePainter.drawLines(lines, 4); } // gradients @@ -2519,10 +2573,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (spinBox->frame) { // rounded corners - cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); - cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1)); + const QPoint points[4] = { + QPoint(r.left() + 1, r.bottom() - 1), + QPoint(r.left() + 1, r.top() + 1), + QPoint(r.right() - 1, r.bottom() - 1), + QPoint(r.right() - 1, r.top() + 1) + }; + cachePainter.drawPoints(points, 4); if (option->state & State_HasFocus) { QColor darkoutline = option->palette.highlight().color().darker(150); @@ -2531,10 +2588,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (spinBox->direction == Qt::LeftToRight) { cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3)); cachePainter.setPen(QPen(darkoutline, 0)); - cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())); - cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())); - cachePainter.drawLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)); - cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); + const QLine lines[4] = { + QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())), + QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())), + QLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)) + }; + cachePainter.drawLines(lines, 4); cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); @@ -2679,18 +2739,24 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // top outline painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top()); painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom()); - painter->drawPoint(fullRect.left() + 4, fullRect.top() + 1); - painter->drawPoint(fullRect.left() + 3, fullRect.top() + 1); - painter->drawPoint(fullRect.left() + 2, fullRect.top() + 2); - painter->drawPoint(fullRect.left() + 1, fullRect.top() + 3); - painter->drawPoint(fullRect.left() + 1, fullRect.top() + 4); + const QPoint points[5] = { + QPoint(fullRect.left() + 4, fullRect.top() + 1), + QPoint(fullRect.left() + 3, fullRect.top() + 1), + QPoint(fullRect.left() + 2, fullRect.top() + 2), + QPoint(fullRect.left() + 1, fullRect.top() + 3), + QPoint(fullRect.left() + 1, fullRect.top() + 4) + }; + painter->drawPoints(points, 5); painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom()); - painter->drawPoint(fullRect.right() - 3, fullRect.top() + 1); - painter->drawPoint(fullRect.right() - 4, fullRect.top() + 1); - painter->drawPoint(fullRect.right() - 2, fullRect.top() + 2); - painter->drawPoint(fullRect.right() - 1, fullRect.top() + 3); - painter->drawPoint(fullRect.right() - 1, fullRect.top() + 4); + const QPoint points2[5] = { + QPoint(fullRect.right() - 3, fullRect.top() + 1), + QPoint(fullRect.right() - 4, fullRect.top() + 1), + QPoint(fullRect.right() - 2, fullRect.top() + 2), + QPoint(fullRect.right() - 1, fullRect.top() + 3), + QPoint(fullRect.right() - 1, fullRect.top() + 4) + }; + painter->drawPoints(points2, 5); // draw bottomline painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom()); @@ -2749,10 +2815,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(maxButtonIconRect.topLeft()); - painter->drawPoint(maxButtonIconRect.topRight()); - painter->drawPoint(maxButtonIconRect.bottomLeft()); - painter->drawPoint(maxButtonIconRect.bottomRight()); + const QPoint points[4] = { + maxButtonIconRect.topLeft(), + maxButtonIconRect.topRight(), + maxButtonIconRect.bottomLeft(), + maxButtonIconRect.bottomRight() + }; + painter->drawPoints(points, 4); } } @@ -2765,18 +2834,24 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); painter->setPen(textAlphaColor); - painter->drawLine(closeIconRect.left() + 1, closeIconRect.top(), - closeIconRect.right(), closeIconRect.bottom() - 1); - painter->drawLine(closeIconRect.left(), closeIconRect.top() + 1, - closeIconRect.right() - 1, closeIconRect.bottom()); - painter->drawLine(closeIconRect.right() - 1, closeIconRect.top(), - closeIconRect.left(), closeIconRect.bottom() - 1); - painter->drawLine(closeIconRect.right(), closeIconRect.top() + 1, - closeIconRect.left() + 1, closeIconRect.bottom()); - painter->drawPoint(closeIconRect.topLeft()); - painter->drawPoint(closeIconRect.topRight()); - painter->drawPoint(closeIconRect.bottomLeft()); - painter->drawPoint(closeIconRect.bottomRight()); + const QLine lines[4] = { + QLine(closeIconRect.left() + 1, closeIconRect.top(), + closeIconRect.right(), closeIconRect.bottom() - 1), + QLine(closeIconRect.left(), closeIconRect.top() + 1, + closeIconRect.right() - 1, closeIconRect.bottom()), + QLine(closeIconRect.right() - 1, closeIconRect.top(), + closeIconRect.left(), closeIconRect.bottom() - 1), + QLine(closeIconRect.right(), closeIconRect.top() + 1, + closeIconRect.left() + 1, closeIconRect.bottom()) + }; + painter->drawLines(lines, 4); + const QPoint points[4] = { + closeIconRect.topLeft(), + closeIconRect.topRight(), + closeIconRect.bottomLeft(), + closeIconRect.bottomRight() + }; + painter->drawPoints(points, 4); painter->setPen(textColor); painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1, @@ -2806,10 +2881,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1, frontWindowRect.right() - 1, frontWindowRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(frontWindowRect.topLeft()); - painter->drawPoint(frontWindowRect.topRight()); - painter->drawPoint(frontWindowRect.bottomLeft()); - painter->drawPoint(frontWindowRect.bottomRight()); + const QPoint points[4] = { + frontWindowRect.topLeft(), + frontWindowRect.topRight(), + frontWindowRect.bottomLeft(), + frontWindowRect.bottomRight() + }; + painter->drawPoints(points, 4); QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3); QRegion clipRegion = backWindowRect; @@ -2821,10 +2899,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1, backWindowRect.right() - 1, backWindowRect.top() + 1); painter->setPen(textAlphaColor); - painter->drawPoint(backWindowRect.topLeft()); - painter->drawPoint(backWindowRect.topRight()); - painter->drawPoint(backWindowRect.bottomLeft()); - painter->drawPoint(backWindowRect.bottomRight()); + const QPoint points2[4] = { + backWindowRect.topLeft(), + backWindowRect.topRight(), + backWindowRect.bottomLeft(), + backWindowRect.bottomRight() + }; + painter->drawPoints(points2, 4); painter->restore(); } } @@ -3498,10 +3579,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp handlePainter.save(); handlePainter.setRenderHint(QPainter::Antialiasing); handlePainter.translate(0.5, 0.5); - handlePainter.drawLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())); - handlePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())); - handlePainter.drawLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())); - handlePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top())); + const QLine lines[4] = { + QLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())), + QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())), + QLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())), + QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top())) + }; + handlePainter.drawLines(lines, 4); handlePainter.restore();; handlePainter.setPen(QPen(outline.darker(130), 1)); handlePainter.drawLine(QPoint(r.left() + 3, r.top()), QPoint(r.right() - 3, r.top())); -- cgit v0.12 From 150c14bc50d28d2e6c768ff00654f527cb226812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 1 Sep 2009 10:37:56 +0200 Subject: Fixed QPainterPath::toFillPolygons autotest Now it verifies that there are two non-intersecting polygons. Reviewed-by: Gunnar Sletta --- tests/auto/qpainterpath/tst_qpainterpath.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp index 26c1f9b..9c4cbc4 100644 --- a/tests/auto/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp @@ -1145,8 +1145,9 @@ void tst_QPainterPath::testToFillPolygons() path.lineTo(QPointF(70, 100)); path.lineTo(QPointF(40, 100)); - QPolygonF polygon = path.toFillPolygons(QMatrix()).first(); - QCOMPARE(polygon.count(QPointF(70, 50)), 2); + const QList polygons = path.toFillPolygons(); + QCOMPARE(polygons.size(), 2); + QCOMPARE(polygons.first().count(QPointF(70, 50)), 0); } void tst_QPainterPath::connectPathDuplicatePoint() -- cgit v0.12 From 9aa88cf3d15bf7ed6d3faf03ebe9fd574e1667ec Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 1 Sep 2009 11:55:30 +0200 Subject: Fix compile error for WinCE Do not use LockWindowUpdate() in Win CE Reviewed-by: Trust Me --- src/activeqt/container/qaxwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 22e7a82..94f85a5 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -1437,7 +1437,9 @@ extern Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent; HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) { +#if !defined(Q_OS_WINCE) LockWindowUpdate(host->window()->winId()); +#endif EnableWindow(host->window()->winId(), fEnable); if (!fEnable) { @@ -1448,8 +1450,9 @@ HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable) QApplicationPrivate::leaveModal(host); } qt_win_ignoreNextMouseReleaseEvent = false; +#if !defined(Q_OS_WINCE) LockWindowUpdate(0); - +#endif return S_OK; } -- cgit v0.12 From c78d75db9467af9f5638073f74bed437c24c3584 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 1 Sep 2009 09:59:17 +0200 Subject: QMargins doesn't need to be exported as it is fully inline Reviewed-by: ogoffart --- src/corelib/tools/qmargins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index 2691c62..549c634 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) -class Q_CORE_EXPORT QMargins +class QMargins { public: QMargins(); -- cgit v0.12 From c15e07884a29be26f1110e4d54a56da0001e3c53 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 1 Sep 2009 10:06:38 +0200 Subject: dynamic_cast in the demo was failing to build without rtti Reviewed-by: Kim Motoyoshi Kalland --- demos/boxes/qtbox.cpp | 14 ++++++++++---- demos/boxes/qtbox.h | 6 ++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/demos/boxes/qtbox.cpp b/demos/boxes/qtbox.cpp index 015bc95..54882fb 100644 --- a/demos/boxes/qtbox.cpp +++ b/demos/boxes/qtbox.cpp @@ -122,7 +122,7 @@ void ItemBase::duplicateSelectedItems(QGraphicsScene *scene) selected = scene->selectedItems(); foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = dynamic_cast(item); + ItemBase *itemBase = qgraphicsitem_cast(item); if (itemBase) scene->addItem(itemBase->createNew(itemBase->m_size, itemBase->pos().x() + itemBase->m_size, itemBase->pos().y())); } @@ -137,7 +137,7 @@ void ItemBase::deleteSelectedItems(QGraphicsScene *scene) selected = scene->selectedItems(); foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = dynamic_cast(item); + ItemBase *itemBase = qgraphicsitem_cast(item); if (itemBase) delete itemBase; } @@ -152,7 +152,7 @@ void ItemBase::growSelectedItems(QGraphicsScene *scene) selected = scene->selectedItems(); foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = dynamic_cast(item); + ItemBase *itemBase = qgraphicsitem_cast(item); if (itemBase) { itemBase->prepareGeometryChange(); itemBase->m_size *= 2; @@ -171,7 +171,7 @@ void ItemBase::shrinkSelectedItems(QGraphicsScene *scene) selected = scene->selectedItems(); foreach (QGraphicsItem *item, selected) { - ItemBase *itemBase = dynamic_cast(item); + ItemBase *itemBase = qgraphicsitem_cast(item); if (itemBase) { itemBase->prepareGeometryChange(); itemBase->m_size /= 2; @@ -257,6 +257,12 @@ void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event) m_size = MIN_ITEM_SIZE; } +int ItemBase::type() const +{ + return Type; +} + + bool ItemBase::isInResizeArea(const QPointF &pos) { return (-pos.y() < pos.x() - m_size + 9); diff --git a/demos/boxes/qtbox.h b/demos/boxes/qtbox.h index 6f39b0d..9465911 100644 --- a/demos/boxes/qtbox.h +++ b/demos/boxes/qtbox.h @@ -47,10 +47,11 @@ #include #include "glbuffers.h" -class ItemBase : public QObject, public QGraphicsItem +class ItemBase : public QGraphicsItem { - Q_OBJECT public: + enum { Type = UserType + 1 }; + ItemBase(int size, int x, int y); virtual ~ItemBase(); virtual QRectF boundingRect() const; @@ -64,6 +65,7 @@ protected: virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void keyPressEvent(QKeyEvent *event); virtual void wheelEvent(QGraphicsSceneWheelEvent *event); + virtual int type() const; bool isInResizeArea(const QPointF &pos); static void duplicateSelectedItems(QGraphicsScene *scene); -- cgit v0.12 From c78c520bde91c08cedc6f7cc5c943998155f078e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 1 Sep 2009 12:11:03 +0200 Subject: Fixed warnings (just 2 Q_Q() that are not used any more --- src/corelib/kernel/qabstractitemmodel.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 0a6c628..ec8fb76 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -601,7 +601,6 @@ void QAbstractItemModelPrivate::rowsInserted(const QModelIndex &parent, void QAbstractItemModelPrivate::itemsAboutToBeMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation) { - Q_Q(QAbstractItemModel); QVector persistent_moved_explicitly; QVector persistent_moved_in_source; QVector persistent_moved_in_destination; @@ -2469,7 +2468,6 @@ void QAbstractItemModel::endRemoveRows() */ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation) { - Q_Q(QAbstractItemModel); // Don't move the range within itself. if ( ( destinationParent == srcParent ) && ( destinationStart >= start ) -- cgit v0.12 From 2a9ffbeda34c04bede04c1aac24eab13fc490fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 09:03:43 +0200 Subject: Make sure graphics effects updates properly when changing their properties. Reviewed-by: Leo --- src/gui/effects/qgraphicseffect.cpp | 23 +++++++++++++++++++++++ src/gui/effects/qgraphicseffect.h | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index ccbf7fc..1e0ea53 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -349,6 +349,22 @@ void QGraphicsEffect::setEnabled(bool enable) */ /*! + Schedules a redraw of the source. Call this function whenever the source + needs to be redrawn. + + This convenience function is equivalent to calling + QGraphicsEffectSource::update(). + + \sa updateBoundingRect(), QGraphicsEffectSource::update() +*/ +void QGraphicsEffect::update() +{ + Q_D(QGraphicsEffect); + if (d->source) + d->source->update(); +} + +/*! Returns a pointer to the source, which provides extra context information that can be useful for the effect. @@ -366,6 +382,8 @@ QGraphicsEffectSource *QGraphicsEffect::source() const function whenever you change any parameters that will cause the virtual boundingRectFor() function to return a different value. + This function will call update() if this is necessary. + \sa boundingRectFor(), boundingRect() */ void QGraphicsEffect::updateBoundingRect() @@ -523,6 +541,7 @@ void QGraphicsColorizeEffect::setColor(const QColor &color) return; d->filter->setColor(color); + update(); emit colorChanged(color); } @@ -610,6 +629,7 @@ void QGraphicsPixelizeEffect::setPixelSize(int size) return; d->pixelSize = size; + update(); emit pixelSizeChanged(size); } @@ -903,6 +923,7 @@ void QGraphicsDropShadowEffect::setColor(const QColor &color) return; d->filter->setColor(color); + update(); emit colorChanged(color); } @@ -1012,6 +1033,7 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) d->isFullyOpaque = 0; else d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1); + update(); emit opacityChanged(opacity); } @@ -1050,6 +1072,7 @@ void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) d->opacityMask = mask; d->hasOpacityMask = (mask.style() != Qt::NoBrush); + update(); emit opacityMaskChanged(mask); } diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 8e5384c..ad941a5 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -118,7 +118,7 @@ public: public Q_SLOTS: void setEnabled(bool enable); - // ### add update() slot + void update(); Q_SIGNALS: void enabledChanged(bool enabled); -- cgit v0.12 From cc6e8f466111dc04395041cdabb73a831ae802c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 10:39:49 +0200 Subject: QGraphicsDropShadowEffect convenience; setXOffset() and setYOffset(). Reviewed-by: Andreas --- src/gui/effects/qgraphicseffect.cpp | 20 +++++++++++++++++++- src/gui/effects/qgraphicseffect.h | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 1e0ea53..2be6a49 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -840,7 +840,7 @@ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() By default, the offset is 8 pixels towards the lower right. - \sa blurRadius(), color() + \sa xOffset(), yOffset(), blurRadius(), color() */ QPointF QGraphicsDropShadowEffect::offset() const { @@ -860,6 +860,24 @@ void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) } /*! + \property QGraphicsDropShadowEffect::xOffset + \brief the horizontal shadow offset in pixels. + + By default, the horizontal shadow offset is 8 pixels. + + \sa yOffset(), offset() +*/ + +/*! + \property QGraphicsDropShadowEffect::yOffset + \brief the vertical shadow offset in pixels. + + By default, the vertical shadow offset is 8 pixels. + + \sa xOffset(), offset() +*/ + +/*! \fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset) This signal is emitted whenever the effect's shadow offset changes. diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index ad941a5..aee7834 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -237,6 +237,8 @@ class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect { Q_OBJECT Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged) + Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) + Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) public: @@ -245,15 +247,31 @@ public: QRectF boundingRectFor(const QRectF &rect) const; QPointF offset() const; + + inline qreal xOffset() const + { return offset().x(); } + + inline qreal yOffset() const + { return offset().y(); } + int blurRadius() const; QColor color() const; public Q_SLOTS: void setOffset(const QPointF &ofs); + inline void setOffset(qreal dx, qreal dy) { setOffset(QPointF(dx, dy)); } + inline void setOffset(qreal d) { setOffset(QPointF(d, d)); } + + inline void setXOffset(qreal dx) + { setOffset(QPointF(dx, yOffset())); } + + inline void setYOffset(qreal dy) + { setOffset(QPointF(xOffset(), dy)); } + void setBlurRadius(int blurRadius); void setColor(const QColor &color); -- cgit v0.12 From d3cf11841763ab222ae0ca62468e83a695116514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 1 Sep 2009 11:50:14 +0200 Subject: Add a benchmark for QGraphicsAnchorLayout. --- .../qgraphicsanchorlayout.pro | 6 + .../tst_qgraphicsanchorlayout.cpp | 197 +++++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro create mode 100644 tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp diff --git a/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro b/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro new file mode 100644 index 0000000..0d563b9 --- /dev/null +++ b/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qgraphicsanchorlayout + +SOURCES += tst_qgraphicsanchorlayout.cpp + diff --git a/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp new file mode 100644 index 0000000..e419bae --- /dev/null +++ b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class tst_QGraphicsAnchorLayout : public QObject +{ + Q_OBJECT +public: + tst_QGraphicsAnchorLayout() {} + ~tst_QGraphicsAnchorLayout() {} + +private slots: + void s60_hard_complex_data(); + void s60_hard_complex(); +}; + + +class RectWidget : public QGraphicsWidget +{ +public: + RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent){} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + Q_UNUSED(option); + Q_UNUSED(widget); + painter->drawRoundRect(rect()); + painter->drawLine(rect().topLeft(), rect().bottomRight()); + painter->drawLine(rect().bottomLeft(), rect().topRight()); + } +}; + +static QGraphicsWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0), + const QSizeF &preferred = QSize(150.0, 100.0), + const QSizeF &maximum = QSizeF(200.0, 100.0), + const QString &name = QString()) +{ + QGraphicsWidget *w = new RectWidget; + w->setMinimumSize(minimum); + w->setPreferredSize(preferred); + w->setMaximumSize(maximum); + w->setData(0, name); + return w; +} + +static void setAnchor(QGraphicsAnchorLayout *l, + QGraphicsLayoutItem *firstItem, + Qt::AnchorPoint firstEdge, + QGraphicsLayoutItem *secondItem, + Qt::AnchorPoint secondEdge, + qreal spacing) +{ + l->addAnchor(firstItem, firstEdge, secondItem, secondEdge); + l->setAnchorSpacing(firstItem, firstEdge, secondItem, secondEdge, spacing); +} + +void tst_QGraphicsAnchorLayout::s60_hard_complex_data() +{ + QTest::addColumn("whichSizeHint"); + QTest::newRow("minimumSizeHint") + << int(Qt::MinimumSize); + QTest::newRow("preferredSizeHint") + << int(Qt::PreferredSize); + QTest::newRow("maximumSizeHint") + << int(Qt::MaximumSize); + // Add it as a reference to see how much overhead the body of effectiveSizeHint takes. + QTest::newRow("noSizeHint") + << -1; +} + +void tst_QGraphicsAnchorLayout::s60_hard_complex() +{ + QFETCH(int, whichSizeHint); + + // Test for "hard" complex case, taken from wiki + // https://cwiki.nokia.com/S60QTUI/AnchorLayoutComplexCases + QSizeF min(0, 10); + QSizeF pref(50, 10); + QSizeF max(100, 10); + + QGraphicsWidget *a = createItem(min, pref, max, "a"); + QGraphicsWidget *b = createItem(min, pref, max, "b"); + QGraphicsWidget *c = createItem(min, pref, max, "c"); + QGraphicsWidget *d = createItem(min, pref, max, "d"); + QGraphicsWidget *e = createItem(min, pref, max, "e"); + QGraphicsWidget *f = createItem(min, pref, max, "f"); + QGraphicsWidget *g = createItem(min, pref, max, "g"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + // + setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 10); + setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 10); + setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 10); + setAnchor(l, c, Qt::AnchorRight, d, Qt::AnchorLeft, 10); + setAnchor(l, d, Qt::AnchorRight, l, Qt::AnchorRight, 10); + + // + setAnchor(l, b, Qt::AnchorLeft, e, Qt::AnchorLeft, 10); + setAnchor(l, e, Qt::AnchorRight, d, Qt::AnchorLeft, 10); + + // + setAnchor(l, a, Qt::AnchorHorizontalCenter, g, Qt::AnchorLeft, 10); + setAnchor(l, g, Qt::AnchorRight, f, Qt::AnchorHorizontalCenter, 10); + setAnchor(l, c, Qt::AnchorLeft, f, Qt::AnchorLeft, 10); + setAnchor(l, f, Qt::AnchorRight, d, Qt::AnchorRight, 10); + + // + setAnchor(l, l, Qt::AnchorTop, e, Qt::AnchorTop, 0); + setAnchor(l, e, Qt::AnchorBottom, a, Qt::AnchorTop, 0); + setAnchor(l, e, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + setAnchor(l, e, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + setAnchor(l, e, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + setAnchor(l, a, Qt::AnchorBottom, f, Qt::AnchorTop, 0); + setAnchor(l, a, Qt::AnchorBottom, b, Qt::AnchorBottom, 0); + setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorBottom, 0); + setAnchor(l, a, Qt::AnchorBottom, d, Qt::AnchorBottom, 0); + setAnchor(l, f, Qt::AnchorBottom, g, Qt::AnchorTop, 0); + setAnchor(l, g, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + // It won't query the size hint if it already has a size set. + // If only one of the sizes is unset it will query sizeHint only of for that hint type. + l->setMinimumSize(60,40); + l->setPreferredSize(220,40); + l->setMaximumSize(240,40); + + switch (whichSizeHint) { + case Qt::MinimumSize: + l->setMinimumSize(-1, -1); + break; + case Qt::PreferredSize: + l->setPreferredSize(-1, -1); + break; + case Qt::MaximumSize: + l->setMaximumSize(-1, -1); + break; + default: + break; + } + + QSizeF sizeHint; + // warm up instruction cache + l->invalidate(); + sizeHint = l->effectiveSizeHint((Qt::SizeHint)whichSizeHint); + // ...then measure... + QBENCHMARK { + l->invalidate(); + sizeHint = l->effectiveSizeHint((Qt::SizeHint)whichSizeHint); + } +} + +QTEST_MAIN(tst_QGraphicsAnchorLayout) + +#include "tst_qgraphicsanchorlayout.moc" -- cgit v0.12 From 4f19cd391aa32b12b9f749af06ebe6836cd0cbae Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 1 Sep 2009 13:31:10 +0200 Subject: Doc: Said what happens when setFocus() is called on a widget in an inactive window. Task-number: 78707 Reviewed-by: Morten Engvoldsen --- src/gui/kernel/qwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 37ffa8fb..863c43e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5962,6 +5962,8 @@ bool QWidget::hasFocus() const isActiveWindow() active window\endlink. The \a reason argument will be passed into any focus event sent from this function, it is used to give an explanation of what caused the widget to get focus. + If the window is not active, the widget will be given the focus when + the window becomes active. First, a focus out event is sent to the focus widget (if any) to tell it that it is about to lose the focus. Then a focus in event -- cgit v0.12 From 7b6152ad6ac588350b8acf4353fb05628e86af2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 1 Sep 2009 13:53:52 +0200 Subject: Compilation fixes for Windows CE on ARM My earlier cleanup/refactoring of qatomic_windows.h broke things on this platform. Should be fixed now. Reviewed-by: Joerg Bornemann --- src/corelib/arch/qatomic_windows.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h index 50dedc1..a09e9fd 100644 --- a/src/corelib/arch/qatomic_windows.h +++ b/src/corelib/arch/qatomic_windows.h @@ -68,7 +68,7 @@ # if _WIN32_WCE < 0x600 && defined(_X86_) // For X86 Windows CE, include winbase.h to catch inline functions which -// overwrite the regular definitions inside of coredll.dll. +// override the regular definitions inside of coredll.dll. // Though one could use the original version of Increment/Decrement, others are // not exported at all. # include @@ -76,19 +76,21 @@ // It's safer to remove the volatile and let the compiler add it as needed. # define QT_INTERLOCKED_NO_VOLATILE -# else // _WIN32_WCE >= 0x600 || _X86_ +# else // _WIN32_WCE >= 0x600 || !_X86_ # define QT_INTERLOCKED_PROTOTYPE __cdecl # define QT_INTERLOCKED_DECLARE_PROTOTYPES -# if _WIN32_WCE >= 0x600 && defined(_X86_) -# define QT_INTERLOCKED_PREFIX _ -# define QT_INTERLOCKED_INTRINSIC +# if _WIN32_WCE >= 0x600 +# if defined(_X86_) +# define QT_INTERLOCKED_PREFIX _ +# define QT_INTERLOCKED_INTRINSIC +# endif # else # define QT_INTERLOCKED_NO_VOLATILE # endif -# endif // _WIN32_WCE >= 0x600 || _X86_ +# endif // _WIN32_WCE >= 0x600 || !_X86_ #endif // Q_OS_WINCE @@ -132,9 +134,9 @@ extern "C" { long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); # if !defined(__i386__) && !defined(_M_IX86) - long QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); - long QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); - __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, long); + void * QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); + void * QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); + __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); # endif } @@ -190,7 +192,7 @@ extern "C" { QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ valueToAdd ) -#if defined(__i386__) || defined(_M_IX86) +#if defined(Q_OS_WINCE) || defined(__i386__) || defined(_M_IX86) # define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ reinterpret_cast( \ @@ -209,7 +211,7 @@ extern "C" { QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ valueToAdd ) -#else // !defined(__i386__) && !defined(_M_IX86) +#else // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) # define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ QT_INTERLOCKED_FUNCTION(InterlockedCompareExchangePointer)( \ @@ -227,7 +229,7 @@ extern "C" { QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ valueToAdd ) -#endif // !defined(__i386__) && !defined(_M_IX86) +#endif // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) //////////////////////////////////////////////////////////////////////////////////////////////////// -- cgit v0.12 From d0b4bd21d5fc04febdfdb41111435d79750e5ff6 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Sep 2009 14:14:18 +0200 Subject: Manual test for QNAM HTTP: Downloading a big file --- tests/manual/qhttpnetworkconnection/main.cpp | 81 ++++++++++++++++++++++ .../qhttpnetworkconnection.pro | 13 ++++ 2 files changed, 94 insertions(+) create mode 100644 tests/manual/qhttpnetworkconnection/main.cpp create mode 100644 tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro diff --git a/tests/manual/qhttpnetworkconnection/main.cpp b/tests/manual/qhttpnetworkconnection/main.cpp new file mode 100644 index 0000000..b15a7ed --- /dev/null +++ b/tests/manual/qhttpnetworkconnection/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +// This file contains benchmarks for QNetworkReply functions. + +#include +#include +#include +#include +#include +#include +#include "../../auto/network-settings.h" + +class tst_qhttpnetworkconnection : public QObject +{ + Q_OBJECT +private slots: + void bigRemoteFile(); + +}; + +void tst_qhttpnetworkconnection::bigRemoteFile() +{ + QNetworkAccessManager manager; + qint64 size; + QTime t; + QNetworkRequest request(QUrl("http://nds1.nokia.com/files/support/global/phones/software/Nokia_Ovi_Suite_webinstaller.exe")); + QNetworkReply* reply = manager.get(request); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + qDebug() << "Starting download"; + t.start(); + QTestEventLoop::instance().enterLoop(50); + QVERIFY(!QTestEventLoop::instance().timeout()); + size = reply->size(); + delete reply; + qDebug() << "Finished!" << endl; + qDebug() << "Time:" << t.elapsed() << "msec"; + qDebug() << "Bytes:" << size; + qDebug() << "Speed:" << (size / 1024) / (t.elapsed() / 1000) << "KB/sec"; +} + +QTEST_MAIN(tst_qhttpnetworkconnection) + +#include "main.moc" diff --git a/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro new file mode 100644 index 0000000..2471389 --- /dev/null +++ b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -0,0 +1,13 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qhttpnetworkconnection +DEPENDPATH += . +INCLUDEPATH += . + +QT -= gui +QT += network + +CONFIG += release + +# Input +SOURCES += main.cpp -- cgit v0.12 From ae2f5c66d16fab9f92f960435057d955e9a832ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Sep 2009 14:09:29 +0200 Subject: Fixed QGLFramebufferObject::toImage() releasing the FBO if bound. Reviewed-by: Trond --- src/opengl/qglframebufferobject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 9659654..859afc7 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -875,9 +875,12 @@ QImage QGLFramebufferObject::toImage() const if (!d->valid) return QImage(); - const_cast(this)->bind(); + bool wasBound = isBound(); + if (!wasBound) + const_cast(this)->bind(); QImage image = qt_gl_read_framebuffer(d->size, d->ctx->format().alpha(), true); - const_cast(this)->release(); + if (!wasBound) + const_cast(this)->release(); return image; } -- cgit v0.12 From e0e0ae322e654b0b152fc54d99201b18b620a0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Sep 2009 14:16:08 +0200 Subject: Fixed toImage() not working on a multisample QGLFramebufferObject. Need to blit into a regular QGLFramebufferObject first to force a multisample resolve. Reviewed-by: Trond --- src/opengl/qglframebufferobject.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 859afc7..8fd113a 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -875,6 +875,16 @@ QImage QGLFramebufferObject::toImage() const if (!d->valid) return QImage(); + // qt_gl_read_framebuffer doesn't work on a multisample FBO + if (format().samples() != 0) { + QGLFramebufferObject temp(size()); + + QRect rect(QPoint(0, 0), size()); + blitFramebuffer(&temp, rect, const_cast(this), rect); + + return temp.toImage(); + } + bool wasBound = isBound(); if (!wasBound) const_cast(this)->bind(); -- cgit v0.12 From a7178d96d7e9c50a4392ab9ee23b219d26028ed3 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 22 Jul 2009 12:55:25 +0200 Subject: Fixes the gif plugin's rendering for some animated gif files. In the case of optimized animated gifs, we don't want to discard the contents of the previous frame, this is handled if needed in the disposal process. Task-number: 247365 Reviewed-by: Samuel --- src/plugins/imageformats/gif/qgifhandler.cpp | 4 ++-- tests/auto/qimagereader/images/qt.gif | Bin 0 -> 26504 bytes tests/auto/qimagereader/images/qt1.gif | Bin 0 -> 7216 bytes tests/auto/qimagereader/images/qt2.gif | Bin 0 -> 5559 bytes tests/auto/qimagereader/images/qt3.gif | Bin 0 -> 4702 bytes tests/auto/qimagereader/images/qt4.gif | Bin 0 -> 4310 bytes tests/auto/qimagereader/images/qt5.gif | Bin 0 -> 4234 bytes tests/auto/qimagereader/images/qt6.gif | Bin 0 -> 4732 bytes tests/auto/qimagereader/images/qt7.gif | Bin 0 -> 5265 bytes tests/auto/qimagereader/images/qt8.gif | Bin 0 -> 6144 bytes tests/auto/qimagereader/qimagereader.qrc | 13 +++++++++++-- tests/auto/qimagereader/tst_qimagereader.cpp | 13 +++++++++++++ 12 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 tests/auto/qimagereader/images/qt.gif create mode 100644 tests/auto/qimagereader/images/qt1.gif create mode 100644 tests/auto/qimagereader/images/qt2.gif create mode 100644 tests/auto/qimagereader/images/qt3.gif create mode 100644 tests/auto/qimagereader/images/qt4.gif create mode 100644 tests/auto/qimagereader/images/qt5.gif create mode 100644 tests/auto/qimagereader/images/qt6.gif create mode 100644 tests/auto/qimagereader/images/qt7.gif create mode 100644 tests/auto/qimagereader/images/qt8.gif diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index de985d8..0f6a349 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -234,7 +234,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, #define LM(l, m) (((m)<<8)|l) digress = false; - int initial = length; + const int initial = length; while (!digress && length) { length--; unsigned char ch=*buffer++; @@ -333,7 +333,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, sheight = newtop + newheight; QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32; - if (image->isNull() || (image->size() != QSize(swidth, sheight)) || image->format() != format) { + if (image->isNull()) { (*image) = QImage(swidth, sheight, format); memset(image->bits(), 0, image->numBytes()); diff --git a/tests/auto/qimagereader/images/qt.gif b/tests/auto/qimagereader/images/qt.gif new file mode 100644 index 0000000..e0a5a80 Binary files /dev/null and b/tests/auto/qimagereader/images/qt.gif differ diff --git a/tests/auto/qimagereader/images/qt1.gif b/tests/auto/qimagereader/images/qt1.gif new file mode 100644 index 0000000..0ce910c Binary files /dev/null and b/tests/auto/qimagereader/images/qt1.gif differ diff --git a/tests/auto/qimagereader/images/qt2.gif b/tests/auto/qimagereader/images/qt2.gif new file mode 100644 index 0000000..993a315 Binary files /dev/null and b/tests/auto/qimagereader/images/qt2.gif differ diff --git a/tests/auto/qimagereader/images/qt3.gif b/tests/auto/qimagereader/images/qt3.gif new file mode 100644 index 0000000..7391678 Binary files /dev/null and b/tests/auto/qimagereader/images/qt3.gif differ diff --git a/tests/auto/qimagereader/images/qt4.gif b/tests/auto/qimagereader/images/qt4.gif new file mode 100644 index 0000000..41109a9 Binary files /dev/null and b/tests/auto/qimagereader/images/qt4.gif differ diff --git a/tests/auto/qimagereader/images/qt5.gif b/tests/auto/qimagereader/images/qt5.gif new file mode 100644 index 0000000..5a3fb54 Binary files /dev/null and b/tests/auto/qimagereader/images/qt5.gif differ diff --git a/tests/auto/qimagereader/images/qt6.gif b/tests/auto/qimagereader/images/qt6.gif new file mode 100644 index 0000000..f22e7c9 Binary files /dev/null and b/tests/auto/qimagereader/images/qt6.gif differ diff --git a/tests/auto/qimagereader/images/qt7.gif b/tests/auto/qimagereader/images/qt7.gif new file mode 100644 index 0000000..a315671 Binary files /dev/null and b/tests/auto/qimagereader/images/qt7.gif differ diff --git a/tests/auto/qimagereader/images/qt8.gif b/tests/auto/qimagereader/images/qt8.gif new file mode 100644 index 0000000..2a7d09e Binary files /dev/null and b/tests/auto/qimagereader/images/qt8.gif differ diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index c6b963b..11b9406 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -1,5 +1,5 @@ - - + + images/16bpp.bmp images/4bpp-rle.bmp images/YCbCr_cmyk.jpg @@ -48,5 +48,14 @@ images/tst7.png images/transparent.xpm images/trolltech.gif + images/qt.gif + images/qt1.gif + images/qt2.gif + images/qt3.gif + images/qt4.gif + images/qt5.gif + images/qt6.gif + images/qt7.gif + images/qt8.gif diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 27c6925..a325a33 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -140,6 +140,7 @@ private slots: #if defined QTEST_HAVE_GIF void gifHandlerBugs(); + void animatedGif(); #endif void readCorruptImage_data(); @@ -710,6 +711,18 @@ void tst_QImageReader::gifHandlerBugs() QCOMPARE(im1.convertToFormat(QImage::Format_ARGB32), im2.convertToFormat(QImage::Format_ARGB32)); } } + +void tst_QImageReader::animatedGif() +{ + QImageReader io(prefix + "qt.gif"); + QImage image= io.read(); + int i=0; + while(!image.isNull()){ + QString frameName = QString(prefix + "qt%1.gif").arg(++i); + QCOMPARE(image, QImage(frameName)); + image=io.read(); + } +} #endif class Server : public QObject -- cgit v0.12 From 505458d4e2d094eba7cf34a71c6cd960c28a52e4 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 1 Sep 2009 15:26:07 +0200 Subject: Doc: Fixed broken links to renamed functions. Reviewed-by: Trust Me --- src/gui/widgets/qcalendarwidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp index dfd8639..8ed57cd 100644 --- a/src/gui/widgets/qcalendarwidget.cpp +++ b/src/gui/widgets/qcalendarwidget.cpp @@ -1967,9 +1967,7 @@ void QCalendarWidgetPrivate::_q_editingFinished() The widget is initialized with the current month and year, but QCalendarWidget provides several public slots to change the year - and month that is shown. The currently displayed month and year - can be retrieved using the currentPageMonth() and currentPageYear() - functions, respectively. + and month that is shown. By default, today's date is selected, and the user can select a date using both mouse and keyboard. The currently selected date @@ -1982,6 +1980,9 @@ void QCalendarWidgetPrivate::_q_editingFinished() all. Note that a date also can be selected programmatically using the setSelectedDate() slot. + The currently displayed month and year can be retrieved using the + monthShown() and yearShown() functions, respectively. + A newly created calendar widget uses abbreviated day names, and both Saturdays and Sundays are marked in red. The calendar grid is not visible. The week numbers are displayed, and the first column @@ -2287,7 +2288,7 @@ int QCalendarWidget::monthShown() const selected date. The currently displayed month and year can be retrieved using the - currentPageMonth() and currentPageYear() functions respectively. + monthShown() and yearShown() functions respectively. \sa yearShown(), monthShown(), showPreviousMonth(), showNextMonth(), showPreviousYear(), showNextYear() -- cgit v0.12 From d117525a4ff8757208231fa77f171c7fd7a30ef9 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 1 Sep 2009 15:27:35 +0200 Subject: fix Windows CE compile failure in qatomic_windows.h Reviewed-by: joao --- src/corelib/arch/qatomic_windows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h index a09e9fd..9b7ff5d 100644 --- a/src/corelib/arch/qatomic_windows.h +++ b/src/corelib/arch/qatomic_windows.h @@ -133,7 +133,7 @@ extern "C" { long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchange )(long QT_INTERLOCKED_VOLATILE *, long); long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); -# if !defined(__i386__) && !defined(_M_IX86) +# if !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) void * QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); void * QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); -- cgit v0.12 From 8abc68d262c40c1f035a2d77779e76f038261a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 15:22:21 +0200 Subject: Make sure the BSP is updated when a graphics effect changes bounding rect. In the case of applying an effect to a QGraphicsItem, we have to notify the scene's BSP that the item's bounding rect has changed. We do this by calling prepareGeometryChange(). In the case of QWidget, it's sub-optimal that we update its parent, but there's no other way to solve it at the moment. --- src/gui/effects/qgraphicseffect.cpp | 4 ++-- src/gui/effects/qgraphicseffect_p.h | 1 + src/gui/graphicsview/qgraphicsitem_p.h | 3 +++ src/gui/kernel/qwidget_p.h | 10 ++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 2be6a49..6624cfb 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -335,7 +335,7 @@ void QGraphicsEffect::setEnabled(bool enable) d->isEnabled = enable; if (d->source) - d->source->update(); + d->source->d_func()->effectBoundingRectChanged(); emit enabledChanged(enable); } @@ -390,7 +390,7 @@ void QGraphicsEffect::updateBoundingRect() { Q_D(QGraphicsEffect); if (d->source) - d->source->update(); + d->source->d_func()->effectBoundingRectChanged(); } /*! diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index bfabfc0..24b605f 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -76,6 +76,7 @@ public: virtual void update() = 0; virtual bool isPixmap() const = 0; virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0) const = 0; + virtual void effectBoundingRectChanged() = 0; friend class QGraphicsScenePrivate; friend class QGraphicsItem; friend class QGraphicsItemPrivate; diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 1090620..49361cf 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -572,6 +572,9 @@ public: inline void update() { item->update(); } + inline void effectBoundingRectChanged() + { item->prepareGeometryChange(); } + inline bool isPixmap() const { return (item->type() == QGraphicsPixmapItem::Type); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index ff0c453..f69c3a7 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -727,6 +727,16 @@ public: inline bool isPixmap() const { return false; } + inline void effectBoundingRectChanged() + { + // ### This function should take a rect parameter; then we can avoid + // updating too much on the parent widget. + if (QWidget *parent = m_widget->parentWidget()) + parent->update(); + else + m_widget->update(); + } + inline const QStyleOption *styleOption() const { return 0; } -- cgit v0.12 From 6b779a021a9c3d334127a4c460ad7f780a97ddb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 15:52:27 +0200 Subject: Fix rounding bug in QGraphicsOpacityEffect. The pixmap was painted at wrong offset. --- src/gui/effects/qgraphicseffect.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 6624cfb..f60e80e 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -1129,19 +1129,20 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); painter->drawPixmap(offset, pixmap); } else { - QRectF srcBrect = source->boundingRect(); - QPixmap pixmap(srcBrect.size().toSize()); + QRect srcBrect = source->boundingRect().toAlignedRect(); + offset = srcBrect.topLeft(); + QPixmap pixmap(srcBrect.size()); pixmap.fill(Qt::transparent); QPainter pixmapPainter(&pixmap); pixmapPainter.setRenderHints(painter->renderHints()); - pixmapPainter.translate(-srcBrect.topLeft()); + pixmapPainter.translate(-offset); source->draw(&pixmapPainter); pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); pixmapPainter.fillRect(srcBrect, d->opacityMask); pixmapPainter.end(); - painter->drawPixmap(srcBrect.topLeft(), pixmap); + painter->drawPixmap(offset, pixmap); } } else { // Draw pixmap in device coordinates to avoid pixmap scaling; -- cgit v0.12 From 500de752ac6af943ced98cd685ed460457b3166d Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Sep 2009 16:03:00 +0200 Subject: Coverity: Small fix for QIODevice --- src/corelib/io/qiodevice.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 75f8e54..ac9f532 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -122,7 +122,12 @@ void debugBinaryString(const char *data, qint64 maxlen) */ QIODevicePrivate::QIODevicePrivate() : openMode(QIODevice::NotOpen), buffer(QIODEVICE_BUFFERSIZE), - pos(0), devicePos(0), accessMode(Unset) + pos(0), devicePos(0) + , baseReadLineDataCalled(false) + , accessMode(Unset) +#ifdef QT_NO_QOBJECT + , q_ptr(0) +#endif { } -- cgit v0.12 From 5632ba903c1b31717b4fabdfc2a3c8b710b5cbf1 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Sep 2009 16:08:56 +0200 Subject: Socket code: Do not use magic buffer size value I have seen a performance increase of around 30% for big file transfers on Linux when having high bandwidth and higher latency. Reviewed-by: Thiago --- src/network/socket/qnativesocketengine.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 3e56995..3d9aa61 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -389,10 +389,19 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data"); } - // Set the send and receive buffer sizes to a magic size, found - // most optimal for our platforms. - setReceiveBufferSize(49152); - setSendBufferSize(49152); + // Before Qt 4.6, we always set the send and receive buffer size to 49152 as + // this was found to be an optimal value. However, modern OS + // all have some kind of auto tuning for this and we therefore don't set + // this explictly anymore. + // If it introduces any performance regressions for Qt 4.6.x (x > 0) then + // it will be put back in. + // + // You can use tests/manual/qhttpnetworkconnection to test HTTP download speed + // with this. + // + // pre-4.6: + // setReceiveBufferSize(49152); + // setSendBufferSize(49152); d->socketType = socketType; d->socketProtocol = protocol; -- cgit v0.12 From 9f59fb741183e1235b2a385b0e688e4a7f4b15c9 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 1 Sep 2009 16:25:49 +0200 Subject: Make sub-attaq working without the popup which make it working on Mac. --- demos/sub-attaq/graphicsscene.cpp | 13 +++++--- demos/sub-attaq/graphicsscene.h | 2 ++ demos/sub-attaq/states.cpp | 25 ++++++++++++--- demos/sub-attaq/states.h | 2 ++ demos/sub-attaq/sub-attaq.pro | 18 +++++++---- demos/sub-attaq/textinformationitem.cpp | 54 ++++++++++++++++++++++++++++++++ demos/sub-attaq/textinformationitem.h | 55 +++++++++++++++++++++++++++++++++ 7 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 demos/sub-attaq/textinformationitem.cpp create mode 100644 demos/sub-attaq/textinformationitem.h diff --git a/demos/sub-attaq/graphicsscene.cpp b/demos/sub-attaq/graphicsscene.cpp index b4fd0c9..79de011 100644 --- a/demos/sub-attaq/graphicsscene.cpp +++ b/demos/sub-attaq/graphicsscene.cpp @@ -51,6 +51,7 @@ #include "animationmanager.h" #include "qanimationstate.h" #include "progressitem.h" +#include "textinformationitem.h" //Qt #include @@ -112,6 +113,8 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode) //The item that display score and level progressItem = new ProgressItem(backgroundItem); + textInformationItem = new TextInformationItem(backgroundItem); + textInformationItem->hide(); //We create the boat boat = new Boat(); addItem(boat); @@ -244,15 +247,15 @@ void GraphicsScene::setupScene(const QList &actions) lettersFadingState->setAnimation(lettersGroupFading); //if new game then we fade out the welcome screen and start playing - lettersMovingState->addTransition(newAction, SIGNAL(triggered()),lettersFadingState); - lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()),gameState); + lettersMovingState->addTransition(newAction, SIGNAL(triggered()), lettersFadingState); + lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()), gameState); //New Game is triggered then player start playing - gameState->addTransition(newAction, SIGNAL(triggered()),gameState); + gameState->addTransition(newAction, SIGNAL(triggered()), gameState); //Wanna quit, then connect to CTRL+Q - gameState->addTransition(quitAction, SIGNAL(triggered()),final); - lettersMovingState->addTransition(quitAction, SIGNAL(triggered()),final); + gameState->addTransition(quitAction, SIGNAL(triggered()), final); + lettersMovingState->addTransition(quitAction, SIGNAL(triggered()), final); //Welcome screen is the initial state machine->setInitialState(lettersMovingState); diff --git a/demos/sub-attaq/graphicsscene.h b/demos/sub-attaq/graphicsscene.h index 073ad17..8fa62f7 100644 --- a/demos/sub-attaq/graphicsscene.h +++ b/demos/sub-attaq/graphicsscene.h @@ -54,6 +54,7 @@ class Torpedo; class Bomb; class PixmapItem; class ProgressItem; +class TextInformationItem; QT_BEGIN_NAMESPACE class QAction; QT_END_NAMESPACE @@ -108,6 +109,7 @@ private: Mode mode; PixmapItem *backgroundItem; ProgressItem *progressItem; + TextInformationItem *textInformationItem; QAction * newAction; QAction * quitAction; Boat *boat; diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp index 75a2615..5c809cb 100644 --- a/demos/sub-attaq/states.cpp +++ b/demos/sub-attaq/states.cpp @@ -47,6 +47,7 @@ #include "torpedo.h" #include "animationmanager.h" #include "progressitem.h" +#include "textinformationitem.h" //Qt #include @@ -226,8 +227,15 @@ void LostState::onEntry(QEvent *) //We clear the scene scene->clearScene(); - //we have only one view - QMessageBox::information(scene->views().at(0),"You lose",message); + //We inform the player + scene->textInformationItem->setMessage(message); + scene->textInformationItem->show(); +} + +void LostState::onExit(QEvent *) +{ + //we hide the information + scene->textInformationItem->hide(); } /** Win State */ @@ -242,7 +250,7 @@ void WinState::onEntry(QEvent *) QString message; if (scene->levelsData.size() - 1 != game->currentLevel) { - message = QString("You win the level %1. Your score is %2.\nPress Space to continue after closing this dialog.").arg(game->currentLevel+1).arg(game->score); + message = QString("You win the level %1. Your score is %2.\nPress Space to continue.").arg(game->currentLevel+1).arg(game->score); //We increment the level number game->currentLevel++; } else { @@ -253,8 +261,15 @@ void WinState::onEntry(QEvent *) game->score = 0; } - //we have only one view - QMessageBox::information(scene->views().at(0),"You win",message); + //We inform the player + scene->textInformationItem->setMessage(message); + scene->textInformationItem->show(); +} + +void WinState::onExit(QEvent *) +{ + //we hide the information + scene->textInformationItem->hide(); } /** UpdateScore State */ diff --git a/demos/sub-attaq/states.h b/demos/sub-attaq/states.h index 7635c0c..3176571 100644 --- a/demos/sub-attaq/states.h +++ b/demos/sub-attaq/states.h @@ -113,6 +113,7 @@ public: protected: void onEntry(QEvent *); + void onExit(QEvent *); private : GraphicsScene *scene; PlayState *game; @@ -125,6 +126,7 @@ public: protected: void onEntry(QEvent *); + void onExit(QEvent *); private : GraphicsScene *scene; PlayState *game; diff --git a/demos/sub-attaq/sub-attaq.pro b/demos/sub-attaq/sub-attaq.pro index ad1327d..ba2b54b 100644 --- a/demos/sub-attaq/sub-attaq.pro +++ b/demos/sub-attaq/sub-attaq.pro @@ -1,5 +1,4 @@ contains(QT_CONFIG, opengl):QT += opengl - HEADERS += boat.h \ bomb.h \ mainwindow.h \ @@ -13,7 +12,8 @@ HEADERS += boat.h \ submarine_p.h \ custompropertyanimation.h \ qanimationstate.h \ - progressitem.h + progressitem.h \ + textinformationitem.h SOURCES += boat.cpp \ bomb.cpp \ main.cpp \ @@ -26,12 +26,18 @@ SOURCES += boat.cpp \ states.cpp \ custompropertyanimation.cpp \ qanimationstate.cpp \ - progressitem.cpp + progressitem.cpp \ + textinformationitem.cpp RESOURCES += subattaq.qrc # install target.path = $$[QT_INSTALL_DEMOS]/animation/sub-attaq -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS sub-attaq.pro pics +sources.files = $$SOURCES \ + $$HEADERS \ + $$RESOURCES \ + $$FORMS \ + sub-attaq.pro \ + pics sources.path = $$[QT_INSTALL_DEMOS]/animation/sub-attaq -INSTALLS += target sources - +INSTALLS += target \ + sources diff --git a/demos/sub-attaq/textinformationitem.cpp b/demos/sub-attaq/textinformationitem.cpp new file mode 100644 index 0000000..759aa56 --- /dev/null +++ b/demos/sub-attaq/textinformationitem.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore 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 Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "textinformationitem.h" +#include "pixmapitem.h" + +TextInformationItem::TextInformationItem (QGraphicsItem * parent) + : QGraphicsTextItem(parent) +{ + setFont(QFont("Comic Sans MS", 25)); +} +#include +void TextInformationItem::setMessage(const QString& text) +{ + setHtml(text); + setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width()/2 , parentItem()->boundingRect().center().y()); +} diff --git a/demos/sub-attaq/textinformationitem.h b/demos/sub-attaq/textinformationitem.h new file mode 100644 index 0000000..aa7f0be --- /dev/null +++ b/demos/sub-attaq/textinformationitem.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore 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 Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTINFORMATIONITEM_H +#define TEXTINFORMATIONITEM_H + +//Qt +#include + +class TextInformationItem : public QGraphicsTextItem +{ +public: + TextInformationItem(QGraphicsItem * parent = 0); + void setMessage(const QString& text); +}; + +#endif // TEXTINFORMATIONITEM_H -- cgit v0.12 From 3418320aa5cad4a982f6278be1fbe8ce66c1558f Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 1 Sep 2009 16:27:57 +0200 Subject: Fixes examples/animation/states, supposedly hidden element was appearing Reviewed-by: trustme --- examples/animation/states/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/animation/states/main.cpp b/examples/animation/states/main.cpp index a78548c..9644049 100644 --- a/examples/animation/states/main.cpp +++ b/examples/animation/states/main.cpp @@ -179,8 +179,8 @@ int main(int argc, char *argv[]) // State 3 state3->assignProperty(button, "text", "Switch to state 1"); - state3->assignProperty(p1, "geometry", QRectF(5, 5, 64, 64)); - state3->assignProperty(p2, "geometry", QRectF(5, 5 + 64 + 5, 64, 64)); + state3->assignProperty(p1, "geometry", QRectF(0, 5, 64, 64)); + state3->assignProperty(p2, "geometry", QRectF(0, 5 + 64 + 5, 64, 64)); state3->assignProperty(p3, "geometry", QRectF(5, 5 + (64 + 5) + 64, 64, 64)); state3->assignProperty(p4, "geometry", QRectF(5 + 64 + 5, 5, 64, 64)); state3->assignProperty(p5, "geometry", QRectF(5 + 64 + 5, 5 + 64 + 5, 64, 64)); -- cgit v0.12 From 3dfde91fcbeaf304edd8d0d09e0732597055cd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 1 Sep 2009 16:31:33 +0200 Subject: Cleanup examples/effects/lighting. There's no need to re-implement QGraphicsDropShadowEffect anymore. --- examples/effects/lighting/lighting.cpp | 22 +++++++-- examples/effects/lighting/lighting.h | 2 - examples/effects/lighting/lighting.pro | 4 +- examples/effects/lighting/shadoweffect.cpp | 76 ------------------------------ examples/effects/lighting/shadoweffect.h | 66 -------------------------- 5 files changed, 21 insertions(+), 149 deletions(-) delete mode 100644 examples/effects/lighting/shadoweffect.cpp delete mode 100644 examples/effects/lighting/shadoweffect.h diff --git a/examples/effects/lighting/lighting.cpp b/examples/effects/lighting/lighting.cpp index 2294b36..e309e2e 100644 --- a/examples/effects/lighting/lighting.cpp +++ b/examples/effects/lighting/lighting.cpp @@ -43,8 +43,6 @@ #include -#include "shadoweffect.h" - #ifndef M_PI #define M_PI 3.14159265358979323846 #endif @@ -98,7 +96,7 @@ void Lighting::setupScene() item->setPen(QPen(Qt::black)); item->setBrush(QBrush(Qt::white)); - item->setGraphicsEffect(new ShadowEffect(item, m_lightSource)); + item->setGraphicsEffect(new QGraphicsDropShadowEffect); item->setZValue(1); item->setPos(i * 80, j * 80); m_scene.addItem(item); @@ -114,6 +112,24 @@ void Lighting::animate() qreal xs = 200 * sin(angle) - 40 + 25; qreal ys = 200 * cos(angle) - 40 + 25; m_lightSource->setPos(xs, ys); + + for (int i = 0; i < m_items.size(); ++i) { + QGraphicsItem *item = m_items.at(i); + Q_ASSERT(item); + QGraphicsDropShadowEffect *effect = static_cast(item->graphicsEffect()); + Q_ASSERT(effect); + + QPointF delta(item->x() - xs, item->y() - ys); + effect->setOffset(delta.toPoint() / 30); + + qreal dx = delta.x(); + qreal dy = delta.y(); + qreal dd = sqrt(dx * dx + dy * dy); + QColor color = effect->color(); + color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7)); + effect->setColor(color); + } + m_scene.update(); } diff --git a/examples/effects/lighting/lighting.h b/examples/effects/lighting/lighting.h index 3e12fdf..eef5cae 100644 --- a/examples/effects/lighting/lighting.h +++ b/examples/effects/lighting/lighting.h @@ -45,8 +45,6 @@ #include #include -#include "shadoweffect.h" - class Lighting: public QGraphicsView { Q_OBJECT diff --git a/examples/effects/lighting/lighting.pro b/examples/effects/lighting/lighting.pro index ea9d5f6..432d1b5 100644 --- a/examples/effects/lighting/lighting.pro +++ b/examples/effects/lighting/lighting.pro @@ -1,5 +1,5 @@ -SOURCES += main.cpp lighting.cpp shadoweffect.cpp -HEADERS += lighting.h shadoweffect.h +SOURCES += main.cpp lighting.cpp +HEADERS += lighting.h # install target.path = $$[QT_INSTALL_EXAMPLES]/effects/lighting diff --git a/examples/effects/lighting/shadoweffect.cpp b/examples/effects/lighting/shadoweffect.cpp deleted file mode 100644 index 16e52fb..0000000 --- a/examples/effects/lighting/shadoweffect.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "shadoweffect.h" - -#include - -ShadowEffect::ShadowEffect(QGraphicsItem *item, QGraphicsItem *source) - : QGraphicsDropShadowEffect() - , item(item), m_lightSource(source) -{ - setBlurRadius(8); - m_color = color(); -} - -void ShadowEffect::adjustForItem() -{ - QPointF delta = item->pos() - m_lightSource->pos(); - setOffset(delta.toPoint() / 30); - - qreal dx = delta.x(); - qreal dy = delta.y(); - qreal dd = sqrt(dx * dx + dy * dy); - m_color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7)); - setColor(m_color); -} - -QRectF ShadowEffect::boundingRectFor(const QRectF &rect) const -{ - const_cast(this)->adjustForItem(); - return QGraphicsDropShadowEffect::boundingRectFor(rect); -} - -void ShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source) -{ - adjustForItem(); - QGraphicsDropShadowEffect::draw(painter, source); -} diff --git a/examples/effects/lighting/shadoweffect.h b/examples/effects/lighting/shadoweffect.h deleted file mode 100644 index 64314e5..0000000 --- a/examples/effects/lighting/shadoweffect.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SHADOWEFFECT_H -#define SHADOWEFFECT_H - -#include -#include - -class ShadowEffect: public QGraphicsDropShadowEffect -{ -public: - ShadowEffect(QGraphicsItem *item, QGraphicsItem *source); - - QRectF boundingRectFor(const QRectF &rect) const; - - void draw(QPainter *painter, QGraphicsEffectSource *source); - -private: - void adjustForItem(); - -private: - QColor m_color; - QGraphicsItem *item; - QGraphicsItem *m_lightSource; -}; - -#endif // SHADOWEFFECT_H -- cgit v0.12 From efc616f2a1a83bd4ca50aea9d40a0df005ada063 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 1 Sep 2009 16:39:30 +0200 Subject: QTreeView: exapnding nodes just after replacing the model wouldn't work The problem is that deleting the previous model would triggera delayed reset. This reset could happen after the model has changed and nodes are expanded. We can now cancel a reset when reset is called from another place (like when we set a new model). Note: autotest included Task-number: 245654 Reviewed-by: ogoffart --- src/gui/itemviews/qabstractitemview.cpp | 8 +++++--- src/gui/itemviews/qabstractitemview_p.h | 10 ++++++++++ tests/auto/qtreeview/tst_qtreeview.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 07c5454..ea98cb2 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -956,6 +956,7 @@ QModelIndex QAbstractItemView::currentIndex() const void QAbstractItemView::reset() { Q_D(QAbstractItemView); + d->delayedReset.stop(); //make sure we stop the timer QList::const_iterator it = d->editors.constBegin(); for (; it != d->editors.constEnd(); ++it) d->releaseEditor(it->editor); @@ -2208,7 +2209,9 @@ void QAbstractItemView::timerEvent(QTimerEvent *event) Q_D(QAbstractItemView); if (event->timerId() == d->fetchMoreTimer.timerId()) d->fetchMore(); - if (event->timerId() == d->autoScrollTimer.timerId()) + else if (event->timerId() == d->delayedReset.timerId()) + reset(); + else if (event->timerId() == d->autoScrollTimer.timerId()) doAutoScroll(); else if (event->timerId() == d->updateTimer.timerId()) d->updateDirtyRegion(); @@ -3132,9 +3135,8 @@ void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &, int, int) */ void QAbstractItemViewPrivate::_q_modelDestroyed() { - Q_Q(QAbstractItemView); model = QAbstractItemModelPrivate::staticEmptyModel(); - QMetaObject::invokeMethod(q, "reset", Qt::QueuedConnection); + doDelayedReset(); } /*! diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 4517941..434d644 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -328,6 +328,15 @@ public: QStyleOptionViewItemV4 viewOptionsV4() const; + void doDelayedReset() + { + //we delay the reset of the timer because some views (QTableView) + //with headers can't handle the fact that the model has been destroyed + //all _q_modelDestroyed slots must have been called + if (!delayedReset.isActive()) + delayedReset.start(0, q_func()); + } + QAbstractItemModel *model; QPointer itemDelegate; QMap > rowDelegates; @@ -389,6 +398,7 @@ public: QBasicTimer updateTimer; QBasicTimer delayedEditing; QBasicTimer delayedAutoScroll; //used when an item is clicked + QBasicTimer delayedReset; QAbstractItemView::ScrollMode verticalScrollMode; QAbstractItemView::ScrollMode horizontalScrollMode; diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index ef43c3a..6709807 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -233,6 +233,7 @@ private slots: void task239271_addRowsWithFirstColumnHidden(); void task254234_proxySort(); void task248022_changeSelection(); + void task245654_changeModelAndExpandAll(); }; class QtTestModel: public QAbstractItemModel @@ -3463,6 +3464,35 @@ void tst_QTreeView::task248022_changeSelection() QCOMPARE(view.selectionModel()->selectedIndexes().count(), list.count()); } +void tst_QTreeView::task245654_changeModelAndExpandAll() +{ + QTreeView view; + QStandardItemModel *model = new QStandardItemModel; + QStandardItem *top = new QStandardItem("top"); + QStandardItem *sub = new QStandardItem("sub"); + top->appendRow(sub); + model->appendRow(top); + view.setModel(model); + view.expandAll(); + QApplication::processEvents(); + QVERIFY(view.isExpanded(top->index())); + + //now let's try to delete the model + //then repopulate and expand again + delete model; + model = new QStandardItemModel; + top = new QStandardItem("top"); + sub = new QStandardItem("sub"); + top->appendRow(sub); + model->appendRow(top); + view.setModel(model); + view.expandAll(); + QApplication::processEvents(); + QVERIFY(view.isExpanded(top->index())); + +} + + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" -- cgit v0.12