summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1d62046..e4c067e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -34,220 +34,225 @@
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130#ifdef DESKTOP_VERSION
131#include <kabc/stdaddressbook.h>
132#endif
130using namespace KOrg; 133using namespace KOrg;
131using namespace KCal; 134using namespace KCal;
132extern int globalFlagBlockAgenda; 135extern int globalFlagBlockAgenda;
133extern int globalFlagBlockStartup; 136extern int globalFlagBlockStartup;
134 137
135 138
136 139
137class KOBeamPrefs : public QDialog 140class KOBeamPrefs : public QDialog
138{ 141{
139 public: 142 public:
140 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 143 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
141 QDialog( parent, name, true ) 144 QDialog( parent, name, true )
142 { 145 {
143 setCaption( i18n("Beam Options") ); 146 setCaption( i18n("Beam Options") );
144 QVBoxLayout* lay = new QVBoxLayout( this ); 147 QVBoxLayout* lay = new QVBoxLayout( this );
145 lay->setSpacing( 3 ); 148 lay->setSpacing( 3 );
146 lay->setMargin( 3 ); 149 lay->setMargin( 3 );
147 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 150 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
148 lay->addWidget( format ); 151 lay->addWidget( format );
149 format->setExclusive ( true ) ; 152 format->setExclusive ( true ) ;
150 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 153 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
151 lay->addWidget( time ); time->setExclusive ( true ) ; 154 lay->addWidget( time ); time->setExclusive ( true ) ;
152 vcal = new QRadioButton(" vCalendar ", format ); 155 vcal = new QRadioButton(" vCalendar ", format );
153 ical = new QRadioButton(" iCalendar ", format ); 156 ical = new QRadioButton(" iCalendar ", format );
154 vcal->setChecked( true ); 157 vcal->setChecked( true );
155 tz = new QRadioButton(i18n(" With timezone "), time ); 158 tz = new QRadioButton(i18n(" With timezone "), time );
156 local = new QRadioButton(i18n(" Local time "), time ); 159 local = new QRadioButton(i18n(" Local time "), time );
157 tz->setChecked( true ); 160 tz->setChecked( true );#ifdef DESKTOP_VERSION
161#include <kabc/stdaddressbook.h>
162#endif
158 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
159 lay->addWidget( ok ); 164 lay->addWidget( ok );
160 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
161 lay->addWidget( cancel ); 166 lay->addWidget( cancel );
162 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
163 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
164 resize( 200, 200 ); 169 resize( 200, 200 );
165 } 170 }
166 171
167 bool beamVcal() { return vcal->isChecked(); } 172 bool beamVcal() { return vcal->isChecked(); }
168 bool beamLocal() { return local->isChecked(); } 173 bool beamLocal() { return local->isChecked(); }
169private: 174private:
170 QRadioButton* vcal, *ical, *local, *tz; 175 QRadioButton* vcal, *ical, *local, *tz;
171}; 176};
172class KOCatPrefs : public QDialog 177class KOCatPrefs : public QDialog
173{ 178{
174 public: 179 public:
175 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
176 QDialog( parent, name, true ) 181 QDialog( parent, name, true )
177 { 182 {
178 setCaption( i18n("Manage new Categories") ); 183 setCaption( i18n("Manage new Categories") );
179 QVBoxLayout* lay = new QVBoxLayout( this ); 184 QVBoxLayout* lay = new QVBoxLayout( this );
180 lay->setSpacing( 3 ); 185 lay->setSpacing( 3 );
181 lay->setMargin( 3 ); 186 lay->setMargin( 3 );
182 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 187 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
183 lay->addWidget( lab ); 188 lay->addWidget( lab );
184 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
185 lay->addWidget( format ); 190 lay->addWidget( format );
186 format->setExclusive ( true ) ; 191 format->setExclusive ( true ) ;
187 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 192 addCatBut = new QRadioButton(i18n("Add to category list"), format );
188 new QRadioButton(i18n("Remove from Events/Todos"), format ); 193 new QRadioButton(i18n("Remove from Events/Todos"), format );
189 addCatBut->setChecked( true ); 194 addCatBut->setChecked( true );
190 QPushButton * ok = new QPushButton( i18n("OK"), this ); 195 QPushButton * ok = new QPushButton( i18n("OK"), this );
191 lay->addWidget( ok ); 196 lay->addWidget( ok );
192 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
193 lay->addWidget( cancel ); 198 lay->addWidget( cancel );
194 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
195 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
196 resize( 200, 200 ); 201 resize( 200, 200 );
197 } 202 }
198 203
199 bool addCat() { return addCatBut->isChecked(); } 204 bool addCat() { return addCatBut->isChecked(); }
200private: 205private:
201 QRadioButton* addCatBut; 206 QRadioButton* addCatBut;
202}; 207};
203 208
204 209
205 210
206CalendarView::CalendarView( CalendarResources *calendar, 211CalendarView::CalendarView( CalendarResources *calendar,
207 QWidget *parent, const char *name ) 212 QWidget *parent, const char *name )
208 : CalendarViewBase( parent, name ), 213 : CalendarViewBase( parent, name ),
209 mCalendar( calendar ), 214 mCalendar( calendar ),
210 mResourceManager( calendar->resourceManager() ) 215 mResourceManager( calendar->resourceManager() )
211{ 216{
212 217
213 mEventEditor = 0; 218 mEventEditor = 0;
214 mTodoEditor = 0; 219 mTodoEditor = 0;
215 220
216 init(); 221 init();
217} 222}
218 223
219CalendarView::CalendarView( Calendar *calendar, 224CalendarView::CalendarView( Calendar *calendar,
220 QWidget *parent, const char *name ) 225 QWidget *parent, const char *name )
221 : CalendarViewBase( parent, name ), 226 : CalendarViewBase( parent, name ),
222 mCalendar( calendar ), 227 mCalendar( calendar ),
223 mResourceManager( 0 ) 228 mResourceManager( 0 )
224{ 229{
225 230
226 mEventEditor = 0; 231 mEventEditor = 0;
227 mTodoEditor = 0; 232 mTodoEditor = 0;
228 init();} 233 init();}
229 234
230void CalendarView::init() 235void CalendarView::init()
231{ 236{
232 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
233 mDatePickerMode = 0; 238 mDatePickerMode = 0;
234 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
235 writeLocale(); 240 writeLocale();
236 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
237 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
238 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
239 mModified = false; 244 mModified = false;
240 mReadOnly = false; 245 mReadOnly = false;
241 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
242 mCalPrinter = 0; 247 mCalPrinter = 0;
243 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
244 249
245 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
246 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
247 252
248 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
249 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
250 255
251 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
252#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
253 // create the main layout frames. 258 // create the main layout frames.
@@ -1237,193 +1242,192 @@ bool CalendarView::syncCalendar(QString filename, int mode)
1237} 1242}
1238void CalendarView::syncPhone() 1243void CalendarView::syncPhone()
1239{ 1244{
1240 syncExternal( 1 ); 1245 syncExternal( 1 );
1241} 1246}
1242void CalendarView::syncExternal( int mode ) 1247void CalendarView::syncExternal( int mode )
1243{ 1248{
1244 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1245 //mCurrentSyncDevice = "sharp-DTM"; 1250 //mCurrentSyncDevice = "sharp-DTM";
1246 if ( KOPrefs::instance()->mAskForPreferences ) 1251 if ( KOPrefs::instance()->mAskForPreferences )
1247 edit_sync_options(); 1252 edit_sync_options();
1248 qApp->processEvents(); 1253 qApp->processEvents();
1249 CalendarLocal* calendar = new CalendarLocal(); 1254 CalendarLocal* calendar = new CalendarLocal();
1250 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1255 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1251 bool syncOK = false; 1256 bool syncOK = false;
1252 bool loadSuccess = false; 1257 bool loadSuccess = false;
1253 PhoneFormat* phoneFormat = 0; 1258 PhoneFormat* phoneFormat = 0;
1254#ifndef DESKTOP_VERSION 1259#ifndef DESKTOP_VERSION
1255 SharpFormat* sharpFormat = 0; 1260 SharpFormat* sharpFormat = 0;
1256 if ( mode == 0 ) { // sharp 1261 if ( mode == 0 ) { // sharp
1257 sharpFormat = new SharpFormat () ; 1262 sharpFormat = new SharpFormat () ;
1258 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1263 loadSuccess = sharpFormat->load( calendar, mCalendar );
1259 1264
1260 } else 1265 } else
1261#endif 1266#endif
1262 if ( mode == 1 ) { // phone 1267 if ( mode == 1 ) { // phone
1263 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1268 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1264 KOPrefs::instance()->mPhoneDevice, 1269 KOPrefs::instance()->mPhoneDevice,
1265 KOPrefs::instance()->mPhoneConnection, 1270 KOPrefs::instance()->mPhoneConnection,
1266 KOPrefs::instance()->mPhoneModel); 1271 KOPrefs::instance()->mPhoneModel);
1267 loadSuccess = phoneFormat->load( calendar,mCalendar); 1272 loadSuccess = phoneFormat->load( calendar,mCalendar);
1268 1273
1269 } else 1274 } else
1270 return; 1275 return;
1271 if ( loadSuccess ) { 1276 if ( loadSuccess ) {
1272 getEventViewerDialog()->setSyncMode( true ); 1277 getEventViewerDialog()->setSyncMode( true );
1273 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1278 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1274 getEventViewerDialog()->setSyncMode( false ); 1279 getEventViewerDialog()->setSyncMode( false );
1275 qApp->processEvents(); 1280 qApp->processEvents();
1276 if ( syncOK ) { 1281 if ( syncOK ) {
1277 if ( KOPrefs::instance()->mWriteBackFile ) 1282 if ( KOPrefs::instance()->mWriteBackFile )
1278 { 1283 {
1279 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1284 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1280 Incidence* inc = iL.first(); 1285 Incidence* inc = iL.first();
1281 if ( phoneFormat ) { 1286 if ( phoneFormat ) {
1282 while ( inc ) { 1287 while ( inc ) {
1283 inc->removeID(mCurrentSyncDevice); 1288 inc->removeID(mCurrentSyncDevice);
1284 inc = iL.next(); 1289 inc = iL.next();
1285 } 1290 }
1286 } 1291 }
1287#ifndef DESKTOP_VERSION 1292#ifndef DESKTOP_VERSION
1288 if ( sharpFormat ) 1293 if ( sharpFormat )
1289 sharpFormat->save(calendar); 1294 sharpFormat->save(calendar);
1290#endif 1295#endif
1291 if ( phoneFormat ) 1296 if ( phoneFormat )
1292 phoneFormat->save(calendar); 1297 phoneFormat->save(calendar);
1293 iL = calendar->rawIncidences(); 1298 iL = calendar->rawIncidences();
1294 inc = iL.first(); 1299 inc = iL.first();
1295 Incidence* loc; 1300 Incidence* loc;
1296 while ( inc ) { 1301 while ( inc ) {
1297 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1302 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1298 loc = mCalendar->incidence(inc->uid() ); 1303 loc = mCalendar->incidence(inc->uid() );
1299 if ( loc ) { 1304 if ( loc ) {
1300 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1305 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1301 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1306 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1302 } 1307 }
1303 } 1308 }
1304 inc = iL.next(); 1309 inc = iL.next();
1305 } 1310 }
1306 Incidence* lse = getLastSyncEvent(); 1311 Incidence* lse = getLastSyncEvent();
1307 if ( lse ) { 1312 if ( lse ) {
1308 lse->setReadOnly( false ); 1313 lse->setReadOnly( false );
1309 lse->setDescription( "" ); 1314 lse->setDescription( "" );
1310 lse->setReadOnly( true ); 1315 lse->setReadOnly( true );
1311 } 1316 }
1312 } 1317 }
1313 } 1318 }
1314 setModified( true ); 1319 setModified( true );
1315 } else { 1320 } else {
1316 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1321 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1317 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1322 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1318 question, i18n("Ok")) ; 1323 question, i18n("Ok")) ;
1319 1324
1320 } 1325 }
1321 delete calendar; 1326 delete calendar;
1322 updateView(); 1327 updateView();
1323 return ;//syncOK; 1328 return ;//syncOK;
1324 1329
1325} 1330}
1326void CalendarView::syncSharp() 1331void CalendarView::syncSharp()
1327{ 1332{
1328 syncExternal( 0 ); 1333 syncExternal( 0 );
1329 1334
1330} 1335}
1331 1336
1332 1337
1333//#include <kabc/stdaddressbook.h>
1334bool CalendarView::importBday() 1338bool CalendarView::importBday()
1335{ 1339{
1336#ifndef KORG_NOKABC 1340#ifndef KORG_NOKABC
1337 1341
1338#ifdef DESKTOP_VERSION 1342#ifdef DESKTOP_VERSION
1339 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1343 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1340 KABC::AddressBook::Iterator it; 1344 KABC::AddressBook::Iterator it;
1341 int count = 0; 1345 int count = 0;
1342 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1346 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1343 ++count; 1347 ++count;
1344 } 1348 }
1345 QProgressBar bar(count,0 ); 1349 QProgressBar bar(count,0 );
1346 int w = 300; 1350 int w = 300;
1347 if ( QApplication::desktop()->width() < 320 ) 1351 if ( QApplication::desktop()->width() < 320 )
1348 w = 220; 1352 w = 220;
1349 int h = bar.sizeHint().height() ; 1353 int h = bar.sizeHint().height() ;
1350 int dw = QApplication::desktop()->width(); 1354 int dw = QApplication::desktop()->width();
1351 int dh = QApplication::desktop()->height(); 1355 int dh = QApplication::desktop()->height();
1352 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1356 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1353 bar.show(); 1357 bar.show();
1354 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1358 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1355 qApp->processEvents(); 1359 qApp->processEvents();
1356 count = 0; 1360 count = 0;
1357 int addCount = 0; 1361 int addCount = 0;
1358 KCal::Attendee* a = 0; 1362 KCal::Attendee* a = 0;
1359 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1363 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1360 if ( ! bar.isVisible() ) 1364 if ( ! bar.isVisible() )
1361 return false; 1365 return false;
1362 bar.setProgress( count++ ); 1366 bar.setProgress( count++ );
1363 qApp->processEvents(); 1367 qApp->processEvents();
1364 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1368 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1365 if ( (*it).birthday().date().isValid() ){ 1369 if ( (*it).birthday().date().isValid() ){
1366 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1370 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1367 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1371 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1368 ++addCount; 1372 ++addCount;
1369 } 1373 }
1370 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1374 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1371 if ( anni.isValid() ){ 1375 if ( anni.isValid() ){
1372 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1376 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1373 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1377 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1374 ++addCount; 1378 ++addCount;
1375 } 1379 }
1376 } 1380 }
1377 updateView(); 1381 updateView();
1378 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1382 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1379#else //DESKTOP_VERSION 1383#else //DESKTOP_VERSION
1380 1384
1381 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1385 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1382 // the result should now arrive through method insertBirthdays 1386 // the result should now arrive through method insertBirthdays
1383 1387
1384#endif //DESKTOP_VERSION 1388#endif //DESKTOP_VERSION
1385 1389
1386#endif //KORG_NOKABC 1390#endif //KORG_NOKABC
1387 1391
1388 1392
1389 return true; 1393 return true;
1390} 1394}
1391 1395
1392// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1396// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1393void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1397void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1394 const QStringList& anniversaryList, const QStringList& realNameList, 1398 const QStringList& anniversaryList, const QStringList& realNameList,
1395 const QStringList& emailList, const QStringList& assembledNameList, 1399 const QStringList& emailList, const QStringList& assembledNameList,
1396 const QStringList& uidList) 1400 const QStringList& uidList)
1397{ 1401{
1398 qDebug("CalendarView::insertBirthdays"); 1402 qDebug("CalendarView::insertBirthdays");
1399 if (uid == this->name()) 1403 if (uid == this->name())
1400 { 1404 {
1401 int count = birthdayList.count(); 1405 int count = birthdayList.count();
1402 int addCount = 0; 1406 int addCount = 0;
1403 KCal::Attendee* a = 0; 1407 KCal::Attendee* a = 0;
1404 1408
1405 qDebug("CalView 1 %i", count); 1409 qDebug("CalView 1 %i", count);
1406 1410
1407 QProgressBar bar(count,0 ); 1411 QProgressBar bar(count,0 );
1408 int w = 300; 1412 int w = 300;
1409 if ( QApplication::desktop()->width() < 320 ) 1413 if ( QApplication::desktop()->width() < 320 )
1410 w = 220; 1414 w = 220;
1411 int h = bar.sizeHint().height() ; 1415 int h = bar.sizeHint().height() ;
1412 int dw = QApplication::desktop()->width(); 1416 int dw = QApplication::desktop()->width();
1413 int dh = QApplication::desktop()->height(); 1417 int dh = QApplication::desktop()->height();
1414 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1418 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1415 bar.show(); 1419 bar.show();
1416 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1420 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1417 qApp->processEvents(); 1421 qApp->processEvents();
1418 1422
1419 QDate birthday; 1423 QDate birthday;
1420 QDate anniversary; 1424 QDate anniversary;
1421 QString realName; 1425 QString realName;
1422 QString email; 1426 QString email;
1423 QString assembledName; 1427 QString assembledName;
1424 QString uid; 1428 QString uid;
1425 bool ok = true; 1429 bool ok = true;
1426 for ( int i = 0; i < count; i++) 1430 for ( int i = 0; i < count; i++)
1427 { 1431 {
1428 if ( ! bar.isVisible() ) 1432 if ( ! bar.isVisible() )
1429 return; 1433 return;