summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-22 18:24:12 (UTC)
committer llornkcor <llornkcor>2002-09-22 18:24:12 (UTC)
commitf8aeb3c2e6b32600329ebbaeb0b4b7a2f371eca2 (patch) (side-by-side diff)
tree216d939631c0ebd8319c6e9564d5d4a69a1b06d2
parent7d8e7e3dba1a42864560c4b493e3f35f6bcb9660 (diff)
downloadopie-f8aeb3c2e6b32600329ebbaeb0b4b7a2f371eca2.zip
opie-f8aeb3c2e6b32600329ebbaeb0b4b7a2f371eca2.tar.gz
opie-f8aeb3c2e6b32600329ebbaeb0b4b7a2f371eca2.tar.bz2
opie uses citytime, not worldtime, and changed tz to more opie specific
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/tzselect.cpp125
1 files changed, 63 insertions, 62 deletions
diff --git a/library/tzselect.cpp b/library/tzselect.cpp
index 6cc0bea..e16b8d4 100644
--- a/library/tzselect.cpp
+++ b/library/tzselect.cpp
@@ -25,194 +25,194 @@
#include "global.h"
#include "config.h"
#include <qtoolbutton.h>
#include <qfile.h>
#include <stdlib.h>
#ifdef Q_WS_QWS
#include <qcopchannel_qws.h>
#endif
class TimeZoneSelectorPrivate
{
public:
TimeZoneSelectorPrivate() : includeLocal(FALSE) {}
bool includeLocal;
};
TZCombo::TZCombo( QWidget *p, const char* n )
: QComboBox( p, n )
{
updateZones();
// check to see if TZ is set, if it is set the current item to that
QString tz = getenv("TZ");
if (parent()->inherits("TimeZoneSelector")) {
- if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
- // overide to the 'local' type.
- tz = "None";
- }
+ if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
+ // overide to the 'local' type.
+ tz = "None";
+ }
}
if ( !tz.isNull() ) {
- int n = 0,
+ int n = 0,
index = 0;
for ( QStringList::Iterator it=identifiers.begin();
- it!=identifiers.end(); ++it) {
- if ( *it == tz )
- index = n;
- n++;
- }
- setCurrentItem(index);
+ it!=identifiers.end(); ++it) {
+ if ( *it == tz )
+ index = n;
+ n++;
+ }
+ setCurrentItem(index);
} else {
- setCurrentItem(0);
+ setCurrentItem(0);
}
// listen on QPE/System
#if defined(Q_WS_QWS)
#if !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/System", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(handleSystemChannel(const QCString&, const QByteArray&)) );
+ this, SLOT(handleSystemChannel(const QCString&, const QByteArray&)) );
#endif
#endif
}
TZCombo::~TZCombo()
{
}
void TZCombo::updateZones()
{
QString cur = currentText();
clear();
identifiers.clear();
int curix=0;
QString tz = getenv("TZ");
bool tzFound = FALSE;
Config cfg("WorldTime");
cfg.setGroup("TimeZones");
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++;
- }
+ 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() )
- break;
- if ( zn == tz )
- tzFound = TRUE;
- QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex));
- identifiers.append(zn);
- insertItem(nm);
- if ( nm == cur )
- curix = listIndex;
- ++cfgIndex;
- ++listIndex;
+ QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null);
+ if ( zn.isNull() )
+ break;
+ if ( zn == tz )
+ tzFound = TRUE;
+ QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex));
+ identifiers.append(zn);
+ insertItem(nm);
+ if ( nm == cur )
+ curix = listIndex;
+ ++cfgIndex;
+ ++listIndex;
}
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;
+ QString zn = *it;
+ QString nm = *++it;
+ if ( zn == tz )
+ tzFound = TRUE;
+ if ( nm == cur )
+ curix = listIndex;
identifiers.append(zn);
insertItem(nm);
- ++listIndex;
+ ++listIndex;
}
}
for (QStringList::Iterator it=extras.begin(); it!=extras.end(); ++it) {
- insertItem(*it);
- identifiers.append(*it);
- if ( *it == cur )
- curix = listIndex;
- ++listIndex;
+ insertItem(*it);
+ identifiers.append(*it);
+ if ( *it == cur )
+ curix = listIndex;
+ ++listIndex;
}
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;
+ int i = tz.find( '/' );
+ QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " ");
+ identifiers.append(tz);
+ insertItem(nm);
+ if ( nm == cur )
+ curix = listIndex;
+ ++listIndex;
}
setCurrentItem(curix);
}
void TZCombo::keyPressEvent( QKeyEvent *e )
{
// ### should popup() in Qt 3.0 (it's virtual there)
// updateZones();
QComboBox::keyPressEvent(e);
}
void TZCombo::mousePressEvent(QMouseEvent*e)
{
// ### should popup() in Qt 3.0 (it's virtual there)
// updateZones();
QComboBox::mousePressEvent(e);
}
QString TZCombo::currZone() const
{
return identifiers[currentItem()];
}
void TZCombo::setCurrZone( const QString& id )
{
for (int i=0; i< count(); i++) {
- if ( identifiers[i] == id ) {
- setCurrentItem(i);
- return;
- }
+ if ( identifiers[i] == id ) {
+ setCurrentItem(i);
+ return;
+}
}
insertItem(id);
setCurrentItem( count() - 1);
identifiers.append(id);
extras.append(id);
}
void TZCombo::handleSystemChannel(const QCString&msg, const QByteArray&)
{
if ( msg == "timeZoneListChange()" ) {
- updateZones();
+ updateZones();
}
}
TimeZoneSelector::TimeZoneSelector(QWidget* p, const char* n) :
QHBox(p,n)
{
d = new TimeZoneSelectorPrivate();
// build the combobox before we do any updates...
cmbTz = new TZCombo( this, "timezone combo" );
cmdTz = new QToolButton( this, "timezone button" );
cmdTz->setIconSet( Resource::loadIconSet( "citytime_icon" ) );
cmdTz->setMaximumSize( cmdTz->sizeHint() );
// set up a connection to catch a newly selected item and throw our
// signal
QObject::connect( cmbTz, SIGNAL( activated( int ) ),
this, SLOT( slotTzActive( int ) ) );
QObject::connect( cmdTz, SIGNAL( clicked() ),
this, SLOT( slotExecute() ) );
}
TimeZoneSelector::~TimeZoneSelector()
@@ -228,47 +228,48 @@ void TimeZoneSelector::setLocalIncluded(bool b)
bool TimeZoneSelector::localIncluded() const
{
return d->includeLocal;
}
QString TimeZoneSelector::currentZone() const
{
return cmbTz->currZone();
}
void TimeZoneSelector::setCurrentZone( const QString& id )
{
cmbTz->setCurrZone( id );
}
void TimeZoneSelector::slotTzActive( int )
{
emit signalNewTz( cmbTz->currZone() );
}
void TimeZoneSelector::slotExecute( void )
{
// execute the world time application...
- Global::execute( "worldtime" );
+ Global::execute( "citytime" );
}
QStringList timezoneDefaults( void )
{
QStringList tzs;
// load up the list just like the file format (citytime.cpp)
tzs.append( "America/New_York" );
tzs.append( "New York" );
tzs.append( "America/Los_Angeles" );
tzs.append( "Los Angeles" );
tzs.append( "Australia/Brisbane" );
tzs.append( "Brisbane" );
- tzs.append( "Europe/Oslo" );
- tzs.append( "Oslo" );
+ tzs.append( "Europe/Berlin" );
+ tzs.append( "Berlin" );
tzs.append( "Asia/Tokyo" );
tzs.append( "Tokyo" );
- tzs.append( "Asia/Hong_Kong" );
- tzs.append( "Hong Kong" );
+ tzs.append( "America/Denver" );
+ tzs.append( "Denver" );
+
return tzs;
}