summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2009-12-11 17:10:43 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2009-12-11 17:10:43 (GMT)
commitb77bd0095345d28f8aaee199c0a1d53457e2ad3f (patch)
tree6ebd8d8e7f2aaa8c477858a746e425d3aaf7c659 /tests
parentc028faac186125565a1e92782da0bd9c3f72c68a (diff)
parentc15c9cd2356eaeba33a5f8e62a90b0aeb45284e1 (diff)
downloadQt-b77bd0095345d28f8aaee199c0a1d53457e2ad3f.zip
Qt-b77bd0095345d28f8aaee199c0a1d53457e2ad3f.tar.gz
Qt-b77bd0095345d28f8aaee199c0a1d53457e2ad3f.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into qt-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fixes cursor blinking in the QComboBox when it becomes editable while having the focus. Add missing benchmark to the benchmarks.pro Itemviews: we needed to call ensurePolishedwhen asking for sizehints Fixes Graphicsitem transformation problems when grouping/ungrouping. Add a simple check for a common wrong usage to avoid infinite recursion Fixed invalid read in QCache::unlink after recent change. Initial documentation for the performance characteristics of QPainter. Fixed qgraphicseffectsource autotest.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp20
-rw-r--r--tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp30
-rw-r--r--tests/benchmarks/benchmarks.pro20
-rw-r--r--tests/manual/qgraphicsitemgroup/customitem.cpp107
-rw-r--r--tests/manual/qgraphicsitemgroup/customitem.h77
-rw-r--r--tests/manual/qgraphicsitemgroup/main.cpp51
-rw-r--r--tests/manual/qgraphicsitemgroup/qgraphicsitemgroup.pro8
-rw-r--r--tests/manual/qgraphicsitemgroup/widget.cpp260
-rw-r--r--tests/manual/qgraphicsitemgroup/widget.h93
-rw-r--r--tests/manual/qgraphicsitemgroup/widget.ui319
11 files changed, 985 insertions, 2 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 6e78522..1cb9f0d 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -90,6 +90,7 @@ private slots:
void parallelToHalfLayout();
void globalSpacing();
void graphicsAnchorHandling();
+ void invalidHierarchyCheck();
};
class RectWidget : public QGraphicsWidget
@@ -2058,5 +2059,24 @@ void tst_QGraphicsAnchorLayout::graphicsAnchorHandling()
delete a;
}
+void tst_QGraphicsAnchorLayout::invalidHierarchyCheck()
+{
+ QGraphicsWidget window(0, Qt::Window);
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ window.setLayout(l);
+
+ QCOMPARE(l->count(), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): "
+ "You cannot add the parent of the layout to the layout.");
+ QVERIFY(!l->addAnchor(l, Qt::AnchorLeft, &window, Qt::AnchorLeft));
+ QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): "
+ "You cannot add the parent of the layout to the layout.");
+ l->addAnchors(l, &window);
+ QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): "
+ "You cannot add the parent of the layout to the layout.");
+ l->addCornerAnchors(l, Qt::TopLeftCorner, &window, Qt::TopLeftCorner);
+ QCOMPARE(l->count(), 0);
+}
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"
diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
index 9991ab4..7a0d40a 100644
--- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
+++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
@@ -352,7 +352,7 @@ void tst_QGraphicsEffectSource::pixmapPadding_data()
QTest::newRow("log,effectrect") << int(Qt::LogicalCoordinates)
<< int(QGraphicsEffect::PadToEffectiveBoundingRect)
- << QSize(30, 30) << QPoint(-10, -10)
+ << QSize(20, 20) << QPoint(-5, -5)
<< 0x00000000u;
QTest::newRow("dev,nopad") << int(Qt::DeviceCoordinates)
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 3e7a2eb..a4931ab 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -318,6 +318,7 @@ private slots:
void childrenBoundingRect3();
void group();
void setGroup();
+ void setGroup2();
void nestedGroups();
void warpChildrenIntoGroup();
void removeFromGroup();
@@ -3345,6 +3346,35 @@ void tst_QGraphicsItem::setGroup()
QCOMPARE(rect->parentItem(), (QGraphicsItem *)0);
}
+void tst_QGraphicsItem::setGroup2()
+{
+ QGraphicsScene scene;
+ QGraphicsItemGroup group;
+ scene.addItem(&group);
+
+ QGraphicsRectItem *rect = scene.addRect(50,50,50,50,Qt::NoPen,Qt::black);
+ rect->setTransformOriginPoint(50,50);
+ rect->setRotation(45);
+ rect->setScale(1.5);
+ rect->translate(20,20);
+ group.translate(-30,-40);
+ group.setRotation(180);
+ group.setScale(0.5);
+
+ QTransform oldSceneTransform = rect->sceneTransform();
+ rect->setGroup(&group);
+ QCOMPARE(rect->sceneTransform(), oldSceneTransform);
+
+ group.setRotation(20);
+ group.setScale(2);
+ rect->setRotation(90);
+ rect->setScale(0.8);
+
+ oldSceneTransform = rect->sceneTransform();
+ rect->setGroup(0);
+ QCOMPARE(rect->sceneTransform(), oldSceneTransform);
+}
+
void tst_QGraphicsItem::nestedGroups()
{
QGraphicsItemGroup *group1 = new QGraphicsItemGroup;
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index 9170039..bffa009 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -20,6 +20,24 @@ SUBDIRS = containers-associative \
qregion \
qvariant \
qwidget \
- qtwidgets
+ qtwidgets \
+ qapplication \
+ qdir \
+ qdiriterator \
+ qgraphicsanchorlayout \
+ qgraphicsitem \
+ qgraphicswidget \
+ qmetaobject \
+ qpixmapcache \
+ qquaternion \
+ qscriptclass \
+ qscriptengine \
+ qscriptvalue \
+ qstringbuilder \
+ qstylesheetstyle \
+ qsvgrenderer \
+ qtableview
+
+
contains(QT_CONFIG, opengl): SUBDIRS += opengl
diff --git a/tests/manual/qgraphicsitemgroup/customitem.cpp b/tests/manual/qgraphicsitemgroup/customitem.cpp
new file mode 100644
index 0000000..16da0c5
--- /dev/null
+++ b/tests/manual/qgraphicsitemgroup/customitem.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "customitem.h"
+
+#include <QPainter>
+#include <QStyle>
+#include <QStyleOption>
+
+QList<CustomGroup*> CustomScene::selectedCustomGroups() const
+{
+ QList<QGraphicsItem*> all = selectedItems();
+ QList<CustomGroup*> groups;
+
+ foreach (QGraphicsItem *item, all) {
+ CustomGroup* group = dynamic_cast<CustomGroup*>(item);
+ if (group)
+ groups.append(group);
+ }
+
+ return groups;
+}
+
+QList<CustomItem*> CustomScene::selectedCustomItems() const
+{
+ QList<QGraphicsItem*> all = selectedItems();
+ QList<CustomItem*> items;
+
+ foreach (QGraphicsItem *item, all) {
+ CustomItem* citem = dynamic_cast<CustomItem*>(item);
+ if (citem)
+ items.append(citem);
+ }
+
+ return items;
+}
+
+CustomGroup::CustomGroup() :
+ QGraphicsItemGroup()
+{
+ setFlag(QGraphicsItem::ItemIsMovable);
+ setFlag(QGraphicsItem::ItemIsSelectable);
+}
+
+void CustomGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ if (option->state & QStyle::State_Selected)
+ painter->setOpacity(1.);
+ else
+ painter->setOpacity(0.2);
+
+ painter->setPen(QPen(QColor(100, 100, 100), 2, Qt::DashLine));
+ painter->drawRect(boundingRect().adjusted(-2, -2, 2, 2));
+}
+
+QRectF CustomGroup::boundingRect() const
+{
+ return QGraphicsItemGroup::boundingRect().adjusted(-4, -4, 4 ,4);
+}
+
+CustomItem::CustomItem(qreal x, qreal y, qreal width, qreal height, const QBrush &brush) :
+ QGraphicsRectItem(x, y, width, height)
+{
+ setFlag(QGraphicsItem::ItemIsMovable);
+ setFlag(QGraphicsItem::ItemIsSelectable);
+ setBrush(brush);
+ setPen(Qt::NoPen);
+ setTransformOriginPoint(boundingRect().center());
+}
diff --git a/tests/manual/qgraphicsitemgroup/customitem.h b/tests/manual/qgraphicsitemgroup/customitem.h
new file mode 100644
index 0000000..387c8ce
--- /dev/null
+++ b/tests/manual/qgraphicsitemgroup/customitem.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CUSTOMITEM_H
+#define CUSTOMITEM_H
+
+#include <QGraphicsItem>
+#include <QBrush>
+#include <QGraphicsScene>
+
+class CustomGroup : public QGraphicsItemGroup
+{
+public:
+ CustomGroup();
+ virtual ~CustomGroup() { }
+
+protected:
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ virtual QRectF boundingRect() const;
+};
+
+class CustomItem : public QGraphicsRectItem
+{
+public:
+ CustomItem(qreal x, qreal y, qreal width, qreal height, const QBrush & brush = QBrush());
+ virtual ~CustomItem() { }
+};
+
+class CustomScene : public QGraphicsScene
+{
+ Q_OBJECT
+public:
+ CustomScene() : QGraphicsScene() { }
+
+ QList<CustomItem*> selectedCustomItems() const;
+ QList<CustomGroup*> selectedCustomGroups() const;
+};
+
+#endif // CUSTOMITEM_H
diff --git a/tests/manual/qgraphicsitemgroup/main.cpp b/tests/manual/qgraphicsitemgroup/main.cpp
new file mode 100644
index 0000000..e7a6e11
--- /dev/null
+++ b/tests/manual/qgraphicsitemgroup/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QApplication>
+#include "widget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/tests/manual/qgraphicsitemgroup/qgraphicsitemgroup.pro b/tests/manual/qgraphicsitemgroup/qgraphicsitemgroup.pro
new file mode 100644
index 0000000..6676a2e
--- /dev/null
+++ b/tests/manual/qgraphicsitemgroup/qgraphicsitemgroup.pro
@@ -0,0 +1,8 @@
+TARGET = qgraphicsitemgroup
+TEMPLATE = app
+SOURCES += main.cpp \
+ widget.cpp \
+ customitem.cpp
+HEADERS += widget.h \
+ customitem.h
+FORMS += widget.ui
diff --git a/tests/manual/qgraphicsitemgroup/widget.cpp b/tests/manual/qgraphicsitemgroup/widget.cpp
new file mode 100644
index 0000000..23bee3f
--- /dev/null
+++ b/tests/manual/qgraphicsitemgroup/widget.cpp
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "widget.h"
+#include "ui_widget.h"
+#include <QGraphicsOpacityEffect>
+#include <QPropertyAnimation>
+
+Widget::Widget(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::Widget),
+ previousSelectionCount(0)
+{
+ ui->setupUi(this);
+
+ effect = new QGraphicsOpacityEffect;
+ effect->setOpacity(0.3);
+ ui->groupBox->setGraphicsEffect(effect);
+
+ fadeIn = new QPropertyAnimation(effect, "opacity");
+ fadeIn->setDuration(200);
+ fadeIn->setStartValue(0.3);
+ fadeIn->setEndValue(1.);
+
+ fadeOut = new QPropertyAnimation(effect, "opacity");
+ fadeOut->setDuration(200);
+ fadeOut->setStartValue(1.);
+ fadeOut->setEndValue(0.3);
+
+ scene = new CustomScene;
+ scene->setSceneRect(-250,-250,500,500);
+ ui->view->setScene(scene);
+ scene->setBackgroundBrush(Qt::white);
+ ui->view->setInteractive(true);
+ ui->view->setDragMode(QGraphicsView::RubberBandDrag);
+ ui->view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+ ui->view->setRenderHints( QPainter::SmoothPixmapTransform |
+ QPainter::TextAntialiasing |
+ QPainter::Antialiasing );
+
+ rectBlue = new CustomItem(-100, -100, 50, 50, QColor(80, 80, 200));
+ scene->addItem(rectBlue);
+ rectGreen = new CustomItem(100, -100, 50, 50, QColor(80, 200, 80));
+ scene->addItem(rectGreen);
+ rectRed = new CustomItem(-100, 100, 50, 50, QColor(200, 80, 80));
+ scene->addItem(rectRed);
+ rectYellow = new CustomItem(100, 100, 50, 50, QColor(200, 200, 20));
+ scene->addItem(rectYellow);
+
+ connect(scene, SIGNAL(selectionChanged()), this, SLOT(onSceneSelectionChanged()));
+}
+
+Widget::~Widget()
+{
+ delete ui;
+ delete fadeIn;
+ delete fadeOut;
+}
+
+void Widget::on_rotate_valueChanged(int value)
+{
+ if (scene->selectedItems().count() != 1)
+ return;
+
+ QGraphicsItem *item = scene->selectedItems().at(0);
+ item->setRotation(value);
+ ui->rotateItem->setValue(checkedItem()->rotation());
+}
+
+void Widget::on_scale_valueChanged(int value)
+{
+ if (scene->selectedItems().count() != 1)
+ return;
+
+ QGraphicsItem *item = scene->selectedItems().at(0);
+ item->setScale(value / 10.);
+ ui->scaleItem->setValue(checkedItem()->scale() * 10);
+}
+
+void Widget::on_rotateItem_valueChanged(int value)
+{
+ if (!scene->selectedItems().empty() && scene->selectedItems().at(0) == checkedItem())
+ ui->rotate->setValue(value);
+ else
+ checkedItem()->setRotation(value);
+}
+
+void Widget::on_scaleItem_valueChanged(int value)
+{
+ if (!scene->selectedItems().empty() && scene->selectedItems().at(0) == checkedItem())
+ ui->scale->setValue(value);
+ else
+ checkedItem()->setScale(value / 10.);
+}
+
+void Widget::on_group_clicked()
+{
+ QList<QGraphicsItem*> all = scene->selectedItems();
+ if (all.size() < 2)
+ return;
+
+ QList<CustomItem*> items = scene->selectedCustomItems();
+ QList<CustomGroup*> groups = scene->selectedCustomGroups();
+
+ if (groups.size() == 1) {
+ foreach (CustomItem *item, items) {
+ item->setSelected(false);
+ groups[0]->addToGroup(item);
+ }
+
+ return;
+ }
+
+ CustomGroup* group = new CustomGroup;
+ scene->addItem(group);
+ foreach (QGraphicsItem *item, all) {
+ item->setSelected(false);
+ group->addToGroup(item);
+ }
+ group->setSelected(true);
+
+ updateUngroupButton();
+}
+
+void Widget::on_dismantle_clicked()
+{
+ QList<CustomGroup*> groups = scene->selectedCustomGroups();
+
+ foreach (CustomGroup *group, groups) {
+ foreach (QGraphicsItem *item, group->childItems())
+ group->removeFromGroup(item);
+
+ delete group;
+ }
+
+ updateUngroupButton();
+}
+
+void Widget::on_merge_clicked()
+{
+ QList<CustomGroup*> groups = scene->selectedCustomGroups();
+ if (groups.size() < 2)
+ return;
+
+ CustomGroup *newBigGroup = groups.takeFirst();
+ foreach (CustomGroup *group, groups) {
+ foreach (QGraphicsItem *item, group->childItems())
+ item->setGroup(newBigGroup);
+
+ delete group;
+ }
+}
+
+void Widget::onSceneSelectionChanged()
+{
+ QList<QGraphicsItem*> all = scene->selectedItems();
+ QList<CustomGroup*> groups = scene->selectedCustomGroups();
+
+ if (all.empty() && all.count() != previousSelectionCount) {
+ fadeOut->start();
+ } else if (previousSelectionCount == 0) {
+ fadeIn->start();
+ }
+
+ if (all.count() == 1) {
+ QGraphicsItem *item = all.at(0);
+ ui->rotate->setValue(item->rotation());
+ ui->scale->setValue(item->scale() * 10);
+ } else {
+ ui->rotate->setValue(ui->rotate->minimum());
+ ui->scale->setValue(ui->scale->minimum());
+ }
+
+ ui->rotate->setEnabled(all.size() == 1);
+ ui->scale->setEnabled(all.size() == 1);
+ ui->group->setEnabled(all.size() > 1);
+ ui->dismantle->setEnabled(!groups.empty());
+ ui->merge->setEnabled(groups.size() > 1);
+
+ previousSelectionCount = all.size();
+
+ updateUngroupButton();
+}
+
+void Widget::on_ungroup_clicked()
+{
+ QGraphicsItemGroup *oldGroup = checkedItem()->group();
+ checkedItem()->setGroup(0);
+ if (oldGroup && oldGroup->childItems().empty())
+ delete oldGroup;
+
+ updateUngroupButton();
+}
+
+void Widget::updateUngroupButton()
+{
+ ui->ungroup->setEnabled(checkedItem()->group() != 0);
+}
+
+CustomItem * Widget::checkedItem() const
+{
+ CustomItem *item;
+
+ if (ui->blue->isChecked())
+ item = rectBlue;
+ else if (ui->red->isChecked())
+ item = rectRed;
+ else if (ui->green->isChecked())
+ item = rectGreen;
+ else if (ui->yellow->isChecked())
+ item = rectYellow;
+
+ return item;
+}
+
+void Widget::on_buttonGroup_buttonClicked()
+{
+ ui->rotateItem->setValue(checkedItem()->rotation());
+ ui->scaleItem->setValue(checkedItem()->scale() * 10);
+
+ updateUngroupButton();
+}
diff --git a/tests/manual/qgraphicsitemgroup/widget.h b/tests/manual/qgraphicsitemgroup/widget.h
new file mode 100644
index 0000000..affc436
--- /dev/null
+++ b/tests/manual/qgraphicsitemgroup/widget.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include "customitem.h"
+
+#include <QWidget>
+#include <QGraphicsItemGroup>
+#include <QPainter>
+
+namespace Ui {
+ class Widget;
+}
+
+class QGraphicsOpacityEffect;
+class QPropertyAnimation;
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+public:
+ Widget(QWidget *parent = 0);
+ ~Widget();
+
+protected Q_SLOTS:
+ void on_rotate_valueChanged(int value);
+ void on_scale_valueChanged(int value);
+ void on_rotateItem_valueChanged(int value);
+ void on_scaleItem_valueChanged(int value);
+ void on_group_clicked();
+ void on_dismantle_clicked();
+ void on_merge_clicked();
+ void onSceneSelectionChanged();
+ void on_ungroup_clicked();
+ void on_buttonGroup_buttonClicked();
+
+private:
+ void updateUngroupButton();
+ CustomItem * checkedItem() const;
+
+ Ui::Widget *ui;
+ CustomScene *scene;
+ CustomItem *rectBlue;
+ CustomItem *rectRed;
+ CustomItem *rectGreen;
+ CustomItem *rectYellow;
+ QGraphicsOpacityEffect* effect;
+ QPropertyAnimation *fadeIn;
+ QPropertyAnimation *fadeOut;
+ int previousSelectionCount;
+};
+
+#endif // WIDGET_H
diff --git a/tests/manual/qgraphicsitemgroup/widget.ui b/tests/manual/qgraphicsitemgroup/widget.ui
new file mode 100644
index 0000000..7e3a4df
--- /dev/null
+++ b/tests/manual/qgraphicsitemgroup/widget.ui
@@ -0,0 +1,319 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget</class>
+ <widget class="QWidget" name="Widget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>782</width>
+ <height>695</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Widget</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Items</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QRadioButton" name="blue">
+ <property name="text">
+ <string>Blue</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="red">
+ <property name="text">
+ <string>Red</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="green">
+ <property name="text">
+ <string>Green</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="yellow">
+ <property name="text">
+ <string>Yellow</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string>buttonGroup</string>
+ </attribute>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Rotate</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="rotateItem">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>360</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Scale</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="scaleItem">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="minimum">
+ <number>5</number>
+ </property>
+ <property name="maximum">
+ <number>30</number>
+ </property>
+ <property name="value">
+ <number>10</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="ungroup">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Ungroup</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>50</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>300</width>
+ <height>164</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>300</width>
+ <height>164</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Selection</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Rotate</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="rotate">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>360</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Scale</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="scale">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="minimum">
+ <number>5</number>
+ </property>
+ <property name="maximum">
+ <number>30</number>
+ </property>
+ <property name="value">
+ <number>10</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QPushButton" name="group">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Group</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="merge">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Merge Groups</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="dismantle">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Dismantle Group</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGraphicsView" name="view"/>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+ <buttongroups>
+ <buttongroup name="buttonGroup"/>
+ </buttongroups>
+</ui>