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.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/library/tzselect.cpp b/library/tzselect.cpp
index f28100b..848dfb7 100644
--- a/library/tzselect.cpp
+++ b/library/tzselect.cpp
@@ -32,98 +32,98 @@
#include <qmessagebox.h>
/*!
\class TimeZoneSelector
\brief The TimeZoneSelector widget allows users to configure their time zone information.
\ingroup qtopiaemb
*/
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 ( !tz.isNull() ) {
int n = 0,
index = 0;
for ( QStringList::Iterator it=identifiers.begin();
it!=identifiers.end(); ++it) {
if ( *it == tz )
index = n;
n++;
}
setCurrentItem(index);
} else {
setCurrentItem(0);
}
// listen on QPE/System
#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&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) );
#endif
}
TZCombo::~TZCombo()
{
}
void TZCombo::updateZones()
{
QString cur = currentText();
clear();
identifiers.clear();
int curix=0;
QString tz = getenv("TZ");
bool tzFound = FALSE;
Config cfg("CityTime");
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++;
}
}
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;
}
if ( !listIndex ) {
QStringList list = timezoneDefaults();
for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) {
@@ -173,98 +173,98 @@ void TZCombo::mousePressEvent(QMouseEvent*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;
}
}
insertItem(id);
setCurrentItem( count() - 1);
identifiers.append(id);
extras.append(id);
}
void TZCombo::handleSystemChannel(const QCString&msg, const QByteArray&)
{
if ( msg == "timeZoneListChange()" ) {
updateZones();
}
}
/*!
Creates a new TimeZoneSelector with parent \a p and name \a n. The combobox will be
populated with the available timezones.
*/
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( cmbTz, SIGNAL( activated(int) ),
+ this, SLOT( slotTzActive(int) ) );
QObject::connect( cmdTz, SIGNAL( clicked() ),
this, SLOT( slotExecute() ) );
}
/*!
Destroys a TimeZoneSelector.
*/
TimeZoneSelector::~TimeZoneSelector()
{
}
void TimeZoneSelector::setLocalIncluded(bool b)
{
d->includeLocal = b;
cmbTz->updateZones();
}
bool TimeZoneSelector::localIncluded() const
{
return d->includeLocal;
}
/*!
Returns the currently selected timezone as a string in location format, e.g.
\code Australia/Brisbane \endcode
*/
QString TimeZoneSelector::currentZone() const
{
return cmbTz->currZone();
}
/*!
Sets the current timezone to \a id.
*/
void TimeZoneSelector::setCurrentZone( const QString& id )
{
cmbTz->setCurrZone( id );
}
/*! \fn void TimeZoneSelector::signalNewTz( const QString& id )
This signal is emitted when a timezone has been selected by the user. The id
is a \l QString in location format, eg \code Australia/Brisbane \endcode
*/
void TimeZoneSelector::slotTzActive( int )
{
emit signalNewTz( cmbTz->currZone() );
}