summaryrefslogtreecommitdiff
authorzecke <zecke>2003-04-13 16:57:28 (UTC)
committer zecke <zecke>2003-04-13 16:57:28 (UTC)
commit0b311079ff19798866291034663757103c6ba935 (patch) (unidiff)
tree70ddccf3a3147475050fa06cc2d807a71ab1d5ee
parent1537ccb435ca725c793db6e94e0b9e83484b57e7 (diff)
downloadopie-0b311079ff19798866291034663757103c6ba935.zip
opie-0b311079ff19798866291034663757103c6ba935.tar.gz
opie-0b311079ff19798866291034663757103c6ba935.tar.bz2
Jumbo API documentation update
and some API fixed ColorDialog is now OColorDialog!!! keep the namespace tidy! ColorPopupMenu is now OColorPopupMenu!!! keep the namespace tidy ColorDialog TT couldn't break bc we can so make it const QColor& OTimePicker add some convience methods more I might have forgot
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/colordialog.cpp17
-rw-r--r--libopie/colordialog.h6
-rw-r--r--libopie/colorpopupmenu.cpp32
-rw-r--r--libopie/colorpopupmenu.h36
-rw-r--r--libopie/ocheckitem.cpp31
-rw-r--r--libopie/ocheckitem.h14
-rw-r--r--libopie/oclickablelabel.cpp33
-rw-r--r--libopie/oclickablelabel.h35
-rw-r--r--libopie/ocolorbutton.cpp45
-rw-r--r--libopie/ocolorbutton.h15
-rw-r--r--libopie/odevice.cpp108
-rw-r--r--libopie/odevice.h63
-rw-r--r--libopie/odevicebutton.h4
-rw-r--r--libopie/ofiledialog.cc40
-rw-r--r--libopie/ofiledialog.h23
-rw-r--r--libopie/ofileselector.h2
-rw-r--r--libopie/ofontmenu.cc46
-rw-r--r--libopie/ofontmenu.h44
-rw-r--r--libopie/ofontselector.cpp132
-rw-r--r--libopie/ofontselector.h23
-rw-r--r--libopie/orecurrancewidget.cpp46
-rw-r--r--libopie/orecurrancewidget.h12
-rw-r--r--libopie/otabbar.h1
-rw-r--r--libopie/otabwidget.h2
-rw-r--r--libopie/oticker.h10
-rw-r--r--libopie/otimepicker.cpp86
-rw-r--r--libopie/otimepicker.h34
-rw-r--r--libopie/owait.cpp12
-rw-r--r--libopie/owait.h13
-rw-r--r--libopie/todayconfigwidget.h18
-rw-r--r--libopie/todayplugininterface.h23
31 files changed, 832 insertions, 174 deletions
diff --git a/libopie/colordialog.cpp b/libopie/colordialog.cpp
index 684d6ea..35f15d6 100644
--- a/libopie/colordialog.cpp
+++ b/libopie/colordialog.cpp
@@ -1,851 +1,858 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of OColorDialog class 4** Implementation of OColorDialog 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 "colordialog.h" 38#include "colordialog.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" 49#include "qdragobject.h"
50#include "qapplication.h" 50#include "qapplication.h"
51#include "qdragobject.h" 51#include "qdragobject.h"
52 52
53static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v ) 53static inline void rgb2hsv( QRgb rgb, int&h, int&s, int&v )
54{ 54{
55 QColor c; 55 QColor c;
56 c.setRgb( rgb ); 56 c.setRgb( rgb );
57 c.getHsv(h,s,v); 57 c.getHsv(h,s,v);
58} 58}
59 59
60/*
61 * avoid clashes with the original Qt
62 */
63namespace {
64
60class QColorPicker : public QFrame 65class QColorPicker : public QFrame
61{ 66{
62 Q_OBJECT 67 Q_OBJECT
63public: 68public:
64 QColorPicker(QWidget* parent=0, const char* name=0); 69 QColorPicker(QWidget* parent=0, const char* name=0);
65 ~QColorPicker(); 70 ~QColorPicker();
66 71
67public slots: 72public slots:
68 void setCol( int h, int s ); 73 void setCol( int h, int s );
69 74
70signals: 75signals:
71 void newCol( int h, int s ); 76 void newCol( int h, int s );
72 77
73protected: 78protected:
74 QSize sizeHint() const; 79 QSize sizeHint() const;
75 QSizePolicy sizePolicy() const; 80 QSizePolicy sizePolicy() const;
76 void drawContents(QPainter* p); 81 void drawContents(QPainter* p);
77 void mouseMoveEvent( QMouseEvent * ); 82 void mouseMoveEvent( QMouseEvent * );
78 void mousePressEvent( QMouseEvent * ); 83 void mousePressEvent( QMouseEvent * );
79 84
80private: 85private:
81 int hue; 86 int hue;
82 int sat; 87 int sat;
83 88
84 QPoint colPt(); 89 QPoint colPt();
85 int huePt( const QPoint &pt ); 90 int huePt( const QPoint &pt );
86 int satPt( const QPoint &pt ); 91 int satPt( const QPoint &pt );
87 void setCol( const QPoint &pt ); 92 void setCol( const QPoint &pt );
88 93
89 QPixmap *pix; 94 QPixmap *pix;
90}; 95};
91 96
92static int pWidth = 200; 97static int pWidth = 200;
93static int pHeight = 200; 98static int pHeight = 200;
94 99
95class QColorLuminancePicker : public QWidget 100class QColorLuminancePicker : public QWidget
96{ 101{
97 Q_OBJECT 102 Q_OBJECT
98public: 103public:
99 QColorLuminancePicker(QWidget* parent=0, const char* name=0); 104 QColorLuminancePicker(QWidget* parent=0, const char* name=0);
100 ~QColorLuminancePicker(); 105 ~QColorLuminancePicker();
101 106
102public slots: 107public slots:
103 void setCol( int h, int s, int v ); 108 void setCol( int h, int s, int v );
104 void setCol( int h, int s ); 109 void setCol( int h, int s );
105 110
106signals: 111signals:
107 void newHsv( int h, int s, int v ); 112 void newHsv( int h, int s, int v );
108 113
109protected: 114protected:
110// QSize sizeHint() const; 115// QSize sizeHint() const;
111// QSizePolicy sizePolicy() const; 116// QSizePolicy sizePolicy() const;
112 void paintEvent( QPaintEvent*); 117 void paintEvent( QPaintEvent*);
113 void mouseMoveEvent( QMouseEvent * ); 118 void mouseMoveEvent( QMouseEvent * );
114 void mousePressEvent( QMouseEvent * ); 119 void mousePressEvent( QMouseEvent * );
115 120
116private: 121private:
117 enum { foff = 3, coff = 4 }; //frame and contents offset 122 enum { foff = 3, coff = 4 }; //frame and contents offset
118 int val; 123 int val;
119 int hue; 124 int hue;
120 int sat; 125 int sat;
121 126
122 int y2val( int y ); 127 int y2val( int y );
123 int val2y( int val ); 128 int val2y( int val );
124 void setVal( int v ); 129 void setVal( int v );
125 130
126 QPixmap *pix; 131 QPixmap *pix;
127}; 132};
128 133
129 134
130int QColorLuminancePicker::y2val( int y ) 135int QColorLuminancePicker::y2val( int y )
131{ 136{
132 int d = height() - 2*coff - 1; 137 int d = height() - 2*coff - 1;
133 return 255 - (y - coff)*255/d; 138 return 255 - (y - coff)*255/d;
134} 139}
135 140
136int QColorLuminancePicker::val2y( int v ) 141int QColorLuminancePicker::val2y( int v )
137{ 142{
138 int d = height() - 2*coff - 1; 143 int d = height() - 2*coff - 1;
139 return coff + (255-v)*d/255; 144 return coff + (255-v)*d/255;
140} 145}
141 146
142QColorLuminancePicker::QColorLuminancePicker(QWidget* parent, 147QColorLuminancePicker::QColorLuminancePicker(QWidget* parent,
143 const char* name) 148 const char* name)
144 :QWidget( parent, name ) 149 :QWidget( parent, name )
145{ 150{
146 hue = 100; val = 100; sat = 100; 151 hue = 100; val = 100; sat = 100;
147 pix = 0; 152 pix = 0;
148 // setBackgroundMode( NoBackground ); 153 // setBackgroundMode( NoBackground );
149} 154}
150 155
151QColorLuminancePicker::~QColorLuminancePicker() 156QColorLuminancePicker::~QColorLuminancePicker()
152{ 157{
153 delete pix; 158 delete pix;
154} 159}
155 160
156void QColorLuminancePicker::mouseMoveEvent( QMouseEvent *m ) 161void QColorLuminancePicker::mouseMoveEvent( QMouseEvent *m )
157{ 162{
158 setVal( y2val(m->y()) ); 163 setVal( y2val(m->y()) );
159} 164}
160void QColorLuminancePicker::mousePressEvent( QMouseEvent *m ) 165void QColorLuminancePicker::mousePressEvent( QMouseEvent *m )
161{ 166{
162 setVal( y2val(m->y()) ); 167 setVal( y2val(m->y()) );
163} 168}
164 169
165void QColorLuminancePicker::setVal( int v ) 170void QColorLuminancePicker::setVal( int v )
166{ 171{
167 if ( val == v ) 172 if ( val == v )
168 return; 173 return;
169 val = QMAX( 0, QMIN(v,255)); 174 val = QMAX( 0, QMIN(v,255));
170 delete pix; pix=0; 175 delete pix; pix=0;
171 repaint( FALSE ); //### 176 repaint( FALSE ); //###
172 emit newHsv( hue, sat, val ); 177 emit newHsv( hue, sat, val );
173} 178}
174 179
175//receives from a hue,sat chooser and relays. 180//receives from a hue,sat chooser and relays.
176void QColorLuminancePicker::setCol( int h, int s ) 181void QColorLuminancePicker::setCol( int h, int s )
177{ 182{
178 setCol( h, s, val ); 183 setCol( h, s, val );
179 emit newHsv( h, s, val ); 184 emit newHsv( h, s, val );
180} 185}
181 186
182void QColorLuminancePicker::paintEvent( QPaintEvent * ) 187void QColorLuminancePicker::paintEvent( QPaintEvent * )
183{ 188{
184 int w = width() - 5; 189 int w = width() - 5;
185 190
186 QRect r( 0, foff, w, height() - 2*foff ); 191 QRect r( 0, foff, w, height() - 2*foff );
187 int wi = r.width() - 2; 192 int wi = r.width() - 2;
188 int hi = r.height() - 2; 193 int hi = r.height() - 2;
189 if ( !pix || pix->height() != hi || pix->width() != wi ) { 194 if ( !pix || pix->height() != hi || pix->width() != wi ) {
190 delete pix; 195 delete pix;
191 QImage img( wi, hi, 32 ); 196 QImage img( wi, hi, 32 );
192 int y; 197 int y;
193 for ( y = 0; y < hi; y++ ) { 198 for ( y = 0; y < hi; y++ ) {
194 QColor c( hue, sat, y2val(y+coff), QColor::Hsv ); 199 QColor c( hue, sat, y2val(y+coff), QColor::Hsv );
195 QRgb r = c.rgb(); 200 QRgb r = c.rgb();
196 int x; 201 int x;
197 for ( x = 0; x < wi; x++ ) 202 for ( x = 0; x < wi; x++ )
198 img.setPixel( x, y, r ); 203 img.setPixel( x, y, r );
199 } 204 }
200 pix = new QPixmap; 205 pix = new QPixmap;
201 pix->convertFromImage(img); 206 pix->convertFromImage(img);
202 } 207 }
203 QPainter p(this); 208 QPainter p(this);
204 p.drawPixmap( 1, coff, *pix ); 209 p.drawPixmap( 1, coff, *pix );
205 QColorGroup g = colorGroup(); 210 QColorGroup g = colorGroup();
206 qDrawShadePanel( &p, r, g, TRUE ); 211 qDrawShadePanel( &p, r, g, TRUE );
207 p.setPen( g.foreground() ); 212 p.setPen( g.foreground() );
208 p.setBrush( g.foreground() ); 213 p.setBrush( g.foreground() );
209 QPointArray a; 214 QPointArray a;
210 int y = val2y(val); 215 int y = val2y(val);
211 a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 ); 216 a.setPoints( 3, w, y, w+5, y+5, w+5, y-5 );
212 erase( w, 0, 5, height() ); 217 erase( w, 0, 5, height() );
213 p.drawPolygon( a ); 218 p.drawPolygon( a );
214} 219}
215 220
216void QColorLuminancePicker::setCol( int h, int s , int v ) 221void QColorLuminancePicker::setCol( int h, int s , int v )
217{ 222{
218 val = v; 223 val = v;
219 hue = h; 224 hue = h;
220 sat = s; 225 sat = s;
221 delete pix; pix=0; 226 delete pix; pix=0;
222 repaint( FALSE );//#### 227 repaint( FALSE );//####
223} 228}
224 229
225QPoint QColorPicker::colPt() 230QPoint QColorPicker::colPt()
226{ return QPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); } 231{ return QPoint( (360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255 ); }
227int QColorPicker::huePt( const QPoint &pt ) 232int QColorPicker::huePt( const QPoint &pt )
228{ return 360 - pt.x()*360/(pWidth-1); } 233{ return 360 - pt.x()*360/(pWidth-1); }
229int QColorPicker::satPt( const QPoint &pt ) 234int QColorPicker::satPt( const QPoint &pt )
230{ return 255 - pt.y()*255/(pHeight-1) ; } 235{ return 255 - pt.y()*255/(pHeight-1) ; }
231void QColorPicker::setCol( const QPoint &pt ) 236void QColorPicker::setCol( const QPoint &pt )
232{ setCol( huePt(pt), satPt(pt) ); } 237{ setCol( huePt(pt), satPt(pt) ); }
233 238
234QColorPicker::QColorPicker(QWidget* parent, const char* name ) 239QColorPicker::QColorPicker(QWidget* parent, const char* name )
235 : QFrame( parent, name ) 240 : QFrame( parent, name )
236{ 241{
237 hue = 0; sat = 0; 242 hue = 0; sat = 0;
238 setCol( 150, 255 ); 243 setCol( 150, 255 );
239 244
240 QImage img( pWidth, pHeight, 32 ); 245 QImage img( pWidth, pHeight, 32 );
241 int x,y; 246 int x,y;
242 for ( y = 0; y < pHeight; y++ ) 247 for ( y = 0; y < pHeight; y++ )
243 for ( x = 0; x < pWidth; x++ ) { 248 for ( x = 0; x < pWidth; x++ ) {
244 QPoint p( x, y ); 249 QPoint p( x, y );
245 img.setPixel( x, y, QColor(huePt(p), satPt(p), 250 img.setPixel( x, y, QColor(huePt(p), satPt(p),
246 200, QColor::Hsv).rgb() ); 251 200, QColor::Hsv).rgb() );
247 } 252 }
248 pix = new QPixmap; 253 pix = new QPixmap;
249 pix->convertFromImage(img); 254 pix->convertFromImage(img);
250 setBackgroundMode( NoBackground ); 255 setBackgroundMode( NoBackground );
251} 256}
252 257
253QColorPicker::~QColorPicker() 258QColorPicker::~QColorPicker()
254{ 259{
255 delete pix; 260 delete pix;
256} 261}
257 262
258QSize QColorPicker::sizeHint() const 263QSize QColorPicker::sizeHint() const
259{ 264{
260 return QSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() ); 265 return QSize( pWidth + 2*frameWidth(), pHeight + 2*frameWidth() );
261} 266}
262 267
263QSizePolicy QColorPicker::sizePolicy() const 268QSizePolicy QColorPicker::sizePolicy() const
264{ 269{
265 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); 270 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
266} 271}
267 272
268void QColorPicker::setCol( int h, int s ) 273void QColorPicker::setCol( int h, int s )
269{ 274{
270 int nhue = QMIN( QMAX(0,h), 360 ); 275 int nhue = QMIN( QMAX(0,h), 360 );
271 int nsat = QMIN( QMAX(0,s), 255); 276 int nsat = QMIN( QMAX(0,s), 255);
272 if ( nhue == hue && nsat == sat ) 277 if ( nhue == hue && nsat == sat )
273 return; 278 return;
274 QRect r( colPt(), QSize(20,20) ); 279 QRect r( colPt(), QSize(20,20) );
275 hue = nhue; sat = nsat; 280 hue = nhue; sat = nsat;
276 r = r.unite( QRect( colPt(), QSize(20,20) ) ); 281 r = r.unite( QRect( colPt(), QSize(20,20) ) );
277 r.moveBy( contentsRect().x()-9, contentsRect().y()-9 ); 282 r.moveBy( contentsRect().x()-9, contentsRect().y()-9 );
278 // update( r ); 283 // update( r );
279 repaint( r, FALSE ); 284 repaint( r, FALSE );
280} 285}
281 286
282void QColorPicker::mouseMoveEvent( QMouseEvent *m ) 287void QColorPicker::mouseMoveEvent( QMouseEvent *m )
283{ 288{
284 QPoint p = m->pos() - contentsRect().topLeft(); 289 QPoint p = m->pos() - contentsRect().topLeft();
285 setCol( p ); 290 setCol( p );
286 emit newCol( hue, sat ); 291 emit newCol( hue, sat );
287} 292}
288 293
289void QColorPicker::mousePressEvent( QMouseEvent *m ) 294void QColorPicker::mousePressEvent( QMouseEvent *m )
290{ 295{
291 QPoint p = m->pos() - contentsRect().topLeft(); 296 QPoint p = m->pos() - contentsRect().topLeft();
292 setCol( p ); 297 setCol( p );
293 emit newCol( hue, sat ); 298 emit newCol( hue, sat );
294} 299}
295 300
296void QColorPicker::drawContents(QPainter* p) 301void QColorPicker::drawContents(QPainter* p)
297{ 302{
298 QRect r = contentsRect(); 303 QRect r = contentsRect();
299 304
300 p->drawPixmap( r.topLeft(), *pix ); 305 p->drawPixmap( r.topLeft(), *pix );
301 QPoint pt = colPt() + r.topLeft(); 306 QPoint pt = colPt() + r.topLeft();
302 p->setPen( QPen(black) ); 307 p->setPen( QPen(black) );
303 308
304 p->fillRect( pt.x()-9, pt.y(), 20, 2, black ); 309 p->fillRect( pt.x()-9, pt.y(), 20, 2, black );
305 p->fillRect( pt.x(), pt.y()-9, 2, 20, black ); 310 p->fillRect( pt.x(), pt.y()-9, 2, 20, black );
306 311
307} 312}
308 313
309class QColorShowLabel; 314class QColorShowLabel;
310 315
311 316
312 317
313class QColIntValidator: public QIntValidator 318class QColIntValidator: public QIntValidator
314{ 319{
315public: 320public:
316 QColIntValidator( int bottom, int top, 321 QColIntValidator( int bottom, int top,
317 QWidget * parent, const char *name = 0 ) 322 QWidget * parent, const char *name = 0 )
318 :QIntValidator( bottom, top, parent, name ) {} 323 :QIntValidator( bottom, top, parent, name ) {}
319 324
320 QValidator::State validate( QString &, int & ) const; 325 QValidator::State validate( QString &, int & ) const;
321}; 326};
322 327
323QValidator::State QColIntValidator::validate( QString &s, int &pos ) const 328QValidator::State QColIntValidator::validate( QString &s, int &pos ) const
324{ 329{
325 State state = QIntValidator::validate(s,pos); 330 State state = QIntValidator::validate(s,pos);
326 if ( state == Valid ) { 331 if ( state == Valid ) {
327 long int val = s.toLong(); 332 long int val = s.toLong();
328 // This is not a general solution, assumes that top() > 0 and 333 // This is not a general solution, assumes that top() > 0 and
329 // bottom >= 0 334 // bottom >= 0
330 if ( val < 0 ) { 335 if ( val < 0 ) {
331 s = "0"; 336 s = "0";
332 pos = 1; 337 pos = 1;
333 } else if ( val > top() ) { 338 } else if ( val > top() ) {
334 s.setNum( top() ); 339 s.setNum( top() );
335 pos = s.length(); 340 pos = s.length();
336 } 341 }
337 } 342 }
338 return state; 343 return state;
339} 344}
340 345
341 346
342 347
343class QColNumLineEdit : public QLineEdit 348class QColNumLineEdit : public QLineEdit
344{ 349{
345public: 350public:
346 QColNumLineEdit( QWidget *parent, const char* name = 0 ) 351 QColNumLineEdit( QWidget *parent, const char* name = 0 )
347 : QLineEdit( parent, name ) { setMaxLength( 3 );} 352 : QLineEdit( parent, name ) { setMaxLength( 3 );}
348 QSize sizeHint() const { 353 QSize sizeHint() const {
349 return QSize( 30, //##### 354 return QSize( 30, //#####
350 QLineEdit::sizeHint().height() ); } 355 QLineEdit::sizeHint().height() ); }
351 void setNum( int i ) { 356 void setNum( int i ) {
352 QString s; 357 QString s;
353 s.setNum(i); 358 s.setNum(i);
354 bool block = signalsBlocked(); 359 bool block = signalsBlocked();
355 blockSignals(TRUE); 360 blockSignals(TRUE);
356 setText( s ); 361 setText( s );
357 blockSignals(block); 362 blockSignals(block);
358 } 363 }
359 int val() const { return text().toInt(); } 364 int val() const { return text().toInt(); }
360}; 365};
361 366
362 367
363class QColorShower : public QWidget 368class QColorShower : public QWidget
364{ 369{
365 Q_OBJECT 370 Q_OBJECT
366public: 371public:
367 QColorShower( QWidget *parent, const char *name = 0 ); 372 QColorShower( QWidget *parent, const char *name = 0 );
368 373
369 //things that don't emit signals 374 //things that don't emit signals
370 void setHsv( int h, int s, int v ); 375 void setHsv( int h, int s, int v );
371 376
372 int currentAlpha() const { return alphaEd->val(); } 377 int currentAlpha() const { return alphaEd->val(); }
373 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); } 378 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
374 void showAlpha( bool b ); 379 void showAlpha( bool b );
375 380
376 381
377 QRgb currentColor() const { return curCol; } 382 QRgb currentColor() const { return curCol; }
378 383
379public slots: 384public slots:
380 void setRgb( QRgb rgb ); 385 void setRgb( QRgb rgb );
381 386
382signals: 387signals:
383 void newCol( QRgb rgb ); 388 void newCol( QRgb rgb );
384private slots: 389private slots:
385 void rgbEd(); 390 void rgbEd();
386 void hsvEd(); 391 void hsvEd();
387private: 392private:
388 void showCurrentColor(); 393 void showCurrentColor();
389 int hue, sat, val; 394 int hue, sat, val;
390 QRgb curCol; 395 QRgb curCol;
391 QColNumLineEdit *hEd; 396 QColNumLineEdit *hEd;
392 QColNumLineEdit *sEd; 397 QColNumLineEdit *sEd;
393 QColNumLineEdit *vEd; 398 QColNumLineEdit *vEd;
394 QColNumLineEdit *rEd; 399 QColNumLineEdit *rEd;
395 QColNumLineEdit *gEd; 400 QColNumLineEdit *gEd;
396 QColNumLineEdit *bEd; 401 QColNumLineEdit *bEd;
397 QColNumLineEdit *alphaEd; 402 QColNumLineEdit *alphaEd;
398 QLabel *alphaLab; 403 QLabel *alphaLab;
399 QColorShowLabel *lab; 404 QColorShowLabel *lab;
400 bool rgbOriginal; 405 bool rgbOriginal;
401}; 406};
402 407
403class QColorShowLabel : public QFrame 408class QColorShowLabel : public QFrame
404{ 409{
405 Q_OBJECT 410 Q_OBJECT
406 411
407public: 412public:
408 QColorShowLabel( QWidget *parent ) :QFrame( parent ) { 413 QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
409 setFrameStyle( QFrame::Panel|QFrame::Sunken ); 414 setFrameStyle( QFrame::Panel|QFrame::Sunken );
410 setBackgroundMode( PaletteBackground ); 415 setBackgroundMode( PaletteBackground );
411 setAcceptDrops( TRUE ); 416 setAcceptDrops( TRUE );
412 mousePressed = FALSE; 417 mousePressed = FALSE;
413 } 418 }
414 void setColor( QColor c ) { col = c; } 419 void setColor( QColor c ) { col = c; }
415 420
416signals: 421signals:
417 void colorDropped( QRgb ); 422 void colorDropped( QRgb );
418 423
419protected: 424protected:
420 void drawContents( QPainter *p ); 425 void drawContents( QPainter *p );
421 void mousePressEvent( QMouseEvent *e ); 426 void mousePressEvent( QMouseEvent *e );
422 void mouseReleaseEvent( QMouseEvent *e ); 427 void mouseReleaseEvent( QMouseEvent *e );
423 428
424private: 429private:
425 QColor col; 430 QColor col;
426 bool mousePressed; 431 bool mousePressed;
427 QPoint pressPos; 432 QPoint pressPos;
428 433
429}; 434};
430 435
431void QColorShowLabel::drawContents( QPainter *p ) 436void QColorShowLabel::drawContents( QPainter *p )
432{ 437{
433 p->fillRect( contentsRect(), col ); 438 p->fillRect( contentsRect(), col );
434} 439}
435 440
436void QColorShower::showAlpha( bool b ) 441void QColorShower::showAlpha( bool b )
437{ 442{
438 if ( b ) { 443 if ( b ) {
439 alphaLab->show(); 444 alphaLab->show();
440 alphaEd->show(); 445 alphaEd->show();
441 } else { 446 } else {
442 alphaLab->hide(); 447 alphaLab->hide();
443 alphaEd->hide(); 448 alphaEd->hide();
444 } 449 }
445} 450}
446 451
447void QColorShowLabel::mousePressEvent( QMouseEvent *e ) 452void QColorShowLabel::mousePressEvent( QMouseEvent *e )
448{ 453{
449 mousePressed = TRUE; 454 mousePressed = TRUE;
450 pressPos = e->pos(); 455 pressPos = e->pos();
451} 456}
452 457
453void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) 458void QColorShowLabel::mouseReleaseEvent( QMouseEvent * )
454{ 459{
455 if ( !mousePressed ) 460 if ( !mousePressed )
456 return; 461 return;
457 mousePressed = FALSE; 462 mousePressed = FALSE;
458} 463}
459 464
460QColorShower::QColorShower( QWidget *parent, const char *name ) 465QColorShower::QColorShower( QWidget *parent, const char *name )
461 :QWidget( parent, name) 466 :QWidget( parent, name)
462{ 467{
463 curCol = qRgb( -1, -1, -1 ); 468 curCol = qRgb( -1, -1, -1 );
464 QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); 469 QColIntValidator *val256 = new QColIntValidator( 0, 255, this );
465 QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); 470 QColIntValidator *val360 = new QColIntValidator( 0, 360, this );
466 471
467 QGridLayout *gl = new QGridLayout( this, 1, 1, 2 ); 472 QGridLayout *gl = new QGridLayout( this, 1, 1, 2 );
468 gl->setMargin( 0 ); 473 gl->setMargin( 0 );
469 lab = new QColorShowLabel( this ); 474 lab = new QColorShowLabel( this );
470 lab->setMinimumWidth( 60 ); //### 475 lab->setMinimumWidth( 60 ); //###
471 gl->addMultiCellWidget(lab, 0,-1,0,0); 476 gl->addMultiCellWidget(lab, 0,-1,0,0);
472 connect( lab, SIGNAL( colorDropped( QRgb ) ), 477 connect( lab, SIGNAL( colorDropped( QRgb ) ),
473 this, SIGNAL( newCol( QRgb ) ) ); 478 this, SIGNAL( newCol( QRgb ) ) );
474 connect( lab, SIGNAL( colorDropped( QRgb ) ), 479 connect( lab, SIGNAL( colorDropped( QRgb ) ),
475 this, SLOT( setRgb( QRgb ) ) ); 480 this, SLOT( setRgb( QRgb ) ) );
476 481
477 hEd = new QColNumLineEdit( this ); 482 hEd = new QColNumLineEdit( this );
478 hEd->setValidator( val360 ); 483 hEd->setValidator( val360 );
479 QLabel *l = new QLabel( hEd, OColorDialog::tr("Hue:"), this ); 484 QLabel *l = new QLabel( hEd, OColorDialog::tr("Hue:"), this );
480 l->setAlignment( AlignRight|AlignVCenter ); 485 l->setAlignment( AlignRight|AlignVCenter );
481 gl->addWidget( l, 0, 1 ); 486 gl->addWidget( l, 0, 1 );
482 gl->addWidget( hEd, 0, 2 ); 487 gl->addWidget( hEd, 0, 2 );
483 488
484 sEd = new QColNumLineEdit( this ); 489 sEd = new QColNumLineEdit( this );
485 sEd->setValidator( val256 ); 490 sEd->setValidator( val256 );
486 l = new QLabel( sEd, OColorDialog::tr("Sat:"), this ); 491 l = new QLabel( sEd, OColorDialog::tr("Sat:"), this );
487 l->setAlignment( AlignRight|AlignVCenter ); 492 l->setAlignment( AlignRight|AlignVCenter );
488 gl->addWidget( l, 1, 1 ); 493 gl->addWidget( l, 1, 1 );
489 gl->addWidget( sEd, 1, 2 ); 494 gl->addWidget( sEd, 1, 2 );
490 495
491 vEd = new QColNumLineEdit( this ); 496 vEd = new QColNumLineEdit( this );
492 vEd->setValidator( val256 ); 497 vEd->setValidator( val256 );
493 l = new QLabel( vEd, OColorDialog::tr("Val:"), this ); 498 l = new QLabel( vEd, OColorDialog::tr("Val:"), this );
494 l->setAlignment( AlignRight|AlignVCenter ); 499 l->setAlignment( AlignRight|AlignVCenter );
495 gl->addWidget( l, 2, 1 ); 500 gl->addWidget( l, 2, 1 );
496 gl->addWidget( vEd, 2, 2 ); 501 gl->addWidget( vEd, 2, 2 );
497 502
498 rEd = new QColNumLineEdit( this ); 503 rEd = new QColNumLineEdit( this );
499 rEd->setValidator( val256 ); 504 rEd->setValidator( val256 );
500 l = new QLabel( rEd, OColorDialog::tr("Red:"), this ); 505 l = new QLabel( rEd, OColorDialog::tr("Red:"), this );
501 l->setAlignment( AlignRight|AlignVCenter ); 506 l->setAlignment( AlignRight|AlignVCenter );
502 gl->addWidget( l, 0, 3 ); 507 gl->addWidget( l, 0, 3 );
503 gl->addWidget( rEd, 0, 4 ); 508 gl->addWidget( rEd, 0, 4 );
504 509
505 gEd = new QColNumLineEdit( this ); 510 gEd = new QColNumLineEdit( this );
506 gEd->setValidator( val256 ); 511 gEd->setValidator( val256 );
507 l = new QLabel( gEd, OColorDialog::tr("Green:"), this ); 512 l = new QLabel( gEd, OColorDialog::tr("Green:"), this );
508 l->setAlignment( AlignRight|AlignVCenter ); 513 l->setAlignment( AlignRight|AlignVCenter );
509 gl->addWidget( l, 1, 3 ); 514 gl->addWidget( l, 1, 3 );
510 gl->addWidget( gEd, 1, 4 ); 515 gl->addWidget( gEd, 1, 4 );
511 516
512 bEd = new QColNumLineEdit( this ); 517 bEd = new QColNumLineEdit( this );
513 bEd->setValidator( val256 ); 518 bEd->setValidator( val256 );
514 l = new QLabel( bEd, OColorDialog::tr("Blue:"), this ); 519 l = new QLabel( bEd, OColorDialog::tr("Blue:"), this );
515 l->setAlignment( AlignRight|AlignVCenter ); 520 l->setAlignment( AlignRight|AlignVCenter );
516 gl->addWidget( l, 2, 3 ); 521 gl->addWidget( l, 2, 3 );
517 gl->addWidget( bEd, 2, 4 ); 522 gl->addWidget( bEd, 2, 4 );
518 523
519 alphaEd = new QColNumLineEdit( this ); 524 alphaEd = new QColNumLineEdit( this );
520 alphaEd->setValidator( val256 ); 525 alphaEd->setValidator( val256 );
521 alphaLab = new QLabel( alphaEd, OColorDialog::tr("Alpha channel:"), this ); 526 alphaLab = new QLabel( alphaEd, OColorDialog::tr("Alpha channel:"), this );
522 alphaLab->setAlignment( AlignRight|AlignVCenter ); 527 alphaLab->setAlignment( AlignRight|AlignVCenter );
523 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); 528 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 );
524 gl->addWidget( alphaEd, 3, 4 ); 529 gl->addWidget( alphaEd, 3, 4 );
525 alphaEd->hide(); 530 alphaEd->hide();
526 alphaLab->hide(); 531 alphaLab->hide();
527 532
528 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 533 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
529 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 534 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
530 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 535 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
531 536
532 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 537 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
533 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 538 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
534 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 539 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
535} 540}
536 541
537void QColorShower::showCurrentColor() 542void QColorShower::showCurrentColor()
538{ 543{
539 lab->setColor( currentColor() ); 544 lab->setColor( currentColor() );
540 lab->repaint(FALSE); //### 545 lab->repaint(FALSE); //###
541} 546}
542 547
543void QColorShower::rgbEd() 548void QColorShower::rgbEd()
544{ 549{
545 rgbOriginal = TRUE; 550 rgbOriginal = TRUE;
546 curCol = qRgb( rEd->val(), gEd->val(), bEd->val() ); 551 curCol = qRgb( rEd->val(), gEd->val(), bEd->val() );
547 rgb2hsv(currentColor(), hue, sat, val ); 552 rgb2hsv(currentColor(), hue, sat, val );
548 553
549 hEd->setNum( hue ); 554 hEd->setNum( hue );
550 sEd->setNum( sat ); 555 sEd->setNum( sat );
551 vEd->setNum( val ); 556 vEd->setNum( val );
552 557
553 showCurrentColor(); 558 showCurrentColor();
554 emit newCol( currentColor() ); 559 emit newCol( currentColor() );
555} 560}
556 561
557void QColorShower::hsvEd() 562void QColorShower::hsvEd()
558{ 563{
559 rgbOriginal = FALSE; 564 rgbOriginal = FALSE;
560 hue = hEd->val(); 565 hue = hEd->val();
561 sat = sEd->val(); 566 sat = sEd->val();
562 val = vEd->val(); 567 val = vEd->val();
563 568
564 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); 569 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
565 570
566 rEd->setNum( qRed(currentColor()) ); 571 rEd->setNum( qRed(currentColor()) );
567 gEd->setNum( qGreen(currentColor()) ); 572 gEd->setNum( qGreen(currentColor()) );
568 bEd->setNum( qBlue(currentColor()) ); 573 bEd->setNum( qBlue(currentColor()) );
569 574
570 showCurrentColor(); 575 showCurrentColor();
571 emit newCol( currentColor() ); 576 emit newCol( currentColor() );
572} 577}
573 578
574void QColorShower::setRgb( QRgb rgb ) 579void QColorShower::setRgb( QRgb rgb )
575{ 580{
576 rgbOriginal = TRUE; 581 rgbOriginal = TRUE;
577 curCol = rgb; 582 curCol = rgb;
578 583
579 rgb2hsv( currentColor(), hue, sat, val ); 584 rgb2hsv( currentColor(), hue, sat, val );
580 585
581 hEd->setNum( hue ); 586 hEd->setNum( hue );
582 sEd->setNum( sat ); 587 sEd->setNum( sat );
583 vEd->setNum( val ); 588 vEd->setNum( val );
584 589
585 rEd->setNum( qRed(currentColor()) ); 590 rEd->setNum( qRed(currentColor()) );
586 gEd->setNum( qGreen(currentColor()) ); 591 gEd->setNum( qGreen(currentColor()) );
587 bEd->setNum( qBlue(currentColor()) ); 592 bEd->setNum( qBlue(currentColor()) );
588 593
589 showCurrentColor(); 594 showCurrentColor();
590} 595}
591 596
592void QColorShower::setHsv( int h, int s, int v ) 597void QColorShower::setHsv( int h, int s, int v )
593{ 598{
594 rgbOriginal = FALSE; 599 rgbOriginal = FALSE;
595 hue = h; val = v; sat = s; //Range check### 600 hue = h; val = v; sat = s; //Range check###
596 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); 601 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
597 602
598 hEd->setNum( hue ); 603 hEd->setNum( hue );
599 sEd->setNum( sat ); 604 sEd->setNum( sat );
600 vEd->setNum( val ); 605 vEd->setNum( val );
601 606
602 rEd->setNum( qRed(currentColor()) ); 607 rEd->setNum( qRed(currentColor()) );
603 gEd->setNum( qGreen(currentColor()) ); 608 gEd->setNum( qGreen(currentColor()) );
604 bEd->setNum( qBlue(currentColor()) ); 609 bEd->setNum( qBlue(currentColor()) );
605 610
606 611
607 showCurrentColor(); 612 showCurrentColor();
608} 613}
609 614
615}
616
610class OColorDialogPrivate : public QObject 617class OColorDialogPrivate : public QObject
611{ 618{
612Q_OBJECT 619Q_OBJECT
613public: 620public:
614 OColorDialogPrivate( OColorDialog *p ); 621 OColorDialogPrivate( OColorDialog *p );
615 QRgb currentColor() const { return cs->currentColor(); } 622 QRgb currentColor() const { return cs->currentColor(); }
616 void setCurrentColor( QRgb rgb ); 623 void setCurrentColor( const QRgb& rgb );
617 624
618 int currentAlpha() const { return cs->currentAlpha(); } 625 int currentAlpha() const { return cs->currentAlpha(); }
619 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); } 626 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
620 void showAlpha( bool b ) { cs->showAlpha( b ); } 627 void showAlpha( bool b ) { cs->showAlpha( b ); }
621 628
622private slots: 629private slots:
623 void newHsv( int h, int s, int v ); 630 void newHsv( int h, int s, int v );
624 void newColorTypedIn( QRgb rgb ); 631 void newColorTypedIn( QRgb rgb );
625private: 632private:
626 QColorPicker *cp; 633 QColorPicker *cp;
627 QColorLuminancePicker *lp; 634 QColorLuminancePicker *lp;
628 QColorShower *cs; 635 QColorShower *cs;
629}; 636};
630 637
631//sets all widgets to display h,s,v 638//sets all widgets to display h,s,v
632void OColorDialogPrivate::newHsv( int h, int s, int v ) 639void OColorDialogPrivate::newHsv( int h, int s, int v )
633{ 640{
634 cs->setHsv( h, s, v ); 641 cs->setHsv( h, s, v );
635 cp->setCol( h, s ); 642 cp->setCol( h, s );
636 lp->setCol( h, s, v ); 643 lp->setCol( h, s, v );
637} 644}
638 645
639//sets all widgets to display rgb 646//sets all widgets to display rgb
640void OColorDialogPrivate::setCurrentColor( QRgb rgb ) 647void OColorDialogPrivate::setCurrentColor( const QRgb& rgb )
641{ 648{
642 cs->setRgb( rgb ); 649 cs->setRgb( rgb );
643 newColorTypedIn( rgb ); 650 newColorTypedIn( rgb );
644} 651}
645 652
646//sets all widgets exept cs to display rgb 653//sets all widgets exept cs to display rgb
647void OColorDialogPrivate::newColorTypedIn( QRgb rgb ) 654void OColorDialogPrivate::newColorTypedIn( QRgb rgb )
648{ 655{
649 int h, s, v; 656 int h, s, v;
650 rgb2hsv(rgb, h, s, v ); 657 rgb2hsv(rgb, h, s, v );
651 cp->setCol( h, s ); 658 cp->setCol( h, s );
652 lp->setCol( h, s, v); 659 lp->setCol( h, s, v);
653} 660}
654 661
655OColorDialogPrivate::OColorDialogPrivate( OColorDialog *dialog ) : 662OColorDialogPrivate::OColorDialogPrivate( OColorDialog *dialog ) :
656 QObject(dialog) 663 QObject(dialog)
657{ 664{
658 int border = 2; 665 int border = 2;
659 QVBoxLayout *topLay = new QVBoxLayout( dialog, border, 2 ); 666 QVBoxLayout *topLay = new QVBoxLayout( dialog, border, 2 );
660 667
661 QHBoxLayout *pickLay = new QHBoxLayout( topLay ); 668 QHBoxLayout *pickLay = new QHBoxLayout( topLay );
662 669
663 670
664 cp = new QColorPicker( dialog ); 671 cp = new QColorPicker( dialog );
665 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken ); 672 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken );
666 pickLay->addWidget( cp ); 673 pickLay->addWidget( cp );
667 674
668 pickLay->addStretch(); 675 pickLay->addStretch();
669 676
670 lp = new QColorLuminancePicker( dialog ); 677 lp = new QColorLuminancePicker( dialog );
671 lp->setFixedWidth( 20 ); //### 678 lp->setFixedWidth( 20 ); //###
672 pickLay->addWidget( lp ); 679 pickLay->addWidget( lp );
673 680
674 connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) ); 681 connect( cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)) );
675 connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) ); 682 connect( lp, SIGNAL(newHsv(int,int,int)), this, SLOT(newHsv(int,int,int)) );
676 683
677 topLay->addStretch(); 684 topLay->addStretch();
678 685
679 cs = new QColorShower( dialog ); 686 cs = new QColorShower( dialog );
680 connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb))); 687 connect( cs, SIGNAL(newCol(QRgb)), this, SLOT(newColorTypedIn(QRgb)));
681 topLay->addWidget( cs ); 688 topLay->addWidget( cs );
682 689
683} 690}
684 691
685 692
686// BEING REVISED: jo 693// BEING REVISED: jo
687/*! 694/*!
688 \class OColorDialog OColorDialog.h 695 \class OColorDialog OColorDialog.h
689 \brief The OColorDialog class provides a dialog widget for specifying colors. 696 \brief The OColorDialog class provides a dialog widget for specifying colors.
690 \ingroup dialogs 697 \ingroup dialogs
691 698
692 The color dialog's function is to allow users to choose colors - 699 The color dialog's function is to allow users to choose colors -
693 for instance, you might use this in a drawing program to allow the 700 for instance, you might use this in a drawing program to allow the
694 user to set the brush color. 701 user to set the brush color.
695 702
696 This version of Qt only provides modal color dialogs. The static 703 This version of Qt only provides modal color dialogs. The static
697 getColor() function shows the dialog and allows the user to specify a color, 704 getColor() function shows the dialog and allows the user to specify a color,
698 while getRgba() does the same but allows the user to specify a color with an 705 while getRgba() does the same but allows the user to specify a color with an
699 alpha channel (transparency) value. 706 alpha channel (transparency) value.
700 707
701 The user can store customCount() different custom colors. The custom 708 The user can store customCount() different custom colors. The custom
702 colors are shared by all color dialogs, and remembered during the 709 colors are shared by all color dialogs, and remembered during the
703 execution of the program. Use setCustomColor() to set the 710 execution of the program. Use setCustomColor() to set the
704 custom colors, and customColor() to get them. 711 custom colors, and customColor() to get them.
705 712
706 <img src=qcolordlg-m.png> <img src=qcolordlg-w.png> 713 <img src=qcolordlg-m.png> <img src=qcolordlg-w.png>
707*/ 714*/
708 715
709/*! 716/*!
710 Constructs a default color dialog. Use setColor() for setting an initial value. 717 Constructs a default color dialog. Use setColor() for setting an initial value.
711 718
712 \sa getColor() 719 \sa getColor()
713*/ 720*/
714 721
715OColorDialog::OColorDialog(QWidget* parent, const char* name, bool modal) : 722OColorDialog::OColorDialog(QWidget* parent, const char* name, bool modal) :
716 QDialog(parent, name, modal ) 723 QDialog(parent, name, modal )
717{ 724{
718 d = new OColorDialogPrivate( this ); 725 d = new OColorDialogPrivate( this );
719} 726}
720 727
721 728
722/*! 729/*!
723 Pops up a modal color dialog letting the user choose a color and returns 730 Pops up a modal color dialog letting the user choose a color and returns
724 that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels 731 that color. The color is initially set to \a initial. Returns an \link QColor::isValid() invalid\endlink color if the user cancels
725 the dialog. All colors allocated by the dialog will be deallocated 732 the dialog. All colors allocated by the dialog will be deallocated
726 before this function returns. 733 before this function returns.
727*/ 734*/
728 735
729QColor OColorDialog::getColor( QColor initial, QWidget *parent, 736QColor OColorDialog::getColor( const QColor& initial, QWidget *parent,
730 const char *name ) 737 const char *name )
731{ 738{
732 int allocContext = QColor::enterAllocContext(); 739 int allocContext = QColor::enterAllocContext();
733 OColorDialog *dlg = new OColorDialog( parent, name, TRUE ); //modal 740 OColorDialog *dlg = new OColorDialog( parent, name, TRUE ); //modal
734 if ( parent && parent->icon() && !parent->icon()->isNull() ) 741 if ( parent && parent->icon() && !parent->icon()->isNull() )
735 dlg->setIcon( *parent->icon() ); 742 dlg->setIcon( *parent->icon() );
736 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) 743 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
737 dlg->setIcon( *qApp->mainWidget()->icon() ); 744 dlg->setIcon( *qApp->mainWidget()->icon() );
738 745
739 dlg->setCaption( OColorDialog::tr( "Select color" ) ); 746 dlg->setCaption( OColorDialog::tr( "Select color" ) );
740 dlg->setColor( initial ); 747 dlg->setColor( initial );
741 dlg->showMaximized(); 748 dlg->showMaximized();
742 int resultCode = dlg->exec(); 749 int resultCode = dlg->exec();
743 QColor::leaveAllocContext(); 750 QColor::leaveAllocContext();
744 QColor result; 751 QColor result;
745 if ( resultCode == QDialog::Accepted ) { 752 if ( resultCode == QDialog::Accepted ) {
746 result = dlg->color(); 753 result = dlg->color();
747 } else { 754 } else {
748 result = initial; 755 result = initial;
749 } 756 }
750 QColor::destroyAllocContext(allocContext); 757 QColor::destroyAllocContext(allocContext);
751 delete dlg; 758 delete dlg;
752 return result; 759 return result;
753} 760}
754 761
755 762
756/*! 763/*!
757 Pops up a modal color dialog, letting the user choose a color and an 764 Pops up a modal color dialog, letting the user choose a color and an
758 alpha channel value. The color+alpha is initially set to \a initial. 765 alpha channel value. The color+alpha is initially set to \a initial.
759 766
760 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK, 767 If \a ok is non-null, \c *ok is set to TRUE if the user clicked OK,
761 and FALSE if the user clicked Cancel. 768 and FALSE if the user clicked Cancel.
762 769
763 If the user clicks Cancel the \a initial value is returned. 770 If the user clicks Cancel the \a initial value is returned.
764*/ 771*/
765 772
766QRgb OColorDialog::getRgba( QRgb initial, bool *ok, 773QRgb OColorDialog::getRgba( const QRgb& initial, bool *ok,
767 QWidget *parent, const char* name ) 774 QWidget *parent, const char* name )
768{ 775{
769 int allocContext = QColor::enterAllocContext(); 776 int allocContext = QColor::enterAllocContext();
770 OColorDialog *dlg = new OColorDialog( parent, name, TRUE ); //modal 777 OColorDialog *dlg = new OColorDialog( parent, name, TRUE ); //modal
771 dlg->setColor( initial ); 778 dlg->setColor( initial );
772 dlg->setSelectedAlpha( qAlpha(initial) ); 779 dlg->setSelectedAlpha( qAlpha(initial) );
773 dlg->showMaximized(); 780 dlg->showMaximized();
774 int resultCode = dlg->exec(); 781 int resultCode = dlg->exec();
775 QColor::leaveAllocContext(); 782 QColor::leaveAllocContext();
776 QRgb result = initial; 783 QRgb result = initial;
777 if ( resultCode == QDialog::Accepted ) { 784 if ( resultCode == QDialog::Accepted ) {
778 QRgb c = dlg->color().rgb(); 785 QRgb c = dlg->color().rgb();
779 int alpha = dlg->selectedAlpha(); 786 int alpha = dlg->selectedAlpha();
780 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha ); 787 result = qRgba( qRed(c), qGreen(c), qBlue(c), alpha );
781 } 788 }
782 if ( ok ) 789 if ( ok )
783 *ok = resultCode == QDialog::Accepted; 790 *ok = resultCode == QDialog::Accepted;
784 791
785 QColor::destroyAllocContext(allocContext); 792 QColor::destroyAllocContext(allocContext);
786 delete dlg; 793 delete dlg;
787 return result; 794 return result;
788} 795}
789 796
790 797
791 798
792 799
793 800
794/*! 801/*!
795 Returns the color currently selected in the dialog. 802 Returns the color currently selected in the dialog.
796 803
797 \sa setColor() 804 \sa setColor()
798*/ 805*/
799 806
800QColor OColorDialog::color() const 807QColor OColorDialog::color() const
801{ 808{
802 return QColor(d->currentColor()); 809 return QColor(d->currentColor());
803} 810}
804 811
805 812
806/*! Destructs the dialog and frees any memory it allocated. 813/*! Destructs the dialog and frees any memory it allocated.
807 814
808*/ 815*/
809 816
810OColorDialog::~OColorDialog() 817OColorDialog::~OColorDialog()
811{ 818{
812 //d inherits QObject, so it is deleted by Qt. 819 //d inherits QObject, so it is deleted by Qt.
813} 820}
814 821
815 822
816/*! 823/*!
817 Sets the color shown in the dialog to \a c. 824 Sets the color shown in the dialog to \a c.
818 825
819 \sa color() 826 \sa color()
820*/ 827*/
821 828
822void OColorDialog::setColor( QColor c ) 829void OColorDialog::setColor( const QColor& c )
823{ 830{
824 d->setCurrentColor( c.rgb() ); 831 d->setCurrentColor( c.rgb() );
825} 832}
826 833
827 834
828 835
829 836
830/*! 837/*!
831 Sets the initial alpha channel value to \a a, and show the alpha channel 838 Sets the initial alpha channel value to \a a, and show the alpha channel
832 entry box. 839 entry box.
833*/ 840*/
834 841
835void OColorDialog::setSelectedAlpha( int a ) 842void OColorDialog::setSelectedAlpha( int a )
836{ 843{
837 d->showAlpha( TRUE ); 844 d->showAlpha( TRUE );
838 d->setCurrentAlpha( a ); 845 d->setCurrentAlpha( a );
839} 846}
840 847
841 848
842/*! 849/*!
843 Returns the value selected for the alpha channel. 850 Returns the value selected for the alpha channel.
844*/ 851*/
845 852
846int OColorDialog::selectedAlpha() const 853int OColorDialog::selectedAlpha() const
847{ 854{
848 return d->currentAlpha(); 855 return d->currentAlpha();
849} 856}
850 857
851#include "colordialog.moc" 858#include "colordialog.moc"
diff --git a/libopie/colordialog.h b/libopie/colordialog.h
index 926f8f2..e9bb7ed 100644
--- a/libopie/colordialog.h
+++ b/libopie/colordialog.h
@@ -1,89 +1,89 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Definition of OColorDialog class 4** Definition of OColorDialog class
5** 5**
6** Created : 990222 6** Created : 990222
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#ifndef OColorDialog_H 38#ifndef OColorDialog_H
39#define OColorDialog_H 39#define OColorDialog_H
40 40
41#ifndef QT_H 41#ifndef QT_H
42#include <qdialog.h> 42#include <qdialog.h>
43#endif // QT_H 43#endif // QT_H
44 44
45class OColorDialogPrivate; 45class OColorDialogPrivate;
46 46
47/** 47/**
48 * @class OColorDialog 48 * @class OColorDialog
49 * @brief The OColorDialog class is a copy of QColorDialog for use in Opie. 49 * @brief The OColorDialog class is a copy of QColorDialog for use in Opie.
50 * 50 *
51 * OColorDialog is a copy of TrollTech's QColorDialog for use in Opie. The default 51 * OColorDialog is a copy of TrollTech's QColorDialog for use in Opie. The default
52 * build of QT/Embedded used by Opie does not include QColorDialog, so it is provided 52 * build of QT/Embedded used by Opie does not include QColorDialog, so it is provided
53 * here. It is renamed to prevent conflicts in the event the QColorDialog is included 53 * here. It is renamed to prevent conflicts in the event the QColorDialog is included
54 * at a later date in QP/E. 54 * at a later date in QP/E.
55 * 55 *
56 * See http://doc.trolltech.com/2.3/qcolordialog.html for complete documentation of 56 * See http://doc.trolltech.com/2.3/qcolordialog.html for complete documentation of
57 * QColorDialog. 57 * QColorDialog.
58 */ 58 */
59class Q_EXPORT OColorDialog : public QDialog 59class Q_EXPORT OColorDialog : public QDialog
60{ 60{
61 Q_OBJECT 61 Q_OBJECT
62 62
63public: 63public:
64 static QColor getColor( QColor, QWidget *parent=0, const char* name=0 ); // ### 3.0: make const QColor& 64 static QColor getColor( const QColor&, QWidget *parent=0, const char* name=0 );
65 static QRgb getRgba( QRgb, bool* ok = 0, 65 static QRgb getRgba( const QRgb&, bool* ok = 0,
66 QWidget *parent=0, const char* name=0 ); 66 QWidget *parent=0, const char* name=0 );
67 67
68private: 68private:
69 ~OColorDialog(); 69 ~OColorDialog();
70 70
71 OColorDialog( QWidget* parent=0, const char* name=0, bool modal=FALSE ); 71 OColorDialog( QWidget* parent=0, const char* name=0, bool modal=FALSE );
72 void setColor( QColor ); // ### 3.0: make const QColor& 72 void setColor( const QColor& );
73 QColor color() const; 73 QColor color() const;
74 74
75private: 75private:
76 void setSelectedAlpha( int ); 76 void setSelectedAlpha( int );
77 int selectedAlpha() const; 77 int selectedAlpha() const;
78private: 78private:
79 OColorDialogPrivate *d; 79 OColorDialogPrivate *d;
80 friend class OColorDialogPrivate; 80 friend class OColorDialogPrivate;
81 81
82 private:// Disabled copy constructor and operator= 82 private:// Disabled copy constructor and operator=
83#if defined(Q_DISABLE_COPY) 83#if defined(Q_DISABLE_COPY)
84 OColorDialog( const OColorDialog & ); 84 OColorDialog( const OColorDialog & );
85 OColorDialog& operator=( const OColorDialog & ); 85 OColorDialog& operator=( const OColorDialog & );
86#endif 86#endif
87}; 87};
88 88
89#endif 89#endif
diff --git a/libopie/colorpopupmenu.cpp b/libopie/colorpopupmenu.cpp
index 510a2ad..dac10e9 100644
--- a/libopie/colorpopupmenu.cpp
+++ b/libopie/colorpopupmenu.cpp
@@ -1,176 +1,170 @@
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 "colorpopupmenu.h" 33#include "colorpopupmenu.h"
34#include "colordialog.h" 34#include "colordialog.h"
35 35
36#include <qaction.h> 36#include <qaction.h>
37#include <qlayout.h> 37#include <qlayout.h>
38#include <qpainter.h> 38#include <qpainter.h>
39 39
40ColorPanelButton::ColorPanelButton( const QColor& color, QWidget* parent, const char* name ) 40OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name )
41 : QFrame( parent, name ) 41 : QFrame( parent, name )
42{ 42{
43 m_color = color; 43 m_color = color;
44 44
45 setFixedSize( 16, 16 ); 45 setFixedSize( 16, 16 );
46 setActive( FALSE ); 46 setActive( FALSE );
47} 47}
48 48
49ColorPanelButton::~ColorPanelButton() 49OColorPanelButton::~OColorPanelButton()
50{ 50{
51} 51}
52 52
53void ColorPanelButton::setActive( bool active ) 53void OColorPanelButton::setActive( bool active )
54{ 54{
55 m_active = active; 55 m_active = active;
56 56
57 if ( m_active ) { 57 if ( m_active ) {
58 setFrameStyle( Panel | Sunken ); 58 setFrameStyle( Panel | Sunken );
59 } else { 59 } else {
60 setFrameStyle( NoFrame ); 60 setFrameStyle( NoFrame );
61 } 61 }
62} 62}
63 63
64void ColorPanelButton::enterEvent( QEvent* e ) 64void OColorPanelButton::enterEvent( QEvent* )
65{ 65{
66 Q_UNUSED( e )
67
68 if ( !m_active ) { 66 if ( !m_active ) {
69 setFrameStyle( Panel | Sunken ); 67 setFrameStyle( Panel | Sunken );
70 } 68 }
71} 69}
72 70
73void ColorPanelButton::leaveEvent( QEvent* e ) 71void OColorPanelButton::leaveEvent( QEvent* )
74{ 72{
75 Q_UNUSED( e )
76
77 if ( !m_active ) { 73 if ( !m_active ) {
78 setFrameStyle( NoFrame ); 74 setFrameStyle( NoFrame );
79 } 75 }
80} 76}
81 77
82void ColorPanelButton::paintEvent( QPaintEvent* e ) 78void OColorPanelButton::paintEvent( QPaintEvent* e )
83{ 79{
84 QFrame::paintEvent( e ); 80 QFrame::paintEvent( e );
85 81
86 QPainter painter; 82 QPainter painter;
87 painter.begin( this ); 83 painter.begin( this );
88 painter.fillRect( 2, 2, 12, 12, m_color ); 84 painter.fillRect( 2, 2, 12, 12, m_color );
89 painter.setPen( Qt::black ); 85 painter.setPen( Qt::black );
90 painter.drawRect( 2, 2, 12, 12 ); 86 painter.drawRect( 2, 2, 12, 12 );
91 painter.end(); 87 painter.end();
92} 88}
93 89
94void ColorPanelButton::mouseReleaseEvent( QMouseEvent* e ) 90void OColorPanelButton::mouseReleaseEvent( QMouseEvent* )
95{ 91{
96 Q_UNUSED( e )
97
98 emit selected( m_color ); 92 emit selected( m_color );
99} 93}
100 94
101ColorPopupMenu::ColorPopupMenu( const QColor& color, QWidget* parent, const char* name ) 95OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name )
102 : QPopupMenu( parent, name ) 96 : QPopupMenu( parent, name )
103{ 97{
104 m_color = color; 98 m_color = color;
105 99
106 colorPanel = new QWidget( this ); 100 colorPanel = new QWidget( this );
107 101
108 colorLayout = new QGridLayout(colorPanel, 5, 6); 102 colorLayout = new QGridLayout(colorPanel, 5, 6);
109 103
110 addColor(QColor(255, 255, 255), 0, 1); 104 addColor(QColor(255, 255, 255), 0, 1);
111 addColor(QColor(192, 192, 192), 0, 2); 105 addColor(QColor(192, 192, 192), 0, 2);
112 addColor(QColor(128, 128, 128), 0, 3); 106 addColor(QColor(128, 128, 128), 0, 3);
113 addColor(QColor(64, 64, 64), 0, 4); 107 addColor(QColor(64, 64, 64), 0, 4);
114 addColor(QColor(0, 0, 0), 0, 5); 108 addColor(QColor(0, 0, 0), 0, 5);
115 109
116 addColor(QColor(255, 0, 0), 1, 0); 110 addColor(QColor(255, 0, 0), 1, 0);
117 addColor(QColor(255, 128, 0), 1, 1); 111 addColor(QColor(255, 128, 0), 1, 1);
118 addColor(QColor(255, 255, 0), 1, 2); 112 addColor(QColor(255, 255, 0), 1, 2);
119 addColor(QColor(128, 255, 0), 1, 3); 113 addColor(QColor(128, 255, 0), 1, 3);
120 addColor(QColor(0, 255, 0), 1, 4); 114 addColor(QColor(0, 255, 0), 1, 4);
121 addColor(QColor(0, 255, 128), 1, 5); 115 addColor(QColor(0, 255, 128), 1, 5);
122 116
123 addColor(QColor(128, 0, 0), 2, 0); 117 addColor(QColor(128, 0, 0), 2, 0);
124 addColor(QColor(128, 64, 0), 2, 1); 118 addColor(QColor(128, 64, 0), 2, 1);
125 addColor(QColor(128, 128, 0), 2, 2); 119 addColor(QColor(128, 128, 0), 2, 2);
126 addColor(QColor(64, 128, 0), 2, 3); 120 addColor(QColor(64, 128, 0), 2, 3);
127 addColor(QColor(0, 128, 0), 2, 4); 121 addColor(QColor(0, 128, 0), 2, 4);
128 addColor(QColor(0, 128, 64), 2, 5); 122 addColor(QColor(0, 128, 64), 2, 5);
129 123
130 addColor(QColor(0, 255, 255), 3, 0); 124 addColor(QColor(0, 255, 255), 3, 0);
131 addColor(QColor(0, 128, 255), 3, 1); 125 addColor(QColor(0, 128, 255), 3, 1);
132 addColor(QColor(0, 0, 255), 3, 2); 126 addColor(QColor(0, 0, 255), 3, 2);
133 addColor(QColor(128, 0, 255), 3, 3); 127 addColor(QColor(128, 0, 255), 3, 3);
134 addColor(QColor(255, 0, 255), 3, 4); 128 addColor(QColor(255, 0, 255), 3, 4);
135 addColor(QColor(255, 0, 128), 3, 5); 129 addColor(QColor(255, 0, 128), 3, 5);
136 130
137 addColor(QColor(0, 128, 128), 4, 0); 131 addColor(QColor(0, 128, 128), 4, 0);
138 addColor(QColor(0, 64, 128), 4, 1); 132 addColor(QColor(0, 64, 128), 4, 1);
139 addColor(QColor(0, 0, 128), 4, 2); 133 addColor(QColor(0, 0, 128), 4, 2);
140 addColor(QColor(64, 0, 128), 4, 3); 134 addColor(QColor(64, 0, 128), 4, 3);
141 addColor(QColor(128, 0, 128), 4, 4); 135 addColor(QColor(128, 0, 128), 4, 4);
142 addColor(QColor(128, 0, 64), 4, 5); 136 addColor(QColor(128, 0, 64), 4, 5);
143 137
144 insertItem( colorPanel ); 138 insertItem( colorPanel );
145 insertSeparator(); 139 insertSeparator();
146 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" ); 140 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" );
147 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) ); 141 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) );
148 chooseColorAction->addTo( this ); 142 chooseColorAction->addTo( this );
149 activateItemAt( 0 ); 143 activateItemAt( 0 );
150} 144}
151 145
152ColorPopupMenu::~ColorPopupMenu() 146OColorPopupMenu::~OColorPopupMenu()
153{ 147{
154} 148}
155 149
156void ColorPopupMenu::addColor( const QColor& color, int row, int col ) 150void OColorPopupMenu::addColor( const QColor& color, int row, int col )
157{ 151{
158 ColorPanelButton* panelButton = new ColorPanelButton( color, colorPanel ); 152 OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel );
159 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) ); 153 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) );
160 colorLayout->addWidget( panelButton, row, col ); 154 colorLayout->addWidget( panelButton, row, col );
161} 155}
162 156
163void ColorPopupMenu::buttonSelected( const QColor& color ) 157void OColorPopupMenu::buttonSelected( const QColor& color )
164{ 158{
165 m_color = color; 159 m_color = color;
166 emit colorSelected( color ); 160 emit colorSelected( color );
167 hide(); 161 hide();
168} 162}
169 163
170void ColorPopupMenu::moreColorClicked() 164void OColorPopupMenu::moreColorClicked()
171{ 165{
172 QColor color = OColorDialog::getColor( m_color ); 166 QColor color = OColorDialog::getColor( m_color );
173 m_color = color; 167 m_color = color;
174 emit colorSelected( color ); 168 emit colorSelected( color );
175 hide(); 169 hide();
176} 170}
diff --git a/libopie/colorpopupmenu.h b/libopie/colorpopupmenu.h
index b0453b2..184b132 100644
--- a/libopie/colorpopupmenu.h
+++ b/libopie/colorpopupmenu.h
@@ -1,254 +1,254 @@
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#ifndef COLORPOPUPMENU_H 33#ifndef COLORPOPUPMENU_H
34#define COLORPOPUPMENU_H 34#define COLORPOPUPMENU_H
35 35
36#include <qframe.h> 36#include <qframe.h>
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38 38
39class QWidget; 39class QWidget;
40class QGridLayout; 40class QGridLayout;
41 41
42/** 42/**
43 * @class ColorPanelButton 43 * @class OColorPanelButton
44 * @brief The ColorPanelButton class provides a button for color selection. 44 * @brief The OColorPanelButton class provides a button for color selection.
45 * 45 *
46 * @see ColorPopupMenu 46 * @see OColorPopupMenu
47 * 47 *
48 * The ColorPanelButton class provides a button for color selection. The button 48 * The OColorPanelButton class provides a button for color selection. The button
49 * is drawn with the desired color and no border. This class is used internally 49 * is drawn with the desired color and no border. This class is used internally
50 * by the ColorPopupMenu class to displaying colors in its menu. 50 * by the OColorPopupMenu class to displaying colors in its menu.
51 */ 51 */
52class ColorPanelButton : public QFrame 52class OColorPanelButton : public QFrame
53{ 53{
54 Q_OBJECT 54 Q_OBJECT
55 55
56public: 56public:
57 57
58/** 58/**
59 * @fn ColorPanelButton( const QColor& color, QWidget* parent = 0, const char* name = 0 ) 59 * @fn OColorPanelButton( const QColor& color, QWidget* parent = 0, const char* name = 0 )
60 * @brief Object constructor. 60 * @brief Object constructor.
61 * 61 *
62 * @param color Desired color. 62 * @param color Desired color.
63 * @param parent Pointer to parent of this control. 63 * @param parent Pointer to parent of this control.
64 * @param name Name of control. 64 * @param name Name of control.
65 * 65 *
66 * Constructs a new ColorPanelButton control with parent, name and desired color. 66 * Constructs a new ColorPanelButton control with parent, name and desired color.
67 */ 67 */
68 ColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0); 68 OColorPanelButton(const QColor& color, QWidget* parent = 0, const char* name = 0);
69 69
70/** 70/**
71 * @fn ~ColorPanelButton() 71 * @fn ~ColorPanelButton()
72 * @brief Object destructor. 72 * @brief Object destructor.
73 */ 73 */
74 ~ColorPanelButton(); 74 ~OColorPanelButton();
75 75
76/** 76/**
77 * @fn setActive( bool active ) 77 * @fn setActive( bool active )
78 * @brief Sets button selection state. 78 * @brief Sets button selection state.
79 * 79 *
80 * @param active Boolean indicator of new button state. 80 * @param active Boolean indicator of new button state.
81 * 81 *
82 * Changes button selection state. If button is selected, a highlighted border 82 * Changes button selection state. If button is selected, a highlighted border
83 * is drawn. 83 * is drawn.
84 */ 84 */
85 void setActive(bool active); 85 void setActive(bool active);
86 86
87/** 87/**
88 * @fn enterEvent( QEvent* e ) 88 * @fn enterEvent( QEvent* e )
89 * @brief Reimplemented for internal reasons. 89 * @brief Reimplemented for internal reasons.
90 * 90 *
91 * @param e Event currently being processed. 91 * @param e Event currently being processed.
92 * 92 *
93 * Reimplemented to ensure correct display of button based on whether it is 93 * Reimplemented to ensure correct display of button based on whether it is
94 * active or not. 94 * active or not.
95 */ 95 */
96 void enterEvent(QEvent* e); 96 void enterEvent(QEvent* e);
97 97
98/** 98/**
99 * @fn leaveEvent( QEvent* e ) 99 * @fn leaveEvent( QEvent* e )
100 * @brief Reimplemented for internal reasons. 100 * @brief Reimplemented for internal reasons.
101 * 101 *
102 * @param e Event currently being processed. 102 * @param e Event currently being processed.
103 * 103 *
104 * Reimplemented to ensure correct display of button based on whether it is 104 * Reimplemented to ensure correct display of button based on whether it is
105 * active or not. 105 * active or not.
106 */ 106 */
107 void leaveEvent(QEvent* e); 107 void leaveEvent(QEvent* e);
108 108
109/** 109/**
110 * @fn paintEvent( QEvent* e ) 110 * @fn paintEvent( QEvent* e )
111 * @brief Reimplemented for internal reasons. 111 * @brief Reimplemented for internal reasons.
112 * 112 *
113 * @param e Event currently being processed. 113 * @param e Event currently being processed.
114 * 114 *
115 * Reimplemented to ensure correct display of button. 115 * Reimplemented to ensure correct display of button.
116 */ 116 */
117 void paintEvent(QPaintEvent* e); 117 void paintEvent(QPaintEvent* e);
118 118
119/** 119/**
120 * @fn mouseReleaseEvent( QMouseEvent* e ) 120 * @fn mouseReleaseEvent( QMouseEvent* e )
121 * @brief Slot executed when button is pressed. 121 * @brief Slot executed when button is pressed.
122 * 122 *
123 * @param e Mouse event currently being processed. 123 * @param e Mouse event currently being processed.
124 * 124 *
125 * @see selected() 125 * @see selected()
126 * 126 *
127 * This slot executes when the button has been pressed. It emits the selected 127 * This slot executes when the button has been pressed. It emits the selected
128 * signal as notification that it has been pressed. 128 * signal as notification that it has been pressed.
129 */ 129 */
130 void mouseReleaseEvent(QMouseEvent* e); 130 void mouseReleaseEvent(QMouseEvent* e);
131 131
132signals: 132signals:
133 133
134/** 134/**
135 * @fn selected( const QColor& color ) 135 * @fn selected( const QColor& color )
136 * @brief Signal to indicate button has been pressed. 136 * @brief Signal to indicate button has been pressed.
137 * 137 *
138 * @param color Button color. 138 * @param color Button color.
139 * 139 *
140 * This signal is emitted when the button is pressed. It provides the color 140 * This signal is emitted when the button is pressed. It provides the color
141 * associated to this button. 141 * associated to this button.
142 */ 142 */
143 void selected(const QColor&); 143 void selected(const QColor&);
144 144
145private: 145private:
146 QColor m_color; 146 QColor m_color;
147 bool m_active : 1; 147 bool m_active : 1;
148 class ColorPanelButtonPrivate; 148 class ColorPanelButtonPrivate;
149 ColorPanelButtonPrivate *d; 149 ColorPanelButtonPrivate *d;
150}; 150};
151 151
152/** 152/**
153 * @class ColorPopupMenu 153 * @class OColorPopupMenu
154 * @brief The ColorPopupMenu class provides a small color selection 154 * @brief The OColorPopupMenu class provides a small color selection
155 * popup menu. 155 * popup menu.
156 * 156 *
157 * ColorPopupMenu is a derivation of TrollTech's QPopupMenu and provides 157 * OColorPopupMenu is a derivation of TrollTech's QPopupMenu and provides
158 * a small color selection popup menu which can be attached to another control 158 * a small color selection popup menu which can be attached to another control
159 * such as a toolbar button of menu item. 159 * such as a toolbar button of menu item.
160 * 160 *
161 * The popup menu displays 30 default colors available in a grid, and also 161 * The popup menu displays 30 default colors available in a grid, and also
162 * includes an option at the bottom to display a color selection dialog box for 162 * includes an option at the bottom to display a color selection dialog box for
163 * finer color control. 163 * finer color control.
164 */ 164 */
165class ColorPopupMenu : public QPopupMenu 165class OColorPopupMenu : public QPopupMenu
166{ 166{
167 Q_OBJECT 167 Q_OBJECT
168 168
169public: 169public:
170 170
171/** 171/**
172 * @fn ColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 ) 172 * @fn OColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 )
173 * @brief Object constructor. 173 * @brief Object constructor.
174 * 174 *
175 * @param color Initial color selected in menu. 175 * @param color Initial color selected in menu.
176 * @param parent Pointer to parent of this control. 176 * @param parent Pointer to parent of this control.
177 * @param name Name of control. 177 * @param name Name of control.
178 * 178 *
179 * Constructs a new ColorPopupMenu control with parent, name and initial color selected. 179 * Constructs a new OColorPopupMenu control with parent, name and initial color selected.
180 */ 180 */
181 ColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 ); 181 OColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 );
182 182
183/** 183/**
184 * @fn ~ColorPopupMenu() 184 * @fn ~OColorPopupMenu()
185 * @brief Object destructor. 185 * @brief Object destructor.
186 */ 186 */
187 ~ColorPopupMenu(); 187 ~OColorPopupMenu();
188 188
189private: 189private:
190 class ColorPopupMenuPrivate; 190 class ColorPopupMenuPrivate;
191 ColorPopupMenuPrivate *d; 191 ColorPopupMenuPrivate *d;
192 QColor m_color; 192 QColor m_color;
193 QWidget* colorPanel; 193 QWidget* colorPanel;
194 QGridLayout* colorLayout; 194 QGridLayout* colorLayout;
195 195
196/** 196/**
197 * @fn addColor( const QColor& color, int row, int col ) 197 * @fn addColor( const QColor& color, int row, int col )
198 * @brief Adds color selection option to popup menu. 198 * @brief Adds color selection option to popup menu.
199 * 199 *
200 * @param color Color to be displayed in menu. 200 * @param color Color to be displayed in menu.
201 * @param row Row where color is to appear in menu. 201 * @param row Row where color is to appear in menu.
202 * @param col Column where color is to appear in menu. 202 * @param col Column where color is to appear in menu.
203 * 203 *
204 * Adds a color selection option to popup menu. Used internally when 204 * Adds a color selection option to popup menu. Used internally when
205 * initially constructing the menu control. 205 * initially constructing the menu control.
206 */ 206 */
207 void addColor( const QColor& color, int row, int col ); 207 void addColor( const QColor& color, int row, int col );
208 208
209signals: 209signals:
210 210
211/** 211/**
212 * @fn colorSelected( const QColor& color ) 212 * @fn colorSelected( const QColor& color )
213 * @brief Signal to indicate color chosen from the menu. 213 * @brief Signal to indicate color chosen from the menu.
214 * 214 *
215 * @param color Color selected from the menu. 215 * @param color Color selected from the menu.
216 * 216 *
217 * This signal is emitted when a color has been selected either directly from 217 * This signal is emitted when a color has been selected either directly from
218 * the menu, or chosen from the color selection dialog. 218 * the menu, or chosen from the color selection dialog.
219 */ 219 */
220 void colorSelected( const QColor& color ); 220 void colorSelected( const QColor& color );
221 221
222protected slots: 222protected slots:
223 223
224/** 224/**
225 * @fn buttonSelected( const QColor& color ) 225 * @fn buttonSelected( const QColor& color )
226 * @brief Slot to process selected color. 226 * @brief Slot to process selected color.
227 * 227 *
228 * @param color Color selected from the menu. 228 * @param color Color selected from the menu.
229 * 229 *
230 * @see colorSelected() 230 * @see colorSelected()
231 * 231 *
232 * This slot executes when a color has been selected from the menu. It performs 232 * This slot executes when a color has been selected from the menu. It performs
233 * two functions: 233 * two functions:
234 * - Emit the colorSelected signal with the color selected. 234 * - Emit the colorSelected signal with the color selected.
235 * - Hide the menu. 235 * - Hide the menu.
236 */ 236 */
237 void buttonSelected( const QColor& color ); 237 void buttonSelected( const QColor& color );
238 238
239/** 239/**
240 * @fn moreColorClicked() 240 * @fn moreColorClicked()
241 * @brief Slot to process display color selection dialog. 241 * @brief Slot to process display color selection dialog.
242 * 242 *
243 * @see colorSelected() 243 * @see colorSelected()
244 * 244 *
245 * This slot executes when the 'More...' option is selected at the bottom of the menu. 245 * This slot executes when the 'More...' option is selected at the bottom of the menu.
246 * It performs the following functions: 246 * It performs the following functions:
247 * - Constructs and executes a OColorDialog to allow finer color selection. 247 * - Constructs and executes a OColorDialog to allow finer color selection.
248 * - Emit the colorSelected signal with the color selected. 248 * - Emit the colorSelected signal with the color selected.
249 * - Hide the menu. 249 * - Hide the menu.
250 */ 250 */
251 void moreColorClicked(); 251 void moreColorClicked();
252}; 252};
253 253
254#endif // COLORPOPUPMENUANEL_H 254#endif // COLORPOPUPMENUANEL_H
diff --git a/libopie/ocheckitem.cpp b/libopie/ocheckitem.cpp
index d6ddc79..082d7a2 100644
--- a/libopie/ocheckitem.cpp
+++ b/libopie/ocheckitem.cpp
@@ -1,75 +1,106 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de 2** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU Library General Public License version 2 as published by the 5** GNU Library General Public License version 2 as published by the
6** Free Software Foundation and appearing in the file LICENSE.GPL 6** Free Software Foundation and appearing in the file LICENSE.GPL
7** included in the packaging of this file. 7** included in the packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11**********************************************************************/ 11**********************************************************************/
12 12
13#include <qpainter.h> 13#include <qpainter.h>
14 14
15#include "ocheckitem.h" 15#include "ocheckitem.h"
16 16
17/**
18 * Constructs an CheckItem with a QTable as parent
19 * and a sort key for.
20 * The sort key will be used by QTable to sort the table later
21 * @param t The parent QTable where the check item belongs
22 * @param key A sort key
23 */
17OCheckItem::OCheckItem( QTable *t, const QString &key ) 24OCheckItem::OCheckItem( QTable *t, const QString &key )
18 : QTableItem( t, Never, "" ), m_checked( FALSE ), m_sortKey( key ) 25 : QTableItem( t, Never, "" ), m_checked( FALSE ), m_sortKey( key )
19{ 26{
20} 27}
21 28
29/**
30 * reimplemted for internal reasons
31 * @return Returns the sort key of the Item
32 * @see QTableItem
33 */
22QString OCheckItem::key() const 34QString OCheckItem::key() const
23{ 35{
24 return m_sortKey; 36 return m_sortKey;
25} 37}
26 38
39/**
40 * This method can check or uncheck the item. It will
41 * call QTable to update the cell.
42 *
43 * @param b Whether to check or uncheck the item
44 */
27void OCheckItem::setChecked( bool b ) 45void OCheckItem::setChecked( bool b )
28{ 46{
29 m_checked = b; 47 m_checked = b;
30 table()->updateCell( row(), col() ); 48 table()->updateCell( row(), col() );
31} 49}
32 50
51/**
52 * This will toggle the item. If it is checked it'll get
53 * unchecked by this method or vice versa.
54 */
33void OCheckItem::toggle() 55void OCheckItem::toggle()
34{ 56{
35 m_checked = !m_checked; 57 m_checked = !m_checked;
36} 58}
37 59
60/**
61 * This will return the state of the item.
62 *
63 * @return Returns true if the item is checked
64 */
38bool OCheckItem::isChecked() const 65bool OCheckItem::isChecked() const
39{ 66{
40 return m_checked; 67 return m_checked;
41} 68}
42 69
70/**
71 * @internal
72 * This paints the item
73 */
43void OCheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, 74void OCheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr,
44 bool ) 75 bool )
45{ 76{
46 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 77 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
47 78
48 int marg = ( cr.width() - BoxSize ) / 2; 79 int marg = ( cr.width() - BoxSize ) / 2;
49 int x = 0; 80 int x = 0;
50 int y = ( cr.height() - BoxSize ) / 2; 81 int y = ( cr.height() - BoxSize ) / 2;
51 p->setPen( QPen( cg.text() ) ); 82 p->setPen( QPen( cg.text() ) );
52 p->drawRect( x + marg, y, BoxSize, BoxSize ); 83 p->drawRect( x + marg, y, BoxSize, BoxSize );
53 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 84 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
54 p->setPen( darkGreen ); 85 p->setPen( darkGreen );
55 x += 1; 86 x += 1;
56 y += 1; 87 y += 1;
57 if ( m_checked ) { 88 if ( m_checked ) {
58 QPointArray a( 7*2 ); 89 QPointArray a( 7*2 );
59 int i, xx, yy; 90 int i, xx, yy;
60 xx = x+1+marg; 91 xx = x+1+marg;
61 yy = y+2; 92 yy = y+2;
62 for ( i=0; i<3; i++ ) { 93 for ( i=0; i<3; i++ ) {
63 a.setPoint( 2*i, xx, yy ); 94 a.setPoint( 2*i, xx, yy );
64 a.setPoint( 2*i+1, xx, yy+2 ); 95 a.setPoint( 2*i+1, xx, yy+2 );
65 xx++; yy++; 96 xx++; yy++;
66 } 97 }
67 yy -= 2; 98 yy -= 2;
68 for ( i=3; i<7; i++ ) { 99 for ( i=3; i<7; i++ ) {
69 a.setPoint( 2*i, xx, yy ); 100 a.setPoint( 2*i, xx, yy );
70 a.setPoint( 2*i+1, xx, yy+2 ); 101 a.setPoint( 2*i+1, xx, yy+2 );
71 xx++; yy--; 102 xx++; yy--;
72 } 103 }
73 p->drawLineSegments( a ); 104 p->drawLineSegments( a );
74 } 105 }
75} 106}
diff --git a/libopie/ocheckitem.h b/libopie/ocheckitem.h
index 7885032..2387134 100644
--- a/libopie/ocheckitem.h
+++ b/libopie/ocheckitem.h
@@ -1,41 +1,53 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) 2** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de)
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU Library General Public License version 2 as published by the 5** GNU Library General Public License version 2 as published by the
6** Free Software Foundation and appearing in the file LICENSE.GPL 6** Free Software Foundation and appearing in the file LICENSE.GPL
7** included in the packaging of this file. 7** included in the packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11**********************************************************************/ 11**********************************************************************/
12#include <qtable.h> 12#include <qtable.h>
13 13
14#ifndef CHECKITEM_H__ 14#ifndef CHECKITEM_H__
15#define CHECKITEM_H__ 15#define CHECKITEM_H__
16 16
17/**
18 * This class represents a checkable QTableItem. This can
19 * be added to any QTable.
20 *
21 *
22 * @see QTable
23 * @see QTableItem
24 * @short An checkable QTableItem
25 * @version 1.0
26 * @author Stefan Eilers ( eilers@handhelds.org )
27 */
28
17class OCheckItem : public QTableItem 29class OCheckItem : public QTableItem
18{ 30{
19public: 31public:
20 enum Size { BoxSize = 10 }; 32 enum Size { BoxSize = 10 };
21 OCheckItem( QTable *t, const QString &sortkey ); 33 OCheckItem( QTable *t, const QString &sortkey );
22 34
23 virtual void setChecked( bool b ); 35 virtual void setChecked( bool b );
24 virtual void toggle(); 36 virtual void toggle();
25 bool isChecked() const; 37 bool isChecked() const;
26 void setKey( const QString &key ) { m_sortKey = key; } 38 void setKey( const QString &key ) { m_sortKey = key; }
27 virtual QString key() const; 39 virtual QString key() const;
28 40
29 void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); 41 void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected );
30 42
31 //static const int BoxSize = 10; 43 //static const int BoxSize = 10;
32 44
33private: 45private:
34 class OCheckItemPrivate; 46 class OCheckItemPrivate;
35 OCheckItemPrivate *d; 47 OCheckItemPrivate *d;
36 bool m_checked: 1; 48 bool m_checked: 1;
37 QString m_sortKey; 49 QString m_sortKey;
38 50
39}; 51};
40 52
41#endif 53#endif
diff --git a/libopie/oclickablelabel.cpp b/libopie/oclickablelabel.cpp
index 5768529..bc7037b 100644
--- a/libopie/oclickablelabel.cpp
+++ b/libopie/oclickablelabel.cpp
@@ -1,88 +1,117 @@
1#include "oclickablelabel.h" 1#include "oclickablelabel.h"
2#include <stdio.h> 2#include <stdio.h>
3 3
4OClickableLabel::OClickableLabel(QWidget* parent, 4/**
5 const char* name, 5 * This constructs the clickable ButtonLabel
6 *
7 * @param parent The parent of this label
8 * @param name A name of this label @see QObject
9 * @param fl The windowing flags
10 */
11OClickableLabel::OClickableLabel(QWidget* parent,
12 const char* name,
6 WFlags fl) : 13 WFlags fl) :
7 QLabel(parent,name,fl) 14 QLabel(parent,name,fl)
8{ 15{
9 textInverted=false; 16 textInverted=false;
10 isToggle=false; 17 isToggle=false;
11 isDown=false; 18 isDown=false;
12 showState(false); 19 showState(false);
13 setFrameShadow(Sunken); 20 setFrameShadow(Sunken);
14} 21}
15 22
23/**
24 * This method makes the label behave as a toggle button
25 *
26 * @param t Whether or not to behave like a toggle button
27 */
16void OClickableLabel::setToggleButton(bool t) { 28void OClickableLabel::setToggleButton(bool t) {
17 isToggle=t; 29 isToggle=t;
18} 30}
19 31
32/**
33 * @internal
34 */
20void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ ) { 35void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ ) {
21 if (isToggle && isDown) { 36 if (isToggle && isDown) {
22 showState(false); 37 showState(false);
23 } else { 38 } else {
24 showState(true); 39 showState(true);
25 } 40 }
26} 41}
27 42
43/**
44 * @internal
45 */
28void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) { 46void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) {
29 if (rect().contains(e->pos()) && isToggle) isDown=!isDown; 47 if (rect().contains(e->pos()) && isToggle) isDown=!isDown;
30 48
31 if (isToggle && isDown) { 49 if (isToggle && isDown) {
32 showState(true); 50 showState(true);
33 } else { 51 } else {
34 showState(false); 52 showState(false);
35 } 53 }
36 54
37 if (rect().contains(e->pos())) { 55 if (rect().contains(e->pos())) {
38 if (isToggle) { 56 if (isToggle) {
39 emit toggled(isDown); 57 emit toggled(isDown);
40 } 58 }
41 emit clicked(); 59 emit clicked();
42 } 60 }
43} 61}
44 62
63/**
64 * @internal
65 */
45void OClickableLabel::mouseMoveEvent( QMouseEvent *e ) { 66void OClickableLabel::mouseMoveEvent( QMouseEvent *e ) {
46 if (rect().contains(e->pos())) { 67 if (rect().contains(e->pos())) {
47 if (isToggle && isDown) { 68 if (isToggle && isDown) {
48 showState(false); 69 showState(false);
49 } else { 70 } else {
50 showState(true); 71 showState(true);
51 } 72 }
52 } else { 73 } else {
53 if (isToggle && isDown) { 74 if (isToggle && isDown) {
54 showState(true); 75 showState(true);
55 } else { 76 } else {
56 showState(false); 77 showState(false);
57 } 78 }
58 } 79 }
59} 80}
60 81
82/**
83 * this toggles the label and inverts the color of
84 * the label
85 * @param on
86 */
61void OClickableLabel::showState(bool on) { 87void OClickableLabel::showState(bool on) {
62 if (on) { 88 if (on) {
63 //setFrameShape(Panel); 89 //setFrameShape(Panel);
64 setInverted(true); 90 setInverted(true);
65 setBackgroundMode(PaletteHighlight); 91 setBackgroundMode(PaletteHighlight);
66 } else { 92 } else {
67 //setFrameShape(NoFrame); 93 //setFrameShape(NoFrame);
68 setInverted(false); 94 setInverted(false);
69 setBackgroundMode(PaletteBackground); 95 setBackgroundMode(PaletteBackground);
70 } 96 }
71 repaint(); 97 repaint();
72} 98}
73 99
74void OClickableLabel::setInverted(bool on) { 100void OClickableLabel::setInverted(bool on) {
75 if ( (!textInverted && on) || (textInverted && !on) ) { 101 if ( (!textInverted && on) || (textInverted && !on) ) {
76 QPalette pal=palette(); 102 QPalette pal=palette();
77 QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground); 103 QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground);
78 col.setRgb(255-col.red(),255-col.green(),255-col.blue()); 104 col.setRgb(255-col.red(),255-col.green(),255-col.blue());
79 pal.setColor(QPalette::Normal, QColorGroup::Foreground, col); 105 pal.setColor(QPalette::Normal, QColorGroup::Foreground, col);
80 setPalette(pal); 106 setPalette(pal);
81 textInverted=!textInverted; 107 textInverted=!textInverted;
82 } 108 }
83} 109}
84 110
111/**
112 * @param on if the Label is down or up
113 */
85void OClickableLabel::setOn(bool on) { 114void OClickableLabel::setOn(bool on) {
86 isDown=on; 115 isDown=on;
87 showState(isDown); 116 showState(isDown);
88} 117}
diff --git a/libopie/oclickablelabel.h b/libopie/oclickablelabel.h
index f65c440..4b6dcbc 100644
--- a/libopie/oclickablelabel.h
+++ b/libopie/oclickablelabel.h
@@ -1,30 +1,53 @@
1#ifndef CLICKABLELABEL 1#ifndef CLICKABLELABEL
2#define CLICKABLELABEL 2#define CLICKABLELABEL
3 3
4#include <qlabel.h> 4#include <qlabel.h>
5 5
6class OClickableLabel: public QLabel 6/**
7 * This class is a special QLabel which can behave
8 * as a QPushButton or QToggleButton.
9 * The reason to use a clickable is if you want to save space
10 * or you want to skip the border of a normal button
11 *
12 * <pre>
13 * QLabel* lbl = new OClickableLabel( parent, "PushLabel" );
14 * lbl->setPixmap( "config" );
15 * QWhatsThis::add( lbl, tr("Click here to do something") );
16 * </pre>
17 *
18 * @short A Label behaving as button
19 * @author Hakan Ardo, Maximillian Reiß ( harlekin@handhelds.org )
20 * @see QLabel
21 * @see QPushButton
22 * @see QToggleButton
23 * @version 1.0
24 */
25
26class OClickableLabel: public QLabel
7{ 27{
8 Q_OBJECT 28 Q_OBJECT
9public: 29public:
10 OClickableLabel(QWidget* parent = 0, const char* name = 0, 30 OClickableLabel(QWidget* parent = 0, const char* name = 0,
11 WFlags fl = 0); 31 WFlags fl = 0);
12 void setToggleButton(bool t); 32 void setToggleButton(bool t);
33
13 protected: 34 protected:
14 void mousePressEvent( QMouseEvent *e ); 35 void mousePressEvent( QMouseEvent *e );
15 void mouseReleaseEvent( QMouseEvent *e ); 36 void mouseReleaseEvent( QMouseEvent *e );
16 void mouseMoveEvent( QMouseEvent *e ); 37 void mouseMoveEvent( QMouseEvent *e );
38
17 public slots: 39 public slots:
18 void setOn(bool on); 40 void setOn(bool on);
19 signals: 41 signals:
20 void clicked(); 42 void clicked();
21 void toggled(bool on); 43 void toggled(bool on);
22 private: 44 private:
23 bool isToggle; 45 bool isToggle : 1;
24 bool isDown; 46 bool isDown : 1;
47 bool textInverted : 1;
48
25 void showState(bool on); 49 void showState(bool on);
26 bool textInverted;
27 void setInverted(bool on); 50 void setInverted(bool on);
28}; 51};
29 52
30#endif 53#endif
diff --git a/libopie/ocolorbutton.cpp b/libopie/ocolorbutton.cpp
index ddb6c4f..113a77a 100644
--- a/libopie/ocolorbutton.cpp
+++ b/libopie/ocolorbutton.cpp
@@ -1,121 +1,142 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 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 <opie/colorpopupmenu.h> 29#include <opie/colorpopupmenu.h>
30#include <opie/ocolorbutton.h> 30#include <opie/ocolorbutton.h>
31#include <qcolor.h> 31#include <qcolor.h>
32#include <qpixmap.h> 32#include <qpixmap.h>
33#include <qimage.h> 33#include <qimage.h>
34 34
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36 36
37class OColorButtonPrivate { 37struct OColorButtonPrivate {
38public: 38 QPopupMenu *m_menu;
39 QPopupMenu *m_menu; 39 QColor m_color;
40 QColor m_color;
41}; 40};
42 41
42
43/**
44 * This concstructs a Color Button with @param color as the start color
45 * It'll use a OColorPopupMenu internally
46 *
47 * @param parent The parent of the Color Button
48 * @param color The color from where to start on
49 * @param name @see QObject
50 */
43OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name ) 51OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name )
44 : QPushButton ( parent, name ) 52 : QPushButton ( parent, name )
45{ 53{
46 d = new OColorButtonPrivate; 54 d = new OColorButtonPrivate;
47 55
48 d-> m_menu = new ColorPopupMenu ( color, 0, 0 ); 56 d-> m_menu = new OColorPopupMenu ( color, 0, 0 );
49 setPopup ( d-> m_menu ); 57 setPopup ( d-> m_menu );
50 //setPopupDelay ( 0 ); 58 //setPopupDelay ( 0 );
51 connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & ))); 59 connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & )));
52 60
53 updateColor ( color ); 61 updateColor ( color );
54 62
55 QSize s = sizeHint ( ) + QSize ( 12, 0 ); 63 QSize s = sizeHint ( ) + QSize ( 12, 0 );
56 setMinimumSize ( s ); 64 setMinimumSize ( s );
57 setMaximumSize ( s. width ( ) * 2, s. height ( )); 65 setMaximumSize ( s. width ( ) * 2, s. height ( ));
58} 66}
59 67
68/**
69 * This destructs the object
70 */
60OColorButton::~OColorButton ( ) 71OColorButton::~OColorButton ( )
61{ 72{
62 delete d; 73 delete d;
63} 74}
64 75
76/**
77 * @return Returns the current color of the button
78 */
65QColor OColorButton::color ( ) const 79QColor OColorButton::color ( ) const
66{ 80{
67 return d-> m_color; 81 return d-> m_color;
68} 82}
69 83
84/**
85 * This method sets the color of the button
86 * @param c The color to be set.
87 */
70void OColorButton::setColor ( const QColor &c ) 88void OColorButton::setColor ( const QColor &c )
71{ 89{
72 updateColor ( c ); 90 updateColor ( c );
73} 91}
74 92
93/**
94 * @internal
95 */
75void OColorButton::updateColor ( const QColor &c ) 96void OColorButton::updateColor ( const QColor &c )
76{ 97{
77 d-> m_color = c; 98 d-> m_color = c;
78 99
79 QImage img ( 16, 16, 32 ); 100 QImage img ( 16, 16, 32 );
80 img. fill ( 0 ); 101 img. fill ( 0 );
81 102
82 int r, g, b; 103 int r, g, b;
83 c. rgb ( &r, &g, &b ); 104 c. rgb ( &r, &g, &b );
84 105
85 int w = img. width ( ); 106 int w = img. width ( );
86 int h = img. height ( ); 107 int h = img. height ( );
87 108
88 int dx = w * 20 / 100; // 15% 109 int dx = w * 20 / 100; // 15%
89 int dy = h * 20 / 100; 110 int dy = h * 20 / 100;
90 111
91 for ( int y = 0; y < h; y++ ) { 112 for ( int y = 0; y < h; y++ ) {
92 for ( int x = 0; x < w; x++ ) { 113 for ( int x = 0; x < w; x++ ) {
93 double alpha = 1.0; 114 double alpha = 1.0;
94 115
95 if ( x < dx ) 116 if ( x < dx )
96 alpha *= ( double ( x + 1 ) / dx ); 117 alpha *= ( double ( x + 1 ) / dx );
97 else if ( x >= w - dx ) 118 else if ( x >= w - dx )
98 alpha *= ( double ( w - x ) / dx ); 119 alpha *= ( double ( w - x ) / dx );
99 if ( y < dy ) 120 if ( y < dy )
100 alpha *= ( double ( y + 1 ) / dy ); 121 alpha *= ( double ( y + 1 ) / dy );
101 else if ( y >= h - dy ) 122 else if ( y >= h - dy )
102 alpha *= ( double ( h - y ) / dy ); 123 alpha *= ( double ( h - y ) / dy );
103 124
104 int a = int ( alpha * 255.0 ); 125 int a = int ( alpha * 255.0 );
105 if ( a < 0 ) 126 if ( a < 0 )
106 a = 0; 127 a = 0;
107 if ( a > 255 ) 128 if ( a > 255 )
108 a = 255; 129 a = 255;
109 130
110 img. setPixel ( x, y, qRgba ( r, g, b, a )); 131 img. setPixel ( x, y, qRgba ( r, g, b, a ));
111 } 132 }
112 } 133 }
113 img. setAlphaBuffer ( true ); 134 img. setAlphaBuffer ( true );
114 135
115 QPixmap pix; 136 QPixmap pix;
116 pix. convertFromImage ( img ); 137 pix. convertFromImage ( img );
117 setPixmap ( pix ); 138 setPixmap ( pix );
118 139
119 emit colorSelected ( c ); 140 emit colorSelected ( c );
120} 141}
121 142
diff --git a/libopie/ocolorbutton.h b/libopie/ocolorbutton.h
index fe40fae..338e654 100644
--- a/libopie/ocolorbutton.h
+++ b/libopie/ocolorbutton.h
@@ -1,59 +1,66 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef __OPIE_OCOLORBUTTON_H__ 29#ifndef __OPIE_OCOLORBUTTON_H__
30#define __OPIE_OCOLORBUTTON_H__ 30#define __OPIE_OCOLORBUTTON_H__
31 31
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33 33
34class OColorButtonPrivate; 34class OColorButtonPrivate;
35class QColor; 35class QColor;
36 36
37/**
38 *
39 * @short A Button which will show a OColorPopupMenu
40 * @author Robert Griebl ( sandman@handhelds.org )
41 * @version 1.0
42 * @see QPushButton
43 */
37class OColorButton : public QPushButton { 44class OColorButton : public QPushButton {
38 Q_OBJECT 45 Q_OBJECT
39public: 46public:
40 OColorButton ( QWidget *parent = 0, const QColor & = black, const char *name = 0 ); 47 OColorButton ( QWidget *parent = 0, const QColor & = black, const char *name = 0 );
41 virtual ~OColorButton ( ); 48 virtual ~OColorButton ( );
42 49
43 QColor color ( ) const; 50 QColor color ( ) const;
44 51
45signals: 52signals:
46 void colorSelected ( const QColor & ); 53 void colorSelected ( const QColor & );
47 54
48public slots: 55public slots:
49 virtual void setColor ( const QColor & ); 56 virtual void setColor ( const QColor & );
50 57
51 protected slots: 58protected slots:
52 virtual void updateColor ( const QColor & ); 59 virtual void updateColor ( const QColor & );
53 60
54private: 61private:
55 OColorButtonPrivate *d; 62 OColorButtonPrivate *d;
56 }; 63};
57 64
58#endif 65#endif
59 66
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9b2a954..8f954b1 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,885 +1,981 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <signal.h> 24#include <signal.h>
25#include <sys/time.h> 25#include <sys/time.h>
26#include <linux/soundcard.h> 26#include <linux/soundcard.h>
27#include <math.h> 27#include <math.h>
28 28
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37 37
38#include "odevice.h" 38#include "odevice.h"
39 39
40#include <qwindowsystem_qws.h> 40#include <qwindowsystem_qws.h>
41 41
42 42
43// _IO and friends are only defined in kernel headers ... 43// _IO and friends are only defined in kernel headers ...
44 44
45#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 45#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
46 46
47#define OD_IO(type,number) OD_IOC(0,type,number,0) 47#define OD_IO(type,number) OD_IOC(0,type,number,0)
48#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 48#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
49#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 49#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
51 51
52using namespace Opie; 52using namespace Opie;
53 53
54class ODeviceData { 54class ODeviceData {
55public: 55public:
56 bool m_qwsserver; 56 bool m_qwsserver : 1;
57 57
58 QString m_vendorstr; 58 QString m_vendorstr;
59 OVendor m_vendor; 59 OVendor m_vendor;
60 60
61 QString m_modelstr; 61 QString m_modelstr;
62 OModel m_model; 62 OModel m_model;
63 63
64 QString m_systemstr; 64 QString m_systemstr;
65 OSystem m_system; 65 OSystem m_system;
66 66
67 QString m_sysverstr; 67 QString m_sysverstr;
68 68
69 Transformation m_rotation; 69 Transformation m_rotation;
70 70
71 QValueList <ODeviceButton> *m_buttons; 71 QValueList <ODeviceButton> *m_buttons;
72 uint m_holdtime; 72 uint m_holdtime;
73}; 73};
74 74
75 75
76class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 76class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
77protected: 77protected:
78 virtual void init ( ); 78 virtual void init ( );
79 virtual void initButtons ( ); 79 virtual void initButtons ( );
80 80
81public: 81public:
82 virtual bool setSoftSuspend ( bool soft ); 82 virtual bool setSoftSuspend ( bool soft );
83 83
84 virtual bool setDisplayBrightness ( int b ); 84 virtual bool setDisplayBrightness ( int b );
85 virtual int displayBrightnessResolution ( ) const; 85 virtual int displayBrightnessResolution ( ) const;
86 86
87 virtual void alarmSound ( ); 87 virtual void alarmSound ( );
88 88
89 virtual QValueList <OLed> ledList ( ) const; 89 virtual QValueList <OLed> ledList ( ) const;
90 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 90 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
91 virtual OLedState ledState ( OLed led ) const; 91 virtual OLedState ledState ( OLed led ) const;
92 virtual bool setLedState ( OLed led, OLedState st ); 92 virtual bool setLedState ( OLed led, OLedState st );
93 93
94 virtual bool hasLightSensor ( ) const; 94 virtual bool hasLightSensor ( ) const;
95 virtual int readLightSensor ( ); 95 virtual int readLightSensor ( );
96 virtual int lightSensorResolution ( ) const; 96 virtual int lightSensorResolution ( ) const;
97 97
98protected: 98protected:
99 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 99 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
100 virtual void timerEvent ( QTimerEvent *te ); 100 virtual void timerEvent ( QTimerEvent *te );
101 101
102 int m_power_timer; 102 int m_power_timer;
103 103
104 OLedState m_leds [2]; 104 OLedState m_leds [2];
105}; 105};
106 106
107class Zaurus : public ODevice { 107class Zaurus : public ODevice {
108protected: 108protected:
109 virtual void init ( ); 109 virtual void init ( );
110 virtual void initButtons ( ); 110 virtual void initButtons ( );
111 111
112public: 112public:
113 virtual bool setSoftSuspend ( bool soft ); 113 virtual bool setSoftSuspend ( bool soft );
114 114
115 virtual bool setDisplayBrightness ( int b ); 115 virtual bool setDisplayBrightness ( int b );
116 virtual int displayBrightnessResolution ( ) const; 116 virtual int displayBrightnessResolution ( ) const;
117 117
118 virtual void alarmSound ( ); 118 virtual void alarmSound ( );
119 virtual void keySound ( ); 119 virtual void keySound ( );
120 virtual void touchSound ( ); 120 virtual void touchSound ( );
121 121
122 virtual QValueList <OLed> ledList ( ) const; 122 virtual QValueList <OLed> ledList ( ) const;
123 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 123 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
124 virtual OLedState ledState ( OLed led ) const; 124 virtual OLedState ledState ( OLed led ) const;
125 virtual bool setLedState ( OLed led, OLedState st ); 125 virtual bool setLedState ( OLed led, OLedState st );
126 126
127protected: 127protected:
128 virtual void buzzer ( int snd ); 128 virtual void buzzer ( int snd );
129 129
130 OLedState m_leds [1]; 130 OLedState m_leds [1];
131}; 131};
132 132
133 133
134struct i_button { 134struct i_button {
135 uint model; 135 uint model;
136 Qt::Key code; 136 Qt::Key code;
137 char *utext; 137 char *utext;
138 char *pix; 138 char *pix;
139 char *fpressedservice; 139 char *fpressedservice;
140 char *fpressedaction; 140 char *fpressedaction;
141 char *fheldservice; 141 char *fheldservice;
142 char *fheldaction; 142 char *fheldaction;
143} ipaq_buttons [] = { 143} ipaq_buttons [] = {
144 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 144 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
145 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 145 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
146 "devicebuttons/ipaq_calendar", 146 "devicebuttons/ipaq_calendar",
147 "datebook", "nextView()", 147 "datebook", "nextView()",
148 "today", "raise()" }, 148 "today", "raise()" },
149 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 149 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
150 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 150 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
151 "devicebuttons/ipaq_contact", 151 "devicebuttons/ipaq_contact",
152 "addressbook", "raise()", 152 "addressbook", "raise()",
153 "addressbook", "beamBusinessCard()" }, 153 "addressbook", "beamBusinessCard()" },
154 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 154 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
155 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 155 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
156 "devicebuttons/ipaq_menu", 156 "devicebuttons/ipaq_menu",
157 "QPE/TaskBar", "toggleMenu()", 157 "QPE/TaskBar", "toggleMenu()",
158 "QPE/TaskBar", "toggleStartMenu()" }, 158 "QPE/TaskBar", "toggleStartMenu()" },
159 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 159 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
160 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 160 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
161 "devicebuttons/ipaq_mail", 161 "devicebuttons/ipaq_mail",
162 "mail", "raise()", 162 "mail", "raise()",
163 "mail", "newMail()" }, 163 "mail", "newMail()" },
164 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 164 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
165 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 165 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
166 "devicebuttons/ipaq_home", 166 "devicebuttons/ipaq_home",
167 "QPE/Launcher", "home()", 167 "QPE/Launcher", "home()",
168 "buttonsettings", "raise()" }, 168 "buttonsettings", "raise()" },
169 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 169 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
170 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 170 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
171 "devicebuttons/ipaq_record", 171 "devicebuttons/ipaq_record",
172 "QPE/VMemo", "toggleRecord()", 172 "QPE/VMemo", "toggleRecord()",
173 "sound", "raise()" }, 173 "sound", "raise()" },
174}; 174};
175 175
176struct z_button { 176struct z_button {
177 Qt::Key code; 177 Qt::Key code;
178 char *utext; 178 char *utext;
179 char *pix; 179 char *pix;
180 char *fpressedservice; 180 char *fpressedservice;
181 char *fpressedaction; 181 char *fpressedaction;
182 char *fheldservice; 182 char *fheldservice;
183 char *fheldaction; 183 char *fheldaction;
184} z_buttons [] = { 184} z_buttons [] = {
185 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 185 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
186 "devicebuttons/z_calendar", 186 "devicebuttons/z_calendar",
187 "datebook", "nextView()", 187 "datebook", "nextView()",
188 "today", "raise()" }, 188 "today", "raise()" },
189 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 189 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
190 "devicebuttons/z_contact", 190 "devicebuttons/z_contact",
191 "addressbook", "raise()", 191 "addressbook", "raise()",
192 "addressbook", "beamBusinessCard()" }, 192 "addressbook", "beamBusinessCard()" },
193 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 193 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
194 "devicebuttons/z_home", 194 "devicebuttons/z_home",
195 "QPE/Launcher", "home()", 195 "QPE/Launcher", "home()",
196 "buttonsettings", "raise()" }, 196 "buttonsettings", "raise()" },
197 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 197 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
198 "devicebuttons/z_menu", 198 "devicebuttons/z_menu",
199 "QPE/TaskBar", "toggleMenu()", 199 "QPE/TaskBar", "toggleMenu()",
200 "QPE/TaskBar", "toggleStartMenu()" }, 200 "QPE/TaskBar", "toggleStartMenu()" },
201 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 201 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
202 "devicebuttons/z_mail", 202 "devicebuttons/z_mail",
203 "mail", "raise()", 203 "mail", "raise()",
204 "mail", "newMail()" }, 204 "mail", "newMail()" },
205}; 205};
206 206
207static QCString makeChannel ( const char *str ) 207static QCString makeChannel ( const char *str )
208{ 208{
209 if ( str && !::strchr ( str, '/' )) 209 if ( str && !::strchr ( str, '/' ))
210 return QCString ( "QPE/Application/" ) + str; 210 return QCString ( "QPE/Application/" ) + str;
211 else 211 else
212 return str; 212 return str;
213} 213}
214 214
215 215
216 216
217 217
218ODevice *ODevice::inst ( ) 218ODevice *ODevice::inst ( )
219{ 219{
220 static ODevice *dev = 0; 220 static ODevice *dev = 0;
221 221
222 if ( !dev ) { 222 if ( !dev ) {
223 if ( QFile::exists ( "/proc/hal/model" )) 223 if ( QFile::exists ( "/proc/hal/model" ))
224 dev = new iPAQ ( ); 224 dev = new iPAQ ( );
225 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 225 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
226 dev = new Zaurus ( ); 226 dev = new Zaurus ( );
227 else 227 else
228 dev = new ODevice ( ); 228 dev = new ODevice ( );
229 229
230 dev-> init ( ); 230 dev-> init ( );
231 } 231 }
232 return dev; 232 return dev;
233} 233}
234 234
235 235
236/************************************************** 236/**************************************************
237 * 237 *
238 * common 238 * common
239 * 239 *
240 **************************************************/ 240 **************************************************/
241 241
242 242
243ODevice::ODevice ( ) 243ODevice::ODevice ( )
244{ 244{
245 d = new ODeviceData; 245 d = new ODeviceData;
246 246
247 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 247 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
248 248
249 d-> m_modelstr = "Unknown"; 249 d-> m_modelstr = "Unknown";
250 d-> m_model = Model_Unknown; 250 d-> m_model = Model_Unknown;
251 d-> m_vendorstr = "Unknown"; 251 d-> m_vendorstr = "Unknown";
252 d-> m_vendor = Vendor_Unknown; 252 d-> m_vendor = Vendor_Unknown;
253 d-> m_systemstr = "Unknown"; 253 d-> m_systemstr = "Unknown";
254 d-> m_system = System_Unknown; 254 d-> m_system = System_Unknown;
255 d-> m_sysverstr = "0.0"; 255 d-> m_sysverstr = "0.0";
256 d-> m_rotation = Rot0; 256 d-> m_rotation = Rot0;
257 257
258 d-> m_holdtime = 1000; // 1000ms 258 d-> m_holdtime = 1000; // 1000ms
259 d-> m_buttons = 0; 259 d-> m_buttons = 0;
260} 260}
261 261
262void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 262void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
263{ 263{
264 if ( msg == "deviceButtonMappingChanged()" ) { 264 if ( msg == "deviceButtonMappingChanged()" ) {
265 reloadButtonMapping ( ); 265 reloadButtonMapping ( );
266 } 266 }
267} 267}
268 268
269void ODevice::init ( ) 269void ODevice::init ( )
270{ 270{
271} 271}
272 272
273/**
274 * This method initialises the button mapping
275 */
273void ODevice::initButtons ( ) 276void ODevice::initButtons ( )
274{ 277{
275 if ( d-> m_buttons ) 278 if ( d-> m_buttons )
276 return; 279 return;
277 280
278 // Simulation uses iPAQ 3660 device buttons 281 // Simulation uses iPAQ 3660 device buttons
279 282
280 qDebug ( "init Buttons" ); 283 qDebug ( "init Buttons" );
281 d-> m_buttons = new QValueList <ODeviceButton>; 284 d-> m_buttons = new QValueList <ODeviceButton>;
282 285
283 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 286 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
284 i_button *ib = ipaq_buttons + i; 287 i_button *ib = ipaq_buttons + i;
285 ODeviceButton b; 288 ODeviceButton b;
286 289
287 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 290 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
288 b. setKeycode ( ib-> code ); 291 b. setKeycode ( ib-> code );
289 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 292 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
290 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 293 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
291 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 294 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
292 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 295 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
293 d-> m_buttons-> append ( b ); 296 d-> m_buttons-> append ( b );
294 } 297 }
295 } 298 }
296 reloadButtonMapping ( ); 299 reloadButtonMapping ( );
297 300
298 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 301 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
299 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 302 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
300} 303}
301 304
302ODevice::~ODevice ( ) 305ODevice::~ODevice ( )
303{ 306{
304 delete d; 307 delete d;
305} 308}
306 309
307bool ODevice::setSoftSuspend ( bool /*soft*/ ) 310bool ODevice::setSoftSuspend ( bool /*soft*/ )
308{ 311{
309 return false; 312 return false;
310} 313}
311 314
312//#include <linux/apm_bios.h> 315//#include <linux/apm_bios.h>
313 316
314#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 317#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
315 318
316 319/**
320 * This method will try to suspend the device
321 * It only works if the user is the QWS Server and the apm application
322 * is installed.
323 * It tries to suspend and then waits some time cause some distributions
324 * do have asynchronus apm implementations.
325 * This method will either fail and return false or it'll suspend the
326 * device and return once the device got woken up
327 *
328 * @return if the device got suspended
329 */
317bool ODevice::suspend ( ) 330bool ODevice::suspend ( )
318{ 331{
319 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 332 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
320 return false; 333 return false;
321 334
322 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 335 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
323 return false; 336 return false;
324 337
325 bool res = false; 338 bool res = false;
326 339
327 struct timeval tvs, tvn; 340 struct timeval tvs, tvn;
328 ::gettimeofday ( &tvs, 0 ); 341 ::gettimeofday ( &tvs, 0 );
329 342
330 ::sync ( ); // flush fs caches 343 ::sync ( ); // flush fs caches
331 res = ( ::system ( "apm --suspend" ) == 0 ); 344 res = ( ::system ( "apm --suspend" ) == 0 );
332 345
333 // This is needed because the iPAQ apm implementation is asynchronous and we 346 // This is needed because the iPAQ apm implementation is asynchronous and we
334 // can not be sure when exactly the device is really suspended 347 // can not be sure when exactly the device is really suspended
335 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 348 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
336 349
337 if ( res ) { 350 if ( res ) {
338 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 351 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
339 ::usleep ( 200 * 1000 ); 352 ::usleep ( 200 * 1000 );
340 ::gettimeofday ( &tvn, 0 ); 353 ::gettimeofday ( &tvn, 0 );
341 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 354 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
342 } 355 }
343 356
344 return res; 357 return res;
345} 358}
346 359
347//#include <linux/fb.h> better not rely on kernel headers in userspace ... 360//#include <linux/fb.h> better not rely on kernel headers in userspace ...
348 361
349#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 362#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
350 363
351/* VESA Blanking Levels */ 364/* VESA Blanking Levels */
352#define VESA_NO_BLANKING 0 365#define VESA_NO_BLANKING 0
353#define VESA_VSYNC_SUSPEND 1 366#define VESA_VSYNC_SUSPEND 1
354#define VESA_HSYNC_SUSPEND 2 367#define VESA_HSYNC_SUSPEND 2
355#define VESA_POWERDOWN 3 368#define VESA_POWERDOWN 3
356 369
357 370/**
371 * This sets the display on or off
372 */
358bool ODevice::setDisplayStatus ( bool on ) 373bool ODevice::setDisplayStatus ( bool on )
359{ 374{
360 if ( d-> m_model == Model_Unknown ) 375 if ( d-> m_model == Model_Unknown )
361 return false; 376 return false;
362 377
363 bool res = false; 378 bool res = false;
364 int fd; 379 int fd;
365 380
366 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 381 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
367 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 382 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
368 ::close ( fd ); 383 ::close ( fd );
369 } 384 }
370 return res; 385 return res;
371} 386}
372 387
373bool ODevice::setDisplayBrightness ( int ) 388/**
389 * This sets the display brightness
390 * @return success or failure
391 */
392bool ODevice::setDisplayBrightness ( int p)
374{ 393{
394 Q_UNUSED( p )
375 return false; 395 return false;
376} 396}
377 397
378int ODevice::displayBrightnessResolution ( ) const 398int ODevice::displayBrightnessResolution ( ) const
379{ 399{
380 return 16; 400 return 16;
381} 401}
382 402
403/**
404 * This returns the vendor as string
405 * @return Vendor as QString
406 */
383QString ODevice::vendorString ( ) const 407QString ODevice::vendorString ( ) const
384{ 408{
385 return d-> m_vendorstr; 409 return d-> m_vendorstr;
386} 410}
387 411
412/**
413 * This returns the vendor as one of the values of OVendor
414 * @return OVendor
415 */
388OVendor ODevice::vendor ( ) const 416OVendor ODevice::vendor ( ) const
389{ 417{
390 return d-> m_vendor; 418 return d-> m_vendor;
391} 419}
392 420
421/**
422 * This returns the model as a string
423 * @return A string representing the model
424 */
393QString ODevice::modelString ( ) const 425QString ODevice::modelString ( ) const
394{ 426{
395 return d-> m_modelstr; 427 return d-> m_modelstr;
396} 428}
397 429
430/**
431 * This does return the OModel used
432 */
398OModel ODevice::model ( ) const 433OModel ODevice::model ( ) const
399{ 434{
400 return d-> m_model; 435 return d-> m_model;
401} 436}
402 437
438/**
439 * This does return the systen name
440 */
403QString ODevice::systemString ( ) const 441QString ODevice::systemString ( ) const
404{ 442{
405 return d-> m_systemstr; 443 return d-> m_systemstr;
406} 444}
407 445
446/**
447 * Return System as OSystem value
448 */
408OSystem ODevice::system ( ) const 449OSystem ODevice::system ( ) const
409{ 450{
410 return d-> m_system; 451 return d-> m_system;
411} 452}
412 453
454/**
455 * @return the version string of the base system
456 */
413QString ODevice::systemVersionString ( ) const 457QString ODevice::systemVersionString ( ) const
414{ 458{
415 return d-> m_sysverstr; 459 return d-> m_sysverstr;
416} 460}
417 461
462/**
463 * @return the current Transformation
464 */
418Transformation ODevice::rotation ( ) const 465Transformation ODevice::rotation ( ) const
419{ 466{
420 return d-> m_rotation; 467 return d-> m_rotation;
421} 468}
422 469
470/**
471 * This plays an alarmSound
472 */
423void ODevice::alarmSound ( ) 473void ODevice::alarmSound ( )
424{ 474{
425#ifndef QT_NO_SOUND 475#ifndef QT_NO_SOUND
426 static Sound snd ( "alarm" ); 476 static Sound snd ( "alarm" );
427 477
428 if ( snd. isFinished ( )) 478 if ( snd. isFinished ( ))
429 snd. play ( ); 479 snd. play ( );
430#endif 480#endif
431} 481}
432 482
483/**
484 * This plays a key sound
485 */
433void ODevice::keySound ( ) 486void ODevice::keySound ( )
434{ 487{
435#ifndef QT_NO_SOUND 488#ifndef QT_NO_SOUND
436 static Sound snd ( "keysound" ); 489 static Sound snd ( "keysound" );
437 490
438 if ( snd. isFinished ( )) 491 if ( snd. isFinished ( ))
439 snd. play ( ); 492 snd. play ( );
440#endif 493#endif
441} 494}
442 495
496/**
497 * This plays a touch sound
498 */
443void ODevice::touchSound ( ) 499void ODevice::touchSound ( )
444{ 500{
445 501
446#ifndef QT_NO_SOUND 502#ifndef QT_NO_SOUND
447 static Sound snd ( "touchsound" ); 503 static Sound snd ( "touchsound" );
448 504
449 if ( snd. isFinished ( )) 505 if ( snd. isFinished ( ))
450 snd. play ( ); 506 snd. play ( );
451#endif 507#endif
452} 508}
453 509
454 510/**
511 * This method will return a list of leds
512 * available on this device
513 * @return a list of LEDs.
514 */
455QValueList <OLed> ODevice::ledList ( ) const 515QValueList <OLed> ODevice::ledList ( ) const
456{ 516{
457 return QValueList <OLed> ( ); 517 return QValueList <OLed> ( );
458} 518}
459 519
520/**
521 * This does return the state of the LEDs
522 */
460QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 523QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
461{ 524{
462 return QValueList <OLedState> ( ); 525 return QValueList <OLedState> ( );
463} 526}
464 527
528/**
529 * @return the state for a given OLed
530 */
465OLedState ODevice::ledState ( OLed /*which*/ ) const 531OLedState ODevice::ledState ( OLed /*which*/ ) const
466{ 532{
467 return Led_Off; 533 return Led_Off;
468} 534}
469 535
470bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 536/**
537 * Set the state for a LED
538 * @param which Which OLed to use
539 * @param st The state to set
540 * @return success or failure
541 */
542bool ODevice::setLedState ( OLed which, OLedState st )
471{ 543{
544 Q_UNUSED( which )
545 Q_UNUSED( st )
472 return false; 546 return false;
473} 547}
474 548
549/**
550 * @return if the device has a light sensor
551 */
475bool ODevice::hasLightSensor ( ) const 552bool ODevice::hasLightSensor ( ) const
476{ 553{
477 return false; 554 return false;
478} 555}
479 556
557/**
558 * @return a value from the light senso
559 */
480int ODevice::readLightSensor ( ) 560int ODevice::readLightSensor ( )
481{ 561{
482 return -1; 562 return -1;
483} 563}
484 564
565/**
566 * @return the light sensor resolution whatever that is ;)
567 */
485int ODevice::lightSensorResolution ( ) const 568int ODevice::lightSensorResolution ( ) const
486{ 569{
487 return 0; 570 return 0;
488} 571}
489 572
573/**
574 * @return a list of hardware buttons
575 */
490const QValueList <ODeviceButton> &ODevice::buttons ( ) 576const QValueList <ODeviceButton> &ODevice::buttons ( )
491{ 577{
492 initButtons ( ); 578 initButtons ( );
493 579
494 return *d-> m_buttons; 580 return *d-> m_buttons;
495} 581}
496 582
583/**
584 * @return The amount of time that would count as a hold
585 */
497uint ODevice::buttonHoldTime ( ) const 586uint ODevice::buttonHoldTime ( ) const
498{ 587{
499 return d-> m_holdtime; 588 return d-> m_holdtime;
500} 589}
501 590
591/**
592 * This method return a ODeviceButton for a key code
593 * or 0 if no special hardware button is available for the device
594 *
595 * @return The devicebutton or 0l
596 * @see ODeviceButton
597 */
502const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 598const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
503{ 599{
504 initButtons ( ); 600 initButtons ( );
505 601
506 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 602 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
507 if ( (*it). keycode ( ) == code ) 603 if ( (*it). keycode ( ) == code )
508 return &(*it); 604 return &(*it);
509 } 605 }
510 return 0; 606 return 0;
511} 607}
512 608
513void ODevice::reloadButtonMapping ( ) 609void ODevice::reloadButtonMapping ( )
514{ 610{
515 initButtons ( ); 611 initButtons ( );
516 612
517 Config cfg ( "ButtonSettings" ); 613 Config cfg ( "ButtonSettings" );
518 614
519 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 615 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
520 ODeviceButton &b = ( *d-> m_buttons ) [i]; 616 ODeviceButton &b = ( *d-> m_buttons ) [i];
521 QString group = "Button" + QString::number ( i ); 617 QString group = "Button" + QString::number ( i );
522 618
523 QCString pch, hch; 619 QCString pch, hch;
524 QCString pm, hm; 620 QCString pm, hm;
525 QByteArray pdata, hdata; 621 QByteArray pdata, hdata;
526 622
527 if ( cfg. hasGroup ( group )) { 623 if ( cfg. hasGroup ( group )) {
528 cfg. setGroup ( group ); 624 cfg. setGroup ( group );
529 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 625 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
530 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 626 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
531 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 627 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
532 628
533 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 629 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
534 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 630 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
535 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 631 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
536 } 632 }
537 633
538 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 634 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
539 635
540 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 636 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
541 } 637 }
542} 638}
543 639
544void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 640void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
545{ 641{
546 initButtons ( ); 642 initButtons ( );
547 643
548 QString mb_chan; 644 QString mb_chan;
549 645
550 if ( button >= (int) d-> m_buttons-> count ( )) 646 if ( button >= (int) d-> m_buttons-> count ( ))
551 return; 647 return;
552 648
553 ODeviceButton &b = ( *d-> m_buttons ) [button]; 649 ODeviceButton &b = ( *d-> m_buttons ) [button];
554 b. setPressedAction ( action ); 650 b. setPressedAction ( action );
555 651
556 mb_chan=b. pressedAction ( ). channel ( ); 652 mb_chan=b. pressedAction ( ). channel ( );
557 653
558 Config buttonFile ( "ButtonSettings" ); 654 Config buttonFile ( "ButtonSettings" );
559 buttonFile. setGroup ( "Button" + QString::number ( button )); 655 buttonFile. setGroup ( "Button" + QString::number ( button ));
560 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 656 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
561 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 657 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
562 658
563 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 659 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
564 660
565 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 661 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
566} 662}
567 663
568void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 664void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
569{ 665{
570 initButtons ( ); 666 initButtons ( );
571 667
572 if ( button >= (int) d-> m_buttons-> count ( )) 668 if ( button >= (int) d-> m_buttons-> count ( ))
573 return; 669 return;
574 670
575 ODeviceButton &b = ( *d-> m_buttons ) [button]; 671 ODeviceButton &b = ( *d-> m_buttons ) [button];
576 b. setHeldAction ( action ); 672 b. setHeldAction ( action );
577 673
578 Config buttonFile ( "ButtonSettings" ); 674 Config buttonFile ( "ButtonSettings" );
579 buttonFile. setGroup ( "Button" + QString::number ( button )); 675 buttonFile. setGroup ( "Button" + QString::number ( button ));
580 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 676 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
581 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 677 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
582 678
583 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 679 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
584 680
585 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 681 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
586} 682}
587 683
588 684
589 685
590 686
591/************************************************** 687/**************************************************
592 * 688 *
593 * iPAQ 689 * iPAQ
594 * 690 *
595 **************************************************/ 691 **************************************************/
596 692
597void iPAQ::init ( ) 693void iPAQ::init ( )
598{ 694{
599 d-> m_vendorstr = "HP"; 695 d-> m_vendorstr = "HP";
600 d-> m_vendor = Vendor_HP; 696 d-> m_vendor = Vendor_HP;
601 697
602 QFile f ( "/proc/hal/model" ); 698 QFile f ( "/proc/hal/model" );
603 699
604 if ( f. open ( IO_ReadOnly )) { 700 if ( f. open ( IO_ReadOnly )) {
605 QTextStream ts ( &f ); 701 QTextStream ts ( &f );
606 702
607 d-> m_modelstr = "H" + ts. readLine ( ); 703 d-> m_modelstr = "H" + ts. readLine ( );
608 704
609 if ( d-> m_modelstr == "H3100" ) 705 if ( d-> m_modelstr == "H3100" )
610 d-> m_model = Model_iPAQ_H31xx; 706 d-> m_model = Model_iPAQ_H31xx;
611 else if ( d-> m_modelstr == "H3600" ) 707 else if ( d-> m_modelstr == "H3600" )
612 d-> m_model = Model_iPAQ_H36xx; 708 d-> m_model = Model_iPAQ_H36xx;
613 else if ( d-> m_modelstr == "H3700" ) 709 else if ( d-> m_modelstr == "H3700" )
614 d-> m_model = Model_iPAQ_H37xx; 710 d-> m_model = Model_iPAQ_H37xx;
615 else if ( d-> m_modelstr == "H3800" ) 711 else if ( d-> m_modelstr == "H3800" )
616 d-> m_model = Model_iPAQ_H38xx; 712 d-> m_model = Model_iPAQ_H38xx;
617 else if ( d-> m_modelstr == "H3900" ) 713 else if ( d-> m_modelstr == "H3900" )
618 d-> m_model = Model_iPAQ_H39xx; 714 d-> m_model = Model_iPAQ_H39xx;
619 else 715 else
620 d-> m_model = Model_Unknown; 716 d-> m_model = Model_Unknown;
621 717
622 f. close ( ); 718 f. close ( );
623 } 719 }
624 720
625 switch ( d-> m_model ) { 721 switch ( d-> m_model ) {
626 case Model_iPAQ_H31xx: 722 case Model_iPAQ_H31xx:
627 case Model_iPAQ_H38xx: 723 case Model_iPAQ_H38xx:
628 d-> m_rotation = Rot90; 724 d-> m_rotation = Rot90;
629 break; 725 break;
630 case Model_iPAQ_H36xx: 726 case Model_iPAQ_H36xx:
631 case Model_iPAQ_H37xx: 727 case Model_iPAQ_H37xx:
632 case Model_iPAQ_H39xx: 728 case Model_iPAQ_H39xx:
633 default: 729 default:
634 d-> m_rotation = Rot270; 730 d-> m_rotation = Rot270;
635 break; 731 break;
636 } 732 }
637 733
638 f. setName ( "/etc/familiar-version" ); 734 f. setName ( "/etc/familiar-version" );
639 if ( f. open ( IO_ReadOnly )) { 735 if ( f. open ( IO_ReadOnly )) {
640 d-> m_systemstr = "Familiar"; 736 d-> m_systemstr = "Familiar";
641 d-> m_system = System_Familiar; 737 d-> m_system = System_Familiar;
642 738
643 QTextStream ts ( &f ); 739 QTextStream ts ( &f );
644 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 740 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
645 741
646 f. close ( ); 742 f. close ( );
647 } else { 743 } else {
648 f. setName ( "/etc/oz_version" ); 744 f. setName ( "/etc/oz_version" );
649 745
650 if ( f. open ( IO_ReadOnly )) { 746 if ( f. open ( IO_ReadOnly )) {
651 d-> m_systemstr = "OpenEmbedded/iPaq"; 747 d-> m_systemstr = "OpenEmbedded/iPaq";
652 d-> m_system = System_Familiar; 748 d-> m_system = System_Familiar;
653 749
654 QTextStream ts ( &f ); 750 QTextStream ts ( &f );
655 ts.setDevice ( &f ); 751 ts.setDevice ( &f );
656 d-> m_sysverstr = ts. readLine ( ); 752 d-> m_sysverstr = ts. readLine ( );
657 f. close ( ); 753 f. close ( );
658 } 754 }
659 } 755 }
660 756
661 757
662 758
663 759
664 760
665 m_leds [0] = m_leds [1] = Led_Off; 761 m_leds [0] = m_leds [1] = Led_Off;
666 762
667 m_power_timer = 0; 763 m_power_timer = 0;
668 764
669 if ( d-> m_qwsserver ) 765 if ( d-> m_qwsserver )
670 QWSServer::setKeyboardFilter ( this ); 766 QWSServer::setKeyboardFilter ( this );
671} 767}
672 768
673void iPAQ::initButtons ( ) 769void iPAQ::initButtons ( )
674{ 770{
675 if ( d-> m_buttons ) 771 if ( d-> m_buttons )
676 return; 772 return;
677 773
678 d-> m_buttons = new QValueList <ODeviceButton>; 774 d-> m_buttons = new QValueList <ODeviceButton>;
679 775
680 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 776 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
681 i_button *ib = ipaq_buttons + i; 777 i_button *ib = ipaq_buttons + i;
682 ODeviceButton b; 778 ODeviceButton b;
683 779
684 if (( ib-> model & d-> m_model ) == d-> m_model ) { 780 if (( ib-> model & d-> m_model ) == d-> m_model ) {
685 b. setKeycode ( ib-> code ); 781 b. setKeycode ( ib-> code );
686 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 782 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
687 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 783 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
688 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 784 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
689 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 785 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
690 786
691 d-> m_buttons-> append ( b ); 787 d-> m_buttons-> append ( b );
692 } 788 }
693 } 789 }
694 reloadButtonMapping ( ); 790 reloadButtonMapping ( );
695 791
696 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 792 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
697 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 793 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
698} 794}
699 795
700 796
701//#include <linux/h3600_ts.h> // including kernel headers is evil ... 797//#include <linux/h3600_ts.h> // including kernel headers is evil ...
702 798
703typedef struct { 799typedef struct {
704 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 800 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
705 unsigned char TotalTime; /* Units of 5 seconds */ 801 unsigned char TotalTime; /* Units of 5 seconds */
706 unsigned char OnTime; /* units of 100m/s */ 802 unsigned char OnTime; /* units of 100m/s */
707 unsigned char OffTime; /* units of 100m/s */ 803 unsigned char OffTime; /* units of 100m/s */
708} LED_IN; 804} LED_IN;
709 805
710typedef struct { 806typedef struct {
711 unsigned char mode; 807 unsigned char mode;
712 unsigned char pwr; 808 unsigned char pwr;
713 unsigned char brightness; 809 unsigned char brightness;
714} FLITE_IN; 810} FLITE_IN;
715 811
716#define LED_ON OD_IOW( 'f', 5, LED_IN ) 812#define LED_ON OD_IOW( 'f', 5, LED_IN )
717#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 813#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
718 814
719 815
720QValueList <OLed> iPAQ::ledList ( ) const 816QValueList <OLed> iPAQ::ledList ( ) const
721{ 817{
722 QValueList <OLed> vl; 818 QValueList <OLed> vl;
723 vl << Led_Power; 819 vl << Led_Power;
724 820
725 if ( d-> m_model == Model_iPAQ_H38xx ) 821 if ( d-> m_model == Model_iPAQ_H38xx )
726 vl << Led_BlueTooth; 822 vl << Led_BlueTooth;
727 return vl; 823 return vl;
728} 824}
729 825
730QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 826QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
731{ 827{
732 QValueList <OLedState> vl; 828 QValueList <OLedState> vl;
733 829
734 if ( l == Led_Power ) 830 if ( l == Led_Power )
735 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 831 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
736 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 832 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
737 vl << Led_Off; // << Led_On << ??? 833 vl << Led_Off; // << Led_On << ???
738 834
739 return vl; 835 return vl;
740} 836}
741 837
742OLedState iPAQ::ledState ( OLed l ) const 838OLedState iPAQ::ledState ( OLed l ) const
743{ 839{
744 switch ( l ) { 840 switch ( l ) {
745 case Led_Power: 841 case Led_Power:
746 return m_leds [0]; 842 return m_leds [0];
747 case Led_BlueTooth: 843 case Led_BlueTooth:
748 return m_leds [1]; 844 return m_leds [1];
749 default: 845 default:
750 return Led_Off; 846 return Led_Off;
751 } 847 }
752} 848}
753 849
754bool iPAQ::setLedState ( OLed l, OLedState st ) 850bool iPAQ::setLedState ( OLed l, OLedState st )
755{ 851{
756 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 852 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
757 853
758 if ( l == Led_Power ) { 854 if ( l == Led_Power ) {
759 if ( fd >= 0 ) { 855 if ( fd >= 0 ) {
760 LED_IN leds; 856 LED_IN leds;
761 ::memset ( &leds, 0, sizeof( leds )); 857 ::memset ( &leds, 0, sizeof( leds ));
762 leds. TotalTime = 0; 858 leds. TotalTime = 0;
763 leds. OnTime = 0; 859 leds. OnTime = 0;
764 leds. OffTime = 1; 860 leds. OffTime = 1;
765 leds. OffOnBlink = 2; 861 leds. OffOnBlink = 2;
766 862
767 switch ( st ) { 863 switch ( st ) {
768 case Led_Off : leds. OffOnBlink = 0; break; 864 case Led_Off : leds. OffOnBlink = 0; break;
769 case Led_On : leds. OffOnBlink = 1; break; 865 case Led_On : leds. OffOnBlink = 1; break;
770 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 866 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
771 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 867 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
772 } 868 }
773 869
774 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 870 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
775 m_leds [0] = st; 871 m_leds [0] = st;
776 return true; 872 return true;
777 } 873 }
778 } 874 }
779 } 875 }
780 return false; 876 return false;
781} 877}
782 878
783 879
784bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 880bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
785{ 881{
786 int newkeycode = keycode; 882 int newkeycode = keycode;
787 883
788 switch ( keycode ) { 884 switch ( keycode ) {
789 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 885 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
790 case HardKey_Menu: { 886 case HardKey_Menu: {
791 if (( d-> m_model == Model_iPAQ_H38xx ) || 887 if (( d-> m_model == Model_iPAQ_H38xx ) ||
792 ( d-> m_model == Model_iPAQ_H39xx )) { 888 ( d-> m_model == Model_iPAQ_H39xx )) {
793 newkeycode = HardKey_Mail; 889 newkeycode = HardKey_Mail;
794 } 890 }
795 break; 891 break;
796 } 892 }
797 893
798 // Rotate cursor keys 180° 894 // Rotate cursor keys 180°
799 case Key_Left : 895 case Key_Left :
800 case Key_Right: 896 case Key_Right:
801 case Key_Up : 897 case Key_Up :
802 case Key_Down : { 898 case Key_Down : {
803 if (( d-> m_model == Model_iPAQ_H31xx ) || 899 if (( d-> m_model == Model_iPAQ_H31xx ) ||
804 ( d-> m_model == Model_iPAQ_H38xx )) { 900 ( d-> m_model == Model_iPAQ_H38xx )) {
805 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 901 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
806 } 902 }
807 break; 903 break;
808 } 904 }
809 905
810 // map Power Button short/long press to F34/F35 906 // map Power Button short/long press to F34/F35
811 case Key_SysReq: { 907 case Key_SysReq: {
812 if ( isPress ) { 908 if ( isPress ) {
813 if ( m_power_timer ) 909 if ( m_power_timer )
814 killTimer ( m_power_timer ); 910 killTimer ( m_power_timer );
815 m_power_timer = startTimer ( 500 ); 911 m_power_timer = startTimer ( 500 );
816 } 912 }
817 else if ( m_power_timer ) { 913 else if ( m_power_timer ) {
818 killTimer ( m_power_timer ); 914 killTimer ( m_power_timer );
819 m_power_timer = 0; 915 m_power_timer = 0;
820 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 916 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
821 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 917 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
822 } 918 }
823 newkeycode = Key_unknown; 919 newkeycode = Key_unknown;
824 break; 920 break;
825 } 921 }
826 } 922 }
827 923
828 if ( newkeycode != keycode ) { 924 if ( newkeycode != keycode ) {
829 if ( newkeycode != Key_unknown ) 925 if ( newkeycode != Key_unknown )
830 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 926 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
831 return true; 927 return true;
832 } 928 }
833 else 929 else
834 return false; 930 return false;
835} 931}
836 932
837void iPAQ::timerEvent ( QTimerEvent * ) 933void iPAQ::timerEvent ( QTimerEvent * )
838{ 934{
839 killTimer ( m_power_timer ); 935 killTimer ( m_power_timer );
840 m_power_timer = 0; 936 m_power_timer = 0;
841 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 937 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
842 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 938 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
843} 939}
844 940
845 941
846void iPAQ::alarmSound ( ) 942void iPAQ::alarmSound ( )
847{ 943{
848#ifndef QT_NO_SOUND 944#ifndef QT_NO_SOUND
849 static Sound snd ( "alarm" ); 945 static Sound snd ( "alarm" );
850 int fd; 946 int fd;
851 int vol; 947 int vol;
852 bool vol_reset = false; 948 bool vol_reset = false;
853 949
854 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 950 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
855 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 951 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
856 Config cfg ( "qpe" ); 952 Config cfg ( "qpe" );
857 cfg. setGroup ( "Volume" ); 953 cfg. setGroup ( "Volume" );
858 954
859 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 955 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
860 if ( volalarm < 0 ) 956 if ( volalarm < 0 )
861 volalarm = 0; 957 volalarm = 0;
862 else if ( volalarm > 100 ) 958 else if ( volalarm > 100 )
863 volalarm = 100; 959 volalarm = 100;
864 volalarm |= ( volalarm << 8 ); 960 volalarm |= ( volalarm << 8 );
865 961
866 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 962 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
867 vol_reset = true; 963 vol_reset = true;
868 } 964 }
869 } 965 }
870 966
871 snd. play ( ); 967 snd. play ( );
872 while ( !snd. isFinished ( )) 968 while ( !snd. isFinished ( ))
873 qApp-> processEvents ( ); 969 qApp-> processEvents ( );
874 970
875 if ( fd >= 0 ) { 971 if ( fd >= 0 ) {
876 if ( vol_reset ) 972 if ( vol_reset )
877 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 973 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
878 ::close ( fd ); 974 ::close ( fd );
879 } 975 }
880#endif 976#endif
881} 977}
882 978
883 979
884bool iPAQ::setSoftSuspend ( bool soft ) 980bool iPAQ::setSoftSuspend ( bool soft )
885{ 981{
diff --git a/libopie/odevice.h b/libopie/odevice.h
index ff578d8..45a790b 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,199 +1,222 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _LIBOPIE_ODEVICE_H_ 20#ifndef _LIBOPIE_ODEVICE_H_
21#define _LIBOPIE_ODEVICE_H_ 21#define _LIBOPIE_ODEVICE_H_
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qnamespace.h> 25#include <qnamespace.h>
26 26
27#include <opie/odevicebutton.h> 27#include <opie/odevicebutton.h>
28 28
29#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 29#include <qpe/qpeapplication.h> /* for Transformation enum.. */
30 30
31class ODeviceData; 31class ODeviceData;
32 32
33namespace Opie { 33namespace Opie {
34 34
35/**
36 * The available devices
37 */
35enum OModel { 38enum OModel {
36 Model_Unknown, 39 Model_Unknown, // = 0
37 40
38 Model_Series_Mask = 0xff000000, 41 Model_Series_Mask = 0xff000000,
39 42
40 Model_iPAQ = ( 1 << 24 ), 43 Model_iPAQ = ( 1 << 24 ),
41 44
42 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 45 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
43 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 46 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
44 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 47 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
45 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 48 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
46 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 49 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
47 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 50 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
48 51
49 Model_Zaurus = ( 2 << 24 ), 52 Model_Zaurus = ( 2 << 24 ),
50 53
51 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 54 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
52 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 55 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
53 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 56 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
54 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 57 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
55 Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), 58 Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ),
56}; 59};
57 60
58 enum OVendor { 61/**
62 * The vendor of the device
63 */
64enum OVendor {
59 Vendor_Unknown, 65 Vendor_Unknown,
60 66
61 Vendor_HP, 67 Vendor_HP,
62 Vendor_Sharp 68 Vendor_Sharp
63 }; 69};
64 70
71/**
72 * The System used
73 */
65enum OSystem { 74enum OSystem {
66 System_Unknown, 75 System_Unknown,
67 76
68 System_Familiar, 77 System_Familiar,
69 System_Zaurus, 78 System_Zaurus,
70 System_OpenZaurus 79 System_OpenZaurus
71}; 80};
72 81
73enum OLedState { 82enum OLedState {
74 Led_Off, 83 Led_Off,
75 Led_On, 84 Led_On,
76 Led_BlinkSlow, 85 Led_BlinkSlow,
77 Led_BlinkFast 86 Led_BlinkFast
78}; 87};
79 88
80enum OLed { 89enum OLed {
81 Led_Mail, 90 Led_Mail,
82 Led_Power, 91 Led_Power,
83 Led_BlueTooth 92 Led_BlueTooth
84}; 93};
85 94
86enum OHardKey { 95enum OHardKey {
87 HardKey_Datebook = Qt::Key_F9, 96 HardKey_Datebook = Qt::Key_F9,
88 HardKey_Contacts = Qt::Key_F10, 97 HardKey_Contacts = Qt::Key_F10,
89 HardKey_Menu = Qt::Key_F11, 98 HardKey_Menu = Qt::Key_F11,
90 HardKey_Home = Qt::Key_F12, 99 HardKey_Home = Qt::Key_F12,
91 HardKey_Mail = Qt::Key_F13, 100 HardKey_Mail = Qt::Key_F13,
92 HardKey_Record = Qt::Key_F24, 101 HardKey_Record = Qt::Key_F24,
93 HardKey_Suspend = Qt::Key_F34, 102 HardKey_Suspend = Qt::Key_F34,
94 HardKey_Backlight = Qt::Key_F35, 103 HardKey_Backlight = Qt::Key_F35,
95}; 104};
96 105
106/**
107 * A singleton which gives informations about device specefic option
108 * like the Hardware used, LEDs, the Base Distribution and
109 * hardware key mappings.
110 *
111 *
112 * @short A small class for device specefic options
113 * @see QObject
114 * @author Robert Griebl
115 * @version 1.0
116 */
97class ODevice : public QObject { 117class ODevice : public QObject {
98 Q_OBJECT 118 Q_OBJECT
99 119
100private: 120private:
121 /* disable copy */
101 ODevice ( const ODevice & ); 122 ODevice ( const ODevice & );
102 123
103protected: 124protected:
104 ODevice ( ); 125 ODevice ( );
105 virtual void init ( ); 126 virtual void init ( );
106 virtual void initButtons ( ); 127 virtual void initButtons ( );
107 128
108 ODeviceData *d; 129 ODeviceData *d;
109 130
110public: 131public:
132 // sandman do we want to allow destructions? -zecke?
111 virtual ~ODevice ( ); 133 virtual ~ODevice ( );
112 134
135
113 static ODevice *inst ( ); 136 static ODevice *inst ( );
114 137
115// information 138// information
116 139
117 QString modelString ( ) const; 140 QString modelString ( ) const;
118 OModel model ( ) const; 141 OModel model ( ) const;
119 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 142 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
120 143
121 QString vendorString ( ) const; 144 QString vendorString ( ) const;
122 OVendor vendor ( ) const; 145 OVendor vendor ( ) const;
123 146
124 QString systemString ( ) const; 147 QString systemString ( ) const;
125 OSystem system ( ) const; 148 OSystem system ( ) const;
126 149
127 QString systemVersionString ( ) const; 150 QString systemVersionString ( ) const;
128 151
129 Transformation rotation ( ) const; 152 Transformation rotation ( ) const;
130 153
131 // system 154// system
132 155
133 virtual bool setSoftSuspend ( bool on ); 156 virtual bool setSoftSuspend ( bool on );
134 virtual bool suspend ( ); 157 virtual bool suspend ( );
135 158
136 virtual bool setDisplayStatus ( bool on ); 159 virtual bool setDisplayStatus ( bool on );
137 virtual bool setDisplayBrightness ( int brightness ); 160 virtual bool setDisplayBrightness ( int brightness );
138 virtual int displayBrightnessResolution ( ) const; 161 virtual int displayBrightnessResolution ( ) const;
139
140// input / output
141 162
163// input / output
164 //FIXME playAlarmSound and al might be better -zecke
142 virtual void alarmSound ( ); 165 virtual void alarmSound ( );
143 virtual void keySound ( ); 166 virtual void keySound ( );
144 virtual void touchSound ( ); 167 virtual void touchSound ( );
145 168
146 virtual QValueList <OLed> ledList ( ) const; 169 virtual QValueList <OLed> ledList ( ) const;
147 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 170 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
148 virtual OLedState ledState ( OLed led ) const; 171 virtual OLedState ledState ( OLed led ) const;
149 virtual bool setLedState ( OLed led, OLedState st ); 172 virtual bool setLedState ( OLed led, OLedState st );
150 173
151 virtual bool hasLightSensor ( ) const; 174 virtual bool hasLightSensor ( ) const;
152 virtual int readLightSensor ( ); 175 virtual int readLightSensor ( );
153 virtual int lightSensorResolution ( ) const; 176 virtual int lightSensorResolution ( ) const;
154 177
155 /** 178 /**
156 * Returns the available buttons on this device. The number and location 179 * Returns the available buttons on this device. The number and location
157 * of buttons will vary depending on the device. Button numbers will be assigned 180 * of buttons will vary depending on the device. Button numbers will be assigned
158 * by the device manufacturer and will be from most preferred button to least preffered 181 * by the device manufacturer and will be from most preferred button to least preffered
159 * button. Note that this list only contains "user mappable" buttons. 182 * button. Note that this list only contains "user mappable" buttons.
160 */ 183 */
161 const QValueList<ODeviceButton> &buttons ( ); 184 const QValueList<ODeviceButton> &buttons ( );
162 185
163 /** 186 /**
164 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 187 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
165 * returns 0L 188 * returns 0L
166 */ 189 */
167 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 190 const ODeviceButton *buttonForKeycode ( ushort keyCode );
168 191
169 /** 192 /**
170 * Reassigns the pressed action for \a button. To return to the factory 193 * Reassigns the pressed action for \a button. To return to the factory
171 * default pass an empty string as \a qcopMessage. 194 * default pass an empty string as \a qcopMessage.
172 */ 195 */
173 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 196 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
174 197
175 /** 198 /**
176 * Reassigns the held action for \a button. To return to the factory 199 * Reassigns the held action for \a button. To return to the factory
177 * default pass an empty string as \a qcopMessage. 200 * default pass an empty string as \a qcopMessage.
178 */ 201 */
179 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 202 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
180 203
181 /** 204 /**
182 * How long (in ms) you have to press a button for a "hold" action 205 * How long (in ms) you have to press a button for a "hold" action
183 */ 206 */
184 uint buttonHoldTime ( ) const; 207 uint buttonHoldTime ( ) const;
185 208
186 signals: 209signals:
187 void buttonMappingChanged ( ); 210 void buttonMappingChanged ( );
188 211
189 private slots: 212private slots:
190 void systemMessage ( const QCString &, const QByteArray & ); 213 void systemMessage ( const QCString &, const QByteArray & );
191 214
192protected: 215protected:
193 void reloadButtonMapping ( ); 216 void reloadButtonMapping ( );
194}; 217};
195 218
196} 219}
197 220
198#endif 221#endif
199 222
diff --git a/libopie/odevicebutton.h b/libopie/odevicebutton.h
index 5281ab2..cf91bbd 100644
--- a/libopie/odevicebutton.h
+++ b/libopie/odevicebutton.h
@@ -1,97 +1,101 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef DEVICE_BUTTON_H 20#ifndef DEVICE_BUTTON_H
21#define DEVICE_BUTTON_H 21#define DEVICE_BUTTON_H
22 22
23#include <qpixmap.h> 23#include <qpixmap.h>
24#include <qstring.h> 24#include <qstring.h>
25 25
26class OQCopMessageData; 26class OQCopMessageData;
27 27
28namespace Opie 28namespace Opie
29{ 29{
30 30
31class OQCopMessage { 31class OQCopMessage {
32public: 32public:
33 OQCopMessage ( ); 33 OQCopMessage ( );
34 OQCopMessage ( const OQCopMessage &copy ); 34 OQCopMessage ( const OQCopMessage &copy );
35 OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( )); 35 OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( ));
36 36
37 OQCopMessage &operator = ( const OQCopMessage &assign ); 37 OQCopMessage &operator = ( const OQCopMessage &assign );
38 38
39 void setChannel ( const QCString &channel ); 39 void setChannel ( const QCString &channel );
40 void setMessage ( const QCString &message ); 40 void setMessage ( const QCString &message );
41 void setData ( const QByteArray &ba ); 41 void setData ( const QByteArray &ba );
42 42
43 QCString channel ( ) const; 43 QCString channel ( ) const;
44 QCString message ( ) const; 44 QCString message ( ) const;
45 QByteArray data ( ) const; 45 QByteArray data ( ) const;
46 46
47 bool send ( ); 47 bool send ( );
48 48
49private: 49private:
50 void init ( const QCString &m_channel, const QCString &message, const QByteArray &args ); 50 void init ( const QCString &m_channel, const QCString &message, const QByteArray &args );
51 51
52 OQCopMessageData *d; 52 OQCopMessageData *d;
53}; 53};
54 54
55 55
56/** 56/**
57 * This class represents a physical button on a Qtopia device. A device may 57 * This class represents a physical button on a Qtopia device. A device may
58 * have n "user programmable" buttons, which are number 1..n. The location 58 * have n "user programmable" buttons, which are number 1..n. The location
59 * and number of buttons will vary from device to device. userText() and pixmap() 59 * and number of buttons will vary from device to device. userText() and pixmap()
60 * may be used to describe this button to the user in help documentation. 60 * may be used to describe this button to the user in help documentation.
61 *
62 * @version 1.0
63 * @author Trolltech
64 * @short A representation of buttons
61 */ 65 */
62 66
63class ODeviceButton 67class ODeviceButton
64{ 68{
65public: 69public:
66 ODeviceButton(); 70 ODeviceButton();
67 virtual ~ODeviceButton(); 71 virtual ~ODeviceButton();
68 72
69 ushort keycode ( ) const; 73 ushort keycode ( ) const;
70 QString userText ( ) const; 74 QString userText ( ) const;
71 QPixmap pixmap ( ) const; 75 QPixmap pixmap ( ) const;
72 OQCopMessage factoryPresetPressedAction ( ) const; 76 OQCopMessage factoryPresetPressedAction ( ) const;
73 OQCopMessage pressedAction ( ) const; 77 OQCopMessage pressedAction ( ) const;
74 OQCopMessage factoryPresetHeldAction ( ) const; 78 OQCopMessage factoryPresetHeldAction ( ) const;
75 OQCopMessage heldAction ( ) const; 79 OQCopMessage heldAction ( ) const;
76 80
77 void setKeycode ( ushort keycode ); 81 void setKeycode ( ushort keycode );
78 void setUserText ( const QString& text ); 82 void setUserText ( const QString& text );
79 void setPixmap ( const QPixmap& picture ); 83 void setPixmap ( const QPixmap& picture );
80 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage ); 84 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage );
81 void setPressedAction ( const OQCopMessage& qcopMessage ); 85 void setPressedAction ( const OQCopMessage& qcopMessage );
82 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage ); 86 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage );
83 void setHeldAction ( const OQCopMessage& qcopMessage ); 87 void setHeldAction ( const OQCopMessage& qcopMessage );
84 88
85private: 89private:
86 ushort m_Keycode; 90 ushort m_Keycode;
87 QString m_UserText; 91 QString m_UserText;
88 QPixmap m_Pixmap; 92 QPixmap m_Pixmap;
89 OQCopMessage m_FactoryPresetPressedAction; 93 OQCopMessage m_FactoryPresetPressedAction;
90 OQCopMessage m_PressedAction; 94 OQCopMessage m_PressedAction;
91 OQCopMessage m_FactoryPresetHeldAction; 95 OQCopMessage m_FactoryPresetHeldAction;
92 OQCopMessage m_HeldAction; 96 OQCopMessage m_HeldAction;
93}; 97};
94 98
95} 99}
96 100
97#endif 101#endif
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc
index 4783004..9e725c2 100644
--- a/libopie/ofiledialog.cc
+++ b/libopie/ofiledialog.cc
@@ -1,116 +1,156 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 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 <qpe/applnk.h> 29#include <qpe/applnk.h>
30#include <qstring.h> 30#include <qstring.h>
31#include <qapplication.h> 31#include <qapplication.h>
32#include <qlayout.h> 32#include <qlayout.h>
33 33
34#include "ofiledialog.h" 34#include "ofiledialog.h"
35 35
36/**
37 * This constructs a modal dialog
38 *
39 * @param caption The caption of the dialog
40 * @param wid The parent widget
41 * @param mode The mode of the OFileSelector @see OFileSelector
42 * @param selector The selector of the OFileSelector
43 * @param dirName the dir or resource to start from
44 * @param fileName a proposed or existing filename
45 * @param mimetypes The mimeTypes
46 */
36OFileDialog::OFileDialog(const QString &caption, 47OFileDialog::OFileDialog(const QString &caption,
37 QWidget *wid, int mode, int selector, 48 QWidget *wid, int mode, int selector,
38 const QString &dirName, 49 const QString &dirName,
39 const QString &fileName, 50 const QString &fileName,
40 const QMap<QString,QStringList>& mimetypes ) 51 const QMap<QString,QStringList>& mimetypes )
41 : QDialog( wid, "OFileDialog", true ) 52 : QDialog( wid, "OFileDialog", true )
42{ 53{
43 // QVBoxLayout *lay = new QVBoxLayout(this); 54 // QVBoxLayout *lay = new QVBoxLayout(this);
44 //showMaximized(); 55 //showMaximized();
45 QVBoxLayout *lay = new QVBoxLayout(this ); 56 QVBoxLayout *lay = new QVBoxLayout(this );
46 file = new OFileSelector(this , mode, selector, 57 file = new OFileSelector(this , mode, selector,
47 dirName, fileName, 58 dirName, fileName,
48 mimetypes ); 59 mimetypes );
49 lay->addWidget( file ); 60 lay->addWidget( file );
50 61
51 //lay->addWidget( file ); 62 //lay->addWidget( file );
52 //showFullScreen(); 63 //showFullScreen();
53 setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); 64 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
54 connect(file, SIGNAL(fileSelected(const QString&) ), 65 connect(file, SIGNAL(fileSelected(const QString&) ),
55 this, SLOT(slotFileSelected(const QString&) ) ); 66 this, SLOT(slotFileSelected(const QString&) ) );
56 67
57 connect(file, SIGNAL(dirSelected(const QString &) ), 68 connect(file, SIGNAL(dirSelected(const QString &) ),
58 this, SLOT(slotDirSelected(const QString &) ) ); 69 this, SLOT(slotDirSelected(const QString &) ) );
59 70
60 71
61 file->setYesCancelVisible( false ); // relayout 72 file->setYesCancelVisible( false ); // relayout
62} 73}
74/**
75 * @returns the mimetype of the selected
76 * currently it return QString::null
77 */
63QString OFileDialog::mimetype()const 78QString OFileDialog::mimetype()const
64{ 79{
65 return QString::null; 80 return QString::null;
66} 81}
82
83/**
84 * @return the fileName
85 */
67QString OFileDialog::fileName()const 86QString OFileDialog::fileName()const
68{ 87{
69 return file->selectedName(); 88 return file->selectedName();
70} 89}
90
91/**
92 * return a DocLnk to the current file
93 */
71DocLnk OFileDialog::selectedDocument()const 94DocLnk OFileDialog::selectedDocument()const
72{ 95{
73 return file->selectedDocument(); 96 return file->selectedDocument();
74} 97}
98
99/**
100 * This opens up a filedialog in Open mode
101 *
102 * @param selector the Selector Mode
103 * @param startDir Where to start from
104 * @param file A proposed filename
105 * @param mimes A list of MimeTypes
106 * @param wid the parent
107 * @param caption of the dialog if QString::null tr("Open") will be used
108 * @return the fileName or QString::null
109 */
75QString OFileDialog::getOpenFileName(int selector, 110QString OFileDialog::getOpenFileName(int selector,
76 const QString &startDir, 111 const QString &startDir,
77 const QString &file, 112 const QString &file,
78 const MimeTypes &mimes, 113 const MimeTypes &mimes,
79 QWidget *wid, 114 QWidget *wid,
80 const QString &caption ) 115 const QString &caption )
81{ 116{
82 QString ret; 117 QString ret;
83 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, 118 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
84 wid, OFileSelector::OPEN, selector, startDir, file, mimes); 119 wid, OFileSelector::OPEN, selector, startDir, file, mimes);
85 dlg.showMaximized(); 120 dlg.showMaximized();
86 if( dlg.exec() ) 121 if( dlg.exec() )
87 ret = dlg.fileName(); 122 ret = dlg.fileName();
88 123
89 return ret; 124 return ret;
90} 125}
126
127/**
128 * This opens up a file dialog in save mode
129 * @see getOpenFileName
130 */
91QString OFileDialog::getSaveFileName(int selector, 131QString OFileDialog::getSaveFileName(int selector,
92 const QString &startDir, 132 const QString &startDir,
93 const QString &file, 133 const QString &file,
94 const MimeTypes &mimes, 134 const MimeTypes &mimes,
95 QWidget *wid, 135 QWidget *wid,
96 const QString &caption ) 136 const QString &caption )
97{ 137{
98 QString ret; 138 QString ret;
99 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, 139 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
100 wid, OFileSelector::SAVE, selector, startDir, file, mimes); 140 wid, OFileSelector::SAVE, selector, startDir, file, mimes);
101 dlg.showMaximized(); 141 dlg.showMaximized();
102 if( dlg.exec() ) 142 if( dlg.exec() )
103 ret = dlg.fileName(); 143 ret = dlg.fileName();
104 144
105 return ret; 145 return ret;
106} 146}
107 147
108void OFileDialog::slotFileSelected(const QString & ) 148void OFileDialog::slotFileSelected(const QString & )
109{ 149{
110 accept(); 150 accept();
111} 151}
112void OFileDialog::slotDirSelected(const QString & ) 152void OFileDialog::slotDirSelected(const QString & )
113{ 153{
114 // if mode 154 // if mode
115 //accept(); 155 //accept();
116} 156}
diff --git a/libopie/ofiledialog.h b/libopie/ofiledialog.h
index e14253c..309086b 100644
--- a/libopie/ofiledialog.h
+++ b/libopie/ofiledialog.h
@@ -1,77 +1,100 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> 3             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30#ifndef OpieFileDialog_h 30#ifndef OpieFileDialog_h
31#define OpieFileDialog_h 31#define OpieFileDialog_h
32 32
33#include <qdialog.h> 33#include <qdialog.h>
34 34
35#include <opie/ofileselector.h> 35#include <opie/ofileselector.h>
36 36
37/**
38 * This class places a OFileSelector inside a QDialog.
39 * It provides static method for letting a user chose
40 * a file for either opening or saving.
41 * Most of the time the c'tor will not be used instead using
42 * the static member functions is prefered.
43 *
44 * <pre>
45 * QMap<QString, QStringList> mimeTypes;
46 * QStringList types;
47 * types << "text/* ";
48 * mimeTypes.insert( tr("Text"), types );
49 * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment
50 * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
51 * "foo","bar", mimeTypes);
52 * </pre>
53 *
54 * @short A small QDialog swalloing a FileSelector
55 * @see QDialog
56 * @see OFileSelector
57 * @version 0.1-unfinished
58 * @author Holger Freyther ( zecke@handhelds.org )
59 */
37class OFileDialog : public QDialog { 60class OFileDialog : public QDialog {
38 Q_OBJECT 61 Q_OBJECT
39 public: 62 public:
40 OFileDialog(const QString &caption, 63 OFileDialog(const QString &caption,
41 QWidget *, int mode, int selector, 64 QWidget *, int mode, int selector,
42 const QString &dirName, 65 const QString &dirName,
43 const QString &fileName = QString::null, 66 const QString &fileName = QString::null,
44 const MimeTypes &mimetypes = MimeTypes() ); 67 const MimeTypes &mimetypes = MimeTypes() );
45 QString mimetype() const; 68 QString mimetype() const;
46 QString fileName() const; 69 QString fileName() const;
47 DocLnk selectedDocument()const; 70 DocLnk selectedDocument()const;
48 71
49 // static methods 72 // static methods
50 static QString getOpenFileName(int selector, 73 static QString getOpenFileName(int selector,
51 const QString& startDir = QString::null, 74 const QString& startDir = QString::null,
52 const QString &fileName = QString::null, 75 const QString &fileName = QString::null,
53 const MimeTypes& mime = MimeTypes(), 76 const MimeTypes& mime = MimeTypes(),
54 QWidget *wid = 0, 77 QWidget *wid = 0,
55 const QString &caption = QString::null ); 78 const QString &caption = QString::null );
56 79
57 static QString getSaveFileName(int selector, 80 static QString getSaveFileName(int selector,
58 const QString& startDir = QString::null, 81 const QString& startDir = QString::null,
59 const QString& fileName = QString::null, 82 const QString& fileName = QString::null,
60 const MimeTypes& mimefilter = MimeTypes(), 83 const MimeTypes& mimefilter = MimeTypes(),
61 QWidget *wid = 0, 84 QWidget *wid = 0,
62 const QString &caption = QString::null ); 85 const QString &caption = QString::null );
63 86
64 //let's OFileSelector catch up first 87 //let's OFileSelector catch up first
65 //static QString getExistingDirectory(const QString& startDir = QString::null, 88 //static QString getExistingDirectory(const QString& startDir = QString::null,
66 // QWidget *parent = 0, 89 // QWidget *parent = 0,
67 // const QString& caption = QString::null ); 90 // const QString& caption = QString::null );
68 private: 91 private:
69 class OFileDialogPrivate; 92 class OFileDialogPrivate;
70 OFileDialogPrivate *d; 93 OFileDialogPrivate *d;
71 OFileSelector *file; 94 OFileSelector *file;
72 95
73 private slots: 96 private slots:
74 void slotFileSelected( const QString & ); 97 void slotFileSelected( const QString & );
75 void slotDirSelected(const QString & ); 98 void slotDirSelected(const QString & );
76}; 99};
77#endif 100#endif
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 17c494e..06ac806 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -1,309 +1,311 @@
1/* 1/*
2 This is based on code and ideas of 2 This is based on code and ideas of
3 L. J. Potter ljp@llornkcor.com 3 L. J. Potter ljp@llornkcor.com
4 Thanks a lot 4 Thanks a lot
5 5
6 6
7               =. This file is part of the OPIE Project 7               =. This file is part of the OPIE Project
8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This library is free software; you can 10 _;:,     .>    :=|. This library is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This library is distributed in the hope that 17    .i_,=:_.      -<s. This library is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef opiefileselector_h 34#ifndef opiefileselector_h
35#define opiefileselector_h 35#define opiefileselector_h
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qstringlist.h> 40#include <qstringlist.h>
41#include <qmap.h> 41#include <qmap.h>
42#include <qvaluelist.h> 42#include <qvaluelist.h>
43 43
44#include <qpe/applnk.h> 44#include <qpe/applnk.h>
45#include <qlistview.h> 45#include <qlistview.h>
46 46
47/** This is OPIEs FileDialog Widget. You can use it 47/** This is OPIEs FileDialog Widget. You can use it
48 * as a dropin replacement of the fileselector and 48 * as a dropin replacement of the fileselector and
49 * or use any of the new features. 49 * or use any of the new features.
50 * This is also a complete FileSave and FileLoad widget 50 * This is also a complete FileSave and FileLoad widget
51 * If you look for a Dialog check OFileDialog 51 * If you look for a Dialog check OFileDialog
52 * 52 *
53 */ 53 */
54class DocLnk; 54class DocLnk;
55class QCheckBox; 55class QCheckBox;
56class QComboBox; 56class QComboBox;
57class QPushButton; 57class QPushButton;
58class FileSelector; 58class FileSelector;
59class QGridLayout; 59class QGridLayout;
60class QLineEdit; 60class QLineEdit;
61class QLabel; 61class QLabel;
62class QWidgetStack; 62class QWidgetStack;
63class QHBoxLayout; 63class QHBoxLayout;
64class QVBoxLayout; 64class QVBoxLayout;
65class QPopupMenu; 65class QPopupMenu;
66class QFileInfo; 66class QFileInfo;
67class QHBox; 67class QHBox;
68// 68//
69 69
70typedef QMap< QString, QStringList> MimeTypes; 70typedef QMap< QString, QStringList> MimeTypes;
71 71
72class OFileSelector : public QWidget { 72class OFileSelector : public QWidget {
73 Q_OBJECT 73 Q_OBJECT
74 public: 74 public:
75 /** 75 /**
76 * The mode of the file selector 76 * The mode of the file selector
77 * Either open, save, fileselector or dir browsing mode 77 * Either open, save, fileselector or dir browsing mode
78 * 78 *
79 */ 79 */
80 enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; 80 enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 };
81 81
82 /** 82 /**
83 * Selector. Either NORMAL for the one shipped with 83 * Selector. Either NORMAL for the one shipped with
84 * libqpe or EXTENDED. for the EXTENDED 84 * libqpe or EXTENDED. for the EXTENDED
85 * EXTENDED_ALL also shows 'hidden' files 85 * EXTENDED_ALL also shows 'hidden' files
86 */ 86 */
87 enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 }; 87 enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 };
88 88
89 /** 89 /**
90 * This is reserved for futrue views 90 * This is reserved for futrue views
91 */ 91 */
92 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; 92 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 };
93 93
94 /** 94 /**
95 * A c'tor which should be used for advanced mode 95 * A c'tor which should be used for advanced mode
96 * @param wid the parent 96 * @param wid the parent
97 * @param mode the Mode of the Selector 97 * @param mode the Mode of the Selector
98 * @param selector the current View of the Selector 98 * @param selector the current View of the Selector
99 * @param dirName in which dir to start 99 * @param dirName in which dir to start
100 * @param fileName a proposed filename 100 * @param fileName a proposed filename
101 * @param mimetypes A list of mimetypes \ 101 * @param mimetypes A list of mimetypes \
102 * QString is for a identifier name like "Text files" 102 * QString is for a identifier name like "Text files"
103 * the coresponding QStringList is used for the mimetypes 103 * the coresponding QStringList is used for the mimetypes
104 * if empty it'll fill the list of mimetypes depending 104 * if empty it'll fill the list of mimetypes depending
105 * on the content of the current directory 105 * on the content of the current directory
106 */ 106 */
107 107
108 OFileSelector(QWidget *wid, int mode, int selector, 108 OFileSelector(QWidget *wid, int mode, int selector,
109 const QString &dirName, 109 const QString &dirName,
110 const QString &fileName = QString::null, 110 const QString &fileName = QString::null,
111 const MimeTypes &mimetypes = MimeTypes() ); 111 const MimeTypes &mimetypes = MimeTypes() );
112 112
113 113
114 /** 114 /**
115 * This is a QPE compatible c'tor 115 * This is a QPE compatible c'tor
116 */ 116 */
117 OFileSelector(const QString &mimeFilter, QWidget *parent, 117 OFileSelector(const QString &mimeFilter, QWidget *parent,
118 const char *name, bool newVisible = TRUE, 118 const char *name, bool newVisible = TRUE,
119 bool closeVisible = FALSE ); 119 bool closeVisible = FALSE );
120 120
121 ~OFileSelector(); 121 ~OFileSelector();
122 122
123 // currently only for the FILESELECTOR Mode 123 // currently only for the FILESELECTOR Mode
124 /**
125 */
124 void setNewVisible( bool /*b*/ ); 126 void setNewVisible( bool /*b*/ );
125 void setCloseVisible(bool /*b*/ ); 127 void setCloseVisible(bool /*b*/ );
126 128
127 // end file selector mode 129 // end file selector mode
128 // deprecated 130 // deprecated
129 void reread(); 131 void reread();
130 // make sure not to leak please 132 // make sure not to leak please
131 const DocLnk *selected(); 133 const DocLnk *selected();
132 // end deprecated 134 // end deprecated
133 135
134 bool isToolbarVisible() const { return m_shTool; }; 136 bool isToolbarVisible() const { return m_shTool; };
135 bool isPermissionBarVisible() const { return m_shPerm; }; 137 bool isPermissionBarVisible() const { return m_shPerm; };
136 bool isLineEditVisible()const { return m_shLne; }; 138 bool isLineEditVisible()const { return m_shLne; };
137 bool isChooserVisible( )const { return m_shChooser; }; 139 bool isChooserVisible( )const { return m_shChooser; };
138 bool isYesCancelVisible()const { return m_shYesNo; }; 140 bool isYesCancelVisible()const { return m_shYesNo; };
139 void setYesCancelVisible( bool show ); 141 void setYesCancelVisible( bool show );
140 void setToolbarVisible( bool show ); 142 void setToolbarVisible( bool show );
141 void setPermissionBarVisible( bool show ); 143 void setPermissionBarVisible( bool show );
142 void setLineEditVisible(bool show) ; 144 void setLineEditVisible(bool show) ;
143 void setChooserVisible( bool chooser ); 145 void setChooserVisible( bool chooser );
144 146
145 QCheckBox* permissionCheckbox(); 147 QCheckBox* permissionCheckbox();
146 bool setPermission() const; 148 bool setPermission() const;
147 void setPermissionChecked( bool check ); 149 void setPermissionChecked( bool check );
148 150
149 void setMode( int ); 151 void setMode( int );
150 152
151 bool showDirs()const { return m_dir; } 153 bool showDirs()const { return m_dir; }
152 void setShowDirs(bool ); 154 void setShowDirs(bool );
153 155
154 const QListView* listView() { return m_View; }; 156 const QListView* listView() { return m_View; };
155 157
156 bool isCaseSensetive()const { return m_case; } 158 bool isCaseSensetive()const { return m_case; }
157 void setCaseSensetive(bool caSe ); 159 void setCaseSensetive(bool caSe );
158 160
159 bool showFiles()const { return m_files; }; 161 bool showFiles()const { return m_files; };
160 void setShowFiles(bool ); 162 void setShowFiles(bool );
161 bool cd(const QString &path ); 163 bool cd(const QString &path );
162 164
163 165
164 int mode()const { return m_mode; }; 166 int mode()const { return m_mode; };
165 int selector()const { return m_selector; }; 167 int selector()const { return m_selector; };
166 void setSelector( int ); 168 void setSelector( int );
167 169
168 bool showPopup()const { return m_showPopup; }; 170 bool showPopup()const { return m_showPopup; };
169 void setShowPopup( bool pop ) { m_showPopup = pop; }; 171 void setShowPopup( bool pop ) { m_showPopup = pop; };
170 void setPopupMenu( QPopupMenu * ); 172 void setPopupMenu( QPopupMenu * );
171 173
172 // void updateLay(); 174 // void updateLay();
173 175
174 void reparse(); // re reads the dir 176 void reparse(); // re reads the dir
175 177
176 QString selectedName( )const; 178 QString selectedName( )const;
177 QStringList selectedNames()const; 179 QStringList selectedNames()const;
178 180
179 QString selectedPath() const; 181 QString selectedPath() const;
180 QStringList selectedPaths() const; 182 QStringList selectedPaths() const;
181 183
182 QString directory()const; 184 QString directory()const;
183 int fileCount() const; 185 int fileCount() const;
184 186
185 /* the user needs to delete it */ 187 /* the user needs to delete it */
186 DocLnk selectedDocument()const; 188 DocLnk selectedDocument()const;
187 /* the user needs to delete it */ 189 /* the user needs to delete it */
188 QValueList<DocLnk> selectedDocuments()const; 190 QValueList<DocLnk> selectedDocuments()const;
189 191
190 signals: 192 signals:
191 void fileSelected( const DocLnk & ); 193 void fileSelected( const DocLnk & );
192 void fileSelected( const QString & ); 194 void fileSelected( const QString & );
193 void dirSelected(const QString &dir ); 195 void dirSelected(const QString &dir );
194 void closeMe(); 196 void closeMe();
195 void ok(); 197 void ok();
196 void cancel(); 198 void cancel();
197 void contextMenu(); 199 void contextMenu();
198 200
199 private slots: 201 private slots:
200 void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); }; 202 void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); };
201 void slotOk(); 203 void slotOk();
202 void slotCancel(); 204 void slotCancel();
203 void slotViewCheck(const QString & ); 205 void slotViewCheck(const QString & );
204 void slotMimeCheck(const QString & ); 206 void slotMimeCheck(const QString & );
205 void slotLocationActivated(const QString & ); 207 void slotLocationActivated(const QString & );
206 void slotInsertLocationPath(const QString &, int); 208 void slotInsertLocationPath(const QString &, int);
207 void locationComboChanged(); 209 void locationComboChanged();
208 210
209 private: 211 private:
210 void init(); 212 void init();
211 void updateMimes(); 213 void updateMimes();
212 214
213 protected: 215 protected:
214 216
215 private: 217 private:
216 int m_mode, m_selector; 218 int m_mode, m_selector;
217 QComboBox *m_location, *m_mimeCheck, *m_viewCheck; 219 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
218 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; 220 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
219 QPushButton *m_reread, *m_up, *m_new, *m_close; 221 QPushButton *m_reread, *m_up, *m_new, *m_close;
220 QListView *m_View; 222 QListView *m_View;
221 QCheckBox *m_checkPerm; 223 QCheckBox *m_checkPerm;
222 QWidget *m_pseudo; 224 QWidget *m_pseudo;
223 QVBoxLayout *m_pseudoLayout; 225 QVBoxLayout *m_pseudoLayout;
224 226
225 QString m_currentDir; 227 QString m_currentDir;
226 QString m_name; 228 QString m_name;
227// QStringList m_mimetypes; 229// QStringList m_mimetypes;
228 QMap<QString, QStringList> m_mimetypes; 230 QMap<QString, QStringList> m_mimetypes;
229 231
230 FileSelector *m_select; 232 FileSelector *m_select;
231 QWidgetStack *m_stack; 233 QWidgetStack *m_stack;
232 QVBoxLayout *m_lay; 234 QVBoxLayout *m_lay;
233 QGridLayout *m_Oselector; 235 QGridLayout *m_Oselector;
234 236
235 QHBox *m_boxToolbar; 237 QHBox *m_boxToolbar;
236 QHBox *m_boxOk; // (no layout anymore) wait 238 QHBox *m_boxOk; // (no layout anymore) wait
237 QHBox *m_boxName; // (no Layout anymore) wait 239 QHBox *m_boxName; // (no Layout anymore) wait
238 QHBox *m_boxView; 240 QHBox *m_boxView;
239 241
240 QPopupMenu *m_custom; 242 QPopupMenu *m_custom;
241 243
242 QLineEdit *m_edit; 244 QLineEdit *m_edit;
243 QLabel *m_fnLabel; 245 QLabel *m_fnLabel;
244 246
245 bool m_shClose : 1; 247 bool m_shClose : 1;
246 bool m_shNew : 1; 248 bool m_shNew : 1;
247 bool m_shTool : 1; 249 bool m_shTool : 1;
248 bool m_shPerm : 1; 250 bool m_shPerm : 1;
249 bool m_shLne : 1; 251 bool m_shLne : 1;
250 bool m_shChooser : 1; 252 bool m_shChooser : 1;
251 bool m_shYesNo : 1; 253 bool m_shYesNo : 1;
252 bool m_boCheckPerm : 1; 254 bool m_boCheckPerm : 1;
253 bool m_autoMime : 1; 255 bool m_autoMime : 1;
254 bool m_case : 1; 256 bool m_case : 1;
255 bool m_dir : 1; 257 bool m_dir : 1;
256 bool m_files : 1; 258 bool m_files : 1;
257 bool m_showPopup : 1; 259 bool m_showPopup : 1;
258 260
259 void initVars(); 261 void initVars();
260 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); 262 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
261 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); 263 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
262 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; 264 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
263 void delItems(); 265 void delItems();
264 void initializeName(); 266 void initializeName();
265 void initializeYes(); 267 void initializeYes();
266 void initializeChooser(); 268 void initializeChooser();
267 void initializeListView(); 269 void initializeListView();
268 void initializePerm(); 270 void initializePerm();
269 void initPics(); 271 void initPics();
270 bool compliesMime(const QString &path, 272 bool compliesMime(const QString &path,
271 const QString &mime); 273 const QString &mime);
272 bool compliesMime(const QString& mime ); 274 bool compliesMime(const QString& mime );
273 /** 275 /**
274 * Updates the QComboBox with the current mimetypes 276 * Updates the QComboBox with the current mimetypes
275 */ 277 */
276 void updateMimeCheck(); 278 void updateMimeCheck();
277 279
278 /** 280 /**
279 * Returns the current mimetype 281 * Returns the current mimetype
280 */ 282 */
281 QString currentMimeType()const; 283 QString currentMimeType()const;
282 class OFileSelectorPrivate; 284 class OFileSelectorPrivate;
283 OFileSelectorPrivate *d; 285 OFileSelectorPrivate *d;
284 static QMap<QString,QPixmap> *m_pixmaps; 286 static QMap<QString,QPixmap> *m_pixmaps;
285 287
286private slots: 288private slots:
287 void slotFileSelected(const QString & ); // not really meant to be a slot 289 void slotFileSelected(const QString & ); // not really meant to be a slot
288 void slotFileBridgeSelected( const DocLnk & ); 290 void slotFileBridgeSelected( const DocLnk & );
289 virtual void slotSelectionChanged(); 291 virtual void slotSelectionChanged();
290 virtual void slotCurrentChanged(QListViewItem* ); 292 virtual void slotCurrentChanged(QListViewItem* );
291 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); 293 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int);
292 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); 294 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int );
293 virtual void slotContextMenu( QListViewItem *item); 295 virtual void slotContextMenu( QListViewItem *item);
294 // listview above 296 // listview above
295 // popup below 297 // popup below
296 virtual void slotChangedDir(); 298 virtual void slotChangedDir();
297 virtual void slotOpen(); 299 virtual void slotOpen();
298 virtual void slotRescan(); 300 virtual void slotRescan();
299 virtual void slotRename(); 301 virtual void slotRename();
300 virtual void slotDelete(); 302 virtual void slotDelete();
301 virtual void cdUP(); 303 virtual void cdUP();
302 virtual void slotHome(); 304 virtual void slotHome();
303 virtual void slotDoc(); 305 virtual void slotDoc();
304 virtual void slotNavigate( ); 306 virtual void slotNavigate( );
305}; 307};
306 308
307 309
308#endif 310#endif
309 311
diff --git a/libopie/ofontmenu.cc b/libopie/ofontmenu.cc
index 52ff3ee..d16c5e5 100644
--- a/libopie/ofontmenu.cc
+++ b/libopie/ofontmenu.cc
@@ -1,112 +1,156 @@
1 1
2 2
3#include <qpe/config.h> 3#include <qpe/config.h>
4#include "ofontmenu.h" 4#include "ofontmenu.h"
5 5
6 6
7 7/**
8 * Constructs the FontMenu.
9 *
10 * @param parent The parent widget
11 * @param name A name for this widget
12 * @param list The list of widgets to be controlled
13 */
8OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list ) 14OFontMenu::OFontMenu(QWidget *parent, const char *name, const QList<QWidget> &list )
9 : QPopupMenu( parent, name ) 15 : QPopupMenu( parent, name )
10{ 16{
11 m_list = list; 17 m_list = list;
12 m_wids.setAutoDelete( TRUE ); 18 m_wids.setAutoDelete( TRUE );
13 19
14 insertItem(tr("Large"), this, SLOT(slotLarge() ), 20 insertItem(tr("Large"), this, SLOT(slotLarge() ),
15 0, 10); 21 0, 10);
16 insertItem(tr("Medium"), this, SLOT(slotMedium() ), 22 insertItem(tr("Medium"), this, SLOT(slotMedium() ),
17 0, 11 ); 23 0, 11 );
18 insertItem(tr("Small"), this, SLOT(slotSmall() ), 24 insertItem(tr("Small"), this, SLOT(slotSmall() ),
19 0, 12 ); 25 0, 12 );
20 setCheckable( true ); 26 setCheckable( true );
21 m_size=10; 27 m_size=10;
22} 28}
29
30/**
31 * This method saves the font size
32 * into a Config object
33 * OFontMenu will be used as group and size as key
34 * @param cfg The Config object to be used
35 */
23void OFontMenu::save(Config *cfg ) 36void OFontMenu::save(Config *cfg )
24{ 37{
25 cfg->setGroup("OFontMenu" ); 38 cfg->setGroup("OFontMenu" );
26 cfg->writeEntry("size", m_size ); 39 cfg->writeEntry("size", m_size );
27} 40}
41
42/**
43 * This method restores the font size from a Config object
44 * it'll apply the sizes to the widgets and will also set the
45 * menu appropriate
46 */
28void OFontMenu::restore(Config *cfg ) 47void OFontMenu::restore(Config *cfg )
29{ 48{
30 cfg->setGroup("OFontMeny" ); 49 cfg->setGroup("OFontMeny" );
31 m_size = cfg->readNumEntry("size" ); 50 m_size = cfg->readNumEntry("size" );
32 setItemChecked(10, false ); 51 setItemChecked(10, false );
33 setItemChecked(11, false ); 52 setItemChecked(11, false );
34 setItemChecked(12, false ); 53 setItemChecked(12, false );
35 switch( m_size ){ 54 switch( m_size ){
36 case 8: 55 case 8:
37 setItemChecked(12, true ); 56 setItemChecked(12, true );
38 break; 57 break;
39 case 14: 58 case 14:
40 setItemChecked(10, true ); 59 setItemChecked(10, true );
41 break; 60 break;
42 case 10:// fall through 61 case 10:// fall through
43 default: 62 default:
44 setItemChecked(11, true ); 63 setItemChecked(11, true );
45 m_size = 10; 64 m_size = 10;
46 break; 65 break;
47 } 66 }
48 setFontSize( m_size ); 67 setFontSize( m_size );
49} 68}
69
70/**
71 * set the list of widgets
72 * @param list the widget list
73 */
50void OFontMenu::setWidgets(const QList<QWidget> &list ) 74void OFontMenu::setWidgets(const QList<QWidget> &list )
51{ 75{
52 m_list = list; 76 m_list = list;
53} 77}
78
79/**
80 * add a widget to the list
81 * @param wid The widget to be added
82 */
54void OFontMenu::addWidget( QWidget *wid ) 83void OFontMenu::addWidget( QWidget *wid )
55{ 84{
56 m_list.append(wid ); 85 m_list.append(wid );
57} 86}
87
88/**
89 * removes the widget from the list of controlled objects
90 * @param wid the to be removed widget
91 */
58void OFontMenu::removeWidget( QWidget *wid ) 92void OFontMenu::removeWidget( QWidget *wid )
59{ 93{
60 m_list.remove( wid ); 94 m_list.remove( wid );
61} 95}
96
97/**
98 * The list of controlled widgets
99 */
62const QList<QWidget> &OFontMenu::widgets()const 100const QList<QWidget> &OFontMenu::widgets()const
63{ 101{
64 return m_list; 102 return m_list;
65} 103}
104
105/**
106 * Forces a size on a widget
107 * @param wid The widget
108 * @param size The font size forced onto the widget
109 */
66void OFontMenu::forceSize(QWidget *wid, int size ) 110void OFontMenu::forceSize(QWidget *wid, int size )
67{ 111{
68 WidSize *widz = new WidSize; 112 WidSize *widz = new WidSize;
69 widz->wid = wid; 113 widz->wid = wid;
70 widz->size = size; 114 widz->size = size;
71 m_wids.append( widz ); 115 m_wids.append( widz );
72} 116}
73void OFontMenu::slotSmall() 117void OFontMenu::slotSmall()
74{ 118{
75 setItemChecked(10, false ); 119 setItemChecked(10, false );
76 setItemChecked(11, false ); 120 setItemChecked(11, false );
77 setItemChecked(12, true ); 121 setItemChecked(12, true );
78 setFontSize( 8 ); 122 setFontSize( 8 );
79} 123}
80void OFontMenu::slotMedium() 124void OFontMenu::slotMedium()
81{ 125{
82 setItemChecked(10, false ); 126 setItemChecked(10, false );
83 setItemChecked(11, true ); 127 setItemChecked(11, true );
84 setItemChecked(12, false ); 128 setItemChecked(12, false );
85 setFontSize(10 ); 129 setFontSize(10 );
86} 130}
87void OFontMenu::slotLarge() 131void OFontMenu::slotLarge()
88{ 132{
89 setItemChecked(10, true ); 133 setItemChecked(10, true );
90 setItemChecked(11, false ); 134 setItemChecked(11, false );
91 setItemChecked(12, false ); 135 setItemChecked(12, false );
92 setFontSize(14 ); 136 setFontSize(14 );
93} 137}
94void OFontMenu::setFontSize(int size ) 138void OFontMenu::setFontSize(int size )
95{ 139{
96 m_size = size; 140 m_size = size;
97 QWidget *wid; 141 QWidget *wid;
98 for(wid = m_list.first(); wid !=0; wid = m_list.next() ){ 142 for(wid = m_list.first(); wid !=0; wid = m_list.next() ){
99 QFont font = wid->font(); 143 QFont font = wid->font();
100 font.setPointSize( size ); 144 font.setPointSize( size );
101 wid->setFont( font ); 145 wid->setFont( font );
102 } 146 }
103 if(!m_wids.isEmpty() ){ 147 if(!m_wids.isEmpty() ){
104 WidSize *wids; 148 WidSize *wids;
105 for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){ 149 for( wids = m_wids.first(); wids != 0; wids = m_wids.next() ){
106 QFont font = wids->wid->font(); 150 QFont font = wids->wid->font();
107 font.setPointSize( wids->size ); 151 font.setPointSize( wids->size );
108 wids->wid->setFont( font ); 152 wids->wid->setFont( font );
109 } 153 }
110 } 154 }
111 emit fontChanged(size ); 155 emit fontChanged(size );
112} 156}
diff --git a/libopie/ofontmenu.h b/libopie/ofontmenu.h
index 5fd515f..6e143ca 100644
--- a/libopie/ofontmenu.h
+++ b/libopie/ofontmenu.h
@@ -1,83 +1,113 @@
1 1
2/* 2/*
3 3
4               =. This file is part of the OPIE Project 4               =. This file is part of the OPIE Project
5             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> 5             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org>
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This library is free software; you can 7 _;:,     .>    :=|. This library 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 library is distributed in the hope that 14    .i_,=:_.      -<s. This library 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 30
31 31
32 32
33 33
34#ifndef ofontmenu_h 34#ifndef ofontmenu_h
35#define ofontmenu_h 35#define ofontmenu_h
36 36
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include <qlist.h> 38#include <qlist.h>
39 39
40 40/*
41 * @internal
42 */
41namespace { 43namespace {
42 struct WidSize { 44 struct WidSize {
43 QWidget *wid; 45 QWidget *wid;
44 int size; 46 int size;
45 }; 47 };
46 48
47}; 49};
48 50
49// if i would be on kde this would be a KActionMenu... 51// forward declarations
50class Config; 52class Config;
53
54/**
55 * This class is a specialised QPopupMenu. It'll display three different
56 * font sizes. Small, Normal and large by adding widgets to the Menu
57 * you can control the font size of these widgets
58 * by using the save and restore method you can also apply font sizes
59 * over two different runtimes
60 *
61 * <pre>
62 * QTable* tbl = new QTable();
63 * QList<QWidget> wid;
64 * wid.append( tbl );
65 * OFontMenu* menu = new OFontMenu(this, "Popup Menu", wid );
66 * Config cfg("mycfg");
67 * menu->restore( cfg );
68 * </pre>
69 *
70 * @author Holger Freyther ( zecke@handhelds.org )
71 * @version 0.1
72 * @short PopupMenu which can control the size of Widgets
73 * @see QPopupMenu
74 */
51class OFontMenu : public QPopupMenu { 75class OFontMenu : public QPopupMenu {
52 Q_OBJECT 76 Q_OBJECT
53 public: 77 public:
54 OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list ); 78 OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list );
55 void save(Config *cfg ); 79 void save(Config *cfg );
56 void restore(Config *cfg ); 80 void restore(Config *cfg );
57 void setWidgets(const QList<QWidget> &list ); 81 void setWidgets(const QList<QWidget> &list );
58 void addWidget(QWidget *wid ); 82 void addWidget(QWidget *wid );
59 void forceSize(QWidget *wid, int size ); 83 void forceSize(QWidget *wid, int size );
60 void removeWidget(QWidget *wid ); 84 void removeWidget(QWidget *wid );
61 const QList<QWidget> &widgets()const; 85 const QList<QWidget> &widgets()const;
62 86
63 signals: 87 signals:
88 /**
89 * this signal gets emitted when the font size gets changed
90 * @param size The new size of font
91 */
64 void fontChanged(int size ); 92 void fontChanged(int size );
93
65 private: 94 private:
66 QList<QWidget> m_list; 95 QList<QWidget> m_list;
67 QList<WidSize> m_wids; 96 QList<WidSize> m_wids;
68 int m_size; 97 int m_size;
69 class OFontMenuPrivate; 98 class OFontMenuPrivate;
70 OFontMenuPrivate *d; 99 OFontMenuPrivate *d;
100
71 private slots: 101 private slots:
72 virtual void slotSmall(); 102 virtual void slotSmall();
73 virtual void slotMedium(); 103 virtual void slotMedium();
74 virtual void slotLarge(); 104 virtual void slotLarge();
75 void setFontSize(int size ); 105 void setFontSize(int size );
76}; 106};
77 107
78#endif 108#endif
79 109
80 110
81 111
82 112
83 113
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp
index b905474..c8471cc 100644
--- a/libopie/ofontselector.cpp
+++ b/libopie/ofontselector.cpp
@@ -1,362 +1,412 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 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 <qlayout.h> 29#include <qlayout.h>
30#include <qlistbox.h> 30#include <qlistbox.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qmultilineedit.h> 34#include <qmultilineedit.h>
35 35
36#include <qpe/fontdatabase.h> 36#include <qpe/fontdatabase.h>
37 37
38#include "ofontselector.h" 38#include "ofontselector.h"
39 39
40class OFontSelectorPrivate { 40class OFontSelectorPrivate {
41public: 41public:
42 QListBox * m_font_family_list; 42 QListBox * m_font_family_list;
43 QComboBox * m_font_style_list; 43 QComboBox * m_font_style_list;
44 QComboBox * m_font_size_list; 44 QComboBox * m_font_size_list;
45 QMultiLineEdit *m_preview; 45 QMultiLineEdit *m_preview;
46 46
47 bool m_pointbug; 47 bool m_pointbug : 1;
48 48
49 FontDatabase m_fdb; 49 FontDatabase m_fdb;
50}; 50};
51 51
52namespace {
52 53
53class FontListItem : public QListBoxText { 54class FontListItem : public QListBoxText {
54public: 55public:
55 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText ( ) 56 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText ( )
56 { 57 {
57 m_name = t; 58 m_name = t;
58 m_styles = styles; 59 m_styles = styles;
59 m_sizes = sizes; 60 m_sizes = sizes;
60 61
61 QString str = t; 62 QString str = t;
62 str [0] = str [0]. upper ( ); 63 str [0] = str [0]. upper ( );
63 setText ( str ); 64 setText ( str );
64 } 65 }
65 66
66 QString family ( ) const 67 QString family ( ) const
67 { 68 {
68 return m_name; 69 return m_name;
69 } 70 }
70 71
71 const QStringList &styles ( ) const 72 const QStringList &styles ( ) const
72 { 73 {
73 return m_styles; 74 return m_styles;
74 } 75 }
75 76
76 const QValueList<int> &sizes ( ) const 77 const QValueList<int> &sizes ( ) const
77 { 78 {
78 return m_sizes; 79 return m_sizes;
79 } 80 }
80 81
81private: 82private:
82 QStringList m_styles; 83 QStringList m_styles;
83 QValueList<int> m_sizes; 84 QValueList<int> m_sizes;
84 QString m_name; 85 QString m_name;
85}; 86};
86 87
87 88
88static int findItemCB ( QComboBox *box, const QString &str ) 89static int findItemCB ( QComboBox *box, const QString &str )
89{ 90{
90 for ( int i = 0; i < box-> count ( ); i++ ) { 91 for ( int i = 0; i < box-> count ( ); i++ ) {
91 if ( box-> text ( i ) == str ) 92 if ( box-> text ( i ) == str )
92 return i; 93 return i;
93 } 94 }
94 return -1; 95 return -1;
95} 96}
96 97
97 98}
99/* static same as anon. namespace */
98static int qt_version ( ) 100static int qt_version ( )
99{ 101{
100 const char *qver = qVersion ( ); 102 const char *qver = qVersion ( );
101 103
102 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); 104 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
103} 105}
104 106
105 107/**
108 * Constructs the Selector object
109 * @param withpreview If a font preview should be given
110 * @param parent The parent of the Font Selector
111 * @param name The name of the object
112 * @param fl WidgetFlags
113 */
106OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 114OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
107{ 115{
108 d = new OFontSelectorPrivate ( ); 116 d = new OFontSelectorPrivate ( );
109 117
110 QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 ); 118 QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 );
111 gridLayout->setRowStretch ( 4, 10 ); 119 gridLayout->setRowStretch ( 4, 10 );
112 120
113 d-> m_font_family_list = new QListBox( this, "FontListBox" ); 121 d-> m_font_family_list = new QListBox( this, "FontListBox" );
114 gridLayout->addMultiCellWidget( d-> m_font_family_list, 0, 4, 0, 0 ); 122 gridLayout->addMultiCellWidget( d-> m_font_family_list, 0, 4, 0, 0 );
115 connect( d-> m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); 123 connect( d-> m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) );
116 124
117 QLabel *label = new QLabel( tr( "Style" ), this ); 125 QLabel *label = new QLabel( tr( "Style" ), this );
118 gridLayout->addWidget( label, 0, 1 ); 126 gridLayout->addWidget( label, 0, 1 );
119 127
120 d-> m_font_style_list = new QComboBox( this, "StyleListBox" ); 128 d-> m_font_style_list = new QComboBox( this, "StyleListBox" );
121 connect( d-> m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); 129 connect( d-> m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) );
122 gridLayout->addWidget( d-> m_font_style_list, 1, 1 ); 130 gridLayout->addWidget( d-> m_font_style_list, 1, 1 );
123 131
124 label = new QLabel( tr( "Size" ), this ); 132 label = new QLabel( tr( "Size" ), this );
125 gridLayout->addWidget( label, 2, 1 ); 133 gridLayout->addWidget( label, 2, 1 );
126 134
127 d-> m_font_size_list = new QComboBox( this, "SizeListBox" ); 135 d-> m_font_size_list = new QComboBox( this, "SizeListBox" );
128 connect( d-> m_font_size_list, SIGNAL( activated( int ) ), 136 connect( d-> m_font_size_list, SIGNAL( activated( int ) ),
129 this, SLOT( fontSizeClicked( int ) ) ); 137 this, SLOT( fontSizeClicked( int ) ) );
130 gridLayout->addWidget( d-> m_font_size_list, 3, 1 ); 138 gridLayout->addWidget( d-> m_font_size_list, 3, 1 );
131 139
132 d-> m_pointbug = ( qt_version ( ) <= 233 ); 140 d-> m_pointbug = ( qt_version ( ) <= 233 );
133 141
134 if ( withpreview ) { 142 if ( withpreview ) {
135 d-> m_preview = new QMultiLineEdit ( this, "Preview" ); 143 d-> m_preview = new QMultiLineEdit ( this, "Preview" );
136 d-> m_preview-> setAlignment ( AlignCenter ); 144 d-> m_preview-> setAlignment ( AlignCenter );
137 d-> m_preview-> setWordWrap ( QMultiLineEdit::WidgetWidth ); 145 d-> m_preview-> setWordWrap ( QMultiLineEdit::WidgetWidth );
138 d-> m_preview-> setMargin ( 3 ); 146 d-> m_preview-> setMargin ( 3 );
139 d-> m_preview-> setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); 147 d-> m_preview-> setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
140 gridLayout-> addRowSpacing ( 5, 4 ); 148 gridLayout-> addRowSpacing ( 5, 4 );
141 gridLayout-> addMultiCellWidget ( d-> m_preview, 6, 6, 0, 1 ); 149 gridLayout-> addMultiCellWidget ( d-> m_preview, 6, 6, 0, 1 );
142 gridLayout-> setRowStretch ( 6, 5 ); 150 gridLayout-> setRowStretch ( 6, 5 );
143 } 151 }
144 else 152 else
145 d-> m_preview = 0; 153 d-> m_preview = 0;
146 154
147 loadFonts ( d-> m_font_family_list ); 155 loadFonts ( d-> m_font_family_list );
148} 156}
149 157
150OFontSelector::~OFontSelector ( ) 158OFontSelector::~OFontSelector ( )
151{ 159{
152 delete d; 160 delete d;
153} 161}
154 162
163/**
164 * This methods tries to set the font
165 * @param f The wishes font
166 * @return success or failure
167 */
155bool OFontSelector::setSelectedFont ( const QFont &f ) 168bool OFontSelector::setSelectedFont ( const QFont &f )
156{ 169{
157 return setSelectedFont ( f. family ( ), d-> m_fdb. styleString ( f ), f. pointSize ( ), QFont::encodingName ( f. charSet ( ))); 170 return setSelectedFont ( f. family ( ), d-> m_fdb. styleString ( f ), f. pointSize ( ), QFont::encodingName ( f. charSet ( )));
158} 171}
159 172
160bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & /*charset*/ ) 173
174/**
175 * This is an overloaded method @see setSelectedFont
176 * @param familyStr The family of the font
177 * @param styleStr The style of the font
178 * @param sizeVal The size of font
179 * @param charset The charset to be used. Will be deprecated by QT3
180 */
181bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset )
161{ 182{
162 QString sizeStr = QString::number ( sizeVal ); 183 QString sizeStr = QString::number ( sizeVal );
163 184
164 QListBoxItem *family = d-> m_font_family_list-> findItem ( familyStr ); 185 QListBoxItem *family = d-> m_font_family_list-> findItem ( familyStr );
165 if ( !family ) 186 if ( !family )
166 family = d-> m_font_family_list-> findItem ( "Helvetica" ); 187 family = d-> m_font_family_list-> findItem ( "Helvetica" );
167 if ( !family ) 188 if ( !family )
168 family = d-> m_font_family_list-> firstItem ( ); 189 family = d-> m_font_family_list-> firstItem ( );
169 d-> m_font_family_list-> setCurrentItem ( family ); 190 d-> m_font_family_list-> setCurrentItem ( family );
170 fontFamilyClicked ( d-> m_font_family_list-> index ( family )); 191 fontFamilyClicked ( d-> m_font_family_list-> index ( family ));
171 192
172 int style = findItemCB ( d-> m_font_style_list, styleStr ); 193 int style = findItemCB ( d-> m_font_style_list, styleStr );
173 if ( style < 0 ) 194 if ( style < 0 )
174 style = findItemCB ( d-> m_font_style_list, "Regular" ); 195 style = findItemCB ( d-> m_font_style_list, "Regular" );
175 if ( style < 0 && d-> m_font_style_list-> count ( ) > 0 ) 196 if ( style < 0 && d-> m_font_style_list-> count ( ) > 0 )
176 style = 0; 197 style = 0;
177 d-> m_font_style_list-> setCurrentItem ( style ); 198 d-> m_font_style_list-> setCurrentItem ( style );
178 fontStyleClicked ( style ); 199 fontStyleClicked ( style );
179 200
180 int size = findItemCB ( d-> m_font_size_list, sizeStr ); 201 int size = findItemCB ( d-> m_font_size_list, sizeStr );
181 if ( size < 0 ) 202 if ( size < 0 )
182 size = findItemCB ( d-> m_font_size_list, "10" ); 203 size = findItemCB ( d-> m_font_size_list, "10" );
183 if ( size < 0 && d-> m_font_size_list-> count ( ) > 0 ) 204 if ( size < 0 && d-> m_font_size_list-> count ( ) > 0 )
184 size = 0; 205 size = 0;
185 d-> m_font_size_list-> setCurrentItem ( size ); 206 d-> m_font_size_list-> setCurrentItem ( size );
186 fontSizeClicked ( size ); 207 fontSizeClicked ( size );
187 208
188 return (( family ) && ( style >= 0 ) && ( size >= 0 )); 209 return (( family ) && ( style >= 0 ) && ( size >= 0 ));
189} 210}
190 211
212/**
213 * This method returns the name, style and size of the currently selected
214 * font or false if no font is selected
215 * @param family The font family will be written there
216 * @param style The style will be written there
217 * @param size The size will be written there
218 * @return success or failure
219 */
191bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) 220bool OFontSelector::selectedFont ( QString &family, QString &style, int &size )
192{ 221{
193 QString dummy; 222 QString dummy;
194 return selectedFont ( family, style, size, dummy ); 223 return selectedFont ( family, style, size, dummy );
195} 224}
196 225
197 226
227/**
228 * This method does return the font family or QString::null if there is
229 * no font item selected
230 * @return the font family
231 */
198QString OFontSelector::fontFamily ( ) const 232QString OFontSelector::fontFamily ( ) const
199{ 233{
200 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); 234 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( ));
201 235
202 return fli ? fli-> family ( ) : QString::null; 236 return fli ? fli-> family ( ) : QString::null;
203} 237}
204 238
239/**
240 * This method will return the style of the font or QString::null
241 * @return the style of the font
242 */
205QString OFontSelector::fontStyle ( ) const 243QString OFontSelector::fontStyle ( ) const
206{ 244{
207 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); 245 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( ));
208 int fst = d-> m_font_style_list-> currentItem ( ); 246 int fst = d-> m_font_style_list-> currentItem ( );
209 247
210 return ( fli && fst >= 0 ) ? fli-> styles ( ) [fst] : QString::null; 248 return ( fli && fst >= 0 ) ? fli-> styles ( ) [fst] : QString::null;
211} 249}
212 250
251/**
252 * This method will return the font size or 10 if no font size is available
253 */
213int OFontSelector::fontSize ( ) const 254int OFontSelector::fontSize ( ) const
214{ 255{
215 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); 256 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( ));
216 int fsi = d-> m_font_size_list-> currentItem ( ); 257 int fsi = d-> m_font_size_list-> currentItem ( );
217 258
218 return ( fli && fsi >= 0 ) ? fli-> sizes ( ) [fsi] : 10; 259 return ( fli && fsi >= 0 ) ? fli-> sizes ( ) [fsi] : 10;
219} 260}
220 261
262/**
263 * returns the charset of the font or QString::null
264 */
221QString OFontSelector::fontCharSet ( ) const 265QString OFontSelector::fontCharSet ( ) const
222{ 266{
223 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); 267 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( ));
224 268
225 return fli ? d-> m_fdb. charSets ( fli-> family ( )) [0] : QString::null; 269 return fli ? d-> m_fdb. charSets ( fli-> family ( )) [0] : QString::null;
226} 270}
227 271
272/**
273 * Overloaded member function see above
274 * @see selectedFont
275 */
228bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) 276bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset )
229{ 277{
230 int ffa = d-> m_font_family_list-> currentItem ( ); 278 int ffa = d-> m_font_family_list-> currentItem ( );
231 int fst = d-> m_font_style_list-> currentItem ( ); 279 int fst = d-> m_font_style_list-> currentItem ( );
232 int fsi = d-> m_font_size_list-> currentItem ( ); 280 int fsi = d-> m_font_size_list-> currentItem ( );
233 281
234 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( ffa ); 282 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( ffa );
235 283
236 if ( fli ) { 284 if ( fli ) {
237 family = fli-> family ( ); 285 family = fli-> family ( );
238 style = fst >= 0 ? fli-> styles ( ) [fst] : QString::null; 286 style = fst >= 0 ? fli-> styles ( ) [fst] : QString::null;
239 size = fsi >= 0 ? fli-> sizes ( ) [fsi] : 10; 287 size = fsi >= 0 ? fli-> sizes ( ) [fsi] : 10;
240 charset = d-> m_fdb. charSets ( fli-> family ( )) [0]; 288 charset = d-> m_fdb. charSets ( fli-> family ( )) [0];
241 289
242 return true; 290 return true;
243 } 291 }
244 else 292 else
245 return false; 293 return false;
246} 294}
247 295
248 296
249 297
250 298
251void OFontSelector::loadFonts ( QListBox *list ) 299void OFontSelector::loadFonts ( QListBox *list )
252{ 300{
253 QStringList f = d-> m_fdb. families ( ); 301 QStringList f = d-> m_fdb. families ( );
254 302
255 for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) { 303 for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) {
256 QValueList <int> ps = d-> m_fdb. pointSizes ( *it ); 304 QValueList <int> ps = d-> m_fdb. pointSizes ( *it );
257 305
258 if ( d-> m_pointbug ) { 306 if ( d-> m_pointbug ) {
259 for ( QValueList <int>::Iterator it = ps. begin ( ); it != ps. end ( ); it++ ) 307 for ( QValueList <int>::Iterator it = ps. begin ( ); it != ps. end ( ); it++ )
260 *it /= 10; 308 *it /= 10;
261 } 309 }
262 310
263 list-> insertItem ( new FontListItem ( *it, d-> m_fdb. styles ( *it ), ps )); 311 list-> insertItem ( new FontListItem ( *it, d-> m_fdb. styles ( *it ), ps ));
264 } 312 }
265} 313}
266 314
267void OFontSelector::fontFamilyClicked ( int index ) 315void OFontSelector::fontFamilyClicked ( int index )
268{ 316{
269 QString oldstyle = d-> m_font_style_list-> currentText ( ); 317 QString oldstyle = d-> m_font_style_list-> currentText ( );
270 QString oldsize = d-> m_font_size_list-> currentText ( ); 318 QString oldsize = d-> m_font_size_list-> currentText ( );
271 319
272 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( index ); 320 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( index );
273 321
274 d-> m_font_style_list-> clear ( ); 322 d-> m_font_style_list-> clear ( );
275 d-> m_font_style_list-> insertStringList ( fli-> styles ( )); 323 d-> m_font_style_list-> insertStringList ( fli-> styles ( ));
276 d-> m_font_style_list-> setEnabled ( !fli-> styles ( ). isEmpty ( )); 324 d-> m_font_style_list-> setEnabled ( !fli-> styles ( ). isEmpty ( ));
277 325
278 int i; 326 int i;
279 327
280 i = findItemCB ( d-> m_font_style_list, oldstyle ); 328 i = findItemCB ( d-> m_font_style_list, oldstyle );
281 if ( i < 0 ) 329 if ( i < 0 )
282 i = findItemCB ( d-> m_font_style_list, "Regular" ); 330 i = findItemCB ( d-> m_font_style_list, "Regular" );
283 if (( i < 0 ) && ( d-> m_font_style_list-> count ( ) > 0 )) 331 if (( i < 0 ) && ( d-> m_font_style_list-> count ( ) > 0 ))
284 i = 0; 332 i = 0;
285 333
286 if ( i >= 0 ) { 334 if ( i >= 0 ) {
287 d-> m_font_style_list-> setCurrentItem ( i ); 335 d-> m_font_style_list-> setCurrentItem ( i );
288 fontStyleClicked ( i ); 336 fontStyleClicked ( i );
289 } 337 }
290 338
291 d-> m_font_size_list-> clear ( ); 339 d-> m_font_size_list-> clear ( );
292 QValueList<int> sl = fli-> sizes ( ); 340 QValueList<int> sl = fli-> sizes ( );
293 341
294 for ( QValueList<int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) 342 for ( QValueList<int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
295 d-> m_font_size_list-> insertItem ( QString::number ( *it )); 343 d-> m_font_size_list-> insertItem ( QString::number ( *it ));
296 344
297 i = findItemCB ( d-> m_font_size_list, oldsize ); 345 i = findItemCB ( d-> m_font_size_list, oldsize );
298 if ( i < 0 ) 346 if ( i < 0 )
299 i = findItemCB ( d-> m_font_size_list, "10" ); 347 i = findItemCB ( d-> m_font_size_list, "10" );
300 if (( i < 0 ) && ( d-> m_font_size_list-> count ( ) > 0 )) 348 if (( i < 0 ) && ( d-> m_font_size_list-> count ( ) > 0 ))
301 i = 0; 349 i = 0;
302 350
303 if ( i >= 0 ) { 351 if ( i >= 0 ) {
304 d-> m_font_size_list-> setCurrentItem ( i ); 352 d-> m_font_size_list-> setCurrentItem ( i );
305 fontSizeClicked ( i ); 353 fontSizeClicked ( i );
306 } 354 }
307 changeFont ( ); 355 changeFont ( );
308} 356}
309 357
310void OFontSelector::fontStyleClicked ( int /*index*/ ) 358void OFontSelector::fontStyleClicked ( int /*index*/ )
311{ 359{
312 changeFont ( ); 360 changeFont ( );
313} 361}
314 362
315void OFontSelector::fontSizeClicked ( int /*index*/ ) 363void OFontSelector::fontSizeClicked ( int /*index*/ )
316{ 364{
317 changeFont ( ); 365 changeFont ( );
318} 366}
319 367
320void OFontSelector::changeFont ( ) 368void OFontSelector::changeFont ( )
321{ 369{
322 QFont f = selectedFont ( ); 370 QFont f = selectedFont ( );
323 371
324 if ( d-> m_preview ) 372 if ( d-> m_preview )
325 d-> m_preview-> setFont ( f ); 373 d-> m_preview-> setFont ( f );
326 374
327 emit fontSelected ( f ); 375 emit fontSelected ( f );
328} 376}
329 377
330 378/**
379 * Return the selected font
380 */
331QFont OFontSelector::selectedFont ( ) 381QFont OFontSelector::selectedFont ( )
332{ 382{
333 int ffa = d-> m_font_family_list-> currentItem ( ); 383 int ffa = d-> m_font_family_list-> currentItem ( );
334 int fst = d-> m_font_style_list-> currentItem ( ); 384 int fst = d-> m_font_style_list-> currentItem ( );
335 int fsi = d-> m_font_size_list-> currentItem ( ); 385 int fsi = d-> m_font_size_list-> currentItem ( );
336 386
337 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( ffa ); 387 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( ffa );
338 388
339 if ( fli ) { 389 if ( fli ) {
340 return d-> m_fdb. font ( fli-> family ( ), \ 390 return d-> m_fdb. font ( fli-> family ( ), \
341 fst >= 0 ? fli-> styles ( ) [fst] : QString::null, \ 391 fst >= 0 ? fli-> styles ( ) [fst] : QString::null, \
342 fsi >= 0 ? fli-> sizes ( ) [fsi] : 10, \ 392 fsi >= 0 ? fli-> sizes ( ) [fsi] : 10, \
343 d-> m_fdb. charSets ( fli-> family ( )) [0] ); 393 d-> m_fdb. charSets ( fli-> family ( )) [0] );
344 } 394 }
345 else 395 else
346 return QFont ( ); 396 return QFont ( );
347} 397}
348 398
349 399
350void OFontSelector::resizeEvent ( QResizeEvent *re ) 400void OFontSelector::resizeEvent ( QResizeEvent *re )
351{ 401{
352 if ( d-> m_preview ) { 402 if ( d-> m_preview ) {
353 d-> m_preview-> setMinimumHeight ( 1 ); 403 d-> m_preview-> setMinimumHeight ( 1 );
354 d-> m_preview-> setMaximumHeight ( 32767 ); 404 d-> m_preview-> setMaximumHeight ( 32767 );
355 } 405 }
356 406
357 QWidget::resizeEvent ( re ); 407 QWidget::resizeEvent ( re );
358 408
359 if ( d-> m_preview ) 409 if ( d-> m_preview )
360 d-> m_preview-> setFixedHeight ( d-> m_preview-> height ( )); 410 d-> m_preview-> setFixedHeight ( d-> m_preview-> height ( ));
361 411
362} 412}
diff --git a/libopie/ofontselector.h b/libopie/ofontselector.h
index 10d16f0..95ffd04 100644
--- a/libopie/ofontselector.h
+++ b/libopie/ofontselector.h
@@ -1,80 +1,93 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef __OPIE_FONTSELECTOR_H__ 29#ifndef OPIE_FONTSELECTOR_H__
30#define __OPIE_FONTSELECTOR_H__ 30#define OPIE_FONTSELECTOR_H__
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34class QListBox; 34class QListBox;
35class OFontSelectorPrivate; 35class OFontSelectorPrivate;
36 36
37 37/**
38 * This class lets you chose a Font out of a list of Fonts.
39 * It can show a preview too. This selector will use all available
40 * fonts
41 *
42 *
43 * @short A widget to select a font
44 * @see QWidget
45 * @see QFont
46 * @author Rober Griebl
47 */
38class OFontSelector : public QWidget 48class OFontSelector : public QWidget
39{ 49{
40 Q_OBJECT 50 Q_OBJECT
41 51
42public: 52public:
43 OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 53 OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
44 virtual ~OFontSelector ( ); 54 virtual ~OFontSelector ( );
45 55
46 bool selectedFont ( QString &family, QString &style, int &size ); 56 bool selectedFont ( QString &family, QString &style, int &size );
47 bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); 57 bool selectedFont ( QString &family, QString &style, int &size, QString &charset );
48 58
49 QFont selectedFont ( ); 59 QFont selectedFont ( );
50 60
51 bool setSelectedFont ( const QFont & ); 61 bool setSelectedFont ( const QFont & );
52 bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 ); 62 bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 );
53 63
54 QString fontFamily ( ) const; 64 QString fontFamily ( ) const;
55 QString fontStyle ( ) const; 65 QString fontStyle ( ) const;
56 int fontSize ( ) const; 66 int fontSize ( ) const;
57 QString fontCharSet ( ) const; 67 QString fontCharSet ( ) const;
58 68
59signals: 69signals:
70 /**
71 * This signal gets emitted when a font got chosen
72 */
60 void fontSelected ( const QFont & ); 73 void fontSelected ( const QFont & );
61 74
62protected slots: 75protected slots:
63 virtual void fontFamilyClicked ( int ); 76 virtual void fontFamilyClicked ( int );
64 virtual void fontStyleClicked ( int ); 77 virtual void fontStyleClicked ( int );
65 virtual void fontSizeClicked ( int ); 78 virtual void fontSizeClicked ( int );
66 79
67protected: 80protected:
68 virtual void resizeEvent ( QResizeEvent *re ); 81 virtual void resizeEvent ( QResizeEvent *re );
69 82
70private: 83private:
71 void loadFonts ( QListBox * ); 84 void loadFonts ( QListBox * );
72 85
73 void changeFont ( ); 86 void changeFont ( );
74 87
75private: 88private:
76 OFontSelectorPrivate *d; 89 OFontSelectorPrivate *d;
77}; 90};
78 91
79#endif 92#endif
80 93
diff --git a/libopie/orecurrancewidget.cpp b/libopie/orecurrancewidget.cpp
index db86184..471249d 100644
--- a/libopie/orecurrancewidget.cpp
+++ b/libopie/orecurrancewidget.cpp
@@ -1,566 +1,610 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qpopupmenu.h> 3#include <qpopupmenu.h>
4#include <qspinbox.h> 4#include <qspinbox.h>
5 5
6#include <qpe/timestring.h> 6#include <qpe/timestring.h>
7 7
8#include "orecurrancewidget.h" 8#include "orecurrancewidget.h"
9 9
10// Global Templates for use in setting up the repeat label... 10// Global Templates for use in setting up the repeat label...
11const QString strDayTemplate = QObject::tr("Every"); 11const QString strDayTemplate = QObject::tr("Every");
12const QString strYearTemplate = QObject::tr("%1 %2 every "); 12const QString strYearTemplate = QObject::tr("%1 %2 every ");
13const QString strMonthDateTemplate = QObject::tr("The %1 every "); 13const QString strMonthDateTemplate = QObject::tr("The %1 every ");
14const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); 14const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every");
15const QString strWeekTemplate = QObject::tr("Every "); 15const QString strWeekTemplate = QObject::tr("Every ");
16const QString dayLabel[] = { QObject::tr("Monday"), 16const QString dayLabel[] = { QObject::tr("Monday"),
17 QObject::tr("Tuesday"), 17 QObject::tr("Tuesday"),
18 QObject::tr("Wednesday"), 18 QObject::tr("Wednesday"),
19 QObject::tr("Thursday"), 19 QObject::tr("Thursday"),
20 QObject::tr("Friday"), 20 QObject::tr("Friday"),
21 QObject::tr("Saturday"), 21 QObject::tr("Saturday"),
22 QObject::tr("Sunday") }; 22 QObject::tr("Sunday") };
23 23
24 24
25 static QString numberPlacing( int x );// return the proper word format for 25 static QString numberPlacing( int x );// return the proper word format for
26 // x (1st, 2nd, etc) 26 // x (1st, 2nd, etc)
27static int week( const QDate &dt ); // what week in the month is dt? 27static int week( const QDate &dt ); // what week in the month is dt?
28 28
29 29/**
30 * Constructs the Widget
31 * @param startOnMonday Does the week start on monday
32 * @param newStart The start date of the recurrence
33 * @param parent The parent widget
34 * @param name the name of object
35 * @param modal if the dialog should be modal
36 * @param fl Additional window flags
37 */
30ORecurranceWidget::ORecurranceWidget( bool startOnMonday, 38ORecurranceWidget::ORecurranceWidget( bool startOnMonday,
31 const QDate& newStart, 39 const QDate& newStart,
32 QWidget* parent, 40 QWidget* parent,
33 const char* name, 41 const char* name,
34 bool modal, 42 bool modal,
35 WFlags fl ) 43 WFlags fl )
36 : ORecurranceBase( parent, name, modal, fl ), 44 : ORecurranceBase( parent, name, modal, fl ),
37 start( newStart ), 45 start( newStart ),
38 currInterval( None ), 46 currInterval( None ),
39 startWeekOnMonday( startOnMonday ) 47 startWeekOnMonday( startOnMonday )
40{ 48{
41 init(); 49 init();
42 fraType->setButton( currInterval ); 50 fraType->setButton( currInterval );
43 chkNoEnd->setChecked( TRUE ); 51 chkNoEnd->setChecked( TRUE );
44 setupNone(); 52 setupNone();
45} 53}
54
55/**
56 * Different constructor
57 * @param startOnMonday Does the week start on monday?
58 * @param rp Already set ORecur object
59 * @param startDate The start date
60 * @param parent The parent widget
61 * @param name The name of the object
62 * @param modal
63 * @param fl The flags for window
64 */
46ORecurranceWidget::ORecurranceWidget( bool startOnMonday, 65ORecurranceWidget::ORecurranceWidget( bool startOnMonday,
47 const ORecur& rp, const QDate& startDate, 66 const ORecur& rp, const QDate& startDate,
48 QWidget* parent, const char* name, 67 QWidget* parent, const char* name,
49 bool modal, WFlags fl) 68 bool modal, WFlags fl)
50 : ORecurranceBase( parent, name, modal, fl ), 69 : ORecurranceBase( parent, name, modal, fl ),
51 start( startDate ), 70 start( startDate ),
52 end( rp.endDate() ), 71 end( rp.endDate() ),
53 startWeekOnMonday( startOnMonday ) 72 startWeekOnMonday( startOnMonday )
54{ 73{
55 // do some stuff with the repeat pattern 74 // do some stuff with the repeat pattern
56 init(); 75 init();
57 setRecurrence( rp ); 76 setRecurrence( rp );
58} 77}
59 78
60ORecurranceWidget::~ORecurranceWidget() { 79ORecurranceWidget::~ORecurranceWidget() {
61} 80}
81
82/**
83 * set the start date
84 * @param date the new start date
85 */
62void ORecurranceWidget::setStartDate( const QDate& date ) { 86void ORecurranceWidget::setStartDate( const QDate& date ) {
63 qWarning("ORecurranceWidget::setStartDate"); 87 qWarning("ORecurranceWidget::setStartDate");
64 setRecurrence( recurrence(), date ); 88 setRecurrence( recurrence(), date );
65} 89}
90/**
91 * set the recurrence
92 * @param rp The ORecur object with the new recurrence rules
93 */
66void ORecurranceWidget::setRecurrence( const ORecur& rp ) { 94void ORecurranceWidget::setRecurrence( const ORecur& rp ) {
67 setRecurrence( rp, start ); 95 setRecurrence( rp, start );
68} 96}
97
98/**
99 * overloaded method taking ORecur and a new start date
100 * @param rp Recurrence rule
101 * @param date The new start date
102 */
69void ORecurranceWidget::setRecurrence( const ORecur& rp, const QDate& date ) { 103void ORecurranceWidget::setRecurrence( const ORecur& rp, const QDate& date ) {
70 start = date; 104 start = date;
71 end = rp.endDate(); 105 end = rp.endDate();
72 switch ( rp.type() ) { 106 switch ( rp.type() ) {
73 default: 107 default:
74 case ORecur::NoRepeat: 108 case ORecur::NoRepeat:
75 currInterval = None; 109 currInterval = None;
76 setupNone(); 110 setupNone();
77 break; 111 break;
78 case ORecur::Daily: 112 case ORecur::Daily:
79 currInterval = Day; 113 currInterval = Day;
80 setupDaily(); 114 setupDaily();
81 break; 115 break;
82 case ORecur::Weekly: 116 case ORecur::Weekly:
83 currInterval = Week; 117 currInterval = Week;
84 setupWeekly(); 118 setupWeekly();
85 int day, buttons; 119 int day, buttons;
86 for ( day = 0x01, buttons = 0; buttons < 7; 120 for ( day = 0x01, buttons = 0; buttons < 7;
87 day = day << 1, buttons++ ) { 121 day = day << 1, buttons++ ) {
88 if ( rp.days() & day ) { 122 if ( rp.days() & day ) {
89 if ( startWeekOnMonday ) 123 if ( startWeekOnMonday )
90 fraExtra->setButton( buttons ); 124 fraExtra->setButton( buttons );
91 else { 125 else {
92 if ( buttons == 7 ) 126 if ( buttons == 7 )
93 fraExtra->setButton( 0 ); 127 fraExtra->setButton( 0 );
94 else 128 else
95 fraExtra->setButton( buttons + 1 ); 129 fraExtra->setButton( buttons + 1 );
96 } 130 }
97 } 131 }
98 } 132 }
99 slotWeekLabel(); 133 slotWeekLabel();
100 break; 134 break;
101 case ORecur::MonthlyDay: 135 case ORecur::MonthlyDay:
102 currInterval = Month; 136 currInterval = Month;
103 setupMonthly(); 137 setupMonthly();
104 fraExtra->setButton( 0 ); 138 fraExtra->setButton( 0 );
105 slotMonthLabel( 0 ); 139 slotMonthLabel( 0 );
106 break; 140 break;
107 case ORecur::MonthlyDate: 141 case ORecur::MonthlyDate:
108 currInterval = Month; 142 currInterval = Month;
109 setupMonthly(); 143 setupMonthly();
110 fraExtra->setButton( 1 ); 144 fraExtra->setButton( 1 );
111 slotMonthLabel( 1 ); 145 slotMonthLabel( 1 );
112 break; 146 break;
113 case ORecur::Yearly: 147 case ORecur::Yearly:
114 currInterval = Year; 148 currInterval = Year;
115 setupYearly(); 149 setupYearly();
116 break; 150 break;
117 } 151 }
118 fraType->setButton( currInterval ); 152 fraType->setButton( currInterval );
119 spinFreq->setValue( rp.frequency() ); 153 spinFreq->setValue( rp.frequency() );
120 if ( !rp.hasEndDate() ) { 154 if ( !rp.hasEndDate() ) {
121 cmdEnd->setText( tr("No End Date") ); 155 cmdEnd->setText( tr("No End Date") );
122 chkNoEnd->setChecked( TRUE ); 156 chkNoEnd->setChecked( TRUE );
123 } else 157 } else
124 cmdEnd->setText( TimeString::shortDate( end ) ); 158 cmdEnd->setText( TimeString::shortDate( end ) );
125} 159}
160
161/**
162 * the user selected recurrence rule.
163 * @return The recurrence rule.
164 */
126ORecur ORecurranceWidget::recurrence()const { 165ORecur ORecurranceWidget::recurrence()const {
127 QListIterator<QToolButton> it( listRTypeButtons ); 166 QListIterator<QToolButton> it( listRTypeButtons );
128 QListIterator<QToolButton> itExtra( listExtra ); 167 QListIterator<QToolButton> itExtra( listExtra );
129 ORecur rpTmp; 168 ORecur rpTmp;
130 int i; 169 int i;
131 for ( i = 0; *it; ++it, i++ ) { 170 for ( i = 0; *it; ++it, i++ ) {
132 if ( (*it)->isOn() ) { 171 if ( (*it)->isOn() ) {
133 switch ( i ) { 172 switch ( i ) {
134 case None: 173 case None:
135 rpTmp.setType( ORecur::NoRepeat ); 174 rpTmp.setType( ORecur::NoRepeat );
136 break; 175 break;
137 case Day: 176 case Day:
138 rpTmp.setType( ORecur::Daily ); 177 rpTmp.setType( ORecur::Daily );
139 break; 178 break;
140 case Week:{ 179 case Week:{
141 rpTmp.setType( ORecur::Weekly ); 180 rpTmp.setType( ORecur::Weekly );
142 int day; 181 int day;
143 int day2 = 0; 182 int day2 = 0;
144 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { 183 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
145 if ( (*itExtra)->isOn() ) { 184 if ( (*itExtra)->isOn() ) {
146 if ( startWeekOnMonday ) 185 if ( startWeekOnMonday )
147 day2 |= day; 186 day2 |= day;
148 else { 187 else {
149 if ( day == 1 ) 188 if ( day == 1 )
150 day2 |= Event::SUN; 189 day2 |= Event::SUN;
151 else 190 else
152 day2 |= day >> 1; 191 day2 |= day >> 1;
153 } 192 }
154 } 193 }
155 } 194 }
156 rpTmp.setDays( day2 ); 195 rpTmp.setDays( day2 );
157 } 196 }
158 break; 197 break;
159 case Month: 198 case Month:
160 if ( cmdExtra1->isOn() ) 199 if ( cmdExtra1->isOn() )
161 rpTmp.setType( ORecur::MonthlyDay ); 200 rpTmp.setType( ORecur::MonthlyDay );
162 else if ( cmdExtra2->isOn() ) 201 else if ( cmdExtra2->isOn() )
163 rpTmp.setType( ORecur::MonthlyDate ); 202 rpTmp.setType( ORecur::MonthlyDate );
164 // figure out the montly day... 203 // figure out the montly day...
165 rpTmp.setPosition( week( start ) ); 204 rpTmp.setPosition( week( start ) );
166 break; 205 break;
167 case Year: 206 case Year:
168 rpTmp.setType( ORecur::Yearly ); 207 rpTmp.setType( ORecur::Yearly );
169 break; 208 break;
170 } 209 }
171 break; // no need to keep looking! 210 break; // no need to keep looking!
172 } 211 }
173 } 212 }
174 rpTmp.setFrequency(spinFreq->value() ); 213 rpTmp.setFrequency(spinFreq->value() );
175 rpTmp.setHasEndDate( !chkNoEnd->isChecked() ); 214 rpTmp.setHasEndDate( !chkNoEnd->isChecked() );
176 if ( rpTmp.hasEndDate() ) { 215 if ( rpTmp.hasEndDate() ) {
177 rpTmp.setEndDate( end ); 216 rpTmp.setEndDate( end );
178 } 217 }
179 // timestamp it... 218 // timestamp it...
180// rpTmp.setCreateTime( ); current DateTime is already set -zecke 219// rpTmp.setCreateTime( ); current DateTime is already set -zecke
181 return rpTmp; 220 return rpTmp;
182} 221}
222
223/**
224 * Return the end date of the recurrence. This is only
225 * valid if the recurrence rule does contain an enddate
226 */
183QDate ORecurranceWidget::endDate()const { 227QDate ORecurranceWidget::endDate()const {
184 return end; 228 return end;
185} 229}
186void ORecurranceWidget::slotSetRType(int rtype) { 230void ORecurranceWidget::slotSetRType(int rtype) {
187 // now call the right function based on the type... 231 // now call the right function based on the type...
188 currInterval = static_cast<repeatButtons>(rtype); 232 currInterval = static_cast<repeatButtons>(rtype);
189 switch ( currInterval ) { 233 switch ( currInterval ) {
190 case None: 234 case None:
191 setupNone(); 235 setupNone();
192 break; 236 break;
193 case Day: 237 case Day:
194 setupDaily(); 238 setupDaily();
195 break; 239 break;
196 case Week: 240 case Week:
197 setupWeekly(); 241 setupWeekly();
198 slotWeekLabel(); 242 slotWeekLabel();
199 break; 243 break;
200 case Month: 244 case Month:
201 setupMonthly(); 245 setupMonthly();
202 cmdExtra2->setOn( TRUE ); 246 cmdExtra2->setOn( TRUE );
203 slotMonthLabel( 1 ); 247 slotMonthLabel( 1 );
204 break; 248 break;
205 case Year: 249 case Year:
206 setupYearly(); 250 setupYearly();
207 break; 251 break;
208 } 252 }
209} 253}
210void ORecurranceWidget::endDateChanged(int y, int m, int d) { 254void ORecurranceWidget::endDateChanged(int y, int m, int d) {
211 end.setYMD( y, m, d ); 255 end.setYMD( y, m, d );
212 if ( end < start ) 256 if ( end < start )
213 end = start; 257 end = start;
214 cmdEnd->setText( TimeString::shortDate( end ) ); 258 cmdEnd->setText( TimeString::shortDate( end ) );
215 repeatPicker->setDate( end.year(), end.month(), end.day() ); 259 repeatPicker->setDate( end.year(), end.month(), end.day() );
216} 260}
217void ORecurranceWidget::slotNoEnd( bool unused) { 261void ORecurranceWidget::slotNoEnd( bool unused) {
218 // if the item was toggled, then go ahead and set it to the maximum date 262 // if the item was toggled, then go ahead and set it to the maximum date
219 if ( unused ) { 263 if ( unused ) {
220 end.setYMD( 3000, 12, 31 ); 264 end.setYMD( 3000, 12, 31 );
221 cmdEnd->setText( tr("No End Date") ); 265 cmdEnd->setText( tr("No End Date") );
222 } else { 266 } else {
223 end = start; 267 end = start;
224 cmdEnd->setText( TimeString::shortDate(end) ); 268 cmdEnd->setText( TimeString::shortDate(end) );
225 } 269 }
226} 270}
227void ORecurranceWidget::setupRepeatLabel( const QString& s) { 271void ORecurranceWidget::setupRepeatLabel( const QString& s) {
228 lblVar1->setText( s ); 272 lblVar1->setText( s );
229} 273}
230void ORecurranceWidget::setupRepeatLabel( int x) { 274void ORecurranceWidget::setupRepeatLabel( int x) {
231 // change the spelling based on the value of x 275 // change the spelling based on the value of x
232 QString strVar2; 276 QString strVar2;
233 277
234 if ( x > 1 ) 278 if ( x > 1 )
235 lblVar1->show(); 279 lblVar1->show();
236 else 280 else
237 lblVar1->hide(); 281 lblVar1->hide();
238 282
239 switch ( currInterval ) { 283 switch ( currInterval ) {
240 case None: 284 case None:
241 break; 285 break;
242 case Day: 286 case Day:
243 if ( x > 1 ) 287 if ( x > 1 )
244 strVar2 = tr( "days" ); 288 strVar2 = tr( "days" );
245 else 289 else
246 strVar2 = tr( "day" ); 290 strVar2 = tr( "day" );
247 break; 291 break;
248 case Week: 292 case Week:
249 if ( x > 1 ) 293 if ( x > 1 )
250 strVar2 = tr( "weeks" ); 294 strVar2 = tr( "weeks" );
251 else 295 else
252 strVar2 = tr( "week" ); 296 strVar2 = tr( "week" );
253 break; 297 break;
254 case Month: 298 case Month:
255 if ( x > 1 ) 299 if ( x > 1 )
256 strVar2 = tr( "months" ); 300 strVar2 = tr( "months" );
257 else 301 else
258 strVar2 = tr( "month" ); 302 strVar2 = tr( "month" );
259 break; 303 break;
260 case Year: 304 case Year:
261 if ( x > 1 ) 305 if ( x > 1 )
262 strVar2 = tr( "years" ); 306 strVar2 = tr( "years" );
263 else 307 else
264 strVar2 = tr( "year" ); 308 strVar2 = tr( "year" );
265 break; 309 break;
266 } 310 }
267 if ( !strVar2.isNull() ) 311 if ( !strVar2.isNull() )
268 lblVar2->setText( strVar2 ); 312 lblVar2->setText( strVar2 );
269} 313}
270void ORecurranceWidget::slotWeekLabel() { 314void ORecurranceWidget::slotWeekLabel() {
271 QString str; 315 QString str;
272 QListIterator<QToolButton> it( listExtra ); 316 QListIterator<QToolButton> it( listExtra );
273 unsigned int i; 317 unsigned int i;
274 unsigned int keepMe; 318 unsigned int keepMe;
275 bool bNeedCarriage = FALSE; 319 bool bNeedCarriage = FALSE;
276 // don't do something we'll regret!!! 320 // don't do something we'll regret!!!
277 if ( currInterval != Week ) 321 if ( currInterval != Week )
278 return; 322 return;
279 323
280 if ( startWeekOnMonday ) 324 if ( startWeekOnMonday )
281 keepMe = start.dayOfWeek() - 1; 325 keepMe = start.dayOfWeek() - 1;
282 else 326 else
283 keepMe = start.dayOfWeek() % 7; 327 keepMe = start.dayOfWeek() % 7;
284 328
285 QStringList list; 329 QStringList list;
286 for ( i = 0; *it; ++it, i++ ) { 330 for ( i = 0; *it; ++it, i++ ) {
287 // a crazy check, if you are repeating weekly, the current day 331 // a crazy check, if you are repeating weekly, the current day
288 // must be selected!!! 332 // must be selected!!!
289 if ( i == keepMe && !( (*it)->isOn() ) ) 333 if ( i == keepMe && !( (*it)->isOn() ) )
290 (*it)->setOn( TRUE ); 334 (*it)->setOn( TRUE );
291 if ( (*it)->isOn() ) { 335 if ( (*it)->isOn() ) {
292 if ( startWeekOnMonday ) 336 if ( startWeekOnMonday )
293 list.append( dayLabel[i] ); 337 list.append( dayLabel[i] );
294 else { 338 else {
295 if ( i == 0 ) 339 if ( i == 0 )
296 list.append( dayLabel[6] ); 340 list.append( dayLabel[6] );
297 else 341 else
298 list.append( dayLabel[i - 1] ); 342 list.append( dayLabel[i - 1] );
299 } 343 }
300 } 344 }
301 } 345 }
302 QStringList::Iterator itStr; 346 QStringList::Iterator itStr;
303 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { 347 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
304 if ( i == 3 ) 348 if ( i == 3 )
305 bNeedCarriage = TRUE; 349 bNeedCarriage = TRUE;
306 else 350 else
307 bNeedCarriage = FALSE; 351 bNeedCarriage = FALSE;
308 if ( str.isNull() ) 352 if ( str.isNull() )
309 str = *itStr; 353 str = *itStr;
310 else if ( i == list.count() - 1 ) { 354 else if ( i == list.count() - 1 ) {
311 if ( i < 2 ) 355 if ( i < 2 )
312 str += tr(" and ") + *itStr; 356 str += tr(" and ") + *itStr;
313 else { 357 else {
314 if ( bNeedCarriage ) 358 if ( bNeedCarriage )
315 str += tr( ",\nand " ) + *itStr; 359 str += tr( ",\nand " ) + *itStr;
316 else 360 else
317 str += tr( ", and " ) + *itStr; 361 str += tr( ", and " ) + *itStr;
318 } 362 }
319 } else { 363 } else {
320 if ( bNeedCarriage ) 364 if ( bNeedCarriage )
321 str += ",\n" + *itStr; 365 str += ",\n" + *itStr;
322 else 366 else
323 str += ", " + *itStr; 367 str += ", " + *itStr;
324 } 368 }
325 } 369 }
326 str = str.prepend( "on " ); 370 str = str.prepend( "on " );
327 lblWeekVar->setText( str ); 371 lblWeekVar->setText( str );
328} 372}
329void ORecurranceWidget::slotMonthLabel(int type) { 373void ORecurranceWidget::slotMonthLabel(int type) {
330 QString str; 374 QString str;
331 if ( currInterval != Month || type > 1 ) 375 if ( currInterval != Month || type > 1 )
332 return; 376 return;
333 if ( type == 1 ) 377 if ( type == 1 )
334 str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); 378 str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
335 else 379 else
336 str = strMonthDayTemplate.arg( numberPlacing(week(start))) 380 str = strMonthDayTemplate.arg( numberPlacing(week(start)))
337 .arg( dayLabel[start.dayOfWeek() - 1] ); 381 .arg( dayLabel[start.dayOfWeek() - 1] );
338 lblRepeat->setText( str ); 382 lblRepeat->setText( str );
339} 383}
340void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { 384void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) {
341 startWeekOnMonday = onMonday; 385 startWeekOnMonday = onMonday;
342 // we need to make this unintrusive as possible... 386 // we need to make this unintrusive as possible...
343 int saveSpin = spinFreq->value(); 387 int saveSpin = spinFreq->value();
344 char days = 0; 388 char days = 0;
345 int day; 389 int day;
346 QListIterator<QToolButton> itExtra( listExtra ); 390 QListIterator<QToolButton> itExtra( listExtra );
347 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { 391 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
348 if ( (*itExtra)->isOn() ) { 392 if ( (*itExtra)->isOn() ) {
349 if ( !startWeekOnMonday ) 393 if ( !startWeekOnMonday )
350 days |= day; 394 days |= day;
351 else { 395 else {
352 if ( day == 1 ) 396 if ( day == 1 )
353 days |= ORecur::SUN; 397 days |= ORecur::SUN;
354 else 398 else
355 days |= day >> 1; 399 days |= day >> 1;
356 } 400 }
357 } 401 }
358 } 402 }
359 setupWeekly(); 403 setupWeekly();
360 spinFreq->setValue( saveSpin ); 404 spinFreq->setValue( saveSpin );
361 int buttons; 405 int buttons;
362 for ( day = 0x01, buttons = 0; buttons < 7; 406 for ( day = 0x01, buttons = 0; buttons < 7;
363 day = day << 1, buttons++ ) { 407 day = day << 1, buttons++ ) {
364 if ( days & day ) { 408 if ( days & day ) {
365 if ( startWeekOnMonday ) 409 if ( startWeekOnMonday )
366 fraExtra->setButton( buttons ); 410 fraExtra->setButton( buttons );
367 else { 411 else {
368 if ( buttons == 7 ) 412 if ( buttons == 7 )
369 fraExtra->setButton( 0 ); 413 fraExtra->setButton( 0 );
370 else 414 else
371 fraExtra->setButton( buttons + 1 ); 415 fraExtra->setButton( buttons + 1 );
372 } 416 }
373 } 417 }
374 } 418 }
375 slotWeekLabel(); 419 slotWeekLabel();
376} 420}
377void ORecurranceWidget::setupNone() { 421void ORecurranceWidget::setupNone() {
378 lblRepeat->setText( tr("No Repeat") ); 422 lblRepeat->setText( tr("No Repeat") );
379 lblVar1->hide(); 423 lblVar1->hide();
380 lblVar2->hide(); 424 lblVar2->hide();
381 hideExtras(); 425 hideExtras();
382 cmdEnd->hide(); 426 cmdEnd->hide();
383 lblFreq->hide(); 427 lblFreq->hide();
384 lblEvery->hide(); 428 lblEvery->hide();
385 lblFreq->hide(); 429 lblFreq->hide();
386 spinFreq->hide(); 430 spinFreq->hide();
387 lblEnd->hide(); 431 lblEnd->hide();
388 lblWeekVar->hide(); 432 lblWeekVar->hide();
389} 433}
390void ORecurranceWidget::setupDaily() { 434void ORecurranceWidget::setupDaily() {
391 hideExtras(); 435 hideExtras();
392 lblWeekVar->hide(); 436 lblWeekVar->hide();
393 spinFreq->setValue( 1 ); 437 spinFreq->setValue( 1 );
394 lblFreq->setText( tr("day(s)") ); 438 lblFreq->setText( tr("day(s)") );
395 lblVar2->show(); 439 lblVar2->show();
396 showRepeatStuff(); 440 showRepeatStuff();
397 lblRepeat->setText( strDayTemplate ); 441 lblRepeat->setText( strDayTemplate );
398 setupRepeatLabel( 1 ); 442 setupRepeatLabel( 1 );
399} 443}
400void ORecurranceWidget::setupWeekly() { 444void ORecurranceWidget::setupWeekly() {
401// reshow the buttons... 445// reshow the buttons...
402 fraExtra->setTitle( tr("Repeat On") ); 446 fraExtra->setTitle( tr("Repeat On") );
403 fraExtra->setExclusive( FALSE ); 447 fraExtra->setExclusive( FALSE );
404 fraExtra->show(); 448 fraExtra->show();
405 if ( startWeekOnMonday ) { 449 if ( startWeekOnMonday ) {
406 cmdExtra1->setText( tr("Mon") ); 450 cmdExtra1->setText( tr("Mon") );
407 cmdExtra2->setText( tr("Tue") ); 451 cmdExtra2->setText( tr("Tue") );
408 cmdExtra3->setText( tr("Wed") ); 452 cmdExtra3->setText( tr("Wed") );
409 cmdExtra4->setText( tr("Thu") ); 453 cmdExtra4->setText( tr("Thu") );
410 cmdExtra5->setText( tr("Fri") ); 454 cmdExtra5->setText( tr("Fri") );
411 cmdExtra6->setText( tr("Sat") ); 455 cmdExtra6->setText( tr("Sat") );
412 cmdExtra7->setText( tr("Sun") ); 456 cmdExtra7->setText( tr("Sun") );
413 } else { 457 } else {
414 cmdExtra1->setText( tr("Sun") ); 458 cmdExtra1->setText( tr("Sun") );
415 cmdExtra2->setText( tr("Mon") ); 459 cmdExtra2->setText( tr("Mon") );
416 cmdExtra3->setText( tr("Tue") ); 460 cmdExtra3->setText( tr("Tue") );
417 cmdExtra4->setText( tr("Wed") ); 461 cmdExtra4->setText( tr("Wed") );
418 cmdExtra5->setText( tr("Thu") ); 462 cmdExtra5->setText( tr("Thu") );
419 cmdExtra6->setText( tr("Fri") ); 463 cmdExtra6->setText( tr("Fri") );
420 cmdExtra7->setText( tr("Sat") ); 464 cmdExtra7->setText( tr("Sat") );
421 } 465 }
422 // I hope clustering these improve performance.... 466 // I hope clustering these improve performance....
423 cmdExtra1->setOn( FALSE ); 467 cmdExtra1->setOn( FALSE );
424 cmdExtra2->setOn( FALSE ); 468 cmdExtra2->setOn( FALSE );
425 cmdExtra3->setOn( FALSE ); 469 cmdExtra3->setOn( FALSE );
426 cmdExtra4->setOn( FALSE ); 470 cmdExtra4->setOn( FALSE );
427 cmdExtra5->setOn( FALSE ); 471 cmdExtra5->setOn( FALSE );
428 cmdExtra6->setOn( FALSE ); 472 cmdExtra6->setOn( FALSE );
429 cmdExtra7->setOn( FALSE ); 473 cmdExtra7->setOn( FALSE );
430 474
431 cmdExtra1->show(); 475 cmdExtra1->show();
432 cmdExtra2->show(); 476 cmdExtra2->show();
433 cmdExtra3->show(); 477 cmdExtra3->show();
434 cmdExtra4->show(); 478 cmdExtra4->show();
435 cmdExtra5->show(); 479 cmdExtra5->show();
436 cmdExtra6->show(); 480 cmdExtra6->show();
437 cmdExtra7->show(); 481 cmdExtra7->show();
438 482
439 lblWeekVar->show(); 483 lblWeekVar->show();
440 spinFreq->setValue( 1 ); 484 spinFreq->setValue( 1 );
441 // might as well set the day too... 485 // might as well set the day too...
442 if ( startWeekOnMonday ) { 486 if ( startWeekOnMonday ) {
443 fraExtra->setButton( start.dayOfWeek() - 1 ); 487 fraExtra->setButton( start.dayOfWeek() - 1 );
444 } else { 488 } else {
445 fraExtra->setButton( start.dayOfWeek() % 7 ); 489 fraExtra->setButton( start.dayOfWeek() % 7 );
446 } 490 }
447 lblFreq->setText( tr("week(s)") ); 491 lblFreq->setText( tr("week(s)") );
448 lblVar2->show(); 492 lblVar2->show();
449 showRepeatStuff(); 493 showRepeatStuff();
450 setupRepeatLabel( 1 ); 494 setupRepeatLabel( 1 );
451} 495}
452void ORecurranceWidget::setupMonthly() { 496void ORecurranceWidget::setupMonthly() {
453 hideExtras(); 497 hideExtras();
454 lblWeekVar->hide(); 498 lblWeekVar->hide();
455 fraExtra->setTitle( tr("Repeat By") ); 499 fraExtra->setTitle( tr("Repeat By") );
456 fraExtra->setExclusive( TRUE ); 500 fraExtra->setExclusive( TRUE );
457 fraExtra->show(); 501 fraExtra->show();
458 cmdExtra1->setText( tr("Day") ); 502 cmdExtra1->setText( tr("Day") );
459 cmdExtra1->show(); 503 cmdExtra1->show();
460 cmdExtra2->setText( tr("Date") ); 504 cmdExtra2->setText( tr("Date") );
461 cmdExtra2->show(); 505 cmdExtra2->show();
462 spinFreq->setValue( 1 ); 506 spinFreq->setValue( 1 );
463 lblFreq->setText( tr("month(s)") ); 507 lblFreq->setText( tr("month(s)") );
464 lblVar2->show(); 508 lblVar2->show();
465 showRepeatStuff(); 509 showRepeatStuff();
466 setupRepeatLabel( 1 ); 510 setupRepeatLabel( 1 );
467} 511}
468void ORecurranceWidget::setupYearly() { 512void ORecurranceWidget::setupYearly() {
469hideExtras(); 513hideExtras();
470 lblWeekVar->hide(); 514 lblWeekVar->hide();
471 spinFreq->setValue( 1 ); 515 spinFreq->setValue( 1 );
472 lblFreq->setText( tr("year(s)") ); 516 lblFreq->setText( tr("year(s)") );
473 lblFreq->show(); 517 lblFreq->show();
474 lblFreq->show(); 518 lblFreq->show();
475 showRepeatStuff(); 519 showRepeatStuff();
476 lblVar2->show(); 520 lblVar2->show();
477 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); 521 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
478 lblRepeat->setText( strEvery ); 522 lblRepeat->setText( strEvery );
479 setupRepeatLabel( 1 ); 523 setupRepeatLabel( 1 );
480 524
481} 525}
482void ORecurranceWidget::init() { 526void ORecurranceWidget::init() {
483 QPopupMenu *m1 = new QPopupMenu( this ); 527 QPopupMenu *m1 = new QPopupMenu( this );
484 repeatPicker = new DateBookMonth( m1, 0, TRUE ); 528 repeatPicker = new DateBookMonth( m1, 0, TRUE );
485 m1->insertItem( repeatPicker ); 529 m1->insertItem( repeatPicker );
486 cmdEnd->setPopup( m1 ); 530 cmdEnd->setPopup( m1 );
487 cmdEnd->setPopupDelay( 0 ); 531 cmdEnd->setPopupDelay( 0 );
488 532
489 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), 533 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)),
490 this, SLOT(endDateChanged(int, int, int)) ); 534 this, SLOT(endDateChanged(int, int, int)) );
491 QObject::connect( qApp, SIGNAL(weekChanged(bool)), 535 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
492 this, SLOT(slotChangeStartOfWeek(bool)) ); 536 this, SLOT(slotChangeStartOfWeek(bool)) );
493 537
494 listRTypeButtons.setAutoDelete( TRUE ); 538 listRTypeButtons.setAutoDelete( TRUE );
495 listRTypeButtons.append( cmdNone ); 539 listRTypeButtons.append( cmdNone );
496 listRTypeButtons.append( cmdDay ); 540 listRTypeButtons.append( cmdDay );
497 listRTypeButtons.append( cmdWeek ); 541 listRTypeButtons.append( cmdWeek );
498 listRTypeButtons.append( cmdMonth ); 542 listRTypeButtons.append( cmdMonth );
499 listRTypeButtons.append( cmdYear ); 543 listRTypeButtons.append( cmdYear );
500 544
501 listExtra.setAutoDelete( TRUE ); 545 listExtra.setAutoDelete( TRUE );
502 listExtra.append( cmdExtra1 ); 546 listExtra.append( cmdExtra1 );
503 listExtra.append( cmdExtra2 ); 547 listExtra.append( cmdExtra2 );
504 listExtra.append( cmdExtra3 ); 548 listExtra.append( cmdExtra3 );
505 listExtra.append( cmdExtra4 ); 549 listExtra.append( cmdExtra4 );
506 listExtra.append( cmdExtra5 ); 550 listExtra.append( cmdExtra5 );
507 listExtra.append( cmdExtra6 ); 551 listExtra.append( cmdExtra6 );
508 listExtra.append( cmdExtra7 ); 552 listExtra.append( cmdExtra7 );
509} 553}
510void ORecurranceWidget::hideExtras() { 554void ORecurranceWidget::hideExtras() {
511 // hide the extra buttons... 555 // hide the extra buttons...
512 fraExtra->hide(); 556 fraExtra->hide();
513 chkNoEnd->hide(); 557 chkNoEnd->hide();
514 QListIterator<QToolButton> it( listExtra ); 558 QListIterator<QToolButton> it( listExtra );
515 for ( ; *it; ++it ) { 559 for ( ; *it; ++it ) {
516 (*it)->hide(); 560 (*it)->hide();
517 (*it)->setOn( FALSE ); 561 (*it)->setOn( FALSE );
518 } 562 }
519} 563}
520void ORecurranceWidget::showRepeatStuff() { 564void ORecurranceWidget::showRepeatStuff() {
521 cmdEnd->show(); 565 cmdEnd->show();
522 chkNoEnd->show(); 566 chkNoEnd->show();
523 lblFreq->show(); 567 lblFreq->show();
524 lblEvery->show(); 568 lblEvery->show();
525 lblFreq->show(); 569 lblFreq->show();
526 spinFreq->show(); 570 spinFreq->show();
527 lblEnd->show(); 571 lblEnd->show();
528 lblRepeat->setText( tr("Every") ); 572 lblRepeat->setText( tr("Every") );
529} 573}
530 574
531 575
532static int week( const QDate &start ) 576static int week( const QDate &start )
533{ 577{
534 // figure out the week... 578 // figure out the week...
535 int stop = start.day(), 579 int stop = start.day(),
536 sentinel = start.dayOfWeek(), 580 sentinel = start.dayOfWeek(),
537 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), 581 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(),
538 week = 1, 582 week = 1,
539 i; 583 i;
540 for ( i = 1; i < stop; i++ ) { 584 for ( i = 1; i < stop; i++ ) {
541 if ( dayOfWeek++ == sentinel ) 585 if ( dayOfWeek++ == sentinel )
542 week++; 586 week++;
543 if ( dayOfWeek > 7 ) 587 if ( dayOfWeek > 7 )
544 dayOfWeek = 0; 588 dayOfWeek = 0;
545 } 589 }
546 return week; 590 return week;
547} 591}
548 592
549static QString numberPlacing( int x ) 593static QString numberPlacing( int x )
550{ 594{
551 // I hope this works in other languages besides english... 595 // I hope this works in other languages besides english...
552 QString str = QString::number( x ); 596 QString str = QString::number( x );
553 switch ( x % 10 ) { 597 switch ( x % 10 ) {
554 case 1: 598 case 1:
555 str += QWidget::tr( "st" ); 599 str += QWidget::tr( "st" );
556 break; 600 break;
557 case 2: 601 case 2:
558 str += QWidget::tr( "nd" ); 602 str += QWidget::tr( "nd" );
559 break; 603 break;
560 case 3: 604 case 3:
561 str += QWidget::tr( "rd" ); 605 str += QWidget::tr( "rd" );
562 break; 606 break;
563 default: 607 default:
564 str += QWidget::tr( "th" ); 608 str += QWidget::tr( "th" );
565 break; 609 break;
566 } 610 }
diff --git a/libopie/orecurrancewidget.h b/libopie/orecurrancewidget.h
index 4a8dd08..af87ce9 100644
--- a/libopie/orecurrancewidget.h
+++ b/libopie/orecurrancewidget.h
@@ -1,72 +1,84 @@
1/* 1/*
2 * GPL and based on the widget from TT 2 * GPL and based on the widget from TT
3 */ 3 */
4 4
5#ifndef OPIE_RECURRANCE_WIDGET_H 5#ifndef OPIE_RECURRANCE_WIDGET_H
6#define OPIE_RECURRANCE_WIDGET_H 6#define OPIE_RECURRANCE_WIDGET_H
7 7
8#include <qlist.h> 8#include <qlist.h>
9#include <qtoolbutton.h> 9#include <qtoolbutton.h>
10#include <qcheckbox.h> 10#include <qcheckbox.h>
11#include <qdatetime.h> 11#include <qdatetime.h>
12#include <qbuttongroup.h> 12#include <qbuttongroup.h>
13 13
14#include <qpe/datebookmonth.h> 14#include <qpe/datebookmonth.h>
15 15
16#include "orecurrancebase.h" 16#include "orecurrancebase.h"
17#include <opie/orecur.h> 17#include <opie/orecur.h>
18 18
19// FIXME spelling!!!! -zecke 19// FIXME spelling!!!! -zecke
20// FIXME spelling filenames
21
22/**
23 * A widget to let the user select rules for recurrences.
24 * This widget can take care of weekly, monthly, daily and yearly recurrence
25 * It is used inside todolist and datebook.
26 *
27 *
28 * @short Widget of selecting Recurrance
29 * @author Trolltech, Holger Freyther
30 * @version 0.9
31 */
20class ORecurranceWidget : public ORecurranceBase { 32class ORecurranceWidget : public ORecurranceBase {
21 Q_OBJECT 33 Q_OBJECT
22public: 34public:
23 ORecurranceWidget( bool startOnMonday, 35 ORecurranceWidget( bool startOnMonday,
24 const QDate& start, QWidget* parent = 0, 36 const QDate& start, QWidget* parent = 0,
25 const char* name = 0, bool modal = TRUE, 37 const char* name = 0, bool modal = TRUE,
26 WFlags fl = 0 ); 38 WFlags fl = 0 );
27 ORecurranceWidget( bool startOnMonday, 39 ORecurranceWidget( bool startOnMonday,
28 const ORecur& rp, const QDate& start, 40 const ORecur& rp, const QDate& start,
29 QWidget* parent = 0, const char* name =0, 41 QWidget* parent = 0, const char* name =0,
30 bool modal = TRUE, WFlags = 0 ); 42 bool modal = TRUE, WFlags = 0 );
31 ~ORecurranceWidget(); 43 ~ORecurranceWidget();
32 ORecur recurrence()const; 44 ORecur recurrence()const;
33 QDate endDate()const; 45 QDate endDate()const;
34 46
35public slots: 47public slots:
36 void slotSetRType( int ); 48 void slotSetRType( int );
37 void endDateChanged( int, int, int ); 49 void endDateChanged( int, int, int );
38 void slotNoEnd( bool unused ); 50 void slotNoEnd( bool unused );
39 void setStartDate( const QDate& ); 51 void setStartDate( const QDate& );
40 void setRecurrence( const ORecur& recur, const QDate& start ); 52 void setRecurrence( const ORecur& recur, const QDate& start );
41 void setRecurrence( const ORecur& recur ); 53 void setRecurrence( const ORecur& recur );
42 54
43private slots: 55private slots:
44 void setupRepeatLabel( const QString& ); 56 void setupRepeatLabel( const QString& );
45 void setupRepeatLabel( int ); 57 void setupRepeatLabel( int );
46 void slotWeekLabel(); 58 void slotWeekLabel();
47 void slotMonthLabel( int ); 59 void slotMonthLabel( int );
48 void slotChangeStartOfWeek( bool onMonday ); 60 void slotChangeStartOfWeek( bool onMonday );
49 61
50private: 62private:
51 void setupNone(); 63 void setupNone();
52 void setupDaily(); 64 void setupDaily();
53 void setupWeekly(); 65 void setupWeekly();
54 void setupMonthly(); 66 void setupMonthly();
55 void setupYearly(); 67 void setupYearly();
56 68
57 enum repeatButtons { None, Day, Week, Month, Year }; 69 enum repeatButtons { None, Day, Week, Month, Year };
58 void init(); 70 void init();
59 void hideExtras(); 71 void hideExtras();
60 void showRepeatStuff(); 72 void showRepeatStuff();
61 73
62 QList<QToolButton> listRTypeButtons; 74 QList<QToolButton> listRTypeButtons;
63 QList<QToolButton> listExtra; 75 QList<QToolButton> listExtra;
64 QDate start; // only used in one spot... 76 QDate start; // only used in one spot...
65 QDate end; 77 QDate end;
66 repeatButtons currInterval; 78 repeatButtons currInterval;
67 bool startWeekOnMonday : 1; 79 bool startWeekOnMonday : 1;
68 DateBookMonth *repeatPicker; 80 DateBookMonth *repeatPicker;
69 81
70}; 82};
71 83
72#endif 84#endif
diff --git a/libopie/otabbar.h b/libopie/otabbar.h
index 16797a3..c413611 100644
--- a/libopie/otabbar.h
+++ b/libopie/otabbar.h
@@ -1,75 +1,76 @@
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 Dan Williams <williamsdr@acm.org> 4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OTABBAR_H 32#ifndef OTABBAR_H
33#define OTABBAR_H 33#define OTABBAR_H
34 34
35#include <qtabbar.h> 35#include <qtabbar.h>
36 36
37/** 37/**
38 * @class OTabBar 38 * @class OTabBar
39 * @brief The OTabBar class is a derivative of QTabBar. 39 * @brief The OTabBar class is a derivative of QTabBar.
40 * 40 *
41 * OTabBar is a derivation of TrollTech's QTabBar which provides 41 * OTabBar is a derivation of TrollTech's QTabBar which provides
42 * a row of tabs for selection. The only difference between this 42 * a row of tabs for selection. The only difference between this
43 * class and QTabBar is that there is no dotted line box around 43 * class and QTabBar is that there is no dotted line box around
44 * the label of the tab with the current focus. 44 * the label of the tab with the current focus.
45 */ 45 */
46class OTabBar : public QTabBar 46class OTabBar : public QTabBar
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 49
50public: 50public:
51/** 51/**
52 * @fn OTabBar( QWidget *parent = 0, const char *name = 0 ) 52 * @fn OTabBar( QWidget *parent = 0, const char *name = 0 )
53 * @brief Object constructor. 53 * @brief Object constructor.
54 * 54 *
55 * @param parent Pointer to parent of this control. 55 * @param parent Pointer to parent of this control.
56 * @param name Name of control. 56 * @param name Name of control.
57 * 57 *
58 * Constructs a new OTabBar control with parent and name. 58 * Constructs a new OTabBar control with parent and name.
59 */ 59 */
60 // FIXME Allow WFlags? -zecke
60 OTabBar( QWidget * = 0, const char * = 0 ); 61 OTabBar( QWidget * = 0, const char * = 0 );
61 62
62protected: 63protected:
63/** 64/**
64 * @fn paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) 65 * @fn paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus )
65 * @brief Internal function to draw a tab's label. 66 * @brief Internal function to draw a tab's label.
66 * 67 *
67 * @param p Pointer to QPainter used for drawing. 68 * @param p Pointer to QPainter used for drawing.
68 * @param br QRect providing region to draw label in. 69 * @param br QRect providing region to draw label in.
69 * @param t Tab to draw label for. 70 * @param t Tab to draw label for.
70 * @param has_focus Boolean value not used, retained for compatibility reasons. 71 * @param has_focus Boolean value not used, retained for compatibility reasons.
71 */ 72 */
72 void paintLabel( QPainter *, const QRect &, QTab *, bool ) const; 73 void paintLabel( QPainter *, const QRect &, QTab *, bool ) const;
73}; 74};
74 75
75#endif 76#endif
diff --git a/libopie/otabwidget.h b/libopie/otabwidget.h
index 0aa9bb8..23fe774 100644
--- a/libopie/otabwidget.h
+++ b/libopie/otabwidget.h
@@ -1,275 +1,277 @@
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 Dan Williams <williamsdr@acm.org> 4              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OTABWIDGET_H 32#ifndef OTABWIDGET_H
33#define OTABWIDGET_H 33#define OTABWIDGET_H
34 34
35#include "otabinfo.h" 35#include "otabinfo.h"
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qlist.h> 38#include <qlist.h>
39 39
40class OTabBar; 40class OTabBar;
41class QComboBox; 41class QComboBox;
42class QPixmap; 42class QPixmap;
43class QTabBar; 43class QTabBar;
44class QWidgetStack; 44class QWidgetStack;
45 45
46/** 46/**
47 * @class OTabWidget 47 * @class OTabWidget
48 * @brief The OTabWidget class provides a stack of widgets. 48 * @brief The OTabWidget class provides a stack of widgets.
49 * 49 *
50 * OTabWidget is a derivation of TrollTech's QTabWidget which provides 50 * OTabWidget is a derivation of TrollTech's QTabWidget which provides
51 * a stack of widgets. Widgets can be selected using either a tab bar or 51 * a stack of widgets. Widgets can be selected using either a tab bar or
52 * drop down list box. 52 * drop down list box.
53 * 53 *
54 * The normal way to use OTabWidget is to do the following in the 54 * The normal way to use OTabWidget is to do the following in the
55 * constructor: 55 * constructor:
56 * - Create a OTabWidget. 56 * - Create a OTabWidget.
57 * - Create a QWidget for each of the pages in the control, insert 57 * - Create a QWidget for each of the pages in the control, insert
58 * children into it, set up geometry management for it, and use addTab() 58 * children into it, set up geometry management for it, and use addTab()
59 * to add the widget. 59 * to add the widget.
60 */ 60 */
61class OTabWidget : public QWidget 61class OTabWidget : public QWidget
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 65
66/** 66/**
67 * @enum TabStyle 67 * @enum TabStyle
68 * @brief Defines how the widget selection control is displayed. 68 * @brief Defines how the widget selection control is displayed.
69 * 69 *
70 * Valid values: 70 * Valid values:
71 * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) 71 * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition)
72 * - TextTab: Tabbed widget selection with text labels 72 * - TextTab: Tabbed widget selection with text labels
73 * - IconTab: Tabbed widget selection with icon labels, text label for active widget 73 * - IconTab: Tabbed widget selection with icon labels, text label for active widget
74 * (similar to Opie launcher) 74 * (similar to Opie launcher)
75 * - TextList: Drop down list widget selection with text labels 75 * - TextList: Drop down list widget selection with text labels
76 * - IconList: Drop down list widget selection with icon & text labels 76 * - IconList: Drop down list widget selection with icon & text labels
77 */ 77 */
78 enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; 78 enum TabStyle { Global, TextTab, IconTab, TextList, IconList };
79 79
80/** 80/**
81 * @enum TabPosition 81 * @enum TabPosition
82 * @brief Defines where the widget selection control is drawn. 82 * @brief Defines where the widget selection control is drawn.
83 * 83 *
84 * Valid values: 84 * Valid values:
85 * - Top: Widget selection control is drawn above widgets 85 * - Top: Widget selection control is drawn above widgets
86 * - Bottom: Widget selection control is drawn below widgets 86 * - Bottom: Widget selection control is drawn below widgets
87 */ 87 */
88 enum TabPosition { Top, Bottom }; 88 enum TabPosition { Top, Bottom };
89 89
90/** 90/**
91 * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top ) 91 * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top )
92 * @brief Object constructor. 92 * @brief Object constructor.
93 * 93 *
94 * @param parent Pointer to parent of this control. 94 * @param parent Pointer to parent of this control.
95 * @param name Name of control. 95 * @param name Name of control.
96 * @param s Style of widget selection control. 96 * @param s Style of widget selection control.
97 * @param p Position of the widget selection control. 97 * @param p Position of the widget selection control.
98 * 98 *
99 * Constructs a new OTabWidget control with parent and name. The style and position parameters 99 * Constructs a new OTabWidget control with parent and name. The style and position parameters
100 * determine how the widget selection control will be displayed. 100 * determine how the widget selection control will be displayed.
101 */ 101 */
102 // FIXME WFlags? -zecke
102 OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); 103 OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top );
103 104
104/** 105/**
105 * @fn ~OTabWidget() 106 * @fn ~OTabWidget()
106 * @brief Object destructor. 107 * @brief Object destructor.
107 */ 108 */
108 ~OTabWidget(); 109 ~OTabWidget();
109 110
110/** 111/**
111 * @fn addTab( QWidget *child, const QString &icon, const QString &label ) 112 * @fn addTab( QWidget *child, const QString &icon, const QString &label )
112 * @brief Add new widget to control. 113 * @brief Add new widget to control.
113 * 114 *
114 * @param child Widget control. 115 * @param child Widget control.
115 * @param icon Path to icon. 116 * @param icon Path to icon.
116 * @param label Text label. 117 * @param label Text label.
117 */ 118 */
118 void addTab( QWidget *, const QString &, const QString & ); 119 void addTab( QWidget *, const QString &, const QString & );
119 120
120/** 121/**
121 * @fn removePage( QWidget *widget ) 122 * @fn removePage( QWidget *widget )
122 * @brief Remove widget from control. Does not delete widget. 123 * @brief Remove widget from control. Does not delete widget.
123 * 124 *
124 * @param widget Widget control to be removed. 125 * @param widget Widget control to be removed.
125 */ 126 */
126 void removePage( QWidget * ); 127 void removePage( QWidget * );
127 128
128/** 129/**
129 * @fn changeTab( QWidget *widget, const QIconSet &icon, const QString &label ) 130 * @fn changeTab( QWidget *widget, const QIconSet &icon, const QString &label )
130 * @brief Change text and/or icon for existing tab 131 * @brief Change text and/or icon for existing tab
131 * 132 *
132 * @param child Widget control. 133 * @param child Widget control.
133 * @param icon Path to icon. 134 * @param icon Path to icon.
134 * @param label Text label. 135 * @param label Text label.
135 */ 136 */
136 void changeTab( QWidget *, const QString &, const QString & ); 137 void changeTab( QWidget *, const QString &, const QString & );
137 138
138/** 139/**
139 * @fn tabStyle() 140 * @fn tabStyle()
140 * @brief Returns current widget selection control style. 141 * @brief Returns current widget selection control style.
141 */ 142 */
142 TabStyle tabStyle() const; 143 TabStyle tabStyle() const;
143 144
144/** 145/**
145 * @fn setTabStyle( TabStyle s ) 146 * @fn setTabStyle( TabStyle s )
146 * @brief Set the current widget selection control style. 147 * @brief Set the current widget selection control style.
147 * 148 *
148 * @param s New style to be used. 149 * @param s New style to be used.
149 */ 150 */
150 void setTabStyle( TabStyle ); 151 void setTabStyle( TabStyle );
151 152
152/** 153/**
153 * @fn tabPosition() 154 * @fn tabPosition()
154 * @brief Returns current widget selection control position. 155 * @brief Returns current widget selection control position.
155 */ 156 */
156 TabPosition tabPosition() const; 157 TabPosition tabPosition() const;
157 158
158/** 159/**
159 * @fn setTabPosition( TabPosition p ) 160 * @fn setTabPosition( TabPosition p )
160 * @brief Set the current widget selection control position. 161 * @brief Set the current widget selection control position.
161 * 162 *
162 * @param p New position of widget selection control. 163 * @param p New position of widget selection control.
163 */ 164 */
164 void setTabPosition( TabPosition ); 165 void setTabPosition( TabPosition );
165 166
166/** 167/**
167 * @fn setCurrentTab( QWidget *childwidget ) 168 * @fn setCurrentTab( QWidget *childwidget )
168 * @brief Selects and brings to top the desired widget by using widget pointer. 169 * @brief Selects and brings to top the desired widget by using widget pointer.
169 * 170 *
170 * @param childwidget Widget to select. 171 * @param childwidget Widget to select.
171 */ 172 */
172 void setCurrentTab( QWidget * ); 173 void setCurrentTab( QWidget * );
173 174
174/** 175/**
175 * @fn setCurrentTab( const QString &tabname ) 176 * @fn setCurrentTab( const QString &tabname )
176 * @brief Selects and brings to top the desired widget, by using label. 177 * @brief Selects and brings to top the desired widget, by using label.
177 * 178 *
178 * @param tabname Text label for widget to select. 179 * @param tabname Text label for widget to select.
179 */ 180 */
180 void setCurrentTab( const QString & ); 181 void setCurrentTab( const QString & );
181 182
182/** 183/**
183 * @fn setCurrentTab( int ) 184 * @fn setCurrentTab( int )
184 * @brief Selects and brings to top the desired widget, by using id. 185 * @brief Selects and brings to top the desired widget, by using id.
185 * 186 *
186 * @param tab id for widget to select. 187 * @param tab id for widget to select.
187 */ 188 */
188 void setCurrentTab(int); 189 void setCurrentTab(int);
189 190
190/** 191/**
191 * @fn sizeHint() 192 * @fn sizeHint()
192 * @brief Reimplemented for internal purposes. 193 * @brief Reimplemented for internal purposes.
193 */ 194 */
194 QSize sizeHint() const; 195 QSize sizeHint() const;
195 196
196/** 197/**
197 * @fn getCurrentTab( ) 198 * @fn getCurrentTab( )
198 * @brief returns current tab id. 199 * @brief returns current tab id.
199 */ 200 */
201 //FIXME TT coding style currentTab() -zecke
200 int getCurrentTab(); 202 int getCurrentTab();
201 203
202 204
203protected: 205protected:
204 206
205/** 207/**
206 * @fn resizeEvent( QResizeEvent * ) 208 * @fn resizeEvent( QResizeEvent * )
207 * @brief Reimplemented for internal purposes. 209 * @brief Reimplemented for internal purposes.
208 */ 210 */
209 void resizeEvent( QResizeEvent * ); 211 void resizeEvent( QResizeEvent * );
210 212
211private: 213private:
212 OTabInfoList tabs; 214 OTabInfoList tabs;
213 OTabInfo *currentTab; 215 OTabInfo *currentTab;
214 216
215 TabStyle tabBarStyle; 217 TabStyle tabBarStyle;
216 TabPosition tabBarPosition; 218 TabPosition tabBarPosition;
217 219
218 QWidgetStack *tabBarStack; 220 QWidgetStack *tabBarStack;
219 OTabBar *tabBar; 221 OTabBar *tabBar;
220 QComboBox *tabList; 222 QComboBox *tabList;
221 223
222 QWidgetStack *widgetStack; 224 QWidgetStack *widgetStack;
223 225
224/** 226/**
225 * @fn loadSmooth( const QString &name ) 227 * @fn loadSmooth( const QString &name )
226 * @brief Loads icon for widget. 228 * @brief Loads icon for widget.
227 * 229 *
228 * @param name Name of icon image file. 230 * @param name Name of icon image file.
229 */ 231 */
230 QPixmap loadSmooth( const QString & ); 232 QPixmap loadSmooth( const QString & );
231 233
232/** 234/**
233 * @fn selectTab( OTabInfo *tab ) 235 * @fn selectTab( OTabInfo *tab )
234 * @brief Internal function to select desired widget. 236 * @brief Internal function to select desired widget.
235 * 237 *
236 * @param tab Pointer to data for widget. 238 * @param tab Pointer to data for widget.
237 */ 239 */
238 void selectTab( OTabInfo * ); 240 void selectTab( OTabInfo * );
239 241
240/** 242/**
241 * @fn setUpLayout() 243 * @fn setUpLayout()
242 * @brief Internal function to adjust layout. 244 * @brief Internal function to adjust layout.
243 */ 245 */
244 void setUpLayout(); 246 void setUpLayout();
245 247
246 248
247signals: 249signals:
248/** 250/**
249 * @fn currentChanegd( QWidget *widget ) 251 * @fn currentChanegd( QWidget *widget )
250 * @brief This signal is emitted whenever the widget has changed. 252 * @brief This signal is emitted whenever the widget has changed.
251 * 253 *
252 * @param widget Pointer to new current widget. 254 * @param widget Pointer to new current widget.
253 */ 255 */
254 void currentChanged( QWidget * ); 256 void currentChanged( QWidget * );
255 257
256private slots: 258private slots:
257 259
258/** 260/**
259 * @fn slotTabBarSelected( int id ) 261 * @fn slotTabBarSelected( int id )
260 * @brief Slot which is called when a tab is selected. 262 * @brief Slot which is called when a tab is selected.
261 * 263 *
262 * @param id ID of widget selected. 264 * @param id ID of widget selected.
263 */ 265 */
264 void slotTabBarSelected( int ); 266 void slotTabBarSelected( int );
265 267
266/** 268/**
267 * @fn slotTabListSelected( int index ) 269 * @fn slotTabListSelected( int index )
268 * @brief Slot which is called when a drop down selection is made. 270 * @brief Slot which is called when a drop down selection is made.
269 * 271 *
270 * @param id Index of widget selected. 272 * @param id Index of widget selected.
271 */ 273 */
272 void slotTabListSelected( int ); 274 void slotTabListSelected( int );
273}; 275};
274 276
275#endif 277#endif
diff --git a/libopie/oticker.h b/libopie/oticker.h
index 5df08da..30b7517 100644
--- a/libopie/oticker.h
+++ b/libopie/oticker.h
@@ -1,146 +1,146 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
4 =. 4 =.
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 General Public 9:`=1 )Y*s>-.--   : the terms of the GNU 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 30
31#ifndef OTICKER_H 31#ifndef OTICKER_H
32#define OTICKER_H 32#define OTICKER_H
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qdrawutil.h> 36#include <qdrawutil.h>
37#include <qpixmap.h> 37#include <qpixmap.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qslider.h> 39#include <qslider.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qframe.h> 41#include <qframe.h>
42#include <qcolor.h> 42#include <qcolor.h>
43/*! 43
44/**
44 * @class OTicker 45 * @class OTicker
45 * @brief The OTicker class provides a QLabel widget that scroll its contents 46 * @brief The OTicker class provides a QLabel widget that scroll its contents
46 * 47 *
47*/ 48 */
48class OTicker : public QLabel { 49class OTicker : public QLabel {
49//class OTicker : public QFrame {
50 Q_OBJECT 50 Q_OBJECT
51 51
52public: 52public:
53 53
54/*! 54/*!
55 * @fn OTicker( QWidget* parent = 0 ) 55 * @fn OTicker( QWidget* parent = 0 )
56 * @brief Object constructor. 56 * @brief Object constructor.
57 * 57 *
58 * @param parent Pointer to parent of this control. 58 * @param parent Pointer to parent of this control.
59 59
60 * Constructs a new OTicker control with parent 60 * Constructs a new OTicker control with parent
61 */ 61 */
62 OTicker( QWidget* parent=0 ); 62 OTicker( QWidget* parent=0 );
63/*! 63/*!
64 * @fn ~OTicker() 64 * @fn ~OTicker()
65 * @brief Object destructor. 65 * @brief Object destructor.
66 */ 66 */
67 ~OTicker(); 67 ~OTicker();
68/*! 68/*!
69 * @fn setText() 69 * @fn setText()
70 * @brief sets text to be displayed 70 * @brief sets text to be displayed
71 * @param text QString text to be displayed. 71 * @param text QString text to be displayed.
72 * 72 *
73 */ 73 */
74 void setText( const QString& text ) ; 74 void setText( const QString& text ) ;
75/*! 75/*!
76 * @fn setBackgroundColor(QColor color) 76 * @fn setBackgroundColor(QColor color)
77 * @brief sets color of the ticker's background 77 * @brief sets color of the ticker's background
78 * @param color QColor color to be set. 78 * @param color QColor color to be set.
79 * 79 *
80 */ 80 */
81 void setBackgroundColor(QColor color); 81 void setBackgroundColor(QColor color);
82/*! 82/*!
83 * @fn setForegroundColor(QColor color) 83 * @fn setForegroundColor(QColor color)
84 * @brief sets color of text 84 * @brief sets color of text
85 * @param color QColor color of text 85 * @param color QColor color of text
86 * 86 *
87 */ 87 */
88 void setForegroundColor(QColor color); 88 void setForegroundColor(QColor color);
89/*! 89/*!
90 * @fn setFrame(int style) 90 * @fn setFrame(int style)
91 * @brief sets frame style 91 * @brief sets frame style
92 * @param style int Frame style to be see. See Qt::WidgetFlags. 92 * @param style int Frame style to be see. See Qt::WidgetFlags.
93 * 93 *
94 */ 94 */
95 void setFrame(int style); 95 void setFrame(int style);
96/*! 96/*!
97 * @fn setUpdateTime(int timeout) 97 * @fn setUpdateTime(int timeout)
98 * @brief sets time of update 98 * @brief sets time of update
99 * @param timeout int time in milliseconds between updates. 99 * @param timeout int time in milliseconds between updates.
100 * 100 *
101 */ 101 */
102 void setUpdateTime(int timeout); 102 void setUpdateTime(int timeout);
103/*! 103/*!
104 * @fn setScrollLength(int length) 104 * @fn setScrollLength(int length)
105 * @brief sets amount of scrolling default is 1 105 * @brief sets amount of scrolling default is 1
106 * @param length int scroll length. 106 * @param length int scroll length.
107 * 107 *
108 */ 108 */
109 void setScrollLength(int length); 109 void setScrollLength(int length);
110signals: 110signals:
111/*! 111/*!
112 * @fn mousePressed() 112 * @fn mousePressed()
113 * @brief signal mouse press event 113 * @brief signal mouse press event
114 * 114 *
115 */ 115 */
116 void mousePressed(); 116 void mousePressed();
117protected: 117protected:
118/*! 118/*!
119 * @fn timerEvent( QTimerEvent * e) 119 * @fn timerEvent( QTimerEvent * e)
120 * @brief timer timeout event 120 * @brief timer timeout event
121 * @param e QEvent see QEvent. 121 * @param e QEvent see QEvent.
122 * 122 *
123 */ 123 */
124 void timerEvent( QTimerEvent * e); 124 void timerEvent( QTimerEvent * e);
125/*! 125/*!
126 * @fn drawContents( QPainter *p ) 126 * @fn drawContents( QPainter *p )
127 * @brief draws widget contents 127 * @brief draws widget contents
128 * @param p QPainter. see QPainter 128 * @param p QPainter. see QPainter
129 * 129 *
130 */ 130 */
131 void drawContents( QPainter *p ); 131 void drawContents( QPainter *p );
132/*! 132/*!
133 * @fn mouseReleaseEvent( QMouseEvent *e) 133 * @fn mouseReleaseEvent( QMouseEvent *e)
134 * @brief mouse release event 134 * @brief mouse release event
135 * @param e QMouseEvent. see QMouseEvent. 135 * @param e QMouseEvent. see QMouseEvent.
136 * 136 *
137 */ 137 */
138 void mouseReleaseEvent( QMouseEvent *e); 138 void mouseReleaseEvent( QMouseEvent *e);
139private: 139private:
140 QColor backgroundcolor, foregroundcolor; 140 QColor backgroundcolor, foregroundcolor;
141 QString scrollText; 141 QString scrollText;
142 QPixmap scrollTextPixmap; 142 QPixmap scrollTextPixmap;
143 int pos, updateTimerTime, scrollLength; 143 int pos, updateTimerTime, scrollLength;
144}; 144};
145 145
146#endif 146#endif
diff --git a/libopie/otimepicker.cpp b/libopie/otimepicker.cpp
index 8e8a4e7..115d39b 100644
--- a/libopie/otimepicker.cpp
+++ b/libopie/otimepicker.cpp
@@ -1,175 +1,245 @@
1#include "otimepicker.h" 1#include "otimepicker.h"
2 2
3#include <qbuttongroup.h> 3#include <qbuttongroup.h>
4#include <qtoolbutton.h> 4#include <qtoolbutton.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <stdio.h> 7#include <stdio.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9 9
10OTimePicker::OTimePicker(QWidget* parent, const char* name, 10
11/**
12 * Constructs the widget
13 * @param parent The parent of the OTimePicker
14 * @param name The name of the object
15 * @param fl Window Flags
16 */
17OTimePicker::OTimePicker(QWidget* parent, const char* name,
11 WFlags fl) : 18 WFlags fl) :
12 QWidget(parent,name,fl) 19 QWidget(parent,name,fl)
13{ 20{
21
14 QVBoxLayout *vbox=new QVBoxLayout(this); 22 QVBoxLayout *vbox=new QVBoxLayout(this);
15 23
16 OClickableLabel *r; 24 OClickableLabel *r;
17 QString s; 25 QString s;
18 26
19 // Hour Row 27 // Hour Row
20 QWidget *row=new QWidget(this); 28 QWidget *row=new QWidget(this);
21 QHBoxLayout *l=new QHBoxLayout(row); 29 QHBoxLayout *l=new QHBoxLayout(row);
22 vbox->addWidget(row); 30 vbox->addWidget(row);
23 31
24 32
25 for (int i=0; i<24; i++) { 33 for (int i=0; i<24; i++) {
26 r=new OClickableLabel(row); 34 r=new OClickableLabel(row);
27 hourLst.append(r); 35 hourLst.append(r);
28 s.sprintf("%.2d",i); 36 s.sprintf("%.2d",i);
29 r->setText(s); 37 r->setText(s);
30 r->setToggleButton(true); 38 r->setToggleButton(true);
31 r->setAlignment(AlignHCenter | AlignVCenter); 39 r->setAlignment(AlignHCenter | AlignVCenter);
32 l->addWidget(r); 40 l->addWidget(r);
33 connect(r, SIGNAL(toggled(bool)), 41 connect(r, SIGNAL(toggled(bool)),
34 this, SLOT(slotHour(bool))); 42 this, SLOT(slotHour(bool)));
35 43
36 if (i==11) { // Second row 44 if (i==11) { // Second row
37 row=new QWidget(this); 45 row=new QWidget(this);
38 l=new QHBoxLayout(row); 46 l=new QHBoxLayout(row);
39 vbox->addWidget(row); 47 vbox->addWidget(row);
40 } 48 }
41 } 49 }
42 50
43 // Minute Row 51 // Minute Row
44 row=new QWidget(this); 52 row=new QWidget(this);
45 l=new QHBoxLayout(row); 53 l=new QHBoxLayout(row);
46 vbox->addWidget(row); 54 vbox->addWidget(row);
47 55
48 for (int i=0; i<60; i+=5) { 56 for (int i=0; i<60; i+=5) {
49 r=new OClickableLabel(row); 57 r=new OClickableLabel(row);
50 minuteLst.append(r); 58 minuteLst.append(r);
51 s.sprintf("%.2d",i); 59 s.sprintf("%.2d",i);
52 r->setText(s); 60 r->setText(s);
53 r->setToggleButton(true); 61 r->setToggleButton(true);
54 r->setAlignment(AlignHCenter | AlignVCenter); 62 r->setAlignment(AlignHCenter | AlignVCenter);
55 l->addWidget(r); 63 l->addWidget(r);
56 connect(r, SIGNAL(toggled(bool)), 64 connect(r, SIGNAL(toggled(bool)),
57 this, SLOT(slotMinute(bool))); 65 this, SLOT(slotMinute(bool)));
58 } 66 }
59} 67}
60 68
69/**
70 * This method return the current time
71 * @return the time
72 */
73QTime OTimePicker::time()const {
74 return tm;
75}
76
61void OTimePicker::slotHour(bool b) { 77void OTimePicker::slotHour(bool b) {
62 78
63 OClickableLabel *r = (OClickableLabel *) sender(); 79 OClickableLabel *r = (OClickableLabel *) sender();
64 80
65 if (b) { 81 if (b) {
66 QValueListIterator<OClickableLabel *> it; 82 QValueListIterator<OClickableLabel *> it;
67 for (it=hourLst.begin(); it!=hourLst.end(); it++) { 83 for (it=hourLst.begin(); it!=hourLst.end(); it++) {
68 if (*it != r) (*it)->setOn(false); 84 if (*it != r) (*it)->setOn(false);
69 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); 85 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
70 } 86 }
71 emit timeChanged(tm); 87 emit timeChanged(tm);
72 } else { 88 } else {
73 r->setOn(true); 89 r->setOn(true);
74 } 90 }
75 91
76} 92}
77 93
78void OTimePicker::slotMinute(bool b) { 94void OTimePicker::slotMinute(bool b) {
79 95
80 OClickableLabel *r = (OClickableLabel *) sender(); 96 OClickableLabel *r = (OClickableLabel *) sender();
81 97
82 if (b) { 98 if (b) {
83 QValueListIterator<OClickableLabel *> it; 99 QValueListIterator<OClickableLabel *> it;
84 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { 100 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) {
85 if (*it != r) (*it)->setOn(false); 101 if (*it != r) (*it)->setOn(false);
86 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); 102 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0);
87 } 103 }
88 emit timeChanged(tm); 104 emit timeChanged(tm);
89 } else { 105 } else {
90 r->setOn(true); 106 r->setOn(true);
91 } 107 }
92 108
93} 109}
94 110
111/**
112 * Method to set the time. No signal gets emitted during this method call
113 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... )
114 * @param t The time to be set
115 */
116void OTimePicker::setTime( const QTime& t) {
117 setTime( t.hour(), t.minute() );
118}
119
120/**
121 * Method to set the time. No signal gets emitted during this method call
122 * @param h The hour
123 * @param m The minute. Minutes need to set by 5 minute steps
124 */
125void OTimePicker::setTime( int h, int m ) {
126 setHour(h);
127 setMinute(m);
128}
129
130/*
131 * FIXME round minutes to the 5 minute arrangement -zecke
132 */
133/**
134 * Method to set the minutes
135 * @param m minutes
136 */
95void OTimePicker::setMinute(int m) { 137void OTimePicker::setMinute(int m) {
96 138
97 QString minute; 139 QString minute;
98 minute.sprintf("%.2d",m); 140 minute.sprintf("%.2d",m);
99 141
100 QValueListIterator<OClickableLabel *> it; 142 QValueListIterator<OClickableLabel *> it;
101 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { 143 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) {
102 if ((*it)->text() == minute) (*it)->setOn(true); 144 if ((*it)->text() == minute) (*it)->setOn(true);
103 else (*it)->setOn(false); 145 else (*it)->setOn(false);
104 } 146 }
105 147
106 tm.setHMS(tm.hour(),m,0); 148 tm.setHMS(tm.hour(),m,0);
107} 149}
108 150
151/**
152 * Method to set the hour
153 */
109void OTimePicker::setHour(int h) { 154void OTimePicker::setHour(int h) {
110 155
111 QString hour; 156 QString hour;
112 hour.sprintf("%.2d",h); 157 hour.sprintf("%.2d",h);
113 158
114 QValueListIterator<OClickableLabel *> it; 159 QValueListIterator<OClickableLabel *> it;
115 for (it=hourLst.begin(); it!=hourLst.end(); it++) { 160 for (it=hourLst.begin(); it!=hourLst.end(); it++) {
116 if ((*it)->text() == hour) (*it)->setOn(true); 161 if ((*it)->text() == hour) (*it)->setOn(true);
117 else (*it)->setOn(false); 162 else (*it)->setOn(false);
118 } 163 }
119 tm.setHMS(h,tm.minute(),0); 164 tm.setHMS(h,tm.minute(),0);
120} 165}
121 166
122 167
168/**
169 * This is a modal Dialog.
170 *
171 * @param parent The parent widget
172 * @param name The name of the object
173 * @param fl Possible window flags
174 */
123OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) 175OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl )
124 : OTimePickerDialogBase (parent , name, true , fl) 176 : OTimePickerDialogBase (parent , name, true , fl)
125{ 177{
126 178
127 connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), 179 connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ),
128 this, SLOT( setTime ( const QTime& ) ) ); 180 this, SLOT( setTime ( const QTime& ) ) );
129 connect ( minuteField, SIGNAL( textChanged ( const QString& ) ), 181 connect ( minuteField, SIGNAL( textChanged ( const QString& ) ),
130 this, SLOT ( setMinute ( const QString& ) ) ); 182 this, SLOT ( setMinute ( const QString& ) ) );
131 connect ( hourField, SIGNAL( textChanged ( const QString& ) ), 183 connect ( hourField, SIGNAL( textChanged ( const QString& ) ),
132 this, SLOT ( setHour ( const QString& ) ) ); 184 this, SLOT ( setHour ( const QString& ) ) );
133 185
134} 186}
135 187
136QTime& OTimePickerDialog::time() 188/**
189 * @return the time
190 */
191QTime OTimePickerDialog::time()const
137{ 192{
138 return m_time; 193 return m_time;
139} 194}
195
196/**
197 * Set the time to time
198 * @param time The time to be set
199 */
140void OTimePickerDialog::setTime( const QTime& time ) 200void OTimePickerDialog::setTime( const QTime& time )
141{ 201{
142 m_time = time; 202 m_time = time;
143 203
144 m_timePicker->setHour ( time.hour() ); 204 m_timePicker->setHour ( time.hour() );
145 m_timePicker->setMinute( time.minute() ); 205 m_timePicker->setMinute( time.minute() );
146 206
147 // Set Textfields 207 // Set Textfields
148 if ( time.hour() < 10 ) 208 if ( time.hour() < 10 )
149 hourField->setText( "0" + QString::number( time.hour() ) ); 209 hourField->setText( "0" + QString::number( time.hour() ) );
150 else 210 else
151 hourField->setText( QString::number( time.hour() ) ); 211 hourField->setText( QString::number( time.hour() ) );
152 212
153 if ( time.minute() < 10 ) 213 if ( time.minute() < 10 )
154 minuteField->setText( "0" + QString::number( time.minute() ) ); 214 minuteField->setText( "0" + QString::number( time.minute() ) );
155 else 215 else
156 minuteField->setText( QString::number( time.minute() ) ); 216 minuteField->setText( QString::number( time.minute() ) );
157 217
158} 218}
159 219
220/**
221 * This method takes the current minute and tries to set hour
222 * to hour. This succeeds if the resulting date is valid
223 * @param hour The hour as a string
224 */
160void OTimePickerDialog::setHour ( const QString& hour ) 225void OTimePickerDialog::setHour ( const QString& hour )
161{ 226{
162 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){ 227 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){
163 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); 228 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 );
164 setTime ( m_time ); 229 setTime ( m_time );
165 } 230 }
166 231
167} 232}
168 233
234/**
235 * Method to set a new minute. It tries to convert the string to int and
236 * if the resulting date is valid a new date is set.
237 * @see setHour
238 */
169void OTimePickerDialog::setMinute ( const QString& minute ) 239void OTimePickerDialog::setMinute ( const QString& minute )
170{ 240{
171 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){ 241 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){
172 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); 242 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 );
173 setTime ( m_time ); 243 setTime ( m_time );
174 } 244 }
175} 245}
diff --git a/libopie/otimepicker.h b/libopie/otimepicker.h
index 825e2d6..495c806 100644
--- a/libopie/otimepicker.h
+++ b/libopie/otimepicker.h
@@ -1,51 +1,81 @@
1#ifndef OTIMEPICKER_H 1#ifndef OTIMEPICKER_H
2#define OTIMEPICKER_H 2#define OTIMEPICKER_H
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qvaluelist.h> 5#include <qvaluelist.h>
6#include <qdatetime.h> 6#include <qdatetime.h>
7#include <qdialog.h> 7#include <qdialog.h>
8 8
9#include <opie/oclickablelabel.h> 9#include <opie/oclickablelabel.h>
10#include "otimepickerbase.h" 10#include "otimepickerbase.h"
11 11
12/**
13 * A class to pick time. It uses clickable labels
14 * internally to allow a quick selection of a time.
15 * A time can be selected by two clicks of a user
16 *
17 * @short A widget to quickly pick a QTime
18 * @version 1.0
19 * @see QWidget
20 * @see QTime
21 * @author Hakan Ardo, Stefan Eilers
22 */
12class OTimePicker: public QWidget { 23class OTimePicker: public QWidget {
13 Q_OBJECT 24 Q_OBJECT
14 25
15 public: 26 public:
16 OTimePicker(QWidget* parent = 0, const char* name = 0, 27 OTimePicker(QWidget* parent = 0, const char* name = 0,
17 WFlags fl = 0); 28 WFlags fl = 0);
29
30 public slots:
18 void setHour(int h); 31 void setHour(int h);
19 void setMinute(int m); 32 void setMinute(int m);
33 void setTime( const QTime& );
34 void setTime( int h, int m );
35
36 public:
37 QTime time()const;
20 38
21 private: 39 private:
22 QValueList<OClickableLabel *> hourLst; 40 QValueList<OClickableLabel *> hourLst;
23 QValueList<OClickableLabel *> minuteLst; 41 QValueList<OClickableLabel *> minuteLst;
24 QTime tm; 42 QTime tm;
43 struct Private;
44 Private *d;
25 45
26 private slots: 46 private slots:
27 void slotHour(bool b); 47 void slotHour(bool b);
28 void slotMinute(bool b); 48 void slotMinute(bool b);
29 49
30 signals: 50 signals:
51 /**
52 * gets emitted when the time got changed by the user
53 */
31 void timeChanged(const QTime &); 54 void timeChanged(const QTime &);
32}; 55};
33 56
57/**
58 *
59 * @short
60 * @version 1.0
61 * @author Stefan Eilers
62 */
63
34class OTimePickerDialog: public OTimePickerDialogBase { 64class OTimePickerDialog: public OTimePickerDialogBase {
35 Q_OBJECT 65 Q_OBJECT
36 66
37 public: 67 public:
38 OTimePickerDialog ( QWidget* parent = 0, const char* name = NULL, WFlags fl = 0 ); 68 OTimePickerDialog ( QWidget* parent = 0, const char* name = NULL, WFlags fl = 0 );
39 ~OTimePickerDialog() { }; 69 ~OTimePickerDialog() { };
40 70
41 QTime& time(); 71 QTime time()const;
42 72
43 public slots: 73 public slots:
44 void setTime( const QTime& time ); 74 void setTime( const QTime& time );
45 void setHour( const QString& hour ); 75 void setHour( const QString& hour );
46 void setMinute( const QString& minute ); 76 void setMinute( const QString& minute );
47 77
48 private: 78 private:
49 QTime m_time; 79 QTime m_time;
50}; 80};
51#endif 81#endif
diff --git a/libopie/owait.cpp b/libopie/owait.cpp
index c90bb72..0fdf08d 100644
--- a/libopie/owait.cpp
+++ b/libopie/owait.cpp
@@ -1,83 +1,93 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org) 2 Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpainter.h> 24#include <qpainter.h>
25 25
26#include "owait.h" 26#include "owait.h"
27 27
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29 29
30static int frame = 0; 30static int frame = 0;
31 31
32/**
33 * This will construct a modal dialog.
34 *
35 * The default timer length is 10.
36 *
37 * @param parent The parent of the widget
38 * @param msg The name of the object
39 * @param dispIcon Display Icon?
40 */
32OWait::OWait(QWidget *parent, const char* msg, bool dispIcon ) 41OWait::OWait(QWidget *parent, const char* msg, bool dispIcon )
33 :QDialog(parent, QObject::tr("Wait"), TRUE,WStyle_Customize) { 42 :QDialog(parent, msg, TRUE,WStyle_Customize) {
43
34 44
35 QHBoxLayout *hbox = new QHBoxLayout( this ); 45 QHBoxLayout *hbox = new QHBoxLayout( this );
36 46
37 m_lb = new QLabel( this ); 47 m_lb = new QLabel( this );
38 m_lb->setBackgroundMode ( NoBackground ); 48 m_lb->setBackgroundMode ( NoBackground );
39 49
40 hbox->addWidget( m_lb ); 50 hbox->addWidget( m_lb );
41 hbox->activate(); 51 hbox->activate();
42 52
43 m_pix = Resource::loadPixmap( "BigBusy" ); 53 m_pix = Resource::loadPixmap( "BigBusy" );
44 m_aniSize = m_pix.height(); 54 m_aniSize = m_pix.height();
45 resize( m_aniSize, m_aniSize ); 55 resize( m_aniSize, m_aniSize );
46 56
47 m_timerLength = 10; 57 m_timerLength = 10;
48 58
49 m_waitTimer = new QTimer( this ); 59 m_waitTimer = new QTimer( this );
50 connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); 60 connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) );
51} 61}
52 62
53void OWait::timerEvent( QTimerEvent * ) { 63void OWait::timerEvent( QTimerEvent * ) {
54 frame = (++frame) % 4; 64 frame = (++frame) % 4;
55 repaint(); 65 repaint();
56} 66}
57 67
58void OWait::paintEvent( QPaintEvent * ) { 68void OWait::paintEvent( QPaintEvent * ) {
59 QPainter p( m_lb ); 69 QPainter p( m_lb );
60 p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); 70 p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize );
61} 71}
62 72
63void OWait::show() { 73void OWait::show() {
64 74
65 move( ( ( qApp->desktop()->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop()->height() ) / 2 ) - ( m_aniSize / 2 ) ); 75 move( ( ( qApp->desktop()->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop()->height() ) / 2 ) - ( m_aniSize / 2 ) );
66 startTimer( 300 ); 76 startTimer( 300 );
67 m_waitTimer->start( m_timerLength * 1000, true ); 77 m_waitTimer->start( m_timerLength * 1000, true );
68 QDialog::show(); 78 QDialog::show();
69} 79}
70 80
71void OWait::hide() { 81void OWait::hide() {
72 killTimers(); 82 killTimers();
73 m_waitTimer->stop(); 83 m_waitTimer->stop();
74 frame = 0; 84 frame = 0;
75 QDialog::hide(); 85 QDialog::hide();
76} 86}
77 87
78void OWait::setTimerLength( int length ) { 88void OWait::setTimerLength( int length ) {
79 m_timerLength = length; 89 m_timerLength = length;
80} 90}
81 91
82OWait::~OWait() { 92OWait::~OWait() {
83} 93}
diff --git a/libopie/owait.h b/libopie/owait.h
index d22e141..6217e31 100644
--- a/libopie/owait.h
+++ b/libopie/owait.h
@@ -1,69 +1,74 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org) 2 Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20 20
21 21
22#ifndef WAITPOPUP_H 22#ifndef WAITPOPUP_H
23#define WAITPOPUP_H 23#define WAITPOPUP_H
24 24
25#include <qdialog.h> 25#include <qdialog.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30/** 30/**
31 * This class displays a animated waiting icon in the middle of the screen. 31 * This class displays a animated waiting icon in the middle of the screen.
32 *
33 * @short modal hour glass dialog
34 * @see QDialog
35 * @author Maximilian Reiß
32 */ 36 */
33class OWait : public QDialog { 37class OWait : public QDialog {
34 38
35 Q_OBJECT 39 Q_OBJECT
36 40
37public: 41public:
38 OWait(QWidget *parent=0,const char* msg=0,bool dispIcon=TRUE); 42 OWait(QWidget *parent=0,const char* name=0, bool dispIcon=TRUE);
39 ~OWait(); 43 ~OWait();
40 44
41 /** 45 /**
42 * reimplemented for control reasons 46 * reimplemented for control reasons
43 */ 47 */
44 void show(); 48 void show();
45 49
46 /** 50 /**
47 * Set the time before the icon will be automaticly hidden 51 * Set the time before the icon will be automaticly hidden
52 * The timer will be started once the widget will be shown.
48 * @param length - time in seconds 53 * @param length - time in seconds
49 */ 54 */
50 void setTimerLength( int length ); 55 void setTimerLength( int length );
51 56
52 public slots: 57 public slots:
53 /** 58 /**
54 * reimplemented for control reasons 59 * reimplemented for control reasons
55 */ 60 */
56 void hide(); 61 void hide();
57 62
58 private: 63 private:
59 void timerEvent( QTimerEvent * ) ; 64 void timerEvent( QTimerEvent * ) ;
60 void paintEvent( QPaintEvent * ); 65 void paintEvent( QPaintEvent * );
61 66
62 QPixmap m_pix; 67 QPixmap m_pix;
63 QLabel *m_lb; 68 QLabel *m_lb;
64 QTimer *m_waitTimer; 69 QTimer *m_waitTimer;
65 int m_timerLength; 70 int m_timerLength;
66 int m_aniSize; 71 int m_aniSize;
67}; 72};
68 73
69#endif 74#endif
diff --git a/libopie/todayconfigwidget.h b/libopie/todayconfigwidget.h
index 48cf379..6b49efc 100644
--- a/libopie/todayconfigwidget.h
+++ b/libopie/todayconfigwidget.h
@@ -1,21 +1,39 @@
1 1
2#ifndef CONFIG_WIDGET_H 2#ifndef CONFIG_WIDGET_H
3#define CONFIG_WIDGET_H 3#define CONFIG_WIDGET_H
4 4
5 5
6/**
7 * A base class for all Today Config Widgets.
8 * This will let a Today plugin to add the possibility of configuration.
9 * Plugins need to inherit from this class and need to implement
10 * the pure virtual method to control configuration.
11 * The Plugin should read its configuration during creation of the Widget
12 *
13 *
14 * @author Maximilian Reiß
15 * @short base class of all today config widgets
16 */
6class TodayConfigWidget : public QWidget { 17class TodayConfigWidget : public QWidget {
7 18
8 19
9public: 20public:
10 21
22 /**
23 * This will construct the widget. The widget gets deleted once the parent
24 * gets deleted as in any Qt application
25 *
26 * @param parent The parent of the widget
27 * @paran name The name of the object
28 */
11 TodayConfigWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) {} ; 29 TodayConfigWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) {} ;
12 virtual ~TodayConfigWidget() {}; 30 virtual ~TodayConfigWidget() {};
13 31
14 /** 32 /**
15 * Plugins need to reimplement this in the config widget 33 * Plugins need to reimplement this in the config widget
16 * Used when the config dialog is closed to write config stuff 34 * Used when the config dialog is closed to write config stuff
17 */ 35 */
18 virtual void writeConfig() = 0; 36 virtual void writeConfig() = 0;
19}; 37};
20 38
21#endif 39#endif
diff --git a/libopie/todayplugininterface.h b/libopie/todayplugininterface.h
index 6ee2a06..29a12bc 100644
--- a/libopie/todayplugininterface.h
+++ b/libopie/todayplugininterface.h
@@ -1,89 +1,106 @@
1 1
2#ifndef TODAY_PLUGIN_INTERFACE 2#ifndef TODAY_PLUGIN_INTERFACE
3#define TODAY_PLUGIN_INTERFACE 3#define TODAY_PLUGIN_INTERFACE
4 4
5#include <qpe/qcom.h> 5#include <qpe/qcom.h>
6#include "todayconfigwidget.h" 6#include "todayconfigwidget.h"
7 7
8class QString; 8class QString;
9class QWidget; 9class QWidget;
10 10
11#ifndef IID_TodayPluginInterface 11#ifndef IID_TodayPluginInterface
12#define IID_TodayPluginInterface QUuid( 0x70481804, 0x2b50, 0x4fba, 0x80, 0xbb, 0x0b, 0xf8, 0xdc, 0x72, 0x04, 0x14) 12#define IID_TodayPluginInterface QUuid( 0x70481804, 0x2b50, 0x4fba, 0x80, 0xbb, 0x0b, 0xf8, 0xdc, 0x72, 0x04, 0x14)
13#endif 13#endif
14 14
15/** 15/**
16 * 16 *
17 * A TodayPluginObject is the base for all Today Plugins.
18 * A plugin author needs to inherit this class and implement
19 * the pure virtual methods
17 * 20 *
21 * @short base class for today plugins
22 * @author Maximilian Reiss
18 * 23 *
19 */ 24 */
20class TodayPluginObject { 25class TodayPluginObject {
21 26
22public: 27public:
23 28
24 virtual ~TodayPluginObject() {}; 29 virtual ~TodayPluginObject() {};
25 30
26 /** 31 /**
27 * The name if the plugin 32 * The name if the plugin
33 * @return The plugin should return its name here
28 */ 34 */
29 virtual QString pluginName() const = 0; 35 virtual QString pluginName() const = 0;
30 36
31 /** 37 /**
32 * Version numbering 38 * Version numbering
39 * @return The plugin should return the version number
33 */ 40 */
34 virtual double versionNumber() const = 0; 41 virtual double versionNumber() const = 0;
35 42
36 43
44 /**
45 * @return the pixmap name widget?! -- FIXME
46 */
37 virtual QString pixmapNameWidget() const = 0; 47 virtual QString pixmapNameWidget() const = 0;
38 48
39 /** widget for the today view 49 /**
50 * widget for the today view
40 * It _needs_ a parent here. 51 * It _needs_ a parent here.
52 * Plugin authors need to take parent as parent!
41 */ 53 */
42 virtual QWidget* widget( QWidget * ) = 0; 54 virtual QWidget* widget( QWidget *parent ) = 0;
43 55
44 /** 56 /**
45 * Pixmap used in the config widget 57 * Pixmap used in the config widget
46 */ 58 */
47 virtual QString pixmapNameConfig() const = 0; 59 virtual QString pixmapNameConfig() const = 0;
48 60
49 /** 61 /**
50 * Config plugin widget - optional 62 * Config plugin widget - optional
51 * If the plugin has a config widget, it _needs_ a parent here. 63 * If the plugin has a config widget, it _needs_ a parent here.
64 * may return 0 if no config widget is needed
52 */ 65 */
53 virtual TodayConfigWidget* configWidget( QWidget * ) = 0; 66 virtual TodayConfigWidget* configWidget( QWidget * ) = 0;
54 67
55 /** 68 /**
56 * The application that should be assigned to the button (pixmap) 69 * The application that should be assigned to the button (pixmap)
70 * Today will show the plugin icon. On click it tries to execute the
71 * plugin related application.
57 */ 72 */
58 virtual QString appName() const = 0; 73 virtual QString appName() const = 0;
59 74
60 75
61 /** 76 /**
62 * If the plugin should take part in the periodic refresh 77 * If the plugin should take part in the periodic refresh
63 */ 78 */
64 virtual bool excludeFromRefresh() const = 0; 79 virtual bool excludeFromRefresh() const = 0;
65 80
66 /** 81 /**
67 * Refresh that plugins view. For updating the plugins 82 * Refresh that plugins view. For updating the plugins
68 * 83 *
69 */ 84 */
70 virtual void refresh() {}; 85 virtual void refresh() {};
71 86
72 /** 87 /**
73 * minimum height the plugin at least should have 88 * minimum height the plugin at least should have
74 */ 89 */
75 // virtual int minHeight() const = 0; 90 // virtual int minHeight() const = 0;
76 91
77 /** 92 /**
78 * maximum height that should be used before starting scrolling 93 * maximum height that should be used before starting scrolling
79 */ 94 */
80 // virtual int maxHeight() const = 0; 95 // virtual int maxHeight() const = 0;
81 96
82}; 97};
83 98
84 99/**
100 * This is part of the QCOM works. See example plugins how to do it right
101 */
85struct TodayPluginInterface : public QUnknownInterface { 102struct TodayPluginInterface : public QUnknownInterface {
86 virtual TodayPluginObject *guiPart() = 0; 103 virtual TodayPluginObject *guiPart() = 0;
87}; 104};
88 105
89#endif 106#endif