bool KonsoleKalendarAdd::addImportedCalendar() { // If --file specified, then import into that file // else, import into the standard calendar QString fileName; if ( m_variables->getCalendarFile().isEmpty() ) fileName = locateLocal( "data", "korganizer/std.ics" ); else fileName = m_variables->getCalendarFile(); CalendarLocal *cal = new CalendarLocal( KPimPrefs::timezone() ); if ( !cal->load( fileName ) || !cal->load( m_variables->getImportFile() ) || !cal->save( fileName ) ) { kdDebug() << "konsolekalendaradd.cpp::importCalendar() | " << "Can't import file: " << m_variables->getImportFile() << endl; return false; } kdDebug() << "konsolekalendaradd.cpp::importCalendar() | " << "Successfully imported file: " << m_variables->getImportFile() << endl; return true; }
bool ResourceLocalDir::doFileLoad(CalendarLocal &cal, const QString &fileName) { if(!cal.load(fileName)) return false; Incidence::List incidences = cal.rawIncidences(); Incidence::List::ConstIterator it; for(it = incidences.constBegin(); it != incidences.constEnd(); ++it) { Incidence *i = *it; if(i) mCalendar.addIncidence(i->clone()); } return true; }
void ResourceGroupware::slotJobResult( KJob *job ) { kDebug() <<"ResourceGroupware::slotJobResult():"; if ( job->error() ) { mIsShowingError = true; loadError( job->errorString() ); mIsShowingError = false; } else { disableChangeNotification(); clearCache(); // FIXME: This does not take into account the time zone! CalendarLocal calendar; ICalFormat ical; if ( !ical.fromString( &calendar, mJobData ) ) { loadError( i18n("Error parsing calendar data.") ); } else { Incidence::List incidences = calendar.incidences(); Incidence::List::ConstIterator it; for( it = incidences.begin(); it != incidences.end(); ++it ) { // kDebug() <<"INCIDENCE:" << (*it)->summary(); Incidence *i = (*it)->clone(); QString remote = (*it)->customProperty( "GWRESOURCE", "UID" ); QString local = idMapper().localId( remote ); if ( local.isEmpty() ) { idMapper().setRemoteId( i->uid(), remote ); } else { i->setUid( local ); } addIncidence( i ); } } saveToCache(); enableChangeNotification(); clearChanges(); emit resourceChanged( this ); emit resourceLoaded( this ); } mDownloadJob = 0; if ( mProgress ) mProgress->setComplete(); mProgress = 0; }
void KOEventEditor::loadTemplate( CalendarLocal &cal ) { Event::List events = cal.events(); if ( events.count() == 0 ) { KMessageBox::error( this, i18nc( "@info", "Template does not contain a valid event." ) ); } else { readEvent( events.first(), QDate(), true ); } }
void KOTodoEditor::loadTemplate(/*const*/ CalendarLocal &cal) { Todo::List todos = cal.todos(); if(todos.count() == 0) { KMessageBox::error(this, i18n("Template does not contain a valid to-do.")); } else { readTodo(todos.first(), 0); } }
/****************************************************************************** * If a function is defined to convert alarms to the current format, call it to * convert an individual file within the overall resource. */ KCalendar::Status AlarmResource::checkCompatibility(CalendarLocal& calendar, const QString& filename, FixFunc conv, bool* wrongType) { if (wrongType) *wrongType = false; KCalendar::Status compat = KCalendar::Incompatible; // assume the worst if (mFixFunction) { // Check whether the version is compatible (and convert it if desired) compat = (*mFixFunction)(calendar, filename, this, conv, wrongType); if (compat == KCalendar::Converted) calendar.save(filename); } return compat; }