diff --git a/src/columns/CMakeLists.txt b/src/columns/CMakeLists.txt index 9f1b29ac9..91d7ee6a2 100644 --- a/src/columns/CMakeLists.txt +++ b/src/columns/CMakeLists.txt @@ -13,6 +13,9 @@ set (columns_SRCS Column.cpp Column.h ColEnd.cpp ColEnd.h ColEntry.cpp ColEntry.h ColID.cpp ColID.h + ColIMask.cpp ColIMask.h + ColMask.cpp ColMask.h + ColParent.cpp ColParent.h ColPriority.cpp ColPriority.h ColProject.cpp ColProject.h ColRecur.cpp ColRecur.h diff --git a/src/columns/ColIMask.cpp b/src/columns/ColIMask.cpp new file mode 100644 index 000000000..418043f23 --- /dev/null +++ b/src/columns/ColIMask.cpp @@ -0,0 +1,84 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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 +// +//////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + +#include +#include +#include +#include +#include + +extern Context context; + +//////////////////////////////////////////////////////////////////////////////// +ColumnIMask::ColumnIMask () +{ + _name = "imask"; + _type = "number"; + _style = "number"; + _label = STRING_COLUMN_LABEL_MASK_IDX; + _modifiable = false; + + _styles.push_back ("number"); + + _examples.push_back ("12"); +} + +//////////////////////////////////////////////////////////////////////////////// +ColumnIMask::~ColumnIMask () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +bool ColumnIMask::validate (std::string& value) +{ + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the minimum and maximum widths for the value. +void ColumnIMask::measure (Task& task, int& minimum, int& maximum) +{ + minimum = maximum = task.get ("imask").length (); + + if (_style != "default" && + _style != "number") + throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); +} + +//////////////////////////////////////////////////////////////////////////////// +void ColumnIMask::render ( + std::vector & lines, + Task& task, + int width, + Color& color) +{ + lines.push_back (color.colorize (rightJustify (task.get ("imask"), width))); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColIMask.h b/src/columns/ColIMask.h new file mode 100644 index 000000000..b3fb7dd72 --- /dev/null +++ b/src/columns/ColIMask.h @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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_COLIMASK +#define INCLUDED_COLIMASK +#define L10N // Localization complete. + +#include +#include +#include +#include +#include + +class ColumnIMask : public Column +{ +public: + ColumnIMask (); + ~ColumnIMask (); + + bool validate (std::string&); + void measure (Task&, int&, int&); + void render (std::vector &, Task&, int, Color&); + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColMask.cpp b/src/columns/ColMask.cpp new file mode 100644 index 000000000..10ea388c4 --- /dev/null +++ b/src/columns/ColMask.cpp @@ -0,0 +1,83 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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 +// +//////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + +#include +#include +#include +#include +#include + +extern Context context; + +//////////////////////////////////////////////////////////////////////////////// +ColumnMask::ColumnMask () +{ + _name = "mask"; + _type = "string"; + _style = "default"; + _label = STRING_COLUMN_LABEL_MASK; + _modifiable = false; + + _styles.push_back ("default"); + + _examples.push_back ("++++---"); +} + +//////////////////////////////////////////////////////////////////////////////// +ColumnMask::~ColumnMask () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +bool ColumnMask::validate (std::string& value) +{ + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the minimum and maximum widths for the value. +void ColumnMask::measure (Task& task, int& minimum, int& maximum) +{ + minimum = maximum = task.get ("mask").length (); + + if (_style != "default") + throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); +} + +//////////////////////////////////////////////////////////////////////////////// +void ColumnMask::render ( + std::vector & lines, + Task& task, + int width, + Color& color) +{ + lines.push_back (color.colorize (task.get ("mask"))); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColMask.h b/src/columns/ColMask.h new file mode 100644 index 000000000..961fb1d83 --- /dev/null +++ b/src/columns/ColMask.h @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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_COLMASK +#define INCLUDED_COLMASK +#define L10N // Localization complete. + +#include +#include +#include +#include +#include + +class ColumnMask : public Column +{ +public: + ColumnMask (); + ~ColumnMask (); + + bool validate (std::string&); + void measure (Task&, int&, int&); + void render (std::vector &, Task&, int, Color&); + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColParent.cpp b/src/columns/ColParent.cpp new file mode 100644 index 000000000..0d41ec2ad --- /dev/null +++ b/src/columns/ColParent.cpp @@ -0,0 +1,92 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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 +// +//////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + +#include +#include +#include +#include +#include + +extern Context context; + +//////////////////////////////////////////////////////////////////////////////// +ColumnParent::ColumnParent () +{ + _name = "parent"; + _type = "string"; + _style = "long"; + _label = STRING_COLUMN_LABEL_PARENT; + _modifiable = false; + + _styles.push_back ("long"); + _styles.push_back ("short"); + + _examples.push_back ("f30cb9c3-3fc0-483f-bfb2-3bf134f00694"); + _examples.push_back ("34f00694"); +} + +//////////////////////////////////////////////////////////////////////////////// +ColumnParent::~ColumnParent () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +bool ColumnParent::validate (std::string& value) +{ + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set the minimum and maximum widths for the value. +void ColumnParent::measure (Task&, int& minimum, int& maximum) +{ + if (_style == "default" || _style == "long") minimum = maximum = 36; + else if (_style == "short") minimum = maximum = 8; + else + throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); +} + +//////////////////////////////////////////////////////////////////////////////// +void ColumnParent::render ( + std::vector & lines, + Task& task, + int width, + Color& color) +{ + // f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default + // 34f00694 short + if (_style == "default" || + _style == "long") + lines.push_back (color.colorize (leftJustify (task.get (_name), width))); + + else if (_style == "short") + lines.push_back (color.colorize (leftJustify (task.get (_name).substr (28), width))); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColParent.h b/src/columns/ColParent.h new file mode 100644 index 000000000..90548d285 --- /dev/null +++ b/src/columns/ColParent.h @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// 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_COLPARENT +#define INCLUDED_COLPARENT +#define L10N // Localization complete. + +#include +#include +#include +#include +#include + +class ColumnParent : public Column +{ +public: + ColumnParent (); + ~ColumnParent (); + + bool validate (std::string&); + 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 b1e656cb7..bd9e83dfc 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -35,6 +35,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -80,6 +83,9 @@ Column* Column::factory (const std::string& name, const std::string& report) else if (column_name == "end") c = new ColumnEnd (); else if (column_name == "entry") c = new ColumnEntry (); else if (column_name == "id") c = new ColumnID (); + else if (column_name == "imask") c = new ColumnIMask (); + else if (column_name == "mask") c = new ColumnMask (); + else if (column_name == "parent") c = new ColumnParent (); else if (column_name == "priority") c = new ColumnPriority (); else if (column_name == "project") c = new ColumnProject (); else if (column_name == "recur") c = new ColumnRecur (); @@ -113,6 +119,9 @@ void Column::factory (std::map & all) c = new ColumnEnd (); all[c->_name] = c; c = new ColumnEntry (); all[c->_name] = c; c = new ColumnID (); all[c->_name] = c; + c = new ColumnIMask (); all[c->_name] = c; + c = new ColumnMask (); all[c->_name] = c; + c = new ColumnParent (); all[c->_name] = c; c = new ColumnPriority (); all[c->_name] = c; c = new ColumnProject (); all[c->_name] = c; c = new ColumnRecur (); all[c->_name] = c; diff --git a/src/commands/CmdImport.cpp b/src/commands/CmdImport.cpp index bc028d068..d65c3bafd 100644 --- a/src/commands/CmdImport.cpp +++ b/src/commands/CmdImport.cpp @@ -157,14 +157,6 @@ int CmdImport::execute (std::string& output) task.setAnnotations (annos); } - // These must be imported, but are not represented by Column - // objects. - else if (i->first == "mask" || - i->first == "imask" || - i->first == "parent") - { - task.set (i->first, unquoteText (i->second->dump ())); - } else throw std::string ("Unrecognized attribute '") + i->first + "'"; }