summaryrefslogtreecommitdiffstats
path: root/examples/graphicsview
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2011-04-27 19:16:41 +0200
committerDavid Boddie <david.boddie@nokia.com>2011-05-23 14:24:07 +0200
commit0748751c9f097d9d866605306bbdd4b96e2a5c4e (patch)
tree1838365e6ad6592a26e193289d2136cb89319972 /examples/graphicsview
parent5feefb0c039dae04290d1fca7c2f24276b6f7582 (diff)
Squashed commit of the changes from the mobile-examples repository
(4.7-generated-declarative branch).
Diffstat (limited to 'examples/graphicsview')
-rw-r--r--examples/graphicsview/anchorlayout/anchorlayout.pro5
-rw-r--r--examples/graphicsview/anchorlayout/main.cpp5
-rw-r--r--examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro2
-rw-r--r--examples/graphicsview/basicgraphicslayouts/main.cpp4
-rw-r--r--examples/graphicsview/collidingmice/collidingmice.pro2
-rw-r--r--examples/graphicsview/collidingmice/main.cpp4
-rw-r--r--examples/graphicsview/diagramscene/diagramscene.pro4
-rw-r--r--examples/graphicsview/dragdroprobot/dragdroprobot.pro3
-rw-r--r--examples/graphicsview/dragdroprobot/main.cpp24
-rw-r--r--examples/graphicsview/elasticnodes/edge.cpp2
-rw-r--r--examples/graphicsview/elasticnodes/elasticnodes.pro3
-rw-r--r--examples/graphicsview/elasticnodes/graphwidget.cpp29
-rw-r--r--examples/graphicsview/elasticnodes/graphwidget.h5
-rw-r--r--examples/graphicsview/elasticnodes/main.cpp15
-rw-r--r--examples/graphicsview/elasticnodes/node.cpp15
-rw-r--r--examples/graphicsview/flowlayout/flowlayout.pro5
-rw-r--r--examples/graphicsview/flowlayout/main.cpp6
-rw-r--r--examples/graphicsview/graphicsview.pro1
-rw-r--r--examples/graphicsview/padnavigator/main.cpp5
-rw-r--r--examples/graphicsview/padnavigator/padnavigator.pro3
-rw-r--r--examples/graphicsview/simpleanchorlayout/main.cpp7
-rw-r--r--examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro4
-rw-r--r--examples/graphicsview/weatheranchorlayout/main.cpp23
-rw-r--r--examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro3
24 files changed, 165 insertions, 14 deletions
diff --git a/examples/graphicsview/anchorlayout/anchorlayout.pro b/examples/graphicsview/anchorlayout/anchorlayout.pro
index 52cb13b241..eb83890f34 100644
--- a/examples/graphicsview/anchorlayout/anchorlayout.pro
+++ b/examples/graphicsview/anchorlayout/anchorlayout.pro
@@ -7,3 +7,8 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/anchorlayout
INSTALLS += target sources
TARGET = anchorlayout
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
+
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp
index c31afd214d..dbe9f19880 100644
--- a/examples/graphicsview/anchorlayout/main.cpp
+++ b/examples/graphicsview/anchorlayout/main.cpp
@@ -122,7 +122,12 @@ int main(int argc, char **argv)
scene.addItem(w);
scene.setBackgroundBrush(Qt::darkGreen);
QGraphicsView view(&scene);
+
+#if defined(Q_WS_S60)
+ view.showMaximized();
+#else
view.show();
+#endif
return app.exec();
}
diff --git a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro
index 8b667387a0..7d0ed4a8cc 100644
--- a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro
+++ b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro
@@ -15,3 +15,5 @@ symbian {
TARGET.UID3 = 0xA000A645
CONFIG += qt_example
}
+maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/basicgraphicslayouts/main.cpp b/examples/graphicsview/basicgraphicslayouts/main.cpp
index 57448a58d7..11da1838f3 100644
--- a/examples/graphicsview/basicgraphicslayouts/main.cpp
+++ b/examples/graphicsview/basicgraphicslayouts/main.cpp
@@ -51,8 +51,12 @@ int main(int argc, char **argv)
Window *window = new Window;
scene.addItem(window);
QGraphicsView view(&scene);
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
+ view.showMaximized();
+#else
view.resize(600, 600);
view.show();
+#endif
return app.exec();
}
diff --git a/examples/graphicsview/collidingmice/collidingmice.pro b/examples/graphicsview/collidingmice/collidingmice.pro
index b49f44be4c..ea2b0d7cdf 100644
--- a/examples/graphicsview/collidingmice/collidingmice.pro
+++ b/examples/graphicsview/collidingmice/collidingmice.pro
@@ -17,3 +17,5 @@ symbian {
TARGET.UID3 = 0xA000A643
CONFIG += qt_example
}
+maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/collidingmice/main.cpp b/examples/graphicsview/collidingmice/main.cpp
index 2970a0079f..43594029fa 100644
--- a/examples/graphicsview/collidingmice/main.cpp
+++ b/examples/graphicsview/collidingmice/main.cpp
@@ -79,8 +79,12 @@ int main(int argc, char **argv)
view.setDragMode(QGraphicsView::ScrollHandDrag);
//! [5] //! [6]
view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
+ view.showMaximized();
+#else
view.resize(400, 300);
view.show();
+#endif
QTimer timer;
QObject::connect(&timer, SIGNAL(timeout()), &scene, SLOT(advance()));
diff --git a/examples/graphicsview/diagramscene/diagramscene.pro b/examples/graphicsview/diagramscene/diagramscene.pro
index 6af1160015..0703365d07 100644
--- a/examples/graphicsview/diagramscene/diagramscene.pro
+++ b/examples/graphicsview/diagramscene/diagramscene.pro
@@ -19,4 +19,8 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/diagramscene
INSTALLS += target sources
symbian: CONFIG += qt_example
+maemo5: CONFIG += qt_example
+symbian: warning(This example might not fully work on Symbian platform)
+maemo5: warning(This example might not fully work on Maemo platform)
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/dragdroprobot/dragdroprobot.pro b/examples/graphicsview/dragdroprobot/dragdroprobot.pro
index 5240b4208f..0fe241dbd2 100644
--- a/examples/graphicsview/dragdroprobot/dragdroprobot.pro
+++ b/examples/graphicsview/dragdroprobot/dragdroprobot.pro
@@ -18,3 +18,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/dragdroprobot
INSTALLS += target sources
symbian: CONFIG += qt_example
+maemo5: CONFIG += qt_example
+
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/dragdroprobot/main.cpp b/examples/graphicsview/dragdroprobot/main.cpp
index 315d2b6917..c8b84ecb97 100644
--- a/examples/graphicsview/dragdroprobot/main.cpp
+++ b/examples/graphicsview/dragdroprobot/main.cpp
@@ -45,6 +45,22 @@
#include <math.h>
+class GraphicsView : public QGraphicsView
+{
+public:
+ GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene)
+ {
+ }
+
+protected:
+ virtual void resizeEvent(QResizeEvent *event)
+ {
+#if defined(Q_OS_SYMBIAN)
+ fitInView(sceneRect(), Qt::KeepAspectRatio);
+#endif
+ }
+};
+
//! [0]
int main(int argc, char **argv)
{
@@ -69,12 +85,16 @@ int main(int argc, char **argv)
scene.addItem(robot);
//! [1]
//! [2]
- QGraphicsView view(&scene);
+ 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();
+#if defined(Q_OS_SYMBIAN)
+ view.showMaximized();
+#else
+ view.show();
+#endif
return app.exec();
}
diff --git a/examples/graphicsview/elasticnodes/edge.cpp b/examples/graphicsview/elasticnodes/edge.cpp
index 2b5cae5e1b..652ab737fc 100644
--- a/examples/graphicsview/elasticnodes/edge.cpp
+++ b/examples/graphicsview/elasticnodes/edge.cpp
@@ -144,6 +144,6 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
painter->setBrush(Qt::black);
painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2);
- painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
+ painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
}
//! [6]
diff --git a/examples/graphicsview/elasticnodes/elasticnodes.pro b/examples/graphicsview/elasticnodes/elasticnodes.pro
index 208c849d13..7a58dd162b 100644
--- a/examples/graphicsview/elasticnodes/elasticnodes.pro
+++ b/examples/graphicsview/elasticnodes/elasticnodes.pro
@@ -21,3 +21,6 @@ symbian {
TARGET.UID3 = 0xA000A642
CONFIG += qt_example
}
+maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
+
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/elasticnodes/graphwidget.cpp b/examples/graphicsview/elasticnodes/graphwidget.cpp
index c875b6551d..f6bf05de31 100644
--- a/examples/graphicsview/elasticnodes/graphwidget.cpp
+++ b/examples/graphicsview/elasticnodes/graphwidget.cpp
@@ -132,17 +132,14 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
centerNode->moveBy(20, 0);
break;
case Qt::Key_Plus:
- scaleView(qreal(1.2));
+ zoomIn();
break;
case Qt::Key_Minus:
- scaleView(1 / qreal(1.2));
+ zoomOut();
break;
case Qt::Key_Space:
case Qt::Key_Enter:
- foreach (QGraphicsItem *item, scene()->items()) {
- if (qgraphicsitem_cast<Node *>(item))
- item->setPos(-150 + qrand() % 300, -150 + qrand() % 300);
- }
+ shuffle();
break;
default:
QGraphicsView::keyPressEvent(event);
@@ -206,6 +203,7 @@ void GraphWidget::drawBackground(QPainter *painter, const QRectF &rect)
painter->setBrush(Qt::NoBrush);
painter->drawRect(sceneRect);
+#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5)
// Text
QRectF textRect(sceneRect.left() + 4, sceneRect.top() + 4,
sceneRect.width() - 4, sceneRect.height() - 4);
@@ -220,6 +218,7 @@ void GraphWidget::drawBackground(QPainter *painter, const QRectF &rect)
painter->drawText(textRect.translated(2, 2), message);
painter->setPen(Qt::black);
painter->drawText(textRect, message);
+#endif
}
//! [6]
@@ -233,3 +232,21 @@ void GraphWidget::scaleView(qreal scaleFactor)
scale(scaleFactor, scaleFactor);
}
//! [7]
+
+void GraphWidget::shuffle()
+{
+ foreach (QGraphicsItem *item, scene()->items()) {
+ if (qgraphicsitem_cast<Node *>(item))
+ item->setPos(-150 + qrand() % 300, -150 + qrand() % 300);
+ }
+}
+
+void GraphWidget::zoomIn()
+{
+ scaleView(qreal(1.2));
+}
+
+void GraphWidget::zoomOut()
+{
+ scaleView(1 / qreal(1.2));
+}
diff --git a/examples/graphicsview/elasticnodes/graphwidget.h b/examples/graphicsview/elasticnodes/graphwidget.h
index 764bb3f0b9..524ef67b8a 100644
--- a/examples/graphicsview/elasticnodes/graphwidget.h
+++ b/examples/graphicsview/elasticnodes/graphwidget.h
@@ -55,6 +55,11 @@ public:
void itemMoved();
+public slots:
+ void shuffle();
+ void zoomIn();
+ void zoomOut();
+
protected:
void keyPressEvent(QKeyEvent *event);
void timerEvent(QTimerEvent *event);
diff --git a/examples/graphicsview/elasticnodes/main.cpp b/examples/graphicsview/elasticnodes/main.cpp
index ab7e7cf7c7..d653da5355 100644
--- a/examples/graphicsview/elasticnodes/main.cpp
+++ b/examples/graphicsview/elasticnodes/main.cpp
@@ -47,7 +47,18 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
- GraphWidget widget;
- widget.show();
+ GraphWidget *widget = new GraphWidget;
+
+ QMainWindow mainWindow;
+ mainWindow.setCentralWidget(widget);
+
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+ mainWindow.menuBar()->addAction("Shuffle", widget, SLOT(shuffle()));
+ mainWindow.menuBar()->addAction("Zoom In", widget, SLOT(zoomIn()));
+ mainWindow.menuBar()->addAction("Zoom Out", widget, SLOT(zoomOut()));
+ mainWindow.showMaximized();
+#else
+ mainWindow.show();
+#endif
return app.exec();
}
diff --git a/examples/graphicsview/elasticnodes/node.cpp b/examples/graphicsview/elasticnodes/node.cpp
index 8d1daddc12..b345f83640 100644
--- a/examples/graphicsview/elasticnodes/node.cpp
+++ b/examples/graphicsview/elasticnodes/node.cpp
@@ -141,9 +141,16 @@ bool Node::advance()
//! [8]
QRectF Node::boundingRect() const
{
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+ // Add some extra space around the circle for easier touching with finger
+ qreal adjust = 30;
+ return QRectF( -10 - adjust, -10 - adjust,
+ 20 + adjust * 2, 20 + adjust * 2);
+#else
qreal adjust = 2;
- return QRectF(-10 - adjust, -10 - adjust,
+ return QRectF( -10 - adjust, -10 - adjust,
23 + adjust, 23 + adjust);
+#endif
}
//! [8]
@@ -151,7 +158,12 @@ QRectF Node::boundingRect() const
QPainterPath Node::shape() const
{
QPainterPath path;
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+ // Add some extra space around the circle for easier touching with finger
+ path.addEllipse( -40, -40, 80, 80);
+#else
path.addEllipse(-10, -10, 20, 20);
+#endif
return path;
}
//! [9]
@@ -174,6 +186,7 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
gradient.setColorAt(1, Qt::darkYellow);
}
painter->setBrush(gradient);
+
painter->setPen(QPen(Qt::black, 0));
painter->drawEllipse(-10, -10, 20, 20);
}
diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro
index ce3536774b..8a97d2dc79 100644
--- a/examples/graphicsview/flowlayout/flowlayout.pro
+++ b/examples/graphicsview/flowlayout/flowlayout.pro
@@ -1,5 +1,4 @@
TEMPLATE = app
-TARGET =
DEPENDPATH += .
INCLUDEPATH += .
@@ -8,3 +7,7 @@ QMAKE_PROJECT_NAME = flowlayout_graphicsview
# Input
HEADERS += flowlayout.h window.h
SOURCES += flowlayout.cpp main.cpp window.cpp
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp
index cee08d76ac..cc5eeb6175 100644
--- a/examples/graphicsview/flowlayout/main.cpp
+++ b/examples/graphicsview/flowlayout/main.cpp
@@ -49,7 +49,13 @@ int main(int argc, char **argv)
QGraphicsView *view = new QGraphicsView(&scene);
Window *w = new Window;
scene.addItem(w);
+
+#if defined(Q_OS_SYMBIAN)
+ view->showMaximized();
+#else
view->resize(400, 300);
view->show();
+#endif
+
return app.exec();
}
diff --git a/examples/graphicsview/graphicsview.pro b/examples/graphicsview/graphicsview.pro
index a1458ded91..d1b0e86e7f 100644
--- a/examples/graphicsview/graphicsview.pro
+++ b/examples/graphicsview/graphicsview.pro
@@ -22,3 +22,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview
INSTALLS += target sources
symbian: CONFIG += qt_example
+maemo5: CONFIG += qt_example
diff --git a/examples/graphicsview/padnavigator/main.cpp b/examples/graphicsview/padnavigator/main.cpp
index 8f4a681743..d7d2f56305 100644
--- a/examples/graphicsview/padnavigator/main.cpp
+++ b/examples/graphicsview/padnavigator/main.cpp
@@ -49,8 +49,11 @@ int main(int argc, char *argv[])
Q_INIT_RESOURCE(padnavigator);
PadNavigator navigator(QSize(3, 3));
+#if defined(Q_OS_SYMBIAN)
+ navigator.showMaximized();
+#else
navigator.show();
-
+#endif
return app.exec();
}
//! [0]
diff --git a/examples/graphicsview/padnavigator/padnavigator.pro b/examples/graphicsview/padnavigator/padnavigator.pro
index 45ebfdcf2a..a51571f705 100644
--- a/examples/graphicsview/padnavigator/padnavigator.pro
+++ b/examples/graphicsview/padnavigator/padnavigator.pro
@@ -30,3 +30,6 @@ symbian {
TARGET.UID3 = 0xA000A644
CONFIG += qt_example
}
+maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
+
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/simpleanchorlayout/main.cpp b/examples/graphicsview/simpleanchorlayout/main.cpp
index 4fa837f540..cba37d9fb7 100644
--- a/examples/graphicsview/simpleanchorlayout/main.cpp
+++ b/examples/graphicsview/simpleanchorlayout/main.cpp
@@ -126,8 +126,15 @@ int main(int argc, char *argv[])
QGraphicsView *view = new QGraphicsView();
view->setScene(scene);
view->setWindowTitle(QApplication::translate("simpleanchorlayout", "Simple Anchor Layout"));
+
+#if defined(Q_OS_SYMBIAN)
+ view->showMaximized();
+#elif defined(Q_WS_MAEMO_5)
+ view-show();
+#else
view->resize(360, 320);
view->show();
+#endif
return app.exec();
}
diff --git a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro
index f85ad8f3a7..6ba525e26c 100644
--- a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro
+++ b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro
@@ -7,3 +7,7 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/simpleanchorlayout
INSTALLS += target sources
TARGET = simpleanchorlayout
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/examples/graphicsview/weatheranchorlayout/main.cpp b/examples/graphicsview/weatheranchorlayout/main.cpp
index 67596ac4bc..b1f2c724a1 100644
--- a/examples/graphicsview/weatheranchorlayout/main.cpp
+++ b/examples/graphicsview/weatheranchorlayout/main.cpp
@@ -51,6 +51,21 @@
#include <QGraphicsSceneResizeEvent>
+class GraphicsView : public QGraphicsView
+{
+public:
+ GraphicsView(QGraphicsScene *scene, QGraphicsWidget *widget) : QGraphicsView(scene), w(widget)
+ {
+ }
+
+ virtual void resizeEvent(QResizeEvent *event)
+ {
+ w->setGeometry(0, 0, event->size().width(), event->size().height());
+ }
+
+ QGraphicsWidget *w;
+};
+
class PixmapWidget : public QGraphicsLayoutItem
{
@@ -175,7 +190,10 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
QGraphicsScene scene;
+#if defined(Q_OS_SYMBIAN)
+#else
scene.setSceneRect(0, 0, 800, 480);
+#endif
// pixmaps widgets
PixmapWidget *title = new PixmapWidget(QPixmap(":/images/title.jpg"));
@@ -250,8 +268,13 @@ int main(int argc, char **argv)
// QGV setup
scene.addItem(w);
scene.setBackgroundBrush(Qt::white);
+#if defined(Q_OS_SYMBIAN)
+ GraphicsView *view = new GraphicsView(&scene, w);
+ view->showMaximized();
+#else
QGraphicsView *view = new QGraphicsView(&scene);
view->show();
+#endif
return app.exec();
}
diff --git a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro
index 57e154e27a..f07b7dfca8 100644
--- a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro
+++ b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro
@@ -12,3 +12,6 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES weatheranchorlayout.pro images
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/weatheranchorlayout
INSTALLS += target sources
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
+simulator: warning(This example might not fully work on Simulator platform)