From kde-commits Tue Feb 24 23:47:23 2009 From: =?utf-8?q?Fredrik=20H=C3=B6glund?= Date: Tue, 24 Feb 2009 23:47:23 +0000 To: kde-commits Subject: branches/KDE/4.2/kdelibs/kio/kio Message-Id: <1235519243.903352.26023.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=123551925208585 SVN commit 931214 by fredrik: Make sure the active margins are initialized in all functions that need to do layout computations. M +8 -1 kfileitemdelegate.cpp --- branches/KDE/4.2/kdelibs/kio/kio/kfileitemdelegate.cpp #931213:931214 @@ -130,7 +130,7 @@ KFileItemDelegate::Private::Private(KFileItemDelegate *parent) : shadowColor(Qt::transparent), shadowOffset(1, 1), shadowBlur(2), maximumSize(0, 0), showToolTipWhenElided(true), q(parent), - animationHandler(new KIO::DelegateAnimationHandler(parent)) + animationHandler(new KIO::DelegateAnimationHandler(parent)), activeMargins(0) { } @@ -174,6 +174,7 @@ QRect KFileItemDelegate::Private::addMargin(const QRect &rect, MarginType type) const { + Q_ASSERT(activeMargins != 0); const Margin &m = activeMargins[type]; return rect.adjusted(-m.left, -m.top, m.right, m.bottom); } @@ -181,6 +182,7 @@ QRect KFileItemDelegate::Private::subtractMargin(const QRect &rect, MarginType type) const { + Q_ASSERT(activeMargins != 0); const Margin &m = activeMargins[type]; return rect.adjusted(m.left, m.top, -m.right, -m.bottom); } @@ -188,6 +190,7 @@ QSize KFileItemDelegate::Private::addMargin(const QSize &size, MarginType type) const { + Q_ASSERT(activeMargins != 0); const Margin &m = activeMargins[type]; return QSize(size.width() + m.left + m.right, size.height() + m.top + m.bottom); } @@ -195,6 +198,7 @@ QSize KFileItemDelegate::Private::subtractMargin(const QSize &size, MarginType type) const { + Q_ASSERT(activeMargins != 0); const Margin &m = activeMargins[type]; return QSize(size.width() - m.left - m.right, size.height() - m.top - m.bottom); } @@ -1315,6 +1319,7 @@ { QStyleOptionViewItemV4 opt(option); d->initStyleOption(&opt, index); + d->setActiveMargins(d->verticalLayout(opt) ? Qt::Vertical : Qt::Horizontal); QRect r = d->labelRectangle(opt); @@ -1360,6 +1365,7 @@ // show it only in the case the display information is elided QStyleOptionViewItemV4 opt(option); d->initStyleOption(&opt, index); + d->setActiveMargins(d->verticalLayout(opt) ? Qt::Vertical : Qt::Horizontal); QTextLayout labelLayout; QTextLayout infoLayout; @@ -1378,6 +1384,7 @@ { QStyleOptionViewItemV4 opt(option); d->initStyleOption(&opt, index); + d->setActiveMargins(d->verticalLayout(opt) ? Qt::Vertical : Qt::Horizontal); QTextLayout labelLayout; QTextLayout infoLayout;