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

korganizer

koprefsdialog.cpp

Go to the documentation of this file.
00001 /*
00002   This file is part of KOrganizer.
00003 
00004   Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org>
00005   Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
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 Foundation, Inc.,
00019   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 "koprefsdialog.h"
00027 #include "koprefs.h"
00028 #include "ktimeedit.h"
00029 #include "koglobals.h"
00030 #include "stdcalendar.h"
00031 #include "calendar/calendardecoration.h"
00032 #include "korganizer/printplugin.h"
00033 
00034 #include <kholidays.h>
00035 using namespace LibKHolidays;
00036 
00037 #include <kcal/calendarresources.h>
00038 
00039 #include <kvbox.h>
00040 #include <kcolorbutton.h>
00041 #include <klocale.h>
00042 #include <kglobal.h>
00043 #include <kmessagebox.h>
00044 #include <kiconloader.h>
00045 #include <kemailsettings.h>
00046 #include <kcalendarsystem.h>
00047 #include <ksystemtimezone.h>
00048 #include <kpushbutton.h>
00049 #include <kocore.h>
00050 #include <kstandarddirs.h>
00051 #include <kconfig.h>
00052 #include <KLineEdit>
00053 #include <KComboBox>
00054 #include <KTabWidget>
00055 
00056 #include <q3listview.h>
00057 #include <q3buttongroup.h>
00058 #include <QLayout>
00059 #include <QLabel>
00060 #include <QSlider>
00061 #include <QFile>
00062 #include <QSpinBox>
00063 #include <QCheckBox>
00064 #include <QRadioButton>
00065 #include <QPushButton>
00066 #include <QTextStream>
00067 #include <QGridLayout>
00068 #include <QBoxLayout>
00069 #include <QHBoxLayout>
00070 #include <QVBoxLayout>
00071 #include <QGroupBox>
00072 #include <QTimeEdit>
00073 #include <QTreeWidget>
00074 
00075 #include "ui_kogroupwareprefspage.h"
00076 
00077 KOPrefsDialogMain::KOPrefsDialogMain( const KComponentData &inst, QWidget *parent )
00078   : KPrefsModule( KOPrefs::instance(), inst, parent )
00079 {
00080   QBoxLayout *topTopLayout = new QVBoxLayout( this );
00081   KTabWidget *tabWidget = new KTabWidget( this );
00082   topTopLayout->addWidget( tabWidget );
00083 
00084   // Personal Settings
00085   QFrame *personalFrame = new QFrame( this );
00086   QVBoxLayout *personalLayout = new QVBoxLayout( personalFrame );
00087   tabWidget->addTab( personalFrame, KIcon( "preferences-desktop-personal" ),
00088                      i18nc( "@title:tab personal settings", "Personal" ) );
00089 
00090   KPrefsWidBool *emailControlCenter =
00091     addWidBool( KOPrefs::instance()->emailControlCenterItem(), personalFrame );
00092   connect( emailControlCenter->checkBox(), SIGNAL(toggled(bool)), SLOT(toggleEmailSettings(bool)) );
00093   personalLayout->addWidget( emailControlCenter->checkBox() );
00094 
00095   mUserEmailSettings =
00096     new QGroupBox( i18nc( "@title:group email settings", "Email Settings" ), personalFrame );
00097 
00098   personalLayout->addWidget( mUserEmailSettings );
00099   QVBoxLayout *emailSettingsLayout = new QVBoxLayout( mUserEmailSettings );
00100   KHBox *hbox1 = new KHBox( mUserEmailSettings );
00101   addWidString( KOPrefs::instance()->userNameItem(), hbox1 );
00102   emailSettingsLayout->addWidget( hbox1 );
00103 
00104   KHBox *hbox2 = new KHBox( mUserEmailSettings );
00105   addWidString( KOPrefs::instance()->userEmailItem(), hbox2 );
00106   emailSettingsLayout->addWidget( hbox2 );
00107 
00108   KPrefsWidRadios *defaultEmailAttachMethod =
00109     addWidRadios( KOPrefs::instance()->defaultEmailAttachMethodItem(), personalFrame );
00110   personalLayout->addWidget( defaultEmailAttachMethod->groupBox() );
00111   personalLayout->addStretch( 1 );
00112 
00113   // Save Settings
00114   QFrame *saveFrame = new QFrame( this );
00115   tabWidget->addTab( saveFrame, KIcon( "document-save" ),
00116                      i18nc( "@title:tab", "Save" ) );
00117   QVBoxLayout *saveLayout = new QVBoxLayout( saveFrame );
00118 
00119   QGroupBox *saveGroupBox =
00120     new QGroupBox( i18nc( "@title:group", "Saving Calendar" ), saveFrame );
00121   saveLayout->addWidget( saveGroupBox );
00122   QVBoxLayout *saveGroupLayout = new QVBoxLayout;
00123   saveGroupBox->setLayout( saveGroupLayout );
00124 
00125   KPrefsWidBool *htmlWithSave =
00126     addWidBool( KOPrefs::instance()->htmlWithSaveItem(), saveGroupBox );
00127   saveGroupLayout->addWidget( htmlWithSave->checkBox() );
00128 
00129   KPrefsWidBool *autoSave =
00130     addWidBool( KOPrefs::instance()->autoSaveItem(), saveGroupBox );
00131   saveGroupLayout->addWidget( autoSave->checkBox() );
00132 
00133   QBoxLayout *intervalLayout = new QHBoxLayout;
00134   saveGroupLayout->addLayout( intervalLayout );
00135 
00136   KPrefsWidInt *autoSaveInterval =
00137     addWidInt( KOPrefs::instance()->autoSaveIntervalItem(), saveGroupBox );
00138   connect( autoSave->checkBox(), SIGNAL(toggled(bool)),
00139            autoSaveInterval->label(), SLOT(setEnabled(bool)) );
00140   connect( autoSave->checkBox(), SIGNAL(toggled(bool)),
00141            autoSaveInterval->spinBox(), SLOT(setEnabled(bool)) );
00142   intervalLayout->addWidget( autoSaveInterval->label() );
00143   intervalLayout->addWidget( autoSaveInterval->spinBox() );
00144 
00145   KPrefsWidBool *confirmItem =
00146     addWidBool( KOPrefs::instance()->confirmItem(), saveFrame );
00147   saveLayout->addWidget( confirmItem->checkBox() );
00148   KPrefsWidRadios *destinationItem =
00149     addWidRadios( KOPrefs::instance()->destinationItem(), saveFrame );
00150   saveLayout->addWidget( destinationItem->groupBox() );
00151   saveLayout->addStretch( 1 );
00152 
00153   // System Tray Settings
00154   QFrame *systrayFrame = new QFrame( this );
00155   QVBoxLayout *systrayLayout = new QVBoxLayout( systrayFrame );
00156   tabWidget->addTab( systrayFrame, KIcon( "preferences-other" ),
00157                      i18nc( "@title:tab systray settings", "System Tray" ) );
00158 
00159   QGroupBox *systrayGroupBox =
00160     new QGroupBox( i18nc( "@title:group", "Show/Hide Options" ), systrayFrame );
00161   systrayLayout->addWidget( systrayGroupBox );
00162   QVBoxLayout *systrayGroupLayout = new QVBoxLayout;
00163   systrayGroupBox->setLayout( systrayGroupLayout );
00164 
00165   KPrefsWidBool *showReminderDaemonItem =
00166     addWidBool( KOPrefs::instance()->showReminderDaemonItem(), systrayGroupBox );
00167   systrayGroupLayout->addWidget( showReminderDaemonItem->checkBox() );
00168   showReminderDaemonItem->checkBox()->setToolTip(
00169     i18nc( "@info:tooltip", "Enable this setting to show the KOrganizer "
00170            "reminder daemon in your system tray (recommended)." ) );
00171 
00172   QLabel *note = new QLabel(
00173     i18nc( "@info",
00174            "<note>The daemon will continue running even if it is not shown "
00175            "in the system tray.</note>" ) );
00176   systrayGroupLayout->addWidget( note );
00177 
00178   systrayLayout->addStretch( 1 );
00179 
00180   load();
00181 }
00182 
00183 void KOPrefsDialogMain::toggleEmailSettings( bool on )
00184 {
00185   mUserEmailSettings->setEnabled( !on );
00186 /*  if (on) {
00187     KEMailSettings settings;
00188     mNameEdit->setText( settings.getSetting(KEMailSettings::RealName) );
00189     mEmailEdit->setText( settings.getSetting(KEMailSettings::EmailAddress) );
00190   } else {
00191     mNameEdit->setText( KOPrefs::instance()->mName );
00192     mEmailEdit->setText( KOPrefs::instance()->mEmail );
00193   }*/
00194 }
00195 
00196 extern "C"
00197 {
00198   KDE_EXPORT KCModule *create_korganizerconfigmain( QWidget *parent, const char * )
00199   {
00200     return new KOPrefsDialogMain( KOGlobals::self()->componentData(), parent );
00201   }
00202 }
00203 
00206 
00207 class KOPrefsDialogTime : public KPrefsModule
00208 {
00209   public:
00210     KOPrefsDialogTime( const KComponentData &inst, QWidget *parent )
00211       : KPrefsModule( KOPrefs::instance(), inst, parent )
00212     {
00213       QVBoxLayout *layout = new QVBoxLayout( this );
00214       KTabWidget *tabWidget = new KTabWidget( this );
00215       layout->addWidget( tabWidget );
00216 
00217       QFrame *regionalPage = new QFrame( parent );
00218       tabWidget->addTab( regionalPage, KIcon( "flag" ),
00219                          i18nc( "@title:tab", "Regional" ) );
00220 
00221       QGridLayout *regionalLayout = new QGridLayout( regionalPage );
00222       regionalLayout->setSpacing( KDialog::spacingHint() );
00223 
00224       KHBox *timeZoneBox = new KHBox( regionalPage );
00225       regionalLayout->addWidget( timeZoneBox, 0, 0, 1, 2 );
00226 
00227       QLabel *timeZoneLabel = new QLabel( i18nc( "@label", "Time zone:" ), timeZoneBox );
00228       QString whatsThis = i18nc( "@info:whatsthis",
00229                                  "Select your time zone from the list of "
00230                                  "locations on this drop down box. If your "
00231                                  "city is not listed, select one which shares "
00232                                  "the same time zone. KOrganizer will "
00233                                  "automatically adjust for daylight savings." );
00234       timeZoneLabel->setWhatsThis( whatsThis );
00235       mTimeZoneCombo = new KComboBox( timeZoneBox );
00236 
00237       connect( mTimeZoneCombo, SIGNAL(activated(int)), SLOT(slotWidChanged()) );
00238 
00239       QString sCurrentlySet(
00240         i18nc( "@item:inlistbox unknown timezone", "Unknown" ) );
00241       KTimeZone zone = KSystemTimeZones::local();
00242       if ( zone.isValid() ) {
00243         sCurrentlySet = zone.name();
00244       }
00245       // Read all system time zones
00246       QStringList list;
00247       const KTimeZones::ZoneMap timezones = KSystemTimeZones::zones();
00248       for ( KTimeZones::ZoneMap::ConstIterator it = timezones.constBegin();
00249             it != timezones.constEnd();  ++it ) {
00250         list.append( i18n( it.key().toUtf8() ) );
00251         tzonenames << it.key();
00252       }
00253       list.sort();
00254       mTimeZoneCombo->addItem(
00255         i18nc( "@item:inlistbox no timezone selected", "[No selection]" ) );
00256       mTimeZoneCombo->addItems( list );
00257 
00258       // find the currently set time zone and select it
00259       int nCurrentlySet = 0;
00260       for ( int i = 0; i < mTimeZoneCombo->count(); ++i ) {
00261         if ( mTimeZoneCombo->itemText(i) == sCurrentlySet ) {
00262           nCurrentlySet = i;
00263           break;
00264         }
00265       }
00266       mTimeZoneCombo->setCurrentIndex( nCurrentlySet );
00267       mTimeZoneCombo->setWhatsThis( whatsThis );
00268 
00269       // holiday region selection
00270       KHBox *holidayRegBox = new KHBox( regionalPage );
00271       regionalLayout->addWidget( holidayRegBox, 1, 0, 1, 2 );
00272 
00273       QLabel *holidayLabel = new QLabel(
00274         i18nc( "@label", "Use holiday region:" ), holidayRegBox );
00275       holidayLabel->setWhatsThis( KOPrefs::instance()->holidaysItem()->whatsThis() );
00276 
00277       mHolidayCombo = new KComboBox( holidayRegBox );
00278       connect( mHolidayCombo, SIGNAL(activated(int)), SLOT(slotWidChanged()) );
00279 
00280       mHolidayCombo->setWhatsThis( KOPrefs::instance()->holidaysItem()->whatsThis() );
00281 
00282       QString currentHolidayName;
00283       QStringList holidayList;
00284       QStringList countryList = KHolidays::locations();
00285 
00286       foreach ( const QString &country, countryList ) {
00287         QString countryFile = KStandardDirs::locate( "locale",
00288                                       "l10n/" + country + "/entry.desktop" );
00289         QString regionName;
00290         if ( !countryFile.isEmpty() ) {
00291           KConfig _cfg( countryFile, KConfig::SimpleConfig );
00292           KConfigGroup cfg(&_cfg, "KCM Locale" );
00293           regionName = cfg.readEntry( "Name" );
00294         }
00295         if ( regionName.isEmpty() ) {
00296           regionName = country;
00297         }
00298 
00299         holidayList << regionName;
00300         mRegionMap[regionName] = country; //store region for saving to config file
00301 
00302         if ( KOGlobals::self()->holidays() &&
00303              ( country == KOGlobals::self()->holidays()->location() ) ) {
00304           currentHolidayName = regionName;
00305         }
00306       }
00307       holidayList.sort();
00308       holidayList.push_front(
00309         i18nc( "@item:inlistbox do not use holidays", "(None)" ) );
00310 
00311       mHolidayCombo->addItems( holidayList );
00312 
00313       for ( int i=0; i < mHolidayCombo->count(); ++i ) {
00314         if ( mHolidayCombo->itemText(i) == currentHolidayName ) {
00315           mHolidayCombo->setCurrentIndex( i );
00316           break;
00317         }
00318       }
00319 
00320       KPrefsWidTime *dayBegins =
00321         addWidTime( KOPrefs::instance()->dayBeginsItem(), regionalPage );
00322       regionalLayout->addWidget( dayBegins->label(), 2, 0 );
00323       regionalLayout->addWidget( dayBegins->timeEdit(), 2, 1 );
00324 
00325       QGroupBox *workingHoursGroupBox =
00326         new QGroupBox( i18nc( "@title:group", "Working Hours" ), regionalPage );
00327       regionalLayout->addWidget( workingHoursGroupBox, 3, 0, 1, 2 );
00328 
00329       QBoxLayout *workingHoursLayout = new QVBoxLayout( workingHoursGroupBox );
00330 
00331       QBoxLayout *workDaysLayout = new QHBoxLayout;
00332       workingHoursLayout->addLayout( workDaysLayout );
00333 
00334       // Respect start of week setting
00335       int weekStart = KGlobal::locale()->weekStartDay();
00336       for ( int i=0; i < 7; ++i ) {
00337         const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
00338         QString weekDayName = calSys->weekDayName( ( i + weekStart + 6 ) % 7 + 1,
00339                                                    KCalendarSystem::ShortDayName );
00340         if ( KOPrefs::instance()->mCompactDialogs ) {
00341           weekDayName = weekDayName.left( 1 );
00342         }
00343         int index = ( i + weekStart + 6 ) % 7;
00344         mWorkDays[ index ] = new QCheckBox( weekDayName );
00345         mWorkDays[ index ]->setWhatsThis(
00346           i18nc( "@info:whatsthis",
00347                  "Check this box to make KOrganizer mark the "
00348                  "working hours for this day of the week. "
00349                  "If this is a work day for you, check "
00350                  "this box, or the working hours will not be "
00351                  "marked with color." ) );
00352 
00353         connect( mWorkDays[ index ], SIGNAL(stateChanged(int)), SLOT(slotWidChanged()) );
00354 
00355         workDaysLayout->addWidget( mWorkDays[ index ] );
00356       }
00357 
00358       KPrefsWidTime *workStart =
00359         addWidTime( KOPrefs::instance()->workingHoursStartItem() );
00360 
00361       QHBoxLayout *workStartLayout = new QHBoxLayout;
00362       workingHoursLayout->addLayout( workStartLayout );
00363 
00364       workStartLayout->addWidget( workStart->label() );
00365       workStartLayout->addWidget( workStart->timeEdit() );
00366 
00367       KPrefsWidTime *workEnd =
00368         addWidTime( KOPrefs::instance()->workingHoursEndItem() );
00369 
00370       QHBoxLayout *workEndLayout = new QHBoxLayout;
00371       workingHoursLayout->addLayout( workEndLayout );
00372 
00373       workEndLayout->addWidget( workEnd->label() );
00374       workEndLayout->addWidget( workEnd->timeEdit() );
00375 
00376       KPrefsWidBool *excludeHolidays =
00377         addWidBool( KOPrefs::instance()->excludeHolidaysItem() );
00378 
00379       workingHoursLayout->addWidget( excludeHolidays->checkBox() );
00380 
00381       regionalLayout->setRowStretch( 4, 1 );
00382 
00383       QFrame *defaultPage = new QFrame( parent );
00384       tabWidget->addTab( defaultPage, KIcon( "draw-eraser" ),
00385                          i18nc( "@title:tab", "Default Values" ) );
00386       QGridLayout *defaultLayout = new QGridLayout( defaultPage );
00387       defaultLayout->setSpacing( KDialog::spacingHint() );
00388 
00389       KPrefsWidTime *defaultTime =
00390         addWidTime( KOPrefs::instance()->startTimeItem(), defaultPage );
00391       defaultLayout->addWidget( defaultTime->label(), 0, 0 );
00392       defaultLayout->addWidget( defaultTime->timeEdit(), 0, 1 );
00393 
00394       KPrefsWidDuration *defaultDuration =
00395         addWidDuration( KOPrefs::instance()->defaultDurationItem(), defaultPage );
00396       defaultLayout->addWidget( defaultDuration->label(), 1, 0 );
00397       defaultLayout->addWidget( defaultDuration->timeEdit(), 1, 1 );
00398 
00399       QStringList alarmList;
00400       alarmList << i18nc( "@item:inlistbox", "1 minute" )
00401                 << i18nc( "@item:inlistbox", "5 minutes" )
00402                 << i18nc( "@item:inlistbox", "10 minutes" )
00403                 << i18nc( "@item:inlistbox", "15 minutes" )
00404                 << i18nc( "@item:inlistbox", "30 minutes" );
00405       QLabel *alarmLabel = new QLabel( i18nc( "@label", "Default reminder time:" ), defaultPage );
00406       defaultLayout->addWidget( alarmLabel, 2, 0 );
00407       alarmLabel->setWhatsThis( KOPrefs::instance()->alarmTimeItem()->whatsThis() );
00408       mAlarmTimeCombo = new KComboBox( defaultPage );
00409       mAlarmTimeCombo->setWhatsThis( KOPrefs::instance()->alarmTimeItem()->whatsThis() );
00410       connect( mAlarmTimeCombo, SIGNAL(activated(int)), SLOT(slotWidChanged()) );
00411       mAlarmTimeCombo->addItems( alarmList );
00412       defaultLayout->addWidget( mAlarmTimeCombo, 2, 1 );
00413 
00414       defaultLayout->setRowStretch( 3, 1 );
00415       load();
00416     }
00417 
00418   protected:
00419     void usrReadConfig()
00420     {
00421       KTimeZone tz = KOPrefs::instance()->timeSpec().timeZone();
00422       if ( tz.isValid() ) {
00423         setCombo( mTimeZoneCombo, i18n( tz.name().toUtf8() ) );
00424       }
00425 
00426       mAlarmTimeCombo->setCurrentIndex( KOPrefs::instance()->mAlarmTime );
00427       for ( int i = 0; i < 7; ++i ) {
00428         mWorkDays[i]->setChecked( ( 1 << i ) & ( KOPrefs::instance()->mWorkWeekMask ) );
00429       }
00430     }
00431 
00432     void usrWriteConfig()
00433     {
00434       // Find untranslated selected zone
00435       QString selectedZone = mTimeZoneCombo->currentText();
00436       QStringList::Iterator tz;
00437       for ( tz = tzonenames.begin(); tz != tzonenames.end(); ++tz ) {
00438         if ( selectedZone == i18n( (*tz).toUtf8() ) ) {
00439           selectedZone = *tz;
00440           break;
00441         }
00442       }
00443       KTimeZone zone = KSystemTimeZones::zone( selectedZone );
00444       if ( zone.isValid() ) {
00445         KOPrefs::instance()->setTimeSpec(zone);
00446       }
00447 
00448       KOPrefs::instance()->mHolidays = ( mHolidayCombo->currentIndex() == 0 ) ?  // (None)
00449                                        QString() :
00450                                        mRegionMap[mHolidayCombo->currentText()];
00451 
00452       KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentIndex();
00453       int mask = 0;
00454       for ( int i = 0; i < 7; ++i ) {
00455         if ( mWorkDays[i]->isChecked() ) {
00456           mask = mask | ( 1 << i );
00457         }
00458       }
00459       KOPrefs::instance()->mWorkWeekMask = mask;
00460       KOPrefs::instance()->writeConfig();
00461     }
00462 
00463     void setCombo( KComboBox *combo, const QString &text, const QStringList *tags = 0 )
00464     {
00465       if ( tags ) {
00466         int i = tags->indexOf( text );
00467         if ( i > 0 ) {
00468           combo->setCurrentIndex( i );
00469         }
00470       } else {
00471         for ( int i=0; i < combo->count(); ++i ) {
00472           if ( combo->itemText( i ) == text ) {
00473             combo->setCurrentIndex( i );
00474             break;
00475           }
00476         }
00477       }
00478     }
00479 
00480   private:
00481     KComboBox    *mTimeZoneCombo;
00482     QStringList   tzonenames;
00483     KComboBox    *mHolidayCombo;
00484     QMap<QString,QString> mRegionMap;
00485     KComboBox    *mAlarmTimeCombo;
00486     QCheckBox    *mWorkDays[7];
00487 };
00488 
00489 extern "C"
00490 {
00491   KDE_EXPORT KCModule *create_korganizerconfigtime( QWidget *parent, const char * )
00492   {
00493     KGlobal::locale()->insertCatalog( "timezones4" );
00494     return new KOPrefsDialogTime( KOGlobals::self()->componentData(), parent );
00495   }
00496 }
00497 
00500 
00501 class KOPrefsDialogViews : public KPrefsModule
00502 {
00503   public:
00504     KOPrefsDialogViews( const KComponentData &inst, QWidget *parent )
00505       : KPrefsModule( KOPrefs::instance(), inst, parent )
00506     {
00507       QBoxLayout *topTopLayout = new QVBoxLayout( this );
00508       KTabWidget *tabWidget = new KTabWidget( this );
00509       topTopLayout->addWidget( tabWidget );
00510 
00511       QFrame *topFrame = new QFrame( this );
00512       tabWidget->addTab( topFrame, KIcon( "view-choose" ),
00513                          i18nc( "@title:tab general settings", "General" ) );
00514       QBoxLayout *generalLayout = new QVBoxLayout( topFrame );
00515       generalLayout->setSpacing( KDialog::spacingHint() );
00516 
00517       KPrefsWidBool *enableToolTips =
00518         addWidBool( KOPrefs::instance()->enableToolTipsItem(), topFrame );
00519       generalLayout->addWidget( enableToolTips->checkBox() );
00520 
00521       KPrefsWidBool *showTodosAgenda =
00522         addWidBool( KOPrefs::instance()->showAllDayTodoItem(), topFrame );
00523       generalLayout->addWidget( showTodosAgenda->checkBox() );
00524 
00525       KPrefsWidBool *todosUseCategoryColors =
00526         addWidBool( KOPrefs::instance()->todosUseCategoryColorsItem(), topFrame );
00527       generalLayout->addWidget( todosUseCategoryColors->checkBox() );
00528 
00529       QGroupBox *dateNavGroup =
00530         new QGroupBox( i18nc( "@title:group", "Date Navigator" ), topFrame );
00531       generalLayout->addWidget( dateNavGroup );
00532 
00533       QBoxLayout *dateNavLayout = new QVBoxLayout( dateNavGroup );
00534 
00535       dateNavLayout->addWidget( addWidBool( KOPrefs::instance()->dailyRecurItem() )->checkBox() );
00536       dateNavLayout->addWidget( addWidBool( KOPrefs::instance()->weeklyRecurItem() )->checkBox() );
00537 
00538       generalLayout->addStretch( 1 );
00539 
00540       QFrame *agendaFrame = new QFrame( this );
00541       tabWidget->addTab( agendaFrame, KIcon( "view-calendar-workweek" ),
00542                          i18nc( "@title:tab", "Agenda View" ) );
00543 
00544       QBoxLayout *agendaLayout = new QVBoxLayout( agendaFrame );
00545 
00546       QBoxLayout *hourSizeLayout = new QHBoxLayout;
00547       agendaLayout->addLayout( hourSizeLayout );
00548 
00549       KPrefsWidInt *hourSize =
00550         addWidInt( KOPrefs::instance()->hourSizeItem() );
00551       hourSize->spinBox()->setSuffix(
00552         i18nc( "@label suffix in the hour size spin box", " pixel" ) );
00553 
00554       hourSizeLayout->addWidget( hourSize->label() );
00555       hourSizeLayout->addWidget( hourSize->spinBox() );
00556       hourSizeLayout->addStretch( 1 );
00557 
00558       QBoxLayout *nextDaysLayout = new QHBoxLayout;
00559       agendaLayout->addLayout( nextDaysLayout );
00560 
00561       KPrefsWidInt *nextDays =
00562         addWidInt( KOPrefs::instance()->nextXDaysItem() );
00563       nextDays->spinBox()->setSuffix(
00564         i18nc( "@label suffix in the N days spin box", " days" ) );
00565 
00566       nextDaysLayout->addWidget( nextDays->label() );
00567       nextDaysLayout->addWidget( nextDays->spinBox() );
00568       nextDaysLayout->addStretch( 1 );
00569 
00570       KPrefsWidBool *marcusBainsEnabled =
00571         addWidBool( KOPrefs::instance()->marcusBainsEnabledItem() );
00572       agendaLayout->addWidget( marcusBainsEnabled->checkBox() );
00573 
00574       KPrefsWidBool *marcusBainsShowSeconds =
00575         addWidBool( KOPrefs::instance()->marcusBainsShowSecondsItem() );
00576       connect( marcusBainsEnabled->checkBox(), SIGNAL(toggled(bool)),
00577                marcusBainsShowSeconds->checkBox(), SLOT(setEnabled(bool)) );
00578 
00579       agendaLayout->addWidget( marcusBainsShowSeconds->checkBox() );
00580       agendaLayout->addWidget(
00581         addWidBool( KOPrefs::instance()->selectionStartsEditorItem() )->checkBox() );
00582       agendaLayout->addWidget(
00583         addWidCombo( KOPrefs::instance()->agendaViewColorsItem() )->comboBox() );
00584       agendaLayout->addWidget(
00585         addWidCombo( KOPrefs::instance()->agendaViewCalendarDisplayItem() )->comboBox() );
00586 
00587       agendaLayout->addStretch( 1 );
00588 
00589       QFrame *monthFrame = new QFrame( this );
00590       tabWidget->addTab( monthFrame, KIcon( "view-calendar-month" ),
00591                          i18nc( "@title:tab", "Month View" ) );
00592 
00593       QBoxLayout *monthLayout = new QVBoxLayout( monthFrame );
00594 
00595       monthLayout->addWidget(
00596         addWidBool( KOPrefs::instance()->enableMonthScrollItem() )->checkBox() );
00597       monthLayout->addWidget(
00598         addWidBool( KOPrefs::instance()->enableMonthItemIconsItem() )->checkBox() );
00599       monthLayout->addWidget(
00600         addWidBool( KOPrefs::instance()->fullViewMonthItem() )->checkBox() );
00601       monthLayout->addWidget(
00602         addWidBool( KOPrefs::instance()->monthViewUsesCategoryColorItem() )->checkBox() );
00603       monthLayout->addWidget(
00604         addWidBool( KOPrefs::instance()->monthViewUsesResourceColorItem() )->checkBox() );
00605 
00606       monthLayout->addStretch( 1 );
00607 
00608       QFrame *todoFrame = new QFrame( this );
00609       tabWidget->addTab( todoFrame, KIcon( "view-calendar-tasks" ),
00610                          i18nc( "@title:tab", "Todo View" ) );
00611 
00612       QBoxLayout *todoLayout = new QVBoxLayout( todoFrame );
00613       todoLayout->addWidget(
00614         addWidBool( KOPrefs::instance()->fullViewTodoItem() )->checkBox() );
00615       todoLayout->addWidget(
00616         addWidBool( KOPrefs::instance()->recordTodosInJournalsItem() )->checkBox() );
00617       todoLayout->addWidget(
00618         addWidBool( KOPrefs::instance()->sortCompletedTodosSeparatelyItem() )->checkBox() );
00619       todoLayout->addStretch( 1 );
00620 
00621       load();
00622     }
00623 };
00624 
00625 extern "C"
00626 {
00627   KDE_EXPORT KCModule *create_korganizerconfigviews( QWidget *parent, const char * )
00628   {
00629     return new KOPrefsDialogViews( KOGlobals::self()->componentData(), parent );
00630   }
00631 }
00632 
00635 
00636 KOPrefsDialogColorsAndFonts::KOPrefsDialogColorsAndFonts( const KComponentData &inst,
00637                                                           QWidget *parent )
00638   : KPrefsModule( KOPrefs::instance(), inst, parent )
00639 {
00640   QBoxLayout *topTopLayout = new QVBoxLayout( this );
00641   KTabWidget *tabWidget = new KTabWidget( this );
00642   topTopLayout->addWidget( tabWidget );
00643 
00644   QWidget *colorFrame = new QWidget( this );
00645   topTopLayout->addWidget( colorFrame );
00646   QGridLayout *colorLayout = new QGridLayout(colorFrame);
00647   colorLayout->setSpacing( KDialog::spacingHint() );
00648   tabWidget->addTab( colorFrame, KIcon( "preferences-desktop-color" ),
00649                      i18nc( "@title:tab", "Colors" ) );
00650 
00651   // Holiday Color
00652   KPrefsWidColor *holidayColor =
00653     addWidColor( KOPrefs::instance()->agendaHolidaysBackgroundColorItem(), colorFrame );
00654   colorLayout->addWidget( holidayColor->label(), 0, 0 );
00655   colorLayout->addWidget( holidayColor->button(), 0, 1 );
00656 
00657   KPrefsWidColor *eventColor =
00658     addWidColor( KOPrefs::instance()->agendaCalendarItemsEventsBackgroundColorItem(), colorFrame );
00659   colorLayout->addWidget( eventColor->label(), 2, 0 );
00660   colorLayout->addWidget( eventColor->button(), 2, 1 );
00661 
00662   // agenda view background color
00663   KPrefsWidColor *agendaBgColor =
00664     addWidColor( KOPrefs::instance()->agendaGridBackgroundColorItem(), colorFrame );
00665   colorLayout->addWidget( agendaBgColor->label(), 3, 0 );
00666   colorLayout->addWidget( agendaBgColor->button(), 3, 1 );
00667 
00668   // working hours color
00669   KPrefsWidColor *agendaGridWorkHoursBackgroundColor =
00670     addWidColor( KOPrefs::instance()->agendaGridWorkHoursBackgroundColorItem(), colorFrame );
00671   colorLayout->addWidget( agendaGridWorkHoursBackgroundColor->label(), 4, 0 );
00672   colorLayout->addWidget( agendaGridWorkHoursBackgroundColor->button(), 4, 1 );
00673 
00674   // Todo due today color
00675   KPrefsWidColor *todoDueTodayColor =
00676     addWidColor(
00677       KOPrefs::instance()->agendaCalendarItemsToDosDueTodayBackgroundColorItem(), colorFrame );
00678   colorLayout->addWidget( todoDueTodayColor->label(), 5, 0 );
00679   colorLayout->addWidget( todoDueTodayColor->button(), 5, 1 );
00680 
00681   // Todo overdue color
00682   KPrefsWidColor *todoOverdueColor =
00683     addWidColor(
00684       KOPrefs::instance()->agendaCalendarItemsToDosOverdueBackgroundColorItem(), colorFrame );
00685   colorLayout->addWidget( todoOverdueColor->label(), 6, 0 );
00686   colorLayout->addWidget( todoOverdueColor->button(), 6, 1 );
00687 
00688   // categories colors
00689   QGroupBox *categoryGroup = new QGroupBox( i18nc( "@title:group", "Categories" ), colorFrame );
00690   colorLayout->addWidget( categoryGroup, 7, 0, 1, 2 );
00691 
00692   QBoxLayout *categoryLayout = new QHBoxLayout;
00693   categoryGroup->setLayout( categoryLayout );
00694 
00695   mCategoryCombo = new KComboBox(categoryGroup);
00696   mCategoryCombo->addItems( KOPrefs::instance()->mCustomCategories );
00697   mCategoryCombo->setWhatsThis(
00698     i18nc( "@info:whatsthis",
00699            "Select here the event category you want to modify. "
00700            "You can change the selected category color using "
00701            "the button below." ) );
00702   connect( mCategoryCombo, SIGNAL(activated(int)), SLOT(updateCategoryColor()) );
00703   categoryLayout->addWidget( mCategoryCombo );
00704 
00705   mCategoryButton = new KColorButton( categoryGroup );
00706   mCategoryButton->setWhatsThis(
00707     i18nc( "@info:whatsthis",
00708            "Choose here the color of the event category selected "
00709            "using the combo box above." ) );
00710   connect( mCategoryButton, SIGNAL(changed(const QColor &)), SLOT(setCategoryColor()) );
00711   categoryLayout->addWidget( mCategoryButton );
00712 
00713   updateCategoryColor();
00714 
00715   // resources colors
00716   QGroupBox *resourceGroup = new QGroupBox( i18nc( "@title:group", "Resources" ), colorFrame );
00717   colorLayout->addWidget( resourceGroup, 8, 0, 1, 2 );
00718 
00719   QBoxLayout *resourceLayout = new QHBoxLayout;
00720   resourceGroup->setLayout( resourceLayout );
00721 
00722   mResourceCombo = new KComboBox(resourceGroup);
00723   mResourceCombo->setWhatsThis(
00724     i18nc( "@info:whatsthis",
00725            "Select here resource you want to modify. "
00726            "You can change the selected resource color using "
00727            "the button below." ) );
00728   connect( mResourceCombo, SIGNAL(activated(int)), SLOT(updateResourceColor()) );
00729   resourceLayout->addWidget( mResourceCombo );
00730 
00731   mResourceButton = new KColorButton( resourceGroup );
00732   mResourceButton->setWhatsThis(
00733     i18nc( "@info:whatsthis",
00734            "Choose here the color of the resource selected "
00735            "using the combo box above." ) );
00736   connect( mResourceButton, SIGNAL(changed(const QColor &)), SLOT(setResourceColor()) );
00737   resourceLayout->addWidget( mResourceButton );
00738 
00739   updateResources();
00740 
00741   colorLayout->setRowStretch( 9, 1 );
00742 
00743   QWidget *fontFrame = new QWidget( this );
00744   tabWidget->addTab( fontFrame, KIcon( "preferences-desktop-font" ),
00745                      i18nc( "@title:tab", "Fonts" ) );
00746 
00747   QGridLayout *fontLayout = new QGridLayout( fontFrame );
00748   fontLayout->setSpacing( KDialog::spacingHint() );
00749 
00750   KPrefsWidFont *timeBarFont =
00751     addWidFont( KOPrefs::instance()->agendaTimeLabelsFontItem(), fontFrame,
00752                 KGlobal::locale()->formatTime( QTime( 12, 34 ) ) );
00753   fontLayout->addWidget( timeBarFont->label(), 0, 0 );
00754   fontLayout->addWidget( timeBarFont->preview(), 0, 1 );
00755   fontLayout->addWidget( timeBarFont->button(), 0, 2 );
00756 
00757   KPrefsWidFont *monthViewFont =
00758     addWidFont( KOPrefs::instance()->monthViewFontItem(), fontFrame,
00759                 KGlobal::locale()->formatTime( QTime( 12, 34 ) ) + ' ' +
00760                 i18nc( "@label", "Event text" ) );
00761 
00762   fontLayout->addWidget( monthViewFont->label(), 1, 0 );
00763   fontLayout->addWidget( monthViewFont->preview(), 1, 1 );
00764   fontLayout->addWidget( monthViewFont->button(), 1, 2 );
00765 
00766   KPrefsWidFont *agendaViewFont =
00767     addWidFont( KOPrefs::instance()->agendaViewFontItem(), fontFrame,
00768                 i18nc( "@label", "Event text" ) );
00769   fontLayout->addWidget( agendaViewFont->label(), 2, 0 );
00770   fontLayout->addWidget( agendaViewFont->preview(), 2, 1 );
00771   fontLayout->addWidget( agendaViewFont->button(), 2, 2 );
00772 
00773   KPrefsWidFont *marcusBainsFont =
00774     addWidFont( KOPrefs::instance()->agendaMarcusBainsLineFontItem(), fontFrame,
00775                 KGlobal::locale()->formatTime( QTime( 12, 34, 23 ) ) );
00776   fontLayout->addWidget( marcusBainsFont->label(), 3, 0 );
00777   fontLayout->addWidget( marcusBainsFont->preview(), 3, 1 );
00778   fontLayout->addWidget( marcusBainsFont->button(), 3, 2 );
00779 
00780   fontLayout->setColumnStretch( 1, 1 );
00781   fontLayout->setRowStretch( 4, 1 );
00782 
00783   load();
00784 }
00785 
00786 void KOPrefsDialogColorsAndFonts::usrWriteConfig()
00787 {
00788   QHash<QString, QColor>::const_iterator i = mCategoryDict.constBegin();
00789   while ( i != mCategoryDict.constEnd() ) {
00790     KOPrefs::instance()->setCategoryColor( i.key(), i.value() );
00791     ++i;
00792   }
00793 
00794   i = mResourceDict.constBegin();
00795   while ( i != mResourceDict.constEnd() ) {
00796     KOPrefs::instance()->setResourceColor( i.key(), i.value() );
00797     ++i;
00798   }
00799 }
00800 
00801 void KOPrefsDialogColorsAndFonts::usrReadConfig()
00802 {
00803   updateCategories();
00804   updateResources();
00805 }
00806 
00807 void KOPrefsDialogColorsAndFonts::updateCategories()
00808 {
00809   mCategoryCombo->clear();
00810   mCategoryCombo->addItems( KOPrefs::instance()->mCustomCategories );
00811   updateCategoryColor();
00812 }
00813 
00814 void KOPrefsDialogColorsAndFonts::setCategoryColor()
00815 {
00816   mCategoryDict.insert( mCategoryCombo->currentText(), mCategoryButton->color() );
00817   slotWidChanged();
00818 }
00819 
00820 void KOPrefsDialogColorsAndFonts::updateCategoryColor()
00821 {
00822   QString cat = mCategoryCombo->currentText();
00823   QColor color = mCategoryDict.value( cat );
00824   if ( !color.isValid() ) {
00825     color = KOPrefs::instance()->categoryColor( cat );
00826   }
00827   if ( color.isValid() ) {
00828     mCategoryButton->setColor( color );
00829   }
00830 }
00831 
00832 void KOPrefsDialogColorsAndFonts::updateResources()
00833 {
00834   mResourceCombo->clear();
00835   mResourceIdentifier.clear();
00836 
00837   KCal::CalendarResourceManager *manager = KOrg::StdCalendar::self()->resourceManager();
00838 
00839   KCal::CalendarResourceManager::Iterator it;
00840   for ( it = manager->begin(); it != manager->end(); ++it ) {
00841     if ( !(*it)->subresources().isEmpty() ) {
00842       QStringList subresources = (*it)->subresources();
00843       for ( int i = 0; i < subresources.count(); ++i ) {
00844         QString resource = subresources.at( i );
00845         if ( (*it)->subresourceActive( resource ) ) {
00846           mResourceCombo->addItem( (*it)->labelForSubresource( resource ) );
00847           mResourceIdentifier.append( resource );
00848         }
00849       }
00850     }
00851 
00852     mResourceCombo->addItem( (*it)->resourceName() );
00853     mResourceIdentifier.append( (*it)->identifier() );
00854   }
00855 
00856   updateResourceColor();
00857 }
00858 
00859 void KOPrefsDialogColorsAndFonts::setResourceColor()
00860 {
00861   mResourceDict.insert( mResourceIdentifier[mResourceCombo->currentIndex()],
00862                         mResourceButton->color() );
00863   slotWidChanged();
00864 }
00865 
00866 void KOPrefsDialogColorsAndFonts::updateResourceColor()
00867 {
00868   QString res= mResourceIdentifier[mResourceCombo->currentIndex()];
00869   QColor color = mCategoryDict.value( res );
00870   if ( color.isValid() )  {
00871     color = KOPrefs::instance()->resourceColor( res );
00872   }
00873   if ( color.isValid() ) {
00874     mResourceButton->setColor( color );
00875   }
00876 }
00877 extern "C"
00878 {
00879   KDE_EXPORT KCModule *create_korganizerconfigcolorsandfonts( QWidget *parent, const char * )
00880   {
00881     return new KOPrefsDialogColorsAndFonts( KOGlobals::self()->componentData(), parent );
00882   }
00883 }
00884 
00887 
00888 KOPrefsDialogGroupScheduling::KOPrefsDialogGroupScheduling( const KComponentData &inst,
00889                                                             QWidget *parent )
00890   : KPrefsModule( KOPrefs::instance(), inst, parent )
00891 {
00892   QBoxLayout *topTopLayout = new QVBoxLayout( this );
00893 
00894   QWidget *topFrame = new QWidget( this );
00895   topTopLayout->addWidget( topFrame );
00896 
00897   QGridLayout *topLayout = new QGridLayout( topFrame );
00898   topLayout->setSpacing( KDialog::spacingHint() );
00899 
00900   KPrefsWidBool *useGroupwareBool =
00901     addWidBool( KOPrefs::instance()->useGroupwareCommunicationItem(), topFrame );
00902   topLayout->addWidget( useGroupwareBool->checkBox(), 0, 0, 1, 2 );
00903   // FIXME: This radio button should only be available when KMail is chosen
00904 //   connect( thekmailradiobuttonupthere, SIGNAL(toggled(bool)),
00905 //            useGroupwareBool->checkBox(), SLOT(enabled(bool)) );
00906 
00907   KPrefsWidBool *bcc =
00908     addWidBool( KOPrefs::instance()->bccItem(), topFrame );
00909   topLayout->addWidget( bcc->checkBox(), 1, 0, 1, 2 );
00910 
00911   KPrefsWidRadios *mailClientGroup =
00912     addWidRadios( KOPrefs::instance()->mailClientItem(), topFrame );
00913   topLayout->addWidget( mailClientGroup->groupBox(), 2, 0, 1, 2 );
00914 
00915 #if 0
00916   KPrefsWidRadios *schedulerGroup =
00917     addWidRadios(
00918       i18nc( "@title", "Scheduler Mail Client" ), KOPrefs::instance()->mIMIPScheduler, topFrame );
00919   schedulerGroup->addRadio( "Dummy" ); // Only for debugging
00920   schedulerGroup->addRadio( i18nc( "@option:radio", "Mail client" ) );
00921 
00922   topLayout->addWidget( schedulerGroup->groupBox(), 0, 0, 1, 2 );
00923 #endif
00924 
00925   QLabel *aMailsLabel = new QLabel(
00926     i18nc( "@label", "Additional email addresses:" ), topFrame );
00927   QString whatsThis = i18nc( "@info:whatsthis",
00928                              "Add, edit or remove additional e-mails addresses "
00929                              "here. These email addresses are the ones you "
00930                              "have in addition to the one set in personal "
00931                              "preferences. If you are an attendee of one event, "
00932                              "but use another email address there, you need to "
00933                              "list this address here so KOrganizer can "
00934                              "recognize it as yours." );
00935   aMailsLabel->setWhatsThis( whatsThis );
00936   topLayout->addWidget( aMailsLabel, 3, 0, 1, 2 );
00937   mAMails = new Q3ListView( topFrame );
00938   mAMails->setWhatsThis( whatsThis );
00939 
00940   mAMails->addColumn( i18nc( "@title:column email addresses", "Email" ), 300 );
00941   topLayout->addWidget( mAMails, 4, 0, 1, 2 );
00942 
00943   QLabel *aEmailsEditLabel = new QLabel( i18nc( "@label", "Additional email address:" ), topFrame );
00944   whatsThis = i18nc( "@info:whatsthis",
00945                      "Edit additional e-mails addresses here. To edit an "
00946                      "address select it from the list above "
00947                      "or press the \"New\" button below. These email "
00948                      "addresses are the ones you have in addition to the "
00949                      "one set in personal preferences." );
00950   aEmailsEditLabel->setWhatsThis( whatsThis );
00951   topLayout->addWidget( aEmailsEditLabel, 5, 0 );
00952   aEmailsEdit = new KLineEdit( topFrame );
00953   aEmailsEdit->setWhatsThis( whatsThis );
00954   aEmailsEdit->setEnabled( false );
00955   topLayout->addWidget( aEmailsEdit, 5, 1 );
00956 
00957   QPushButton *add = new QPushButton(
00958     i18nc( "@action:button add a new email address",