summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/netsystemtime.pro6
-rw-r--r--noncore/settings/netsystemtime/ntpbase.cpp328
-rw-r--r--noncore/settings/netsystemtime/ntpbase.h93
-rw-r--r--noncore/settings/netsystemtime/settime.cpp8
4 files changed, 428 insertions, 7 deletions
diff --git a/noncore/settings/netsystemtime/netsystemtime.pro b/noncore/settings/netsystemtime/netsystemtime.pro
index 026b8da..0530ea5 100644
--- a/noncore/settings/netsystemtime/netsystemtime.pro
+++ b/noncore/settings/netsystemtime/netsystemtime.pro
@@ -1,26 +1,26 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on debug
3 #CONFIG = qt warn_on release 3 #CONFIG = qt warn_on release
4 HEADERS = ntp.h settime.h 4 HEADERS = ntp.h settime.h ntpbase.h
5 SOURCES = main.cpp ntp.cpp settime.cpp 5 SOURCES = main.cpp ntp.cpp settime.cpp ntpbase.cpp
6 INCLUDEPATH+= $(OPIEDIR)/include 6 INCLUDEPATH+= $(OPIEDIR)/include
7 DEPENDPATH+= $(OPIEDIR)/include 7 DEPENDPATH+= $(OPIEDIR)/include
8LIBS += -lqpe -lopie 8LIBS += -lqpe -lopie
9 INTERFACES= ntpbase.ui 9 INTERFACES=
10DESTDIR = $(OPIEDIR)/bin 10DESTDIR = $(OPIEDIR)/bin
11 TARGET = netsystemtime 11 TARGET = netsystemtime
12 12
13TRANSLATIONS = ../../../i18n/de/netsystemtime.ts \ 13TRANSLATIONS = ../../../i18n/de/netsystemtime.ts \
14 ../../../i18n/en/netsystemtime.ts \ 14 ../../../i18n/en/netsystemtime.ts \
15 ../../../i18n/es/netsystemtime.ts \ 15 ../../../i18n/es/netsystemtime.ts \
16 ../../../i18n/fr/netsystemtime.ts \ 16 ../../../i18n/fr/netsystemtime.ts \
17 ../../../i18n/hu/netsystemtime.ts \ 17 ../../../i18n/hu/netsystemtime.ts \
18 ../../../i18n/ja/netsystemtime.ts \ 18 ../../../i18n/ja/netsystemtime.ts \
19 ../../../i18n/ko/netsystemtime.ts \ 19 ../../../i18n/ko/netsystemtime.ts \
20 ../../../i18n/no/netsystemtime.ts \ 20 ../../../i18n/no/netsystemtime.ts \
21 ../../../i18n/pl/netsystemtime.ts \ 21 ../../../i18n/pl/netsystemtime.ts \
22 ../../../i18n/pt/netsystemtime.ts \ 22 ../../../i18n/pt/netsystemtime.ts \
23 ../../../i18n/pt_BR/netsystemtime.ts \ 23 ../../../i18n/pt_BR/netsystemtime.ts \
24 ../../../i18n/sl/netsystemtime.ts \ 24 ../../../i18n/sl/netsystemtime.ts \
25 ../../../i18n/zh_CN/netsystemtime.ts \ 25 ../../../i18n/zh_CN/netsystemtime.ts \
26 ../../../i18n/zh_TW/netsystemtime.ts 26 ../../../i18n/zh_TW/netsystemtime.ts
diff --git a/noncore/settings/netsystemtime/ntpbase.cpp b/noncore/settings/netsystemtime/ntpbase.cpp
new file mode 100644
index 0000000..7762e93
--- a/dev/null
+++ b/noncore/settings/netsystemtime/ntpbase.cpp
@@ -0,0 +1,328 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'ntpbase.ui'
3**
4** Created: Mon Oct 21 21:06:08 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "ntpbase.h"
10
11#include <qcombobox.h>
12#include <qframe.h>
13#include <qlabel.h>
14#include <qmultilineedit.h>
15#include <qpushbutton.h>
16#include <qspinbox.h>
17#include <qtable.h>
18#include <qtabwidget.h>
19#include <qlayout.h>
20#include <qvariant.h>
21#include <qtooltip.h>
22#include <qwhatsthis.h>
23
24/*
25 * Constructs a NtpBase which is a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'
27 */
28NtpBase::NtpBase( QWidget* parent, const char* name, WFlags fl )
29 : QWidget( parent, name, fl )
30{
31 if ( !name )
32 setName( "NtpBase" );
33 resize( 320, 411 );
34 setCaption( tr( "Network Time" ) );
35 NtpBaseLayout = new QGridLayout( this );
36 NtpBaseLayout->setSpacing( 2 );
37 NtpBaseLayout->setMargin( 2 );
38
39 TabWidgetMain = new QTabWidget( this, "TabWidgetMain" );
40
41 tabMain = new QWidget( TabWidgetMain, "tabMain" );
42 tabMainLayout = new QGridLayout( tabMain );
43 tabMainLayout->setSpacing( 2 );
44 tabMainLayout->setMargin( 2 );
45
46 FrameSystemTime = new QFrame( tabMain, "FrameSystemTime" );
47 FrameSystemTime->setFrameShape( QFrame::StyledPanel );
48 FrameSystemTime->setFrameShadow( QFrame::Raised );
49
50 tabMainLayout->addWidget( FrameSystemTime, 0, 0 );
51
52 tabNtp = new QWidget( TabWidgetMain, "tabNtp" );
53 tabNtpLayout = new QGridLayout( tabNtp );
54 tabNtpLayout->setSpacing( 2 );
55 tabNtpLayout->setMargin( 1 );
56
57 runNtp = new QPushButton( tabNtp, "runNtp" );
58 runNtp->setText( tr( "Get time from network" ) );
59
60 tabNtpLayout->addWidget( runNtp, 1, 0 );
61
62 FrameNtp = new QFrame( tabNtp, "FrameNtp" );
63 FrameNtp->setFrameShape( QFrame::StyledPanel );
64 FrameNtp->setFrameShadow( QFrame::Raised );
65 FrameNtpLayout = new QGridLayout( FrameNtp );
66 FrameNtpLayout->setSpacing( 2 );
67 FrameNtpLayout->setMargin( 2 );
68
69 Layout4 = new QVBoxLayout;
70 Layout4->setSpacing( 6 );
71 Layout4->setMargin( 0 );
72
73 TextLabel1 = new QLabel( FrameNtp, "TextLabel1" );
74 TextLabel1->setAutoMask( FALSE );
75 TextLabel1->setText( tr( "Start Time:" ) );
76 Layout4->addWidget( TextLabel1 );
77
78 TextLabelStartTime = new QLabel( FrameNtp, "TextLabelStartTime" );
79 TextLabelStartTime->setText( tr( "nan" ) );
80 Layout4->addWidget( TextLabelStartTime );
81
82 TextLabel3 = new QLabel( FrameNtp, "TextLabel3" );
83 TextLabel3->setText( tr( "Time Shift:" ) );
84 Layout4->addWidget( TextLabel3 );
85
86 TextLabelTimeShift = new QLabel( FrameNtp, "TextLabelTimeShift" );
87 TextLabelTimeShift->setText( tr( "nan" ) );
88 Layout4->addWidget( TextLabelTimeShift );
89
90 TextLabel5 = new QLabel( FrameNtp, "TextLabel5" );
91 TextLabel5->setText( tr( "New Time:" ) );
92 Layout4->addWidget( TextLabel5 );
93
94 TextLabelNewTime = new QLabel( FrameNtp, "TextLabelNewTime" );
95 TextLabelNewTime->setText( tr( "nan" ) );
96 Layout4->addWidget( TextLabelNewTime );
97 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
98 Layout4->addItem( spacer );
99
100 FrameNtpLayout->addLayout( Layout4, 0, 0 );
101
102 MultiLineEditntpOutPut = new QMultiLineEdit( FrameNtp, "MultiLineEditntpOutPut" );
103 QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() );
104 MultiLineEditntpOutPut_font.setPointSize( 7 );
105 MultiLineEditntpOutPut->setFont( MultiLineEditntpOutPut_font );
106 MultiLineEditntpOutPut->setWordWrap( QMultiLineEdit::WidgetWidth );
107 MultiLineEditntpOutPut->setText( tr( "" ) );
108
109 FrameNtpLayout->addWidget( MultiLineEditntpOutPut, 1, 0 );
110
111 tabNtpLayout->addWidget( FrameNtp, 0, 0 );
112
113 tabPredict = new QWidget( TabWidgetMain, "tabPredict" );
114 tabPredictLayout = new QGridLayout( tabPredict );
115 tabPredictLayout->setSpacing( 6 );
116 tabPredictLayout->setMargin( 5 );
117
118 TableLookups = new QTable( tabPredict, "TableLookups" );
119 QFont TableLookups_font( TableLookups->font() );
120 TableLookups_font.setPointSize( 8 );
121 TableLookups->setFont( TableLookups_font );
122 TableLookups->setNumRows( 2 );
123 TableLookups->setNumCols( 2 );
124
125 tabPredictLayout->addWidget( TableLookups, 0, 0 );
126
127 Layout9 = new QGridLayout;
128 Layout9->setSpacing( 6 );
129 Layout9->setMargin( 0 );
130
131 TextLabelShift = new QLabel( tabPredict, "TextLabelShift" );
132 TextLabelShift->setText( tr( "nan" ) );
133
134 Layout9->addWidget( TextLabelShift, 0, 1 );
135
136 TextLabel4 = new QLabel( tabPredict, "TextLabel4" );
137 TextLabel4->setText( tr( "Esimated Shift:" ) );
138
139 Layout9->addWidget( TextLabel4, 1, 0 );
140
141 TextLabelEstimatedShift = new QLabel( tabPredict, "TextLabelEstimatedShift" );
142 TextLabelEstimatedShift->setText( tr( "nan" ) );
143
144 Layout9->addWidget( TextLabelEstimatedShift, 1, 1 );
145
146 TextLabel3_2 = new QLabel( tabPredict, "TextLabel3_2" );
147 TextLabel3_2->setText( tr( "Predicted Time:" ) );
148
149 Layout9->addWidget( TextLabel3_2, 2, 0 );
150
151 Mean_shift_label = new QLabel( tabPredict, "Mean_shift_label" );
152 Mean_shift_label->setText( tr( "Mean shift:" ) );
153
154 Layout9->addWidget( Mean_shift_label, 0, 0 );
155
156 TextLabelPredTime = new QLabel( tabPredict, "TextLabelPredTime" );
157 TextLabelPredTime->setText( tr( "nan" ) );
158
159 Layout9->addWidget( TextLabelPredTime, 2, 1 );
160
161 tabPredictLayout->addLayout( Layout9, 1, 0 );
162
163 Layout11 = new QHBoxLayout;
164 Layout11->setSpacing( 6 );
165 Layout11->setMargin( 0 );
166
167 PushButtonSetPredTime = new QPushButton( tabPredict, "PushButtonSetPredTime" );
168 PushButtonSetPredTime->setText( tr( "Set predicted time" ) );
169 Layout11->addWidget( PushButtonSetPredTime );
170
171 PushButtonPredict = new QPushButton( tabPredict, "PushButtonPredict" );
172 PushButtonPredict->setText( tr( "Predict time" ) );
173 Layout11->addWidget( PushButtonPredict );
174
175 tabPredictLayout->addLayout( Layout11, 2, 0 );
176
177 TabSettings = new QWidget( TabWidgetMain, "TabSettings" );
178 TabSettingsLayout = new QGridLayout( TabSettings );
179 TabSettingsLayout->setSpacing( 2 );
180 TabSettingsLayout->setMargin( 2 );
181
182 FrameSettings = new QFrame( TabSettings, "FrameSettings" );
183 FrameSettings->setFrameShape( QFrame::StyledPanel );
184 FrameSettings->setFrameShadow( QFrame::Raised );
185 FrameSettingsLayout = new QGridLayout( FrameSettings );
186 FrameSettingsLayout->setSpacing( 11 );
187 FrameSettingsLayout->setMargin( 3 );
188
189 Layout6 = new QGridLayout;
190 Layout6->setSpacing( 6 );
191 Layout6->setMargin( 0 );
192
193 TextLabel7_2 = new QLabel( FrameSettings, "TextLabel7_2" );
194 TextLabel7_2->setText( tr( "Use" ) );
195
196 Layout6->addWidget( TextLabel7_2, 0, 0 );
197
198 TextLabel2_2 = new QLabel( FrameSettings, "TextLabel2_2" );
199 TextLabel2_2->setText( tr( "as" ) );
200
201 Layout6->addWidget( TextLabel2_2, 0, 2 );
202
203 TextLabel1_3 = new QLabel( FrameSettings, "TextLabel1_3" );
204 TextLabel1_3->setText( tr( "NTP server to get the time from the network." ) );
205 TextLabel1_3->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
206
207 Layout6->addMultiCellWidget( TextLabel1_3, 1, 1, 0, 1 );
208
209 ComboNtpSrv = new QComboBox( FALSE, FrameSettings, "ComboNtpSrv" );
210 ComboNtpSrv->setEditable( TRUE );
211
212 Layout6->addWidget( ComboNtpSrv, 0, 1 );
213
214 FrameSettingsLayout->addLayout( Layout6, 0, 0 );
215 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
216 FrameSettingsLayout->addItem( spacer_2, 3, 0 );
217
218 Layout7 = new QGridLayout;
219 Layout7->setSpacing( 6 );
220 Layout7->setMargin( 0 );
221
222 TextLabel1_2 = new QLabel( FrameSettings, "TextLabel1_2" );
223 TextLabel1_2->setText( tr( "Insure a delay of" ) );
224
225 Layout7->addWidget( TextLabel1_2, 0, 0 );
226
227 TextLabel2 = new QLabel( FrameSettings, "TextLabel2" );
228 TextLabel2->setText( tr( "minutes until" ) );
229
230 Layout7->addWidget( TextLabel2, 0, 2 );
231
232 TextLabel3_3 = new QLabel( FrameSettings, "TextLabel3_3" );
233 TextLabel3_3->setText( tr( "a new NTP lookup will be used to predict the time." ) );
234 TextLabel3_3->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
235
236 Layout7->addMultiCellWidget( TextLabel3_3, 1, 1, 0, 2 );
237
238 SpinBoxMinLookupDelay = new QSpinBox( FrameSettings, "SpinBoxMinLookupDelay" );
239 SpinBoxMinLookupDelay->setMaxValue( 9999999 );
240 SpinBoxMinLookupDelay->setMinValue( 42 );
241
242 Layout7->addWidget( SpinBoxMinLookupDelay, 0, 1 );
243
244 FrameSettingsLayout->addLayout( Layout7, 2, 0 );
245
246 Layout7_2 = new QGridLayout;
247 Layout7_2->setSpacing( 6 );
248 Layout7_2->setMargin( 0 );
249
250 TextLabel1_2_2 = new QLabel( FrameSettings, "TextLabel1_2_2" );
251 TextLabel1_2_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, TextLabel1_2_2->sizePolicy().hasHeightForWidth() ) );
252 TextLabel1_2_2->setText( tr( "Wait for " ) );
253
254 Layout7_2->addWidget( TextLabel1_2_2, 0, 0 );
255
256 TextLabel2_3 = new QLabel( FrameSettings, "TextLabel2_3" );
257 TextLabel2_3->setText( tr( "minutes until" ) );
258
259 Layout7_2->addWidget( TextLabel2_3, 0, 2 );
260
261 TextLabel3_3_2 = new QLabel( FrameSettings, "TextLabel3_3_2" );
262 TextLabel3_3_2->setText( tr( "NTP tries to syncronises the clock with the network." ) );
263 TextLabel3_3_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
264
265 Layout7_2->addMultiCellWidget( TextLabel3_3_2, 1, 1, 0, 2 );
266
267 SpinBoxNtpDelay = new QSpinBox( FrameSettings, "SpinBoxNtpDelay" );
268 SpinBoxNtpDelay->setMaxValue( 9999999 );
269 SpinBoxNtpDelay->setMinValue( 0 );
270
271 Layout7_2->addWidget( SpinBoxNtpDelay, 0, 1 );
272
273 FrameSettingsLayout->addLayout( Layout7_2, 1, 0 );
274
275 TabSettingsLayout->addWidget( FrameSettings, 0, 0 );
276
277 tabManualSetTime = new QWidget( TabWidgetMain, "tabManualSetTime" );
278 tabManualSetTimeLayout = new QVBoxLayout( tabManualSetTime );
279 tabManualSetTimeLayout->setSpacing( 2 );
280 tabManualSetTimeLayout->setMargin( 2 );
281
282 FrameSetTime = new QFrame( tabManualSetTime, "FrameSetTime" );
283 FrameSetTime->setFrameShape( QFrame::StyledPanel );
284 FrameSetTime->setFrameShadow( QFrame::Raised );
285 tabManualSetTimeLayout->addWidget( FrameSetTime );
286
287 PushButtonSetManualTime = new QPushButton( tabManualSetTime, "PushButtonSetManualTime" );
288 PushButtonSetManualTime->setText( tr( "Set time" ) );
289 tabManualSetTimeLayout->addWidget( PushButtonSetManualTime );
290
291 TabWidgetMain->insertTab( tabMain, tr( "Main" ) );
292
293 TabWidgetMain->insertTab( tabManualSetTime, tr( "Manual" ) );
294
295 TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) );
296
297 TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) );
298 TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) );
299
300 NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 );
301}
302
303/*
304 * Destroys the object and frees any allocated resources
305 */
306NtpBase::~NtpBase()
307{
308 // no need to delete child widgets, Qt does it all for us
309}
310
311/*
312 * Main event handler. Reimplemented to handle application
313 * font changes
314 */
315bool NtpBase::event( QEvent* ev )
316{
317 bool ret = QWidget::event( ev );
318 if ( ev->type() == QEvent::ApplicationFontChange ) {
319 QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() );
320 MultiLineEditntpOutPut_font.setPointSize( 7 );
321 MultiLineEditntpOutPut->setFont( MultiLineEditntpOutPut_font );
322 QFont TableLookups_font( TableLookups->font() );
323 TableLookups_font.setPointSize( 8 );
324 TableLookups->setFont( TableLookups_font );
325 }
326 return ret;
327}
328
diff --git a/noncore/settings/netsystemtime/ntpbase.h b/noncore/settings/netsystemtime/ntpbase.h
new file mode 100644
index 0000000..b337822
--- a/dev/null
+++ b/noncore/settings/netsystemtime/ntpbase.h
@@ -0,0 +1,93 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'ntpbase.ui'
3**
4** Created: Mon Oct 21 21:05:47 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef NTPBASE_H
10#define NTPBASE_H
11
12#include <qvariant.h>
13#include <qwidget.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QComboBox;
18class QFrame;
19class QLabel;
20class QMultiLineEdit;
21class QPushButton;
22class QSpinBox;
23class QTabWidget;
24class QTable;
25
26class NtpBase : public QWidget
27{
28 Q_OBJECT
29
30public:
31 NtpBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
32 ~NtpBase();
33
34 QTabWidget* TabWidgetMain;
35 QWidget* tabMain;
36 QFrame* FrameSystemTime;
37 QWidget* tabNtp;
38 QPushButton* runNtp;
39 QFrame* FrameNtp;
40 QLabel* TextLabel1;
41 QLabel* TextLabelStartTime;
42 QLabel* TextLabel3;
43 QLabel* TextLabelTimeShift;
44 QLabel* TextLabel5;
45 QLabel* TextLabelNewTime;
46 QMultiLineEdit* MultiLineEditntpOutPut;
47 QWidget* tabPredict;
48 QTable* TableLookups;
49 QLabel* TextLabelShift;
50 QLabel* TextLabel4;
51 QLabel* TextLabelEstimatedShift;
52 QLabel* TextLabel3_2;
53 QLabel* Mean_shift_label;
54 QLabel* TextLabelPredTime;
55 QPushButton* PushButtonSetPredTime;
56 QPushButton* PushButtonPredict;
57 QWidget* TabSettings;
58 QFrame* FrameSettings;
59 QLabel* TextLabel7_2;
60 QLabel* TextLabel2_2;
61 QLabel* TextLabel1_3;
62 QComboBox* ComboNtpSrv;
63 QLabel* TextLabel1_2;
64 QLabel* TextLabel2;
65 QLabel* TextLabel3_3;
66 QSpinBox* SpinBoxMinLookupDelay;
67 QLabel* TextLabel1_2_2;
68 QLabel* TextLabel2_3;
69 QLabel* TextLabel3_3_2;
70 QSpinBox* SpinBoxNtpDelay;
71 QWidget* tabManualSetTime;
72 QFrame* FrameSetTime;
73 QPushButton* PushButtonSetManualTime;
74
75protected:
76 QGridLayout* NtpBaseLayout;
77 QGridLayout* tabMainLayout;
78 QGridLayout* tabNtpLayout;
79 QGridLayout* FrameNtpLayout;
80 QVBoxLayout* Layout4;
81 QGridLayout* tabPredictLayout;
82 QGridLayout* Layout9;
83 QHBoxLayout* Layout11;
84 QGridLayout* TabSettingsLayout;
85 QGridLayout* FrameSettingsLayout;
86 QGridLayout* Layout6;
87 QGridLayout* Layout7;
88 QGridLayout* Layout7_2;
89 QVBoxLayout* tabManualSetTimeLayout;
90 bool event( QEvent* );
91};
92
93#endif // NTPBASE_H
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index f6e02d5..949fcb3 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -15,216 +15,216 @@
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "settime.h" 21#include "settime.h"
22 22
23#include <qpe/alarmserver.h> 23#include <qpe/alarmserver.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/datebookdb.h> 26#include <qpe/datebookdb.h>
27#include <qpe/datebookmonth.h> 27#include <qpe/datebookmonth.h>
28#include <qpe/global.h> 28#include <qpe/global.h>
29#include <qpe/resource.h> 29#include <qpe/resource.h>
30#include <qpe/timeconversion.h> 30#include <qpe/timeconversion.h>
31#include <qpe/tzselect.h> 31#include <qpe/tzselect.h>
32#include <qpe/timestring.h> 32#include <qpe/timestring.h>
33#include <qpe/qpedialog.h> 33#include <qpe/qpedialog.h>
34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36#endif 36#endif
37 37
38#include <qbuttongroup.h> 38#include <qbuttongroup.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qradiobutton.h> 42#include <qradiobutton.h>
43#include <qspinbox.h> 43#include <qspinbox.h>
44#include <qtoolbutton.h> 44#include <qtoolbutton.h>
45#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
46#include <qcombobox.h> 46#include <qcombobox.h>
47 47
48#include <sys/time.h> 48#include <sys/time.h>
49#include <time.h> 49#include <time.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <stdio.h> 51#include <stdio.h>
52 52
53 53
54SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) 54SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f )
55 : NtpBase( parent, name, f ) 55 : NtpBase( parent, name, f )
56{ 56{
57 // setCaption( tr("Set System Time") ); 57 // setCaption( tr("Set System Time") );
58 58
59// QVBoxLayout *vb = new QVBoxLayout( this, 5 ); 59// QVBoxLayout *vb = new QVBoxLayout( this, 5 );
60 QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 ); 60 QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 );
61 QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 ); 61 QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 );
62 62
63# TextLabelMainPredTime = new QLabel( FrameSystemTime ); 63 TextLabelMainPredTime = new QLabel( FrameSystemTime );
64# vb->addWidget( TextLabelMainPredTime, 1, 0 ); 64 vb->addWidget( TextLabelMainPredTime, 1, 0 );
65 65
66 QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); 66 QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" );
67 67
68 QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); 68 QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" );
69 lblZone->setMaximumSize( lblZone->sizeHint() ); 69 lblZone->setMaximumSize( lblZone->sizeHint() );
70 hb->addWidget( lblZone ); 70 hb->addWidget( lblZone );
71 71
72 tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" ); 72 tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" );
73 tz->setMinimumSize( tz->sizeHint() ); 73 tz->setMinimumSize( tz->sizeHint() );
74 hb->addWidget( tz ); 74 hb->addWidget( tz );
75 75
76 timeButton = new SetTime( FrameSetTime ); 76 timeButton = new SetTime( FrameSetTime );
77 vb2->addWidget( timeButton ); 77 vb2->addWidget( timeButton );
78 78
79 QHBoxLayout *db = new QHBoxLayout( vb2 ); 79 QHBoxLayout *db = new QHBoxLayout( vb2 );
80 QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime ); 80 QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime );
81 db->addWidget( dateLabel, 1 ); 81 db->addWidget( dateLabel, 1 );
82 dateButton = new DateButton( TRUE, FrameSetTime ); 82 dateButton = new DateButton( TRUE, FrameSetTime );
83 db->addWidget( dateButton, 2 ); 83 db->addWidget( dateButton, 2 );
84 84
85 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 85 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
86 vb2->addItem( spacer ); 86 vb2->addItem( spacer );
87 87
88 hline = new QFrame( FrameSystemTime ); 88 QFrame *hline = new QFrame( FrameSystemTime );
89 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 89 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
90 vb->addWidget( hline ); 90 vb->addWidget( hline );
91 91
92 Config config("qpe"); 92 Config config("qpe");
93 config.setGroup( "Time" ); 93 config.setGroup( "Time" );
94 94
95 QHBoxLayout *hb1 = new QHBoxLayout( vb ); 95 QHBoxLayout *hb1 = new QHBoxLayout( vb );
96 96
97 QLabel *l = new QLabel( tr("Time format"), FrameSystemTime ); 97 QLabel *l = new QLabel( tr("Time format"), FrameSystemTime );
98 hb1->addWidget( l, 1 ); 98 hb1->addWidget( l, 1 );
99 99
100 100
101 ampmCombo = new QComboBox( FrameSystemTime ); 101 ampmCombo = new QComboBox( FrameSystemTime );
102 ampmCombo->insertItem( tr("24 hour"), 0 ); 102 ampmCombo->insertItem( tr("24 hour"), 0 );
103 ampmCombo->insertItem( tr("12 hour"), 1 ); 103 ampmCombo->insertItem( tr("12 hour"), 1 );
104 hb1->addWidget( ampmCombo, 2 ); 104 hb1->addWidget( ampmCombo, 2 );
105 105
106 int show12hr = config.readBoolEntry("AMPM") ? 1 : 0; 106 int show12hr = config.readBoolEntry("AMPM") ? 1 : 0;
107 ampmCombo->setCurrentItem( show12hr ); 107 ampmCombo->setCurrentItem( show12hr );
108 timeButton->show12hourTime( show12hr ); 108 timeButton->show12hourTime( show12hr );
109 109
110 connect(ampmCombo, SIGNAL(activated(int)), 110 connect(ampmCombo, SIGNAL(activated(int)),
111 timeButton, SLOT(show12hourTime(int))); 111 timeButton, SLOT(show12hourTime(int)));
112 112
113 113
114 114
115 QHBoxLayout *hb2 = new QHBoxLayout( vb ); 115 QHBoxLayout *hb2 = new QHBoxLayout( vb );
116 l = new QLabel( tr("Weeks start on" ), FrameSystemTime ); 116 l = new QLabel( tr("Weeks start on" ), FrameSystemTime );
117 //l->setAlignment( AlignRight | AlignVCenter ); 117 //l->setAlignment( AlignRight | AlignVCenter );
118 hb2->addWidget( l, 1 ); 118 hb2->addWidget( l, 1 );
119 119
120 weekStartCombo = new QComboBox( FrameSystemTime ); 120 weekStartCombo = new QComboBox( FrameSystemTime );
121 weekStartCombo->insertItem( tr("Sunday"), 0 ); 121 weekStartCombo->insertItem( tr("Sunday"), 0 );
122 weekStartCombo->insertItem( tr("Monday"), 1 ); 122 weekStartCombo->insertItem( tr("Monday"), 1 );
123 123
124 hb2->addWidget( weekStartCombo, 2 ); 124 hb2->addWidget( weekStartCombo, 2 );
125 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0; 125 int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0;
126 dateButton->setWeekStartsMonday( startMonday ); 126 dateButton->setWeekStartsMonday( startMonday );
127 weekStartCombo->setCurrentItem( startMonday ); 127 weekStartCombo->setCurrentItem( startMonday );
128 128
129 connect( weekStartCombo, SIGNAL( activated(int)), 129 connect( weekStartCombo, SIGNAL( activated(int)),
130 dateButton, SLOT(setWeekStartsMonday(int))); 130 dateButton, SLOT(setWeekStartsMonday(int)));
131 131
132 132
133 QHBoxLayout *hb3 = new QHBoxLayout( vb ); 133 QHBoxLayout *hb3 = new QHBoxLayout( vb );
134 l = new QLabel( tr("Date format" ), FrameSystemTime ); 134 l = new QLabel( tr("Date format" ), FrameSystemTime );
135 hb3->addWidget( l, 1 ); 135 hb3->addWidget( l, 1 );
136 dateFormatCombo = new QComboBox( FrameSystemTime ); 136 dateFormatCombo = new QComboBox( FrameSystemTime );
137 hb3->addWidget( dateFormatCombo, 2 ); 137 hb3->addWidget( dateFormatCombo, 2 );
138 138
139 config.setGroup( "Date" ); 139 config.setGroup( "Date" );
140 DateFormat df(QChar(config.readEntry("Separator", "/")[0]), 140 DateFormat df(QChar(config.readEntry("Separator", "/")[0]),
141 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), 141 (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
142 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); 142 (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
143 143
144 int currentdf = 0; 144 int currentdf = 0;
145 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear); 145 date_formats[0] = DateFormat('/', DateFormat::MonthDayYear);
146 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) ); 146 dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) );
147 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear); 147 date_formats[1] = DateFormat('.', DateFormat::DayMonthYear);
148 if (df == date_formats[1]) 148 if (df == date_formats[1])
149 currentdf = 1; 149 currentdf = 1;
150 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) ); 150 dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) );
151 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay, 151 date_formats[2] = DateFormat('-', DateFormat::YearMonthDay,
152 DateFormat::DayMonthYear); 152 DateFormat::DayMonthYear);
153 if (df == date_formats[2]) 153 if (df == date_formats[2])
154 currentdf = 2; 154 currentdf = 2;
155 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601 155 dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601
156 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear); 156 date_formats[3] = DateFormat('/', DateFormat::DayMonthYear);
157 if (df == date_formats[3]) 157 if (df == date_formats[3])
158 currentdf = 3; 158 currentdf = 3;
159 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) ); 159 dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) );
160 160
161 dateFormatCombo->setCurrentItem( currentdf ); 161 dateFormatCombo->setCurrentItem( currentdf );
162 dateButton->setDateFormat( df ); 162 dateButton->setDateFormat( df );
163 163
164 connect( dateFormatCombo, SIGNAL( activated(int)), 164 connect( dateFormatCombo, SIGNAL( activated(int)),
165 SLOT(formatChanged(int))); 165 SLOT(formatChanged(int)));
166 166
167 QHBoxLayout *hb4 = new QHBoxLayout( vb ); 167 QHBoxLayout *hb4 = new QHBoxLayout( vb );
168 l = new QLabel( tr("Applet format" ), FrameSystemTime ); 168 l = new QLabel( tr("Applet format" ), FrameSystemTime );
169 hb4->addWidget( l, 1 ); 169 hb4->addWidget( l, 1 );
170 170
171 clockAppletCombo = new QComboBox( FrameSystemTime ); 171 clockAppletCombo = new QComboBox( FrameSystemTime );
172 clockAppletCombo->insertItem( tr("hh:mm"), 0 ); 172 clockAppletCombo->insertItem( tr("hh:mm"), 0 );
173 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); 173 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 );
174 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); 174 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 );
175 175
176 hb4->addWidget( clockAppletCombo, 2 ); 176 hb4->addWidget( clockAppletCombo, 2 );
177 int clockApplet = config.readNumEntry("ClockApplet",0); 177 int clockApplet = config.readNumEntry("ClockApplet",0);
178 clockAppletCombo->setCurrentItem( clockApplet ); 178 clockAppletCombo->setCurrentItem( clockApplet );
179 179
180 vb->addStretch( 0 ); 180 vb->addStretch( 0 );
181 181
182 QFrame *hline = new QFrame( FrameSystemTime ); 182 hline = new QFrame( FrameSystemTime );
183 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 183 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
184 vb->addWidget( hline ); 184 vb->addWidget( hline );
185 185
186 ButtonSetTime = new QPushButton( FrameSystemTime ); 186 ButtonSetTime = new QPushButton( FrameSystemTime );
187 vb->addWidget( ButtonSetTime, 1, 0 ); 187 vb->addWidget( ButtonSetTime, 1, 0 );
188 188
189 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), 189 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()),
190 this, SLOT(commitTime())); 190 this, SLOT(commitTime()));
191 191
192 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 192 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
193 timeButton, SLOT( slotTzChange( const QString& ) ) ); 193 timeButton, SLOT( slotTzChange( const QString& ) ) );
194 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 194 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
195 SLOT( tzChange( const QString& ) ) ); 195 SLOT( tzChange( const QString& ) ) );
196 196
197 QObject::connect( weekStartCombo, SIGNAL( activated ( int )), 197 QObject::connect( weekStartCombo, SIGNAL( activated ( int )),
198 SLOT(updateSystem(int ) )); 198 SLOT(updateSystem(int ) ));
199 QObject::connect( ampmCombo, SIGNAL( activated ( int )), 199 QObject::connect( ampmCombo, SIGNAL( activated ( int )),
200 SLOT(updateSystem(int ) )); 200 SLOT(updateSystem(int ) ));
201 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), 201 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )),
202 SLOT(updateSystem(int ) )); 202 SLOT(updateSystem(int ) ));
203 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), 203 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )),
204 SLOT(updateSystem(int ) )); 204 SLOT(updateSystem(int ) ));
205} 205}
206 206
207SetDateTime::~SetDateTime() 207SetDateTime::~SetDateTime()
208{ 208{
209 writeSettings(); 209 writeSettings();
210 210
211} 211}
212 212
213void SetDateTime::writeSettings() 213void SetDateTime::writeSettings()
214{ 214{
215 Config config("qpe"); 215 Config config("qpe");
216 config.setGroup( "Time" ); 216 config.setGroup( "Time" );
217 config.writeEntry( "AMPM", ampmCombo->currentItem() ); 217 config.writeEntry( "AMPM", ampmCombo->currentItem() );
218 config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); 218 config.writeEntry( "MONDAY", weekStartCombo->currentItem() );
219 config.setGroup( "Date" ); 219 config.setGroup( "Date" );
220 DateFormat df = date_formats[dateFormatCombo->currentItem()]; 220 DateFormat df = date_formats[dateFormatCombo->currentItem()];
221 config.writeEntry( "Separator", QString(df.separator())); 221 config.writeEntry( "Separator", QString(df.separator()));
222 config.writeEntry( "ShortOrder", df.shortOrder()); 222 config.writeEntry( "ShortOrder", df.shortOrder());
223 config.writeEntry( "LongOrder", df.longOrder()); 223 config.writeEntry( "LongOrder", df.longOrder());
224 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); 224 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() );
225 225
226 Config lconfig("locale"); 226 Config lconfig("locale");
227 lconfig.setGroup( "Location" ); 227 lconfig.setGroup( "Location" );
228 lconfig.writeEntry( "Timezone", tz->currentZone() ); 228 lconfig.writeEntry( "Timezone", tz->currentZone() );
229 229
230} 230}