Changeset View
Changeset View
Standalone View
Standalone View
src/views/dolphinview.cpp
Show First 20 Lines • Show All 713 Lines • ▼ Show 20 Line(s) | 709 | { | |||
---|---|---|---|---|---|
714 | 714 | | |||
715 | const QMimeDatabase db; | 715 | const QMimeDatabase db; | ||
716 | 716 | | |||
717 | // Duplicate all selected items and append "copy" to the end of the file name | 717 | // Duplicate all selected items and append "copy" to the end of the file name | ||
718 | // but before the filename extension, if present | 718 | // but before the filename extension, if present | ||
719 | QList<QUrl> newSelection; | 719 | QList<QUrl> newSelection; | ||
720 | for (const auto &item : itemList) { | 720 | for (const auto &item : itemList) { | ||
721 | const QUrl originalURL = item.url(); | 721 | const QUrl originalURL = item.url(); | ||
722 | const QString originalDirectoryPath = originalURL.adjusted(QUrl::RemoveFilename).path(); | ||||
722 | const QString originalFileName = item.name(); | 723 | const QString originalFileName = item.name(); | ||
724 | | ||||
723 | QString extension = db.suffixForFileName(originalFileName); | 725 | QString extension = db.suffixForFileName(originalFileName); | ||
724 | 726 | | |||
725 | QUrl duplicateURL = originalURL; | 727 | QUrl duplicateURL = originalURL; | ||
726 | 728 | | |||
727 | // No extension; new filename is "<oldfilename> copy" | 729 | // No extension; new filename is "<oldfilename> copy" | ||
728 | if (extension.isEmpty()) { | 730 | if (extension.isEmpty()) { | ||
729 | duplicateURL.setPath(i18nc("<file path> copy", "%1 copy", originalURL.path())); | 731 | duplicateURL.setPath(i18nc("<file path><filename> copy", "%1%2 copy", originalDirectoryPath, originalFileName)); | ||
730 | // There's an extension; new filename is "<oldfilename> copy.<extension>" | 732 | // There's an extension; new filename is "<oldfilename> copy.<extension>" | ||
731 | } else { | 733 | } else { | ||
732 | // Need to add a dot since QMimeDatabase::suffixForFileName() doesn't include it | 734 | // Need to add a dot since QMimeDatabase::suffixForFileName() doesn't include it | ||
733 | extension = QLatin1String(".") + extension; | 735 | extension = QLatin1String(".") + extension; | ||
734 | const QString directoryPath = originalURL.adjusted(QUrl::RemoveFilename).path(); | | |||
735 | const QString originalFilenameWithoutExtension = originalFileName.chopped(extension.size()); | 736 | const QString originalFilenameWithoutExtension = originalFileName.chopped(extension.size()); | ||
736 | // Preserve file's original filename extension in case the casing differs | 737 | // Preserve file's original filename extension in case the casing differs | ||
737 | // from what QMimeDatabase::suffixForFileName() returned | 738 | // from what QMimeDatabase::suffixForFileName() returned | ||
738 | const QString originalExtension = originalFileName.right(extension.size()); | 739 | const QString originalExtension = originalFileName.right(extension.size()); | ||
739 | duplicateURL.setPath(i18nc("<file path><filename> copy.<extension>", "%1%2 copy%3", directoryPath, originalFilenameWithoutExtension, originalExtension)); | 740 | duplicateURL.setPath(i18nc("<file path><filename> copy.<extension>", "%1%2 copy%3", originalDirectoryPath, originalFilenameWithoutExtension, originalExtension)); | ||
aacid: this is a case in which I think you even want more puzzle. getting this translated to %2%1copy… | |||||
i tihnk i would remove the .<extension> part, it's not part of the translatable string so it can be a bit confusing, also it's not like it gives translators anything they can work with, no? I mean why would it translate differently whether the filename has an extension or not? aacid: i tihnk i would remove the .<extension> part, it's not part of the translatable string so it… | |||||
740 | } | 741 | } | ||
741 | 742 | | |||
742 | KIO::CopyJob* job = KIO::copyAs(originalURL, duplicateURL, KIO::HideProgressInfo); | 743 | KIO::CopyJob* job = KIO::copyAs(originalURL, duplicateURL, KIO::HideProgressInfo); | ||
743 | KJobWidgets::setWindow(job, this); | 744 | KJobWidgets::setWindow(job, this); | ||
744 | 745 | | |||
745 | if (job) { | 746 | if (job) { | ||
746 | newSelection << duplicateURL; | 747 | newSelection << duplicateURL; | ||
747 | KIO::FileUndoManager::self()->recordCopyJob(job); | 748 | KIO::FileUndoManager::self()->recordCopyJob(job); | ||
▲ Show 20 Lines • Show All 1159 Lines • Show Last 20 Lines |
this is a case in which I think you even want more puzzle. getting this translated to %2%1copy makes no sense, the only thing you want translated here is "%1 copy" and then append the extenstion to that, the extension always has to be at the end right? That's something the filesystem mandates, not the translation