remove createLayout from Containment. now each containment will need to implement its own layouting. this is not so big a deal since FreeLayout is no longer needed to make applets behave properly. now panels can do whatever the heck they want.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=802255
This commit is contained in:
Aaron J. Seigo 2008-04-28 23:00:08 +00:00
parent fa166c72ef
commit 69524609a3
2 changed files with 12 additions and 82 deletions

View File

@ -355,8 +355,6 @@ void Containment::setFormFactor(FormFactor formFactor)
//kDebug() << "switching FF to " << formFactor;
FormFactor was = d->formFactor;
createLayout(formFactor);
d->formFactor = formFactor;
if (isContainment() && containmentType() == PanelContainment && was != formFactor) {
@ -364,73 +362,9 @@ void Containment::setFormFactor(FormFactor formFactor)
d->positionPanel(true);
}
QGraphicsLayout *lay = layout();
QGraphicsLinearLayout * linearLay = dynamic_cast<QGraphicsLinearLayout *>(lay);
if (linearLay) {
foreach (Applet* applet, d->applets) {
applet->updateConstraints(Plasma::FormFactorConstraint);
}
}
updateConstraints(Plasma::FormFactorConstraint);
}
void Containment::createLayout(FormFactor formFactor)
{
//note: setting a new layout autodeletes the old one
//and creating a layout calls setLayout on the parent
switch (formFactor) {
case Planar:
case MediaCenter:
//setLayout(new QGraphicsLinearLayout());
break;
case Horizontal: {
if
(!layout())
{
QGraphicsLinearLayout *lay = new QGraphicsLinearLayout();
lay->setOrientation(Qt::Horizontal);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(4);
lay->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
setLayout(lay);
}
else
{
QGraphicsLayout *lay = layout();
QGraphicsLinearLayout * linearLay = dynamic_cast<QGraphicsLinearLayout *>(lay);
if (linearLay) {
linearLay->setOrientation(Qt::Horizontal);
}
}
break;
}
case Vertical: {
if
(!layout())
{
QGraphicsLinearLayout *lay = new QGraphicsLinearLayout();
lay->setOrientation(Qt::Vertical);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(4);
setLayout(lay);
}
else
{
QGraphicsLayout *lay = layout();
QGraphicsLinearLayout * linearLay = dynamic_cast<QGraphicsLinearLayout *>(lay);
if (linearLay) {
linearLay->setOrientation(Qt::Vertical);
}
}
break;
}
default:
kDebug() << "This can't be happening! Or... can it? ;)" << d->formFactor;
//setLayout(0); //auto-delete
break;
}
}
FormFactor Containment::formFactor() const
{
if (isContainment()) {
@ -1001,12 +935,18 @@ void Containment::Private::containmentConstraintsEvent(Plasma::Constraints const
toolBox->enableTool("addwidgets", q->immutability() == NotImmutable);
}
if (constraints & Plasma::FormFactorConstraint && toolBox) {
if (q->formFactor() == Vertical) {
toolBox->setOrientation(Qt::Vertical);
//defaults to horizontal
} else {
toolBox->setOrientation(Qt::Horizontal);
if (constraints & Plasma::FormFactorConstraint) {
if (toolBox) {
if (q->formFactor() == Vertical) {
toolBox->setOrientation(Qt::Vertical);
//defaults to horizontal
} else {
toolBox->setOrientation(Qt::Horizontal);
}
}
foreach (Applet *applet, applets) {
applet->updateConstraints(Plasma::FormFactorConstraint);
}
}

View File

@ -344,16 +344,6 @@ class PLASMA_EXPORT Containment : public Applet
*/
void setContainmentType(Containment::Type type);
/**
* Optionally creates a layout for the Containment for the new
* form factor. This is called before the current form factor is
* reset, and adding applets to the new layout, if any, is handled
* automatically.
*
* @param formFactor the new FormFacto
*/
virtual void createLayout(FormFactor formFactor);
void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);