summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/settings/netsystemtime/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp
index c995d6e..ba96f33 100644
--- a/noncore/settings/netsystemtime/mainwindow.cpp
+++ b/noncore/settings/netsystemtime/mainwindow.cpp
@@ -27,48 +27,50 @@
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;
52using namespace Opie::Core;
51MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) 53MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f )
52 : QDialog( 0x0, 0x0, TRUE, 0 ) 54 : QDialog( 0x0, 0x0, TRUE, 0 )
53{ 55{
54 setCaption( tr( "SystemTime" ) ); 56 setCaption( tr( "SystemTime" ) );
55 57
56 QVBoxLayout *layout = new QVBoxLayout( this ); 58 QVBoxLayout *layout = new QVBoxLayout( this );
57 layout->setMargin( 2 ); 59 layout->setMargin( 2 );
58 layout->setSpacing( 4 ); 60 layout->setSpacing( 4 );
59 61
60 // Create main tabbed control 62 // Create main tabbed control
61 mainWidget = new OTabWidget( this ); 63 mainWidget = new OTabWidget( this );
62 64
63 // Default object pointers to null 65 // Default object pointers to null
64 ntpProcess = 0x0; 66 ntpProcess = 0x0;
65 ntpTab = 0x0; 67 ntpTab = 0x0;
66 68
67 // Add tab widgets 69 // Add tab widgets
68 mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); 70 mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) );
69 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); 71 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) );
70 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); 72 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) );
71 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); 73 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) );
72 Config config( "ntp" ); 74 Config config( "ntp" );
73 config.setGroup( "settings" ); 75 config.setGroup( "settings" );
74 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); 76 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) );
@@ -167,51 +169,51 @@ void MainWindow::runNTP()
167 switch ( 169 switch (
168 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) 170 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No )
169 ) 171 )
170 { 172 {
171 case QMessageBox::Yes: break; 173 case QMessageBox::Yes: break;
172 case QMessageBox::No: return; 174 case QMessageBox::No: return;
173 default: return; 175 default: return;
174 } 176 }
175 } 177 }
176 178
177 QString srv = settingsTab->ntpServer(); 179 QString srv = settingsTab->ntpServer();
178 180
179 // Send information to time server tab if enabled 181 // Send information to time server tab if enabled
180 if ( ntpTabEnabled ) 182 if ( ntpTabEnabled )
181 { 183 {
182 ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); 184 ntpTab->setStartTime( QDateTime::currentDateTime().toString() );
183 QString output = tr( "Running:\nntpdate " ); 185 QString output = tr( "Running:\nntpdate " );
184 output.append( srv ); 186 output.append( srv );
185 ntpTab->addNtpOutput( output ); 187 ntpTab->addNtpOutput( output );
186 } 188 }
187 189
188 if ( !ntpProcess ) 190 if ( !ntpProcess )
189 { 191 {
190 ntpProcess = new OProcess(); 192 ntpProcess = new OProcess();
191 connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 193 connect( ntpProcess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
192 this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); 194 this, SLOT(slotNtpOutput(OProcess*,char*,int)) );
193 connect( ntpProcess, SIGNAL(processExited(OProcess*)), 195 connect( ntpProcess, SIGNAL(processExited(Opie::Core::OProcess*)),
194 this, SLOT(slotNtpFinished(OProcess*)) ); 196 this, SLOT(slotNtpFinished(OProcess*)) );
195 } 197 }
196 198
197 else 199 else
198 ntpProcess->clearArguments(); 200 ntpProcess->clearArguments();
199 201
200 *ntpProcess << "ntpdate" << srv; 202 *ntpProcess << "ntpdate" << srv;
201 bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); 203 bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput );
202 if ( !ret ) 204 if ( !ret )
203 { 205 {
204 QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); 206 QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) );
205 if ( ntpTabEnabled ) 207 if ( ntpTabEnabled )
206 ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); 208 ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) );
207 } 209 }
208} 210}
209 211
210bool MainWindow::ntpDelayElapsed() 212bool MainWindow::ntpDelayElapsed()
211{ 213{
212 // Determine if time elapsed is greater than time delay 214 // Determine if time elapsed is greater than time delay
213 Config config( "ntp" ); 215 Config config( "ntp" );
214 config.setGroup( "lookups" ); 216 config.setGroup( "lookups" );
215 _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); 217 _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 );
216 if ( _lookupDiff < 0 ) 218 if ( _lookupDiff < 0 )
217 return true; 219 return true;