author | drw <drw> | 2005-06-15 18:52:47 (UTC) |
---|---|---|
committer | drw <drw> | 2005-06-15 18:52:47 (UTC) |
commit | c93c8f75bb082c0257ce80f9e8a1eb470bdce397 (patch) (side-by-side diff) | |
tree | 2a83c0cbe4398daf0a141a62b80bd1b926353ce2 | |
parent | 1c8aab0c489b9d469646a0e0ab08f500f1bbb507 (diff) | |
download | opie-c93c8f75bb082c0257ce80f9e8a1eb470bdce397.zip opie-c93c8f75bb082c0257ce80f9e8a1eb470bdce397.tar.gz opie-c93c8f75bb082c0257ce80f9e8a1eb470bdce397.tar.bz2 |
Resource -> OResource and fix doc headers
-rw-r--r-- | noncore/settings/netsystemtime/formattabwidget.cpp | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/formattabwidget.h | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/main.cpp | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/mainwindow.cpp | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/mainwindow.h | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntptabwidget.cpp | 55 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntptabwidget.h | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/predicttabwidget.cpp | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/predicttabwidget.h | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settingstabwidget.cpp | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settingstabwidget.h | 48 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/timetabwidget.cpp | 60 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/timetabwidget.h | 48 |
13 files changed, 338 insertions, 305 deletions
diff --git a/noncore/settings/netsystemtime/formattabwidget.cpp b/noncore/settings/netsystemtime/formattabwidget.cpp index 982305b..7d01bff 100644 --- a/noncore/settings/netsystemtime/formattabwidget.cpp +++ b/noncore/settings/netsystemtime/formattabwidget.cpp @@ -1,168 +1,170 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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 "formattabwidget.h" #include <qpe/config.h> #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qcombobox.h> #include <qlabel.h> #include <qlayout.h> #include <qscrollview.h> #include <qtimer.h> FormatTabWidget::FormatTabWidget( 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 ); // Time format selector layout->addWidget( new QLabel( tr( "Time format" ), container ), 0, 0 ); cbAppletFormat = new QComboBox( container ); cbAppletFormat->insertItem( tr( "hh:mm" ), 0 ); cbAppletFormat->insertItem( tr( "D/M hh:mm" ), 1 ); cbAppletFormat->insertItem( tr( "M/D hh:mm" ), 2 ); layout->addWidget( cbAppletFormat, 0, 1 ); // 12/24 hour selector layout->addWidget( new QLabel( tr( "12/24 hour" ), container ), 1, 0 ); cbAmpm = new QComboBox( container ); cbAmpm->insertItem( tr( "24 hour" ), 0 ); cbAmpm->insertItem( tr( "12 hour" ), 1 ); connect( cbAmpm, SIGNAL(activated(int)), this, SIGNAL(show12HourTime(int)) ); layout->addWidget( cbAmpm, 1, 1 ); // Date format selector layout->addWidget( new QLabel( tr( "Date format" ), container ), 2, 0 ); cbDateFormat = new QComboBox( container ); connect( cbDateFormat, SIGNAL(activated(int)), this, SLOT(slotDateFormatChanged(int)) ); layout->addWidget( cbDateFormat, 2, 1 ); // Week starts on selector layout->addWidget( new QLabel( tr( "Weeks start on" ), container ), 3, 0 ); cbWeekStart = new QComboBox( container ); cbWeekStart->insertItem( tr( "Sunday" ), 0 ); cbWeekStart->insertItem( tr( "Monday" ), 1 ); connect( cbWeekStart, SIGNAL(activated(int)), this, SIGNAL(weekStartChanged(int)) ); layout->addWidget( cbWeekStart, 3, 1 ); // Initialize values Config config( "qpe" ); config.setGroup( "Date" ); cbAppletFormat->setCurrentItem( config.readNumEntry( "ClockApplet", 0 ) ); DateFormat df(QChar(config.readEntry("Separator", "/")[0]), (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear), (DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear)); int currentdf = 0; date_formats[0] = DateFormat( '/', DateFormat::MonthDayYear ); cbDateFormat->insertItem( tr( date_formats[0].toNumberString() ) ); date_formats[1] = DateFormat( '.', DateFormat::DayMonthYear ); if ( df == date_formats[1] ) currentdf = 1; cbDateFormat->insertItem( tr( date_formats[1].toNumberString() ) ); date_formats[2] = DateFormat( '-', DateFormat::YearMonthDay, DateFormat::DayMonthYear ); if ( df == date_formats[2] ) currentdf = 2; cbDateFormat->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601 date_formats[3] = DateFormat( '/', DateFormat::DayMonthYear ); if ( df == date_formats[3] ) currentdf = 3; cbDateFormat->insertItem( tr( date_formats[3].toNumberString() ) ); cbDateFormat->setCurrentItem( currentdf ); //dateButton->setDateFormat( df ); config.setGroup( "Time" ); cbAmpm->setCurrentItem( config.readBoolEntry( "AMPM", FALSE ) ? 1 : 0 ); cbWeekStart->setCurrentItem( config.readBoolEntry( "MONDAY", TRUE ) ? 1 : 0 ); // Send initial configuration options QTimer::singleShot( 1200, this, SLOT(sendOptions()) ); } FormatTabWidget::~FormatTabWidget() { } void FormatTabWidget::saveSettings( bool commit ) { int ampm = cbAmpm->currentItem(); int weekstart = cbWeekStart->currentItem(); DateFormat df = date_formats[cbDateFormat->currentItem()]; int appletformat = cbAppletFormat->currentItem(); if ( commit ) { // Write settings to config file Config config("qpe"); config.setGroup( "Time" ); config.writeEntry( "AMPM", ampm ); config.writeEntry( "MONDAY", weekstart ); config.setGroup( "Date" ); config.writeEntry( "Separator", QString( df.separator() ) ); config.writeEntry( "ShortOrder", df.shortOrder() ); config.writeEntry( "LongOrder", df.longOrder() ); config.writeEntry( "ClockApplet", appletformat ); } // Make rest of system aware of new settings QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); setClock << ampm; QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); setWeek << weekstart; QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); setDateFormat << df; } void FormatTabWidget::slotDateFormatChanged( int selected ) { emit dateFormatChanged( date_formats[selected] ); } void FormatTabWidget::sendOptions() { emit show12HourTime( cbAmpm->currentItem() ); emit dateFormatChanged( date_formats[cbDateFormat->currentItem()] ); emit weekStartChanged( cbWeekStart->currentItem() ); } diff --git a/noncore/settings/netsystemtime/formattabwidget.h b/noncore/settings/netsystemtime/formattabwidget.h index e4073e7..171cd5f 100644 --- a/noncore/settings/netsystemtime/formattabwidget.h +++ b/noncore/settings/netsystemtime/formattabwidget.h @@ -1,65 +1,67 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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. - */ #ifndef FORMATTABWIDGET_H #define FORMATTABWIDGET_H #include <qpe/timestring.h> #include <qwidget.h> class QComboBox; class FormatTabWidget : public QWidget { Q_OBJECT public: FormatTabWidget( QWidget * = 0x0 ); ~FormatTabWidget(); void saveSettings( bool ); private: QComboBox *cbAmpm; QComboBox *cbWeekStart; QComboBox *cbDateFormat; QComboBox *cbAppletFormat; DateFormat date_formats[4]; signals: void show12HourTime( int ); void dateFormatChanged( const DateFormat & ); void weekStartChanged( int ); private slots: void slotDateFormatChanged( int ); void sendOptions(); }; #endif diff --git a/noncore/settings/netsystemtime/main.cpp b/noncore/settings/netsystemtime/main.cpp index dbcdc17..ef1bc8e 100644 --- a/noncore/settings/netsystemtime/main.cpp +++ b/noncore/settings/netsystemtime/main.cpp @@ -1,34 +1,36 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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 "mainwindow.h" #include <opie2/oapplicationfactory.h> using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp index 1f9f8c3..35d4105 100644 --- a/noncore/settings/netsystemtime/mainwindow.cpp +++ b/noncore/settings/netsystemtime/mainwindow.cpp @@ -1,416 +1,418 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= -_;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: -: = ...= . :.=- You should have received a copy of the GNU --. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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 "mainwindow.h" #include "timetabwidget.h" #include "formattabwidget.h" #include "settingstabwidget.h" #include "ntptabwidget.h" #include "predicttabwidget.h" #include <qpe/config.h> #include <qpe/datebookdb.h> #include <qpe/qpeapplication.h> #include <qpe/qpedialog.h> #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qlayout.h> #include <qmessagebox.h> #include <qsocket.h> #include <qstring.h> #include <qtimer.h> using namespace Opie::Ui; using namespace Opie::Core; MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) : QDialog( parent, name, modal, f ) { setCaption( tr( "SystemTime" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); // Create main tabbed control mainWidget = new OTabWidget( this ); // Default object pointers to null ntpProcess = 0x0; ntpTab = 0x0; // Add tab widgets mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); Config config( "ntp" ); config.setGroup( "settings" ); slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", false ) ); slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", false ) ); mainWidget->setCurrentTab( tr( "Time" ) ); layout->addWidget( mainWidget ); connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(slotQCopReceive(const QCString&,const QByteArray&)) ); // Create NTP socket ntpSock = new QSocket( this ); connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); slotProbeNTPServer(); // Create timer for automatic time lookups ntpTimer = new QTimer( this ); // Connect everything together connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); connect( timeTab, SIGNAL(tzChanged(const QString&)), predictTab, SLOT(slotTZChanged(const QString&)) ); connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime(int)) ); connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat&)), timeTab, SLOT(slotDateFormatChanged(const DateFormat&)) ); connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); connect( predictTab, SIGNAL(setTime(const QDateTime&)), this, SLOT(slotSetTime(const QDateTime&)) ); // Do initial time server check slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); slotCheckNtp( -1 ); // Display app //showMaximized(); (void)new QPEDialogListener(this); } MainWindow::~MainWindow() { if ( ntpProcess ) delete ntpProcess; } void MainWindow::accept() { // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) { QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); disableScreenSaver << 0 << 0 << 0; } // Update the systemtime timeTab->saveSettings( true ); // Save format options formatTab->saveSettings( true ); // Save settings options settingsTab->saveSettings(); // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better // grip on itself (example re-trigger alarms for when we travel back in time). DateBookDB db; // Turn back on the screensaver QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); enableScreenSaver << -1 << -1 << -1; // Exit app qApp->quit(); } void MainWindow::reject() { // Reset time settings timeTab->saveSettings( false ); // Send notifications but do not save settings formatTab->saveSettings( false ); // Exit app qApp->quit(); } void MainWindow::runNTP() { if ( !ntpDelayElapsed() && ntpInteractive ) { QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); switch ( QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) ) { case QMessageBox::Yes: break; case QMessageBox::No: return; default: return; } } QString srv = settingsTab->ntpServer(); // Send information to time server tab if enabled if ( ntpTabEnabled ) { ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); QString output = tr( "Running:\nntpdate " ); output.append( srv ); ntpTab->addNtpOutput( output ); ntpTab->setNTPBtnEnabled( false ); } // Disable set time buttons & change app caption to indicate time update is happening timeTab->setNTPBtnEnabled( false ); setCaption( tr( "Retrieving time from network..." ) ); if ( !ntpProcess ) { ntpProcess = new OProcess(); connect( ntpProcess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), this, SLOT(slotNtpOutput(Opie::Core::OProcess*,char*,int)) ); connect( ntpProcess, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT(slotNtpFinished(Opie::Core::OProcess*)) ); } else ntpProcess->clearArguments(); *ntpProcess << "ntpdate" << srv; bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); if ( !ret ) { QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); if ( ntpTabEnabled ) { ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); ntpTab->setNTPBtnEnabled( true ); } // Re-enable set time buttons & change app caption to indicate time update is happening timeTab->setNTPBtnEnabled( true ); setCaption( tr( "SystemTime" ) ); } } bool MainWindow::ntpDelayElapsed() { // Determine if time elapsed is greater than time delay Config config( "ntp" ); config.setGroup( "lookups" ); _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); if ( _lookupDiff < 0 ) return true; return ( _lookupDiff - ( ntpDelay * 60) ) > 0; } void MainWindow::slotSetTime( const QDateTime &dt ) { timeTab->setDateTime( dt ); } void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & ) { if ( msg == "ntpLookup(QString)" ) { ntpInteractive = false; runNTP(); } if ( msg == "setPredictedTime(QString)" ) { //setPredictTime(); } } void MainWindow::slotDisplayNTPTab( bool display ) { ntpTabEnabled = display; // Create widget if it hasn't needed if ( display && !ntpTab ) { ntpTab = new NTPTabWidget( mainWidget ); connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); } // Display/hide tab display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) : mainWidget->removePage( ntpTab ); } void MainWindow::slotDisplayPredictTab( bool display ) { predictTabEnabled = display; // Create widget if it hasn't needed if ( display && !predictTab ) { } // Display/hide tab display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) : mainWidget->removePage( predictTab ); } void MainWindow::slotGetNTPTime() { ntpInteractive = true; runNTP(); } void MainWindow::slotTimerGetNTPTime() { ntpInteractive = false; runNTP(); } void MainWindow::slotProbeNTPServer() { ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); } void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) { QString output = QString( buffer ).left( buflen ); ntpOutput.append( output ); if ( ntpTabEnabled ) ntpTab->addNtpOutput( output ); } void MainWindow::slotNtpFinished( OProcess *p ) { QString output; QDateTime dt = QDateTime::currentDateTime(); // Re-enable set time buttons & change app caption to indicate time update is happening if ( ntpTabEnabled ) ntpTab->setNTPBtnEnabled( true ); timeTab->setNTPBtnEnabled( true ); setCaption( tr( "SystemTime" ) ); // Verify run was successful if ( p->exitStatus() != 0 ) { if ( isVisible() && ntpInteractive ) { output = tr( "Error while getting time from\n server: " ); output.append( settingsTab->ntpServer() ); QMessageBox::critical(this, tr( "Error" ), output ); } // slotCheckNtp(-1); return; } // Set controls on time tab to new time value timeTab->setDateTime( dt ); // Write out lookup information Config config( "ntp" ); config.setGroup( "lookups" ); int lastLookup = config.readNumEntry( "time", 0 ); int lookupCount = config.readNumEntry( "count", 0 ); bool lastNtp = config.readBoolEntry( "lastNtp", false ); int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); config.writeEntry( "time", time ); // Calculate new time/time shift QString _offset = "offset"; QString _sec = "sec"; QRegExp _reOffset = QRegExp( _offset ); QRegExp _reEndOffset = QRegExp( _sec ); int posOffset = _reOffset.match( ntpOutput ); int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); posOffset += _offset.length() + 1; QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); float timeShift = diff.toFloat(); if ( timeShift == 0.0 ) return; int secsSinceLast = time - lastLookup; output = tr( "%1 seconds").arg(QString::number( timeShift )); // Display information on time server tab if ( ntpTabEnabled ) { ntpTab->setTimeShift( output ); ntpTab->setNewTime( dt.toString() ); } if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) { QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); config.setGroup( grpname ); lookupCount++; predictTab->setShiftPerSec( (int)(timeShift / secsSinceLast) ); config.writeEntry( "secsSinceLast", secsSinceLast ); config.writeEntry( "timeShift", QString::number( timeShift ) ); config.setGroup( "lookups" ); config.writeEntry( "count", lookupCount ); config.writeEntry( "lastNtp", true ); } } void MainWindow::slotNTPDelayChanged( int delay ) { ntpTimer->changeInterval( delay * 1000 * 60 ); ntpDelay = delay; } void MainWindow::slotCheckNtp( int i ) { if ( i == 0 ) { if ( ntpDelayElapsed() ) { runNTP(); disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) ); connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) ); } else { disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) ); connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); } } else { predictTab->slotPredictTime(); if ( i > 0 ) { QString output = tr( "Could not connect to server " ); output.append( settingsTab->ntpServer() ); ntpOutput.append( output ); if ( ntpTabEnabled ) ntpTab->addNtpOutput( output ); } connect( ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); } } diff --git a/noncore/settings/netsystemtime/mainwindow.h b/noncore/settings/netsystemtime/mainwindow.h index 8701803..0ef24e0 100644 --- a/noncore/settings/netsystemtime/mainwindow.h +++ b/noncore/settings/netsystemtime/mainwindow.h @@ -1,98 +1,100 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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. - */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qdialog.h> #include <opie2/oprocess.h> #include <opie2/otabwidget.h> class TimeTabWidget; class FormatTabWidget; class SettingsTabWidget; class NTPTabWidget; class PredictTabWidget; class QDateTime; class QSocket; class QTimer; class MainWindow : public QDialog { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, bool modal = FALSE,WFlags f = 0); ~MainWindow(); static QString appName() { return QString::fromLatin1("systemtime"); } protected: void accept(); void reject(); private: Opie::Ui::OTabWidget *mainWidget; TimeTabWidget *timeTab; FormatTabWidget *formatTab; SettingsTabWidget *settingsTab; NTPTabWidget *ntpTab; PredictTabWidget *predictTab; bool ntpTabEnabled; bool predictTabEnabled; Opie::Core::OProcess *ntpProcess; QTimer *ntpTimer; QSocket *ntpSock; int ntpDelay; bool ntpInteractive; QString ntpOutput; int _lookupDiff; void runNTP(); bool ntpDelayElapsed(); private slots: void slotSetTime( const QDateTime & ); void slotQCopReceive( const QCString &, const QByteArray & ); void slotDisplayNTPTab( bool ); void slotDisplayPredictTab( bool ); void slotGetNTPTime(); void slotTimerGetNTPTime(); void slotProbeNTPServer(); void slotNtpOutput( Opie::Core::OProcess *, char *, int ); void slotNtpFinished( Opie::Core::OProcess* ); void slotNTPDelayChanged( int ); void slotCheckNtp( int ); }; #endif diff --git a/noncore/settings/netsystemtime/ntptabwidget.cpp b/noncore/settings/netsystemtime/ntptabwidget.cpp index 616bc22..16d21cc 100644 --- a/noncore/settings/netsystemtime/ntptabwidget.cpp +++ b/noncore/settings/netsystemtime/ntptabwidget.cpp @@ -1,112 +1,117 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= -_;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: -: = ...= . :.=- You should have received a copy of the GNU --. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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 <qpe/resource.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 ); mleNtpOutput->setFont( font ); mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth ); layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 ); // Set NTP time button - m_ntpBtn = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), + 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/ntptabwidget.h b/noncore/settings/netsystemtime/ntptabwidget.h index f05482e..a7dd02e 100644 --- a/noncore/settings/netsystemtime/ntptabwidget.h +++ b/noncore/settings/netsystemtime/ntptabwidget.h @@ -1,64 +1,66 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= -_;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: -: = ...= . :.=- You should have received a copy of the GNU --. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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. - */ #ifndef NTPTABWIDGET_H #define NTPTABWIDGET_H #include <qwidget.h> class QLabel; class QMultiLineEdit; class QPushButton; class NTPTabWidget : public QWidget { Q_OBJECT public: NTPTabWidget( QWidget * = 0x0 ); ~NTPTabWidget(); void setStartTime( const QString & ); void setTimeShift( const QString & ); void setNewTime( const QString & ); void addNtpOutput( const QString & ); void setNTPBtnEnabled( bool enabled ); private: QLabel *lblStartTime; QLabel *lblTimeShift; QLabel *lblNewTime; QMultiLineEdit *mleNtpOutput; QPushButton *m_ntpBtn; signals: void getNTPTime(); }; #endif diff --git a/noncore/settings/netsystemtime/predicttabwidget.cpp b/noncore/settings/netsystemtime/predicttabwidget.cpp index c706add..98e0afd 100644 --- a/noncore/settings/netsystemtime/predicttabwidget.cpp +++ b/noncore/settings/netsystemtime/predicttabwidget.cpp @@ -1,166 +1,168 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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 ); 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 ); } diff --git a/noncore/settings/netsystemtime/predicttabwidget.h b/noncore/settings/netsystemtime/predicttabwidget.h index da1d8ed..a0f1073 100644 --- a/noncore/settings/netsystemtime/predicttabwidget.h +++ b/noncore/settings/netsystemtime/predicttabwidget.h @@ -1,68 +1,70 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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. - */ #ifndef PREDICTTABWIDGET_H #define PREDICTTABWIDGET_H #include <qdatetime.h> #include <qstring.h> #include <qwidget.h> class QLabel; class QTable; class PredictTabWidget : public QWidget { Q_OBJECT public: PredictTabWidget( QWidget * = 0x0 ); ~PredictTabWidget(); void setShiftPerSec( int ); private: QTable *tblLookups; QLabel *lblDrift; QLabel *lblDiff; QLabel *lblPredicted; float _shiftPerSec; QString tz; QDateTime predictedTime; signals: void setTime( const QDateTime & ); public slots: void slotTZChanged( const QString & ); void slotPredictTime(); void slotSetPredictedTime(); }; #endif diff --git a/noncore/settings/netsystemtime/settingstabwidget.cpp b/noncore/settings/netsystemtime/settingstabwidget.cpp index 9315d2e..3bb0ec3 100644 --- a/noncore/settings/netsystemtime/settingstabwidget.cpp +++ b/noncore/settings/netsystemtime/settingstabwidget.cpp @@ -1,161 +1,163 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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 "settingstabwidget.h" #include <qpe/config.h> #include <qpe/qpeapplication.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qlabel.h> #include <qlayout.h> #include <qscrollview.h> #include <qspinbox.h> SettingsTabWidget::SettingsTabWidget( 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 ); // Time server selector layout->addWidget( new QLabel( tr( "Time server" ), container ), 0, 0 ); cbTimeServer = new QComboBox( TRUE, container ); layout->addMultiCellWidget( cbTimeServer, 1, 1, 0, 1 ); // Lookup delay selector layout->addWidget( new QLabel( tr( "minutes between time updates" ), container ), 2, 1 ); sbNtpDelay = new QSpinBox( 1, 9999999, 1, container ); sbNtpDelay->setWrapping( TRUE ); sbNtpDelay->setMaximumWidth( 50 ); connect( sbNtpDelay, SIGNAL(valueChanged(int)), this, SIGNAL(ntpDelayChanged(int)) ); layout->addWidget( sbNtpDelay, 2, 0 ); // Prediction delay selector layout->addWidget( new QLabel( tr( "minutes between prediction updates" ), container ), 3, 1 ); sbPredictDelay = new QSpinBox( 42, 9999999, 1, container ); sbPredictDelay->setWrapping( TRUE ); sbPredictDelay->setMaximumWidth( 50 ); layout->addWidget( sbPredictDelay, 3, 0 ); // Space filler layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); // Display time server information selector chNtpTab = new QCheckBox( tr( "Display time server information" ), container ); connect( chNtpTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayNTPTab(bool) ) ); layout->addMultiCellWidget( chNtpTab, 5, 5, 0, 1 ); // Display time prediction information selector chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container ); connect( chPredictTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayPredictTab(bool) ) ); layout->addMultiCellWidget( chPredictTab, 6, 6, 0, 1 ); // Space filler layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); // Initialize values QString ntpSrvsFile = QPEApplication::qpeDir(); ntpSrvsFile.append( "etc/ntpservers" ); Config ntpSrvs( ntpSrvsFile, Config::File ); ntpSrvs.setGroup( "servers" ); int srvCount = ntpSrvs.readNumEntry( "count", 0 ); for ( int i = 0; i < srvCount; i++ ) { ntpSrvs.setGroup( QString::number( i ) ); cbTimeServer->insertItem( ntpSrvs.readEntry( "name" ) ); } if ( srvCount==0 ) { cbTimeServer->insertItem( "time.fu-berlin.de" ); cbTimeServer->insertItem( "time-a.nist.gov" ); cbTimeServer->insertItem( "ntp.bri.connect.com.au" ); } Config config( "ntp" ); config.setGroup( "settings" ); sbPredictDelay->setValue( config.readNumEntry( "minLookupDiff", 720 ) ); sbNtpDelay->setValue( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) ); chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) ); chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) ); } SettingsTabWidget::~SettingsTabWidget() { } void SettingsTabWidget::saveSettings() { int srvCount = cbTimeServer->count(); bool serversChanged = TRUE; int curSrv = cbTimeServer->currentItem(); QString edit = cbTimeServer->currentText(); for ( int i = 0; i < srvCount; i++ ) { if ( edit == cbTimeServer->text( i ) ) serversChanged = FALSE; } if ( serversChanged ) { QString ntpSrvsFile = QPEApplication::qpeDir(); ntpSrvsFile.append( "etc/ntpservers" ); Config ntpSrvs( ntpSrvsFile, Config::File ); ntpSrvs.setGroup( "servers" ); ntpSrvs.writeEntry( "count", ++srvCount ); ntpSrvs.setGroup( "0" ); ntpSrvs.writeEntry( "name", edit ); curSrv = 0; for ( int i = 1; i < srvCount; i++ ) { // odebug << "ntpSrvs[" << i << "/" << srvCount << "]=" << cbTimeServer->text( i ).latin1() << "" << oendl; ntpSrvs.setGroup( QString::number( i ) ); ntpSrvs.writeEntry( "name", cbTimeServer->text( i-1 ) ); } } Config config( "ntp", Config::User ); config.setGroup( "settings" ); config.writeEntry( "ntpServer", curSrv ); config.writeEntry( "minLookupDiff", sbPredictDelay->value() ); config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() ); config.writeEntry( "displayNtpTab", chNtpTab->isChecked() ); config.writeEntry( "displayPredictTab", chPredictTab->isChecked() ); } QString SettingsTabWidget::ntpServer() { return cbTimeServer->currentText(); } diff --git a/noncore/settings/netsystemtime/settingstabwidget.h b/noncore/settings/netsystemtime/settingstabwidget.h index 2901bb3..9578245 100644 --- a/noncore/settings/netsystemtime/settingstabwidget.h +++ b/noncore/settings/netsystemtime/settingstabwidget.h @@ -1,62 +1,64 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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. - */ #ifndef SETTINGSTABWIDGET_H #define SETTINGSTABWIDGET_H #include <qwidget.h> class QCheckBox; class QComboBox; class QSpinBox; class SettingsTabWidget : public QWidget { Q_OBJECT public: SettingsTabWidget( QWidget * = 0x0 ); ~SettingsTabWidget(); void saveSettings(); QString ntpServer(); private: QComboBox *cbTimeServer; QSpinBox *sbNtpDelay; QSpinBox *sbPredictDelay; QCheckBox *chNtpTab; QCheckBox *chPredictTab; signals: void ntpDelayChanged( int ); void displayNTPTab( bool ); void displayPredictTab( bool ); }; #endif diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp index 905461f..bcfbdf7 100644 --- a/noncore/settings/netsystemtime/timetabwidget.cpp +++ b/noncore/settings/netsystemtime/timetabwidget.cpp @@ -1,303 +1,309 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= -_;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: -: = ...= . :.=- You should have received a copy of the GNU --. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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 "timetabwidget.h" +#include <opie2/oresource.h> + +#include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/datebookmonth.h> #include <qpe/global.h> -#include <qpe/resource.h> #include <qpe/tzselect.h> #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qcombobox.h> #include <qdatetime.h> #include <qframe.h> #include <qlabel.h> #include <qlayout.h> #include <qpushbutton.h> #include <qscrollview.h> #include <qspinbox.h> #include <stdlib.h> #include <sys/time.h> static const int ValueAM = 0; static const int ValuePM = 1; TimeTabWidget::TimeTabWidget( QWidget *parent ) : QWidget( parent, 0x0, 0 ) { // Synchronize HW clock to systemtime // This app will update systemtime // - if Cancel is clicked, will reset systemtime to HW clock's time // - if Ok is clicked, will leave systemtime as is system("/sbin/hwclock --systohc --utc"); 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 ); // Hours layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 ); sbHour = new QSpinBox( container ); sbHour->setWrapping( TRUE ); layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 ); // Minutes layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 ); sbMin = new QSpinBox( container ); sbMin->setWrapping( TRUE ); sbMin->setMinValue( 0 ); sbMin->setMaxValue( 59 ); layout->addMultiCellWidget( sbMin, 2, 2, 2, 3 ); // AM/PM cbAmpm = new QComboBox( container ); cbAmpm->insertItem( tr( "AM" ), ValueAM ); cbAmpm->insertItem( tr( "PM" ), ValuePM ); layout->addMultiCellWidget( cbAmpm, 2, 2, 4, 5 ); // Date layout->addWidget( new QLabel( tr( "Date" ), container ), 4, 0 ); btnDate = new DateButton( TRUE, container ); layout->addMultiCellWidget( btnDate, 4, 4, 1, 5 ); // Timezone layout->addMultiCellWidget( new QLabel( tr( "Time zone" ), container ), 6, 6, 0, 1 ); selTimeZone = new TimeZoneSelector( container ); connect( selTimeZone, SIGNAL(signalNewTz(const QString&)), this, SLOT(slotTZChanged(const QString&)) ); layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 ); // Space filler layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); // Set NTP time button - m_ntpBtn = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), + 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, 8, 8, 0, 5 ); // Set predicted time button - QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ), - container ); + QPushButton *pb = new QPushButton( Opie::Core::OResource::loadPixmap( "netsystemtime/predicttab", Opie::Core::OResource::SmallIcon ), + tr( "Set predicted time" ), container ); + pb->setMinimumHeight( AppLnk::smallIconSize()+4 ); connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) ); layout->addMultiCellWidget( pb, 9, 9, 0, 5 ); // Space filler at bottom of widget layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 ); // Initialize values Config config( "locale" ); config.setGroup( "Location" ); selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) ); use12HourTime = FALSE; setDateTime( QDateTime::currentDateTime() ); } TimeTabWidget::~TimeTabWidget() { } void TimeTabWidget::saveSettings( bool commit ) { if ( commit ) { // Set timezone and announce to world QString tz = selTimeZone->currentZone(); Config config("locale"); config.setGroup( "Location" ); config.writeEntry( "Timezone", tz ); setenv( "TZ", tz, 1 ); QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); setTimeZone << tz; // If controls have a valid date & time, update systemtime int hour = sbHour->value(); if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) hour += 12; QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); setSystemTime( dt ); } else { // Reset systemtime to hardware clock (i.e. undo any changes made by this app) system("/sbin/hwclock --hctosys --utc"); } } void TimeTabWidget::setDateTime( const QDateTime &dt ) { // Set time QTime t = dt.time(); if( use12HourTime ) { int show_hour = t.hour(); if ( t.hour() >= 12 ) { show_hour -= 12; cbAmpm->setCurrentItem( ValuePM ); } else { cbAmpm->setCurrentItem( ValueAM ); } if ( show_hour == 0 ) show_hour = 12; sbHour->setValue( show_hour ); } else { sbHour->setValue( t.hour() ); } sbMin->setValue( t.minute() ); // Set date btnDate->setDate( dt.date() ); } void TimeTabWidget::setNTPBtnEnabled( bool enabled ) { m_ntpBtn->setEnabled( enabled ); } void TimeTabWidget::setSystemTime( const QDateTime &dt ) { // Set system clock if ( dt.isValid() ) { struct timeval myTv; int t = TimeConversion::toUTC( dt ); myTv.tv_sec = t; myTv.tv_usec = 0; if ( myTv.tv_sec != -1 ) ::settimeofday( &myTv, 0 ); /* * Commit the datetime to the 'hardware' * as Global::writeHWClock() is a NOOP with Opie Alarm */ system("/sbin/hwclock --systohc --utc"); } } void TimeTabWidget::slotUse12HourTime( int i ) { use12HourTime = (i == 1); cbAmpm->setEnabled( use12HourTime ); int show_hour = sbHour->value(); if ( use12HourTime ) { sbHour->setMinValue( 1 ); sbHour->setMaxValue( 12 ); if ( show_hour >= 12 ) { show_hour -= 12; cbAmpm->setCurrentItem( ValuePM ); } else { cbAmpm->setCurrentItem( ValueAM ); } if ( show_hour == 0 ) show_hour = 12; } else { sbHour->setMinValue( 0 ); sbHour->setMaxValue( 23 ); if ( cbAmpm->currentItem() == ValuePM ) { show_hour += 12; if ( show_hour == 24 ) show_hour = 0; } } sbHour->setValue( show_hour ); } void TimeTabWidget::slotDateFormatChanged( const DateFormat &df ) { btnDate->setDateFormat( df ); } void TimeTabWidget::slotWeekStartChanged( int monday ) { btnDate->setWeekStartsMonday( monday ); } void TimeTabWidget::slotTZChanged( const QString &newtz ) { // If controls have a valid date & time, update systemtime int hour = sbHour->value(); if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) hour += 12; QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); setSystemTime( dt ); QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); setTimeZone << newtz; // Set system timezone QString currtz = getenv( "TZ" ); setenv( "TZ", newtz, 1 ); // Get new date/time hour = sbHour->value(); if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) hour += 12; dt = QDateTime::currentDateTime(); // Reset system timezone if ( !currtz.isNull() ) { setenv( "TZ", currtz, 1 ); } // Set controls to new time setDateTime( dt ); emit tzChanged( newtz ); } diff --git a/noncore/settings/netsystemtime/timetabwidget.h b/noncore/settings/netsystemtime/timetabwidget.h index 949535d..4674c5c8 100644 --- a/noncore/settings/netsystemtime/timetabwidget.h +++ b/noncore/settings/netsystemtime/timetabwidget.h @@ -1,80 +1,82 @@ /* - This file is part of the OPIE Project + Â Â Â Â Â Â Â Â This file is part of the Opie Project + + Copyright (C) Opie Team <opie-devel@handhelds.org> =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= -_;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU 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 file 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 General -..}^=.= = ; Public License for more details. -++= -. .` .: -: = ...= . :.=- You should have received a copy of the GNU --. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., - 59 Temple Place - Suite 330, + .=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. - */ #ifndef TIMETABWIDGET_H #define TIMETABWIDGET_H #include <qwidget.h> class DateButton; class DateFormat; class QComboBox; class QDateTime; class QPushButton; class QSpinBox; class TimeZoneSelector; class TimeTabWidget : public QWidget { Q_OBJECT public: TimeTabWidget( QWidget * = 0l ); ~TimeTabWidget(); void saveSettings( bool ); void setDateTime( const QDateTime & ); void setNTPBtnEnabled( bool enabled ); private: QSpinBox *sbHour; QSpinBox *sbMin; QComboBox *cbAmpm; DateButton *btnDate; TimeZoneSelector *selTimeZone; QPushButton *m_ntpBtn; bool use12HourTime; void setSystemTime( const QDateTime & ); signals: void tzChanged( const QString & ); void getNTPTime(); void getPredictedTime(); public slots: void slotUse12HourTime( int ); void slotDateFormatChanged( const DateFormat & ); void slotWeekStartChanged( int ); private slots: void slotTZChanged( const QString & ); }; #endif |