Logo Search packages:      
Sourcecode: kmess version File versions  Download package

QSize KMessViewDelegate::sizeHint ( const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const

Return an hint about the size of an item

Parameters:
optionContains some details about the item we have to determine size of
indexPoints to the actual list item
Returns:
The ize for the given index

Definition at line 515 of file kmessviewdelegate.cpp.

{
  Q_UNUSED( option );

  // Read the actual data off the model index
  const ModelDataList itemData( index.data().toMap() );

  // the height of the item should be
  // large enough to accommodate the font.
  QFont generalFont = KGlobalSettings::generalFont();
  QFontMetricsF metrics( generalFont );

  QSize size( KIconLoader::SizeSmall + 2, KIconLoader::SizeSmall + 4 );

  if ( size.height() < metrics.height() )
  {
    size.setHeight( metrics.height() );
  }

  if( itemData.isEmpty() )
  {
    return size;
  }

  int picturesDimension = currentAccount_->getListPictureSize();
  switch( itemData[ "type" ].toInt() )
  {
    case ContactListModelItem::ItemContact:
      if( picturesDimension > 0 )
      {
        QSize pictureSize( size );
        if( picturesDimension <= 32 )
        {
          // Fix the margin
          pictureSize.rheight() = 36;
        }
        else
        {
          pictureSize.rheight() = picturesDimension + 2;
        }

        qreal fontHeight = metrics.height() * 2; // x2 to account for PSM.

        if ( fontHeight > pictureSize.height() )
        {
          pictureSize.setHeight( fontHeight );
        }

        return pictureSize;
      }
      else
      {
        return size;
      }

    case ContactListModelItem::ItemGroup:
    default:
      return size;
  }
}

Generated by  Doxygen 1.6.0   Back to index