Mercurial > projects > qtd
diff 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 |
line wrap: on
line diff
--- a/examples/layouts/borderlayout/borderlayout.d Sat Dec 26 05:10:16 2009 +0500 +++ b/examples/layouts/borderlayout/borderlayout.d Sun Dec 27 21:13:38 2009 +0500 @@ -75,40 +75,47 @@ } } - void addItem(IQLayoutItem item) - { - add(item, Position.West); - } - void addWidget(QWidget widget, Position position) { add(cast(IQLayoutItem) new QWidgetItem(widget), position); } - int expandingDirections() + void add(IQLayoutItem item, Position position) + { + list ~= new ItemWrapper(item, position); + } + +override +{ + void addItem(IQLayoutItem item) + { + add(item, Position.West); + } + + int expandingDirections() const { return Qt.Horizontal | Qt.Vertical; } - bool hasHeightForWidth() + bool hasHeightForWidth() const { return false; } - int count() + int count() const { return list.length; } - QLayoutItem itemAt(int index) + IQLayoutItem itemAt(int index) const { if(index >= 0 && index < list.length) - return list[index].item; + return cast(IQLayoutItem) list[index].item; else return null; } - QSize minimumSize() + QSize minimumSize() const { return calculateSize(SizeType.MinimumSize); } @@ -182,7 +189,7 @@ centerHeight)); } - QSize sizeHint() + QSize sizeHint() const { return calculateSize(SizeType.SizeHint); } @@ -195,11 +202,7 @@ } return null; } - - void add(IQLayoutItem item, Position position) - { - list ~= new ItemWrapper(item, position); - } +} private: @@ -217,12 +220,12 @@ enum SizeType { MinimumSize, SizeHint }; - QSize calculateSize(SizeType sizeType) + QSize calculateSize(SizeType sizeType) const { QSize totalSize; for (int i = 0; i < list.length; ++i) { - ItemWrapper wrapper = list[i]; + const ItemWrapper wrapper = list[i]; Position position = wrapper.position; QSize itemSize;