tery with different size policies

svn path=/trunk/KDE/kdelibs/; revision=1112902
This commit is contained in:
Marco Martin 2010-04-09 13:05:48 +00:00
parent ea1e8d4b93
commit 3b3c111e48
3 changed files with 6 additions and 7 deletions

View File

@ -103,6 +103,7 @@ Extender::Extender(Applet *applet)
delete applet->d->extender.data(); delete applet->d->extender.data();
} }
applet->d->extender = this; applet->d->extender = this;
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
d->layout = new QGraphicsLinearLayout(this); d->layout = new QGraphicsLinearLayout(this);

View File

@ -56,7 +56,8 @@ ExtenderGroup::ExtenderGroup(Extender *parent, uint groupId)
d->childsWidget->installEventFilter(this); d->childsWidget->installEventFilter(this);
d->scrollWidget->setWidget(d->childsWidget); d->scrollWidget->setWidget(d->childsWidget);
d->layout = new QGraphicsLinearLayout(Qt::Vertical, d->childsWidget); d->layout = new QGraphicsLinearLayout(Qt::Vertical, d->childsWidget);
d->scrollWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); d->childsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
d->scrollWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
QAction *expand = new QAction(this); QAction *expand = new QAction(this);
expand->setVisible(true); expand->setVisible(true);
@ -175,10 +176,6 @@ void ExtenderGroup::expandGroup()
} }
d->scrollWidget->show(); d->scrollWidget->show();
static_cast<QGraphicsLinearLayout *>(layout())->addItem(d->scrollWidget); static_cast<QGraphicsLinearLayout *>(layout())->addItem(d->scrollWidget);
//resize to the bax between our hint and extender one
//TODO: do this on every childswidget resize?
extender()->resize(extender()->effectiveSizeHint(Qt::PreferredSize).expandedTo(effectiveSizeHint(Qt::PreferredSize)));
} }
void ExtenderGroup::collapseGroup() void ExtenderGroup::collapseGroup()
@ -202,7 +199,6 @@ void ExtenderGroup::collapseGroup()
} }
d->scrollWidget->hide(); d->scrollWidget->hide();
static_cast<QGraphicsLinearLayout *>(layout())->removeItem(d->scrollWidget); static_cast<QGraphicsLinearLayout *>(layout())->removeItem(d->scrollWidget);
extender()->resize(extender()->effectiveSizeHint(Qt::MinimumSize));
} }
void ExtenderGroup::resizeEvent(QGraphicsSceneResizeEvent *event) void ExtenderGroup::resizeEvent(QGraphicsSceneResizeEvent *event)
@ -237,6 +233,7 @@ void ExtenderGroupPrivate::addItemToGroup(Plasma::ExtenderItem *item)
{ {
if (item->group() == q) { if (item->group() == q) {
item->setParentItem(childsWidget); item->setParentItem(childsWidget);
item->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
layout->addItem(item); layout->addItem(item);
layout->activate(); layout->activate();
@ -261,6 +258,7 @@ void ExtenderGroupPrivate::removeItemFromGroup(Plasma::ExtenderItem *item)
childsWidget->resize(childsWidget->size().width(), childsWidget->resize(childsWidget->size().width(),
childsWidget->effectiveSizeHint(Qt::PreferredSize).height()); childsWidget->effectiveSizeHint(Qt::PreferredSize).height());
layout->removeItem(item); layout->removeItem(item);
item->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
} }
} }

View File

@ -114,7 +114,7 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId)
d(new ExtenderItemPrivate(this, hostExtender)) d(new ExtenderItemPrivate(this, hostExtender))
{ {
Q_ASSERT(hostExtender); Q_ASSERT(hostExtender);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
//set the extenderId //set the extenderId
if (extenderItemId) { if (extenderItemId) {