summaryrefslogtreecommitdiffstats
path: root/examples/graphicsview/diagramscene
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/diagramscene
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/diagramscene')
-rw-r--r--examples/graphicsview/diagramscene/arrow.cpp145
-rw-r--r--examples/graphicsview/diagramscene/arrow.h91
-rw-r--r--examples/graphicsview/diagramscene/diagramitem.cpp152
-rw-r--r--examples/graphicsview/diagramscene/diagramitem.h96
-rw-r--r--examples/graphicsview/diagramscene/diagramscene.cpp240
-rw-r--r--examples/graphicsview/diagramscene/diagramscene.desktop11
-rw-r--r--examples/graphicsview/diagramscene/diagramscene.h112
-rw-r--r--examples/graphicsview/diagramscene/diagramscene.pro23
-rw-r--r--examples/graphicsview/diagramscene/diagramscene.qrc20
-rw-r--r--examples/graphicsview/diagramscene/diagramtextitem.cpp81
-rw-r--r--examples/graphicsview/diagramscene/diagramtextitem.h78
-rw-r--r--examples/graphicsview/diagramscene/images/background1.pngbin112 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/background2.pngbin114 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/background3.pngbin116 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/background4.pngbin96 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/bold.pngbin274 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/bringtofront.pngbin293 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/delete.pngbin831 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/floodfill.pngbin282 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/italic.pngbin247 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/linecolor.pngbin145 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/linepointer.pngbin141 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/pointer.pngbin173 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/sendtoback.pngbin318 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/textpointer.pngbin753 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/images/underline.pngbin250 -> 0 bytes
-rw-r--r--examples/graphicsview/diagramscene/main.cpp55
-rw-r--r--examples/graphicsview/diagramscene/mainwindow.cpp661
-rw-r--r--examples/graphicsview/diagramscene/mainwindow.h150
29 files changed, 0 insertions, 1915 deletions
diff --git a/examples/graphicsview/diagramscene/arrow.cpp b/examples/graphicsview/diagramscene/arrow.cpp
deleted file mode 100644
index 236d836e13..0000000000
--- a/examples/graphicsview/diagramscene/arrow.cpp
+++ /dev/null
@@ -1,145 +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 "arrow.h"
-#include <math.h>
-
-const qreal Pi = 3.14;
-
-//! [0]
-Arrow::Arrow(DiagramItem *startItem, DiagramItem *endItem, QGraphicsItem *parent)
- : QGraphicsLineItem(parent)
-{
- myStartItem = startItem;
- myEndItem = endItem;
- setFlag(QGraphicsItem::ItemIsSelectable, true);
- myColor = Qt::black;
- setPen(QPen(myColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
-}
-//! [0]
-
-//! [1]
-QRectF Arrow::boundingRect() const
-{
- qreal extra = (pen().width() + 20) / 2.0;
-
- return QRectF(line().p1(), QSizeF(line().p2().x() - line().p1().x(),
- line().p2().y() - line().p1().y()))
- .normalized()
- .adjusted(-extra, -extra, extra, extra);
-}
-//! [1]
-
-//! [2]
-QPainterPath Arrow::shape() const
-{
- QPainterPath path = QGraphicsLineItem::shape();
- path.addPolygon(arrowHead);
- return path;
-}
-//! [2]
-
-//! [3]
-void Arrow::updatePosition()
-{
- QLineF line(mapFromItem(myStartItem, 0, 0), mapFromItem(myEndItem, 0, 0));
- setLine(line);
-}
-//! [3]
-
-//! [4]
-void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
- QWidget *)
-{
- if (myStartItem->collidesWithItem(myEndItem))
- return;
-
- QPen myPen = pen();
- myPen.setColor(myColor);
- qreal arrowSize = 20;
- painter->setPen(myPen);
- painter->setBrush(myColor);
-//! [4] //! [5]
-
- QLineF centerLine(myStartItem->pos(), myEndItem->pos());
- QPolygonF endPolygon = myEndItem->polygon();
- QPointF p1 = endPolygon.first() + myEndItem->pos();
- QPointF p2;
- QPointF intersectPoint;
- QLineF polyLine;
- for (int i = 1; i < endPolygon.count(); ++i) {
- p2 = endPolygon.at(i) + myEndItem->pos();
- polyLine = QLineF(p1, p2);
- QLineF::IntersectType intersectType =
- polyLine.intersect(centerLine, &intersectPoint);
- if (intersectType == QLineF::BoundedIntersection)
- break;
- p1 = p2;
- }
-
- setLine(QLineF(intersectPoint, myStartItem->pos()));
-//! [5] //! [6]
-
- double angle = ::acos(line().dx() / line().length());
- if (line().dy() >= 0)
- angle = (Pi * 2) - angle;
-
- QPointF arrowP1 = line().p1() + QPointF(sin(angle + Pi / 3) * arrowSize,
- cos(angle + Pi / 3) * arrowSize);
- QPointF arrowP2 = line().p1() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
- cos(angle + Pi - Pi / 3) * arrowSize);
-
- arrowHead.clear();
- arrowHead << line().p1() << arrowP1 << arrowP2;
-//! [6] //! [7]
- painter->drawLine(line());
- painter->drawPolygon(arrowHead);
- if (isSelected()) {
- painter->setPen(QPen(myColor, 1, Qt::DashLine));
- QLineF myLine = line();
- myLine.translate(0, 4.0);
- painter->drawLine(myLine);
- myLine.translate(0,-8.0);
- painter->drawLine(myLine);
- }
-}
-//! [7]
diff --git a/examples/graphicsview/diagramscene/arrow.h b/examples/graphicsview/diagramscene/arrow.h
deleted file mode 100644
index ac09d6ad00..0000000000
--- a/examples/graphicsview/diagramscene/arrow.h
+++ /dev/null
@@ -1,91 +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 ARROW_H
-#define ARROW_H
-
-#include <QGraphicsLineItem>
-
-#include "diagramitem.h"
-
-QT_BEGIN_NAMESPACE
-class QGraphicsPolygonItem;
-class QGraphicsLineItem;
-class QGraphicsScene;
-class QRectF;
-class QGraphicsSceneMouseEvent;
-class QPainterPath;
-QT_END_NAMESPACE
-
-//! [0]
-class Arrow : public QGraphicsLineItem
-{
-public:
- enum { Type = UserType + 4 };
-
- Arrow(DiagramItem *startItem, DiagramItem *endItem,
- QGraphicsItem *parent = 0);
-
- int type() const
- { return Type; }
- QRectF boundingRect() const;
- QPainterPath shape() const;
- void setColor(const QColor &color)
- { myColor = color; }
- DiagramItem *startItem() const
- { return myStartItem; }
- DiagramItem *endItem() const
- { return myEndItem; }
-
- void updatePosition();
-
-protected:
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget = 0);
-
-private:
- DiagramItem *myStartItem;
- DiagramItem *myEndItem;
- QColor myColor;
- QPolygonF arrowHead;
-};
-//! [0]
-
-#endif
diff --git a/examples/graphicsview/diagramscene/diagramitem.cpp b/examples/graphicsview/diagramscene/diagramitem.cpp
deleted file mode 100644
index 9509c30270..0000000000
--- a/examples/graphicsview/diagramscene/diagramitem.cpp
+++ /dev/null
@@ -1,152 +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 "diagramitem.h"
-#include "arrow.h"
-
-//! [0]
-DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu,
- QGraphicsItem *parent)
- : QGraphicsPolygonItem(parent)
-{
- myDiagramType = diagramType;
- myContextMenu = contextMenu;
-
- QPainterPath path;
- switch (myDiagramType) {
- case StartEnd:
- path.moveTo(200, 50);
- path.arcTo(150, 0, 50, 50, 0, 90);
- path.arcTo(50, 0, 50, 50, 90, 90);
- path.arcTo(50, 50, 50, 50, 180, 90);
- path.arcTo(150, 50, 50, 50, 270, 90);
- path.lineTo(200, 25);
- myPolygon = path.toFillPolygon();
- break;
- case Conditional:
- myPolygon << QPointF(-100, 0) << QPointF(0, 100)
- << QPointF(100, 0) << QPointF(0, -100)
- << QPointF(-100, 0);
- break;
- case Step:
- myPolygon << QPointF(-100, -100) << QPointF(100, -100)
- << QPointF(100, 100) << QPointF(-100, 100)
- << QPointF(-100, -100);
- break;
- default:
- myPolygon << QPointF(-120, -80) << QPointF(-70, 80)
- << QPointF(120, 80) << QPointF(70, -80)
- << QPointF(-120, -80);
- break;
- }
- setPolygon(myPolygon);
- setFlag(QGraphicsItem::ItemIsMovable, true);
- setFlag(QGraphicsItem::ItemIsSelectable, true);
- setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
-}
-//! [0]
-
-//! [1]
-void DiagramItem::removeArrow(Arrow *arrow)
-{
- int index = arrows.indexOf(arrow);
-
- if (index != -1)
- arrows.removeAt(index);
-}
-//! [1]
-
-//! [2]
-void DiagramItem::removeArrows()
-{
- foreach (Arrow *arrow, arrows) {
- arrow->startItem()->removeArrow(arrow);
- arrow->endItem()->removeArrow(arrow);
- scene()->removeItem(arrow);
- delete arrow;
- }
-}
-//! [2]
-
-//! [3]
-void DiagramItem::addArrow(Arrow *arrow)
-{
- arrows.append(arrow);
-}
-//! [3]
-
-//! [4]
-QPixmap DiagramItem::image() const
-{
- QPixmap pixmap(250, 250);
- pixmap.fill(Qt::transparent);
- QPainter painter(&pixmap);
- painter.setPen(QPen(Qt::black, 8));
- painter.translate(125, 125);
- painter.drawPolyline(myPolygon);
-
- return pixmap;
-}
-//! [4]
-
-//! [5]
-void DiagramItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
-{
- scene()->clearSelection();
- setSelected(true);
- myContextMenu->exec(event->screenPos());
-}
-//! [5]
-
-//! [6]
-QVariant DiagramItem::itemChange(GraphicsItemChange change,
- const QVariant &value)
-{
- if (change == QGraphicsItem::ItemPositionChange) {
- foreach (Arrow *arrow, arrows) {
- arrow->updatePosition();
- }
- }
-
- return value;
-}
-//! [6]
diff --git a/examples/graphicsview/diagramscene/diagramitem.h b/examples/graphicsview/diagramscene/diagramitem.h
deleted file mode 100644
index 07b3b6e830..0000000000
--- a/examples/graphicsview/diagramscene/diagramitem.h
+++ /dev/null
@@ -1,96 +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 DIAGRAMITEM_H
-#define DIAGRAMITEM_H
-
-#include <QGraphicsPixmapItem>
-#include <QList>
-
-QT_BEGIN_NAMESPACE
-class QPixmap;
-class QGraphicsItem;
-class QGraphicsScene;
-class QTextEdit;
-class QGraphicsSceneMouseEvent;
-class QMenu;
-class QGraphicsSceneContextMenuEvent;
-class QPainter;
-class QStyleOptionGraphicsItem;
-class QWidget;
-class QPolygonF;
-QT_END_NAMESPACE
-
-class Arrow;
-
-//! [0]
-class DiagramItem : public QGraphicsPolygonItem
-{
-public:
- enum { Type = UserType + 15 };
- enum DiagramType { Step, Conditional, StartEnd, Io };
-
- DiagramItem(DiagramType diagramType, QMenu *contextMenu,
- QGraphicsItem *parent = 0);
-
- void removeArrow(Arrow *arrow);
- void removeArrows();
- DiagramType diagramType() const
- { return myDiagramType; }
- QPolygonF polygon() const
- { return myPolygon; }
- void addArrow(Arrow *arrow);
- QPixmap image() const;
- int type() const
- { return Type;}
-
-protected:
- void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
-
-private:
- DiagramType myDiagramType;
- QPolygonF myPolygon;
- QMenu *myContextMenu;
- QList<Arrow *> arrows;
-};
-//! [0]
-
-#endif
diff --git a/examples/graphicsview/diagramscene/diagramscene.cpp b/examples/graphicsview/diagramscene/diagramscene.cpp
deleted file mode 100644
index c4a654aa99..0000000000
--- a/examples/graphicsview/diagramscene/diagramscene.cpp
+++ /dev/null
@@ -1,240 +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 "diagramscene.h"
-#include "arrow.h"
-
-//! [0]
-DiagramScene::DiagramScene(QMenu *itemMenu, QObject *parent)
- : QGraphicsScene(parent)
-{
- myItemMenu = itemMenu;
- myMode = MoveItem;
- myItemType = DiagramItem::Step;
- line = 0;
- textItem = 0;
- myItemColor = Qt::white;
- myTextColor = Qt::black;
- myLineColor = Qt::black;
-}
-//! [0]
-
-//! [1]
-void DiagramScene::setLineColor(const QColor &color)
-{
- myLineColor = color;
- if (isItemChange(Arrow::Type)) {
- Arrow *item =
- qgraphicsitem_cast<Arrow *>(selectedItems().first());
- item->setColor(myLineColor);
- update();
- }
-}
-//! [1]
-
-//! [2]
-void DiagramScene::setTextColor(const QColor &color)
-{
- myTextColor = color;
- if (isItemChange(DiagramTextItem::Type)) {
- DiagramTextItem *item =
- qgraphicsitem_cast<DiagramTextItem *>(selectedItems().first());
- item->setDefaultTextColor(myTextColor);
- }
-}
-//! [2]
-
-//! [3]
-void DiagramScene::setItemColor(const QColor &color)
-{
- myItemColor = color;
- if (isItemChange(DiagramItem::Type)) {
- DiagramItem *item =
- qgraphicsitem_cast<DiagramItem *>(selectedItems().first());
- item->setBrush(myItemColor);
- }
-}
-//! [3]
-
-//! [4]
-void DiagramScene::setFont(const QFont &font)
-{
- myFont = font;
-
- if (isItemChange(DiagramTextItem::Type)) {
- QGraphicsTextItem *item =
- qgraphicsitem_cast<DiagramTextItem *>(selectedItems().first());
- //At this point the selection can change so the first selected item might not be a DiagramTextItem
- if (item)
- item->setFont(myFont);
- }
-}
-//! [4]
-
-void DiagramScene::setMode(Mode mode)
-{
- myMode = mode;
-}
-
-void DiagramScene::setItemType(DiagramItem::DiagramType type)
-{
- myItemType = type;
-}
-
-//! [5]
-void DiagramScene::editorLostFocus(DiagramTextItem *item)
-{
- QTextCursor cursor = item->textCursor();
- cursor.clearSelection();
- item->setTextCursor(cursor);
-
- if (item->toPlainText().isEmpty()) {
- removeItem(item);
- item->deleteLater();
- }
-}
-//! [5]
-
-//! [6]
-void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
-{
- if (mouseEvent->button() != Qt::LeftButton)
- return;
-
- DiagramItem *item;
- switch (myMode) {
- case InsertItem:
- item = new DiagramItem(myItemType, myItemMenu);
- item->setBrush(myItemColor);
- addItem(item);
- item->setPos(mouseEvent->scenePos());
- emit itemInserted(item);
- break;
-//! [6] //! [7]
- case InsertLine:
- line = new QGraphicsLineItem(QLineF(mouseEvent->scenePos(),
- mouseEvent->scenePos()));
- line->setPen(QPen(myLineColor, 2));
- addItem(line);
- break;
-//! [7] //! [8]
- case InsertText:
- textItem = new DiagramTextItem();
- textItem->setFont(myFont);
- textItem->setTextInteractionFlags(Qt::TextEditorInteraction);
- textItem->setZValue(1000.0);
- connect(textItem, SIGNAL(lostFocus(DiagramTextItem*)),
- this, SLOT(editorLostFocus(DiagramTextItem*)));
- connect(textItem, SIGNAL(selectedChange(QGraphicsItem*)),
- this, SIGNAL(itemSelected(QGraphicsItem*)));
- addItem(textItem);
- textItem->setDefaultTextColor(myTextColor);
- textItem->setPos(mouseEvent->scenePos());
- emit textInserted(textItem);
-//! [8] //! [9]
- default:
- ;
- }
- QGraphicsScene::mousePressEvent(mouseEvent);
-}
-//! [9]
-
-//! [10]
-void DiagramScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
-{
- if (myMode == InsertLine && line != 0) {
- QLineF newLine(line->line().p1(), mouseEvent->scenePos());
- line->setLine(newLine);
- } else if (myMode == MoveItem) {
- QGraphicsScene::mouseMoveEvent(mouseEvent);
- }
-}
-//! [10]
-
-//! [11]
-void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
-{
- if (line != 0 && myMode == InsertLine) {
- QList<QGraphicsItem *> startItems = items(line->line().p1());
- if (startItems.count() && startItems.first() == line)
- startItems.removeFirst();
- QList<QGraphicsItem *> endItems = items(line->line().p2());
- if (endItems.count() && endItems.first() == line)
- endItems.removeFirst();
-
- removeItem(line);
- delete line;
-//! [11] //! [12]
-
- if (startItems.count() > 0 && endItems.count() > 0 &&
- startItems.first()->type() == DiagramItem::Type &&
- endItems.first()->type() == DiagramItem::Type &&
- startItems.first() != endItems.first()) {
- DiagramItem *startItem =
- qgraphicsitem_cast<DiagramItem *>(startItems.first());
- DiagramItem *endItem =
- qgraphicsitem_cast<DiagramItem *>(endItems.first());
- Arrow *arrow = new Arrow(startItem, endItem);
- arrow->setColor(myLineColor);
- startItem->addArrow(arrow);
- endItem->addArrow(arrow);
- arrow->setZValue(-1000.0);
- addItem(arrow);
- arrow->updatePosition();
- }
- }
-//! [12] //! [13]
- line = 0;
- QGraphicsScene::mouseReleaseEvent(mouseEvent);
-}
-//! [13]
-
-//! [14]
-bool DiagramScene::isItemChange(int type)
-{
- foreach (QGraphicsItem *item, selectedItems()) {
- if (item->type() == type)
- return true;
- }
- return false;
-}
-//! [14]
diff --git a/examples/graphicsview/diagramscene/diagramscene.desktop b/examples/graphicsview/diagramscene/diagramscene.desktop
deleted file mode 100644
index 54506ff979..0000000000
--- a/examples/graphicsview/diagramscene/diagramscene.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=Diagram Scene
-Exec=/opt/usr/bin/diagramscene
-Icon=diagramscene
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
diff --git a/examples/graphicsview/diagramscene/diagramscene.h b/examples/graphicsview/diagramscene/diagramscene.h
deleted file mode 100644
index 9f65eba890..0000000000
--- a/examples/graphicsview/diagramscene/diagramscene.h
+++ /dev/null
@@ -1,112 +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 DIAGRAMSCENE_H
-#define DIAGRAMSCENE_H
-
-#include <QGraphicsScene>
-#include "diagramitem.h"
-#include "diagramtextitem.h"
-
-QT_BEGIN_NAMESPACE
-class QGraphicsSceneMouseEvent;
-class QMenu;
-class QPointF;
-class QGraphicsLineItem;
-class QFont;
-class QGraphicsTextItem;
-class QColor;
-QT_END_NAMESPACE
-
-//! [0]
-class DiagramScene : public QGraphicsScene
-{
- Q_OBJECT
-
-public:
- enum Mode { InsertItem, InsertLine, InsertText, MoveItem };
-
- DiagramScene(QMenu *itemMenu, QObject *parent = 0);
- QFont font() const
- { return myFont; }
- QColor textColor() const
- { return myTextColor; }
- QColor itemColor() const
- { return myItemColor; }
- QColor lineColor() const
- { return myLineColor; }
- void setLineColor(const QColor &color);
- void setTextColor(const QColor &color);
- void setItemColor(const QColor &color);
- void setFont(const QFont &font);
-
-public slots:
- void setMode(Mode mode);
- void setItemType(DiagramItem::DiagramType type);
- void editorLostFocus(DiagramTextItem *item);
-
-signals:
- void itemInserted(DiagramItem *item);
- void textInserted(QGraphicsTextItem *item);
- void itemSelected(QGraphicsItem *item);
-
-protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
-
-private:
- bool isItemChange(int type);
-
- DiagramItem::DiagramType myItemType;
- QMenu *myItemMenu;
- Mode myMode;
- bool leftButtonDown;
- QPointF startPoint;
- QGraphicsLineItem *line;
- QFont myFont;
- DiagramTextItem *textItem;
- QColor myTextColor;
- QColor myItemColor;
- QColor myLineColor;
-};
-//! [0]
-
-#endif
diff --git a/examples/graphicsview/diagramscene/diagramscene.pro b/examples/graphicsview/diagramscene/diagramscene.pro
deleted file mode 100644
index e45f4a894b..0000000000
--- a/examples/graphicsview/diagramscene/diagramscene.pro
+++ /dev/null
@@ -1,23 +0,0 @@
-HEADERS = mainwindow.h \
- diagramitem.h \
- diagramscene.h \
- arrow.h \
- diagramtextitem.h
-SOURCES = mainwindow.cpp \
- diagramitem.cpp \
- main.cpp \
- arrow.cpp \
- diagramtextitem.cpp \
- diagramscene.cpp
-RESOURCES = diagramscene.qrc
-
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/diagramscene
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS diagramscene.pro images
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/diagramscene
-INSTALLS += target sources
-
-
-QT += widgets
-simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/diagramscene/diagramscene.qrc b/examples/graphicsview/diagramscene/diagramscene.qrc
deleted file mode 100644
index a11158402f..0000000000
--- a/examples/graphicsview/diagramscene/diagramscene.qrc
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/pointer.png</file>
- <file>images/linepointer.png</file>
- <file>images/textpointer.png</file>
- <file>images/bold.png</file>
- <file>images/italic.png</file>
- <file>images/underline.png</file>
- <file>images/floodfill.png</file>
- <file>images/bringtofront.png</file>
- <file>images/delete.png</file>
- <file>images/sendtoback.png</file>
- <file>images/linecolor.png</file>
- <file>images/background1.png</file>
- <file>images/background2.png</file>
- <file>images/background3.png</file>
- <file>images/background4.png</file>
-</qresource>
-</RCC>
-
diff --git a/examples/graphicsview/diagramscene/diagramtextitem.cpp b/examples/graphicsview/diagramscene/diagramtextitem.cpp
deleted file mode 100644
index 1e583045da..0000000000
--- a/examples/graphicsview/diagramscene/diagramtextitem.cpp
+++ /dev/null
@@ -1,81 +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 "diagramtextitem.h"
-#include "diagramscene.h"
-
-//! [0]
-DiagramTextItem::DiagramTextItem(QGraphicsItem *parent)
- : QGraphicsTextItem(parent)
-{
- setFlag(QGraphicsItem::ItemIsMovable);
- setFlag(QGraphicsItem::ItemIsSelectable);
-}
-//! [0]
-
-//! [1]
-QVariant DiagramTextItem::itemChange(GraphicsItemChange change,
- const QVariant &value)
-{
- if (change == QGraphicsItem::ItemSelectedHasChanged)
- emit selectedChange(this);
- return value;
-}
-//! [1]
-
-//! [2]
-void DiagramTextItem::focusOutEvent(QFocusEvent *event)
-{
- setTextInteractionFlags(Qt::NoTextInteraction);
- emit lostFocus(this);
- QGraphicsTextItem::focusOutEvent(event);
-}
-//! [2]
-
-//! [5]
-void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- if (textInteractionFlags() == Qt::NoTextInteraction)
- setTextInteractionFlags(Qt::TextEditorInteraction);
- QGraphicsTextItem::mouseDoubleClickEvent(event);
-}
-//! [5]
diff --git a/examples/graphicsview/diagramscene/diagramtextitem.h b/examples/graphicsview/diagramscene/diagramtextitem.h
deleted file mode 100644
index 611e9b6700..0000000000
--- a/examples/graphicsview/diagramscene/diagramtextitem.h
+++ /dev/null
@@ -1,78 +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 DIAGRAMTEXTITEM_H
-#define DIAGRAMTEXTITEM_H
-
-#include <QGraphicsTextItem>
-#include <QPen>
-
-QT_BEGIN_NAMESPACE
-class QFocusEvent;
-class QGraphicsItem;
-class QGraphicsScene;
-class QGraphicsSceneMouseEvent;
-QT_END_NAMESPACE
-
-//! [0]
-class DiagramTextItem : public QGraphicsTextItem
-{
- Q_OBJECT
-
-public:
- enum { Type = UserType + 3 };
-
- DiagramTextItem(QGraphicsItem *parent = 0);
-
- int type() const
- { return Type; }
-
-signals:
- void lostFocus(DiagramTextItem *item);
- void selectedChange(QGraphicsItem *item);
-
-protected:
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
- void focusOutEvent(QFocusEvent *event);
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
-};
-//! [0]
-
-#endif
diff --git a/examples/graphicsview/diagramscene/images/background1.png b/examples/graphicsview/diagramscene/images/background1.png
deleted file mode 100644
index 0f93c6bf42..0000000000
--- a/examples/graphicsview/diagramscene/images/background1.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/background2.png b/examples/graphicsview/diagramscene/images/background2.png
deleted file mode 100644
index 1e293db67a..0000000000
--- a/examples/graphicsview/diagramscene/images/background2.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/background3.png b/examples/graphicsview/diagramscene/images/background3.png
deleted file mode 100644
index 3db4f8ea5f..0000000000
--- a/examples/graphicsview/diagramscene/images/background3.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/background4.png b/examples/graphicsview/diagramscene/images/background4.png
deleted file mode 100644
index 9c1f3bfd77..0000000000
--- a/examples/graphicsview/diagramscene/images/background4.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/bold.png b/examples/graphicsview/diagramscene/images/bold.png
deleted file mode 100644
index 986e65e250..0000000000
--- a/examples/graphicsview/diagramscene/images/bold.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/bringtofront.png b/examples/graphicsview/diagramscene/images/bringtofront.png
deleted file mode 100644
index bda27578a2..0000000000
--- a/examples/graphicsview/diagramscene/images/bringtofront.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/delete.png b/examples/graphicsview/diagramscene/images/delete.png
deleted file mode 100644
index df2a147d24..0000000000
--- a/examples/graphicsview/diagramscene/images/delete.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/floodfill.png b/examples/graphicsview/diagramscene/images/floodfill.png
deleted file mode 100644
index 54c0dae237..0000000000
--- a/examples/graphicsview/diagramscene/images/floodfill.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/italic.png b/examples/graphicsview/diagramscene/images/italic.png
deleted file mode 100644
index 9a438b57ad..0000000000
--- a/examples/graphicsview/diagramscene/images/italic.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/linecolor.png b/examples/graphicsview/diagramscene/images/linecolor.png
deleted file mode 100644
index 98a821f27e..0000000000
--- a/examples/graphicsview/diagramscene/images/linecolor.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/linepointer.png b/examples/graphicsview/diagramscene/images/linepointer.png
deleted file mode 100644
index 66933d43b3..0000000000
--- a/examples/graphicsview/diagramscene/images/linepointer.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/pointer.png b/examples/graphicsview/diagramscene/images/pointer.png
deleted file mode 100644
index 0b0b0aa69d..0000000000
--- a/examples/graphicsview/diagramscene/images/pointer.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/sendtoback.png b/examples/graphicsview/diagramscene/images/sendtoback.png
deleted file mode 100644
index 5aa3b0a243..0000000000
--- a/examples/graphicsview/diagramscene/images/sendtoback.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/textpointer.png b/examples/graphicsview/diagramscene/images/textpointer.png
deleted file mode 100644
index b25832cada..0000000000
--- a/examples/graphicsview/diagramscene/images/textpointer.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/images/underline.png b/examples/graphicsview/diagramscene/images/underline.png
deleted file mode 100644
index 9b8209f525..0000000000
--- a/examples/graphicsview/diagramscene/images/underline.png
+++ /dev/null
Binary files differ
diff --git a/examples/graphicsview/diagramscene/main.cpp b/examples/graphicsview/diagramscene/main.cpp
deleted file mode 100644
index 33bc97b71f..0000000000
--- a/examples/graphicsview/diagramscene/main.cpp
+++ /dev/null
@@ -1,55 +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 "mainwindow.h"
-
-int main(int argv, char *args[])
-{
- Q_INIT_RESOURCE(diagramscene);
-
- QApplication app(argv, args);
- MainWindow mainWindow;
- mainWindow.setGeometry(100, 100, 800, 500);
- mainWindow.show();
-
- return app.exec();
-}
diff --git a/examples/graphicsview/diagramscene/mainwindow.cpp b/examples/graphicsview/diagramscene/mainwindow.cpp
deleted file mode 100644
index 977730a3bb..0000000000
--- a/examples/graphicsview/diagramscene/mainwindow.cpp
+++ /dev/null
@@ -1,661 +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 <QLabel>
-
-#include "mainwindow.h"
-#include "diagramitem.h"
-#include "diagramscene.h"
-#include "diagramtextitem.h"
-#include "arrow.h"
-
-const int InsertTextButton = 10;
-
-//! [0]
-MainWindow::MainWindow()
-{
- createActions();
- createToolBox();
- createMenus();
-
- scene = new DiagramScene(itemMenu, this);
- scene->setSceneRect(QRectF(0, 0, 5000, 5000));
- connect(scene, SIGNAL(itemInserted(DiagramItem*)),
- this, SLOT(itemInserted(DiagramItem*)));
- connect(scene, SIGNAL(textInserted(QGraphicsTextItem*)),
- this, SLOT(textInserted(QGraphicsTextItem*)));
- connect(scene, SIGNAL(itemSelected(QGraphicsItem*)),
- this, SLOT(itemSelected(QGraphicsItem*)));
- createToolbars();
-
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(toolBox);
- view = new QGraphicsView(scene);
- layout->addWidget(view);
-
- QWidget *widget = new QWidget;
- widget->setLayout(layout);
-
- setCentralWidget(widget);
- setWindowTitle(tr("Diagramscene"));
- setUnifiedTitleAndToolBarOnMac(true);
-}
-//! [0]
-
-//! [1]
-void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
-{
- QList<QAbstractButton *> buttons = backgroundButtonGroup->buttons();
- foreach (QAbstractButton *myButton, buttons) {
- if (myButton != button)
- button->setChecked(false);
- }
- QString text = button->text();
- if (text == tr("Blue Grid"))
- scene->setBackgroundBrush(QPixmap(":/images/background1.png"));
- else if (text == tr("White Grid"))
- scene->setBackgroundBrush(QPixmap(":/images/background2.png"));
- else if (text == tr("Gray Grid"))
- scene->setBackgroundBrush(QPixmap(":/images/background3.png"));
- else
- scene->setBackgroundBrush(QPixmap(":/images/background4.png"));
-
- scene->update();
- view->update();
-}
-//! [1]
-
-//! [2]
-void MainWindow::buttonGroupClicked(int id)
-{
- QList<QAbstractButton *> buttons = buttonGroup->buttons();
- foreach (QAbstractButton *button, buttons) {
- if (buttonGroup->button(id) != button)
- button->setChecked(false);
- }
- if (id == InsertTextButton) {
- scene->setMode(DiagramScene::InsertText);
- } else {
- scene->setItemType(DiagramItem::DiagramType(id));
- scene->setMode(DiagramScene::InsertItem);
- }
-}
-//! [2]
-
-//! [3]
-void MainWindow::deleteItem()
-{
- foreach (QGraphicsItem *item, scene->selectedItems()) {
- if (item->type() == Arrow::Type) {
- scene->removeItem(item);
- Arrow *arrow = qgraphicsitem_cast<Arrow *>(item);
- arrow->startItem()->removeArrow(arrow);
- arrow->endItem()->removeArrow(arrow);
- delete item;
- }
- }
-
- foreach (QGraphicsItem *item, scene->selectedItems()) {
- if (item->type() == DiagramItem::Type) {
- qgraphicsitem_cast<DiagramItem *>(item)->removeArrows();
- }
- scene->removeItem(item);
- delete item;
- }
-}
-//! [3]
-
-//! [4]
-void MainWindow::pointerGroupClicked(int)
-{
- scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
-}
-//! [4]
-
-//! [5]
-void MainWindow::bringToFront()
-{
- if (scene->selectedItems().isEmpty())
- return;
-
- QGraphicsItem *selectedItem = scene->selectedItems().first();
- QList<QGraphicsItem *> overlapItems = selectedItem->collidingItems();
-
- qreal zValue = 0;
- foreach (QGraphicsItem *item, overlapItems) {
- if (item->zValue() >= zValue &&
- item->type() == DiagramItem::Type)
- zValue = item->zValue() + 0.1;
- }
- selectedItem->setZValue(zValue);
-}
-//! [5]
-
-//! [6]
-void MainWindow::sendToBack()
-{
- if (scene->selectedItems().isEmpty())
- return;
-
- QGraphicsItem *selectedItem = scene->selectedItems().first();
- QList<QGraphicsItem *> overlapItems = selectedItem->collidingItems();
-
- qreal zValue = 0;
- foreach (QGraphicsItem *item, overlapItems) {
- if (item->zValue() <= zValue &&
- item->type() == DiagramItem::Type)
- zValue = item->zValue() - 0.1;
- }
- selectedItem->setZValue(zValue);
-}
-//! [6]
-
-//! [7]
-void MainWindow::itemInserted(DiagramItem *item)
-{
- pointerTypeGroup->button(int(DiagramScene::MoveItem))->setChecked(true);
- scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
- buttonGroup->button(int(item->diagramType()))->setChecked(false);
-}
-//! [7]
-
-//! [8]
-void MainWindow::textInserted(QGraphicsTextItem *)
-{
- buttonGroup->button(InsertTextButton)->setChecked(false);
- scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
-}
-//! [8]
-
-//! [9]
-void MainWindow::currentFontChanged(const QFont &)
-{
- handleFontChange();
-}
-//! [9]
-
-//! [10]
-void MainWindow::fontSizeChanged(const QString &)
-{
- handleFontChange();
-}
-//! [10]
-
-//! [11]
-void MainWindow::sceneScaleChanged(const QString &scale)
-{
- double newScale = scale.left(scale.indexOf(tr("%"))).toDouble() / 100.0;
- QMatrix oldMatrix = view->matrix();
- view->resetMatrix();
- view->translate(oldMatrix.dx(), oldMatrix.dy());
- view->scale(newScale, newScale);
-}
-//! [11]
-
-//! [12]
-void MainWindow::textColorChanged()
-{
- textAction = qobject_cast<QAction *>(sender());
- fontColorToolButton->setIcon(createColorToolButtonIcon(
- ":/images/textpointer.png",
- qvariant_cast<QColor>(textAction->data())));
- textButtonTriggered();
-}
-//! [12]
-
-//! [13]
-void MainWindow::itemColorChanged()
-{
- fillAction = qobject_cast<QAction *>(sender());
- fillColorToolButton->setIcon(createColorToolButtonIcon(
- ":/images/floodfill.png",
- qvariant_cast<QColor>(fillAction->data())));
- fillButtonTriggered();
-}
-//! [13]
-
-//! [14]
-void MainWindow::lineColorChanged()
-{
- lineAction = qobject_cast<QAction *>(sender());
- lineColorToolButton->setIcon(createColorToolButtonIcon(
- ":/images/linecolor.png",
- qvariant_cast<QColor>(lineAction->data())));
- lineButtonTriggered();
-}
-//! [14]
-
-//! [15]
-void MainWindow::textButtonTriggered()
-{
- scene->setTextColor(qvariant_cast<QColor>(textAction->data()));
-}
-//! [15]
-
-//! [16]
-void MainWindow::fillButtonTriggered()
-{
- scene->setItemColor(qvariant_cast<QColor>(fillAction->data()));
-}
-//! [16]
-
-//! [17]
-void MainWindow::lineButtonTriggered()
-{
- scene->setLineColor(qvariant_cast<QColor>(lineAction->data()));
-}
-//! [17]
-
-//! [18]
-void MainWindow::handleFontChange()
-{
- QFont font = fontCombo->currentFont();
- font.setPointSize(fontSizeCombo->currentText().toInt());
- font.setWeight(boldAction->isChecked() ? QFont::Bold : QFont::Normal);
- font.setItalic(italicAction->isChecked());
- font.setUnderline(underlineAction->isChecked());
-
- scene->setFont(font);
-}
-//! [18]
-
-//! [19]
-void MainWindow::itemSelected(QGraphicsItem *item)
-{
- DiagramTextItem *textItem =
- qgraphicsitem_cast<DiagramTextItem *>(item);
-
- QFont font = textItem->font();
- fontCombo->setCurrentFont(font);
- fontSizeCombo->setEditText(QString().setNum(font.pointSize()));
- boldAction->setChecked(font.weight() == QFont::Bold);
- italicAction->setChecked(font.italic());
- underlineAction->setChecked(font.underline());
-}
-//! [19]
-
-//! [20]
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Diagram Scene"),
- tr("The <b>Diagram Scene</b> example shows "
- "use of the graphics framework."));
-}
-//! [20]
-
-//! [21]
-void MainWindow::createToolBox()
-{
- buttonGroup = new QButtonGroup(this);
- buttonGroup->setExclusive(false);
- connect(buttonGroup, SIGNAL(buttonClicked(int)),
- this, SLOT(buttonGroupClicked(int)));
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(createCellWidget(tr("Conditional"),
- DiagramItem::Conditional), 0, 0);
- layout->addWidget(createCellWidget(tr("Process"),
- DiagramItem::Step),0, 1);
- layout->addWidget(createCellWidget(tr("Input/Output"),
- DiagramItem::Io), 1, 0);
-//! [21]
-
- QToolButton *textButton = new QToolButton;
- textButton->setCheckable(true);
- buttonGroup->addButton(textButton, InsertTextButton);
- textButton->setIcon(QIcon(QPixmap(":/images/textpointer.png")
- .scaled(30, 30)));
- textButton->setIconSize(QSize(50, 50));
- QGridLayout *textLayout = new QGridLayout;
- textLayout->addWidget(textButton, 0, 0, Qt::AlignHCenter);
- textLayout->addWidget(new QLabel(tr("Text")), 1, 0, Qt::AlignCenter);
- QWidget *textWidget = new QWidget;
- textWidget->setLayout(textLayout);
- layout->addWidget(textWidget, 1, 1);
-
- layout->setRowStretch(3, 10);
- layout->setColumnStretch(2, 10);
-
- QWidget *itemWidget = new QWidget;
- itemWidget->setLayout(layout);
-
- backgroundButtonGroup = new QButtonGroup(this);
- connect(backgroundButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)),
- this, SLOT(backgroundButtonGroupClicked(QAbstractButton*)));
-
- QGridLayout *backgroundLayout = new QGridLayout;
- backgroundLayout->addWidget(createBackgroundCellWidget(tr("Blue Grid"),
- ":/images/background1.png"), 0, 0);
- backgroundLayout->addWidget(createBackgroundCellWidget(tr("White Grid"),
- ":/images/background2.png"), 0, 1);
- backgroundLayout->addWidget(createBackgroundCellWidget(tr("Gray Grid"),
- ":/images/background3.png"), 1, 0);
- backgroundLayout->addWidget(createBackgroundCellWidget(tr("No Grid"),
- ":/images/background4.png"), 1, 1);
-
- backgroundLayout->setRowStretch(2, 10);
- backgroundLayout->setColumnStretch(2, 10);
-
- QWidget *backgroundWidget = new QWidget;
- backgroundWidget->setLayout(backgroundLayout);
-
-
-//! [22]
- toolBox = new QToolBox;
- toolBox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Ignored));
- toolBox->setMinimumWidth(itemWidget->sizeHint().width());
- toolBox->addItem(itemWidget, tr("Basic Flowchart Shapes"));
- toolBox->addItem(backgroundWidget, tr("Backgrounds"));
-}
-//! [22]
-
-//! [23]
-void MainWindow::createActions()
-{
- toFrontAction = new QAction(QIcon(":/images/bringtofront.png"),
- tr("Bring to &Front"), this);
- toFrontAction->setShortcut(tr("Ctrl+F"));
- toFrontAction->setStatusTip(tr("Bring item to front"));
- connect(toFrontAction, SIGNAL(triggered()),
- this, SLOT(bringToFront()));
-//! [23]
-
- sendBackAction = new QAction(QIcon(":/images/sendtoback.png"),
- tr("Send to &Back"), this);
- sendBackAction->setShortcut(tr("Ctrl+B"));
- sendBackAction->setStatusTip(tr("Send item to back"));
- connect(sendBackAction, SIGNAL(triggered()),
- this, SLOT(sendToBack()));
-
- deleteAction = new QAction(QIcon(":/images/delete.png"),
- tr("&Delete"), this);
- deleteAction->setShortcut(tr("Delete"));
- deleteAction->setStatusTip(tr("Delete item from diagram"));
- connect(deleteAction, SIGNAL(triggered()),
- this, SLOT(deleteItem()));
-
- exitAction = new QAction(tr("E&xit"), this);
- exitAction->setShortcuts(QKeySequence::Quit);
- exitAction->setStatusTip(tr("Quit Scenediagram example"));
- connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
-
- boldAction = new QAction(tr("Bold"), this);
- boldAction->setCheckable(true);
- QPixmap pixmap(":/images/bold.png");
- boldAction->setIcon(QIcon(pixmap));
- boldAction->setShortcut(tr("Ctrl+B"));
- connect(boldAction, SIGNAL(triggered()),
- this, SLOT(handleFontChange()));
-
- italicAction = new QAction(QIcon(":/images/italic.png"),
- tr("Italic"), this);
- italicAction->setCheckable(true);
- italicAction->setShortcut(tr("Ctrl+I"));
- connect(italicAction, SIGNAL(triggered()),
- this, SLOT(handleFontChange()));
-
- underlineAction = new QAction(QIcon(":/images/underline.png"),
- tr("Underline"), this);
- underlineAction->setCheckable(true);
- underlineAction->setShortcut(tr("Ctrl+U"));
- connect(underlineAction, SIGNAL(triggered()),
- this, SLOT(handleFontChange()));
-
- aboutAction = new QAction(tr("A&bout"), this);
- aboutAction->setShortcut(tr("Ctrl+B"));
- connect(aboutAction, SIGNAL(triggered()),
- this, SLOT(about()));
-}
-
-//! [24]
-void MainWindow::createMenus()
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(exitAction);
-
- itemMenu = menuBar()->addMenu(tr("&Item"));
- itemMenu->addAction(deleteAction);
- itemMenu->addSeparator();
- itemMenu->addAction(toFrontAction);
- itemMenu->addAction(sendBackAction);
-
- aboutMenu = menuBar()->addMenu(tr("&Help"));
- aboutMenu->addAction(aboutAction);
-}
-//! [24]
-
-//! [25]
-void MainWindow::createToolbars()
-{
-//! [25]
- editToolBar = addToolBar(tr("Edit"));
- editToolBar->addAction(deleteAction);
- editToolBar->addAction(toFrontAction);
- editToolBar->addAction(sendBackAction);
-
- fontCombo = new QFontComboBox();
- connect(fontCombo, SIGNAL(currentFontChanged(QFont)),
- this, SLOT(currentFontChanged(QFont)));
-
- fontSizeCombo = new QComboBox;
- fontSizeCombo->setEditable(true);
- for (int i = 8; i < 30; i = i + 2)
- fontSizeCombo->addItem(QString().setNum(i));
- QIntValidator *validator = new QIntValidator(2, 64, this);
- fontSizeCombo->setValidator(validator);
- connect(fontSizeCombo, SIGNAL(currentIndexChanged(QString)),
- this, SLOT(fontSizeChanged(QString)));
-
- fontColorToolButton = new QToolButton;
- fontColorToolButton->setPopupMode(QToolButton::MenuButtonPopup);
- fontColorToolButton->setMenu(createColorMenu(SLOT(textColorChanged()),
- Qt::black));
- textAction = fontColorToolButton->menu()->defaultAction();
- fontColorToolButton->setIcon(createColorToolButtonIcon(
- ":/images/textpointer.png", Qt::black));
- fontColorToolButton->setAutoFillBackground(true);
- connect(fontColorToolButton, SIGNAL(clicked()),
- this, SLOT(textButtonTriggered()));
-
-//! [26]
- fillColorToolButton = new QToolButton;
- fillColorToolButton->setPopupMode(QToolButton::MenuButtonPopup);
- fillColorToolButton->setMenu(createColorMenu(SLOT(itemColorChanged()),
- Qt::white));
- fillAction = fillColorToolButton->menu()->defaultAction();
- fillColorToolButton->setIcon(createColorToolButtonIcon(
- ":/images/floodfill.png", Qt::white));
- connect(fillColorToolButton, SIGNAL(clicked()),
- this, SLOT(fillButtonTriggered()));
-//! [26]
-
- lineColorToolButton = new QToolButton;
- lineColorToolButton->setPopupMode(QToolButton::MenuButtonPopup);
- lineColorToolButton->setMenu(createColorMenu(SLOT(lineColorChanged()),
- Qt::black));
- lineAction = lineColorToolButton->menu()->defaultAction();
- lineColorToolButton->setIcon(createColorToolButtonIcon(
- ":/images/linecolor.png", Qt::black));
- connect(lineColorToolButton, SIGNAL(clicked()),
- this, SLOT(lineButtonTriggered()));
-
- textToolBar = addToolBar(tr("Font"));
- textToolBar->addWidget(fontCombo);
- textToolBar->addWidget(fontSizeCombo);
- textToolBar->addAction(boldAction);
- textToolBar->addAction(italicAction);
- textToolBar->addAction(underlineAction);
-
- colorToolBar = addToolBar(tr("Color"));
- colorToolBar->addWidget(fontColorToolButton);
- colorToolBar->addWidget(fillColorToolButton);
- colorToolBar->addWidget(lineColorToolButton);
-
- QToolButton *pointerButton = new QToolButton;
- pointerButton->setCheckable(true);
- pointerButton->setChecked(true);
- pointerButton->setIcon(QIcon(":/images/pointer.png"));
- QToolButton *linePointerButton = new QToolButton;
- linePointerButton->setCheckable(true);
- linePointerButton->setIcon(QIcon(":/images/linepointer.png"));
-
- pointerTypeGroup = new QButtonGroup(this);
- pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem));
- pointerTypeGroup->addButton(linePointerButton,
- int(DiagramScene::InsertLine));
- connect(pointerTypeGroup, SIGNAL(buttonClicked(int)),
- this, SLOT(pointerGroupClicked(int)));
-
- sceneScaleCombo = new QComboBox;
- QStringList scales;
- scales << tr("50%") << tr("75%") << tr("100%") << tr("125%") << tr("150%");
- sceneScaleCombo->addItems(scales);
- sceneScaleCombo->setCurrentIndex(2);
- connect(sceneScaleCombo, SIGNAL(currentIndexChanged(QString)),
- this, SLOT(sceneScaleChanged(QString)));
-
- pointerToolbar = addToolBar(tr("Pointer type"));
- pointerToolbar->addWidget(pointerButton);
- pointerToolbar->addWidget(linePointerButton);
- pointerToolbar->addWidget(sceneScaleCombo);
-//! [27]
-}
-//! [27]
-
-//! [28]
-QWidget *MainWindow::createBackgroundCellWidget(const QString &text,
- const QString &image)
-{
- QToolButton *button = new QToolButton;
- button->setText(text);
- button->setIcon(QIcon(image));
- button->setIconSize(QSize(50, 50));
- button->setCheckable(true);
- backgroundButtonGroup->addButton(button);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(button, 0, 0, Qt::AlignHCenter);
- layout->addWidget(new QLabel(text), 1, 0, Qt::AlignCenter);
-
- QWidget *widget = new QWidget;
- widget->setLayout(layout);
-
- return widget;
-}
-//! [28]
-
-//! [29]
-QWidget *MainWindow::createCellWidget(const QString &text,
- DiagramItem::DiagramType type)
-{
-
- DiagramItem item(type, itemMenu);
- QIcon icon(item.image());
-
- QToolButton *button = new QToolButton;
- button->setIcon(icon);
- button->setIconSize(QSize(50, 50));
- button->setCheckable(true);
- buttonGroup->addButton(button, int(type));
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(button, 0, 0, Qt::AlignHCenter);
- layout->addWidget(new QLabel(text), 1, 0, Qt::AlignCenter);
-
- QWidget *widget = new QWidget;
- widget->setLayout(layout);
-
- return widget;
-}
-//! [29]
-
-//! [30]
-QMenu *MainWindow::createColorMenu(const char *slot, QColor defaultColor)
-{
- QList<QColor> colors;
- colors << Qt::black << Qt::white << Qt::red << Qt::blue << Qt::yellow;
- QStringList names;
- names << tr("black") << tr("white") << tr("red") << tr("blue")
- << tr("yellow");
-
- QMenu *colorMenu = new QMenu(this);
- for (int i = 0; i < colors.count(); ++i) {
- QAction *action = new QAction(names.at(i), this);
- action->setData(colors.at(i));
- action->setIcon(createColorIcon(colors.at(i)));
- connect(action, SIGNAL(triggered()),
- this, slot);
- colorMenu->addAction(action);
- if (colors.at(i) == defaultColor) {
- colorMenu->setDefaultAction(action);
- }
- }
- return colorMenu;
-}
-//! [30]
-
-//! [31]
-QIcon MainWindow::createColorToolButtonIcon(const QString &imageFile,
- QColor color)
-{
- QPixmap pixmap(50, 80);
- pixmap.fill(Qt::transparent);
- QPainter painter(&pixmap);
- QPixmap image(imageFile);
- QRect target(0, 0, 50, 60);
- QRect source(0, 0, 42, 42);
- painter.fillRect(QRect(0, 60, 50, 80), color);
- painter.drawPixmap(target, image, source);
-
- return QIcon(pixmap);
-}
-//! [31]
-
-//! [32]
-QIcon MainWindow::createColorIcon(QColor color)
-{
- QPixmap pixmap(20, 20);
- QPainter painter(&pixmap);
- painter.setPen(Qt::NoPen);
- painter.fillRect(QRect(0, 0, 20, 20), color);
-
- return QIcon(pixmap);
-}
-//! [32]
diff --git a/examples/graphicsview/diagramscene/mainwindow.h b/examples/graphicsview/diagramscene/mainwindow.h
deleted file mode 100644
index e3c0496c79..0000000000
--- a/examples/graphicsview/diagramscene/mainwindow.h
+++ /dev/null
@@ -1,150 +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 MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-#include "diagramitem.h"
-
-class DiagramScene;
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QToolBox;
-class QSpinBox;
-class QComboBox;
-class QFontComboBox;
-class QButtonGroup;
-class QLineEdit;
-class QGraphicsTextItem;
-class QFont;
-class QToolButton;
-class QAbstractButton;
-class QGraphicsView;
-QT_END_NAMESPACE
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-private slots:
- void backgroundButtonGroupClicked(QAbstractButton *button);
- void buttonGroupClicked(int id);
- void deleteItem();
- void pointerGroupClicked(int id);
- void bringToFront();
- void sendToBack();
- void itemInserted(DiagramItem *item);
- void textInserted(QGraphicsTextItem *item);
- void currentFontChanged(const QFont &font);
- void fontSizeChanged(const QString &size);
- void sceneScaleChanged(const QString &scale);
- void textColorChanged();
- void itemColorChanged();
- void lineColorChanged();
- void textButtonTriggered();
- void fillButtonTriggered();
- void lineButtonTriggered();
- void handleFontChange();
- void itemSelected(QGraphicsItem *item);
- void about();
-
-private:
- void createToolBox();
- void createActions();
- void createMenus();
- void createToolbars();
- QWidget *createBackgroundCellWidget(const QString &text,
- const QString &image);
- QWidget *createCellWidget(const QString &text,
- DiagramItem::DiagramType type);
- QMenu *createColorMenu(const char *slot, QColor defaultColor);
- QIcon createColorToolButtonIcon(const QString &image, QColor color);
- QIcon createColorIcon(QColor color);
-
- DiagramScene *scene;
- QGraphicsView *view;
-
- QAction *exitAction;
- QAction *addAction;
- QAction *deleteAction;
-
- QAction *toFrontAction;
- QAction *sendBackAction;
- QAction *aboutAction;
-
- QMenu *fileMenu;
- QMenu *itemMenu;
- QMenu *aboutMenu;
-
- QToolBar *textToolBar;
- QToolBar *editToolBar;
- QToolBar *colorToolBar;
- QToolBar *pointerToolbar;
-
- QComboBox *sceneScaleCombo;
- QComboBox *itemColorCombo;
- QComboBox *textColorCombo;
- QComboBox *fontSizeCombo;
- QFontComboBox *fontCombo;
-
- QToolBox *toolBox;
- QButtonGroup *buttonGroup;
- QButtonGroup *pointerTypeGroup;
- QButtonGroup *backgroundButtonGroup;
- QToolButton *fontColorToolButton;
- QToolButton *fillColorToolButton;
- QToolButton *lineColorToolButton;
- QAction *boldAction;
- QAction *underlineAction;
- QAction *italicAction;
- QAction *textAction;
- QAction *fillAction;
- QAction *lineAction;
-};
-//! [0]
-
-#endif