diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-05-31 05:23:40 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-05-31 05:23:40 (GMT) |
commit | f587dfeaa9d369235d347af3d14339054ee59908 (patch) | |
tree | 3ac92f6a08d871099d8808e8d5fc59f50863bacb /src/gui | |
parent | feb9949a11abbf244e0bfcdc128981596758de40 (diff) | |
parent | 9da305aedfaa5da5a3059c99ac5a5389dab42b10 (diff) | |
download | Qt-f587dfeaa9d369235d347af3d14339054ee59908.zip Qt-f587dfeaa9d369235d347af3d14339054ee59908.tar.gz Qt-f587dfeaa9d369235d347af3d14339054ee59908.tar.bz2 |
Merge remote branch 'staging/4.7' into HEAD
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 6 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 18 | ||||
-rw-r--r-- | src/gui/itemviews/qitemdelegate.cpp | 1 | ||||
-rw-r--r-- | src/gui/itemviews/qsortfilterproxymodel.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qdnd_x11.cpp | 21 | ||||
-rw-r--r-- | src/gui/styles/qgtkstyle.cpp | 2 | ||||
-rw-r--r-- | src/gui/styles/qgtkstyle_p.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qstatictext.cpp | 163 | ||||
-rw-r--r-- | src/gui/text/qstatictext_p.h | 19 |
10 files changed, 147 insertions, 90 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index db6c4c5..36d21a6 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1275,14 +1275,14 @@ void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rec QTransform matrix = childd->transformToParent(); if (x) matrix *= *x; - *rect |= matrix.mapRect(child->boundingRect()); + *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect()); if (!childd->children.isEmpty()) childd->childrenBoundingRectHelper(&matrix, rect); } else { if (x) - *rect |= x->mapRect(child->boundingRect()); + *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect()); else - *rect |= child->boundingRect(); + *rect |= child->d_ptr->effectiveBoundingRect(); if (!childd->children.isEmpty()) childd->childrenBoundingRectHelper(x, rect); } diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index ae0abf9..22c3f92 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4889,6 +4889,24 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b if (updateAll) return; + if (removingItemFromScene && !ignoreOpacity && !item->d_ptr->ignoreOpacity) { + // If any of the item's ancestors ignore opacity, it means that the opacity + // was set to 0 (and the update request has not yet been processed). That + // also means that we have to ignore the opacity for the item itself; otherwise + // things like: parent->setOpacity(0); scene->removeItem(child) won't work. + // Note that we only do this when removing items from the scene. In all other + // cases the ignoreOpacity bit propagates properly in processDirtyItems, but + // since the item is removed immediately it won't be processed there. + QGraphicsItem *p = item->d_ptr->parent; + while (p) { + if (p->d_ptr->ignoreOpacity) { + item->d_ptr->ignoreOpacity = true; + break; + } + p = p->d_ptr->parent; + } + } + if (item->d_ptr->discardUpdateRequest(/*ignoreVisibleBit=*/force, /*ignoreDirtyBit=*/removingItemFromScene || invalidateChildren, /*ignoreOpacity=*/ignoreOpacity)) { diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index d5f6fd2..9bbfc23 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -667,7 +667,6 @@ void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &o { Q_D(const QItemDelegate); - QPen pen = painter->pen(); QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index b12cd45..f9b6b94 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -2392,7 +2392,7 @@ bool QSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex QVariant r = (right.model() ? right.model()->data(right, d->sort_role) : QVariant()); switch (l.userType()) { case QVariant::Invalid: - return (r.type() == QVariant::Invalid); + return (r.type() != QVariant::Invalid); case QVariant::Int: return l.toInt() < r.toInt(); case QVariant::UInt: diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 57c4c99..0d11b27 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -666,7 +666,8 @@ void QApplicationPrivate::process_cmdline() \o -geometry \e geometry, sets the client geometry of the first window that is shown. \o -fn or \c -font \e font, defines the application font. The font - should be specified using an X logical font description. + should be specified using an X logical font description. Note that + this option is ignored when Qt is built with fontconfig support enabled. \o -bg or \c -background \e color, sets the default background color and an application palette (light and dark shades are calculated). \o -fg or \c -foreground \e color, sets the default foreground color. diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index 2b12317..92dd0a1 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -64,6 +64,7 @@ #include "qtextcodec.h" #include "qdnd_p.h" +#include "qapplication_p.h" #include "qt_x11_p.h" #include "qx11info_x11.h" @@ -1111,7 +1112,20 @@ void qt_xdnd_send_leave() waiting_for_status = false; } - +// TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8. +static Qt::KeyboardModifiers currentKeyboardModifiers() +{ + Window root; + Window child; + int root_x, root_y, win_x, win_y; + uint keybstate; + for (int i = 0; i < ScreenCount(X11->display); ++i) { + if (XQueryPointer(X11->display, QX11Info::appRootWindow(i), &root, &child, + &root_x, &root_y, &win_x, &win_y, &keybstate)) + return X11->translateModifiers(keybstate & 0x00ff); + } + return 0; +} void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive) { @@ -1159,6 +1173,11 @@ void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive) if (!dropData) dropData = (manager->object) ? manager->dragPrivate()->data : manager->dropData; + // Drop coming from another app? Update keyboard modifiers. + if (!qt_xdnd_dragging) { + QApplicationPrivate::modifier_buttons = currentKeyboardModifiers(); + } + QDropEvent de(qt_xdnd_current_position, possible_actions, dropData, QApplication::mouseButtons(), QApplication::keyboardModifiers()); QApplication::sendEvent(qt_xdnd_current_widget, &de); diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 6c8d561..9d6dc9a 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -325,6 +325,7 @@ void QGtkStyle::polish(QApplication *app) qt_filedialog_save_filename_hook = &QGtkStylePrivate::saveFilename; qt_filedialog_open_filenames_hook = &QGtkStylePrivate::openFilenames; qt_filedialog_existing_directory_hook = &QGtkStylePrivate::openDirectory; + qApp->installEventFilter(&d->filter); } } } @@ -345,6 +346,7 @@ void QGtkStyle::unpolish(QApplication *app) qt_filedialog_save_filename_hook = 0; qt_filedialog_open_filenames_hook = 0; qt_filedialog_existing_directory_hook = 0; + qApp->removeEventFilter(&d->filter); } } diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp index 3c6a1ef..4ed0fab 100644 --- a/src/gui/styles/qgtkstyle_p.cpp +++ b/src/gui/styles/qgtkstyle_p.cpp @@ -285,8 +285,6 @@ void QGtkStylePrivate::init() { resolveGtk(); initGtkWidgets(); - if (isThemeAvailable()) - qApp->installEventFilter(&filter); } GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index c7817c6..84c1d96 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -363,23 +363,24 @@ QSizeF QStaticText::size() const } QStaticTextPrivate::QStaticTextPrivate() - : textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0), + : textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0), charPool(0), needsRelayout(true), useBackendOptimizations(false), textFormat(Qt::AutoText) { } QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other) : text(other.text), font(other.font), textWidth(other.textWidth), matrix(other.matrix), - items(0), itemCount(0), glyphPool(0), positionPool(0), needsRelayout(true), + items(0), itemCount(0), glyphPool(0), positionPool(0), charPool(0), needsRelayout(true), useBackendOptimizations(other.useBackendOptimizations), textFormat(other.textFormat) { } QStaticTextPrivate::~QStaticTextPrivate() { - delete[] items; + delete[] items; delete[] glyphPool; delete[] positionPool; + delete[] charPool; } QStaticTextPrivate *QStaticTextPrivate::get(const QStaticText *q) @@ -395,15 +396,8 @@ namespace { class DrawTextItemRecorder: public QPaintEngine { public: - DrawTextItemRecorder(int expectedItemCount, QStaticTextItem *items, - int expectedGlyphCount, QFixedPoint *positionPool, glyph_t *glyphPool) - : m_items(items), - m_itemCount(0), m_glyphCount(0), - m_expectedItemCount(expectedItemCount), - m_expectedGlyphCount(expectedGlyphCount), - m_glyphPool(glyphPool), - m_positionPool(positionPool), - m_dirtyPen(false) + DrawTextItemRecorder(bool useBackendOptimizations, int numChars) + : m_dirtyPen(false), m_useBackendOptimizations(useBackendOptimizations) { } @@ -415,26 +409,19 @@ namespace { virtual void drawTextItem(const QPointF &position, const QTextItem &textItem) { - const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); - - m_itemCount++; - m_glyphCount += ti.glyphs.numGlyphs; - if (m_items == 0) - return; - - Q_ASSERT(m_itemCount <= m_expectedItemCount); - Q_ASSERT(m_glyphCount <= m_expectedGlyphCount); - - QStaticTextItem *currentItem = (m_items + (m_itemCount - 1)); - currentItem->fontEngine = ti.fontEngine; - currentItem->font = ti.font(); - currentItem->chars = ti.chars; - currentItem->numChars = ti.num_chars; - currentItem->numGlyphs = ti.glyphs.numGlyphs; - currentItem->glyphs = m_glyphPool; - currentItem->glyphPositions = m_positionPool; + const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); + + QStaticTextItem currentItem; + currentItem.fontEngine = ti.fontEngine; + currentItem.font = ti.font(); + currentItem.charOffset = m_chars.size(); + currentItem.numChars = ti.num_chars; + currentItem.numGlyphs = ti.glyphs.numGlyphs; + currentItem.glyphOffset = m_glyphs.size(); // Store offset into glyph pool + currentItem.positionOffset = m_glyphs.size(); // Offset into position pool + currentItem.useBackendOptimizations = m_useBackendOptimizations; if (m_dirtyPen) - currentItem->color = state->pen().color(); + currentItem.color = state->pen().color(); QTransform matrix = state->transform(); matrix.translate(position.x(), position.y()); @@ -447,13 +434,21 @@ namespace { Q_ASSERT(size == ti.glyphs.numGlyphs); Q_ASSERT(size == positions.size()); - memmove(currentItem->glyphs, glyphs.constData(), sizeof(glyph_t) * size); - memmove(currentItem->glyphPositions, positions.constData(), sizeof(QFixedPoint) * size); + m_glyphs.resize(m_glyphs.size() + size); + m_positions.resize(m_glyphs.size()); + m_chars.resize(m_chars.size() + ti.num_chars); - m_glyphPool += size; - m_positionPool += size; - } + glyph_t *glyphsDestination = m_glyphs.data() + currentItem.glyphOffset; + qMemCopy(glyphsDestination, glyphs.constData(), sizeof(glyph_t) * currentItem.numGlyphs); + QFixedPoint *positionsDestination = m_positions.data() + currentItem.positionOffset; + qMemCopy(positionsDestination, positions.constData(), sizeof(QFixedPoint) * currentItem.numGlyphs); + + QChar *charsDestination = m_chars.data() + currentItem.charOffset; + qMemCopy(charsDestination, ti.chars, sizeof(QChar) * currentItem.numChars); + + m_items.append(currentItem); + } virtual bool begin(QPaintDevice *) { return true; } virtual bool end() { return true; } @@ -463,38 +458,42 @@ namespace { return User; } - int itemCount() const + QVector<QStaticTextItem> items() const { - return m_itemCount; + return m_items; } - int glyphCount() const + QVector<QFixedPoint> positions() const { - return m_glyphCount; + return m_positions; } - private: - QStaticTextItem *m_items; - int m_itemCount; - int m_glyphCount; - int m_expectedItemCount; - int m_expectedGlyphCount; + QVector<glyph_t> glyphs() const + { + return m_glyphs; + } + + QVector<QChar> chars() const + { + return m_chars; + } - glyph_t *m_glyphPool; - QFixedPoint *m_positionPool; + private: + QVector<QStaticTextItem> m_items; + QVector<QFixedPoint> m_positions; + QVector<glyph_t> m_glyphs; + QVector<QChar> m_chars; bool m_dirtyPen; + bool m_useBackendOptimizations; }; class DrawTextItemDevice: public QPaintDevice { public: - DrawTextItemDevice(int expectedItemCount = -1, QStaticTextItem *items = 0, - int expectedGlyphCount = -1, QFixedPoint *positionPool = 0, - glyph_t *glyphPool = 0) + DrawTextItemDevice(bool useBackendOptimizations, int numChars) { - m_paintEngine = new DrawTextItemRecorder(expectedItemCount, items, - expectedGlyphCount, positionPool, glyphPool); + m_paintEngine = new DrawTextItemRecorder(useBackendOptimizations, numChars); } ~DrawTextItemDevice() @@ -538,14 +537,24 @@ namespace { return m_paintEngine; } - int itemCount() const + QVector<glyph_t> glyphs() const { - return m_paintEngine->itemCount(); + return m_paintEngine->glyphs(); } - int glyphCount() const + QVector<QFixedPoint> positions() const { - return m_paintEngine->glyphCount(); + return m_paintEngine->positions(); + } + + QVector<QStaticTextItem> items() const + { + return m_paintEngine->items(); + } + + QVector<QChar> chars() const + { + return m_paintEngine->chars(); } private: @@ -616,42 +625,42 @@ void QStaticTextPrivate::init() delete[] items; delete[] glyphPool; delete[] positionPool; + delete[] charPool; position = QPointF(0, 0); - // Draw once to count number of items and glyphs, so that we can use as little memory - // as possible to store the data - DrawTextItemDevice counterDevice; + DrawTextItemDevice device(useBackendOptimizations, text.size()); { - QPainter painter(&counterDevice); + QPainter painter(&device); painter.setFont(font); painter.setTransform(matrix); paintText(QPointF(0, 0), &painter); - } - itemCount = counterDevice.itemCount(); + QVector<QStaticTextItem> deviceItems = device.items(); + QVector<QFixedPoint> positions = device.positions(); + QVector<glyph_t> glyphs = device.glyphs(); + QVector<QChar> chars = device.chars(); + + itemCount = deviceItems.size(); items = new QStaticTextItem[itemCount]; - if (useBackendOptimizations) { - for (int i=0; i<itemCount; ++i) - items[i].useBackendOptimizations = true; - } + glyphPool = new glyph_t[glyphs.size()]; + qMemCopy(glyphPool, glyphs.constData(), glyphs.size() * sizeof(glyph_t)); + positionPool = new QFixedPoint[positions.size()]; + qMemCopy(positionPool, positions.constData(), positions.size() * sizeof(QFixedPoint)); - int glyphCount = counterDevice.glyphCount(); - glyphPool = new glyph_t[glyphCount]; - positionPool = new QFixedPoint[glyphCount]; + charPool = new QChar[chars.size()]; + qMemCopy(charPool, chars.constData(), chars.size() * sizeof(QChar)); - // Draw again to actually record the items and glyphs - DrawTextItemDevice recorderDevice(itemCount, items, glyphCount, positionPool, glyphPool); - { - QPainter painter(&recorderDevice); - painter.setFont(font); - painter.setTransform(matrix); + for (int i=0; i<itemCount; ++i) { + items[i] = deviceItems.at(i); - paintText(QPointF(0, 0), &painter); + items[i].glyphs = glyphPool + items[i].glyphOffset; + items[i].glyphPositions = positionPool + items[i].positionOffset; + items[i].chars = charPool + items[i].charOffset; } needsRelayout = false; diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index f017ed1..2ab5579 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -88,9 +88,18 @@ public: userData = newUserData; } - QFixedPoint *glyphPositions; // 8 bytes per glyph - glyph_t *glyphs; // 4 bytes per glyph - const QChar *chars; // 2 bytes per glyph + union { + QFixedPoint *glyphPositions; // 8 bytes per glyph + int positionOffset; + }; + union { + glyph_t *glyphs; // 4 bytes per glyph + int glyphOffset; + }; + union { + QChar *chars; // 2 bytes per glyph + int charOffset; + }; // ================= // 14 bytes per glyph @@ -134,14 +143,16 @@ public: QTransform matrix; // 80 bytes per text QStaticTextItem *items; // 4 bytes per text int itemCount; // 4 bytes per text + glyph_t *glyphPool; // 4 bytes per text QFixedPoint *positionPool; // 4 bytes per text + QChar *charPool; // 4 bytes per text unsigned char needsRelayout : 1; unsigned char useBackendOptimizations : 1; // 1 byte per text unsigned char textFormat : 2; // ================ - // 163 bytes per text + // 167 bytes per text static QStaticTextPrivate *get(const QStaticText *q); }; |