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 "importdialog.h"
00026
00027
#include "koprefs.h"
00028
#include "stdcalendar.h"
00029
00030
#include <libkcal/calendarresources.h>
00031
#include <libkcal/resourcelocal.h>
00032
#include <kresources/remote/resourceremote.h>
00033
00034
#include <klocale.h>
00035
00036
#include <qlabel.h>
00037
#include <qlayout.h>
00038
#include <qradiobutton.h>
00039
#include <qbuttongroup.h>
00040
00041
using namespace KCal;
00042
00043 ImportDialog::ImportDialog(
const KURL &url,
QWidget *parent )
00044 : KDialogBase( Plain, i18n("Import Calendar"), Ok | Cancel, Ok, parent,
00045 0, true, true ),
00046 mUrl( url )
00047 {
00048
QFrame *topFrame = plainPage();
00049
QVBoxLayout *topLayout =
new QVBoxLayout( topFrame, 0, spacingHint() );
00050
00051
QString txt = i18n(
"Import calendar at '%1' into KOrganizer.")
00052 .arg( mUrl.prettyURL() );
00053
00054 topLayout->addWidget(
new QLabel( txt, topFrame ) );
00055
00056
QButtonGroup *radioBox =
new QButtonGroup( 1, Horizontal, topFrame );
00057 radioBox->setFlat(
true );
00058 topLayout->addWidget( radioBox );
00059
00060 mAddButton =
new QRadioButton( i18n(
"Add as new calendar"), radioBox );
00061
00062 mMergeButton =
new QRadioButton( i18n(
"Merge into existing calendar"),
00063 radioBox );
00064
00065 mOpenButton =
new QRadioButton( i18n(
"Open in separate window"), radioBox );
00066
00067 mAddButton->setChecked(
true );
00068 }
00069
00070 ImportDialog::~ImportDialog()
00071 {
00072 }
00073
00074
void ImportDialog::slotOk()
00075 {
00076 kdDebug() <<
"Adding resource for url '" << mUrl <<
"'" << endl;
00077
00078
if ( mAddButton->isChecked() ) {
00079
00080
00081
00082 CalendarResources *cr = KOrg::StdCalendar::self();
00083
00084 CalendarResourceManager *manager = cr->resourceManager();
00085
00086 ResourceCalendar *resource = 0;
00087
00088
QString name;
00089
00090 kdDebug() <<
"URL: " << mUrl << endl;
00091
if ( mUrl.isLocalFile() ) {
00092 kdDebug() <<
"Local Resource" << endl;
00093 resource =
new ResourceLocal( mUrl.path() );
00094 resource->setTimeZoneId( KOPrefs::instance()->mTimeZoneId );
00095 name = mUrl.path();
00096 }
else {
00097 kdDebug() <<
"Remote Resource" << endl;
00098 resource =
new ResourceRemote( mUrl );
00099 resource->setTimeZoneId( KOPrefs::instance()->mTimeZoneId );
00100 name = mUrl.prettyURL();
00101 resource->setReadOnly(
true );
00102 }
00103
00104
if ( resource ) {
00105 resource->setResourceName( name );
00106 manager->add( resource );
00107 emit resourceAdded( resource );
00108 }
00109
00110 }
else if ( mMergeButton->isChecked() ) {
00111
00112 emit openURL( mUrl,
true );
00113 }
else if ( mOpenButton->isChecked() ) {
00114
00115 emit newWindow( mUrl );
00116 }
else {
00117 kdError() <<
"ImportDialog: internal error." << endl;
00118 }
00119
00120 emit dialogFinished(
this );
00121 accept();
00122 }
00123
00124
00125
#include "importdialog.moc"