summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntptabwidget.cpp2
-rw-r--r--noncore/settings/netsystemtime/predicttabwidget.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/netsystemtime/ntptabwidget.cpp b/noncore/settings/netsystemtime/ntptabwidget.cpp
index 16d21cc..d0107a4 100644
--- a/noncore/settings/netsystemtime/ntptabwidget.cpp
+++ b/noncore/settings/netsystemtime/ntptabwidget.cpp
@@ -1,117 +1,117 @@
/*
                This file is part of the Opie Project
Copyright (C) Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
: ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
:     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "ntptabwidget.h"
#include <opie2/oresource.h>
#include <qpe/applnk.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include <qscrollview.h>
NTPTabWidget::NTPTabWidget( QWidget *parent )
: QWidget( parent, 0x0, 0 )
{
QVBoxLayout *tmpvb = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
tmpvb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Start time
layout->addWidget( new QLabel( tr( "Start time" ), container ), 0, 0 );
lblStartTime = new QLabel( tr( "n/a" ), container );
layout->addWidget( lblStartTime, 0, 1 );
// Time shift
layout->addWidget( new QLabel( tr( "Time shift" ), container ), 1, 0 );
lblTimeShift = new QLabel( tr( "n/a" ), container );
layout->addWidget( lblTimeShift, 1, 1 );
// New time
layout->addWidget( new QLabel( tr( "New time" ), container ), 2, 0 );
lblNewTime = new QLabel( tr( "n/a" ), container );
layout->addWidget( lblNewTime, 2, 1 );
// NTP output display
mleNtpOutput = new QMultiLineEdit( container );
QFont font( mleNtpOutput->font() );
- font.setPointSize( 7 );
+ font.setPointSize( font.pointSize() - 2 );
mleNtpOutput->setFont( font );
mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth );
layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 );
// Set NTP time button
m_ntpBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "netsystemtime/ntptab", Opie::Core::OResource::SmallIcon ),
tr( "Get time from the network" ), container );
m_ntpBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
connect( m_ntpBtn, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) );
layout->addMultiCellWidget( m_ntpBtn, 4, 4, 0, 1 );
}
NTPTabWidget::~NTPTabWidget()
{
}
void NTPTabWidget::setStartTime( const QString &str )
{
lblStartTime->setText( str );
}
void NTPTabWidget::setTimeShift( const QString &str )
{
lblTimeShift->setText( str );
}
void NTPTabWidget::setNewTime( const QString &str )
{
lblNewTime->setText( str );
}
void NTPTabWidget::addNtpOutput( const QString &str )
{
mleNtpOutput->append( str );
mleNtpOutput->setCursorPosition( mleNtpOutput->numLines() + 1, 0, FALSE );
}
void NTPTabWidget::setNTPBtnEnabled( bool enabled )
{
m_ntpBtn->setEnabled( enabled );
}
diff --git a/noncore/settings/netsystemtime/predicttabwidget.cpp b/noncore/settings/netsystemtime/predicttabwidget.cpp
index 98e0afd..0b95277 100644
--- a/noncore/settings/netsystemtime/predicttabwidget.cpp
+++ b/noncore/settings/netsystemtime/predicttabwidget.cpp
@@ -1,168 +1,168 @@
/*
                This file is part of the Opie Project
Copyright (C) Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
: ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
:     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "predicttabwidget.h"
#include <qpe/config.h>
#include <qpe/timeconversion.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qscrollview.h>
#include <qtable.h>
#include <stdlib.h>
PredictTabWidget::PredictTabWidget( QWidget *parent )
: QWidget( parent, 0x0, 0 )
{
/*
QVBoxLayout *tmpvb = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
tmpvb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
*/
QGridLayout *layout = new QGridLayout( this );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Predicted time drift
layout->addWidget( new QLabel( tr( "Predicted time drift" ), this ), 0, 0 );
lblDrift = new QLabel( tr( "n/a" ), this );
layout->addWidget( lblDrift, 0, 1 );
// Estimated time difference
layout->addWidget( new QLabel( tr( "Estimated shift" ), this ), 1, 0 );
lblDiff = new QLabel( tr( "n/a" ), this );
layout->addWidget( lblDiff, 1, 1 );
// Predicted time
layout->addWidget( new QLabel( tr( "Predicted time" ), this ), 2, 0 );
lblPredicted = new QLabel( tr( "n/a" ), this );
layout->addWidget( lblPredicted, 2, 1 );
// Prediction table
tblLookups = new QTable( 2, 3, this );
QFont font( tblLookups->font() );
- font.setPointSize( 7 );
+ font.setPointSize( font.pointSize() - 2 );
tblLookups->setFont( font );
tblLookups->horizontalHeader()->setLabel( 0, tr( "Shift [s/h]" ) );
tblLookups->horizontalHeader()->setLabel( 1, tr( "Last [h]" ) );
tblLookups->horizontalHeader()->setLabel( 2, tr( "Offset [s]" ) );
tblLookups->setMinimumHeight( 50 );
tblLookups->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) );
layout->addMultiCellWidget( tblLookups, 3, 3, 0, 1 );
// Predict time button
QPushButton *pb = new QPushButton( tr( "Predict time" ), this );
connect( pb, SIGNAL(clicked()), this, SLOT(slotPredictTime()) );
layout->addWidget( pb, 4, 0 );
// Set predicted time button
pb = new QPushButton( tr( "Set predicted time" ), this );
connect( pb, SIGNAL(clicked()), this, SLOT(slotSetPredictedTime()) );
layout->addWidget( pb, 4, 1 );
// Initialize values
Config config( "ntp" );
config.setGroup( "lookups" );
int lookupCount = config.readNumEntry( "count", 0 );
float last, shift, shiftPerSec;
tblLookups->setNumRows( lookupCount );
int cw = tblLookups->width() / 4;
cw = 50;
tblLookups->sortColumn( 0, FALSE, TRUE );
_shiftPerSec = 0;
QString grpname;
for ( int i=0; i < lookupCount; i++ )
{
grpname = "lookup_";
grpname.append( QString::number( i ) );
config.setGroup( grpname );
last = config.readEntry( "secsSinceLast", 0 ).toFloat();
shift = QString( config.readEntry( "timeShift", 0 ) ).toFloat();
shiftPerSec = shift / last;
_shiftPerSec += shiftPerSec;
tblLookups->setText( i, 0, QString::number( shiftPerSec * 60 * 60 ) );
tblLookups->setText( i, 2, QString::number( shift ) );
tblLookups->setText( i, 1, QString::number( last / ( 60 * 60 ) ) );
}
if(lookupCount)
_shiftPerSec /= lookupCount;
QString drift = QString::number( _shiftPerSec * 60 * 60);
drift.append( tr( " s/h" ) );
lblDrift->setText( drift );
Config lconfig( "locale" );
lconfig.setGroup( "Location" );
tz = lconfig.readEntry( "Timezone", "America/New_York" );
}
PredictTabWidget::~PredictTabWidget()
{
}
void PredictTabWidget::setShiftPerSec( int i )
{
_shiftPerSec += i;
}
void PredictTabWidget::slotTZChanged( const QString &newtz )
{
tz = newtz;
}
void PredictTabWidget::slotPredictTime()
{
Config config( "ntp" );
config.setGroup( "lookups" );
int lastTime = config.readNumEntry( "time", 0 );
config.writeEntry( "lastNtp", TRUE );
setenv( "TZ", tz, 1 );
int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
int corr = int( ( now - lastTime ) * _shiftPerSec );
QString diff = QString::number( corr );
diff.append( tr( " seconds" ) );
lblDiff->setText( diff );
predictedTime = QDateTime::currentDateTime().addSecs( corr );
lblPredicted->setText( predictedTime.toString() );
}
void PredictTabWidget::slotSetPredictedTime()
{
slotPredictTime();
emit setTime( predictedTime );
}