mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
View
- Implemented status.default, status.short.
This commit is contained in:
parent
1506ee67f4
commit
5e851c4c98
5 changed files with 173 additions and 1 deletions
|
@ -11,6 +11,7 @@ set (columns_SRCS Column.cpp Column.h
|
|||
ColPriority.cpp ColPriority.h
|
||||
ColProject.cpp ColProject.h
|
||||
ColRecur.cpp ColRecur.h
|
||||
ColStatus.cpp ColStatus.h
|
||||
ColTags.cpp ColTags.h
|
||||
ColUUID.cpp ColUUID.h)
|
||||
|
||||
|
|
115
src/columns/ColStatus.cpp
Normal file
115
src/columns/ColStatus.cpp
Normal file
|
@ -0,0 +1,115 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <ColStatus.h>
|
||||
#include <text.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnStatus::ColumnStatus ()
|
||||
{
|
||||
_type = "string";
|
||||
_style = "default";
|
||||
_label = "Status";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnStatus::~ColumnStatus ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnStatus::setStyle (const std::string& value)
|
||||
{
|
||||
_style = value;
|
||||
|
||||
if (_style == "short" && _label == "Status")
|
||||
_label = "St";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnStatus::measure (Task& task, int& minimum, int& maximum)
|
||||
{
|
||||
Task::status status = task.getStatus ();
|
||||
|
||||
if (_style == "default")
|
||||
{
|
||||
if (status == Task::pending ||
|
||||
status == Task::deleted ||
|
||||
status == Task::waiting)
|
||||
{
|
||||
minimum = maximum = 7;
|
||||
}
|
||||
else if (status == Task::completed ||
|
||||
status == Task::recurring)
|
||||
{
|
||||
minimum = maximum = 9;
|
||||
}
|
||||
}
|
||||
else if (_style == "short")
|
||||
minimum = maximum = 1;
|
||||
else
|
||||
throw std::string ("Unrecognized column format '") + _type + "." + _style + "'";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnStatus::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
Task::status status = task.getStatus ();
|
||||
std::string value;
|
||||
|
||||
if (_style == "default")
|
||||
{
|
||||
if (status == Task::pending) value = "Pending";
|
||||
else if (status == Task::completed) value = "Completed";
|
||||
else if (status == Task::deleted) value = "Deleted";
|
||||
else if (status == Task::waiting) value = "Waiting";
|
||||
else if (status == Task::recurring) value = "Recurring";
|
||||
}
|
||||
|
||||
else if (_style == "short")
|
||||
{
|
||||
if (status == Task::pending) value = "P";
|
||||
else if (status == Task::completed) value = "C";
|
||||
else if (status == Task::deleted) value = "D";
|
||||
else if (status == Task::waiting) value = "W";
|
||||
else if (status == Task::recurring) value = "R";
|
||||
}
|
||||
|
||||
lines.push_back (color.colorize (leftJustify (value, width)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
50
src/columns/ColStatus.h
Normal file
50
src/columns/ColStatus.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_COLSTATUS
|
||||
#define INCLUDED_COLSTATUS
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Column.h>
|
||||
#include <Color.h>
|
||||
#include <Task.h>
|
||||
|
||||
class ColumnStatus : public Column
|
||||
{
|
||||
public:
|
||||
ColumnStatus ();
|
||||
~ColumnStatus ();
|
||||
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -37,6 +37,7 @@
|
|||
#include <ColProject.h>
|
||||
#include <ColRecur.h>
|
||||
//#include <ColStart.h>
|
||||
#include <ColStatus.h>
|
||||
#include <ColTags.h>
|
||||
//#include <ColUntil.h>
|
||||
#include <ColUUID.h>
|
||||
|
@ -78,6 +79,7 @@ Column* Column::factory (const std::string& name)
|
|||
else if (column_name == "project") column = new ColumnProject ();
|
||||
else if (column_name == "recur") column = new ColumnRecur ();
|
||||
// else if (column_name == "start") column = new ColumnStart ();
|
||||
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 == "uuid") column = new ColumnUUID ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue