ColLast: New recurrence attribute

This commit is contained in:
Paul Beckingham 2016-12-31 09:01:21 -05:00
parent 5ac7ca6885
commit aedf99a827
13 changed files with 126 additions and 0 deletions

View file

@ -14,6 +14,7 @@ set (columns_SRCS Column.cpp Column.h
ColEntry.cpp ColEntry.h
ColID.cpp ColID.h
ColIMask.cpp ColIMask.h
ColLast.cpp ColLast.h
ColMask.cpp ColMask.h
ColModified.cpp ColModified.h
ColParent.cpp ColParent.h

70
src/columns/ColLast.cpp Normal file
View file

@ -0,0 +1,70 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// http://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#include <cmake.h>
#include <ColLast.h>
#include <format.h>
#include <i18n.h>
////////////////////////////////////////////////////////////////////////////////
ColumnLast::ColumnLast ()
{
_name = "imask";
_style = "number";
_label = STRING_COLUMN_LABEL_LAST;
_modifiable = false;
_styles = {"number"};
_examples = {"12"};
}
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnLast::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
minimum = maximum = task.get ("imask").length ();
if (_style != "default" &&
_style != "number")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
void ColumnLast::render (
std::vector <std::string>& lines,
Task& task,
int width,
Color& color)
{
if (task.has (_name))
renderStringRight (lines, width, color, task.get ("imask"));
}
////////////////////////////////////////////////////////////////////////////////

43
src/columns/ColLast.h Normal file
View file

@ -0,0 +1,43 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// http://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_COLLAST
#define INCLUDED_COLLAST
#include <ColTypeNumeric.h>
class ColumnLast : public ColumnTypeNumeric
{
public:
ColumnLast ();
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:
};
#endif
////////////////////////////////////////////////////////////////////////////////

View file

@ -36,6 +36,7 @@
#include <ColEntry.h>
#include <ColID.h>
#include <ColIMask.h>
#include <ColLast.h>
#include <ColMask.h>
#include <ColModified.h>
#include <ColParent.h>
@ -88,6 +89,7 @@ Column* Column::factory (const std::string& name, const std::string& report)
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 == "last") c = new ColumnLast ();
else if (column_name == "mask") c = new ColumnMask ();
else if (column_name == "modified") c = new ColumnModified ();
else if (column_name == "parent") c = new ColumnParent ();
@ -131,6 +133,7 @@ void Column::factory (std::map <std::string, Column*>& all)
c = new ColumnEntry (); all[c->_name] = c;
c = new ColumnID (); all[c->_name] = c;
c = new ColumnIMask (); all[c->_name] = c;
c = new ColumnLast (); all[c->_name] = c;
c = new ColumnMask (); all[c->_name] = c;
c = new ColumnModified (); all[c->_name] = c;
c = new ColumnParent (); all[c->_name] = c;

View file

@ -210,6 +210,7 @@
#define STRING_COLUMN_LABEL_VALUE "Wert"
#define STRING_COLUMN_LABEL_MASK "Maske"
#define STRING_COLUMN_LABEL_MASK_IDX "Masken-Index"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Vorgänger-Aufgabe"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Datum"

View file

@ -210,6 +210,7 @@
#define STRING_COLUMN_LABEL_VALUE "Value"
#define STRING_COLUMN_LABEL_MASK "Mask"
#define STRING_COLUMN_LABEL_MASK_IDX "Mask Index"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Parent task"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"

View file

@ -210,6 +210,7 @@
#define STRING_COLUMN_LABEL_VALUE "Valoro"
#define STRING_COLUMN_LABEL_MASK "Masko"
#define STRING_COLUMN_LABEL_MASK_IDX "Mask-indico"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Patra tasko"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Dato"

View file

@ -211,6 +211,7 @@
#define STRING_COLUMN_LABEL_VALUE "Valor"
#define STRING_COLUMN_LABEL_MASK "Máscara"
#define STRING_COLUMN_LABEL_MASK_IDX "Máscara de Índice"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Tarea madre"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Fecha"

View file

@ -210,6 +210,7 @@
#define STRING_COLUMN_LABEL_VALUE "Valeur"
#define STRING_COLUMN_LABEL_MASK "Masque"
#define STRING_COLUMN_LABEL_MASK_IDX "Indice de masque"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Tâche mère"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"

View file

@ -210,6 +210,7 @@
#define STRING_COLUMN_LABEL_VALUE "Valore"
#define STRING_COLUMN_LABEL_MASK "Maschera"
#define STRING_COLUMN_LABEL_MASK_IDX "Indice Maschera"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Task genitore"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"

View file

@ -210,6 +210,7 @@
#define STRING_COLUMN_LABEL_VALUE "Value"
#define STRING_COLUMN_LABEL_MASK "Mask"
#define STRING_COLUMN_LABEL_MASK_IDX "Mask Index"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Parent task"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"

View file

@ -210,6 +210,7 @@
#define STRING_COLUMN_LABEL_VALUE "Wartość"
#define STRING_COLUMN_LABEL_MASK "Maska"
#define STRING_COLUMN_LABEL_MASK_IDX "Indeks Maski"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Zadanie rodzic"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"

View file

@ -211,6 +211,7 @@
#define STRING_COLUMN_LABEL_VALUE "Valor"
#define STRING_COLUMN_LABEL_MASK "Máscara"
#define STRING_COLUMN_LABEL_MASK_IDX "Índice de Máscara"
#define STRING_COLUMN_LABEL_LAST "Last instance"
#define STRING_COLUMN_LABEL_PARENT "Tarefa mãe"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"