Skip to content

Commit

Permalink
client: Add elements to containments
Browse files Browse the repository at this point in the history
This is much more clean.

Issue: #151
  • Loading branch information
plfiorini committed Mar 25, 2014
1 parent 11c3b97 commit f1a2326
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
4 changes: 3 additions & 1 deletion src/client/scripting/panelinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* $END_LICENSE$
***************************************************************************/

#include <HawaiiShell/Containment>

#include "panelinterface.h"
#include "panelview.h"
#include "shellmanager.h"
Expand Down Expand Up @@ -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"
19 changes: 0 additions & 19 deletions src/client/views/panelview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ PanelView::PanelView(ShellUi *mantle, QScreen *screen)

PanelView::~PanelView()
{
qDeleteAll(m_elements);

delete m_surface;
m_surface = nullptr;
}
Expand Down Expand Up @@ -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
Expand Down
14 changes: 1 addition & 13 deletions src/client/views/panelview.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include <QtConfiguration/QConfiguration>

#include <HawaiiShell/ElementItem>
#include <HawaiiShell/Element>
#include <HawaiiShell/HawaiiShell>
#include <HawaiiShell/QuickView>

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -109,8 +99,6 @@ public Q_SLOTS:
int m_minimumLength;
int m_maximumLength;
QConfiguration *m_configuration;
QSet<QString> m_elementsSet;
QList<Hawaii::Shell::ElementItem *> m_elements;
PanelSurface *m_surface;
QPointer<PanelConfigView> m_configView;

Expand Down

0 comments on commit f1a2326

Please sign in to comment.