with some intriguing grotesqueness internal to the library, we can simplify the API and remove location/formFactor from Containment and just use the ones in Applet; externally this is probably rather safer

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=802277
This commit is contained in:
Aaron J. Seigo 2008-04-29 00:49:10 +00:00
parent b94c6913ff
commit 2dd5891029
3 changed files with 11 additions and 45 deletions

View File

@ -326,7 +326,8 @@ public:
void checkImmutability()
{
const bool systemImmutable = q->globalConfig().isImmutable() || q->config().isImmutable() ||
(q->containment() && q->containment()->immutability() == SystemImmutable) ||
((!isContainment && q->containment()) &&
q->containment()->immutability() == SystemImmutable) ||
(dynamic_cast<Corona*>(q->scene()) && static_cast<Corona*>(q->scene())->immutability() == SystemImmutable);
if (systemImmutable) {
@ -549,7 +550,7 @@ KConfigGroup Applet::config() const
KConfigGroup Applet::globalConfig() const
{
KConfigGroup globalAppletConfig;
const Containment *c = isContainment() ? dynamic_cast<const Containment*>(this) : containment();
const Containment *c = containment();
QString group = isContainment() ? "ContainmentGlobals" : "AppletGlobals";
if (c && c->corona()) {
@ -1046,24 +1047,23 @@ void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *o
FormFactor Applet::formFactor() const
{
Containment* c = containment();
return c ? c->formFactor() : Plasma::Planar;
return c ? c->d->formFactor : Plasma::Planar;
}
Containment* Applet::containment() const
{
/*
* while this is probably "more correct", much of the code in applet assumes containment
* returns zero in the case that this is a containment itself.
* if (isContainment()) {
return dynamic_cast<Containment*>(const_cast<Applet*>(this));
if (isContainment()) {
Containment *c = dynamic_cast<Containment*>(const_cast<Applet*>(this));
if (c) {
return c;
}
}
*/
QGraphicsItem *parent = parentItem();
Containment *c = 0;
while (parent) {
Containment *possibleC = dynamic_cast<Containment*>(parent);
Containment *possibleC = dynamic_cast<Containment*>(parent);
if (possibleC && possibleC->isContainment()) {
c = possibleC;
break;
@ -1077,12 +1077,7 @@ Containment* Applet::containment() const
Location Applet::location() const
{
Containment* c = containment();
if (!c) {
return Plasma::Desktop;
}
return c->location();
return c ? c->d->location : Plasma::Desktop;
}
Qt::AspectRatioMode Applet::aspectRatioMode() const

View File

@ -365,15 +365,6 @@ void Containment::setFormFactor(FormFactor formFactor)
updateConstraints(Plasma::FormFactorConstraint);
}
FormFactor Containment::formFactor() const
{
if (isContainment()) {
return d->formFactor;
}
return Applet::formFactor();
}
void Containment::setLocation(Location location)
{
if (d->location == location) {
@ -407,11 +398,6 @@ void Containment::setLocation(Location location)
updateConstraints(Plasma::LocationConstraint);
}
Location Containment::location() const
{
return d->location;
}
void Containment::addSiblingContainment()
{
emit addSiblingContainment(this);

View File

@ -129,21 +129,6 @@ class PLASMA_EXPORT Containment : public Applet
*/
Corona* corona() const;
/**
* Returns the current form factor the applets in this Containment
* are being displayed in.
*
* @see Plasma::FormFactor
*/
FormFactor formFactor() const;
/**
* Returns the location of this Containment
*
* @see Plasma::Location
*/
Location location() const;
/**
* Returns a list of all known containments.
*