summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
Unidiff
Diffstat (limited to 'korganizer/kofilterview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index ce2880a..9709324 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -100,298 +100,306 @@ void KOFilterView::setSelectedFilter(QString filterName)
100 emit filterChanged(); 100 emit filterChanged();
101} 101}
102void KOFilterView::setSelectedFilter( int fil ) 102void KOFilterView::setSelectedFilter( int fil )
103{ 103{
104 if ( fil >= mSelectionCombo->count() ) 104 if ( fil >= mSelectionCombo->count() )
105 return; 105 return;
106 mSelectionCombo->setCurrentItem( fil ); 106 mSelectionCombo->setCurrentItem( fil );
107 emit filterChanged(); 107 emit filterChanged();
108} 108}
109 109
110 110
111 111
112KOCalEditView::KOCalEditView(QWidget* parent, 112KOCalEditView::KOCalEditView(QWidget* parent,
113 const char* name ) 113 const char* name )
114 : QScrollView(parent,name) 114 : QScrollView(parent,name)
115{ 115{
116 mw = 0; 116 mw = 0;
117 setResizePolicy( AutoOneFit ); 117 setResizePolicy( AutoOneFit );
118 setFrameStyle ( QFrame::Panel | QFrame::Plain ); 118 setFrameStyle ( QFrame::Panel | QFrame::Plain );
119 setLineWidth ( 1 ); 119 setLineWidth ( 1 );
120 setMidLineWidth ( 1 ); 120 setMidLineWidth ( 1 );
121 setFocusPolicy(NoFocus); 121 setFocusPolicy(NoFocus);
122} 122}
123 123
124KOCalEditView::~KOCalEditView() 124KOCalEditView::~KOCalEditView()
125{ 125{
126 // no need to delete child widgets, Qt does it all for us 126 // no need to delete child widgets, Qt does it all for us
127} 127}
128void KOCalEditView::selectCal(int id ,bool b) 128void KOCalEditView::selectCal(int id ,bool b)
129{ 129{
130 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 130 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
131 emit calendarEnabled ( id, b ); 131 emit calendarEnabled ( id, b );
132 emit needsUpdate(); 132 emit needsUpdate();
133 133
134} 134}
135void KOCalEditView::selectStdCal( int id, bool b ) 135void KOCalEditView::selectStdCal( int id, bool b )
136{ 136{
137 137
138 if ( !b ) { 138 if ( !b ) {
139 KOCalCheckButton* it = (KOCalCheckButton*) sender(); 139 KOCalCheckButton* it = (KOCalCheckButton*) sender();
140 if ( it ) { 140 if ( it ) {
141 it->blockSignals( true ); 141 it->blockSignals( true );
142 it->setChecked( true ); 142 it->setChecked( true );
143 it->blockSignals( false ); 143 it->blockSignals( false );
144 return; 144 return;
145 } 145 }
146 return; 146 return;
147 } 147 }
148 KOCalCheckButton* sen = (KOCalCheckButton*) sender(); 148 KOCalRadioButton* sen = (KOCalRadioButton*) sender();
149 KOCalCheckButton* it = mStdandardB.first(); 149 KOCalRadioButton* it = mStdandardB.first();
150 while ( it ) { 150 while ( it ) {
151 if ( it->isChecked() ) { 151 if ( it->isChecked() ) {
152 if ( it != sen ) { 152 if ( it != sen ) {
153 it->blockSignals( true ); 153 it->blockSignals( true );
154 it->setChecked( false ); 154 it->setChecked( false );
155 it->blockSignals( false ); 155 it->blockSignals( false );
156 break; 156 break;
157 } 157 }
158 } 158 }
159 it = mStdandardB.next(); 159 it = mStdandardB.next();
160 } 160 }
161 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 161 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
162 while ( kkf ) { 162 while ( kkf ) {
163 kkf->isStandard = false; 163 kkf->isStandard = false;
164 kkf = KOPrefs::instance()->mCalendars.next(); 164 kkf = KOPrefs::instance()->mCalendars.next();
165 } 165 }
166 KOPrefs::instance()->getCalendar( id )->isStandard = true; 166 KOPrefs::instance()->getCalendar( id )->isStandard = true;
167 emit setCalendarDefault ( id ); 167 emit setCalendarDefault ( id );
168} 168}
169 169
170void KOCalEditView::selectCalAlarm(int id ,bool b ) 170void KOCalEditView::selectCalAlarm(int id ,bool b )
171{ 171{
172 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 172 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
173 emit alarmEnabled ( id , b ); 173 emit alarmEnabled ( id , b );
174 emit needsUpdate(); 174 emit needsUpdate();
175} 175}
176void KOCalEditView::selectReadOnly(int id ,bool b ) 176void KOCalEditView::selectReadOnly(int id ,bool b )
177{ 177{
178 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 178 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
179 emit calendarReadonly ( id , b ); 179 emit calendarReadonly ( id , b );
180 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { 180 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) {
181 KOPrefs::instance()->getCalendar( id )->isStandard = false; 181 KOPrefs::instance()->getCalendar( id )->isStandard = false;
182 KOPrefs::instance()->getCalendar( 1 )->isStandard = true; 182 KOPrefs::instance()->getCalendar( 1 )->isStandard = true;
183 emit setCalendarDefault ( 1 ); 183 emit setCalendarDefault ( 1 );
184 } 184 }
185 emit needsUpdate(); 185 emit needsUpdate();
186 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 186 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
187 187
188} 188}
189void KOCalEditView::setColor( const QColor& c, int id ) 189void KOCalEditView::setColor( const QColor& c, int id )
190{ 190{
191 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 191 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
192 emit needsUpdate(); 192 emit needsUpdate();
193} 193}
194void KOCalEditView::deleteCal( int id ) 194void KOCalEditView::deleteCal( int id )
195{ 195{
196 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 196 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
197 QString name = kkf->mName; 197 QString name = kkf->mName;
198 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 198 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
199 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 199 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
200 if ( kkf->isStandard ) 200 if ( kkf->isStandard )
201 selectStdCal( 1, true ); 201 selectStdCal( 1, true );
202 emit removeCalendar ( id ); 202 emit removeCalendar ( id );
203 KOPrefs::instance()->mCalendars.remove ( kkf ); 203 KOPrefs::instance()->mCalendars.remove ( kkf );
204 emit needsUpdate(); 204 emit needsUpdate();
205 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 205 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
206} 206}
207void KOCalEditView::infoCal( int id ) 207void KOCalEditView::infoCal( int id )
208{ 208{
209 QString name = KOPrefs::instance()->getCalendar( id )->mName; 209 QString name = KOPrefs::instance()->getCalendar( id )->mName;
210 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); 210 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 );
211 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { 211 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
212 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { 212 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) {
213 emit calendarAdded( id ); 213 emit calendarAdded( id );
214 emit needsUpdate(); 214 emit needsUpdate();
215 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 215 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
216 } 216 }
217 } 217 }
218 else 218 else
219 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 219 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
220} 220}
221void KOCalEditView::readConfig() 221void KOCalEditView::readConfig()
222{ 222{
223 223
224 mStdandardB.clear(); 224 mStdandardB.clear();
225 mEnabledB.clear(); 225 mEnabledB.clear();
226 mAlarmB.clear(); 226 mAlarmB.clear();
227 mROB.clear(); 227 mROB.clear();
228 228
229 if ( mw ) delete mw; 229 if ( mw ) delete mw;
230 mw = new QWidget ( viewport() ); 230 mw = new QWidget ( viewport() );
231 addChild(mw); 231 addChild(mw);
232 int ii = 0; 232 int ii = 0;
233 mainLayout = new QGridLayout ( mw , 2, 8 ); 233 mainLayout = new QGridLayout ( mw , 2, 8 );
234 mainLayout->setMargin( 2 ); 234 mainLayout->setMargin( 2 );
235 mainLayout->setSpacing( 2 ); 235 mainLayout->setSpacing( 2 );
236 QPushButton * addBut = new QPushButton ( mw ); 236 QPushButton * addBut = new QPushButton ( mw );
237 addBut->setFocusPolicy(NoFocus); 237 addBut->setFocusPolicy(NoFocus);
238 mainLayout->addWidget( addBut,0,0 ); 238 mainLayout->addWidget( addBut,0,0 );
239 addBut->setPixmap ( SmallIcon("greenhook16")); 239 addBut->setText( "D");
240 connect(addBut,SIGNAL(clicked()),SLOT(defaultInfo()));
241 //addBut->setPixmap ( SmallIcon("greenhook16"));
240 addBut->setMaximumWidth( addBut->sizeHint().height() ); 242 addBut->setMaximumWidth( addBut->sizeHint().height() );
241 int max = addBut->sizeHint().height(); 243 int max = addBut->sizeHint().height();
242 addBut = new QPushButton ( mw ); 244 addBut = new QPushButton ( mw );
243 addBut->setFocusPolicy(NoFocus); 245 addBut->setFocusPolicy(NoFocus);
244 mainLayout->addWidget( addBut,0,++ii ); 246 mainLayout->addWidget( addBut,0,++ii );
245 addBut->setPixmap ( SmallIcon("eye")); 247 addBut->setPixmap ( SmallIcon("eye"));
246 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 248 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
247 addBut->setMaximumWidth( addBut->sizeHint().height() ); 249 addBut->setMaximumWidth( addBut->sizeHint().height() );
248 250
249 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); 251 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw );
250 mainLayout->addWidget( lab,0,++ii ); 252 mainLayout->addWidget( lab,0,++ii );
251 //lab = new QLabel ( i18n(" "), mw ); 253 //lab = new QLabel ( i18n(" "), mw );
252 //mainLayout->addWidget( lab,0,++ii ); 254 //mainLayout->addWidget( lab,0,++ii );
253 //lab->setFixedWidth( 1 ); 255 //lab->setFixedWidth( 1 );
254 addBut = new QPushButton ( mw ); 256 addBut = new QPushButton ( mw );
255 addBut->setFocusPolicy(NoFocus); 257 addBut->setFocusPolicy(NoFocus);
256 mainLayout->addWidget( addBut,0,++ii ); 258 mainLayout->addWidget( addBut,0,++ii );
257 addBut->setPixmap ( SmallIcon("bell")); 259 addBut->setPixmap ( SmallIcon("bell"));
258 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 260 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
259 addBut->setMaximumWidth( addBut->sizeHint().height() ); 261 addBut->setMaximumWidth( addBut->sizeHint().height() );
260 262
261 addBut = new QPushButton ( mw ); 263 addBut = new QPushButton ( mw );
262 addBut->setFocusPolicy(NoFocus); 264 addBut->setFocusPolicy(NoFocus);
263 mainLayout->addWidget( addBut,0,++ii ); 265 mainLayout->addWidget( addBut,0,++ii );
264 addBut->setPixmap ( SmallIcon("pencil")); 266 addBut->setPixmap ( SmallIcon("pencil"));
265 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 267 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
266 addBut->setMaximumWidth( addBut->sizeHint().height() ); 268 addBut->setMaximumWidth( addBut->sizeHint().height() );
267 lab = new QLabel ( "", mw ); 269 lab = new QLabel ( "", mw );
268 mainLayout->addWidget( lab,0,++ii ); 270 mainLayout->addWidget( lab,0,++ii );
269 271
270 addBut = new QPushButton ( mw ); 272 addBut = new QPushButton ( mw );
271 addBut->setFocusPolicy(NoFocus); 273 addBut->setFocusPolicy(NoFocus);
272 mainLayout->addWidget( addBut,0,++ii ); 274 mainLayout->addWidget( addBut,0,++ii );
273 addBut->setPixmap ( SmallIcon("plus")); 275 addBut->setPixmap ( SmallIcon("plus"));
274 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 276 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
275 277
276 lab = new QLabel ( " ", mw ); 278 lab = new QLabel ( " ", mw );
277 mainLayout->addWidget( lab,0,++ii ); 279 mainLayout->addWidget( lab,0,++ii );
278 280
279 281
280#if 0 282#if 0
281 addBut = new QPushButton ( mw ); 283 addBut = new QPushButton ( mw );
282 mainLayout->addWidget( addBut,0,6 ); 284 mainLayout->addWidget( addBut,0,6 );
283 addBut->setPixmap ( SmallIcon("minus")); 285 addBut->setPixmap ( SmallIcon("minus"));
284 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); 286 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll()));
285 addBut->setMaximumWidth( addBut->sizeHint().height() ); 287 addBut->setMaximumWidth( addBut->sizeHint().height() );
286#endif 288#endif
287 289
288 290
289 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 291 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
290 int row = 1; 292 int row = 1;
291 while ( kkf ) { 293 while ( kkf ) {
292 int iii = 0; 294 int iii = 0;
293 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 295 KOCalRadioButton* rb = new KOCalRadioButton( mw );
294 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); 296 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb );
295 cb->setChecked( kkf->isStandard ); 297 rb->setChecked( kkf->isStandard );
296 cb->setNum( kkf->mCalNumber ); 298 rb->setNum( kkf->mCalNumber );
297 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); 299 connect (rb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
298 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 300 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
299 cb->setEnabled( false ); 301 rb->setEnabled( false );
300 cb = new KOCalCheckButton( mw ); 302 KOCalCheckButton* cb = new KOCalCheckButton( mw );
301 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); 303 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb );
302 cb->setChecked( kkf->isEnabled ); 304 cb->setChecked( kkf->isEnabled );
303 cb->setNum( kkf->mCalNumber ); 305 cb->setNum( kkf->mCalNumber );
304 if ( kkf->mErrorOnLoad ) 306 if ( kkf->mErrorOnLoad )
305 cb->setEnabled( false ); 307 cb->setEnabled( false );
306 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 308 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
307 KOCalButton* name = new KOCalButton( mw ); 309 KOCalButton* name = new KOCalButton( mw );
308 name->setNum( kkf->mCalNumber ); 310 name->setNum( kkf->mCalNumber );
309 name->setText( kkf->mName ); 311 name->setText( kkf->mName );
310 mainLayout->addWidget( name,row,++iii ); 312 mainLayout->addWidget( name,row,++iii );
311 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 313 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
312 //lab = new QLabel (" ", mw ); 314 //lab = new QLabel (" ", mw );
313 //mainLayout->addWidget( lab,row,++iii ); 315 //mainLayout->addWidget( lab,row,++iii );
314 cb = new KOCalCheckButton( mw ); 316 cb = new KOCalCheckButton( mw );
315 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); 317 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb );
316 cb->setChecked( kkf->isAlarmEnabled ); 318 cb->setChecked( kkf->isAlarmEnabled );
317 cb->setNum( kkf->mCalNumber ); 319 cb->setNum( kkf->mCalNumber );
318 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 320 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
319 if ( kkf->mErrorOnLoad ) 321 if ( kkf->mErrorOnLoad )
320 cb->setEnabled( false ); 322 cb->setEnabled( false );
321 cb = new KOCalCheckButton( mw ); 323 cb = new KOCalCheckButton( mw );
322 mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); 324 mainLayout->addWidget( cb,row,++iii );mROB.append( cb );
323 cb->setChecked( kkf->isReadOnly ); 325 cb->setChecked( kkf->isReadOnly );
324 cb->setNum( kkf->mCalNumber ); 326 cb->setNum( kkf->mCalNumber );
325 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 327 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
326 if ( kkf->mErrorOnLoad ) 328 if ( kkf->mErrorOnLoad )
327 cb->setEnabled( false ); 329 cb->setEnabled( false );
328 if ( row > 1) { 330 if ( row > 1) {
329 KColorButton *colb = new KColorButton( mw ); 331 KColorButton *colb = new KColorButton( mw );
330 mainLayout->addWidget( colb,row,++iii ); 332 mainLayout->addWidget( colb,row,++iii );
331 colb->setID( kkf->mCalNumber ); 333 colb->setID( kkf->mCalNumber );
332 colb->setColor( kkf->mDefaultColor ); 334 colb->setColor( kkf->mDefaultColor );
333 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 335 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
334 KOCalButton* calb = new KOCalButton( mw ); 336 KOCalButton* calb = new KOCalButton( mw );
335 mainLayout->addWidget( calb,row,++iii ); 337 mainLayout->addWidget( calb,row,++iii );
336 calb->setNum( kkf->mCalNumber ); 338 calb->setNum( kkf->mCalNumber );
337 calb->setPixmap ( SmallIcon("minus")); 339 calb->setPixmap ( SmallIcon("minus"));
338 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 340 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
339 int hei = calb->sizeHint().height(); 341 int hei = calb->sizeHint().height();
340 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 342 //calb->setMaximumSize( hei*9/10, hei*9/10 );
341 } 343 }
342 ++row; 344 ++row;
343 kkf = KOPrefs::instance()->mCalendars.next(); 345 kkf = KOPrefs::instance()->mCalendars.next();
344 } 346 }
345 lab = new QLabel ( "", mw ); 347 lab = new QLabel ( "", mw );
346 mainLayout->addWidget( lab,row,0 ); 348 mainLayout->addWidget( lab,row,0 );
347 mw->show(); 349 mw->show();
348 350
349} 351}
352
353
354void KOCalEditView::defaultInfo()
355{
356 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
357}
350void KOCalEditView::addCal() 358void KOCalEditView::addCal()
351{ 359{
352 bool tryagain = true; 360 bool tryagain = true;
353 QString name, file; 361 QString name, file;
354 while ( tryagain ) { 362 while ( tryagain ) {
355 KONewCalPrefs prefs ( this ); 363 KONewCalPrefs prefs ( this );
356 prefs.nameE->setText( name ); 364 prefs.nameE->setText( name );
357 prefs.url->setURL( file ); 365 prefs.url->setURL( file );
358 if ( ! prefs.exec() ) 366 if ( ! prefs.exec() )
359 return; 367 return;
360 name = prefs.calName(); 368 name = prefs.calName();
361 file = prefs.calFileName(); 369 file = prefs.calFileName();
362 tryagain = false; 370 tryagain = false;
363 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 371 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
364 while ( kkf ) { 372 while ( kkf ) {
365 if ( kkf->mName == name ) { 373 if ( kkf->mName == name ) {
366 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); 374 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
367 name = ""; 375 name = "";
368 tryagain = true; 376 tryagain = true;
369 break; 377 break;
370 } 378 }
371 if ( kkf->mFileName == file ) { 379 if ( kkf->mFileName == file ) {
372 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); 380 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
373 tryagain = true; 381 tryagain = true;
374 file = ""; 382 file = "";
375 break; 383 break;
376 } 384 }
377 kkf = KOPrefs::instance()->mCalendars.next(); 385 kkf = KOPrefs::instance()->mCalendars.next();
378 } 386 }
379 } 387 }
380 QFileInfo fi ( file ); 388 QFileInfo fi ( file );
381 if (!fi.exists() ) { 389 if (!fi.exists() ) {
382 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) 390 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No )
383 return; 391 return;
384 QFile fileIn( file ); 392 QFile fileIn( file );
385 if (!fileIn.open( IO_WriteOnly ) ) { 393 if (!fileIn.open( IO_WriteOnly ) ) {
386 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); 394 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
387 return; 395 return;
388 } 396 }
389 QTextStream tsIn( &fileIn ); 397 QTextStream tsIn( &fileIn );
390 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 398 tsIn.setCodec( QTextCodec::codecForName("utf8") );
391 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; 399 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
392 fileIn.close(); 400 fileIn.close();
393 } 401 }
394 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 402 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
395 kkf->mName = name; 403 kkf->mName = name;
396 kkf->mFileName = file; 404 kkf->mFileName = file;
397 emit calendarAdded( kkf->mCalNumber ); 405 emit calendarAdded( kkf->mCalNumber );