Hello and merry christmas!

I'd like to display a table of a SQLITE database, which looks like this:
Screen0022.png

The first column in my table view should be "name", and the rows should be user-checkable. Their check state is specified by the values in the "use" column. This column itself however should not be displayed in the table view. The rest of the columns are read-only. These and some other requirements make it obvious for subclassing one of the SQL models, because to my knowledge none of them provide this functionality by default.

While I subclassed some QAbstractTableModels with my own data structure before, I am having trouble getting my head around these SQL models. I think, the QSqlQueryModel would be the best choice, by reimplementing flags(), data() and setData() (for the check state). So far, I wasn't able to properly display the checkstate but not displaying the column "use". In my data() method, I called the base class' data() method and depending on the column and role, I decided what will finally be returned.

Here's an example (not working; I use PyQt, it seems... ):
Qt Code:
  1. def data(self, index, role=Qt.DisplayRole):
  2. if not index.isValid():
  3. return QVariant()
  4.  
  5. row = index.row()
  6. col = index.column()
  7. data = super(SkyObjectModel, self).data(index, role)
  8.  
  9.  
  10. if role == Qt.CheckStateRole:
  11. return self.record(row).field('use').value()
  12. elif role == Qt.DisplayRole:
  13. return data
  14. else:
  15. return QVariant()
To copy to clipboard, switch view to plain text mode 

So, my questions are:
- what model would I subclass (if necessary) ?
- how would I reimplement the data()/setData() method?

I am grateful for a firm push in the right direction.

Best regards,
Andi