korganizer Library API Documentation

importdialog.cpp

00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 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 // TODO: This should be better done by the action manager 00080 // TODO: currently, the new resource does not show up in the 00081 // resource view. You have to restart korganizer first. 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 // emit a signal to action manager to merge mUrl into the current calendar 00112 emit openURL( mUrl, true ); 00113 } else if ( mOpenButton->isChecked() ) { 00114 // emit a signal to the action manager to open mUrl in a separate window 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"
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:19:30 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003