summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabprefs.cpp4
-rw-r--r--kalarmd/alarmdialog.cpp9
-rw-r--r--kmicromail/koprefs.cpp11
-rw-r--r--korganizer/koprefs.cpp12
-rw-r--r--microkde/kdatetbl.cpp2
5 files changed, 15 insertions, 23 deletions
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index a2095d4..01e84d0 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,155 +1,155 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qregexp.h> 30#include <qregexp.h>
31#include <stdlib.h> 31#include <stdlib.h>
32#include <libkdepim/kpimglobalprefs.h> 32#include <libkdepim/kpimglobalprefs.h>
33 33
34#include <kconfig.h> 34#include <kconfig.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kstaticdeleter.h> 36#include <kstaticdeleter.h>
37#include <kglobalsettings.h>
37//US#include <kdebug.h> // defines kdDebug() 38//US#include <kdebug.h> // defines kdDebug()
38 39
39#include "kabprefs.h" 40#include "kabprefs.h"
40 41
41#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
42#include <qapplication.h> 43#include <qapplication.h>
43#endif 44#endif
44 45
45KABPrefs *KABPrefs::sInstance = 0; 46KABPrefs *KABPrefs::sInstance = 0;
46static KStaticDeleter<KABPrefs> staticDeleterAB; 47static KStaticDeleter<KABPrefs> staticDeleterAB;
47 48
48KABPrefs::KABPrefs() 49KABPrefs::KABPrefs()
49 : KPimPrefs("kaddressbookrc") 50 : KPimPrefs("kaddressbookrc")
50{ 51{
51 mDetailsFont = QFont("helvetica",12);
52 KPrefs::setCurrentGroup( "Views" ); 52 KPrefs::setCurrentGroup( "Views" );
53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
54 54
55 KPrefs::setCurrentGroup( "General" ); 55 KPrefs::setCurrentGroup( "General" );
56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
58 58
59#ifdef KAB_EMBEDDED 59#ifdef KAB_EMBEDDED
60 addItemBool("AskForQuit",&mAskForQuit,true); 60 addItemBool("AskForQuit",&mAskForQuit,true);
61 addItemBool("ToolBarHor",&mToolBarHor, true ); 61 addItemBool("ToolBarHor",&mToolBarHor, true );
62 addItemBool("ToolBarUp",&mToolBarUp, false ); 62 addItemBool("ToolBarUp",&mToolBarUp, false );
63 addItemBool("SearchWithReturn",&mSearchWithReturn, false ); 63 addItemBool("SearchWithReturn",&mSearchWithReturn, false );
64 addItemFont("DetailsFont",&mDetailsFont); 64 addItemFont("DetailsFont",&mDetailsFont,KGlobalSettings::generalFont());
65 65
66 66
67#endif //KAB_EMBEDDED 67#endif //KAB_EMBEDDED
68 68
69 KPrefs::setCurrentGroup( "MainWindow" ); 69 KPrefs::setCurrentGroup( "MainWindow" );
70 bool m_visible = false; 70 bool m_visible = false;
71#ifdef DESKTOP_VERSION 71#ifdef DESKTOP_VERSION
72 m_visible = true; 72 m_visible = true;
73#endif 73#endif
74 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible ); 74 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible );
75 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 75 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
76 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 76 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
77 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 77 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
78 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 78 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
79 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 79 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
80 80
81 81
82 KPrefs::setCurrentGroup( "Extensions_General" ); 82 KPrefs::setCurrentGroup( "Extensions_General" );
83 QStringList defaultExtensions; 83 QStringList defaultExtensions;
84 defaultExtensions << "merge"; 84 defaultExtensions << "merge";
85 defaultExtensions << "distribution_list_editor"; 85 defaultExtensions << "distribution_list_editor";
86 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 86 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
87 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 87 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
88 88
89 KPrefs::setCurrentGroup( "Views" ); 89 KPrefs::setCurrentGroup( "Views" );
90 QString defaultView = i18n( "Default Table View" ); 90 QString defaultView = i18n( "Default Table View" );
91 addItemString( "CurrentView", &mCurrentView, defaultView ); 91 addItemString( "CurrentView", &mCurrentView, defaultView );
92 addItemStringList( "ViewNames", &mViewNames, defaultView ); 92 addItemStringList( "ViewNames", &mViewNames, defaultView );
93 93
94 KPrefs::setCurrentGroup( "Filters" ); 94 KPrefs::setCurrentGroup( "Filters" );
95 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 95 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
96 96
97} 97}
98 98
99KABPrefs::~KABPrefs() 99KABPrefs::~KABPrefs()
100{ 100{
101 //qDebug("KABPrefs::~KABPrefs() "); 101 //qDebug("KABPrefs::~KABPrefs() ");
102 if (sInstance == this) 102 if (sInstance == this)
103 sInstance = staticDeleterAB.setObject(0); 103 sInstance = staticDeleterAB.setObject(0);
104} 104}
105 105
106KABPrefs *KABPrefs::instance() 106KABPrefs *KABPrefs::instance()
107{ 107{
108 if ( !sInstance ) { 108 if ( !sInstance ) {
109#ifdef KAB_EMBEDDED 109#ifdef KAB_EMBEDDED
110 sInstance = staticDeleterAB.setObject( new KABPrefs() ); 110 sInstance = staticDeleterAB.setObject( new KABPrefs() );
111#else //KAB_EMBEDDED 111#else //KAB_EMBEDDED
112 //US the following line has changed ???. Why 112 //US the following line has changed ???. Why
113 staticDeleterAB.setObject( sInstance, new KABPrefs() ); 113 staticDeleterAB.setObject( sInstance, new KABPrefs() );
114#endif //KAB_EMBEDDED 114#endif //KAB_EMBEDDED
115 sInstance->readConfig(); 115 sInstance->readConfig();
116 } 116 }
117 117
118 return sInstance; 118 return sInstance;
119} 119}
120 120
121void KABPrefs::setCategoryDefaults() 121void KABPrefs::setCategoryDefaults()
122{ 122{
123 mCustomCategories.clear(); 123 mCustomCategories.clear();
124 124
125 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 125 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
126 << i18n( "Customer" ) << i18n( "Friend" ); 126 << i18n( "Customer" ) << i18n( "Friend" );
127} 127}
128 128
129 // US introduce a nonconst way to return the config object. 129 // US introduce a nonconst way to return the config object.
130KConfig* KABPrefs::getConfig() 130KConfig* KABPrefs::getConfig()
131{ 131{
132 return config(); 132 return config();
133} 133}
134void KABPrefs::usrReadConfig() 134void KABPrefs::usrReadConfig()
135{ 135{
136 KPimPrefs::usrReadConfig(); 136 KPimPrefs::usrReadConfig();
137} 137}
138 138
139 139
140/*US 140/*US
141void KABPrefs::usrSetDefaults() 141void KABPrefs::usrSetDefaults()
142{ 142{
143 KPimPrefs::usrSetDefaults(); 143 KPimPrefs::usrSetDefaults();
144} 144}
145 145
146void KABPrefs::usrReadConfig() 146void KABPrefs::usrReadConfig()
147{ 147{
148 KPimPrefs::usrReadConfig(); 148 KPimPrefs::usrReadConfig();
149} 149}
150 150
151void KABPrefs::usrWriteConfig() 151void KABPrefs::usrWriteConfig()
152{ 152{
153 KPimPrefs::usrWriteConfig(); 153 KPimPrefs::usrWriteConfig();
154} 154}
155*/ 155*/
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp
index 521781e..751ba57 100644
--- a/kalarmd/alarmdialog.cpp
+++ b/kalarmd/alarmdialog.cpp
@@ -1,258 +1,261 @@
1/* 1/*
2 This file is part of the KDE alarm daemon. 2 This file is part of the KDE alarm daemon.
3 Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24// $Id$ 24// $Id$
25 25
26#include <qhbox.h> 26#include <qhbox.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qapp.h> 28#include <qapp.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qsound.h> 33#include <qsound.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qspinbox.h> 35#include <qspinbox.h>
36#include <stdlib.h> 36#include <stdlib.h>
37#ifndef _WIN32_ 37#ifndef _WIN32_
38#include <unistd.h> 38#include <unistd.h>
39#include <sys/ioctl.h> 39#include <sys/ioctl.h>
40#endif 40#endif
41#include <stdio.h> 41#include <stdio.h>
42#include <fcntl.h> 42#include <fcntl.h>
43 43
44#ifndef DESKTOP_VERSION 44#ifndef DESKTOP_VERSION
45#include <qtopia/alarmserver.h> 45#include <qtopia/alarmserver.h>
46#include <qpe/resource.h> 46#include <qpe/resource.h>
47#include <qtopia/sound.h> 47#include <qtopia/sound.h>
48#endif 48#endif
49 49
50#include "alarmdialog.h" 50#include "alarmdialog.h"
51 51
52 52
53AlarmDialog::AlarmDialog(QWidget *parent,const char *name) 53AlarmDialog::AlarmDialog(QWidget *parent,const char *name)
54 : QDialog (parent, name, true, Qt::WStyle_StaysOnTop ) 54 : QDialog (parent, name, true, Qt::WStyle_StaysOnTop )
55{ 55{
56 setCaption( "KO/Pi Alarm!" ); 56 setCaption( "KO/Pi Alarm!" );
57 QVBoxLayout* layout = new QVBoxLayout( this); 57 QVBoxLayout* layout = new QVBoxLayout( this);
58 QLabel* l = new QLabel("The following event triggered alarm:",this); 58 QLabel* l = new QLabel("The following event triggered alarm:",this);
59 layout->addWidget ( l ); 59 layout->addWidget ( l );
60 l->setAlignment( AlignCenter); 60 l->setAlignment( AlignCenter);
61 mMessage = new QLabel ( " ", this ); 61 mMessage = new QLabel ( " ", this );
62 int fs = 18; 62 int fs = 18;
63 int fs2 = 12; 63 int fs2 = 12;
64 if ( QApplication::desktop()->width() < 480 ) { 64 if ( QApplication::desktop()->width() < 480 ) {
65 setMaximumSize(220, 260); 65 setMaximumSize(220, 260);
66 fs2 = 10; 66 fs2 = 10;
67 } 67 }
68 else { 68 else {
69 setMaximumSize(440, 440); 69 setMaximumSize(440, 440);
70 } 70 }
71 layout->setSpacing( 3 ); 71 layout->setSpacing( 3 );
72 layout->setMargin( 3 ); 72 layout->setMargin( 3 );
73 73 QFont fo = QApplication::font();
74 l->setFont( QFont("helvetica",fs2, QFont::Bold) ); 74 fo.setBold( true );
75 mMessage->setFont( QFont("helvetica",fs, QFont::Bold) ); 75 fo.setPointSize( fs2 );
76 l->setFont( fo );
77 fo.setPointSize( fs );
78 mMessage->setFont(fo );
76 mMessage->setAlignment( AlignCenter); 79 mMessage->setAlignment( AlignCenter);
77 l = new QLabel("Missed Alarms:",this); 80 l = new QLabel("Missed Alarms:",this);
78 l->setAlignment( AlignCenter); 81 l->setAlignment( AlignCenter);
79 layout->addWidget ( mMessage ); 82 layout->addWidget ( mMessage );
80 layout->addWidget ( l ); 83 layout->addWidget ( l );
81 mMissedAlarms= new QLabel ( "", this ); 84 mMissedAlarms= new QLabel ( "", this );
82 mMissedAlarms->setAlignment( AlignCenter); 85 mMissedAlarms->setAlignment( AlignCenter);
83 86
84 playSoundTimer = new QTimer( this ); 87 playSoundTimer = new QTimer( this );
85 connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); 88 connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) );
86 89
87 playSoundTimer->stop(); 90 playSoundTimer->stop();
88 91
89 layout->addWidget ( mMissedAlarms ); 92 layout->addWidget ( mMissedAlarms );
90 QHBox *suspendBox = new QHBox( this ); 93 QHBox *suspendBox = new QHBox( this );
91 suspendBox->setSpacing(3); 94 suspendBox->setSpacing(3);
92 layout->addWidget ( suspendBox ); 95 layout->addWidget ( suspendBox );
93 (void)new QLabel("Suspend duration (minutes):",suspendBox); 96 (void)new QLabel("Suspend duration (minutes):",suspendBox);
94 mSuspendSpin = new QSpinBox(1,1440,1,suspendBox); 97 mSuspendSpin = new QSpinBox(1,1440,1,suspendBox);
95 mSuspendSpin->setValue(7); // default suspend duration 98 mSuspendSpin->setValue(7); // default suspend duration
96 QHBox * bbox = new QHBox ( this ); 99 QHBox * bbox = new QHBox ( this );
97 layout->addWidget ( bbox ); 100 layout->addWidget ( bbox );
98 bbox->layout()->setSpacing( 5 ); 101 bbox->layout()->setSpacing( 5 );
99 QPushButton* suspend = new QPushButton( "Suspend", bbox); 102 QPushButton* suspend = new QPushButton( "Suspend", bbox);
100 QPushButton* silen = new QPushButton( " Stop sound ", bbox); 103 QPushButton* silen = new QPushButton( " Stop sound ", bbox);
101 QPushButton* okbut = new QPushButton( "Ok", bbox); 104 QPushButton* okbut = new QPushButton( "Ok", bbox);
102 connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); 105 connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) );
103 connect (suspend , SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); 106 connect (suspend , SIGNAL( clicked() ), this, SLOT (slotSuspend() ) );
104 connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); 107 connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) );
105#ifndef _WIN32_ 108#ifndef _WIN32_
106 if ( QFile::exists ( "/dev/sharp_led" ) ) 109 if ( QFile::exists ( "/dev/sharp_led" ) )
107 fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 110 fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
108 else 111 else
109#endif 112#endif
110 fd_led = 0; 113 fd_led = 0;
111 statusLED.which = SHARP_LED_SALARM; 114 statusLED.which = SHARP_LED_SALARM;
112 mSilent = false; 115 mSilent = false;
113 mSuspendCounter = 0; 116 mSuspendCounter = 0;
114 setServerNotification( true ); 117 setServerNotification( true );
115} 118}
116void AlarmDialog::reject () 119void AlarmDialog::reject ()
117{ 120{
118 QTimer::singleShot ( 3000, this, SLOT (suspend()) ); 121 QTimer::singleShot ( 3000, this, SLOT (suspend()) );
119 slotSuspend(); 122 slotSuspend();
120} 123}
121AlarmDialog::~AlarmDialog() 124AlarmDialog::~AlarmDialog()
122{ 125{
123} 126}
124void AlarmDialog::silent () 127void AlarmDialog::silent ()
125{ 128{
126 mSilent = true; 129 mSilent = true;
127} 130}
128void AlarmDialog::accept() 131void AlarmDialog::accept()
129{ 132{
130 slotOk(); 133 slotOk();
131} 134}
132 135
133void AlarmDialog::suspend() 136void AlarmDialog::suspend()
134{ 137{
135#ifdef DESKTOP_VERSION 138#ifdef DESKTOP_VERSION
136 139
137#else 140#else
138 Sound::soundAlarm (); 141 Sound::soundAlarm ();
139#endif 142#endif
140} 143}
141void AlarmDialog::slotOk() 144void AlarmDialog::slotOk()
142{ 145{
143 mStopAlarm = true; 146 mStopAlarm = true;
144 mMissedAlarms->setText(""); 147 mMissedAlarms->setText("");
145 mMessage->setText(""); 148 mMessage->setText("");
146#ifndef _WIN32_ 149#ifndef _WIN32_
147 if ( fd_led > 0 ) { 150 if ( fd_led > 0 ) {
148 statusLED.status = LED_SALARM_OFF ; 151 statusLED.status = LED_SALARM_OFF ;
149 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); 152 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
150 } 153 }
151#endif 154#endif
152 QDialog::accept(); 155 QDialog::accept();
153} 156}
154 157
155void AlarmDialog::slotSuspend() 158void AlarmDialog::slotSuspend()
156{ 159{
157 //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); 160 //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value());
158 mStopAlarm = true; 161 mStopAlarm = true;
159 QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); 162 QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 );
160 QString mess = "suspend_alarm" +mFileName+"+++" ; 163 QString mess = "suspend_alarm" +mFileName+"+++" ;
161 if ( mMessage->text().left( 10 ) !="Suspended:" ) 164 if ( mMessage->text().left( 10 ) !="Suspended:" )
162 mess += "Suspended:\n"; 165 mess += "Suspended:\n";
163 mess +=mMessage->text(); 166 mess +=mMessage->text();
164#ifndef DESKTOP_VERSION 167#ifndef DESKTOP_VERSION
165 if ( mServerNotification ) 168 if ( mServerNotification )
166 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); 169 AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1());
167#endif 170#endif
168 emit addAlarm( nextA , mess ); 171 emit addAlarm( nextA , mess );
169 slotOk(); 172 slotOk();
170} 173}
171 174
172void AlarmDialog::setServerNotification( bool b ) 175void AlarmDialog::setServerNotification( bool b )
173{ 176{
174 mServerNotification = b; 177 mServerNotification = b;
175} 178}
176int AlarmDialog::getSuspendTime( ) 179int AlarmDialog::getSuspendTime( )
177{ 180{
178 return mSuspendSpin->value(); 181 return mSuspendSpin->value();
179 182
180} 183}
181void AlarmDialog::setSuspendTime( int val ) 184void AlarmDialog::setSuspendTime( int val )
182{ 185{
183 mSuspendSpin->setValue( val ); 186 mSuspendSpin->setValue( val );
184} 187}
185bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) 188bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes)
186{ 189{
187 if ( mess.left( 9) != "Suspended" ) 190 if ( mess.left( 9) != "Suspended" )
188 mSuspendCounter = suspendtimes; 191 mSuspendCounter = suspendtimes;
189 mPauseCount = pause; 192 mPauseCount = pause;
190 mFileName = fn; 193 mFileName = fn;
191 mPlayWav = playwav; 194 mPlayWav = playwav;
192 if ( !QFile::exists( fn ) ) 195 if ( !QFile::exists( fn ) )
193 mFileName = ""; 196 mFileName = "";
194 alarmCounter = 0 ; 197 alarmCounter = 0 ;
195 maxAlarmReplay = replay ; 198 maxAlarmReplay = replay ;
196 mStopAlarm = false; 199 mStopAlarm = false;
197 mSilent = false; 200 mSilent = false;
198 if ( mMissedAlarms->text() == "" ) 201 if ( mMissedAlarms->text() == "" )
199 mMissedAlarms->setText( mMessage->text()); 202 mMissedAlarms->setText( mMessage->text());
200 else 203 else
201 mMissedAlarms->setText( mMessage->text()+ "\n" + mMissedAlarms->text() ); 204 mMissedAlarms->setText( mMessage->text()+ "\n" + mMissedAlarms->text() );
202 if ( mMissedAlarms->text().length() > 180 ) 205 if ( mMissedAlarms->text().length() > 180 )
203 mMissedAlarms->setText(mMissedAlarms->text().left ( 180 )); 206 mMissedAlarms->setText(mMissedAlarms->text().left ( 180 ));
204 mMessage->setText(mess); 207 mMessage->setText(mess);
205 int w =sizeHint().width() ; 208 int w =sizeHint().width() ;
206 int h = sizeHint().height() ; 209 int h = sizeHint().height() ;
207 int dw = QApplication::desktop()->width(); 210 int dw = QApplication::desktop()->width();
208 int dh = QApplication::desktop()->height(); 211 int dh = QApplication::desktop()->height();
209 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 212 setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
210 show(); 213 show();
211 raise(); 214 raise();
212 qApp->processEvents(); 215 qApp->processEvents();
213 repaint(); 216 repaint();
214 qApp->processEvents(); 217 qApp->processEvents();
215 218
216#ifndef _WIN32_ 219#ifndef _WIN32_
217 if ( fd_led > 0 ) { 220 if ( fd_led > 0 ) {
218 statusLED.status = LED_SALARM_ON ; 221 statusLED.status = LED_SALARM_ON ;
219 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); 222 ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
220 } 223 }
221#endif 224#endif
222 playSoundTimer->start( 1000, true ); 225 playSoundTimer->start( 1000, true );
223 return true; 226 return true;
224 227
225} 228}
226 229
227 230
228void AlarmDialog::playSound () 231void AlarmDialog::playSound ()
229{ 232{
230 if (mStopAlarm ) 233 if (mStopAlarm )
231 return; 234 return;
232 showNormal(); 235 showNormal();
233 setActiveWindow(); 236 setActiveWindow();
234 setFocus(); 237 setFocus();
235 raise(); 238 raise();
236 239
237 qApp->processEvents(); 240 qApp->processEvents();
238 if ( alarmCounter < maxAlarmReplay && ! mSilent) { 241 if ( alarmCounter < maxAlarmReplay && ! mSilent) {
239 ++alarmCounter; 242 ++alarmCounter;
240 if ( !mPlayWav || mFileName.length() < 2 ) { 243 if ( !mPlayWav || mFileName.length() < 2 ) {
241 244
242#ifndef DESKTOP_VERSION 245#ifndef DESKTOP_VERSION
243 Sound::soundAlarm (); 246 Sound::soundAlarm ();
244#endif 247#endif
245 } else { 248 } else {
246 QSound::play ( mFileName ); 249 QSound::play ( mFileName );
247 //qDebug("BEEP!"); 250 //qDebug("BEEP!");
248 } 251 }
249 } else { 252 } else {
250 if ( ! mSilent && mSuspendCounter > 0 ) { 253 if ( ! mSilent && mSuspendCounter > 0 ) {
251 --mSuspendCounter; 254 --mSuspendCounter;
252 reject (); 255 reject ();
253 hide(); 256 hide();
254 return; 257 return;
255 } 258 }
256 } 259 }
257 playSoundTimer->start( mPauseCount * 1000, true ); 260 playSoundTimer->start( mPauseCount * 1000, true );
258} 261}
diff --git a/kmicromail/koprefs.cpp b/kmicromail/koprefs.cpp
index 7b1e169..e4b61dc 100644
--- a/kmicromail/koprefs.cpp
+++ b/kmicromail/koprefs.cpp
@@ -1,129 +1,126 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <kglobalsettings.h>
44 45
45#include "koprefs.h" 46#include "koprefs.h"
46#include "mainwindow.h" 47#include "mainwindow.h"
47 48
48 49
49KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
50static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
51 52
52KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
53 KPimPrefs("kopiemailrc") 54 KPimPrefs("kopiemailrc")
54{ 55{
55 mAppFont = QFont("helvetica",12);
56 mComposeFont = QFont("helvetica",12);
57 mReadFont = QFont("helvetica",12);
58
59 KPrefs::setCurrentGroup("General"); 56 KPrefs::setCurrentGroup("General");
60 addItemString("SendCodec",&mSendCodec,i18n ("userdefined") ); 57 addItemString("SendCodec",&mSendCodec,i18n ("userdefined") );
61 addItemString("SenderName",&mName,i18n ("Please set at") ); 58 addItemString("SenderName",&mName,i18n ("Please set at") );
62 addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") ); 59 addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") );
63 addItemBool("ViewMailAsHtml",&mViewAsHtml,false); 60 addItemBool("ViewMailAsHtml",&mViewAsHtml,false);
64 addItemBool("SendMailLater",&mSendLater,true); 61 addItemBool("SendMailLater",&mSendLater,true);
65 addItemBool("ShowToField",&mShowToField,false); 62 addItemBool("ShowToField",&mShowToField,false);
66 addItemBool("UseKapi",&mUseKapi,false); 63 addItemBool("UseKapi",&mUseKapi,false);
67 addItemInt("CurrentCodec",&mCurrentCodec,0); 64 addItemInt("CurrentCodec",&mCurrentCodec,0);
68 addItemBool("ShowInfoSub",&mShowInfoSub,true); 65 addItemBool("ShowInfoSub",&mShowInfoSub,true);
69 addItemBool("ShowInfoFrom",&mShowInfoFrom,true); 66 addItemBool("ShowInfoFrom",&mShowInfoFrom,true);
70 addItemBool("ShowInfoTo",&mShowInfoTo,true); 67 addItemBool("ShowInfoTo",&mShowInfoTo,true);
71 addItemBool("ShowInfoStart",&mShowInfoStart,true); 68 addItemBool("ShowInfoStart",&mShowInfoStart,true);
72 KPrefs::setCurrentGroup("Fonts"); 69 KPrefs::setCurrentGroup("Fonts");
73 addItemFont("Application Font",&mAppFont); 70 addItemFont("Application Font",&mAppFont,KGlobalSettings::generalFont());
74 addItemFont("Compose Font",&mComposeFont); 71 addItemFont("Compose Font",&mComposeFont,KGlobalSettings::generalFont());
75 addItemFont("Read Font",&mReadFont); 72 addItemFont("Read Font",&mReadFont,KGlobalSettings::generalFont());
76 fillMailDefaults(); 73 fillMailDefaults();
77 isDirty = false; 74 isDirty = false;
78} 75}
79 76
80 77
81KOPrefs::~KOPrefs() 78KOPrefs::~KOPrefs()
82{ 79{
83 if ( isDirty ) 80 if ( isDirty )
84 writeConfig(); 81 writeConfig();
85 if (mInstance == this) 82 if (mInstance == this)
86 mInstance = insd.setObject(0); 83 mInstance = insd.setObject(0);
87 84
88} 85}
89 86
90 87
91KOPrefs *KOPrefs::instance() 88KOPrefs *KOPrefs::instance()
92{ 89{
93 if (!mInstance) { 90 if (!mInstance) {
94 mInstance = insd.setObject(new KOPrefs()); 91 mInstance = insd.setObject(new KOPrefs());
95 mInstance->readConfig(); 92 mInstance->readConfig();
96 } 93 }
97 94
98 return mInstance; 95 return mInstance;
99} 96}
100 97
101void KOPrefs::usrSetDefaults() 98void KOPrefs::usrSetDefaults()
102{ 99{
103 100
104} 101}
105 102
106void KOPrefs::fillMailDefaults() 103void KOPrefs::fillMailDefaults()
107{ 104{
108 if (mName.isEmpty()) mName = i18n ("Please set at"); 105 if (mName.isEmpty()) mName = i18n ("Please set at");
109 if (mEmail.isEmpty()) mEmail = i18n ("Settings@General TAB"); 106 if (mEmail.isEmpty()) mEmail = i18n ("Settings@General TAB");
110} 107}
111 108
112void KOPrefs::usrReadConfig() 109void KOPrefs::usrReadConfig()
113{ 110{
114 111
115 KPimPrefs::usrReadConfig(); 112 KPimPrefs::usrReadConfig();
116} 113}
117 114
118 115
119void KOPrefs::usrWriteConfig() 116void KOPrefs::usrWriteConfig()
120{ 117{
121 KPimPrefs::usrWriteConfig(); 118 KPimPrefs::usrWriteConfig();
122} 119}
123 120
124 121
125 122
126KConfig* KOPrefs::getConfig() 123KConfig* KOPrefs::getConfig()
127{ 124{
128 return config(); 125 return config();
129} 126}
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 5bfe2a1..7efb6a6 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,460 +1,450 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kglobalsettings.h> 39#include <kglobalsettings.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kemailsettings.h> 43#include <kemailsettings.h>
44#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "mainwindow.h" 48#include "mainwindow.h"
49 49
50KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
51static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
52 52
53KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
54 KPimPrefs("korganizerrc") 54 KPimPrefs("korganizerrc")
55{ 55{
56 mCategoryColors.setAutoDelete(true); 56 mCategoryColors.setAutoDelete(true);
57 fillMailDefaults(); 57 fillMailDefaults();
58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
59 QColor defaultHolidayColor = QColor(255,0,0); 59 QColor defaultHolidayColor = QColor(255,0,0);
60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
63 QColor defaultTodoDueTodayColor = QColor(255,220,100); 63 QColor defaultTodoDueTodayColor = QColor(255,220,100);
64 QColor defaultTodoOverdueColor = QColor(255,153,125); 64 QColor defaultTodoOverdueColor = QColor(255,153,125);
65 65
66 /* 66
67 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
68 mDefaultViewFont = QFont("helvetica",10);
69 mDefaultMonthViewFont = QFont("helvetica",8);
70 mMarcusBainsFont= QFont("helvetica",10);
71 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
72 mEditBoxFont = QFont("helvetica",12);
73 mJornalViewFont = QFont("helvetica",12);
74 */
75
76
77 KPrefs::setCurrentGroup("General"); 67 KPrefs::setCurrentGroup("General");
78 68
79 69
80 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 70 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
81 71
82 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 72 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
83 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 73 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
84 addItemBool("ShowIconSearch",&mShowIconSearch,true); 74 addItemBool("ShowIconSearch",&mShowIconSearch,true);
85 addItemBool("ShowIconList",&mShowIconList,true); 75 addItemBool("ShowIconList",&mShowIconList,true);
86 addItemBool("ShowIconDay1",&mShowIconDay1,true); 76 addItemBool("ShowIconDay1",&mShowIconDay1,true);
87 addItemBool("ShowIconDay5",&mShowIconDay5,true); 77 addItemBool("ShowIconDay5",&mShowIconDay5,true);
88 addItemBool("ShowIconDay7",&mShowIconDay7,true); 78 addItemBool("ShowIconDay7",&mShowIconDay7,true);
89 addItemBool("ShowIconMonth",&mShowIconMonth,true); 79 addItemBool("ShowIconMonth",&mShowIconMonth,true);
90 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 80 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
91 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 81 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
92 addItemBool("ShowIconBack",&mShowIconBack,true); 82 addItemBool("ShowIconBack",&mShowIconBack,true);
93 addItemBool("ShowIconToday",&mShowIconToday,true); 83 addItemBool("ShowIconToday",&mShowIconToday,true);
94 addItemBool("ShowIconForward",&mShowIconForward,true); 84 addItemBool("ShowIconForward",&mShowIconForward,true);
95 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 85 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
96 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 86 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
97 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 87 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
98 addItemBool("ShowIconNext",&mShowIconNext,true); 88 addItemBool("ShowIconNext",&mShowIconNext,true);
99 addItemBool("ShowIconJournal",&mShowIconJournal,true); 89 addItemBool("ShowIconJournal",&mShowIconJournal,true);
100 addItemBool("ShowIconStretch",&mShowIconStretch,true); 90 addItemBool("ShowIconStretch",&mShowIconStretch,true);
101 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 91 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
102 92
103 addItemBool("AskForQuit",&mAskForQuit,false); 93 addItemBool("AskForQuit",&mAskForQuit,false);
104 94
105#ifndef DESKTOP_VERSION 95#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 96 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 97#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 98 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 99#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 100 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 101 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 102 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
113 addItemInt("Whats Next Days",&mWhatsNextDays,3); 103 addItemInt("Whats Next Days",&mWhatsNextDays,3);
114 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 104 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
115 105
116 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 106 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
117 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 107 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
118 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 108 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
119 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 109 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
120 addItemInt("AllDay Size",&mAllDaySize,28); 110 addItemInt("AllDay Size",&mAllDaySize,28);
121 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 111 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
122 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 112 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
123 113
124 addItemStringList("LocationDefaults",&mLocationDefaults ); 114 addItemStringList("LocationDefaults",&mLocationDefaults );
125 addItemStringList("EventSummary User",&mEventSummaryUser); 115 addItemStringList("EventSummary User",&mEventSummaryUser);
126 addItemStringList("TodoSummary User",&mTodoSummaryUser); 116 addItemStringList("TodoSummary User",&mTodoSummaryUser);
127 117
128 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 118 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
129 addItemBool("Enable Project View",&mEnableProjectView,false); 119 addItemBool("Enable Project View",&mEnableProjectView,false);
130 addItemBool("Auto Save",&mAutoSave,false); 120 addItemBool("Auto Save",&mAutoSave,false);
131 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 121 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
132 addItemBool("Confirm Deletes",&mConfirm,true); 122 addItemBool("Confirm Deletes",&mConfirm,true);
133 addItemString("Archive File",&mArchiveFile); 123 addItemString("Archive File",&mArchiveFile);
134 addItemString("Html Export File",&mHtmlExportFile, 124 addItemString("Html Export File",&mHtmlExportFile,
135 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 125 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
136 addItemBool("Html With Save",&mHtmlWithSave,false); 126 addItemBool("Html With Save",&mHtmlWithSave,false);
137 127
138 KPrefs::setCurrentGroup("Personal Settings"); 128 KPrefs::setCurrentGroup("Personal Settings");
139 129
140 addItemInt("Mail Client",&mMailClient,MailClientKMail); 130 addItemInt("Mail Client",&mMailClient,MailClientKMail);
141 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 131 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
142 addItemBool("Bcc",&mBcc,false); 132 addItemBool("Bcc",&mBcc,false);
143 133
144 KPrefs::setCurrentGroup("Time & Date"); 134 KPrefs::setCurrentGroup("Time & Date");
145 135
146 136
147 addItemInt("Default Start Time",&mStartTime,10); 137 addItemInt("Default Start Time",&mStartTime,10);
148 addItemInt("Default Duration",&mDefaultDuration,2); 138 addItemInt("Default Duration",&mDefaultDuration,2);
149 addItemInt("Default Alarm Time",&mAlarmTime,3); 139 addItemInt("Default Alarm Time",&mAlarmTime,3);
150 KPrefs::setCurrentGroup("AlarmSettings"); 140 KPrefs::setCurrentGroup("AlarmSettings");
151 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 141 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
152 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 142 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
153 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 143 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
154 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 144 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
155 145
156 146
157 KPrefs::setCurrentGroup("Calendar"); 147 KPrefs::setCurrentGroup("Calendar");
158 148
159 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 149 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
160 150
161 KPrefs::setCurrentGroup("Fonts"); 151 KPrefs::setCurrentGroup("Fonts");
162 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 152 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
163 addItemFont("TimeBar Font",&mTimeBarFont,KGlobalSettings::generalFont() ); 153 addItemFont("TimeBar Font",&mTimeBarFont,KGlobalSettings::generalFont() );
164 addItemFont("MonthView Font",&mMonthViewFont,KGlobalSettings::generalFont()); 154 addItemFont("MonthView Font",&mMonthViewFont,KGlobalSettings::generalFont());
165 addItemFont("AgendaView Font",&mAgendaViewFont,KGlobalSettings::generalFont()); 155 addItemFont("AgendaView Font",&mAgendaViewFont,KGlobalSettings::generalFont());
166 addItemFont("MarcusBains Font",&mMarcusBainsFont,KGlobalSettings::generalFont()); 156 addItemFont("MarcusBains Font",&mMarcusBainsFont,KGlobalSettings::generalFont());
167 addItemFont("TimeLabels Font",&mTimeLabelsFont,KGlobalSettings::generalFont()); 157 addItemFont("TimeLabels Font",&mTimeLabelsFont,KGlobalSettings::generalFont());
168 addItemFont("TodoView Font",&mTodoViewFont,KGlobalSettings::generalFont()); 158 addItemFont("TodoView Font",&mTodoViewFont,KGlobalSettings::generalFont());
169 addItemFont("ListView Font",&mListViewFont,KGlobalSettings::generalFont()); 159 addItemFont("ListView Font",&mListViewFont,KGlobalSettings::generalFont());
170 addItemFont("DateNavigator Font",&mDateNavigatorFont,KGlobalSettings::generalFont()); 160 addItemFont("DateNavigator Font",&mDateNavigatorFont,KGlobalSettings::generalFont());
171 addItemFont("EditBox Font",&mEditBoxFont,KGlobalSettings::generalFont()); 161 addItemFont("EditBox Font",&mEditBoxFont,KGlobalSettings::generalFont());
172 addItemFont("JournalView Font",&mJornalViewFont,KGlobalSettings::generalFont()); 162 addItemFont("JournalView Font",&mJornalViewFont,KGlobalSettings::generalFont());
173 addItemFont("WhatsNextView Font",&mWhatsNextFont,KGlobalSettings::generalFont()); 163 addItemFont("WhatsNextView Font",&mWhatsNextFont,KGlobalSettings::generalFont());
174 addItemFont("EventView Font",&mEventViewFont,KGlobalSettings::generalFont()); 164 addItemFont("EventView Font",&mEventViewFont,KGlobalSettings::generalFont());
175 165
176 KPrefs::setCurrentGroup("RemoteSyncing"); 166 KPrefs::setCurrentGroup("RemoteSyncing");
177 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 167 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
178 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 168 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
179 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 169 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
180 addItemInt("LastSyncTime",&mLastSyncTime,0); 170 addItemInt("LastSyncTime",&mLastSyncTime,0);
181 171
182#ifdef _WIN32_ 172#ifdef _WIN32_
183 QString hdp= locateLocal("data","korganizer")+"\\\\"; 173 QString hdp= locateLocal("data","korganizer")+"\\\\";
184#else 174#else
185 QString hdp= locateLocal("data","korganizer")+"/"; 175 QString hdp= locateLocal("data","korganizer")+"/";
186#endif 176#endif
187 177
188 KPrefs::setCurrentGroup("LoadSaveFileNames"); 178 KPrefs::setCurrentGroup("LoadSaveFileNames");
189 179
190 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 180 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
191 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 181 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
192 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 182 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
193 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 183 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
194 184
195 185
196 KPrefs::setCurrentGroup("Locale"); 186 KPrefs::setCurrentGroup("Locale");
197 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 187 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
198 188
199 189
200 KPrefs::setCurrentGroup("Colors"); 190 KPrefs::setCurrentGroup("Colors");
201 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 191 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
202 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 192 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
203 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 193 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
204 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 194 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
205 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 195 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
206 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 196 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
207 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 197 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
208 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 198 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
209 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 199 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
210 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 200 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
211 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 201 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
212 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 202 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
213 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 203 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
214 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 204 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
215 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 205 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
216 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 206 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
217 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 207 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
218 addItemBool("UseAppColors",&mUseAppColors,false); 208 addItemBool("UseAppColors",&mUseAppColors,false);
219 209
220 210
221 211
222 KPrefs::setCurrentGroup("Views"); 212 KPrefs::setCurrentGroup("Views");
223 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 213 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
224 addItemInt("Hour Size",&mHourSize,8); 214 addItemInt("Hour Size",&mHourSize,8);
225 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 215 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
226 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 216 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
227 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 217 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
228 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 218 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
229 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 219 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
230 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 220 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
231#ifdef DESKTOP_VERION 221#ifdef DESKTOP_VERION
232 addItemBool("Enable ToolTips",&mEnableToolTips,true); 222 addItemBool("Enable ToolTips",&mEnableToolTips,true);
233#else 223#else
234 addItemBool("Enable ToolTips",&mEnableToolTips,false); 224 addItemBool("Enable ToolTips",&mEnableToolTips,false);
235#endif 225#endif
236 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 226 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
237 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 227 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
238 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 228 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
239 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 229 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
240 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 230 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
241 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 231 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
242 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 232 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
243 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 233 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
244 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 234 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
245 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 235 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
246 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 236 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
247 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 237 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
248 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 238 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
249 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 239 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
250 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 240 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
251 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 241 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
252 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 242 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
253 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 243 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
254 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 244 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
255 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 245 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
256#ifdef DESKTOP_VERSION 246#ifdef DESKTOP_VERSION
257 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 247 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
258#else 248#else
259 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 249 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
260#endif 250#endif
261 addItemInt("Day Begins",&mDayBegins,7); 251 addItemInt("Day Begins",&mDayBegins,7);
262 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 252 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
263 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 253 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
264 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 254 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
265 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 255 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
266 256
267 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 257 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
268 addItemBool("Full View Month",&mFullViewMonth,true); 258 addItemBool("Full View Month",&mFullViewMonth,true);
269 addItemBool("Full View Todo",&mFullViewTodo,true); 259 addItemBool("Full View Todo",&mFullViewTodo,true);
270 addItemBool("Quick Todo",&mEnableQuickTodo,false); 260 addItemBool("Quick Todo",&mEnableQuickTodo,false);
271 261
272 addItemInt("Next X Days",&mNextXDays,3); 262 addItemInt("Next X Days",&mNextXDays,3);
273 263
274 KPrefs::setCurrentGroup("Printer"); 264 KPrefs::setCurrentGroup("Printer");
275 265
276 KPrefs::setCurrentGroup("Layout"); 266 KPrefs::setCurrentGroup("Layout");
277 267
278 addItemBool("CompactDialogs",&mCompactDialogs,false); 268 addItemBool("CompactDialogs",&mCompactDialogs,false);
279 addItemBool("VerticalScreen",&mVerticalScreen,true); 269 addItemBool("VerticalScreen",&mVerticalScreen,true);
280 270
281 KPrefs::setCurrentGroup("KOrganizer Plugins"); 271 KPrefs::setCurrentGroup("KOrganizer Plugins");
282 272
283 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 273 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
284 274
285 KPrefs::setCurrentGroup("Group Scheduling"); 275 KPrefs::setCurrentGroup("Group Scheduling");
286 276
287 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 277 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
288 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 278 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
289 addItemStringList("AdditionalMails",&mAdditionalMails,""); 279 addItemStringList("AdditionalMails",&mAdditionalMails,"");
290 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 280 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
291 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 281 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
292 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 282 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
293 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 283 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
294 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 284 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
295 285
296 KPrefs::setCurrentGroup( "Editors" ); 286 KPrefs::setCurrentGroup( "Editors" );
297 287
298 addItemStringList( "EventTemplates", &mEventTemplates ); 288 addItemStringList( "EventTemplates", &mEventTemplates );
299 addItemStringList( "TodoTemplates", &mTodoTemplates ); 289 addItemStringList( "TodoTemplates", &mTodoTemplates );
300 290
301 addItemInt("DestinationPolicy",&mDestination,standardDestination); 291 addItemInt("DestinationPolicy",&mDestination,standardDestination);
302 292
303 293
304 294
305} 295}
306 296
307 297
308KOPrefs::~KOPrefs() 298KOPrefs::~KOPrefs()
309{ 299{
310 if (mInstance == this) 300 if (mInstance == this)
311 mInstance = insd.setObject(0); 301 mInstance = insd.setObject(0);
312 302
313 //qDebug("KOPrefs::~KOPrefs() "); 303 //qDebug("KOPrefs::~KOPrefs() ");
314} 304}
315 305
316 306
317KOPrefs *KOPrefs::instance() 307KOPrefs *KOPrefs::instance()
318{ 308{
319 if (!mInstance) { 309 if (!mInstance) {
320 mInstance = insd.setObject(new KOPrefs()); 310 mInstance = insd.setObject(new KOPrefs());
321 mInstance->readConfig(); 311 mInstance->readConfig();
322 } 312 }
323 313
324 return mInstance; 314 return mInstance;
325} 315}
326 316
327void KOPrefs::usrSetDefaults() 317void KOPrefs::usrSetDefaults()
328{ 318{
329 319
330} 320}
331 321
332void KOPrefs::fillMailDefaults() 322void KOPrefs::fillMailDefaults()
333{ 323{
334 if (mName.isEmpty()) mName = i18n("Anonymous"); 324 if (mName.isEmpty()) mName = i18n("Anonymous");
335 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 325 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
336} 326}
337 327
338void KOPrefs::setTimeZoneIdDefault() 328void KOPrefs::setTimeZoneIdDefault()
339{ 329{
340 ; 330 ;
341} 331}
342 332
343void KOPrefs::setAllDefaults() 333void KOPrefs::setAllDefaults()
344{ 334{
345 setCategoryDefaults(); 335 setCategoryDefaults();
346 mEventSummaryUser = getDefaultList() ; 336 mEventSummaryUser = getDefaultList() ;
347 mTodoSummaryUser = getDefaultList() ; 337 mTodoSummaryUser = getDefaultList() ;
348 mLocationDefaults = getLocationDefaultList(); 338 mLocationDefaults = getLocationDefaultList();
349} 339}
350 340
351void KOPrefs::setCategoryDefaults() 341void KOPrefs::setCategoryDefaults()
352{ 342{
353 mCustomCategories.clear(); 343 mCustomCategories.clear();
354 mCustomCategories = getDefaultList(); 344 mCustomCategories = getDefaultList();
355 345
356 QStringList::Iterator it; 346 QStringList::Iterator it;
357 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 347 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
358 setCategoryColor(*it,mDefaultCategoryColor); 348 setCategoryColor(*it,mDefaultCategoryColor);
359 } 349 }
360} 350}
361QStringList KOPrefs::getLocationDefaultList() 351QStringList KOPrefs::getLocationDefaultList()
362{ 352{
363 QStringList retval ; 353 QStringList retval ;
364 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 354 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
365 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 355 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
366 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 356 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
367 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 357 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
368 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 358 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
369 359
370 retval.sort(); 360 retval.sort();
371 return retval; 361 return retval;
372} 362}
373QStringList KOPrefs::getDefaultList() 363QStringList KOPrefs::getDefaultList()
374{ 364{
375 QStringList retval ; 365 QStringList retval ;
376 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 366 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
377 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 367 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
378 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 368 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
379 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 369 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
380 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 370 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
381 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 371 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
382 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 372 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
383 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 373 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
384 retval.sort(); 374 retval.sort();
385 //qDebug("cat %s ", retval.join("-").latin1()); 375 //qDebug("cat %s ", retval.join("-").latin1());
386 return retval; 376 return retval;
387} 377}
388 378
389void KOPrefs::usrReadConfig() 379void KOPrefs::usrReadConfig()
390{ 380{
391 config()->setGroup("General"); 381 config()->setGroup("General");
392 382
393 //qDebug("KOPrefs::usrReadConfig() "); 383 //qDebug("KOPrefs::usrReadConfig() ");
394 mCustomCategories = config()->readListEntry("Custom Categories"); 384 mCustomCategories = config()->readListEntry("Custom Categories");
395 mOldLoadedLanguage = mOldLanguage ; 385 mOldLoadedLanguage = mOldLanguage ;
396 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 386 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
397 if (mLocationDefaults.isEmpty()) { 387 if (mLocationDefaults.isEmpty()) {
398 mLocationDefaults = getLocationDefaultList(); 388 mLocationDefaults = getLocationDefaultList();
399 } 389 }
400 390
401 if (mEventSummaryUser.isEmpty()) { 391 if (mEventSummaryUser.isEmpty()) {
402 mEventSummaryUser = getDefaultList() ; 392 mEventSummaryUser = getDefaultList() ;
403 } 393 }
404 if (mTodoSummaryUser.isEmpty()) { 394 if (mTodoSummaryUser.isEmpty()) {
405 mTodoSummaryUser = getDefaultList() ; 395 mTodoSummaryUser = getDefaultList() ;
406 } 396 }
407 397
408 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 398 if (mCustomCategories.isEmpty()) setCategoryDefaults();
409 399
410 config()->setGroup("Personal Settings"); 400 config()->setGroup("Personal Settings");
411 mName = config()->readEntry("user_name",""); 401 mName = config()->readEntry("user_name","");
412 mEmail = config()->readEntry("user_email",""); 402 mEmail = config()->readEntry("user_email","");
413 fillMailDefaults(); 403 fillMailDefaults();
414 404
415 config()->setGroup("Category Colors"); 405 config()->setGroup("Category Colors");
416 QStringList::Iterator it; 406 QStringList::Iterator it;
417 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 407 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
418 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 408 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
419 409
420 } 410 }
421 411
422 KPimPrefs::usrReadConfig(); 412 KPimPrefs::usrReadConfig();
423} 413}
424 414
425 415
426void KOPrefs::usrWriteConfig() 416void KOPrefs::usrWriteConfig()
427{ 417{
428 config()->setGroup("General"); 418 config()->setGroup("General");
429 config()->writeEntry("Custom Categories",mCustomCategories); 419 config()->writeEntry("Custom Categories",mCustomCategories);
430 420
431 config()->setGroup("Personal Settings"); 421 config()->setGroup("Personal Settings");
432 config()->writeEntry("user_name",mName); 422 config()->writeEntry("user_name",mName);
433 config()->writeEntry("user_email",mEmail); 423 config()->writeEntry("user_email",mEmail);
434 424
435 config()->setGroup("Category Colors"); 425 config()->setGroup("Category Colors");
436 QDictIterator<QColor> it(mCategoryColors); 426 QDictIterator<QColor> it(mCategoryColors);
437 while (it.current()) { 427 while (it.current()) {
438 config()->writeEntry(it.currentKey(),*(it.current())); 428 config()->writeEntry(it.currentKey(),*(it.current()));
439 ++it; 429 ++it;
440 } 430 }
441 431
442 432
443 KPimPrefs::usrWriteConfig(); 433 KPimPrefs::usrWriteConfig();
444} 434}
445 435
446void KOPrefs::setCategoryColor(QString cat,const QColor & color) 436void KOPrefs::setCategoryColor(QString cat,const QColor & color)
447{ 437{
448 mCategoryColors.replace(cat,new QColor(color)); 438 mCategoryColors.replace(cat,new QColor(color));
449} 439}
450 440
451QColor *KOPrefs::categoryColor(QString cat) 441QColor *KOPrefs::categoryColor(QString cat)
452{ 442{
453 QColor *color = 0; 443 QColor *color = 0;
454 444
455 if (!cat.isEmpty()) color = mCategoryColors[cat]; 445 if (!cat.isEmpty()) color = mCategoryColors[cat];
456 446
457 if (color) return color; 447 if (color) return color;
458 else return &mDefaultCategoryColor; 448 else return &mDefaultCategoryColor;
459} 449}
460 450
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index a9924ba..1024796 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -76,768 +76,770 @@ void
76KDateValidator::fixup( QString& ) const 76KDateValidator::fixup( QString& ) const
77{ 77{
78 78
79} 79}
80 80
81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) 81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f)
82 : QGridView(parent, name, f) 82 : QGridView(parent, name, f)
83{ 83{
84 setFont( KGlobalSettings::generalFont() ); 84 setFont( KGlobalSettings::generalFont() );
85 if(!date_.isValid()) 85 if(!date_.isValid())
86 { 86 {
87 date_=QDate::currentDate(); 87 date_=QDate::currentDate();
88 } 88 }
89 setFocusPolicy( QWidget::StrongFocus ); 89 setFocusPolicy( QWidget::StrongFocus );
90 setNumRows(7); // 6 weeks max + headline 90 setNumRows(7); // 6 weeks max + headline
91 setNumCols(7); // 7 days a week 91 setNumCols(7); // 7 days a week
92 setHScrollBarMode(AlwaysOff); 92 setHScrollBarMode(AlwaysOff);
93 setVScrollBarMode(AlwaysOff); 93 setVScrollBarMode(AlwaysOff);
94 viewport()->setBackgroundColor(QColor(220,245,255)); 94 viewport()->setBackgroundColor(QColor(220,245,255));
95#if 0 95#if 0
96 viewport()->setEraseColor(lightGray); 96 viewport()->setEraseColor(lightGray);
97#endif 97#endif
98 mMarkCurrent = false; 98 mMarkCurrent = false;
99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth 99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth
100} 100}
101 101
102void 102void
103KDateTable::paintCell(QPainter *painter, int row, int col) 103KDateTable::paintCell(QPainter *painter, int row, int col)
104{ 104{
105 QRect rect; 105 QRect rect;
106 QString text; 106 QString text;
107 QPen pen; 107 QPen pen;
108 int w=cellWidth(); 108 int w=cellWidth();
109 int h=cellHeight(); 109 int h=cellHeight();
110 int pos; 110 int pos;
111 QBrush brushBlue(blue); 111 QBrush brushBlue(blue);
112 QBrush brushLightblue(QColor(220,245,255)); 112 QBrush brushLightblue(QColor(220,245,255));
113 QFont _font=font(); 113 QFont _font=font();
114 // ----- 114 // -----
115 if(row==0) 115 if(row==0)
116 { // we are drawing the headline 116 { // we are drawing the headline
117 _font.setBold(true); 117 _font.setBold(true);
118 painter->setFont(_font); 118 painter->setFont(_font);
119 bool normalday = true; 119 bool normalday = true;
120 QString daystr; 120 QString daystr;
121 if (KGlobal::locale()->weekStartsMonday()) 121 if (KGlobal::locale()->weekStartsMonday())
122 { 122 {
123 daystr = KGlobal::locale()->weekDayName(col+1, true); 123 daystr = KGlobal::locale()->weekDayName(col+1, true);
124 if (col == 5 || col == 6) 124 if (col == 5 || col == 6)
125 normalday = false; 125 normalday = false;
126 } else { 126 } else {
127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); 127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true);
128 if (col == 0 || col == 6) 128 if (col == 0 || col == 6)
129 normalday = false; 129 normalday = false;
130 } 130 }
131 if (!normalday) 131 if (!normalday)
132 { 132 {
133 painter->setPen(QColor(220,245,255)); 133 painter->setPen(QColor(220,245,255));
134 painter->setBrush(brushLightblue); 134 painter->setBrush(brushLightblue);
135 painter->drawRect(0, 0, w, h); 135 painter->drawRect(0, 0, w, h);
136 painter->setPen(blue); 136 painter->setPen(blue);
137 } else { 137 } else {
138 painter->setPen(blue); 138 painter->setPen(blue);
139 painter->setBrush(brushBlue); 139 painter->setBrush(brushBlue);
140 painter->drawRect(0, 0, w, h); 140 painter->drawRect(0, 0, w, h);
141 painter->setPen(white); 141 painter->setPen(white);
142 } 142 }
143 painter->drawText(0, 0, w, h-1, AlignCenter, 143 painter->drawText(0, 0, w, h-1, AlignCenter,
144 daystr, -1, &rect); 144 daystr, -1, &rect);
145 painter->setPen(black); 145 painter->setPen(black);
146 painter->moveTo(0, h-1); 146 painter->moveTo(0, h-1);
147 painter->lineTo(w-1, h-1); 147 painter->lineTo(w-1, h-1);
148 // ----- draw the weekday: 148 // ----- draw the weekday:
149 } else { 149 } else {
150 painter->setFont(_font); 150 painter->setFont(_font);
151 pos=7*(row-1)+col; 151 pos=7*(row-1)+col;
152 if (KGlobal::locale()->weekStartsMonday()) 152 if (KGlobal::locale()->weekStartsMonday())
153 pos++; 153 pos++;
154 if(pos<firstday || (firstday+numdays<=pos)) 154 if(pos<firstday || (firstday+numdays<=pos))
155 { // we are either 155 { // we are either
156 // ° painting a day of the previous month or 156 // ° painting a day of the previous month or
157 // ° painting a day of the following month 157 // ° painting a day of the following month
158 if(pos<firstday) 158 if(pos<firstday)
159 { // previous month 159 { // previous month
160 text.setNum(numDaysPrevMonth+pos-firstday+1); 160 text.setNum(numDaysPrevMonth+pos-firstday+1);
161 } else { // following month 161 } else { // following month
162 text.setNum(pos-firstday-numdays+1); 162 text.setNum(pos-firstday-numdays+1);
163 } 163 }
164 painter->setPen(gray); 164 painter->setPen(gray);
165 } else { // paint a day of the current month 165 } else { // paint a day of the current month
166 text.setNum(pos-firstday+1); 166 text.setNum(pos-firstday+1);
167 painter->setPen(black); 167 painter->setPen(black);
168 } 168 }
169 169
170 pen=painter->pen(); 170 pen=painter->pen();
171 if(firstday+date.day()-1==pos) 171 if(firstday+date.day()-1==pos)
172 { 172 {
173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
174 painter->setPen(green); 174 painter->setPen(green);
175 else 175 else
176 painter->setPen(red); 176 painter->setPen(red);
177 if(hasFocus()) 177 if(hasFocus())
178 { 178 {
179 painter->setBrush(darkRed); 179 painter->setBrush(darkRed);
180 pen=white; 180 pen=white;
181 } else { 181 } else {
182 painter->setBrush(darkGray); 182 painter->setBrush(darkGray);
183 pen=white; 183 pen=white;
184 } 184 }
185 } else { 185 } else {
186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
187 { 187 {
188 painter->setPen(green); 188 painter->setPen(green);
189 painter->setBrush(darkGreen); 189 painter->setBrush(darkGreen);
190 pen=white; 190 pen=white;
191 } else { 191 } else {
192 painter->setBrush(QColor(220,245,255)); 192 painter->setBrush(QColor(220,245,255));
193 painter->setPen(QColor(220,245,255)); 193 painter->setPen(QColor(220,245,255));
194 } 194 }
195 } 195 }
196 painter->drawRect(0, 0, w, h); 196 painter->drawRect(0, 0, w, h);
197 painter->setPen(pen); 197 painter->setPen(pen);
198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); 198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect);
199 } 199 }
200 /* 200 /*
201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); 201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
202 if(rect.height()>maxCell.height()) { 202 if(rect.height()>maxCell.height()) {
203 maxCell.setHeight(rect.height()); 203 maxCell.setHeight(rect.height());
204 } 204 }
205 */ 205 */
206} 206}
207 207
208void 208void
209KDateTable::keyPressEvent( QKeyEvent *e ) 209KDateTable::keyPressEvent( QKeyEvent *e )
210{ 210{
211 /* 211 /*
212 // not working properly 212 // not working properly
213 if ( e->key() == Qt::Key_Prior ) { 213 if ( e->key() == Qt::Key_Prior ) {
214 if ( date.month() == 1 ) { 214 if ( date.month() == 1 ) {
215 KNotifyClient::beep(); 215 KNotifyClient::beep();
216 return; 216 return;
217 } 217 }
218 int day = date.day(); 218 int day = date.day();
219 if ( day > 27 ) 219 if ( day > 27 )
220 while ( !QDate::isValid( date.year(), date.month()-1, day ) ) 220 while ( !QDate::isValid( date.year(), date.month()-1, day ) )
221 day--; 221 day--;
222 setDate(QDate(date.year(), date.month()-1, day)); 222 setDate(QDate(date.year(), date.month()-1, day));
223 return; 223 return;
224 } 224 }
225 if ( e->key() == Qt::Key_Next ) { 225 if ( e->key() == Qt::Key_Next ) {
226 if ( date.month() == 12 ) { 226 if ( date.month() == 12 ) {
227 KNotifyClient::beep(); 227 KNotifyClient::beep();
228 return; 228 return;
229 } 229 }
230 int day = date.day(); 230 int day = date.day();
231 if ( day > 27 ) 231 if ( day > 27 )
232 while ( !QDate::isValid( date.year(), date.month()+1, day ) ) 232 while ( !QDate::isValid( date.year(), date.month()+1, day ) )
233 day--; 233 day--;
234 setDate(QDate(date.year(), date.month()+1, day)); 234 setDate(QDate(date.year(), date.month()+1, day));
235 return; 235 return;
236 } 236 }
237 */ 237 */
238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
239 239
240 int temp=firstday+date.day()-dayoff; 240 int temp=firstday+date.day()-dayoff;
241 int pos = temp; 241 int pos = temp;
242 bool irgnore = true; 242 bool irgnore = true;
243 if ( e->state() != Qt::ControlButton ) { 243 if ( e->state() != Qt::ControlButton ) {
244 if ( e->key() == Qt::Key_Up ) { 244 if ( e->key() == Qt::Key_Up ) {
245 pos -= 7; 245 pos -= 7;
246 irgnore = false; 246 irgnore = false;
247 } 247 }
248 if ( e->key() == Qt::Key_Down ) { 248 if ( e->key() == Qt::Key_Down ) {
249 pos += 7; 249 pos += 7;
250 irgnore = false; 250 irgnore = false;
251 } 251 }
252 if ( e->key() == Qt::Key_Left ) { 252 if ( e->key() == Qt::Key_Left ) {
253 pos--; 253 pos--;
254 irgnore = false; 254 irgnore = false;
255 } 255 }
256 if ( e->key() == Qt::Key_Right ) { 256 if ( e->key() == Qt::Key_Right ) {
257 pos++; 257 pos++;
258 irgnore = false; 258 irgnore = false;
259 } 259 }
260 } 260 }
261 if ( irgnore ) 261 if ( irgnore )
262 e->ignore(); 262 e->ignore();
263 263
264 if(pos+dayoff<=firstday) 264 if(pos+dayoff<=firstday)
265 { // this day is in the previous month 265 { // this day is in the previous month
266 KNotifyClient::beep(); 266 KNotifyClient::beep();
267 return; 267 return;
268 } 268 }
269 if(firstday+numdays<pos+dayoff) 269 if(firstday+numdays<pos+dayoff)
270 { // this date is in the next month 270 { // this date is in the next month
271 KNotifyClient::beep(i18n( "Month not long enough" )); 271 KNotifyClient::beep(i18n( "Month not long enough" ));
272 return; 272 return;
273 } 273 }
274 274
275 if ( pos == temp ) 275 if ( pos == temp )
276 return; 276 return;
277 277
278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); 278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff));
279 updateCell(temp/7+1, temp%7); // Update the previously selected cell 279 updateCell(temp/7+1, temp%7); // Update the previously selected cell
280 updateCell(pos/7+1, pos%7); // Update the selected cell 280 updateCell(pos/7+1, pos%7); // Update the selected cell
281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
282 282
283 283
284} 284}
285 285
286void 286void
287KDateTable::viewportResizeEvent(QResizeEvent * e) 287KDateTable::viewportResizeEvent(QResizeEvent * e)
288{ 288{
289 QGridView::viewportResizeEvent(e); 289 QGridView::viewportResizeEvent(e);
290 290
291 setCellWidth(viewport()->width()/7); 291 setCellWidth(viewport()->width()/7);
292 setCellHeight(viewport()->height()/7); 292 setCellHeight(viewport()->height()/7);
293} 293}
294 294
295void 295void
296KDateTable::setFontSize(int size) 296KDateTable::setFontSize(int size)
297{ 297{
298 int count; 298 int count;
299 QRect rect; 299 QRect rect;
300 // ----- store rectangles: 300 // ----- store rectangles:
301 fontsize=size; 301 fontsize=size;
302 QFont _font = font(); 302 QFont _font = font();
303 _font.setPointSize(fontsize); 303 _font.setPointSize(fontsize);
304 setFont( _font ); 304 setFont( _font );
305 _font.setBold( true ); 305 _font.setBold( true );
306 QFontMetrics metrics(_font); 306 QFontMetrics metrics(_font);
307 307
308 // ----- find largest day name: 308 // ----- find largest day name:
309 maxCell.setWidth(0); 309 maxCell.setWidth(0);
310 maxCell.setHeight(0); 310 maxCell.setHeight(0);
311 for(count=0; count<7; ++count) 311 for(count=0; count<7; ++count)
312 { 312 {
313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); 313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
314 maxCell.setWidth(QMAX(maxCell.width(), rect.width())); 314 maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
315 maxCell.setHeight(QMAX(maxCell.height(), rect.height())); 315 maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
316 } 316 }
317 // ----- compare with a real wide number and add some space: 317 // ----- compare with a real wide number and add some space:
318 rect=metrics.boundingRect(QString::fromLatin1("88")); 318 rect=metrics.boundingRect(QString::fromLatin1("88"));
319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); 319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
320#ifdef DESKTOP_VERSION 320#ifdef DESKTOP_VERSION
321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); 321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
322#else 322#else
323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); 323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
324#endif 324#endif
325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { 325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
326 maxCell.setHeight(maxCell.width() * 1000 / 1900 ); 326 maxCell.setHeight(maxCell.width() * 1000 / 1900 );
327 qDebug("setmax "); 327 qDebug("setmax ");
328 } 328 }
329} 329}
330 330
331void 331void
332KDateTable::contentsMousePressEvent(QMouseEvent *e) 332KDateTable::contentsMousePressEvent(QMouseEvent *e)
333{ 333{
334 if(e->type()!=QEvent::MouseButtonPress) 334 if(e->type()!=QEvent::MouseButtonPress)
335 { // the KDatePicker only reacts on mouse press events: 335 { // the KDatePicker only reacts on mouse press events:
336 return; 336 return;
337 } 337 }
338 if(!isEnabled()) 338 if(!isEnabled())
339 { 339 {
340 KNotifyClient::beep(); 340 KNotifyClient::beep();
341 return; 341 return;
342 } 342 }
343 343
344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
345 // ----- 345 // -----
346 int row, col, pos, temp; 346 int row, col, pos, temp;
347 QPoint mouseCoord; 347 QPoint mouseCoord;
348 // ----- 348 // -----
349 mouseCoord = e->pos(); 349 mouseCoord = e->pos();
350 row=rowAt(mouseCoord.y()); 350 row=rowAt(mouseCoord.y());
351 col=columnAt(mouseCoord.x()); 351 col=columnAt(mouseCoord.x());
352 if(row<0 || col<0) 352 if(row<0 || col<0)
353 { // the user clicked on the frame of the table 353 { // the user clicked on the frame of the table
354 return; 354 return;
355 } 355 }
356 pos=7*(row-1)+col+1; 356 pos=7*(row-1)+col+1;
357#if 0 357#if 0
358 if(pos+dayoff<=firstday) 358 if(pos+dayoff<=firstday)
359 { // this day is in the previous month 359 { // this day is in the previous month
360 KNotifyClient::beep(); 360 KNotifyClient::beep();
361 return; 361 return;
362 } 362 }
363 if(firstday+numdays<pos+dayoff) 363 if(firstday+numdays<pos+dayoff)
364 { // this date is in the next month 364 { // this date is in the next month
365 KNotifyClient::beep(); 365 KNotifyClient::beep();
366 return; 366 return;
367 } 367 }
368#endif 368#endif
369 temp=firstday+date.day()-dayoff-1; 369 temp=firstday+date.day()-dayoff-1;
370 QDate da = QDate(date.year(), date.month(),1); 370 QDate da = QDate(date.year(), date.month(),1);
371 setDate(da.addDays( pos-firstday+dayoff-1)); 371 setDate(da.addDays( pos-firstday+dayoff-1));
372 updateCell(temp/7+1, temp%7); // Update the previously selected cell 372 updateCell(temp/7+1, temp%7); // Update the previously selected cell
373 updateCell(row, col); // Update the selected cell 373 updateCell(row, col); // Update the selected cell
374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
375 emit(tableClicked()); 375 emit(tableClicked());
376} 376}
377 377
378bool 378bool
379KDateTable::setDate(const QDate& date_) 379KDateTable::setDate(const QDate& date_)
380{ 380{
381 bool changed=false; 381 bool changed=false;
382 QDate temp; 382 QDate temp;
383 mMarkCurrent = false; 383 mMarkCurrent = false;
384 // ----- 384 // -----
385 if(!date_.isValid()) 385 if(!date_.isValid())
386 { 386 {
387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; 387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
388 return false; 388 return false;
389 } 389 }
390 if(date!=date_) 390 if(date!=date_)
391 { 391 {
392 date=date_; 392 date=date_;
393 changed=true; 393 changed=true;
394 } 394 }
395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); 395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() );
396 temp.setYMD(date.year(), date.month(), 1); 396 temp.setYMD(date.year(), date.month(), 1);
397 firstday=temp.dayOfWeek(); 397 firstday=temp.dayOfWeek();
398 if(firstday==1) firstday=8; 398 if(firstday==1) firstday=8;
399 numdays=date.daysInMonth(); 399 numdays=date.daysInMonth();
400 if(date.month()==1) 400 if(date.month()==1)
401 { // set to december of previous year 401 { // set to december of previous year
402 temp.setYMD(date.year()-1, 12, 1); 402 temp.setYMD(date.year()-1, 12, 1);
403 } else { // set to previous month 403 } else { // set to previous month
404 temp.setYMD(date.year(), date.month()-1, 1); 404 temp.setYMD(date.year(), date.month()-1, 1);
405 } 405 }
406 numDaysPrevMonth=temp.daysInMonth(); 406 numDaysPrevMonth=temp.daysInMonth();
407 if(changed) 407 if(changed)
408 { 408 {
409 repaintContents(false); 409 repaintContents(false);
410 } 410 }
411 emit(dateChanged(date)); 411 emit(dateChanged(date));
412 return true; 412 return true;
413} 413}
414 414
415const QDate& 415const QDate&
416KDateTable::getDate() const 416KDateTable::getDate() const
417{ 417{
418 return date; 418 return date;
419} 419}
420 420
421void KDateTable::focusInEvent( QFocusEvent *e ) 421void KDateTable::focusInEvent( QFocusEvent *e )
422{ 422{
423 repaintContents(false); 423 repaintContents(false);
424 QGridView::focusInEvent( e ); 424 QGridView::focusInEvent( e );
425} 425}
426 426
427void KDateTable::focusOutEvent( QFocusEvent *e ) 427void KDateTable::focusOutEvent( QFocusEvent *e )
428{ 428{
429 repaintContents(false); 429 repaintContents(false);
430 QGridView::focusOutEvent( e ); 430 QGridView::focusOutEvent( e );
431} 431}
432 432
433QSize 433QSize
434KDateTable::sizeHint() const 434KDateTable::sizeHint() const
435{ 435{
436 if(maxCell.height()>0 && maxCell.width()>0) 436 if(maxCell.height()>0 && maxCell.width()>0)
437 { 437 {
438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), 438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
439 (maxCell.height()+4)*numRows()+2*frameWidth()); 439 (maxCell.height()+4)*numRows()+2*frameWidth());
440 } else { 440 } else {
441 return QSize(-1, -1); 441 return QSize(-1, -1);
442 } 442 }
443} 443}
444 444
445KDateInternalMonthPicker::KDateInternalMonthPicker 445KDateInternalMonthPicker::KDateInternalMonthPicker
446(QWidget* parent, const char* name) 446(QWidget* parent, const char* name)
447 : QGridView(parent, name), 447 : QGridView(parent, name),
448 result(0) // invalid 448 result(0) // invalid
449{ 449{
450 QRect rect; 450 QRect rect;
451 QFont font; 451 QFont font;
452 // ----- 452 // -----
453 activeCol = -1; 453 activeCol = -1;
454 activeRow = -1; 454 activeRow = -1;
455 font=KGlobalSettings::generalFont(); 455 font=KGlobalSettings::generalFont();
456 int fontsize = 10; 456 int fontsize = 10;
457 int add = 2; 457 int add = 2;
458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
459 add += 8; 459 add += 8;
460 if ( QApplication::desktop()->width() > 640 )
461 add += 4;
460 font.setPointSize(fontsize+add); 462 font.setPointSize(fontsize+add);
461 setFont(font); 463 setFont(font);
462 setHScrollBarMode(AlwaysOff); 464 setHScrollBarMode(AlwaysOff);
463 setVScrollBarMode(AlwaysOff); 465 setVScrollBarMode(AlwaysOff);
464 setFrameStyle(QFrame::NoFrame); 466 setFrameStyle(QFrame::NoFrame);
465 setNumRows(4); 467 setNumRows(4);
466 setNumCols(3); 468 setNumCols(3);
467 // enable to find drawing failures: 469 // enable to find drawing failures:
468 // setTableFlags(Tbl_clipCellPainting); 470 // setTableFlags(Tbl_clipCellPainting);
469#if 0 471#if 0
470 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 472 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
471#endif 473#endif
472 // ----- find the preferred size 474 // ----- find the preferred size
473 // (this is slow, possibly, but unfortunatly it is needed here): 475 // (this is slow, possibly, but unfortunatly it is needed here):
474 QFontMetrics metrics(font); 476 QFontMetrics metrics(font);
475 for(int i=1; i <= 12; ++i) 477 for(int i=1; i <= 12; ++i)
476 { 478 {
477 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); 479 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
478 if(max.width()<rect.width()) max.setWidth(rect.width()); 480 if(max.width()<rect.width()) max.setWidth(rect.width());
479 if(max.height()<rect.height()) max.setHeight(rect.height()); 481 if(max.height()<rect.height()) max.setHeight(rect.height());
480 } 482 }
481 483
482} 484}
483 485
484QSize 486QSize
485KDateInternalMonthPicker::sizeHint() const 487KDateInternalMonthPicker::sizeHint() const
486{ 488{
487 return QSize((max.width()+6)*numCols()+2*frameWidth(), 489 return QSize((max.width()+6)*numCols()+2*frameWidth(),
488 (max.height()+6)*numRows()+2*frameWidth()); 490 (max.height()+6)*numRows()+2*frameWidth());
489} 491}
490 492
491int 493int
492KDateInternalMonthPicker::getResult() const 494KDateInternalMonthPicker::getResult() const
493{ 495{
494 return result; 496 return result;
495} 497}
496 498
497void 499void
498KDateInternalMonthPicker::setupPainter(QPainter *p) 500KDateInternalMonthPicker::setupPainter(QPainter *p)
499{ 501{
500 p->setPen(black); 502 p->setPen(black);
501} 503}
502 504
503void 505void
504KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) 506KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*)
505{ 507{
506 setCellWidth(width()/3); 508 setCellWidth(width()/3);
507 setCellHeight(height()/4); 509 setCellHeight(height()/4);
508} 510}
509 511
510void 512void
511KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) 513KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
512{ 514{
513 int index; 515 int index;
514 QString text; 516 QString text;
515 // ----- find the number of the cell: 517 // ----- find the number of the cell:
516 index=3*row+col+1; 518 index=3*row+col+1;
517 text=KGlobal::locale()->monthName(index, false); 519 text=KGlobal::locale()->monthName(index, false);
518 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 520 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
519 if ( activeCol == col && activeRow == row ) 521 if ( activeCol == col && activeRow == row )
520 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 522 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
521} 523}
522 524
523void 525void
524KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) 526KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
525{ 527{
526 if(!isEnabled() || e->button() != LeftButton) 528 if(!isEnabled() || e->button() != LeftButton)
527 { 529 {
528 KNotifyClient::beep(); 530 KNotifyClient::beep();
529 return; 531 return;
530 } 532 }
531 // ----- 533 // -----
532 int row, col; 534 int row, col;
533 QPoint mouseCoord; 535 QPoint mouseCoord;
534 // ----- 536 // -----
535 mouseCoord = e->pos(); 537 mouseCoord = e->pos();
536 row=rowAt(mouseCoord.y()); 538 row=rowAt(mouseCoord.y());
537 col=columnAt(mouseCoord.x()); 539 col=columnAt(mouseCoord.x());
538 540
539 if(row<0 || col<0) 541 if(row<0 || col<0)
540 { // the user clicked on the frame of the table 542 { // the user clicked on the frame of the table
541 activeCol = -1; 543 activeCol = -1;
542 activeRow = -1; 544 activeRow = -1;
543 } else { 545 } else {
544 activeCol = col; 546 activeCol = col;
545 activeRow = row; 547 activeRow = row;
546 updateCell( row, col /*, false */ ); 548 updateCell( row, col /*, false */ );
547 } 549 }
548} 550}
549 551
550void 552void
551KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) 553KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e)
552{ 554{
553 if (e->state() & LeftButton) 555 if (e->state() & LeftButton)
554 { 556 {
555 int row, col; 557 int row, col;
556 QPoint mouseCoord; 558 QPoint mouseCoord;
557 // ----- 559 // -----
558 mouseCoord = e->pos(); 560 mouseCoord = e->pos();
559 row=rowAt(mouseCoord.y()); 561 row=rowAt(mouseCoord.y());
560 col=columnAt(mouseCoord.x()); 562 col=columnAt(mouseCoord.x());
561 int tmpRow = -1, tmpCol = -1; 563 int tmpRow = -1, tmpCol = -1;
562 if(row<0 || col<0) 564 if(row<0 || col<0)
563 { // the user clicked on the frame of the table 565 { // the user clicked on the frame of the table
564 if ( activeCol > -1 ) 566 if ( activeCol > -1 )
565 { 567 {
566 tmpRow = activeRow; 568 tmpRow = activeRow;
567 tmpCol = activeCol; 569 tmpCol = activeCol;
568 } 570 }
569 activeCol = -1; 571 activeCol = -1;
570 activeRow = -1; 572 activeRow = -1;
571 } else { 573 } else {
572 bool differentCell = (activeRow != row || activeCol != col); 574 bool differentCell = (activeRow != row || activeCol != col);
573 if ( activeCol > -1 && differentCell) 575 if ( activeCol > -1 && differentCell)
574 { 576 {
575 tmpRow = activeRow; 577 tmpRow = activeRow;
576 tmpCol = activeCol; 578 tmpCol = activeCol;
577 } 579 }
578 if ( differentCell) 580 if ( differentCell)
579 { 581 {
580 activeRow = row; 582 activeRow = row;
581 activeCol = col; 583 activeCol = col;
582 updateCell( row, col /*, false */ ); // mark the new active cell 584 updateCell( row, col /*, false */ ); // mark the new active cell
583 } 585 }
584 } 586 }
585 if ( tmpRow > -1 ) // repaint the former active cell 587 if ( tmpRow > -1 ) // repaint the former active cell
586 updateCell( tmpRow, tmpCol /*, true */ ); 588 updateCell( tmpRow, tmpCol /*, true */ );
587 } 589 }
588} 590}
589 591
590void 592void
591KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) 593KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e)
592{ 594{
593 if(!isEnabled()) 595 if(!isEnabled())
594 { 596 {
595 return; 597 return;
596 } 598 }
597 // ----- 599 // -----
598 int row, col, pos; 600 int row, col, pos;
599 QPoint mouseCoord; 601 QPoint mouseCoord;
600 // ----- 602 // -----
601 mouseCoord = e->pos(); 603 mouseCoord = e->pos();
602 row=rowAt(mouseCoord.y()); 604 row=rowAt(mouseCoord.y());
603 col=columnAt(mouseCoord.x()); 605 col=columnAt(mouseCoord.x());
604 if(row<0 || col<0) 606 if(row<0 || col<0)
605 { // the user clicked on the frame of the table 607 { // the user clicked on the frame of the table
606 emit(closeMe(0)); 608 emit(closeMe(0));
607 } 609 }
608 pos=3*row+col+1; 610 pos=3*row+col+1;
609 result=pos; 611 result=pos;
610 emit(closeMe(1)); 612 emit(closeMe(1));
611} 613}
612 614
613 615
614 616
615KDateInternalYearSelector::KDateInternalYearSelector 617KDateInternalYearSelector::KDateInternalYearSelector
616(int fontsize, QWidget* parent, const char* name) 618(int fontsize, QWidget* parent, const char* name)
617 : QLineEdit(parent, name), 619 : QLineEdit(parent, name),
618 val(new QIntValidator(this)), 620 val(new QIntValidator(this)),
619 result(0) 621 result(0)
620{ 622{
621 QFont font; 623 QFont font;
622 // ----- 624 // -----
623 font=KGlobalSettings::generalFont(); 625 font=KGlobalSettings::generalFont();
624 font.setPointSize(fontsize); 626 font.setPointSize(fontsize);
625 setFont(font); 627 setFont(font);
626#if 0 628#if 0
627 setFrameStyle(QFrame::NoFrame); 629 setFrameStyle(QFrame::NoFrame);
628#endif 630#endif
629 // we have to respect the limits of QDate here, I fear: 631 // we have to respect the limits of QDate here, I fear:
630 val->setRange(0, 8000); 632 val->setRange(0, 8000);
631 setValidator(val); 633 setValidator(val);
632 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); 634 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot()));
633} 635}
634 636
635void 637void
636KDateInternalYearSelector::yearEnteredSlot() 638KDateInternalYearSelector::yearEnteredSlot()
637{ 639{
638 bool ok; 640 bool ok;
639 int year; 641 int year;
640 QDate date; 642 QDate date;
641 // ----- check if this is a valid year: 643 // ----- check if this is a valid year:
642 year=text().toInt(&ok); 644 year=text().toInt(&ok);
643 if(!ok) 645 if(!ok)
644 { 646 {
645 KNotifyClient::beep(); 647 KNotifyClient::beep();
646 return; 648 return;
647 } 649 }
648 date.setYMD(year, 1, 1); 650 date.setYMD(year, 1, 1);
649 if(!date.isValid()) 651 if(!date.isValid())
650 { 652 {
651 KNotifyClient::beep(); 653 KNotifyClient::beep();
652 return; 654 return;
653 } 655 }
654 result=year; 656 result=year;
655 emit(closeMe(1)); 657 emit(closeMe(1));
656} 658}
657 659
658int 660int
659KDateInternalYearSelector::getYear() 661KDateInternalYearSelector::getYear()
660{ 662{
661 return result; 663 return result;
662} 664}
663 665
664void 666void
665KDateInternalYearSelector::setYear(int year) 667KDateInternalYearSelector::setYear(int year)
666{ 668{
667 QString temp; 669 QString temp;
668 // ----- 670 // -----
669 temp.setNum(year); 671 temp.setNum(year);
670 setText(temp); 672 setText(temp);
671} 673}
672 674
673KPopupFrame::KPopupFrame(QWidget* parent, const char* name) 675KPopupFrame::KPopupFrame(QWidget* parent, const char* name)
674 : QFrame(parent, name, WType_Popup), 676 : QFrame(parent, name, WType_Popup),
675 result(0), // rejected 677 result(0), // rejected
676 main(0) 678 main(0)
677{ 679{
678 setFrameStyle(QFrame::Box|QFrame::Raised); 680 setFrameStyle(QFrame::Box|QFrame::Raised);
679 setMidLineWidth(2); 681 setMidLineWidth(2);
680} 682}
681 683
682void 684void
683KPopupFrame::keyPressEvent(QKeyEvent* e) 685KPopupFrame::keyPressEvent(QKeyEvent* e)
684{ 686{
685 if(e->key()==Key_Escape) 687 if(e->key()==Key_Escape)
686 { 688 {
687 result=0; // rejected 689 result=0; // rejected
688 qApp->exit_loop(); 690 qApp->exit_loop();
689 } 691 }
690} 692}
691 693
692void 694void
693KPopupFrame::close(int r) 695KPopupFrame::close(int r)
694{ 696{
695 result=r; 697 result=r;
696 qApp->exit_loop(); 698 qApp->exit_loop();
697} 699}
698 700
699void 701void
700KPopupFrame::setMainWidget(QWidget* m) 702KPopupFrame::setMainWidget(QWidget* m)
701{ 703{
702 main=m; 704 main=m;
703 if(main!=0) 705 if(main!=0)
704 { 706 {
705 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); 707 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth());
706 } 708 }
707} 709}
708 710
709void 711void
710KPopupFrame::resizeEvent(QResizeEvent*) 712KPopupFrame::resizeEvent(QResizeEvent*)
711{ 713{
712 if(main!=0) 714 if(main!=0)
713 { 715 {
714 main->setGeometry(frameWidth(), frameWidth(), 716 main->setGeometry(frameWidth(), frameWidth(),
715 width()-2*frameWidth(), height()-2*frameWidth()); 717 width()-2*frameWidth(), height()-2*frameWidth());
716 } 718 }
717} 719}
718 720
719void 721void
720KPopupFrame::popup(const QPoint &pos) 722KPopupFrame::popup(const QPoint &pos)
721{ 723{
722 // Make sure the whole popup is visible. 724 // Make sure the whole popup is visible.
723 QRect d = QApplication::desktop()->frameGeometry(); 725 QRect d = QApplication::desktop()->frameGeometry();
724 int x = pos.x(); 726 int x = pos.x();
725 int y = pos.y(); 727 int y = pos.y();
726 int w = width(); 728 int w = width();
727 int h = height(); 729 int h = height();
728 if (x+w > d.x()+d.width()) 730 if (x+w > d.x()+d.width())
729 x = d.width() - w; 731 x = d.width() - w;
730 if (y+h > d.y()+d.height()) 732 if (y+h > d.y()+d.height())
731 y = d.height() - h; 733 y = d.height() - h;
732 if (x < d.x()) 734 if (x < d.x())
733 x = 0; 735 x = 0;
734 if (y < d.y()) 736 if (y < d.y())
735 y = 0; 737 y = 0;
736 738
737 // Pop the thingy up. 739 // Pop the thingy up.
738 move(x, y); 740 move(x, y);
739 show(); 741 show();
740} 742}
741 743
742int 744int
743KPopupFrame::exec(QPoint pos) 745KPopupFrame::exec(QPoint pos)
744{ 746{
745 popup(pos); 747 popup(pos);
746 repaint(); 748 repaint();
747 qApp->enter_loop(); 749 qApp->enter_loop();
748 hide(); 750 hide();
749 return result; 751 return result;
750} 752}
751 753
752int 754int
753KPopupFrame::exec(int x, int y) 755KPopupFrame::exec(int x, int y)
754{ 756{
755 return exec(QPoint(x, y)); 757 return exec(QPoint(x, y));
756} 758}
757 759
758void KPopupFrame::virtual_hook( int, void* ) 760void KPopupFrame::virtual_hook( int, void* )
759{ /*BASE::virtual_hook( id, data );*/ } 761{ /*BASE::virtual_hook( id, data );*/ }
760 762
761void KDateTable::virtual_hook( int, void* ) 763void KDateTable::virtual_hook( int, void* )
762{ /*BASE::virtual_hook( id, data );*/ } 764{ /*BASE::virtual_hook( id, data );*/ }
763 765
764//#include "kdatetbl.moc" 766//#include "kdatetbl.moc"
765 767
766 768
767KDateInternalWeekPicker::KDateInternalWeekPicker 769KDateInternalWeekPicker::KDateInternalWeekPicker
768(QWidget* parent, const char* name) 770(QWidget* parent, const char* name)
769 : QGridView(parent, name), 771 : QGridView(parent, name),
770 result(0) // invalid 772 result(0) // invalid
771{ 773{
772 QRect rect; 774 QRect rect;
773 QFont font; 775 QFont font;
774 // ----- 776 // -----
775 activeCol = -1; 777 activeCol = -1;
776 activeRow = -1; 778 activeRow = -1;
777 font=KGlobalSettings::generalFont(); 779 font=KGlobalSettings::generalFont();
778 int fontsize = 10; 780 int fontsize = 10;
779 int add = 2; 781 int add = 2;
780 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 782 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
781 add += 6; 783 add += 6;
782 font.setPointSize(fontsize+add); 784 font.setPointSize(fontsize+add);
783 setFont(font); 785 setFont(font);
784 setHScrollBarMode(AlwaysOff); 786 setHScrollBarMode(AlwaysOff);
785 setVScrollBarMode(AlwaysOff); 787 setVScrollBarMode(AlwaysOff);
786 setFrameStyle(QFrame::NoFrame); 788 setFrameStyle(QFrame::NoFrame);
787 setNumRows(13); 789 setNumRows(13);
788 setNumCols(4); 790 setNumCols(4);
789 // enable to find drawing failures: 791 // enable to find drawing failures:
790 // setTableFlags(Tbl_clipCellPainting); 792 // setTableFlags(Tbl_clipCellPainting);
791#if 0 793#if 0
792 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 794 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
793#endif 795#endif
794 // ----- find the preferred size 796 // ----- find the preferred size
795 // (this is slow, possibly, but unfortunatly it is needed here): 797 // (this is slow, possibly, but unfortunatly it is needed here):
796 QFontMetrics metrics(font); 798 QFontMetrics metrics(font);
797 for(int i=1; i <= 52; ++i) 799 for(int i=1; i <= 52; ++i)
798 { 800 {
799 rect=metrics.boundingRect(QString::number( i )); 801 rect=metrics.boundingRect(QString::number( i ));
800 if(max.width()<rect.width()) max.setWidth(rect.width()); 802 if(max.width()<rect.width()) max.setWidth(rect.width());
801 if(max.height()<rect.height()) max.setHeight(rect.height()); 803 if(max.height()<rect.height()) max.setHeight(rect.height());
802 } 804 }
803 if ( QApplication::desktop()->width() > 640 ) { 805 if ( QApplication::desktop()->width() > 640 ) {
804 806
805 max.setWidth(max.width()+6); 807 max.setWidth(max.width()+6);
806 max.setHeight(max.height()+8); 808 max.setHeight(max.height()+8);
807 } 809 }
808} 810}
809 811
810QSize 812QSize
811KDateInternalWeekPicker::sizeHint() const 813KDateInternalWeekPicker::sizeHint() const
812{ 814{
813 return QSize((max.width()+6)*numCols()+2*frameWidth(), 815 return QSize((max.width()+6)*numCols()+2*frameWidth(),
814 (max.height()+6)*numRows()+2*frameWidth()); 816 (max.height()+6)*numRows()+2*frameWidth());
815} 817}
816 818
817int 819int
818KDateInternalWeekPicker::getResult() const 820KDateInternalWeekPicker::getResult() const
819{ 821{
820 return result; 822 return result;
821} 823}
822 824
823void 825void
824KDateInternalWeekPicker::setupPainter(QPainter *p) 826KDateInternalWeekPicker::setupPainter(QPainter *p)
825{ 827{
826 p->setPen(black); 828 p->setPen(black);
827} 829}
828 830
829void 831void
830KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) 832KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
831{ 833{
832 setCellWidth(width()/4); 834 setCellWidth(width()/4);
833 setCellHeight(height()/13); 835 setCellHeight(height()/13);
834} 836}
835 837
836void 838void
837KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) 839KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
838{ 840{
839 int index; 841 int index;
840 QString text; 842 QString text;
841 // ----- find the number of the cell: 843 // ----- find the number of the cell:
842 index=4*row+col+1; 844 index=4*row+col+1;
843 text=QString::number( index ); 845 text=QString::number( index );