summaryrefslogtreecommitdiff
authortille <tille>2002-06-27 10:04:37 (UTC)
committer tille <tille>2002-06-27 10:04:37 (UTC)
commit7c3fe018ad8855011c6e0441ed1bef2c09e293f2 (patch) (side-by-side diff)
tree299a1e9ffee7ca35f698165d07e02cb415f0010e
parent596749dc52cc89b5325f9089b79d0b9cc8240682 (diff)
downloadopie-7c3fe018ad8855011c6e0441ed1bef2c09e293f2.zip
opie-7c3fe018ad8855011c6e0441ed1bef2c09e293f2.tar.gz
opie-7c3fe018ad8855011c6e0441ed1bef2c09e293f2.tar.bz2
imp. table
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp28
-rw-r--r--noncore/settings/netsystemtime/ntp.h3
-rw-r--r--noncore/settings/netsystemtime/ntpbase.ui8
3 files changed, 18 insertions, 21 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 6a5c062..0abb401 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -41,10 +41,8 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) );
ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
ntpTimer = new QTimer(this);
- processTimer = new QTimer(this);
- ntpTimer->start(SpinBoxNtpDelay->value()*1000*60);
ntpProcess = new OProcess( );
connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
SLOT(slotNtpDelayChanged(int)) );
@@ -114,10 +112,8 @@ void Ntp::slotRunNtp()
}
}
TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
- connect( processTimer, SIGNAL( timeout() ), SLOT(slotTimeoutNtpProcess()) );
- processTimer->start(2*1000*60, true);
ntpProcess->clearArguments();
*ntpProcess << "ntpdate" << getNtpServer();
bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
@@ -141,18 +137,18 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
}
void Ntp::ntpFinished(OProcess *p)
{
- if (!p->normalExit())
+ qDebug("p->exitStatus() %i",p->exitStatus());
+ if (p->exitStatus()!=0 || !p->normalExit())
{
slotProbeNtpServer();
return;
}
- processTimer->stop();
Config cfg("ntp",Config::User);
cfg.setGroup("lookups");
int lastLookup = cfg.readNumEntry("time",0);
- int lookupCount = cfg.readNumEntry("count",-1);
+ int lookupCount = cfg.readNumEntry("count",0);
int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
cfg.writeEntry("time", time);
cfg.setGroup("correction");
cfg.writeEntry("time", time);
@@ -193,16 +189,16 @@ float Ntp::getTimeShift()
void Ntp::readLookups()
{
Config cfg("ntp",Config::User);
cfg.setGroup("lookups");
- int lookupCount = cfg.readNumEntry("count",-1);
+ int lookupCount = cfg.readNumEntry("count",0);
float last, shift, shiftPerSec;
qDebug("lookupCount = %i",lookupCount);
TableLookups->setNumCols( 3 );
TableLookups->setNumRows( lookupCount);
- TableLookups->horizontalHeader()->setLabel(1,"secsSinceLast");
- TableLookups->horizontalHeader()->setLabel(2,"timeShift");
- TableLookups->horizontalHeader()->setLabel(0,"shift/s");
+ TableLookups->horizontalHeader()->setLabel(1,tr("last [h]"));
+ TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]"));
+ TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]"));
int cw = 50;//TableLookups->width()/4;
qDebug("column width %i",cw);
TableLookups->setColumnWidth( 0, cw+30 );
TableLookups->setColumnWidth( 1, cw );
@@ -217,11 +213,11 @@ void Ntp::readLookups()
// qDebug("%i last %f",i,last);
// qDebug("%i shift %f",i,shift);
shiftPerSec = shift / last;
_shiftPerSec += shiftPerSec;
- TableLookups->setText( i,0,QString::number(shiftPerSec));
+ TableLookups->setText( i,0,QString::number(shiftPerSec*60));
TableLookups->setText( i,2,QString::number(shift));
- TableLookups->setText( i,1,QString::number(last));
+ TableLookups->setText( i,1,QString::number(last/60));
}
_shiftPerSec /= lookupCount+1;
TextLabelShift->setText(QString::number(_shiftPerSec)+tr(" seconds"));
}
@@ -272,8 +268,9 @@ void Ntp::slotCheckNtp(int i)
}
void Ntp::slotProbeNtpServer()
{
+ qDebug("Ntp::slotProbeNtpServer()");
ntpSock->connectToHost( getNtpServer() ,123);
}
void Ntp::slotNtpDelayChanged(int delay)
@@ -286,9 +283,4 @@ void Ntp::ntpOutPut(QString out)
MultiLineEditntpOutPut->append(out);
MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
}
-void Ntp::slotTimeoutNtpProcess()
-{
- ntpProcess->kill();
- slotProbeNtpServer();
-}
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h
index d166973..c78dc55 100644
--- a/noncore/settings/netsystemtime/ntp.h
+++ b/noncore/settings/netsystemtime/ntp.h
@@ -24,9 +24,9 @@ private:
QString _ntpOutput;
float _shiftPerSec;
int _lookupDiff;
OProcess *ntpProcess;
- QTimer *ntpTimer, *processTimer;
+ QTimer *ntpTimer;
QSocket *ntpSock;
float getTimeShift();
void readLookups();
@@ -41,8 +41,7 @@ private slots:
void slotCheckNtp(int);
void setPredictTime();
void slotProbeNtpServer();
void slotNtpDelayChanged(int);
- void slotTimeoutNtpProcess();
};
#endif
diff --git a/noncore/settings/netsystemtime/ntpbase.ui b/noncore/settings/netsystemtime/ntpbase.ui
index a83dc93..f5e9371 100644
--- a/noncore/settings/netsystemtime/ntpbase.ui
+++ b/noncore/settings/netsystemtime/ntpbase.ui
@@ -10,9 +10,9 @@
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>328</width>
+ <width>324</width>
<height>411</height>
</rect>
</property>
<property stdset="1">
@@ -299,8 +299,14 @@
<name>name</name>
<cstring>TableLookups</cstring>
</property>
<property stdset="1">
+ <name>font</name>
+ <font>
+ <pointsize>8</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
<name>numRows</name>
<number>2</number>
</property>
<property stdset="1">