Remove Applet::Private::isContainment
Instead determine by introspecting if this inherits from Containment REVIEW: 114405
This commit is contained in:
parent
1f83fdcc3c
commit
ef58fdbf6f
@ -221,7 +221,7 @@ KConfigGroup Applet::config() const
|
||||
return KConfigGroup(KSharedConfig::openConfig(), "PlasmaTransientsConfig");
|
||||
}
|
||||
|
||||
if (d->isContainment) {
|
||||
if (isContainment()) {
|
||||
return *(d->mainConfigGroup());
|
||||
}
|
||||
|
||||
@ -349,10 +349,12 @@ Types::Types::ImmutabilityType Applet::immutability() const
|
||||
|
||||
//Returning the more strict immutability between the applet immutability, Containment and Corona
|
||||
Types::ImmutabilityType upperImmutability = Types::Mutable;
|
||||
Containment *cont = d->isContainment ? 0 : containment();
|
||||
|
||||
if (cont) {
|
||||
upperImmutability = cont->immutability();
|
||||
if (!isContainment()) {
|
||||
const Containment *cont = containment();
|
||||
if (cont) {
|
||||
upperImmutability = cont->immutability();
|
||||
}
|
||||
}
|
||||
|
||||
if (upperImmutability != Types::Mutable) {
|
||||
@ -496,7 +498,7 @@ void Applet::flushPendingConstraintsEvents()
|
||||
|
||||
// now take care of constraints in special subclass: Contaiment
|
||||
Containment* containment = qobject_cast<Plasma::Containment*>(this);
|
||||
if (d->isContainment && containment) {
|
||||
if (containment) {
|
||||
containment->d->containmentConstraintsEvent(c);
|
||||
}
|
||||
|
||||
@ -542,19 +544,16 @@ Types::FormFactor Applet::formFactor() const
|
||||
|
||||
Containment *Applet::containment() const
|
||||
{
|
||||
if (d->isContainment) {
|
||||
Containment *c = qobject_cast<Containment*>(const_cast<Applet*>(this));
|
||||
if (c) {
|
||||
return c;
|
||||
}
|
||||
Containment *c = qobject_cast<Containment*>(const_cast<Applet*>(this));
|
||||
if (c) {
|
||||
return c;
|
||||
}
|
||||
|
||||
QObject *parent = this->parent();
|
||||
Containment *c = 0;
|
||||
|
||||
while (parent) {
|
||||
Containment *possibleC = dynamic_cast<Containment*>(parent);
|
||||
if (possibleC && possibleC->Applet::d->isContainment) {
|
||||
Containment *possibleC = qobject_cast<Containment*>(parent);
|
||||
if (possibleC) {
|
||||
c = possibleC;
|
||||
break;
|
||||
}
|
||||
@ -567,7 +566,7 @@ Containment *Applet::containment() const
|
||||
QObject *objParent = this->parent();
|
||||
while (objParent) {
|
||||
Containment *possibleC = qobject_cast<Containment*>(objParent);
|
||||
if (possibleC && possibleC->Applet::d->isContainment) {
|
||||
if (possibleC) {
|
||||
c = possibleC;
|
||||
break;
|
||||
}
|
||||
@ -737,7 +736,7 @@ void Applet::timerEvent(QTimerEvent *event)
|
||||
|
||||
bool Applet::isContainment() const
|
||||
{
|
||||
return d->isContainment;
|
||||
return qobject_cast<const Containment*>(this);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
@ -90,18 +90,12 @@ Containment::Containment(const QString &packagePath, uint appletId)
|
||||
|
||||
Containment::~Containment()
|
||||
{
|
||||
// Applet touches our dptr if we are a containment and is the superclass (think of dtors)
|
||||
// so we reset this as we exit the building
|
||||
Applet::d->isContainment = false;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void Containment::init()
|
||||
{
|
||||
Applet::init();
|
||||
if (!isContainment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (d->type == Types::NoContainmentType) {
|
||||
//setContainmentType(Plasma::Types::DesktopContainment);
|
||||
@ -172,11 +166,6 @@ void Containment::restore(KConfigGroup &group)
|
||||
// qDebug() << " screen:" << group.readEntry("screen", d->screen);
|
||||
#endif
|
||||
*/
|
||||
if (!isContainment()) {
|
||||
Applet::restore(group);
|
||||
return;
|
||||
}
|
||||
|
||||
setLocation((Plasma::Types::Location)group.readEntry("location", (int)d->location));
|
||||
setFormFactor((Plasma::Types::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
|
||||
d->lastScreen = group.readEntry("lastScreen", d->lastScreen);
|
||||
@ -241,10 +230,6 @@ void Containment::save(KConfigGroup &g) const
|
||||
// locking is saved in Applet::save
|
||||
Applet::save(group);
|
||||
|
||||
if (!isContainment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
group.writeEntry("screen", d->screen);
|
||||
group.writeEntry("lastScreen", d->lastScreen);
|
||||
group.writeEntry("formfactor", (int)d->formFactor);
|
||||
@ -357,7 +342,7 @@ Applet *Containment::createApplet(const QString &name, const QVariantList &args)
|
||||
|
||||
void Containment::addApplet(Applet *applet)
|
||||
{
|
||||
if (!isContainment() || immutability() != Types::Mutable) {
|
||||
if (immutability() != Types::Mutable) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -448,8 +448,6 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi
|
||||
conf.deleteGroup();
|
||||
}
|
||||
|
||||
applet->d->isContainment = true;
|
||||
applet->d->setIsContainment(true, true);
|
||||
containments.append(containment);
|
||||
|
||||
QObject::connect(containment, SIGNAL(destroyed(QObject*)),
|
||||
|
@ -61,7 +61,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
|
||||
itemStatus(Types::UnknownStatus),
|
||||
modificationsTimer(0),
|
||||
hasConfigurationInterface(false),
|
||||
isContainment(false),
|
||||
failed(false),
|
||||
transient(false),
|
||||
needsConfig(false),
|
||||
@ -166,7 +165,7 @@ void AppletPrivate::cleanUpAndDelete()
|
||||
|
||||
resetConfigurationObject();
|
||||
|
||||
if (isContainment) {
|
||||
if (q->isContainment()) {
|
||||
// prematurely emit our destruction if we are a Containment,
|
||||
// giving Corona a chance to remove this Containment from its collection
|
||||
emit q->QObject::destroyed(q);
|
||||
@ -234,7 +233,7 @@ void AppletPrivate::requestConfiguration()
|
||||
|
||||
void AppletPrivate::updateShortcuts()
|
||||
{
|
||||
if (isContainment) {
|
||||
if (q->isContainment()) {
|
||||
//a horrible hack to avoid clobbering corona settings
|
||||
//we pull them out, then read, then put them back
|
||||
QList<QString> names;
|
||||
@ -261,13 +260,10 @@ void AppletPrivate::updateShortcuts()
|
||||
|
||||
void AppletPrivate::propagateConfigChanged()
|
||||
{
|
||||
if (isContainment) {
|
||||
Containment *c = qobject_cast<Containment *>(q);
|
||||
if (c) {
|
||||
c->d->configChanged();
|
||||
}
|
||||
Containment *c = qobject_cast<Containment *>(q);
|
||||
if (c) {
|
||||
c->d->configChanged();
|
||||
}
|
||||
|
||||
q->configChanged();
|
||||
}
|
||||
|
||||
@ -296,21 +292,6 @@ void AppletPrivate::setUiReady()
|
||||
uiReady = true;
|
||||
}
|
||||
|
||||
void AppletPrivate::setIsContainment(bool nowIsContainment, bool forceUpdate)
|
||||
{
|
||||
if (isContainment == nowIsContainment && !forceUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
isContainment = nowIsContainment;
|
||||
//FIXME I do not like this function.
|
||||
//currently it's only called before ctmt/applet init, with (true,true), and I'm going to assume it stays that way.
|
||||
//if someone calls it at some other time it'll cause headaches. :P
|
||||
|
||||
delete mainConfig;
|
||||
mainConfig = 0;
|
||||
}
|
||||
|
||||
// put all setup routines for script here. at this point we can assume that
|
||||
// package exists and that we have a script engine
|
||||
void AppletPrivate::setupPackage()
|
||||
@ -378,7 +359,7 @@ KConfigGroup *AppletPrivate::mainConfigGroup()
|
||||
return mainConfig;
|
||||
}
|
||||
|
||||
if (isContainment) {
|
||||
if (q->isContainment()) {
|
||||
Corona *corona = static_cast<Containment*>(q)->corona();
|
||||
KConfigGroup containmentConfig;
|
||||
//qDebug() << "got a corona, baby?" << (QObject*)corona << (QObject*)q;
|
||||
|
@ -56,11 +56,6 @@ public:
|
||||
// package exists and that we have a script engin
|
||||
void setupPackage();
|
||||
|
||||
/**
|
||||
* Sets whether or not this Applet is acting as a Containment
|
||||
*/
|
||||
void setIsContainment(bool isContainment, bool forceUpdate = false);
|
||||
|
||||
QString globalName() const;
|
||||
void scheduleConstraintsUpdate(Plasma::Types::Constraints c);
|
||||
void scheduleModificationNotification();
|
||||
@ -110,7 +105,6 @@ public:
|
||||
|
||||
// a great green field of booleans :)
|
||||
bool hasConfigurationInterface : 1;
|
||||
bool isContainment : 1;
|
||||
bool failed : 1;
|
||||
bool transient : 1;
|
||||
bool needsConfig : 1;
|
||||
|
Loading…
Reference in New Issue
Block a user