summaryrefslogtreecommitdiff
path: root/core/settings/citytime/citytime.cpp
Unidiff
Diffstat (limited to 'core/settings/citytime/citytime.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/settings/citytime/citytime.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/settings/citytime/citytime.cpp b/core/settings/citytime/citytime.cpp
index b2f9f14..f33b19f 100644
--- a/core/settings/citytime/citytime.cpp
+++ b/core/settings/citytime/citytime.cpp
@@ -9,43 +9,45 @@
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
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// changes by Maximilian Reiss <harlekin@handhelds.org>
22
21#include "zonemap.h" 23#include "zonemap.h"
22#include "citytime.h" 24#include "citytime.h"
23 25
24#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
25#include <qpe/config.h> 27#include <qpe/config.h>
26#include <qpe/timestring.h> 28#include <qpe/timestring.h>
27#include <qpe/tzselect.h> 29#include <qpe/tzselect.h>
28#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 30#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
29#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
30#endif 32#endif
31 33
32
33#include <qdir.h> 34#include <qdir.h>
34#include <qfile.h> 35#include <qfile.h>
35#include <qlabel.h> 36#include <qlabel.h>
36#include <qmessagebox.h> 37#include <qmessagebox.h>
37#include <qregexp.h> 38#include <qregexp.h>
38#include <qtextstream.h> 39#include <qtextstream.h>
39#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qlayout.h>
40 42
41#include <stdlib.h> 43#include <stdlib.h>
42 44
43CityTime::CityTime( QWidget *parent, const char* name, 45CityTime::CityTime( QWidget *parent, const char* name,
44 WFlags fl ) 46 WFlags fl )
45 : CityTimeBase( parent, name, fl ), 47 : CityTimeBase( parent, name, fl ),
46 strRealTz(0), 48 strRealTz(0),
47 bAdded(false) 49 bAdded(false)
48{ 50{
49 Config config( "qpe" ); 51 Config config( "qpe" );
50 bWhichClock = config.readBoolEntry( "AMPM", TRUE ); 52 bWhichClock = config.readBoolEntry( "AMPM", TRUE );
51 frmMap->changeClock( bWhichClock ); 53 frmMap->changeClock( bWhichClock );
@@ -68,25 +70,24 @@ CityTime::CityTime( QWidget *parent, const char* name,
68 listCities.append( cmdCity3 ); 70 listCities.append( cmdCity3 );
69 71
70 listTimes.append( lblCTime1 ); 72 listTimes.append( lblCTime1 );
71 listTimes.append( lblCTime2 ); 73 listTimes.append( lblCTime2 );
72 listTimes.append( lblCTime3 ); 74 listTimes.append( lblCTime3 );
73 75
74 76
75 // kludgy way of getting the screen size so we don't have to depend 77 // kludgy way of getting the screen size so we don't have to depend
76 // on a resize event... 78 // on a resize event...
77 QWidget *d = QApplication::desktop(); 79 QWidget *d = QApplication::desktop();
78 if ( d->width() < d->height() ) { 80 if ( d->width() < d->height() ) {
79 // append for that 4 down look 81 // append for that 4 down look
80
81 listCities.append( cmdCity4 ); 82 listCities.append( cmdCity4 );
82 listCities.append( cmdCity5 ); 83 listCities.append( cmdCity5 );
83 listCities.append( cmdCity6 ); 84 listCities.append( cmdCity6 );
84 listTimes.append( lblCTime4 ); 85 listTimes.append( lblCTime4 );
85 listTimes.append( lblCTime5 ); 86 listTimes.append( lblCTime5 );
86 listTimes.append( lblCTime6 ); 87 listTimes.append( lblCTime6 );
87 lblCTime7->hide(); 88 lblCTime7->hide();
88 lblCTime8->hide(); 89 lblCTime8->hide();
89 lblCTime9->hide(); 90 lblCTime9->hide();
90 cmdCity7->hide(); 91 cmdCity7->hide();
91 cmdCity8->hide(); 92 cmdCity8->hide();
92 cmdCity9->hide(); 93 cmdCity9->hide();
@@ -95,24 +96,28 @@ CityTime::CityTime( QWidget *parent, const char* name,
95 listCities.append( cmdCity8 ); 96 listCities.append( cmdCity8 );
96 listCities.append( cmdCity9 ); 97 listCities.append( cmdCity9 );
97 listTimes.append( lblCTime7 ); 98 listTimes.append( lblCTime7 );
98 listTimes.append( lblCTime8 ); 99 listTimes.append( lblCTime8 );
99 listTimes.append( lblCTime9 ); 100 listTimes.append( lblCTime9 );
100 lblCTime4->hide(); 101 lblCTime4->hide();
101 lblCTime5->hide(); 102 lblCTime5->hide();
102 lblCTime6->hide(); 103 lblCTime6->hide();
103 cmdCity4->hide(); 104 cmdCity4->hide();
104 cmdCity5->hide(); 105 cmdCity5->hide();
105 cmdCity6->hide(); 106 cmdCity6->hide();
106 } 107 }
108
109 selWidget = frmMap->selectionWidget( this );
110 selWidget->hide();
111 CityTimeBaseLayout->addWidget( selWidget );
107 bAdded = true; 112 bAdded = true;
108 readInTimes(); 113 readInTimes();
109 changed = FALSE; 114 changed = FALSE;
110 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), 115 QObject::connect( qApp, SIGNAL( clockChanged(bool) ),
111 this, SLOT( changeClock(bool) ) ); 116 this, SLOT( changeClock(bool) ) );
112 // now start the timer so we can update the time quickly every second 117 // now start the timer so we can update the time quickly every second
113 timerEvent( 0 ); 118 timerEvent( 0 );
114} 119}
115 120
116CityTime::~CityTime() 121CityTime::~CityTime()
117{ 122{
118 if ( changed ) { 123 if ( changed ) {
@@ -190,48 +195,53 @@ void CityTime::showTime( void )
190 unsetenv( "TZ" ); 195 unsetenv( "TZ" );
191 if ( !strRealTz.isNull() ) { 196 if ( !strRealTz.isNull() ) {
192 if ( setenv( "TZ", strRealTz, true ) != 0 ) { 197 if ( setenv( "TZ", strRealTz, true ) != 0 ) {
193 QMessageBox::critical( this, tr( "Restore Time Zone" ), 198 QMessageBox::critical( this, tr( "Restore Time Zone" ),
194 tr( "There was a problem setting your timezone." 199 tr( "There was a problem setting your timezone."
195 "Your time may be wrong now..." ) ); 200 "Your time may be wrong now..." ) );
196 } 201 }
197 } 202 }
198} 203}
199 204
200void CityTime::beginNewTz() 205void CityTime::beginNewTz()
201{ 206{
207 buttonWidget->hide();
202 frmMap->setFocus(); 208 frmMap->setFocus();
209 selWidget->show();
210 // CityTimeBaseLayout->addWidget( selWidget );
203} 211}
204 212
205void CityTime::slotNewTz( const QString & strNewCountry, 213void CityTime::slotNewTz( const QString & strNewCountry,
206 const QString & strNewCity ) 214 const QString & strNewCity )
207{ 215{
208 // determine what to do based on what putton is pressed... 216 // determine what to do based on what putton is pressed...
209 QListIterator<QToolButton> itCity(listCities); 217 QListIterator<QToolButton> itCity(listCities);
210 int i; 218 int i;
211 // go through the list and make adjustments based on which button is on 219 // go through the list and make adjustments based on which button is on
212 for ( i = 0, itCity.toFirst(); itCity.current(), i < CITIES; i++, ++itCity ) { 220 for ( i = 0, itCity.toFirst(); itCity.current(), i < CITIES; i++, ++itCity ) {
213 QToolButton *cmdTmp = itCity.current(); 221 QToolButton *cmdTmp = itCity.current();
214 if ( cmdTmp->isOn() ) { 222 if ( cmdTmp->isOn() ) {
215 strCityTz[i] = strNewCountry + strNewCity; 223 strCityTz[i] = strNewCountry + strNewCity;
216 QString s = strNewCity; 224 QString s = strNewCity;
217 cmdTmp->setText( s.replace( QRegExp("_"), " " ) ); 225 cmdTmp->setText( s.replace( QRegExp("_"), " " ) );
218 cmdTmp->toggle(); 226 cmdTmp->toggle();
219 // we can actually break, since there is only one button 227 // we can actually break, since there is only one button
220 // that is ever pressed! 228 // that is ever pressed!
221 changed = TRUE; 229 changed = TRUE;
222 break; 230 break;
223 } 231 }
224 } 232 }
225 showTime(); 233 showTime();
234 buttonWidget->show();
235 selWidget->hide();
226} 236}
227 237
228void CityTime::readInTimes( void ) 238void CityTime::readInTimes( void )
229{ 239{
230 Config cfg("CityTime"); 240 Config cfg("CityTime");
231 cfg.setGroup("TimeZones"); 241 cfg.setGroup("TimeZones");
232 QListIterator<QToolButton> itCity( listCities ); 242 QListIterator<QToolButton> itCity( listCities );
233 int i=0; 243 int i=0;
234 nameRealTz = QString::null; 244 nameRealTz = QString::null;
235 QString zn; 245 QString zn;
236 for ( ; i < CITIES ; i++ ) { 246 for ( ; i < CITIES ; i++ ) {
237 zn = cfg.readEntry("Zone"+QString::number(i), QString::null); 247 zn = cfg.readEntry("Zone"+QString::number(i), QString::null);