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

kontact

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