Display item info in playlist view only if text displayed is elided

This commit is contained in:
Arnaud Bienner 2011-02-02 22:58:19 +00:00
parent 2623a170a4
commit e8720f5bda
1 changed files with 12 additions and 1 deletions

View File

@ -226,9 +226,20 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
if (text.isEmpty() || !he)
return false;
QRect displayed_text;
QSize real_text;
bool is_elided = false;
switch (event->type()) {
case QEvent::ToolTip:
QToolTip::showText(he->globalPos(), text, view);
real_text = sizeHint(option, index);
displayed_text = view->visualRect(index);
is_elided = displayed_text.width() < real_text.width();
if(is_elided) {
QToolTip::showText(he->globalPos(), text, view);
} else { // in case that another text was previously displayed
QToolTip::hideText();
}
return true;
case QEvent::QueryWhatsThis: