summaryrefslogtreecommitdiff
authortille <tille>2002-06-25 20:10:42 (UTC)
committer tille <tille>2002-06-25 20:10:42 (UTC)
commit4c671979117dc8ec75c91ce543c7039730530a63 (patch) (unidiff)
tree69995a8c917fba569814fd0475e7819a95d65ac5
parentaf4a3940dd672423da28b54e5d955cc5d33cecda (diff)
downloadopie-4c671979117dc8ec75c91ce543c7039730530a63.zip
opie-4c671979117dc8ec75c91ce543c7039730530a63.tar.gz
opie-4c671979117dc8ec75c91ce543c7039730530a63.tar.bz2
working
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp77
-rw-r--r--noncore/settings/netsystemtime/ntp.h13
-rw-r--r--noncore/settings/netsystemtime/ntpbase.ui171
-rw-r--r--noncore/settings/netsystemtime/settime.cpp27
-rw-r--r--noncore/settings/netsystemtime/settime.h10
5 files changed, 212 insertions, 86 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 87b20ec..4a7959e 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -1,191 +1,216 @@
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 <qtable.h> 4#include <qtable.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qsocket.h>
6#include <qlineedit.h> 7#include <qlineedit.h>
8#include <qspinbox.h>
7#include <qmultilineedit.h> 9#include <qmultilineedit.h>
8#include <opie/oprocess.h> 10#include <opie/oprocess.h>
9#include <qpe/config.h> 11#include <qpe/config.h>
10#include <qpe/global.h> 12#include <qpe/global.h>
11#include <qpe/timeconversion.h> 13#include <qpe/timeconversion.h>
12#include <qpe/tzselect.h> 14#include <qpe/tzselect.h>
13#include <qpe/timestring.h> 15#include <qpe/timestring.h>
14#include <qpe/qpedialog.h> 16#include <qpe/qpedialog.h>
15#include <sys/time.h> 17#include <sys/time.h>
16#include <time.h> 18#include <time.h>
17#include <stdlib.h> 19#include <stdlib.h>
18 20
19 21
20Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 22Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
21 : SetDateTime( parent, name, fl ) 23 : SetDateTime( parent, name, fl )
22{ 24{
23 Config cfg("ntp",Config::User); 25 Config cfg("ntp",Config::User);
24 cfg.setGroup("settings"); 26 cfg.setGroup("settings");
25 _maxOffset = cfg.readNumEntry("maxOffset",5); 27 // _maxOffset = cfg.readNumEntry("maxOffset",5);
26 _minLookupDiff = cfg.readNumEntry("minLookupDiff",10); 28// _minLookupDiff = cfg.readNumEntry("minLookupDiff",10);
27 LineEditNtpServer->setText( cfg.readEntry("ntpServer") ); 29 SpinBoxMinDelay->setValue( cfg.readNumEntry("minLookupDiff",10) );
30 SpinBoxMinDelay->setMinValue( 7 );
31 LineEditNtpSrv->setText( cfg.readEntry("ntpServer", tr("time.fu-berlin.de")) );
28 ntpProcess = new OProcess( ); 32 ntpProcess = new OProcess( );
33
34 QSocket *ntpSock = new QSocket( this );
35 ntpSock->connectToHost( LineEditNtpSrv->text() ,123);
36 connect( ntpSock, SIGNAL( error(int) ),
37 SLOT(slotCheckNtp(int)) );
38
29 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 39 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
30 this, SLOT(getNtpOutput(OProcess*,char*,int))); 40 this, SLOT(getNtpOutput(OProcess*,char*,int)));
31 connect ( ntpProcess, SIGNAL(processExited(OProcess*)), 41 connect ( ntpProcess, SIGNAL(processExited(OProcess*)),
32 this, SLOT(ntpFinished(OProcess*))); 42 this, SLOT(ntpFinished(OProcess*)));
33 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); 43 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp()));
34 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); 44 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime()));
35 // _nextCorrection = new QTimer( this ); 45
36// connect( _nextCorrection, SIGNAL(timeout()), SLOT(correctClock()) ); 46// slotRunNtp();
37 slotRunNtp();
38 readLookups(); 47 readLookups();
39} 48}
40 49
41Ntp::~Ntp() 50Ntp::~Ntp()
42{ 51{
43
44}
45
46void Ntp::accept()
47{
48 Config cfg("ntp",Config::User); 52 Config cfg("ntp",Config::User);
49 cfg.setGroup("settings"); 53 cfg.setGroup("settings");
50 cfg.writeEntry("ntpServer", LineEditNtpServer->text()); 54 cfg.writeEntry("ntpServer", LineEditNtpSrv->text());
55 cfg.writeEntry( "minLookupDiff", SpinBoxMinDelay->value() );
51} 56}
52 57
53 58
54void Ntp::slotRunNtp() 59void Ntp::slotRunNtp()
55{ 60{
56 TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); 61 TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
57 ntpProcess->clearArguments(); 62 ntpProcess->clearArguments();
58 *ntpProcess << "ntpdate" << LineEditNtpServer->text(); 63 *ntpProcess << "ntpdate" << LineEditNtpSrv->text();
59 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 64 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
60 if ( !ret ) { 65 if ( !ret ) {
61 qDebug("Error while executing ntp"); 66 qDebug("Error while executing ntp");
62 } 67 }
63} 68}
64 69
65void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) 70void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
66{ 71{
67 QString lineStr, lineStrOld; 72 QString lineStr, lineStrOld;
68 lineStr = buffer; 73 lineStr = buffer;
69 lineStr=lineStr.left(buflen); 74 lineStr=lineStr.left(buflen);
70 if (lineStr!=lineStrOld) 75 if (lineStr!=lineStrOld)
71 { 76 {
72 // outPut->append(lineStr); 77 MultiLineEditntpOutPut->append(lineStr);
73 _ntpOutput += lineStr; 78 _ntpOutput += lineStr;
74 } 79 }
75 lineStrOld = lineStr; 80 lineStrOld = lineStr;
76} 81}
77 82
78void Ntp::ntpFinished(OProcess*) 83void Ntp::ntpFinished(OProcess*)
79{ 84{
80 Config cfg("ntp",Config::User); 85 Config cfg("ntp",Config::User);
81 cfg.setGroup("lookups"); 86 cfg.setGroup("lookups");
82 int lastLookup = cfg.readNumEntry("time",0); 87 int lastLookup = cfg.readNumEntry("time",0);
83 int lookupCount = cfg.readNumEntry("count",-1); 88 int lookupCount = cfg.readNumEntry("count",-1);
84 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 89 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
85 cfg.writeEntry("time", time); 90 cfg.writeEntry("time", time);
86 cfg.setGroup("correction"); 91 cfg.setGroup("correction");
87 cfg.writeEntry("time", time); 92 cfg.writeEntry("time", time);
88 93
89 float timeShift = getTimeShift(); 94 float timeShift = getTimeShift();
90 if (timeShift == 0.0) return; 95 if (timeShift == 0.0) return;
91 int secsSinceLast = time - lastLookup; 96 int secsSinceLast = time - lastLookup;
92 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 97 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
93 if ( lastLookup > 0 && secsSinceLast > 60*_minLookupDiff) 98 if ( lastLookup > 0 && secsSinceLast > 60*24* SpinBoxMinDelay->value())
94 { 99 {
95 lookupCount++; 100 lookupCount++;
96 cfg.writeEntry("count",lookupCount); 101 cfg.writeEntry("count",lookupCount);
97 cfg.setGroup("lookup_"+QString::number(lookupCount)); 102 cfg.setGroup("lookup_"+QString::number(lookupCount));
98 _shiftPerSec = timeShift / secsSinceLast; 103 _shiftPerSec = timeShift / secsSinceLast;
99// float nextCorr = _maxOffset / _shiftPerSec; 104// float nextCorr = _maxOffset / _shiftPerSec;
100 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 105 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
101 cfg.writeEntry("secsSinceLast",secsSinceLast); 106 cfg.writeEntry("secsSinceLast",secsSinceLast);
102 cfg.writeEntry("timeShift",QString::number(timeShift)); 107 cfg.writeEntry("timeShift",QString::number(timeShift));
103 } 108 }
104} 109}
105 110
106//void Ntp::correctClock() 111//void Ntp::correctClock()
107//{ 112//{
108 //qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1()); 113 //qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1());
109 //Config cfg("ntp",Config::User); 114 //Config cfg("ntp",Config::User);
110// cfg.setGroup("correction"); 115// cfg.setGroup("correction");
111 // int lastTime = cfg.readNumEntry("time",0); 116 // int lastTime = cfg.readNumEntry("time",0);
112// if ( lastTime == 0 ) 117// if ( lastTime == 0 )
113// { 118// {
114 // return; 119 // return;
115// } 120// }
116// int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); 121// int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
117// int corr = int((now - lastTime) * _shiftPerSec); 122// int corr = int((now - lastTime) * _shiftPerSec);
118// struct timeval myTv; 123// struct timeval myTv;
119// myTv.tv_sec = TimeConversion::toUTC( QDateTime::currentDateTime().addSecs(corr) ); 124// myTv.tv_sec = TimeConversion::toUTC( QDateTime::currentDateTime().addSecs(corr) );
120// myTv.tv_usec = 0; 125// myTv.tv_usec = 0;
121// 126//
122// if ( myTv.tv_sec != -1 ) 127// if ( myTv.tv_sec != -1 )
123// ::settimeofday( &myTv, 0 ); 128// ::settimeofday( &myTv, 0 );
124// Global::writeHWClock(); 129// Global::writeHWClock();
125// cfg.writeEntry("time",now); 130// cfg.writeEntry("time",now);
126 //qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1()); 131 //qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1());
127//} 132//}
128 133
129float Ntp::getTimeShift() 134float Ntp::getTimeShift()
130{ 135{
131 QString _offset = "offset"; 136 QString _offset = "offset";
132 QString _sec = "sec"; 137 QString _sec = "sec";
133 QRegExp _reOffset = QRegExp(_offset); 138 QRegExp _reOffset = QRegExp(_offset);
134 QRegExp _reEndOffset = QRegExp(_sec); 139 QRegExp _reEndOffset = QRegExp(_sec);
135 int posOffset = _reOffset.match( _ntpOutput ); 140 int posOffset = _reOffset.match( _ntpOutput );
136 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); 141 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset );
137 posOffset += _offset.length() + 1; 142 posOffset += _offset.length() + 1;
138 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); 143 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1);
139 qDebug("%s", _ntpOutput.latin1()); 144 qDebug("%s", _ntpOutput.latin1());
140 qDebug("diff = >%s<",diff.latin1()); 145 qDebug("diff = >%s<",diff.latin1());
141 TextLabelTimeShift->setText(diff); 146 TextLabelTimeShift->setText(diff);
142 return diff.toFloat(); 147 return diff.toFloat();
143} 148}
144 149
145void Ntp::readLookups() 150void Ntp::readLookups()
146{ 151{
147 Config cfg("ntp",Config::User); 152 Config cfg("ntp",Config::User);
148 cfg.setGroup("lookups"); 153 cfg.setGroup("lookups");
149 int lookupCount = cfg.readNumEntry("count",-1); 154 int lookupCount = cfg.readNumEntry("count",-1);
150 float last, shift, shiftPerSec; 155 float last, shift, shiftPerSec;
151 qDebug("lookupCount = %i",lookupCount); 156 qDebug("lookupCount = %i",lookupCount);
152 TableLookups->setNumCols( 3 ); 157 TableLookups->setNumCols( 3 );
153 TableLookups->setNumRows( lookupCount); 158 TableLookups->setNumRows( lookupCount);
154 TableLookups->horizontalHeader()->setLabel(2,"secsSinceLast"); 159 TableLookups->horizontalHeader()->setLabel(1,"secsSinceLast");
155 TableLookups->horizontalHeader()->setLabel(1,"timeShift"); 160 TableLookups->horizontalHeader()->setLabel(2,"timeShift");
156 TableLookups->horizontalHeader()->setLabel(0,"shift/s"); 161 TableLookups->horizontalHeader()->setLabel(0,"shift/s");
157 int cw = TableLookups->width()/4; 162 int cw = 50;//TableLookups->width()/4;
158 qDebug("column width %i",cw); 163 qDebug("column width %i",cw);
159 TableLookups->setColumnWidth( 0, cw ); 164 TableLookups->setColumnWidth( 0, cw+30 );
160 TableLookups->setColumnWidth( 1, cw ); 165 TableLookups->setColumnWidth( 1, cw );
161 TableLookups->setColumnWidth( 2, cw ); 166 TableLookups->setColumnWidth( 2, cw );
162 for (int i=0; i < lookupCount; i++) 167 for (int i=0; i < lookupCount; i++)
163 { 168 {
164 cfg.setGroup("lookup_"+QString::number(i)); 169 cfg.setGroup("lookup_"+QString::number(i));
165 last = cfg.readEntry("secsSinceLast",0).toFloat(); 170 last = cfg.readEntry("secsSinceLast",0).toFloat();
166 shift = QString(cfg.readEntry("timeShift",0)).toFloat(); 171 shift = QString(cfg.readEntry("timeShift",0)).toFloat();
167 qDebug("%i last %f",i,last); 172 // qDebug("%i last %f",i,last);
168 qDebug("%i shift %f",i,shift); 173 // qDebug("%i shift %f",i,shift);
169 shiftPerSec = shift / last; 174 shiftPerSec = shift / last;
170 _shiftPerSec += shiftPerSec; 175 _shiftPerSec += shiftPerSec;
171 TableLookups->setText( i,0,QString::number(shiftPerSec)); 176 TableLookups->setText( i,0,QString::number(shiftPerSec));
172 TableLookups->setText( i,1,QString::number(shift)); 177 TableLookups->setText( i,2,QString::number(shift));
173 TableLookups->setText( i,2,QString::number(last)); 178 TableLookups->setText( i,1,QString::number(last));
174 } 179 }
175 _shiftPerSec /= lookupCount+1; 180 _shiftPerSec /= lookupCount+1;
176 TextLabelShift->setText(QString::number(_shiftPerSec)); 181 TextLabelShift->setText(QString::number(_shiftPerSec));
177} 182}
178 183
179void Ntp::preditctTime() 184void Ntp::preditctTime()
180{ 185{
181 qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1()); 186 qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1());
182 Config cfg("ntp",Config::User); 187 Config cfg("ntp",Config::User);
183 cfg.setGroup("lookups"); 188 cfg.setGroup("lookups");
184 int lastTime = cfg.readNumEntry("time",0); 189 int lastTime = cfg.readNumEntry("time",0);
185 setenv( "TZ", tz->currentZone(), 1 ); 190 setenv( "TZ", tz->currentZone(), 1 );
186 int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); 191 int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
187 int corr = int((now - lastTime) * _shiftPerSec); 192 int corr = int((now - lastTime) * _shiftPerSec);
188 QDateTime dt = QDateTime::currentDateTime().addSecs(corr); 193 predictedTime = QDateTime::currentDateTime().addSecs(corr);
189 setTime(dt); 194 TextLabelPredTime->setText(predictedTime.toString());
190 TextLabelPredTime->setText(dt.toString()); 195 TextLabelMainPredTime->setText(predictedTime.toString());
196}
197
198void Ntp::setPredictTime()
199{
200 preditctTime();
201 setTime( predictedTime );
202}
203
204void Ntp::slotCheckNtp(int i)
205{
206 if (i == 0)
207 {
208 TextLabelMainPredTime->hide();
209 ButtonSetTime->setText( tr("Get time from network") );
210 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
211 }else{
212 preditctTime();
213 ButtonSetTime->setText( tr("Predict time") );
214 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
215 };
191} 216}
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h
index d2e238d..284ae27 100644
--- a/noncore/settings/netsystemtime/ntp.h
+++ b/noncore/settings/netsystemtime/ntp.h
@@ -1,41 +1,38 @@
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#include <qtimer.h>
6 5
7class OProcess; 6class OProcess;
8class QString; 7class QString;
9 8
10 9
11class Ntp : public SetDateTime 10class Ntp : public SetDateTime
12{ 11{
13 Q_OBJECT 12 Q_OBJECT
14 13
15public: 14public:
16 Ntp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 15 Ntp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
17 ~Ntp(); 16 ~Ntp();
18 17
19 OProcess *ntpProcess;
20
21protected: 18protected:
22 virtual void accept(); 19 QDateTime predictedTime;
20
23 21
24private: 22private:
25 QString _ntpOutput; 23 QString _ntpOutput;
26 int _maxOffset;
27 float _shiftPerSec; 24 float _shiftPerSec;
28 // QTimer *_nextCorrection; 25 OProcess *ntpProcess;
29 int _minLookupDiff;
30 26
31 float getTimeShift(); 27 float getTimeShift();
32 void readLookups(); 28 void readLookups();
33private slots: 29private slots:
34 void slotRunNtp(); 30 void slotRunNtp();
35 void getNtpOutput(OProcess *proc, char *buffer, int buflen); 31 void getNtpOutput(OProcess *proc, char *buffer, int buflen);
36 void ntpFinished(OProcess*); 32 void ntpFinished(OProcess*);
37// void correctClock();
38 void preditctTime(); 33 void preditctTime();
34 void slotCheckNtp(int);
35 void setPredictTime();
39}; 36};
40 37
41#endif 38#endif
diff --git a/noncore/settings/netsystemtime/ntpbase.ui b/noncore/settings/netsystemtime/ntpbase.ui
index ccae5bf..e444065 100644
--- a/noncore/settings/netsystemtime/ntpbase.ui
+++ b/noncore/settings/netsystemtime/ntpbase.ui
@@ -1,482 +1,587 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>NtpBase</class> 2<class>NtpBase</class>
3<widget> 3<widget>
4 <class>QDialog</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>280</width> 14 <width>276</width>
15 <height>337</height> 15 <height>337</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>1</number> 35 <number>1</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>3</number> 62 <number>3</number>
63 </property> 63 </property>
64 <property stdset="1"> 64 <property stdset="1">
65 <name>spacing</name> 65 <name>spacing</name>
66 <number>3</number> 66 <number>3</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>3</number> 98 <number>3</number>
99 </property> 99 </property>
100 <property stdset="1"> 100 <property stdset="1">
101 <name>spacing</name> 101 <name>spacing</name>
102 <number>3</number> 102 <number>3</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 <grid> 132 <grid>
133 <property stdset="1"> 133 <property stdset="1">
134 <name>margin</name> 134 <name>margin</name>
135 <number>11</number> 135 <number>11</number>
136 </property> 136 </property>
137 <property stdset="1"> 137 <property stdset="1">
138 <name>spacing</name> 138 <name>spacing</name>
139 <number>6</number> 139 <number>6</number>
140 </property> 140 </property>
141 <widget row="0" column="0" > 141 <widget row="0" column="0" >
142 <class>QLayoutWidget</class> 142 <class>QLayoutWidget</class>
143 <property stdset="1"> 143 <property stdset="1">
144 <name>name</name> 144 <name>name</name>
145 <cstring>Layout4</cstring> 145 <cstring>Layout4</cstring>
146 </property> 146 </property>
147 <vbox> 147 <vbox>
148 <property stdset="1"> 148 <property stdset="1">
149 <name>margin</name> 149 <name>margin</name>
150 <number>0</number> 150 <number>0</number>
151 </property> 151 </property>
152 <property stdset="1"> 152 <property stdset="1">
153 <name>spacing</name> 153 <name>spacing</name>
154 <number>6</number> 154 <number>6</number>
155 </property> 155 </property>
156 <widget> 156 <widget>
157 <class>QLabel</class> 157 <class>QLabel</class>
158 <property stdset="1"> 158 <property stdset="1">
159 <name>name</name> 159 <name>name</name>
160 <cstring>TextLabel1</cstring> 160 <cstring>TextLabel1</cstring>
161 </property> 161 </property>
162 <property stdset="1"> 162 <property stdset="1">
163 <name>autoMask</name> 163 <name>autoMask</name>
164 <bool>false</bool> 164 <bool>false</bool>
165 </property> 165 </property>
166 <property stdset="1"> 166 <property stdset="1">
167 <name>text</name> 167 <name>text</name>
168 <string>Start Time:</string> 168 <string>Start Time:</string>
169 </property> 169 </property>
170 </widget> 170 </widget>
171 <widget> 171 <widget>
172 <class>QLabel</class> 172 <class>QLabel</class>
173 <property stdset="1"> 173 <property stdset="1">
174 <name>name</name> 174 <name>name</name>
175 <cstring>TextLabelStartTime</cstring> 175 <cstring>TextLabelStartTime</cstring>
176 </property> 176 </property>
177 <property stdset="1"> 177 <property stdset="1">
178 <name>text</name> 178 <name>text</name>
179 <string>nan</string> 179 <string>nan</string>
180 </property> 180 </property>
181 </widget> 181 </widget>
182 <widget> 182 <widget>
183 <class>QLabel</class> 183 <class>QLabel</class>
184 <property stdset="1"> 184 <property stdset="1">
185 <name>name</name> 185 <name>name</name>
186 <cstring>TextLabel3</cstring> 186 <cstring>TextLabel3</cstring>
187 </property> 187 </property>
188 <property stdset="1"> 188 <property stdset="1">
189 <name>text</name> 189 <name>text</name>
190 <string>Time Shift:</string> 190 <string>Time Shift:</string>
191 </property> 191 </property>
192 </widget> 192 </widget>
193 <widget> 193 <widget>
194 <class>QLabel</class> 194 <class>QLabel</class>
195 <property stdset="1"> 195 <property stdset="1">
196 <name>name</name> 196 <name>name</name>
197 <cstring>TextLabelTimeShift</cstring> 197 <cstring>TextLabelTimeShift</cstring>
198 </property> 198 </property>
199 <property stdset="1"> 199 <property stdset="1">
200 <name>text</name> 200 <name>text</name>
201 <string>nan</string> 201 <string>nan</string>
202 </property> 202 </property>
203 </widget> 203 </widget>
204 <widget> 204 <widget>
205 <class>QLabel</class> 205 <class>QLabel</class>
206 <property stdset="1"> 206 <property stdset="1">
207 <name>name</name> 207 <name>name</name>
208 <cstring>TextLabel5</cstring> 208 <cstring>TextLabel5</cstring>
209 </property> 209 </property>
210 <property stdset="1"> 210 <property stdset="1">
211 <name>text</name> 211 <name>text</name>
212 <string>New Time:</string> 212 <string>New Time:</string>
213 </property> 213 </property>
214 </widget> 214 </widget>
215 <widget> 215 <widget>
216 <class>QLabel</class> 216 <class>QLabel</class>
217 <property stdset="1"> 217 <property stdset="1">
218 <name>name</name> 218 <name>name</name>
219 <cstring>TextLabelNewTime</cstring> 219 <cstring>TextLabelNewTime</cstring>
220 </property> 220 </property>
221 <property stdset="1"> 221 <property stdset="1">
222 <name>text</name> 222 <name>text</name>
223 <string>nan</string> 223 <string>nan</string>
224 </property> 224 </property>
225 </widget> 225 </widget>
226 <spacer> 226 <spacer>
227 <property> 227 <property>
228 <name>name</name> 228 <name>name</name>
229 <cstring>Spacer1</cstring> 229 <cstring>Spacer1</cstring>
230 </property> 230 </property>
231 <property stdset="1"> 231 <property stdset="1">
232 <name>orientation</name> 232 <name>orientation</name>
233 <enum>Vertical</enum> 233 <enum>Vertical</enum>
234 </property> 234 </property>
235 <property stdset="1"> 235 <property stdset="1">
236 <name>sizeType</name> 236 <name>sizeType</name>
237 <enum>Expanding</enum> 237 <enum>Expanding</enum>
238 </property> 238 </property>
239 <property> 239 <property>
240 <name>sizeHint</name> 240 <name>sizeHint</name>
241 <size> 241 <size>
242 <width>20</width> 242 <width>20</width>
243 <height>20</height> 243 <height>20</height>
244 </size> 244 </size>
245 </property> 245 </property>
246 </spacer> 246 </spacer>
247 </vbox> 247 </vbox>
248 </widget> 248 </widget>
249 <widget row="1" column="0" > 249 <widget row="1" column="0" >
250 <class>QLayoutWidget</class> 250 <class>QMultiLineEdit</class>
251 <property stdset="1"> 251 <property stdset="1">
252 <name>name</name> 252 <name>name</name>
253 <cstring>Layout6</cstring> 253 <cstring>MultiLineEditntpOutPut</cstring>
254 </property>
255 <property stdset="1">
256 <name>wordWrap</name>
257 <enum>WidgetWidth</enum>
254 </property> 258 </property>
255 <hbox>
256 <property stdset="1">
257 <name>margin</name>
258 <number>0</number>
259 </property>
260 <property stdset="1">
261 <name>spacing</name>
262 <number>6</number>
263 </property>
264 <widget>
265 <class>QLabel</class>
266 <property stdset="1">
267 <name>name</name>
268 <cstring>TextLabel7</cstring>
269 </property>
270 <property stdset="1">
271 <name>text</name>
272 <string>NTP Server:</string>
273 </property>
274 </widget>
275 <widget>
276 <class>QLineEdit</class>
277 <property stdset="1">
278 <name>name</name>
279 <cstring>LineEditNtpServer</cstring>
280 </property>
281 </widget>
282 </hbox>
283 </widget> 259 </widget>
284 </grid> 260 </grid>
285 </widget> 261 </widget>
286 </grid> 262 </grid>
287 </widget> 263 </widget>
288 <widget> 264 <widget>
289 <class>QWidget</class> 265 <class>QWidget</class>
290 <property stdset="1"> 266 <property stdset="1">
291 <name>name</name> 267 <name>name</name>
292 <cstring>tab</cstring> 268 <cstring>tab</cstring>
293 </property> 269 </property>
294 <attribute> 270 <attribute>
295 <name>title</name> 271 <name>title</name>
296 <string>Auto</string> 272 <string>Predict</string>
297 </attribute> 273 </attribute>
298 <grid> 274 <grid>
299 <property stdset="1"> 275 <property stdset="1">
300 <name>margin</name> 276 <name>margin</name>
301 <number>2</number> 277 <number>2</number>
302 </property> 278 </property>
303 <property stdset="1"> 279 <property stdset="1">
304 <name>spacing</name> 280 <name>spacing</name>
305 <number>2</number> 281 <number>2</number>
306 </property> 282 </property>
307 <widget row="0" column="0" > 283 <widget row="0" column="0" >
308 <class>QTable</class> 284 <class>QTable</class>
309 <property stdset="1"> 285 <property stdset="1">
310 <name>name</name> 286 <name>name</name>
311 <cstring>TableLookups</cstring> 287 <cstring>TableLookups</cstring>
312 </property> 288 </property>
313 <property stdset="1"> 289 <property stdset="1">
314 <name>numRows</name> 290 <name>numRows</name>
315 <number>2</number> 291 <number>2</number>
316 </property> 292 </property>
317 <property stdset="1"> 293 <property stdset="1">
318 <name>numCols</name> 294 <name>numCols</name>
319 <number>2</number> 295 <number>2</number>
320 </property> 296 </property>
321 </widget> 297 </widget>
322 <widget row="2" column="0" > 298 <widget row="2" column="0" >
323 <class>QPushButton</class> 299 <class>QPushButton</class>
324 <property stdset="1"> 300 <property stdset="1">
325 <name>name</name> 301 <name>name</name>
326 <cstring>PushButtonPredict</cstring> 302 <cstring>PushButtonPredict</cstring>
327 </property> 303 </property>
328 <property stdset="1"> 304 <property stdset="1">
329 <name>text</name> 305 <name>text</name>
330 <string>predict time</string> 306 <string>predict time</string>
331 </property> 307 </property>
332 </widget> 308 </widget>
333 <widget row="1" column="0" > 309 <widget row="1" column="0" >
334 <class>QLayoutWidget</class> 310 <class>QLayoutWidget</class>
335 <property stdset="1"> 311 <property stdset="1">
336 <name>name</name> 312 <name>name</name>
337 <cstring>Layout5</cstring> 313 <cstring>Layout5</cstring>
338 </property> 314 </property>
339 <grid> 315 <grid>
340 <property stdset="1"> 316 <property stdset="1">
341 <name>margin</name> 317 <name>margin</name>
342 <number>0</number> 318 <number>0</number>
343 </property> 319 </property>
344 <property stdset="1"> 320 <property stdset="1">
345 <name>spacing</name> 321 <name>spacing</name>
346 <number>6</number> 322 <number>6</number>
347 </property> 323 </property>
348 <widget row="0" column="1" > 324 <widget row="0" column="1" >
349 <class>QLabel</class> 325 <class>QLabel</class>
350 <property stdset="1"> 326 <property stdset="1">
351 <name>name</name> 327 <name>name</name>
352 <cstring>TextLabelShift</cstring> 328 <cstring>TextLabelShift</cstring>
353 </property> 329 </property>
354 <property stdset="1"> 330 <property stdset="1">
355 <name>text</name> 331 <name>text</name>
356 <string>nan</string> 332 <string>nan</string>
357 </property> 333 </property>
358 </widget> 334 </widget>
359 <widget row="1" column="1" > 335 <widget row="1" column="1" >
360 <class>QLabel</class> 336 <class>QLabel</class>
361 <property stdset="1"> 337 <property stdset="1">
362 <name>name</name> 338 <name>name</name>
363 <cstring>TextLabelPredTime</cstring> 339 <cstring>TextLabelPredTime</cstring>
364 </property> 340 </property>
365 <property stdset="1"> 341 <property stdset="1">
366 <name>text</name> 342 <name>text</name>
367 <string>nan</string> 343 <string>nan</string>
368 </property> 344 </property>
369 </widget> 345 </widget>
370 <widget row="0" column="0" > 346 <widget row="0" column="0" >
371 <class>QLabel</class> 347 <class>QLabel</class>
372 <property stdset="1"> 348 <property stdset="1">
373 <name>name</name> 349 <name>name</name>
374 <cstring>Mean_shift_label</cstring> 350 <cstring>Mean_shift_label</cstring>
375 </property> 351 </property>
376 <property stdset="1"> 352 <property stdset="1">
377 <name>text</name> 353 <name>text</name>
378 <string>Mean shift:</string> 354 <string>Mean shift:</string>
379 </property> 355 </property>
380 </widget> 356 </widget>
381 <widget row="1" column="0" > 357 <widget row="1" column="0" >
382 <class>QLabel</class> 358 <class>QLabel</class>
383 <property stdset="1"> 359 <property stdset="1">
384 <name>name</name> 360 <name>name</name>
385 <cstring>TextLabel3_2</cstring> 361 <cstring>TextLabel3_2</cstring>
386 </property> 362 </property>
387 <property stdset="1"> 363 <property stdset="1">
388 <name>text</name> 364 <name>text</name>
389 <string>Pred. Time:</string> 365 <string>Pred. Time:</string>
390 </property> 366 </property>
391 </widget> 367 </widget>
392 </grid> 368 </grid>
393 </widget> 369 </widget>
394 </grid> 370 </grid>
395 </widget> 371 </widget>
396 <widget> 372 <widget>
397 <class>QWidget</class> 373 <class>QWidget</class>
398 <property stdset="1"> 374 <property stdset="1">
399 <name>name</name> 375 <name>name</name>
400 <cstring>TabSettings</cstring> 376 <cstring>TabSettings</cstring>
401 </property> 377 </property>
402 <attribute> 378 <attribute>
403 <name>title</name> 379 <name>title</name>
404 <string>Settings</string> 380 <string>Settings</string>
405 </attribute> 381 </attribute>
406 <grid> 382 <grid>
407 <property stdset="1"> 383 <property stdset="1">
408 <name>margin</name> 384 <name>margin</name>
409 <number>3</number> 385 <number>3</number>
410 </property> 386 </property>
411 <property stdset="1"> 387 <property stdset="1">
412 <name>spacing</name> 388 <name>spacing</name>
413 <number>3</number> 389 <number>3</number>
414 </property> 390 </property>
415 <widget row="0" column="0" > 391 <widget row="0" column="0" >
416 <class>QFrame</class> 392 <class>QFrame</class>
417 <property stdset="1"> 393 <property stdset="1">
418 <name>name</name> 394 <name>name</name>
419 <cstring>FrameSettings</cstring> 395 <cstring>FrameSettings</cstring>
420 </property> 396 </property>
421 <property stdset="1"> 397 <property stdset="1">
422 <name>frameShape</name> 398 <name>frameShape</name>
423 <enum>StyledPanel</enum> 399 <enum>StyledPanel</enum>
424 </property> 400 </property>
425 <property stdset="1"> 401 <property stdset="1">
426 <name>frameShadow</name> 402 <name>frameShadow</name>
427 <enum>Raised</enum> 403 <enum>Raised</enum>
428 </property> 404 </property>
405 <grid>
406 <property stdset="1">
407 <name>margin</name>
408 <number>11</number>
409 </property>
410 <property stdset="1">
411 <name>spacing</name>
412 <number>6</number>
413 </property>
414 <widget row="0" column="0" >
415 <class>QLayoutWidget</class>
416 <property stdset="1">
417 <name>name</name>
418 <cstring>Layout6</cstring>
419 </property>
420 <grid>
421 <property stdset="1">
422 <name>margin</name>
423 <number>0</number>
424 </property>
425 <property stdset="1">
426 <name>spacing</name>
427 <number>6</number>
428 </property>
429 <spacer row="2" column="0" >
430 <property>
431 <name>name</name>
432 <cstring>Spacer2</cstring>
433 </property>
434 <property stdset="1">
435 <name>orientation</name>
436 <enum>Vertical</enum>
437 </property>
438 <property stdset="1">
439 <name>sizeType</name>
440 <enum>Expanding</enum>
441 </property>
442 <property>
443 <name>sizeHint</name>
444 <size>
445 <width>20</width>
446 <height>20</height>
447 </size>
448 </property>
449 </spacer>
450 <widget row="1" column="0" >
451 <class>QLayoutWidget</class>
452 <property stdset="1">
453 <name>name</name>
454 <cstring>Layout6</cstring>
455 </property>
456 <hbox>
457 <property stdset="1">
458 <name>margin</name>
459 <number>0</number>
460 </property>
461 <property stdset="1">
462 <name>spacing</name>
463 <number>6</number>
464 </property>
465 <widget>
466 <class>QLabel</class>
467 <property stdset="1">
468 <name>name</name>
469 <cstring>TextLabel7_2</cstring>
470 </property>
471 <property stdset="1">
472 <name>text</name>
473 <string>NTP Server:</string>
474 </property>
475 </widget>
476 <widget>
477 <class>QLineEdit</class>
478 <property stdset="1">
479 <name>name</name>
480 <cstring>LineEditNtpSrv</cstring>
481 </property>
482 </widget>
483 </hbox>
484 </widget>
485 <widget row="0" column="0" >
486 <class>QLayoutWidget</class>
487 <property stdset="1">
488 <name>name</name>
489 <cstring>Layout5</cstring>
490 </property>
491 <hbox>
492 <property stdset="1">
493 <name>margin</name>
494 <number>0</number>
495 </property>
496 <property stdset="1">
497 <name>spacing</name>
498 <number>6</number>
499 </property>
500 <widget>
501 <class>QLabel</class>
502 <property stdset="1">
503 <name>name</name>
504 <cstring>TextLabel1_2</cstring>
505 </property>
506 <property stdset="1">
507 <name>text</name>
508 <string>Min. delay:</string>
509 </property>
510 </widget>
511 <widget>
512 <class>QSpinBox</class>
513 <property stdset="1">
514 <name>name</name>
515 <cstring>SpinBoxMinDelay</cstring>
516 </property>
517 </widget>
518 <widget>
519 <class>QLabel</class>
520 <property stdset="1">
521 <name>name</name>
522 <cstring>TextLabel2</cstring>
523 </property>
524 <property stdset="1">
525 <name>text</name>
526 <string>minutes</string>
527 </property>
528 </widget>
529 </hbox>
530 </widget>
531 </grid>
532 </widget>
533 </grid>
429 </widget> 534 </widget>
430 </grid> 535 </grid>
431 </widget> 536 </widget>
432 <widget> 537 <widget>
433 <class>QWidget</class> 538 <class>QWidget</class>
434 <property stdset="1"> 539 <property stdset="1">
435 <name>name</name> 540 <name>name</name>
436 <cstring>tabSetTime</cstring> 541 <cstring>tabSetTime</cstring>
437 </property> 542 </property>
438 <attribute> 543 <attribute>
439 <name>title</name> 544 <name>title</name>
440 <string>Manual</string> 545 <string>Manual</string>
441 </attribute> 546 </attribute>
442 <vbox> 547 <vbox>
443 <property stdset="1"> 548 <property stdset="1">
444 <name>margin</name> 549 <name>margin</name>
445 <number>2</number> 550 <number>2</number>
446 </property> 551 </property>
447 <property stdset="1"> 552 <property stdset="1">
448 <name>spacing</name> 553 <name>spacing</name>
449 <number>2</number> 554 <number>2</number>
450 </property> 555 </property>
451 <widget> 556 <widget>
452 <class>QFrame</class> 557 <class>QFrame</class>
453 <property stdset="1"> 558 <property stdset="1">
454 <name>name</name> 559 <name>name</name>
455 <cstring>FrameSetTime</cstring> 560 <cstring>FrameSetTime</cstring>
456 </property> 561 </property>
457 <property stdset="1"> 562 <property stdset="1">
458 <name>frameShape</name> 563 <name>frameShape</name>
459 <enum>StyledPanel</enum> 564 <enum>StyledPanel</enum>
460 </property> 565 </property>
461 <property stdset="1"> 566 <property stdset="1">
462 <name>frameShadow</name> 567 <name>frameShadow</name>
463 <enum>Raised</enum> 568 <enum>Raised</enum>
464 </property> 569 </property>
465 </widget> 570 </widget>
466 <widget> 571 <widget>
467 <class>QPushButton</class> 572 <class>QPushButton</class>
468 <property stdset="1"> 573 <property stdset="1">
469 <name>name</name> 574 <name>name</name>
470 <cstring>PushButtonSetManualTime</cstring> 575 <cstring>PushButtonSetManualTime</cstring>
471 </property> 576 </property>
472 <property stdset="1"> 577 <property stdset="1">
473 <name>text</name> 578 <name>text</name>
474 <string>Set time</string> 579 <string>Set time</string>
475 </property> 580 </property>
476 </widget> 581 </widget>
477 </vbox> 582 </vbox>
478 </widget> 583 </widget>
479 </widget> 584 </widget>
480 </grid> 585 </grid>
481</widget> 586</widget>
482</UI> 587</UI>
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index 01268c9..2cef6e8 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -1,461 +1,462 @@
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 );
64 vb->addWidget( TextLabelMainPredTime, 1, 0 );
65 ButtonSetTime = new QPushButton( FrameSystemTime );
66 vb->addWidget( ButtonSetTime, 1, 0 );
67
68 QFrame *hline = new QFrame( FrameSystemTime );
69 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
70 vb->addWidget( hline );
71
63 QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); 72 QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" );
64 73
65 QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); 74 QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" );
66 lblZone->setMaximumSize( lblZone->sizeHint() ); 75 lblZone->setMaximumSize( lblZone->sizeHint() );
67 hb->addWidget( lblZone ); 76 hb->addWidget( lblZone );
68 77
69 tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); 78 tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" );
70 tz->setMinimumSize( tz->sizeHint() ); 79 tz->setMinimumSize( tz->sizeHint() );
71 hb->addWidget( tz ); 80 hb->addWidget( tz );
72 81
73 timeButton = new SetTime( FrameSetTime ); 82 timeButton = new SetTime( FrameSetTime );
74 vb2->addWidget( timeButton ); 83 vb2->addWidget( timeButton );
75 84
76 QHBoxLayout *db = new QHBoxLayout( vb2 ); 85 QHBoxLayout *db = new QHBoxLayout( vb2 );
77 QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); 86 QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime );
78 db->addWidget( dateLabel, 1 ); 87 db->addWidget( dateLabel, 1 );
79 dateButton = new DateButton( TRUE, FrameSetTime ); 88 dateButton = new DateButton( TRUE, FrameSetTime );
80 db->addWidget( dateButton, 2 ); 89 db->addWidget( dateButton, 2 );
81 90
82 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 91 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
83 vb2->addItem( spacer ); 92 vb2->addItem( spacer );
84 93
85 QFrame *hline = new QFrame( FrameSystemTime ); 94 hline = new QFrame( FrameSystemTime );
86 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 95 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
87 vb->addWidget( hline ); 96 vb->addWidget( hline );
88 97
89 Config config("qpe"); 98 Config config("qpe");
90 config.setGroup( "Time" ); 99 config.setGroup( "Time" );
91 100
92 QHBoxLayout *hb1 = new QHBoxLayout( vb ); 101 QHBoxLayout *hb1 = new QHBoxLayout( vb );
93 102
94 QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); 103 QLabel *l = new QLabel( tr("Time format"), FrameSystemTime );
95 // l->setAlignment( AlignRight | AlignVCenter );
96 hb1->addWidget( l, 1 ); 104 hb1->addWidget( l, 1 );
97 105
98 106
99 ampmCombo = new QComboBox( FrameSystemTime ); 107 ampmCombo = new QComboBox( FrameSystemTime );
100 ampmCombo->insertItem( tr("24 hour"), 0 ); 108 ampmCombo->insertItem( tr("24 hour"), 0 );
101 ampmCombo->insertItem( tr("12 hour"), 1 ); 109 ampmCombo->insertItem( tr("12 hour"), 1 );
102 hb1->addWidget( ampmCombo, 2 ); 110 hb1->addWidget( ampmCombo, 2 );
103 111
104 int show12hr = config.readBoolEntry("AMPM") ? 1 : 0; 112 int show12hr = config.readBoolEntry("AMPM") ? 1 : 0;
105 ampmCombo->setCurrentItem( show12hr ); 113 ampmCombo->setCurrentItem( show12hr );
106 timeButton->show12hourTime( show12hr ); 114 timeButton->show12hourTime( show12hr );
107 115
108 connect(ampmCombo, SIGNAL(activated(int)), 116 connect(ampmCombo, SIGNAL(activated(int)),
109 timeButton, SLOT(show12hourTime(int))); 117 timeButton, SLOT(show12hourTime(int)));
110 118
111 119
112 120
113 QHBoxLayout *hb2 = new QHBoxLayout( vb ); 121 QHBoxLayout *hb2 = new QHBoxLayout( vb );
114 l = new QLabel( tr("Weeks start on" ), FrameSystemTime ); 122 l = new QLabel( tr("Weeks start on" ), FrameSystemTime );
115 //l->setAlignment( AlignRight | AlignVCenter ); 123 //l->setAlignment( AlignRight | AlignVCenter );
116 hb2->addWidget( l, 1 ); 124 hb2->addWidget( l, 1 );
117 125
118 weekStartCombo = new QComboBox( FrameSystemTime ); 126 weekStartCombo = new QComboBox( FrameSystemTime );
119 weekStartCombo->insertItem( tr("Sunday"), 0 ); 127 weekStartCombo->insertItem( tr("Sunday"), 0 );
120 weekStartCombo->insertItem( tr("Monday"), 1 ); 128 weekStartCombo->insertItem( tr("Monday"), 1 );
121 129
122 hb2->addWidget( weekStartCombo, 2 ); 130 hb2->addWidget( weekStartCombo, 2 );
123 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0; 131 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0;
124 dateButton->setWeekStartsMonday( startMonday ); 132 dateButton->setWeekStartsMonday( startMonday );
125 weekStartCombo->setCurrentItem( startMonday ); 133 weekStartCombo->setCurrentItem( startMonday );
126 134
127 connect( weekStartCombo, SIGNAL( activated(int)), 135 connect( weekStartCombo, SIGNAL( activated(int)),
128 dateButton, SLOT(setWeekStartsMonday(int))); 136 dateButton, SLOT(setWeekStartsMonday(int)));
129 137
130 138
131 QHBoxLayout *hb3 = new QHBoxLayout( vb ); 139 QHBoxLayout *hb3 = new QHBoxLayout( vb );
132 l = new QLabel( tr("Date format" ), FrameSystemTime ); 140 l = new QLabel( tr("Date format" ), FrameSystemTime );
133 hb3->addWidget( l, 1 ); 141 hb3->addWidget( l, 1 );
134 dateFormatCombo = new QComboBox( FrameSystemTime ); 142 dateFormatCombo = new QComboBox( FrameSystemTime );
135 hb3->addWidget( dateFormatCombo, 2 ); 143 hb3->addWidget( dateFormatCombo, 2 );
136 144
137 config.setGroup( "Date" ); 145 config.setGroup( "Date" );
138 DateFormat df(QChar(config.readEntry("Separator", "/")[0]), 146 DateFormat df(QChar(config.readEntry("Separator", "/")[0]),
139 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), 147 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
140 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); 148 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
141 149
142 int currentdf = 0; 150 int currentdf = 0;
143 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear); 151 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear);
144 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) ); 152 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) );
145 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear); 153 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear);
146 if (df == date_formats[1]) 154 if (df == date_formats[1])
147 currentdf = 1; 155 currentdf = 1;
148 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) ); 156 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) );
149 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay, 157 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay,
150 DateFormat::DayMonthYear); 158 DateFormat::DayMonthYear);
151 if (df == date_formats[2]) 159 if (df == date_formats[2])
152 currentdf = 2; 160 currentdf = 2;
153 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601 161 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601
154 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear); 162 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear);
155 if (df == date_formats[3]) 163 if (df == date_formats[3])
156 currentdf = 3; 164 currentdf = 3;
157 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) ); 165 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) );
158 166
159 dateFormatCombo->setCurrentItem( currentdf ); 167 dateFormatCombo->setCurrentItem( currentdf );
160 dateButton->setDateFormat( df ); 168 dateButton->setDateFormat( df );
161 169
162 connect( dateFormatCombo, SIGNAL( activated(int)), 170 connect( dateFormatCombo, SIGNAL( activated(int)),
163 SLOT(formatChanged(int))); 171 SLOT(formatChanged(int)));
164 172
165 QHBoxLayout *hb4 = new QHBoxLayout( vb ); 173 QHBoxLayout *hb4 = new QHBoxLayout( vb );
166 l = new QLabel( tr("Applet format" ), FrameSystemTime ); 174 l = new QLabel( tr("Applet format" ), FrameSystemTime );
167 hb4->addWidget( l, 1 ); 175 hb4->addWidget( l, 1 );
168 176
169 clockAppletCombo = new QComboBox( FrameSystemTime ); 177 clockAppletCombo = new QComboBox( FrameSystemTime );
170 clockAppletCombo->insertItem( tr("hh:mm"), 0 ); 178 clockAppletCombo->insertItem( tr("hh:mm"), 0 );
171 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); 179 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 );
172 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); 180 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 );
173 181
174 hb4->addWidget( clockAppletCombo, 2 ); 182 hb4->addWidget( clockAppletCombo, 2 );
175 int clockApplet = config.readNumEntry("ClockApplet",0); 183 int clockApplet = config.readNumEntry("ClockApplet",0);
176 clockAppletCombo->setCurrentItem( clockApplet ); 184 clockAppletCombo->setCurrentItem( clockApplet );
177 185
178 vb->addStretch( 0 ); 186 vb->addStretch( 0 );
179 187
188 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()),
189 this, SLOT(commitTime()));
190
180 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 191 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
181 timeButton, SLOT( slotTzChange( const QString& ) ) ); 192 timeButton, SLOT( slotTzChange( const QString& ) ) );
182 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 193 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
183 SLOT( tzChange( const QString& ) ) ); 194 SLOT( tzChange( const QString& ) ) );
184 QObject::connect( PushButtonSetManualTime, SLOT(clicked()),
185 SLOT(commitTime()));
186// dl = new QPEDialogListener(this);
187} 195}
188 196
189void SetDateTime::accept() 197SetDateTime::~SetDateTime()
190{ 198{
191 199
192 Config config("qpe"); 200 Config config("qpe");
193 config.setGroup( "Time" ); 201 config.setGroup( "Time" );
194 config.writeEntry( "AMPM", ampmCombo->currentItem() ); 202 config.writeEntry( "AMPM", ampmCombo->currentItem() );
195 config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); 203 config.writeEntry( "MONDAY", weekStartCombo->currentItem() );
196 config.setGroup( "Date" ); 204 config.setGroup( "Date" );
197 DateFormat df = date_formats[dateFormatCombo->currentItem()]; 205 DateFormat df = date_formats[dateFormatCombo->currentItem()];
198 config.writeEntry( "Separator", QString(df.separator())); 206 config.writeEntry( "Separator", QString(df.separator()));
199 config.writeEntry( "ShortOrder", df.shortOrder()); 207 config.writeEntry( "ShortOrder", df.shortOrder());
200 config.writeEntry( "LongOrder", df.longOrder()); 208 config.writeEntry( "LongOrder", df.longOrder());
201 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); 209 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() );
202 210
203 Config lconfig("locale"); 211 Config lconfig("locale");
204 lconfig.setGroup( "Location" ); 212 lconfig.setGroup( "Location" );
205 lconfig.writeEntry( "Timezone", tz->currentZone() ); 213 lconfig.writeEntry( "Timezone", tz->currentZone() );
206 214
207} 215}
208 216
209void SetDateTime::commitTime() 217void SetDateTime::commitTime()
210{ 218{
211 tz->setFocus(); 219 tz->setFocus();
212 // really turn off the screensaver before doing anything 220 // really turn off the screensaver before doing anything
213 { 221 {
214 // Needs to be encased in { } so that it deconstructs and sends 222 // Needs to be encased in { } so that it deconstructs and sends
215 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 223 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
216 disableScreenSaver << 0 << 0 << 0; 224 disableScreenSaver << 0 << 0 << 0;
217 } 225 }
218 // Need to process the QCOP event generated above before proceeding 226 // Need to process the QCOP event generated above before proceeding
219 qApp->processEvents(); 227 qApp->processEvents();
220 228
221 // before we progress further, set our TZ! 229 // before we progress further, set our TZ!
222 setenv( "TZ", tz->currentZone(), 1 ); 230 setenv( "TZ", tz->currentZone(), 1 );
223 // now set the time... 231 // now set the time...
224 QDateTime dt( dateButton->date(), timeButton->time() ); 232 QDateTime dt( dateButton->date(), timeButton->time() );
225 233
226 if ( dt.isValid() ) setTime(dt); 234 if ( dt.isValid() ) setTime(dt);
227} 235}
228 236
229void SetDateTime::setTime(QDateTime dt) 237void SetDateTime::setTime(QDateTime dt)
230{ 238{
231 Config cfg("ntp",Config::User); 239 Config cfg("ntp",Config::User);
232 cfg.setGroup("correction"); 240 cfg.setGroup("correction");
233 int t = TimeConversion::toUTC(dt); 241 int t = TimeConversion::toUTC(dt);
234 struct timeval myTv; 242 struct timeval myTv;
235 myTv.tv_sec = t; 243 myTv.tv_sec = t;
236 cfg.writeEntry("time", t ); 244 cfg.writeEntry("time", t );
237 myTv.tv_usec = 0; 245 myTv.tv_usec = 0;
238 246
239 if ( myTv.tv_sec != -1 ) 247 if ( myTv.tv_sec != -1 )
240 ::settimeofday( &myTv, 0 ); 248 ::settimeofday( &myTv, 0 );
241 Global::writeHWClock(); 249 Global::writeHWClock();
242 // since time has changed quickly load in the datebookdb 250 // since time has changed quickly load in the datebookdb
243 // to allow the alarm server to get a better grip on itself 251 // to allow the alarm server to get a better grip on itself
244 // (example re-trigger alarms for when we travel back in time) 252 // (example re-trigger alarms for when we travel back in time)
245 DateBookDB db; 253 DateBookDB db;
246 254
247 // set the timezone for everyone else... 255 // set the timezone for everyone else...
248 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); 256 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
249 setTimeZone << tz->currentZone(); 257 setTimeZone << tz->currentZone();
250 258
251 // AM/PM setting and notify time changed 259 // AM/PM setting and notify time changed
252 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); 260 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" );
253 setClock << ampmCombo->currentItem(); 261 setClock << ampmCombo->currentItem();
254 262
255 // Notify everyone what day we prefer to start the week on. 263 // Notify everyone what day we prefer to start the week on.
256 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); 264 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" );
257 setWeek << weekStartCombo->currentItem(); 265 setWeek << weekStartCombo->currentItem();
258 266
259 // Notify everyone what date format to use 267 // Notify everyone what date format to use
260 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); 268 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" );
261 setDateFormat << date_formats[dateFormatCombo->currentItem()]; 269 setDateFormat << date_formats[dateFormatCombo->currentItem()];
262 270
263 // Restore screensaver 271 // Restore screensaver
264 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 272 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
265 enableScreenSaver << -1 << -1 << -1; 273 enableScreenSaver << -1 << -1 << -1;
266 274
267 // QDialog::accept();
268}
269
270void SetDateTime::done(int r)
271{
272// QDialog::done(r);
273 close();
274} 275}
275 276
276void SetDateTime::tzChange( const QString &tz ) 277void SetDateTime::tzChange( const QString &tz )
277{ 278{
278 // set the TZ get the time and leave gracefully... 279 // set the TZ get the time and leave gracefully...
279 QString strSave; 280 QString strSave;
280 strSave = getenv( "TZ" ); 281 strSave = getenv( "TZ" );
281 setenv( "TZ", tz, 1 ); 282 setenv( "TZ", tz, 1 );
282 283
283 QDate d = QDate::currentDate(); 284 QDate d = QDate::currentDate();
284 // reset the time. 285 // reset the time.
285 if ( !strSave.isNull() ) { 286 if ( !strSave.isNull() ) {
286 setenv( "TZ", strSave, 1 ); 287 setenv( "TZ", strSave, 1 );
287 } 288 }
288 dateButton->setDate( d ); 289 dateButton->setDate( d );
289} 290}
290 291
291void SetDateTime::formatChanged(int i) 292void SetDateTime::formatChanged(int i)
292{ 293{
293 dateButton->setDateFormat(date_formats[i]); 294 dateButton->setDateFormat(date_formats[i]);
294} 295}
295 296
296static const int ValueAM = 0; 297static const int ValueAM = 0;
297static const int ValuePM = 1; 298static const int ValuePM = 1;
298 299
299 300
300 301
301SetTime::SetTime( QWidget *parent, const char *name ) 302SetTime::SetTime( QWidget *parent, const char *name )
302 : QWidget( parent, name ) 303 : QWidget( parent, name )
303{ 304{
304 use12hourTime = FALSE; 305 use12hourTime = FALSE;
305 306
306 QTime currTime = QTime::currentTime(); 307 QTime currTime = QTime::currentTime();
307 hour = currTime.hour(); 308 hour = currTime.hour();
308 minute = currTime.minute(); 309 minute = currTime.minute();
309 310
310 QHBoxLayout *hb2 = new QHBoxLayout( this ); 311 QHBoxLayout *hb2 = new QHBoxLayout( this );
311 hb2->setSpacing( 3 ); 312 hb2->setSpacing( 3 );
312 313
313 QLabel *l = new QLabel( tr("Hour"), this ); 314 QLabel *l = new QLabel( tr("Hour"), this );
314 // l->setAlignment( AlignRight | AlignVCenter ); 315 // l->setAlignment( AlignRight | AlignVCenter );
315 hb2->addWidget( l ); 316 hb2->addWidget( l );
316 317
317 sbHour = new QSpinBox( this ); 318 sbHour = new QSpinBox( this );
318 sbHour->setMinimumWidth( 30 ); 319 sbHour->setMinimumWidth( 30 );
319 if(use12hourTime) { 320 if(use12hourTime) {
320 sbHour->setMinValue(1); 321 sbHour->setMinValue(1);
321 sbHour->setMaxValue( 12 ); 322 sbHour->setMaxValue( 12 );
322 int show_hour = hour; 323 int show_hour = hour;
323 if (hour > 12) 324 if (hour > 12)
324 show_hour -= 12; 325 show_hour -= 12;
325 if (show_hour == 0) 326 if (show_hour == 0)
326 show_hour = 12; 327 show_hour = 12;
327 328
328 sbHour->setValue( show_hour ); 329 sbHour->setValue( show_hour );
329 } else { 330 } else {
330 sbHour->setMinValue( 0 ); 331 sbHour->setMinValue( 0 );
331 sbHour->setMaxValue( 23 ); 332 sbHour->setMaxValue( 23 );
332 sbHour->setValue( hour ); 333 sbHour->setValue( hour );
333 } 334 }
334 sbHour->setWrapping(TRUE); 335 sbHour->setWrapping(TRUE);
335 connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); 336 connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) );
336 hb2->addWidget( sbHour ); 337 hb2->addWidget( sbHour );
337 338
338 hb2->addStretch( 1 ); 339 hb2->addStretch( 1 );
339 340
340 l = new QLabel( tr("Minute"), this ); 341 l = new QLabel( tr("Minute"), this );
341 //l->setAlignment( AlignRight | AlignVCenter ); 342 //l->setAlignment( AlignRight | AlignVCenter );
342 hb2->addWidget( l ); 343 hb2->addWidget( l );
343 344
344 sbMin = new QSpinBox( this ); 345 sbMin = new QSpinBox( this );
345 sbMin->setMinValue( 0 ); 346 sbMin->setMinValue( 0 );
346 sbMin->setMaxValue( 59 ); 347 sbMin->setMaxValue( 59 );
347 sbMin->setWrapping(TRUE); 348 sbMin->setWrapping(TRUE);
348 sbMin->setValue( minute ); 349 sbMin->setValue( minute );
349 sbMin->setMinimumWidth( 30 ); 350 sbMin->setMinimumWidth( 30 );
350 connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); 351 connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) );
351 hb2->addWidget( sbMin ); 352 hb2->addWidget( sbMin );
352 353
353 hb2->addStretch( 1 ); 354 hb2->addStretch( 1 );
354 355
355 ampm = new QComboBox( this ); 356 ampm = new QComboBox( this );
356 ampm->insertItem( tr("AM"), ValueAM ); 357 ampm->insertItem( tr("AM"), ValueAM );
357 ampm->insertItem( tr("PM"), ValuePM ); 358 ampm->insertItem( tr("PM"), ValuePM );
358 connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) ); 359 connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) );
359 hb2->addWidget( ampm ); 360 hb2->addWidget( ampm );
360 361
361 hb2->addStretch( 1 ); 362 hb2->addStretch( 1 );
362 363
363} 364}
364 365
365QTime SetTime::time() const 366QTime SetTime::time() const
366{ 367{
367 return QTime( hour, minute, 0 ); 368 return QTime( hour, minute, 0 );
368} 369}
369 370
370void SetTime::hourChanged( int value ) 371void SetTime::hourChanged( int value )
371{ 372{
372 if(use12hourTime) { 373 if(use12hourTime) {
373 int realhour = value; 374 int realhour = value;
374 if (realhour == 12) 375 if (realhour == 12)
375 realhour = 0; 376 realhour = 0;
376 if (ampm->currentItem() == ValuePM ) 377 if (ampm->currentItem() == ValuePM )
377 realhour += 12; 378 realhour += 12;
378 hour = realhour; 379 hour = realhour;
379 } else 380 } else
380 hour = value; 381 hour = value;
381} 382}
382 383
383void SetTime::minuteChanged( int value ) 384void SetTime::minuteChanged( int value )
384{ 385{
385 minute = value; 386 minute = value;
386} 387}
387 388
388void SetTime::show12hourTime( int on ) 389void SetTime::show12hourTime( int on )
389{ 390{
390 use12hourTime = on; 391 use12hourTime = on;
391 ampm->setEnabled(on); 392 ampm->setEnabled(on);
392 393
393 int show_hour = hour; 394 int show_hour = hour;
394 if ( on ) { 395 if ( on ) {
395 /* this might change the value of hour */ 396 /* this might change the value of hour */
396 sbHour->setMinValue(1); 397 sbHour->setMinValue(1);
397 sbHour->setMaxValue( 12 ); 398 sbHour->setMaxValue( 12 );
398 399
399 /* so use one we saved earlier */ 400 /* so use one we saved earlier */
400 if (show_hour >= 12) { 401 if (show_hour >= 12) {
401 show_hour -= 12; 402 show_hour -= 12;
402 ampm->setCurrentItem( ValuePM ); 403 ampm->setCurrentItem( ValuePM );
403 } else { 404 } else {
404 ampm->setCurrentItem( ValueAM ); 405 ampm->setCurrentItem( ValueAM );
405 } 406 }
406 if (show_hour == 0) 407 if (show_hour == 0)
407 show_hour = 12; 408 show_hour = 12;
408 409
409 } else { 410 } else {
410 sbHour->setMinValue( 0 ); 411 sbHour->setMinValue( 0 );
411 sbHour->setMaxValue( 23 ); 412 sbHour->setMaxValue( 23 );
412 } 413 }
413 414
414 415
415 sbHour->setValue( show_hour ); 416 sbHour->setValue( show_hour );
416} 417}
417 418
418void SetTime::checkedPM( int c ) 419void SetTime::checkedPM( int c )
419{ 420{
420 int show_hour = sbHour->value(); 421 int show_hour = sbHour->value();
421 if (show_hour == 12) 422 if (show_hour == 12)
422 show_hour = 0; 423 show_hour = 0;
423 424
424 if ( c == ValuePM ) 425 if ( c == ValuePM )
425 show_hour += 12; 426 show_hour += 12;
426 427
427 hour = show_hour; 428 hour = show_hour;
428} 429}
429 430
430void SetTime::slotTzChange( const QString &tz ) 431void SetTime::slotTzChange( const QString &tz )
431{ 432{
432 // set the TZ get the time and leave gracefully... 433 // set the TZ get the time and leave gracefully...
433 QString strSave; 434 QString strSave;
434 strSave = getenv( "TZ" ); 435 strSave = getenv( "TZ" );
435 setenv( "TZ", tz, 1 ); 436 setenv( "TZ", tz, 1 );
436 437
437 QTime t = QTime::currentTime(); 438 QTime t = QTime::currentTime();
438 // reset the time. 439 // reset the time.
439 if ( !strSave.isNull() ) { 440 if ( !strSave.isNull() ) {
440 setenv( "TZ", strSave, 1 ); 441 setenv( "TZ", strSave, 1 );
441 } 442 }
442 443
443 // just set the spinboxes and let it propage through 444 // just set the spinboxes and let it propage through
444 if(use12hourTime) { 445 if(use12hourTime) {
445 int show_hour = t.hour(); 446 int show_hour = t.hour();
446 if (t.hour() >= 12) { 447 if (t.hour() >= 12) {
447 show_hour -= 12; 448 show_hour -= 12;
448 ampm->setCurrentItem( ValuePM ); 449 ampm->setCurrentItem( ValuePM );
449 } else { 450 } else {
450 ampm->setCurrentItem( ValueAM ); 451 ampm->setCurrentItem( ValueAM );
451 } 452 }
452 if (show_hour == 0) 453 if (show_hour == 0)
453 show_hour = 12; 454 show_hour = 12;
454 sbHour->setValue( show_hour ); 455 sbHour->setValue( show_hour );
455 } else { 456 } else {
456 sbHour->setValue( t.hour() ); 457 sbHour->setValue( t.hour() );
457 } 458 }
458 sbMin->setValue( t.minute() ); 459 sbMin->setValue( t.minute() );
459} 460}
460 461
461 462
diff --git a/noncore/settings/netsystemtime/settime.h b/noncore/settings/netsystemtime/settime.h
index 729bf4b..60423e7 100644
--- a/noncore/settings/netsystemtime/settime.h
+++ b/noncore/settings/netsystemtime/settime.h
@@ -1,98 +1,96 @@
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#ifndef SYSTEM_TIME_H 20#ifndef SYSTEM_TIME_H
21#define SYSTEM_TIME_H 21#define SYSTEM_TIME_H
22 22
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25#include <qdialog.h> 25#include <qdialog.h>
26 26
27#include <qpe/timestring.h> 27#include <qpe/timestring.h>
28#include "ntpbase.h" 28#include "ntpbase.h"
29 29
30class QToolButton; 30class QToolButton;
31class QSpinBox; 31class QSpinBox;
32class QLabel; 32class QLabel;
33class TimeZoneSelector; 33class TimeZoneSelector;
34class DateBookMonth; 34class DateBookMonth;
35class QComboBox; 35class QComboBox;
36//class QPEDialogListener;
37 36
38class SetTime : public QWidget 37class SetTime : public QWidget
39{ 38{
40 Q_OBJECT 39 Q_OBJECT
41public: 40public:
42 SetTime( QWidget *parent=0, const char *name=0 ); 41 SetTime( QWidget *parent=0, const char *name=0 );
43 42
44 QTime time() const; 43 QTime time() const;
45 44
46public slots: 45public slots:
47 void slotTzChange( const QString& tz ); 46 void slotTzChange( const QString& tz );
48 void show12hourTime( int ); 47 void show12hourTime( int );
49 48
50protected slots: 49protected slots:
51 void hourChanged( int value ); 50 void hourChanged( int value );
52 void minuteChanged( int value ); 51 void minuteChanged( int value );
53 52
54 void checkedPM( int ); 53 void checkedPM( int );
55 54
56protected: 55protected:
57 int hour; 56 int hour;
58 int minute; 57 int minute;
59 bool use12hourTime; 58 bool use12hourTime;
60 QComboBox *ampm; 59 QComboBox *ampm;
61 QSpinBox *sbHour; 60 QSpinBox *sbHour;
62 QSpinBox *sbMin; 61 QSpinBox *sbMin;
63}; 62};
64 63
65class DateButton; 64class DateButton;
66 65
67class SetDateTime : public NtpBase 66class SetDateTime : public NtpBase
68{ 67{
69 Q_OBJECT 68 Q_OBJECT
70public: 69public:
71 SetDateTime( QWidget *parent=0, const char *name=0, WFlags f=0 ); 70 SetDateTime( QWidget *parent=0, const char *name=0, WFlags f=0 );
71 ~SetDateTime();
72 72
73protected slots: 73protected slots:
74 void commitTime();
74 void tzChange( const QString &tz ); 75 void tzChange( const QString &tz );
75 void formatChanged(int); 76 void formatChanged(int);
76 77
77protected: 78protected:
78 void commitTime();
79 void setTime(QDateTime dt); 79 void setTime(QDateTime dt);
80 virtual void accept();
81 virtual void done(int);
82 80
83 SetTime *timeButton; 81 SetTime *timeButton;
84 DateButton *dateButton; 82 DateButton *dateButton;
85 TimeZoneSelector *tz; 83 TimeZoneSelector *tz;
86 QComboBox *weekStartCombo; 84 QComboBox *weekStartCombo;
87 QComboBox *ampmCombo; 85 QComboBox *ampmCombo;
88 QComboBox *dateFormatCombo; 86 QComboBox *dateFormatCombo;
89 QComboBox *clockAppletCombo; 87 QComboBox *clockAppletCombo;
90 88 QPushButton *ButtonSetTime;
91// QPEDialogListener *dl; 89 QLabel *TextLabelMainPredTime;
92 90
93 DateFormat date_formats[4]; 91 DateFormat date_formats[4];
94}; 92};
95 93
96 94
97#endif 95#endif
98 96