diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2012-08-17 13:23:19 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-20 12:20:55 +0200 |
commit | 806dda08d685bc5f9ed71dfe8b61f21848d48066 (patch) | |
tree | a63533a1c4a335ae17adc105abb0ae4e62e2f26e /examples/graphicsview/flowlayout | |
parent | 9f942014e31842b512c3198de035d041c59f54a9 (diff) |
Moving .qdoc files under examples/widgets/doc
Updated those .qdoc files to refer to the new relative examples
emplacement. Images and snippets to be moved later.
Also grouped all widgets related examples under widgets.
Change-Id: Ib29696e2d8948524537f53e8dda88f9ee26a597f
Reviewed-by: J-P Nurmi <j-p.nurmi@nokia.com>
Diffstat (limited to 'examples/graphicsview/flowlayout')
-rw-r--r-- | examples/graphicsview/flowlayout/flowlayout.cpp | 213 | ||||
-rw-r--r-- | examples/graphicsview/flowlayout/flowlayout.desktop | 11 | ||||
-rw-r--r-- | examples/graphicsview/flowlayout/flowlayout.h | 76 | ||||
-rw-r--r-- | examples/graphicsview/flowlayout/flowlayout.pro | 14 | ||||
-rw-r--r-- | examples/graphicsview/flowlayout/main.cpp | 57 | ||||
-rw-r--r-- | examples/graphicsview/flowlayout/window.cpp | 62 | ||||
-rw-r--r-- | examples/graphicsview/flowlayout/window.h | 47 |
7 files changed, 0 insertions, 480 deletions
diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp deleted file mode 100644 index 3f787109eb..0000000000 --- a/examples/graphicsview/flowlayout/flowlayout.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "flowlayout.h" -#include <QtWidgets/qwidget.h> -#include <QtCore/qmath.h> - -FlowLayout::FlowLayout() -{ - m_spacing[0] = 6; - m_spacing[1] = 6; - QSizePolicy sp = sizePolicy(); - sp.setHeightForWidth(true); - setSizePolicy(sp); -} - -void FlowLayout::insertItem(int index, QGraphicsLayoutItem *item) -{ - item->setParentLayoutItem(this); - if (uint(index) > uint(m_items.count())) - index = m_items.count(); - m_items.insert(index, item); - invalidate(); -} - -int FlowLayout::count() const -{ - return m_items.count(); -} - -QGraphicsLayoutItem *FlowLayout::itemAt(int index) const -{ - return m_items.value(index); -} - -void FlowLayout::removeAt(int index) -{ - m_items.removeAt(index); - invalidate(); -} - -qreal FlowLayout::spacing(Qt::Orientation o) const -{ - return m_spacing[int(o) - 1]; -} - -void FlowLayout::setSpacing(Qt::Orientations o, qreal spacing) -{ - if (o & Qt::Horizontal) - m_spacing[0] = spacing; - if (o & Qt::Vertical) - m_spacing[1] = spacing; -} - -void FlowLayout::setGeometry(const QRectF &geom) -{ - QGraphicsLayout::setGeometry(geom); - doLayout(geom, true); -} - -qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const -{ - qreal left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - const qreal maxw = geom.width() - left - right; - - qreal x = 0; - qreal y = 0; - qreal maxRowHeight = 0; - QSizeF pref; - for (int i = 0; i < m_items.count(); ++i) { - QGraphicsLayoutItem *item = m_items.at(i); - pref = item->effectiveSizeHint(Qt::PreferredSize); - maxRowHeight = qMax(maxRowHeight, pref.height()); - - qreal next_x; - next_x = x + pref.width(); - if (next_x > maxw) { - if (x == 0) { - pref.setWidth(maxw); - } else { - x = 0; - next_x = pref.width(); - } - y += maxRowHeight + spacing(Qt::Vertical); - maxRowHeight = 0; - } - - if (applyNewGeometry) - item->setGeometry(QRectF(QPointF(left + x, top + y), pref)); - x = next_x + spacing(Qt::Horizontal); - } - maxRowHeight = qMax(maxRowHeight, pref.height()); - return top + y + maxRowHeight + bottom; -} - -QSizeF FlowLayout::minSize(const QSizeF &constraint) const -{ - QSizeF size(0, 0); - qreal left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - if (constraint.width() >= 0) { // height for width - const qreal height = doLayout(QRectF(QPointF(0,0), constraint), false); - size = QSizeF(constraint.width(), height); - } else if (constraint.height() >= 0) { // width for height? - // not supported - } else { - QGraphicsLayoutItem *item; - foreach (item, m_items) - size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize)); - size += QSize(left + right, top + bottom); - } - return size; -} - -QSizeF FlowLayout::prefSize() const -{ - qreal left, right; - getContentsMargins(&left, 0, &right, 0); - - QGraphicsLayoutItem *item; - qreal maxh = 0; - qreal totalWidth = 0; - foreach (item, m_items) { - if (totalWidth > 0) - totalWidth += spacing(Qt::Horizontal); - QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize); - totalWidth += pref.width(); - maxh = qMax(maxh, pref.height()); - } - maxh += spacing(Qt::Vertical); - - const qreal goldenAspectRatio = 1.61803399; - qreal w = qSqrt(totalWidth * maxh * goldenAspectRatio) + left + right; - - return minSize(QSizeF(w, -1)); -} - -QSizeF FlowLayout::maxSize() const -{ - QGraphicsLayoutItem *item; - qreal totalWidth = 0; - qreal totalHeight = 0; - foreach (item, m_items) { - if (totalWidth > 0) - totalWidth += spacing(Qt::Horizontal); - if (totalHeight > 0) - totalHeight += spacing(Qt::Vertical); - QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize); - totalWidth += pref.width(); - totalHeight += pref.height(); - } - - qreal left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); - return QSizeF(left + totalWidth + right, top + totalHeight + bottom); -} - -QSizeF FlowLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ - QSizeF sh = constraint; - switch (which) { - case Qt::PreferredSize: - sh = prefSize(); - break; - case Qt::MinimumSize: - sh = minSize(constraint); - break; - case Qt::MaximumSize: - sh = maxSize(); - break; - default: - break; - } - return sh; -} diff --git a/examples/graphicsview/flowlayout/flowlayout.desktop b/examples/graphicsview/flowlayout/flowlayout.desktop deleted file mode 100644 index 54ea3b0290..0000000000 --- a/examples/graphicsview/flowlayout/flowlayout.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Flow Layout -Exec=/opt/usr/bin/flowlayout -Icon=flowlayout -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h deleted file mode 100644 index 751e435ec0..0000000000 --- a/examples/graphicsview/flowlayout/flowlayout.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtWidgets/qgraphicslayout.h> - -class FlowLayout : public QGraphicsLayout -{ -public: - FlowLayout(); - inline void addItem(QGraphicsLayoutItem *item); - void insertItem(int index, QGraphicsLayoutItem *item); - void setSpacing(Qt::Orientations o, qreal spacing); - qreal spacing(Qt::Orientation o) const; - - // inherited functions - void setGeometry(const QRectF &geom); - - int count() const; - QGraphicsLayoutItem *itemAt(int index) const; - void removeAt(int index); - -protected: - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; - -private: - qreal doLayout(const QRectF &geom, bool applyNewGeometry) const; - QSizeF minSize(const QSizeF &constraint) const; - QSizeF prefSize() const; - QSizeF maxSize() const; - - QList<QGraphicsLayoutItem*> m_items; - qreal m_spacing[2]; -}; - - -inline void FlowLayout::addItem(QGraphicsLayoutItem *item) -{ - insertItem(-1, item); -} diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro deleted file mode 100644 index 5f69a74d60..0000000000 --- a/examples/graphicsview/flowlayout/flowlayout.pro +++ /dev/null @@ -1,14 +0,0 @@ -QT += widgets - -QMAKE_PROJECT_NAME = flowlayout_graphicsview - -HEADERS += flowlayout.h window.h -SOURCES += flowlayout.cpp main.cpp window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/flowlayout -sources.files = $$SOURCES $$HEADERS *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/flowlayout -INSTALLS += target sources - -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp deleted file mode 100644 index a7a1155224..0000000000 --- a/examples/graphicsview/flowlayout/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtWidgets> -#include "window.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - QGraphicsScene scene; - QGraphicsView *view = new QGraphicsView(&scene); - Window *w = new Window; - scene.addItem(w); - - view->resize(400, 300); - view->show(); - - return app.exec(); -} diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp deleted file mode 100644 index 193a2bbc6e..0000000000 --- a/examples/graphicsview/flowlayout/window.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtWidgets/qgraphicsproxywidget.h> -#include <QtWidgets/qlabel.h> -#include "flowlayout.h" -#include "window.h" - -Window::Window() -: QGraphicsWidget(0, Qt::Window) -{ - FlowLayout *lay = new FlowLayout; - QLatin1String wiseWords("I am not bothered by the fact that I am unknown." - " I am bothered when I do not know others. (Confucius)"); - QString sentence(wiseWords); - QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts); - for (int i = 0; i < words.count(); ++i) { - QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); - QLabel *label = new QLabel(words.at(i)); - label->setFrameStyle(QFrame::Box | QFrame::Plain); - proxy->setWidget(label); - lay->addItem(proxy); - } - setLayout(lay); -} diff --git a/examples/graphicsview/flowlayout/window.h b/examples/graphicsview/flowlayout/window.h deleted file mode 100644 index b1eb874c21..0000000000 --- a/examples/graphicsview/flowlayout/window.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtWidgets/qgraphicswidget.h> - -class Window : public QGraphicsWidget { - Q_OBJECT -public: - Window(); -}; |