void snippets() { //! [Instantiating the default manager for the platform] QOrganizerManager defaultManager; //! [Instantiating the default manager for the platform] //! [Instantiating a specific manager] QOrganizerManager specificManager("KCal"); //! [Instantiating a specific manager] // XXX TODO: use rrule instead of rdates. QDateTime startDateTime = QDateTime::currentDateTime(); QDate firstOccDate = startDateTime.date().addDays(7); QDate secondOccDate = startDateTime.date().addDays(14); QDate thirdOccDate = startDateTime.date().addDays(21); QDateTime endDateTime = startDateTime.addDays(28); QSet<QDate> rDates; rDates << firstOccDate << secondOccDate << thirdOccDate; //! [Creating a recurrent event] QOrganizerEvent marshmallowMeeting; marshmallowMeeting.setRecurrenceDates(rDates); marshmallowMeeting.setPriority(QOrganizerItemPriority::HighPriority); marshmallowMeeting.setLocation("Meeting Room 8"); marshmallowMeeting.setDescription("A meeting every wednesday to discuss the vitally important topic of marshmallows"); marshmallowMeeting.setDisplayLabel("Marshmallow Conference"); if (!defaultManager.saveItem(&marshmallowMeeting)) qDebug() << "Failed to save the recurrent event; error:" << defaultManager.error(); //! [Creating a recurrent event] //! [Retrieving occurrences of a particular recurrent event within a time period] QList<QOrganizerItem> instances = defaultManager.itemOccurrences(marshmallowMeeting, startDateTime, endDateTime); //! [Retrieving occurrences of a particular recurrent event within a time period] qDebug() << "dumping retrieved instances:"; foreach(const QOrganizerItem& currInst, instances) { dumpItem(currInst); qDebug() << "...................."; }
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()); }