Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi/akonadiserializer.cpp
Show First 20 Lines • Show All 452 Lines • ▼ Show 20 Line(s) | 452 | { | |||
---|---|---|---|---|---|
453 | const QString todoUid = project->property("todoUid").toString(); | 453 | const QString todoUid = project->property("todoUid").toString(); | ||
454 | const QString relatedUid = relatedUidFromItem(item); | 454 | const QString relatedUid = relatedUidFromItem(item); | ||
455 | 455 | | |||
456 | return !todoUid.isEmpty() | 456 | return !todoUid.isEmpty() | ||
457 | && !relatedUid.isEmpty() | 457 | && !relatedUid.isEmpty() | ||
458 | && todoUid == relatedUid; | 458 | && todoUid == relatedUid; | ||
459 | } | 459 | } | ||
460 | 460 | | |||
461 | Domain::Context::Ptr Serializer::createContextFromTag(Akonadi::Tag tag) | | |||
462 | { | | |||
463 | if (!isContext(tag)) | | |||
464 | return Domain::Context::Ptr(); | | |||
465 | | ||||
466 | auto context = Domain::Context::Ptr::create(); | | |||
467 | updateContextFromTag(context, tag); | | |||
468 | return context; | | |||
469 | } | | |||
470 | | ||||
471 | Akonadi::Tag Serializer::createTagFromContext(Domain::Context::Ptr context) | | |||
472 | { | | |||
473 | auto tag = Akonadi::Tag(); | | |||
474 | tag.setName(context->name()); | | |||
475 | tag.setType(Akonadi::SerializerInterface::contextTagType()); | | |||
476 | tag.setGid(QByteArray(context->name().toLatin1())); | | |||
477 | | ||||
478 | if (context->property("tagId").isValid()) | | |||
479 | tag.setId(context->property("tagId").value<Akonadi::Tag::Id>()); | | |||
480 | | ||||
481 | return tag; | | |||
482 | } | | |||
483 | | ||||
484 | void Serializer::updateContextFromTag(Domain::Context::Ptr context, Akonadi::Tag tag) | | |||
485 | { | | |||
486 | if (!isContext(tag)) | | |||
487 | return; | | |||
488 | | ||||
489 | context->setProperty("tagId", tag.id()); | | |||
490 | context->setName(tag.name()); | | |||
491 | } | | |||
492 | | ||||
493 | bool Serializer::isContext(const Akonadi::Tag &tag) const | | |||
494 | { | | |||
495 | return (tag.type() == Akonadi::SerializerInterface::contextTagType()); | | |||
496 | } | | |||
497 | | ||||
498 | bool Serializer::isContextTag(const Domain::Context::Ptr &context, const Akonadi::Tag &tag) const | | |||
499 | { | | |||
500 | return (context->property("tagId").value<Akonadi::Tag::Id>() == tag.id()); | | |||
501 | } | | |||
502 | | ||||
503 | static QStringList extractContexts(KCalCore::Todo::Ptr todo) | 461 | static QStringList extractContexts(KCalCore::Todo::Ptr todo) | ||
504 | { | 462 | { | ||
505 | const auto contexts = todo->customProperty(s_appName, s_contextListProperty); | 463 | const auto contexts = todo->customProperty(s_appName, s_contextListProperty); | ||
506 | return contexts.split(',', QString::SkipEmptyParts); | 464 | return contexts.split(',', QString::SkipEmptyParts); | ||
507 | } | 465 | } | ||
508 | 466 | | |||
509 | bool Serializer::isContextChild(Domain::Context::Ptr context, Item item) const | 467 | bool Serializer::isContextChild(Domain::Context::Ptr context, Item item) const | ||
510 | { | 468 | { | ||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |