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>
27 class QLayoutItem;
28 class QWidgetItem;
29 
30 // CTK includes
31 #include "ctkWidgetsExport.h"
32 class ctkLayoutManagerPrivate;
34 
83 class CTK_WIDGETS_EXPORT ctkLayoutManager: public QObject
84 {
85  Q_OBJECT
88  Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
89 public:
91  ctkLayoutManager(QObject* parent = 0);
92  explicit ctkLayoutManager(QWidget* viewport, QObject* parent);
93 
95  virtual ~ctkLayoutManager();
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 
109 public Q_SLOTS:
110 
111 Q_SIGNALS:
113 
114 protected:
115  QScopedPointer<ctkLayoutManagerPrivate> d_ptr;
116  ctkLayoutManager(ctkLayoutManagerPrivate* ptr, QWidget* viewport, QObject* parent);
117 
118  virtual void onViewportChanged();
119  void clearLayout();
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 
170 private:
171  Q_DECLARE_PRIVATE(ctkLayoutManager);
172  Q_DISABLE_COPY(ctkLayoutManager);
173 };
174 
175 #endif
virtual void setLayout(const QDomDocument &newLayout)
ctkLayoutManager(QWidget *viewport, QObject *parent)
virtual QList< QWidget * > viewsFromXML(QDomElement layoutElement)
virtual ~ctkLayoutManager()
Destructor.
virtual void setupLayout()
virtual void addChildItemToLayout(QDomElement itemElement, QLayoutItem *childItem, QLayoutItem *layoutItem)
virtual QWidget * viewFromXML(QDomElement layoutElement)=0
const QDomDocument layout() const
QScopedPointer< ctkLayoutManagerPrivate > d_ptr
int spacing() const
virtual QLayoutItem * processElement(QDomElement element)
void setSpacing(int spacing)
virtual void onViewportChanged()
ctkLayoutManager(QObject *parent=0)
Constructor.
Q_INVOKABLE void setViewport(QWidget *widget)
virtual QLayoutItem * layoutFromXML(QDomElement layoutElement)
Q_INVOKABLE QWidget * viewport() const
QWidgetItem * widgetItemFromXML(QDomElement layoutElement)
ctkLayoutManager(ctkLayoutManagerPrivate *ptr, QWidget *viewport, QObject *parent)
QList< QLayoutItem * > widgetItemsFromXML(QDomElement layoutElement)
virtual void setupView(QDomElement layoutElement, QWidget *view)
virtual QLayoutItem * processLayoutElement(QDomElement layoutElement)
void processItemElement(QDomElement layoutElement, QLayoutItem *layoutItem)