From ab29ef8326fbf747d1f5839fb286bb27bb44fafe Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 20 Aug 2021 20:17:50 -0400 Subject: [PATCH] CmdCustom: Respect report..context configuration variable This allows the user to configure if a specific report should (or should not) adhere to the currently active context. Closes #2560. --- src/commands/CmdCustom.cpp | 15 +++++++++++++++ src/commands/CmdCustom.h | 1 + src/commands/Command.h | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index 1bfd8ca56..6fb338110 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -59,6 +59,21 @@ CmdCustom::CmdCustom ( _category = Category::report; } +//////////////////////////////////////////////////////////////////////////////// +// Whether a report uses context is defined by the report..context +// configuration variable. +// +bool CmdCustom::uses_context () const +{ + auto config = Context::getContext ().config; + auto key = "report." + _keyword + ".context"; + + if (config.has (key)) + return config.getBoolean (key); + else + return _uses_context; +} + //////////////////////////////////////////////////////////////////////////////// int CmdCustom::execute (std::string& output) { diff --git a/src/commands/CmdCustom.h b/src/commands/CmdCustom.h index 4b1dbf381..f88bc0303 100644 --- a/src/commands/CmdCustom.h +++ b/src/commands/CmdCustom.h @@ -34,6 +34,7 @@ class CmdCustom : public Command { public: CmdCustom (const std::string&, const std::string&, const std::string&); + bool uses_context () const override; int execute (std::string&); private: diff --git a/src/commands/Command.h b/src/commands/Command.h index 71c13bd30..f144a1cc3 100644 --- a/src/commands/Command.h +++ b/src/commands/Command.h @@ -63,7 +63,7 @@ public: bool read_only () const; bool displays_id () const; bool needs_gc () const; - bool uses_context () const; + virtual bool uses_context () const; bool accepts_filter () const; bool accepts_modifications () const; bool accepts_miscellaneous () const;