From 97d24ee90e59f7f33c28f6442e63d5f27fb7cca2 Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 8 May 2009 11:51:34 +0200 Subject: Improved scrolling performance with invisible blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Thorbjørn --- src/gui/widgets/qplaintextedit.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 14efd23..f317742 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -560,7 +560,8 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const { if (!currentBlock.isValid()) return QRectF(); Q_ASSERT(currentBlock.blockNumber() == currentBlockNumber); - QPlainTextDocumentLayout *documentLayout = qobject_cast(document()->documentLayout()); + QTextDocument *doc = document(); + QPlainTextDocumentLayout *documentLayout = qobject_cast(doc->documentLayout()); Q_ASSERT(documentLayout); QPointF offset; @@ -571,13 +572,22 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const { offset.ry() += r.height(); currentBlock = currentBlock.next(); ++currentBlockNumber; + if (!currentBlock.isVisible()) { + currentBlock = doc->findBlockByLineNumber(currentBlock.firstLineNumber()); + currentBlockNumber = currentBlock.blockNumber(); + } r = documentLayout->blockBoundingRect(currentBlock); } while (currentBlockNumber > blockNumber && offset.y() >= -textEdit->viewport()->height()) { currentBlock = currentBlock.previous(); + --currentBlockNumber; + while (!currentBlock.isVisible()) { + currentBlock = currentBlock.previous(); + --currentBlockNumber; + } if (!currentBlock.isValid()) break; - --currentBlockNumber; + r = documentLayout->blockBoundingRect(currentBlock); offset.ry() -= r.height(); } -- cgit v0.12 From 330bebda90472f12dcbfde5a04600f4f6e97326d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 6 May 2009 13:04:14 +0200 Subject: Fix leak of global data Static variable was dynamically allocated but never freed. Task-number: 253013 Reviewed-by: Thiago --- src/corelib/tools/qlocale.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 559ba81..a2154a9 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -5367,6 +5367,14 @@ static Bigint *mult(Bigint *a, Bigint *b) static Bigint *p5s; +struct p5s_deleter +{ + ~p5s_deleter() + { + Bfree(p5s); + } +}; + static Bigint *pow5mult(Bigint *b, int k) { Bigint *b1, *p5, *p51; @@ -5388,6 +5396,7 @@ static Bigint *pow5mult(Bigint *b, int k) return b; if (!(p5 = p5s)) { /* first time */ + static p5s_deleter deleter; p5 = p5s = i2b(625); p5->next = 0; } -- cgit v0.12 From 4c7004122a858cd6d891efc7923ba11484fbf997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 6 May 2009 17:47:28 +0200 Subject: Fixed leak of plugin instances It seems that plugins were never explicitly unloaded, resulting in leaks of the instance object. Added a static deleter to ensure deletion on exit. The QPointer (previously in place) ensures we don't do a double-free nor try to access an invalid pointer. Task-number: 253013 Reviewed-by: mariusSO --- src/corelib/plugin/qplugin.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index 4d0e53c..121a875 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -63,6 +63,21 @@ typedef QObject *(*QtPluginInstanceFunction)(); void Q_CORE_EXPORT qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunction function); +struct qt_plugin_instance_deleter +{ + qt_plugin_instance_deleter(QPointer &instance) + : instance_(instance) + { + } + + ~qt_plugin_instance_deleter() + { + delete instance_; + } + + QPointer &instance_; +}; + #define Q_IMPORT_PLUGIN(PLUGIN) \ extern QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance_##PLUGIN(); \ class Static##PLUGIN##PluginInstance{ \ @@ -76,8 +91,10 @@ void Q_CORE_EXPORT qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunctio #define Q_PLUGIN_INSTANCE(IMPLEMENTATION) \ { \ static QT_PREPEND_NAMESPACE(QPointer) _instance; \ - if (!_instance) \ + if (!_instance) { \ + static QT_PREPEND_NAMESPACE(qt_plugin_instance_deleter) deleter(_instance); \ _instance = new IMPLEMENTATION; \ + } \ return _instance; \ } -- cgit v0.12 From da1234d6ea6c5e3c0b84d64fbe9ac15a7c3f30d3 Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 8 May 2009 13:35:58 +0200 Subject: Extend QTextDocument test This new test tests desired undo merging behaviour after insertions. --- tests/auto/qtextdocument/tst_qtextdocument.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 4ef5299..63a172b 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -161,6 +161,8 @@ private slots: void testUndoCommandAdded(); + void testUndoBlocks(); + private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); @@ -2435,5 +2437,21 @@ void tst_QTextDocument::testUndoCommandAdded() QCOMPARE(spy.count(), 1); } +void tst_QTextDocument::testUndoBlocks() +{ + QVERIFY(doc); + cursor.insertText("Hello World"); + cursor.insertText("period"); + doc->undo(); + QCOMPARE(doc->toPlainText(), QString("")); + cursor.insertText("Hello World"); + cursor.insertText("One\nTwo\nThree"); + QCOMPARE(doc->toPlainText(), QString("Hello WorldOne\nTwo\nThree")); + doc->undo(); + QCOMPARE(doc->toPlainText(), QString("Hello World")); + doc->undo(); + QCOMPARE(doc->toPlainText(), QString("")); +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" -- cgit v0.12 From 4af30f47c37fd0e6826aca2984dd0f567dc7e465 Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 8 May 2009 16:39:42 +0200 Subject: Fixed unwanted merging of undo commands from different edit blocks With this patch, commands no longer merge across block bounderies. In order to have merging still work for the normal insertion and deletion case, the unnecessary beginEditBlock()/endEditBlock() calls where cleaned up. Reviewed-by: Simon Hausmann --- src/gui/text/qtextcursor.cpp | 25 +++++++++++++++++++------ src/gui/text/qtextdocument_p.cpp | 39 ++++++++++++++++++++++++++------------- src/gui/text/qtextdocument_p.h | 3 ++- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 48963bb..d12e3fe 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -145,7 +145,6 @@ void QTextCursorPrivate::remove() { if (anchor == position) return; - priv->beginEditBlock(); currentCharFormat = -1; int pos1 = position; int pos2 = adjusted_anchor; @@ -159,15 +158,18 @@ void QTextCursorPrivate::remove() // deleting inside table? -> delete only content QTextTable *table = complexSelectionTable(); if (table) { + priv->beginEditBlock(); int startRow, startCol, numRows, numCols; selectedTableCells(&startRow, &numRows, &startCol, &numCols); clearCells(table, startRow, startCol, numRows, numCols, op); + adjusted_anchor = anchor = position; + priv->endEditBlock(); } else { priv->remove(pos1, pos2-pos1, op); + adjusted_anchor = anchor = position; + priv->finishEdit(); } - adjusted_anchor = anchor = position; - priv->endEditBlock(); } void QTextCursorPrivate::clearCells(QTextTable *table, int startRow, int startCol, int numRows, int numCols, QTextUndoCommand::Operation op) @@ -1291,9 +1293,14 @@ void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format QTextCharFormat format = _format; format.clearProperty(QTextFormat::ObjectIndex); - d->priv->beginEditBlock(); + bool hasEditBlock = false; + + if (d->anchor != d->position) { + hasEditBlock = true; + d->priv->beginEditBlock(); + d->remove(); + } - d->remove(); if (!text.isEmpty()) { QTextFormatCollection *formats = d->priv->formatCollection(); int formatIdx = formats->indexForFormat(format); @@ -1323,6 +1330,11 @@ void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format || ch == QChar::ParagraphSeparator || ch == QLatin1Char('\r')) { + if (!hasEditBlock) { + hasEditBlock = true; + d->priv->beginEditBlock(); + } + if (blockEnd > blockStart) d->priv->insert(d->position, textStart + blockStart, blockEnd - blockStart, formatIdx); @@ -1333,7 +1345,8 @@ void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format if (textStart + blockStart < textEnd) d->priv->insert(d->position, textStart + blockStart, textEnd - textStart - blockStart, formatIdx); } - d->priv->endEditBlock(); + if (hasEditBlock) + d->priv->endEditBlock(); d->setX(); } diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 05ddf47..e1da4be 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -404,7 +404,7 @@ int QTextDocumentPrivate::insertBlock(const QChar &blockSeparator, int b = blocks.findNode(pos); QTextBlockData *B = blocks.fragment(b); - QTextUndoCommand c = { QTextUndoCommand::BlockInserted, true, + QTextUndoCommand c = { QTextUndoCommand::BlockInserted, editBlock != 0, op, charFormat, strPos, pos, { blockFormat }, B->revision }; @@ -439,20 +439,19 @@ void QTextDocumentPrivate::insert(int pos, int strPos, int strLength, int format Q_ASSERT(pos >= 0 && pos < fragments.length()); Q_ASSERT(formats.format(format).isCharFormat()); - beginEditBlock(); insert_string(pos, strPos, strLength, format, QTextUndoCommand::MoveCursor); if (undoEnabled) { int b = blocks.findNode(pos); QTextBlockData *B = blocks.fragment(b); - QTextUndoCommand c = { QTextUndoCommand::Inserted, true, + QTextUndoCommand c = { QTextUndoCommand::Inserted, editBlock != 0, QTextUndoCommand::MoveCursor, format, strPos, pos, { strLength }, B->revision }; appendUndoItem(c); B->revision = undoState; Q_ASSERT(undoState == undoStack.size()); } - endEditBlock(); + finishEdit(); } void QTextDocumentPrivate::insert(int pos, const QString &str, int format) @@ -584,8 +583,6 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O Q_ASSERT(startAndEndInSameFrame || endIsEndOfChildFrame || startIsStartOfFrameAndEndIsEndOfFrameWithCommonParent || isFirstTableCell); #endif - beginEditBlock(); - split(pos); split(pos+length); @@ -605,10 +602,10 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O int blockRevision = B->revision; QTextFragmentData *X = fragments.fragment(x); - QTextUndoCommand c = { QTextUndoCommand::Removed, true, + QTextUndoCommand c = { QTextUndoCommand::Removed, editBlock != 0, op, X->format, X->stringPosition, key, { X->size_array[0] }, blockRevision }; - QTextUndoCommand cInsert = { QTextUndoCommand::Inserted, true, + QTextUndoCommand cInsert = { QTextUndoCommand::Inserted, editBlock != 0, op, X->format, X->stringPosition, dstKey, { X->size_array[0] }, blockRevision }; @@ -648,7 +645,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O Q_ASSERT(blocks.length() == fragments.length()); - endEditBlock(); + finishEdit(); } void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operation op) @@ -1004,8 +1001,12 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) if (!undoStack.isEmpty() && modified) { QTextUndoCommand &last = undoStack[undoState - 1]; - if (last.tryMerge(c)) - return; + if ( (last.block && c.block) // part of the same block => can merge + || (!c.block && !last.block // two single undo items => can merge + && (undoState < 2 || !undoStack[undoState-2].block))) { + if (last.tryMerge(c)) + return; + } } if (modifiedState > undoState) modifiedState = -1; @@ -1013,6 +1014,9 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) undoState++; emitUndoAvailable(true); emitRedoAvailable(false); + + if (!c.block) + emit document()->undoCommandAdded(); } void QTextDocumentPrivate::truncateUndoStack() @@ -1082,7 +1086,6 @@ void QTextDocumentPrivate::joinPreviousEditBlock() void QTextDocumentPrivate::endEditBlock() { - Q_Q(QTextDocument); if (--editBlock) return; @@ -1093,6 +1096,16 @@ void QTextDocumentPrivate::endEditBlock() emit document()->undoCommandAdded(); } + finishEdit(); +} + +void QTextDocumentPrivate::finishEdit() +{ + Q_Q(QTextDocument); + + if (editBlock) + return; + if (framesDirty) scan_frames(docChangeFrom, docChangeOldLength, docChangeLength); @@ -1279,7 +1292,7 @@ void QTextDocumentPrivate::changeObjectFormat(QTextObject *obj, int format) if (f) documentChange(f->firstPosition(), f->lastPosition() - f->firstPosition()); - QTextUndoCommand c = { QTextUndoCommand::GroupFormatChange, true, QTextUndoCommand::MoveCursor, oldFormatIndex, + QTextUndoCommand c = { QTextUndoCommand::GroupFormatChange, editBlock != 0, QTextUndoCommand::MoveCursor, oldFormatIndex, 0, 0, { obj->d_func()->objectIndex }, 0 }; appendUndoItem(c); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index 25763e1..d754ff0 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -139,7 +139,7 @@ public: MoveCursor = 1 }; quint16 command; - quint8 block; ///< All undo commands that have this set to zero/false are combined with the preceding command on undo/redo. + quint8 block; ///< All undo commands that have this set to true are combined with the preceding command on undo/redo. quint8 operation; int format; quint32 strPos; @@ -202,6 +202,7 @@ public: inline void beginEditBlock() { editBlock++; } void joinPreviousEditBlock(); void endEditBlock(); + void finishEdit(); inline bool isInEditBlock() const { return editBlock; } void enableUndoRedo(bool enable); inline bool isUndoRedoEnabled() const { return undoEnabled; } -- cgit v0.12 From 6fdff777765c93996b7de9fc36c0de7ff4928102 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Fri, 8 May 2009 16:46:41 +0200 Subject: Stop a crash in QMenuBar on Designer after my changes. In the past, we checked on the existence of the pointer, but now that this is controlled by the property, we need to also check the pointer in the action event. --- src/gui/widgets/qmenubar.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index d4de5bd..d2e6bfb 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1273,6 +1273,8 @@ void QMenuBar::actionEvent(QActionEvent *e) #else QMenuBarPrivate::QWceMenuBarPrivate *nativeMenuBar = d->wce_menubar; #endif + if (!nativeMenuBar) + return; if(e->type() == QEvent::ActionAdded) nativeMenuBar->addAction(e->action(), nativeMenuBar->findAction(e->before())); else if(e->type() == QEvent::ActionRemoved) -- cgit v0.12 From f0243e70e05a3368582fd0478d840096d6b60c3f Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 8 May 2009 14:55:01 +0200 Subject: QToolBarLayout and QDockWidgetLayout, which are private classes, are no more exported designer was using QToolBarLayout members. We fixed that by using styles. Reviewed-by: Friedemann Kleint Reviewed-by: ogoffart --- src/gui/styles/qcommonstyle.cpp | 19 +++++++++++++++++++ src/gui/styles/qstyle.cpp | 2 ++ src/gui/styles/qstyle.h | 2 ++ src/gui/widgets/qdockwidget_p.h | 2 +- src/gui/widgets/qtoolbar.cpp | 12 ++++++++---- src/gui/widgets/qtoolbarlayout.cpp | 19 +------------------ src/gui/widgets/qtoolbarlayout_p.h | 4 +--- tools/designer/src/lib/shared/qdesigner_toolbar.cpp | 12 ++++++++---- 8 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 1d12bed..c0899f8 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -3187,6 +3187,25 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, } break; #endif //QT_NO_ITEMVIEWS +#ifndef QT_NO_TOOLBAR + case SE_ToolBarHandle: + if (const QStyleOptionToolBar *tbopt = qstyleoption_cast(opt)) { + if (tbopt->features & QStyleOptionToolBar::Movable) { + ///we need to access the widget here because the style option doesn't + //have all the information we need (ie. the layout's margin) + const QToolBar *tb = qobject_cast(widget); + const int margin = tb && tb->layout() ? tb->layout()->margin() : 2; + const int handleExtent = pixelMetric(QStyle::PM_ToolBarExtensionExtent, opt, tb); + if (tbopt->state & QStyle::State_Horizontal) { + r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin); + r = QStyle::visualRect(tbopt->direction, tbopt->rect, r); + } else { + r = QRect(margin, margin, tbopt->rect.width() - 2*margin, handleExtent); + } + } + } + break; +#endif //QT_NO_TOOLBAR default: break; } diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index 982f48f..b73332f 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -1048,6 +1048,8 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SE_TabBarTabRightButton Area for a widget on the right side of a tab in a tab bar. \value SE_TabBarTabText Area for the text on a tab in a tab bar. + \value SE_ToolBarHandle Area for the handle of a tool bar. + \sa subElementRect() */ diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h index c1cbbdd..cc92459 100644 --- a/src/gui/styles/qstyle.h +++ b/src/gui/styles/qstyle.h @@ -373,6 +373,8 @@ public: SE_ShapedFrameContents, + SE_ToolBarHandle, + // do not add any values below/greater than this SE_CustomBase = 0xf0000000 }; diff --git a/src/gui/widgets/qdockwidget_p.h b/src/gui/widgets/qdockwidget_p.h index 0bc619c..31b530f 100644 --- a/src/gui/widgets/qdockwidget_p.h +++ b/src/gui/widgets/qdockwidget_p.h @@ -128,7 +128,7 @@ public: bool isAnimating() const; }; -class Q_GUI_EXPORT QDockWidgetLayout : public QLayout +class QDockWidgetLayout : public QLayout { Q_OBJECT public: diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index fadccbc..d765794 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -274,9 +274,11 @@ void QToolBarPrivate::endDrag() bool QToolBarPrivate::mousePressEvent(QMouseEvent *event) { - if (layout->handleRect().contains(event->pos()) == false) { + Q_Q(QToolBar); + QStyleOptionToolBar opt; + q->initStyleOption(&opt); + if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) { #ifdef Q_WS_MAC - Q_Q(QToolBar); // When using the unified toolbar on Mac OS X the user can can click and // drag between toolbar contents to move the window. Make this work by // implementing the standard mouse-dragging code and then call @@ -1041,7 +1043,7 @@ void QToolBar::paintEvent(QPaintEvent *) style->drawControl(QStyle::CE_ToolBar, &opt, &p, this); } - opt.rect = d->layout->handleRect(); + opt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &opt, this); if (opt.rect.isValid()) style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this); } @@ -1142,7 +1144,9 @@ bool QToolBar::event(QEvent *event) case QEvent::HoverMove: { #ifndef QT_NO_CURSOR QHoverEvent *e = static_cast(event); - if (d->layout->handleRect().contains(e->pos())) + QStyleOptionToolBar opt; + initStyleOption(&opt); + if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos())) setCursor(Qt::SizeAllCursor); else unsetCursor(); diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp index 7771f46..0bfa493 100644 --- a/src/gui/widgets/qtoolbarlayout.cpp +++ b/src/gui/widgets/qtoolbarlayout.cpp @@ -334,7 +334,7 @@ void QToolBarLayout::updateGeomArray() const if (QMainWindow *mw = qobject_cast(parentWidget()->parentWidget())) { if (mw->unifiedTitleAndToolBarOnMac() && mw->toolBarArea(static_cast(parentWidget())) == Qt::TopToolBarArea) { - if (that->expandFlag) { + if (expandFlag) { tb->setMaximumSize(0xFFFFFF, 0xFFFFFF); } else { tb->setMaximumSize(hint); @@ -360,23 +360,11 @@ void QToolBarLayout::setGeometry(const QRect &rect) QStyle *style = tb->style(); QStyleOptionToolBar opt; tb->initStyleOption(&opt); - const int handleExtent = movable() - ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0; const int margin = this->margin(); const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); Qt::Orientation o = tb->orientation(); QLayout::setGeometry(rect); - if (movable()) { - if (o == Qt::Horizontal) { - handRect = QRect(margin, margin, handleExtent, rect.height() - 2*margin); - handRect = QStyle::visualRect(parentWidget()->layoutDirection(), rect, handRect); - } else { - handRect = QRect(margin, margin, rect.width() - 2*margin, handleExtent); - } - } else { - handRect = QRect(); - } bool ranOutOfSpace = false; if (!animating) @@ -742,11 +730,6 @@ QToolBarItem *QToolBarLayout::createItem(QAction *action) return result; } -QRect QToolBarLayout::handleRect() const -{ - return handRect; -} - QT_END_NAMESPACE #endif // QT_NO_TOOLBAR diff --git a/src/gui/widgets/qtoolbarlayout_p.h b/src/gui/widgets/qtoolbarlayout_p.h index 2eca773..27164b3 100644 --- a/src/gui/widgets/qtoolbarlayout_p.h +++ b/src/gui/widgets/qtoolbarlayout_p.h @@ -75,7 +75,7 @@ public: bool customWidget; }; -class Q_GUI_EXPORT QToolBarLayout : public QLayout +class QToolBarLayout : public QLayout { Q_OBJECT @@ -100,8 +100,6 @@ public: int indexOf(QAction *action) const; int indexOf(QWidget *widget) const { return QLayout::indexOf(widget); } - QRect handleRect() const; - bool layoutActions(const QSize &size); QSize expandedSize(const QSize &size) const; bool expanded, animating; diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp index 1c465da..012b498 100644 --- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -61,7 +61,6 @@ #include #include #include -#include #include Q_DECLARE_METATYPE(QAction*) @@ -443,9 +442,14 @@ QAction *ToolBarEventFilter::actionAt(const QToolBar *tb, const QPoint &pos) QRect ToolBarEventFilter::handleArea(const QToolBar *tb) { - const QToolBarLayout *tbl = qobject_cast(tb->layout()); - Q_ASSERT(tbl); - return tbl->handleRect(); + //that's a trick to get acces to the initStyleOption which is a protected member + class ToolBar : public QToolBar + { + friend class ToolBarEventFilter; + }; + QStyleOptionToolBar opt; + static_cast(tb)->initStyleOption(&opt); + return tb->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, tb); } bool ToolBarEventFilter::withinHandleArea(const QToolBar *tb, const QPoint &pos) -- cgit v0.12 From abe987689028e244f463e4d0d5b0b294deb9c824 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 8 May 2009 16:48:25 +0200 Subject: Do not export inline private classes in qcssparser_p.h Reviewed-by: ogoffart --- src/gui/text/qcssparser_p.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 97a0aef..4b07442 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -495,7 +495,7 @@ const quint64 PseudoClass_Alternate = Q_UINT64_C(0x0000100000000000); const quint64 PseudoClass_Any = Q_UINT64_C(0x0000ffffffffffff); const int NumPseudos = 46; -struct Q_GUI_EXPORT Pseudo +struct Pseudo { Pseudo() : negated(false) { } quint64 type; @@ -504,7 +504,7 @@ struct Q_GUI_EXPORT Pseudo bool negated; }; -struct Q_GUI_EXPORT AttributeSelector +struct AttributeSelector { enum ValueMatchType { NoMatch, @@ -519,7 +519,7 @@ struct Q_GUI_EXPORT AttributeSelector ValueMatchType valueMatchCriterium; }; -struct Q_GUI_EXPORT BasicSelector +struct BasicSelector { inline BasicSelector() : relationToNext(NoRelation) {} @@ -586,7 +586,7 @@ private: QPalette pal; }; -struct Q_GUI_EXPORT StyleRule +struct StyleRule { StyleRule() : order(0) { } QVector selectors; @@ -594,19 +594,19 @@ struct Q_GUI_EXPORT StyleRule int order; }; -struct Q_GUI_EXPORT MediaRule +struct MediaRule { QStringList media; QVector styleRules; }; -struct Q_GUI_EXPORT PageRule +struct PageRule { QString selector; QVector declarations; }; -struct Q_GUI_EXPORT ImportRule +struct ImportRule { QString href; QStringList media; -- cgit v0.12 From 7ec33b89beaad84893b8c79f1a1b81a9cd63887f Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 8 May 2009 17:37:42 +0200 Subject: removing additional unused export to classes only used in QtGui Reviewed-by: ogoffart --- src/gui/text/qcssparser_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 4b07442..fbd6c16 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -403,7 +403,7 @@ struct BorderData { // 4. QVector - { prop1: value1; prop2: value2; } // 5. Declaration - prop1: value1; -struct Q_GUI_EXPORT Declaration +struct Declaration { struct DeclarationData : public QSharedData { @@ -539,7 +539,7 @@ struct BasicSelector Relation relationToNext; }; -struct Q_GUI_EXPORT Selector +struct Selector { QVector basicSelectors; int specificity() const; @@ -552,7 +552,7 @@ struct MediaRule; struct PageRule; struct ImportRule; -struct Q_GUI_EXPORT ValueExtractor +struct ValueExtractor { ValueExtractor(const QVector &declarations, const QPalette & = QPalette()); @@ -620,7 +620,7 @@ enum StyleSheetOrigin { StyleSheetOrigin_Inline }; -struct Q_GUI_EXPORT StyleSheet +struct StyleSheet { StyleSheet() : origin(StyleSheetOrigin_Unspecified), depth(0) { } QVector styleRules; //only contains rules that are not indexed -- cgit v0.12 From e8c6f81979d129bdf5251a0520c39b846f47d850 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 8 May 2009 17:54:00 +0200 Subject: removed more exports on private classes (QMouseEventEx and QKeyEventEx) --- src/gui/kernel/qevent_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index cc94aad..8e762d6 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE // // ### Qt 5: remove -class Q_GUI_EXPORT QKeyEventEx : public QKeyEvent +class QKeyEventEx : public QKeyEvent { public: QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers, @@ -76,7 +76,7 @@ protected: }; // ### Qt 5: remove -class Q_GUI_EXPORT QMouseEventEx : public QMouseEvent +class QMouseEventEx : public QMouseEvent { public: QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos, -- cgit v0.12 From b7f84c44ae723a77ed34246949e49438491f54e9 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Mon, 11 May 2009 07:59:45 +0200 Subject: fix build on windows - partly revert f0243e70e05a3368582fd0478d840096d6b60c3f as it broke the build due to widgets accessible plugins using QDockWidgetLayout Reviewed-by: Rhys Weatherley --- src/gui/widgets/qdockwidget_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qdockwidget_p.h b/src/gui/widgets/qdockwidget_p.h index 31b530f..0bc619c 100644 --- a/src/gui/widgets/qdockwidget_p.h +++ b/src/gui/widgets/qdockwidget_p.h @@ -128,7 +128,7 @@ public: bool isAnimating() const; }; -class QDockWidgetLayout : public QLayout +class Q_GUI_EXPORT QDockWidgetLayout : public QLayout { Q_OBJECT public: -- cgit v0.12