From 5309132add2b4bd064d7033199efac98ef597f00 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 20 Aug 2021 20:51:44 -0400 Subject: [PATCH] CmdTimesheet: Add ability to specify if context should be used This makes timesheet consistent with other report commands. --- src/commands/CmdTimesheet.cpp | 16 ++++++++++++++++ src/commands/CmdTimesheet.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index 307dc363c..4ec8ba406 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -53,6 +53,22 @@ CmdTimesheet::CmdTimesheet () _category = Command::Category::report; } +//////////////////////////////////////////////////////////////////////////////// +// Whether a the timesheet uses context is defined by the +// report.timesheet.context configuration variable. +// +bool CmdTimesheet::uses_context () const +{ + auto config = Context::getContext ().config; + auto key = "report.timesheet.context"; + + if (config.has (key)) + return config.getBoolean (key); + else + return _uses_context; +} + + //////////////////////////////////////////////////////////////////////////////// int CmdTimesheet::execute (std::string& output) { diff --git a/src/commands/CmdTimesheet.h b/src/commands/CmdTimesheet.h index 88fcc8326..dc6236bf1 100644 --- a/src/commands/CmdTimesheet.h +++ b/src/commands/CmdTimesheet.h @@ -35,6 +35,7 @@ class CmdTimesheet : public Command public: CmdTimesheet (); int execute (std::string&); + bool uses_context () const override; }; #endif