ColRType: New recurrence attribute

This commit is contained in:
Paul Beckingham 2016-12-31 09:09:29 -05:00
parent aedf99a827
commit 76c2de685b
13 changed files with 124 additions and 0 deletions

View file

@ -20,6 +20,7 @@ set (columns_SRCS Column.cpp Column.h
ColParent.cpp ColParent.h
ColProject.cpp ColProject.h
ColRecur.cpp ColRecur.h
ColRType.cpp ColRType.h
ColScheduled.cpp ColScheduled.h
ColStart.cpp ColStart.h
ColStatus.cpp ColStatus.h

68
src/columns/ColRType.cpp Normal file
View file

@ -0,0 +1,68 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 <ColRType.h>
#include <format.h>
#include <i18n.h>
////////////////////////////////////////////////////////////////////////////////
ColumnRType::ColumnRType ()
{
_name = "rtype";
_style = "default";
_label = STRING_COLUMN_LABEL_RTYPE;
_modifiable = false;
_styles = {"default"};
_examples = {"periodic", "chained"};
}
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnRType::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
minimum = maximum = task.get (_name).length ();
if (_style != "default")
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
}
////////////////////////////////////////////////////////////////////////////////
void ColumnRType::render (
std::vector <std::string>& lines,
Task& task,
int width,
Color& color)
{
if (task.has (_name))
renderStringLeft (lines, width, color, task.get (_name));
}
////////////////////////////////////////////////////////////////////////////////

43
src/columns/ColRType.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_COLRTYPE
#define INCLUDED_COLRTYPE
#include <ColTypeString.h>
class ColumnRType : public ColumnTypeString
{
public:
ColumnRType ();
void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&);
private:
};
#endif
////////////////////////////////////////////////////////////////////////////////

View file

@ -42,6 +42,7 @@
#include <ColParent.h>
#include <ColProject.h>
#include <ColRecur.h>
#include <ColRType.h>
#include <ColScheduled.h>
#include <ColStart.h>
#include <ColStatus.h>
@ -95,6 +96,7 @@ Column* Column::factory (const std::string& name, const std::string& report)
else if (column_name == "parent") c = new ColumnParent ();
else if (column_name == "project") c = new ColumnProject ();
else if (column_name == "recur") c = new ColumnRecur ();
else if (column_name == "rtype") c = new ColumnRType ();
else if (column_name == "scheduled") c = new ColumnScheduled ();
else if (column_name == "start") c = new ColumnStart ();
else if (column_name == "status") c = new ColumnStatus ();
@ -139,6 +141,7 @@ void Column::factory (std::map <std::string, Column*>& all)
c = new ColumnParent (); all[c->_name] = c;
c = new ColumnProject (); all[c->_name] = c;
c = new ColumnRecur (); all[c->_name] = c;
c = new ColumnRType (); all[c->_name] = c;
c = new ColumnScheduled (); all[c->_name] = c;
c = new ColumnStart (); all[c->_name] = c;
c = new ColumnStatus (); all[c->_name] = c;

View file

@ -211,6 +211,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Vorgänger-Aufgabe"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Datum"

View file

@ -211,6 +211,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Parent task"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"

View file

@ -211,6 +211,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Patra tasko"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Dato"

View file

@ -212,6 +212,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Tarea madre"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Fecha"

View file

@ -211,6 +211,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Tâche mère"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"

View file

@ -211,6 +211,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Task genitore"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"

View file

@ -211,6 +211,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Parent task"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"

View file

@ -211,6 +211,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Zadanie rodzic"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"

View file

@ -212,6 +212,7 @@
#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_RTYPE "Recurrence type"
#define STRING_COLUMN_LABEL_PARENT "Tarefa mãe"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"