ColTemplate: New recurrence attribute

This commit is contained in:
Paul Beckingham 2016-12-31 08:47:47 -05:00
parent b600671e53
commit 5ac7ca6885
14 changed files with 159 additions and 0 deletions

View file

@ -24,6 +24,7 @@ set (columns_SRCS Column.cpp Column.h
ColStatus.cpp ColStatus.h
ColString.cpp ColString.h
ColTags.cpp ColTags.h
ColTemplate.cpp ColTemplate.h
ColTypeDate.cpp ColTypeDate.h
ColTypeDuration.cpp ColTypeDuration.h
ColTypeNumeric.cpp ColTypeNumeric.h

View file

@ -0,0 +1,78 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 <ColTemplate.h>
#include <format.h>
#include <i18n.h>
////////////////////////////////////////////////////////////////////////////////
ColumnTemplate::ColumnTemplate ()
{
_name = "template";
_style = "long";
_label = STRING_COLUMN_LABEL_TEMPLATE;
_modifiable = false;
_styles = {"long", "short"};
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"};
}
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnTemplate::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
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 ColumnTemplate::render (
std::vector <std::string>& lines,
Task& task,
int width,
Color& color)
{
if (task.has (_name))
{
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
// f30cb9c3 short
if (_style == "default" ||
_style == "long")
renderStringLeft (lines, width, color, task.get(_name));
else if (_style == "short")
renderStringLeft (lines, width, color, task.get (_name).substr (0, 8));
}
}
////////////////////////////////////////////////////////////////////////////////

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

View file

@ -46,6 +46,7 @@
#include <ColStatus.h>
#include <ColString.h>
#include <ColTags.h>
#include <ColTemplate.h>
#include <ColUntil.h>
#include <ColUrgency.h>
#include <ColUUID.h>
@ -96,6 +97,7 @@ Column* Column::factory (const std::string& name, const std::string& report)
else if (column_name == "start") c = new ColumnStart ();
else if (column_name == "status") c = new ColumnStatus ();
else if (column_name == "tags") c = new ColumnTags ();
else if (column_name == "template") c = new ColumnTemplate ();
else if (column_name == "until") c = new ColumnUntil ();
else if (column_name == "urgency") c = new ColumnUrgency ();
else if (column_name == "uuid") c = new ColumnUUID ();
@ -138,6 +140,7 @@ void Column::factory (std::map <std::string, Column*>& all)
c = new ColumnStart (); all[c->_name] = c;
c = new ColumnStatus (); all[c->_name] = c;
c = new ColumnTags (); all[c->_name] = c;
c = new ColumnTemplate (); all[c->_name] = c;
c = new ColumnUntil (); all[c->_name] = c;
c = new ColumnUrgency (); all[c->_name] = c;
c = new ColumnUUID (); all[c->_name] = c;

25
src/l10n/check_translations.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
REFERENCE_LANGUAGE_FILE="eng-USA.h"
TESTED_LANGUAGE_FILES=`ls *.h | grep -v $REFERENCE_LANGUAGE_FILE`
# At the beginning, we haven't detected any invalid translation files
MISMATCHED=0
# Generate list of keys, not including defines that are commented out. Strips out the leading whitespace.
cat $REFERENCE_LANGUAGE_FILE | grep "^[[:space:]]*#define" | sed -e 's/^ *//' - | cut -f2 -d' ' | sort > identifiers
# Generate report
for LANGUAGE_FILE in $TESTED_LANGUAGE_FILES
do
echo "Comparing $REFERENCE_LANGUAGE_FILE (left) to $LANGUAGE_FILE (right)"
cat $LANGUAGE_FILE | grep "^[[:space:]]*#define" | sed -e 's/^ *//' - | cut -f2 -d' ' | sort | diff identifiers -
MISMATCHED=$(($MISMATCHED+$?))
echo ""
done
# Cleanup
rm -f identifiers
# Exit with number of not synced translations files
exit $MISMATCHED

View file

@ -211,6 +211,7 @@
#define STRING_COLUMN_LABEL_MASK "Maske"
#define STRING_COLUMN_LABEL_MASK_IDX "Masken-Index"
#define STRING_COLUMN_LABEL_PARENT "Vorgänger-Aufgabe"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Datum"
#define STRING_COLUMN_LABEL_COLUMN "Spalten"
#define STRING_COLUMN_LABEL_STYLES "Unterstützte Formate"

View file

@ -211,6 +211,7 @@
#define STRING_COLUMN_LABEL_MASK "Mask"
#define STRING_COLUMN_LABEL_MASK_IDX "Mask Index"
#define STRING_COLUMN_LABEL_PARENT "Parent task"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"
#define STRING_COLUMN_LABEL_COLUMN "Columns"
#define STRING_COLUMN_LABEL_STYLES "Supported Formats"

View file

@ -211,6 +211,7 @@
#define STRING_COLUMN_LABEL_MASK "Masko"
#define STRING_COLUMN_LABEL_MASK_IDX "Mask-indico"
#define STRING_COLUMN_LABEL_PARENT "Patra tasko"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Dato"
#define STRING_COLUMN_LABEL_COLUMN "Kolumnoj"
#define STRING_COLUMN_LABEL_STYLES "Formaĝoj Subtenataj"

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_PARENT "Tarea madre"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Fecha"
#define STRING_COLUMN_LABEL_COLUMN "Columnas"
#define STRING_COLUMN_LABEL_STYLES "Formatos soportados"

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_PARENT "Tâche mère"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"
#define STRING_COLUMN_LABEL_COLUMN "Colonnes"
#define STRING_COLUMN_LABEL_STYLES "Formats supportés"

View file

@ -211,6 +211,7 @@
#define STRING_COLUMN_LABEL_MASK "Maschera"
#define STRING_COLUMN_LABEL_MASK_IDX "Indice Maschera"
#define STRING_COLUMN_LABEL_PARENT "Task genitore"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"
#define STRING_COLUMN_LABEL_COLUMN "Colonna"
#define STRING_COLUMN_LABEL_STYLES "Formati Supportati"

View file

@ -211,6 +211,7 @@
#define STRING_COLUMN_LABEL_MASK "Mask"
#define STRING_COLUMN_LABEL_MASK_IDX "Mask Index"
#define STRING_COLUMN_LABEL_PARENT "Parent task"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Date"
#define STRING_COLUMN_LABEL_COLUMN "Columns"
#define STRING_COLUMN_LABEL_STYLES "Supported Formats"

View file

@ -211,6 +211,7 @@
#define STRING_COLUMN_LABEL_MASK "Maska"
#define STRING_COLUMN_LABEL_MASK_IDX "Indeks Maski"
#define STRING_COLUMN_LABEL_PARENT "Zadanie rodzic"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"
#define STRING_COLUMN_LABEL_COLUMN "Kolumny"
#define STRING_COLUMN_LABEL_STYLES "Formaty"

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_PARENT "Tarefa mãe"
#define STRING_COLUMN_LABEL_TEMPLATE "Template task"
#define STRING_COLUMN_LABEL_DATE "Data"
#define STRING_COLUMN_LABEL_COLUMN "Colunas"
#define STRING_COLUMN_LABEL_STYLES "Formatos Suportados"