summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-04 15:21:02 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-04 15:21:02 (GMT)
commit793d3c2da83098e32063c4ae6df187058103bde8 (patch)
tree7b96581a67bd66ff30b0ede18b0fbfd71d9345cf /examples
parent2d0f49df3a3c44601bf2e41ea722c2384b71aab0 (diff)
parentc2d47f6717fdccd44838f3c128693a3c09f6cf68 (diff)
downloadQt-793d3c2da83098e32063c4ae6df187058103bde8.zip
Qt-793d3c2da83098e32063c4ae6df187058103bde8.tar.gz
Qt-793d3c2da83098e32063c4ae6df187058103bde8.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into windows-7-multitouch
Diffstat (limited to 'examples')
-rw-r--r--examples/layouts/flowlayout/flowlayout.cpp27
-rw-r--r--examples/layouts/flowlayout/flowlayout.h3
-rw-r--r--examples/layouts/flowlayout/window.cpp3
-rw-r--r--examples/layouts/flowlayout/window.h3
4 files changed, 30 insertions, 6 deletions
diff --git a/examples/layouts/flowlayout/flowlayout.cpp b/examples/layouts/flowlayout/flowlayout.cpp
index c4032d0..263911d 100644
--- a/examples/layouts/flowlayout/flowlayout.cpp
+++ b/examples/layouts/flowlayout/flowlayout.cpp
@@ -42,7 +42,7 @@
#include <QtGui>
#include "flowlayout.h"
-
+//! [1]
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
{
@@ -54,19 +54,25 @@ FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
+//! [1]
+//! [2]
FlowLayout::~FlowLayout()
{
QLayoutItem *item;
while ((item = takeAt(0)))
delete item;
}
+//! [2]
+//! [3]
void FlowLayout::addItem(QLayoutItem *item)
{
itemList.append(item);
}
+//! [3]
+//! [4]
int FlowLayout::horizontalSpacing() const
{
if (m_hSpace >= 0) {
@@ -84,7 +90,9 @@ int FlowLayout::verticalSpacing() const
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
}
}
+//! [4]
+//! [5]
int FlowLayout::count() const
{
return itemList.size();
@@ -102,12 +110,16 @@ QLayoutItem *FlowLayout::takeAt(int index)
else
return 0;
}
+//! [5]
+//! [6]
Qt::Orientations FlowLayout::expandingDirections() const
{
return 0;
}
+//! [6]
+//! [7]
bool FlowLayout::hasHeightForWidth() const
{
return true;
@@ -118,7 +130,9 @@ int FlowLayout::heightForWidth(int width) const
int height = doLayout(QRect(0, 0, width, 0), true);
return height;
}
+//! [7]
+//! [8]
void FlowLayout::setGeometry(const QRect &rect)
{
QLayout::setGeometry(rect);
@@ -140,7 +154,9 @@ QSize FlowLayout::minimumSize() const
size += QSize(2*margin(), 2*margin());
return size;
}
+//! [8]
+//! [9]
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
{
int left, top, right, bottom;
@@ -149,7 +165,9 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
int x = effectiveRect.x();
int y = effectiveRect.y();
int lineHeight = 0;
+//! [9]
+//! [10]
QLayoutItem *item;
foreach (item, itemList) {
QWidget *wid = item->widget();
@@ -161,6 +179,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
+//! [10]
+//! [11]
int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
x = effectiveRect.x();
@@ -177,7 +197,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
}
return y + lineHeight - rect.y() + bottom;
}
-
+//! [11]
+//! [12]
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
QObject *parent = this->parent();
@@ -190,4 +211,4 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
return static_cast<QLayout *>(parent)->spacing();
}
}
-
+//! [12]
diff --git a/examples/layouts/flowlayout/flowlayout.h b/examples/layouts/flowlayout/flowlayout.h
index 9940e55..bab7f36 100644
--- a/examples/layouts/flowlayout/flowlayout.h
+++ b/examples/layouts/flowlayout/flowlayout.h
@@ -45,7 +45,7 @@
#include <QLayout>
#include <QRect>
#include <QWidgetItem>
-
+//! [0]
class FlowLayout : public QLayout
{
public:
@@ -74,5 +74,6 @@ private:
int m_hSpace;
int m_vSpace;
};
+//! [0]
#endif
diff --git a/examples/layouts/flowlayout/window.cpp b/examples/layouts/flowlayout/window.cpp
index 51d9886..b7d9eae 100644
--- a/examples/layouts/flowlayout/window.cpp
+++ b/examples/layouts/flowlayout/window.cpp
@@ -43,7 +43,7 @@
#include "flowlayout.h"
#include "window.h"
-
+//! [1]
Window::Window()
{
FlowLayout *flowLayout = new FlowLayout;
@@ -57,3 +57,4 @@ Window::Window()
setWindowTitle(tr("Flow Layout"));
}
+//! [1] \ No newline at end of file
diff --git a/examples/layouts/flowlayout/window.h b/examples/layouts/flowlayout/window.h
index ffd60af..77f8b6f 100644
--- a/examples/layouts/flowlayout/window.h
+++ b/examples/layouts/flowlayout/window.h
@@ -47,7 +47,7 @@
QT_BEGIN_NAMESPACE
class QLabel;
QT_END_NAMESPACE
-
+//! [0]
class Window : public QWidget
{
Q_OBJECT
@@ -55,5 +55,6 @@ class Window : public QWidget
public:
Window();
};
+//! [0]
#endif