summaryrefslogtreecommitdiff
path: root/library/tzselect.cpp
Side-by-side diff
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 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
@@ -20,2 +20,4 @@
+#define QTOPIA_INTERNAL_TZSELECT_INC_LOCAL
+
#include "tzselect.h"
@@ -32,2 +34,9 @@
+class TimeZoneSelectorPrivate
+{
+public:
+ TimeZoneSelectorPrivate() : includeLocal(FALSE) {}
+ bool includeLocal;
+};
+
TZCombo::TZCombo( QWidget *p, const char* n )
@@ -38,2 +47,8 @@ TZCombo::TZCombo( QWidget *p, const char* n )
QString tz = getenv("TZ");
+ if (parent()->inherits("TimeZoneSelector")) {
+ if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
+ // overide to the 'local' type.
+ tz = "None";
+ }
+ }
if ( !tz.isNull() ) {
@@ -41,3 +56,3 @@ TZCombo::TZCombo( QWidget *p, const char* n )
index = 0;
- for ( QStringList::Iterator it=identifiers.begin();
+ for ( QStringList::Iterator it=identifiers.begin();
it!=identifiers.end(); ++it) {
@@ -78,7 +93,18 @@ void TZCombo::updateZones()
bool tzFound = FALSE;
- Config cfg("CityTime");
+ Config cfg("WorldTime");
cfg.setGroup("TimeZones");
- int i=0;
- for ( ; 1; i++ ) {
- QString zn = cfg.readEntry("Zone"+QString::number(i), QString::null);
+ int listIndex = 0;
+ if (parent()->inherits("TimeZoneSelector")) {
+ if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
+ // overide to the 'local' type.
+ identifiers.append( "None" );
+ insertItem( tr("None") );
+ if ( cur == tr("None"))
+ curix = 0;
+ listIndex++;
+ }
+ }
+ int cfgIndex = 0;
+ while (1) {
+ QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null);
if ( zn.isNull() )
@@ -87,3 +113,3 @@ void TZCombo::updateZones()
tzFound = TRUE;
- QString nm = cfg.readEntry("ZoneName"+QString::number(i));
+ QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex));
identifiers.append(zn);
@@ -91,12 +117,19 @@ void TZCombo::updateZones()
if ( nm == cur )
- curix = i;
+ curix = listIndex;
+ ++cfgIndex;
+ ++listIndex;
}
- if ( !tzFound && !tz.isEmpty()) {
- int i = tz.find( '/' );
- QString nm = tz.mid( i+1 );
- identifiers.append(tz);
- insertItem(nm);
- if ( nm == cur )
- curix = i;
- ++i;
+ if ( !listIndex ) {
+ QStringList list = timezoneDefaults();
+ for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) {
+ QString zn = *it;
+ QString nm = *++it;
+ if ( zn == tz )
+ tzFound = TRUE;
+ if ( nm == cur )
+ curix = listIndex;
+ identifiers.append(zn);
+ insertItem(nm);
+ ++listIndex;
+ }
}
@@ -106,11 +139,13 @@ void TZCombo::updateZones()
if ( *it == cur )
- curix = i;
- ++i;
+ curix = listIndex;
+ ++listIndex;
}
- if ( !i ) {
- QStringList list = timezoneDefaults();
- for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) {
- identifiers.append(*it); ++it;
- insertItem(*it);
- }
+ if ( !tzFound && !tz.isEmpty()) {
+ int i = tz.find( '/' );
+ QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " ");
+ identifiers.append(tz);
+ insertItem(nm);
+ if ( nm == cur )
+ curix = listIndex;
+ ++listIndex;
}
@@ -166,2 +201,3 @@ TimeZoneSelector::TimeZoneSelector(QWidget* p, const char* n) :
{
+ d = new TimeZoneSelectorPrivate();
// build the combobox before we do any updates...
@@ -170,4 +206,3 @@ TimeZoneSelector::TimeZoneSelector(QWidget* p, const char* n) :
cmdTz = new QToolButton( this, "timezone button" );
- QPixmap pixGlobe = Resource::loadPixmap( "citytime_icon" );
- cmdTz->setPixmap( pixGlobe );
+ cmdTz->setIconSet( Resource::loadIconSet( "citytime_icon" ) );
cmdTz->setMaximumSize( cmdTz->sizeHint() );
@@ -186,2 +221,13 @@ TimeZoneSelector::~TimeZoneSelector()
+void TimeZoneSelector::setLocalIncluded(bool b)
+{
+ d->includeLocal = b;
+ cmbTz->updateZones();
+}
+
+bool TimeZoneSelector::localIncluded() const
+{
+ return d->includeLocal;
+}
+
@@ -204,4 +250,4 @@ void TimeZoneSelector::slotExecute( void )
{
- // execute the city time application...
- Global::execute( "citytime" );
+ // execute the world time application...
+ Global::execute( "worldtime" );
}