From f39120dd73e0de9511bc0965f48cad26b1b1f05a Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 14 Jun 2013 14:42:08 -0400 Subject: [PATCH] Integrated Priority column modification to the ColPriority object, from Task core. --- ChangeLog | 5 +++++ src/Task.cpp | 18 +++++++++++------- src/columns/ColPriority.cpp | 12 ++++++++++++ src/columns/ColPriority.h | 2 ++ src/columns/Column.cpp | 14 ++++++++++++++ src/columns/Column.h | 2 ++ 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65a27263d..a34fd80c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,11 @@ Features + The 'debug.tls' configuration variable takes an integer which corresponds to the GnuTLS log level. For debugging. + File format 2 (used in version 0.9.3 - 1.5.0) is no longer supported. + + Migrated column processing code into Task.cpp for future use within each + individual column object. Legacy code left in Task.cpp for column objects + that are not yet modified. + + ColPriority.cpp - Migration of column modification code out of Task.cpp and + into the individual column object. Bugs + #1196 Now builds on Hurd (thanks to Jakub Wilk). diff --git a/src/Task.cpp b/src/Task.cpp index 10ae25f0c..067920a1f 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1804,12 +1804,6 @@ void Task::modify ( } } - // Priorities are converted to upper case. - else if (name == "priority") - { - (*this).set (name, upperCase (value)); - } - // Dates are special, maybe. else if (column->type () == "date") { @@ -1879,9 +1873,19 @@ void Task::modify ( throw format (STRING_UDA_NUMERIC, result); } - // By default, just add/remove it. + // Try to use modify method, otherwise just continue to the final option. + else if (column->can_modify ()) + { + // column->modify () contains the logic for the specific column + // and returns the appropriate value for (*this).set () + if (column->validate (value)) + (*this).set (name, column->modify (value)); + else + throw format (STRING_INVALID_MOD, name, value); + } else { + // Final default action if (column->validate (value)) (*this).set (name, value); else diff --git a/src/columns/ColPriority.cpp b/src/columns/ColPriority.cpp index 6dd1bc8ef..0309c7e89 100644 --- a/src/columns/ColPriority.cpp +++ b/src/columns/ColPriority.cpp @@ -119,3 +119,15 @@ void ColumnPriority::render ( } //////////////////////////////////////////////////////////////////////////////// +std::string ColumnPriority::modify (std::string& value) +{ + return upperCase (value); +} + +//////////////////////////////////////////////////////////////////////////////// +bool ColumnPriority::can_modify () +{ + return true; +} + +//////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/src/columns/ColPriority.h b/src/columns/ColPriority.h index fe107e8f5..8209cd2f7 100644 --- a/src/columns/ColPriority.h +++ b/src/columns/ColPriority.h @@ -44,6 +44,8 @@ public: void setStyle (const std::string&); void measure (Task&, unsigned int&, unsigned int&); void render (std::vector &, Task&, int, Color&); + std::string modify (std::string&); + bool can_modify (); private: }; diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index 13be73a29..61f6c7850 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -323,3 +323,17 @@ void Column::render (std::vector &, Task&, int, Color&) } //////////////////////////////////////////////////////////////////////////////// +// No L10N. +bool Column::can_modify () +{ + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +// No L10N. +std::string Column::modify (std::string& value) +{ + throw std::string ("Virtual method Column::modify not overridden."); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.h b/src/columns/Column.h index 6221cebad..b97930fc8 100644 --- a/src/columns/Column.h +++ b/src/columns/Column.h @@ -64,6 +64,8 @@ public: 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 can_modify (); + virtual std::string modify (std::string&); protected: std::string _name;