diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index 3a82ef511..c275ee675 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -100,9 +100,9 @@ namespace // local helper functions // use that string to format dateTime. Append the formatted time to path. void appendFormattedTime(Glib::ustring& path, unsigned int& ix, const Glib::ustring& templateText, const Glib::DateTime& dateTime) { - constexpr unsigned int quoteMark = (unsigned int)'"'; + constexpr gunichar quoteMark('"'); if ((ix + 1) < templateText.size() && templateText[ix] == quoteMark) { - auto endPos = templateText.find_first_of(quoteMark, ++ix); + const auto endPos = templateText.find_first_of(quoteMark, ++ix); if (endPos != Glib::ustring::npos) { Glib::ustring formatString(templateText, ix, endPos-ix); path += dateTime.format(formatString); @@ -1024,8 +1024,10 @@ Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileNam switch(options.savePathTemplate[ix++]) { case 'E': // (approximate) time when export started + { dateTime = Glib::DateTime::create_now_local(); break; + } case 'F': // time when file was last saved { Glib::RefPtr file = Gio::File::create_for_path(origFileName); @@ -1035,16 +1037,18 @@ Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileNam dateTime = info->get_modification_date_time(); } } - } break; + } case 'P': // time when picture was taken { - auto timestamp = FramesData(origFileName).getDateTimeAsTS(); + const auto timestamp = FramesData(origFileName).getDateTimeAsTS(); dateTime = Glib::DateTime::create_now_local(timestamp); + break; } - break; default: + { break; + } } if (dateTime) { appendFormattedTime(path, ix, options.savePathTemplate, dateTime); diff --git a/rtgui/batchqueuepanel.cc b/rtgui/batchqueuepanel.cc index f7e46fa7c..bf6cc0772 100644 --- a/rtgui/batchqueuepanel.cc +++ b/rtgui/batchqueuepanel.cc @@ -344,7 +344,7 @@ void BatchQueuePanel::templateHelpButtonToggled() if (buffer->get_text().empty()) { // Populate the help text the first time it's shown populateTemplateHelpBuffer(buffer); - auto fullWidth = middleSplitPane->get_width(); + const auto fullWidth = middleSplitPane->get_width(); middleSplitPane->set_position(fullWidth / 2); } scrolledTemplateHelpWindow->set_visible(visible); @@ -354,13 +354,13 @@ void BatchQueuePanel::templateHelpButtonToggled() void BatchQueuePanel::populateTemplateHelpBuffer(Glib::RefPtr buffer) { auto pos = buffer->begin(); - auto insertTopicHeading = [&pos, buffer](const Glib::ustring& text) { + const auto insertTopicHeading = [&pos, buffer](const Glib::ustring& text) { pos = buffer->insert_markup(pos, Glib::ustring::format("\n\n", text, "\n")); }; - auto insertTopicBody = [&pos, buffer](const Glib::ustring& text) { + const auto insertTopicBody = [&pos, buffer](const Glib::ustring& text) { pos = buffer->insert_markup(pos, Glib::ustring::format("\n", text, "\n")); }; - auto mainTitle = M("QUEUE_LOCATION_TEMPLATE_HELP_TITLE"); + const auto mainTitle = M("QUEUE_LOCATION_TEMPLATE_HELP_TITLE"); pos = buffer->insert_markup(pos, Glib::ustring::format("", mainTitle, "\n")); pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_INTRO")); @@ -377,21 +377,21 @@ void BatchQueuePanel::populateTemplateHelpBuffer(Glib::RefPtr b pos = buffer->insert(pos, "\n"); pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_BODY_1")); #ifdef _WIN32 - auto exampleFilePath = M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_WINDOWS"); + const auto exampleFilePath = M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_WINDOWS"); #else - auto exampleFilePath = M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_LINUX"); + const auto exampleFilePath = M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_LINUX"); #endif pos = buffer->insert_markup(pos, Glib::ustring::format("\n ", exampleFilePath, "\n")); pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_BODY_2")); // Examples are generated from exampleFilePath using the actual template processing function - Options savedOptions = options; // to be restored after generating example results + const Options savedOptions = options; // to be restored after generating example results options.saveUsePathTemplate = true; // Since this code only ever runs once (the first time the help text is presented), no attempt is // made to be efficient. Use a brute-force method to discover the number of elements in exampleFilePath. int pathElementCount = 0; for (int n=9; n>=0; n--) { - options.savePathTemplate = Glib::ustring::format("%d",n); - auto result = BatchQueue::calcAutoFileNameBase(exampleFilePath); + options.savePathTemplate = Glib::ustring::format("%d", n); + const auto result = BatchQueue::calcAutoFileNameBase(exampleFilePath); if (!result.empty()) { // The 'd' specifier returns an empty string if N exceeds the number of path elements, so // the largest N that does not return an empty string is the number of elements in exampleFilePath. @@ -401,11 +401,11 @@ void BatchQueuePanel::populateTemplateHelpBuffer(Glib::RefPtr b } // Function inserts examples for a particular specifier, with every valid N value for the // number of elements in the path. - auto insertPathExamples = [&buffer, &pos, pathElementCount, exampleFilePath](char letter, int offset1, int mult1, int offset2, int mult2) + const auto insertPathExamples = [&buffer, &pos, pathElementCount, exampleFilePath](char letter, int offset1, int mult1, int offset2, int mult2) { for (int n=0; n b insertPathExamples('p', 1, 1, -pathElementCount, 1); // %p1 = %p-4 = /home/tom/photos/2010-10-31/ insertPathExamples('P', 1, 1, -pathElementCount, 1); // %P1 = %P-4 = 2010-10-31/ { - Glib::ustring fspecifier("%f"); + const Glib::ustring fspecifier("%f"); options.savePathTemplate = fspecifier; - auto result = BatchQueue::calcAutoFileNameBase(exampleFilePath); + const auto result = BatchQueue::calcAutoFileNameBase(exampleFilePath); pos = buffer->insert_markup(pos, Glib::ustring::format("\n ", fspecifier, " = ", result, "")); } @@ -437,15 +437,15 @@ void BatchQueuePanel::populateTemplateHelpBuffer(Glib::RefPtr b insertTopicHeading(M("QUEUE_LOCATION_TEMPLATE_HELP_TIMESTAMP_TITLE")); pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_TIMESTAMP_BODY")); - Glib::ustring dateTimeFormatExamples[] = { + const Glib::ustring dateTimeFormatExamples[] = { "%Y-%m-%d", "%Y%m%d_%H%M%S", "%y/%b/%-d/" }; - auto timezone = Glib::DateTime::create_now_local().get_timezone(); - auto timeForExamples = Glib::DateTime::create_from_iso8601("2001-02-03T04:05:06.123456", timezone); - for (auto fmt : dateTimeFormatExamples) { - auto result = timeForExamples.format(fmt); + const auto timezone = Glib::DateTime::create_now_local().get_timezone(); + const auto timeForExamples = Glib::DateTime::create_from_iso8601("2001-02-03T04:05:06.123456", timezone); + for (auto && fmt : dateTimeFormatExamples) { + const auto result = timeForExamples.format(fmt); pos = buffer->insert_markup(pos, Glib::ustring::format("\n %tE\"", fmt, "\" = ", result, "")); }