summaryrefslogtreecommitdiff
authorchicken <chicken>2004-03-01 17:53:46 (UTC)
committer chicken <chicken>2004-03-01 17:53:46 (UTC)
commit5b4e342004537f84fa53911a46cd00d810378da7 (patch) (unidiff)
tree763c74ad41014de91c010fb996ec527f841ef3bc
parent5b640d3f070b0b2de361421abf93949410546e19 (diff)
downloadopie-5b4e342004537f84fa53911a46cd00d810378da7.zip
opie-5b4e342004537f84fa53911a46cd00d810378da7.tar.gz
opie-5b4e342004537f84fa53911a46cd00d810378da7.tar.bz2
fix includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/citytime/citytime.cpp5
-rw-r--r--core/settings/citytime/citytimebase.cpp3
-rw-r--r--core/settings/citytime/main.cpp1
-rw-r--r--core/settings/citytime/stylusnormalizer.cpp1
-rw-r--r--core/settings/citytime/zonemap.cpp7
-rw-r--r--core/settings/light-and-power/light.cpp1
-rw-r--r--libqtaux/ocolorbutton.cpp3
-rw-r--r--libqtaux/ocolorpopupmenu.cpp1
-rw-r--r--libqtaux/qcolordialog.cpp2
-rw-r--r--libqtaux/qinputdialog.cpp1
-rw-r--r--libqtaux/qsplitter.cpp4
11 files changed, 0 insertions, 29 deletions
diff --git a/core/settings/citytime/citytime.cpp b/core/settings/citytime/citytime.cpp
index b359ae1..e7f0c46 100644
--- a/core/settings/citytime/citytime.cpp
+++ b/core/settings/citytime/citytime.cpp
@@ -1,284 +1,279 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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// changes by Maximilian Reiss <harlekin@handhelds.org> 21// changes by Maximilian Reiss <harlekin@handhelds.org>
22 22
23#include "zonemap.h" 23#include "zonemap.h"
24#include "citytime.h" 24#include "citytime.h"
25 25
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#include <qpe/timestring.h>
29#include <qpe/tzselect.h> 28#include <qpe/tzselect.h>
30#if !defined(QT_NO_COP) 29#if !defined(QT_NO_COP)
31#include <qpe/qcopenvelope_qws.h> 30#include <qpe/qcopenvelope_qws.h>
32#endif 31#endif
33 32
34#include <qdir.h>
35#include <qfile.h>
36#include <qlabel.h> 33#include <qlabel.h>
37#include <qmessagebox.h> 34#include <qmessagebox.h>
38#include <qregexp.h>
39#include <qtextstream.h>
40#include <qtoolbutton.h> 35#include <qtoolbutton.h>
41#include <qlayout.h> 36#include <qlayout.h>
42 37
43#include <stdlib.h> 38#include <stdlib.h>
44 39
45CityTime::CityTime( QWidget *parent, const char* name, 40CityTime::CityTime( QWidget *parent, const char* name,
46 WFlags fl ) 41 WFlags fl )
47 : CityTimeBase( parent, name, fl ), 42 : CityTimeBase( parent, name, fl ),
48 strRealTz(0), 43 strRealTz(0),
49 bAdded(false) 44 bAdded(false)
50{ 45{
51 Config config( "qpe" ); 46 Config config( "qpe" );
52 config.setGroup( "Time" ); 47 config.setGroup( "Time" );
53 bWhichClock = config.readBoolEntry( "AMPM", TRUE ); 48 bWhichClock = config.readBoolEntry( "AMPM", TRUE );
54 qDebug( QString("%1").arg(bWhichClock) ); 49 qDebug( QString("%1").arg(bWhichClock) );
55 frmMap->changeClock( bWhichClock ); 50 frmMap->changeClock( bWhichClock );
56 51
57 char *pEnv; 52 char *pEnv;
58 pEnv = NULL; 53 pEnv = NULL;
59 pEnv = getenv("TZ"); 54 pEnv = getenv("TZ");
60 if ( pEnv ) 55 if ( pEnv )
61 strRealTz = pEnv; 56 strRealTz = pEnv;
62 pEnv = NULL; 57 pEnv = NULL;
63 pEnv = getenv("HOME"); 58 pEnv = getenv("HOME");
64 if ( pEnv ) 59 if ( pEnv )
65 strHome = pEnv; 60 strHome = pEnv;
66 // append the labels to their respective lists... 61 // append the labels to their respective lists...
67 listCities.setAutoDelete( true ); 62 listCities.setAutoDelete( true );
68 listTimes.setAutoDelete( true ); 63 listTimes.setAutoDelete( true );
69 64
70 listCities.append( cmdCity1 ); 65 listCities.append( cmdCity1 );
71 listCities.append( cmdCity2 ); 66 listCities.append( cmdCity2 );
72 listCities.append( cmdCity3 ); 67 listCities.append( cmdCity3 );
73 68
74 listTimes.append( lblCTime1 ); 69 listTimes.append( lblCTime1 );
75 listTimes.append( lblCTime2 ); 70 listTimes.append( lblCTime2 );
76 listTimes.append( lblCTime3 ); 71 listTimes.append( lblCTime3 );
77 72
78 73
79 // kludgy way of getting the screen size so we don't have to depend 74 // kludgy way of getting the screen size so we don't have to depend
80 // on a resize event... 75 // on a resize event...
81 QWidget *d = QApplication::desktop(); 76 QWidget *d = QApplication::desktop();
82 if ( d->width() < d->height() ) { 77 if ( d->width() < d->height() ) {
83 // append for that 4 down look 78 // append for that 4 down look
84 listCities.append( cmdCity4 ); 79 listCities.append( cmdCity4 );
85 listCities.append( cmdCity5 ); 80 listCities.append( cmdCity5 );
86 listCities.append( cmdCity6 ); 81 listCities.append( cmdCity6 );
87 listTimes.append( lblCTime4 ); 82 listTimes.append( lblCTime4 );
88 listTimes.append( lblCTime5 ); 83 listTimes.append( lblCTime5 );
89 listTimes.append( lblCTime6 ); 84 listTimes.append( lblCTime6 );
90 lblCTime7->hide(); 85 lblCTime7->hide();
91 lblCTime8->hide(); 86 lblCTime8->hide();
92 lblCTime9->hide(); 87 lblCTime9->hide();
93 cmdCity7->hide(); 88 cmdCity7->hide();
94 cmdCity8->hide(); 89 cmdCity8->hide();
95 cmdCity9->hide(); 90 cmdCity9->hide();
96 } else { 91 } else {
97 listCities.append( cmdCity7 ); 92 listCities.append( cmdCity7 );
98 listCities.append( cmdCity8 ); 93 listCities.append( cmdCity8 );
99 listCities.append( cmdCity9 ); 94 listCities.append( cmdCity9 );
100 listTimes.append( lblCTime7 ); 95 listTimes.append( lblCTime7 );
101 listTimes.append( lblCTime8 ); 96 listTimes.append( lblCTime8 );
102 listTimes.append( lblCTime9 ); 97 listTimes.append( lblCTime9 );
103 lblCTime4->hide(); 98 lblCTime4->hide();
104 lblCTime5->hide(); 99 lblCTime5->hide();
105 lblCTime6->hide(); 100 lblCTime6->hide();
106 cmdCity4->hide(); 101 cmdCity4->hide();
107 cmdCity5->hide(); 102 cmdCity5->hide();
108 cmdCity6->hide(); 103 cmdCity6->hide();
109 } 104 }
110 105
111 selWidget = frmMap->selectionWidget( this ); 106 selWidget = frmMap->selectionWidget( this );
112 selWidget->hide(); 107 selWidget->hide();
113 CityTimeBaseLayout->addWidget( selWidget ); 108 CityTimeBaseLayout->addWidget( selWidget );
114 bAdded = true; 109 bAdded = true;
115 readInTimes(); 110 readInTimes();
116 changed = FALSE; 111 changed = FALSE;
117 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), 112 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ),
118 this, SLOT( changeClock( bool ) ) ); 113 this, SLOT( changeClock( bool ) ) );
119 // now start the timer so we can update the time quickly every second 114 // now start the timer so we can update the time quickly every second
120 timerEvent( 0 ); 115 timerEvent( 0 );
121} 116}
122 117
123CityTime::~CityTime() 118CityTime::~CityTime()
124{ 119{
125 if ( changed ) { 120 if ( changed ) {
126 Config cfg("CityTime"); 121 Config cfg("CityTime");
127 cfg.setGroup("TimeZones"); 122 cfg.setGroup("TimeZones");
128 QListIterator<QToolButton> itCity( listCities ); 123 QListIterator<QToolButton> itCity( listCities );
129 int i; 124 int i;
130 bool realTzWritten = FALSE; 125 bool realTzWritten = FALSE;
131 for ( i = 0, itCity.toFirst(); i < CITIES; i++, ++itCity ) { 126 for ( i = 0, itCity.toFirst(); i < CITIES; i++, ++itCity ) {
132 if ( !strCityTz[i].isNull() ) { 127 if ( !strCityTz[i].isNull() ) {
133 cfg.writeEntry("Zone"+QString::number(i), strCityTz[i]); 128 cfg.writeEntry("Zone"+QString::number(i), strCityTz[i]);
134 cfg.writeEntry("ZoneName"+QString::number(i), itCity.current()->text()); 129 cfg.writeEntry("ZoneName"+QString::number(i), itCity.current()->text());
135 if ( strCityTz[i] == strRealTz ) 130 if ( strCityTz[i] == strRealTz )
136 realTzWritten = TRUE; 131 realTzWritten = TRUE;
137 } 132 }
138 } 133 }
139 if ( realTzWritten ) { 134 if ( realTzWritten ) {
140 cfg.removeEntry("Zone"+QString::number(CITIES)); 135 cfg.removeEntry("Zone"+QString::number(CITIES));
141 cfg.removeEntry("ZoneName"+QString::number(CITIES)); 136 cfg.removeEntry("ZoneName"+QString::number(CITIES));
142 } else { 137 } else {
143 cfg.writeEntry("Zone"+QString::number(CITIES), strRealTz); 138 cfg.writeEntry("Zone"+QString::number(CITIES), strRealTz);
144 if ( nameRealTz.isEmpty() ) { 139 if ( nameRealTz.isEmpty() ) {
145 int i = strRealTz.find( '/' ); 140 int i = strRealTz.find( '/' );
146 nameRealTz = strRealTz.mid( i+1 ); 141 nameRealTz = strRealTz.mid( i+1 );
147 } 142 }
148 cfg.writeEntry("ZoneName"+QString::number(CITIES), nameRealTz); 143 cfg.writeEntry("ZoneName"+QString::number(CITIES), nameRealTz);
149 } 144 }
150 QCopEnvelope ( "QPE/System", "timeZoneListChange()" ); 145 QCopEnvelope ( "QPE/System", "timeZoneListChange()" );
151 146
152 changed = FALSE; 147 changed = FALSE;
153 } 148 }
154 // restore the timezone, just in case we messed with it and 149 // restore the timezone, just in case we messed with it and
155 // are destroyed at an inoppurtune moment 150 // are destroyed at an inoppurtune moment
156 if ( !strRealTz.isNull() ) { 151 if ( !strRealTz.isNull() ) {
157 // this should be checked, but there is not much that can done at this 152 // this should be checked, but there is not much that can done at this
158 //point if it fails 153 //point if it fails
159 setenv( "TZ", strRealTz, true ); 154 setenv( "TZ", strRealTz, true );
160 } 155 }
161} 156}
162 157
163void CityTime::timerEvent( QTimerEvent *e ) 158void CityTime::timerEvent( QTimerEvent *e )
164{ 159{
165 if ( e ) 160 if ( e )
166 killTimer( timerId ); 161 killTimer( timerId );
167 // change the time again!! 162 // change the time again!!
168 showTime(); 163 showTime();
169 int ms = 1000 - QTime::currentTime().msec(); 164 int ms = 1000 - QTime::currentTime().msec();
170 timerId = startTimer( ms ); 165 timerId = startTimer( ms );
171} 166}
172 167
173void CityTime::mousePressEvent( QMouseEvent * ) 168void CityTime::mousePressEvent( QMouseEvent * )
174{ 169{
175 // DEBUG enable this to get a look at the zone information DEBUG 170 // DEBUG enable this to get a look at the zone information DEBUG
176// frmMap->showZones(); 171// frmMap->showZones();
177} 172}
178 173
179void CityTime::showTime( void ) 174void CityTime::showTime( void )
180{ 175{
181 int i; 176 int i;
182 QListIterator<QLabel> itTime(listTimes); 177 QListIterator<QLabel> itTime(listTimes);
183 178
184 // traverse the list... 179 // traverse the list...
185 for ( i = 0, itTime.toFirst(); i < CITIES; i++, ++itTime) { 180 for ( i = 0, itTime.toFirst(); i < CITIES; i++, ++itTime) {
186 if ( !strCityTz[i].isNull() ) { 181 if ( !strCityTz[i].isNull() ) {
187 if ( setenv( "TZ", strCityTz[i], true ) == 0 ) { 182 if ( setenv( "TZ", strCityTz[i], true ) == 0 ) {
188 itTime.current()->setText( TimeString::shortTime( bWhichClock ) ); 183 itTime.current()->setText( TimeString::shortTime( bWhichClock ) );
189 } else { 184 } else {
190 QMessageBox::critical( this, tr( "Time Changing" ), 185 QMessageBox::critical( this, tr( "Time Changing" ),
191 tr( "There was a problem setting timezone %1" ) 186 tr( "There was a problem setting timezone %1" )
192 .arg( QString::number( i + 1 ) ) ); 187 .arg( QString::number( i + 1 ) ) );
193 } 188 }
194 } 189 }
195 } 190 }
196 // done playing around... put it all back 191 // done playing around... put it all back
197 unsetenv( "TZ" ); 192 unsetenv( "TZ" );
198 if ( !strRealTz.isNull() ) { 193 if ( !strRealTz.isNull() ) {
199 if ( setenv( "TZ", strRealTz, true ) != 0 ) { 194 if ( setenv( "TZ", strRealTz, true ) != 0 ) {
200 QMessageBox::critical( this, tr( "Restore Time Zone" ), 195 QMessageBox::critical( this, tr( "Restore Time Zone" ),
201 tr( "There was a problem setting your timezone." 196 tr( "There was a problem setting your timezone."
202 "Your time may be wrong now..." ) ); 197 "Your time may be wrong now..." ) );
203 } 198 }
204 } 199 }
205} 200}
206 201
207void CityTime::beginNewTz() 202void CityTime::beginNewTz()
208{ 203{
209 buttonWidget->hide(); 204 buttonWidget->hide();
210 frmMap->setFocus(); 205 frmMap->setFocus();
211 selWidget->show(); 206 selWidget->show();
212 // CityTimeBaseLayout->addWidget( selWidget ); 207 // CityTimeBaseLayout->addWidget( selWidget );
213} 208}
214 209
215void CityTime::slotNewTz( const QString & strNewCountry, 210void CityTime::slotNewTz( const QString & strNewCountry,
216 const QString & strNewCity ) 211 const QString & strNewCity )
217{ 212{
218 // determine what to do based on what putton is pressed... 213 // determine what to do based on what putton is pressed...
219 QListIterator<QToolButton> itCity(listCities); 214 QListIterator<QToolButton> itCity(listCities);
220 int i; 215 int i;
221 // go through the list and make adjustments based on which button is on 216 // go through the list and make adjustments based on which button is on
222 for ( i = 0, itCity.toFirst(); itCity.current(), i < CITIES; i++, ++itCity ) { 217 for ( i = 0, itCity.toFirst(); itCity.current(), i < CITIES; i++, ++itCity ) {
223 QToolButton *cmdTmp = itCity.current(); 218 QToolButton *cmdTmp = itCity.current();
224 if ( cmdTmp->isOn() ) { 219 if ( cmdTmp->isOn() ) {
225 strCityTz[i] = strNewCountry + strNewCity; 220 strCityTz[i] = strNewCountry + strNewCity;
226 QString s = strNewCity; 221 QString s = strNewCity;
227 cmdTmp->setText( s.replace( QRegExp("_"), " " ) ); 222 cmdTmp->setText( s.replace( QRegExp("_"), " " ) );
228 cmdTmp->toggle(); 223 cmdTmp->toggle();
229 // we can actually break, since there is only one button 224 // we can actually break, since there is only one button
230 // that is ever pressed! 225 // that is ever pressed!
231 changed = TRUE; 226 changed = TRUE;
232 break; 227 break;
233 } 228 }
234 } 229 }
235 showTime(); 230 showTime();
236 buttonWidget->show(); 231 buttonWidget->show();
237 selWidget->hide(); 232 selWidget->hide();
238} 233}
239 234
240void CityTime::readInTimes( void ) 235void CityTime::readInTimes( void )
241{ 236{
242 Config cfg("CityTime"); 237 Config cfg("CityTime");
243 cfg.setGroup("TimeZones"); 238 cfg.setGroup("TimeZones");
244 QListIterator<QToolButton> itCity( listCities ); 239 QListIterator<QToolButton> itCity( listCities );
245 int i=0; 240 int i=0;
246 nameRealTz = QString::null; 241 nameRealTz = QString::null;
247 QString zn; 242 QString zn;
248 for ( ; i < CITIES ; i++ ) { 243 for ( ; i < CITIES ; i++ ) {
249 zn = cfg.readEntry("Zone"+QString::number(i), QString::null); 244 zn = cfg.readEntry("Zone"+QString::number(i), QString::null);
250 if ( zn.isNull() ) 245 if ( zn.isNull() )
251 break; 246 break;
252 QString nm = cfg.readEntry("ZoneName"+QString::number(i)); 247 QString nm = cfg.readEntry("ZoneName"+QString::number(i));
253 strCityTz[i] = zn; 248 strCityTz[i] = zn;
254 itCity.current()->setText(nm); 249 itCity.current()->setText(nm);
255 if ( zn == strRealTz ) 250 if ( zn == strRealTz )
256 nameRealTz = nm; 251 nameRealTz = nm;
257 ++itCity; 252 ++itCity;
258 } 253 }
259 if ( i == 0 ) { 254 if ( i == 0 ) {
260 // write in our own in a shameless self promotion and some humor 255 // write in our own in a shameless self promotion and some humor
261 QStringList list = timezoneDefaults(); 256 QStringList list = timezoneDefaults();
262 int i; 257 int i;
263 QStringList::Iterator it = list.begin(); 258 QStringList::Iterator it = list.begin();
264 for ( i = 0, itCity.toFirst(); i < CITIES && itCity.current(); 259 for ( i = 0, itCity.toFirst(); i < CITIES && itCity.current();
265 i++, ++itCity ) { 260 i++, ++itCity ) {
266 strCityTz[i] = *it++; 261 strCityTz[i] = *it++;
267 itCity.current()->setText( *it++ ); 262 itCity.current()->setText( *it++ );
268 } 263 }
269 } 264 }
270 if ( nameRealTz.isEmpty() ) { 265 if ( nameRealTz.isEmpty() ) {
271 //remember the current time zone even if we don't have room 266 //remember the current time zone even if we don't have room
272 //to show it. 267 //to show it.
273 zn = cfg.readEntry("Zone"+QString::number(CITIES), QString::null); 268 zn = cfg.readEntry("Zone"+QString::number(CITIES), QString::null);
274 if ( zn == strRealTz ) 269 if ( zn == strRealTz )
275 nameRealTz = cfg.readEntry("ZoneName"+QString::number(CITIES)); 270 nameRealTz = cfg.readEntry("ZoneName"+QString::number(CITIES));
276 i++; 271 i++;
277 } 272 }
278} 273}
279 274
280void CityTime::changeClock( bool newClock ) 275void CityTime::changeClock( bool newClock )
281{ 276{
282 bWhichClock = newClock; 277 bWhichClock = newClock;
283 showTime(); 278 showTime();
284} 279}
diff --git a/core/settings/citytime/citytimebase.cpp b/core/settings/citytime/citytimebase.cpp
index d734cf3..a3483cc 100644
--- a/core/settings/citytime/citytimebase.cpp
+++ b/core/settings/citytime/citytimebase.cpp
@@ -1,414 +1,411 @@
1 1
2 2
3// changes by Maximilian Reiss <harlekin@handhelds.org> 3// changes by Maximilian Reiss <harlekin@handhelds.org>
4 4
5#include "citytimebase.h" 5#include "citytimebase.h"
6 6
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qpushbutton.h>
9#include <qtoolbutton.h> 8#include <qtoolbutton.h>
10#include "zonemap.h" 9#include "zonemap.h"
11#include <qlayout.h> 10#include <qlayout.h>
12#include <qvariant.h>
13#include <qtooltip.h>
14#include <qwhatsthis.h> 11#include <qwhatsthis.h>
15 12
16 13
17/* 14/*
18 * Constructs a CityTimeBase which is a child of 'parent', with the 15 * Constructs a CityTimeBase which is a child of 'parent', with the
19 * name 'name' and widget flags set to 'f' 16 * name 'name' and widget flags set to 'f'
20 */ 17 */
21CityTimeBase::CityTimeBase( QWidget* parent, const char* name, WFlags ) 18CityTimeBase::CityTimeBase( QWidget* parent, const char* name, WFlags )
22 : QWidget( parent, name, WStyle_ContextHelp ) 19 : QWidget( parent, name, WStyle_ContextHelp )
23{ 20{
24 if ( !name ) 21 if ( !name )
25 setName( "CityTimeBase" ); 22 setName( "CityTimeBase" );
26 setCaption( tr( "City Time" ) ); 23 setCaption( tr( "City Time" ) );
27 CityTimeBaseLayout = new QVBoxLayout( this ); 24 CityTimeBaseLayout = new QVBoxLayout( this );
28 CityTimeBaseLayout->setSpacing( 3 ); 25 CityTimeBaseLayout->setSpacing( 3 );
29 CityTimeBaseLayout->setMargin( 0 ); 26 CityTimeBaseLayout->setMargin( 0 );
30 27
31 frmMap = new ZoneMap( this, "frmMap" ); 28 frmMap = new ZoneMap( this, "frmMap" );
32 frmMap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, frmMap->sizePolicy().hasHeightForWidth() ) ); 29 frmMap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, frmMap->sizePolicy().hasHeightForWidth() ) );
33 CityTimeBaseLayout->addWidget( frmMap ); 30 CityTimeBaseLayout->addWidget( frmMap );
34 31
35 buttonWidget = new QWidget( this ); 32 buttonWidget = new QWidget( this );
36 QWhatsThis::add( buttonWidget, tr( "Click on one of the set cities to replace it" ) ); 33 QWhatsThis::add( buttonWidget, tr( "Click on one of the set cities to replace it" ) );
37 Layout2 = new QGridLayout( buttonWidget ); 34 Layout2 = new QGridLayout( buttonWidget );
38 Layout2->setSpacing( 3 ); 35 Layout2->setSpacing( 3 );
39 Layout2->setMargin( 4 ); 36 Layout2->setMargin( 4 );
40 37
41 cmdCity7 = new QToolButton( buttonWidget, "cmdCity7" ); 38 cmdCity7 = new QToolButton( buttonWidget, "cmdCity7" );
42 cmdCity7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity7->sizePolicy().hasHeightForWidth() ) ); 39 cmdCity7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity7->sizePolicy().hasHeightForWidth() ) );
43 QFont cmdCity7_font( cmdCity7->font() ); 40 QFont cmdCity7_font( cmdCity7->font() );
44 cmdCity7_font.setBold( TRUE ); 41 cmdCity7_font.setBold( TRUE );
45 cmdCity7->setFont( cmdCity7_font ); 42 cmdCity7->setFont( cmdCity7_font );
46 cmdCity7->setFocusPolicy( QToolButton::TabFocus ); 43 cmdCity7->setFocusPolicy( QToolButton::TabFocus );
47 cmdCity7->setText( tr( "" ) ); 44 cmdCity7->setText( tr( "" ) );
48 cmdCity7->setToggleButton( TRUE ); 45 cmdCity7->setToggleButton( TRUE );
49 cmdCity7->setToggleButton( TRUE ); 46 cmdCity7->setToggleButton( TRUE );
50 47
51 Layout2->addWidget( cmdCity7, 0, 2 ); 48 Layout2->addWidget( cmdCity7, 0, 2 );
52 49
53 lblCTime9 = new QLabel( buttonWidget, "lblCTime9" ); 50 lblCTime9 = new QLabel( buttonWidget, "lblCTime9" );
54 lblCTime9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime9->sizePolicy().hasHeightForWidth() ) ); 51 lblCTime9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime9->sizePolicy().hasHeightForWidth() ) );
55 QFont lblCTime9_font( lblCTime9->font() ); 52 QFont lblCTime9_font( lblCTime9->font() );
56 lblCTime9_font.setPointSize( 10 ); 53 lblCTime9_font.setPointSize( 10 );
57 lblCTime9->setFont( lblCTime9_font ); 54 lblCTime9->setFont( lblCTime9_font );
58 lblCTime9->setText( tr( "" ) ); 55 lblCTime9->setText( tr( "" ) );
59 lblCTime9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 56 lblCTime9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
60 57
61 Layout2->addWidget( lblCTime9, 2, 3 ); 58 Layout2->addWidget( lblCTime9, 2, 3 );
62 59
63 cmdCity8 = new QToolButton( buttonWidget, "cmdCity8" ); 60 cmdCity8 = new QToolButton( buttonWidget, "cmdCity8" );
64 cmdCity8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity8->sizePolicy().hasHeightForWidth() ) ); 61 cmdCity8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity8->sizePolicy().hasHeightForWidth() ) );
65 QFont cmdCity8_font( cmdCity8->font() ); 62 QFont cmdCity8_font( cmdCity8->font() );
66 cmdCity8_font.setBold( TRUE ); 63 cmdCity8_font.setBold( TRUE );
67 cmdCity8->setFont( cmdCity8_font ); 64 cmdCity8->setFont( cmdCity8_font );
68 cmdCity8->setFocusPolicy( QToolButton::TabFocus ); 65 cmdCity8->setFocusPolicy( QToolButton::TabFocus );
69 cmdCity8->setText( tr( "" ) ); 66 cmdCity8->setText( tr( "" ) );
70 cmdCity8->setToggleButton( TRUE ); 67 cmdCity8->setToggleButton( TRUE );
71 cmdCity8->setToggleButton( TRUE ); 68 cmdCity8->setToggleButton( TRUE );
72 69
73 Layout2->addWidget( cmdCity8, 1, 2 ); 70 Layout2->addWidget( cmdCity8, 1, 2 );
74 71
75 cmdCity2 = new QToolButton( buttonWidget, "cmdCity2" ); 72 cmdCity2 = new QToolButton( buttonWidget, "cmdCity2" );
76 QFont cmdCity2_font( cmdCity2->font() ); 73 QFont cmdCity2_font( cmdCity2->font() );
77 cmdCity2_font.setBold( TRUE ); 74 cmdCity2_font.setBold( TRUE );
78 cmdCity2->setFont( cmdCity2_font ); 75 cmdCity2->setFont( cmdCity2_font );
79 cmdCity2->setFocusPolicy( QToolButton::TabFocus ); 76 cmdCity2->setFocusPolicy( QToolButton::TabFocus );
80 cmdCity2->setText( tr( "" ) ); 77 cmdCity2->setText( tr( "" ) );
81 cmdCity2->setToggleButton( TRUE ); 78 cmdCity2->setToggleButton( TRUE );
82 cmdCity2->setToggleButton( TRUE ); 79 cmdCity2->setToggleButton( TRUE );
83 80
84 Layout2->addWidget( cmdCity2, 1, 0 ); 81 Layout2->addWidget( cmdCity2, 1, 0 );
85 82
86 lblCTime6 = new QLabel( buttonWidget, "lblCTime6" ); 83 lblCTime6 = new QLabel( buttonWidget, "lblCTime6" );
87 QFont lblCTime6_font( lblCTime6->font() ); 84 QFont lblCTime6_font( lblCTime6->font() );
88 lblCTime6_font.setPointSize( 10 ); 85 lblCTime6_font.setPointSize( 10 );
89 lblCTime6->setFont( lblCTime6_font ); 86 lblCTime6->setFont( lblCTime6_font );
90 lblCTime6->setText( tr( "" ) ); 87 lblCTime6->setText( tr( "" ) );
91 lblCTime6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 88 lblCTime6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
92 89
93 Layout2->addWidget( lblCTime6, 5, 1 ); 90 Layout2->addWidget( lblCTime6, 5, 1 );
94 91
95 cmdCity6 = new QToolButton( buttonWidget, "cmdCity6" ); 92 cmdCity6 = new QToolButton( buttonWidget, "cmdCity6" );
96 cmdCity6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity6->sizePolicy().hasHeightForWidth() ) ); 93 cmdCity6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity6->sizePolicy().hasHeightForWidth() ) );
97 QFont cmdCity6_font( cmdCity6->font() ); 94 QFont cmdCity6_font( cmdCity6->font() );
98 cmdCity6_font.setBold( TRUE ); 95 cmdCity6_font.setBold( TRUE );
99 cmdCity6->setFont( cmdCity6_font ); 96 cmdCity6->setFont( cmdCity6_font );
100 cmdCity6->setFocusPolicy( QToolButton::TabFocus ); 97 cmdCity6->setFocusPolicy( QToolButton::TabFocus );
101 cmdCity6->setText( tr( "" ) ); 98 cmdCity6->setText( tr( "" ) );
102 cmdCity6->setToggleButton( TRUE ); 99 cmdCity6->setToggleButton( TRUE );
103 cmdCity6->setToggleButton( TRUE ); 100 cmdCity6->setToggleButton( TRUE );
104 101
105 Layout2->addWidget( cmdCity6, 5, 0 ); 102 Layout2->addWidget( cmdCity6, 5, 0 );
106 103
107 cmdCity4 = new QToolButton( buttonWidget, "cmdCity4" ); 104 cmdCity4 = new QToolButton( buttonWidget, "cmdCity4" );
108 cmdCity4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity4->sizePolicy().hasHeightForWidth() ) ); 105 cmdCity4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity4->sizePolicy().hasHeightForWidth() ) );
109 QFont cmdCity4_font( cmdCity4->font() ); 106 QFont cmdCity4_font( cmdCity4->font() );
110 cmdCity4_font.setBold( TRUE ); 107 cmdCity4_font.setBold( TRUE );
111 cmdCity4->setFont( cmdCity4_font ); 108 cmdCity4->setFont( cmdCity4_font );
112 cmdCity4->setFocusPolicy( QToolButton::TabFocus ); 109 cmdCity4->setFocusPolicy( QToolButton::TabFocus );
113 cmdCity4->setText( tr( "" ) ); 110 cmdCity4->setText( tr( "" ) );
114 cmdCity4->setToggleButton( TRUE ); 111 cmdCity4->setToggleButton( TRUE );
115 cmdCity4->setToggleButton( TRUE ); 112 cmdCity4->setToggleButton( TRUE );
116 113
117 Layout2->addWidget( cmdCity4, 3, 0 ); 114 Layout2->addWidget( cmdCity4, 3, 0 );
118 115
119 lblCTime5 = new QLabel( buttonWidget, "lblCTime5" ); 116 lblCTime5 = new QLabel( buttonWidget, "lblCTime5" );
120 QFont lblCTime5_font( lblCTime5->font() ); 117 QFont lblCTime5_font( lblCTime5->font() );
121 lblCTime5_font.setPointSize( 10 ); 118 lblCTime5_font.setPointSize( 10 );
122 lblCTime5->setFont( lblCTime5_font ); 119 lblCTime5->setFont( lblCTime5_font );
123 lblCTime5->setText( tr( "" ) ); 120 lblCTime5->setText( tr( "" ) );
124 lblCTime5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 121 lblCTime5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
125 122
126 Layout2->addWidget( lblCTime5, 4, 1 ); 123 Layout2->addWidget( lblCTime5, 4, 1 );
127 124
128 lblCTime2 = new QLabel( buttonWidget, "lblCTime2" ); 125 lblCTime2 = new QLabel( buttonWidget, "lblCTime2" );
129 lblCTime2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime2->sizePolicy().hasHeightForWidth() ) ); 126 lblCTime2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime2->sizePolicy().hasHeightForWidth() ) );
130 QFont lblCTime2_font( lblCTime2->font() ); 127 QFont lblCTime2_font( lblCTime2->font() );
131 lblCTime2_font.setPointSize( 10 ); 128 lblCTime2_font.setPointSize( 10 );
132 lblCTime2->setFont( lblCTime2_font ); 129 lblCTime2->setFont( lblCTime2_font );
133 lblCTime2->setText( tr( "" ) ); 130 lblCTime2->setText( tr( "" ) );
134 lblCTime2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 131 lblCTime2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
135 132
136 Layout2->addWidget( lblCTime2, 1, 1 ); 133 Layout2->addWidget( lblCTime2, 1, 1 );
137 134
138 lblCTime1 = new QLabel( buttonWidget, "lblCTime1" ); 135 lblCTime1 = new QLabel( buttonWidget, "lblCTime1" );
139 lblCTime1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime1->sizePolicy().hasHeightForWidth() ) ); 136 lblCTime1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime1->sizePolicy().hasHeightForWidth() ) );
140 QFont lblCTime1_font( lblCTime1->font() ); 137 QFont lblCTime1_font( lblCTime1->font() );
141 lblCTime1_font.setPointSize( 10 ); 138 lblCTime1_font.setPointSize( 10 );
142 lblCTime1->setFont( lblCTime1_font ); 139 lblCTime1->setFont( lblCTime1_font );
143 lblCTime1->setText( tr( "" ) ); 140 lblCTime1->setText( tr( "" ) );
144 lblCTime1->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 141 lblCTime1->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
145 142
146 Layout2->addWidget( lblCTime1, 0, 1 ); 143 Layout2->addWidget( lblCTime1, 0, 1 );
147 144
148 cmdCity3 = new QToolButton( buttonWidget, "cmdCity3" ); 145 cmdCity3 = new QToolButton( buttonWidget, "cmdCity3" );
149 cmdCity3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity3->sizePolicy().hasHeightForWidth() ) ); 146 cmdCity3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity3->sizePolicy().hasHeightForWidth() ) );
150 QFont cmdCity3_font( cmdCity3->font() ); 147 QFont cmdCity3_font( cmdCity3->font() );
151 cmdCity3_font.setBold( TRUE ); 148 cmdCity3_font.setBold( TRUE );
152 cmdCity3->setFont( cmdCity3_font ); 149 cmdCity3->setFont( cmdCity3_font );
153 cmdCity3->setFocusPolicy( QToolButton::TabFocus ); 150 cmdCity3->setFocusPolicy( QToolButton::TabFocus );
154 cmdCity3->setText( tr( "" ) ); 151 cmdCity3->setText( tr( "" ) );
155 cmdCity3->setToggleButton( TRUE ); 152 cmdCity3->setToggleButton( TRUE );
156 cmdCity3->setToggleButton( TRUE ); 153 cmdCity3->setToggleButton( TRUE );
157 154
158 Layout2->addWidget( cmdCity3, 2, 0 ); 155 Layout2->addWidget( cmdCity3, 2, 0 );
159 156
160 lblCTime8 = new QLabel( buttonWidget, "lblCTime8" ); 157 lblCTime8 = new QLabel( buttonWidget, "lblCTime8" );
161 lblCTime8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime8->sizePolicy().hasHeightForWidth() ) ); 158 lblCTime8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime8->sizePolicy().hasHeightForWidth() ) );
162 QFont lblCTime8_font( lblCTime8->font() ); 159 QFont lblCTime8_font( lblCTime8->font() );
163 lblCTime8_font.setPointSize( 10 ); 160 lblCTime8_font.setPointSize( 10 );
164 lblCTime8->setFont( lblCTime8_font ); 161 lblCTime8->setFont( lblCTime8_font );
165 lblCTime8->setText( tr( "" ) ); 162 lblCTime8->setText( tr( "" ) );
166 lblCTime8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 163 lblCTime8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
167 164
168 Layout2->addWidget( lblCTime8, 1, 3 ); 165 Layout2->addWidget( lblCTime8, 1, 3 );
169 166
170 cmdCity1 = new QToolButton( buttonWidget, "cmdCity1" ); 167 cmdCity1 = new QToolButton( buttonWidget, "cmdCity1" );
171 cmdCity1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity1->sizePolicy().hasHeightForWidth() ) ); 168 cmdCity1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity1->sizePolicy().hasHeightForWidth() ) );
172 QFont cmdCity1_font( cmdCity1->font() ); 169 QFont cmdCity1_font( cmdCity1->font() );
173 cmdCity1_font.setBold( TRUE ); 170 cmdCity1_font.setBold( TRUE );
174 cmdCity1->setFont( cmdCity1_font ); 171 cmdCity1->setFont( cmdCity1_font );
175 cmdCity1->setFocusPolicy( QToolButton::TabFocus ); 172 cmdCity1->setFocusPolicy( QToolButton::TabFocus );
176 cmdCity1->setText( tr( "" ) ); 173 cmdCity1->setText( tr( "" ) );
177 cmdCity1->setToggleButton( TRUE ); 174 cmdCity1->setToggleButton( TRUE );
178 cmdCity1->setToggleButton( TRUE ); 175 cmdCity1->setToggleButton( TRUE );
179 176
180 Layout2->addWidget( cmdCity1, 0, 0 ); 177 Layout2->addWidget( cmdCity1, 0, 0 );
181 178
182 lblCTime7 = new QLabel( buttonWidget, "lblCTime7" ); 179 lblCTime7 = new QLabel( buttonWidget, "lblCTime7" );
183 lblCTime7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime7->sizePolicy().hasHeightForWidth() ) ); 180 lblCTime7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime7->sizePolicy().hasHeightForWidth() ) );
184 QFont lblCTime7_font( lblCTime7->font() ); 181 QFont lblCTime7_font( lblCTime7->font() );
185 lblCTime7_font.setPointSize( 10 ); 182 lblCTime7_font.setPointSize( 10 );
186 lblCTime7->setFont( lblCTime7_font ); 183 lblCTime7->setFont( lblCTime7_font );
187 lblCTime7->setText( tr( "" ) ); 184 lblCTime7->setText( tr( "" ) );
188 lblCTime7->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 185 lblCTime7->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
189 186
190 Layout2->addWidget( lblCTime7, 0, 3 ); 187 Layout2->addWidget( lblCTime7, 0, 3 );
191 188
192 lblCTime4 = new QLabel( buttonWidget, "lblCTime4" ); 189 lblCTime4 = new QLabel( buttonWidget, "lblCTime4" );
193 QFont lblCTime4_font( lblCTime4->font() ); 190 QFont lblCTime4_font( lblCTime4->font() );
194 lblCTime4_font.setPointSize( 10 ); 191 lblCTime4_font.setPointSize( 10 );
195 lblCTime4->setFont( lblCTime4_font ); 192 lblCTime4->setFont( lblCTime4_font );
196 lblCTime4->setText( tr( "" ) ); 193 lblCTime4->setText( tr( "" ) );
197 lblCTime4->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 194 lblCTime4->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
198 195
199 Layout2->addWidget( lblCTime4, 3, 1 ); 196 Layout2->addWidget( lblCTime4, 3, 1 );
200 197
201 cmdCity5 = new QToolButton( buttonWidget, "cmdCity5" ); 198 cmdCity5 = new QToolButton( buttonWidget, "cmdCity5" );
202 cmdCity5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity5->sizePolicy().hasHeightForWidth() ) ); 199 cmdCity5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity5->sizePolicy().hasHeightForWidth() ) );
203 QFont cmdCity5_font( cmdCity5->font() ); 200 QFont cmdCity5_font( cmdCity5->font() );
204 cmdCity5_font.setBold( TRUE ); 201 cmdCity5_font.setBold( TRUE );
205 cmdCity5->setFont( cmdCity5_font ); 202 cmdCity5->setFont( cmdCity5_font );
206 cmdCity5->setFocusPolicy( QToolButton::TabFocus ); 203 cmdCity5->setFocusPolicy( QToolButton::TabFocus );
207 cmdCity5->setText( tr( "" ) ); 204 cmdCity5->setText( tr( "" ) );
208 cmdCity5->setToggleButton( TRUE ); 205 cmdCity5->setToggleButton( TRUE );
209 cmdCity5->setToggleButton( TRUE ); 206 cmdCity5->setToggleButton( TRUE );
210 207
211 Layout2->addWidget( cmdCity5, 4, 0 ); 208 Layout2->addWidget( cmdCity5, 4, 0 );
212 209
213 lblCTime3 = new QLabel( buttonWidget, "lblCTime3" ); 210 lblCTime3 = new QLabel( buttonWidget, "lblCTime3" );
214 QFont lblCTime3_font( lblCTime3->font() ); 211 QFont lblCTime3_font( lblCTime3->font() );
215 lblCTime3_font.setPointSize( 10 ); 212 lblCTime3_font.setPointSize( 10 );
216 lblCTime3->setFont( lblCTime3_font ); 213 lblCTime3->setFont( lblCTime3_font );
217 lblCTime3->setText( tr( "" ) ); 214 lblCTime3->setText( tr( "" ) );
218 lblCTime3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 215 lblCTime3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
219 216
220 Layout2->addWidget( lblCTime3, 2, 1 ); 217 Layout2->addWidget( lblCTime3, 2, 1 );
221 218
222 cmdCity9 = new QToolButton( buttonWidget, "cmdCity9" ); 219 cmdCity9 = new QToolButton( buttonWidget, "cmdCity9" );
223 cmdCity9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity9->sizePolicy().hasHeightForWidth() ) ); 220 cmdCity9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity9->sizePolicy().hasHeightForWidth() ) );
224 QFont cmdCity9_font( cmdCity9->font() ); 221 QFont cmdCity9_font( cmdCity9->font() );
225 cmdCity9_font.setBold( TRUE ); 222 cmdCity9_font.setBold( TRUE );
226 cmdCity9->setFont( cmdCity9_font ); 223 cmdCity9->setFont( cmdCity9_font );
227 cmdCity9->setFocusPolicy( QToolButton::TabFocus ); 224 cmdCity9->setFocusPolicy( QToolButton::TabFocus );
228 cmdCity9->setText( tr( "" ) ); 225 cmdCity9->setText( tr( "" ) );
229 cmdCity9->setToggleButton( TRUE ); 226 cmdCity9->setToggleButton( TRUE );
230 cmdCity9->setToggleButton( TRUE ); 227 cmdCity9->setToggleButton( TRUE );
231 228
232 Layout2->addWidget( cmdCity9, 2, 2 ); 229 Layout2->addWidget( cmdCity9, 2, 2 );
233 CityTimeBaseLayout->addWidget( buttonWidget ); 230 CityTimeBaseLayout->addWidget( buttonWidget );
234 231
235 // signals and slots connections 232 // signals and slots connections
236 connect( frmMap, SIGNAL( signalTz(const QString &, const QString &) ), this, SLOT( slotNewTz(const QString &, const QString &) ) ); 233 connect( frmMap, SIGNAL( signalTz(const QString &, const QString &) ), this, SLOT( slotNewTz(const QString &, const QString &) ) );
237 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 234 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
238 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 235 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
239 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 236 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
240 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 237 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
241 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 238 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
242 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 239 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
243 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 240 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
244 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 241 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
245 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 242 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
246 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 243 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
247 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 244 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
248 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 245 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
249 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 246 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
250 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 247 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
251 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 248 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
252 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 249 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
253 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 250 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
254 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 251 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
255 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 252 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
256 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 253 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
257 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 254 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
258 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 255 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
259 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 256 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
260 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 257 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
261 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 258 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
262 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 259 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
263 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 260 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
264 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 261 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
265 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 262 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
266 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 263 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
267 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 264 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
268 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 265 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
269 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 266 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
270 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 267 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
271 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 268 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
272 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 269 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
273 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 270 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
274 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 271 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
275 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 272 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
276 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 273 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
277 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 274 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
278 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 275 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
279 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 276 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
280 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 277 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
281 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 278 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
282 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 279 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
283 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 280 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
284 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 281 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
285 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 282 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
286 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 283 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
287 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 284 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
288 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 285 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
289 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 286 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
290 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 287 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
291 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 288 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
292 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 289 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
293 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 290 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
294 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 291 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
295 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 292 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
296 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 293 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
297 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 294 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
298 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 295 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
299 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 296 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
300 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 297 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
301 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 298 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
302 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 299 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
303 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 300 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
304 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 301 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
305 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 302 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
306 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 303 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
307 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 304 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
308 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 305 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
309 connect( cmdCity1, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 306 connect( cmdCity1, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
310 connect( cmdCity2, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 307 connect( cmdCity2, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
311 connect( cmdCity7, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 308 connect( cmdCity7, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
312 connect( cmdCity3, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 309 connect( cmdCity3, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
313 connect( cmdCity4, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 310 connect( cmdCity4, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
314 connect( cmdCity5, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 311 connect( cmdCity5, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
315 connect( cmdCity6, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 312 connect( cmdCity6, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
316 connect( cmdCity8, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 313 connect( cmdCity8, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
317 connect( cmdCity9, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 314 connect( cmdCity9, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
318 315
319 // tab order 316 // tab order
320 setTabOrder( cmdCity1, cmdCity2 ); 317 setTabOrder( cmdCity1, cmdCity2 );
321 setTabOrder( cmdCity2, cmdCity3 ); 318 setTabOrder( cmdCity2, cmdCity3 );
322 setTabOrder( cmdCity3, cmdCity4 ); 319 setTabOrder( cmdCity3, cmdCity4 );
323 setTabOrder( cmdCity4, cmdCity5 ); 320 setTabOrder( cmdCity4, cmdCity5 );
324 setTabOrder( cmdCity5, cmdCity6 ); 321 setTabOrder( cmdCity5, cmdCity6 );
325 setTabOrder( cmdCity6, cmdCity7 ); 322 setTabOrder( cmdCity6, cmdCity7 );
326 setTabOrder( cmdCity7, cmdCity8 ); 323 setTabOrder( cmdCity7, cmdCity8 );
327 setTabOrder( cmdCity8, cmdCity9 ); 324 setTabOrder( cmdCity8, cmdCity9 );
328 setTabOrder( cmdCity9, frmMap ); 325 setTabOrder( cmdCity9, frmMap );
329} 326}
330 327
331/* 328/*
332 * Destroys the object and frees any allocated resources 329 * Destroys the object and frees any allocated resources
333 */ 330 */
334CityTimeBase::~CityTimeBase() 331CityTimeBase::~CityTimeBase()
335{ 332{
336 // no need to delete child widgets, Qt does it all for us 333 // no need to delete child widgets, Qt does it all for us
337} 334}
338 335
339/* 336/*
340 * Main event handler. Reimplemented to handle application 337 * Main event handler. Reimplemented to handle application
341 * font changes 338 * font changes
342 */ 339 */
343bool CityTimeBase::event( QEvent* ev ) 340bool CityTimeBase::event( QEvent* ev )
344{ 341{
345 bool ret = QWidget::event( ev ); 342 bool ret = QWidget::event( ev );
346 if ( ev->type() == QEvent::ApplicationFontChange ) { 343 if ( ev->type() == QEvent::ApplicationFontChange ) {
347 QFont cmdCity7_font( cmdCity7->font() ); 344 QFont cmdCity7_font( cmdCity7->font() );
348 cmdCity7_font.setBold( TRUE ); 345 cmdCity7_font.setBold( TRUE );
349 cmdCity7->setFont( cmdCity7_font ); 346 cmdCity7->setFont( cmdCity7_font );
350 QFont lblCTime9_font( lblCTime9->font() ); 347 QFont lblCTime9_font( lblCTime9->font() );
351 lblCTime9_font.setPointSize( 10 ); 348 lblCTime9_font.setPointSize( 10 );
352 lblCTime9->setFont( lblCTime9_font ); 349 lblCTime9->setFont( lblCTime9_font );
353 QFont cmdCity8_font( cmdCity8->font() ); 350 QFont cmdCity8_font( cmdCity8->font() );
354 cmdCity8_font.setBold( TRUE ); 351 cmdCity8_font.setBold( TRUE );
355 cmdCity8->setFont( cmdCity8_font ); 352 cmdCity8->setFont( cmdCity8_font );
356 QFont cmdCity2_font( cmdCity2->font() ); 353 QFont cmdCity2_font( cmdCity2->font() );
357 cmdCity2_font.setBold( TRUE ); 354 cmdCity2_font.setBold( TRUE );
358 cmdCity2->setFont( cmdCity2_font ); 355 cmdCity2->setFont( cmdCity2_font );
359 QFont lblCTime6_font( lblCTime6->font() ); 356 QFont lblCTime6_font( lblCTime6->font() );
360 lblCTime6_font.setPointSize( 10 ); 357 lblCTime6_font.setPointSize( 10 );
361 lblCTime6->setFont( lblCTime6_font ); 358 lblCTime6->setFont( lblCTime6_font );
362 QFont cmdCity6_font( cmdCity6->font() ); 359 QFont cmdCity6_font( cmdCity6->font() );
363 cmdCity6_font.setBold( TRUE ); 360 cmdCity6_font.setBold( TRUE );
364 cmdCity6->setFont( cmdCity6_font ); 361 cmdCity6->setFont( cmdCity6_font );
365 QFont cmdCity4_font( cmdCity4->font() ); 362 QFont cmdCity4_font( cmdCity4->font() );
366 cmdCity4_font.setBold( TRUE ); 363 cmdCity4_font.setBold( TRUE );
367 cmdCity4->setFont( cmdCity4_font ); 364 cmdCity4->setFont( cmdCity4_font );
368 QFont lblCTime5_font( lblCTime5->font() ); 365 QFont lblCTime5_font( lblCTime5->font() );
369 lblCTime5_font.setPointSize( 10 ); 366 lblCTime5_font.setPointSize( 10 );
370 lblCTime5->setFont( lblCTime5_font ); 367 lblCTime5->setFont( lblCTime5_font );
371 QFont lblCTime2_font( lblCTime2->font() ); 368 QFont lblCTime2_font( lblCTime2->font() );
372 lblCTime2_font.setPointSize( 10 ); 369 lblCTime2_font.setPointSize( 10 );
373 lblCTime2->setFont( lblCTime2_font ); 370 lblCTime2->setFont( lblCTime2_font );
374 QFont lblCTime1_font( lblCTime1->font() ); 371 QFont lblCTime1_font( lblCTime1->font() );
375 lblCTime1_font.setPointSize( 10 ); 372 lblCTime1_font.setPointSize( 10 );
376 lblCTime1->setFont( lblCTime1_font ); 373 lblCTime1->setFont( lblCTime1_font );
377 QFont cmdCity3_font( cmdCity3->font() ); 374 QFont cmdCity3_font( cmdCity3->font() );
378 cmdCity3_font.setBold( TRUE ); 375 cmdCity3_font.setBold( TRUE );
379 cmdCity3->setFont( cmdCity3_font ); 376 cmdCity3->setFont( cmdCity3_font );
380 QFont lblCTime8_font( lblCTime8->font() ); 377 QFont lblCTime8_font( lblCTime8->font() );
381 lblCTime8_font.setPointSize( 10 ); 378 lblCTime8_font.setPointSize( 10 );
382 lblCTime8->setFont( lblCTime8_font ); 379 lblCTime8->setFont( lblCTime8_font );
383 QFont cmdCity1_font( cmdCity1->font() ); 380 QFont cmdCity1_font( cmdCity1->font() );
384 cmdCity1_font.setBold( TRUE ); 381 cmdCity1_font.setBold( TRUE );
385 cmdCity1->setFont( cmdCity1_font ); 382 cmdCity1->setFont( cmdCity1_font );
386 QFont lblCTime7_font( lblCTime7->font() ); 383 QFont lblCTime7_font( lblCTime7->font() );
387 lblCTime7_font.setPointSize( 10 ); 384 lblCTime7_font.setPointSize( 10 );
388 lblCTime7->setFont( lblCTime7_font ); 385 lblCTime7->setFont( lblCTime7_font );
389 QFont lblCTime4_font( lblCTime4->font() ); 386 QFont lblCTime4_font( lblCTime4->font() );
390 lblCTime4_font.setPointSize( 10 ); 387 lblCTime4_font.setPointSize( 10 );
391 lblCTime4->setFont( lblCTime4_font ); 388 lblCTime4->setFont( lblCTime4_font );
392 QFont cmdCity5_font( cmdCity5->font() ); 389 QFont cmdCity5_font( cmdCity5->font() );
393 cmdCity5_font.setBold( TRUE ); 390 cmdCity5_font.setBold( TRUE );
394 cmdCity5->setFont( cmdCity5_font ); 391 cmdCity5->setFont( cmdCity5_font );
395 QFont lblCTime3_font( lblCTime3->font() ); 392 QFont lblCTime3_font( lblCTime3->font() );
396 lblCTime3_font.setPointSize( 10 ); 393 lblCTime3_font.setPointSize( 10 );
397 lblCTime3->setFont( lblCTime3_font ); 394 lblCTime3->setFont( lblCTime3_font );
398 QFont cmdCity9_font( cmdCity9->font() ); 395 QFont cmdCity9_font( cmdCity9->font() );
399 cmdCity9_font.setBold( TRUE ); 396 cmdCity9_font.setBold( TRUE );
400 cmdCity9->setFont( cmdCity9_font ); 397 cmdCity9->setFont( cmdCity9_font );
401 } 398 }
402 return ret; 399 return ret;
403} 400}
404 401
405void CityTimeBase::beginNewTz() 402void CityTimeBase::beginNewTz()
406{ 403{
407 qWarning( "CityTimeBase::beginNewTz(): Not implemented yet!" ); 404 qWarning( "CityTimeBase::beginNewTz(): Not implemented yet!" );
408} 405}
409 406
410void CityTimeBase::slotNewTz(const QString &, const QString &) 407void CityTimeBase::slotNewTz(const QString &, const QString &)
411{ 408{
412 qWarning( "CityTimeBase::slotNewTz(const QString &, const QString &): Not implemented yet!" ); 409 qWarning( "CityTimeBase::slotNewTz(const QString &, const QString &): Not implemented yet!" );
413} 410}
414 411
diff --git a/core/settings/citytime/main.cpp b/core/settings/citytime/main.cpp
index 69bfe44..59498b7 100644
--- a/core/settings/citytime/main.cpp
+++ b/core/settings/citytime/main.cpp
@@ -1,25 +1,24 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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#include "citytime.h" 21#include "citytime.h"
22#include <qpe/qpeapplication.h>
23#include <opie/oapplicationfactory.h> 22#include <opie/oapplicationfactory.h>
24 23
25OPIE_EXPORT_APP( OApplicationFactory<CityTime> ) 24OPIE_EXPORT_APP( OApplicationFactory<CityTime> )
diff --git a/core/settings/citytime/stylusnormalizer.cpp b/core/settings/citytime/stylusnormalizer.cpp
index c6c65d2..281a0bc 100644
--- a/core/settings/citytime/stylusnormalizer.cpp
+++ b/core/settings/citytime/stylusnormalizer.cpp
@@ -1,99 +1,98 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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#include <qpoint.h>
22#include <qtimer.h> 21#include <qtimer.h>
23 22
24#include "stylusnormalizer.h" 23#include "stylusnormalizer.h"
25 24
26static const int FLUSHTIME = 100; 25static const int FLUSHTIME = 100;
27 26
28_StylusEvent::_StylusEvent( const QPoint& newPt ) 27_StylusEvent::_StylusEvent( const QPoint& newPt )
29 : _pt( newPt ), 28 : _pt( newPt ),
30 _t( QTime::currentTime() ) 29 _t( QTime::currentTime() )
31{ 30{
32} 31}
33 32
34_StylusEvent::~_StylusEvent() 33_StylusEvent::~_StylusEvent()
35{ 34{
36} 35}
37 36
38StylusNormalizer::StylusNormalizer( QWidget *parent, const char* name ) 37StylusNormalizer::StylusNormalizer( QWidget *parent, const char* name )
39 : QWidget( parent, name ), 38 : QWidget( parent, name ),
40 _next( 0 ), 39 _next( 0 ),
41 bFirst( true ) 40 bFirst( true )
42{ 41{
43 // initialize _ptList 42 // initialize _ptList
44 int i; 43 int i;
45 for (i = 0; i < SAMPLES; i++ ) { 44 for (i = 0; i < SAMPLES; i++ ) {
46 _ptList[i].setPoint( -1, -1 ); 45 _ptList[i].setPoint( -1, -1 );
47 } 46 }
48 _tExpire = new QTimer( this ); 47 _tExpire = new QTimer( this );
49 QObject::connect( _tExpire, SIGNAL( timeout() ), 48 QObject::connect( _tExpire, SIGNAL( timeout() ),
50 this, SLOT( slotAveragePoint() ) ); 49 this, SLOT( slotAveragePoint() ) );
51} 50}
52 51
53StylusNormalizer::~StylusNormalizer() 52StylusNormalizer::~StylusNormalizer()
54{ 53{
55} 54}
56 55
57void StylusNormalizer::addEvent( const QPoint& pt ) 56void StylusNormalizer::addEvent( const QPoint& pt )
58{ 57{
59 _ptList[_next].setPoint( pt ); 58 _ptList[_next].setPoint( pt );
60 _ptList[_next++].setTime( QTime::currentTime() ); 59 _ptList[_next++].setTime( QTime::currentTime() );
61 if ( _next >= SAMPLES ) { 60 if ( _next >= SAMPLES ) {
62 _next = 0; 61 _next = 0;
63 } 62 }
64 // make a single mouse click work 63 // make a single mouse click work
65 if ( bFirst ) { 64 if ( bFirst ) {
66 slotAveragePoint(); 65 slotAveragePoint();
67 bFirst = false; 66 bFirst = false;
68 } 67 }
69} 68}
70 69
71void StylusNormalizer::slotAveragePoint( void ) 70void StylusNormalizer::slotAveragePoint( void )
72{ 71{
73 QPoint pt( 0, 0 ); 72 QPoint pt( 0, 0 );
74 QTime tCurr = QTime::currentTime(); 73 QTime tCurr = QTime::currentTime();
75 int i, 74 int i,
76 size; 75 size;
77 size = 0; 76 size = 0;
78 for ( i = 0; i < SAMPLES; i++ ) { 77 for ( i = 0; i < SAMPLES; i++ ) {
79 if ( ( (_ptList[i]).time().msecsTo( tCurr ) < FLUSHTIME ) && 78 if ( ( (_ptList[i]).time().msecsTo( tCurr ) < FLUSHTIME ) &&
80 ( _ptList[i].point() != QPoint( -1, -1 ) ) ) { 79 ( _ptList[i].point() != QPoint( -1, -1 ) ) ) {
81 pt += _ptList[i].point(); 80 pt += _ptList[i].point();
82 size++; 81 size++;
83 } 82 }
84 } 83 }
85 if ( size > 0 ) 84 if ( size > 0 )
86 emit signalNewPoint( pt /= size ); 85 emit signalNewPoint( pt /= size );
87} 86}
88 87
89void StylusNormalizer::start( void ) 88void StylusNormalizer::start( void )
90{ 89{
91 _tExpire->start( FLUSHTIME ); 90 _tExpire->start( FLUSHTIME );
92} 91}
93 92
94void StylusNormalizer::stop( void ) 93void StylusNormalizer::stop( void )
95{ 94{
96 _tExpire->stop(); 95 _tExpire->stop();
97 bFirst = true; 96 bFirst = true;
98} 97}
99 98
diff --git a/core/settings/citytime/zonemap.cpp b/core/settings/citytime/zonemap.cpp
index 872e786..b83da59 100644
--- a/core/settings/citytime/zonemap.cpp
+++ b/core/settings/citytime/zonemap.cpp
@@ -1,731 +1,724 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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// changes by Maximilian Reiss <harlekin@handhelds.org> 21// changes by Maximilian Reiss <harlekin@handhelds.org>
22 22
23#include "sun.h" 23#include "sun.h"
24#include "zonemap.h" 24#include "zonemap.h"
25 25
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/timestring.h>
28#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
29 28
30#include <qdatetime.h>
31#include <qfile.h> 29#include <qfile.h>
32#include <qimage.h>
33#include <qlabel.h> 30#include <qlabel.h>
34#include <qlist.h>
35#include <qmessagebox.h> 31#include <qmessagebox.h>
36#include <qpixmap.h>
37#include <qpainter.h>
38#include <qregexp.h>
39#include <qtextstream.h> 32#include <qtextstream.h>
40#include <qtimer.h> 33#include <qtimer.h>
41#include <qtoolbutton.h> 34#include <qtoolbutton.h>
42#include <qlayout.h> 35#include <qlayout.h>
43#include <qhbox.h> 36#include <qhbox.h>
44#include <qlistview.h> 37#include <qlistview.h>
45#include <qwhatsthis.h> 38#include <qwhatsthis.h>
46 39
47#include <limits.h> 40#include <limits.h>
48 41
49// the map file... 42// the map file...
50static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab"; 43static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab";
51static const char strMAP[] = "citytime/simple_grid_400"; 44static const char strMAP[] = "citytime/simple_grid_400";
52 45
53// the maximum distance we'll allow the pointer to be away from a city 46// the maximum distance we'll allow the pointer to be away from a city
54// and still show the city's time 47// and still show the city's time
55static const int iTHRESHOLD = 50000; 48static const int iTHRESHOLD = 50000;
56 49
57// The label offset (how far away from pointer) 50// The label offset (how far away from pointer)
58static const int iLABELOFFSET = 8; 51static const int iLABELOFFSET = 8;
59 52
60// the size of the dot to draw, and where to start it 53// the size of the dot to draw, and where to start it
61static const int iCITYSIZE = 3; 54static const int iCITYSIZE = 3;
62const int iCITYOFFSET = 2; 55const int iCITYOFFSET = 2;
63 56
64// the darkening function 57// the darkening function
65static inline void darken( QImage *pImage, int start, int stop, int row ); 58static inline void darken( QImage *pImage, int start, int stop, int row );
66static void dayNight( QImage *pImage ); 59static void dayNight( QImage *pImage );
67 60
68ZoneField::ZoneField( const QString& strLine ) 61ZoneField::ZoneField( const QString& strLine )
69{ 62{
70 // make a bunch of RegExp's to match the data from the line 63 // make a bunch of RegExp's to match the data from the line
71 QRegExp regCoord( "[-+][0-9]+" );// the latitude 64 QRegExp regCoord( "[-+][0-9]+" );// the latitude
72 QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough) 65 QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough)
73 QRegExp regCity( "[A-Za-z_-]*" ); // the city 66 QRegExp regCity( "[A-Za-z_-]*" ); // the city
74 67
75 int iStart, 68 int iStart,
76 iStop, 69 iStop,
77 iLen, 70 iLen,
78 tmp; 71 tmp;
79 QString strTmp; 72 QString strTmp;
80 // we should be able to assume that the country code is always the first 73 // we should be able to assume that the country code is always the first
81 // two chars, so just grap them and let it go... 74 // two chars, so just grap them and let it go...
82 strCountryCode = strLine.left( 2 ); 75 strCountryCode = strLine.left( 2 );
83 iStart = regCoord.match( strLine, 0, &iLen ); 76 iStart = regCoord.match( strLine, 0, &iLen );
84 if ( iStart >= 0 ) { 77 if ( iStart >= 0 ) {
85 strTmp = strLine.mid( iStart, iLen ); 78 strTmp = strLine.mid( iStart, iLen );
86 tmp = strTmp.toInt(); 79 tmp = strTmp.toInt();
87 // okay, there are two versions of the format, make a decision based on 80 // okay, there are two versions of the format, make a decision based on
88 // the size... 81 // the size...
89 // Oh BTW, we are storing everything in seconds! 82 // Oh BTW, we are storing everything in seconds!
90 if ( iLen < 7 ) { 83 if ( iLen < 7 ) {
91 _y = tmp / 100; 84 _y = tmp / 100;
92 _y *= 60; 85 _y *= 60;
93 _y += tmp % 100; 86 _y += tmp % 100;
94 _y *= 60; 87 _y *= 60;
95 } else { 88 } else {
96 _y = tmp / 10000; 89 _y = tmp / 10000;
97 _y *= 60; 90 _y *= 60;
98 tmp %= 10000; 91 tmp %= 10000;
99 _y += tmp / 100; 92 _y += tmp / 100;
100 _y *= 60; 93 _y *= 60;
101 tmp %= 100; 94 tmp %= 100;
102 _y += tmp; 95 _y += tmp;
103 } 96 }
104 } 97 }
105 iStart = regCoord.match( strLine, iStart + iLen, &iLen ); 98 iStart = regCoord.match( strLine, iStart + iLen, &iLen );
106 if ( iStart >= 0 ) { 99 if ( iStart >= 0 ) {
107 strTmp = strLine.mid( iStart, iLen ); 100 strTmp = strLine.mid( iStart, iLen );
108 tmp = strTmp.toInt(); 101 tmp = strTmp.toInt();
109 if ( iLen < 8 ) { 102 if ( iLen < 8 ) {
110 _x = tmp / 100; 103 _x = tmp / 100;
111 _x *= 60; 104 _x *= 60;
112 _x += tmp % 100; 105 _x += tmp % 100;
113 _x *= 60; 106 _x *= 60;
114 } else { 107 } else {
115 _x = tmp / 10000; 108 _x = tmp / 10000;
116 _x *= 60; 109 _x *= 60;
117 tmp %= 10000; 110 tmp %= 10000;
118 _x += tmp / 100; 111 _x += tmp / 100;
119 _x *= 60; 112 _x *= 60;
120 tmp %= 100; 113 tmp %= 100;
121 _x += tmp; 114 _x += tmp;
122 } 115 }
123 } 116 }
124 iStart = regCountry.match( strLine, 0, &iLen ); 117 iStart = regCountry.match( strLine, 0, &iLen );
125 // help with the shortcoming in 2.x regexp... 118 // help with the shortcoming in 2.x regexp...
126 iStop = strLine.findRev( '/' ); 119 iStop = strLine.findRev( '/' );
127 if ( iStart >= 0 ) { 120 if ( iStart >= 0 ) {
128 iLen = (iStop - iStart) + 1; 121 iLen = (iStop - iStart) + 1;
129 strCountry = strLine.mid( iStart, iLen ); 122 strCountry = strLine.mid( iStart, iLen );
130 } 123 }
131 // now match the city... 124 // now match the city...
132 iStart = regCity.match( strLine, iStart + iLen, &iLen ); 125 iStart = regCity.match( strLine, iStart + iLen, &iLen );
133 if ( iStart >= 0 ) { 126 if ( iStart >= 0 ) {
134 strCity = strLine.mid( iStart, iLen ); 127 strCity = strLine.mid( iStart, iLen );
135 } 128 }
136} 129}
137 130
138void ZoneField::showStructure( void ) const 131void ZoneField::showStructure( void ) const
139{ 132{
140 qDebug( "Country: %s", strCountry.latin1() ); 133 qDebug( "Country: %s", strCountry.latin1() );
141 qDebug( "City: %s", strCity.latin1() ); 134 qDebug( "City: %s", strCity.latin1() );
142 qDebug( "x: %d", _x ); 135 qDebug( "x: %d", _x );
143 qDebug( "y: %d\n", _y ); 136 qDebug( "y: %d\n", _y );
144} 137}
145 138
146ZoneMap::ZoneMap( QWidget *parent, const char* name ) 139ZoneMap::ZoneMap( QWidget *parent, const char* name )
147 : QScrollView( parent, name ), 140 : QScrollView( parent, name ),
148 pLast( 0 ), 141 pLast( 0 ),
149 pRepaint( 0 ), 142 pRepaint( 0 ),
150 ox( 0 ), 143 ox( 0 ),
151 oy( 0 ), 144 oy( 0 ),
152 drawableW( -1 ), 145 drawableW( -1 ),
153 drawableH( -1 ), 146 drawableH( -1 ),
154 bZoom( FALSE ), 147 bZoom( FALSE ),
155 bIllum( TRUE ), 148 bIllum( TRUE ),
156 cursor( 0 ) 149 cursor( 0 )
157{ 150{
158 viewport()->setFocusPolicy( StrongFocus ); 151 viewport()->setFocusPolicy( StrongFocus );
159 152
160 // set mouse tracking so we can use the mouse move event 153 // set mouse tracking so we can use the mouse move event
161 zones.setAutoDelete( true ); 154 zones.setAutoDelete( true );
162 // get the map loaded 155 // get the map loaded
163 // just set the current image to point 156 // just set the current image to point
164 pixCurr = new QPixmap(); 157 pixCurr = new QPixmap();
165 158
166 QPixmap pixZoom = Resource::loadPixmap( "mag" ); 159 QPixmap pixZoom = Resource::loadPixmap( "mag" );
167 160
168 cmdZoom = new QToolButton( this, "Zoom command" ); 161 cmdZoom = new QToolButton( this, "Zoom command" );
169 cmdZoom->setPixmap( pixZoom ); 162 cmdZoom->setPixmap( pixZoom );
170 cmdZoom->setToggleButton( true ); 163 cmdZoom->setToggleButton( true );
171 164
172 cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, 165 cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0,
173 (QSizePolicy::SizeType)0, 166 (QSizePolicy::SizeType)0,
174 cmdZoom->sizePolicy().hasHeightForWidth() ) ); 167 cmdZoom->sizePolicy().hasHeightForWidth() ) );
175 cmdZoom->setMaximumSize( cmdZoom->sizeHint() ); 168 cmdZoom->setMaximumSize( cmdZoom->sizeHint() );
176 // probably don't need this, but just in case... 169 // probably don't need this, but just in case...
177 cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() ); 170 cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() );
178 171
179 172
180 lblCity = new QLabel( tr( "CITY" ), this, "City Label" ); 173 lblCity = new QLabel( tr( "CITY" ), this, "City Label" );
181 lblCity->setMinimumSize( lblCity->sizeHint() ); 174 lblCity->setMinimumSize( lblCity->sizeHint() );
182 lblCity->setFrameStyle( QFrame::Plain | QFrame::Box ); 175 lblCity->setFrameStyle( QFrame::Plain | QFrame::Box );
183 lblCity->setBackgroundColor( yellow ); 176 lblCity->setBackgroundColor( yellow );
184 lblCity->hide(); 177 lblCity->hide();
185 178
186 // A timer to make sure the label gets hidden 179 // A timer to make sure the label gets hidden
187 tHide = new QTimer( this, "Label Timer" ); 180 tHide = new QTimer( this, "Label Timer" );
188 QObject::connect( tHide, SIGNAL( timeout() ), 181 QObject::connect( tHide, SIGNAL( timeout() ),
189 lblCity, SLOT( hide() ) ); 182 lblCity, SLOT( hide() ) );
190 QObject::connect( tHide, SIGNAL( timeout() ), 183 QObject::connect( tHide, SIGNAL( timeout() ),
191 this, SLOT( slotRedraw() ) ); 184 this, SLOT( slotRedraw() ) );
192 QTimer *tUpdate = new QTimer( this, "Update Timer" ); 185 QTimer *tUpdate = new QTimer( this, "Update Timer" );
193 QObject::connect( tUpdate, SIGNAL( timeout() ), 186 QObject::connect( tUpdate, SIGNAL( timeout() ),
194 this, SLOT( slotUpdate() ) ); 187 this, SLOT( slotUpdate() ) );
195 QObject::connect( qApp, SIGNAL( timeChanged() ), 188 QObject::connect( qApp, SIGNAL( timeChanged() ),
196 this, SLOT( slotUpdate() ) ); 189 this, SLOT( slotUpdate() ) );
197 QObject::connect( cmdZoom, SIGNAL( toggled( bool ) ), 190 QObject::connect( cmdZoom, SIGNAL( toggled( bool ) ),
198 this, SLOT( slotZoom( bool ) ) ); 191 this, SLOT( slotZoom( bool ) ) );
199 QObject::connect( &norm, SIGNAL( signalNewPoint( const QPoint& ) ), 192 QObject::connect( &norm, SIGNAL( signalNewPoint( const QPoint& ) ),
200 this, SLOT( slotFindCity( const QPoint& ) ) ); 193 this, SLOT( slotFindCity( const QPoint& ) ) );
201 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), 194 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ),
202 this, SLOT( changeClock( bool ) ) ); 195 this, SLOT( changeClock( bool ) ) );
203 // update the sun's movement every 5 minutes 196 // update the sun's movement every 5 minutes
204 tUpdate->start( 5 * 60 * 1000 ); 197 tUpdate->start( 5 * 60 * 1000 );
205 // May as well read in the timezone information too... 198 // May as well read in the timezone information too...
206 readZones(); 199 readZones();
207} 200}
208 201
209ZoneMap::~ZoneMap() 202ZoneMap::~ZoneMap()
210{ 203{
211} 204}
212 205
213void ZoneMap::readZones( void ) 206void ZoneMap::readZones( void )
214{ 207{
215 QFile fZone( strZONEINFO ); 208 QFile fZone( strZONEINFO );
216 if ( !fZone.open( IO_ReadOnly ) ) { 209 if ( !fZone.open( IO_ReadOnly ) ) {
217 QMessageBox::warning (this, 210 QMessageBox::warning (this,
218 tr( "Unable to Find Timezone Info" ), 211 tr( "Unable to Find Timezone Info" ),
219 tr( "<p>Unable to find any timezone information in %1" ) 212 tr( "<p>Unable to find any timezone information in %1" )
220 .arg( strZONEINFO )); 213 .arg( strZONEINFO ));
221 exit(-1); 214 exit(-1);
222 } else { 215 } else {
223 QTextStream tZone( &fZone ); 216 QTextStream tZone( &fZone );
224 while ( !tZone.atEnd() ) { 217 while ( !tZone.atEnd() ) {
225 QString strLine = tZone.readLine(); 218 QString strLine = tZone.readLine();
226 // only pass on lines that aren't comments 219 // only pass on lines that aren't comments
227 if ( strLine[0] != '#' ) { 220 if ( strLine[0] != '#' ) {
228 zones.append( new ZoneField( strLine ) ); 221 zones.append( new ZoneField( strLine ) );
229 } 222 }
230 } 223 }
231 fZone.close(); 224 fZone.close();
232 } 225 }
233} 226}
234 227
235void ZoneMap::viewportMousePressEvent( QMouseEvent* event ) 228void ZoneMap::viewportMousePressEvent( QMouseEvent* event )
236{ 229{
237 // add the mouse event into the normalizer, and get the average, 230 // add the mouse event into the normalizer, and get the average,
238 // pass it along 231 // pass it along
239 slotRedraw(); 232 slotRedraw();
240 norm.start(); 233 norm.start();
241 norm.addEvent( event->pos() ); 234 norm.addEvent( event->pos() );
242} 235}
243 236
244void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event ) 237void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event )
245{ 238{
246 norm.addEvent( event->pos() ); 239 norm.addEvent( event->pos() );
247} 240}
248 241
249void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* ) 242void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* )
250{ 243{
251 // get the averaged points in case a timeout hasn't occurred, 244 // get the averaged points in case a timeout hasn't occurred,
252 // more for "mouse clicks" 245 // more for "mouse clicks"
253 norm.stop(); 246 norm.stop();
254 if ( pLast != NULL ) { 247 if ( pLast != NULL ) {
255 emit signalTz( pLast->country(), pLast->city() ); 248 emit signalTz( pLast->country(), pLast->city() );
256 pLast = NULL; 249 pLast = NULL;
257 } 250 }
258 tHide->start( 2000, true ); 251 tHide->start( 2000, true );
259} 252}
260 253
261void ZoneMap::keyPressEvent( QKeyEvent *ke ) 254void ZoneMap::keyPressEvent( QKeyEvent *ke )
262{ 255{
263 switch ( ke->key() ) { 256 switch ( ke->key() ) {
264 case Key_Left: 257 case Key_Left:
265 case Key_Right: 258 case Key_Right:
266 case Key_Up: 259 case Key_Up:
267 case Key_Down: { 260 case Key_Down: {
268 tHide->stop(); 261 tHide->stop();
269 if ( !cursor ) 262 if ( !cursor )
270 slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 ); 263 slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 );
271 ZoneField *city = findCityNear( cursor, ke->key() ); 264 ZoneField *city = findCityNear( cursor, ke->key() );
272 if ( city ) { 265 if ( city ) {
273 cursor = city; 266 cursor = city;
274 int tmpx, tmpy; 267 int tmpx, tmpy;
275 zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy ); 268 zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy );
276 ensureVisible( tmpx, tmpy ); 269 ensureVisible( tmpx, tmpy );
277 showCity( cursor ); 270 showCity( cursor );
278 tHide->start( 3000, true ); 271 tHide->start( 3000, true );
279 } 272 }
280 } 273 }
281 break; 274 break;
282 275
283 case Key_Space: 276 case Key_Space:
284 case Key_Enter: 277 case Key_Enter:
285 case Key_Return: 278 case Key_Return:
286 if ( cursor ) { 279 if ( cursor ) {
287 emit signalTz( cursor->country(), cursor->city() ); 280 emit signalTz( cursor->country(), cursor->city() );
288 tHide->start( 0, true ); 281 tHide->start( 0, true );
289 } 282 }
290 break; 283 break;
291 } 284 }
292} 285}
293 286
294ZoneField *ZoneMap::findCityNear( ZoneField *city, int key ) 287ZoneField *ZoneMap::findCityNear( ZoneField *city, int key )
295{ 288{
296 ZoneField *pZone; 289 ZoneField *pZone;
297 ZoneField *pClosest = 0; 290 ZoneField *pClosest = 0;
298 long ddist = LONG_MAX; 291 long ddist = LONG_MAX;
299 292
300 QListIterator<ZoneField> it( zones ); 293 QListIterator<ZoneField> it( zones );
301 for (; it.current(); ++it) { 294 for (; it.current(); ++it) {
302 pZone = it.current(); 295 pZone = it.current();
303 long dx = (pZone->x() - city->x())/100; 296 long dx = (pZone->x() - city->x())/100;
304 long dy = (pZone->y() - city->y())/100; 297 long dy = (pZone->y() - city->y())/100;
305 switch ( key ) { 298 switch ( key ) {
306 case Key_Right: 299 case Key_Right:
307 case Key_Left: 300 case Key_Left:
308 if ( key == Key_Left ) 301 if ( key == Key_Left )
309 dx = -dx; 302 dx = -dx;
310 if ( dx > 0 ) { 303 if ( dx > 0 ) {
311 long dist = QABS(dy)*4 + dx; 304 long dist = QABS(dy)*4 + dx;
312 if ( dist < ddist ) { 305 if ( dist < ddist ) {
313 ddist = dist; 306 ddist = dist;
314 pClosest = pZone; 307 pClosest = pZone;
315 } 308 }
316 } 309 }
317 break; 310 break;
318 case Key_Down: 311 case Key_Down:
319 case Key_Up: 312 case Key_Up:
320 if ( key == Key_Down ) 313 if ( key == Key_Down )
321 dy = -dy; 314 dy = -dy;
322 if ( dy > 0 ) { 315 if ( dy > 0 ) {
323 long dist = QABS(dx)*4 + dy; 316 long dist = QABS(dx)*4 + dy;
324 if ( dist < ddist ) { 317 if ( dist < ddist ) {
325 ddist = dist; 318 ddist = dist;
326 pClosest = pZone; 319 pClosest = pZone;
327 } 320 }
328 } 321 }
329 break; 322 break;
330 } 323 }
331 } 324 }
332 325
333 return pClosest; 326 return pClosest;
334} 327}
335 328
336void ZoneMap::slotFindCity( const QPoint &pos ) 329void ZoneMap::slotFindCity( const QPoint &pos )
337{ 330{
338 lblCity->hide(); 331 lblCity->hide();
339 // given coordinates on the screen find the closest city and display the 332 // given coordinates on the screen find the closest city and display the
340 // label close to it 333 // label close to it
341 int tmpx, tmpy, x, y; 334 int tmpx, tmpy, x, y;
342 long lDistance, 335 long lDistance,
343 lClosest; 336 lClosest;
344 ZoneField *pZone, 337 ZoneField *pZone,
345 *pClosest; 338 *pClosest;
346 339
347 if ( tHide->isActive() ) { 340 if ( tHide->isActive() ) {
348 tHide->stop(); 341 tHide->stop();
349 } 342 }
350 viewportToContents(pos.x(), pos.y(), tmpx, tmpy); 343 viewportToContents(pos.x(), pos.y(), tmpx, tmpy);
351 winToZone( tmpx, tmpy, x, y ); 344 winToZone( tmpx, tmpy, x, y );
352 // Find city alogorithim: start out at an (near) infinite distance away and 345 // Find city alogorithim: start out at an (near) infinite distance away and
353 // then find the closest city, (similar to the Z-buffer technique, I guess) 346 // then find the closest city, (similar to the Z-buffer technique, I guess)
354 // the only problem is that this is all done with doubles, but I don't know 347 // the only problem is that this is all done with doubles, but I don't know
355 // another way to do it at the moment. Another problem is a linked list is 348 // another way to do it at the moment. Another problem is a linked list is
356 // used obviously something indexed would help 349 // used obviously something indexed would help
357 QListIterator<ZoneField> it( zones ); 350 QListIterator<ZoneField> it( zones );
358 pClosest = 0; 351 pClosest = 0;
359 lClosest = LONG_MAX; 352 lClosest = LONG_MAX;
360 for (; it.current(); ++it) { 353 for (; it.current(); ++it) {
361 pZone = it.current(); 354 pZone = it.current();
362 // use the manhattenLength, a good enough of an appoximation here 355 // use the manhattenLength, a good enough of an appoximation here
363 lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() ); 356 lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() );
364 // first to zero wins! 357 // first to zero wins!
365 if ( lDistance < lClosest ) { 358 if ( lDistance < lClosest ) {
366 lClosest = lDistance; 359 lClosest = lDistance;
367 pClosest = pZone; 360 pClosest = pZone;
368 } 361 }
369 } 362 }
370 363
371 // Okay, we found the closest city, but it might still be too far away. 364 // Okay, we found the closest city, but it might still be too far away.
372 if ( lClosest <= iTHRESHOLD ) { 365 if ( lClosest <= iTHRESHOLD ) {
373 showCity( pClosest ); 366 showCity( pClosest );
374 cursor = pClosest; 367 cursor = pClosest;
375 } 368 }
376} 369}
377 370
378void ZoneMap::showCity( ZoneField *city ) 371void ZoneMap::showCity( ZoneField *city )
379{ 372{
380 pLast = city; 373 pLast = city;
381 // we'll use city and country a couple of times, get them to save some 374 // we'll use city and country a couple of times, get them to save some
382 // time 375 // time
383 QString strCity = pLast->city(); 376 QString strCity = pLast->city();
384 QString strCountry = pLast->country(); 377 QString strCountry = pLast->country();
385 // Display the time at this location by setting the environment timezone 378 // Display the time at this location by setting the environment timezone
386 // getting the current time [there] and then swapping back the variable 379 // getting the current time [there] and then swapping back the variable
387 // so no one notices... 380 // so no one notices...
388 QString strSave; 381 QString strSave;
389 char *p = getenv( "TZ" ); 382 char *p = getenv( "TZ" );
390 if ( p ) { 383 if ( p ) {
391 strSave = p; 384 strSave = p;
392 } 385 }
393 // set the timezone :) 386 // set the timezone :)
394 setenv( "TZ", strCountry + strCity, true ); 387 setenv( "TZ", strCountry + strCity, true );
395 lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" + 388 lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" +
396 TimeString::shortTime( ampm ) ); 389 TimeString::shortTime( ampm ) );
397 lblCity->setMinimumSize( lblCity->sizeHint() ); 390 lblCity->setMinimumSize( lblCity->sizeHint() );
398 // undue our damage... 391 // undue our damage...
399 unsetenv( "TZ" ); 392 unsetenv( "TZ" );
400 if ( p ) 393 if ( p )
401 setenv( "TZ", strSave, true ); 394 setenv( "TZ", strSave, true );
402 // Now decide where to move the label, x & y can be reused 395 // Now decide where to move the label, x & y can be reused
403 int tmpx, tmpy, x, y; 396 int tmpx, tmpy, x, y;
404 zoneToWin( pLast->x(), pLast->y(), tmpx, tmpy ); 397 zoneToWin( pLast->x(), pLast->y(), tmpx, tmpy );
405 contentsToViewport(tmpx, tmpy, x, y); 398 contentsToViewport(tmpx, tmpy, x, y);
406 if ( lblCity->width() > drawableW - x ) { 399 if ( lblCity->width() > drawableW - x ) {
407 // oops... try putting it on the right 400 // oops... try putting it on the right
408 x = x - lblCity->width() - iLABELOFFSET; 401 x = x - lblCity->width() - iLABELOFFSET;
409 } else { 402 } else {
410 // the default... 403 // the default...
411 x += iLABELOFFSET; 404 x += iLABELOFFSET;
412 } 405 }
413 if ( lblCity->height() > drawableH - y ) { 406 if ( lblCity->height() > drawableH - y ) {
414 // move it up... 407 // move it up...
415 y = y - lblCity->height() - iLABELOFFSET; 408 y = y - lblCity->height() - iLABELOFFSET;
416 } else if ( y < 0 ) { 409 } else if ( y < 0 ) {
417 // the city is actually off the screen... 410 // the city is actually off the screen...
418 // this only happens on the a zoom when you are near the top, 411 // this only happens on the a zoom when you are near the top,
419 // a quick workaround.. 412 // a quick workaround..
420 y = iLABELOFFSET; 413 y = iLABELOFFSET;
421 } else { 414 } else {
422 // the default 415 // the default
423 y += iLABELOFFSET; 416 y += iLABELOFFSET;
424 } 417 }
425 418
426 // draw in the city and the label 419 // draw in the city and the label
427 if ( pRepaint ) { 420 if ( pRepaint ) {
428 int repx, 421 int repx,
429 repy; 422 repy;
430 zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); 423 zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy );
431 updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, 424 updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET,
432 iCITYSIZE, iCITYSIZE ); 425 iCITYSIZE, iCITYSIZE );
433 } 426 }
434 updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE, 427 updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE,
435 iCITYSIZE ); 428 iCITYSIZE );
436 pRepaint = pLast; 429 pRepaint = pLast;
437 430
438 lblCity->move( x, y ); 431 lblCity->move( x, y );
439 lblCity->show(); 432 lblCity->show();
440} 433}
441 434
442void ZoneMap::resizeEvent( QResizeEvent *e ) 435void ZoneMap::resizeEvent( QResizeEvent *e )
443{ 436{
444 // keep the zoom button down in the corner 437 // keep the zoom button down in the corner
445 QSize _size = e->size(); 438 QSize _size = e->size();
446 cmdZoom->move( _size.width() - cmdZoom->width(), 439 cmdZoom->move( _size.width() - cmdZoom->width(),
447 _size.height() - cmdZoom->height() ); 440 _size.height() - cmdZoom->height() );
448 if ( !bZoom ) { 441 if ( !bZoom ) {
449 drawableW = width() - 2 * frameWidth(); 442 drawableW = width() - 2 * frameWidth();
450 drawableH = height() - 2 * frameWidth(); 443 drawableH = height() - 2 * frameWidth();
451 makeMap( drawableW, drawableH ); 444 makeMap( drawableW, drawableH );
452 resizeContents( drawableW, drawableH ); 445 resizeContents( drawableW, drawableH );
453 } 446 }
454} 447}
455 448
456void ZoneMap::showZones( void ) const 449void ZoneMap::showZones( void ) const
457{ 450{
458 // go through the zones in the list and just display the values... 451 // go through the zones in the list and just display the values...
459 QListIterator<ZoneField> itZone( zones ); 452 QListIterator<ZoneField> itZone( zones );
460 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 453 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
461 ZoneField *pZone = itZone.current(); 454 ZoneField *pZone = itZone.current();
462 pZone->showStructure(); 455 pZone->showStructure();
463 } 456 }
464} 457}
465 458
466 459
467QWidget* ZoneMap::selectionWidget( QWidget *parent) { 460QWidget* ZoneMap::selectionWidget( QWidget *parent) {
468 461
469 QWidget *returnWidget = new QWidget( parent ); 462 QWidget *returnWidget = new QWidget( parent );
470 463
471 QVBoxLayout *layout = new QVBoxLayout( returnWidget ); 464 QVBoxLayout *layout = new QVBoxLayout( returnWidget );
472 QHBox *hBox = new QHBox( returnWidget ); 465 QHBox *hBox = new QHBox( returnWidget );
473 QListView *continentView = new QListView( hBox ); 466 QListView *continentView = new QListView( hBox );
474 continentView->addColumn( tr("Continent") ); 467 continentView->addColumn( tr("Continent") );
475 QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") ); 468 QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") );
476 connect ( continentView, SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( slotGetCities( QListViewItem * ) ) ); 469 connect ( continentView, SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( slotGetCities( QListViewItem * ) ) );
477 470
478 QStringList continentList; 471 QStringList continentList;
479 QListIterator<ZoneField> itZone( zones ); 472 QListIterator<ZoneField> itZone( zones );
480 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 473 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
481 ZoneField *pZone = itZone.current(); 474 ZoneField *pZone = itZone.current();
482 if ( continentList.contains( pZone->country() ) == 0 ) { 475 if ( continentList.contains( pZone->country() ) == 0 ) {
483 QString name; 476 QString name;
484 QListViewItem *item; 477 QListViewItem *item;
485 if ( !(pZone->country().length() > 24) ) { 478 if ( !(pZone->country().length() > 24) ) {
486 name = pZone->country().left(pZone->country().length()-1 ); 479 name = pZone->country().left(pZone->country().length()-1 );
487 } else { 480 } else {
488 name = pZone->country().left( 24 ); 481 name = pZone->country().left( 24 );
489 } 482 }
490 item = new QListViewItem( continentView, name, pZone->country() ); 483 item = new QListViewItem( continentView, name, pZone->country() );
491 continentList.append( pZone->country() ); 484 continentList.append( pZone->country() );
492 } 485 }
493 } 486 }
494 487
495 cityView = new QListView( hBox ); 488 cityView = new QListView( hBox );
496 cityView->addColumn( tr("City") ); 489 cityView->addColumn( tr("City") );
497 490
498 layout->addWidget( hBox ); 491 layout->addWidget( hBox );
499 return returnWidget; 492 return returnWidget;
500} 493}
501 494
502void ZoneMap::slotGetCities( QListViewItem * contItem) { 495void ZoneMap::slotGetCities( QListViewItem * contItem) {
503 496
504 cityView->clear(); 497 cityView->clear();
505 selectedCont = contItem->text( 1 ); 498 selectedCont = contItem->text( 1 );
506 QListIterator<ZoneField> itZone( zones ); 499 QListIterator<ZoneField> itZone( zones );
507 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 500 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
508 ZoneField *pZone = itZone.current(); 501 ZoneField *pZone = itZone.current();
509 if ( pZone->country() == contItem->text( 1 ) ) { 502 if ( pZone->country() == contItem->text( 1 ) ) {
510 QListViewItem *item; 503 QListViewItem *item;
511 item = new QListViewItem( cityView, pZone->city() ); 504 item = new QListViewItem( cityView, pZone->city() );
512 connect ( cityView, SIGNAL( clicked ( QListViewItem* ) ), this, SLOT( slotCitySelected( QListViewItem* ) ) ); 505 connect ( cityView, SIGNAL( clicked ( QListViewItem* ) ), this, SLOT( slotCitySelected( QListViewItem* ) ) );
513 } 506 }
514 } 507 }
515} 508}
516 509
517void ZoneMap::slotCitySelected( QListViewItem *cityItem ) { 510void ZoneMap::slotCitySelected( QListViewItem *cityItem ) {
518 if ( cityItem ) { 511 if ( cityItem ) {
519 emit signalTz( selectedCont, cityItem->text( 0 ) ); 512 emit signalTz( selectedCont, cityItem->text( 0 ) );
520 } 513 }
521} 514}
522 515
523void ZoneMap::drawCities( QPainter *p ) 516void ZoneMap::drawCities( QPainter *p )
524{ 517{
525 int x, y, j; 518 int x, y, j;
526 // draw in the cities 519 // draw in the cities
527 // for testing only as when you put it 520 // for testing only as when you put it
528 // on the small screen it looks awful and not to mention useless 521 // on the small screen it looks awful and not to mention useless
529 p->setPen( red ); 522 p->setPen( red );
530 QListIterator<ZoneField> itZone( zones ); 523 QListIterator<ZoneField> itZone( zones );
531 for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) { 524 for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) {
532 ZoneField *pZone = itZone.current(); 525 ZoneField *pZone = itZone.current();
533 zoneToWin( pZone->x(), pZone->y(), x, y ); 526 zoneToWin( pZone->x(), pZone->y(), x, y );
534 if ( x > wImg ) 527 if ( x > wImg )
535 x = x - wImg; 528 x = x - wImg;
536 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); 529 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE);
537 } 530 }
538} 531}
539 532
540static void dayNight(QImage *pImage) 533static void dayNight(QImage *pImage)
541{ 534{
542 // create a mask the functions from sun.h 535 // create a mask the functions from sun.h
543 double dJulian, 536 double dJulian,
544 dSunRad, 537 dSunRad,
545 dSunDecl, 538 dSunDecl,
546 dSunRadius, 539 dSunRadius,
547 dSunLong; 540 dSunLong;
548 int wImage = pImage->width(), 541 int wImage = pImage->width(),
549 hImage = pImage->height(), 542 hImage = pImage->height(),
550 iStart, 543 iStart,
551 iStop, 544 iStop,
552 iMid, 545 iMid,
553 relw, 546 relw,
554 i; 547 i;
555 short wtab[ wImage ]; 548 short wtab[ wImage ];
556 time_t tCurrent; 549 time_t tCurrent;
557 struct tm *pTm; 550 struct tm *pTm;
558 551
559 // get the position of the sun bassed on our current time... 552 // get the position of the sun bassed on our current time...
560 tCurrent = time( NULL ); 553 tCurrent = time( NULL );
561 pTm = gmtime( &tCurrent ); 554 pTm = gmtime( &tCurrent );
562 dJulian = jtime( pTm ); 555 dJulian = jtime( pTm );
563 sunpos( dJulian, 0, &dSunRad, &dSunDecl, &dSunRadius, &dSunLong ); 556 sunpos( dJulian, 0, &dSunRad, &dSunDecl, &dSunRadius, &dSunLong );
564 557
565 // now get the projected illumination 558 // now get the projected illumination
566 projillum( wtab, wImage, hImage, dSunDecl ); 559 projillum( wtab, wImage, hImage, dSunDecl );
567 relw = wImage - int( wImage * 0.0275 ); 560 relw = wImage - int( wImage * 0.0275 );
568 561
569 // draw the map, keeping in mind that we may go too far off the map... 562 // draw the map, keeping in mind that we may go too far off the map...
570 iMid = ( relw * ( 24*60 - pTm->tm_hour * 60 - pTm->tm_min ) ) / ( 24*60 ); 563 iMid = ( relw * ( 24*60 - pTm->tm_hour * 60 - pTm->tm_min ) ) / ( 24*60 );
571 564
572 for ( i = 0; i < hImage; i++ ) { 565 for ( i = 0; i < hImage; i++ ) {
573 if ( wtab[i] > 0 ) { 566 if ( wtab[i] > 0 ) {
574 iStart = iMid - wtab[i]; 567 iStart = iMid - wtab[i];
575 iStop = iMid + wtab[i]; 568 iStop = iMid + wtab[i];
576 if ( iStart < 0 ) { 569 if ( iStart < 0 ) {
577 darken( pImage, iStop, wImage + iStart, i ); 570 darken( pImage, iStop, wImage + iStart, i );
578 } else if ( iStop > wImage ) { 571 } else if ( iStop > wImage ) {
579 darken( pImage, iStop - wImage, iStart, i ); 572 darken( pImage, iStop - wImage, iStart, i );
580 } else { 573 } else {
581 darken( pImage, 0, iStart, i ); 574 darken( pImage, 0, iStart, i );
582 darken( pImage, iStop, wImage, i ); 575 darken( pImage, iStop, wImage, i );
583 } 576 }
584 } else { 577 } else {
585 darken( pImage, 0, wImage, i ); 578 darken( pImage, 0, wImage, i );
586 } 579 }
587 } 580 }
588} 581}
589 582
590static inline void darken( QImage *pImage, int start, int stop, int row ) 583static inline void darken( QImage *pImage, int start, int stop, int row )
591{ 584{
592 int colors, 585 int colors,
593 j; 586 j;
594 uchar *p; 587 uchar *p;
595 588
596 // assume that the image is similar to the one we have... 589 // assume that the image is similar to the one we have...
597 colors = pImage->numColors() / 2; 590 colors = pImage->numColors() / 2;
598 591
599 p = pImage->scanLine( row ); 592 p = pImage->scanLine( row );
600 for ( j = start; j <= stop; j++ ) { 593 for ( j = start; j <= stop; j++ ) {
601 if ( p[j] < colors ) 594 if ( p[j] < colors )
602 p[j] += colors; 595 p[j] += colors;
603 } 596 }
604} 597}
605 598
606void ZoneMap::makeMap( int w, int h ) 599void ZoneMap::makeMap( int w, int h )
607{ 600{
608 QImage imgOrig = Resource::loadImage( strMAP ); 601 QImage imgOrig = Resource::loadImage( strMAP );
609 if ( imgOrig.isNull() ) { 602 if ( imgOrig.isNull() ) {
610 QMessageBox::warning( this, 603 QMessageBox::warning( this,
611 tr( "Couldn't Find Map" ), 604 tr( "Couldn't Find Map" ),
612 tr( "<p>Couldn't load map: %1, exiting") 605 tr( "<p>Couldn't load map: %1, exiting")
613 .arg( strMAP ) ); 606 .arg( strMAP ) );
614 exit(-1); 607 exit(-1);
615 } 608 }
616 609
617 // set up the color table for darkening... 610 // set up the color table for darkening...
618 imgOrig = imgOrig.convertDepth( 8 ); 611 imgOrig = imgOrig.convertDepth( 8 );
619 int numColors = imgOrig.numColors(); 612 int numColors = imgOrig.numColors();
620 // double the colors 613 // double the colors
621 imgOrig.setNumColors( 2 * numColors ); 614 imgOrig.setNumColors( 2 * numColors );
622 // darken the new ones... 615 // darken the new ones...
623 for ( int i = 0; i < numColors; i++ ) { 616 for ( int i = 0; i < numColors; i++ ) {
624 QRgb rgb = imgOrig.color( i ); 617 QRgb rgb = imgOrig.color( i );
625 imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3, 618 imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3,
626 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) ); 619 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) );
627 } 620 }
628 621
629 // else go one with making the map... 622 // else go one with making the map...
630 if ( bIllum ) { 623 if ( bIllum ) {
631 // do a daylight mask 624 // do a daylight mask
632 dayNight(&imgOrig); 625 dayNight(&imgOrig);
633 } 626 }
634 // redo the width and height 627 // redo the width and height
635 wImg = w; 628 wImg = w;
636 hImg = h; 629 hImg = h;
637 ox = ( wImg / 2 ) - int( wImg * 0.0275 ); 630 ox = ( wImg / 2 ) - int( wImg * 0.0275 );
638 oy = hImg / 2; 631 oy = hImg / 2;
639 pixCurr->convertFromImage( imgOrig.smoothScale(w, h), 632 pixCurr->convertFromImage( imgOrig.smoothScale(w, h),
640 QPixmap::ThresholdDither ); 633 QPixmap::ThresholdDither );
641} 634}
642 635
643void ZoneMap::drawCity( QPainter *p, const ZoneField *pCity ) 636void ZoneMap::drawCity( QPainter *p, const ZoneField *pCity )
644{ 637{
645 int x, 638 int x,
646 y; 639 y;
647 640
648 p->setPen( red ); 641 p->setPen( red );
649 zoneToWin( pCity->x(), pCity->y(), x, y ); 642 zoneToWin( pCity->x(), pCity->y(), x, y );
650 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE ); 643 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE );
651} 644}
652 645
653void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) 646void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
654{ 647{
655 // if there is a need to resize, then do it... 648 // if there is a need to resize, then do it...
656 // get our drawable area 649 // get our drawable area
657 drawableW = width() - 2 * frameWidth(); 650 drawableW = width() - 2 * frameWidth();
658 drawableH = height() - 2 * frameWidth(); 651 drawableH = height() - 2 * frameWidth();
659 652
660 int pixmapW = pixCurr->width(), 653 int pixmapW = pixCurr->width(),
661 pixmapH = pixCurr->height(); 654 pixmapH = pixCurr->height();
662 if ( !bZoom && ( ( pixmapW != drawableW ) || 655 if ( !bZoom && ( ( pixmapW != drawableW ) ||
663 ( pixmapH != drawableH) ) ) { 656 ( pixmapH != drawableH) ) ) {
664 makeMap( drawableW, drawableH ); 657 makeMap( drawableW, drawableH );
665 } 658 }
666 659
667 // taken from the scrollview example... 660 // taken from the scrollview example...
668 int rowheight = pixCurr->height(); 661 int rowheight = pixCurr->height();
669 int toprow = cy / rowheight; 662 int toprow = cy / rowheight;
670 int bottomrow = ( cy + ch + rowheight - 1 ) / rowheight; 663 int bottomrow = ( cy + ch + rowheight - 1 ) / rowheight;
671 int colwidth = pixCurr->width(); 664 int colwidth = pixCurr->width();
672 int leftcol= cx / colwidth; 665 int leftcol= cx / colwidth;
673 int rightcol= ( cx + cw + colwidth - 1 ) / colwidth; 666 int rightcol= ( cx + cw + colwidth - 1 ) / colwidth;
674 for ( int r = toprow; r <= bottomrow; r++ ) { 667 for ( int r = toprow; r <= bottomrow; r++ ) {
675 int py = r * rowheight; 668 int py = r * rowheight;
676 for ( int c = leftcol; c <= rightcol; c++ ) { 669 for ( int c = leftcol; c <= rightcol; c++ ) {
677 int px = c * colwidth; 670 int px = c * colwidth;
678 p->drawPixmap( px, py, *pixCurr ); 671 p->drawPixmap( px, py, *pixCurr );
679 } 672 }
680 } 673 }
681 674
682 // Draw that city! 675 // Draw that city!
683 if ( pLast ) 676 if ( pLast )
684 drawCity( p, pLast ); 677 drawCity( p, pLast );
685} 678}
686 679
687void ZoneMap::slotZoom( bool setZoom ) 680void ZoneMap::slotZoom( bool setZoom )
688{ 681{
689 bZoom = setZoom; 682 bZoom = setZoom;
690 if ( bZoom ) { 683 if ( bZoom ) {
691 makeMap( 2 * wImg , 2 * hImg ); 684 makeMap( 2 * wImg , 2 * hImg );
692 resizeContents( wImg, hImg ); 685 resizeContents( wImg, hImg );
693 } else { 686 } else {
694 makeMap( drawableW, drawableH ); 687 makeMap( drawableW, drawableH );
695 resizeContents( drawableW, drawableH ); 688 resizeContents( drawableW, drawableH );
696 } 689 }
697} 690}
698 691
699void ZoneMap::slotIllum( bool setIllum ) 692void ZoneMap::slotIllum( bool setIllum )
700{ 693{
701 bIllum = !setIllum; 694 bIllum = !setIllum;
702 // make the map... 695 // make the map...
703 makeMap( pixCurr->width(), pixCurr->height() ); 696 makeMap( pixCurr->width(), pixCurr->height() );
704 updateContents( 0, 0, wImg, hImg ); 697 updateContents( 0, 0, wImg, hImg );
705} 698}
706 699
707void ZoneMap::slotUpdate( void ) 700void ZoneMap::slotUpdate( void )
708{ 701{
709 // recalculate the light, most people will never see this, 702 // recalculate the light, most people will never see this,
710 // but it is good to be complete 703 // but it is good to be complete
711 makeMap ( pixCurr->width(), pixCurr->height() ); 704 makeMap ( pixCurr->width(), pixCurr->height() );
712 updateContents( contentsX(), contentsY(), drawableW, drawableH ); 705 updateContents( contentsX(), contentsY(), drawableW, drawableH );
713} 706}
714 707
715void ZoneMap::slotRedraw( void ) 708void ZoneMap::slotRedraw( void )
716{ 709{
717 // paint over that pesky city... 710 // paint over that pesky city...
718 int x, 711 int x,
719 y; 712 y;
720 if ( pRepaint ) { 713 if ( pRepaint ) {
721 pLast = 0; 714 pLast = 0;
722 zoneToWin(pRepaint->x(), pRepaint->y(), x, y); 715 zoneToWin(pRepaint->x(), pRepaint->y(), x, y);
723 updateContents( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); 716 updateContents( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE);
724 pRepaint = 0; 717 pRepaint = 0;
725 } 718 }
726} 719}
727 720
728void ZoneMap::changeClock( bool whichClock ) 721void ZoneMap::changeClock( bool whichClock )
729{ 722{
730 ampm = whichClock; 723 ampm = whichClock;
731} 724}
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 60f7417..4baff8e 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -1,314 +1,313 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "light.h" 29#include "light.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/power.h> 32#include <qpe/power.h>
33#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 33#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
34#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
35#endif 35#endif
36#include <qpe/qpeapplication.h>
37 36
38#include <qlabel.h> 37#include <qlabel.h>
39#include <qcheckbox.h> 38#include <qcheckbox.h>
40#include <qtabwidget.h> 39#include <qtabwidget.h>
41#include <qslider.h> 40#include <qslider.h>
42#include <qspinbox.h> 41#include <qspinbox.h>
43#include <qpushbutton.h> 42#include <qpushbutton.h>
44#include <qgroupbox.h> 43#include <qgroupbox.h>
45#include <qcombobox.h> 44#include <qcombobox.h>
46 45
47#include <opie/odevice.h> 46#include <opie/odevice.h>
48 47
49#include "sensor.h" 48#include "sensor.h"
50 49
51using namespace Opie; 50using namespace Opie;
52 51
53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 52LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) 53 : LightSettingsBase( parent, name, false, WStyle_ContextHelp )
55{ 54{
56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); 55 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( );
57 m_cres = ODevice::inst ( )-> displayContrastResolution ( ); 56 m_cres = ODevice::inst ( )-> displayContrastResolution ( );
58 57
59 // check whether to show the light sensor stuff 58 // check whether to show the light sensor stuff
60 59
61 if ( !ODevice::inst ( )-> hasLightSensor ( )) { 60 if ( !ODevice::inst ( )-> hasLightSensor ( )) {
62 auto_brightness-> hide ( ); 61 auto_brightness-> hide ( );
63 CalibrateLightSensor-> hide ( ); 62 CalibrateLightSensor-> hide ( );
64 auto_brightness_ac-> hide ( ); 63 auto_brightness_ac-> hide ( );
65 CalibrateLightSensor_ac-> hide ( ); 64 CalibrateLightSensor_ac-> hide ( );
66 } 65 }
67 66
68 // check whether to show the contrast stuff 67 // check whether to show the contrast stuff
69 68
70 if (m_cres) { 69 if (m_cres) {
71 GroupLight->setTitle(tr("Backlight && Contrast")); 70 GroupLight->setTitle(tr("Backlight && Contrast"));
72 GroupLight_ac->setTitle(GroupLight->title()); 71 GroupLight_ac->setTitle(GroupLight->title());
73 } else { 72 } else {
74 contrast->hide(); 73 contrast->hide();
75 contrast_ac->hide(); 74 contrast_ac->hide();
76 } 75 }
77 76
78 // check whether to show the cpu frequency stuff 77 // check whether to show the cpu frequency stuff
79 78
80 QStrList freq = ODevice::inst()->allowedCpuFrequencies(); 79 QStrList freq = ODevice::inst()->allowedCpuFrequencies();
81 if ( freq.count() ) { 80 if ( freq.count() ) {
82 frequency->insertStrList( freq ); 81 frequency->insertStrList( freq );
83 frequency_ac->insertStrList( freq ); 82 frequency_ac->insertStrList( freq );
84 } else { 83 } else {
85 frequencyLabel->hide(); 84 frequencyLabel->hide();
86 frequency->hide(); 85 frequency->hide();
87 frequencyLabel_ac->hide(); 86 frequencyLabel_ac->hide();
88 frequency_ac->hide(); 87 frequency_ac->hide();
89 } 88 }
90 89
91 // check whether to show the hinge action stuff 90 // check whether to show the hinge action stuff
92 91
93 if ( !ODevice::inst()->hasHingeSensor() ) { 92 if ( !ODevice::inst()->hasHingeSensor() ) {
94 closeHingeLabel->hide(); 93 closeHingeLabel->hide();
95 closeHingeAction->hide(); 94 closeHingeAction->hide();
96 closeHingeLabel_ac->hide(); 95 closeHingeLabel_ac->hide();
97 closeHingeAction_ac->hide(); 96 closeHingeAction_ac->hide();
98 } 97 }
99 98
100 Config config ( "apm" ); 99 Config config ( "apm" );
101 config. setGroup ( "Battery" ); 100 config. setGroup ( "Battery" );
102 101
103 // battery spinboxes 102 // battery spinboxes
104 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); 103 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
105 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); 104 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
106 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 105 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
107 106
108 // battery check and slider 107 // battery check and slider
109 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 108 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
110 109
111 // CPU frequency 110 // CPU frequency
112 frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); 111 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
113 112
114 // hinge action 113 // hinge action
115 closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); 114 closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) );
116 115
117 int bright = config. readNumEntry ( "Brightness", 127 ); 116 int bright = config. readNumEntry ( "Brightness", 127 );
118 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 117 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
119 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); 118 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
120 brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); 119 brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
121 brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); 120 brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
122 brightness-> setValue ( bright ); 121 brightness-> setValue ( bright );
123 122
124 if (m_cres) { 123 if (m_cres) {
125 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); 124 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres ));
126 contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); 125 contrast-> setLineStep ( QMAX( 1, 256 / m_cres ));
127 contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); 126 contrast-> setPageStep ( QMAX( 1, 256 / m_cres ));
128 contrast-> setValue ( contr ); 127 contrast-> setValue ( contr );
129 } 128 }
130 129
131 // light sensor 130 // light sensor
132 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 131 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
133 m_sensordata = config. readListEntry ( "LightSensorData", ';' ); 132 m_sensordata = config. readListEntry ( "LightSensorData", ';' );
134 133
135 config. setGroup ( "AC" ); 134 config. setGroup ( "AC" );
136 135
137 // ac spinboxes 136 // ac spinboxes
138 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); 137 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 ));
139 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); 138 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
140 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); 139 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
141 140
142 // ac check and slider 141 // ac check and slider
143 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 142 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
144 143
145 // CPU frequency 144 // CPU frequency
146 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); 145 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
147 146
148 // hinge action 147 // hinge action
149 closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); 148 closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) );
150 149
151 bright = config. readNumEntry ( "Brightness", 255 ); 150 bright = config. readNumEntry ( "Brightness", 255 );
152 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); 151 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
153 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); 152 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
154 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); 153 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
155 brightness_ac-> setValue ( bright ); 154 brightness_ac-> setValue ( bright );
156 155
157 if (m_cres) { 156 if (m_cres) {
158 contr = config. readNumEntry ( "Contrast", 127); 157 contr = config. readNumEntry ( "Contrast", 127);
159 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); 158 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres ));
160 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); 159 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres ));
161 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); 160 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres ));
162 contrast_ac-> setValue ( contr ); 161 contrast_ac-> setValue ( contr );
163 } 162 }
164 163
165 // light sensor 164 // light sensor
166 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 165 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
167 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); 166 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' );
168 167
169 // warnings 168 // warnings
170 config. setGroup ( "Warnings" ); 169 config. setGroup ( "Warnings" );
171 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); 170 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 );
172 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); 171 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) );
173 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); 172 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) );
174 173
175 m_resettimer = new QTimer ( this ); 174 m_resettimer = new QTimer ( this );
176 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); 175 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( )));
177 176
178 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { 177 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) {
179 tabs-> setCurrentPage ( 0 ); 178 tabs-> setCurrentPage ( 0 );
180 } 179 }
181 else { 180 else {
182 tabs-> setCurrentPage ( 1 ); 181 tabs-> setCurrentPage ( 1 );
183 } 182 }
184 183
185 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 184 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
186 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 185 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
187 if (m_cres) { 186 if (m_cres) {
188 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 187 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
189 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 188 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
190 } 189 }
191 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 190 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
192 connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 191 connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
193 connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); 192 connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) );
194 connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); 193 connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) );
195} 194}
196 195
197LightSettings::~LightSettings ( ) 196LightSettings::~LightSettings ( )
198{ 197{
199} 198}
200 199
201void LightSettings::calibrateSensor ( ) 200void LightSettings::calibrateSensor ( )
202{ 201{
203 Sensor *s = new Sensor ( m_sensordata, this ); 202 Sensor *s = new Sensor ( m_sensordata, this );
204 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 203 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
205 QPEApplication::execDialog( s ); 204 QPEApplication::execDialog( s );
206 delete s; 205 delete s;
207} 206}
208 207
209void LightSettings::calibrateSensorAC ( ) 208void LightSettings::calibrateSensorAC ( )
210{ 209{
211 Sensor *s = new Sensor ( m_sensordata_ac, this ); 210 Sensor *s = new Sensor ( m_sensordata_ac, this );
212 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 211 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
213 QPEApplication::execDialog ( s ); 212 QPEApplication::execDialog ( s );
214 delete s; 213 delete s;
215} 214}
216 215
217void LightSettings::setBacklight ( int bright ) 216void LightSettings::setBacklight ( int bright )
218{ 217{
219 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 218 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
220 e << bright; 219 e << bright;
221 220
222 if ( bright != -1 ) { 221 if ( bright != -1 ) {
223 m_resettimer-> stop ( ); 222 m_resettimer-> stop ( );
224 m_resettimer-> start ( 4000, true ); 223 m_resettimer-> start ( 4000, true );
225 } 224 }
226} 225}
227 226
228void LightSettings::setContrast ( int contr ) 227void LightSettings::setContrast ( int contr )
229{ 228{
230 if (contr == -1) contr = m_oldcontrast; 229 if (contr == -1) contr = m_oldcontrast;
231 ODevice::inst ( )-> setDisplayContrast(contr); 230 ODevice::inst ( )-> setDisplayContrast(contr);
232} 231}
233 232
234void LightSettings::setFrequency ( int index ) 233void LightSettings::setFrequency ( int index )
235{ 234{
236 qWarning("LightSettings::setFrequency(%d)", index); 235 qWarning("LightSettings::setFrequency(%d)", index);
237 ODevice::inst ( )-> setCurrentCpuFrequency(index); 236 ODevice::inst ( )-> setCurrentCpuFrequency(index);
238} 237}
239 238
240void LightSettings::resetBacklight ( ) 239void LightSettings::resetBacklight ( )
241{ 240{
242 setBacklight ( -1 ); 241 setBacklight ( -1 );
243 setContrast ( -1 ); 242 setContrast ( -1 );
244} 243}
245 244
246void LightSettings::setCloseHingeAction ( int index ) 245void LightSettings::setCloseHingeAction ( int index )
247{ 246{
248 qWarning("LightSettings::setCloseHingeStatus(%d)", index); 247 qWarning("LightSettings::setCloseHingeStatus(%d)", index);
249} 248}
250 249
251void LightSettings::accept ( ) 250void LightSettings::accept ( )
252{ 251{
253 Config config ( "apm" ); 252 Config config ( "apm" );
254 253
255 // bat 254 // bat
256 config. setGroup ( "Battery" ); 255 config. setGroup ( "Battery" );
257 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 256 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
258 config. writeEntry ( "Dim", interval_dim-> value ( )); 257 config. writeEntry ( "Dim", interval_dim-> value ( ));
259 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 258 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
260 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 259 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
261 config. writeEntry ( "Brightness", brightness-> value () ); 260 config. writeEntry ( "Brightness", brightness-> value () );
262 if (m_cres) 261 if (m_cres)
263 config. writeEntry ( "Contrast", contrast-> value () ); 262 config. writeEntry ( "Contrast", contrast-> value () );
264 config. writeEntry ( "Freq", frequency->currentItem() ); 263 config. writeEntry ( "Freq", frequency->currentItem() );
265 config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); 264 config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() );
266 265
267 // ac 266 // ac
268 config. setGroup ( "AC" ); 267 config. setGroup ( "AC" );
269 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); 268 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
270 config. writeEntry ( "Dim", interval_dim_ac-> value ( )); 269 config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
271 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); 270 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
272 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); 271 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
273 config. writeEntry ( "Brightness", brightness_ac-> value () ); 272 config. writeEntry ( "Brightness", brightness_ac-> value () );
274 if (m_cres) 273 if (m_cres)
275 config. writeEntry ( "Contrast", contrast_ac-> value () ); 274 config. writeEntry ( "Contrast", contrast_ac-> value () );
276 config. writeEntry ( "Freq", frequency_ac->currentItem() ); 275 config. writeEntry ( "Freq", frequency_ac->currentItem() );
277 config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); 276 config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() );
278 277
279 // only make light sensor stuff appear if the unit has a sensor 278 // only make light sensor stuff appear if the unit has a sensor
280 if ( ODevice::inst ( )-> hasLightSensor ( )) { 279 if ( ODevice::inst ( )-> hasLightSensor ( )) {
281 config. setGroup ( "Battery" ); 280 config. setGroup ( "Battery" );
282 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 281 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
283 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 282 config. writeEntry ( "LightSensorData", m_sensordata, ';' );
284 config. setGroup ( "AC" ); 283 config. setGroup ( "AC" );
285 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); 284 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() );
286 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); 285 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
287 } 286 }
288 287
289 // advanced 288 // advanced
290 config. setGroup ( "Warnings" ); 289 config. setGroup ( "Warnings" );
291 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); 290 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 );
292 config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); 291 config. writeEntry ( "power_verylow", lowSpinBox-> value ( ));
293 config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); 292 config. writeEntry ( "power_critical", criticalSpinBox-> value ( ));
294 config. write ( ); 293 config. write ( );
295 294
296 // notify the launcher 295 // notify the launcher
297 { 296 {
298 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 297 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
299 } 298 }
300 { 299 {
301 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); 300 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" );
302 e << -1; 301 e << -1;
303 } 302 }
304 LightSettingsBase::accept ( ); 303 LightSettingsBase::accept ( );
305} 304}
306 305
307void LightSettings::done ( int r ) 306void LightSettings::done ( int r )
308{ 307{
309 m_resettimer-> stop ( ); 308 m_resettimer-> stop ( );
310 resetBacklight ( ); 309 resetBacklight ( );
311 310
312 LightSettingsBase::done ( r ); 311 LightSettingsBase::done ( r );
313 close ( ); 312 close ( );
314} 313}
diff --git a/libqtaux/ocolorbutton.cpp b/libqtaux/ocolorbutton.cpp
index d2ad873..fd3f963 100644
--- a/libqtaux/ocolorbutton.cpp
+++ b/libqtaux/ocolorbutton.cpp
@@ -1,150 +1,147 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Robert Griebl <sandman@handhelds.org> 3 Copyright (C) Robert Griebl <sandman@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "ocolorpopupmenu.h" 30#include "ocolorpopupmenu.h"
31#include "ocolorbutton.h" 31#include "ocolorbutton.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <qpe/resource.h>
35 34
36/* QT */ 35/* QT */
37#include <qcolor.h>
38#include <qpixmap.h>
39#include <qimage.h> 36#include <qimage.h>
40 37
41using namespace Opie; 38using namespace Opie;
42 39
43struct OColorButtonPrivate 40struct OColorButtonPrivate
44{ 41{
45 QPopupMenu *m_menu; 42 QPopupMenu *m_menu;
46 QColor m_color; 43 QColor m_color;
47}; 44};
48 45
49/** 46/**
50 * This concstructs a Color Button with @param color as the start color 47 * This concstructs a Color Button with @param color as the start color
51 * It'll use a OColorPopupMenu internally 48 * It'll use a OColorPopupMenu internally
52 * 49 *
53 * @param parent The parent of the Color Button 50 * @param parent The parent of the Color Button
54 * @param color The color from where to start on 51 * @param color The color from where to start on
55 * @param name @see QObject 52 * @param name @see QObject
56 */ 53 */
57OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name ) 54OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name )
58 : QPushButton ( parent, name ) 55 : QPushButton ( parent, name )
59{ 56{
60 d = new OColorButtonPrivate; 57 d = new OColorButtonPrivate;
61 58
62 d-> m_menu = new OColorPopupMenu ( color, 0, 0 ); 59 d-> m_menu = new OColorPopupMenu ( color, 0, 0 );
63 setPopup ( d-> m_menu ); 60 setPopup ( d-> m_menu );
64 //setPopupDelay ( 0 ); 61 //setPopupDelay ( 0 );
65 connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & ))); 62 connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & )));
66 63
67 updateColor ( color ); 64 updateColor ( color );
68 65
69 QSize s = sizeHint ( ) + QSize ( 12, 0 ); 66 QSize s = sizeHint ( ) + QSize ( 12, 0 );
70 setMinimumSize ( s ); 67 setMinimumSize ( s );
71 setMaximumSize ( s. width ( ) * 2, s. height ( )); 68 setMaximumSize ( s. width ( ) * 2, s. height ( ));
72} 69}
73 70
74/** 71/**
75 * This destructs the object 72 * This destructs the object
76 */ 73 */
77OColorButton::~OColorButton ( ) 74OColorButton::~OColorButton ( )
78{ 75{
79 delete d; 76 delete d;
80} 77}
81 78
82/** 79/**
83 * @return Returns the current color of the button 80 * @return Returns the current color of the button
84 */ 81 */
85QColor OColorButton::color ( ) const 82QColor OColorButton::color ( ) const
86{ 83{
87 return d-> m_color; 84 return d-> m_color;
88} 85}
89 86
90/** 87/**
91 * This method sets the color of the button 88 * This method sets the color of the button
92 * @param c The color to be set. 89 * @param c The color to be set.
93 */ 90 */
94void OColorButton::setColor ( const QColor &c ) 91void OColorButton::setColor ( const QColor &c )
95{ 92{
96 updateColor ( c ); 93 updateColor ( c );
97} 94}
98 95
99/** 96/**
100 * @internal 97 * @internal
101 */ 98 */
102void OColorButton::updateColor ( const QColor &c ) 99void OColorButton::updateColor ( const QColor &c )
103{ 100{
104 d-> m_color = c; 101 d-> m_color = c;
105 102
106 QImage img ( 16, 16, 32 ); 103 QImage img ( 16, 16, 32 );
107 img. fill ( 0 ); 104 img. fill ( 0 );
108 105
109 int r, g, b; 106 int r, g, b;
110 c. rgb ( &r, &g, &b ); 107 c. rgb ( &r, &g, &b );
111 108
112 int w = img. width ( ); 109 int w = img. width ( );
113 int h = img. height ( ); 110 int h = img. height ( );
114 111
115 int dx = w * 20 / 100; // 15% 112 int dx = w * 20 / 100; // 15%
116 int dy = h * 20 / 100; 113 int dy = h * 20 / 100;
117 114
118 for ( int y = 0; y < h; y++ ) 115 for ( int y = 0; y < h; y++ )
119 { 116 {
120 for ( int x = 0; x < w; x++ ) 117 for ( int x = 0; x < w; x++ )
121 { 118 {
122 double alpha = 1.0; 119 double alpha = 1.0;
123 120
124 if ( x < dx ) 121 if ( x < dx )
125 alpha *= ( double ( x + 1 ) / dx ); 122 alpha *= ( double ( x + 1 ) / dx );
126 else if ( x >= w - dx ) 123 else if ( x >= w - dx )
127 alpha *= ( double ( w - x ) / dx ); 124 alpha *= ( double ( w - x ) / dx );
128 if ( y < dy ) 125 if ( y < dy )
129 alpha *= ( double ( y + 1 ) / dy ); 126 alpha *= ( double ( y + 1 ) / dy );
130 else if ( y >= h - dy ) 127 else if ( y >= h - dy )
131 alpha *= ( double ( h - y ) / dy ); 128 alpha *= ( double ( h - y ) / dy );
132 129
133 int a = int ( alpha * 255.0 ); 130 int a = int ( alpha * 255.0 );
134 if ( a < 0 ) 131 if ( a < 0 )
135 a = 0; 132 a = 0;
136 if ( a > 255 ) 133 if ( a > 255 )
137 a = 255; 134 a = 255;
138 135
139 img. setPixel ( x, y, qRgba ( r, g, b, a )); 136 img. setPixel ( x, y, qRgba ( r, g, b, a ));
140 } 137 }
141 } 138 }
142 img. setAlphaBuffer ( true ); 139 img. setAlphaBuffer ( true );
143 140
144 QPixmap pix; 141 QPixmap pix;
145 pix. convertFromImage ( img ); 142 pix. convertFromImage ( img );
146 setPixmap ( pix ); 143 setPixmap ( pix );
147 144
148 emit colorSelected ( c ); 145 emit colorSelected ( c );
149} 146}
150 147
diff --git a/libqtaux/ocolorpopupmenu.cpp b/libqtaux/ocolorpopupmenu.cpp
index 6c5f99c..c5b2b88 100644
--- a/libqtaux/ocolorpopupmenu.cpp
+++ b/libqtaux/ocolorpopupmenu.cpp
@@ -1,176 +1,175 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net> 4              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net>
5              Dan Williams <williamsdr@acm.org> 5              Dan Williams <williamsdr@acm.org>
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#include "ocolorpopupmenu.h" 33#include "ocolorpopupmenu.h"
34#include "qcolordialog.h" 34#include "qcolordialog.h"
35 35
36/* QT */ 36/* QT */
37#include <qaction.h>
38#include <qlayout.h> 37#include <qlayout.h>
39#include <qpainter.h> 38#include <qpainter.h>
40 39
41using namespace Opie; 40using namespace Opie;
42 41
43OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name ) 42OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name )
44 : QFrame( parent, name ) 43 : QFrame( parent, name )
45{ 44{
46 m_color = color; 45 m_color = color;
47 46
48 setFixedSize( 16, 16 ); 47 setFixedSize( 16, 16 );
49 setActive( FALSE ); 48 setActive( FALSE );
50} 49}
51 50
52OColorPanelButton::~OColorPanelButton() 51OColorPanelButton::~OColorPanelButton()
53{ 52{
54} 53}
55 54
56void OColorPanelButton::setActive( bool active ) 55void OColorPanelButton::setActive( bool active )
57{ 56{
58 m_active = active; 57 m_active = active;
59 58
60 if ( m_active ) { 59 if ( m_active ) {
61 setFrameStyle( Panel | Sunken ); 60 setFrameStyle( Panel | Sunken );
62 } else { 61 } else {
63 setFrameStyle( NoFrame ); 62 setFrameStyle( NoFrame );
64 } 63 }
65} 64}
66 65
67void OColorPanelButton::enterEvent( QEvent* ) 66void OColorPanelButton::enterEvent( QEvent* )
68{ 67{
69 if ( !m_active ) { 68 if ( !m_active ) {
70 setFrameStyle( Panel | Sunken ); 69 setFrameStyle( Panel | Sunken );
71 } 70 }
72} 71}
73 72
74void OColorPanelButton::leaveEvent( QEvent* ) 73void OColorPanelButton::leaveEvent( QEvent* )
75{ 74{
76 if ( !m_active ) { 75 if ( !m_active ) {
77 setFrameStyle( NoFrame ); 76 setFrameStyle( NoFrame );
78 } 77 }
79} 78}
80 79
81void OColorPanelButton::paintEvent( QPaintEvent* e ) 80void OColorPanelButton::paintEvent( QPaintEvent* e )
82{ 81{
83 QFrame::paintEvent( e ); 82 QFrame::paintEvent( e );
84 83
85 QPainter painter; 84 QPainter painter;
86 painter.begin( this ); 85 painter.begin( this );
87 painter.fillRect( 2, 2, 12, 12, m_color ); 86 painter.fillRect( 2, 2, 12, 12, m_color );
88 painter.setPen( Qt::black ); 87 painter.setPen( Qt::black );
89 painter.drawRect( 2, 2, 12, 12 ); 88 painter.drawRect( 2, 2, 12, 12 );
90 painter.end(); 89 painter.end();
91} 90}
92 91
93void OColorPanelButton::mouseReleaseEvent( QMouseEvent* ) 92void OColorPanelButton::mouseReleaseEvent( QMouseEvent* )
94{ 93{
95 emit selected( m_color ); 94 emit selected( m_color );
96} 95}
97 96
98OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name ) 97OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name )
99 : QPopupMenu( parent, name ) 98 : QPopupMenu( parent, name )
100{ 99{
101 m_color = color; 100 m_color = color;
102 101
103 colorPanel = new QWidget( this ); 102 colorPanel = new QWidget( this );
104 103
105 colorLayout = new QGridLayout(colorPanel, 5, 6); 104 colorLayout = new QGridLayout(colorPanel, 5, 6);
106 105
107 addColor(QColor(255, 255, 255), 0, 1); 106 addColor(QColor(255, 255, 255), 0, 1);
108 addColor(QColor(192, 192, 192), 0, 2); 107 addColor(QColor(192, 192, 192), 0, 2);
109 addColor(QColor(128, 128, 128), 0, 3); 108 addColor(QColor(128, 128, 128), 0, 3);
110 addColor(QColor(64, 64, 64), 0, 4); 109 addColor(QColor(64, 64, 64), 0, 4);
111 addColor(QColor(0, 0, 0), 0, 5); 110 addColor(QColor(0, 0, 0), 0, 5);
112 111
113 addColor(QColor(255, 0, 0), 1, 0); 112 addColor(QColor(255, 0, 0), 1, 0);
114 addColor(QColor(255, 128, 0), 1, 1); 113 addColor(QColor(255, 128, 0), 1, 1);
115 addColor(QColor(255, 255, 0), 1, 2); 114 addColor(QColor(255, 255, 0), 1, 2);
116 addColor(QColor(128, 255, 0), 1, 3); 115 addColor(QColor(128, 255, 0), 1, 3);
117 addColor(QColor(0, 255, 0), 1, 4); 116 addColor(QColor(0, 255, 0), 1, 4);
118 addColor(QColor(0, 255, 128), 1, 5); 117 addColor(QColor(0, 255, 128), 1, 5);
119 118
120 addColor(QColor(128, 0, 0), 2, 0); 119 addColor(QColor(128, 0, 0), 2, 0);
121 addColor(QColor(128, 64, 0), 2, 1); 120 addColor(QColor(128, 64, 0), 2, 1);
122 addColor(QColor(128, 128, 0), 2, 2); 121 addColor(QColor(128, 128, 0), 2, 2);
123 addColor(QColor(64, 128, 0), 2, 3); 122 addColor(QColor(64, 128, 0), 2, 3);
124 addColor(QColor(0, 128, 0), 2, 4); 123 addColor(QColor(0, 128, 0), 2, 4);
125 addColor(QColor(0, 128, 64), 2, 5); 124 addColor(QColor(0, 128, 64), 2, 5);
126 125
127 addColor(QColor(0, 255, 255), 3, 0); 126 addColor(QColor(0, 255, 255), 3, 0);
128 addColor(QColor(0, 128, 255), 3, 1); 127 addColor(QColor(0, 128, 255), 3, 1);
129 addColor(QColor(0, 0, 255), 3, 2); 128 addColor(QColor(0, 0, 255), 3, 2);
130 addColor(QColor(128, 0, 255), 3, 3); 129 addColor(QColor(128, 0, 255), 3, 3);
131 addColor(QColor(255, 0, 255), 3, 4); 130 addColor(QColor(255, 0, 255), 3, 4);
132 addColor(QColor(255, 0, 128), 3, 5); 131 addColor(QColor(255, 0, 128), 3, 5);
133 132
134 addColor(QColor(0, 128, 128), 4, 0); 133 addColor(QColor(0, 128, 128), 4, 0);
135 addColor(QColor(0, 64, 128), 4, 1); 134 addColor(QColor(0, 64, 128), 4, 1);
136 addColor(QColor(0, 0, 128), 4, 2); 135 addColor(QColor(0, 0, 128), 4, 2);
137 addColor(QColor(64, 0, 128), 4, 3); 136 addColor(QColor(64, 0, 128), 4, 3);
138 addColor(QColor(128, 0, 128), 4, 4); 137 addColor(QColor(128, 0, 128), 4, 4);
139 addColor(QColor(128, 0, 64), 4, 5); 138 addColor(QColor(128, 0, 64), 4, 5);
140 139
141 insertItem( colorPanel ); 140 insertItem( colorPanel );
142 insertSeparator(); 141 insertSeparator();
143 insertItem(tr("More"),this,SLOT( moreColorClicked())); 142 insertItem(tr("More"),this,SLOT( moreColorClicked()));
144 /* 143 /*
145 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" ); 144 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" );
146 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) ); 145 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) );
147 chooseColorAction->addTo( this ); 146 chooseColorAction->addTo( this );
148 */ 147 */
149 activateItemAt( 0 ); 148 activateItemAt( 0 );
150} 149}
151 150
152OColorPopupMenu::~OColorPopupMenu() 151OColorPopupMenu::~OColorPopupMenu()
153{ 152{
154} 153}
155 154
156void OColorPopupMenu::addColor( const QColor& color, int row, int col ) 155void OColorPopupMenu::addColor( const QColor& color, int row, int col )
157{ 156{
158 OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel ); 157 OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel );
159 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) ); 158 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) );
160 colorLayout->addWidget( panelButton, row, col ); 159 colorLayout->addWidget( panelButton, row, col );
161} 160}
162 161
163void OColorPopupMenu::buttonSelected( const QColor& color ) 162void OColorPopupMenu::buttonSelected( const QColor& color )
164{ 163{
165 m_color = color; 164 m_color = color;
166 emit colorSelected( color ); 165 emit colorSelected( color );
167 hide(); 166 hide();
168} 167}
169 168
170void OColorPopupMenu::moreColorClicked() 169void OColorPopupMenu::moreColorClicked()
171{ 170{
172 QColor color = QColorDialog::getColor( m_color ); 171 QColor color = QColorDialog::getColor( m_color );
173 m_color = color; 172 m_color = color;
174 emit colorSelected( color ); 173 emit colorSelected( color );
175 hide(); 174 hide();
176} 175}
diff --git a/libqtaux/qcolordialog.cpp b/libqtaux/qcolordialog.cpp
index b960b04..907c2aa 100644
--- a/libqtaux/qcolordialog.cpp
+++ b/libqtaux/qcolordialog.cpp
@@ -1,1630 +1,1628 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QColorDialog class 4** Implementation of QColorDialog class
5** 5**
6** Created : 990222 6** Created : 990222
7** 7**
8** Copyright (C) 1999-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the dialogs module of the Qt GUI Toolkit. 10** This file is part of the dialogs module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qcolordialog.h" 38#include "qcolordialog.h"
39 39
40#include "qpainter.h" 40#include "qpainter.h"
41#include "qlayout.h" 41#include "qlayout.h"
42#include "qlabel.h" 42#include "qlabel.h"
43#include "qpushbutton.h" 43#include "qpushbutton.h"
44#include "qlineedit.h" 44#include "qlineedit.h"
45#include "qimage.h" 45#include "qimage.h"
46#include "qpixmap.h" 46#include "qpixmap.h"
47#include "qdrawutil.h" 47#include "qdrawutil.h"
48#include "qvalidator.h" 48#include "qvalidator.h"
49#include "qdragobject.h"
50#include "qapplication.h" 49#include "qapplication.h"
51#include "qdragobject.h"
52 50
53//////////// QWellArray BEGIN 51//////////// QWellArray BEGIN
54 52
55#include "qobjectdict.h" 53#include "qobjectdict.h"
56 54
57// 55//
58// W A R N I N G 56// W A R N I N G
59// ------------- 57// -------------
60// 58//
61// This file is not part of the Qt API. It exists for the convenience 59// This file is not part of the Qt API. It exists for the convenience
62// of qwellarray.cpp and qcolordialog.cpp. 60// of qwellarray.cpp and qcolordialog.cpp.
63// This header file may change from version to version without notice, 61// This header file may change from version to version without notice,
64// or even be removed. 62// or even be removed.
65// 63//
66// 64//
67 65
68 66
69#include "qtableview.h" 67#include "qtableview.h"
70 68
71 69
72struct QWellArrayData; 70struct QWellArrayData;
73 71
74class QWellArray : public QTableView 72class QWellArray : public QTableView
75{ 73{
76 Q_OBJECT 74 Q_OBJECT
77 Q_PROPERTY( int numCols READ numCols ) 75 Q_PROPERTY( int numCols READ numCols )
78 Q_PROPERTY( int numRows READ numRows ) 76 Q_PROPERTY( int numRows READ numRows )
79 Q_PROPERTY( int selectedColumn READ selectedColumn ) 77 Q_PROPERTY( int selectedColumn READ selectedColumn )
80 Q_PROPERTY( int selectedRow READ selectedRow ) 78 Q_PROPERTY( int selectedRow READ selectedRow )
81 79
82public: 80public:
83 QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE ); 81 QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE );
84 82
85 ~QWellArray() {} 83 ~QWellArray() {}
86 QString cellContent( int row, int col ) const; 84 QString cellContent( int row, int col ) const;
87 // ### Paul !!! virtual void setCellContent( int row, int col, const QString &); 85 // ### Paul !!! virtual void setCellContent( int row, int col, const QString &);
88 86
89 // ##### Obsolete since not const 87 // ##### Obsolete since not const
90 int numCols() { return nCols; } 88 int numCols() { return nCols; }
91 int numRows() { return nRows; } 89 int numRows() { return nRows; }
92 90
93 int numCols() const { return nCols; } 91 int numCols() const { return nCols; }
94 int numRows() const { return nRows; } 92 int numRows() const { return nRows; }
95 93
96 // ##### Obsolete since not const 94 // ##### Obsolete since not const
97 int selectedColumn() { return selCol; } 95 int selectedColumn() { return selCol; }
98 int selectedRow() { return selRow; } 96 int selectedRow() { return selRow; }
99 97
100 int selectedColumn() const { return selCol; } 98 int selectedColumn() const { return selCol; }
101 int selectedRow() const { return selRow; } 99 int selectedRow() const { return selRow; }
102 100
103 virtual void setSelected( int row, int col ); 101 virtual void setSelected( int row, int col );
104 102
105 void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); } 103 void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); }
106 104
107 QSize sizeHint() const; 105 QSize sizeHint() const;
108 106
109 virtual void setDimension( int rows, int cols ); 107 virtual void setDimension( int rows, int cols );
110 virtual void setCellBrush( int row, int col, const QBrush & ); 108 virtual void setCellBrush( int row, int col, const QBrush & );
111 QBrush cellBrush( int row, int col ); 109 QBrush cellBrush( int row, int col );
112 110
113signals: 111signals:
114 void selected( int row, int col ); 112 void selected( int row, int col );
115 113
116protected: 114protected:
117 virtual void setCurrent( int row, int col ); 115 virtual void setCurrent( int row, int col );
118 116
119 virtual void drawContents( QPainter *, int row, int col, const QRect& ); 117 virtual void drawContents( QPainter *, int row, int col, const QRect& );
120 void drawContents( QPainter * ); 118 void drawContents( QPainter * );
121 119
122 void paintCell( QPainter*, int row, int col ); 120 void paintCell( QPainter*, int row, int col );
123 void mousePressEvent( QMouseEvent* ); 121 void mousePressEvent( QMouseEvent* );
124 void mouseReleaseEvent( QMouseEvent* ); 122 void mouseReleaseEvent( QMouseEvent* );
125 void mouseMoveEvent( QMouseEvent* ); 123 void mouseMoveEvent( QMouseEvent* );
126 void keyPressEvent( QKeyEvent* ); 124 void keyPressEvent( QKeyEvent* );
127 void focusInEvent( QFocusEvent* ); 125 void focusInEvent( QFocusEvent* );
128 void focusOutEvent( QFocusEvent* ); 126 void focusOutEvent( QFocusEvent* );
129 127
130private: 128private:
131 int curRow; 129 int curRow;
132 int curCol; 130 int curCol;
133 int selRow; 131 int selRow;
134 int selCol; 132 int selCol;
135 int nCols; 133 int nCols;
136 int nRows; 134 int nRows;
137 bool smallStyle; 135 bool smallStyle;
138 QWellArrayData *d; 136 QWellArrayData *d;
139 137
140 private:// Disabled copy constructor and operator= 138 private:// Disabled copy constructor and operator=
141#if defined(Q_DISABLE_COPY) 139#if defined(Q_DISABLE_COPY)
142 QWellArray( const QWellArray & ); 140 QWellArray( const QWellArray & );
143 QWellArray& operator=( const QWellArray & ); 141 QWellArray& operator=( const QWellArray & );
144#endif 142#endif
145}; 143};
146 144
147 145
148 146
149// non-interface ... 147// non-interface ...
150 148
151 149
152 150
153struct QWellArrayData { 151struct QWellArrayData {
154 QBrush *brush; 152 QBrush *brush;
155}; 153};
156 154
157// NOT REVISED 155// NOT REVISED
158/* WARNING, NOT 156/* WARNING, NOT
159 \class QWellArray qwellarray_p.h 157 \class QWellArray qwellarray_p.h
160 \brief .... 158 \brief ....
161 159
162 .... 160 ....
163 161
164 \ingroup advanced 162 \ingroup advanced
165*/ 163*/
166 164
167QWellArray::QWellArray( QWidget *parent, const char * name, bool popup ) 165QWellArray::QWellArray( QWidget *parent, const char * name, bool popup )
168 : QTableView( parent, name, 166 : QTableView( parent, name,
169 popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 ) 167 popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 )
170{ 168{
171 d = 0; 169 d = 0;
172 setFocusPolicy( StrongFocus ); 170 setFocusPolicy( StrongFocus );
173 setBackgroundMode( PaletteButton ); 171 setBackgroundMode( PaletteButton );
174 nCols = 7; 172 nCols = 7;
175 nRows = 7; 173 nRows = 7;
176 int w = 24; // cell width 174 int w = 24; // cell width
177 int h = 21; // cell height 175 int h = 21; // cell height
178 smallStyle = popup; 176 smallStyle = popup;
179 177
180 if ( popup ) { 178 if ( popup ) {
181 w = h = 18; 179 w = h = 18;
182 if ( style() == WindowsStyle ) 180 if ( style() == WindowsStyle )
183 setFrameStyle( QFrame::WinPanel | QFrame::Raised ); 181 setFrameStyle( QFrame::WinPanel | QFrame::Raised );
184 else 182 else
185 setFrameStyle( QFrame::Panel | QFrame::Raised ); 183 setFrameStyle( QFrame::Panel | QFrame::Raised );
186 setMargin( 1 ); 184 setMargin( 1 );
187 setLineWidth( 2 ); 185 setLineWidth( 2 );
188 } 186 }
189 setNumCols( nCols ); 187 setNumCols( nCols );
190 setNumRows( nRows ); 188 setNumRows( nRows );
191 setCellWidth( w ); 189 setCellWidth( w );
192 setCellHeight( h ); 190 setCellHeight( h );
193 curCol = 0; 191 curCol = 0;
194 curRow = 0; 192 curRow = 0;
195 selCol = -1; 193 selCol = -1;
196 selRow = -1; 194 selRow = -1;
197 195
198 if ( smallStyle ) 196 if ( smallStyle )
199 setMouseTracking( TRUE ); 197 setMouseTracking( TRUE );
200 setOffset( 5 , 10 ); 198 setOffset( 5 , 10 );
201 199
202 resize( sizeHint() ); 200 resize( sizeHint() );
203 201
204} 202}
205 203
206 204
207QSize QWellArray::sizeHint() const 205QSize QWellArray::sizeHint() const
208{ 206{
209 constPolish(); 207 constPolish();
210 int f = frameWidth() * 2; 208 int f = frameWidth() * 2;
211 int w = nCols * cellWidth() + f; 209 int w = nCols * cellWidth() + f;
212 int h = nRows * cellHeight() + f; 210 int h = nRows * cellHeight() + f;
213 return QSize( w, h ); 211 return QSize( w, h );
214} 212}
215 213
216 214
217void QWellArray::paintCell( QPainter* p, int row, int col ) 215void QWellArray::paintCell( QPainter* p, int row, int col )
218{ 216{
219 int w = cellWidth( col ); // width of cell in pixels 217 int w = cellWidth( col ); // width of cell in pixels
220 int h = cellHeight( row ); // height of cell in pixels 218 int h = cellHeight( row ); // height of cell in pixels
221 int b = 1; 219 int b = 1;
222 220
223 if ( !smallStyle ) 221 if ( !smallStyle )
224 b = 3; 222 b = 3;
225 223
226 const QColorGroup & g = colorGroup(); 224 const QColorGroup & g = colorGroup();
227 p->setPen( QPen( black, 0, SolidLine ) ); 225 p->setPen( QPen( black, 0, SolidLine ) );
228 if ( !smallStyle && row ==selRow && col == selCol && 226 if ( !smallStyle && row ==selRow && col == selCol &&
229 style() != MotifStyle ) { 227 style() != MotifStyle ) {
230 int n = 2; 228 int n = 2;
231 p->drawRect( n, n, w-2*n, h-2*n ); 229 p->drawRect( n, n, w-2*n, h-2*n );
232 } 230 }
233 231
234 232
235 if ( style() == WindowsStyle ) { 233 if ( style() == WindowsStyle ) {
236 qDrawWinPanel( p, b, b , w - 2*b, h - 2*b, 234 qDrawWinPanel( p, b, b , w - 2*b, h - 2*b,
237 g, TRUE ); 235 g, TRUE );
238 b += 2; 236 b += 2;
239 } else { 237 } else {
240 if ( smallStyle ) { 238 if ( smallStyle ) {
241 qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, 239 qDrawShadePanel( p, b, b , w - 2*b, h - 2*b,
242 g, TRUE, 2 ); 240 g, TRUE, 2 );
243 b += 2; 241 b += 2;
244 } else { 242 } else {
245 int t = ( row == selRow && col == selCol ) ? 2 : 0; 243 int t = ( row == selRow && col == selCol ) ? 2 : 0;
246 b -= t; 244 b -= t;
247 qDrawShadePanel( p, b, b , w - 2*b, h - 2*b, 245 qDrawShadePanel( p, b, b , w - 2*b, h - 2*b,
248 g, TRUE, 2 ); 246 g, TRUE, 2 );
249 b += 2 + t; 247 b += 2 + t;
250 } 248 }
251 } 249 }
252 250
253 251
254 if ( (row == curRow) && (col == curCol) ) { 252 if ( (row == curRow) && (col == curCol) ) {
255 if ( smallStyle ) { 253 if ( smallStyle ) {
256 p->setPen ( white ); 254 p->setPen ( white );
257 p->drawRect( 1, 1, w-2, h-2 ); 255 p->drawRect( 1, 1, w-2, h-2 );
258 p->setPen ( black ); 256 p->setPen ( black );
259 p->drawRect( 0, 0, w, h ); 257 p->drawRect( 0, 0, w, h );
260 p->drawRect( 2, 2, w-4, h-4 ); 258 p->drawRect( 2, 2, w-4, h-4 );
261 b = 3; 259 b = 3;
262 } else if ( hasFocus() ) { 260 } else if ( hasFocus() ) {
263 style().drawFocusRect(p, QRect(0,0,w,h), g ); 261 style().drawFocusRect(p, QRect(0,0,w,h), g );
264 } 262 }
265 } 263 }
266 drawContents( p, row, col, QRect(b, b, w - 2*b, h - 2*b) ); 264 drawContents( p, row, col, QRect(b, b, w - 2*b, h - 2*b) );
267} 265}
268 266
269/*! 267/*!
270 Pass-through to QTableView::drawContents() to avoid hiding. 268 Pass-through to QTableView::drawContents() to avoid hiding.
271*/ 269*/
272void QWellArray::drawContents( QPainter *p ) 270void QWellArray::drawContents( QPainter *p )
273{ 271{
274 QTableView::drawContents(p); 272 QTableView::drawContents(p);
275} 273}
276 274
277/*! 275/*!
278 Reimplement this function to change the contents of the well array. 276 Reimplement this function to change the contents of the well array.
279 */ 277 */
280void QWellArray::drawContents( QPainter *p, int row, int col, const QRect &r ) 278void QWellArray::drawContents( QPainter *p, int row, int col, const QRect &r )
281{ 279{
282 280
283 if ( d ) { 281 if ( d ) {
284 p->fillRect( r, d->brush[row*nCols+col] ); 282 p->fillRect( r, d->brush[row*nCols+col] );
285 } else { 283 } else {
286 p->fillRect( r, white ); 284 p->fillRect( r, white );
287 p->setPen( black ); 285 p->setPen( black );
288 p->drawLine( r.topLeft(), r.bottomRight() ); 286 p->drawLine( r.topLeft(), r.bottomRight() );
289 p->drawLine( r.topRight(), r.bottomLeft() ); 287 p->drawLine( r.topRight(), r.bottomLeft() );
290 } 288 }
291} 289}
292 290
293 291
294/*\reimp 292/*\reimp
295*/ 293*/
296void QWellArray::mousePressEvent( QMouseEvent* e ) 294void QWellArray::mousePressEvent( QMouseEvent* e )
297{ 295{
298 // The current cell marker is set to the cell the mouse is pressed 296 // The current cell marker is set to the cell the mouse is pressed
299 // in. 297 // in.
300 QPoint pos = e->pos(); 298 QPoint pos = e->pos();
301 setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); 299 setCurrent( findRow( pos.y() ), findCol( pos.x() ) );
302} 300}
303 301
304/*\reimp 302/*\reimp
305*/ 303*/
306void QWellArray::mouseReleaseEvent( QMouseEvent* ) 304void QWellArray::mouseReleaseEvent( QMouseEvent* )
307{ 305{
308 // The current cell marker is set to the cell the mouse is clicked 306 // The current cell marker is set to the cell the mouse is clicked
309 // in. 307 // in.
310 setSelected( curRow, curCol ); 308 setSelected( curRow, curCol );
311} 309}
312 310
313 311
314/*\reimp 312/*\reimp
315*/ 313*/
316void QWellArray::mouseMoveEvent( QMouseEvent* e ) 314void QWellArray::mouseMoveEvent( QMouseEvent* e )
317{ 315{
318 // The current cell marker is set to the cell the mouse is 316 // The current cell marker is set to the cell the mouse is
319 // clicked in. 317 // clicked in.
320 if ( smallStyle ) { 318 if ( smallStyle ) {
321 QPoint pos = e->pos(); 319 QPoint pos = e->pos();
322 setCurrent( findRow( pos.y() ), findCol( pos.x() ) ); 320 setCurrent( findRow( pos.y() ), findCol( pos.x() ) );
323 } 321 }
324} 322}
325 323
326/* 324/*
327 Sets the cell currently having the focus. This is not necessarily 325 Sets the cell currently having the focus. This is not necessarily
328 the same as the currently selected cell. 326 the same as the currently selected cell.
329*/ 327*/
330 328
331void QWellArray::setCurrent( int row, int col ) 329void QWellArray::setCurrent( int row, int col )
332{ 330{
333 331
334 if ( (curRow == row) && (curCol == col) ) 332 if ( (curRow == row) && (curCol == col) )
335 return; 333 return;
336 334
337 if ( row < 0 || col < 0 ) 335 if ( row < 0 || col < 0 )
338 row = col = -1; 336 row = col = -1;
339 337
340 int oldRow = curRow; 338 int oldRow = curRow;
341 int oldCol = curCol; 339 int oldCol = curCol;
342 340
343 curRow = row; 341 curRow = row;
344 curCol = col; 342 curCol = col;
345 343
346 updateCell( oldRow, oldCol ); 344 updateCell( oldRow, oldCol );
347 updateCell( curRow, curCol ); 345 updateCell( curRow, curCol );
348} 346}
349 347
350 348
351/*! 349/*!
352 Sets the currently selected cell to \a row, \a col. If \a row or \a 350 Sets the currently selected cell to \a row, \a col. If \a row or \a
353 col are less than zero, the current cell is unselected. 351 col are less than zero, the current cell is unselected.
354 352
355 Does not set the position of the focus indicator. 353 Does not set the position of the focus indicator.
356*/ 354*/
357 355
358void QWellArray::setSelected( int row, int col ) 356void QWellArray::setSelected( int row, int col )
359{ 357{
360 if ( (selRow == row) && (selCol == col) ) 358 if ( (selRow == row) && (selCol == col) )
361 return; 359 return;
362 360
363 int oldRow = selRow; 361 int oldRow = selRow;
364 int oldCol = selCol; 362 int oldCol = selCol;
365 363
366 if ( row < 0 || col < 0 ) 364 if ( row < 0 || col < 0 )
367 row = col = -1; 365 row = col = -1;
368 366
369 selCol = col; 367 selCol = col;
370 selRow = row; 368 selRow = row;
371 369
372 updateCell( oldRow, oldCol ); 370 updateCell( oldRow, oldCol );
373 updateCell( selRow, selCol ); 371 updateCell( selRow, selCol );
374 if ( row >= 0 ) 372 if ( row >= 0 )
375 emit selected( row, col ); 373 emit selected( row, col );
376 374
377 if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") ) 375 if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") )
378 parentWidget()->close(); 376 parentWidget()->close();
379 377
380} 378}
381 379
382 380
383 381
384/*!\reimp 382/*!\reimp
385*/ 383*/
386void QWellArray::focusInEvent( QFocusEvent* ) 384void QWellArray::focusInEvent( QFocusEvent* )
387{ 385{
388 updateCell( curRow, curCol ); 386 updateCell( curRow, curCol );
389} 387}
390 388
391 389
392/*! 390/*!
393 Sets the size of the well array to be \c rows cells by \c cols. 391 Sets the size of the well array to be \c rows cells by \c cols.
394 Resets any brush info set by setCellBrush(). 392 Resets any brush info set by setCellBrush().
395 393
396 Must be called by reimplementors. 394 Must be called by reimplementors.
397 */ 395 */
398void QWellArray::setDimension( int rows, int cols ) 396void QWellArray::setDimension( int rows, int cols )
399{ 397{
400 nRows = rows; 398 nRows = rows;
401 nCols = cols; 399 nCols = cols;
402 if ( d ) { 400 if ( d ) {
403 if ( d->brush ) 401 if ( d->brush )
404 delete[] d->brush; 402 delete[] d->brush;
405 delete d; 403 delete d;
406 d = 0; 404 d = 0;
407 } 405 }
408 setNumCols( nCols ); 406 setNumCols( nCols );
409 setNumRows( nRows ); 407 setNumRows( nRows );
410} 408}
411 409
412void QWellArray::setCellBrush( int row, int col, const QBrush &b ) 410void QWellArray::setCellBrush( int row, int col, const QBrush &b )
413{ 411{
414 if ( !d ) { 412 if ( !d ) {
415 d = new QWellArrayData; 413 d = new QWellArrayData;
416 d->brush = new QBrush[nRows*nCols]; 414 d->brush = new QBrush[nRows*nCols];
417 } 415 }
418 if ( row >= 0 && row < nRows && col >= 0 && col < nCols ) 416 if ( row >= 0 && row < nRows && col >= 0 && col < nCols )
419 d->brush[row*nCols+col] = b; 417 d->brush[row*nCols+col] = b;
420#ifdef CHECK_RANGE 418#ifdef CHECK_RANGE
421 else 419 else
422 qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col ); 420 qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col );
423#endif 421#endif
424} 422}
425 423
426 424
427 425
428/*! 426/*!
429 Returns the brush set for the cell at \a row, \a col. If no brush is set, 427 Returns the brush set for the cell at \a row, \a col. If no brush is set,
430 \c NoBrush is returned. 428 \c NoBrush is returned.
431*/ 429*/
432 430
433QBrush QWellArray::cellBrush( int row, int col ) 431QBrush QWellArray::cellBrush( int row, int col )
434{ 432{
435 if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols ) 433 if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols )
436 return d->brush[row*nCols+col]; 434 return d->brush[row*nCols+col];
437 return NoBrush; 435 return NoBrush;
438} 436}
439 437
440 438
441 439
442/*!\reimp 440/*!\reimp
443*/ 441*/
444 442
445void QWellArray::focusOutEvent( QFocusEvent* ) 443void QWellArray::focusOutEvent( QFocusEvent* )
446{ 444{
447 updateCell( curRow, curCol ); 445 updateCell( curRow, curCol );
448} 446}
449 447
450/*\reimp 448/*\reimp
451*/ 449*/
452void QWellArray::keyPressEvent( QKeyEvent* e ) 450void QWellArray::keyPressEvent( QKeyEvent* e )
453{ 451{
454 switch( e->key() ) { // Look at the key code 452 switch( e->key() ) { // Look at the key code
455 case Key_Left: // If 'left arrow'-key, 453 case Key_Left: // If 'left arrow'-key,
456 if( curCol > 0 ) { // and cr't not in leftmost col 454 if( curCol > 0 ) { // and cr't not in leftmost col
457 setCurrent( curRow, curCol - 1);// set cr't to next left column 455 setCurrent( curRow, curCol - 1);// set cr't to next left column
458 int edge = leftCell(); // find left edge 456 int edge = leftCell(); // find left edge
459 if ( curCol < edge ) // if we have moved off edge, 457 if ( curCol < edge ) // if we have moved off edge,
460 setLeftCell( edge - 1 );// scroll view to rectify 458 setLeftCell( edge - 1 );// scroll view to rectify
461 } 459 }
462 break; 460 break;
463 case Key_Right: // Correspondingly... 461 case Key_Right: // Correspondingly...
464 if( curCol < numCols()-1 ) { 462 if( curCol < numCols()-1 ) {
465 setCurrent( curRow, curCol + 1); 463 setCurrent( curRow, curCol + 1);
466 int edge = lastColVisible(); 464 int edge = lastColVisible();
467 if ( curCol >= edge ) 465 if ( curCol >= edge )
468 setLeftCell( leftCell() + 1 ); 466 setLeftCell( leftCell() + 1 );
469 } 467 }
470 break; 468 break;
471 case Key_Up: 469 case Key_Up:
472 if( curRow > 0 ) { 470 if( curRow > 0 ) {
473 setCurrent( curRow - 1, curCol); 471 setCurrent( curRow - 1, curCol);
474 int edge = topCell(); 472 int edge = topCell();
475 if ( curRow < edge ) 473 if ( curRow < edge )
476 setTopCell( edge - 1 ); 474 setTopCell( edge - 1 );
477 } else if ( smallStyle ) 475 } else if ( smallStyle )
478 focusNextPrevChild( FALSE ); 476 focusNextPrevChild( FALSE );
479 break; 477 break;
480 case Key_Down: 478 case Key_Down:
481 if( curRow < numRows()-1 ) { 479 if( curRow < numRows()-1 ) {
482 setCurrent( curRow + 1, curCol); 480 setCurrent( curRow + 1, curCol);
483 int edge = lastRowVisible(); 481 int edge = lastRowVisible();
484 if ( curRow >= edge ) 482 if ( curRow >= edge )
485 setTopCell( topCell() + 1 ); 483 setTopCell( topCell() + 1 );
486 } else if ( smallStyle ) 484 } else if ( smallStyle )
487 focusNextPrevChild( TRUE ); 485 focusNextPrevChild( TRUE );
488 break; 486 break;
489 case Key_Space: 487 case Key_Space:
490 case Key_Return: 488 case Key_Return:
491 case Key_Enter: 489 case Key_Enter:
492 setSelected( curRow, curCol ); 490 setSelected( curRow, curCol );
493 break; 491 break;
494 default: // If not an interesting key, 492 default: // If not an interesting key,
495 e->ignore(); // we don't accept the event 493 e->ignore(); // we don't accept the event
496 return; 494 return;
497 } 495 }
498 496
499} 497}
500 498
501//////////// QWellArray END 499//////////// QWellArray END
502 500
503static bool initrgb = FALSE; 501static bool initrgb = FALSE;
504static QRgb stdrgb[6*8]; 502static QRgb stdrgb[6*8];
505static QRgb cusrgb[2*8]; 503static QRgb cusrgb[2*8];
506 504
507 505
508static void initRGB() 506static void initRGB()
509{ 507{
510 if ( initrgb ) 508 if ( initrgb )
511 return; 509 return;
512 initrgb = TRUE; 510 initrgb = TRUE;
513 int i = 0; 511 int i = 0;
514 for ( int g = 0; g < 4; g++ ) 512 for ( int g = 0; g < 4; g++ )
515 for ( int r = 0; r < 4; r++ ) 513 for ( int r = 0; r < 4; r++ )
516 for ( int b = 0; b < 3; b++ ) 514 for ( int b = 0; b < 3; b++ )
517 stdrgb[i++] = qRgb( r*255/3, g*255/3, b*255/2 ); 515 stdrgb[i++] = qRgb( r*255/3, g*255/3, b*255/2 );
518 516
519 for ( i = 0; i < 2*8; i++ ) 517 for ( i = 0; i < 2*8; i++ )
520 cusrgb[i] = qRgb(0xff,0xff,0xff); 518 cusrgb[i] = qRgb(0xff,0xff,0xff);
521} 519}
522 520
523/*! 521/*!
524 Returns the number of custom colors supported by 522 Returns the number of custom colors supported by
525 QColorDialog. All color dialogs share the same custom colors. 523 QColorDialog. All color dialogs share the same custom colors.
526*/ 524*/
527int QColorDialog::customCount() 525int QColorDialog::customCount()
528{ 526{
529 return 2*8; 527 return 2*8;
530} 528}
531 529
532/*! 530/*!
533 Returns custom color number \a i as a QRgb. 531 Returns custom color number \a i as a QRgb.
534 */ 532 */
535QRgb QColorDialog::customColor( int i ) 533QRgb QColorDialog::customColor( int i )
536{ 534{
537 initRGB(); 535 initRGB();
538 if ( i < 0 || i >= customCount() ) { 536 if ( i < 0 || i >= customCount() ) {
539#ifdef CHECK_RANGE 537#ifdef CHECK_RANGE
540 qWarning( "QColorDialog::customColor() index %d out of range", i ); 538 qWarning( "QColorDialog::customColor() index %d out of range", i );
541 #endif 539 #endif
542 i = 0; 540 i = 0;
543 } 541 }
544 return cusrgb[i]; 542 return cusrgb[i];
545} 543}
546 544
547/*! 545/*!
548 Sets custom color number \a i to the QRgb value \a c. 546 Sets custom color number \a i to the QRgb value \a c.
549*/ 547*/
550void QColorDialog::setCustomColor( int i, QRgb c ) 548void QColorDialog::setCustomColor( int i, QRgb c )
551{ 549{
552 initRGB(); 550 initRGB();
553 if ( i < 0 || i >= customCount() ) { 551 if ( i < 0 || i >= customCount() ) {
554#ifdef CHECK_RANGE 552#ifdef CHECK_RANGE
555 qWarning( "QColorDialog::customColor() index %d out of range", i ); 553 qWarning( "QColorDialog::customColor() index %d out of range", i );
556 #endif 554 #endif
557 return; 555 return;
558 } 556 }
559 cusrgb[i] = c; 557 cusrgb[i] = c;
560} 558}
561 559
562static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v ) 560static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v )
563{ 561{
564 QColor c; 562 QColor c;
565 c.setRgb( rgb ); 563 c.setRgb( rgb );
566 c.getHsv(h,s,v); 564 c.getHsv(h,s,v);
567} 565}
568 566
569class QColorWell : public QWellArray 567class QColorWell : public QWellArray
570{ 568{
571public: 569public:
572 QColorWell( QWidget *parent, int r, int c, QRgb *vals ) 570 QColorWell( QWidget *parent, int r, int c, QRgb *vals )
573 :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 ) 571 :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 )
574 { setDimension(r,c); setWFlags( WResizeNoErase ); } 572 { setDimension(r,c); setWFlags( WResizeNoErase ); }
575 QSizePolicy sizePolicy() const; 573 QSizePolicy sizePolicy() const;
576 574
577protected: 575protected:
578 void drawContents( QPainter *, int row, int col, const QRect& ); 576 void drawContents( QPainter *, int row, int col, const QRect& );
579 void drawContents( QPainter *p ) { QWellArray::drawContents(p); } 577 void drawContents( QPainter *p ) { QWellArray::drawContents(p); }
580 void mousePressEvent( QMouseEvent *e ); 578 void mousePressEvent( QMouseEvent *e );
581 void mouseMoveEvent( QMouseEvent *e ); 579 void mouseMoveEvent( QMouseEvent *e );
582 void mouseReleaseEvent( QMouseEvent *e ); 580 void mouseReleaseEvent( QMouseEvent *e );
583#ifndef QT_NO_DRAGANDDROP 581#ifndef QT_NO_DRAGANDDROP
584 void dragEnterEvent( QDragEnterEvent *e ); 582 void dragEnterEvent( QDragEnterEvent *e );
585 void dragLeaveEvent( QDragLeaveEvent *e ); 583 void dragLeaveEvent( QDragLeaveEvent *e );
586 void dragMoveEvent( QDragMoveEvent *e ); 584 void dragMoveEvent( QDragMoveEvent *e );
587 void dropEvent( QDropEvent *e ); 585 void dropEvent( QDropEvent *e );
588#endif 586#endif
589 587
590private: 588private:
591 QRgb *values; 589 QRgb *values;
592 bool mousePressed; 590 bool mousePressed;
593 QPoint pressPos; 591 QPoint pressPos;
594 QPoint oldCurrent; 592 QPoint oldCurrent;
595 593
596}; 594};
597 595
598QSizePolicy QColorWell::sizePolicy() const 596QSizePolicy QColorWell::sizePolicy() const
599{ 597{
600 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); 598 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
601} 599}
602 600
603void QColorWell::drawContents( QPainter *p, int row, int col, const QRect &r ) 601void QColorWell::drawContents( QPainter *p, int row, int col, const QRect &r )
604{ 602{
605 int i = row + col*numRows(); 603 int i = row + col*numRows();
606 p->fillRect( r, QColor( values[i] ) ); 604 p->fillRect( r, QColor( values[i] ) );
607} 605}
608 606
609void QColorWell::mousePressEvent( QMouseEvent *e ) 607void QColorWell::mousePressEvent( QMouseEvent *e )
610{ 608{
611 oldCurrent = QPoint( selectedRow(), selectedColumn() ); 609 oldCurrent = QPoint( selectedRow(), selectedColumn() );
612 QWellArray::mousePressEvent( e ); 610 QWellArray::mousePressEvent( e );
613 mousePressed = TRUE; 611 mousePressed = TRUE;
614 pressPos = e->pos(); 612 pressPos = e->pos();
615} 613}
616 614
617void QColorWell::mouseMoveEvent( QMouseEvent *e ) 615void QColorWell::mouseMoveEvent( QMouseEvent *e )
618{ 616{
619 QWellArray::mouseMoveEvent( e ); 617 QWellArray::mouseMoveEvent( e );
620#ifndef QT_NO_DRAGANDDROP 618#ifndef QT_NO_DRAGANDDROP
621 if ( !mousePressed ) 619 if ( !mousePressed )
622 return; 620 return;
623 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { 621 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) {
624 setCurrent( oldCurrent.x(), oldCurrent.y() ); 622 setCurrent( oldCurrent.x(), oldCurrent.y() );
625 int i = findRow( e->y() ) + findCol( e->x() ) * numRows(); 623 int i = findRow( e->y() ) + findCol( e->x() ) * numRows();
626 QColor col( values[ i ] ); 624 QColor col( values[ i ] );
627 QColorDrag *drg = new QColorDrag( col, this ); 625 QColorDrag *drg = new QColorDrag( col, this );
628 QPixmap pix( cellWidth(), cellHeight() ); 626 QPixmap pix( cellWidth(), cellHeight() );
629 pix.fill( col ); 627 pix.fill( col );
630 QPainter p( &pix ); 628 QPainter p( &pix );
631 p.drawRect( 0, 0, pix.width(), pix.height() ); 629 p.drawRect( 0, 0, pix.width(), pix.height() );
632 p.end(); 630 p.end();
633 drg->setPixmap( pix ); 631 drg->setPixmap( pix );
634 mousePressed = FALSE; 632 mousePressed = FALSE;
635 drg->dragCopy(); 633 drg->dragCopy();
636 } 634 }
637#endif 635#endif
638} 636}
639 637
640#ifndef QT_NO_DRAGANDDROP 638#ifndef QT_NO_DRAGANDDROP
641void QColorWell::dragEnterEvent( QDragEnterEvent *e ) 639void QColorWell::dragEnterEvent( QDragEnterEvent *e )
642{ 640{
643 setFocus(); 641 setFocus();
644 if ( QColorDrag::canDecode( e ) ) 642 if ( QColorDrag::canDecode( e ) )
645 e->accept(); 643 e->accept();
646 else 644 else
647 e->ignore(); 645 e->ignore();
648} 646}
649 647
650void QColorWell::dragLeaveEvent( QDragLeaveEvent * ) 648void QColorWell::dragLeaveEvent( QDragLeaveEvent * )
651{ 649{
652 if ( hasFocus() ) 650 if ( hasFocus() )
653 parentWidget()->setFocus(); 651 parentWidget()->setFocus();
654} 652}
655 653
656void QColorWell::dragMoveEvent( QDragMoveEvent *e ) 654void QColorWell::dragMoveEvent( QDragMoveEvent *e )
657{ 655{
658 if ( QColorDrag::canDecode( e ) ) { 656 if ( QColorDrag::canDecode( e ) ) {
659 setCurrent( findRow( e->pos().y() ), findCol( e->pos().x() ) ); 657 setCurrent( findRow( e->pos().y() ), findCol( e->pos().x() ) );
660 e->accept(); 658 e->accept();
661 } else 659 } else
662 e->ignore(); 660 e->ignore();
663} 661}
664 662
665void QColorWell::dropEvent( QDropEvent *e ) 663void QColorWell::dropEvent( QDropEvent *e )
666{ 664{
667 if ( QColorDrag::canDecode( e ) ) { 665 if ( QColorDrag::canDecode( e ) ) {
668 int i = findRow( e->pos().y() ) + findCol( e->pos().x() ) * numRows(); 666 int i = findRow( e->pos().y() ) + findCol( e->pos().x() ) * numRows();
669 QColor col; 667 QColor col;
670 QColorDrag::decode( e, col ); 668 QColorDrag::decode( e, col );
671 values[ i ] = col.rgb(); 669 values[ i ] = col.rgb();
672 repaint( FALSE ); 670 repaint( FALSE );
673 e->accept(); 671 e->accept();
674 } else { 672 } else {
675 e->ignore(); 673 e->ignore();
676 } 674 }
677} 675}
678 676
679#endif // QT_NO_DRAGANDDROP 677#endif // QT_NO_DRAGANDDROP
680 678
681void QColorWell::mouseReleaseEvent( QMouseEvent *e ) 679void QColorWell::mouseReleaseEvent( QMouseEvent *e )
682{ 680{
683 if ( !mousePressed ) 681 if ( !mousePressed )
684 return; 682 return;
685 QWellArray::mouseReleaseEvent( e ); 683 QWellArray::mouseReleaseEvent( e );
686 mousePressed = FALSE; 684 mousePressed = FALSE;
687} 685}
688 686
689class QColorPicker : public QFrame 687class QColorPicker : public QFrame
690{ 688{
691 Q_OBJECT 689 Q_OBJECT
692public: 690public:
693 QColorPicker(QWidget* parent=0, const char* name=0); 691 QColorPicker(QWidget* parent=0, const char* name=0);
694 ~QColorPicker(); 692 ~QColorPicker();
695 693
696public slots: 694public slots:
697 void setCol( int h, int s ); 695 void setCol( int h, int s );
698 696
699signals: 697signals:
700 void newCol( int h, int s ); 698 void newCol( int h, int s );
701 699
702protected: 700protected:
703 QSize sizeHint() const; 701 QSize sizeHint() const;
704 QSizePolicy sizePolicy() const; 702 QSizePolicy sizePolicy() const;
705 void drawContents(QPainter* p); 703 void drawContents(QPainter* p);
706 void mouseMoveEvent( QMouseEvent * ); 704 void mouseMoveEvent( QMouseEvent * );
707 void mousePressEvent( QMouseEvent * ); 705 void mousePressEvent( QMouseEvent * );
708 706
709private: 707private:
710 int hue; 708 int hue;
711 int sat; 709 int sat;
712 710
713 QPoint colPt(); 711 QPoint colPt();
714 int huePt( const QPoint &pt ); 712 int huePt( const QPoint &pt );
715 int satPt( const QPoint &pt ); 713 int satPt( const QPoint &pt );
716 void setCol( const QPoint &pt ); 714 void setCol( const QPoint &pt );
717 715
718 QPixmap *pix; 716 QPixmap *pix;
719}; 717};
720 718
721static int pWidth = 200; 719static int pWidth = 200;
722static int pHeight = 200; 720static int pHeight = 200;
723 721
724class QColorLuminancePicker : public QWidget 722class QColorLuminancePicker : public QWidget
725{ 723{
726 Q_OBJECT 724 Q_OBJECT
727public: 725public:
728 QColorLuminancePicker(QWidget* parent=0, const char* name=0); 726 QColorLuminancePicker(QWidget* parent=0, const char* name=0);
729 ~QColorLuminancePicker(); 727 ~QColorLuminancePicker();
730 728
731public slots: 729public slots:
732 void setCol( int h, int s, int v ); 730 void setCol( int h, int s, int v );
733 void setCol( int h, int s ); 731 void setCol( int h, int s );
734 732
735signals: 733signals:
736 void newHsv( int h, int s, int v ); 734 void newHsv( int h, int s, int v );
737 735
738protected: 736protected:
739// QSize sizeHint() const; 737// QSize sizeHint() const;
740// QSizePolicy sizePolicy() const; 738// QSizePolicy sizePolicy() const;
741 void paintEvent( QPaintEvent*); 739 void paintEvent( QPaintEvent*);
742 void mouseMoveEvent( QMouseEvent * ); 740 void mouseMoveEvent( QMouseEvent * );
743 void mousePressEvent( QMouseEvent * ); 741 void mousePressEvent( QMouseEvent * );
744 742
745private: 743private:
746 enum { foff = 3, coff = 4 }; //frame and contents offset 744 enum { foff = 3, coff = 4 }; //frame and contents offset
747 int val; 745 int val;
748 int hue; 746 int hue;
749 int sat; 747 int sat;
750 748
751 int y2val( int y ); 749 int y2val( int y );
752 int val2y( int val ); 750 int val2y( int val );
753 void setVal( int v ); 751 void setVal( int v );
754 752
755 QPixmap *pix; 753 QPixmap *pix;
756}; 754};
757 755
758 756
759int QColorLuminancePicker::y2val( int y ) 757int QColorLuminancePicker::y2val( int y )
760{ 758{
761 int d = height() - 2*coff - 1; 759 int d = height() - 2*coff - 1;
762 return 255 - (y - coff)*255/d; 760 return 255 - (y - coff)*255/d;
763} 761}
764 762
765int QColorLuminancePicker::val2y( int v ) 763int QColorLuminancePicker::val2y( int v )
766{ 764{
767 int d = height() - 2*coff - 1; 765 int d = height() - 2*coff - 1;
768 return coff + (255-v)*d/255; 766 return coff + (255-v)*d/255;
769} 767}
770 768
771QColorLuminancePicker::QColorLuminancePicker(QWidget* parent, 769QColorLuminancePicker::QColorLuminancePicker(QWidget* parent,
772 const char* name) 770 const char* name)
773 :QWidget( parent, name ) 771 :QWidget( parent, name )
774{ 772{
775 hue = 100; val = 100; sat = 100; 773 hue = 100; val = 100; sat = 100;
776 pix = 0; 774 pix = 0;
777 // setBackgroundMode( NoBackground ); 775 // setBackgroundMode( NoBackground );
778} 776}
779 777
780QColorLuminancePicker::~QColorLuminancePicker() 778QColorLuminancePicker::~QColorLuminancePicker()
781{ 779{
782 delete pix; 780 delete pix;
783} 781}
784 782
785void QColorLuminancePicker::mouseMoveEvent( QMouseEvent *m ) 783void QColorLuminancePicker::mouseMoveEvent( QMouseEvent *m )
786{ 784{
787 setVal( y2val(m->y()) ); 785 setVal( y2val(m->y()) );
788} 786}
789void QColorLuminancePicker::mousePressEvent( QMouseEvent *m ) 787void QColorLuminancePicker::mousePressEvent( QMouseEvent *m )
790{ 788{
791 setVal( y2val(m->y()) ); 789 setVal( y2val(m->y()) );
792} 790}
793 791
794void QColorLuminancePicker::setVal( int v ) 792void QColorLuminancePicker::setVal( int v )
795{ 793{
796 if ( val == v ) 794 if ( val == v )
797 return; 795 return;
798 val = QMAX( 0, QMIN(v,255)); 796 val = QMAX( 0, QMIN(v,255));
799 delete pix; pix=0; 797 delete pix; pix=0;
800 repaint( FALSE ); //### 798 repaint( FALSE ); //###
801 emit newHsv( hue, sat, val ); 799 emit newHsv( hue, sat, val );
802} 800}
803 801
804//receives from a hue,sat chooser and relays. 802//receives from a hue,sat chooser and relays.
805void QColorLuminancePicker::setCol( int h, int s ) 803void QColorLuminancePicker::setCol( int h, int s )
806{ 804{
807 setCol( h, s, val ); 805 setCol( h, s, val );
808 emit newHsv( h, s, val ); 806 emit newHsv( h, s, val );
809} 807}
810 808
811void QColorLuminancePicker::paintEvent( QPaintEvent * ) 809void QColorLuminancePicker::paintEvent( QPaintEvent * )
812{ 810{
813 int w = width() - 5; 811 int w = width() - 5;
814 812
815 QRect r( 0, foff, w, height() - 2*foff ); 813 QRect r( 0, foff, w, height() - 2*foff );
816 int wi = r.width() - 2; 814 int wi = r.width() - 2;
817 int hi = r.height() - 2; 815 int hi = r.height() - 2;
818 if ( !pix || pix->height() != hi || pix->width() != wi ) { 816 if ( !pix || pix->height() != hi || pix->width() != wi ) {
819 delete pix; 817 delete pix;
820 QImage img( wi, hi, 32 ); 818 QImage img( wi, hi, 32 );
821 int y; 819 int y;
822 for ( y = 0; y < hi; y++ ) { 820 for ( y = 0; y < hi; y++ ) {
823 QColor c( hue, sat, y2val(y+coff), QColor::Hsv ); 821 QColor c( hue, sat, y2val(y+coff), QColor::Hsv );
824 QRgb r = c.rgb(); 822 QRgb r = c.rgb();
825 int x; 823 int x;
826 for ( x = 0; x < wi; x++ ) 824 for ( x = 0; x < wi; x++ )
827 img.setPixel( x, y, r ); 825 img.setPixel( x, y, r );
828 } 826 }
829 pix = new QPixmap; 827 pix = new QPixmap;
830 pix->convertFromImage(img); 828 pix->convertFromImage(img);
831 } 829 }
832 QPainter p(this); 830 QPainter p(this);
833 p.drawPixmap( 1, coff, *pix ); 831 p.drawPixmap( 1, coff, *pix );
834 QColorGroup g = colorGroup(); 832 QColorGroup g = colorGroup();
835 qDrawShadePanel( &p, r, g, TRUE ); 833 qDrawShadePanel( &p, r, g, TRUE );
836 p.setPen( g.foreground() ); 834 p.setPen( g.foreground() );
837 p.setBrush( g.foreground() ); 835 p.setBrush( g.foreground() );
838 QPointArray a; 836 QPointArray a;
839 int y = val2y(val); 837 int y = val2y(val);
840 a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 ); 838 a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 );
841 erase( w, 0, 5, height() ); 839 erase( w, 0, 5, height() );
842 p.drawPolygon( a ); 840 p.drawPolygon( a );
843} 841}
844 842
845void QColorLuminancePicker::setCol( int h, int s , int v ) 843void QColorLuminancePicker::setCol( int h, int s , int v )
846{ 844{
847 val = v; 845 val = v;
848 hue = h; 846 hue = h;
849 sat = s; 847 sat = s;
850 delete pix; pix=0; 848 delete pix; pix=0;
851 repaint( FALSE );//#### 849 repaint( FALSE );//####
852} 850}
853 851
854QPoint QColorPicker::colPt() 852QPoint QColorPicker::colPt()
855{ return QPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); } 853{ return QPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); }
856int QColorPicker::huePt( const QPoint &pt ) 854int QColorPicker::huePt( const QPoint &pt )
857{ return 360 - pt.x()*360/(pWidth-1); } 855{ return 360 - pt.x()*360/(pWidth-1); }
858int QColorPicker::satPt( const QPoint &pt ) 856int QColorPicker::satPt( const QPoint &pt )
859{ return 255 - pt.y()*255/(pHeight-1) ; } 857{ return 255 - pt.y()*255/(pHeight-1) ; }
860void QColorPicker::setCol( const QPoint &pt ) 858void QColorPicker::setCol( const QPoint &pt )
861{ setCol( huePt(pt), satPt(pt) ); } 859{ setCol( huePt(pt), satPt(pt) ); }
862 860
863QColorPicker::QColorPicker(QWidget* parent, const char* name ) 861QColorPicker::QColorPicker(QWidget* parent, const char* name )
864 : QFrame( parent, name ) 862 : QFrame( parent, name )
865{ 863{
866 hue = 0; sat = 0; 864 hue = 0; sat = 0;
867 setCol( 150, 255 ); 865 setCol( 150, 255 );
868 866
869 QImage img( pWidth, pHeight, 32 ); 867 QImage img( pWidth, pHeight, 32 );
870 int x,y; 868 int x,y;
871 for ( y = 0; y < pHeight; y++ ) 869 for ( y = 0; y < pHeight; y++ )
872 for ( x = 0; x < pWidth; x++ ) { 870 for ( x = 0; x < pWidth; x++ ) {
873 QPoint p( x, y ); 871 QPoint p( x, y );
874 img.setPixel( x, y, QColor(huePt(p), satPt(p), 872 img.setPixel( x, y, QColor(huePt(p), satPt(p),
875 200, QColor::Hsv).rgb() ); 873 200, QColor::Hsv).rgb() );
876 } 874 }
877 pix = new QPixmap; 875 pix = new QPixmap;
878 pix->convertFromImage(img); 876 pix->convertFromImage(img);
879 setBackgroundMode( NoBackground ); 877 setBackgroundMode( NoBackground );
880} 878}
881 879
882QColorPicker::~QColorPicker() 880QColorPicker::~QColorPicker()
883{ 881{
884 delete pix; 882 delete pix;
885} 883}
886 884
887QSize QColorPicker::sizeHint() const 885QSize QColorPicker::sizeHint() const
888{ 886{
889 return QSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() ); 887 return QSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() );
890} 888}
891 889
892QSizePolicy QColorPicker::sizePolicy() const 890QSizePolicy QColorPicker::sizePolicy() const
893{ 891{
894 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); 892 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
895} 893}
896 894
897void QColorPicker::setCol( int h, int s ) 895void QColorPicker::setCol( int h, int s )
898{ 896{
899 int nhue = QMIN( QMAX(0,h), 360 ); 897 int nhue = QMIN( QMAX(0,h), 360 );
900 int nsat = QMIN( QMAX(0,s), 255); 898 int nsat = QMIN( QMAX(0,s), 255);
901 if ( nhue == hue && nsat == sat ) 899 if ( nhue == hue && nsat == sat )
902 return; 900 return;
903 QRect r( colPt(), QSize(20,20) ); 901 QRect r( colPt(), QSize(20,20) );
904 hue = nhue; sat = nsat; 902 hue = nhue; sat = nsat;
905 r = r.unite( QRect( colPt(), QSize(20,20) ) ); 903 r = r.unite( QRect( colPt(), QSize(20,20) ) );
906 r.moveBy( contentsRect().x()-9, contentsRect().y()-9 ); 904 r.moveBy( contentsRect().x()-9, contentsRect().y()-9 );
907 // update( r ); 905 // update( r );
908 repaint( r, FALSE ); 906 repaint( r, FALSE );
909} 907}
910 908
911void QColorPicker::mouseMoveEvent( QMouseEvent *m ) 909void QColorPicker::mouseMoveEvent( QMouseEvent *m )
912{ 910{
913 QPoint p = m->pos() - contentsRect().topLeft(); 911 QPoint p = m->pos() - contentsRect().topLeft();
914 setCol( p ); 912 setCol( p );
915 emit newCol( hue, sat ); 913 emit newCol( hue, sat );
916} 914}
917 915
918void QColorPicker::mousePressEvent( QMouseEvent *m ) 916void QColorPicker::mousePressEvent( QMouseEvent *m )
919{ 917{
920 QPoint p = m->pos() - contentsRect().topLeft(); 918 QPoint p = m->pos() - contentsRect().topLeft();
921 setCol( p ); 919 setCol( p );
922 emit newCol( hue, sat ); 920 emit newCol( hue, sat );
923} 921}
924 922
925void QColorPicker::drawContents(QPainter* p) 923void QColorPicker::drawContents(QPainter* p)
926{ 924{
927 QRect r = contentsRect(); 925 QRect r = contentsRect();
928 926
929 p->drawPixmap( r.topLeft(), *pix ); 927 p->drawPixmap( r.topLeft(), *pix );
930 QPoint pt = colPt() + r.topLeft(); 928 QPoint pt = colPt() + r.topLeft();
931 p->setPen( QPen(black) ); 929 p->setPen( QPen(black) );
932 930
933 p->fillRect( pt.x()-9, pt.y(), 20, 2, black ); 931 p->fillRect( pt.x()-9, pt.y(), 20, 2, black );
934 p->fillRect( pt.x(), pt.y()-9, 2, 20, black ); 932 p->fillRect( pt.x(), pt.y()-9, 2, 20, black );
935 933
936} 934}
937 935
938class QColorShowLabel; 936class QColorShowLabel;
939 937
940 938
941 939
942class QColIntValidator: public QIntValidator 940class QColIntValidator: public QIntValidator
943{ 941{
944public: 942public:
945 QColIntValidator( int bottom, int top, 943 QColIntValidator( int bottom, int top,
946 QWidget * parent, const char *name = 0 ) 944 QWidget * parent, const char *name = 0 )
947 :QIntValidator( bottom, top, parent, name ) {} 945 :QIntValidator( bottom, top, parent, name ) {}
948 946
949 QValidator::State validate( QString &, int & ) const; 947 QValidator::State validate( QString &, int & ) const;
950}; 948};
951 949
952QValidator::State QColIntValidator::validate( QString &s, int &pos ) const 950QValidator::State QColIntValidator::validate( QString &s, int &pos ) const
953{ 951{
954 State state = QIntValidator::validate(s,pos); 952 State state = QIntValidator::validate(s,pos);
955 if ( state == Valid ) { 953 if ( state == Valid ) {
956 long int val = s.toLong(); 954 long int val = s.toLong();
957 // This is not a general solution, assumes that top() > 0 and 955 // This is not a general solution, assumes that top() > 0 and
958 // bottom >= 0 956 // bottom >= 0
959 if ( val < 0 ) { 957 if ( val < 0 ) {
960 s = "0"; 958 s = "0";
961 pos = 1; 959 pos = 1;
962 } else if ( val > top() ) { 960 } else if ( val > top() ) {
963 s.setNum( top() ); 961 s.setNum( top() );
964 pos = s.length(); 962 pos = s.length();
965 } 963 }
966 } 964 }
967 return state; 965 return state;
968} 966}
969 967
970 968
971 969
972class QColNumLineEdit : public QLineEdit 970class QColNumLineEdit : public QLineEdit
973{ 971{
974public: 972public:
975 QColNumLineEdit( QWidget *parent, const char* name = 0 ) 973 QColNumLineEdit( QWidget *parent, const char* name = 0 )
976 : QLineEdit( parent, name ) { setMaxLength( 3 );} 974 : QLineEdit( parent, name ) { setMaxLength( 3 );}
977 QSize sizeHint() const { 975 QSize sizeHint() const {
978 return QSize( 30, //##### 976 return QSize( 30, //#####
979 QLineEdit::sizeHint().height() ); } 977 QLineEdit::sizeHint().height() ); }
980 void setNum( int i ) { 978 void setNum( int i ) {
981 QString s; 979 QString s;
982 s.setNum(i); 980 s.setNum(i);
983 bool block = signalsBlocked(); 981 bool block = signalsBlocked();
984 blockSignals(TRUE); 982 blockSignals(TRUE);
985 setText( s ); 983 setText( s );
986 blockSignals(block); 984 blockSignals(block);
987 } 985 }
988 int val() const { return text().toInt(); } 986 int val() const { return text().toInt(); }
989}; 987};
990 988
991 989
992class QColorShower : public QWidget 990class QColorShower : public QWidget
993{ 991{
994 Q_OBJECT 992 Q_OBJECT
995public: 993public:
996 QColorShower( QWidget *parent, const char *name = 0 ); 994 QColorShower( QWidget *parent, const char *name = 0 );
997 995
998 //things that don't emit signals 996 //things that don't emit signals
999 void setHsv( int h, int s, int v ); 997 void setHsv( int h, int s, int v );
1000 998
1001 int currentAlpha() const { return alphaEd->val(); } 999 int currentAlpha() const { return alphaEd->val(); }
1002 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); } 1000 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
1003 void showAlpha( bool b ); 1001 void showAlpha( bool b );
1004 1002
1005 1003
1006 QRgb currentColor() const { return curCol; } 1004 QRgb currentColor() const { return curCol; }
1007 1005
1008public slots: 1006public slots:
1009 void setRgb( QRgb rgb ); 1007 void setRgb( QRgb rgb );
1010 1008
1011signals: 1009signals:
1012 void newCol( QRgb rgb ); 1010 void newCol( QRgb rgb );
1013private slots: 1011private slots:
1014 void rgbEd(); 1012 void rgbEd();
1015 void hsvEd(); 1013 void hsvEd();
1016private: 1014private:
1017 void showCurrentColor(); 1015 void showCurrentColor();
1018 int hue, sat, val; 1016 int hue, sat, val;
1019 QRgb curCol; 1017 QRgb curCol;
1020 QColNumLineEdit *hEd; 1018 QColNumLineEdit *hEd;
1021 QColNumLineEdit *sEd; 1019 QColNumLineEdit *sEd;
1022 QColNumLineEdit *vEd; 1020 QColNumLineEdit *vEd;
1023 QColNumLineEdit *rEd; 1021 QColNumLineEdit *rEd;
1024 QColNumLineEdit *gEd; 1022 QColNumLineEdit *gEd;
1025 QColNumLineEdit *bEd; 1023 QColNumLineEdit *bEd;
1026 QColNumLineEdit *alphaEd; 1024 QColNumLineEdit *alphaEd;
1027 QLabel *alphaLab; 1025 QLabel *alphaLab;
1028 QColorShowLabel *lab; 1026 QColorShowLabel *lab;
1029 bool rgbOriginal; 1027 bool rgbOriginal;
1030}; 1028};
1031 1029
1032class QColorShowLabel : public QFrame 1030class QColorShowLabel : public QFrame
1033{ 1031{
1034 Q_OBJECT 1032 Q_OBJECT
1035 1033
1036public: 1034public:
1037 QColorShowLabel( QWidget *parent ) :QFrame( parent ) { 1035 QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
1038 setFrameStyle( QFrame::Panel|QFrame::Sunken ); 1036 setFrameStyle( QFrame::Panel|QFrame::Sunken );
1039 setBackgroundMode( PaletteBackground ); 1037 setBackgroundMode( PaletteBackground );
1040 setAcceptDrops( TRUE ); 1038 setAcceptDrops( TRUE );
1041 mousePressed = FALSE; 1039 mousePressed = FALSE;
1042 } 1040 }
1043 void setColor( QColor c ) { col = c; } 1041 void setColor( QColor c ) { col = c; }
1044 1042
1045signals: 1043signals:
1046 void colorDropped( QRgb ); 1044 void colorDropped( QRgb );
1047 1045
1048protected: 1046protected:
1049 void drawContents( QPainter *p ); 1047 void drawContents( QPainter *p );
1050 void mousePressEvent( QMouseEvent *e ); 1048 void mousePressEvent( QMouseEvent *e );
1051 void mouseMoveEvent( QMouseEvent *e ); 1049 void mouseMoveEvent( QMouseEvent *e );
1052 void mouseReleaseEvent( QMouseEvent *e ); 1050 void mouseReleaseEvent( QMouseEvent *e );
1053#ifndef QT_NO_DRAGANDDROP 1051#ifndef QT_NO_DRAGANDDROP
1054 void dragEnterEvent( QDragEnterEvent *e ); 1052 void dragEnterEvent( QDragEnterEvent *e );
1055 void dragLeaveEvent( QDragLeaveEvent *e ); 1053 void dragLeaveEvent( QDragLeaveEvent *e );
1056 void dropEvent( QDropEvent *e ); 1054 void dropEvent( QDropEvent *e );
1057#endif 1055#endif
1058 1056
1059private: 1057private:
1060 QColor col; 1058 QColor col;
1061 bool mousePressed; 1059 bool mousePressed;
1062 QPoint pressPos; 1060 QPoint pressPos;
1063 1061
1064}; 1062};
1065 1063
1066void QColorShowLabel::drawContents( QPainter *p ) 1064void QColorShowLabel::drawContents( QPainter *p )
1067{ 1065{
1068 p->fillRect( contentsRect(), col ); 1066 p->fillRect( contentsRect(), col );
1069} 1067}
1070 1068
1071void QColorShower::showAlpha( bool b ) 1069void QColorShower::showAlpha( bool b )
1072{ 1070{
1073 if ( b ) { 1071 if ( b ) {
1074 alphaLab->show(); 1072 alphaLab->show();
1075 alphaEd->show(); 1073 alphaEd->show();
1076 } else { 1074 } else {
1077 alphaLab->hide(); 1075 alphaLab->hide();
1078 alphaEd->hide(); 1076 alphaEd->hide();
1079 } 1077 }
1080} 1078}
1081 1079
1082void QColorShowLabel::mousePressEvent( QMouseEvent *e ) 1080void QColorShowLabel::mousePressEvent( QMouseEvent *e )
1083{ 1081{
1084 mousePressed = TRUE; 1082 mousePressed = TRUE;
1085 pressPos = e->pos(); 1083 pressPos = e->pos();
1086} 1084}
1087 1085
1088void QColorShowLabel::mouseMoveEvent( QMouseEvent *e ) 1086void QColorShowLabel::mouseMoveEvent( QMouseEvent *e )
1089{ 1087{
1090#ifndef QT_NO_DRAGANDDROP 1088#ifndef QT_NO_DRAGANDDROP
1091 if ( !mousePressed ) 1089 if ( !mousePressed )
1092 return; 1090 return;
1093 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { 1091 if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) {
1094 QColorDrag *drg = new QColorDrag( col, this ); 1092 QColorDrag *drg = new QColorDrag( col, this );
1095 QPixmap pix( 30, 20 ); 1093 QPixmap pix( 30, 20 );
1096 pix.fill( col ); 1094 pix.fill( col );
1097 QPainter p( &pix ); 1095 QPainter p( &pix );
1098 p.drawRect( 0, 0, pix.width(), pix.height() ); 1096 p.drawRect( 0, 0, pix.width(), pix.height() );
1099 p.end(); 1097 p.end();
1100 drg->setPixmap( pix ); 1098 drg->setPixmap( pix );
1101 mousePressed = FALSE; 1099 mousePressed = FALSE;
1102 drg->dragCopy(); 1100 drg->dragCopy();
1103 } 1101 }
1104#endif 1102#endif
1105} 1103}
1106 1104
1107#ifndef QT_NO_DRAGANDDROP 1105#ifndef QT_NO_DRAGANDDROP
1108void QColorShowLabel::dragEnterEvent( QDragEnterEvent *e ) 1106void QColorShowLabel::dragEnterEvent( QDragEnterEvent *e )
1109{ 1107{
1110 if ( QColorDrag::canDecode( e ) ) 1108 if ( QColorDrag::canDecode( e ) )
1111 e->accept(); 1109 e->accept();
1112 else 1110 else
1113 e->ignore(); 1111 e->ignore();
1114} 1112}
1115 1113
1116void QColorShowLabel::dragLeaveEvent( QDragLeaveEvent * ) 1114void QColorShowLabel::dragLeaveEvent( QDragLeaveEvent * )
1117{ 1115{
1118} 1116}
1119 1117
1120void QColorShowLabel::dropEvent( QDropEvent *e ) 1118void QColorShowLabel::dropEvent( QDropEvent *e )
1121{ 1119{
1122 if ( QColorDrag::canDecode( e ) ) { 1120 if ( QColorDrag::canDecode( e ) ) {
1123 QColorDrag::decode( e, col ); 1121 QColorDrag::decode( e, col );
1124 repaint( FALSE ); 1122 repaint( FALSE );
1125 emit colorDropped( col.rgb() ); 1123 emit colorDropped( col.rgb() );
1126 e->accept(); 1124 e->accept();
1127 } else { 1125 } else {
1128 e->ignore(); 1126 e->ignore();
1129 } 1127 }
1130} 1128}
1131#endif // QT_NO_DRAGANDDROP 1129#endif // QT_NO_DRAGANDDROP
1132 1130
1133void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) 1131void QColorShowLabel::mouseReleaseEvent( QMouseEvent * )
1134{ 1132{
1135 if ( !mousePressed ) 1133 if ( !mousePressed )
1136 return; 1134 return;
1137 mousePressed = FALSE; 1135 mousePressed = FALSE;
1138} 1136}
1139 1137
1140QColorShower::QColorShower( QWidget *parent, const char *name ) 1138QColorShower::QColorShower( QWidget *parent, const char *name )
1141 :QWidget( parent, name) 1139 :QWidget( parent, name)
1142{ 1140{
1143 curCol = qRgb( -1, -1, -1 ); 1141 curCol = qRgb( -1, -1, -1 );
1144 QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); 1142 QColIntValidator *val256 = new QColIntValidator( 0, 255, this );
1145 QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); 1143 QColIntValidator *val360 = new QColIntValidator( 0, 360, this );
1146 1144
1147 QGridLayout *gl = new QGridLayout( this, 1, 1, 6 ); 1145 QGridLayout *gl = new QGridLayout( this, 1, 1, 6 );
1148 lab = new QColorShowLabel( this ); 1146 lab = new QColorShowLabel( this );
1149 lab->setMinimumWidth( 60 ); //### 1147 lab->setMinimumWidth( 60 ); //###
1150 gl->addMultiCellWidget(lab, 0,-1,0,0); 1148 gl->addMultiCellWidget(lab, 0,-1,0,0);
1151 connect( lab, SIGNAL( colorDropped(QRgb) ), 1149 connect( lab, SIGNAL( colorDropped(QRgb) ),
1152 this, SIGNAL( newCol(QRgb) ) ); 1150 this, SIGNAL( newCol(QRgb) ) );
1153 connect( lab, SIGNAL( colorDropped(QRgb) ), 1151 connect( lab, SIGNAL( colorDropped(QRgb) ),
1154 this, SLOT( setRgb(QRgb) ) ); 1152 this, SLOT( setRgb(QRgb) ) );
1155 1153
1156 hEd = new QColNumLineEdit( this ); 1154 hEd = new QColNumLineEdit( this );
1157 hEd->setValidator( val360 ); 1155 hEd->setValidator( val360 );
1158 QLabel *l = new QLabel( hEd, QColorDialog::tr("Hu&e:"), this ); 1156 QLabel *l = new QLabel( hEd, QColorDialog::tr("Hu&e:"), this );
1159 l->setAlignment( AlignRight|AlignVCenter ); 1157 l->setAlignment( AlignRight|AlignVCenter );
1160 gl->addWidget( l, 0, 1 ); 1158 gl->addWidget( l, 0, 1 );
1161 gl->addWidget( hEd, 0, 2 ); 1159 gl->addWidget( hEd, 0, 2 );
1162 1160
1163 sEd = new QColNumLineEdit( this ); 1161 sEd = new QColNumLineEdit( this );
1164 sEd->setValidator( val256 ); 1162 sEd->setValidator( val256 );
1165 l = new QLabel( sEd, QColorDialog::tr("&Sat:"), this ); 1163 l = new QLabel( sEd, QColorDialog::tr("&Sat:"), this );
1166 l->setAlignment( AlignRight|AlignVCenter ); 1164 l->setAlignment( AlignRight|AlignVCenter );
1167 gl->addWidget( l, 1, 1 ); 1165 gl->addWidget( l, 1, 1 );
1168 gl->addWidget( sEd, 1, 2 ); 1166 gl->addWidget( sEd, 1, 2 );
1169 1167
1170 vEd = new QColNumLineEdit( this ); 1168 vEd = new QColNumLineEdit( this );
1171 vEd->setValidator( val256 ); 1169 vEd->setValidator( val256 );
1172 l = new QLabel( vEd, QColorDialog::tr("&Val:"), this ); 1170 l = new QLabel( vEd, QColorDialog::tr("&Val:"), this );
1173 l->setAlignment( AlignRight|AlignVCenter ); 1171 l->setAlignment( AlignRight|AlignVCenter );
1174 gl->addWidget( l, 2, 1 ); 1172 gl->addWidget( l, 2, 1 );
1175 gl->addWidget( vEd, 2, 2 ); 1173 gl->addWidget( vEd, 2, 2 );
1176 1174
1177 rEd = new QColNumLineEdit( this ); 1175 rEd = new QColNumLineEdit( this );
1178 rEd->setValidator( val256 ); 1176 rEd->setValidator( val256 );
1179 l = new QLabel( rEd, QColorDialog::tr("&Red:"), this ); 1177 l = new QLabel( rEd, QColorDialog::tr("&Red:"), this );
1180 l->setAlignment( AlignRight|AlignVCenter ); 1178 l->setAlignment( AlignRight|AlignVCenter );
1181 gl->addWidget( l, 0, 3 ); 1179 gl->addWidget( l, 0, 3 );
1182 gl->addWidget( rEd, 0, 4 ); 1180 gl->addWidget( rEd, 0, 4 );
1183 1181
1184 gEd = new QColNumLineEdit( this ); 1182 gEd = new QColNumLineEdit( this );
1185 gEd->setValidator( val256 ); 1183 gEd->setValidator( val256 );
1186 l = new QLabel( gEd, QColorDialog::tr("&Green:"), this ); 1184 l = new QLabel( gEd, QColorDialog::tr("&Green:"), this );
1187 l->setAlignment( AlignRight|AlignVCenter ); 1185 l->setAlignment( AlignRight|AlignVCenter );
1188 gl->addWidget( l, 1, 3 ); 1186 gl->addWidget( l, 1, 3 );
1189 gl->addWidget( gEd, 1, 4 ); 1187 gl->addWidget( gEd, 1, 4 );
1190 1188
1191 bEd = new QColNumLineEdit( this ); 1189 bEd = new QColNumLineEdit( this );
1192 bEd->setValidator( val256 ); 1190 bEd->setValidator( val256 );
1193 l = new QLabel( bEd, QColorDialog::tr("Bl&ue:"), this ); 1191 l = new QLabel( bEd, QColorDialog::tr("Bl&ue:"), this );
1194 l->setAlignment( AlignRight|AlignVCenter ); 1192 l->setAlignment( AlignRight|AlignVCenter );
1195 gl->addWidget( l, 2, 3 ); 1193 gl->addWidget( l, 2, 3 );
1196 gl->addWidget( bEd, 2, 4 ); 1194 gl->addWidget( bEd, 2, 4 );
1197 1195
1198 alphaEd = new QColNumLineEdit( this ); 1196 alphaEd = new QColNumLineEdit( this );
1199 alphaEd->setValidator( val256 ); 1197 alphaEd->setValidator( val256 );
1200 alphaLab = new QLabel( alphaEd, QColorDialog::tr("A&lpha channel:"), this ); 1198 alphaLab = new QLabel( alphaEd, QColorDialog::tr("A&lpha channel:"), this );
1201 alphaLab->setAlignment( AlignRight|AlignVCenter ); 1199 alphaLab->setAlignment( AlignRight|AlignVCenter );
1202 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); 1200 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 );
1203 gl->addWidget( alphaEd, 3, 4 ); 1201 gl->addWidget( alphaEd, 3, 4 );
1204 alphaEd->hide(); 1202 alphaEd->hide();
1205 alphaLab->hide(); 1203 alphaLab->hide();
1206 1204
1207 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 1205 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
1208 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 1206 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
1209 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 1207 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
1210 1208
1211 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 1209 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
1212 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 1210 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
1213 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 1211 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
1214} 1212}
1215 1213
1216void QColorShower::showCurrentColor() 1214void QColorShower::showCurrentColor()
1217{ 1215{
1218 lab->setColor( currentColor() ); 1216 lab->setColor( currentColor() );
1219 lab->repaint(FALSE); //### 1217 lab->repaint(FALSE); //###
1220} 1218}
1221 1219
1222void QColorShower::rgbEd() 1220void QColorShower::rgbEd()
1223{ 1221{
1224 rgbOriginal = TRUE; 1222 rgbOriginal = TRUE;
1225 curCol = qRgb( rEd->val(), gEd->val(), bEd->val() ); 1223 curCol = qRgb( rEd->val(), gEd->val(), bEd->val() );
1226 rgb2hsv(currentColor(), hue, sat, val ); 1224 rgb2hsv(currentColor(), hue, sat, val );
1227 1225
1228 hEd->setNum( hue ); 1226 hEd->setNum( hue );
1229 sEd->setNum( sat ); 1227 sEd->setNum( sat );
1230 vEd->setNum( val ); 1228 vEd->setNum( val );
1231 1229
1232 showCurrentColor(); 1230 showCurrentColor();
1233 emit newCol( currentColor() ); 1231 emit newCol( currentColor() );
1234} 1232}
1235 1233
1236void QColorShower::hsvEd() 1234void QColorShower::hsvEd()
1237{ 1235{
1238 rgbOriginal = FALSE; 1236 rgbOriginal = FALSE;
1239 hue = hEd->val(); 1237 hue = hEd->val();
1240 sat = sEd->val(); 1238 sat = sEd->val();
1241 val = vEd->val(); 1239 val = vEd->val();
1242 1240
1243 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); 1241 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
1244 1242
1245 rEd->setNum( qRed(currentColor()) ); 1243 rEd->setNum( qRed(currentColor()) );
1246 gEd->setNum( qGreen(currentColor()) ); 1244 gEd->setNum( qGreen(currentColor()) );
1247 bEd->setNum( qBlue(currentColor()) ); 1245 bEd->setNum( qBlue(currentColor()) );
1248 1246
1249 showCurrentColor(); 1247 showCurrentColor();
1250 emit newCol( currentColor() ); 1248 emit newCol( currentColor() );
1251} 1249}
1252 1250
1253void QColorShower::setRgb( QRgb rgb ) 1251void QColorShower::setRgb( QRgb rgb )
1254{ 1252{
1255 rgbOriginal = TRUE; 1253 rgbOriginal = TRUE;
1256 curCol = rgb; 1254 curCol = rgb;
1257 1255
1258 rgb2hsv( currentColor(), hue, sat, val ); 1256 rgb2hsv( currentColor(), hue, sat, val );
1259 1257
1260 hEd->setNum( hue ); 1258 hEd->setNum( hue );
1261 sEd->setNum( sat ); 1259 sEd->setNum( sat );
1262 vEd->setNum( val ); 1260 vEd->setNum( val );
1263 1261
1264 rEd->setNum( qRed(currentColor()) ); 1262 rEd->setNum( qRed(currentColor()) );
1265 gEd->setNum( qGreen(currentColor()) ); 1263 gEd->setNum( qGreen(currentColor()) );
1266 bEd->setNum( qBlue(currentColor()) ); 1264 bEd->setNum( qBlue(currentColor()) );
1267 1265
1268 showCurrentColor(); 1266 showCurrentColor();
1269} 1267}
1270 1268
1271void QColorShower::setHsv( int h, int s, int v ) 1269void QColorShower::setHsv( int h, int s, int v )
1272{ 1270{
1273 rgbOriginal = FALSE; 1271 rgbOriginal = FALSE;
1274 hue = h; val = v; sat = s; //Range check### 1272 hue = h; val = v; sat = s; //Range check###
1275 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); 1273 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
1276 1274
1277 hEd->setNum( hue ); 1275 hEd->setNum( hue );
1278 sEd->setNum( sat ); 1276 sEd->setNum( sat );
1279 vEd->setNum( val ); 1277 vEd->setNum( val );
1280 1278
1281 rEd->setNum( qRed(currentColor()) ); 1279 rEd->setNum( qRed(currentColor()) );
1282 gEd->setNum( qGreen(currentColor()) ); 1280 gEd->setNum( qGreen(currentColor()) );
1283 bEd->setNum( qBlue(currentColor()) ); 1281 bEd->setNum( qBlue(currentColor()) );
1284 1282
1285 1283
1286 showCurrentColor(); 1284 showCurrentColor();
1287} 1285}
1288 1286
1289class QColorDialogPrivate : public QObject 1287class QColorDialogPrivate : public QObject
1290{ 1288{
1291Q_OBJECT 1289Q_OBJECT
1292public: 1290public:
1293 QColorDialogPrivate( QColorDialog *p ); 1291 QColorDialogPrivate( QColorDialog *p );
1294 QRgb currentColor() const { return cs->currentColor(); } 1292 QRgb currentColor() const { return cs->currentColor(); }
1295 void setCurrentColor( QRgb rgb ); 1293 void setCurrentColor( QRgb rgb );
1296 1294
1297 int currentAlpha() const { return cs->currentAlpha(); } 1295 int currentAlpha() const { return cs->currentAlpha(); }
1298 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); } 1296 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
1299 void showAlpha( bool b ) { cs->showAlpha( b ); } 1297 void showAlpha( bool b ) { cs->showAlpha( b ); }
1300 1298
1301private slots: 1299private slots:
1302 void addCustom(); 1300 void addCustom();
1303 1301
1304 void newHsv( int h, int s, int v ); 1302 void newHsv( int h, int s, int v );
1305 void newColorTypedIn( QRgb rgb ); 1303 void newColorTypedIn( QRgb rgb );
1306 void newCustom( int, int ); 1304 void newCustom( int, int );
1307 void newStandard( int, int ); 1305 void newStandard( int, int );
1308private: 1306private:
1309 QColorPicker *cp; 1307 QColorPicker *cp;
1310 QColorLuminancePicker *lp; 1308 QColorLuminancePicker *lp;
1311 QWellArray *custom; 1309 QWellArray *custom;
1312 QWellArray *standard; 1310 QWellArray *standard;
1313 QColorShower *cs; 1311 QColorShower *cs;
1314 int nextCust; 1312 int nextCust;
1315 bool compact; 1313 bool compact;
1316}; 1314};
1317 1315
1318//sets all widgets to display h,s,v 1316//sets all widgets to display h,s,v
1319void QColorDialogPrivate::newHsv( int h, int s, int v ) 1317void QColorDialogPrivate::newHsv( int h, int s, int v )
1320{ 1318{
1321 cs->setHsv( h, s, v ); 1319 cs->setHsv( h, s, v );
1322 cp->setCol( h, s ); 1320 cp->setCol( h, s );
1323 lp->setCol( h, s, v ); 1321 lp->setCol( h, s, v );
1324} 1322}
1325 1323
1326//sets all widgets to display rgb 1324//sets all widgets to display rgb
1327void QColorDialogPrivate::setCurrentColor( QRgb rgb ) 1325void QColorDialogPrivate::setCurrentColor( QRgb rgb )
1328{ 1326{
1329 cs->setRgb( rgb ); 1327 cs->setRgb( rgb );
1330 newColorTypedIn( rgb ); 1328 newColorTypedIn( rgb );
1331} 1329}
1332 1330
1333//sets all widgets exept cs to display rgb 1331//sets all widgets exept cs to display rgb
1334void QColorDialogPrivate::newColorTypedIn( QRgb rgb ) 1332void QColorDialogPrivate::newColorTypedIn( QRgb rgb )
1335{ 1333{
1336 int h, s, v; 1334 int h, s, v;
1337 rgb2hsv(rgb, h, s, v ); 1335 rgb2hsv(rgb, h, s, v );
1338 cp->setCol( h, s ); 1336 cp->setCol( h, s );
1339 lp->setCol( h, s, v); 1337 lp->setCol( h, s, v);
1340} 1338}
1341 1339
1342void QColorDialogPrivate::newCustom( int r, int c ) 1340void QColorDialogPrivate::newCustom( int r, int c )
1343{ 1341{
1344 int i = r+2*c; 1342 int i = r+2*c;
1345 setCurrentColor( cusrgb[i] ); 1343 setCurrentColor( cusrgb[i] );
1346 nextCust = i; 1344 nextCust = i;
1347 standard->setSelected(-1,-1); 1345 standard->setSelected(-1,-1);
1348} 1346}
1349 1347
1350void QColorDialogPrivate::newStandard( int r, int c ) 1348void QColorDialogPrivate::newStandard( int r, int c )
1351{ 1349{
1352 setCurrentColor( stdrgb[r+c*6] ); 1350 setCurrentColor( stdrgb[r+c*6] );
1353 custom->setSelected(-1,-1); 1351 custom->setSelected(-1,-1);
1354} 1352}
1355 1353
1356QColorDialogPrivate::QColorDialogPrivate( QColorDialog *dialog ) : 1354QColorDialogPrivate::QColorDialogPrivate( QColorDialog *dialog ) :
1357 QObject(dialog) 1355 QObject(dialog)
1358{ 1356{
1359 compact = FALSE; 1357 compact = FALSE;
1360 // small displays (e.g. PDAs cannot fit the full color dialog, 1358 // small displays (e.g. PDAs cannot fit the full color dialog,
1361 // so just use the color picker. 1359 // so just use the color picker.
1362 if ( qApp->desktop()->width() < 480 || qApp->desktop()->height() < 350 ) 1360 if ( qApp->desktop()->width() < 480 || qApp->desktop()->height() < 350 )
1363 compact = TRUE; 1361 compact = TRUE;
1364 1362
1365 nextCust = 0; 1363 nextCust = 0;
1366 const int lumSpace = 3; 1364 const int lumSpace = 3;
1367 int border = 12; 1365 int border = 12;
1368 if ( compact ) 1366 if ( compact )
1369 border = 6; 1367 border = 6;
1370 QHBoxLayout *topLay = new QHBoxLayout( dialog, border, 6 ); 1368 QHBoxLayout *topLay = new QHBoxLayout( dialog, border, 6 );
1371 QVBoxLayout *leftLay = 0; 1369 QVBoxLayout *leftLay = 0;
1372 1370
1373 if ( !compact ) 1371 if ( !compact )
1374 leftLay = new QVBoxLayout( topLay ); 1372 leftLay = new QVBoxLayout( topLay );
1375 1373
1376 initRGB(); 1374 initRGB();
1377 1375
1378 if ( !compact ) { 1376 if ( !compact ) {
1379 standard = new QColorWell( dialog, 6, 8, stdrgb ); 1377 standard = new QColorWell( dialog, 6, 8, stdrgb );
1380 standard->setCellSize( 28, 24 ); 1378 standard->setCellSize( 28, 24 );
1381 QLabel * lab = new QLabel( standard, 1379 QLabel * lab = new QLabel( standard,
1382 QColorDialog::tr( "&Basic colors"), dialog ); 1380 QColorDialog::tr( "&Basic colors"), dialog );
1383 connect( standard, SIGNAL(selected(int,int)), SLOT(newStandard(int,int))); 1381 connect( standard, SIGNAL(selected(int,int)), SLOT(newStandard(int,int)));
1384 leftLay->addWidget( lab ); 1382 leftLay->addWidget( lab );
1385 leftLay->addWidget( standard ); 1383 leftLay->addWidget( standard );
1386 1384
1387 1385
1388 leftLay->addStretch(); 1386 leftLay->addStretch();
1389 1387
1390 custom = new QColorWell( dialog, 2, 8, cusrgb ); 1388 custom = new QColorWell( dialog, 2, 8, cusrgb );
1391 custom->setCellSize( 28, 24 ); 1389 custom->setCellSize( 28, 24 );
1392 custom->setAcceptDrops( TRUE ); 1390 custom->setAcceptDrops( TRUE );
1393 1391
1394 connect( custom, SIGNAL(selected(int,int)), SLOT(newCustom(int,int))); 1392 connect( custom, SIGNAL(selected(int,int)), SLOT(newCustom(int,int)));
1395 lab = new QLabel( custom, QColorDialog::tr( "&Custom colors") , dialog ); 1393 lab = new QLabel( custom, QColorDialog::tr( "&Custom colors") , dialog );
1396 leftLay->addWidget( lab ); 1394 leftLay->addWidget( lab );
1397 leftLay->addWidget( custom ); 1395 leftLay->addWidget( custom );
1398 1396
1399 QPushButton *custbut = 1397 QPushButton *custbut =
1400 new QPushButton( QColorDialog::tr("&Define Custom Colors >>"), 1398 new QPushButton( QColorDialog::tr("&Define Custom Colors >>"),
1401 dialog ); 1399 dialog );
1402 custbut->setEnabled( FALSE ); 1400 custbut->setEnabled( FALSE );
1403 leftLay->addWidget( custbut ); 1401 leftLay->addWidget( custbut );
1404 } else { 1402 } else {
1405 // better color picker size for small displays 1403 // better color picker size for small displays
1406 pWidth = 150; 1404 pWidth = 150;
1407 pHeight = 100; 1405 pHeight = 100;
1408 } 1406 }
1409 1407
1410 QVBoxLayout *rightLay = new QVBoxLayout( topLay ); 1408 QVBoxLayout *rightLay = new QVBoxLayout( topLay );
1411 1409
1412 QHBoxLayout *pickLay = new QHBoxLayout( rightLay ); 1410 QHBoxLayout *pickLay = new QHBoxLayout( rightLay );
1413 1411
1414 1412
1415 QVBoxLayout *cLay = new QVBoxLayout( pickLay ); 1413 QVBoxLayout *cLay = new QVBoxLayout( pickLay );
1416 cp = new QColorPicker( dialog ); 1414 cp = new QColorPicker( dialog );
1417 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken ); 1415 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken );
1418 cLay->addSpacing( lumSpace ); 1416 cLay->addSpacing( lumSpace );
1419 cLay->addWidget( cp ); 1417 cLay->addWidget( cp );
1420 cLay->addSpacing( lumSpace ); 1418 cLay->addSpacing( lumSpace );
1421 1419
1422 lp = new QColorLuminancePicker( dialog ); 1420 lp = new QColorLuminancePicker( dialog );
1423 lp->setFixedWidth( 20 ); //### 1421 lp->setFixedWidth( 20 ); //###
1424 pickLay->addWidget( lp ); 1422 pickLay->addWidget( lp );
1425 1423
1426 connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) ); 1424 connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) );
1427 connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) ); 1425 connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) );
1428 1426
1429 rightLay->addStretch(); 1427 rightLay->addStretch();
1430 1428
1431 cs = new QColorShower( dialog ); 1429 cs = new QColorShower( dialog );
1432 connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb))); 1430 connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb)));
1433 rightLay->addWidget( cs ); 1431 rightLay->addWidget( cs );
1434 1432
1435 QHBoxLayout *buttons; 1433 QHBoxLayout *buttons;
1436 if ( compact ) 1434 if ( compact )
1437 buttons = new QHBoxLayout( rightLay ); 1435 buttons = new QHBoxLayout( rightLay );
1438 else 1436 else
1439 buttons = new QHBoxLayout( leftLay ); 1437 buttons = new QHBoxLayout( leftLay );
1440 1438
1441 QPushButton *ok, *cancel; 1439 QPushButton *ok, *cancel;
1442 ok = new QPushButton( QColorDialog::tr("OK"), dialog ); 1440 ok = new QPushButton( QColorDialog::tr("OK"), dialog );
1443 connect( ok, SIGNAL(clicked()), dialog, SLOT(accept()) ); 1441 connect( ok, SIGNAL(clicked()), dialog, SLOT(accept()) );
1444 ok->setDefault(TRUE); 1442 ok->setDefault(TRUE);
1445 cancel = new QPushButton( QColorDialog::tr("Cancel"), dialog ); 1443 cancel = new QPushButton( QColorDialog::tr("Cancel"), dialog );
1446 connect( cancel, SIGNAL(clicked()), dialog, SLOT(reject()) ); 1444 connect( cancel, SIGNAL(clicked()), dialog, SLOT(reject()) );
1447 buttons->addWidget( ok ); 1445 buttons->addWidget( ok );
1448 buttons->addWidget( cancel ); 1446 buttons->addWidget( cancel );
1449 buttons->addStretch(); 1447 buttons->addStretch();
1450 1448
1451 if ( !compact ) { 1449 if ( !compact ) {
1452 QPushButton *addCusBt = new QPushButton( 1450 QPushButton *addCusBt = new QPushButton(
1453 QColorDialog::tr("&Add To Custom Colors"), 1451 QColorDialog::tr("&Add To Custom Colors"),
1454 dialog ); 1452 dialog );
1455 rightLay->addWidget( addCusBt ); 1453 rightLay->addWidget( addCusBt );
1456 connect( addCusBt, SIGNAL(clicked()), this, SLOT(addCustom()) ); 1454 connect( addCusBt, SIGNAL(clicked()), this, SLOT(addCustom()) );
1457 } 1455 }
1458} 1456}
1459 1457
1460void QColorDialogPrivate::addCustom() 1458void QColorDialogPrivate::addCustom()
1461{ 1459{
1462 cusrgb[nextCust] = cs->currentColor(); 1460 cusrgb[nextCust] = cs->currentColor();
1463 custom->repaint( FALSE ); //### 1461 custom->repaint( FALSE ); //###
1464 nextCust = (nextCust+1) % 16; 1462 nextCust = (nextCust+1) % 16;
1465} 1463}
1466 1464
1467 1465
1468// BEING REVISED: jo 1466// BEING REVISED: jo
1469/*! 1467/*!
1470 \class QColorDialog qcolordialog.h 1468 \class QColorDialog qcolordialog.h
1471 \brief The QColorDialog class provides a dialog widget for specifying colors. 1469 \brief The QColorDialog class provides a dialog widget for specifying colors.
1472 \ingroup dialogs 1470 \ingroup dialogs
1473 1471
1474 The color dialog's function is to allow users to choose colors - 1472 The color dialog's function is to allow users to choose colors -
1475 for instance, you might use this in a drawing program to allow the 1473 for instance, you might use this in a drawing program to allow the
1476 user to set the brush color. 1474 user to set the brush color.
1477 1475
1478 This version of Qt only provides modal color dialogs. The static 1476 This version of Qt only provides modal color dialogs. The static
1479 getColor() function shows the dialog and allows the user to specify a color, 1477 getColor() function shows the dialog and allows the user to specify a color,
1480 while getRgba() does the same but allows the user to specify a color with an 1478 while getRgba() does the same but allows the user to specify a color with an
1481 alpha channel (transparency) value. 1479 alpha channel (transparency) value.
1482 1480
1483 The user can store customCount() different custom colors. The custom 1481 The user can store customCount() different custom colors. The custom
1484 colors are shared by all color dialogs, and remembered during the 1482 colors are shared by all color dialogs, and remembered during the
1485 execution of the program. Use setCustomColor() to set the 1483 execution of the program. Use setCustomColor() to set the
1486 custom colors, and customColor() to get them. 1484 custom colors, and customColor() to get them.
1487 1485
1488 <img src=qcolordlg-m.png> <img src=qcolordlg-w.png> 1486 <img src=qcolordlg-m.png> <img src=qcolordlg-w.png>
1489*/ 1487*/
1490 1488
1491/*! 1489/*!
1492 Constructs a default color dialog. Use setColor() for setting an initial value. 1490 Constructs a default color dialog. Use setColor() for setting an initial value.
1493 1491
1494 \sa getColor() 1492 \sa getColor()
1495*/ 1493*/
1496 1494
1497QColorDialog::QColorDialog(QWidget* parent, const char* name, bool modal) : 1495QColorDialog::QColorDialog(QWidget* parent, const char* name, bool modal) :
1498 QDialog(parent, name, modal ) 1496 QDialog(parent, name, modal )
1499{ 1497{
1500 setSizeGripEnabled( TRUE ); 1498 setSizeGripEnabled( TRUE );
1501 d = new QColorDialogPrivate( this ); 1499 d = new QColorDialogPrivate( this );
1502} 1500}
1503 1501
1504 1502
1505/*! 1503/*!
1506 Pops up a modal color dialog letting the user choose a color and returns 1504 Pops up a modal color dialog letting the user choose a color and returns
1507 that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels 1505 that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels
1508 the dialog. All colors allocated by the dialog will be deallocated 1506 the dialog. All colors allocated by the dialog will be deallocated
1509 before this function returns. 1507 before this function returns.
1510*/ 1508*/
1511 1509
1512QColor QColorDialog::getColor( QColor initial, QWidget *parent, 1510QColor QColorDialog::getColor( QColor initial, QWidget *parent,
1513 const char *name ) 1511 const char *name )
1514{ 1512{
1515 int allocContext = QColor::enterAllocContext(); 1513 int allocContext = QColor::enterAllocContext();
1516 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal 1514 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal
1517 if ( parent && parent->icon() && !parent->icon()->isNull() ) 1515 if ( parent && parent->icon() && !parent->icon()->isNull() )
1518 dlg->setIcon( *parent->icon() ); 1516 dlg->setIcon( *parent->icon() );
1519 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) 1517 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
1520 dlg->setIcon( *qApp->mainWidget()->icon() ); 1518 dlg->setIcon( *qApp->mainWidget()->icon() );
1521 1519
1522 dlg->setCaption( QColorDialog::tr( "Select color" ) ); 1520 dlg->setCaption( QColorDialog::tr( "Select color" ) );
1523 dlg->setColor( initial ); 1521 dlg->setColor( initial );
1524 int resultCode = dlg->exec(); 1522 int resultCode = dlg->exec();
1525 QColor::leaveAllocContext(); 1523 QColor::leaveAllocContext();
1526 QColor result; 1524 QColor result;
1527 if ( resultCode == QDialog::Accepted ) 1525 if ( resultCode == QDialog::Accepted )
1528 result = dlg->color(); 1526 result = dlg->color();
1529 QColor::destroyAllocContext(allocContext); 1527 QColor::destroyAllocContext(allocContext);
1530 delete dlg; 1528 delete dlg;
1531 return result; 1529 return result;
1532} 1530}
1533 1531
1534 1532
1535/*! 1533/*!
1536 Pops up a modal color dialog, letting the user choose a color and an 1534 Pops up a modal color dialog, letting the user choose a color and an
1537 alpha channel value. The color+alpha is initially set to \a initial. 1535 alpha channel value. The color+alpha is initially set to \a initial.
1538 1536
1539 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK, 1537 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK,
1540 and FALSE if the user clicked Cancel. 1538 and FALSE if the user clicked Cancel.
1541 1539
1542 If the user clicks Cancel the \a initial value is returned. 1540 If the user clicks Cancel the \a initial value is returned.
1543*/ 1541*/
1544 1542
1545QRgb QColorDialog::getRgba( QRgb initial, bool *ok, 1543QRgb QColorDialog::getRgba( QRgb initial, bool *ok,
1546 QWidget *parent, const char* name ) 1544 QWidget *parent, const char* name )
1547{ 1545{
1548 int allocContext = QColor::enterAllocContext(); 1546 int allocContext = QColor::enterAllocContext();
1549 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal 1547 QColorDialog *dlg = new QColorDialog( parent, name, TRUE ); //modal
1550 dlg->setColor( initial ); 1548 dlg->setColor( initial );
1551 dlg->setSelectedAlpha( qAlpha(initial) ); 1549 dlg->setSelectedAlpha( qAlpha(initial) );
1552 int resultCode = dlg->exec(); 1550 int resultCode = dlg->exec();
1553 QColor::leaveAllocContext(); 1551 QColor::leaveAllocContext();
1554 QRgb result = initial; 1552 QRgb result = initial;
1555 if ( resultCode == QDialog::Accepted ) { 1553 if ( resultCode == QDialog::Accepted ) {
1556 QRgb c = dlg->color().rgb(); 1554 QRgb c = dlg->color().rgb();
1557 int alpha = dlg->selectedAlpha(); 1555 int alpha = dlg->selectedAlpha();
1558 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha ); 1556 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha );
1559 } 1557 }
1560 if ( ok ) 1558 if ( ok )
1561 *ok = resultCode == QDialog::Accepted; 1559 *ok = resultCode == QDialog::Accepted;
1562 1560
1563 QColor::destroyAllocContext(allocContext); 1561 QColor::destroyAllocContext(allocContext);
1564 delete dlg; 1562 delete dlg;
1565 return result; 1563 return result;
1566} 1564}
1567 1565
1568 1566
1569 1567
1570 1568
1571 1569
1572/*! 1570/*!
1573 Returns the color currently selected in the dialog. 1571 Returns the color currently selected in the dialog.
1574 1572
1575 \sa setColor() 1573 \sa setColor()
1576*/ 1574*/
1577 1575
1578QColor QColorDialog::color() const 1576QColor QColorDialog::color() const
1579{ 1577{
1580 return QColor(d->currentColor()); 1578 return QColor(d->currentColor());
1581} 1579}
1582 1580
1583 1581
1584/*! Destructs the dialog and frees any memory it allocated. 1582/*! Destructs the dialog and frees any memory it allocated.
1585 1583
1586*/ 1584*/
1587 1585
1588QColorDialog::~QColorDialog() 1586QColorDialog::~QColorDialog()
1589{ 1587{
1590 //d inherits QObject, so it is deleted by Qt. 1588 //d inherits QObject, so it is deleted by Qt.
1591} 1589}
1592 1590
1593 1591
1594/*! 1592/*!
1595 Sets the color shown in the dialog to \a c. 1593 Sets the color shown in the dialog to \a c.
1596 1594
1597 \sa color() 1595 \sa color()
1598*/ 1596*/
1599 1597
1600void QColorDialog::setColor( QColor c ) 1598void QColorDialog::setColor( QColor c )
1601{ 1599{
1602 d->setCurrentColor( c.rgb() ); 1600 d->setCurrentColor( c.rgb() );
1603} 1601}
1604 1602
1605 1603
1606 1604
1607 1605
1608/*! 1606/*!
1609 Sets the initial alpha channel value to \a a, and show the alpha channel 1607 Sets the initial alpha channel value to \a a, and show the alpha channel
1610 entry box. 1608 entry box.
1611*/ 1609*/
1612 1610
1613void QColorDialog::setSelectedAlpha( int a ) 1611void QColorDialog::setSelectedAlpha( int a )
1614{ 1612{
1615 d->showAlpha( TRUE ); 1613 d->showAlpha( TRUE );
1616 d->setCurrentAlpha( a ); 1614 d->setCurrentAlpha( a );
1617} 1615}
1618 1616
1619 1617
1620/*! 1618/*!
1621 Returns the value selected for the alpha channel. 1619 Returns the value selected for the alpha channel.
1622*/ 1620*/
1623 1621
1624int QColorDialog::selectedAlpha() const 1622int QColorDialog::selectedAlpha() const
1625{ 1623{
1626 return d->currentAlpha(); 1624 return d->currentAlpha();
1627} 1625}
1628 1626
1629 1627
1630#include "qcolordialog.moc" \ No newline at end of file 1628#include "qcolordialog.moc" \ No newline at end of file
diff --git a/libqtaux/qinputdialog.cpp b/libqtaux/qinputdialog.cpp
index 821c74d..43e243f 100644
--- a/libqtaux/qinputdialog.cpp
+++ b/libqtaux/qinputdialog.cpp
@@ -1,493 +1,492 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QInputDialog class 4** Implementation of QInputDialog class
5** 5**
6** Created : 991212 6** Created : 991212
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the dialogs module of the Qt GUI Toolkit. 10** This file is part of the dialogs module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qinputdialog.h" 38#include "qinputdialog.h"
39 39
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlineedit.h>
43#include <qpushbutton.h> 42#include <qpushbutton.h>
44#include <qspinbox.h> 43#include <qspinbox.h>
45#include <qcombobox.h> 44#include <qcombobox.h>
46#include <qwidgetstack.h> 45#include <qwidgetstack.h>
47#include <qvalidator.h> 46#include <qvalidator.h>
48#include <qapplication.h> 47#include <qapplication.h>
49 48
50class QInputDialogPrivate 49class QInputDialogPrivate
51{ 50{
52public: 51public:
53 friend class QInputDialog; 52 friend class QInputDialog;
54 QLineEdit *lineEdit; 53 QLineEdit *lineEdit;
55 QSpinBox *spinBox; 54 QSpinBox *spinBox;
56 QComboBox *comboBox, *editComboBox; 55 QComboBox *comboBox, *editComboBox;
57 QPushButton *ok; 56 QPushButton *ok;
58 QWidgetStack *stack; 57 QWidgetStack *stack;
59 QInputDialog::Type type; 58 QInputDialog::Type type;
60}; 59};
61 60
62/*! 61/*!
63 \class QInputDialog qinputdialog.h 62 \class QInputDialog qinputdialog.h
64 \brief A convenience dialog to get a simple input from the user 63 \brief A convenience dialog to get a simple input from the user
65 \ingroup dialogs 64 \ingroup dialogs
66 65
67 The QInputDialog is a simple dialog which can be used if you 66 The QInputDialog is a simple dialog which can be used if you
68 need a simple input from the user. This can be text, a number or 67 need a simple input from the user. This can be text, a number or
69 an item from a list. Also a label has to be set to tell the user 68 an item from a list. Also a label has to be set to tell the user
70 what he/she should input. 69 what he/she should input.
71 70
72 In this Qt version only the 4 static convenience functions 71 In this Qt version only the 4 static convenience functions
73 getText(), getInteger(), getDouble() and getItem() of QInputDialog 72 getText(), getInteger(), getDouble() and getItem() of QInputDialog
74 are available. 73 are available.
75 74
76 Use it like this: 75 Use it like this:
77 76
78 \code 77 \code
79 bool ok = FALSE; 78 bool ok = FALSE;
80 QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this ); 79 QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this );
81 if ( ok && !text.isEmpty() ) 80 if ( ok && !text.isEmpty() )
82 ;// user entered something and pressed ok 81 ;// user entered something and pressed ok
83 else 82 else
84 ;// user entered nothing or pressed cancel 83 ;// user entered nothing or pressed cancel
85 \endcode 84 \endcode
86 85
87 There are more static convenience methods! 86 There are more static convenience methods!
88 87
89 \sa getText(), getInteger(), getDouble(), getItem() 88 \sa getText(), getInteger(), getDouble(), getItem()
90*/ 89*/
91 90
92/*! 91/*!
93 \enum QInputDialog::Type 92 \enum QInputDialog::Type
94 93
95 This enum type specifies the type of the dialog 94 This enum type specifies the type of the dialog
96 (which kind of input can be done): 95 (which kind of input can be done):
97 96
98 <ul> 97 <ul>
99 <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or 98 <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or
100 (e.g. using a QValidator) a numerical input can be done. Using lineEdit() 99 (e.g. using a QValidator) a numerical input can be done. Using lineEdit()
101 the QLineEdit can be accessed. 100 the QLineEdit can be accessed.
102 <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal 101 <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal
103 input can be done. Using spinBox() the QSpinBox can be accessed. 102 input can be done. Using spinBox() the QSpinBox can be accessed.
104 <li>\c ComboBox - A read-only QComboBox is used for taking the input, 103 <li>\c ComboBox - A read-only QComboBox is used for taking the input,
105 so one item of a list can be chosen. Using comboBox() the QComboBox 104 so one item of a list can be chosen. Using comboBox() the QComboBox
106 can be accessed. 105 can be accessed.
107 <li>\c EditableComboBox - An editable QComboBox is used for taking the input, 106 <li>\c EditableComboBox - An editable QComboBox is used for taking the input,
108 so either one item of a list can be chosen or a text can be entered. Using 107 so either one item of a list can be chosen or a text can be entered. Using
109 editableComboBox() the QComboBox can be accessed. 108 editableComboBox() the QComboBox can be accessed.
110 </ul> 109 </ul>
111*/ 110*/
112 111
113/*! 112/*!
114 Constructs the dialog. \a label is the text which is shown to the user (it should mention 113 Constructs the dialog. \a label is the text which is shown to the user (it should mention
115 to the user what he/she should input), \a parent the parent widget of the dialog, \a name 114 to the user what he/she should input), \a parent the parent widget of the dialog, \a name
116 the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops 115 the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops
117 up modeless. With \a type you specify the type of the dialog. 116 up modeless. With \a type you specify the type of the dialog.
118 117
119 \sa getText(), getInteger(), getDouble(), getItem() 118 \sa getText(), getInteger(), getDouble(), getItem()
120*/ 119*/
121 120
122QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name, 121QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name,
123 bool modal, Type type) 122 bool modal, Type type)
124 : QDialog( parent, name, modal ) 123 : QDialog( parent, name, modal )
125{ 124{
126 if ( parent && parent->icon() &&!parent->icon()->isNull() ) 125 if ( parent && parent->icon() &&!parent->icon()->isNull() )
127 setIcon( *parent->icon() ); 126 setIcon( *parent->icon() );
128 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) 127 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
129 QDialog::setIcon( *qApp->mainWidget()->icon() ); 128 QDialog::setIcon( *qApp->mainWidget()->icon() );
130 129
131 d = new QInputDialogPrivate; 130 d = new QInputDialogPrivate;
132 d->lineEdit = 0; 131 d->lineEdit = 0;
133 d->spinBox = 0; 132 d->spinBox = 0;
134 d->comboBox = 0; 133 d->comboBox = 0;
135 134
136 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); 135 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
137 136
138 QLabel* l = new QLabel( label, this ); 137 QLabel* l = new QLabel( label, this );
139 vbox->addWidget( l ); 138 vbox->addWidget( l );
140 139
141 d->stack = new QWidgetStack( this ); 140 d->stack = new QWidgetStack( this );
142 vbox->addWidget( d->stack ); 141 vbox->addWidget( d->stack );
143 d->lineEdit = new QLineEdit( d->stack ); 142 d->lineEdit = new QLineEdit( d->stack );
144 d->spinBox = new QSpinBox( d->stack ); 143 d->spinBox = new QSpinBox( d->stack );
145 d->comboBox = new QComboBox( FALSE, d->stack ); 144 d->comboBox = new QComboBox( FALSE, d->stack );
146 d->editComboBox = new QComboBox( TRUE, d->stack ); 145 d->editComboBox = new QComboBox( TRUE, d->stack );
147 146
148 QHBoxLayout *hbox = new QHBoxLayout( 6 ); 147 QHBoxLayout *hbox = new QHBoxLayout( 6 );
149 vbox->addLayout( hbox, AlignRight ); 148 vbox->addLayout( hbox, AlignRight );
150 149
151 d->ok = new QPushButton( tr( "&OK" ), this ); 150 d->ok = new QPushButton( tr( "&OK" ), this );
152 d->ok->setDefault( TRUE ); 151 d->ok->setDefault( TRUE );
153 QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); 152 QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this );
154 153
155 QSize bs( d->ok->sizeHint() ); 154 QSize bs( d->ok->sizeHint() );
156 if ( cancel->sizeHint().width() > bs.width() ) 155 if ( cancel->sizeHint().width() > bs.width() )
157 bs.setWidth( cancel->sizeHint().width() ); 156 bs.setWidth( cancel->sizeHint().width() );
158 157
159 d->ok->setFixedSize( bs ); 158 d->ok->setFixedSize( bs );
160 cancel->setFixedSize( bs ); 159 cancel->setFixedSize( bs );
161 160
162 hbox->addWidget( new QWidget( this ) ); 161 hbox->addWidget( new QWidget( this ) );
163 hbox->addWidget( d->ok ); 162 hbox->addWidget( d->ok );
164 hbox->addWidget( cancel ); 163 hbox->addWidget( cancel );
165 164
166 connect( d->lineEdit, SIGNAL( returnPressed() ), 165 connect( d->lineEdit, SIGNAL( returnPressed() ),
167 this, SLOT( tryAccept() ) ); 166 this, SLOT( tryAccept() ) );
168 connect( d->lineEdit, SIGNAL( textChanged(const QString&) ), 167 connect( d->lineEdit, SIGNAL( textChanged(const QString&) ),
169 this, SLOT( textChanged(const QString&) ) ); 168 this, SLOT( textChanged(const QString&) ) );
170 169
171 connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); 170 connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
172 connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 171 connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
173 172
174 resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() ); 173 resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() );
175 174
176 setType( type ); 175 setType( type );
177} 176}
178 177
179/*! 178/*!
180 Returns the line edit, which is used in the LineEdit mode 179 Returns the line edit, which is used in the LineEdit mode
181*/ 180*/
182 181
183QLineEdit *QInputDialog::lineEdit() const 182QLineEdit *QInputDialog::lineEdit() const
184{ 183{
185 return d->lineEdit; 184 return d->lineEdit;
186} 185}
187 186
188/*! 187/*!
189 Returns the spinbox, which is used in the SpinBox mode 188 Returns the spinbox, which is used in the SpinBox mode
190*/ 189*/
191 190
192QSpinBox *QInputDialog::spinBox() const 191QSpinBox *QInputDialog::spinBox() const
193{ 192{
194 return d->spinBox; 193 return d->spinBox;
195} 194}
196 195
197/*! 196/*!
198 Returns the combobox, which is used in the ComboBox mode 197 Returns the combobox, which is used in the ComboBox mode
199*/ 198*/
200 199
201QComboBox *QInputDialog::comboBox() const 200QComboBox *QInputDialog::comboBox() const
202{ 201{
203 return d->comboBox; 202 return d->comboBox;
204} 203}
205 204
206/*! 205/*!
207 Returns the combobox, which is used in the EditableComboBox mode 206 Returns the combobox, which is used in the EditableComboBox mode
208*/ 207*/
209 208
210QComboBox *QInputDialog::editableComboBox() const 209QComboBox *QInputDialog::editableComboBox() const
211{ 210{
212 return d->editComboBox; 211 return d->editComboBox;
213} 212}
214 213
215/*! 214/*!
216 Sets the input type of the dialog to \a t. 215 Sets the input type of the dialog to \a t.
217*/ 216*/
218 217
219void QInputDialog::setType( Type t ) 218void QInputDialog::setType( Type t )
220{ 219{
221 switch ( t ) { 220 switch ( t ) {
222 case LineEdit: 221 case LineEdit:
223 d->stack->raiseWidget( d->lineEdit ); 222 d->stack->raiseWidget( d->lineEdit );
224 d->lineEdit->setFocus(); 223 d->lineEdit->setFocus();
225 break; 224 break;
226 case SpinBox: 225 case SpinBox:
227 d->stack->raiseWidget( d->spinBox ); 226 d->stack->raiseWidget( d->spinBox );
228 d->spinBox->setFocus(); 227 d->spinBox->setFocus();
229 break; 228 break;
230 case ComboBox: 229 case ComboBox:
231 d->stack->raiseWidget( d->comboBox ); 230 d->stack->raiseWidget( d->comboBox );
232 d->comboBox->setFocus(); 231 d->comboBox->setFocus();
233 break; 232 break;
234 case EditableComboBox: 233 case EditableComboBox:
235 d->stack->raiseWidget( d->editComboBox ); 234 d->stack->raiseWidget( d->editComboBox );
236 d->editComboBox->setFocus(); 235 d->editComboBox->setFocus();
237 break; 236 break;
238 } 237 }
239 238
240 d->type = t; 239 d->type = t;
241} 240}
242 241
243/*! 242/*!
244 Returns the input type of the dialog. 243 Returns the input type of the dialog.
245 244
246 \sa setType() 245 \sa setType()
247*/ 246*/
248 247
249QInputDialog::Type QInputDialog::type() const 248QInputDialog::Type QInputDialog::type() const
250{ 249{
251 return d->type; 250 return d->type;
252} 251}
253 252
254/*! 253/*!
255 Destructor. 254 Destructor.
256*/ 255*/
257 256
258QInputDialog::~QInputDialog() 257QInputDialog::~QInputDialog()
259{ 258{
260 delete d; 259 delete d;
261} 260}
262 261
263/*! 262/*!
264 Static convenience function to get a textual input from the user. \a caption is the text 263 Static convenience function to get a textual input from the user. \a caption is the text
265 which is displayed in the title bar of the dialog. \a label is the text which 264 which is displayed in the title bar of the dialog. \a label is the text which
266 is shown to the user (it should mention to the user what he/she should input), \a text 265 is shown to the user (it should mention to the user what he/she should input), \a text
267 the default text which will be initially set to the line edit, \a ok a pointer to 266 the default text which will be initially set to the line edit, \a ok a pointer to
268 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the 267 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
269 user pressed cancel, \a parent the parent widget of the dialog and \a name 268 user pressed cancel, \a parent the parent widget of the dialog and \a name
270 the name of it. The dialogs pops up modally! 269 the name of it. The dialogs pops up modally!
271 270
272 This method returns the text which has been entered in the line edit. 271 This method returns the text which has been entered in the line edit.
273 272
274 You will use this static method like this: 273 You will use this static method like this:
275 274
276 \code 275 \code
277 bool ok = FALSE; 276 bool ok = FALSE;
278 QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this ); 277 QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this );
279 if ( ok && !text.isEmpty() ) 278 if ( ok && !text.isEmpty() )
280 ;// user entered something and pressed ok 279 ;// user entered something and pressed ok
281 else 280 else
282 ;// user entered nothing or pressed cancel 281 ;// user entered nothing or pressed cancel
283 \endcode 282 \endcode
284*/ 283*/
285 284
286QString QInputDialog::getText( const QString &caption, const QString &label, const QString &text, 285QString QInputDialog::getText( const QString &caption, const QString &label, const QString &text,
287 bool *ok, QWidget *parent, const char *name ) 286 bool *ok, QWidget *parent, const char *name )
288{ 287{
289 return getText( caption, label, QLineEdit::Normal, text, ok, parent, name ); 288 return getText( caption, label, QLineEdit::Normal, text, ok, parent, name );
290} 289}
291 290
292/*! 291/*!
293 Like above, but accepts an a \a mode which the line edit will use to display text. 292 Like above, but accepts an a \a mode which the line edit will use to display text.
294 293
295 \sa getText() 294 \sa getText()
296*/ 295*/
297 296
298QString QInputDialog::getText( const QString &caption, const QString &label, QLineEdit::EchoMode mode, 297QString QInputDialog::getText( const QString &caption, const QString &label, QLineEdit::EchoMode mode,
299 const QString &text, bool *ok, QWidget *parent, const char *name ) 298 const QString &text, bool *ok, QWidget *parent, const char *name )
300{ 299{
301 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit ); 300 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit );
302 dlg->setCaption( caption ); 301 dlg->setCaption( caption );
303 dlg->lineEdit()->setText( text ); 302 dlg->lineEdit()->setText( text );
304 dlg->lineEdit()->setEchoMode( mode ); 303 dlg->lineEdit()->setEchoMode( mode );
305 if ( !text.isEmpty() ) 304 if ( !text.isEmpty() )
306 dlg->lineEdit()->selectAll(); 305 dlg->lineEdit()->selectAll();
307 306
308 bool ok_ = FALSE; 307 bool ok_ = FALSE;
309 QString result; 308 QString result;
310 ok_ = dlg->exec() == QDialog::Accepted; 309 ok_ = dlg->exec() == QDialog::Accepted;
311 if ( ok ) 310 if ( ok )
312 *ok = ok_; 311 *ok = ok_;
313 if ( ok_ ) 312 if ( ok_ )
314 result = dlg->lineEdit()->text(); 313 result = dlg->lineEdit()->text();
315 314
316 delete dlg; 315 delete dlg;
317 return result; 316 return result;
318} 317}
319 318
320/*! 319/*!
321 Static convenience function to get an integral input from the user. \a caption is the text 320 Static convenience function to get an integral input from the user. \a caption is the text
322 which is displayed in the title bar of the dialog. \a label is the text which 321 which is displayed in the title bar of the dialog. \a label is the text which
323 is shown to the user (it should mention to the user what he/she should input), \a num 322 is shown to the user (it should mention to the user what he/she should input), \a num
324 the default number which will be initially set to the spinbox, \a from and \a to the 323 the default number which will be initially set to the spinbox, \a from and \a to the
325 range in which the entered number has to be, \a step the step in which the number can 324 range in which the entered number has to be, \a step the step in which the number can
326 be increased/decreased by the spinbox, \a ok a pointer to 325 be increased/decreased by the spinbox, \a ok a pointer to
327 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the 326 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
328 user pressed cancel, \a parent the parent widget of the dialog and \a name 327 user pressed cancel, \a parent the parent widget of the dialog and \a name
329 the name of it. The dialogs pops up modally! 328 the name of it. The dialogs pops up modally!
330 329
331 This method returns the number which has been entered by the user. 330 This method returns the number which has been entered by the user.
332 331
333 You will use this static method like this: 332 You will use this static method like this:
334 333
335 \code 334 \code
336 bool ok = FALSE; 335 bool ok = FALSE;
337 int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this ); 336 int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this );
338 if ( ok ) 337 if ( ok )
339 ;// user entered something and pressed ok 338 ;// user entered something and pressed ok
340 else 339 else
341 ;// user pressed cancel 340 ;// user pressed cancel
342 \endcode 341 \endcode
343*/ 342*/
344 343
345int QInputDialog::getInteger( const QString &caption, const QString &label, int num, int from, int to, int step, 344int QInputDialog::getInteger( const QString &caption, const QString &label, int num, int from, int to, int step,
346 bool *ok, QWidget *parent, const char *name ) 345 bool *ok, QWidget *parent, const char *name )
347{ 346{
348 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, SpinBox ); 347 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, SpinBox );
349 dlg->setCaption( caption ); 348 dlg->setCaption( caption );
350 dlg->spinBox()->setRange( from, to ); 349 dlg->spinBox()->setRange( from, to );
351 dlg->spinBox()->setSteps( step, 0 ); 350 dlg->spinBox()->setSteps( step, 0 );
352 dlg->spinBox()->setValue( num ); 351 dlg->spinBox()->setValue( num );
353 352
354 bool ok_ = FALSE; 353 bool ok_ = FALSE;
355 int result; 354 int result;
356 ok_ = dlg->exec() == QDialog::Accepted; 355 ok_ = dlg->exec() == QDialog::Accepted;
357 if ( ok ) 356 if ( ok )
358 *ok = ok_; 357 *ok = ok_;
359 result = dlg->spinBox()->value(); 358 result = dlg->spinBox()->value();
360 359
361 delete dlg; 360 delete dlg;
362 return result; 361 return result;
363} 362}
364 363
365/*! 364/*!
366 Static convenience function to get a decimal input from the user. \a caption is the text 365 Static convenience function to get a decimal input from the user. \a caption is the text
367 which is displayed in the title bar of the dialog. \a label is the text which 366 which is displayed in the title bar of the dialog. \a label is the text which
368 is shown to the user (it should mention to the user what he/she should input), \a num 367 is shown to the user (it should mention to the user what he/she should input), \a num
369 the default decimal number which will be initially set to the line edit, \a from and \a to the 368 the default decimal number which will be initially set to the line edit, \a from and \a to the
370 range in which the entered number has to be, \a decimals the number of decimal which 369 range in which the entered number has to be, \a decimals the number of decimal which
371 the number may have, \a ok a pointer to 370 the number may have, \a ok a pointer to
372 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the 371 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
373 user pressed cancel, \a parent the parent widget of the dialog and \a name 372 user pressed cancel, \a parent the parent widget of the dialog and \a name
374 the name of it. The dialogs pops up modally! 373 the name of it. The dialogs pops up modally!
375 374
376 This method returns the number which has been entered by the user. 375 This method returns the number which has been entered by the user.
377 376
378 You will use this static method like this: 377 You will use this static method like this:
379 378
380 \code 379 \code
381 bool ok = FALSE; 380 bool ok = FALSE;
382 double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this ); 381 double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this );
383 if ( ok ) 382 if ( ok )
384 ;// user entered something and pressed ok 383 ;// user entered something and pressed ok
385 else 384 else
386 ;// user pressed cancel 385 ;// user pressed cancel
387 \endcode 386 \endcode
388*/ 387*/
389 388
390double QInputDialog::getDouble( const QString &caption, const QString &label, double num, 389double QInputDialog::getDouble( const QString &caption, const QString &label, double num,
391 double from, double to, int decimals, 390 double from, double to, int decimals,
392 bool *ok, QWidget *parent, const char *name ) 391 bool *ok, QWidget *parent, const char *name )
393{ 392{
394 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit ); 393 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit );
395 dlg->setCaption( caption ); 394 dlg->setCaption( caption );
396 dlg->lineEdit()->setValidator( new QDoubleValidator( from, to, decimals, dlg->lineEdit() ) ); 395 dlg->lineEdit()->setValidator( new QDoubleValidator( from, to, decimals, dlg->lineEdit() ) );
397 dlg->lineEdit()->setText( QString::number( num, 'f', decimals ) ); 396 dlg->lineEdit()->setText( QString::number( num, 'f', decimals ) );
398 dlg->lineEdit()->selectAll(); 397 dlg->lineEdit()->selectAll();
399 398
400 bool accepted = ( dlg->exec() == QDialog::Accepted ); 399 bool accepted = ( dlg->exec() == QDialog::Accepted );
401 if ( ok ) 400 if ( ok )
402 *ok = accepted; 401 *ok = accepted;
403 402
404 double result = dlg->lineEdit()->text().toDouble(); 403 double result = dlg->lineEdit()->text().toDouble();
405 404
406 delete dlg; 405 delete dlg;
407 return result; 406 return result;
408} 407}
409 408
410/*! 409/*!
411 Static convenience function to let the user select an item from a string list. \a caption is the text 410 Static convenience function to let the user select an item from a string list. \a caption is the text
412 which is displayed in the title bar of the dialog. \a label is the text which 411 which is displayed in the title bar of the dialog. \a label is the text which
413 is shown to the user (it should mention to the user what he/she should input), \a list the 412 is shown to the user (it should mention to the user what he/she should input), \a list the
414 string list which is inserted into the combobox, \a current the number of the item which should 413 string list which is inserted into the combobox, \a current the number of the item which should
415 be initially the current item, \a editable specifies if the combobox should be editable (if it is TRUE) 414 be initially the current item, \a editable specifies if the combobox should be editable (if it is TRUE)
416 or read-only (if \a editable is FALSE), \a ok a pointer to 415 or read-only (if \a editable is FALSE), \a ok a pointer to
417 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the 416 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
418 user pressed cancel, \a parent the parent widget of the dialog and \a name 417 user pressed cancel, \a parent the parent widget of the dialog and \a name
419 the name of it. The dialogs pops up modally! 418 the name of it. The dialogs pops up modally!
420 419
421 This method returns the text of the current item, or if \a editable was TRUE, the current 420 This method returns the text of the current item, or if \a editable was TRUE, the current
422 text of the combobox. 421 text of the combobox.
423 422
424 You will use this static method like this: 423 You will use this static method like this:
425 424
426 \code 425 \code
427 QStringList lst; 426 QStringList lst;
428 lst << "First" << "Second" << "Third" << "Fourth" << "Fifth"; 427 lst << "First" << "Second" << "Third" << "Fourth" << "Fifth";
429 bool ok = FALSE; 428 bool ok = FALSE;
430 QString res = QInputDialog::getItem( tr( "Please select an item" ), lst, 1, TRUE, &ok, this ); 429 QString res = QInputDialog::getItem( tr( "Please select an item" ), lst, 1, TRUE, &ok, this );
431 if ( ok ) 430 if ( ok )
432 ;// user selected an item and pressed ok 431 ;// user selected an item and pressed ok
433 else 432 else
434 ;// user pressed cancel 433 ;// user pressed cancel
435 \endcode 434 \endcode
436*/ 435*/
437 436
438QString QInputDialog::getItem( const QString &caption, const QString &label, const QStringList &list, 437QString QInputDialog::getItem( const QString &caption, const QString &label, const QStringList &list,
439 int current, bool editable, 438 int current, bool editable,
440 bool *ok, QWidget *parent, const char *name ) 439 bool *ok, QWidget *parent, const char *name )
441{ 440{
442 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, editable ? EditableComboBox : ComboBox ); 441 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, editable ? EditableComboBox : ComboBox );
443 dlg->setCaption( caption ); 442 dlg->setCaption( caption );
444 if ( editable ) { 443 if ( editable ) {
445 dlg->editableComboBox()->insertStringList( list ); 444 dlg->editableComboBox()->insertStringList( list );
446 dlg->editableComboBox()->setCurrentItem( current ); 445 dlg->editableComboBox()->setCurrentItem( current );
447 } else { 446 } else {
448 dlg->comboBox()->insertStringList( list ); 447 dlg->comboBox()->insertStringList( list );
449 dlg->comboBox()->setCurrentItem( current ); 448 dlg->comboBox()->setCurrentItem( current );
450 } 449 }
451 450
452 bool ok_ = FALSE; 451 bool ok_ = FALSE;
453 QString result; 452 QString result;
454 ok_ = dlg->exec() == QDialog::Accepted; 453 ok_ = dlg->exec() == QDialog::Accepted;
455 if ( ok ) 454 if ( ok )
456 *ok = ok_; 455 *ok = ok_;
457 if ( editable ) 456 if ( editable )
458 result = dlg->editableComboBox()->currentText(); 457 result = dlg->editableComboBox()->currentText();
459 else 458 else
460 result = dlg->comboBox()->currentText(); 459 result = dlg->comboBox()->currentText();
461 460
462 delete dlg; 461 delete dlg;
463 return result; 462 return result;
464} 463}
465 464
466/*! 465/*!
467 \internal 466 \internal
468*/ 467*/
469 468
470void QInputDialog::textChanged( const QString &s ) 469void QInputDialog::textChanged( const QString &s )
471{ 470{
472 bool on; 471 bool on;
473 if ( d->lineEdit->validator() ) { 472 if ( d->lineEdit->validator() ) {
474 QString str = d->lineEdit->text(); 473 QString str = d->lineEdit->text();
475 int index = d->lineEdit->cursorPosition(); 474 int index = d->lineEdit->cursorPosition();
476 on = ( d->lineEdit->validator()->validate(str, index) == 475 on = ( d->lineEdit->validator()->validate(str, index) ==
477 QValidator::Acceptable ); 476 QValidator::Acceptable );
478 } else { 477 } else {
479 on = !s.isEmpty(); 478 on = !s.isEmpty();
480 } 479 }
481 d->ok->setEnabled( on ); 480 d->ok->setEnabled( on );
482} 481}
483 482
484/*! 483/*!
485 \internal 484 \internal
486*/ 485*/
487 486
488void QInputDialog::tryAccept() 487void QInputDialog::tryAccept()
489{ 488{
490 if ( !d->lineEdit->text().isEmpty() ) 489 if ( !d->lineEdit->text().isEmpty() )
491 accept(); 490 accept();
492} 491}
493 492
diff --git a/libqtaux/qsplitter.cpp b/libqtaux/qsplitter.cpp
index ab6e01b..39321f8 100644
--- a/libqtaux/qsplitter.cpp
+++ b/libqtaux/qsplitter.cpp
@@ -1,1128 +1,1124 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Splitter widget 4** Splitter widget
5** 5**
6** Created: 980105 6** Created: 980105
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the widgets module of the Qt GUI Toolkit. 10** This file is part of the widgets module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#include "qsplitter.h" 37#include "qsplitter.h"
38 38
39#include "qpainter.h"
40#include "qdrawutil.h" 39#include "qdrawutil.h"
41#include "qbitmap.h"
42#include "qlayoutengine_p.h" 40#include "qlayoutengine_p.h"
43#include "qlist.h"
44#include "qarray.h"
45#include "qobjectlist.h" 41#include "qobjectlist.h"
46#include "qapplication.h" //sendPostedEvents 42#include "qapplication.h" //sendPostedEvents
47 43
48class QSplitterHandle : public QWidget 44class QSplitterHandle : public QWidget
49{ 45{
50public: 46public:
51 QSplitterHandle( Qt::Orientation o, 47 QSplitterHandle( Qt::Orientation o,
52 QSplitter *parent, const char* name=0 ); 48 QSplitter *parent, const char* name=0 );
53 void setOrientation( Qt::Orientation o ); 49 void setOrientation( Qt::Orientation o );
54 Qt::Orientation orientation() const { return orient; } 50 Qt::Orientation orientation() const { return orient; }
55 51
56 bool opaque() const { return s->opaqueResize(); } 52 bool opaque() const { return s->opaqueResize(); }
57 53
58 QSize sizeHint() const; 54 QSize sizeHint() const;
59 QSizePolicy sizePolicy() const; 55 QSizePolicy sizePolicy() const;
60 56
61 int id() const { return myId; } // data->list.at(id())->wid == this 57 int id() const { return myId; } // data->list.at(id())->wid == this
62 void setId( int i ) { myId = i; } 58 void setId( int i ) { myId = i; }
63 59
64protected: 60protected:
65 void paintEvent( QPaintEvent * ); 61 void paintEvent( QPaintEvent * );
66 void mouseMoveEvent( QMouseEvent * ); 62 void mouseMoveEvent( QMouseEvent * );
67 void mousePressEvent( QMouseEvent * ); 63 void mousePressEvent( QMouseEvent * );
68 void mouseReleaseEvent( QMouseEvent * ); 64 void mouseReleaseEvent( QMouseEvent * );
69 65
70private: 66private:
71 Qt::Orientation orient; 67 Qt::Orientation orient;
72 bool opaq; 68 bool opaq;
73 int myId; 69 int myId;
74 70
75 QSplitter *s; 71 QSplitter *s;
76}; 72};
77 73
78static int mouseOffset; 74static int mouseOffset;
79static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 75static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
80 76
81 77
82QSplitterHandle::QSplitterHandle( Qt::Orientation o, 78QSplitterHandle::QSplitterHandle( Qt::Orientation o,
83 QSplitter *parent, const char * name ) 79 QSplitter *parent, const char * name )
84 : QWidget( parent, name ) 80 : QWidget( parent, name )
85{ 81{
86 s = parent; 82 s = parent;
87 setOrientation(o); 83 setOrientation(o);
88} 84}
89 85
90QSizePolicy QSplitterHandle::sizePolicy() const 86QSizePolicy QSplitterHandle::sizePolicy() const
91{ 87{
92 //### removeme 3.0 88 //### removeme 3.0
93 return QWidget::sizePolicy(); 89 return QWidget::sizePolicy();
94} 90}
95 91
96QSize QSplitterHandle::sizeHint() const 92QSize QSplitterHandle::sizeHint() const
97{ 93{
98 int sw = style().splitterWidth(); 94 int sw = style().splitterWidth();
99 return QSize(sw,sw).expandedTo( QApplication::globalStrut() ); 95 return QSize(sw,sw).expandedTo( QApplication::globalStrut() );
100} 96}
101 97
102void QSplitterHandle::setOrientation( Qt::Orientation o ) 98void QSplitterHandle::setOrientation( Qt::Orientation o )
103{ 99{
104 orient = o; 100 orient = o;
105#ifndef QT_NO_CURSOR 101#ifndef QT_NO_CURSOR
106 if ( o == QSplitter::Horizontal ) 102 if ( o == QSplitter::Horizontal )
107 setCursor( splitHCursor ); 103 setCursor( splitHCursor );
108 else 104 else
109 setCursor( splitVCursor ); 105 setCursor( splitVCursor );
110#endif 106#endif
111} 107}
112 108
113 109
114void QSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 110void QSplitterHandle::mouseMoveEvent( QMouseEvent *e )
115{ 111{
116 if ( !(e->state()&LeftButton) ) 112 if ( !(e->state()&LeftButton) )
117 return; 113 return;
118 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 114 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
119 - mouseOffset; 115 - mouseOffset;
120 if ( opaque() ) { 116 if ( opaque() ) {
121 s->moveSplitter( pos, id() ); 117 s->moveSplitter( pos, id() );
122 } else { 118 } else {
123 int min = pos; int max = pos; 119 int min = pos; int max = pos;
124 s->getRange( id(), &min, &max ); 120 s->getRange( id(), &min, &max );
125 s->setRubberband( QMAX( min, QMIN(max, pos ))); 121 s->setRubberband( QMAX( min, QMIN(max, pos )));
126 } 122 }
127} 123}
128 124
129void QSplitterHandle::mousePressEvent( QMouseEvent *e ) 125void QSplitterHandle::mousePressEvent( QMouseEvent *e )
130{ 126{
131 if ( e->button() == LeftButton ) 127 if ( e->button() == LeftButton )
132 mouseOffset = s->pick(e->pos()); 128 mouseOffset = s->pick(e->pos());
133} 129}
134 130
135void QSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 131void QSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
136{ 132{
137 if ( !opaque() && e->button() == LeftButton ) { 133 if ( !opaque() && e->button() == LeftButton ) {
138 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())); 134 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()));
139 s->setRubberband( -1 ); 135 s->setRubberband( -1 );
140 s->moveSplitter( pos, id() ); 136 s->moveSplitter( pos, id() );
141 } 137 }
142} 138}
143 139
144void QSplitterHandle::paintEvent( QPaintEvent * ) 140void QSplitterHandle::paintEvent( QPaintEvent * )
145{ 141{
146 QPainter p( this ); 142 QPainter p( this );
147 s->drawSplitter( &p, 0, 0, width(), height() ); 143 s->drawSplitter( &p, 0, 0, width(), height() );
148} 144}
149 145
150 146
151class QSplitterLayoutStruct 147class QSplitterLayoutStruct
152{ 148{
153public: 149public:
154 QSplitter::ResizeMode mode; 150 QSplitter::ResizeMode mode;
155 QCOORD sizer; 151 QCOORD sizer;
156 bool isSplitter; 152 bool isSplitter;
157 QWidget *wid; 153 QWidget *wid;
158}; 154};
159 155
160class QSplitterData 156class QSplitterData
161{ 157{
162public: 158public:
163 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 159 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
164 160
165 QList<QSplitterLayoutStruct> list; 161 QList<QSplitterLayoutStruct> list;
166 bool opaque; 162 bool opaque;
167 bool firstShow; 163 bool firstShow;
168}; 164};
169 165
170 166
171// NOT REVISED 167// NOT REVISED
172/*! 168/*!
173 \class QSplitter qsplitter.h 169 \class QSplitter qsplitter.h
174 \brief The QSplitter class implements a splitter widget. 170 \brief The QSplitter class implements a splitter widget.
175 171
176 \ingroup organizers 172 \ingroup organizers
177 173
178 A splitter lets the user control the size of child widgets by 174 A splitter lets the user control the size of child widgets by
179 dragging the boundary between the children. Any number of widgets 175 dragging the boundary between the children. Any number of widgets
180 may be controlled. 176 may be controlled.
181 177
182 To show a QListBox, a QListView and a QMultiLineEdit side by side: 178 To show a QListBox, a QListView and a QMultiLineEdit side by side:
183 179
184 \code 180 \code
185 QSplitter *split = new QSplitter( parent ); 181 QSplitter *split = new QSplitter( parent );
186 QListBox *lb = new QListBox( split ); 182 QListBox *lb = new QListBox( split );
187 QListView *lv = new QListView( split ); 183 QListView *lv = new QListView( split );
188 QMultiLineEdit *ed = new QMultiLineEdit( split ); 184 QMultiLineEdit *ed = new QMultiLineEdit( split );
189 \endcode 185 \endcode
190 186
191 In QSplitter the boundary can be either horizontal or vertical. The 187 In QSplitter the boundary can be either horizontal or vertical. The
192 default is horizontal (the children are side by side) and you 188 default is horizontal (the children are side by side) and you
193 can use setOrientation( QSplitter::Vertical ) to set it to vertical. 189 can use setOrientation( QSplitter::Vertical ) to set it to vertical.
194 190
195 By default, all widgets can be as large or as small as the user 191 By default, all widgets can be as large or as small as the user
196 wishes, down to \link QWidget::minimumSizeHint() minimumSizeHint()\endlink. 192 wishes, down to \link QWidget::minimumSizeHint() minimumSizeHint()\endlink.
197 You can naturally use setMinimumSize() and/or 193 You can naturally use setMinimumSize() and/or
198 setMaximumSize() on the children. Use setResizeMode() to specify that 194 setMaximumSize() on the children. Use setResizeMode() to specify that
199 a widget should keep its size when the splitter is resized. 195 a widget should keep its size when the splitter is resized.
200 196
201 QSplitter normally resizes the children only at the end of a 197 QSplitter normally resizes the children only at the end of a
202 resize operation, but if you call setOpaqueResize( TRUE ), the 198 resize operation, but if you call setOpaqueResize( TRUE ), the
203 widgets are resized as often as possible. 199 widgets are resized as often as possible.
204 200
205 The initial distribution of size between the widgets is determined 201 The initial distribution of size between the widgets is determined
206 by the initial size of each widget. You can also use setSizes() to 202 by the initial size of each widget. You can also use setSizes() to
207 set the sizes of all the widgets. The function sizes() returns the 203 set the sizes of all the widgets. The function sizes() returns the
208 sizes set by the user. 204 sizes set by the user.
209 205
210 If you hide() a child, its space will be distributed among the other 206 If you hide() a child, its space will be distributed among the other
211 children. When you show() it again, it will be reinstated. 207 children. When you show() it again, it will be reinstated.
212 208
213 <img src=qsplitter-m.png> <img src=qsplitter-w.png> 209 <img src=qsplitter-m.png> <img src=qsplitter-w.png>
214 210
215 \sa QTabBar 211 \sa QTabBar
216*/ 212*/
217 213
218 214
219 215
220static QSize minSize( const QWidget *w ) 216static QSize minSize( const QWidget *w )
221{ 217{
222 QSize min = w->minimumSize(); 218 QSize min = w->minimumSize();
223 QSize s; 219 QSize s;
224 if ( min.height() <= 0 || min.width() <= 0 ) 220 if ( min.height() <= 0 || min.width() <= 0 )
225 s = w->minimumSizeHint(); 221 s = w->minimumSizeHint();
226 if ( min.height() > 0 ) 222 if ( min.height() > 0 )
227 s.setHeight( min.height() ); 223 s.setHeight( min.height() );
228 if ( min.width() > 0 ) 224 if ( min.width() > 0 )
229 s.setWidth( min.width() ); 225 s.setWidth( min.width() );
230 return s.expandedTo(QSize(0,0)); 226 return s.expandedTo(QSize(0,0));
231} 227}
232 228
233/*! 229/*!
234 Constructs a horizontal splitter. 230 Constructs a horizontal splitter.
235*/ 231*/
236 232
237QSplitter::QSplitter( QWidget *parent, const char *name ) 233QSplitter::QSplitter( QWidget *parent, const char *name )
238 :QFrame(parent,name,WPaintUnclipped) 234 :QFrame(parent,name,WPaintUnclipped)
239{ 235{
240 orient = Horizontal; 236 orient = Horizontal;
241 init(); 237 init();
242} 238}
243 239
244 240
245/*! 241/*!
246 Constructs splitter with orientation \a o. 242 Constructs splitter with orientation \a o.
247*/ 243*/
248 244
249QSplitter::QSplitter( Orientation o, QWidget *parent, const char *name ) 245QSplitter::QSplitter( Orientation o, QWidget *parent, const char *name )
250 :QFrame(parent,name,WPaintUnclipped) 246 :QFrame(parent,name,WPaintUnclipped)
251{ 247{
252 orient = o; 248 orient = o;
253 init(); 249 init();
254} 250}
255 251
256 252
257/*! 253/*!
258 Destructs the splitter. 254 Destructs the splitter.
259*/ 255*/
260 256
261QSplitter::~QSplitter() 257QSplitter::~QSplitter()
262{ 258{
263 data->list.setAutoDelete( TRUE ); 259 data->list.setAutoDelete( TRUE );
264 delete data; 260 delete data;
265} 261}
266 262
267 263
268void QSplitter::init() 264void QSplitter::init()
269{ 265{
270 data = new QSplitterData; 266 data = new QSplitterData;
271 if ( orient == Horizontal ) 267 if ( orient == Horizontal )
272 setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum) ); 268 setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum) );
273 else 269 else
274 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed) ); 270 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed) );
275} 271}
276 272
277 273
278/*! 274/*!
279 \fn void QSplitter::refresh() 275 \fn void QSplitter::refresh()
280 276
281 Updates the splitter state. You should not need to call this 277 Updates the splitter state. You should not need to call this
282 function during normal use of the splitter. 278 function during normal use of the splitter.
283*/ 279*/
284 280
285 281
286/*! Sets the orientation to \a o. By default the orientation is 282/*! Sets the orientation to \a o. By default the orientation is
287 horizontal (the widgets are side by side). 283 horizontal (the widgets are side by side).
288 284
289 \sa orientation() 285 \sa orientation()
290*/ 286*/
291 287
292void QSplitter::setOrientation( Orientation o ) 288void QSplitter::setOrientation( Orientation o )
293{ 289{
294 if ( orient == o ) 290 if ( orient == o )
295 return; 291 return;
296 orient = o; 292 orient = o;
297 293
298 if ( orient == Horizontal ) 294 if ( orient == Horizontal )
299 setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ) ); 295 setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ) );
300 else 296 else
301 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) ); 297 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) );
302 298
303 QSplitterLayoutStruct *s = data->list.first(); 299 QSplitterLayoutStruct *s = data->list.first();
304 while ( s ) { 300 while ( s ) {
305 if ( s->isSplitter ) 301 if ( s->isSplitter )
306 ((QSplitterHandle*)s->wid)->setOrientation( o ); 302 ((QSplitterHandle*)s->wid)->setOrientation( o );
307 s = data->list.next(); // ### next at end of loop, no iterator 303 s = data->list.next(); // ### next at end of loop, no iterator
308 } 304 }
309 recalc( isVisible() ); 305 recalc( isVisible() );
310} 306}
311 307
312 308
313/*! 309/*!
314 \fn Orientation QSplitter::orientation() const 310 \fn Orientation QSplitter::orientation() const
315 311
316 Returns the orientation (\c Horizontal or \c Vertical) of the splitter. 312 Returns the orientation (\c Horizontal or \c Vertical) of the splitter.
317 \sa setOrientation() 313 \sa setOrientation()
318*/ 314*/
319 315
320/*! 316/*!
321 \reimp 317 \reimp
322*/ 318*/
323void QSplitter::resizeEvent( QResizeEvent * ) 319void QSplitter::resizeEvent( QResizeEvent * )
324{ 320{
325 doResize(); 321 doResize();
326} 322}
327 323
328 324
329/*! 325/*!
330 Inserts the widget \a w at the end, or at the beginning if \a first is TRUE 326 Inserts the widget \a w at the end, or at the beginning if \a first is TRUE
331 327
332 It is the responsibility of the caller of this function to make sure 328 It is the responsibility of the caller of this function to make sure
333 that \a w is not already in the splitter, and to call recalcId if 329 that \a w is not already in the splitter, and to call recalcId if
334 needed. (If \a first is TRUE, then recalcId is very probably 330 needed. (If \a first is TRUE, then recalcId is very probably
335 needed.) 331 needed.)
336*/ 332*/
337 333
338QSplitterLayoutStruct *QSplitter::addWidget( QWidget *w, bool first ) 334QSplitterLayoutStruct *QSplitter::addWidget( QWidget *w, bool first )
339{ 335{
340 QSplitterLayoutStruct *s; 336 QSplitterLayoutStruct *s;
341 QSplitterHandle *newHandle = 0; 337 QSplitterHandle *newHandle = 0;
342 if ( data->list.count() > 0 ) { 338 if ( data->list.count() > 0 ) {
343 s = new QSplitterLayoutStruct; 339 s = new QSplitterLayoutStruct;
344 s->mode = KeepSize; 340 s->mode = KeepSize;
345 newHandle = new QSplitterHandle( orientation(), this ); 341 newHandle = new QSplitterHandle( orientation(), this );
346 s->wid = newHandle; 342 s->wid = newHandle;
347 newHandle->setId(data->list.count()); 343 newHandle->setId(data->list.count());
348 s->isSplitter = TRUE; 344 s->isSplitter = TRUE;
349 s->sizer = pick( newHandle->sizeHint() ); 345 s->sizer = pick( newHandle->sizeHint() );
350 if ( first ) 346 if ( first )
351 data->list.insert( 0, s ); 347 data->list.insert( 0, s );
352 else 348 else
353 data->list.append( s ); 349 data->list.append( s );
354 } 350 }
355 s = new QSplitterLayoutStruct; 351 s = new QSplitterLayoutStruct;
356 s->mode = Stretch; 352 s->mode = Stretch;
357 s->wid = w; 353 s->wid = w;
358 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 354 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
359 s->sizer = pick( w->sizeHint() ); 355 s->sizer = pick( w->sizeHint() );
360 else 356 else
361 s->sizer = pick( w->size() ); 357 s->sizer = pick( w->size() );
362 s->isSplitter = FALSE; 358 s->isSplitter = FALSE;
363 if ( first ) 359 if ( first )
364 data->list.insert( 0, s ); 360 data->list.insert( 0, s );
365 else 361 else
366 data->list.append( s ); 362 data->list.append( s );
367 if ( newHandle && isVisible() ) 363 if ( newHandle && isVisible() )
368 newHandle->show(); //will trigger sending of post events 364 newHandle->show(); //will trigger sending of post events
369 return s; 365 return s;
370} 366}
371 367
372 368
373/*! 369/*!
374 Tells the splitter that a child widget has been inserted/removed. 370 Tells the splitter that a child widget has been inserted/removed.
375*/ 371*/
376 372
377void QSplitter::childEvent( QChildEvent *c ) 373void QSplitter::childEvent( QChildEvent *c )
378{ 374{
379 if ( c->type() == QEvent::ChildInserted ) { 375 if ( c->type() == QEvent::ChildInserted ) {
380 if ( !c->child()->isWidgetType() ) 376 if ( !c->child()->isWidgetType() )
381 return; 377 return;
382 378
383 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 379 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
384 return; 380 return;
385 381
386 QSplitterLayoutStruct *s = data->list.first(); 382 QSplitterLayoutStruct *s = data->list.first();
387 while ( s ) { 383 while ( s ) {
388 if ( s->wid == c->child() ) 384 if ( s->wid == c->child() )
389 return; 385 return;
390 s = data->list.next(); 386 s = data->list.next();
391 } 387 }
392 addWidget( (QWidget*)c->child() ); 388 addWidget( (QWidget*)c->child() );
393 recalc( isVisible() ); 389 recalc( isVisible() );
394 390
395 } else if ( c->type() == QEvent::ChildRemoved ) { 391 } else if ( c->type() == QEvent::ChildRemoved ) {
396 QSplitterLayoutStruct *p = 0; 392 QSplitterLayoutStruct *p = 0;
397 if ( data->list.count() > 1 ) 393 if ( data->list.count() > 1 )
398 p = data->list.at(1); //remove handle _after_ first widget. 394 p = data->list.at(1); //remove handle _after_ first widget.
399 QSplitterLayoutStruct *s = data->list.first(); 395 QSplitterLayoutStruct *s = data->list.first();
400 while ( s ) { 396 while ( s ) {
401 if ( s->wid == c->child() ) { 397 if ( s->wid == c->child() ) {
402 data->list.removeRef( s ); 398 data->list.removeRef( s );
403 delete s; 399 delete s;
404 if ( p && p->isSplitter ) { 400 if ( p && p->isSplitter ) {
405 data->list.removeRef( p ); 401 data->list.removeRef( p );
406 delete p->wid; //will call childEvent 402 delete p->wid; //will call childEvent
407 delete p; 403 delete p;
408 } 404 }
409 recalcId(); 405 recalcId();
410 doResize(); 406 doResize();
411 return; 407 return;
412 } 408 }
413 p = s; 409 p = s;
414 s = data->list.next(); 410 s = data->list.next();
415 } 411 }
416 } 412 }
417} 413}
418 414
419 415
420/*! 416/*!
421 Shows a rubber band at position \a p. If \a p is negative, the 417 Shows a rubber band at position \a p. If \a p is negative, the
422 rubber band is removed. 418 rubber band is removed.
423*/ 419*/
424 420
425void QSplitter::setRubberband( int p ) 421void QSplitter::setRubberband( int p )
426{ 422{
427 QPainter paint( this ); 423 QPainter paint( this );
428 paint.setPen( gray ); 424 paint.setPen( gray );
429 paint.setBrush( gray ); 425 paint.setBrush( gray );
430 paint.setRasterOp( XorROP ); 426 paint.setRasterOp( XorROP );
431 QRect r = contentsRect(); 427 QRect r = contentsRect();
432 const int rBord = 3; //Themable???? 428 const int rBord = 3; //Themable????
433 const int sw = style().splitterWidth(); 429 const int sw = style().splitterWidth();
434 if ( orient == Horizontal ) { 430 if ( orient == Horizontal ) {
435 if ( opaqueOldPos >= 0 ) 431 if ( opaqueOldPos >= 0 )
436 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 432 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
437 2*rBord, r.height() ); 433 2*rBord, r.height() );
438 if ( p >= 0 ) 434 if ( p >= 0 )
439 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 435 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
440 } else { 436 } else {
441 if ( opaqueOldPos >= 0 ) 437 if ( opaqueOldPos >= 0 )
442 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 438 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
443 r.width(), 2*rBord ); 439 r.width(), 2*rBord );
444 if ( p >= 0 ) 440 if ( p >= 0 )
445 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 441 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
446 } 442 }
447 opaqueOldPos = p; 443 opaqueOldPos = p;
448} 444}
449 445
450 446
451/*! \reimp */ 447/*! \reimp */
452 448
453bool QSplitter::event( QEvent *e ) 449bool QSplitter::event( QEvent *e )
454{ 450{
455 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 451 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
456 recalc( isVisible() ); 452 recalc( isVisible() );
457 if ( e->type() == QEvent::Show ) 453 if ( e->type() == QEvent::Show )
458 data->firstShow = FALSE; 454 data->firstShow = FALSE;
459 } 455 }
460 return QWidget::event( e ); 456 return QWidget::event( e );
461} 457}
462 458
463 459
464/*! 460/*!
465 Draws the splitter handle in the rectangle described by \a x, \a y, 461 Draws the splitter handle in the rectangle described by \a x, \a y,
466 \a w, \a h using painter \a p. 462 \a w, \a h using painter \a p.
467 \sa QStyle::drawSplitter 463 \sa QStyle::drawSplitter
468*/ 464*/
469 465
470void QSplitter::drawSplitter( QPainter *p, 466void QSplitter::drawSplitter( QPainter *p,
471 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 467 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
472{ 468{
473 style().drawSplitter( p, x, y, w, h, colorGroup(), orient ); 469 style().drawSplitter( p, x, y, w, h, colorGroup(), orient );
474} 470}
475 471
476 472
477/*! 473/*!
478 Returns the id of the splitter to the right of or below the widget \a w, 474 Returns the id of the splitter to the right of or below the widget \a w,
479 or 0 if there is no such splitter. 475 or 0 if there is no such splitter.
480 (ie. it is either not in this QSplitter, or it is at the end). 476 (ie. it is either not in this QSplitter, or it is at the end).
481*/ 477*/
482 478
483int QSplitter::idAfter( QWidget* w ) const 479int QSplitter::idAfter( QWidget* w ) const
484{ 480{
485 QSplitterLayoutStruct *s = data->list.first(); 481 QSplitterLayoutStruct *s = data->list.first();
486 bool seen_w = FALSE; 482 bool seen_w = FALSE;
487 while ( s ) { 483 while ( s ) {
488 if ( s->isSplitter && seen_w ) 484 if ( s->isSplitter && seen_w )
489 return data->list.at(); 485 return data->list.at();
490 if ( !s->isSplitter && s->wid == w ) 486 if ( !s->isSplitter && s->wid == w )
491 seen_w = TRUE; 487 seen_w = TRUE;
492 s = data->list.next(); 488 s = data->list.next();
493 } 489 }
494 return 0; 490 return 0;
495} 491}
496 492
497 493
498/*! 494/*!
499 Moves the left/top edge of the splitter handle with id \a id as 495 Moves the left/top edge of the splitter handle with id \a id as
500 close as possible to \a p which is the distance from the left (or 496 close as possible to \a p which is the distance from the left (or
501 top) edge of the widget. 497 top) edge of the widget.
502 498
503 \sa idAfter() 499 \sa idAfter()
504*/ 500*/
505void QSplitter::moveSplitter( QCOORD p, int id ) 501void QSplitter::moveSplitter( QCOORD p, int id )
506{ 502{
507 p = adjustPos( p, id ); 503 p = adjustPos( p, id );
508 504
509 QSplitterLayoutStruct *s = data->list.at(id); 505 QSplitterLayoutStruct *s = data->list.at(id);
510 int oldP = orient == Horizontal? s->wid->x() : s->wid->y(); 506 int oldP = orient == Horizontal? s->wid->x() : s->wid->y();
511 bool upLeft = p < oldP; 507 bool upLeft = p < oldP;
512 508
513 moveAfter( p, id, upLeft ); 509 moveAfter( p, id, upLeft );
514 moveBefore( p-1, id-1, upLeft ); 510 moveBefore( p-1, id-1, upLeft );
515 511
516 storeSizes(); 512 storeSizes();
517} 513}
518 514
519 515
520void QSplitter::setG( QWidget *w, int p, int s ) 516void QSplitter::setG( QWidget *w, int p, int s )
521{ 517{
522 if ( orient == Horizontal ) 518 if ( orient == Horizontal )
523 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 519 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
524 else 520 else
525 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 521 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
526} 522}
527 523
528 524
529/*! 525/*!
530 Places the right/bottom edge of the widget at \a id at position \a pos. 526 Places the right/bottom edge of the widget at \a id at position \a pos.
531 527
532 \sa idAfter() 528 \sa idAfter()
533*/ 529*/
534 530
535void QSplitter::moveBefore( int pos, int id, bool upLeft ) 531void QSplitter::moveBefore( int pos, int id, bool upLeft )
536{ 532{
537 QSplitterLayoutStruct *s = data->list.at(id); 533 QSplitterLayoutStruct *s = data->list.at(id);
538 if ( !s ) 534 if ( !s )
539 return; 535 return;
540 QWidget *w = s->wid; 536 QWidget *w = s->wid;
541 if ( w->isHidden() ) { 537 if ( w->isHidden() ) {
542 moveBefore( pos, id-1, upLeft ); 538 moveBefore( pos, id-1, upLeft );
543 } else if ( s->isSplitter ) { 539 } else if ( s->isSplitter ) {
544 int dd = s->sizer; 540 int dd = s->sizer;
545 if ( upLeft ) { 541 if ( upLeft ) {
546 setG( w, pos-dd+1, dd ); 542 setG( w, pos-dd+1, dd );
547 moveBefore( pos-dd, id-1, upLeft ); 543 moveBefore( pos-dd, id-1, upLeft );
548 } else { 544 } else {
549 moveBefore( pos-dd, id-1, upLeft ); 545 moveBefore( pos-dd, id-1, upLeft );
550 setG( w, pos-dd+1, dd ); 546 setG( w, pos-dd+1, dd );
551 } 547 }
552 } else { 548 } else {
553 int left = pick( w->pos() ); 549 int left = pick( w->pos() );
554 int dd = pos - left + 1; 550 int dd = pos - left + 1;
555 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 551 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
556 int newLeft = pos-dd+1; 552 int newLeft = pos-dd+1;
557 setG( w, newLeft, dd ); 553 setG( w, newLeft, dd );
558 if ( left != newLeft ) 554 if ( left != newLeft )
559 moveBefore( newLeft-1, id-1, upLeft ); 555 moveBefore( newLeft-1, id-1, upLeft );
560 } 556 }
561} 557}
562 558
563 559
564/*! 560/*!
565 Places the left/top edge of the widget at \a id at position \a pos. 561 Places the left/top edge of the widget at \a id at position \a pos.
566 562
567 \sa idAfter() 563 \sa idAfter()
568*/ 564*/
569 565
570void QSplitter::moveAfter( int pos, int id, bool upLeft ) 566void QSplitter::moveAfter( int pos, int id, bool upLeft )
571{ 567{
572 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 568 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
573 data->list.at(id) : 0; 569 data->list.at(id) : 0;
574 if ( !s ) 570 if ( !s )
575 return; 571 return;
576 QWidget *w = s->wid; 572 QWidget *w = s->wid;
577 if ( w->isHidden() ) { 573 if ( w->isHidden() ) {
578 moveAfter( pos, id+1, upLeft ); 574 moveAfter( pos, id+1, upLeft );
579 } else if ( pick( w->pos() ) == pos ) { 575 } else if ( pick( w->pos() ) == pos ) {
580 //No need to do anything if it's already there. 576 //No need to do anything if it's already there.
581 return; 577 return;
582 } else if ( s->isSplitter ) { 578 } else if ( s->isSplitter ) {
583 int dd = s->sizer; 579 int dd = s->sizer;
584 if ( upLeft ) { 580 if ( upLeft ) {
585 setG( w, pos, dd ); 581 setG( w, pos, dd );
586 moveAfter( pos+dd, id+1, upLeft ); 582 moveAfter( pos+dd, id+1, upLeft );
587 } else { 583 } else {
588 moveAfter( pos+dd, id+1, upLeft ); 584 moveAfter( pos+dd, id+1, upLeft );
589 setG( w, pos, dd ); 585 setG( w, pos, dd );
590 } 586 }
591 } else { 587 } else {
592 int right = pick( w->geometry().bottomRight() ); 588 int right = pick( w->geometry().bottomRight() );
593 589
594 int dd = right - pos + 1; 590 int dd = right - pos + 1;
595 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 591 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
596 int newRight = pos+dd-1; 592 int newRight = pos+dd-1;
597 setG( w, pos, dd ); 593 setG( w, pos, dd );
598 moveAfter( newRight+1, id+1, upLeft ); 594 moveAfter( newRight+1, id+1, upLeft );
599 } 595 }
600} 596}
601 597
602 598
603/*! 599/*!
604 Returns the valid range of the splitter with id \a id in \a min and \a max. 600 Returns the valid range of the splitter with id \a id in \a min and \a max.
605 601
606 \sa idAfter() 602 \sa idAfter()
607*/ 603*/
608 604
609void QSplitter::getRange( int id, int *min, int *max ) 605void QSplitter::getRange( int id, int *min, int *max )
610{ 606{
611 int minB = 0;//before 607 int minB = 0;//before
612 int maxB = 0; 608 int maxB = 0;
613 int minA = 0; 609 int minA = 0;
614 int maxA = 0;//after 610 int maxA = 0;//after
615 int n = data->list.count(); 611 int n = data->list.count();
616 if ( id < 0 || id >= n ) 612 if ( id < 0 || id >= n )
617 return; 613 return;
618 int i; 614 int i;
619 for ( i = 0; i < id; i++ ) { 615 for ( i = 0; i < id; i++ ) {
620 QSplitterLayoutStruct *s = data->list.at(i); 616 QSplitterLayoutStruct *s = data->list.at(i);
621 if ( s->wid->isHidden() ) { 617 if ( s->wid->isHidden() ) {
622 //ignore 618 //ignore
623 } else if ( s->isSplitter ) { 619 } else if ( s->isSplitter ) {
624 minB += s->sizer; 620 minB += s->sizer;
625 maxB += s->sizer; 621 maxB += s->sizer;
626 } else { 622 } else {
627 minB += pick( minSize(s->wid) ); 623 minB += pick( minSize(s->wid) );
628 maxB += pick( s->wid->maximumSize() ); 624 maxB += pick( s->wid->maximumSize() );
629 } 625 }
630 } 626 }
631 for ( i = id; i < n; i++ ) { 627 for ( i = id; i < n; i++ ) {
632 QSplitterLayoutStruct *s = data->list.at(i); 628 QSplitterLayoutStruct *s = data->list.at(i);
633 if ( s->wid->isHidden() ) { 629 if ( s->wid->isHidden() ) {
634 //ignore 630 //ignore
635 } else if ( s->isSplitter ) { 631 } else if ( s->isSplitter ) {
636 minA += s->sizer; 632 minA += s->sizer;
637 maxA += s->sizer; 633 maxA += s->sizer;
638 } else { 634 } else {
639 minA += pick( minSize(s->wid) ); 635 minA += pick( minSize(s->wid) );
640 maxA += pick( s->wid->maximumSize() ); 636 maxA += pick( s->wid->maximumSize() );
641 } 637 }
642 } 638 }
643 QRect r = contentsRect(); 639 QRect r = contentsRect();
644 if ( min ) 640 if ( min )
645 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 641 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
646 if ( max ) 642 if ( max )
647 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 643 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
648 644
649} 645}
650 646
651 647
652/*! 648/*!
653 Returns the legal position closest to \a p of the splitter with id \a id. 649 Returns the legal position closest to \a p of the splitter with id \a id.
654 650
655 \sa idAfter() 651 \sa idAfter()
656*/ 652*/
657 653
658int QSplitter::adjustPos( int p, int id ) 654int QSplitter::adjustPos( int p, int id )
659{ 655{
660 int min = 0; 656 int min = 0;
661 int max = 0; 657 int max = 0;
662 getRange( id, &min, &max ); 658 getRange( id, &min, &max );
663 p = QMAX( min, QMIN( p, max ) ); 659 p = QMAX( min, QMIN( p, max ) );
664 660
665 return p; 661 return p;
666} 662}
667 663
668 664
669void QSplitter::doResize() 665void QSplitter::doResize()
670{ 666{
671 QRect r = contentsRect(); 667 QRect r = contentsRect();
672 int i; 668 int i;
673 int n = data->list.count(); 669 int n = data->list.count();
674 QArray<QLayoutStruct> a( n ); 670 QArray<QLayoutStruct> a( n );
675 for ( i = 0; i< n; i++ ) { 671 for ( i = 0; i< n; i++ ) {
676 a[i].init(); 672 a[i].init();
677 QSplitterLayoutStruct *s = data->list.at(i); 673 QSplitterLayoutStruct *s = data->list.at(i);
678 if ( s->wid->isHidden() ) { 674 if ( s->wid->isHidden() ) {
679 a[i].stretch = 0; 675 a[i].stretch = 0;
680 a[i].sizeHint = a[i].minimumSize = 0; 676 a[i].sizeHint = a[i].minimumSize = 0;
681 a[i].maximumSize = 0; 677 a[i].maximumSize = 0;
682 } else if ( s->isSplitter ) { 678 } else if ( s->isSplitter ) {
683 a[i].stretch = 0; 679 a[i].stretch = 0;
684 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 680 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
685 a[i].empty = FALSE; 681 a[i].empty = FALSE;
686 } else if ( s->mode == KeepSize ) { 682 } else if ( s->mode == KeepSize ) {
687 a[i].stretch = 0; 683 a[i].stretch = 0;
688 a[i].minimumSize = pick( minSize(s->wid) ); 684 a[i].minimumSize = pick( minSize(s->wid) );
689 a[i].sizeHint = s->sizer; 685 a[i].sizeHint = s->sizer;
690 a[i].maximumSize = pick( s->wid->maximumSize() ); 686 a[i].maximumSize = pick( s->wid->maximumSize() );
691 a[i].empty = FALSE; 687 a[i].empty = FALSE;
692 } else if ( s->mode == FollowSizeHint ) { 688 } else if ( s->mode == FollowSizeHint ) {
693 a[i].stretch = 0; 689 a[i].stretch = 0;
694 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 690 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
695 a[i].maximumSize = pick( s->wid->maximumSize() ); 691 a[i].maximumSize = pick( s->wid->maximumSize() );
696 a[i].empty = FALSE; 692 a[i].empty = FALSE;
697 } else { //proportional 693 } else { //proportional
698 a[i].stretch = s->sizer; 694 a[i].stretch = s->sizer;
699 a[i].maximumSize = pick( s->wid->maximumSize() ); 695 a[i].maximumSize = pick( s->wid->maximumSize() );
700 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 696 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
701 a[i].empty = FALSE; 697 a[i].empty = FALSE;
702 } 698 }
703 } 699 }
704 700
705 qGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 701 qGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
706 for ( i = 0; i< n; i++ ) { 702 for ( i = 0; i< n; i++ ) {
707 QSplitterLayoutStruct *s = data->list.at(i); 703 QSplitterLayoutStruct *s = data->list.at(i);
708 if ( orient == Horizontal ) 704 if ( orient == Horizontal )
709 s->wid->setGeometry( a[i].pos, r.top(), a[i].size, r.height() ); 705 s->wid->setGeometry( a[i].pos, r.top(), a[i].size, r.height() );
710 else 706 else
711 s->wid->setGeometry( r.left(), a[i].pos, r.width(), a[i].size ); 707 s->wid->setGeometry( r.left(), a[i].pos, r.width(), a[i].size );
712 } 708 }
713 709
714} 710}
715 711
716 712
717void QSplitter::recalc( bool update ) 713void QSplitter::recalc( bool update )
718{ 714{
719 int fi = 2*frameWidth(); 715 int fi = 2*frameWidth();
720 int maxl = fi; 716 int maxl = fi;
721 int minl = fi; 717 int minl = fi;
722 int maxt = QWIDGETSIZE_MAX; 718 int maxt = QWIDGETSIZE_MAX;
723 int mint = fi; 719 int mint = fi;
724 int n = data->list.count(); 720 int n = data->list.count();
725 bool first = TRUE; 721 bool first = TRUE;
726 /* 722 /*
727 The splitter before a hidden widget is always hidden. 723 The splitter before a hidden widget is always hidden.
728 The splitter before the first visible widget is hidden. 724 The splitter before the first visible widget is hidden.
729 The splitter before any other visible widget is visible. 725 The splitter before any other visible widget is visible.
730 */ 726 */
731 for ( int i = 0; i< n; i++ ) { 727 for ( int i = 0; i< n; i++ ) {
732 QSplitterLayoutStruct *s = data->list.at(i); 728 QSplitterLayoutStruct *s = data->list.at(i);
733 if ( !s->isSplitter ) { 729 if ( !s->isSplitter ) {
734 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 730 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0;
735 if ( p && p->isSplitter ) 731 if ( p && p->isSplitter )
736 if ( first || s->wid->isHidden() ) 732 if ( first || s->wid->isHidden() )
737 p->wid->hide(); //may trigger new recalc 733 p->wid->hide(); //may trigger new recalc
738 else 734 else
739 p->wid->show(); //may trigger new recalc 735 p->wid->show(); //may trigger new recalc
740 if ( !s->wid->isHidden() ) 736 if ( !s->wid->isHidden() )
741 first = FALSE; 737 first = FALSE;
742 } 738 }
743 } 739 }
744 740
745 bool empty=TRUE; 741 bool empty=TRUE;
746 for ( int j = 0; j< n; j++ ) { 742 for ( int j = 0; j< n; j++ ) {
747 QSplitterLayoutStruct *s = data->list.at(j); 743 QSplitterLayoutStruct *s = data->list.at(j);
748 if ( !s->wid->isHidden() ) { 744 if ( !s->wid->isHidden() ) {
749 empty = FALSE; 745 empty = FALSE;
750 if ( s->isSplitter ) { 746 if ( s->isSplitter ) {
751 minl += s->sizer; 747 minl += s->sizer;
752 maxl += s->sizer; 748 maxl += s->sizer;
753 } else { 749 } else {
754 QSize minS = minSize(s->wid); 750 QSize minS = minSize(s->wid);
755 minl += pick( minS ); 751 minl += pick( minS );
756 maxl += pick( s->wid->maximumSize() ); 752 maxl += pick( s->wid->maximumSize() );
757 mint = QMAX( mint, trans( minS )); 753 mint = QMAX( mint, trans( minS ));
758 int tm = trans( s->wid->maximumSize() ); 754 int tm = trans( s->wid->maximumSize() );
759 if ( tm > 0 ) 755 if ( tm > 0 )
760 maxt = QMIN( maxt, tm ); 756 maxt = QMIN( maxt, tm );
761 } 757 }
762 } 758 }
763 } 759 }
764 if ( empty ) 760 if ( empty )
765 maxl = maxt = 0; 761 maxl = maxt = 0;
766 else 762 else
767 maxl = QMIN( maxl, QWIDGETSIZE_MAX ); 763 maxl = QMIN( maxl, QWIDGETSIZE_MAX );
768 if ( maxt < mint ) 764 if ( maxt < mint )
769 maxt = mint; 765 maxt = mint;
770 766
771 if ( orient == Horizontal ) { 767 if ( orient == Horizontal ) {
772 setMaximumSize( maxl, maxt ); 768 setMaximumSize( maxl, maxt );
773 setMinimumSize( minl, mint ); 769 setMinimumSize( minl, mint );
774 } else { 770 } else {
775 setMaximumSize( maxt, maxl ); 771 setMaximumSize( maxt, maxl );
776 setMinimumSize( mint, minl ); 772 setMinimumSize( mint, minl );
777 } 773 }
778 if ( update ) 774 if ( update )
779 doResize(); 775 doResize();
780} 776}
781 777
782/*! \enum QSplitter::ResizeMode 778/*! \enum QSplitter::ResizeMode
783 779
784 This enum type describes how QSplitter will resize each of its child widgets. The currently defined values are: <ul> 780 This enum type describes how QSplitter will resize each of its child widgets. The currently defined values are: <ul>
785 781
786 <li> \c Stretch - the widget will be resized when the splitter 782 <li> \c Stretch - the widget will be resized when the splitter
787 itself is resized. 783 itself is resized.
788 784
789 <li> \c KeepSize - QSplitter will try to keep this widget's size 785 <li> \c KeepSize - QSplitter will try to keep this widget's size
790 unchanged. 786 unchanged.
791 787
792 <li> \c FollowSizeHint - QSplitter will resize the widget when its 788 <li> \c FollowSizeHint - QSplitter will resize the widget when its
793 size hint changes. 789 size hint changes.
794 790
795 </ul> 791 </ul>
796 792
797*/ 793*/
798 794
799/*! 795/*!
800 Sets resize mode of \a w to \a mode. 796 Sets resize mode of \a w to \a mode.
801 797
802 \sa ResizeMode 798 \sa ResizeMode
803*/ 799*/
804 800
805void QSplitter::setResizeMode( QWidget *w, ResizeMode mode ) 801void QSplitter::setResizeMode( QWidget *w, ResizeMode mode )
806{ 802{
807 processChildEvents(); 803 processChildEvents();
808 QSplitterLayoutStruct *s = data->list.first(); 804 QSplitterLayoutStruct *s = data->list.first();
809 while ( s ) { 805 while ( s ) {
810 if ( s->wid == w ) { 806 if ( s->wid == w ) {
811 s->mode = mode; 807 s->mode = mode;
812 return; 808 return;
813 } 809 }
814 s = data->list.next(); 810 s = data->list.next();
815 } 811 }
816 s = addWidget( w, TRUE ); 812 s = addWidget( w, TRUE );
817 s->mode = mode; 813 s->mode = mode;
818} 814}
819 815
820 816
821/*! 817/*!
822 Returns TRUE if opaque resize is on, FALSE otherwise. 818 Returns TRUE if opaque resize is on, FALSE otherwise.
823 819
824 \sa setOpaqueResize() 820 \sa setOpaqueResize()
825*/ 821*/
826 822
827bool QSplitter::opaqueResize() const 823bool QSplitter::opaqueResize() const
828{ 824{
829 return data->opaque; 825 return data->opaque;
830} 826}
831 827
832 828
833/*! 829/*!
834 Sets opaque resize to \a on. Opaque resize is initially turned off. 830 Sets opaque resize to \a on. Opaque resize is initially turned off.
835 831
836 \sa opaqueResize() 832 \sa opaqueResize()
837*/ 833*/
838 834
839void QSplitter::setOpaqueResize( bool on ) 835void QSplitter::setOpaqueResize( bool on )
840{ 836{
841 data->opaque = on; 837 data->opaque = on;
842} 838}
843 839
844 840
845/*! 841/*!
846 Moves \a w to the leftmost/top position. 842 Moves \a w to the leftmost/top position.
847*/ 843*/
848 844
849void QSplitter::moveToFirst( QWidget *w ) 845void QSplitter::moveToFirst( QWidget *w )
850{ 846{
851 processChildEvents(); 847 processChildEvents();
852 bool found = FALSE; 848 bool found = FALSE;
853 QSplitterLayoutStruct *s = data->list.first(); 849 QSplitterLayoutStruct *s = data->list.first();
854 while ( s ) { 850 while ( s ) {
855 if ( s->wid == w ) { 851 if ( s->wid == w ) {
856 found = TRUE; 852 found = TRUE;
857 QSplitterLayoutStruct *p = data->list.prev(); 853 QSplitterLayoutStruct *p = data->list.prev();
858 if ( p ) { // not already at first place 854 if ( p ) { // not already at first place
859 data->list.take(); //take p 855 data->list.take(); //take p
860 data->list.take(); // take s 856 data->list.take(); // take s
861 data->list.insert( 0, p ); 857 data->list.insert( 0, p );
862 data->list.insert( 0, s ); 858 data->list.insert( 0, s );
863 } 859 }
864 break; 860 break;
865 } 861 }
866 s = data->list.next(); 862 s = data->list.next();
867 } 863 }
868 if ( !found ) 864 if ( !found )
869 addWidget( w, TRUE ); 865 addWidget( w, TRUE );
870 recalcId(); 866 recalcId();
871} 867}
872 868
873 869
874/*! 870/*!
875 Moves \a w to the rightmost/bottom position. 871 Moves \a w to the rightmost/bottom position.
876*/ 872*/
877 873
878void QSplitter::moveToLast( QWidget *w ) 874void QSplitter::moveToLast( QWidget *w )
879{ 875{
880 processChildEvents(); 876 processChildEvents();
881 bool found = FALSE; 877 bool found = FALSE;
882 QSplitterLayoutStruct *s = data->list.first(); 878 QSplitterLayoutStruct *s = data->list.first();
883 while ( s ) { 879 while ( s ) {
884 if ( s->wid == w ) { 880 if ( s->wid == w ) {
885 found = TRUE; 881 found = TRUE;
886 data->list.take(); // take s 882 data->list.take(); // take s
887 QSplitterLayoutStruct *p = data->list.current(); 883 QSplitterLayoutStruct *p = data->list.current();
888 if ( p ) { // the splitter handle after s 884 if ( p ) { // the splitter handle after s
889 data->list.take(); //take p 885 data->list.take(); //take p
890 data->list.append( p ); 886 data->list.append( p );
891 } 887 }
892 data->list.append( s ); 888 data->list.append( s );
893 break; 889 break;
894 } 890 }
895 s = data->list.next(); 891 s = data->list.next();
896 } 892 }
897 if ( !found ) 893 if ( !found )
898 addWidget( w); 894 addWidget( w);
899 recalcId(); 895 recalcId();
900} 896}
901 897
902 898
903void QSplitter::recalcId() 899void QSplitter::recalcId()
904{ 900{
905 int n = data->list.count(); 901 int n = data->list.count();
906 for ( int i = 0; i < n; i++ ) { 902 for ( int i = 0; i < n; i++ ) {
907 QSplitterLayoutStruct *s = data->list.at(i); 903 QSplitterLayoutStruct *s = data->list.at(i);
908 if ( s->isSplitter ) 904 if ( s->isSplitter )
909 ((QSplitterHandle*)s->wid)->setId(i); 905 ((QSplitterHandle*)s->wid)->setId(i);
910 } 906 }
911} 907}
912 908
913 909
914/*!\reimp 910/*!\reimp
915*/ 911*/
916QSize QSplitter::sizeHint() const 912QSize QSplitter::sizeHint() const
917{ 913{
918 constPolish(); 914 constPolish();
919 int l = 0; 915 int l = 0;
920 int t = 0; 916 int t = 0;
921 if ( children() ) { 917 if ( children() ) {
922 const QObjectList * c = children(); 918 const QObjectList * c = children();
923 QObjectListIt it( *c ); 919 QObjectListIt it( *c );
924 QObject * o; 920 QObject * o;
925 921
926 while( (o=it.current()) != 0 ) { 922 while( (o=it.current()) != 0 ) {
927 ++it; 923 ++it;
928 if ( o->isWidgetType() && 924 if ( o->isWidgetType() &&
929 !((QWidget*)o)->isHidden() ) { 925 !((QWidget*)o)->isHidden() ) {
930 QSize s = ((QWidget*)o)->sizeHint(); 926 QSize s = ((QWidget*)o)->sizeHint();
931 if ( s.isValid() ) { 927 if ( s.isValid() ) {
932 l += pick( s ); 928 l += pick( s );
933 t = QMAX( t, trans( s ) ); 929 t = QMAX( t, trans( s ) );
934 } 930 }
935 } 931 }
936 } 932 }
937 } 933 }
938 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 934 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
939} 935}
940 936
941 937
942/*! 938/*!
943\reimp 939\reimp
944*/ 940*/
945 941
946QSize QSplitter::minimumSizeHint() const 942QSize QSplitter::minimumSizeHint() const
947{ 943{
948 constPolish(); 944 constPolish();
949 int l = 0; 945 int l = 0;
950 int t = 0; 946 int t = 0;
951 if ( children() ) { 947 if ( children() ) {
952 const QObjectList * c = children(); 948 const QObjectList * c = children();
953 QObjectListIt it( *c ); 949 QObjectListIt it( *c );
954 QObject * o; 950 QObject * o;
955 951
956 while( (o=it.current()) != 0 ) { 952 while( (o=it.current()) != 0 ) {
957 ++it; 953 ++it;
958 if ( o->isWidgetType() && 954 if ( o->isWidgetType() &&
959 !((QWidget*)o)->isHidden() ) { 955 !((QWidget*)o)->isHidden() ) {
960 QSize s = minSize((QWidget*)o); 956 QSize s = minSize((QWidget*)o);
961 if ( s.isValid() ) { 957 if ( s.isValid() ) {
962 l += pick( s ); 958 l += pick( s );
963 t = QMAX( t, trans( s ) ); 959 t = QMAX( t, trans( s ) );
964 } 960 }
965 } 961 }
966 } 962 }
967 } 963 }
968 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 964 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
969} 965}
970 966
971 967
972 968
973/*!\reimp 969/*!\reimp
974*/ 970*/
975QSizePolicy QSplitter::sizePolicy() const 971QSizePolicy QSplitter::sizePolicy() const
976{ 972{
977 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); 973 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
978} 974}
979 975
980 976
981/*! 977/*!
982 Calculates stretch parameters from current sizes 978 Calculates stretch parameters from current sizes
983*/ 979*/
984 980
985void QSplitter::storeSizes() 981void QSplitter::storeSizes()
986{ 982{
987 QSplitterLayoutStruct *s = data->list.first(); 983 QSplitterLayoutStruct *s = data->list.first();
988 while ( s ) { 984 while ( s ) {
989 if ( !s->isSplitter ) 985 if ( !s->isSplitter )
990 s->sizer = pick( s->wid->size() ); 986 s->sizer = pick( s->wid->size() );
991 s = data->list.next(); 987 s = data->list.next();
992 } 988 }
993} 989}
994 990
995 991
996#if 0 // ### remove this code ASAP 992#if 0 // ### remove this code ASAP
997 993
998/*! 994/*!
999 Hides \a w if \a hide is TRUE, and updates the splitter. 995 Hides \a w if \a hide is TRUE, and updates the splitter.
1000 996
1001 \warning Due to a limitation in the current implementation, 997 \warning Due to a limitation in the current implementation,
1002 calling QWidget::hide() will not work. 998 calling QWidget::hide() will not work.
1003*/ 999*/
1004 1000
1005void QSplitter::setHidden( QWidget *w, bool hide ) 1001void QSplitter::setHidden( QWidget *w, bool hide )
1006{ 1002{
1007 if ( w == w1 ) { 1003 if ( w == w1 ) {
1008 w1show = !hide; 1004 w1show = !hide;
1009 } else if ( w == w2 ) { 1005 } else if ( w == w2 ) {
1010 w2show = !hide; 1006 w2show = !hide;
1011 } else { 1007 } else {
1012#ifdef CHECK_RANGE 1008#ifdef CHECK_RANGE
1013 qWarning( "QSplitter::setHidden(), unknown widget" ); 1009 qWarning( "QSplitter::setHidden(), unknown widget" );
1014#endif 1010#endif
1015 return; 1011 return;
1016 } 1012 }
1017 if ( hide ) 1013 if ( hide )
1018 w->hide(); 1014 w->hide();
1019 else 1015 else
1020 w->show(); 1016 w->show();
1021 recalc( TRUE ); 1017 recalc( TRUE );
1022} 1018}
1023 1019
1024 1020
1025/*! 1021/*!
1026 Returns the hidden status of \a w 1022 Returns the hidden status of \a w
1027*/ 1023*/
1028 1024
1029bool QSplitter::isHidden( QWidget *w ) const 1025bool QSplitter::isHidden( QWidget *w ) const
1030{ 1026{
1031 if ( w == w1 ) 1027 if ( w == w1 )
1032 return !w1show; 1028 return !w1show;
1033 else if ( w == w2 ) 1029 else if ( w == w2 )
1034 return !w2show; 1030 return !w2show;
1035#ifdef CHECK_RANGE 1031#ifdef CHECK_RANGE
1036 else 1032 else
1037 qWarning( "QSplitter::isHidden(), unknown widget" ); 1033 qWarning( "QSplitter::isHidden(), unknown widget" );
1038#endif 1034#endif
1039 return FALSE; 1035 return FALSE;
1040} 1036}
1041#endif 1037#endif
1042 1038
1043 1039
1044/*! 1040/*!
1045 Returns a list of the size parameters of all the widgets in this 1041 Returns a list of the size parameters of all the widgets in this
1046 splitter. 1042 splitter.
1047 1043
1048 Giving the values to setSizes() will give a splitter with the same 1044 Giving the values to setSizes() will give a splitter with the same
1049 layout as this one. 1045 layout as this one.
1050 1046
1051 \sa setSizes() 1047 \sa setSizes()
1052*/ 1048*/
1053 1049
1054QValueList<int> QSplitter::sizes() const 1050QValueList<int> QSplitter::sizes() const
1055{ 1051{
1056 if ( !testWState(WState_Polished) ) { 1052 if ( !testWState(WState_Polished) ) {
1057 QWidget* that = (QWidget*) this; 1053 QWidget* that = (QWidget*) this;
1058 that->polish(); 1054 that->polish();
1059 } 1055 }
1060 QValueList<int> list; 1056 QValueList<int> list;
1061 QSplitterLayoutStruct *s = data->list.first(); 1057 QSplitterLayoutStruct *s = data->list.first();
1062 while ( s ) { 1058 while ( s ) {
1063 if ( !s->isSplitter ) 1059 if ( !s->isSplitter )
1064 list.append( s->sizer ); 1060 list.append( s->sizer );
1065 s = data->list.next(); 1061 s = data->list.next();
1066 } 1062 }
1067 return list; 1063 return list;
1068} 1064}
1069 1065
1070 1066
1071 1067
1072/*! 1068/*!
1073 Sets the size parameters to the values given in \a list. 1069 Sets the size parameters to the values given in \a list.
1074 If the splitter is horizontal, the values set the sizes from 1070 If the splitter is horizontal, the values set the sizes from
1075 left to right. If it is vertical, the sizes are applied from 1071 left to right. If it is vertical, the sizes are applied from
1076 top to bottom. 1072 top to bottom.
1077 Extra values in \a list are ignored. 1073 Extra values in \a list are ignored.
1078 1074
1079 If \a list contains too few values, the result is undefined 1075 If \a list contains too few values, the result is undefined
1080 but the program will still be well-behaved. 1076 but the program will still be well-behaved.
1081 1077
1082 \sa sizes() 1078 \sa sizes()
1083*/ 1079*/
1084 1080
1085void QSplitter::setSizes( QValueList<int> list ) 1081void QSplitter::setSizes( QValueList<int> list )
1086{ 1082{
1087 processChildEvents(); 1083 processChildEvents();
1088 QValueList<int>::Iterator it = list.begin(); 1084 QValueList<int>::Iterator it = list.begin();
1089 QSplitterLayoutStruct *s = data->list.first(); 1085 QSplitterLayoutStruct *s = data->list.first();
1090 while ( s && it != list.end() ) { 1086 while ( s && it != list.end() ) {
1091 if ( !s->isSplitter ) { 1087 if ( !s->isSplitter ) {
1092 s->sizer = *it; 1088 s->sizer = *it;
1093 ++it; 1089 ++it;
1094 } 1090 }
1095 s = data->list.next(); 1091 s = data->list.next();
1096 } 1092 }
1097 doResize(); 1093 doResize();
1098} 1094}
1099 1095
1100 1096
1101/*! 1097/*!
1102 Gets all posted child events, ensuring that the internal state of 1098 Gets all posted child events, ensuring that the internal state of
1103 the splitter is consistent with the programmer's idea. 1099 the splitter is consistent with the programmer's idea.
1104*/ 1100*/
1105 1101
1106void QSplitter::processChildEvents() 1102void QSplitter::processChildEvents()
1107{ 1103{
1108 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1104 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1109} 1105}
1110 1106
1111 1107
1112/*! 1108/*!
1113 \reimp 1109 \reimp
1114*/ 1110*/
1115 1111
1116void QSplitter::styleChange( QStyle& old ) 1112void QSplitter::styleChange( QStyle& old )
1117{ 1113{
1118 int sw = style().splitterWidth(); 1114 int sw = style().splitterWidth();
1119 QSplitterLayoutStruct *s = data->list.first(); 1115 QSplitterLayoutStruct *s = data->list.first();
1120 while ( s ) { 1116 while ( s ) {
1121 if ( s->isSplitter ) 1117 if ( s->isSplitter )
1122 s->sizer = sw; 1118 s->sizer = sw;
1123 s = data->list.next(); 1119 s = data->list.next();
1124 } 1120 }
1125 doResize(); 1121 doResize();
1126 QFrame::styleChange( old ); 1122 QFrame::styleChange( old );
1127} 1123}
1128 1124