resize to the proper sizes when expanding/collapsing the groups

svn path=/trunk/KDE/kdelibs/; revision=1186426
This commit is contained in:
Marco Martin 2010-10-16 11:08:25 +00:00
parent f49d3bc29b
commit 616a10059d
2 changed files with 21 additions and 7 deletions

View File

@ -512,6 +512,8 @@ void Extender::itemAddedEvent(ExtenderItem *item, const QPointF &pos)
//remove the empty extender message if needed. //remove the empty extender message if needed.
d->updateEmptyExtenderLabel(); d->updateEmptyExtenderLabel();
d->updateBorders(); d->updateBorders();
resize(d->mainWidget->effectiveSizeHint(Qt::PreferredSize));
} }
void Extender::itemRemovedEvent(ExtenderItem *item) void Extender::itemRemovedEvent(ExtenderItem *item)
@ -528,12 +530,18 @@ void Extender::itemRemovedEvent(ExtenderItem *item)
d->spacerWidget = 0; 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()));
//add the empty extender message if needed. //add the empty extender message if needed.
d->updateEmptyExtenderLabel(); d->updateEmptyExtenderLabel();
d->updateBorders(); d->updateBorders();
updateGeometry(); updateGeometry();
resize(effectiveSizeHint(Qt::PreferredSize));
resize(d->mainWidget->effectiveSizeHint(Qt::PreferredSize));
} }
void Extender::itemHoverEnterEvent(ExtenderItem *item) void Extender::itemHoverEnterEvent(ExtenderItem *item)

View File

@ -167,16 +167,19 @@ void ExtenderGroup::expandGroup()
config().writeEntry("groupCollapsed", d->collapsed); config().writeEntry("groupCollapsed", d->collapsed);
action("collapse")->setVisible(true); action("collapse")->setVisible(true);
action("expand")->setVisible(false); action("expand")->setVisible(false);
d->childsWidget->show();
static_cast<QGraphicsLinearLayout *>(layout())->addItem(d->childsWidget);
updateGeometry();
foreach (ExtenderItem *item, extender()->attachedItems()) { foreach (ExtenderItem *item, extender()->attachedItems()) {
if (item->group() == this) { if (item->group() == this) {
item->show(); item->show();
extender()->itemAddedEvent(item); extender()->itemAddedEvent(item);
} }
} }
d->childsWidget->show();
static_cast<QGraphicsLinearLayout *>(layout())->addItem(d->childsWidget); //extender()->resize(extender()->effectiveSizeHint(Qt::PreferredSize));
updateGeometry();
extender()->resize(extender()->effectiveSizeHint(Qt::PreferredSize));
} }
void ExtenderGroup::collapseGroup() void ExtenderGroup::collapseGroup()
@ -192,14 +195,17 @@ void ExtenderGroup::collapseGroup()
config().writeEntry("groupCollapsed", d->collapsed); config().writeEntry("groupCollapsed", d->collapsed);
action("collapse")->setVisible(false); action("collapse")->setVisible(false);
action("expand")->setVisible(true); action("expand")->setVisible(true);
d->childsWidget->hide();
static_cast<QGraphicsLinearLayout *>(layout())->removeItem(d->childsWidget);
updateGeometry();
foreach (ExtenderItem *item, extender()->attachedItems()) { foreach (ExtenderItem *item, extender()->attachedItems()) {
if (item != this && item->group() == this) { if (item != this && item->group() == this) {
item->hide(); item->hide();
extender()->itemRemovedEvent(item); extender()->itemRemovedEvent(item);
} }
} }
d->childsWidget->hide();
static_cast<QGraphicsLinearLayout *>(layout())->removeItem(d->childsWidget);
} }
void ExtenderGroup::resizeEvent(QGraphicsSceneResizeEvent *event) void ExtenderGroup::resizeEvent(QGraphicsSceneResizeEvent *event)