diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index c3723515f..349cefddf 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -49,6 +49,34 @@ using namespace rtengine; #define PATH_SEPARATOR '/'; #endif +namespace // local helper functions +{ + // Look for N or -N in templateText at position ix, meaning "index from end" and "index from start" + // For N, return Nth index from the end, and for -N return the Nth index from the start + // N is a digit 1 through 9 + unsigned int decodePathIndex(unsigned int & ix, Glib::ustring & templateText, size_t numPathElements) + { + unsigned int pathIndex = numPathElements; // means input was invalid + bool fromStart = false; + if (ix < templateText.size()) { + if (templateText[ix] == '-') { + fromStart = true; // minus sign means N is from the start rather than the end of the path + ix++; + } + } + if (ix < templateText.size()) { + unsigned int n = templateText[ix] - '1'; + if (!fromStart) { + n = numPathElements - n - 1; + } + if (n < numPathElements) { + pathIndex = n; + } + } + return pathIndex; + } +} + BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCatalog(aFileCatalog), sequence(0), listener(nullptr) { @@ -567,7 +595,7 @@ void BatchQueue::openLastSelectedItemInEditor() { MYREADERLOCK(l, entryRW); - if (selected.size() > 0) { + if (!selected.empty()) { openItemInEditor(selected.back()); } } @@ -577,15 +605,13 @@ void BatchQueue::updateDestinationPathPreview() { MYWRITERLOCK(l, entryRW); - if (selected.size()) - { + if (!selected.empty()) { auto &entry = *selected.at(0); int sequence = 0; // Sequence during subsequent queue processing can't be determined here Glib::ustring baseDestination = calcAutoFileNameBase(entry.filename, sequence); Glib::ustring destination = Glib::ustring::compose ("%1.%2", baseDestination, options.saveFormatBatch.format); - if (listener) - { + if (listener) { listener->setDestinationPreviewText(destination); } } @@ -830,36 +856,6 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img) return processing ? processing->job : nullptr; } -// Look for N or -N in templateText at position ix, meaning "index from end" and "index from start" -// For N, return Nth index from the end, and for -N return the Nth index from the start -// N is a digit 1 through 9 -static inline unsigned decodePathIndex(unsigned & ix, Glib::ustring & templateText, size_t numPathElements) -{ - unsigned pathIndex = numPathElements; // means input was invalid - bool fromStart = false; - if (ix < templateText.size()) - { - if (templateText[ix] == '-') - { - fromStart = true; // minus sign means N is from the start rather than the end of the path - ix++; - } - } - if (ix < templateText.size()) - { - unsigned n = templateText[ix] - '1'; - if (!fromStart) - { - n = numPathElements - n - 1; - } - if (n < numPathElements) - { - pathIndex = n; - } - } - return pathIndex; -} - // Calculates automatic filename of processed batch entry, but just the base name // example output: "c:\out\converted\dsc0121" Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileName, int sequence) @@ -918,10 +914,10 @@ Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileNam if (options.savePathTemplate[ix] == 'P') { // insert path elements from given index to the end ix++; - unsigned n = decodePathIndex(ix, options.savePathTemplate, da.size()); + unsigned int n = decodePathIndex(ix, options.savePathTemplate, da.size()); if (n < da.size()) { - for (unsigned i=n; i