From 5ac7ca6885c458d363a83e10bacae0f81e5d087b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 08:47:47 -0500 Subject: [PATCH 01/44] ColTemplate: New recurrence attribute --- src/columns/CMakeLists.txt | 1 + src/columns/ColTemplate.cpp | 78 ++++++++++++++++++++++++++++++++++ src/columns/ColTemplate.h | 43 +++++++++++++++++++ src/columns/Column.cpp | 3 ++ src/l10n/check_translations.sh | 25 +++++++++++ src/l10n/deu-DEU.h | 1 + src/l10n/eng-USA.h | 1 + src/l10n/epo-RUS.h | 1 + src/l10n/esp-ESP.h | 1 + src/l10n/fra-FRA.h | 1 + src/l10n/ita-ITA.h | 1 + src/l10n/jpn-JPN.h | 1 + src/l10n/pol-POL.h | 1 + src/l10n/por-PRT.h | 1 + 14 files changed, 159 insertions(+) create mode 100644 src/columns/ColTemplate.cpp create mode 100644 src/columns/ColTemplate.h create mode 100755 src/l10n/check_translations.sh diff --git a/src/columns/CMakeLists.txt b/src/columns/CMakeLists.txt index 0bfffc941..f73e1afc5 100644 --- a/src/columns/CMakeLists.txt +++ b/src/columns/CMakeLists.txt @@ -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 diff --git a/src/columns/ColTemplate.cpp b/src/columns/ColTemplate.cpp new file mode 100644 index 000000000..f9168525f --- /dev/null +++ b/src/columns/ColTemplate.cpp @@ -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 +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +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 & 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)); + } +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColTemplate.h b/src/columns/ColTemplate.h new file mode 100644 index 000000000..956b3ce2d --- /dev/null +++ b/src/columns/ColTemplate.h @@ -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 + +class ColumnTemplate : public ColumnTypeString +{ +public: + ColumnTemplate (); + void measure (Task&, unsigned int&, unsigned int&); + void render (std::vector &, Task&, int, Color&); + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index 75e4e6bd5..b3eee6b5f 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -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 & 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; diff --git a/src/l10n/check_translations.sh b/src/l10n/check_translations.sh new file mode 100755 index 000000000..2f4b59119 --- /dev/null +++ b/src/l10n/check_translations.sh @@ -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 diff --git a/src/l10n/deu-DEU.h b/src/l10n/deu-DEU.h index aae7aea89..39b597b6a 100644 --- a/src/l10n/deu-DEU.h +++ b/src/l10n/deu-DEU.h @@ -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" diff --git a/src/l10n/eng-USA.h b/src/l10n/eng-USA.h index c0e477f1a..83539cafb 100644 --- a/src/l10n/eng-USA.h +++ b/src/l10n/eng-USA.h @@ -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" diff --git a/src/l10n/epo-RUS.h b/src/l10n/epo-RUS.h index fd6fa3785..a527f0946 100644 --- a/src/l10n/epo-RUS.h +++ b/src/l10n/epo-RUS.h @@ -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" diff --git a/src/l10n/esp-ESP.h b/src/l10n/esp-ESP.h index 1e612e9b5..ad642d0b7 100644 --- a/src/l10n/esp-ESP.h +++ b/src/l10n/esp-ESP.h @@ -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" diff --git a/src/l10n/fra-FRA.h b/src/l10n/fra-FRA.h index 2ca31651e..93c845d45 100644 --- a/src/l10n/fra-FRA.h +++ b/src/l10n/fra-FRA.h @@ -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" diff --git a/src/l10n/ita-ITA.h b/src/l10n/ita-ITA.h index 768d14001..f36a4b32b 100644 --- a/src/l10n/ita-ITA.h +++ b/src/l10n/ita-ITA.h @@ -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" diff --git a/src/l10n/jpn-JPN.h b/src/l10n/jpn-JPN.h index 42a41b724..593440521 100644 --- a/src/l10n/jpn-JPN.h +++ b/src/l10n/jpn-JPN.h @@ -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" diff --git a/src/l10n/pol-POL.h b/src/l10n/pol-POL.h index d3ddabdb3..0b36f7724 100644 --- a/src/l10n/pol-POL.h +++ b/src/l10n/pol-POL.h @@ -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" diff --git a/src/l10n/por-PRT.h b/src/l10n/por-PRT.h index f710f3f81..c8bd6b3a4 100644 --- a/src/l10n/por-PRT.h +++ b/src/l10n/por-PRT.h @@ -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" From aedf99a8274a34bd15aa3b5e5c5bed60f0dc7f48 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 09:01:21 -0500 Subject: [PATCH 02/44] ColLast: New recurrence attribute --- src/columns/CMakeLists.txt | 1 + src/columns/ColLast.cpp | 70 ++++++++++++++++++++++++++++++++++++++ src/columns/ColLast.h | 43 +++++++++++++++++++++++ src/columns/Column.cpp | 3 ++ src/l10n/deu-DEU.h | 1 + src/l10n/eng-USA.h | 1 + src/l10n/epo-RUS.h | 1 + src/l10n/esp-ESP.h | 1 + src/l10n/fra-FRA.h | 1 + src/l10n/ita-ITA.h | 1 + src/l10n/jpn-JPN.h | 1 + src/l10n/pol-POL.h | 1 + src/l10n/por-PRT.h | 1 + 13 files changed, 126 insertions(+) create mode 100644 src/columns/ColLast.cpp create mode 100644 src/columns/ColLast.h diff --git a/src/columns/CMakeLists.txt b/src/columns/CMakeLists.txt index f73e1afc5..d8217ea5c 100644 --- a/src/columns/CMakeLists.txt +++ b/src/columns/CMakeLists.txt @@ -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 diff --git a/src/columns/ColLast.cpp b/src/columns/ColLast.cpp new file mode 100644 index 000000000..13d4da4c5 --- /dev/null +++ b/src/columns/ColLast.cpp @@ -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 +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +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 & lines, + Task& task, + int width, + Color& color) +{ + if (task.has (_name)) + renderStringRight (lines, width, color, task.get ("imask")); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColLast.h b/src/columns/ColLast.h new file mode 100644 index 000000000..83f1c48ad --- /dev/null +++ b/src/columns/ColLast.h @@ -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 + +class ColumnLast : public ColumnTypeNumeric +{ +public: + ColumnLast (); + void measure (Task&, unsigned int&, unsigned int&); + void render (std::vector &, Task&, int, Color&); + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index b3eee6b5f..fa3e88785 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -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 & 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; diff --git a/src/l10n/deu-DEU.h b/src/l10n/deu-DEU.h index 39b597b6a..e99e02cf1 100644 --- a/src/l10n/deu-DEU.h +++ b/src/l10n/deu-DEU.h @@ -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" diff --git a/src/l10n/eng-USA.h b/src/l10n/eng-USA.h index 83539cafb..324695e4e 100644 --- a/src/l10n/eng-USA.h +++ b/src/l10n/eng-USA.h @@ -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" diff --git a/src/l10n/epo-RUS.h b/src/l10n/epo-RUS.h index a527f0946..ef85a0011 100644 --- a/src/l10n/epo-RUS.h +++ b/src/l10n/epo-RUS.h @@ -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" diff --git a/src/l10n/esp-ESP.h b/src/l10n/esp-ESP.h index ad642d0b7..e39f5b324 100644 --- a/src/l10n/esp-ESP.h +++ b/src/l10n/esp-ESP.h @@ -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" diff --git a/src/l10n/fra-FRA.h b/src/l10n/fra-FRA.h index 93c845d45..e02ae59b8 100644 --- a/src/l10n/fra-FRA.h +++ b/src/l10n/fra-FRA.h @@ -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" diff --git a/src/l10n/ita-ITA.h b/src/l10n/ita-ITA.h index f36a4b32b..fba4d772c 100644 --- a/src/l10n/ita-ITA.h +++ b/src/l10n/ita-ITA.h @@ -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" diff --git a/src/l10n/jpn-JPN.h b/src/l10n/jpn-JPN.h index 593440521..6a302812e 100644 --- a/src/l10n/jpn-JPN.h +++ b/src/l10n/jpn-JPN.h @@ -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" diff --git a/src/l10n/pol-POL.h b/src/l10n/pol-POL.h index 0b36f7724..5574a4395 100644 --- a/src/l10n/pol-POL.h +++ b/src/l10n/pol-POL.h @@ -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" diff --git a/src/l10n/por-PRT.h b/src/l10n/por-PRT.h index c8bd6b3a4..2dd7dbe66 100644 --- a/src/l10n/por-PRT.h +++ b/src/l10n/por-PRT.h @@ -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" From 76c2de685bfdddbcb32b618a70b358c7f6389ecb Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 09:09:29 -0500 Subject: [PATCH 03/44] ColRType: New recurrence attribute --- src/columns/CMakeLists.txt | 1 + src/columns/ColRType.cpp | 68 ++++++++++++++++++++++++++++++++++++++ src/columns/ColRType.h | 43 ++++++++++++++++++++++++ src/columns/Column.cpp | 3 ++ src/l10n/deu-DEU.h | 1 + src/l10n/eng-USA.h | 1 + src/l10n/epo-RUS.h | 1 + src/l10n/esp-ESP.h | 1 + src/l10n/fra-FRA.h | 1 + src/l10n/ita-ITA.h | 1 + src/l10n/jpn-JPN.h | 1 + src/l10n/pol-POL.h | 1 + src/l10n/por-PRT.h | 1 + 13 files changed, 124 insertions(+) create mode 100644 src/columns/ColRType.cpp create mode 100644 src/columns/ColRType.h diff --git a/src/columns/CMakeLists.txt b/src/columns/CMakeLists.txt index d8217ea5c..6df76bcc7 100644 --- a/src/columns/CMakeLists.txt +++ b/src/columns/CMakeLists.txt @@ -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 diff --git a/src/columns/ColRType.cpp b/src/columns/ColRType.cpp new file mode 100644 index 000000000..e9fe03537 --- /dev/null +++ b/src/columns/ColRType.cpp @@ -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 +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +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 & lines, + Task& task, + int width, + Color& color) +{ + if (task.has (_name)) + renderStringLeft (lines, width, color, task.get (_name)); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColRType.h b/src/columns/ColRType.h new file mode 100644 index 000000000..bce9747fb --- /dev/null +++ b/src/columns/ColRType.h @@ -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 + +class ColumnRType : public ColumnTypeString +{ +public: + ColumnRType (); + void measure (Task&, unsigned int&, unsigned int&); + void render (std::vector &, Task&, int, Color&); + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index fa3e88785..432f6def8 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -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 & 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; diff --git a/src/l10n/deu-DEU.h b/src/l10n/deu-DEU.h index e99e02cf1..570b5cbf5 100644 --- a/src/l10n/deu-DEU.h +++ b/src/l10n/deu-DEU.h @@ -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" diff --git a/src/l10n/eng-USA.h b/src/l10n/eng-USA.h index 324695e4e..b54e94246 100644 --- a/src/l10n/eng-USA.h +++ b/src/l10n/eng-USA.h @@ -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" diff --git a/src/l10n/epo-RUS.h b/src/l10n/epo-RUS.h index ef85a0011..bf3defcd6 100644 --- a/src/l10n/epo-RUS.h +++ b/src/l10n/epo-RUS.h @@ -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" diff --git a/src/l10n/esp-ESP.h b/src/l10n/esp-ESP.h index e39f5b324..be365ad76 100644 --- a/src/l10n/esp-ESP.h +++ b/src/l10n/esp-ESP.h @@ -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" diff --git a/src/l10n/fra-FRA.h b/src/l10n/fra-FRA.h index e02ae59b8..418b6936c 100644 --- a/src/l10n/fra-FRA.h +++ b/src/l10n/fra-FRA.h @@ -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" diff --git a/src/l10n/ita-ITA.h b/src/l10n/ita-ITA.h index fba4d772c..630e6f786 100644 --- a/src/l10n/ita-ITA.h +++ b/src/l10n/ita-ITA.h @@ -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" diff --git a/src/l10n/jpn-JPN.h b/src/l10n/jpn-JPN.h index 6a302812e..548993324 100644 --- a/src/l10n/jpn-JPN.h +++ b/src/l10n/jpn-JPN.h @@ -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" diff --git a/src/l10n/pol-POL.h b/src/l10n/pol-POL.h index 5574a4395..2c272fecd 100644 --- a/src/l10n/pol-POL.h +++ b/src/l10n/pol-POL.h @@ -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" diff --git a/src/l10n/por-PRT.h b/src/l10n/por-PRT.h index 2dd7dbe66..a4aeaa9ae 100644 --- a/src/l10n/por-PRT.h +++ b/src/l10n/por-PRT.h @@ -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" From b17bfb50b3f6d675e2d8fe9806b2705498834cee Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 09:53:42 -0500 Subject: [PATCH 04/44] ColType*: Push the ::validate and ::modify methods down from Column --- src/columns/ColTypeDate.cpp | 6 ++++++ src/columns/ColTypeDate.h | 1 + src/columns/ColTypeDuration.cpp | 6 ++++++ src/columns/ColTypeDuration.h | 1 + src/columns/ColTypeNumeric.cpp | 6 ++++++ src/columns/ColTypeNumeric.h | 1 + src/columns/ColTypeString.cpp | 6 ++++++ src/columns/ColTypeString.h | 1 + src/columns/Column.cpp | 6 ------ src/columns/Column.h | 2 +- 10 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/columns/ColTypeDate.cpp b/src/columns/ColTypeDate.cpp index 357c9d6ce..869f94483 100644 --- a/src/columns/ColTypeDate.cpp +++ b/src/columns/ColTypeDate.cpp @@ -204,6 +204,12 @@ void ColumnTypeDate::render ( } } +//////////////////////////////////////////////////////////////////////////////// +bool ColumnTypeDate::validate (const std::string& input) const +{ + return input.length () ? true : false; +} + //////////////////////////////////////////////////////////////////////////////// void ColumnTypeDate::modify (Task& task, const std::string& value) { diff --git a/src/columns/ColTypeDate.h b/src/columns/ColTypeDate.h index 789339c04..fff7aecc1 100644 --- a/src/columns/ColTypeDate.h +++ b/src/columns/ColTypeDate.h @@ -39,6 +39,7 @@ public: ColumnTypeDate (); virtual void measure (Task&, unsigned int&, unsigned int&); virtual void render (std::vector &, Task&, int, Color&); + virtual bool validate (const std::string&) const; virtual void modify (Task&, const std::string&); }; diff --git a/src/columns/ColTypeDuration.cpp b/src/columns/ColTypeDuration.cpp index b3e433d81..144c95794 100644 --- a/src/columns/ColTypeDuration.cpp +++ b/src/columns/ColTypeDuration.cpp @@ -43,6 +43,12 @@ ColumnTypeDuration::ColumnTypeDuration () _type = "duration"; } +//////////////////////////////////////////////////////////////////////////////// +bool ColumnTypeDuration::validate (const std::string& input) const +{ + return input.length () ? true : false; +} + //////////////////////////////////////////////////////////////////////////////// void ColumnTypeDuration::modify (Task& task, const std::string& value) { diff --git a/src/columns/ColTypeDuration.h b/src/columns/ColTypeDuration.h index d556a486c..54ab03c0a 100644 --- a/src/columns/ColTypeDuration.h +++ b/src/columns/ColTypeDuration.h @@ -35,6 +35,7 @@ class ColumnTypeDuration : public Column { public: ColumnTypeDuration (); + virtual bool validate (const std::string&) const; virtual void modify (Task&, const std::string&); }; diff --git a/src/columns/ColTypeNumeric.cpp b/src/columns/ColTypeNumeric.cpp index b69147f1f..1f37cf382 100644 --- a/src/columns/ColTypeNumeric.cpp +++ b/src/columns/ColTypeNumeric.cpp @@ -43,6 +43,12 @@ ColumnTypeNumeric::ColumnTypeNumeric () _type = "numeric"; } +//////////////////////////////////////////////////////////////////////////////// +bool ColumnTypeNumeric::validate (const std::string& input) const +{ + return input.length () ? true : false; +} + //////////////////////////////////////////////////////////////////////////////// void ColumnTypeNumeric::modify (Task& task, const std::string& value) { diff --git a/src/columns/ColTypeNumeric.h b/src/columns/ColTypeNumeric.h index ff2f9c12b..9cc68a62f 100644 --- a/src/columns/ColTypeNumeric.h +++ b/src/columns/ColTypeNumeric.h @@ -35,6 +35,7 @@ class ColumnTypeNumeric : public Column { public: ColumnTypeNumeric (); + virtual bool validate (const std::string&) const; virtual void modify (Task&, const std::string&); }; diff --git a/src/columns/ColTypeString.cpp b/src/columns/ColTypeString.cpp index af91ae008..5b3856a0a 100644 --- a/src/columns/ColTypeString.cpp +++ b/src/columns/ColTypeString.cpp @@ -43,6 +43,12 @@ ColumnTypeString::ColumnTypeString () _type = "string"; } +//////////////////////////////////////////////////////////////////////////////// +bool ColumnTypeString::validate (const std::string& input) const +{ + return input.length () ? true : false; +} + //////////////////////////////////////////////////////////////////////////////// void ColumnTypeString::modify (Task& task, const std::string& value) { diff --git a/src/columns/ColTypeString.h b/src/columns/ColTypeString.h index 697c98e51..21d3b32f9 100644 --- a/src/columns/ColTypeString.h +++ b/src/columns/ColTypeString.h @@ -35,6 +35,7 @@ class ColumnTypeString : public Column { public: ColumnTypeString (); + virtual bool validate (const std::string&) const; virtual void modify (Task&, const std::string&); }; diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index 432f6def8..81a03f1e5 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -292,12 +292,6 @@ void Column::setStyle (const std::string& style) _style = style; } -//////////////////////////////////////////////////////////////////////////////// -bool Column::validate (const std::string& input) const -{ - return input.length () ? true : false; -} - //////////////////////////////////////////////////////////////////////////////// // All integer values are right-justified. void Column::renderInteger ( diff --git a/src/columns/Column.h b/src/columns/Column.h index d064a261e..32f117933 100644 --- a/src/columns/Column.h +++ b/src/columns/Column.h @@ -57,12 +57,12 @@ public: virtual void setLabel (const std::string& value) { _label = value; } virtual void setReport (const std::string& value) { _report = value; } - virtual bool validate (const std::string&) const; virtual void measure (const std::string&, unsigned int&, unsigned int&) {}; virtual void measure (Task&, unsigned int&, unsigned int&) {}; virtual void renderHeader (std::vector &, int, Color&); virtual void render (std::vector &, const std::string&, int, Color&) {}; virtual void render (std::vector &, Task&, int, Color&) {}; + virtual bool validate (const std::string&) const {return false;}; virtual void modify (Task&, const std::string&) {}; protected: From ade87bda2467c708b6dd6c94a19d084698858ccb Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 09:54:31 -0500 Subject: [PATCH 05/44] ColRType: Added ::setStyle and ::validate --- src/columns/ColRType.cpp | 45 +++++++++++++++++++++++++++++++++++----- src/columns/ColRType.h | 2 ++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/columns/ColRType.cpp b/src/columns/ColRType.cpp index e9fe03537..1d0e2d9be 100644 --- a/src/columns/ColRType.cpp +++ b/src/columns/ColRType.cpp @@ -26,8 +26,13 @@ #include #include +#include +#include #include #include +#include + +extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnRType::ColumnRType () @@ -36,10 +41,21 @@ ColumnRType::ColumnRType () _style = "default"; _label = STRING_COLUMN_LABEL_RTYPE; _modifiable = false; - _styles = {"default"}; + _styles = {"default", "indicator"}; _examples = {"periodic", "chained"}; } +//////////////////////////////////////////////////////////////////////////////// +// Overriden so that style <----> label are linked. +// Note that you can not determine which gets called first. +void ColumnRType::setStyle (const std::string& value) +{ + _style = value; + + if (_style == "indicator" && _label == STRING_COLUMN_LABEL_RTYPE) + _label = _label.substr (0, context.config.get ("rtype.indicator").length ()); +} + //////////////////////////////////////////////////////////////////////////////// // Set the minimum and maximum widths for the value. void ColumnRType::measure (Task& task, unsigned int& minimum, unsigned int& maximum) @@ -47,9 +63,11 @@ void ColumnRType::measure (Task& task, unsigned int& minimum, unsigned int& maxi minimum = maximum = 0; if (task.has (_name)) { - minimum = maximum = task.get (_name).length (); - - if (_style != "default") + if (_style == "default") + minimum = maximum = task.get (_name).length (); + else if (_style == "indicator") + minimum = maximum = 1; + else throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } @@ -62,7 +80,24 @@ void ColumnRType::render ( Color& color) { if (task.has (_name)) - renderStringLeft (lines, width, color, task.get (_name)); + { + if (_style == "default") + renderStringRight (lines, width, color, task.get (_name)); + + else if (_style == "indicator") + { + std::string value {" "}; + value[0] = toupper (task.get (_name)[0]); + renderStringRight (lines, width, color, value); + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +bool ColumnRType::validate (const std::string& input) const +{ + return input == "periodic" || + input == "chained"; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColRType.h b/src/columns/ColRType.h index bce9747fb..e082da304 100644 --- a/src/columns/ColRType.h +++ b/src/columns/ColRType.h @@ -33,8 +33,10 @@ class ColumnRType : public ColumnTypeString { public: ColumnRType (); + void setStyle (const std::string&); void measure (Task&, unsigned int&, unsigned int&); void render (std::vector &, Task&, int, Color&); + bool validate (const std::string&) const; private: }; From 6818b85c269986f010faa0320a8b4427a2769c19 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:23:51 -0500 Subject: [PATCH 06/44] ColLast: Corrected use of _name --- src/columns/ColLast.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/columns/ColLast.cpp b/src/columns/ColLast.cpp index 13d4da4c5..7adecaabc 100644 --- a/src/columns/ColLast.cpp +++ b/src/columns/ColLast.cpp @@ -32,7 +32,7 @@ //////////////////////////////////////////////////////////////////////////////// ColumnLast::ColumnLast () { - _name = "imask"; + _name = "last"; _style = "number"; _label = STRING_COLUMN_LABEL_LAST; _modifiable = false; @@ -48,7 +48,7 @@ void ColumnLast::measure (Task& task, unsigned int& minimum, unsigned int& maxim if (task.has (_name)) { - minimum = maximum = task.get ("imask").length (); + minimum = maximum = task.get (_name).length (); if (_style != "default" && _style != "number") @@ -64,7 +64,7 @@ void ColumnLast::render ( Color& color) { if (task.has (_name)) - renderStringRight (lines, width, color, task.get ("imask")); + renderStringRight (lines, width, color, task.get (_name)); } //////////////////////////////////////////////////////////////////////////////// From a9063284d95aa13d059317ac91ed7db9f9620686 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:31:27 -0500 Subject: [PATCH 07/44] ColScheduled: Formatting cleanup --- src/columns/ColScheduled.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/columns/ColScheduled.cpp b/src/columns/ColScheduled.cpp index bd3beeb13..482495c9c 100644 --- a/src/columns/ColScheduled.cpp +++ b/src/columns/ColScheduled.cpp @@ -31,8 +31,8 @@ //////////////////////////////////////////////////////////////////////////////// ColumnScheduled::ColumnScheduled () { - _name = "scheduled"; - _label = STRING_COLUMN_LABEL_SCHED; + _name = "scheduled"; + _label = STRING_COLUMN_LABEL_SCHED; } //////////////////////////////////////////////////////////////////////////////// From f3b28374c2f6eef189f405e3c68af5de9e981fa2 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:32:18 -0500 Subject: [PATCH 08/44] ColScheduled: Fixed bug where the wrong column label was used --- src/columns/ColScheduled.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/columns/ColScheduled.cpp b/src/columns/ColScheduled.cpp index 482495c9c..40e51a666 100644 --- a/src/columns/ColScheduled.cpp +++ b/src/columns/ColScheduled.cpp @@ -42,7 +42,7 @@ void ColumnScheduled::setStyle (const std::string& value) { _style = value; - if (_style == "countdown" && _label == STRING_COLUMN_LABEL_DUE) + if (_style == "countdown" && _label == STRING_COLUMN_LABEL_SCHED) _label = STRING_COLUMN_LABEL_COUNT; } From 8e39420375419e89c195480e50bc7bd487988bdf Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:32:41 -0500 Subject: [PATCH 09/44] ColUntil: Formatting cleanup --- src/columns/ColUntil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/columns/ColUntil.cpp b/src/columns/ColUntil.cpp index 3776051f1..1b8423ebf 100644 --- a/src/columns/ColUntil.cpp +++ b/src/columns/ColUntil.cpp @@ -31,8 +31,8 @@ //////////////////////////////////////////////////////////////////////////////// ColumnUntil::ColumnUntil () { - _name = "until"; - _label = STRING_COLUMN_LABEL_UNTIL; + _name = "until"; + _label = STRING_COLUMN_LABEL_UNTIL; } //////////////////////////////////////////////////////////////////////////////// From 33896652271a65e2096374be40c8f7d5775962d5 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:32:58 -0500 Subject: [PATCH 10/44] ColDepends: Corrected use of _name --- src/columns/ColDepends.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/columns/ColDepends.cpp b/src/columns/ColDepends.cpp index ce425776b..acfdf88a8 100644 --- a/src/columns/ColDepends.cpp +++ b/src/columns/ColDepends.cpp @@ -73,7 +73,7 @@ void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& ma if (_style == "indicator") { - if (task.has ("depends")) + if (task.has (_name)) minimum = maximum = utf8_width (context.config.get ("dependency.indicator")); else minimum = maximum = 0; @@ -86,7 +86,7 @@ void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& ma _style == "list") { minimum = maximum = 0; - if (task.has ("depends")) + if (task.has (_name)) { std::vector blocking_ids; for (auto& i : blocking) From 79b25400420e29d2689fb2a80b2d8f8465a2123e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:34:24 -0500 Subject: [PATCH 11/44] ColWait: Formatting cleanup --- src/columns/ColWait.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/columns/ColWait.cpp b/src/columns/ColWait.cpp index d8cf4d8e6..96f99840c 100644 --- a/src/columns/ColWait.cpp +++ b/src/columns/ColWait.cpp @@ -31,8 +31,8 @@ //////////////////////////////////////////////////////////////////////////////// ColumnWait::ColumnWait () { - _name = "wait"; - _label = STRING_COLUMN_LABEL_WAIT; + _name = "wait"; + _label = STRING_COLUMN_LABEL_WAIT; } //////////////////////////////////////////////////////////////////////////////// From 57e9858c1df27c2c8d0789baca67ab38575af85c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:36:13 -0500 Subject: [PATCH 12/44] ColUrgency: Marked column as unmodifiable --- src/columns/ColUrgency.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/columns/ColUrgency.cpp b/src/columns/ColUrgency.cpp index 82a6586ca..8ee23ef95 100644 --- a/src/columns/ColUrgency.cpp +++ b/src/columns/ColUrgency.cpp @@ -32,11 +32,12 @@ //////////////////////////////////////////////////////////////////////////////// ColumnUrgency::ColumnUrgency () { - _name = "urgency"; - _style = "real"; - _label = STRING_COLUMN_LABEL_URGENCY; - _styles = {"real", "integer"}; - _examples = {"4.6", "4"}; + _name = "urgency"; + _style = "real"; + _label = STRING_COLUMN_LABEL_URGENCY; + _modifiable = false; + _styles = {"real", "integer"}; + _examples = {"4.6", "4"}; } //////////////////////////////////////////////////////////////////////////////// From 0f4337334cd0a1f7972d8dc8fd36c69c93c0c483 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:38:11 -0500 Subject: [PATCH 13/44] ColUUID: Removed unnecessary header --- src/columns/ColUUID.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/columns/ColUUID.cpp b/src/columns/ColUUID.cpp index 83f1a7dc9..aea498bf3 100644 --- a/src/columns/ColUUID.cpp +++ b/src/columns/ColUUID.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -45,6 +44,8 @@ ColumnUUID::ColumnUUID () // Set the minimum and maximum widths for the value. void ColumnUUID::measure (Task&, unsigned int& minimum, unsigned int& maximum) { + // Mandatory attribute, no need to check the value. + if (_style == "default" || _style == "long") minimum = maximum = 36; else if (_style == "short") minimum = maximum = 8; else From e616538bcc6afb2f8a93739b7f55caef02e0d66c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:40:11 -0500 Subject: [PATCH 14/44] ColUDA: Added _modifiable --- src/columns/ColUDA.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/columns/ColUDA.cpp b/src/columns/ColUDA.cpp index b59e4c562..e1ad5427c 100644 --- a/src/columns/ColUDA.cpp +++ b/src/columns/ColUDA.cpp @@ -40,12 +40,13 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnUDAString::ColumnUDAString () { - _name = ""; - _style = "default"; - _label = ""; - _uda = true; - _hyphenate = true; - _styles = {_style, "indicator"}; + _name = ""; // Gets overwritten at runtime. + _style = "default"; + _label = ""; + _modifiable = true; + _uda = true; + _hyphenate = true; + _styles = {_style, "indicator"}; } //////////////////////////////////////////////////////////////////////////////// From 9888f98333583699abdf37763701a41ac5403029 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 10:40:29 -0500 Subject: [PATCH 15/44] ColUDA: Removed redundant code --- src/columns/ColUDA.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/columns/ColUDA.cpp b/src/columns/ColUDA.cpp index e1ad5427c..a7534ed5c 100644 --- a/src/columns/ColUDA.cpp +++ b/src/columns/ColUDA.cpp @@ -122,14 +122,11 @@ void ColumnUDAString::render ( } else if (_style == "indicator") { - if (task.has (_name)) - { - auto indicator = context.config.get ("uda." + _name + ".indicator"); - if (indicator == "") - indicator = "U"; + auto indicator = context.config.get ("uda." + _name + ".indicator"); + if (indicator == "") + indicator = "U"; - renderStringRight (lines, width, color, indicator); - } + renderStringRight (lines, width, color, indicator); } } } From 62f40d0830618a95b33b8e907fe19df98aefc4f8 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:08:59 -0500 Subject: [PATCH 16/44] ColDescription: Added _modifiable --- src/columns/ColDescription.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/columns/ColDescription.cpp b/src/columns/ColDescription.cpp index 512ce02c1..7706c861c 100644 --- a/src/columns/ColDescription.cpp +++ b/src/columns/ColDescription.cpp @@ -40,16 +40,17 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnDescription::ColumnDescription () { - _name = "description"; - _style = "combined"; - _label = STRING_COLUMN_LABEL_DESC; + _name = "description"; + _style = "combined"; + _label = STRING_COLUMN_LABEL_DESC; + _modifiable = true; - _styles = {"combined", - "desc", - "oneline", - "truncated", - "count", - "truncated_count"}; + _styles = {"combined", + "desc", + "oneline", + "truncated", + "count", + "truncated_count"}; _dateformat = context.config.get ("dateformat.annotation"); if (_dateformat == "") From 9fd1500d200a960d9fec7a3dc517b05d6ea8bdd4 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:09:13 -0500 Subject: [PATCH 17/44] ColDue: Added _modifiable --- src/columns/ColDue.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/columns/ColDue.cpp b/src/columns/ColDue.cpp index 2cf64a79e..07037f546 100644 --- a/src/columns/ColDue.cpp +++ b/src/columns/ColDue.cpp @@ -31,8 +31,9 @@ //////////////////////////////////////////////////////////////////////////////// ColumnDue::ColumnDue () { - _name = "due"; - _label = STRING_COLUMN_LABEL_DUE; + _name = "due"; + _modifiable = true; + _label = STRING_COLUMN_LABEL_DUE; } //////////////////////////////////////////////////////////////////////////////// From 3c9081c22b722338ab5e6c5fe2bd9a931076b117 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:09:27 -0500 Subject: [PATCH 18/44] ColEntry: Added _modifiable --- src/columns/ColEntry.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/columns/ColEntry.cpp b/src/columns/ColEntry.cpp index 8a75b8f50..c78a76171 100644 --- a/src/columns/ColEntry.cpp +++ b/src/columns/ColEntry.cpp @@ -31,8 +31,9 @@ //////////////////////////////////////////////////////////////////////////////// ColumnEntry::ColumnEntry () { - _name = "entry"; - _label = STRING_COLUMN_LABEL_ADDED; + _name = "entry"; + _modifiable = true; + _label = STRING_COLUMN_LABEL_ADDED; } //////////////////////////////////////////////////////////////////////////////// From b3e976fbaaacb28d1c377fe58cc3d97214414f5b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:09:54 -0500 Subject: [PATCH 19/44] ColIMask: Corrected use of _name --- src/columns/ColIMask.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/columns/ColIMask.cpp b/src/columns/ColIMask.cpp index 5f053fa98..ee17436f3 100644 --- a/src/columns/ColIMask.cpp +++ b/src/columns/ColIMask.cpp @@ -48,7 +48,7 @@ void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maxi if (task.has (_name)) { - minimum = maximum = task.get ("imask").length (); + minimum = maximum = task.get (_name).length (); if (_style != "default" && _style != "number") @@ -64,7 +64,7 @@ void ColumnIMask::render ( Color& color) { if (task.has (_name)) - renderStringRight (lines, width, color, task.get ("imask")); + renderStringRight (lines, width, color, task.get (_name)); } //////////////////////////////////////////////////////////////////////////////// From a8d7a5122aa839e05fb1979d774f7d22a91a3261 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:10:13 -0500 Subject: [PATCH 20/44] ColMask: Corrected use of _name --- src/columns/ColMask.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/columns/ColMask.cpp b/src/columns/ColMask.cpp index 08a8e70e5..d7a82e256 100644 --- a/src/columns/ColMask.cpp +++ b/src/columns/ColMask.cpp @@ -47,7 +47,7 @@ void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maxim minimum = maximum = 0; if (task.has (_name)) { - minimum = maximum = task.get ("mask").length (); + minimum = maximum = task.get (_name).length (); if (_style != "default") throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); @@ -62,7 +62,7 @@ void ColumnMask::render ( Color& color) { if (task.has (_name)) - renderStringLeft (lines, width, color, task.get ("mask")); + renderStringLeft (lines, width, color, task.get (_name)); } //////////////////////////////////////////////////////////////////////////////// From d48c35732506e3287cbf0fe082cdb73f99f85593 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:10:44 -0500 Subject: [PATCH 21/44] ColRecur: Added _modifiable --- src/columns/ColRecur.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index 129c0e4ac..acf1e7ed0 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -44,11 +44,12 @@ extern Task& contextTask; //////////////////////////////////////////////////////////////////////////////// ColumnRecur::ColumnRecur () { - _name = "recur"; - _style = "duration"; - _label = STRING_COLUMN_LABEL_RECUR; - _styles = {"duration", "indicator"}; - _examples = {"weekly", context.config.get ("recurrence.indicator")}; + _name = "recur"; + _style = "duration"; + _label = STRING_COLUMN_LABEL_RECUR; + _modifiable = true; + _styles = {"duration", "indicator"}; + _examples = {"weekly", context.config.get ("recurrence.indicator")}; } //////////////////////////////////////////////////////////////////////////////// From 5ae1da51b7b4708c253415af77e42b84949a2cfa Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:11:04 -0500 Subject: [PATCH 22/44] ColRecur: Corrected use of _name --- src/columns/ColRecur.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index acf1e7ed0..f7594a62e 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -74,11 +74,11 @@ void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maxi if (_style == "default" || _style == "duration") { - minimum = maximum = Duration (task.get ("recur")).formatISO ().length (); + minimum = maximum = Duration (task.get (_name)).formatISO ().length (); } else if (_style == "indicator") { - if (task.has ("recur")) + if (task.has (_name)) minimum = maximum = utf8_width (context.config.get ("recurrence.indicator")); else minimum = maximum = 0; @@ -99,7 +99,7 @@ void ColumnRecur::render ( { if (_style == "default" || _style == "duration") - renderStringRight (lines, width, color, Duration (task.get ("recur")).formatISO ()); + renderStringRight (lines, width, color, Duration (task.get (_name)).formatISO ()); else if (_style == "indicator") renderStringRight (lines, width, color, context.config.get ("recurrence.indicator")); From 24f6b2665fc4b8c58e83a13592951776497f00e9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:11:42 -0500 Subject: [PATCH 23/44] ColStart: Removed redundant code --- src/columns/ColStart.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/columns/ColStart.cpp b/src/columns/ColStart.cpp index df807d045..3bb6a9ed3 100644 --- a/src/columns/ColStart.cpp +++ b/src/columns/ColStart.cpp @@ -62,12 +62,7 @@ void ColumnStart::measure (Task& task, unsigned int& minimum, unsigned int& maxi if (task.has (_name)) { if (_style == "active") - { - if (task.has ("start")) - minimum = maximum = utf8_width (context.config.get ("active.indicator")); - else - minimum = maximum = 0; - } + minimum = maximum = utf8_width (context.config.get ("active.indicator")); else ColumnTypeDate::measure (task, minimum, maximum); } From 7a4d99f95422713c4421fa3e74d678532f0e9851 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:11:56 -0500 Subject: [PATCH 24/44] ColTags: Corrected use of _name --- src/columns/ColTags.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/columns/ColTags.cpp b/src/columns/ColTags.cpp index c32232030..ce79a0c2b 100644 --- a/src/columns/ColTags.cpp +++ b/src/columns/ColTags.cpp @@ -80,7 +80,7 @@ void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maxim { if (_style == "indicator") { - if (task.has ("tags")) + if (task.has (_name)) minimum = maximum = utf8_width (context.config.get ("tag.indicator")); else minimum = maximum = 0; @@ -163,7 +163,7 @@ void ColumnTags::modify (Task& task, const std::string& value) std::string label = " MODIFICATION "; // TW-1701 - task.set ("tags", ""); + task.set (_name, ""); for (auto& tag : split (value, ',')) { From c81c9f5b589231e3667878c340a813e34d5b00d6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:45:31 -0500 Subject: [PATCH 25/44] ColDepends: Removed redundant code --- src/columns/ColDepends.cpp | 77 +++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/src/columns/ColDepends.cpp b/src/columns/ColDepends.cpp index acfdf88a8..5cb752ac6 100644 --- a/src/columns/ColDepends.cpp +++ b/src/columns/ColDepends.cpp @@ -68,26 +68,28 @@ void ColumnDepends::setStyle (const std::string& value) // Set the minimum and maximum widths for the value. void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { - std::vector blocking; - dependencyGetBlocking (task, blocking); - - if (_style == "indicator") + minimum = maximum = 0; + if (task.has (_name)) { - if (task.has (_name)) - minimum = maximum = utf8_width (context.config.get ("dependency.indicator")); - else - minimum = maximum = 0; - } - else if (_style == "count") - { - minimum = maximum = 2 + format ((int) blocking.size ()).length (); - } - else if (_style == "default" || - _style == "list") - { - minimum = maximum = 0; - if (task.has (_name)) + if (_style == "indicator") { + minimum = maximum = utf8_width (context.config.get ("dependency.indicator")); + } + + else if (_style == "count") + { + std::vector blocking; + dependencyGetBlocking (task, blocking); + minimum = maximum = 2 + format ((int) blocking.size ()).length (); + } + + else if (_style == "default" || + _style == "list") + { + minimum = maximum = 0; + std::vector blocking; + dependencyGetBlocking (task, blocking); + std::vector blocking_ids; for (auto& i : blocking) blocking_ids.push_back (i.id); @@ -103,9 +105,9 @@ void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& ma minimum = length; } } + else + throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } //////////////////////////////////////////////////////////////////////////////// @@ -118,30 +120,35 @@ void ColumnDepends::render ( if (task.has (_name)) { if (_style == "indicator") + { renderStringRight (lines, width, color, context.config.get ("dependency.indicator")); - else + } + + else if (_style == "count") { std::vector blocking; dependencyGetBlocking (task, blocking); - if (_style == "count") - renderStringRight (lines, width, color, '[' + format (static_cast (blocking.size ())) + ']'); + renderStringRight (lines, width, color, '[' + format (static_cast (blocking.size ())) + ']'); + } - else if (_style == "default" || - _style == "list") - { - std::vector blocking_ids; - for (const auto& t : blocking) - blocking_ids.push_back (t.id); + else if (_style == "default" || + _style == "list") + { + std::vector blocking; + dependencyGetBlocking (task, blocking); - auto combined = join (" ", blocking_ids); + std::vector blocking_ids; + for (const auto& t : blocking) + blocking_ids.push_back (t.id); - std::vector all; - wrapText (all, combined, width, _hyphenate); + auto combined = join (" ", blocking_ids); - for (const auto& i : all) - renderStringLeft (lines, width, color, i); - } + std::vector all; + wrapText (all, combined, width, _hyphenate); + + for (const auto& i : all) + renderStringLeft (lines, width, color, i); } } } From 110db6bb9107d6e51f903aa49eb72ef24ffaad0c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:46:02 -0500 Subject: [PATCH 26/44] ColID: Documented ID 0 case --- src/columns/ColID.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/columns/ColID.cpp b/src/columns/ColID.cpp index 48e7c016c..c47d2ea4f 100644 --- a/src/columns/ColID.cpp +++ b/src/columns/ColID.cpp @@ -68,6 +68,7 @@ void ColumnID::render ( int width, Color& color) { + // Completed and deleted tasks have no ID. if (task.id) renderInteger (lines, width, color, task.id); else From b6d19ce1ad9f427f041c4038ec62faa35f14e332 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:47:10 -0500 Subject: [PATCH 27/44] ColRecur: Removed redundant code --- src/columns/ColRecur.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index f7594a62e..f1cf833fc 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -78,10 +78,7 @@ void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maxi } else if (_style == "indicator") { - if (task.has (_name)) - minimum = maximum = utf8_width (context.config.get ("recurrence.indicator")); - else - minimum = maximum = 0; + minimum = maximum = utf8_width (context.config.get ("recurrence.indicator")); } else throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); From 78ff1975b289ab4da743499d974ca693ec046f19 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:47:34 -0500 Subject: [PATCH 28/44] ColTags: Removed redundant code --- src/columns/ColTags.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/columns/ColTags.cpp b/src/columns/ColTags.cpp index ce79a0c2b..246c7ee3b 100644 --- a/src/columns/ColTags.cpp +++ b/src/columns/ColTags.cpp @@ -80,10 +80,7 @@ void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maxim { if (_style == "indicator") { - if (task.has (_name)) - minimum = maximum = utf8_width (context.config.get ("tag.indicator")); - else - minimum = maximum = 0; + minimum = maximum = utf8_width (context.config.get ("tag.indicator")); } else if (_style == "count") { From c8bd60b713f321c3e971886a210d574d4a23ea28 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:49:15 -0500 Subject: [PATCH 29/44] ColUDA: Removed redundant code --- src/columns/ColUDA.cpp | 90 ++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 57 deletions(-) diff --git a/src/columns/ColUDA.cpp b/src/columns/ColUDA.cpp index a7534ed5c..83c8ab38e 100644 --- a/src/columns/ColUDA.cpp +++ b/src/columns/ColUDA.cpp @@ -79,23 +79,18 @@ void ColumnUDAString::measure (Task& task, unsigned int& minimum, unsigned int& std::string value = task.get (_name); if (value != "") { - std::string stripped = Color::strip (value); + auto stripped = Color::strip (value); maximum = longestLine (stripped); minimum = longestWord (stripped); } } else if (_style == "indicator") { - if (task.has (_name)) - { - auto indicator = context.config.get ("uda." + _name + ".indicator"); - if (indicator == "") - indicator = "U"; + auto indicator = context.config.get ("uda." + _name + ".indicator"); + if (indicator == "") + indicator = "U"; - minimum = maximum = utf8_width (indicator); - } - else - minimum = maximum = 0; + minimum = maximum = utf8_width (indicator); } else throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); @@ -169,22 +164,17 @@ void ColumnUDANumeric::measure (Task& task, unsigned int& minimum, unsigned int& { if (_style == "default") { - std::string value = task.get (_name); + auto value = task.get (_name); if (value != "") minimum = maximum = value.length (); } else if (_style == "indicator") { - if (task.has (_name)) - { - auto indicator = context.config.get ("uda." + _name + ".indicator"); - if (indicator == "") - indicator = "U"; + auto indicator = context.config.get ("uda." + _name + ".indicator"); + if (indicator == "") + indicator = "U"; - minimum = maximum = utf8_width (indicator); - } - else - minimum = maximum = 0; + minimum = maximum = utf8_width (indicator); } else throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); @@ -202,19 +192,16 @@ void ColumnUDANumeric::render ( { if (_style == "default") { - std::string value = task.get (_name); + auto value = task.get (_name); renderStringRight (lines, width, color, value); } else if (_style == "indicator") { - if (task.has (_name)) - { - auto indicator = context.config.get ("uda." + _name + ".indicator"); - if (indicator == "") - indicator = "U"; + auto indicator = context.config.get ("uda." + _name + ".indicator"); + if (indicator == "") + indicator = "U"; - renderStringRight (lines, width, color, indicator); - } + renderStringRight (lines, width, color, indicator); } } } @@ -257,7 +244,7 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma { if (_style == "default") { - std::string value = task.get (_name); + auto value = task.get (_name); if (value != "") { // Determine the output date format, which uses a hierarchy of definitions. @@ -265,7 +252,7 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma // rc.dateformat.report // rc.dateformat Datetime date ((time_t) strtol (value.c_str (), NULL, 10)); - std::string format = context.config.get ("report." + _report + ".dateformat"); + auto format = context.config.get ("report." + _report + ".dateformat"); if (format == "") format = context.config.get ("dateformat.report"); if (format == "") @@ -276,16 +263,11 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma } else if (_style == "indicator") { - if (task.has (_name)) - { - auto indicator = context.config.get ("uda." + _name + ".indicator"); - if (indicator == "") - indicator = "U"; + auto indicator = context.config.get ("uda." + _name + ".indicator"); + if (indicator == "") + indicator = "U"; - minimum = maximum = utf8_width (indicator); - } - else - minimum = maximum = 0; + minimum = maximum = utf8_width (indicator); } else throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); @@ -303,13 +285,13 @@ void ColumnUDADate::render ( { if (_style == "default") { - std::string value = task.get (_name); + auto value = task.get (_name); // Determine the output date format, which uses a hierarchy of definitions. // rc.report..dateformat // rc.dateformat.report // rc.dateformat. - std::string format = context.config.get ("report." + _report + ".dateformat"); + auto format = context.config.get ("report." + _report + ".dateformat"); if (format == "") { format = context.config.get ("dateformat.report"); @@ -321,14 +303,11 @@ void ColumnUDADate::render ( } else if (_style == "indicator") { - if (task.has (_name)) - { - auto indicator = context.config.get ("uda." + _name + ".indicator"); - if (indicator == "") - indicator = "U"; + auto indicator = context.config.get ("uda." + _name + ".indicator"); + if (indicator == "") + indicator = "U"; - renderStringRight (lines, width, color, indicator); - } + renderStringRight (lines, width, color, indicator); } } } @@ -371,7 +350,7 @@ void ColumnUDADuration::measure (Task& task, unsigned int& minimum, unsigned int { if (_style == "default") { - std::string value = task.get (_name); + auto value = task.get (_name); if (value != "") minimum = maximum = Duration (value).formatISO ().length (); } @@ -404,19 +383,16 @@ void ColumnUDADuration::render ( { if (_style == "default") { - std::string value = task.get (_name); + auto value = task.get (_name); renderStringRight (lines, width, color, Duration (value).formatISO ()); } else if (_style == "indicator") { - if (task.has (_name)) - { - auto indicator = context.config.get ("uda." + _name + ".indicator"); - if (indicator == "") - indicator = "U"; + auto indicator = context.config.get ("uda." + _name + ".indicator"); + if (indicator == "") + indicator = "U"; - renderStringRight (lines, width, color, indicator); - } + renderStringRight (lines, width, color, indicator); } } } From d4c9317239748bc1e07fa1eb16362a4ddfc788b9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:51:54 -0500 Subject: [PATCH 30/44] CmdCommands: Removed obsolete include --- src/commands/CmdCommands.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/CmdCommands.cpp b/src/commands/CmdCommands.cpp index 3295fff4f..23dd98422 100644 --- a/src/commands/CmdCommands.cpp +++ b/src/commands/CmdCommands.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include From 40c66232742d5c51477fe5ab16ce4038261a6370 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 11:53:00 -0500 Subject: [PATCH 31/44] ColString: Removed obsolete column for ViewText --- src/columns/CMakeLists.txt | 1 - src/columns/ColString.cpp | 116 ------------------------------------- src/columns/ColString.h | 49 ---------------- src/columns/Column.cpp | 4 -- 4 files changed, 170 deletions(-) delete mode 100644 src/columns/ColString.cpp delete mode 100644 src/columns/ColString.h diff --git a/src/columns/CMakeLists.txt b/src/columns/CMakeLists.txt index 6df76bcc7..002982bbb 100644 --- a/src/columns/CMakeLists.txt +++ b/src/columns/CMakeLists.txt @@ -24,7 +24,6 @@ set (columns_SRCS Column.cpp Column.h ColScheduled.cpp ColScheduled.h ColStart.cpp ColStart.h ColStatus.cpp ColStatus.h - ColString.cpp ColString.h ColTags.cpp ColTags.h ColTemplate.cpp ColTemplate.h ColTypeDate.cpp ColTypeDate.h diff --git a/src/columns/ColString.cpp b/src/columns/ColString.cpp deleted file mode 100644 index 5313b0ad0..000000000 --- a/src/columns/ColString.cpp +++ /dev/null @@ -1,116 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 -#include -#include -#include -#include -#include -#include - -extern Context context; - -//////////////////////////////////////////////////////////////////////////////// -ColumnString::ColumnString () -{ - _name = "string"; - _type = "string"; - _style = "left"; - _label = ""; - _styles = {"left", - "right", - "left_fixed", - "right_fixed"}; - _examples = {"Hello (wrapped) ", - " Hello (wrapped)", - "Hello (no-wrap) ", - " Hello (no-wrap)"}; - _hyphenate = context.config.getBoolean ("hyphenate"); -} - -//////////////////////////////////////////////////////////////////////////////// -// ColumnString is unique - it copies the report name into the label. This is -// a kludgy reuse of an otherwise unused member. -void ColumnString::setReport (const std::string& value) -{ - _report = _label = value; -} - -//////////////////////////////////////////////////////////////////////////////// -// Set the minimum and maximum widths for the value. -// -void ColumnString::measure (const std::string& value, unsigned int& minimum, unsigned int& maximum) -{ - minimum = maximum = 0; - - if (_style == "left" || - _style == "right" || - _style == "default") - { - std::string stripped = Color::strip (value); - maximum = longestLine (stripped); - minimum = longestWord (stripped); - } - else if (_style == "left_fixed" || - _style == "right_fixed") - minimum = maximum = strippedLength (value); - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); -} - -//////////////////////////////////////////////////////////////////////////////// -void ColumnString::render ( - std::vector & lines, - const std::string& value, - int width, - Color& color) -{ - if (_style == "default" || _style == "left") - { - std::vector raw; - wrapText (raw, value, width, _hyphenate); - - for (auto& i : raw) - renderStringLeft (lines, width, color, i); - } - else if (_style == "right") - { - std::vector raw; - wrapText (raw, value, width, _hyphenate); - - for (auto& i : raw) - renderStringRight (lines, width, color, i); - } - - else if (_style == "left_fixed") - renderStringLeft (lines, width, color, value); - - else if (_style == "right_fixed") - renderStringRight (lines, width, color, value); -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColString.h b/src/columns/ColString.h deleted file mode 100644 index f228d38fc..000000000 --- a/src/columns/ColString.h +++ /dev/null @@ -1,49 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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_COLSTRING -#define INCLUDED_COLSTRING - -#include -#include -#include -#include -#include - -class ColumnString : public Column -{ -public: - ColumnString (); - void setReport (const std::string&); - void measure (const std::string&, unsigned int&, unsigned int&); - void render (std::vector &, const std::string&, int, Color&); - -private: - bool _hyphenate; -}; - -#endif -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index 81a03f1e5..ee105d36f 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -107,9 +106,6 @@ Column* Column::factory (const std::string& name, const std::string& report) else if (column_name == "uuid") c = new ColumnUUID (); else if (column_name == "wait") c = new ColumnWait (); - // Special non-task column. - else if (column_name == "string") c = new ColumnString (); - // UDA. else if (context.config.has ("uda." + column_name + ".type")) c = Column::uda (column_name); From c31e0b106d3ec0cf3ae05634a0f8683b94829b28 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 12:27:20 -0500 Subject: [PATCH 32/44] Task: Renamed ::getUDAOrphans to ::getUDAOrphanUUIDs --- src/Task.cpp | 7 +++++-- src/Task.h | 2 +- src/commands/CmdEdit.cpp | 4 +--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Task.cpp b/src/Task.cpp index c0aaf4338..2b9c2eb15 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1336,12 +1336,15 @@ void Task::removeTag (const std::string& tag) #ifdef PRODUCT_TASKWARRIOR //////////////////////////////////////////////////////////////////////////////// // A UDA Orphan is an attribute that is not represented in context.columns. -void Task::getUDAOrphans (std::vector & names) const +std::vector Task::getUDAOrphanUUIDs () const { + std::vector orphans; for (auto& it : data) if (it.first.compare (0, 11, "annotation_", 11) != 0) if (context.columns.find (it.first) == context.columns.end ()) - names.push_back (it.first); + orphans.push_back (it.first); + + return orphans; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Task.h b/src/Task.h index b4cf6d336..5ac4b8b7e 100644 --- a/src/Task.h +++ b/src/Task.h @@ -145,7 +145,7 @@ public: void getDependencies (std::vector &) const; void getDependencies (std::vector &) const; - void getUDAOrphans (std::vector &) const; + std::vector getUDAOrphanUUIDs () const; void substitute (const std::string&, const std::string&, const std::string&); #endif diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index 9e6b52e80..580f73216 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -312,9 +312,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat) } // UDA orphans - std::vector orphans; - task.getUDAOrphans (orphans); - + auto orphans = task.getUDAOrphanUUIDs (); if (orphans.size ()) { before << "# " << STRING_EDIT_UDA_ORPHAN_SEP << '\n'; From cfc3e098c1c1b55b6865b699e2966cee364a77a7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 15:44:13 -0500 Subject: [PATCH 33/44] Task: Improved method signature --- src/Task.cpp | 4 ++-- src/Task.h | 2 +- src/commands/CmdEdit.cpp | 9 ++------- src/commands/CmdInfo.cpp | 3 +-- src/commands/CmdStats.cpp | 3 +-- src/commands/CmdTags.cpp | 12 ++---------- 6 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/Task.cpp b/src/Task.cpp index 2b9c2eb15..5ed1a2219 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1313,9 +1313,9 @@ void Task::addTags (const std::vector & tags) } //////////////////////////////////////////////////////////////////////////////// -void Task::getTags (std::vector& tags) const +std::vector Task::getTags () const { - tags = split (get ("tags"), ','); + return split (get ("tags"), ','); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Task.h b/src/Task.h index 5ac4b8b7e..c64e083e1 100644 --- a/src/Task.h +++ b/src/Task.h @@ -125,7 +125,7 @@ public: bool hasTag (const std::string&) const; void addTag (const std::string&); void addTags (const std::vector &); - void getTags (std::vector&) const; + std::vector getTags () const; void removeTag (const std::string&); bool hasAnnotations () const; diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index 580f73216..a38d6403f 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -224,14 +224,10 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat) << "# iMask: " << task.get ("imask") << '\n' << " Project: " << task.get ("project") << '\n'; - std::vector tags; - task.getTags (tags); - auto allTags = join (" ", tags); - if (verbose) before << "# " << STRING_EDIT_TAG_SEP << '\n'; - before << " Tags: " << allTags << '\n' + before << " Tags: " << join (" ", task.getTags ()) << '\n' << " Description: " << task.get ("description") << '\n' << " Created: " << formatDate (task, "entry", dateformat) << '\n' << " Started: " << formatDate (task, "start", dateformat) << '\n' @@ -353,9 +349,8 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string // tags value = findValue (after, "\n Tags:"); - auto tags = split (value, ' '); task.remove ("tags"); - task.addTags (tags); + task.addTags (split (value, ' ')); // description. value = findMultilineValue (after, "\n Description:", "\n Created:"); diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index b35404d50..7b8c5a047 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -300,8 +300,7 @@ int CmdInfo::execute (std::string& output) } // tags ... - std::vector tags; - task.getTags (tags); + auto tags = task.getTags (); if (tags.size ()) { auto allTags = join (" ", tags); diff --git a/src/commands/CmdStats.cpp b/src/commands/CmdStats.cpp index b77915e85..84695e9fd 100644 --- a/src/commands/CmdStats.cpp +++ b/src/commands/CmdStats.cpp @@ -145,8 +145,7 @@ int CmdStats::execute (std::string& output) task.getAnnotations (annotations); annotationsT += annotations.size (); - std::vector tags; - task.getTags (tags); + auto tags = task.getTags (); if (tags.size ()) ++taggedT; diff --git a/src/commands/CmdTags.cpp b/src/commands/CmdTags.cpp index 839974cc8..a27f8fc4b 100644 --- a/src/commands/CmdTags.cpp +++ b/src/commands/CmdTags.cpp @@ -79,10 +79,7 @@ int CmdTags::execute (std::string& output) std::map unique; for (auto& task : filtered) { - std::vector tags; - task.getTags (tags); - - for (auto& tag : tags) + for (auto& tag : task.getTags ()) if (unique.find (tag) != unique.end ()) unique[tag]++; else @@ -182,13 +179,8 @@ int CmdCompletionTags::execute (std::string& output) // names as keys. std::map unique; for (auto& task : filtered) - { - std::vector tags; - task.getTags (tags); - - for (auto& tag : tags) + for (auto& tag : task.getTags ()) unique[tag] = 0; - } // Add built-in tags to map. unique["nocolor"] = 0; From 5193f7d03ea6cfbf597de56106119f0caab2f66d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 15:55:06 -0500 Subject: [PATCH 34/44] Task: Improved method signature --- src/DOM.cpp | 6 ++---- src/Task.cpp | 12 ++++++------ src/Task.h | 2 +- src/Variant.cpp | 10 ++-------- src/columns/ColDescription.cpp | 16 ++++------------ src/commands/CmdDenotate.cpp | 3 +-- src/commands/CmdEdit.cpp | 4 +--- src/commands/CmdInfo.cpp | 4 +--- src/commands/CmdStats.cpp | 5 +---- src/commands/CmdTimesheet.cpp | 8 ++------ 10 files changed, 21 insertions(+), 49 deletions(-) diff --git a/src/DOM.cpp b/src/DOM.cpp index eba6b30aa..1d5f43519 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -300,8 +300,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value) if (ref.data.size () && size == 3 && elements[0] == "annotations") { - std::map annos; - ref.getAnnotations (annos); + auto annos = ref.getAnnotations (); int a = strtol (elements[1].c_str (), NULL, 10); int count = 0; @@ -329,8 +328,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value) if (ref.data.size () && size == 4 && elements[0] == "annotations" && elements[2] == "entry") { - std::map annos; - ref.getAnnotations (annos); + auto annos = ref.getAnnotations (); int a = strtol (elements[1].c_str (), NULL, 10); int count = 0; diff --git a/src/Task.cpp b/src/Task.cpp index 5ed1a2219..a6c82c5e6 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1081,13 +1081,14 @@ void Task::removeAnnotations () } //////////////////////////////////////////////////////////////////////////////// -void Task::getAnnotations (std::map & annotations) const +std::map Task::getAnnotations () const { - annotations.clear (); - + std::map a; for (auto& ann : data) if (! ann.first.compare (0, 11, "annotation_", 11)) - annotations.insert (ann); + a.insert (ann); + + return a; } //////////////////////////////////////////////////////////////////////////////// @@ -1357,8 +1358,7 @@ void Task::substitute ( // Get the data to modify. std::string description = get ("description"); - std::map annotations; - getAnnotations (annotations); + auto annotations = getAnnotations (); // Count the changes, so we know whether to proceed to annotations, after // modifying description. diff --git a/src/Task.h b/src/Task.h index c64e083e1..72939ad4a 100644 --- a/src/Task.h +++ b/src/Task.h @@ -129,7 +129,7 @@ public: void removeTag (const std::string&); bool hasAnnotations () const; - void getAnnotations (std::map &) const; + std::map getAnnotations () const; void setAnnotations (const std::map &); void addAnnotation (const std::string&); void removeAnnotations (); diff --git a/src/Variant.cpp b/src/Variant.cpp index 0bcdbe898..aac28b53e 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -874,10 +874,7 @@ bool Variant::operator_match (const Variant& other, const Task& task) const // in the annotations. if (left.source () == "description") { - std::map annotations; - task.getAnnotations (annotations); - - for (auto& a : annotations) + for (auto& a : task.getAnnotations ()) if (r.match (a.second)) return true; } @@ -909,10 +906,7 @@ bool Variant::operator_match (const Variant& other, const Task& task) const // in the annotations. if (left.source () == "description") { - std::map annotations; - task.getAnnotations (annotations); - - for (auto& a : annotations) + for (auto& a : task.getAnnotations ()) if (find (a.second, pattern, searchCaseSensitive) != std::string::npos) return true; } diff --git a/src/columns/ColDescription.cpp b/src/columns/ColDescription.cpp index 7706c861c..db7fa387c 100644 --- a/src/columns/ColDescription.cpp +++ b/src/columns/ColDescription.cpp @@ -102,9 +102,7 @@ void ColumnDescription::measure (Task& task, unsigned int& minimum, unsigned int if (min_anno > minimum) minimum = min_anno; - std::map annos; - task.getAnnotations (annos); - for (auto& i : annos) + for (auto& i : task.getAnnotations ()) { unsigned int len = min_anno + 1 + utf8_width (i.second); if (len > maximum) @@ -129,9 +127,7 @@ void ColumnDescription::measure (Task& task, unsigned int& minimum, unsigned int if (task.annotation_count) { auto min_anno = Datetime::length (_dateformat); - std::map annos; - task.getAnnotations (annos); - for (auto& i : annos) + for (auto& i : task.getAnnotations ()) maximum += min_anno + 1 + utf8_width (i.second); } } @@ -179,9 +175,7 @@ void ColumnDescription::render ( { if (task.annotation_count) { - std::map annos; - task.getAnnotations (annos); - for (const auto& i : annos) + for (const auto& i : task.getAnnotations ()) { Datetime dt (strtol (i.first.substr (11).c_str (), NULL, 10)); description += '\n' + std::string (_indent, ' ') + dt.toString (_dateformat) + ' ' + i.second; @@ -210,9 +204,7 @@ void ColumnDescription::render ( { if (task.annotation_count) { - std::map annos; - task.getAnnotations (annos); - for (const auto& i : annos) + for (const auto& i : task.getAnnotations ()) { Datetime dt (strtol (i.first.substr (11).c_str (), NULL, 10)); description += ' ' + dt.toString (_dateformat) + ' ' + i.second; diff --git a/src/commands/CmdDenotate.cpp b/src/commands/CmdDenotate.cpp index 7bd040aa5..3b9fd42db 100644 --- a/src/commands/CmdDenotate.cpp +++ b/src/commands/CmdDenotate.cpp @@ -90,8 +90,7 @@ int CmdDenotate::execute (std::string&) { Task before (task); - std::map annotations; - task.getAnnotations (annotations); + auto annotations = task.getAnnotations (); if (annotations.size () == 0) throw std::string (STRING_CMD_DENO_NONE); diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index a38d6403f..b669286c7 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -245,9 +245,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat) << "# " << STRING_EDIT_HEADER_14 << '\n' << "# " << STRING_EDIT_HEADER_15 << '\n'; - std::map annotations; - task.getAnnotations (annotations); - for (auto& anno : annotations) + for (auto& anno : task.getAnnotations ()) { Datetime dt (strtol (anno.first.substr (11).c_str (), NULL, 10)); before << " Annotation: " << dt.toString (dateformat) diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 7b8c5a047..3aeb4148a 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -134,9 +134,7 @@ int CmdInfo::execute (std::string& output) std::string description = task.get ("description"); int indent = context.config.getInteger ("indent.annotation"); - std::map annotations; - task.getAnnotations (annotations); - for (auto& anno : annotations) + for (auto& anno : task.getAnnotations ()) description += '\n' + std::string (indent, ' ') + Datetime (anno.first.substr (11)).toString (dateformatanno) diff --git a/src/commands/CmdStats.cpp b/src/commands/CmdStats.cpp index 84695e9fd..6942f3ea9 100644 --- a/src/commands/CmdStats.cpp +++ b/src/commands/CmdStats.cpp @@ -140,10 +140,7 @@ int CmdStats::execute (std::string& output) daysPending += (now.toEpoch () - entry) / 86400.0; descLength += task.get ("description").length (); - - std::map annotations; - task.getAnnotations (annotations); - annotationsT += annotations.size (); + annotationsT += task.getAnnotations ().size (); auto tags = task.getTags (); if (tags.size ()) diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index f9673d294..899a23eef 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -142,9 +142,7 @@ int CmdTimesheet::execute (std::string& output) std::string description = task.get ("description"); int indent = context.config.getInteger ("indent.annotation"); - std::map annotations; - task.getAnnotations (annotations); - for (auto& ann : annotations) + for (auto& ann : task.getAnnotations ()) description += '\n' + std::string (indent, ' ') + Datetime (ann.first.substr (11)).toString (context.config.get ("dateformat")) @@ -198,9 +196,7 @@ int CmdTimesheet::execute (std::string& output) std::string description = task.get ("description"); int indent = context.config.getInteger ("indent.annotation"); - std::map annotations; - task.getAnnotations (annotations); - for (auto& ann : annotations) + for (auto& ann : task.getAnnotations ()) description += '\n' + std::string (indent, ' ') + Datetime (ann.first.substr (11)).toString (context.config.get ("dateformat")) From 245ed39b78c6ce99ff8189c32082b729ec1b8cb2 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 16:15:24 -0500 Subject: [PATCH 35/44] Task: Improved method signature --- src/TDB2.cpp | 5 +---- src/Task.cpp | 26 ++++++++++++-------------- src/Task.h | 6 +++--- src/commands/CmdDiagnostics.cpp | 5 +---- src/commands/CmdEdit.cpp | 3 +-- src/dependency.cpp | 3 +-- src/feedback.cpp | 30 +++++++----------------------- 7 files changed, 26 insertions(+), 52 deletions(-) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 1961a8e9f..6e326cb2a 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -528,10 +528,7 @@ void TF2::dependency_scan () { if (left.has ("depends")) { - std::vector deps; - left.getDependencies (deps); - - for (auto& dep : deps) + for (auto& dep : left.getDependencyUUIDs ()) { for (auto& right : _tasks) { diff --git a/src/Task.cpp b/src/Task.cpp index a6c82c5e6..18d189981 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1186,35 +1186,33 @@ void Task::removeDependency (int id) } //////////////////////////////////////////////////////////////////////////////// -void Task::getDependencies (std::vector & all) const +std::vector Task::getDependencyIDs () const { - auto deps = split (get ("depends"), ','); - - all.clear (); - - for (auto& dep : deps) + std::vector all; + for (auto& dep : split (get ("depends"), ',')) all.push_back (context.tdb2.pending.id (dep)); + + return all; } //////////////////////////////////////////////////////////////////////////////// -void Task::getDependencies (std::vector & all) const +std::vector Task::getDependencyUUIDs () const { - all = split (get ("depends"), ','); + return split (get ("depends"), ','); } //////////////////////////////////////////////////////////////////////////////// -void Task::getDependencies (std::vector & all) const +std::vector Task::getDependencyTasks () const { - std::vector deps = split (get ("depends"), ','); - - all.clear (); - - for (auto& dep : deps) + std::vector all; + for (auto& dep : split (get ("depends"), ',')) { Task task; context.tdb2.get (dep, task); all.push_back (task); } + + return all; } #endif diff --git a/src/Task.h b/src/Task.h index 72939ad4a..cf2c7d076 100644 --- a/src/Task.h +++ b/src/Task.h @@ -141,9 +141,9 @@ public: #ifdef PRODUCT_TASKWARRIOR void removeDependency (int); void removeDependency (const std::string&); - void getDependencies (std::vector &) const; - void getDependencies (std::vector &) const; - void getDependencies (std::vector &) const; + std::vector getDependencyIDs () const; + std::vector getDependencyUUIDs () const; + std::vector getDependencyTasks () const; std::vector getUDAOrphanUUIDs () const; diff --git a/src/commands/CmdDiagnostics.cpp b/src/commands/CmdDiagnostics.cpp index 0e9789f64..2a5f6dd73 100644 --- a/src/commands/CmdDiagnostics.cpp +++ b/src/commands/CmdDiagnostics.cpp @@ -456,10 +456,7 @@ int CmdDiagnostics::execute (std::string& output) for (auto& task : all) { // Check dependencies - std::vector dependencies; - task.getDependencies(dependencies); - - for (auto& uuid : dependencies) + for (auto& uuid : task.getDependencyUUIDs ()) { if (! context.tdb2.has (uuid)) { diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index b669286c7..dbffde4a1 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -256,8 +256,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat) before << " Annotation: " << now.toString (dateformat) << " -- \n"; // Add dependencies here. - std::vector dependencies; - task.getDependencies (dependencies); + auto dependencies = task.getDependencyUUIDs (); std::stringstream allDeps; for (unsigned int i = 0; i < dependencies.size (); ++i) { diff --git a/src/dependency.cpp b/src/dependency.cpp index de4f6ee94..11f9f8346 100644 --- a/src/dependency.cpp +++ b/src/dependency.cpp @@ -82,8 +82,7 @@ bool dependencyIsCircular (const Task& task) while (! s.empty ()) { Task& current = s.top (); - std::vector deps_current; - current.getDependencies (deps_current); + auto deps_current = current.getDependencyUUIDs (); // This is a basic depth first search that always terminates given the // fact that we do not visit any task twice diff --git a/src/feedback.cpp b/src/feedback.cpp index bbb9e057b..dac344ade 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -84,8 +84,7 @@ std::string taskDifferences (const Task& before, const Task& after) { if (name == "depends") { - std::vector deps_after; - after.getDependencies (deps_after); + auto deps_after = after.getDependencyTasks (); out << " - " << format (STRING_FEEDBACK_DEP_SET, taskIdentifiers (deps_after)) @@ -110,12 +109,10 @@ std::string taskDifferences (const Task& before, const Task& after) { if (name == "depends") { - std::vector deps_before; - before.getDependencies (deps_before); + auto deps_before = before.getDependencyTasks (); std::string from = taskIdentifiers (deps_before); - std::vector deps_after; - after.getDependencies (deps_after); + auto deps_after = after.getDependencyTasks (); std::string to = taskIdentifiers (deps_after); out << " - " @@ -169,11 +166,7 @@ std::string taskInfoDifferences ( { if (name == "depends") { - std::vector deps_before; - before.getDependencies (deps_before); - std::string from = taskIdentifiers (deps_before); - - out << format (STRING_FEEDBACK_DEP_DEL, from) + out << format (STRING_FEEDBACK_DEP_DEL, taskIdentifiers (before.getDependencyTasks ())) << "\n"; } else if (name.substr (0, 11) == "annotation_") @@ -198,11 +191,7 @@ std::string taskInfoDifferences ( { if (name == "depends") { - std::vector deps_after; - after.getDependencies (deps_after); - std::string to = taskIdentifiers (deps_after); - - out << format (STRING_FEEDBACK_DEP_WAS_SET, to) + out << format (STRING_FEEDBACK_DEP_WAS_SET, taskIdentifiers (after.getDependencyTasks ())) << "\n"; } else if (name.substr (0, 11) == "annotation_") @@ -231,13 +220,8 @@ std::string taskInfoDifferences ( { if (name == "depends") { - std::vector deps_before; - before.getDependencies (deps_before); - std::string from = taskIdentifiers (deps_before); - - std::vector deps_after; - after.getDependencies (deps_after); - std::string to = taskIdentifiers (deps_after); + auto from = taskIdentifiers (before.getDependencyTasks ()); + auto to = taskIdentifiers (after.getDependencyTasks ()); out << format (STRING_FEEDBACK_DEP_WAS_MOD, from, to) << "\n"; From b0a4a409a6e6219ef0089c93c9a5cc49a48a8f30 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 31 Dec 2016 16:33:39 -0500 Subject: [PATCH 36/44] Task: Improved method signature --- ChangeLog | 3 +++ src/Task.cpp | 11 ++++------- src/Task.h | 20 ++++++++++---------- src/columns/ColDepends.cpp | 15 ++++----------- src/commands/CmdInfo.cpp | 6 ++---- src/dependency.cpp | 23 +++++++++++++---------- src/feedback.cpp | 6 ++---- src/main.h | 4 ++-- 8 files changed, 40 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ddc30066..bd0c6ca31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,9 @@ (thanks to Flavio Poletti). - TW-1857 Change Task::get call to the more efficient Task::has (thanks to Zachary Manning). +- TW‐1858 Change signature for dependencyGetBlocked +- TW-1859 Change signature of Task::getTags +- TW-1860 Change signature of Task::getAnnotations - TW-1873 Specify different path to extensions/hooks directory (thanks to Eli). - TW-1878 uuids subcommand produces a space-delimited list, not comma-delimited diff --git a/src/Task.cpp b/src/Task.cpp index 18d189981..48ac9a30c 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1865,19 +1865,16 @@ float Task::urgency () //////////////////////////////////////////////////////////////////////////////// float Task::urgency_inherit () const { + float v = FLT_MIN; +#ifdef PRODUCT_TASKWARRIOR // Calling dependencyGetBlocked is rather expensive. // It is called recursively for each dependency in the chain here. - std::vector blocked; -#ifdef PRODUCT_TASKWARRIOR - dependencyGetBlocked (*this, blocked); -#endif - - float v = FLT_MIN; - for (auto& task : blocked) + for (auto& task : dependencyGetBlocked (*this)) { // Find highest urgency in all blocked tasks. v = std::max (v, task.urgency ()); } +#endif return v; } diff --git a/src/Task.h b/src/Task.h index cf2c7d076..16a091575 100644 --- a/src/Task.h +++ b/src/Task.h @@ -170,17 +170,17 @@ private: const std::string decode (const std::string&) const; public: - float urgency_project () const; - float urgency_active () const; - float urgency_scheduled () const; - float urgency_waiting () const; - float urgency_blocked () const; - float urgency_inherit () const; + float urgency_project () const; + float urgency_active () const; + float urgency_scheduled () const; + float urgency_waiting () const; + float urgency_blocked () const; + float urgency_inherit () const; float urgency_annotations () const; - float urgency_tags () const; - float urgency_due () const; - float urgency_blocking () const; - float urgency_age () const; + float urgency_tags () const; + float urgency_due () const; + float urgency_blocking () const; + float urgency_age () const; }; #endif diff --git a/src/columns/ColDepends.cpp b/src/columns/ColDepends.cpp index 5cb752ac6..287045bb5 100644 --- a/src/columns/ColDepends.cpp +++ b/src/columns/ColDepends.cpp @@ -78,17 +78,14 @@ void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& ma else if (_style == "count") { - std::vector blocking; - dependencyGetBlocking (task, blocking); - minimum = maximum = 2 + format ((int) blocking.size ()).length (); + minimum = maximum = 2 + format ((int) dependencyGetBlocking (task).size ()).length (); } else if (_style == "default" || _style == "list") { minimum = maximum = 0; - std::vector blocking; - dependencyGetBlocking (task, blocking); + auto blocking = dependencyGetBlocking (task); std::vector blocking_ids; for (auto& i : blocking) @@ -126,17 +123,13 @@ void ColumnDepends::render ( else if (_style == "count") { - std::vector blocking; - dependencyGetBlocking (task, blocking); - - renderStringRight (lines, width, color, '[' + format (static_cast (blocking.size ())) + ']'); + renderStringRight (lines, width, color, '[' + format (static_cast (dependencyGetBlocking (task).size ())) + ']'); } else if (_style == "default" || _style == "list") { - std::vector blocking; - dependencyGetBlocking (task, blocking); + auto blocking = dependencyGetBlocking (task); std::vector blocking_ids; for (const auto& t : blocking) diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 3aeb4148a..60dc2dafc 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -160,8 +160,7 @@ int CmdInfo::execute (std::string& output) // dependencies: blocked { - std::vector blocked; - dependencyGetBlocking (task, blocked); + auto blocked = dependencyGetBlocking (task); if (blocked.size ()) { std::stringstream message; @@ -176,8 +175,7 @@ int CmdInfo::execute (std::string& output) // dependencies: blocking { - std::vector blocking; - dependencyGetBlocked (task, blocking); + auto blocking = dependencyGetBlocked (task); if (blocking.size ()) { std::stringstream message; diff --git a/src/dependency.cpp b/src/dependency.cpp index 11f9f8346..04af7b362 100644 --- a/src/dependency.cpp +++ b/src/dependency.cpp @@ -38,29 +38,35 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// -void dependencyGetBlocked (const Task& task, std::vector & blocked) +std::vector dependencyGetBlocked (const Task& task) { std::string uuid = task.get ("uuid"); - auto all = context.tdb2.pending.get_tasks (); - for (auto& it : all) + std::vector blocked; + for (auto& it : context.tdb2.pending.get_tasks ()) if (it.getStatus () != Task::completed && it.getStatus () != Task::deleted && it.has ("depends") && it.get ("depends").find (uuid) != std::string::npos) blocked.push_back (it); + + return blocked; } //////////////////////////////////////////////////////////////////////////////// -void dependencyGetBlocking (const Task& task, std::vector & blocking) +std::vector dependencyGetBlocking (const Task& task) { std::string depends = task.get ("depends"); + std::vector blocking; + if (depends != "") for (auto& it : context.tdb2.pending.get_tasks ()) if (it.getStatus () != Task::completed && it.getStatus () != Task::deleted && depends.find (it.get ("uuid")) != std::string::npos) blocking.push_back (it); + + return blocking; } //////////////////////////////////////////////////////////////////////////////// @@ -145,14 +151,12 @@ bool dependencyIsCircular (const Task& task) // void dependencyChainOnComplete (Task& task) { - std::vector blocking; - dependencyGetBlocking (task, blocking); + auto blocking = dependencyGetBlocking (task); // If the task is anything but the tail end of a dependency chain. if (blocking.size ()) { - std::vector blocked; - dependencyGetBlocked (task, blocked); + auto blocked = dependencyGetBlocked (task); // Nag about broken chain. if (context.config.getBoolean ("dependency.reminder")) @@ -205,8 +209,7 @@ void dependencyChainOnStart (Task& task) { if (context.config.getBoolean ("dependency.reminder")) { - std::vector blocking; - dependencyGetBlocking (task, blocking); + auto blocking = dependencyGetBlocking (task); // If the task is anything but the tail end of a dependency chain, nag about // broken chain. diff --git a/src/feedback.cpp b/src/feedback.cpp index dac344ade..ba1b2d2b2 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -381,14 +381,12 @@ void feedback_unblocked (const Task& task) if (context.verbose ("affected")) { // Get a list of tasks that depended on this task. - std::vector blocked; - dependencyGetBlocked (task, blocked); + auto blocked = dependencyGetBlocked (task); // Scan all the tasks that were blocked by this task for (auto& i : blocked) { - std::vector blocking; - dependencyGetBlocking (i, blocking); + auto blocking = dependencyGetBlocking (i); if (blocking.size () == 0) { if (i.id) diff --git a/src/main.h b/src/main.h index 8856e05ce..e66cb2798 100644 --- a/src/main.h +++ b/src/main.h @@ -52,8 +52,8 @@ std::string colorizeError (const std::string&); std::string colorizeDebug (const std::string&); // dependency.cpp -void dependencyGetBlocked (const Task&, std::vector &); -void dependencyGetBlocking (const Task&, std::vector &); +std::vector dependencyGetBlocked (const Task&); +std::vector dependencyGetBlocking (const Task&); bool dependencyIsCircular (const Task&); void dependencyChainOnComplete (Task&); void dependencyChainOnStart (Task&); From e871976bb93c8fcc9a7ea8d1e55371f6c11fdd4d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Jan 2017 10:46:40 -0500 Subject: [PATCH 37/44] Columns: Consistency --- src/columns/ColIMask.cpp | 1 - src/columns/ColLast.cpp | 1 - src/columns/ColParent.cpp | 1 - src/columns/ColProject.cpp | 1 - src/columns/ColRecur.cpp | 1 - src/columns/ColStart.cpp | 3 ++- src/columns/ColTags.cpp | 1 - src/columns/ColTemplate.cpp | 1 - src/columns/ColTypeDate.cpp | 1 - src/columns/ColUDA.cpp | 4 ---- src/columns/Column.cpp | 2 +- 11 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/columns/ColIMask.cpp b/src/columns/ColIMask.cpp index ee17436f3..3d2a905cc 100644 --- a/src/columns/ColIMask.cpp +++ b/src/columns/ColIMask.cpp @@ -45,7 +45,6 @@ ColumnIMask::ColumnIMask () void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { minimum = maximum = task.get (_name).length (); diff --git a/src/columns/ColLast.cpp b/src/columns/ColLast.cpp index 7adecaabc..3e74fb8e4 100644 --- a/src/columns/ColLast.cpp +++ b/src/columns/ColLast.cpp @@ -45,7 +45,6 @@ ColumnLast::ColumnLast () void ColumnLast::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { minimum = maximum = task.get (_name).length (); diff --git a/src/columns/ColParent.cpp b/src/columns/ColParent.cpp index 38518681f..a58a39a2e 100644 --- a/src/columns/ColParent.cpp +++ b/src/columns/ColParent.cpp @@ -45,7 +45,6 @@ ColumnParent::ColumnParent () void ColumnParent::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { if (_style == "default" || _style == "long") minimum = maximum = 36; diff --git a/src/columns/ColProject.cpp b/src/columns/ColProject.cpp index 069563db8..1da64525d 100644 --- a/src/columns/ColProject.cpp +++ b/src/columns/ColProject.cpp @@ -59,7 +59,6 @@ ColumnProject::ColumnProject () void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { std::string project = task.get (_name); diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index f1cf833fc..bcf7db6ae 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -68,7 +68,6 @@ void ColumnRecur::setStyle (const std::string& value) void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { if (_style == "default" || diff --git a/src/columns/ColStart.cpp b/src/columns/ColStart.cpp index 3bb6a9ed3..6760a4227 100644 --- a/src/columns/ColStart.cpp +++ b/src/columns/ColStart.cpp @@ -58,13 +58,14 @@ void ColumnStart::setStyle (const std::string& value) void ColumnStart::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { if (_style == "active") minimum = maximum = utf8_width (context.config.get ("active.indicator")); else ColumnTypeDate::measure (task, minimum, maximum); + + // TODO Throw on bad format. } } diff --git a/src/columns/ColTags.cpp b/src/columns/ColTags.cpp index 246c7ee3b..b044bb827 100644 --- a/src/columns/ColTags.cpp +++ b/src/columns/ColTags.cpp @@ -75,7 +75,6 @@ void ColumnTags::setStyle (const std::string& value) void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { if (_style == "indicator") diff --git a/src/columns/ColTemplate.cpp b/src/columns/ColTemplate.cpp index f9168525f..6a392d39e 100644 --- a/src/columns/ColTemplate.cpp +++ b/src/columns/ColTemplate.cpp @@ -45,7 +45,6 @@ ColumnTemplate::ColumnTemplate () 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; diff --git a/src/columns/ColTypeDate.cpp b/src/columns/ColTypeDate.cpp index 869f94483..c1675a14c 100644 --- a/src/columns/ColTypeDate.cpp +++ b/src/columns/ColTypeDate.cpp @@ -72,7 +72,6 @@ ColumnTypeDate::ColumnTypeDate () void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { Datetime date (task.get_date (_name)); diff --git a/src/columns/ColUDA.cpp b/src/columns/ColUDA.cpp index 83c8ab38e..60faa1e20 100644 --- a/src/columns/ColUDA.cpp +++ b/src/columns/ColUDA.cpp @@ -71,7 +71,6 @@ bool ColumnUDAString::validate (const std::string& value) const void ColumnUDAString::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { if (_style == "default") @@ -159,7 +158,6 @@ bool ColumnUDANumeric::validate (const std::string& value) const void ColumnUDANumeric::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { if (_style == "default") @@ -239,7 +237,6 @@ bool ColumnUDADate::validate (const std::string& value) const void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { if (_style == "default") @@ -345,7 +342,6 @@ bool ColumnUDADuration::validate (const std::string& value) const void ColumnUDADuration::measure (Task& task, unsigned int& minimum, unsigned int& maximum) { minimum = maximum = 0; - if (task.has (_name)) { if (_style == "default") diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index ee105d36f..29766ec96 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -154,7 +154,7 @@ void Column::factory (std::map & all) //////////////////////////////////////////////////////////////////////////////// void Column::uda (std::map & all) { - // For each UDA, instantiate and initialize ColumnUDA(). + // For each UDA, instantiate and initialize ColumnUDA. std::set udas; for (const auto& i : context.config) From ebd6273c86b5ab8431ce20c0ea25debf1bc69cd3 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Jan 2017 11:04:08 -0500 Subject: [PATCH 38/44] Columns: Attribute objects properly delegate to Column::setStyle to validate formats --- src/columns/ColDepends.cpp | 2 +- src/columns/ColEntry.cpp | 2 +- src/columns/ColRType.cpp | 2 +- src/columns/ColRecur.cpp | 2 +- src/columns/ColScheduled.cpp | 2 +- src/columns/ColStart.cpp | 2 +- src/columns/ColStatus.cpp | 2 +- src/columns/ColTags.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/columns/ColDepends.cpp b/src/columns/ColDepends.cpp index 287045bb5..75b055a60 100644 --- a/src/columns/ColDepends.cpp +++ b/src/columns/ColDepends.cpp @@ -58,7 +58,7 @@ ColumnDepends::ColumnDepends () // Note that you can not determine which gets called first. void ColumnDepends::setStyle (const std::string& value) { - _style = value; + Column::setStyle (value); if (_style == "indicator" && _label == STRING_COLUMN_LABEL_DEP) _label = _label.substr (0, context.config.get ("dependency.indicator").length ()); else if (_style == "count" && _label == STRING_COLUMN_LABEL_DEP) _label = STRING_COLUMN_LABEL_DEP_S; diff --git a/src/columns/ColEntry.cpp b/src/columns/ColEntry.cpp index c78a76171..2bdf0890d 100644 --- a/src/columns/ColEntry.cpp +++ b/src/columns/ColEntry.cpp @@ -41,7 +41,7 @@ ColumnEntry::ColumnEntry () // Note that you can not determine which gets called first. void ColumnEntry::setStyle (const std::string& value) { - _style = value; + Column::setStyle (value); if (_style == "age" && _label == STRING_COLUMN_LABEL_ADDED) diff --git a/src/columns/ColRType.cpp b/src/columns/ColRType.cpp index 1d0e2d9be..e9e2d9ac5 100644 --- a/src/columns/ColRType.cpp +++ b/src/columns/ColRType.cpp @@ -50,7 +50,7 @@ ColumnRType::ColumnRType () // Note that you can not determine which gets called first. void ColumnRType::setStyle (const std::string& value) { - _style = value; + Column::setStyle (value); if (_style == "indicator" && _label == STRING_COLUMN_LABEL_RTYPE) _label = _label.substr (0, context.config.get ("rtype.indicator").length ()); diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index bcf7db6ae..ea4d10018 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -57,7 +57,7 @@ ColumnRecur::ColumnRecur () // Note that you can not determine which gets called first. void ColumnRecur::setStyle (const std::string& value) { - _style = value; + Column::setStyle (value); if (_style == "indicator" && _label == STRING_COLUMN_LABEL_RECUR) _label = _label.substr (0, context.config.get ("recurrence.indicator").length ()); diff --git a/src/columns/ColScheduled.cpp b/src/columns/ColScheduled.cpp index 40e51a666..646ebd0e4 100644 --- a/src/columns/ColScheduled.cpp +++ b/src/columns/ColScheduled.cpp @@ -40,7 +40,7 @@ ColumnScheduled::ColumnScheduled () // Note that you can not determine which gets called first. void ColumnScheduled::setStyle (const std::string& value) { - _style = value; + Column::setStyle (value); if (_style == "countdown" && _label == STRING_COLUMN_LABEL_SCHED) _label = STRING_COLUMN_LABEL_COUNT; diff --git a/src/columns/ColStart.cpp b/src/columns/ColStart.cpp index 6760a4227..7606fefad 100644 --- a/src/columns/ColStart.cpp +++ b/src/columns/ColStart.cpp @@ -47,7 +47,7 @@ ColumnStart::ColumnStart () // Note that you can not determine which gets called first. void ColumnStart::setStyle (const std::string& value) { - _style = value; + Column::setStyle (value); if (_style == "active" && _label == STRING_COLUMN_LABEL_STARTED) _label = STRING_COLUMN_LABEL_ACTIVE; diff --git a/src/columns/ColStatus.cpp b/src/columns/ColStatus.cpp index ef403bd00..2e5af0cbe 100644 --- a/src/columns/ColStatus.cpp +++ b/src/columns/ColStatus.cpp @@ -46,7 +46,7 @@ ColumnStatus::ColumnStatus () // Note that you can not determine which gets called first. void ColumnStatus::setStyle (const std::string& value) { - _style = value; + Column::setStyle (value); if (_style == "short" && _label == STRING_COLUMN_LABEL_STATUS) _label = STRING_COLUMN_LABEL_STAT; diff --git a/src/columns/ColTags.cpp b/src/columns/ColTags.cpp index b044bb827..6684b331b 100644 --- a/src/columns/ColTags.cpp +++ b/src/columns/ColTags.cpp @@ -59,7 +59,7 @@ ColumnTags::ColumnTags () // Note that you can not determine which gets called first. void ColumnTags::setStyle (const std::string& value) { - _style = value; + Column::setStyle (value); if (_style == "indicator" && _label == STRING_COLUMN_LABEL_TAGS) From 09562c8facbc888ef3c6693c6d46fc12c0d615df Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Jan 2017 11:10:03 -0500 Subject: [PATCH 39/44] Columns: Removed redundant format checking --- src/columns/ColDepends.cpp | 2 -- src/columns/ColDescription.cpp | 3 --- src/columns/ColID.cpp | 4 ---- src/columns/ColIMask.cpp | 6 ------ src/columns/ColLast.cpp | 6 ------ src/columns/ColMask.cpp | 5 ----- src/columns/ColParent.cpp | 2 -- src/columns/ColProject.cpp | 4 ---- src/columns/ColRType.cpp | 2 -- src/columns/ColRecur.cpp | 2 -- src/columns/ColStatus.cpp | 2 -- src/columns/ColTags.cpp | 2 -- src/columns/ColTemplate.cpp | 2 -- src/columns/ColTypeDate.cpp | 2 -- src/columns/ColUDA.cpp | 8 -------- src/columns/ColUUID.cpp | 2 -- src/columns/ColUrgency.cpp | 3 --- 17 files changed, 57 deletions(-) diff --git a/src/columns/ColDepends.cpp b/src/columns/ColDepends.cpp index 75b055a60..c2fbe6d36 100644 --- a/src/columns/ColDepends.cpp +++ b/src/columns/ColDepends.cpp @@ -102,8 +102,6 @@ void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& ma minimum = length; } } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } diff --git a/src/columns/ColDescription.cpp b/src/columns/ColDescription.cpp index db7fa387c..940ebc7bb 100644 --- a/src/columns/ColDescription.cpp +++ b/src/columns/ColDescription.cpp @@ -153,9 +153,6 @@ void ColumnDescription::measure (Task& task, unsigned int& minimum, unsigned int minimum = 4; maximum = utf8_width (description) + 1 + 1 + format (task.annotation_count).length () + 1; } - - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColID.cpp b/src/columns/ColID.cpp index c47d2ea4f..b11980593 100644 --- a/src/columns/ColID.cpp +++ b/src/columns/ColID.cpp @@ -55,10 +55,6 @@ void ColumnID::measure (Task& task, unsigned int& minimum, unsigned int& maximum else length = 1 + (int) log10 ((double) task.id); // Slow minimum = maximum = length; - - if (_style != "default" && - _style != "number") - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColIMask.cpp b/src/columns/ColIMask.cpp index 3d2a905cc..a267371c6 100644 --- a/src/columns/ColIMask.cpp +++ b/src/columns/ColIMask.cpp @@ -46,13 +46,7 @@ void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maxi { minimum = maximum = 0; if (task.has (_name)) - { minimum = maximum = task.get (_name).length (); - - if (_style != "default" && - _style != "number") - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); - } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColLast.cpp b/src/columns/ColLast.cpp index 3e74fb8e4..71e49b82d 100644 --- a/src/columns/ColLast.cpp +++ b/src/columns/ColLast.cpp @@ -46,13 +46,7 @@ void ColumnLast::measure (Task& task, unsigned int& minimum, unsigned int& maxim { minimum = maximum = 0; if (task.has (_name)) - { minimum = maximum = task.get (_name).length (); - - if (_style != "default" && - _style != "number") - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); - } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColMask.cpp b/src/columns/ColMask.cpp index d7a82e256..97e14753a 100644 --- a/src/columns/ColMask.cpp +++ b/src/columns/ColMask.cpp @@ -46,12 +46,7 @@ void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maxim { minimum = maximum = 0; if (task.has (_name)) - { minimum = maximum = task.get (_name).length (); - - if (_style != "default") - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); - } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColParent.cpp b/src/columns/ColParent.cpp index a58a39a2e..614b375de 100644 --- a/src/columns/ColParent.cpp +++ b/src/columns/ColParent.cpp @@ -49,8 +49,6 @@ void ColumnParent::measure (Task& task, unsigned int& minimum, unsigned int& max { if (_style == "default" || _style == "long") minimum = maximum = 36; else if (_style == "short") minimum = maximum = 8; - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } diff --git a/src/columns/ColProject.cpp b/src/columns/ColProject.cpp index 1da64525d..cfdf3ef15 100644 --- a/src/columns/ColProject.cpp +++ b/src/columns/ColProject.cpp @@ -73,10 +73,6 @@ void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& ma { project = indentProject (project, " ", '.'); } - else if (_style != "default" && - _style != "full" && - _style != "indented") - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); minimum = longestWord (project); maximum = utf8_width (project); diff --git a/src/columns/ColRType.cpp b/src/columns/ColRType.cpp index e9e2d9ac5..96968c32e 100644 --- a/src/columns/ColRType.cpp +++ b/src/columns/ColRType.cpp @@ -67,8 +67,6 @@ void ColumnRType::measure (Task& task, unsigned int& minimum, unsigned int& maxi minimum = maximum = task.get (_name).length (); else if (_style == "indicator") minimum = maximum = 1; - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index ea4d10018..159e4a5d7 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -79,8 +79,6 @@ void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maxi { minimum = maximum = utf8_width (context.config.get ("recurrence.indicator")); } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } diff --git a/src/columns/ColStatus.cpp b/src/columns/ColStatus.cpp index 2e5af0cbe..4dec53c19 100644 --- a/src/columns/ColStatus.cpp +++ b/src/columns/ColStatus.cpp @@ -74,8 +74,6 @@ void ColumnStatus::measure (Task& task, unsigned int& minimum, unsigned int& max } else if (_style == "short") minimum = maximum = 1; - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColTags.cpp b/src/columns/ColTags.cpp index 6684b331b..1f11c1df8 100644 --- a/src/columns/ColTags.cpp +++ b/src/columns/ColTags.cpp @@ -108,8 +108,6 @@ void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maxim else minimum = maximum = utf8_width (tags); } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } diff --git a/src/columns/ColTemplate.cpp b/src/columns/ColTemplate.cpp index 6a392d39e..f25e8660b 100644 --- a/src/columns/ColTemplate.cpp +++ b/src/columns/ColTemplate.cpp @@ -49,8 +49,6 @@ void ColumnTemplate::measure (Task& task, unsigned int& minimum, unsigned int& m { if (_style == "default" || _style == "long") minimum = maximum = 36; else if (_style == "short") minimum = maximum = 8; - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } diff --git a/src/columns/ColTypeDate.cpp b/src/columns/ColTypeDate.cpp index c1675a14c..b239a264c 100644 --- a/src/columns/ColTypeDate.cpp +++ b/src/columns/ColTypeDate.cpp @@ -130,8 +130,6 @@ void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& m if (date > now) minimum = maximum = Duration (date - now).formatVague ().length (); } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } diff --git a/src/columns/ColUDA.cpp b/src/columns/ColUDA.cpp index 60faa1e20..4723e984f 100644 --- a/src/columns/ColUDA.cpp +++ b/src/columns/ColUDA.cpp @@ -91,8 +91,6 @@ void ColumnUDAString::measure (Task& task, unsigned int& minimum, unsigned int& minimum = maximum = utf8_width (indicator); } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } @@ -174,8 +172,6 @@ void ColumnUDANumeric::measure (Task& task, unsigned int& minimum, unsigned int& minimum = maximum = utf8_width (indicator); } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } @@ -266,8 +262,6 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma minimum = maximum = utf8_width (indicator); } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } @@ -363,8 +357,6 @@ void ColumnUDADuration::measure (Task& task, unsigned int& minimum, unsigned int else minimum = maximum = 0; } - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } } diff --git a/src/columns/ColUUID.cpp b/src/columns/ColUUID.cpp index aea498bf3..ad734834d 100644 --- a/src/columns/ColUUID.cpp +++ b/src/columns/ColUUID.cpp @@ -48,8 +48,6 @@ void ColumnUUID::measure (Task&, unsigned int& minimum, unsigned int& maximum) if (_style == "default" || _style == "long") minimum = maximum = 36; else if (_style == "short") minimum = maximum = 8; - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColUrgency.cpp b/src/columns/ColUrgency.cpp index 8ee23ef95..64b5d887b 100644 --- a/src/columns/ColUrgency.cpp +++ b/src/columns/ColUrgency.cpp @@ -49,9 +49,6 @@ void ColumnUrgency::measure (Task& task, unsigned int& minimum, unsigned int& ma else if (_style == "integer") minimum = maximum = format ((int)task.urgency ()).length (); - - else - throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } //////////////////////////////////////////////////////////////////////////////// From 8049c8ba99c785adf0230bf47ce03ea159142354 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Jan 2017 11:46:35 -0500 Subject: [PATCH 40/44] feddback: Added TEMPLATE and INSTANCE virtual tags --- NEWS | 1 + src/feedback.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 1ecb47ad9..31f2b37b2 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,7 @@ Newly Deprecated Features in Taskwarrior 2.6.0 - The use of alternate Boolean configuration settings is deprecated. Use values "0" for off, and "1" for on. Avoid used of "on", "off", "true", "t", "false", "f", "yes", "y", "no", "n". + - The 'PARENT' and 'CHILD' virtual tags are replaced by 'TEMPLATE' and 'INSTANCE'. Removed Features in 2.6.0 diff --git a/src/feedback.cpp b/src/feedback.cpp index ba1b2d2b2..cb6ed9264 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -318,22 +318,24 @@ void feedback_reserved_tags (const std::string& tag) tag == "ANNOTATED" || tag == "BLOCKED" || tag == "BLOCKING" || - tag == "CHILD" || + tag == "CHILD" || // Deprecated 2.6.0 tag == "COMPLETED" || tag == "DELETED" || tag == "DUE" || tag == "DUETODAY" || + tag == "INSTANCE" || tag == "LATEST" || tag == "MONTH" || tag == "ORPHAN" || tag == "OVERDUE" || - tag == "PARENT" || + tag == "PARENT" || // Deprecated 2.6.0 tag == "PENDING" || tag == "PRIORITY" || tag == "PROJECT" || tag == "READY" || tag == "SCHEDULED" || tag == "TAGGED" || + tag == "TEMPLATE" || tag == "TODAY" || tag == "TOMORROW" || tag == "UDA" || From b266dc3f2d2cf8227f59b72a28f6b100e7847a13 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Jan 2017 11:49:09 -0500 Subject: [PATCH 41/44] Docs: Added TEMPLATE and INSTANCE virtual tag descriptions --- doc/man/task.1.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/man/task.1.in b/doc/man/task.1.in index f7d4e0c40..ac43d2c4d 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -677,15 +677,16 @@ are: ANNOTATED Matches if the task has annotations BLOCKED Matches if the task is blocked BLOCKING Matches if the task is blocking - CHILD Matches if the task has a parent + CHILD Matches if the task has a parent (deprecated in 2.6.0) COMPLETED Matches if the task has completed status DELETED Matches if the task has deleted status DUE Matches if the task is due + INSTANCE Matches if the task is a recurrent instance LATEST Matches if the task is the newest added task MONTH Matches if the task is due this month ORPHAN Matches if the task has any orphaned UDA values OVERDUE Matches if the task is overdue - PARENT Matches if the task is a parent + PARENT Matches if the task is a parent (deprecated in 2.6.0) PENDING Matches if the task has pending status PRIORITY Matches if the task has a priority PROJECT Matches if the task has a project @@ -693,6 +694,7 @@ are: READY Matches if the task is actionable SCHEDULED Matches if the task is scheduled TAGGED Matches if the task has tags + TEMPLATE Matches if the task is a recurrence template TODAY Matches if the task is due today TOMORROW Matches if the task is due sometime tomorrow UDA Matches if the task has any UDA values From f12a4d7cd6a5a1a38ff32a97c8b7fae4562dfc45 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Jan 2017 12:00:53 -0500 Subject: [PATCH 42/44] Task: Added TEMPLATE and INSTANCE virtual tags --- src/Task.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Task.cpp b/src/Task.cpp index 48ac9a30c..d3f83f2c2 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1259,11 +1259,13 @@ bool Task::hasTag (const std::string& tag) const #endif if (tag == "ACTIVE") return has ("start"); if (tag == "SCHEDULED") return has ("scheduled"); - if (tag == "CHILD") return has ("parent"); + if (tag == "CHILD") return has ("parent"); // 2017-01-07: Deprecated in 2.6.0 + if (tag == "INSTANCE") return has ("template"); if (tag == "UNTIL") return has ("until"); if (tag == "ANNOTATED") return hasAnnotations (); if (tag == "TAGGED") return has ("tags"); - if (tag == "PARENT") return has ("mask"); + if (tag == "PARENT") return has ("mask"); // 2017-01-07: Deprecated in 2.6.0 + if (tag == "TEMPLATE") return has ("last"); if (tag == "WAITING") return get ("status") == "waiting"; if (tag == "PENDING") return get ("status") == "pending"; if (tag == "COMPLETED") return get ("status") == "completed"; From 9939b7ea3559c9be1b8241041382242c2e41cf68 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Jan 2017 12:02:03 -0500 Subject: [PATCH 43/44] CmdTags: Added TEMPLATE and INSTANCE virtual tags --- src/commands/CmdTags.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commands/CmdTags.cpp b/src/commands/CmdTags.cpp index a27f8fc4b..63e89c4a8 100644 --- a/src/commands/CmdTags.cpp +++ b/src/commands/CmdTags.cpp @@ -191,19 +191,21 @@ int CmdCompletionTags::execute (std::string& output) unique["ANNOTATED"] = 0; unique["BLOCKED"] = 0; unique["BLOCKING"] = 0; - unique["CHILD"] = 0; + unique["CHILD"] = 0; // 2017-01-07: Deprecated in 2.6.0 unique["COMPLETED"] = 0; unique["DELETED"] = 0; unique["DUE"] = 0; unique["DUETODAY"] = 0; + unique["INSTANCE"] = 0; unique["MONTH"] = 0; unique["ORPHAN"] = 0; unique["OVERDUE"] = 0; - unique["PARENT"] = 0; + unique["PARENT"] = 0; // 2017-01-07: Deprecated in 2.6.0 unique["PENDING"] = 0; unique["READY"] = 0; unique["SCHEDULED"] = 0; unique["TAGGED"] = 0; + unique["TEMPLATE"] = 0; unique["TODAY"] = 0; unique["TOMORROW"] = 0; unique["UDA"] = 0; From fd4ca4758186f5aad9aa7b91357de4d3a4bc30ee Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Jan 2017 12:04:13 -0500 Subject: [PATCH 44/44] CmdInfo: Added TEMPLATE and INSTANCE virtual tags --- src/commands/CmdInfo.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 60dc2dafc..5f45ac20e 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -197,6 +197,7 @@ int CmdInfo::execute (std::string& output) } // parent + // 2017-01-07: Deprecated in 2.6.0 if (task.has ("parent")) { row = view.addRow (); @@ -205,6 +206,7 @@ int CmdInfo::execute (std::string& output) } // mask + // 2017-01-07: Deprecated in 2.6.0 if (task.has ("mask")) { row = view.addRow (); @@ -213,6 +215,7 @@ int CmdInfo::execute (std::string& output) } // imask + // 2017-01-07: Deprecated in 2.6.0 if (task.has ("imask")) { row = view.addRow (); @@ -220,6 +223,30 @@ int CmdInfo::execute (std::string& output) view.set (row, 1, task.get ("imask")); } + // template + if (task.has ("template")) + { + row = view.addRow (); + view.set (row, 0, STRING_COLUMN_LABEL_TEMPLATE); + view.set (row, 1, task.get ("template")); + } + + // last + if (task.has ("last")) + { + row = view.addRow (); + view.set (row, 0, STRING_COLUMN_LABEL_LAST); + view.set (row, 1, task.get ("last")); + } + + // rtype + if (task.has ("rtype")) + { + row = view.addRow (); + view.set (row, 0, STRING_COLUMN_LABEL_RTYPE); + view.set (row, 1, task.get ("rtype")); + } + // entry row = view.addRow (); view.set (row, 0, STRING_COLUMN_LABEL_ENTERED); @@ -315,19 +342,21 @@ int CmdInfo::execute (std::string& output) if (task.hasTag ("ANNOTATED")) virtualTags += "ANNOTATED "; if (task.hasTag ("BLOCKED")) virtualTags += "BLOCKED "; if (task.hasTag ("BLOCKING")) virtualTags += "BLOCKING "; - if (task.hasTag ("CHILD")) virtualTags += "CHILD "; + if (task.hasTag ("CHILD")) virtualTags += "CHILD "; // 2017-01-07: Deprecated in 2.6.0 if (task.hasTag ("COMPLETED")) virtualTags += "COMPLETED "; if (task.hasTag ("DELETED")) virtualTags += "DELETED "; if (task.hasTag ("DUE")) virtualTags += "DUE "; if (task.hasTag ("DUETODAY")) virtualTags += "DUETODAY "; + if (task.hasTag ("INSTANCE")) virtualTags += "INSTANCE "; if (task.hasTag ("MONTH")) virtualTags += "MONTH "; if (task.hasTag ("ORPHAN")) virtualTags += "ORPHAN "; if (task.hasTag ("OVERDUE")) virtualTags += "OVERDUE "; - if (task.hasTag ("PARENT")) virtualTags += "PARENT "; + if (task.hasTag ("PARENT")) virtualTags += "PARENT "; // 2017-01-07: Deprecated in 2.6.0 if (task.hasTag ("PENDING")) virtualTags += "PENDING "; if (task.hasTag ("READY")) virtualTags += "READY "; if (task.hasTag ("SCHEDULED")) virtualTags += "SCHEDULED "; if (task.hasTag ("TAGGED")) virtualTags += "TAGGED "; + if (task.hasTag ("TEMPLATE")) virtualTags += "TEMPLATE "; if (task.hasTag ("TODAY")) virtualTags += "TODAY "; if (task.hasTag ("TOMORROW")) virtualTags += "TOMORROW "; if (task.hasTag ("UDA")) virtualTags += "UDA ";