actually pass around what constraints are being updated. this allows preventing of unecessary processing (for one) and also can avoid recursion where someone calls a constraints setter from inside constraintsUpdated.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=719831
This commit is contained in:
Aaron J. Seigo 2007-10-01 23:24:38 +00:00
parent 0f7e4e52ab
commit b51cc728fd
4 changed files with 31 additions and 9 deletions

View File

@ -474,15 +474,15 @@ const Package* Applet::package() const
return d->package;
}
void Applet::updateConstraints()
void Applet::updateConstraints(Plasma::Constraints constraints)
{
constraintsUpdated();
constraintsUpdated(constraints);
setShadowShown(formFactor() == Planar);
}
void Applet::constraintsUpdated()
void Applet::constraintsUpdated(Plasma::Constraints constraints)
{
kDebug() << "Applet::constraintsUpdate(): constraints are FormFactor: " << formFactor() << ", Location: " << location();
kDebug() << constraints << "constraints are FormFactor: " << formFactor() << ", Location: " << location();
}
QString Applet::name() const

View File

@ -182,8 +182,10 @@ class PLASMA_EXPORT Applet : public Widget
* Called when any of the geometry constraints have been updated.
* This method calls constraintsUpdated, which may be reimplemented,
* once the Applet has been prepared for updating the constraints.
*
* @param constraints the type of constraints that were updated
*/
void updateConstraints();
void updateConstraints(Plasma::Constraints constraints);
/**
* Called when any of the geometry constraints have been updated.
@ -194,9 +196,10 @@ class PLASMA_EXPORT Applet : public Widget
* Do not call update() from this method; an update() will be triggered
* at the appropriate time for the applet.
*
* @param constraints the type of constraints that were updated
* @property constraint
*/
virtual void constraintsUpdated();
virtual void constraintsUpdated(Plasma::Constraints constraints);
/**
* Returns the current form factor the applet is being displayed in.

View File

@ -427,8 +427,10 @@ void Containment::setFormFactor(FormFactor formFactor)
foreach (Applet* applet, d->applets) {
d->layout->addItem(applet);
applet->updateConstraints();
applet->updateConstraints(Plasma::FormFactorConstraint);
}
updateConstraints(Plasma::FormFactorConstraint);
}
FormFactor Containment::formFactor() const
@ -445,8 +447,10 @@ void Containment::setLocation(Location location)
d->location = location;
foreach (Applet* applet, d->applets) {
applet->updateConstraints();
applet->updateConstraints(Plasma::LocationConstraint);
}
updateConstraints(Plasma::LocationConstraint);
}
Location Containment::location() const
@ -493,7 +497,7 @@ Applet* Containment::addApplet(const QString& name, const QVariantList& args, ui
d->layout->addItem(applet);
}
applet->updateConstraints();
applet->updateConstraints(Plasma::AllConstraints);
kDebug() << applet->name() << "sizehint:" << applet->sizeHint()
<< "geometry:" << applet->geometry();
@ -555,6 +559,7 @@ void Containment::setScreen(int screen)
}
d->screen = screen;
updateConstraints(Plasma::ScreenConstraint);
}
int Containment::screen() const

View File

@ -30,6 +30,18 @@
namespace Plasma
{
/**
* The Constriants enumeration lists the various constraints that Plasma
* objects have managed for them and which they may wish to react to,
* for instance in Applet::constraintsUpdated
*/
enum Constraint { FormFactorConstraint = 1 /** The FormFactor for an object */,
LocationConstraint = 2 /** The Location of an object */,
ScreenConstraint = 4 /** Which screen an object is on */,
AllConstraints = FormFactorConstraint | LocationConstraint | ScreenConstraint
};
Q_DECLARE_FLAGS(Constraints, Constraint)
/**
* The FormFactor enumeration describes how a Plasma::Applet should arrange
* itself. The value is derived from the container managing the Applet
@ -125,4 +137,6 @@ PLASMA_EXPORT Direction locationToDirection(Location location);
} // Plasma namespace
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints)
#endif // multiple inclusion guard