mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
View
- Implemented urgency.default.
This commit is contained in:
parent
7e1f8591f6
commit
b4be5991b8
5 changed files with 124 additions and 0 deletions
|
@ -19,6 +19,7 @@ set (columns_SRCS Column.cpp Column.h
|
||||||
ColStatus.cpp ColStatus.h
|
ColStatus.cpp ColStatus.h
|
||||||
ColTags.cpp ColTags.h
|
ColTags.cpp ColTags.h
|
||||||
ColUntil.cpp ColUntil.h
|
ColUntil.cpp ColUntil.h
|
||||||
|
ColUrgency.cpp ColUrgency.h
|
||||||
ColUUID.cpp ColUUID.h
|
ColUUID.cpp ColUUID.h
|
||||||
ColWait.cpp ColWait.h)
|
ColWait.cpp ColWait.h)
|
||||||
|
|
||||||
|
|
70
src/columns/ColUrgency.cpp
Normal file
70
src/columns/ColUrgency.cpp
Normal file
|
@ -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 <Context.h>
|
||||||
|
#include <ColUrgency.h>
|
||||||
|
#include <text.h>
|
||||||
|
|
||||||
|
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 <std::string>& lines,
|
||||||
|
Task& task,
|
||||||
|
int width,
|
||||||
|
Color& color)
|
||||||
|
{
|
||||||
|
lines.push_back (
|
||||||
|
color.colorize (
|
||||||
|
rightJustify (
|
||||||
|
format (task.urgency (), 4, 3), width)));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
49
src/columns/ColUrgency.h
Normal file
49
src/columns/ColUrgency.h
Normal file
|
@ -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 <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <Column.h>
|
||||||
|
#include <Color.h>
|
||||||
|
#include <Task.h>
|
||||||
|
|
||||||
|
class ColumnUrgency : public Column
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ColumnUrgency ();
|
||||||
|
~ColumnUrgency ();
|
||||||
|
|
||||||
|
void measure (Task&, int&, int&);
|
||||||
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
|
@ -40,6 +40,7 @@
|
||||||
#include <ColStatus.h>
|
#include <ColStatus.h>
|
||||||
#include <ColTags.h>
|
#include <ColTags.h>
|
||||||
#include <ColUntil.h>
|
#include <ColUntil.h>
|
||||||
|
#include <ColUrgency.h>
|
||||||
#include <ColUUID.h>
|
#include <ColUUID.h>
|
||||||
#include <ColWait.h>
|
#include <ColWait.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
@ -82,6 +83,7 @@ Column* Column::factory (const std::string& name)
|
||||||
else if (column_name == "status") column = new ColumnStatus ();
|
else if (column_name == "status") column = new ColumnStatus ();
|
||||||
else if (column_name == "tags") column = new ColumnTags ();
|
else if (column_name == "tags") column = new ColumnTags ();
|
||||||
else if (column_name == "until") column = new ColumnUntil ();
|
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 == "uuid") column = new ColumnUUID ();
|
||||||
else if (column_name == "wait") column = new ColumnWait ();
|
else if (column_name == "wait") column = new ColumnWait ();
|
||||||
else
|
else
|
||||||
|
|
|
@ -41,6 +41,7 @@ int main (int argc, char** argv)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Set up configuration.
|
// Set up configuration.
|
||||||
|
context.config.setDefaults ();
|
||||||
context.config.set ("fontunderline", true);
|
context.config.set ("fontunderline", true);
|
||||||
context.config.set ("tag.indicator", "+");
|
context.config.set ("tag.indicator", "+");
|
||||||
context.config.set ("dependency.indicator", "D");
|
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.julian"));
|
||||||
// view.add (Column::factory ("due.epoch"));
|
// view.add (Column::factory ("due.epoch"));
|
||||||
// view.add (Column::factory ("due.iso"));
|
// view.add (Column::factory ("due.iso"));
|
||||||
|
view.add (Column::factory ("urgency"));
|
||||||
view.width (120);
|
view.width (120);
|
||||||
view.leftMargin (4);
|
view.leftMargin (4);
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue