diff --git a/containment.cpp b/containment.cpp index 320fc407a..294d2675f 100644 --- a/containment.cpp +++ b/containment.cpp @@ -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(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(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(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); } } diff --git a/containment.h b/containment.h index b4b5b78f2..7cde9b792 100644 --- a/containment.h +++ b/containment.h @@ -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);