From ad5f372dc09cb382a31763dbd90c89dfd76ea75f Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig <jensb.bache-wiig@nokia.com> Date: Thu, 16 Jun 2011 14:06:42 +0200 Subject: [PATCH] Fixed choicelist index in TableViewGallery --- components/TableView.qml | 24 +++++++++++++++--------- examples/TableViewGallery.qml | 13 ++++++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/components/TableView.qml b/components/TableView.qml index 786e46d40..e293fb4ea 100644 --- a/components/TableView.qml +++ b/components/TableView.qml @@ -217,17 +217,17 @@ FocusScope{ } function decrementCurrentIndex() { - tree.blockUpdates = true - if (currentIndex > 0) tree.currentIndex = tree.currentIndex - 1 - wheelarea.verticalValue = contentY/wheelarea.scale - tree.blockUpdates = false + tree.blockUpdates = true; + tree.decrementCurrentIndex(); + wheelarea.verticalValue = contentY/wheelarea.scale; + tree.blockUpdates = false; } function incrementCurrentIndex() { - tree.blockUpdates = true - if (currentIndex< model.count - 1) tree.currentIndex = tree.currentIndex + 1 - wheelarea.verticalValue = contentY/wheelarea.scale - tree.blockUpdates = false + tree.blockUpdates = true; + tree.incrementCurrentIndex(); + wheelarea.verticalValue = contentY/wheelarea.scale; + tree.blockUpdates = false; } ListView { @@ -545,7 +545,7 @@ FocusScope{ anchors.topMargin: styleitem.style == "mac" ? tableColumn.height : 0 onValueChanged: { if(!tree.blockUpdates) - contentY = value + time.start() } anchors.bottomMargin: hscrollbar.visible ? hscrollbar.height : styleitem.frameoffset @@ -553,6 +553,12 @@ FocusScope{ Keys.onDownPressed: if (tree.currentIndex< tree.count - 1) tree.currentIndex = tree.currentIndex + 1 } + Timer{ + id:time + interval: 0 + onTriggered:contentY = vscrollbar.value + } + QStyleItem { z: 2 anchors.fill: parent diff --git a/examples/TableViewGallery.qml b/examples/TableViewGallery.qml index 4a91a6e59..6da8ab9ab 100644 --- a/examples/TableViewGallery.qml +++ b/examples/TableViewGallery.qml @@ -19,7 +19,7 @@ Rectangle { ChoiceList { id: delegateChooser - enabled: frame.current == 3 ? 1 : 0 + enabled: frame.current == 4 ? 1 : 0 model: delegatemenu anchors.left: parent.left anchors.leftMargin: 8 @@ -59,8 +59,8 @@ Rectangle { ListModel { id: largeModel Component.onCompleted: { - 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"}) + for (var i=0 ; i< 5000 ; ++i) + largeModel.append({"name":"Person "+i , "age": Math.round(Math.random()*100), "gender": Math.random()>0.5 ? "Male" : "Female"}) } } @@ -194,7 +194,6 @@ Rectangle { model: largeModel anchors.margins: 12 anchors.fill: parent - TableColumn { property: "name" caption: "Name" @@ -205,7 +204,11 @@ Rectangle { caption: "Age" width: 120 } - + TableColumn { + property: "gender" + caption: "Gender" + width: 120 + } frame: frameCheckbox.checked headerVisible: headerCheckbox.checked sortIndicatorVisible: sortableCheckbox.checked -- GitLab