Diffstat (limited to 'noncore/settings/netsystemtime/ntptabwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/netsystemtime/ntptabwidget.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/noncore/settings/netsystemtime/ntptabwidget.cpp b/noncore/settings/netsystemtime/ntptabwidget.cpp new file mode 100644 index 0000000..d71c230 --- a/dev/null +++ b/noncore/settings/netsystemtime/ntptabwidget.cpp | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "ntptabwidget.h" | ||
30 | |||
31 | #include <qpe/resource.h> | ||
32 | |||
33 | #include <qlabel.h> | ||
34 | #include <qlayout.h> | ||
35 | #include <qmultilineedit.h> | ||
36 | #include <qpushbutton.h> | ||
37 | #include <qscrollview.h> | ||
38 | |||
39 | NTPTabWidget::NTPTabWidget( QWidget *parent ) | ||
40 | : QWidget( parent, 0x0, 0 ) | ||
41 | { | ||
42 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | ||
43 | QScrollView *sv = new QScrollView( this ); | ||
44 | tmpvb->addWidget( sv, 0, 0 ); | ||
45 | sv->setResizePolicy( QScrollView::AutoOneFit ); | ||
46 | sv->setFrameStyle( QFrame::NoFrame ); | ||
47 | QWidget *container = new QWidget( sv->viewport() ); | ||
48 | sv->addChild( container ); | ||
49 | |||
50 | QGridLayout *layout = new QGridLayout( container ); | ||
51 | layout->setMargin( 2 ); | ||
52 | layout->setSpacing( 4 ); | ||
53 | |||
54 | // Start time | ||
55 | layout->addWidget( new QLabel( tr( "Start time" ), container ), 0, 0 ); | ||
56 | lblStartTime = new QLabel( tr( "n/a" ), container ); | ||
57 | layout->addWidget( lblStartTime, 0, 1 ); | ||
58 | |||
59 | // Time shift | ||
60 | layout->addWidget( new QLabel( tr( "Time shift" ), container ), 1, 0 ); | ||
61 | lblTimeShift = new QLabel( tr( "n/a" ), container ); | ||
62 | layout->addWidget( lblTimeShift, 1, 1 ); | ||
63 | |||
64 | // New time | ||
65 | layout->addWidget( new QLabel( tr( "New time" ), container ), 2, 0 ); | ||
66 | lblNewTime = new QLabel( tr( "n/a" ), container ); | ||
67 | layout->addWidget( lblNewTime, 2, 1 ); | ||
68 | |||
69 | // NTP output display | ||
70 | mleNtpOutput = new QMultiLineEdit( container ); | ||
71 | QFont font( mleNtpOutput->font() ); | ||
72 | font.setPointSize( 7 ); | ||
73 | mleNtpOutput->setFont( font ); | ||
74 | mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth ); | ||
75 | layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 ); | ||
76 | |||
77 | // Set NTP time button | ||
78 | QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), | ||
79 | tr( "Get time from the network" ), container ); | ||
80 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); | ||
81 | layout->addMultiCellWidget( pb, 4, 4, 0, 1 ); | ||
82 | } | ||
83 | |||
84 | NTPTabWidget::~NTPTabWidget() | ||
85 | { | ||
86 | } | ||
87 | |||
88 | void NTPTabWidget::setStartTime( const QString &str ) | ||
89 | { | ||
90 | lblStartTime->setText( str ); | ||
91 | } | ||
92 | |||
93 | void NTPTabWidget::setTimeShift( const QString &str ) | ||
94 | { | ||
95 | lblTimeShift->setText( str ); | ||
96 | } | ||
97 | |||
98 | void NTPTabWidget::setNewTime( const QString &str ) | ||
99 | { | ||
100 | lblNewTime->setText( str ); | ||
101 | } | ||
102 | |||
103 | void NTPTabWidget::addNtpOutput( const QString &str ) | ||
104 | { | ||
105 | mleNtpOutput->append( str ); | ||
106 | mleNtpOutput->setCursorPosition( mleNtpOutput->numLines() + 1, 0, FALSE ); | ||
107 | } | ||