58 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW |
58 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW |
59 |
59 |
60 #include "qgraphicslayout.h" |
60 #include "qgraphicslayout.h" |
61 #include "qgraphicslayoutitem_p.h" |
61 #include "qgraphicslayoutitem_p.h" |
62 #include <QtGui/qstyle.h> |
62 #include <QtGui/qstyle.h> |
|
63 #include <QtGui/qwidget.h> |
|
64 #include <QtGui/qstyleoption.h> |
63 |
65 |
64 QT_BEGIN_NAMESPACE |
66 QT_BEGIN_NAMESPACE |
65 |
67 |
66 class QGraphicsLayoutItem; |
68 class QGraphicsLayoutItem; |
67 class QGraphicsWidget; |
69 class QGraphicsWidget; |
73 if(checked_env == -1) |
75 if(checked_env == -1) |
74 checked_env = !!qgetenv("QT_GRAPHICSLAYOUT_DEBUG").toInt(); |
76 checked_env = !!qgetenv("QT_GRAPHICSLAYOUT_DEBUG").toInt(); |
75 return checked_env; |
77 return checked_env; |
76 } |
78 } |
77 #endif |
79 #endif |
|
80 |
|
81 |
|
82 class QLayoutStyleInfo |
|
83 { |
|
84 public: |
|
85 inline QLayoutStyleInfo() { invalidate(); } |
|
86 inline QLayoutStyleInfo(QStyle *style, QWidget *widget) |
|
87 : m_valid(true), m_style(style), m_widget(widget) |
|
88 { |
|
89 Q_ASSERT(style); |
|
90 if (widget) //### |
|
91 m_styleOption.initFrom(widget); |
|
92 m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
|
93 m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing); |
|
94 } |
|
95 |
|
96 inline void invalidate() { m_valid = false; m_style = 0; m_widget = 0; } |
|
97 |
|
98 inline QStyle *style() const { return m_style; } |
|
99 inline QWidget *widget() const { return m_widget; } |
|
100 |
|
101 inline bool operator==(const QLayoutStyleInfo &other) |
|
102 { return m_style == other.m_style && m_widget == other.m_widget; } |
|
103 inline bool operator!=(const QLayoutStyleInfo &other) |
|
104 { return !(*this == other); } |
|
105 |
|
106 inline void setDefaultSpacing(Qt::Orientation o, qreal spacing){ |
|
107 if (spacing >= 0) |
|
108 m_defaultSpacing[o - 1] = spacing; |
|
109 } |
|
110 |
|
111 inline qreal defaultSpacing(Qt::Orientation o) const { |
|
112 return m_defaultSpacing[o - 1]; |
|
113 } |
|
114 |
|
115 inline qreal perItemSpacing(QSizePolicy::ControlType control1, |
|
116 QSizePolicy::ControlType control2, |
|
117 Qt::Orientation orientation) const |
|
118 { |
|
119 Q_ASSERT(style()); |
|
120 return style()->layoutSpacing(control1, control2, orientation, &m_styleOption, widget()); |
|
121 } |
|
122 private: |
|
123 bool m_valid; |
|
124 QStyle *m_style; |
|
125 QWidget *m_widget; |
|
126 QStyleOption m_styleOption; |
|
127 qreal m_defaultSpacing[2]; |
|
128 }; |
78 |
129 |
79 class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPrivate |
130 class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPrivate |
80 { |
131 { |
81 Q_DECLARE_PUBLIC(QGraphicsLayout) |
132 Q_DECLARE_PUBLIC(QGraphicsLayout) |
82 |
133 |