importdialog.cpp
00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org> 00005 Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 00021 As a special exception, permission is given to link this program 00022 with any edition of TQt, and distribute the resulting executable, 00023 without including the source code for TQt in the source distribution. 00024 */ 00025 00026 #include "importdialog.h" 00027 00028 #include "koprefs.h" 00029 #include "stdcalendar.h" 00030 00031 #include <klocale.h> 00032 00033 #include <tqlabel.h> 00034 #include <tqlayout.h> 00035 #include <tqradiobutton.h> 00036 #include <tqbuttongroup.h> 00037 00038 using namespace KCal; 00039 00040 ImportDialog::ImportDialog( const KURL &url, TQWidget *parent, bool isPart ) 00041 : KDialogBase( Plain, i18n("Import Calendar/Event"), Ok | Cancel, Ok, parent, 00042 0, true, true ), 00043 mUrl( url ) 00044 { 00045 TQFrame *topFrame = plainPage(); 00046 TQVBoxLayout *topLayout = new TQVBoxLayout( topFrame, 0, spacingHint() ); 00047 00048 TQString txt = i18n("Import calendar/event at '%1' into KOrganizer.") 00049 .arg( mUrl.prettyURL() ); 00050 00051 topLayout->addWidget( new TQLabel( txt, topFrame ) ); 00052 00053 TQButtonGroup *radioBox = new TQButtonGroup( 1, Qt::Horizontal, topFrame ); 00054 radioBox->setFlat( true ); 00055 topLayout->addWidget( radioBox ); 00056 00057 mAddButton = new TQRadioButton( i18n("Add as new calendar"), radioBox ); 00058 00059 mMergeButton = new TQRadioButton( i18n("Merge into existing calendar"), 00060 radioBox ); 00061 00062 mOpenButton = isPart ? 0 : new TQRadioButton( i18n("Open in separate window"), radioBox ); 00063 00064 mAddButton->setChecked( true ); 00065 } 00066 00067 ImportDialog::~ImportDialog() 00068 { 00069 } 00070 00071 void ImportDialog::slotOk() 00072 { 00073 kdDebug(5850) << "Adding resource for url '" << mUrl << "'" << endl; 00074 00075 if ( mAddButton->isChecked() ) { 00076 emit addResource( mUrl ); 00077 } else if ( mMergeButton->isChecked() ) { 00078 // emit a signal to action manager to merge mUrl into the current calendar 00079 emit openURL( mUrl, true ); 00080 } else if ( mOpenButton && mOpenButton->isChecked() ) { 00081 // emit a signal to the action manager to open mUrl in a separate window 00082 emit newWindow( mUrl ); 00083 } else { 00084 kdError() << "ImportDialog: internal error." << endl; 00085 } 00086 00087 emit dialogFinished( this ); 00088 accept(); 00089 } 00090 00091 00092 #include "importdialog.moc"