mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup
- Eliminatd helpers.cpp, and the redundant getFullDescription function therein. - The timesheet report now uses standard description formatting.
This commit is contained in:
parent
a300dba2df
commit
761ef296ad
4 changed files with 27 additions and 115 deletions
|
@ -33,7 +33,6 @@ set (task_SRCS A3.cpp A3.h
|
||||||
Uri.cpp Uri.h
|
Uri.cpp Uri.h
|
||||||
ViewTask.cpp ViewTask.h
|
ViewTask.cpp ViewTask.h
|
||||||
ViewText.cpp ViewText.h
|
ViewText.cpp ViewText.h
|
||||||
helpers.cpp
|
|
||||||
dependency.cpp
|
dependency.cpp
|
||||||
feedback.cpp
|
feedback.cpp
|
||||||
i18n.h
|
i18n.h
|
||||||
|
|
|
@ -127,7 +127,20 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
completed.set (row, 2, dt.toString (format));
|
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 <std::string, std::string> annotations;
|
||||||
|
task->getAnnotations (annotations);
|
||||||
|
std::map <std::string, std::string>::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, 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 <std::string, std::string> annotations;
|
||||||
|
task->getAnnotations (annotations);
|
||||||
|
std::map <std::string, std::string>::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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
109
src/helpers.cpp
109
src/helpers.cpp
|
@ -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 <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <Context.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include <Date.h>
|
|
||||||
#include <Duration.h>
|
|
||||||
#include <ViewText.h>
|
|
||||||
#include <text.h>
|
|
||||||
#include <util.h>
|
|
||||||
#include <i18n.h>
|
|
||||||
#include <main.h>
|
|
||||||
|
|
||||||
|
|
||||||
extern Context context;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
std::string getFullDescription (Task& task, const std::string& report)
|
|
||||||
{
|
|
||||||
std::string desc = task.get ("description");
|
|
||||||
std::string annotationDetails;
|
|
||||||
|
|
||||||
std::map <std::string, std::string> 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 <std::string, std::string>::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 <std::string, std::string>::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;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
|
@ -48,9 +48,6 @@ void updateRecurrenceMask (Task&);
|
||||||
int getDueState (const std::string&);
|
int getDueState (const std::string&);
|
||||||
bool nag (Task&);
|
bool nag (Task&);
|
||||||
|
|
||||||
// helpers.cpp
|
|
||||||
std::string getFullDescription (Task&, const std::string&);
|
|
||||||
|
|
||||||
// rules.cpp
|
// rules.cpp
|
||||||
void initializeColorRules ();
|
void initializeColorRules ();
|
||||||
void autoColorize (Task&, Color&);
|
void autoColorize (Task&, Color&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue