00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "kcmplanner.h"
00027
00028 #include <KAboutData>
00029 #include <KComponentData>
00030
00031 extern "C"
00032 {
00033 KDE_EXPORT KCModule *create_planner( QWidget *parent, const char * )
00034 {
00035 KComponentData inst( "kcmplanner" );
00036 return new KCMPlanner( inst, parent );
00037 }
00038 }
00039
00040 KCMPlanner::KCMPlanner( const KComponentData &inst, QWidget *parent )
00041 : KCModule( inst, parent )
00042 {
00043 setupUi( this );
00044
00045 customDaysChanged( 7 );
00046
00047 connect( mShowRecurrence, SIGNAL(stateChanged(int)), SLOT(modified()) );
00048 connect( mShowReminder, SIGNAL(stateChanged(int)), SLOT(modified()) );
00049 connect( mUnderline, SIGNAL(stateChanged(int)), SLOT(modified()) );
00050 connect( mTodo, SIGNAL(stateChanged(int)), SLOT(modified()) );
00051 connect( mSd, SIGNAL(stateChanged(int)), SLOT(modified()) );
00052
00053 connect( mDateTodayButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00054 connect( mDateMonthButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00055 connect( mDateRangeButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00056
00057 connect( mHideCompletedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00058 connect( mHideOpenEndedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00059 connect( mHideUnstartedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00060 connect( mHideInProgressBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00061 connect( mHideOverdueBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00062
00063 connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(modified()) );
00064 connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(customDaysChanged(int)) );
00065
00066
00067 connect( mBirthdayConList, SIGNAL(stateChanged(int)), SLOT(modified()) );
00068
00069 connect( mAnniversariesConList, SIGNAL(stateChanged(int)), SLOT(modified()) );
00070 connect( mHolidaysCal, SIGNAL(stateChanged(int)), SLOT(modified()) );
00071 connect( mSpecialOccasionsCal, SIGNAL(stateChanged(int)), SLOT(modified()) );
00072
00073 connect( mShowMyEventsOnly, SIGNAL(stateChanged(int)), SLOT(modified()) );
00074 connect( mShowMyTodosOnly, SIGNAL(stateChanged(int)), SLOT(modified()) );
00075
00076 load();
00077 }
00078
00079 KCMPlanner::~KCMPlanner()
00080 {
00081 }
00082
00083 void KCMPlanner::modified()
00084 {
00085 emit changed( true );
00086 }
00087
00088 void KCMPlanner::customDaysChanged( int value )
00089 {
00090 mCustomDays->setSuffix( i18np( " day", " days", value ) );
00091 }
00092
00093 void KCMPlanner::buttonClicked( bool state )
00094 {
00095 mCustomDays->setEnabled( state );
00096 }
00097
00098 void KCMPlanner::load()
00099 {
00100 KConfig config( "plannerrc" );
00101
00102
00103 KConfigGroup group = config.group( "General" );
00104
00105 mShowRecurrence->setChecked( group.readEntry( "ShowRecurrence", true ) );
00106 mShowReminder->setChecked( group.readEntry( "ShowReminder", true ) );
00107 mUnderline->setChecked( group.readEntry( "underlineLink", true ) );
00108 mTodo->setChecked( group.readEntry( "ShowTodo", true ) );
00109 mSd->setChecked( group.readEntry( "ShowSd", true ) );
00110
00111
00112 group = config.group( "Calendar" );
00113
00114
00115 int days = group.readEntry( "DaysToShow", 7 );
00116 if ( days == 1 ) {
00117 mDateTodayButton->setChecked( true );
00118 } else if( days == 31 ) {
00119 mDateMonthButton->setChecked( true );
00120 } else {
00121 mDateRangeButton->setChecked( true );
00122 mCustomDays->setValue( days );
00123 mCustomDays->setEnabled( true );
00124 }
00125
00126
00127 group = config.group( "Hide" );
00128 mHideInProgressBox->setChecked( group.readEntry( "InProgress", false ) );
00129 mHideOverdueBox->setChecked( group.readEntry( "Overdue", false ) );
00130 mHideCompletedBox->setChecked( group.readEntry( "Completed", true ) );
00131 mHideOpenEndedBox->setChecked( group.readEntry( "OpenEnded", false ) );
00132 mHideUnstartedBox->setChecked( group.readEntry( "NotStarted", false ) );
00133
00134
00135 group = config.group( "SpecialDates" );
00136
00137
00138 mBirthdayConList->setChecked( group.readEntry( "BirthdayConList", true ) );
00139
00140 mAnniversariesConList->setChecked( group.readEntry( "AnniversariesConList", true ) );
00141 mHolidaysCal->setChecked( group.readEntry ( "HolidaysCal", true ) );
00142 mSpecialOccasionsCal->setChecked( group.readEntry( "SpecialOccasionsCal", true ) );
00143
00144
00145 group = config.group( "Groupware" );
00146 mShowMyEventsOnly->setChecked( group.readEntry( "ShowMyEventsOnly", false ) );
00147 mShowMyTodosOnly->setChecked( group.readEntry( "ShowMyTodosOnly", false ) );
00148
00149 emit changed( false );
00150 }
00151
00152 void KCMPlanner::save()
00153 {
00154 KConfig config( "plannerrc" );
00155
00156
00157 KConfigGroup group = config.group( "General" );
00158
00159 group.writeEntry( "ShowRecurrence", mShowRecurrence->isChecked() );
00160 group.writeEntry( "ShowReminder", mShowReminder->isChecked() );
00161 group.writeEntry( "underlineLink", mUnderline->isChecked() );
00162 group.writeEntry( "ShowTodo", mTodo->isChecked() );
00163 group.writeEntry( "ShowSd", mSd->isChecked() );
00164
00165
00166 group = config.group( "Calendar" );
00167
00168 int days ;
00169 if ( mDateTodayButton->isChecked() ) {
00170 days = 1;
00171 } else if ( mDateMonthButton->isChecked() ) {
00172 days = 31;
00173 } else {
00174 days = mCustomDays->value();
00175 }
00176 group.writeEntry( "DaysToShow", days );
00177
00178
00179 group = config.group( "Hide" );
00180 group.writeEntry( "InProgress", mHideInProgressBox->isChecked() );
00181 group.writeEntry( "Overdue", mHideOverdueBox->isChecked() );
00182 group.writeEntry( "Completed", mHideCompletedBox->isChecked() );
00183 group.writeEntry( "OpenEnded", mHideOpenEndedBox->isChecked() );
00184 group.writeEntry( "NotStarted", mHideUnstartedBox->isChecked() );
00185
00186
00187 group = config.group( "SpecialDates" );
00188
00189
00190 group.writeEntry( "BirthdayConList", mBirthdayConList->isChecked() );
00191
00192 group.writeEntry( "AnniversariesConList", mAnniversariesConList->isChecked() );
00193 group.writeEntry( "HolidaysCal", mHolidaysCal->isChecked() );
00194 group.writeEntry( "SpecialOccasionsCal", mSpecialOccasionsCal->isChecked() );
00195
00196
00197 group = config.group( "Groupware" );
00198 group.writeEntry( "ShowMyEventsOnly", mShowMyEventsOnly->isChecked() );
00199 group.writeEntry( "ShowMyTodosOnly", mShowMyTodosOnly->isChecked() );
00200
00201 config.sync();
00202
00203 emit changed( false );
00204 }
00205
00206 void KCMPlanner::defaults()
00207 {
00208 mShowRecurrence->setChecked( true );
00209 mShowReminder->setChecked( true );
00210 mUnderline->setChecked( true );
00211 mTodo->setChecked( true );
00212 mSd->setChecked( true );
00213
00214 mDateRangeButton->setChecked( true );
00215 mCustomDays->setValue( 7 );
00216 mCustomDays->setEnabled( true );
00217
00218 mHideInProgressBox->setChecked( false );
00219 mHideOverdueBox->setChecked( false );
00220 mHideCompletedBox->setChecked( true );
00221 mHideOpenEndedBox->setChecked( false );
00222 mHideUnstartedBox->setChecked( false );
00223
00224
00225 mBirthdayConList->setChecked( true );
00226
00227 mAnniversariesConList->setChecked( true );
00228 mHolidaysCal->setChecked( true );
00229 mSpecialOccasionsCal->setChecked( true );
00230
00231 mShowMyEventsOnly->setChecked( false );
00232 mShowMyTodosOnly->setChecked( false );
00233
00234 emit changed( true );
00235 }
00236
00237 const KAboutData *KCMPlanner::aboutData() const
00238 {
00239 KAboutData *about = new KAboutData(
00240 I18N_NOOP( "kcmplanner" ), 0, ki18n( "Planner Summary Configuration Dialog" ),
00241 0, KLocalizedString(), KAboutData::License_GPL, ki18n( "(c) 2007-2008 Oral Timocin" ) );
00242
00243 about->addAuthor( ki18n( "Tobias Koenig" ), KLocalizedString(), "tokoe@kde.org" );
00244 about->addAuthor( ki18n( "Allen Winter" ), KLocalizedString(), "winter@kde.org" );
00245 about->addAuthor( ki18n( "Oral Timocin" ), KLocalizedString(), "o.timocin.kde@gmx.de" );
00246
00247 return about;
00248 }
00249
00250 #include "kcmplanner.moc"