void Task::setAnnotations (const std::map <std::string, std::string>& annotations) { // Erase old annotations. removeAnnotations (); std::map <std::string, std::string>::const_iterator ci; for (ci = annotations.begin (); ci != annotations.end (); ++ci) this->insert (*ci); annotation_count = annotations.size (); recalc_urgency = true; }
TITANIUM_FUNCTION(View, removeAnnotations) { TITANIUM_ASSERT(arguments.size() > 0); auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); const auto _0Obj = static_cast<JSObject>(_0); TITANIUM_ASSERT(_0Obj.IsArray()); const auto annotations = static_cast<JSArray>(_0Obj); removeAnnotations(annotations.GetPrivateItems<Annotation>()); return get_context().CreateUndefined(); }
void Map::removeAnnotation(uint32_t annotation) { removeAnnotations({ annotation }); }
void Map::removeAnnotation(AnnotationID annotation) { removeAnnotations({ annotation }); }
//////////////////////////////////////////////////////////////////////////////// // Support FF2, FF3. // Thankfully FF1 is no longer supported. void Task::legacyParse (const std::string& line) { switch (determineVersion (line)) { // File format version 1, from 2006.11.27 - 2007.12.31 case 1: throw std::string (STRING_TASK_NO_FF1); break; // File format version 2, from 2008.1.1 - 2009.3.23 case 2: { if (line.length () > 46) // ^.{36} . \[\] \[\] \n { set ("uuid", line.substr (0, 36)); Task::status status = line[37] == '+' ? completed : line[37] == 'X' ? deleted : line[37] == 'r' ? recurring : pending; set ("status", statusToText (status)); size_t openTagBracket = line.find ("["); size_t closeTagBracket = line.find ("]", openTagBracket); if (openTagBracket != std::string::npos && closeTagBracket != std::string::npos) { size_t openAttrBracket = line.find ("[", closeTagBracket); size_t closeAttrBracket = line.find ("]", openAttrBracket); if (openAttrBracket != std::string::npos && closeAttrBracket != std::string::npos) { std::string tags = line.substr ( openTagBracket + 1, closeTagBracket - openTagBracket - 1); std::vector <std::string> tagSet; split (tagSet, tags, ' '); addTags (tagSet); std::string attributes = line.substr ( openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1); std::vector <std::string> pairs; split (pairs, attributes, ' '); for (size_t i = 0; i < pairs.size (); ++i) { std::vector <std::string> pair; split (pair, pairs[i], ':'); if (pair.size () == 2) set (pair[0], pair[1]); } set ("description", line.substr (closeAttrBracket + 2)); } else throw std::string (STRING_TASK_PARSE_ATT_BRACK); } else throw std::string (STRING_TASK_PARSE_TAG_BRACK); } else throw std::string (STRING_TASK_PARSE_TOO_SHORT); removeAnnotations (); } break; // File format version 3, from 2009.3.23 case 3: { if (line.length () > 49) // ^.{36} . \[\] \[\] \[\] \n { set ("uuid", line.substr (0, 36)); Task::status status = line[37] == '+' ? completed : line[37] == 'X' ? deleted : line[37] == 'r' ? recurring : pending; set ("status", statusToText (status)); size_t openTagBracket = line.find ("["); size_t closeTagBracket = line.find ("]", openTagBracket); if (openTagBracket != std::string::npos && closeTagBracket != std::string::npos) { size_t openAttrBracket = line.find ("[", closeTagBracket); size_t closeAttrBracket = line.find ("]", openAttrBracket); if (openAttrBracket != std::string::npos && closeAttrBracket != std::string::npos) { size_t openAnnoBracket = line.find ("[", closeAttrBracket); size_t closeAnnoBracket = line.find ("]", openAnnoBracket); if (openAnnoBracket != std::string::npos && closeAnnoBracket != std::string::npos) { std::string tags = line.substr ( openTagBracket + 1, closeTagBracket - openTagBracket - 1); std::vector <std::string> tagSet; split (tagSet, tags, ' '); addTags (tagSet); std::string attributes = line.substr ( openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1); std::vector <std::string> pairs; split (pairs, attributes, ' '); for (size_t i = 0; i < pairs.size (); ++i) { std::vector <std::string> pair; split (pair, pairs[i], ':'); if (pair.size () == 2) set (pair[0], pair[1]); } // Extract and split the annotations, which are of the form: // 1234:"..." 5678:"..." std::string annotations = line.substr ( openAnnoBracket + 1, closeAnnoBracket - openAnnoBracket - 1); pairs.clear (); std::string::size_type start = 0; std::string::size_type end = 0; do { end = annotations.find ('"', start); if (end != std::string::npos) { end = annotations.find ('"', end + 1); if (start != std::string::npos && end != std::string::npos) { pairs.push_back (annotations.substr (start, end - start + 1)); start = end + 2; } } } while (start != std::string::npos && end != std::string::npos); for (size_t i = 0; i < pairs.size (); ++i) { std::string pair = pairs[i]; std::string::size_type colon = pair.find (":"); if (colon != std::string::npos) { std::string name = pair.substr (0, colon); std::string value = pair.substr (colon + 2, pair.length () - colon - 3); set ("annotation_" + name, value); ++annotation_count; } } set ("description", line.substr (closeAnnoBracket + 2)); } else throw std::string (STRING_TASK_PARSE_ANNO_BRACK); } else throw std::string (STRING_TASK_PARSE_ATT_BRACK); } else throw std::string (STRING_TASK_PARSE_TAG_BRACK); } else throw std::string (STRING_TASK_PARSE_TOO_SHORT); } break; default: throw std::string (STRING_TASK_PARSE_UNREC_FF); break; } recalc_urgency = true; }