void MemoryCalendarTest::testIncidences() { MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) ); cal->setProductId( QLatin1String( "fredware calendar" ) ); QDate dt = QDate::currentDate(); Event::Ptr event1 = Event::Ptr( new Event() ); event1->setUid( "1" ); event1->setDtStart( KDateTime( dt ) ); event1->setDtEnd( KDateTime( dt ).addDays( 1 ) ); event1->setSummary( "Event1 Summary" ); event1->setDescription( "This is a description of the first event" ); event1->setLocation( "the place" ); Event::Ptr event2 = Event::Ptr( new Event() ); event2->setUid( "2" ); event2->setDtStart( KDateTime( dt ).addDays( 1 ) ); event2->setDtEnd( KDateTime( dt ).addDays( 2 ) ); event2->setSummary( "Event2 Summary" ); event2->setDescription( "This is a description of the second event" ); event2->setLocation( "the other place" ); QVERIFY( cal->addEvent( event1 ) ); QVERIFY( cal->addEvent( event2 ) ); Todo::Ptr todo1 = Todo::Ptr( new Todo() ); todo1->setUid( "3" ); todo1->setDtStart( KDateTime( dt ).addDays( 1 ) ); todo1->setDtDue( KDateTime( dt ).addDays( 2 ) ); todo1->setSummary( "Todo1 Summary" ); todo1->setDescription( "This is a description of a todo" ); todo1->setLocation( "this place" ); Todo::Ptr todo2 = Todo::Ptr( new Todo() ); todo2->setUid( "4" ); todo2->setDtStart( KDateTime( dt ).addDays( 1 ) ); todo2->setAllDay( true ); todo2->setSummary( "<qt><h1>Todo2 Summary</h1></qt>", true ); todo2->setDescription( "This is a description of a todo" ); todo2->setLocation( "<html><a href=\"http://www.fred.com\">this place</a></html>", true ); QVERIFY( cal->addTodo( todo1 ) ); QVERIFY( cal->addTodo( todo2 ) ); FileStorage store( cal, "foo.ics" ); QVERIFY( store.save() ); cal->close(); QVERIFY( store.load() ); Todo::Ptr todo = cal->incidence( "4" ).staticCast<Todo>(); QVERIFY( todo->uid() == "4" ); QVERIFY( todo->summaryIsRich() ); QVERIFY( todo->locationIsRich() ); cal->close(); unlink( "foo.ics" ); }
void CalendarBaseTest::createInitialIncidences() { mExpectedSlotResult = true; for (int i=0; i<5; ++i) { Event::Ptr event = Event::Ptr(new Event()); event->setUid(QStringLiteral("event") + QString::number(i)); event->setSummary(QStringLiteral("summary") + QString::number(i)); event->setDtStart(KDateTime::currentDateTime(KDateTime::UTC)); mUids.append(event->uid()); QVERIFY(mCalendar->addEvent(event)); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); } mOneEventUid = mUids.last(); for (int i=0; i<5; ++i) { Todo::Ptr todo = Todo::Ptr(new Todo()); todo->setUid(QStringLiteral("todo") + QString::number(i)); todo->setDtStart(KDateTime::currentDateTime(KDateTime::UTC)); todo->setSummary(QStringLiteral("summary") + QString::number(i)); mUids.append(todo->uid()); QVERIFY(mCalendar->addTodo(todo)); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); } mOneTodoUid = mUids.last(); for (int i=0; i<5; ++i) { Journal::Ptr journal = Journal::Ptr(new Journal()); journal->setUid(QStringLiteral("journal") + QString::number(i)); journal->setSummary(QStringLiteral("summary") + QString::number(i)); journal->setDtStart(KDateTime::currentDateTime(KDateTime::UTC)); mUids.append(journal->uid()); QVERIFY(mCalendar->addJournal(journal)); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); } mOneJournalUid = mUids.last(); for (int i=0; i<5; ++i) { Incidence::Ptr incidence = Incidence::Ptr(new Event()); incidence->setUid(QStringLiteral("incidence") + QString::number(i)); incidence->setSummary(QStringLiteral("summary") + QString::number(i)); incidence->setDtStart(KDateTime::currentDateTime(KDateTime::UTC)); mUids.append(incidence->uid()); QVERIFY(mCalendar->addIncidence(incidence)); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); } mOneIncidenceUid = mUids.last(); }
void HtmlExport::createTodo(QTextStream *ts, const Todo::Ptr &todo) { qCDebug(KCALUTILS_LOG); const bool completed = todo->isCompleted(); Incidence::List relations = d->mCalendar->relations(todo->uid()); *ts << "<tr>" << endl; *ts << " <td class=\"sum"; if (completed) { *ts << "done"; } *ts << "\">" << endl; *ts << " <a name=\"" << todo->uid() << "\"></a>" << endl; *ts << " <b>" << cleanChars(todo->summary()) << "</b>" << endl; if (!todo->description().isEmpty()) { *ts << " <p>" << breakString(cleanChars(todo->description())) << "</p>" << endl; } if (relations.count()) { *ts << " <div align=\"right\"><a href=\"#sub" << todo->uid() << "\">" << i18nc("@title:column sub-to-dos of the parent to-do", "Sub-To-dos") << "</a></div>" << endl; } *ts << " </td>" << endl; *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; *ts << " " << todo->priority() << endl; *ts << " </td>" << endl; *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; *ts << " " << i18nc("@info to-do percent complete", "%1 %", todo->percentComplete()) << endl; *ts << " </td>" << endl; if (d->mSettings->taskDueDate()) { *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; if (todo->hasDueDate()) { *ts << " " << Stringify::formatDate(todo->dtDue(true)) << endl; } else { *ts << " " << endl; } *ts << " </td>" << endl; } if (d->mSettings->taskLocation()) { *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; formatLocation(ts, todo); *ts << " </td>" << endl; } if (d->mSettings->taskCategories()) { *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; formatCategories(ts, todo); *ts << " </td>" << endl; } if (d->mSettings->taskAttendees()) { *ts << " <td"; if (completed) { *ts << " class=\"done\""; } *ts << ">" << endl; formatAttendees(ts, todo); *ts << " </td>" << endl; } *ts << "</tr>" << endl; }