From f0c72fce6ca41c6cc3d7282998baf6007f43885f Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig <jens.bache-wiig@nokia.com> Date: Fri, 20 May 2011 16:51:31 +0200 Subject: [PATCH] Updated itemview gallery --- components/TableView.qml | 2 + examples/ItemViewGallery.qml | 65 ++++++++++++++++++++------------ examples/images/header.png | Bin 0 -> 356 bytes examples/images/selectedrow.png | Bin 0 -> 303 bytes 4 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 examples/images/header.png create mode 100644 examples/images/selectedrow.png diff --git a/components/TableView.qml b/components/TableView.qml index 97abac84b..f3f7510a1 100644 --- a/components/TableView.qml +++ b/components/TableView.qml @@ -278,6 +278,8 @@ FocusScope{ id: itemDelegateLoader visible: header[index].visible sourceComponent: itemDelegate + property variant model: tree.model + property variant itemProperty: header[index].property width: header[index].width height: item ? item.height : Math.max(16, styleitem.sizeFromContents(16, 16).height) diff --git a/examples/ItemViewGallery.qml b/examples/ItemViewGallery.qml index ff3565513..7a2913f47 100644 --- a/examples/ItemViewGallery.qml +++ b/examples/ItemViewGallery.qml @@ -72,7 +72,7 @@ Rectangle { ListModel { id: largeModel Component.onCompleted: { - for (var i=0 ; i< 80 ; ++i) + for (var i=0 ; i< 50 ; ++i) largeModel.append({"name":"Person "+i , "age": Math.round(Math.random()*100), "sex": Math.random()>0.5 ? "Male" : "Female"}) } } @@ -186,13 +186,11 @@ Rectangle { ListModel { id: delegatemenu - ListElement { text: "Gray" } - ListElement { text: "hover" } - ListElement { text: "Apple" } - ListElement { text: "Coconut" } + ListElement { text: "Shiny" } + ListElement { text: "Scale" } + ListElement { text: "Editable" } } - Component { id: delegate1 Item { @@ -209,6 +207,17 @@ Rectangle { } } + + + Component { + id: slickRowDelegate + Rectangle{ + color: itemAlternateBackground ? "#cef" : "white" + // selected: itemSelected ? "true" : "false" + } + + } + Component { id: delegate2 Item { @@ -237,13 +246,15 @@ Rectangle { elide: itemElideMode text: itemValue ? itemValue : "" color: itemForeground - visible: columnIndex == 0 + visible: !itemSelected } TextInput{ - color:"#333" + color: itemForeground anchors.fill: parent anchors.margins: 4 - visible: columnIndex == 1 + visible: itemSelected + text: itemValue ? itemValue : "" + onTextChanged: model.setProperty(rowIndex, itemProperty, text) } } } @@ -272,28 +283,34 @@ Rectangle { width: 120 } - headerDelegate: Rectangle { - color: "#555" - Rectangle { - width: 1 - height: parent.height - color: "#444" - } + headerDelegate: BorderImage{ + source: "images/header.png" + border{left:2;right:2;top:2;bottom:2} Text { text: itemValue anchors.centerIn:parent - color:"#ccc" + color:"#333" } } rowDelegate: Rectangle { - color: itemSelected ? "#888" : (itemAlternateBackground ? "#ccc" : "#ddd") - clip: true - Rectangle{ - width: parent.width - height:1 - anchors.bottom: parent.bottom - color: "#aaa" + color: itemSelected ? "#448" : (itemAlternateBackground ? "#eee" : "#fff") + border.color:"#ccc" + border.width: 1 + anchors.left: parent.left + anchors.leftMargin: -2 + anchors.rightMargin: -1 + BorderImage{ + id:selected + anchors.fill: parent + source: "images/selectedrow.png" + visible: itemSelected + border{left:2;right:2;top:2;bottom:2} + SequentialAnimation { + running: true; loops: Animation.Infinite + NumberAnimation { target:selected; property: "opacity"; to: 1.0; duration: 900} + NumberAnimation { target:selected; property: "opacity"; to: 0.5; duration: 900} + } } } diff --git a/examples/images/header.png b/examples/images/header.png new file mode 100644 index 0000000000000000000000000000000000000000..dba6646092ce4f4f6dcc52f05c3fa96535eab660 GIT binary patch literal 356 zcmeAS@N?(olHy`uVBq!ia0vp^c0er2!2~3qadFKBQjEnx?oJHr&dIz4a@dl*-CY>W z7}6Lff2wOX1&VMMctjR6FmMZlFeAgPITAoY_7YEDSN7YiB79tOD^GkB2MS4+xJHyX z=jZ08=9Mrw7o{eaq^2m8XO?6rxO@5rgg5em6z%tPaSVw#{5I?&*I@;oJw1Q^tN-HG zK2Z~t&z~BweBE8E7LoT0IpQ8aoivNfQ=+BVuh)xxfu?HrE@uv@<SnnPinnRm-k$1L zu*>dV>F(*u#>-!8bDZG(C%!&AZJOU6Q*}+}Jn;&_9hHv`l*e<WNcNhpojIZEeXieS z_qzr`lD`;>4m{qjv@mpSY*F)i(cZbG>p%UNdia{&_eURuluy3dnpdTgXm+OJ&Kj<E t4W9pXAolg?PwSR!{AU<;etysc&UxNxJXS9+*#N!5;OXk;vd$@?2>@;Pged?3 literal 0 HcmV?d00001 diff --git a/examples/images/selectedrow.png b/examples/images/selectedrow.png new file mode 100644 index 0000000000000000000000000000000000000000..71192ea4e2b72d820f7afa745d50275fa8a1fb82 GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^Hb5-S!2~34eBFHkNHG=%xjQkeJ16rJ$YD$Jc6VVg zV@P9|{Hd<l6ez-3;1OBOz`!jG!i)^F=12eq*-JcqUD<E5ituqtwRWVP1qw-)xJHyX z=jZ08=9Mrw7o{eaq^2m8XO?6rxO@5rgg5eu0~K|7x;TbJ9DX}(FIR(tNUQ%NDU&aU zY{UCSba`DnuD5ZhNY85Fw`uN>d9u5x{>`#VLEnAyZgM3Yj~thCwDh^WP*K<t*}QIw z9Pci%lE6+i%a?seQ`Oh^$~C9HmY;g=&$dfpzy9uHjQ^$L=fWtx)m-7LyP{ImJjUW( rOWkEH8K1Jwd3@&omL<vYkr%|pN{sdUH(cEfbQOcAtDnm{r-UW|VfSVC literal 0 HcmV?d00001 -- GitLab