diff --git a/src/columns/CMakeLists.txt b/src/columns/CMakeLists.txt index d6b4a43d3..08e0968a7 100644 --- a/src/columns/CMakeLists.txt +++ b/src/columns/CMakeLists.txt @@ -19,6 +19,7 @@ set (columns_SRCS Column.cpp Column.h ColStatus.cpp ColStatus.h ColTags.cpp ColTags.h ColUntil.cpp ColUntil.h + ColUrgency.cpp ColUrgency.h ColUUID.cpp ColUUID.h ColWait.cpp ColWait.h) diff --git a/src/columns/ColUrgency.cpp b/src/columns/ColUrgency.cpp new file mode 100644 index 000000000..71dd921b3 --- /dev/null +++ b/src/columns/ColUrgency.cpp @@ -0,0 +1,70 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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 +#include +#include + +extern Context context; + +//////////////////////////////////////////////////////////////////////////////// +ColumnUrgency::ColumnUrgency () +{ + _type = "number"; + _style = "default"; + _label = "Urgency"; +} + +//////////////////////////////////////////////////////////////////////////////// +ColumnUrgency::~ColumnUrgency () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the minimum and maximum widths for the value. +void ColumnUrgency::measure (Task& task, int& minimum, int& maximum) +{ + minimum = maximum = format (task.urgency (), 4, 3).length (); + + if (_style != "default") + throw std::string ("Unrecognized column format '") + _type + "." + _style + "'"; +} + +//////////////////////////////////////////////////////////////////////////////// +void ColumnUrgency::render ( + std::vector & lines, + Task& task, + int width, + Color& color) +{ + lines.push_back ( + color.colorize ( + rightJustify ( + format (task.urgency (), 4, 3), width))); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColUrgency.h b/src/columns/ColUrgency.h new file mode 100644 index 000000000..33b784c3c --- /dev/null +++ b/src/columns/ColUrgency.h @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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_COLURGENCY +#define INCLUDED_COLURGENCY + +#include +#include +#include +#include +#include + +class ColumnUrgency : public Column +{ +public: + ColumnUrgency (); + ~ColumnUrgency (); + + void measure (Task&, int&, int&); + void render (std::vector &, Task&, int, Color&); + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index f2547d510..6cfc799fe 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,7 @@ Column* Column::factory (const std::string& name) else if (column_name == "status") column = new ColumnStatus (); else if (column_name == "tags") column = new ColumnTags (); else if (column_name == "until") column = new ColumnUntil (); + else if (column_name == "urgency") column = new ColumnUrgency (); else if (column_name == "uuid") column = new ColumnUUID (); else if (column_name == "wait") column = new ColumnWait (); else diff --git a/test/view.t.cpp b/test/view.t.cpp index 6e7d02c4d..5eede7130 100644 --- a/test/view.t.cpp +++ b/test/view.t.cpp @@ -41,6 +41,7 @@ int main (int argc, char** argv) try { // Set up configuration. + context.config.setDefaults (); context.config.set ("fontunderline", true); context.config.set ("tag.indicator", "+"); context.config.set ("dependency.indicator", "D"); @@ -103,6 +104,7 @@ int main (int argc, char** argv) view.add (Column::factory ("due.julian")); // view.add (Column::factory ("due.epoch")); // view.add (Column::factory ("due.iso")); + view.add (Column::factory ("urgency")); view.width (120); view.leftMargin (4); /*