diff options
55 files changed, 1143 insertions, 320 deletions
diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 6a94f26..bedf58a 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -49,3 +49,8 @@ information about a particular change. - QStyleOptionGraphicsItem::levelOfDetails is obsoleted and its value is always initialized to 1. For a more fine-grained value use QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &). + + - When mixing OpenGL and QPainter calls you need to first call syncState() + on the paint engine, for example "painter->paintEngine()->syncState()". + This is to ensure that the engine flushes any pending drawing and sets up + the GL modelview/projection matrices properly. diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 16307e6..61d61df 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer); +Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer) QUnifiedTimer::QUnifiedTimer() : QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), consistentTiming(false) { diff --git a/src/corelib/animation/qanimationgroup_p.h b/src/corelib/animation/qanimationgroup_p.h index a7bd0fa..0f07138 100644 --- a/src/corelib/animation/qanimationgroup_p.h +++ b/src/corelib/animation/qanimationgroup_p.h @@ -57,7 +57,7 @@ #include <QtCore/qlist.h> -#include "qabstractanimation_p.h" +#include "private/qabstractanimation_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h index f36d972..ecd6791 100644 --- a/src/corelib/animation/qparallelanimationgroup_p.h +++ b/src/corelib/animation/qparallelanimationgroup_p.h @@ -54,7 +54,7 @@ // #include "qparallelanimationgroup.h" -#include "qanimationgroup_p.h" +#include "private/qanimationgroup_p.h" #include <QtCore/QHash> QT_BEGIN_NAMESPACE diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 47361a5..43b5283 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE typedef QPair<QObject *, QByteArray> QPropertyAnimationPair; typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash; -Q_GLOBAL_STATIC(QPropertyAnimationHash, _q_runningAnimations); +Q_GLOBAL_STATIC(QPropertyAnimationHash, _q_runningAnimations) Q_GLOBAL_STATIC_WITH_ARGS(QMutex, guardHashLock, (QMutex::Recursive) ) void QPropertyAnimationPrivate::updateMetaProperty() diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h index 39317ba..2fdd50c 100644 --- a/src/corelib/animation/qpropertyanimation.h +++ b/src/corelib/animation/qpropertyanimation.h @@ -76,7 +76,7 @@ protected: void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); private: - Q_PRIVATE_SLOT(d_func(), void _q_targetDestroyed()); + Q_PRIVATE_SLOT(d_func(), void _q_targetDestroyed()) Q_DISABLE_COPY(QPropertyAnimation) Q_DECLARE_PRIVATE(QPropertyAnimation) }; diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h index a4387dd..16c63ab 100644 --- a/src/corelib/animation/qpropertyanimation_p.h +++ b/src/corelib/animation/qpropertyanimation_p.h @@ -56,7 +56,7 @@ #include "qpropertyanimation.h" #include <QtCore/qmetaobject.h> -#include "qvariantanimation_p.h" +#include "private/qvariantanimation_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h index 3ac90f8..c01aaf0 100644 --- a/src/corelib/animation/qsequentialanimationgroup_p.h +++ b/src/corelib/animation/qsequentialanimationgroup_p.h @@ -54,7 +54,7 @@ // #include "qsequentialanimationgroup.h" -#include "qanimationgroup_p.h" +#include "private/qanimationgroup_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index aee2324..3ae0e39 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -58,7 +58,7 @@ #include <QtCore/qmetaobject.h> #include <QtCore/qvector.h> -#include "qabstractanimation_p.h" +#include "private/qabstractanimation_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/io/qfilesystemwatcher_dnotify.cpp b/src/corelib/io/qfilesystemwatcher_dnotify.cpp index e87375a..a8397f8 100644 --- a/src/corelib/io/qfilesystemwatcher_dnotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_dnotify.cpp @@ -114,7 +114,7 @@ private: bool isExecing; }; -Q_GLOBAL_STATIC(QDnotifySignalThread, dnotifySignal); +Q_GLOBAL_STATIC(QDnotifySignalThread, dnotifySignal) QDnotifySignalThread::QDnotifySignalThread() : isExecing(false) diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index f50acdb..1ff3a4c 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -143,11 +143,11 @@ QT_BEGIN_NAMESPACE QNonContiguousByteDevice::QNonContiguousByteDevice() : QObject((QObject*)0), resetDisabled(false) { -}; +} QNonContiguousByteDevice::~QNonContiguousByteDevice() { -}; +} void QNonContiguousByteDevice::disableReset() { @@ -253,7 +253,7 @@ QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(Q QNonContiguousByteDeviceRingBufferImpl::~QNonContiguousByteDeviceRingBufferImpl() { -}; +} const char* QNonContiguousByteDeviceRingBufferImpl::readPointer(qint64 maximumLength, qint64 &len) { @@ -268,19 +268,19 @@ const char* QNonContiguousByteDeviceRingBufferImpl::readPointer(qint64 maximumLe len = qMin(len, maximumLength); return returnValue; -}; +} bool QNonContiguousByteDeviceRingBufferImpl::advanceReadPointer(qint64 amount) { currentPosition += amount; emit readProgress(currentPosition, size()); return true; -}; +} bool QNonContiguousByteDeviceRingBufferImpl::atEnd() { return currentPosition >= size(); -}; +} bool QNonContiguousByteDeviceRingBufferImpl::reset() { @@ -289,12 +289,12 @@ bool QNonContiguousByteDeviceRingBufferImpl::reset() currentPosition = 0; return true; -}; +} qint64 QNonContiguousByteDeviceRingBufferImpl::size() { return ringBuffer->size(); -}; +} QNonContiguousByteDeviceIoDeviceImpl::QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d) : QNonContiguousByteDevice(), @@ -306,12 +306,12 @@ QNonContiguousByteDeviceIoDeviceImpl::QNonContiguousByteDeviceIoDeviceImpl(QIODe initialPosition = d->pos(); connect(device, SIGNAL(readyRead()), this, SIGNAL(readyRead()), Qt::QueuedConnection); connect(device, SIGNAL(readChannelFinished()), this, SIGNAL(readyRead()), Qt::QueuedConnection); -}; +} QNonContiguousByteDeviceIoDeviceImpl::~QNonContiguousByteDeviceIoDeviceImpl() { delete currentReadBuffer; -}; +} const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLength, qint64 &len) { @@ -347,7 +347,7 @@ const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLeng len = haveRead; return currentReadBuffer->data(); -}; +} bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount) { @@ -377,12 +377,12 @@ bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount) emit readProgress(totalAdvancements, size()); return true; -}; +} bool QNonContiguousByteDeviceIoDeviceImpl::atEnd() { return eof == true; -}; +} bool QNonContiguousByteDeviceIoDeviceImpl::reset() { @@ -395,7 +395,7 @@ bool QNonContiguousByteDeviceIoDeviceImpl::reset() } return false; -}; +} qint64 QNonContiguousByteDeviceIoDeviceImpl::size() { @@ -405,7 +405,7 @@ qint64 QNonContiguousByteDeviceIoDeviceImpl::size() return -1; return device->size() - initialPosition; -}; +} QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd) : QIODevice((QObject*)0) { @@ -497,7 +497,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *dev // generic QIODevice return new QNonContiguousByteDeviceIoDeviceImpl(device); // FIXME -}; +} /*! \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *ringBuffer); @@ -509,7 +509,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *dev QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *ringBuffer) { return new QNonContiguousByteDeviceRingBufferImpl(ringBuffer); -}; +} /*! \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray); @@ -521,7 +521,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *r QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray) { return new QNonContiguousByteDeviceByteArrayImpl(byteArray); -}; +} /*! \fn static QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice); diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 3e4b467..5ba9898 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -206,8 +206,6 @@ static int numerusHelper(int n, const uchar *rules, int rulesSize) return -1; } -extern bool qt_detectRTLLanguage(); - class QTranslatorPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QTranslator) @@ -348,7 +346,7 @@ QTranslator::QTranslator(QObject * parent, const char * name) QTranslator::~QTranslator() { if (QCoreApplication::instance()) - QCoreApplication::instance()->removeTranslator(this); + QCoreApplication::removeTranslator(this); Q_D(QTranslator); d->clear(); } diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 5163027..4740bf1 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC(QList<QFactoryLoader *>, qt_factory_loaders); +Q_GLOBAL_STATIC(QList<QFactoryLoader *>, qt_factory_loaders) Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_factoryloader_mutex, (QMutex::Recursive)) diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h index 600cec0..ab17ad3 100644 --- a/src/corelib/statemachine/qeventtransition_p.h +++ b/src/corelib/statemachine/qeventtransition_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qabstracttransition_p.h" +#include "private/qabstracttransition_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h index 5aaa64c..875dac8 100644 --- a/src/corelib/statemachine/qhistorystate_p.h +++ b/src/corelib/statemachine/qhistorystate_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qabstractstate_p.h" +#include "private/qabstractstate_p.h" #include <QtCore/qlist.h> diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h index 339de63..aacb6fc 100644 --- a/src/corelib/statemachine/qsignaltransition_p.h +++ b/src/corelib/statemachine/qsignaltransition_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qabstracttransition_p.h" +#include "private/qabstracttransition_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h index 93744b9..eddd831 100644 --- a/src/corelib/statemachine/qstate_p.h +++ b/src/corelib/statemachine/qstate_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qabstractstate_p.h" +#include "private/qabstractstate_p.h" #include <QtCore/qlist.h> #include <QtCore/qbytearray.h> diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 54953b4..24073ca 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -62,7 +62,7 @@ #include <QtCore/qvector.h> #include "qstate.h" -#include "qstate_p.h" +#include "private/qstate_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 9d36a83..b07b948 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -96,7 +96,7 @@ public: ShowBase = 0x80, UppercaseBase = 0x100, - ForcePoint = Alternate, + ForcePoint = Alternate }; enum GroupSeparatorMode { diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index b807a89..2b4a242 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -71,8 +71,8 @@ /*! \fn int QLatin1Literal::size() const - Returns the number of characters in the literal \i{excluding} the trailing - NUL char. + Returns the number of characters in the literal \e{excluding} the trailing + NULL char. */ /*! \fn char *QLatin1Literal::data() const @@ -122,7 +122,7 @@ \sa QLatin1Literal, QString */ -/* !fn template <class A, class B> QStringBuilder<A, B> operator%(const A &a, const B &b) +/* \fn template <class A, class B> QStringBuilder<A, B> operator%(const A &a, const B &b) Returns a \c QStringBuilder object that is converted to a QString object when assigned to a variable of QString type or passed to a function that diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 9165836..554e9d5 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -88,6 +88,52 @@ QT_BEGIN_NAMESPACE +Q_GLOBAL_STATIC(QMacWindowFader, macwindowFader); + +QMacWindowFader::QMacWindowFader() + : m_duration(0.250) +{ +} + +QMacWindowFader *QMacWindowFader::currentFader() +{ + return macwindowFader(); +} + +void QMacWindowFader::registerWindowToFade(QWidget *window) +{ + m_windowsToFade.append(window); +} + +void QMacWindowFader::performFade() +{ + const QWidgetList myWidgetsToFade = m_windowsToFade; + const int widgetCount = myWidgetsToFade.count(); +#if QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; + [NSAnimationContext beginGrouping]; + [[NSAnimationContext currentContext] setDuration:NSTimeInterval(m_duration)]; +#endif + + for (int i = 0; i < widgetCount; ++i) { + QWidget *widget = m_windowsToFade.at(i); + OSWindowRef window = qt_mac_window_for(widget); +#if QT_MAC_USE_COCOA + [[window animator] setAlphaValue:0.0]; + QTimer::singleShot(qRound(m_duration * 1000), widget, SLOT(hide())); +#else + TransitionWindowOptions options = {0, m_duration, 0, 0}; + TransitionWindowWithOptions(window, kWindowFadeTransitionEffect, kWindowHideTransitionAction, + 0, 1, &options); +#endif + } +#if QT_MAC_USE_COCOA + [NSAnimationContext endGrouping]; +#endif + m_duration = 0.250; + m_windowsToFade.clear(); +} + extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp; extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm extern QWidget * mac_mouse_grabber; @@ -95,29 +141,26 @@ extern QWidget * mac_mouse_grabber; void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds) { OSWindowRef wnd = static_cast<OSWindowRef>(window); - if( wnd ) { + if (wnd) { + QWidget *widget; #if QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; - [NSAnimationContext beginGrouping]; - [[wnd animator] setAlphaValue:0.0]; - if (durationSeconds > 0) { - [[NSAnimationContext currentContext] setDuration:NSTimeInterval(durationSeconds)]; - } else { - durationSeconds = [[NSAnimationContext currentContext] duration]; - } - [NSAnimationContext endGrouping]; - QTimer::singleShot(qRound(durationSeconds * 1000), [wnd QT_MANGLE_NAMESPACE(qt_qwidget)], SLOT(hide())); + widget = [wnd QT_MANGLE_NAMESPACE(qt_qwidget)]; #else - if (durationSeconds <= 0) - durationSeconds = 0.15; - TransitionWindowOptions options = {0, durationSeconds, 0, 0}; - TransitionWindowWithOptions(wnd, kWindowFadeTransitionEffect, kWindowHideTransitionAction, 0, 1, &options); + const UInt32 kWidgetCreatorQt = kEventClassQt; + enum { + kWidgetPropertyQWidget = 'QWId' //QWidget * + }; + if (GetWindowProperty(static_cast<WindowRef>(window), kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(widget), 0, &widget) != noErr) + widget = 0; #endif - } + if (widget) { + QMacWindowFader::currentFader()->setFadeDuration(durationSeconds); + QMacWindowFader::currentFader()->registerWindowToFade(widget); + QMacWindowFader::currentFader()->performFade(); + } + } } - - bool macWindowIsTextured( void * /*OSWindowRef*/ window ) { OSWindowRef wnd = static_cast<OSWindowRef>(window); diff --git a/src/gui/kernel/qt_mac_p.h b/src/gui/kernel/qt_mac_p.h index ca995dc..3b0f546 100644 --- a/src/gui/kernel/qt_mac_p.h +++ b/src/gui/kernel/qt_mac_p.h @@ -120,6 +120,21 @@ public: } }; +// Class for chaining to gether a bunch of fades. It pretty much is only used for qmenu fading. +class QMacWindowFader +{ + QWidgetList m_windowsToFade; + float m_duration; + Q_DISABLE_COPY(QMacWindowFader) +public: + QMacWindowFader(); // PLEASE DON'T CALL THIS. + static QMacWindowFader *currentFader(); + void registerWindowToFade(QWidget *window); + void setFadeDuration(float durationInSecs) { m_duration = durationInSecs; } + float fadeDuration() const { return m_duration; } + void performFade(); +}; + class Q_GUI_EXPORT QMacCocoaAutoReleasePool { private: diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 7e41ea1..adb48a8 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1359,17 +1359,10 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) // already been set return; - XWMHints *h = 0; - if (q->internalWinId()) - h = XGetWMHints(X11->display, q->internalWinId()); - XWMHints wm_hints; - if (!h) { - memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy - h = &wm_hints; - } - // preparing images to set the _NET_WM_ICON property QIcon icon = q->windowIcon(); + QVector<long> icon_data; + Qt::HANDLE pixmap_handle = 0; if (!icon.isNull()) { QList<QSize> availableSizes = icon.availableSizes(); if(availableSizes.isEmpty()) { @@ -1379,7 +1372,6 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) availableSizes.push_back(QSize(64,64)); availableSizes.push_back(QSize(128,128)); } - QVector<long> icon_data; for(int i = 0; i < availableSizes.size(); ++i) { QSize size = availableSizes.at(i); QPixmap pixmap = icon.pixmap(size); @@ -1401,11 +1393,6 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) } } if (!icon_data.isEmpty()) { - if (q->internalWinId()) { - XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON), XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) icon_data.data(), - icon_data.size()); - } extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); /* if the app is running on an unknown desktop, or it is not @@ -1419,22 +1406,44 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) // unknown DE or non-default visual/colormap, use 1bpp bitmap if (!forceReset || !topData->iconPixmap) topData->iconPixmap = new QBitmap(qt_toX11Pixmap(icon.pixmap(QSize(64,64)))); - h->icon_pixmap = topData->iconPixmap->handle(); + pixmap_handle = topData->iconPixmap->handle(); } else { // default depth, use a normal pixmap (even though this // violates the ICCCM), since this works on all DEs known to Qt if (!forceReset || !topData->iconPixmap) topData->iconPixmap = new QPixmap(qt_toX11Pixmap(icon.pixmap(QSize(64,64)))); - h->icon_pixmap = static_cast<QX11PixmapData*>(topData->iconPixmap->data)->x11ConvertToDefaultDepth(); + pixmap_handle = static_cast<QX11PixmapData*>(topData->iconPixmap->data)->x11ConvertToDefaultDepth(); } - h->flags |= IconPixmapHint; - } else { - h->flags &= ~(IconPixmapHint | IconMaskHint); } } - if (q->internalWinId()) - XSetWMHints(X11->display, q->internalWinId(), h); + if (!q->internalWinId()) + return; + + if (!icon_data.isEmpty()) { + XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON), XA_CARDINAL, 32, + PropModeReplace, (unsigned char *) icon_data.data(), + icon_data.size()); + } else { + XDeleteProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON)); + } + + XWMHints *h = XGetWMHints(X11->display, q->internalWinId()); + XWMHints wm_hints; + if (!h) { + memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy + h = &wm_hints; + } + + if (pixmap_handle) { + h->icon_pixmap = pixmap_handle; + h->flags |= IconPixmapHint; + } else { + h->icon_pixmap = 0; + h->flags &= ~(IconPixmapHint | IconMaskHint); + } + + XSetWMHints(X11->display, q->internalWinId(), h); if (h != &wm_hints) XFree((char *)h); } diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp index a77ca42..6ecd878 100644 --- a/src/gui/math3d/qgenericmatrix.cpp +++ b/src/gui/math3d/qgenericmatrix.cpp @@ -116,7 +116,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QGenericMatrix::fill(qreal value) + \fn void QGenericMatrix::fill(T value) Fills all elements of this matrix with \a value. */ diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h index d0b22de..b4d3707 100644 --- a/src/gui/math3d/qgenericmatrix.h +++ b/src/gui/math3d/qgenericmatrix.h @@ -65,7 +65,7 @@ public: bool isIdentity() const; void setIdentity(); - void fill(qreal value); + void fill(T value); QGenericMatrix<M, N, T, InnerT> transposed() const; @@ -175,7 +175,7 @@ Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::setIdentity() } template <int N, int M, typename T, typename InnerT> -Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::fill(qreal value) +Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::fill(T value) { for (int col = 0; col < N; ++col) for (int row = 0; row < M; ++row) diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index a8dabf3..8ef4da3 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -740,6 +740,43 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector) \overload Multiplies this matrix by another that scales coordinates by the + components \a x, and \a y. Returns this matrix. + + \sa translate(), rotate() +*/ +QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y) +{ + float vx(x); + float vy(y); + if (flagBits == Identity) { + m[0][0] = vx; + m[1][1] = vy; + flagBits = Scale; + } else if (flagBits == Scale || flagBits == (Scale | Translation)) { + m[0][0] *= vx; + m[1][1] *= vy; + } else if (flagBits == Translation) { + m[0][0] = vx; + m[1][1] = vy; + flagBits |= Scale; + } else { + m[0][0] *= vx; + m[0][1] *= vx; + m[0][2] *= vx; + m[0][3] *= vx; + m[1][0] *= vy; + m[1][1] *= vy; + m[1][2] *= vy; + m[1][3] *= vy; + flagBits = General; + } + return *this; +} + +/*! + \overload + + Multiplies this matrix by another that scales coordinates by the components \a x, \a y, and \a z. Returns this matrix. \sa translate(), rotate() @@ -872,6 +909,46 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector) \overload Multiplies this matrix by another that translates coordinates + by the components \a x, and \a y. Returns this matrix. + + \sa scale(), rotate() +*/ +QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y) +{ + float vx(x); + float vy(y); + if (flagBits == Identity) { + m[3][0] = vx; + m[3][1] = vy; + flagBits = Translation; + } else if (flagBits == Translation) { + m[3][0] += vx; + m[3][1] += vy; + } else if (flagBits == Scale) { + m[3][0] = m[0][0] * vx; + m[3][1] = m[1][1] * vy; + m[3][2] = 0.; + flagBits |= Translation; + } else if (flagBits == (Scale | Translation)) { + m[3][0] += m[0][0] * vx; + m[3][1] += m[1][1] * vy; + } else { + m[3][0] += m[0][0] * vx + m[1][0] * vy; + m[3][1] += m[0][1] * vx + m[1][1] * vy; + m[3][2] += m[0][2] * vx + m[1][2] * vy; + m[3][3] += m[0][3] * vx + m[1][3] * vy; + if (flagBits == Rotation) + flagBits |= Translation; + else if (flagBits != (Rotation | Translation)) + flagBits = General; + } + return *this; +} + +/*! + \overload + + Multiplies this matrix by another that translates coordinates by the components \a x, \a y, and \a z. Returns this matrix. \sa scale(), rotate() @@ -1411,8 +1488,6 @@ QTransform QMatrix4x4::toTransform() const #endif /*! - \fn QRect QMatrix4x4::mapRect(const QRect& rect) const - Maps \a rect by multiplying this matrix by the corners of \a rect and then forming a new rectangle from the results. The returned rectangle will be an ordinary 2D rectangle @@ -1420,10 +1495,43 @@ QTransform QMatrix4x4::toTransform() const \sa map() */ +QRect QMatrix4x4::mapRect(const QRect& rect) const +{ + if (flagBits == (Translation | Scale) || flagBits == Scale) { + qreal x = rect.x() * m[0][0] + m[3][0]; + qreal y = rect.y() * m[1][1] + m[3][1]; + qreal w = rect.width() * m[0][0]; + qreal h = rect.height() * m[1][1]; + if (w < 0) { + w = -w; + x -= w; + } + if (h < 0) { + h = -h; + y -= h; + } + return QRect(qRound(x), qRound(y), qRound(w), qRound(h)); + } else if (flagBits == Translation) { + return QRect(qRound(rect.x() + m[3][0]), + qRound(rect.y() + m[3][1]), + rect.width(), rect.height()); + } -/*! - \fn QRectF QMatrix4x4::mapRect(const QRectF& rect) const + QPoint tl = map(rect.topLeft()); + QPoint tr = map(QPoint(rect.x() + rect.width(), rect.y())); + QPoint bl = map(QPoint(rect.x(), rect.y() + rect.height())); + QPoint br = map(QPoint(rect.x() + rect.width(), + rect.y() + rect.height())); + + int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); + int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); + int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); + int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); + + return QRect(xmin, ymin, xmax - xmin, ymax - ymin); +} +/*! Maps \a rect by multiplying this matrix by the corners of \a rect and then forming a new rectangle from the results. The returned rectangle will be an ordinary 2D rectangle @@ -1431,6 +1539,36 @@ QTransform QMatrix4x4::toTransform() const \sa map() */ +QRectF QMatrix4x4::mapRect(const QRectF& rect) const +{ + if (flagBits == (Translation | Scale) || flagBits == Scale) { + qreal x = rect.x() * m[0][0] + m[3][0]; + qreal y = rect.y() * m[1][1] + m[3][1]; + qreal w = rect.width() * m[0][0]; + qreal h = rect.height() * m[1][1]; + if (w < 0) { + w = -w; + x -= w; + } + if (h < 0) { + h = -h; + y -= h; + } + return QRectF(x, y, w, h); + } else if (flagBits == Translation) { + return rect.translated(m[3][0], m[3][1]); + } + + QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight()); + QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight()); + + qreal xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); + qreal xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); + qreal ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); + qreal ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); + + return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); +} /*! \fn float *QMatrix4x4::data() diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 2b485c1..ba7f67f 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -130,9 +130,11 @@ public: QMatrix4x4& translate(const QVector3D& vector); QMatrix4x4& rotate(qreal angle, const QVector3D& vector); #endif - QMatrix4x4& scale(qreal x, qreal y, qreal z = 1.0f); + QMatrix4x4& scale(qreal x, qreal y); + QMatrix4x4& scale(qreal x, qreal y, qreal z); QMatrix4x4& scale(qreal factor); - QMatrix4x4& translate(qreal x, qreal y, qreal z = 0.0f); + QMatrix4x4& translate(qreal x, qreal y); + QMatrix4x4& translate(qreal x, qreal y, qreal z); QMatrix4x4& rotate(qreal angle, qreal x, qreal y, qreal z = 0.0f); #ifndef QT_NO_QUATERNION QMatrix4x4& rotate(const QQuaternion& quaternion); @@ -629,26 +631,43 @@ inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix) inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector) { float x, y, z, w; - x = vector.xp * matrix.m[0][0] + - vector.yp * matrix.m[1][0] + - vector.zp * matrix.m[2][0] + - matrix.m[3][0]; - y = vector.xp * matrix.m[0][1] + - vector.yp * matrix.m[1][1] + - vector.zp * matrix.m[2][1] + - matrix.m[3][1]; - z = vector.xp * matrix.m[0][2] + - vector.yp * matrix.m[1][2] + - vector.zp * matrix.m[2][2] + - matrix.m[3][2]; - w = vector.xp * matrix.m[0][3] + - vector.yp * matrix.m[1][3] + - vector.zp * matrix.m[2][3] + - matrix.m[3][3]; - if (w == 1.0f) - return QVector3D(x, y, z, 1); - else - return QVector3D(x / w, y / w, z / w, 1); + if (matrix.flagBits == QMatrix4x4::Identity) { + return vector; + } else if (matrix.flagBits == QMatrix4x4::Translation) { + return QVector3D(vector.xp + matrix.m[3][0], + vector.yp + matrix.m[3][1], + vector.zp + matrix.m[3][2], 1); + } else if (matrix.flagBits == + (QMatrix4x4::Translation | QMatrix4x4::Scale)) { + return QVector3D(vector.xp * matrix.m[0][0] + matrix.m[3][0], + vector.yp * matrix.m[1][1] + matrix.m[3][1], + vector.zp * matrix.m[2][2] + matrix.m[3][2], 1); + } else if (matrix.flagBits == QMatrix4x4::Scale) { + return QVector3D(vector.xp * matrix.m[0][0], + vector.yp * matrix.m[1][1], + vector.zp * matrix.m[2][2], 1); + } else { + x = vector.xp * matrix.m[0][0] + + vector.yp * matrix.m[1][0] + + vector.zp * matrix.m[2][0] + + matrix.m[3][0]; + y = vector.xp * matrix.m[0][1] + + vector.yp * matrix.m[1][1] + + vector.zp * matrix.m[2][1] + + matrix.m[3][1]; + z = vector.xp * matrix.m[0][2] + + vector.yp * matrix.m[1][2] + + vector.zp * matrix.m[2][2] + + matrix.m[3][2]; + w = vector.xp * matrix.m[0][3] + + vector.yp * matrix.m[1][3] + + vector.zp * matrix.m[2][3] + + matrix.m[3][3]; + if (w == 1.0f) + return QVector3D(x, y, z, 1); + else + return QVector3D(x / w, y / w, z / w, 1); + } } #endif @@ -750,19 +769,33 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point) float x, y, w; xin = point.x(); yin = point.y(); - x = xin * matrix.m[0][0] + - yin * matrix.m[1][0] + - matrix.m[3][0]; - y = xin * matrix.m[0][1] + - yin * matrix.m[1][1] + - matrix.m[3][1]; - w = xin * matrix.m[0][3] + - yin * matrix.m[1][3] + - matrix.m[3][3]; - if (w == 1.0f) - return QPoint(qRound(x), qRound(y)); - else - return QPoint(qRound(x / w), qRound(y / w)); + if (matrix.flagBits == QMatrix4x4::Identity) { + return point; + } else if (matrix.flagBits == QMatrix4x4::Translation) { + return QPoint(qRound(xin + matrix.m[3][0]), + qRound(yin + matrix.m[3][1])); + } else if (matrix.flagBits == + (QMatrix4x4::Translation | QMatrix4x4::Scale)) { + return QPoint(qRound(xin * matrix.m[0][0] + matrix.m[3][0]), + qRound(yin * matrix.m[1][1] + matrix.m[3][1])); + } else if (matrix.flagBits == QMatrix4x4::Scale) { + return QPoint(qRound(xin * matrix.m[0][0]), + qRound(yin * matrix.m[1][1])); + } else { + x = xin * matrix.m[0][0] + + yin * matrix.m[1][0] + + matrix.m[3][0]; + y = xin * matrix.m[0][1] + + yin * matrix.m[1][1] + + matrix.m[3][1]; + w = xin * matrix.m[0][3] + + yin * matrix.m[1][3] + + matrix.m[3][3]; + if (w == 1.0f) + return QPoint(qRound(x), qRound(y)); + else + return QPoint(qRound(x / w), qRound(y / w)); + } } inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point) @@ -771,19 +804,33 @@ inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point) float x, y, w; xin = point.x(); yin = point.y(); - x = xin * matrix.m[0][0] + - yin * matrix.m[1][0] + - matrix.m[3][0]; - y = xin * matrix.m[0][1] + - yin * matrix.m[1][1] + - matrix.m[3][1]; - w = xin * matrix.m[0][3] + - yin * matrix.m[1][3] + - matrix.m[3][3]; - if (w == 1.0f) { - return QPointF(qreal(x), qreal(y)); + if (matrix.flagBits == QMatrix4x4::Identity) { + return point; + } else if (matrix.flagBits == QMatrix4x4::Translation) { + return QPointF(xin + matrix.m[3][0], + yin + matrix.m[3][1]); + } else if (matrix.flagBits == + (QMatrix4x4::Translation | QMatrix4x4::Scale)) { + return QPointF(xin * matrix.m[0][0] + matrix.m[3][0], + yin * matrix.m[1][1] + matrix.m[3][1]); + } else if (matrix.flagBits == QMatrix4x4::Scale) { + return QPointF(xin * matrix.m[0][0], + yin * matrix.m[1][1]); } else { - return QPointF(qreal(x / w), qreal(y / w)); + x = xin * matrix.m[0][0] + + yin * matrix.m[1][0] + + matrix.m[3][0]; + y = xin * matrix.m[0][1] + + yin * matrix.m[1][1] + + matrix.m[3][1]; + w = xin * matrix.m[0][3] + + yin * matrix.m[1][3] + + matrix.m[3][3]; + if (w == 1.0f) { + return QPointF(qreal(x), qreal(y)); + } else { + return QPointF(qreal(x / w), qreal(y / w)); + } } } @@ -901,32 +948,6 @@ inline QVector4D QMatrix4x4::map(const QVector4D& point) const #endif -inline QRect QMatrix4x4::mapRect(const QRect& rect) const -{ - QPoint tl = map(rect.topLeft()); QPoint tr = map(rect.topRight()); - QPoint bl = map(rect.bottomLeft()); QPoint br = map(rect.bottomRight()); - - int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); - int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); - int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); - int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); - - return QRect(QPoint(xmin, ymin), QPoint(xmax, ymax)); -} - -inline QRectF QMatrix4x4::mapRect(const QRectF& rect) const -{ - QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight()); - QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight()); - - qreal xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); - qreal xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); - qreal ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); - qreal ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); - - return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); -} - inline float *QMatrix4x4::data() { // We have to assume that the caller will modify the matrix elements, diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index 7de1ec4..9859425 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -49,6 +49,7 @@ #include <private/qtextengine_p.h> #include <qvarlengtharray.h> #include <private/qfontengine_p.h> +#include <private/qpaintengineex_p.h> QT_BEGIN_NAMESPACE @@ -302,6 +303,9 @@ void QPaintEngine::syncState() { Q_ASSERT(state); updateState(*state); + + if (isExtended()) + static_cast<QPaintEngineEx *>(this)->sync(); } static QPaintEngine *qt_polygon_recursion = 0; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 3f85095..578a815 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4475,14 +4475,12 @@ void QClipData::fixup() if (sl != left || sr != right) isRect = false; } - ++xmax; // qDebug("xmin=%d,xmax=%d,ymin=%d,ymax=%d %s", xmin, xmax, ymin, ymax, isRect ? "rectangular" : ""); if (isRect) { hasRectClip = true; clipRect.setRect(xmin, ymin, xmax - xmin, ymax - ymin); } - } /* diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index 593726c..1c55242 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -216,6 +216,8 @@ public: inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); } inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); } + virtual void sync() {} + virtual QPixmapFilter *createPixmapFilter(int /*type*/) const { return 0; } protected: diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 3004841..50100af 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -398,9 +398,12 @@ QRect QMenuPrivate::actionRect(QAction *act) const return ret; } +static const float MenuFadeTimeInSec = 0.150; + void QMenuPrivate::hideUpToMenuBar() { Q_Q(QMenu); + bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide); if (!tornoff) { QWidget *caused = causedPopup.widget; hideMenu(q); //hide after getting causedPopup @@ -415,8 +418,9 @@ void QMenuPrivate::hideUpToMenuBar() if (QMenu *m = qobject_cast<QMenu*>(caused)) { caused = m->d_func()->causedPopup.widget; if (!m->d_func()->tornoff) - hideMenu(m); - m->d_func()->setCurrentAction(0); + hideMenu(m, fadeMenus); + if (!fadeMenus) // Mac doesn't clear the action until after hidden. + m->d_func()->setCurrentAction(0); } else { #ifndef QT_NO_TOOLBUTTON if (qobject_cast<QToolButton*>(caused) == 0) @@ -425,26 +429,32 @@ void QMenuPrivate::hideUpToMenuBar() caused = 0; } } +#if defined(Q_WS_MAC) + if (fadeMenus) { + QEventLoop eventLoop; + QTimer::singleShot(int(MenuFadeTimeInSec * 1000), &eventLoop, SLOT(quit())); + QMacWindowFader::currentFader()->performFade(); + eventLoop.exec(); + } +#endif } setCurrentAction(0); } -void QMenuPrivate::hideMenu(QMenu *menu) +void QMenuPrivate::hideMenu(QMenu *menu, bool justRegister) { if (!menu) return; - #if !defined(QT_NO_EFFECTS) menu->blockSignals(true); aboutToHide = true; // Flash item which is about to trigger (if any). if (menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem) - && currentAction && currentAction == actionAboutToTrigger) { - + && currentAction && currentAction == actionAboutToTrigger + && menu->actions().contains(currentAction)) { QEventLoop eventLoop; QAction *activeAction = currentAction; - // Deselect and wait 60 ms. menu->setActiveAction(0); QTimer::singleShot(60, &eventLoop, SLOT(quit())); eventLoop.exec(); @@ -458,22 +468,24 @@ void QMenuPrivate::hideMenu(QMenu *menu) // Fade out. if (menu->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide)) { // ### Qt 4.4: - // Should be something like: q->transitionWindow(Qt::FadeOutTransition, 150); + // Should be something like: q->transitionWindow(Qt::FadeOutTransition, MenuFadeTimeInSec); // Hopefully we'll integrate qt/research/windowtransitions into main before 4.4. // Talk to Richard, Trenton or Bjoern. #if defined(Q_WS_MAC) - macWindowFade(qt_mac_window_for(menu)); // FIXME - what is the default duration for view animations + if (justRegister) { + QMacWindowFader::currentFader()->setFadeDuration(MenuFadeTimeInSec); + QMacWindowFader::currentFader()->registerWindowToFade(menu); + } else { + macWindowFade(qt_mac_window_for(menu), MenuFadeTimeInSec); + } - // Wait for the transition to complete. - QEventLoop eventLoop; - QTimer::singleShot(150, &eventLoop, SLOT(quit())); - eventLoop.exec(); #endif // Q_WS_MAC } aboutToHide = false; menu->blockSignals(false); #endif // QT_NO_EFFECTS - menu->hide(); + if (!justRegister) + menu->hide(); } void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index cce083f..87c886c 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1829,6 +1829,9 @@ OSMenuRef QMenuBar::macMenu() { return d_func()->macMenu(); } */ static bool qt_mac_is_ancestor(QWidget* possibleAncestor, QWidget *child) { + if (!possibleAncestor) + return false; + QWidget * current = child->parentWidget(); while (current != 0) { if (current == possibleAncestor) @@ -1847,22 +1850,19 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget) { if (modalWidget == 0 || menuBar == 0) return false; - const Qt::WindowModality modality = modalWidget->windowModality(); - if (modality == Qt::ApplicationModal) { - return true; - } else if (modality == Qt::WindowModal) { - QWidget * parent = menuBar->parentWidget(); - - // Special case for the global menu bar: It's not associated - // with a window so don't disable it. - if (parent == 0) - return false; - // Disable menu entries in menu bars that belong to ancestors of - // the modal widget, leave entries in unrelated menu bars enabled. - return qt_mac_is_ancestor(parent, modalWidget); + // If there is an application modal window on + // screen, the entries of the menubar should be disabled: + QWidget *w = modalWidget; + while (w) { + if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) + return true; + w = w->parentWidget(); } - return false; // modality == NonModal + + // INVARIANT: modalWidget is window modal. Disable menu entries + // if the menu bar belongs to an ancestor of modalWidget: + return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget); } static void cancelAllMenuTracking() diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index edfeee7..f08283d 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -220,7 +220,7 @@ public: virtual QList<QPointer<QWidget> > calcCausedStack() const; QMenuCaused causedPopup; void hideUpToMenuBar(); - void hideMenu(QMenu *menu); + void hideMenu(QMenu *menu, bool justRegister = false); //index mappings inline QAction *actionAt(int i) const { return q_func()->actions().at(i); } diff --git a/src/gui/widgets/qstatusbar.cpp b/src/gui/widgets/qstatusbar.cpp index c970838..3829bcb 100644 --- a/src/gui/widgets/qstatusbar.cpp +++ b/src/gui/widgets/qstatusbar.cpp @@ -144,7 +144,7 @@ QRect QStatusBarPrivate::messageRect() const if (rtl) left = qMax(left, item->w->x() + item->w->width() + 2); else - right = qMin(right, item->w->x()-1); + right = qMin(right, item->w->x() - 2); } break; } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index e7b6ee4..40f3a8d 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -449,6 +449,43 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } +void QGL2PaintEngineEx::sync() +{ + Q_D(QGL2PaintEngineEx); + ensureActive(); + d->transferMode(BrushDrawingMode); + + QGLContext *ctx = d->ctx; + glUseProgram(0); + +#ifndef QT_OPENGL_ES_2 + // be nice to people who mix OpenGL 1.x code with QPainter commands + // by setting modelview and projection matrices to mirror the GL 1 + // paint engine + const QTransform& mtx = state()->matrix; + + float mv_matrix[4][4] = + { + { mtx.m11(), mtx.m12(), 0, mtx.m13() }, + { mtx.m21(), mtx.m22(), 0, mtx.m23() }, + { 0, 0, 1, 0 }, + { mtx.dx(), mtx.dy(), 0, mtx.m33() } + }; + + const QSize sz = d->drawable.size(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999); + + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(&mv_matrix[0][0]); +#endif + + glDisable(GL_BLEND); + glActiveTexture(GL_TEXTURE0); +} + void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) { if (newMode == mode) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index dececa3..7213474 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -126,6 +126,7 @@ public: return static_cast<const QOpenGL2PaintEngineState *>(QPaintEngineEx::state()); } void updateClipRegion(const QRegion &clipRegion, Qt::ClipOperation op); + virtual void sync(); private: Q_DISABLE_COPY(QGL2PaintEngineEx) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index b1a63b5..b3523d4 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -440,7 +440,7 @@ inline bool qt_gl_preferGL2Engine() return true; #else return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) - && !qgetenv("QT_GL_USE_OPENGL2ENGINE").isEmpty(); + && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty(); #endif } diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 85bcda5..8d94c8b 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -372,45 +372,50 @@ QPaintEngine* QGLPixmapData::paintEngine() const if (m_engine) return m_engine; - else if (!useFramebufferObjects()) { - m_dirty = true; - if (m_source.size() != size()) - m_source = QImage(size(), QImage::Format_ARGB32_Premultiplied); - if (m_hasFillColor) { - m_source.fill(PREMUL(m_fillColor.rgba())); - m_hasFillColor = false; - } - return m_source.paintEngine(); - } - extern QGLWidget* qt_gl_share_widget(); + if (useFramebufferObjects()) { + extern QGLWidget* qt_gl_share_widget(); - if (!QGLContext::currentContext()) - qt_gl_share_widget()->makeCurrent(); - QGLShareContextScope ctx(qt_gl_share_widget()->context()); + if (!QGLContext::currentContext()) + qt_gl_share_widget()->makeCurrent(); + QGLShareContextScope ctx(qt_gl_share_widget()->context()); - if (textureBufferStack.size() <= currentTextureBuffer) { - textureBufferStack << createTextureBuffer(size()); - } else { - QSize sz = textureBufferStack.at(currentTextureBuffer).fbo->size(); - if (sz.width() < m_width || sz.height() < m_height) { - if (sz.width() < m_width) - sz.setWidth(qMax(m_width, qRound(sz.width() * 1.5))); - if (sz.height() < m_height) - sz.setHeight(qMax(m_height, qRound(sz.height() * 1.5))); - delete textureBufferStack.at(currentTextureBuffer).fbo; - textureBufferStack[currentTextureBuffer] = - createTextureBuffer(sz, textureBufferStack.at(currentTextureBuffer).engine); - qDebug() << "Creating new pixmap texture buffer:" << sz; + if (textureBufferStack.size() <= currentTextureBuffer) { + textureBufferStack << createTextureBuffer(size()); + } else { + QSize sz = textureBufferStack.at(currentTextureBuffer).fbo->size(); + if (sz.width() < m_width || sz.height() < m_height) { + if (sz.width() < m_width) + sz.setWidth(qMax(m_width, qRound(sz.width() * 1.5))); + if (sz.height() < m_height) + sz.setHeight(qMax(m_height, qRound(sz.height() * 1.5))); + delete textureBufferStack.at(currentTextureBuffer).fbo; + textureBufferStack[currentTextureBuffer] = + createTextureBuffer(sz, textureBufferStack.at(currentTextureBuffer).engine); + qDebug() << "Creating new pixmap texture buffer:" << sz; + } } - } - m_renderFbo = textureBufferStack.at(currentTextureBuffer).fbo; - m_engine = textureBufferStack.at(currentTextureBuffer).engine; + if (textureBufferStack.at(currentTextureBuffer).fbo->isValid()) { + m_renderFbo = textureBufferStack.at(currentTextureBuffer).fbo; + m_engine = textureBufferStack.at(currentTextureBuffer).engine; + + ++currentTextureBuffer; + + return m_engine; + } - ++currentTextureBuffer; + qWarning() << "Failed to create pixmap texture buffer of size " << size() << ", falling back to raster paint engine"; + } - return m_engine; + m_dirty = true; + if (m_source.size() != size()) + m_source = QImage(size(), QImage::Format_ARGB32_Premultiplied); + if (m_hasFillColor) { + m_source.fill(PREMUL(m_fillColor.rgba())); + m_hasFillColor = false; + } + return m_source.paintEngine(); } GLuint QGLPixmapData::bind(bool copyBack) const diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index bb510fc..4d51e89 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -167,6 +167,9 @@ private slots: void fill(); + void mapRect_data(); + void mapRect(); + private: static void setMatrix(QMatrix2x2& m, const qreal *values); static void setMatrixFixed(QMatrix2x2& m, const qreal *values); @@ -1975,6 +1978,14 @@ void tst_QMatrix::scale4x4_data() 0.0f, 0.0f, 0.0f, 1.0f}; QTest::newRow("complex") << (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexScale; + + static const qreal complexScale2D[] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, -11.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("complex2D") + << (qreal)2.0f << (qreal)-11.0f << (qreal)1.0f << (void *)complexScale2D; } void tst_QMatrix::scale4x4() { @@ -1993,6 +2004,12 @@ void tst_QMatrix::scale4x4() m2.scale(x, y, z); QVERIFY(isSame(m2, (const qreal *)resultValues)); + if (z == 1.0f) { + QMatrix4x4 m2b; + m2b.scale(x, y); + QVERIFY(m2b == m2); + } + QVector3D v1(2.0f, 3.0f, -4.0f); QVector3D v2 = m1 * v1; QCOMPARE(v2.x(), (qreal)(2.0f * x)); @@ -2046,6 +2063,12 @@ void tst_QMatrix::scale4x4() QVERIFY(isSame(m5, (const qreal *)resultValues)); } + if (z == 1.0f) { + QMatrix4x4 m4b(m3); + m4b.scale(x, y); + QVERIFY(m4b == m4); + } + // Test coverage when the special matrix type is unknown. QMatrix4x4 m6; @@ -2101,6 +2124,14 @@ void tst_QMatrix::translate4x4_data() 0.0f, 0.0f, 0.0f, 1.0f}; QTest::newRow("complex") << (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexTranslate; + + static const qreal complexTranslate2D[] = + {1.0f, 0.0f, 0.0f, 2.0f, + 0.0f, 1.0f, 0.0f, -11.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("complex2D") + << (qreal)2.0f << (qreal)-11.0f << (qreal)0.0f << (void *)complexTranslate2D; } void tst_QMatrix::translate4x4() { @@ -2119,6 +2150,12 @@ void tst_QMatrix::translate4x4() m2.translate(x, y, z); QVERIFY(isSame(m2, (const qreal *)resultValues)); + if (z == 0.0f) { + QMatrix4x4 m2b; + m2b.translate(x, y); + QVERIFY(m2b == m2); + } + QVector3D v1(2.0f, 3.0f, -4.0f); QVector3D v2 = m1 * v1; QCOMPARE(v2.x(), (qreal)(2.0f + x)); @@ -2153,6 +2190,12 @@ void tst_QMatrix::translate4x4() QMatrix4x4 m4(m3); m4.translate(x, y, z); QVERIFY(m4 == m3 * m1); + + if (z == 0.0f) { + QMatrix4x4 m4b(m3); + m4b.translate(x, y); + QVERIFY(m4b == m4); + } } // Test the generation and use of 4x4 rotation matrices. @@ -3180,6 +3223,117 @@ void tst_QMatrix::fill() QVERIFY(isSame(m2, fillValues4x3)); } +// Test the mapRect() function for QRect and QRectF. +void tst_QMatrix::mapRect_data() +{ + QTest::addColumn<qreal>("x"); + QTest::addColumn<qreal>("y"); + QTest::addColumn<qreal>("width"); + QTest::addColumn<qreal>("height"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + QTest::newRow("rect") + << (qreal)1.0f << (qreal)-20.5f << (qreal)100.0f << (qreal)63.75f; +} +void tst_QMatrix::mapRect() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, width); + QFETCH(qreal, height); + + QRectF rect(x, y, width, height); + QRect recti(qRound(x), qRound(y), qRound(width), qRound(height)); + + QMatrix4x4 m1; + QVERIFY(m1.mapRect(rect) == rect); + QVERIFY(m1.mapRect(recti) == recti); + + QMatrix4x4 m2; + m2.translate(-100.5f, 64.0f); + QRectF translated = rect.translated(-100.5f, 64.0f); + QRect translatedi = QRect(qRound(recti.x() - 100.5f), recti.y() + 64, + recti.width(), recti.height()); + QVERIFY(m2.mapRect(rect) == translated); + QVERIFY(m2.mapRect(recti) == translatedi); + + QMatrix4x4 m3; + m3.scale(-100.5f, 64.0f); + qreal scalex = x * -100.5f; + qreal scaley = y * 64.0f; + qreal scalewid = width * -100.5f; + qreal scaleht = height * 64.0f; + if (scalewid < 0.0f) { + scalewid = -scalewid; + scalex -= scalewid; + } + if (scaleht < 0.0f) { + scaleht = -scaleht; + scaley -= scaleht; + } + QRectF scaled(scalex, scaley, scalewid, scaleht); + QVERIFY(m3.mapRect(rect) == scaled); + scalex = recti.x() * -100.5f; + scaley = recti.y() * 64.0f; + scalewid = recti.width() * -100.5f; + scaleht = recti.height() * 64.0f; + if (scalewid < 0.0f) { + scalewid = -scalewid; + scalex -= scalewid; + } + if (scaleht < 0.0f) { + scaleht = -scaleht; + scaley -= scaleht; + } + QRect scaledi(qRound(scalex), qRound(scaley), + qRound(scalewid), qRound(scaleht)); + QVERIFY(m3.mapRect(recti) == scaledi); + + QMatrix4x4 m4; + m4.translate(-100.5f, 64.0f); + m4.scale(-2.5f, 4.0f); + qreal transx1 = x * -2.5f - 100.5f; + qreal transy1 = y * 4.0f + 64.0f; + qreal transx2 = (x + width) * -2.5f - 100.5f; + qreal transy2 = (y + height) * 4.0f + 64.0f; + if (transx1 > transx2) + qSwap(transx1, transx2); + if (transy1 > transy2) + qSwap(transy1, transy2); + QRectF trans(transx1, transy1, transx2 - transx1, transy2 - transy1); + QVERIFY(m4.mapRect(rect) == trans); + transx1 = recti.x() * -2.5f - 100.5f; + transy1 = recti.y() * 4.0f + 64.0f; + transx2 = (recti.x() + recti.width()) * -2.5f - 100.5f; + transy2 = (recti.y() + recti.height()) * 4.0f + 64.0f; + if (transx1 > transx2) + qSwap(transx1, transx2); + if (transy1 > transy2) + qSwap(transy1, transy2); + QRect transi(qRound(transx1), qRound(transy1), + qRound(transx2) - qRound(transx1), + qRound(transy2) - qRound(transy1)); + QVERIFY(m4.mapRect(recti) == transi); + + m4.rotate(45.0f, 0.0f, 0.0f, 1.0f); + + QTransform t4; + t4.translate(-100.5f, 64.0f); + t4.scale(-2.5f, 4.0f); + t4.rotate(45.0f); + QRectF mr = m4.mapRect(rect); + QRectF tr = t4.mapRect(rect); + QVERIFY(fuzzyCompare(mr.x(), tr.x())); + QVERIFY(fuzzyCompare(mr.y(), tr.y())); + QVERIFY(fuzzyCompare(mr.width(), tr.width())); + QVERIFY(fuzzyCompare(mr.height(), tr.height())); + + QRect mri = m4.mapRect(recti); + QRect tri = t4.mapRect(recti); + QVERIFY(mri == tri); +} + QTEST_APPLESS_MAIN(tst_QMatrix) #include "tst_qmatrixnxn.moc" diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 87f9c13..af0f6cf 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -226,6 +226,7 @@ private slots: void extendedBlendModes(); void zeroOpacity(); + void clippingBug(); private: void fillData(); @@ -4168,5 +4169,28 @@ void tst_QPainter::zeroOpacity() QCOMPARE(target.pixel(0, 0), 0xff000000); } +void tst_QPainter::clippingBug() +{ + QImage img(32, 32, QImage::Format_ARGB32_Premultiplied); + img.fill(0); + + QImage expected = img; + QPainter p(&expected); + p.fillRect(1, 1, 30, 30, Qt::red); + p.end(); + + QPainterPath path; + path.addRect(1, 1, 30, 30); + path.addRect(1, 1, 30, 30); + path.addRect(1, 1, 30, 30); + + p.begin(&img); + p.setClipPath(path); + p.fillRect(0, 0, 32, 32, Qt::red); + p.end(); + + QCOMPARE(img, expected); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" diff --git a/tests/auto/test.pl b/tests/auto/test.pl index f2a1fe4..9fd5c9d 100755 --- a/tests/auto/test.pl +++ b/tests/auto/test.pl @@ -179,7 +179,7 @@ print " Tests started: $totalStarted \n"; print " Tests executed: $totalExecuted \n"; print " Tests timed out: $totalTimedOut \n"; -# This procedure takes care of handling death children on due time +# This procedure takes care of handling dead children on due time sub handleDeath { $buryChildren = 1; } diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 4c39373..bc41125 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -9,6 +9,7 @@ SUBDIRS = containers-associative \ qpixmap \ blendbench \ qstringlist \ + qmatrix4x4 \ qobject \ qrect \ qregexp \ diff --git a/tests/benchmarks/qmatrix4x4/qmatrix4x4.pro b/tests/benchmarks/qmatrix4x4/qmatrix4x4.pro new file mode 100644 index 0000000..e82d9de --- /dev/null +++ b/tests/benchmarks/qmatrix4x4/qmatrix4x4.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qmatrix4x4 + +SOURCES += tst_qmatrix4x4.cpp + diff --git a/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp new file mode 100644 index 0000000..5046b17 --- /dev/null +++ b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp @@ -0,0 +1,261 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtGui/qmatrix4x4.h> + +class tst_QMatrix4x4 : public QObject +{ + Q_OBJECT +public: + tst_QMatrix4x4() {} + ~tst_QMatrix4x4() {} + +private slots: + void multiply_data(); + void multiply(); + + void multiplyInPlace_data(); + void multiplyInPlace(); + + void multiplyDirect_data(); + void multiplyDirect(); + + void mapVector3D_data(); + void mapVector3D(); + + void mapVector2D_data(); + void mapVector2D(); + + void mapVectorDirect_data(); + void mapVectorDirect(); +}; + +static qreal const generalValues[16] = + {1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + +void tst_QMatrix4x4::multiply_data() +{ + QTest::addColumn<QMatrix4x4>("m1"); + QTest::addColumn<QMatrix4x4>("m2"); + + QTest::newRow("identity * identity") + << QMatrix4x4() << QMatrix4x4(); + QTest::newRow("identity * general") + << QMatrix4x4() << QMatrix4x4(generalValues); + QTest::newRow("general * identity") + << QMatrix4x4(generalValues) << QMatrix4x4(); + QTest::newRow("general * general") + << QMatrix4x4(generalValues) << QMatrix4x4(generalValues); +} + +QMatrix4x4 mresult; + +void tst_QMatrix4x4::multiply() +{ + QFETCH(QMatrix4x4, m1); + QFETCH(QMatrix4x4, m2); + + QMatrix4x4 m3; + + QBENCHMARK { + m3 = m1 * m2; + } + + // Force the result to be stored so the compiler doesn't + // optimize away the contents of the benchmark loop. + mresult = m3; +} + +void tst_QMatrix4x4::multiplyInPlace_data() +{ + multiply_data(); +} + +void tst_QMatrix4x4::multiplyInPlace() +{ + QFETCH(QMatrix4x4, m1); + QFETCH(QMatrix4x4, m2); + + QMatrix4x4 m3; + + QBENCHMARK { + m3 = m1; + m3 *= m2; + } + + // Force the result to be stored so the compiler doesn't + // optimize away the contents of the benchmark loop. + mresult = m3; +} + +// Use a direct naive multiplication algorithm. This is used +// to compare against the optimized routines to see if they are +// actually faster than the naive implementation. +void tst_QMatrix4x4::multiplyDirect_data() +{ + multiply_data(); +} +void tst_QMatrix4x4::multiplyDirect() +{ + QFETCH(QMatrix4x4, m1); + QFETCH(QMatrix4x4, m2); + + QMatrix4x4 m3; + + const float *m1data = m1.constData(); + const float *m2data = m2.constData(); + float *m3data = m3.data(); + + QBENCHMARK { + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + m3data[col * 4 + row] = 0.0f; + for (int j = 0; j < 4; ++j) { + m3data[col * 4 + row] += + m1data[j * 4 + row] * m2data[col * 4 + j]; + } + } + } + } +} + +QVector3D vresult; + +void tst_QMatrix4x4::mapVector3D_data() +{ + QTest::addColumn<QMatrix4x4>("m1"); + + QTest::newRow("identity") << QMatrix4x4(); + QTest::newRow("general") << QMatrix4x4(generalValues); + + QMatrix4x4 t1; + t1.translate(-100.5f, 64.0f, 75.25f); + QTest::newRow("translate3D") << t1; + + QMatrix4x4 t2; + t2.translate(-100.5f, 64.0f); + QTest::newRow("translate2D") << t2; + + QMatrix4x4 s1; + s1.scale(-100.5f, 64.0f, 75.25f); + QTest::newRow("scale3D") << s1; + + QMatrix4x4 s2; + s2.scale(-100.5f, 64.0f); + QTest::newRow("scale2D") << s2; +} +void tst_QMatrix4x4::mapVector3D() +{ + QFETCH(QMatrix4x4, m1); + + QVector3D v(10.5f, -2.0f, 3.0f); + QVector3D result; + + m1.inferSpecialType(); + + QBENCHMARK { + result = m1 * v; + } + + // Force the result to be stored so the compiler doesn't + // optimize away the contents of the benchmark loop. + vresult = result; +} + +QPointF vresult2; + +void tst_QMatrix4x4::mapVector2D_data() +{ + mapVector3D_data(); +} +void tst_QMatrix4x4::mapVector2D() +{ + QFETCH(QMatrix4x4, m1); + + QPointF v(10.5f, -2.0f); + QPointF result; + + m1.inferSpecialType(); + + QBENCHMARK { + result = m1 * v; + } + + // Force the result to be stored so the compiler doesn't + // optimize away the contents of the benchmark loop. + vresult2 = result; +} + +// Use a direct naive multiplication algorithm. This is used +// to compare against the optimized routines to see if they are +// actually faster than the naive implementation. +void tst_QMatrix4x4::mapVectorDirect_data() +{ + mapVector3D_data(); +} +void tst_QMatrix4x4::mapVectorDirect() +{ + QFETCH(QMatrix4x4, m1); + + const float *m1data = m1.constData(); + float v[4] = {10.5f, -2.0f, 3.0f, 1.0f}; + float result[4]; + + QBENCHMARK { + for (int row = 0; row < 4; ++row) { + result[row] = 0.0f; + for (int col = 0; col < 4; ++col) { + result[row] += m1data[col * 4 + row] * v[col]; + } + } + result[0] /= result[3]; + result[1] /= result[3]; + result[2] /= result[3]; + } +} + +QTEST_MAIN(tst_QMatrix4x4) + +#include "tst_qmatrix4x4.moc" diff --git a/tests/benchmarks/qstringbuilder/main.cpp b/tests/benchmarks/qstringbuilder/main.cpp index 8eb4e78..d4e2fa0 100644 --- a/tests/benchmarks/qstringbuilder/main.cpp +++ b/tests/benchmarks/qstringbuilder/main.cpp @@ -1,17 +1,64 @@ -#include "qstringbuilder.h" +// Select one of the scenarios below +#define SCENARIO 3 + +#if SCENARIO == 1 +// this is the "no harm done" version. Only operator% is active, +// with NO_CAST * defined +#define P % +#undef QT_USE_FAST_OPERATOR_PLUS +#undef QT_USE_FAST_CONCATENATION +#define QT_NO_CAST_FROM_ASCII +#define QT_NO_CAST_TO_ASCII +#endif -#include <QDebug> -#include <QString> -#include <qtest.h> +#if SCENARIO == 2 +// this is the "full" version. Operator+ is replaced by a QStringBuilder +// based version +// with NO_CAST * defined +#define P % +#define QT_USE_FAST_OPERATOR_PLUS +#define QT_USE_FAST_CONCATENATION +#define QT_NO_CAST_FROM_ASCII +#define QT_NO_CAST_TO_ASCII +#endif + +#if SCENARIO == 3 +// this is the "no harm done" version. Only operator% is active, +// with NO_CAST * _not_ defined +#define P % +#undef QT_USE_FAST_OPERATOR_PLUS +#undef QT_USE_FAST_CONCATENATION +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII +#endif + +#if SCENARIO == 4 +// this is the "full" version. Operator+ is replaced by a QStringBuilder +// based version +// with NO_CAST * _not_ defined +#define P % +#define QT_USE_FAST_OPERATOR_PLUS +#define QT_USE_FAST_CONCATENATION +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII +#endif + +#include <qbytearray.h> +#include <qdebug.h> +#include <qstring.h> +#include <qstringbuilder.h> + +#include <qtest.h> #define COMPARE(a, b) QCOMPARE(a, b) //#define COMPARE(a, b) #define SEP(s) qDebug() << "\n\n-------- " s " ---------"; -#define L(s) QLatin1String(s) + +#define LITERAL "some string literal" class tst_qstringbuilder : public QObject { @@ -19,12 +66,16 @@ class tst_qstringbuilder : public QObject public: tst_qstringbuilder() - : l1literal("some string literal"), - l1string("some string literal"), - ba("some string literal"), + : l1literal(LITERAL), + l1string(LITERAL), + ba(LITERAL), string(l1string), stringref(&string, 2, 10), - achar('c') + achar('c'), + r2(QLatin1String(LITERAL LITERAL)), + r3(QLatin1String(LITERAL LITERAL LITERAL)), + r4(QLatin1String(LITERAL LITERAL LITERAL LITERAL)), + r5(QLatin1String(LITERAL LITERAL LITERAL LITERAL LITERAL)) {} @@ -51,10 +102,10 @@ public: int s = 0; for (int i = 0; i < N; ++i) { #if 0 - s += QString(l1literal % l1literal).size(); - s += QString(l1literal % l1literal % l1literal).size(); - s += QString(l1literal % l1literal % l1literal % l1literal).size(); - s += QString(l1literal % l1literal % l1literal % l1literal % l1literal).size(); + s += QString(l1literal P l1literal).size(); + s += QString(l1literal P l1literal P l1literal).size(); + s += QString(l1literal P l1literal P l1literal P l1literal).size(); + s += QString(l1literal P l1literal P l1literal P l1literal P l1literal).size(); #endif s += QString(achar % l1literal % achar).size(); } @@ -71,24 +122,30 @@ private slots: void separator_1() { SEP("literal + literal (builder first)"); } void b_2_l1literal() { - QBENCHMARK { r = l1literal % l1literal; } - COMPARE(r, QString(l1string + l1string)); + QBENCHMARK { r = l1literal P l1literal; } + COMPARE(r, r2); + } + #ifndef QT_NO_CAST_FROM_ASCII + void b_l1literal_LITERAL() { + QBENCHMARK { r = l1literal P LITERAL; } + COMPARE(r, r2); } + #endif void s_2_l1string() { QBENCHMARK { r = l1string + l1string; } - COMPARE(r, QString(l1literal % l1literal)); + COMPARE(r, r2); } void separator_2() { SEP("2 strings"); } void b_2_string() { - QBENCHMARK { r = string % string; } - COMPARE(r, QString(string + string)); + QBENCHMARK { r = string P string; } + COMPARE(r, r2); } void s_2_string() { QBENCHMARK { r = string + string; } - COMPARE(r, QString(string % string)); + COMPARE(r, r2); } @@ -107,12 +164,12 @@ private slots: void separator_2b() { SEP("3 strings"); } void b_3_string() { - QBENCHMARK { r = string % string % string; } - COMPARE(r, QString(string + string + string)); + QBENCHMARK { r = string P string P string; } + COMPARE(r, r3); } void s_3_string() { QBENCHMARK { r = string + string + string; } - COMPARE(r, QString(string % string % string)); + COMPARE(r, r3); } @@ -120,56 +177,66 @@ private slots: void b_string_l1literal() { QBENCHMARK { r = string % l1literal; } - COMPARE(r, QString(string + l1string)); + COMPARE(r, r2); } + #ifndef QT_NO_CAST_FROM_ASCII + void b_string_LITERAL() { + QBENCHMARK { r = string P LITERAL; } + COMPARE(r, r2); + } + void b_LITERAL_string() { + QBENCHMARK { r = LITERAL P string; } + COMPARE(r, r2); + } + #endif void b_string_l1string() { - QBENCHMARK { r = string % l1string; } - COMPARE(r, QString(string + l1string)); + QBENCHMARK { r = string P l1string; } + COMPARE(r, r2); } void s_string_l1literal() { QBENCHMARK { r = string + l1string; } - COMPARE(r, QString(string % l1literal)); + COMPARE(r, r2); } void s_string_l1string() { QBENCHMARK { r = string + l1string; } - COMPARE(r, QString(string % l1literal)); + COMPARE(r, r2); } void separator_3() { SEP("3 literals"); } void b_3_l1literal() { - QBENCHMARK { r = l1literal % l1literal % l1literal; } - COMPARE(r, QString(l1string + l1string + l1string)); + QBENCHMARK { r = l1literal P l1literal P l1literal; } + COMPARE(r, r3); } void s_3_l1string() { QBENCHMARK { r = l1string + l1string + l1string; } - COMPARE(r, QString(l1literal % l1literal % l1literal)); + COMPARE(r, r3); } void separator_4() { SEP("4 literals"); } void b_4_l1literal() { - QBENCHMARK { r = l1literal % l1literal % l1literal % l1literal; } - COMPARE(r, QString(l1string + l1string + l1string + l1string)); + QBENCHMARK { r = l1literal P l1literal P l1literal P l1literal; } + COMPARE(r, r4); } void s_4_l1string() { QBENCHMARK { r = l1string + l1string + l1string + l1string; } - COMPARE(r, QString(l1literal % l1literal % l1literal % l1literal)); + COMPARE(r, r4); } void separator_5() { SEP("5 literals"); } void b_5_l1literal() { - QBENCHMARK { r = l1literal % l1literal % l1literal % l1literal %l1literal; } - COMPARE(r, QString(l1string + l1string + l1string + l1string + l1string)); + QBENCHMARK { r = l1literal P l1literal P l1literal P l1literal P l1literal; } + COMPARE(r, r5); } void s_5_l1string() { QBENCHMARK { r = l1string + l1string + l1string + l1string + l1string; } - COMPARE(r, QString(l1literal % l1literal % l1literal % l1literal % l1literal)); + COMPARE(r, r5); } @@ -177,12 +244,12 @@ private slots: void b_string_4_char() { QBENCHMARK { r = string + achar + achar + achar + achar; } - COMPARE(r, QString(string % achar % achar % achar % achar)); + COMPARE(r, QString(string P achar P achar P achar P achar)); } void s_string_4_char() { QBENCHMARK { r = string + achar + achar + achar + achar; } - COMPARE(r, QString(string % achar % achar % achar % achar)); + COMPARE(r, QString(string P achar P achar P achar P achar)); } @@ -190,26 +257,26 @@ private slots: void b_char_string_char() { QBENCHMARK { r = achar + string + achar; } - COMPARE(r, QString(achar % string % achar)); + COMPARE(r, QString(achar P string P achar)); } void s_char_string_char() { QBENCHMARK { r = achar + string + achar; } - COMPARE(r, QString(achar % string % achar)); + COMPARE(r, QString(achar P string P achar)); } void separator_8() { SEP("string.arg"); } void b_string_arg() { - const QString pattern = l1string + QLatin1String("%1") + l1string; - QBENCHMARK { r = l1literal % string % l1literal; } - COMPARE(r, QString(l1string + string + l1string)); + const QString pattern = l1string + QString::fromLatin1("%1") + l1string; + QBENCHMARK { r = l1literal P string P l1literal; } + COMPARE(r, r3); } void s_string_arg() { const QString pattern = l1string + QLatin1String("%1") + l1string; QBENCHMARK { r = pattern.arg(string); } - COMPARE(r, QString(l1string + string + l1string)); + COMPARE(r, r3); } void s_bytearray_arg() { @@ -223,16 +290,16 @@ private slots: void b_reserve() { QBENCHMARK { r.clear(); - r = string % string % string % string; + r = string P string P string P string; } - COMPARE(r, QString(string + string + string + string)); + COMPARE(r, r4); } void b_reserve_lit() { QBENCHMARK { r.clear(); - r = string % l1literal % string % string; + r = string P l1literal P string P string; } - COMPARE(r, QString(string + string + string + string)); + COMPARE(r, r4); } void s_reserve() { QBENCHMARK { @@ -243,7 +310,7 @@ private slots: r += string; r += string; } - COMPARE(r, QString(string + string + string + string)); + COMPARE(r, r4); } void s_reserve_lit() { QBENCHMARK { @@ -256,7 +323,7 @@ private slots: r += string; r += string; } - COMPARE(r, QString(string + string + string + string)); + COMPARE(r, r4); } private: @@ -266,6 +333,7 @@ private: const QString string; const QStringRef stringref; const QLatin1Char achar; + const QString r2, r3, r4, r5; QString r; }; @@ -280,12 +348,14 @@ int main(int argc, char *argv[]) //QString("x") % 2; // Sanity test, should only compile when the // operator%(QString, int) is visible. - if (argc == 2 && (argv[1] == L("--run-builder") || argv[1] == L("-b"))) { + if (argc == 2 && (QLatin1String(argv[1]) == QLatin1String("--run-builder") + || QLatin1String(argv[1]) == QLatin1String("-b"))) { tst_qstringbuilder test; return test.run_builder(); } - if (argc == 2 && (argv[1] == L("--run-traditional") || argv[1] == L("-t"))) { + if (argc == 2 && (QLatin1String(argv[1]) == QLatin1String("--run-traditional") + || QLatin1String(argv[1]) == QLatin1String("-t"))) { tst_qstringbuilder test; return test.run_traditional(); } diff --git a/tests/benchmarks/qstringbuilder/qstringbuilder.pro b/tests/benchmarks/qstringbuilder/qstringbuilder.pro index 02daaaa..79171b4 100644 --- a/tests/benchmarks/qstringbuilder/qstringbuilder.pro +++ b/tests/benchmarks/qstringbuilder/qstringbuilder.pro @@ -2,10 +2,6 @@ load(qttest_p4) TEMPLATE = app TARGET = tst_qstringbuilder -# Uncomment to test compilation of the drop-in -# replacement operator+() -#DEFINES += QT_USE_FAST_OPERATOR_PLUS - QMAKE_CXXFLAGS += -g QMAKE_CFLAGS += -g diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 4dae28e..c5aefb1 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -403,6 +403,7 @@ QAction *QAbstractFormBuilder::create(DomAction *ui_action, QObject *parent) if (!a) return 0; + m_actions.insert(ui_action->attributeName(), a); applyProperties(a, ui_action->elementProperty()); return a; } @@ -415,7 +416,7 @@ QActionGroup *QAbstractFormBuilder::create(DomActionGroup *ui_action_group, QObj QActionGroup *a = createActionGroup(parent, ui_action_group->attributeName()); if (!a) return 0; - + m_actionGroups.insert(ui_action_group->attributeName(), a); applyProperties(a, ui_action_group->elementProperty()); foreach (DomAction *ui_action, ui_action_group->elementAction()) { @@ -1184,8 +1185,6 @@ QAction *QAbstractFormBuilder::createAction(QObject *parent, const QString &name { QAction *action = new QAction(parent); action->setObjectName(name); - m_actions.insert(name, action); - return action; } @@ -1196,8 +1195,6 @@ QActionGroup *QAbstractFormBuilder::createActionGroup(QObject *parent, const QSt { QActionGroup *g = new QActionGroup(parent); g->setObjectName(name); - m_actionGroups.insert(name, g); - return g; } diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp index 414eb14..53d1e9d 100644 --- a/tools/designer/src/lib/uilib/formbuilder.cpp +++ b/tools/designer/src/lib/uilib/formbuilder.cpp @@ -120,7 +120,10 @@ QFormBuilder::~QFormBuilder() */ QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget) { - QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false); + QFormBuilderExtra *fb = QFormBuilderExtra::instance(this); + if (!fb->parentWidgetIsSet()) + fb->setParentWidget(parentWidget); + fb->setProcessingLayoutWidget(false); if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative() && parentWidget #ifndef QT_NO_MAINWINDOW @@ -145,7 +148,7 @@ QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget) && !qobject_cast<QDockWidget *>(parentWidget) #endif ) - QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(true); + fb->setProcessingLayoutWidget(true); return QAbstractFormBuilder::create(ui_widget, parentWidget); } @@ -228,9 +231,6 @@ QWidget *QFormBuilder::createWidget(const QString &widgetName, QWidget *parentWi if (qobject_cast<QDialog *>(w)) w->setParent(parentWidget); - if (!fb->rootWidget()) - fb->setRootWidget(w); - return w; } @@ -369,9 +369,10 @@ QWidget *QFormBuilder::create(DomUI *ui, QWidget *parentWidget) */ QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget) { + QFormBuilderExtra *fb = QFormBuilderExtra::instance(this); // Is this a temporary layout widget used to represent QLayout hierarchies in Designer? // Set its margins to 0. - bool layoutWidget = QFormBuilderExtra::instance(this)->processingLayoutWidget(); + bool layoutWidget = fb->processingLayoutWidget(); QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget); if (layoutWidget) { const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); @@ -392,7 +393,7 @@ QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *pa bottom = prop->elementNumber(); l->setContentsMargins(left, top, right, bottom); - QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false); + fb->setProcessingLayoutWidget(false); } return l; } @@ -525,6 +526,7 @@ QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const /*! \internal */ + void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties) { typedef QList<DomProperty*> DomPropertyList; @@ -542,11 +544,12 @@ void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &proper continue; const QString attributeName = (*it)->attributeName(); - if (o == fb->rootWidget() && attributeName == strings.geometryProperty) { - // apply only the size for the rootWidget - fb->rootWidget()->resize(qvariant_cast<QRect>(v).size()); + const bool isWidget = o->isWidgetType(); + if (isWidget && o->parent() == fb->parentWidget() && attributeName == strings.geometryProperty) { + // apply only the size part of a geometry for the root widget + static_cast<QWidget*>(o)->resize(qvariant_cast<QRect>(v).size()); } else if (fb->applyPropertyInternally(o, attributeName, v)) { - } else if (!qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) { + } else if (isWidget && !qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) { // ### special-casing for Line (QFrame) -- try to fix me o->setProperty("frameShape", v); // v is of QFrame::Shape enum } else { diff --git a/tools/designer/src/lib/uilib/formbuilderextra.cpp b/tools/designer/src/lib/uilib/formbuilderextra.cpp index cb82967..38fe2ae 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra.cpp +++ b/tools/designer/src/lib/uilib/formbuilderextra.cpp @@ -81,7 +81,8 @@ QFormBuilderExtra::~QFormBuilderExtra() void QFormBuilderExtra::clear() { m_buddies.clear(); - m_rootWidget = 0; + m_parentWidget = 0; + m_parentWidgetIsSet = false; #ifndef QT_FORMBUILDER_NO_SCRIPT m_FormScriptRunner.clearErrors(); m_customWidgetScriptHash.clear(); @@ -136,14 +137,21 @@ bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode return false; } -const QPointer<QWidget> &QFormBuilderExtra::rootWidget() const +const QPointer<QWidget> &QFormBuilderExtra::parentWidget() const { - return m_rootWidget; + return m_parentWidget; } -void QFormBuilderExtra::setRootWidget(const QPointer<QWidget> &w) +bool QFormBuilderExtra::parentWidgetIsSet() const { - m_rootWidget = w; + return m_parentWidgetIsSet; +} + +void QFormBuilderExtra::setParentWidget(const QPointer<QWidget> &w) +{ + // Parent widget requires special handling of the geometry property. + m_parentWidget = w; + m_parentWidgetIsSet = true; } #ifndef QT_FORMBUILDER_NO_SCRIPT diff --git a/tools/designer/src/lib/uilib/formbuilderextra_p.h b/tools/designer/src/lib/uilib/formbuilderextra_p.h index f357239..9166c48 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra_p.h +++ b/tools/designer/src/lib/uilib/formbuilderextra_p.h @@ -101,8 +101,9 @@ public: void applyInternalProperties() const; static bool applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label); - const QPointer<QWidget> &rootWidget() const; - void setRootWidget(const QPointer<QWidget> &w); + const QPointer<QWidget> &parentWidget() const; + bool parentWidgetIsSet() const; + void setParentWidget(const QPointer<QWidget> &w); #ifndef QT_FORMBUILDER_NO_SCRIPT QFormScriptRunner &formScriptRunner(); @@ -182,7 +183,8 @@ private: QResourceBuilder *m_resourceBuilder; QTextBuilder *m_textBuilder; - QPointer<QWidget> m_rootWidget; + QPointer<QWidget> m_parentWidget; + bool m_parentWidgetIsSet; }; void uiLibWarning(const QString &message); diff --git a/tools/designer/src/uitools/quiloader.cpp b/tools/designer/src/uitools/quiloader.cpp index 2a66095..c6c2d80 100644 --- a/tools/designer/src/uitools/quiloader.cpp +++ b/tools/designer/src/uitools/quiloader.cpp @@ -613,8 +613,7 @@ void QUiLoaderPrivate::setupWidgetMap() const reason, you can subclass the QUiLoader class and reimplement these functions to intervene the process of constructing a user interface. For example, you might want to have a list of the actions created when loading - a form or creating a custom widget. However, in your reimplementation, you - must call QUiLoader's original implementation of these functions first. + a form or creating a custom widget. For a complete example using the QUiLoader class, see the \l{Calculator Builder Example}. diff --git a/tools/qdoc3/codeparser.cpp b/tools/qdoc3/codeparser.cpp index f0ff27e..20b37a0 100644 --- a/tools/qdoc3/codeparser.cpp +++ b/tools/qdoc3/codeparser.cpp @@ -47,6 +47,7 @@ #include "codeparser.h" #include "node.h" #include "tree.h" +#include "config.h" QT_BEGIN_NAMESPACE @@ -67,6 +68,7 @@ QT_BEGIN_NAMESPACE #define COMMAND_TITLE Doc::alias(QLatin1String("title")) QList<CodeParser *> CodeParser::parsers; +bool CodeParser::showInternal = false; /*! The constructor adds this code parser to the static @@ -87,11 +89,11 @@ CodeParser::~CodeParser() } /*! - Initializing a code parser is trivial. + Initialize the code parser base class. */ -void CodeParser::initializeParser(const Config & /* config */) +void CodeParser::initializeParser(const Config& config) { - // nothing. + showInternal = config.getBool(QLatin1String(CONFIG_SHOWINTERNAL)); } /*! @@ -217,8 +219,10 @@ void CodeParser::processCommonMetaCommand(const Location &location, node->setStatus(Node::Preliminary); } else if (command == COMMAND_INTERNAL) { - node->setAccess(Node::Private); - node->setStatus(Node::Internal); + if (!showInternal) { + node->setAccess(Node::Private); + node->setStatus(Node::Internal); + } } else if (command == COMMAND_REENTRANT) { node->setThreadSafeness(Node::Reentrant); diff --git a/tools/qdoc3/codeparser.h b/tools/qdoc3/codeparser.h index 019e806..0152b9c 100644 --- a/tools/qdoc3/codeparser.h +++ b/tools/qdoc3/codeparser.h @@ -87,6 +87,7 @@ class CodeParser private: static QList<CodeParser *> parsers; + static bool showInternal; }; QT_END_NAMESPACE diff --git a/tools/qdoc3/config.h b/tools/qdoc3/config.h index 9443f0d..7eb7048 100644 --- a/tools/qdoc3/config.h +++ b/tools/qdoc3/config.h @@ -147,6 +147,7 @@ class Config #define CONFIG_QHP "qhp" #define CONFIG_QUOTINGINFORMATION "quotinginformation" #define CONFIG_SLOW "slow" +#define CONFIG_SHOWINTERNAL "showinternal" #define CONFIG_SOURCEDIRS "sourcedirs" #define CONFIG_SOURCES "sources" #define CONFIG_SPURIOUS "spurious" diff --git a/tools/qdoc3/main.cpp b/tools/qdoc3/main.cpp index 514d06e..995d037 100644 --- a/tools/qdoc3/main.cpp +++ b/tools/qdoc3/main.cpp @@ -95,6 +95,7 @@ static const struct { }; static bool slow = false; +static bool showInternal = false; static QStringList defines; static QHash<QString, Tree *> trees; @@ -120,14 +121,16 @@ static void printHelp() { Location::information(tr("Usage: qdoc [options] file1.qdocconf ...\n" "Options:\n" - " -help " + " -help " "Display this information and exit\n" - " -version " + " -version " "Display version of qdoc and exit\n" - " -D<name> " + " -D<name> " "Define <name> as a macro while parsing sources\n" - " -slow " - "Turn on features that slow down qdoc") ); + " -slow " + "Turn on features that slow down qdoc" + " -showinternal " + "Include stuff marked internal") ); } /*! @@ -160,6 +163,8 @@ static void processQdocconfFile(const QString &fileName) ++i; } config.setStringList(CONFIG_SLOW, QStringList(slow ? "true" : "false")); + config.setStringList(CONFIG_SHOWINTERNAL, + QStringList(showInternal ? "true" : "false")); /* With the default configuration values in place, load @@ -326,10 +331,11 @@ static void processQdocconfFile(const QString &fileName) /* Generate the XML tag file, if it was requested. */ + QString tagFile = config.getString(CONFIG_TAGFILE); if (!tagFile.isEmpty()) tree->generateTagFile(tagFile); - + tree->setVersion(""); Generator::terminate(); CodeParser::terminate(); @@ -342,7 +348,6 @@ static void processQdocconfFile(const QString &fileName) foreach (QTranslator *translator, translators) delete translator; - delete tree; } @@ -426,6 +431,9 @@ int main(int argc, char **argv) else if (opt == "-slow") { slow = true; } + else if (opt == "-showinternal") { + showInternal = true; + } else { qdocFiles.append(opt); } |