aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2021-03-18 21:51:05 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2021-03-18 21:51:05 +0000
commitf9d603827986591a366567635d5c62d7222521e8 (patch)
tree75a0afc372f411c3d6d8f46bb6d739804e3a13fd /src
parentfed7feb74c469e0b0eb7c86c74ce76a19e705747 (diff)
downloadqmmp-f9d603827986591a366567635d5c62d7222521e8.tar.gz
qmmp-f9d603827986591a366567635d5c62d7222521e8.tar.bz2
qmmp-f9d603827986591a366567635d5c62d7222521e8.zip
library: using file name as title if title is empty
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9765 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/General/library/library.cpp13
-rw-r--r--src/plugins/General/library/librarymodel.cpp3
2 files changed, 9 insertions, 7 deletions
diff --git a/src/plugins/General/library/library.cpp b/src/plugins/General/library/library.cpp
index fe3da9bd4..c286e5878 100644
--- a/src/plugins/General/library/library.cpp
+++ b/src/plugins/General/library/library.cpp
@@ -162,11 +162,15 @@ void Library::addTrack(TrackInfo *track, const QString &filePath)
":year, :track, :discnumber, :duration, "
":audioinfo, :url, :filepath, :searchstring)");
+ QString title = track->value(Qmmp::TITLE).isEmpty() ? track->path().section("/", -1) : track->value(Qmmp::TITLE);
+ QString album = track->value(Qmmp::ALBUM).isEmpty() ? tr("Unknown") : track->value(Qmmp::ALBUM);
+ QString artist = track->value(Qmmp::ARTIST).isEmpty() ? tr("Unknown") : track->value(Qmmp::ARTIST);
+
query.bindValue(":timestamp", QFileInfo(filePath).lastModified());
- query.bindValue(":title", track->value(Qmmp::TITLE));
- query.bindValue(":artist", track->value(Qmmp::ARTIST));
+ query.bindValue(":title", title);
+ query.bindValue(":artist", artist);
query.bindValue(":albumartist", track->value(Qmmp::ALBUMARTIST));
- query.bindValue(":album", track->value(Qmmp::ALBUM));
+ query.bindValue(":album", album);
query.bindValue(":comment", track->value(Qmmp::COMMENT));
query.bindValue(":genre", track->value(Qmmp::GENRE));
query.bindValue(":composer", track->value(Qmmp::COMPOSER));
@@ -177,8 +181,7 @@ void Library::addTrack(TrackInfo *track, const QString &filePath)
query.bindValue(":audioinfo", serializeAudioInfo(track->properties()));
query.bindValue(":url", track->path());
query.bindValue(":filepath", filePath);
- query.bindValue(":searchstring", QString("%1|||%2|||%3").arg(track->value(Qmmp::ARTIST))
- .arg(track->value(Qmmp::ALBUM)).arg(track->value(Qmmp::TITLE)).toLower());
+ query.bindValue(":searchstring", QString("%1|||%2|||%3").arg(artist).arg(album).arg(title).toLower());
if(!query.exec())
qWarning("Library: exec error: %s", qPrintable(query.lastError().text()));
}
diff --git a/src/plugins/General/library/librarymodel.cpp b/src/plugins/General/library/librarymodel.cpp
index a1c583149..9541bb382 100644
--- a/src/plugins/General/library/librarymodel.cpp
+++ b/src/plugins/General/library/librarymodel.cpp
@@ -194,8 +194,7 @@ QVariant LibraryModel::data(const QModelIndex &index, int role) const
if(!index.isValid() || role != Qt::DisplayRole)
return QVariant();
- QString name = static_cast<LibraryTreeItem *>(index.internalPointer())->name;
- return name.isEmpty() ? tr("Unknown") : name;
+ return static_cast<LibraryTreeItem *>(index.internalPointer())->name;
}
QModelIndex LibraryModel::parent(const QModelIndex &child) const