From 4495e93f8d75aa98374afa1021c2be9d14db4f39 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 2 Oct 2011 01:04:16 -0400 Subject: [PATCH] Legacy - Moved more legacy checking code to legacy.cpp. --- src/commands/CmdCustom.cpp | 56 ++---------------------------------- src/legacy.cpp | 59 ++++++++++++++++++++++++++++++++++++++ src/main.h | 2 ++ 3 files changed, 63 insertions(+), 54 deletions(-) diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index 2179d3e20..f6f61532c 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -187,69 +187,17 @@ int CmdCustom::execute (std::string& output) //////////////////////////////////////////////////////////////////////////////// void CmdCustom::validateReportColumns (std::vector & columns) { - // One-time initialization, on demand. - static std::map legacyMap; - if (! legacyMap.size ()) - { - legacyMap["priority_long"] = "priority.long"; // Deprecated. - legacyMap["entry_time"] = "entry"; // Deprecated. - legacyMap["start_time"] = "start"; // Deprecated. - legacyMap["end_time"] = "end"; // Deprecated. - legacyMap["countdown"] = "due.countdown"; // Deprecated. - legacyMap["countdown_compact"] = "due.countdown"; // Deprecated. - legacyMap["age"] = "entry.age"; // Deprecated. - legacyMap["age_compact"] = "entry.age"; // Deprecated. - legacyMap["active"] = "start.active"; // Deprecated. - legacyMap["recurrence_indicator"] = "recur.indicator"; // Deprecated. - legacyMap["tag_indicator"] = "tags.indicator"; // Deprecated. - legacyMap["description_only"] = "description.desc"; // Deprecated. - } - std::vector ::iterator i; for (i = columns.begin (); i != columns.end (); ++i) - { - // If a legacy column was used, complain about it, but modify it anyway. - std::map ::iterator found = legacyMap.find (*i); - if (found != legacyMap.end ()) - { - context.footnote (format (STRING_CMD_CUSTOM_OLD_FIELD, *i, found->second)); - *i = found->second; - } - } + legacyColumnMap (*i); } //////////////////////////////////////////////////////////////////////////////// void CmdCustom::validateSortColumns (std::vector & columns) { - // One-time initialization, on demand. - static std::map legacyMap; - if (! legacyMap.size ()) - { - legacyMap["priority_long"] = "priority"; // Deprecated - legacyMap["entry_time"] = "entry"; // Deprecated - legacyMap["start_time"] = "start"; // Deprecated - legacyMap["end_time"] = "end"; // Deprecated - legacyMap["countdown"] = "due"; // Deprecated - legacyMap["countdown_compact"] = "due"; // Deprecated - legacyMap["age"] = "entry"; // Deprecated - legacyMap["age_compact"] = "entry"; // Deprecated - legacyMap["active"] = "start"; // Deprecated - legacyMap["recurrence_indicator"] = "recur"; // Deprecated - legacyMap["tag_indicator"] = "tags"; // Deprecated - legacyMap["description_only"] = "description"; // Deprecated - } - std::vector ::iterator i; for (i = columns.begin (); i != columns.end (); ++i) - { - // If a legacy column was used, complain about it, but modify it anyway. - std::map ::iterator found = legacyMap.find (*i); - if (found != legacyMap.end ()) - { - context.footnote (format (STRING_CMD_CUSTOM_OLD_SORT, *i, found->second)); - *i = found->second; - } - } + legacySortColumnMap (*i); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/legacy.cpp b/src/legacy.cpp index 07e57e7d7..018aa889e 100644 --- a/src/legacy.cpp +++ b/src/legacy.cpp @@ -42,4 +42,63 @@ void legacyAttributeCheck (const std::string& name) } //////////////////////////////////////////////////////////////////////////////// +void legacyColumnMap (std::string& name) +{ + // One-time initialization, on demand. + static std::map legacyMap; + if (! legacyMap.size ()) + { + legacyMap["priority_long"] = "priority.long"; // Deprecated. + legacyMap["entry_time"] = "entry"; // Deprecated. + legacyMap["start_time"] = "start"; // Deprecated. + legacyMap["end_time"] = "end"; // Deprecated. + legacyMap["countdown"] = "due.countdown"; // Deprecated. + legacyMap["countdown_compact"] = "due.countdown"; // Deprecated. + legacyMap["age"] = "entry.age"; // Deprecated. + legacyMap["age_compact"] = "entry.age"; // Deprecated. + legacyMap["active"] = "start.active"; // Deprecated. + legacyMap["recurrence_indicator"] = "recur.indicator"; // Deprecated. + legacyMap["tag_indicator"] = "tags.indicator"; // Deprecated. + legacyMap["description_only"] = "description.desc"; // Deprecated. + } + // If a legacy column was used, complain about it, but modify it anyway. + std::map ::iterator found = legacyMap.find (name); + if (found != legacyMap.end ()) + { + context.footnote (format (STRING_CMD_CUSTOM_OLD_FIELD, name, found->second)); + name = found->second; + } +} + +//////////////////////////////////////////////////////////////////////////////// +void legacySortColumnMap (std::string& name) +{ + // One-time initialization, on demand. + static std::map legacyMap; + if (! legacyMap.size ()) + { + legacyMap["priority_long"] = "priority"; // Deprecated + legacyMap["entry_time"] = "entry"; // Deprecated + legacyMap["start_time"] = "start"; // Deprecated + legacyMap["end_time"] = "end"; // Deprecated + legacyMap["countdown"] = "due"; // Deprecated + legacyMap["countdown_compact"] = "due"; // Deprecated + legacyMap["age"] = "entry"; // Deprecated + legacyMap["age_compact"] = "entry"; // Deprecated + legacyMap["active"] = "start"; // Deprecated + legacyMap["recurrence_indicator"] = "recur"; // Deprecated + legacyMap["tag_indicator"] = "tags"; // Deprecated + legacyMap["description_only"] = "description"; // Deprecated + } + + // If a legacy column was used, complain about it, but modify it anyway. + std::map ::iterator found = legacyMap.find (name); + if (found != legacyMap.end ()) + { + context.footnote (format (STRING_CMD_CUSTOM_OLD_SORT, name, found->second)); + name = found->second; + } +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/main.h b/src/main.h index 038a624bc..a359a0ca6 100644 --- a/src/main.h +++ b/src/main.h @@ -80,6 +80,8 @@ void sort_tasks (std::vector &, std::vector &, const std::string&); // legacy.cpp void legacyAttributeCheck (const std::string&); +void legacyColumnMap (std::string&); +void legacySortColumnMap (std::string&); // list template ///////////////////////////////////////////////////////////////////////////////