| 110 | |
| 111 | |
| 112 | bool NNotebookViewDelegate::helpEvent(QHelpEvent *e, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index) { |
| 113 | if ( !e || !view ) |
| 114 | return false; |
| 115 | |
| 116 | if ( e->type() == QEvent::ToolTip ) { |
| 117 | QRect rect = view->visualRect( index ); |
| 118 | QSize size = sizeHint( option, index ); |
| 119 | if ( rect.width() < size.width() ) { |
| 120 | QVariant tooltip = index.data( Qt::DisplayRole ); |
| 121 | if ( tooltip.canConvert<QString>() ) { |
| 122 | QToolTip::showText( e->globalPos(), QString( "<div>%1</div>" ) |
| 123 | .arg( Qt::escape( tooltip.toString() ) ), view ); |
| 124 | return true; |
| 125 | } |
| 126 | } |
| 127 | if ( !QStyledItemDelegate::helpEvent( e, view, option, index ) ) |
| 128 | QToolTip::hideText(); |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | return QStyledItemDelegate::helpEvent( e, view, option, index ); |
| 133 | } |