bool ContactListView::event( QEvent *e )
{

  if( e->type() != QEvent::ToolTip )
    return K3ListView::event( e );
  if ( !tooltips() )
    return true;
  QHelpEvent * he = static_cast< QHelpEvent * >( e );
  QPoint pnt = viewport()->mapFromGlobal( mapToGlobal( he->pos() ) );
  Q3ListViewItem * item = itemAt ( pnt );
  if ( item )
  {
    ContactListViewItem *plvi = static_cast<ContactListViewItem *>( item );
    QString s;

    //kDebug(5720) <<"Tip rec:" << r.x() <<"," << r.y() <<"," << r.width()
    //          << "," << r.height();

    KABC::Addressee a = plvi->addressee();
    if (a.isEmpty())
      return true;

    s += i18nc("label: value", "%1: %2", a.formattedNameLabel(),
               a.formattedName());

    s += '\n';
    s += i18nc("label: value", "%1: %2", a.organizationLabel(),
               a.organization());

    QString notes = a.note().trimmed();
    if ( !notes.isEmpty() ) {
      notes += '\n';
      s += '\n' + i18nc("label: value", "%1: \n", a.noteLabel());
      QFontMetrics fm( font() );

      // Begin word wrap code based on QMultiLineEdit code
      int i = 0;
      bool doBreak = false;
      int linew = 0;
      int lastSpace = -1;
      int a = 0;
      int lastw = 0;

      while ( i < int(notes.length()) ) {
        doBreak = false;
        if ( notes[i] != '\n' )
          linew += fm.width( notes[i] );

        if ( lastSpace >= a && notes[i] != '\n' )
          if  (linew >= parentWidget()->width()) {
            doBreak = true;
            if ( lastSpace > a ) {
              i = lastSpace;
              linew = lastw;
            }
            else
              i = qMax( a, i-1 );
          }

        if ( notes[i] == '\n' || doBreak ) {
          s += notes.mid( a, i - a + (doBreak?1:0) ) +'\n';

          a = i + 1;
          lastSpace = a;
          linew = 0;
        }

        if ( notes[i].isSpace() ) {
          lastSpace = i;
          lastw = linew;
        }

        if ( lastSpace <= a ) {
          lastw = linew;
        }

        ++i;
      }
    }
    if ( s.isEmpty() )
      QToolTip::hideText();
    else
      QToolTip::showText( he->globalPos(), s );
  }
  return true;
}