diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-11-29 22:58:27 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-11-29 22:58:27 (GMT) |
commit | 1fe08312164a8eef87b3efe9b77452b86224999f (patch) | |
tree | 65d3147ae69860d9031ffaa86dcdd28f5d5fca21 | |
parent | 10b5653ad4f25c6f37d640facf4a5ef01fe25926 (diff) | |
parent | c2c31f30830a4e1e455a13321dd7bae6ac8b360f (diff) | |
download | Qt-1fe08312164a8eef87b3efe9b77452b86224999f.zip Qt-1fe08312164a8eef87b3efe9b77452b86224999f.tar.gz Qt-1fe08312164a8eef87b3efe9b77452b86224999f.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6
66 files changed, 1021 insertions, 730 deletions
diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index 057629d..58059d1 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -423,7 +423,7 @@ in the \l{Qt for Windows CE Requirements} document. "Control Panel->System->Advanced->Environment variables" and for older versions by editing \c{c:\autoexec.bat}. - Make sure the enviroment variables for your compiler are set. + Make sure the enviroment variables for your compiler are set. Visual Studio includes \c{vcvars32.bat} for that purpose - or simply use the "Visual Studio Command Prompt" from the Start menu. @@ -530,7 +530,7 @@ in the \l{Qt for the Symbian platform Requirements} document. \snippet doc/src/snippets/code/doc_src_installation.qdoc 25 - To run the demos on the emulator simply navigate to the directory of the demo + To run the demos on the emulator simply navigate to the directory of the demo you want to see and run: \snippet doc/src/snippets/code/doc_src_installation.qdoc 27 @@ -554,7 +554,7 @@ Symbian platform, in the \l{Qt for the Symbian platform Requirements} document. \note \bold {This document describes how to install and configure Qt for -the Symbian platform from scratch. +the Symbian platform from scratch. If you are using pre-built binaries, follow the instructions given in the \l{Installing Qt on the Symbian platform from a Binary Package} document.} @@ -616,7 +616,7 @@ If you are using pre-built binaries, follow the instructions given in the \snippet doc/src/snippets/code/doc_src_installation.qdoc 31 to build the tools using MinGW, and the libraries using SBSv2. - SBSv2 also known as a (\l{http://developer.symbian.org/wiki/index.php/Introduction_to_RAPTOR} {Raptor}) + SBSv2 (also known as \l{http://developer.symbian.org/wiki/index.php/Introduction_to_RAPTOR} {Raptor}) is a next-generation Symbian build system. SBSv2 is not officially supported by any of the S60 SDKs currently available from Forum Nokia. @@ -641,8 +641,8 @@ If you are using pre-built binaries, follow the instructions given in the \snippet doc/src/snippets/code/doc_src_installation.qdoc 29 - \note You will need to supply certificate that allows installation - of binaries with "All -Tcb" capability to your device. + \note You will need to supply certificate that allows installation + of binaries with "All -Tcb" capability to your device. Similarly, install fluidlauncher to the device: @@ -651,7 +651,7 @@ If you are using pre-built binaries, follow the instructions given in the This will create a self-signed \c fluidlauncher_armv5_urel.sis and install it to your device. - To run the demos on the emulator simply navigate to the directory of the demo + To run the demos on the emulator simply navigate to the directory of the demo you want to see and run: \snippet doc/src/snippets/code/doc_src_installation.qdoc 27 @@ -827,7 +827,7 @@ If you are using pre-built binaries, follow the instructions given in the when building Qt from its source code. On Debian-based GNU/Linux systems, for example, we recommend that you install the following development packages: - + \list \o libfontconfig1-dev \o libfreetype6-dev @@ -850,7 +850,7 @@ If you are using pre-built binaries, follow the instructions given in the The configure script will autodetect if OpenGL headers and libraries are installed on your system, and if so, it will include the QtOpenGL module in the Qt library. - + If your OpenGL headers or libraries are placed in a non-standard directory, you may need to change the \c QMAKE_INCDIR_OPENGL and/or \c QMAKE_LIBDIR_OPENGL in the config file for your system. @@ -954,7 +954,7 @@ If you are using pre-built binaries, follow the instructions given in the \table \header \o{1,2} Architecture \o{1,2} Compiler \o{2,1} QtCore \o{2,1} QtGui \o{2,1} QtNetwork \o{2,1} QtWebKit - \header \o Minimal \o Normal \o Minimal \o Normal \o Minimal \o Normal \o Minimal \o Normal + \header \o Minimal \o Normal \o Minimal \o Normal \o Minimal \o Normal \o Minimal \o Normal \row \o linux-x86-g++ \o GCC 4.2.4 \o 1.7M \o 2.7M \o 3.3M \o 9.9M \o 653K \o 1.1M \o N/A \o 17M \row \o linux-arm-g++ \o GCC 4.1.1 \o 1.9M \o 3.2M \o 4.1M \o 11M \o 507K \o 1.0M \o N/A \o 17M \row \o linux-mips-g++ (MIPS32) @@ -984,7 +984,7 @@ If you are using pre-built binaries, follow the instructions given in the Qt for the Symbian platform requires the following software installed on your development PC: \list - \o \l{http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide_cpp/}{Carbide.c++ v2.0.0 or higher} + \o \l{http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide_cpp/}{Carbide.c++ v2.0.0 or higher} \list \o \bold{Note:} It may be necessary to update the Carbide compiler. See \l{http://pepper.troll.no/s60prereleases/patches/}{here} for instructions how to check your @@ -1006,7 +1006,7 @@ If you are using pre-built binaries, follow the instructions given in the \o \bold{Note:} This is not required if you are using pre-built binary package. \endlist \o Building Qt libraries requires \l{http://www.arm.com/products/DevTools/RVCT.html}{RVCT} 2.2 [build 686] or later, - which is not available free of charge. + which is not available free of charge. \endlist Running Qt on real device requires the following packages to be installed on your device. diff --git a/examples/widgets/scribble/scribblearea.cpp b/examples/widgets/scribble/scribblearea.cpp index 6c9d8aa..2bc2a69 100644 --- a/examples/widgets/scribble/scribblearea.cpp +++ b/examples/widgets/scribble/scribblearea.cpp @@ -139,11 +139,12 @@ void ScribbleArea::mouseReleaseEvent(QMouseEvent *event) } //! [12] //! [13] -void ScribbleArea::paintEvent(QPaintEvent * /* event */) +void ScribbleArea::paintEvent(QPaintEvent *event) //! [13] //! [14] { QPainter painter(this); - painter.drawImage(QPoint(0, 0), image); + QRect dirtyRect = event->rect(); + painter.drawImage(dirtyRect, image, dirtyRect); } //! [14] diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp index 69b4941..d1586a5 100644 --- a/examples/widgets/softkeys/softkeys.cpp +++ b/examples/widgets/softkeys/softkeys.cpp @@ -66,11 +66,11 @@ MainWindow::MainWindow(QWidget *parent) infoLabel = new QLabel(tr(""), this); infoLabel->setContextMenuPolicy(Qt::NoContextMenu); - toggleButton = new QPushButton(tr("Custom softkeys"), this); + toggleButton = new QPushButton(tr("Custom"), this); toggleButton->setContextMenuPolicy(Qt::NoContextMenu); toggleButton->setCheckable(true); - pushButton = new QPushButton(tr("Open File Dialog"), this); + pushButton = new QPushButton(tr("File Dialog"), this); pushButton->setContextMenuPolicy(Qt::NoContextMenu); QComboBox* comboBox = new QComboBox(this); @@ -81,12 +81,12 @@ MainWindow::MainWindow(QWidget *parent) << QApplication::translate("MainWindow", "Selection3", 0, QApplication::UnicodeUTF8) ); - layout = new QVBoxLayout; - layout->addWidget(textEditor); - layout->addWidget(infoLabel); - layout->addWidget(toggleButton); - layout->addWidget(pushButton); - layout->addWidget(comboBox); + layout = new QGridLayout; + layout->addWidget(textEditor, 0, 0, 1, 2); + layout->addWidget(infoLabel, 1, 0, 1, 2); + layout->addWidget(toggleButton, 2, 0); + layout->addWidget(pushButton, 2, 1); + layout->addWidget(comboBox, 3, 0, 1, 2); central->setLayout(layout); fileMenu = menuBar()->addMenu(tr("&File")); diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h index 178ae64..1372fa4 100644 --- a/examples/widgets/softkeys/softkeys.h +++ b/examples/widgets/softkeys/softkeys.h @@ -61,7 +61,7 @@ public: MainWindow(QWidget *parent = 0); ~MainWindow(); private: - QVBoxLayout *layout; + QGridLayout *layout; QWidget *central; QTextEdit* textEditor; QLabel *infoLabel; diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp index 49cb468..ff3cf11 100644 --- a/examples/xml/saxbookmarks/mainwindow.cpp +++ b/examples/xml/saxbookmarks/mainwindow.cpp @@ -67,8 +67,11 @@ MainWindow::MainWindow() void MainWindow::open() { #if defined(Q_OS_SYMBIAN) - // Always look for bookmarks on the same drive where the application is installed to. - QString bookmarksFolder = QCoreApplication::applicationFilePath().left(1); + // Look for bookmarks on the same drive where the application is installed to, + // if drive is not read only. QDesktopServices::DataLocation does this check, + // and returns writable drive. + QString bookmarksFolder = + QDesktopServices::storageLocation(QDesktopServices::DataLocation).left(1); bookmarksFolder.append(":/Data/qt/saxbookmarks"); QDir::setCurrent(bookmarksFolder); #endif diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp index f3ec8e1..bfb03ab 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp @@ -975,7 +975,7 @@ HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc) face->glyphs_substituted = false; face->buffer = 0; - HB_Error error; + HB_Error error = HB_Err_Ok; HB_Stream stream; HB_Stream gdefStream; diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index ef4989b..299585a 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -229,7 +229,10 @@ void QUnifiedTimer::restartAnimationTimer() void QUnifiedTimer::timerEvent(QTimerEvent *event) { - if (event->timerId() == startStopAnimationTimer.timerId()) { + //in the case of consistent timing we make sure the orders in which events come is always the same + //for that purpose we do as if the startstoptimer would always fire before the animation timer + if ((consistentTiming && startStopAnimationTimer.isActive()) || + event->timerId() == startStopAnimationTimer.timerId()) { startStopAnimationTimer.stop(); //we transfer the waiting animations into the "really running" state @@ -247,7 +250,9 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event) time.start(); } } - } else if (event->timerId() == animationTimer.timerId()) { + } + + if (event->timerId() == animationTimer.timerId()) { // update current time on all top level animations updateAnimationsTime(); restartAnimationTimer(); diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 10a61ca..9335085 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -2546,9 +2546,9 @@ bool QAbstractItemModel::beginMoveRows(const QModelIndex &sourceParent, int sour int destinationLast = destinationChild + (sourceLast - sourceFirst); d->changes.push(QAbstractItemModelPrivate::Change(destinationParent, destinationChild, destinationLast)); - d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical); emit rowsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild); emit layoutAboutToBeChanged(); + d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical); return true; } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 95602d9..4321c59 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -145,8 +145,7 @@ QObjectPrivate::QObjectPrivate(int version) receiveChildEvents = true; postedEvents = 0; extraData = 0; - for (uint i = 0; i < (sizeof connectedSignals / sizeof connectedSignals[0]); ++i) - connectedSignals[i] = 0; + connectedSignals = 0; inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; @@ -2937,13 +2936,9 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index, QObjectPrivate *const sender_d = QObjectPrivate::get(s); if (signal_index < 0) { - for (uint i = 0; i < (sizeof sender_d->connectedSignals - / sizeof sender_d->connectedSignals[0] ); ++i) - sender_d->connectedSignals[i] = ~0u; - } else if (signal_index < (int)sizeof sender_d->connectedSignals * 8) { - uint n = (signal_index / (8 * sizeof sender_d->connectedSignals[0])); - sender_d->connectedSignals[n] |= (1 << (signal_index - n * 8 - * sizeof sender_d->connectedSignals[0])); + sender_d->connectedSignals = ~ulong(0); + } else if (signal_index < (int)sizeof(sender_d->connectedSignals) * 8) { + sender_d->connectedSignals |= ulong(1) << signal_index; } return true; @@ -3201,15 +3196,9 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign computeOffsets(m, &signalOffset, &methodOffset); int signal_index = signalOffset + local_signal_index; - if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8 - && !qt_signal_spy_callback_set.signal_begin_callback - && !qt_signal_spy_callback_set.signal_end_callback) { - uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0])); - uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]); - if ((sender->d_func()->connectedSignals[n] & m) == 0) - // nothing connected to these signals, and no spy - return; - } + + if (!sender->d_func()->isSignalConnected(signal_index)) + return; // nothing connected to these signals, and no spy if (sender->d_func()->blockSig) return; @@ -3370,28 +3359,6 @@ int QObjectPrivate::signalIndex(const char *signalName) const return relative_index + signalOffset; } -/*! \internal - - Returns true if the signal with index \a signal_index from object \a sender is connected. - Signals with indices above a certain range are always considered connected (see connectedSignals - in QObjectPrivate). If a signal spy is installed, all signals are considered connected. - - \a signal_index must be the index returned by QObjectPrivate::signalIndex; -*/ -bool QObjectPrivate::isSignalConnected(int signal_index) const -{ - if (signal_index < (int)sizeof(connectedSignals) * 8 - && !qt_signal_spy_callback_set.signal_begin_callback - && !qt_signal_spy_callback_set.signal_end_callback) { - uint n = (signal_index / (8 * sizeof connectedSignals[0])); - uint m = 1 << (signal_index - n * 8 * sizeof connectedSignals[0]); - if ((connectedSignals[n] & m) == 0) - // nothing connected to these signals, and no spy - return false; - } - return true; -} - /***************************************************************************** Properties *****************************************************************************/ diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index f087407..f899c78 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -172,7 +172,7 @@ public: } int signalIndex(const char *signalName) const; - bool isSignalConnected(int signalIdx) const; + inline bool isSignalConnected(int signalIdx) const; public: QString objectName; @@ -183,7 +183,7 @@ public: Connection *senders; // linked list of connections connected to this object Sender *currentSender; // object currently activating the object - mutable quint32 connectedSignals[2]; // 64-bit, so doesn't cause padding on 64-bit platforms + mutable ulong connectedSignals; #ifdef QT3_SUPPORT QList<QObject *> pendingChildInsertedEvents; @@ -205,6 +205,23 @@ public: int *deleteWatch; }; +/*! \internal + + Returns true if the signal with index \a signal_index from object \a sender is connected. + Signals with indices above a certain range are always considered connected (see connectedSignals + in QObjectPrivate). If a signal spy is installed, all signals are considered connected. + + \a signal_index must be the index returned by QObjectPrivate::signalIndex; +*/ +inline bool QObjectPrivate::isSignalConnected(int signal_index) const +{ + return signal_index >= (int)sizeof(connectedSignals) * 8 + || qt_signal_spy_callback_set.signal_begin_callback + || qt_signal_spy_callback_set.signal_end_callback + || (connectedSignals & (ulong(1) << signal_index)); +} + + inline void q_guard_addGuard(QGuard<QObject> *g) { QObjectPrivate *p = QObjectPrivate::get(g->o); diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index c0e4890..cf28dc4 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -236,6 +236,18 @@ bool QEglContext::makeCurrent(EGLSurface surface) currentSurface = surface; setCurrentContext(apiType, this); + // Force the right API to be bound before making the context current. + // The EGL implementation should be able to figure this out from ctx, + // but some systems require the API to be explicitly set anyway. +#ifdef EGL_OPENGL_ES_API + if (apiType == QEgl::OpenGL) + eglBindAPI(EGL_OPENGL_ES_API); +#endif +#ifdef EGL_OPENVG_API + if (apiType == QEgl::OpenVG) + eglBindAPI(EGL_OPENVG_API); +#endif + bool ok = eglMakeCurrent(dpy, surface, surface, ctx); if (!ok) qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError()); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 94a37a0..bb45e7e 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -755,7 +755,6 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch case QGraphicsItem::ItemClipsChildrenToShape: flag = AncestorClipsChildren; enabled = flags & QGraphicsItem::ItemClipsChildrenToShape; - invalidateCachedClipPathRecursively(/*childrenOnly=*/true); break; case QGraphicsItem::ItemIgnoresTransformations: flag = AncestorIgnoresTransformations; @@ -1104,9 +1103,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) parent->itemChange(QGraphicsItem::ItemChildAddedChange, thisPointerVariant); if (scene) { if (!implicitUpdate) - scene->d_func()->markDirty(q_ptr, QRect(), - /*invalidateChildren=*/false, - /*maybeDirtyClipPath=*/true); + scene->d_func()->markDirty(q_ptr); // Re-enable scene pos notifications for new ancestors if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) @@ -1147,11 +1144,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) setEnabledHelper(true, /* explicit = */ false); // If the item is being deleted, the whole scene will be updated. - if (scene) { - scene->d_func()->markDirty(q_ptr, QRect(), - /*invalidateChildren=*/false, - /*maybeDirtyClipPath=*/true); - } + if (scene) + scene->d_func()->markDirty(q_ptr); } } @@ -1732,9 +1726,6 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->updateAncestorFlag(ItemClipsChildrenToShape); } - if ((flags & ItemClipsToShape) != (oldFlags & ItemClipsToShape)) - d_ptr->invalidateCachedClipPath(); - if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) { // Item children clipping changes. Propagate the ancestor flag to // all children. @@ -1777,9 +1768,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) else d_ptr->scene->d_func()->unregisterScenePosItem(this); } - d_ptr->scene->d_func()->markDirty(this, QRectF(), - /*invalidateChildren=*/true, - /*maybeDirtyClipPath*/true); + d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true); } // Notify change. @@ -2127,12 +2116,8 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData)); if (c) c->purge(); - if (scene) { - scene->d_func()->markDirty(q_ptr, QRectF(), - /*invalidateChildren=*/false, - /*maybeDirtyClipPath=*/false, - /*force=*/true); - } + if (scene) + scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); } // Certain properties are dropped as an item becomes invisible. @@ -2542,7 +2527,6 @@ void QGraphicsItem::setOpacity(qreal opacity) #endif //QT_NO_GRAPHICSEFFECT d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true, - /*maybeDirtyClipPath=*/false, /*force=*/false, /*ignoreOpacity=*/true); } @@ -2590,8 +2574,11 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) d_ptr->graphicsEffect = 0; if (oldEffectPrivate) { oldEffectPrivate->setGraphicsEffectSource(0); // deletes the current source. - if (d_ptr->scene) // Update the views directly. - d_ptr->scene->d_func()->markDirty(this, QRectF(), false, false, false, false, true); + if (d_ptr->scene) { // Update the views directly. + d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/false, + /*force=*/false, /*ignoreOpacity=*/false, + /*removeItemFromScene=*/true); + } } } else { // Set new effect. @@ -3399,7 +3386,6 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos) { Q_Q(QGraphicsItem); inSetPosHelper = 1; - updateCachedClipPathFromSetPosHelper(pos); if (scene) q->prepareGeometryChange(); QPointF oldPos = this->pos; @@ -4535,22 +4521,12 @@ bool QGraphicsItem::isClipped() const QPainterPath QGraphicsItem::clipPath() const { Q_D(const QGraphicsItem); - if (!d->dirtyClipPath) - return d->emptyClipPath ? QPainterPath() : d->cachedClipPath; - - if (!isClipped()) { - d_ptr->setCachedClipPath(QPainterPath()); - return d->cachedClipPath; - } + if (!isClipped()) + return QPainterPath(); const QRectF thisBoundingRect(boundingRect()); - if (thisBoundingRect.isEmpty()) { - if (d_ptr->flags & ItemClipsChildrenToShape) - d_ptr->setEmptyCachedClipPathRecursively(); - else - d_ptr->setEmptyCachedClipPath(); + if (thisBoundingRect.isEmpty()) return QPainterPath(); - } QPainterPath clip; // Start with the item's bounding rect. @@ -4561,40 +4537,18 @@ QPainterPath QGraphicsItem::clipPath() const const QGraphicsItem *lastParent = this; // Intersect any in-between clips starting at the top and moving downwards. - bool foundValidClipPath = false; while ((parent = parent->d_ptr->parent)) { if (parent->d_ptr->flags & ItemClipsChildrenToShape) { // Map clip to the current parent and intersect with its shape/clipPath clip = lastParent->itemTransform(parent).map(clip); - if ((foundValidClipPath = !parent->d_ptr->dirtyClipPath && parent->isClipped())) { - if (parent->d_ptr->emptyClipPath) { - if (d_ptr->flags & ItemClipsChildrenToShape) - d_ptr->setEmptyCachedClipPathRecursively(); - else - d_ptr->setEmptyCachedClipPath(); - return QPainterPath(); - } - clip = clip.intersected(parent->d_ptr->cachedClipPath); - if (!(parent->d_ptr->flags & ItemClipsToShape)) - clip = clip.intersected(parent->shape()); - } else { - clip = clip.intersected(parent->shape()); - } - - if (clip.isEmpty()) { - if (d_ptr->flags & ItemClipsChildrenToShape) - d_ptr->setEmptyCachedClipPathRecursively(); - else - d_ptr->setEmptyCachedClipPath(); + clip = clip.intersected(parent->shape()); + if (clip.isEmpty()) return clip; - } lastParent = parent; } - if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) - || foundValidClipPath) { + if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) break; - } } if (lastParent != this) { @@ -4607,7 +4561,6 @@ QPainterPath QGraphicsItem::clipPath() const if (d->flags & ItemClipsToShape) clip = clip.intersected(shape()); - d_ptr->setCachedClipPath(clip); return clip; } @@ -5026,15 +4979,14 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity) \internal Returns true if we can discard an update request; otherwise false. */ -bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping, bool ignoreVisibleBit, - bool ignoreDirtyBit, bool ignoreOpacity) const +bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreVisibleBit, bool ignoreDirtyBit, + bool ignoreOpacity) const { // No scene, or if the scene is updating everything, means we have nothing // to do. The only exception is if the scene tracks the growing scene rect. return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) - || (!ignoreClipping && (childrenClippedToShape() && isClippedAway())) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent()); } @@ -5169,109 +5121,6 @@ void QGraphicsItemPrivate::removeExtraItemCache() unsetExtra(ExtraCacheData); } -void QGraphicsItemPrivate::setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect) -{ - setEmptyCachedClipPath(); - - const bool checkRect = !emptyIfOutsideThisRect.isNull() - && !(flags & QGraphicsItem::ItemClipsChildrenToShape); - for (int i = 0; i < children.size(); ++i) { - if (!checkRect) { - children.at(i)->d_ptr->setEmptyCachedClipPathRecursively(); - continue; - } - - QGraphicsItem *child = children.at(i); - const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect); - if (rect.intersects(child->boundingRect())) - child->d_ptr->invalidateCachedClipPathRecursively(false, rect); - else - child->d_ptr->setEmptyCachedClipPathRecursively(rect); - } -} - -void QGraphicsItemPrivate::invalidateCachedClipPathRecursively(bool childrenOnly, const QRectF &emptyIfOutsideThisRect) -{ - if (!childrenOnly) - invalidateCachedClipPath(); - - const bool checkRect = !emptyIfOutsideThisRect.isNull(); - for (int i = 0; i < children.size(); ++i) { - if (!checkRect) { - children.at(i)->d_ptr->invalidateCachedClipPathRecursively(false); - continue; - } - - QGraphicsItem *child = children.at(i); - const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect); - if (rect.intersects(child->boundingRect())) - child->d_ptr->invalidateCachedClipPathRecursively(false, rect); - else - child->d_ptr->setEmptyCachedClipPathRecursively(rect); - } -} - -void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &newPos) -{ - Q_ASSERT(inSetPosHelper); - - if (inDestructor || !(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) - return; // Not clipped by any ancestor. - - // Find closest clip ancestor and transform. - Q_Q(QGraphicsItem); - // COMBINE - QTransform thisToParentTransform = QTransform::fromTranslate(newPos.x(), newPos.y()); - if (transformData) - thisToParentTransform = transformData->computedFullTransform(&thisToParentTransform); - QGraphicsItem *clipParent = parent; - while (clipParent && !clipParent->d_ptr->inDestructor && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) { - thisToParentTransform *= clipParent->d_ptr->transformToParent(); - clipParent = clipParent->d_ptr->parent; - } - - // Ensure no parents are currently being deleted. This can only - // happen if the item is moved by a dying ancestor. - QGraphicsItem *p = clipParent; - while (p) { - if (p->d_ptr->inDestructor) - return; - p = p->d_ptr->parent; - } - - // From here everything is calculated in clip parent's coordinates. - const QRectF parentBoundingRect(clipParent->boundingRect()); - const QRectF thisBoundingRect(thisToParentTransform.mapRect(q->boundingRect())); - - if (!parentBoundingRect.intersects(thisBoundingRect)) { - // Item is moved outside the clip parent's bounding rect, - // i.e. it is fully clipped and the clip path is empty. - if (flags & QGraphicsItem::ItemClipsChildrenToShape) - setEmptyCachedClipPathRecursively(); - else - setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentBoundingRect)); - return; - } - - const QPainterPath parentClip(clipParent->isClipped() ? clipParent->clipPath() : clipParent->shape()); - if (parentClip.contains(thisBoundingRect)) - return; // Item is inside the clip parent's shape. No update required. - - const QRectF parentClipRect(parentClip.controlPointRect()); - if (!parentClipRect.intersects(thisBoundingRect)) { - // Item is moved outside the clip parent's shape, - // i.e. it is fully clipped and the clip path is empty. - if (flags & QGraphicsItem::ItemClipsChildrenToShape) - setEmptyCachedClipPathRecursively(); - else - setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentClipRect)); - } else { - // Item is partially inside the clip parent's shape, - // i.e. the cached clip path must be invalidated. - invalidateCachedClipPathRecursively(false, thisToParentTransform.inverted().mapRect(parentClipRect)); - } -} - // Traverses all the ancestors up to the top-level and updates the pointer to // always point to the top-most item that has a dirty scene transform. // It then backtracks to the top-most dirty item and start calculating the @@ -7288,9 +7137,7 @@ void QGraphicsItem::prepareGeometryChange() QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); scenePrivate->index->prepareBoundingRectChange(this); - scenePrivate->markDirty(this, QRectF(), - /*invalidateChildren=*/true, - /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper); + scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true); // For compatibility reasons, we have to update the item's old geometry // if someone is connected to the changed signal or the scene has no views. @@ -7313,16 +7160,6 @@ void QGraphicsItem::prepareGeometryChange() // ### Only do this if the parent's effect applies to the entire subtree. parent->d_ptr->notifyBoundingRectChanged = 1; } - - if (d_ptr->inSetPosHelper) - return; - - if (d_ptr->flags & ItemClipsChildrenToShape - || d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) { - d_ptr->invalidateCachedClipPathRecursively(); - } else { - d_ptr->invalidateCachedClipPath(); - } } /*! @@ -9604,9 +9441,11 @@ void QGraphicsTextItem::setDefaultTextColor(const QColor &col) { QTextControl *c = dd->textControl(); QPalette pal = c->palette(); + QColor old = pal.color(QPalette::Text); pal.setColor(QPalette::Text, col); c->setPalette(pal); - update(); + if (old != col) + update(); } /*! diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 75c8246..d6ffb1a 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -152,8 +152,6 @@ public: dirty(0), dirtyChildren(0), localCollisionHack(0), - dirtyClipPath(1), - emptyClipPath(0), inSetPosHelper(0), needSortChildren(1), // ### can be 0 by default? allChildrenDirty(0), @@ -221,7 +219,7 @@ public: void appendGraphicsTransform(QGraphicsTransform *t); void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); - bool discardUpdateRequest(bool ignoreClipping = false, bool ignoreVisibleBit = false, + bool discardUpdateRequest(bool ignoreVisibleBit = false, bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; int depth() const; #ifndef QT_NO_GRAPHICSEFFECT @@ -307,26 +305,6 @@ public: QGraphicsItemCache *extraItemCache() const; void removeExtraItemCache(); - inline void setCachedClipPath(const QPainterPath &path) - { - cachedClipPath = path; - dirtyClipPath = 0; - emptyClipPath = 0; - } - - inline void setEmptyCachedClipPath() - { - emptyClipPath = 1; - dirtyClipPath = 0; - } - - void setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect = QRectF()); - - inline void invalidateCachedClipPath() - { /*static int count = 0 ;qWarning("%i", ++count);*/ dirtyClipPath = 1; emptyClipPath = 0; } - - void invalidateCachedClipPathRecursively(bool childrenOnly = false, const QRectF &emptyIfOutsideThisRect = QRectF()); - void updateCachedClipPathFromSetPosHelper(const QPointF &newPos); void ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem); inline void ensureSceneTransform() { @@ -409,17 +387,12 @@ public: return true; } - inline bool isClippedAway() const - { return !dirtyClipPath && q_func()->isClipped() && (emptyClipPath || cachedClipPath.isEmpty()); } - inline bool childrenClippedToShape() const { return (flags & QGraphicsItem::ItemClipsChildrenToShape) || children.isEmpty(); } inline bool isInvisible() const { - return !visible - || (childrenClippedToShape() && isClippedAway()) - || (childrenCombineOpacity() && isFullyTransparent()); + return !visible || (childrenCombineOpacity() && isFullyTransparent()); } void setFocusHelper(Qt::FocusReason focusReason, bool climb); @@ -435,7 +408,6 @@ public: inline void sendScenePosChange(); virtual void siblingOrderChange(); - QPainterPath cachedClipPath; QRectF childrenBoundingRect; QRectF needsRepaint; QMap<QWidget *, QRect> paintedViewBoundingRects; @@ -480,8 +452,6 @@ public: quint32 dirty : 1; quint32 dirtyChildren : 1; quint32 localCollisionHack : 1; - quint32 dirtyClipPath : 1; - quint32 emptyClipPath : 1; quint32 inSetPosHelper : 1; quint32 needSortChildren : 1; quint32 allChildrenDirty : 1; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 10d251d..8777cdc 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -555,7 +555,8 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) // Clear focus on the item to remove any reference in the focusWidget chain. item->clearFocus(); - markDirty(item, QRectF(), false, false, false, false, /*removingItemFromScene=*/true); + markDirty(item, QRectF(), /*invalidateChildren=*/false, /*force=*/false, + /*ignoreOpacity=*/false, /*removingItemFromScene=*/true); if (item->d_ptr->inDestructor) { // The item is actually in its destructor, we call the special method in the index. @@ -4759,15 +4760,13 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q } void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren, - bool maybeDirtyClipPath, bool force, bool ignoreOpacity, - bool removingItemFromScene) + bool force, bool ignoreOpacity, bool removingItemFromScene) { Q_ASSERT(item); if (updateAll) return; - if (item->d_ptr->discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath, - /*ignoreVisibleBit=*/force, + if (item->d_ptr->discardUpdateRequest(/*ignoreVisibleBit=*/force, /*ignoreDirtyBit=*/removingItemFromScene || invalidateChildren, /*ignoreOpacity=*/ignoreOpacity)) { if (item->d_ptr->dirty) { diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index fdec466..69e4d5b 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -78,7 +78,7 @@ class QGraphicsSceneIndex; class QGraphicsView; class QGraphicsWidget; -class QGraphicsScenePrivate : public QObjectPrivate +class Q_AUTOTEST_EXPORT QGraphicsScenePrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QGraphicsScene) public: @@ -222,8 +222,7 @@ public: QRegion *, QWidget *, qreal, const QTransform *const, bool, bool); void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false, - bool maybeDirtyClipPath = false, bool force = false, bool ignoreOpacity = false, - bool removingItemFromScene = false); + bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false); void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false, qreal parentOpacity = qreal(1.0)); @@ -266,6 +265,7 @@ public: { if (needSortTopLevelItems) { qSort(topLevelItems.begin(), topLevelItems.end(), qt_notclosestLeaf); + topLevelSequentialOrdering = false; needSortTopLevelItems = false; } } diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index d9c65bb..f6c06d5 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -385,8 +385,6 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) QSizeF oldSize = size(); QGraphicsLayoutItem::setGeometry(newGeom); - wd->invalidateCachedClipPathRecursively(); - // Send resize event bool resized = newGeom.size() != oldSize; if (resized) { diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index 35322e9..650075b 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -55,20 +55,11 @@ Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64 = 0; Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0; Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0; - -QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks = 0; - - -QImagePixmapCleanupHooks::QImagePixmapCleanupHooks() -{ - qt_image_and_pixmap_cleanup_hooks = this; -} +Q_GLOBAL_STATIC(QImagePixmapCleanupHooks, qt_image_and_pixmap_cleanup_hooks) QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance() { - if (!qt_image_and_pixmap_cleanup_hooks) - qt_image_and_pixmap_cleanup_hooks = new QImagePixmapCleanupHooks; - return qt_image_and_pixmap_cleanup_hooks; + return qt_image_and_pixmap_cleanup_hooks(); } void QImagePixmapCleanupHooks::addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook) @@ -105,9 +96,8 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks[i](pm); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->pixmapModificationHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->pixmapModificationHooks[i](pm); if (qt_pixmap_cleanup_hook_64) qt_pixmap_cleanup_hook_64(pm->cacheKey()); @@ -115,9 +105,8 @@ void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm) void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks[i](pm); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->pixmapDestructionHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->pixmapDestructionHooks[i](pm); if (qt_pixmap_cleanup_hook_64) qt_pixmap_cleanup_hook_64(pm->cacheKey()); @@ -125,9 +114,8 @@ void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm) void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->imageHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->imageHooks[i](key); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->imageHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->imageHooks[i](key); if (qt_image_cleanup_hook_64) qt_image_cleanup_hook_64(key); diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h index 9e490d7..dfc5f28 100644 --- a/src/gui/image/qimagepixmapcleanuphooks_p.h +++ b/src/gui/image/qimagepixmapcleanuphooks_p.h @@ -61,13 +61,10 @@ typedef void (*_qt_image_cleanup_hook_64)(qint64); typedef void (*_qt_pixmap_cleanup_hook_pm)(QPixmap*); class QImagePixmapCleanupHooks; -extern QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks; class Q_GUI_EXPORT QImagePixmapCleanupHooks { public: - QImagePixmapCleanupHooks(); - static QImagePixmapCleanupHooks *instance(); static void enableCleanupHooks(const QImage &image); diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index f1ae3d2..fc82f30 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -1153,6 +1153,8 @@ void QSortFilterProxyModelPrivate::_q_sourceAboutToBeReset() { Q_Q(QSortFilterProxyModel); q->beginResetModel(); + invalidatePersistentIndexes(); + clear_mapping(); } void QSortFilterProxyModelPrivate::_q_sourceReset() @@ -1470,6 +1472,8 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) { Q_D(QSortFilterProxyModel); + beginResetModel(); + disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); @@ -1551,7 +1555,7 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); d->clear_mapping(); - reset(); + endResetModel(); if (d->update_source_sort_column() && d->dynamic_sortfilter) d->sort(); } diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index fb2bc72..89d961c 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -133,36 +133,46 @@ private: TTimeIntervalMicroSeconds iDuration; }; +static QS60Beep* qt_S60Beep = 0; + QS60Beep::~QS60Beep() { + if (iToneUtil) { + switch (iState) { + case EBeepPlaying: + iToneUtil->CancelPlay(); + break; + case EBeepNotPrepared: + iToneUtil->CancelPrepare(); + break; + } + } delete iToneUtil; } QS60Beep* QS60Beep::NewL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) { - QS60Beep* self=new (ELeave) QS60Beep(); + QS60Beep* self = new (ELeave) QS60Beep(); CleanupStack::PushL(self); self->ConstructL(aFrequency, aDuration); CleanupStack::Pop(); return self; -}; +} void QS60Beep::ConstructL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) { - iToneUtil=CMdaAudioToneUtility::NewL(*this); - iState=EBeepNotPrepared; - iFrequency=aFrequency; - iDuration=aDuration; - iToneUtil->PrepareToPlayTone(iFrequency,iDuration); + iToneUtil = CMdaAudioToneUtility::NewL(*this); + iState = EBeepNotPrepared; + iFrequency = aFrequency; + iDuration = aDuration; + iToneUtil->PrepareToPlayTone(iFrequency, iDuration); } void QS60Beep::Play() { - if (iState != EBeepNotPrepared) { - if (iState == EBeepPlaying) { - iToneUtil->CancelPlay(); - iState = EBeepPrepared; - } + if (iState == EBeepPlaying) { + iToneUtil->CancelPlay(); + iState = EBeepPrepared; } iToneUtil->Play(); @@ -173,13 +183,14 @@ void QS60Beep::MatoPrepareComplete(TInt aError) { if (aError == KErrNone) { iState = EBeepPrepared; + Play(); } } void QS60Beep::MatoPlayComplete(TInt aError) { Q_UNUSED(aError); - iState=EBeepPrepared; + iState = EBeepPrepared; } @@ -1226,6 +1237,10 @@ void qt_init(QApplicationPrivate * /* priv */, int) *****************************************************************************/ void qt_cleanup() { + if(qt_S60Beep) { + delete qt_S60Beep; + qt_S60Beep = 0; + } QFontCache::cleanup(); // Has to happen now, since QFontEngineS60 has FBS handles // S60 structure and window server session are freed in eventdispatcher destructor as they are needed there @@ -1467,14 +1482,13 @@ void QApplication::setCursorFlashTime(int msecs) void QApplication::beep() { - TInt frequency=440; - TTimeIntervalMicroSeconds duration(500000); - QS60Beep* beep=NULL; - TRAPD(err, beep=QS60Beep::NewL(frequency, duration)); - if (!err) - beep->Play(); - delete beep; - beep=NULL; + if (!qt_S60Beep) { + TInt frequency = 880; + TTimeIntervalMicroSeconds duration(500000); + TRAP_IGNORE(qt_S60Beep=QS60Beep::NewL(frequency, duration)); + } + if (qt_S60Beep) + qt_S60Beep->Play(); } /*! diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index fbb9115..b389054 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4605,7 +4605,7 @@ void QWidgetPrivate::updateFont(const QFont &font) if (!q->parentWidget() && extra && extra->proxyWidget) { QGraphicsProxyWidget *p = extra->proxyWidget; inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve(); - } else + } else #endif //QT_NO_GRAPHICSVIEW if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { inheritedFontResolveMask = 0; @@ -9897,13 +9897,13 @@ void QWidget::scroll(int dx, int dy) Q_D(QWidget); #ifndef QT_NO_GRAPHICSVIEW if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) { - // Graphics View maintains its own dirty region as a list of rects; - // until we can connect item updates directly to the view, we must - // separately add a translated dirty region. - if (!d->dirty.isEmpty()) { - foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) - proxy->update(rect); - } + // Graphics View maintains its own dirty region as a list of rects; + // until we can connect item updates directly to the view, we must + // separately add a translated dirty region. + if (!d->dirty.isEmpty()) { + foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) + proxy->update(rect); + } proxy->scroll(dx, dy, proxy->subWidgetRect(this)); return; } @@ -9932,13 +9932,13 @@ void QWidget::scroll(int dx, int dy, const QRect &r) Q_D(QWidget); #ifndef QT_NO_GRAPHICSVIEW if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) { - // Graphics View maintains its own dirty region as a list of rects; - // until we can connect item updates directly to the view, we must - // separately add a translated dirty region. - if (!d->dirty.isEmpty()) { - foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) - proxy->update(rect); - } + // Graphics View maintains its own dirty region as a list of rects; + // until we can connect item updates directly to the view, we must + // separately add a translated dirty region. + if (!d->dirty.isEmpty()) { + foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) + proxy->update(rect); + } proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint())); return; } diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 8226797..1b8f413 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -949,6 +949,8 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) return; QWidgetBackingStore *wbs = x->backingStore; + if (!wbs) + return; static int accelEnv = -1; if (accelEnv == -1) { diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 48629d1..fc1863f 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5886,7 +5886,12 @@ void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption Draws the text item \a ti at position \a p. */ -/*! \internal +/*! + \fn void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti) + + \internal + \since 4.1 + Draws the text item \a ti at position \a p. This method ignores the painters background mode and @@ -5899,34 +5904,57 @@ void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption ignored aswell. You'll need to pass in the correct flags to get underlining and strikeout. */ -static QPainterPath generateWavyPath(qreal minWidth, qreal maxRadius, QPaintDevice *device) + +static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen) { - extern int qt_defaultDpi(); + const qreal radiusBase = qMax(qreal(1), maxRadius); + + QString key = QLatin1String("WaveUnderline-"); + key += pen.color().name(); + key += QLatin1Char('-'); + key += QString::number(radiusBase); + + QPixmap pixmap; + if (QPixmapCache::find(key, pixmap)) + return pixmap; + + const qreal halfPeriod = qMax(qreal(2), radiusBase * 1.61803399); // the golden ratio + const int width = qCeil(100 / (2 * halfPeriod)) * (2 * halfPeriod); + const int radius = qFloor(radiusBase); + QPainterPath path; - bool up = true; - const qreal radius = qMax(qreal(.5), qMin(qreal(1.25 * device->logicalDpiY() / qt_defaultDpi()), maxRadius)); - qreal xs, ys; - int i = 0; - path.moveTo(0, radius); - do { - xs = i*(2*radius); - ys = 0; + qreal xs = 0; + qreal ys = radius; - qreal remaining = minWidth - xs; - qreal angle = 180; + while (xs < width) { + xs += halfPeriod; + ys = -ys; + path.quadTo(xs - halfPeriod / 2, ys, xs, 0); + } - // cut-off at the last arc segment - if (remaining < 2 * radius) - angle = 180 * remaining / (2 * radius); + pixmap = QPixmap(width, radius * 2); + pixmap.fill(Qt::transparent); + { + QPen wavePen = pen; + wavePen.setCapStyle(Qt::SquareCap); + + // This is to protect against making the line too fat, as happens on Mac OS X + // due to it having a rather thick width for the regular underline. + const qreal maxPenWidth = .8 * radius; + if (wavePen.widthF() > maxPenWidth) + wavePen.setWidth(maxPenWidth); - path.arcTo(xs, ys, 2*radius, 2*radius, 180, up ? angle : -angle); + QPainter imgPainter(&pixmap); + imgPainter.setPen(wavePen); + imgPainter.setRenderHint(QPainter::Antialiasing); + imgPainter.translate(0, radius); + imgPainter.drawPath(path); + } - up = !up; - ++i; - } while (xs + 2*radius < minWidth); + QPixmapCache::insert(key, pixmap); - return path; + return pixmap; } static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QTextItemInt &ti) @@ -5947,9 +5975,11 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const pen.setCapStyle(Qt::FlatCap); QLineF line(pos.x(), pos.y(), pos.x() + ti.width.toReal(), pos.y()); + + const qreal underlineOffset = fe->underlinePosition().toReal(); // deliberately ceil the offset to avoid the underline coming too close to // the text above it. - const qreal underlinePos = pos.y() + qCeil(fe->underlinePosition().toReal()); + const qreal underlinePos = pos.y() + qCeil(underlineOffset); if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle)); @@ -5957,16 +5987,18 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const if (underlineStyle == QTextCharFormat::WaveUnderline) { painter->save(); - painter->setRenderHint(QPainter::Antialiasing); - painter->translate(pos.x(), underlinePos); + painter->translate(0, pos.y() + 1); QColor uc = ti.charFormat.underlineColor(); if (uc.isValid()) - painter->setPen(uc); + pen.setColor(uc); - painter->drawPath(generateWavyPath(ti.width.toReal(), - fe->underlinePosition().toReal(), - painter->device())); + // Adapt wave to underlineOffset or pen width, whatever is larger, to make it work on all platforms + const QPixmap wave = generateWavyPixmap(qMax(underlineOffset, pen.widthF()), pen); + const int descent = (int) ti.descent.toReal(); + + painter->setBrushOrigin(painter->brushOrigin().x(), 0); + painter->fillRect(pos.x(), 0, qCeil(ti.width.toReal()), qMin(wave.height(), descent), wave); painter->restore(); } else if (underlineStyle != QTextCharFormat::NoUnderline) { QLineF underLine(line.x1(), underlinePos, line.x2(), underlinePos); @@ -6001,10 +6033,6 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const painter->setBrush(oldBrush); } -/*! - \internal - \since 4.1 -*/ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) { #ifdef QT_DEBUG_DRAW diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 51c2a96..4075cf7 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -4843,9 +4843,11 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex uint sc = SC_TitleBarMinButton; ThemeTitleBarWidget tbw = kThemeWidgetCollapseBox; bool active = titlebar->state & State_Active; - int border = 2; - titleBarRect.origin.x += border; - titleBarRect.origin.y -= border; + if (qMacVersion() < QSysInfo::MV_10_6) { + int border = 2; + titleBarRect.origin.x += border; + titleBarRect.origin.y -= border; + } while (sc <= SC_TitleBarCloseButton) { if (sc & titlebar->subControls) { diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index ee10ff6..dca78ca 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -144,7 +144,7 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, - {SE_Editor, QS60StyleEnums::SP_QsnFrNotepadCenter}, + {SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, }; static const int frameElementsCount = @@ -459,11 +459,6 @@ void QS60StylePrivate::setThemePalette(QApplication *app) const storeThemePalette(&widgetPalette); } -void QS60StylePrivate::setThemePalette(QStyleOption *option) const -{ - setThemePalette(&option->palette); -} - QPalette* QS60StylePrivate::themePalette() { return m_themePalette; @@ -640,16 +635,16 @@ void QS60StylePrivate::setThemePalette(QWidget *widget) const { if(!widget) return; - QPalette widgetPalette = QApplication::palette(widget); //header view and its viewport need to be set 100% transparent button color, since drawing code will //draw transparent theme graphics to table column and row headers. if (qobject_cast<QHeaderView *>(widget)){ + QPalette widgetPalette = QApplication::palette(widget); widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); QHeaderView* header = qobject_cast<QHeaderView *>(widget); widgetPalette.setColor(QPalette::Button, Qt::transparent ); - if ( header->viewport() ) + if (header->viewport()) header->viewport()->setPalette(widgetPalette); QApplication::setPalette(widgetPalette, "QHeaderView"); } @@ -812,7 +807,7 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag case QS60StyleEnums::SP_QgnGrafTabActiveL: //Returned QSize for tabs must not be square, but narrow rectangle with width:height //ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). - result.setWidth(10); + result.setWidth(result.height()>>1); break; case QS60StyleEnums::SP_QgnIndiSliderEdit: result.scale(pixelMetric(QStyle::PM_SliderLength), @@ -870,7 +865,7 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag return result; } -bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush) +bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush) { //If brush is not changed from style's default values, draw theme graphics. return (backgroundBrush.color() == Qt::transparent || @@ -1788,7 +1783,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (qobject_cast<const QAbstractButton *>(widget)) { //Make cornerButton slightly smaller so that it is not on top of table border graphic. QStyleOptionHeader subopt = *header; - const int borderTweak = + const int borderTweak = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)>>1; if (subopt.direction == Qt::LeftToRight) subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); @@ -1881,7 +1876,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); } else { const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); - if (option->direction == Qt::LeftToRight) + if (option->direction == Qt::LeftToRight) headerRect.adjust(-2*frameWidth, 0, 0, 0); else headerRect.adjust(0, 0, 2*frameWidth, 0); @@ -2027,7 +2022,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti buttonRect.setHeight((int)(buttonRect.height() * scaler)); // move the rect up for half of the new height-gain const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; - buttonRect.adjust(0,-newY,0,-newY); + buttonRect.adjust(0, -newY, -1, -newY); painter->save(); QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); @@ -2596,7 +2591,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2*pixelMetric(PM_ButtonMargin); const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth); ret = toolButton->rect; - const bool popup = (toolButton->features & + const bool popup = (toolButton->features & (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) == QStyleOptionToolButton::MenuButtonPopup; switch (scontrol) { diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index ea86bb2..5ab2308 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -271,15 +271,6 @@ public: SP_QsnFrButtonSideLInactive, SP_QsnFrButtonSideRInactive, SP_QsnFrButtonCenterInactive, - SP_QsnFrNotepadCornerTl, - SP_QsnFrNotepadCornerTr, - SP_QsnFrNotepadCornerBl, - SP_QsnFrNotepadCornerBr, - SP_QsnFrNotepadSideT, - SP_QsnFrNotepadSideB, - SP_QsnFrNotepadSideL, - SP_QsnFrNotepadSideR, - SP_QsnFrNotepadCenter }; enum ColorLists { @@ -418,8 +409,6 @@ public: //set theme palette for application void setThemePalette(QApplication *application) const; - //set theme palette for style option - void setThemePalette(QStyleOption *option) const; //access to theme palette static QPalette* themePalette(); diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index 18851b7..7ec8e31 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -485,6 +485,7 @@ glyph_metrics_t QFontEngineWin::boundingBox(const QGlyphLayout &glyphs) return glyph_metrics_t(0, -tm.tmAscent, w, tm.tmHeight, w, 0); } +#ifndef Q_WS_WINCE bool QFontEngineWin::getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const { Q_ASSERT(metrics != 0); @@ -536,6 +537,7 @@ bool QFontEngineWin::getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph return false; } } +#endif glyph_metrics_t QFontEngineWin::boundingBox(glyph_t glyph, const QTransform &t) { diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h index 43e1f12..bab71c9 100644 --- a/src/gui/text/qfontengine_win_p.h +++ b/src/gui/text/qfontengine_win_p.h @@ -109,7 +109,9 @@ public: int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const; void getCMap(); +#ifndef Q_WS_WINCE bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const; +#endif QString _name; HFONT hfont; diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 3800224..785b2bd 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1411,6 +1411,8 @@ bool QLineEdit::event(QEvent * e) QTimer::singleShot(0, this, SLOT(_q_handleWindowActivate())); }else if(e->type() == QEvent::ShortcutOverride){ d->control->processEvent(e); + } else if (e->type() == QEvent::KeyRelease) { + d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); } #ifdef QT_KEYPAD_NAVIGATION @@ -1615,6 +1617,8 @@ void QLineEdit::keyPressEvent(QKeyEvent *event) } #endif d->control->processKeyEvent(event); + if (event->isAccepted()) + d->control->setCursorBlinkPeriod(0); } /*! diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 501e62f..557acfb 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -120,6 +120,7 @@ void QMainWindowPrivate::init() #ifdef QT_SOFTKEYS_ENABLED menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q); menuBarAction->setObjectName(QLatin1String("_q_menuSoftKeyAction")); + menuBarAction->setVisible(false); #endif } diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 761a060..2e27226 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -229,7 +229,7 @@ void QMenuPrivate::updateActionRects() const Q_Q(const QMenu); if (!itemsDirty) return; - + q->ensurePolished(); //let's reinitialize the buffer @@ -292,7 +292,7 @@ void QMenuPrivate::updateActionRects() const if (!action->isVisible() || (collapsibleSeparators && previousWasSeparator && action->isSeparator())) continue; // we continue, this action will get an empty QRect - + previousWasSeparator = action->isSeparator(); //let the style modify the above size.. @@ -1139,7 +1139,7 @@ void QMenuPrivate::_q_actionTriggered() //we check the parent hierarchy QList< QPointer<QWidget> > list; for(QWidget *widget = q->parentWidget(); widget; ) { - if (qobject_cast<QMenu*>(widget) + if (qobject_cast<QMenu*>(widget) #ifndef QT_NO_MENUBAR || qobject_cast<QMenuBar*>(widget) #endif @@ -1306,7 +1306,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) the addAction(), addActions() and insertAction() functions. An action is represented vertically and rendered by QStyle. In addition, actions can have a text label, an optional icon drawn on the very left side, - and shortcut key sequence such as "Ctrl+X". + and shortcut key sequence such as "Ctrl+X". The existing actions held by a menu can be found with actions(). @@ -1906,9 +1906,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction) pos.setX(qMax(p.x()-size.width(), screen.right()-desktopFrame-size.width()+1)); } else { if (pos.x()+size.width()-1 > screen.right()-desktopFrame) - pos.setX(qMin(p.x()+size.width(), screen.right()-desktopFrame-size.width()+1)); + pos.setX(screen.right()-desktopFrame-size.width()+1); if (pos.x() < screen.left()+desktopFrame) - pos.setX(qMax(p.x(), screen.left() + desktopFrame)); + pos.setX(screen.left() + desktopFrame); } if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) { if(snapToMouse) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index c7759e8..eae8b7d 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -1802,6 +1802,9 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e) QTextBlock block = firstVisibleBlock(); qreal maximumWidth = document()->documentLayout()->documentSize().width(); + // Set a brush origin so that the WaveUnderline knows where the wave started + painter.setBrushOrigin(offset); + // keep right margin clean from full-width selection int maxX = offset.x() + qMax((qreal)viewportRect.width(), maximumWidth) - document()->documentMargin(); diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp index 9eb07ac..50b225c 100644 --- a/src/gui/widgets/qspinbox.cpp +++ b/src/gui/widgets/qspinbox.cpp @@ -65,14 +65,13 @@ class QSpinBoxPrivate : public QAbstractSpinBoxPrivate { Q_DECLARE_PUBLIC(QSpinBox) public: - QSpinBoxPrivate(QWidget *parent = 0); + QSpinBoxPrivate(); void emitSignals(EmitPolicy ep, const QVariant &); virtual QVariant valueFromText(const QString &n) const; virtual QString textFromValue(const QVariant &n) const; QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const; - QChar thousand; inline void init() { Q_Q(QSpinBox); @@ -85,7 +84,7 @@ class QDoubleSpinBoxPrivate : public QAbstractSpinBoxPrivate { Q_DECLARE_PUBLIC(QDoubleSpinBox) public: - QDoubleSpinBoxPrivate(QWidget *parent = 0); + QDoubleSpinBoxPrivate(); void emitSignals(EmitPolicy ep, const QVariant &); virtual QVariant valueFromText(const QString &n) const; @@ -95,7 +94,6 @@ public: double round(double input) const; // variables int decimals; - QChar delimiter, thousand; inline void init() { Q_Q(QDoubleSpinBox); @@ -201,7 +199,7 @@ public: */ QSpinBox::QSpinBox(QWidget *parent) - : QAbstractSpinBox(*new QSpinBoxPrivate(parent), parent) + : QAbstractSpinBox(*new QSpinBoxPrivate, parent) { Q_D(QSpinBox); d->init(); @@ -213,7 +211,7 @@ QSpinBox::QSpinBox(QWidget *parent) argument and then use setObjectName() instead. */ QSpinBox::QSpinBox(QWidget *parent, const char *name) - : QAbstractSpinBox(*new QSpinBoxPrivate(parent), parent) + : QAbstractSpinBox(*new QSpinBoxPrivate, parent) { Q_D(QSpinBox); setObjectName(QString::fromAscii(name)); @@ -225,7 +223,7 @@ QSpinBox::QSpinBox(QWidget *parent, const char *name) argument and then use setObjectName() instead. */ QSpinBox::QSpinBox(int minimum, int maximum, int step, QWidget *parent, const char *name) - : QAbstractSpinBox(*new QSpinBoxPrivate(parent), parent) + : QAbstractSpinBox(*new QSpinBoxPrivate, parent) { Q_D(QSpinBox); d->minimum = QVariant(qMin<int>(minimum, maximum)); @@ -464,10 +462,9 @@ void QSpinBox::setRange(int minimum, int maximum) QString QSpinBox::textFromValue(int value) const { - Q_D(const QSpinBox); QString str = locale().toString(value); if (qAbs(value) >= 1000 || value == INT_MIN) { - str.remove(d->thousand); + str.remove(locale().groupSeparator()); } return str; @@ -516,9 +513,7 @@ QValidator::State QSpinBox::validate(QString &text, int &pos) const */ void QSpinBox::fixup(QString &input) const { - Q_D(const QSpinBox); - - input.remove(d->thousand); + input.remove(locale().groupSeparator()); } @@ -600,7 +595,7 @@ void QSpinBox::fixup(QString &input) const \sa setMinimum(), setMaximum(), setSingleStep() */ QDoubleSpinBox::QDoubleSpinBox(QWidget *parent) - : QAbstractSpinBox(*new QDoubleSpinBoxPrivate(parent), parent) + : QAbstractSpinBox(*new QDoubleSpinBoxPrivate, parent) { Q_D(QDoubleSpinBox); d->init(); @@ -875,7 +870,7 @@ QString QDoubleSpinBox::textFromValue(double value) const Q_D(const QDoubleSpinBox); QString str = locale().toString(value, 'f', d->decimals); if (qAbs(value) >= 1000.0) { - str.remove(d->thousand); + str.remove(locale().groupSeparator()); } return str; } @@ -920,9 +915,7 @@ QValidator::State QDoubleSpinBox::validate(QString &text, int &pos) const */ void QDoubleSpinBox::fixup(QString &input) const { - Q_D(const QDoubleSpinBox); - - input.remove(d->thousand); + input.remove(locale().groupSeparator()); } // --- QSpinBoxPrivate --- @@ -932,18 +925,13 @@ void QDoubleSpinBox::fixup(QString &input) const Constructs a QSpinBoxPrivate object */ -QSpinBoxPrivate::QSpinBoxPrivate(QWidget *parent) +QSpinBoxPrivate::QSpinBoxPrivate() { minimum = QVariant((int)0); maximum = QVariant((int)99); value = minimum; singleStep = QVariant((int)1); type = QVariant::Int; - const QString str = (parent ? parent->locale() : QLocale()).toString(4567); - if (str.size() == 5) { - thousand = QChar(str.at(1)); - } - } /*! @@ -1019,20 +1007,17 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, state = QValidator::Invalid; // special-case -0 will be interpreted as 0 and thus not be invalid with a range from 0-100 } else { bool ok = false; - bool removedThousand = false; num = locale.toInt(copy, &ok, 10); - if (!ok && copy.contains(thousand) && (max >= 1000 || min <= -1000)) { - const int s = copy.size(); - copy.remove(thousand); - pos = qMax(0, pos - (s - copy.size())); - removedThousand = true; - num = locale.toInt(copy, &ok, 10); + if (!ok && copy.contains(locale.groupSeparator()) && (max >= 1000 || min <= -1000)) { + QString copy2 = copy; + copy2.remove(locale.groupSeparator()); + num = locale.toInt(copy2, &ok, 10); } QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num; if (!ok) { state = QValidator::Invalid; } else if (num >= min && num <= max) { - state = removedThousand ? QValidator::Intermediate : QValidator::Acceptable; + state = QValidator::Acceptable; } else if (max == min) { state = QValidator::Invalid; } else { @@ -1064,7 +1049,7 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, Constructs a QSpinBoxPrivate object */ -QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate(QWidget *parent) +QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate() { minimum = QVariant(0.0); maximum = QVariant(99.99); @@ -1072,15 +1057,6 @@ QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate(QWidget *parent) singleStep = QVariant(1.0); decimals = 2; type = QVariant::Double; - const QString str = (parent ? parent->locale() : QLocale()).toString(4567.1); - if (str.size() == 6) { - delimiter = str.at(4); - thousand = QChar((ushort)0); - } else if (str.size() == 7) { - thousand = str.at(1); - delimiter = str.at(5); - } - Q_ASSERT(!delimiter.isNull()); } /*! @@ -1155,7 +1131,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, state = max != min ? QValidator::Intermediate : QValidator::Invalid; goto end; case 1: - if (copy.at(0) == delimiter + if (copy.at(0) == locale.decimalPoint() || (plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-'))) { state = QValidator::Intermediate; @@ -1163,7 +1139,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, } break; case 2: - if (copy.at(1) == delimiter + if (copy.at(1) == locale.decimalPoint() && ((plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-')))) { state = QValidator::Intermediate; goto end; @@ -1172,14 +1148,14 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, default: break; } - if (copy.at(0) == thousand) { + if (copy.at(0) == locale.groupSeparator()) { QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; state = QValidator::Invalid; goto end; } else if (len > 1) { - const int dec = copy.indexOf(delimiter); + const int dec = copy.indexOf(locale.decimalPoint()); if (dec != -1) { - if (dec + 1 < copy.size() && copy.at(dec + 1) == delimiter && pos == dec + 1) { + if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) { copy.remove(dec + 1, 1); // typing a delimiter when you are on the delimiter } // should be treated as typing right arrow @@ -1189,7 +1165,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, goto end; } for (int i=dec + 1; i<copy.size(); ++i) { - if (copy.at(i).isSpace() || copy.at(i) == thousand) { + if (copy.at(i).isSpace() || copy.at(i) == locale.groupSeparator()) { QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; state = QValidator::Invalid; goto end; @@ -1198,12 +1174,12 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, } else { const QChar &last = copy.at(len - 1); const QChar &secondLast = copy.at(len - 2); - if ((last == thousand || last.isSpace()) - && (secondLast == thousand || secondLast.isSpace())) { + if ((last == locale.groupSeparator() || last.isSpace()) + && (secondLast == locale.groupSeparator() || secondLast.isSpace())) { state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; goto end; - } else if (last.isSpace() && (!thousand.isSpace() || secondLast.isSpace())) { + } else if (last.isSpace() && (!locale.groupSeparator().isSpace() || secondLast.isSpace())) { state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; goto end; @@ -1215,11 +1191,10 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, bool ok = false; num = locale.toDouble(copy, &ok); QSBDEBUG() << __FILE__ << __LINE__ << locale << copy << num << ok; - bool notAcceptable = false; if (!ok) { - if (thousand.isPrint()) { - if (max < 1000 && min > -1000 && copy.contains(thousand)) { + if (locale.groupSeparator().isPrint()) { + if (max < 1000 && min > -1000 && copy.contains(locale.groupSeparator())) { state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; goto end; @@ -1227,27 +1202,23 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, const int len = copy.size(); for (int i=0; i<len- 1; ++i) { - if (copy.at(i) == thousand && copy.at(i + 1) == thousand) { + if (copy.at(i) == locale.groupSeparator() && copy.at(i + 1) == locale.groupSeparator()) { QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; state = QValidator::Invalid; goto end; } } - const int s = copy.size(); - copy.remove(thousand); - pos = qMax(0, pos - (s - copy.size())); - - - num = locale.toDouble(copy, &ok); - QSBDEBUG() << thousand << num << copy << ok; + QString copy2 = copy; + copy2.remove(locale.groupSeparator()); + num = locale.toDouble(copy2, &ok); + QSBDEBUG() << locale.groupSeparator() << num << copy2 << ok; if (!ok) { state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; goto end; } - notAcceptable = true; } } @@ -1255,9 +1226,8 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; } else if (num >= min && num <= max) { - state = notAcceptable ? QValidator::Intermediate : QValidator::Acceptable; - QSBDEBUG() << __FILE__ << __LINE__<< "state is set to " - << (state == QValidator::Intermediate ? "Intermediate" : "Acceptable"); + state = QValidator::Acceptable; + QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Acceptable"; } else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min) state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 823f919..07432c6 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1773,13 +1773,10 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; #if !defined(QT_OPENGL_ES_2) - if (!d->device->format().alpha() #if defined(Q_WS_WIN) - && qt_cleartype_enabled + if (qt_cleartype_enabled) #endif - ) { d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; - } #endif #if defined(QT_OPENGL_ES_2) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index 1478b09..c78f73f 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -209,6 +209,65 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen) } } +void QTriangulatingStroker::moveTo(const qreal *pts) +{ + m_cx = pts[0]; + m_cy = pts[1]; + + float x2 = pts[2]; + float y2 = pts[3]; + normalVector(m_cx, m_cy, x2, y2, &m_nvx, &m_nvy); + + + // To acheive jumps we insert zero-area tringles. This is done by + // adding two identical points in both the end of previous strip + // and beginning of next strip + bool invisibleJump = m_vertices.size(); + + switch (m_cap_style) { + case Qt::FlatCap: + if (invisibleJump) { + m_vertices.add(m_cx + m_nvx); + m_vertices.add(m_cy + m_nvy); + } + break; + case Qt::SquareCap: { + float sx = m_cx - m_nvy; + float sy = m_cy + m_nvx; + if (invisibleJump) { + m_vertices.add(sx + m_nvx); + m_vertices.add(sy + m_nvy); + } + emitLineSegment(sx, sy, m_nvx, m_nvy); + break; } + case Qt::RoundCap: { + QVarLengthArray<float> points; + arcPoints(m_cx, m_cy, m_cx + m_nvx, m_cy + m_nvy, m_cx - m_nvx, m_cy - m_nvy, points); + m_vertices.resize(m_vertices.size() + points.size() + 2 * int(invisibleJump)); + int count = m_vertices.size(); + int front = 0; + int end = points.size() / 2; + while (front != end) { + m_vertices.at(--count) = points[2 * end - 1]; + m_vertices.at(--count) = points[2 * end - 2]; + --end; + if (front == end) + break; + m_vertices.at(--count) = points[2 * front + 1]; + m_vertices.at(--count) = points[2 * front + 0]; + ++front; + } + + if (invisibleJump) { + m_vertices.at(count - 1) = m_vertices.at(count + 1); + m_vertices.at(count - 2) = m_vertices.at(count + 0); + } + break; } + default: break; // ssssh gcc... + } + emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); +} + void QTriangulatingStroker::cubicTo(const qreal *pts) { const QPointF *p = (const QPointF *) pts; @@ -246,6 +305,151 @@ void QTriangulatingStroker::cubicTo(const qreal *pts) m_nvy = vy; } +void QTriangulatingStroker::join(const qreal *pts) +{ + // Creates a join to the next segment (m_cx, m_cy) -> (pts[0], pts[1]) + normalVector(m_cx, m_cy, pts[0], pts[1], &m_nvx, &m_nvy); + + switch (m_join_style) { + case Qt::BevelJoin: + break; + case Qt::MiterJoin: { + // Find out on which side the join should be. + int count = m_vertices.size(); + float prevNvx = m_vertices.at(count - 2) - m_cx; + float prevNvy = m_vertices.at(count - 1) - m_cy; + float xprod = prevNvx * m_nvy - prevNvy * m_nvx; + float px, py, qx, qy; + + // If the segments are parallel, use bevel join. + if (qFuzzyIsNull(xprod)) + break; + + // Find the corners of the previous and next segment to join. + if (xprod < 0) { + px = m_vertices.at(count - 2); + py = m_vertices.at(count - 1); + qx = m_cx - m_nvx; + qy = m_cy - m_nvy; + } else { + px = m_vertices.at(count - 4); + py = m_vertices.at(count - 3); + qx = m_cx + m_nvx; + qy = m_cy + m_nvy; + } + + // Find intersection point. + float pu = px * prevNvx + py * prevNvy; + float qv = qx * m_nvx + qy * m_nvy; + float ix = (m_nvy * pu - prevNvy * qv) / xprod; + float iy = (prevNvx * qv - m_nvx * pu) / xprod; + + // Check that the distance to the intersection point is less than the miter limit. + if ((ix - px) * (ix - px) + (iy - py) * (iy - py) <= m_miter_limit * m_miter_limit) { + m_vertices.add(ix); + m_vertices.add(iy); + m_vertices.add(ix); + m_vertices.add(iy); + } + // else + // Do a plain bevel join if the miter limit is exceeded or if + // the lines are parallel. This is not what the raster + // engine's stroker does, but it is both faster and similar to + // what some other graphics API's do. + + break; } + case Qt::RoundJoin: { + QVarLengthArray<float> points; + int count = m_vertices.size(); + float prevNvx = m_vertices.at(count - 2) - m_cx; + float prevNvy = m_vertices.at(count - 1) - m_cy; + if (m_nvx * prevNvy - m_nvy * prevNvx < 0) { + arcPoints(0, 0, m_nvx, m_nvy, -prevNvx, -prevNvy, points); + for (int i = points.size() / 2; i > 0; --i) + emitLineSegment(m_cx, m_cy, points[2 * i - 2], points[2 * i - 1]); + } else { + arcPoints(0, 0, -prevNvx, -prevNvy, m_nvx, m_nvy, points); + for (int i = 0; i < points.size() / 2; ++i) + emitLineSegment(m_cx, m_cy, points[2 * i + 0], points[2 * i + 1]); + } + break; } + default: break; // gcc warn-- + } + + emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); +} + +void QTriangulatingStroker::endCap(const qreal *) +{ + switch (m_cap_style) { + case Qt::FlatCap: + break; + case Qt::SquareCap: + emitLineSegment(m_cx + m_nvy, m_cy - m_nvx, m_nvx, m_nvy); + break; + case Qt::RoundCap: { + QVarLengthArray<float> points; + int count = m_vertices.size(); + arcPoints(m_cx, m_cy, m_vertices.at(count - 2), m_vertices.at(count - 1), m_vertices.at(count - 4), m_vertices.at(count - 3), points); + int front = 0; + int end = points.size() / 2; + while (front != end) { + m_vertices.add(points[2 * end - 2]); + m_vertices.add(points[2 * end - 1]); + --end; + if (front == end) + break; + m_vertices.add(points[2 * front + 0]); + m_vertices.add(points[2 * front + 1]); + ++front; + } + break; } + default: break; // to shut gcc up... + } +} + +void QTriangulatingStroker::arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray<float> &points) +{ + float dx1 = fromX - cx; + float dy1 = fromY - cy; + float dx2 = toX - cx; + float dy2 = toY - cy; + + // while more than 180 degrees left: + while (dx1 * dy2 - dx2 * dy1 < 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); + } + + // while more than 90 degrees left: + while (dx1 * dx2 + dy1 * dy2 < 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); + } + + // while more than 0 degrees left: + while (dx1 * dy2 - dx2 * dy1 > 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); + } + + // remove last point which was rotated beyond [toX, toY]. + if (!points.isEmpty()) + points.resize(points.size() - 2); +} + static void qdashprocessor_moveTo(qreal x, qreal y, void *data) { ((QDashedStrokeProcessor *) data)->addElement(QPainterPath::MoveToElement, x, y); diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index a0117d5..2dba0ce 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -43,6 +43,7 @@ #define QTRIANGULATINGSTROKER_P_H #include <private/qdatabuffer_p.h> +#include <qvarlengtharray.h> #include <private/qvectorpath_p.h> #include <private/qbezier_p.h> #include <private/qnumeric_p.h> @@ -62,13 +63,13 @@ public: private: inline void emitLineSegment(float x, float y, float nx, float ny); - inline void moveTo(const qreal *pts); + void moveTo(const qreal *pts); inline void lineTo(const qreal *pts); void cubicTo(const qreal *pts); - inline void join(const qreal *pts); + void join(const qreal *pts); inline void normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny); - inline void endCap(const qreal *pts); - inline void arc(float x, float y); + void endCap(const qreal *pts); + void arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray<float> &points); void endCapOrJoinClosed(const qreal *start, const qreal *cur, bool implicitClose, bool endsAtStart); @@ -116,10 +117,6 @@ private: qreal m_inv_scale; }; - - - - inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny) { @@ -139,8 +136,6 @@ inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, fl *ny = dx * pw; } - - inline void QTriangulatingStroker::emitLineSegment(float x, float y, float vx, float vy) { m_vertices.add(x + vx); @@ -149,103 +144,6 @@ inline void QTriangulatingStroker::emitLineSegment(float x, float y, float vx, f m_vertices.add(y - vy); } - - -// We draw a full circle for any round join or round cap which is a -// bit of overkill... -inline void QTriangulatingStroker::arc(float x, float y) -{ - float dx = m_width; - float dy = 0; - for (int i=0; i<=m_roundness; ++i) { - float tmpx = dx * m_cos_theta - dy * m_sin_theta; - float tmpy = dx * m_sin_theta + dy * m_cos_theta; - dx = tmpx; - dy = tmpy; - emitLineSegment(x, y, dx, dy); - } -} - - - -inline void QTriangulatingStroker::endCap(const qreal *pts) -{ - switch (m_cap_style) { - case Qt::FlatCap: - break; - case Qt::SquareCap: { - float dx = m_cx - *(pts - 2); - float dy = m_cy - *(pts - 1); - - float len = m_width / sqrt(dx * dx + dy * dy); - dx = dx * len; - dy = dy * len; - - emitLineSegment(m_cx + dx, m_cy + dy, m_nvx, m_nvy); - break; } - case Qt::RoundCap: - arc(m_cx, m_cy); - break; - default: break; // to shut gcc up... - } -} - - -void QTriangulatingStroker::moveTo(const qreal *pts) -{ - m_cx = pts[0]; - m_cy = pts[1]; - - float x2 = pts[2]; - float y2 = pts[3]; - normalVector(m_cx, m_cy, x2, y2, &m_nvx, &m_nvy); - - - // To acheive jumps we insert zero-area tringles. This is done by - // adding two identical points in both the end of previous strip - // and beginning of next strip - bool invisibleJump = m_vertices.size(); - - switch (m_cap_style) { - case Qt::FlatCap: - if (invisibleJump) { - m_vertices.add(m_cx + m_nvx); - m_vertices.add(m_cy + m_nvy); - } - break; - case Qt::SquareCap: { - float dx = x2 - m_cx; - float dy = y2 - m_cy; - float len = m_width / sqrt(dx * dx + dy * dy); - dx = dx * len; - dy = dy * len; - float sx = m_cx - dx; - float sy = m_cy - dy; - if (invisibleJump) { - m_vertices.add(sx + m_nvx); - m_vertices.add(sy + m_nvy); - } - emitLineSegment(sx, sy, m_nvx, m_nvy); - break; } - case Qt::RoundCap: - if (invisibleJump) { - m_vertices.add(m_cx + m_nvx); - m_vertices.add(m_cy + m_nvy); - } - - // This emitLineSegment is not needed for the arc, but we need - // to start where we put the invisibleJump vertex, otherwise - // we'll have visible triangles between subpaths. - emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); - arc(m_cx, m_cy); - break; - default: break; // ssssh gcc... - } - emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); -} - - - void QTriangulatingStroker::lineTo(const qreal *pts) { emitLineSegment(pts[0], pts[1], m_nvx, m_nvy); @@ -253,52 +151,6 @@ void QTriangulatingStroker::lineTo(const qreal *pts) m_cy = pts[1]; } - - -void QTriangulatingStroker::join(const qreal *pts) -{ - // Creates a join to the next segment (m_cx, m_cy) -> (pts[0], pts[1]) - normalVector(m_cx, m_cy, pts[0], pts[1], &m_nvx, &m_nvy); - - switch (m_join_style) { - case Qt::BevelJoin: - break; - case Qt::MiterJoin: { - int p1 = m_vertices.size() - 6; - int p2 = m_vertices.size() - 2; - QLineF line(m_vertices.at(p1), m_vertices.at(p1+1), - m_vertices.at(p2), m_vertices.at(p2+1)); - QLineF nextLine(m_cx - m_nvx, m_cy - m_nvy, - pts[0] - m_nvx, pts[1] - m_nvy); - - QPointF isect; - if (line.intersect(nextLine, &isect) != QLineF::NoIntersection - && QLineF(line.p2(), isect).length() <= m_miter_limit) { - // The intersection point mirrored over the m_cx, m_cy point - m_vertices.add(m_cx - (isect.x() - m_cx)); - m_vertices.add(m_cy - (isect.y() - m_cy)); - - // The intersection point - m_vertices.add(isect.x()); - m_vertices.add(isect.y()); - } - // else - // Do a plain bevel join if the miter limit is exceeded or if - // the lines are parallel. This is not what the raster - // engine's stroker does, but it is both faster and similar to - // what some other graphics API's do. - - break; } - case Qt::RoundJoin: - arc(m_cx, m_cy); - break; - - default: break; // gcc warn-- - } - - emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); -} - QT_END_NAMESPACE #endif diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index fda4b10..6b829dd 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1570,12 +1570,6 @@ void QVGPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) d->dirty |= QPaintEngine::DirtyClipRegion; - // If we have a non-simple transform, then use path-based clipping. - if (op != Qt::NoClip && !clipTransformIsSimple(d->transform)) { - QPaintEngineEx::clip(rect, op); - return; - } - switch (op) { case Qt::NoClip: { @@ -1612,12 +1606,6 @@ void QVGPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) d->dirty |= QPaintEngine::DirtyClipRegion; - // If we have a non-simple transform, then use path-based clipping. - if (op != Qt::NoClip && !clipTransformIsSimple(d->transform)) { - QPaintEngineEx::clip(region, op); - return; - } - switch (op) { case Qt::NoClip: { @@ -3459,14 +3447,11 @@ void QVGCompositionHelper::endCompositing() } void QVGCompositionHelper::blitWindow - (QVGEGLWindowSurfacePrivate *surface, const QRect& rect, - const QPoint& topLeft, int opacity) + (VGImage image, const QSize& imageSize, + const QRect& rect, const QPoint& topLeft, int opacity) { - // Get the VGImage that is acting as a back buffer for the window. - VGImage image = surface->surfaceImage(); if (image == VG_INVALID_HANDLE) return; - QSize imageSize = surface->surfaceSize(); // Determine which sub rectangle of the window to draw. QRect sr = rect.translated(-topLeft); diff --git a/src/openvg/qvgcompositionhelper_p.h b/src/openvg/qvgcompositionhelper_p.h index 3afe31e..ed24e73 100644 --- a/src/openvg/qvgcompositionhelper_p.h +++ b/src/openvg/qvgcompositionhelper_p.h @@ -71,8 +71,8 @@ public: void startCompositing(const QSize& screenSize); void endCompositing(); - void blitWindow(QVGEGLWindowSurfacePrivate *surface, const QRect& rect, - const QPoint& topLeft, int opacity); + void blitWindow(VGImage image, const QSize& imageSize, + const QRect& rect, const QPoint& topLeft, int opacity); void fillBackground(const QRegion& region, const QBrush& brush); void drawCursorPixmap(const QPixmap& pixmap, const QPoint& offset); void setScissor(const QRegion& region); diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index 29d82c8..62871cf 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -200,6 +200,42 @@ static QEglContext *createContext(QPaintDevice *device) else eglSwapInterval(context->display(), 1); +#ifdef EGL_RENDERABLE_TYPE + // Has the user specified an explicit EGL configuration to use? + QByteArray configId = qgetenv("QT_VG_EGL_CONFIG"); + if (!configId.isEmpty()) { + EGLint cfgId = configId.toInt(); + EGLint properties[] = { + EGL_CONFIG_ID, cfgId, + EGL_NONE + }; + EGLint matching = 0; + EGLConfig cfg; + if (eglChooseConfig + (context->display(), properties, &cfg, 1, &matching) && + matching > 0) { + // Check that the selected configuration actually supports OpenVG + // and then create the context with it. + EGLint id = 0; + EGLint type = 0; + eglGetConfigAttrib + (context->display(), cfg, EGL_CONFIG_ID, &id); + eglGetConfigAttrib + (context->display(), cfg, EGL_RENDERABLE_TYPE, &type); + if (cfgId == id && (type & EGL_OPENVG_BIT) != 0) { + context->setConfig(cfg); + if (!context->createContext()) { + delete context; + return 0; + } + return context; + } else { + qWarning("QT_VG_EGL_CONFIG: %d is not a valid OpenVG configuration", int(cfgId)); + } + } + } +#endif + // Choose an appropriate configuration for rendering into the device. QEglProperties configProps; configProps.setPaintDeviceFormat(device); @@ -211,19 +247,19 @@ static QEglContext *createContext(QPaintDevice *device) configProps.setValue(EGL_ALPHA_MASK_SIZE, 1); #endif #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT - configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT | + configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT); configProps.setRenderableType(QEgl::OpenVG); if (!context->chooseConfig(configProps)) { // Try again without the "pre" bit. - configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT); + configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT); if (!context->chooseConfig(configProps)) { delete context; return 0; } } #else - configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT); + configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT); configProps.setRenderableType(QEgl::OpenVG); if (!context->chooseConfig(configProps)) { delete context; diff --git a/tests/auto/languagechange/tst_languagechange.cpp b/tests/auto/languagechange/tst_languagechange.cpp index 1319f15..449d34b 100644 --- a/tests/auto/languagechange/tst_languagechange.cpp +++ b/tests/auto/languagechange/tst_languagechange.cpp @@ -193,7 +193,7 @@ void tst_languageChange::retranslatability_data() #else << "QFileSystemModel::Type::All other platforms" #endif - << "QFileSystemModel::%1 KB" +// << "QFileSystemModel::%1 KB" << "QDialogButtonBox::Cancel" << "QDialogButtonBox::Open" << "QFileDialog::File &name:"); @@ -232,6 +232,7 @@ void tst_languageChange::retranslatability() QSKIP("The native file dialog is used on Mac OS", SkipSingle); #endif QFileDialog dlg; + dlg.setOption(QFileDialog::DontUseNativeDialog); QString tmpParentDir = QDir::tempPath() + "/languagechangetestdir"; QString tmpDir = tmpParentDir + "/finaldir"; QString fooName = tmpParentDir + "/foo"; diff --git a/tests/auto/linguist/lconvert/data/phrasebook.qph b/tests/auto/linguist/lconvert/data/phrasebook.qph new file mode 100644 index 0000000..847a53b --- /dev/null +++ b/tests/auto/linguist/lconvert/data/phrasebook.qph @@ -0,0 +1,21 @@ +<!DOCTYPE QPH> +<QPH language="de" sourcelanguage="en_US"> +<phrase> + <source>About</source> + <target>Info</target> +</phrase> +<phrase> + <source>adornment</source> + <target>Zubehör</target> +</phrase> +<phrase> + <source>barrel button</source> + <target>Pen-Knopf</target> + <definition>pen</definition> +</phrase> +<phrase> + <source>foo & bar</source> + <target>Foo & bar</target> + <definition><test>übergroß</definition> +</phrase> +</QPH> diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp index 10098a4..cf8f5c3 100644 --- a/tests/auto/linguist/lconvert/tst_lconvert.cpp +++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp @@ -213,6 +213,7 @@ void tst_lconvert::readverifies_data() QTest::newRow("relative locations") << "relative.ts" << "ts"; QTest::newRow("message ids") << "msgid.ts" << "ts"; QTest::newRow("length variants") << "variants.ts" << "ts"; + QTest::newRow("qph") << "phrasebook.qph" << "qph"; } void tst_lconvert::readverifies() diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp index 413419d..3736813 100644 --- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -112,6 +112,8 @@ private slots: void testMoveWithinOwnRange_data(); void testMoveWithinOwnRange(); + void testMoveThroughProxy(); + void testReset(); @@ -1112,6 +1114,25 @@ void tst_QAbstractItemModel::testMoveSameParentUp() } } +void tst_QAbstractItemModel::testMoveThroughProxy() +{ + QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); + proxy->setSourceModel(m_model); + + QList<QPersistentModelIndex> persistentList; + + persistentList.append(proxy->index(0, 0)); + persistentList.append(proxy->index(0, 0, proxy->mapFromSource(m_model->index(5, 0)))); + + ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this); + moveCommand->setNumCols(4); + moveCommand->setAncestorRowNumbers(QList<int>() << 5); + moveCommand->setStartRow(0); + moveCommand->setEndRow(0); + moveCommand->setDestRow(0); + moveCommand->doCommand(); +} + void tst_QAbstractItemModel::testMoveToGrandParent_data() { QTest::addColumn<int>("startRow"); diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index af71961..bd5cd70 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2516,10 +2516,12 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() layout.addWidget(&edit); w.show(); + QApplication::setActiveWindow(&w); QTest::qWaitForWindowShown(&w); cb.clearEditText(); cb.setFocus(); QApplication::processEvents(); + QTRY_VERIFY(cb.hasFocus()); QTest::keyClick(0, '1'); QCOMPARE(spy.count(), 0); edit.setFocus(); diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index 3d2fa42..00ebed0 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -147,6 +147,8 @@ private slots: void task221221(); void task255471_decimalsValidation(); + void taskQTBUG_5008_textFromValueAndValidate(); + public slots: void valueChangedHelper(const QString &); void valueChangedHelper(double); @@ -682,7 +684,7 @@ void tst_QDoubleSpinBox::valueFromTextAndValidate_data() QTest::newRow("data10") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1"); QTest::newRow("data11") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString("1"); QTest::newRow("data12") << QString("1,") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString(); - QTest::newRow("data13") << QString("1,") << Intermediate << 0.0 << 1000.0 << (int)QLocale::C << QString(); + QTest::newRow("data13") << QString("1,") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); QTest::newRow("data14") << QString("1, ") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1,"); QTest::newRow("data15") << QString("1, ") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString(); QTest::newRow("data16") << QString("2") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString(); @@ -717,8 +719,8 @@ void tst_QDoubleSpinBox::valueFromTextAndValidate_data() QTest::newRow("data45") << QString("200,2") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString(); QTest::newRow("data46") << QString("200,2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); QTest::newRow("data47") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); - QTest::newRow("data48") << QString("2.2") << Intermediate << 0.0 << 1000.0 << (int)QLocale::German << QString(); - QTest::newRow("data49") << QString("2.2,00") << Intermediate << 0.0 << 1000.0 << (int)QLocale::German << QString(); + QTest::newRow("data48") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); + QTest::newRow("data49") << QString("2.2,00") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); QTest::newRow("data50") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); QTest::newRow("data51") << QString("2.2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString(); QTest::newRow("data52") << QString("2..2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::German << QString(); @@ -1044,6 +1046,37 @@ void tst_QDoubleSpinBox::task255471_decimalsValidation() } } +void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate() +{ + class DecoratedSpinBox : public QDoubleSpinBox + { + public: + DecoratedSpinBox() + { + setLocale(QLocale::French); + setMaximum(100000000); + setValue(1000); + } + + //we use the French delimiters here + QString textFromValue (double value) const + { + return locale().toString(value); + } + + using QDoubleSpinBox::lineEdit; + } spinbox; + spinbox.show(); + spinbox.activateWindow(); + spinbox.setFocus(); + QTest::qWaitForWindowShown(&spinbox); + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); + spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator + QTest::keyClick(0, Qt::Key_0); // let's insert a 0 + QCOMPARE(spinbox.value(), 10000.); + spinbox.clearFocus(); //make sure the value is correctly formatted + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); +} QTEST_MAIN(tst_QDoubleSpinBox) #include "tst_qdoublespinbox.moc" diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index db80db6..565a3e7 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -9759,16 +9759,16 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() { struct Item : public QGraphicsTextItem { - bool painted; + int painted; void paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *wid) { - painted = true; + painted++; QGraphicsTextItem::paint(painter, opt, wid); } }; Item *i = new Item; - i->painted = false; + i->painted = 0; i->setPlainText("I AM A TROLL"); QGraphicsScene scene; @@ -9780,11 +9780,11 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() QTRY_VERIFY(i->painted); QApplication::processEvents(); - i->painted = false; + i->painted = 0; QColor col(Qt::red); i->setDefaultTextColor(col); QApplication::processEvents(); - QTRY_VERIFY(i->painted); //check that changing the color force an update + QTRY_COMPARE(i->painted, 1); //check that changing the color force an update i->painted = false; QImage image(400, 200, QImage::Format_RGB32); @@ -9792,7 +9792,7 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() QPainter painter(&image); scene.render(&painter); painter.end(); - QVERIFY(i->painted); + QCOMPARE(i->painted, 1); int numRedPixel = 0; QRgb rgb = col.rgb(); @@ -9810,6 +9810,11 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() } } QCOMPARE(numRedPixel, -1); //color not found, FAIL! + + i->painted = 0; + i->setDefaultTextColor(col); + QApplication::processEvents(); + QCOMPARE(i->painted, 0); //same color as before should not trigger an update (QTBUG-6242) } QTEST_MAIN(tst_QGraphicsItem) diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 20d9eb8..a8017ff 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -46,6 +46,8 @@ #endif #include <QtGui> +#include <private/qgraphicsscene_p.h> +#include <private/qgraphicssceneindex_p.h> #include <math.h> #include "../../shared/util.h" @@ -269,6 +271,7 @@ private slots: void initialFocus(); void polishItems(); void isActive(); + void siblingIndexAlwaysValid(); // task specific tests below me void task139710_bspTreeCrash(); @@ -4181,6 +4184,35 @@ void tst_QGraphicsScene::isActive() } +void tst_QGraphicsScene::siblingIndexAlwaysValid() +{ + QGraphicsScene scene; + + QGraphicsWidget *parent = new QGraphicsWidget; + parent->setZValue(350); + parent->setGeometry(0, 0, 100, 100); + QGraphicsWidget *parent2 = new QGraphicsWidget; + parent2->setGeometry(10, 10, 50, 50); + QGraphicsWidget *child = new QGraphicsWidget(parent2); + child->setGeometry(15, 15, 25, 25); + child->setZValue(150); + //Both are top level + scene.addItem(parent); + scene.addItem(parent2); + + //Then we make the child a top level + child->setParentItem(0); + + //This is trigerred by a repaint... + QGraphicsScenePrivate::get(&scene)->index->estimateTopLevelItems(QRectF(), Qt::AscendingOrder); + + delete child; + + //If there are in the list that's bad, we crash... + QVERIFY(!QGraphicsScenePrivate::get(&scene)->topLevelItems.contains(static_cast<QGraphicsItem *>(child))); + +} + void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() { QGraphicsScene scene; diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 9fe8e49..4f4761c 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -1417,8 +1417,22 @@ void tst_QLineEdit::undo_keypressevents() } #ifndef QT_NO_CLIPBOARD +static bool nativeClipboardWorking() +{ +#ifdef Q_WS_MAC + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate(0, &pasteboard); + if (status == noErr) + CFRelease(pasteboard); + return status == noErr; +#endif + return true; +} + void tst_QLineEdit::QTBUG5786_undoPaste() { + if (!nativeClipboardWorking()) + QSKIP("this machine doesn't support the clipboard", SkipAll); QString initial("initial"); QString string("test"); QString additional("add"); diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index 320cd8d..aa6caae 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -168,7 +168,7 @@ private slots: void task256322_highlight(); void menubarSizeHint(); void taskQTBUG4965_escapeEaten(); - + #if defined(QT3_SUPPORT) void indexBasedInsertion_data(); void indexBasedInsertion(); @@ -1360,7 +1360,7 @@ tst_QMenuBar::allowActiveAndDisabled() // disabled menu items are added QMenu fileMenu("&File"); - // Task 241043 : check that second menu is activated + // Task 241043 : check that second menu is activated // if all items are disabled QAction *act = fileMenu.addAction("Disabled"); act->setEnabled(false); @@ -1388,7 +1388,7 @@ tst_QMenuBar::allowActiveAndDisabled() QCOMPARE(mb->activeAction()->text(), fileMenu.title()); else QCOMPARE(mb->activeAction()->text(), fileMenu.title()); - + mb->hide(); #endif //Q_WS_MAC } @@ -1603,7 +1603,7 @@ void tst_QMenuBar::menubarSizeHint() virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const { // I chose strange values (prime numbers to be more sure that the size of the menubar is correct) - switch (metric) + switch (metric) { case QStyle::PM_MenuBarItemSpacing: return 7; @@ -1621,7 +1621,7 @@ void tst_QMenuBar::menubarSizeHint() QMenuBar mb; mb.setNativeMenuBar(false); //we can't check the geometry of native menubars - + mb.setStyle(&style); //this is a list of arbitrary strings so that we check the geometry QStringList list = QStringList() << "trer" << "ezrfgtgvqd" << "sdgzgzerzerzer" << "eerzertz" << "er"; @@ -1667,12 +1667,15 @@ void tst_QMenuBar::menubarSizeHint() void tst_QMenuBar::taskQTBUG4965_escapeEaten() { +#ifdef Q_WS_MAC + QSKIP("On Mac, do not test the menubar with escape key", SkipAll); +#endif QMenuBar menubar; QMenu menu("menu1"); QAction *first = menubar.addMenu(&menu); menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC")); menubar.show(); - menubar.setActiveWindow(); + QApplication::setActiveWindow(&menubar); QTest::qWaitForWindowShown(&menubar); menubar.setActiveAction(first); QTRY_VERIFY(menu.isVisible()); diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 5035139..67a9c46 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -60,6 +60,10 @@ #include <QProcess> #include "qobject.h" +#ifdef QT_BUILD_INTERNAL +#include <private/qobject_p.h> +#endif + #include <math.h> @@ -121,6 +125,7 @@ private slots: void interfaceIid(); void deleteQObjectWhenDeletingEvent(); void overloads(); + void isSignalConnected(); protected: }; @@ -3016,5 +3021,109 @@ void tst_QObject::overloads() QCOMPARE(obj2.o4_obj, qApp); //default arg of the slot } +class ManySignals : public QObject +{ Q_OBJECT + friend class tst_QObject; +signals: + void sig00(); void sig01(); void sig02(); void sig03(); void sig04(); + void sig05(); void sig06(); void sig07(); void sig08(); void sig09(); + void sig10(); void sig11(); void sig12(); void sig13(); void sig14(); + void sig15(); void sig16(); void sig17(); void sig18(); void sig19(); + void sig20(); void sig21(); void sig22(); void sig23(); void sig24(); + void sig25(); void sig26(); void sig27(); void sig28(); void sig29(); + void sig30(); void sig31(); void sig32(); void sig33(); void sig34(); + void sig35(); void sig36(); void sig37(); void sig38(); void sig39(); + void sig40(); void sig41(); void sig42(); void sig43(); void sig44(); + void sig45(); void sig46(); void sig47(); void sig48(); void sig49(); + void sig50(); void sig51(); void sig52(); void sig53(); void sig54(); + void sig55(); void sig56(); void sig57(); void sig58(); void sig59(); + void sig60(); void sig61(); void sig62(); void sig63(); void sig64(); + void sig65(); void sig66(); void sig67(); void sig68(); void sig69(); + +public slots: + void received() { rec++; } +public: + int rec; +}; + + +void tst_QObject::isSignalConnected() +{ + ManySignals o; + o.rec = 0; +#ifdef QT_BUILD_INTERNAL + QObjectPrivate *priv = QObjectPrivate::get(&o); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("destroyed()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig00()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()"))); + if (sizeof(void *) >= 8) { //on 32bit isSignalConnected only works with the first 32 signals + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()"))); + } +#endif + + QObject::connect(&o, SIGNAL(sig00()), &o, SIGNAL(sig69())); + QObject::connect(&o, SIGNAL(sig34()), &o, SIGNAL(sig03())); + QObject::connect(&o, SIGNAL(sig69()), &o, SIGNAL(sig34())); + QObject::connect(&o, SIGNAL(sig03()), &o, SIGNAL(sig18())); + +#ifdef QT_BUILD_INTERNAL + QVERIFY(!priv->isSignalConnected(priv->signalIndex("destroyed()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()"))); + + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig00()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig03()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig34()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig18()"))); +#endif + + QObject::connect(&o, SIGNAL(sig18()), &o, SIGNAL(sig29())); + QObject::connect(&o, SIGNAL(sig29()), &o, SIGNAL(sig62())); + QObject::connect(&o, SIGNAL(sig62()), &o, SIGNAL(sig28())); + QObject::connect(&o, SIGNAL(sig28()), &o, SIGNAL(sig27())); + +#ifdef QT_BUILD_INTERNAL + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig18()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig62()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig28()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig27()"))); +#endif + + QCOMPARE(o.rec, 0); + emit o.sig01(); + emit o.sig34(); + QCOMPARE(o.rec, 0); + + QObject::connect(&o, SIGNAL(sig27()), &o, SLOT(received())); + +#ifdef QT_BUILD_INTERNAL + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig00()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig03()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig34()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig18()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig62()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig28()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig27()"))); + + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig04()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig21()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig25()"))); +#endif + + emit o.sig00(); + QCOMPARE(o.rec, 1); + emit o.sig69(); + QCOMPARE(o.rec, 2); + emit o.sig36(); + QCOMPARE(o.rec, 2); +} + QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index e99e9d6..b7839f7 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -135,6 +135,7 @@ private slots: void task251296_hiddenChildren(); void task252507_mapFromToSource(); void task255652_removeRowsRecursive(); + void taskQTBUG_6205_doubleProxySelectionSetSourceModel(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -2815,5 +2816,41 @@ void tst_QSortFilterProxyModel::task255652_removeRowsRecursive() delete pItem11; } +void tst_QSortFilterProxyModel::taskQTBUG_6205_doubleProxySelectionSetSourceModel() +{ + QStandardItemModel *model1 = new QStandardItemModel; + QStandardItem *parentItem = model1->invisibleRootItem(); + for (int i = 0; i < 4; ++i) { + QStandardItem *item = new QStandardItem(QString("model1 item %0").arg(i)); + parentItem->appendRow(item); + parentItem = item; + } + + QStandardItemModel *model2 = new QStandardItemModel; + QStandardItem *parentItem2 = model2->invisibleRootItem(); + for (int i = 0; i < 4; ++i) { + QStandardItem *item = new QStandardItem(QString("model2 item %0").arg(i)); + parentItem2->appendRow(item); + parentItem2 = item; + } + + QSortFilterProxyModel *toggleProxy = new QSortFilterProxyModel; + toggleProxy->setSourceModel(model1); + + QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel; + proxyModel->setSourceModel(toggleProxy); + + QModelIndex mi = proxyModel->index(0, 0, proxyModel->index(0, 0, proxyModel->index(0, 0))); + QItemSelectionModel ism(proxyModel); + ism.select(mi, QItemSelectionModel::Select); + QModelIndexList mil = ism.selectedIndexes(); + QCOMPARE(mil.count(), 1); + QCOMPARE(mil.first(), mi); + + toggleProxy->setSourceModel(model2); + // No crash, it's good news! + QVERIFY(ism.selection().isEmpty()); +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index 2389060..655de15 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -146,6 +146,8 @@ private slots: void sizeHint(); + void taskQTBUG_5008_textFromValueAndValidate(); + public slots: void valueChangedHelper(const QString &); void valueChangedHelper(int); @@ -1004,5 +1006,38 @@ void tst_QSpinBox::sizeHint() delete widget; } +void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate() +{ + class DecoratedSpinBox : public QSpinBox + { + public: + DecoratedSpinBox() + { + setLocale(QLocale::French); + setMaximum(100000000); + setValue(1000000); + } + + //we use the French delimiters here + QString textFromValue (int value) const + { + return locale().toString(value); + } + + using QSpinBox::lineEdit; + } spinbox; + spinbox.show(); + spinbox.activateWindow(); + spinbox.setFocus(); + QTest::qWaitForWindowShown(&spinbox); + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); + spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator + QTest::keyClick(0, Qt::Key_0); // let's insert a 0 + QCOMPARE(spinbox.value(), 10000000); //it's been multiplied by 10 + spinbox.clearFocus(); //make sure the value is correctly formatted + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); +} + + QTEST_MAIN(tst_QSpinBox) #include "tst_qspinbox.moc" diff --git a/tests/auto/qstatusbar/tst_qstatusbar.cpp b/tests/auto/qstatusbar/tst_qstatusbar.cpp index 92d9185..03d8ca8 100644 --- a/tests/auto/qstatusbar/tst_qstatusbar.cpp +++ b/tests/auto/qstatusbar/tst_qstatusbar.cpp @@ -266,10 +266,15 @@ void tst_QStatusBar::QTBUG4334_hiddenOnMaximizedWindow() main.setStatusBar(&statusbar); main.showMaximized(); QTest::qWaitForWindowShown(&main); +#ifndef Q_WS_MAC QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible()); +#endif main.showNormal(); QTest::qWaitForWindowShown(&main); QVERIFY(statusbar.findChild<QSizeGrip*>()->isVisible()); + main.showFullScreen(); + QTest::qWaitForWindowShown(&main); + QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible()); } QTEST_MAIN(tst_QStatusBar) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 1e3f5f8..9960f47 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -391,6 +391,7 @@ private slots: #endif void focusProxyAndInputMethods(); + void scrollWithoutBackingStore(); private: bool ensureScreenSize(int width, int height); @@ -9703,5 +9704,42 @@ void tst_QWidget::focusProxyAndInputMethods() delete toplevel; } +class scrollWidgetWBS : public QWidget +{ +public: + void deleteBackingStore() + { + if (static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) { + delete static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore; + static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = 0; + } + } + void enableBackingStore() + { + if (!static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) { + static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = new QWidgetBackingStore(this); + static_cast<QWidgetPrivate*>(d_ptr.data())->invalidateBuffer(this->rect()); + repaint(); + } + } +}; + +void tst_QWidget::scrollWithoutBackingStore() +{ + scrollWidgetWBS scrollable; + scrollable.resize(100,100); + QLabel child(QString("@"),&scrollable); + child.resize(50,50); + scrollable.show(); + QTest::qWaitForWindowShown(&scrollable); + scrollable.scroll(50,50); + QCOMPARE(child.pos(),QPoint(50,50)); + scrollable.deleteBackingStore(); + scrollable.scroll(-25,-25); + QCOMPARE(child.pos(),QPoint(25,25)); + scrollable.enableBackingStore(); + QCOMPARE(child.pos(),QPoint(25,25)); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" diff --git a/tests/auto/qwidget_window/tst_qwidget_window.cpp b/tests/auto/qwidget_window/tst_qwidget_window.cpp index 13d1d2d..ec11ab3 100644 --- a/tests/auto/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/qwidget_window/tst_qwidget_window.cpp @@ -52,6 +52,9 @@ #include <QX11Info> #endif // Q_WS_X11 +#include "../../shared/util.h" + + class tst_QWidget_window : public QWidget { Q_OBJECT @@ -150,7 +153,7 @@ void tst_QWidget_window::tst_show_resize_hide_show() class TestWidget : public QWidget { public: - int m_first, m_next; + int m_first, m_next; bool paintEventReceived; void reset(){ m_first = m_next = 0; paintEventReceived = false; } @@ -163,7 +166,7 @@ public: case QEvent::Show: if (m_first) m_next = event->type(); - else + else m_first = event->type(); break; case QEvent::Paint: @@ -173,7 +176,7 @@ public: break; } return QWidget::event(event); - } + } }; void tst_QWidget_window::tst_windowFilePathAndwindowTitle_data() @@ -289,7 +292,7 @@ void tst_QWidget_window::tst_showWithoutActivating() #else QWidget w; w.show(); - qt_x11_wait_for_window_manager(&w); + QTest::qWaitForWindowShown(&w); QApplication::processEvents(); QApplication::clipboard(); @@ -302,8 +305,11 @@ void tst_QWidget_window::tst_showWithoutActivating() Window window; int revertto; - XGetInputFocus(QX11Info::display(), &window, &revertto); - QCOMPARE(lineEdit->winId(), window); + QTRY_COMPARE(lineEdit->winId(), + (XGetInputFocus(QX11Info::display(), &window, &revertto), window) ); + // Note the use of the , before window because we want the XGetInputFocus to be re-executed + // in each iteration of the inside loop of the QTRY_COMPARE macro + #endif // Q_WS_X11 } @@ -315,11 +321,9 @@ void tst_QWidget_window::tst_paintEventOnSecondShow() w.reset(); w.show(); -#ifdef Q_WS_X11 - QTest::qWait(500); -#endif + QTest::qWaitForWindowShown(&w); QApplication::processEvents(); - QVERIFY(w.paintEventReceived); + QTRY_VERIFY(w.paintEventReceived); } QTEST_MAIN(tst_QWidget_window) diff --git a/tests/auto/rcc/data/images.expected b/tests/auto/rcc/data/images.expected index 24d75b6..71be819 100644 --- a/tests/auto/rcc/data/images.expected +++ b/tests/auto/rcc/data/images.expected @@ -97,10 +97,10 @@ static const unsigned char qt_resource_struct[] = { QT_BEGIN_NAMESPACE -extern bool qRegisterResourceData +extern Q_CORE_EXPORT bool qRegisterResourceData (int, const unsigned char *, const unsigned char *, const unsigned char *); -extern bool qUnregisterResourceData +extern Q_CORE_EXPORT bool qUnregisterResourceData (int, const unsigned char *, const unsigned char *, const unsigned char *); QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 6f6875f..7488662 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -223,6 +223,7 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); vboxLayout->setMargin(0); + tabWidget = new QTabWidget(this); #ifndef Q_OS_MAC resourcePath.append(QLatin1String("win")); #else @@ -230,7 +231,6 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) tabWidget->setDocumentMode(true); #endif - tabWidget = new QTabWidget(this); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int))); diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index 5c3aaa1..383f5aa 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -305,8 +305,6 @@ MainWindow::MainWindow() m_contextView->setModel(m_sortedContextsModel); m_contextView->header()->setMovable(false); m_contextView->setColumnHidden(0, true); - m_contextView->header()->setResizeMode(1, QHeaderView::Stretch); - m_contextView->header()->setResizeMode(2, QHeaderView::ResizeToContents); m_contextView->header()->setStretchLastSection(false); m_contextDock->setWidget(m_contextView); @@ -335,8 +333,6 @@ MainWindow::MainWindow() m_messageView->setModel(m_sortedMessagesModel); m_messageView->header()->setMovable(false); m_messageView->setColumnHidden(0, true); - m_messageView->setColumnHidden(2, true); - // last visible column auto-stretches m_messagesDock->setWidget(m_messageView); @@ -443,6 +439,7 @@ MainWindow::MainWindow() statusBar()->addPermanentWidget(m_modifiedLabel); modelCountChanged(); + initViewHeaders(); resetSorting(); connect(m_dataModel, SIGNAL(modifiedChanged(bool)), @@ -509,6 +506,14 @@ MainWindow::~MainWindow() delete m_printer; } +void MainWindow::initViewHeaders() +{ + m_contextView->header()->setResizeMode(1, QHeaderView::Stretch); + m_contextView->header()->setResizeMode(2, QHeaderView::ResizeToContents); + m_messageView->setColumnHidden(2, true); + // last visible column auto-stretches +} + void MainWindow::modelCountChanged() { int mc = m_dataModel->modelCount(); @@ -740,6 +745,7 @@ bool MainWindow::closeAll() m_messageView->setUpdatesEnabled(false); m_dataModel->closeAll(); modelCountChanged(); + initViewHeaders(); recentFiles().closeGroup(); return true; } @@ -2348,6 +2354,17 @@ void MainWindow::updatePhraseDicts() m_phraseView->update(); } +static bool haveMnemonic(const QString &str) +{ + QString mnemonic = QKeySequence::mnemonic(str); + if (mnemonic == QLatin1String("Alt+Space")) { + // "Nobody" ever really uses these, and they are highly annoying + // because we get a lot of false positives. + return false; + } + return !mnemonic.isEmpty(); +} + void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) { MultiDataIndex curIdx = index; @@ -2379,10 +2396,10 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) } if (m_ui.actionAccelerators->isChecked()) { - bool sk = !QKeySequence::mnemonic(source).isEmpty(); + bool sk = haveMnemonic(source); bool tk = true; for (int i = 0; i < translations.count() && tk; ++i) { - tk &= !QKeySequence::mnemonic(translations[i]).isEmpty(); + tk &= haveMnemonic(translations[i]); } if (!sk && tk) { diff --git a/tools/linguist/linguist/mainwindow.h b/tools/linguist/linguist/mainwindow.h index 8b46893..dc711d8 100644 --- a/tools/linguist/linguist/mainwindow.h +++ b/tools/linguist/linguist/mainwindow.h @@ -179,6 +179,7 @@ private: bool prev(bool checkUnfinished); void updateStatistics(); + void initViewHeaders(); void modelCountChanged(); void setupMenuBar(); void setupToolBars(); diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index 024fd91..49cd382 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -786,16 +786,9 @@ void MultiDataModel::closeAll() m_numFinished = 0; m_numEditable = 0; m_numMessages = 0; - int delCol = m_dataModels.count(); - m_msgModel->beginRemoveColumns(QModelIndex(), 1, delCol); - for (int i = m_multiContextList.size(); --i >= 0;) { - m_msgModel->beginRemoveColumns(m_msgModel->createIndex(i, 0, 0), 1, delCol); - m_msgModel->endRemoveColumns(); - } qDeleteAll(m_dataModels); m_dataModels.clear(); m_multiContextList.clear(); - m_msgModel->endRemoveColumns(); m_msgModel->reset(); emit allModelsDeleted(); onModifiedChanged(); diff --git a/tools/linguist/linguist/translationsettingsdialog.cpp b/tools/linguist/linguist/translationsettingsdialog.cpp index 0d94c3a..562f14e 100644 --- a/tools/linguist/linguist/translationsettingsdialog.cpp +++ b/tools/linguist/linguist/translationsettingsdialog.cpp @@ -60,15 +60,7 @@ TranslationSettingsDialog::TranslationSettingsDialog(QWidget *parent) m_ui.srcCbLanguageList->model()->sort(0, Qt::AscendingOrder); m_ui.srcCbLanguageList->insertItem(0, QLatin1String("POSIX"), QVariant(QLocale::C)); - for (int i = QLocale::AnyCountry + 1; i < QLocale::LastCountry; ++i) { - QString country = QLocale::countryToString(QLocale::Country(i)); - m_ui.srcCbCountryList->addItem(country, QVariant(i)); - } - m_ui.srcCbCountryList->model()->sort(0, Qt::AscendingOrder); - m_ui.srcCbCountryList->insertItem(0, tr("Any Country"), QVariant(QLocale::AnyCountry)); - m_ui.tgtCbLanguageList->setModel(m_ui.srcCbLanguageList->model()); - m_ui.tgtCbCountryList->setModel(m_ui.srcCbCountryList->model()); } void TranslationSettingsDialog::setDataModel(DataModel *dataModel) @@ -87,6 +79,31 @@ void TranslationSettingsDialog::setPhraseBook(PhraseBook *phraseBook) setWindowTitle(tr("Settings for '%1' - Qt Linguist").arg(fn)); } +static void fillCountryCombo(const QVariant &lng, QComboBox *combo) +{ + combo->clear(); + QLocale::Language lang = QLocale::Language(lng.toInt()); + if (lang != QLocale::C) { + foreach (QLocale::Country cntr, QLocale::countriesForLanguage(lang)) { + QString country = QLocale::countryToString(cntr); + combo->addItem(country, QVariant(cntr)); + } + combo->model()->sort(0, Qt::AscendingOrder); + } + combo->insertItem(0, TranslationSettingsDialog::tr("Any Country"), QVariant(QLocale::AnyCountry)); + combo->setCurrentIndex(0); +} + +void TranslationSettingsDialog::on_srcCbLanguageList_currentIndexChanged(int idx) +{ + fillCountryCombo(m_ui.srcCbLanguageList->itemData(idx), m_ui.srcCbCountryList); +} + +void TranslationSettingsDialog::on_tgtCbLanguageList_currentIndexChanged(int idx) +{ + fillCountryCombo(m_ui.tgtCbLanguageList->itemData(idx), m_ui.tgtCbCountryList); +} + void TranslationSettingsDialog::on_buttonBox_accepted() { int itemindex = m_ui.tgtCbLanguageList->currentIndex(); diff --git a/tools/linguist/linguist/translationsettingsdialog.h b/tools/linguist/linguist/translationsettingsdialog.h index 2408add..7908cd7 100644 --- a/tools/linguist/linguist/translationsettingsdialog.h +++ b/tools/linguist/linguist/translationsettingsdialog.h @@ -66,6 +66,8 @@ private: private slots: void on_buttonBox_accepted(); + void on_srcCbLanguageList_currentIndexChanged(int idx); + void on_tgtCbLanguageList_currentIndexChanged(int idx); private: Ui::TranslationSettingsDialog m_ui; diff --git a/tools/linguist/shared/qph.cpp b/tools/linguist/shared/qph.cpp index 788245c..32bdabb 100644 --- a/tools/linguist/shared/qph.cpp +++ b/tools/linguist/shared/qph.cpp @@ -81,14 +81,20 @@ bool QPHReader::read(Translator &translator) while (!atEnd()) { readNext(); if (isStartElement()) { - if (name() == QLatin1String("source")) + if (name() == QLatin1String("source")) { m_currentField = SourceField; - else if (name() == QLatin1String("target")) + } else if (name() == QLatin1String("target")) { m_currentField = TargetField; - else if (name() == QLatin1String("definition")) + } else if (name() == QLatin1String("definition")) { m_currentField = DefinitionField; - else + } else { m_currentField = NoField; + if (name() == QLatin1String("QPH")) { + QXmlStreamAttributes atts = attributes(); + translator.setLanguageCode(atts.value(QLatin1String("language")).toString()); + translator.setSourceLanguageCode(atts.value(QLatin1String("sourcelanguage")).toString()); + } + } } else if (isWhiteSpace()) { // ignore these } else if (isCharacters()) { @@ -104,7 +110,7 @@ bool QPHReader::read(Translator &translator) TranslatorMessage msg; msg.setSourceText(m_currentSource); msg.setTranslation(m_currentTarget); - msg.setTranslatorComment(m_currentDefinition); + msg.setComment(m_currentDefinition); translator.append(msg); m_currentSource.clear(); m_currentTarget.clear(); @@ -157,7 +163,14 @@ static bool saveQPH(const Translator &translator, QIODevice &dev, ConversionData { QTextStream t(&dev); t.setCodec(QTextCodec::codecForName("UTF-8")); - t << "<!DOCTYPE QPH>\n<QPH>\n"; + t << "<!DOCTYPE QPH>\n<QPH"; + QString languageCode = translator.languageCode(); + if (!languageCode.isEmpty() && languageCode != QLatin1String("C")) + t << " language=\"" << languageCode << "\""; + languageCode = translator.sourceLanguageCode(); + if (!languageCode.isEmpty() && languageCode != QLatin1String("C")) + t << " sourcelanguage=\"" << languageCode << "\""; + t << ">\n"; foreach (const TranslatorMessage &msg, translator.messages()) { t << "<phrase>\n"; t << " <source>" << protect(msg.sourceText()) << "</source>\n"; @@ -166,9 +179,8 @@ static bool saveQPH(const Translator &translator, QIODevice &dev, ConversionData QChar(Translator::TextVariantSeparator)); t << " <target>" << protect(str) << "</target>\n"; - if (!msg.context().isEmpty() || !msg.comment().isEmpty()) - t << " <definition>" << msg.context() << msg.comment() - << "</definition>\n"; + if (!msg.comment().isEmpty()) + t << " <definition>" << protect(msg.comment()) << "</definition>\n"; t << "</phrase>\n"; } t << "</QPH>\n"; diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 353cf9d..fa447a3 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -55,10 +55,12 @@ QT_BEGIN_NAMESPACE #ifdef QT_BOOTSTRAPPED -struct QObject { +class QObject { +public: static QString tr(const char *sourceText, const char * = 0, int n = -1); }; -struct QCoreApplication : public QObject { +class QCoreApplication : public QObject { +public: enum Encoding { CodecForTr }; static QString translate(const char *, const char *sourceText, const char * = 0, Encoding = CodecForTr, int n = -1) diff --git a/translations/translations.pri b/translations/translations.pri index 5eb7328..7a24a4f 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -9,7 +9,7 @@ defineReplace(prependAll) { } LUPDATE = $$QT_BUILD_TREE/bin/lupdate -locations relative -no-ui-lines -win32:isEmpty(QMAKE_SH):LUPDATE ~= s|/|\\|g +LUPDATE ~= s,/,$$QMAKE_DIR_SEP, ###### Qt Libraries diff --git a/translations/translations.pro b/translations/translations.pro index 60f84e6..ef09dc3 100644 --- a/translations/translations.pro +++ b/translations/translations.pro @@ -1,7 +1,7 @@ TRANSLATIONS = $$files(*.ts) LRELEASE = $$QT_BUILD_TREE/bin/lrelease -win32:isEmpty(QMAKE_SH):LRELEASE ~= s|/|\\|g +LRELEASE ~= s,/,$$QMAKE_DIR_SEP, contains(TEMPLATE_PREFIX, vc):vcproj = 1 |