From 743cb929582712515b22b5b154d148bbfe13b5a9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 4 Apr 2015 14:50:38 -0400 Subject: [PATCH] Context: Static initialize UDA sort order values --- src/Context.cpp | 13 +++++++++++++ src/Task.cpp | 2 ++ src/Task.h | 1 + 3 files changed, 16 insertions(+) diff --git a/src/Context.cpp b/src/Context.cpp index 6f095d24e..3cb1a9562 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -641,6 +641,19 @@ void Context::staticInitialization () Lexer::dateFormat = Variant::dateFormat = config.get ("dateformat"); Lexer::isoEnabled = Variant::isoEnabled = config.getBoolean ("date.iso"); + Config::const_iterator rc; + for (rc = config.begin (); rc != config.end (); ++rc) + { + if (rc->first.substr (0, 4) == "uda." && + rc->first.substr (rc->first.length () - 7, 7) == ".values") + { + std::string name = rc->first.substr (4, rc->first.length () - 7 - 4); + std::vector values; + split (values, rc->second, ','); + Task::customOrder[name] = values; + } + } + std::map ::iterator i; for (i = columns.begin (); i != columns.end (); ++i) Task::attributes[i->first] = i->second->type (); diff --git a/src/Task.cpp b/src/Task.cpp index 44c58a541..15875733f 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -87,6 +87,8 @@ float Task::urgencyBlockingCoefficient = 0.0; float Task::urgencyAgeCoefficient = 0.0; float Task::urgencyAgeMax = 0.0; +std::map > Task::customOrder; + static const std::string dummy (""); //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Task.h b/src/Task.h index 4eeca3854..4cbc06fb1 100644 --- a/src/Task.h +++ b/src/Task.h @@ -43,6 +43,7 @@ public: static bool regex; static std::map attributes; // name -> type static std::map coefficients; + static std::map > customOrder; static float urgencyPriorityCoefficient; static float urgencyProjectCoefficient; static float urgencyActiveCoefficient;