From 69a9572261d44358c083ee5d8802d5042b3a470c Mon Sep 17 00:00:00 2001
From: Caroline Chao <caroline.chao@digia.com>
Date: Wed, 15 May 2013 09:08:51 +0200
Subject: [PATCH] TableView: expose rowAt method

Task-number: QTBUG-31160

Change-Id: I7dc6e0d755093786e079f526e5ff5f6cbcfa94e0
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
---
 src/controls/TableView.qml | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml
index c954b2a1e..4441207e7 100644
--- a/src/controls/TableView.qml
+++ b/src/controls/TableView.qml
@@ -247,8 +247,6 @@ ScrollView {
     If positioning the \a row creates an empty space at the beginning
     or end of the view, then the view is positioned at the boundary.
 
-    Note that this method should only be called after the Component has completed.
-    To position the view at startup, this method should be called by Component.onCompleted.
     For example, to position the view at the end at startup:
 
     \code
@@ -259,12 +257,29 @@ ScrollView {
     TableView Component.onCompleted is called. In that case you may need to
     delay the call to positionViewAtRow by using a \l {Timer}.
 
+    \note This method should only be called after the component has completed.
     */
 
     function positionViewAtRow(row, mode) {
         listView.positionViewAtRow(row, mode)
     }
 
+    /*!
+        \qmlmethod int TableView::rowAt( int x, int y )
+
+        Returns the index of the visible row at the point \a x, \a y in content
+        coordinates. If there is no visible row at the point specified, \c -1 is returned.
+
+        \note This method should only be called after the component has completed.
+    */
+
+    function rowAt(x, y) {
+        if (headerVisible)
+            y -= headerrow.height
+        return listView.indexAt(x, y)
+    }
+
+
     style: Qt.createComponent(Settings.theme() + "/TableViewStyle.qml", root)
 
 
-- 
GitLab