Commit eec41892 authored by Urs Fleisch's avatar Urs Fleisch

Do not change file extension when creating file name from tags.

parent a5817e7b
......@@ -4,6 +4,7 @@ Mon Apr 23 11:26:19 CEST 2018 Urs Fleisch <ufleisch@users.sourceforge.net>
* Improved:
+ Faster saving when many files are unchanged.
+ Do not change file extension when creating file name from tags.
+ Support for cross building.
* Fixed:
......
......@@ -394,7 +394,7 @@ QString TrackData::formatFilenameFromTags(QString str, bool isDirname) const
str.remove(0, sepPos + 1);
}
// add extension to str
str += getFileExtension();
str += getFileExtension(true);
}
TrackDataFormatReplacer fmt(*this, str);
......@@ -419,9 +419,12 @@ QString TrackData::getFormatToolTip(bool onlyRows)
/**
* Get file extension including the dot.
*
* @param preferFromFilename true to prefer extension from current filename
* over default extension for file type
*
* @return file extension, e.g. ".mp3".
*/
QString TrackData::getFileExtension() const
QString TrackData::getFileExtension(bool preferFromFilename) const
{
QString fileExtension;
QString absFilename;
......@@ -429,12 +432,13 @@ QString TrackData::getFileExtension() const
fileExtension = taggedFile->getFileExtension();
absFilename = taggedFile->getAbsFilename();
}
if (!fileExtension.isEmpty()) {
return fileExtension;
} else {
if (preferFromFilename || fileExtension.isEmpty()) {
int dotPos = absFilename.lastIndexOf(QLatin1Char('.'));
return dotPos != -1 ? absFilename.mid(dotPos) : QString();
if (dotPos != -1) {
return absFilename.mid(dotPos);
}
}
return fileExtension;
}
/**
......
......@@ -78,9 +78,12 @@ public:
/**
* Get file extension including the dot.
*
* @param preferFromFilename true to prefer extension from current filename
* over default extension for file type
*
* @return file extension, e.g. ".mp3".
*/
QString getFileExtension() const;
QString getFileExtension(bool preferFromFilename = false) const;
/**
* Get the total number of tracks in the directory.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment