From e301cda990ed159fac1c5505d40c2a0f6ca7f16a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 20 Jan 2011 10:40:32 -0500 Subject: [PATCH] Bug, Reorg - Fixed bug in journal annotations that omitted \n characters for certain events, creating an unreadable journal entry. - Relocated the 'Total active time' into the journal table, made the text bold, and changed from "Xh XXm" format to Duration::format. --- src/report.cpp | 50 +++++++++++++++++++++++--------------------------- src/util.cpp | 4 ++-- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/report.cpp b/src/report.cpp index 10088182b..05acf1183 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -675,10 +675,6 @@ int handleInfo (std::string& outs) } } - out << optionalBlankLine () - << table.render () - << "\n"; - journal.setTableWidth (context.getWidth ()); journal.setDateFormat (context.config.get ("dateformat")); @@ -708,7 +704,7 @@ int handleInfo (std::string& outs) std::string previous; std::string current; unsigned int i = 0; - long time = 0; + long total_time = 0; while (i < undo.size ()) { when = undo[i++]; @@ -737,41 +733,41 @@ int handleInfo (std::string& outs) && after.get ("start") != "") { // task started - time -= timestamp.toEpoch(); + total_time -= timestamp.toEpoch (); } else if (before.get ("start") != "" && after.get ("start") == "") { // task stopped - time += timestamp.toEpoch(); + total_time += timestamp.toEpoch (); } } } } + // add now() if task is still active + if (total_time < 0) + total_time += Date ().toEpoch (); + + + // print total active time + if (total_time > 0) + { + row = journal.addRow (); + journal.addCell (row, 0, "Total active time"); + journal.addCell (row, 1, Duration (total_time).format ()); + + if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) + journal.setCellColor (row, 1, Color ("bold")); + } + + out << optionalBlankLine () + << table.render () + << "\n"; + if (journal.rowCount () > 0) out << journal.render () << "\n"; - - // add now() if task is still active - if (time < 0) - time += Date().toEpoch(); - - // print total active time - if (time >= 0) - { - int row = journal.addRow (); - int hours = time / 3600; - int minutes = (time % 3600) / 60; - - out << "Total active time: " - << hours << "h " << minutes; - - if (minutes == 0) - out << "0"; - - out << "m\n\n"; - } } } diff --git a/src/util.cpp b/src/util.cpp index aceb46472..7c2ed334c 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -506,7 +506,7 @@ std::string taskInfoDifferences (const Task& before, const Task& after) { out << "annotation added '" << after.get (*name) - << "'"; + << "'\n"; } else out << *name @@ -542,7 +542,7 @@ std::string taskInfoDifferences (const Task& before, const Task& after) { out << "annotation '" << after.get (*name) - << "'"; + << "'\n"; } else out << *name