From 9268e552d8e4be4329d738a667e5d1bdb246422d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 5 May 2011 19:55:00 -0400 Subject: [PATCH] View - Integrated new longestWord helper function. --- src/columns/ColDescription.cpp | 26 +++++--------------------- src/columns/ColProject.cpp | 11 +---------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/columns/ColDescription.cpp b/src/columns/ColDescription.cpp index 8d3dcb4ad..0fcbd46bf 100644 --- a/src/columns/ColDescription.cpp +++ b/src/columns/ColDescription.cpp @@ -30,6 +30,7 @@ #include #include #include +#include extern Context context; @@ -63,6 +64,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum) format = context.config.get ("dateformat"); minimum = Date::length (format); + minimum = longestWord (description); maximum = description.length (); std::vector annos; @@ -77,16 +79,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum) else if (_style == "desc") { maximum = description.length (); - minimum = 0; - - Nibbler nibbler (description); - std::string word; - while (nibbler.getUntilWS (word)) - { - nibbler.skipWS (); - if (word.length () > minimum) - minimum = word.length (); - } + minimum = longestWord (description); } // The text ... @@ -96,7 +89,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum) if (format == "") format = context.config.get ("dateformat"); - minimum = Date::length (format); + minimum = max (Date::length (format), longestWord (description)); maximum = description.length (); std::vector annos; @@ -121,16 +114,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum) // + ' ' + '[' + + ']' maximum = description.length () + 3 + format ((int)annos.size ()).length (); - minimum = 0; - - Nibbler nibbler (description); - std::string word; - while (nibbler.getUntilWS (word)) - { - nibbler.skipWS (); - if (word.length () > minimum) - minimum = word.length (); - } + minimum = longestWord (description); } else diff --git a/src/columns/ColProject.cpp b/src/columns/ColProject.cpp index 72b7a0769..67896175a 100644 --- a/src/columns/ColProject.cpp +++ b/src/columns/ColProject.cpp @@ -60,17 +60,8 @@ void ColumnProject::measure (Task& task, int& minimum, int& maximum) else if (_style != "default") throw std::string ("Unrecognized column format '") + _type + "." + _style + "'"; - minimum = 0; + minimum = longestWord (project); maximum = project.length (); - - Nibbler nibbler (project); - std::string word; - while (nibbler.getUntilWS (word)) - { - nibbler.skipWS (); - if (word.length () > minimum) - minimum = word.length (); - } } ////////////////////////////////////////////////////////////////////////////////