allow swapping of arbitrary containments, not just this view's containment

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=872751
This commit is contained in:
Aaron J. Seigo 2008-10-18 01:29:42 +00:00
parent 2f501ace5e
commit 333b91acfb
2 changed files with 26 additions and 3 deletions

View File

@ -253,7 +253,16 @@ Containment *View::containment() const
Containment *View::swapContainment(const QString &name, const QVariantList &args) Containment *View::swapContainment(const QString &name, const QVariantList &args)
{ {
Containment *old = d->containment; return swapContainment(d->containment, name, args);
}
Containment *View::swapContainment(Plasma::Containment *existing, const QString &name, const QVariantList &args)
{
if (!existing) {
return 0;
}
Containment *old = existing;
Plasma::Corona *corona = old->corona(); Plasma::Corona *corona = old->corona();
Plasma::Containment *c = corona->addContainment(name, args); Plasma::Containment *c = corona->addContainment(name, args);
if (c) { if (c) {
@ -263,8 +272,10 @@ Containment *View::swapContainment(const QString &name, const QVariantList &args
// ensure that the old containments configuration is up to date // ensure that the old containments configuration is up to date
old->save(oldConfig); old->save(oldConfig);
if (old == d->containment) {
// set our containment to the new one // set our containment to the new one
setContainment(c); setContainment(c);
}
// Copy configuration to new containment // Copy configuration to new containment
oldConfig.copyTo(&newConfig); oldConfig.copyTo(&newConfig);
@ -286,6 +297,7 @@ Containment *View::swapContainment(const QString &name, const QVariantList &args
return c; return c;
} }
return old; return old;
} }

11
view.h
View File

@ -121,6 +121,17 @@ public:
*/ */
Containment *containment() const; Containment *containment() const;
/**
* Swaps one containment with another.
*
* @param existing the existing containment to swap out
* @param name the plugin name for the new containment.
* @param args argument list to pass to the containment
*/
Containment *swapContainment(Plasma::Containment *existing,
const QString &name,
const QVariantList &args = QVariantList());
/** /**
* Swap the containment for this view, which will also cause the view * Swap the containment for this view, which will also cause the view
* to track the geometry of the containment. * to track the geometry of the containment.