summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-18 22:08:36 (UTC)
committer zautrix <zautrix>2004-10-18 22:08:36 (UTC)
commit9fd09e806dfe3df5abdf70991b6ec170fed51078 (patch) (unidiff)
treedc708d0baa4ddb5773531750bcca6000fc7297f4
parentc051fdcc1e7abac87f74430a7fcf3e7099f3b062 (diff)
downloadkdepimpi-9fd09e806dfe3df5abdf70991b6ec170fed51078.zip
kdepimpi-9fd09e806dfe3df5abdf70991b6ec170fed51078.tar.gz
kdepimpi-9fd09e806dfe3df5abdf70991b6ec170fed51078.tar.bz2
added 30min plus to timezone setting
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp5
-rw-r--r--libkdepim/kpimglobalprefs.cpp3
-rw-r--r--libkdepim/kpimglobalprefs.h1
-rw-r--r--microkde/kdecore/klocale.cpp4
-rw-r--r--microkde/kdecore/klocale.h2
5 files changed, 12 insertions, 3 deletions
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
index 1eef150..332f975 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -1,776 +1,781 @@
1/* 1/*
2 This file is part of KdePim/Pi. 2 This file is part of KdePim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qbuttongroup.h> 37#include <qbuttongroup.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qregexp.h> 39#include <qregexp.h>
40 40
41#include <kdialog.h> 41#include <kdialog.h>
42#include <klocale.h> 42#include <klocale.h>
43#include <kdateedit.h> 43#include <kdateedit.h>
44#include <kglobal.h> 44#include <kglobal.h>
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47/*US 47/*US
48#include <qcheckbox.h> 48#include <qcheckbox.h>
49#include <qframe.h> 49#include <qframe.h>
50#include <qpushbutton.h> 50#include <qpushbutton.h>
51#include <qcombobox.h> 51#include <qcombobox.h>
52#include <qlineedit.h> 52#include <qlineedit.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qfile.h> 54#include <qfile.h>
55 55
56#include <kconfig.h> 56#include <kconfig.h>
57#include <kdebug.h> 57#include <kdebug.h>
58#include <kdialog.h> 58#include <kdialog.h>
59#include <klistview.h> 59#include <klistview.h>
60#include <klocale.h> 60#include <klocale.h>
61#include <kglobal.h> 61#include <kglobal.h>
62#include <kmessagebox.h> 62#include <kmessagebox.h>
63#include <kstandarddirs.h> 63#include <kstandarddirs.h>
64 64
65#ifndef KAB_EMBEDDED 65#ifndef KAB_EMBEDDED
66#include <ktrader.h> 66#include <ktrader.h>
67#else // KAB_EMBEDDED 67#else // KAB_EMBEDDED
68#include <mergewidget.h> 68#include <mergewidget.h>
69#include <distributionlistwidget.h> 69#include <distributionlistwidget.h>
70#endif // KAB_EMBEDDED 70#endif // KAB_EMBEDDED
71 71
72#include "addresseewidget.h" 72#include "addresseewidget.h"
73#include "extensionconfigdialog.h" 73#include "extensionconfigdialog.h"
74#include "extensionwidget.h" 74#include "extensionwidget.h"
75*/ 75*/
76 76
77#include "qapplication.h" 77#include "qapplication.h"
78 78
79#include "kpimglobalprefs.h" 79#include "kpimglobalprefs.h"
80 80
81#include "kdepimconfigwidget.h" 81#include "kdepimconfigwidget.h"
82 82
83 83
84KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name ) 84KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name )
85 : KPrefsWidget(prefs, parent, name ) 85 : KPrefsWidget(prefs, parent, name )
86{ 86{
87 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); 87 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email"));
88 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); 88 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone"));
89 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); 89 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS"));
90 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); 90 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax"));
91 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); 91 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager"));
92 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); 92 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP"));
93 93
94 94
95 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 95 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
96 KDialog::spacingHint() ); 96 KDialog::spacingHint() );
97 97
98 tabWidget = new QTabWidget( this ); 98 tabWidget = new QTabWidget( this );
99 topLayout->addWidget( tabWidget ); 99 topLayout->addWidget( tabWidget );
100 100
101 101
102 setupLocaleTab(); 102 setupLocaleTab();
103 setupLocaleDateTab(); 103 setupLocaleDateTab();
104 setupTimeZoneTab(); 104 setupTimeZoneTab();
105 setupExternalAppTab(); 105 setupExternalAppTab();
106 106
107} 107}
108void KDEPIMConfigWidget::showTimeZoneTab() 108void KDEPIMConfigWidget::showTimeZoneTab()
109{ 109{
110 tabWidget->setCurrentPage ( 2 ) ; 110 tabWidget->setCurrentPage ( 2 ) ;
111} 111}
112void KDEPIMConfigWidget::setupExternalAppTab() 112void KDEPIMConfigWidget::setupExternalAppTab()
113{ 113{
114 QWidget *externalAppsPage = new QWidget( this ); 114 QWidget *externalAppsPage = new QWidget( this );
115 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), 115 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(),
116 KDialog::spacingHintSmall() ); 116 KDialog::spacingHintSmall() );
117 117
118 mExternalApps = new QComboBox( externalAppsPage ); 118 mExternalApps = new QComboBox( externalAppsPage );
119 119
120 QMap<ExternalAppHandler::Types, QString>::Iterator it; 120 QMap<ExternalAppHandler::Types, QString>::Iterator it;
121 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) 121 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it )
122 mExternalApps->insertItem( it.data(), it.key() ); 122 mExternalApps->insertItem( it.data(), it.key() );
123 123
124 layout->addWidget( mExternalApps ); 124 layout->addWidget( mExternalApps );
125 125
126 connect( mExternalApps, SIGNAL( activated( int ) ), 126 connect( mExternalApps, SIGNAL( activated( int ) ),
127 this, SLOT (externalapp_changed( int ) ) ); 127 this, SLOT (externalapp_changed( int ) ) );
128 128
129 129
130 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); 130 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage );
131 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); 131 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" );
132 132
133 133
134 mClient = new QComboBox( mExternalAppGroupBox ); 134 mClient = new QComboBox( mExternalAppGroupBox );
135 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); 135 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 );
136 136
137 connect( mClient, SIGNAL( activated( int ) ), 137 connect( mClient, SIGNAL( activated( int ) ),
138 this, SLOT (client_changed( int ) ) ); 138 this, SLOT (client_changed( int ) ) );
139 139
140 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); 140 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox);
141 boxLayout->addWidget( lab, 1, 0 ); 141 boxLayout->addWidget( lab, 1, 0 );
142 mChannel = new QLineEdit(mExternalAppGroupBox); 142 mChannel = new QLineEdit(mExternalAppGroupBox);
143 mChannel->setReadOnly(true); 143 mChannel->setReadOnly(true);
144 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 ); 144 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 );
145 145
146 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox); 146 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox);
147 boxLayout->addWidget( lab, 3, 0 ); 147 boxLayout->addWidget( lab, 3, 0 );
148 mMessage = new QLineEdit(mExternalAppGroupBox); 148 mMessage = new QLineEdit(mExternalAppGroupBox);
149 mMessage->setReadOnly(true); 149 mMessage->setReadOnly(true);
150 boxLayout->addWidget( mMessage , 4, 0); 150 boxLayout->addWidget( mMessage , 4, 0);
151 151
152 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox); 152 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox);
153 boxLayout->addWidget( lab, 3, 1 ); 153 boxLayout->addWidget( lab, 3, 1 );
154 mParameters = new QLineEdit(mExternalAppGroupBox); 154 mParameters = new QLineEdit(mExternalAppGroupBox);
155 mParameters->setReadOnly(true); 155 mParameters->setReadOnly(true);
156 boxLayout->addWidget( mParameters, 4, 1 ); 156 boxLayout->addWidget( mParameters, 4, 1 );
157 157
158 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox); 158 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox);
159 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 ); 159 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 );
160 160
161 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox); 161 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox);
162 boxLayout->addWidget( lab, 6, 0 ); 162 boxLayout->addWidget( lab, 6, 0 );
163 mMessage2 = new QLineEdit(mExternalAppGroupBox); 163 mMessage2 = new QLineEdit(mExternalAppGroupBox);
164 mMessage2->setReadOnly(true); 164 mMessage2->setReadOnly(true);
165 boxLayout->addWidget( mMessage2 , 7, 0); 165 boxLayout->addWidget( mMessage2 , 7, 0);
166 166
167 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox); 167 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox);
168 boxLayout->addWidget( lab, 6, 1 ); 168 boxLayout->addWidget( lab, 6, 1 );
169 mParameters2 = new QLineEdit(mExternalAppGroupBox); 169 mParameters2 = new QLineEdit(mExternalAppGroupBox);
170 mParameters2->setReadOnly(true); 170 mParameters2->setReadOnly(true);
171 boxLayout->addWidget( mParameters2, 7, 1 ); 171 boxLayout->addWidget( mParameters2, 7, 1 );
172 172
173 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox); 173 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox);
174 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 ); 174 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 );
175 175
176 176
177 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 177 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
178 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 178 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
179 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 179 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
180 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 180 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
181 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 181 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
182 182
183 183
184 layout->addWidget( mExternalAppGroupBox ); 184 layout->addWidget( mExternalAppGroupBox );
185 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); 185 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) );
186 186
187} 187}
188 188
189 189
190void KDEPIMConfigWidget::setupLocaleDateTab() 190void KDEPIMConfigWidget::setupLocaleDateTab()
191{ 191{
192 QWidget *topFrame = new QWidget( this ); 192 QWidget *topFrame = new QWidget( this );
193 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2); 193 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2);
194 194
195 topLayout->setSpacing(KDialog::spacingHint()); 195 topLayout->setSpacing(KDialog::spacingHint());
196 topLayout->setMargin(KDialog::marginHint()); 196 topLayout->setMargin(KDialog::marginHint());
197 int iii = 0; 197 int iii = 0;
198 198
199 199
200 KPrefsWidRadios *syncPrefsGroup = 200 KPrefsWidRadios *syncPrefsGroup =
201 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame); 201 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame);
202 QString format; 202 QString format;
203 if ( QApplication::desktop()->width() < 480 ) 203 if ( QApplication::desktop()->width() < 480 )
204 format = "(%d.%m.%Y)"; 204 format = "(%d.%m.%Y)";
205 else 205 else
206 format = "(%d.%m.%Y|%A %d %B %Y)"; 206 format = "(%d.%m.%Y|%A %d %B %Y)";
207 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 207 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
208 if ( QApplication::desktop()->width() < 480 ) 208 if ( QApplication::desktop()->width() < 480 )
209 format = "(%m.%d.%Y)"; 209 format = "(%m.%d.%Y)";
210 else 210 else
211 format = "(%m.%d.%Y|%A %B %d %Y)"; 211 format = "(%m.%d.%Y|%A %B %d %Y)";
212 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 212 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
213 if ( QApplication::desktop()->width() < 480 ) 213 if ( QApplication::desktop()->width() < 480 )
214 format = "(%Y-%m-%d)"; 214 format = "(%Y-%m-%d)";
215 else 215 else
216 format = "(%Y-%m-%d|%A %Y %B %d)"; 216 format = "(%Y-%m-%d|%A %Y %B %d)";
217 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 217 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
218 syncPrefsGroup->addRadio(i18n("User defined")); 218 syncPrefsGroup->addRadio(i18n("User defined"));
219 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 219 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
220 ++iii; 220 ++iii;
221 ++iii; 221 ++iii;
222 QLabel * lab; 222 QLabel * lab;
223 mUserDateFormatLong = new QLineEdit(topFrame); 223 mUserDateFormatLong = new QLineEdit(topFrame);
224 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 224 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
225 topLayout->addWidget(lab ,iii,0); 225 topLayout->addWidget(lab ,iii,0);
226 topLayout->addWidget(mUserDateFormatLong,iii,1); 226 topLayout->addWidget(mUserDateFormatLong,iii,1);
227 ++iii; 227 ++iii;
228 mUserDateFormatShort = new QLineEdit(topFrame); 228 mUserDateFormatShort = new QLineEdit(topFrame);
229 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 229 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
230 topLayout->addWidget(lab ,iii,0); 230 topLayout->addWidget(lab ,iii,0);
231 topLayout->addWidget(mUserDateFormatShort,iii,1); 231 topLayout->addWidget(mUserDateFormatShort,iii,1);
232 ++iii; 232 ++iii;
233 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 233 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
234 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 234 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
235 ++iii; 235 ++iii;
236 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 236 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
237 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 237 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
238 ++iii; 238 ++iii;
239 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 239 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
240 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 240 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
241 ++iii; 241 ++iii;
242 242
243 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 243 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
244 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 244 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
245 245
246 246
247 tabWidget->addTab( topFrame, i18n( "Date Format" ) ); 247 tabWidget->addTab( topFrame, i18n( "Date Format" ) );
248} 248}
249 249
250void KDEPIMConfigWidget::setupLocaleTab() 250void KDEPIMConfigWidget::setupLocaleTab()
251{ 251{
252 252
253 QWidget *topFrame = new QWidget( this ); 253 QWidget *topFrame = new QWidget( this );
254 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 254 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
255 255
256 topLayout->setSpacing(KDialog::spacingHint()); 256 topLayout->setSpacing(KDialog::spacingHint());
257 topLayout->setMargin(KDialog::marginHint()); 257 topLayout->setMargin(KDialog::marginHint());
258 int iii = 0; 258 int iii = 0;
259 KPrefsWidRadios *syncPrefsGroup = 259 KPrefsWidRadios *syncPrefsGroup =
260 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame); 260 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame);
261 syncPrefsGroup->addRadio(i18n("English")); 261 syncPrefsGroup->addRadio(i18n("English"));
262 syncPrefsGroup->addRadio(i18n("German")); 262 syncPrefsGroup->addRadio(i18n("German"));
263 syncPrefsGroup->addRadio(i18n("French")); 263 syncPrefsGroup->addRadio(i18n("French"));
264 syncPrefsGroup->addRadio(i18n("Italian")); 264 syncPrefsGroup->addRadio(i18n("Italian"));
265 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 265 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
266 if ( QApplication::desktop()->width() < 300 ) 266 if ( QApplication::desktop()->width() < 300 )
267 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 267 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
268 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 268 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
269 ++iii; 269 ++iii;
270 270
271 syncPrefsGroup = 271 syncPrefsGroup =
272 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame); 272 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame);
273 if ( QApplication::desktop()->width() > 300 ) 273 if ( QApplication::desktop()->width() > 300 )
274 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 274 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
275 syncPrefsGroup->addRadio(i18n("24:00")); 275 syncPrefsGroup->addRadio(i18n("24:00"));
276 syncPrefsGroup->addRadio(i18n("12:00am")); 276 syncPrefsGroup->addRadio(i18n("12:00am"));
277 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 277 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
278 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 278 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
279 ++iii; 279 ++iii;
280 280
281 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"), 281 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"),
282 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame); 282 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame);
283 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 283 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
284 ++iii; 284 ++iii;
285 285
286 286
287 tabWidget->addTab( topFrame, i18n( "Locale" ) ); 287 tabWidget->addTab( topFrame, i18n( "Locale" ) );
288 288
289} 289}
290 290
291 291
292void KDEPIMConfigWidget::setupTimeZoneTab() 292void KDEPIMConfigWidget::setupTimeZoneTab()
293{ 293{
294 QWidget *topFrame = new QWidget( this ); 294 QWidget *topFrame = new QWidget( this );
295 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 2); 295 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 2);
296 topLayout->setSpacing(KDialog::spacingHint()); 296 topLayout->setSpacing(KDialog::spacingHint());
297 topLayout->setMargin(KDialog::marginHint()); 297 topLayout->setMargin(KDialog::marginHint());
298 298
299 QHBox *timeZoneBox = new QHBox( topFrame ); 299 QHBox *timeZoneBox = new QHBox( topFrame );
300 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); 300 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
301 301
302 new QLabel( i18n("Timezone:"), timeZoneBox ); 302 new QLabel( i18n("Timezone:"), timeZoneBox );
303 mTimeZoneCombo = new QComboBox( timeZoneBox ); 303 mTimeZoneCombo = new QComboBox( timeZoneBox );
304 if ( QApplication::desktop()->width() < 300 ) { 304 if ( QApplication::desktop()->width() < 300 ) {
305 mTimeZoneCombo->setMaximumWidth(150); 305 mTimeZoneCombo->setMaximumWidth(150);
306 } 306 }
307 307
308 QStringList list; 308 QStringList list;
309 list = KGlobal::locale()->timeZoneList(); 309 list = KGlobal::locale()->timeZoneList();
310 mTimeZoneCombo->insertStringList(list); 310 mTimeZoneCombo->insertStringList(list);
311 311
312 // find the currently set time zone and select it 312 // find the currently set time zone and select it
313 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId; 313 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId;
314 int nCurrentlySet = 11; 314 int nCurrentlySet = 11;
315 for (int i = 0; i < mTimeZoneCombo->count(); i++) 315 for (int i = 0; i < mTimeZoneCombo->count(); i++)
316 { 316 {
317 if (mTimeZoneCombo->text(i) == sCurrentlySet) 317 if (mTimeZoneCombo->text(i) == sCurrentlySet)
318 { 318 {
319 nCurrentlySet = i; 319 nCurrentlySet = i;
320 break; 320 break;
321 } 321 }
322 } 322 }
323 mTimeZoneCombo->setCurrentItem(nCurrentlySet); 323 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
324 int iii = 1; 324 int iii = 1;
325 KPrefsWidBool *sb = 325 KPrefsWidBool *sb =
326 addWidBool(i18n("Add 30 min (+00:30) to selected Timezone"),
327 &(KPimGlobalPrefs::instance()->mTimeZoneAdd30min),topFrame);
328 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
329 ++iii;
330 sb =
326 addWidBool(i18n("Timezone has daylight saving"), 331 addWidBool(i18n("Timezone has daylight saving"),
327 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame); 332 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame);
328 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 333 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
329 ++iii; 334 ++iii;
330 QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); 335 QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame );
331 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 336 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
332 ++iii; 337 ++iii;
333 lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); 338 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
334 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 339 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
335 ++iii; 340 ++iii;
336 lab = new QLabel( i18n("Daylight start:"), topFrame ); 341 lab = new QLabel( i18n("Daylight start:"), topFrame );
337 topLayout->addWidget(lab, iii,0); 342 topLayout->addWidget(lab, iii,0);
338 mStartDateSavingEdit = new KDateEdit(topFrame); 343 mStartDateSavingEdit = new KDateEdit(topFrame);
339 topLayout->addWidget(mStartDateSavingEdit, iii,1); 344 topLayout->addWidget(mStartDateSavingEdit, iii,1);
340 ++iii; 345 ++iii;
341 346
342 lab = new QLabel( i18n("Daylight end:"), topFrame ); 347 lab = new QLabel( i18n("Daylight end:"), topFrame );
343 topLayout->addWidget(lab, iii,0); 348 topLayout->addWidget(lab, iii,0);
344 mEndDateSavingEdit = new KDateEdit(topFrame); 349 mEndDateSavingEdit = new KDateEdit(topFrame);
345 topLayout->addWidget(mEndDateSavingEdit, iii,1); 350 topLayout->addWidget(mEndDateSavingEdit, iii,1);
346 ++iii; 351 ++iii;
347 QDate current ( 2001, 1,1); 352 QDate current ( 2001, 1,1);
348 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1)); 353 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1));
349 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1)); 354 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1));
350 355
351 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 356 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
352 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 357 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
353 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) ); 358 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) );
354 359
355 360
356 361
357 tabWidget->addTab( topFrame, i18n( "Time Zone" ) ); 362 tabWidget->addTab( topFrame, i18n( "Time Zone" ) );
358 363
359} 364}
360 365
361void KDEPIMConfigWidget::externalapp_changed( int newApp ) 366void KDEPIMConfigWidget::externalapp_changed( int newApp )
362{ 367{
363 // first store the current data 368 // first store the current data
364 saveEditFieldSettings(); 369 saveEditFieldSettings();
365 370
366 // set mCurrentApp 371 // set mCurrentApp
367 mCurrentApp = (ExternalAppHandler::Types)newApp; 372 mCurrentApp = (ExternalAppHandler::Types)newApp;
368 373
369 // set mCurrentClient 374 // set mCurrentClient
370 switch(mCurrentApp) 375 switch(mCurrentApp)
371 { 376 {
372 case(ExternalAppHandler::EMAIL): 377 case(ExternalAppHandler::EMAIL):
373 mCurrentClient = mEmailClient; 378 mCurrentClient = mEmailClient;
374 break; 379 break;
375 case(ExternalAppHandler::PHONE): 380 case(ExternalAppHandler::PHONE):
376 mCurrentClient = mPhoneClient; 381 mCurrentClient = mPhoneClient;
377 break; 382 break;
378 case(ExternalAppHandler::SMS): 383 case(ExternalAppHandler::SMS):
379 mCurrentClient = mSMSClient; 384 mCurrentClient = mSMSClient;
380 break; 385 break;
381 case(ExternalAppHandler::FAX): 386 case(ExternalAppHandler::FAX):
382 mCurrentClient = mFaxClient; 387 mCurrentClient = mFaxClient;
383 break; 388 break;
384 case(ExternalAppHandler::PAGER): 389 case(ExternalAppHandler::PAGER):
385 mCurrentClient = mPagerClient; 390 mCurrentClient = mPagerClient;
386 break; 391 break;
387 case(ExternalAppHandler::SIP): 392 case(ExternalAppHandler::SIP):
388 mCurrentClient = mSipClient; 393 mCurrentClient = mSipClient;
389 break; 394 break;
390 default: 395 default:
391 return; 396 return;
392 } 397 }
393 398
394 // and at last update the widgets 399 // and at last update the widgets
395 updateClientWidgets(); 400 updateClientWidgets();
396} 401}
397 402
398 403
399 404
400void KDEPIMConfigWidget::client_changed( int newClient ) 405void KDEPIMConfigWidget::client_changed( int newClient )
401{ 406{
402 if (newClient == mCurrentClient) 407 if (newClient == mCurrentClient)
403 return; 408 return;
404 409
405 // first store the current data 410 // first store the current data
406 saveEditFieldSettings(); 411 saveEditFieldSettings();
407 412
408 413
409 //then reset the clientvariable 414 //then reset the clientvariable
410 mCurrentClient = newClient; 415 mCurrentClient = newClient;
411 416
412 // and at last update the widgets 417 // and at last update the widgets
413 updateClientWidgets(); 418 updateClientWidgets();
414 419
415 KPrefsWidget::modified(); 420 KPrefsWidget::modified();
416} 421}
417 422
418void KDEPIMConfigWidget::saveEditFieldSettings() 423void KDEPIMConfigWidget::saveEditFieldSettings()
419{ 424{
420 425
421 switch(mCurrentApp) 426 switch(mCurrentApp)
422 { 427 {
423 case(ExternalAppHandler::EMAIL): 428 case(ExternalAppHandler::EMAIL):
424 mEmailClient = mClient->currentItem(); 429 mEmailClient = mClient->currentItem();
425 break; 430 break;
426 case(ExternalAppHandler::PHONE): 431 case(ExternalAppHandler::PHONE):
427 mPhoneClient= mClient->currentItem(); 432 mPhoneClient= mClient->currentItem();
428 break; 433 break;
429 case(ExternalAppHandler::SMS): 434 case(ExternalAppHandler::SMS):
430 mSMSClient = mClient->currentItem(); 435 mSMSClient = mClient->currentItem();
431 break; 436 break;
432 case(ExternalAppHandler::FAX): 437 case(ExternalAppHandler::FAX):
433 mFaxClient = mClient->currentItem(); 438 mFaxClient = mClient->currentItem();
434 break; 439 break;
435 case(ExternalAppHandler::PAGER): 440 case(ExternalAppHandler::PAGER):
436 mPagerClient = mClient->currentItem(); 441 mPagerClient = mClient->currentItem();
437 break; 442 break;
438 case(ExternalAppHandler::SIP): 443 case(ExternalAppHandler::SIP):
439 mSipClient = mClient->currentItem(); 444 mSipClient = mClient->currentItem();
440 break; 445 break;
441 default: 446 default:
442 return; 447 return;
443 } 448 }
444 449
445 //store the current data back to the apropriate membervariables if we had set it to "other" 450 //store the current data back to the apropriate membervariables if we had set it to "other"
446 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 451 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
447 { 452 {
448 mEmailOtherChannel = mChannel->text(); 453 mEmailOtherChannel = mChannel->text();
449 mEmailOtherMessage = mMessage->text(); 454 mEmailOtherMessage = mMessage->text();
450 mEmailOtherMessageParameters = mParameters->text(); 455 mEmailOtherMessageParameters = mParameters->text();
451 mEmailOtherMessage2 = mMessage2->text(); 456 mEmailOtherMessage2 = mMessage2->text();
452 mEmailOtherMessageParameters2 = mParameters2->text(); 457 mEmailOtherMessageParameters2 = mParameters2->text();
453 } 458 }
454 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 459 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
455 { 460 {
456 mPhoneOtherChannel = mChannel->text(); 461 mPhoneOtherChannel = mChannel->text();
457 mPhoneOtherMessage = mMessage->text(); 462 mPhoneOtherMessage = mMessage->text();
458 mPhoneOtherMessageParameters = mParameters->text(); 463 mPhoneOtherMessageParameters = mParameters->text();
459 } 464 }
460 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 465 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
461 { 466 {
462 mSMSOtherChannel = mChannel->text(); 467 mSMSOtherChannel = mChannel->text();
463 mSMSOtherMessage = mMessage->text(); 468 mSMSOtherMessage = mMessage->text();
464 mSMSOtherMessageParameters = mParameters->text(); 469 mSMSOtherMessageParameters = mParameters->text();
465 } 470 }
466 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 471 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
467 { 472 {
468 mFaxOtherChannel = mChannel->text(); 473 mFaxOtherChannel = mChannel->text();
469 mFaxOtherMessage = mMessage->text(); 474 mFaxOtherMessage = mMessage->text();
470 mFaxOtherMessageParameters = mParameters->text(); 475 mFaxOtherMessageParameters = mParameters->text();
471 } 476 }
472 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 477 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
473 { 478 {
474 mPagerOtherChannel = mChannel->text(); 479 mPagerOtherChannel = mChannel->text();
475 mPagerOtherMessage = mMessage->text(); 480 mPagerOtherMessage = mMessage->text();
476 mPagerOtherMessageParameters = mParameters->text(); 481 mPagerOtherMessageParameters = mParameters->text();
477 } 482 }
478 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 483 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
479 { 484 {
480 mSipOtherChannel = mChannel->text(); 485 mSipOtherChannel = mChannel->text();
481 mSipOtherMessage = mMessage->text(); 486 mSipOtherMessage = mMessage->text();
482 mSipOtherMessageParameters = mParameters->text(); 487 mSipOtherMessageParameters = mParameters->text();
483 } 488 }
484 489
485 490
486} 491}
487 492
488void KDEPIMConfigWidget::updateClientWidgets() 493void KDEPIMConfigWidget::updateClientWidgets()
489{ 494{
490 bool blocked = signalsBlocked(); 495 bool blocked = signalsBlocked();
491 blockSignals( true ); 496 blockSignals( true );
492 497
493 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display 498 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display
494 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp ); 499 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp );
495 if (it == mExternalAppsMap.end()) 500 if (it == mExternalAppsMap.end())
496 return; 501 return;
497 502
498 // update group box 503 // update group box
499 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data())); 504 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data()));
500 505
501 //update the entries in the client combobox 506 //update the entries in the client combobox
502 mClient->clear(); 507 mClient->clear();
503 508
504 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); 509 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp);
505 DefaultAppItem* dai; 510 DefaultAppItem* dai;
506 for ( dai=items.first(); dai != 0; dai=items.next() ) 511 for ( dai=items.first(); dai != 0; dai=items.next() )
507 { 512 {
508 mClient->insertItem( i18n(dai->_label), dai->_id ); 513 mClient->insertItem( i18n(dai->_label), dai->_id );
509 514
510 if (dai->_id == mCurrentClient) 515 if (dai->_id == mCurrentClient)
511 { 516 {
512 //restore the edit fields with the data of the local membervariables if we had set it to "other". 517 //restore the edit fields with the data of the local membervariables if we had set it to "other".
513 //Otherwise take the default data from externalapphandler. 518 //Otherwise take the default data from externalapphandler.
514 mChannel->setText(dai->_channel); 519 mChannel->setText(dai->_channel);
515 mMessage->setText(dai->_message); 520 mMessage->setText(dai->_message);
516 mParameters->setText(dai->_parameters); 521 mParameters->setText(dai->_parameters);
517 mMessage2->setText(dai->_message2); 522 mMessage2->setText(dai->_message2);
518 mParameters2->setText(dai->_parameters2); 523 mParameters2->setText(dai->_parameters2);
519 524
520 525
521 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 526 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
522 { 527 {
523 mChannel->setText(mEmailOtherChannel); 528 mChannel->setText(mEmailOtherChannel);
524 mMessage->setText(mEmailOtherMessage); 529 mMessage->setText(mEmailOtherMessage);
525 mParameters->setText(mEmailOtherMessageParameters); 530 mParameters->setText(mEmailOtherMessageParameters);
526 mMessage2->setText(mEmailOtherMessage2); 531 mMessage2->setText(mEmailOtherMessage2);
527 mParameters2->setText(mEmailOtherMessageParameters2); 532 mParameters2->setText(mEmailOtherMessageParameters2);
528 } 533 }
529 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 534 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
530 { 535 {
531 mChannel->setText(mPhoneOtherChannel); 536 mChannel->setText(mPhoneOtherChannel);
532 mMessage->setText(mPhoneOtherMessage); 537 mMessage->setText(mPhoneOtherMessage);
533 mParameters->setText(mPhoneOtherMessageParameters); 538 mParameters->setText(mPhoneOtherMessageParameters);
534 } 539 }
535 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 540 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
536 { 541 {
537 mChannel->setText(mSMSOtherChannel); 542 mChannel->setText(mSMSOtherChannel);
538 mMessage->setText(mSMSOtherMessage); 543 mMessage->setText(mSMSOtherMessage);
539 mParameters->setText(mSMSOtherMessageParameters); 544 mParameters->setText(mSMSOtherMessageParameters);
540 } 545 }
541 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 546 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
542 { 547 {
543 mChannel->setText(mFaxOtherChannel); 548 mChannel->setText(mFaxOtherChannel);
544 mMessage->setText(mFaxOtherMessage); 549 mMessage->setText(mFaxOtherMessage);
545 mParameters->setText(mFaxOtherMessageParameters); 550 mParameters->setText(mFaxOtherMessageParameters);
546 } 551 }
547 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 552 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
548 { 553 {
549 mChannel->setText(mPagerOtherChannel); 554 mChannel->setText(mPagerOtherChannel);
550 mMessage->setText(mPagerOtherMessage); 555 mMessage->setText(mPagerOtherMessage);
551 mParameters->setText(mPagerOtherMessageParameters); 556 mParameters->setText(mPagerOtherMessageParameters);
552 } 557 }
553 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 558 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
554 { 559 {
555 mChannel->setText(mSipOtherChannel); 560 mChannel->setText(mSipOtherChannel);
556 mMessage->setText(mSipOtherMessage); 561 mMessage->setText(mSipOtherMessage);
557 mParameters->setText(mSipOtherMessageParameters); 562 mParameters->setText(mSipOtherMessageParameters);
558 } 563 }
559 } 564 }
560 565
561 } 566 }
562 567
563 bool readonly; 568 bool readonly;
564 bool enabled; 569 bool enabled;
565 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 570 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
566 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 571 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
567 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 572 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
568 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 573 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
569 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 574 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
570 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))) 575 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)))
571 { 576 {
572 readonly = false; 577 readonly = false;
573 } 578 }
574 else 579 else
575 { 580 {
576 readonly = true; 581 readonly = true;
577 } 582 }
578 583
579 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC)) 584 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC))
580 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC)) 585 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC))
581 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC)) 586 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC))
582 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC)) 587 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC))
583 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC)) 588 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC))
584 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC))) 589 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC)))
585 { 590 {
586 enabled = false; 591 enabled = false;
587 } 592 }
588 else 593 else
589 { 594 {
590 enabled = true; 595 enabled = true;
591 } 596 }
592 597
593 598
594 mChannel->setReadOnly(readonly); 599 mChannel->setReadOnly(readonly);
595 mMessage->setReadOnly(readonly); 600 mMessage->setReadOnly(readonly);
596 mParameters->setReadOnly(readonly); 601 mParameters->setReadOnly(readonly);
597 mMessage2->setReadOnly(readonly); 602 mMessage2->setReadOnly(readonly);
598 mParameters2->setReadOnly(readonly); 603 mParameters2->setReadOnly(readonly);
599 604
600 mChannel->setEnabled(enabled); 605 mChannel->setEnabled(enabled);
601 mMessage->setEnabled(enabled); 606 mMessage->setEnabled(enabled);
602 mParameters->setEnabled(enabled); 607 mParameters->setEnabled(enabled);
603 mMessage2->setEnabled(enabled); 608 mMessage2->setEnabled(enabled);
604 mParameters2->setEnabled(enabled); 609 mParameters2->setEnabled(enabled);
605 610
606 611
607 612
608 mClient->setCurrentItem(mCurrentClient); 613 mClient->setCurrentItem(mCurrentClient);
609 614
610 615
611 // enable/disable the extra message/parameter field 616 // enable/disable the extra message/parameter field
612 if (mCurrentApp == ExternalAppHandler::EMAIL) 617 if (mCurrentApp == ExternalAppHandler::EMAIL)
613 { 618 {
614 } 619 }
615 else 620 else
616 { 621 {
617 mMessage2->setText( "" ); 622 mMessage2->setText( "" );
618 mParameters2->setText( "" ); 623 mParameters2->setText( "" );
619 } 624 }
620 625
621 if (enabled == true) { 626 if (enabled == true) {
622 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 627 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
623 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 628 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
624 } 629 }
625 630
626 631
627 blockSignals( blocked ); 632 blockSignals( blocked );
628 633
629} 634}
630 635
631void KDEPIMConfigWidget::usrReadConfig() 636void KDEPIMConfigWidget::usrReadConfig()
632{ 637{
633 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 638 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
634 639
635 bool blocked = signalsBlocked(); 640 bool blocked = signalsBlocked();
636 blockSignals( true ); 641 blockSignals( true );
637 642
638 QString dummy = prefs->mUserDateFormatLong; 643 QString dummy = prefs->mUserDateFormatLong;
639 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 644 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
640 dummy = prefs->mUserDateFormatShort; 645 dummy = prefs->mUserDateFormatShort;
641 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); 646 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
642 647
643 QDate current ( 2001, 1,1); 648 QDate current ( 2001, 1,1);
644 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1)); 649 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1));
645 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); 650 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1));
646 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); 651 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId));
647 652
648 653
649 654
650 655
651 mEmailClient = prefs->mEmailClient; 656 mEmailClient = prefs->mEmailClient;
652 mEmailOtherChannel = prefs->mEmailOtherChannel; 657 mEmailOtherChannel = prefs->mEmailOtherChannel;
653 mEmailOtherMessage = prefs->mEmailOtherMessage; 658 mEmailOtherMessage = prefs->mEmailOtherMessage;
654 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; 659 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters;
655 mEmailOtherMessage2 = prefs->mEmailOtherMessage2; 660 mEmailOtherMessage2 = prefs->mEmailOtherMessage2;
656 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; 661 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2;
657 662
658 mPhoneClient = prefs->mPhoneClient; 663 mPhoneClient = prefs->mPhoneClient;
659 mPhoneOtherChannel = prefs->mPhoneOtherChannel; 664 mPhoneOtherChannel = prefs->mPhoneOtherChannel;
660 mPhoneOtherMessage = prefs->mPhoneOtherMessage; 665 mPhoneOtherMessage = prefs->mPhoneOtherMessage;
661 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; 666 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters;
662 667
663 mFaxClient = prefs->mFaxClient; 668 mFaxClient = prefs->mFaxClient;
664 mFaxOtherChannel = prefs->mFaxOtherChannel; 669 mFaxOtherChannel = prefs->mFaxOtherChannel;
665 mFaxOtherMessage = prefs->mFaxOtherMessage; 670 mFaxOtherMessage = prefs->mFaxOtherMessage;
666 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; 671 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters;
667 672
668 mSMSClient = prefs->mSMSClient; 673 mSMSClient = prefs->mSMSClient;
669 mSMSOtherChannel = prefs->mSMSOtherChannel; 674 mSMSOtherChannel = prefs->mSMSOtherChannel;
670 mSMSOtherMessage = prefs->mSMSOtherMessage; 675 mSMSOtherMessage = prefs->mSMSOtherMessage;
671 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters; 676 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters;
672 677
673 mPagerClient = prefs->mPagerClient; 678 mPagerClient = prefs->mPagerClient;
674 mPagerOtherChannel = prefs->mPagerOtherChannel; 679 mPagerOtherChannel = prefs->mPagerOtherChannel;
675 mPagerOtherMessage = prefs->mPagerOtherMessage; 680 mPagerOtherMessage = prefs->mPagerOtherMessage;
676 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters; 681 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters;
677 682
678 mSipClient = prefs->mPagerClient; 683 mSipClient = prefs->mPagerClient;
679 mSipOtherChannel = prefs->mSipOtherChannel; 684 mSipOtherChannel = prefs->mSipOtherChannel;
680 mSipOtherMessage = prefs->mSipOtherMessage; 685 mSipOtherMessage = prefs->mSipOtherMessage;
681 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters; 686 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters;
682 687
683 mCurrentApp = ExternalAppHandler::EMAIL; 688 mCurrentApp = ExternalAppHandler::EMAIL;
684 mCurrentClient = mEmailClient; 689 mCurrentClient = mEmailClient;
685 690
686 updateClientWidgets(); 691 updateClientWidgets();
687 692
688 blockSignals( blocked ); 693 blockSignals( blocked );
689 694
690} 695}
691 696
692void KDEPIMConfigWidget::usrWriteConfig() 697void KDEPIMConfigWidget::usrWriteConfig()
693{ 698{
694 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 699 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
695 700
696 saveEditFieldSettings(); 701 saveEditFieldSettings();
697 702
698 703
699 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 704 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
700 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 705 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
701 706
702 prefs->mTimeZoneId = mTimeZoneCombo->currentText(); 707 prefs->mTimeZoneId = mTimeZoneCombo->currentText();
703 QDate date; 708 QDate date;
704 date = mStartDateSavingEdit->date(); 709 date = mStartDateSavingEdit->date();
705 int sub = 0; 710 int sub = 0;
706 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 711 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
707 sub = 1; 712 sub = 1;
708 prefs->mDaylightsavingStart = date.dayOfYear()-sub; 713 prefs->mDaylightsavingStart = date.dayOfYear()-sub;
709 date = mEndDateSavingEdit->date(); 714 date = mEndDateSavingEdit->date();
710 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 715 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
711 sub = 1; 716 sub = 1;
712 else 717 else
713 sub = 0; 718 sub = 0;
714 prefs->mDaylightsavingEnd = date.dayOfYear()-sub; 719 prefs->mDaylightsavingEnd = date.dayOfYear()-sub;
715 720
716 721
717 prefs->mEmailClient = mEmailClient; 722 prefs->mEmailClient = mEmailClient;
718 prefs->mEmailOtherChannel = mEmailOtherChannel; 723 prefs->mEmailOtherChannel = mEmailOtherChannel;
719 prefs->mEmailOtherMessage = mEmailOtherMessage; 724 prefs->mEmailOtherMessage = mEmailOtherMessage;
720 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; 725 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters;
721 prefs->mEmailOtherMessage2 = mEmailOtherMessage2; 726 prefs->mEmailOtherMessage2 = mEmailOtherMessage2;
722 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; 727 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2;
723 728
724 prefs->mPhoneClient = mPhoneClient; 729 prefs->mPhoneClient = mPhoneClient;
725 prefs->mPhoneOtherChannel = mPhoneOtherChannel; 730 prefs->mPhoneOtherChannel = mPhoneOtherChannel;
726 prefs->mPhoneOtherMessage = mPhoneOtherMessage; 731 prefs->mPhoneOtherMessage = mPhoneOtherMessage;
727 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; 732 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters;
728 733
729 prefs->mFaxClient = mFaxClient; 734 prefs->mFaxClient = mFaxClient;
730 prefs->mFaxOtherChannel = mFaxOtherChannel; 735 prefs->mFaxOtherChannel = mFaxOtherChannel;
731 prefs->mFaxOtherMessage = mFaxOtherMessage; 736 prefs->mFaxOtherMessage = mFaxOtherMessage;
732 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters; 737 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters;
733 738
734 prefs->mSMSClient = mSMSClient; 739 prefs->mSMSClient = mSMSClient;
735 prefs->mSMSOtherChannel = mSMSOtherChannel; 740 prefs->mSMSOtherChannel = mSMSOtherChannel;
736 prefs->mSMSOtherMessage = mSMSOtherMessage; 741 prefs->mSMSOtherMessage = mSMSOtherMessage;
737 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters; 742 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters;
738 743
739 prefs->mPagerClient = mPagerClient; 744 prefs->mPagerClient = mPagerClient;
740 prefs->mPagerOtherChannel = mPagerOtherChannel; 745 prefs->mPagerOtherChannel = mPagerOtherChannel;
741 prefs->mPagerOtherMessage = mPagerOtherMessage; 746 prefs->mPagerOtherMessage = mPagerOtherMessage;
742 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; 747 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters;
743 748
744 749
745 prefs->mSipClient = mSipClient; 750 prefs->mSipClient = mSipClient;
746 prefs->mSipOtherChannel = mSipOtherChannel; 751 prefs->mSipOtherChannel = mSipOtherChannel;
747 prefs->mSipOtherMessage = mSipOtherMessage; 752 prefs->mSipOtherMessage = mSipOtherMessage;
748 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters; 753 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters;
749 754
750 //release the cache that other views can access the changed values instantanious 755 //release the cache that other views can access the changed values instantanious
751 ExternalAppHandler::instance()->loadConfig(); 756 ExternalAppHandler::instance()->loadConfig();
752 KPimGlobalPrefs::instance()->setGlobalConfig(); 757 KPimGlobalPrefs::instance()->setGlobalConfig();
753} 758}
754 759
755 760
756void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text, 761void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text,
757 const QStringList *tags) 762 const QStringList *tags)
758{ 763{
759 if (tags) { 764 if (tags) {
760 int i = tags->findIndex(text); 765 int i = tags->findIndex(text);
761 if (i > 0) combo->setCurrentItem(i); 766 if (i > 0) combo->setCurrentItem(i);
762 } else { 767 } else {
763 for(int i=0;i<combo->count();++i) { 768 for(int i=0;i<combo->count();++i) {
764 if (combo->text(i) == text) { 769 if (combo->text(i) == text) {
765 combo->setCurrentItem(i); 770 combo->setCurrentItem(i);
766 break; 771 break;
767 } 772 }
768 } 773 }
769 } 774 }
770} 775}
771 776
772 777
773void KDEPIMConfigWidget::textChanged( const QString& text ) 778void KDEPIMConfigWidget::textChanged( const QString& text )
774{ 779{
775 emit changed( true ); 780 emit changed( true );
776} 781}
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index 5081b26..04e2072 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -1,138 +1,139 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kstaticdeleter.h> 35#include <kstaticdeleter.h>
36 36
37#include <qregexp.h> 37#include <qregexp.h>
38#include "kpimglobalprefs.h" 38#include "kpimglobalprefs.h"
39 39
40KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; 40KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
41static KStaticDeleter<KPimGlobalPrefs> staticDeleter; 41static KStaticDeleter<KPimGlobalPrefs> staticDeleter;
42 42
43 43
44KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) 44KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
45 : KPrefs("microkdeglobalrc") 45 : KPrefs("microkdeglobalrc")
46{ 46{
47 47
48 KPrefs::setCurrentGroup("Locale"); 48 KPrefs::setCurrentGroup("Locale");
49 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 49 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
50 addItemInt("PreferredTime",&mPreferredTime,0); 50 addItemInt("PreferredTime",&mPreferredTime,0);
51 addItemInt("PreferredDate",&mPreferredDate,0); 51 addItemInt("PreferredDate",&mPreferredDate,0);
52 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 52 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
53 //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); 53 //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false);
54 // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 54 // addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
55 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 55 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
56 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 56 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
57 57
58 KPrefs::setCurrentGroup("Time & Date"); 58 KPrefs::setCurrentGroup("Time & Date");
59 59
60 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 60 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
61 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 61 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
62 addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false);
62 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 63 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
63 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 64 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
64 65
65 KPrefs::setCurrentGroup( "ExternalApplications" ); 66 KPrefs::setCurrentGroup( "ExternalApplications" );
66 67
67 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); 68 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC );
68 addItemString( "EmailChannel", &mEmailOtherChannel, "" ); 69 addItemString( "EmailChannel", &mEmailOtherChannel, "" );
69 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); 70 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" );
70 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); 71 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" );
71 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); 72 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" );
72 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); 73 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" );
73 74
74 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); 75 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC );
75 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); 76 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" );
76 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); 77 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" );
77 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); 78 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" );
78 79
79 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); 80 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC );
80 addItemString( "FaxChannel", &mFaxOtherChannel, "" ); 81 addItemString( "FaxChannel", &mFaxOtherChannel, "" );
81 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); 82 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" );
82 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); 83 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" );
83 84
84 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); 85 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC );
85 addItemString( "SMSChannel", &mSMSOtherChannel, "" ); 86 addItemString( "SMSChannel", &mSMSOtherChannel, "" );
86 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); 87 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" );
87 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); 88 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" );
88 89
89 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); 90 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC );
90 addItemString( "PagerChannel", &mPagerOtherChannel, "" ); 91 addItemString( "PagerChannel", &mPagerOtherChannel, "" );
91 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); 92 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" );
92 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); 93 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" );
93 94
94 addItemInt( "SIPChannelType", &mSipClient, NONE_SIC ); 95 addItemInt( "SIPChannelType", &mSipClient, NONE_SIC );
95 addItemString( "SIPChannel", &mSipOtherChannel, "" ); 96 addItemString( "SIPChannel", &mSipOtherChannel, "" );
96 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); 97 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" );
97 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); 98 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" );
98 99
99 KPrefs::setCurrentGroup( "PhoneAccess" ); 100 KPrefs::setCurrentGroup( "PhoneAccess" );
100 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); 101 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
101 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); 102 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
102 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); 103 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
103 104
104} 105}
105 106
106 107
107void KPimGlobalPrefs::setGlobalConfig() 108void KPimGlobalPrefs::setGlobalConfig()
108{ 109{
109 110
110 KGlobal::locale()->setHore24Format( !mPreferredTime ); 111 KGlobal::locale()->setHore24Format( !mPreferredTime );
111 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); 112 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday );
112 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); 113 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate );
113 KGlobal::locale()->setLanguage( mPreferredLanguage ); 114 KGlobal::locale()->setLanguage( mPreferredLanguage );
114 QString dummy = mUserDateFormatLong; 115 QString dummy = mUserDateFormatLong;
115 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 116 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
116 dummy = mUserDateFormatShort; 117 dummy = mUserDateFormatShort;
117 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 118 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
118 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, 119 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving,
119 mDaylightsavingStart, 120 mDaylightsavingStart,
120 mDaylightsavingEnd ); 121 mDaylightsavingEnd );
121 KGlobal::locale()->setTimezone( mTimeZoneId ); 122 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min );
122 123
123} 124}
124KPimGlobalPrefs::~KPimGlobalPrefs() 125KPimGlobalPrefs::~KPimGlobalPrefs()
125{ 126{
126 //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() "); 127 //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() ");
127 writeConfig(); 128 writeConfig();
128} 129}
129 130
130KPimGlobalPrefs *KPimGlobalPrefs::instance() 131KPimGlobalPrefs *KPimGlobalPrefs::instance()
131{ 132{
132 if ( !sInstance ) { 133 if ( !sInstance ) {
133 sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); 134 sInstance = staticDeleter.setObject( new KPimGlobalPrefs() );
134 sInstance->readConfig(); 135 sInstance->readConfig();
135 } 136 }
136 137
137 return sInstance; 138 return sInstance;
138} 139}
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h
index f6b6628..7c55099 100644
--- a/libkdepim/kpimglobalprefs.h
+++ b/libkdepim/kpimglobalprefs.h
@@ -1,138 +1,139 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KPIMGLOBALPREFS_H 31#ifndef KPIMGLOBALPREFS_H
32#define KPIMGLOBALPREFS_H 32#define KPIMGLOBALPREFS_H
33 33
34#include "kprefs.h" 34#include "kprefs.h"
35 35
36class KPimGlobalPrefs : public KPrefs 36class KPimGlobalPrefs : public KPrefs
37{ 37{
38 public: 38 public:
39 39
40 void setGlobalConfig(); 40 void setGlobalConfig();
41 static KPimGlobalPrefs *instance(); 41 static KPimGlobalPrefs *instance();
42 42
43 43
44 virtual ~KPimGlobalPrefs(); 44 virtual ~KPimGlobalPrefs();
45 45
46 46
47 enum EMailClients { 47 enum EMailClients {
48 NONE_EMC = 0, 48 NONE_EMC = 0,
49 OTHER_EMC = 1, 49 OTHER_EMC = 1,
50 OMPI_EMC = 2, 50 OMPI_EMC = 2,
51 QTOPIA_EMC = 3, 51 QTOPIA_EMC = 3,
52 OPIE_EMC = 4 52 OPIE_EMC = 4
53 }; 53 };
54 54
55 enum PhoneClients { 55 enum PhoneClients {
56 NONE_PHC = 0, 56 NONE_PHC = 0,
57 OTHER_PHC = 1, 57 OTHER_PHC = 1,
58 KPPI_PHC = 2 58 KPPI_PHC = 2
59 }; 59 };
60 60
61 enum FaxClients { 61 enum FaxClients {
62 NONE_FAC = 0, 62 NONE_FAC = 0,
63 OTHER_FAC = 1 63 OTHER_FAC = 1
64 }; 64 };
65 65
66 enum SMSClients { 66 enum SMSClients {
67 NONE_SMC = 0, 67 NONE_SMC = 0,
68 OTHER_SMC = 1 68 OTHER_SMC = 1
69 }; 69 };
70 70
71 enum PagerClients { 71 enum PagerClients {
72 NONE_PAC = 0, 72 NONE_PAC = 0,
73 OTHER_PAC = 1 73 OTHER_PAC = 1
74 }; 74 };
75 75
76 enum SIPClients { 76 enum SIPClients {
77 NONE_SIC = 0, 77 NONE_SIC = 0,
78 OTHER_SIC = 1 78 OTHER_SIC = 1
79 }; 79 };
80 80
81 private: 81 private:
82 KPimGlobalPrefs( const QString &name = QString::null ); 82 KPimGlobalPrefs( const QString &name = QString::null );
83 83
84 static KPimGlobalPrefs *sInstance; 84 static KPimGlobalPrefs *sInstance;
85 85
86 86
87 public: 87 public:
88 //US I copied the following "locale" settings from KOPrefs 88 //US I copied the following "locale" settings from KOPrefs
89 int mPreferredDate; 89 int mPreferredDate;
90 QString mUserDateFormatLong; 90 QString mUserDateFormatLong;
91 QString mUserDateFormatShort; 91 QString mUserDateFormatShort;
92 int mPreferredLanguage; 92 int mPreferredLanguage;
93 int mPreferredTime; 93 int mPreferredTime;
94 bool mWeekStartsOnSunday; 94 bool mWeekStartsOnSunday;
95 QString mTimeZoneId; 95 QString mTimeZoneId;
96 bool mUseDaylightsaving; 96 bool mUseDaylightsaving;
97 int mDaylightsavingStart; 97 int mDaylightsavingStart;
98 int mDaylightsavingEnd; 98 int mDaylightsavingEnd;
99 bool mTimeZoneAdd30min;
99 100
100 int mEmailClient; 101 int mEmailClient;
101 QString mEmailOtherChannel; 102 QString mEmailOtherChannel;
102 QString mEmailOtherMessage; 103 QString mEmailOtherMessage;
103 QString mEmailOtherMessageParameters; 104 QString mEmailOtherMessageParameters;
104 QString mEmailOtherMessage2; 105 QString mEmailOtherMessage2;
105 QString mEmailOtherMessageParameters2; 106 QString mEmailOtherMessageParameters2;
106 107
107 int mPhoneClient; 108 int mPhoneClient;
108 QString mPhoneOtherChannel; 109 QString mPhoneOtherChannel;
109 QString mPhoneOtherMessage; 110 QString mPhoneOtherMessage;
110 QString mPhoneOtherMessageParameters; 111 QString mPhoneOtherMessageParameters;
111 112
112 int mFaxClient; 113 int mFaxClient;
113 QString mFaxOtherChannel; 114 QString mFaxOtherChannel;
114 QString mFaxOtherMessage; 115 QString mFaxOtherMessage;
115 QString mFaxOtherMessageParameters; 116 QString mFaxOtherMessageParameters;
116 117
117 int mSMSClient; 118 int mSMSClient;
118 QString mSMSOtherChannel; 119 QString mSMSOtherChannel;
119 QString mSMSOtherMessage; 120 QString mSMSOtherMessage;
120 QString mSMSOtherMessageParameters; 121 QString mSMSOtherMessageParameters;
121 122
122 int mPagerClient; 123 int mPagerClient;
123 QString mPagerOtherChannel; 124 QString mPagerOtherChannel;
124 QString mPagerOtherMessage; 125 QString mPagerOtherMessage;
125 QString mPagerOtherMessageParameters; 126 QString mPagerOtherMessageParameters;
126 127
127 int mSipClient; 128 int mSipClient;
128 QString mSipOtherChannel; 129 QString mSipOtherChannel;
129 QString mSipOtherMessage; 130 QString mSipOtherMessage;
130 QString mSipOtherMessageParameters; 131 QString mSipOtherMessageParameters;
131 132
132 QString mEx2PhoneDevice; 133 QString mEx2PhoneDevice;
133 QString mEx2PhoneConnection; 134 QString mEx2PhoneConnection;
134 QString mEx2PhoneModel; 135 QString mEx2PhoneModel;
135 136
136}; 137};
137 138
138#endif 139#endif
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 27acfec..673d845 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -1,988 +1,990 @@
1#include <qregexp.h> 1#include <qregexp.h>
2#include <qapplication.h> 2#include <qapplication.h>
3 3
4#include "kdebug.h" 4#include "kdebug.h"
5#include "kcalendarsystemgregorian.h" 5#include "kcalendarsystemgregorian.h"
6 6
7#include "klocale.h" 7#include "klocale.h"
8 8
9 9
10QDict<QString> *mLocaleDict = 0; 10QDict<QString> *mLocaleDict = 0;
11void setLocaleDict( QDict<QString> * dict ) 11void setLocaleDict( QDict<QString> * dict )
12{ 12{
13 mLocaleDict = dict; 13 mLocaleDict = dict;
14 14
15} 15}
16QString i18n(const char *text) 16QString i18n(const char *text)
17{ 17{
18 if ( ! mLocaleDict ) 18 if ( ! mLocaleDict )
19 return QString( text ); 19 return QString( text );
20 else { 20 else {
21 QString* ret = mLocaleDict->find(QString(text)) ; 21 QString* ret = mLocaleDict->find(QString(text)) ;
22 if ( ret == 0 ) { 22 if ( ret == 0 ) {
23 return QString( text ); 23 return QString( text );
24 } 24 }
25 else { 25 else {
26 if ( (*ret).isEmpty() ) 26 if ( (*ret).isEmpty() )
27 return QString( text ); 27 return QString( text );
28 else 28 else
29 return (*ret); 29 return (*ret);
30 } 30 }
31 } 31 }
32 32
33} 33}
34 34
35QString i18n(const char *,const char *text) 35QString i18n(const char *,const char *text)
36{ 36{
37 return i18n( text ); 37 return i18n( text );
38} 38}
39 39
40QString i18n(const char *text1, const char *textn, int num) 40QString i18n(const char *text1, const char *textn, int num)
41{ 41{
42 if ( num == 1 ) return i18n( text1 ); 42 if ( num == 1 ) return i18n( text1 );
43 else { 43 else {
44 QString text = i18n( textn ); 44 QString text = i18n( textn );
45 int pos = text.find( "%n" ); 45 int pos = text.find( "%n" );
46 if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); 46 if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) );
47 return text; 47 return text;
48 } 48 }
49} 49}
50 50
51inline void put_it_in( QChar *buffer, uint& index, const QString &s ) 51inline void put_it_in( QChar *buffer, uint& index, const QString &s )
52{ 52{
53 for ( uint l = 0; l < s.length(); l++ ) 53 for ( uint l = 0; l < s.length(); l++ )
54 buffer[index++] = s.at( l ); 54 buffer[index++] = s.at( l );
55} 55}
56 56
57inline void put_it_in( QChar *buffer, uint& index, int number ) 57inline void put_it_in( QChar *buffer, uint& index, int number )
58{ 58{
59 buffer[index++] = number / 10 + '0'; 59 buffer[index++] = number / 10 + '0';
60 buffer[index++] = number % 10 + '0'; 60 buffer[index++] = number % 10 + '0';
61} 61}
62 62
63static int readInt(const QString &str, uint &pos) 63static int readInt(const QString &str, uint &pos)
64{ 64{
65 if (!str.at(pos).isDigit()) return -1; 65 if (!str.at(pos).isDigit()) return -1;
66 int result = 0; 66 int result = 0;
67 for (; str.length() > pos && str.at(pos).isDigit(); pos++) 67 for (; str.length() > pos && str.at(pos).isDigit(); pos++)
68 { 68 {
69 result *= 10; 69 result *= 10;
70 result += str.at(pos).digitValue(); 70 result += str.at(pos).digitValue();
71 } 71 }
72 72
73 return result; 73 return result;
74} 74}
75 75
76KLocale::KLocale() : mCalendarSystem( 0 ) 76KLocale::KLocale() : mCalendarSystem( 0 )
77{ 77{
78 78
79 m_decimalSymbol = "."; 79 m_decimalSymbol = ".";
80 m_positiveSign = ""; 80 m_positiveSign = "";
81 m_negativeSign = "-"; 81 m_negativeSign = "-";
82 m_thousandsSeparator = ","; 82 m_thousandsSeparator = ",";
83 83
84 84
85 85
86 86
87 mWeekStartsMonday = true; 87 mWeekStartsMonday = true;
88 mHourF24Format = true; 88 mHourF24Format = true;
89 mIntDateFormat = Default; 89 mIntDateFormat = Default;
90 mIntTimeFormat = Default; 90 mIntTimeFormat = Default;
91 mLanguage = 0; 91 mLanguage = 0;
92 mDateFormat = "%a %Y %b %d"; 92 mDateFormat = "%a %Y %b %d";
93 mDateFormatShort = "%Y-%m-%d"; 93 mDateFormatShort = "%Y-%m-%d";
94 mTimeZoneList << i18n ("-11:00 US/Samoa") 94 mTimeZoneList << i18n ("-11:00 US/Samoa")
95 << i18n ("-10:00 US/Hawaii") 95 << i18n ("-10:00 US/Hawaii")
96 << i18n ("-09:00 US/Alaska") 96 << i18n ("-09:00 US/Alaska")
97 << i18n ("-08:00 US/Pacific") 97 << i18n ("-08:00 US/Pacific")
98 << i18n ("-07:00 US/Mountain") 98 << i18n ("-07:00 US/Mountain")
99 << i18n ("-06:00 US/Central") 99 << i18n ("-06:00 US/Central")
100 << i18n ("-05:00 US/Eastern") 100 << i18n ("-05:00 US/Eastern")
101 << i18n ("-04:00 Brazil/West") 101 << i18n ("-04:00 Brazil/West")
102 << i18n ("-03:00 Brazil/East") 102 << i18n ("-03:00 Brazil/East")
103 << i18n ("-02:00 Brazil/DeNoronha") 103 << i18n ("-02:00 Brazil/DeNoronha")
104 << i18n ("-01:00 Atlantic/Azores") 104 << i18n ("-01:00 Atlantic/Azores")
105 << i18n (" 00:00 Europe/London(UTC)") 105 << i18n (" 00:00 Europe/London(UTC)")
106 << i18n ("+01:00 Europe/Oslo(CET)") 106 << i18n ("+01:00 Europe/Oslo(CET)")
107 << i18n ("+02:00 Europe/Helsinki") 107 << i18n ("+02:00 Europe/Helsinki")
108 << i18n ("+03:00 Europe/Moscow") 108 << i18n ("+03:00 Europe/Moscow")
109 << i18n ("+04:00 Indian/Mauritius") 109 << i18n ("+04:00 Indian/Mauritius")
110 << i18n ("+05:00 Indian/Maldives") 110 << i18n ("+05:00 Indian/Maldives")
111 << i18n ("+06:00 Indian/Chagos") 111 << i18n ("+06:00 Indian/Chagos")
112 << i18n ("+07:00 Asia/Bangkok") 112 << i18n ("+07:00 Asia/Bangkok")
113 << i18n ("+08:00 Asia/Hongkong") 113 << i18n ("+08:00 Asia/Hongkong")
114 << i18n ("+09:00 Asia/Tokyo") 114 << i18n ("+09:00 Asia/Tokyo")
115 << i18n ("+10:00 Asia/Vladivostok") 115 << i18n ("+10:00 Asia/Vladivostok")
116 << i18n ("+11:00 Asia/Magadan") 116 << i18n ("+11:00 Asia/Magadan")
117 << i18n ("+12:00 Asia/Kamchatka") 117 << i18n ("+12:00 Asia/Kamchatka")
118 // << i18n (" xx:xx User defined offset") 118 // << i18n (" xx:xx User defined offset")
119 << i18n (" Local Time"); 119 << i18n (" Local Time");
120 mSouthDaylight = false; 120 mSouthDaylight = false;
121 mTimeZoneOffset = 0; 121 mTimeZoneOffset = 0;
122 daylightEnabled = false; 122 daylightEnabled = false;
123} 123}
124 124
125void KLocale::setDateFormat( QString s ) 125void KLocale::setDateFormat( QString s )
126{ 126{
127 mDateFormat = s; 127 mDateFormat = s;
128} 128}
129 129
130void KLocale::setDateFormatShort( QString s ) 130void KLocale::setDateFormatShort( QString s )
131{ 131{
132 mDateFormatShort = s; 132 mDateFormatShort = s;
133} 133}
134 134
135void KLocale::setHore24Format ( bool b ) 135void KLocale::setHore24Format ( bool b )
136{ 136{
137 mHourF24Format = b; 137 mHourF24Format = b;
138} 138}
139void KLocale::setWeekStartMonday( bool b ) 139void KLocale::setWeekStartMonday( bool b )
140{ 140{
141 mWeekStartsMonday = b; 141 mWeekStartsMonday = b;
142} 142}
143 143
144KLocale::IntDateFormat KLocale::getIntDateFormat( ) 144KLocale::IntDateFormat KLocale::getIntDateFormat( )
145{ 145{
146 return mIntDateFormat; 146 return mIntDateFormat;
147 147
148} 148}
149void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) 149void KLocale::setIntDateFormat( KLocale::IntDateFormat i )
150{ 150{
151 mIntDateFormat = i; 151 mIntDateFormat = i;
152} 152}
153KLocale::IntDateFormat KLocale::getIntTimeFormat( ) 153KLocale::IntDateFormat KLocale::getIntTimeFormat( )
154{ 154{
155 return mIntTimeFormat; 155 return mIntTimeFormat;
156 156
157} 157}
158void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) 158void KLocale::setIntTimeFormat( KLocale::IntDateFormat i )
159{ 159{
160 mIntTimeFormat = i; 160 mIntTimeFormat = i;
161} 161}
162 162
163void KLocale::setLanguage( int i ) 163void KLocale::setLanguage( int i )
164{ 164{
165 mLanguage = i; 165 mLanguage = i;
166} 166}
167QString KLocale::translate( const char *index ) const 167QString KLocale::translate( const char *index ) const
168{ 168{
169 return i18n( index ); 169 return i18n( index );
170} 170}
171 171
172QString KLocale::translate( const char *, const char *fallback) const 172QString KLocale::translate( const char *, const char *fallback) const
173{ 173{
174 return i18n( fallback ); 174 return i18n( fallback );
175} 175}
176 176
177QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const 177QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const
178{ 178{
179 const QString rst = timeFormat(intIntDateFormat); 179 const QString rst = timeFormat(intIntDateFormat);
180 180
181 // only "pm/am" here can grow, the rest shrinks, but 181 // only "pm/am" here can grow, the rest shrinks, but
182 // I'm rather safe than sorry 182 // I'm rather safe than sorry
183 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; 183 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30];
184 184
185 uint index = 0; 185 uint index = 0;
186 bool escape = false; 186 bool escape = false;
187 int number = 0; 187 int number = 0;
188 188
189 for ( uint format_index = 0; format_index < rst.length(); format_index++ ) 189 for ( uint format_index = 0; format_index < rst.length(); format_index++ )
190 { 190 {
191 if ( !escape ) 191 if ( !escape )
192 { 192 {
193 if ( rst.at( format_index ).unicode() == '%' ) 193 if ( rst.at( format_index ).unicode() == '%' )
194 escape = true; 194 escape = true;
195 else 195 else
196 buffer[index++] = rst.at( format_index ); 196 buffer[index++] = rst.at( format_index );
197 } 197 }
198 else 198 else
199 { 199 {
200 switch ( rst.at( format_index ).unicode() ) 200 switch ( rst.at( format_index ).unicode() )
201 { 201 {
202 case '%': 202 case '%':
203 buffer[index++] = '%'; 203 buffer[index++] = '%';
204 break; 204 break;
205 case 'H': 205 case 'H':
206 put_it_in( buffer, index, pTime.hour() ); 206 put_it_in( buffer, index, pTime.hour() );
207 break; 207 break;
208 case 'I': 208 case 'I':
209 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); 209 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 );
210 break; 210 break;
211 case 'M': 211 case 'M':
212 put_it_in( buffer, index, pTime.minute() ); 212 put_it_in( buffer, index, pTime.minute() );
213 break; 213 break;
214 case 'S': 214 case 'S':
215 if (includeSecs) 215 if (includeSecs)
216 put_it_in( buffer, index, pTime.second() ); 216 put_it_in( buffer, index, pTime.second() );
217 else 217 else
218 { 218 {
219 // we remove the seperator sign before the seconds and 219 // we remove the seperator sign before the seconds and
220 // assume that works everywhere 220 // assume that works everywhere
221 --index; 221 --index;
222 break; 222 break;
223 } 223 }
224 break; 224 break;
225 case 'k': 225 case 'k':
226 number = pTime.hour(); 226 number = pTime.hour();
227 case 'l': 227 case 'l':
228 // to share the code 228 // to share the code
229 if ( rst.at( format_index ).unicode() == 'l' ) 229 if ( rst.at( format_index ).unicode() == 'l' )
230 number = (pTime.hour() + 11) % 12 + 1; 230 number = (pTime.hour() + 11) % 12 + 1;
231 if ( number / 10 ) 231 if ( number / 10 )
232 buffer[index++] = number / 10 + '0'; 232 buffer[index++] = number / 10 + '0';
233 buffer[index++] = number % 10 + '0'; 233 buffer[index++] = number % 10 + '0';
234 break; 234 break;
235 case 'p': 235 case 'p':
236 { 236 {
237 QString s; 237 QString s;
238 if ( pTime.hour() >= 12 ) 238 if ( pTime.hour() >= 12 )
239 put_it_in( buffer, index, i18n("pm") ); 239 put_it_in( buffer, index, i18n("pm") );
240 else 240 else
241 put_it_in( buffer, index, i18n("am") ); 241 put_it_in( buffer, index, i18n("am") );
242 break; 242 break;
243 } 243 }
244 default: 244 default:
245 buffer[index++] = rst.at( format_index ); 245 buffer[index++] = rst.at( format_index );
246 break; 246 break;
247 } 247 }
248 escape = false; 248 escape = false;
249 } 249 }
250 } 250 }
251 QString ret( buffer, index ); 251 QString ret( buffer, index );
252 delete [] buffer; 252 delete [] buffer;
253 return ret; 253 return ret;
254} 254}
255 255
256QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const 256QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const
257{ 257{
258 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); 258 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat);
259 259
260 // I'm rather safe than sorry 260 // I'm rather safe than sorry
261 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; 261 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50];
262 262
263 unsigned int index = 0; 263 unsigned int index = 0;
264 bool escape = false; 264 bool escape = false;
265 int number = 0; 265 int number = 0;
266 266
267 for ( uint format_index = 0; format_index < rst.length(); ++format_index ) 267 for ( uint format_index = 0; format_index < rst.length(); ++format_index )
268 { 268 {
269 if ( !escape ) 269 if ( !escape )
270 { 270 {
271 if ( rst.at( format_index ).unicode() == '%' ) 271 if ( rst.at( format_index ).unicode() == '%' )
272 escape = true; 272 escape = true;
273 else 273 else
274 buffer[index++] = rst.at( format_index ); 274 buffer[index++] = rst.at( format_index );
275 } 275 }
276 else 276 else
277 { 277 {
278 switch ( rst.at( format_index ).unicode() ) 278 switch ( rst.at( format_index ).unicode() )
279 { 279 {
280 case '%': 280 case '%':
281 buffer[index++] = '%'; 281 buffer[index++] = '%';
282 break; 282 break;
283 case 'Y': 283 case 'Y':
284 put_it_in( buffer, index, pDate.year() / 100 ); 284 put_it_in( buffer, index, pDate.year() / 100 );
285 case 'y': 285 case 'y':
286 put_it_in( buffer, index, pDate.year() % 100 ); 286 put_it_in( buffer, index, pDate.year() % 100 );
287 break; 287 break;
288 case 'n': 288 case 'n':
289 number = pDate.month(); 289 number = pDate.month();
290 case 'e': 290 case 'e':
291 // to share the code 291 // to share the code
292 if ( rst.at( format_index ).unicode() == 'e' ) 292 if ( rst.at( format_index ).unicode() == 'e' )
293 number = pDate.day(); 293 number = pDate.day();
294 if ( number / 10 ) 294 if ( number / 10 )
295 buffer[index++] = number / 10 + '0'; 295 buffer[index++] = number / 10 + '0';
296 buffer[index++] = number % 10 + '0'; 296 buffer[index++] = number % 10 + '0';
297 break; 297 break;
298 case 'm': 298 case 'm':
299 put_it_in( buffer, index, pDate.month() ); 299 put_it_in( buffer, index, pDate.month() );
300 break; 300 break;
301 case 'b': 301 case 'b':
302 put_it_in( buffer, index, monthName(pDate.month(), true) ); 302 put_it_in( buffer, index, monthName(pDate.month(), true) );
303 break; 303 break;
304 case 'B': 304 case 'B':
305 put_it_in( buffer, index, monthName(pDate.month(), false) ); 305 put_it_in( buffer, index, monthName(pDate.month(), false) );
306 break; 306 break;
307 case 'd': 307 case 'd':
308 put_it_in( buffer, index, pDate.day() ); 308 put_it_in( buffer, index, pDate.day() );
309 break; 309 break;
310 case 'a': 310 case 'a':
311 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); 311 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) );
312 break; 312 break;
313 case 'A': 313 case 'A':
314 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); 314 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) );
315 break; 315 break;
316 default: 316 default:
317 buffer[index++] = rst.at( format_index ); 317 buffer[index++] = rst.at( format_index );
318 break; 318 break;
319 } 319 }
320 escape = false; 320 escape = false;
321 } 321 }
322 } 322 }
323 QString ret( buffer, index ); 323 QString ret( buffer, index );
324 delete [] buffer; 324 delete [] buffer;
325 return ret; 325 return ret;
326} 326}
327 327
328QString KLocale::formatDateTime(const QDateTime &pDateTime, 328QString KLocale::formatDateTime(const QDateTime &pDateTime,
329 bool shortFormat, 329 bool shortFormat,
330 bool includeSeconds, 330 bool includeSeconds,
331 IntDateFormat intIntDateFormat) const 331 IntDateFormat intIntDateFormat) const
332{ 332{
333 QString format("%1 %2"); 333 QString format("%1 %2");
334 334
335 if ( intIntDateFormat == Default ) 335 if ( intIntDateFormat == Default )
336 format = "%1 %2"; 336 format = "%1 %2";
337 else if ( intIntDateFormat == Format1 ) 337 else if ( intIntDateFormat == Format1 )
338 format = "%1 %2"; 338 format = "%1 %2";
339 else if ( intIntDateFormat == ISODate ) 339 else if ( intIntDateFormat == ISODate )
340 format = "%1T%2"; 340 format = "%1T%2";
341 341
342 QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) 342 QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat ))
343 .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); 343 .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ));
344 344
345 //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); 345 //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() );
346 346
347 return res; 347 return res;
348} 348}
349 349
350QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const 350QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const
351{ 351{
352 return formatDateTime(pDateTime, true, true, intIntDateFormat); 352 return formatDateTime(pDateTime, true, true, intIntDateFormat);
353} 353}
354 354
355QDate KLocale::readDate(const QString &intstr, bool* ok) const 355QDate KLocale::readDate(const QString &intstr, bool* ok) const
356{ 356{
357 QDate date; 357 QDate date;
358 date = readDate(intstr, true, ok); 358 date = readDate(intstr, true, ok);
359 if (date.isValid()) return date; 359 if (date.isValid()) return date;
360 return readDate(intstr, false, ok); 360 return readDate(intstr, false, ok);
361} 361}
362 362
363QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const 363QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const
364{ 364{
365 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); 365 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace();
366 return readDate( intstr, fmt, ok ); 366 return readDate( intstr, fmt, ok );
367} 367}
368 368
369QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const 369QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const
370{ 370{
371 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; 371 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl;
372 QString str = intstr.simplifyWhiteSpace().lower(); 372 QString str = intstr.simplifyWhiteSpace().lower();
373 int day = -1, month = -1; 373 int day = -1, month = -1;
374 // allow the year to be omitted if not in the format 374 // allow the year to be omitted if not in the format
375 int year = QDate::currentDate().year(); 375 int year = QDate::currentDate().year();
376 uint strpos = 0; 376 uint strpos = 0;
377 uint fmtpos = 0; 377 uint fmtpos = 0;
378 378
379 while (fmt.length() > fmtpos || str.length() > strpos) 379 while (fmt.length() > fmtpos || str.length() > strpos)
380 { 380 {
381 if ( !(fmt.length() > fmtpos && str.length() > strpos) ) 381 if ( !(fmt.length() > fmtpos && str.length() > strpos) )
382 goto error; 382 goto error;
383 383
384 QChar c = fmt.at(fmtpos++); 384 QChar c = fmt.at(fmtpos++);
385 385
386 if (c != '%') { 386 if (c != '%') {
387 if (c.isSpace()) 387 if (c.isSpace())
388 strpos++; 388 strpos++;
389 else if (c != str.at(strpos++)) 389 else if (c != str.at(strpos++))
390 goto error; 390 goto error;
391 continue; 391 continue;
392 } 392 }
393 393
394 // remove space at the begining 394 // remove space at the begining
395 if (str.length() > strpos && str.at(strpos).isSpace()) 395 if (str.length() > strpos && str.at(strpos).isSpace())
396 strpos++; 396 strpos++;
397 397
398 c = fmt.at(fmtpos++); 398 c = fmt.at(fmtpos++);
399 switch (c) 399 switch (c)
400 { 400 {
401 case 'a': 401 case 'a':
402 case 'A': 402 case 'A':
403 // this will just be ignored 403 // this will just be ignored
404 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 404 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
405 for (int j = 1; j < 8; j++) { 405 for (int j = 1; j < 8; j++) {
406 QString s = weekDayName(j, c == 'a').lower(); 406 QString s = weekDayName(j, c == 'a').lower();
407 int len = s.length(); 407 int len = s.length();
408 if (str.mid(strpos, len) == s) 408 if (str.mid(strpos, len) == s)
409 strpos += len; 409 strpos += len;
410 } 410 }
411 break; 411 break;
412 } 412 }
413 case 'b': 413 case 'b':
414 case 'B': 414 case 'B':
415 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 415 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
416 for (int j = 1; j < 13; j++) { 416 for (int j = 1; j < 13; j++) {
417 QString s = monthName(j, c == 'b').lower(); 417 QString s = monthName(j, c == 'b').lower();
418 int len = s.length(); 418 int len = s.length();
419 if (str.mid(strpos, len) == s) { 419 if (str.mid(strpos, len) == s) {
420 month = j; 420 month = j;
421 strpos += len; 421 strpos += len;
422 } 422 }
423 } 423 }
424 break; 424 break;
425 } 425 }
426 case 'd': 426 case 'd':
427 case 'e': 427 case 'e':
428 day = readInt(str, strpos); 428 day = readInt(str, strpos);
429 if (day < 1 || day > 31) 429 if (day < 1 || day > 31)
430 goto error; 430 goto error;
431 431
432 break; 432 break;
433 433
434 case 'n': 434 case 'n':
435 case 'm': 435 case 'm':
436 month = readInt(str, strpos); 436 month = readInt(str, strpos);
437 if (month < 1 || month > 12) 437 if (month < 1 || month > 12)
438 goto error; 438 goto error;
439 439
440 break; 440 break;
441 441
442 case 'Y': 442 case 'Y':
443 case 'y': 443 case 'y':
444 year = readInt(str, strpos); 444 year = readInt(str, strpos);
445 if (year < 0) 445 if (year < 0)
446 goto error; 446 goto error;
447 // Qt treats a year in the range 0-100 as 1900-1999. 447 // Qt treats a year in the range 0-100 as 1900-1999.
448 // It is nicer for the user if we treat 0-68 as 2000-2068 448 // It is nicer for the user if we treat 0-68 as 2000-2068
449 if (year < 69) 449 if (year < 69)
450 year += 2000; 450 year += 2000;
451 else if (c == 'y') 451 else if (c == 'y')
452 year += 1900; 452 year += 1900;
453 453
454 break; 454 break;
455 } 455 }
456 } 456 }
457 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; 457 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl;
458 if ( year != -1 && month != -1 && day != -1 ) 458 if ( year != -1 && month != -1 && day != -1 )
459 { 459 {
460 if (ok) *ok = true; 460 if (ok) *ok = true;
461 return QDate(year, month, day); 461 return QDate(year, month, day);
462 } 462 }
463 error: 463 error:
464 if (ok) *ok = false; 464 if (ok) *ok = false;
465 return QDate(); // invalid date 465 return QDate(); // invalid date
466} 466}
467 467
468QTime KLocale::readTime(const QString &intstr, bool *ok) const 468QTime KLocale::readTime(const QString &intstr, bool *ok) const
469{ 469{
470 QTime _time; 470 QTime _time;
471 _time = readTime(intstr, true, ok); 471 _time = readTime(intstr, true, ok);
472 if (_time.isValid()) return _time; 472 if (_time.isValid()) return _time;
473 return readTime(intstr, false, ok); 473 return readTime(intstr, false, ok);
474} 474}
475 475
476QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const 476QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
477{ 477{
478 QString str = intstr.simplifyWhiteSpace().lower(); 478 QString str = intstr.simplifyWhiteSpace().lower();
479 QString Format = timeFormat().simplifyWhiteSpace(); 479 QString Format = timeFormat().simplifyWhiteSpace();
480 if (!seconds) 480 if (!seconds)
481 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); 481 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null);
482 482
483 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds 483 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds
484 484
485 bool g_12h = false; 485 bool g_12h = false;
486 bool pm = false; 486 bool pm = false;
487 uint strpos = 0; 487 uint strpos = 0;
488 uint Formatpos = 0; 488 uint Formatpos = 0;
489 489
490 while (Format.length() > Formatpos || str.length() > strpos) 490 while (Format.length() > Formatpos || str.length() > strpos)
491 { 491 {
492 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; 492 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error;
493 493
494 QChar c = Format.at(Formatpos++); 494 QChar c = Format.at(Formatpos++);
495 495
496 if (c != '%') 496 if (c != '%')
497 { 497 {
498 if (c.isSpace()) 498 if (c.isSpace())
499 strpos++; 499 strpos++;
500 else if (c != str.at(strpos++)) 500 else if (c != str.at(strpos++))
501 goto error; 501 goto error;
502 continue; 502 continue;
503 } 503 }
504 504
505 // remove space at the begining 505 // remove space at the begining
506 if (str.length() > strpos && str.at(strpos).isSpace()) 506 if (str.length() > strpos && str.at(strpos).isSpace())
507 strpos++; 507 strpos++;
508 508
509 c = Format.at(Formatpos++); 509 c = Format.at(Formatpos++);
510 switch (c) 510 switch (c)
511 { 511 {
512 case 'p': 512 case 'p':
513 { 513 {
514 QString s; 514 QString s;
515 s = i18n("pm").lower(); 515 s = i18n("pm").lower();
516 int len = s.length(); 516 int len = s.length();
517 if (str.mid(strpos, len) == s) 517 if (str.mid(strpos, len) == s)
518 { 518 {
519 pm = true; 519 pm = true;
520 strpos += len; 520 strpos += len;
521 } 521 }
522 else 522 else
523 { 523 {
524 s = i18n("am").lower(); 524 s = i18n("am").lower();
525 len = s.length(); 525 len = s.length();
526 if (str.mid(strpos, len) == s) { 526 if (str.mid(strpos, len) == s) {
527 pm = false; 527 pm = false;
528 strpos += len; 528 strpos += len;
529 } 529 }
530 else 530 else
531 goto error; 531 goto error;
532 } 532 }
533 } 533 }
534 break; 534 break;
535 535
536 case 'k': 536 case 'k':
537 case 'H': 537 case 'H':
538 g_12h = false; 538 g_12h = false;
539 hour = readInt(str, strpos); 539 hour = readInt(str, strpos);
540 if (hour < 0 || hour > 23) 540 if (hour < 0 || hour > 23)
541 goto error; 541 goto error;
542 542
543 break; 543 break;
544 544
545 case 'l': 545 case 'l':
546 case 'I': 546 case 'I':
547 g_12h = true; 547 g_12h = true;
548 hour = readInt(str, strpos); 548 hour = readInt(str, strpos);
549 if (hour < 1 || hour > 12) 549 if (hour < 1 || hour > 12)
550 goto error; 550 goto error;
551 551
552 break; 552 break;
553 553
554 case 'M': 554 case 'M':
555 minute = readInt(str, strpos); 555 minute = readInt(str, strpos);
556 if (minute < 0 || minute > 59) 556 if (minute < 0 || minute > 59)
557 goto error; 557 goto error;
558 558
559 break; 559 break;
560 560
561 case 'S': 561 case 'S':
562 second = readInt(str, strpos); 562 second = readInt(str, strpos);
563 if (second < 0 || second > 59) 563 if (second < 0 || second > 59)
564 goto error; 564 goto error;
565 565
566 break; 566 break;
567 } 567 }
568 } 568 }
569 if (g_12h) 569 if (g_12h)
570 { 570 {
571 hour %= 12; 571 hour %= 12;
572 if (pm) hour += 12; 572 if (pm) hour += 12;
573 } 573 }
574 574
575 if (ok) *ok = true; 575 if (ok) *ok = true;
576 return QTime(hour, minute, second); 576 return QTime(hour, minute, second);
577 577
578 error: 578 error:
579 if (ok) *ok = false; 579 if (ok) *ok = false;
580 return QTime(-1, -1, -1); // return invalid date if it didn't work 580 return QTime(-1, -1, -1); // return invalid date if it didn't work
581 // This will be removed in the near future, since it gives a warning on stderr. 581 // This will be removed in the near future, since it gives a warning on stderr.
582 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. 582 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime.
583} 583}
584 584
585QDateTime KLocale::readDateTime(const QString &intstr, 585QDateTime KLocale::readDateTime(const QString &intstr,
586 IntDateFormat intIntDateFormat, 586 IntDateFormat intIntDateFormat,
587 bool* ok) const 587 bool* ok) const
588{ 588{
589 bool ok1, ok2; 589 bool ok1, ok2;
590 590
591 // AT the moment we can not read any other format then ISODate 591 // AT the moment we can not read any other format then ISODate
592 if ( intIntDateFormat != ISODate ) 592 if ( intIntDateFormat != ISODate )
593 { 593 {
594 qDebug("KLocale::readDateTime, only ISODate is supported."); 594 qDebug("KLocale::readDateTime, only ISODate is supported.");
595 return QDateTime(); 595 return QDateTime();
596 } 596 }
597 597
598 int pos = intstr.find("T"); 598 int pos = intstr.find("T");
599 QString date = intstr.left(pos); 599 QString date = intstr.left(pos);
600 QString time = intstr.mid(pos+1); 600 QString time = intstr.mid(pos+1);
601 601
602 QString dformat = dateFormat(intIntDateFormat); 602 QString dformat = dateFormat(intIntDateFormat);
603 QString tformat = timeFormat(intIntDateFormat); 603 QString tformat = timeFormat(intIntDateFormat);
604 604
605 QDate m_date = readDate(date, dformat, &ok1); 605 QDate m_date = readDate(date, dformat, &ok1);
606 QTime m_time = readTime(time, tformat, &ok2); 606 QTime m_time = readTime(time, tformat, &ok2);
607 607
608 QDateTime m_dt; 608 QDateTime m_dt;
609 609
610 if (ok) 610 if (ok)
611 { 611 {
612 if ((ok1 == false) || (ok2 == false)) 612 if ((ok1 == false) || (ok2 == false))
613 *ok = false; 613 *ok = false;
614 else 614 else
615 *ok = true; 615 *ok = true;
616 } 616 }
617 617
618 //only set values if both operations returned true. 618 //only set values if both operations returned true.
619 if ((ok1 == true) && (ok2 == true)) 619 if ((ok1 == true) && (ok2 == true))
620 { 620 {
621 m_dt.setDate(m_date); 621 m_dt.setDate(m_date);
622 m_dt.setTime(m_time); 622 m_dt.setTime(m_time);
623 } 623 }
624 624
625 //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); 625 //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
626 return m_dt; 626 return m_dt;
627} 627}
628 628
629QDate KLocale::readDate(const QString &intstr, 629QDate KLocale::readDate(const QString &intstr,
630 IntDateFormat intIntDateFormat, 630 IntDateFormat intIntDateFormat,
631 bool* ok) const 631 bool* ok) const
632{ 632{
633 bool ok1; 633 bool ok1;
634 634
635 QString dformat = dateFormat(intIntDateFormat); 635 QString dformat = dateFormat(intIntDateFormat);
636 636
637 QDate m_date = readDate(intstr, dformat, &ok1); 637 QDate m_date = readDate(intstr, dformat, &ok1);
638 638
639 if (ok) 639 if (ok)
640 *ok = ok1; 640 *ok = ok1;
641 641
642 //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); 642 //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
643 return m_date; 643 return m_date;
644} 644}
645 645
646 646
647bool KLocale::use12Clock() const 647bool KLocale::use12Clock() const
648{ 648{
649 return !mHourF24Format ;; 649 return !mHourF24Format ;;
650} 650}
651 651
652bool KLocale::weekStartsMonday() const 652bool KLocale::weekStartsMonday() const
653{ 653{
654 return mWeekStartsMonday; 654 return mWeekStartsMonday;
655} 655}
656 656
657int KLocale::weekStartDay() const 657int KLocale::weekStartDay() const
658{ 658{
659 if ( mWeekStartsMonday ) 659 if ( mWeekStartsMonday )
660 return 1; 660 return 1;
661 return 7; 661 return 7;
662} 662}
663 663
664QString KLocale::weekDayName(int i,bool shortName) const 664QString KLocale::weekDayName(int i,bool shortName) const
665{ 665{
666 if ( shortName ) 666 if ( shortName )
667 switch ( i ) 667 switch ( i )
668 { 668 {
669 case 1: return i18n("Monday", "Mon"); 669 case 1: return i18n("Monday", "Mon");
670 case 2: return i18n("Tuesday", "Tue"); 670 case 2: return i18n("Tuesday", "Tue");
671 case 3: return i18n("Wednesday", "Wed"); 671 case 3: return i18n("Wednesday", "Wed");
672 case 4: return i18n("Thursday", "Thu"); 672 case 4: return i18n("Thursday", "Thu");
673 case 5: return i18n("Friday", "Fri"); 673 case 5: return i18n("Friday", "Fri");
674 case 6: return i18n("Saturday", "Sat"); 674 case 6: return i18n("Saturday", "Sat");
675 case 7: return i18n("Sunday", "Sun"); 675 case 7: return i18n("Sunday", "Sun");
676 } 676 }
677 else 677 else
678 switch ( i ) 678 switch ( i )
679 { 679 {
680 case 1: return i18n("Monday"); 680 case 1: return i18n("Monday");
681 case 2: return i18n("Tuesday"); 681 case 2: return i18n("Tuesday");
682 case 3: return i18n("Wednesday"); 682 case 3: return i18n("Wednesday");
683 case 4: return i18n("Thursday"); 683 case 4: return i18n("Thursday");
684 case 5: return i18n("Friday"); 684 case 5: return i18n("Friday");
685 case 6: return i18n("Saturday"); 685 case 6: return i18n("Saturday");
686 case 7: return i18n("Sunday"); 686 case 7: return i18n("Sunday");
687 } 687 }
688 688
689 return QString::null; 689 return QString::null;
690} 690}
691 691
692QString KLocale::monthName(int i,bool shortName) const 692QString KLocale::monthName(int i,bool shortName) const
693{ 693{
694 if ( shortName ) 694 if ( shortName )
695 switch ( i ) 695 switch ( i )
696 { 696 {
697 case 1: return i18n("January", "Jan"); 697 case 1: return i18n("January", "Jan");
698 case 2: return i18n("February", "Feb"); 698 case 2: return i18n("February", "Feb");
699 case 3: return i18n("March", "Mar"); 699 case 3: return i18n("March", "Mar");
700 case 4: return i18n("April", "Apr"); 700 case 4: return i18n("April", "Apr");
701 case 5: return i18n("May short", "May"); 701 case 5: return i18n("May short", "May");
702 case 6: return i18n("June", "Jun"); 702 case 6: return i18n("June", "Jun");
703 case 7: return i18n("July", "Jul"); 703 case 7: return i18n("July", "Jul");
704 case 8: return i18n("August", "Aug"); 704 case 8: return i18n("August", "Aug");
705 case 9: return i18n("September", "Sep"); 705 case 9: return i18n("September", "Sep");
706 case 10: return i18n("October", "Oct"); 706 case 10: return i18n("October", "Oct");
707 case 11: return i18n("November", "Nov"); 707 case 11: return i18n("November", "Nov");
708 case 12: return i18n("December", "Dec"); 708 case 12: return i18n("December", "Dec");
709 } 709 }
710 else 710 else
711 switch (i) 711 switch (i)
712 { 712 {
713 case 1: return i18n("January"); 713 case 1: return i18n("January");
714 case 2: return i18n("February"); 714 case 2: return i18n("February");
715 case 3: return i18n("March"); 715 case 3: return i18n("March");
716 case 4: return i18n("April"); 716 case 4: return i18n("April");
717 case 5: return i18n("May long", "May"); 717 case 5: return i18n("May long", "May");
718 case 6: return i18n("June"); 718 case 6: return i18n("June");
719 case 7: return i18n("July"); 719 case 7: return i18n("July");
720 case 8: return i18n("August"); 720 case 8: return i18n("August");
721 case 9: return i18n("September"); 721 case 9: return i18n("September");
722 case 10: return i18n("October"); 722 case 10: return i18n("October");
723 case 11: return i18n("November"); 723 case 11: return i18n("November");
724 case 12: return i18n("December"); 724 case 12: return i18n("December");
725 } 725 }
726 726
727 return QString::null; 727 return QString::null;
728} 728}
729 729
730QString KLocale::country() const 730QString KLocale::country() const
731{ 731{
732 return QString::null; 732 return QString::null;
733} 733}
734 734
735QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const 735QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
736{ 736{
737 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 737 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
738 738
739 if ( dformat == ISODate ) 739 if ( dformat == ISODate )
740 return "%Y-%m-%d"; 740 return "%Y-%m-%d";
741 741
742 if ( QApplication::desktop()->width() < 480 ) { 742 if ( QApplication::desktop()->width() < 480 ) {
743 if ( dformat == Default ) 743 if ( dformat == Default )
744 return "%a %d %b %Y"; 744 return "%a %d %b %Y";
745 else if ( dformat == Format1 ) 745 else if ( dformat == Format1 )
746 return "%a %b %d %Y"; 746 return "%a %b %d %Y";
747 } else { 747 } else {
748 if ( dformat == Default ) 748 if ( dformat == Default )
749 return "%A %d %B %Y"; 749 return "%A %d %B %Y";
750 else if ( dformat == Format1 ) 750 else if ( dformat == Format1 )
751 return "%A %B %d %Y"; 751 return "%A %B %d %Y";
752 752
753 } 753 }
754 return mDateFormat ; 754 return mDateFormat ;
755} 755}
756 756
757QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const 757QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const
758{ 758{
759 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 759 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
760 760
761 if ( dformat == Default ) 761 if ( dformat == Default )
762 return "%d.%m.%Y"; 762 return "%d.%m.%Y";
763 else if ( dformat == Format1 ) 763 else if ( dformat == Format1 )
764 return "%m.%d.%Y"; 764 return "%m.%d.%Y";
765 else if ( dformat == ISODate ) // = Qt::ISODate 765 else if ( dformat == ISODate ) // = Qt::ISODate
766 return "%Y-%m-%d"; 766 return "%Y-%m-%d";
767 return mDateFormatShort ; 767 return mDateFormatShort ;
768 768
769} 769}
770 770
771 771
772QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const 772QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const
773{ 773{
774 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; 774 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat;
775 775
776 if ( tformat == Default ) 776 if ( tformat == Default )
777 if ( mHourF24Format) 777 if ( mHourF24Format)
778 return "%H:%M:%S"; 778 return "%H:%M:%S";
779 else 779 else
780 return "%I:%M:%S%p"; 780 return "%I:%M:%S%p";
781 781
782 else if ( tformat == Format1 ) 782 else if ( tformat == Format1 )
783 if ( mHourF24Format) 783 if ( mHourF24Format)
784 return "%H:%M:%S"; 784 return "%H:%M:%S";
785 else 785 else
786 return "%I:%M:%S%p"; 786 return "%I:%M:%S%p";
787 787
788 else if ( tformat == ISODate ) // = Qt::ISODate 788 else if ( tformat == ISODate ) // = Qt::ISODate
789 if ( mHourF24Format) 789 if ( mHourF24Format)
790 return "%H:%M:%S"; 790 return "%H:%M:%S";
791 else 791 else
792 return "%I:%M:%S%p"; 792 return "%I:%M:%S%p";
793 793
794} 794}
795 795
796void KLocale::insertCatalogue ( const QString & ) 796void KLocale::insertCatalogue ( const QString & )
797{ 797{
798} 798}
799 799
800KCalendarSystem *KLocale::calendar() 800KCalendarSystem *KLocale::calendar()
801{ 801{
802 if ( !mCalendarSystem ) { 802 if ( !mCalendarSystem ) {
803 mCalendarSystem = new KCalendarSystemGregorian; 803 mCalendarSystem = new KCalendarSystemGregorian;
804 } 804 }
805 805
806 return mCalendarSystem; 806 return mCalendarSystem;
807} 807}
808 808
809int KLocale::timezoneOffset( QString timeZone ) 809int KLocale::timezoneOffset( QString timeZone )
810{ 810{
811 int ret = 1001; 811 int ret = 1001;
812 int index = mTimeZoneList.findIndex( timeZone ); 812 int index = mTimeZoneList.findIndex( timeZone );
813 if ( index < 24 ) 813 if ( index < 24 )
814 ret = ( index-11 ) * 60 ; 814 ret = ( index-11 ) * 60 ;
815 return ret; 815 return ret;
816} 816}
817 817
818QStringList KLocale::timeZoneList() const 818QStringList KLocale::timeZoneList() const
819{ 819{
820 return mTimeZoneList; 820 return mTimeZoneList;
821} 821}
822void KLocale::setTimezone( const QString &timeZone ) 822void KLocale::setTimezone( const QString &timeZone, bool oddTZ )
823{ 823{
824 mTimeZoneOffset = timezoneOffset( timeZone ); 824 mTimeZoneOffset = timezoneOffset( timeZone );
825 if ( oddTZ )
826 mTimeZoneOffset += 30;
825} 827}
826 828
827void KLocale::setDaylightSaving( bool b, int start , int end ) 829void KLocale::setDaylightSaving( bool b, int start , int end )
828{ 830{
829 daylightEnabled = b; 831 daylightEnabled = b;
830 daylightStart = start; 832 daylightStart = start;
831 daylightEnd = end; 833 daylightEnd = end;
832 mSouthDaylight = (end < start); 834 mSouthDaylight = (end < start);
833 // qDebug("klocale daylight %d %d %d ", b, start , end ); 835 // qDebug("klocale daylight %d %d %d ", b, start , end );
834} 836}
835 837
836int KLocale::localTimeOffset( const QDateTime &dt ) 838int KLocale::localTimeOffset( const QDateTime &dt )
837{ 839{
838 bool addDaylight = false; 840 bool addDaylight = false;
839 if ( daylightEnabled ) { 841 if ( daylightEnabled ) {
840 int d_end, d_start; 842 int d_end, d_start;
841 int dayofyear = dt.date().dayOfYear(); 843 int dayofyear = dt.date().dayOfYear();
842 int year = dt.date().year(); 844 int year = dt.date().year();
843 int add = 0; 845 int add = 0;
844 if ( QDate::leapYear(year) ) 846 if ( QDate::leapYear(year) )
845 add = 1; 847 add = 1;
846 QDate date ( year,1,1 ); 848 QDate date ( year,1,1 );
847 if ( daylightEnd > 59 ) 849 if ( daylightEnd > 59 )
848 d_end = daylightEnd +add; 850 d_end = daylightEnd +add;
849 else 851 else
850 d_end = daylightEnd; 852 d_end = daylightEnd;
851 if ( daylightStart > 59 ) 853 if ( daylightStart > 59 )
852 d_start = daylightStart +add; 854 d_start = daylightStart +add;
853 else 855 else
854 d_start = daylightStart; 856 d_start = daylightStart;
855 QDate s_date = date.addDays( d_start -1 ); 857 QDate s_date = date.addDays( d_start -1 );
856 QDate e_date = date.addDays( d_end -1 ); 858 QDate e_date = date.addDays( d_end -1 );
857 int dof = s_date.dayOfWeek(); 859 int dof = s_date.dayOfWeek();
858 if ( dof < 7 ) 860 if ( dof < 7 )
859 s_date = s_date.addDays( -dof ); 861 s_date = s_date.addDays( -dof );
860 dof = e_date.dayOfWeek(); 862 dof = e_date.dayOfWeek();
861 if ( dof < 7 ) 863 if ( dof < 7 )
862 e_date = e_date.addDays( -dof ); 864 e_date = e_date.addDays( -dof );
863 QTime startTime ( 3,0,0 ); 865 QTime startTime ( 3,0,0 );
864 QDateTime startDt( s_date, startTime ); 866 QDateTime startDt( s_date, startTime );
865 QDateTime endDt( e_date, startTime ); 867 QDateTime endDt( e_date, startTime );
866 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); 868 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( ));
867 if ( mSouthDaylight ) { 869 if ( mSouthDaylight ) {
868 if ( ! ( endDt < dt && dt < startDt) ) 870 if ( ! ( endDt < dt && dt < startDt) )
869 addDaylight = true; 871 addDaylight = true;
870 } else { 872 } else {
871 if ( startDt < dt && dt < endDt ) 873 if ( startDt < dt && dt < endDt )
872 addDaylight = true; 874 addDaylight = true;
873 875
874 876
875 } 877 }
876 } 878 }
877 int addMin = 0; 879 int addMin = 0;
878 if ( addDaylight ) 880 if ( addDaylight )
879 addMin = 60; 881 addMin = 60;
880 return mTimeZoneOffset + addMin; 882 return mTimeZoneOffset + addMin;
881} 883}
882// ****************************************************************** 884// ******************************************************************
883// added LR 885// added LR
884QString KLocale::formatNumber(double num, int precision) const 886QString KLocale::formatNumber(double num, int precision) const
885{ 887{
886 bool neg = num < 0; 888 bool neg = num < 0;
887 if (precision == -1) precision = 2; 889 if (precision == -1) precision = 2;
888 QString res = QString::number(neg?-num:num, 'f', precision); 890 QString res = QString::number(neg?-num:num, 'f', precision);
889 int pos = res.find('.'); 891 int pos = res.find('.');
890 if (pos == -1) pos = res.length(); 892 if (pos == -1) pos = res.length();
891 else res.replace(pos, 1, decimalSymbol()); 893 else res.replace(pos, 1, decimalSymbol());
892 894
893 while (0 < (pos -= 3)) 895 while (0 < (pos -= 3))
894 res.insert(pos, thousandsSeparator()); // thousand sep 896 res.insert(pos, thousandsSeparator()); // thousand sep
895 897
896 // How can we know where we should put the sign? 898 // How can we know where we should put the sign?
897 res.prepend(neg?negativeSign():positiveSign()); 899 res.prepend(neg?negativeSign():positiveSign());
898 900
899 return res; 901 return res;
900} 902}
901QString KLocale::formatNumber(const QString &numStr) const 903QString KLocale::formatNumber(const QString &numStr) const
902{ 904{
903 return formatNumber(numStr.toDouble()); 905 return formatNumber(numStr.toDouble());
904} 906}
905double KLocale::readNumber(const QString &_str, bool * ok) const 907double KLocale::readNumber(const QString &_str, bool * ok) const
906{ 908{
907 QString str = _str.stripWhiteSpace(); 909 QString str = _str.stripWhiteSpace();
908 bool neg = str.find(negativeSign()) == 0; 910 bool neg = str.find(negativeSign()) == 0;
909 if (neg) 911 if (neg)
910 str.remove( 0, negativeSign().length() ); 912 str.remove( 0, negativeSign().length() );
911 913
912 /* will hold the scientific notation portion of the number. 914 /* will hold the scientific notation portion of the number.
913 Example, with 2.34E+23, exponentialPart == "E+23" 915 Example, with 2.34E+23, exponentialPart == "E+23"
914 */ 916 */
915 QString exponentialPart; 917 QString exponentialPart;
916 int EPos; 918 int EPos;
917 919
918 EPos = str.find('E', 0, false); 920 EPos = str.find('E', 0, false);
919 921
920 if (EPos != -1) 922 if (EPos != -1)
921 { 923 {
922 exponentialPart = str.mid(EPos); 924 exponentialPart = str.mid(EPos);
923 str = str.left(EPos); 925 str = str.left(EPos);
924 } 926 }
925 927
926 int pos = str.find(decimalSymbol()); 928 int pos = str.find(decimalSymbol());
927 QString major; 929 QString major;
928 QString minor; 930 QString minor;
929 if ( pos == -1 ) 931 if ( pos == -1 )
930 major = str; 932 major = str;
931 else 933 else
932 { 934 {
933 major = str.left(pos); 935 major = str.left(pos);
934 minor = str.mid(pos + decimalSymbol().length()); 936 minor = str.mid(pos + decimalSymbol().length());
935 } 937 }
936 938
937 // Remove thousand separators 939 // Remove thousand separators
938 int thlen = thousandsSeparator().length(); 940 int thlen = thousandsSeparator().length();
939 int lastpos = 0; 941 int lastpos = 0;
940 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) 942 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 )
941 { 943 {
942 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N 944 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N
943 int fromEnd = major.length() - pos; 945 int fromEnd = major.length() - pos;
944 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error 946 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error
945 || pos - lastpos > 3 // More than 3 digits between two separators -> error 947 || pos - lastpos > 3 // More than 3 digits between two separators -> error
946 || pos == 0 // Can't start with a separator 948 || pos == 0 // Can't start with a separator
947 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators 949 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators
948 { 950 {
949 if (ok) *ok = false; 951 if (ok) *ok = false;
950 return 0.0; 952 return 0.0;
951 } 953 }
952 954
953 lastpos = pos; 955 lastpos = pos;
954 major.remove( pos, thlen ); 956 major.remove( pos, thlen );
955 } 957 }
956 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator 958 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator
957 { 959 {
958 if (ok) *ok = false; 960 if (ok) *ok = false;
959 return 0.0; 961 return 0.0;
960 } 962 }
961 963
962 QString tot; 964 QString tot;
963 if (neg) tot = '-'; 965 if (neg) tot = '-';
964 966
965 tot += major + '.' + minor + exponentialPart; 967 tot += major + '.' + minor + exponentialPart;
966 968
967 return tot.toDouble(ok); 969 return tot.toDouble(ok);
968} 970}
969QString KLocale::decimalSymbol() const 971QString KLocale::decimalSymbol() const
970{ 972{
971 973
972 return m_decimalSymbol; 974 return m_decimalSymbol;
973} 975}
974 976
975QString KLocale::thousandsSeparator() const 977QString KLocale::thousandsSeparator() const
976{ 978{
977 979
978 return m_thousandsSeparator; 980 return m_thousandsSeparator;
979} 981}
980QString KLocale::positiveSign() const 982QString KLocale::positiveSign() const
981{ 983{
982 return m_positiveSign; 984 return m_positiveSign;
983} 985}
984 986
985QString KLocale::negativeSign() const 987QString KLocale::negativeSign() const
986{ 988{
987 return m_negativeSign; 989 return m_negativeSign;
988} 990}
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index 5783530..be9442c 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -1,118 +1,118 @@
1#ifndef MINIKDE_KLOCALE_H 1#ifndef MINIKDE_KLOCALE_H
2#define MINIKDE_KLOCALE_H 2#define MINIKDE_KLOCALE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qdatetime.h> 6#include <qdatetime.h>
7#include <qdict.h> 7#include <qdict.h>
8 8
9#ifndef I18N_NOOP 9#ifndef I18N_NOOP
10#define I18N_NOOP(x) (x) 10#define I18N_NOOP(x) (x)
11#endif 11#endif
12 12
13class KCalendarSystem; 13class KCalendarSystem;
14void setLocaleDict( QDict<QString> * dict ); 14void setLocaleDict( QDict<QString> * dict );
15QString i18n(const char *text); 15QString i18n(const char *text);
16QString i18n(const char *hint, const char *text); 16QString i18n(const char *hint, const char *text);
17QString i18n(const char *text1, const char *textn, int num); 17QString i18n(const char *text1, const char *textn, int num);
18 18
19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict 19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict
20// with our i18n method. we use uic -tr tr2i18n to redirect 20// with our i18n method. we use uic -tr tr2i18n to redirect
21// to the right i18n() function 21// to the right i18n() function
22inline QString tr2i18n(const char* message, const char* =0) { 22inline QString tr2i18n(const char* message, const char* =0) {
23 return i18n( message); 23 return i18n( message);
24} 24}
25 25
26class KLocale 26class KLocale
27{ 27{
28 public: 28 public:
29 KLocale(); 29 KLocale();
30 30
31 QString formatNumber(double num, int precision = -1) const; 31 QString formatNumber(double num, int precision = -1) const;
32 QString formatNumber(const QString &numStr) const; 32 QString formatNumber(const QString &numStr) const;
33 double readNumber(const QString &numStr, bool * ok = 0) const; 33 double readNumber(const QString &numStr, bool * ok = 0) const;
34 34
35 QString decimalSymbol() const; 35 QString decimalSymbol() const;
36 QString thousandsSeparator() const; 36 QString thousandsSeparator() const;
37 QString positiveSign() const; 37 QString positiveSign() const;
38 QString negativeSign() const; 38 QString negativeSign() const;
39 39
40 40
41 QString translate( const char *index ) const; 41 QString translate( const char *index ) const;
42 QString translate( const char *index, const char *fallback) const; 42 QString translate( const char *index, const char *fallback) const;
43 43
44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; 44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 };
45 45
46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; 46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const;
47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const; 48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const;
49 QString formatDateTime(const QDateTime &pDateTime, 49 QString formatDateTime(const QDateTime &pDateTime,
50 bool shortFormat, 50 bool shortFormat,
51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
52 52
53 QDate readDate(const QString &str, bool* ok = 0) const; 53 QDate readDate(const QString &str, bool* ok = 0) const;
54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; 54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
55 QTime readTime(const QString &str, bool* ok = 0) const; 55 QTime readTime(const QString &str, bool* ok = 0) const;
56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
57 57
58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
59 59
60 bool use12Clock() const; 60 bool use12Clock() const;
61 bool weekStartsMonday() const; 61 bool weekStartsMonday() const;
62 int weekStartDay() const; 62 int weekStartDay() const;
63 63
64 QString weekDayName(int,bool=false) const; 64 QString weekDayName(int,bool=false) const;
65 QString monthName(int,bool=false) const; 65 QString monthName(int,bool=false) const;
66 66
67 QString country() const; 67 QString country() const;
68 68
69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; 69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; 70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; 71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const;
72 72
73 void insertCatalogue ( const QString & ); 73 void insertCatalogue ( const QString & );
74 74
75 KCalendarSystem *calendar(); 75 KCalendarSystem *calendar();
76 void setHore24Format ( bool ); 76 void setHore24Format ( bool );
77 void setWeekStartMonday( bool ); 77 void setWeekStartMonday( bool );
78 void setIntDateFormat( IntDateFormat ); 78 void setIntDateFormat( IntDateFormat );
79 void setIntTimeFormat( IntDateFormat ); 79 void setIntTimeFormat( IntDateFormat );
80 IntDateFormat getIntDateFormat( ); 80 IntDateFormat getIntDateFormat( );
81 IntDateFormat getIntTimeFormat( ); 81 IntDateFormat getIntTimeFormat( );
82 void setLanguage( int ); 82 void setLanguage( int );
83 void setDateFormat( QString ); 83 void setDateFormat( QString );
84 void setDateFormatShort( QString ); 84 void setDateFormatShort( QString );
85 85
86 QString m_decimalSymbol; 86 QString m_decimalSymbol;
87 QString m_thousandsSeparator; 87 QString m_thousandsSeparator;
88 QString m_currencySymbol; 88 QString m_currencySymbol;
89 QString m_monetaryDecimalSymbol; 89 QString m_monetaryDecimalSymbol;
90 QString m_monetaryThousandsSeparator; 90 QString m_monetaryThousandsSeparator;
91 QString m_positiveSign; 91 QString m_positiveSign;
92 QString m_negativeSign; 92 QString m_negativeSign;
93 93
94 int timezoneOffset( QString ); 94 int timezoneOffset( QString );
95 QStringList timeZoneList() const; 95 QStringList timeZoneList() const;
96 void setDaylightSaving( bool, int , int ); 96 void setDaylightSaving( bool, int , int );
97 int localTimeOffset(const QDateTime &); 97 int localTimeOffset(const QDateTime &);
98 void setTimezone( const QString &timeZone ); 98 void setTimezone( const QString &timeZone , bool oddTZ);
99 private: 99 private:
100 QTime readTime(const QString &str, bool seconds, bool *ok) const; 100 QTime readTime(const QString &str, bool seconds, bool *ok) const;
101 QDate readDate(const QString &str, bool shortFormat, bool *ok) const; 101 QDate readDate(const QString &str, bool shortFormat, bool *ok) const;
102 KCalendarSystem *mCalendarSystem; 102 KCalendarSystem *mCalendarSystem;
103 bool mWeekStartsMonday; 103 bool mWeekStartsMonday;
104 bool mHourF24Format; 104 bool mHourF24Format;
105 IntDateFormat mIntDateFormat; 105 IntDateFormat mIntDateFormat;
106 IntDateFormat mIntTimeFormat; 106 IntDateFormat mIntTimeFormat;
107 int mLanguage; 107 int mLanguage;
108 QString mDateFormat; 108 QString mDateFormat;
109 QString mDateFormatShort; 109 QString mDateFormatShort;
110 QStringList mTimeZoneList; 110 QStringList mTimeZoneList;
111 bool daylightEnabled; 111 bool daylightEnabled;
112 int mDaylightTZoffset; 112 int mDaylightTZoffset;
113 int mNondaylightTZoffset; 113 int mNondaylightTZoffset;
114 bool mSouthDaylight; 114 bool mSouthDaylight;
115 int daylightStart, daylightEnd, mTimeZoneOffset; 115 int daylightStart, daylightEnd, mTimeZoneOffset;
116}; 116};
117 117
118#endif 118#endif