• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kontact

kcmplanner.cpp

Go to the documentation of this file.
00001 /*
00002   This file is part of Kontact.
00003   Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
00004 
00005   This program is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009 
00010   This program is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013   GNU General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this program; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019   As a special exception, permission is given to link this program
00020   with any edition of Qt, and distribute the resulting executable,
00021   without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #include "kcmplanner.h"
00025 
00026 #include <kaboutdata.h>
00027 #include <kacceleratormanager.h>
00028 #include <kcomponentdata.h>
00029 #include <kconfig.h>
00030 #include <kdebug.h>
00031 #include <klocale.h>
00032 #include <kdemacros.h>
00033 
00034 #include <QCheckBox>
00035 #include <QLabel>
00036 #include <QLayout>
00037 #include <QRadioButton>
00038 #include <QSpinBox>
00039 
00040 extern "C"
00041 {
00042   KDE_EXPORT KCModule *create_planner( QWidget *parent, const char * )
00043   {
00044     KComponentData inst( "kcmplanner" );
00045     return new KCMPlanner( inst, parent );
00046   }
00047 }
00048 
00049 KCMPlanner::KCMPlanner( const KComponentData &inst, QWidget *parent )
00050   : KCModule( inst, parent )
00051 {
00052   setupUi( this );
00053 
00054   customDaysChanged( 7 );
00055 
00056   connect( mShowRecurrence, SIGNAL(stateChanged(int)), SLOT(modified()) );
00057   connect( mShowReminder, SIGNAL(stateChanged(int)), SLOT(modified()) );
00058   connect( mUnderline, SIGNAL(stateChanged(int)), SLOT(modified()) );
00059   connect( mTodo, SIGNAL(stateChanged(int)), SLOT(modified()) );
00060   connect( mSd, SIGNAL(stateChanged(int)), SLOT(modified()) );
00061 
00062   connect( mDateTodayButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00063   connect( mDateMonthButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00064   connect( mDateRangeButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00065 
00066   connect( mHideCompletedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00067   connect( mHideOpenEndedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00068   connect( mHideUnstartedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00069   connect( mHideInProgressBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00070   connect( mHideOverdueBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00071 
00072   connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(modified()) );
00073   connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(customDaysChanged(int)) );
00074 
00075 //   connect( mBirthdayCal, SIGNAL(stateChanged(int)), SLOT(modified()) );
00076   connect( mBirthdayConList, SIGNAL(stateChanged(int)), SLOT(modified()) );
00077 //   connect( mAnniversariesCal, SIGNAL(stateChanged(int)), SLOT(modified()) );
00078   connect( mAnniversariesConList, SIGNAL(stateChanged(int)), SLOT(modified()) );
00079   connect( mHolidaysCal, SIGNAL(stateChanged(int)), SLOT(modified()) );
00080   connect( mSpecialOccasionsCal, SIGNAL(stateChanged(int)), SLOT(modified()) );
00081 
00082   KAcceleratorManager::manage( this );
00083 
00084   load();
00085 }
00086 
00087 KCMPlanner::~KCMPlanner()
00088 {
00089 }
00090 
00091 void KCMPlanner::modified()
00092 {
00093   emit changed( true );
00094 }
00095 
00096 void KCMPlanner::customDaysChanged( int value )
00097 {
00098   mCustomDays->setSuffix( i18np( " day", " days", value ) );
00099 }
00100 
00101 void KCMPlanner::buttonClicked( bool state )
00102 {
00103   mCustomDays->setEnabled( state );
00104 }
00105 
00106 void KCMPlanner::load()
00107 {
00108   KConfig config( "plannerrc" );
00109 
00110   //Read general config
00111   KConfigGroup general = config.group( "General" );
00112 
00113   mShowRecurrence->setChecked( general.readEntry( "ShowRecurrence", true ) );
00114   mShowReminder->setChecked( general.readEntry( "ShowReminder", true ) );
00115   mUnderline->setChecked( general.readEntry( "underlineLink", true ) );
00116   mTodo->setChecked( general.readEntry( "ShowTodo", true ) );
00117   mSd->setChecked( general.readEntry( "ShowSd", true ) );
00118 
00119   //Read Calendar Config
00120   KConfigGroup calendar = config.group( "Calendar" );
00121 
00122   //Set the count of Days from config
00123   int days = calendar.readEntry( "DaysToShow", 7 );
00124   if ( days == 1 ) {
00125     mDateTodayButton->setChecked( true );
00126   } else if( days == 31 ) {
00127     mDateMonthButton->setChecked( true );
00128   } else {
00129     mDateRangeButton->setChecked( true );
00130     mCustomDays->setValue( days );
00131     mCustomDays->setEnabled( true );
00132   }
00133 
00134   //Read Todo Config
00135   KConfigGroup hideGroup( &config, "Hide" );
00136   mHideInProgressBox->setChecked( hideGroup.readEntry( "InProgress", false ) );
00137   mHideOverdueBox->setChecked( hideGroup.readEntry( "Overdue", false ) );
00138   mHideCompletedBox->setChecked( hideGroup.readEntry( "Completed", true ) );
00139   mHideOpenEndedBox->setChecked( hideGroup.readEntry( "OpenEnded", false ) );
00140   mHideUnstartedBox->setChecked( hideGroup.readEntry( "NotStarted", false ) );
00141   //Read Special Dates Config
00142   KConfigGroup sd = config.group( "SpecialDates" );
00143 
00144 //   mSdGroup->setChecked( sd.readEntry( "SpecialDates", true ) );
00145 //   mBirthdayCal->setChecked( sd.readEntry( "BirthdayCal", true ) );
00146   mBirthdayConList->setChecked( sd.readEntry( "BirthdayConList", true ) );
00147 //   mAnniversariesCal->setChecked( sd.readEntry( "AnniversariesCal", true ) );
00148   mAnniversariesConList->setChecked( sd.readEntry( "AnniversariesConList", true ) );
00149   mHolidaysCal->setChecked( sd.readEntry ( "HolidaysCal", true ) );
00150   mSpecialOccasionsCal->setChecked( sd.readEntry( "SpecialOccasionsCal", true ) );
00151 
00152   emit changed( false );
00153 }
00154 
00155 void KCMPlanner::save()
00156 {
00157   KConfig config( "plannerrc" );
00158 
00159   //General Setion
00160   KConfigGroup general = config.group( "General" );
00161 
00162   general.writeEntry( "ShowRecurrence", mShowRecurrence->isChecked() );
00163   general.writeEntry( "ShowReminder", mShowReminder->isChecked() );
00164   general.writeEntry( "underlineLink", mUnderline->isChecked() );
00165   general.writeEntry( "ShowTodo", mTodo->isChecked() );
00166   general.writeEntry( "ShowSd", mSd->isChecked() );
00167 
00168   //Calendar Section
00169   KConfigGroup calendar = config.group( "Calendar" );
00170 
00171   int days ;
00172 if ( mDateTodayButton->isChecked() ) {
00173     days = 1;
00174   } else if ( mDateMonthButton->isChecked() ) {
00175     days = 31;
00176   } else {
00177     days = mCustomDays->value();
00178   }
00179   calendar.writeEntry( "DaysToShow", days );
00180 
00181   //Todo Section
00182   KConfigGroup hideGroup( &config, "Hide" );
00183   hideGroup.writeEntry( "InProgress", mHideInProgressBox->isChecked() );
00184   hideGroup.writeEntry( "Overdue", mHideOverdueBox->isChecked() );
00185   hideGroup.writeEntry( "Completed", mHideCompletedBox->isChecked() );
00186   hideGroup.writeEntry( "OpenEnded", mHideOpenEndedBox->isChecked() );
00187   hideGroup.writeEntry( "NotStarted", mHideUnstartedBox->isChecked() );
00188 
00189   //SpecialDates Section
00190   KConfigGroup sd = config.group( "SpecialDates" );
00191 
00192 //   sd.writeEntry( "BirthdayCal", mBirthdayCal->isChecked() );
00193   sd.writeEntry( "BirthdayConList", mBirthdayConList->isChecked() );
00194 //   sd.writeEntry( "AnniversariesCal", mAnniversariesCal->isChecked() );
00195   sd.writeEntry( "AnniversariesConList", mAnniversariesConList->isChecked() );
00196   sd.writeEntry( "HolidaysCal", mHolidaysCal->isChecked() );
00197   sd.writeEntry( "SpecialOccasionsCal", mSpecialOccasionsCal->isChecked() );
00198 
00199   config.sync();
00200 
00201   emit changed( false );
00202 }
00203 
00204  void KCMPlanner::defaults()
00205 {
00206   mShowRecurrence->setChecked( true );
00207   mShowReminder->setChecked( true );
00208   mUnderline->setChecked( true );
00209   mTodo->setChecked( true );
00210   mSd->setChecked( true );
00211 
00212   mDateRangeButton->setChecked( true );
00213   mCustomDays->setValue( 7 );
00214   mCustomDays->setEnabled( true );
00215 
00216   mHideInProgressBox->setChecked( false );
00217   mHideOverdueBox->setChecked( false );
00218   mHideCompletedBox->setChecked( true );
00219   mHideOpenEndedBox->setChecked( false );
00220   mHideUnstartedBox->setChecked( false );
00221 
00222 //   mBirthdayCal->setChecked( true );
00223   mBirthdayConList->setChecked( true );
00224 //   mAnniversariesCal->setChecked( true );
00225   mAnniversariesConList->setChecked( true );
00226   mHolidaysCal->setChecked( true );
00227   mSpecialOccasionsCal->setChecked( true );
00228 
00229   emit changed( true );
00230 }
00231 
00232 const KAboutData *KCMPlanner::aboutData() const
00233 {
00234   KAboutData *about = new KAboutData(
00235     I18N_NOOP( "kcmplanner" ), 0, ki18n( "Planner Summary Configuration Dialog" ),
00236     0, KLocalizedString(), KAboutData::License_GPL, ki18n( "(c) 2007-2008 Oral Timocin" ) );
00237 
00238   about->addAuthor( ki18n( "Tobias Koenig" ), KLocalizedString(), "tokoe@kde.org" );
00239   about->addAuthor( ki18n( "Allen Winter" ), KLocalizedString(), "winter@kde.org" );
00240   about->addAuthor( ki18n( "Oral Timocin" ), KLocalizedString(), "o.timocin.kde@gmx.de" );
00241 
00242   return about;
00243 }
00244 
00245 #include "kcmplanner.moc"

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal