-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 | |||
@@ -133,36 +133,18 @@ void KOCalEditView::selectCal(int id ,bool b) | |||
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 | } |
@@ -178,10 +160,17 @@ void KOCalEditView::selectReadOnly(int id ,bool b ) | |||
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 ); |
@@ -189,4 +178,23 @@ void KOCalEditView::selectReadOnly(int id ,bool b ) | |||
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 | { |
@@ -200,8 +208,8 @@ void KOCalEditView::deleteCal( int id ) | |||
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() ) ); |
@@ -285,4 +293,5 @@ void KOCalEditView::readConfig() | |||
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; |
@@ -290,11 +299,13 @@ void KOCalEditView::readConfig() | |||
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 ) |
@@ -310,5 +321,5 @@ void KOCalEditView::readConfig() | |||
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) ) ); |
@@ -339,4 +350,6 @@ void KOCalEditView::readConfig() | |||
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 ); |
@@ -345,5 +358,4 @@ void KOCalEditView::readConfig() | |||
345 | } | 358 | } |
346 | 359 | ||
347 | |||
348 | void KOCalEditView::defaultInfo() | 360 | void KOCalEditView::defaultInfo() |
349 | { | 361 | { |
@@ -432,13 +444,13 @@ void KOCalEditView::enableAlarm() | |||
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 | } |
@@ -447,5 +459,6 @@ void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) | |||
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 | } |
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h index 02107cf..874fc6a 100644 --- a/korganizer/kofilterview.h +++ b/korganizer/kofilterview.h | |||
@@ -71,5 +71,7 @@ class KONewCalPrefs : public QDialog | |||
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 | } |
@@ -164,7 +166,8 @@ class KOCalRadioButton : public QRadioButton | |||
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; |
@@ -175,5 +178,5 @@ private: | |||
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 | ||
@@ -217,5 +220,5 @@ class KOCalEditView : public QScrollView | |||
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 ); |
@@ -226,4 +229,5 @@ class KOCalEditView : public QScrollView | |||
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 ); |
@@ -238,5 +242,5 @@ class KOCalEditView : public QScrollView | |||
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; |