CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkLayoutManager.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 __ctkLayoutManager_h
22#define __ctkLayoutManager_h
23
24// Qt includes
25#include <QObject>
26#include <QDomDocument>
27class QLayoutItem;
28class QWidgetItem;
29
30// CTK includes
31#include "ctkWidgetsExport.h"
32class ctkLayoutManagerPrivate;
34
83class CTK_WIDGETS_EXPORT ctkLayoutManager: public QObject
84{
85 Q_OBJECT
88 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
89public:
91 ctkLayoutManager(QObject* parent = 0);
92 explicit ctkLayoutManager(QWidget* viewport, QObject* parent);
93
96
97 Q_INVOKABLE void setViewport(QWidget* widget);
98 Q_INVOKABLE QWidget* viewport()const;
99
102 int spacing()const;
105 void setSpacing(int spacing);
106
107 void refresh();
108
109public Q_SLOTS:
110
111Q_SIGNALS:
113
114protected:
115 QScopedPointer<ctkLayoutManagerPrivate> d_ptr;
116 ctkLayoutManager(ctkLayoutManagerPrivate* ptr, QWidget* viewport, QObject* parent);
117
118 virtual void onViewportChanged();
120 virtual void setupLayout();
121
122 virtual void setLayout(const QDomDocument& newLayout);
123 const QDomDocument layout()const;
124
128 virtual QLayoutItem* processElement(QDomElement element);
131 virtual QLayoutItem* processLayoutElement(QDomElement layoutElement);
134 virtual QLayoutItem* layoutFromXML(QDomElement layoutElement);
137 void processItemElement(QDomElement layoutElement, QLayoutItem* layoutItem);
140 virtual void addChildItemToLayout(QDomElement itemElement, QLayoutItem* childItem, QLayoutItem* layoutItem);
144 QWidgetItem* widgetItemFromXML(QDomElement layoutElement);
149 virtual void setupView(QDomElement layoutElement, QWidget* view);
152 QList<QLayoutItem*> widgetItemsFromXML(QDomElement layoutElement);
158 virtual QWidget* viewFromXML(QDomElement layoutElement) = 0;
168 virtual QList<QWidget*> viewsFromXML(QDomElement layoutElement);
169
170private:
171 Q_DECLARE_PRIVATE(ctkLayoutManager);
172 Q_DISABLE_COPY(ctkLayoutManager);
173};
174
175#endif
virtual void setLayout(const QDomDocument &newLayout)
virtual QLayoutItem * layoutFromXML(QDomElement layoutElement)
ctkLayoutManager(QWidget *viewport, QObject *parent)
virtual ~ctkLayoutManager()
Destructor.
virtual void setupLayout()
Q_INVOKABLE QWidget * viewport() const
virtual void addChildItemToLayout(QDomElement itemElement, QLayoutItem *childItem, QLayoutItem *layoutItem)
virtual QLayoutItem * processLayoutElement(QDomElement layoutElement)
const QDomDocument layout() const
QScopedPointer< ctkLayoutManagerPrivate > d_ptr
int spacing() const
QList< QLayoutItem * > widgetItemsFromXML(QDomElement layoutElement)
void setSpacing(int spacing)
virtual void onViewportChanged()
ctkLayoutManager(QObject *parent=0)
Constructor.
Q_INVOKABLE void setViewport(QWidget *widget)
virtual QList< QWidget * > viewsFromXML(QDomElement layoutElement)
ctkLayoutManager(ctkLayoutManagerPrivate *ptr, QWidget *viewport, QObject *parent)
QWidgetItem * widgetItemFromXML(QDomElement layoutElement)
virtual QLayoutItem * processElement(QDomElement element)
virtual QWidget * viewFromXML(QDomElement layoutElement)=0
virtual void setupView(QDomElement layoutElement, QWidget *view)
void processItemElement(QDomElement layoutElement, QLayoutItem *layoutItem)