title: Qt TableView indexAt different behaviour with/without header
body: <p>Using PySide 1.2</p>
  
  <p>Grabbing the index of a clicked item in a <code>QTableView</code> returns a different result wether there is a horizontal header or not.
  If there is a horizontal header, it's seems to be included in the computing of <code>visualRect</code>. So the first line, first column index is no longer 0, 0 but 1, 0.</p>
  
  <p>Is this intended ? Because it is really confusing and inconvenient because the last line index will be invalid.</p>
  
  <p>To reproduce : </p>
  
  <pre><code>import re
  import operator
  import os
  import sys 
  # from Qt.QtCore import * 
  # from Qt.QtGui import * 
  # from Qt.QtWidgets import * 
  from PySide.QtCore import * 
  from PySide.QtGui import * 
  
  
  def main(): 
      app = QApplication(sys.argv) 
      w = MyWindow() 
      w.show() 
      sys.exit(app.exec_()) 
  
  
  class CustomTableView(QTableView):
      """
      """
  
      def __init__(self, parent=None):
          """
          """
          super(CustomTableView, self).__init__(parent=parent)
  
      def mousePressEvent(self, mouse_event):
          """
          """
          view_pos = self.mapFromGlobal(mouse_event.globalPos())
          index = self.indexAt(view_pos)
          print('mouse press index not  cutting header : ' + str((index.row(), index.column())))
          view_pos.setY(view_pos.y() - self.horizontalHeader().sizeHint().height())
          index = self.indexAt(view_pos)
          print('mouse press index cutting header : ' + str((index.row(), index.column())))
          super(CustomTableView, self).mousePressEvent(mouse_event)
  
  
  class MyWindow(QWidget): 
      def __init__(self, *args): 
          QWidget.__init__(self, *args) 
  
          # create table
          self.get_table_data()
          table = self.createTable() 
  
          # layout
          layout = QVBoxLayout()
          layout.addWidget(table) 
          self.setLayout(layout) 
  
      def get_table_data(self):
          stdouterr = os.popen4("dir c:\\")[1].read()
          lines = stdouterr.splitlines()
          lines = lines[5:]
          lines = lines[:-2]
          self.tabledata = [re.split(r"\s+", line, 4)
                       for line in lines]
  
      def createTable(self):
          # create the view
          tv = CustomTableView()
  
          # set the table model
          header = ['date', 'time', '', 'size', 'filename']
          tm = MyTableModel(self.tabledata, header, self) 
          tv.setModel(tm)
          return tv
  
  class MyTableModel(QAbstractTableModel): 
      def __init__(self, datain, headerdata, parent=None, *args): 
          """ datain: a list of lists
              headerdata: a list of strings
          """
          QAbstractTableModel.__init__(self, parent, *args) 
          self.arraydata = datain
          self.headerdata = headerdata
  
      def rowCount(self, parent): 
          return len(self.arraydata)
  
      def columnCount(self, parent): 
          return len(self.arraydata[0]) 
  
      def data(self, index, role): 
          if not index.isValid(): 
              return None 
          elif role != Qt.DisplayRole: 
              return None 
          return self.arraydata[index.row()][index.column()]
  
      def headerData(self, col, orientation, role):
          if orientation == Qt.Horizontal and role == Qt.DisplayRole:
              return self.headerdata[col]
          return None
  
  if __name__ == "__main__": 
      main()
  </code></pre>