void ServerList
::addItem( const QString &hostName, quint16 port,
const QString
& username,
const QString& password, quint16 timeout, quint16 numberConnections )
{
// first, insert a top level row
int rows = model()->rowCount();
model()->insertRow( rows );
// set host name to the index in the first
// column of the newly inserted row
model()->setData( parent, hostName );
//Server ns( hostName, port, username, password, timeout, numberConnections );
//server.append( ns );
// add a column and enough rows for connection children
// the parent is the parent we just inserted above
model()->insertColumn( 0, parent ); // one column for children
rows = model()->rowCount( parent );
model()->insertRows( rows, numberConnections, parent ); // one row for each child
// set connection names for each children
for ( int x = 0; x < numberConnections; x++ )
{
QModelIndex child
= model
()->index
( x,
0, parent
);
// all connections are under the same parent // which is, again, the same parent we
// inserted in the first place
model
()->setData
( child,
QString("Connection #%1").
arg( x
+ 1 ) );
}
}
void ServerList::addItem( const QString &hostName, quint16 port, const QString& username,
const QString& password, quint16 timeout, quint16 numberConnections )
{
// first, insert a top level row
int rows = model()->rowCount();
model()->insertRow( rows );
// set host name to the index in the first
// column of the newly inserted row
QModelIndex parent = model()->index( rows, 0 );
model()->setData( parent, hostName );
//Server ns( hostName, port, username, password, timeout, numberConnections );
//server.append( ns );
// add a column and enough rows for connection children
// the parent is the parent we just inserted above
model()->insertColumn( 0, parent ); // one column for children
rows = model()->rowCount( parent );
model()->insertRows( rows, numberConnections, parent ); // one row for each child
// set connection names for each children
for ( int x = 0; x < numberConnections; x++ )
{
QModelIndex child = model()->index( x, 0, parent ); // all connections are under the same parent
// which is, again, the same parent we
// inserted in the first place
model()->setData( child, QString("Connection #%1").arg( x + 1 ) );
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks