diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2011-05-16 10:19:02 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2011-05-16 10:19:02 +0200 |
commit | 276d60a4d6c9d1b72c4aa7df1f86e7ce9097beeb (patch) | |
tree | 73130ce8a80181fb9d234028c5057d7eb86f02ab /src | |
parent | 850b602c7a72635eb37a998089ee085d5d505c34 (diff) | |
parent | 173099696f44073441975febfa35ddfb3585e8c5 (diff) |
Merge remote branch 'origin/master' into refactor
Conflicts:
src/modules/qt_openvg.pri
src/widgets/to_be_moved/qlinecontrol_p.h
Diffstat (limited to 'src')
34 files changed, 336 insertions, 261 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 35edcdb1a1..a16bf2599d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -44,11 +44,11 @@ #include <stddef.h> -#define QT_VERSION_STR "4.8.0" +#define QT_VERSION_STR "5.0.0" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x040800 +#define QT_VERSION 0x050000 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index d19fcc5377..6a14e7c410 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -86,10 +86,11 @@ public: Qt_4_5 = 11, Qt_4_6 = 12, Qt_4_7 = Qt_4_6, - Qt_4_8 = Qt_4_7 -#if QT_VERSION >= 0x040900 + Qt_4_8 = Qt_4_7, + Qt_4_9 = Qt_4_8, + Qt_5_0 = Qt_4_8 +#if QT_VERSION >= 0x050100 #error Add the datastream version for this Qt version - Qt_4_9 = Qt_4_8 #endif }; diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 1501daf5a9..90ed7293fd 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -113,64 +113,6 @@ QListData::Data *QListData::detach_grow(int *idx, int num) return x; } -#if QT_VERSION >= 0x050000 -# error "Remove QListData::detach(), it is only required for binary compatibility for 4.0.x to 4.2.x" -#endif -QListData::Data *QListData::detach() -{ - Data *x = static_cast<Data *>(qMalloc(DataHeaderSize + d->alloc * sizeof(void *))); - Q_CHECK_PTR(x); - - x->ref = 1; - x->sharable = true; - x->alloc = d->alloc; - if (!x->alloc) { - x->begin = 0; - x->end = 0; - } else { - x->begin = d->begin; - x->end = d->end; - } - - qSwap(d, x); - if (!x->ref.deref()) - return x; - return 0; -} - -/*! - * Detaches the QListData by reallocating new memory. - * Returns the old (shared) data, it is up to the caller to deref() and free() - * For the new data node_copy needs to be called. - * - * \internal - */ -#if QT_VERSION >= 0x050000 -# error "Remove QListData::detach2(), it is only required for binary compatibility for 4.3.x to 4.5.x" -#endif -QListData::Data *QListData::detach2() -{ - Data *x = d; - Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + x->alloc * sizeof(void *))); - Q_CHECK_PTR(t); - - ::memcpy(t, d, DataHeaderSize + d->alloc * sizeof(void *)); - - t->ref = 1; - t->sharable = true; - t->alloc = x->alloc; - if (!t->alloc) { - t->begin = 0; - t->end = 0; - } else { - t->begin = x->begin; - t->end = x->end; - } - d = t; - - return x; -} - /*! * Detaches the QListData by allocating new memory for a list which possibly * has a different size than the copied one. @@ -200,21 +142,6 @@ QListData::Data *QListData::detach(int alloc) return x; } -/*! - * Detaches the QListData by reallocating new memory. - * Returns the old (shared) data, it is up to the caller to deref() and free() - * For the new data node_copy needs to be called. - * - * \internal - */ -#if QT_VERSION >= 0x050000 -# error "Remove QListData::detach3(), it is only required for binary compatibility for 4.5.x to 4.6.x" -#endif -QListData::Data *QListData::detach3() -{ - return detach(d->alloc); -} - void QListData::realloc(int alloc) { Q_ASSERT(d->ref == 1); @@ -254,24 +181,6 @@ void **QListData::append() } // ensures that enough space is available to append the list -#if QT_VERSION >= 0x050000 -# error "Remove QListData::append(), it is only required for binary compatibility up to 4.5.x" -#endif -void **QListData::append(const QListData& l) -{ - Q_ASSERT(d->ref == 1); - int e = d->end; - int n = l.d->end - l.d->begin; - if (n) { - if (e + n > d->alloc) - realloc(grow(e + n)); - ::memcpy(d->array + d->end, l.d->array + l.d->begin, n*sizeof(void*)); - d->end += n; - } - return d->array + e; -} - -// ensures that enough space is available to append the list void **QListData::append2(const QListData& l) { return append(l.d->end - l.d->begin); diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 498b1546e2..3ee262fcf1 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -3,6 +3,8 @@ #include <qdebug.h> #include <math.h> +QT_BEGIN_NAMESPACE + #if 0 inline QString capString(int caps) { @@ -148,28 +150,28 @@ static StrokeLine strokeLine(int strokeSelection) switch (strokeSelection) { case Aliased|Solid|RegularDraw: - stroke = &::drawLine<drawPixel, NoDasher>; + stroke = &QT_PREPEND_NAMESPACE(drawLine)<drawPixel, NoDasher>; break; case Aliased|Solid|FastDraw: - stroke = &::drawLine<drawPixelARGB32Opaque, NoDasher>; + stroke = &QT_PREPEND_NAMESPACE(drawLine)<drawPixelARGB32Opaque, NoDasher>; break; case Aliased|Dashed|RegularDraw: - stroke = &::drawLine<drawPixel, Dasher>; + stroke = &QT_PREPEND_NAMESPACE(drawLine)<drawPixel, Dasher>; break; case Aliased|Dashed|FastDraw: - stroke = &::drawLine<drawPixelARGB32Opaque, Dasher>; + stroke = &QT_PREPEND_NAMESPACE(drawLine)<drawPixelARGB32Opaque, Dasher>; break; case AntiAliased|Solid|RegularDraw: - stroke = &drawLineAA<drawPixel, NoDasher>; + stroke = &QT_PREPEND_NAMESPACE(drawLineAA)<drawPixel, NoDasher>; break; case AntiAliased|Solid|FastDraw: - stroke = &drawLineAA<drawPixelARGB32, NoDasher>; + stroke = &QT_PREPEND_NAMESPACE(drawLineAA)<drawPixelARGB32, NoDasher>; break; case AntiAliased|Dashed|RegularDraw: - stroke = &drawLineAA<drawPixel, Dasher>; + stroke = &QT_PREPEND_NAMESPACE(drawLineAA)<drawPixel, Dasher>; break; case AntiAliased|Dashed|FastDraw: - stroke = &drawLineAA<drawPixelARGB32, Dasher>; + stroke = &QT_PREPEND_NAMESPACE(drawLineAA)<drawPixelARGB32, Dasher>; break; default: Q_ASSERT(false); @@ -952,3 +954,5 @@ static void drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx } } } + +QT_END_NAMESPACE diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index bc6dd76829..1355a5ad13 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -6,6 +6,12 @@ #include <private/qpaintengine_raster_p.h> #include <qpen.h> +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + class QCosmeticStroker; @@ -98,4 +104,8 @@ public: bool clipLine(qreal &x1, qreal &y1, qreal &x2, qreal &y2); }; +QT_END_NAMESPACE + +QT_END_HEADER + #endif // QCOSMETICLINE_H diff --git a/src/modules/qt_core.pri b/src/modules/qt_core.pri index bf013432a5..e6e5df9d27 100644 --- a/src/modules/qt_core.pri +++ b/src/modules/qt_core.pri @@ -1,6 +1,6 @@ -QT.core.VERSION = 4.8.0 -QT.core.MAJOR_VERSION = 4 -QT.core.MINOR_VERSION = 8 +QT.core.VERSION = 5.0.0 +QT.core.MAJOR_VERSION = 5 +QT.core.MINOR_VERSION = 0 QT.core.PATCH_VERSION = 0 QT.core.name = QtCore diff --git a/src/modules/qt_dbus.pri b/src/modules/qt_dbus.pri index 9aefab9b82..d57160eb77 100644 --- a/src/modules/qt_dbus.pri +++ b/src/modules/qt_dbus.pri @@ -1,6 +1,6 @@ -QT.dbus.VERSION = 4.8.0 -QT.dbus.MAJOR_VERSION = 4 -QT.dbus.MINOR_VERSION = 8 +QT.dbus.VERSION = 5.0.0 +QT.dbus.MAJOR_VERSION = 5 +QT.dbus.MINOR_VERSION = 0 QT.dbus.PATCH_VERSION = 0 QT.dbus.name = QtDBus diff --git a/src/modules/qt_gui.pri b/src/modules/qt_gui.pri index 1ef3697db6..0d1b2109f8 100644 --- a/src/modules/qt_gui.pri +++ b/src/modules/qt_gui.pri @@ -1,6 +1,6 @@ -QT.gui.VERSION = 4.8.0 -QT.gui.MAJOR_VERSION = 4 -QT.gui.MINOR_VERSION = 8 +QT.gui.VERSION = 5.0.0 +QT.gui.MAJOR_VERSION = 5 +QT.gui.MINOR_VERSION = 0 QT.gui.PATCH_VERSION = 0 QT.gui.name = QtGui diff --git a/src/modules/qt_network.pri b/src/modules/qt_network.pri index 44326c2b2d..76b462286f 100644 --- a/src/modules/qt_network.pri +++ b/src/modules/qt_network.pri @@ -1,6 +1,6 @@ -QT.network.VERSION = 4.8.0 -QT.network.MAJOR_VERSION = 4 -QT.network.MINOR_VERSION = 8 +QT.network.VERSION = 5.0.0 +QT.network.MAJOR_VERSION = 5 +QT.network.MINOR_VERSION = 0 QT.network.PATCH_VERSION = 0 QT.network.name = QtNetwork diff --git a/src/modules/qt_opengl.pri b/src/modules/qt_opengl.pri index a1080cb5a5..22476cf949 100644 --- a/src/modules/qt_opengl.pri +++ b/src/modules/qt_opengl.pri @@ -1,6 +1,6 @@ -QT.opengl.VERSION = 4.8.0 -QT.opengl.MAJOR_VERSION = 4 -QT.opengl.MINOR_VERSION = 8 +QT.opengl.VERSION = 5.0.0 +QT.opengl.MAJOR_VERSION = 5 +QT.opengl.MINOR_VERSION = 0 QT.opengl.PATCH_VERSION = 0 QT.opengl.name = QtOpenGL diff --git a/src/modules/qt_sql.pri b/src/modules/qt_sql.pri index 14d2422989..02f48d2a6b 100644 --- a/src/modules/qt_sql.pri +++ b/src/modules/qt_sql.pri @@ -1,6 +1,6 @@ -QT.sql.VERSION = 4.8.0 -QT.sql.MAJOR_VERSION = 4 -QT.sql.MINOR_VERSION = 8 +QT.sql.VERSION = 5.0.0 +QT.sql.MAJOR_VERSION = 5 +QT.sql.MINOR_VERSION = 0 QT.sql.PATCH_VERSION = 0 QT.sql.name = QtSql diff --git a/src/modules/qt_testlib.pri b/src/modules/qt_testlib.pri index 9fd9b2e446..923fb27df3 100644 --- a/src/modules/qt_testlib.pri +++ b/src/modules/qt_testlib.pri @@ -1,6 +1,6 @@ -QT.testlib.VERSION = 4.8.0 -QT.testlib.MAJOR_VERSION = 4 -QT.testlib.MINOR_VERSION = 8 +QT.testlib.VERSION = 5.0.0 +QT.testlib.MAJOR_VERSION = 5 +QT.testlib.MINOR_VERSION = 0 QT.testlib.PATCH_VERSION = 0 QT.testlib.name = QtTest diff --git a/src/modules/qt_uilib.pri b/src/modules/qt_uilib.pri index 5973216921..04616ac6af 100644 --- a/src/modules/qt_uilib.pri +++ b/src/modules/qt_uilib.pri @@ -1,6 +1,6 @@ -QT.uilib.VERSION = 4.8.0 -QT.uilib.MAJOR_VERSION = 4 -QT.uilib.MINOR_VERSION = 8 +QT.uilib.VERSION = 5.0.0 +QT.uilib.MAJOR_VERSION = 5 +QT.uilib.MINOR_VERSION = 0 QT.uilib.PATCH_VERSION = 0 QT.uilib.name = QtUiLib diff --git a/src/modules/qt_uitools.pri b/src/modules/qt_uitools.pri index d30c8b845b..128a20cfd7 100644 --- a/src/modules/qt_uitools.pri +++ b/src/modules/qt_uitools.pri @@ -1,6 +1,6 @@ -QT.uitools.VERSION = 4.8.0 -QT.uitools.MAJOR_VERSION = 4 -QT.uitools.MINOR_VERSION = 8 +QT.uitools.VERSION = 5.0.0 +QT.uitools.MAJOR_VERSION = 5 +QT.uitools.MINOR_VERSION = 0 QT.uitools.PATCH_VERSION = 0 QT.uitools.name = QtUiTools diff --git a/src/modules/qt_xml.pri b/src/modules/qt_xml.pri index e7db6365eb..ea831236e6 100644 --- a/src/modules/qt_xml.pri +++ b/src/modules/qt_xml.pri @@ -1,6 +1,6 @@ -QT.xml.VERSION = 4.8.0 -QT.xml.MAJOR_VERSION = 4 -QT.xml.MINOR_VERSION = 8 +QT.xml.VERSION = 5.0.0 +QT.xml.MAJOR_VERSION = 5 +QT.xml.MINOR_VERSION = 0 QT.xml.PATCH_VERSION = 0 QT.xml.name = QtXml diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp index e463af5d47..77c9990d9e 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp +++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp @@ -96,7 +96,6 @@ public: QWaylandSelection(QWaylandDisplay *display, QMimeData *data); ~QWaylandSelection(); -private: static uint32_t getTime(); static void send(void *data, struct wl_selection *selection, const char *mime_type, int fd); static void cancelled(void *data, struct wl_selection *selection); @@ -164,7 +163,7 @@ void QWaylandSelection::cancelled(void *data, struct wl_selection *selection) } QWaylandClipboard::QWaylandClipboard(QWaylandDisplay *display) - : mDisplay(display), mSelection(0), mMimeDataIn(0), mOffer(0) + : mDisplay(display), mMimeDataIn(0), mOffer(0) { clipboard = this; } @@ -222,6 +221,8 @@ QVariant QWaylandClipboard::retrieveData(const QString &mimeType, QVariant::Type QMimeData *QWaylandClipboard::mimeData(QClipboard::Mode mode) { Q_ASSERT(mode == QClipboard::Clipboard); + if (!mSelections.isEmpty()) + return mSelections.last()->mMimeData; if (!mMimeDataIn) mMimeDataIn = new QWaylandMimeData; mMimeDataIn->clearAll(); @@ -236,7 +237,7 @@ void QWaylandClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) if (!mDisplay->inputDevices().isEmpty()) { if (!data) data = new QMimeData; - mSelection = new QWaylandSelection(mDisplay, data); + mSelections.append(new QWaylandSelection(mDisplay, data)); } else { qWarning("QWaylandClipboard::setMimeData: No input devices"); } @@ -266,21 +267,27 @@ void QWaylandClipboard::offer(void *data, struct wl_selection_offer *selection_offer, const char *type) { + Q_UNUSED(data); Q_UNUSED(selection_offer); - QWaylandClipboard *self = static_cast<QWaylandClipboard *>(data); - self->mOfferedMimeTypes.append(QString::fromLatin1(type)); + clipboard->mOfferedMimeTypes.append(QString::fromLatin1(type)); } void QWaylandClipboard::keyboardFocus(void *data, struct wl_selection_offer *selection_offer, wl_input_device *input_device) { - QWaylandClipboard *self = static_cast<QWaylandClipboard *>(data); + Q_UNUSED(data); if (!input_device) { wl_selection_offer_destroy(selection_offer); - self->mOffer = 0; + clipboard->mOffer = 0; return; } - self->mOffer = selection_offer; - self->emitChanged(QClipboard::Clipboard); + clipboard->mOffer = selection_offer; + if (clipboard->mSelections.isEmpty()) + QMetaObject::invokeMethod(&clipboard->mEmitter, "emitChanged", Qt::QueuedConnection); +} + +void QWaylandClipboardSignalEmitter::emitChanged() +{ + clipboard->emitChanged(QClipboard::Clipboard); } diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.h b/src/plugins/platforms/wayland/qwaylandclipboard.h index 6a02254cae..db436b890a 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.h +++ b/src/plugins/platforms/wayland/qwaylandclipboard.h @@ -51,6 +51,13 @@ class QWaylandSelection; class QWaylandMimeData; struct wl_selection_offer; +class QWaylandClipboardSignalEmitter : public QObject +{ + Q_OBJECT +public slots: + void emitChanged(); +}; + class QWaylandClipboard : public QPlatformClipboard { public: @@ -80,11 +87,11 @@ private: static void forceRoundtrip(struct wl_display *display); QWaylandDisplay *mDisplay; - QWaylandSelection *mSelection; QWaylandMimeData *mMimeDataIn; QList<QWaylandSelection *> mSelections; QStringList mOfferedMimeTypes; struct wl_selection_offer *mOffer; + QWaylandClipboardSignalEmitter mEmitter; }; #endif // QWAYLANDCLIPBOARD_H diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 175bdd8451..93a226bd06 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -5,8 +5,6 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += core-private gui-private -QT+=gui-private core-private - SOURCES = \ qxcbconnection.cpp \ qxcbintegration.cpp \ diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri index bcf473f1fe..2dd96bf7f2 100644 --- a/src/plugins/qpluginbase.pri +++ b/src/plugins/qpluginbase.pri @@ -1,6 +1,6 @@ TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.8.0 + VERSION=5.0.0 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/src/qbase.pri b/src/qbase.pri index 6336aa9f5c..03f85cf931 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -12,7 +12,7 @@ INCLUDEPATH *= $$MODULE_INCLUDES $$MODULE_INCLUDES/.. #just for today to have so isEmpty(QT_ARCH):!isEmpty(ARCH):QT_ARCH=$$ARCH #another compat that will rot for change #215700 TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.8.0 + VERSION=5.0.0 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h index b0b48c5025..fce5aad56a 100644 --- a/src/testlib/qsignalspy.h +++ b/src/testlib/qsignalspy.h @@ -68,8 +68,15 @@ public: #else static const int memberOffset = QObject::staticMetaObject.methodCount(); #endif - Q_ASSERT(obj); - Q_ASSERT(aSignal); + if (!obj) { + qWarning("QSignalSpy: Cannot spy on a null object"); + return; + } + + if (!aSignal) { + qWarning("QSignalSpy: Null signal name is not valid"); + return; + } if (((aSignal[0] - '0') & 0x03) != QSIGNAL_CODE) { qWarning("QSignalSpy: Not a valid signal, use the SIGNAL macro"); diff --git a/src/testlib/qsignalspy.qdoc b/src/testlib/qsignalspy.qdoc index 0c22868852..83dcccede2 100644 --- a/src/testlib/qsignalspy.qdoc +++ b/src/testlib/qsignalspy.qdoc @@ -62,7 +62,11 @@ /*! \fn QSignalSpy::QSignalSpy(QObject *object, const char *signal) Constructs a new QSignalSpy that listens for emissions of the \a signal - from the QObject \a object. Neither \a signal nor \a object can be null. + from the QObject \a object. If QSignalSpy is not able to listen for a + valid signal (for example, because \a object is null or \a signal does + not denote a valid signal of \a object), an explanatory warning message + will be output using qWarning() and subsequent calls to \c isValid() will + return false. Example: \snippet doc/src/snippets/code/doc_src_qsignalspy.cpp 4 diff --git a/src/widgets/accessible/qaccessible.h b/src/widgets/accessible/qaccessible.h index 33e76a7ad2..c1b9afbcd5 100644 --- a/src/widgets/accessible/qaccessible.h +++ b/src/widgets/accessible/qaccessible.h @@ -111,8 +111,8 @@ public: TableSummaryChanged, TextAttributeChanged, TextCaretMoved, - TextChanged, - TextColumnChanged, + // TextChanged, deprecated, use TextUpdated + TextColumnChanged = TextCaretMoved + 2, TextInserted, TextRemoved, TextUpdated, diff --git a/src/widgets/graphicsview/qgraphicslayout.cpp b/src/widgets/graphicsview/qgraphicslayout.cpp index 5bd298061d..a67ae48cc7 100644 --- a/src/widgets/graphicsview/qgraphicslayout.cpp +++ b/src/widgets/graphicsview/qgraphicslayout.cpp @@ -269,12 +269,20 @@ void QGraphicsLayout::activate() return; Q_ASSERT(!parentItem->isLayout()); - setGeometry(parentItem->contentsRect()); // relayout children + if (QGraphicsLayout::instantInvalidatePropagation()) { + QGraphicsWidget *parentWidget = static_cast<QGraphicsWidget*>(parentItem); + if (!parentWidget->parentLayoutItem()) { + // we've reached the topmost widget, resize it + bool wasResized = parentWidget->testAttribute(Qt::WA_Resized); + parentWidget->resize(parentWidget->size()); + parentWidget->setAttribute(Qt::WA_Resized, wasResized); + } - // ### bug, should be parentItem ? - parentLayoutItem()->updateGeometry(); // bubble up; will set activated to false - // ### too many resizes? maybe we should walk up the chain to the - // ### top-level layouted layoutItem and call activate there. + setGeometry(parentItem->contentsRect()); // relayout children + } else { + setGeometry(parentItem->contentsRect()); // relayout children + parentLayoutItem()->updateGeometry(); + } } /*! @@ -300,32 +308,36 @@ bool QGraphicsLayout::isActivated() const */ void QGraphicsLayout::invalidate() { - // only mark layouts as invalid (activated = false) if we can post a LayoutRequest event. - QGraphicsLayoutItem *layoutItem = this; - while (layoutItem && layoutItem->isLayout()) { - // we could call updateGeometry(), but what if that method - // does not call the base implementation? In addition, updateGeometry() - // does more than we need. - layoutItem->d_func()->sizeHintCacheDirty = true; - layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true; - layoutItem = layoutItem->parentLayoutItem(); - } - if (layoutItem) { - layoutItem->d_func()->sizeHintCacheDirty = true; - layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true; - } - - bool postIt = layoutItem ? !layoutItem->isLayout() : false; - if (postIt) { - layoutItem = this; - while (layoutItem && layoutItem->isLayout() - && static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated) { - static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated = false; + if (QGraphicsLayout::instantInvalidatePropagation()) { + updateGeometry(); + } else { + // only mark layouts as invalid (activated = false) if we can post a LayoutRequest event. + QGraphicsLayoutItem *layoutItem = this; + while (layoutItem && layoutItem->isLayout()) { + // we could call updateGeometry(), but what if that method + // does not call the base implementation? In addition, updateGeometry() + // does more than we need. + layoutItem->d_func()->sizeHintCacheDirty = true; + layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true; layoutItem = layoutItem->parentLayoutItem(); } - if (layoutItem && !layoutItem->isLayout()) { - // If a layout has a parent that is not a layout it must be a QGraphicsWidget. - QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest)); + if (layoutItem) { + layoutItem->d_func()->sizeHintCacheDirty = true; + layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true; + } + + bool postIt = layoutItem ? !layoutItem->isLayout() : false; + if (postIt) { + layoutItem = this; + while (layoutItem && layoutItem->isLayout() + && static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated) { + static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated = false; + layoutItem = layoutItem->parentLayoutItem(); + } + if (layoutItem && !layoutItem->isLayout()) { + // If a layout has a parent that is not a layout it must be a QGraphicsWidget. + QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest)); + } } } } @@ -335,12 +347,27 @@ void QGraphicsLayout::invalidate() */ void QGraphicsLayout::updateGeometry() { - QGraphicsLayoutItem::updateGeometry(); - if (QGraphicsLayoutItem *parentItem = parentLayoutItem()) { - if (parentItem->isLayout()) { + Q_D(QGraphicsLayout); + if (QGraphicsLayout::instantInvalidatePropagation()) { + d->activated = false; + QGraphicsLayoutItem::updateGeometry(); + + QGraphicsLayoutItem *parentItem = parentLayoutItem(); + if (!parentItem) + return; + + if (parentItem->isLayout()) + static_cast<QGraphicsLayout *>(parentItem)->invalidate(); + else parentItem->updateGeometry(); - } else { - invalidate(); + } else { + QGraphicsLayoutItem::updateGeometry(); + if (QGraphicsLayoutItem *parentItem = parentLayoutItem()) { + if (parentItem->isLayout()) { + parentItem->updateGeometry(); + } else { + invalidate(); + } } } } @@ -446,6 +473,50 @@ void QGraphicsLayout::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) d->addChildLayoutItem(layoutItem); } +static bool g_instantInvalidatePropagation = false; + +/*! + \internal + \since 4.8 + \see instantInvalidatePropagation + + Calling this function with \a enable set to true will enable a feature that + makes propagation of invalidation up to ancestor layout items to be done in + one go. It will propagate up the parentLayoutItem() hierarchy until it has + reached the root. If the root item is a QGraphicsWidget, it will *post* a + layout request to it. When the layout request is consumed it will traverse + down the hierarchy of layouts and widgets and activate all layouts that is + invalid (not activated). This is the recommended behaviour. + + If not set it will also propagate up the parentLayoutItem() hierarchy, but + it will stop at the \i first \i widget it encounters, and post a layout + request to the widget. When the layout request is consumed, this might + cause it to continue propagation up to the parentLayoutItem() of the + widget. It will continue in this fashion until it has reached a widget with + no parentLayoutItem(). This strategy might cause drawing artifacts, since + it is not done in one go, and the consumption of layout requests might be + interleaved by consumption of paint events, which might cause significant + flicker. + Note, this is not the recommended behavior, but for compatibility reasons + this is the default behaviour. +*/ +void QGraphicsLayout::setInstantInvalidatePropagation(bool enable) +{ + g_instantInvalidatePropagation = enable; +} + +/*! + \internal + \since 4.8 + \see setInstantInvalidatePropagation + + returns true if the complete widget/layout hierarchy is rearranged in one go. +*/ +bool QGraphicsLayout::instantInvalidatePropagation() +{ + return g_instantInvalidatePropagation; +} + QT_END_NAMESPACE #endif //QT_NO_GRAPHICSVIEW diff --git a/src/widgets/graphicsview/qgraphicslayout.h b/src/widgets/graphicsview/qgraphicslayout.h index 113e6b9b7f..afe6682c90 100644 --- a/src/widgets/graphicsview/qgraphicslayout.h +++ b/src/widgets/graphicsview/qgraphicslayout.h @@ -76,6 +76,8 @@ public: virtual QGraphicsLayoutItem *itemAt(int i) const = 0; virtual void removeAt(int index) = 0; + static void setInstantInvalidatePropagation(bool enable); + static bool instantInvalidatePropagation(); protected: QGraphicsLayout(QGraphicsLayoutPrivate &, QGraphicsLayoutItem *); void addChildLayoutItem(QGraphicsLayoutItem *layoutItem); diff --git a/src/widgets/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp index c325602cc6..05e6cdf599 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp @@ -180,9 +180,14 @@ void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item) { if (item->isLayout()) { QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item); - if (layout->d_func()->activated) - layout->invalidate(); - + if (layout->d_func()->activated) { + if (QGraphicsLayout::instantInvalidatePropagation()) { + return; + } else { + layout->invalidate(); // ### LOOKS SUSPICIOUSLY WRONG!!??? + } + } + for (int i = layout->count() - 1; i >= 0; --i) { QGraphicsLayoutItem *childItem = layout->itemAt(i); if (childItem) diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp index 5591638395..40f9b1de71 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp +++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp @@ -275,17 +275,13 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item) qWarning("QGraphicsLinearLayout::insertItem: cannot insert itself"); return; } - Q_ASSERT(item); - - //the order of the following instructions is very important because - //invalidating the layout before adding the child item will make the layout happen - //before we try to paint the item - invalidate(); d->addChildLayoutItem(item); + Q_ASSERT(item); d->fixIndex(&index); d->engine.insertRow(index, d->orientation); new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index); + invalidate(); } /*! diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 60a80fc8b8..06f7013c46 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -354,8 +354,10 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) newGeom = rect; newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize)) .boundedTo(effectiveSizeHint(Qt::MaximumSize))); - if (newGeom == d->geom) - return; + + if (newGeom == d->geom) { + goto relayoutChildrenAndReturn; + } // setPos triggers ItemPositionChange, which can adjust position wd->inSetGeometry = 1; @@ -363,8 +365,9 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) wd->inSetGeometry = 0; newGeom.moveTopLeft(pos()); - if (newGeom == d->geom) - return; + if (newGeom == d->geom) { + goto relayoutChildrenAndReturn; + } // Update and prepare to change the geometry (remove from index) if the size has changed. if (wd->scene) { @@ -375,35 +378,54 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) } // Update the layout item geometry - bool moved = oldPos != pos(); - if (moved) { - // Send move event. - QGraphicsSceneMoveEvent event; - event.setOldPos(oldPos); - event.setNewPos(pos()); - QApplication::sendEvent(this, &event); - if (wd->inSetPos) { - //set the new pos - d->geom.moveTopLeft(pos()); - emit geometryChanged(); - return; + { + bool moved = oldPos != pos(); + if (moved) { + // Send move event. + QGraphicsSceneMoveEvent event; + event.setOldPos(oldPos); + event.setNewPos(pos()); + QApplication::sendEvent(this, &event); + if (wd->inSetPos) { + //set the new pos + d->geom.moveTopLeft(pos()); + emit geometryChanged(); + goto relayoutChildrenAndReturn; + } + } + QSizeF oldSize = size(); + QGraphicsLayoutItem::setGeometry(newGeom); + // Send resize event + bool resized = newGeom.size() != oldSize; + if (resized) { + QGraphicsSceneResizeEvent re; + re.setOldSize(oldSize); + re.setNewSize(newGeom.size()); + if (oldSize.width() != newGeom.size().width()) + emit widthChanged(); + if (oldSize.height() != newGeom.size().height()) + emit heightChanged(); + QGraphicsLayout *lay = wd->layout; + if (QGraphicsLayout::instantInvalidatePropagation()) { + if (!lay || lay->isActivated()) { + QApplication::sendEvent(this, &re); + } + } else { + QApplication::sendEvent(this, &re); + } } } - QSizeF oldSize = size(); - QGraphicsLayoutItem::setGeometry(newGeom); - // Send resize event - bool resized = newGeom.size() != oldSize; - if (resized) { - QGraphicsSceneResizeEvent re; - re.setOldSize(oldSize); - re.setNewSize(newGeom.size()); - if (oldSize.width() != newGeom.size().width()) - emit widthChanged(); - if (oldSize.height() != newGeom.size().height()) - emit heightChanged(); - QApplication::sendEvent(this, &re); - } + emit geometryChanged(); +relayoutChildrenAndReturn: + if (QGraphicsLayout::instantInvalidatePropagation()) { + if (QGraphicsLayout *lay = wd->layout) { + if (!lay->isActivated()) { + QEvent layoutRequest(QEvent::LayoutRequest); + QApplication::sendEvent(this, &layoutRequest); + } + } + } } /*! @@ -1052,16 +1074,31 @@ void QGraphicsWidget::updateGeometry() QGraphicsLayoutItem *parentItem = parentLayoutItem(); if (parentItem && parentItem->isLayout()) { - parentItem->updateGeometry(); + if (QGraphicsLayout::instantInvalidatePropagation()) { + static_cast<QGraphicsLayout *>(parentItem)->invalidate(); + } else { + parentItem->updateGeometry(); + } } else { if (parentItem) { + // This is for custom layouting QGraphicsWidget *parentWid = parentWidget(); //### if (parentWid->isVisible()) QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest)); + } else { + /** + * If this is the topmost widget, post a LayoutRequest event to the widget. + * When the event is received, it will start flowing all the way down to the leaf + * widgets in one go. This will make a relayout flicker-free. + */ + if (QGraphicsLayout::instantInvalidatePropagation()) + QApplication::postEvent(static_cast<QGraphicsWidget *>(this), new QEvent(QEvent::LayoutRequest)); + } + if (!QGraphicsLayout::instantInvalidatePropagation()) { + bool wasResized = testAttribute(Qt::WA_Resized); + resize(size()); // this will restrict the size + setAttribute(Qt::WA_Resized, wasResized); } - bool wasResized = testAttribute(Qt::WA_Resized); - resize(size()); // this will restrict the size - setAttribute(Qt::WA_Resized, wasResized); } } diff --git a/src/widgets/itemviews/qidentityproxymodel.cpp b/src/widgets/itemviews/qidentityproxymodel.cpp index 9396e6199a..60f7d98bd8 100644 --- a/src/widgets/itemviews/qidentityproxymodel.cpp +++ b/src/widgets/itemviews/qidentityproxymodel.cpp @@ -1,13 +1,18 @@ /**************************************************************************** ** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, -** a KDAB Group company, info@kdab.com, -** author Stephen Kelly <stephen.kelly@kdab.com> +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> ** All rights reserved. -** Contact: Nokia Corporation (info@qt.nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -20,17 +25,17 @@ ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/widgets/itemviews/qidentityproxymodel.h b/src/widgets/itemviews/qidentityproxymodel.h index 9e38e747ea..0c96e7f5bd 100644 --- a/src/widgets/itemviews/qidentityproxymodel.h +++ b/src/widgets/itemviews/qidentityproxymodel.h @@ -1,13 +1,18 @@ /**************************************************************************** ** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, -** a KDAB Group company, info@kdab.com, -** author Stephen Kelly <stephen.kelly@kdab.com> +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> ** All rights reserved. -** Contact: Nokia Corporation (info@qt.nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -20,17 +25,17 @@ ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** ** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/widgets/to_be_moved/qlinecontrol.cpp b/src/widgets/to_be_moved/qlinecontrol.cpp index 40ebb65d0a..2a15555b89 100644 --- a/src/widgets/to_be_moved/qlinecontrol.cpp +++ b/src/widgets/to_be_moved/qlinecontrol.cpp @@ -651,7 +651,12 @@ void QLineControl::internalSetText(const QString &txt, int pos, bool edited) m_modifiedState = m_undoState = 0; m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos; m_textDirty = (oldText != m_text); - finishChange(-1, true, edited); + bool changed = finishChange(-1, true, edited); + +#ifndef QT_NO_ACCESSIBILITY + if (changed) + QAccessible::updateAccessibility(parent(), 0, QAccessible::TextUpdated); +#endif } @@ -1238,6 +1243,9 @@ void QLineControl::emitCursorPositionChanged() const int oldLast = m_lastCursorPos; m_lastCursorPos = m_cursor; cursorPositionChanged(oldLast, m_cursor); +#ifndef QT_NO_ACCESSIBILITY + QAccessible::updateAccessibility(parent(), 0, QAccessible::TextCaretMoved); +#endif } } diff --git a/src/widgets/to_be_moved/qlinecontrol_p.h b/src/widgets/to_be_moved/qlinecontrol_p.h index 9e1adb6792..088a6e83d8 100644 --- a/src/widgets/to_be_moved/qlinecontrol_p.h +++ b/src/widgets/to_be_moved/qlinecontrol_p.h @@ -61,7 +61,6 @@ #include "QtGui/qtextlayout.h" #include "QtWidgets/qstyleoption.h" #include "QtCore/qpointer.h" -#include "QtWidgets/qlineedit.h" #include "QtGui/qclipboard.h" #include "QtCore/qpoint.h" #include "QtWidgets/qcompleter.h" diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 816689019d..0a3773c8af 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -154,6 +154,7 @@ void QLineEditPrivate::init(const QString& txt) { Q_Q(QLineEdit); control = new QLineControl(txt); + control->setParent(q); control->setFont(q->font()); QObject::connect(control, SIGNAL(textChanged(QString)), q, SIGNAL(textChanged(QString))); diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index b3ec575c86..afb4aa6f0b 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -84,7 +84,6 @@ public: ~QLineEditPrivate() { - delete control; } QLineControl *control; |