CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Loading...
Searching...
No Matches
ctkLayoutViewFactory.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Library: CTK
4
5 Copyright (c) Kitware Inc.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0.txt
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19=========================================================================*/
20
21#ifndef __ctkLayoutViewFactory_h
22#define __ctkLayoutViewFactory_h
23
24// Qt includes
25#include <QObject>
26#include <QDomDocument>
27class QLayoutItem;
28class QWidgetItem;
29
30// CTK includes
31#include "ctkWidgetsExport.h"
32class ctkLayoutViewFactoryPrivate;
33
42class CTK_WIDGETS_EXPORT ctkLayoutViewFactory: public QObject
43{
44 Q_OBJECT
48 Q_PROPERTY(bool useCachedViews READ useCachedViews WRITE setUseCachedViews);
49public:
51 ctkLayoutViewFactory(QObject* parent = 0);
52
55
62 virtual QStringList supportedElementNames()const;
63
68 virtual bool isElementSupported(QDomElement layoutElement)const;
69
72 bool useCachedViews()const;
75 void setUseCachedViews(bool cache);
76
79 virtual void beginSetupLayout();
82 virtual void endSetupLayout();
83
88 virtual void setupView(QDomElement layoutElement, QWidget* view);
97 virtual QWidget* viewFromXML(QDomElement layoutElement);
108 virtual QList<QWidget*> viewsFromXML(QDomElement layoutElement);
109
114protected:
115 QScopedPointer<ctkLayoutViewFactoryPrivate> d_ptr;
116
119 virtual QWidget* createViewFromXML(QDomElement layoutElement);
123 virtual QList<QWidget*> createViewsFromXML(QDomElement layoutElement);
124
128 QList<QWidget*> registeredViews(const QDomElement& layoutElement)const;
129
132 virtual void registerView(QDomElement layoutElement, QWidget* view);
133
136 virtual void unregisterView(QDomElement layoutElement, QWidget* view);
137
140 virtual void unregisterView(QWidget* view);
141
145 QDomElement layoutElement(QWidget* view)const;
146
147private:
148 Q_DECLARE_PRIVATE(ctkLayoutViewFactory);
149 Q_DISABLE_COPY(ctkLayoutViewFactory);
150};
151
173template<class T>
175{
176public:
177 ctkTemplateLayoutViewFactory(QObject* parent = 0)
178 : ctkLayoutViewFactory(parent)
179 {
180 this->setUseCachedViews(true);
181 }
182 virtual QWidget* createViewFromXML(QDomElement layoutElement){
183 Q_UNUSED(layoutElement);
184 return new T;
185 }
186};
187
188#endif
QDomElement layoutElement(QWidget *view) const
virtual void unregisterView(QWidget *view)
virtual QList< QWidget * > createViewsFromXML(QDomElement layoutElement)
ctkLayoutViewFactory(QObject *parent=0)
Constructor.
QScopedPointer< ctkLayoutViewFactoryPrivate > d_ptr
QList< QWidget * > registeredViews() const
virtual void setupView(QDomElement layoutElement, QWidget *view)
virtual QList< QWidget * > viewsFromXML(QDomElement layoutElement)
virtual QWidget * viewFromXML(QDomElement layoutElement)
virtual void endSetupLayout()
virtual void registerView(QDomElement layoutElement, QWidget *view)
virtual void unregisterView(QDomElement layoutElement, QWidget *view)
bool useCachedViews() const
void setUseCachedViews(bool cache)
virtual QWidget * createViewFromXML(QDomElement layoutElement)
virtual bool isElementSupported(QDomElement layoutElement) const
QList< QWidget * > registeredViews(const QDomElement &layoutElement) const
virtual ~ctkLayoutViewFactory()
Destructor.
virtual void beginSetupLayout()
virtual QStringList supportedElementNames() const
virtual QWidget * createViewFromXML(QDomElement layoutElement)
ctkTemplateLayoutViewFactory(QObject *parent=0)