krop's commit fixes my problem in a better way, reverting
[kdepim.git] / korganizer / importdialog.cpp
blobde59fbc507d1961e7e6a36c6b605ae0212a57edb
1 /*
2 This file is part of KOrganizer.
4 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution.
26 #include "importdialog.h"
28 #include "koprefs.h"
29 #include "stdcalendar.h"
31 #include <KLocale>
32 #include <KSqueezedTextLabel>
34 #include <QLabel>
35 #include <QLayout>
36 #include <QRadioButton>
37 #include <QGroupBox>
39 //Added by qt3to4:
40 #include <QVBoxLayout>
41 #include <QFrame>
43 using namespace KCal;
45 ImportDialog::ImportDialog( const KUrl &url, QWidget *parent )
46 : KDialog( parent ), mUrl( url )
48 setCaption( i18n( "Import Calendar" ) );
49 setButtons( Ok | Cancel );
50 setDefaultButton( Ok );
51 setModal( true );
52 showButtonSeparator( true );
53 QFrame *topFrame = new QFrame( this );
54 setMainWidget( topFrame );
55 QVBoxLayout *topLayout = new QVBoxLayout( topFrame );
56 topLayout->setSpacing( spacingHint() );
57 topLayout->setMargin( 0 );
59 QString txt = i18n( "Please select import method for calendar at\n\n%1.",
60 mUrl.prettyUrl() );
61 KSqueezedTextLabel *lbl = new KSqueezedTextLabel( txt, topFrame );
62 lbl->setTextElideMode( Qt::ElideMiddle );
63 topLayout->addWidget( lbl );
65 QGroupBox *radioBox = new QGroupBox( topFrame );
66 QBoxLayout *boxLayout = new QVBoxLayout( radioBox );
67 radioBox->setFlat( true );
68 topLayout->addWidget( radioBox );
70 mAddButton = new QRadioButton( i18n( "Add as new calendar" ), radioBox );
71 boxLayout->addWidget( mAddButton );
73 mMergeButton = new QRadioButton( i18n( "Merge into existing calendar" ), radioBox );
74 boxLayout->addWidget( mMergeButton );
76 mOpenButton = new QRadioButton( i18n( "Open in separate window" ), radioBox );
77 boxLayout->addWidget( mOpenButton );
79 mAddButton->setChecked( true );
80 connect( this, SIGNAL(okClicked()), SLOT(slotOk()) );
83 ImportDialog::~ImportDialog()
87 void ImportDialog::slotOk()
89 kDebug() << "Adding resource for url '" << mUrl <<"'";
91 if ( mAddButton->isChecked() ) {
92 emit addResource( mUrl );
93 } else if ( mMergeButton->isChecked() ) {
94 // emit a signal to action manager to merge mUrl into the current calendar
95 emit openURL( mUrl, true );
96 } else if ( mOpenButton->isChecked() ) {
97 // emit a signal to the action manager to open mUrl in a separate window
98 emit newWindow( mUrl );
99 } else {
100 kError() << "ImportDialog: internal error.";
103 emit dialogFinished( this );
104 accept();
107 #include "importdialog.moc"