Mercurial > projects > qtd
comparison examples/layouts/borderlayout/borderlayout.d @ 322:7c2cf27391c4 signals
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
author | eldar_ins@eldar-laptop |
---|---|
date | Sun, 27 Dec 2009 21:13:38 +0500 |
parents | 6aeaf24018d7 |
children | 778ef7374fb5 |
comparison
equal
deleted
inserted
replaced
321:d458ed66e871 | 322:7c2cf27391c4 |
---|---|
73 delete l; | 73 delete l; |
74 l = takeAt(0); | 74 l = takeAt(0); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void addWidget(QWidget widget, Position position) | |
79 { | |
80 add(cast(IQLayoutItem) new QWidgetItem(widget), position); | |
81 } | |
82 | |
83 void add(IQLayoutItem item, Position position) | |
84 { | |
85 list ~= new ItemWrapper(item, position); | |
86 } | |
87 | |
88 override | |
89 { | |
78 void addItem(IQLayoutItem item) | 90 void addItem(IQLayoutItem item) |
79 { | 91 { |
80 add(item, Position.West); | 92 add(item, Position.West); |
81 } | 93 } |
82 | 94 |
83 void addWidget(QWidget widget, Position position) | 95 int expandingDirections() const |
84 { | |
85 add(cast(IQLayoutItem) new QWidgetItem(widget), position); | |
86 } | |
87 | |
88 int expandingDirections() | |
89 { | 96 { |
90 return Qt.Horizontal | Qt.Vertical; | 97 return Qt.Horizontal | Qt.Vertical; |
91 } | 98 } |
92 | 99 |
93 bool hasHeightForWidth() | 100 bool hasHeightForWidth() const |
94 { | 101 { |
95 return false; | 102 return false; |
96 } | 103 } |
97 | 104 |
98 int count() | 105 int count() const |
99 { | 106 { |
100 return list.length; | 107 return list.length; |
101 } | 108 } |
102 | 109 |
103 QLayoutItem itemAt(int index) | 110 IQLayoutItem itemAt(int index) const |
104 { | 111 { |
105 if(index >= 0 && index < list.length) | 112 if(index >= 0 && index < list.length) |
106 return list[index].item; | 113 return cast(IQLayoutItem) list[index].item; |
107 else | 114 else |
108 return null; | 115 return null; |
109 } | 116 } |
110 | 117 |
111 QSize minimumSize() | 118 QSize minimumSize() const |
112 { | 119 { |
113 return calculateSize(SizeType.MinimumSize); | 120 return calculateSize(SizeType.MinimumSize); |
114 } | 121 } |
115 | 122 |
116 void setGeometry(const QRect rect) | 123 void setGeometry(const QRect rect) |
180 center.item.setGeometry(QRect(westWidth, northHeight, | 187 center.item.setGeometry(QRect(westWidth, northHeight, |
181 rect.width() - eastWidth - westWidth, | 188 rect.width() - eastWidth - westWidth, |
182 centerHeight)); | 189 centerHeight)); |
183 } | 190 } |
184 | 191 |
185 QSize sizeHint() | 192 QSize sizeHint() const |
186 { | 193 { |
187 return calculateSize(SizeType.SizeHint); | 194 return calculateSize(SizeType.SizeHint); |
188 } | 195 } |
189 | 196 |
190 QLayoutItem takeAt(int index) | 197 QLayoutItem takeAt(int index) |
193 ItemWrapper layoutStruct = list[index]; | 200 ItemWrapper layoutStruct = list[index]; |
194 return layoutStruct.item; | 201 return layoutStruct.item; |
195 } | 202 } |
196 return null; | 203 return null; |
197 } | 204 } |
198 | 205 } |
199 void add(IQLayoutItem item, Position position) | |
200 { | |
201 list ~= new ItemWrapper(item, position); | |
202 } | |
203 | 206 |
204 private: | 207 private: |
205 | 208 |
206 class ItemWrapper | 209 class ItemWrapper |
207 { | 210 { |
215 Position position; | 218 Position position; |
216 }; | 219 }; |
217 | 220 |
218 enum SizeType { MinimumSize, SizeHint }; | 221 enum SizeType { MinimumSize, SizeHint }; |
219 | 222 |
220 QSize calculateSize(SizeType sizeType) | 223 QSize calculateSize(SizeType sizeType) const |
221 { | 224 { |
222 QSize totalSize; | 225 QSize totalSize; |
223 | 226 |
224 for (int i = 0; i < list.length; ++i) { | 227 for (int i = 0; i < list.length; ++i) { |
225 ItemWrapper wrapper = list[i]; | 228 const ItemWrapper wrapper = list[i]; |
226 Position position = wrapper.position; | 229 Position position = wrapper.position; |
227 QSize itemSize; | 230 QSize itemSize; |
228 | 231 |
229 if (sizeType == SizeType.MinimumSize) | 232 if (sizeType == SizeType.MinimumSize) |
230 itemSize = wrapper.item.minimumSize(); | 233 itemSize = wrapper.item.minimumSize(); |