From 761ef296ad90c79f8f94ca1d10dc1af1903d3518 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 3 Mar 2012 16:08:21 -0500 Subject: [PATCH] Code Cleanup - Eliminatd helpers.cpp, and the redundant getFullDescription function therein. - The timesheet report now uses standard description formatting. --- src/CMakeLists.txt | 1 - src/commands/CmdTimesheet.cpp | 29 ++++++++- src/helpers.cpp | 109 ---------------------------------- src/main.h | 3 - 4 files changed, 27 insertions(+), 115 deletions(-) delete mode 100644 src/helpers.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 998ebea2b..6d7a620a1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,6 @@ set (task_SRCS A3.cpp A3.h Uri.cpp Uri.h ViewTask.cpp ViewTask.h ViewText.cpp ViewText.h - helpers.cpp dependency.cpp feedback.cpp i18n.h diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index fa6dfe6ec..2c4a00231 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -127,7 +127,20 @@ int CmdTimesheet::execute (std::string& output) completed.set (row, 2, dt.toString (format)); } - completed.set (row, 3, getFullDescription (*task, "timesheet"), c); + std::string description = task->get ("description"); + int indent = context.config.getInteger ("indent.annotation"); + + std::map annotations; + task->getAnnotations (annotations); + std::map ::iterator ann; + for (ann = annotations.begin (); ann != annotations.end (); ++ann) + description += "\n" + + std::string (indent, ' ') + + Date (ann->first.substr (11)).toString (context.config.get ("dateformat")) + + " " + + ann->second; + + completed.set (row, 3, description, c); } } } @@ -171,8 +184,20 @@ int CmdTimesheet::execute (std::string& output) started.set (row, 2, dt.toString (format)); } - started.set (row, 3, getFullDescription (*task, "timesheet"), c); + std::string description = task->get ("description"); + int indent = context.config.getInteger ("indent.annotation"); + std::map annotations; + task->getAnnotations (annotations); + std::map ::iterator ann; + for (ann = annotations.begin (); ann != annotations.end (); ++ann) + description += "\n" + + std::string (indent, ' ') + + Date (ann->first.substr (11)).toString (context.config.get ("dateformat")) + + " " + + ann->second; + + started.set (row, 3, description, c); } } } diff --git a/src/helpers.cpp b/src/helpers.cpp deleted file mode 100644 index 443667c9c..000000000 --- a/src/helpers.cpp +++ /dev/null @@ -1,109 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// taskwarrior - a command line task list manager. -// -// Copyright 2006-2012, Paul Beckingham, Federico Hernandez. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -// http://www.opensource.org/licenses/mit-license.php -// -//////////////////////////////////////////////////////////////////////////////// - -#define L10N // Localization complete. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -extern Context context; - -/////////////////////////////////////////////////////////////////////////////// -std::string getFullDescription (Task& task, const std::string& report) -{ - std::string desc = task.get ("description"); - std::string annotationDetails; - - std::map annotations; - task.getAnnotations (annotations); - - if (annotations.size () != 0) - { - std::string annotationDetails = context.config.get ("report." + report + ".annotations"); - if (annotationDetails == "") - annotationDetails = context.config.get ("annotations"); - if (report == "info") - annotationDetails = "full"; - - if (annotationDetails == "none") - { - desc = "+" + desc; - } - else if (annotationDetails == "sparse") - { - if (annotations.size () > 1) - desc = "+" + desc; - - std::map ::iterator i = annotations.begin (); - - Date dt (strtol (i->first.substr (11).c_str (), NULL, 10)); - std::string format = context.config.get ("dateformat.annotation"); - if (format == "") - format = context.config.get ("dateformat"); - std::string when = dt.toString (format); - desc += "\n" + when + " " + i->second; - } - else - { - std::map ::iterator anno; - for (anno = annotations.begin (); anno != annotations.end (); ++anno) - { - Date dt (strtol (anno->first.substr (11).c_str (), NULL, 10)); - std::string format = context.config.get ("dateformat.annotation"); - if (format == "") - format = context.config.get ("dateformat"); - std::string when = dt.toString (format); - desc += "\n" + when + " " + anno->second; - } - } - } - - return desc; -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/main.h b/src/main.h index c16dd2246..005d22ff2 100644 --- a/src/main.h +++ b/src/main.h @@ -48,9 +48,6 @@ void updateRecurrenceMask (Task&); int getDueState (const std::string&); bool nag (Task&); -// helpers.cpp -std::string getFullDescription (Task&, const std::string&); - // rules.cpp void initializeColorRules (); void autoColorize (Task&, Color&);