-rw-r--r-- | noncore/settings/netsystemtime/ntptabwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/predicttabwidget.cpp | 2 |
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) Opie Team <opie-devel@handhelds.org> | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "ntptabwidget.h" | 31 | #include "ntptabwidget.h" |
32 | 32 | ||
33 | #include <opie2/oresource.h> | 33 | #include <opie2/oresource.h> |
34 | 34 | ||
35 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
36 | 36 | ||
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qmultilineedit.h> | 39 | #include <qmultilineedit.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qscrollview.h> | 41 | #include <qscrollview.h> |
42 | 42 | ||
43 | NTPTabWidget::NTPTabWidget( QWidget *parent ) | 43 | NTPTabWidget::NTPTabWidget( QWidget *parent ) |
44 | : QWidget( parent, 0x0, 0 ) | 44 | : QWidget( parent, 0x0, 0 ) |
45 | { | 45 | { |
46 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | 46 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); |
47 | QScrollView *sv = new QScrollView( this ); | 47 | QScrollView *sv = new QScrollView( this ); |
48 | tmpvb->addWidget( sv, 0, 0 ); | 48 | tmpvb->addWidget( sv, 0, 0 ); |
49 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 49 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
50 | sv->setFrameStyle( QFrame::NoFrame ); | 50 | sv->setFrameStyle( QFrame::NoFrame ); |
51 | QWidget *container = new QWidget( sv->viewport() ); | 51 | QWidget *container = new QWidget( sv->viewport() ); |
52 | sv->addChild( container ); | 52 | sv->addChild( container ); |
53 | 53 | ||
54 | QGridLayout *layout = new QGridLayout( container ); | 54 | QGridLayout *layout = new QGridLayout( container ); |
55 | layout->setMargin( 2 ); | 55 | layout->setMargin( 2 ); |
56 | layout->setSpacing( 4 ); | 56 | layout->setSpacing( 4 ); |
57 | 57 | ||
58 | // Start time | 58 | // Start time |
59 | layout->addWidget( new QLabel( tr( "Start time" ), container ), 0, 0 ); | 59 | layout->addWidget( new QLabel( tr( "Start time" ), container ), 0, 0 ); |
60 | lblStartTime = new QLabel( tr( "n/a" ), container ); | 60 | lblStartTime = new QLabel( tr( "n/a" ), container ); |
61 | layout->addWidget( lblStartTime, 0, 1 ); | 61 | layout->addWidget( lblStartTime, 0, 1 ); |
62 | 62 | ||
63 | // Time shift | 63 | // Time shift |
64 | layout->addWidget( new QLabel( tr( "Time shift" ), container ), 1, 0 ); | 64 | layout->addWidget( new QLabel( tr( "Time shift" ), container ), 1, 0 ); |
65 | lblTimeShift = new QLabel( tr( "n/a" ), container ); | 65 | lblTimeShift = new QLabel( tr( "n/a" ), container ); |
66 | layout->addWidget( lblTimeShift, 1, 1 ); | 66 | layout->addWidget( lblTimeShift, 1, 1 ); |
67 | 67 | ||
68 | // New time | 68 | // New time |
69 | layout->addWidget( new QLabel( tr( "New time" ), container ), 2, 0 ); | 69 | layout->addWidget( new QLabel( tr( "New time" ), container ), 2, 0 ); |
70 | lblNewTime = new QLabel( tr( "n/a" ), container ); | 70 | lblNewTime = new QLabel( tr( "n/a" ), container ); |
71 | layout->addWidget( lblNewTime, 2, 1 ); | 71 | layout->addWidget( lblNewTime, 2, 1 ); |
72 | 72 | ||
73 | // NTP output display | 73 | // NTP output display |
74 | mleNtpOutput = new QMultiLineEdit( container ); | 74 | mleNtpOutput = new QMultiLineEdit( container ); |
75 | QFont font( mleNtpOutput->font() ); | 75 | QFont font( mleNtpOutput->font() ); |
76 | font.setPointSize( 7 ); | 76 | font.setPointSize( font.pointSize() - 2 ); |
77 | mleNtpOutput->setFont( font ); | 77 | mleNtpOutput->setFont( font ); |
78 | mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth ); | 78 | mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth ); |
79 | layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 ); | 79 | layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 ); |
80 | 80 | ||
81 | // Set NTP time button | 81 | // Set NTP time button |
82 | m_ntpBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "netsystemtime/ntptab", Opie::Core::OResource::SmallIcon ), | 82 | m_ntpBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "netsystemtime/ntptab", Opie::Core::OResource::SmallIcon ), |
83 | tr( "Get time from the network" ), container ); | 83 | tr( "Get time from the network" ), container ); |
84 | m_ntpBtn->setMinimumHeight( AppLnk::smallIconSize()+4 ); | 84 | m_ntpBtn->setMinimumHeight( AppLnk::smallIconSize()+4 ); |
85 | connect( m_ntpBtn, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); | 85 | connect( m_ntpBtn, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); |
86 | layout->addMultiCellWidget( m_ntpBtn, 4, 4, 0, 1 ); | 86 | layout->addMultiCellWidget( m_ntpBtn, 4, 4, 0, 1 ); |
87 | } | 87 | } |
88 | 88 | ||
89 | NTPTabWidget::~NTPTabWidget() | 89 | NTPTabWidget::~NTPTabWidget() |
90 | { | 90 | { |
91 | } | 91 | } |
92 | 92 | ||
93 | void NTPTabWidget::setStartTime( const QString &str ) | 93 | void NTPTabWidget::setStartTime( const QString &str ) |
94 | { | 94 | { |
95 | lblStartTime->setText( str ); | 95 | lblStartTime->setText( str ); |
96 | } | 96 | } |
97 | 97 | ||
98 | void NTPTabWidget::setTimeShift( const QString &str ) | 98 | void NTPTabWidget::setTimeShift( const QString &str ) |
99 | { | 99 | { |
100 | lblTimeShift->setText( str ); | 100 | lblTimeShift->setText( str ); |
101 | } | 101 | } |
102 | 102 | ||
103 | void NTPTabWidget::setNewTime( const QString &str ) | 103 | void NTPTabWidget::setNewTime( const QString &str ) |
104 | { | 104 | { |
105 | lblNewTime->setText( str ); | 105 | lblNewTime->setText( str ); |
106 | } | 106 | } |
107 | 107 | ||
108 | void NTPTabWidget::addNtpOutput( const QString &str ) | 108 | void NTPTabWidget::addNtpOutput( const QString &str ) |
109 | { | 109 | { |
110 | mleNtpOutput->append( str ); | 110 | mleNtpOutput->append( str ); |
111 | mleNtpOutput->setCursorPosition( mleNtpOutput->numLines() + 1, 0, FALSE ); | 111 | mleNtpOutput->setCursorPosition( mleNtpOutput->numLines() + 1, 0, FALSE ); |
112 | } | 112 | } |
113 | 113 | ||
114 | void NTPTabWidget::setNTPBtnEnabled( bool enabled ) | 114 | void NTPTabWidget::setNTPBtnEnabled( bool enabled ) |
115 | { | 115 | { |
116 | m_ntpBtn->setEnabled( enabled ); | 116 | m_ntpBtn->setEnabled( enabled ); |
117 | } | 117 | } |
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) Opie Team <opie-devel@handhelds.org> | 4 | Copyright (C) Opie Team <opie-devel@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "predicttabwidget.h" | 31 | #include "predicttabwidget.h" |
32 | 32 | ||
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/timeconversion.h> | 34 | #include <qpe/timeconversion.h> |
35 | 35 | ||
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qscrollview.h> | 39 | #include <qscrollview.h> |
40 | #include <qtable.h> | 40 | #include <qtable.h> |
41 | 41 | ||
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | 43 | ||
44 | PredictTabWidget::PredictTabWidget( QWidget *parent ) | 44 | PredictTabWidget::PredictTabWidget( QWidget *parent ) |
45 | : QWidget( parent, 0x0, 0 ) | 45 | : QWidget( parent, 0x0, 0 ) |
46 | { | 46 | { |
47 | /* | 47 | /* |
48 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | 48 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); |
49 | QScrollView *sv = new QScrollView( this ); | 49 | QScrollView *sv = new QScrollView( this ); |
50 | tmpvb->addWidget( sv, 0, 0 ); | 50 | tmpvb->addWidget( sv, 0, 0 ); |
51 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 51 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
52 | sv->setFrameStyle( QFrame::NoFrame ); | 52 | sv->setFrameStyle( QFrame::NoFrame ); |
53 | QWidget *container = new QWidget( sv->viewport() ); | 53 | QWidget *container = new QWidget( sv->viewport() ); |
54 | sv->addChild( container ); | 54 | sv->addChild( container ); |
55 | */ | 55 | */ |
56 | 56 | ||
57 | QGridLayout *layout = new QGridLayout( this ); | 57 | QGridLayout *layout = new QGridLayout( this ); |
58 | layout->setMargin( 2 ); | 58 | layout->setMargin( 2 ); |
59 | layout->setSpacing( 4 ); | 59 | layout->setSpacing( 4 ); |
60 | 60 | ||
61 | // Predicted time drift | 61 | // Predicted time drift |
62 | layout->addWidget( new QLabel( tr( "Predicted time drift" ), this ), 0, 0 ); | 62 | layout->addWidget( new QLabel( tr( "Predicted time drift" ), this ), 0, 0 ); |
63 | lblDrift = new QLabel( tr( "n/a" ), this ); | 63 | lblDrift = new QLabel( tr( "n/a" ), this ); |
64 | layout->addWidget( lblDrift, 0, 1 ); | 64 | layout->addWidget( lblDrift, 0, 1 ); |
65 | 65 | ||
66 | // Estimated time difference | 66 | // Estimated time difference |
67 | layout->addWidget( new QLabel( tr( "Estimated shift" ), this ), 1, 0 ); | 67 | layout->addWidget( new QLabel( tr( "Estimated shift" ), this ), 1, 0 ); |
68 | lblDiff = new QLabel( tr( "n/a" ), this ); | 68 | lblDiff = new QLabel( tr( "n/a" ), this ); |
69 | layout->addWidget( lblDiff, 1, 1 ); | 69 | layout->addWidget( lblDiff, 1, 1 ); |
70 | 70 | ||
71 | // Predicted time | 71 | // Predicted time |
72 | layout->addWidget( new QLabel( tr( "Predicted time" ), this ), 2, 0 ); | 72 | layout->addWidget( new QLabel( tr( "Predicted time" ), this ), 2, 0 ); |
73 | lblPredicted = new QLabel( tr( "n/a" ), this ); | 73 | lblPredicted = new QLabel( tr( "n/a" ), this ); |
74 | layout->addWidget( lblPredicted, 2, 1 ); | 74 | layout->addWidget( lblPredicted, 2, 1 ); |
75 | 75 | ||
76 | // Prediction table | 76 | // Prediction table |
77 | tblLookups = new QTable( 2, 3, this ); | 77 | tblLookups = new QTable( 2, 3, this ); |
78 | QFont font( tblLookups->font() ); | 78 | QFont font( tblLookups->font() ); |
79 | font.setPointSize( 7 ); | 79 | font.setPointSize( font.pointSize() - 2 ); |
80 | tblLookups->setFont( font ); | 80 | tblLookups->setFont( font ); |
81 | tblLookups->horizontalHeader()->setLabel( 0, tr( "Shift [s/h]" ) ); | 81 | tblLookups->horizontalHeader()->setLabel( 0, tr( "Shift [s/h]" ) ); |
82 | tblLookups->horizontalHeader()->setLabel( 1, tr( "Last [h]" ) ); | 82 | tblLookups->horizontalHeader()->setLabel( 1, tr( "Last [h]" ) ); |
83 | tblLookups->horizontalHeader()->setLabel( 2, tr( "Offset [s]" ) ); | 83 | tblLookups->horizontalHeader()->setLabel( 2, tr( "Offset [s]" ) ); |
84 | 84 | ||
85 | tblLookups->setMinimumHeight( 50 ); | 85 | tblLookups->setMinimumHeight( 50 ); |
86 | tblLookups->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); | 86 | tblLookups->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); |
87 | layout->addMultiCellWidget( tblLookups, 3, 3, 0, 1 ); | 87 | layout->addMultiCellWidget( tblLookups, 3, 3, 0, 1 ); |
88 | 88 | ||
89 | // Predict time button | 89 | // Predict time button |
90 | QPushButton *pb = new QPushButton( tr( "Predict time" ), this ); | 90 | QPushButton *pb = new QPushButton( tr( "Predict time" ), this ); |
91 | connect( pb, SIGNAL(clicked()), this, SLOT(slotPredictTime()) ); | 91 | connect( pb, SIGNAL(clicked()), this, SLOT(slotPredictTime()) ); |
92 | layout->addWidget( pb, 4, 0 ); | 92 | layout->addWidget( pb, 4, 0 ); |
93 | 93 | ||
94 | // Set predicted time button | 94 | // Set predicted time button |
95 | pb = new QPushButton( tr( "Set predicted time" ), this ); | 95 | pb = new QPushButton( tr( "Set predicted time" ), this ); |
96 | connect( pb, SIGNAL(clicked()), this, SLOT(slotSetPredictedTime()) ); | 96 | connect( pb, SIGNAL(clicked()), this, SLOT(slotSetPredictedTime()) ); |
97 | layout->addWidget( pb, 4, 1 ); | 97 | layout->addWidget( pb, 4, 1 ); |
98 | 98 | ||
99 | // Initialize values | 99 | // Initialize values |
100 | Config config( "ntp" ); | 100 | Config config( "ntp" ); |
101 | config.setGroup( "lookups" ); | 101 | config.setGroup( "lookups" ); |
102 | int lookupCount = config.readNumEntry( "count", 0 ); | 102 | int lookupCount = config.readNumEntry( "count", 0 ); |
103 | float last, shift, shiftPerSec; | 103 | float last, shift, shiftPerSec; |
104 | tblLookups->setNumRows( lookupCount ); | 104 | tblLookups->setNumRows( lookupCount ); |
105 | int cw = tblLookups->width() / 4; | 105 | int cw = tblLookups->width() / 4; |
106 | cw = 50; | 106 | cw = 50; |
107 | tblLookups->sortColumn( 0, FALSE, TRUE ); | 107 | tblLookups->sortColumn( 0, FALSE, TRUE ); |
108 | _shiftPerSec = 0; | 108 | _shiftPerSec = 0; |
109 | QString grpname; | 109 | QString grpname; |
110 | for ( int i=0; i < lookupCount; i++ ) | 110 | for ( int i=0; i < lookupCount; i++ ) |
111 | { | 111 | { |
112 | grpname = "lookup_"; | 112 | grpname = "lookup_"; |
113 | grpname.append( QString::number( i ) ); | 113 | grpname.append( QString::number( i ) ); |
114 | config.setGroup( grpname ); | 114 | config.setGroup( grpname ); |
115 | last = config.readEntry( "secsSinceLast", 0 ).toFloat(); | 115 | last = config.readEntry( "secsSinceLast", 0 ).toFloat(); |
116 | shift = QString( config.readEntry( "timeShift", 0 ) ).toFloat(); | 116 | shift = QString( config.readEntry( "timeShift", 0 ) ).toFloat(); |
117 | shiftPerSec = shift / last; | 117 | shiftPerSec = shift / last; |
118 | _shiftPerSec += shiftPerSec; | 118 | _shiftPerSec += shiftPerSec; |
119 | tblLookups->setText( i, 0, QString::number( shiftPerSec * 60 * 60 ) ); | 119 | tblLookups->setText( i, 0, QString::number( shiftPerSec * 60 * 60 ) ); |
120 | tblLookups->setText( i, 2, QString::number( shift ) ); | 120 | tblLookups->setText( i, 2, QString::number( shift ) ); |
121 | tblLookups->setText( i, 1, QString::number( last / ( 60 * 60 ) ) ); | 121 | tblLookups->setText( i, 1, QString::number( last / ( 60 * 60 ) ) ); |
122 | } | 122 | } |
123 | if(lookupCount) | 123 | if(lookupCount) |
124 | _shiftPerSec /= lookupCount; | 124 | _shiftPerSec /= lookupCount; |
125 | QString drift = QString::number( _shiftPerSec * 60 * 60); | 125 | QString drift = QString::number( _shiftPerSec * 60 * 60); |
126 | drift.append( tr( " s/h" ) ); | 126 | drift.append( tr( " s/h" ) ); |
127 | lblDrift->setText( drift ); | 127 | lblDrift->setText( drift ); |
128 | 128 | ||
129 | Config lconfig( "locale" ); | 129 | Config lconfig( "locale" ); |
130 | lconfig.setGroup( "Location" ); | 130 | lconfig.setGroup( "Location" ); |
131 | tz = lconfig.readEntry( "Timezone", "America/New_York" ); | 131 | tz = lconfig.readEntry( "Timezone", "America/New_York" ); |
132 | } | 132 | } |
133 | 133 | ||
134 | PredictTabWidget::~PredictTabWidget() | 134 | PredictTabWidget::~PredictTabWidget() |
135 | { | 135 | { |
136 | } | 136 | } |
137 | 137 | ||
138 | void PredictTabWidget::setShiftPerSec( int i ) | 138 | void PredictTabWidget::setShiftPerSec( int i ) |
139 | { | 139 | { |
140 | _shiftPerSec += i; | 140 | _shiftPerSec += i; |
141 | } | 141 | } |
142 | 142 | ||
143 | void PredictTabWidget::slotTZChanged( const QString &newtz ) | 143 | void PredictTabWidget::slotTZChanged( const QString &newtz ) |
144 | { | 144 | { |
145 | tz = newtz; | 145 | tz = newtz; |
146 | } | 146 | } |
147 | 147 | ||
148 | void PredictTabWidget::slotPredictTime() | 148 | void PredictTabWidget::slotPredictTime() |
149 | { | 149 | { |
150 | Config config( "ntp" ); | 150 | Config config( "ntp" ); |
151 | config.setGroup( "lookups" ); | 151 | config.setGroup( "lookups" ); |
152 | int lastTime = config.readNumEntry( "time", 0 ); | 152 | int lastTime = config.readNumEntry( "time", 0 ); |
153 | config.writeEntry( "lastNtp", TRUE ); | 153 | config.writeEntry( "lastNtp", TRUE ); |
154 | setenv( "TZ", tz, 1 ); | 154 | setenv( "TZ", tz, 1 ); |
155 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 155 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
156 | int corr = int( ( now - lastTime ) * _shiftPerSec ); | 156 | int corr = int( ( now - lastTime ) * _shiftPerSec ); |
157 | QString diff = QString::number( corr ); | 157 | QString diff = QString::number( corr ); |
158 | diff.append( tr( " seconds" ) ); | 158 | diff.append( tr( " seconds" ) ); |
159 | lblDiff->setText( diff ); | 159 | lblDiff->setText( diff ); |
160 | predictedTime = QDateTime::currentDateTime().addSecs( corr ); | 160 | predictedTime = QDateTime::currentDateTime().addSecs( corr ); |
161 | lblPredicted->setText( predictedTime.toString() ); | 161 | lblPredicted->setText( predictedTime.toString() ); |
162 | } | 162 | } |
163 | 163 | ||
164 | void PredictTabWidget::slotSetPredictedTime() | 164 | void PredictTabWidget::slotSetPredictedTime() |
165 | { | 165 | { |
166 | slotPredictTime(); | 166 | slotPredictTime(); |
167 | emit setTime( predictedTime ); | 167 | emit setTime( predictedTime ); |
168 | } | 168 | } |