korganizer

konewstuff.cpp
1 /*
2  This file is part of KOrganizer.
3  Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 
19  As a special exception, permission is given to link this program
20  with any edition of TQt, and distribute the resulting executable,
21  without including the source code for TQt in the source distribution.
22 */
23 
24 #include <tdeapplication.h>
25 #include <kdebug.h>
26 
27 #include <libkcal/calendarlocal.h>
28 #include <libkcal/filestorage.h>
29 
30 #include "koprefs.h"
31 #include "calendarview.h"
32 
33 #include "konewstuff.h"
34 
35 KONewStuff::KONewStuff( CalendarView *view ) :
36  TDENewStuff( "korganizer calendar", view ),
37  mView( view )
38 {
39 }
40 
41 bool KONewStuff::install( const TQString &fileName )
42 {
43  kdDebug(5850) << "KONewStuff::install(): " << fileName << endl;
44 
45  CalendarLocal cal( KOPrefs::instance()->mTimeZoneId );
46  FileStorage storage( &cal, fileName );
47  if ( !storage.load() ) {
48  KMessageBox::error( mView, i18n("Could not load calendar.") );
49  return false;
50  }
51 
52  Event::List events = cal.events();
53 
54  TQStringList eventList;
55 
56  Event::List::ConstIterator it;
57  for( it = events.begin(); it != events.end(); ++it ) {
58  TQString text = (*it)->summary();
59  eventList.append( text );
60  }
61 
62  int result = KMessageBox::warningContinueCancelList( mView,
63  i18n("The downloaded events will be merged into your current calendar."),
64  eventList );
65 
66  if ( result != KMessageBox::Continue ) return false;
67 
68  return mView->openCalendar( fileName, true );
69 }
70 
71 bool KONewStuff::createUploadFile( const TQString &fileName )
72 {
73  return mView->saveCalendar( fileName );
74 }
This is the main calendar widget.
Definition: calendarview.h:82
bool view(TQWidget *parent, Attachment *attachment)