From 52a65fde8e97f1f6dc26192058fadc1d2275983a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 11 Feb 2010 13:26:22 +0100 Subject: Speed up custom bitmap brushes on X11 without Xrender support. There's no need to fall back and go via draw_helper() if we're using a bitmap brush that's drawn using a solid color. Task-number: QTBUG-8140 Reviewed-by: Kim --- src/gui/painting/qpainter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3bcaf8c..075c457 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -708,13 +708,14 @@ void QPainterPrivate::updateEmulationSpecifier(QPainterState *s) bool penTextureAlpha = false; if (penBrush.style() == Qt::TexturePattern) penTextureAlpha = qHasPixmapTexture(penBrush) - ? penBrush.texture().hasAlpha() + ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() : penBrush.textureImage().hasAlphaChannel(); bool brushTextureAlpha = false; - if (s->brush.style() == Qt::TexturePattern) + if (s->brush.style() == Qt::TexturePattern) { brushTextureAlpha = qHasPixmapTexture(s->brush) - ? s->brush.texture().hasAlpha() + ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha() : s->brush.textureImage().hasAlphaChannel(); + } if (((penBrush.style() == Qt::TexturePattern && penTextureAlpha) || (s->brush.style() == Qt::TexturePattern && brushTextureAlpha)) && !engine->hasFeature(QPaintEngine::MaskedBrush)) -- cgit v0.12 From 2acc883b3a339b716da9249a1366b08225acbd8a Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 11 Feb 2010 15:16:44 +0100 Subject: document the slowness of QPixmap::hasAlpha() Reviewed-by: Kim --- src/gui/image/qpixmap.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index d1e5c40..1df7946 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1670,10 +1670,9 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) \o The hasAlphaChannel() returns true if the pixmap has a format that - respects the alpha channel, otherwise returns false, while the - hasAlpha() function returns true if the pixmap has an alpha - channel \e or a mask (otherwise false). The mask() function returns - the mask as a QBitmap object, which can be set using setMask(). + respects the alpha channel, otherwise returns false. The hasAlpha(), + setMask() and mask() functions are legacy and should not be used. + They are potentially very slow. The createHeuristicMask() function creates and returns a 1-bpp heuristic mask (i.e. a QBitmap) for this pixmap. It works by @@ -1760,6 +1759,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) Returns true if this pixmap has an alpha channel, \e or has a mask, otherwise returns false. + \warning This is potentially an expensive operation. + \sa hasAlphaChannel(), mask() */ bool QPixmap::hasAlpha() const -- cgit v0.12 From d9a6d2e28e4a38ff1242e5e9b1d2225844a51a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 11 Feb 2010 15:39:56 +0100 Subject: Make QCUPSSupport::printerHasPPD() clean up after itself. This call "leaked" a temporary file in /tmp every time a QPrinter object was created. Not very nice at all. Task-number: QTBUG-6419 Reviewed-by: Kim --- src/gui/painting/qcups.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qcups.cpp b/src/gui/painting/qcups.cpp index 7903762..ac41692 100644 --- a/src/gui/painting/qcups.cpp +++ b/src/gui/painting/qcups.cpp @@ -342,7 +342,9 @@ bool QCUPSSupport::printerHasPPD(const char *printerName) { if (!isAvailable()) return false; - return _cupsGetPPD(printerName) != 0; + const char *ppdFile = _cupsGetPPD(printerName); + unlink(ppdFile); + return (ppdFile != 0); } QString QCUPSSupport::unicodeString(const char *s) -- cgit v0.12 From 2f389a95f5b9e4c7130aa333586d803b639bf259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Mon, 8 Feb 2010 17:08:01 +0100 Subject: Add functional Graphics View benchmarks. Widgets and use cases are externally developed and imported from: git://gitorious.org/+qt-performance-test-developers/qt/qt-performance-test-developers-clone.git (master branch, tests/benchmarks/uimodels/GraphicsViewBenchmark) I couldn't simply import everything because the benchmarks were heavily dependent on an internal measuring tool involving QtScripts and whatnot, not suitable for inclusion in the Qt repository. Everything is now converted into proper QTestLib compatible benchmark functions. --- .../GraphicsViewBenchmark.pro | 71 + .../GraphicsViewBenchmark.qrc | 85 + .../functional/GraphicsViewBenchmark/main.cpp | 686 ++++ .../resources/avatars/avatar_man_001_58x58.png | Bin 0 -> 6598 bytes .../resources/avatars/avatar_man_002_58x58.png | Bin 0 -> 6687 bytes .../resources/avatars/avatar_man_003_58x58.png | Bin 0 -> 6261 bytes .../resources/avatars/avatar_man_004_58x58.png | Bin 0 -> 6783 bytes .../resources/avatars/avatar_man_005_58x58.png | Bin 0 -> 6317 bytes .../resources/avatars/avatar_man_006_58x58.png | Bin 0 -> 7020 bytes .../resources/avatars/avatar_man_007_58x58.png | Bin 0 -> 3706 bytes .../resources/avatars/avatar_man_008_58x58.png | Bin 0 -> 6749 bytes .../resources/avatars/avatar_man_009_58x58.png | Bin 0 -> 5436 bytes .../resources/avatars/avatar_man_010_58x58.png | Bin 0 -> 1454 bytes .../resources/avatars/avatar_picture_001_58x58.png | Bin 0 -> 2983 bytes .../resources/avatars/avatar_picture_002_58x58.png | Bin 0 -> 3463 bytes .../resources/avatars/avatar_picture_003_58x58.png | Bin 0 -> 763 bytes .../resources/avatars/avatar_picture_004_58x58.png | Bin 0 -> 2252 bytes .../resources/avatars/avatar_picture_005_58x58.png | Bin 0 -> 2451 bytes .../resources/avatars/avatar_woman_001_58x58.png | Bin 0 -> 6330 bytes .../resources/avatars/avatar_woman_002_58x58.png | Bin 0 -> 6237 bytes .../resources/avatars/avatar_woman_003_58x58.png | Bin 0 -> 6192 bytes .../resources/avatars/avatar_woman_004_58x58.png | Bin 0 -> 7489 bytes .../resources/avatars/avatar_woman_005_58x58.png | Bin 0 -> 6764 bytes .../resources/avatars/avatar_woman_006_58x58.png | Bin 0 -> 6218 bytes .../resources/avatars/avatar_woman_007_58x58.png | Bin 0 -> 6122 bytes .../resources/avatars/avatar_woman_008_58x58.png | Bin 0 -> 6658 bytes .../resources/avatars/avatar_woman_009_58x58.png | Bin 0 -> 8293 bytes .../resources/avatars/avatar_woman_010_58x58.png | Bin 0 -> 4783 bytes .../blue_SVG/blue_background_360x640px.svg | 14 + .../blue_background_horisontal_640x360px.svg | 16 + .../blue_SVG/blue_contact_default_icon_52x52px.svg | 22 + .../blue_contact_list_divider_360x76px.svg | 7 + .../blue_contact_list_highlighter_360x76px.svg | 10 + .../blue_SVG/blue_contact_status_idle_33x33px.svg | 55 + .../blue_contact_status_offline_33x33px.svg | 55 + .../blue_contact_status_online_33x33px.svg | 56 + .../resources/blue_SVG/blue_scroll_16x80px.svg | 39 + .../resources/blue_SVG/blue_scrollbar_7x14px.svg | 7 + .../blue_SVG/blue_status_field_left_14x24px.svg | 24 + .../blue_SVG/blue_status_field_middle_14x24px.svg | 11 + .../blue_SVG/blue_status_field_right_14x24px.svg | 13 + .../resources/blue_SVG/blue_topbar_356x96px.svg | 2007 ++++++++++ .../blue_SVG/blue_topbar_horisontal_636x96px.svg | 4060 ++++++++++++++++++++ .../blue_SVG/blue_user_default_icon_68x68px.svg | 22 + .../blue_SVG/blue_user_status_idle_38x38px.svg | 55 + .../blue_SVG/blue_user_status_offline_38x38px.svg | 55 + .../blue_SVG/blue_user_status_online_38x38px.svg | 55 + .../resources/contacts/areacodes.txt | 62 + .../resources/contacts/firstnamesF.txt | 100 + .../resources/contacts/firstnamesM.txt | 100 + .../resources/contacts/lastnames.txt | 150 + .../lime_SVG/lime_background_360x640px.svg | 40 + .../lime_background_horisontal_640x360px.svg | 39 + .../lime_SVG/lime_contact_default_icon_53x53px.svg | 30 + ...lime_contact_default_icon_highlight_53x53px.svg | 31 + .../lime_contact_list_divider_360x76px.svg | 7 + .../lime_contact_list_highlighter_357x80px.svg | 11 + .../lime_SVG/lime_contact_status_idle_27x47.svg | 63 + .../lime_SVG/lime_contact_status_offline_27x47.svg | 58 + .../lime_SVG/lime_contact_status_online_27x47.svg | 63 + .../resources/lime_SVG/lime_scroll_5x80px.svg | 12 + .../resources/lime_SVG/lime_scrollbar_5x14px.svg | 7 + .../lime_SVG/lime_status_field_left_14x24px.svg | 30 + .../lime_SVG/lime_status_field_middle_10x24px.svg | 18 + .../lime_SVG/lime_status_field_right_14x24px.svg | 19 + .../resources/lime_SVG/lime_topbar_356x96px.svg | 26 + .../lime_SVG/lime_topbar_horisontal_636x96px.svg | 26 + .../lime_SVG/lime_user_default_icon_84x68px.svg | 32 + .../lime_SVG/lime_user_status_idle_24x24px.svg | 53 + .../lime_SVG/lime_user_status_offline_24x24px.svg | 53 + .../lime_SVG/lime_user_status_online_24x24px.svg | 53 + .../widgets/abstractitemcontainer.cpp | 401 ++ .../widgets/abstractitemcontainer.h | 111 + .../widgets/abstractitemview.cpp | 444 +++ .../widgets/abstractitemview.h | 118 + .../widgets/abstractscrollarea.cpp | 249 ++ .../widgets/abstractscrollarea.h | 101 + .../widgets/abstractviewitem.cpp | 117 + .../widgets/abstractviewitem.h | 96 + .../widgets/backgrounditem.cpp | 85 + .../GraphicsViewBenchmark/widgets/backgrounditem.h | 72 + .../GraphicsViewBenchmark/widgets/button.cpp | 209 + .../GraphicsViewBenchmark/widgets/button.h | 102 + .../GraphicsViewBenchmark/widgets/commandline.cpp | 206 + .../GraphicsViewBenchmark/widgets/commandline.h | 52 + .../GraphicsViewBenchmark/widgets/dummydatagen.cpp | 141 + .../GraphicsViewBenchmark/widgets/dummydatagen.h | 72 + .../GraphicsViewBenchmark/widgets/gvbwidget.cpp | 59 + .../GraphicsViewBenchmark/widgets/gvbwidget.h | 58 + .../GraphicsViewBenchmark/widgets/iconitem.cpp | 169 + .../GraphicsViewBenchmark/widgets/iconitem.h | 96 + .../widgets/itemrecyclinglist.cpp | 275 ++ .../widgets/itemrecyclinglist.h | 85 + .../widgets/itemrecyclinglist.pri | 19 + .../widgets/itemrecyclinglistview.cpp | 79 + .../widgets/itemrecyclinglistview.h | 67 + .../GraphicsViewBenchmark/widgets/label.cpp | 98 + .../GraphicsViewBenchmark/widgets/label.h | 76 + .../GraphicsViewBenchmark/widgets/listitem.cpp | 314 ++ .../GraphicsViewBenchmark/widgets/listitem.h | 109 + .../widgets/listitemcache.cpp | 92 + .../GraphicsViewBenchmark/widgets/listitemcache.h | 69 + .../widgets/listitemcontainer.cpp | 211 + .../widgets/listitemcontainer.h | 92 + .../GraphicsViewBenchmark/widgets/listmodel.cpp | 146 + .../GraphicsViewBenchmark/widgets/listmodel.h | 82 + .../GraphicsViewBenchmark/widgets/listwidget.cpp | 132 + .../GraphicsViewBenchmark/widgets/listwidget.h | 87 + .../GraphicsViewBenchmark/widgets/mainview.cpp | 348 ++ .../GraphicsViewBenchmark/widgets/mainview.h | 123 + .../GraphicsViewBenchmark/widgets/menu.cpp | 202 + .../GraphicsViewBenchmark/widgets/menu.h | 84 + .../widgets/recycledlistitem.cpp | 147 + .../widgets/recycledlistitem.h | 83 + .../widgets/resourcemoninterface.h | 97 + .../GraphicsViewBenchmark/widgets/scrollbar.cpp | 299 ++ .../GraphicsViewBenchmark/widgets/scrollbar.h | 97 + .../GraphicsViewBenchmark/widgets/scroller.cpp | 305 ++ .../GraphicsViewBenchmark/widgets/scroller.h | 79 + .../GraphicsViewBenchmark/widgets/scroller_p.h | 103 + .../GraphicsViewBenchmark/widgets/settings.cpp | 59 + .../GraphicsViewBenchmark/widgets/settings.h | 115 + .../GraphicsViewBenchmark/widgets/simplelist.cpp | 164 + .../GraphicsViewBenchmark/widgets/simplelist.h | 80 + .../widgets/simplelistview.cpp | 500 +++ .../GraphicsViewBenchmark/widgets/simplelistview.h | 92 + .../GraphicsViewBenchmark/widgets/theme.cpp | 240 ++ .../GraphicsViewBenchmark/widgets/theme.h | 134 + .../GraphicsViewBenchmark/widgets/themeevent.cpp | 53 + .../GraphicsViewBenchmark/widgets/themeevent.h | 64 + .../GraphicsViewBenchmark/widgets/topbar.cpp | 359 ++ .../GraphicsViewBenchmark/widgets/topbar.h | 126 + .../GraphicsViewBenchmark/widgets/webview.cpp | 263 ++ .../GraphicsViewBenchmark/widgets/webview.h | 40 + .../GraphicsViewBenchmark/widgets/webview_p.h | 58 + .../gui/graphicsview/functional/functional.pro | 3 + tests/benchmarks/gui/graphicsview/graphicsview.pro | 1 + 137 files changed, 17817 insertions(+) create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.pro create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.qrc create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_001_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_002_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_003_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_004_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_005_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_006_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_007_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_008_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_009_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_010_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_001_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_002_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_003_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_004_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_005_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_001_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_002_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_003_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_004_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_005_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_006_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_007_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_008_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_009_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_010_58x58.png create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_360x640px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_horisontal_640x360px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_default_icon_52x52px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_divider_360x76px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_idle_33x33px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_offline_33x33px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_online_33x33px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scroll_16x80px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scrollbar_7x14px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_left_14x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_middle_14x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_right_14x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_356x96px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_horisontal_636x96px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_default_icon_68x68px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_idle_38x38px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_offline_38x38px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_online_38x38px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/areacodes.txt create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesF.txt create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesM.txt create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/lastnames.txt create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_360x640px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_horisontal_640x360px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_53x53px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_divider_360x76px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_idle_27x47.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_offline_27x47.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_online_27x47.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scroll_5x80px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scrollbar_5x14px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_left_14x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_middle_10x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_right_14x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_356x96px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_horisontal_636x96px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_default_icon_84x68px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_idle_24x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_offline_24x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_online_24x24px.svg create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/button.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/button.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.pri create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/label.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/label.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitemcache.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitemcache.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitemcontainer.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitemcontainer.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listmodel.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listmodel.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listwidget.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listwidget.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/menu.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/menu.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/recycledlistitem.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/recycledlistitem.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/resourcemoninterface.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/scrollbar.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/scrollbar.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelistview.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelistview.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/theme.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/theme.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/topbar.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/topbar.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/webview.cpp create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/webview.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/webview_p.h create mode 100644 tests/benchmarks/gui/graphicsview/functional/functional.pro diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.pro b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.pro new file mode 100644 index 0000000..131ec12 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.pro @@ -0,0 +1,71 @@ +load(qttest_p4) +TEMPLATE = app + +QT += svg +contains(QT_CONFIG, opengl):QT += opengl + +HEADERS += widgets/gvbwidget.h \ + widgets/abstractscrollarea.h \ + widgets/mainview.h \ + widgets/iconitem.h \ + widgets/label.h \ + widgets/listitem.h \ + widgets/scrollbar.h \ + widgets/simplelistview.h \ + widgets/scroller.h \ + widgets/scroller_p.h \ + widgets/button.h \ + widgets/menu.h \ + widgets/themeevent.h \ + widgets/theme.h \ + widgets/backgrounditem.h \ + widgets/topbar.h \ + widgets/commandline.h \ + widgets/dummydatagen.h \ + widgets/settings.h \ + widgets/listitemcache.h \ + widgets/listwidget.h \ + widgets/simplelist.h \ + widgets/itemrecyclinglist.h \ + widgets/itemrecyclinglistview.h \ + widgets/abstractitemview.h \ + widgets/abstractviewitem.h \ + widgets/recycledlistitem.h \ + widgets/listitemcontainer.h \ + widgets/abstractitemcontainer.h \ + widgets/listmodel.h + +SOURCES += main.cpp \ + widgets/gvbwidget.cpp \ + widgets/abstractscrollarea.cpp \ + widgets/mainview.cpp \ + widgets/iconitem.cpp \ + widgets/label.cpp \ + widgets/listitem.cpp \ + widgets/scrollbar.cpp \ + widgets/simplelistview.cpp \ + widgets/scroller.cpp \ + widgets/button.cpp \ + widgets/menu.cpp \ + widgets/themeevent.cpp \ + widgets/theme.cpp \ + widgets/backgrounditem.cpp \ + widgets/topbar.cpp \ + widgets/commandline.cpp \ + widgets/dummydatagen.cpp \ + widgets/settings.cpp \ + widgets/listitemcache.cpp \ + widgets/listwidget.cpp \ + widgets/simplelist.cpp \ + widgets/itemrecyclinglist.cpp \ + widgets/itemrecyclinglistview.cpp \ + widgets/abstractitemview.cpp \ + widgets/abstractviewitem.cpp \ + widgets/recycledlistitem.cpp \ + widgets/listitemcontainer.cpp \ + widgets/abstractitemcontainer.cpp \ + widgets/listmodel.cpp + +TARGET = tst_GraphicsViewBenchmark +RESOURCES += GraphicsViewBenchmark.qrc +INCLUDEPATH += widgets diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.qrc b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.qrc new file mode 100644 index 0000000..18ae04d --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.qrc @@ -0,0 +1,85 @@ + + + resources/blue_SVG/blue_background_360x640px.svg + resources/blue_SVG/blue_background_horisontal_640x360px.svg + resources/blue_SVG/blue_contact_default_icon_52x52px.svg + resources/blue_SVG/blue_contact_list_divider_360x76px.svg + resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg + resources/blue_SVG/blue_contact_status_idle_33x33px.svg + resources/blue_SVG/blue_contact_status_offline_33x33px.svg + resources/blue_SVG/blue_contact_status_online_33x33px.svg + resources/blue_SVG/blue_scrollbar_7x14px.svg + resources/blue_SVG/blue_scroll_16x80px.svg + resources/blue_SVG/blue_status_field_left_14x24px.svg + resources/blue_SVG/blue_status_field_middle_14x24px.svg + resources/blue_SVG/blue_status_field_right_14x24px.svg + resources/blue_SVG/blue_topbar_356x96px.svg + resources/blue_SVG/blue_topbar_horisontal_636x96px.svg + resources/blue_SVG/blue_user_default_icon_68x68px.svg + resources/blue_SVG/blue_user_status_idle_38x38px.svg + resources/blue_SVG/blue_user_status_offline_38x38px.svg + resources/blue_SVG/blue_user_status_online_38x38px.svg + + + + resources/lime_SVG/lime_background_360x640px.svg + resources/lime_SVG/lime_background_horisontal_640x360px.svg + resources/lime_SVG/lime_contact_default_icon_53x53px.svg + resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg + resources/lime_SVG/lime_contact_list_divider_360x76px.svg + resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg + resources/blue_SVG/blue_contact_status_idle_33x33px.svg + resources/blue_SVG/blue_contact_status_offline_33x33px.svg + resources/blue_SVG/blue_contact_status_online_33x33px.svg + resources/lime_SVG/lime_scrollbar_5x14px.svg + resources/lime_SVG/lime_scroll_5x80px.svg + resources/lime_SVG/lime_status_field_left_14x24px.svg + resources/lime_SVG/lime_status_field_middle_10x24px.svg + resources/lime_SVG/lime_status_field_right_14x24px.svg + resources/lime_SVG/lime_topbar_356x96px.svg + resources/lime_SVG/lime_topbar_horisontal_636x96px.svg + resources/lime_SVG/lime_user_default_icon_84x68px.svg + resources/lime_SVG/lime_user_status_idle_24x24px.svg + resources/lime_SVG/lime_user_status_offline_24x24px.svg + resources/lime_SVG/lime_user_status_online_24x24px.svg + + + + resources/avatars/avatar_man_001_58x58.png + resources/avatars/avatar_man_002_58x58.png + resources/avatars/avatar_man_003_58x58.png + resources/avatars/avatar_man_004_58x58.png + resources/avatars/avatar_man_005_58x58.png + resources/avatars/avatar_man_006_58x58.png + resources/avatars/avatar_man_007_58x58.png + resources/avatars/avatar_man_008_58x58.png + resources/avatars/avatar_man_009_58x58.png + resources/avatars/avatar_man_010_58x58.png + + resources/avatars/avatar_picture_001_58x58.png + resources/avatars/avatar_picture_002_58x58.png + resources/avatars/avatar_picture_003_58x58.png + resources/avatars/avatar_picture_004_58x58.png + resources/avatars/avatar_picture_005_58x58.png + + resources/avatars/avatar_woman_001_58x58.png + resources/avatars/avatar_woman_002_58x58.png + resources/avatars/avatar_woman_003_58x58.png + resources/avatars/avatar_woman_004_58x58.png + resources/avatars/avatar_woman_005_58x58.png + resources/avatars/avatar_woman_006_58x58.png + resources/avatars/avatar_woman_007_58x58.png + resources/avatars/avatar_woman_008_58x58.png + resources/avatars/avatar_woman_009_58x58.png + resources/avatars/avatar_woman_010_58x58.png + + + + resources/contacts/areacodes.txt + resources/contacts/firstnamesF.txt + resources/contacts/firstnamesM.txt + resources/contacts/lastnames.txt + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp new file mode 100644 index 0000000..f294717 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp @@ -0,0 +1,686 @@ +#include +#include +#include + +#include "mainview.h" +#include "dummydatagen.h" +#include "simplelist.h" +#include "itemrecyclinglist.h" +#include "simplelist.h" +#include "theme.h" + +class tst_GraphicsViewBenchmark : public QObject +{ + Q_OBJECT +public: + enum ListType { + Simple, + Recycling, + None + }; + + enum ScrollStep { + Slow = 2, + Normal = 8, + Fast = 64 + }; + + tst_GraphicsViewBenchmark() + : mMainView(0), currentListSize(-1), currentListType(None) {} + ~tst_GraphicsViewBenchmark() {} + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + +private slots: + // Benchmarks: + void createAndFillList_data(); + void createAndFillList(); + void add100ItemsToBeginningOfList_data(); + void add100ItemsToBeginningOfList(); + void remove100ItemsFromBeginningOfList_data(); + void remove100ItemsFromBeginningOfList(); + void deleteList_data(); + void deleteList(); + void themeChange_data(); + void themeChange(); + void update_data(); + void update(); + void scroll_data(); + void scroll(); + +private: + MainView *mMainView; + DummyDataGenerator mDataGenerator; + int currentListSize; + ListType currentListType; + + void resetView(); + void ensureListSizeAndType(int listSize, ListType listType); + void ensureTheme(Theme::Themes theme); + void ensureRotationAngle(int rotation); + void ensureSubtreeCache(bool enable); + void ensureImageBasedRendering(bool enable); + void insertListData(); + inline void setTestWidget(QGraphicsWidget *widget, int listSize, ListType listType) + { + currentListSize = listSize; + currentListType = listType; + mMainView->setTestWidget(widget); + } +}; + +Q_DECLARE_METATYPE(tst_GraphicsViewBenchmark::ListType) +Q_DECLARE_METATYPE(Theme::Themes) +Q_DECLARE_METATYPE(tst_GraphicsViewBenchmark::ScrollStep) + +const int AddRemoveCount = 100; + +static ListItem *newSimpleListItem(DummyDataGenerator &dataGenerator, const int id) +{ + ListItem *item = new ListItem(); + item->setText(dataGenerator.randomName(), ListItem::FirstPos ); + item->setText(dataGenerator.randomPhoneNumber(QString("%1").arg(id)), ListItem::SecondPos ); + item->setIcon(new IconItem(dataGenerator.randomIconItem(), item), ListItem::LeftIcon ); + item->setIcon(new IconItem(dataGenerator.randomStatusItem(), item), ListItem::RightIcon); + item->setFont(Theme::p()->font(Theme::ContactName), ListItem::FirstPos); + item->setFont(Theme::p()->font(Theme::ContactNumber), ListItem::SecondPos); + item->setBorderPen(Theme::p()->listItemBorderPen()); + item->setRounding(Theme::p()->listItemRounding()); + item->icon(ListItem::LeftIcon)->setRotation(Theme::p()->iconRotation(ListItem::LeftIcon)); + item->icon(ListItem::RightIcon)->setRotation(Theme::p()->iconRotation(ListItem::RightIcon)); + item->icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::LeftIcon)); + item->icon(ListItem::RightIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::RightIcon)); + item->icon(ListItem::LeftIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::LeftIcon)); + item->icon(ListItem::RightIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::RightIcon)); + return item; +} + +static RecycledListItem *newRecyclingListItem(DummyDataGenerator &dataGenerator, const int id) +{ + RecycledListItem *item = new RecycledListItem(); + item->item()->setText(dataGenerator.randomName(), ListItem::FirstPos ); + item->item()->setText(dataGenerator.randomPhoneNumber(QString("%1").arg(id)), ListItem::SecondPos ); + item->item()->setIcon(new IconItem(dataGenerator.randomIconItem()), ListItem::LeftIcon ); + item->item()->setIcon(new IconItem(dataGenerator.randomStatusItem()), ListItem::RightIcon); + item->item()->setFont(Theme::p()->font(Theme::ContactName), ListItem::FirstPos); + item->item()->setFont(Theme::p()->font(Theme::ContactNumber), ListItem::SecondPos); + item->item()->setBorderPen(Theme::p()->listItemBorderPen()); + item->item()->setRounding(Theme::p()->listItemRounding()); + item->item()->icon(ListItem::LeftIcon)->setRotation(Theme::p()->iconRotation(ListItem::LeftIcon)); + item->item()->icon(ListItem::RightIcon)->setRotation(Theme::p()->iconRotation(ListItem::RightIcon)); + item->item()->icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::LeftIcon)); + item->item()->icon(ListItem::RightIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::RightIcon)); + item->item()->icon(ListItem::LeftIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::LeftIcon)); + item->item()->icon(ListItem::RightIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::RightIcon)); + return item; +} + +static void fillList(DummyDataGenerator &dataGenerator, int itemCount, QGraphicsWidget *list) +{ + if (SimpleList *simpleList = qobject_cast(list)) { + for (int i = 0; i < itemCount; ++i) + simpleList->addItem(newSimpleListItem(dataGenerator, i)); + } else if (ItemRecyclingList *recyclingList = qobject_cast(list)) { + for (int i = 0; i < itemCount; ++i) + recyclingList->addItem(newRecyclingListItem(dataGenerator, i)); + } else { + qFatal("fillList: internal error"); + } +} + +void tst_GraphicsViewBenchmark::resetView() +{ + if (QGraphicsWidget *widget = mMainView->takeTestWidget()) { + delete widget; + currentListSize = -1; + currentListType = None; + QTest::qWait(50); + } else { + if (currentListSize != -1) + qFatal("tst_GraphicsViewBenchmark::resetView: internal error: wrong list size"); + if (currentListType != None) + qFatal("tst_GraphicsViewBenchmark::resetView: internal error: wrong list type"); + } + ensureTheme(Theme::Blue); + ensureRotationAngle(0); + ensureSubtreeCache(false); + ensureImageBasedRendering(false); +} + +void tst_GraphicsViewBenchmark::ensureListSizeAndType(int listSize, ListType listType) +{ + if (currentListSize != listSize || currentListType != listType) { + resetView(); + if (listType == Simple) { + SimpleList *list = new SimpleList; + fillList(mDataGenerator, listSize, list); + setTestWidget(list, listSize, listType); + } else if (listType == Recycling) { + ItemRecyclingList *list = new ItemRecyclingList; + fillList(mDataGenerator, listSize, list); + setTestWidget(list, listSize, listType); + } + QTest::qWait(50); + return; + } + + // Okay, we're supposed to have the right list type and size. Make sure we actually have it. + QGraphicsWidget *widget = mMainView->testWidget(); + if (!widget) { + if (currentListType != None || currentListSize != -1) + qFatal("tst_GraphicsViewBenchmark::ensureListSizeAndType: internal error: no test widget"); + return; + } + + if (listType == Simple) { + SimpleList *list = qobject_cast(widget); + if (!list) + qFatal("tst_GraphicsViewBenchmark::ensureListSizeAndType: internal error: wrong list type"); + if (list->itemCount() != listSize) + qFatal("tst_GraphicsViewBenchmark::ensureListSizeAndType: internal error: wrong list size"); + } else if (listType == Recycling){ + ItemRecyclingList *list = qobject_cast(widget); + if (!list) + qFatal("tst_GraphicsViewBenchmark::ensureListSizeAndType: internal error: wrong list type"); + if (list->rows() != listSize) + qFatal("tst_GraphicsViewBenchmark::ensureListSizeAndType: internal error: wrong list size"); + } +} + +void tst_GraphicsViewBenchmark::ensureTheme(Theme::Themes theme) +{ + if (Theme::p()->theme() != theme) { + Theme::p()->setTheme(theme); + // The theme change itself can take a lot of time, so make + // sure we give it a little bit time to stabilize *after* + // the changes, hence sendPostedEvents(); qWait(); + QApplication::sendPostedEvents(); + QTest::qWait(50); + } +} + +void tst_GraphicsViewBenchmark::ensureRotationAngle(int angle) +{ + const bool useTwoColumns = angle != 0; + bool wait = false; + if (mMainView->rotationAngle() != angle) { + mMainView->rotateContent(-mMainView->rotationAngle() + angle); + wait = true; + } + if (QGraphicsWidget *widget = mMainView->testWidget()) { + if (SimpleList *list = qobject_cast(widget)) { + if (list->twoColumns() != useTwoColumns) { + list->setTwoColumns(useTwoColumns); + wait = true; + } + } else if (ItemRecyclingList *list = qobject_cast(widget)) { + if (list->twoColumns() != useTwoColumns) { + list->setTwoColumns(useTwoColumns); + wait = true; + } + } + } + if (wait) + QTest::qWait(50); +} + +void tst_GraphicsViewBenchmark::ensureSubtreeCache(bool enable) +{ + QGraphicsWidget *widget = mMainView->testWidget(); + if (!widget) + return; + + if (SimpleList *list = qobject_cast(widget)) { + if (list->listItemCaching() != enable) { + list->setListItemCaching(enable); + QTest::qWait(50); + } + } else if (ItemRecyclingList *list = qobject_cast(widget)) { + if (list->listItemCaching() != enable) { + list->setListItemCaching(enable); + QTest::qWait(50); + } + } + QPixmapCache::clear(); +} + +void tst_GraphicsViewBenchmark::ensureImageBasedRendering(bool enable) +{ + if (mMainView->imageBasedRendering() != enable) { + mMainView->setImageBasedRendering(enable); + QTest::qWait(50); + } +} + +void tst_GraphicsViewBenchmark::insertListData() +{ + QTest::addColumn("listSize"); + QTest::addColumn("listType"); + + QTest::newRow("Simple list containing 10 items") << 10 << Simple; + QTest::newRow("Recycling list containing 10 items") << 10 << Recycling; + QTest::newRow("Simple list containing 50 items") << 50 << Simple; + QTest::newRow("Recycling list containing 50 items") << 50 << Recycling; + QTest::newRow("Simple list containing 500 items") << 500 << Simple; + QTest::newRow("Recycling list containing 500 items") << 500 << Recycling; +} + +void tst_GraphicsViewBenchmark::initTestCase() +{ + // ### Add support for: + // 1) OpenGL + // 2) FPS + // 3) Running the test manually + // Everything we need is already in widgets/[settings.cpp, commandline.cpp] + mMainView = new MainView(/*enableOpenGL=*/false, /*outputFPS=*/false); + +#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) + mMainView->showFullScreen(); +#else + mMainView->resize(360, 640); + mMainView->show(); +#endif + + mDataGenerator.Reset(); + SimpleList *list = new SimpleList; + list->setListItemCaching(false); + mMainView->setTestWidget(list); + fillList(mDataGenerator, 5, list); + mMainView->takeTestWidget(); + delete list; + + currentListSize = -1; + currentListType = None; + + QTest::qWaitForWindowShown(mMainView); +} + +void tst_GraphicsViewBenchmark::cleanupTestCase() +{ + delete mMainView; + mMainView = 0; +} + +void tst_GraphicsViewBenchmark::init() +{ + // Make sure we don't have pending events in the queue. + // Yes, each test run takes a little bit longer, but the results are more stable. + QTest::qWait(150); +} + +void tst_GraphicsViewBenchmark::createAndFillList_data() +{ + insertListData(); +} + +void tst_GraphicsViewBenchmark::createAndFillList() +{ + QFETCH(int, listSize); + QFETCH(ListType, listType); + + resetView(); + + if (listType == Simple) { + QBENCHMARK { + SimpleList *list = new SimpleList; + setTestWidget(list, listSize, listType); + fillList(mDataGenerator, listSize, list); + } + } else { + QBENCHMARK { + ItemRecyclingList *list = new ItemRecyclingList; + setTestWidget(list, listSize, listType); + fillList(mDataGenerator, listSize, list); + } + } + + resetView(); +} + +void tst_GraphicsViewBenchmark::add100ItemsToBeginningOfList_data() +{ + insertListData(); +} + +void tst_GraphicsViewBenchmark::add100ItemsToBeginningOfList() +{ + QFETCH(int, listSize); + QFETCH(ListType, listType); + + resetView(); + + if (listType == Simple) { + SimpleList *list = new SimpleList; + fillList(mDataGenerator, listSize, list); + setTestWidget(list, listSize, listType); + QTest::qWait(50); + QBENCHMARK { + for (int i = 0; i < AddRemoveCount; ++i) + list->insertItem(0, newSimpleListItem(mDataGenerator, i)); + } + } else { + ItemRecyclingList *list = new ItemRecyclingList; + fillList(mDataGenerator, listSize, list); + setTestWidget(list, listSize, listType); + QTest::qWait(50); + QBENCHMARK { + for (int i = 0; i < AddRemoveCount; ++i) + list->insertItem(0, newRecyclingListItem(mDataGenerator, i)); + } + } + + resetView(); +} + +void tst_GraphicsViewBenchmark::remove100ItemsFromBeginningOfList_data() +{ + insertListData(); +} + +void tst_GraphicsViewBenchmark::remove100ItemsFromBeginningOfList() +{ + QFETCH(int, listSize); + QFETCH(ListType, listType); + + resetView(); + + if (listType == Simple) { + SimpleList *list = new SimpleList; + fillList(mDataGenerator, listSize, list); + setTestWidget(list, listSize, listType); + QTest::qWait(50); + QBENCHMARK { + for (int i = 0; i < AddRemoveCount; ++i) + delete list->takeItem(0); + } + } else { + ItemRecyclingList *list = new ItemRecyclingList; + fillList(mDataGenerator, listSize, list); + setTestWidget(list, listSize, listType); + QTest::qWait(50); + QBENCHMARK { + for (int i = 0; i < AddRemoveCount; ++i) + delete list->takeItem(0); + } + } + + resetView(); +} + +void tst_GraphicsViewBenchmark::deleteList_data() +{ + insertListData(); + QTest::newRow("Simple list containing 1000 items") << 1000 << Simple; + QTest::newRow("Recycling list containing 1000 items") << 1000 << Recycling; +} + +void tst_GraphicsViewBenchmark::deleteList() +{ + QFETCH(int, listSize); + QFETCH(ListType, listType); + + if (listSize < 500) + return; // Too small to measure. + + QGraphicsWidget *list = 0; + if (listType == Simple) + list = new SimpleList; + else + list = new ItemRecyclingList; + fillList(mDataGenerator, listSize, list); + QTest::qWait(20); + + QBENCHMARK_ONCE { + delete list; + } +} + +void tst_GraphicsViewBenchmark::themeChange_data() +{ + QTest::addColumn("listSize"); + QTest::addColumn("listType"); + QTest::addColumn("fromTheme"); + QTest::addColumn("toTheme"); + + QTest::newRow("From Blue to Lime, simple list containing 10 items") << 10 << Simple << Theme::Blue << Theme::Lime; + QTest::newRow("From Lime to Blue, simple list containing 10 items") << 10 << Simple << Theme::Lime << Theme::Blue; + + QTest::newRow("From Blue to Lime, recycling list containing 10 items") << 10 << Recycling << Theme::Blue << Theme::Lime; + QTest::newRow("From Lime to Blue, recycling list containing 10 items") << 10 << Recycling << Theme::Lime << Theme::Blue; + + QTest::newRow("From Blue to Lime, simple list containing 50 items") << 50 << Simple << Theme::Blue << Theme::Lime; + QTest::newRow("From Lime to Blue, simple list containing 50 items") << 50 << Simple << Theme::Lime << Theme::Blue; + + QTest::newRow("From Blue to Lime, recycling list containing 50 items") << 50 << Recycling << Theme::Blue << Theme::Lime; + QTest::newRow("From Lime to Blue, recycling list containing 50 items") << 50 << Recycling << Theme::Lime << Theme::Blue; + + QTest::newRow("From Blue to Lime, simple list containing 500 items") << 500 << Simple << Theme::Blue << Theme::Lime; + QTest::newRow("From Lime to Blue, simple list containing 500 items") << 500 << Simple << Theme::Lime << Theme::Blue; + + QTest::newRow("From Blue to Lime, recycling list containing 500 items") << 500 << Recycling << Theme::Blue << Theme::Lime; + QTest::newRow("From Lime to Blue, recycling list containing 500 items") << 500 << Recycling << Theme::Lime << Theme::Blue; +} + +void tst_GraphicsViewBenchmark::themeChange() +{ + QFETCH(int, listSize); + QFETCH(ListType, listType); + QFETCH(Theme::Themes, fromTheme); + QFETCH(Theme::Themes, toTheme); + + if (fromTheme == toTheme) + qFatal("tst_GraphicsViewBenchmark::themeChange: to and from theme is the same"); + + ensureListSizeAndType(listSize, listType); + ensureTheme(fromTheme); + + QBENCHMARK { + Theme::p()->setTheme(toTheme); + } +} + +static inline QLatin1String stringForTheme(Theme::Themes theme) +{ + if (theme == Theme::Blue) + return QLatin1String("Blue"); + return QLatin1String("Lime"); +} + +static inline QLatin1String stringForListType(tst_GraphicsViewBenchmark::ListType type) +{ + if (type == tst_GraphicsViewBenchmark::Simple) + return QLatin1String("Simple"); + if (type == tst_GraphicsViewBenchmark::Recycling) + return QLatin1String("Recycling"); + return QLatin1String("None"); +} + +static inline QLatin1String stringForScrollStep(tst_GraphicsViewBenchmark::ScrollStep step) +{ + if (step == tst_GraphicsViewBenchmark::Slow) + return QLatin1String("Slow"); + if (step == tst_GraphicsViewBenchmark::Normal) + return QLatin1String("Normal"); + return QLatin1String("Fast"); +} + +static inline QString rowString(int listSize, tst_GraphicsViewBenchmark::ListType listType, + Theme::Themes theme, int toImage, int cache, int angle) +{ + return QString("Items=%1, List=%2, Theme=%3, RenderToImage=%4, Cache=%5, RotAngle=%6") + .arg(QString::number(listSize)).arg(stringForListType(listType)) + .arg(stringForTheme(theme)).arg(QString::number(toImage)) + .arg(QString::number(cache)).arg(QString::number(angle)); +} + +static inline QString rowString(int listSize, tst_GraphicsViewBenchmark::ListType listType, + Theme::Themes theme, int cache, int angle, + tst_GraphicsViewBenchmark::ScrollStep step) +{ + return QString("Items=%1, List=%2, Theme=%3, Cache=%4, RotAngle=%5, Speed=%6") + .arg(QString::number(listSize)).arg(stringForListType(listType)) + .arg(stringForTheme(theme)).arg(QString::number(cache)) + .arg(QString::number(angle)).arg(stringForScrollStep(step)); +} + +void tst_GraphicsViewBenchmark::update_data() +{ + QTest::addColumn("listSize"); + QTest::addColumn("listType"); + QTest::addColumn("theme"); + QTest::addColumn("renderToImage"); + QTest::addColumn("subtreeCache"); + QTest::addColumn("rotationAngle"); + + QList listTypes; + listTypes << Simple << Recycling; + + QList listSizes; + listSizes << 10 << 50 << 500; + + QList themes; + themes << Theme::Blue << Theme::Lime; + + QList rotationAngles; + rotationAngles << 0 << 90; + + // Generate rows: + foreach (ListType listType, listTypes) { + foreach (int listSize, listSizes) { + foreach (int angle, rotationAngles) { + foreach (Theme::Themes theme, themes) { + for (int toImage = 0; toImage < 2; ++toImage) { + for (int cache = 0; cache < 2; ++cache) { + QString string = rowString(listSize, listType, theme, toImage, cache, angle); + QTest::newRow(string.toLatin1()) << listSize << listType << theme << bool(toImage) + << bool(cache) << angle; + } + } + } + } + } + } +} + +void tst_GraphicsViewBenchmark::update() +{ + QFETCH(int, listSize); + QFETCH(ListType, listType); + QFETCH(Theme::Themes, theme); + QFETCH(bool, renderToImage); + QFETCH(bool, subtreeCache); + QFETCH(int, rotationAngle); + + mMainView->viewport()->setUpdatesEnabled(false); + + ensureListSizeAndType(listSize, listType); + ensureTheme(theme); + ensureRotationAngle(rotationAngle); + ensureSubtreeCache(subtreeCache); + ensureImageBasedRendering(renderToImage); + + QEventLoop loop; + QObject::connect(mMainView, SIGNAL(repainted()), &loop, SLOT(quit())); + QTimer::singleShot(4000, &loop, SLOT(quit())); + // Dry run (especially important when cache is enabled). + // NB! setUpdatesEnabled triggers an update(). + mMainView->viewport()->setUpdatesEnabled(true); + loop.exec(QEventLoop::AllEvents | QEventLoop::ExcludeUserInputEvents| QEventLoop::ExcludeSocketNotifiers); + QTest::qWait(50); + + QTimer::singleShot(4000, &loop, SLOT(quit())); + QBENCHMARK { + mMainView->viewport()->update(); + loop.exec(QEventLoop::AllEvents | QEventLoop::ExcludeUserInputEvents| QEventLoop::ExcludeSocketNotifiers); + } +} + +void tst_GraphicsViewBenchmark::scroll_data() +{ + QTest::addColumn("listSize"); + QTest::addColumn("listType"); + QTest::addColumn("theme"); + QTest::addColumn("subtreeCache"); + QTest::addColumn("rotationAngle"); + QTest::addColumn("scrollStep"); + + QList listTypes; + listTypes << Simple << Recycling; + + QList listSizes; + listSizes << 10 << 50 << 500; + + QList themes; + themes << Theme::Blue << Theme::Lime; + + QList rotationAngles; + rotationAngles << 0 << 90; + + QList scrollSteps; + scrollSteps << Slow << Normal << Fast; + + // Generate rows: + foreach (ListType listType, listTypes) { + foreach (int listSize, listSizes) { + foreach (int angle, rotationAngles) { + foreach (ScrollStep step, scrollSteps) { + foreach (Theme::Themes theme, themes) { + for (int cache = 0; cache < 2; ++cache) { + QString string = rowString(listSize, listType, theme, cache, angle, step); + QTest::newRow(string.toLatin1()) << listSize << listType << theme + << bool(cache) << angle << step; + } + } + } + } + } + } +} + +void tst_GraphicsViewBenchmark::scroll() +{ + QFETCH(int, listSize); + QFETCH(ListType, listType); + QFETCH(Theme::Themes, theme); + QFETCH(bool, subtreeCache); + QFETCH(int, rotationAngle); + QFETCH(ScrollStep, scrollStep); + + mMainView->viewport()->setUpdatesEnabled(false); + + ensureListSizeAndType(listSize, listType); + ensureTheme(theme); + ensureRotationAngle(rotationAngle); + ensureSubtreeCache(subtreeCache); + ensureImageBasedRendering(false); + + ScrollBar *sb = 0; + if (listType == Simple) + sb = static_cast(mMainView->testWidget())->verticalScrollBar(); + else + sb = static_cast(mMainView->testWidget())->verticalScrollBar(); + const qreal sliderStart = sb->sliderSize() / qreal(2.0); + const qreal sliderTarget = sliderStart + qreal(scrollStep); + sb->setSliderPosition(sliderStart); + + QEventLoop loop; + QObject::connect(mMainView, SIGNAL(repainted()), &loop, SLOT(quit())); + QTimer::singleShot(4000, &loop, SLOT(quit())); + // Dry run (especially important when cache is enabled). + // NB! setUpdatesEnabled triggers an update(). + mMainView->viewport()->setUpdatesEnabled(true); + loop.exec(QEventLoop::AllEvents | QEventLoop::ExcludeUserInputEvents| QEventLoop::ExcludeSocketNotifiers); + QTest::qWait(50); + + QTimer::singleShot(4000, &loop, SLOT(quit())); + QBENCHMARK { + sb->setSliderPosition(sliderTarget); + loop.exec(QEventLoop::AllEvents | QEventLoop::ExcludeUserInputEvents| QEventLoop::ExcludeSocketNotifiers); + } +} + +QTEST_MAIN(tst_GraphicsViewBenchmark) +#include "main.moc" diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_001_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_001_58x58.png new file mode 100644 index 0000000..525b555 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_001_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_002_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_002_58x58.png new file mode 100644 index 0000000..3d93298 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_002_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_003_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_003_58x58.png new file mode 100644 index 0000000..556cfcb Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_003_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_004_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_004_58x58.png new file mode 100644 index 0000000..94acf9e Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_004_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_005_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_005_58x58.png new file mode 100644 index 0000000..ed0c7c4 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_005_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_006_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_006_58x58.png new file mode 100644 index 0000000..d4b4dc3 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_006_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_007_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_007_58x58.png new file mode 100644 index 0000000..0e45d18 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_007_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_008_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_008_58x58.png new file mode 100644 index 0000000..0c25540 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_008_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_009_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_009_58x58.png new file mode 100644 index 0000000..ce435ea Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_009_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_010_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_010_58x58.png new file mode 100644 index 0000000..021db25 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_010_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_001_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_001_58x58.png new file mode 100644 index 0000000..0051da3 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_001_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_002_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_002_58x58.png new file mode 100644 index 0000000..e8a946a Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_002_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_003_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_003_58x58.png new file mode 100644 index 0000000..b2bb851 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_003_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_004_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_004_58x58.png new file mode 100644 index 0000000..871c075 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_004_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_005_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_005_58x58.png new file mode 100644 index 0000000..d4c18b8 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_005_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_001_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_001_58x58.png new file mode 100644 index 0000000..10a5947 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_001_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_002_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_002_58x58.png new file mode 100644 index 0000000..65b4e03 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_002_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_003_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_003_58x58.png new file mode 100644 index 0000000..935ec07 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_003_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_004_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_004_58x58.png new file mode 100644 index 0000000..fbc1a93 Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_004_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_005_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_005_58x58.png new file mode 100644 index 0000000..af96d3e Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_005_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_006_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_006_58x58.png new file mode 100644 index 0000000..fb4192d Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_006_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_007_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_007_58x58.png new file mode 100644 index 0000000..f5d6dea Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_007_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_008_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_008_58x58.png new file mode 100644 index 0000000..d08b8dc Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_008_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_009_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_009_58x58.png new file mode 100644 index 0000000..768b97d Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_009_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_010_58x58.png b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_010_58x58.png new file mode 100644 index 0000000..d1fe28e Binary files /dev/null and b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_010_58x58.png differ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_360x640px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_360x640px.svg new file mode 100644 index 0000000..1552baf --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_360x640px.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_horisontal_640x360px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_horisontal_640x360px.svg new file mode 100644 index 0000000..5589110 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_horisontal_640x360px.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_default_icon_52x52px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_default_icon_52x52px.svg new file mode 100644 index 0000000..665675b --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_default_icon_52x52px.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_divider_360x76px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_divider_360x76px.svg new file mode 100644 index 0000000..db9fc7a --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_divider_360x76px.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg new file mode 100644 index 0000000..dae2bd4 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_idle_33x33px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_idle_33x33px.svg new file mode 100644 index 0000000..fe12e78 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_idle_33x33px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_offline_33x33px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_offline_33x33px.svg new file mode 100644 index 0000000..0c973f1 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_offline_33x33px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_online_33x33px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_online_33x33px.svg new file mode 100644 index 0000000..fcb434a --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_online_33x33px.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scroll_16x80px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scroll_16x80px.svg new file mode 100644 index 0000000..897be81 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scroll_16x80px.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scrollbar_7x14px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scrollbar_7x14px.svg new file mode 100644 index 0000000..3baec2f --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scrollbar_7x14px.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_left_14x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_left_14x24px.svg new file mode 100644 index 0000000..dd6fb70 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_left_14x24px.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_middle_14x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_middle_14x24px.svg new file mode 100644 index 0000000..cabf928 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_middle_14x24px.svg @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_right_14x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_right_14x24px.svg new file mode 100644 index 0000000..f3a795b --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_right_14x24px.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_356x96px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_356x96px.svg new file mode 100644 index 0000000..a0efd34 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_356x96px.svg @@ -0,0 +1,2007 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_horisontal_636x96px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_horisontal_636x96px.svg new file mode 100644 index 0000000..0a3efd8 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_horisontal_636x96px.svg @@ -0,0 +1,4060 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_default_icon_68x68px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_default_icon_68x68px.svg new file mode 100644 index 0000000..1ffeedd --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_default_icon_68x68px.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_idle_38x38px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_idle_38x38px.svg new file mode 100644 index 0000000..71f49aa --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_idle_38x38px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_offline_38x38px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_offline_38x38px.svg new file mode 100644 index 0000000..84c2514 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_offline_38x38px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_online_38x38px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_online_38x38px.svg new file mode 100644 index 0000000..76daf31 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_online_38x38px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/areacodes.txt b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/areacodes.txt new file mode 100644 index 0000000..dc7e7d8 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/areacodes.txt @@ -0,0 +1,62 @@ ++30 ++31 ++32 ++33 ++34 ++350 ++351 ++352 ++353 ++354 ++355 ++356 ++357 ++358 ++359 ++36 ++3 ++370 ++371 ++372 ++373 ++374 ++375 ++376 ++377 ++377 44 ++378 ++379 ++38 ++380 ++381 ++382 ++383 ++384 ++385 ++386 ++386 49 ++387 ++388 ++388 3 ++389 ++39 ++40 ++41 ++42 ++420 ++421 ++422 ++423 ++424 ++425 ++426 ++427 ++428 ++429 ++43 ++44 ++45 ++46 ++47 ++48 ++49 \ No newline at end of file diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesF.txt b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesF.txt new file mode 100644 index 0000000..4bf1492 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesF.txt @@ -0,0 +1,100 @@ +Aida +Aija +Aila +Aili +Ailikki +Aimi +Aina +Alexia +Alice +Amanda +Amber +Amy +Angela +Angelica +Ann +Beth +Brenda +Brooke +Caitlin +Camilla +Camille +Carmen +Cassandra +Catherine +Edna +Eeva +Eeve +Eevi +Eija +Eila +Eimi +Eleanor +Eleonora +Elizabeth +Ellen +Enna +Enni +Erica +Erika +Erja +Essi +Essie +Heini +Heleena +Helen +Helena +Helene +Helga +Hilja +Hilkka +Hille +Hillervo +Hillevi +Hilma +Irene +Irina +Irja +Irma +Irmeli +Iro +Jacqueline +Jane +Jennifer +Jenny +Jessica +Jill +Kaire +Kaisa +Kaisla +Kaisu +Katarine +Kate +Kate +Kateriina +Katharina +Katharine +Katherine +Kathleen +Marge +Mary +May +Megan +Melinda +Morgan +Nellie +Nelly +Pauline +Peggy +Pepi +Scarlett +Sheila +Shirley +Sissy +Stephanie +Sylvia +Taylor +Terrie +Terry +Victoria +Violet \ No newline at end of file diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesM.txt b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesM.txt new file mode 100644 index 0000000..189d8d0 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesM.txt @@ -0,0 +1,100 @@ +Aabraham +Aadam +Aadolf +Aake +Aaku +Aatu +Ahti +Ahvo +Aimo +Aki +Akseli +Aku +Bartholomew +Ben +Benjamin +Bill +Billie +Billy +Bob +Brendan +Brian +Bryan +Calvin +Carl +Charles +Chester +Chris +Christian +Christopher +Chuck +Dale +Dave +David +Dennis +Dick +Dominick +Donald +Dustin +Dusty +Harri +Heikki +Heimo +Heino +Helmer +Helmeri +Hemmi +Hemmo +Henri +Jeff +Jeffrey +Jermu +Jero +Jerri +Jerry +Jesper +Jesperi +Jesse +Jetro +Jim +Jimi +Jimmy +Joakim +Joe +John +Johnny +Jonah +Jonathan +Joseph +Leevi +Leimo +Leimu +Leino +Leivo +Lenne +Lennu +Mark +Martin +Matt +Matthew +Michael +Mike +Niko +Nooa +Nuutti +Nyyrikki +Okke +Okko +Olavi +Oliver +Olli +Onni +Pertti +Perttu +Walter +Warren +Wesley +William +Willie +Winston +Woodrow \ No newline at end of file diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/lastnames.txt b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/lastnames.txt new file mode 100644 index 0000000..35b3f9f --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/lastnames.txt @@ -0,0 +1,150 @@ +Adams +Allen +Anderson +Bailey +Baker +Barnes +Bell +Bennett +Brooks +Brown +Butler +Campbell +Carter +Clark +Collins +Cook +Cooper +Cox +Cruz +Davis +Daz +Edwards +Evans +Fisher +Flores +Foster +Garca +Gmez +Gonzlez +Gray +Green +Gutirrez +Hall +Harris +Heikkinen +Helenius +Helve +Hernndez +Hill +Hiltunen +Hirvonen +Holm +Honkanen +Howard +Hughes +Huhtala +Huttunen +Hyppnen +Jackson +James +Jenkins +Johnson +Jones +Kauppinen +Kelly +Kemppainen +King +Klemetti +Kokkonen +Kolehmainen +Korhonen +Kurikka +Kuura +Kyr +Krkkinen +Lee +Lewis +Long +Lpez +Martikainen +Martin +Martnez +Mattila +Mikkola +Mikkonen +Miller +Mitchell +Moore +Morales +Morgan +Morris +Muje +Murphy +Mustonen +Myers +Myllrinen +Menp +Mkel +Mkinen +Nelson +Nguyen +Ortiz +Parker +Prez +Perry +Peterson +Phillips +Powell +Price +Ramrez +Reed +Reyes +Richardson +Rivera +Roberts +Robinson +Rodrguez +Rogers +Ross +Russell +Saarinen +Saaristo +Salminen +Salo +Salonen +Snchez +Sanders +Scott +Seppnen +Silvennoinen +Silvo +Smith +Sokura +Stewart +Sullivan +Suomalainen +Taylor +Thomas +Thompson +Torres +Turner +Valkeap +Walker +Valo +Valtonen +Vanhanen +Ward +Watson +Venlinen +Vesa +White +Vihavainen +Williams +Wilson +Virtanen +Wood +Voutilainen +Wright +Vuorela +Young \ No newline at end of file diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_360x640px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_360x640px.svg new file mode 100644 index 0000000..8daf275 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_360x640px.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_horisontal_640x360px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_horisontal_640x360px.svg new file mode 100644 index 0000000..c2b070a --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_horisontal_640x360px.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_53x53px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_53x53px.svg new file mode 100644 index 0000000..6e34f25 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_53x53px.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg new file mode 100644 index 0000000..29c284d --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_divider_360x76px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_divider_360x76px.svg new file mode 100644 index 0000000..db9fc7a --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_divider_360x76px.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg new file mode 100644 index 0000000..0ee3ea2 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_idle_27x47.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_idle_27x47.svg new file mode 100644 index 0000000..925d3eb --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_idle_27x47.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_offline_27x47.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_offline_27x47.svg new file mode 100644 index 0000000..6f74723 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_offline_27x47.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_online_27x47.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_online_27x47.svg new file mode 100644 index 0000000..5695160 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_online_27x47.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scroll_5x80px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scroll_5x80px.svg new file mode 100644 index 0000000..4f6482a --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scroll_5x80px.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scrollbar_5x14px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scrollbar_5x14px.svg new file mode 100644 index 0000000..54a40c3 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scrollbar_5x14px.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_left_14x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_left_14x24px.svg new file mode 100644 index 0000000..a21c91d --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_left_14x24px.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_middle_10x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_middle_10x24px.svg new file mode 100644 index 0000000..b84200d --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_middle_10x24px.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_right_14x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_right_14x24px.svg new file mode 100644 index 0000000..231560d --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_right_14x24px.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_356x96px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_356x96px.svg new file mode 100644 index 0000000..679d9a5 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_356x96px.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_horisontal_636x96px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_horisontal_636x96px.svg new file mode 100644 index 0000000..1ef4fb9 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_horisontal_636x96px.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_default_icon_84x68px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_default_icon_84x68px.svg new file mode 100644 index 0000000..4df0214 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_default_icon_84x68px.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_idle_24x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_idle_24x24px.svg new file mode 100644 index 0000000..2d6da38 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_idle_24x24px.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_offline_24x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_offline_24x24px.svg new file mode 100644 index 0000000..d592026 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_offline_24x24px.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_online_24x24px.svg b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_online_24x24px.svg new file mode 100644 index 0000000..46ad07d --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_online_24x24px.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.cpp new file mode 100644 index 0000000..a3628fd --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.cpp @@ -0,0 +1,401 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "abstractitemcontainer.h" +#include "abstractitemview.h" +#include "abstractviewitem.h" +#include "scrollbar.h" + +AbstractItemContainer::AbstractItemContainer(int bufferSize, QGraphicsWidget *parent) + : GvbWidget(parent), + m_items(), + m_itemView(0), + m_prototype(0), + m_bufferSize(bufferSize), + m_twoColumns(false) +{ +} + +AbstractItemContainer::~AbstractItemContainer() +{ + delete m_prototype; + m_prototype = 0; +} + +AbstractViewItem *AbstractItemContainer::prototype() +{ + return m_prototype; +} + +int AbstractItemContainer::bufferSize() const +{ + return m_bufferSize; +} + +bool AbstractItemContainer::event(QEvent *e) +{ + if (e->type() == QEvent::LayoutRequest) + updateItemBuffer(); + + return QGraphicsWidget::event(e); +} + + +bool AbstractItemContainer::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type()==QEvent::GraphicsSceneResize && m_itemView) { +#if (QT_VERSION >= 0x040600) + const bool caching = m_itemView->listItemCaching(); + m_itemView->setListItemCaching(false); +#endif + + QSizeF s = m_itemView->size(); + s.setWidth(s.width()-m_itemView->verticalScrollBar()->size().width()); + adjustVisibleContainerSize(s); + + m_itemView->updateViewContent(); + updateItemBuffer(); + +#if (QT_VERSION >= 0x040600) + m_itemView->setListItemCaching(caching); +#endif + } + + return QGraphicsWidget::eventFilter(obj, event); +} + +QVariant AbstractItemContainer::itemChange(GraphicsItemChange change, const QVariant &value) +{ + QVariant ichange = QGraphicsWidget::itemChange(change,value); + + if (change == ItemPositionChange) { + if (m_itemView && layout() && !layout()->isActivated()) + m_itemView->refreshContainerGeometry(); + } + return ichange; + } + +/*virtual*/ +void AbstractItemContainer::setItemView(AbstractItemView *view) +{ + m_itemView = view; + + if (m_itemView) { + setParentItem(m_itemView); + m_itemView->installEventFilter(this); + } +} +/*virtual*/ +void AbstractItemContainer::setItemPrototype(AbstractViewItem *ptype) +{ + m_prototype = ptype; + m_prototype->setParentItem(0); + m_prototype->hide(); +} + +/*virtual*/ +void AbstractItemContainer::reset() +{ + qDeleteAll(m_items); + m_items.clear(); + updateItemBuffer(); +} + + +/*virtual*/ +void AbstractItemContainer::addItem(const QModelIndex &index) +{ + if (m_items.count() < maxItemCountInItemBuffer() || + (m_items.count() > 0 && + m_items.first()->modelIndex().row()-1 <= index.row() && + m_items.last()->modelIndex().row() >= index.row())) { + int itemPos = 0; + if (m_items.count() != 0) + itemPos = qMax(0, index.row() - m_items.first()->modelIndex().row()); + + if (itemPos >= m_items.count() || m_items.at(itemPos)->modelIndex() != index) { + AbstractViewItem *item = 0; + if (m_prototype) + item = m_prototype->newItemInstance(); + + if (item) { + item->setModel(m_itemView->model()); + item->setTwoColumns(m_twoColumns); + m_items.insert(itemPos, item); + addItemToVisibleLayout(itemPos, item); + + if (item->modelIndex() != index) { + item->setModelIndex(index); + } + } + } + updateItemBuffer(); + } +} +void AbstractItemContainer::removeItem(const QModelIndex &index) +{ + AbstractViewItem *item = findItemByIndex(index); + + if (item) { + if (maxItemCountInItemBuffer() < m_items.count()) { + m_items.removeOne(item); + removeItemFromVisibleLayout(item); + + delete item; + } + else { + m_items.removeOne(item); + removeItemFromVisibleLayout(item); + + QModelIndex newIndex = m_itemView->nextIndex(m_items.last()->modelIndex()); + if (newIndex.isValid()) { + // Item readded as last item in buffer. + m_items.append(item); + addItemToVisibleLayout(m_items.count() - 1, item); + item->setModelIndex(newIndex); + } else { + // Item readded as first item in buffer. + newIndex = m_itemView->previousIndex(m_items.first()->modelIndex()); + + m_items.prepend(item); + addItemToVisibleLayout(0, item); + item->setModelIndex(newIndex); + } + } + } +} + +/*virtual*/ +int AbstractItemContainer::itemCount() const +{ + return m_items.count(); +} + +AbstractViewItem *AbstractItemContainer::firstItem() +{ + return m_items.first(); +} + +/*virtual*/ +AbstractViewItem* AbstractItemContainer::itemAt(const int row) const +{ + if (row<0 || row >= m_items.count()) + return 0; + return m_items.at(row); +} + +AbstractViewItem* AbstractItemContainer::findItemByIndex(const QModelIndex &index) const +{ + AbstractViewItem *item = 0; + for (int i = 0; i < m_items.count(); ++i) { + if (m_items.at(i)->modelIndex() == index) { + item = m_items.at(i); + break; + } + } + return item; +} + +bool AbstractItemContainer::itemVisibleInView(AbstractViewItem* item, const QRectF &viewRect, bool fullyVisible) const +{ + if (!item || !m_itemView) + return false; + + QRectF itemRectBoundingRect = item->mapToItem(m_itemView, item->boundingRect()).boundingRect(); + + if (fullyVisible && viewRect.contains(itemRectBoundingRect)) + return true; + else if (viewRect.intersects(itemRectBoundingRect)) + return true; + + return false; +} + +void AbstractItemContainer::updateItemBuffer() +{ + if (!m_itemView || (m_itemView && !m_itemView->boundingRect().isValid())) + return; + + int maxCount = maxItemCountInItemBuffer(); + + if (m_items.count() < maxCount) { + // New items needs to be added. + QModelIndex index; + if (m_items.count() > 0) + index = m_items.last()->modelIndex(); + while (m_items.count() < maxCount) { + index = m_itemView->nextIndex(index); + + if (!index.isValid()) + break; + + insertItem(m_items.count(), index); + } + + index = m_items.first()->modelIndex(); + while (m_items.count() < maxCount) { + index = m_itemView->previousIndex(index); + + if (!index.isValid()) + break; + + insertItem(0, index); + } + } + + QRectF viewRect = boundingRect(); + + while (m_items.count() > maxCount) { + int firstVisible = 0; + int lastVisible = 0; + findFirstAndLastVisibleBufferIndex(firstVisible, lastVisible, viewRect, false); + + AbstractViewItem* item = 0; + if (lastVisible != m_items.count() - 1) { + item = m_items.takeLast(); + } + else if (firstVisible != 0 && m_items.first()->modelIndex().row() != firstVisible-1) { + item = m_items.takeFirst(); + } + else { + // All the items are visible. Take the item at the end of the buffer. + item = m_items.takeLast(); + } + + m_items.removeOne(item); + removeItemFromVisibleLayout(item); + delete item; + } +} + +void AbstractItemContainer::insertItem(int pos, const QModelIndex &index) +{ + AbstractViewItem *item = 0; + if (m_prototype) + item = m_prototype->newItemInstance(); + + if (item) { + item->setModel(m_itemView->model()); + item->setModelIndex(index); + item->setTwoColumns(m_twoColumns); + m_items.insert(pos, item); + addItemToVisibleLayout(pos, item); + item->updateItemContents(); + if (pos == 0) + m_itemView->scrollContentsBy(qreal(0.0), + item->effectiveSizeHint(Qt::PreferredSize).height()); + } +} + +void AbstractItemContainer::findFirstAndLastVisibleBufferIndex(int &firstVisibleBufferIndex, + int &lastVisibleBufferIndex, + const QRectF &viewRect, + bool fullyVisible) const +{ + if (layout() && !layout()->isActivated()) + layout()->activate(); + + firstVisibleBufferIndex = -1; + lastVisibleBufferIndex = -1; + + int count = m_items.count(); + for (int i = 0; i < count; ++i) { + if (itemVisibleInView(m_items.at(i), viewRect, fullyVisible)) { + if (firstVisibleBufferIndex == -1) + firstVisibleBufferIndex = i; + lastVisibleBufferIndex = i; + } + else if ( lastVisibleBufferIndex != -1 ) + break; // lastVisibleBufferIndex is already set + } +} + +/*virtual*/ +int AbstractItemContainer::maxItemCountInItemBuffer() const +{ + if (m_itemView && !m_itemView->boundingRect().isEmpty()) + { + return m_itemView->indexCount(); + } + return 0; +} + + +void AbstractItemContainer::themeChange() +{ + for (int i = 0; i themeChange(); +} + +void AbstractItemContainer::updateContent() +{ + for (int i = 0; i updateItemContents(); +} + +#if (QT_VERSION >= 0x040600) +void AbstractItemContainer::setSubtreeCacheEnabled(bool enabled) +{ + for (int i = 0; i setSubtreeCacheEnabled(enabled); + if (m_prototype) + m_prototype->setSubtreeCacheEnabled(enabled); +} +#endif + +void AbstractItemContainer::setTwoColumns(const bool enabled) +{ + if (m_twoColumns == enabled) + return; + + m_twoColumns = enabled; + + for (int i = 0; i < m_items.count(); ++i) + m_items.at(i)->setTwoColumns(enabled); +} + +bool AbstractItemContainer::twoColumns() +{ + return m_twoColumns; +} + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.h new file mode 100644 index 0000000..a0e49ce --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ABSTRACTITEMCONTAINER_H +#define ABSTRACTITEMCONTAINER_H + +#include + +#include "gvbwidget.h" + +class QGraphicsWidget; +class AbstractItemView; +class AbstractViewItem; + +class AbstractItemContainer : public GvbWidget +{ + Q_OBJECT +public: + AbstractItemContainer(int bufferSize, QGraphicsWidget *parent=0); + virtual ~AbstractItemContainer(); + + virtual void addItem(const QModelIndex &index); + virtual void removeItem(const QModelIndex &index); + + virtual void setItemView(AbstractItemView *view); + virtual void setItemPrototype(AbstractViewItem *ptype); + virtual void reset(); + virtual int itemCount() const; + virtual AbstractViewItem* itemAt(const int row) const; + AbstractViewItem* findItemByIndex(const QModelIndex &index) const; + AbstractViewItem *prototype(); + AbstractViewItem *firstItem(); + void updateContent(); + void themeChange(); + int bufferSize() const; + virtual void setTwoColumns(const bool enabled); + bool twoColumns(); + +#if (QT_VERSION >= 0x040600) + void setSubtreeCacheEnabled(const bool enabled); + virtual void setListItemCaching(const bool enabled, const int index) = 0; +#endif + +protected: + virtual void adjustVisibleContainerSize(const QSizeF &size) = 0; + virtual void addItemToVisibleLayout(int index, AbstractViewItem *item) = 0; + virtual void removeItemFromVisibleLayout(AbstractViewItem *item) = 0; + + virtual bool event(QEvent *e); + virtual bool eventFilter(QObject *obj, QEvent *event); + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); + virtual int maxItemCountInItemBuffer() const; + bool itemVisibleInView(AbstractViewItem* item, const QRectF &viewRect, bool fullyVisible = true) const; + +protected: + void updateItemBuffer(); + void findFirstAndLastVisibleBufferIndex(int &firstVisibleBufferIndex, + int &lastVisibleBufferIndex, + const QRectF &viewRect, + bool fullyVisible) const; + QList m_items; + AbstractItemView *m_itemView; + AbstractViewItem *m_prototype; + int m_bufferSize; + +private: + void insertItem(int pos, const QModelIndex &index); + bool m_twoColumns; + + Q_DISABLE_COPY(AbstractItemContainer) +}; + +#endif // ABSTRACTITEMCONTAINER_H diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.cpp new file mode 100644 index 0000000..ba958ca --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.cpp @@ -0,0 +1,444 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "abstractitemview.h" +#include "abstractviewitem.h" +#include "scrollbar.h" + +AbstractItemView::AbstractItemView(QGraphicsWidget *parent) + : AbstractScrollArea(parent), + m_model(0), + m_rootIndex(), + m_container(0), + m_selectionModel(0), + m_currentIndex(), + m_scroller() +{ + setRootIndex(QModelIndex()); +} + +/*virtual*/ +AbstractItemView::~AbstractItemView() +{ +} + +/*virtual*/ +void AbstractItemView::setModel(QAbstractItemModel *model, AbstractViewItem *prototype) +{ + if( m_model == model || !model) + return; + + if (m_model) { + disconnect(m_model, SIGNAL(destroyed()), + this, SLOT(_q_modelDestroyed())); + disconnect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT( dataChanged(QModelIndex,QModelIndex))); + disconnect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(rowsInserted(QModelIndex,int,int))); + disconnect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), + this, SLOT(rowsRemoved(QModelIndex,int,int))); + disconnect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); + disconnect(m_model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); + disconnect(m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), + this, SLOT(columnsInserted(QModelIndex,int,int))); + disconnect(m_model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), + this, SLOT(columnsAboutToBeInserted(QModelIndex,int,int))); + disconnect(m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), + this, SLOT(columnsRemoved(QModelIndex,int,int))); + disconnect(m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(columnsAboutToBeRemoved(QModelIndex,int,int))); + disconnect(m_model, SIGNAL(modelReset()), this, SLOT(reset())); + disconnect(m_model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); + + m_model = 0; + } + + setSelectionModel(0); + + m_currentIndex = QModelIndex(); + m_rootIndex = QModelIndex(); + + m_model = model; + + Q_ASSERT_X(m_model->index(0,0) == m_model->index(0,0), + "AbstractItemView::setModel", + "A model should return the exact same index " + "(including its internal id/pointer) when asked for it twice in a row."); + Q_ASSERT_X(m_model->index(0,0).parent() == QModelIndex(), + "AbstractItemView::setModel", + "The parent of a top level index should be invalid"); + + + connect(m_model, SIGNAL(destroyed()), this, SLOT(modelDestroyed())); + connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT( dataChanged(QModelIndex,QModelIndex))); + connect(m_model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); + connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(rowsInserted(QModelIndex,int,int))); + connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); + connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), + this, SLOT(rowsRemoved(QModelIndex,int,int))); + connect(m_model, SIGNAL(modelReset()), this, SLOT(reset())); + connect(m_model, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); + + setSelectionModel(new QItemSelectionModel(m_model)); + + if (prototype && m_container) { + m_container->setItemPrototype(prototype); + m_container->reset(); + } +} + +/*virtual*/ +void AbstractItemView::setContainer(AbstractItemContainer *container) +{ + m_container = container; + m_container->setItemView(this); + m_container->setParentItem(viewport()); + + viewport()->setFlag( + QGraphicsItem::ItemClipsChildrenToShape, true); + m_scroller.setScrollable(this); + installEventFilter(&m_scroller); +} + +/*virtual*/ +void AbstractItemView::setRootIndex(const QModelIndex &index) +{ + m_rootIndex = index; + // TODO fix this if we change index, container should be updated? Or do we need root index? +} + +/*virtual*/ +int AbstractItemView::indexCount() const +{ + if (m_model) + return m_model->rowCount(m_rootIndex); + return 0; +} + +/*virtual*/ +QAbstractItemModel* AbstractItemView::model() const +{ + return m_model; +} + +/*virtual*/ +QModelIndex AbstractItemView::nextIndex(const QModelIndex &index) const +{ + if (!m_model) + return QModelIndex(); + + if (index.isValid()) + return m_model->index(index.row() + 1, 0, m_rootIndex); + else + return m_model->index(0, 0, m_rootIndex); +} + +/*virtual*/ +QModelIndex AbstractItemView::previousIndex(const QModelIndex &index) const +{ + if (!m_model) + return QModelIndex(); + + if (index.isValid()) + return m_model->index(index.row() - 1, 0, m_rootIndex); + else + return m_model->index(m_model->rowCount(m_rootIndex) - 1, 0, m_rootIndex); +} + +/*virtual*/ +void AbstractItemView::setItemPrototype(AbstractViewItem* prototype) +{ + if (prototype && m_container) { + m_container->setItemPrototype(prototype); + m_container->reset(); + } +} + +void AbstractItemView::setSelectionModel(QItemSelectionModel *smodel) +{ + if (smodel && smodel->model() != m_model) { + return; + } + if (m_selectionModel) { + disconnect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(currentSelectionChanged(QItemSelection, QItemSelection))); + + disconnect(m_selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + this, SLOT(currentIndexChanged(QModelIndex, QModelIndex))); + + delete m_selectionModel; + m_selectionModel = 0; + } + + m_selectionModel = smodel; + + if (m_selectionModel) { + connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(currentSelectionChanged(QItemSelection, QItemSelection))); + connect(m_selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + this, SLOT(currentIndexChanged(QModelIndex, QModelIndex))); + } +} + +/*virtual*/ +void AbstractItemView::currentIndexChanged(const QModelIndex ¤t, const QModelIndex &previous) +{ + Q_UNUSED(previous) + + if (current != m_currentIndex) + m_currentIndex = current; +} + +/*virtual*/ +void AbstractItemView::currentSelectionChanged(const QItemSelection &selected, + const QItemSelection &deselected) +{ + Q_UNUSED(selected) + Q_UNUSED(deselected) +} + +/*virtual*/ +void AbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + Q_UNUSED(topLeft) + Q_UNUSED(bottomRight) + // TODO implement if we like to edit view items. +} + +/*virtual*/ +void AbstractItemView::rowsAboutToBeInserted(const QModelIndex &index, int start, int end) +{ + Q_UNUSED(index) + Q_UNUSED(start) + Q_UNUSED(end) + + // TODO implement +} + + +/*virtual*/ +void AbstractItemView::rowsAboutToBeRemoved(const QModelIndex &index,int start, int end) +{ + Q_UNUSED(index) + Q_UNUSED(start) + Q_UNUSED(end) +} + +/*virtual*/ +void AbstractItemView::rowsRemoved(const QModelIndex &parent,int start, int end) +{ + Q_UNUSED(parent) + Q_UNUSED(start) + Q_UNUSED(end) + + if (start <= m_currentIndex.row() && m_currentIndex.row() <= end) { + QModelIndex newCurrentIndex = m_model->index(start, 0, m_rootIndex); + if (!newCurrentIndex.isValid()) { + newCurrentIndex = m_model->index(qMax(0,start - 1), 0, m_rootIndex); + } + + if (m_selectionModel) { + m_selectionModel->setCurrentIndex(newCurrentIndex, QItemSelectionModel::NoUpdate); + } + } + for (int i = end; i >= start; --i) //The items are already removed from the model. + m_container->removeItem(QModelIndex()); // Indexes are already invalid. +} + +/*virtual*/ +void AbstractItemView::reset() +{ + m_rootIndex = QModelIndex(); + + if (m_container) + m_container->reset(); + + setCurrentIndex(QModelIndex()); + + ScrollBar *sb = verticalScrollBar(); + + if (sb) + sb->setSliderSize(0); +} + +/*virtual*/ +void AbstractItemView::rowsInserted(const QModelIndex &parent, int start, int end) +{ + if (!m_container) + return; + + for (int i = start; i <= end; ++i) + m_container->addItem(m_model->index(i, 0, parent)); + + refreshContainerGeometry(); +} + +/*virtual*/ +void AbstractItemView::modelDestroyed() +{ + m_model = 0; + setSelectionModel(0); + reset(); +} + +/*virtual*/ +void AbstractItemView::layoutChanged() +{ + m_container->reset(); +} + +bool AbstractItemView::event(QEvent *e) +{ + bool result = AbstractScrollArea::event(e); + if (e && e->type()==QEvent::LayoutRequest) { + refreshContainerGeometry(); + result = true; + } + if (e && e->type()==QEvent::GraphicsSceneResize) { + m_scroller.stopScrolling(); + refreshContainerGeometry(); + + m_container->resize(this->size().width()-verticalScrollBar()->size().width(), + m_container->preferredHeight()); + + if(verticalScrollBar()->sliderPosition() > verticalScrollBar()->sliderSize()) + verticalScrollBar()->setSliderPosition(verticalScrollBar()->sliderSize()); + + result = true; + } + return result; +} + +void AbstractItemView::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags selectionFlag) +{ + if (m_selectionModel) + m_selectionModel->setCurrentIndex(index, selectionFlag); +} + +void AbstractItemView::refreshContainerGeometry() +{ + if (!m_container || !m_model) + return; + + if (m_container->layout() && !m_container->layout()->isActivated()) + m_container->layout()->activate(); + + ScrollBar *sb = verticalScrollBar(); + + if (sb) { + AbstractViewItem *item = m_container->itemAt(0); + if (item) { + qreal oneItemH = item->size().height(); + sb->setSliderSize(oneItemH*m_model->rowCount(m_rootIndex)-size().height()); + } + if (!sb->isVisible() && verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff && + contentsRect().height() < m_container->boundingRect().height()) + sb->show(); + } +} + +void AbstractItemView::scrollContentsBy(qreal dx, qreal dy) +{ + AbstractScrollArea::scrollContentsBy(dx, dy); + + if (!viewport() || !m_container || (m_container && m_container->itemCount() <= 0) || + !m_model || (m_model && m_model->rowCount() <= 0) || + (viewport() && viewport()->boundingRect().height() < contentsRect().height())) + return; + + qreal itemH = 1; + + AbstractViewItem *item = m_container->itemAt(0); + if(item && item->size().height() > 1) { + itemH = item->size().height(); + } + else if(item && item->preferredHeight() > 1) { + itemH = item->preferredHeight(); + } + + qreal vpx = m_container->pos().x(); + qreal vpy = m_container->pos().y(); + + if ((vpy+m_container->size().height()-dy > pos().y()+size().height()) && + (qAbs(dy) < itemH) && (vpy-dy <= 0)) { + m_container->setPos(vpx, vpy-dy); + } + else { + qreal vPos = verticalScrollBar()->sliderPosition(); + int startRow = m_model->index(vPos/itemH, 0).row(); + int itemsInContainer = m_container->itemCount(); + + for (int i = 0; iitemAt(i); + changedItem->setModelIndex(m_model->index(startRow+i,0)); +#if (QT_VERSION >= 0x040600) + m_container->setListItemCaching(listItemCaching(), i); +#endif + } + + qreal diff = vPos-startRow*itemH; + + if (diff < 0) + m_container->setPos(vpx, diff); + else + m_container->setPos(vpx, -diff); + } +} + +void AbstractItemView::changeTheme() +{ + if (m_container) + m_container->themeChange(); +} + +void AbstractItemView::updateViewContent() +{ + if (m_container) + m_container->updateContent(); +} diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.h new file mode 100644 index 0000000..9d8220e --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ABSTRACTITEMVIEW_H +#define ABSTRACTITEMVIEW_H + +#include +#include +#include +#include + +#include "listitemcontainer.h" +#include "abstractscrollarea.h" +#include "scroller.h" + +class QItemSelectionModel; + +class AbstractItemView : public AbstractScrollArea +{ + Q_OBJECT +public: + AbstractItemView(QGraphicsWidget *parent = 0); + virtual ~AbstractItemView(); + virtual void setContainer(AbstractItemContainer *container); + virtual void setModel(QAbstractItemModel *model, AbstractViewItem *prototype); + virtual QAbstractItemModel* model() const; + virtual void setItemPrototype(AbstractViewItem* prototype); + + void setSelectionModel(QItemSelectionModel *smodel); + + virtual QModelIndex nextIndex(const QModelIndex &index) const; + virtual QModelIndex previousIndex(const QModelIndex &index) const; + + virtual int indexCount() const; + + void refreshContainerGeometry(); // TODO Can this be moved to scroll area? + + void updateViewContent(); + virtual void scrollContentsBy(qreal dx, qreal dy); + +#if (QT_VERSION >= 0x040600) + virtual bool listItemCaching() const = 0; + virtual void setListItemCaching(bool enabled) = 0; +#endif + +protected: + virtual bool event(QEvent *e); + void changeTheme(); + +public slots: + virtual void setRootIndex(const QModelIndex &index); + void setCurrentIndex(const QModelIndex &index, + QItemSelectionModel::SelectionFlags selectionFlag = QItemSelectionModel::NoUpdate); +protected slots: + virtual void currentIndexChanged(const QModelIndex ¤t, const QModelIndex &previous); + virtual void currentSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + virtual void rowsAboutToBeInserted(const QModelIndex &index, int start, int end); + virtual void rowsInserted(const QModelIndex &parent, int start, int end); + virtual void rowsAboutToBeRemoved(const QModelIndex &index,int start, int end); + virtual void rowsRemoved(const QModelIndex &parent,int start, int end); + virtual void modelDestroyed(); + virtual void layoutChanged(); + virtual void reset(); + +protected: + + QAbstractItemModel *m_model; + QPersistentModelIndex m_rootIndex; + AbstractItemContainer *m_container; + QItemSelectionModel *m_selectionModel; + QPersistentModelIndex m_currentIndex; + +private: + Q_DISABLE_COPY(AbstractItemView) + Scroller m_scroller; +}; + + +#endif // ABSTRACTITEMVIEW_H diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.cpp new file mode 100644 index 0000000..8bef331 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.cpp @@ -0,0 +1,249 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "abstractscrollarea.h" +#include "scrollbar.h" + +AbstractScrollArea::AbstractScrollArea(QGraphicsWidget *parent) + : GvbWidget(parent) + , m_viewport(0) + , m_horizontalScrollBar(0) + , m_verticalScrollBar(0) + , m_prevHorizontalValue(0.0) + , m_prevVerticalValue(0.0) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setContentsMargins(0, 0, 0, 0); + + m_horizontalScrollBar = new ScrollBar(Qt::Horizontal, this); + m_horizontalScrollBar->hide(); + m_horizontalScrollBar->setContentsMargins(0, 0, 0, 0); + m_horizontalScrollBarPolicy = Qt::ScrollBarAsNeeded; + m_horizontalScrollBar->setZValue(zValue()+1); // Raise scroll bar to top + m_horizontalScrollBar->setVisible(false); + + connect(m_horizontalScrollBar, SIGNAL(sliderPositionChange(qreal)), + this, SLOT(horizontalScroll(qreal))); + connect(m_horizontalScrollBar, SIGNAL(sliderPressed()), + this, SLOT(horizontalScrollStart())); + + m_verticalScrollBar = new ScrollBar(Qt::Vertical, this); + m_verticalScrollBar->hide(); + m_verticalScrollBar->setContentsMargins(0, 0, 0, 0); + m_verticalScrollBarPolicy = Qt::ScrollBarAsNeeded; + m_verticalScrollBar->setZValue(zValue()+1); // Raise scroll bar to top + m_verticalScrollBar->setVisible(false); + + connect(m_verticalScrollBar, SIGNAL(sliderPositionChange(qreal)), + this, SLOT(verticalScroll(qreal))); + connect(m_verticalScrollBar, SIGNAL(sliderPressed()), + this, SLOT(verticalScrollStart())); + + QGraphicsWidget *viewport = new QGraphicsWidget; + setViewport(viewport); +} + +AbstractScrollArea::~AbstractScrollArea() +{ +} + +ScrollBar *AbstractScrollArea::verticalScrollBar() const +{ + return m_verticalScrollBar; +} + +ScrollBar *AbstractScrollArea::horizontalScrollBar() const +{ + return m_horizontalScrollBar; +} + +void AbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy) +{ + m_horizontalScrollBarPolicy = policy; +} + +void AbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy) +{ + m_verticalScrollBarPolicy = policy; +} + +Qt::ScrollBarPolicy AbstractScrollArea::verticalScrollBarPolicy() const +{ + return m_verticalScrollBarPolicy; +} + +Qt::ScrollBarPolicy AbstractScrollArea::horizontalScrollBarPolicy() const +{ + return m_horizontalScrollBarPolicy; +} + +QGraphicsWidget *AbstractScrollArea::viewport() const +{ + return m_viewport; +} + +void AbstractScrollArea::setViewport(QGraphicsWidget *viewport) +{ + if (m_viewport) { + m_viewport->setParentItem(0); + + QList children = m_viewport->childItems(); + + foreach (QGraphicsItem *child, children) + child->setParentItem(0); + + delete m_viewport; + } + + m_viewport = viewport; + + if (viewport) { + + m_viewport->setParentItem(this); + m_viewport->setContentsMargins(0, 0, 0, 0); + + adjustScrollBars(); + } + + emit viewportChanged(viewport); +} + +bool AbstractScrollArea::event(QEvent *e) +{ + if (e->type() == QEvent::ApplicationLayoutDirectionChange + || e->type() == QEvent::LayoutDirectionChange) { + } else if (e->type() == QEvent::GraphicsSceneResize) { + QGraphicsSceneResizeEvent *event = + static_cast(e); + + QSizeF newSize = event->newSize(); + QRectF hrect = m_horizontalScrollBar->boundingRect(); + QRectF vrect = m_verticalScrollBar->boundingRect(); + + QSizeF vpSize = newSize; + + if (m_horizontalScrollBarPolicy != Qt::ScrollBarAlwaysOff) + vpSize.setHeight(newSize.height() - hrect.height()); + if (m_verticalScrollBarPolicy != Qt::ScrollBarAlwaysOff) + vpSize.setWidth(newSize.width() - vrect.width()); + + m_viewport->resize(vpSize); + + adjustScrollBars(); + } + + return QGraphicsWidget::event(e); +} + + +void AbstractScrollArea::scrollContentsBy(qreal dx, qreal dy) +{ + Q_UNUSED(dx) + Q_UNUSED(dy) + prepareGeometryChange(); +} + +void AbstractScrollArea::verticalScrollStart() +{ + m_prevVerticalValue = m_verticalScrollBar->sliderPosition(); +} + +void AbstractScrollArea::verticalScroll(qreal value) +{ + qreal dy = value - m_prevVerticalValue; + if (!qFuzzyCompare(dy,qreal(0.0))) { + scrollContentsBy(0.0, dy); + m_prevVerticalValue = value; + } +} + +void AbstractScrollArea::horizontalScrollStart() +{ + m_prevHorizontalValue = m_horizontalScrollBar->sliderPosition(); +} + +void AbstractScrollArea::horizontalScroll(qreal value) +{ + qreal dx = value - m_prevHorizontalValue; + if (!qFuzzyCompare(dx,qreal(0.0))) { + scrollContentsBy(dx, 0.0); + m_prevHorizontalValue = value; + } +} + +void AbstractScrollArea::adjustScrollBars() +{ + if (m_horizontalScrollBarPolicy == Qt::ScrollBarAlwaysOff) { + m_horizontalScrollBar->hide(); + } else { + m_horizontalScrollBar->show(); + + QRectF sbgeom = boundingRect(); + + sbgeom.setTop(sbgeom.bottom() - m_horizontalScrollBar->boundingRect().height()); + sbgeom.setRight(sbgeom.right() - m_verticalScrollBar->boundingRect().width()); + m_horizontalScrollBar->setGeometry(sbgeom); + } + + if (m_verticalScrollBarPolicy == Qt::ScrollBarAlwaysOff) { + m_verticalScrollBar->hide(); + QRectF sbgeom = boundingRect(); + sbgeom.setLeft(sbgeom.right()); + sbgeom.setBottom(sbgeom.bottom()); + m_verticalScrollBar->setGeometry(sbgeom); + } else { + m_verticalScrollBar->show(); + + QRectF sbgeom = boundingRect(); + + sbgeom.setLeft(sbgeom.right() - m_verticalScrollBar->boundingRect().width()); + if (m_horizontalScrollBarPolicy != Qt::ScrollBarAlwaysOff) + sbgeom.setBottom(sbgeom.bottom() - m_horizontalScrollBar->boundingRect().height()); + m_verticalScrollBar->setGeometry(sbgeom); + } +} + + + + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.h new file mode 100644 index 0000000..c39da14 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ABSTRACTSCROLLAREA_H +#define ABSTRACTSCROLLAREA_H + +#include "gvbwidget.h" + +class ScrollBar; +class QGraphicsGridLayout; + +class AbstractScrollArea : public GvbWidget +{ + Q_OBJECT + +public: + + AbstractScrollArea(QGraphicsWidget *parent = 0); + ~AbstractScrollArea(); + +public: + + void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy); + void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy); + Qt::ScrollBarPolicy verticalScrollBarPolicy() const; + Qt::ScrollBarPolicy horizontalScrollBarPolicy() const; + + QGraphicsWidget *viewport() const; + void setViewport(QGraphicsWidget *viewport); + + ScrollBar *verticalScrollBar() const; + ScrollBar *horizontalScrollBar() const; + +signals: + + void viewportChanged(QGraphicsWidget *viewport); + +protected: + + virtual bool event(QEvent *e); + virtual void scrollContentsBy(qreal dx, qreal dy); + +private slots: + + void verticalScrollStart(); + void verticalScroll(qreal); + void horizontalScrollStart(); + void horizontalScroll(qreal); + +private: + + void adjustScrollBars(); + + QGraphicsWidget *m_viewport; + ScrollBar *m_horizontalScrollBar; + ScrollBar *m_verticalScrollBar; + Qt::ScrollBarPolicy m_verticalScrollBarPolicy; + Qt::ScrollBarPolicy m_horizontalScrollBarPolicy; + qreal m_prevHorizontalValue; + qreal m_prevVerticalValue; +}; + +#endif // ABSTRACTSCROLLAREA_H diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.cpp new file mode 100644 index 0000000..83938c1 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "abstractviewitem.h" + +AbstractViewItem::AbstractViewItem(QGraphicsWidget *parent) + : GvbWidget(parent), + m_index(), + m_itemView(0), + m_prototype(0) +{ +} + +/*virtual*/ +AbstractViewItem::~AbstractViewItem() +{ +} + +QModelIndex AbstractViewItem::modelIndex() const +{ + return m_index; +} + +AbstractViewItem *AbstractViewItem::prototype() const +{ + return m_prototype; +} + +AbstractItemView *AbstractViewItem::itemView() const +{ + return m_itemView; +} + +void AbstractViewItem::setItemView(AbstractItemView *itemView) +{ + m_itemView = itemView; +} + +void AbstractViewItem::setModelIndex(const QModelIndex &index) +{ + if (m_index != index) { + m_index = index; + updateItemContents(); + } +} + +/*virtual*/ +QSizeF AbstractViewItem::effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + return GvbWidget::effectiveSizeHint(which, constraint); +} + +/*virtual*/ +bool AbstractViewItem::event(QEvent *e) +{ + return QGraphicsWidget::event(e); +} + +/*virtual*/ +void AbstractViewItem::updateItemContents() +{ + ; // No impl yet +} + +/*virtual*/ +void AbstractViewItem::themeChange() +{ + ; // No impl yet +} + +#if (QT_VERSION >= 0x040600) +/*virtual*/ +void AbstractViewItem::setSubtreeCacheEnabled(bool enabled) +{ + Q_UNUSED(enabled) + ; // No impl +} +#endif + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.h new file mode 100644 index 0000000..54552c2 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ABSTRACTVIEWITEM_H +#define ABSTRACTVIEWITEM_H + +#include + +#include "gvbwidget.h" +#include "abstractitemview.h" +#include "listitem.h" + +class QGraphicsWidget; + +class AbstractViewItem : public GvbWidget +{ + Q_OBJECT +public: + AbstractViewItem(QGraphicsWidget *parent = 0); + virtual ~AbstractViewItem(); + + virtual AbstractViewItem *newItemInstance() = 0; + + QModelIndex modelIndex() const; + + void setModelIndex(const QModelIndex &index); + + AbstractViewItem *prototype() const; + AbstractItemView *itemView() const; + void setItemView(AbstractItemView *itemView) ; + virtual void updateItemContents(); + virtual void themeChange(); + +#if (QT_VERSION >= 0x040600) + virtual void setSubtreeCacheEnabled(bool enabled); +#endif + + virtual QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; + + virtual void setModel(QAbstractItemModel *model) = 0; + virtual QVariant data(int role) const = 0; + virtual void setData(const QVariant &value, int role = Qt::DisplayRole) = 0; + virtual void setTwoColumns(const bool enabled) = 0; + +protected: + virtual bool event(QEvent *e); + + QPersistentModelIndex m_index; + +private: + Q_DISABLE_COPY(AbstractViewItem) + + AbstractItemView *m_itemView; + AbstractViewItem *m_prototype; + +}; + +#endif // ABSTRACTVIEWITEM_H diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.cpp new file mode 100644 index 0000000..fc3ed61 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "backgrounditem.h" +#include "theme.h" + +BackgroundItem::BackgroundItem(const QString &filename, QGraphicsWidget *parent) + : GvbWidget(parent), + m_background(), + m_fileName(filename) +{ + setContentsMargins(0,0,0,0); + + connect(Theme::p(), SIGNAL(themeChanged()), this, SLOT(themeChange())); +} + +BackgroundItem::~BackgroundItem() +{ + +} + +void BackgroundItem::resizeEvent(QGraphicsSceneResizeEvent *event) +{ + GvbWidget::resizeEvent(event); + m_background = Theme::p()->pixmap(m_fileName, size().toSize()); +} + +void BackgroundItem::paint(QPainter *painter, + const QStyleOptionGraphicsItem *option, + QWidget *widget) +{ + Q_UNUSED(widget) + painter->setCompositionMode(QPainter::CompositionMode_Source); + painter->drawPixmap(option->exposedRect, m_background, option->exposedRect); +} + +void BackgroundItem::themeChange() +{ + m_background = Theme::p()->pixmap(m_fileName, size().toSize()); + update(); +} + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.h new file mode 100644 index 0000000..f127a7b --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __BACKGROUNDITEM_H__ +#define __BACKGROUNDITEM_H__ + +#include + +#include "gvbwidget.h" + +class QGraphicsWidget; + +class BackgroundItem : public GvbWidget +{ + Q_OBJECT + +public: + BackgroundItem(const QString &filename, QGraphicsWidget *parent=0); + ~BackgroundItem(); + + void paint(QPainter *painter, + const QStyleOptionGraphicsItem *option, + QWidget *widget = 0); + void resizeEvent(QGraphicsSceneResizeEvent *event); + +public slots: + void themeChange(); + +private: + QPixmap m_background; + QString m_fileName; +}; + +#endif /* __BACKGROUNDITEM_H__ */ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/button.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/button.cpp new file mode 100644 index 0000000..6a8e81c --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/button.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "button.h" +#include "theme.h" + +static const int MinTextWidthAsChars = 8; + +class ButtonPrivate { + Q_DECLARE_PUBLIC(Button) + +public: + + ButtonPrivate(Button *button) + : down(false) + , q_ptr(button) + { + textItem = new QGraphicsSimpleTextItem(q_ptr); + } + + QGraphicsSimpleTextItem *textItem; + bool down; + Button *q_ptr; +}; + +Button::Button(const QString &text, QGraphicsItem *parent, QSizeF minimumSize) + : QGraphicsWidget(parent) + , d_ptr(new ButtonPrivate(this)), m_background(), m_selected(false) +{ + Q_D(Button); + setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + //setCacheMode(QGraphicsItem::ItemCoordinateCache); + if(minimumSize.isValid()) + setMinimumSize(minimumSize); + setContentsMargins(0, 0, 0, 0); + d->textItem->setText(text); + prepareGeometryChange(); + + m_font = Theme::p()->font(Theme::MenuItem); + d->textItem->setFont(m_font); + connect(Theme::p(), SIGNAL(themeChanged()), this, SLOT(themeChange())); +} + +Button::~Button() +{ + delete d_ptr; +} + +bool Button::isDown() +{ + Q_D(Button); + + return d->down; +} + +void Button::setText(const QString &text) +{ + Q_D(Button); + d->textItem->setText(text); + update(); +} + +QString Button::text() +{ + Q_D(Button); + return d->textItem->text(); +} + +void Button::paint(QPainter *painter, + const QStyleOptionGraphicsItem *option, + QWidget *widget) +{ + Q_UNUSED(widget); + Q_UNUSED(option); + + if(!m_background.isNull()) + painter->drawPixmap(QPoint(), m_background); + if(m_selected) { + painter->setBrush(Qt::black); + painter->setOpacity(0.2); + painter->drawRect(boundingRect().toRect()); + } +} + +QSizeF Button::sizeHint(Qt::SizeHint which, + const QSizeF &constraint) const +{ + Q_D(const Button); + + switch (which) + { + case Qt::MinimumSize: + { + QFontMetricsF fm(d->textItem->font()); + return QSizeF(MinTextWidthAsChars * fm.maxWidth(), fm.height()); + } + case Qt::PreferredSize: + { + QFontMetricsF fm(d->textItem->font()); + return QSizeF(fm.width(d->textItem->text()), fm.height()); + } + default: + return QGraphicsWidget::sizeHint(which, constraint); + } +} + +void Button::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + Q_D(Button); + + if (event->button() != Qt::LeftButton || + !sceneBoundingRect().contains(event->scenePos())) + return; + + d->down = true; + + prepareGeometryChange(); + emit pressed(); + +} + +void Button::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + Q_D(Button); + + if (!d->down || event->button() != Qt::LeftButton) + return; + + d->down = false; + + prepareGeometryChange(); + + emit released(); + + if (sceneBoundingRect().contains(event->scenePos())) + emit clicked(); +} + +void Button::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + Q_UNUSED(event); +} + +void Button::resizeEvent(QGraphicsSceneResizeEvent *event) +{ + Q_D(Button); + QGraphicsWidget::resizeEvent(event); + + QRectF rect = d->textItem->boundingRect(); + QRectF buttonrect = this->boundingRect(); + d->textItem->setPos((buttonrect.width() - rect.width())/2, (buttonrect.height() - rect.height())/2 ); + + QSize currentSize = buttonrect.size().toSize(); + if( m_background.size() != currentSize && (currentSize.width() > 0 && currentSize.height() > 0) ) { + m_background = Theme::p()->pixmap("status_field_middle.svg", buttonrect.size().toSize()); + } +} + +void Button::setBackground(QPixmap& background) +{ + m_background = background; +} + +void Button::themeChange() +{ + Q_D(Button); + + m_font = Theme::p()->font(Theme::MenuItem); + d->textItem->setFont(m_font); +} diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/button.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/button.h new file mode 100644 index 0000000..d4fca2f --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/button.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BUTTON_H +#define BUTTON_H + +#include + +class ButtonPrivate; +class QTextDocument; + +class QPixmap; +class QFont; + +class Button : public QGraphicsWidget +{ + Q_OBJECT + Q_DECLARE_PRIVATE(Button) + +public: + + Button(const QString &text, QGraphicsItem *parent=0, QSizeF minimumSize = QSizeF()); + virtual ~Button(); + +signals: + + void clicked(bool checked = false); + void pressed(); + void released(); + +public slots: + + void themeChange(); + void setText(const QString &text); + QString text(); + +public: + + void setBackground(QPixmap& background); + bool isDown(); + void select(bool select){m_selected = select;} + void click() {emit clicked();} + +private: + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget = 0); + QSizeF sizeHint(Qt::SizeHint which, + const QSizeF &constraint = QSizeF()) const; + + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + void resizeEvent(QGraphicsSceneResizeEvent *event); + +private: + Q_DISABLE_COPY(Button) + ButtonPrivate *d_ptr; + QPixmap m_background; + QFont m_font; + bool m_selected; +}; + +#endif // BUTTON_H diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp new file mode 100644 index 0000000..9205bed --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp @@ -0,0 +1,206 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "commandline.h" + +static void usage(const char *appname) +{ + printf("%s [options]\n", appname); + printf("Options:\n"); + printf("\t -h,-help : This help\n"); +#ifdef AUTO_TESTS + printf("\t -o file : Write output to file\n"); + printf("\t -xml : Outputs results as XML document\n"); + printf("\t -lightxml : Outputs results as stream of XML tags\n"); + printf("\t -script-name file : Use this script instead of internal script file\n"); +#endif + printf("\t -resolution : UI resolution in format WxH where width and height are positive values\n"); + printf("\t -rotation : UI rotation in degrees\n"); + printf("\t -subtree-cache : Enables usage of subtree caching method\n"); + printf("\t -noresusage : Disables CPU and Memory usage measurement\n"); +#ifndef AUTO_TESTS + printf("\t -fps : Output FPS count to stdout during application execution\n"); + printf("\t -items : Count of items created to the list\n"); +#endif +#if ENABLE_OPENGL +#ifndef QT_NO_OPENGL + printf("\t -opengl : Enables OpenGL usage. Building PRECONDITIONS: ENABLE_OPENGL is on. QT_NO_OPENGL is off.\n"); +#endif +#endif + printf("\n"); +} + +bool readSettingsFromCommandLine(int argc, char *argv[], + Settings& config) +{ + bool builtWithOpenGL = false; + Settings::Options options; + +#if ENABLE_OPENGL +#ifndef QT_NO_OPENGL + builtWithOpenGL = true; +#endif +#endif + for (int i=0; i= argc) { + printf("-o needs an extra parameter specifying the filename\n"); + usage(argv[0]); + return false; + } else { + config.setOutputFileName(QString(argv[i+1])); + i++; + } + } + if (strcmp(argv[i], "-xml") == 0) { + config.setResultFormat(1); // See FileLogger::ResultFormat + } + if (strcmp(argv[i], "-lightxml") == 0) { + config.setResultFormat(2); // See FileLogger::ResultFormat + } + if (strcmp(argv[i], "-script-name") == 0) { + if (i + 1 >= argc) { + printf("-script-name needs an extra parameter specifying the filename\n"); + usage(argv[0]); + return false; + } else { + config.setScriptName(QString(argv[i+1])); + i++; + } + } +#endif + if (strcmp(argv[i], "-resolution") == 0) { + if (i + 1 >= argc) { + printf("-resolution needs an extra parameter specifying the application UI resolution\n"); + usage(argv[0]); + return false; + } + else { + QStringList res = QString(argv[i+1]).split("x"); + if (res.count() != 2) { + printf("-resolution parameter UI resolution should be set in format WxH where width and height are positive values\n"); + usage(argv[0]); + return false; + } + int width = res.at(0).toInt(); + int height = res.at(1).toInt(); + + config.setSize(QSize(width, height)); + + if (width <=0 || height <=0) { + printf("-resolution parameter UI resolution should be set in format WxH where width and height are positive values\n"); + usage(argv[0]); + return false; + } + i++; + } + } + if (strcmp(argv[i], "-rotation") == 0) { + if (i + 1 >= argc) { + printf("-rotation needs an extra parameter specifying the application UI rotation in degrees\n"); + usage(argv[0]); + return false; + } + else { + bool ok; + int angle = QString(argv[i+1]).toInt(&ok); + if (!ok) { + printf("-rotation parameter should specify rotation angle in degrees\n"); + usage(argv[0]); + return false; + } + config.setAngle(angle); + i++; + } + } + if (strcmp(argv[i], "-subtree-cache") == 0) { + options |= Settings::UseListItemCache; + } + if (strcmp(argv[i], "-opengl") == 0) { + if (builtWithOpenGL) + options |= Settings::UseOpenGL; + else { + printf("-opengl parameter can be used only with building PRECONDITIONS: ENABLE_OPENGL is on. QT_NO_OPENGL is off.\n"); + usage(argv[0]); + return false; + } + } + if (strcmp(argv[i], "-noresusage") == 0) { + options |= Settings::NoResourceUsage; + } +#ifndef AUTO_TESTS + if (strcmp(argv[i], "-fps") == 0) { + options |= Settings::OutputFps; + } + if (strcmp(argv[i], "-items") == 0) { + if (i + 1 >= argc) { + printf("-items needs an extra parameter specifying amount of list items\n"); + usage(argv[0]); + return false; + } + else { + bool ok; + int amount = QString(argv[i+1]).toInt(&ok); + if (!ok) { + printf("-items needs an extra parameter specifying amount (integer) of list items\n"); + usage(argv[0]); + return false; + } + config.setListItemCount(amount); + i++; + } + } +#endif + } + + config.setOptions(options); + + return true; +} + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.h new file mode 100644 index 0000000..3794638 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef COMMANDLINE_H +#define COMMANDLINE_H + +#include "settings.h" + +bool readSettingsFromCommandLine(int argc, + char *argv[], + Settings& settings); + + +#endif // COMMANDLINE_H diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.cpp new file mode 100644 index 0000000..2716227 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "theme.h" + +#include "dummydatagen.h" + +DummyDataGenerator::DummyDataGenerator() : m_isMale(false) +{ + QFile countryCodeFile(":/contact/areacodes.txt"); + countryCodeFile.open(QIODevice::ReadOnly); + while (!countryCodeFile.atEnd()) { + m_countryCodes << QString(countryCodeFile.readLine()).remove("\n"); + } + + QFile firstNameFFile(":/contact/firstnamesF.txt"); + firstNameFFile.open(QIODevice::ReadOnly); + while (!firstNameFFile.atEnd()) { + m_firstNamesF << QString(firstNameFFile.readLine()).remove("\n"); + } + + QFile firstNameMFile(":/contact/firstnamesM.txt"); + firstNameMFile.open(QIODevice::ReadOnly); + while (!firstNameMFile.atEnd()) { + m_firstNamesM << QString(firstNameMFile.readLine()).remove("\n"); + } + + QFile lastNameFile(":/contact/lastnames.txt"); + lastNameFile.open(QIODevice::ReadOnly); + while (!lastNameFile.atEnd()) { + m_lastNames << QString(lastNameFile.readLine()).remove("\n"); + } + Reset(); +} + +DummyDataGenerator::~DummyDataGenerator() +{ + +} + +void DummyDataGenerator::Reset() +{ + qsrand(100); +} + +QString DummyDataGenerator::randomPhoneNumber(QString indexNumber) +{ + int index = qrand()%m_countryCodes.count(); + QString countryCode = m_countryCodes.at(index); + QString areaCode = QString::number(index) + QString("0").repeated(2-QString::number(index).length()); + QString beginNumber = QString::number(555-index*2); + QString endNumber = QString("0").repeated(4-indexNumber.length()) + indexNumber; + + return countryCode +" " + areaCode +" " + beginNumber +" " + endNumber; +} + +QString DummyDataGenerator::randomFirstName() +{ + m_isMale = !m_isMale; + if (m_isMale) + return m_firstNamesM.at(qrand()%m_firstNamesM.count()); + return m_firstNamesF.at(qrand()%m_firstNamesF.count()); +} + +QString DummyDataGenerator::randomLastName() +{ + return m_lastNames.at(qrand()%m_lastNames.count()); +} + +QString DummyDataGenerator::randomName() +{ + return QString(randomFirstName()+QString(", ")+randomLastName()); +} + +QString DummyDataGenerator::randomIconItem() +{ + QString avatar = Theme::p()->pixmapPath() + "contact_default_icon.svg"; + if (qrand()%4) { + int randVal = 1+qrand()%25; + + if(m_isMale && randVal > 15) { + randVal -= 15; + } + if(!m_isMale && randVal <= 10) { + randVal += 10; + } + + avatar = QString(":/avatars/avatar_%1.png").arg(randVal, 3, 10, QChar('0')); + } + return avatar; +} + +QString DummyDataGenerator::randomStatusItem() +{ + switch ( qrand()%3 ) + { + case 0: return Theme::p()->pixmapPath() + "contact_status_online.svg"; + case 1: return Theme::p()->pixmapPath() + "contact_status_offline.svg"; + case 2: return Theme::p()->pixmapPath() + "contact_status_idle.svg"; + } + return 0; +} diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.h new file mode 100644 index 0000000..df59221 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __DUMMYDATAGEN_H__ +#define __DUMMYDATAGEN_H__ + +#include +#include + +class DummyDataGenerator : public QObject +{ + Q_OBJECT +public: + DummyDataGenerator(); + ~DummyDataGenerator(); + +public: + void Reset(); + QString randomPhoneNumber(QString indexNumber); + QString randomFirstName(); + QString randomLastName(); + QString randomName(); + QString randomIconItem(); + QString randomStatusItem(); + +private: + QStringList m_countryCodes; + QStringList m_firstNamesF; + QStringList m_firstNamesM; + QStringList m_lastNames; + bool m_isMale; +}; + +#endif // __DUMMYDATAGEN_H__ diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.cpp new file mode 100644 index 0000000..244b76b --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "gvbwidget.h" + +GvbWidget::GvbWidget(QGraphicsItem * parent, Qt::WindowFlags wFlags) + : QGraphicsWidget(parent, wFlags) +{ + +} + +GvbWidget::~GvbWidget() +{ +} + +void GvbWidget::keyPressEvent(QKeyEvent *event) +{ + Q_UNUSED(event) +} + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.h new file mode 100644 index 0000000..d4ae6de --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GVBWIDGET_H +#define GVBWIDGET_H + +#include + +class GvbWidget : public QGraphicsWidget +{ + Q_OBJECT + +public: + + GvbWidget(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); + ~GvbWidget(); + virtual void keyPressEvent(QKeyEvent *event); +}; + +#endif diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.cpp new file mode 100644 index 0000000..77866e4 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#if (QT_VERSION >= 0x040600) +#include +#endif + +#include "iconitem.h" + +IconItem::IconItem(const QString &filename, QGraphicsItem *parent) + : GvbWidget(parent) + , m_filename(filename) + , m_rotation(0.0) +#if (QT_VERSION >= 0x040600) + , m_opacityEffect(0) +#endif + , m_smoothTransformation(false) +{ + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + setContentsMargins(0,0,0,0); + setPreferredSize(58,58); +} + +IconItem::~IconItem() +{ +} + +void IconItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + + reload(); + + const QPointF c = boundingRect().center(); + painter->translate(c.x(), c.y()); + painter->rotate(m_rotation); + painter->translate(-c.x(), -c.y()); + + if (m_smoothTransformation) + painter->setRenderHints(QPainter::SmoothPixmapTransform); + + painter->drawPixmap(0,0, m_pixmap); +} + +QSizeF IconItem::sizeHint(Qt::SizeHint which, + const QSizeF &constraint) const +{ + switch (which) + { + case Qt::MinimumSize: + case Qt::PreferredSize: + case Qt::MaximumSize: + return m_pixmap.size(); + + default: + return GvbWidget::sizeHint(which, constraint); + } +} + +void IconItem::reload() +{ + const QSize iconSize = size().toSize(); + if (iconSize.width() == 0 || iconSize.height() == 0) + return; + + const QString key = m_filename+QString::number(iconSize.width())+QString::number(iconSize.height()); + if (QPixmapCache::find(key, m_pixmap)) + return; + + if (m_filename.endsWith(".svg", Qt::CaseInsensitive)) + { + m_pixmap = QPixmap(iconSize); + m_pixmap.fill(Qt::transparent); + QSvgRenderer doc(m_filename); + QPainter painter(&m_pixmap); + painter.setViewport(0, 0, iconSize.width(), iconSize.height()); + doc.render(&painter); + } + else + { + m_pixmap = QPixmap(m_filename).scaled(iconSize); + } + + QPixmapCache::insert(key, m_pixmap); + updateGeometry(); +} + +QString IconItem::fileName() const +{ + return m_filename; +} + +void IconItem::setFileName(const QString &filename) +{ + if( m_filename != filename) { + m_filename = filename; + reload(); + } +} + +#if (QT_VERSION >= 0x040600) +void IconItem::setOpacityEffectEnabled(const bool enable) +{ + if (!m_opacityEffect) + { + QRadialGradient gradient(0.5, 0.5, 1.0); + gradient.setCoordinateMode(QGradient::ObjectBoundingMode); + gradient.setColorAt(0.0, QColor(0,0,0, 255)); + gradient.setColorAt(0.46, QColor(0,0,0, 255)); + gradient.setColorAt(0.62, QColor(0,0,0, 0)); + + m_opacityEffect = new QGraphicsOpacityEffect; + m_opacityEffect->setOpacityMask(gradient); + m_opacityEffect->setOpacity(1.0); + this->setGraphicsEffect(m_opacityEffect); + } + m_opacityEffect->setEnabled(enable); +} + +bool IconItem::isOpacityEffectEnabled() const +{ + if (m_opacityEffect) + return m_opacityEffect->isEnabled(); + + return false; +} +#endif diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.h new file mode 100644 index 0000000..7f0a232 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ICONITEM_H +#define ICONITEM_H + +#include + +#include "gvbwidget.h" + +#if (QT_VERSION >= 0x040600) +class QGraphicsOpacityEffect; +#endif +class QPainter; + +class IconItem : public GvbWidget +{ + Q_OBJECT + +public: + + IconItem(const QString &filename = "", QGraphicsItem *parent = 0); + + virtual ~IconItem(); + + QString fileName() const; + void setFileName(const QString &filename); + +#if (QT_VERSION >= 0x040600) + void setOpacityEffectEnabled(const bool enable); + bool isOpacityEffectEnabled() const; +#endif + void setRotation(const qreal rotation) { m_rotation = rotation; } + qreal rotation() const { return m_rotation; } + + void setSmoothTransformationEnabled(const bool enable) { m_smoothTransformation = enable; } + bool isSmoothTransformationEnabled() const { return m_smoothTransformation; } + +private: + + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget */*widget = 0*/); + QSizeF sizeHint(Qt::SizeHint which, + const QSizeF &constraint = QSizeF()) const; + +private: + Q_DISABLE_COPY(IconItem) + void reload(); + + QString m_filename; + QPixmap m_pixmap; + qreal m_rotation; +#if (QT_VERSION >= 0x040600) + QGraphicsOpacityEffect *m_opacityEffect; +#endif + bool m_smoothTransformation; +}; + +#endif diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp new file mode 100644 index 0000000..3b62a38 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "itemrecyclinglist.h" +#include "listitemcontainer.h" +#include "abstractviewitem.h" +#include "recycledlistitem.h" +#include "theme.h" +#include "scrollbar.h" + +ItemRecyclingList::ItemRecyclingList(const int itemBuffer, QGraphicsWidget * parent) + : ItemRecyclingListView(parent), + m_listModel(new ListModel(this)) +{ + ListItemContainer *container = new ListItemContainer(itemBuffer, this, this); + container->setParentItem(this); + ItemRecyclingListView::setContainer(container); + ItemRecyclingListView::setModel(m_listModel, new RecycledListItem(this)); + setObjectName("ItemRecyclingList"); + connect(Theme::p(), SIGNAL(themeChanged()), this, SLOT(themeChange())); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +} + +/* virtual */ +ItemRecyclingList::~ItemRecyclingList() +{ +} + +/* virtual */ +void ItemRecyclingList::insertItem(int index, RecycledListItem *item) +{ + if (index<0) + index = 0; + if (index > m_listModel->rowCount()) + index = m_listModel->rowCount(); + if (m_listModel && item) + m_listModel->insert(index,item); + + updateListItemBackgrounds(index); +} + +/* virtual */ +void ItemRecyclingList::addItem(RecycledListItem *item) +{ + if (item) + m_listModel->appendRow(item); + + const int index = m_listModel->rowCount()-1; + updateListItemBackgrounds(index); +} + +/* virtual */ +void ItemRecyclingList::clear() +{ + m_listModel->clear(); +} + +/* virtual */ +AbstractViewItem *ItemRecyclingList::takeItem(const int row) +{ + if (row < 0 || row >= m_listModel->rowCount() || !m_listModel) + return 0; + return m_listModel->takeItem(row); +} + +/*virtual*/ +void ItemRecyclingList::setItemPrototype(AbstractViewItem* prototype) +{ + ItemRecyclingListView::setItemPrototype(prototype); +} + +void ItemRecyclingList::themeChange() +{ + const bool caching = listItemCaching(); + setListItemCaching(false); + + const QString iconName = Theme::p()->pixmapPath()+"contact_default_icon.svg"; + const int count = m_listModel->rowCount(); + + for (int i=0; iitem(i); + if (ritem) { + ListItem *item = ritem->item(); + + // Update default icons + const QString filename = item->icon(ListItem::LeftIcon)->fileName(); + if (filename.contains("contact_default_icon")) { + item->icon(ListItem::LeftIcon)->setFileName(iconName); + } + + // Update status icons + QString statusIcon = item->icon(ListItem::RightIcon)->fileName(); + const int index = statusIcon.indexOf("contact_status"); + if (index != -1) { + statusIcon.remove(0, index); + item->icon(ListItem::RightIcon)->setFileName(Theme::p()->pixmapPath()+statusIcon); + } + + // Update fonts + item->setFont(Theme::p()->font(Theme::ContactName), ListItem::FirstPos); + item->setFont(Theme::p()->font(Theme::ContactNumber), ListItem::SecondPos); + item->setFont(Theme::p()->font(Theme::ContactEmail), ListItem::ThirdPos); + + // Update list dividers + if (i%2) { + item->setBackgroundBrush(Theme::p()->listItemBackgroundBrushOdd()); + item->setBackgroundOpacity(Theme::p()->listItemBackgroundOpacityOdd()); + } + else { + item->setBackgroundBrush(Theme::p()->listItemBackgroundBrushEven()); + item->setBackgroundOpacity(Theme::p()->listItemBackgroundOpacityEven()); + } + + // Update borders + item->setBorderPen(Theme::p()->listItemBorderPen()); + item->setRounding(Theme::p()->listItemRounding()); + + // Update icons + item->icon(ListItem::LeftIcon)->setRotation(Theme::p()->iconRotation(ListItem::LeftIcon)); + item->icon(ListItem::RightIcon)->setRotation(Theme::p()->iconRotation(ListItem::RightIcon)); +#if (QT_VERSION >= 0x040600) + item->icon(ListItem::LeftIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::LeftIcon)); + item->icon(ListItem::RightIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::RightIcon)); +#endif + item->icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::LeftIcon)); + item->icon(ListItem::RightIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::RightIcon)); + } + } + updateViewContent(); + setListItemCaching(caching); +} + +void ItemRecyclingList::keyPressEvent(QKeyEvent *event) +{ + static QTime keyPressInterval = QTime::currentTime(); + static qreal step = 0.0; + static bool repeat = false; + int interval = keyPressInterval.elapsed(); + + ScrollBar* sb = verticalScrollBar(); + qreal currentValue = sb->sliderPosition(); + + if(interval < 250 ) { + if(!repeat) step = 0.0; + step = step + 2.0; + if(step > 100) step = 100; + repeat = true; + } + else { + step = 1.0; + if(m_listModel->item(0)) m_listModel->item(0)->size().height(); + step = m_listModel->item(0)->size().height(); + repeat = false; + } + + if(event->key() == Qt::Key_Up ) { //Up Arrow + sb->setSliderPosition(currentValue - step); + } + + if(event->key() == Qt::Key_Down ) { //Down Arrow + sb->setSliderPosition(currentValue + step); + } + keyPressInterval.start(); +} + +bool ItemRecyclingList::listItemCaching() const +{ +#if (QT_VERSION >= 0x040600) + ListItemContainer *container = + static_cast(m_container); + + return container->listItemCaching(); +#else + return false; +#endif +} + +void ItemRecyclingList::setListItemCaching(bool enabled) +{ +#if (QT_VERSION >= 0x040600) + ListItemContainer *container = + static_cast(m_container); + container->setListItemCaching(enabled); +#else + Q_UNUSED(enabled) +#endif +} + +void ItemRecyclingList::updateListItemBackgrounds(int index) +{ + const int itemCount = m_listModel->rowCount(); + + for (int i=index; iitem(i); + if (ritem) { + ListItem *item = ritem->item(); + if (i%2) { + item->setBackgroundBrush(Theme::p()->listItemBackgroundBrushOdd()); + item->setBackgroundOpacity(Theme::p()->listItemBackgroundOpacityOdd()); + } + else { + item->setBackgroundBrush(Theme::p()->listItemBackgroundBrushEven()); + item->setBackgroundOpacity(Theme::p()->listItemBackgroundOpacityEven()); + } + } + } +} + +void ItemRecyclingList::setTwoColumns(const bool enabled) +{ + if (twoColumns() == enabled) + return; + +#if (QT_VERSION >= 0x040600) + const bool caching = listItemCaching(); + setListItemCaching(false); +#endif + + m_container->setTwoColumns(enabled); + refreshContainerGeometry(); + +#if (QT_VERSION >= 0x040600) + setListItemCaching(caching); +#endif +} + +bool ItemRecyclingList::twoColumns() +{ + return m_container->twoColumns(); +} + diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.h new file mode 100644 index 0000000..1be1562 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ITEMRECYCLINGLIST_H +#define ITEMRECYCLINGLIST_H + +#include "listitem.h" +#include "abstractitemview.h" +#include "listmodel.h" +#include "itemrecyclinglistview.h" +#include "recycledlistitem.h" + +class QGraphicsWidget; + +class ItemRecyclingList : public ItemRecyclingListView +{ + Q_OBJECT + +public: + ItemRecyclingList(const int itemBuffer = 4, QGraphicsWidget * parent = 0); + virtual ~ItemRecyclingList(); + + virtual void insertItem(int index, RecycledListItem *item); + virtual void addItem(RecycledListItem *item); + virtual void clear(); + virtual AbstractViewItem *takeItem(const int row); + virtual void setItemPrototype(AbstractViewItem* prototype); + virtual void keyPressEvent(QKeyEvent *event); + virtual bool listItemCaching() const; + virtual void setListItemCaching(bool enabled); + + void setTwoColumns(const bool enabled); + bool twoColumns(); + +public slots: + void themeChange(); + +private: + void updateListItemBackgrounds(int index); + +private: + Q_DISABLE_COPY(ItemRecyclingList) + + ListModel *m_listModel; +}; + +#endif // ITEMRECYCLINGLIST_H diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.pri b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.pri new file mode 100644 index 0000000..55b551e --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.pri @@ -0,0 +1,19 @@ +HEADERS += $$ROOTDIR/tests/itemrecyclinglist/itemrecyclinglist.h \ + $$ROOTDIR/tests/itemrecyclinglist/itemrecyclinglistview.h \ + $$ROOTDIR/tests/itemrecyclinglist/abstractitemview.h \ + $$ROOTDIR/tests/itemrecyclinglist/abstractviewitem.h \ + $$ROOTDIR/tests/itemrecyclinglist/recycledlistitem.h \ + $$ROOTDIR/tests/itemrecyclinglist/listitemcontainer.h \ + $$ROOTDIR/tests/itemrecyclinglist/abstractitemcontainer.h \ + $$ROOTDIR/tests/itemrecyclinglist/listmodel.h + +SOURCES += $$ROOTDIR/tests/itemrecyclinglist/itemrecyclinglist.cpp \ + $$ROOTDIR/tests/itemrecyclinglist/itemrecyclinglistview.cpp \ + $$ROOTDIR/tests/itemrecyclinglist/abstractitemview.cpp \ + $$ROOTDIR/tests/itemrecyclinglist/abstractviewitem.cpp \ + $$ROOTDIR/tests/itemrecyclinglist/recycledlistitem.cpp \ + $$ROOTDIR/tests/itemrecyclinglist/listitemcontainer.cpp \ + $$ROOTDIR/tests/itemrecyclinglist/abstractitemcontainer.cpp \ + $$ROOTDIR/tests/itemrecyclinglist/listmodel.cpp + +INCLUDEPATH += $$ROOTDIR/tests/itemrecyclinglist diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.cpp new file mode 100644 index 0000000..d069a33 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "itemrecyclinglistview.h" + +ItemRecyclingListView::ItemRecyclingListView(QGraphicsWidget * parent) + : AbstractItemView(parent), m_rootIndex() +{ +} + +/*virtual*/ +ItemRecyclingListView::~ItemRecyclingListView() +{ +} +void ItemRecyclingListView::setCurrentRow(const int row) +{ + setCurrentIndex(model()->index(row,0)); +} + +int ItemRecyclingListView::rows() const +{ + if (m_model) + return m_model->rowCount(); + return 0; +} + +/*virtual*/ +void ItemRecyclingListView::rowsInserted(const QModelIndex &parent, int start, int end) +{ + if (parent == m_rootIndex) { + AbstractItemView::rowsInserted(parent, start, end); + } +} + +/*virtual*/ +void ItemRecyclingListView::rowsRemoved(const QModelIndex &parent, int start, int end) +{ + if (parent == m_rootIndex) { + AbstractItemView::rowsRemoved(parent, start, end); + } +} diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.h new file mode 100644 index 0000000..f52001f --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ITEMRECYCLINGLISTVIEW_H +#define ITEMRECYCLINGLISTVIEW_H + +#include "abstractitemview.h" + +class ItemRecyclingListView : public AbstractItemView +{ +public: + ItemRecyclingListView(QGraphicsWidget * parent = 0); + virtual ~ItemRecyclingListView(); + void setCurrentRow(const int row); + int rows() const; +#if (QT_VERSION >= 0x040600) + virtual bool listItemCaching() const = 0; + virtual void setListItemCaching(bool enabled) = 0; +#endif + +protected: + void rowsInserted(const QModelIndex &parent, int start, int end); + void rowsRemoved(const QModelIndex &parent,int start,int end); + +private: + QModelIndex m_rootIndex; +}; + +#endif // ITEMRECYCLINGLISTVIEW_H diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/label.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/label.cpp new file mode 100644 index 0000000..38ef86f --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/label.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "label.h" + +Label::Label(const QString& text, QGraphicsItem *parent) + : GvbWidget(parent) +{ + m_textItem = new QGraphicsSimpleTextItem(this); + setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + setContentsMargins(0, 0, 0, 0); + setText(text); +#if QT_VERSION >= 0x040600 + // This flag was introduced in Qt 4.6. + setFlag(QGraphicsItem::ItemHasNoContents, true); +#endif +} + +Label::~Label() +{ +} + +void Label::setText(const QString& text) +{ + m_textItem->setText(text); + prepareGeometryChange(); +} + +QString Label::text() const +{ + return m_textItem->text(); +} + +void Label::setFont(const QFont font) +{ + m_textItem->setFont(font); +} + +void Label::resizeEvent(QGraphicsSceneResizeEvent *event) +{ + GvbWidget::resizeEvent(event); +} + +QSizeF Label::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + switch (which) + { + case Qt::MinimumSize: + // fall thru + case Qt::PreferredSize: + { + QFontMetricsF fm(m_textItem->font()); + return QSizeF(fm.width(m_textItem->text()), fm.height()); + } + default: + return GvbWidget::sizeHint(which, constraint); + } +} diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/label.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/label.h new file mode 100644 index 0000000..dee35b9 --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/label.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTITEM_H +#define TEXTITEM_H + +#include "gvbwidget.h" + +class QPainter; +class QStyleOptionGraphicsItem; +class QGraphicsTextItem; + +class Label : public GvbWidget +{ + Q_OBJECT + +public: + + Label(const QString& text, QGraphicsItem *parent = 0); + ~Label(); + +public: + + void setText(const QString& text); + QString text() const; + void setFont(const QFont font); + +private: + void resizeEvent(QGraphicsSceneResizeEvent *event); + QSizeF sizeHint(Qt::SizeHint which, + const QSizeF &constraint = QSizeF()) const; + +private: + Q_DISABLE_COPY(Label) + QGraphicsSimpleTextItem *m_textItem; +}; + +#endif diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.cpp new file mode 100644 index 0000000..937ad9d --- /dev/null +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.cpp @@ -0,0 +1,314 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "listitem.h" +#include "theme.h" + +struct ItemData +{ + QHash texts; + QHash fonts; + QHash icons; + QHash iconRotations; + QHash iconSmoothTransformations; + QHash iconOpacityEffets; + QPen borderPen; + QBrush backgroundBrush; + qreal backgroundOpacity; + QSize rounding; +}; +Q_DECLARE_METATYPE(ItemData); + +ListItem::ListItem(QGraphicsWidget *parent) + : GvbWidget(parent), + m_txtlayout(new QGraphicsGridLayout()), + m_layout(new QGraphicsLinearLayout(Qt::Horizontal)), + m_liconlayout(new QGraphicsLinearLayout(Qt::Horizontal)), + m_riconlayout(new QGraphicsLinearLayout(Qt::Horizontal)) + ,m_fonts() + ,m_borderPen(Qt::NoPen) + ,m_backgroundBrush(QBrush()) + ,m_backgroundOpacity(1.0) + ,m_rounding(0.0, 0.0) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + setContentsMargins(0,4,4,0); + m_layout->setContentsMargins(0,0,0,0); + + m_txtlayout->setContentsMargins(0,8,0,8); + m_liconlayout->setContentsMargins(8,8,8,8); + m_riconlayout->setContentsMargins(0,8,4,8); + + m_layout->insertItem(0, m_liconlayout); + m_layout->insertItem(1, m_txtlayout); + m_layout->insertItem(2, m_riconlayout); + + m_layout->setStretchFactor(m_liconlayout, 1); + m_layout->setStretchFactor(m_txtlayout, 5); + m_layout->setStretchFactor(m_riconlayout, 1); + + setFlag(QGraphicsItem::ItemClipsToShape); + setLayout(m_layout); +} + +ListItem::~ListItem() +{ + if ( !m_liconlayout->parentLayoutItem() ) + delete m_liconlayout; + + if ( !m_riconlayout->parentLayoutItem() ) + delete m_riconlayout; +} + +void ListItem::setIcon( IconItem *iconItem, const IconItemPos iconPos ) +{ + if (iconPos == LeftIcon) { + if (m_liconlayout->count() > 0 && m_liconlayout->itemAt(0)) { + delete m_liconlayout->itemAt(0); + m_liconlayout->addItem( iconItem ); + } + else { + m_liconlayout->addItem( iconItem ); + } + m_liconlayout->itemAt(0)->setMaximumSize(58,58); + } + else if (iconPos == RightIcon) { + if (m_riconlayout->count() > 0 && m_riconlayout->itemAt(0)) { + delete m_riconlayout->itemAt(0); + m_riconlayout->addItem( iconItem ); + } + else { + m_riconlayout->addItem( iconItem ); + } + m_riconlayout->itemAt(0)->setMaximumSize(22,22); + } + m_layout->invalidate(); +} + +IconItem* ListItem::icon( const IconItemPos iconPos ) const +{ + QGraphicsLayoutItem* item = 0; + + if (iconPos == LeftIcon && m_liconlayout->count() > 0) { + item = m_liconlayout->itemAt(0); + } + else if (iconPos == RightIcon && m_riconlayout->count() > 0) { + item = m_riconlayout->itemAt(0); + } + + if (item) { + IconItem* titem = static_cast(item); + return titem; + } + return 0; +} + +QVariant ListItem::data(int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + ItemData data; + + if (text(ListItem::FirstPos).size() > 0) { + data.texts[ListItem::FirstPos] = text(ListItem::FirstPos); + data.fonts[ListItem::FirstPos] = m_fonts[ListItem::FirstPos]; + } + if (text(ListItem::SecondPos).size() > 0) { + data.texts[ListItem::SecondPos] = text(ListItem::SecondPos); + data.fonts[ListItem::SecondPos] = m_fonts[ListItem::SecondPos]; + } + if (text(ListItem::ThirdPos).size() > 0) { + data.texts[ListItem::ThirdPos] = text(ListItem::ThirdPos); + data.fonts[ListItem::ThirdPos] = m_fonts[ListItem::ThirdPos]; + } + if (text(ListItem::LastPos).size() > 0) { + data.texts[ListItem::LastPos] = text(ListItem::LastPos); + data.fonts[ListItem::LastPos] = m_fonts[ListItem::LastPos]; + } + + if (icon(ListItem::LeftIcon)) { + data.icons[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->fileName(); + data.iconRotations[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->rotation(); + data.iconSmoothTransformations[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->isSmoothTransformationEnabled(); +#if (QT_VERSION >= 0x040600) + data.iconOpacityEffets[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->isOpacityEffectEnabled(); +#endif + } + + if (icon(ListItem::RightIcon)) { + data.icons[ListItem::RightIcon] = icon(ListItem::RightIcon)->fileName(); + data.iconRotations[ListItem::RightIcon] = icon(ListItem::RightIcon)->rotation(); + data.iconSmoothTransformations[ListItem::RightIcon] = icon(ListItem::RightIcon)->isSmoothTransformationEnabled(); +#if (QT_VERSION >= 0x040600) + data.iconOpacityEffets[ListItem::RightIcon] = icon(ListItem::RightIcon)->isOpacityEffectEnabled(); +#endif + } + + data.borderPen = m_borderPen; + data.backgroundBrush = m_backgroundBrush; + data.backgroundOpacity = m_backgroundOpacity; + data.rounding = m_rounding; + + QVariant var; + var.setValue(data); + return var; +} + +void ListItem::setData(const QVariant &value, int role) +{ + if (role != Qt::DisplayRole) + return; + + ItemData data = value.value(); + QList textkeys = data.texts.keys(); + + for( int i = 0; i iconkeys = data.icons.keys(); + for( int i = 0; isetFileName(data.icons[iconkeys.at(i)]); + else { + IconItem *iconItem = new IconItem(data.icons[iconkeys.at(i)], this); + setIcon(iconItem, iconkeys.at(i)); + } + } + + if (icon(ListItem::LeftIcon)) { + icon(ListItem::LeftIcon)->setRotation(data.iconRotations[ListItem::LeftIcon]); + icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(data.iconSmoothTransformations[ListItem::LeftIcon]); +#if (QT_VERSION >= 0x040600) + icon(ListItem::LeftIcon)->setOpacityEffectEnabled(data.iconOpacityEffets[ListItem::LeftIcon]); +#endif + } + + if (icon(ListItem::RightIcon)) { + icon(ListItem::RightIcon)->setRotation(data.iconRotations[ListItem::RightIcon]); + icon(ListItem::RightIcon)->setSmoothTransformationEnabled(data.iconSmoothTransformations[ListItem::RightIcon]); +#if (QT_VERSION >= 0x040600) + icon(ListItem::RightIcon)->setOpacityEffectEnabled(data.iconOpacityEffets[ListItem::RightIcon]); +#endif + } + + m_borderPen = data.borderPen; + m_backgroundBrush = data.backgroundBrush; + m_backgroundOpacity = data.backgroundOpacity; + m_rounding = data.rounding; +} + +void ListItem::setText(const QString str, const TextPos position) +{ + QGraphicsLayoutItem * item = 0; + + if (m_txtlayout->rowCount() > position && position >= 0) + item = m_txtlayout->itemAt(position, 0); + + if (!item) { + Label *label = new Label(str,this); + m_txtlayout->addItem(label, position, 0); + if (m_fonts.contains(position)) + label->setFont(m_fonts[position]); + } + else { + Label *titem = static_cast