summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kofilterview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp95
1 files changed, 54 insertions, 41 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)
}
-void KOCalEditView::selectStdCal( int id, bool b )
+void KOCalEditView::selectStdCal( int id )
{
-
- if ( !b ) {
- KOCalCheckButton* it = (KOCalCheckButton*) sender();
- if ( it ) {
- it->blockSignals( true );
- it->setChecked( true );
- it->blockSignals( false );
- return;
- }
- return;
- }
- KOCalRadioButton* sen = (KOCalRadioButton*) sender();
KOCalRadioButton* it = mStdandardB.first();
while ( it ) {
- if ( it->isChecked() ) {
- if ( it != sen ) {
- it->blockSignals( true );
- it->setChecked( false );
- it->blockSignals( false );
- break;
- }
- }
+ it->blockSignals( true );
+ it->setChecked( it->num() == id );
+ it->blockSignals( false );
it = mStdandardB.next();
}
KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
while ( kkf ) {
- kkf->isStandard = false;
+ kkf->isStandard = (kkf->mCalNumber == id );
kkf = KOPrefs::instance()->mCalendars.next();
}
- KOPrefs::instance()->getCalendar( id )->isStandard = true;
emit setCalendarDefault ( id );
}
@@ -178,10 +160,17 @@ void KOCalEditView::selectReadOnly(int id ,bool b )
KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
emit calendarReadonly ( id , b );
- if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) {
- KOPrefs::instance()->getCalendar( id )->isStandard = false;
- KOPrefs::instance()->getCalendar( 1 )->isStandard = true;
- mStdandardB.at(0)->setChecked( true );
- mStdandardB.at(id-1)->setChecked( false );
- emit setCalendarDefault ( 1 );
+ if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) {
+ findNewStandard();
+ } else {
+ if ( !b ){
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ while ( kkf ) {
+ if (kkf->isReadOnly && kkf->isStandard ) {
+ selectStdCal( id );
+ break;
+ }
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+ }
}
mStdandardB.at(id-1)->setEnabled( !b );
@@ -189,4 +178,23 @@ void KOCalEditView::selectReadOnly(int id ,bool b )
}
+void KOCalEditView::findNewStandard()
+{
+ bool found = false;
+ KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
+ while ( kkf ) {
+ if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) {
+ found = true;
+ selectStdCal( kkf->mCalNumber );
+ break;
+ }
+ kkf = KOPrefs::instance()->mCalendars.next();
+ }
+ if ( !found ) {
+ KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"),
+ i18n("Houston, we have a problem!") );
+
+ }
+}
+
void KOCalEditView::setColor( const QColor& c, int id )
{
@@ -200,8 +208,8 @@ void KOCalEditView::deleteCal( int id )
QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
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;
- if ( kkf->isStandard )
- selectStdCal( 1, true );
+ bool findnewstd = kkf->isStandard;
emit removeCalendar ( id );
KOPrefs::instance()->mCalendars.remove ( kkf );
+ if ( findnewstd ) findNewStandard();
emit needsUpdate();
QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
@@ -285,4 +293,5 @@ void KOCalEditView::readConfig()
KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
int row = 1;
+ bool errorLoadStandard = false;
while ( kkf ) {
int iii = 0;
@@ -290,11 +299,13 @@ void KOCalEditView::readConfig()
mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb );
rb->setChecked( kkf->isStandard );
+ if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) )
+ errorLoadStandard = true;
rb->setNum( kkf->mCalNumber );
- connect (rb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
+ connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) );
if ( kkf->mErrorOnLoad || kkf->isReadOnly )
rb->setEnabled( false );
KOCalCheckButton* cb = new KOCalCheckButton( mw );
mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb );
- cb->setChecked( kkf->isEnabled );
+ cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad );
cb->setNum( kkf->mCalNumber );
if ( kkf->mErrorOnLoad )
@@ -310,5 +321,5 @@ void KOCalEditView::readConfig()
cb = new KOCalCheckButton( mw );
mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb );
- cb->setChecked( kkf->isAlarmEnabled );
+ cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad);
cb->setNum( kkf->mCalNumber );
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
@@ -339,4 +350,6 @@ void KOCalEditView::readConfig()
kkf = KOPrefs::instance()->mCalendars.next();
}
+ if ( errorLoadStandard )
+ findNewStandard();
lab = new QLabel ( "", mw );
mainLayout->addWidget( lab,row,0 );
@@ -345,5 +358,4 @@ void KOCalEditView::readConfig()
}
-
void KOCalEditView::defaultInfo()
{
@@ -432,13 +444,13 @@ void KOCalEditView::enableAlarm()
void KOCalEditView::disableRO()
{
- toggleList( mROB );
+ toggleList( mROB, false );
}
-void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
+void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable )
{
- bool dis = false;
+ bool dis = !enable;
KOCalCheckButton* it = list.first();
while ( it ) {
- if ( !it->isChecked() ) {
- dis = true;
+ if ( !it->isChecked() == enable && it->isEnabled() ) {
+ dis = !dis;
break;
}
@@ -447,5 +459,6 @@ void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
it = list.first();
while ( it ) {
- it->setChecked(dis);
+ if ( it->isEnabled() )
+ it->setChecked(dis);
it = list.next();
}