From a897301131c59233c872627907925efac8a27c7b Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 12 Mar 2010 13:05:42 +0100 Subject: --warn; --- src/declarative/qml/qdeclarativelist.h | 10 +++++----- src/declarative/util/qdeclarativetimeline_p_p.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h index 8d59384..ed402a8 100644 --- a/src/declarative/qml/qdeclarativelist.h +++ b/src/declarative/qml/qdeclarativelist.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QObject; -class QMetaObject; +struct QMetaObject; template struct QDeclarativeListProperty { typedef void (*AppendFunction)(QDeclarativeListProperty *, T*); @@ -61,12 +61,12 @@ struct QDeclarativeListProperty { typedef T *(*AtFunction)(QDeclarativeListProperty *, int); typedef void (*ClearFunction)(QDeclarativeListProperty *); - QDeclarativeListProperty() + QDeclarativeListProperty() : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} QDeclarativeListProperty(QObject *o, QList &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), clear(qlist_clear), dummy1(0), dummy2(0) {} - QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, + QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, ClearFunction r = 0) : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} @@ -81,7 +81,7 @@ struct QDeclarativeListProperty { QObject *object; void *data; - + AppendFunction append; CountFunction count; @@ -94,7 +94,7 @@ struct QDeclarativeListProperty { private: static void qlist_append(QDeclarativeListProperty *p, T *v) { - ((QList *)p->data)->append(v); + ((QList *)p->data)->append(v); } static int qlist_count(QDeclarativeListProperty *p) { return ((QList *)p->data)->count(); diff --git a/src/declarative/util/qdeclarativetimeline_p_p.h b/src/declarative/util/qdeclarativetimeline_p_p.h index c08c07c..598c897 100644 --- a/src/declarative/util/qdeclarativetimeline_p_p.h +++ b/src/declarative/util/qdeclarativetimeline_p_p.h @@ -160,7 +160,7 @@ public: QDeclarativeTimeLineObject *callbackObject() const; private: - friend class QDeclarativeTimeLinePrivate; + friend struct QDeclarativeTimeLinePrivate; Callback d0; void *d1; QDeclarativeTimeLineObject *d2; -- cgit v0.12 From 981515b84df18d3f4bde5a8de33ea6a3a9614073 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 15 Mar 2010 07:22:45 +0100 Subject: Get debug code compiling since function signature changes --- src/gui/painting/qtextureglyphcache.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index cf3957b..edbf580 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -73,7 +73,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const const QFixedPoint *) { #ifdef CACHE_DEBUG - printf("Populating with '%s'\n", QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data()); + printf("Populating with %d glyphs\n", numGlyphs); qDebug() << " -> current transformation: " << m_transform; #endif @@ -93,17 +93,14 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const glyph_metrics_t metrics = fontEngine->boundingBox(glyph, m_transform); #ifdef CACHE_DEBUG - printf("'%c' (%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f, ti.ascent=%.2f, ti.descent=%.2f\n", - ti.chars[i].toLatin1(), + printf("(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n", glyph, metrics.width.toReal(), metrics.height.toReal(), metrics.xoff.toReal(), metrics.yoff.toReal(), metrics.x.toReal(), - metrics.y.toReal(), - ti.ascent.toReal(), - ti.descent.toReal()); + metrics.y.toReal()); #endif int glyph_width = metrics.width.ceil().toInt(); int glyph_height = metrics.height.ceil().toInt(); @@ -333,10 +330,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g) QPoint base(c.x + glyphMargin(), c.y + glyphMargin() + c.baseLineY-1); if (m_image.rect().contains(base)) m_image.setPixel(base, 255); - m_image.save(QString::fromLatin1("cache-%1-%2-%3.png") - .arg(m_current_textitem->font().family()) - .arg(m_current_textitem->font().pointSize()) - .arg(m_transform.type())); + m_image.save(QString::fromLatin1("cache-%1.png").arg(int(this))); #endif } -- cgit v0.12 From ee3841ae90156f991717376f34921de97e47097c Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 15 Mar 2010 07:30:58 +0100 Subject: Fixed wasted space in the texture cache. We were using the height of the texture to position the next row, rather than just adding the rowHeight. This used to work when the texture cached grew by rowHeight, now it grows to next power of two... Reviewed-by: Eskil --- src/gui/painting/qtextureglyphcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index edbf580..4ca0c3a 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -136,7 +136,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const if (m_cx + c.w > m_w) { // no room on the current line, start new glyph strip m_cx = 0; - m_cy = m_h; + m_cy += rowHeight; } if (m_cy + c.h > m_h) { int new_height = m_h*2; -- cgit v0.12 From dd5d297d2969795a47ef7a5234b64a791e080c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 20 Apr 2010 14:01:06 +0200 Subject: Made sure that QTabWidget reported a big enough size hint. This avoids some minor clipping issues observed (see autotest). Reviewed-by: MortenS --- src/gui/styles/qmacstyle_mac.mm | 51 ++++++++++++++++++++++++++++++++ src/gui/widgets/qtabwidget.cpp | 8 ++--- tests/auto/qtabwidget/tst_qtabwidget.cpp | 24 +++++++++++++++ 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 116b03e..fe87b80 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -5614,6 +5614,57 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, // hack to work around horrible sizeHint() code in QAbstractSpinBox sz.setHeight(sz.height() - 3); break; + case QStyle::CT_TabWidget: + // the size between the pane and the "contentsRect" (+4,+4) + // (the "contentsRect" is on the inside of the pane) + sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget); + /** + This is supposed to show the relationship between the tabBar and + the stack widget of a QTabWidget. + Unfortunately ascii is not a good way of representing graphics..... + PS: The '=' line is the painted frame. + + top ---+ + | + | + | + | vvv just outside the painted frame is the "pane" + - -|- - - - - - - - - - <-+ + TAB BAR +=====^============ | +2 pixels + - - -|- - -|- - - - - - - <-+ + | | ^ ^^^ just inside the painted frame is the "contentsRect" + | | | + | overlap | + | | | + bottom ------+ <-+ +14 pixels + | + v + ------------------------------ <- top of stack widget + + + To summarize: + * 2 is the distance between the pane and the contentsRect + * The 14 and the 1's are the distance from the contentsRect to the stack widget. + (same value as used in SE_TabWidgetTabContents) + * overlap is how much the pane should overlap the tab bar + */ + // then add the size between the stackwidget and the "contentsRect" + + if (const QStyleOptionTabWidgetFrame *twf + = qstyleoption_cast(opt)) { + QSize extra(0,0); + const int overlap = pixelMetric(PM_TabBarBaseOverlap, opt, widget); + const int gapBetweenTabbarAndStackWidget = 2 + 14 - overlap; + + if (getTabDirection(twf->shape) == kThemeTabNorth || getTabDirection(twf->shape) == kThemeTabSouth) { + extra = QSize(2, gapBetweenTabbarAndStackWidget + 1); + } else { + extra = QSize(gapBetweenTabbarAndStackWidget + 1, 2); + } + sz+= extra; + } + + break; case QStyle::CT_TabBarTab: if (const QStyleOptionTabV3 *tab = qstyleoption_cast(opt)) { const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget); diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 047a905..583c112 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -814,8 +814,8 @@ QSize QTabWidget::sizeHint() const { Q_D(const QTabWidget); QSize lc(0, 0), rc(0, 0); - QStyleOption opt(0); - opt.init(this); + QStyleOptionTabWidgetFrameV2 opt; + initStyleOption(&opt); opt.state = QStyle::State_None; if (d->leftCornerWidget) @@ -863,8 +863,8 @@ QSize QTabWidget::minimumSizeHint() const QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t); - QStyleOption opt(0); - opt.rect = rect(); + QStyleOptionTabWidgetFrameV2 opt; + initStyleOption(&opt); opt.palette = palette(); opt.state = QStyle::State_None; return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp index 4491fb3..6d5a873 100644 --- a/tests/auto/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp @@ -45,6 +45,7 @@ #include #include #include +#include //TESTED_CLASS= //TESTED_FILES= @@ -120,6 +121,7 @@ class tst_QTabWidget:public QObject { void clear(); void keyboardNavigation(); void paintEventCount(); + void minimumSizeHint(); private: int addPage(); @@ -621,6 +623,28 @@ void tst_QTabWidget::paintEventCount() QCOMPARE(tab2->count, 1); } +void tst_QTabWidget::minimumSizeHint() +{ + QTabWidget tw; + QWidget *page = new QWidget; + QVBoxLayout *lay = new QVBoxLayout; + + QLabel *label = new QLabel(QLatin1String("XXgypq lorem ipsum must be long, must be long. lorem ipsumMMMW")); + lay->addWidget(label); + + page->setLayout(lay); + + tw.addTab(page, QLatin1String("page1")); + + tw.show(); + QTest::qWaitForWindowShown(&tw); + tw.resize(tw.minimumSizeHint()); + + QSize minSize = label->minimumSizeHint(); + QSize actSize = label->geometry().size(); + QVERIFY(minSize.width() <= actSize.width()); + QVERIFY(minSize.height() <= actSize.height()); +} QTEST_MAIN(tst_QTabWidget) #include "tst_qtabwidget.moc" -- cgit v0.12 From eb7fad0afd164bb9b56ed47990eaa66cad0c2641 Mon Sep 17 00:00:00 2001 From: Markus Hossner Date: Wed, 21 Apr 2010 10:56:22 +0200 Subject: QAbstractGraphicsShapeItem: ignore already set pen or brush MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If setPen() or setBrush() of a QAbstractGraphicsShapeItem is called with a pen or brush equal to its current pen or brush prepareGeometryChange() and update() shouldn't be called. Testing for identical pen and brush is cheap in comparison with a QGraphicsView update() without seeing a change Merge-request: 562 Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 5735cd6..c19c052 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7694,6 +7694,8 @@ QPen QAbstractGraphicsShapeItem::pen() const void QAbstractGraphicsShapeItem::setPen(const QPen &pen) { Q_D(QAbstractGraphicsShapeItem); + if (d->pen == pen) + return; prepareGeometryChange(); d->pen = pen; d->boundingRect = QRectF(); @@ -7724,6 +7726,8 @@ QBrush QAbstractGraphicsShapeItem::brush() const void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush) { Q_D(QAbstractGraphicsShapeItem); + if (d->brush == brush) + return; d->brush = brush; update(); } @@ -8854,6 +8858,8 @@ QPen QGraphicsLineItem::pen() const void QGraphicsLineItem::setPen(const QPen &pen) { Q_D(QGraphicsLineItem); + if (d->pen == pen) + return; prepareGeometryChange(); d->pen = pen; update(); -- cgit v0.12