summaryrefslogtreecommitdiffstats
path: root/examples/graphicsview/dragdroprobot
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2012-08-17 13:23:19 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-20 12:20:55 +0200
commit806dda08d685bc5f9ed71dfe8b61f21848d48066 (patch)
treea63533a1c4a335ae17adc105abb0ae4e62e2f26e /examples/graphicsview/dragdroprobot
parent9f942014e31842b512c3198de035d041c59f54a9 (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/dragdroprobot')
-rw-r--r--examples/graphicsview/dragdroprobot/coloritem.cpp142
-rw-r--r--examples/graphicsview/dragdroprobot/coloritem.h65
-rw-r--r--examples/graphicsview/dragdroprobot/dragdroprobot.desktop11
-rw-r--r--examples/graphicsview/dragdroprobot/dragdroprobot.pro22
-rw-r--r--examples/graphicsview/dragdroprobot/images/head.pngbin14972 -> 0 bytes
-rw-r--r--examples/graphicsview/dragdroprobot/main.cpp94
-rw-r--r--examples/graphicsview/dragdroprobot/robot.cpp307
-rw-r--r--examples/graphicsview/dragdroprobot/robot.h118
-rw-r--r--examples/graphicsview/dragdroprobot/robot.qrc5
9 files changed, 0 insertions, 764 deletions
diff --git a/examples/graphicsview/dragdroprobot/coloritem.cpp b/examples/graphicsview/dragdroprobot/coloritem.cpp
deleted file mode 100644
index 18e7a01af2..0000000000
--- a/examples/graphicsview/dragdroprobot/coloritem.cpp
+++ /dev/null
@@ -1,142 +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 "coloritem.h"
-
-//! [0]
-ColorItem::ColorItem()
- : color(qrand() % 256, qrand() % 256, qrand() % 256)
-{
- setToolTip(QString("QColor(%1, %2, %3)\n%4")
- .arg(color.red()).arg(color.green()).arg(color.blue())
- .arg("Click and drag this color onto the robot!"));
- setCursor(Qt::OpenHandCursor);
- setAcceptedMouseButtons(Qt::LeftButton);
-}
-//! [0]
-
-//! [1]
-QRectF ColorItem::boundingRect() const
-{
- return QRectF(-15.5, -15.5, 34, 34);
-}
-//! [1]
-
-//! [2]
-void ColorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
- painter->setPen(Qt::NoPen);
- painter->setBrush(Qt::darkGray);
- painter->drawEllipse(-12, -12, 30, 30);
- painter->setPen(QPen(Qt::black, 1));
- painter->setBrush(QBrush(color));
- painter->drawEllipse(-15, -15, 30, 30);
-}
-//! [2]
-
-//! [3]
-void ColorItem::mousePressEvent(QGraphicsSceneMouseEvent *)
-{
- setCursor(Qt::ClosedHandCursor);
-}
-//! [3]
-
-//! [5]
-void ColorItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton))
- .length() < QApplication::startDragDistance()) {
- return;
- }
-
- QDrag *drag = new QDrag(event->widget());
- QMimeData *mime = new QMimeData;
- drag->setMimeData(mime);
-//! [5]
-
-//! [6]
- static int n = 0;
- if (n++ > 2 && (qrand() % 3) == 0) {
- QImage image(":/images/head.png");
- mime->setImageData(image);
-
- drag->setPixmap(QPixmap::fromImage(image).scaled(30, 40));
- drag->setHotSpot(QPoint(15, 30));
-//! [6]
-//! [7]
- } else {
- mime->setColorData(color);
- mime->setText(QString("#%1%2%3")
- .arg(color.red(), 2, 16, QLatin1Char('0'))
- .arg(color.green(), 2, 16, QLatin1Char('0'))
- .arg(color.blue(), 2, 16, QLatin1Char('0')));
-
- QPixmap pixmap(34, 34);
- pixmap.fill(Qt::white);
-
- QPainter painter(&pixmap);
- painter.translate(15, 15);
- painter.setRenderHint(QPainter::Antialiasing);
- paint(&painter, 0, 0);
- painter.end();
-
- pixmap.setMask(pixmap.createHeuristicMask());
-
- drag->setPixmap(pixmap);
- drag->setHotSpot(QPoint(15, 20));
- }
-//! [7]
-
-//! [8]
- drag->exec();
- setCursor(Qt::OpenHandCursor);
-}
-//! [8]
-
-//! [4]
-void ColorItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
-{
- setCursor(Qt::OpenHandCursor);
-}
-//! [4]
diff --git a/examples/graphicsview/dragdroprobot/coloritem.h b/examples/graphicsview/dragdroprobot/coloritem.h
deleted file mode 100644
index 9d3b4a9693..0000000000
--- a/examples/graphicsview/dragdroprobot/coloritem.h
+++ /dev/null
@@ -1,65 +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$
-**
-****************************************************************************/
-
-#ifndef COLORITEM_H
-#define COLORITEM_H
-
-#include <QGraphicsItem>
-
-//! [0]
-class ColorItem : public QGraphicsItem
-{
-public:
- ColorItem();
-
- QRectF boundingRect() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
-
-protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
-
-private:
- QColor color;
-};
-//! [0]
-
-#endif
diff --git a/examples/graphicsview/dragdroprobot/dragdroprobot.desktop b/examples/graphicsview/dragdroprobot/dragdroprobot.desktop
deleted file mode 100644
index c01e3a3425..0000000000
--- a/examples/graphicsview/dragdroprobot/dragdroprobot.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=Drag and Drop Robot
-Exec=/opt/usr/bin/dragdroprobot
-Icon=dragdroprobot
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/graphicsview/dragdroprobot/dragdroprobot.pro b/examples/graphicsview/dragdroprobot/dragdroprobot.pro
deleted file mode 100644
index 3e33bad2f9..0000000000
--- a/examples/graphicsview/dragdroprobot/dragdroprobot.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-HEADERS += \
- coloritem.h \
- robot.h
-
-SOURCES += \
- coloritem.cpp \
- main.cpp \
- robot.cpp
-
-RESOURCES += \
- robot.qrc
-
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/dragdroprobot
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS dragdroprobot.pro images
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/dragdroprobot
-INSTALLS += target sources
-
-QT += widgets
-
-simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/dragdroprobot/images/head.png b/examples/graphicsview/dragdroprobot/images/head.png
deleted file mode 100644
index 1e520e09b8..0000000000
--- a/examples/graphicsview/dragdroprobot/images/head.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/dragdroprobot/main.cpp b/examples/graphicsview/dragdroprobot/main.cpp
deleted file mode 100644
index 05d3c8f1b3..0000000000
--- a/examples/graphicsview/dragdroprobot/main.cpp
+++ /dev/null
@@ -1,94 +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 "coloritem.h"
-#include "robot.h"
-
-#include <math.h>
-
-class GraphicsView : public QGraphicsView
-{
-public:
- GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene)
- {
- }
-
-protected:
- virtual void resizeEvent(QResizeEvent *)
- {
- }
-};
-
-//! [0]
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
-//! [0]
-//! [1]
- QGraphicsScene scene(-200, -200, 400, 400);
-
- for (int i = 0; i < 10; ++i) {
- ColorItem *item = new ColorItem;
- item->setPos(::sin((i * 6.28) / 10.0) * 150,
- ::cos((i * 6.28) / 10.0) * 150);
-
- scene.addItem(item);
- }
-
- Robot *robot = new Robot;
- robot->setTransform(QTransform::fromScale(1.2, 1.2), true);
- robot->setPos(0, -20);
- scene.addItem(robot);
-//! [1]
-//! [2]
- GraphicsView view(&scene);
- view.setRenderHint(QPainter::Antialiasing);
- view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- view.setBackgroundBrush(QColor(230, 200, 167));
- view.setWindowTitle("Drag and Drop Robot");
- view.show();
-
- return app.exec();
-}
-//! [2]
diff --git a/examples/graphicsview/dragdroprobot/robot.cpp b/examples/graphicsview/dragdroprobot/robot.cpp
deleted file mode 100644
index 20935bf6c5..0000000000
--- a/examples/graphicsview/dragdroprobot/robot.cpp
+++ /dev/null
@@ -1,307 +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 "robot.h"
-
-//! [0]
-RobotPart::RobotPart(QGraphicsItem *parent)
- : QGraphicsObject(parent), color(Qt::lightGray), dragOver(false)
-{
- setAcceptDrops(true);
-}
-//! [0]
-
-//! [1]
-void RobotPart::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
-{
- if (event->mimeData()->hasColor()) {
- event->setAccepted(true);
- dragOver = true;
- update();
- } else {
- event->setAccepted(false);
- }
-}
-//! [1]
-
-//! [2]
-void RobotPart::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_UNUSED(event);
- dragOver = false;
- update();
-}
-//! [2]
-
-//! [3]
-void RobotPart::dropEvent(QGraphicsSceneDragDropEvent *event)
-{
- dragOver = false;
- if (event->mimeData()->hasColor())
- color = qvariant_cast<QColor>(event->mimeData()->colorData());
- update();
-}
-//! [3]
-
-//! [4]
-RobotHead::RobotHead(QGraphicsItem *parent)
- : RobotPart(parent)
-{
-}
-//! [4]
-
-//! [5]
-QRectF RobotHead::boundingRect() const
-{
- return QRectF(-15, -50, 30, 50);
-}
-//! [5]
-
-//! [6]
-void RobotHead::paint(QPainter *painter,
- const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
- if (pixmap.isNull()) {
- painter->setBrush(dragOver ? color.light(130) : color);
- painter->drawRoundedRect(-10, -30, 20, 30, 25, 25, Qt::RelativeSize);
- painter->setBrush(Qt::white);
- painter->drawEllipse(-7, -3 - 20, 7, 7);
- painter->drawEllipse(0, -3 - 20, 7, 7);
- painter->setBrush(Qt::black);
- painter->drawEllipse(-5, -1 - 20, 2, 2);
- painter->drawEllipse(2, -1 - 20, 2, 2);
- painter->setPen(QPen(Qt::black, 2));
- painter->setBrush(Qt::NoBrush);
- painter->drawArc(-6, -2 - 20, 12, 15, 190 * 16, 160 * 16);
- } else {
- painter->scale(.2272, .2824);
- painter->drawPixmap(QPointF(-15 * 4.4, -50 * 3.54), pixmap);
- }
-}
-//! [6]
-
-//! [7]
-void RobotHead::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
-{
- if (event->mimeData()->hasImage()) {
- event->setAccepted(true);
- dragOver = true;
- update();
- } else {
- RobotPart::dragEnterEvent(event);
- }
-}
-//! [7]
-
-//! [8]
-void RobotHead::dropEvent(QGraphicsSceneDragDropEvent *event)
-{
- if (event->mimeData()->hasImage()) {
- dragOver = false;
- pixmap = qvariant_cast<QPixmap>(event->mimeData()->imageData());
- update();
- } else {
- RobotPart::dropEvent(event);
- }
-}
-//! [8]
-
-RobotTorso::RobotTorso(QGraphicsItem *parent)
- : RobotPart(parent)
-{
-}
-
-QRectF RobotTorso::boundingRect() const
-{
- return QRectF(-30, -20, 60, 60);
-}
-
-void RobotTorso::paint(QPainter *painter,
- const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
-
- painter->setBrush(dragOver ? color.light(130) : color);
- painter->drawRoundedRect(-20, -20, 40, 60, 25, 25, Qt::RelativeSize);
- painter->drawEllipse(-25, -20, 20, 20);
- painter->drawEllipse(5, -20, 20, 20);
- painter->drawEllipse(-20, 22, 20, 20);
- painter->drawEllipse(0, 22, 20, 20);
-}
-
-RobotLimb::RobotLimb(QGraphicsItem *parent)
- : RobotPart(parent)
-{
-}
-
-QRectF RobotLimb::boundingRect() const
-{
- return QRectF(-5, -5, 40, 10);
-}
-
-void RobotLimb::paint(QPainter *painter,
- const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
-
- painter->setBrush(dragOver ? color.light(130) : color);
- painter->drawRoundedRect(boundingRect(), 50, 50, Qt::RelativeSize);
- painter->drawEllipse(-5, -5, 10, 10);
-}
-
-//! [10]
-Robot::Robot(QGraphicsItem *parent)
- : RobotPart(parent)
-{
- setFlag(ItemHasNoContents);
-
- QGraphicsObject *torsoItem = new RobotTorso(this);
- QGraphicsObject *headItem = new RobotHead(torsoItem);
- QGraphicsObject *upperLeftArmItem = new RobotLimb(torsoItem);
- QGraphicsObject *lowerLeftArmItem = new RobotLimb(upperLeftArmItem);
- QGraphicsObject *upperRightArmItem = new RobotLimb(torsoItem);
- QGraphicsObject *lowerRightArmItem = new RobotLimb(upperRightArmItem);
- QGraphicsObject *upperRightLegItem = new RobotLimb(torsoItem);
- QGraphicsObject *lowerRightLegItem = new RobotLimb(upperRightLegItem);
- QGraphicsObject *upperLeftLegItem = new RobotLimb(torsoItem);
- QGraphicsObject *lowerLeftLegItem = new RobotLimb(upperLeftLegItem);
-//! [10]
-
-//! [11]
- headItem->setPos(0, -18);
- upperLeftArmItem->setPos(-15, -10);
- lowerLeftArmItem->setPos(30, 0);
- upperRightArmItem->setPos(15, -10);
- lowerRightArmItem->setPos(30, 0);
- upperRightLegItem->setPos(10, 32);
- lowerRightLegItem->setPos(30, 0);
- upperLeftLegItem->setPos(-10, 32);
- lowerLeftLegItem->setPos(30, 0);
-//! [11]
-
-//! [12]
- QParallelAnimationGroup *animation = new QParallelAnimationGroup(this);
-
- QPropertyAnimation *headAnimation = new QPropertyAnimation(headItem, "rotation");
- headAnimation->setStartValue(20);
- headAnimation->setEndValue(-20);
- QPropertyAnimation *headScaleAnimation = new QPropertyAnimation(headItem, "scale");
- headScaleAnimation->setEndValue(1.1);
- animation->addAnimation(headAnimation);
- animation->addAnimation(headScaleAnimation);
-//! [12]
-
- QPropertyAnimation *upperLeftArmAnimation = new QPropertyAnimation(upperLeftArmItem, "rotation");
- upperLeftArmAnimation->setStartValue(190);
- upperLeftArmAnimation->setEndValue(180);
- animation->addAnimation(upperLeftArmAnimation);
-
- QPropertyAnimation *lowerLeftArmAnimation = new QPropertyAnimation(lowerLeftArmItem, "rotation");
- lowerLeftArmAnimation->setStartValue(50);
- lowerLeftArmAnimation->setEndValue(10);
- animation->addAnimation(lowerLeftArmAnimation);
-
- QPropertyAnimation *upperRightArmAnimation = new QPropertyAnimation(upperRightArmItem, "rotation");
- upperRightArmAnimation->setStartValue(300);
- upperRightArmAnimation->setEndValue(310);
- animation->addAnimation(upperRightArmAnimation);
-
- QPropertyAnimation *lowerRightArmAnimation = new QPropertyAnimation(lowerRightArmItem, "rotation");
- lowerRightArmAnimation->setStartValue(0);
- lowerRightArmAnimation->setEndValue(-70);
- animation->addAnimation(lowerRightArmAnimation);
-
- QPropertyAnimation *upperLeftLegAnimation = new QPropertyAnimation(upperLeftLegItem, "rotation");
- upperLeftLegAnimation->setStartValue(150);
- upperLeftLegAnimation->setEndValue(80);
- animation->addAnimation(upperLeftLegAnimation);
-
- QPropertyAnimation *lowerLeftLegAnimation = new QPropertyAnimation(lowerLeftLegItem, "rotation");
- lowerLeftLegAnimation->setStartValue(70);
- lowerLeftLegAnimation->setEndValue(10);
- animation->addAnimation(lowerLeftLegAnimation);
-
- QPropertyAnimation *upperRightLegAnimation = new QPropertyAnimation(upperRightLegItem, "rotation");
- upperRightLegAnimation->setStartValue(40);
- upperRightLegAnimation->setEndValue(120);
- animation->addAnimation(upperRightLegAnimation);
-
- QPropertyAnimation *lowerRightLegAnimation = new QPropertyAnimation(lowerRightLegItem, "rotation");
- lowerRightLegAnimation->setStartValue(10);
- lowerRightLegAnimation->setEndValue(50);
- animation->addAnimation(lowerRightLegAnimation);
-
- QPropertyAnimation *torsoAnimation = new QPropertyAnimation(torsoItem, "rotation");
- torsoAnimation->setStartValue(5);
- torsoAnimation->setEndValue(-20);
- animation->addAnimation(torsoAnimation);
-
-//! [13]
- for (int i = 0; i < animation->animationCount(); ++i) {
- QPropertyAnimation *anim = qobject_cast<QPropertyAnimation *>(animation->animationAt(i));
- anim->setEasingCurve(QEasingCurve::SineCurve);
- anim->setDuration(2000);
- }
-
- animation->setLoopCount(-1);
- animation->start();
-//! [13]
-}
-
-//! [9]
-QRectF Robot::boundingRect() const
-{
- return QRectF();
-}
-
-void Robot::paint(QPainter *painter,
- const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(painter);
- Q_UNUSED(option);
- Q_UNUSED(widget);
-}
-//! [9]
diff --git a/examples/graphicsview/dragdroprobot/robot.h b/examples/graphicsview/dragdroprobot/robot.h
deleted file mode 100644
index ff9fb49485..0000000000
--- a/examples/graphicsview/dragdroprobot/robot.h
+++ /dev/null
@@ -1,118 +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$
-**
-****************************************************************************/
-
-#ifndef ROBOT_H
-#define ROBOT_H
-
-#include <QGraphicsItem>
-
-QT_BEGIN_NAMESPACE
-class QGraphicsSceneMouseEvent;
-class QParallelAnimationGroup;
-QT_END_NAMESPACE
-
-//! [0]
-class RobotPart : public QGraphicsObject
-{
-public:
- RobotPart(QGraphicsItem *parent = 0);
-
-protected:
- void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
- void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
- void dropEvent(QGraphicsSceneDragDropEvent *event);
-
- QColor color;
- bool dragOver;
-};
-//! [0]
-
-//! [1]
-class RobotHead : public RobotPart
-{
-public:
- RobotHead(QGraphicsItem *parent = 0);
-
- QRectF boundingRect() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
-
-protected:
- void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
- void dropEvent(QGraphicsSceneDragDropEvent *event);
-
-private:
- QPixmap pixmap;
-};
-//! [1]
-
-//! [2]
-class RobotTorso : public RobotPart
-{
-public:
- RobotTorso(QGraphicsItem *parent = 0);
-
- QRectF boundingRect() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
-};
-//! [2]
-
-//! [3]
-class RobotLimb : public RobotPart
-{
-public:
- RobotLimb(QGraphicsItem *parent = 0);
-
- QRectF boundingRect() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
-};
-//! [3]
-
-//! [4]
-class Robot : public RobotPart
-{
-public:
- Robot(QGraphicsItem *parent = 0);
-
- QRectF boundingRect() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
-};
-//! [4]
-
-#endif
diff --git a/examples/graphicsview/dragdroprobot/robot.qrc b/examples/graphicsview/dragdroprobot/robot.qrc
deleted file mode 100644
index b0969d2a64..0000000000
--- a/examples/graphicsview/dragdroprobot/robot.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>images/head.png</file>
- </qresource>
-</RCC>