korganizer

importdialog.cpp
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6
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.
11
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.
16
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.
20
21 As a special exception, permission is given to link this program
22 with any edition of TQt, and distribute the resulting executable,
23 without including the source code for TQt in the source distribution.
24*/
25
26#include "importdialog.h"
27
28#include "koprefs.h"
29#include "stdcalendar.h"
30
31#include <tdelocale.h>
32
33#include <tqlabel.h>
34#include <tqlayout.h>
35#include <tqradiobutton.h>
36#include <tqbuttongroup.h>
37
38using namespace KCal;
39
40ImportDialog::ImportDialog( const KURL &url, TQWidget *parent, bool isPart )
41 : KDialogBase( Plain, i18n("Import Calendar/Event"), Ok | Cancel, Ok, parent,
42 0, true, true ),
43 mUrl( url )
44{
45 TQFrame *topFrame = plainPage();
46 TQVBoxLayout *topLayout = new TQVBoxLayout( topFrame, 0, spacingHint() );
47
48 TQString txt = i18n("Import calendar/event at '%1' into KOrganizer.")
49 .arg( mUrl.prettyURL() );
50
51 topLayout->addWidget( new TQLabel( txt, topFrame ) );
52
53 TQButtonGroup *radioBox = new TQButtonGroup( 1, TQt::Horizontal, topFrame );
54 radioBox->setFlat( true );
55 topLayout->addWidget( radioBox );
56
57 mAddButton = new TQRadioButton( i18n("Add as new calendar"), radioBox );
58
59 mMergeButton = new TQRadioButton( i18n("Merge into existing calendar"),
60 radioBox );
61
62 mOpenButton = isPart ? 0 : new TQRadioButton( i18n("Open in separate window"), radioBox );
63
64 mAddButton->setChecked( true );
65}
66
67ImportDialog::~ImportDialog()
68{
69}
70
71void ImportDialog::slotOk()
72{
73 kdDebug(5850) << "Adding resource for url '" << mUrl << "'" << endl;
74
75 if ( mAddButton->isChecked() ) {
76 emit addResource( mUrl );
77 } else if ( mMergeButton->isChecked() ) {
78 // emit a signal to action manager to merge mUrl into the current calendar
79 emit openURL( mUrl, true );
80 } else if ( mOpenButton && mOpenButton->isChecked() ) {
81 // emit a signal to the action manager to open mUrl in a separate window
82 emit newWindow( mUrl );
83 } else {
84 kdError() << "ImportDialog: internal error." << endl;
85 }
86
87 emit dialogFinished( this );
88 accept();
89}
90
91
92#include "importdialog.moc"