Use consistent song tooltip everywhere
This commit is contained in:
committed by
craig.p.drummond
parent
c056c3ff13
commit
479b124bb1
@@ -295,14 +295,8 @@ QVariant AlbumsModel::data(const QModelIndex &index, int role) const
|
||||
case Qt::DecorationRole:
|
||||
return Song::Playlist==si->type ? Icons::self()->playlistIcon : Icons::self()->audioFileIcon;
|
||||
#endif
|
||||
case Qt::ToolTipRole: {
|
||||
quint32 year=si->parent->songs.count() ? si->parent->songs.at(0)->year : 0;
|
||||
return si->parent->artist+QLatin1String("<br/>")+
|
||||
si->parent->album+(year>0 ? (QLatin1String(" (")+QString::number(year)+QChar(')')) : QString())+QLatin1String("<br/>")+
|
||||
data(index, Qt::DisplayRole).toString()+QLatin1String("<br/>")+
|
||||
Utils::formatTime(si->time, true)+QLatin1String("<br/>")+
|
||||
QLatin1String("<small><i>")+si->filePath()+QLatin1String("</i></small>");
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
return si->toolTip();
|
||||
case Cantata::Role_MainText:
|
||||
case Qt::DisplayRole:
|
||||
if (Song::Playlist==si->type) {
|
||||
|
||||
@@ -90,13 +90,6 @@ static QString parentData(const MusicLibraryItem *i)
|
||||
return data;
|
||||
}
|
||||
|
||||
static void addField(const QString &name, const QString &val, QString &tt)
|
||||
{
|
||||
if (!val.isEmpty()) {
|
||||
tt+=QString("<tr><td align=\"right\"><b>%1: </b></td><td>%2</td></tr>").arg(name).arg(val);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant MusicModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid()) {
|
||||
@@ -172,41 +165,7 @@ QVariant MusicModel::data(const QModelIndex &index, int role) const
|
||||
QLatin1String("<br/><small><i>")+static_cast<MusicLibraryItemPodcastEpisode *>(item)->published()+QLatin1String("</i></small>");
|
||||
}
|
||||
#endif
|
||||
const Song &song=static_cast<MusicLibraryItemSong *>(item)->song();
|
||||
QString toolTip=QLatin1String("<table>");
|
||||
addField(i18n("Title"), song.title, toolTip);
|
||||
addField(i18n("Artist"), song.artist, toolTip);
|
||||
if (song.albumartist!=song.artist) {
|
||||
addField(i18n("Album artist"), song.albumartist, toolTip);
|
||||
}
|
||||
addField(i18n("Composer"), song.composer(), toolTip);
|
||||
addField(i18n("Album"), song.album, toolTip);
|
||||
if (song.track>0) {
|
||||
addField(i18n("Track number"), QString::number(song.track), toolTip);
|
||||
}
|
||||
if (song.disc>0) {
|
||||
addField(i18n("Disc number"), QString::number(song.disc), toolTip);
|
||||
}
|
||||
addField(i18n("Genre"), song.genre, toolTip);
|
||||
if (song.year>0) {
|
||||
addField(i18n("Year"), QString::number(song.year), toolTip);
|
||||
}
|
||||
if (song.time>0) {
|
||||
addField(i18n("Length"), Utils::formatTime(song.time, true), toolTip);
|
||||
}
|
||||
toolTip+=QLatin1String("</table>");
|
||||
|
||||
#ifdef ENABLE_ONLINE_SERVICES
|
||||
if (dynamic_cast<const OnlineService *>(root(item))) {
|
||||
return toolTip;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_DEVICES_SUPPORT
|
||||
if (dynamic_cast<const Device *>(root(item))) {
|
||||
return toolTip;
|
||||
}
|
||||
#endif
|
||||
return toolTip+QLatin1String("<br/><br/><small><i>")+song.file+QLatin1String("</i></small>");
|
||||
return static_cast<MusicLibraryItemSong *>(item)->song().toolTip();
|
||||
}
|
||||
|
||||
return parentData(item)+
|
||||
|
||||
@@ -443,18 +443,9 @@ QVariant PlaylistsModel::data(const QModelIndex &index, int role) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
case Qt::ToolTipRole: {
|
||||
QString text=s->entryName();
|
||||
|
||||
if (Qt::ToolTipRole==role) {
|
||||
text=text.replace("\n", "<br/>");
|
||||
if (!s->title.isEmpty()) {
|
||||
text+=QLatin1String("<br/>")+Utils::formatTime(s->time);
|
||||
text+=QLatin1String("<br/><small><i>")+s->file+QLatin1String("</i></small>");
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
return s->entryName();
|
||||
case Qt::ToolTipRole:
|
||||
return s->toolTip();
|
||||
#ifndef ENABLE_UBUNTU
|
||||
case Qt::DecorationRole:
|
||||
return multiCol ? QVariant() : (s->title.isEmpty() ? Icons::self()->streamIcon : Icons::self()->audioFileIcon);
|
||||
|
||||
@@ -576,12 +576,7 @@ QVariant PlayQueueModel::data(const QModelIndex &index, int role) const
|
||||
if (s.album.isEmpty() && s.isStream()) {
|
||||
return basicPath(s);
|
||||
} else {
|
||||
return s.albumArtist()+QLatin1String("<br/>")+
|
||||
s.displayAlbum()+QLatin1String("<br/>")+
|
||||
s.trackAndTitleStr()+QLatin1String("<br/>")+
|
||||
Utils::formatTime(s.time)+QLatin1String("<br/>")+
|
||||
(s.priority>0 ? i18n("<b>(Priority: %1)</b>", s.priority)+QLatin1String("<br/>") : QString())+
|
||||
QLatin1String("<small><i>")+basicPath(s)+QLatin1String("</i></small>");
|
||||
return s.toolTip();
|
||||
}
|
||||
}
|
||||
case Qt::TextAlignmentRole:
|
||||
|
||||
@@ -209,18 +209,9 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt::ToolTipRole: {
|
||||
QString text=song->entryName();
|
||||
|
||||
if (Qt::ToolTipRole==role) {
|
||||
text=text.replace("\n", "<br/>");
|
||||
if (!song->title.isEmpty()) {
|
||||
text+=QLatin1String("<br/>")+Utils::formatTime(song->time);
|
||||
text+=QLatin1String("<br/><small><i>")+song->file+QLatin1String("</i></small>");
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
return song->entryName();
|
||||
case Qt::ToolTipRole:
|
||||
return song->toolTip();
|
||||
case Cantata::Role_MainText:
|
||||
return song->title.isEmpty() ? song->file : song->trackAndTitleStr();
|
||||
case Cantata::Role_SubText:
|
||||
|
||||
45
mpd/song.cpp
45
mpd/song.cpp
@@ -483,6 +483,51 @@ QString Song::trackAndTitleStr(bool showArtistIfDifferent) const
|
||||
QLatin1Char(' ')+(showArtistIfDifferent && diffArtist() ? artistSong() : title);
|
||||
}
|
||||
|
||||
#ifndef CANTATA_NO_UI_FUNCTIONS
|
||||
static void addField(const QString &name, const QString &val, QString &tt)
|
||||
{
|
||||
if (!val.isEmpty()) {
|
||||
tt+=QString("<tr><td align=\"right\"><b>%1: </b></td><td>%2</td></tr>").arg(name).arg(val);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QString Song::toolTip() const
|
||||
{
|
||||
#ifdef CANTATA_NO_UI_FUNCTIONS
|
||||
return QString();
|
||||
#else
|
||||
QString toolTip=QLatin1String("<table>");
|
||||
addField(i18n("Title"), title, toolTip);
|
||||
addField(i18n("Artist"), artist, toolTip);
|
||||
if (albumartist!=artist) {
|
||||
addField(i18n("Album artist"), albumartist, toolTip);
|
||||
}
|
||||
addField(i18n("Composer"), composer(), toolTip);
|
||||
addField(i18n("Performer"), performer(), toolTip);
|
||||
addField(i18n("Album"), album, toolTip);
|
||||
if (track>0) {
|
||||
addField(i18n("Track number"), QString::number(track), toolTip);
|
||||
}
|
||||
if (disc>0) {
|
||||
addField(i18n("Disc number"), QString::number(disc), toolTip);
|
||||
}
|
||||
addField(i18n("Genre"), genre, toolTip);
|
||||
if (year>0) {
|
||||
addField(i18n("Year"), QString::number(year), toolTip);
|
||||
}
|
||||
if (time>0) {
|
||||
addField(i18n("Length"), Utils::formatTime(time, true), toolTip);
|
||||
}
|
||||
toolTip+=QLatin1String("</table>");
|
||||
|
||||
if (isNonMPD()) {
|
||||
return toolTip;
|
||||
}
|
||||
return toolTip+QLatin1String("<br/><br/><small><i>")+filePath()+QLatin1String("</i></small>");
|
||||
#endif
|
||||
}
|
||||
|
||||
void Song::setExtraField(int f, const QString &v)
|
||||
{
|
||||
if (v.isEmpty()) {
|
||||
|
||||
@@ -126,6 +126,7 @@ struct Song
|
||||
const QString & albumArtist() const { return albumartist.isEmpty() ? artist : albumartist; }
|
||||
QString displayTitle() const { return !albumartist.isEmpty() && albumartist!=artist ? artistSong() : title; }
|
||||
QString trackAndTitleStr(bool showArtistIfDifferent=true) const;
|
||||
QString toolTip() const;
|
||||
|
||||
QString extraField(int f) const { return extra[f]; }
|
||||
void setExtraField(int f, const QString &v);
|
||||
|
||||
@@ -27,7 +27,7 @@ else (ENABLE_KDE_SUPPORT)
|
||||
endif (WIN32)
|
||||
endif (ENABLE_KDE_SUPPORT)
|
||||
|
||||
add_definitions(-DCANTATA_TAG_SERVER)
|
||||
add_definitions(-DCANTATA_TAG_SERVER -DCANTATA_NO_UI_FUNCTIONS)
|
||||
target_link_libraries(cantata-tags ${TAGLIB_LIBRARIES} ${QTGUILIBS} ${QTCORELIBS} ${QTNETWORKLIBS})
|
||||
if (TAGLIB-EXTRAS_FOUND)
|
||||
target_link_libraries(cantata-tags ${TAGLIB-EXTRAS_LIBRARIES})
|
||||
|
||||
Reference in New Issue
Block a user