diff --git a/plan/src/plugins/filters/icalendar/export/icalendarexport.cpp b/plan/src/plugins/filters/icalendar/export/icalendarexport.cpp index daf1c2d52b3..5eba36bc1ef 100644 --- a/plan/src/plugins/filters/icalendar/export/icalendarexport.cpp +++ b/plan/src/plugins/filters/icalendar/export/icalendarexport.cpp @@ -1,211 +1,211 @@ /* This file is part of the KDE project Copyright (C) 2009, 2011, 2012 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "icalendarexport.h" #include "config.h" #include #include #include #include #include #include "kptdebug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace KPlato; K_PLUGIN_FACTORY_WITH_JSON(ICalendarExportFactory, "plan_icalendar_export.json", registerPlugin();) #ifdef HAVE_QDATETIME_KCALCORE #define KQDT QDateTime #else #define KQDT KDateTime #endif ICalendarExport::ICalendarExport(QObject* parent, const QVariantList &) : KoFilter(parent) { } KoFilter::ConversionStatus ICalendarExport::convert(const QByteArray& from, const QByteArray& to) { debugPlan << from << to; if ( ( from != "application/x-vnd.kde.plan" ) || ( to != "text/calendar" ) ) { return KoFilter::NotImplemented; } bool batch = false; if ( m_chain->manager() ) { batch = m_chain->manager()->getBatchMode(); } if ( batch ) { //TODO debugPlan << "batch"; return KoFilter::UsageError; } debugPlan<<"online:"<inputDocument(); MainDocument *doc = dynamic_cast( m_chain->inputDocument() ); if (doc == 0) { errorPlan << "Cannot open Plan document"; return KoFilter::InternalError; } if (m_chain->outputFile().isEmpty()) { errorPlan << "Output filename is empty"; return KoFilter::InternalError; } QFile file(m_chain->outputFile()); if (! file.open(QIODevice::WriteOnly)) { errorPlan << "Failed to open output file:" << file.fileName(); return KoFilter::StorageCreationError; } KoFilter::ConversionStatus status = convert(doc->getProject(), file); file.close(); //debugPlan << "Finished with status:"< lst = project.allScheduleManagers(); foreach(const ScheduleManager *m, lst) { if (! baselined) { id = lst.last()->scheduleId(); //debugPlan<<"last:"<isBaselined()) { id = m->scheduleId(); //debugPlan<<"baselined:"<setUid( node->id() ); todo->setSummary(node->name()); todo->setDescription(node->description()); todo->setCategories(QLatin1String("Plan")); if (! node->projectNode()->leader().isEmpty()) { todo->setOrganizer(node->projectNode()->leader()); } if ( node->type() != Node::Type_Project && ! node->leader().isEmpty()) { -#if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 11, 90) +#if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 11, 80) KCalCore::Person p = KCalCore::Person::fromFullName(node->leader()); KCalCore::Attendee a(p.name(), p.email()); a.setRole(KCalCore::Attendee::NonParticipant); #else KCalCore::Person::Ptr p = KCalCore::Person::fromFullName(node->leader()); KCalCore::Attendee::Ptr a(new KCalCore::Attendee(p->name(), p->email())); a->setRole(KCalCore::Attendee::NonParticipant); #endif todo->addAttendee(a); } DateTime st = node->startTime(id); DateTime et = node->endTime(id); if (st.isValid()) { todo->setDtStart( KQDT( st ) ); } if (et.isValid()) { todo->setDtDue( KQDT( et ) ); } if (node->type() == Node::Type_Task) { const Task *task = qobject_cast(const_cast(node)); Schedule *s = task->schedule(id); if (id < 0 || s == 0) { // Not scheduled, use requests const QList lst = task->requestedResources(); foreach(const Resource *r, lst) { if (r->type() == Resource::Type_Work) { -#if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 11, 90) +#if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 11, 80) todo->addAttendee(KCalCore::Attendee(r->name(), r->email())); #else todo->addAttendee(KCalCore::Attendee::Ptr(new KCalCore::Attendee(r->name(), r->email()))); #endif } } } else { foreach(const Resource *r, s->resources()) { if (r->type() == Resource::Type_Work) { -#if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 11, 90) +#if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 11, 80) todo->addAttendee(KCalCore::Attendee(r->name(), r->email())); #else todo->addAttendee(KCalCore::Attendee::Ptr(new KCalCore::Attendee(r->name(), r->email()))); #endif } } } } else if (node->type() == Node::Type_Milestone) { const Task *task = qobject_cast(const_cast(node)); todo->setDtStart(KQDT()); todo->setPercentComplete(task->completion().percentFinished()); } foreach(const Document *doc, node->documents().documents()) { -#if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 11, 90) +#if KCALCORE_VERSION >= QT_VERSION_CHECK(5, 11, 80) todo->addAttachment(KCalCore::Attachment(doc->url().url())); #else todo->addAttachment(KCalCore::Attachment::Ptr(new KCalCore::Attachment(doc->url().url()))); #endif } if (! parent.isNull()) { todo->setRelatedTo(parent->uid(), KCalCore::Incidence::RelTypeParent); } cal->addTodo(todo); foreach(const Node *n, node->childNodeIterator()) { createTodos(cal, n, id, todo); } } #include "icalendarexport.moc"