From f1a23265c335c4daa90db6609682931966617623 Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Tue, 25 Mar 2014 08:18:30 +0000 Subject: [PATCH] client: Add elements to containments This is much more clean. Issue: #151 --- src/client/scripting/panelinterface.cpp | 4 +++- src/client/views/panelview.cpp | 19 ------------------- src/client/views/panelview.h | 14 +------------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/client/scripting/panelinterface.cpp b/src/client/scripting/panelinterface.cpp index 5851eebb..efc34cf3 100644 --- a/src/client/scripting/panelinterface.cpp +++ b/src/client/scripting/panelinterface.cpp @@ -24,6 +24,8 @@ * $END_LICENSE$ ***************************************************************************/ +#include + #include "panelinterface.h" #include "panelview.h" #include "shellmanager.h" @@ -162,7 +164,7 @@ void PanelInterface::setThickness(int value) void PanelInterface::addElement(const QString &element) { - m_view->addElement(element); + m_view->containment()->addElement(element); } #include "moc_panelinterface.cpp" diff --git a/src/client/views/panelview.cpp b/src/client/views/panelview.cpp index 397e84e6..1bca841b 100644 --- a/src/client/views/panelview.cpp +++ b/src/client/views/panelview.cpp @@ -134,8 +134,6 @@ PanelView::PanelView(ShellUi *mantle, QScreen *screen) PanelView::~PanelView() { - qDeleteAll(m_elements); - delete m_surface; m_surface = nullptr; } @@ -289,23 +287,6 @@ void PanelView::setMaximumLength(int value) dockPanel(); } -QStringList PanelView::elements() const -{ - return m_elementsSet.toList(); -} - -void PanelView::addElement(const QString &name) -{ - m_elementsSet.insert(name); - - Element *element = new Element(name, containment(), this); - ElementItem *elementItem = new ElementItem(element); - elementItem->setContextProperty("Shell", QVariant::fromValue(ShellManager::instance()->controller())); - elementItem->initialize(); - m_elements.append(elementItem); - Q_EMIT elementAdded(elementItem); -} - void PanelView::showConfigurationWindow() { // Recreate the window if necessary and show it diff --git a/src/client/views/panelview.h b/src/client/views/panelview.h index 10a86446..685da231 100644 --- a/src/client/views/panelview.h +++ b/src/client/views/panelview.h @@ -33,7 +33,7 @@ #include -#include +#include #include #include @@ -52,7 +52,6 @@ class PanelView : public Hawaii::Shell::QuickView Q_PROPERTY(int length READ length WRITE setLength NOTIFY lengthChanged) Q_PROPERTY(int minimumLength READ minimumLength WRITE setMinimumLength NOTIFY minimumLengthChanged) Q_PROPERTY(int maximumLength READ maximumLength WRITE setMaximumLength NOTIFY maximumLengthChanged) - Q_PROPERTY(QStringList elements READ elements NOTIFY elementsChanged) public: explicit PanelView(ShellUi *mantle, QScreen *screen); virtual ~PanelView(); @@ -78,11 +77,6 @@ class PanelView : public Hawaii::Shell::QuickView int maximumLength() const; void setMaximumLength(int value); - QStringList elements() const; - -public Q_SLOTS: - void addElement(const QString &name); - protected: void showConfigurationWindow(); void hideConfigurationWindow(); @@ -96,10 +90,6 @@ public Q_SLOTS: void minimumLengthChanged(); void maximumLengthChanged(); - void elementsChanged(); - void elementAdded(Hawaii::Shell::ElementItem *element); - void elementRemoved(); - private: bool m_maximized; Qt::Alignment m_alignment; @@ -109,8 +99,6 @@ public Q_SLOTS: int m_minimumLength; int m_maximumLength; QConfiguration *m_configuration; - QSet m_elementsSet; - QList m_elements; PanelSurface *m_surface; QPointer m_configView;