Show new lines properly in the comment tooltip, and simplify whitespace in the comment column. Fixes issue #1011
This commit is contained in:
parent
029f2e1f80
commit
a07a808e5f
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue