-rw-r--r-- | korganizer/kofilterview.cpp | 95 | ||||
-rw-r--r-- | korganizer/kofilterview.h | 14 |
2 files changed, 63 insertions, 46 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 20118aa..1335d7e 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -111,119 +111,127 @@ void KOFilterView::setSelectedFilter( int fil ) | |||
111 | 111 | ||
112 | KOCalEditView::KOCalEditView(QWidget* parent, | 112 | KOCalEditView::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 | ||
124 | KOCalEditView::~KOCalEditView() | 124 | KOCalEditView::~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 | } |
128 | void KOCalEditView::selectCal(int id ,bool b) | 128 | void 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 | } |
135 | void KOCalEditView::selectStdCal( int id, bool b ) | 135 | void KOCalEditView::selectStdCal( int id ) |
136 | { | 136 | { |
137 | |||
138 | if ( !b ) { | ||
139 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); | ||
140 | if ( it ) { | ||
141 | it->blockSignals( true ); | ||
142 | it->setChecked( true ); | ||
143 | it->blockSignals( false ); | ||
144 | return; | ||
145 | } | ||
146 | return; | ||
147 | } | ||
148 | KOCalRadioButton* sen = (KOCalRadioButton*) sender(); | ||
149 | KOCalRadioButton* it = mStdandardB.first(); | 137 | KOCalRadioButton* it = mStdandardB.first(); |
150 | while ( it ) { | 138 | while ( it ) { |
151 | if ( it->isChecked() ) { | 139 | it->blockSignals( true ); |
152 | if ( it != sen ) { | 140 | it->setChecked( it->num() == id ); |
153 | it->blockSignals( true ); | 141 | it->blockSignals( false ); |
154 | it->setChecked( false ); | ||
155 | it->blockSignals( false ); | ||
156 | break; | ||
157 | } | ||
158 | } | ||
159 | it = mStdandardB.next(); | 142 | it = mStdandardB.next(); |
160 | } | 143 | } |
161 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 144 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
162 | while ( kkf ) { | 145 | while ( kkf ) { |
163 | kkf->isStandard = false; | 146 | kkf->isStandard = (kkf->mCalNumber == id ); |
164 | kkf = KOPrefs::instance()->mCalendars.next(); | 147 | kkf = KOPrefs::instance()->mCalendars.next(); |
165 | } | 148 | } |
166 | KOPrefs::instance()->getCalendar( id )->isStandard = true; | ||
167 | emit setCalendarDefault ( id ); | 149 | emit setCalendarDefault ( id ); |
168 | } | 150 | } |
169 | 151 | ||
170 | void KOCalEditView::selectCalAlarm(int id ,bool b ) | 152 | void KOCalEditView::selectCalAlarm(int id ,bool b ) |
171 | { | 153 | { |
172 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; | 154 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; |
173 | emit alarmEnabled ( id , b ); | 155 | emit alarmEnabled ( id , b ); |
174 | emit needsUpdate(); | 156 | emit needsUpdate(); |
175 | } | 157 | } |
176 | void KOCalEditView::selectReadOnly(int id ,bool b ) | 158 | void KOCalEditView::selectReadOnly(int id ,bool b ) |
177 | { | 159 | { |
178 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; | 160 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; |
179 | emit calendarReadonly ( id , b ); | 161 | emit calendarReadonly ( id , b ); |
180 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { | 162 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) { |
181 | KOPrefs::instance()->getCalendar( id )->isStandard = false; | 163 | findNewStandard(); |
182 | KOPrefs::instance()->getCalendar( 1 )->isStandard = true; | 164 | } else { |
183 | mStdandardB.at(0)->setChecked( true ); | 165 | if ( !b ){ |
184 | mStdandardB.at(id-1)->setChecked( false ); | 166 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
185 | emit setCalendarDefault ( 1 ); | 167 | while ( kkf ) { |
168 | if (kkf->isReadOnly && kkf->isStandard ) { | ||
169 | selectStdCal( id ); | ||
170 | break; | ||
171 | } | ||
172 | kkf = KOPrefs::instance()->mCalendars.next(); | ||
173 | } | ||
174 | } | ||
186 | } | 175 | } |
187 | mStdandardB.at(id-1)->setEnabled( !b ); | 176 | mStdandardB.at(id-1)->setEnabled( !b ); |
188 | emit needsUpdate(); | 177 | emit needsUpdate(); |
189 | 178 | ||
190 | } | 179 | } |
180 | void KOCalEditView::findNewStandard() | ||
181 | { | ||
182 | bool found = false; | ||
183 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | ||
184 | while ( kkf ) { | ||
185 | if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) { | ||
186 | found = true; | ||
187 | selectStdCal( kkf->mCalNumber ); | ||
188 | break; | ||
189 | } | ||
190 | kkf = KOPrefs::instance()->mCalendars.next(); | ||
191 | } | ||
192 | if ( !found ) { | ||
193 | KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"), | ||
194 | i18n("Houston, we have a problem!") ); | ||
195 | |||
196 | } | ||
197 | } | ||
198 | |||
191 | void KOCalEditView::setColor( const QColor& c, int id ) | 199 | void KOCalEditView::setColor( const QColor& c, int id ) |
192 | { | 200 | { |
193 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; | 201 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; |
194 | emit needsUpdate(); | 202 | emit needsUpdate(); |
195 | } | 203 | } |
196 | void KOCalEditView::deleteCal( int id ) | 204 | void KOCalEditView::deleteCal( int id ) |
197 | { | 205 | { |
198 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 206 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
199 | QString name = kkf->mName; | 207 | QString name = kkf->mName; |
200 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); | 208 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
201 | 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; | 209 | 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; |
202 | if ( kkf->isStandard ) | 210 | bool findnewstd = kkf->isStandard; |
203 | selectStdCal( 1, true ); | ||
204 | emit removeCalendar ( id ); | 211 | emit removeCalendar ( id ); |
205 | KOPrefs::instance()->mCalendars.remove ( kkf ); | 212 | KOPrefs::instance()->mCalendars.remove ( kkf ); |
213 | if ( findnewstd ) findNewStandard(); | ||
206 | emit needsUpdate(); | 214 | emit needsUpdate(); |
207 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 215 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
208 | } | 216 | } |
209 | void KOCalEditView::infoCal( int id ) | 217 | void KOCalEditView::infoCal( int id ) |
210 | { | 218 | { |
211 | QString name = KOPrefs::instance()->getCalendar( id )->mName; | 219 | QString name = KOPrefs::instance()->getCalendar( id )->mName; |
212 | QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); | 220 | QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); |
213 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { | 221 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { |
214 | 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) ) ) { | 222 | 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) ) ) { |
215 | emit calendarAdded( id ); | 223 | emit calendarAdded( id ); |
216 | emit needsUpdate(); | 224 | emit needsUpdate(); |
217 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 225 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
218 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); | 226 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); |
219 | } | 227 | } |
220 | } | 228 | } |
221 | else | 229 | else |
222 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | 230 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); |
223 | } | 231 | } |
224 | void KOCalEditView::readConfig() | 232 | void KOCalEditView::readConfig() |
225 | { | 233 | { |
226 | 234 | ||
227 | mStdandardB.clear(); | 235 | mStdandardB.clear(); |
228 | mEnabledB.clear(); | 236 | mEnabledB.clear(); |
229 | mAlarmB.clear(); | 237 | mAlarmB.clear(); |
@@ -263,109 +271,113 @@ void KOCalEditView::readConfig() | |||
263 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 271 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
264 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 272 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
265 | 273 | ||
266 | addBut = new QPushButton ( mw ); | 274 | addBut = new QPushButton ( mw ); |
267 | addBut->setFocusPolicy(NoFocus); | 275 | addBut->setFocusPolicy(NoFocus); |
268 | mainLayout->addWidget( addBut,0,++ii ); | 276 | mainLayout->addWidget( addBut,0,++ii ); |
269 | addBut->setPixmap ( SmallIcon("pencil")); | 277 | addBut->setPixmap ( SmallIcon("pencil")); |
270 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); | 278 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); |
271 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 279 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
272 | lab = new QLabel ( "", mw ); | 280 | lab = new QLabel ( "", mw ); |
273 | mainLayout->addWidget( lab,0,++ii ); | 281 | mainLayout->addWidget( lab,0,++ii ); |
274 | 282 | ||
275 | addBut = new QPushButton ( mw ); | 283 | addBut = new QPushButton ( mw ); |
276 | addBut->setFocusPolicy(NoFocus); | 284 | addBut->setFocusPolicy(NoFocus); |
277 | mainLayout->addWidget( addBut,0,++ii ); | 285 | mainLayout->addWidget( addBut,0,++ii ); |
278 | addBut->setPixmap ( SmallIcon("plus")); | 286 | addBut->setPixmap ( SmallIcon("plus")); |
279 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 287 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
280 | 288 | ||
281 | lab = new QLabel ( " ", mw ); | 289 | lab = new QLabel ( " ", mw ); |
282 | mainLayout->addWidget( lab,0,++ii ); | 290 | mainLayout->addWidget( lab,0,++ii ); |
283 | 291 | ||
284 | 292 | ||
285 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 293 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
286 | int row = 1; | 294 | int row = 1; |
295 | bool errorLoadStandard = false; | ||
287 | while ( kkf ) { | 296 | while ( kkf ) { |
288 | int iii = 0; | 297 | int iii = 0; |
289 | KOCalRadioButton* rb = new KOCalRadioButton( mw ); | 298 | KOCalRadioButton* rb = new KOCalRadioButton( mw ); |
290 | mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); | 299 | mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); |
291 | rb->setChecked( kkf->isStandard ); | 300 | rb->setChecked( kkf->isStandard ); |
301 | if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) | ||
302 | errorLoadStandard = true; | ||
292 | rb->setNum( kkf->mCalNumber ); | 303 | rb->setNum( kkf->mCalNumber ); |
293 | connect (rb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); | 304 | connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); |
294 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 305 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
295 | rb->setEnabled( false ); | 306 | rb->setEnabled( false ); |
296 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); | 307 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); |
297 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); | 308 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); |
298 | cb->setChecked( kkf->isEnabled ); | 309 | cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); |
299 | cb->setNum( kkf->mCalNumber ); | 310 | cb->setNum( kkf->mCalNumber ); |
300 | if ( kkf->mErrorOnLoad ) | 311 | if ( kkf->mErrorOnLoad ) |
301 | cb->setEnabled( false ); | 312 | cb->setEnabled( false ); |
302 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); | 313 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); |
303 | KOCalButton* name = new KOCalButton( mw ); | 314 | KOCalButton* name = new KOCalButton( mw ); |
304 | name->setNum( kkf->mCalNumber ); | 315 | name->setNum( kkf->mCalNumber ); |
305 | name->setText( kkf->mName ); | 316 | name->setText( kkf->mName ); |
306 | mainLayout->addWidget( name,row,++iii ); | 317 | mainLayout->addWidget( name,row,++iii ); |
307 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); | 318 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); |
308 | //lab = new QLabel (" ", mw ); | 319 | //lab = new QLabel (" ", mw ); |
309 | //mainLayout->addWidget( lab,row,++iii ); | 320 | //mainLayout->addWidget( lab,row,++iii ); |
310 | cb = new KOCalCheckButton( mw ); | 321 | cb = new KOCalCheckButton( mw ); |
311 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); | 322 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); |
312 | cb->setChecked( kkf->isAlarmEnabled ); | 323 | cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); |
313 | cb->setNum( kkf->mCalNumber ); | 324 | cb->setNum( kkf->mCalNumber ); |
314 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); | 325 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); |
315 | if ( kkf->mErrorOnLoad ) | 326 | if ( kkf->mErrorOnLoad ) |
316 | cb->setEnabled( false ); | 327 | cb->setEnabled( false ); |
317 | cb = new KOCalCheckButton( mw ); | 328 | cb = new KOCalCheckButton( mw ); |
318 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); | 329 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); |
319 | cb->setChecked( kkf->isReadOnly ); | 330 | cb->setChecked( kkf->isReadOnly ); |
320 | cb->setNum( kkf->mCalNumber ); | 331 | cb->setNum( kkf->mCalNumber ); |
321 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); | 332 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); |
322 | if ( kkf->mErrorOnLoad ) | 333 | if ( kkf->mErrorOnLoad ) |
323 | cb->setEnabled( false ); | 334 | cb->setEnabled( false ); |
324 | if ( row > 1) { | 335 | if ( row > 1) { |
325 | KColorButton *colb = new KColorButton( mw ); | 336 | KColorButton *colb = new KColorButton( mw ); |
326 | mainLayout->addWidget( colb,row,++iii ); | 337 | mainLayout->addWidget( colb,row,++iii ); |
327 | colb->setID( kkf->mCalNumber ); | 338 | colb->setID( kkf->mCalNumber ); |
328 | colb->setColor( kkf->mDefaultColor ); | 339 | colb->setColor( kkf->mDefaultColor ); |
329 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); | 340 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); |
330 | KOCalButton* calb = new KOCalButton( mw ); | 341 | KOCalButton* calb = new KOCalButton( mw ); |
331 | mainLayout->addWidget( calb,row,++iii ); | 342 | mainLayout->addWidget( calb,row,++iii ); |
332 | calb->setNum( kkf->mCalNumber ); | 343 | calb->setNum( kkf->mCalNumber ); |
333 | calb->setPixmap ( SmallIcon("minus")); | 344 | calb->setPixmap ( SmallIcon("minus")); |
334 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); | 345 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); |
335 | int hei = calb->sizeHint().height(); | 346 | int hei = calb->sizeHint().height(); |
336 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); | 347 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); |
337 | } | 348 | } |
338 | ++row; | 349 | ++row; |
339 | kkf = KOPrefs::instance()->mCalendars.next(); | 350 | kkf = KOPrefs::instance()->mCalendars.next(); |
340 | } | 351 | } |
352 | if ( errorLoadStandard ) | ||
353 | findNewStandard(); | ||
341 | lab = new QLabel ( "", mw ); | 354 | lab = new QLabel ( "", mw ); |
342 | mainLayout->addWidget( lab,row,0 ); | 355 | mainLayout->addWidget( lab,row,0 ); |
343 | mw->show(); | 356 | mw->show(); |
344 | 357 | ||
345 | } | 358 | } |
346 | 359 | ||
347 | |||
348 | void KOCalEditView::defaultInfo() | 360 | void KOCalEditView::defaultInfo() |
349 | { | 361 | { |
350 | 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.") ); | 362 | 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.") ); |
351 | } | 363 | } |
352 | void KOCalEditView::addCal() | 364 | void KOCalEditView::addCal() |
353 | { | 365 | { |
354 | bool tryagain = true; | 366 | bool tryagain = true; |
355 | QString name, file; | 367 | QString name, file; |
356 | while ( tryagain ) { | 368 | while ( tryagain ) { |
357 | KONewCalPrefs prefs ( this ); | 369 | KONewCalPrefs prefs ( this ); |
358 | prefs.nameE->setText( name ); | 370 | prefs.nameE->setText( name ); |
359 | prefs.url->setURL( file ); | 371 | prefs.url->setURL( file ); |
360 | if ( ! prefs.exec() ) | 372 | if ( ! prefs.exec() ) |
361 | return; | 373 | return; |
362 | name = prefs.calName(); | 374 | name = prefs.calName(); |
363 | file = prefs.calFileName(); | 375 | file = prefs.calFileName(); |
364 | tryagain = false; | 376 | tryagain = false; |
365 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 377 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
366 | while ( kkf ) { | 378 | while ( kkf ) { |
367 | if ( kkf->mName == name ) { | 379 | if ( kkf->mName == name ) { |
368 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); | 380 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); |
369 | name = ""; | 381 | name = ""; |
370 | tryagain = true; | 382 | tryagain = true; |
371 | break; | 383 | break; |
@@ -410,47 +422,48 @@ int KOCalEditView::addCalendar( QString name, QString file, bool ask ) | |||
410 | return kkf->mCalNumber; | 422 | return kkf->mCalNumber; |
411 | } | 423 | } |
412 | int KOCalEditView::getBirtdayID() | 424 | int KOCalEditView::getBirtdayID() |
413 | { | 425 | { |
414 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 426 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
415 | while ( kkf ) { | 427 | while ( kkf ) { |
416 | if ( kkf->mName == i18n("Birthdays") ) | 428 | if ( kkf->mName == i18n("Birthdays") ) |
417 | return kkf->mCalNumber; | 429 | return kkf->mCalNumber; |
418 | kkf = KOPrefs::instance()->mCalendars.next(); | 430 | kkf = KOPrefs::instance()->mCalendars.next(); |
419 | } | 431 | } |
420 | QString file = locateLocal( "data", "korganizer/birthdays.ics" ); | 432 | QString file = locateLocal( "data", "korganizer/birthdays.ics" ); |
421 | return addCalendar( i18n("Birthdays"), file, false ); | 433 | return addCalendar( i18n("Birthdays"), file, false ); |
422 | } | 434 | } |
423 | 435 | ||
424 | void KOCalEditView::enableAll() | 436 | void KOCalEditView::enableAll() |
425 | { | 437 | { |
426 | toggleList( mEnabledB ); | 438 | toggleList( mEnabledB ); |
427 | } | 439 | } |
428 | void KOCalEditView::enableAlarm() | 440 | void KOCalEditView::enableAlarm() |
429 | { | 441 | { |
430 | toggleList( mAlarmB ); | 442 | toggleList( mAlarmB ); |
431 | } | 443 | } |
432 | void KOCalEditView::disableRO() | 444 | void KOCalEditView::disableRO() |
433 | { | 445 | { |
434 | toggleList( mROB ); | 446 | toggleList( mROB, false ); |
435 | } | 447 | } |
436 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) | 448 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) |
437 | { | 449 | { |
438 | bool dis = false; | 450 | bool dis = !enable; |
439 | KOCalCheckButton* it = list.first(); | 451 | KOCalCheckButton* it = list.first(); |
440 | while ( it ) { | 452 | while ( it ) { |
441 | if ( !it->isChecked() ) { | 453 | if ( !it->isChecked() == enable && it->isEnabled() ) { |
442 | dis = true; | 454 | dis = !dis; |
443 | break; | 455 | break; |
444 | } | 456 | } |
445 | it = list.next(); | 457 | it = list.next(); |
446 | } | 458 | } |
447 | it = list.first(); | 459 | it = list.first(); |
448 | while ( it ) { | 460 | while ( it ) { |
449 | it->setChecked(dis); | 461 | if ( it->isEnabled() ) |
462 | it->setChecked(dis); | ||
450 | it = list.next(); | 463 | it = list.next(); |
451 | } | 464 | } |
452 | } | 465 | } |
453 | void KOCalEditView::deleteAll() | 466 | void KOCalEditView::deleteAll() |
454 | { | 467 | { |
455 | qDebug("delteAll"); | 468 | qDebug("delteAll"); |
456 | } | 469 | } |
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h index 02107cf..874fc6a 100644 --- a/korganizer/kofilterview.h +++ b/korganizer/kofilterview.h | |||
@@ -49,49 +49,51 @@ class KONewCalPrefs : public QDialog | |||
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | public: | 51 | public: |
52 | KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : | 52 | KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : |
53 | QDialog( parent, name, true ) | 53 | QDialog( parent, name, true ) |
54 | { | 54 | { |
55 | setCaption( i18n("Add new Calendar") ); | 55 | setCaption( i18n("Add new Calendar") ); |
56 | QVBoxLayout* lay = new QVBoxLayout( this ); | 56 | QVBoxLayout* lay = new QVBoxLayout( this ); |
57 | lay->setSpacing( 3 ); | 57 | lay->setSpacing( 3 ); |
58 | lay->setMargin( 3 ); | 58 | lay->setMargin( 3 ); |
59 | QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); | 59 | QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); |
60 | lay->addWidget( lab ); | 60 | lay->addWidget( lab ); |
61 | nameE = new KLineEdit( this ); | 61 | nameE = new KLineEdit( this ); |
62 | lay->addWidget( nameE ); | 62 | lay->addWidget( nameE ); |
63 | lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this ); | 63 | lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this ); |
64 | lay->addWidget( lab ); | 64 | lay->addWidget( lab ); |
65 | url = new KURLRequester ( this ); | 65 | url = new KURLRequester ( this ); |
66 | lay->addWidget( url ); | 66 | lay->addWidget( url ); |
67 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 67 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
68 | lay->addWidget( ok ); | 68 | lay->addWidget( ok ); |
69 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 69 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
70 | lay->addWidget( cancel ); | 70 | lay->addWidget( cancel ); |
71 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) ); | 71 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) ); |
72 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 72 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
73 | setMinimumWidth( 220 ); | 73 | int minwid = 220; |
74 | if ( QApplication::desktop()->width() >= 320 ) minwid = 300; | ||
75 | setMinimumWidth( minwid ); | ||
74 | resize(sizeHint() ); | 76 | resize(sizeHint() ); |
75 | } | 77 | } |
76 | 78 | ||
77 | QString calName() { return nameE->text(); } | 79 | QString calName() { return nameE->text(); } |
78 | QString calFileName() { return url->url(); } | 80 | QString calFileName() { return url->url(); } |
79 | 81 | ||
80 | public slots: | 82 | public slots: |
81 | void checkValid() { | 83 | void checkValid() { |
82 | if ( nameE->text().isEmpty() ) { | 84 | if ( nameE->text().isEmpty() ) { |
83 | KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") ); | 85 | KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") ); |
84 | nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () )); | 86 | nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () )); |
85 | return; | 87 | return; |
86 | } | 88 | } |
87 | if ( url->url().isEmpty() ) { | 89 | if ( url->url().isEmpty() ) { |
88 | KMessageBox::information( this, i18n("Sorry, the file name is empty!") ); | 90 | KMessageBox::information( this, i18n("Sorry, the file name is empty!") ); |
89 | return; | 91 | return; |
90 | } | 92 | } |
91 | accept(); | 93 | accept(); |
92 | } | 94 | } |
93 | 95 | ||
94 | public: | 96 | public: |
95 | KLineEdit* nameE; | 97 | KLineEdit* nameE; |
96 | KURLRequester *url; | 98 | KURLRequester *url; |
97 | }; | 99 | }; |
@@ -142,109 +144,111 @@ private: | |||
142 | int mNumber; | 144 | int mNumber; |
143 | void keyPressEvent ( QKeyEvent * e ) | 145 | void keyPressEvent ( QKeyEvent * e ) |
144 | { | 146 | { |
145 | e->ignore(); | 147 | e->ignore(); |
146 | } | 148 | } |
147 | 149 | ||
148 | private slots : | 150 | private slots : |
149 | void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } | 151 | void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } |
150 | }; | 152 | }; |
151 | 153 | ||
152 | class KOCalRadioButton : public QRadioButton | 154 | class KOCalRadioButton : public QRadioButton |
153 | { | 155 | { |
154 | Q_OBJECT | 156 | Q_OBJECT |
155 | public: | 157 | public: |
156 | KOCalRadioButton( QWidget *parent=0, const char *name=0 ) : | 158 | KOCalRadioButton( QWidget *parent=0, const char *name=0 ) : |
157 | QRadioButton( parent, name) | 159 | QRadioButton( parent, name) |
158 | { | 160 | { |
159 | connect( this, SIGNAL( toggled ( bool ) ), | 161 | connect( this, SIGNAL( toggled ( bool ) ), |
160 | SLOT( bottonClicked( bool ) )); | 162 | SLOT( bottonClicked( bool ) )); |
161 | mNumber = -1; | 163 | mNumber = -1; |
162 | setFocusPolicy(NoFocus); | 164 | setFocusPolicy(NoFocus); |
163 | //setMaximumWidth( 10 ); | 165 | //setMaximumWidth( 10 ); |
164 | 166 | ||
165 | } | 167 | } |
168 | int num() { return mNumber;} | ||
166 | void setNum ( int num ) {mNumber = num; } | 169 | void setNum ( int num ) {mNumber = num; } |
167 | signals: | 170 | signals: |
168 | void selectNum ( int, bool ); | 171 | void selectNum ( int ); |
169 | private: | 172 | private: |
170 | int mNumber; | 173 | int mNumber; |
171 | void keyPressEvent ( QKeyEvent * e ) | 174 | void keyPressEvent ( QKeyEvent * e ) |
172 | { | 175 | { |
173 | e->ignore(); | 176 | e->ignore(); |
174 | } | 177 | } |
175 | 178 | ||
176 | private slots : | 179 | private slots : |
177 | void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } | 180 | void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber); } |
178 | }; | 181 | }; |
179 | 182 | ||
180 | 183 | ||
181 | 184 | ||
182 | class KOFilterView : public KOFilterView_base | 185 | class KOFilterView : public KOFilterView_base |
183 | { | 186 | { |
184 | Q_OBJECT | 187 | Q_OBJECT |
185 | public: | 188 | public: |
186 | KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0); | 189 | KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0); |
187 | ~KOFilterView(); | 190 | ~KOFilterView(); |
188 | 191 | ||
189 | void updateFilters(); | 192 | void updateFilters(); |
190 | 193 | ||
191 | bool filtersEnabled(); | 194 | bool filtersEnabled(); |
192 | void setFiltersEnabled(bool); | 195 | void setFiltersEnabled(bool); |
193 | CalFilter *selectedFilter(); | 196 | CalFilter *selectedFilter(); |
194 | void setSelectedFilter(QString); | 197 | void setSelectedFilter(QString); |
195 | void setSelectedFilter( int ); | 198 | void setSelectedFilter( int ); |
196 | 199 | ||
197 | signals: | 200 | signals: |
198 | void filterChanged(); | 201 | void filterChanged(); |
199 | void editFilters(); | 202 | void editFilters(); |
200 | 203 | ||
201 | private: | 204 | private: |
202 | QPtrList<CalFilter> *mFilters; | 205 | QPtrList<CalFilter> *mFilters; |
203 | }; | 206 | }; |
204 | 207 | ||
205 | class KOCalEditView : public QScrollView | 208 | class KOCalEditView : public QScrollView |
206 | { | 209 | { |
207 | Q_OBJECT | 210 | Q_OBJECT |
208 | public: | 211 | public: |
209 | KOCalEditView( QWidget* parent=0,const char* name=0); | 212 | KOCalEditView( QWidget* parent=0,const char* name=0); |
210 | ~KOCalEditView(); | 213 | ~KOCalEditView(); |
211 | int addCalendar( QString calName, QString fileName, bool ask = true ); | 214 | int addCalendar( QString calName, QString fileName, bool ask = true ); |
212 | int getBirtdayID(); | 215 | int getBirtdayID(); |
213 | public slots: | 216 | public slots: |
214 | void addCal(); | 217 | void addCal(); |
215 | void enableAll(); | 218 | void enableAll(); |
216 | void enableAlarm(); | 219 | void enableAlarm(); |
217 | void disableRO(); | 220 | void disableRO(); |
218 | void deleteAll(); | 221 | void deleteAll(); |
219 | void selectStdCal(int,bool ); | 222 | void selectStdCal(int); |
220 | void selectCal(int,bool ); | 223 | void selectCal(int,bool ); |
221 | void selectCalAlarm(int,bool ); | 224 | void selectCalAlarm(int,bool ); |
222 | void selectReadOnly(int,bool ); | 225 | void selectReadOnly(int,bool ); |
223 | void setColor(const QColor &,int) ; | 226 | void setColor(const QColor &,int) ; |
224 | void deleteCal(int) ; | 227 | void deleteCal(int) ; |
225 | void infoCal(int) ; | 228 | void infoCal(int) ; |
226 | void readConfig(); | 229 | void readConfig(); |
227 | void defaultInfo(); | 230 | void defaultInfo(); |
231 | void findNewStandard(); | ||
228 | signals: | 232 | signals: |
229 | void alarmEnabled ( int cal, bool enable ); | 233 | void alarmEnabled ( int cal, bool enable ); |
230 | void calendarEnabled ( int cal, bool enable ); | 234 | void calendarEnabled ( int cal, bool enable ); |
231 | void calendarReadonly ( int cal, bool readonly ); | 235 | void calendarReadonly ( int cal, bool readonly ); |
232 | void setCalendarDefault ( int cal ); | 236 | void setCalendarDefault ( int cal ); |
233 | void removeCalendar ( int cal ); | 237 | void removeCalendar ( int cal ); |
234 | void calendarAdded( int ); | 238 | void calendarAdded( int ); |
235 | void needsUpdate(); | 239 | void needsUpdate(); |
236 | void checkCalendar(); | 240 | void checkCalendar(); |
237 | 241 | ||
238 | private: | 242 | private: |
239 | QWidget *mw; | 243 | QWidget *mw; |
240 | void toggleList ( QPtrList<KOCalCheckButton> ); | 244 | void toggleList ( QPtrList<KOCalCheckButton> , bool b = true ); |
241 | QPtrList<KOCalRadioButton> mStdandardB; | 245 | QPtrList<KOCalRadioButton> mStdandardB; |
242 | QPtrList<KOCalCheckButton> mEnabledB; | 246 | QPtrList<KOCalCheckButton> mEnabledB; |
243 | QPtrList<KOCalCheckButton> mAlarmB; | 247 | QPtrList<KOCalCheckButton> mAlarmB; |
244 | QPtrList<KOCalCheckButton> mROB; | 248 | QPtrList<KOCalCheckButton> mROB; |
245 | QGridLayout* mainLayout; | 249 | QGridLayout* mainLayout; |
246 | }; | 250 | }; |
247 | 251 | ||
248 | 252 | ||
249 | 253 | ||
250 | #endif // KOFILTERVIEW_H | 254 | #endif // KOFILTERVIEW_H |