summaryrefslogtreecommitdiff
path: root/library/tzselect.cpp
authorzecke <zecke>2002-09-10 12:09:49 (UTC)
committer zecke <zecke>2002-09-10 12:09:49 (UTC)
commit6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff)
tree6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/tzselect.cpp
parentd10cddb3c9ce75bc90b14add14bc133737fe35aa (diff)
downloadopie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2
Qtopia1-6 merge
still to test bic changes to be resolved more changes to be made?
Diffstat (limited to 'library/tzselect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/tzselect.cpp104
1 files changed, 75 insertions, 29 deletions
diff --git a/library/tzselect.cpp b/library/tzselect.cpp
index 5f102d5..6cc0bea 100644
--- a/library/tzselect.cpp
+++ b/library/tzselect.cpp
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -20,2 +20,4 @@
20 20
21#define QTOPIA_INTERNAL_TZSELECT_INC_LOCAL
22
21#include "tzselect.h" 23#include "tzselect.h"
@@ -32,2 +34,9 @@
32 34
35class TimeZoneSelectorPrivate
36{
37public:
38 TimeZoneSelectorPrivate() : includeLocal(FALSE) {}
39 bool includeLocal;
40};
41
33TZCombo::TZCombo( QWidget *p, const char* n ) 42TZCombo::TZCombo( QWidget *p, const char* n )
@@ -38,2 +47,8 @@ TZCombo::TZCombo( QWidget *p, const char* n )
38 QString tz = getenv("TZ"); 47 QString tz = getenv("TZ");
48 if (parent()->inherits("TimeZoneSelector")) {
49 if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
50 // overide to the 'local' type.
51 tz = "None";
52 }
53 }
39 if ( !tz.isNull() ) { 54 if ( !tz.isNull() ) {
@@ -41,3 +56,3 @@ TZCombo::TZCombo( QWidget *p, const char* n )
41 index = 0; 56 index = 0;
42 for ( QStringList::Iterator it=identifiers.begin(); 57 for ( QStringList::Iterator it=identifiers.begin();
43 it!=identifiers.end(); ++it) { 58 it!=identifiers.end(); ++it) {
@@ -78,7 +93,18 @@ void TZCombo::updateZones()
78 bool tzFound = FALSE; 93 bool tzFound = FALSE;
79 Config cfg("CityTime"); 94 Config cfg("WorldTime");
80 cfg.setGroup("TimeZones"); 95 cfg.setGroup("TimeZones");
81 int i=0; 96 int listIndex = 0;
82 for ( ; 1; i++ ) { 97 if (parent()->inherits("TimeZoneSelector")) {
83 QString zn = cfg.readEntry("Zone"+QString::number(i), QString::null); 98 if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
99 // overide to the 'local' type.
100 identifiers.append( "None" );
101 insertItem( tr("None") );
102 if ( cur == tr("None"))
103 curix = 0;
104 listIndex++;
105 }
106 }
107 int cfgIndex = 0;
108 while (1) {
109 QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null);
84 if ( zn.isNull() ) 110 if ( zn.isNull() )
@@ -87,3 +113,3 @@ void TZCombo::updateZones()
87 tzFound = TRUE; 113 tzFound = TRUE;
88 QString nm = cfg.readEntry("ZoneName"+QString::number(i)); 114 QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex));
89 identifiers.append(zn); 115 identifiers.append(zn);
@@ -91,12 +117,19 @@ void TZCombo::updateZones()
91 if ( nm == cur ) 117 if ( nm == cur )
92 curix = i; 118 curix = listIndex;
119 ++cfgIndex;
120 ++listIndex;
93 } 121 }
94 if ( !tzFound && !tz.isEmpty()) { 122 if ( !listIndex ) {
95 int i = tz.find( '/' ); 123 QStringList list = timezoneDefaults();
96 QString nm = tz.mid( i+1 ); 124 for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) {
97 identifiers.append(tz); 125 QString zn = *it;
98 insertItem(nm); 126 QString nm = *++it;
99 if ( nm == cur ) 127 if ( zn == tz )
100 curix = i; 128 tzFound = TRUE;
101 ++i; 129 if ( nm == cur )
130 curix = listIndex;
131 identifiers.append(zn);
132 insertItem(nm);
133 ++listIndex;
134 }
102 } 135 }
@@ -106,11 +139,13 @@ void TZCombo::updateZones()
106 if ( *it == cur ) 139 if ( *it == cur )
107 curix = i; 140 curix = listIndex;
108 ++i; 141 ++listIndex;
109 } 142 }
110 if ( !i ) { 143 if ( !tzFound && !tz.isEmpty()) {
111 QStringList list = timezoneDefaults(); 144 int i = tz.find( '/' );
112 for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) { 145 QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " ");
113 identifiers.append(*it); ++it; 146 identifiers.append(tz);
114 insertItem(*it); 147 insertItem(nm);
115 } 148 if ( nm == cur )
149 curix = listIndex;
150 ++listIndex;
116 } 151 }
@@ -166,2 +201,3 @@ TimeZoneSelector::TimeZoneSelector(QWidget* p, const char* n) :
166{ 201{
202 d = new TimeZoneSelectorPrivate();
167 // build the combobox before we do any updates... 203 // build the combobox before we do any updates...
@@ -170,4 +206,3 @@ TimeZoneSelector::TimeZoneSelector(QWidget* p, const char* n) :
170 cmdTz = new QToolButton( this, "timezone button" ); 206 cmdTz = new QToolButton( this, "timezone button" );
171 QPixmap pixGlobe = Resource::loadPixmap( "citytime_icon" ); 207 cmdTz->setIconSet( Resource::loadIconSet( "citytime_icon" ) );
172 cmdTz->setPixmap( pixGlobe );
173 cmdTz->setMaximumSize( cmdTz->sizeHint() ); 208 cmdTz->setMaximumSize( cmdTz->sizeHint() );
@@ -186,2 +221,13 @@ TimeZoneSelector::~TimeZoneSelector()
186 221
222void TimeZoneSelector::setLocalIncluded(bool b)
223{
224 d->includeLocal = b;
225 cmbTz->updateZones();
226}
227
228bool TimeZoneSelector::localIncluded() const
229{
230 return d->includeLocal;
231}
232
187 233
@@ -204,4 +250,4 @@ void TimeZoneSelector::slotExecute( void )
204{ 250{
205 // execute the city time application... 251 // execute the world time application...
206 Global::execute( "citytime" ); 252 Global::execute( "worldtime" );
207} 253}