summaryrefslogtreecommitdiffstats
path: root/src/widget/wsingletoncontainer.h
diff options
context:
space:
mode:
authorOwen Williams <owilliams@mixxx.org>2015-01-15 20:44:01 -0500
committerOwen Williams <owilliams@mixxx.org>2015-01-15 20:44:01 -0500
commitee11a8e1599d906bc902a8f3e9a297342841d3f6 (patch)
treef1fc0adfd49ed783dabef1cbfc8df247572b6add /src/widget/wsingletoncontainer.h
parentb371427855bbef8b9e05e02b7052ecc2a86b611c (diff)
Make the SingletonMap its own class
Diffstat (limited to 'src/widget/wsingletoncontainer.h')
-rw-r--r--src/widget/wsingletoncontainer.h40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/widget/wsingletoncontainer.h b/src/widget/wsingletoncontainer.h
index b2bd95ffc2..e2ae587aba 100644
--- a/src/widget/wsingletoncontainer.h
+++ b/src/widget/wsingletoncontainer.h
@@ -47,34 +47,38 @@
#include "widget/wwidgetgroup.h"
class WSingletonContainer : public WWidgetGroup {
-
Q_OBJECT
+ public:
+ // Prepares the container and remembers the widget, but does not add the
+ // widget to the container.
+ WSingletonContainer(QWidget* widget, QWidget* pParent=NULL);
+ public slots:
+ virtual void showEvent(QShowEvent* event);
+ private:
+ QPointer<QWidget> m_pWidget;
+ QLayout* m_pLayout;
+};
+
+class SingletonMap {
public:
typedef QMap<QString, QWidget*> WidgetMap;
- virtual ~WSingletonContainer() { }
-
- // We don't want to end up with badly-constructed containers, so only
- // provide a factory function.
- static WSingletonContainer* getSingleton(QString objectName,
- WidgetMap* widgetMap,
- QWidget* pParent=NULL);
-
// Takes a constructed QWidget and inserts it in the map of available
- // singletons.
- static void defineSingleton(QString objectName, QWidget* widget,
- WidgetMap* widgetMap);
+ // singletons. Checks that an object of that name hasn't already been
+ // defined.
+ void defineSingleton(QString objectName, QWidget* widget);
- public slots:
- virtual void showEvent(QShowEvent* event);
+ // We don't want to end up with badly-constructed containers, so only
+ // provide a factory function. Returns NULL if the objectName is not in
+ // the map.
+ WSingletonContainer* getSingleton(QString objectName,
+ QWidget* pParent=NULL);
private:
- WSingletonContainer(QWidget* widget, QWidget* pParent=NULL);
-
- QPointer<QWidget> m_pWidget;
- QLayout* m_pLayout;
+ WidgetMap m_singletons;
};
+
#endif // WSINGLETONCONTAINER_H