From 5bb4761c739bf8fd33e778a184d747fe4079cab3 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 19 Feb 2014 19:37:30 +0100 Subject: [PATCH] use a namespace in libplasmaquick right now only the library builds --- src/plasmaquick/appletquickitem.cpp | 5 +- src/plasmaquick/appletquickitem.h | 7 ++- src/plasmaquick/configmodel.cpp | 2 + src/plasmaquick/configmodel.h | 5 ++ src/plasmaquick/configview.cpp | 4 ++ src/plasmaquick/configview.h | 5 ++ src/plasmaquick/packageurlinterceptor.cpp | 5 +- src/plasmaquick/packageurlinterceptor.h | 4 ++ src/plasmaquick/plasmaquickview.cpp | 65 +++++++++++--------- src/plasmaquick/plasmaquickview.h | 20 +++--- src/plasmaquick/private/appletquickitem_p.h | 4 ++ src/plasmaquick/private/configcategory_p.cpp | 3 + src/plasmaquick/private/configcategory_p.h | 4 ++ 13 files changed, 93 insertions(+), 40 deletions(-) diff --git a/src/plasmaquick/appletquickitem.cpp b/src/plasmaquick/appletquickitem.cpp index 7966fcaca..a0dbf5ed2 100644 --- a/src/plasmaquick/appletquickitem.cpp +++ b/src/plasmaquick/appletquickitem.cpp @@ -38,6 +38,9 @@ #include +namespace PlasmaQuick +{ + QHash AppletQuickItemPrivate::s_rootObjects = QHash(); AppletQuickItemPrivate::AppletQuickItemPrivate(Plasma::Applet *a, AppletQuickItem *item) @@ -660,7 +663,7 @@ void AppletQuickItem::itemChange(ItemChange change, const ItemChangeData &value) QQuickItem::itemChange(change, value); } - +} #include "moc_appletquickitem.cpp" diff --git a/src/plasmaquick/appletquickitem.h b/src/plasmaquick/appletquickitem.h index 28bdab877..d0a1acaef 100644 --- a/src/plasmaquick/appletquickitem.h +++ b/src/plasmaquick/appletquickitem.h @@ -39,6 +39,8 @@ namespace KDeclarative { } +namespace PlasmaQuick { + class AppletQuickItemPrivate; class PLASMAQUICK_EXPORT AppletQuickItem : public QQuickItem @@ -146,6 +148,9 @@ private: Q_PRIVATE_SLOT(d, void fillHeightChanged()) }; -QML_DECLARE_TYPEINFO(AppletQuickItem, QML_HAS_ATTACHED_PROPERTIES) +} + +QML_DECLARE_TYPEINFO(PlasmaQuick::AppletQuickItem, QML_HAS_ATTACHED_PROPERTIES) + #endif diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp index f495556fd..26a8fba29 100644 --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -38,6 +38,7 @@ #include #include +namespace PlasmaQuick { //////////////////////////////ConfigModel @@ -242,5 +243,6 @@ QQmlListProperty ConfigModel::categories() } +} #include "moc_configmodel.cpp" diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h index c158c16de..e6b43704c 100644 --- a/src/plasmaquick/configmodel.h +++ b/src/plasmaquick/configmodel.h @@ -30,6 +30,9 @@ namespace Plasma { class Applet; } +namespace PlasmaQuick +{ + class ConfigPropertyMap; class ConfigCategoryPrivate; @@ -100,4 +103,6 @@ private: ConfigModelPrivate *const d; }; +} + #endif // multiple inclusion guard diff --git a/src/plasmaquick/configview.cpp b/src/plasmaquick/configview.cpp index 887a4d293..7d3efccba 100644 --- a/src/plasmaquick/configview.cpp +++ b/src/plasmaquick/configview.cpp @@ -39,6 +39,8 @@ #include +namespace PlasmaQuick +{ //////////////////////////////ConfigView @@ -156,4 +158,6 @@ void ConfigView::resizeEvent(QResizeEvent *re) QQuickWindow::resizeEvent(re); } +} + #include "moc_configview.cpp" diff --git a/src/plasmaquick/configview.h b/src/plasmaquick/configview.h index 307278752..c6b4d13ab 100644 --- a/src/plasmaquick/configview.h +++ b/src/plasmaquick/configview.h @@ -29,6 +29,9 @@ namespace Plasma { class Applet; } +namespace PlasmaQuick +{ + class ConfigViewPrivate; class ConfigModel; @@ -68,4 +71,6 @@ private: ConfigViewPrivate *const d; }; +} + #endif // multiple inclusion guard diff --git a/src/plasmaquick/packageurlinterceptor.cpp b/src/plasmaquick/packageurlinterceptor.cpp index 71699d7eb..71e7d6837 100644 --- a/src/plasmaquick/packageurlinterceptor.cpp +++ b/src/plasmaquick/packageurlinterceptor.cpp @@ -25,6 +25,9 @@ #include +namespace PlasmaQuick +{ + PackageUrlInterceptor::PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p) : QQmlAbstractUrlInterceptor(), m_package(p), @@ -138,6 +141,6 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept return QUrl(); } - +} diff --git a/src/plasmaquick/packageurlinterceptor.h b/src/plasmaquick/packageurlinterceptor.h index c722a4db3..b2c01edf5 100644 --- a/src/plasmaquick/packageurlinterceptor.h +++ b/src/plasmaquick/packageurlinterceptor.h @@ -28,6 +28,9 @@ class QQmlEngine; +namespace PlasmaQuick +{ + //depends from https://codereview.qt-project.org/#change,65626 class PLASMAQUICK_EXPORT PackageUrlInterceptor: public QQmlAbstractUrlInterceptor { @@ -76,5 +79,6 @@ private: QQmlEngine *m_engine; }; +} #endif diff --git a/src/plasmaquick/plasmaquickview.cpp b/src/plasmaquick/plasmaquickview.cpp index a7c480a49..550b1fe32 100644 --- a/src/plasmaquick/plasmaquickview.cpp +++ b/src/plasmaquick/plasmaquickview.cpp @@ -27,36 +27,39 @@ #include "plasma/pluginloader.h" -class PlasmaQuickViewPrivate +namespace PlasmaQuick +{ + +class ViewPrivate { public: - PlasmaQuickViewPrivate(Plasma::Corona *corona, PlasmaQuickView *view); - ~PlasmaQuickViewPrivate(); + ViewPrivate(Plasma::Corona *corona, View *view); + ~ViewPrivate(); void setContainment(Plasma::Containment *cont); Plasma::Types::FormFactor formFactor() const; Plasma::Types::Location location() const; void showConfigurationInterface(Plasma::Applet *applet); - PlasmaQuickView *q; - friend class PlasmaQuickView; + View *q; + friend class View; Plasma::Corona *corona; QWeakPointer containment; QWeakPointer configView; }; -PlasmaQuickViewPrivate::PlasmaQuickViewPrivate(Plasma::Corona *cor, PlasmaQuickView *view) +ViewPrivate::ViewPrivate(Plasma::Corona *cor, View *view) : q(view), corona(cor) { } -PlasmaQuickViewPrivate::~PlasmaQuickViewPrivate() +ViewPrivate::~ViewPrivate() { } -void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont) +void ViewPrivate::setContainment(Plasma::Containment *cont) { if (containment.data() == cont) { return; @@ -91,11 +94,11 @@ void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont) if (cont) { cont->reactToScreenChange(); QObject::connect(cont, &Plasma::Containment::locationChanged, - q, &PlasmaQuickView::locationChanged); + q, &View::locationChanged); QObject::connect(cont, &Plasma::Containment::formFactorChanged, - q, &PlasmaQuickView::formFactorChanged); + q, &View::formFactorChanged); QObject::connect(cont, &Plasma::Containment::configureRequested, - q, &PlasmaQuickView::showConfigurationInterface); + q, &View::showConfigurationInterface); } else { return; } @@ -120,7 +123,7 @@ void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont) } } -Plasma::Types::Location PlasmaQuickViewPrivate::location() const +Plasma::Types::Location ViewPrivate::location() const { if (!containment) { return Plasma::Types::Desktop; @@ -128,7 +131,7 @@ Plasma::Types::Location PlasmaQuickViewPrivate::location() const return containment.data()->location(); } -Plasma::Types::FormFactor PlasmaQuickViewPrivate::formFactor() const +Plasma::Types::FormFactor ViewPrivate::formFactor() const { if (!containment) { return Plasma::Types::Planar; @@ -136,7 +139,7 @@ Plasma::Types::FormFactor PlasmaQuickViewPrivate::formFactor() const return containment.data()->formFactor(); } -void PlasmaQuickViewPrivate::showConfigurationInterface(Plasma::Applet *applet) +void ViewPrivate::showConfigurationInterface(Plasma::Applet *applet) { if (configView) { configView.data()->hide(); @@ -156,9 +159,9 @@ void PlasmaQuickViewPrivate::showConfigurationInterface(Plasma::Applet *applet) -PlasmaQuickView::PlasmaQuickView(Plasma::Corona *corona, QWindow *parent) +View::View(Plasma::Corona *corona, QWindow *parent) : QQuickView(parent), - d(new PlasmaQuickViewPrivate(corona, this)) + d(new ViewPrivate(corona, this)) { QSurfaceFormat format; format.setAlphaBufferSize(8); @@ -168,29 +171,29 @@ PlasmaQuickView::PlasmaQuickView(Plasma::Corona *corona, QWindow *parent) QObject::connect(screen(), &QScreen::geometryChanged, - this, &PlasmaQuickView::screenGeometryChanged); + this, &View::screenGeometryChanged); if (!corona->package().isValid()) { qWarning() << "Invalid home screen package"; } - setResizeMode(PlasmaQuickView::SizeRootObjectToView); + setResizeMode(View::SizeRootObjectToView); QObject::connect(corona, &Plasma::Corona::packageChanged, - this, &PlasmaQuickView::coronaPackageChanged); + this, &View::coronaPackageChanged); } -PlasmaQuickView::~PlasmaQuickView() +View::~View() { delete d; } -Plasma::Corona *PlasmaQuickView::corona() const +Plasma::Corona *View::corona() const { return d->corona; } -KConfigGroup PlasmaQuickView::config() const +KConfigGroup View::config() const { if (!containment()) { return KConfigGroup(); @@ -199,45 +202,47 @@ KConfigGroup PlasmaQuickView::config() const return KConfigGroup(&views, QString::number(containment()->screen())); } -void PlasmaQuickView::setContainment(Plasma::Containment *cont) +void View::setContainment(Plasma::Containment *cont) { d->setContainment(cont); } -Plasma::Containment *PlasmaQuickView::containment() const +Plasma::Containment *View::containment() const { return d->containment.data(); } -void PlasmaQuickView::setLocation(Plasma::Types::Location location) +void View::setLocation(Plasma::Types::Location location) { d->containment.data()->setLocation(location); } -Plasma::Types::Location PlasmaQuickView::location() const +Plasma::Types::Location View::location() const { return d->location(); } -Plasma::Types::FormFactor PlasmaQuickView::formFactor() const +Plasma::Types::FormFactor View::formFactor() const { return d->formFactor(); } -QRectF PlasmaQuickView::screenGeometry() +QRectF View::screenGeometry() { return screen()->geometry(); } -void PlasmaQuickView::showConfigurationInterface(Plasma::Applet *applet) +void View::showConfigurationInterface(Plasma::Applet *applet) { d->showConfigurationInterface(applet); } -void PlasmaQuickView::coronaPackageChanged(const Plasma::Package &package) +void View::coronaPackageChanged(const Plasma::Package &package) { setContainment(0); setSource(QUrl::fromLocalFile(package.filePath("views", "Desktop.qml"))); } +} + #include "moc_plasmaquickview.cpp" diff --git a/src/plasmaquick/plasmaquickview.h b/src/plasmaquick/plasmaquickview.h index cc92ab22d..a853a0f77 100644 --- a/src/plasmaquick/plasmaquickview.h +++ b/src/plasmaquick/plasmaquickview.h @@ -25,9 +25,13 @@ #include "plasma/corona.h" #include "plasma/containment.h" -class PlasmaQuickViewPrivate; -class PLASMAQUICK_EXPORT PlasmaQuickView : public QQuickView +namespace PlasmaQuick +{ + +class ViewPrivate; + +class PLASMAQUICK_EXPORT View : public QQuickView { Q_OBJECT Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged) @@ -39,8 +43,8 @@ public: * @param corona the corona of this view * @param parent the QWindow this View is parented to **/ - explicit PlasmaQuickView(Plasma::Corona *corona, QWindow *parent = 0); - virtual ~PlasmaQuickView(); + explicit View(Plasma::Corona *corona, QWindow *parent = 0); + virtual ~View(); /** * @return the corona of this view @@ -115,8 +119,10 @@ Q_SIGNALS: void screenGeometryChanged(); private: - PlasmaQuickViewPrivate *const d; - friend class PlasmaQuickViewPrivate; + ViewPrivate *const d; + friend class ViewPrivate; }; -#endif // PLASMAQUICKVIEW_H +} + +#endif // View_H diff --git a/src/plasmaquick/private/appletquickitem_p.h b/src/plasmaquick/private/appletquickitem_p.h index 7e111136e..8e0b3f7a1 100644 --- a/src/plasmaquick/private/appletquickitem_p.h +++ b/src/plasmaquick/private/appletquickitem_p.h @@ -30,6 +30,8 @@ namespace KDeclarative { class QmlObject; } +namespace PlasmaQuick { + class AppletQuickItem; class AppletQuickItemPrivate @@ -90,4 +92,6 @@ public: static QHash s_rootObjects; }; +} + #endif diff --git a/src/plasmaquick/private/configcategory_p.cpp b/src/plasmaquick/private/configcategory_p.cpp index 5183d3793..08e48c138 100644 --- a/src/plasmaquick/private/configcategory_p.cpp +++ b/src/plasmaquick/private/configcategory_p.cpp @@ -38,6 +38,8 @@ #include #include +namespace PlasmaQuick { + ///////////////////////ConfigCategory ConfigCategory::ConfigCategory(QObject *parent) @@ -110,5 +112,6 @@ void ConfigCategory::setPluginName(const QString &name) emit pluginNameChanged(); } +} #include "private/moc_configcategory_p.cpp" diff --git a/src/plasmaquick/private/configcategory_p.h b/src/plasmaquick/private/configcategory_p.h index 3ea208a7a..d1103c57d 100644 --- a/src/plasmaquick/private/configcategory_p.h +++ b/src/plasmaquick/private/configcategory_p.h @@ -22,6 +22,8 @@ #include +namespace PlasmaQuick { + //This class represents a single row item of the ConfigModel model in a QML friendly manner. //the properties contains all the data needed to represent an icon in the sidebar of a configuration dialog, of applets or containments class ConfigCategory : public QObject @@ -61,4 +63,6 @@ private: QString m_pluginName; }; +} + #endif // multiple inclusion guard