From 333b91acfb7256a0198d47840a6ed6284ac73855 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Sat, 18 Oct 2008 01:29:42 +0000 Subject: [PATCH] allow swapping of arbitrary containments, not just this view's containment svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=872751 --- view.cpp | 18 +++++++++++++++--- view.h | 11 +++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/view.cpp b/view.cpp index 87dba539a..ea1ab0d16 100644 --- a/view.cpp +++ b/view.cpp @@ -253,7 +253,16 @@ Containment *View::containment() const 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::Containment *c = corona->addContainment(name, args); 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 old->save(oldConfig); - // set our containment to the new one - setContainment(c); + if (old == d->containment) { + // set our containment to the new one + setContainment(c); + } // Copy configuration to new containment oldConfig.copyTo(&newConfig); @@ -286,6 +297,7 @@ Containment *View::swapContainment(const QString &name, const QVariantList &args return c; } + return old; } diff --git a/view.h b/view.h index 91d64beb6..9f8dd6519 100644 --- a/view.h +++ b/view.h @@ -121,6 +121,17 @@ public: */ 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 * to track the geometry of the containment.