Show new lines properly in the comment tooltip, and simplify whitespace in the comment column. Fixes issue #1011

This commit is contained in:
David Sansome 2010-12-04 16:43:09 +00:00
parent 029f2e1f80
commit a07a808e5f
2 changed files with 16 additions and 5 deletions

View File

@ -251,7 +251,11 @@ QVariant Playlist::data(const QModelIndex& index, int role) const {
case Column_Filetype: return song.filetype();
case Column_DateModified: return song.mtime();
case Column_DateCreated: return song.ctime();
case Column_Comment: return song.comment();
case Column_Comment:
if (role == Qt::DisplayRole)
return song.comment().simplified();
return song.comment();
}
}

View File

@ -24,14 +24,15 @@
#include <QDateTime>
#include <QDir>
#include <QHeaderView>
#include <QHelpEvent>
#include <QLinearGradient>
#include <QLineEdit>
#include <QPainter>
#include <QScrollBar>
#include <QTextDocument>
#include <QToolTip>
#include <QWhatsThis>
#include <QHelpEvent>
#include <QHeaderView>
#include <QScrollBar>
#include <QLinearGradient>
const int QueuedItemDelegate::kQueueBoxBorder = 1;
const int QueuedItemDelegate::kQueueBoxCornerRadius = 3;
@ -210,6 +211,12 @@ bool PlaylistDelegateBase::helpEvent(QHelpEvent *event, QAbstractItemView *view,
QHelpEvent *he = static_cast<QHelpEvent*>(event);
QString text = displayText(index.data(), QLocale::system());
// Special case: we want newlines in the comment tooltip
if (index.column() == Playlist::Column_Comment) {
text = Qt::escape(index.data(Qt::ToolTipRole).toString());
text.replace("\n", "<br />");
}
if (text.isEmpty() || !he)
return false;