From 75822eed4721d319792948fa7ff6864866410f20 Mon Sep 17 00:00:00 2001 From: Louis-Claude Canon Date: Tue, 3 Jul 2012 10:41:40 +0200 Subject: [PATCH] Code Cleanup - Reduce the number of project change messages when annoting and denoting. --- src/commands/CmdAnnotate.cpp | 11 ++++++++++- src/commands/CmdDenotate.cpp | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/commands/CmdAnnotate.cpp b/src/commands/CmdAnnotate.cpp index 2393d2149..7069e18c3 100644 --- a/src/commands/CmdAnnotate.cpp +++ b/src/commands/CmdAnnotate.cpp @@ -67,6 +67,9 @@ int CmdAnnotate::execute (std::string& output) if (!modifications.size ()) throw std::string (STRING_CMD_MODIFY_NEED_TEXT); + // Accumulated project change notifications. + std::map projectChanges; + std::vector ::iterator task; for (task = filtered.begin (); task != filtered.end (); ++task) { @@ -85,7 +88,7 @@ int CmdAnnotate::execute (std::string& output) ++count; feedback_affected (STRING_CMD_ANNO_TASK, *task); if (context.verbose ("project")) - context.footnote (onProjectChange (*task, false)); + projectChanges[task->get ("project")] = onProjectChange (*task, false); // Annotate siblings. if (task->has ("parent")) @@ -118,6 +121,12 @@ int CmdAnnotate::execute (std::string& output) } } + // Now list the project changes. + std::map ::iterator i; + for (i = projectChanges.begin (); i != projectChanges.end (); ++i) + if (i->first != "") + context.footnote (i->second); + context.tdb2.commit (); feedback_affected (count == 1 ? STRING_CMD_ANNO_1 : STRING_CMD_ANNO_N, count); return rc; diff --git a/src/commands/CmdDenotate.cpp b/src/commands/CmdDenotate.cpp index dcadc934d..fea2a36a6 100644 --- a/src/commands/CmdDenotate.cpp +++ b/src/commands/CmdDenotate.cpp @@ -68,6 +68,9 @@ int CmdDenotate::execute (std::string& output) if (!words.size ()) throw std::string (STRING_CMD_DENO_WORDS); + // Accumulated project change notifications. + std::map projectChanges; + std::string pattern = words.combine (); std::vector ::iterator task; @@ -122,7 +125,7 @@ int CmdDenotate::execute (std::string& output) context.tdb2.modify (*task); feedback_affected (format (STRING_CMD_DENO_FOUND, anno)); if (context.verbose ("project")) - context.footnote (onProjectChange (*task, false)); + projectChanges[task->get ("project")] = onProjectChange (*task, false); } } else @@ -132,6 +135,12 @@ int CmdDenotate::execute (std::string& output) } } + // Now list the project changes. + std::map ::iterator i; + for (i = projectChanges.begin (); i != projectChanges.end (); ++i) + if (i->first != "") + context.footnote (i->second); + context.tdb2.commit (); feedback_affected (count == 1 ? STRING_CMD_DENO_1 : STRING_CMD_DENO_N, count); return rc;