QVariant SubkeyListModel::data( const QModelIndex & idx, int role ) const {

    if ( role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ToolTipRole )
	return QVariant();

    const Subkey subkey = this->subkey( idx );
    if ( subkey.isNull() )
	return QVariant();

    switch ( idx.column() ) {
    case ID:
	return QString::fromLatin1( subkey.keyID() );
    case Type:
	return Formatting::type( subkey );
    case ValidFrom:
	if ( role == Qt::EditRole )
	    return Formatting::creationDate( subkey );
	else
	    return Formatting::creationDateString( subkey );
    case ValidUntil:
	if ( role == Qt::EditRole )
	    return Formatting::expirationDate( subkey );
	else
	    return Formatting::expirationDateString( subkey );
    case Status:
	return Formatting::validityShort( subkey );
    case Bits:
	return subkey.length();
    }

    return QVariant();
}
QModelIndex SubkeyListModel::index( const Subkey & subkey, int col ) const {
    // O(N), but not sorted, so no better way...
    for ( unsigned int row = 0, end = d->key.numSubkeys() ; row != end ; ++row )
        if ( qstricmp( subkey.keyID(), d->key.subkey( row ).keyID() ) == 0 )
            return index( row, col );
    return QModelIndex();
}