resourceimportdialog.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "resourceimportdialog.h"
00026
00027 #include "kocore.h"
00028 #include "koprefs.h"
00029
00030 #include <libkcal/calendarresources.h>
00031 #include <libkcal/resourcelocal.h>
00032 #include <libkcal/resourceremote.h>
00033
00034 #include <klocale.h>
00035
00036 #include <qlabel.h>
00037 #include <qlayout.h>
00038
00039 ResourceImportDialog::ResourceImportDialog( const QString &url,
00040 QWidget *parent )
00041 : KDialogBase( Plain, i18n("Import Calendar"), Ok | Cancel, Ok, parent,
00042 0, true, true ),
00043 mUrl( url )
00044 {
00045 QFrame *topFrame = plainPage();
00046 QVBoxLayout *topLayout = new QVBoxLayout( topFrame, 0, spacingHint() );
00047
00048 QString txt = i18n("Do you want to add the calendar at '%1' to KOrganizer")
00049 .arg( mUrl );
00050
00051 topLayout->addWidget( new QLabel( txt, topFrame ) );
00052 }
00053
00054 ResourceImportDialog::~ResourceImportDialog()
00055 {
00056 }
00057
00058 void ResourceImportDialog::slotOk()
00059 {
00060 kdDebug() << "Adding resource for url '" << mUrl << "'" << endl;
00061
00062 KCal::CalendarResources *cr = KOCore::self()->calendarResources();
00063
00064 KCal::CalendarResourceManager *manager = cr->resourceManager();
00065
00066 KCal::ResourceCalendar *resource = 0;
00067
00068 KURL url( mUrl );
00069 kdDebug() << "URL: " << url.url() << endl;
00070 if ( url.isLocalFile() ) {
00071 kdDebug() << "Local Resource" << endl;
00072 resource = new KCal::ResourceLocal( mUrl );
00073 resource->setTimeZoneId( KOPrefs::instance()->mTimeZoneId );
00074 } else {
00075 kdDebug() << "Remote Resource" << endl;
00076
00077 }
00078
00079 if ( resource ) {
00080 resource->setResourceName( mUrl );
00081 manager->add( resource );
00082 }
00083
00084 accept();
00085 }
00086
00087 #include "resourceimportdialog.moc"
This file is part of the documentation for korganizer Library Version 3.2.2.