From 9095934bc0143ab4cfa493542af6503e918e9ffd Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 8 Jul 2009 23:17:33 -0400 Subject: [PATCH] Bug Fix - #171 - Fixed bug that caused redundant information to be displayed when the "done" command was run. Thanks to John Florian. --- src/Permission.cpp | 12 +++++++++++- src/Permission.h | 3 ++- src/command.cpp | 16 ++++------------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Permission.cpp b/src/Permission.cpp index d729821a9..6058cbd03 100644 --- a/src/Permission.cpp +++ b/src/Permission.cpp @@ -25,6 +25,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include "Permission.h" #include "Context.h" #include "util.h" @@ -43,7 +44,7 @@ Permission::Permission () } //////////////////////////////////////////////////////////////////////////////// -bool Permission::confirmed (const std::string& question) +bool Permission::confirmed (const Task& task, const std::string& question) { if (!needConfirmation) return true; @@ -51,6 +52,14 @@ bool Permission::confirmed (const std::string& question) if (allConfirmed) return true; + std::cout << std::endl + << "Task " + << task.id + << " \"" + << task.get ("description") + << "\"" + << std::endl; + int answer = confirm3 (question); if (answer == 2) allConfirmed = true; @@ -58,6 +67,7 @@ bool Permission::confirmed (const std::string& question) if (answer > 0) return true; + return false; } diff --git a/src/Permission.h b/src/Permission.h index ef7ce024c..e3755add2 100644 --- a/src/Permission.h +++ b/src/Permission.h @@ -28,6 +28,7 @@ #define INCLUDED_PERMISSION #include +#include "Task.h" class Permission { @@ -38,7 +39,7 @@ public: void bigChange () { needConfirmation = true; } void bigSequence () { needConfirmation = true; } - bool confirmed (const std::string&); + bool confirmed (const Task&, const std::string&); private: bool needConfirmation; diff --git a/src/command.cpp b/src/command.cpp index d5f6cb352..da2277450 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -763,9 +763,7 @@ std::string handleDone () if (taskDiff (before, *task)) { - std::cout << "Task " << before.id << " \"" << before.get ("description") << "\"" << std::endl; - std::string question = taskDifferences (before, *task) + "Are you sure?"; - if (permission.confirmed (question)) + if (permission.confirmed (before, taskDifferences (before, *task) + "Are you sure?")) { context.tdb.update (*task); @@ -909,9 +907,7 @@ std::string handleModify () if (taskDiff (before, *other)) { - std::cout << "Task " << before.id << " \"" << before.get ("description") << "\"" << std::endl; - std::string question = taskDifferences (before, *other) + "Are you sure?"; - if (changes && permission.confirmed (question)) + if (changes && permission.confirmed (before, taskDifferences (before, *task) + "Are you sure?")) { context.tdb.update (*other); ++count; @@ -970,9 +966,7 @@ std::string handleAppend () if (taskDiff (before, *other)) { - std::cout << "Task " << before.id << " \"" << before.get ("description") << "\"" << std::endl; - std::string question = taskDifferences (before, *other) + "Are you sure?"; - if (changes && permission.confirmed (question)) + if (changes && permission.confirmed (before, taskDifferences (before, *task) + "Are you sure?")) { context.tdb.update (*other); @@ -1257,9 +1251,7 @@ std::string handleAnnotate () if (taskDiff (before, *task)) { - std::cout << "Task " << before.id << " \"" << before.get ("description") << "\"" << std::endl; - std::string question = taskDifferences (before, *task) + "Are you sure?"; - if (permission.confirmed (question)) + if (permission.confirmed (before, taskDifferences (before, *task) + "Are you sure?")) { context.tdb.update (*task);