I would represent every field as a column and add two convenience methods that would operate on whole structs:
Qt Code:
  1. class ConnectionListModel : public QAbstractTableModel
  2. {
  3. ...
  4. enum Column
  5. {
  6. Name,
  7. HostAddress,
  8. Port,
  9. Username,
  10. Password,
  11. SessionType
  12. };
  13. ...
  14. // below index points to a certain field in certain connection
  15. bool setData( const QModelIndex & index, const QVariant & value, int role );
  16. ...
  17. bool setConnection( int row, const ConnectionData & conn );
  18. const ConnectionData & connection( int row ) const;
  19. ...
  20. };
To copy to clipboard, switch view to plain text mode