summaryrefslogtreecommitdiff
authordrw <drw>2005-02-23 16:14:09 (UTC)
committer drw <drw>2005-02-23 16:14:09 (UTC)
commite5b1e010c321ba1edac704f9d668df75b22fd074 (patch) (unidiff)
treec76221c7d8292f66ef05040721edf816a04fbeba
parent30857db6ca3f355aa3d50b59f03a13c82f265af2 (diff)
downloadopie-e5b1e010c321ba1edac704f9d668df75b22fd074.zip
opie-e5b1e010c321ba1edac704f9d668df75b22fd074.tar.gz
opie-e5b1e010c321ba1edac704f9d668df75b22fd074.tar.bz2
Fix UI to prevent error dialog from displaying when it shouldn't
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp61
-rw-r--r--noncore/settings/netsystemtime/ntptabwidget.cpp61
-rw-r--r--noncore/settings/netsystemtime/ntptabwidget.h46
-rw-r--r--noncore/settings/netsystemtime/timetabwidget.cpp57
-rw-r--r--noncore/settings/netsystemtime/timetabwidget.h47
5 files changed, 152 insertions, 120 deletions
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp
index 385d355..486257f 100644
--- a/noncore/settings/netsystemtime/mainwindow.cpp
+++ b/noncore/settings/netsystemtime/mainwindow.cpp
@@ -1,398 +1,413 @@
1/* 1/*
2                This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> 4 .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?>
5           .>+-= 5 .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6_;:, .> :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.-- : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12    .%`+i>       _;_. 12 .%`+i> _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13 .i_,=:_. -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.= = ; Public License for more details.
19++=   -.     .`     .: 19++= -. .` .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20: = ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21-. .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22 -_. . . )=. = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23 -- :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "mainwindow.h" 29#include "mainwindow.h"
30#include "timetabwidget.h" 30#include "timetabwidget.h"
31#include "formattabwidget.h" 31#include "formattabwidget.h"
32#include "settingstabwidget.h" 32#include "settingstabwidget.h"
33#include "ntptabwidget.h" 33#include "ntptabwidget.h"
34#include "predicttabwidget.h" 34#include "predicttabwidget.h"
35 35
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/datebookdb.h> 37#include <qpe/datebookdb.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qpe/qpedialog.h> 39#include <qpe/qpedialog.h>
40 40
41#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 41#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43#endif 43#endif
44 44
45#include <qlayout.h> 45#include <qlayout.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qsocket.h> 47#include <qsocket.h>
48#include <qstring.h> 48#include <qstring.h>
49#include <qtimer.h> 49#include <qtimer.h>
50 50
51using namespace Opie::Ui; 51using namespace Opie::Ui;
52using namespace Opie::Core; 52using namespace Opie::Core;
53MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) 53MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f )
54 : QDialog( 0x0, 0x0, TRUE, 0 ) 54 : QDialog( parent, name, modal, f )
55{ 55{
56 setCaption( tr( "SystemTime" ) ); 56 setCaption( tr( "SystemTime" ) );
57 57
58 QVBoxLayout *layout = new QVBoxLayout( this ); 58 QVBoxLayout *layout = new QVBoxLayout( this );
59 layout->setMargin( 2 ); 59 layout->setMargin( 2 );
60 layout->setSpacing( 4 ); 60 layout->setSpacing( 4 );
61 61
62 // Create main tabbed control 62 // Create main tabbed control
63 mainWidget = new OTabWidget( this ); 63 mainWidget = new OTabWidget( this );
64 64
65 // Default object pointers to null 65 // Default object pointers to null
66 ntpProcess = 0x0; 66 ntpProcess = 0x0;
67 ntpTab = 0x0; 67 ntpTab = 0x0;
68 68
69 // Add tab widgets 69 // Add tab widgets
70 mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); 70 mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) );
71 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); 71 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) );
72 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); 72 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) );
73 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); 73 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) );
74 Config config( "ntp" ); 74 Config config( "ntp" );
75 config.setGroup( "settings" ); 75 config.setGroup( "settings" );
76 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); 76 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) );
77 slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); 77 slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) );
78 78
79 mainWidget->setCurrentTab( tr( "Time" ) ); 79 mainWidget->setCurrentTab( tr( "Time" ) );
80 layout->addWidget( mainWidget ); 80 layout->addWidget( mainWidget );
81 81
82 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 82 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
83 this, SLOT(slotQCopReceive(const QCString&,const QByteArray&)) ); 83 this, SLOT(slotQCopReceive(const QCString&,const QByteArray&)) );
84 84
85 85
86 // Create NTP socket 86 // Create NTP socket
87 ntpSock = new QSocket( this ); 87 ntpSock = new QSocket( this );
88 connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); 88 connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) );
89 slotProbeNTPServer(); 89 slotProbeNTPServer();
90 90
91 // Create timer for automatic time lookups 91 // Create timer for automatic time lookups
92 ntpTimer = new QTimer( this ); 92 ntpTimer = new QTimer( this );
93 93
94 // Connect everything together 94 // Connect everything together
95 connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); 95 connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
96 connect( timeTab, SIGNAL(tzChanged(const QString&)), predictTab, SLOT(slotTZChanged(const QString&)) ); 96 connect( timeTab, SIGNAL(tzChanged(const QString&)), predictTab, SLOT(slotTZChanged(const QString&)) );
97 connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); 97 connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) );
98 connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime(int)) ); 98 connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime(int)) );
99 connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat&)), 99 connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat&)),
100 timeTab, SLOT(slotDateFormatChanged(const DateFormat&)) ); 100 timeTab, SLOT(slotDateFormatChanged(const DateFormat&)) );
101 connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); 101 connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) );
102 connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); 102 connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) );
103 connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); 103 connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) );
104 connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); 104 connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) );
105 connect( predictTab, SIGNAL(setTime(const QDateTime&)), this, SLOT(slotSetTime(const QDateTime&)) ); 105 connect( predictTab, SIGNAL(setTime(const QDateTime&)), this, SLOT(slotSetTime(const QDateTime&)) );
106 106
107 // Do initial time server check 107 // Do initial time server check
108 slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); 108 slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) );
109 slotCheckNtp( -1 ); 109 slotCheckNtp( -1 );
110 110
111 // Display app 111 // Display app
112 //showMaximized(); 112 //showMaximized();
113 (void)new QPEDialogListener(this); 113 (void)new QPEDialogListener(this);
114} 114}
115 115
116MainWindow::~MainWindow() 116MainWindow::~MainWindow()
117{ 117{
118 if ( ntpProcess ) 118 if ( ntpProcess )
119 delete ntpProcess; 119 delete ntpProcess;
120} 120}
121 121
122void MainWindow::accept() 122void MainWindow::accept()
123{ 123{
124 // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) 124 // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends)
125 { 125 {
126 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 126 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
127 disableScreenSaver << 0 << 0 << 0; 127 disableScreenSaver << 0 << 0 << 0;
128 } 128 }
129 129
130 // Update the systemtime 130 // Update the systemtime
131 timeTab->saveSettings( TRUE ); 131 timeTab->saveSettings( TRUE );
132 132
133 // Save format options 133 // Save format options
134 formatTab->saveSettings( TRUE ); 134 formatTab->saveSettings( TRUE );
135 135
136 // Save settings options 136 // Save settings options
137 settingsTab->saveSettings(); 137 settingsTab->saveSettings();
138 138
139 // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better 139 // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better
140 // grip on itself (example re-trigger alarms for when we travel back in time). 140 // grip on itself (example re-trigger alarms for when we travel back in time).
141 DateBookDB db; 141 DateBookDB db;
142 142
143 // Turn back on the screensaver 143 // Turn back on the screensaver
144 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 144 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
145 enableScreenSaver << -1 << -1 << -1; 145 enableScreenSaver << -1 << -1 << -1;
146 146
147 // Exit app 147 // Exit app
148 qApp->quit(); 148 qApp->quit();
149} 149}
150 150
151void MainWindow::reject() 151void MainWindow::reject()
152{ 152{
153 // Reset time settings 153 // Reset time settings
154 timeTab->saveSettings( FALSE ); 154 timeTab->saveSettings( FALSE );
155 155
156 // Send notifications but do not save settings 156 // Send notifications but do not save settings
157 formatTab->saveSettings( FALSE ); 157 formatTab->saveSettings( FALSE );
158 158
159 // Exit app 159 // Exit app
160 qApp->quit(); 160 qApp->quit();
161} 161}
162 162
163void MainWindow::runNTP() 163void MainWindow::runNTP()
164{ 164{
165 if ( !ntpDelayElapsed() && ntpInteractive ) 165 if ( !ntpDelayElapsed() && ntpInteractive )
166 { 166 {
167 QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); 167 QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) );
168 168
169 switch ( 169 switch (
170 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) 170 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No )
171 ) 171 )
172 { 172 {
173 case QMessageBox::Yes: break; 173 case QMessageBox::Yes: break;
174 case QMessageBox::No: return; 174 case QMessageBox::No: return;
175 default: return; 175 default: return;
176 } 176 }
177 } 177 }
178 178
179 QString srv = settingsTab->ntpServer(); 179 QString srv = settingsTab->ntpServer();
180 180
181 // Send information to time server tab if enabled 181 // Send information to time server tab if enabled
182 if ( ntpTabEnabled ) 182 if ( ntpTabEnabled )
183 { 183 {
184 ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); 184 ntpTab->setStartTime( QDateTime::currentDateTime().toString() );
185 QString output = tr( "Running:\nntpdate " ); 185 QString output = tr( "Running:\nntpdate " );
186 output.append( srv ); 186 output.append( srv );
187 ntpTab->addNtpOutput( output ); 187 ntpTab->addNtpOutput( output );
188 } 188 }
189 189
190 // Disable set time buttons & change app caption to indicate time update is happening
191 ntpTab->setNTPBtnEnabled( false );
192 timeTab->setNTPBtnEnabled( false );
193 setCaption( tr( "Retrieving time from network..." ) );
194
190 if ( !ntpProcess ) 195 if ( !ntpProcess )
191 { 196 {
192 ntpProcess = new OProcess(); 197 ntpProcess = new OProcess();
193 connect( ntpProcess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), 198 connect( ntpProcess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
194 this, SLOT(slotNtpOutput(Opie::Core::OProcess*,char*,int)) ); 199 this, SLOT(slotNtpOutput(Opie::Core::OProcess*,char*,int)) );
195 connect( ntpProcess, SIGNAL(processExited(Opie::Core::OProcess*)), 200 connect( ntpProcess, SIGNAL(processExited(Opie::Core::OProcess*)),
196 this, SLOT(slotNtpFinished(Opie::Core::OProcess*)) ); 201 this, SLOT(slotNtpFinished(Opie::Core::OProcess*)) );
197 } 202 }
198 203
199 else 204 else
200 ntpProcess->clearArguments(); 205 ntpProcess->clearArguments();
201 206
202 *ntpProcess << "ntpdate" << srv; 207 *ntpProcess << "ntpdate" << srv;
203 bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); 208 bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput );
204 if ( !ret ) 209 if ( !ret )
205 { 210 {
206 QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); 211 QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) );
207 if ( ntpTabEnabled ) 212 if ( ntpTabEnabled )
208 ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); 213 ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) );
214
215 // Re-enable set time buttons & change app caption to indicate time update is happening
216 ntpTab->setNTPBtnEnabled( true );
217 timeTab->setNTPBtnEnabled( true );
218 setCaption( tr( "SystemTime" ) );
209 } 219 }
210} 220}
211 221
212bool MainWindow::ntpDelayElapsed() 222bool MainWindow::ntpDelayElapsed()
213{ 223{
214 // Determine if time elapsed is greater than time delay 224 // Determine if time elapsed is greater than time delay
215 Config config( "ntp" ); 225 Config config( "ntp" );
216 config.setGroup( "lookups" ); 226 config.setGroup( "lookups" );
217 _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); 227 _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 );
218 if ( _lookupDiff < 0 ) 228 if ( _lookupDiff < 0 )
219 return true; 229 return true;
220 return ( _lookupDiff - ( ntpDelay * 60) ) > 0; 230 return ( _lookupDiff - ( ntpDelay * 60) ) > 0;
221} 231}
222 232
223void MainWindow::slotSetTime( const QDateTime &dt ) 233void MainWindow::slotSetTime( const QDateTime &dt )
224{ 234{
225 timeTab->setDateTime( dt ); 235 timeTab->setDateTime( dt );
226} 236}
227 237
228void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & ) 238void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & )
229{ 239{
230 if ( msg == "ntpLookup(QString)" ) 240 if ( msg == "ntpLookup(QString)" )
231 { 241 {
232 ntpInteractive = false; 242 ntpInteractive = false;
233 runNTP(); 243 runNTP();
234 } 244 }
235 if ( msg == "setPredictedTime(QString)" ) 245 if ( msg == "setPredictedTime(QString)" )
236 { 246 {
237 //setPredictTime(); 247 //setPredictTime();
238 } 248 }
239} 249}
240 250
241void MainWindow::slotDisplayNTPTab( bool display ) 251void MainWindow::slotDisplayNTPTab( bool display )
242{ 252{
243 ntpTabEnabled = display; 253 ntpTabEnabled = display;
244 254
245 // Create widget if it hasn't needed 255 // Create widget if it hasn't needed
246 if ( display && !ntpTab ) 256 if ( display && !ntpTab )
247 { 257 {
248 ntpTab = new NTPTabWidget( mainWidget ); 258 ntpTab = new NTPTabWidget( mainWidget );
249 connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); 259 connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
250 } 260 }
251 261
252 // Display/hide tab 262 // Display/hide tab
253 display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) 263 display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) )
254 : mainWidget->removePage( ntpTab ); 264 : mainWidget->removePage( ntpTab );
255} 265}
256 266
257void MainWindow::slotDisplayPredictTab( bool display ) 267void MainWindow::slotDisplayPredictTab( bool display )
258{ 268{
259 predictTabEnabled = display; 269 predictTabEnabled = display;
260 270
261 // Create widget if it hasn't needed 271 // Create widget if it hasn't needed
262 if ( display && !predictTab ) 272 if ( display && !predictTab )
263 { 273 {
264 } 274 }
265 // Display/hide tab 275 // Display/hide tab
266 display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) 276 display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) )
267 : mainWidget->removePage( predictTab ); 277 : mainWidget->removePage( predictTab );
268} 278}
269 279
270void MainWindow::slotGetNTPTime() 280void MainWindow::slotGetNTPTime()
271{ 281{
272 ntpInteractive = TRUE; 282 ntpInteractive = TRUE;
273 runNTP(); 283 runNTP();
274} 284}
275 285
276void MainWindow::slotTimerGetNTPTime() 286void MainWindow::slotTimerGetNTPTime()
277{ 287{
278 ntpInteractive = FALSE; 288 ntpInteractive = FALSE;
279 runNTP(); 289 runNTP();
280} 290}
281 291
282void MainWindow::slotProbeNTPServer() 292void MainWindow::slotProbeNTPServer()
283{ 293{
284 ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); 294 ntpSock->connectToHost( settingsTab->ntpServer(), 123 );
285} 295}
286 296
287void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) 297void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen )
288{ 298{
289 QString output = QString( buffer ).left( buflen ); 299 QString output = QString( buffer ).left( buflen );
290 ntpOutput.append( output ); 300 ntpOutput.append( output );
291 301
292 if ( ntpTabEnabled ) 302 if ( ntpTabEnabled )
293 ntpTab->addNtpOutput( output ); 303 ntpTab->addNtpOutput( output );
294} 304}
295 305
296void MainWindow::slotNtpFinished( OProcess *p ) 306void MainWindow::slotNtpFinished( OProcess *p )
297{ 307{
298 QString output; 308 QString output;
299 QDateTime dt = QDateTime::currentDateTime(); 309 QDateTime dt = QDateTime::currentDateTime();
300 310
311 // Re-enable set time buttons & change app caption to indicate time update is happening
312 ntpTab->setNTPBtnEnabled( true );
313 timeTab->setNTPBtnEnabled( true );
314 setCaption( tr( "SystemTime" ) );
315
301 // Verify run was successful 316 // Verify run was successful
302 if ( p->exitStatus() != 0 || !p->normalExit() ) 317 if ( p->exitStatus() != 0 || !p->normalExit() )
303 { 318 {
304 if ( isVisible() && ntpInteractive ) 319 if ( isVisible() && ntpInteractive )
305 { 320 {
306 output = tr( "Error while getting time from\n server: " ); 321 output = tr( "Error while getting time from\n server: " );
307 output.append( settingsTab->ntpServer() ); 322 output.append( settingsTab->ntpServer() );
308 QMessageBox::critical(this, tr( "Error" ), output ); 323 QMessageBox::critical(this, tr( "Error" ), output );
309 } 324 }
310 // slotCheckNtp(-1); 325 // slotCheckNtp(-1);
311 return; 326 return;
312 } 327 }
313 328
314 // Set controls on time tab to new time value 329 // Set controls on time tab to new time value
315 timeTab->setDateTime( dt ); 330 timeTab->setDateTime( dt );
316 331
317 // Write out lookup information 332 // Write out lookup information
318 Config config( "ntp" ); 333 Config config( "ntp" );
319 config.setGroup( "lookups" ); 334 config.setGroup( "lookups" );
320 int lastLookup = config.readNumEntry( "time", 0 ); 335 int lastLookup = config.readNumEntry( "time", 0 );
321 int lookupCount = config.readNumEntry( "count", 0 ); 336 int lookupCount = config.readNumEntry( "count", 0 );
322 bool lastNtp = config.readBoolEntry( "lastNtp", FALSE ); 337 bool lastNtp = config.readBoolEntry( "lastNtp", FALSE );
323 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 338 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
324 config.writeEntry( "time", time ); 339 config.writeEntry( "time", time );
325 340
326 // Calculate new time/time shift 341 // Calculate new time/time shift
327 QString _offset = "offset"; 342 QString _offset = "offset";
328 QString _sec = "sec"; 343 QString _sec = "sec";
329 QRegExp _reOffset = QRegExp( _offset ); 344 QRegExp _reOffset = QRegExp( _offset );
330 QRegExp _reEndOffset = QRegExp( _sec ); 345 QRegExp _reEndOffset = QRegExp( _sec );
331 int posOffset = _reOffset.match( ntpOutput ); 346 int posOffset = _reOffset.match( ntpOutput );
332 int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); 347 int posEndOffset = _reEndOffset.match( ntpOutput, posOffset );
333 posOffset += _offset.length() + 1; 348 posOffset += _offset.length() + 1;
334 QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); 349 QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 );
335 350
336 float timeShift = diff.toFloat(); 351 float timeShift = diff.toFloat();
337 if ( timeShift == 0.0 ) 352 if ( timeShift == 0.0 )
338 return; 353 return;
339 int secsSinceLast = time - lastLookup; 354 int secsSinceLast = time - lastLookup;
340 output = tr( "%1 seconds").arg(QString::number( timeShift )); 355 output = tr( "%1 seconds").arg(QString::number( timeShift ));
341 356
342 // Display information on time server tab 357 // Display information on time server tab
343 if ( ntpTabEnabled ) 358 if ( ntpTabEnabled )
344 { 359 {
345 ntpTab->setTimeShift( output ); 360 ntpTab->setTimeShift( output );
346 ntpTab->setNewTime( dt.toString() ); 361 ntpTab->setNewTime( dt.toString() );
347 } 362 }
348 363
349 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) 364 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay )
350 { 365 {
351 QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); 366 QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) );
352 config.setGroup( grpname ); 367 config.setGroup( grpname );
353 lookupCount++; 368 lookupCount++;
354 predictTab->setShiftPerSec( timeShift / secsSinceLast ); 369 predictTab->setShiftPerSec( (int)(timeShift / secsSinceLast) );
355 config.writeEntry( "secsSinceLast", secsSinceLast ); 370 config.writeEntry( "secsSinceLast", secsSinceLast );
356 config.writeEntry( "timeShift", QString::number( timeShift ) ); 371 config.writeEntry( "timeShift", QString::number( timeShift ) );
357 config.setGroup( "lookups" ); 372 config.setGroup( "lookups" );
358 config.writeEntry( "count", lookupCount ); 373 config.writeEntry( "count", lookupCount );
359 config.writeEntry( "lastNtp", TRUE ); 374 config.writeEntry( "lastNtp", TRUE );
360 } 375 }
361} 376}
362 377
363void MainWindow::slotNTPDelayChanged( int delay ) 378void MainWindow::slotNTPDelayChanged( int delay )
364{ 379{
365 ntpTimer->changeInterval( delay * 1000 * 60 ); 380 ntpTimer->changeInterval( delay * 1000 * 60 );
366 ntpDelay = delay; 381 ntpDelay = delay;
367} 382}
368 383
369void MainWindow::slotCheckNtp( int i ) 384void MainWindow::slotCheckNtp( int i )
370{ 385{
371 if ( i == 0 ) 386 if ( i == 0 )
372 { 387 {
373 if ( ntpDelayElapsed() ) 388 if ( ntpDelayElapsed() )
374 { 389 {
375 runNTP(); 390 runNTP();
376 disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) ); 391 disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) );
377 connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) ); 392 connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) );
378 } 393 }
379 else 394 else
380 { 395 {
381 disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) ); 396 disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) );
382 connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); 397 connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) );
383 } 398 }
384 } 399 }
385 else 400 else
386 { 401 {
387 predictTab->slotPredictTime(); 402 predictTab->slotPredictTime();
388 if ( i > 0 ) 403 if ( i > 0 )
389 { 404 {
390 QString output = tr( "Could not connect to server " ); 405 QString output = tr( "Could not connect to server " );
391 output.append( settingsTab->ntpServer() ); 406 output.append( settingsTab->ntpServer() );
392 ntpOutput.append( output ); 407 ntpOutput.append( output );
393 if ( ntpTabEnabled ) 408 if ( ntpTabEnabled )
394 ntpTab->addNtpOutput( output ); 409 ntpTab->addNtpOutput( output );
395 } 410 }
396 connect( ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); 411 connect( ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) );
397 } 412 }
398} 413}
diff --git a/noncore/settings/netsystemtime/ntptabwidget.cpp b/noncore/settings/netsystemtime/ntptabwidget.cpp
index d71c230..616bc22 100644
--- a/noncore/settings/netsystemtime/ntptabwidget.cpp
+++ b/noncore/settings/netsystemtime/ntptabwidget.cpp
@@ -1,107 +1,112 @@
1/* 1/*
2                This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> 4 .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?>
5           .>+-= 5 .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6_;:, .> :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.-- : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12    .%`+i>       _;_. 12 .%`+i> _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13 .i_,=:_. -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.= = ; Public License for more details.
19++=   -.     .`     .: 19++= -. .` .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20: = ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21-. .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22 -_. . . )=. = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23 -- :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "ntptabwidget.h" 29#include "ntptabwidget.h"
30 30
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32 32
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qmultilineedit.h> 35#include <qmultilineedit.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37#include <qscrollview.h> 37#include <qscrollview.h>
38 38
39NTPTabWidget::NTPTabWidget( QWidget *parent ) 39NTPTabWidget::NTPTabWidget( QWidget *parent )
40 : QWidget( parent, 0x0, 0 ) 40 : QWidget( parent, 0x0, 0 )
41{ 41{
42 QVBoxLayout *tmpvb = new QVBoxLayout( this ); 42 QVBoxLayout *tmpvb = new QVBoxLayout( this );
43 QScrollView *sv = new QScrollView( this ); 43 QScrollView *sv = new QScrollView( this );
44 tmpvb->addWidget( sv, 0, 0 ); 44 tmpvb->addWidget( sv, 0, 0 );
45 sv->setResizePolicy( QScrollView::AutoOneFit ); 45 sv->setResizePolicy( QScrollView::AutoOneFit );
46 sv->setFrameStyle( QFrame::NoFrame ); 46 sv->setFrameStyle( QFrame::NoFrame );
47 QWidget *container = new QWidget( sv->viewport() ); 47 QWidget *container = new QWidget( sv->viewport() );
48 sv->addChild( container ); 48 sv->addChild( container );
49 49
50 QGridLayout *layout = new QGridLayout( container ); 50 QGridLayout *layout = new QGridLayout( container );
51 layout->setMargin( 2 ); 51 layout->setMargin( 2 );
52 layout->setSpacing( 4 ); 52 layout->setSpacing( 4 );
53 53
54 // Start time 54 // Start time
55 layout->addWidget( new QLabel( tr( "Start time" ), container ), 0, 0 ); 55 layout->addWidget( new QLabel( tr( "Start time" ), container ), 0, 0 );
56 lblStartTime = new QLabel( tr( "n/a" ), container ); 56 lblStartTime = new QLabel( tr( "n/a" ), container );
57 layout->addWidget( lblStartTime, 0, 1 ); 57 layout->addWidget( lblStartTime, 0, 1 );
58 58
59 // Time shift 59 // Time shift
60 layout->addWidget( new QLabel( tr( "Time shift" ), container ), 1, 0 ); 60 layout->addWidget( new QLabel( tr( "Time shift" ), container ), 1, 0 );
61 lblTimeShift = new QLabel( tr( "n/a" ), container ); 61 lblTimeShift = new QLabel( tr( "n/a" ), container );
62 layout->addWidget( lblTimeShift, 1, 1 ); 62 layout->addWidget( lblTimeShift, 1, 1 );
63 63
64 // New time 64 // New time
65 layout->addWidget( new QLabel( tr( "New time" ), container ), 2, 0 ); 65 layout->addWidget( new QLabel( tr( "New time" ), container ), 2, 0 );
66 lblNewTime = new QLabel( tr( "n/a" ), container ); 66 lblNewTime = new QLabel( tr( "n/a" ), container );
67 layout->addWidget( lblNewTime, 2, 1 ); 67 layout->addWidget( lblNewTime, 2, 1 );
68 68
69 // NTP output display 69 // NTP output display
70 mleNtpOutput = new QMultiLineEdit( container ); 70 mleNtpOutput = new QMultiLineEdit( container );
71 QFont font( mleNtpOutput->font() ); 71 QFont font( mleNtpOutput->font() );
72 font.setPointSize( 7 ); 72 font.setPointSize( 7 );
73 mleNtpOutput->setFont( font ); 73 mleNtpOutput->setFont( font );
74 mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth ); 74 mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth );
75 layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 ); 75 layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 );
76 76
77 // Set NTP time button 77 // Set NTP time button
78 QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), 78 m_ntpBtn = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ),
79 tr( "Get time from the network" ), container ); 79 tr( "Get time from the network" ), container );
80 connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); 80 connect( m_ntpBtn, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) );
81 layout->addMultiCellWidget( pb, 4, 4, 0, 1 ); 81 layout->addMultiCellWidget( m_ntpBtn, 4, 4, 0, 1 );
82} 82}
83 83
84NTPTabWidget::~NTPTabWidget() 84NTPTabWidget::~NTPTabWidget()
85{ 85{
86} 86}
87 87
88void NTPTabWidget::setStartTime( const QString &str ) 88void NTPTabWidget::setStartTime( const QString &str )
89{ 89{
90 lblStartTime->setText( str ); 90 lblStartTime->setText( str );
91} 91}
92 92
93void NTPTabWidget::setTimeShift( const QString &str ) 93void NTPTabWidget::setTimeShift( const QString &str )
94{ 94{
95 lblTimeShift->setText( str ); 95 lblTimeShift->setText( str );
96} 96}
97 97
98void NTPTabWidget::setNewTime( const QString &str ) 98void NTPTabWidget::setNewTime( const QString &str )
99{ 99{
100 lblNewTime->setText( str ); 100 lblNewTime->setText( str );
101} 101}
102 102
103void NTPTabWidget::addNtpOutput( const QString &str ) 103void NTPTabWidget::addNtpOutput( const QString &str )
104{ 104{
105 mleNtpOutput->append( str ); 105 mleNtpOutput->append( str );
106 mleNtpOutput->setCursorPosition( mleNtpOutput->numLines() + 1, 0, FALSE ); 106 mleNtpOutput->setCursorPosition( mleNtpOutput->numLines() + 1, 0, FALSE );
107} 107}
108
109void NTPTabWidget::setNTPBtnEnabled( bool enabled )
110{
111 m_ntpBtn->setEnabled( enabled );
112}
diff --git a/noncore/settings/netsystemtime/ntptabwidget.h b/noncore/settings/netsystemtime/ntptabwidget.h
index 811c57e..f05482e 100644
--- a/noncore/settings/netsystemtime/ntptabwidget.h
+++ b/noncore/settings/netsystemtime/ntptabwidget.h
@@ -1,60 +1,64 @@
1/* 1/*
2                This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> 4 .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?>
5           .>+-= 5 .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6_;:, .> :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.-- : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12    .%`+i>       _;_. 12 .%`+i> _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13 .i_,=:_. -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.= = ; Public License for more details.
19++=   -.     .`     .: 19++= -. .` .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20: = ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21-. .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22 -_. . . )=. = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23 -- :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef NTPTABWIDGET_H 29#ifndef NTPTABWIDGET_H
30#define NTPTABWIDGET_H 30#define NTPTABWIDGET_H
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34class QLabel; 34class QLabel;
35class QMultiLineEdit; 35class QMultiLineEdit;
36class QPushButton;
36 37
37class NTPTabWidget : public QWidget 38class NTPTabWidget : public QWidget
38{ 39{
39 Q_OBJECT 40 Q_OBJECT
40 41
41public: 42public:
42 NTPTabWidget( QWidget * = 0x0 ); 43 NTPTabWidget( QWidget * = 0x0 );
43 ~NTPTabWidget(); 44 ~NTPTabWidget();
44 45
45 void setStartTime( const QString & ); 46 void setStartTime( const QString & );
46 void setTimeShift( const QString & ); 47 void setTimeShift( const QString & );
47 void setNewTime( const QString & ); 48 void setNewTime( const QString & );
48 void addNtpOutput( const QString & ); 49 void addNtpOutput( const QString & );
50 void setNTPBtnEnabled( bool enabled );
49 51
50private: 52private:
51 QLabel *lblStartTime; 53 QLabel *lblStartTime;
52 QLabel *lblTimeShift; 54 QLabel *lblTimeShift;
53 QLabel *lblNewTime; 55 QLabel *lblNewTime;
54 QMultiLineEdit *mleNtpOutput; 56 QMultiLineEdit *mleNtpOutput;
57 QPushButton *m_ntpBtn;
58
55 59
56signals: 60signals:
57 void getNTPTime(); 61 void getNTPTime();
58}; 62};
59 63
60#endif 64#endif
diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp
index 3cc127d..905461f 100644
--- a/noncore/settings/netsystemtime/timetabwidget.cpp
+++ b/noncore/settings/netsystemtime/timetabwidget.cpp
@@ -1,298 +1,303 @@
1/* 1/*
2                This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> 4 .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?>
5           .>+-= 5 .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6_;:, .> :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.-- : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12    .%`+i>       _;_. 12 .%`+i> _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13 .i_,=:_. -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.= = ; Public License for more details.
19++=   -.     .`     .: 19++= -. .` .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20: = ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21-. .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22 -_. . . )=. = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23 -- :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "timetabwidget.h" 29#include "timetabwidget.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/datebookmonth.h> 32#include <qpe/datebookmonth.h>
33#include <qpe/global.h> 33#include <qpe/global.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/tzselect.h> 35#include <qpe/tzselect.h>
36 36
37#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 37#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39#endif 39#endif
40 40
41#include <qcombobox.h> 41#include <qcombobox.h>
42#include <qdatetime.h> 42#include <qdatetime.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlabel.h> 44#include <qlabel.h>
45#include <qlayout.h> 45#include <qlayout.h>
46#include <qpushbutton.h> 46#include <qpushbutton.h>
47#include <qscrollview.h> 47#include <qscrollview.h>
48#include <qspinbox.h> 48#include <qspinbox.h>
49 49
50#include <stdlib.h> 50#include <stdlib.h>
51#include <sys/time.h> 51#include <sys/time.h>
52 52
53static const int ValueAM = 0; 53static const int ValueAM = 0;
54static const int ValuePM = 1; 54static const int ValuePM = 1;
55 55
56TimeTabWidget::TimeTabWidget( QWidget *parent ) 56TimeTabWidget::TimeTabWidget( QWidget *parent )
57 : QWidget( parent, 0x0, 0 ) 57 : QWidget( parent, 0x0, 0 )
58{ 58{
59 // Synchronize HW clock to systemtime 59 // Synchronize HW clock to systemtime
60 // This app will update systemtime 60 // This app will update systemtime
61 // - if Cancel is clicked, will reset systemtime to HW clock's time 61 // - if Cancel is clicked, will reset systemtime to HW clock's time
62 // - if Ok is clicked, will leave systemtime as is 62 // - if Ok is clicked, will leave systemtime as is
63 system("/sbin/hwclock --systohc --utc"); 63 system("/sbin/hwclock --systohc --utc");
64 64
65 QVBoxLayout *tmpvb = new QVBoxLayout( this ); 65 QVBoxLayout *tmpvb = new QVBoxLayout( this );
66 QScrollView *sv = new QScrollView( this ); 66 QScrollView *sv = new QScrollView( this );
67 tmpvb->addWidget( sv, 0, 0 ); 67 tmpvb->addWidget( sv, 0, 0 );
68 sv->setResizePolicy( QScrollView::AutoOneFit ); 68 sv->setResizePolicy( QScrollView::AutoOneFit );
69 sv->setFrameStyle( QFrame::NoFrame ); 69 sv->setFrameStyle( QFrame::NoFrame );
70 QWidget *container = new QWidget( sv->viewport() ); 70 QWidget *container = new QWidget( sv->viewport() );
71 sv->addChild( container ); 71 sv->addChild( container );
72 72
73 QGridLayout *layout = new QGridLayout( container ); 73 QGridLayout *layout = new QGridLayout( container );
74 layout->setMargin( 2 ); 74 layout->setMargin( 2 );
75 layout->setSpacing( 4 ); 75 layout->setSpacing( 4 );
76 76
77 // Hours 77 // Hours
78 layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 ); 78 layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 );
79 sbHour = new QSpinBox( container ); 79 sbHour = new QSpinBox( container );
80 sbHour->setWrapping( TRUE ); 80 sbHour->setWrapping( TRUE );
81 layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 ); 81 layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 );
82 82
83 // Minutes 83 // Minutes
84 layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 ); 84 layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 );
85 sbMin = new QSpinBox( container ); 85 sbMin = new QSpinBox( container );
86 sbMin->setWrapping( TRUE ); 86 sbMin->setWrapping( TRUE );
87 sbMin->setMinValue( 0 ); 87 sbMin->setMinValue( 0 );
88 sbMin->setMaxValue( 59 ); 88 sbMin->setMaxValue( 59 );
89 layout->addMultiCellWidget( sbMin, 2, 2, 2, 3 ); 89 layout->addMultiCellWidget( sbMin, 2, 2, 2, 3 );
90 90
91 // AM/PM 91 // AM/PM
92 cbAmpm = new QComboBox( container ); 92 cbAmpm = new QComboBox( container );
93 cbAmpm->insertItem( tr( "AM" ), ValueAM ); 93 cbAmpm->insertItem( tr( "AM" ), ValueAM );
94 cbAmpm->insertItem( tr( "PM" ), ValuePM ); 94 cbAmpm->insertItem( tr( "PM" ), ValuePM );
95 layout->addMultiCellWidget( cbAmpm, 2, 2, 4, 5 ); 95 layout->addMultiCellWidget( cbAmpm, 2, 2, 4, 5 );
96 96
97 // Date 97 // Date
98 layout->addWidget( new QLabel( tr( "Date" ), container ), 4, 0 ); 98 layout->addWidget( new QLabel( tr( "Date" ), container ), 4, 0 );
99 btnDate = new DateButton( TRUE, container ); 99 btnDate = new DateButton( TRUE, container );
100 layout->addMultiCellWidget( btnDate, 4, 4, 1, 5 ); 100 layout->addMultiCellWidget( btnDate, 4, 4, 1, 5 );
101 101
102 // Timezone 102 // Timezone
103 layout->addMultiCellWidget( new QLabel( tr( "Time zone" ), container ), 6, 6, 0, 1 ); 103 layout->addMultiCellWidget( new QLabel( tr( "Time zone" ), container ), 6, 6, 0, 1 );
104 selTimeZone = new TimeZoneSelector( container ); 104 selTimeZone = new TimeZoneSelector( container );
105 connect( selTimeZone, SIGNAL(signalNewTz(const QString&)), this, SLOT(slotTZChanged(const QString&)) ); 105 connect( selTimeZone, SIGNAL(signalNewTz(const QString&)), this, SLOT(slotTZChanged(const QString&)) );
106 layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 ); 106 layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 );
107 107
108 // Space filler 108 // Space filler
109 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); 109 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 );
110 110
111 // Set NTP time button 111 // Set NTP time button
112 QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), 112 m_ntpBtn = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ),
113 tr( "Get time from the network" ), container ); 113 tr( "Get time from the network" ), container );
114 connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); 114 connect( m_ntpBtn, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) );
115 layout->addMultiCellWidget( pb, 8, 8, 0, 5 ); 115 layout->addMultiCellWidget( m_ntpBtn, 8, 8, 0, 5 );
116 116
117 // Set predicted time button 117 // Set predicted time button
118 pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ), 118 QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ),
119 container ); 119 container );
120 connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) ); 120 connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) );
121 layout->addMultiCellWidget( pb, 9, 9, 0, 5 ); 121 layout->addMultiCellWidget( pb, 9, 9, 0, 5 );
122 122
123 // Space filler at bottom of widget 123 // Space filler at bottom of widget
124 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 ); 124 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 );
125 125
126 // Initialize values 126 // Initialize values
127 Config config( "locale" ); 127 Config config( "locale" );
128 config.setGroup( "Location" ); 128 config.setGroup( "Location" );
129 selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) ); 129 selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) );
130 use12HourTime = FALSE; 130 use12HourTime = FALSE;
131 setDateTime( QDateTime::currentDateTime() ); 131 setDateTime( QDateTime::currentDateTime() );
132} 132}
133 133
134TimeTabWidget::~TimeTabWidget() 134TimeTabWidget::~TimeTabWidget()
135{ 135{
136} 136}
137 137
138void TimeTabWidget::saveSettings( bool commit ) 138void TimeTabWidget::saveSettings( bool commit )
139{ 139{
140 if ( commit ) 140 if ( commit )
141 { 141 {
142 // Set timezone and announce to world 142 // Set timezone and announce to world
143 QString tz = selTimeZone->currentZone(); 143 QString tz = selTimeZone->currentZone();
144 Config config("locale"); 144 Config config("locale");
145 config.setGroup( "Location" ); 145 config.setGroup( "Location" );
146 config.writeEntry( "Timezone", tz ); 146 config.writeEntry( "Timezone", tz );
147 setenv( "TZ", tz, 1 ); 147 setenv( "TZ", tz, 1 );
148 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); 148 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
149 setTimeZone << tz; 149 setTimeZone << tz;
150 150
151 // If controls have a valid date & time, update systemtime 151 // If controls have a valid date & time, update systemtime
152 int hour = sbHour->value(); 152 int hour = sbHour->value();
153 if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) 153 if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
154 hour += 12; 154 hour += 12;
155 QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); 155 QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) );
156 setSystemTime( dt ); 156 setSystemTime( dt );
157 } 157 }
158 else 158 else
159 { 159 {
160 // Reset systemtime to hardware clock (i.e. undo any changes made by this app) 160 // Reset systemtime to hardware clock (i.e. undo any changes made by this app)
161 system("/sbin/hwclock --hctosys --utc"); 161 system("/sbin/hwclock --hctosys --utc");
162 } 162 }
163} 163}
164 164
165void TimeTabWidget::setDateTime( const QDateTime &dt ) 165void TimeTabWidget::setDateTime( const QDateTime &dt )
166{ 166{
167 // Set time 167 // Set time
168 QTime t = dt.time(); 168 QTime t = dt.time();
169 if( use12HourTime ) 169 if( use12HourTime )
170 { 170 {
171 int show_hour = t.hour(); 171 int show_hour = t.hour();
172 if ( t.hour() >= 12 ) 172 if ( t.hour() >= 12 )
173 { 173 {
174 show_hour -= 12; 174 show_hour -= 12;
175 cbAmpm->setCurrentItem( ValuePM ); 175 cbAmpm->setCurrentItem( ValuePM );
176 } 176 }
177 else 177 else
178 { 178 {
179 cbAmpm->setCurrentItem( ValueAM ); 179 cbAmpm->setCurrentItem( ValueAM );
180 } 180 }
181 if ( show_hour == 0 ) 181 if ( show_hour == 0 )
182 show_hour = 12; 182 show_hour = 12;
183 sbHour->setValue( show_hour ); 183 sbHour->setValue( show_hour );
184 } 184 }
185 else 185 else
186 { 186 {
187 sbHour->setValue( t.hour() ); 187 sbHour->setValue( t.hour() );
188 } 188 }
189 sbMin->setValue( t.minute() ); 189 sbMin->setValue( t.minute() );
190 190
191 // Set date 191 // Set date
192 btnDate->setDate( dt.date() ); 192 btnDate->setDate( dt.date() );
193} 193}
194 194
195void TimeTabWidget::setNTPBtnEnabled( bool enabled )
196{
197 m_ntpBtn->setEnabled( enabled );
198}
199
195void TimeTabWidget::setSystemTime( const QDateTime &dt ) 200void TimeTabWidget::setSystemTime( const QDateTime &dt )
196{ 201{
197 // Set system clock 202 // Set system clock
198 if ( dt.isValid() ) 203 if ( dt.isValid() )
199 { 204 {
200 struct timeval myTv; 205 struct timeval myTv;
201 int t = TimeConversion::toUTC( dt ); 206 int t = TimeConversion::toUTC( dt );
202 myTv.tv_sec = t; 207 myTv.tv_sec = t;
203 myTv.tv_usec = 0; 208 myTv.tv_usec = 0;
204 209
205 if ( myTv.tv_sec != -1 ) 210 if ( myTv.tv_sec != -1 )
206 ::settimeofday( &myTv, 0 ); 211 ::settimeofday( &myTv, 0 );
207 212
208 /* 213 /*
209 * Commit the datetime to the 'hardware' 214 * Commit the datetime to the 'hardware'
210 * as Global::writeHWClock() is a NOOP with Opie Alarm 215 * as Global::writeHWClock() is a NOOP with Opie Alarm
211 */ 216 */
212 system("/sbin/hwclock --systohc --utc"); 217 system("/sbin/hwclock --systohc --utc");
213 } 218 }
214} 219}
215 220
216void TimeTabWidget::slotUse12HourTime( int i ) 221void TimeTabWidget::slotUse12HourTime( int i )
217{ 222{
218 use12HourTime = (i == 1); 223 use12HourTime = (i == 1);
219 224
220 cbAmpm->setEnabled( use12HourTime ); 225 cbAmpm->setEnabled( use12HourTime );
221 226
222 int show_hour = sbHour->value(); 227 int show_hour = sbHour->value();
223 228
224 if ( use12HourTime ) 229 if ( use12HourTime )
225 { 230 {
226 sbHour->setMinValue( 1 ); 231 sbHour->setMinValue( 1 );
227 sbHour->setMaxValue( 12 ); 232 sbHour->setMaxValue( 12 );
228 233
229 if ( show_hour >= 12 ) 234 if ( show_hour >= 12 )
230 { 235 {
231 show_hour -= 12; 236 show_hour -= 12;
232 cbAmpm->setCurrentItem( ValuePM ); 237 cbAmpm->setCurrentItem( ValuePM );
233 } 238 }
234 else 239 else
235 { 240 {
236 cbAmpm->setCurrentItem( ValueAM ); 241 cbAmpm->setCurrentItem( ValueAM );
237 } 242 }
238 if ( show_hour == 0 ) 243 if ( show_hour == 0 )
239 show_hour = 12; 244 show_hour = 12;
240 } 245 }
241 else 246 else
242 { 247 {
243 sbHour->setMinValue( 0 ); 248 sbHour->setMinValue( 0 );
244 sbHour->setMaxValue( 23 ); 249 sbHour->setMaxValue( 23 );
245 250
246 if ( cbAmpm->currentItem() == ValuePM ) 251 if ( cbAmpm->currentItem() == ValuePM )
247 { 252 {
248 show_hour += 12; 253 show_hour += 12;
249 if ( show_hour == 24 ) 254 if ( show_hour == 24 )
250 show_hour = 0; 255 show_hour = 0;
251 } 256 }
252 } 257 }
253 258
254 sbHour->setValue( show_hour ); 259 sbHour->setValue( show_hour );
255} 260}
256 261
257void TimeTabWidget::slotDateFormatChanged( const DateFormat &df ) 262void TimeTabWidget::slotDateFormatChanged( const DateFormat &df )
258{ 263{
259 btnDate->setDateFormat( df ); 264 btnDate->setDateFormat( df );
260} 265}
261 266
262void TimeTabWidget::slotWeekStartChanged( int monday ) 267void TimeTabWidget::slotWeekStartChanged( int monday )
263{ 268{
264 btnDate->setWeekStartsMonday( monday ); 269 btnDate->setWeekStartsMonday( monday );
265} 270}
266 271
267void TimeTabWidget::slotTZChanged( const QString &newtz ) 272void TimeTabWidget::slotTZChanged( const QString &newtz )
268{ 273{
269 // If controls have a valid date & time, update systemtime 274 // If controls have a valid date & time, update systemtime
270 int hour = sbHour->value(); 275 int hour = sbHour->value();
271 if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) 276 if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
272 hour += 12; 277 hour += 12;
273 QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); 278 QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) );
274 setSystemTime( dt ); 279 setSystemTime( dt );
275 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); 280 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
276 setTimeZone << newtz; 281 setTimeZone << newtz;
277 282
278 // Set system timezone 283 // Set system timezone
279 QString currtz = getenv( "TZ" ); 284 QString currtz = getenv( "TZ" );
280 setenv( "TZ", newtz, 1 ); 285 setenv( "TZ", newtz, 1 );
281 286
282 // Get new date/time 287 // Get new date/time
283 hour = sbHour->value(); 288 hour = sbHour->value();
284 if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) 289 if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
285 hour += 12; 290 hour += 12;
286 dt = QDateTime::currentDateTime(); 291 dt = QDateTime::currentDateTime();
287 292
288 // Reset system timezone 293 // Reset system timezone
289 if ( !currtz.isNull() ) 294 if ( !currtz.isNull() )
290 { 295 {
291 setenv( "TZ", currtz, 1 ); 296 setenv( "TZ", currtz, 1 );
292 } 297 }
293 298
294 // Set controls to new time 299 // Set controls to new time
295 setDateTime( dt ); 300 setDateTime( dt );
296 301
297 emit tzChanged( newtz ); 302 emit tzChanged( newtz );
298} 303}
diff --git a/noncore/settings/netsystemtime/timetabwidget.h b/noncore/settings/netsystemtime/timetabwidget.h
index f44a1da..949535d 100644
--- a/noncore/settings/netsystemtime/timetabwidget.h
+++ b/noncore/settings/netsystemtime/timetabwidget.h
@@ -1,77 +1,80 @@
1/* 1/*
2                This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> 4 .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?>
5           .>+-= 5 .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6_;:, .> :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.-- : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12    .%`+i>       _;_. 12 .%`+i> _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13 .i_,=:_. -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.= = ; Public License for more details.
19++=   -.     .`     .: 19++= -. .` .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20: = ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21-. .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22 -_. . . )=. = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23 -- :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef TIMETABWIDGET_H 29#ifndef TIMETABWIDGET_H
30#define TIMETABWIDGET_H 30#define TIMETABWIDGET_H
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34class DateButton; 34class DateButton;
35class DateFormat; 35class DateFormat;
36class QComboBox; 36class QComboBox;
37class QDateTime; 37class QDateTime;
38class QPushButton;
38class QSpinBox; 39class QSpinBox;
39class TimeZoneSelector; 40class TimeZoneSelector;
40 41
41class TimeTabWidget : public QWidget 42class TimeTabWidget : public QWidget
42{ 43{
43 Q_OBJECT 44 Q_OBJECT
44 45
45public: 46public:
46 TimeTabWidget( QWidget * = 0x0 ); 47 TimeTabWidget( QWidget * = 0l );
47 ~TimeTabWidget(); 48 ~TimeTabWidget();
48 49
49 void saveSettings( bool ); 50 void saveSettings( bool );
50 void setDateTime( const QDateTime & ); 51 void setDateTime( const QDateTime & );
52 void setNTPBtnEnabled( bool enabled );
51 53
52private: 54private:
53 QSpinBox *sbHour; 55 QSpinBox *sbHour;
54 QSpinBox *sbMin; 56 QSpinBox *sbMin;
55 QComboBox *cbAmpm; 57 QComboBox *cbAmpm;
56 DateButton *btnDate; 58 DateButton *btnDate;
57 TimeZoneSelector *selTimeZone; 59 TimeZoneSelector *selTimeZone;
60 QPushButton *m_ntpBtn;
58 61
59 bool use12HourTime; 62 bool use12HourTime;
60 63
61 void setSystemTime( const QDateTime & ); 64 void setSystemTime( const QDateTime & );
62 65
63signals: 66signals:
64 void tzChanged( const QString & ); 67 void tzChanged( const QString & );
65 void getNTPTime(); 68 void getNTPTime();
66 void getPredictedTime(); 69 void getPredictedTime();
67 70
68public slots: 71public slots:
69 void slotUse12HourTime( int ); 72 void slotUse12HourTime( int );
70 void slotDateFormatChanged( const DateFormat & ); 73 void slotDateFormatChanged( const DateFormat & );
71 void slotWeekStartChanged( int ); 74 void slotWeekStartChanged( int );
72 75
73private slots: 76private slots:
74 void slotTZChanged( const QString & ); 77 void slotTZChanged( const QString & );
75}; 78};
76 79
77#endif 80#endif