Enhancement - annotation substitution

- Annotations are now modifiable using the /from/to/ modification
  command.
This commit is contained in:
Paul Beckingham 2009-04-12 00:56:58 -04:00
parent daea320564
commit a6b45af0a2
6 changed files with 38 additions and 2 deletions

View file

@ -254,11 +254,17 @@ void T::setSubstitution (const std::string& from, const std::string& to)
}
////////////////////////////////////////////////////////////////////////////////
void T::getAnnotations (std::map <time_t, std::string>& all)
void T::getAnnotations (std::map <time_t, std::string>& all) const
{
all = mAnnotations;
}
////////////////////////////////////////////////////////////////////////////////
void T::setAnnotations (const std::map <time_t, std::string>& all)
{
mAnnotations = all;
}
////////////////////////////////////////////////////////////////////////////////
void T::addAnnotation (const std::string& description)
{

View file

@ -79,7 +79,8 @@ public:
void removeAttribute (const std::string&);
void removeAttributes ();
void getAnnotations (std::map <time_t, std::string>&);
void getAnnotations (std::map <time_t, std::string>&) const;
void setAnnotations (const std::map <time_t, std::string>&);
void addAnnotation (const std::string&);
const std::string compose () const;

View file

@ -769,6 +769,28 @@ std::string handleModify (TDB& tdb, T& task, Config& conf)
original.setDescription (description);
++changes;
}
else
{
std::map <time_t, std::string> annotations;
original.getAnnotations (annotations);
std::map <time_t, std::string>::iterator it;
for (it = annotations.begin (); it != annotations.end (); ++it)
{
size_t pattern = it->second.find (from);
if (pattern != std::string::npos)
{
it->second = it->second.substr (0, pattern) +
to +
it->second.substr (pattern + from.length (), std::string::npos);
++changes;
break;
}
}
if (changes)
original.setAnnotations (annotations);
}
}
if (changes)