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

kontact

kcmtodosummary.cpp

Go to the documentation of this file.
00001 /*
00002   This file is part of Kontact.
00003 
00004   Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
00005   Copyright (c) 2005-2006,2008 Allen Winter <winter@kde.org>
00006 
00007   This program is free software; you can redistribute it and/or modify
00008   it under the terms of the GNU General Public License as published by
00009   the Free Software Foundation; either version 2 of the License, or
00010   (at your option) any later version.
00011 
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015   GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License along
00018   with this program; if not, write to the Free Software
00019   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021   As a special exception, permission is given to link this program
00022   with any edition of Qt, and distribute the resulting executable,
00023   without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #include "kcmtodosummary.h"
00027 
00028 #include <kaboutdata.h>
00029 #include <kacceleratormanager.h>
00030 #include <kcomponentdata.h>
00031 #include <kconfig.h>
00032 #include <kdebug.h>
00033 #include <klocale.h>
00034 #include <kdemacros.h>
00035 
00036 #include <QCheckBox>
00037 #include <QLabel>
00038 #include <QLayout>
00039 #include <QRadioButton>
00040 #include <QSpinBox>
00041 
00042 extern "C"
00043 {
00044   KDE_EXPORT KCModule *create_todosummary( QWidget *parent, const char * )
00045   {
00046     KComponentData inst( "kcmtodosummary" );
00047     return new KCMTodoSummary( inst, parent );
00048   }
00049 }
00050 
00051 KCMTodoSummary::KCMTodoSummary( const KComponentData &inst, QWidget *parent )
00052   : KCModule( inst, parent )
00053 {
00054   setupUi( this );
00055 
00056   customDaysChanged( 7 );
00057 
00058   connect( mDateTodayButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00059   connect( mDateMonthButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00060   connect( mDateRangeButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00061 
00062   connect( mHideCompletedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00063   connect( mHideOpenEndedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00064   connect( mHideUnstartedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00065   connect( mHideInProgressBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00066   connect( mHideOverdueBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00067 
00068   connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(modified()) );
00069   connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(customDaysChanged(int)) );
00070 
00071   KAcceleratorManager::manage( this );
00072 
00073   load();
00074 }
00075 
00076 KCMTodoSummary::~KCMTodoSummary()
00077 {
00078 }
00079 
00080 void KCMTodoSummary::modified()
00081 {
00082   emit changed( true );
00083 }
00084 
00085 void KCMTodoSummary::customDaysChanged( int value )
00086 {
00087   mCustomDays->setSuffix( i18np( " day", " days", value ) );
00088 }
00089 
00090 void KCMTodoSummary::load()
00091 {
00092   KConfig config( "kcmtodosummaryrc" );
00093   KConfigGroup daysGroup( &config, "Days" );
00094 
00095   int days = daysGroup.readEntry( "DaysToShow", 7 );
00096   if ( days == 1 ) {
00097     mDateTodayButton->setChecked( true );
00098   } else if ( days == 31 ) {
00099     mDateMonthButton->setChecked( true );
00100   } else {
00101     mDateRangeButton->setChecked( true );
00102     mCustomDays->setValue( days );
00103     mCustomDays->setEnabled( true );
00104   }
00105 
00106   KConfigGroup hideGroup( &config, "Hide" );
00107   mHideInProgressBox->setChecked( hideGroup.readEntry( "InProgress", false ) );
00108   mHideOverdueBox->setChecked( hideGroup.readEntry( "Overdue", false ) );
00109   mHideCompletedBox->setChecked( hideGroup.readEntry( "Completed", true ) );
00110   mHideOpenEndedBox->setChecked( hideGroup.readEntry( "OpenEnded", false ) );
00111   mHideUnstartedBox->setChecked( hideGroup.readEntry( "NotStarted", false ) );
00112 
00113   emit changed( false );
00114 }
00115 
00116 void KCMTodoSummary::save()
00117 {
00118   KConfig config( "kcmtodosummaryrc" );
00119   KConfigGroup daysGroup( &config, "Days" );
00120 
00121   int days;
00122   if ( mDateTodayButton->isChecked() ) {
00123     days = 1;
00124   } else if ( mDateMonthButton->isChecked() ) {
00125     days = 31;
00126   } else {
00127     days = mCustomDays->value();
00128   }
00129   daysGroup.writeEntry( "DaysToShow", days );
00130 
00131   KConfigGroup hideGroup( &config, "Hide" );
00132   hideGroup.writeEntry( "InProgress", mHideInProgressBox->isChecked() );
00133   hideGroup.writeEntry( "Overdue", mHideOverdueBox->isChecked() );
00134   hideGroup.writeEntry( "Completed", mHideCompletedBox->isChecked() );
00135   hideGroup.writeEntry( "OpenEnded", mHideOpenEndedBox->isChecked() );
00136   hideGroup.writeEntry( "NotStarted", mHideUnstartedBox->isChecked() );
00137 
00138   config.sync();
00139   emit changed( false );
00140 }
00141 
00142 void KCMTodoSummary::defaults()
00143 {
00144   mDateRangeButton->setChecked( true );
00145   mCustomDays->setValue( 7 );
00146   mCustomDays->setEnabled( true );
00147 
00148   mHideInProgressBox->setChecked( false );
00149   mHideOverdueBox->setChecked( false );
00150   mHideCompletedBox->setChecked( true );
00151   mHideOpenEndedBox->setChecked( false );
00152   mHideUnstartedBox->setChecked( false );
00153 
00154   emit changed( true );
00155 }
00156 
00157 const KAboutData *KCMTodoSummary::aboutData() const
00158 {
00159   KAboutData *about = new KAboutData(
00160     I18N_NOOP( "kcmtodosummary" ), 0,
00161     ki18n( "Pending To-dos Configuration Dialog" ),
00162     0, KLocalizedString(), KAboutData::License_GPL,
00163     ki18n( "(c) 2003 - 2004 Tobias Koenig" ) );
00164 
00165   about->addAuthor( ki18n( "Tobias Koenig" ),
00166                     KLocalizedString(), "tokoe@kde.org" );
00167   about->addAuthor( ki18n( "Allen Winter" ),
00168                     KLocalizedString(), "winter@kde.org" );
00169 
00170   return about;
00171 }
00172 
00173 #include "kcmtodosummary.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