resize to the proper size when an item is collapsed/restored

svn path=/trunk/KDE/kdelibs/; revision=1186431
This commit is contained in:
Marco Martin 2010-10-16 11:35:16 +00:00
parent 616a10059d
commit 32e10a77d2
3 changed files with 20 additions and 9 deletions

View File

@ -504,10 +504,7 @@ void Extender::itemAddedEvent(ExtenderItem *item, const QPointF &pos)
}
}
//FIXME: hardcoded number for the scrollbar
d->scrollWidget->setMinimumWidth(d->mainWidget->effectiveSizeHint(Qt::MinimumSize).width() + 32);
//FIXME: hardcoded number
d->scrollWidget->setMinimumHeight(qMin((qreal)300, d->mainWidget->effectiveSizeHint(Qt::MinimumSize).height()));
d->adjustMinimumSize();
//remove the empty extender message if needed.
d->updateEmptyExtenderLabel();
@ -530,10 +527,7 @@ void Extender::itemRemovedEvent(ExtenderItem *item)
d->spacerWidget = 0;
}
//FIXME: hardcoded number for the scrollbar
d->scrollWidget->setMinimumWidth(d->mainWidget->effectiveSizeHint(Qt::MinimumSize).width() + 32);
//FIXME: hardcoded number
d->scrollWidget->setMinimumHeight(qMin((qreal)300, d->mainWidget->effectiveSizeHint(Qt::MinimumSize).height()));
d->adjustMinimumSize();
//add the empty extender message if needed.
d->updateEmptyExtenderLabel();
@ -835,6 +829,14 @@ void ExtenderPrivate::updateEmptyExtenderLabel()
}
}
void ExtenderPrivate::adjustMinimumSize()
{
//FIXME: hardcoded number for the scrollbar
scrollWidget->setMinimumWidth(mainWidget->effectiveSizeHint(Qt::MinimumSize).width() + 32);
//FIXME: hardcoded number
scrollWidget->setMinimumHeight(qMin((qreal)300, mainWidget->effectiveSizeHint(Qt::MinimumSize).height()));
}
ExtenderGroup *ExtenderPrivate::findGroup(const QString &name) const
{
foreach (ExtenderItem *item, attachedExtenderItems) {

View File

@ -600,8 +600,16 @@ void ExtenderItem::setCollapsed(bool collapsed)
d->layout->insertItem(1, d->widget.data());
}
updateGeometry();
if (extender()) {
extender()->resize(extender()->effectiveSizeHint(Qt::PreferredSize));
extender()->d->adjustMinimumSize();
static_cast<QGraphicsLayoutItem *>(extender()->d->mainWidget)->updateGeometry();
if (group()) {
group()->layout()->invalidate();
static_cast<QGraphicsLayoutItem *>(group())->updateGeometry();
}
extender()->resize(extender()->d->mainWidget->effectiveSizeHint(Qt::PreferredSize));
}
}
}

View File

@ -74,6 +74,7 @@ class ExtenderPrivate
void updateBorders();
void delayItemAddedEvent();
void updateEmptyExtenderLabel();
void adjustMinimumSize();
ExtenderGroup *findGroup(const QString &name) const;
Extender *q;