summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp58
-rw-r--r--noncore/settings/netsystemtime/ntp.h4
-rw-r--r--noncore/settings/netsystemtime/ntpbase.ui4
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.control2
-rw-r--r--noncore/settings/netsystemtime/settime.cpp2
5 files changed, 41 insertions, 29 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 364609d..bcbf7a1 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -1,272 +1,282 @@
1#include "ntp.h" 1#include "ntp.h"
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qregexp.h> 3#include <qregexp.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qtable.h> 5#include <qtable.h>
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qsocket.h> 7#include <qsocket.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qspinbox.h> 9#include <qspinbox.h>
10#include <qmessagebox.h> 10#include <qmessagebox.h>
11#include <qmultilineedit.h> 11#include <qmultilineedit.h>
12#include <opie/oprocess.h> 12#include <opie/oprocess.h>
13#include <qpe/config.h> 13#include <qpe/config.h>
14#include <qpe/global.h> 14#include <qpe/global.h>
15#include <qpe/timeconversion.h> 15#include <qpe/timeconversion.h>
16#include <qpe/tzselect.h> 16#include <qpe/tzselect.h>
17#include <qpe/timestring.h> 17#include <qpe/timestring.h>
18#include <qpe/qpedialog.h> 18#include <qpe/qpedialog.h>
19#include <sys/time.h> 19#include <sys/time.h>
20#include <time.h> 20#include <time.h>
21#include <stdlib.h> 21#include <stdlib.h>
22 22
23 23
24Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 24Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
25 : SetDateTime( parent, name, fl ) 25 : SetDateTime( parent, name, fl )
26{ 26{
27 27
28 Config ntpSrvs("/etc/ntpservers",Config::File); 28 Config ntpSrvs("/etc/ntpservers",Config::File);
29 ntpSrvs.setGroup("servers"); 29 ntpSrvs.setGroup("servers");
30 int srvCount = ntpSrvs.readNumEntry("count", 0 ); 30 int srvCount = ntpSrvs.readNumEntry("count", 0 );
31 for (int i = 0; i < srvCount; i++) 31 for (int i = 0; i < srvCount; i++)
32 { 32 {
33 ntpSrvs.setGroup(QString::number(i)); 33 ntpSrvs.setGroup(QString::number(i));
34 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); 34 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") );
35 } 35 }
36 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); 36 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de"));
37 37
38 Config cfg("ntp",Config::User); 38 Config cfg("ntp",Config::User);
39 cfg.setGroup("settings"); 39 cfg.setGroup("settings");
40 // _maxOffset = cfg.readNumEntry("maxOffset",5); 40 // _maxOffset = cfg.readNumEntry("maxOffset",5);
41// _minLookupDiff = cfg.readNumEntry("minLookupDiff",10); 41// _minLookupDiff = cfg.readNumEntry("minLookupDiff",10);
42 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); 42 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) );
43 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); 43 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) );
44 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); 44 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
45 45
46 ntpTimer = new QTimer(this); 46 ntpTimer = new QTimer(this);
47 ntpTimer->start(SpinBoxNtpDelay->value()*100); 47 ntpTimer->start(SpinBoxNtpDelay->value()*1000*60);
48 48
49 ntpProcess = new OProcess( ); 49 ntpProcess = new OProcess( );
50 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), 50 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
51 SLOT(slotNtpDelayChanged(int)) ); 51 SLOT(slotNtpDelayChanged(int)) );
52 52
53 ntpSock = new QSocket( this ); 53 ntpSock = new QSocket( this );
54 connect( ntpSock, SIGNAL( error(int) ), 54 connect( ntpSock, SIGNAL( error(int) ),
55 SLOT(slotCheckNtp(int)) ); 55 SLOT(slotCheckNtp(int)) );
56 slotProbeNtpServer(); 56 slotProbeNtpServer();
57 57
58 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 58 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
59 this, SLOT(getNtpOutput(OProcess*,char*,int))); 59 this, SLOT(getNtpOutput(OProcess*,char*,int)));
60 connect ( ntpProcess, SIGNAL(processExited(OProcess*)), 60 connect ( ntpProcess, SIGNAL(processExited(OProcess*)),
61 this, SLOT(ntpFinished(OProcess*))); 61 this, SLOT(ntpFinished(OProcess*)));
62 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); 62 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp()));
63 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); 63 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime()));
64 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); 64 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime()));
65 slotCheckNtp(-1); 65 slotCheckNtp(-1);
66 readLookups(); 66 readLookups();
67} 67}
68 68
69Ntp::~Ntp() 69Ntp::~Ntp()
70{ 70{
71 delete ntpProcess; 71 delete ntpProcess;
72 Config ntpSrvs("/etc/ntpservers",Config::File); 72 Config ntpSrvs("/etc/ntpservers",Config::File);
73 ntpSrvs.setGroup("servers"); 73 ntpSrvs.setGroup("servers");
74 int srvCount = ComboNtpSrv->count(); 74 int srvCount = ComboNtpSrv->count();
75 ntpSrvs.writeEntry("count", srvCount); 75 ntpSrvs.writeEntry("count", srvCount);
76 for (int i = 0; i < srvCount; i++) 76 for (int i = 0; i < srvCount; i++)
77 { 77 {
78 ntpSrvs.setGroup(QString::number(i)); 78 ntpSrvs.setGroup(QString::number(i));
79 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); 79 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) );
80 } 80 }
81 Config cfg("ntp",Config::User); 81 Config cfg("ntp",Config::User);
82 cfg.setGroup("settings"); 82 cfg.setGroup("settings");
83 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); 83 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem());
84 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); 84 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() );
85 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); 85 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() );
86} 86}
87 87
88 88bool Ntp::ntpDelayElapsed()
89void Ntp::slotRunNtp()
90{ 89{
91 Config cfg("ntp",Config::User); 90 Config cfg("ntp",Config::User);
92 cfg.setGroup("lookups"); 91 cfg.setGroup("lookups");
93 int lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); 92 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
93 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60;
94}
94 95
95 if ( lookupDiff < SpinBoxNtpDelay->value()*60 ) 96QString Ntp::getNtpServer()
97{
98 return ComboNtpSrv->currentText();
99}
100
101void Ntp::slotRunNtp()
102{
103 if ( !ntpDelayElapsed() )
96 { 104 {
97 switch ( 105 switch (
98 QMessageBox::warning(this, tr("Run ntp?"), 106 QMessageBox::warning(this, tr("Run NTP?"),
99 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ 107 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+
100 QString::number(lookupDiff%60)+tr(" minutes elapsed since last loopup.")+ 108 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+
101 "<br>"+tr("Rerun ntp?"), 109 "<br>"+tr("Rerun NTP?"),
102 QMessageBox::Ok,QMessageBox::Cancel) 110 QMessageBox::Ok,QMessageBox::Cancel)
103 ) { 111 ) {
104 case QMessageBox::Ok: break; 112 case QMessageBox::Ok: break;
105 case QMessageBox::Cancel: return; 113 case QMessageBox::Cancel: return;
106 default: return; 114 default: return;
107 } 115 }
108 } 116 }
109 TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); 117 TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
110 MultiLineEditntpOutPut->append( "\n"+tr("Running:")+"\nntpdate "+ ComboNtpSrv->currentText()+"\n"); 118 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
111 ntpProcess->clearArguments(); 119 ntpProcess->clearArguments();
112 *ntpProcess << "ntpdate" << ComboNtpSrv->currentText(); 120 *ntpProcess << "ntpdate" << getNtpServer();
113 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 121 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
114 if ( !ret ) { 122 if ( !ret ) {
115 qDebug("Error while executing ntp"); 123 qDebug("Error while executing ntpdate");
124 ntpOutPut( tr("Error while executing ntpdate"));
116 } 125 }
117} 126}
118 127
119void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) 128void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
120{ 129{
121 QString lineStr, lineStrOld; 130 QString lineStr, lineStrOld;
122 lineStr = buffer; 131 lineStr = buffer;
123 lineStr=lineStr.left(buflen); 132 lineStr=lineStr.left(buflen);
124 if (lineStr!=lineStrOld) 133 if (lineStr!=lineStrOld)
125 { 134 {
126 MultiLineEditntpOutPut->append(lineStr); 135 ntpOutPut(lineStr);
127 _ntpOutput += lineStr; 136 _ntpOutput += lineStr;
128 } 137 }
129 lineStrOld = lineStr; 138 lineStrOld = lineStr;
130} 139}
131 140
132void Ntp::ntpFinished(OProcess*) 141void Ntp::ntpFinished(OProcess*)
133{ 142{
134 Config cfg("ntp",Config::User); 143 Config cfg("ntp",Config::User);
135 cfg.setGroup("lookups"); 144 cfg.setGroup("lookups");
136 int lastLookup = cfg.readNumEntry("time",0); 145 int lastLookup = cfg.readNumEntry("time",0);
137 int lookupCount = cfg.readNumEntry("count",-1); 146 int lookupCount = cfg.readNumEntry("count",-1);
138 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 147 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
139 cfg.writeEntry("time", time); 148 cfg.writeEntry("time", time);
140 cfg.setGroup("correction"); 149 cfg.setGroup("correction");
141 cfg.writeEntry("time", time); 150 cfg.writeEntry("time", time);
142 151
143 float timeShift = getTimeShift(); 152 float timeShift = getTimeShift();
144 if (timeShift == 0.0) return; 153 if (timeShift == 0.0) return;
145 int secsSinceLast = time - lastLookup; 154 int secsSinceLast = time - lastLookup;
146 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 155 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
147 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); 156 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
148 if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) 157 if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
149 { 158 {
150 lookupCount++; 159 lookupCount++;
151 cfg.writeEntry("count",lookupCount); 160 cfg.writeEntry("count",lookupCount);
152 cfg.setGroup("lookup_"+QString::number(lookupCount)); 161 cfg.setGroup("lookup_"+QString::number(lookupCount));
153 _shiftPerSec = timeShift / secsSinceLast; 162 _shiftPerSec = timeShift / secsSinceLast;
154// float nextCorr = _maxOffset / _shiftPerSec;
155 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 163 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
156 cfg.writeEntry("secsSinceLast",secsSinceLast); 164 cfg.writeEntry("secsSinceLast",secsSinceLast);
157 cfg.writeEntry("timeShift",QString::number(timeShift)); 165 cfg.writeEntry("timeShift",QString::number(timeShift));
158 } 166 }
159} 167}
160 168
161 169
162float Ntp::getTimeShift() 170float Ntp::getTimeShift()
163{ 171{
164 QString _offset = "offset"; 172 QString _offset = "offset";
165 QString _sec = "sec"; 173 QString _sec = "sec";
166 QRegExp _reOffset = QRegExp(_offset); 174 QRegExp _reOffset = QRegExp(_offset);
167 QRegExp _reEndOffset = QRegExp(_sec); 175 QRegExp _reEndOffset = QRegExp(_sec);
168 int posOffset = _reOffset.match( _ntpOutput ); 176 int posOffset = _reOffset.match( _ntpOutput );
169 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); 177 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset );
170 posOffset += _offset.length() + 1; 178 posOffset += _offset.length() + 1;
171 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); 179 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1);
172 qDebug("%s", _ntpOutput.latin1()); 180 qDebug("%s", _ntpOutput.latin1());
173 qDebug("diff = >%s<",diff.latin1()); 181 qDebug("diff = >%s<",diff.latin1());
174 return diff.toFloat(); 182 return diff.toFloat();
175} 183}
176 184
177void Ntp::readLookups() 185void Ntp::readLookups()
178{ 186{
179 Config cfg("ntp",Config::User); 187 Config cfg("ntp",Config::User);
180 cfg.setGroup("lookups"); 188 cfg.setGroup("lookups");
181 int lookupCount = cfg.readNumEntry("count",-1); 189 int lookupCount = cfg.readNumEntry("count",-1);
182 float last, shift, shiftPerSec; 190 float last, shift, shiftPerSec;
183 qDebug("lookupCount = %i",lookupCount); 191 qDebug("lookupCount = %i",lookupCount);
184 TableLookups->setNumCols( 3 ); 192 TableLookups->setNumCols( 3 );
185 TableLookups->setNumRows( lookupCount); 193 TableLookups->setNumRows( lookupCount);
186 TableLookups->horizontalHeader()->setLabel(1,"secsSinceLast"); 194 TableLookups->horizontalHeader()->setLabel(1,"secsSinceLast");
187 TableLookups->horizontalHeader()->setLabel(2,"timeShift"); 195 TableLookups->horizontalHeader()->setLabel(2,"timeShift");
188 TableLookups->horizontalHeader()->setLabel(0,"shift/s"); 196 TableLookups->horizontalHeader()->setLabel(0,"shift/s");
189 int cw = 50;//TableLookups->width()/4; 197 int cw = 50;//TableLookups->width()/4;
190 qDebug("column width %i",cw); 198 qDebug("column width %i",cw);
191 TableLookups->setColumnWidth( 0, cw+30 ); 199 TableLookups->setColumnWidth( 0, cw+30 );
192 TableLookups->setColumnWidth( 1, cw ); 200 TableLookups->setColumnWidth( 1, cw );
193 TableLookups->setColumnWidth( 2, cw ); 201 TableLookups->setColumnWidth( 2, cw );
194 TableLookups->sortColumn(0, false, true ); 202 TableLookups->sortColumn(0, false, true );
195 // TableLookups->setSorting( true ); 203 // TableLookups->setSorting( true );
196 for (int i=0; i < lookupCount; i++) 204 for (int i=0; i < lookupCount; i++)
197 { 205 {
198 cfg.setGroup("lookup_"+QString::number(i)); 206 cfg.setGroup("lookup_"+QString::number(i));
199 last = cfg.readEntry("secsSinceLast",0).toFloat(); 207 last = cfg.readEntry("secsSinceLast",0).toFloat();
200 shift = QString(cfg.readEntry("timeShift",0)).toFloat(); 208 shift = QString(cfg.readEntry("timeShift",0)).toFloat();
201 // qDebug("%i last %f",i,last); 209 // qDebug("%i last %f",i,last);
202 // qDebug("%i shift %f",i,shift); 210 // qDebug("%i shift %f",i,shift);
203 shiftPerSec = shift / last; 211 shiftPerSec = shift / last;
204 _shiftPerSec += shiftPerSec; 212 _shiftPerSec += shiftPerSec;
205 TableLookups->setText( i,0,QString::number(shiftPerSec)); 213 TableLookups->setText( i,0,QString::number(shiftPerSec));
206 TableLookups->setText( i,2,QString::number(shift)); 214 TableLookups->setText( i,2,QString::number(shift));
207 TableLookups->setText( i,1,QString::number(last)); 215 TableLookups->setText( i,1,QString::number(last));
208 } 216 }
209 _shiftPerSec /= lookupCount+1; 217 _shiftPerSec /= lookupCount+1;
210 TextLabelShift->setText(QString::number(_shiftPerSec)+tr(" seconds")); 218 TextLabelShift->setText(QString::number(_shiftPerSec)+tr(" seconds"));
211} 219}
212 220
213void Ntp::preditctTime() 221void Ntp::preditctTime()
214{ 222{
215 qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1());
216 Config cfg("ntp",Config::User); 223 Config cfg("ntp",Config::User);
217 cfg.setGroup("lookups"); 224 cfg.setGroup("lookups");
218 int lastTime = cfg.readNumEntry("time",0); 225 int lastTime = cfg.readNumEntry("time",0);
219 setenv( "TZ", tz->currentZone(), 1 ); 226 setenv( "TZ", tz->currentZone(), 1 );
220 int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); 227 int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
221 int corr = int((now - lastTime) * _shiftPerSec); 228 int corr = int((now - lastTime) * _shiftPerSec);
222 TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); 229 TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds"));
223 predictedTime = QDateTime::currentDateTime().addSecs(corr); 230 predictedTime = QDateTime::currentDateTime().addSecs(corr);
224 TextLabelPredTime->setText(predictedTime.toString()); 231 TextLabelPredTime->setText(predictedTime.toString());
225 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); 232 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>");
226} 233}
227 234
228void Ntp::setPredictTime() 235void Ntp::setPredictTime()
229{ 236{
230 preditctTime(); 237 preditctTime();
231 setTime( predictedTime ); 238 setTime( predictedTime );
232} 239}
233 240
234void Ntp::slotCheckNtp(int i) 241void Ntp::slotCheckNtp(int i)
235{ 242{
236 if (i == 0) 243 if (i == 0)
237 { 244 {
238 TextLabelMainPredTime->hide(); 245 TextLabelMainPredTime->hide();
239 ButtonSetTime->setText( tr("Get time from network") ); 246 ButtonSetTime->setText( tr("Get time from network") );
240 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); 247 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
241 Config cfg("ntp",Config::User); 248 if ( ntpDelayElapsed() )
242 cfg.setGroup("lookups");
243 int lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
244 if ( lookupDiff > SpinBoxNtpDelay->value()*60 )
245 { 249 {
250 slotRunNtp();
246 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); 251 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) );
247 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); 252 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) );
248 }else{ 253 }else{
249 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); 254 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
250 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 255 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
251 } 256 }
252 }else{ 257 }else{
253 preditctTime(); 258 preditctTime();
254 ButtonSetTime->setText( tr("Set predicted time") ); 259 ButtonSetTime->setText( tr("Set predicted time") );
260 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
255 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); 261 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
256 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 262 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
257 } 263 }
264 //ntpTimer->start(SpinBoxNtpDelay->value()*1000*60);
258} 265}
259 266
260void Ntp::slotProbeNtpServer() 267void Ntp::slotProbeNtpServer()
261{ 268{
262 Config cfg("ntp",Config::User); 269 if ( ntpDelayElapsed() )
263 cfg.setGroup("lookups"); 270 ntpSock->connectToHost( getNtpServer() ,123);
264 int lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
265 if ( lookupDiff > SpinBoxNtpDelay->value()*60 )
266 ntpSock->connectToHost( ComboNtpSrv->currentText() ,123);
267} 271}
268 272
269void Ntp::slotNtpDelayChanged(int delay) 273void Ntp::slotNtpDelayChanged(int delay)
270{ 274{
271 ntpTimer->changeInterval( delay*100 ); 275 ntpTimer->changeInterval( delay*1000*60 );
276}
277
278void Ntp::ntpOutPut(QString out)
279{
280 MultiLineEditntpOutPut->append(out);
281 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
272} 282}
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h
index 7cc309f..c78dc55 100644
--- a/noncore/settings/netsystemtime/ntp.h
+++ b/noncore/settings/netsystemtime/ntp.h
@@ -1,43 +1,47 @@
1#ifndef NTP_H 1#ifndef NTP_H
2#define NTP_H 2#define NTP_H
3#include "settime.h" 3#include "settime.h"
4#include <qdatetime.h> 4#include <qdatetime.h>
5 5
6class OProcess; 6class OProcess;
7class QString; 7class QString;
8class QTimer; 8class QTimer;
9class QSocket; 9class QSocket;
10 10
11class Ntp : public SetDateTime 11class Ntp : public SetDateTime
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
14 14
15public: 15public:
16 Ntp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 16 Ntp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
17 ~Ntp(); 17 ~Ntp();
18 18
19protected: 19protected:
20 QDateTime predictedTime; 20 QDateTime predictedTime;
21 21
22 22
23private: 23private:
24 QString _ntpOutput; 24 QString _ntpOutput;
25 float _shiftPerSec; 25 float _shiftPerSec;
26 int _lookupDiff;
26 OProcess *ntpProcess; 27 OProcess *ntpProcess;
27 QTimer *ntpTimer; 28 QTimer *ntpTimer;
28 QSocket *ntpSock; 29 QSocket *ntpSock;
29 30
30 float getTimeShift(); 31 float getTimeShift();
31 void readLookups(); 32 void readLookups();
33 void ntpOutPut(QString);
34 bool ntpDelayElapsed();
35 QString getNtpServer();
32private slots: 36private slots:
33 void slotRunNtp(); 37 void slotRunNtp();
34 void getNtpOutput(OProcess *proc, char *buffer, int buflen); 38 void getNtpOutput(OProcess *proc, char *buffer, int buflen);
35 void ntpFinished(OProcess*); 39 void ntpFinished(OProcess*);
36 void preditctTime(); 40 void preditctTime();
37 void slotCheckNtp(int); 41 void slotCheckNtp(int);
38 void setPredictTime(); 42 void setPredictTime();
39 void slotProbeNtpServer(); 43 void slotProbeNtpServer();
40 void slotNtpDelayChanged(int); 44 void slotNtpDelayChanged(int);
41}; 45};
42 46
43#endif 47#endif
diff --git a/noncore/settings/netsystemtime/ntpbase.ui b/noncore/settings/netsystemtime/ntpbase.ui
index 4e10fd2..a83dc93 100644
--- a/noncore/settings/netsystemtime/ntpbase.ui
+++ b/noncore/settings/netsystemtime/ntpbase.ui
@@ -1,777 +1,777 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>NtpBase</class> 2<class>NtpBase</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>NtpBase</cstring> 7 <cstring>NtpBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>331</width> 14 <width>328</width>
15 <height>426</height> 15 <height>411</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Network Time</string> 20 <string>Network Time</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <grid> 28 <grid>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>2</number> 31 <number>2</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>2</number> 35 <number>2</number>
36 </property> 36 </property>
37 <widget row="0" column="0" > 37 <widget row="0" column="0" >
38 <class>QTabWidget</class> 38 <class>QTabWidget</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>TabWidgetMain</cstring> 41 <cstring>TabWidgetMain</cstring>
42 </property> 42 </property>
43 <property> 43 <property>
44 <name>layoutMargin</name> 44 <name>layoutMargin</name>
45 </property> 45 </property>
46 <property> 46 <property>
47 <name>layoutSpacing</name> 47 <name>layoutSpacing</name>
48 </property> 48 </property>
49 <widget> 49 <widget>
50 <class>QWidget</class> 50 <class>QWidget</class>
51 <property stdset="1"> 51 <property stdset="1">
52 <name>name</name> 52 <name>name</name>
53 <cstring>tabMain</cstring> 53 <cstring>tabMain</cstring>
54 </property> 54 </property>
55 <attribute> 55 <attribute>
56 <name>title</name> 56 <name>title</name>
57 <string>Main</string> 57 <string>Main</string>
58 </attribute> 58 </attribute>
59 <grid> 59 <grid>
60 <property stdset="1"> 60 <property stdset="1">
61 <name>margin</name> 61 <name>margin</name>
62 <number>2</number> 62 <number>2</number>
63 </property> 63 </property>
64 <property stdset="1"> 64 <property stdset="1">
65 <name>spacing</name> 65 <name>spacing</name>
66 <number>2</number> 66 <number>2</number>
67 </property> 67 </property>
68 <widget row="0" column="0" > 68 <widget row="0" column="0" >
69 <class>QFrame</class> 69 <class>QFrame</class>
70 <property stdset="1"> 70 <property stdset="1">
71 <name>name</name> 71 <name>name</name>
72 <cstring>FrameSystemTime</cstring> 72 <cstring>FrameSystemTime</cstring>
73 </property> 73 </property>
74 <property stdset="1"> 74 <property stdset="1">
75 <name>frameShape</name> 75 <name>frameShape</name>
76 <enum>StyledPanel</enum> 76 <enum>StyledPanel</enum>
77 </property> 77 </property>
78 <property stdset="1"> 78 <property stdset="1">
79 <name>frameShadow</name> 79 <name>frameShadow</name>
80 <enum>Raised</enum> 80 <enum>Raised</enum>
81 </property> 81 </property>
82 </widget> 82 </widget>
83 </grid> 83 </grid>
84 </widget> 84 </widget>
85 <widget> 85 <widget>
86 <class>QWidget</class> 86 <class>QWidget</class>
87 <property stdset="1"> 87 <property stdset="1">
88 <name>name</name> 88 <name>name</name>
89 <cstring>tabNtp</cstring> 89 <cstring>tabNtp</cstring>
90 </property> 90 </property>
91 <attribute> 91 <attribute>
92 <name>title</name> 92 <name>title</name>
93 <string>NTP</string> 93 <string>NTP</string>
94 </attribute> 94 </attribute>
95 <grid> 95 <grid>
96 <property stdset="1"> 96 <property stdset="1">
97 <name>margin</name> 97 <name>margin</name>
98 <number>1</number> 98 <number>1</number>
99 </property> 99 </property>
100 <property stdset="1"> 100 <property stdset="1">
101 <name>spacing</name> 101 <name>spacing</name>
102 <number>2</number> 102 <number>2</number>
103 </property> 103 </property>
104 <widget row="1" column="0" > 104 <widget row="1" column="0" >
105 <class>QPushButton</class> 105 <class>QPushButton</class>
106 <property stdset="1"> 106 <property stdset="1">
107 <name>name</name> 107 <name>name</name>
108 <cstring>runNtp</cstring> 108 <cstring>runNtp</cstring>
109 </property> 109 </property>
110 <property stdset="1"> 110 <property stdset="1">
111 <name>text</name> 111 <name>text</name>
112 <string>Get time from network</string> 112 <string>Get time from network</string>
113 </property> 113 </property>
114 </widget> 114 </widget>
115 <widget row="0" column="0" > 115 <widget row="0" column="0" >
116 <class>QFrame</class> 116 <class>QFrame</class>
117 <property stdset="1"> 117 <property stdset="1">
118 <name>name</name> 118 <name>name</name>
119 <cstring>FrameNtp</cstring> 119 <cstring>FrameNtp</cstring>
120 </property> 120 </property>
121 <property stdset="1"> 121 <property stdset="1">
122 <name>frameShape</name> 122 <name>frameShape</name>
123 <enum>StyledPanel</enum> 123 <enum>StyledPanel</enum>
124 </property> 124 </property>
125 <property stdset="1"> 125 <property stdset="1">
126 <name>frameShadow</name> 126 <name>frameShadow</name>
127 <enum>Raised</enum> 127 <enum>Raised</enum>
128 </property> 128 </property>
129 <property> 129 <property>
130 <name>layoutMargin</name> 130 <name>layoutMargin</name>
131 </property> 131 </property>
132 <property> 132 <property>
133 <name>layoutSpacing</name> 133 <name>layoutSpacing</name>
134 </property> 134 </property>
135 <grid> 135 <grid>
136 <property stdset="1"> 136 <property stdset="1">
137 <name>margin</name> 137 <name>margin</name>
138 <number>2</number> 138 <number>2</number>
139 </property> 139 </property>
140 <property stdset="1"> 140 <property stdset="1">
141 <name>spacing</name> 141 <name>spacing</name>
142 <number>2</number> 142 <number>2</number>
143 </property> 143 </property>
144 <widget row="0" column="0" > 144 <widget row="0" column="0" >
145 <class>QLayoutWidget</class> 145 <class>QLayoutWidget</class>
146 <property stdset="1"> 146 <property stdset="1">
147 <name>name</name> 147 <name>name</name>
148 <cstring>Layout4</cstring> 148 <cstring>Layout4</cstring>
149 </property> 149 </property>
150 <vbox> 150 <vbox>
151 <property stdset="1"> 151 <property stdset="1">
152 <name>margin</name> 152 <name>margin</name>
153 <number>0</number> 153 <number>0</number>
154 </property> 154 </property>
155 <property stdset="1"> 155 <property stdset="1">
156 <name>spacing</name> 156 <name>spacing</name>
157 <number>6</number> 157 <number>6</number>
158 </property> 158 </property>
159 <widget> 159 <widget>
160 <class>QLabel</class> 160 <class>QLabel</class>
161 <property stdset="1"> 161 <property stdset="1">
162 <name>name</name> 162 <name>name</name>
163 <cstring>TextLabel1</cstring> 163 <cstring>TextLabel1</cstring>
164 </property> 164 </property>
165 <property stdset="1"> 165 <property stdset="1">
166 <name>autoMask</name> 166 <name>autoMask</name>
167 <bool>false</bool> 167 <bool>false</bool>
168 </property> 168 </property>
169 <property stdset="1"> 169 <property stdset="1">
170 <name>text</name> 170 <name>text</name>
171 <string>Start Time:</string> 171 <string>Start Time:</string>
172 </property> 172 </property>
173 </widget> 173 </widget>
174 <widget> 174 <widget>
175 <class>QLabel</class> 175 <class>QLabel</class>
176 <property stdset="1"> 176 <property stdset="1">
177 <name>name</name> 177 <name>name</name>
178 <cstring>TextLabelStartTime</cstring> 178 <cstring>TextLabelStartTime</cstring>
179 </property> 179 </property>
180 <property stdset="1"> 180 <property stdset="1">
181 <name>text</name> 181 <name>text</name>
182 <string>nan</string> 182 <string>nan</string>
183 </property> 183 </property>
184 </widget> 184 </widget>
185 <widget> 185 <widget>
186 <class>QLabel</class> 186 <class>QLabel</class>
187 <property stdset="1"> 187 <property stdset="1">
188 <name>name</name> 188 <name>name</name>
189 <cstring>TextLabel3</cstring> 189 <cstring>TextLabel3</cstring>
190 </property> 190 </property>
191 <property stdset="1"> 191 <property stdset="1">
192 <name>text</name> 192 <name>text</name>
193 <string>Time Shift:</string> 193 <string>Time Shift:</string>
194 </property> 194 </property>
195 </widget> 195 </widget>
196 <widget> 196 <widget>
197 <class>QLabel</class> 197 <class>QLabel</class>
198 <property stdset="1"> 198 <property stdset="1">
199 <name>name</name> 199 <name>name</name>
200 <cstring>TextLabelTimeShift</cstring> 200 <cstring>TextLabelTimeShift</cstring>
201 </property> 201 </property>
202 <property stdset="1"> 202 <property stdset="1">
203 <name>text</name> 203 <name>text</name>
204 <string>nan</string> 204 <string>nan</string>
205 </property> 205 </property>
206 </widget> 206 </widget>
207 <widget> 207 <widget>
208 <class>QLabel</class> 208 <class>QLabel</class>
209 <property stdset="1"> 209 <property stdset="1">
210 <name>name</name> 210 <name>name</name>
211 <cstring>TextLabel5</cstring> 211 <cstring>TextLabel5</cstring>
212 </property> 212 </property>
213 <property stdset="1"> 213 <property stdset="1">
214 <name>text</name> 214 <name>text</name>
215 <string>New Time:</string> 215 <string>New Time:</string>
216 </property> 216 </property>
217 </widget> 217 </widget>
218 <widget> 218 <widget>
219 <class>QLabel</class> 219 <class>QLabel</class>
220 <property stdset="1"> 220 <property stdset="1">
221 <name>name</name> 221 <name>name</name>
222 <cstring>TextLabelNewTime</cstring> 222 <cstring>TextLabelNewTime</cstring>
223 </property> 223 </property>
224 <property stdset="1"> 224 <property stdset="1">
225 <name>text</name> 225 <name>text</name>
226 <string>nan</string> 226 <string>nan</string>
227 </property> 227 </property>
228 </widget> 228 </widget>
229 <spacer> 229 <spacer>
230 <property> 230 <property>
231 <name>name</name> 231 <name>name</name>
232 <cstring>Spacer1</cstring> 232 <cstring>Spacer1</cstring>
233 </property> 233 </property>
234 <property stdset="1"> 234 <property stdset="1">
235 <name>orientation</name> 235 <name>orientation</name>
236 <enum>Vertical</enum> 236 <enum>Vertical</enum>
237 </property> 237 </property>
238 <property stdset="1"> 238 <property stdset="1">
239 <name>sizeType</name> 239 <name>sizeType</name>
240 <enum>Expanding</enum> 240 <enum>Expanding</enum>
241 </property> 241 </property>
242 <property> 242 <property>
243 <name>sizeHint</name> 243 <name>sizeHint</name>
244 <size> 244 <size>
245 <width>20</width> 245 <width>20</width>
246 <height>20</height> 246 <height>20</height>
247 </size> 247 </size>
248 </property> 248 </property>
249 </spacer> 249 </spacer>
250 </vbox> 250 </vbox>
251 </widget> 251 </widget>
252 <widget row="1" column="0" > 252 <widget row="1" column="0" >
253 <class>QMultiLineEdit</class> 253 <class>QMultiLineEdit</class>
254 <property stdset="1"> 254 <property stdset="1">
255 <name>name</name> 255 <name>name</name>
256 <cstring>MultiLineEditntpOutPut</cstring> 256 <cstring>MultiLineEditntpOutPut</cstring>
257 </property> 257 </property>
258 <property stdset="1"> 258 <property stdset="1">
259 <name>font</name> 259 <name>font</name>
260 <font> 260 <font>
261 <pointsize>7</pointsize> 261 <pointsize>7</pointsize>
262 </font> 262 </font>
263 </property> 263 </property>
264 <property stdset="1"> 264 <property stdset="1">
265 <name>wordWrap</name> 265 <name>wordWrap</name>
266 <enum>WidgetWidth</enum> 266 <enum>WidgetWidth</enum>
267 </property> 267 </property>
268 <property stdset="1"> 268 <property stdset="1">
269 <name>text</name> 269 <name>text</name>
270 <string></string> 270 <string></string>
271 </property> 271 </property>
272 </widget> 272 </widget>
273 </grid> 273 </grid>
274 </widget> 274 </widget>
275 </grid> 275 </grid>
276 </widget> 276 </widget>
277 <widget> 277 <widget>
278 <class>QWidget</class> 278 <class>QWidget</class>
279 <property stdset="1"> 279 <property stdset="1">
280 <name>name</name> 280 <name>name</name>
281 <cstring>tab</cstring> 281 <cstring>tab</cstring>
282 </property> 282 </property>
283 <attribute> 283 <attribute>
284 <name>title</name> 284 <name>title</name>
285 <string>Predict</string> 285 <string>Predict</string>
286 </attribute> 286 </attribute>
287 <grid> 287 <grid>
288 <property stdset="1"> 288 <property stdset="1">
289 <name>margin</name> 289 <name>margin</name>
290 <number>5</number> 290 <number>5</number>
291 </property> 291 </property>
292 <property stdset="1"> 292 <property stdset="1">
293 <name>spacing</name> 293 <name>spacing</name>
294 <number>6</number> 294 <number>6</number>
295 </property> 295 </property>
296 <widget row="0" column="0" > 296 <widget row="0" column="0" >
297 <class>QTable</class> 297 <class>QTable</class>
298 <property stdset="1"> 298 <property stdset="1">
299 <name>name</name> 299 <name>name</name>
300 <cstring>TableLookups</cstring> 300 <cstring>TableLookups</cstring>
301 </property> 301 </property>
302 <property stdset="1"> 302 <property stdset="1">
303 <name>numRows</name> 303 <name>numRows</name>
304 <number>2</number> 304 <number>2</number>
305 </property> 305 </property>
306 <property stdset="1"> 306 <property stdset="1">
307 <name>numCols</name> 307 <name>numCols</name>
308 <number>2</number> 308 <number>2</number>
309 </property> 309 </property>
310 </widget> 310 </widget>
311 <widget row="1" column="0" > 311 <widget row="1" column="0" >
312 <class>QLayoutWidget</class> 312 <class>QLayoutWidget</class>
313 <property stdset="1"> 313 <property stdset="1">
314 <name>name</name> 314 <name>name</name>
315 <cstring>Layout9</cstring> 315 <cstring>Layout9</cstring>
316 </property> 316 </property>
317 <grid> 317 <grid>
318 <property stdset="1"> 318 <property stdset="1">
319 <name>margin</name> 319 <name>margin</name>
320 <number>0</number> 320 <number>0</number>
321 </property> 321 </property>
322 <property stdset="1"> 322 <property stdset="1">
323 <name>spacing</name> 323 <name>spacing</name>
324 <number>6</number> 324 <number>6</number>
325 </property> 325 </property>
326 <widget row="0" column="1" > 326 <widget row="0" column="1" >
327 <class>QLabel</class> 327 <class>QLabel</class>
328 <property stdset="1"> 328 <property stdset="1">
329 <name>name</name> 329 <name>name</name>
330 <cstring>TextLabelShift</cstring> 330 <cstring>TextLabelShift</cstring>
331 </property> 331 </property>
332 <property stdset="1"> 332 <property stdset="1">
333 <name>text</name> 333 <name>text</name>
334 <string>nan</string> 334 <string>nan</string>
335 </property> 335 </property>
336 </widget> 336 </widget>
337 <widget row="1" column="0" > 337 <widget row="1" column="0" >
338 <class>QLabel</class> 338 <class>QLabel</class>
339 <property stdset="1"> 339 <property stdset="1">
340 <name>name</name> 340 <name>name</name>
341 <cstring>TextLabel4</cstring> 341 <cstring>TextLabel4</cstring>
342 </property> 342 </property>
343 <property stdset="1"> 343 <property stdset="1">
344 <name>text</name> 344 <name>text</name>
345 <string>Esimated Shift:</string> 345 <string>Esimated Shift:</string>
346 </property> 346 </property>
347 </widget> 347 </widget>
348 <widget row="1" column="1" > 348 <widget row="1" column="1" >
349 <class>QLabel</class> 349 <class>QLabel</class>
350 <property stdset="1"> 350 <property stdset="1">
351 <name>name</name> 351 <name>name</name>
352 <cstring>TextLabelEstimatedShift</cstring> 352 <cstring>TextLabelEstimatedShift</cstring>
353 </property> 353 </property>
354 <property stdset="1"> 354 <property stdset="1">
355 <name>text</name> 355 <name>text</name>
356 <string>nan</string> 356 <string>nan</string>
357 </property> 357 </property>
358 </widget> 358 </widget>
359 <widget row="2" column="0" > 359 <widget row="2" column="0" >
360 <class>QLabel</class> 360 <class>QLabel</class>
361 <property stdset="1"> 361 <property stdset="1">
362 <name>name</name> 362 <name>name</name>
363 <cstring>TextLabel3_2</cstring> 363 <cstring>TextLabel3_2</cstring>
364 </property> 364 </property>
365 <property stdset="1"> 365 <property stdset="1">
366 <name>text</name> 366 <name>text</name>
367 <string>Predicted Time:</string> 367 <string>Predicted Time:</string>
368 </property> 368 </property>
369 </widget> 369 </widget>
370 <widget row="0" column="0" > 370 <widget row="0" column="0" >
371 <class>QLabel</class> 371 <class>QLabel</class>
372 <property stdset="1"> 372 <property stdset="1">
373 <name>name</name> 373 <name>name</name>
374 <cstring>Mean_shift_label</cstring> 374 <cstring>Mean_shift_label</cstring>
375 </property> 375 </property>
376 <property stdset="1"> 376 <property stdset="1">
377 <name>text</name> 377 <name>text</name>
378 <string>Mean shift:</string> 378 <string>Mean shift:</string>
379 </property> 379 </property>
380 </widget> 380 </widget>
381 <widget row="2" column="1" > 381 <widget row="2" column="1" >
382 <class>QLabel</class> 382 <class>QLabel</class>
383 <property stdset="1"> 383 <property stdset="1">
384 <name>name</name> 384 <name>name</name>
385 <cstring>TextLabelPredTime</cstring> 385 <cstring>TextLabelPredTime</cstring>
386 </property> 386 </property>
387 <property stdset="1"> 387 <property stdset="1">
388 <name>text</name> 388 <name>text</name>
389 <string>nan</string> 389 <string>nan</string>
390 </property> 390 </property>
391 </widget> 391 </widget>
392 </grid> 392 </grid>
393 </widget> 393 </widget>
394 <widget row="2" column="0" > 394 <widget row="2" column="0" >
395 <class>QLayoutWidget</class> 395 <class>QLayoutWidget</class>
396 <property stdset="1"> 396 <property stdset="1">
397 <name>name</name> 397 <name>name</name>
398 <cstring>Layout11</cstring> 398 <cstring>Layout11</cstring>
399 </property> 399 </property>
400 <hbox> 400 <hbox>
401 <property stdset="1"> 401 <property stdset="1">
402 <name>margin</name> 402 <name>margin</name>
403 <number>0</number> 403 <number>0</number>
404 </property> 404 </property>
405 <property stdset="1"> 405 <property stdset="1">
406 <name>spacing</name> 406 <name>spacing</name>
407 <number>6</number> 407 <number>6</number>
408 </property> 408 </property>
409 <widget> 409 <widget>
410 <class>QPushButton</class> 410 <class>QPushButton</class>
411 <property stdset="1"> 411 <property stdset="1">
412 <name>name</name> 412 <name>name</name>
413 <cstring>PushButtonSetPredTime</cstring> 413 <cstring>PushButtonSetPredTime</cstring>
414 </property> 414 </property>
415 <property stdset="1"> 415 <property stdset="1">
416 <name>text</name> 416 <name>text</name>
417 <string>Set predicted time</string> 417 <string>Set predicted time</string>
418 </property> 418 </property>
419 </widget> 419 </widget>
420 <widget> 420 <widget>
421 <class>QPushButton</class> 421 <class>QPushButton</class>
422 <property stdset="1"> 422 <property stdset="1">
423 <name>name</name> 423 <name>name</name>
424 <cstring>PushButtonPredict</cstring> 424 <cstring>PushButtonPredict</cstring>
425 </property> 425 </property>
426 <property stdset="1"> 426 <property stdset="1">
427 <name>text</name> 427 <name>text</name>
428 <string>Predict time</string> 428 <string>Predict time</string>
429 </property> 429 </property>
430 </widget> 430 </widget>
431 </hbox> 431 </hbox>
432 </widget> 432 </widget>
433 </grid> 433 </grid>
434 </widget> 434 </widget>
435 <widget> 435 <widget>
436 <class>QWidget</class> 436 <class>QWidget</class>
437 <property stdset="1"> 437 <property stdset="1">
438 <name>name</name> 438 <name>name</name>
439 <cstring>TabSettings</cstring> 439 <cstring>TabSettings</cstring>
440 </property> 440 </property>
441 <attribute> 441 <attribute>
442 <name>title</name> 442 <name>title</name>
443 <string>Settings</string> 443 <string>Settings</string>
444 </attribute> 444 </attribute>
445 <grid> 445 <grid>
446 <property stdset="1"> 446 <property stdset="1">
447 <name>margin</name> 447 <name>margin</name>
448 <number>2</number> 448 <number>2</number>
449 </property> 449 </property>
450 <property stdset="1"> 450 <property stdset="1">
451 <name>spacing</name> 451 <name>spacing</name>
452 <number>2</number> 452 <number>2</number>
453 </property> 453 </property>
454 <widget row="0" column="0" > 454 <widget row="0" column="0" >
455 <class>QFrame</class> 455 <class>QFrame</class>
456 <property stdset="1"> 456 <property stdset="1">
457 <name>name</name> 457 <name>name</name>
458 <cstring>FrameSettings</cstring> 458 <cstring>FrameSettings</cstring>
459 </property> 459 </property>
460 <property stdset="1"> 460 <property stdset="1">
461 <name>frameShape</name> 461 <name>frameShape</name>
462 <enum>StyledPanel</enum> 462 <enum>StyledPanel</enum>
463 </property> 463 </property>
464 <property stdset="1"> 464 <property stdset="1">
465 <name>frameShadow</name> 465 <name>frameShadow</name>
466 <enum>Raised</enum> 466 <enum>Raised</enum>
467 </property> 467 </property>
468 <property> 468 <property>
469 <name>layoutMargin</name> 469 <name>layoutMargin</name>
470 </property> 470 </property>
471 <property> 471 <property>
472 <name>layoutSpacing</name> 472 <name>layoutSpacing</name>
473 </property> 473 </property>
474 <grid> 474 <grid>
475 <property stdset="1"> 475 <property stdset="1">
476 <name>margin</name> 476 <name>margin</name>
477 <number>3</number> 477 <number>3</number>
478 </property> 478 </property>
479 <property stdset="1"> 479 <property stdset="1">
480 <name>spacing</name> 480 <name>spacing</name>
481 <number>11</number> 481 <number>11</number>
482 </property> 482 </property>
483 <widget row="0" column="0" > 483 <widget row="0" column="0" >
484 <class>QLayoutWidget</class> 484 <class>QLayoutWidget</class>
485 <property stdset="1"> 485 <property stdset="1">
486 <name>name</name> 486 <name>name</name>
487 <cstring>Layout6</cstring> 487 <cstring>Layout6</cstring>
488 </property> 488 </property>
489 <grid> 489 <grid>
490 <property stdset="1"> 490 <property stdset="1">
491 <name>margin</name> 491 <name>margin</name>
492 <number>0</number> 492 <number>0</number>
493 </property> 493 </property>
494 <property stdset="1"> 494 <property stdset="1">
495 <name>spacing</name> 495 <name>spacing</name>
496 <number>6</number> 496 <number>6</number>
497 </property> 497 </property>
498 <widget row="0" column="0" > 498 <widget row="0" column="0" >
499 <class>QLabel</class> 499 <class>QLabel</class>
500 <property stdset="1"> 500 <property stdset="1">
501 <name>name</name> 501 <name>name</name>
502 <cstring>TextLabel7_2</cstring> 502 <cstring>TextLabel7_2</cstring>
503 </property> 503 </property>
504 <property stdset="1"> 504 <property stdset="1">
505 <name>text</name> 505 <name>text</name>
506 <string>Use</string> 506 <string>Use</string>
507 </property> 507 </property>
508 </widget> 508 </widget>
509 <widget row="0" column="2" > 509 <widget row="0" column="2" >
510 <class>QLabel</class> 510 <class>QLabel</class>
511 <property stdset="1"> 511 <property stdset="1">
512 <name>name</name> 512 <name>name</name>
513 <cstring>TextLabel2_2</cstring> 513 <cstring>TextLabel2_2</cstring>
514 </property> 514 </property>
515 <property stdset="1"> 515 <property stdset="1">
516 <name>text</name> 516 <name>text</name>
517 <string>as</string> 517 <string>as</string>
518 </property> 518 </property>
519 </widget> 519 </widget>
520 <widget row="1" column="0" rowspan="1" colspan="2" > 520 <widget row="1" column="0" rowspan="1" colspan="2" >
521 <class>QLabel</class> 521 <class>QLabel</class>
522 <property stdset="1"> 522 <property stdset="1">
523 <name>name</name> 523 <name>name</name>
524 <cstring>TextLabel1_3</cstring> 524 <cstring>TextLabel1_3</cstring>
525 </property> 525 </property>
526 <property stdset="1"> 526 <property stdset="1">
527 <name>text</name> 527 <name>text</name>
528 <string>NTP server to get the time from the network.</string> 528 <string>NTP server to get the time from the network.</string>
529 </property> 529 </property>
530 <property stdset="1"> 530 <property stdset="1">
531 <name>alignment</name> 531 <name>alignment</name>
532 <set>WordBreak|AlignVCenter|AlignLeft</set> 532 <set>WordBreak|AlignVCenter|AlignLeft</set>
533 </property> 533 </property>
534 <property> 534 <property>
535 <name>wordwrap</name> 535 <name>wordwrap</name>
536 </property> 536 </property>
537 </widget> 537 </widget>
538 <widget row="0" column="1" > 538 <widget row="0" column="1" >
539 <class>QComboBox</class> 539 <class>QComboBox</class>
540 <property stdset="1"> 540 <property stdset="1">
541 <name>name</name> 541 <name>name</name>
542 <cstring>ComboNtpSrv</cstring> 542 <cstring>ComboNtpSrv</cstring>
543 </property> 543 </property>
544 <property stdset="1"> 544 <property stdset="1">
545 <name>editable</name> 545 <name>editable</name>
546 <bool>true</bool> 546 <bool>true</bool>
547 </property> 547 </property>
548 </widget> 548 </widget>
549 </grid> 549 </grid>
550 </widget> 550 </widget>
551 <spacer row="3" column="0" > 551 <spacer row="3" column="0" >
552 <property> 552 <property>
553 <name>name</name> 553 <name>name</name>
554 <cstring>Spacer2</cstring> 554 <cstring>Spacer2</cstring>
555 </property> 555 </property>
556 <property stdset="1"> 556 <property stdset="1">
557 <name>orientation</name> 557 <name>orientation</name>
558 <enum>Vertical</enum> 558 <enum>Vertical</enum>
559 </property> 559 </property>
560 <property stdset="1"> 560 <property stdset="1">
561 <name>sizeType</name> 561 <name>sizeType</name>
562 <enum>Expanding</enum> 562 <enum>Expanding</enum>
563 </property> 563 </property>
564 <property> 564 <property>
565 <name>sizeHint</name> 565 <name>sizeHint</name>
566 <size> 566 <size>
567 <width>20</width> 567 <width>20</width>
568 <height>20</height> 568 <height>20</height>
569 </size> 569 </size>
570 </property> 570 </property>
571 </spacer> 571 </spacer>
572 <widget row="2" column="0" > 572 <widget row="2" column="0" >
573 <class>QLayoutWidget</class> 573 <class>QLayoutWidget</class>
574 <property stdset="1"> 574 <property stdset="1">
575 <name>name</name> 575 <name>name</name>
576 <cstring>Layout7</cstring> 576 <cstring>Layout7</cstring>
577 </property> 577 </property>
578 <grid> 578 <grid>
579 <property stdset="1"> 579 <property stdset="1">
580 <name>margin</name> 580 <name>margin</name>
581 <number>0</number> 581 <number>0</number>
582 </property> 582 </property>
583 <property stdset="1"> 583 <property stdset="1">
584 <name>spacing</name> 584 <name>spacing</name>
585 <number>6</number> 585 <number>6</number>
586 </property> 586 </property>
587 <widget row="0" column="0" > 587 <widget row="0" column="0" >
588 <class>QLabel</class> 588 <class>QLabel</class>
589 <property stdset="1"> 589 <property stdset="1">
590 <name>name</name> 590 <name>name</name>
591 <cstring>TextLabel1_2</cstring> 591 <cstring>TextLabel1_2</cstring>
592 </property> 592 </property>
593 <property stdset="1"> 593 <property stdset="1">
594 <name>text</name> 594 <name>text</name>
595 <string>Insure a delay of</string> 595 <string>Insure a delay of</string>
596 </property> 596 </property>
597 </widget> 597 </widget>
598 <widget row="0" column="2" > 598 <widget row="0" column="2" >
599 <class>QLabel</class> 599 <class>QLabel</class>
600 <property stdset="1"> 600 <property stdset="1">
601 <name>name</name> 601 <name>name</name>
602 <cstring>TextLabel2</cstring> 602 <cstring>TextLabel2</cstring>
603 </property> 603 </property>
604 <property stdset="1"> 604 <property stdset="1">
605 <name>text</name> 605 <name>text</name>
606 <string>minutes until</string> 606 <string>minutes until</string>
607 </property> 607 </property>
608 </widget> 608 </widget>
609 <widget row="1" column="0" rowspan="1" colspan="3" > 609 <widget row="1" column="0" rowspan="1" colspan="3" >
610 <class>QLabel</class> 610 <class>QLabel</class>
611 <property stdset="1"> 611 <property stdset="1">
612 <name>name</name> 612 <name>name</name>
613 <cstring>TextLabel3_3</cstring> 613 <cstring>TextLabel3_3</cstring>
614 </property> 614 </property>
615 <property stdset="1"> 615 <property stdset="1">
616 <name>text</name> 616 <name>text</name>
617 <string>a new NTP lookup will be used to predict the time.</string> 617 <string>a new NTP lookup will be used to predict the time.</string>
618 </property> 618 </property>
619 <property stdset="1"> 619 <property stdset="1">
620 <name>alignment</name> 620 <name>alignment</name>
621 <set>WordBreak|AlignVCenter|AlignLeft</set> 621 <set>WordBreak|AlignVCenter|AlignLeft</set>
622 </property> 622 </property>
623 <property> 623 <property>
624 <name>wordwrap</name> 624 <name>wordwrap</name>
625 </property> 625 </property>
626 </widget> 626 </widget>
627 <widget row="0" column="1" > 627 <widget row="0" column="1" >
628 <class>QSpinBox</class> 628 <class>QSpinBox</class>
629 <property stdset="1"> 629 <property stdset="1">
630 <name>name</name> 630 <name>name</name>
631 <cstring>SpinBoxMinLookupDelay</cstring> 631 <cstring>SpinBoxMinLookupDelay</cstring>
632 </property> 632 </property>
633 <property stdset="1"> 633 <property stdset="1">
634 <name>maxValue</name> 634 <name>maxValue</name>
635 <number>9999999</number> 635 <number>9999999</number>
636 </property> 636 </property>
637 <property stdset="1"> 637 <property stdset="1">
638 <name>minValue</name> 638 <name>minValue</name>
639 <number>42</number> 639 <number>42</number>
640 </property> 640 </property>
641 </widget> 641 </widget>
642 </grid> 642 </grid>
643 </widget> 643 </widget>
644 <widget row="1" column="0" > 644 <widget row="1" column="0" >
645 <class>QLayoutWidget</class> 645 <class>QLayoutWidget</class>
646 <property stdset="1"> 646 <property stdset="1">
647 <name>name</name> 647 <name>name</name>
648 <cstring>Layout7_2</cstring> 648 <cstring>Layout7_2</cstring>
649 </property> 649 </property>
650 <grid> 650 <grid>
651 <property stdset="1"> 651 <property stdset="1">
652 <name>margin</name> 652 <name>margin</name>
653 <number>0</number> 653 <number>0</number>
654 </property> 654 </property>
655 <property stdset="1"> 655 <property stdset="1">
656 <name>spacing</name> 656 <name>spacing</name>
657 <number>6</number> 657 <number>6</number>
658 </property> 658 </property>
659 <widget row="0" column="0" > 659 <widget row="0" column="0" >
660 <class>QLabel</class> 660 <class>QLabel</class>
661 <property stdset="1"> 661 <property stdset="1">
662 <name>name</name> 662 <name>name</name>
663 <cstring>TextLabel1_2_2</cstring> 663 <cstring>TextLabel1_2_2</cstring>
664 </property> 664 </property>
665 <property stdset="1"> 665 <property stdset="1">
666 <name>sizePolicy</name> 666 <name>sizePolicy</name>
667 <sizepolicy> 667 <sizepolicy>
668 <hsizetype>1</hsizetype> 668 <hsizetype>1</hsizetype>
669 <vsizetype>1</vsizetype> 669 <vsizetype>1</vsizetype>
670 </sizepolicy> 670 </sizepolicy>
671 </property> 671 </property>
672 <property stdset="1"> 672 <property stdset="1">
673 <name>text</name> 673 <name>text</name>
674 <string>Wait for </string> 674 <string>Wait for </string>
675 </property> 675 </property>
676 </widget> 676 </widget>
677 <widget row="0" column="2" > 677 <widget row="0" column="2" >
678 <class>QLabel</class> 678 <class>QLabel</class>
679 <property stdset="1"> 679 <property stdset="1">
680 <name>name</name> 680 <name>name</name>
681 <cstring>TextLabel2_3</cstring> 681 <cstring>TextLabel2_3</cstring>
682 </property> 682 </property>
683 <property stdset="1"> 683 <property stdset="1">
684 <name>text</name> 684 <name>text</name>
685 <string>minutes until</string> 685 <string>minutes until</string>
686 </property> 686 </property>
687 </widget> 687 </widget>
688 <widget row="1" column="0" rowspan="1" colspan="3" > 688 <widget row="1" column="0" rowspan="1" colspan="3" >
689 <class>QLabel</class> 689 <class>QLabel</class>
690 <property stdset="1"> 690 <property stdset="1">
691 <name>name</name> 691 <name>name</name>
692 <cstring>TextLabel3_3_2</cstring> 692 <cstring>TextLabel3_3_2</cstring>
693 </property> 693 </property>
694 <property stdset="1"> 694 <property stdset="1">
695 <name>text</name> 695 <name>text</name>
696 <string>NTP tries to syncronises the clock with the network.</string> 696 <string>NTP tries to syncronises the clock with the network.</string>
697 </property> 697 </property>
698 <property stdset="1"> 698 <property stdset="1">
699 <name>alignment</name> 699 <name>alignment</name>
700 <set>WordBreak|AlignVCenter|AlignLeft</set> 700 <set>WordBreak|AlignVCenter|AlignLeft</set>
701 </property> 701 </property>
702 <property> 702 <property>
703 <name>wordwrap</name> 703 <name>wordwrap</name>
704 </property> 704 </property>
705 </widget> 705 </widget>
706 <widget row="0" column="1" > 706 <widget row="0" column="1" >
707 <class>QSpinBox</class> 707 <class>QSpinBox</class>
708 <property stdset="1"> 708 <property stdset="1">
709 <name>name</name> 709 <name>name</name>
710 <cstring>SpinBoxNtpDelay</cstring> 710 <cstring>SpinBoxNtpDelay</cstring>
711 </property> 711 </property>
712 <property stdset="1"> 712 <property stdset="1">
713 <name>maxValue</name> 713 <name>maxValue</name>
714 <number>9999999</number> 714 <number>9999999</number>
715 </property> 715 </property>
716 <property stdset="1"> 716 <property stdset="1">
717 <name>minValue</name> 717 <name>minValue</name>
718 <number>0</number> 718 <number>0</number>
719 </property> 719 </property>
720 </widget> 720 </widget>
721 </grid> 721 </grid>
722 </widget> 722 </widget>
723 </grid> 723 </grid>
724 </widget> 724 </widget>
725 </grid> 725 </grid>
726 </widget> 726 </widget>
727 <widget> 727 <widget>
728 <class>QWidget</class> 728 <class>QWidget</class>
729 <property stdset="1"> 729 <property stdset="1">
730 <name>name</name> 730 <name>name</name>
731 <cstring>tabSetTime</cstring> 731 <cstring>tabSetTime</cstring>
732 </property> 732 </property>
733 <attribute> 733 <attribute>
734 <name>title</name> 734 <name>title</name>
735 <string>Manual</string> 735 <string>Manual</string>
736 </attribute> 736 </attribute>
737 <vbox> 737 <vbox>
738 <property stdset="1"> 738 <property stdset="1">
739 <name>margin</name> 739 <name>margin</name>
740 <number>2</number> 740 <number>2</number>
741 </property> 741 </property>
742 <property stdset="1"> 742 <property stdset="1">
743 <name>spacing</name> 743 <name>spacing</name>
744 <number>2</number> 744 <number>2</number>
745 </property> 745 </property>
746 <widget> 746 <widget>
747 <class>QFrame</class> 747 <class>QFrame</class>
748 <property stdset="1"> 748 <property stdset="1">
749 <name>name</name> 749 <name>name</name>
750 <cstring>FrameSetTime</cstring> 750 <cstring>FrameSetTime</cstring>
751 </property> 751 </property>
752 <property stdset="1"> 752 <property stdset="1">
753 <name>frameShape</name> 753 <name>frameShape</name>
754 <enum>StyledPanel</enum> 754 <enum>StyledPanel</enum>
755 </property> 755 </property>
756 <property stdset="1"> 756 <property stdset="1">
757 <name>frameShadow</name> 757 <name>frameShadow</name>
758 <enum>Raised</enum> 758 <enum>Raised</enum>
759 </property> 759 </property>
760 </widget> 760 </widget>
761 <widget> 761 <widget>
762 <class>QPushButton</class> 762 <class>QPushButton</class>
763 <property stdset="1"> 763 <property stdset="1">
764 <name>name</name> 764 <name>name</name>
765 <cstring>PushButtonSetManualTime</cstring> 765 <cstring>PushButtonSetManualTime</cstring>
766 </property> 766 </property>
767 <property stdset="1"> 767 <property stdset="1">
768 <name>text</name> 768 <name>text</name>
769 <string>Set time</string> 769 <string>Set time</string>
770 </property> 770 </property>
771 </widget> 771 </widget>
772 </vbox> 772 </vbox>
773 </widget> 773 </widget>
774 </widget> 774 </widget>
775 </grid> 775 </grid>
776</widget> 776</widget>
777</UI> 777</UI>
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.control b/noncore/settings/netsystemtime/opie-netsystemtime.control
index 406d7b0..d3290e9 100644
--- a/noncore/settings/netsystemtime/opie-netsystemtime.control
+++ b/noncore/settings/netsystemtime/opie-netsystemtime.control
@@ -1,11 +1,11 @@
1Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop 1Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers
2Priority: optional 2Priority: optional
3Section: opie/settings 3Section: opie/settings
4Depends: ntpdate 4Depends: ntpdate
5Conflicts: opie-systemtime 5Conflicts: opie-systemtime
6Maintainer: Patrick S. Vogt <tille@handhelds.org> 6Maintainer: Patrick S. Vogt <tille@handhelds.org>
7Architecture: arm 7Architecture: arm
8Version: $QPE_VERSION-$SUB_VERSION 8Version: $QPE_VERSION-$SUB_VERSION
9Depends: opie-base ($QPE_VERSION), ntpdate 9Depends: opie-base ($QPE_VERSION), ntpdate
10Description: ntp ( Network Time Protocol) gui 10Description: ntp ( Network Time Protocol) gui
11This utility syncs system time with a atomic timerserver via internet 11This utility syncs system time with a atomic timerserver via internet
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index 2398c08..93543cd 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -1,489 +1,487 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "settime.h" 21#include "settime.h"
22 22
23#include <qpe/alarmserver.h> 23#include <qpe/alarmserver.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/datebookdb.h> 26#include <qpe/datebookdb.h>
27#include <qpe/datebookmonth.h> 27#include <qpe/datebookmonth.h>
28#include <qpe/global.h> 28#include <qpe/global.h>
29#include <qpe/resource.h> 29#include <qpe/resource.h>
30#include <qpe/timeconversion.h> 30#include <qpe/timeconversion.h>
31#include <qpe/tzselect.h> 31#include <qpe/tzselect.h>
32#include <qpe/timestring.h> 32#include <qpe/timestring.h>
33#include <qpe/qpedialog.h> 33#include <qpe/qpedialog.h>
34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36#endif 36#endif
37 37
38#include <qbuttongroup.h> 38#include <qbuttongroup.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qradiobutton.h> 42#include <qradiobutton.h>
43#include <qspinbox.h> 43#include <qspinbox.h>
44#include <qtoolbutton.h> 44#include <qtoolbutton.h>
45#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
46#include <qcombobox.h> 46#include <qcombobox.h>
47 47
48#include <sys/time.h> 48#include <sys/time.h>
49#include <time.h> 49#include <time.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <stdio.h> 51#include <stdio.h>
52 52
53 53
54SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) 54SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f )
55 : NtpBase( parent, name, f ) 55 : NtpBase( parent, name, f )
56{ 56{
57 // setCaption( tr("Set System Time") ); 57 // setCaption( tr("Set System Time") );
58 58
59// QVBoxLayout *vb = new QVBoxLayout( this, 5 ); 59// QVBoxLayout *vb = new QVBoxLayout( this, 5 );
60 QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); 60 QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 );
61 QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 ); 61 QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 );
62 62
63 TextLabelMainPredTime = new QLabel( FrameSystemTime ); 63 TextLabelMainPredTime = new QLabel( FrameSystemTime );
64 vb->addWidget( TextLabelMainPredTime, 1, 0 ); 64 vb->addWidget( TextLabelMainPredTime, 1, 0 );
65 ButtonSetTime = new QPushButton( FrameSystemTime ); 65 ButtonSetTime = new QPushButton( FrameSystemTime );
66 vb->addWidget( ButtonSetTime, 1, 0 ); 66 vb->addWidget( ButtonSetTime, 1, 0 );
67 67
68 QFrame *hline = new QFrame( FrameSystemTime ); 68 QFrame *hline = new QFrame( FrameSystemTime );
69 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 69 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
70 vb->addWidget( hline ); 70 vb->addWidget( hline );
71 71
72 QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); 72 QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" );
73 73
74 QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); 74 QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" );
75 lblZone->setMaximumSize( lblZone->sizeHint() ); 75 lblZone->setMaximumSize( lblZone->sizeHint() );
76 hb->addWidget( lblZone ); 76 hb->addWidget( lblZone );
77 77
78 tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); 78 tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" );
79 tz->setMinimumSize( tz->sizeHint() ); 79 tz->setMinimumSize( tz->sizeHint() );
80 hb->addWidget( tz ); 80 hb->addWidget( tz );
81 81
82 timeButton = new SetTime( FrameSetTime ); 82 timeButton = new SetTime( FrameSetTime );
83 vb2->addWidget( timeButton ); 83 vb2->addWidget( timeButton );
84 84
85 QHBoxLayout *db = new QHBoxLayout( vb2 ); 85 QHBoxLayout *db = new QHBoxLayout( vb2 );
86 QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); 86 QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime );
87 db->addWidget( dateLabel, 1 ); 87 db->addWidget( dateLabel, 1 );
88 dateButton = new DateButton( TRUE, FrameSetTime ); 88 dateButton = new DateButton( TRUE, FrameSetTime );
89 db->addWidget( dateButton, 2 ); 89 db->addWidget( dateButton, 2 );
90 90
91 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 91 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
92 vb2->addItem( spacer ); 92 vb2->addItem( spacer );
93 93
94 hline = new QFrame( FrameSystemTime ); 94 hline = new QFrame( FrameSystemTime );
95 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 95 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
96 vb->addWidget( hline ); 96 vb->addWidget( hline );
97 97
98 Config config("qpe"); 98 Config config("qpe");
99 config.setGroup( "Time" ); 99 config.setGroup( "Time" );
100 100
101 QHBoxLayout *hb1 = new QHBoxLayout( vb ); 101 QHBoxLayout *hb1 = new QHBoxLayout( vb );
102 102
103 QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); 103 QLabel *l = new QLabel( tr("Time format"), FrameSystemTime );
104 hb1->addWidget( l, 1 ); 104 hb1->addWidget( l, 1 );
105 105
106 106
107 ampmCombo = new QComboBox( FrameSystemTime ); 107 ampmCombo = new QComboBox( FrameSystemTime );
108 ampmCombo->insertItem( tr("24 hour"), 0 ); 108 ampmCombo->insertItem( tr("24 hour"), 0 );
109 ampmCombo->insertItem( tr("12 hour"), 1 ); 109 ampmCombo->insertItem( tr("12 hour"), 1 );
110 hb1->addWidget( ampmCombo, 2 ); 110 hb1->addWidget( ampmCombo, 2 );
111 111
112 int show12hr = config.readBoolEntry("AMPM") ? 1 : 0; 112 int show12hr = config.readBoolEntry("AMPM") ? 1 : 0;
113 ampmCombo->setCurrentItem( show12hr ); 113 ampmCombo->setCurrentItem( show12hr );
114 timeButton->show12hourTime( show12hr ); 114 timeButton->show12hourTime( show12hr );
115 115
116 connect(ampmCombo, SIGNAL(activated(int)), 116 connect(ampmCombo, SIGNAL(activated(int)),
117 timeButton, SLOT(show12hourTime(int))); 117 timeButton, SLOT(show12hourTime(int)));
118 118
119 119
120 120
121 QHBoxLayout *hb2 = new QHBoxLayout( vb ); 121 QHBoxLayout *hb2 = new QHBoxLayout( vb );
122 l = new QLabel( tr("Weeks start on" ), FrameSystemTime ); 122 l = new QLabel( tr("Weeks start on" ), FrameSystemTime );
123 //l->setAlignment( AlignRight | AlignVCenter ); 123 //l->setAlignment( AlignRight | AlignVCenter );
124 hb2->addWidget( l, 1 ); 124 hb2->addWidget( l, 1 );
125 125
126 weekStartCombo = new QComboBox( FrameSystemTime ); 126 weekStartCombo = new QComboBox( FrameSystemTime );
127 weekStartCombo->insertItem( tr("Sunday"), 0 ); 127 weekStartCombo->insertItem( tr("Sunday"), 0 );
128 weekStartCombo->insertItem( tr("Monday"), 1 ); 128 weekStartCombo->insertItem( tr("Monday"), 1 );
129 129
130 hb2->addWidget( weekStartCombo, 2 ); 130 hb2->addWidget( weekStartCombo, 2 );
131 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0; 131 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0;
132 dateButton->setWeekStartsMonday( startMonday ); 132 dateButton->setWeekStartsMonday( startMonday );
133 weekStartCombo->setCurrentItem( startMonday ); 133 weekStartCombo->setCurrentItem( startMonday );
134 134
135 connect( weekStartCombo, SIGNAL( activated(int)), 135 connect( weekStartCombo, SIGNAL( activated(int)),
136 dateButton, SLOT(setWeekStartsMonday(int))); 136 dateButton, SLOT(setWeekStartsMonday(int)));
137 137
138 138
139 QHBoxLayout *hb3 = new QHBoxLayout( vb ); 139 QHBoxLayout *hb3 = new QHBoxLayout( vb );
140 l = new QLabel( tr("Date format" ), FrameSystemTime ); 140 l = new QLabel( tr("Date format" ), FrameSystemTime );
141 hb3->addWidget( l, 1 ); 141 hb3->addWidget( l, 1 );
142 dateFormatCombo = new QComboBox( FrameSystemTime ); 142 dateFormatCombo = new QComboBox( FrameSystemTime );
143 hb3->addWidget( dateFormatCombo, 2 ); 143 hb3->addWidget( dateFormatCombo, 2 );
144 144
145 config.setGroup( "Date" ); 145 config.setGroup( "Date" );
146 DateFormat df(QChar(config.readEntry("Separator", "/")[0]), 146 DateFormat df(QChar(config.readEntry("Separator", "/")[0]),
147 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), 147 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
148 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); 148 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
149 149
150 int currentdf = 0; 150 int currentdf = 0;
151 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear); 151 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear);
152 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) ); 152 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) );
153 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear); 153 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear);
154 if (df == date_formats[1]) 154 if (df == date_formats[1])
155 currentdf = 1; 155 currentdf = 1;
156 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) ); 156 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) );
157 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay, 157 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay,
158 DateFormat::DayMonthYear); 158 DateFormat::DayMonthYear);
159 if (df == date_formats[2]) 159 if (df == date_formats[2])
160 currentdf = 2; 160 currentdf = 2;
161 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601 161 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601
162 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear); 162 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear);
163 if (df == date_formats[3]) 163 if (df == date_formats[3])
164 currentdf = 3; 164 currentdf = 3;
165 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) ); 165 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) );
166 166
167 dateFormatCombo->setCurrentItem( currentdf ); 167 dateFormatCombo->setCurrentItem( currentdf );
168 dateButton->setDateFormat( df ); 168 dateButton->setDateFormat( df );
169 169
170 connect( dateFormatCombo, SIGNAL( activated(int)), 170 connect( dateFormatCombo, SIGNAL( activated(int)),
171 SLOT(formatChanged(int))); 171 SLOT(formatChanged(int)));
172 172
173 QHBoxLayout *hb4 = new QHBoxLayout( vb ); 173 QHBoxLayout *hb4 = new QHBoxLayout( vb );
174 l = new QLabel( tr("Applet format" ), FrameSystemTime ); 174 l = new QLabel( tr("Applet format" ), FrameSystemTime );
175 hb4->addWidget( l, 1 ); 175 hb4->addWidget( l, 1 );
176 176
177 clockAppletCombo = new QComboBox( FrameSystemTime ); 177 clockAppletCombo = new QComboBox( FrameSystemTime );
178 clockAppletCombo->insertItem( tr("hh:mm"), 0 ); 178 clockAppletCombo->insertItem( tr("hh:mm"), 0 );
179 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); 179 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 );
180 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); 180 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 );
181 181
182 hb4->addWidget( clockAppletCombo, 2 ); 182 hb4->addWidget( clockAppletCombo, 2 );
183 int clockApplet = config.readNumEntry("ClockApplet",0); 183 int clockApplet = config.readNumEntry("ClockApplet",0);
184 clockAppletCombo->setCurrentItem( clockApplet ); 184 clockAppletCombo->setCurrentItem( clockApplet );
185 185
186 vb->addStretch( 0 ); 186 vb->addStretch( 0 );
187 187
188 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), 188 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()),
189 this, SLOT(commitTime())); 189 this, SLOT(commitTime()));
190 190
191 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 191 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
192 timeButton, SLOT( slotTzChange( const QString& ) ) ); 192 timeButton, SLOT( slotTzChange( const QString& ) ) );
193 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 193 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
194 SLOT( tzChange( const QString& ) ) ); 194 SLOT( tzChange( const QString& ) ) );
195 195
196 QObject::connect( weekStartCombo, SIGNAL( activated ( int )), 196 QObject::connect( weekStartCombo, SIGNAL( activated ( int )),
197 SLOT(updateSystem(int ) )); 197 SLOT(updateSystem(int ) ));
198 QObject::connect( ampmCombo, SIGNAL( activated ( int )), 198 QObject::connect( ampmCombo, SIGNAL( activated ( int )),
199 SLOT(updateSystem(int ) )); 199 SLOT(updateSystem(int ) ));
200 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), 200 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )),
201 SLOT(updateSystem(int ) )); 201 SLOT(updateSystem(int ) ));
202 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), 202 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )),
203 SLOT(updateSystem(int ) )); 203 SLOT(updateSystem(int ) ));
204} 204}
205 205
206SetDateTime::~SetDateTime() 206SetDateTime::~SetDateTime()
207{ 207{
208 writeSettings(); 208 writeSettings();
209 209
210} 210}
211 211
212void SetDateTime::writeSettings() 212void SetDateTime::writeSettings()
213{ 213{
214 Config config("qpe"); 214 Config config("qpe");
215 config.setGroup( "Time" ); 215 config.setGroup( "Time" );
216 config.writeEntry( "AMPM", ampmCombo->currentItem() ); 216 config.writeEntry( "AMPM", ampmCombo->currentItem() );
217 config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); 217 config.writeEntry( "MONDAY", weekStartCombo->currentItem() );
218 config.setGroup( "Date" ); 218 config.setGroup( "Date" );
219 DateFormat df = date_formats[dateFormatCombo->currentItem()]; 219 DateFormat df = date_formats[dateFormatCombo->currentItem()];
220 config.writeEntry( "Separator", QString(df.separator())); 220 config.writeEntry( "Separator", QString(df.separator()));
221 config.writeEntry( "ShortOrder", df.shortOrder()); 221 config.writeEntry( "ShortOrder", df.shortOrder());
222 config.writeEntry( "LongOrder", df.longOrder()); 222 config.writeEntry( "LongOrder", df.longOrder());
223 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); 223 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() );
224 224
225 Config lconfig("locale"); 225 Config lconfig("locale");
226 lconfig.setGroup( "Location" ); 226 lconfig.setGroup( "Location" );
227 lconfig.writeEntry( "Timezone", tz->currentZone() ); 227 lconfig.writeEntry( "Timezone", tz->currentZone() );
228 228
229} 229}
230 230
231void SetDateTime::commitTime() 231void SetDateTime::commitTime()
232{ 232{
233 tz->setFocus(); 233 tz->setFocus();
234 // really turn off the screensaver before doing anything 234 // really turn off the screensaver before doing anything
235 { 235 {
236 // Needs to be encased in { } so that it deconstructs and sends 236 // Needs to be encased in { } so that it deconstructs and sends
237 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 237 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
238 disableScreenSaver << 0 << 0 << 0; 238 disableScreenSaver << 0 << 0 << 0;
239 } 239 }
240 // Need to process the QCOP event generated above before proceeding 240 // Need to process the QCOP event generated above before proceeding
241 qApp->processEvents(); 241 qApp->processEvents();
242 242
243 // before we progress further, set our TZ! 243 // before we progress further, set our TZ!
244 setenv( "TZ", tz->currentZone(), 1 ); 244 setenv( "TZ", tz->currentZone(), 1 );
245 // now set the time... 245 // now set the time...
246 QDateTime dt( dateButton->date(), timeButton->time() ); 246 QDateTime dt( dateButton->date(), timeButton->time() );
247 247
248 if ( dt.isValid() ) setTime(dt); 248 if ( dt.isValid() ) setTime(dt);
249} 249}
250 250
251void SetDateTime::setTime(QDateTime dt) 251void SetDateTime::setTime(QDateTime dt)
252{ 252{
253 Config cfg("ntp",Config::User); 253 Config cfg("ntp",Config::User);
254 cfg.setGroup("correction"); 254 cfg.setGroup("correction");
255 int t = TimeConversion::toUTC(dt); 255 int t = TimeConversion::toUTC(dt);
256 struct timeval myTv; 256 struct timeval myTv;
257 myTv.tv_sec = t; 257 myTv.tv_sec = t;
258 cfg.writeEntry("time", t ); 258 cfg.writeEntry("time", t );
259 myTv.tv_usec = 0; 259 myTv.tv_usec = 0;
260 260
261 if ( myTv.tv_sec != -1 ) 261 if ( myTv.tv_sec != -1 )
262 ::settimeofday( &myTv, 0 ); 262 ::settimeofday( &myTv, 0 );
263 Global::writeHWClock(); 263 Global::writeHWClock();
264 // since time has changed quickly load in the datebookdb 264 // since time has changed quickly load in the datebookdb
265 // to allow the alarm server to get a better grip on itself 265 // to allow the alarm server to get a better grip on itself
266 // (example re-trigger alarms for when we travel back in time) 266 // (example re-trigger alarms for when we travel back in time)
267 DateBookDB db; 267 DateBookDB db;
268} 268}
269 269
270void SetDateTime::updateSystem(int i) 270void SetDateTime::updateSystem(int i)
271{ 271{
272 qDebug("SetDateTime::updateSystem(int %i)",i); 272 qDebug("SetDateTime::updateSystem(int %i)",i);
273 writeSettings(); 273 writeSettings();
274 274
275 // set the timezone for everyone else... 275 // set the timezone for everyone else...
276 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); 276 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
277 setTimeZone << tz->currentZone(); 277 setTimeZone << tz->currentZone();
278 278
279 // AM/PM setting and notify time changed 279 // AM/PM setting and notify time changed
280 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); 280 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" );
281 setClock << ampmCombo->currentItem(); 281 setClock << ampmCombo->currentItem();
282 282
283 // Notify everyone what day we prefer to start the week on. 283 // Notify everyone what day we prefer to start the week on.
284 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); 284 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" );
285 setWeek << weekStartCombo->currentItem(); 285 setWeek << weekStartCombo->currentItem();
286 286
287 // Notify everyone what date format to use 287 // Notify everyone what date format to use
288 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); 288 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" );
289 setDateFormat << date_formats[dateFormatCombo->currentItem()]; 289 setDateFormat << date_formats[dateFormatCombo->currentItem()];
290 290
291 // Restore screensaver 291 // Restore screensaver
292 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 292 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
293 enableScreenSaver << -1 << -1 << -1; 293 enableScreenSaver << -1 << -1 << -1;
294 // since time has changed quickly load in the datebookdb 294 // since time has changed quickly load in the datebookdb
295 // to allow the alarm server to get a better grip on itself 295 // to allow the alarm server to get a better grip on itself
296 // (example re-trigger alarms for when we travel back in time) 296 // (example re-trigger alarms for when we travel back in time)
297 DateBookDB db; 297 DateBookDB db;
298 298
299} 299}
300 300
301void SetDateTime::tzChange( const QString &tz ) 301void SetDateTime::tzChange( const QString &tz )
302{ 302{
303 qDebug("SetDateTime::tzChange");
304 // set the TZ get the time and leave gracefully... 303 // set the TZ get the time and leave gracefully...
305 QString strSave; 304 QString strSave;
306 strSave = getenv( "TZ" ); 305 strSave = getenv( "TZ" );
307 setenv( "TZ", tz, 1 ); 306 setenv( "TZ", tz, 1 );
308 307
309 QDate d = QDate::currentDate(); 308 QDate d = QDate::currentDate();
310 // reset the time. 309 // reset the time.
311 if ( !strSave.isNull() ) { 310 if ( !strSave.isNull() ) {
312 setenv( "TZ", strSave, 1 ); 311 setenv( "TZ", strSave, 1 );
313 } 312 }
314 dateButton->setDate( d ); 313 dateButton->setDate( d );
315 updateSystem(); 314 updateSystem();
316} 315}
317 316
318void SetDateTime::formatChanged(int i) 317void SetDateTime::formatChanged(int i)
319{ 318{
320 dateButton->setDateFormat(date_formats[i]); 319 dateButton->setDateFormat(date_formats[i]);
321} 320}
322 321
323static const int ValueAM = 0; 322static const int ValueAM = 0;
324static const int ValuePM = 1; 323static const int ValuePM = 1;
325 324
326 325
327 326
328SetTime::SetTime( QWidget *parent, const char *name ) 327SetTime::SetTime( QWidget *parent, const char *name )
329 : QWidget( parent, name ) 328 : QWidget( parent, name )
330{ 329{
331 use12hourTime = FALSE; 330 use12hourTime = FALSE;
332 331
333 QTime currTime = QTime::currentTime(); 332 QTime currTime = QTime::currentTime();
334 hour = currTime.hour(); 333 hour = currTime.hour();
335 minute = currTime.minute(); 334 minute = currTime.minute();
336 335
337 QHBoxLayout *hb2 = new QHBoxLayout( this ); 336 QHBoxLayout *hb2 = new QHBoxLayout( this );
338 hb2->setSpacing( 3 ); 337 hb2->setSpacing( 3 );
339 338
340 QLabel *l = new QLabel( tr("Hour"), this ); 339 QLabel *l = new QLabel( tr("Hour"), this );
341 // l->setAlignment( AlignRight | AlignVCenter ); 340 // l->setAlignment( AlignRight | AlignVCenter );
342 hb2->addWidget( l ); 341 hb2->addWidget( l );
343 342
344 sbHour = new QSpinBox( this ); 343 sbHour = new QSpinBox( this );
345 sbHour->setMinimumWidth( 30 ); 344 sbHour->setMinimumWidth( 30 );
346 if(use12hourTime) { 345 if(use12hourTime) {
347 sbHour->setMinValue(1); 346 sbHour->setMinValue(1);
348 sbHour->setMaxValue( 12 ); 347 sbHour->setMaxValue( 12 );
349 int show_hour = hour; 348 int show_hour = hour;
350 if (hour > 12) 349 if (hour > 12)
351 show_hour -= 12; 350 show_hour -= 12;
352 if (show_hour == 0) 351 if (show_hour == 0)
353 show_hour = 12; 352 show_hour = 12;
354 353
355 sbHour->setValue( show_hour ); 354 sbHour->setValue( show_hour );
356 } else { 355 } else {
357 sbHour->setMinValue( 0 ); 356 sbHour->setMinValue( 0 );
358 sbHour->setMaxValue( 23 ); 357 sbHour->setMaxValue( 23 );
359 sbHour->setValue( hour ); 358 sbHour->setValue( hour );
360 } 359 }
361 sbHour->setWrapping(TRUE); 360 sbHour->setWrapping(TRUE);
362 connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); 361 connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) );
363 hb2->addWidget( sbHour ); 362 hb2->addWidget( sbHour );
364 363
365 hb2->addStretch( 1 ); 364 hb2->addStretch( 1 );
366 365
367 l = new QLabel( tr("Minute"), this ); 366 l = new QLabel( tr("Minute"), this );
368 //l->setAlignment( AlignRight | AlignVCenter ); 367 //l->setAlignment( AlignRight | AlignVCenter );
369 hb2->addWidget( l ); 368 hb2->addWidget( l );
370 369
371 sbMin = new QSpinBox( this ); 370 sbMin = new QSpinBox( this );
372 sbMin->setMinValue( 0 ); 371 sbMin->setMinValue( 0 );
373 sbMin->setMaxValue( 59 ); 372 sbMin->setMaxValue( 59 );
374 sbMin->setWrapping(TRUE); 373 sbMin->setWrapping(TRUE);
375 sbMin->setValue( minute ); 374 sbMin->setValue( minute );
376 sbMin->setMinimumWidth( 30 ); 375 sbMin->setMinimumWidth( 30 );
377 connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); 376 connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) );
378 hb2->addWidget( sbMin ); 377 hb2->addWidget( sbMin );
379 378
380 hb2->addStretch( 1 ); 379 hb2->addStretch( 1 );
381 380
382 ampm = new QComboBox( this ); 381 ampm = new QComboBox( this );
383 ampm->insertItem( tr("AM"), ValueAM ); 382 ampm->insertItem( tr("AM"), ValueAM );
384 ampm->insertItem( tr("PM"), ValuePM ); 383 ampm->insertItem( tr("PM"), ValuePM );
385 connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); 384 connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) );
386 hb2->addWidget( ampm ); 385 hb2->addWidget( ampm );
387 386
388 hb2->addStretch( 1 ); 387 hb2->addStretch( 1 );
389 388
390} 389}
391 390
392QTime SetTime::time() const 391QTime SetTime::time() const
393{ 392{
394 return QTime( hour, minute, 0 ); 393 return QTime( hour, minute, 0 );
395} 394}
396 395
397void SetTime::hourChanged( int value ) 396void SetTime::hourChanged( int value )
398{ 397{
399 if(use12hourTime) { 398 if(use12hourTime) {
400 int realhour = value; 399 int realhour = value;
401 if (realhour == 12) 400 if (realhour == 12)
402 realhour = 0; 401 realhour = 0;
403 if (ampm->currentItem() == ValuePM ) 402 if (ampm->currentItem() == ValuePM )
404 realhour += 12; 403 realhour += 12;
405 hour = realhour; 404 hour = realhour;
406 } else 405 } else
407 hour = value; 406 hour = value;
408} 407}
409 408
410void SetTime::minuteChanged( int value ) 409void SetTime::minuteChanged( int value )
411{ 410{
412 minute = value; 411 minute = value;
413} 412}
414 413
415void SetTime::show12hourTime( int on ) 414void SetTime::show12hourTime( int on )
416{ 415{
417 use12hourTime = on; 416 use12hourTime = on;
418 ampm->setEnabled(on); 417 ampm->setEnabled(on);
419 418
420 int show_hour = hour; 419 int show_hour = hour;
421 if ( on ) { 420 if ( on ) {
422 /* this might change the value of hour */ 421 /* this might change the value of hour */
423 sbHour->setMinValue(1); 422 sbHour->setMinValue(1);
424 sbHour->setMaxValue( 12 ); 423 sbHour->setMaxValue( 12 );
425 424
426 /* so use one we saved earlier */ 425 /* so use one we saved earlier */
427 if (show_hour >= 12) { 426 if (show_hour >= 12) {
428 show_hour -= 12; 427 show_hour -= 12;
429 ampm->setCurrentItem( ValuePM ); 428 ampm->setCurrentItem( ValuePM );
430 } else { 429 } else {
431 ampm->setCurrentItem( ValueAM ); 430 ampm->setCurrentItem( ValueAM );
432 } 431 }
433 if (show_hour == 0) 432 if (show_hour == 0)
434 show_hour = 12; 433 show_hour = 12;
435 434
436 } else { 435 } else {
437 sbHour->setMinValue( 0 ); 436 sbHour->setMinValue( 0 );
438 sbHour->setMaxValue( 23 ); 437 sbHour->setMaxValue( 23 );
439 } 438 }
440 439
441 440
442 sbHour->setValue( show_hour ); 441 sbHour->setValue( show_hour );
443} 442}
444 443
445void SetTime::checkedPM( int c ) 444void SetTime::checkedPM( int c )
446{ 445{
447 int show_hour = sbHour->value(); 446 int show_hour = sbHour->value();
448 if (show_hour == 12) 447 if (show_hour == 12)
449 show_hour = 0; 448 show_hour = 0;
450 449
451 if ( c == ValuePM ) 450 if ( c == ValuePM )
452 show_hour += 12; 451 show_hour += 12;
453 452
454 hour = show_hour; 453 hour = show_hour;
455} 454}
456 455
457void SetTime::slotTzChange( const QString &tz ) 456void SetTime::slotTzChange( const QString &tz )
458{ 457{
459 qDebug("SetTime::slotTzChange");
460 // set the TZ get the time and leave gracefully... 458 // set the TZ get the time and leave gracefully...
461 QString strSave; 459 QString strSave;
462 strSave = getenv( "TZ" ); 460 strSave = getenv( "TZ" );
463 setenv( "TZ", tz, 1 ); 461 setenv( "TZ", tz, 1 );
464 462
465 QTime t = QTime::currentTime(); 463 QTime t = QTime::currentTime();
466 // reset the time. 464 // reset the time.
467 if ( !strSave.isNull() ) { 465 if ( !strSave.isNull() ) {
468 setenv( "TZ", strSave, 1 ); 466 setenv( "TZ", strSave, 1 );
469 } 467 }
470 468
471 // just set the spinboxes and let it propage through 469 // just set the spinboxes and let it propage through
472 if(use12hourTime) { 470 if(use12hourTime) {
473 int show_hour = t.hour(); 471 int show_hour = t.hour();
474 if (t.hour() >= 12) { 472 if (t.hour() >= 12) {
475 show_hour -= 12; 473 show_hour -= 12;
476 ampm->setCurrentItem( ValuePM ); 474 ampm->setCurrentItem( ValuePM );
477 } else { 475 } else {
478 ampm->setCurrentItem( ValueAM ); 476 ampm->setCurrentItem( ValueAM );
479 } 477 }
480 if (show_hour == 0) 478 if (show_hour == 0)
481 show_hour = 12; 479 show_hour = 12;
482 sbHour->setValue( show_hour ); 480 sbHour->setValue( show_hour );
483 } else { 481 } else {
484 sbHour->setValue( t.hour() ); 482 sbHour->setValue( t.hour() );
485 } 483 }
486 sbMin->setValue( t.minute() ); 484 sbMin->setValue( t.minute() );
487} 485}
488 486
489 487