| 83 | |
| 84 | |
| 85 | bool NTagViewDelegate::helpEvent(QHelpEvent *e, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) { |
| 86 | if ( !e || !view ) |
| 87 | return false; |
| 88 | |
| 89 | if ( e->type() == QEvent::ToolTip ) { |
| 90 | QRect rect = view->visualRect( index ); |
| 91 | QSize size = sizeHint( option, index ); |
| 92 | if ( rect.width() < size.width() ) { |
| 93 | QVariant tooltip = index.data( Qt::DisplayRole ); |
| 94 | if ( tooltip.canConvert<QString>() ) { |
| 95 | QToolTip::showText( e->globalPos(), QString( "<div>%1</div>" ) |
| 96 | .arg( Qt::escape( tooltip.toString() ) ), view ); |
| 97 | return true; |
| 98 | } |
| 99 | } |
| 100 | if ( !QStyledItemDelegate::helpEvent( e, view, option, index ) ) |
| 101 | QToolTip::hideText(); |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | return QStyledItemDelegate::helpEvent( e, view, option, index ); |
| 106 | } |