QOrganizerEvent OrganizerItemTransform::convertCEventToQEvent(CEvent *cevent) { QOrganizerEvent retn; // Priority int tempint = cevent->getPriority(); if (tempint != -1) retn.setPriority(static_cast<QOrganizerItemPriority::Priority>(tempint)); // assume that the saved priority is vCal compliant. // Location geo coordinates QOrganizerItemLocation loc = retn.detail<QOrganizerItemLocation>(); if(addGeoToQOIL(QString::fromStdString(cevent->getGeo()), &loc)) retn.saveDetail(&loc); // Start time QDateTime tempdt = QDateTime::fromTime_t(cevent->getDateStart()); if (!tempdt.isNull()) retn.setStartDateTime(tempdt); // End time tempdt = QDateTime::fromTime_t(cevent->getDateEnd()); if (!tempdt.isNull()) retn.setEndDateTime(tempdt); // Recurrence information m_recTransformer.transformToQrecurrence(cevent->getRecurrence()); retn.setRecurrenceRules(m_recTransformer.recurrenceRules()); retn.setExceptionRules(m_recTransformer.exceptionRules()); retn.setRecurrenceDates(m_recTransformer.recurrenceDates()); retn.setExceptionDates(m_recTransformer.exceptionDates()); return retn; }
QDateTime TimeZone::convert(const QDateTime& dateTime) const { Q_ASSERT(isValid()); QOrganizerManager* manager = getManager(); int offset = 100000; // impossible value QDateTime latestPhase; foreach(const TimeZonePhase& phase, mPhases) { QOrganizerEvent event; event.setStartDateTime(phase.startDateTime()); event.setRecurrenceRules(QSet<QOrganizerRecurrenceRule>() << phase.recurrenceRule()); event.setRecurrenceDates(phase.recurrenceDates()); QList<QOrganizerItem> occurrences = manager->itemOccurrences(event, phase.startDateTime(), dateTime, 500); if (!occurrences.isEmpty()) { QDateTime phaseStart(static_cast<QOrganizerEventOccurrence>(occurrences.last()).startDateTime()); if (phaseStart > latestPhase) { latestPhase = phaseStart; offset = phase.utcOffset(); } } }
void tst_QVersitOrganizerExporter::testExport_data() { QTest::addColumn<QList<QOrganizerItem> >("items"); QTest::addColumn<QVersitDocument>("expectedDocument"); { QVersitDocument document(QVersitDocument::ICalendar20Type); document.setComponentType(QLatin1String("VCALENDAR")); QVersitDocument nested(QVersitDocument::ICalendar20Type); nested.setComponentType(QLatin1String("VEVENT")); QVersitProperty property; property.setName(QLatin1String("SUMMARY")); property.setValue(QLatin1String("Bastille Day Party")); nested.addProperty(property); property.setName(QLatin1String("DTSTART")); property.setValue(QLatin1String("19970714T170000Z")); nested.addProperty(property); property.setName(QLatin1String("DTEND")); property.setValue(QLatin1String("19970715T035959Z")); nested.addProperty(property); document.addSubDocument(nested); nested.clear(); nested.setType(QVersitDocument::ICalendar20Type); nested.setComponentType(QLatin1String("VTODO")); property.setName(QLatin1String("SUMMARY")); property.setValue(QLatin1String("Take out the garbage")); nested.addProperty(property); property.setName(QLatin1String("DTSTART")); property.setValue(QLatin1String("20100609T080000")); nested.addProperty(property); property.setName(QLatin1String("DUE")); property.setValue(QLatin1String("20100610T080000")); nested.addProperty(property); document.addSubDocument(nested); nested.clear(); nested.setType(QVersitDocument::ICalendar20Type); nested.setComponentType(QLatin1String("VJOURNAL")); property.setName(QLatin1String("SUMMARY")); property.setValue(QLatin1String("Trip to Thailand")); nested.addProperty(property); property.setName(QLatin1String("DTSTART")); property.setValue(QLatin1String("20100615T112300")); nested.addProperty(property); document.addSubDocument(nested); QOrganizerEvent event; event.setDisplayLabel(QLatin1String("Bastille Day Party")); event.setStartDateTime(QDateTime(QDate(1997, 7, 14), QTime(17, 0, 0), Qt::UTC)); event.setEndDateTime(QDateTime(QDate(1997, 7, 15), QTime(3, 59, 59), Qt::UTC)); QOrganizerTodo todo; todo.setDisplayLabel(QLatin1String("Take out the garbage")); todo.setStartDateTime(QDateTime(QDate(2010, 6, 9), QTime(8, 0, 0))); todo.setDueDateTime(QDateTime(QDate(2010, 6, 10), QTime(8, 0, 0))); QOrganizerJournal journal; journal.setDisplayLabel(QLatin1String("Trip to Thailand")); journal.setDateTime(QDateTime(QDate(2010, 6, 15), QTime(11, 23, 0))); QList<QOrganizerItem> items; items << static_cast<QOrganizerItem>(event); items << static_cast<QOrganizerItem>(todo); items << static_cast<QOrganizerItem>(journal); QTest::newRow("sample event, todo and journal") << items << document; } { QVersitDocument document(QVersitDocument::ICalendar20Type); document.setComponentType(QLatin1String("VCALENDAR")); QVersitDocument nested(QVersitDocument::ICalendar20Type); nested.setComponentType(QLatin1String("VEVENT")); QVersitProperty property; property.setName(QLatin1String("UID")); property.setValue(QLatin1String("1234")); nested.addProperty(property); property.setName(QLatin1String("RECURRENCE-ID")); property.setValue(QLatin1String("20100608")); nested.addProperty(property); document.addSubDocument(nested); // An event occurrence with OriginalDate and Guid set QOrganizerEventOccurrence event; event.setGuid(QLatin1String("1234")); event.setOriginalDate(QDate(2010, 6, 8)); QList<QOrganizerItem> items; items << static_cast<QOrganizerItem>(event); QTest::newRow("event occurrence exception") << items << document; } }
void CalendarThreadWrapper::addToCalendar() { #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) QString desc; const QString viaStation = m_result->viaStation(); if (viaStation.isEmpty()) desc.append(tr("%1 to %2").arg(m_result->departureStation()).arg(m_result->arrivalStation()) + "\n"); else desc.append(tr("%1 via %3 to %2").arg(m_result->departureStation()).arg(m_result->arrivalStation()).arg(viaStation) + "\n"); if (!m_result->info().isEmpty()) { desc.append(m_result->info() + "\n"); } for (int i=0; i < m_result->itemcount(); i++) { JourneyDetailResultItem *item = m_result->getItem(i); if (!item->train().isEmpty()) { desc.append(item->train() + "\n"); } desc.append(item->departureDateTime().date().toString() + " " + item->departureDateTime().time().toString("HH:mm") + " " + item->departureStation()); if (!item->departureInfo().isEmpty()) { desc.append(" - " + item->departureInfo()); } desc.append("\n"); desc.append(item->arrivalDateTime().date().toString() + " " + item->arrivalDateTime().time().toString("HH:mm") + " " + item->arrivalStation()); if (!item->arrivalInfo().isEmpty()) { desc.append(" - " + item->arrivalInfo()); } desc.append("\n"); if (!item->info().isEmpty()) { desc.append(item->info() + "\n"); } desc.append("--\n"); } desc.append(tr("\n(added by fahrplan app, please recheck informations before travel.)")); QOrganizerManager defaultManager; QOrganizerEvent event; if (viaStation.isEmpty()) event.setDisplayLabel(tr("Journey: %1 to %2").arg(m_result->departureStation()).arg(m_result->arrivalStation())); else event.setDisplayLabel(tr("Journey: %1 via %3 to %2").arg(m_result->departureStation()).arg(m_result->arrivalStation()).arg(viaStation)); event.setDescription(desc); event.setStartDateTime(m_result->departureDateTime()); event.setEndDateTime(m_result->arrivalDateTime()); emit addCalendarEntryComplete(defaultManager.saveItem(&event)); #else emit addCalendarEntryComplete(false); #endif QThread::currentThread()->exit(0); // Move back to GUI thread so the deleteLater() callback works (it requires // an event loop which is still alive) moveToThread(QCoreApplication::instance()->thread()); }