I would represent every field as a column and add two convenience methods that would operate on whole structs:
{
...
enum Column
{
Name,
HostAddress,
Port,
Username,
Password,
SessionType
};
...
// below index points to a certain field in certain connection
...
bool setConnection( int row, const ConnectionData & conn );
const ConnectionData & connection( int row ) const;
...
};
class ConnectionListModel : public QAbstractTableModel
{
...
enum Column
{
Name,
HostAddress,
Port,
Username,
Password,
SessionType
};
...
// below index points to a certain field in certain connection
bool setData( const QModelIndex & index, const QVariant & value, int role );
...
bool setConnection( int row, const ConnectionData & conn );
const ConnectionData & connection( int row ) const;
...
};
To copy to clipboard, switch view to plain text mode
Bookmarks