From 3c4ea1b3c662d17b4b82a55a4b10e50226dbb14f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Thu, 22 Mar 2018 10:47:02 +0100 Subject: Benchmark: move widgets benchmarks still in gui subdirectory to widgets Move all widget-dependent benchmarks which were still in gui subdirectory to widgets Task-number: QTBUG-23129 Change-Id: I1359f1ea4036cacdfdbe08ff9ecdf1e2c75a005b Reviewed-by: Richard Moe Gustavsen --- .../GraphicsViewBenchmark.pro | 70 + .../GraphicsViewBenchmark.qrc | 85 + .../functional/GraphicsViewBenchmark/main.cpp | 780 ++++ .../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 | 382 ++ .../widgets/abstractitemcontainer.h | 96 + .../widgets/abstractitemview.cpp | 425 ++ .../widgets/abstractitemview.h | 103 + .../widgets/abstractscrollarea.cpp | 236 ++ .../widgets/abstractscrollarea.h | 88 + .../widgets/abstractviewitem.cpp | 102 + .../widgets/abstractviewitem.h | 81 + .../widgets/backgrounditem.cpp | 71 + .../GraphicsViewBenchmark/widgets/backgrounditem.h | 59 + .../GraphicsViewBenchmark/widgets/button.cpp | 196 + .../GraphicsViewBenchmark/widgets/button.h | 89 + .../GraphicsViewBenchmark/widgets/commandline.cpp | 183 + .../GraphicsViewBenchmark/widgets/commandline.h | 39 + .../GraphicsViewBenchmark/widgets/dummydatagen.cpp | 127 + .../GraphicsViewBenchmark/widgets/dummydatagen.h | 59 + .../GraphicsViewBenchmark/widgets/gvbwidget.cpp | 46 + .../GraphicsViewBenchmark/widgets/gvbwidget.h | 45 + .../GraphicsViewBenchmark/widgets/iconitem.cpp | 149 + .../GraphicsViewBenchmark/widgets/iconitem.h | 78 + .../widgets/itemrecyclinglist.cpp | 248 ++ .../widgets/itemrecyclinglist.h | 72 + .../widgets/itemrecyclinglist.pri | 19 + .../widgets/itemrecyclinglistview.cpp | 66 + .../widgets/itemrecyclinglistview.h | 52 + .../GraphicsViewBenchmark/widgets/label.cpp | 81 + .../GraphicsViewBenchmark/widgets/label.h | 63 + .../GraphicsViewBenchmark/widgets/listitem.cpp | 287 ++ .../GraphicsViewBenchmark/widgets/listitem.h | 96 + .../widgets/listitemcache.cpp | 79 + .../GraphicsViewBenchmark/widgets/listitemcache.h | 56 + .../widgets/listitemcontainer.cpp | 182 + .../widgets/listitemcontainer.h | 75 + .../GraphicsViewBenchmark/widgets/listmodel.cpp | 133 + .../GraphicsViewBenchmark/widgets/listmodel.h | 69 + .../GraphicsViewBenchmark/widgets/listwidget.cpp | 117 + .../GraphicsViewBenchmark/widgets/listwidget.h | 72 + .../GraphicsViewBenchmark/widgets/mainview.cpp | 331 ++ .../GraphicsViewBenchmark/widgets/mainview.h | 110 + .../GraphicsViewBenchmark/widgets/menu.cpp | 189 + .../GraphicsViewBenchmark/widgets/menu.h | 71 + .../widgets/recycledlistitem.cpp | 134 + .../widgets/recycledlistitem.h | 70 + .../widgets/resourcemoninterface.h | 84 + .../GraphicsViewBenchmark/widgets/scrollbar.cpp | 286 ++ .../GraphicsViewBenchmark/widgets/scrollbar.h | 84 + .../GraphicsViewBenchmark/widgets/scroller.cpp | 292 ++ .../GraphicsViewBenchmark/widgets/scroller.h | 66 + .../GraphicsViewBenchmark/widgets/scroller_p.h | 90 + .../GraphicsViewBenchmark/widgets/settings.cpp | 46 + .../GraphicsViewBenchmark/widgets/settings.h | 103 + .../GraphicsViewBenchmark/widgets/simplelist.cpp | 143 + .../GraphicsViewBenchmark/widgets/simplelist.h | 67 + .../widgets/simplelistview.cpp | 463 +++ .../GraphicsViewBenchmark/widgets/simplelistview.h | 77 + .../GraphicsViewBenchmark/widgets/theme.cpp | 223 ++ .../GraphicsViewBenchmark/widgets/theme.h | 118 + .../GraphicsViewBenchmark/widgets/themeevent.cpp | 40 + .../GraphicsViewBenchmark/widgets/themeevent.h | 51 + .../GraphicsViewBenchmark/widgets/topbar.cpp | 346 ++ .../GraphicsViewBenchmark/widgets/topbar.h | 114 + .../GraphicsViewBenchmark/widgets/webview.cpp | 289 ++ .../GraphicsViewBenchmark/widgets/webview.h | 68 + .../GraphicsViewBenchmark/widgets/webview_p.h | 86 + .../widgets/graphicsview/functional/functional.pro | 4 + .../widgets/graphicsview/graphicsview.pro | 10 + .../qgraphicsanchorlayout.pro | 7 + .../tst_qgraphicsanchorlayout.cpp | 420 ++ .../graphicsview/qgraphicsitem/qgraphicsitem.pro | 6 + .../qgraphicsitem/tst_qgraphicsitem.cpp | 234 ++ .../qgraphicslayout/qgraphicslayout.pro | 5 + .../qgraphicslayout/tst_qgraphicslayout.cpp | 140 + .../qgraphicslinearlayout.pro | 5 + .../tst_qgraphicslinearlayout.cpp | 120 + .../graphicsview/qgraphicsscene/qgraphicsscene.pro | 7 + .../qgraphicsscene/tst_qgraphicsscene.cpp | 243 ++ .../qgraphicsview/benchapps/chipTest/chip.cpp | 163 + .../qgraphicsview/benchapps/chipTest/chip.debug | Bin 0 -> 863805 bytes .../qgraphicsview/benchapps/chipTest/chip.h | 55 + .../qgraphicsview/benchapps/chipTest/chip.pro | 19 + .../qgraphicsview/benchapps/chipTest/fileprint.png | Bin 0 -> 1456 bytes .../qgraphicsview/benchapps/chipTest/images.qrc | 10 + .../qgraphicsview/benchapps/chipTest/main.cpp | 44 + .../benchapps/chipTest/mainwindow.cpp | 74 + .../qgraphicsview/benchapps/chipTest/mainwindow.h | 53 + .../qgraphicsview/benchapps/chipTest/qt4logo.png | Bin 0 -> 48333 bytes .../benchapps/chipTest/rotateleft.png | Bin 0 -> 1754 bytes .../benchapps/chipTest/rotateright.png | Bin 0 -> 1732 bytes .../qgraphicsview/benchapps/chipTest/view.cpp | 251 ++ .../qgraphicsview/benchapps/chipTest/view.h | 73 + .../qgraphicsview/benchapps/chipTest/zoomin.png | Bin 0 -> 1622 bytes .../qgraphicsview/benchapps/chipTest/zoomout.png | Bin 0 -> 1601 bytes .../qgraphicsview/benchapps/moveItems/main.cpp | 99 + .../benchapps/moveItems/moveItems.pro | 1 + .../qgraphicsview/benchapps/scrolltest/main.cpp | 139 + .../benchapps/scrolltest/scrolltest.pro | 1 + .../graphicsview/qgraphicsview/chiptester/chip.cpp | 169 + .../graphicsview/qgraphicsview/chiptester/chip.h | 55 + .../qgraphicsview/chiptester/chiptester.cpp | 132 + .../qgraphicsview/chiptester/chiptester.h | 74 + .../qgraphicsview/chiptester/chiptester.pri | 13 + .../qgraphicsview/chiptester/images.qrc | 5 + .../qgraphicsview/chiptester/qt4logo.png | Bin 0 -> 48333 bytes .../graphicsview/qgraphicsview/images/designer.png | Bin 0 -> 4205 bytes .../qgraphicsview/images/wine-big.jpeg | Bin 0 -> 12249 bytes .../graphicsview/qgraphicsview/images/wine.jpeg | Bin 0 -> 2265 bytes .../graphicsview/qgraphicsview/qgraphicsview.pro | 9 + .../graphicsview/qgraphicsview/qgraphicsview.qrc | 9 + .../widgets/graphicsview/qgraphicsview/random.data | Bin 0 -> 800 bytes .../qgraphicsview/tst_qgraphicsview.cpp | 901 +++++ .../qgraphicswidget/qgraphicswidget.pro | 6 + .../qgraphicswidget/tst_qgraphicswidget.cpp | 83 + tests/benchmarks/widgets/itemviews/itemviews.pro | 4 + .../widgets/itemviews/qheaderview/qheaderview.pro | 7 + .../itemviews/qheaderview/qheaderviewbench.cpp | 251 ++ .../widgets/itemviews/qtableview/qtableview.pro | 7 + .../itemviews/qtableview/tst_qtableview.cpp | 373 ++ tests/benchmarks/widgets/kernel/kernel.pro | 4 + .../widgets/kernel/qapplication/main.cpp | 58 + .../widgets/kernel/qapplication/qapplication.pro | 8 + .../benchmarks/widgets/kernel/qwidget/qwidget.pro | 4 + .../widgets/kernel/qwidget/tst_qwidget.cpp | 243 ++ .../widgets/styles/qstylesheetstyle/main.cpp | 189 + .../styles/qstylesheetstyle/qstylesheetstyle.pro | 7 + tests/benchmarks/widgets/styles/styles.pro | 3 + tests/benchmarks/widgets/widgets.pro | 10 + 197 files changed, 21870 insertions(+) create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.pro create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.qrc create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/main.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_001_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_002_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_003_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_004_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_005_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_006_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_007_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_008_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_009_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_010_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_001_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_002_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_003_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_004_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_005_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_001_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_002_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_003_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_004_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_005_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_006_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_007_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_008_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_009_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_010_58x58.png create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_360x640px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_horisontal_640x360px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_default_icon_52x52px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_divider_360x76px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_idle_33x33px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_offline_33x33px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_online_33x33px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scroll_16x80px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scrollbar_7x14px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_left_14x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_middle_14x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_right_14x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_356x96px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_horisontal_636x96px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_default_icon_68x68px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_idle_38x38px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_offline_38x38px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_online_38x38px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/areacodes.txt create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesF.txt create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesM.txt create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/lastnames.txt create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_360x640px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_horisontal_640x360px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_53x53px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_divider_360x76px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_idle_27x47.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_offline_27x47.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_online_27x47.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scroll_5x80px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scrollbar_5x14px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_left_14x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_middle_10x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_right_14x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_356x96px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_horisontal_636x96px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_default_icon_84x68px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_idle_24x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_offline_24x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_online_24x24px.svg create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/button.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/button.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.pri create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/label.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/label.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitemcache.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitemcache.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitemcontainer.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitemcontainer.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listmodel.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listmodel.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listwidget.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listwidget.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/menu.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/menu.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/recycledlistitem.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/recycledlistitem.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/resourcemoninterface.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scrollbar.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scrollbar.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/settings.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelistview.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelistview.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/theme.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/theme.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/topbar.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/topbar.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/webview.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/webview.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/webview_p.h create mode 100644 tests/benchmarks/widgets/graphicsview/functional/functional.pro create mode 100644 tests/benchmarks/widgets/graphicsview/graphicsview.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicslayout/qgraphicslayout.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicslinearlayout/qgraphicslinearlayout.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.debug create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.h create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/fileprint.png create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/images.qrc create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/main.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/mainwindow.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/mainwindow.h create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/qt4logo.png create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/rotateleft.png create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/rotateright.png create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.h create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/zoomin.png create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/zoomout.png create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/moveItems/moveItems.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/scrolltest/scrolltest.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.h create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.pri create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/images.qrc create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/qt4logo.png create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/images/designer.png create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/images/wine-big.jpeg create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/images/wine.jpeg create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/qgraphicsview.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/qgraphicsview.qrc create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/random.data create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicswidget/qgraphicswidget.pro create mode 100644 tests/benchmarks/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp create mode 100644 tests/benchmarks/widgets/itemviews/itemviews.pro create mode 100644 tests/benchmarks/widgets/itemviews/qheaderview/qheaderview.pro create mode 100644 tests/benchmarks/widgets/itemviews/qheaderview/qheaderviewbench.cpp create mode 100644 tests/benchmarks/widgets/itemviews/qtableview/qtableview.pro create mode 100644 tests/benchmarks/widgets/itemviews/qtableview/tst_qtableview.cpp create mode 100644 tests/benchmarks/widgets/kernel/kernel.pro create mode 100644 tests/benchmarks/widgets/kernel/qapplication/main.cpp create mode 100644 tests/benchmarks/widgets/kernel/qapplication/qapplication.pro create mode 100644 tests/benchmarks/widgets/kernel/qwidget/qwidget.pro create mode 100644 tests/benchmarks/widgets/kernel/qwidget/tst_qwidget.cpp create mode 100644 tests/benchmarks/widgets/styles/qstylesheetstyle/main.cpp create mode 100644 tests/benchmarks/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro create mode 100644 tests/benchmarks/widgets/styles/styles.pro (limited to 'tests/benchmarks/widgets') diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.pro b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.pro new file mode 100644 index 0000000000..ded6a06795 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.pro @@ -0,0 +1,70 @@ +TEMPLATE = app + +QT += svg testlib +qtHaveModule(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/widgets/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.qrc b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/GraphicsViewBenchmark.qrc new file mode 100644 index 0000000000..18ae04dd69 --- /dev/null +++ b/tests/benchmarks/widgets/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/widgets/graphicsview/functional/GraphicsViewBenchmark/main.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/main.cpp new file mode 100644 index 0000000000..87ab80d74f --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/main.cpp @@ -0,0 +1,780 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include + +#include "mainview.h" +#include "dummydatagen.h" +#include "simplelist.h" +#include "itemrecyclinglist.h" +#include "simplelist.h" +#include "theme.h" +#include "commandline.h" + +class tst_GraphicsViewBenchmark : public QObject +{ + Q_OBJECT +public: + enum ListType { + Simple, + Recycling, + None + }; + + enum ScrollStep { + Slow = 2, + Normal = 8, + Fast = 64 + }; + + tst_GraphicsViewBenchmark(Settings *settings) + : mSettings(settings), 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: + Settings *mSettings; + 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() +{ + mMainView = new MainView(mSettings->options() & Settings::UseOpenGL, + mSettings->options() & Settings::OutputFps); + + if (mSettings->size().width() > 0 && mSettings->size().height() > 0) { + mMainView->resize(mSettings->size().width(), mSettings->size().height()); + mMainView->show(); + } else if (QApplication::desktop()->width() < 360 || QApplication::desktop()->height() < 640) { + mMainView->showFullScreen(); + } else { + mMainView->resize(360, 640); + mMainView->show(); + } + + mDataGenerator.Reset(); + SimpleList *list = new SimpleList; + list->setListItemCaching(false); + mMainView->setTestWidget(list); + fillList(mDataGenerator, 5, list); + mMainView->takeTestWidget(); + delete list; + + currentListSize = -1; + currentListType = None; + + QVERIFY(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); + } +} + +int main(int argc, char *argv[]) +{ + Settings settings; + if (!readSettingsFromCommandLine(argc, argv, settings)) + return 1; + + // Eat command line arguments. + int aargc = 0; + for (int i = 0; i < argc; ++i) { + if (argv[i]) + ++aargc; + } + char **aargv = new char*[aargc]; + aargc = 0; + for (int i = 0; i < argc; ++i) { + if (argv[i]) + aargv[aargc++] = argv[i]; + } + + QApplication app(aargc, aargv); + + int returnValue = 0; + if (settings.options() & Settings::ManualTest) { + MainView view(settings.options() & Settings::UseOpenGL, settings.options() & Settings::OutputFps); + + DummyDataGenerator dataGenerator; + dataGenerator.Reset(); + + SimpleList *list = new SimpleList; + if (settings.options() & Settings::UseListItemCache) + list->setListItemCaching(true); + else + list->setListItemCaching(false); + + if (settings.listItemCount()) + fillList(dataGenerator, settings.listItemCount(), list); + else + fillList(dataGenerator, 500, list); + + view.setTestWidget(list); + + if ((settings.angle() % 360) != 0) + view.rotateContent(settings.angle()); + + if (settings.size().width() > 0 && settings.size().height() > 0) { + view.resize(settings.size().width(), settings.size().height()); + view.show(); + } else if (QApplication::desktop()->width() < 360 || QApplication::desktop()->height() < 640) { + view.showFullScreen(); + } else { + view.resize(360, 640); + view.show(); + } + returnValue = app.exec(); + } else { + QTEST_DISABLE_KEYPAD_NAVIGATION + tst_GraphicsViewBenchmark tc(&settings); + returnValue = QTest::qExec(&tc, aargc, aargv); + } + + delete [] aargv; + return returnValue; +} + +#include "main.moc" diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_001_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_001_58x58.png new file mode 100644 index 0000000000..525b5559a0 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_001_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_002_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_002_58x58.png new file mode 100644 index 0000000000..3d932985a6 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_002_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_003_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_003_58x58.png new file mode 100644 index 0000000000..556cfcba6a Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_003_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_004_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_004_58x58.png new file mode 100644 index 0000000000..94acf9e669 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_004_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_005_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_005_58x58.png new file mode 100644 index 0000000000..ed0c7c42f0 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_005_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_006_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_006_58x58.png new file mode 100644 index 0000000000..d4b4dc3a8e Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_006_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_007_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_007_58x58.png new file mode 100644 index 0000000000..0e45d18e4d Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_007_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_008_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_008_58x58.png new file mode 100644 index 0000000000..0c25540ac9 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_008_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_009_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_009_58x58.png new file mode 100644 index 0000000000..ce435ea537 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_009_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_010_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_010_58x58.png new file mode 100644 index 0000000000..021db25882 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_man_010_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_001_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_001_58x58.png new file mode 100644 index 0000000000..0051da326f Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_001_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_002_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_002_58x58.png new file mode 100644 index 0000000000..e8a946a8ba Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_002_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_003_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_003_58x58.png new file mode 100644 index 0000000000..b2bb851f69 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_003_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_004_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_004_58x58.png new file mode 100644 index 0000000000..871c075d05 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_004_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_005_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_005_58x58.png new file mode 100644 index 0000000000..d4c18b8bb0 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_picture_005_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_001_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_001_58x58.png new file mode 100644 index 0000000000..10a5947234 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_001_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_002_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_002_58x58.png new file mode 100644 index 0000000000..65b4e03c5b Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_002_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_003_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_003_58x58.png new file mode 100644 index 0000000000..935ec07171 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_003_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_004_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_004_58x58.png new file mode 100644 index 0000000000..fbc1a937fd Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_004_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_005_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_005_58x58.png new file mode 100644 index 0000000000..af96d3e149 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_005_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_006_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_006_58x58.png new file mode 100644 index 0000000000..fb4192d35f Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_006_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_007_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_007_58x58.png new file mode 100644 index 0000000000..f5d6dea0b0 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_007_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_008_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_008_58x58.png new file mode 100644 index 0000000000..d08b8dc364 Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_008_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_009_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_009_58x58.png new file mode 100644 index 0000000000..768b97de6e Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_009_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_010_58x58.png b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_010_58x58.png new file mode 100644 index 0000000000..d1fe28e61e Binary files /dev/null and b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/avatars/avatar_woman_010_58x58.png differ diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_360x640px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_360x640px.svg new file mode 100644 index 0000000000..1552bafa17 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_360x640px.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_horisontal_640x360px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_horisontal_640x360px.svg new file mode 100644 index 0000000000..5589110950 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_background_horisontal_640x360px.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_default_icon_52x52px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_default_icon_52x52px.svg new file mode 100644 index 0000000000..665675b1e8 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_default_icon_52x52px.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_divider_360x76px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_divider_360x76px.svg new file mode 100644 index 0000000000..db9fc7af33 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_divider_360x76px.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg new file mode 100644 index 0000000000..dae2bd4842 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_list_highlighter_360x76px.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_idle_33x33px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_idle_33x33px.svg new file mode 100644 index 0000000000..fe12e782a6 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_idle_33x33px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_offline_33x33px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_offline_33x33px.svg new file mode 100644 index 0000000000..0c973f1bc9 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_offline_33x33px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_online_33x33px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_online_33x33px.svg new file mode 100644 index 0000000000..fcb434afda --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_contact_status_online_33x33px.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scroll_16x80px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scroll_16x80px.svg new file mode 100644 index 0000000000..897be81dc5 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scroll_16x80px.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scrollbar_7x14px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scrollbar_7x14px.svg new file mode 100644 index 0000000000..3baec2f4b6 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_scrollbar_7x14px.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_left_14x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_left_14x24px.svg new file mode 100644 index 0000000000..dd6fb70a8d --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_left_14x24px.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_middle_14x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_middle_14x24px.svg new file mode 100644 index 0000000000..cabf9285a7 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_middle_14x24px.svg @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_right_14x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_right_14x24px.svg new file mode 100644 index 0000000000..f3a795b88d --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_status_field_right_14x24px.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_356x96px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_356x96px.svg new file mode 100644 index 0000000000..a0efd347fb --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_356x96px.svg @@ -0,0 +1,2007 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_horisontal_636x96px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_horisontal_636x96px.svg new file mode 100644 index 0000000000..0a3efd8111 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_topbar_horisontal_636x96px.svg @@ -0,0 +1,4060 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_default_icon_68x68px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_default_icon_68x68px.svg new file mode 100644 index 0000000000..1ffeedde1b --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_default_icon_68x68px.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_idle_38x38px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_idle_38x38px.svg new file mode 100644 index 0000000000..71f49aa719 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_idle_38x38px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_offline_38x38px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_offline_38x38px.svg new file mode 100644 index 0000000000..84c2514adc --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_offline_38x38px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_online_38x38px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_online_38x38px.svg new file mode 100644 index 0000000000..76daf31809 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/blue_SVG/blue_user_status_online_38x38px.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/areacodes.txt b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/areacodes.txt new file mode 100644 index 0000000000..dc7e7d81b6 --- /dev/null +++ b/tests/benchmarks/widgets/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/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesF.txt b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesF.txt new file mode 100644 index 0000000000..4bf14924a7 --- /dev/null +++ b/tests/benchmarks/widgets/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/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesM.txt b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/firstnamesM.txt new file mode 100644 index 0000000000..189d8d015f --- /dev/null +++ b/tests/benchmarks/widgets/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/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/lastnames.txt b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/contacts/lastnames.txt new file mode 100644 index 0000000000..35b3f9f9c2 --- /dev/null +++ b/tests/benchmarks/widgets/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 +Díaz +Edwards +Evans +Fisher +Flores +Foster +García +Gómez +González +Gray +Green +Gutiérrez +Hall +Harris +Heikkinen +Helenius +Helve +Hernández +Hill +Hiltunen +Hirvonen +Holm +Honkanen +Howard +Hughes +Huhtala +Huttunen +Hyppönen +Jackson +James +Jenkins +Johnson +Jones +Kauppinen +Kelly +Kemppainen +King +Klemetti +Kokkonen +Kolehmainen +Korhonen +Kurikka +Kuura +Kyrö +Kärkkäinen +Lee +Lewis +Long +López +Martikainen +Martin +Martínez +Mattila +Mikkola +Mikkonen +Miller +Mitchell +Moore +Morales +Morgan +Morris +Muje +Murphy +Mustonen +Myers +Myllärinen +Mäenpää +Mäkelä +Mäkinen +Nelson +Nguyen +Ortiz +Parker +Pérez +Perry +Peterson +Phillips +Powell +Price +Ramírez +Reed +Reyes +Richardson +Rivera +Roberts +Robinson +Rodríguez +Rogers +Ross +Russell +Saarinen +Saaristo +Salminen +Salo +Salonen +Sánchez +Sanders +Scott +Seppänen +Silvennoinen +Silvo +Smith +Sokura +Stewart +Sullivan +Suomalainen +Taylor +Thomas +Thompson +Torres +Turner +Valkeapää +Walker +Valo +Valtonen +Vanhanen +Ward +Watson +Venäläinen +Vesa +White +Vihavainen +Williams +Wilson +Virtanen +Wood +Voutilainen +Wright +Vuorela +Young \ No newline at end of file diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_360x640px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_360x640px.svg new file mode 100644 index 0000000000..8daf275b19 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_360x640px.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_horisontal_640x360px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_horisontal_640x360px.svg new file mode 100644 index 0000000000..c2b070a3b1 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_background_horisontal_640x360px.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_53x53px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_53x53px.svg new file mode 100644 index 0000000000..6e34f255b2 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_53x53px.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg new file mode 100644 index 0000000000..29c284de08 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_default_icon_highlight_53x53px.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_divider_360x76px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_divider_360x76px.svg new file mode 100644 index 0000000000..db9fc7af33 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_divider_360x76px.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg new file mode 100644 index 0000000000..0ee3ea23e6 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_list_highlighter_357x80px.svg @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_idle_27x47.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_idle_27x47.svg new file mode 100644 index 0000000000..925d3eb36e --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_idle_27x47.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_offline_27x47.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_offline_27x47.svg new file mode 100644 index 0000000000..6f74723f09 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_offline_27x47.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_online_27x47.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_online_27x47.svg new file mode 100644 index 0000000000..56951605de --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_contact_status_online_27x47.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scroll_5x80px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scroll_5x80px.svg new file mode 100644 index 0000000000..4f6482afa5 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scroll_5x80px.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scrollbar_5x14px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scrollbar_5x14px.svg new file mode 100644 index 0000000000..54a40c3cc8 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_scrollbar_5x14px.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_left_14x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_left_14x24px.svg new file mode 100644 index 0000000000..a21c91df48 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_left_14x24px.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_middle_10x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_middle_10x24px.svg new file mode 100644 index 0000000000..b84200d9b1 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_middle_10x24px.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_right_14x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_right_14x24px.svg new file mode 100644 index 0000000000..231560dd9e --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_status_field_right_14x24px.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_356x96px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_356x96px.svg new file mode 100644 index 0000000000..679d9a5305 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_356x96px.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_horisontal_636x96px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_horisontal_636x96px.svg new file mode 100644 index 0000000000..1ef4fb9224 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_topbar_horisontal_636x96px.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_default_icon_84x68px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_default_icon_84x68px.svg new file mode 100644 index 0000000000..4df0214e56 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_default_icon_84x68px.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_idle_24x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_idle_24x24px.svg new file mode 100644 index 0000000000..2d6da38ad0 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_idle_24x24px.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_offline_24x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_offline_24x24px.svg new file mode 100644 index 0000000000..d5920268b1 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_offline_24x24px.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_online_24x24px.svg b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_online_24x24px.svg new file mode 100644 index 0000000000..46ad07dbbd --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/resources/lime_SVG/lime_user_status_online_24x24px.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.cpp new file mode 100644 index 0000000000..00481a638d --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.cpp @@ -0,0 +1,382 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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) { + const bool caching = m_itemView->listItemCaching(); + m_itemView->setListItemCaching(false); + + QSizeF s = m_itemView->size(); + s.setWidth(s.width()-m_itemView->verticalScrollBar()->size().width()); + adjustVisibleContainerSize(s); + + m_itemView->updateViewContent(); + updateItemBuffer(); + + m_itemView->setListItemCaching(caching); + } + + 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(); +} + +void AbstractItemContainer::setSubtreeCacheEnabled(bool enabled) +{ + for (int i = 0; i setSubtreeCacheEnabled(enabled); + if (m_prototype) + m_prototype->setSubtreeCacheEnabled(enabled); +} + +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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.h new file mode 100644 index 0000000000..7373f66deb --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemcontainer.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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(); + + void setSubtreeCacheEnabled(const bool enabled); + virtual void setListItemCaching(const bool enabled, const int index) = 0; + +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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.cpp new file mode 100644 index 0000000000..961cf4e03c --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.cpp @@ -0,0 +1,425 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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)); + m_container->setListItemCaching(listItemCaching(), i); + } + + 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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.h new file mode 100644 index 0000000000..8cd295ba89 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractitemview.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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); + + virtual bool listItemCaching() const = 0; + virtual void setListItemCaching(bool enabled) = 0; + +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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.cpp new file mode 100644 index 0000000000..39847b8edb --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.cpp @@ -0,0 +1,236 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.h new file mode 100644 index 0000000000..f681ca9fce --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractscrollarea.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.cpp new file mode 100644 index 0000000000..6a6df15e23 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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 +} + +/*virtual*/ +void AbstractViewItem::setSubtreeCacheEnabled(bool enabled) +{ + Q_UNUSED(enabled) + ; // No impl +} + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.h new file mode 100644 index 0000000000..4f9fbf4623 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/abstractviewitem.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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(); + + virtual void setSubtreeCacheEnabled(bool enabled); + + 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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.cpp new file mode 100644 index 0000000000..9f5f16d373 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.h new file mode 100644 index 0000000000..0cb0ee778c --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/backgrounditem.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/button.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/button.cpp new file mode 100644 index 0000000000..b8bd55789d --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/button.cpp @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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.horizontalAdvance(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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/button.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/button.h new file mode 100644 index 0000000000..8e76b88463 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/button.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp new file mode 100644 index 0000000000..226c60cec8 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "commandline.h" + +static void usage(const char *appname) +{ + Q_UNUSED(appname); + printf(" GraphicsViewBenchmark related options:\n"); + printf(" -h,-help,--help: This help\n"); + printf(" -resolution : UI resolution in format WxH where width and height are positive values\n"); + printf(" -opengl : Enables OpenGL usage. Building PRECONDITIONS: QT_NO_OPENGL is off.\n"); + printf(" -manual : Run test manually \n"); + printf("\n The following options are available in manual mode:\n"); + printf(" -rotation : UI rotation in degrees\n"); + printf(" -subtree-cache : Enables usage of subtree caching method\n"); + printf(" -fps : Output FPS count to stdout during application execution\n"); + printf(" -items : Count of items created to the list\n"); + printf("\n"); +} + +static inline bool argumentOnlyAvailableInManualMode(const char *arg) +{ + return (strcmp(arg, "-rotation") == 0) + || (strcmp(arg, "-subtree-cache") == 0) + || (strcmp(arg, "-fps") == 0) + || (strcmp(arg, "-items") == 0); +} + +bool readSettingsFromCommandLine(int argc, char *argv[], + Settings& config) +{ + bool builtWithOpenGL = false; + Settings::Options options; + +#ifndef QT_NO_OPENGL + builtWithOpenGL = true; +#endif + for (int i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-manual") == 0) { + options |= Settings::ManualTest; + argv[i] = 0; + break; + } + } + + for (int i = 1; i < argc; ++i) { + if (!argv[i]) + continue; + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0) { + usage(argv[0]); + return true; + } + if (strcmp(argv[i], "-opengl") == 0) { + if (builtWithOpenGL) { + options |= Settings::UseOpenGL; + argv[i] = 0; + } else { + printf("-opengl parameter can be used only with building PRECONDITIONS: QT_NO_OPENGL is off.\n"); + usage(argv[0]); + return false; + } + } else 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(QLatin1Char('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; + } + argv[i] = 0; + i++; + argv[i] = 0; + } + } + + if (!argv[i]) + continue; + + if (!(options & Settings::ManualTest)) { + if (argumentOnlyAvailableInManualMode(argv[i])) { + printf("\nWrong option: '%s' is only available in manual mode\n\n", argv[i]); + usage(argv[0]); + return false; + } + continue; + } + + 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); + argv[i] = 0; + i++; + argv[i] = 0; + } + } else if (strcmp(argv[i], "-subtree-cache") == 0) { + options |= Settings::UseListItemCache; + argv[i] = 0; + } else if (strcmp(argv[i], "-fps") == 0) { + options |= Settings::OutputFps; + argv[i] = 0; + } else 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); + argv[i] = 0; + i++; + argv[i] = 0; + } + } + } + + config.setOptions(options); + + return true; +} + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.h new file mode 100644 index 0000000000..eaddeac59d --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/commandline.h @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.cpp new file mode 100644 index 0000000000..7809b38050 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#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() +{ +} + +QString DummyDataGenerator::randomPhoneNumber(QString indexNumber) +{ + int index = QRandomGenerator::global()->bounded(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 + QLatin1Char(' ') + areaCode +QLatin1Char(' ') + beginNumber + + QLatin1Char(' ') + endNumber; +} + +QString DummyDataGenerator::randomFirstName() +{ + m_isMale = !m_isMale; + if (m_isMale) + return m_firstNamesM.at(QRandomGenerator::global()->bounded(m_firstNamesM.count())); + return m_firstNamesF.at(QRandomGenerator::global()->bounded(m_firstNamesF.count())); +} + +QString DummyDataGenerator::randomLastName() +{ + return m_lastNames.at(QRandomGenerator::global()->bounded(m_lastNames.count())); +} + +QString DummyDataGenerator::randomName() +{ + return QString(randomFirstName()+QString(", ")+randomLastName()); +} + +QString DummyDataGenerator::randomIconItem() +{ + QString avatar = Theme::p()->pixmapPath() + "contact_default_icon.svg"; + if (QRandomGenerator::global()->bounded(4)) { + int randVal = 1+QRandomGenerator::global()->bounded(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 (QRandomGenerator::global()->bounded(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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.h new file mode 100644 index 0000000000..bcb9681d5d --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/dummydatagen.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.cpp new file mode 100644 index 0000000000..3682ae55e1 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.h new file mode 100644 index 0000000000..7e247b63a4 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/gvbwidget.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.cpp new file mode 100644 index 0000000000..a081e1b064 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include "iconitem.h" + +IconItem::IconItem(const QString &filename, QGraphicsItem *parent) + : GvbWidget(parent) + , m_filename(filename) + , m_rotation(0.0) + , m_opacityEffect(0) + , 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(); + } +} + +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; +} diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.h new file mode 100644 index 0000000000..48d1bafe9f --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/iconitem.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ICONITEM_H +#define ICONITEM_H + +#include + +#include "gvbwidget.h" + +class QGraphicsOpacityEffect; +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); + + void setOpacityEffectEnabled(const bool enable); + bool isOpacityEffectEnabled() const; + + 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; + QGraphicsOpacityEffect *m_opacityEffect; + bool m_smoothTransformation; +}; + +#endif diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp new file mode 100644 index 0000000000..eabe3671e5 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp @@ -0,0 +1,248 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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)); + item->icon(ListItem::LeftIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::LeftIcon)); + item->icon(ListItem::RightIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::RightIcon)); + 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 +{ + ListItemContainer *container = + static_cast(m_container); + + return container->listItemCaching(); +} + +void ItemRecyclingList::setListItemCaching(bool enabled) +{ + ListItemContainer *container = + static_cast(m_container); + container->setListItemCaching(enabled); +} + +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; + + const bool caching = listItemCaching(); + setListItemCaching(false); + + m_container->setTwoColumns(enabled); + refreshContainerGeometry(); + + setListItemCaching(caching); +} + +bool ItemRecyclingList::twoColumns() +{ + return m_container->twoColumns(); +} + diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.h new file mode 100644 index 0000000000..a69b60c9e2 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.pri b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.pri new file mode 100644 index 0000000000..55b551ef8f --- /dev/null +++ b/tests/benchmarks/widgets/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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.cpp new file mode 100644 index 0000000000..5aa93256ff --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.h new file mode 100644 index 0000000000..467f193604 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglistview.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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; + virtual bool listItemCaching() const = 0; + virtual void setListItemCaching(bool enabled) = 0; + +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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/label.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/label.cpp new file mode 100644 index 0000000000..5fb2ee1a51 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/label.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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); + // This flag was introduced in Qt 4.6. + setFlag(QGraphicsItem::ItemHasNoContents, true); +} + +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.horizontalAdvance(m_textItem->text()), fm.height()); + } + default: + return GvbWidget::sizeHint(which, constraint); + } +} diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/label.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/label.h new file mode 100644 index 0000000000..2c1f14b20e --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/label.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.cpp new file mode 100644 index 0000000000..1872bcc9d3 --- /dev/null +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/listitem.cpp @@ -0,0 +1,287 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $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(); + data.iconOpacityEffets[ListItem::LeftIcon] = icon(ListItem::LeftIcon)->isOpacityEffectEnabled(); + } + + 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(); + data.iconOpacityEffets[ListItem::RightIcon] = icon(ListItem::RightIcon)->isOpacityEffectEnabled(); + } + + 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]); + icon(ListItem::LeftIcon)->setOpacityEffectEnabled(data.iconOpacityEffets[ListItem::LeftIcon]); + } + + if (icon(ListItem::RightIcon)) { + icon(ListItem::RightIcon)->setRotation(data.iconRotations[ListItem::RightIcon]); + icon(ListItem::RightIcon)->setSmoothTransformationEnabled(data.iconSmoothTransformations[ListItem::RightIcon]); + icon(ListItem::RightIcon)->setOpacityEffectEnabled(data.iconOpacityEffets[ListItem::RightIcon]); + } + + 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