kontact Library API Documentation

kcmkorgsummary.cpp

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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 <qbuttongroup.h> 00025 #include <qlabel.h> 00026 #include <qlayout.h> 00027 #include <qradiobutton.h> 00028 #include <qspinbox.h> 00029 00030 #include <kaboutdata.h> 00031 #include <kapplication.h> 00032 #include <kaccelmanager.h> 00033 #include <kconfig.h> 00034 #include <kdebug.h> 00035 #include <kdialogbase.h> 00036 #include <klocale.h> 00037 00038 #include "kcmkorgsummary.h" 00039 00040 extern "C" 00041 { 00042 KCModule *create_korgsummary( QWidget *parent, const char * ) 00043 { 00044 return new KCMKOrgSummary( parent, "kcmkorgsummary" ); 00045 } 00046 } 00047 00048 KCMKOrgSummary::KCMKOrgSummary( QWidget *parent, const char *name ) 00049 : KCModule( parent, name ) 00050 { 00051 initGUI(); 00052 00053 customDaysChanged( 1 ); 00054 00055 connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) ); 00056 connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) ); 00057 connect( mTodoGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) ); 00058 connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( modified() ) ); 00059 connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( customDaysChanged( int ) ) ); 00060 00061 KAcceleratorManager::manage( this ); 00062 00063 load(); 00064 } 00065 00066 void KCMKOrgSummary::modified() 00067 { 00068 emit changed( true ); 00069 } 00070 00071 void KCMKOrgSummary::buttonClicked( int id ) 00072 { 00073 mCustomDays->setEnabled( id == 4 ); 00074 } 00075 00076 void KCMKOrgSummary::customDaysChanged( int value ) 00077 { 00078 mCustomDays->setSuffix( i18n( " day", " days", value ) ); 00079 } 00080 00081 void KCMKOrgSummary::initGUI() 00082 { 00083 QVBoxLayout *layout = new QVBoxLayout( this, KDialog::marginHint(), 00084 KDialog::spacingHint() ); 00085 00086 mCalendarGroup = new QButtonGroup( 0, Vertical, i18n( "Calendar" ), this ); 00087 QVBoxLayout *boxLayout = new QVBoxLayout( mCalendarGroup->layout(), 00088 KDialog::spacingHint() ); 00089 00090 QLabel *label = new QLabel( i18n( "How many days should the calendar display at once?" ), mCalendarGroup ); 00091 boxLayout->addWidget( label ); 00092 00093 QRadioButton *button = new QRadioButton( i18n( "One day" ), mCalendarGroup ); 00094 boxLayout->addWidget( button ); 00095 00096 button = new QRadioButton( i18n( "Five days" ), mCalendarGroup ); 00097 boxLayout->addWidget( button ); 00098 00099 button = new QRadioButton( i18n( "One week" ), mCalendarGroup ); 00100 boxLayout->addWidget( button ); 00101 00102 button = new QRadioButton( i18n( "One month" ), mCalendarGroup ); 00103 boxLayout->addWidget( button ); 00104 00105 QHBoxLayout *hbox = new QHBoxLayout( boxLayout, KDialog::spacingHint() ); 00106 00107 button = new QRadioButton( "", mCalendarGroup ); 00108 hbox->addWidget( button ); 00109 00110 mCustomDays = new QSpinBox( 1, 365, 1, mCalendarGroup ); 00111 mCustomDays->setEnabled( false ); 00112 hbox->addWidget( mCustomDays ); 00113 00114 hbox->addStretch( 1 ); 00115 00116 layout->addWidget( mCalendarGroup ); 00117 00118 mTodoGroup = new QButtonGroup( 2, Horizontal, i18n( "Todos" ), this ); 00119 new QRadioButton( i18n( "Show all tasks" ), mTodoGroup ); 00120 new QRadioButton( i18n( "Show today's tasks" ), mTodoGroup ); 00121 00122 layout->addWidget( mTodoGroup ); 00123 } 00124 00125 void KCMKOrgSummary::load() 00126 { 00127 KConfig config( "kcmkorgsummaryrc" ); 00128 00129 config.setGroup( "Calendar" ); 00130 int days = config.readNumEntry( "DaysToShow", 1 ); 00131 if ( days == 1 ) 00132 mCalendarGroup->setButton( 0 ); 00133 else if ( days == 5 ) 00134 mCalendarGroup->setButton( 1 ); 00135 else if ( days == 7 ) 00136 mCalendarGroup->setButton( 2 ); 00137 else if ( days == 31 ) 00138 mCalendarGroup->setButton( 3 ); 00139 else { 00140 mCalendarGroup->setButton( 4 ); 00141 mCustomDays->setValue( days ); 00142 mCustomDays->setEnabled( true ); 00143 } 00144 00145 config.setGroup( "Todo" ); 00146 bool allTodos = config.readBoolEntry( "ShowAllTodos", false ); 00147 00148 if ( allTodos ) 00149 mTodoGroup->setButton( 0 ); 00150 else 00151 mTodoGroup->setButton( 1 ); 00152 00153 emit changed( false ); 00154 } 00155 00156 void KCMKOrgSummary::save() 00157 { 00158 KConfig config( "kcmkorgsummaryrc" ); 00159 00160 config.setGroup( "Calendar" ); 00161 00162 int days; 00163 switch ( mCalendarGroup->selectedId() ) { 00164 case 0: days = 1; break; 00165 case 1: days = 5; break; 00166 case 2: days = 7; break; 00167 case 3: days = 31; break; 00168 case 4: 00169 default: days = mCustomDays->value(); break; 00170 } 00171 config.writeEntry( "DaysToShow", days ); 00172 00173 config.setGroup( "Todo" ); 00174 config.writeEntry( "ShowAllTodos", mTodoGroup->selectedId() == 0 ); 00175 00176 config.sync(); 00177 00178 emit changed( false ); 00179 } 00180 00181 void KCMKOrgSummary::defaults() 00182 { 00183 mCalendarGroup->setButton( 0 ); 00184 mTodoGroup->setButton( 1 ); 00185 00186 emit changed( true ); 00187 } 00188 00189 const KAboutData* KCMKOrgSummary::aboutData() const 00190 { 00191 KAboutData *about = new KAboutData( I18N_NOOP( "kcmkorgsummary" ), 00192 I18N_NOOP( "Schedule Configuration Dialog" ), 00193 0, 0, KAboutData::License_GPL, 00194 I18N_NOOP( "(c) 2003 - 2004 Tobias Koenig" ) ); 00195 00196 about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); 00197 00198 return about; 00199 } 00200 00201 #include "kcmkorgsummary.moc"
KDE Logo
This file is part of the documentation for kontact Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:19:35 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003