summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/big-screen/example/osplitter_mail.cpp4
-rw-r--r--libopie/colordialog.cpp8
-rw-r--r--libopie/colorpopupmenu.cpp2
-rw-r--r--libopie/ocolorbutton.cpp2
-rw-r--r--libopie/odevice.cpp16
-rw-r--r--libopie/ofileselector.cpp14
-rw-r--r--libopie/ofontselector.cpp8
-rw-r--r--libopie/orecurrancewidget.cpp4
-rw-r--r--libopie/otabwidget.cpp4
-rw-r--r--libopie/otimepicker.cpp12
-rw-r--r--libopie/pim/ocontactaccess.cpp13
-rw-r--r--libopie/pim/opimmainwindow.cpp8
12 files changed, 50 insertions, 45 deletions
diff --git a/libopie/big-screen/example/osplitter_mail.cpp b/libopie/big-screen/example/osplitter_mail.cpp
index 4eaf3a9..4356baa 100644
--- a/libopie/big-screen/example/osplitter_mail.cpp
+++ b/libopie/big-screen/example/osplitter_mail.cpp
@@ -1,82 +1,82 @@
1 1
2#include <qstring.h> 2#include <qstring.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qheader.h> 4#include <qheader.h>
5#include <qlayout.h> 5#include <qlayout.h>
6 6
7#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
8#include <opie/oapplicationfactory.h> 8#include <opie/oapplicationfactory.h>
9 9
10#include "../osplitter.h" 10#include "../osplitter.h"
11 11
12#include "osplitter_mail.h" 12#include "osplitter_mail.h"
13 13
14 14
15OPIE_EXPORT_APP( OApplicationFactory<ListViews> ) 15OPIE_EXPORT_APP( OApplicationFactory<ListViews> )
16 16
17class Folder { 17class Folder {
18 int dummy; 18 int dummy;
19}; 19};
20 20
21// ----------------------------------------------------------------- 21// -----------------------------------------------------------------
22 22
23ListViews::ListViews( QWidget* p, const char* name, WFlags fl ) 23ListViews::ListViews( QWidget* p, const char* name, WFlags fl )
24 : QWidget( p, name, fl ) { 24 : QWidget( p, name, fl ) {
25 qApp->installEventFilter( this ); 25 qApp->installEventFilter( this );
26 m_lstFolders.setAutoDelete( true ); 26 m_lstFolders.setAutoDelete( true );
27 QHBoxLayout *lay = new QHBoxLayout(this); 27 QHBoxLayout *lay = new QHBoxLayout(this);
28 28
29 m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" ); 29 m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" );
30 lay->addWidget( m_splitter ); 30 lay->addWidget( m_splitter );
31 connect(m_splitter, SIGNAL(sizeChange(bool, const QSize& ) ), 31 connect(m_splitter, SIGNAL(sizeChange(bool,const QSize&) ),
32 this, SLOT(slotSizeChange(bool, const QSize& ) ) ); 32 this, SLOT(slotSizeChange(bool,const QSize&) ) );
33 33
34 m_overview = new QListView( m_splitter ); 34 m_overview = new QListView( m_splitter );
35 m_overview->header()->setClickEnabled( FALSE ); 35 m_overview->header()->setClickEnabled( FALSE );
36 m_overview->addColumn( tr("Folder") ); 36 m_overview->addColumn( tr("Folder") );
37 m_overview->setMaximumWidth( 200 ); 37 m_overview->setMaximumWidth( 200 );
38 m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") ); 38 m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") );
39 m_splitter->setSizeChange( 300 ); 39 m_splitter->setSizeChange( 300 );
40 40
41 /* OSplitter starts with the small mode */ 41 /* OSplitter starts with the small mode */
42 m_messages = 0; 42 m_messages = 0;
43 m_message = m_attach = 0; 43 m_message = m_attach = 0;
44 44
45 splitti = new OSplitter( Vertical, m_splitter, "Splitti2" ); 45 splitti = new OSplitter( Vertical, m_splitter, "Splitti2" );
46 splitti->setSizeChange( 300 ); 46 splitti->setSizeChange( 300 );
47 splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) ); 47 splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
48 48
49 QLabel *lbl = new QLabel(splitti); 49 QLabel *lbl = new QLabel(splitti);
50 lbl->setTextFormat ( Qt::RichText ); 50 lbl->setTextFormat ( Qt::RichText );
51 lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>"); 51 lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>");
52 52
53 m_messages = new QListView( splitti ); 53 m_messages = new QListView( splitti );
54 m_messages->addColumn(" Messages "); 54 m_messages->addColumn(" Messages ");
55 55
56 folder1 = new QListView( splitti ); 56 folder1 = new QListView( splitti );
57 folder1->addColumn( "Messages 2 " ); 57 folder1->addColumn( "Messages 2 " );
58 58
59 splitti->addWidget(m_messages, "mail", tr("Mails") ); 59 splitti->addWidget(m_messages, "mail", tr("Mails") );
60 splitti->addWidget(folder1, "folder", tr("Folder") ); 60 splitti->addWidget(folder1, "folder", tr("Folder") );
61 splitti->addWidget( lbl, "logo", tr("Label") ); 61 splitti->addWidget( lbl, "logo", tr("Label") );
62 m_message = lbl; 62 m_message = lbl;
63 63
64 m_splitter->addWidget( splitti ); 64 m_splitter->addWidget( splitti );
65 65
66} 66}
67 67
68 68
69ListViews::~ListViews() { 69ListViews::~ListViews() {
70 70
71} 71}
72 72
73 73
74bool ListViews::eventFilter( QObject* obj, QEvent* ev ) { 74bool ListViews::eventFilter( QObject* obj, QEvent* ev ) {
75 if (!obj->isWidgetType() ) 75 if (!obj->isWidgetType() )
76 return false; 76 return false;
77 if ( ev->type() == QEvent::MouseButtonRelease ) { 77 if ( ev->type() == QEvent::MouseButtonRelease ) {
78 qWarning(" name %s, class %s", obj->name(), obj->className() ); 78 qWarning(" name %s, class %s", obj->name(), obj->className() );
79 } 79 }
80 80
81 return false; 81 return false;
82} 82}
diff --git a/libopie/colordialog.cpp b/libopie/colordialog.cpp
index d46da41..b2854a6 100644
--- a/libopie/colordialog.cpp
+++ b/libopie/colordialog.cpp
@@ -283,388 +283,388 @@ void QColorPicker::setCol( int h, int s )
283} 283}
284 284
285void QColorPicker::mouseMoveEvent( QMouseEvent *m ) 285void QColorPicker::mouseMoveEvent( QMouseEvent *m )
286{ 286{
287 QPoint p = m->pos() - contentsRect().topLeft(); 287 QPoint p = m->pos() - contentsRect().topLeft();
288 setCol( p ); 288 setCol( p );
289 emit newCol( hue, sat ); 289 emit newCol( hue, sat );
290} 290}
291 291
292void QColorPicker::mousePressEvent( QMouseEvent *m ) 292void QColorPicker::mousePressEvent( QMouseEvent *m )
293{ 293{
294 QPoint p = m->pos() - contentsRect().topLeft(); 294 QPoint p = m->pos() - contentsRect().topLeft();
295 setCol( p ); 295 setCol( p );
296 emit newCol( hue, sat ); 296 emit newCol( hue, sat );
297} 297}
298 298
299void QColorPicker::drawContents(QPainter* p) 299void QColorPicker::drawContents(QPainter* p)
300{ 300{
301 QRect r = contentsRect(); 301 QRect r = contentsRect();
302 302
303 p->drawPixmap( r.topLeft(), *pix ); 303 p->drawPixmap( r.topLeft(), *pix );
304 QPoint pt = colPt() + r.topLeft(); 304 QPoint pt = colPt() + r.topLeft();
305 p->setPen( QPen(black) ); 305 p->setPen( QPen(black) );
306 306
307 p->fillRect( pt.x()-9, pt.y(), 20, 2, black ); 307 p->fillRect( pt.x()-9, pt.y(), 20, 2, black );
308 p->fillRect( pt.x(), pt.y()-9, 2, 20, black ); 308 p->fillRect( pt.x(), pt.y()-9, 2, 20, black );
309 309
310} 310}
311 311
312class QColorShowLabel; 312class QColorShowLabel;
313 313
314 314
315 315
316class QColIntValidator: public QIntValidator 316class QColIntValidator: public QIntValidator
317{ 317{
318public: 318public:
319 QColIntValidator( int bottom, int top, 319 QColIntValidator( int bottom, int top,
320 QWidget * parent, const char *name = 0 ) 320 QWidget * parent, const char *name = 0 )
321 :QIntValidator( bottom, top, parent, name ) {} 321 :QIntValidator( bottom, top, parent, name ) {}
322 322
323 QValidator::State validate( QString &, int & ) const; 323 QValidator::State validate( QString &, int & ) const;
324}; 324};
325 325
326QValidator::State QColIntValidator::validate( QString &s, int &pos ) const 326QValidator::State QColIntValidator::validate( QString &s, int &pos ) const
327{ 327{
328 State state = QIntValidator::validate(s,pos); 328 State state = QIntValidator::validate(s,pos);
329 if ( state == Valid ) { 329 if ( state == Valid ) {
330 long int val = s.toLong(); 330 long int val = s.toLong();
331 // This is not a general solution, assumes that top() > 0 and 331 // This is not a general solution, assumes that top() > 0 and
332 // bottom >= 0 332 // bottom >= 0
333 if ( val < 0 ) { 333 if ( val < 0 ) {
334 s = "0"; 334 s = "0";
335 pos = 1; 335 pos = 1;
336 } else if ( val > top() ) { 336 } else if ( val > top() ) {
337 s.setNum( top() ); 337 s.setNum( top() );
338 pos = s.length(); 338 pos = s.length();
339 } 339 }
340 } 340 }
341 return state; 341 return state;
342} 342}
343 343
344 344
345 345
346class QColNumLineEdit : public QLineEdit 346class QColNumLineEdit : public QLineEdit
347{ 347{
348public: 348public:
349 QColNumLineEdit( QWidget *parent, const char* name = 0 ) 349 QColNumLineEdit( QWidget *parent, const char* name = 0 )
350 : QLineEdit( parent, name ) { setMaxLength( 3 );} 350 : QLineEdit( parent, name ) { setMaxLength( 3 );}
351 QSize sizeHint() const { 351 QSize sizeHint() const {
352 return QSize( 30, //##### 352 return QSize( 30, //#####
353 QLineEdit::sizeHint().height() ); } 353 QLineEdit::sizeHint().height() ); }
354 void setNum( int i ) { 354 void setNum( int i ) {
355 QString s; 355 QString s;
356 s.setNum(i); 356 s.setNum(i);
357 bool block = signalsBlocked(); 357 bool block = signalsBlocked();
358 blockSignals(TRUE); 358 blockSignals(TRUE);
359 setText( s ); 359 setText( s );
360 blockSignals(block); 360 blockSignals(block);
361 } 361 }
362 int val() const { return text().toInt(); } 362 int val() const { return text().toInt(); }
363}; 363};
364 364
365 365
366class QColorShower : public QWidget 366class QColorShower : public QWidget
367{ 367{
368 Q_OBJECT 368 Q_OBJECT
369public: 369public:
370 QColorShower( QWidget *parent, const char *name = 0 ); 370 QColorShower( QWidget *parent, const char *name = 0 );
371 371
372 //things that don't emit signals 372 //things that don't emit signals
373 void setHsv( int h, int s, int v ); 373 void setHsv( int h, int s, int v );
374 374
375 int currentAlpha() const { return alphaEd->val(); } 375 int currentAlpha() const { return alphaEd->val(); }
376 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); } 376 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
377 void showAlpha( bool b ); 377 void showAlpha( bool b );
378 378
379 379
380 QRgb currentColor() const { return curCol; } 380 QRgb currentColor() const { return curCol; }
381 381
382public slots: 382public slots:
383 void setRgb( QRgb rgb ); 383 void setRgb( QRgb rgb );
384 384
385signals: 385signals:
386 void newCol( QRgb rgb ); 386 void newCol( QRgb rgb );
387private slots: 387private slots:
388 void rgbEd(); 388 void rgbEd();
389 void hsvEd(); 389 void hsvEd();
390private: 390private:
391 void showCurrentColor(); 391 void showCurrentColor();
392 int hue, sat, val; 392 int hue, sat, val;
393 QRgb curCol; 393 QRgb curCol;
394 QColNumLineEdit *hEd; 394 QColNumLineEdit *hEd;
395 QColNumLineEdit *sEd; 395 QColNumLineEdit *sEd;
396 QColNumLineEdit *vEd; 396 QColNumLineEdit *vEd;
397 QColNumLineEdit *rEd; 397 QColNumLineEdit *rEd;
398 QColNumLineEdit *gEd; 398 QColNumLineEdit *gEd;
399 QColNumLineEdit *bEd; 399 QColNumLineEdit *bEd;
400 QColNumLineEdit *alphaEd; 400 QColNumLineEdit *alphaEd;
401 QLabel *alphaLab; 401 QLabel *alphaLab;
402 QColorShowLabel *lab; 402 QColorShowLabel *lab;
403 bool rgbOriginal; 403 bool rgbOriginal;
404}; 404};
405 405
406class QColorShowLabel : public QFrame 406class QColorShowLabel : public QFrame
407{ 407{
408 Q_OBJECT 408 Q_OBJECT
409 409
410public: 410public:
411 QColorShowLabel( QWidget *parent ) :QFrame( parent ) { 411 QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
412 setFrameStyle( QFrame::Panel|QFrame::Sunken ); 412 setFrameStyle( QFrame::Panel|QFrame::Sunken );
413 setBackgroundMode( PaletteBackground ); 413 setBackgroundMode( PaletteBackground );
414 setAcceptDrops( TRUE ); 414 setAcceptDrops( TRUE );
415 mousePressed = FALSE; 415 mousePressed = FALSE;
416 } 416 }
417 void setColor( QColor c ) { col = c; } 417 void setColor( QColor c ) { col = c; }
418 418
419signals: 419signals:
420 void colorDropped( QRgb ); 420 void colorDropped( QRgb );
421 421
422protected: 422protected:
423 void drawContents( QPainter *p ); 423 void drawContents( QPainter *p );
424 void mousePressEvent( QMouseEvent *e ); 424 void mousePressEvent( QMouseEvent *e );
425 void mouseReleaseEvent( QMouseEvent *e ); 425 void mouseReleaseEvent( QMouseEvent *e );
426 426
427private: 427private:
428 QColor col; 428 QColor col;
429 bool mousePressed; 429 bool mousePressed;
430 QPoint pressPos; 430 QPoint pressPos;
431 431
432}; 432};
433 433
434void QColorShowLabel::drawContents( QPainter *p ) 434void QColorShowLabel::drawContents( QPainter *p )
435{ 435{
436 p->fillRect( contentsRect(), col ); 436 p->fillRect( contentsRect(), col );
437} 437}
438 438
439void QColorShower::showAlpha( bool b ) 439void QColorShower::showAlpha( bool b )
440{ 440{
441 if ( b ) { 441 if ( b ) {
442 alphaLab->show(); 442 alphaLab->show();
443 alphaEd->show(); 443 alphaEd->show();
444 } else { 444 } else {
445 alphaLab->hide(); 445 alphaLab->hide();
446 alphaEd->hide(); 446 alphaEd->hide();
447 } 447 }
448} 448}
449 449
450void QColorShowLabel::mousePressEvent( QMouseEvent *e ) 450void QColorShowLabel::mousePressEvent( QMouseEvent *e )
451{ 451{
452 mousePressed = TRUE; 452 mousePressed = TRUE;
453 pressPos = e->pos(); 453 pressPos = e->pos();
454} 454}
455 455
456void QColorShowLabel::mouseReleaseEvent( QMouseEvent * ) 456void QColorShowLabel::mouseReleaseEvent( QMouseEvent * )
457{ 457{
458 if ( !mousePressed ) 458 if ( !mousePressed )
459 return; 459 return;
460 mousePressed = FALSE; 460 mousePressed = FALSE;
461} 461}
462 462
463QColorShower::QColorShower( QWidget *parent, const char *name ) 463QColorShower::QColorShower( QWidget *parent, const char *name )
464 :QWidget( parent, name) 464 :QWidget( parent, name)
465{ 465{
466 curCol = qRgb( -1, -1, -1 ); 466 curCol = qRgb( -1, -1, -1 );
467 QColIntValidator *val256 = new QColIntValidator( 0, 255, this ); 467 QColIntValidator *val256 = new QColIntValidator( 0, 255, this );
468 QColIntValidator *val360 = new QColIntValidator( 0, 360, this ); 468 QColIntValidator *val360 = new QColIntValidator( 0, 360, this );
469 469
470 QGridLayout *gl = new QGridLayout( this, 1, 1, 2 ); 470 QGridLayout *gl = new QGridLayout( this, 1, 1, 2 );
471 gl->setMargin( 0 ); 471 gl->setMargin( 0 );
472 lab = new QColorShowLabel( this ); 472 lab = new QColorShowLabel( this );
473 lab->setMinimumWidth( 60 ); //### 473 lab->setMinimumWidth( 60 ); //###
474 gl->addMultiCellWidget(lab, 0,-1,0,0); 474 gl->addMultiCellWidget(lab, 0,-1,0,0);
475 connect( lab, SIGNAL( colorDropped( QRgb ) ), 475 connect( lab, SIGNAL( colorDropped(QRgb) ),
476 this, SIGNAL( newCol( QRgb ) ) ); 476 this, SIGNAL( newCol(QRgb) ) );
477 connect( lab, SIGNAL( colorDropped( QRgb ) ), 477 connect( lab, SIGNAL( colorDropped(QRgb) ),
478 this, SLOT( setRgb( QRgb ) ) ); 478 this, SLOT( setRgb(QRgb) ) );
479 479
480 hEd = new QColNumLineEdit( this ); 480 hEd = new QColNumLineEdit( this );
481 hEd->setValidator( val360 ); 481 hEd->setValidator( val360 );
482 QLabel *l = new QLabel( hEd, OColorDialog::tr("Hue:"), this ); 482 QLabel *l = new QLabel( hEd, OColorDialog::tr("Hue:"), this );
483 l->setAlignment( AlignRight|AlignVCenter ); 483 l->setAlignment( AlignRight|AlignVCenter );
484 gl->addWidget( l, 0, 1 ); 484 gl->addWidget( l, 0, 1 );
485 gl->addWidget( hEd, 0, 2 ); 485 gl->addWidget( hEd, 0, 2 );
486 486
487 sEd = new QColNumLineEdit( this ); 487 sEd = new QColNumLineEdit( this );
488 sEd->setValidator( val256 ); 488 sEd->setValidator( val256 );
489 l = new QLabel( sEd, OColorDialog::tr("Sat:"), this ); 489 l = new QLabel( sEd, OColorDialog::tr("Sat:"), this );
490 l->setAlignment( AlignRight|AlignVCenter ); 490 l->setAlignment( AlignRight|AlignVCenter );
491 gl->addWidget( l, 1, 1 ); 491 gl->addWidget( l, 1, 1 );
492 gl->addWidget( sEd, 1, 2 ); 492 gl->addWidget( sEd, 1, 2 );
493 493
494 vEd = new QColNumLineEdit( this ); 494 vEd = new QColNumLineEdit( this );
495 vEd->setValidator( val256 ); 495 vEd->setValidator( val256 );
496 l = new QLabel( vEd, OColorDialog::tr("Val:"), this ); 496 l = new QLabel( vEd, OColorDialog::tr("Val:"), this );
497 l->setAlignment( AlignRight|AlignVCenter ); 497 l->setAlignment( AlignRight|AlignVCenter );
498 gl->addWidget( l, 2, 1 ); 498 gl->addWidget( l, 2, 1 );
499 gl->addWidget( vEd, 2, 2 ); 499 gl->addWidget( vEd, 2, 2 );
500 500
501 rEd = new QColNumLineEdit( this ); 501 rEd = new QColNumLineEdit( this );
502 rEd->setValidator( val256 ); 502 rEd->setValidator( val256 );
503 l = new QLabel( rEd, OColorDialog::tr("Red:"), this ); 503 l = new QLabel( rEd, OColorDialog::tr("Red:"), this );
504 l->setAlignment( AlignRight|AlignVCenter ); 504 l->setAlignment( AlignRight|AlignVCenter );
505 gl->addWidget( l, 0, 3 ); 505 gl->addWidget( l, 0, 3 );
506 gl->addWidget( rEd, 0, 4 ); 506 gl->addWidget( rEd, 0, 4 );
507 507
508 gEd = new QColNumLineEdit( this ); 508 gEd = new QColNumLineEdit( this );
509 gEd->setValidator( val256 ); 509 gEd->setValidator( val256 );
510 l = new QLabel( gEd, OColorDialog::tr("Green:"), this ); 510 l = new QLabel( gEd, OColorDialog::tr("Green:"), this );
511 l->setAlignment( AlignRight|AlignVCenter ); 511 l->setAlignment( AlignRight|AlignVCenter );
512 gl->addWidget( l, 1, 3 ); 512 gl->addWidget( l, 1, 3 );
513 gl->addWidget( gEd, 1, 4 ); 513 gl->addWidget( gEd, 1, 4 );
514 514
515 bEd = new QColNumLineEdit( this ); 515 bEd = new QColNumLineEdit( this );
516 bEd->setValidator( val256 ); 516 bEd->setValidator( val256 );
517 l = new QLabel( bEd, OColorDialog::tr("Blue:"), this ); 517 l = new QLabel( bEd, OColorDialog::tr("Blue:"), this );
518 l->setAlignment( AlignRight|AlignVCenter ); 518 l->setAlignment( AlignRight|AlignVCenter );
519 gl->addWidget( l, 2, 3 ); 519 gl->addWidget( l, 2, 3 );
520 gl->addWidget( bEd, 2, 4 ); 520 gl->addWidget( bEd, 2, 4 );
521 521
522 alphaEd = new QColNumLineEdit( this ); 522 alphaEd = new QColNumLineEdit( this );
523 alphaEd->setValidator( val256 ); 523 alphaEd->setValidator( val256 );
524 alphaLab = new QLabel( alphaEd, OColorDialog::tr("Alpha channel:"), this ); 524 alphaLab = new QLabel( alphaEd, OColorDialog::tr("Alpha channel:"), this );
525 alphaLab->setAlignment( AlignRight|AlignVCenter ); 525 alphaLab->setAlignment( AlignRight|AlignVCenter );
526 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 ); 526 gl->addMultiCellWidget( alphaLab, 3, 3, 1, 3 );
527 gl->addWidget( alphaEd, 3, 4 ); 527 gl->addWidget( alphaEd, 3, 4 );
528 alphaEd->hide(); 528 alphaEd->hide();
529 alphaLab->hide(); 529 alphaLab->hide();
530 530
531 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 531 connect( hEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
532 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 532 connect( sEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
533 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) ); 533 connect( vEd, SIGNAL(textChanged(const QString&)), this, SLOT(hsvEd()) );
534 534
535 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 535 connect( rEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
536 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 536 connect( gEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
537 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) ); 537 connect( bEd, SIGNAL(textChanged(const QString&)), this, SLOT(rgbEd()) );
538} 538}
539 539
540void QColorShower::showCurrentColor() 540void QColorShower::showCurrentColor()
541{ 541{
542 lab->setColor( currentColor() ); 542 lab->setColor( currentColor() );
543 lab->repaint(FALSE); //### 543 lab->repaint(FALSE); //###
544} 544}
545 545
546void QColorShower::rgbEd() 546void QColorShower::rgbEd()
547{ 547{
548 rgbOriginal = TRUE; 548 rgbOriginal = TRUE;
549 curCol = qRgb( rEd->val(), gEd->val(), bEd->val() ); 549 curCol = qRgb( rEd->val(), gEd->val(), bEd->val() );
550 rgb2hsv(currentColor(), hue, sat, val ); 550 rgb2hsv(currentColor(), hue, sat, val );
551 551
552 hEd->setNum( hue ); 552 hEd->setNum( hue );
553 sEd->setNum( sat ); 553 sEd->setNum( sat );
554 vEd->setNum( val ); 554 vEd->setNum( val );
555 555
556 showCurrentColor(); 556 showCurrentColor();
557 emit newCol( currentColor() ); 557 emit newCol( currentColor() );
558} 558}
559 559
560void QColorShower::hsvEd() 560void QColorShower::hsvEd()
561{ 561{
562 rgbOriginal = FALSE; 562 rgbOriginal = FALSE;
563 hue = hEd->val(); 563 hue = hEd->val();
564 sat = sEd->val(); 564 sat = sEd->val();
565 val = vEd->val(); 565 val = vEd->val();
566 566
567 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); 567 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
568 568
569 rEd->setNum( qRed(currentColor()) ); 569 rEd->setNum( qRed(currentColor()) );
570 gEd->setNum( qGreen(currentColor()) ); 570 gEd->setNum( qGreen(currentColor()) );
571 bEd->setNum( qBlue(currentColor()) ); 571 bEd->setNum( qBlue(currentColor()) );
572 572
573 showCurrentColor(); 573 showCurrentColor();
574 emit newCol( currentColor() ); 574 emit newCol( currentColor() );
575} 575}
576 576
577void QColorShower::setRgb( QRgb rgb ) 577void QColorShower::setRgb( QRgb rgb )
578{ 578{
579 rgbOriginal = TRUE; 579 rgbOriginal = TRUE;
580 curCol = rgb; 580 curCol = rgb;
581 581
582 rgb2hsv( currentColor(), hue, sat, val ); 582 rgb2hsv( currentColor(), hue, sat, val );
583 583
584 hEd->setNum( hue ); 584 hEd->setNum( hue );
585 sEd->setNum( sat ); 585 sEd->setNum( sat );
586 vEd->setNum( val ); 586 vEd->setNum( val );
587 587
588 rEd->setNum( qRed(currentColor()) ); 588 rEd->setNum( qRed(currentColor()) );
589 gEd->setNum( qGreen(currentColor()) ); 589 gEd->setNum( qGreen(currentColor()) );
590 bEd->setNum( qBlue(currentColor()) ); 590 bEd->setNum( qBlue(currentColor()) );
591 591
592 showCurrentColor(); 592 showCurrentColor();
593} 593}
594 594
595void QColorShower::setHsv( int h, int s, int v ) 595void QColorShower::setHsv( int h, int s, int v )
596{ 596{
597 rgbOriginal = FALSE; 597 rgbOriginal = FALSE;
598 hue = h; val = v; sat = s; //Range check### 598 hue = h; val = v; sat = s; //Range check###
599 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb(); 599 curCol = QColor( hue, sat, val, QColor::Hsv ).rgb();
600 600
601 hEd->setNum( hue ); 601 hEd->setNum( hue );
602 sEd->setNum( sat ); 602 sEd->setNum( sat );
603 vEd->setNum( val ); 603 vEd->setNum( val );
604 604
605 rEd->setNum( qRed(currentColor()) ); 605 rEd->setNum( qRed(currentColor()) );
606 gEd->setNum( qGreen(currentColor()) ); 606 gEd->setNum( qGreen(currentColor()) );
607 bEd->setNum( qBlue(currentColor()) ); 607 bEd->setNum( qBlue(currentColor()) );
608 608
609 609
610 showCurrentColor(); 610 showCurrentColor();
611} 611}
612 612
613} 613}
614 614
615class OColorDialogPrivate : public QObject 615class OColorDialogPrivate : public QObject
616{ 616{
617Q_OBJECT 617Q_OBJECT
618public: 618public:
619 OColorDialogPrivate( OColorDialog *p ); 619 OColorDialogPrivate( OColorDialog *p );
620 QRgb currentColor() const { return cs->currentColor(); } 620 QRgb currentColor() const { return cs->currentColor(); }
621 void setCurrentColor( const QRgb& rgb ); 621 void setCurrentColor( const QRgb& rgb );
622 622
623 int currentAlpha() const { return cs->currentAlpha(); } 623 int currentAlpha() const { return cs->currentAlpha(); }
624 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); } 624 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
625 void showAlpha( bool b ) { cs->showAlpha( b ); } 625 void showAlpha( bool b ) { cs->showAlpha( b ); }
626 626
627private slots: 627private slots:
628 void newHsv( int h, int s, int v ); 628 void newHsv( int h, int s, int v );
629 void newColorTypedIn( QRgb rgb ); 629 void newColorTypedIn( QRgb rgb );
630private: 630private:
631 QColorPicker *cp; 631 QColorPicker *cp;
632 QColorLuminancePicker *lp; 632 QColorLuminancePicker *lp;
633 QColorShower *cs; 633 QColorShower *cs;
634}; 634};
635 635
636//sets all widgets to display h,s,v 636//sets all widgets to display h,s,v
637void OColorDialogPrivate::newHsv( int h, int s, int v ) 637void OColorDialogPrivate::newHsv( int h, int s, int v )
638{ 638{
639 cs->setHsv( h, s, v ); 639 cs->setHsv( h, s, v );
640 cp->setCol( h, s ); 640 cp->setCol( h, s );
641 lp->setCol( h, s, v ); 641 lp->setCol( h, s, v );
642} 642}
643 643
644//sets all widgets to display rgb 644//sets all widgets to display rgb
645void OColorDialogPrivate::setCurrentColor( const QRgb& rgb ) 645void OColorDialogPrivate::setCurrentColor( const QRgb& rgb )
646{ 646{
647 cs->setRgb( rgb ); 647 cs->setRgb( rgb );
648 newColorTypedIn( rgb ); 648 newColorTypedIn( rgb );
649} 649}
650 650
651//sets all widgets exept cs to display rgb 651//sets all widgets exept cs to display rgb
652void OColorDialogPrivate::newColorTypedIn( QRgb rgb ) 652void OColorDialogPrivate::newColorTypedIn( QRgb rgb )
653{ 653{
654 int h, s, v; 654 int h, s, v;
655 rgb2hsv(rgb, h, s, v ); 655 rgb2hsv(rgb, h, s, v );
656 cp->setCol( h, s ); 656 cp->setCol( h, s );
657 lp->setCol( h, s, v); 657 lp->setCol( h, s, v);
658} 658}
659 659
660OColorDialogPrivate::OColorDialogPrivate( OColorDialog *dialog ) : 660OColorDialogPrivate::OColorDialogPrivate( OColorDialog *dialog ) :
661 QObject(dialog) 661 QObject(dialog)
662{ 662{
663 int border = 2; 663 int border = 2;
664 QVBoxLayout *topLay = new QVBoxLayout( dialog, border, 2 ); 664 QVBoxLayout *topLay = new QVBoxLayout( dialog, border, 2 );
665 665
666 QHBoxLayout *pickLay = new QHBoxLayout( topLay ); 666 QHBoxLayout *pickLay = new QHBoxLayout( topLay );
667 667
668 668
669 cp = new QColorPicker( dialog ); 669 cp = new QColorPicker( dialog );
670 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken ); 670 cp->setFrameStyle( QFrame::Panel + QFrame::Sunken );
diff --git a/libopie/colorpopupmenu.cpp b/libopie/colorpopupmenu.cpp
index 0d66fba..03ad233 100644
--- a/libopie/colorpopupmenu.cpp
+++ b/libopie/colorpopupmenu.cpp
@@ -1,172 +1,172 @@
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 <qlayout.h> 36#include <qlayout.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name ) 39OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name )
40 : QFrame( parent, name ) 40 : QFrame( parent, name )
41{ 41{
42 m_color = color; 42 m_color = color;
43 43
44 setFixedSize( 16, 16 ); 44 setFixedSize( 16, 16 );
45 setActive( FALSE ); 45 setActive( FALSE );
46} 46}
47 47
48OColorPanelButton::~OColorPanelButton() 48OColorPanelButton::~OColorPanelButton()
49{ 49{
50} 50}
51 51
52void OColorPanelButton::setActive( bool active ) 52void OColorPanelButton::setActive( bool active )
53{ 53{
54 m_active = active; 54 m_active = active;
55 55
56 if ( m_active ) { 56 if ( m_active ) {
57 setFrameStyle( Panel | Sunken ); 57 setFrameStyle( Panel | Sunken );
58 } else { 58 } else {
59 setFrameStyle( NoFrame ); 59 setFrameStyle( NoFrame );
60 } 60 }
61} 61}
62 62
63void OColorPanelButton::enterEvent( QEvent* ) 63void OColorPanelButton::enterEvent( QEvent* )
64{ 64{
65 if ( !m_active ) { 65 if ( !m_active ) {
66 setFrameStyle( Panel | Sunken ); 66 setFrameStyle( Panel | Sunken );
67 } 67 }
68} 68}
69 69
70void OColorPanelButton::leaveEvent( QEvent* ) 70void OColorPanelButton::leaveEvent( QEvent* )
71{ 71{
72 if ( !m_active ) { 72 if ( !m_active ) {
73 setFrameStyle( NoFrame ); 73 setFrameStyle( NoFrame );
74 } 74 }
75} 75}
76 76
77void OColorPanelButton::paintEvent( QPaintEvent* e ) 77void OColorPanelButton::paintEvent( QPaintEvent* e )
78{ 78{
79 QFrame::paintEvent( e ); 79 QFrame::paintEvent( e );
80 80
81 QPainter painter; 81 QPainter painter;
82 painter.begin( this ); 82 painter.begin( this );
83 painter.fillRect( 2, 2, 12, 12, m_color ); 83 painter.fillRect( 2, 2, 12, 12, m_color );
84 painter.setPen( Qt::black ); 84 painter.setPen( Qt::black );
85 painter.drawRect( 2, 2, 12, 12 ); 85 painter.drawRect( 2, 2, 12, 12 );
86 painter.end(); 86 painter.end();
87} 87}
88 88
89void OColorPanelButton::mouseReleaseEvent( QMouseEvent* ) 89void OColorPanelButton::mouseReleaseEvent( QMouseEvent* )
90{ 90{
91 emit selected( m_color ); 91 emit selected( m_color );
92} 92}
93 93
94OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name ) 94OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name )
95 : QPopupMenu( parent, name ) 95 : QPopupMenu( parent, name )
96{ 96{
97 m_color = color; 97 m_color = color;
98 98
99 colorPanel = new QWidget( this ); 99 colorPanel = new QWidget( this );
100 100
101 colorLayout = new QGridLayout(colorPanel, 5, 6); 101 colorLayout = new QGridLayout(colorPanel, 5, 6);
102 102
103 addColor(QColor(255, 255, 255), 0, 1); 103 addColor(QColor(255, 255, 255), 0, 1);
104 addColor(QColor(192, 192, 192), 0, 2); 104 addColor(QColor(192, 192, 192), 0, 2);
105 addColor(QColor(128, 128, 128), 0, 3); 105 addColor(QColor(128, 128, 128), 0, 3);
106 addColor(QColor(64, 64, 64), 0, 4); 106 addColor(QColor(64, 64, 64), 0, 4);
107 addColor(QColor(0, 0, 0), 0, 5); 107 addColor(QColor(0, 0, 0), 0, 5);
108 108
109 addColor(QColor(255, 0, 0), 1, 0); 109 addColor(QColor(255, 0, 0), 1, 0);
110 addColor(QColor(255, 128, 0), 1, 1); 110 addColor(QColor(255, 128, 0), 1, 1);
111 addColor(QColor(255, 255, 0), 1, 2); 111 addColor(QColor(255, 255, 0), 1, 2);
112 addColor(QColor(128, 255, 0), 1, 3); 112 addColor(QColor(128, 255, 0), 1, 3);
113 addColor(QColor(0, 255, 0), 1, 4); 113 addColor(QColor(0, 255, 0), 1, 4);
114 addColor(QColor(0, 255, 128), 1, 5); 114 addColor(QColor(0, 255, 128), 1, 5);
115 115
116 addColor(QColor(128, 0, 0), 2, 0); 116 addColor(QColor(128, 0, 0), 2, 0);
117 addColor(QColor(128, 64, 0), 2, 1); 117 addColor(QColor(128, 64, 0), 2, 1);
118 addColor(QColor(128, 128, 0), 2, 2); 118 addColor(QColor(128, 128, 0), 2, 2);
119 addColor(QColor(64, 128, 0), 2, 3); 119 addColor(QColor(64, 128, 0), 2, 3);
120 addColor(QColor(0, 128, 0), 2, 4); 120 addColor(QColor(0, 128, 0), 2, 4);
121 addColor(QColor(0, 128, 64), 2, 5); 121 addColor(QColor(0, 128, 64), 2, 5);
122 122
123 addColor(QColor(0, 255, 255), 3, 0); 123 addColor(QColor(0, 255, 255), 3, 0);
124 addColor(QColor(0, 128, 255), 3, 1); 124 addColor(QColor(0, 128, 255), 3, 1);
125 addColor(QColor(0, 0, 255), 3, 2); 125 addColor(QColor(0, 0, 255), 3, 2);
126 addColor(QColor(128, 0, 255), 3, 3); 126 addColor(QColor(128, 0, 255), 3, 3);
127 addColor(QColor(255, 0, 255), 3, 4); 127 addColor(QColor(255, 0, 255), 3, 4);
128 addColor(QColor(255, 0, 128), 3, 5); 128 addColor(QColor(255, 0, 128), 3, 5);
129 129
130 addColor(QColor(0, 128, 128), 4, 0); 130 addColor(QColor(0, 128, 128), 4, 0);
131 addColor(QColor(0, 64, 128), 4, 1); 131 addColor(QColor(0, 64, 128), 4, 1);
132 addColor(QColor(0, 0, 128), 4, 2); 132 addColor(QColor(0, 0, 128), 4, 2);
133 addColor(QColor(64, 0, 128), 4, 3); 133 addColor(QColor(64, 0, 128), 4, 3);
134 addColor(QColor(128, 0, 128), 4, 4); 134 addColor(QColor(128, 0, 128), 4, 4);
135 addColor(QColor(128, 0, 64), 4, 5); 135 addColor(QColor(128, 0, 64), 4, 5);
136 136
137 insertItem( colorPanel ); 137 insertItem( colorPanel );
138 insertSeparator(); 138 insertSeparator();
139 insertItem(tr("More"),this,SLOT( moreColorClicked())); 139 insertItem(tr("More"),this,SLOT( moreColorClicked()));
140 /* 140 /*
141 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" ); 141 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" );
142 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) ); 142 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) );
143 chooseColorAction->addTo( this ); 143 chooseColorAction->addTo( this );
144 */ 144 */
145 activateItemAt( 0 ); 145 activateItemAt( 0 );
146} 146}
147 147
148OColorPopupMenu::~OColorPopupMenu() 148OColorPopupMenu::~OColorPopupMenu()
149{ 149{
150} 150}
151 151
152void OColorPopupMenu::addColor( const QColor& color, int row, int col ) 152void OColorPopupMenu::addColor( const QColor& color, int row, int col )
153{ 153{
154 OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel ); 154 OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel );
155 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) ); 155 connect( panelButton, SIGNAL( selected(const QColor&) ), this, SLOT( buttonSelected(const QColor&) ) );
156 colorLayout->addWidget( panelButton, row, col ); 156 colorLayout->addWidget( panelButton, row, col );
157} 157}
158 158
159void OColorPopupMenu::buttonSelected( const QColor& color ) 159void OColorPopupMenu::buttonSelected( const QColor& color )
160{ 160{
161 m_color = color; 161 m_color = color;
162 emit colorSelected( color ); 162 emit colorSelected( color );
163 hide(); 163 hide();
164} 164}
165 165
166void OColorPopupMenu::moreColorClicked() 166void OColorPopupMenu::moreColorClicked()
167{ 167{
168 QColor color = OColorDialog::getColor( m_color ); 168 QColor color = OColorDialog::getColor( m_color );
169 m_color = color; 169 m_color = color;
170 emit colorSelected( color ); 170 emit colorSelected( color );
171 hide(); 171 hide();
172} 172}
diff --git a/libopie/ocolorbutton.cpp b/libopie/ocolorbutton.cpp
index 93fe5d0..298dba2 100644
--- a/libopie/ocolorbutton.cpp
+++ b/libopie/ocolorbutton.cpp
@@ -1,139 +1,139 @@
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 31
32#include <qpe/resource.h> 32#include <qpe/resource.h>
33 33
34struct OColorButtonPrivate { 34struct OColorButtonPrivate {
35 QPopupMenu *m_menu; 35 QPopupMenu *m_menu;
36 QColor m_color; 36 QColor m_color;
37}; 37};
38 38
39 39
40/** 40/**
41 * This concstructs a Color Button with @param color as the start color 41 * This concstructs a Color Button with @param color as the start color
42 * It'll use a OColorPopupMenu internally 42 * It'll use a OColorPopupMenu internally
43 * 43 *
44 * @param parent The parent of the Color Button 44 * @param parent The parent of the Color Button
45 * @param color The color from where to start on 45 * @param color The color from where to start on
46 * @param name @see QObject 46 * @param name @see QObject
47 */ 47 */
48OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name ) 48OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name )
49 : QPushButton ( parent, name ) 49 : QPushButton ( parent, name )
50{ 50{
51 d = new OColorButtonPrivate; 51 d = new OColorButtonPrivate;
52 52
53 d-> m_menu = new OColorPopupMenu ( color, 0, 0 ); 53 d-> m_menu = new OColorPopupMenu ( color, 0, 0 );
54 setPopup ( d-> m_menu ); 54 setPopup ( d-> m_menu );
55 //setPopupDelay ( 0 ); 55 //setPopupDelay ( 0 );
56 connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & ))); 56 connect ( d-> m_menu, SIGNAL( colorSelected(const QColor&)), this, SLOT( updateColor(const QColor&)));
57 57
58 updateColor ( color ); 58 updateColor ( color );
59 59
60 QSize s = sizeHint ( ) + QSize ( 12, 0 ); 60 QSize s = sizeHint ( ) + QSize ( 12, 0 );
61 setMinimumSize ( s ); 61 setMinimumSize ( s );
62 setMaximumSize ( s. width ( ) * 2, s. height ( )); 62 setMaximumSize ( s. width ( ) * 2, s. height ( ));
63} 63}
64 64
65/** 65/**
66 * This destructs the object 66 * This destructs the object
67 */ 67 */
68OColorButton::~OColorButton ( ) 68OColorButton::~OColorButton ( )
69{ 69{
70 delete d; 70 delete d;
71} 71}
72 72
73/** 73/**
74 * @return Returns the current color of the button 74 * @return Returns the current color of the button
75 */ 75 */
76QColor OColorButton::color ( ) const 76QColor OColorButton::color ( ) const
77{ 77{
78 return d-> m_color; 78 return d-> m_color;
79} 79}
80 80
81/** 81/**
82 * This method sets the color of the button 82 * This method sets the color of the button
83 * @param c The color to be set. 83 * @param c The color to be set.
84 */ 84 */
85void OColorButton::setColor ( const QColor &c ) 85void OColorButton::setColor ( const QColor &c )
86{ 86{
87 updateColor ( c ); 87 updateColor ( c );
88} 88}
89 89
90/** 90/**
91 * @internal 91 * @internal
92 */ 92 */
93void OColorButton::updateColor ( const QColor &c ) 93void OColorButton::updateColor ( const QColor &c )
94{ 94{
95 d-> m_color = c; 95 d-> m_color = c;
96 96
97 QImage img ( 16, 16, 32 ); 97 QImage img ( 16, 16, 32 );
98 img. fill ( 0 ); 98 img. fill ( 0 );
99 99
100 int r, g, b; 100 int r, g, b;
101 c. rgb ( &r, &g, &b ); 101 c. rgb ( &r, &g, &b );
102 102
103 int w = img. width ( ); 103 int w = img. width ( );
104 int h = img. height ( ); 104 int h = img. height ( );
105 105
106 int dx = w * 20 / 100; // 15% 106 int dx = w * 20 / 100; // 15%
107 int dy = h * 20 / 100; 107 int dy = h * 20 / 100;
108 108
109 for ( int y = 0; y < h; y++ ) { 109 for ( int y = 0; y < h; y++ ) {
110 for ( int x = 0; x < w; x++ ) { 110 for ( int x = 0; x < w; x++ ) {
111 double alpha = 1.0; 111 double alpha = 1.0;
112 112
113 if ( x < dx ) 113 if ( x < dx )
114 alpha *= ( double ( x + 1 ) / dx ); 114 alpha *= ( double ( x + 1 ) / dx );
115 else if ( x >= w - dx ) 115 else if ( x >= w - dx )
116 alpha *= ( double ( w - x ) / dx ); 116 alpha *= ( double ( w - x ) / dx );
117 if ( y < dy ) 117 if ( y < dy )
118 alpha *= ( double ( y + 1 ) / dy ); 118 alpha *= ( double ( y + 1 ) / dy );
119 else if ( y >= h - dy ) 119 else if ( y >= h - dy )
120 alpha *= ( double ( h - y ) / dy ); 120 alpha *= ( double ( h - y ) / dy );
121 121
122 int a = int ( alpha * 255.0 ); 122 int a = int ( alpha * 255.0 );
123 if ( a < 0 ) 123 if ( a < 0 )
124 a = 0; 124 a = 0;
125 if ( a > 255 ) 125 if ( a > 255 )
126 a = 255; 126 a = 255;
127 127
128 img. setPixel ( x, y, qRgba ( r, g, b, a )); 128 img. setPixel ( x, y, qRgba ( r, g, b, a ));
129 } 129 }
130 } 130 }
131 img. setAlphaBuffer ( true ); 131 img. setAlphaBuffer ( true );
132 132
133 QPixmap pix; 133 QPixmap pix;
134 pix. convertFromImage ( img ); 134 pix. convertFromImage ( img );
135 setPixmap ( pix ); 135 setPixmap ( pix );
136 136
137 emit colorSelected ( c ); 137 emit colorSelected ( c );
138} 138}
139 139
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c0b6efa..4258d60 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -343,385 +343,385 @@ struct s_button {
343 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 343 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
344 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 344 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
345 "devicebuttons/simpad_upper_down", 345 "devicebuttons/simpad_upper_down",
346 "addressbook", "raise()", 346 "addressbook", "raise()",
347 "addressbook", "beamBusinessCard()" }, 347 "addressbook", "beamBusinessCard()" },
348 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 348 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
349 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 349 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
350 "devicebuttons/simpad_upper_right", 350 "devicebuttons/simpad_upper_right",
351 "QPE/TaskBar", "toggleMenu()", 351 "QPE/TaskBar", "toggleMenu()",
352 "QPE/TaskBar", "toggleStartMenu()" }, 352 "QPE/TaskBar", "toggleStartMenu()" },
353 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 353 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
354 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 354 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
355 "devicebuttons/simpad_upper_left", 355 "devicebuttons/simpad_upper_left",
356 "QPE/Rotation", "flip()", 356 "QPE/Rotation", "flip()",
357 "QPE/Rotation", "flip()" }, 357 "QPE/Rotation", "flip()" },
358 /* 358 /*
359 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 359 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
360 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 360 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
361 "devicebuttons/simpad_lower_upper", 361 "devicebuttons/simpad_lower_upper",
362 "QPE/Launcher", "home()", 362 "QPE/Launcher", "home()",
363 "buttonsettings", "raise()" }, 363 "buttonsettings", "raise()" },
364 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 364 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
365 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 365 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
366 "devicebuttons/simpad_upper_lower", 366 "devicebuttons/simpad_upper_lower",
367 "QPE/Launcher", "home()", 367 "QPE/Launcher", "home()",
368 "buttonsettings", "raise()" }, 368 "buttonsettings", "raise()" },
369 */ 369 */
370}; 370};
371 371
372struct r_button { 372struct r_button {
373 uint model; 373 uint model;
374 Qt::Key code; 374 Qt::Key code;
375 char *utext; 375 char *utext;
376 char *pix; 376 char *pix;
377 char *fpressedservice; 377 char *fpressedservice;
378 char *fpressedaction; 378 char *fpressedaction;
379 char *fheldservice; 379 char *fheldservice;
380 char *fheldaction; 380 char *fheldaction;
381} ramses_buttons [] = { 381} ramses_buttons [] = {
382 { Model_Ramses_MNCI, 382 { Model_Ramses_MNCI,
383 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 383 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
384 "devicebuttons/z_menu", 384 "devicebuttons/z_menu",
385 "QPE/TaskBar", "toggleMenu()", 385 "QPE/TaskBar", "toggleMenu()",
386 "QPE/TaskBar", "toggleStartMenu()" }, 386 "QPE/TaskBar", "toggleStartMenu()" },
387 { Model_Ramses_MNCI, 387 { Model_Ramses_MNCI,
388 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 388 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
389 "devicebuttons/ipaq_home", 389 "devicebuttons/ipaq_home",
390 "QPE/Launcher", "home()", 390 "QPE/Launcher", "home()",
391 "buttonsettings", "raise()" }, 391 "buttonsettings", "raise()" },
392}; 392};
393 393
394class Yopy : public ODevice { 394class Yopy : public ODevice {
395protected: 395protected:
396 virtual void init ( ); 396 virtual void init ( );
397 virtual void initButtons ( ); 397 virtual void initButtons ( );
398 398
399public: 399public:
400 virtual bool suspend ( ); 400 virtual bool suspend ( );
401 401
402 virtual bool setDisplayBrightness ( int b ); 402 virtual bool setDisplayBrightness ( int b );
403 virtual int displayBrightnessResolution ( ) const; 403 virtual int displayBrightnessResolution ( ) const;
404 404
405 static bool isYopy ( ); 405 static bool isYopy ( );
406}; 406};
407 407
408struct yopy_button { 408struct yopy_button {
409 Qt::Key code; 409 Qt::Key code;
410 char *utext; 410 char *utext;
411 char *pix; 411 char *pix;
412 char *fpressedservice; 412 char *fpressedservice;
413 char *fpressedaction; 413 char *fpressedaction;
414 char *fheldservice; 414 char *fheldservice;
415 char *fheldaction; 415 char *fheldaction;
416} yopy_buttons [] = { 416} yopy_buttons [] = {
417 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), 417 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
418 "devicebuttons/yopy_action", 418 "devicebuttons/yopy_action",
419 "datebook", "nextView()", 419 "datebook", "nextView()",
420 "today", "raise()" }, 420 "today", "raise()" },
421 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), 421 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
422 "devicebuttons/yopy_ok", 422 "devicebuttons/yopy_ok",
423 "addressbook", "raise()", 423 "addressbook", "raise()",
424 "addressbook", "beamBusinessCard()" }, 424 "addressbook", "beamBusinessCard()" },
425 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), 425 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
426 "devicebuttons/yopy_end", 426 "devicebuttons/yopy_end",
427 "QPE/Launcher", "home()", 427 "QPE/Launcher", "home()",
428 "buttonsettings", "raise()" }, 428 "buttonsettings", "raise()" },
429}; 429};
430 430
431static QCString makeChannel ( const char *str ) 431static QCString makeChannel ( const char *str )
432{ 432{
433 if ( str && !::strchr ( str, '/' )) 433 if ( str && !::strchr ( str, '/' ))
434 return QCString ( "QPE/Application/" ) + str; 434 return QCString ( "QPE/Application/" ) + str;
435 else 435 else
436 return str; 436 return str;
437} 437}
438 438
439static inline bool isQWS() 439static inline bool isQWS()
440{ 440{
441 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 441 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
442} 442}
443 443
444ODevice *ODevice::inst ( ) 444ODevice *ODevice::inst ( )
445{ 445{
446 static ODevice *dev = 0; 446 static ODevice *dev = 0;
447 447
448 if ( !dev ) { 448 if ( !dev ) {
449 if ( QFile::exists ( "/proc/hal/model" )) 449 if ( QFile::exists ( "/proc/hal/model" ))
450 dev = new iPAQ ( ); 450 dev = new iPAQ ( );
451 else if ( Zaurus::isZaurus() ) 451 else if ( Zaurus::isZaurus() )
452 dev = new Zaurus ( ); 452 dev = new Zaurus ( );
453 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 453 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
454 dev = new SIMpad ( ); 454 dev = new SIMpad ( );
455 else if ( QFile::exists ( "/proc/sys/board/name" )) 455 else if ( QFile::exists ( "/proc/sys/board/name" ))
456 dev = new Ramses ( ); 456 dev = new Ramses ( );
457 else if ( Yopy::isYopy() ) 457 else if ( Yopy::isYopy() )
458 dev = new Yopy ( ); 458 dev = new Yopy ( );
459 else if ( Jornada::isJornada() ) 459 else if ( Jornada::isJornada() )
460 dev = new Jornada ( ); 460 dev = new Jornada ( );
461 else 461 else
462 dev = new ODevice ( ); 462 dev = new ODevice ( );
463 dev-> init ( ); 463 dev-> init ( );
464 } 464 }
465 return dev; 465 return dev;
466} 466}
467 467
468 468
469/************************************************** 469/**************************************************
470 * 470 *
471 * common 471 * common
472 * 472 *
473 **************************************************/ 473 **************************************************/
474 474
475 475
476ODevice::ODevice ( ) 476ODevice::ODevice ( )
477{ 477{
478 d = new ODeviceData; 478 d = new ODeviceData;
479 479
480 d-> m_modelstr = "Unknown"; 480 d-> m_modelstr = "Unknown";
481 d-> m_model = Model_Unknown; 481 d-> m_model = Model_Unknown;
482 d-> m_vendorstr = "Unknown"; 482 d-> m_vendorstr = "Unknown";
483 d-> m_vendor = Vendor_Unknown; 483 d-> m_vendor = Vendor_Unknown;
484 d-> m_systemstr = "Unknown"; 484 d-> m_systemstr = "Unknown";
485 d-> m_system = System_Unknown; 485 d-> m_system = System_Unknown;
486 d-> m_sysverstr = "0.0"; 486 d-> m_sysverstr = "0.0";
487 d-> m_rotation = Rot0; 487 d-> m_rotation = Rot0;
488 d-> m_direction = CW; 488 d-> m_direction = CW;
489 489
490 d-> m_holdtime = 1000; // 1000ms 490 d-> m_holdtime = 1000; // 1000ms
491 d-> m_buttons = 0; 491 d-> m_buttons = 0;
492 d-> m_cpu_frequencies = new QStrList; 492 d-> m_cpu_frequencies = new QStrList;
493} 493}
494 494
495void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 495void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
496{ 496{
497 if ( msg == "deviceButtonMappingChanged()" ) { 497 if ( msg == "deviceButtonMappingChanged()" ) {
498 reloadButtonMapping ( ); 498 reloadButtonMapping ( );
499 } 499 }
500} 500}
501 501
502void ODevice::init ( ) 502void ODevice::init ( )
503{ 503{
504} 504}
505 505
506/** 506/**
507 * This method initialises the button mapping 507 * This method initialises the button mapping
508 */ 508 */
509void ODevice::initButtons ( ) 509void ODevice::initButtons ( )
510{ 510{
511 if ( d-> m_buttons ) 511 if ( d-> m_buttons )
512 return; 512 return;
513 513
514 // Simulation uses iPAQ 3660 device buttons 514 // Simulation uses iPAQ 3660 device buttons
515 515
516 qDebug ( "init Buttons" ); 516 qDebug ( "init Buttons" );
517 d-> m_buttons = new QValueList <ODeviceButton>; 517 d-> m_buttons = new QValueList <ODeviceButton>;
518 518
519 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 519 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
520 i_button *ib = ipaq_buttons + i; 520 i_button *ib = ipaq_buttons + i;
521 ODeviceButton b; 521 ODeviceButton b;
522 522
523 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 523 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
524 b. setKeycode ( ib-> code ); 524 b. setKeycode ( ib-> code );
525 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 525 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
526 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 526 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
527 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 527 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
528 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 528 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
529 d-> m_buttons-> append ( b ); 529 d-> m_buttons-> append ( b );
530 } 530 }
531 } 531 }
532 reloadButtonMapping ( ); 532 reloadButtonMapping ( );
533 533
534 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 534 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
535 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 535 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
536} 536}
537 537
538ODevice::~ODevice ( ) 538ODevice::~ODevice ( )
539{ 539{
540// we leak m_devicebuttons and m_cpu_frequency 540// we leak m_devicebuttons and m_cpu_frequency
541// but it's a singleton and it is not so importantant 541// but it's a singleton and it is not so importantant
542// -zecke 542// -zecke
543 delete d; 543 delete d;
544} 544}
545 545
546bool ODevice::setSoftSuspend ( bool /*soft*/ ) 546bool ODevice::setSoftSuspend ( bool /*soft*/ )
547{ 547{
548 return false; 548 return false;
549} 549}
550 550
551//#include <linux/apm_bios.h> 551//#include <linux/apm_bios.h>
552 552
553#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 553#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
554 554
555/** 555/**
556 * This method will try to suspend the device 556 * This method will try to suspend the device
557 * It only works if the user is the QWS Server and the apm application 557 * It only works if the user is the QWS Server and the apm application
558 * is installed. 558 * is installed.
559 * It tries to suspend and then waits some time cause some distributions 559 * It tries to suspend and then waits some time cause some distributions
560 * do have asynchronus apm implementations. 560 * do have asynchronus apm implementations.
561 * This method will either fail and return false or it'll suspend the 561 * This method will either fail and return false or it'll suspend the
562 * device and return once the device got woken up 562 * device and return once the device got woken up
563 * 563 *
564 * @return if the device got suspended 564 * @return if the device got suspended
565 */ 565 */
566bool ODevice::suspend ( ) 566bool ODevice::suspend ( )
567{ 567{
568 qDebug("ODevice::suspend"); 568 qDebug("ODevice::suspend");
569 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 569 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
570 return false; 570 return false;
571 571
572 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 572 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
573 return false; 573 return false;
574 574
575 bool res = false; 575 bool res = false;
576 576
577 struct timeval tvs, tvn; 577 struct timeval tvs, tvn;
578 ::gettimeofday ( &tvs, 0 ); 578 ::gettimeofday ( &tvs, 0 );
579 579
580 ::sync ( ); // flush fs caches 580 ::sync ( ); // flush fs caches
581 res = ( ::system ( "apm --suspend" ) == 0 ); 581 res = ( ::system ( "apm --suspend" ) == 0 );
582 582
583 // This is needed because the iPAQ apm implementation is asynchronous and we 583 // This is needed because the iPAQ apm implementation is asynchronous and we
584 // can not be sure when exactly the device is really suspended 584 // can not be sure when exactly the device is really suspended
585 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 585 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
586 586
587 if ( res ) { 587 if ( res ) {
588 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 588 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
589 ::usleep ( 200 * 1000 ); 589 ::usleep ( 200 * 1000 );
590 ::gettimeofday ( &tvn, 0 ); 590 ::gettimeofday ( &tvn, 0 );
591 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 591 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
592 } 592 }
593 593
594 return res; 594 return res;
595} 595}
596 596
597//#include <linux/fb.h> better not rely on kernel headers in userspace ... 597//#include <linux/fb.h> better not rely on kernel headers in userspace ...
598 598
599#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 599#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
600 600
601/* VESA Blanking Levels */ 601/* VESA Blanking Levels */
602#define VESA_NO_BLANKING 0 602#define VESA_NO_BLANKING 0
603#define VESA_VSYNC_SUSPEND 1 603#define VESA_VSYNC_SUSPEND 1
604#define VESA_HSYNC_SUSPEND 2 604#define VESA_HSYNC_SUSPEND 2
605#define VESA_POWERDOWN 3 605#define VESA_POWERDOWN 3
606 606
607/** 607/**
608 * This sets the display on or off 608 * This sets the display on or off
609 */ 609 */
610bool ODevice::setDisplayStatus ( bool on ) 610bool ODevice::setDisplayStatus ( bool on )
611{ 611{
612 qDebug("ODevice::setDisplayStatus(%d)", on); 612 qDebug("ODevice::setDisplayStatus(%d)", on);
613 613
614 if ( d-> m_model == Model_Unknown ) 614 if ( d-> m_model == Model_Unknown )
615 return false; 615 return false;
616 616
617 bool res = false; 617 bool res = false;
618 int fd; 618 int fd;
619 619
620 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 620 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
621 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 621 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
622 ::close ( fd ); 622 ::close ( fd );
623 } 623 }
624 return res; 624 return res;
625} 625}
626 626
627/** 627/**
628 * This sets the display brightness 628 * This sets the display brightness
629 * 629 *
630 * @param p The brightness to be set on a scale from 0 to 255 630 * @param p The brightness to be set on a scale from 0 to 255
631 * @return success or failure 631 * @return success or failure
632 */ 632 */
633bool ODevice::setDisplayBrightness ( int p) 633bool ODevice::setDisplayBrightness ( int p)
634{ 634{
635 Q_UNUSED( p ) 635 Q_UNUSED( p )
636 return false; 636 return false;
637} 637}
638 638
639/** 639/**
640 * @return returns the number of steppings on the brightness slider 640 * @return returns the number of steppings on the brightness slider
641 * in the Light-'n-Power settings. 641 * in the Light-'n-Power settings.
642 */ 642 */
643int ODevice::displayBrightnessResolution ( ) const 643int ODevice::displayBrightnessResolution ( ) const
644{ 644{
645 return 16; 645 return 16;
646} 646}
647 647
648/** 648/**
649 * This sets the display contrast 649 * This sets the display contrast
650 * @param p The contrast to be set on a scale from 0 to 255 650 * @param p The contrast to be set on a scale from 0 to 255
651 * @return success or failure 651 * @return success or failure
652 */ 652 */
653bool ODevice::setDisplayContrast ( int p) 653bool ODevice::setDisplayContrast ( int p)
654{ 654{
655 Q_UNUSED( p ) 655 Q_UNUSED( p )
656 return false; 656 return false;
657} 657}
658 658
659/** 659/**
660 * @return return the max value for the brightness settings slider 660 * @return return the max value for the brightness settings slider
661 * or 0 if the device doesn't support setting of a contrast 661 * or 0 if the device doesn't support setting of a contrast
662 */ 662 */
663int ODevice::displayContrastResolution ( ) const 663int ODevice::displayContrastResolution ( ) const
664{ 664{
665 return 0; 665 return 0;
666} 666}
667 667
668/** 668/**
669 * This returns the vendor as string 669 * This returns the vendor as string
670 * @return Vendor as QString 670 * @return Vendor as QString
671 */ 671 */
672QString ODevice::vendorString ( ) const 672QString ODevice::vendorString ( ) const
673{ 673{
674 return d-> m_vendorstr; 674 return d-> m_vendorstr;
675} 675}
676 676
677/** 677/**
678 * This returns the vendor as one of the values of OVendor 678 * This returns the vendor as one of the values of OVendor
679 * @return OVendor 679 * @return OVendor
680 */ 680 */
681OVendor ODevice::vendor ( ) const 681OVendor ODevice::vendor ( ) const
682{ 682{
683 return d-> m_vendor; 683 return d-> m_vendor;
684} 684}
685 685
686/** 686/**
687 * This returns the model as a string 687 * This returns the model as a string
688 * @return A string representing the model 688 * @return A string representing the model
689 */ 689 */
690QString ODevice::modelString ( ) const 690QString ODevice::modelString ( ) const
691{ 691{
692 return d-> m_modelstr; 692 return d-> m_modelstr;
693} 693}
694 694
695/** 695/**
696 * This does return the OModel used 696 * This does return the OModel used
697 */ 697 */
698OModel ODevice::model ( ) const 698OModel ODevice::model ( ) const
699{ 699{
700 return d-> m_model; 700 return d-> m_model;
701} 701}
702 702
703/** 703/**
704 * This does return the systen name 704 * This does return the systen name
705 */ 705 */
706QString ODevice::systemString ( ) const 706QString ODevice::systemString ( ) const
707{ 707{
708 return d-> m_systemstr; 708 return d-> m_systemstr;
709} 709}
710 710
711/** 711/**
712 * Return System as OSystem value 712 * Return System as OSystem value
713 */ 713 */
714OSystem ODevice::system ( ) const 714OSystem ODevice::system ( ) const
715{ 715{
716 return d-> m_system; 716 return d-> m_system;
717} 717}
718 718
719/** 719/**
720 * @return the version string of the base system 720 * @return the version string of the base system
721 */ 721 */
722QString ODevice::systemVersionString ( ) const 722QString ODevice::systemVersionString ( ) const
723{ 723{
724 return d-> m_sysverstr; 724 return d-> m_sysverstr;
725} 725}
726 726
727/** 727/**
@@ -923,534 +923,534 @@ uint ODevice::buttonHoldTime ( ) const
923 return d-> m_holdtime; 923 return d-> m_holdtime;
924} 924}
925 925
926/** 926/**
927 * This method return a ODeviceButton for a key code 927 * This method return a ODeviceButton for a key code
928 * or 0 if no special hardware button is available for the device 928 * or 0 if no special hardware button is available for the device
929 * 929 *
930 * @return The devicebutton or 0l 930 * @return The devicebutton or 0l
931 * @see ODeviceButton 931 * @see ODeviceButton
932 */ 932 */
933const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 933const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
934{ 934{
935 initButtons ( ); 935 initButtons ( );
936 936
937 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 937 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
938 if ( (*it). keycode ( ) == code ) 938 if ( (*it). keycode ( ) == code )
939 return &(*it); 939 return &(*it);
940 } 940 }
941 return 0; 941 return 0;
942} 942}
943 943
944void ODevice::reloadButtonMapping ( ) 944void ODevice::reloadButtonMapping ( )
945{ 945{
946 initButtons ( ); 946 initButtons ( );
947 947
948 Config cfg ( "ButtonSettings" ); 948 Config cfg ( "ButtonSettings" );
949 949
950 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 950 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
951 ODeviceButton &b = ( *d-> m_buttons ) [i]; 951 ODeviceButton &b = ( *d-> m_buttons ) [i];
952 QString group = "Button" + QString::number ( i ); 952 QString group = "Button" + QString::number ( i );
953 953
954 QCString pch, hch; 954 QCString pch, hch;
955 QCString pm, hm; 955 QCString pm, hm;
956 QByteArray pdata, hdata; 956 QByteArray pdata, hdata;
957 957
958 if ( cfg. hasGroup ( group )) { 958 if ( cfg. hasGroup ( group )) {
959 cfg. setGroup ( group ); 959 cfg. setGroup ( group );
960 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 960 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
961 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 961 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
962 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 962 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
963 963
964 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 964 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
965 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 965 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
966 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 966 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
967 } 967 }
968 968
969 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 969 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
970 970
971 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 971 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
972 } 972 }
973} 973}
974 974
975void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 975void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
976{ 976{
977 initButtons ( ); 977 initButtons ( );
978 978
979 QString mb_chan; 979 QString mb_chan;
980 980
981 if ( button >= (int) d-> m_buttons-> count ( )) 981 if ( button >= (int) d-> m_buttons-> count ( ))
982 return; 982 return;
983 983
984 ODeviceButton &b = ( *d-> m_buttons ) [button]; 984 ODeviceButton &b = ( *d-> m_buttons ) [button];
985 b. setPressedAction ( action ); 985 b. setPressedAction ( action );
986 986
987 mb_chan=b. pressedAction ( ). channel ( ); 987 mb_chan=b. pressedAction ( ). channel ( );
988 988
989 Config buttonFile ( "ButtonSettings" ); 989 Config buttonFile ( "ButtonSettings" );
990 buttonFile. setGroup ( "Button" + QString::number ( button )); 990 buttonFile. setGroup ( "Button" + QString::number ( button ));
991 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 991 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
992 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 992 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
993 993
994 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 994 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
995 995
996 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 996 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
997} 997}
998 998
999void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 999void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
1000{ 1000{
1001 initButtons ( ); 1001 initButtons ( );
1002 1002
1003 if ( button >= (int) d-> m_buttons-> count ( )) 1003 if ( button >= (int) d-> m_buttons-> count ( ))
1004 return; 1004 return;
1005 1005
1006 ODeviceButton &b = ( *d-> m_buttons ) [button]; 1006 ODeviceButton &b = ( *d-> m_buttons ) [button];
1007 b. setHeldAction ( action ); 1007 b. setHeldAction ( action );
1008 1008
1009 Config buttonFile ( "ButtonSettings" ); 1009 Config buttonFile ( "ButtonSettings" );
1010 buttonFile. setGroup ( "Button" + QString::number ( button )); 1010 buttonFile. setGroup ( "Button" + QString::number ( button ));
1011 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 1011 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
1012 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 1012 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
1013 1013
1014 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 1014 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
1015 1015
1016 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 1016 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
1017} 1017}
1018void ODevice::virtual_hook(int id, void* data){ 1018void ODevice::virtual_hook(int id, void* data){
1019 switch( id ) { 1019 switch( id ) {
1020 case VIRTUAL_ROTATION:{ 1020 case VIRTUAL_ROTATION:{
1021 VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); 1021 VirtRotation* rot = reinterpret_cast<VirtRotation*>( data );
1022 rot->trans = d->m_rotation; 1022 rot->trans = d->m_rotation;
1023 break; 1023 break;
1024 } 1024 }
1025 case VIRTUAL_DIRECTION:{ 1025 case VIRTUAL_DIRECTION:{
1026 VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); 1026 VirtDirection *dir = reinterpret_cast<VirtDirection*>( data );
1027 dir->direct = d->m_direction; 1027 dir->direct = d->m_direction;
1028 break; 1028 break;
1029 } 1029 }
1030 case VIRTUAL_HAS_HINGE:{ 1030 case VIRTUAL_HAS_HINGE:{
1031 VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); 1031 VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data );
1032 hin->hasHinge = false; 1032 hin->hasHinge = false;
1033 break; 1033 break;
1034 } 1034 }
1035 case VIRTUAL_HINGE:{ 1035 case VIRTUAL_HINGE:{
1036 VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); 1036 VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data );
1037 hin->hingeStat = CASE_UNKNOWN; 1037 hin->hingeStat = CASE_UNKNOWN;
1038 break; 1038 break;
1039 } 1039 }
1040 } 1040 }
1041} 1041}
1042 1042
1043/************************************************** 1043/**************************************************
1044 * 1044 *
1045 * Yopy 3500/3700 1045 * Yopy 3500/3700
1046 * 1046 *
1047 **************************************************/ 1047 **************************************************/
1048 1048
1049bool Yopy::isYopy ( ) 1049bool Yopy::isYopy ( )
1050{ 1050{
1051 QFile f( "/proc/cpuinfo" ); 1051 QFile f( "/proc/cpuinfo" );
1052 if ( f. open ( IO_ReadOnly ) ) { 1052 if ( f. open ( IO_ReadOnly ) ) {
1053 QTextStream ts ( &f ); 1053 QTextStream ts ( &f );
1054 QString line; 1054 QString line;
1055 while( line = ts. readLine ( ) ) { 1055 while( line = ts. readLine ( ) ) {
1056 if ( line. left ( 8 ) == "Hardware" ) { 1056 if ( line. left ( 8 ) == "Hardware" ) {
1057 int loc = line. find ( ":" ); 1057 int loc = line. find ( ":" );
1058 if ( loc != -1 ) { 1058 if ( loc != -1 ) {
1059 QString model = 1059 QString model =
1060 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1060 line. mid ( loc + 2 ). simplifyWhiteSpace( );
1061 return ( model == "Yopy" ); 1061 return ( model == "Yopy" );
1062 } 1062 }
1063 } 1063 }
1064 } 1064 }
1065 } 1065 }
1066 return false; 1066 return false;
1067} 1067}
1068 1068
1069void Yopy::init ( ) 1069void Yopy::init ( )
1070{ 1070{
1071 d-> m_vendorstr = "G.Mate"; 1071 d-> m_vendorstr = "G.Mate";
1072 d-> m_vendor = Vendor_GMate; 1072 d-> m_vendor = Vendor_GMate;
1073 d-> m_modelstr = "Yopy3700"; 1073 d-> m_modelstr = "Yopy3700";
1074 d-> m_model = Model_Yopy_3700; 1074 d-> m_model = Model_Yopy_3700;
1075 d-> m_rotation = Rot0; 1075 d-> m_rotation = Rot0;
1076 1076
1077 d-> m_systemstr = "Linupy"; 1077 d-> m_systemstr = "Linupy";
1078 d-> m_system = System_Linupy; 1078 d-> m_system = System_Linupy;
1079 1079
1080 QFile f ( "/etc/issue" ); 1080 QFile f ( "/etc/issue" );
1081 if ( f. open ( IO_ReadOnly )) { 1081 if ( f. open ( IO_ReadOnly )) {
1082 QTextStream ts ( &f ); 1082 QTextStream ts ( &f );
1083 ts.readLine(); 1083 ts.readLine();
1084 d-> m_sysverstr = ts. readLine ( ); 1084 d-> m_sysverstr = ts. readLine ( );
1085 f. close ( ); 1085 f. close ( );
1086 } 1086 }
1087} 1087}
1088 1088
1089void Yopy::initButtons ( ) 1089void Yopy::initButtons ( )
1090{ 1090{
1091 if ( d-> m_buttons ) 1091 if ( d-> m_buttons )
1092 return; 1092 return;
1093 1093
1094 d-> m_buttons = new QValueList <ODeviceButton>; 1094 d-> m_buttons = new QValueList <ODeviceButton>;
1095 1095
1096 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1096 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1097 1097
1098 yopy_button *ib = yopy_buttons + i; 1098 yopy_button *ib = yopy_buttons + i;
1099 1099
1100 ODeviceButton b; 1100 ODeviceButton b;
1101 1101
1102 b. setKeycode ( ib-> code ); 1102 b. setKeycode ( ib-> code );
1103 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1103 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1104 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1104 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1105 b. setFactoryPresetPressedAction 1105 b. setFactoryPresetPressedAction
1106 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1106 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1107 b. setFactoryPresetHeldAction 1107 b. setFactoryPresetHeldAction
1108 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1108 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1109 1109
1110 d-> m_buttons-> append ( b ); 1110 d-> m_buttons-> append ( b );
1111 } 1111 }
1112 reloadButtonMapping ( ); 1112 reloadButtonMapping ( );
1113 1113
1114 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1114 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1115 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1115 connect(sysch, SIGNAL(received(const QCString&,const QByteArray&)),
1116 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1116 this, SLOT(systemMessage(const QCString&,const QByteArray&)));
1117} 1117}
1118 1118
1119bool Yopy::suspend() 1119bool Yopy::suspend()
1120{ 1120{
1121 /* Opie for Yopy does not implement its own power management at the 1121 /* Opie for Yopy does not implement its own power management at the
1122 moment. The public version runs parallel to X, and relies on the 1122 moment. The public version runs parallel to X, and relies on the
1123 existing power management features. */ 1123 existing power management features. */
1124 return false; 1124 return false;
1125} 1125}
1126 1126
1127bool Yopy::setDisplayBrightness(int bright) 1127bool Yopy::setDisplayBrightness(int bright)
1128{ 1128{
1129 /* The code here works, but is disabled as the current version runs 1129 /* The code here works, but is disabled as the current version runs
1130 parallel to X, and relies on the existing backlight demon. */ 1130 parallel to X, and relies on the existing backlight demon. */
1131#if 0 1131#if 0
1132 if ( QFile::exists("/proc/sys/pm/light") ) { 1132 if ( QFile::exists("/proc/sys/pm/light") ) {
1133 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1133 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1134 if (fd >= 0 ) { 1134 if (fd >= 0 ) {
1135 if (bright) 1135 if (bright)
1136 ::write(fd, "1\n", 2); 1136 ::write(fd, "1\n", 2);
1137 else 1137 else
1138 ::write(fd, "0\n", 2); 1138 ::write(fd, "0\n", 2);
1139 ::close(fd); 1139 ::close(fd);
1140 return true; 1140 return true;
1141 } 1141 }
1142 } 1142 }
1143#endif 1143#endif
1144 return false; 1144 return false;
1145} 1145}
1146 1146
1147int Yopy::displayBrightnessResolution() const 1147int Yopy::displayBrightnessResolution() const
1148{ 1148{
1149 return 2; 1149 return 2;
1150} 1150}
1151 1151
1152/************************************************** 1152/**************************************************
1153 * 1153 *
1154 * iPAQ 1154 * iPAQ
1155 * 1155 *
1156 **************************************************/ 1156 **************************************************/
1157 1157
1158void iPAQ::init ( ) 1158void iPAQ::init ( )
1159{ 1159{
1160 d-> m_vendorstr = "HP"; 1160 d-> m_vendorstr = "HP";
1161 d-> m_vendor = Vendor_HP; 1161 d-> m_vendor = Vendor_HP;
1162 1162
1163 QFile f ( "/proc/hal/model" ); 1163 QFile f ( "/proc/hal/model" );
1164 1164
1165 if ( f. open ( IO_ReadOnly )) { 1165 if ( f. open ( IO_ReadOnly )) {
1166 QTextStream ts ( &f ); 1166 QTextStream ts ( &f );
1167 1167
1168 d-> m_modelstr = "H" + ts. readLine ( ); 1168 d-> m_modelstr = "H" + ts. readLine ( );
1169 1169
1170 if ( d-> m_modelstr == "H3100" ) 1170 if ( d-> m_modelstr == "H3100" )
1171 d-> m_model = Model_iPAQ_H31xx; 1171 d-> m_model = Model_iPAQ_H31xx;
1172 else if ( d-> m_modelstr == "H3600" ) 1172 else if ( d-> m_modelstr == "H3600" )
1173 d-> m_model = Model_iPAQ_H36xx; 1173 d-> m_model = Model_iPAQ_H36xx;
1174 else if ( d-> m_modelstr == "H3700" ) 1174 else if ( d-> m_modelstr == "H3700" )
1175 d-> m_model = Model_iPAQ_H37xx; 1175 d-> m_model = Model_iPAQ_H37xx;
1176 else if ( d-> m_modelstr == "H3800" ) 1176 else if ( d-> m_modelstr == "H3800" )
1177 d-> m_model = Model_iPAQ_H38xx; 1177 d-> m_model = Model_iPAQ_H38xx;
1178 else if ( d-> m_modelstr == "H3900" ) 1178 else if ( d-> m_modelstr == "H3900" )
1179 d-> m_model = Model_iPAQ_H39xx; 1179 d-> m_model = Model_iPAQ_H39xx;
1180 else if ( d-> m_modelstr == "H5400" ) 1180 else if ( d-> m_modelstr == "H5400" )
1181 d-> m_model = Model_iPAQ_H5xxx; 1181 d-> m_model = Model_iPAQ_H5xxx;
1182 else 1182 else
1183 d-> m_model = Model_Unknown; 1183 d-> m_model = Model_Unknown;
1184 1184
1185 f. close ( ); 1185 f. close ( );
1186 } 1186 }
1187 1187
1188 switch ( d-> m_model ) { 1188 switch ( d-> m_model ) {
1189 case Model_iPAQ_H31xx: 1189 case Model_iPAQ_H31xx:
1190 case Model_iPAQ_H38xx: 1190 case Model_iPAQ_H38xx:
1191 d-> m_rotation = Rot90; 1191 d-> m_rotation = Rot90;
1192 break; 1192 break;
1193 case Model_iPAQ_H36xx: 1193 case Model_iPAQ_H36xx:
1194 case Model_iPAQ_H37xx: 1194 case Model_iPAQ_H37xx:
1195 case Model_iPAQ_H39xx: 1195 case Model_iPAQ_H39xx:
1196 1196
1197 default: 1197 default:
1198 d-> m_rotation = Rot270; 1198 d-> m_rotation = Rot270;
1199 break; 1199 break;
1200 case Model_iPAQ_H5xxx: 1200 case Model_iPAQ_H5xxx:
1201 d-> m_rotation = Rot0; 1201 d-> m_rotation = Rot0;
1202 } 1202 }
1203 1203
1204 f. setName ( "/etc/familiar-version" ); 1204 f. setName ( "/etc/familiar-version" );
1205 if ( f. open ( IO_ReadOnly )) { 1205 if ( f. open ( IO_ReadOnly )) {
1206 d-> m_systemstr = "Familiar"; 1206 d-> m_systemstr = "Familiar";
1207 d-> m_system = System_Familiar; 1207 d-> m_system = System_Familiar;
1208 1208
1209 QTextStream ts ( &f ); 1209 QTextStream ts ( &f );
1210 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1210 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1211 1211
1212 f. close ( ); 1212 f. close ( );
1213 } else { 1213 } else {
1214 f. setName ( "/etc/oz_version" ); 1214 f. setName ( "/etc/oz_version" );
1215 1215
1216 if ( f. open ( IO_ReadOnly )) { 1216 if ( f. open ( IO_ReadOnly )) {
1217 d-> m_systemstr = "OpenEmbedded/iPaq"; 1217 d-> m_systemstr = "OpenEmbedded/iPaq";
1218 d-> m_system = System_Familiar; 1218 d-> m_system = System_Familiar;
1219 1219
1220 QTextStream ts ( &f ); 1220 QTextStream ts ( &f );
1221 ts.setDevice ( &f ); 1221 ts.setDevice ( &f );
1222 d-> m_sysverstr = ts. readLine ( ); 1222 d-> m_sysverstr = ts. readLine ( );
1223 f. close ( ); 1223 f. close ( );
1224 } 1224 }
1225 } 1225 }
1226 1226
1227 1227
1228 1228
1229 1229
1230 1230
1231 m_leds [0] = m_leds [1] = Led_Off; 1231 m_leds [0] = m_leds [1] = Led_Off;
1232 1232
1233 m_power_timer = 0; 1233 m_power_timer = 0;
1234 1234
1235} 1235}
1236 1236
1237void iPAQ::initButtons ( ) 1237void iPAQ::initButtons ( )
1238{ 1238{
1239 if ( d-> m_buttons ) 1239 if ( d-> m_buttons )
1240 return; 1240 return;
1241 1241
1242 if ( isQWS( ) ) 1242 if ( isQWS( ) )
1243 QWSServer::setKeyboardFilter ( this ); 1243 QWSServer::setKeyboardFilter ( this );
1244 1244
1245 d-> m_buttons = new QValueList <ODeviceButton>; 1245 d-> m_buttons = new QValueList <ODeviceButton>;
1246 1246
1247 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1247 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1248 i_button *ib = ipaq_buttons + i; 1248 i_button *ib = ipaq_buttons + i;
1249 ODeviceButton b; 1249 ODeviceButton b;
1250 1250
1251 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1251 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1252 b. setKeycode ( ib-> code ); 1252 b. setKeycode ( ib-> code );
1253 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1253 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1254 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1254 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1255 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1255 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1256 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1256 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1257 1257
1258 d-> m_buttons-> append ( b ); 1258 d-> m_buttons-> append ( b );
1259 } 1259 }
1260 } 1260 }
1261 reloadButtonMapping ( ); 1261 reloadButtonMapping ( );
1262 1262
1263 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1263 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1264 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1264 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
1265} 1265}
1266 1266
1267 1267
1268//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1268//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1269 1269
1270typedef struct { 1270typedef struct {
1271 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1271 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1272 unsigned char TotalTime; /* Units of 5 seconds */ 1272 unsigned char TotalTime; /* Units of 5 seconds */
1273 unsigned char OnTime; /* units of 100m/s */ 1273 unsigned char OnTime; /* units of 100m/s */
1274 unsigned char OffTime; /* units of 100m/s */ 1274 unsigned char OffTime; /* units of 100m/s */
1275} LED_IN; 1275} LED_IN;
1276 1276
1277typedef struct { 1277typedef struct {
1278 unsigned char mode; 1278 unsigned char mode;
1279 unsigned char pwr; 1279 unsigned char pwr;
1280 unsigned char brightness; 1280 unsigned char brightness;
1281} FLITE_IN; 1281} FLITE_IN;
1282 1282
1283#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1283#define LED_ON OD_IOW( 'f', 5, LED_IN )
1284#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1284#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1285 1285
1286 1286
1287QValueList <OLed> iPAQ::ledList ( ) const 1287QValueList <OLed> iPAQ::ledList ( ) const
1288{ 1288{
1289 QValueList <OLed> vl; 1289 QValueList <OLed> vl;
1290 vl << Led_Power; 1290 vl << Led_Power;
1291 1291
1292 if ( d-> m_model == Model_iPAQ_H38xx ) 1292 if ( d-> m_model == Model_iPAQ_H38xx )
1293 vl << Led_BlueTooth; 1293 vl << Led_BlueTooth;
1294 return vl; 1294 return vl;
1295} 1295}
1296 1296
1297QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1297QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1298{ 1298{
1299 QValueList <OLedState> vl; 1299 QValueList <OLedState> vl;
1300 1300
1301 if ( l == Led_Power ) 1301 if ( l == Led_Power )
1302 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1302 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1303 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1303 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1304 vl << Led_Off; // << Led_On << ??? 1304 vl << Led_Off; // << Led_On << ???
1305 1305
1306 return vl; 1306 return vl;
1307} 1307}
1308 1308
1309OLedState iPAQ::ledState ( OLed l ) const 1309OLedState iPAQ::ledState ( OLed l ) const
1310{ 1310{
1311 switch ( l ) { 1311 switch ( l ) {
1312 case Led_Power: 1312 case Led_Power:
1313 return m_leds [0]; 1313 return m_leds [0];
1314 case Led_BlueTooth: 1314 case Led_BlueTooth:
1315 return m_leds [1]; 1315 return m_leds [1];
1316 default: 1316 default:
1317 return Led_Off; 1317 return Led_Off;
1318 } 1318 }
1319} 1319}
1320 1320
1321bool iPAQ::setLedState ( OLed l, OLedState st ) 1321bool iPAQ::setLedState ( OLed l, OLedState st )
1322{ 1322{
1323 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1323 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1324 1324
1325 if ( l == Led_Power ) { 1325 if ( l == Led_Power ) {
1326 if ( fd >= 0 ) { 1326 if ( fd >= 0 ) {
1327 LED_IN leds; 1327 LED_IN leds;
1328 ::memset ( &leds, 0, sizeof( leds )); 1328 ::memset ( &leds, 0, sizeof( leds ));
1329 leds. TotalTime = 0; 1329 leds. TotalTime = 0;
1330 leds. OnTime = 0; 1330 leds. OnTime = 0;
1331 leds. OffTime = 1; 1331 leds. OffTime = 1;
1332 leds. OffOnBlink = 2; 1332 leds. OffOnBlink = 2;
1333 1333
1334 switch ( st ) { 1334 switch ( st ) {
1335 case Led_Off : leds. OffOnBlink = 0; break; 1335 case Led_Off : leds. OffOnBlink = 0; break;
1336 case Led_On : leds. OffOnBlink = 1; break; 1336 case Led_On : leds. OffOnBlink = 1; break;
1337 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1337 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1338 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1338 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1339 } 1339 }
1340 1340
1341 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1341 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1342 m_leds [0] = st; 1342 m_leds [0] = st;
1343 return true; 1343 return true;
1344 } 1344 }
1345 } 1345 }
1346 } 1346 }
1347 return false; 1347 return false;
1348} 1348}
1349 1349
1350 1350
1351bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1351bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1352{ 1352{
1353 int newkeycode = keycode; 1353 int newkeycode = keycode;
1354 1354
1355 switch ( keycode ) { 1355 switch ( keycode ) {
1356 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1356 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1357 case HardKey_Menu: { 1357 case HardKey_Menu: {
1358 if (( d-> m_model == Model_iPAQ_H38xx ) || 1358 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1359 ( d-> m_model == Model_iPAQ_H39xx ) || 1359 ( d-> m_model == Model_iPAQ_H39xx ) ||
1360 ( d-> m_model == Model_iPAQ_H5xxx)) { 1360 ( d-> m_model == Model_iPAQ_H5xxx)) {
1361 newkeycode = HardKey_Mail; 1361 newkeycode = HardKey_Mail;
1362 } 1362 }
1363 break; 1363 break;
1364 } 1364 }
1365 1365
1366 // Rotate cursor keys 180° or 270° 1366 // Rotate cursor keys 180° or 270°
1367 case Key_Left : 1367 case Key_Left :
1368 case Key_Right: 1368 case Key_Right:
1369 case Key_Up : 1369 case Key_Up :
1370 case Key_Down : { 1370 case Key_Down : {
1371 1371
1372 if (( d-> m_model == Model_iPAQ_H31xx ) || 1372 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1373 ( d-> m_model == Model_iPAQ_H38xx )) { 1373 ( d-> m_model == Model_iPAQ_H38xx )) {
1374 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1374 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1375 } 1375 }
1376 // Rotate the cursor keys by 270° 1376 // Rotate the cursor keys by 270°
1377 // keycode - Key_Left = position of the button starting from left clockwise 1377 // keycode - Key_Left = position of the button starting from left clockwise
1378 // add the rotation to it and modolo. No we've the original offset 1378 // add the rotation to it and modolo. No we've the original offset
1379 // add the offset to the Key_Left key 1379 // add the offset to the Key_Left key
1380 if ( d-> m_model == Model_iPAQ_H5xxx ) 1380 if ( d-> m_model == Model_iPAQ_H5xxx )
1381 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 1381 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
1382 break; 1382 break;
1383 } 1383 }
1384 1384
1385 // map Power Button short/long press to F34/F35 1385 // map Power Button short/long press to F34/F35
1386 case Key_SysReq: { 1386 case Key_SysReq: {
1387 if ( isPress ) { 1387 if ( isPress ) {
1388 if ( m_power_timer ) 1388 if ( m_power_timer )
1389 killTimer ( m_power_timer ); 1389 killTimer ( m_power_timer );
1390 m_power_timer = startTimer ( 500 ); 1390 m_power_timer = startTimer ( 500 );
1391 } 1391 }
1392 else if ( m_power_timer ) { 1392 else if ( m_power_timer ) {
1393 killTimer ( m_power_timer ); 1393 killTimer ( m_power_timer );
1394 m_power_timer = 0; 1394 m_power_timer = 0;
1395 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1395 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1396 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1396 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1397 } 1397 }
1398 newkeycode = Key_unknown; 1398 newkeycode = Key_unknown;
1399 break; 1399 break;
1400 } 1400 }
1401 } 1401 }
1402 1402
1403 if ( newkeycode != keycode ) { 1403 if ( newkeycode != keycode ) {
1404 if ( newkeycode != Key_unknown ) 1404 if ( newkeycode != Key_unknown )
1405 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1405 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1406 return true; 1406 return true;
1407 } 1407 }
1408 else 1408 else
1409 return false; 1409 return false;
1410} 1410}
1411 1411
1412void iPAQ::timerEvent ( QTimerEvent * ) 1412void iPAQ::timerEvent ( QTimerEvent * )
1413{ 1413{
1414 killTimer ( m_power_timer ); 1414 killTimer ( m_power_timer );
1415 m_power_timer = 0; 1415 m_power_timer = 0;
1416 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1416 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1417 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1417 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1418} 1418}
1419 1419
1420 1420
1421void iPAQ::alarmSound ( ) 1421void iPAQ::alarmSound ( )
1422{ 1422{
1423#ifndef QT_NO_SOUND 1423#ifndef QT_NO_SOUND
1424 static Sound snd ( "alarm" ); 1424 static Sound snd ( "alarm" );
1425 int fd; 1425 int fd;
1426 int vol; 1426 int vol;
1427 bool vol_reset = false; 1427 bool vol_reset = false;
1428 1428
1429 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1429 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1430 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1430 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1431 Config cfg ( "qpe" ); 1431 Config cfg ( "qpe" );
1432 cfg. setGroup ( "Volume" ); 1432 cfg. setGroup ( "Volume" );
1433 1433
1434 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1434 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1435 if ( volalarm < 0 ) 1435 if ( volalarm < 0 )
1436 volalarm = 0; 1436 volalarm = 0;
1437 else if ( volalarm > 100 ) 1437 else if ( volalarm > 100 )
1438 volalarm = 100; 1438 volalarm = 100;
1439 volalarm |= ( volalarm << 8 ); 1439 volalarm |= ( volalarm << 8 );
1440 1440
1441 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1441 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1442 vol_reset = true; 1442 vol_reset = true;
1443 } 1443 }
1444 } 1444 }
1445 1445
1446 snd. play ( ); 1446 snd. play ( );
1447 while ( !snd. isFinished ( )) 1447 while ( !snd. isFinished ( ))
1448 qApp-> processEvents ( ); 1448 qApp-> processEvents ( );
1449 1449
1450 if ( fd >= 0 ) { 1450 if ( fd >= 0 ) {
1451 if ( vol_reset ) 1451 if ( vol_reset )
1452 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1452 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1453 ::close ( fd ); 1453 ::close ( fd );
1454 } 1454 }
1455#endif 1455#endif
1456} 1456}
@@ -1558,386 +1558,386 @@ int iPAQ::lightSensorResolution ( ) const
1558 1558
1559// Check whether this device is the sharp zaurus.. 1559// Check whether this device is the sharp zaurus..
1560// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 1560// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
1561// class up into individual classes. We need three classes 1561// class up into individual classes. We need three classes
1562// 1562//
1563// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 1563// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
1564// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 1564// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
1565// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 1565// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
1566// 1566//
1567// Only question right now is: Do we really need to do it? Because as soon 1567// Only question right now is: Do we really need to do it? Because as soon
1568// as the OpenZaurus kernel is ready, there will be a unified interface for all 1568// as the OpenZaurus kernel is ready, there will be a unified interface for all
1569// Zaurus models (concerning apm, backlight, buttons, etc.) 1569// Zaurus models (concerning apm, backlight, buttons, etc.)
1570// 1570//
1571// Comments? - mickeyl. 1571// Comments? - mickeyl.
1572 1572
1573bool Zaurus::isZaurus() 1573bool Zaurus::isZaurus()
1574{ 1574{
1575 1575
1576 // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! 1576 // If the special devices by embedix exist, it is quite simple: it is a Zaurus !
1577 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ 1577 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
1578 return true; 1578 return true;
1579 } 1579 }
1580 1580
1581 // On non-embedix kernels, we have to look closer. 1581 // On non-embedix kernels, we have to look closer.
1582 bool is_zaurus = false; 1582 bool is_zaurus = false;
1583 QFile f ( "/proc/cpuinfo" ); 1583 QFile f ( "/proc/cpuinfo" );
1584 if ( f. open ( IO_ReadOnly ) ) { 1584 if ( f. open ( IO_ReadOnly ) ) {
1585 QString model; 1585 QString model;
1586 QFile f ( "/proc/cpuinfo" ); 1586 QFile f ( "/proc/cpuinfo" );
1587 1587
1588 QTextStream ts ( &f ); 1588 QTextStream ts ( &f );
1589 QString line; 1589 QString line;
1590 while( line = ts. readLine ( ) ) { 1590 while( line = ts. readLine ( ) ) {
1591 if ( line. left ( 8 ) == "Hardware" ) 1591 if ( line. left ( 8 ) == "Hardware" )
1592 break; 1592 break;
1593 } 1593 }
1594 int loc = line. find ( ":" ); 1594 int loc = line. find ( ":" );
1595 if ( loc != -1 ) 1595 if ( loc != -1 )
1596 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1596 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1597 1597
1598 if ( model == "Sharp-Collie" 1598 if ( model == "Sharp-Collie"
1599 || model == "Collie" 1599 || model == "Collie"
1600 || model == "SHARP Corgi" 1600 || model == "SHARP Corgi"
1601 || model == "SHARP Shepherd" 1601 || model == "SHARP Shepherd"
1602 || model == "SHARP Poodle" 1602 || model == "SHARP Poodle"
1603 || model == "SHARP Husky" 1603 || model == "SHARP Husky"
1604 ) 1604 )
1605 is_zaurus = true; 1605 is_zaurus = true;
1606 1606
1607 } 1607 }
1608 return is_zaurus; 1608 return is_zaurus;
1609} 1609}
1610 1610
1611 1611
1612void Zaurus::init ( ) 1612void Zaurus::init ( )
1613{ 1613{
1614 d-> m_vendorstr = "Sharp"; 1614 d-> m_vendorstr = "Sharp";
1615 d-> m_vendor = Vendor_Sharp; 1615 d-> m_vendor = Vendor_Sharp;
1616 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 1616 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
1617 1617
1618 // QFile f ( "/proc/filesystems" ); 1618 // QFile f ( "/proc/filesystems" );
1619 QString model; 1619 QString model;
1620 1620
1621 // It isn't a good idea to check the system configuration to 1621 // It isn't a good idea to check the system configuration to
1622 // detect the distribution ! 1622 // detect the distribution !
1623 // Otherwise it may happen that any other distribution is detected as openzaurus, just 1623 // Otherwise it may happen that any other distribution is detected as openzaurus, just
1624 // because it uses a jffs2 filesystem.. 1624 // because it uses a jffs2 filesystem..
1625 // (eilers) 1625 // (eilers)
1626 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1626 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1627 QFile f ("/etc/oz_version"); 1627 QFile f ("/etc/oz_version");
1628 if ( f.exists() ){ 1628 if ( f.exists() ){
1629 d-> m_vendorstr = "OpenZaurus Team"; 1629 d-> m_vendorstr = "OpenZaurus Team";
1630 d-> m_systemstr = "OpenZaurus"; 1630 d-> m_systemstr = "OpenZaurus";
1631 d-> m_system = System_OpenZaurus; 1631 d-> m_system = System_OpenZaurus;
1632 1632
1633 if ( f. open ( IO_ReadOnly )) { 1633 if ( f. open ( IO_ReadOnly )) {
1634 QTextStream ts ( &f ); 1634 QTextStream ts ( &f );
1635 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1635 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1636 f. close ( ); 1636 f. close ( );
1637 } 1637 }
1638 1638
1639 // Openzaurus sometimes uses the embedix kernel! 1639 // Openzaurus sometimes uses the embedix kernel!
1640 // => Check whether this is an embedix kernel 1640 // => Check whether this is an embedix kernel
1641 FILE *uname = popen("uname -r", "r"); 1641 FILE *uname = popen("uname -r", "r");
1642 QString line; 1642 QString line;
1643 if ( f.open(IO_ReadOnly, uname) ) { 1643 if ( f.open(IO_ReadOnly, uname) ) {
1644 QTextStream ts ( &f ); 1644 QTextStream ts ( &f );
1645 line = ts. readLine ( ); 1645 line = ts. readLine ( );
1646 int loc = line. find ( "embedix" ); 1646 int loc = line. find ( "embedix" );
1647 if ( loc != -1 ) 1647 if ( loc != -1 )
1648 m_embedix = true; 1648 m_embedix = true;
1649 else 1649 else
1650 m_embedix = false; 1650 m_embedix = false;
1651 f. close ( ); 1651 f. close ( );
1652 } 1652 }
1653 pclose(uname); 1653 pclose(uname);
1654 } 1654 }
1655 else { 1655 else {
1656 d-> m_systemstr = "Zaurus"; 1656 d-> m_systemstr = "Zaurus";
1657 d-> m_system = System_Zaurus; 1657 d-> m_system = System_Zaurus;
1658 } 1658 }
1659 1659
1660 f. setName ( "/proc/cpuinfo" ); 1660 f. setName ( "/proc/cpuinfo" );
1661 if ( f. open ( IO_ReadOnly ) ) { 1661 if ( f. open ( IO_ReadOnly ) ) {
1662 QTextStream ts ( &f ); 1662 QTextStream ts ( &f );
1663 QString line; 1663 QString line;
1664 while( line = ts. readLine ( ) ) { 1664 while( line = ts. readLine ( ) ) {
1665 if ( line. left ( 8 ) == "Hardware" ) 1665 if ( line. left ( 8 ) == "Hardware" )
1666 break; 1666 break;
1667 } 1667 }
1668 int loc = line. find ( ":" ); 1668 int loc = line. find ( ":" );
1669 if ( loc != -1 ) 1669 if ( loc != -1 )
1670 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1670 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1671 } 1671 }
1672 1672
1673 if ( model == "SHARP Corgi" ) { 1673 if ( model == "SHARP Corgi" ) {
1674 d-> m_model = Model_Zaurus_SLC7x0; 1674 d-> m_model = Model_Zaurus_SLC7x0;
1675 d-> m_modelstr = "Zaurus SL-C700"; 1675 d-> m_modelstr = "Zaurus SL-C700";
1676 } else if ( model == "SHARP Shepherd" ) { 1676 } else if ( model == "SHARP Shepherd" ) {
1677 d-> m_model = Model_Zaurus_SLC7x0; 1677 d-> m_model = Model_Zaurus_SLC7x0;
1678 d-> m_modelstr = "Zaurus SL-C750"; 1678 d-> m_modelstr = "Zaurus SL-C750";
1679 } else if ( model == "SHARP Husky" ) { 1679 } else if ( model == "SHARP Husky" ) {
1680 d-> m_model = Model_Zaurus_SLC7x0; 1680 d-> m_model = Model_Zaurus_SLC7x0;
1681 d-> m_modelstr = "Zaurus SL-C760"; 1681 d-> m_modelstr = "Zaurus SL-C760";
1682 } else if ( model == "SHARP Poodle" ) { 1682 } else if ( model == "SHARP Poodle" ) {
1683 d-> m_model = Model_Zaurus_SLB600; 1683 d-> m_model = Model_Zaurus_SLB600;
1684 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1684 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1685 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 1685 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
1686 d-> m_model = Model_Zaurus_SL5500; 1686 d-> m_model = Model_Zaurus_SL5500;
1687 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1687 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1688 } else { 1688 } else {
1689 d-> m_model = Model_Zaurus_SL5500; 1689 d-> m_model = Model_Zaurus_SL5500;
1690 d-> m_modelstr = "Zaurus (Model unknown)"; 1690 d-> m_modelstr = "Zaurus (Model unknown)";
1691 } 1691 }
1692 1692
1693 bool flipstate = false; 1693 bool flipstate = false;
1694 switch ( d-> m_model ) { 1694 switch ( d-> m_model ) {
1695 case Model_Zaurus_SLA300: 1695 case Model_Zaurus_SLA300:
1696 d-> m_rotation = Rot0; 1696 d-> m_rotation = Rot0;
1697 break; 1697 break;
1698 case Model_Zaurus_SLC7x0: 1698 case Model_Zaurus_SLC7x0:
1699 d-> m_rotation = rotation(); 1699 d-> m_rotation = rotation();
1700 d-> m_direction = direction(); 1700 d-> m_direction = direction();
1701 break; 1701 break;
1702 case Model_Zaurus_SLB600: 1702 case Model_Zaurus_SLB600:
1703 case Model_Zaurus_SL5500: 1703 case Model_Zaurus_SL5500:
1704 case Model_Zaurus_SL5000: 1704 case Model_Zaurus_SL5000:
1705 default: 1705 default:
1706 d-> m_rotation = Rot270; 1706 d-> m_rotation = Rot270;
1707 break; 1707 break;
1708 } 1708 }
1709 m_leds [0] = Led_Off; 1709 m_leds [0] = Led_Off;
1710} 1710}
1711 1711
1712void Zaurus::initButtons ( ) 1712void Zaurus::initButtons ( )
1713{ 1713{
1714 if ( d-> m_buttons ) 1714 if ( d-> m_buttons )
1715 return; 1715 return;
1716 1716
1717 d-> m_buttons = new QValueList <ODeviceButton>; 1717 d-> m_buttons = new QValueList <ODeviceButton>;
1718 1718
1719 struct z_button * pz_buttons; 1719 struct z_button * pz_buttons;
1720 int buttoncount; 1720 int buttoncount;
1721 switch ( d-> m_model ) { 1721 switch ( d-> m_model ) {
1722 case Model_Zaurus_SLC7x0: 1722 case Model_Zaurus_SLC7x0:
1723 pz_buttons = z_buttons_c700; 1723 pz_buttons = z_buttons_c700;
1724 buttoncount = ARRAY_SIZE(z_buttons_c700); 1724 buttoncount = ARRAY_SIZE(z_buttons_c700);
1725 break; 1725 break;
1726 default: 1726 default:
1727 pz_buttons = z_buttons; 1727 pz_buttons = z_buttons;
1728 buttoncount = ARRAY_SIZE(z_buttons); 1728 buttoncount = ARRAY_SIZE(z_buttons);
1729 break; 1729 break;
1730 } 1730 }
1731 1731
1732 for ( int i = 0; i < buttoncount; i++ ) { 1732 for ( int i = 0; i < buttoncount; i++ ) {
1733 struct z_button *zb = pz_buttons + i; 1733 struct z_button *zb = pz_buttons + i;
1734 ODeviceButton b; 1734 ODeviceButton b;
1735 1735
1736 b. setKeycode ( zb-> code ); 1736 b. setKeycode ( zb-> code );
1737 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1737 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1738 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1738 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1739 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), 1739 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ),
1740 zb-> fpressedaction )); 1740 zb-> fpressedaction ));
1741 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), 1741 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ),
1742 zb-> fheldaction )); 1742 zb-> fheldaction ));
1743 1743
1744 d-> m_buttons-> append ( b ); 1744 d-> m_buttons-> append ( b );
1745 } 1745 }
1746 1746
1747 reloadButtonMapping ( ); 1747 reloadButtonMapping ( );
1748 1748
1749 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1749 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1750 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), 1750 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
1751 this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1751 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
1752} 1752}
1753 1753
1754#include <unistd.h> 1754#include <unistd.h>
1755#include <fcntl.h> 1755#include <fcntl.h>
1756#include <sys/ioctl.h> 1756#include <sys/ioctl.h>
1757 1757
1758//#include <asm/sharp_char.h> // including kernel headers is evil ... 1758//#include <asm/sharp_char.h> // including kernel headers is evil ...
1759 1759
1760#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1760#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1761 1761
1762 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1762 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1763#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1763#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1764 1764
1765#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1765#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1766#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1766#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1767#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1767#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1768 1768
1769/* --- for SHARP_BUZZER device --- */ 1769/* --- for SHARP_BUZZER device --- */
1770 1770
1771 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1771 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1772//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1772//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1773 1773
1774#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1774#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1775#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1775#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1776#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1776#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1777#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1777#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1778#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1778#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1779 1779
1780//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1780//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1781//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1781//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1782 1782
1783//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1783//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1784//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1784//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1785//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1785//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1786//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1786//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1787//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1787//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1788//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1788//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1789//#define SHARP_PDA_APPSTART 9 /* application start */ 1789//#define SHARP_PDA_APPSTART 9 /* application start */
1790//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1790//#define SHARP_PDA_APPQUIT 10 /* application ends */
1791 1791
1792//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1792//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1793//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1793//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1794//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1794//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1795//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1795//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1796// 1796//
1797 1797
1798 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1798 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1799#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1799#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1800 1800
1801#define SHARP_IOCTL_GET_ROTATION 0x413c 1801#define SHARP_IOCTL_GET_ROTATION 0x413c
1802 1802
1803typedef struct sharp_led_status { 1803typedef struct sharp_led_status {
1804 int which; /* select which LED status is wanted. */ 1804 int which; /* select which LED status is wanted. */
1805 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1805 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1806} sharp_led_status; 1806} sharp_led_status;
1807 1807
1808#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1808#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1809 1809
1810#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1810#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1811#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1811#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1812#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1812#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1813 1813
1814// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1814// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1815 1815
1816#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1816#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1817#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1817#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1818#define APM_EVT_POWER_BUTTON (1 << 0) 1818#define APM_EVT_POWER_BUTTON (1 << 0)
1819 1819
1820#define FL_IOCTL_STEP_CONTRAST 100 1820#define FL_IOCTL_STEP_CONTRAST 100
1821 1821
1822 1822
1823void Zaurus::buzzer ( int sound ) 1823void Zaurus::buzzer ( int sound )
1824{ 1824{
1825#ifndef QT_NO_SOUND 1825#ifndef QT_NO_SOUND
1826 QString soundname; 1826 QString soundname;
1827 1827
1828 // Not all devices have real sound 1828 // Not all devices have real sound
1829 if ( d->m_model == Model_Zaurus_SLC7x0 1829 if ( d->m_model == Model_Zaurus_SLC7x0
1830 || d->m_model == Model_Zaurus_SLB600 ){ 1830 || d->m_model == Model_Zaurus_SLB600 ){
1831 1831
1832 switch ( sound ){ 1832 switch ( sound ){
1833 case SHARP_BUZ_SCHEDULE_ALARM: 1833 case SHARP_BUZ_SCHEDULE_ALARM:
1834 soundname = "alarm"; 1834 soundname = "alarm";
1835 break; 1835 break;
1836 case SHARP_BUZ_TOUCHSOUND: 1836 case SHARP_BUZ_TOUCHSOUND:
1837 soundname = "touchsound"; 1837 soundname = "touchsound";
1838 break; 1838 break;
1839 case SHARP_BUZ_KEYSOUND: 1839 case SHARP_BUZ_KEYSOUND:
1840 soundname = "keysound"; 1840 soundname = "keysound";
1841 break; 1841 break;
1842 default: 1842 default:
1843 soundname = "alarm"; 1843 soundname = "alarm";
1844 1844
1845 } 1845 }
1846 } 1846 }
1847 1847
1848 // If a soundname is defined, we expect that this device has 1848 // If a soundname is defined, we expect that this device has
1849 // sound capabilities.. Otherwise we expect to have the buzzer 1849 // sound capabilities.. Otherwise we expect to have the buzzer
1850 // device.. 1850 // device..
1851 if ( !soundname.isEmpty() ){ 1851 if ( !soundname.isEmpty() ){
1852 int fd; 1852 int fd;
1853 int vol; 1853 int vol;
1854 bool vol_reset = false; 1854 bool vol_reset = false;
1855 1855
1856 Sound snd ( soundname ); 1856 Sound snd ( soundname );
1857 1857
1858 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1858 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1859 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1859 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1860 Config cfg ( "qpe" ); 1860 Config cfg ( "qpe" );
1861 cfg. setGroup ( "Volume" ); 1861 cfg. setGroup ( "Volume" );
1862 1862
1863 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1863 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1864 if ( volalarm < 0 ) 1864 if ( volalarm < 0 )
1865 volalarm = 0; 1865 volalarm = 0;
1866 else if ( volalarm > 100 ) 1866 else if ( volalarm > 100 )
1867 volalarm = 100; 1867 volalarm = 100;
1868 volalarm |= ( volalarm << 8 ); 1868 volalarm |= ( volalarm << 8 );
1869 1869
1870 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1870 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1871 vol_reset = true; 1871 vol_reset = true;
1872 } 1872 }
1873 } 1873 }
1874 1874
1875 snd. play ( ); 1875 snd. play ( );
1876 while ( !snd. isFinished ( )) 1876 while ( !snd. isFinished ( ))
1877 qApp-> processEvents ( ); 1877 qApp-> processEvents ( );
1878 1878
1879 if ( fd >= 0 ) { 1879 if ( fd >= 0 ) {
1880 if ( vol_reset ) 1880 if ( vol_reset )
1881 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1881 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1882 ::close ( fd ); 1882 ::close ( fd );
1883 } 1883 }
1884 } else { 1884 } else {
1885 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1885 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1886 1886
1887 if ( fd >= 0 ) { 1887 if ( fd >= 0 ) {
1888 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1888 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1889 ::close ( fd ); 1889 ::close ( fd );
1890 } 1890 }
1891 1891
1892 } 1892 }
1893#endif 1893#endif
1894} 1894}
1895 1895
1896 1896
1897void Zaurus::alarmSound ( ) 1897void Zaurus::alarmSound ( )
1898{ 1898{
1899 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1899 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1900} 1900}
1901 1901
1902void Zaurus::touchSound ( ) 1902void Zaurus::touchSound ( )
1903{ 1903{
1904 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1904 buzzer ( SHARP_BUZ_TOUCHSOUND );
1905} 1905}
1906 1906
1907void Zaurus::keySound ( ) 1907void Zaurus::keySound ( )
1908{ 1908{
1909 buzzer ( SHARP_BUZ_KEYSOUND ); 1909 buzzer ( SHARP_BUZ_KEYSOUND );
1910} 1910}
1911 1911
1912 1912
1913QValueList <OLed> Zaurus::ledList ( ) const 1913QValueList <OLed> Zaurus::ledList ( ) const
1914{ 1914{
1915 QValueList <OLed> vl; 1915 QValueList <OLed> vl;
1916 vl << Led_Mail; 1916 vl << Led_Mail;
1917 return vl; 1917 return vl;
1918} 1918}
1919 1919
1920QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1920QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1921{ 1921{
1922 QValueList <OLedState> vl; 1922 QValueList <OLedState> vl;
1923 1923
1924 if ( l == Led_Mail ) 1924 if ( l == Led_Mail )
1925 vl << Led_Off << Led_On << Led_BlinkSlow; 1925 vl << Led_Off << Led_On << Led_BlinkSlow;
1926 return vl; 1926 return vl;
1927} 1927}
1928 1928
1929OLedState Zaurus::ledState ( OLed which ) const 1929OLedState Zaurus::ledState ( OLed which ) const
1930{ 1930{
1931 if ( which == Led_Mail ) 1931 if ( which == Led_Mail )
1932 return m_leds [0]; 1932 return m_leds [0];
1933 else 1933 else
1934 return Led_Off; 1934 return Led_Off;
1935} 1935}
1936 1936
1937bool Zaurus::setLedState ( OLed which, OLedState st ) 1937bool Zaurus::setLedState ( OLed which, OLedState st )
1938{ 1938{
1939 if (!m_embedix) // Currently not supported on non_embedix kernels 1939 if (!m_embedix) // Currently not supported on non_embedix kernels
1940 return false; 1940 return false;
1941 1941
1942 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1942 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1943 1943
@@ -2109,385 +2109,385 @@ Transformation Zaurus::rotation ( ) const
2109 case Model_Zaurus_SLB600: 2109 case Model_Zaurus_SLB600:
2110 case Model_Zaurus_SL5500: 2110 case Model_Zaurus_SL5500:
2111 case Model_Zaurus_SL5000: 2111 case Model_Zaurus_SL5000:
2112 default: 2112 default:
2113 rot = d-> m_rotation; 2113 rot = d-> m_rotation;
2114 break; 2114 break;
2115 } 2115 }
2116 2116
2117 return rot; 2117 return rot;
2118} 2118}
2119ODirection Zaurus::direction ( ) const 2119ODirection Zaurus::direction ( ) const
2120{ 2120{
2121 ODirection dir; 2121 ODirection dir;
2122 int handle = 0; 2122 int handle = 0;
2123 int retval = 0; 2123 int retval = 0;
2124 switch ( d-> m_model ) { 2124 switch ( d-> m_model ) {
2125 case Model_Zaurus_SLC7x0: 2125 case Model_Zaurus_SLC7x0:
2126 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2126 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2127 if (handle == -1) { 2127 if (handle == -1) {
2128 dir = CW; 2128 dir = CW;
2129 } else { 2129 } else {
2130 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2130 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2131 ::close (handle); 2131 ::close (handle);
2132 if (retval == 2 ) 2132 if (retval == 2 )
2133 dir = CCW; 2133 dir = CCW;
2134 else 2134 else
2135 dir = CW; 2135 dir = CW;
2136 } 2136 }
2137 break; 2137 break;
2138 case Model_Zaurus_SLA300: 2138 case Model_Zaurus_SLA300:
2139 case Model_Zaurus_SLB600: 2139 case Model_Zaurus_SLB600:
2140 case Model_Zaurus_SL5500: 2140 case Model_Zaurus_SL5500:
2141 case Model_Zaurus_SL5000: 2141 case Model_Zaurus_SL5000:
2142 default: 2142 default:
2143 dir = d-> m_direction; 2143 dir = d-> m_direction;
2144 break; 2144 break;
2145 } 2145 }
2146 return dir; 2146 return dir;
2147 2147
2148} 2148}
2149 2149
2150int Zaurus::displayBrightnessResolution ( ) const 2150int Zaurus::displayBrightnessResolution ( ) const
2151{ 2151{
2152 if (m_embedix) 2152 if (m_embedix)
2153 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; 2153 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
2154 else 2154 else
2155 return 256; 2155 return 256;
2156} 2156}
2157 2157
2158bool Zaurus::hasHingeSensor() const 2158bool Zaurus::hasHingeSensor() const
2159{ 2159{
2160 return d->m_model == Model_Zaurus_SLC7x0; 2160 return d->m_model == Model_Zaurus_SLC7x0;
2161} 2161}
2162 2162
2163OHingeStatus Zaurus::readHingeSensor() 2163OHingeStatus Zaurus::readHingeSensor()
2164{ 2164{
2165 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2165 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2166 if (handle == -1) 2166 if (handle == -1)
2167 { 2167 {
2168 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 2168 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
2169 return CASE_UNKNOWN; 2169 return CASE_UNKNOWN;
2170 } 2170 }
2171 else 2171 else
2172 { 2172 {
2173 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2173 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2174 ::close (handle); 2174 ::close (handle);
2175 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 2175 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
2176 { 2176 {
2177 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 2177 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
2178 return static_cast<OHingeStatus>( retval ); 2178 return static_cast<OHingeStatus>( retval );
2179 } 2179 }
2180 else 2180 else
2181 { 2181 {
2182 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 2182 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
2183 return CASE_UNKNOWN; 2183 return CASE_UNKNOWN;
2184 } 2184 }
2185 } 2185 }
2186} 2186}
2187 2187
2188 2188
2189void Zaurus::virtual_hook( int id, void *data ) { 2189void Zaurus::virtual_hook( int id, void *data ) {
2190 switch( id ) { 2190 switch( id ) {
2191 case VIRTUAL_ROTATION:{ 2191 case VIRTUAL_ROTATION:{
2192 VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); 2192 VirtRotation* rot = reinterpret_cast<VirtRotation*>( data );
2193 rot->trans = rotation(); 2193 rot->trans = rotation();
2194 break; 2194 break;
2195 } 2195 }
2196 case VIRTUAL_DIRECTION:{ 2196 case VIRTUAL_DIRECTION:{
2197 VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); 2197 VirtDirection *dir = reinterpret_cast<VirtDirection*>( data );
2198 dir->direct = direction(); 2198 dir->direct = direction();
2199 break; 2199 break;
2200 } 2200 }
2201 case VIRTUAL_HAS_HINGE:{ 2201 case VIRTUAL_HAS_HINGE:{
2202 VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); 2202 VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data );
2203 hin->hasHinge = hasHingeSensor(); 2203 hin->hasHinge = hasHingeSensor();
2204 break; 2204 break;
2205 } 2205 }
2206 case VIRTUAL_HINGE:{ 2206 case VIRTUAL_HINGE:{
2207 VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); 2207 VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data );
2208 hin->hingeStat = readHingeSensor(); 2208 hin->hingeStat = readHingeSensor();
2209 break; 2209 break;
2210 } 2210 }
2211 default: 2211 default:
2212 ODevice::virtual_hook( id, data ); 2212 ODevice::virtual_hook( id, data );
2213 break; 2213 break;
2214 } 2214 }
2215} 2215}
2216 2216
2217/************************************************** 2217/**************************************************
2218 * 2218 *
2219 * SIMpad 2219 * SIMpad
2220 * 2220 *
2221 **************************************************/ 2221 **************************************************/
2222 2222
2223void SIMpad::init ( ) 2223void SIMpad::init ( )
2224{ 2224{
2225 d-> m_vendorstr = "SIEMENS"; 2225 d-> m_vendorstr = "SIEMENS";
2226 d-> m_vendor = Vendor_SIEMENS; 2226 d-> m_vendor = Vendor_SIEMENS;
2227 2227
2228 QFile f ( "/proc/hal/model" ); 2228 QFile f ( "/proc/hal/model" );
2229 2229
2230 //TODO Implement model checking 2230 //TODO Implement model checking
2231 //FIXME For now we assume an SL4 2231 //FIXME For now we assume an SL4
2232 2232
2233 d-> m_modelstr = "SL4"; 2233 d-> m_modelstr = "SL4";
2234 d-> m_model = Model_SIMpad_SL4; 2234 d-> m_model = Model_SIMpad_SL4;
2235 2235
2236 switch ( d-> m_model ) { 2236 switch ( d-> m_model ) {
2237 default: 2237 default:
2238 d-> m_rotation = Rot0; 2238 d-> m_rotation = Rot0;
2239 d-> m_direction = CCW; 2239 d-> m_direction = CCW;
2240 d-> m_holdtime = 1000; // 1000ms 2240 d-> m_holdtime = 1000; // 1000ms
2241 2241
2242 break; 2242 break;
2243 } 2243 }
2244 2244
2245 f. setName ( "/etc/familiar-version" ); 2245 f. setName ( "/etc/familiar-version" );
2246 if ( f. open ( IO_ReadOnly )) { 2246 if ( f. open ( IO_ReadOnly )) {
2247 d-> m_systemstr = "Familiar"; 2247 d-> m_systemstr = "Familiar";
2248 d-> m_system = System_Familiar; 2248 d-> m_system = System_Familiar;
2249 2249
2250 QTextStream ts ( &f ); 2250 QTextStream ts ( &f );
2251 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 2251 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
2252 2252
2253 f. close ( ); 2253 f. close ( );
2254 } else { 2254 } else {
2255 f. setName ( "/etc/oz_version" ); 2255 f. setName ( "/etc/oz_version" );
2256 2256
2257 if ( f. open ( IO_ReadOnly )) { 2257 if ( f. open ( IO_ReadOnly )) {
2258 d-> m_systemstr = "OpenEmbedded/SIMpad"; 2258 d-> m_systemstr = "OpenEmbedded/SIMpad";
2259 d-> m_system = System_OpenZaurus; 2259 d-> m_system = System_OpenZaurus;
2260 2260
2261 QTextStream ts ( &f ); 2261 QTextStream ts ( &f );
2262 ts.setDevice ( &f ); 2262 ts.setDevice ( &f );
2263 d-> m_sysverstr = ts. readLine ( ); 2263 d-> m_sysverstr = ts. readLine ( );
2264 f. close ( ); 2264 f. close ( );
2265 } 2265 }
2266 } 2266 }
2267 2267
2268 m_leds [0] = m_leds [1] = Led_Off; 2268 m_leds [0] = m_leds [1] = Led_Off;
2269 2269
2270 m_power_timer = 0; 2270 m_power_timer = 0;
2271 2271
2272} 2272}
2273 2273
2274void SIMpad::initButtons ( ) 2274void SIMpad::initButtons ( )
2275{ 2275{
2276 if ( d-> m_buttons ) 2276 if ( d-> m_buttons )
2277 return; 2277 return;
2278 2278
2279 if ( isQWS( ) ) 2279 if ( isQWS( ) )
2280 QWSServer::setKeyboardFilter ( this ); 2280 QWSServer::setKeyboardFilter ( this );
2281 2281
2282 d-> m_buttons = new QValueList <ODeviceButton>; 2282 d-> m_buttons = new QValueList <ODeviceButton>;
2283 2283
2284 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 2284 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
2285 s_button *sb = simpad_buttons + i; 2285 s_button *sb = simpad_buttons + i;
2286 ODeviceButton b; 2286 ODeviceButton b;
2287 2287
2288 if (( sb-> model & d-> m_model ) == d-> m_model ) { 2288 if (( sb-> model & d-> m_model ) == d-> m_model ) {
2289 b. setKeycode ( sb-> code ); 2289 b. setKeycode ( sb-> code );
2290 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 2290 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
2291 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 2291 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
2292 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 2292 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
2293 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 2293 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
2294 2294
2295 d-> m_buttons-> append ( b ); 2295 d-> m_buttons-> append ( b );
2296 } 2296 }
2297 } 2297 }
2298 reloadButtonMapping ( ); 2298 reloadButtonMapping ( );
2299 2299
2300 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 2300 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
2301 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 2301 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
2302} 2302}
2303 2303
2304// SIMpad boardcontrol register CS3 2304// SIMpad boardcontrol register CS3
2305#define SIMPAD_BOARDCONTROL "/proc/cs3" 2305#define SIMPAD_BOARDCONTROL "/proc/cs3"
2306#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 2306#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
2307#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 2307#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
2308#define SIMPAD_EN1 0x0004 // This is only for EPROM's 2308#define SIMPAD_EN1 0x0004 // This is only for EPROM's
2309#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 2309#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
2310#define SIMPAD_DISPLAY_ON 0x0010 2310#define SIMPAD_DISPLAY_ON 0x0010
2311#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 2311#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
2312#define SIMPAD_MQ_RESET 0x0040 2312#define SIMPAD_MQ_RESET 0x0040
2313#define SIMPAD_PCMCIA_RESET 0x0080 2313#define SIMPAD_PCMCIA_RESET 0x0080
2314#define SIMPAD_DECT_POWER_ON 0x0100 2314#define SIMPAD_DECT_POWER_ON 0x0100
2315#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 2315#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
2316#define SIMPAD_RS232_ON 0x0400 2316#define SIMPAD_RS232_ON 0x0400
2317#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 2317#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
2318#define SIMPAD_LED2_ON 0x1000 2318#define SIMPAD_LED2_ON 0x1000
2319#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 2319#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
2320#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 2320#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
2321#define SIMPAD_RESET_SIMCARD 0x8000 2321#define SIMPAD_RESET_SIMCARD 0x8000
2322 2322
2323//SIMpad touchscreen backlight strength control 2323//SIMpad touchscreen backlight strength control
2324#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 2324#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
2325#define SIMPAD_BACKLIGHT_MASK 0x00a10044 2325#define SIMPAD_BACKLIGHT_MASK 0x00a10044
2326 2326
2327QValueList <OLed> SIMpad::ledList ( ) const 2327QValueList <OLed> SIMpad::ledList ( ) const
2328{ 2328{
2329 QValueList <OLed> vl; 2329 QValueList <OLed> vl;
2330 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 2330 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
2331 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 2331 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
2332 return vl; 2332 return vl;
2333} 2333}
2334 2334
2335QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 2335QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
2336{ 2336{
2337 QValueList <OLedState> vl; 2337 QValueList <OLedState> vl;
2338 2338
2339 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 2339 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
2340 vl << Led_Off << Led_On; 2340 vl << Led_Off << Led_On;
2341 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 2341 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
2342 //vl << Led_Off; 2342 //vl << Led_Off;
2343 return vl; 2343 return vl;
2344} 2344}
2345 2345
2346OLedState SIMpad::ledState ( OLed l ) const 2346OLedState SIMpad::ledState ( OLed l ) const
2347{ 2347{
2348 switch ( l ) { 2348 switch ( l ) {
2349 case Led_Power: 2349 case Led_Power:
2350 return m_leds [0]; 2350 return m_leds [0];
2351 //case Led_Mail: 2351 //case Led_Mail:
2352 //return m_leds [1]; 2352 //return m_leds [1];
2353 default: 2353 default:
2354 return Led_Off; 2354 return Led_Off;
2355 } 2355 }
2356} 2356}
2357 2357
2358bool SIMpad::setLedState ( OLed l, OLedState st ) 2358bool SIMpad::setLedState ( OLed l, OLedState st )
2359{ 2359{
2360 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 2360 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
2361 2361
2362 if ( l == Led_Power ) { 2362 if ( l == Led_Power ) {
2363 if ( fd >= 0 ) { 2363 if ( fd >= 0 ) {
2364 LED_IN leds; 2364 LED_IN leds;
2365 ::memset ( &leds, 0, sizeof( leds )); 2365 ::memset ( &leds, 0, sizeof( leds ));
2366 leds. TotalTime = 0; 2366 leds. TotalTime = 0;
2367 leds. OnTime = 0; 2367 leds. OnTime = 0;
2368 leds. OffTime = 1; 2368 leds. OffTime = 1;
2369 leds. OffOnBlink = 2; 2369 leds. OffOnBlink = 2;
2370 2370
2371 switch ( st ) { 2371 switch ( st ) {
2372 case Led_Off : leds. OffOnBlink = 0; break; 2372 case Led_Off : leds. OffOnBlink = 0; break;
2373 case Led_On : leds. OffOnBlink = 1; break; 2373 case Led_On : leds. OffOnBlink = 1; break;
2374 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 2374 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
2375 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 2375 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
2376 } 2376 }
2377 2377
2378 { 2378 {
2379 /*TODO Implement this like that: 2379 /*TODO Implement this like that:
2380 read from cs3 2380 read from cs3
2381 && with SIMPAD_LED2_ON 2381 && with SIMPAD_LED2_ON
2382 write to cs3 */ 2382 write to cs3 */
2383 m_leds [0] = st; 2383 m_leds [0] = st;
2384 return true; 2384 return true;
2385 } 2385 }
2386 } 2386 }
2387 } 2387 }
2388 return false; 2388 return false;
2389} 2389}
2390 2390
2391 2391
2392bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 2392bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
2393{ 2393{
2394 //TODO 2394 //TODO
2395 return false; 2395 return false;
2396} 2396}
2397 2397
2398void SIMpad::timerEvent ( QTimerEvent * ) 2398void SIMpad::timerEvent ( QTimerEvent * )
2399{ 2399{
2400 killTimer ( m_power_timer ); 2400 killTimer ( m_power_timer );
2401 m_power_timer = 0; 2401 m_power_timer = 0;
2402 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 2402 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
2403 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 2403 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
2404} 2404}
2405 2405
2406 2406
2407void SIMpad::alarmSound ( ) 2407void SIMpad::alarmSound ( )
2408{ 2408{
2409#ifndef QT_NO_SOUND 2409#ifndef QT_NO_SOUND
2410 static Sound snd ( "alarm" ); 2410 static Sound snd ( "alarm" );
2411 int fd; 2411 int fd;
2412 int vol; 2412 int vol;
2413 bool vol_reset = false; 2413 bool vol_reset = false;
2414 2414
2415 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 2415 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
2416 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 2416 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
2417 Config cfg ( "qpe" ); 2417 Config cfg ( "qpe" );
2418 cfg. setGroup ( "Volume" ); 2418 cfg. setGroup ( "Volume" );
2419 2419
2420 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 2420 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
2421 if ( volalarm < 0 ) 2421 if ( volalarm < 0 )
2422 volalarm = 0; 2422 volalarm = 0;
2423 else if ( volalarm > 100 ) 2423 else if ( volalarm > 100 )
2424 volalarm = 100; 2424 volalarm = 100;
2425 volalarm |= ( volalarm << 8 ); 2425 volalarm |= ( volalarm << 8 );
2426 2426
2427 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 2427 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
2428 vol_reset = true; 2428 vol_reset = true;
2429 } 2429 }
2430 } 2430 }
2431 2431
2432 snd. play ( ); 2432 snd. play ( );
2433 while ( !snd. isFinished ( )) 2433 while ( !snd. isFinished ( ))
2434 qApp-> processEvents ( ); 2434 qApp-> processEvents ( );
2435 2435
2436 if ( fd >= 0 ) { 2436 if ( fd >= 0 ) {
2437 if ( vol_reset ) 2437 if ( vol_reset )
2438 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 2438 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
2439 ::close ( fd ); 2439 ::close ( fd );
2440 } 2440 }
2441#endif 2441#endif
2442} 2442}
2443 2443
2444 2444
2445bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 2445bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
2446{ 2446{
2447 qDebug( "ODevice for SIMpad: suspend()" ); 2447 qDebug( "ODevice for SIMpad: suspend()" );
2448 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2448 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
2449 return false; 2449 return false;
2450 2450
2451 bool res = false; 2451 bool res = false;
2452 2452
2453 struct timeval tvs, tvn; 2453 struct timeval tvs, tvn;
2454 ::gettimeofday ( &tvs, 0 ); 2454 ::gettimeofday ( &tvs, 0 );
2455 2455
2456 ::sync ( ); // flush fs caches 2456 ::sync ( ); // flush fs caches
2457 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 2457 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
2458 2458
2459 return res; 2459 return res;
2460} 2460}
2461 2461
2462 2462
2463bool SIMpad::setSoftSuspend ( bool soft ) 2463bool SIMpad::setSoftSuspend ( bool soft )
2464{ 2464{
2465 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 2465 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
2466 return false; 2466 return false;
2467} 2467}
2468 2468
2469 2469
2470bool SIMpad::setDisplayStatus ( bool on ) 2470bool SIMpad::setDisplayStatus ( bool on )
2471{ 2471{
2472 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 2472 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
2473 2473
2474 bool res = false; 2474 bool res = false;
2475 int fd; 2475 int fd;
2476 2476
2477 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 2477 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
2478 2478
2479 res = ( ::system( (const char*) cmdline ) == 0 ); 2479 res = ( ::system( (const char*) cmdline ) == 0 );
2480 2480
2481 return res; 2481 return res;
2482} 2482}
2483 2483
2484 2484
2485bool SIMpad::setDisplayBrightness ( int bright ) 2485bool SIMpad::setDisplayBrightness ( int bright )
2486{ 2486{
2487 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 2487 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
2488 bool res = false; 2488 bool res = false;
2489 int fd; 2489 int fd;
2490 2490
2491 if ( bright > 255 ) 2491 if ( bright > 255 )
2492 bright = 255; 2492 bright = 255;
2493 if ( bright < 1 ) 2493 if ( bright < 1 )
@@ -2609,238 +2609,238 @@ bool Ramses::setSoftSuspend(bool soft)
2609 perror("APM_IOCGEVTSRC"); 2609 perror("APM_IOCGEVTSRC");
2610 } 2610 }
2611 else 2611 else
2612 perror("APM_IOCGEVTSRC"); 2612 perror("APM_IOCGEVTSRC");
2613 2613
2614 ::close(fd); 2614 ::close(fd);
2615 } 2615 }
2616 else 2616 else
2617 perror("/dev/apm_bios or /dev/misc/apm_bios"); 2617 perror("/dev/apm_bios or /dev/misc/apm_bios");
2618 2618
2619 return res; 2619 return res;
2620#else 2620#else
2621 return true; 2621 return true;
2622#endif 2622#endif
2623} 2623}
2624 2624
2625bool Ramses::suspend ( ) 2625bool Ramses::suspend ( )
2626{ 2626{
2627 qDebug("Ramses::suspend"); 2627 qDebug("Ramses::suspend");
2628 return false; 2628 return false;
2629} 2629}
2630 2630
2631/** 2631/**
2632 * This sets the display on or off 2632 * This sets the display on or off
2633 */ 2633 */
2634bool Ramses::setDisplayStatus(bool on) 2634bool Ramses::setDisplayStatus(bool on)
2635{ 2635{
2636 qDebug("Ramses::setDisplayStatus(%d)", on); 2636 qDebug("Ramses::setDisplayStatus(%d)", on);
2637#if 0 2637#if 0
2638 bool res = false; 2638 bool res = false;
2639 int fd; 2639 int fd;
2640 2640
2641 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 2641 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2642 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 2642 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2643 ::close(fd); 2643 ::close(fd);
2644 } 2644 }
2645 return res; 2645 return res;
2646#else 2646#else
2647 return true; 2647 return true;
2648#endif 2648#endif
2649} 2649}
2650 2650
2651 2651
2652/* 2652/*
2653 * We get something between 0..255 into us 2653 * We get something between 0..255 into us
2654*/ 2654*/
2655bool Ramses::setDisplayBrightness(int bright) 2655bool Ramses::setDisplayBrightness(int bright)
2656{ 2656{
2657 qDebug("Ramses::setDisplayBrightness(%d)", bright); 2657 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2658 bool res = false; 2658 bool res = false;
2659 int fd; 2659 int fd;
2660 2660
2661 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 2661 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2662 2662
2663 if (bright > 255 ) 2663 if (bright > 255 )
2664 bright = 255; 2664 bright = 255;
2665 if (bright < 0) 2665 if (bright < 0)
2666 bright = 0; 2666 bright = 0;
2667 2667
2668 // Turn backlight completely off 2668 // Turn backlight completely off
2669 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 2669 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
2670 char writeCommand[10]; 2670 char writeCommand[10];
2671 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 2671 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
2672 res = (::write(fd, writeCommand, count) != -1); 2672 res = (::write(fd, writeCommand, count) != -1);
2673 ::close(fd); 2673 ::close(fd);
2674 } 2674 }
2675 2675
2676 // scale backlight brightness to hardware 2676 // scale backlight brightness to hardware
2677 bright = 500-(bright * 500 / 255); 2677 bright = 500-(bright * 500 / 255);
2678 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { 2678 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2679 qDebug(" %d -> pwm1", bright); 2679 qDebug(" %d -> pwm1", bright);
2680 char writeCommand[100]; 2680 char writeCommand[100];
2681 const int count = sprintf(writeCommand, "%d\n", bright); 2681 const int count = sprintf(writeCommand, "%d\n", bright);
2682 res = (::write(fd, writeCommand, count) != -1); 2682 res = (::write(fd, writeCommand, count) != -1);
2683 ::close(fd); 2683 ::close(fd);
2684 } 2684 }
2685 return res; 2685 return res;
2686} 2686}
2687 2687
2688 2688
2689int Ramses::displayBrightnessResolution() const 2689int Ramses::displayBrightnessResolution() const
2690{ 2690{
2691 return 32; 2691 return 32;
2692} 2692}
2693 2693
2694bool Ramses::setDisplayContrast(int contr) 2694bool Ramses::setDisplayContrast(int contr)
2695{ 2695{
2696 qDebug("Ramses::setDisplayContrast(%d)", contr); 2696 qDebug("Ramses::setDisplayContrast(%d)", contr);
2697 bool res = false; 2697 bool res = false;
2698 int fd; 2698 int fd;
2699 2699
2700 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 2700 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
2701 2701
2702 if (contr > 255 ) 2702 if (contr > 255 )
2703 contr = 255; 2703 contr = 255;
2704 if (contr < 0) 2704 if (contr < 0)
2705 contr = 0; 2705 contr = 0;
2706 contr = 90 - (contr * 20 / 255); 2706 contr = 90 - (contr * 20 / 255);
2707 2707
2708 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { 2708 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2709 qDebug(" %d -> pwm0", contr); 2709 qDebug(" %d -> pwm0", contr);
2710 char writeCommand[100]; 2710 char writeCommand[100];
2711 const int count = sprintf(writeCommand, "%d\n", contr); 2711 const int count = sprintf(writeCommand, "%d\n", contr);
2712 res = (::write(fd, writeCommand, count) != -1); 2712 res = (::write(fd, writeCommand, count) != -1);
2713 res = true; 2713 res = true;
2714 ::close(fd); 2714 ::close(fd);
2715 } 2715 }
2716 return res; 2716 return res;
2717} 2717}
2718 2718
2719 2719
2720int Ramses::displayContrastResolution() const 2720int Ramses::displayContrastResolution() const
2721{ 2721{
2722 return 20; 2722 return 20;
2723} 2723}
2724 2724
2725 2725
2726/************************************************** 2726/**************************************************
2727 * * 2727 * *
2728 * Jornada * 2728 * Jornada *
2729 * * 2729 * *
2730 **************************************************/ 2730 **************************************************/
2731 2731
2732 2732
2733bool Jornada::isJornada ( ) 2733bool Jornada::isJornada ( )
2734{ 2734{
2735 QFile f( "/proc/cpuinfo" ); 2735 QFile f( "/proc/cpuinfo" );
2736 if ( f. open ( IO_ReadOnly ) ) { 2736 if ( f. open ( IO_ReadOnly ) ) {
2737 QTextStream ts ( &f ); 2737 QTextStream ts ( &f );
2738 QString line; 2738 QString line;
2739 while( line = ts. readLine ( ) ) { 2739 while( line = ts. readLine ( ) ) {
2740 if ( line. left ( 8 ) == "Hardware" ) { 2740 if ( line. left ( 8 ) == "Hardware" ) {
2741 int loc = line. find ( ":" ); 2741 int loc = line. find ( ":" );
2742 if ( loc != -1 ) { 2742 if ( loc != -1 ) {
2743 QString model = 2743 QString model =
2744 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 2744 line. mid ( loc + 2 ). simplifyWhiteSpace( );
2745 return ( model == "HP Jornada 56x" ); 2745 return ( model == "HP Jornada 56x" );
2746 } 2746 }
2747 } 2747 }
2748 } 2748 }
2749 } 2749 }
2750 return false; 2750 return false;
2751} 2751}
2752 2752
2753void Jornada::init ( ) 2753void Jornada::init ( )
2754{ 2754{
2755 d-> m_vendorstr = "HP"; 2755 d-> m_vendorstr = "HP";
2756 d-> m_vendor = Vendor_HP; 2756 d-> m_vendor = Vendor_HP;
2757 d-> m_modelstr = "Jornada 56x"; 2757 d-> m_modelstr = "Jornada 56x";
2758 d-> m_model = Model_Jornada_56x; 2758 d-> m_model = Model_Jornada_56x;
2759 d-> m_systemstr = "Familiar"; 2759 d-> m_systemstr = "Familiar";
2760 d-> m_system = System_Familiar; 2760 d-> m_system = System_Familiar;
2761 d-> m_rotation = Rot0; 2761 d-> m_rotation = Rot0;
2762 2762
2763 QFile f ( "/etc/familiar-version" ); 2763 QFile f ( "/etc/familiar-version" );
2764 f. setName ( "/etc/familiar-version" ); 2764 f. setName ( "/etc/familiar-version" );
2765 if ( f. open ( IO_ReadOnly )) { 2765 if ( f. open ( IO_ReadOnly )) {
2766 2766
2767 QTextStream ts ( &f ); 2767 QTextStream ts ( &f );
2768 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 2768 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
2769 2769
2770 f. close ( ); 2770 f. close ( );
2771 } 2771 }
2772} 2772}
2773 2773
2774#if 0 2774#if 0
2775void Jornada::initButtons ( ) 2775void Jornada::initButtons ( )
2776{ 2776{
2777 if ( d-> m_buttons ) 2777 if ( d-> m_buttons )
2778 return; 2778 return;
2779 2779
2780 // Simulation uses iPAQ 3660 device buttons 2780 // Simulation uses iPAQ 3660 device buttons
2781 2781
2782 qDebug ( "init Buttons" ); 2782 qDebug ( "init Buttons" );
2783 d-> m_buttons = new QValueList <ODeviceButton>; 2783 d-> m_buttons = new QValueList <ODeviceButton>;
2784 2784
2785 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 2785 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
2786 i_button *ib = ipaq_buttons + i; 2786 i_button *ib = ipaq_buttons + i;
2787 ODeviceButton b; 2787 ODeviceButton b;
2788 2788
2789 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 2789 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
2790 b. setKeycode ( ib-> code ); 2790 b. setKeycode ( ib-> code );
2791 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 2791 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
2792 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 2792 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
2793 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 2793 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
2794 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 2794 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
2795 d-> m_buttons-> append ( b ); 2795 d-> m_buttons-> append ( b );
2796 } 2796 }
2797 } 2797 }
2798 reloadButtonMapping ( ); 2798 reloadButtonMapping ( );
2799 2799
2800 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 2800 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
2801 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 2801 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
2802} 2802}
2803#endif 2803#endif
2804int Jornada::displayBrightnessResolution ( ) const 2804int Jornada::displayBrightnessResolution ( ) const
2805{ 2805{
2806} 2806}
2807 2807
2808bool Jornada::setDisplayBrightness ( int bright ) 2808bool Jornada::setDisplayBrightness ( int bright )
2809{ 2809{
2810 bool res = false; 2810 bool res = false;
2811 int fd; 2811 int fd;
2812 2812
2813 if ( bright > 255 ) 2813 if ( bright > 255 )
2814 bright = 255; 2814 bright = 255;
2815 if ( bright < 0 ) 2815 if ( bright < 0 )
2816 bright = 0; 2816 bright = 0;
2817 2817
2818 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 2818 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
2819 FLITE_IN bl; 2819 FLITE_IN bl;
2820 bl. mode = 1; 2820 bl. mode = 1;
2821 bl. pwr = bright ? 1 : 0; 2821 bl. pwr = bright ? 1 : 0;
2822 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 2822 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
2823 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 2823 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
2824 ::close ( fd ); 2824 ::close ( fd );
2825 } 2825 }
2826 return res; 2826 return res;
2827} 2827}
2828 2828
2829bool Jornada::setSoftSuspend ( bool soft ) 2829bool Jornada::setSoftSuspend ( bool soft )
2830{ 2830{
2831 bool res = false; 2831 bool res = false;
2832 int fd; 2832 int fd;
2833 2833
2834 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 2834 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
2835 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 2835 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
2836 res = true; 2836 res = true;
2837 else 2837 else
2838 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 2838 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
2839 2839
2840 ::close ( fd ); 2840 ::close ( fd );
2841 } 2841 }
2842 else 2842 else
2843 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 2843 ::perror ( "/proc/sys/ts/suspend_button_mode" );
2844 2844
2845 return res; 2845 return res;
2846} 2846}
diff --git a/libopie/ofileselector.cpp b/libopie/ofileselector.cpp
index 1ba94ae..2a6aed0 100644
--- a/libopie/ofileselector.cpp
+++ b/libopie/ofileselector.cpp
@@ -1,584 +1,584 @@
1#include <qcombobox.h> 1#include <qcombobox.h>
2#include <qdir.h> 2#include <qdir.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <qpopupmenu.h> 6#include <qpopupmenu.h>
7#include <qwidgetstack.h> 7#include <qwidgetstack.h>
8 8
9/* hacky but we need to get FileSelector::filter */ 9/* hacky but we need to get FileSelector::filter */
10#define private public 10#define private public
11#include <qpe/fileselector.h> 11#include <qpe/fileselector.h>
12#undef private 12#undef private
13 13
14#include <qpe/qpeapplication.h> 14#include <qpe/qpeapplication.h>
15#include <qpe/mimetype.h> 15#include <qpe/mimetype.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/storage.h> 17#include <qpe/storage.h>
18 18
19#include "ofileselector_p.h" 19#include "ofileselector_p.h"
20#include "ofileselector.h" 20#include "ofileselector.h"
21 21
22 22
23 23
24OFileViewInterface::OFileViewInterface( OFileSelector* selector ) 24OFileViewInterface::OFileViewInterface( OFileSelector* selector )
25 : m_selector( selector ) { 25 : m_selector( selector ) {
26} 26}
27OFileViewInterface::~OFileViewInterface() { 27OFileViewInterface::~OFileViewInterface() {
28} 28}
29QString OFileViewInterface::name()const{ 29QString OFileViewInterface::name()const{
30 return m_name; 30 return m_name;
31} 31}
32void OFileViewInterface::setName( const QString& name ) { 32void OFileViewInterface::setName( const QString& name ) {
33 m_name = name; 33 m_name = name;
34} 34}
35OFileSelector* OFileViewInterface::selector()const { 35OFileSelector* OFileViewInterface::selector()const {
36 return m_selector; 36 return m_selector;
37} 37}
38DocLnk OFileViewInterface::selectedDocument()const { 38DocLnk OFileViewInterface::selectedDocument()const {
39 return DocLnk( selectedName() ); 39 return DocLnk( selectedName() );
40} 40}
41bool OFileViewInterface::showNew()const { 41bool OFileViewInterface::showNew()const {
42 return selector()->showNew(); 42 return selector()->showNew();
43} 43}
44bool OFileViewInterface::showClose()const { 44bool OFileViewInterface::showClose()const {
45 return selector()->showClose(); 45 return selector()->showClose();
46} 46}
47MimeTypes OFileViewInterface::mimeTypes()const { 47MimeTypes OFileViewInterface::mimeTypes()const {
48 return selector()->mimeTypes(); 48 return selector()->mimeTypes();
49} 49}
50QStringList OFileViewInterface::currentMimeType()const { 50QStringList OFileViewInterface::currentMimeType()const {
51 return selector()->currentMimeType(); 51 return selector()->currentMimeType();
52} 52}
53void OFileViewInterface::activate( const QString& ) { 53void OFileViewInterface::activate( const QString& ) {
54 // not implemented here 54 // not implemented here
55} 55}
56void OFileViewInterface::ok() { 56void OFileViewInterface::ok() {
57 emit selector()->ok(); 57 emit selector()->ok();
58} 58}
59void OFileViewInterface::cancel() { 59void OFileViewInterface::cancel() {
60 emit selector()->cancel(); 60 emit selector()->cancel();
61} 61}
62void OFileViewInterface::closeMe() { 62void OFileViewInterface::closeMe() {
63 emit selector()->closeMe(); 63 emit selector()->closeMe();
64} 64}
65void OFileViewInterface::fileSelected( const QString& str) { 65void OFileViewInterface::fileSelected( const QString& str) {
66 emit selector()->fileSelected( str); 66 emit selector()->fileSelected( str);
67} 67}
68void OFileViewInterface::fileSelected( const DocLnk& lnk) { 68void OFileViewInterface::fileSelected( const DocLnk& lnk) {
69 emit selector()->fileSelected( lnk ); 69 emit selector()->fileSelected( lnk );
70} 70}
71void OFileViewInterface::setCurrentFileName( const QString& str ) { 71void OFileViewInterface::setCurrentFileName( const QString& str ) {
72 selector()->m_lneEdit->setText( str ); 72 selector()->m_lneEdit->setText( str );
73} 73}
74QString OFileViewInterface::currentFileName()const{ 74QString OFileViewInterface::currentFileName()const{
75 return selector()->m_lneEdit->text(); 75 return selector()->m_lneEdit->text();
76} 76}
77QString OFileViewInterface::startDirectory()const{ 77QString OFileViewInterface::startDirectory()const{
78 return selector()->m_startDir; 78 return selector()->m_startDir;
79} 79}
80 80
81 81
82ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 82ODocumentFileView::ODocumentFileView( OFileSelector* selector )
83 : OFileViewInterface( selector ) { 83 : OFileViewInterface( selector ) {
84 m_selector = 0; 84 m_selector = 0;
85 setName( QObject::tr("Documents") ); 85 setName( QObject::tr("Documents") );
86} 86}
87ODocumentFileView::~ODocumentFileView() { 87ODocumentFileView::~ODocumentFileView() {
88 88
89} 89}
90QString ODocumentFileView::selectedName()const { 90QString ODocumentFileView::selectedName()const {
91 if (!m_selector) 91 if (!m_selector)
92 return QString::null; 92 return QString::null;
93 93
94 return m_selector->selectedDocument().file(); 94 return m_selector->selectedDocument().file();
95} 95}
96QString ODocumentFileView::selectedPath()const { 96QString ODocumentFileView::selectedPath()const {
97 return QPEApplication::documentDir(); 97 return QPEApplication::documentDir();
98} 98}
99QString ODocumentFileView::directory()const { 99QString ODocumentFileView::directory()const {
100 return selectedPath(); 100 return selectedPath();
101} 101}
102void ODocumentFileView::reread() { 102void ODocumentFileView::reread() {
103 if (!m_selector) 103 if (!m_selector)
104 return; 104 return;
105 105
106 m_selector->setNewVisible( showNew() ); 106 m_selector->setNewVisible( showNew() );
107 m_selector->setCloseVisible( showClose() ); 107 m_selector->setCloseVisible( showClose() );
108 m_selector->filter = currentMimeType().join(";"); 108 m_selector->filter = currentMimeType().join(";");
109 m_selector->reread(); 109 m_selector->reread();
110} 110}
111int ODocumentFileView::fileCount()const { 111int ODocumentFileView::fileCount()const {
112 if (!m_selector) 112 if (!m_selector)
113 return -1; 113 return -1;
114 114
115 return m_selector->fileCount(); 115 return m_selector->fileCount();
116} 116}
117DocLnk ODocumentFileView::selectedDocument()const { 117DocLnk ODocumentFileView::selectedDocument()const {
118 if (!m_selector) 118 if (!m_selector)
119 return DocLnk(); 119 return DocLnk();
120 120
121 return m_selector->selectedDocument(); 121 return m_selector->selectedDocument();
122} 122}
123QWidget* ODocumentFileView::widget( QWidget* parent ) { 123QWidget* ODocumentFileView::widget( QWidget* parent ) {
124 if (!m_selector ) { 124 if (!m_selector ) {
125 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 125 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
126 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), 126 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ),
127 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 127 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
128 QObject::connect(m_selector, SIGNAL(closeMe() ), 128 QObject::connect(m_selector, SIGNAL(closeMe() ),
129 selector(), SIGNAL(closeMe() ) ); 129 selector(), SIGNAL(closeMe() ) );
130 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), 130 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ),
131 selector(), SIGNAL(newSelected(const DocLnk& ) ) ); 131 selector(), SIGNAL(newSelected(const DocLnk&) ) );
132 } 132 }
133 133
134 return m_selector; 134 return m_selector;
135} 135}
136 136
137/* 137/*
138 * This is the file system view used 138 * This is the file system view used
139 * we use a QListView + QListViewItems for it 139 * we use a QListView + QListViewItems for it
140 */ 140 */
141 141
142OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 142OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
143 const QString& path, const QString& date, 143 const QString& path, const QString& date,
144 const QString& size, const QString& dir, 144 const QString& size, const QString& dir,
145 bool isLocked, bool isDir ) 145 bool isLocked, bool isDir )
146 : QListViewItem( view ) 146 : QListViewItem( view )
147{ 147{
148 setPixmap(0, pixmap ); 148 setPixmap(0, pixmap );
149 setText(1, path ); 149 setText(1, path );
150 setText(2, size ); 150 setText(2, size );
151 setText(3, date ); 151 setText(3, date );
152 m_isDir = isDir; 152 m_isDir = isDir;
153 m_dir = dir; 153 m_dir = dir;
154 m_locked = isLocked; 154 m_locked = isLocked;
155} 155}
156OFileSelectorItem::~OFileSelectorItem() { 156OFileSelectorItem::~OFileSelectorItem() {
157 157
158} 158}
159bool OFileSelectorItem::isLocked()const { 159bool OFileSelectorItem::isLocked()const {
160 return m_locked; 160 return m_locked;
161} 161}
162QString OFileSelectorItem::directory()const { 162QString OFileSelectorItem::directory()const {
163 return m_dir; 163 return m_dir;
164} 164}
165bool OFileSelectorItem::isDir()const { 165bool OFileSelectorItem::isDir()const {
166 return m_isDir; 166 return m_isDir;
167} 167}
168QString OFileSelectorItem::path()const { 168QString OFileSelectorItem::path()const {
169 return text( 1 ); 169 return text( 1 );
170} 170}
171QString OFileSelectorItem::key( int id, bool )const { 171QString OFileSelectorItem::key( int id, bool )const {
172 QString ke; 172 QString ke;
173 if( id == 0 || id == 1 ){ // name 173 if( id == 0 || id == 1 ){ // name
174 if( m_isDir ){ 174 if( m_isDir ){
175 ke.append("0" ); 175 ke.append("0" );
176 ke.append( text(1) ); 176 ke.append( text(1) );
177 }else{ 177 }else{
178 ke.append("1" ); 178 ke.append("1" );
179 ke.append( text(1) ); 179 ke.append( text(1) );
180 } 180 }
181 return ke; 181 return ke;
182 }else 182 }else
183 return text( id ); 183 return text( id );
184 184
185} 185}
186 186
187OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, 187OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir,
188 OFileSelector* sel) 188 OFileSelector* sel)
189 : QWidget( parent ), m_sel( sel ) { 189 : QWidget( parent ), m_sel( sel ) {
190 m_all = false; 190 m_all = false;
191 QVBoxLayout* lay = new QVBoxLayout( this ); 191 QVBoxLayout* lay = new QVBoxLayout( this );
192 m_currentDir = startDir; 192 m_currentDir = startDir;
193 193
194 /* 194 /*
195 * now we add a special bar 195 * now we add a special bar
196 * One Button For Up 196 * One Button For Up
197 * Home 197 * Home
198 * Doc 198 * Doc
199 * And a dropdown menu with FileSystems 199 * And a dropdown menu with FileSystems
200 * FUTURE: one to change dir with lineedit 200 * FUTURE: one to change dir with lineedit
201 * Bookmarks 201 * Bookmarks
202 * Create Dir 202 * Create Dir
203 */ 203 */
204 QHBox* box = new QHBox(this ); 204 QHBox* box = new QHBox(this );
205 box->setBackgroundMode( PaletteButton ); 205 box->setBackgroundMode( PaletteButton );
206 box->setSpacing( 0 ); 206 box->setSpacing( 0 );
207 207
208 QToolButton *btn = new QToolButton( box ); 208 QToolButton *btn = new QToolButton( box );
209 btn->setIconSet( Resource::loadIconSet("up") ); 209 btn->setIconSet( Resource::loadIconSet("up") );
210 connect(btn, SIGNAL(clicked() ), 210 connect(btn, SIGNAL(clicked() ),
211 this, SLOT( cdUP() ) ); 211 this, SLOT( cdUP() ) );
212 212
213 btn = new QToolButton( box ); 213 btn = new QToolButton( box );
214 btn->setIconSet( Resource::loadIconSet("home") ); 214 btn->setIconSet( Resource::loadIconSet("home") );
215 connect(btn, SIGNAL(clicked() ), 215 connect(btn, SIGNAL(clicked() ),
216 this, SLOT( cdHome() ) ); 216 this, SLOT( cdHome() ) );
217 217
218 btn = new QToolButton( box ); 218 btn = new QToolButton( box );
219 btn->setIconSet( Resource::loadIconSet("DocsIcon") ); 219 btn->setIconSet( Resource::loadIconSet("DocsIcon") );
220 connect(btn, SIGNAL(clicked() ), 220 connect(btn, SIGNAL(clicked() ),
221 this, SLOT(cdDoc() ) ); 221 this, SLOT(cdDoc() ) );
222 222
223 m_btnNew = new QToolButton( box ); 223 m_btnNew = new QToolButton( box );
224 m_btnNew->setIconSet( Resource::loadIconSet("new") ); 224 m_btnNew->setIconSet( Resource::loadIconSet("new") );
225 connect(m_btnNew, SIGNAL(clicked() ), 225 connect(m_btnNew, SIGNAL(clicked() ),
226 this, SLOT(slotNew() ) ); 226 this, SLOT(slotNew() ) );
227 227
228 228
229 m_btnClose = new QToolButton( box ); 229 m_btnClose = new QToolButton( box );
230 m_btnClose->setIconSet( Resource::loadIconSet("close") ); 230 m_btnClose->setIconSet( Resource::loadIconSet("close") );
231 connect(m_btnClose, SIGNAL(clicked() ), 231 connect(m_btnClose, SIGNAL(clicked() ),
232 selector(), SIGNAL(closeMe() ) ); 232 selector(), SIGNAL(closeMe() ) );
233 233
234 btn = new QToolButton( box ); 234 btn = new QToolButton( box );
235 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); 235 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") );
236 236
237 /* let's fill device parts */ 237 /* let's fill device parts */
238 QPopupMenu* pop = new QPopupMenu(this); 238 QPopupMenu* pop = new QPopupMenu(this);
239 connect(pop, SIGNAL( activated(int) ), 239 connect(pop, SIGNAL( activated(int) ),
240 this, SLOT(slotFSActivated(int) ) ); 240 this, SLOT(slotFSActivated(int) ) );
241 241
242 StorageInfo storage; 242 StorageInfo storage;
243 const QList<FileSystem> &fs = storage.fileSystems(); 243 const QList<FileSystem> &fs = storage.fileSystems();
244 QListIterator<FileSystem> it(fs); 244 QListIterator<FileSystem> it(fs);
245 for ( ; it.current(); ++it ) { 245 for ( ; it.current(); ++it ) {
246 const QString disk = (*it)->name(); 246 const QString disk = (*it)->name();
247 const QString path = (*it)->path(); 247 const QString path = (*it)->path();
248 m_dev.insert( disk, path ); 248 m_dev.insert( disk, path );
249 pop->insertItem( disk ); 249 pop->insertItem( disk );
250 } 250 }
251 m_fsPop = pop; 251 m_fsPop = pop;
252 252
253 253
254 btn->setPopup( pop ); 254 btn->setPopup( pop );
255 255
256 lay->addWidget( box ); 256 lay->addWidget( box );
257 257
258 m_view = new QListView( this ); 258 m_view = new QListView( this );
259 259
260 m_view->installEventFilter(this); 260 m_view->installEventFilter(this);
261 261
262 QPEApplication::setStylusOperation( m_view->viewport(), 262 QPEApplication::setStylusOperation( m_view->viewport(),
263 QPEApplication::RightOnHold); 263 QPEApplication::RightOnHold);
264 m_view->addColumn(" " ); 264 m_view->addColumn(" " );
265 m_view->addColumn(tr("Name"), 135 ); 265 m_view->addColumn(tr("Name"), 135 );
266 m_view->addColumn(tr("Size"), -1 ); 266 m_view->addColumn(tr("Size"), -1 );
267 m_view->addColumn(tr("Date"), 60 ); 267 m_view->addColumn(tr("Date"), 60 );
268 m_view->addColumn(tr("Mime Type"), -1 ); 268 m_view->addColumn(tr("Mime Type"), -1 );
269 269
270 270
271 m_view->setSorting( 1 ); 271 m_view->setSorting( 1 );
272 m_view->setAllColumnsShowFocus( TRUE ); 272 m_view->setAllColumnsShowFocus( TRUE );
273 273
274 lay->addWidget( m_view, 1000 ); 274 lay->addWidget( m_view, 1000 );
275 connectSlots(); 275 connectSlots();
276} 276}
277OFileViewFileListView::~OFileViewFileListView() { 277OFileViewFileListView::~OFileViewFileListView() {
278} 278}
279void OFileViewFileListView::slotNew() { 279void OFileViewFileListView::slotNew() {
280 DocLnk lnk; 280 DocLnk lnk;
281 emit selector()->newSelected( lnk ); 281 emit selector()->newSelected( lnk );
282} 282}
283OFileSelectorItem* OFileViewFileListView::currentItem()const{ 283OFileSelectorItem* OFileViewFileListView::currentItem()const{
284 QListViewItem* item = m_view->currentItem(); 284 QListViewItem* item = m_view->currentItem();
285 if (!item ) 285 if (!item )
286 return 0l; 286 return 0l;
287 287
288 return static_cast<OFileSelectorItem*>(item); 288 return static_cast<OFileSelectorItem*>(item);
289} 289}
290void OFileViewFileListView::reread( bool all ) { 290void OFileViewFileListView::reread( bool all ) {
291 m_view->clear(); 291 m_view->clear();
292 292
293 if (selector()->showClose() ) 293 if (selector()->showClose() )
294 m_btnClose->show(); 294 m_btnClose->show();
295 else 295 else
296 m_btnClose->hide(); 296 m_btnClose->hide();
297 297
298 if (selector()->showNew() ) 298 if (selector()->showNew() )
299 m_btnNew->show(); 299 m_btnNew->show();
300 else 300 else
301 m_btnNew->hide(); 301 m_btnNew->hide();
302 302
303 m_mimes = selector()->currentMimeType(); 303 m_mimes = selector()->currentMimeType();
304 m_all = all; 304 m_all = all;
305 305
306 QDir dir( m_currentDir ); 306 QDir dir( m_currentDir );
307 if (!dir.exists() ) 307 if (!dir.exists() )
308 return; 308 return;
309 309
310 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 310 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
311 int filter; 311 int filter;
312 if (m_all ) 312 if (m_all )
313 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 313 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
314 else 314 else
315 filter = QDir::Files | QDir::Dirs | QDir::All; 315 filter = QDir::Files | QDir::Dirs | QDir::All;
316 dir.setFilter( filter ); 316 dir.setFilter( filter );
317 317
318 // now go through all files 318 // now go through all files
319 const QFileInfoList *list = dir.entryInfoList(); 319 const QFileInfoList *list = dir.entryInfoList();
320 if (!list) { 320 if (!list) {
321 cdUP(); 321 cdUP();
322 return; 322 return;
323 } 323 }
324 QFileInfoListIterator it( *list ); 324 QFileInfoListIterator it( *list );
325 QFileInfo *fi; 325 QFileInfo *fi;
326 while( (fi=it.current() ) ){ 326 while( (fi=it.current() ) ){
327 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ 327 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
328 ++it; 328 ++it;
329 continue; 329 continue;
330 } 330 }
331 331
332 /* 332 /*
333 * It is a symlink we try to resolve it now but don't let us attack by DOS 333 * It is a symlink we try to resolve it now but don't let us attack by DOS
334 * 334 *
335 */ 335 */
336 if( fi->isSymLink() ){ 336 if( fi->isSymLink() ){
337 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 337 QString file = fi->dirPath( true ) + "/" + fi->readLink();
338 for( int i = 0; i<=4; i++) { // 5 tries to prevent dos 338 for( int i = 0; i<=4; i++) { // 5 tries to prevent dos
339 QFileInfo info( file ); 339 QFileInfo info( file );
340 if( !info.exists() ){ 340 if( !info.exists() ){
341 addSymlink( fi, TRUE ); 341 addSymlink( fi, TRUE );
342 break; 342 break;
343 }else if( info.isDir() ){ 343 }else if( info.isDir() ){
344 addDir( fi, TRUE ); 344 addDir( fi, TRUE );
345 break; 345 break;
346 }else if( info.isFile() ){ 346 }else if( info.isFile() ){
347 addFile( fi, TRUE ); 347 addFile( fi, TRUE );
348 break; 348 break;
349 }else if( info.isSymLink() ){ 349 }else if( info.isSymLink() ){
350 file = info.dirPath(true ) + "/" + info.readLink() ; 350 file = info.dirPath(true ) + "/" + info.readLink() ;
351 break; 351 break;
352 }else if( i == 4){ // couldn't resolve symlink add it as symlink 352 }else if( i == 4){ // couldn't resolve symlink add it as symlink
353 addSymlink( fi ); 353 addSymlink( fi );
354 } 354 }
355 } // off for loop for symlink resolving 355 } // off for loop for symlink resolving
356 }else if( fi->isDir() ) 356 }else if( fi->isDir() )
357 addDir( fi ); 357 addDir( fi );
358 else if( fi->isFile() ) 358 else if( fi->isFile() )
359 addFile( fi ); 359 addFile( fi );
360 360
361 ++it; 361 ++it;
362 } // of while loop 362 } // of while loop
363 m_view->sort(); 363 m_view->sort();
364 364
365} 365}
366int OFileViewFileListView::fileCount()const{ 366int OFileViewFileListView::fileCount()const{
367 return m_view->childCount(); 367 return m_view->childCount();
368} 368}
369QString OFileViewFileListView::currentDir()const{ 369QString OFileViewFileListView::currentDir()const{
370 return m_currentDir; 370 return m_currentDir;
371} 371}
372OFileSelector* OFileViewFileListView::selector() { 372OFileSelector* OFileViewFileListView::selector() {
373 return m_sel; 373 return m_sel;
374} 374}
375 375
376bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { 376bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) {
377 if ( e->type() == QEvent::KeyPress ) { 377 if ( e->type() == QEvent::KeyPress ) {
378 QKeyEvent *k = (QKeyEvent *)e; 378 QKeyEvent *k = (QKeyEvent *)e;
379 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { 379 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) {
380 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 380 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
381 return true; 381 return true;
382 } 382 }
383 } 383 }
384 return false; 384 return false;
385} 385}
386 386
387 387
388void OFileViewFileListView::connectSlots() { 388void OFileViewFileListView::connectSlots() {
389 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 389 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
390 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 390 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
391 connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), 391 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
392 this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); 392 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
393} 393}
394void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { 394void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) {
395 if (!item) 395 if (!item)
396 return; 396 return;
397#if 0 397#if 0
398 398
399 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 399 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
400 400
401 if (!sel->isDir() ) { 401 if (!sel->isDir() ) {
402 selector()->m_lneEdit->setText( sel->text(1) ); 402 selector()->m_lneEdit->setText( sel->text(1) );
403 // if in fileselector mode we will emit selected 403 // if in fileselector mode we will emit selected
404 if ( selector()->mode() == OFileSelector::FileSelector ) { 404 if ( selector()->mode() == OFileSelector::FileSelector ) {
405 qWarning("slot Current Changed"); 405 qWarning("slot Current Changed");
406 QStringList str = QStringList::split("->", sel->text(1) ); 406 QStringList str = QStringList::split("->", sel->text(1) );
407 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 407 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
408 emit selector()->fileSelected( path ); 408 emit selector()->fileSelected( path );
409 DocLnk lnk( path ); 409 DocLnk lnk( path );
410 emit selector()->fileSelected( lnk ); 410 emit selector()->fileSelected( lnk );
411 } 411 }
412 } 412 }
413#endif 413#endif
414} 414}
415void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { 415void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) {
416 if (!item || ( button != Qt::LeftButton) ) 416 if (!item || ( button != Qt::LeftButton) )
417 return; 417 return;
418 418
419 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 419 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
420 if (!sel->isLocked() ) { 420 if (!sel->isLocked() ) {
421 QStringList str = QStringList::split("->", sel->text(1) ); 421 QStringList str = QStringList::split("->", sel->text(1) );
422 if (sel->isDir() ) { 422 if (sel->isDir() ) {
423 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 423 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
424 emit selector()->dirSelected( m_currentDir ); 424 emit selector()->dirSelected( m_currentDir );
425 reread( m_all ); 425 reread( m_all );
426 }else { // file 426 }else { // file
427 qWarning("slot Clicked"); 427 qWarning("slot Clicked");
428 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 428 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
429 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 429 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
430 emit selector()->fileSelected( path ); 430 emit selector()->fileSelected( path );
431 DocLnk lnk( path ); 431 DocLnk lnk( path );
432 emit selector()->fileSelected( lnk ); 432 emit selector()->fileSelected( lnk );
433 } 433 }
434 } // not locked 434 } // not locked
435} 435}
436void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { 436void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) {
437 MimeType type( info->absFilePath() ); 437 MimeType type( info->absFilePath() );
438 if (!compliesMime( type.id() ) ) 438 if (!compliesMime( type.id() ) )
439 return; 439 return;
440 440
441 QPixmap pix = type.pixmap(); 441 QPixmap pix = type.pixmap();
442 QString dir, name; bool locked; 442 QString dir, name; bool locked;
443 if ( pix.isNull() ) { 443 if ( pix.isNull() ) {
444 QWMatrix matrix; 444 QWMatrix matrix;
445 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 445 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
446 matrix.scale( .4, .4 ); 446 matrix.scale( .4, .4 );
447 pix = pixer.xForm( matrix ); 447 pix = pixer.xForm( matrix );
448 } 448 }
449 dir = info->dirPath( true ); 449 dir = info->dirPath( true );
450 locked = false; 450 locked = false;
451 if ( symlink ) 451 if ( symlink )
452 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 452 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
453 else{ 453 else{
454 name = info->fileName(); 454 name = info->fileName();
455 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 455 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
456 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { 456 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) {
457 locked = true; pix = Resource::loadPixmap("locked"); 457 locked = true; pix = Resource::loadPixmap("locked");
458 } 458 }
459 } 459 }
460 (void)new OFileSelectorItem( m_view, pix, name, 460 (void)new OFileSelectorItem( m_view, pix, name,
461 info->lastModified().toString(), QString::number( info->size() ), 461 info->lastModified().toString(), QString::number( info->size() ),
462 dir, locked ); 462 dir, locked );
463} 463}
464void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { 464void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) {
465 bool locked = false; QString name; QPixmap pix; 465 bool locked = false; QString name; QPixmap pix;
466 466
467 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 467 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
468 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { 468 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) {
469 locked = true; 469 locked = true;
470 if ( symlink ) 470 if ( symlink )
471 pix = Resource::loadPixmap( "opie/symlink" ); 471 pix = Resource::loadPixmap( "opie/symlink" );
472 else 472 else
473 pix = Resource::loadPixmap( "lockedfolder" ); 473 pix = Resource::loadPixmap( "lockedfolder" );
474 }else 474 }else
475 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); 475 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder");
476 476
477 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : 477 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() :
478 info->fileName(); 478 info->fileName();
479 479
480 (void)new OFileSelectorItem( m_view, pix, name, 480 (void)new OFileSelectorItem( m_view, pix, name,
481 info->lastModified().toString(), 481 info->lastModified().toString(),
482 QString::number( info->size() ), 482 QString::number( info->size() ),
483 info->dirPath( true ), locked, true ); 483 info->dirPath( true ), locked, true );
484 484
485 485
486} 486}
487void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { 487void OFileViewFileListView::addSymlink( QFileInfo* , bool ) {
488 488
489} 489}
490void OFileViewFileListView::cdUP() { 490void OFileViewFileListView::cdUP() {
491 QDir dir( m_currentDir ); 491 QDir dir( m_currentDir );
492 dir.cdUp(); 492 dir.cdUp();
493 493
494 if (!dir.exists() ) 494 if (!dir.exists() )
495 m_currentDir = "/"; 495 m_currentDir = "/";
496 else 496 else
497 m_currentDir = dir.absPath(); 497 m_currentDir = dir.absPath();
498 498
499 emit selector()->dirSelected( m_currentDir ); 499 emit selector()->dirSelected( m_currentDir );
500 reread( m_all ); 500 reread( m_all );
501} 501}
502void OFileViewFileListView::cdHome() { 502void OFileViewFileListView::cdHome() {
503 m_currentDir = QDir::homeDirPath(); 503 m_currentDir = QDir::homeDirPath();
504 emit selector()->dirSelected( m_currentDir ); 504 emit selector()->dirSelected( m_currentDir );
505 reread( m_all ); 505 reread( m_all );
506} 506}
507void OFileViewFileListView::cdDoc() { 507void OFileViewFileListView::cdDoc() {
508 m_currentDir = QPEApplication::documentDir(); 508 m_currentDir = QPEApplication::documentDir();
509 emit selector()->dirSelected( m_currentDir ); 509 emit selector()->dirSelected( m_currentDir );
510 reread( m_all ); 510 reread( m_all );
511} 511}
512void OFileViewFileListView::changeDir( const QString& dir ) { 512void OFileViewFileListView::changeDir( const QString& dir ) {
513 m_currentDir = dir; 513 m_currentDir = dir;
514 emit selector()->dirSelected( m_currentDir ); 514 emit selector()->dirSelected( m_currentDir );
515 reread( m_all ); 515 reread( m_all );
516} 516}
517void OFileViewFileListView::slotFSActivated( int id ) { 517void OFileViewFileListView::slotFSActivated( int id ) {
518 changeDir ( m_dev[m_fsPop->text(id)] ); 518 changeDir ( m_dev[m_fsPop->text(id)] );
519} 519}
520 520
521/* check if the mimetype in mime 521/* check if the mimetype in mime
522 * complies with the one which is current 522 * complies with the one which is current
523 */ 523 */
524/* 524/*
525 * We've the mimetype of the file 525 * We've the mimetype of the file
526 * We need to get the stringlist of the current mimetype 526 * We need to get the stringlist of the current mimetype
527 * 527 *
528 * mime = image@slashjpeg 528 * mime = image@slashjpeg
529 * QStringList = 'image@slash*' 529 * QStringList = 'image@slash*'
530 * or QStringList = image/jpeg;image/png;application/x-ogg 530 * or QStringList = image/jpeg;image/png;application/x-ogg
531 * or QStringList = application/x-ogg;image@slash*; 531 * or QStringList = application/x-ogg;image@slash*;
532 * with all these mime filters it should get acceptes 532 * with all these mime filters it should get acceptes
533 * to do so we need to look if mime is contained inside 533 * to do so we need to look if mime is contained inside
534 * the stringlist 534 * the stringlist
535 * if it's contained return true 535 * if it's contained return true
536 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' 536 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*'
537 * is contained in the mimefilter and then we will 537 * is contained in the mimefilter and then we will
538 * look if both are equal until the '/' 538 * look if both are equal until the '/'
539 */ 539 */
540bool OFileViewFileListView::compliesMime( const QString& str) { 540bool OFileViewFileListView::compliesMime( const QString& str) {
541 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) 541 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() )
542 return true; 542 return true;
543 543
544 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { 544 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) {
545 QRegExp reg( (*it) ); 545 QRegExp reg( (*it) );
546 reg.setWildcard( true ); 546 reg.setWildcard( true );
547 if ( str.find( reg ) != -1 ) 547 if ( str.find( reg ) != -1 )
548 return true; 548 return true;
549 549
550 } 550 }
551 return false; 551 return false;
552} 552}
553/* 553/*
554 * The listView giving access to the file system! 554 * The listView giving access to the file system!
555 */ 555 */
556class OFileViewFileSystem : public OFileViewInterface { 556class OFileViewFileSystem : public OFileViewInterface {
557public: 557public:
558 OFileViewFileSystem( OFileSelector* ); 558 OFileViewFileSystem( OFileSelector* );
559 ~OFileViewFileSystem(); 559 ~OFileViewFileSystem();
560 560
561 QString selectedName() const; 561 QString selectedName() const;
562 QString selectedPath() const; 562 QString selectedPath() const;
563 563
564 QString directory()const; 564 QString directory()const;
565 void reread(); 565 void reread();
566 int fileCount()const; 566 int fileCount()const;
567 567
568 QWidget* widget( QWidget* parent ); 568 QWidget* widget( QWidget* parent );
569 void activate( const QString& ); 569 void activate( const QString& );
570private: 570private:
571 OFileViewFileListView* m_view; 571 OFileViewFileListView* m_view;
572 bool m_all : 1; 572 bool m_all : 1;
573}; 573};
574OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) 574OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel)
575 : OFileViewInterface( sel ) { 575 : OFileViewInterface( sel ) {
576 m_view = 0; 576 m_view = 0;
577 m_all = false; 577 m_all = false;
578} 578}
579OFileViewFileSystem::~OFileViewFileSystem() { 579OFileViewFileSystem::~OFileViewFileSystem() {
580} 580}
581QString OFileViewFileSystem::selectedName()const{ 581QString OFileViewFileSystem::selectedName()const{
582 if (!m_view ) 582 if (!m_view )
583 return QString::null; 583 return QString::null;
584 584
@@ -591,339 +591,339 @@ QString OFileViewFileSystem::selectedPath()const{
591} 591}
592QString OFileViewFileSystem::directory()const{ 592QString OFileViewFileSystem::directory()const{
593 if (!m_view) 593 if (!m_view)
594 return QString::null; 594 return QString::null;
595 595
596 OFileSelectorItem* item = m_view->currentItem(); 596 OFileSelectorItem* item = m_view->currentItem();
597 if (!item ) 597 if (!item )
598 return QString::null; 598 return QString::null;
599 599
600 return QDir(item->directory() ).absPath(); 600 return QDir(item->directory() ).absPath();
601} 601}
602void OFileViewFileSystem::reread() { 602void OFileViewFileSystem::reread() {
603 if (!m_view) 603 if (!m_view)
604 return; 604 return;
605 605
606 m_view->reread( m_all ); 606 m_view->reread( m_all );
607} 607}
608int OFileViewFileSystem::fileCount()const{ 608int OFileViewFileSystem::fileCount()const{
609 if (!m_view ) 609 if (!m_view )
610 return -1; 610 return -1;
611 return m_view->fileCount(); 611 return m_view->fileCount();
612} 612}
613QWidget* OFileViewFileSystem::widget( QWidget* parent ) { 613QWidget* OFileViewFileSystem::widget( QWidget* parent ) {
614 if (!m_view ) { 614 if (!m_view ) {
615 m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); 615 m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
616 } 616 }
617 return m_view; 617 return m_view;
618} 618}
619void OFileViewFileSystem::activate( const QString& str) { 619void OFileViewFileSystem::activate( const QString& str) {
620 m_all = (str != QObject::tr("Files") ); 620 m_all = (str != QObject::tr("Files") );
621 621
622 622
623} 623}
624 624
625/* Selector */ 625/* Selector */
626/** 626/**
627 * @short new and complete c'tor 627 * @short new and complete c'tor
628 * 628 *
629 * Create a OFileSelector to let the user select a file. It can 629 * Create a OFileSelector to let the user select a file. It can
630 * either be used to open a file, select a save name in a dir or 630 * either be used to open a file, select a save name in a dir or
631 * as a dropin for the FileSelector. 631 * as a dropin for the FileSelector.
632 * 632 *
633 * <pre> 633 * <pre>
634 * QMap<QString, QStringList> mimeTypes; 634 * QMap<QString, QStringList> mimeTypes;
635 * QStringList types; 635 * QStringList types;
636 * types << "text@slash* "; 636 * types << "text@slash* ";
637 * types << "audio@slash*"; 637 * types << "audio@slash*";
638 * mimeTypes.insert( tr("Audio and Text"), types ); 638 * mimeTypes.insert( tr("Audio and Text"), types );
639 * mimeTypes.insert( tr("All"), "*@slash*); 639 * mimeTypes.insert( tr("All"), "*@slash*);
640 * 640 *
641 * now you could create your fileselector 641 * now you could create your fileselector
642 * </pre> 642 * </pre>
643 * 643 *
644 * 644 *
645 * @param parent the parent of this widget 645 * @param parent the parent of this widget
646 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) 646 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR)
647 * @param sel The selector to be used 647 * @param sel The selector to be used
648 * @param dirName The name of the dir to start int 648 * @param dirName The name of the dir to start int
649 * @param fileName The fileName placed in the fileselector lineedit 649 * @param fileName The fileName placed in the fileselector lineedit
650 * @param mimetypes The MimeType map of used mimetypes 650 * @param mimetypes The MimeType map of used mimetypes
651 * @param showNew Show a New Button. Most likely to be used in the FileSelector view. 651 * @param showNew Show a New Button. Most likely to be used in the FileSelector view.
652 * @param showClose Show a Close Button. Most likely to be used in FileSelector view. 652 * @param showClose Show a Close Button. Most likely to be used in FileSelector view.
653 * 653 *
654 */ 654 */
655OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, 655OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
656 const QString& dirName, const QString& fileName, 656 const QString& dirName, const QString& fileName,
657 const MimeTypes& mimetypes, 657 const MimeTypes& mimetypes,
658 bool showNew, bool showClose) 658 bool showNew, bool showClose)
659 : QWidget( parent, "OFileSelector" ) 659 : QWidget( parent, "OFileSelector" )
660{ 660{
661 m_current = 0; 661 m_current = 0;
662 m_shNew = showNew; 662 m_shNew = showNew;
663 m_shClose = showClose; 663 m_shClose = showClose;
664 m_mimeType = mimetypes; 664 m_mimeType = mimetypes;
665 m_startDir = dirName; 665 m_startDir = dirName;
666 666
667 m_mode = mode; 667 m_mode = mode;
668 m_selector = sel; 668 m_selector = sel;
669 669
670 initUI(); 670 initUI();
671 m_lneEdit->setText( fileName ); 671 m_lneEdit->setText( fileName );
672 initMime(); 672 initMime();
673 initViews(); 673 initViews();
674 674
675 QString str; 675 QString str;
676 switch ( m_selector ) { 676 switch ( m_selector ) {
677 default: 677 default:
678 case Normal: 678 case Normal:
679 str = QObject::tr("Documents"); 679 str = QObject::tr("Documents");
680 m_cmbView->setCurrentItem( 0 ); 680 m_cmbView->setCurrentItem( 0 );
681 break; 681 break;
682 case Extended: 682 case Extended:
683 str = QObject::tr("Files"); 683 str = QObject::tr("Files");
684 m_cmbView->setCurrentItem( 1 ); 684 m_cmbView->setCurrentItem( 1 );
685 break; 685 break;
686 case ExtendedAll: 686 case ExtendedAll:
687 str = QObject::tr("All Files"); 687 str = QObject::tr("All Files");
688 m_cmbView->setCurrentItem( 2 ); 688 m_cmbView->setCurrentItem( 2 );
689 break; 689 break;
690 } 690 }
691 slotViewChange( str ); 691 slotViewChange( str );
692 692
693} 693}
694 694
695/** 695/**
696 * This a convience c'tor to just substitute the use of FileSelector 696 * This a convience c'tor to just substitute the use of FileSelector
697 */ 697 */
698OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, 698OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name,
699 bool showNew, bool showClose ) 699 bool showNew, bool showClose )
700 : QWidget( parent, name ) 700 : QWidget( parent, name )
701{ 701{
702 m_current = 0; 702 m_current = 0;
703 m_shNew = showNew; 703 m_shNew = showNew;
704 m_shClose = showClose; 704 m_shClose = showClose;
705 m_startDir = QPEApplication::documentDir(); 705 m_startDir = QPEApplication::documentDir();
706 706
707 if (!mimeFilter.isEmpty() ) 707 if (!mimeFilter.isEmpty() )
708 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); 708 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) );
709 709
710 m_mode = OFileSelector::FileSelector; 710 m_mode = OFileSelector::FileSelector;
711 m_selector = OFileSelector::Normal; 711 m_selector = OFileSelector::Normal;
712 712
713 initUI(); 713 initUI();
714 initMime(); 714 initMime();
715 initViews(); 715 initViews();
716 m_cmbView->setCurrentItem( 0 ); 716 m_cmbView->setCurrentItem( 0 );
717 slotViewChange( QObject::tr("Documents") ); 717 slotViewChange( QObject::tr("Documents") );
718} 718}
719/* 719/*
720 * INIT UI will set up the basic GUI 720 * INIT UI will set up the basic GUI
721 * Layout: Simple VBoxLayout 721 * Layout: Simple VBoxLayout
722 * On top a WidgetStack containing the Views... 722 * On top a WidgetStack containing the Views...
723 * - List View 723 * - List View
724 * - Document View 724 * - Document View
725 * Below we will have a Label + LineEdit 725 * Below we will have a Label + LineEdit
726 * Below we will have two ComoBoxes one for choosing the view one for 726 * Below we will have two ComoBoxes one for choosing the view one for
727 * choosing the mimetype 727 * choosing the mimetype
728 */ 728 */
729void OFileSelector::initUI() { 729void OFileSelector::initUI() {
730 QVBoxLayout* lay = new QVBoxLayout( this ); 730 QVBoxLayout* lay = new QVBoxLayout( this );
731 731
732 m_stack = new QWidgetStack( this ); 732 m_stack = new QWidgetStack( this );
733 lay->addWidget( m_stack, 1000 ); 733 lay->addWidget( m_stack, 1000 );
734 734
735 m_nameBox = new QHBox( this ); 735 m_nameBox = new QHBox( this );
736 (void)new QLabel( tr("Name:"), m_nameBox ); 736 (void)new QLabel( tr("Name:"), m_nameBox );
737 m_lneEdit = new QLineEdit( m_nameBox ); 737 m_lneEdit = new QLineEdit( m_nameBox );
738 m_lneEdit ->installEventFilter(this); 738 m_lneEdit ->installEventFilter(this);
739 lay->addWidget( m_nameBox ); 739 lay->addWidget( m_nameBox );
740 740
741 m_cmbBox = new QHBox( this ); 741 m_cmbBox = new QHBox( this );
742 m_cmbView = new QComboBox( m_cmbBox ); 742 m_cmbView = new QComboBox( m_cmbBox );
743 m_cmbMime = new QComboBox( m_cmbBox ); 743 m_cmbMime = new QComboBox( m_cmbBox );
744 lay->addWidget( m_cmbBox ); 744 lay->addWidget( m_cmbBox );
745} 745}
746 746
747/* 747/*
748 * This will make sure that the return key in the name edit causes dialogs to close 748 * This will make sure that the return key in the name edit causes dialogs to close
749 */ 749 */
750 750
751bool OFileSelector::eventFilter (QObject *o, QEvent *e) { 751bool OFileSelector::eventFilter (QObject *o, QEvent *e) {
752 if ( e->type() == QEvent::KeyPress ) { 752 if ( e->type() == QEvent::KeyPress ) {
753 QKeyEvent *k = (QKeyEvent *)e; 753 QKeyEvent *k = (QKeyEvent *)e;
754 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { 754 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) {
755 emit ok(); 755 emit ok();
756 return true; 756 return true;
757 } 757 }
758 } 758 }
759 return false; 759 return false;
760} 760}
761 761
762/* 762/*
763 * This will insert the MimeTypes into the Combo Box 763 * This will insert the MimeTypes into the Combo Box
764 * And also connect the changed signal 764 * And also connect the changed signal
765 * 765 *
766 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes 766 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes
767 */ 767 */
768void OFileSelector::initMime() { 768void OFileSelector::initMime() {
769 MimeTypes::Iterator it; 769 MimeTypes::Iterator it;
770 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { 770 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) {
771 m_cmbMime->insertItem( it.key() ); 771 m_cmbMime->insertItem( it.key() );
772 } 772 }
773 m_cmbMime->setCurrentItem( 0 ); 773 m_cmbMime->setCurrentItem( 0 );
774 774
775 connect( m_cmbMime, SIGNAL(activated(int) ), 775 connect( m_cmbMime, SIGNAL(activated(int) ),
776 this, SLOT(slotMimeTypeChanged() ) ); 776 this, SLOT(slotMimeTypeChanged() ) );
777 777
778} 778}
779void OFileSelector::initViews() { 779void OFileSelector::initViews() {
780 m_cmbView->insertItem( QObject::tr("Documents") ); 780 m_cmbView->insertItem( QObject::tr("Documents") );
781 m_cmbView->insertItem( QObject::tr("Files") ); 781 m_cmbView->insertItem( QObject::tr("Files") );
782 m_cmbView->insertItem( QObject::tr("All Files") ); 782 m_cmbView->insertItem( QObject::tr("All Files") );
783 connect(m_cmbView, SIGNAL(activated( const QString& ) ), 783 connect(m_cmbView, SIGNAL(activated(const QString&) ),
784 this, SLOT(slotViewChange( const QString& ) ) ); 784 this, SLOT(slotViewChange(const QString&) ) );
785 785
786 786
787 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 787 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
788 788
789 /* see above why add both */ 789 /* see above why add both */
790 OFileViewInterface* in = new OFileViewFileSystem( this ); 790 OFileViewInterface* in = new OFileViewFileSystem( this );
791 m_views.insert( QObject::tr("Files"), in ); 791 m_views.insert( QObject::tr("Files"), in );
792 m_views.insert( QObject::tr("All Files"), in ); 792 m_views.insert( QObject::tr("All Files"), in );
793} 793}
794 794
795/** 795/**
796 * d'tor 796 * d'tor
797 */ 797 */
798OFileSelector::~OFileSelector() { 798OFileSelector::~OFileSelector() {
799 799
800} 800}
801 801
802/** 802/**
803 * Convience function for the fileselector 803 * Convience function for the fileselector
804 * make sure to delete the DocLnk 804 * make sure to delete the DocLnk
805 * 805 *
806 * @see DocLnk 806 * @see DocLnk
807 * @todo remove in ODP 807 * @todo remove in ODP
808 */ 808 */
809const DocLnk* OFileSelector::selected() { 809const DocLnk* OFileSelector::selected() {
810 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); 810 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
811 return lnk; 811 return lnk;
812} 812}
813 813
814/** 814/**
815 * 815 *
816 * @return the name of the selected file 816 * @return the name of the selected file
817 */ 817 */
818QString OFileSelector::selectedName()const{ 818QString OFileSelector::selectedName()const{
819 return currentView()->selectedName(); 819 return currentView()->selectedName();
820} 820}
821 821
822/** 822/**
823 * @return the selected path 823 * @return the selected path
824 */ 824 */
825QString OFileSelector::selectedPath()const { 825QString OFileSelector::selectedPath()const {
826 return currentView()->selectedPath(); 826 return currentView()->selectedPath();
827} 827}
828 828
829/** 829/**
830 * @return the directory name 830 * @return the directory name
831 */ 831 */
832QString OFileSelector::directory()const { 832QString OFileSelector::directory()const {
833 return currentView()->directory(); 833 return currentView()->directory();
834} 834}
835 835
836/** 836/**
837 * @return a DocLnk for the selected document 837 * @return a DocLnk for the selected document
838 */ 838 */
839DocLnk OFileSelector::selectedDocument()const { 839DocLnk OFileSelector::selectedDocument()const {
840 return currentView()->selectedDocument(); 840 return currentView()->selectedDocument();
841} 841}
842 842
843/** 843/**
844 * @return the number of items for the current view 844 * @return the number of items for the current view
845 */ 845 */
846int OFileSelector::fileCount()const { 846int OFileSelector::fileCount()const {
847 return currentView()->fileCount(); 847 return currentView()->fileCount();
848} 848}
849 849
850/** 850/**
851 * @return reparse the file content 851 * @return reparse the file content
852 */ 852 */
853void OFileSelector::reread() { 853void OFileSelector::reread() {
854 return currentView()->reread(); 854 return currentView()->reread();
855} 855}
856OFileViewInterface* OFileSelector::currentView()const{ 856OFileViewInterface* OFileSelector::currentView()const{
857 return m_current; 857 return m_current;
858} 858}
859bool OFileSelector::showNew()const { 859bool OFileSelector::showNew()const {
860 return m_shNew; 860 return m_shNew;
861} 861}
862bool OFileSelector::showClose()const { 862bool OFileSelector::showClose()const {
863 return m_shClose; 863 return m_shClose;
864} 864}
865MimeTypes OFileSelector::mimeTypes()const { 865MimeTypes OFileSelector::mimeTypes()const {
866 return m_mimeType; 866 return m_mimeType;
867} 867}
868 868
869/** 869/**
870 * @return the Mode of the OFileSelector 870 * @return the Mode of the OFileSelector
871 */ 871 */
872int OFileSelector::mode()const{ 872int OFileSelector::mode()const{
873 return m_mode; 873 return m_mode;
874} 874}
875 875
876/** 876/**
877 * @return the Selector of the OFileSelector 877 * @return the Selector of the OFileSelector
878 */ 878 */
879int OFileSelector::selector()const{ 879int OFileSelector::selector()const{
880 return m_selector; 880 return m_selector;
881} 881}
882QStringList OFileSelector::currentMimeType()const { 882QStringList OFileSelector::currentMimeType()const {
883 return m_mimeType[m_cmbMime->currentText()]; 883 return m_mimeType[m_cmbMime->currentText()];
884} 884}
885void OFileSelector::slotMimeTypeChanged() { 885void OFileSelector::slotMimeTypeChanged() {
886 reread(); 886 reread();
887} 887}
888void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { 888void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) {
889 m_lneEdit->setText( lnk.name() ); 889 m_lneEdit->setText( lnk.name() );
890 emit fileSelected( lnk ); 890 emit fileSelected( lnk );
891 emit fileSelected( lnk.name() ); 891 emit fileSelected( lnk.name() );
892} 892}
893void OFileSelector::slotFileBridge( const QString& str) { 893void OFileSelector::slotFileBridge( const QString& str) {
894 DocLnk lnk( str ); 894 DocLnk lnk( str );
895 emit fileSelected( lnk ); 895 emit fileSelected( lnk );
896} 896}
897void OFileSelector::slotViewChange( const QString& view ) { 897void OFileSelector::slotViewChange( const QString& view ) {
898 OFileViewInterface* interface = m_views[view]; 898 OFileViewInterface* interface = m_views[view];
899 if (!interface) 899 if (!interface)
900 return; 900 return;
901 901
902 interface->activate( view ); 902 interface->activate( view );
903 if (m_current) 903 if (m_current)
904 m_stack->removeWidget( m_current->widget( m_stack ) ); 904 m_stack->removeWidget( m_current->widget( m_stack ) );
905 905
906 static int id = 1; 906 static int id = 1;
907 907
908 m_stack->addWidget( interface->widget(m_stack), id ); 908 m_stack->addWidget( interface->widget(m_stack), id );
909 m_stack->raiseWidget( id ); 909 m_stack->raiseWidget( id );
910 910
911 interface->reread(); 911 interface->reread();
912 m_current = interface; 912 m_current = interface;
913 913
914 id++; 914 id++;
915} 915}
916void OFileSelector::setNewVisible( bool b ) { 916void OFileSelector::setNewVisible( bool b ) {
917 m_shNew = b; 917 m_shNew = b;
918 currentView()->reread(); 918 currentView()->reread();
919} 919}
920void OFileSelector::setCloseVisible( bool b ) { 920void OFileSelector::setCloseVisible( bool b ) {
921 m_shClose = b; 921 m_shClose = b;
922 currentView()->reread(); 922 currentView()->reread();
923} 923}
924void OFileSelector::setNameVisible( bool b ) { 924void OFileSelector::setNameVisible( bool b ) {
925 if ( b ) 925 if ( b )
926 m_nameBox->show(); 926 m_nameBox->show();
927 else 927 else
928 m_nameBox->hide(); 928 m_nameBox->hide();
929} 929}
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp
index 7e07008..87b7869 100644
--- a/libopie/ofontselector.cpp
+++ b/libopie/ofontselector.cpp
@@ -1,328 +1,328 @@
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 <qmultilineedit.h> 33#include <qmultilineedit.h>
34 34
35#include <qpe/fontdatabase.h> 35#include <qpe/fontdatabase.h>
36 36
37#include "ofontselector.h" 37#include "ofontselector.h"
38 38
39class OFontSelectorPrivate { 39class OFontSelectorPrivate {
40public: 40public:
41 QListBox * m_font_family_list; 41 QListBox * m_font_family_list;
42 QComboBox * m_font_style_list; 42 QComboBox * m_font_style_list;
43 QComboBox * m_font_size_list; 43 QComboBox * m_font_size_list;
44 QMultiLineEdit *m_preview; 44 QMultiLineEdit *m_preview;
45 45
46 bool m_pointbug : 1; 46 bool m_pointbug : 1;
47 47
48 FontDatabase m_fdb; 48 FontDatabase m_fdb;
49}; 49};
50 50
51namespace { 51namespace {
52 52
53class FontListItem : public QListBoxText { 53class FontListItem : public QListBoxText {
54public: 54public:
55 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText ( ) 55 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText ( )
56 { 56 {
57 m_name = t; 57 m_name = t;
58 m_styles = styles; 58 m_styles = styles;
59 m_sizes = sizes; 59 m_sizes = sizes;
60 60
61 QString str = t; 61 QString str = t;
62 str [0] = str [0]. upper ( ); 62 str [0] = str [0]. upper ( );
63 setText ( str ); 63 setText ( str );
64 } 64 }
65 65
66 QString family ( ) const 66 QString family ( ) const
67 { 67 {
68 return m_name; 68 return m_name;
69 } 69 }
70 70
71 const QStringList &styles ( ) const 71 const QStringList &styles ( ) const
72 { 72 {
73 return m_styles; 73 return m_styles;
74 } 74 }
75 75
76 const QValueList<int> &sizes ( ) const 76 const QValueList<int> &sizes ( ) const
77 { 77 {
78 return m_sizes; 78 return m_sizes;
79 } 79 }
80 80
81private: 81private:
82 QStringList m_styles; 82 QStringList m_styles;
83 QValueList<int> m_sizes; 83 QValueList<int> m_sizes;
84 QString m_name; 84 QString m_name;
85}; 85};
86 86
87 87
88static int findItemCB ( QComboBox *box, const QString &str ) 88static int findItemCB ( QComboBox *box, const QString &str )
89{ 89{
90 for ( int i = 0; i < box-> count ( ); i++ ) { 90 for ( int i = 0; i < box-> count ( ); i++ ) {
91 if ( box-> text ( i ) == str ) 91 if ( box-> text ( i ) == str )
92 return i; 92 return i;
93 } 93 }
94 return -1; 94 return -1;
95} 95}
96 96
97} 97}
98/* static same as anon. namespace */ 98/* static same as anon. namespace */
99static int qt_version ( ) 99static int qt_version ( )
100{ 100{
101 const char *qver = qVersion ( ); 101 const char *qver = qVersion ( );
102 102
103 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); 103 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
104} 104}
105 105
106/** 106/**
107 * Constructs the Selector object 107 * Constructs the Selector object
108 * @param withpreview If a font preview should be given 108 * @param withpreview If a font preview should be given
109 * @param parent The parent of the Font Selector 109 * @param parent The parent of the Font Selector
110 * @param name The name of the object 110 * @param name The name of the object
111 * @param fl WidgetFlags 111 * @param fl WidgetFlags
112 */ 112 */
113OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 113OFontSelector::OFontSelector ( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
114{ 114{
115 d = new OFontSelectorPrivate ( ); 115 d = new OFontSelectorPrivate ( );
116 116
117 QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 ); 117 QGridLayout *gridLayout = new QGridLayout ( this, 0, 0, 4, 4 );
118 gridLayout->setRowStretch ( 4, 10 ); 118 gridLayout->setRowStretch ( 4, 10 );
119 119
120 d-> m_font_family_list = new QListBox( this, "FontListBox" ); 120 d-> m_font_family_list = new QListBox( this, "FontListBox" );
121 gridLayout->addMultiCellWidget( d-> m_font_family_list, 0, 4, 0, 0 ); 121 gridLayout->addMultiCellWidget( d-> m_font_family_list, 0, 4, 0, 0 );
122 connect( d-> m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); 122 connect( d-> m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) );
123 123
124 QLabel *label = new QLabel( tr( "Style" ), this ); 124 QLabel *label = new QLabel( tr( "Style" ), this );
125 gridLayout->addWidget( label, 0, 1 ); 125 gridLayout->addWidget( label, 0, 1 );
126 126
127 d-> m_font_style_list = new QComboBox( this, "StyleListBox" ); 127 d-> m_font_style_list = new QComboBox( this, "StyleListBox" );
128 connect( d-> m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); 128 connect( d-> m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) );
129 gridLayout->addWidget( d-> m_font_style_list, 1, 1 ); 129 gridLayout->addWidget( d-> m_font_style_list, 1, 1 );
130 130
131 label = new QLabel( tr( "Size" ), this ); 131 label = new QLabel( tr( "Size" ), this );
132 gridLayout->addWidget( label, 2, 1 ); 132 gridLayout->addWidget( label, 2, 1 );
133 133
134 d-> m_font_size_list = new QComboBox( this, "SizeListBox" ); 134 d-> m_font_size_list = new QComboBox( this, "SizeListBox" );
135 connect( d-> m_font_size_list, SIGNAL( activated( int ) ), 135 connect( d-> m_font_size_list, SIGNAL( activated(int) ),
136 this, SLOT( fontSizeClicked( int ) ) ); 136 this, SLOT( fontSizeClicked(int) ) );
137 gridLayout->addWidget( d-> m_font_size_list, 3, 1 ); 137 gridLayout->addWidget( d-> m_font_size_list, 3, 1 );
138 138
139 d-> m_pointbug = ( qt_version ( ) <= 233 ); 139 d-> m_pointbug = ( qt_version ( ) <= 233 );
140 140
141 if ( withpreview ) { 141 if ( withpreview ) {
142 d-> m_preview = new QMultiLineEdit ( this, "Preview" ); 142 d-> m_preview = new QMultiLineEdit ( this, "Preview" );
143 d-> m_preview-> setAlignment ( AlignCenter ); 143 d-> m_preview-> setAlignment ( AlignCenter );
144 d-> m_preview-> setWordWrap ( QMultiLineEdit::WidgetWidth ); 144 d-> m_preview-> setWordWrap ( QMultiLineEdit::WidgetWidth );
145 d-> m_preview-> setMargin ( 3 ); 145 d-> m_preview-> setMargin ( 3 );
146 d-> m_preview-> setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); 146 d-> m_preview-> setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
147 gridLayout-> addRowSpacing ( 5, 4 ); 147 gridLayout-> addRowSpacing ( 5, 4 );
148 gridLayout-> addMultiCellWidget ( d-> m_preview, 6, 6, 0, 1 ); 148 gridLayout-> addMultiCellWidget ( d-> m_preview, 6, 6, 0, 1 );
149 gridLayout-> setRowStretch ( 6, 5 ); 149 gridLayout-> setRowStretch ( 6, 5 );
150 } 150 }
151 else 151 else
152 d-> m_preview = 0; 152 d-> m_preview = 0;
153 153
154 loadFonts ( d-> m_font_family_list ); 154 loadFonts ( d-> m_font_family_list );
155} 155}
156 156
157OFontSelector::~OFontSelector ( ) 157OFontSelector::~OFontSelector ( )
158{ 158{
159 delete d; 159 delete d;
160} 160}
161 161
162/** 162/**
163 * This methods tries to set the font 163 * This methods tries to set the font
164 * @param f The wishes font 164 * @param f The wishes font
165 * @return success or failure 165 * @return success or failure
166 */ 166 */
167bool OFontSelector::setSelectedFont ( const QFont &f ) 167bool OFontSelector::setSelectedFont ( const QFont &f )
168{ 168{
169 return setSelectedFont ( f. family ( ), d-> m_fdb. styleString ( f ), f. pointSize ( ), QFont::encodingName ( f. charSet ( ))); 169 return setSelectedFont ( f. family ( ), d-> m_fdb. styleString ( f ), f. pointSize ( ), QFont::encodingName ( f. charSet ( )));
170} 170}
171 171
172 172
173/** 173/**
174 * This is an overloaded method @see setSelectedFont 174 * This is an overloaded method @see setSelectedFont
175 * @param familyStr The family of the font 175 * @param familyStr The family of the font
176 * @param styleStr The style of the font 176 * @param styleStr The style of the font
177 * @param sizeVal The size of font 177 * @param sizeVal The size of font
178 * @param charset The charset to be used. Will be deprecated by QT3 178 * @param charset The charset to be used. Will be deprecated by QT3
179 */ 179 */
180bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) 180bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset )
181{ 181{
182 QString sizeStr = QString::number ( sizeVal ); 182 QString sizeStr = QString::number ( sizeVal );
183 183
184 QListBoxItem *family = d-> m_font_family_list-> findItem ( familyStr ); 184 QListBoxItem *family = d-> m_font_family_list-> findItem ( familyStr );
185 if ( !family ) 185 if ( !family )
186 family = d-> m_font_family_list-> findItem ( "Helvetica" ); 186 family = d-> m_font_family_list-> findItem ( "Helvetica" );
187 if ( !family ) 187 if ( !family )
188 family = d-> m_font_family_list-> firstItem ( ); 188 family = d-> m_font_family_list-> firstItem ( );
189 d-> m_font_family_list-> setCurrentItem ( family ); 189 d-> m_font_family_list-> setCurrentItem ( family );
190 fontFamilyClicked ( d-> m_font_family_list-> index ( family )); 190 fontFamilyClicked ( d-> m_font_family_list-> index ( family ));
191 191
192 int style = findItemCB ( d-> m_font_style_list, styleStr ); 192 int style = findItemCB ( d-> m_font_style_list, styleStr );
193 if ( style < 0 ) 193 if ( style < 0 )
194 style = findItemCB ( d-> m_font_style_list, "Regular" ); 194 style = findItemCB ( d-> m_font_style_list, "Regular" );
195 if ( style < 0 && d-> m_font_style_list-> count ( ) > 0 ) 195 if ( style < 0 && d-> m_font_style_list-> count ( ) > 0 )
196 style = 0; 196 style = 0;
197 d-> m_font_style_list-> setCurrentItem ( style ); 197 d-> m_font_style_list-> setCurrentItem ( style );
198 fontStyleClicked ( style ); 198 fontStyleClicked ( style );
199 199
200 int size = findItemCB ( d-> m_font_size_list, sizeStr ); 200 int size = findItemCB ( d-> m_font_size_list, sizeStr );
201 if ( size < 0 ) 201 if ( size < 0 )
202 size = findItemCB ( d-> m_font_size_list, "10" ); 202 size = findItemCB ( d-> m_font_size_list, "10" );
203 if ( size < 0 && d-> m_font_size_list-> count ( ) > 0 ) 203 if ( size < 0 && d-> m_font_size_list-> count ( ) > 0 )
204 size = 0; 204 size = 0;
205 d-> m_font_size_list-> setCurrentItem ( size ); 205 d-> m_font_size_list-> setCurrentItem ( size );
206 fontSizeClicked ( size ); 206 fontSizeClicked ( size );
207 207
208 return (( family ) && ( style >= 0 ) && ( size >= 0 )); 208 return (( family ) && ( style >= 0 ) && ( size >= 0 ));
209} 209}
210 210
211/** 211/**
212 * This method returns the name, style and size of the currently selected 212 * This method returns the name, style and size of the currently selected
213 * font or false if no font is selected 213 * font or false if no font is selected
214 * @param family The font family will be written there 214 * @param family The font family will be written there
215 * @param style The style will be written there 215 * @param style The style will be written there
216 * @param size The size will be written there 216 * @param size The size will be written there
217 * @return success or failure 217 * @return success or failure
218 */ 218 */
219bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) 219bool OFontSelector::selectedFont ( QString &family, QString &style, int &size )
220{ 220{
221 QString dummy; 221 QString dummy;
222 return selectedFont ( family, style, size, dummy ); 222 return selectedFont ( family, style, size, dummy );
223} 223}
224 224
225 225
226/** 226/**
227 * This method does return the font family or QString::null if there is 227 * This method does return the font family or QString::null if there is
228 * no font item selected 228 * no font item selected
229 * @return the font family 229 * @return the font family
230 */ 230 */
231QString OFontSelector::fontFamily ( ) const 231QString OFontSelector::fontFamily ( ) const
232{ 232{
233 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); 233 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( ));
234 234
235 return fli ? fli-> family ( ) : QString::null; 235 return fli ? fli-> family ( ) : QString::null;
236} 236}
237 237
238/** 238/**
239 * This method will return the style of the font or QString::null 239 * This method will return the style of the font or QString::null
240 * @return the style of the font 240 * @return the style of the font
241 */ 241 */
242QString OFontSelector::fontStyle ( ) const 242QString OFontSelector::fontStyle ( ) const
243{ 243{
244 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); 244 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( ));
245 int fst = d-> m_font_style_list-> currentItem ( ); 245 int fst = d-> m_font_style_list-> currentItem ( );
246 246
247 return ( fli && fst >= 0 ) ? fli-> styles ( ) [fst] : QString::null; 247 return ( fli && fst >= 0 ) ? fli-> styles ( ) [fst] : QString::null;
248} 248}
249 249
250/** 250/**
251 * This method will return the font size or 10 if no font size is available 251 * This method will return the font size or 10 if no font size is available
252 */ 252 */
253int OFontSelector::fontSize ( ) const 253int OFontSelector::fontSize ( ) const
254{ 254{
255 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); 255 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( ));
256 int fsi = d-> m_font_size_list-> currentItem ( ); 256 int fsi = d-> m_font_size_list-> currentItem ( );
257 257
258 return ( fli && fsi >= 0 ) ? fli-> sizes ( ) [fsi] : 10; 258 return ( fli && fsi >= 0 ) ? fli-> sizes ( ) [fsi] : 10;
259} 259}
260 260
261/** 261/**
262 * returns the charset of the font or QString::null 262 * returns the charset of the font or QString::null
263 */ 263 */
264QString OFontSelector::fontCharSet ( ) const 264QString OFontSelector::fontCharSet ( ) const
265{ 265{
266 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( )); 266 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( d-> m_font_family_list-> currentItem ( ));
267 267
268 return fli ? d-> m_fdb. charSets ( fli-> family ( )) [0] : QString::null; 268 return fli ? d-> m_fdb. charSets ( fli-> family ( )) [0] : QString::null;
269} 269}
270 270
271/** 271/**
272 * Overloaded member function see above 272 * Overloaded member function see above
273 * @see selectedFont 273 * @see selectedFont
274 */ 274 */
275bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) 275bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset )
276{ 276{
277 int ffa = d-> m_font_family_list-> currentItem ( ); 277 int ffa = d-> m_font_family_list-> currentItem ( );
278 int fst = d-> m_font_style_list-> currentItem ( ); 278 int fst = d-> m_font_style_list-> currentItem ( );
279 int fsi = d-> m_font_size_list-> currentItem ( ); 279 int fsi = d-> m_font_size_list-> currentItem ( );
280 280
281 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( ffa ); 281 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( ffa );
282 282
283 if ( fli ) { 283 if ( fli ) {
284 family = fli-> family ( ); 284 family = fli-> family ( );
285 style = fst >= 0 ? fli-> styles ( ) [fst] : QString::null; 285 style = fst >= 0 ? fli-> styles ( ) [fst] : QString::null;
286 size = fsi >= 0 ? fli-> sizes ( ) [fsi] : 10; 286 size = fsi >= 0 ? fli-> sizes ( ) [fsi] : 10;
287 charset = d-> m_fdb. charSets ( fli-> family ( )) [0]; 287 charset = d-> m_fdb. charSets ( fli-> family ( )) [0];
288 288
289 return true; 289 return true;
290 } 290 }
291 else 291 else
292 return false; 292 return false;
293} 293}
294 294
295 295
296 296
297 297
298void OFontSelector::loadFonts ( QListBox *list ) 298void OFontSelector::loadFonts ( QListBox *list )
299{ 299{
300 QStringList f = d-> m_fdb. families ( ); 300 QStringList f = d-> m_fdb. families ( );
301 301
302 for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) { 302 for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) {
303 QValueList <int> ps = d-> m_fdb. pointSizes ( *it ); 303 QValueList <int> ps = d-> m_fdb. pointSizes ( *it );
304 304
305 if ( d-> m_pointbug ) { 305 if ( d-> m_pointbug ) {
306 for ( QValueList <int>::Iterator it = ps. begin ( ); it != ps. end ( ); it++ ) 306 for ( QValueList <int>::Iterator it = ps. begin ( ); it != ps. end ( ); it++ )
307 *it /= 10; 307 *it /= 10;
308 } 308 }
309 309
310 list-> insertItem ( new FontListItem ( *it, d-> m_fdb. styles ( *it ), ps )); 310 list-> insertItem ( new FontListItem ( *it, d-> m_fdb. styles ( *it ), ps ));
311 } 311 }
312} 312}
313 313
314void OFontSelector::fontFamilyClicked ( int index ) 314void OFontSelector::fontFamilyClicked ( int index )
315{ 315{
316 QString oldstyle = d-> m_font_style_list-> currentText ( ); 316 QString oldstyle = d-> m_font_style_list-> currentText ( );
317 QString oldsize = d-> m_font_size_list-> currentText ( ); 317 QString oldsize = d-> m_font_size_list-> currentText ( );
318 318
319 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( index ); 319 FontListItem *fli = (FontListItem *) d-> m_font_family_list-> item ( index );
320 320
321 d-> m_font_style_list-> clear ( ); 321 d-> m_font_style_list-> clear ( );
322 d-> m_font_style_list-> insertStringList ( fli-> styles ( )); 322 d-> m_font_style_list-> insertStringList ( fli-> styles ( ));
323 d-> m_font_style_list-> setEnabled ( !fli-> styles ( ). isEmpty ( )); 323 d-> m_font_style_list-> setEnabled ( !fli-> styles ( ). isEmpty ( ));
324 324
325 int i; 325 int i;
326 326
327 i = findItemCB ( d-> m_font_style_list, oldstyle ); 327 i = findItemCB ( d-> m_font_style_list, oldstyle );
328 if ( i < 0 ) 328 if ( i < 0 )
diff --git a/libopie/orecurrancewidget.cpp b/libopie/orecurrancewidget.cpp
index d81851e..33be269 100644
--- a/libopie/orecurrancewidget.cpp
+++ b/libopie/orecurrancewidget.cpp
@@ -361,272 +361,272 @@ void ORecurranceWidget::slotWeekLabel() {
361 list.append( dayLabel[i - 1] ); 361 list.append( dayLabel[i - 1] );
362 } 362 }
363 } 363 }
364 } 364 }
365 QStringList::Iterator itStr; 365 QStringList::Iterator itStr;
366 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { 366 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
367 if ( i == 3 ) 367 if ( i == 3 )
368 bNeedCarriage = TRUE; 368 bNeedCarriage = TRUE;
369 else 369 else
370 bNeedCarriage = FALSE; 370 bNeedCarriage = FALSE;
371 if ( str.isNull() ) 371 if ( str.isNull() )
372 str = *itStr; 372 str = *itStr;
373 else if ( i == list.count() - 1 ) { 373 else if ( i == list.count() - 1 ) {
374 if ( i < 2 ) 374 if ( i < 2 )
375 str += tr(" and ") + *itStr; 375 str += tr(" and ") + *itStr;
376 else { 376 else {
377 if ( bNeedCarriage ) 377 if ( bNeedCarriage )
378 str += tr( ",\nand " ) + *itStr; 378 str += tr( ",\nand " ) + *itStr;
379 else 379 else
380 str += tr( ", and " ) + *itStr; 380 str += tr( ", and " ) + *itStr;
381 } 381 }
382 } else { 382 } else {
383 if ( bNeedCarriage ) 383 if ( bNeedCarriage )
384 str += ",\n" + *itStr; 384 str += ",\n" + *itStr;
385 else 385 else
386 str += ", " + *itStr; 386 str += ", " + *itStr;
387 } 387 }
388 } 388 }
389 str = str.prepend( tr("on ") ); 389 str = str.prepend( tr("on ") );
390 390
391 lblWeekVar->setText( str ); 391 lblWeekVar->setText( str );
392} 392}
393void ORecurranceWidget::slotMonthLabel(int type) { 393void ORecurranceWidget::slotMonthLabel(int type) {
394 QString str; 394 QString str;
395 if ( currInterval != Month || type > 1 ) 395 if ( currInterval != Month || type > 1 )
396 return; 396 return;
397 if ( type == 1 ) 397 if ( type == 1 )
398 str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); 398 str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
399 else 399 else
400 str = strMonthDayTemplate.arg( numberPlacing(week(start))) 400 str = strMonthDayTemplate.arg( numberPlacing(week(start)))
401 .arg( dayLabel[start.dayOfWeek() - 1] ); 401 .arg( dayLabel[start.dayOfWeek() - 1] );
402 lblRepeat->setText( str ); 402 lblRepeat->setText( str );
403} 403}
404void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { 404void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) {
405 startWeekOnMonday = onMonday; 405 startWeekOnMonday = onMonday;
406 // we need to make this unintrusive as possible... 406 // we need to make this unintrusive as possible...
407 int saveSpin = spinFreq->value(); 407 int saveSpin = spinFreq->value();
408 char days = 0; 408 char days = 0;
409 int day; 409 int day;
410 QListIterator<QToolButton> itExtra( listExtra ); 410 QListIterator<QToolButton> itExtra( listExtra );
411 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { 411 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
412 if ( (*itExtra)->isOn() ) { 412 if ( (*itExtra)->isOn() ) {
413 if ( !startWeekOnMonday ) 413 if ( !startWeekOnMonday )
414 days |= day; 414 days |= day;
415 else { 415 else {
416 if ( day == 1 ) 416 if ( day == 1 )
417 days |= ORecur::SUN; 417 days |= ORecur::SUN;
418 else 418 else
419 days |= day >> 1; 419 days |= day >> 1;
420 } 420 }
421 } 421 }
422 } 422 }
423 setupWeekly(); 423 setupWeekly();
424 spinFreq->setValue( saveSpin ); 424 spinFreq->setValue( saveSpin );
425 int buttons; 425 int buttons;
426 for ( day = 0x01, buttons = 0; buttons < 7; 426 for ( day = 0x01, buttons = 0; buttons < 7;
427 day = day << 1, buttons++ ) { 427 day = day << 1, buttons++ ) {
428 if ( days & day ) { 428 if ( days & day ) {
429 if ( startWeekOnMonday ) 429 if ( startWeekOnMonday )
430 fraExtra->setButton( buttons ); 430 fraExtra->setButton( buttons );
431 else { 431 else {
432 if ( buttons == 7 ) 432 if ( buttons == 7 )
433 fraExtra->setButton( 0 ); 433 fraExtra->setButton( 0 );
434 else 434 else
435 fraExtra->setButton( buttons + 1 ); 435 fraExtra->setButton( buttons + 1 );
436 } 436 }
437 } 437 }
438 } 438 }
439 slotWeekLabel(); 439 slotWeekLabel();
440} 440}
441void ORecurranceWidget::setupNone() { 441void ORecurranceWidget::setupNone() {
442 lblRepeat->setText( tr("No Repeat") ); 442 lblRepeat->setText( tr("No Repeat") );
443 lblVar1->hide(); 443 lblVar1->hide();
444 lblVar2->hide(); 444 lblVar2->hide();
445 hideExtras(); 445 hideExtras();
446 cmdEnd->hide(); 446 cmdEnd->hide();
447 lblFreq->hide(); 447 lblFreq->hide();
448 lblEvery->hide(); 448 lblEvery->hide();
449 lblFreq->hide(); 449 lblFreq->hide();
450 spinFreq->hide(); 450 spinFreq->hide();
451 lblEnd->hide(); 451 lblEnd->hide();
452 lblWeekVar->hide(); 452 lblWeekVar->hide();
453} 453}
454void ORecurranceWidget::setupDaily() { 454void ORecurranceWidget::setupDaily() {
455 hideExtras(); 455 hideExtras();
456 lblWeekVar->hide(); 456 lblWeekVar->hide();
457 spinFreq->setValue( 1 ); 457 spinFreq->setValue( 1 );
458 lblFreq->setText( tr("day(s)") ); 458 lblFreq->setText( tr("day(s)") );
459 lblVar2->show(); 459 lblVar2->show();
460 showRepeatStuff(); 460 showRepeatStuff();
461 lblRepeat->setText( strDayTemplate ); 461 lblRepeat->setText( strDayTemplate );
462 setupRepeatLabel( 1 ); 462 setupRepeatLabel( 1 );
463} 463}
464void ORecurranceWidget::setupWeekly() { 464void ORecurranceWidget::setupWeekly() {
465// reshow the buttons... 465// reshow the buttons...
466 fraExtra->setTitle( tr("Repeat On") ); 466 fraExtra->setTitle( tr("Repeat On") );
467 fraExtra->setExclusive( FALSE ); 467 fraExtra->setExclusive( FALSE );
468 fraExtra->show(); 468 fraExtra->show();
469 if ( startWeekOnMonday ) { 469 if ( startWeekOnMonday ) {
470 cmdExtra1->setText( tr("Mon") ); 470 cmdExtra1->setText( tr("Mon") );
471 cmdExtra2->setText( tr("Tue") ); 471 cmdExtra2->setText( tr("Tue") );
472 cmdExtra3->setText( tr("Wed") ); 472 cmdExtra3->setText( tr("Wed") );
473 cmdExtra4->setText( tr("Thu") ); 473 cmdExtra4->setText( tr("Thu") );
474 cmdExtra5->setText( tr("Fri") ); 474 cmdExtra5->setText( tr("Fri") );
475 cmdExtra6->setText( tr("Sat") ); 475 cmdExtra6->setText( tr("Sat") );
476 cmdExtra7->setText( tr("Sun") ); 476 cmdExtra7->setText( tr("Sun") );
477 } else { 477 } else {
478 cmdExtra1->setText( tr("Sun") ); 478 cmdExtra1->setText( tr("Sun") );
479 cmdExtra2->setText( tr("Mon") ); 479 cmdExtra2->setText( tr("Mon") );
480 cmdExtra3->setText( tr("Tue") ); 480 cmdExtra3->setText( tr("Tue") );
481 cmdExtra4->setText( tr("Wed") ); 481 cmdExtra4->setText( tr("Wed") );
482 cmdExtra5->setText( tr("Thu") ); 482 cmdExtra5->setText( tr("Thu") );
483 cmdExtra6->setText( tr("Fri") ); 483 cmdExtra6->setText( tr("Fri") );
484 cmdExtra7->setText( tr("Sat") ); 484 cmdExtra7->setText( tr("Sat") );
485 } 485 }
486 // I hope clustering these improve performance.... 486 // I hope clustering these improve performance....
487 cmdExtra1->setOn( FALSE ); 487 cmdExtra1->setOn( FALSE );
488 cmdExtra2->setOn( FALSE ); 488 cmdExtra2->setOn( FALSE );
489 cmdExtra3->setOn( FALSE ); 489 cmdExtra3->setOn( FALSE );
490 cmdExtra4->setOn( FALSE ); 490 cmdExtra4->setOn( FALSE );
491 cmdExtra5->setOn( FALSE ); 491 cmdExtra5->setOn( FALSE );
492 cmdExtra6->setOn( FALSE ); 492 cmdExtra6->setOn( FALSE );
493 cmdExtra7->setOn( FALSE ); 493 cmdExtra7->setOn( FALSE );
494 494
495 cmdExtra1->show(); 495 cmdExtra1->show();
496 cmdExtra2->show(); 496 cmdExtra2->show();
497 cmdExtra3->show(); 497 cmdExtra3->show();
498 cmdExtra4->show(); 498 cmdExtra4->show();
499 cmdExtra5->show(); 499 cmdExtra5->show();
500 cmdExtra6->show(); 500 cmdExtra6->show();
501 cmdExtra7->show(); 501 cmdExtra7->show();
502 502
503 lblWeekVar->show(); 503 lblWeekVar->show();
504 spinFreq->setValue( 1 ); 504 spinFreq->setValue( 1 );
505 // might as well set the day too... 505 // might as well set the day too...
506 if ( startWeekOnMonday ) { 506 if ( startWeekOnMonday ) {
507 fraExtra->setButton( start.dayOfWeek() - 1 ); 507 fraExtra->setButton( start.dayOfWeek() - 1 );
508 } else { 508 } else {
509 fraExtra->setButton( start.dayOfWeek() % 7 ); 509 fraExtra->setButton( start.dayOfWeek() % 7 );
510 } 510 }
511 lblFreq->setText( tr("week(s)") ); 511 lblFreq->setText( tr("week(s)") );
512 lblVar2->show(); 512 lblVar2->show();
513 showRepeatStuff(); 513 showRepeatStuff();
514 setupRepeatLabel( 1 ); 514 setupRepeatLabel( 1 );
515} 515}
516void ORecurranceWidget::setupMonthly() { 516void ORecurranceWidget::setupMonthly() {
517 hideExtras(); 517 hideExtras();
518 lblWeekVar->hide(); 518 lblWeekVar->hide();
519 fraExtra->setTitle( tr("Repeat By") ); 519 fraExtra->setTitle( tr("Repeat By") );
520 fraExtra->setExclusive( TRUE ); 520 fraExtra->setExclusive( TRUE );
521 fraExtra->show(); 521 fraExtra->show();
522 cmdExtra1->setText( tr("Day") ); 522 cmdExtra1->setText( tr("Day") );
523 cmdExtra1->show(); 523 cmdExtra1->show();
524 cmdExtra2->setText( tr("Date") ); 524 cmdExtra2->setText( tr("Date") );
525 cmdExtra2->show(); 525 cmdExtra2->show();
526 spinFreq->setValue( 1 ); 526 spinFreq->setValue( 1 );
527 lblFreq->setText( tr("month(s)") ); 527 lblFreq->setText( tr("month(s)") );
528 lblVar2->show(); 528 lblVar2->show();
529 showRepeatStuff(); 529 showRepeatStuff();
530 setupRepeatLabel( 1 ); 530 setupRepeatLabel( 1 );
531} 531}
532void ORecurranceWidget::setupYearly() { 532void ORecurranceWidget::setupYearly() {
533hideExtras(); 533hideExtras();
534 lblWeekVar->hide(); 534 lblWeekVar->hide();
535 spinFreq->setValue( 1 ); 535 spinFreq->setValue( 1 );
536 lblFreq->setText( tr("year(s)") ); 536 lblFreq->setText( tr("year(s)") );
537 lblFreq->show(); 537 lblFreq->show();
538 lblFreq->show(); 538 lblFreq->show();
539 showRepeatStuff(); 539 showRepeatStuff();
540 lblVar2->show(); 540 lblVar2->show();
541 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); 541 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
542 lblRepeat->setText( strEvery ); 542 lblRepeat->setText( strEvery );
543 setupRepeatLabel( 1 ); 543 setupRepeatLabel( 1 );
544 544
545} 545}
546void ORecurranceWidget::init() { 546void ORecurranceWidget::init() {
547 QPopupMenu *m1 = new QPopupMenu( this ); 547 QPopupMenu *m1 = new QPopupMenu( this );
548 repeatPicker = new DateBookMonth( m1, 0, TRUE ); 548 repeatPicker = new DateBookMonth( m1, 0, TRUE );
549 m1->insertItem( repeatPicker ); 549 m1->insertItem( repeatPicker );
550 cmdEnd->setPopup( m1 ); 550 cmdEnd->setPopup( m1 );
551 cmdEnd->setPopupDelay( 0 ); 551 cmdEnd->setPopupDelay( 0 );
552 552
553 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), 553 QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)),
554 this, SLOT(endDateChanged(int, int, int)) ); 554 this, SLOT(endDateChanged(int,int,int)) );
555 QObject::connect( qApp, SIGNAL(weekChanged(bool)), 555 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
556 this, SLOT(slotChangeStartOfWeek(bool)) ); 556 this, SLOT(slotChangeStartOfWeek(bool)) );
557 557
558 listRTypeButtons.setAutoDelete( TRUE ); 558 listRTypeButtons.setAutoDelete( TRUE );
559 listRTypeButtons.append( cmdNone ); 559 listRTypeButtons.append( cmdNone );
560 listRTypeButtons.append( cmdDay ); 560 listRTypeButtons.append( cmdDay );
561 listRTypeButtons.append( cmdWeek ); 561 listRTypeButtons.append( cmdWeek );
562 listRTypeButtons.append( cmdMonth ); 562 listRTypeButtons.append( cmdMonth );
563 listRTypeButtons.append( cmdYear ); 563 listRTypeButtons.append( cmdYear );
564 564
565 listExtra.setAutoDelete( TRUE ); 565 listExtra.setAutoDelete( TRUE );
566 listExtra.append( cmdExtra1 ); 566 listExtra.append( cmdExtra1 );
567 listExtra.append( cmdExtra2 ); 567 listExtra.append( cmdExtra2 );
568 listExtra.append( cmdExtra3 ); 568 listExtra.append( cmdExtra3 );
569 listExtra.append( cmdExtra4 ); 569 listExtra.append( cmdExtra4 );
570 listExtra.append( cmdExtra5 ); 570 listExtra.append( cmdExtra5 );
571 listExtra.append( cmdExtra6 ); 571 listExtra.append( cmdExtra6 );
572 listExtra.append( cmdExtra7 ); 572 listExtra.append( cmdExtra7 );
573} 573}
574void ORecurranceWidget::hideExtras() { 574void ORecurranceWidget::hideExtras() {
575 // hide the extra buttons... 575 // hide the extra buttons...
576 fraExtra->hide(); 576 fraExtra->hide();
577 chkNoEnd->hide(); 577 chkNoEnd->hide();
578 QListIterator<QToolButton> it( listExtra ); 578 QListIterator<QToolButton> it( listExtra );
579 for ( ; *it; ++it ) { 579 for ( ; *it; ++it ) {
580 (*it)->hide(); 580 (*it)->hide();
581 (*it)->setOn( FALSE ); 581 (*it)->setOn( FALSE );
582 } 582 }
583} 583}
584void ORecurranceWidget::showRepeatStuff() { 584void ORecurranceWidget::showRepeatStuff() {
585 cmdEnd->show(); 585 cmdEnd->show();
586 chkNoEnd->show(); 586 chkNoEnd->show();
587 lblFreq->show(); 587 lblFreq->show();
588 lblEvery->show(); 588 lblEvery->show();
589 lblFreq->show(); 589 lblFreq->show();
590 spinFreq->show(); 590 spinFreq->show();
591 lblEnd->show(); 591 lblEnd->show();
592 lblRepeat->setText( tr("Every") ); 592 lblRepeat->setText( tr("Every") );
593} 593}
594 594
595 595
596static int week( const QDate &start ) 596static int week( const QDate &start )
597{ 597{
598 // figure out the week... 598 // figure out the week...
599 int stop = start.day(), 599 int stop = start.day(),
600 sentinel = start.dayOfWeek(), 600 sentinel = start.dayOfWeek(),
601 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), 601 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(),
602 week = 1, 602 week = 1,
603 i; 603 i;
604 for ( i = 1; i < stop; i++ ) { 604 for ( i = 1; i < stop; i++ ) {
605 if ( dayOfWeek++ == sentinel ) 605 if ( dayOfWeek++ == sentinel )
606 week++; 606 week++;
607 if ( dayOfWeek > 7 ) 607 if ( dayOfWeek > 7 )
608 dayOfWeek = 0; 608 dayOfWeek = 0;
609 } 609 }
610 return week; 610 return week;
611} 611}
612 612
613static QString numberPlacing( int x ) 613static QString numberPlacing( int x )
614{ 614{
615 // I hope this works in other languages besides english... 615 // I hope this works in other languages besides english...
616 QString str = QString::number( x ); 616 QString str = QString::number( x );
617 switch ( x % 10 ) { 617 switch ( x % 10 ) {
618 case 1: 618 case 1:
619 str += QWidget::tr( "st" ); 619 str += QWidget::tr( "st" );
620 break; 620 break;
621 case 2: 621 case 2:
622 str += QWidget::tr( "nd" ); 622 str += QWidget::tr( "nd" );
623 break; 623 break;
624 case 3: 624 case 3:
625 str += QWidget::tr( "rd" ); 625 str += QWidget::tr( "rd" );
626 break; 626 break;
627 default: 627 default:
628 str += QWidget::tr( "th" ); 628 str += QWidget::tr( "th" );
629 break; 629 break;
630 } 630 }
631 return str; 631 return str;
632} 632}
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp
index 3a9a5ec..52190b2 100644
--- a/libopie/otabwidget.cpp
+++ b/libopie/otabwidget.cpp
@@ -1,269 +1,269 @@
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#include "otabwidget.h" 32#include "otabwidget.h"
33 33
34#include <qpe/applnk.h> 34#include <qpe/applnk.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <opie/otabbar.h> 37#include <opie/otabbar.h>
38 38
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qwidgetstack.h> 40#include <qwidgetstack.h>
41 41
42OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) 42OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
43 : QWidget( parent, name ) 43 : QWidget( parent, name )
44{ 44{
45 if ( s == Global ) 45 if ( s == Global )
46 { 46 {
47 Config config( "qpe" ); 47 Config config( "qpe" );
48 config.setGroup( "Appearance" ); 48 config.setGroup( "Appearance" );
49 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); 49 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
50 if ( s <= Global || s > IconList) 50 if ( s <= Global || s > IconList)
51 { 51 {
52 s = IconTab; 52 s = IconTab;
53 } 53 }
54 QString pos = config.readEntry( "TabPosition", "Top"); 54 QString pos = config.readEntry( "TabPosition", "Top");
55 if ( pos == "Bottom" ) 55 if ( pos == "Bottom" )
56 { 56 {
57 p = Bottom; 57 p = Bottom;
58 } 58 }
59 else 59 else
60 { 60 {
61 p = Top; 61 p = Top;
62 } 62 }
63 } 63 }
64 64
65 widgetStack = new QWidgetStack( this, "widgetstack" ); 65 widgetStack = new QWidgetStack( this, "widgetstack" );
66 widgetStack->setFrameStyle( QFrame::NoFrame ); 66 widgetStack->setFrameStyle( QFrame::NoFrame );
67 widgetStack->setLineWidth( style().defaultFrameWidth() ); 67 widgetStack->setLineWidth( style().defaultFrameWidth() );
68 68
69 tabBarStack = new QWidgetStack( this, "tabbarstack" ); 69 tabBarStack = new QWidgetStack( this, "tabbarstack" );
70 70
71 tabBar = new OTabBar( tabBarStack, "tabbar" ); 71 tabBar = new OTabBar( tabBarStack, "tabbar" );
72 tabBarStack->addWidget( tabBar, 0 ); 72 tabBarStack->addWidget( tabBar, 0 );
73 connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) ); 73 connect( tabBar, SIGNAL( selected(int) ), this, SLOT( slotTabBarSelected(int) ) );
74 74
75 tabList = new QComboBox( false, tabBarStack, "tablist" ); 75 tabList = new QComboBox( false, tabBarStack, "tablist" );
76 tabBarStack->addWidget( tabList, 1 ); 76 tabBarStack->addWidget( tabList, 1 );
77 connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) ); 77 connect( tabList, SIGNAL( activated(int) ), this, SLOT( slotTabListSelected(int) ) );
78 78
79 tabBarPosition = p; 79 tabBarPosition = p;
80 setTabStyle( s ); 80 setTabStyle( s );
81 setTabPosition( p ); 81 setTabPosition( p );
82 82
83 currTab= 0x0; 83 currTab= 0x0;
84} 84}
85 85
86OTabWidget::~OTabWidget() 86OTabWidget::~OTabWidget()
87{ 87{
88} 88}
89 89
90void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 90void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
91{ 91{
92 QPixmap iconset = loadSmooth( icon ); 92 QPixmap iconset = loadSmooth( icon );
93 93
94 QTab *tab = new QTab(); 94 QTab *tab = new QTab();
95 if ( tabBarStyle == IconTab ) 95 if ( tabBarStyle == IconTab )
96 { 96 {
97 tab->label = QString::null; 97 tab->label = QString::null;
98 } 98 }
99 else 99 else
100 { 100 {
101 tab->label = label; 101 tab->label = label;
102 } 102 }
103 if ( tabBarStyle == IconTab || tabBarStyle == IconList ) 103 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
104 { 104 {
105 tab->iconset = new QIconSet( iconset ); 105 tab->iconset = new QIconSet( iconset );
106 } 106 }
107 int tabid = tabBar->addTab( tab ); 107 int tabid = tabBar->addTab( tab );
108 108
109 if ( tabBarStyle == IconTab || tabBarStyle == IconList ) 109 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
110 { 110 {
111 tabList->insertItem( iconset, label, -1 ); 111 tabList->insertItem( iconset, label, -1 );
112 } 112 }
113 else 113 else
114 { 114 {
115 tabList->insertItem( label ); 115 tabList->insertItem( label );
116 } 116 }
117 117
118 widgetStack->addWidget( child, tabid ); 118 widgetStack->addWidget( child, tabid );
119 widgetStack->raiseWidget( child ); 119 widgetStack->raiseWidget( child );
120 widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); 120 widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
121 121
122 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); 122 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
123 tabs.append( tabinfo ); 123 tabs.append( tabinfo );
124 selectTab( tabinfo ); 124 selectTab( tabinfo );
125} 125}
126 126
127void OTabWidget::removePage( QWidget *childwidget ) 127void OTabWidget::removePage( QWidget *childwidget )
128{ 128{
129 if ( childwidget ) 129 if ( childwidget )
130 { 130 {
131 OTabInfo *tab = tabs.first(); 131 OTabInfo *tab = tabs.first();
132 while ( tab && tab->control() != childwidget ) 132 while ( tab && tab->control() != childwidget )
133 { 133 {
134 tab = tabs.next(); 134 tab = tabs.next();
135 } 135 }
136 if ( tab && tab->control() == childwidget ) 136 if ( tab && tab->control() == childwidget )
137 { 137 {
138 tabBar->setTabEnabled( tab->id(), FALSE ); 138 tabBar->setTabEnabled( tab->id(), FALSE );
139 tabBar->removeTab( tabBar->tab( tab->id() ) ); 139 tabBar->removeTab( tabBar->tab( tab->id() ) );
140 int i = 0; 140 int i = 0;
141 while ( i < tabList->count() && tabList->text( i ) != tab->label() ) 141 while ( i < tabList->count() && tabList->text( i ) != tab->label() )
142 { 142 {
143 i++; 143 i++;
144 } 144 }
145 if ( tabList->text( i ) == tab->label() ) 145 if ( tabList->text( i ) == tab->label() )
146 { 146 {
147 tabList->removeItem( i ); 147 tabList->removeItem( i );
148 } 148 }
149 widgetStack->removeWidget( childwidget ); 149 widgetStack->removeWidget( childwidget );
150 tabs.remove( tab ); 150 tabs.remove( tab );
151 delete tab; 151 delete tab;
152 currTab = tabs.current(); 152 currTab = tabs.current();
153 if ( !currTab ) 153 if ( !currTab )
154 { 154 {
155 widgetStack->setFrameStyle( QFrame::NoFrame ); 155 widgetStack->setFrameStyle( QFrame::NoFrame );
156 } 156 }
157 157
158 setUpLayout(); 158 setUpLayout();
159 } 159 }
160 } 160 }
161} 161}
162 162
163void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) 163void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
164{ 164{
165 OTabInfo *currtab = tabs.first(); 165 OTabInfo *currtab = tabs.first();
166 while ( currtab && currtab->control() != widget ) 166 while ( currtab && currtab->control() != widget )
167 { 167 {
168 currtab = tabs.next(); 168 currtab = tabs.next();
169 } 169 }
170 if ( currtab && currtab->control() == widget ) 170 if ( currtab && currtab->control() == widget )
171 { 171 {
172 QTab *tab = tabBar->tab( currtab->id() ); 172 QTab *tab = tabBar->tab( currtab->id() );
173 QPixmap icon( loadSmooth( iconset ) ); 173 QPixmap icon( loadSmooth( iconset ) );
174 tab->setText( label ); 174 tab->setText( label );
175 if ( tabBarStyle == IconTab ) 175 if ( tabBarStyle == IconTab )
176 tab->setIconSet( icon ); 176 tab->setIconSet( icon );
177 int i = 0; 177 int i = 0;
178 while ( i < tabList->count() && tabList->text( i ) != currtab->label() ) 178 while ( i < tabList->count() && tabList->text( i ) != currtab->label() )
179 { 179 {
180 i++; 180 i++;
181 } 181 }
182 if ( i < tabList->count() && tabList->text( i ) == currtab->label() ) 182 if ( i < tabList->count() && tabList->text( i ) == currtab->label() )
183 { 183 {
184 if ( tabBarStyle == IconTab || tabBarStyle == IconList ) 184 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
185 { 185 {
186 tabList->changeItem( icon, label, i ); 186 tabList->changeItem( icon, label, i );
187 } 187 }
188 else 188 else
189 { 189 {
190 tabList->changeItem( label, i ); 190 tabList->changeItem( label, i );
191 } 191 }
192 } 192 }
193 currtab->setLabel( label ); 193 currtab->setLabel( label );
194 currtab->setIcon( iconset ); 194 currtab->setIcon( iconset );
195 } 195 }
196 setUpLayout(); 196 setUpLayout();
197} 197}
198 198
199void OTabWidget::setCurrentTab( QWidget *childwidget ) 199void OTabWidget::setCurrentTab( QWidget *childwidget )
200{ 200{
201 OTabInfo *currtab = tabs.first(); 201 OTabInfo *currtab = tabs.first();
202 while ( currtab && currtab->control() != childwidget ) 202 while ( currtab && currtab->control() != childwidget )
203 { 203 {
204 currtab = tabs.next(); 204 currtab = tabs.next();
205 } 205 }
206 if ( currtab && currtab->control() == childwidget ) 206 if ( currtab && currtab->control() == childwidget )
207 { 207 {
208 selectTab( currtab ); 208 selectTab( currtab );
209 } 209 }
210} 210}
211 211
212void OTabWidget::setCurrentTab( const QString &tabname ) 212void OTabWidget::setCurrentTab( const QString &tabname )
213{ 213{
214 OTabInfo *newtab = tabs.first(); 214 OTabInfo *newtab = tabs.first();
215 while ( newtab && newtab->label() != tabname ) 215 while ( newtab && newtab->label() != tabname )
216 { 216 {
217 newtab = tabs.next(); 217 newtab = tabs.next();
218 } 218 }
219 if ( newtab && newtab->label() == tabname ) 219 if ( newtab && newtab->label() == tabname )
220 { 220 {
221 selectTab( newtab ); 221 selectTab( newtab );
222 } 222 }
223} 223}
224 224
225void OTabWidget::setCurrentTab(int tabindex) { 225void OTabWidget::setCurrentTab(int tabindex) {
226 OTabInfo *newtab = tabs.first(); 226 OTabInfo *newtab = tabs.first();
227 while ( newtab && newtab->id() != tabindex ) 227 while ( newtab && newtab->id() != tabindex )
228 { 228 {
229 newtab = tabs.next(); 229 newtab = tabs.next();
230 } 230 }
231 if ( newtab && newtab->id() == tabindex ) 231 if ( newtab && newtab->id() == tabindex )
232 { 232 {
233 selectTab( newtab ); 233 selectTab( newtab );
234 } 234 }
235} 235}
236 236
237 237
238OTabWidget::TabStyle OTabWidget::tabStyle() const 238OTabWidget::TabStyle OTabWidget::tabStyle() const
239{ 239{
240 return tabBarStyle; 240 return tabBarStyle;
241} 241}
242 242
243void OTabWidget::setTabStyle( TabStyle s ) 243void OTabWidget::setTabStyle( TabStyle s )
244{ 244{
245 tabBarStyle = s; 245 tabBarStyle = s;
246 if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) 246 if ( tabBarStyle == TextTab || tabBarStyle == IconTab )
247 { 247 {
248 QTab *currtab; 248 QTab *currtab;
249 for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) 249 for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() )
250 { 250 {
251 currtab = tabBar->tab( tabinfo->id() ); 251 currtab = tabBar->tab( tabinfo->id() );
252 if ( tabBarStyle == IconTab ) 252 if ( tabBarStyle == IconTab )
253 { 253 {
254 currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); 254 currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) );
255 if ( tabinfo == currTab ) 255 if ( tabinfo == currTab )
256 currtab->setText( tabinfo->label() ); 256 currtab->setText( tabinfo->label() );
257 else 257 else
258 currtab->setText( QString::null ); 258 currtab->setText( QString::null );
259 } 259 }
260 else 260 else
261 { 261 {
262 currtab->iconset = 0x0; 262 currtab->iconset = 0x0;
263 currtab->setText( tabinfo->label() ); 263 currtab->setText( tabinfo->label() );
264 } 264 }
265 } 265 }
266 tabBarStack->raiseWidget( tabBar ); 266 tabBarStack->raiseWidget( tabBar );
267 } 267 }
268 else if ( tabBarStyle == TextList || tabBarStyle == IconList ) 268 else if ( tabBarStyle == TextList || tabBarStyle == IconList )
269 { 269 {
diff --git a/libopie/otimepicker.cpp b/libopie/otimepicker.cpp
index 1eca7c5..11b80ed 100644
--- a/libopie/otimepicker.cpp
+++ b/libopie/otimepicker.cpp
@@ -1,242 +1,242 @@
1#include "otimepicker.h" 1#include "otimepicker.h"
2 2
3#include <qlayout.h> 3#include <qlayout.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6 6
7 7
8/** 8/**
9 * Constructs the widget 9 * Constructs the widget
10 * @param parent The parent of the OTimePicker 10 * @param parent The parent of the OTimePicker
11 * @param name The name of the object 11 * @param name The name of the object
12 * @param fl Window Flags 12 * @param fl Window Flags
13 */ 13 */
14OTimePicker::OTimePicker(QWidget* parent, const char* name, 14OTimePicker::OTimePicker(QWidget* parent, const char* name,
15 WFlags fl) : 15 WFlags fl) :
16 QWidget(parent,name,fl) 16 QWidget(parent,name,fl)
17{ 17{
18 18
19 QVBoxLayout *vbox=new QVBoxLayout(this); 19 QVBoxLayout *vbox=new QVBoxLayout(this);
20 20
21 OClickableLabel *r; 21 OClickableLabel *r;
22 QString s; 22 QString s;
23 23
24 // Hour Row 24 // Hour Row
25 QWidget *row=new QWidget(this); 25 QWidget *row=new QWidget(this);
26 QHBoxLayout *l=new QHBoxLayout(row); 26 QHBoxLayout *l=new QHBoxLayout(row);
27 vbox->addWidget(row); 27 vbox->addWidget(row);
28 28
29 29
30 for (int i=0; i<24; i++) { 30 for (int i=0; i<24; i++) {
31 r=new OClickableLabel(row); 31 r=new OClickableLabel(row);
32 hourLst.append(r); 32 hourLst.append(r);
33 s.sprintf("%.2d",i); 33 s.sprintf("%.2d",i);
34 r->setText(s); 34 r->setText(s);
35 r->setToggleButton(true); 35 r->setToggleButton(true);
36 r->setAlignment(AlignHCenter | AlignVCenter); 36 r->setAlignment(AlignHCenter | AlignVCenter);
37 l->addWidget(r); 37 l->addWidget(r);
38 connect(r, SIGNAL(toggled(bool)), 38 connect(r, SIGNAL(toggled(bool)),
39 this, SLOT(slotHour(bool))); 39 this, SLOT(slotHour(bool)));
40 40
41 if (i==11) { // Second row 41 if (i==11) { // Second row
42 row=new QWidget(this); 42 row=new QWidget(this);
43 l=new QHBoxLayout(row); 43 l=new QHBoxLayout(row);
44 vbox->addWidget(row); 44 vbox->addWidget(row);
45 } 45 }
46 } 46 }
47 47
48 // Minute Row 48 // Minute Row
49 row=new QWidget(this); 49 row=new QWidget(this);
50 l=new QHBoxLayout(row); 50 l=new QHBoxLayout(row);
51 vbox->addWidget(row); 51 vbox->addWidget(row);
52 52
53 for (int i=0; i<60; i+=5) { 53 for (int i=0; i<60; i+=5) {
54 r=new OClickableLabel(row); 54 r=new OClickableLabel(row);
55 minuteLst.append(r); 55 minuteLst.append(r);
56 s.sprintf("%.2d",i); 56 s.sprintf("%.2d",i);
57 r->setText(s); 57 r->setText(s);
58 r->setToggleButton(true); 58 r->setToggleButton(true);
59 r->setAlignment(AlignHCenter | AlignVCenter); 59 r->setAlignment(AlignHCenter | AlignVCenter);
60 l->addWidget(r); 60 l->addWidget(r);
61 connect(r, SIGNAL(toggled(bool)), 61 connect(r, SIGNAL(toggled(bool)),
62 this, SLOT(slotMinute(bool))); 62 this, SLOT(slotMinute(bool)));
63 } 63 }
64} 64}
65 65
66/** 66/**
67 * This method return the current time 67 * This method return the current time
68 * @return the time 68 * @return the time
69 */ 69 */
70QTime OTimePicker::time()const { 70QTime OTimePicker::time()const {
71 return tm; 71 return tm;
72} 72}
73 73
74void OTimePicker::slotHour(bool b) { 74void OTimePicker::slotHour(bool b) {
75 75
76 OClickableLabel *r = (OClickableLabel *) sender(); 76 OClickableLabel *r = (OClickableLabel *) sender();
77 77
78 if (b) { 78 if (b) {
79 QValueListIterator<OClickableLabel *> it; 79 QValueListIterator<OClickableLabel *> it;
80 for (it=hourLst.begin(); it!=hourLst.end(); it++) { 80 for (it=hourLst.begin(); it!=hourLst.end(); it++) {
81 if (*it != r) (*it)->setOn(false); 81 if (*it != r) (*it)->setOn(false);
82 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); 82 else tm.setHMS((*it)->text().toInt(), tm.minute(), 0);
83 } 83 }
84 emit timeChanged(tm); 84 emit timeChanged(tm);
85 } else { 85 } else {
86 r->setOn(true); 86 r->setOn(true);
87 } 87 }
88 88
89} 89}
90 90
91void OTimePicker::slotMinute(bool b) { 91void OTimePicker::slotMinute(bool b) {
92 92
93 OClickableLabel *r = (OClickableLabel *) sender(); 93 OClickableLabel *r = (OClickableLabel *) sender();
94 94
95 if (b) { 95 if (b) {
96 QValueListIterator<OClickableLabel *> it; 96 QValueListIterator<OClickableLabel *> it;
97 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { 97 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) {
98 if (*it != r) (*it)->setOn(false); 98 if (*it != r) (*it)->setOn(false);
99 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); 99 else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0);
100 } 100 }
101 emit timeChanged(tm); 101 emit timeChanged(tm);
102 } else { 102 } else {
103 r->setOn(true); 103 r->setOn(true);
104 } 104 }
105 105
106} 106}
107 107
108/** 108/**
109 * Method to set the time. No signal gets emitted during this method call 109 * Method to set the time. No signal gets emitted during this method call
110 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) 110 * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... )
111 * @param t The time to be set 111 * @param t The time to be set
112 */ 112 */
113void OTimePicker::setTime( const QTime& t) { 113void OTimePicker::setTime( const QTime& t) {
114 setTime( t.hour(), t.minute() ); 114 setTime( t.hour(), t.minute() );
115} 115}
116 116
117/** 117/**
118 * Method to set the time. No signal gets emitted during this method call 118 * Method to set the time. No signal gets emitted during this method call
119 * @param h The hour 119 * @param h The hour
120 * @param m The minute. Minutes need to set by 5 minute steps 120 * @param m The minute. Minutes need to set by 5 minute steps
121 */ 121 */
122void OTimePicker::setTime( int h, int m ) { 122void OTimePicker::setTime( int h, int m ) {
123 setHour(h); 123 setHour(h);
124 setMinute(m); 124 setMinute(m);
125} 125}
126 126
127/* 127/*
128 * FIXME round minutes to the 5 minute arrangement -zecke 128 * FIXME round minutes to the 5 minute arrangement -zecke
129 */ 129 */
130/** 130/**
131 * Method to set the minutes 131 * Method to set the minutes
132 * @param m minutes 132 * @param m minutes
133 */ 133 */
134void OTimePicker::setMinute(int m) { 134void OTimePicker::setMinute(int m) {
135 135
136 QString minute; 136 QString minute;
137 minute.sprintf("%.2d",m); 137 minute.sprintf("%.2d",m);
138 138
139 QValueListIterator<OClickableLabel *> it; 139 QValueListIterator<OClickableLabel *> it;
140 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { 140 for (it=minuteLst.begin(); it!=minuteLst.end(); it++) {
141 if ((*it)->text() == minute) (*it)->setOn(true); 141 if ((*it)->text() == minute) (*it)->setOn(true);
142 else (*it)->setOn(false); 142 else (*it)->setOn(false);
143 } 143 }
144 144
145 tm.setHMS(tm.hour(),m,0); 145 tm.setHMS(tm.hour(),m,0);
146} 146}
147 147
148/** 148/**
149 * Method to set the hour 149 * Method to set the hour
150 */ 150 */
151void OTimePicker::setHour(int h) { 151void OTimePicker::setHour(int h) {
152 152
153 QString hour; 153 QString hour;
154 hour.sprintf("%.2d",h); 154 hour.sprintf("%.2d",h);
155 155
156 QValueListIterator<OClickableLabel *> it; 156 QValueListIterator<OClickableLabel *> it;
157 for (it=hourLst.begin(); it!=hourLst.end(); it++) { 157 for (it=hourLst.begin(); it!=hourLst.end(); it++) {
158 if ((*it)->text() == hour) (*it)->setOn(true); 158 if ((*it)->text() == hour) (*it)->setOn(true);
159 else (*it)->setOn(false); 159 else (*it)->setOn(false);
160 } 160 }
161 tm.setHMS(h,tm.minute(),0); 161 tm.setHMS(h,tm.minute(),0);
162} 162}
163 163
164 164
165/** 165/**
166 * This is a modal Dialog. 166 * This is a modal Dialog.
167 * 167 *
168 * @param parent The parent widget 168 * @param parent The parent widget
169 * @param name The name of the object 169 * @param name The name of the object
170 * @param fl Possible window flags 170 * @param fl Possible window flags
171 */ 171 */
172OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) 172OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl )
173 : OTimePickerDialogBase (parent , name, true , fl) 173 : OTimePickerDialogBase (parent , name, true , fl)
174{ 174{
175 175
176 connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), 176 connect ( m_timePicker, SIGNAL( timeChanged(const QTime&) ),
177 this, SLOT( setTime ( const QTime& ) ) ); 177 this, SLOT( setTime(const QTime&) ) );
178 connect ( minuteField, SIGNAL( textChanged ( const QString& ) ), 178 connect ( minuteField, SIGNAL( textChanged(const QString&) ),
179 this, SLOT ( setMinute ( const QString& ) ) ); 179 this, SLOT ( setMinute(const QString&) ) );
180 connect ( hourField, SIGNAL( textChanged ( const QString& ) ), 180 connect ( hourField, SIGNAL( textChanged(const QString&) ),
181 this, SLOT ( setHour ( const QString& ) ) ); 181 this, SLOT ( setHour(const QString&) ) );
182 182
183} 183}
184 184
185/** 185/**
186 * @return the time 186 * @return the time
187 */ 187 */
188QTime OTimePickerDialog::time()const 188QTime OTimePickerDialog::time()const
189{ 189{
190 return m_time; 190 return m_time;
191} 191}
192 192
193/** 193/**
194 * Set the time to time 194 * Set the time to time
195 * @param time The time to be set 195 * @param time The time to be set
196 */ 196 */
197void OTimePickerDialog::setTime( const QTime& time ) 197void OTimePickerDialog::setTime( const QTime& time )
198{ 198{
199 m_time = time; 199 m_time = time;
200 200
201 m_timePicker->setHour ( time.hour() ); 201 m_timePicker->setHour ( time.hour() );
202 m_timePicker->setMinute( time.minute() ); 202 m_timePicker->setMinute( time.minute() );
203 203
204 // Set Textfields 204 // Set Textfields
205 if ( time.hour() < 10 ) 205 if ( time.hour() < 10 )
206 hourField->setText( "0" + QString::number( time.hour() ) ); 206 hourField->setText( "0" + QString::number( time.hour() ) );
207 else 207 else
208 hourField->setText( QString::number( time.hour() ) ); 208 hourField->setText( QString::number( time.hour() ) );
209 209
210 if ( time.minute() < 10 ) 210 if ( time.minute() < 10 )
211 minuteField->setText( "0" + QString::number( time.minute() ) ); 211 minuteField->setText( "0" + QString::number( time.minute() ) );
212 else 212 else
213 minuteField->setText( QString::number( time.minute() ) ); 213 minuteField->setText( QString::number( time.minute() ) );
214 214
215} 215}
216 216
217/** 217/**
218 * This method takes the current minute and tries to set hour 218 * This method takes the current minute and tries to set hour
219 * to hour. This succeeds if the resulting date is valid 219 * to hour. This succeeds if the resulting date is valid
220 * @param hour The hour as a string 220 * @param hour The hour as a string
221 */ 221 */
222void OTimePickerDialog::setHour ( const QString& hour ) 222void OTimePickerDialog::setHour ( const QString& hour )
223{ 223{
224 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){ 224 if ( QTime::isValid ( hour.toInt(), m_time.minute() , 00 ) ){
225 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 ); 225 m_time.setHMS ( hour.toInt(), m_time.minute() , 00 );
226 setTime ( m_time ); 226 setTime ( m_time );
227 } 227 }
228 228
229} 229}
230 230
231/** 231/**
232 * Method to set a new minute. It tries to convert the string to int and 232 * Method to set a new minute. It tries to convert the string to int and
233 * if the resulting date is valid a new date is set. 233 * if the resulting date is valid a new date is set.
234 * @see setHour 234 * @see setHour
235 */ 235 */
236void OTimePickerDialog::setMinute ( const QString& minute ) 236void OTimePickerDialog::setMinute ( const QString& minute )
237{ 237{
238 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){ 238 if ( QTime::isValid ( m_time.hour(), minute.toInt(), 00 ) ){
239 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 ); 239 m_time.setHMS ( m_time.hour(), minute.toInt(), 00 );
240 setTime ( m_time ); 240 setTime ( m_time );
241 } 241 }
242} 242}
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
index 2e3ec1f..bc359f7 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/libopie/pim/ocontactaccess.cpp
@@ -1,168 +1,173 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.9 2004/03/02 12:14:22 alwin
25 * run the optimize_connect script
26 * the whole cvs is tagged with "before_optimize_connect" if there are problems you
27 * can check the diff (but it had compiled and run here)
28 *
24 * Revision 1.8 2003/05/08 13:55:09 tille 29 * Revision 1.8 2003/05/08 13:55:09 tille
25 * search stuff 30 * search stuff
26 * and match, toRichText & toShortText in oevent 31 * and match, toRichText & toShortText in oevent
27 * 32 *
28 * Revision 1.7 2002/11/13 14:14:51 eilers 33 * Revision 1.7 2002/11/13 14:14:51 eilers
29 * Added sorted for Contacts.. 34 * Added sorted for Contacts..
30 * 35 *
31 * Revision 1.6 2002/11/01 15:10:42 eilers 36 * Revision 1.6 2002/11/01 15:10:42 eilers
32 * Added regExp-search in database for all fields in a contact. 37 * Added regExp-search in database for all fields in a contact.
33 * 38 *
34 * Revision 1.5 2002/10/16 10:52:40 eilers 39 * Revision 1.5 2002/10/16 10:52:40 eilers
35 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 40 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
36 * 41 *
37 * Revision 1.4 2002/10/14 16:21:54 eilers 42 * Revision 1.4 2002/10/14 16:21:54 eilers
38 * Some minor interface updates 43 * Some minor interface updates
39 * 44 *
40 * Revision 1.3 2002/10/07 17:34:24 eilers 45 * Revision 1.3 2002/10/07 17:34:24 eilers
41 * added OBackendFactory for advanced backend access 46 * added OBackendFactory for advanced backend access
42 * 47 *
43 * Revision 1.2 2002/10/02 16:18:11 eilers 48 * Revision 1.2 2002/10/02 16:18:11 eilers
44 * debugged and seems to work almost perfectly .. 49 * debugged and seems to work almost perfectly ..
45 * 50 *
46 * Revision 1.1 2002/09/27 17:11:44 eilers 51 * Revision 1.1 2002/09/27 17:11:44 eilers
47 * Added API for accessing the Contact-Database ! It is compiling, but 52 * Added API for accessing the Contact-Database ! It is compiling, but
48 * please do not expect that anything is working ! 53 * please do not expect that anything is working !
49 * I will debug that stuff in the next time .. 54 * I will debug that stuff in the next time ..
50 * Please read README_COMPILE for compiling ! 55 * Please read README_COMPILE for compiling !
51 * 56 *
52 * 57 *
53 */ 58 */
54 59
55#include "ocontactaccess.h" 60#include "ocontactaccess.h"
56#include "obackendfactory.h" 61#include "obackendfactory.h"
57 62
58#include <qasciidict.h> 63#include <qasciidict.h>
59#include <qdatetime.h> 64#include <qdatetime.h>
60#include <qfile.h> 65#include <qfile.h>
61#include <qregexp.h> 66#include <qregexp.h>
62#include <qlist.h> 67#include <qlist.h>
63#include <qcopchannel_qws.h> 68#include <qcopchannel_qws.h>
64 69
65//#include <qpe/qcopenvelope_qws.h> 70//#include <qpe/qcopenvelope_qws.h>
66#include <qpe/global.h> 71#include <qpe/global.h>
67 72
68#include <errno.h> 73#include <errno.h>
69#include <fcntl.h> 74#include <fcntl.h>
70#include <unistd.h> 75#include <unistd.h>
71#include <stdlib.h> 76#include <stdlib.h>
72 77
73#include "ocontactaccessbackend_xml.h" 78#include "ocontactaccessbackend_xml.h"
74 79
75 80
76OContactAccess::OContactAccess ( const QString appname, const QString , 81OContactAccess::OContactAccess ( const QString appname, const QString ,
77 OContactAccessBackend* end, bool autosync ): 82 OContactAccessBackend* end, bool autosync ):
78 OPimAccessTemplate<OContact>( end ) 83 OPimAccessTemplate<OContact>( end )
79{ 84{
80 /* take care of the backend. If there is no one defined, we 85 /* take care of the backend. If there is no one defined, we
81 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 86 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
82 */ 87 */
83 if( end == 0 ) { 88 if( end == 0 ) {
84 qWarning ("Using BackendFactory !"); 89 qWarning ("Using BackendFactory !");
85 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 90 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
86 } 91 }
87 // Set backend locally and in template 92 // Set backend locally and in template
88 m_backEnd = end; 93 m_backEnd = end;
89 OPimAccessTemplate<OContact>::setBackEnd (end); 94 OPimAccessTemplate<OContact>::setBackEnd (end);
90 95
91 96
92 /* Connect signal of external db change to function */ 97 /* Connect signal of external db change to function */
93 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 98 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
94 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 99 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)),
95 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 100 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
96 if ( autosync ){ 101 if ( autosync ){
97 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 102 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
98 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 103 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 104 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
100 } 105 }
101 106
102 107
103} 108}
104OContactAccess::~OContactAccess () 109OContactAccess::~OContactAccess ()
105{ 110{
106 /* The user may forget to save the changed database, therefore try to 111 /* The user may forget to save the changed database, therefore try to
107 * do it for him.. 112 * do it for him..
108 */ 113 */
109 save(); 114 save();
110 // delete m_backEnd; is done by template.. 115 // delete m_backEnd; is done by template..
111} 116}
112 117
113 118
114bool OContactAccess::save () 119bool OContactAccess::save ()
115{ 120{
116 /* If the database was changed externally, we could not save the 121 /* If the database was changed externally, we could not save the
117 * Data. This will remove added items which is unacceptable ! 122 * Data. This will remove added items which is unacceptable !
118 * Therefore: Reload database and merge the data... 123 * Therefore: Reload database and merge the data...
119 */ 124 */
120 if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) 125 if ( OPimAccessTemplate<OContact>::wasChangedExternally() )
121 reload(); 126 reload();
122 127
123 bool status = OPimAccessTemplate<OContact>::save(); 128 bool status = OPimAccessTemplate<OContact>::save();
124 if ( !status ) return false; 129 if ( !status ) return false;
125 130
126 /* Now tell everyone that new data is available. 131 /* Now tell everyone that new data is available.
127 */ 132 */
128 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 133 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
129 134
130 return true; 135 return true;
131} 136}
132 137
133const uint OContactAccess::querySettings() 138const uint OContactAccess::querySettings()
134{ 139{
135 return ( m_backEnd->querySettings() ); 140 return ( m_backEnd->querySettings() );
136} 141}
137 142
138bool OContactAccess::hasQuerySettings ( int querySettings ) const 143bool OContactAccess::hasQuerySettings ( int querySettings ) const
139{ 144{
140 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 145 return ( m_backEnd->hasQuerySettings ( querySettings ) );
141} 146}
142ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 147ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
143{ 148{
144 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 149 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
145 return ( ORecordList<OContact>(matchingContacts, this) ); 150 return ( ORecordList<OContact>(matchingContacts, this) );
146} 151}
147 152
148 153
149bool OContactAccess::wasChangedExternally()const 154bool OContactAccess::wasChangedExternally()const
150{ 155{
151 return ( m_backEnd->wasChangedExternally() ); 156 return ( m_backEnd->wasChangedExternally() );
152} 157}
153 158
154 159
155void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) 160void OContactAccess::copMessage( const QCString &msg, const QByteArray & )
156{ 161{
157 if ( msg == "addressbookUpdated()" ){ 162 if ( msg == "addressbookUpdated()" ){
158 qWarning ("OContactAccess: Received addressbokUpdated()"); 163 qWarning ("OContactAccess: Received addressbokUpdated()");
159 emit signalChanged ( this ); 164 emit signalChanged ( this );
160 } else if ( msg == "flush()" ) { 165 } else if ( msg == "flush()" ) {
161 qWarning ("OContactAccess: Received flush()"); 166 qWarning ("OContactAccess: Received flush()");
162 save (); 167 save ();
163 } else if ( msg == "reload()" ) { 168 } else if ( msg == "reload()" ) {
164 qWarning ("OContactAccess: Received reload()"); 169 qWarning ("OContactAccess: Received reload()");
165 reload (); 170 reload ();
166 emit signalChanged ( this ); 171 emit signalChanged ( this );
167 } 172 }
168} 173}
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp
index 2739e26..99a0333 100644
--- a/libopie/pim/opimmainwindow.cpp
+++ b/libopie/pim/opimmainwindow.cpp
@@ -1,150 +1,150 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <qdatetime.h> 2#include <qdatetime.h>
3#include <qcopchannel_qws.h> 3#include <qcopchannel_qws.h>
4 4
5#include <qpe/sound.h> 5#include <qpe/sound.h>
6#include <qpe/qcopenvelope_qws.h> 6#include <qpe/qcopenvelope_qws.h>
7#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
8 8
9#include "opimresolver.h" 9#include "opimresolver.h"
10#include "opimmainwindow.h" 10#include "opimmainwindow.h"
11 11
12OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, 12OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
13 const char* name, WFlags flag ) 13 const char* name, WFlags flag )
14 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { 14 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) {
15 15
16 /* 16 /*
17 * let's generate our QCopChannel 17 * let's generate our QCopChannel
18 */ 18 */
19 m_str = QString("QPE/"+m_service).local8Bit(); 19 m_str = QString("QPE/"+m_service).local8Bit();
20 m_channel= new QCopChannel(m_str, this ); 20 m_channel= new QCopChannel(m_str, this );
21 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), 21 connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&) ),
22 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 22 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
23 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), 23 connect(qApp, SIGNAL(appMessage(const QCString&,const QByteArray&) ),
24 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 24 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
25 25
26 /* connect flush and reload */ 26 /* connect flush and reload */
27 connect(qApp, SIGNAL(flush() ), 27 connect(qApp, SIGNAL(flush() ),
28 this, SLOT(flush() ) ); 28 this, SLOT(flush() ) );
29 connect(qApp, SIGNAL(reload() ), 29 connect(qApp, SIGNAL(reload() ),
30 this, SLOT(reload() ) ); 30 this, SLOT(reload() ) );
31} 31}
32OPimMainWindow::~OPimMainWindow() { 32OPimMainWindow::~OPimMainWindow() {
33 delete m_channel; 33 delete m_channel;
34} 34}
35QCopChannel* OPimMainWindow::channel() { 35QCopChannel* OPimMainWindow::channel() {
36 return m_channel; 36 return m_channel;
37} 37}
38void OPimMainWindow::doSetDocument( const QString& ) { 38void OPimMainWindow::doSetDocument( const QString& ) {
39 39
40} 40}
41void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { 41void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
42 bool needShow = false; 42 bool needShow = false;
43 /* 43 /*
44 * create demands to create 44 * create demands to create
45 * a new record... 45 * a new record...
46 */ 46 */
47 QDataStream stream(array, IO_ReadOnly); 47 QDataStream stream(array, IO_ReadOnly);
48 if ( cmd == "create()" ) { 48 if ( cmd == "create()" ) {
49 raise(); 49 raise();
50 int uid = create(); 50 int uid = create();
51 QCopEnvelope e(m_str, "created(int)" ); 51 QCopEnvelope e(m_str, "created(int)" );
52 e << uid; 52 e << uid;
53 needShow = true; 53 needShow = true;
54 }else if ( cmd == "remove(int)" ) { 54 }else if ( cmd == "remove(int)" ) {
55 int uid; 55 int uid;
56 stream >> uid; 56 stream >> uid;
57 bool rem = remove( uid ); 57 bool rem = remove( uid );
58 QCopEnvelope e(m_str, "removed(bool)" ); 58 QCopEnvelope e(m_str, "removed(bool)" );
59 e << rem; 59 e << rem;
60 needShow = true; 60 needShow = true;
61 }else if ( cmd == "beam(int)" ) { 61 }else if ( cmd == "beam(int)" ) {
62 int uid; 62 int uid;
63 stream >> uid; 63 stream >> uid;
64 beam( uid); 64 beam( uid);
65 }else if ( cmd == "show(int)" ) { 65 }else if ( cmd == "show(int)" ) {
66 raise(); 66 raise();
67 int uid; 67 int uid;
68 stream >> uid; 68 stream >> uid;
69 show( uid ); 69 show( uid );
70 needShow = true; 70 needShow = true;
71 }else if ( cmd == "edit(int)" ) { 71 }else if ( cmd == "edit(int)" ) {
72 raise(); 72 raise();
73 int uid; 73 int uid;
74 stream >> uid; 74 stream >> uid;
75 edit( uid ); 75 edit( uid );
76 }else if ( cmd == "add(int,QByteArray)" ) { 76 }else if ( cmd == "add(int,QByteArray)" ) {
77 int rtti; 77 int rtti;
78 QByteArray array; 78 QByteArray array;
79 stream >> rtti; 79 stream >> rtti;
80 stream >> array; 80 stream >> array;
81 m_fallBack = record(rtti, array ); 81 m_fallBack = record(rtti, array );
82 if (!m_fallBack) return; 82 if (!m_fallBack) return;
83 add( *m_fallBack ); 83 add( *m_fallBack );
84 delete m_fallBack; 84 delete m_fallBack;
85 }else if ( cmd == "alarm(QDateTime,int)" ) { 85 }else if ( cmd == "alarm(QDateTime,int)" ) {
86 raise(); 86 raise();
87 QDateTime dt; int uid; 87 QDateTime dt; int uid;
88 stream >> dt; 88 stream >> dt;
89 stream >> uid; 89 stream >> uid;
90 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); 90 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid );
91 QDateTime current = QDateTime::currentDateTime(); 91 QDateTime current = QDateTime::currentDateTime();
92 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) 92 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() )
93 return; 93 return;
94 doAlarm( dt, uid ); 94 doAlarm( dt, uid );
95 needShow = true; 95 needShow = true;
96 } 96 }
97 97
98 if (needShow ) 98 if (needShow )
99 QPEApplication::setKeepRunning(); 99 QPEApplication::setKeepRunning();
100} 100}
101/* implement the url scripting here */ 101/* implement the url scripting here */
102void OPimMainWindow::setDocument( const QString& str) { 102void OPimMainWindow::setDocument( const QString& str) {
103 doSetDocument( str ); 103 doSetDocument( str );
104} 104}
105/* 105/*
106 * we now try to get the array demarshalled 106 * we now try to get the array demarshalled
107 * check if the rtti matches this one 107 * check if the rtti matches this one
108 */ 108 */
109OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { 109OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) {
110 if ( service() != rtti ) 110 if ( service() != rtti )
111 return 0l; 111 return 0l;
112 112
113 OPimRecord* record = OPimResolver::self()->record( rtti ); 113 OPimRecord* record = OPimResolver::self()->record( rtti );
114 QDataStream str(array, IO_ReadOnly ); 114 QDataStream str(array, IO_ReadOnly );
115 if ( !record || !record->loadFromStream(str) ) { 115 if ( !record || !record->loadFromStream(str) ) {
116 delete record; 116 delete record;
117 record = 0l; 117 record = 0l;
118 } 118 }
119 119
120 return record; 120 return record;
121} 121}
122/* 122/*
123 * get the rtti for the service 123 * get the rtti for the service
124 */ 124 */
125int OPimMainWindow::service() { 125int OPimMainWindow::service() {
126 if ( m_rtti == -1 ) 126 if ( m_rtti == -1 )
127 m_rtti = OPimResolver::self()->serviceId( m_service ); 127 m_rtti = OPimResolver::self()->serviceId( m_service );
128 128
129 return m_rtti; 129 return m_rtti;
130} 130}
131void OPimMainWindow::doAlarm( const QDateTime&, int ) { 131void OPimMainWindow::doAlarm( const QDateTime&, int ) {
132 132
133} 133}
134void OPimMainWindow::startAlarm(int count ) { 134void OPimMainWindow::startAlarm(int count ) {
135 m_alarmCount = count; 135 m_alarmCount = count;
136 m_playedCount = 0; 136 m_playedCount = 0;
137 Sound::soundAlarm(); 137 Sound::soundAlarm();
138 m_timerId = startTimer( 5000 ); 138 m_timerId = startTimer( 5000 );
139} 139}
140void OPimMainWindow::killAlarm() { 140void OPimMainWindow::killAlarm() {
141 killTimer( m_timerId ); 141 killTimer( m_timerId );
142} 142}
143void OPimMainWindow::timerEvent( QTimerEvent* e) { 143void OPimMainWindow::timerEvent( QTimerEvent* e) {
144 if ( m_playedCount <m_alarmCount ) { 144 if ( m_playedCount <m_alarmCount ) {
145 m_playedCount++; 145 m_playedCount++;
146 Sound::soundAlarm(); 146 Sound::soundAlarm();
147 }else { 147 }else {
148 killTimer( e->timerId() ); 148 killTimer( e->timerId() );
149 } 149 }
150} 150}