mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
View
- Implemented recur.default and recur.indicator.
This commit is contained in:
parent
a033300a7d
commit
0b3281d01d
5 changed files with 176 additions and 5 deletions
|
@ -10,6 +10,7 @@ set (columns_SRCS Column.cpp Column.h
|
|||
ColID.cpp ColID.h
|
||||
ColPriority.cpp ColPriority.h
|
||||
ColProject.cpp ColProject.h
|
||||
ColRecur.cpp ColRecur.h
|
||||
ColTags.cpp ColTags.h
|
||||
ColUUID.cpp ColUUID.h)
|
||||
|
||||
|
|
113
src/columns/ColRecur.cpp
Normal file
113
src/columns/ColRecur.cpp
Normal file
|
@ -0,0 +1,113 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <Context.h>
|
||||
#include <Nibbler.h>
|
||||
#include <ColRecur.h>
|
||||
#include <text.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnRecur::ColumnRecur ()
|
||||
{
|
||||
_type = "string";
|
||||
_style = "default";
|
||||
_label = "Recur";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnRecur::~ColumnRecur ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnRecur::setStyle (const std::string& value)
|
||||
{
|
||||
_style = value;
|
||||
|
||||
if (_style == "indicator" && _label == "Recur")
|
||||
_label = _label.substr (0, context.config.get ("recurrence.indicator").length ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnRecur::measure (Task& task, int& minimum, int& maximum)
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
minimum = maximum = task.get ("recur").length ();
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has ("recur"))
|
||||
minimum = maximum = context.config.get ("recurrence.indicator").length ();
|
||||
}
|
||||
else
|
||||
throw std::string ("Unrecognized column format '") + _type + "." + _style + "'";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnRecur::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
lines.push_back (color.colorize (rightJustify (task.get ("recur"), width)));
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has ("recur"))
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (context.config.get ("recurrence.indicator").length (), width)));
|
||||
}
|
||||
|
||||
/*
|
||||
std::string project = task.get ("project");
|
||||
if (_style == "parent")
|
||||
{
|
||||
std::string::size_type period = project.find ('.');
|
||||
if (period != std::string::npos)
|
||||
project = project.substr (0, period);
|
||||
}
|
||||
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, project, width);
|
||||
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = raw.begin (); i != raw.end (); ++i)
|
||||
lines.push_back (color.colorize (leftJustify (*i, width)));
|
||||
*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
50
src/columns/ColRecur.h
Normal file
50
src/columns/ColRecur.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_COLRECUR
|
||||
#define INCLUDED_COLRECUR
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Column.h>
|
||||
#include <Color.h>
|
||||
#include <Task.h>
|
||||
|
||||
class ColumnRecur : public Column
|
||||
{
|
||||
public:
|
||||
ColumnRecur ();
|
||||
~ColumnRecur ();
|
||||
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -35,10 +35,10 @@
|
|||
#include <ColID.h>
|
||||
#include <ColPriority.h>
|
||||
#include <ColProject.h>
|
||||
//#include <ColRecur.h>
|
||||
#include <ColRecur.h>
|
||||
//#include <ColStart.h>
|
||||
#include <ColTags.h>
|
||||
//#include <ColUntilDepends.h>
|
||||
//#include <ColUntil.h>
|
||||
#include <ColUUID.h>
|
||||
//#include <ColWait.h>
|
||||
#include <text.h>
|
||||
|
@ -46,9 +46,9 @@
|
|||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO Supports the new complete column definition:
|
||||
// Supports the new complete column definition:
|
||||
//
|
||||
// <type>[.<format>][.<key>[.<direction>][.<break>]]
|
||||
// <type>[.<format>]
|
||||
//
|
||||
Column* Column::factory (const std::string& name)
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ Column* Column::factory (const std::string& name)
|
|||
else if (column_name == "id") column = new ColumnID ();
|
||||
else if (column_name == "priority") column = new ColumnPriority ();
|
||||
else if (column_name == "project") column = new ColumnProject ();
|
||||
// else if (column_name == "recur") column = new ColumnRecur ();
|
||||
else if (column_name == "recur") column = new ColumnRecur ();
|
||||
// else if (column_name == "start") column = new ColumnStart ();
|
||||
else if (column_name == "tags") column = new ColumnTags ();
|
||||
// else if (column_name == "until") column = new ColumnUntil ();
|
||||
|
|
|
@ -43,6 +43,8 @@ int main (int argc, char** argv)
|
|||
// Set up configuration.
|
||||
context.config.set ("fontunderline", true);
|
||||
context.config.set ("tag.indicator", "+");
|
||||
context.config.set ("dependency.indicator", "D");
|
||||
context.config.set ("recurrence.indicator", "R");
|
||||
|
||||
// Two sample tasks.
|
||||
Task t1 ("["
|
||||
|
@ -57,6 +59,7 @@ int main (int argc, char** argv)
|
|||
"uuid:\"f30cb9c3-3fc0-483f-bfb2-3bf134f00694\" "
|
||||
"description:\"This is the description text\" "
|
||||
"project:\"Garden Care\" "
|
||||
"recur:\"monthly\" "
|
||||
"depends:\"2a64f6e0-bf8e-430d-bf71-9ec3f0d9b661\""
|
||||
"]");
|
||||
t2.id = 11;
|
||||
|
@ -86,6 +89,10 @@ int main (int argc, char** argv)
|
|||
view.add (Column::factory ("tags.count"));
|
||||
view.add (Column::factory ("description.truncated"));
|
||||
view.add (Column::factory ("depends"));
|
||||
view.add (Column::factory ("depends.count"));
|
||||
view.add (Column::factory ("depends.indicator"));
|
||||
view.add (Column::factory ("recur"));
|
||||
view.add (Column::factory ("recur.indicator"));
|
||||
view.width (100);
|
||||
view.leftMargin (4);
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue