summaryrefslogtreecommitdiff
path: root/library/tzselect.cpp
authorzecke <zecke>2002-10-16 01:09:22 (UTC)
committer zecke <zecke>2002-10-16 01:09:22 (UTC)
commit543e54de7170c606b6883ac4152567e7faf13182 (patch) (unidiff)
tree8a7d623e96cab0135a2f7cb11aa9f7491bfda9a2 /library/tzselect.cpp
parent3e973543b77631d053a9616b5540966dbe51ab47 (diff)
downloadopie-543e54de7170c606b6883ac4152567e7faf13182.zip
opie-543e54de7170c606b6883ac4152567e7faf13182.tar.gz
opie-543e54de7170c606b6883ac4152567e7faf13182.tar.bz2
Remove #ifdef QWS HELL
a Platform which is not supporting IPC compatible to QCopChannel/Envelope is not of much use nowadays.. so be sure your platform is supporting it
Diffstat (limited to 'library/tzselect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/tzselect.cpp4
1 files changed, 0 insertions, 4 deletions
diff --git a/library/tzselect.cpp b/library/tzselect.cpp
index 9436867..2e5a433 100644
--- a/library/tzselect.cpp
+++ b/library/tzselect.cpp
@@ -1,173 +1,169 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
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#define QTOPIA_INTERNAL_TZSELECT_INC_LOCAL 21#define QTOPIA_INTERNAL_TZSELECT_INC_LOCAL
22 22
23#include "tzselect.h" 23#include "tzselect.h"
24#include "resource.h" 24#include "resource.h"
25#include "global.h" 25#include "global.h"
26#include "config.h" 26#include "config.h"
27#include <qtoolbutton.h> 27#include <qtoolbutton.h>
28#include <qfile.h> 28#include <qfile.h>
29#include <stdlib.h> 29#include <stdlib.h>
30 30
31#ifdef Q_WS_QWS
32#include <qcopchannel_qws.h> 31#include <qcopchannel_qws.h>
33#endif
34 32
35class TimeZoneSelectorPrivate 33class TimeZoneSelectorPrivate
36{ 34{
37public: 35public:
38 TimeZoneSelectorPrivate() : includeLocal(FALSE) {} 36 TimeZoneSelectorPrivate() : includeLocal(FALSE) {}
39 bool includeLocal; 37 bool includeLocal;
40}; 38};
41 39
42TZCombo::TZCombo( QWidget *p, const char* n ) 40TZCombo::TZCombo( QWidget *p, const char* n )
43 : QComboBox( p, n ) 41 : QComboBox( p, n )
44{ 42{
45 updateZones(); 43 updateZones();
46 // check to see if TZ is set, if it is set the current item to that 44 // check to see if TZ is set, if it is set the current item to that
47 QString tz = getenv("TZ"); 45 QString tz = getenv("TZ");
48 if (parent()->inherits("TimeZoneSelector")) { 46 if (parent()->inherits("TimeZoneSelector")) {
49 if ( ((TimeZoneSelector *)parent())->localIncluded() ) { 47 if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
50 // overide to the 'local' type. 48 // overide to the 'local' type.
51 tz = "None"; 49 tz = "None";
52 } 50 }
53 } 51 }
54 if ( !tz.isNull() ) { 52 if ( !tz.isNull() ) {
55 int n = 0, 53 int n = 0,
56 index = 0; 54 index = 0;
57 for ( QStringList::Iterator it=identifiers.begin(); 55 for ( QStringList::Iterator it=identifiers.begin();
58 it!=identifiers.end(); ++it) { 56 it!=identifiers.end(); ++it) {
59 if ( *it == tz ) 57 if ( *it == tz )
60 index = n; 58 index = n;
61 n++; 59 n++;
62 } 60 }
63 setCurrentItem(index); 61 setCurrentItem(index);
64 } else { 62 } else {
65 setCurrentItem(0); 63 setCurrentItem(0);
66 } 64 }
67 65
68 66
69 67
70 // listen on QPE/System 68 // listen on QPE/System
71#if defined(Q_WS_QWS)
72#if !defined(QT_NO_COP) 69#if !defined(QT_NO_COP)
73 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 70 QCopChannel *channel = new QCopChannel( "QPE/System", this );
74 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 71 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
75 this, SLOT(handleSystemChannel(const QCString&, const QByteArray&)) ); 72 this, SLOT(handleSystemChannel(const QCString&, const QByteArray&)) );
76#endif 73#endif
77#endif
78 74
79 75
80} 76}
81 77
82TZCombo::~TZCombo() 78TZCombo::~TZCombo()
83{ 79{
84} 80}
85 81
86void TZCombo::updateZones() 82void TZCombo::updateZones()
87{ 83{
88 QString cur = currentText(); 84 QString cur = currentText();
89 clear(); 85 clear();
90 identifiers.clear(); 86 identifiers.clear();
91 int curix=0; 87 int curix=0;
92 QString tz = getenv("TZ"); 88 QString tz = getenv("TZ");
93 bool tzFound = FALSE; 89 bool tzFound = FALSE;
94 Config cfg("CityTime"); 90 Config cfg("CityTime");
95 cfg.setGroup("TimeZones"); 91 cfg.setGroup("TimeZones");
96 int listIndex = 0; 92 int listIndex = 0;
97 if (parent()->inherits("TimeZoneSelector")) { 93 if (parent()->inherits("TimeZoneSelector")) {
98 if ( ((TimeZoneSelector *)parent())->localIncluded() ) { 94 if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
99 // overide to the 'local' type. 95 // overide to the 'local' type.
100 identifiers.append( "None" ); 96 identifiers.append( "None" );
101 insertItem( tr("None") ); 97 insertItem( tr("None") );
102 if ( cur == tr("None")) 98 if ( cur == tr("None"))
103 curix = 0; 99 curix = 0;
104 listIndex++; 100 listIndex++;
105 } 101 }
106 } 102 }
107 int cfgIndex = 0; 103 int cfgIndex = 0;
108 while (1) { 104 while (1) {
109 QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null); 105 QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null);
110 if ( zn.isNull() ) 106 if ( zn.isNull() )
111 break; 107 break;
112 if ( zn == tz ) 108 if ( zn == tz )
113 tzFound = TRUE; 109 tzFound = TRUE;
114 QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex)); 110 QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex));
115 identifiers.append(zn); 111 identifiers.append(zn);
116 insertItem(nm); 112 insertItem(nm);
117 if ( nm == cur ) 113 if ( nm == cur )
118 curix = listIndex; 114 curix = listIndex;
119 ++cfgIndex; 115 ++cfgIndex;
120 ++listIndex; 116 ++listIndex;
121 } 117 }
122 if ( !listIndex ) { 118 if ( !listIndex ) {
123 QStringList list = timezoneDefaults(); 119 QStringList list = timezoneDefaults();
124 for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) { 120 for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) {
125 QString zn = *it; 121 QString zn = *it;
126 QString nm = *++it; 122 QString nm = *++it;
127 if ( zn == tz ) 123 if ( zn == tz )
128 tzFound = TRUE; 124 tzFound = TRUE;
129 if ( nm == cur ) 125 if ( nm == cur )
130 curix = listIndex; 126 curix = listIndex;
131 identifiers.append(zn); 127 identifiers.append(zn);
132 insertItem(nm); 128 insertItem(nm);
133 ++listIndex; 129 ++listIndex;
134 } 130 }
135 } 131 }
136 for (QStringList::Iterator it=extras.begin(); it!=extras.end(); ++it) { 132 for (QStringList::Iterator it=extras.begin(); it!=extras.end(); ++it) {
137 insertItem(*it); 133 insertItem(*it);
138 identifiers.append(*it); 134 identifiers.append(*it);
139 if ( *it == cur ) 135 if ( *it == cur )
140 curix = listIndex; 136 curix = listIndex;
141 ++listIndex; 137 ++listIndex;
142 } 138 }
143 if ( !tzFound && !tz.isEmpty()) { 139 if ( !tzFound && !tz.isEmpty()) {
144 int i = tz.find( '/' ); 140 int i = tz.find( '/' );
145 QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " "); 141 QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " ");
146 identifiers.append(tz); 142 identifiers.append(tz);
147 insertItem(nm); 143 insertItem(nm);
148 if ( nm == cur ) 144 if ( nm == cur )
149 curix = listIndex; 145 curix = listIndex;
150 ++listIndex; 146 ++listIndex;
151 } 147 }
152 setCurrentItem(curix); 148 setCurrentItem(curix);
153} 149}
154 150
155 151
156void TZCombo::keyPressEvent( QKeyEvent *e ) 152void TZCombo::keyPressEvent( QKeyEvent *e )
157{ 153{
158 // ### should popup() in Qt 3.0 (it's virtual there) 154 // ### should popup() in Qt 3.0 (it's virtual there)
159// updateZones(); 155// updateZones();
160 QComboBox::keyPressEvent(e); 156 QComboBox::keyPressEvent(e);
161} 157}
162 158
163void TZCombo::mousePressEvent(QMouseEvent*e) 159void TZCombo::mousePressEvent(QMouseEvent*e)
164{ 160{
165 // ### should popup() in Qt 3.0 (it's virtual there) 161 // ### should popup() in Qt 3.0 (it's virtual there)
166// updateZones(); 162// updateZones();
167 QComboBox::mousePressEvent(e); 163 QComboBox::mousePressEvent(e);
168} 164}
169 165
170QString TZCombo::currZone() const 166QString TZCombo::currZone() const
171{ 167{
172 return identifiers[currentItem()]; 168 return identifiers[currentItem()];
173} 169}